@fy-stack/app-construct 0.0.141 → 0.0.143

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 (95) hide show
  1. package/dist/index.d.ts +8 -9
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +9 -15
  4. package/dist/lib/ecs/apps/image-app-construct.d.ts +17 -0
  5. package/dist/lib/ecs/apps/image-app-construct.d.ts.map +1 -0
  6. package/dist/lib/ecs/apps/image-app-construct.js +55 -0
  7. package/dist/lib/ecs/apps/next-app-router-construct.d.ts +22 -0
  8. package/dist/lib/ecs/apps/next-app-router-construct.d.ts.map +1 -0
  9. package/dist/lib/ecs/apps/next-app-router-construct.js +52 -0
  10. package/dist/lib/ecs/apps/task-construct.d.ts +16 -0
  11. package/dist/lib/ecs/apps/task-construct.d.ts.map +1 -0
  12. package/dist/lib/ecs/apps/task-construct.js +101 -0
  13. package/dist/lib/ecs/ecs-construct.d.ts +10 -0
  14. package/dist/lib/ecs/ecs-construct.d.ts.map +1 -0
  15. package/dist/lib/ecs/ecs-construct.js +42 -0
  16. package/dist/lib/ecs/ecs-server-construct.d.ts +28 -0
  17. package/dist/lib/ecs/ecs-server-construct.d.ts.map +1 -0
  18. package/dist/lib/ecs/ecs-server-construct.js +161 -0
  19. package/dist/lib/ecs/shared/taskDefinitionImage.d.ts +13 -0
  20. package/dist/lib/ecs/shared/taskDefinitionImage.d.ts.map +1 -0
  21. package/dist/lib/ecs/shared/taskDefinitionImage.js +27 -0
  22. package/dist/lib/ecs/shared/util/ecs-api-gateway.d.ts +2 -0
  23. package/dist/lib/ecs/shared/util/ecs-api-gateway.d.ts.map +1 -0
  24. package/dist/lib/ecs/shared/util/ecs-api-gateway.js +5 -0
  25. package/dist/lib/ecs/types.d.ts +89 -0
  26. package/dist/lib/ecs/types.d.ts.map +1 -0
  27. package/dist/lib/ecs/types.js +2 -0
  28. package/dist/lib/lambda/apps/image-app-construct.d.ts +68 -0
  29. package/dist/lib/lambda/apps/image-app-construct.d.ts.map +1 -0
  30. package/dist/lib/lambda/apps/image-app-construct.js +92 -0
  31. package/dist/lib/lambda/apps/next-app-router-construct.d.ts +33 -0
  32. package/dist/lib/lambda/apps/next-app-router-construct.d.ts.map +1 -0
  33. package/dist/lib/lambda/apps/next-app-router-construct.js +77 -0
  34. package/dist/lib/lambda/apps/node-api-construct.d.ts +43 -0
  35. package/dist/lib/lambda/apps/node-api-construct.d.ts.map +1 -0
  36. package/dist/lib/lambda/apps/node-api-construct.js +91 -0
  37. package/dist/lib/lambda/apps/node-app-construct.d.ts +32 -0
  38. package/dist/lib/lambda/apps/node-app-construct.d.ts.map +1 -0
  39. package/dist/lib/lambda/apps/node-app-construct.js +73 -0
  40. package/dist/lib/lambda/lambda-construct.d.ts +7 -0
  41. package/dist/lib/lambda/lambda-construct.d.ts.map +1 -0
  42. package/dist/lib/lambda/lambda-construct.js +34 -0
  43. package/dist/lib/lambda/types.d.ts +32 -0
  44. package/dist/lib/lambda/types.d.ts.map +1 -0
  45. package/dist/lib/lambda/types.js +2 -0
  46. package/dist/lib/lambda/utils/getDefaultLambda.d.ts +8 -0
  47. package/dist/lib/lambda/utils/getDefaultLambda.d.ts.map +1 -0
  48. package/dist/lib/lambda/utils/getDefaultLambda.js +11 -0
  49. package/dist/lib/lambda/utils/lambda-api.d.ts +6 -0
  50. package/dist/lib/lambda/utils/lambda-api.d.ts.map +1 -0
  51. package/dist/lib/lambda/utils/lambda-api.js +17 -0
  52. package/dist/lib/lambda/utils/lambda-attach.d.ts +4 -0
  53. package/dist/lib/lambda/utils/lambda-attach.d.ts.map +1 -0
  54. package/dist/lib/lambda/utils/lambda-attach.js +11 -0
  55. package/dist/lib/lambda/utils/lambda-grant.d.ts +4 -0
  56. package/dist/lib/lambda/utils/lambda-grant.d.ts.map +1 -0
  57. package/dist/lib/lambda/utils/lambda-grant.js +8 -0
  58. package/dist/lib/next-app-router-construct.d.ts.map +1 -1
  59. package/dist/lib/next-app-router-construct.js +3 -2
  60. package/dist/lib/shared/next-app-router.d.ts +12 -0
  61. package/dist/lib/shared/next-app-router.d.ts.map +1 -0
  62. package/dist/lib/shared/next-app-router.js +87 -0
  63. package/dist/lib/shared/util/params-from-attachable.d.ts +5 -0
  64. package/dist/lib/shared/util/params-from-attachable.d.ts.map +1 -0
  65. package/dist/lib/shared/util/params-from-attachable.js +11 -0
  66. package/dist/lib/shared/util/types.d.ts +25 -0
  67. package/dist/lib/shared/util/types.d.ts.map +1 -0
  68. package/dist/lib/shared/util/types.js +20 -0
  69. package/dist/lib/static/apps/next-pages-export-construct.d.ts +16 -0
  70. package/dist/lib/static/apps/next-pages-export-construct.d.ts.map +1 -0
  71. package/dist/lib/static/apps/next-pages-export-construct.js +69 -0
  72. package/dist/lib/static/apps/static-website-construct.d.ts +16 -0
  73. package/dist/lib/static/apps/static-website-construct.d.ts.map +1 -0
  74. package/dist/lib/static/apps/static-website-construct.js +62 -0
  75. package/dist/lib/static/next-pages-export-construct.d.ts +21 -0
  76. package/dist/lib/static/next-pages-export-construct.d.ts.map +1 -0
  77. package/dist/lib/static/next-pages-export-construct.js +78 -0
  78. package/dist/lib/static/static-construct.d.ts +7 -0
  79. package/dist/lib/static/static-construct.d.ts.map +1 -0
  80. package/dist/lib/static/static-construct.js +28 -0
  81. package/dist/lib/static/static-website-construct.d.ts +21 -0
  82. package/dist/lib/static/static-website-construct.d.ts.map +1 -0
  83. package/dist/lib/static/static-website-construct.js +71 -0
  84. package/dist/lib/static/types.d.ts +16 -0
  85. package/dist/lib/static/types.d.ts.map +1 -0
  86. package/dist/lib/static/types.js +2 -0
  87. package/dist/lib/types.d.ts +9 -0
  88. package/dist/lib/types.d.ts.map +1 -1
  89. package/dist/lib/util/params-from-attachable.d.ts +5 -0
  90. package/dist/lib/util/params-from-attachable.d.ts.map +1 -0
  91. package/dist/lib/util/params-from-attachable.js +11 -0
  92. package/dist/lib/util/strip-trailing-slash.d.ts +2 -0
  93. package/dist/lib/util/strip-trailing-slash.d.ts.map +1 -0
  94. package/dist/lib/util/strip-trailing-slash.js +6 -0
  95. package/package.json +3 -3
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LambdaConstruct = void 0;
4
+ const types_1 = require("@fy-stack/types");
5
+ const constructs_1 = require("constructs");
6
+ const image_app_construct_1 = require("./apps/image-app-construct");
7
+ const next_app_router_construct_1 = require("./apps/next-app-router-construct");
8
+ const node_api_construct_1 = require("./apps/node-api-construct");
9
+ const node_app_construct_1 = require("./apps/node-app-construct");
10
+ const AppBuilds = {
11
+ [types_1.AppType.NEXT_APP_ROUTER]: next_app_router_construct_1.NextAppRouterConstruct,
12
+ [types_1.AppType.NODE_APP]: node_app_construct_1.NodeAppConstruct,
13
+ [types_1.AppType.NODE_API]: node_api_construct_1.NodeApiConstruct,
14
+ [types_1.AppType.IMAGE_APP]: image_app_construct_1.ImageAppConstruct,
15
+ };
16
+ class LambdaConstruct extends constructs_1.Construct {
17
+ apps = {};
18
+ constructor(scope, id, props) {
19
+ super(scope, id);
20
+ Object.assign(this.apps, Object.fromEntries(Object.entries(props.apps).map(([key, app]) => {
21
+ const AppTypeConstruct = AppBuilds[app.type];
22
+ return [
23
+ key,
24
+ new AppTypeConstruct(this, `${key}App`, {
25
+ // @ts-expect-error invalid params
26
+ buildParams: AppTypeConstruct.parse(app.buildParams ?? {}),
27
+ vpc: props.vpc,
28
+ ...app,
29
+ }),
30
+ ];
31
+ })));
32
+ }
33
+ }
34
+ exports.LambdaConstruct = LambdaConstruct;
@@ -0,0 +1,32 @@
1
+ import { type ApiResource, AppType, type Attach, type CDNResource, type EventResource, type Grant } from '@fy-stack/types';
2
+ import type { IVpc } from 'aws-cdk-lib/aws-ec2';
3
+ import type { Function } from 'aws-cdk-lib/aws-lambda';
4
+ import { Queue } from 'aws-cdk-lib/aws-sqs';
5
+ export type LambdaConstructProps = {
6
+ vpc?: IVpc;
7
+ apps: Record<string, App>;
8
+ };
9
+ export interface AppConstruct extends Attach, Grant, CDNResource, EventResource, ApiResource {
10
+ function: Function;
11
+ queue?: Queue;
12
+ }
13
+ export type App = {
14
+ type: typeof AppType.IMAGE_APP | typeof AppType.NEXT_APP_ROUTER | typeof AppType.NODE_APP | typeof AppType.NODE_API;
15
+ output: string;
16
+ env?: Record<string, string>;
17
+ queue?: {
18
+ batchSize?: number;
19
+ };
20
+ buildParams?: Record<string, unknown>;
21
+ };
22
+ export type AppProperties<BuildParams = Record<string, unknown>> = {
23
+ queue?: {
24
+ batchSize?: number;
25
+ };
26
+ env?: Record<string, string>;
27
+ timeout?: number;
28
+ buildParams: BuildParams;
29
+ output: string;
30
+ vpc?: IVpc;
31
+ };
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,OAAO,EACP,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,KAAK,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,WAAW,YACf,SAAQ,MAAM,EACZ,KAAK,EACL,WAAW,EACX,aAAa,EACb,WAAW;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,GAAG,GAAG;IAChB,IAAI,EACA,OAAO,OAAO,CAAC,SAAS,GACxB,OAAO,OAAO,CAAC,eAAe,GAC9B,OAAO,OAAO,CAAC,QAAQ,GACvB,OAAO,OAAO,CAAC,QAAQ,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACjE,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { Duration } from 'aws-cdk-lib';
2
+ import { AppProperties } from '../types';
3
+ export declare function getDefaultLambda(props: AppProperties<unknown>): {
4
+ memorySize: number;
5
+ timeout: Duration;
6
+ environment: Record<string, string> | undefined;
7
+ };
8
+ //# sourceMappingURL=getDefaultLambda.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDefaultLambda.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/getDefaultLambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;;;;EAM7D"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultLambda = getDefaultLambda;
4
+ const aws_cdk_lib_1 = require("aws-cdk-lib");
5
+ function getDefaultLambda(props) {
6
+ return {
7
+ memorySize: 512,
8
+ timeout: aws_cdk_lib_1.Duration.seconds(props.timeout ?? 30),
9
+ environment: props.env,
10
+ };
11
+ }
@@ -0,0 +1,6 @@
1
+ import { HttpUrlIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ export declare function lambdaApi(func: Function, path: string): {
4
+ [x: string]: HttpUrlIntegration;
5
+ };
6
+ //# sourceMappingURL=lambda-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-api.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/lambda-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM;;EAgBrD"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdaApi = lambdaApi;
4
+ const tslib_1 = require("tslib");
5
+ const aws_apigatewayv2_integrations_1 = require("aws-cdk-lib/aws-apigatewayv2-integrations");
6
+ const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
7
+ function lambdaApi(func, path) {
8
+ const apiUrl = func.addFunctionUrl({
9
+ authType: lambda.FunctionUrlAuthType.NONE,
10
+ });
11
+ func.addEnvironment('BASE_PATH', path);
12
+ const integration = new aws_apigatewayv2_integrations_1.HttpUrlIntegration('AppIntegration', apiUrl.url + '{proxy}');
13
+ return {
14
+ [path]: integration,
15
+ [`${path}/{proxy+}`]: integration,
16
+ };
17
+ }
@@ -0,0 +1,4 @@
1
+ import { Attachable } from '@fy-stack/types';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ export declare function lambdaAttach(func: Function, attachable: Record<string, Attachable>): void;
4
+ //# sourceMappingURL=lambda-attach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-attach.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/lambda-attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAIlD,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,QAOlF"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdaAttach = lambdaAttach;
4
+ const params_from_attachable_1 = require("../../util/params-from-attachable");
5
+ function lambdaAttach(func, attachable) {
6
+ const params = {};
7
+ Object.assign(params, ...(0, params_from_attachable_1.paramsFromAttachable)(attachable));
8
+ for (const i in params) {
9
+ func.addEnvironment(i, params[i]);
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ import { Grantable } from '@fy-stack/types';
2
+ import { Function } from 'aws-cdk-lib/aws-lambda';
3
+ export declare function lambdaGrant(func: Function, grants: Grantable[]): void;
4
+ //# sourceMappingURL=lambda-grant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-grant.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/lambda-grant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAI9D"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdaGrant = lambdaGrant;
4
+ function lambdaGrant(func, grants) {
5
+ for (const i in grants) {
6
+ grants[i].grantable(func);
7
+ }
8
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../src/lib/next-app-router-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAIjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAItD,QAAA,MAAM,iBAAiB;;;;;;EAErB,CAAA;AAEF,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IACpE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAgEjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAuDpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
1
+ {"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../src/lib/next-app-router-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAItD,QAAA,MAAM,iBAAiB;;;;;;EAErB,CAAC;AAEH,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IACpE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAiEjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAwDpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
@@ -8,7 +8,6 @@ const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
8
8
  const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
9
9
  const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
10
10
  const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
11
- const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
12
11
  const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
13
12
  const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
14
13
  const constructs_1 = require("constructs");
@@ -57,6 +56,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
57
56
  AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
58
57
  PORT: '8080',
59
58
  AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
59
+ AWS_LWA_INVOKE_MODE: 'response_stream'
60
60
  };
61
61
  Object.assign(environment, props.env);
62
62
  const serverOutput = path.join(props.output, "/.next/standalone");
@@ -67,7 +67,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
67
67
  handler: "run.sh",
68
68
  timeout: cdk.Duration.seconds(60),
69
69
  code: lambda.Code.fromAsset(serverOutput),
70
- loggingFormat: aws_lambda_1.LoggingFormat.JSON,
70
+ loggingFormat: lambda.LoggingFormat.JSON,
71
71
  layers: [webAdapterLayer],
72
72
  environment,
73
73
  });
@@ -75,6 +75,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
75
75
  cloudfront(path) {
76
76
  const webUrl = this.function.addFunctionUrl({
77
77
  authType: lambda.FunctionUrlAuthType.NONE,
78
+ invokeMode: lambda.InvokeMode.RESPONSE_STREAM
78
79
  });
79
80
  const serverOrigin = new cloudfrontOrigin.FunctionUrlOrigin(webUrl);
80
81
  const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
@@ -0,0 +1,12 @@
1
+ import * as cdk from 'aws-cdk-lib';
2
+ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
3
+ import * as s3 from 'aws-cdk-lib/aws-s3';
4
+ import { Construct } from 'constructs';
5
+ export declare function staticDeployment(app: Construct, output: string): cdk.aws_s3.Bucket;
6
+ export declare function staticCloudfrontBehaviour(staticBucket: s3.Bucket, basePath: string): {
7
+ [x: string]: cdk.aws_cloudfront.BehaviorOptions;
8
+ };
9
+ export declare function serverCloudfrontBehaviour(app: Construct, serverOrigin: cloudfront.IOrigin, basePath: string): {
10
+ [x: string]: cdk.aws_cloudfront.BehaviorOptions;
11
+ };
12
+ //# sourceMappingURL=next-app-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-app-router.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/next-app-router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AACnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAgC9D;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,QAAQ,EAAE,MAAM;;EAqBjB;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM;;EA6BjB"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.staticDeployment = staticDeployment;
4
+ exports.staticCloudfrontBehaviour = staticCloudfrontBehaviour;
5
+ exports.serverCloudfrontBehaviour = serverCloudfrontBehaviour;
6
+ const tslib_1 = require("tslib");
7
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
+ const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
9
+ const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
10
+ const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
11
+ const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
12
+ const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
13
+ function staticDeployment(app, output) {
14
+ const staticBucket = new s3.Bucket(app, `StaticBucket`, {
15
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
16
+ autoDeleteObjects: true,
17
+ blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS_ONLY,
18
+ publicReadAccess: true,
19
+ websiteIndexDocument: 'index.html',
20
+ websiteErrorDocument: 'index.html',
21
+ cors: [
22
+ {
23
+ allowedHeaders: ['*'],
24
+ allowedOrigins: ['*'],
25
+ allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
26
+ },
27
+ ],
28
+ });
29
+ new s3Deploy.BucketDeployment(app, `StaticDeployment`, {
30
+ destinationBucket: staticBucket,
31
+ sources: [s3Deploy.Source.asset(node_path_1.default.join(output, '/.next/static'))],
32
+ destinationKeyPrefix: '_next/static',
33
+ retainOnDelete: false,
34
+ });
35
+ new s3Deploy.BucketDeployment(app, `PublicDeployment`, {
36
+ destinationBucket: staticBucket,
37
+ sources: [s3Deploy.Source.asset(node_path_1.default.join(output, '/public'))],
38
+ destinationKeyPrefix: '',
39
+ retainOnDelete: false,
40
+ });
41
+ return staticBucket;
42
+ }
43
+ function staticCloudfrontBehaviour(staticBucket, basePath) {
44
+ const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(staticBucket);
45
+ const staticBehavior = {
46
+ origin: staticOrigin,
47
+ cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
48
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
49
+ cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
50
+ compress: true,
51
+ viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
52
+ };
53
+ return {
54
+ [`${basePath}/_next/*`]: staticBehavior,
55
+ [`${basePath}/*.ico`]: staticBehavior,
56
+ [`${basePath}/*.png`]: staticBehavior,
57
+ [`${basePath}/*.svg`]: staticBehavior,
58
+ [`${basePath}/*.jpg`]: staticBehavior,
59
+ [`${basePath}/*.jpeg`]: staticBehavior,
60
+ };
61
+ }
62
+ function serverCloudfrontBehaviour(app, serverOrigin, basePath) {
63
+ const imageCachePolicy = new cloudfront.CachePolicy(app, 'ImagePolicy', {
64
+ queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
65
+ maxTtl: cdk.Duration.days(365),
66
+ enableAcceptEncodingGzip: true,
67
+ enableAcceptEncodingBrotli: true,
68
+ });
69
+ const appBehaviour = {
70
+ origin: serverOrigin,
71
+ cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
72
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
73
+ compress: true,
74
+ viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
75
+ originRequestPolicy: cloudfront.OriginRequestPolicy.ALL_VIEWER,
76
+ responseHeadersPolicy: cloudfront.ResponseHeadersPolicy
77
+ .CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS,
78
+ };
79
+ return {
80
+ [`${basePath}/*`]: appBehaviour,
81
+ [`${basePath}/_next/image`]: {
82
+ ...appBehaviour,
83
+ cachePolicy: imageCachePolicy,
84
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
85
+ },
86
+ };
87
+ }
@@ -0,0 +1,5 @@
1
+ import { Attachable } from '@fy-stack/types';
2
+ export declare function paramsFromAttachable(attachable: Record<string, Attachable>): {
3
+ [k: string]: string;
4
+ }[];
5
+ //# sourceMappingURL=params-from-attachable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-from-attachable.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/util/params-from-attachable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;IAS1E"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paramsFromAttachable = paramsFromAttachable;
4
+ function paramsFromAttachable(attachable) {
5
+ return Object.entries(attachable).map(([key, val]) => {
6
+ return Object.fromEntries(Object.entries(val?.attachable() ?? {}).map(([subKey, subVal]) => [
7
+ `${key}_${subKey}`.toUpperCase(),
8
+ subVal,
9
+ ]));
10
+ });
11
+ }
@@ -0,0 +1,25 @@
1
+ export declare enum AppType {
2
+ NODE_APP = "nodeApp",
3
+ NODE_API = "nestApi",
4
+ IMAGE_APP = "imageApp",
5
+ NEXT_APP_ROUTER = "nextAppRouter",
6
+ NEXT_PAGE_EXPORT = "nextPageExport",
7
+ STATIC_WEBSITE = "staticWebsite"
8
+ }
9
+ export type AppAttachment = {
10
+ auth?: boolean;
11
+ storage?: boolean;
12
+ database?: boolean;
13
+ secrets?: boolean;
14
+ queue?: {
15
+ batchSize?: number;
16
+ };
17
+ };
18
+ export declare enum AppGrant {
19
+ AUTH = "auth",
20
+ STORAGE = "storage",
21
+ DATABASE = "database",
22
+ SECRETS = "secrets",
23
+ EVENT = "event"
24
+ }
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/shared/util/types.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,QAAQ,YAAY;IACpB,QAAQ,YAAY;IACpB,SAAS,aAAa;IACtB,eAAe,kBAAkB;IACjC,gBAAgB,mBAAmB;IACnC,cAAc,kBAAkB;CACjC;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChC,CAAC;AAEF,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppGrant = exports.AppType = void 0;
4
+ var AppType;
5
+ (function (AppType) {
6
+ AppType["NODE_APP"] = "nodeApp";
7
+ AppType["NODE_API"] = "nestApi";
8
+ AppType["IMAGE_APP"] = "imageApp";
9
+ AppType["NEXT_APP_ROUTER"] = "nextAppRouter";
10
+ AppType["NEXT_PAGE_EXPORT"] = "nextPageExport";
11
+ AppType["STATIC_WEBSITE"] = "staticWebsite";
12
+ })(AppType || (exports.AppType = AppType = {}));
13
+ var AppGrant;
14
+ (function (AppGrant) {
15
+ AppGrant["AUTH"] = "auth";
16
+ AppGrant["STORAGE"] = "storage";
17
+ AppGrant["DATABASE"] = "database";
18
+ AppGrant["SECRETS"] = "secrets";
19
+ AppGrant["EVENT"] = "event";
20
+ })(AppGrant || (exports.AppGrant = AppGrant = {}));
@@ -0,0 +1,16 @@
1
+ import type { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
2
+ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
3
+ import { Construct } from 'constructs';
4
+ import { z } from 'zod';
5
+ import { AppConstruct, AppProperties } from '../types';
6
+ declare const BuildParamsSchema: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
7
+ export declare class NextPagesExportConstruct extends Construct implements AppConstruct {
8
+ private readonly static;
9
+ constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
10
+ cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
11
+ cloudfrontPolicy(distributionId: string): void;
12
+ api(): Record<string, HttpRouteIntegration>;
13
+ static parse(params: unknown): {} | undefined;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=next-pages-export-construct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-pages-export-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/static/apps/next-pages-export-construct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,QAAA,MAAM,iBAAiB,+DAA0B,CAAC;AAElD,qBAAa,wBACX,SAAQ,SACR,YAAW,YAAY;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAGjC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAkCzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAmBpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NextPagesExportConstruct = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path = tslib_1.__importStar(require("node:path"));
6
+ const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
7
+ const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
8
+ const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
9
+ const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
10
+ const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
11
+ const constructs_1 = require("constructs");
12
+ const zod_1 = require("zod");
13
+ const BuildParamsSchema = zod_1.z.object({}).optional();
14
+ class NextPagesExportConstruct extends constructs_1.Construct {
15
+ static;
16
+ constructor(scope, id, props) {
17
+ super(scope, id);
18
+ this.static = new s3.Bucket(this, `StaticBucket`, {
19
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
20
+ autoDeleteObjects: true,
21
+ blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS_ONLY,
22
+ publicReadAccess: true,
23
+ websiteIndexDocument: 'index.html',
24
+ websiteErrorDocument: 'index.html',
25
+ cors: [
26
+ {
27
+ allowedHeaders: ['*'],
28
+ allowedOrigins: ['*'],
29
+ allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
30
+ },
31
+ ],
32
+ });
33
+ new s3Deploy.BucketDeployment(this, `StaticDeployment`, {
34
+ destinationBucket: this.static,
35
+ sources: [s3Deploy.Source.asset(path.join(props.output, '/.next'))],
36
+ retainOnDelete: false,
37
+ });
38
+ new s3Deploy.BucketDeployment(this, `PublicDeployment`, {
39
+ destinationBucket: this.static,
40
+ sources: [s3Deploy.Source.asset(path.join(props.output, '/public'))],
41
+ destinationKeyPrefix: 'public',
42
+ retainOnDelete: false,
43
+ });
44
+ }
45
+ cloudfront(path) {
46
+ const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
47
+ const staticBehavior = {
48
+ origin: staticOrigin,
49
+ cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
50
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
51
+ cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
52
+ compress: true,
53
+ viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
54
+ };
55
+ return {
56
+ [`${path}/*`]: staticBehavior,
57
+ };
58
+ }
59
+ cloudfrontPolicy(distributionId) {
60
+ throw new Error(`cloudfrontPolicy not supported for ${this}`);
61
+ }
62
+ api() {
63
+ throw new Error('api not supported for this construct');
64
+ }
65
+ static parse(params) {
66
+ return BuildParamsSchema.parse(params);
67
+ }
68
+ }
69
+ exports.NextPagesExportConstruct = NextPagesExportConstruct;
@@ -0,0 +1,16 @@
1
+ import { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
2
+ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
3
+ import { Construct } from 'constructs';
4
+ import { z } from 'zod';
5
+ import { AppConstruct, AppProperties } from '../types';
6
+ declare const BuildParamsSchema: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
7
+ export declare class StaticWebsiteConstruct extends Construct implements AppConstruct {
8
+ private readonly static;
9
+ constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
10
+ cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
11
+ cloudfrontPolicy(distributionId: string): void;
12
+ api(): Record<string, HttpRouteIntegration>;
13
+ static parse(params: unknown): {} | undefined;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=static-website-construct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-website-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/static/apps/static-website-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,QAAA,MAAM,iBAAiB,+DAA0B,CAAC;AAElD,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAC3E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAGjC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA2BzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAmBpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StaticWebsiteConstruct = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
6
+ const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
7
+ const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
8
+ const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
9
+ const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
10
+ const constructs_1 = require("constructs");
11
+ const zod_1 = require("zod");
12
+ const BuildParamsSchema = zod_1.z.object({}).optional();
13
+ class StaticWebsiteConstruct extends constructs_1.Construct {
14
+ static;
15
+ constructor(scope, id, props) {
16
+ super(scope, id);
17
+ this.static = new s3.Bucket(this, `StaticBucket`, {
18
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
19
+ autoDeleteObjects: true,
20
+ blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS_ONLY,
21
+ publicReadAccess: true,
22
+ websiteIndexDocument: 'index.html',
23
+ websiteErrorDocument: 'index.html',
24
+ cors: [
25
+ {
26
+ allowedHeaders: ['*'],
27
+ allowedOrigins: ['*'],
28
+ allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
29
+ },
30
+ ],
31
+ });
32
+ new s3Deploy.BucketDeployment(this, `StaticDeployment`, {
33
+ destinationBucket: this.static,
34
+ sources: [s3Deploy.Source.asset(props.output)],
35
+ retainOnDelete: false,
36
+ });
37
+ }
38
+ cloudfront(path) {
39
+ const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
40
+ const staticBehavior = {
41
+ origin: staticOrigin,
42
+ cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
43
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
44
+ cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
45
+ compress: true,
46
+ viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
47
+ };
48
+ return {
49
+ [`${path}/*`]: staticBehavior,
50
+ };
51
+ }
52
+ cloudfrontPolicy(distributionId) {
53
+ throw new Error(`cloudfrontPolicy not supported for ${this}`);
54
+ }
55
+ api() {
56
+ throw new Error('api not supported for this construct');
57
+ }
58
+ static parse(params) {
59
+ return BuildParamsSchema.parse(params);
60
+ }
61
+ }
62
+ exports.StaticWebsiteConstruct = StaticWebsiteConstruct;
@@ -0,0 +1,21 @@
1
+ import { Attachable, Grantable } from '@fy-stack/types';
2
+ import type { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
3
+ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
4
+ import { ITopicSubscription } from 'aws-cdk-lib/aws-sns';
5
+ import { Construct } from 'constructs';
6
+ import { z } from 'zod';
7
+ import { AppConstruct, AppProperties } from '../types';
8
+ declare const BuildParamsSchema: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
9
+ export declare class NextPagesExportConstruct extends Construct implements AppConstruct {
10
+ private readonly static;
11
+ constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
12
+ cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
13
+ cloudfrontPolicy(distributionId: string): void;
14
+ api(): Record<string, HttpRouteIntegration>;
15
+ attach(attachable: Record<string, Attachable>): void;
16
+ grant(...grants: Grantable[]): void;
17
+ subscription(): ITopicSubscription;
18
+ static parse(params: unknown): {} | undefined;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=next-pages-export-construct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next-pages-export-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/static/next-pages-export-construct.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,QAAA,MAAM,iBAAiB,+DAA0B,CAAA;AAEjD,qBAAa,wBAAyB,SAAQ,SAAU,YAAW,YAAY;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAiCjG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAmBpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,IAAI,kBAAkB;IAIlC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAE1B"}