@incloodsolutions/devkit 0.0.2 → 0.0.4

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 (128) hide show
  1. package/README.md +150 -41
  2. package/dist/aws-cdk/api-gateway-v2.cjs +77 -0
  3. package/dist/aws-cdk/api-gateway-v2.cjs.map +1 -0
  4. package/dist/aws-cdk/api-gateway-v2.d.cts +55 -0
  5. package/dist/aws-cdk/api-gateway-v2.d.ts +55 -0
  6. package/dist/aws-cdk/api-gateway-v2.js +75 -0
  7. package/dist/aws-cdk/api-gateway-v2.js.map +1 -0
  8. package/dist/aws-cdk/api-gateway-websocket.cjs +77 -0
  9. package/dist/aws-cdk/api-gateway-websocket.cjs.map +1 -0
  10. package/dist/aws-cdk/api-gateway-websocket.d.cts +73 -0
  11. package/dist/aws-cdk/api-gateway-websocket.d.ts +73 -0
  12. package/dist/aws-cdk/api-gateway-websocket.js +75 -0
  13. package/dist/aws-cdk/api-gateway-websocket.js.map +1 -0
  14. package/dist/aws-cdk/api-gateway.cjs +98 -0
  15. package/dist/aws-cdk/api-gateway.cjs.map +1 -0
  16. package/dist/aws-cdk/api-gateway.d.cts +80 -0
  17. package/dist/aws-cdk/api-gateway.d.ts +80 -0
  18. package/dist/aws-cdk/api-gateway.js +96 -0
  19. package/dist/aws-cdk/api-gateway.js.map +1 -0
  20. package/dist/aws-cdk/cloudfront.cjs +68 -0
  21. package/dist/aws-cdk/cloudfront.cjs.map +1 -0
  22. package/dist/aws-cdk/cloudfront.d.cts +36 -0
  23. package/dist/aws-cdk/cloudfront.d.ts +36 -0
  24. package/dist/aws-cdk/cloudfront.js +66 -0
  25. package/dist/aws-cdk/cloudfront.js.map +1 -0
  26. package/dist/aws-cdk/cloudwatch.cjs +43 -0
  27. package/dist/aws-cdk/cloudwatch.cjs.map +1 -0
  28. package/dist/aws-cdk/cloudwatch.d.cts +36 -0
  29. package/dist/aws-cdk/cloudwatch.d.ts +36 -0
  30. package/dist/aws-cdk/cloudwatch.js +41 -0
  31. package/dist/aws-cdk/cloudwatch.js.map +1 -0
  32. package/dist/aws-cdk/dynamo-db.cjs +113 -0
  33. package/dist/aws-cdk/dynamo-db.cjs.map +1 -0
  34. package/dist/aws-cdk/dynamo-db.d.cts +53 -0
  35. package/dist/aws-cdk/dynamo-db.d.ts +53 -0
  36. package/dist/aws-cdk/dynamo-db.js +111 -0
  37. package/dist/aws-cdk/dynamo-db.js.map +1 -0
  38. package/dist/aws-cdk/event-bridge.cjs +47 -0
  39. package/dist/aws-cdk/event-bridge.cjs.map +1 -0
  40. package/dist/aws-cdk/event-bridge.d.cts +41 -0
  41. package/dist/aws-cdk/event-bridge.d.ts +41 -0
  42. package/dist/aws-cdk/event-bridge.js +45 -0
  43. package/dist/aws-cdk/event-bridge.js.map +1 -0
  44. package/dist/aws-cdk/lambda-authorizer-v2.cjs +50 -0
  45. package/dist/aws-cdk/lambda-authorizer-v2.cjs.map +1 -0
  46. package/dist/aws-cdk/lambda-authorizer-v2.d.cts +45 -0
  47. package/dist/aws-cdk/lambda-authorizer-v2.d.ts +45 -0
  48. package/dist/aws-cdk/lambda-authorizer-v2.js +48 -0
  49. package/dist/aws-cdk/lambda-authorizer-v2.js.map +1 -0
  50. package/dist/aws-cdk/lambda-authorizer.cjs +37 -0
  51. package/dist/aws-cdk/lambda-authorizer.cjs.map +1 -0
  52. package/dist/aws-cdk/lambda-authorizer.d.cts +44 -0
  53. package/dist/aws-cdk/lambda-authorizer.d.ts +44 -0
  54. package/dist/aws-cdk/lambda-authorizer.js +35 -0
  55. package/dist/aws-cdk/lambda-authorizer.js.map +1 -0
  56. package/dist/aws-cdk/lambda-layer.cjs +69 -0
  57. package/dist/aws-cdk/lambda-layer.cjs.map +1 -0
  58. package/dist/aws-cdk/lambda-layer.d.cts +52 -0
  59. package/dist/aws-cdk/lambda-layer.d.ts +52 -0
  60. package/dist/aws-cdk/lambda-layer.js +67 -0
  61. package/dist/aws-cdk/lambda-layer.js.map +1 -0
  62. package/dist/aws-cdk/lambda.cjs +82 -0
  63. package/dist/aws-cdk/lambda.cjs.map +1 -0
  64. package/dist/aws-cdk/lambda.d.cts +37 -0
  65. package/dist/aws-cdk/lambda.d.ts +37 -0
  66. package/dist/aws-cdk/lambda.js +80 -0
  67. package/dist/aws-cdk/lambda.js.map +1 -0
  68. package/dist/aws-cdk/role-policy.cjs +53 -0
  69. package/dist/aws-cdk/role-policy.cjs.map +1 -0
  70. package/dist/aws-cdk/role-policy.d.cts +44 -0
  71. package/dist/aws-cdk/role-policy.d.ts +44 -0
  72. package/dist/aws-cdk/role-policy.js +51 -0
  73. package/dist/aws-cdk/role-policy.js.map +1 -0
  74. package/dist/aws-cdk/s3-deployment.cjs +177 -0
  75. package/dist/aws-cdk/s3-deployment.cjs.map +1 -0
  76. package/dist/aws-cdk/s3-deployment.d.cts +72 -0
  77. package/dist/aws-cdk/s3-deployment.d.ts +72 -0
  78. package/dist/aws-cdk/s3-deployment.js +175 -0
  79. package/dist/aws-cdk/s3-deployment.js.map +1 -0
  80. package/dist/aws-cdk/s3.cjs +38 -0
  81. package/dist/aws-cdk/s3.cjs.map +1 -0
  82. package/dist/aws-cdk/s3.d.cts +36 -0
  83. package/dist/aws-cdk/s3.d.ts +36 -0
  84. package/dist/aws-cdk/s3.js +36 -0
  85. package/dist/aws-cdk/s3.js.map +1 -0
  86. package/dist/aws-cdk/sns.cjs +43 -0
  87. package/dist/aws-cdk/sns.cjs.map +1 -0
  88. package/dist/aws-cdk/sns.d.cts +45 -0
  89. package/dist/aws-cdk/sns.d.ts +45 -0
  90. package/dist/aws-cdk/sns.js +41 -0
  91. package/dist/aws-cdk/sns.js.map +1 -0
  92. package/dist/aws-cdk/sqs.cjs +55 -0
  93. package/dist/aws-cdk/sqs.cjs.map +1 -0
  94. package/dist/aws-cdk/sqs.d.cts +52 -0
  95. package/dist/aws-cdk/sqs.d.ts +52 -0
  96. package/dist/aws-cdk/sqs.js +53 -0
  97. package/dist/aws-cdk/sqs.js.map +1 -0
  98. package/dist/aws-cdk/vpc.cjs +33 -0
  99. package/dist/aws-cdk/vpc.cjs.map +1 -0
  100. package/dist/aws-cdk/vpc.d.cts +34 -0
  101. package/dist/aws-cdk/vpc.d.ts +34 -0
  102. package/dist/aws-cdk/vpc.js +31 -0
  103. package/dist/aws-cdk/vpc.js.map +1 -0
  104. package/dist/aws-cdk.cjs +905 -0
  105. package/dist/aws-cdk.cjs.map +1 -0
  106. package/dist/aws-cdk.d.cts +34 -0
  107. package/dist/aws-cdk.d.ts +34 -0
  108. package/dist/aws-cdk.js +887 -0
  109. package/dist/aws-cdk.js.map +1 -0
  110. package/dist/aws-types.cjs +4 -0
  111. package/dist/aws-types.cjs.map +1 -0
  112. package/dist/aws-types.d.cts +42 -0
  113. package/dist/aws-types.d.ts +42 -0
  114. package/dist/aws-types.js +3 -0
  115. package/dist/aws-types.js.map +1 -0
  116. package/dist/aws.cjs +905 -0
  117. package/dist/aws.cjs.map +1 -0
  118. package/dist/aws.d.cts +34 -0
  119. package/dist/aws.d.ts +34 -0
  120. package/dist/aws.js +887 -0
  121. package/dist/aws.js.map +1 -0
  122. package/dist/index.cjs +43 -19
  123. package/dist/index.cjs.map +1 -1
  124. package/dist/index.d.cts +34 -755
  125. package/dist/index.d.ts +34 -755
  126. package/dist/index.js +43 -19
  127. package/dist/index.js.map +1 -1
  128. package/package.json +181 -19
