@worktif/runtime 0.3.0-edge.0 → 0.3.0-edge.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +26 -26
  2. package/out/dist/bin/index.js +41 -35
  3. package/out/dist/bin/purenow.js +23 -22
  4. package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/package.json +1 -1
  5. package/out/dist/bin/templates/runtime-web/cdk/package.json.template +1 -1
  6. package/out/dist/infra/index.js +164 -0
  7. package/out/dist/lambda/bundle.js +57 -0
  8. package/out/dist/lib/index.d.ts +0 -1
  9. package/out/dist/lib/index.js +4 -4
  10. package/out/dist/lib/lib/runtime-web/index.d.ts +3 -8
  11. package/out/dist/lib/lib/runtime-web/pureweb.d.ts +1 -1
  12. package/out/dist/src/bin/commands/index.d.ts +3 -0
  13. package/out/dist/src/bin/commands/runtime-web-deployment.service.d.ts +15 -0
  14. package/out/dist/src/bin/index.d.ts +3 -2
  15. package/out/dist/src/bin/{purenow-runtime-cli.d.ts → runtime-web-cli.d.ts} +13 -4
  16. package/out/dist/src/bin/services/index.d.ts +0 -1
  17. package/out/dist/src/bin/services/purenow-runtime-deployment.strategy.d.ts +2 -2
  18. package/out/dist/src/bin/services/purenow-runtime-stacks-deploy.service.d.ts +2 -3
  19. package/out/dist/src/bin/services/purenow-runtime-stacks-deploy.service.types.d.ts +1 -1
  20. package/out/dist/src/bin/services/runtime-web-cli-extensions.d.ts +0 -1
  21. package/out/dist/src/core/bundle/index.d.ts +5 -0
  22. package/out/dist/src/core/bundle/index.d.ts.map +1 -0
  23. package/out/dist/src/core/bundle/runtime.container.d.ts +35 -0
  24. package/out/dist/src/core/bundle/runtime.container.d.ts.map +1 -0
  25. package/out/dist/src/core/bundle/runtime.container.types.d.ts +15 -0
  26. package/out/dist/src/core/bundle/runtime.container.types.d.ts.map +1 -0
  27. package/out/dist/src/core/index.d.ts +5 -0
  28. package/out/dist/src/core/index.d.ts.map +1 -0
  29. package/out/dist/src/core/runtime-web/detector/index.d.ts +7 -0
  30. package/out/dist/src/core/runtime-web/detector/index.d.ts.map +1 -0
  31. package/out/dist/src/core/runtime-web/detector/metadata-collectors.d.ts +52 -0
  32. package/out/dist/src/core/runtime-web/detector/metadata-collectors.d.ts.map +1 -0
  33. package/out/dist/src/core/runtime-web/detector/runtime-detector.d.ts +69 -0
  34. package/out/dist/src/core/runtime-web/detector/runtime-detector.d.ts.map +1 -0
  35. package/out/dist/src/core/runtime-web/detector/runtime-detector.types.d.ts +40 -0
  36. package/out/dist/src/core/runtime-web/detector/runtime-detector.types.d.ts.map +1 -0
  37. package/out/dist/src/core/runtime-web/di/di-errors.d.ts +44 -0
  38. package/out/dist/src/core/runtime-web/di/di-errors.d.ts.map +1 -0
  39. package/out/dist/src/core/runtime-web/di/index.d.ts +9 -0
  40. package/out/dist/src/core/runtime-web/di/index.d.ts.map +1 -0
  41. package/out/dist/src/core/runtime-web/di/pure-container-factory.d.ts +105 -0
  42. package/out/dist/src/core/runtime-web/di/pure-container-factory.d.ts.map +1 -0
  43. package/out/dist/src/core/runtime-web/di/ties-registrar.d.ts +87 -0
  44. package/out/dist/src/core/runtime-web/di/ties-registrar.d.ts.map +1 -0
  45. package/out/dist/src/core/runtime-web/factory/handler-wrappers.d.ts +122 -0
  46. package/out/dist/src/core/runtime-web/factory/handler-wrappers.d.ts.map +1 -0
  47. package/out/dist/src/core/runtime-web/factory/index.d.ts +12 -0
  48. package/out/dist/src/core/runtime-web/factory/index.d.ts.map +1 -0
  49. package/out/dist/src/core/runtime-web/factory/lambda-handler-factory.d.ts +110 -0
  50. package/out/dist/src/core/runtime-web/factory/lambda-handler-factory.d.ts.map +1 -0
  51. package/out/dist/src/core/runtime-web/factory/runtime-web-lambda-handler.d.ts +94 -0
  52. package/out/dist/src/core/runtime-web/factory/runtime-web-lambda-handler.d.ts.map +1 -0
  53. package/out/dist/src/core/runtime-web/index.d.ts +7 -0
  54. package/out/dist/src/core/runtime-web/index.d.ts.map +1 -0
  55. package/out/dist/src/core/runtime-web/pipelines/index.d.ts +3 -0
  56. package/out/dist/src/core/runtime-web/pipelines/index.d.ts.map +1 -0
  57. package/out/dist/src/core/runtime-web/pipelines/lambda-pipeline.d.ts +110 -0
  58. package/out/dist/src/core/runtime-web/pipelines/lambda-pipeline.d.ts.map +1 -0
  59. package/out/dist/src/core/runtime-web/registrar/container-registry.d.ts +261 -0
  60. package/out/dist/src/core/runtime-web/registrar/container-registry.d.ts.map +1 -0
  61. package/out/dist/src/core/runtime-web/registrar/index.d.ts +6 -0
  62. package/out/dist/src/core/runtime-web/registrar/index.d.ts.map +1 -0
  63. package/out/dist/src/core/runtime-web/registrar/microservice-registrar.d.ts +167 -0
  64. package/out/dist/src/core/runtime-web/registrar/microservice-registrar.d.ts.map +1 -0
  65. package/out/dist/src/core/services/index.d.ts +4 -0
  66. package/out/dist/src/core/services/index.d.ts.map +1 -0
  67. package/out/dist/src/core/services/runtime-extensions/index.d.ts +4 -0
  68. package/out/dist/src/core/services/runtime-extensions/index.d.ts.map +1 -0
  69. package/out/dist/src/core/services/runtime-extensions/runtime-extensions.service.d.ts +98 -0
  70. package/out/dist/src/core/services/runtime-extensions/runtime-extensions.service.d.ts.map +1 -0
  71. package/out/dist/src/core/services/runtime-extensions/runtime-extensions.types.d.ts +71 -0
  72. package/out/dist/src/core/services/runtime-extensions/runtime-extensions.types.d.ts.map +1 -0
  73. package/out/dist/src/infra/index.d.ts +3 -0
  74. package/out/dist/src/infra/runtime-web/constructs/api-gateway-builder.d.ts +157 -0
  75. package/out/dist/src/infra/runtime-web/constructs/index.d.ts +3 -0
  76. package/out/dist/src/infra/runtime-web/constructs/lambda-builder.d.ts +158 -0
  77. package/out/dist/src/infra/runtime-web/index.d.ts +21 -0
  78. package/out/dist/src/infra/runtime-web/pipelines/cdk-pipeline.d.ts +112 -0
  79. package/out/dist/src/infra/runtime-web/pipelines/index.d.ts +2 -0
  80. package/out/dist/src/infra/runtime-web/stacks/index.d.ts +2 -0
  81. package/out/dist/src/infra/runtime-web/stacks/runtime-web-stack.d.ts +182 -0
  82. package/out/dist/src/infra/runtime-web/validation/config-validator.d.ts +127 -0
  83. package/out/dist/src/infra/runtime-web/validation/index.d.ts +2 -0
  84. package/out/dist/src/lib/index.d.ts +3 -0
  85. package/out/dist/src/lib/runtime-web/index.d.ts +3 -8
  86. package/out/dist/src/lib/runtime-web/pureweb.d.ts +1 -1
  87. package/out/dist/src/lib/runtime-web/runtime.config.types.d.ts +71 -0
  88. package/package.json +44 -11
  89. package/out/dist/lib/utils/index.d.ts +0 -2
  90. package/out/dist/lib/utils/types/index.d.ts +0 -3
  91. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/.env.example +0 -0
  92. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/README.md +0 -0
  93. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/gitignore.template +0 -0
  94. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/purenow.config.ts +0 -0
  95. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/app.tsx +0 -0
  96. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/handlers/users/index.ts +0 -0
  97. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/handlers/users/users.handlers.ts +0 -0
  98. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/index.tsx +0 -0
  99. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/pages/about-page.tsx +0 -0
  100. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/pages/home-page.tsx +0 -0
  101. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/pages/users-page.tsx +0 -0
  102. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/routes.tsx +0 -0
  103. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/services/index.ts +0 -0
  104. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/services/users.service.ts +0 -0
  105. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/ties/index.ts +0 -0
  106. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/src/ties/users.ties.ts +0 -0
  107. /package/out/dist/bin/templates/runtime-web/{purenow-basic → basic}/tsconfig.json +0 -0
  108. /package/out/dist/lib/{utils/types → lib/runtime-web}/runtime.config.types.d.ts +0 -0
