@incloodsolutions/devkit 0.0.1 → 0.0.3

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 (154) hide show
  1. package/README.md +42 -16
  2. package/dist/aws/cdk/constructs/api-gateway-construct.cjs +95 -0
  3. package/dist/aws/cdk/constructs/api-gateway-construct.cjs.map +1 -0
  4. package/dist/aws/cdk/constructs/api-gateway-construct.d.cts +80 -0
  5. package/dist/aws/cdk/constructs/api-gateway-construct.d.ts +80 -0
  6. package/dist/aws/cdk/constructs/api-gateway-construct.js +93 -0
  7. package/dist/aws/cdk/constructs/api-gateway-construct.js.map +1 -0
  8. package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs +77 -0
  9. package/dist/aws/cdk/constructs/api-gateway-v2-construct.cjs.map +1 -0
  10. package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.cts +55 -0
  11. package/dist/aws/cdk/constructs/api-gateway-v2-construct.d.ts +55 -0
  12. package/dist/aws/cdk/constructs/api-gateway-v2-construct.js +75 -0
  13. package/dist/aws/cdk/constructs/api-gateway-v2-construct.js.map +1 -0
  14. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs +65 -0
  15. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.cjs.map +1 -0
  16. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.cts +73 -0
  17. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.d.ts +73 -0
  18. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js +63 -0
  19. package/dist/aws/cdk/constructs/api-gateway-websocket-construct.js.map +1 -0
  20. package/dist/aws/cdk/constructs/cloudfront-construct.cjs +68 -0
  21. package/dist/aws/cdk/constructs/cloudfront-construct.cjs.map +1 -0
  22. package/dist/aws/cdk/constructs/cloudfront-construct.d.cts +36 -0
  23. package/dist/aws/cdk/constructs/cloudfront-construct.d.ts +36 -0
  24. package/dist/aws/cdk/constructs/cloudfront-construct.js +66 -0
  25. package/dist/aws/cdk/constructs/cloudfront-construct.js.map +1 -0
  26. package/dist/aws/cdk/constructs/cloudwatch-construct.cjs +43 -0
  27. package/dist/aws/cdk/constructs/cloudwatch-construct.cjs.map +1 -0
  28. package/dist/aws/cdk/constructs/cloudwatch-construct.d.cts +36 -0
  29. package/dist/aws/cdk/constructs/cloudwatch-construct.d.ts +36 -0
  30. package/dist/aws/cdk/constructs/cloudwatch-construct.js +41 -0
  31. package/dist/aws/cdk/constructs/cloudwatch-construct.js.map +1 -0
  32. package/dist/aws/cdk/constructs/dynamo-db-construct.cjs +113 -0
  33. package/dist/aws/cdk/constructs/dynamo-db-construct.cjs.map +1 -0
  34. package/dist/aws/cdk/constructs/dynamo-db-construct.d.cts +53 -0
  35. package/dist/aws/cdk/constructs/dynamo-db-construct.d.ts +53 -0
  36. package/dist/aws/cdk/constructs/dynamo-db-construct.js +111 -0
  37. package/dist/aws/cdk/constructs/dynamo-db-construct.js.map +1 -0
  38. package/dist/aws/cdk/constructs/event-bridge-construct.cjs +47 -0
  39. package/dist/aws/cdk/constructs/event-bridge-construct.cjs.map +1 -0
  40. package/dist/aws/cdk/constructs/event-bridge-construct.d.cts +41 -0
  41. package/dist/aws/cdk/constructs/event-bridge-construct.d.ts +41 -0
  42. package/dist/aws/cdk/constructs/event-bridge-construct.js +45 -0
  43. package/dist/aws/cdk/constructs/event-bridge-construct.js.map +1 -0
  44. package/dist/aws/cdk/constructs/index.cjs +881 -0
  45. package/dist/aws/cdk/constructs/index.cjs.map +1 -0
  46. package/dist/aws/cdk/constructs/index.d.cts +34 -0
  47. package/dist/aws/cdk/constructs/index.d.ts +34 -0
  48. package/dist/aws/cdk/constructs/index.js +863 -0
  49. package/dist/aws/cdk/constructs/index.js.map +1 -0
  50. package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs +37 -0
  51. package/dist/aws/cdk/constructs/lambda-authorizer-construct.cjs.map +1 -0
  52. package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.cts +44 -0
  53. package/dist/aws/cdk/constructs/lambda-authorizer-construct.d.ts +44 -0
  54. package/dist/aws/cdk/constructs/lambda-authorizer-construct.js +35 -0
  55. package/dist/aws/cdk/constructs/lambda-authorizer-construct.js.map +1 -0
  56. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs +47 -0
  57. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.cjs.map +1 -0
  58. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.cts +45 -0
  59. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.d.ts +45 -0
  60. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js +45 -0
  61. package/dist/aws/cdk/constructs/lambda-authorizer-v2-construct.js.map +1 -0
  62. package/dist/aws/cdk/constructs/lambda-construct.cjs +82 -0
  63. package/dist/aws/cdk/constructs/lambda-construct.cjs.map +1 -0
  64. package/dist/aws/cdk/constructs/lambda-construct.d.cts +37 -0
  65. package/dist/aws/cdk/constructs/lambda-construct.d.ts +37 -0
  66. package/dist/aws/cdk/constructs/lambda-construct.js +80 -0
  67. package/dist/aws/cdk/constructs/lambda-construct.js.map +1 -0
  68. package/dist/aws/cdk/constructs/lambda-layer-construct.cjs +72 -0
  69. package/dist/aws/cdk/constructs/lambda-layer-construct.cjs.map +1 -0
  70. package/dist/aws/cdk/constructs/lambda-layer-construct.d.cts +52 -0
  71. package/dist/aws/cdk/constructs/lambda-layer-construct.d.ts +52 -0
  72. package/dist/aws/cdk/constructs/lambda-layer-construct.js +70 -0
  73. package/dist/aws/cdk/constructs/lambda-layer-construct.js.map +1 -0
  74. package/dist/aws/cdk/constructs/role-policy-construct.cjs +53 -0
  75. package/dist/aws/cdk/constructs/role-policy-construct.cjs.map +1 -0
  76. package/dist/aws/cdk/constructs/role-policy-construct.d.cts +44 -0
  77. package/dist/aws/cdk/constructs/role-policy-construct.d.ts +44 -0
  78. package/dist/aws/cdk/constructs/role-policy-construct.js +51 -0
  79. package/dist/aws/cdk/constructs/role-policy-construct.js.map +1 -0
  80. package/dist/aws/cdk/constructs/s3-construct.cjs +38 -0
  81. package/dist/aws/cdk/constructs/s3-construct.cjs.map +1 -0
  82. package/dist/aws/cdk/constructs/s3-construct.d.cts +36 -0
  83. package/dist/aws/cdk/constructs/s3-construct.d.ts +36 -0
  84. package/dist/aws/cdk/constructs/s3-construct.js +36 -0
  85. package/dist/aws/cdk/constructs/s3-construct.js.map +1 -0
  86. package/dist/aws/cdk/constructs/s3-deployment-construct.cjs +168 -0
  87. package/dist/aws/cdk/constructs/s3-deployment-construct.cjs.map +1 -0
  88. package/dist/aws/cdk/constructs/s3-deployment-construct.d.cts +72 -0
  89. package/dist/aws/cdk/constructs/s3-deployment-construct.d.ts +72 -0
  90. package/dist/aws/cdk/constructs/s3-deployment-construct.js +166 -0
  91. package/dist/aws/cdk/constructs/s3-deployment-construct.js.map +1 -0
  92. package/dist/aws/cdk/constructs/sns-construct.cjs +43 -0
  93. package/dist/aws/cdk/constructs/sns-construct.cjs.map +1 -0
  94. package/dist/aws/cdk/constructs/sns-construct.d.cts +45 -0
  95. package/dist/aws/cdk/constructs/sns-construct.d.ts +45 -0
  96. package/dist/aws/cdk/constructs/sns-construct.js +41 -0
  97. package/dist/aws/cdk/constructs/sns-construct.js.map +1 -0
  98. package/dist/aws/cdk/constructs/sqs-construct.cjs +55 -0
  99. package/dist/aws/cdk/constructs/sqs-construct.cjs.map +1 -0
  100. package/dist/aws/cdk/constructs/sqs-construct.d.cts +52 -0
  101. package/dist/aws/cdk/constructs/sqs-construct.d.ts +52 -0
  102. package/dist/aws/cdk/constructs/sqs-construct.js +53 -0
  103. package/dist/aws/cdk/constructs/sqs-construct.js.map +1 -0
  104. package/dist/aws/cdk/constructs/vpc-construct.cjs +33 -0
  105. package/dist/aws/cdk/constructs/vpc-construct.cjs.map +1 -0
  106. package/dist/aws/cdk/constructs/vpc-construct.d.cts +34 -0
  107. package/dist/aws/cdk/constructs/vpc-construct.d.ts +34 -0
  108. package/dist/aws/cdk/constructs/vpc-construct.js +31 -0
  109. package/dist/aws/cdk/constructs/vpc-construct.js.map +1 -0
  110. package/dist/aws/cdk/index.cjs +881 -0
  111. package/dist/aws/cdk/index.cjs.map +1 -0
  112. package/dist/aws/cdk/index.d.cts +34 -0
  113. package/dist/aws/cdk/index.d.ts +34 -0
  114. package/dist/aws/cdk/index.js +863 -0
  115. package/dist/aws/cdk/index.js.map +1 -0
  116. package/dist/aws/cli/index.cjs +4 -0
  117. package/dist/aws/cli/index.cjs.map +1 -0
  118. package/dist/aws/cli/index.d.cts +2 -0
  119. package/dist/aws/cli/index.d.ts +2 -0
  120. package/dist/aws/cli/index.js +3 -0
  121. package/dist/aws/cli/index.js.map +1 -0
  122. package/dist/aws/index.cjs +881 -0
  123. package/dist/aws/index.cjs.map +1 -0
  124. package/dist/aws/index.d.cts +34 -0
  125. package/dist/aws/index.d.ts +34 -0
  126. package/dist/aws/index.js +863 -0
  127. package/dist/aws/index.js.map +1 -0
  128. package/dist/aws/types/index.cjs +4 -0
  129. package/dist/aws/types/index.cjs.map +1 -0
  130. package/dist/aws/types/index.d.cts +18 -0
  131. package/dist/aws/types/index.d.ts +18 -0
  132. package/dist/aws/types/index.js +3 -0
  133. package/dist/aws/types/index.js.map +1 -0
  134. package/dist/index.d.cts +34 -755
  135. package/dist/index.d.ts +34 -755
  136. package/dist/lint/index.cjs +4 -0
  137. package/dist/lint/index.cjs.map +1 -0
  138. package/dist/lint/index.d.cts +2 -0
  139. package/dist/lint/index.d.ts +2 -0
  140. package/dist/lint/index.js +3 -0
  141. package/dist/lint/index.js.map +1 -0
  142. package/dist/prettier/index.cjs +4 -0
  143. package/dist/prettier/index.cjs.map +1 -0
  144. package/dist/prettier/index.d.cts +2 -0
  145. package/dist/prettier/index.d.ts +2 -0
  146. package/dist/prettier/index.js +3 -0
  147. package/dist/prettier/index.js.map +1 -0
  148. package/dist/utility/index.cjs +4 -0
  149. package/dist/utility/index.cjs.map +1 -0
  150. package/dist/utility/index.d.cts +2 -0
  151. package/dist/utility/index.d.ts +2 -0
  152. package/dist/utility/index.js +3 -0
  153. package/dist/utility/index.js.map +1 -0
  154. package/package.json +8 -3
