@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,4 @@
1
+ import 'reflect-metadata';
2
+ export * from '@worktif/purenow/lambda';
3
+ export * from './runtime-extensions';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/services/index.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAG1B,cAAc,yBAAyB,CAAC;AAGxC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import 'reflect-metadata';
2
+ export * from './runtime-extensions.service';
3
+ export * from './runtime-extensions.types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/services/runtime-extensions/index.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,98 @@
1
+ import 'reflect-metadata';
2
+ import { BeforeInstance, Maybe } from '@worktif/utils';
3
+ import type { RuntimeConfig, RuntimeStackConfig } from './runtime-extensions.types';
4
+ /**
5
+ * RuntimeExtensions service provides runtime-specific functionality that extends
6
+ * purenow's base capabilities. This service follows purenow's architectural patterns
7
+ * for AWS integrations and dependency injection.
8
+ *
9
+ * Key responsibilities:
10
+ * - Enhance development server with runtime-specific features
11
+ * - Provide runtime-specific build optimizations
12
+ * - Configure Runtime Core stack deployment
13
+ * - Extend purenow functionality without replacing it
14
+ */
15
+ export declare class RuntimeExtensions {
16
+ /**
17
+ * Runtime configuration with default values.
18
+ * Extends purenow configuration rather than replacing it.
19
+ */
20
+ private runtimeConfig;
21
+ /**
22
+ * Constructor for RuntimeExtensions service.
23
+ * Uses dependency injection pattern consistent with purenow services.
24
+ */
25
+ constructor();
26
+ /**
27
+ * Initialize runtime extensions with default configuration.
28
+ * Sets up runtime-specific features that extend purenow functionality.
29
+ */
30
+ private initializeRuntimeExtensions;
31
+ /**
32
+ * Enhance development server with runtime-specific features.
33
+ * Extends purenow's development server without replacing it.
34
+ *
35
+ * @param serverConfig - Base server configuration from purenow
36
+ * @param beforeInstance - Logger instance for tracking
37
+ * @returns Runtime Core server configuration
38
+ */
39
+ enhanceDevServer(serverConfig: Record<string, any>, beforeInstance?: BeforeInstance): Promise<Record<string, any>>;
40
+ /**
41
+ * Optimize build process with runtime-specific optimizations.
42
+ * Extends purenow's build process without replacing it.
43
+ *
44
+ * @param buildConfig - Base build configuration from purenow
45
+ * @param beforeInstance - Logger instance for tracking
46
+ * @returns Optimized build configuration
47
+ */
48
+ optimizeBuild(buildConfig: Record<string, any>, beforeInstance?: BeforeInstance): Promise<Record<string, any>>;
49
+ /**
50
+ * Configure Runtime Core stack for runtime deployment.
51
+ * Extends purenow's two-stack architecture to three stacks.
52
+ *
53
+ * @param baseStackConfig - Base stack configuration from purenow
54
+ * @param beforeInstance - Logger instance for tracking
55
+ * @returns Runtime stack configuration for Runtime Core stack
56
+ */
57
+ configureRuntimeCoreStack(baseStackConfig: Record<string, any>, beforeInstance?: BeforeInstance): Promise<Maybe<RuntimeStackConfig>>;
58
+ /**
59
+ * Update runtime configuration.
60
+ * Allows dynamic configuration of runtime features.
61
+ *
62
+ * @param config - New runtime configuration
63
+ * @param beforeInstance - Logger instance for tracking
64
+ */
65
+ updateConfiguration(config: Partial<RuntimeConfig>, beforeInstance?: BeforeInstance): Promise<void>;
66
+ /**
67
+ * Get current runtime configuration.
68
+ * Provides read-only access to runtime configuration.
69
+ *
70
+ * @returns Current runtime configuration
71
+ */
72
+ getConfiguration(): Readonly<RuntimeConfig>;
73
+ /**
74
+ * Check if runtime feature is enabled.
75
+ * Utility method for checking feature flags.
76
+ *
77
+ * @param feature - Feature name to check
78
+ * @returns True if feature is enabled
79
+ */
80
+ isFeatureEnabled(feature: string): boolean;
81
+ /**
82
+ * Enable runtime feature.
83
+ * Adds feature to the list of enabled features.
84
+ *
85
+ * @param feature - Feature name to enable
86
+ * @param beforeInstance - Logger instance for tracking
87
+ */
88
+ enableFeature(feature: string, beforeInstance?: BeforeInstance): Promise<void>;
89
+ /**
90
+ * Disable runtime feature.
91
+ * Removes feature from the list of enabled features.
92
+ *
93
+ * @param feature - Feature name to disable
94
+ * @param beforeInstance - Logger instance for tracking
95
+ */
96
+ disableFeature(feature: string, beforeInstance?: BeforeInstance): Promise<void>;
97
+ }
98
+ //# sourceMappingURL=runtime-extensions.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-extensions.service.d.ts","sourceRoot":"","sources":["../../../../../../src/core/services/runtime-extensions/runtime-extensions.service.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EAKd,KAAK,EAEN,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,qBACa,iBAAiB;IAY5B;;;OAGG;IACH,OAAO,CAAC,aAAa,CAcnB;IAEF;;;OAGG;;IAMH;;;OAGG;YAKW,2BAA2B;IAazC;;;;;;;OAOG;IAKU,gBAAgB,CAC3B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IA0B/B;;;;;;;OAOG;IAKU,aAAa,CACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IA0B/B;;;;;;;OAOG;IAKU,yBAAyB,CACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpC,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IA6CrC;;;;;;OAMG;IAKU,mBAAmB,CAC9B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,EAC9B,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,IAAI,CAAC;IA0BhB;;;;;OAKG;IACI,gBAAgB,IAAI,QAAQ,CAAC,aAAa,CAAC;IAIlD;;;;;;OAMG;IACI,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIjD;;;;;;OAMG;IAKU,aAAa,CACxB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;OAMG;IAKU,cAAc,CACzB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC,IAAI,CAAC;CAgBjB"}
@@ -0,0 +1,71 @@
1
+ import 'reflect-metadata';
2
+ /**
3
+ * Configuration options for runtime-specific features.
4
+ */
5
+ export interface RuntimeConfig {
6
+ /** Enable Runtime Core stack deployment */
7
+ enableRuntimeCoreStack?: boolean;
8
+ /** Runtime web mode configuration */
9
+ runtimeWebMode?: 'development' | 'production';
10
+ /** Additional runtime features to enable */
11
+ additionalFeatures?: string[];
12
+ /** Development server enhancements */
13
+ devServerEnhancements?: {
14
+ hotReload?: boolean;
15
+ debugMode?: boolean;
16
+ performanceMonitoring?: boolean;
17
+ };
18
+ /** Build optimizations */
19
+ buildOptimizations?: {
20
+ bundleAnalysis?: boolean;
21
+ treeshaking?: boolean;
22
+ codeMinification?: boolean;
23
+ };
24
+ }
25
+ /**
26
+ * Runtime stack configuration for the Runtime Core stack.
27
+ */
28
+ export interface RuntimeStackConfig {
29
+ /** Name of the runtime stack */
30
+ stackName: string;
31
+ /** AWS resources to include in the stack */
32
+ resources: RuntimeResource[];
33
+ /** Dependencies on other stacks */
34
+ dependencies: string[];
35
+ /** Stack outputs to export */
36
+ outputs: Record<string, string>;
37
+ }
38
+ /**
39
+ * Runtime-specific AWS resource configuration.
40
+ */
41
+ export interface RuntimeResource {
42
+ /** Resource type (e.g., 'Lambda', 'DynamoDB', 'S3') */
43
+ type: string;
44
+ /** Resource name */
45
+ name: string;
46
+ /** Resource configuration */
47
+ config: Record<string, any>;
48
+ }
49
+ /**
50
+ * Development server enhancement options.
51
+ */
52
+ export interface DevServerEnhancements {
53
+ /** Enable hot module replacement */
54
+ hotReload: boolean;
55
+ /** Enable debug mode with additional logging */
56
+ debugMode: boolean;
57
+ /** Enable performance monitoring */
58
+ performanceMonitoring: boolean;
59
+ }
60
+ /**
61
+ * Build optimization configuration.
62
+ */
63
+ export interface BuildOptimizations {
64
+ /** Enable bundle analysis */
65
+ bundleAnalysis: boolean;
66
+ /** Enable tree shaking */
67
+ treeshaking: boolean;
68
+ /** Enable code minification */
69
+ codeMinification: boolean;
70
+ }
71
+ //# sourceMappingURL=runtime-extensions.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-extensions.types.d.ts","sourceRoot":"","sources":["../../../../../../src/core/services/runtime-extensions/runtime-extensions.types.ts"],"names":[],"mappings":"AAgBA,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qCAAqC;IACrC,cAAc,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;IAC9C,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,sCAAsC;IACtC,qBAAqB,CAAC,EAAE;QACtB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,qBAAqB,CAAC,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE;QACnB,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,mCAAmC;IACnC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,SAAS,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,0BAA0B;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,+BAA+B;IAC/B,gBAAgB,EAAE,OAAO,CAAC;CAC3B"}
@@ -0,0 +1,3 @@
1
+ export * from '@worktif/purenow/infra';
2
+ export * from './runtime-web';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,157 @@
1
+ import { Construct } from 'constructs';
2
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
3
+ import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import type { HttpMethod } from '../../../lib/runtime-web/types';
5
+ import { PurenowInfraResourceOptions, PurenowInfraResources } from '@worktif/purenow/infra';
6
+ import { RuntimeWebStackProps } from '../../runtime-web';
7
+ /**
8
+ * Properties for ApiGatewayBuilder construct
9
+ */
10
+ export interface ApiGatewayBuilderProps {
11
+ /**
12
+ * Deployment stage
13
+ */
14
+ stage: 'dev' | 'staging' | 'prod';
15
+ /**
16
+ * Service name for resource naming
17
+ */
18
+ serviceName: string;
19
+ /**
20
+ * Allowed origins for CORS
21
+ * @default ['*'] for dev/staging, specific domains for prod
22
+ */
23
+ allowedOrigins?: string[];
24
+ /**
25
+ * Custom domain configuration
26
+ */
27
+ domain?: {
28
+ rootDomain: string;
29
+ subdomain?: string;
30
+ certificateArn?: string;
31
+ hostedZoneId?: string;
32
+ };
33
+ }
34
+ /**
35
+ * ApiGatewayBuilder - CDK construct for building API Gateway from Lambda definitions.
36
+ *
37
+ * Creates HTTP API Gateway with routes for Lambda functions based on their
38
+ * HttpIntegration configuration. Supports CORS, authentication, and custom domains.
39
+ *
40
+ * **Features**:
41
+ * - Automatic route creation from HttpIntegration
42
+ * - CORS configuration based on stage
43
+ * - Authentication mapping (none, jwt, iam, cognito, custom)
44
+ * - Custom domain support
45
+ * - Named stages (not $default)
46
+ *
47
+ * **Requirements**: REQ-14
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const builder = new ApiGatewayBuilder(this, 'ApiGatewayBuilder', {
52
+ * stage: 'dev',
53
+ * serviceName: 'my-app'
54
+ * });
55
+ *
56
+ * const { api, stage } = builder.createApiGateway(lambdaFunctions, register);
57
+ * ```
58
+ */
59
+ export declare class ApiGatewayBuilder extends Construct implements PurenowInfraResources {
60
+ private readonly props;
61
+ /**
62
+ * Microservice registrar for DI container management
63
+ */
64
+ private readonly registrar;
65
+ constructor(scope: Construct, id: string, props: ApiGatewayBuilderProps);
66
+ /**
67
+ * Create API Gateway with routes for all Lambda functions.
68
+ *
69
+ * Creates an HTTP API with routes based on the HttpIntegration configuration
70
+ * of each Lambda definition. Only creates routes for Lambdas with HTTP config.
71
+ *
72
+ * @param lambdaFunctions - Map of Lambda functions by ID
73
+ * @param props
74
+ * @returns Object with API Gateway and stage
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const { api, stage } = builder.createApiGateway(lambdaFunctions, {
79
+ * payments: {
80
+ * ties: [PaymentsTies],
81
+ * lambdas: [
82
+ * {
83
+ * id: 'charge',
84
+ * http: { method: 'POST', path: '/api/payments/charge' }
85
+ * }
86
+ * ]
87
+ * }
88
+ * });
89
+ * ```
90
+ */
91
+ createApiGateway(lambdaFunctions: Map<string, lambda.Function>, props: RuntimeWebStackProps): {
92
+ api: apigatewayv2.HttpApi;
93
+ stage: apigatewayv2.HttpStage;
94
+ };
95
+ /**
96
+ * Create a route for a Lambda function.
97
+ *
98
+ * Creates an API Gateway route with Lambda integration based on the
99
+ * HttpIntegration configuration.
100
+ *
101
+ * @param api - HTTP API instance
102
+ * @param lambdaFn - Lambda function to integrate
103
+ * @param http - HTTP integration configuration
104
+ * @param lambdaId - Lambda ID for naming
105
+ * @private
106
+ */
107
+ private createRoute;
108
+ /**
109
+ * Map high-level HTTP method to CDK HttpMethod.
110
+ *
111
+ * @param method - High-level HTTP method string
112
+ * @returns CDK HttpMethod enum value
113
+ */
114
+ mapHttpMethod(method: HttpMethod): apigatewayv2.HttpMethod;
115
+ /**
116
+ * Create authorizer based on auth type.
117
+ *
118
+ * Maps high-level auth types to CDK authorizer configurations.
119
+ * Currently supports 'none' (no auth). JWT, IAM, Cognito, and custom
120
+ * authorizers can be added in future iterations.
121
+ *
122
+ * @param authType - Authentication type
123
+ * @returns Authorizer or undefined for no auth
124
+ * @private
125
+ */
126
+ private createAuthorizer;
127
+ /**
128
+ * Create CORS configuration for API Gateway.
129
+ *
130
+ * Creates CORS preflight options based on stage and allowed origins.
131
+ *
132
+ * @param allowedOrigins - Array of allowed origins
133
+ * @returns CORS preflight options
134
+ * @private
135
+ */
136
+ private createCorsConfig;
137
+ /**
138
+ * Generates a signature for the provided region by extracting the first character of each segment in the region string, delimited by hyphens.
139
+ *
140
+ * @param {string} region - The region string to generate the signature from. It is expected to be a hyphen-separated string.
141
+ * @return {string} The generated region signature, formed by concatenating the first character of each valid segment. Returns an empty string if the input is invalid or empty.
142
+ */
143
+ private getRegionSignature;
144
+ /**
145
+ * Generates a resource name by concatenating service name, resource name,
146
+ * simplified region, and stage with hyphens as separators.
147
+ *
148
+ * @param {Object} params - An object containing the required parameters.
149
+ * @param {string} params.name - The name of the resource.
150
+ * @param {string} params.serviceName - The name of the service associated with the resource.
151
+ * @param {string} params.regionSimplified - The simplified region identifier.
152
+ * @param {string} params.stage - The deployment stage of the resource.
153
+ * @returns {string} The concatenated resource name.
154
+ */
155
+ resourceName({ name, serviceName, stage, region }: PurenowInfraResourceOptions): string;
156
+ }
157
+ //# sourceMappingURL=api-gateway-builder.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { LambdaBuilder, LambdaBuilderProps } from './lambda-builder';
2
+ export { ApiGatewayBuilder, ApiGatewayBuilderProps } from './api-gateway-builder';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,158 @@
1
+ import { Construct } from 'constructs';
2
+ import * as lambda from 'aws-cdk-lib/aws-lambda';
3
+ import * as iam from 'aws-cdk-lib/aws-iam';
4
+ import type { LambdaDefinition, VpcConfig } from '../../../lib/runtime-web/types';
5
+ import { PurenowInfraResourceOptions, PurenowInfraResources } from '@worktif/purenow/infra';
6
+ import { RuntimeWebStackProps } from '../../runtime-web';
7
+ /**
8
+ * Properties for LambdaBuilder construct
9
+ */
10
+ export interface LambdaBuilderProps {
11
+ /**
12
+ * Deployment stage
13
+ */
14
+ stage: 'dev' | 'staging' | 'prod';
15
+ /**
16
+ * Service name for resource naming
17
+ */
18
+ serviceName: string;
19
+ /**
20
+ * IAM role for Lambda execution
21
+ */
22
+ lambdaRole: iam.IRole;
23
+ /**
24
+ * Default memory size in MB
25
+ * @default 512
26
+ */
27
+ defaultMemorySize?: number;
28
+ /**
29
+ * Default timeout in seconds
30
+ * @default 30
31
+ */
32
+ defaultTimeout?: number;
33
+ /**
34
+ * Global environment variables
35
+ */
36
+ globalEnvironment?: Record<string, string>;
37
+ /**
38
+ * VPC configuration
39
+ */
40
+ vpc?: VpcConfig;
41
+ }
42
+ /**
43
+ * LambdaBuilder - CDK construct for building Lambda functions from definitions.
44
+ *
45
+ * Creates Lambda functions with proper configuration, environment variables,
46
+ * IAM permissions, and CloudWatch log groups. Supports VPC deployment and
47
+ * X-Ray tracing.
48
+ *
49
+ * **Features**:
50
+ * - Automatic Lambda function creation from LambdaDefinition
51
+ * - Environment variable injection (LAMBDA_ID, SERVICE_NAME, STAGE)
52
+ * - CloudWatch log group with retention policy
53
+ * - X-Ray tracing support
54
+ * - VPC deployment support
55
+ * - AWS SDK v3 externalization for bundle size optimization
56
+ *
57
+ * **Requirements**: REQ-11, REQ-13
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const builder = new LambdaBuilder(this, 'LambdaBuilder', {
62
+ * stage: 'dev',
63
+ * serviceName: 'my-app',
64
+ * lambdaRole,
65
+ * defaultMemorySize: 512,
66
+ * defaultTimeout: 30
67
+ * });
68
+ *
69
+ * const lambdaFn = builder.buildLambda('payments.charge', 'payments', lambdaDef);
70
+ * ```
71
+ */
72
+ export declare class LambdaBuilder extends Construct implements PurenowInfraResources {
73
+ private readonly props;
74
+ private readonly vpc?;
75
+ private readonly securityGroups?;
76
+ private readonly subnets?;
77
+ constructor(scope: Construct, id: string, props: LambdaBuilderProps);
78
+ /**
79
+ * Build a Lambda function from a LambdaDefinition.
80
+ *
81
+ * Creates a Lambda function with proper configuration, environment variables,
82
+ * and CloudWatch log group. The function is configured for Runtime Web Core
83
+ * with DI support.
84
+ *
85
+ * @param props
86
+ * @param lambdaId - Full Lambda ID (e.g., 'payments.charge')
87
+ * @param serviceName - Name of the parent microservice
88
+ * @param definition - Lambda definition with handler and configuration
89
+ * @returns Lambda Function instance
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const lambdaFn = builder.buildLambda('payments.charge', 'payments', {
94
+ * id: 'charge',
95
+ * ties: [PaymentsService],
96
+ * handler: (deps) => async (event) => { ... },
97
+ * http: { method: 'POST', path: '/api/payments/charge' },
98
+ * config: { memorySize: 1024, timeout: 60 }
99
+ * });
100
+ * ```
101
+ */
102
+ buildLambda(props: RuntimeWebStackProps, lambdaId: string, serviceName: string, definition: LambdaDefinition): lambda.Function;
103
+ /**
104
+ * Build environment variables for Lambda function.
105
+ *
106
+ * Combines global environment variables with Lambda-specific variables
107
+ * including LAMBDA_ID, SERVICE_NAME, and STAGE.
108
+ *
109
+ * @param lambdaId - Full Lambda ID
110
+ * @param serviceName - Name of the parent microservice
111
+ * @param definition - Lambda definition
112
+ * @returns Environment variables record
113
+ * @private
114
+ */
115
+ private buildEnvironment;
116
+ /**
117
+ * Get Lambda code asset.
118
+ *
119
+ * Returns the Lambda code asset for the function. For Runtime Web Core,
120
+ * this uses inline code that imports from the Lambda Layer.
121
+ *
122
+ * // @todp: here smth wrong I see
123
+ *
124
+ * @param definition - Lambda definition
125
+ * @returns Lambda Code asset
126
+ * @private
127
+ */
128
+ private getLambdaCode;
129
+ /**
130
+ * Add IAM permissions to Lambda function.
131
+ *
132
+ * Adds additional IAM permissions to the Lambda function's execution role.
133
+ *
134
+ * @param lambdaFunction - Lambda function to add permissions to
135
+ * @param permissions - Array of IAM policy statements
136
+ */
137
+ addPermissions(lambdaFunction: lambda.Function, permissions: iam.PolicyStatement[]): void;
138
+ /**
139
+ * Generates a signature for the provided region by extracting the first character of each segment in the region string, delimited by hyphens.
140
+ *
141
+ * @param {string} region - The region string to generate the signature from. It is expected to be a hyphen-separated string.
142
+ * @return {string} The generated region signature, formed by concatenating the first character of each valid segment. Returns an empty string if the input is invalid or empty.
143
+ */
144
+ private getRegionSignature;
145
+ /**
146
+ * Generates a resource name by concatenating service name, resource name,
147
+ * simplified region, and stage with hyphens as separators.
148
+ *
149
+ * @param {Object} params - An object containing the required parameters.
150
+ * @param {string} params.name - The name of the resource.
151
+ * @param {string} params.serviceName - The name of the service associated with the resource.
152
+ * @param {string} params.regionSimplified - The simplified region identifier.
153
+ * @param {string} params.stage - The deployment stage of the resource.
154
+ * @returns {string} The concatenated resource name.
155
+ */
156
+ resourceName({ name, serviceName, stage, region }: PurenowInfraResourceOptions): string;
157
+ }
158
+ //# sourceMappingURL=lambda-builder.d.ts.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Runtime Web Core - Infrastructure (CDK)
3
+ *
4
+ * **ARCHITECTURE NOTE**: This module contains CDK-only code that:
5
+ * - Runs ONLY during `cdk synth` and `cdk deploy`
6
+ * - Imports from `@infra/*` (CDK constructs, stacks)
7
+ * - Uses `aws-cdk-lib` (build-time dependency)
8
+ * - NEVER runs in Lambda or browser
9
+ * - NEVER bundled into Lambda or browser builds
10
+ *
11
+ * **Exports**:
12
+ * - CDKPipeline: Synthesizes CloudFormation templates from microservice definitions
13
+ * - RuntimeWebStack: CDK stack for Lambda functions and API Gateway
14
+ * - LambdaBuilder: Construct for creating Lambda functions
15
+ * - ApiGatewayBuilder: Construct for creating API Gateway
16
+ */
17
+ export * from './constructs';
18
+ export * from './pipelines';
19
+ export * from './stacks';
20
+ export * from './validation';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,112 @@
1
+ import type { CDKMetadata, RuntimeWebConfig } from '../../../lib/runtime-web/types';
2
+ /**
3
+ * CDK execution pipeline for Runtime Target Core.
4
+ *
5
+ * **ARCHITECTURE NOTE**: This file is in `src/infra/` because it:
6
+ * - Imports from `@infra/*` (CDK constructs, stacks)
7
+ * - Uses `aws-cdk-lib` (build-time only)
8
+ * - Synthesizes CloudFormation templates (local execution only)
9
+ * - NEVER runs in Lambda or browser
10
+ *
11
+ * Handles CloudFormation template synthesis from microservice definitions.
12
+ * Creates CDK App, infrastructure stack (S3, CloudFront, DynamoDB), and
13
+ * runtime stack (Lambda functions, API Gateway) based on the configuration.
14
+ *
15
+ * **Execution Flow**:
16
+ * 1. Create CDK App instance
17
+ * 2. Create PurenowInfraStack for S3/CloudFront/DynamoDB
18
+ * 3. Create RuntimeWebStack for Lambda/API Gateway
19
+ * 4. Call app.synth() to synthesize CloudFormation
20
+ *
21
+ * **Requirements**: REQ-06, REQ-11
22
+ */
23
+ export declare class CDKPipeline {
24
+ private readonly logger;
25
+ /**
26
+ * Execute CDK pipeline for infrastructure synthesis.
27
+ *
28
+ * Creates CDK App and stacks based on the configuration, then synthesizes
29
+ * CloudFormation templates. The infrastructure configuration is required
30
+ * for CDK context execution.
31
+ *
32
+ * @param config - Purenow configuration with infrastructure options
33
+ * @param context - CDK environment context with metadata
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const pipeline = new CDKPipeline();
38
+ * await pipeline.execute(config, {
39
+ * type: 'cdk',
40
+ * metadata: {
41
+ * account: '123456789012',
42
+ * region: 'us-east-1',
43
+ * cdkVersion: '2.100.0',
44
+ * nodeVersion: '18.17.0'
45
+ * }
46
+ * });
47
+ * ```
48
+ */
49
+ execute(config: RuntimeWebConfig, context: {
50
+ type: 'cdk';
51
+ metadata: CDKMetadata;
52
+ }): Promise<void>;
53
+ /**
54
+ * Create CDK App instance.
55
+ *
56
+ * Creates the root CDK App that will contain all stacks.
57
+ *
58
+ * @returns CDK App instance
59
+ * @private
60
+ */
61
+ private createCDKApp;
62
+ /**
63
+ * Create infrastructure stack for S3, CloudFront, and DynamoDB.
64
+ *
65
+ * Creates the PurenowInfraStack with all the foundational AWS resources
66
+ * needed for the application (storage, CDN, database).
67
+ *
68
+ * @param app - CDK App instance
69
+ * @param config - Purenow configuration
70
+ * @param infraOptions - Infrastructure configuration
71
+ * @returns PurenowInfraStack instance
72
+ * @private
73
+ */
74
+ private createInfraStack;
75
+ /**
76
+ * Create runtime stack for Lambda functions and API Gateway.
77
+ *
78
+ * Creates the RuntimeWebStack with all the Lambda functions and API Gateway
79
+ * based on the microservice definitions. This stack depends on the
80
+ * infrastructure stack for shared resources.
81
+ *
82
+ * @param app - CDK App instance
83
+ * @param config - Purenow configuration
84
+ * @param infraOptions - Infrastructure configuration
85
+ * @param infraStack - Infrastructure stack instance
86
+ * @returns RuntimeWebStack instance or undefined if no microservices
87
+ * @private
88
+ */
89
+ private createRuntimeStack;
90
+ /**
91
+ * Synthesize CDK App to CloudFormation templates.
92
+ *
93
+ * Calls app.synth() to generate CloudFormation templates from the
94
+ * defined stacks. This is the final step that produces the deployable
95
+ * infrastructure code.
96
+ *
97
+ * @param app - CDK App instance with stacks
98
+ * @private
99
+ */
100
+ private synthesizeApp;
101
+ /**
102
+ * Get RuntimeWebStack class.
103
+ *
104
+ * Returns the RuntimeWebStack class for creating runtime stacks
105
+ * with microservice support.
106
+ *
107
+ * @returns RuntimeWebStack class constructor
108
+ * @private
109
+ */
110
+ private getRuntimeWebStackClass;
111
+ }
112
+ //# sourceMappingURL=cdk-pipeline.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { CDKPipeline } from './cdk-pipeline';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { RuntimeWebStack, RuntimeWebStackProps } from './runtime-web-stack';
2
+ //# sourceMappingURL=index.d.ts.map