@@ -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.cjs.map
68
+ //# sourceMappingURL=cloudfront.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aws/cdk/constructs/cloudfront-construct.ts"],"names":["Construct","Distribution","ViewerProtocolPolicy","Duration"],"mappings":";;;;;;;;AAgCO,IAAM,uBAAA,GAAN,cAAsCA,oBAAA,CAAU;AAAA,EAhCvD;AAgCuD,IAAA,MAAA,CAAA,IAAA,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ACD","file":"cloudfront.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { Duration } from 'aws-cdk-lib';\nimport {\n\tDistribution,\n\tDistributionProps,\n\tViewerProtocolPolicy,\n} 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<\n\tIBaseCdkConstructProps<{\n\t\t/** Partial configuration for the CloudFront distribution */\n\t\treadonly cloudfrontOptions: Partial<DistributionProps>;\n\t}>,\n\t'appName' | 'stage' | 'stackName'\n> {}\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\n\t\t\t\t\t\t?.viewerProtocolPolicy || 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}\n"]}
@@ -0,0 +1,36 @@
1
+ import { Construct } from 'constructs';
2
+ import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
3
+ import { IBaseCdkConstructProps } from '../aws-types.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 '../aws-types.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 };
@@ -0,0 +1,66 @@
1
+ import { Construct } from 'constructs';
2
+ import { Duration } from 'aws-cdk-lib';
3
+ import { Distribution, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var BaseCloudfrontConstruct = class extends Construct {
8
+ static {
9
+ __name(this, "BaseCloudfrontConstruct");
10
+ }
11
+ /** The created CloudFront distribution instance */
12
+ distribution;
13
+ /**
14
+ * @param scope Parent construct
15
+ * @param id Unique construct identifier
16
+ * @param props Configuration for CloudFront distribution
17
+ */
18
+ constructor(scope, id, props) {
19
+ super(scope, id);
20
+ this.distribution = new Distribution(this, id, {
21
+ ...props.options?.cloudfrontOptions,
22
+ /**
23
+ * Default behaviour configuration
24
+ * Enforces HTTPS if not explicitly defined
25
+ */
26
+ defaultBehavior: {
27
+ ...props.options?.cloudfrontOptions?.defaultBehavior,
28
+ viewerProtocolPolicy: props.options?.cloudfrontOptions?.defaultBehavior?.viewerProtocolPolicy || ViewerProtocolPolicy.REDIRECT_TO_HTTPS
29
+ },
30
+ /**
31
+ * Error response configuration
32
+ *
33
+ * Adds SPA-friendly fallbacks:
34
+ * - 400, 403, 404 responses are redirected to index.html
35
+ */
36
+ errorResponses: [
37
+ ...props.options?.cloudfrontOptions?.errorResponses || [],
38
+ /** Handle 400 errors */
39
+ {
40
+ httpStatus: 400,
41
+ responseHttpStatus: 200,
42
+ responsePagePath: "/index.html",
43
+ ttl: Duration.days(1)
44
+ },
45
+ /** Handle 403 errors */
46
+ {
47
+ httpStatus: 403,
48
+ responseHttpStatus: 200,
49
+ responsePagePath: "/index.html",
50
+ ttl: Duration.days(1)
51
+ },
52
+ /** Handle 404 errors */
53
+ {
54
+ httpStatus: 404,
55
+ responseHttpStatus: 200,
56
+ responsePagePath: "/index.html",
57
+ ttl: Duration.days(1)
58
+ }
59
+ ]
60
+ });
61
+ }
62
+ };
63
+
64
+ export { BaseCloudfrontConstruct };
65
+ //# sourceMappingURL=cloudfront.js.map
66
+ //# sourceMappingURL=cloudfront.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aws/cdk/constructs/cloudfront-construct.ts"],"names":[],"mappings":";;;;;;AAgCO,IAAM,uBAAA,GAAN,cAAsC,SAAA,CAAU;AAAA,EAhCvD;AAgCuD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A;AAAA,EACF;AACD","file":"cloudfront.js","sourcesContent":["import { Construct } from 'constructs';\nimport { Duration } from 'aws-cdk-lib';\nimport {\n\tDistribution,\n\tDistributionProps,\n\tViewerProtocolPolicy,\n} 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<\n\tIBaseCdkConstructProps<{\n\t\t/** Partial configuration for the CloudFront distribution */\n\t\treadonly cloudfrontOptions: Partial<DistributionProps>;\n\t}>,\n\t'appName' | 'stage' | 'stackName'\n> {}\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\n\t\t\t\t\t\t?.viewerProtocolPolicy || 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}\n"]}
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsLogs = require('aws-cdk-lib/aws-logs');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var BaseCloudwatchLogGroupConstruct = class extends constructs.Construct {
10
+ static {
11
+ __name(this, "BaseCloudwatchLogGroupConstruct");
12
+ }
13
+ /** The created CloudWatch Log Group instance */
14
+ logGroup;
15
+ /**
16
+ * @param scope Parent construct
17
+ * @param id Unique construct identifier
18
+ * @param props Configuration for the log group
19
+ */
20
+ constructor(scope, id, props) {
21
+ super(scope, id);
22
+ this.logGroup = new awsLogs.LogGroup(this, id, {
23
+ ...props.options?.logGroupOptions,
24
+ /**
25
+ * Removal policy applied to the log group
26
+ * Defaults to DESTROY when not explicitly defined
27
+ */
28
+ removalPolicy: props?.options?.logGroupOptions?.removalPolicy || awsCdkLib.RemovalPolicy.DESTROY,
29
+ /**
30
+ * Log retention period
31
+ * Defaults to INFINITE when not explicitly defined
32
+ */
33
+ retention: props?.options?.logGroupOptions?.retention || awsLogs.RetentionDays.INFINITE
34
+ });
35
+ new awsCdkLib.CfnOutput(this, "CloudwatchArn", {
36
+ value: this.logGroup.logGroupArn
37
+ });
38
+ }
39
+ };
40
+
41
+ exports.BaseCloudwatchLogGroupConstruct = BaseCloudwatchLogGroupConstruct;
42
+ //# sourceMappingURL=cloudwatch.cjs.map
43
+ //# sourceMappingURL=cloudwatch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aws/cdk/constructs/cloudwatch-construct.ts"],"names":["Construct","LogGroup","RemovalPolicy","RetentionDays","CfnOutput"],"mappings":";;;;;;;;AA4BO,IAAM,+BAAA,GAAN,cAA8CA,oBAAA,CAAU;AAAA,EA5B/D;AA4B+D,IAAA,MAAA,CAAA,IAAA,EAAA,iCAAA,CAAA;AAAA;AAAA;AAAA,EAErD,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAgC;AACzE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,QAAA,GAAW,IAAIC,gBAAA,CAAS,IAAA,EAAM,EAAA,EAAI;AAAA,MACtC,GAAG,MAAM,OAAA,EAAS,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,eAAA,EAAiB,iBAAiBC,uBAAA,CAAc,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMjE,SAAA,EACC,KAAA,EAAO,OAAA,EAAS,eAAA,EAAiB,aAAaC,qBAAA,CAAc;AAAA,KAC7D,CAAA;AAKD,IAAA,IAAIC,mBAAA,CAAU,MAAM,eAAA,EAAiB;AAAA,MACpC,KAAA,EAAO,KAAK,QAAA,CAAS;AAAA,KACrB,CAAA;AAAA,EACF;AACD","file":"cloudwatch.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { LogGroup, LogGroupProps, RetentionDays } from 'aws-cdk-lib/aws-logs';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseCloudwatchLogGroupConstruct\n *\n * Provides configuration for creating a CloudWatch Log Group\n * with optional overrides for retention and removal policy.\n */\ninterface ILogGroupConstructProps extends Omit<\n\tIBaseCdkConstructProps<{\n\t\t/** Log Group configuration options */\n\t\treadonly logGroupOptions: LogGroupProps;\n\t}>,\n\t'appName' | 'stage' | 'stackName'\n> {}\n\n/**\n * CDK construct for CloudWatch Log Group\n *\n * Responsibilities:\n * - Creates a log group with configurable options\n * - Applies default removal policy and retention if not provided\n * - Exposes the log group ARN as a CloudFormation output\n */\nexport class BaseCloudwatchLogGroupConstruct extends Construct {\n\t/** The created CloudWatch Log Group instance */\n\treadonly logGroup: LogGroup;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for the log group\n\t */\n\tconstructor(scope: Construct, id: string, props: ILogGroupConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.logGroup = new LogGroup(this, id, {\n\t\t\t...props.options?.logGroupOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the log group\n\t\t\t * Defaults to DESTROY when not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops?.options?.logGroupOptions?.removalPolicy || RemovalPolicy.DESTROY,\n\n\t\t\t/**\n\t\t\t * Log retention period\n\t\t\t * Defaults to INFINITE when not explicitly defined\n\t\t\t */\n\t\t\tretention:\n\t\t\t\tprops?.options?.logGroupOptions?.retention || RetentionDays.INFINITE,\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the Log Group ARN\n\t\t */\n\t\tnew CfnOutput(this, 'CloudwatchArn', {\n\t\t\tvalue: this.logGroup.logGroupArn,\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { Construct } from 'constructs';
2
+ import { LogGroup, LogGroupProps } from 'aws-cdk-lib/aws-logs';
3
+ import { IBaseCdkConstructProps } from '../aws-types.cjs';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseCloudwatchLogGroupConstruct
8
+ *
9
+ * Provides configuration for creating a CloudWatch Log Group
10
+ * with optional overrides for retention and removal policy.
11
+ */
12
+ interface ILogGroupConstructProps extends Omit<IBaseCdkConstructProps<{
13
+ /** Log Group configuration options */
14
+ readonly logGroupOptions: LogGroupProps;
15
+ }>, 'appName' | 'stage' | 'stackName'> {
16
+ }
17
+ /**
18
+ * CDK construct for CloudWatch Log Group
19
+ *
20
+ * Responsibilities:
21
+ * - Creates a log group with configurable options
22
+ * - Applies default removal policy and retention if not provided
23
+ * - Exposes the log group ARN as a CloudFormation output
24
+ */
25
+ declare class BaseCloudwatchLogGroupConstruct extends Construct {
26
+ /** The created CloudWatch Log Group instance */
27
+ readonly logGroup: LogGroup;
28
+ /**
29
+ * @param scope Parent construct
30
+ * @param id Unique construct identifier
31
+ * @param props Configuration for the log group
32
+ */
33
+ constructor(scope: Construct, id: string, props: ILogGroupConstructProps);
34
+ }
35
+
36
+ export { BaseCloudwatchLogGroupConstruct };
@@ -0,0 +1,36 @@
1
+ import { Construct } from 'constructs';
2
+ import { LogGroup, LogGroupProps } from 'aws-cdk-lib/aws-logs';
3
+ import { IBaseCdkConstructProps } from '../aws-types.js';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseCloudwatchLogGroupConstruct
8
+ *
9
+ * Provides configuration for creating a CloudWatch Log Group
10
+ * with optional overrides for retention and removal policy.
11
+ */
12
+ interface ILogGroupConstructProps extends Omit<IBaseCdkConstructProps<{
13
+ /** Log Group configuration options */
14
+ readonly logGroupOptions: LogGroupProps;
15
+ }>, 'appName' | 'stage' | 'stackName'> {
16
+ }
17
+ /**
18
+ * CDK construct for CloudWatch Log Group
19
+ *
20
+ * Responsibilities:
21
+ * - Creates a log group with configurable options
22
+ * - Applies default removal policy and retention if not provided
23
+ * - Exposes the log group ARN as a CloudFormation output
24
+ */
25
+ declare class BaseCloudwatchLogGroupConstruct extends Construct {
26
+ /** The created CloudWatch Log Group instance */
27
+ readonly logGroup: LogGroup;
28
+ /**
29
+ * @param scope Parent construct
30
+ * @param id Unique construct identifier
31
+ * @param props Configuration for the log group
32
+ */
33
+ constructor(scope: Construct, id: string, props: ILogGroupConstructProps);
34
+ }
35
+
36
+ export { BaseCloudwatchLogGroupConstruct };
@@ -0,0 +1,41 @@
1
+ import { Construct } from 'constructs';
2
+ import { RemovalPolicy, CfnOutput } from 'aws-cdk-lib';
3
+ import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var BaseCloudwatchLogGroupConstruct = class extends Construct {
8
+ static {
9
+ __name(this, "BaseCloudwatchLogGroupConstruct");
10
+ }
11
+ /** The created CloudWatch Log Group instance */
12
+ logGroup;
13
+ /**
14
+ * @param scope Parent construct
15
+ * @param id Unique construct identifier
16
+ * @param props Configuration for the log group
17
+ */
18
+ constructor(scope, id, props) {
19
+ super(scope, id);
20
+ this.logGroup = new LogGroup(this, id, {
21
+ ...props.options?.logGroupOptions,
22
+ /**
23
+ * Removal policy applied to the log group
24
+ * Defaults to DESTROY when not explicitly defined
25
+ */
26
+ removalPolicy: props?.options?.logGroupOptions?.removalPolicy || RemovalPolicy.DESTROY,
27
+ /**
28
+ * Log retention period
29
+ * Defaults to INFINITE when not explicitly defined
30
+ */
31
+ retention: props?.options?.logGroupOptions?.retention || RetentionDays.INFINITE
32
+ });
33
+ new CfnOutput(this, "CloudwatchArn", {
34
+ value: this.logGroup.logGroupArn
35
+ });
36
+ }
37
+ };
38
+
39
+ export { BaseCloudwatchLogGroupConstruct };
40
+ //# sourceMappingURL=cloudwatch.js.map
41
+ //# sourceMappingURL=cloudwatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aws/cdk/constructs/cloudwatch-construct.ts"],"names":[],"mappings":";;;;;;AA4BO,IAAM,+BAAA,GAAN,cAA8C,SAAA,CAAU;AAAA,EA5B/D;AA4B+D,IAAA,MAAA,CAAA,IAAA,EAAA,iCAAA,CAAA;AAAA;AAAA;AAAA,EAErD,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,KAAA,EAAkB,EAAA,EAAY,KAAA,EAAgC;AACzE,IAAA,KAAA,CAAM,OAAO,EAAE,CAAA;AAEf,IAAA,IAAA,CAAK,QAAA,GAAW,IAAI,QAAA,CAAS,IAAA,EAAM,EAAA,EAAI;AAAA,MACtC,GAAG,MAAM,OAAA,EAAS,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMlB,aAAA,EACC,KAAA,EAAO,OAAA,EAAS,eAAA,EAAiB,iBAAiB,aAAA,CAAc,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMjE,SAAA,EACC,KAAA,EAAO,OAAA,EAAS,eAAA,EAAiB,aAAa,aAAA,CAAc;AAAA,KAC7D,CAAA;AAKD,IAAA,IAAI,SAAA,CAAU,MAAM,eAAA,EAAiB;AAAA,MACpC,KAAA,EAAO,KAAK,QAAA,CAAS;AAAA,KACrB,CAAA;AAAA,EACF;AACD","file":"cloudwatch.js","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput, RemovalPolicy } from 'aws-cdk-lib';\nimport { LogGroup, LogGroupProps, RetentionDays } from 'aws-cdk-lib/aws-logs';\n\nimport { IBaseCdkConstructProps } from '../../types';\n\n/**\n * Props for BaseCloudwatchLogGroupConstruct\n *\n * Provides configuration for creating a CloudWatch Log Group\n * with optional overrides for retention and removal policy.\n */\ninterface ILogGroupConstructProps extends Omit<\n\tIBaseCdkConstructProps<{\n\t\t/** Log Group configuration options */\n\t\treadonly logGroupOptions: LogGroupProps;\n\t}>,\n\t'appName' | 'stage' | 'stackName'\n> {}\n\n/**\n * CDK construct for CloudWatch Log Group\n *\n * Responsibilities:\n * - Creates a log group with configurable options\n * - Applies default removal policy and retention if not provided\n * - Exposes the log group ARN as a CloudFormation output\n */\nexport class BaseCloudwatchLogGroupConstruct extends Construct {\n\t/** The created CloudWatch Log Group instance */\n\treadonly logGroup: LogGroup;\n\n\t/**\n\t * @param scope Parent construct\n\t * @param id Unique construct identifier\n\t * @param props Configuration for the log group\n\t */\n\tconstructor(scope: Construct, id: string, props: ILogGroupConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.logGroup = new LogGroup(this, id, {\n\t\t\t...props.options?.logGroupOptions,\n\n\t\t\t/**\n\t\t\t * Removal policy applied to the log group\n\t\t\t * Defaults to DESTROY when not explicitly defined\n\t\t\t */\n\t\t\tremovalPolicy:\n\t\t\t\tprops?.options?.logGroupOptions?.removalPolicy || RemovalPolicy.DESTROY,\n\n\t\t\t/**\n\t\t\t * Log retention period\n\t\t\t * Defaults to INFINITE when not explicitly defined\n\t\t\t */\n\t\t\tretention:\n\t\t\t\tprops?.options?.logGroupOptions?.retention || RetentionDays.INFINITE,\n\t\t});\n\n\t\t/**\n\t\t * CloudFormation output exposing the Log Group ARN\n\t\t */\n\t\tnew CfnOutput(this, 'CloudwatchArn', {\n\t\t\tvalue: this.logGroup.logGroupArn,\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ var constructs = require('constructs');
4
+ var awsCdkLib = require('aws-cdk-lib');
5
+ var awsDynamodb = require('aws-cdk-lib/aws-dynamodb');
6
+ var toolkit = require('@incloodsolutions/toolkit');
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var BaseDynamoDBConstruct = class _BaseDynamoDBConstruct extends constructs.Construct {
11
+ static {
12
+ __name(this, "BaseDynamoDBConstruct");
13
+ }
14
+ /** Newly created DynamoDB table (null if importing existing table) */
15
+ table;
16
+ /** Imported DynamoDB table reference (null if creating new table) */
17
+ existingTable;
18
+ /** Enables debug logging */
19
+ enableDebug = false;
20
+ /**
21
+ * @param scope Parent construct
22
+ * @param id Unique construct identifier
23
+ * @param props Configuration for table creation or import
24
+ */
25
+ constructor(scope, id, props) {
26
+ super(scope, id);
27
+ this.enableDebug = props?.enableDebug;
28
+ if (props.options?.fromExistingTableName) {
29
+ this.table = null;
30
+ this.existingTable = awsDynamodb.Table.fromTableName(
31
+ this,
32
+ `${id}-RefName`,
33
+ props.options.fromExistingTableName
34
+ );
35
+ if (this.enableDebug) {
36
+ toolkit.printLog(
37
+ _BaseDynamoDBConstruct.name,
38
+ `Created Dynamo-DB table from existing using name ${props.options?.fromExistingTableName}`
39
+ );
40
+ }
41
+ } else if (props.options?.fromExistingTableArn) {
42
+ this.table = null;
43
+ this.existingTable = awsDynamodb.Table.fromTableArn(
44
+ this,
45
+ `${id}-RefArn`,
46
+ props.options.fromExistingTableArn
47
+ );
48
+ if (this.enableDebug) {
49
+ toolkit.printLog(
50
+ _BaseDynamoDBConstruct.name,
51
+ `Created Dynamo-DB table from existing using ARN`
52
+ );
53
+ }
54
+ } else if (props.options?.fromExistingTableAttributes) {
55
+ this.table = null;
56
+ this.existingTable = awsDynamodb.Table.fromTableAttributes(
57
+ this,
58
+ `${id}-RefAttributes`,
59
+ props.options.fromExistingTableAttributes
60
+ );
61
+ if (this.enableDebug) {
62
+ toolkit.printLog(
63
+ _BaseDynamoDBConstruct.name,
64
+ `Created Dynamo-DB table from existing attributes`
65
+ );
66
+ }
67
+ } else {
68
+ this.existingTable = null;
69
+ this.table = new awsDynamodb.Table(this, id, {
70
+ ...props.options?.tableOptions,
71
+ /**
72
+ * Billing mode defaults to PAY_PER_REQUEST if not provided
73
+ */
74
+ billingMode: props.options?.tableOptions?.billingMode || awsDynamodb.BillingMode.PAY_PER_REQUEST,
75
+ /**
76
+ * Deletion protection:
77
+ * - Uses explicit value if provided
78
+ * - Defaults to true in production stage
79
+ */
80
+ deletionProtection: props.options?.tableOptions?.deletionProtection === true || props.options?.tableOptions?.deletionProtection === false ? props.options.tableOptions.deletionProtection : props.stage === "production"
81
+ });
82
+ if (props.options?.globalSecondaryIndexes?.length) {
83
+ props.options.globalSecondaryIndexes.forEach((globalIndex) => {
84
+ this.table.addGlobalSecondaryIndex(globalIndex);
85
+ if (this.enableDebug) {
86
+ toolkit.printLog(
87
+ _BaseDynamoDBConstruct.name,
88
+ `Added GSI: ${globalIndex.indexName}`
89
+ );
90
+ }
91
+ });
92
+ }
93
+ if (props.options?.localSecondaryIndexes?.length) {
94
+ props.options.localSecondaryIndexes.forEach((localIndex) => {
95
+ this.table.addLocalSecondaryIndex(localIndex);
96
+ if (this.enableDebug) {
97
+ toolkit.printLog(
98
+ _BaseDynamoDBConstruct.name,
99
+ `Added LSI: ${localIndex.indexName}`
100
+ );
101
+ }
102
+ });
103
+ }
104
+ }
105
+ new awsCdkLib.CfnOutput(this, "DynamoDbArn", {
106
+ value: props.options?.fromExistingTableName || props.options?.fromExistingTableArn ? this.existingTable.tableArn : this.table.tableArn
107
+ });
108
+ }
109
+ };
110
+
111
+ exports.BaseDynamoDBConstruct = BaseDynamoDBConstruct;
112
+ //# sourceMappingURL=dynamo-db.cjs.map
113
+ //# sourceMappingURL=dynamo-db.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aws/cdk/constructs/dynamo-db-construct.ts"],"names":["Construct","Table","printLog","BillingMode","CfnOutput"],"mappings":";;;;;;;;;AAwDO,IAAM,qBAAA,GAAN,MAAM,sBAAA,SAA8BA,oBAAA,CAAoC;AAAA,EAxD/E;AAwD+E,IAAA,MAAA,CAAA,IAAA,EAAA,uBAAA,CAAA;AAAA;AAAA;AAAA,EAErE,KAAA;AAAA;AAAA,EAGA,aAAA;AAAA;AAAA,EAGT,WAAA,GAAc,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,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,CAAC,UAAA,KAAe;AAC3D,UAAA,IAAA,CAAK,KAAA,CAAM,uBAAuB,UAAU,CAAA;AAE5C,UAAA,IAAI,KAAK,WAAA,EAAa;AACrB,YAAAA,gBAAA;AAAA,cACC,sBAAA,CAAsB,IAAA;AAAA,cACtB,CAAA,WAAA,EAAc,WAAW,SAAS,CAAA;AAAA,aACnC;AAAA,UACD;AAAA,QACD,CAAC,CAAA;AAAA,MACF;AAAA,IACD;AAMA,IAAA,IAAIE,mBAAA,CAAU,MAAM,aAAA,EAAe;AAAA,MAClC,KAAA,EACC,KAAA,CAAM,OAAA,EAAS,qBAAA,IACf,KAAA,CAAM,OAAA,EAAS,oBAAA,GACZ,IAAA,CAAK,aAAA,CAAc,QAAA,GACnB,IAAA,CAAK,KAAA,CAAM;AAAA,KACf,CAAA;AAAA,EACF;AACD","file":"dynamo-db.cjs","sourcesContent":["import { Construct } from 'constructs';\nimport { CfnOutput } from 'aws-cdk-lib';\nimport {\n\tBillingMode,\n\tGlobalSecondaryIndexProps,\n\tITable,\n\tLocalSecondaryIndexProps,\n\tTable,\n\tTableAttributes,\n\tTableProps,\n} from 'aws-cdk-lib/aws-dynamodb';\n\nimport { printLog } from '@incloodsolutions/toolkit';\n\nimport { IBaseCdkConstructProps, IBaseConstruct } from '../../types';\n\n/**\n * Props for BaseDynamoDBConstruct\n *\n * Provides configuration for:\n * - Creating a new DynamoDB table\n * - Importing an existing table (by name, ARN, or attributes)\n * - Defining Global Secondary Indexes (GSI) and Local Secondary Indexes (LSI)\n */\ninterface IDynamoDBConstructProps extends Omit<\n\tIBaseCdkConstructProps<{\n\t\t/** Configuration for creating a new table */\n\t\treadonly tableOptions?: TableProps;\n\n\t\t/** Import an existing table by ARN */\n\t\treadonly fromExistingTableArn?: string;\n\n\t\t/** Import an existing table by name */\n\t\treadonly fromExistingTableName?: string;\n\n\t\t/** Import an existing table using attributes */\n\t\treadonly fromExistingTableAttributes?: TableAttributes;\n\n\t\t/** Global Secondary Index definitions */\n\t\treadonly globalSecondaryIndexes?: GlobalSecondaryIndexProps[];\n\n\t\t/** Local Secondary Index definitions */\n\t\treadonly localSecondaryIndexes?: LocalSecondaryIndexProps[];\n\t}>,\n\t'appName' | 'stackName'\n> {}\n\n/**\n * CDK construct for DynamoDB table management\n *\n * Responsibilities:\n * - Creates a new DynamoDB table or imports an existing one\n * - Applies default billing mode and deletion protection\n * - Attaches optional GSIs and LSIs\n * - Exposes table ARN as a CloudFormation output\n */\nexport class BaseDynamoDBConstruct extends Construct implements IBaseConstruct {\n\t/** Newly created DynamoDB table (null if importing existing table) */\n\treadonly table: Table;\n\n\t/** Imported DynamoDB table reference (null if creating new table) */\n\treadonly existingTable: ITable;\n\n\t/** Enables debug logging */\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 table creation or import\n\t */\n\tconstructor(scope: Construct, id: string, props: IDynamoDBConstructProps) {\n\t\tsuper(scope, id);\n\n\t\tthis.enableDebug = props?.enableDebug;\n\n\t\t/**\n\t\t * Import table by name\n\t\t */\n\t\tif (props.options?.fromExistingTableName) {\n\t\t\tthis.table = null;\n\n\t\t\tthis.existingTable = Table.fromTableName(\n\t\t\t\tthis,\n\t\t\t\t`${id}-RefName`,\n\t\t\t\tprops.options.fromExistingTableName,\n\t\t\t);\n\n\t\t\tif (this.enableDebug) {\n\t\t\t\tprintLog(\n\t\t\t\t\tBaseDynamoDBConstruct.name,\n\t\t\t\t\t`Created Dynamo-DB table from existing using name ${props.options?.fromExistingTableName}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Import table by ARN\n\t\t\t */\n\t\t} else if (props.options?.fromExistingTableArn) {\n\t\t\tthis.table = null;\n\n\t\t\tthis.existingTable = Table.fromTableArn(\n\t\t\t\tthis,\n\t\t\t\t`${id}-RefArn`,\n\t\t\t\tprops.options.fromExistingTableArn,\n\t\t\t);\n\n\t\t\tif (this.enableDebug) {\n\t\t\t\tprintLog(\n\t\t\t\t\tBaseDynamoDBConstruct.name,\n\t\t\t\t\t`Created Dynamo-DB table from existing using ARN`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Import table using attributes\n\t\t\t */\n\t\t} else if (props.options?.fromExistingTableAttributes) {\n\t\t\tthis.table = null;\n\n\t\t\tthis.existingTable = Table.fromTableAttributes(\n\t\t\t\tthis,\n\t\t\t\t`${id}-RefAttributes`,\n\t\t\t\tprops.options.fromExistingTableAttributes,\n\t\t\t);\n\n\t\t\tif (this.enableDebug) {\n\t\t\t\tprintLog(\n\t\t\t\t\tBaseDynamoDBConstruct.name,\n\t\t\t\t\t`Created Dynamo-DB table from existing attributes`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Create new table\n\t\t\t */\n\t\t} else {\n\t\t\tthis.existingTable = null;\n\n\t\t\tthis.table = new Table(this, id, {\n\t\t\t\t...props.options?.tableOptions,\n\n\t\t\t\t/**\n\t\t\t\t * Billing mode defaults to PAY_PER_REQUEST if not provided\n\t\t\t\t */\n\t\t\t\tbillingMode:\n\t\t\t\t\tprops.options?.tableOptions?.billingMode ||\n\t\t\t\t\tBillingMode.PAY_PER_REQUEST,\n\n\t\t\t\t/**\n\t\t\t\t * Deletion protection:\n\t\t\t\t * - Uses explicit value if provided\n\t\t\t\t * - Defaults to true in production stage\n\t\t\t\t */\n\t\t\t\tdeletionProtection:\n\t\t\t\t\tprops.options?.tableOptions?.deletionProtection === true ||\n\t\t\t\t\tprops.options?.tableOptions?.deletionProtection === false\n\t\t\t\t\t\t? props.options.tableOptions.deletionProtection\n\t\t\t\t\t\t: props.stage === 'production',\n\t\t\t});\n\n\t\t\t/**\n\t\t\t * Attach Global Secondary Indexes (GSI)\n\t\t\t */\n\t\t\tif (props.options?.globalSecondaryIndexes?.length) {\n\t\t\t\tprops.options.globalSecondaryIndexes.forEach((globalIndex) => {\n\t\t\t\t\tthis.table.addGlobalSecondaryIndex(globalIndex);\n\n\t\t\t\t\tif (this.enableDebug) {\n\t\t\t\t\t\tprintLog(\n\t\t\t\t\t\t\tBaseDynamoDBConstruct.name,\n\t\t\t\t\t\t\t`Added GSI: ${globalIndex.indexName}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Attach Local Secondary Indexes (LSI)\n\t\t\t */\n\t\t\tif (props.options?.localSecondaryIndexes?.length) {\n\t\t\t\tprops.options.localSecondaryIndexes.forEach((localIndex) => {\n\t\t\t\t\tthis.table.addLocalSecondaryIndex(localIndex);\n\n\t\t\t\t\tif (this.enableDebug) {\n\t\t\t\t\t\tprintLog(\n\t\t\t\t\t\t\tBaseDynamoDBConstruct.name,\n\t\t\t\t\t\t\t`Added LSI: ${localIndex.indexName}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * CloudFormation output exposing the table ARN\n\t\t * Resolves to either created or imported table\n\t\t */\n\t\tnew CfnOutput(this, 'DynamoDbArn', {\n\t\t\tvalue:\n\t\t\t\tprops.options?.fromExistingTableName ||\n\t\t\t\tprops.options?.fromExistingTableArn\n\t\t\t\t\t? this.existingTable.tableArn\n\t\t\t\t\t: this.table.tableArn,\n\t\t});\n\t}\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import { Construct } from 'constructs';
2
+ import { Table, ITable, TableProps, TableAttributes, GlobalSecondaryIndexProps, LocalSecondaryIndexProps } from 'aws-cdk-lib/aws-dynamodb';
3
+ import { IBaseConstruct, IBaseCdkConstructProps } from '../aws-types.cjs';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseDynamoDBConstruct
8
+ *
9
+ * Provides configuration for:
10
+ * - Creating a new DynamoDB table
11
+ * - Importing an existing table (by name, ARN, or attributes)
12
+ * - Defining Global Secondary Indexes (GSI) and Local Secondary Indexes (LSI)
13
+ */
14
+ interface IDynamoDBConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** Configuration for creating a new table */
16
+ readonly tableOptions?: TableProps;
17
+ /** Import an existing table by ARN */
18
+ readonly fromExistingTableArn?: string;
19
+ /** Import an existing table by name */
20
+ readonly fromExistingTableName?: string;
21
+ /** Import an existing table using attributes */
22
+ readonly fromExistingTableAttributes?: TableAttributes;
23
+ /** Global Secondary Index definitions */
24
+ readonly globalSecondaryIndexes?: GlobalSecondaryIndexProps[];
25
+ /** Local Secondary Index definitions */
26
+ readonly localSecondaryIndexes?: LocalSecondaryIndexProps[];
27
+ }>, 'appName' | 'stackName'> {
28
+ }
29
+ /**
30
+ * CDK construct for DynamoDB table management
31
+ *
32
+ * Responsibilities:
33
+ * - Creates a new DynamoDB table or imports an existing one
34
+ * - Applies default billing mode and deletion protection
35
+ * - Attaches optional GSIs and LSIs
36
+ * - Exposes table ARN as a CloudFormation output
37
+ */
38
+ declare class BaseDynamoDBConstruct extends Construct implements IBaseConstruct {
39
+ /** Newly created DynamoDB table (null if importing existing table) */
40
+ readonly table: Table;
41
+ /** Imported DynamoDB table reference (null if creating new table) */
42
+ readonly existingTable: ITable;
43
+ /** Enables debug logging */
44
+ enableDebug: boolean;
45
+ /**
46
+ * @param scope Parent construct
47
+ * @param id Unique construct identifier
48
+ * @param props Configuration for table creation or import
49
+ */
50
+ constructor(scope: Construct, id: string, props: IDynamoDBConstructProps);
51
+ }
52
+
53
+ export { BaseDynamoDBConstruct };
@@ -0,0 +1,53 @@
1
+ import { Construct } from 'constructs';
2
+ import { Table, ITable, TableProps, TableAttributes, GlobalSecondaryIndexProps, LocalSecondaryIndexProps } from 'aws-cdk-lib/aws-dynamodb';
3
+ import { IBaseConstruct, IBaseCdkConstructProps } from '../aws-types.js';
4
+ import '@incloodsolutions/toolkit';
5
+
6
+ /**
7
+ * Props for BaseDynamoDBConstruct
8
+ *
9
+ * Provides configuration for:
10
+ * - Creating a new DynamoDB table
11
+ * - Importing an existing table (by name, ARN, or attributes)
12
+ * - Defining Global Secondary Indexes (GSI) and Local Secondary Indexes (LSI)
13
+ */
14
+ interface IDynamoDBConstructProps extends Omit<IBaseCdkConstructProps<{
15
+ /** Configuration for creating a new table */
16
+ readonly tableOptions?: TableProps;
17
+ /** Import an existing table by ARN */
18
+ readonly fromExistingTableArn?: string;
19
+ /** Import an existing table by name */
20
+ readonly fromExistingTableName?: string;
21
+ /** Import an existing table using attributes */
22
+ readonly fromExistingTableAttributes?: TableAttributes;
23
+ /** Global Secondary Index definitions */
24
+ readonly globalSecondaryIndexes?: GlobalSecondaryIndexProps[];
25
+ /** Local Secondary Index definitions */
26
+ readonly localSecondaryIndexes?: LocalSecondaryIndexProps[];
27
+ }>, 'appName' | 'stackName'> {
28
+ }
29
+ /**
30
+ * CDK construct for DynamoDB table management
31
+ *
32
+ * Responsibilities:
33
+ * - Creates a new DynamoDB table or imports an existing one
34
+ * - Applies default billing mode and deletion protection
35
+ * - Attaches optional GSIs and LSIs
36
+ * - Exposes table ARN as a CloudFormation output
37
+ */
38
+ declare class BaseDynamoDBConstruct extends Construct implements IBaseConstruct {
39
+ /** Newly created DynamoDB table (null if importing existing table) */
40
+ readonly table: Table;
41
+ /** Imported DynamoDB table reference (null if creating new table) */
42
+ readonly existingTable: ITable;
43
+ /** Enables debug logging */
44
+ enableDebug: boolean;
45
+ /**
46
+ * @param scope Parent construct
47
+ * @param id Unique construct identifier
48
+ * @param props Configuration for table creation or import
49
+ */
50
+ constructor(scope: Construct, id: string, props: IDynamoDBConstructProps);
51
+ }
52
+
53
+ export { BaseDynamoDBConstruct };