@@ -0,0 +1,55 @@
1
+ import { Construct } from 'constructs';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ import { HttpApi, HttpApiProps, AddRoutesOptions } from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import { IBaseConstruct, IBaseCdkConstructProps } from '../../types/index.js';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Properties for configuring the API Gateway v2 construct
9
+ *
10
+ * Extends base CDK construct props and provides configuration for:
11
+ * - HTTP API (Api Gateway v2)
12
+ * - Route definitions
13
+ * - Lambda handlers
14
+ */
15
+ interface IApiGatewayV2ConstructProps extends Omit<IBaseCdkConstructProps<{
16
+ /** HTTP API configuration options */
17
+ readonly gatewayOptions: HttpApiProps;
18
+ /** Route definitions passed directly to `addRoutes` */
19
+ readonly routeOptions: Partial<AddRoutesOptions>[];
20
+ }>, 'appName' | 'stage' | 'stackName'> {
21
+ /**
22
+ * Lambda functions used as route handlers
23
+ *
24
+ * Note:
25
+ * Each handler is paired with each route during route creation
26
+ */
27
+ readonly handlerFunctions: Function[];
28
+ }
29
+ /**
30
+ * CDK construct for creating an API Gateway v2 (HTTP API)
31
+ *
32
+ * Responsibilities:
33
+ * - Creates an HTTP API with optional custom configuration
34
+ * - Applies default CORS configuration when not provided
35
+ * - Attaches routes with Lambda integrations
36
+ * - Exposes API URL as a CloudFormation output
37
+ *
38
+ * Behaviour:
39
+ * - Each route is registered for every provided handler function
40
+ * - Throws if no handler functions are supplied
41
+ */
42
+ declare class BaseApiGatewayV2Construct extends Construct implements IBaseConstruct {
43
+ /** The created HTTP API instance */
44
+ readonly api: HttpApi;
45
+ /** Enables debug logging (if used externally) */
46
+ enableDebug: boolean;
47
+ /**
48
+ * @param scope Parent construct
49
+ * @param id Unique construct identifier
50
+ * @param props Configuration for API, routes, and handlers
51
+ */
52
+ constructor(scope: Construct, id: string, props: IApiGatewayV2ConstructProps);
53
+ }
54
+
55
+ export { BaseApiGatewayV2Construct };
@@ -0,0 +1,75 @@
1
+ import { Construct } from 'constructs';
2
+ import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
3
+ import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
4
+ import { HttpApi, CorsHttpMethod } from 'aws-cdk-lib/aws-apigatewayv2';
5
+ import { CustomException } from '@incloodsolutions/toolkit';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var BaseApiGatewayV2Construct = class extends Construct {
10
+ static {
11
+ __name(this, "BaseApiGatewayV2Construct");
12
+ }
13
+ /** The created HTTP API instance */
14
+ api;
15
+ /** Enables debug logging (if used externally) */
16
+ enableDebug = false;
17
+ /**
18
+ * @param scope Parent construct
19
+ * @param id Unique construct identifier
20
+ * @param props Configuration for API, routes, and handlers
21
+ */
22
+ constructor(scope, id, props) {
23
+ super(scope, id);
24
+ this.enableDebug = props.enableDebug;
25
+ this.api = new HttpApi(this, id, {
26
+ ...props?.options?.gatewayOptions,
27
+ /** Default API description if not provided */
28
+ description: props?.options?.gatewayOptions?.description || "This is an Http API using CDK",
29
+ /**
30
+ * CORS configuration
31
+ * Falls back to allowing all methods and standard headers if not explicitly defined
32
+ */
33
+ corsPreflight: {
34
+ ...props.options?.gatewayOptions?.corsPreflight,
35
+ /** Allow all HTTP methods by default */
36
+ allowMethods: props.options?.gatewayOptions?.corsPreflight?.allowMethods || Object.values(CorsHttpMethod),
37
+ /** Merge default headers with user-defined headers */
38
+ allowHeaders: [
39
+ "Content-Type",
40
+ "Accept",
41
+ "X-Amz-Date",
42
+ "Authorization",
43
+ "X-Api-Key",
44
+ "X-Amz-Security-Token",
45
+ "X-Amz-User-Agent",
46
+ ...props.options?.gatewayOptions?.corsPreflight?.allowHeaders || []
47
+ ]
48
+ }
49
+ });
50
+ if (!props?.handlerFunctions?.length) {
51
+ throw new CustomException("Construct requires atleast one function");
52
+ }
53
+ if (props?.options?.routeOptions?.length) {
54
+ props.handlerFunctions.forEach((handlerFunc) => {
55
+ props?.options?.routeOptions.forEach((route) => {
56
+ this.api.addRoutes({
57
+ ...route,
58
+ /**
59
+ * Lambda integration for each route
60
+ */
61
+ integration: new HttpLambdaIntegration("routes", handlerFunc)
62
+ });
63
+ });
64
+ });
65
+ }
66
+ this.api.applyRemovalPolicy(RemovalPolicy.DESTROY);
67
+ new CfnOutput(this, "ApiGatewayV2", {
68
+ value: this.api.url
69
+ });
70
+ }
71
+ };
72
+
73
+ export { BaseApiGatewayV2Construct };
74
+ //# sourceMappingURL=api-gateway-v2-construct.js.map
75
+ //# sourceMappingURL=api-gateway-v2-construct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/api-gateway-v2-construct.ts"],"names":[],"mappings":";;;;;;;;AA+CO,IAAM,yBAAA,GAAN,cAAwC,SAAA,CAAoC;AAAA,EA/CnF;AA+CmF,IAAA,MAAA,CAAA,IAAA,EAAA,2BAAA,CAAA;AAAA;AAAA;AAAA,EAEzE,GAAA;AAAA;AAAA,EAGT,WAAA,GAAc,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAoC;AAC7E,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,cAAc,KAAA,CAAM,WAAA;AAEzB,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,OAAA,CAAQ,IAAA,EAAM,EAAA,EAAI;AAAA,MAChC,GAAG,OAAO,OAAA,EAAS,cAAA;AAAA;AAAA,MAGnB,WAAA,EAAa,KAAA,EAAO,OAAA,EAAS,cAAA,EAAgB,WAAA,IAAe,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAM5D,aAAA,EAAe;AAAA,QACd,GAAG,KAAA,CAAM,OAAA,EAAS,cAAA,EAAgB,aAAA;AAAA;AAAA,QAGlC,YAAA,EAAc,MAAM,OAAA,EAAS,cAAA,EAAgB,eAAe,YAAA,IAAgB,MAAA,CAAO,OAAO,cAAc,CAAA;AAAA;AAAA,QAGxG,YAAA,EAAc;AAAA,UACb,cAAA;AAAA,UACA,QAAA;AAAA,UACA,YAAA;AAAA,UACA,eAAA;AAAA,UACA,WAAA;AAAA,UACA,sBAAA;AAAA,UACA,kBAAA;AAAA,UACA,GAAG,KAAA,CAAM,OAAA,EAAS,cAAA,EAAgB,aAAA,EAAe,gBAAgB;AAAC;AACnE;AACD,KACA,CAAA;AAKD,IAAA,IAAI,CAAC,KAAA,EAAO,gBAAA,EAAkB,MAAA,EAAQ;AACrC,MAAA,MAAM,IAAI,gBAAgB,yCAAyC,CAAA;AAAA,IACpE;AAKA,IAAA,IAAI,KAAA,EAAO,OAAA,EAAS,YAAA,EAAc,MAAA,EAAQ;AACzC,MAAA,KAAA,CAAM,gBAAA,CAAiB,QAAQ,CAAA,WAAA,KAAe;AAC7C,QAAA,KAAA,EAAO,OAAA,EAAS,YAAA,CAAa,OAAA,CAAQ,CAAA,KAAA,KAAS;AAC7C,UAAA,IAAA,CAAK,IAAI,SAAA,CAAU;AAAA,YAClB,GAAG,KAAA;AAAA;AAAA;AAAA;AAAA,YAKH,WAAA,EAAa,IAAI,qBAAA,CAAsB,QAAA,EAAU,WAAW;AAAA,WACxC,CAAA;AAAA,QACtB,CAAC,CAAA;AAAA,MACF,CAAC,CAAA;AAAA,IACF;AAKA,IAAA,IAAA,CAAK,GAAA,CAAI,kBAAA,CAAmB,aAAA,CAAc,OAAO,CAAA;AAKjD,IAAA,IAAI,SAAA,CAAU,MAAM,cAAA,EAAgB;AAAA,MACnC,KAAA,EAAO,KAAK,GAAA,CAAI;AAAA,KAChB,CAAA;AAAA,EACF;AACD","file":"api-gateway-v2-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { Function } from 'aws-cdk-lib/aws-lambda';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';\nimport { AddRoutesOptions, CorsHttpMethod, HttpApi, HttpApiProps } from 'aws-cdk-lib/aws-apigatewayv2';\n\nimport { CustomException } from '@incloodsolutions/toolkit';\nimport { IBaseCdkConstructProps, IBaseConstruct } from '../../types';\n\n/**\n * Properties for configuring the API Gateway v2 construct\n *\n * Extends base CDK construct props and provides configuration for:\n * - HTTP API (Api Gateway v2)\n * - Route definitions\n * - Lambda handlers\n */\ninterface IApiGatewayV2ConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** HTTP API configuration options */\n\treadonly gatewayOptions: HttpApiProps;\n\n\t/** Route definitions passed directly to `addRoutes` */\n\treadonly routeOptions: Partial<AddRoutesOptions>[];\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Lambda functions used as route handlers\n\t *\n\t * Note:\n\t * Each handler is paired with each route during route creation\n\t */\n\treadonly handlerFunctions: Function[];\n}\n\n\n/**\n * CDK construct for creating an API Gateway v2 (HTTP API)\n *\n * Responsibilities:\n * - Creates an HTTP API with optional custom configuration\n * - Applies default CORS configuration when not provided\n * - Attaches routes with Lambda integrations\n * - Exposes API URL as a CloudFormation output\n *\n * Behaviour:\n * - Each route is registered for every provided handler function\n * - Throws if no handler functions are supplied\n */\nexport class BaseApiGatewayV2Construct extends Construct implements IBaseConstruct {\n\t/** The created HTTP API instance */\n\treadonly api: HttpApi;\n\n\t/** Enables debug logging (if used externally) */\n\tenableDebug = false;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for API, routes, and handlers\n\t */\n\tconstructor(scope: Construct, id: string, props: IApiGatewayV2ConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.enableDebug = props.enableDebug;\n\n\t\tthis.api = new HttpApi(this, id, {\n\t\t\t...props?.options?.gatewayOptions,\n\n\t\t\t/** Default API description if not provided */\n\t\t\tdescription: props?.options?.gatewayOptions?.description || 'This is an Http API using CDK',\n\n\t\t\t/**\n\t\t\t * CORS configuration\n\t\t\t * Falls back to allowing all methods and standard headers if not explicitly defined\n\t\t\t */\n\t\t\tcorsPreflight: {\n\t\t\t\t...props.options?.gatewayOptions?.corsPreflight,\n\n\t\t\t\t/** Allow all HTTP methods by default */\n\t\t\t\tallowMethods: props.options?.gatewayOptions?.corsPreflight?.allowMethods || Object.values(CorsHttpMethod),\n\n\t\t\t\t/** Merge default headers with user-defined headers */\n\t\t\t\tallowHeaders: [\n\t\t\t\t\t'Content-Type',\n\t\t\t\t\t'Accept',\n\t\t\t\t\t'X-Amz-Date',\n\t\t\t\t\t'Authorization',\n\t\t\t\t\t'X-Api-Key',\n\t\t\t\t\t'X-Amz-Security-Token',\n\t\t\t\t\t'X-Amz-User-Agent',\n\t\t\t\t\t...props.options?.gatewayOptions?.corsPreflight?.allowHeaders || []\n\t\t\t\t]\n\t\t\t}\n\t\t});\n\n\t\t/**\n\t\t * Ensure at least one handler function is provided\n\t\t */\n\t\tif (!props?.handlerFunctions?.length) {\n\t\t\tthrow new CustomException('Construct requires atleast one function');\n\t\t}\n\n\t\t/**\n\t\t * Register routes with Lambda integrations\n\t\t */\n\t\tif (props?.options?.routeOptions?.length) {\n\t\t\tprops.handlerFunctions.forEach(handlerFunc => {\n\t\t\t\tprops?.options?.routeOptions.forEach(route => {\n\t\t\t\t\tthis.api.addRoutes({\n\t\t\t\t\t\t...route,\n\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Lambda integration for each route\n\t\t\t\t\t\t */\n\t\t\t\t\t\tintegration: new HttpLambdaIntegration('routes', handlerFunc)\n\t\t\t\t\t} as AddRoutesOptions);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t/**\n\t\t * Apply removal policy (useful for non-production environments)\n\t\t */\n\t\tthis.api.applyRemovalPolicy(RemovalPolicy.DESTROY);\n\n\t\t/**\n\t\t * CloudFormation output exposing the API base URL\n\t\t */\n\t\tnew CfnOutput(this, 'ApiGatewayV2', {\n\t\t\tvalue: this.api.url,\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsApigatewayv2Integrations = require('aws-cdk-lib/aws-apigatewayv2-integrations');
6
+ var awsApigatewayv2 = require('aws-cdk-lib/aws-apigatewayv2');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var BaseApiGatewayWebSocketConstruct = class extends constructs.Construct {
11
+ static {
12
+ __name(this, "BaseApiGatewayWebSocketConstruct");
13
+ }
14
+ /** The created WebSocket API instance */
15
+ socketApi;
16
+ /**
17
+ * @param scope Parent construct
18
+ * @param id Unique construct identifier
19
+ * @param props Configuration for API, stage, and route handlers
20
+ */
21
+ constructor(scope, id, props) {
22
+ super(scope, id);
23
+ this.socketApi = new awsApigatewayv2.WebSocketApi(this, id, {
24
+ ...props.options.webSocketApiOptions,
25
+ /**
26
+ * Route for connection establishment ($connect)
27
+ */
28
+ connectRouteOptions: {
29
+ ...props.handlers.connect?.option,
30
+ integration: new awsApigatewayv2Integrations.WebSocketLambdaIntegration("connectIntegration", props.handlers.connect.function)
31
+ },
32
+ /**
33
+ * Route for disconnection events ($disconnect)
34
+ */
35
+ disconnectRouteOptions: {
36
+ ...props.handlers.disconnect?.option,
37
+ integration: new awsApigatewayv2Integrations.WebSocketLambdaIntegration("disconnectIntegration", props.handlers.disconnect.function)
38
+ },
39
+ /**
40
+ * Default route for unmatched messages ($default)
41
+ */
42
+ defaultRouteOptions: {
43
+ ...props.handlers.default?.option,
44
+ integration: new awsApigatewayv2Integrations.WebSocketLambdaIntegration("defaultIntegration", props.handlers.default.function)
45
+ }
46
+ });
47
+ this.socketApi.addRoute("notifications", {
48
+ ...props.handlers.message?.option,
49
+ /** Lambda integration for message handling */
50
+ integration: new awsApigatewayv2Integrations.WebSocketLambdaIntegration("routes", props.handlers.message.function)
51
+ });
52
+ const webSocketStage = new awsApigatewayv2.WebSocketStage(this, `${id}_stage`, {
53
+ ...props.options?.webSocketStageOptions,
54
+ webSocketApi: this.socketApi,
55
+ autoDeploy: true
56
+ });
57
+ new awsCdkLib.CfnOutput(this, "WebSocketURL", {
58
+ value: webSocketStage.url
59
+ });
60
+ }
61
+ };
62
+
63
+ exports.BaseApiGatewayWebSocketConstruct = BaseApiGatewayWebSocketConstruct;
64
+ //# sourceMappingURL=api-gateway-websocket-construct.cjs.map
65
+ //# sourceMappingURL=api-gateway-websocket-construct.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/api-gateway-websocket-construct.ts"],"names":["Construct","WebSocketApi","WebSocketLambdaIntegration","WebSocketStage","CfnOutput"],"mappings":";;;;;;;;;AAoEO,IAAM,gCAAA,GAAN,cAA+CA,oBAAA,CAAU;AAAA,EApEhE;AAoEgE,IAAA,MAAA,CAAA,IAAA,EAAA,kCAAA,CAAA;AAAA;AAAA;AAAA,EAEtD,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2C;AACpF,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,SAAA,GAAY,IAAIC,4BAAA,CAAa,IAAA,EAAM,EAAA,EAAI;AAAA,MAC3C,GAAG,MAAM,OAAA,CAAQ,mBAAA;AAAA;AAAA;AAAA;AAAA,MAKjB,mBAAA,EAAqB;AAAA,QACpB,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA,QAC3B,aAAa,IAAIC,sDAAA,CAA2B,sBAAsB,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA,OAClG;AAAA;AAAA;AAAA;AAAA,MAKA,sBAAA,EAAwB;AAAA,QACvB,GAAG,KAAA,CAAM,QAAA,CAAS,UAAA,EAAY,MAAA;AAAA,QAC9B,aAAa,IAAIA,sDAAA,CAA2B,yBAAyB,KAAA,CAAM,QAAA,CAAS,WAAW,QAAQ;AAAA,OACxG;AAAA;AAAA;AAAA;AAAA,MAKA,mBAAA,EAAqB;AAAA,QACpB,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA,QAC3B,aAAa,IAAIA,sDAAA,CAA2B,sBAAsB,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA;AAClG,KACA,CAAA;AAKD,IAAA,IAAA,CAAK,SAAA,CAAU,SAAS,eAAA,EAAiB;AAAA,MACxC,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA;AAAA,MAG3B,aAAa,IAAIA,sDAAA,CAA2B,UAAU,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA,KACrF,CAAA;AAMD,IAAA,MAAM,iBAAiB,IAAIC,8BAAA,CAAe,IAAA,EAAM,CAAA,EAAG,EAAE,CAAA,MAAA,CAAA,EAAU;AAAA,MAC9D,GAAG,MAAM,OAAA,EAAS,qBAAA;AAAA,MAClB,cAAc,IAAA,CAAK,SAAA;AAAA,MACnB,UAAA,EAAY;AAAA,KACZ,CAAA;AAKD,IAAA,IAAIC,mBAAA,CAAU,MAAM,cAAA,EAAgB;AAAA,MACnC,OAAO,cAAA,CAAe;AAAA,KACtB,CAAA;AAAA,EACF;AACD","file":"api-gateway-websocket-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput } from 'aws-cdk-lib';\nimport { Function } from 'aws-cdk-lib/aws-lambda';\nimport { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';\nimport { WebSocketApi, WebSocketApiProps, WebSocketRouteOptions, WebSocketStage, WebSocketStageProps } from 'aws-cdk-lib/aws-apigatewayv2';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseApiGatewayWebSocketConstruct\n *\n * Provides configuration for:\n * - WebSocket API (API Gateway v2)\n * - WebSocket stage\n * - Route handlers for lifecycle events\n */\ninterface IApiGatewayWebsocketConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** WebSocket API configuration options */\n\treadonly webSocketApiOptions: WebSocketApiProps;\n\n\t/** WebSocket stage configuration options */\n\treadonly webSocketStageOptions: WebSocketStageProps;\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Lambda handlers mapped to WebSocket lifecycle routes\n\t *\n\t * Includes:\n\t * - $connect\n\t * - $disconnect\n\t * - $default\n\t * - custom message route\n\t */\n\treadonly handlers: {\n\t\t/** Handler for connection establishment ($connect) */\n\t\treadonly connect: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for unmatched routes ($default) */\n\t\treadonly default: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for custom message route (e.g. 'notifications') */\n\t\treadonly message: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for disconnection events ($disconnect) */\n\t\treadonly disconnect: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\t}\n}\n\n/**\n * CDK construct for WebSocket API Gateway\n *\n * Responsibilities:\n * - Creates a WebSocket API with lifecycle route integrations\n * - Registers a custom message route\n * - Deploys a stage with auto-deploy enabled\n * - Exposes WebSocket endpoint URL as a CloudFormation output\n */\nexport class BaseApiGatewayWebSocketConstruct extends Construct {\n\t/** The created WebSocket API instance */\n\treadonly socketApi: WebSocketApi;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for API, stage, and route handlers\n\t */\n\tconstructor(scope: Construct, id: string, props: IApiGatewayWebsocketConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.socketApi = new WebSocketApi(this, id, {\n\t\t\t...props.options.webSocketApiOptions,\n\n\t\t\t/**\n\t\t\t * Route for connection establishment ($connect)\n\t\t\t */\n\t\t\tconnectRouteOptions: {\n\t\t\t\t...props.handlers.connect?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('connectIntegration', props.handlers.connect.function),\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Route for disconnection events ($disconnect)\n\t\t\t */\n\t\t\tdisconnectRouteOptions: {\n\t\t\t\t...props.handlers.disconnect?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('disconnectIntegration', props.handlers.disconnect.function)\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Default route for unmatched messages ($default)\n\t\t\t */\n\t\t\tdefaultRouteOptions: {\n\t\t\t\t...props.handlers.default?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('defaultIntegration', props.handlers.default.function)\n\t\t\t},\n\t\t});\n\n\t\t/**\n\t\t * Custom message route (e.g. \"notifications\")\n\t\t */\n\t\tthis.socketApi.addRoute(\"notifications\", {\n\t\t\t...props.handlers.message?.option,\n\n\t\t\t/** Lambda integration for message handling */\n\t\t\tintegration: new WebSocketLambdaIntegration('routes', props.handlers.message.function),\n\t\t});\n\n\t\t/**\n\t\t * WebSocket stage deployment\n\t\t * Auto-deploy ensures changes are immediately available\n\t\t */\n\t\tconst webSocketStage = new WebSocketStage(this, `${id}_stage`, {\n\t\t\t...props.options?.webSocketStageOptions,\n\t\t\twebSocketApi: this.socketApi,\n\t\t\tautoDeploy: true\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing WebSocket endpoint URL\n\t\t */\n\t\tnew CfnOutput(this, 'WebSocketURL', {\n\t\t\tvalue: webSocketStage.url,\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,73 @@
1
+ import { Construct } from 'constructs';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ import { WebSocketApi, WebSocketApiProps, WebSocketStageProps, WebSocketRouteOptions } from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import { IBaseCdkConstructProps } from '../../types/index.cjs';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseApiGatewayWebSocketConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - WebSocket API (API Gateway v2)
12
+ * - WebSocket stage
13
+ * - Route handlers for lifecycle events
14
+ */
15
+ interface IApiGatewayWebsocketConstructProps extends Omit<IBaseCdkConstructProps<{
16
+ /** WebSocket API configuration options */
17
+ readonly webSocketApiOptions: WebSocketApiProps;
18
+ /** WebSocket stage configuration options */
19
+ readonly webSocketStageOptions: WebSocketStageProps;
20
+ }>, 'appName' | 'stage' | 'stackName'> {
21
+ /**
22
+ * Lambda handlers mapped to WebSocket lifecycle routes
23
+ *
24
+ * Includes:
25
+ * - $connect
26
+ * - $disconnect
27
+ * - $default
28
+ * - custom message route
29
+ */
30
+ readonly handlers: {
31
+ /** Handler for connection establishment ($connect) */
32
+ readonly connect: {
33
+ option: WebSocketRouteOptions;
34
+ function: Function;
35
+ };
36
+ /** Handler for unmatched routes ($default) */
37
+ readonly default: {
38
+ option: WebSocketRouteOptions;
39
+ function: Function;
40
+ };
41
+ /** Handler for custom message route (e.g. 'notifications') */
42
+ readonly message: {
43
+ option: WebSocketRouteOptions;
44
+ function: Function;
45
+ };
46
+ /** Handler for disconnection events ($disconnect) */
47
+ readonly disconnect: {
48
+ option: WebSocketRouteOptions;
49
+ function: Function;
50
+ };
51
+ };
52
+ }
53
+ /**
54
+ * CDK construct for WebSocket API Gateway
55
+ *
56
+ * Responsibilities:
57
+ * - Creates a WebSocket API with lifecycle route integrations
58
+ * - Registers a custom message route
59
+ * - Deploys a stage with auto-deploy enabled
60
+ * - Exposes WebSocket endpoint URL as a CloudFormation output
61
+ */
62
+ declare class BaseApiGatewayWebSocketConstruct extends Construct {
63
+ /** The created WebSocket API instance */
64
+ readonly socketApi: WebSocketApi;
65
+ /**
66
+ * @param scope Parent construct
67
+ * @param id Unique construct identifier
68
+ * @param props Configuration for API, stage, and route handlers
69
+ */
70
+ constructor(scope: Construct, id: string, props: IApiGatewayWebsocketConstructProps);
71
+ }
72
+
73
+ export { BaseApiGatewayWebSocketConstruct };
@@ -0,0 +1,73 @@
1
+ import { Construct } from 'constructs';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ import { WebSocketApi, WebSocketApiProps, WebSocketStageProps, WebSocketRouteOptions } from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import { IBaseCdkConstructProps } from '../../types/index.js';
5
+ import '@incloodsolutions/toolkit';
6
+
7
+ /**
8
+ * Props for BaseApiGatewayWebSocketConstruct
9
+ *
10
+ * Provides configuration for:
11
+ * - WebSocket API (API Gateway v2)
12
+ * - WebSocket stage
13
+ * - Route handlers for lifecycle events
14
+ */
15
+ interface IApiGatewayWebsocketConstructProps extends Omit<IBaseCdkConstructProps<{
16
+ /** WebSocket API configuration options */
17
+ readonly webSocketApiOptions: WebSocketApiProps;
18
+ /** WebSocket stage configuration options */
19
+ readonly webSocketStageOptions: WebSocketStageProps;
20
+ }>, 'appName' | 'stage' | 'stackName'> {
21
+ /**
22
+ * Lambda handlers mapped to WebSocket lifecycle routes
23
+ *
24
+ * Includes:
25
+ * - $connect
26
+ * - $disconnect
27
+ * - $default
28
+ * - custom message route
29
+ */
30
+ readonly handlers: {
31
+ /** Handler for connection establishment ($connect) */
32
+ readonly connect: {
33
+ option: WebSocketRouteOptions;
34
+ function: Function;
35
+ };
36
+ /** Handler for unmatched routes ($default) */
37
+ readonly default: {
38
+ option: WebSocketRouteOptions;
39
+ function: Function;
40
+ };
41
+ /** Handler for custom message route (e.g. 'notifications') */
42
+ readonly message: {
43
+ option: WebSocketRouteOptions;
44
+ function: Function;
45
+ };
46
+ /** Handler for disconnection events ($disconnect) */
47
+ readonly disconnect: {
48
+ option: WebSocketRouteOptions;
49
+ function: Function;
50
+ };
51
+ };
52
+ }
53
+ /**
54
+ * CDK construct for WebSocket API Gateway
55
+ *
56
+ * Responsibilities:
57
+ * - Creates a WebSocket API with lifecycle route integrations
58
+ * - Registers a custom message route
59
+ * - Deploys a stage with auto-deploy enabled
60
+ * - Exposes WebSocket endpoint URL as a CloudFormation output
61
+ */
62
+ declare class BaseApiGatewayWebSocketConstruct extends Construct {
63
+ /** The created WebSocket API instance */
64
+ readonly socketApi: WebSocketApi;
65
+ /**
66
+ * @param scope Parent construct
67
+ * @param id Unique construct identifier
68
+ * @param props Configuration for API, stage, and route handlers
69
+ */
70
+ constructor(scope: Construct, id: string, props: IApiGatewayWebsocketConstructProps);
71
+ }
72
+
73
+ export { BaseApiGatewayWebSocketConstruct };
@@ -0,0 +1,63 @@
1
+ import { Construct } from 'constructs';
2
+ import { CfnOutput } from 'aws-cdk-lib';
3
+ import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
4
+ import { WebSocketApi, WebSocketStage } from 'aws-cdk-lib/aws-apigatewayv2';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var BaseApiGatewayWebSocketConstruct = class extends Construct {
9
+ static {
10
+ __name(this, "BaseApiGatewayWebSocketConstruct");
11
+ }
12
+ /** The created WebSocket API instance */
13
+ socketApi;
14
+ /**
15
+ * @param scope Parent construct
16
+ * @param id Unique construct identifier
17
+ * @param props Configuration for API, stage, and route handlers
18
+ */
19
+ constructor(scope, id, props) {
20
+ super(scope, id);
21
+ this.socketApi = new WebSocketApi(this, id, {
22
+ ...props.options.webSocketApiOptions,
23
+ /**
24
+ * Route for connection establishment ($connect)
25
+ */
26
+ connectRouteOptions: {
27
+ ...props.handlers.connect?.option,
28
+ integration: new WebSocketLambdaIntegration("connectIntegration", props.handlers.connect.function)
29
+ },
30
+ /**
31
+ * Route for disconnection events ($disconnect)
32
+ */
33
+ disconnectRouteOptions: {
34
+ ...props.handlers.disconnect?.option,
35
+ integration: new WebSocketLambdaIntegration("disconnectIntegration", props.handlers.disconnect.function)
36
+ },
37
+ /**
38
+ * Default route for unmatched messages ($default)
39
+ */
40
+ defaultRouteOptions: {
41
+ ...props.handlers.default?.option,
42
+ integration: new WebSocketLambdaIntegration("defaultIntegration", props.handlers.default.function)
43
+ }
44
+ });
45
+ this.socketApi.addRoute("notifications", {
46
+ ...props.handlers.message?.option,
47
+ /** Lambda integration for message handling */
48
+ integration: new WebSocketLambdaIntegration("routes", props.handlers.message.function)
49
+ });
50
+ const webSocketStage = new WebSocketStage(this, `${id}_stage`, {
51
+ ...props.options?.webSocketStageOptions,
52
+ webSocketApi: this.socketApi,
53
+ autoDeploy: true
54
+ });
55
+ new CfnOutput(this, "WebSocketURL", {
56
+ value: webSocketStage.url
57
+ });
58
+ }
59
+ };
60
+
61
+ export { BaseApiGatewayWebSocketConstruct };
62
+ //# sourceMappingURL=api-gateway-websocket-construct.js.map
63
+ //# sourceMappingURL=api-gateway-websocket-construct.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/api-gateway-websocket-construct.ts"],"names":[],"mappings":";;;;;;;AAoEO,IAAM,gCAAA,GAAN,cAA+C,SAAA,CAAU;AAAA,EApEhE;AAoEgE,IAAA,MAAA,CAAA,IAAA,EAAA,kCAAA,CAAA;AAAA;AAAA;AAAA,EAEtD,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAA2C;AACpF,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,SAAA,GAAY,IAAI,YAAA,CAAa,IAAA,EAAM,EAAA,EAAI;AAAA,MAC3C,GAAG,MAAM,OAAA,CAAQ,mBAAA;AAAA;AAAA;AAAA;AAAA,MAKjB,mBAAA,EAAqB;AAAA,QACpB,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA,QAC3B,aAAa,IAAI,0BAAA,CAA2B,sBAAsB,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA,OAClG;AAAA;AAAA;AAAA;AAAA,MAKA,sBAAA,EAAwB;AAAA,QACvB,GAAG,KAAA,CAAM,QAAA,CAAS,UAAA,EAAY,MAAA;AAAA,QAC9B,aAAa,IAAI,0BAAA,CAA2B,yBAAyB,KAAA,CAAM,QAAA,CAAS,WAAW,QAAQ;AAAA,OACxG;AAAA;AAAA;AAAA;AAAA,MAKA,mBAAA,EAAqB;AAAA,QACpB,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA,QAC3B,aAAa,IAAI,0BAAA,CAA2B,sBAAsB,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA;AAClG,KACA,CAAA;AAKD,IAAA,IAAA,CAAK,SAAA,CAAU,SAAS,eAAA,EAAiB;AAAA,MACxC,GAAG,KAAA,CAAM,QAAA,CAAS,OAAA,EAAS,MAAA;AAAA;AAAA,MAG3B,aAAa,IAAI,0BAAA,CAA2B,UAAU,KAAA,CAAM,QAAA,CAAS,QAAQ,QAAQ;AAAA,KACrF,CAAA;AAMD,IAAA,MAAM,iBAAiB,IAAI,cAAA,CAAe,IAAA,EAAM,CAAA,EAAG,EAAE,CAAA,MAAA,CAAA,EAAU;AAAA,MAC9D,GAAG,MAAM,OAAA,EAAS,qBAAA;AAAA,MAClB,cAAc,IAAA,CAAK,SAAA;AAAA,MACnB,UAAA,EAAY;AAAA,KACZ,CAAA;AAKD,IAAA,IAAI,SAAA,CAAU,MAAM,cAAA,EAAgB;AAAA,MACnC,OAAO,cAAA,CAAe;AAAA,KACtB,CAAA;AAAA,EACF;AACD","file":"api-gateway-websocket-construct.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput } from 'aws-cdk-lib';\nimport { Function } from 'aws-cdk-lib/aws-lambda';\nimport { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';\nimport { WebSocketApi, WebSocketApiProps, WebSocketRouteOptions, WebSocketStage, WebSocketStageProps } from 'aws-cdk-lib/aws-apigatewayv2';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseApiGatewayWebSocketConstruct\n *\n * Provides configuration for:\n * - WebSocket API (API Gateway v2)\n * - WebSocket stage\n * - Route handlers for lifecycle events\n */\ninterface IApiGatewayWebsocketConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** WebSocket API configuration options */\n\treadonly webSocketApiOptions: WebSocketApiProps;\n\n\t/** WebSocket stage configuration options */\n\treadonly webSocketStageOptions: WebSocketStageProps;\n}>, 'appName' | 'stage' | 'stackName'> {\n\t/**\n\t * Lambda handlers mapped to WebSocket lifecycle routes\n\t *\n\t * Includes:\n\t * - $connect\n\t * - $disconnect\n\t * - $default\n\t * - custom message route\n\t */\n\treadonly handlers: {\n\t\t/** Handler for connection establishment ($connect) */\n\t\treadonly connect: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for unmatched routes ($default) */\n\t\treadonly default: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for custom message route (e.g. 'notifications') */\n\t\treadonly message: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\n\t\t/** Handler for disconnection events ($disconnect) */\n\t\treadonly disconnect: {\n\t\t\toption: WebSocketRouteOptions;\n\t\t\tfunction: Function;\n\t\t};\n\t}\n}\n\n/**\n * CDK construct for WebSocket API Gateway\n *\n * Responsibilities:\n * - Creates a WebSocket API with lifecycle route integrations\n * - Registers a custom message route\n * - Deploys a stage with auto-deploy enabled\n * - Exposes WebSocket endpoint URL as a CloudFormation output\n */\nexport class BaseApiGatewayWebSocketConstruct extends Construct {\n\t/** The created WebSocket API instance */\n\treadonly socketApi: WebSocketApi;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for API, stage, and route handlers\n\t */\n\tconstructor(scope: Construct, id: string, props: IApiGatewayWebsocketConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.socketApi = new WebSocketApi(this, id, {\n\t\t\t...props.options.webSocketApiOptions,\n\n\t\t\t/**\n\t\t\t * Route for connection establishment ($connect)\n\t\t\t */\n\t\t\tconnectRouteOptions: {\n\t\t\t\t...props.handlers.connect?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('connectIntegration', props.handlers.connect.function),\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Route for disconnection events ($disconnect)\n\t\t\t */\n\t\t\tdisconnectRouteOptions: {\n\t\t\t\t...props.handlers.disconnect?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('disconnectIntegration', props.handlers.disconnect.function)\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Default route for unmatched messages ($default)\n\t\t\t */\n\t\t\tdefaultRouteOptions: {\n\t\t\t\t...props.handlers.default?.option,\n\t\t\t\tintegration: new WebSocketLambdaIntegration('defaultIntegration', props.handlers.default.function)\n\t\t\t},\n\t\t});\n\n\t\t/**\n\t\t * Custom message route (e.g. \"notifications\")\n\t\t */\n\t\tthis.socketApi.addRoute(\"notifications\", {\n\t\t\t...props.handlers.message?.option,\n\n\t\t\t/** Lambda integration for message handling */\n\t\t\tintegration: new WebSocketLambdaIntegration('routes', props.handlers.message.function),\n\t\t});\n\n\t\t/**\n\t\t * WebSocket stage deployment\n\t\t * Auto-deploy ensures changes are immediately available\n\t\t */\n\t\tconst webSocketStage = new WebSocketStage(this, `${id}_stage`, {\n\t\t\t...props.options?.webSocketStageOptions,\n\t\t\twebSocketApi: this.socketApi,\n\t\t\tautoDeploy: true\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing WebSocket endpoint URL\n\t\t */\n\t\tnew CfnOutput(this, 'WebSocketURL', {\n\t\t\tvalue: webSocketStage.url,\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsCloudfront = require('aws-cdk-lib/aws-cloudfront');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var BaseCloudfrontConstruct = class extends constructs.Construct {
10
+ static {
11
+ __name(this, "BaseCloudfrontConstruct");
12
+ }
13
+ /** The created CloudFront distribution instance */
14
+ distribution;
15
+ /**
16
+ * @param scope Parent construct
17
+ * @param id Unique construct identifier
18
+ * @param props Configuration for CloudFront distribution
19
+ */
20
+ constructor(scope, id, props) {
21
+ super(scope, id);
22
+ this.distribution = new awsCloudfront.Distribution(this, id, {
23
+ ...props.options?.cloudfrontOptions,
24
+ /**
25
+ * Default behaviour configuration
26
+ * Enforces HTTPS if not explicitly defined
27
+ */
28
+ defaultBehavior: {
29
+ ...props.options?.cloudfrontOptions?.defaultBehavior,
30
+ viewerProtocolPolicy: props.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy || awsCloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS
31
+ },
32
+ /**
33
+ * Error response configuration
34
+ *
35
+ * Adds SPA-friendly fallbacks:
36
+ * - 400, 403, 404 responses are redirected to index.html
37
+ */
38
+ errorResponses: [
39
+ ...props.options?.cloudfrontOptions?.errorResponses || [],
40
+ /** Handle 400 errors */
41
+ {
42
+ httpStatus: 400,
43
+ responseHttpStatus: 200,
44
+ responsePagePath: "/index.html",
45
+ ttl: awsCdkLib.Duration.days(1)
46
+ },
47
+ /** Handle 403 errors */
48
+ {
49
+ httpStatus: 403,
50
+ responseHttpStatus: 200,
51
+ responsePagePath: "/index.html",
52
+ ttl: awsCdkLib.Duration.days(1)
53
+ },
54
+ /** Handle 404 errors */
55
+ {
56
+ httpStatus: 404,
57
+ responseHttpStatus: 200,
58
+ responsePagePath: "/index.html",
59
+ ttl: awsCdkLib.Duration.days(1)
60
+ }
61
+ ]
62
+ });
63
+ }
64
+ };
65
+
66
+ exports.BaseCloudfrontConstruct = BaseCloudfrontConstruct;
67
+ //# sourceMappingURL=cloudfront-construct.cjs.map
68
+ //# sourceMappingURL=cloudfront-construct.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/aws/cdk/constructs/cloudfront-construct.ts"],"names":["Construct","Distribution","ViewerProtocolPolicy","Duration"],"mappings":";;;;;;;;AAyBO,IAAM,uBAAA,GAAN,cAAsCA,oBAAA,CAAU;AAAA,EAzBvD;AAyBuD,IAAA,MAAA,CAAA,IAAA,EAAA,yBAAA,CAAA;AAAA;AAAA;AAAA,EAE7C,YAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAkC;AAC3E,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,YAAA,GAAe,IAAIC,0BAAA,CAAa,IAAA,EAAM,EAAA,EAAI;AAAA,MAC9C,GAAG,MAAM,OAAA,EAAS,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,eAAA,EAAiB;AAAA,QAChB,GAAG,KAAA,CAAM,OAAA,EAAS,iBAAA,EAAmB,eAAA;AAAA,QACrC,sBACC,KAAA,CAAM,OAAA,EAAS,iBAAA,EAAmB,eAAA,EAAiB,wBAChDC,kCAAA,CAAqB;AAAA,OAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQA,cAAA,EAAgB;AAAA,QACf,GAAG,KAAA,CAAM,OAAA,EAAS,iBAAA,EAAmB,kBAAkB,EAAC;AAAA;AAAA,QAGxD;AAAA,UACC,UAAA,EAAY,GAAA;AAAA,UACZ,kBAAA,EAAoB,GAAA;AAAA,UACpB,gBAAA,EAAkB,aAAA;AAAA,UAClB,GAAA,EAAKC,kBAAA,CAAS,IAAA,CAAK,CAAC;AAAA,SACrB;AAAA;AAAA,QAGA;AAAA,UACC,UAAA,EAAY,GAAA;AAAA,UACZ,kBAAA,EAAoB,GAAA;AAAA,UACpB,gBAAA,EAAkB,aAAA;AAAA,UAClB,GAAA,EAAKA,kBAAA,CAAS,IAAA,CAAK,CAAC;AAAA,SACrB;AAAA;AAAA,QAGA;AAAA,UACC,UAAA,EAAY,GAAA;AAAA,UACZ,kBAAA,EAAoB,GAAA;AAAA,UACpB,gBAAA,EAAkB,aAAA;AAAA,UAClB,GAAA,EAAKA,kBAAA,CAAS,IAAA,CAAK,CAAC;AAAA;AACrB;AACD,KACA,CAAA;AAAA,EACF;AACD","file":"cloudfront-construct.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { Duration } from 'aws-cdk-lib';\nimport { Distribution, DistributionProps, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseCloudfrontConstruct\n *\n * Provides configuration for creating a CloudFront distribution\n * with optional overrides for default behaviour and error handling.\n */\ninterface ICloudfrontConstructProps extends Omit<IBaseCdkConstructProps<{\n\t/** Partial configuration for the CloudFront distribution */\n\treadonly cloudfrontOptions: Partial<DistributionProps>;\n}>, 'appName' | 'stage' | 'stackName'> { }\n\n/**\n * CDK construct for CloudFront distribution\n *\n * Responsibilities:\n * - Creates a CloudFront distribution with configurable options\n * - Enforces HTTPS redirection by default\n * - Adds fallback error responses for SPA routing (400, 403, 404 → index.html)\n */\nexport class BaseCloudfrontConstruct extends Construct {\n\t/** The created CloudFront distribution instance */\n\treadonly distribution: Distribution;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for CloudFront distribution\n\t */\n\tconstructor(scope: Construct, id: string, props: ICloudfrontConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.distribution = new Distribution(this, id, {\n\t\t\t...props.options?.cloudfrontOptions,\n\n\t\t\t/**\n\t\t\t * Default behaviour configuration\n\t\t\t * Enforces HTTPS if not explicitly defined\n\t\t\t */\n\t\t\tdefaultBehavior: {\n\t\t\t\t...props.options?.cloudfrontOptions?.defaultBehavior,\n\t\t\t\tviewerProtocolPolicy:\n\t\t\t\t\tprops.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy\n\t\t\t\t\t|| ViewerProtocolPolicy.REDIRECT_TO_HTTPS\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Error response configuration\n\t\t\t *\n\t\t\t * Adds SPA-friendly fallbacks:\n\t\t\t * - 400, 403, 404 responses are redirected to index.html\n\t\t\t */\n\t\t\terrorResponses: [\n\t\t\t\t...props.options?.cloudfrontOptions?.errorResponses || [],\n\n\t\t\t\t/** Handle 400 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 400,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 403 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 403,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\n\t\t\t\t/** Handle 404 errors */\n\t\t\t\t{\n\t\t\t\t\thttpStatus: 404,\n\t\t\t\t\tresponseHttpStatus: 200,\n\t\t\t\t\tresponsePagePath: '/index.html',\n\t\t\t\t\tttl: Duration.days(1)\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\t}\n}"]}
@@ -0,0 +1,36 @@
1
+ import { Construct } from 'constructs';
2
+ import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
3
+ import { IBaseCdkConstructProps } from '../../types/index.cjs';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseCloudfrontConstruct
8
+ *
9
+ * Provides configuration for creating a CloudFront distribution
10
+ * with optional overrides for default behaviour and error handling.
11
+ */
12
+ interface ICloudfrontConstructProps extends Omit<IBaseCdkConstructProps<{
13
+ /** Partial configuration for the CloudFront distribution */
14
+ readonly cloudfrontOptions: Partial<DistributionProps>;
15
+ }>, 'appName' | 'stage' | 'stackName'> {
16
+ }
17
+ /**
18
+ * CDK construct for CloudFront distribution
19
+ *
20
+ * Responsibilities:
21
+ * - Creates a CloudFront distribution with configurable options
22
+ * - Enforces HTTPS redirection by default
23
+ * - Adds fallback error responses for SPA routing (400, 403, 404 → index.html)
24
+ */
25
+ declare class BaseCloudfrontConstruct extends Construct {
26
+ /** The created CloudFront distribution instance */
27
+ readonly distribution: Distribution;
28
+ /**
29
+ * @param scope Parent construct
30
+ * @param id Unique construct identifier
31
+ * @param props Configuration for CloudFront distribution
32
+ */
33
+ constructor(scope: Construct, id: string, props: ICloudfrontConstructProps);
34
+ }
35
+
36
+ export { BaseCloudfrontConstruct };
@@ -0,0 +1,36 @@
1
+ import { Construct } from 'constructs';
2
+ import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
3
+ import { IBaseCdkConstructProps } from '../../types/index.js';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseCloudfrontConstruct
8
+ *
9
+ * Provides configuration for creating a CloudFront distribution
10
+ * with optional overrides for default behaviour and error handling.
11
+ */
12
+ interface ICloudfrontConstructProps extends Omit<IBaseCdkConstructProps<{
13
+ /** Partial configuration for the CloudFront distribution */
14
+ readonly cloudfrontOptions: Partial<DistributionProps>;
15
+ }>, 'appName' | 'stage' | 'stackName'> {
16
+ }
17
+ /**
18
+ * CDK construct for CloudFront distribution
19
+ *
20
+ * Responsibilities:
21
+ * - Creates a CloudFront distribution with configurable options
22
+ * - Enforces HTTPS redirection by default
23
+ * - Adds fallback error responses for SPA routing (400, 403, 404 → index.html)
24
+ */
25
+ declare class BaseCloudfrontConstruct extends Construct {
26
+ /** The created CloudFront distribution instance */
27
+ readonly distribution: Distribution;
28
+ /**
29
+ * @param scope Parent construct
30
+ * @param id Unique construct identifier
31
+ * @param props Configuration for CloudFront distribution
32
+ */
33
+ constructor(scope: Construct, id: string, props: ICloudfrontConstructProps);
34
+ }
35
+
36
+ export { BaseCloudfrontConstruct };