@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,69 @@
1
+ import type { EnvironmentContext } from '../../../lib/runtime-web/types';
2
+ /**
3
+ * Runtime environment detector for Runtime Target Core.
4
+ *
5
+ * Automatically detects the execution environment (browser, Lambda, or CDK)
6
+ * and provides appropriate metadata for each context. This enables the
7
+ * unified purenow() entry point to route execution to the correct pipeline.
8
+ *
9
+ * **Detection Priority**:
10
+ * 1. Browser: Check for `window` object
11
+ * 2. Lambda: Check for `AWS_LAMBDA_FUNCTION_NAME` environment variable
12
+ * 3. CDK: Check for explicit mode, CDK env vars, or process arguments
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const detector = new RuntimeDetector();
17
+ * const context = detector.detect();
18
+ *
19
+ * switch (context.type) {
20
+ * case 'browser':
21
+ * // Execute browser pipeline
22
+ * break;
23
+ * case 'lambda':
24
+ * // Execute Lambda pipeline
25
+ * break;
26
+ * case 'cdk':
27
+ * // Execute CDK pipeline
28
+ * break;
29
+ * }
30
+ * ```
31
+ */
32
+ export declare class RuntimeDetector {
33
+ /**
34
+ * Detect the current runtime environment.
35
+ *
36
+ * Uses a series of checks to determine the execution context:
37
+ * - Browser: Presence of `window` object
38
+ * - Lambda: AWS Lambda environment variables
39
+ * - CDK: Explicit mode or CDK-specific indicators
40
+ *
41
+ * @returns Environment context with type and metadata
42
+ * @throws Error if environment cannot be determined
43
+ */
44
+ detect(): EnvironmentContext;
45
+ /**
46
+ * Check if running in browser environment.
47
+ *
48
+ * @returns True if `window` object exists
49
+ */
50
+ private isBrowser;
51
+ /**
52
+ * Check if running in AWS Lambda environment.
53
+ *
54
+ * @returns True if AWS Lambda environment variable is present
55
+ */
56
+ private isLambda;
57
+ /**
58
+ * Check if running in CDK environment.
59
+ *
60
+ * Uses multiple detection methods in priority order:
61
+ * 1. Explicit mode: PURENOW_MODE=cdk (recommended)
62
+ * 2. CDK environment variables: CDK_DEFAULT_ACCOUNT or CDK_DEFAULT_REGION
63
+ * 3. Process arguments: contains 'cdk' or 'synth'
64
+ *
65
+ * @returns True if CDK environment is detected
66
+ */
67
+ private isCDK;
68
+ }
69
+ //# sourceMappingURL=runtime-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-detector.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/detector/runtime-detector.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;OAUG;IACH,MAAM,IAAI,kBAAkB;IA6B5B;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAIjB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK;CAkBd"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Internal types for the RuntimeDetector module.
3
+ *
4
+ * These types are used internally by the detector and are not part of the public API.
5
+ * Public types are exported from @lib/runtime-web/types.
6
+ */
7
+ /**
8
+ * Detection result for internal use.
9
+ *
10
+ * Contains the raw detection result before metadata collection.
11
+ */
12
+ export interface DetectionResult {
13
+ /** Detected environment type */
14
+ type: 'browser' | 'lambda' | 'cdk';
15
+ /** Whether detection was successful */
16
+ success: boolean;
17
+ /** Detection method used */
18
+ method: 'window' | 'lambda-env' | 'cdk-explicit' | 'cdk-env' | 'cdk-args';
19
+ }
20
+ /**
21
+ * Detection error information.
22
+ */
23
+ export interface DetectionError {
24
+ /** Error message */
25
+ message: string;
26
+ /** Detection attempts made */
27
+ attempts: string[];
28
+ /** Environment variables checked */
29
+ envVarsChecked: string[];
30
+ }
31
+ /**
32
+ * Metadata collection options.
33
+ */
34
+ export interface MetadataOptions {
35
+ /** Whether to include sensitive information */
36
+ includeSensitive?: boolean;
37
+ /** Whether to validate collected data */
38
+ validate?: boolean;
39
+ }
40
+ //# sourceMappingURL=runtime-detector.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-detector.types.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/detector/runtime-detector.types.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,gCAAgC;IAChC,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,MAAM,EAAE,QAAQ,GAAG,YAAY,GAAG,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;CAC3E;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,oCAAoC;IACpC,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Error thrown when a DI container operation fails.
3
+ *
4
+ * Used for container creation, service resolution, and validation errors.
5
+ */
6
+ export declare class DIContainerError extends Error {
7
+ /**
8
+ * Create a new DI container error.
9
+ *
10
+ * @param containerName - Name or identifier of the container
11
+ * @param message - Detailed error message
12
+ */
13
+ constructor(containerName: string, message: string);
14
+ }
15
+ /**
16
+ * Error thrown when Ties class registration fails.
17
+ *
18
+ * Used when a Ties class doesn't implement the required register() method
19
+ * or when registration fails for other reasons.
20
+ */
21
+ export declare class TiesRegistrationError extends Error {
22
+ /**
23
+ * Create a new Ties registration error.
24
+ *
25
+ * @param tiesClassName - Name of the Ties class that failed
26
+ * @param reason - Reason for the registration failure
27
+ */
28
+ constructor(tiesClassName: string, reason: string);
29
+ }
30
+ /**
31
+ * Error thrown when a required service is not found in the container.
32
+ *
33
+ * Used when attempting to resolve a service that hasn't been registered.
34
+ */
35
+ export declare class MissingServiceError extends Error {
36
+ /**
37
+ * Create a new missing service error.
38
+ *
39
+ * @param serviceName - Name of the missing service
40
+ * @param containerName - Name or identifier of the container
41
+ */
42
+ constructor(serviceName: string, containerName: string);
43
+ }
44
+ //# sourceMappingURL=di-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"di-errors.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/di/di-errors.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC;;;;;OAKG;gBACS,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKnD;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C;;;;;OAKG;gBACS,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAKlD;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C;;;;;OAKG;gBACS,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAKvD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Dependency injection module for Runtime Target Core.
3
+ *
4
+ * Provides PureContainer integration and Ties registration functionality.
5
+ */
6
+ export { TiesRegistrar } from './ties-registrar';
7
+ export { PureContainerFactory } from './pure-container-factory';
8
+ export { DIContainerError, TiesRegistrationError, MissingServiceError } from './di-errors';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/di/index.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,105 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import type { TiesInstance } from '../../../lib/runtime-web/types';
3
+ /**
4
+ * Factory for creating and configuring PureContainer instances for microservices.
5
+ *
6
+ * Creates PureContainer<string> instances with singleton scope by default and
7
+ * registers all services from the provided Ties classes. This provides a
8
+ * consistent way to build DI containers for microservices.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const factory = new PureContainerFactory();
13
+ * const container = factory.createMicroserviceContainer([PaymentsTies, BillingTies]);
14
+ *
15
+ * // Container now has all services registered by the Ties classes
16
+ * const paymentsService = container.run('PaymentsService');
17
+ * ```
18
+ */
19
+ export declare class PureContainerFactory {
20
+ private readonly tiesRegistrar;
21
+ constructor();
22
+ /**
23
+ * Create a PureContainer for a microservice with registered Ties classes.
24
+ *
25
+ * Creates a new PureContainer<string> with singleton scope by default,
26
+ * then registers all services from the provided Ties classes.
27
+ *
28
+ * @param tiesClasses - Array of Ties class constructors to register
29
+ * @returns Configured PureContainer with all services registered
30
+ * @throws DIContainerError if container creation or registration fails
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const container = factory.createMicroserviceContainer([
35
+ * PaymentsTies,
36
+ * BillingTies,
37
+ * ConfigTies
38
+ * ]);
39
+ *
40
+ * // Use the container to resolve services
41
+ * const paymentsService = container.run('PaymentsService');
42
+ * const config = container.runConstant('PaymentsConfig');
43
+ * ```
44
+ */
45
+ createMicroserviceContainer(tiesClasses: TiesInstance[]): PureContainer<string>;
46
+ /**
47
+ * Create a PureContainer with custom configuration.
48
+ *
49
+ * Allows creating containers with custom scope settings or other options.
50
+ * Still registers the provided Ties classes.
51
+ *
52
+ * @param tiesClasses - Array of Ties class constructors to register
53
+ * @param options - PureContainer configuration options
54
+ * @returns Configured PureContainer with all services registered
55
+ * @throws DIContainerError if container creation or registration fails
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const container = factory.createCustomContainer(
60
+ * [PaymentsTies],
61
+ * { defaultScope: 'Transient' }
62
+ * );
63
+ * ```
64
+ */
65
+ createCustomContainer(tiesClasses: TiesInstance[], options?: {
66
+ defaultScope?: 'Singleton' | 'Transient';
67
+ }): PureContainer<string>;
68
+ /**
69
+ * Validate that a container has all required services registered.
70
+ *
71
+ * Convenience method that delegates to TiesRegistrar.validateContainer().
72
+ * Useful for ensuring container integrity after creation.
73
+ *
74
+ * @param container - PureContainer to validate
75
+ * @param requiredServices - Array of service names that must be registered
76
+ * @throws Error if any required service is not registered
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const container = factory.createMicroserviceContainer([PaymentsTies]);
81
+ * factory.validateContainer(container, ['PaymentsService', 'PaymentsConfig']);
82
+ * ```
83
+ */
84
+ validateContainer(container: PureContainer<string>, requiredServices: string[]): void;
85
+ /**
86
+ * Create a container and validate it has all expected services.
87
+ *
88
+ * Combines container creation with validation in a single step.
89
+ * Automatically extracts expected service names from Ties classes if possible.
90
+ *
91
+ * @param tiesClasses - Array of Ties class constructors to register
92
+ * @param additionalServices - Additional service names to validate (optional)
93
+ * @returns Validated PureContainer with all services registered
94
+ * @throws DIContainerError if container creation fails
95
+ * @throws Error if validation fails
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const container = factory.createValidatedContainer([PaymentsTies]);
100
+ * // Container is guaranteed to have all services registered by PaymentsTies
101
+ * ```
102
+ */
103
+ createValidatedContainer(tiesClasses: TiesInstance[], additionalServices?: string[]): PureContainer<string>;
104
+ }
105
+ //# sourceMappingURL=pure-container-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure-container-factory.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/di/pure-container-factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAW,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;;;;;;;;;;;;;;GAeG;AACH,qBACa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;;IAM9C;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,2BAA2B,CAAC,WAAW,EAAE,YAAY,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC;IAoB/E;;;;;;;;;;;;;;;;;;OAkBG;IACH,qBAAqB,CACnB,WAAW,EAAE,YAAY,EAAE,EAC3B,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,CAAA;KAAO,GACzD,aAAa,CAAC,MAAM,CAAC;IAcxB;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,IAAI;IAIrF;;;;;;;;;;;;;;;;;OAiBG;IACH,wBAAwB,CACtB,WAAW,EAAE,YAAY,EAAE,EAC3B,kBAAkB,GAAE,MAAM,EAAO,GAChC,aAAa,CAAC,MAAM,CAAC;CAazB"}
@@ -0,0 +1,87 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import type { TiesInstance } from '../../../lib/runtime-web/types';
3
+ /**
4
+ * Ties registration helper for PureContainer integration.
5
+ *
6
+ * Processes Ties classes and registers their services with a PureContainer instance.
7
+ * Each Ties class must implement a register(container: PureContainer<string>) method
8
+ * that uses container.tie(), container.tieConst(), or container.tieSingleton() to
9
+ * register services.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const registrar = new TiesRegistrar();
14
+ * const container = new PureContainer<string>({ defaultScope: 'Singleton' });
15
+ *
16
+ * registrar.registerTies(container, [PaymentsTies, BillingTies]);
17
+ *
18
+ * // Now container has all services registered by the Ties classes
19
+ * const paymentsService = container.run('PaymentsService');
20
+ * ```
21
+ */
22
+ export declare class TiesRegistrar {
23
+ /**
24
+ * Register all Ties classes with the provided container.
25
+ *
26
+ * Calls the register(container) method on each Ties class instance.
27
+ * The Ties classes are responsible for calling container.tie(),
28
+ * container.tieConst(), or container.tieSingleton() to register their services.
29
+ *
30
+ * @param container - PureContainer instance to register services with
31
+ * @param tiesClasses - Array of Ties class constructors
32
+ * @throws TiesRegistrationError if a Ties class doesn't implement register()
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // Ties class example
37
+ * class PaymentsTies {
38
+ * register(container: PureContainer<string>): void {
39
+ * container.tieSingleton({
40
+ * PaymentsService: {
41
+ * instance: PaymentsService,
42
+ * args: []
43
+ * }
44
+ * });
45
+ * }
46
+ * }
47
+ *
48
+ * registrar.registerTies(container, [PaymentsTies]);
49
+ * ```
50
+ */
51
+ registerTies(container: PureContainer<string>, tiesClasses: TiesInstance[]): void;
52
+ /**
53
+ * Validate that all required services are registered in the container.
54
+ *
55
+ * Attempts to resolve each service name to ensure it's properly registered.
56
+ * This is useful for catching missing service registrations early.
57
+ *
58
+ * @param container - PureContainer to validate
59
+ * @param requiredServices - Array of service names that must be registered
60
+ * @throws Error if any required service is not registered
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * registrar.validateContainer(container, ['PaymentsService', 'BillingService']);
65
+ * ```
66
+ */
67
+ validateContainer(container: PureContainer<string>, requiredServices: string[]): void;
68
+ /**
69
+ * Extract service names from Ties classes for validation.
70
+ *
71
+ * This is a helper method that can be used to automatically determine
72
+ * which services should be registered by a set of Ties classes.
73
+ * Note: This requires the Ties classes to expose their service names,
74
+ * which is optional but recommended for better error reporting.
75
+ *
76
+ * @param tiesClasses - Array of Ties class constructors
77
+ * @returns Array of service names that should be registered
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const expectedServices = registrar.extractServiceNames([PaymentsTies]);
82
+ * registrar.validateContainer(container, expectedServices);
83
+ * ```
84
+ */
85
+ extractServiceNames(tiesClasses: TiesInstance[]): string[];
86
+ }
87
+ //# sourceMappingURL=ties-registrar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ties-registrar.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/di/ties-registrar.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAW,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBACa,aAAa;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,YAAY,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAI;IA6BjF;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,IAAI;IAmBrF;;;;;;;;;;;;;;;;OAgBG;IACH,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE;CAsB3D"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Lambda context information for logging and monitoring.
3
+ */
4
+ export interface LambdaContextInfo {
5
+ /** Lambda function name */
6
+ functionName?: string;
7
+ /** Lambda function version */
8
+ functionVersion?: string;
9
+ /** AWS request ID */
10
+ awsRequestId?: string;
11
+ /** Remaining time in milliseconds */
12
+ getRemainingTimeInMillis?: () => number;
13
+ /** Memory limit in MB */
14
+ memoryLimitInMB?: string;
15
+ /** Log group name */
16
+ logGroupName?: string;
17
+ /** Log stream name */
18
+ logStreamName?: string;
19
+ }
20
+ /**
21
+ * Handler metadata for logging context.
22
+ */
23
+ export interface HandlerMetadata {
24
+ /** Lambda identifier (e.g., 'payments.charge') */
25
+ id: string;
26
+ /** Service name (e.g., 'payments') */
27
+ service: string;
28
+ }
29
+ /**
30
+ * Execution metrics collected during handler invocation.
31
+ */
32
+ export interface ExecutionMetrics {
33
+ /** Start timestamp */
34
+ startTime: number;
35
+ /** End timestamp */
36
+ endTime: number;
37
+ /** Duration in milliseconds */
38
+ duration: number;
39
+ /** Memory usage information (if available) */
40
+ memoryUsed?: number;
41
+ /** Remaining time when handler completed */
42
+ remainingTime?: number;
43
+ }
44
+ /**
45
+ * Logging wrapper for Lambda invocation lifecycle.
46
+ *
47
+ * Provides structured logging for Lambda invocation start/end with
48
+ * contextual information including timing, memory usage, and AWS
49
+ * Lambda context details.
50
+ *
51
+ * @param handler - Original Lambda handler function
52
+ * @param metadata - Handler metadata for logging context
53
+ * @returns Wrapped handler with logging
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const wrappedHandler = loggingWrapper(
58
+ * async (event, context) => { return { success: true }; },
59
+ * { id: 'payments.charge', service: 'payments' }
60
+ * );
61
+ * ```
62
+ */
63
+ export declare function loggingWrapper(handler: (event: unknown, context: unknown) => Promise<unknown>, metadata: HandlerMetadata): (event: unknown, context: unknown) => Promise<unknown>;
64
+ /**
65
+ * Error wrapper for Lambda handler error handling.
66
+ *
67
+ * Catches and logs errors with structured information, then returns
68
+ * appropriate error responses. Handles both thrown errors and rejected
69
+ * promises consistently.
70
+ *
71
+ * @param handler - Original Lambda handler function
72
+ * @param metadata - Handler metadata for error context
73
+ * @returns Wrapped handler with error handling
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const wrappedHandler = errorWrapper(
78
+ * async (event, context) => { return { success: true }; },
79
+ * { id: 'payments.charge', service: 'payments' }
80
+ * );
81
+ * ```
82
+ */
83
+ export declare function errorWrapper(handler: (event: unknown, context: unknown) => Promise<unknown>, metadata: HandlerMetadata): (event: unknown, context: unknown) => Promise<unknown>;
84
+ /**
85
+ * Timing wrapper for Lambda handler performance monitoring.
86
+ *
87
+ * Measures handler execution time and memory usage, providing
88
+ * detailed performance metrics for monitoring and optimization.
89
+ *
90
+ * @param handler - Original Lambda handler function
91
+ * @param metadata - Handler metadata for timing context
92
+ * @returns Wrapped handler with timing measurements
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const wrappedHandler = timingWrapper(
97
+ * async (event, context) => { return { success: true }; },
98
+ * { id: 'payments.charge', service: 'payments' }
99
+ * );
100
+ * ```
101
+ */
102
+ export declare function timingWrapper(handler: (event: unknown, context: unknown) => Promise<unknown>, metadata: HandlerMetadata): (event: unknown, context: unknown) => Promise<unknown>;
103
+ /**
104
+ * Combined wrapper that applies logging, error handling, and timing.
105
+ *
106
+ * Convenience function that applies all three wrappers in the correct
107
+ * order: timing (innermost) → error handling → logging (outermost).
108
+ *
109
+ * @param handler - Original Lambda handler function
110
+ * @param metadata - Handler metadata for all wrappers
111
+ * @returns Fully wrapped handler with all enhancements
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * const wrappedHandler = fullWrapper(
116
+ * async (event, context) => { return { success: true }; },
117
+ * { id: 'payments.charge', service: 'payments' }
118
+ * );
119
+ * ```
120
+ */
121
+ export declare function fullWrapper(handler: (event: unknown, context: unknown) => Promise<unknown>, metadata: HandlerMetadata): (event: unknown, context: unknown) => Promise<unknown>;
122
+ //# sourceMappingURL=handler-wrappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-wrappers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/factory/handler-wrappers.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8BAA8B;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,wBAAwB,CAAC,EAAE,MAAM,MAAM,CAAC;IACxC,yBAAyB;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/D,QAAQ,EAAE,eAAe,GACxB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAoDxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/D,QAAQ,EAAE,eAAe,GACxB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAkDxD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/D,QAAQ,EAAE,eAAe,GACxB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CA+CxD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/D,QAAQ,EAAE,eAAe,GACxB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CASxD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Lambda Handler Factory Module
3
+ *
4
+ * Provides factory classes and utilities for creating Lambda handlers with
5
+ * dependency injection support. This module bridges the gap between the
6
+ * existing Purenow Core LambdaApi infrastructure and the new Runtime Web
7
+ * Core dependency injection system.
8
+ */
9
+ export { LambdaHandlerFactory } from './lambda-handler-factory';
10
+ export { RuntimeWebLambdaHandler } from './runtime-web-lambda-handler';
11
+ export { loggingWrapper, errorWrapper, timingWrapper, fullWrapper, type HandlerMetadata, type LambdaContextInfo, type ExecutionMetrics, } from './handler-wrappers';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/factory/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { PureContainer } from '@worktif/utils';
2
+ import type { LambdaDefinition } from '../../../lib/runtime-web/types';
3
+ import type { RuntimeWebLambdaHandler } from './runtime-web-lambda-handler';
4
+ /**
5
+ * Factory for creating Lambda handlers with dependency injection.
6
+ *
7
+ * Transforms user-provided Lambda definitions into full Lambda handler classes
8
+ * that extend LambdaApi and include automatic dependency injection using
9
+ * PureContainer. Handles the complexity of DI resolution and error wrapping.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const factory = new LambdaHandlerFactory();
14
+ * const handler = factory.create(lambdaDefinition, container);
15
+ *
16
+ * // Handler is ready to be invoked by AWS Lambda runtime
17
+ * const result = await handler.handler(event, context);
18
+ * ```
19
+ */
20
+ export declare class LambdaHandlerFactory {
21
+ private readonly logger;
22
+ constructor();
23
+ /**
24
+ * Create a Lambda handler class instance from a definition.
25
+ *
26
+ * Creates a RuntimeWebLambdaHandler that extends LambdaApi and includes
27
+ * automatic dependency injection. The handler will resolve dependencies
28
+ * from the provided container and inject them into the user's handler function.
29
+ *
30
+ * @param definition - Lambda definition with handler and dependencies
31
+ * @param container - PureContainer with registered services
32
+ * @returns Lambda handler class instance ready for AWS Lambda runtime
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const lambdaDef: LambdaDefinition = {
37
+ * id: 'charge',
38
+ * ties: [PaymentsService, BillingService],
39
+ * handler: (deps) => async (event, context) => {
40
+ * return await deps.paymentsService.processCharge(event.body);
41
+ * }
42
+ * };
43
+ *
44
+ * const handler = factory.create(lambdaDef, container);
45
+ * ```
46
+ */
47
+ create(definition: LambdaDefinition, container: PureContainer<string>): RuntimeWebLambdaHandler;
48
+ /**
49
+ * Inject dependencies from PureContainer using class references.
50
+ *
51
+ * Resolves class references to service instances using PureContainer.run()
52
+ * with class names as keys. Converts class names to camelCase for the
53
+ * dependency object keys (e.g., PaymentsService → paymentsService).
54
+ *
55
+ * @param ties - Array of class constructors for dependency injection
56
+ * @param container - PureContainer with registered services
57
+ * @returns Object with camelCase keys containing resolved dependencies
58
+ * @throws Error if any dependency cannot be resolved
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const ties = [PaymentsService, BillingService];
63
+ * const deps = factory.injectDependencies(ties, container);
64
+ * // Result: { paymentsService: PaymentsService, billingService: BillingService }
65
+ * ```
66
+ */
67
+ injectDependencies(ties: Array<new (...args: unknown[]) => unknown>, container: PureContainer<string>): Record<string, unknown>;
68
+ /**
69
+ * Wrap a handler function with logging and error handling.
70
+ *
71
+ * Adds structured logging for Lambda invocation start/end, error handling
72
+ * that catches and logs exceptions, and timing information. Returns a
73
+ * wrapped handler that maintains the same signature as the original.
74
+ *
75
+ * @param handler - Original Lambda handler function
76
+ * @param metadata - Lambda metadata for logging context
77
+ * @returns Wrapped handler with logging and error handling
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const wrappedHandler = factory.wrapHandler(
82
+ * async (event, context) => { return { success: true }; },
83
+ * { id: 'payments.charge', service: 'payments' }
84
+ * );
85
+ * ```
86
+ */
87
+ wrapHandler(handler: (event: unknown, context: unknown) => Promise<unknown>, metadata: {
88
+ id: string;
89
+ service: string;
90
+ }): (event: unknown, context: unknown) => Promise<unknown>;
91
+ /**
92
+ * Convert class name to camelCase for dependency object keys.
93
+ *
94
+ * Converts PascalCase class names to camelCase property names for the
95
+ * dependency injection object. This provides a consistent naming convention
96
+ * for injected dependencies.
97
+ *
98
+ * @param className - PascalCase class name
99
+ * @returns camelCase property name
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * factory.toCamelCase('PaymentsService'); // 'paymentsService'
104
+ * factory.toCamelCase('BillingService'); // 'billingService'
105
+ * factory.toCamelCase('ConfigService'); // 'configService'
106
+ * ```
107
+ */
108
+ private toCamelCase;
109
+ }
110
+ //# sourceMappingURL=lambda-handler-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-handler-factory.d.ts","sourceRoot":"","sources":["../../../../../../src/core/runtime-web/factory/lambda-handler-factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAmB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACH,qBACa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;;IAQhC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,uBAAuB;IAY/F;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAAkB,CAChB,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EAChD,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAqC1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CACT,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/D,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACxC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC;IAIzD;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,WAAW;CAGpB"}