@@ -0,0 +1,94 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import { LambdaApi } from '@worktif/purews';
3
+ import type { LambdaInterface } from '@aws-lambda-powertools/commons/types';
4
+ import type { LambdaDefinition } from '../../../lib/runtime-web/types';
5
+ import type { LambdaHandlerFactory } from './lambda-handler-factory';
6
+ /**
7
+ * Runtime Web Lambda handler that extends LambdaApi with dependency injection.
8
+ *
9
+ * This class bridges the gap between the existing Purenow Core LambdaApi
10
+ * infrastructure and the new Runtime Web Core dependency injection system.
11
+ * It extends LambdaApi to maintain compatibility while adding automatic
12
+ * DI resolution and user handler invocation.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const handler = new RuntimeWebLambdaHandler(definition, container, factory);
17
+ *
18
+ * // AWS Lambda runtime calls this method
19
+ * const result = await handler.handler(event, context);
20
+ * ```
21
+ */
22
+ export declare class RuntimeWebLambdaHandler extends LambdaApi implements LambdaInterface {
23
+ private readonly definition;
24
+ private readonly container;
25
+ private readonly factory;
26
+ private readonly logger;
27
+ private readonly userHandler;
28
+ /**
29
+ * Create a Runtime Web Lambda handler.
30
+ *
31
+ * @param definition - Lambda definition with handler and dependencies
32
+ * @param container - PureContainer with registered services
33
+ * @param factory - Factory instance for dependency injection and wrapping
34
+ */
35
+ constructor(definition: LambdaDefinition, container: PureContainer<string>, factory: LambdaHandlerFactory);
36
+ /**
37
+ * Main Lambda handler method called by AWS Lambda runtime.
38
+ *
39
+ * This method is called by the AWS Lambda runtime for each invocation.
40
+ * It injects dependencies, calls the user's handler function, and returns
41
+ * the result. Extends the existing LambdaApi.handler() method to add
42
+ * dependency injection support.
43
+ *
44
+ * @param event - Lambda event object
45
+ * @param context - Lambda context object
46
+ * @returns Promise resolving to the handler result
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // AWS Lambda runtime calls this automatically
51
+ * const result = await handler.handler(apiGatewayEvent, lambdaContext);
52
+ * ```
53
+ */
54
+ handler(event: unknown, context: unknown): Promise<unknown>;
55
+ /**
56
+ * Create the user handler with dependency injection and wrapping.
57
+ *
58
+ * This method is called once during construction to resolve dependencies
59
+ * and create the wrapped user handler. The result is cached for reuse
60
+ * across Lambda invocations to avoid repeated DI resolution.
61
+ *
62
+ * @returns Wrapped user handler with dependencies injected
63
+ * @private
64
+ */
65
+ private createUserHandler;
66
+ /**
67
+ * Get the Lambda definition used by this handler.
68
+ *
69
+ * Provides access to the original Lambda definition for debugging
70
+ * or introspection purposes.
71
+ *
72
+ * @returns The Lambda definition
73
+ */
74
+ getDefinition(): LambdaDefinition;
75
+ /**
76
+ * Get the PureContainer used by this handler.
77
+ *
78
+ * Provides access to the DI container for debugging or advanced
79
+ * use cases. Generally not needed in normal operation.
80
+ *
81
+ * @returns The PureContainer instance
82
+ */
83
+ getContainer(): PureContainer<string>;
84
+ /**
85
+ * Check if the handler has been properly initialized.
86
+ *
87
+ * Verifies that the user handler has been created successfully
88
+ * and is ready for invocation.
89
+ *
90
+ * @returns True if handler is ready, false otherwise
91
+ */
92
+ isReady(): boolean;
93
+ }
94
+ //# sourceMappingURL=runtime-web-lambda-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-web-lambda-handler.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/factory/runtime-web-lambda-handler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAU,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,uBAAwB,SAAQ,SAAU,YAAW,eAAe;IAY7E,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAb1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyD;IAErF;;;;;;OAMG;gBAEgB,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,oBAAoB;IAsBhD;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BjE;;;;;;;;;OASG;IACH,OAAO,CAAC,iBAAiB;IAmCzB;;;;;;;OAOG;IACH,aAAa,IAAI,gBAAgB;IAIjC;;;;;;;OAOG;IACH,YAAY,IAAI,aAAa,CAAC,MAAM,CAAC;IAIrC;;;;;;;OAOG;IACH,OAAO,IAAI,OAAO;CAGnB"}
@@ -0,0 +1,7 @@
1
+ import 'reflect-metadata';
2
+ export * from './detector';
3
+ export * from './di';
4
+ export * from './factory';
5
+ export * from './pipelines';
6
+ export * from './registrar';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/runtime-web/index.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,YAAY,CAAC;AAC3B,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import 'reflect-metadata';
2
+ export * from './lambda-pipeline';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/pipelines/index.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAK1B,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,110 @@
1
+ import type { LambdaMetadata, RuntimeWebConfig } from '../../../lib/runtime-web/types';
2
+ /**
3
+ * Lambda execution pipeline for Runtime Target Core.
4
+ *
5
+ * Handles Lambda function execution with dependency injection.
6
+ * Resolves the Lambda ID from environment variables, gets the appropriate
7
+ * DI container, creates the handler with injected dependencies, and executes
8
+ * the business logic.
9
+ *
10
+ * **Execution Flow**:
11
+ * 1. Resolve Lambda ID from LAMBDA_ID environment variable
12
+ * 2. Use MicroserviceRegistrar to get container for Lambda
13
+ * 3. Use LambdaHandlerFactory to create handler with DI
14
+ * 4. Execute handler and return result
15
+ *
16
+ * **Requirements**: REQ-06, REQ-08
17
+ */
18
+ export declare class LambdaPipeline {
19
+ private readonly logger;
20
+ private registrar?;
21
+ private handlerFactory?;
22
+ /**
23
+ * Execute Lambda pipeline for server-side function execution.
24
+ *
25
+ * Processes the microservice registry, resolves the Lambda ID from environment
26
+ * variables, gets the appropriate DI container, creates the handler with
27
+ * dependency injection, and executes the business logic.
28
+ *
29
+ * @param config - Purenow configuration with microservice registry
30
+ * @param context - Lambda environment context with metadata
31
+ * @returns Result from Lambda handler execution
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const pipeline = new LambdaPipeline();
36
+ * const result = await pipeline.execute(config, {
37
+ * type: 'lambda',
38
+ * metadata: {
39
+ * functionName: 'my-app-payments-charge-dev',
40
+ * version: '$LATEST',
41
+ * region: 'us-east-1',
42
+ * memoryLimit: 1024,
43
+ * requestId: 'abc-123'
44
+ * }
45
+ * });
46
+ * ```
47
+ */
48
+ execute(config: RuntimeWebConfig, context: {
49
+ type: 'lambda';
50
+ metadata: LambdaMetadata;
51
+ }): Promise<unknown>;
52
+ /**
53
+ * Initialize the microservice registrar and process all services.
54
+ *
55
+ * Creates a new MicroserviceRegistrar and processes all microservice
56
+ * definitions from the configuration to build DI containers.
57
+ *
58
+ * @param config - Purenow configuration
59
+ * @private
60
+ */
61
+ private initializeRegistrar;
62
+ /**
63
+ * Resolve Lambda ID from environment variables.
64
+ *
65
+ * Gets the Lambda ID from the LAMBDA_ID environment variable that
66
+ * is set by the CDK stack during deployment.
67
+ *
68
+ * @returns Lambda ID (e.g., 'payments.charge')
69
+ * @throws Error if LAMBDA_ID environment variable is not set
70
+ * @private
71
+ */
72
+ private resolveLambdaId;
73
+ /**
74
+ * Get DI container for the specified Lambda.
75
+ *
76
+ * Uses the MicroserviceRegistrar to look up the appropriate DI container
77
+ * for the Lambda function based on its ID.
78
+ *
79
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
80
+ * @returns PureContainer instance for the Lambda's microservice
81
+ * @throws Error if container not found
82
+ * @private
83
+ */
84
+ private getContainerForLambda;
85
+ /**
86
+ * Create Lambda handler with dependency injection.
87
+ *
88
+ * Uses the LambdaHandlerFactory to create a handler instance with
89
+ * automatic dependency injection from the DI container.
90
+ *
91
+ * @param lambdaId - Full Lambda ID
92
+ * @param container - PureContainer with registered services
93
+ * @returns Lambda handler instance ready for execution
94
+ * @private
95
+ */
96
+ private createHandlerWithDI;
97
+ /**
98
+ * Find Lambda definition by ID from the processed microservices.
99
+ *
100
+ * Uses the MicroserviceRegistrar to retrieve the Lambda definition
101
+ * that matches the specified ID.
102
+ *
103
+ * @param lambdaId - Full Lambda ID to find
104
+ * @returns Lambda definition
105
+ * @throws Error if Lambda definition not found
106
+ * @private
107
+ */
108
+ private findLambdaDefinition;
109
+ }
110
+ //# sourceMappingURL=lambda-pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-pipeline.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/pipelines/lambda-pipeline.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/E;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAEpB;IAEH,OAAO,CAAC,SAAS,CAAC,CAAwB;IAC1C,OAAO,CAAC,cAAc,CAAC,CAAuB;IAE9C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,OAAO,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAgDhH;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IA8B3B;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAcvB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,qBAAqB;IAwB7B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;IA+B3B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
@@ -0,0 +1,261 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import type { LambdaDefinition } from '../../../lib/runtime-web/types';
3
+ /**
4
+ * Registry for managing PureContainer instances and Lambda-to-service mappings.
5
+ *
6
+ * Provides a centralized registry for storing and retrieving DI containers
7
+ * for microservices, along with mappings between Lambda functions and their
8
+ * parent services. This enables clean separation of concerns and makes the
9
+ * MicroserviceRegistrar more focused on processing logic.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const registry = new ContainerRegistry();
14
+ *
15
+ * // Register a service with its container
16
+ * registry.registerService('payments', paymentsContainer);
17
+ *
18
+ * // Map Lambda to service
19
+ * registry.registerLambda('payments.charge', 'payments');
20
+ *
21
+ * // Retrieve container for Lambda
22
+ * const container = registry.getContainer('payments.charge');
23
+ * ```
24
+ */
25
+ export declare class ContainerRegistry {
26
+ private readonly containers;
27
+ private readonly lambdaToService;
28
+ private readonly lambdaDefinitions;
29
+ /**
30
+ * Register a service with its DI container.
31
+ *
32
+ * Stores the PureContainer instance for the given service name.
33
+ * Validates that the service name is not already registered to prevent
34
+ * accidental overwrites.
35
+ *
36
+ * @param serviceName - Name of the microservice
37
+ * @param container - PureContainer instance for the service
38
+ * @throws DIContainerError if service is already registered
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const paymentsContainer = new PureContainer<string>();
43
+ * registry.registerService('payments', paymentsContainer);
44
+ * ```
45
+ */
46
+ registerService(serviceName: string, container: PureContainer<string>): void;
47
+ /**
48
+ * Register a Lambda function with its parent service and definition.
49
+ *
50
+ * Creates a mapping between the Lambda ID and its parent service name,
51
+ * and stores the Lambda definition for runtime lookup.
52
+ * This enables looking up the correct DI container for Lambda invocations.
53
+ *
54
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
55
+ * @param serviceName - Name of the parent microservice
56
+ * @param definition - Lambda definition with handler and dependencies
57
+ * @throws DIContainerError if Lambda is already registered
58
+ * @throws MissingServiceError if parent service is not registered
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * registry.registerLambda('payments.charge', 'payments', chargeDefinition);
63
+ * registry.registerLambda('payments.refund', 'payments', refundDefinition);
64
+ * ```
65
+ */
66
+ registerLambda(lambdaId: string, serviceName: string, definition: LambdaDefinition): void;
67
+ /**
68
+ * Get the DI container for a service by name.
69
+ *
70
+ * Retrieves the PureContainer instance for the given service name.
71
+ *
72
+ * @param serviceName - Name of the microservice
73
+ * @returns PureContainer instance for the service
74
+ * @throws MissingServiceError if service is not registered
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const container = registry.getContainer('payments');
79
+ * const paymentsService = container.run('PaymentsService');
80
+ * ```
81
+ */
82
+ getContainer(serviceName: string): PureContainer<string>;
83
+ /**
84
+ * Get the DI container for a Lambda function.
85
+ *
86
+ * Looks up the parent service for the Lambda ID and returns the
87
+ * corresponding PureContainer instance.
88
+ *
89
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
90
+ * @returns PureContainer instance for the Lambda's microservice
91
+ * @throws MissingServiceError if Lambda or service is not registered
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const container = registry.getContainerForLambda('payments.charge');
96
+ * const paymentsService = container.run('PaymentsService');
97
+ * ```
98
+ */
99
+ getContainerForLambda(lambdaId: string): PureContainer<string>;
100
+ /**
101
+ * Get the parent service name for a Lambda function.
102
+ *
103
+ * Looks up the service name that owns the given Lambda ID.
104
+ *
105
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
106
+ * @returns Name of the parent microservice
107
+ * @throws MissingServiceError if Lambda is not registered
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const serviceName = registry.getLambdaService('payments.charge');
112
+ * console.log(serviceName); // 'payments'
113
+ * ```
114
+ */
115
+ getLambdaService(lambdaId: string): string;
116
+ /**
117
+ * Get the Lambda definition for a Lambda function.
118
+ *
119
+ * Retrieves the stored Lambda definition for the given Lambda ID.
120
+ *
121
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
122
+ * @returns Lambda definition with handler and dependencies
123
+ * @throws MissingServiceError if Lambda is not registered
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const definition = registry.getLambdaDefinition('payments.charge');
128
+ * console.log(definition.ties); // [PaymentsService, BillingService]
129
+ * ```
130
+ */
131
+ getLambdaDefinition(lambdaId: string): LambdaDefinition;
132
+ /**
133
+ * Check if a service is registered.
134
+ *
135
+ * @param serviceName - Name of the service to check
136
+ * @returns True if service is registered
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * if (registry.hasService('payments')) {
141
+ * const container = registry.getContainer('payments');
142
+ * }
143
+ * ```
144
+ */
145
+ hasService(serviceName: string): boolean;
146
+ /**
147
+ * Check if a Lambda is registered.
148
+ *
149
+ * @param lambdaId - Full Lambda ID to check
150
+ * @returns True if Lambda is registered
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * if (registry.hasLambda('payments.charge')) {
155
+ * const container = registry.getContainerForLambda('payments.charge');
156
+ * }
157
+ * ```
158
+ */
159
+ hasLambda(lambdaId: string): boolean;
160
+ /**
161
+ * Get all registered service names.
162
+ *
163
+ * @returns Array of service names that have been registered
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const services = registry.getServiceNames();
168
+ * console.log(services); // ['payments', 'users', 'notifications']
169
+ * ```
170
+ */
171
+ getServiceNames(): string[];
172
+ /**
173
+ * Get all registered Lambda IDs.
174
+ *
175
+ * @returns Array of Lambda IDs that have been registered
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * const lambdas = registry.getLambdaIds();
180
+ * console.log(lambdas); // ['payments.charge', 'payments.refund', 'users.create']
181
+ * ```
182
+ */
183
+ getLambdaIds(): string[];
184
+ /**
185
+ * Get all Lambda IDs for a specific service.
186
+ *
187
+ * @param serviceName - Name of the service
188
+ * @returns Array of Lambda IDs belonging to the service
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const paymentLambdas = registry.getLambdasForService('payments');
193
+ * console.log(paymentLambdas); // ['payments.charge', 'payments.refund']
194
+ * ```
195
+ */
196
+ getLambdasForService(serviceName: string): string[];
197
+ /**
198
+ * Remove a service and all its Lambda mappings.
199
+ *
200
+ * Removes the service container and all Lambda-to-service mappings
201
+ * for Lambdas belonging to this service.
202
+ *
203
+ * @param serviceName - Name of the service to remove
204
+ * @returns True if service was removed, false if it didn't exist
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const removed = registry.removeService('payments');
209
+ * console.log(removed); // true if 'payments' was registered
210
+ * ```
211
+ */
212
+ removeService(serviceName: string): boolean;
213
+ /**
214
+ * Remove a Lambda mapping.
215
+ *
216
+ * Removes the Lambda-to-service mapping for the given Lambda ID.
217
+ * Does not affect the parent service container.
218
+ *
219
+ * @param lambdaId - Full Lambda ID to remove
220
+ * @returns True if Lambda was removed, false if it didn't exist
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * const removed = registry.removeLambda('payments.charge');
225
+ * console.log(removed); // true if 'payments.charge' was registered
226
+ * ```
227
+ */
228
+ removeLambda(lambdaId: string): boolean;
229
+ /**
230
+ * Clear all registered services and Lambda mappings.
231
+ *
232
+ * Removes all containers, mappings, and definitions from the registry.
233
+ * Useful for testing or when reinitializing the registry.
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * registry.clear();
238
+ * console.log(registry.getServiceNames()); // []
239
+ * console.log(registry.getLambdaIds()); // []
240
+ * ```
241
+ */
242
+ clear(): void;
243
+ /**
244
+ * Get registry statistics.
245
+ *
246
+ * Returns information about the current state of the registry.
247
+ *
248
+ * @returns Object with service and Lambda counts
249
+ *
250
+ * @example
251
+ * ```typescript
252
+ * const stats = registry.getStats();
253
+ * console.log(stats); // { services: 3, lambdas: 8 }
254
+ * ```
255
+ */
256
+ getStats(): {
257
+ services: number;
258
+ lambdas: number;
259
+ };
260
+ }
261
+ //# sourceMappingURL=container-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container-registry.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/registrar/container-registry.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiD;IAC5E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkC;IAClE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA4C;IAE9E;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI;IAW5E;;;;;;;;;;;;;;;;;;OAkBG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAmBzF;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAQxD;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAK9D;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAQ1C;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAQvD;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpC;;;;;;;;;;OAUG;IACH,eAAe,IAAI,MAAM,EAAE;IAI3B;;;;;;;;;;OAUG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAYnD;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAoB3C;;;;;;;;;;;;;;OAcG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIvC;;;;;;;;;;;;OAYG;IACH,KAAK,IAAI,IAAI;IAMb;;;;;;;;;;;;OAYG;IACH,QAAQ,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CAMlD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Microservice registration module for Runtime Target Core.
3
+ */
4
+ export { MicroserviceRegistrar } from './microservice-registrar';
5
+ export { ContainerRegistry } from './container-registry';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/registrar/index.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,167 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import type { LambdaDefinition, MicroserviceDefinition } from '../../../lib/runtime-web/types';
3
+ import { ContainerRegistry } from '../../runtime-web/registrar/container-registry';
4
+ /**
5
+ * Microservice registrar for managing DI containers and Lambda mappings.
6
+ *
7
+ * Processes microservice definitions to create PureContainer instances and
8
+ * maintains mappings between Lambda functions and their parent services.
9
+ * This enables the framework to resolve the correct DI container for each
10
+ * Lambda invocation.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const registrar = new MicroserviceRegistrar();
15
+ *
16
+ * // Process a microservice definition
17
+ * registrar.processService('payments', {
18
+ * ties: [PaymentsTies],
19
+ * lambdas: [chargeHandler, refundHandler]
20
+ * });
21
+ *
22
+ * // Get container for a specific Lambda
23
+ * const container = registrar.getContainerForLambda('payments.charge');
24
+ * ```
25
+ */
26
+ export declare class MicroserviceRegistrar {
27
+ private readonly containerFactory;
28
+ private readonly registry;
29
+ constructor();
30
+ /**
31
+ * Process a microservice definition and create its DI container.
32
+ *
33
+ * Creates a PureContainer from the Ties classes and processes all Lambda
34
+ * definitions to establish service mappings. Auto-sets the service property
35
+ * on each Lambda definition and generates Lambda IDs.
36
+ *
37
+ * @param serviceName - Name of the microservice
38
+ * @param definition - Microservice definition with Ties and Lambdas
39
+ * @throws Error if service processing fails
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * registrar.processService('payments', {
44
+ * ties: [PaymentsTies, BillingTies],
45
+ * lambdas: [
46
+ * {
47
+ * id: 'charge',
48
+ * ties: [PaymentsService],
49
+ * handler: (deps) => async (event) => { ... }
50
+ * }
51
+ * ]
52
+ * });
53
+ * ```
54
+ */
55
+ processService(serviceName: string, definition: MicroserviceDefinition): void;
56
+ /**
57
+ * Get the DI container for a specific Lambda function.
58
+ *
59
+ * Looks up the service name for the Lambda ID and returns the
60
+ * corresponding PureContainer instance.
61
+ *
62
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
63
+ * @returns PureContainer instance for the Lambda's microservice
64
+ * @throws MissingServiceError if Lambda or service not found
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * const container = registrar.getContainerForLambda('payments.charge');
69
+ * const paymentsService = container.run('PaymentsService');
70
+ * ```
71
+ */
72
+ getContainerForLambda(lambdaId: string): PureContainer<string>;
73
+ /**
74
+ * Generate a Lambda ID from service name and Lambda definition.
75
+ *
76
+ * Uses explicit ID if provided, otherwise extracts from handler function name.
77
+ * The final ID format is always '{serviceName}.{lambdaId}'.
78
+ *
79
+ * @param serviceName - Name of the parent microservice
80
+ * @param definition - Lambda definition
81
+ * @returns Full Lambda ID
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // With explicit ID
86
+ * generateLambdaId('payments', { id: 'charge', ... }) // → 'payments.charge'
87
+ *
88
+ * // Without explicit ID (extracts from handler name)
89
+ * generateLambdaId('payments', { handler: function processPayment() {...} }) // → 'payments.processPayment'
90
+ * ```
91
+ */
92
+ generateLambdaId(serviceName: string, definition: LambdaDefinition): string;
93
+ /**
94
+ * Get all registered service names.
95
+ *
96
+ * @returns Array of service names that have been processed
97
+ */
98
+ getServiceNames(): string[];
99
+ /**
100
+ * Get all registered Lambda IDs.
101
+ *
102
+ * @returns Array of Lambda IDs that have been processed
103
+ */
104
+ getLambdaIds(): string[];
105
+ /**
106
+ * Get the service name for a Lambda ID.
107
+ *
108
+ * @param lambdaId - Full Lambda ID
109
+ * @returns Service name or undefined if not found
110
+ */
111
+ getServiceForLambda(lambdaId: string): string | undefined;
112
+ /**
113
+ * Check if a service is registered.
114
+ *
115
+ * @param serviceName - Name of the service to check
116
+ * @returns True if service is registered
117
+ */
118
+ hasService(serviceName: string): boolean;
119
+ /**
120
+ * Check if a Lambda is registered.
121
+ *
122
+ * @param lambdaId - Full Lambda ID to check
123
+ * @returns True if Lambda is registered
124
+ */
125
+ hasLambda(lambdaId: string): boolean;
126
+ /**
127
+ * Get all Lambda definitions for a service.
128
+ *
129
+ * @param serviceName - Name of the service
130
+ * @returns Array of Lambda IDs for the service
131
+ */
132
+ getLambdasForService(serviceName: string): string[];
133
+ /**
134
+ * Clear all registered services and containers.
135
+ *
136
+ * Useful for testing or when reinitializing the registrar.
137
+ */
138
+ clear(): void;
139
+ /**
140
+ * Get Lambda definition by ID.
141
+ *
142
+ * Retrieves the Lambda definition for the specified Lambda ID.
143
+ *
144
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
145
+ * @returns Lambda definition with handler and dependencies
146
+ * @throws Error if Lambda definition not found
147
+ */
148
+ getLambdaDefinition(lambdaId: string): LambdaDefinition;
149
+ /**
150
+ * Get the underlying container registry.
151
+ *
152
+ * Provides access to the internal ContainerRegistry for advanced use cases.
153
+ *
154
+ * @returns ContainerRegistry instance
155
+ */
156
+ getRegistry(): ContainerRegistry;
157
+ /**
158
+ * Validate a container has all required services (private helper).
159
+ *
160
+ * This is currently disabled but can be enabled for debugging.
161
+ *
162
+ * @param container - Container to validate
163
+ * @param definition - Microservice definition
164
+ */
165
+ private validateContainer;
166
+ }
167
+ //# sourceMappingURL=microservice-registrar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microservice-registrar.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/registrar/microservice-registrar.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAW,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;;IAO7C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,GAAG,IAAI;IA0B7E;;;;;;;;;;;;;;;OAeG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IAI9D;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,MAAM;IAU3E;;;;OAIG;IACH,eAAe,IAAI,MAAM,EAAE;IAI3B;;;;OAIG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;;;;OAKG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQzD;;;;;OAKG;IACH,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIpC;;;;;OAKG;IACH,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAInD;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;;;;OAQG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAIvD;;;;;;OAMG;IACH,WAAW,IAAI,iBAAiB;IAIhC;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;CAa1B"}