Initial commit: SDI SaaS Platform foundation

- Complete monorepo structure with pnpm workspaces
- Prisma database schema with 20+ entities
- NestJS API with 9 core modules
- BullMQ orchestration worker
- AWS and Azure provider adapters
- Docker Compose infrastructure
- Complete documentation
This commit is contained in:
austindebest
2026-04-20 00:00:59 +01:00
commit d62468adf9
69 changed files with 10136 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
{
"name": "@sdi/shared-types",
"version": "0.1.0",
"main": "./src/index.ts",
"types": "./src/index.ts",
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
},
"devDependencies": {
"typescript": "^5.3.3"
}
}

View File

@@ -0,0 +1,208 @@
// ============================================================================
// SERVICE ORDER TYPES
// ============================================================================
export type ServiceOrderStatus =
| 'draft'
| 'submitted'
| 'validating'
| 'quoted'
| 'approved'
| 'queued'
| 'provisioning'
| 'active'
| 'failed'
| 'suspended'
| 'terminated';
export type ServiceStatus =
| 'pending'
| 'provisioning'
| 'active'
| 'suspended'
| 'failed'
| 'terminated';
export type ProvisioningTaskStatus =
| 'pending'
| 'running'
| 'completed'
| 'failed'
| 'retrying';
// ============================================================================
// PROVIDER ADAPTER TYPES
// ============================================================================
export interface ServiceIntent {
sourceEndpointId: string;
targetEndpointId: string;
bandwidthMbps: number;
metadata?: Record<string, any>;
}
export interface ValidationResult {
ok: boolean;
errors?: string[];
warnings?: string[];
}
export interface QuoteResult {
monthlyRecurring: number;
setupFee: number;
currency: string;
validUntil: Date;
metadata?: Record<string, any>;
}
export interface ProvisionRequest {
sourceEndpointId: string;
targetEndpointId: string;
bandwidthMbps: number;
metadata?: Record<string, any>;
}
export interface ProvisionResponse {
success: boolean;
externalServiceId?: string;
error?: string;
metadata?: Record<string, any>;
}
export interface ModifyRequest {
externalServiceId: string;
bandwidthMbps?: number;
metadata?: Record<string, any>;
}
export interface ModifyResponse {
success: boolean;
error?: string;
}
export interface ActionResult {
success: boolean;
error?: string;
}
export interface ProviderAdapter {
validate(payload: ServiceIntent): Promise<ValidationResult>;
quote(payload: ServiceIntent): Promise<QuoteResult>;
provision(payload: ProvisionRequest): Promise<ProvisionResponse>;
getStatus(externalId: string): Promise<ServiceStatus>;
modify(payload: ModifyRequest): Promise<ModifyResponse>;
suspend(externalId: string): Promise<ActionResult>;
terminate(externalId: string): Promise<ActionResult>;
syncInventory?(): Promise<void>;
}
// ============================================================================
// WEBHOOK EVENT TYPES
// ============================================================================
export type WebhookEventType =
| 'quote.ready'
| 'order.accepted'
| 'order.rejected'
| 'service.provisioning.started'
| 'service.provider.pending'
| 'service.active'
| 'service.failed'
| 'service.modified'
| 'service.suspended'
| 'service.terminated'
| 'invoice.generated'
| 'incident.created';
export interface WebhookEvent {
id: string;
type: WebhookEventType;
timestamp: Date;
data: Record<string, any>;
}
// ============================================================================
// API REQUEST/RESPONSE TYPES
// ============================================================================
export interface CreateQuoteRequest {
productOfferingId: string;
sourceEndpointId: string;
targetEndpointId: string;
bandwidthMbps: number;
}
export interface CreateOrderRequest {
quoteId?: string;
productOfferingId: string;
sourceEndpointId: string;
targetEndpointId: string;
bandwidthMbps: number;
}
export interface ModifyServiceRequest {
bandwidthMbps?: number;
}
// ============================================================================
// ORCHESTRATION EVENT TYPES
// ============================================================================
export type OrchestrationEventType =
| 'order.created'
| 'order.validated'
| 'quote.generated'
| 'order.approved'
| 'provisioning.started'
| 'provider.request.sent'
| 'provider.pending'
| 'provider.completed'
| 'service.active'
| 'service.failed'
| 'billing.metering.started'
| 'inventory.sync.completed'
| 'incident.opened';
export interface OrchestrationEvent {
type: OrchestrationEventType;
orderId: string;
tenantId: string;
payload: Record<string, any>;
timestamp: Date;
}
// ============================================================================
// PROVIDER TYPES
// ============================================================================
export type ProviderType = 'aws' | 'azure' | 'carrier' | 'exchange';
export type EndpointKind =
| 'cloud_region'
| 'datacenter'
| 'exchange'
| 'customer_site';
// ============================================================================
// BILLING TYPES
// ============================================================================
export interface PricingRule {
setupFee: number;
monthlyRecurring: number;
bandwidthTiers?: Array<{
minMbps: number;
maxMbps: number;
pricePerMbps: number;
}>;
currency: string;
}
export interface UsageMetrics {
serviceId: string;
bandwidthUsageMbps: number;
dataTransferGB: number;
uptimePercentage: number;
periodStart: Date;
periodEnd: Date;
}

View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"extends": "../../tsconfig.json",
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}