@fy-stack/app-construct 0.0.127 → 0.0.129
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.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/image-app-construct.d.ts +1 -0
- package/dist/lib/image-app-construct.d.ts.map +1 -1
- package/dist/lib/image-app-construct.js +3 -0
- package/dist/lib/next-app-router-construct.d.ts +4 -5
- package/dist/lib/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/next-app-router-construct.js +15 -2
- package/dist/lib/next-pages-export-construct.d.ts +17 -0
- package/dist/lib/next-pages-export-construct.d.ts.map +1 -0
- package/dist/lib/next-pages-export-construct.js +73 -0
- package/dist/lib/node-api-construct.d.ts +1 -0
- package/dist/lib/node-api-construct.d.ts.map +1 -1
- package/dist/lib/node-api-construct.js +3 -0
- package/dist/lib/node-app-construct.d.ts +1 -0
- package/dist/lib/node-app-construct.d.ts.map +1 -1
- package/dist/lib/node-app-construct.js +7 -1
- package/dist/lib/react-static-construct.d.ts +17 -0
- package/dist/lib/react-static-construct.d.ts.map +1 -0
- package/dist/lib/react-static-construct.js +66 -0
- package/dist/lib/static-website-construct.d.ts +17 -0
- package/dist/lib/static-website-construct.d.ts.map +1 -0
- package/dist/lib/static-website-construct.js +66 -0
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { ImageAppConstruct } from './lib/image-app-construct';
|
|
2
2
|
export { NextAppRouterConstruct } from './lib/next-app-router-construct';
|
|
3
|
+
export { NextPagesExportConstruct } from './lib/next-pages-export-construct';
|
|
3
4
|
export { NodeApiConstruct } from './lib/node-api-construct';
|
|
4
5
|
export { NodeAppConstruct } from './lib/node-app-construct';
|
|
6
|
+
export { StaticWebsiteConstruct } from './lib/static-website-construct';
|
|
5
7
|
export type { AppConstruct, AppProperties } from "./lib/types";
|
|
6
8
|
export { lambdaAttach } from "./lib/utils/lambda-attach";
|
|
7
9
|
export { lambdaGrant } from "./lib/utils/lambda-grant";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.lambdaGrant = exports.lambdaAttach = exports.NodeAppConstruct = exports.NodeApiConstruct = exports.NextAppRouterConstruct = exports.ImageAppConstruct = void 0;
|
|
3
|
+
exports.lambdaGrant = exports.lambdaAttach = exports.StaticWebsiteConstruct = exports.NodeAppConstruct = exports.NodeApiConstruct = exports.NextPagesExportConstruct = exports.NextAppRouterConstruct = exports.ImageAppConstruct = void 0;
|
|
4
4
|
var image_app_construct_1 = require("./lib/image-app-construct");
|
|
5
5
|
Object.defineProperty(exports, "ImageAppConstruct", { enumerable: true, get: function () { return image_app_construct_1.ImageAppConstruct; } });
|
|
6
6
|
var next_app_router_construct_1 = require("./lib/next-app-router-construct");
|
|
7
7
|
Object.defineProperty(exports, "NextAppRouterConstruct", { enumerable: true, get: function () { return next_app_router_construct_1.NextAppRouterConstruct; } });
|
|
8
|
+
var next_pages_export_construct_1 = require("./lib/next-pages-export-construct");
|
|
9
|
+
Object.defineProperty(exports, "NextPagesExportConstruct", { enumerable: true, get: function () { return next_pages_export_construct_1.NextPagesExportConstruct; } });
|
|
8
10
|
var node_api_construct_1 = require("./lib/node-api-construct");
|
|
9
11
|
Object.defineProperty(exports, "NodeApiConstruct", { enumerable: true, get: function () { return node_api_construct_1.NodeApiConstruct; } });
|
|
10
12
|
var node_app_construct_1 = require("./lib/node-app-construct");
|
|
11
13
|
Object.defineProperty(exports, "NodeAppConstruct", { enumerable: true, get: function () { return node_app_construct_1.NodeAppConstruct; } });
|
|
14
|
+
var static_website_construct_1 = require("./lib/static-website-construct");
|
|
15
|
+
Object.defineProperty(exports, "StaticWebsiteConstruct", { enumerable: true, get: function () { return static_website_construct_1.StaticWebsiteConstruct; } });
|
|
12
16
|
var lambda_attach_1 = require("./lib/utils/lambda-attach");
|
|
13
17
|
Object.defineProperty(exports, "lambdaAttach", { enumerable: true, get: function () { return lambda_attach_1.lambdaAttach; } });
|
|
14
18
|
var lambda_grant_1 = require("./lib/utils/lambda-grant");
|
|
@@ -14,6 +14,7 @@ export declare class ImageAppConstruct extends Construct implements AppConstruct
|
|
|
14
14
|
grant(...grantables: Grantable[]): void;
|
|
15
15
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
16
16
|
cloudfront(path: string): Record<string, BehaviorOptions>;
|
|
17
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
17
18
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=image-app-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../src/lib/image-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAEL,QAAQ,EAIT,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAK5E,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKtD,qBAAa,iBACX,SAAQ,SACR,YAAW,YAAY;IAEhB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;gBAEpB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IA2B9D,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAIpD,KAAK,CAAC,GAAG,UAAU,EAAE,SAA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AAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAqBzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;CAGxD"}
|
|
@@ -65,6 +65,9 @@ class ImageAppConstruct extends constructs_1.Construct {
|
|
|
65
65
|
};
|
|
66
66
|
return { [`${path}/*`]: apiBehavior };
|
|
67
67
|
}
|
|
68
|
+
cloudfrontPolicy(distributionId) {
|
|
69
|
+
throw new Error("cloudfrontPolicy not implemented");
|
|
70
|
+
}
|
|
68
71
|
api(path) {
|
|
69
72
|
return (0, lambda_api_1.lambdaApi)(this.function, path);
|
|
70
73
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Attachable, Grantable } from '@fy-stack/types';
|
|
2
|
-
import * as cdk from 'aws-cdk-lib';
|
|
3
2
|
import type { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
3
|
+
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
4
4
|
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
5
5
|
import { ITopicSubscription } from 'aws-cdk-lib/aws-sns';
|
|
6
6
|
import * as sqs from 'aws-cdk-lib/aws-sqs';
|
|
@@ -11,10 +11,9 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
|
|
|
11
11
|
queue: sqs.Queue | undefined;
|
|
12
12
|
private readonly static;
|
|
13
13
|
constructor(scope: Construct, id: string, props: AppProperties);
|
|
14
|
-
cloudfront(path: string):
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
api(path: string): Record<string, HttpRouteIntegration>;
|
|
14
|
+
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
15
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
16
|
+
api(): Record<string, HttpRouteIntegration>;
|
|
18
17
|
attach(attachable: Record<string, Attachable>): void;
|
|
19
18
|
grant(...grants: Grantable[]): void;
|
|
20
19
|
subscription(): ITopicSubscription;
|
|
@@ -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;
|
|
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;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAItD,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;IAiE9D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAmDpE,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;CAGnC"}
|
|
@@ -84,6 +84,12 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
84
84
|
compress: true,
|
|
85
85
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
86
86
|
};
|
|
87
|
+
const imageCachePolicy = new cloudfront.CachePolicy(this, "ImagePolicy", {
|
|
88
|
+
queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
|
|
89
|
+
maxTtl: cdk.Duration.days(365),
|
|
90
|
+
enableAcceptEncodingGzip: true,
|
|
91
|
+
enableAcceptEncodingBrotli: true
|
|
92
|
+
});
|
|
87
93
|
const appBehaviour = {
|
|
88
94
|
origin: serverOrigin,
|
|
89
95
|
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
|
|
@@ -96,12 +102,19 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
96
102
|
};
|
|
97
103
|
return {
|
|
98
104
|
[`${path}/*`]: appBehaviour,
|
|
99
|
-
[`${path}/_next/image
|
|
105
|
+
[`${path}/_next/image`]: {
|
|
106
|
+
...appBehaviour,
|
|
107
|
+
cachePolicy: imageCachePolicy,
|
|
108
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
|
|
109
|
+
},
|
|
100
110
|
[`${path}/_next/*`]: staticBehavior,
|
|
101
111
|
[`${path}/*.ico`]: staticBehavior,
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
|
-
|
|
114
|
+
cloudfrontPolicy(distributionId) {
|
|
115
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
116
|
+
}
|
|
117
|
+
api() {
|
|
105
118
|
throw new Error('api not supported for this construct');
|
|
106
119
|
}
|
|
107
120
|
attach(attachable) {
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { AppConstruct, AppProperties } from './types';
|
|
7
|
+
export declare class NextPagesExportConstruct extends Construct implements AppConstruct {
|
|
8
|
+
private readonly static;
|
|
9
|
+
constructor(scope: Construct, id: string, props: AppProperties);
|
|
10
|
+
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
11
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
12
|
+
api(): Record<string, HttpRouteIntegration>;
|
|
13
|
+
attach(attachable: Record<string, Attachable>): void;
|
|
14
|
+
grant(...grants: Grantable[]): void;
|
|
15
|
+
subscription(): ITopicSubscription;
|
|
16
|
+
}
|
|
17
|
+
//# 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/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;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEtD,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;IAiC9D,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;CAGnC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
class NextPagesExportConstruct extends constructs_1.Construct {
|
|
13
|
+
static;
|
|
14
|
+
constructor(scope, id, props) {
|
|
15
|
+
super(scope, id);
|
|
16
|
+
this.static = new s3.Bucket(this, `StaticBucket`, {
|
|
17
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
18
|
+
autoDeleteObjects: true,
|
|
19
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS,
|
|
20
|
+
publicReadAccess: true,
|
|
21
|
+
websiteIndexDocument: 'index.html',
|
|
22
|
+
websiteErrorDocument: 'index.html',
|
|
23
|
+
cors: [
|
|
24
|
+
{
|
|
25
|
+
allowedHeaders: ['*'],
|
|
26
|
+
allowedOrigins: ['*'],
|
|
27
|
+
allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
new s3Deploy.BucketDeployment(this, `StaticDeployment`, {
|
|
32
|
+
destinationBucket: this.static,
|
|
33
|
+
sources: [s3Deploy.Source.asset(path.join(props.output, "/.next")),],
|
|
34
|
+
retainOnDelete: false,
|
|
35
|
+
});
|
|
36
|
+
new s3Deploy.BucketDeployment(this, `PublicDeployment`, {
|
|
37
|
+
destinationBucket: this.static,
|
|
38
|
+
sources: [s3Deploy.Source.asset(path.join(props.output, "/public"))],
|
|
39
|
+
destinationKeyPrefix: "public",
|
|
40
|
+
retainOnDelete: false,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
cloudfront(path) {
|
|
44
|
+
const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
|
|
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
|
+
[`${path}/*`]: staticBehavior,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
cloudfrontPolicy(distributionId) {
|
|
58
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
59
|
+
}
|
|
60
|
+
api() {
|
|
61
|
+
throw new Error('api not supported for this construct');
|
|
62
|
+
}
|
|
63
|
+
attach(attachable) {
|
|
64
|
+
throw new Error('attach not supported for this construct');
|
|
65
|
+
}
|
|
66
|
+
grant(...grants) {
|
|
67
|
+
throw new Error('grant not supported for this construct');
|
|
68
|
+
}
|
|
69
|
+
subscription() {
|
|
70
|
+
throw new Error(`subscription not supported for ${this}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.NextPagesExportConstruct = NextPagesExportConstruct;
|
|
@@ -23,6 +23,7 @@ export declare class NodeApiConstruct extends Construct implements AppConstruct
|
|
|
23
23
|
responseHeadersPolicy: cdk.aws_cloudfront.IResponseHeadersPolicy;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
26
27
|
api(path: string): {
|
|
27
28
|
[x: string]: cdk.aws_apigatewayv2_integrations.HttpUrlIntegration;
|
|
28
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-api-construct.d.ts","sourceRoot":"","sources":["../../src/lib/node-api-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAGnC,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKtD,qBAAa,gBAAiB,SAAQ,SAAU,YAAW,YAAY;IAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBAExB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAA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AM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM;;;CAGjB"}
|
|
@@ -76,6 +76,9 @@ class NodeApiConstruct extends constructs_1.Construct {
|
|
|
76
76
|
};
|
|
77
77
|
return { [`${path}/*`]: apiBehavior };
|
|
78
78
|
}
|
|
79
|
+
cloudfrontPolicy(distributionId) {
|
|
80
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
81
|
+
}
|
|
79
82
|
api(path) {
|
|
80
83
|
return (0, lambda_api_1.lambdaApi)(this.function, path);
|
|
81
84
|
}
|
|
@@ -14,6 +14,7 @@ export declare class NodeAppConstruct extends Construct implements AppConstruct
|
|
|
14
14
|
grant(...grants: Grantable[]): void;
|
|
15
15
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
16
16
|
cloudfront(path: string): Record<string, BehaviorOptions>;
|
|
17
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
17
18
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
18
19
|
}
|
|
19
20
|
//# sourceMappingURL=node-app-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../src/lib/node-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../src/lib/node-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAKtD,qBAAa,gBAAiB,SAAQ,SAAU,YAAW,YAAY;IAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBAExB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IA8B9D,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAI7C,KAAK,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE;IAI5B,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB;IAO1D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAIzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;CAUxD"}
|
|
@@ -11,6 +11,7 @@ const sqs = tslib_1.__importStar(require("aws-cdk-lib/aws-sqs"));
|
|
|
11
11
|
const constructs_1 = require("constructs");
|
|
12
12
|
const lambda_attach_1 = require("./utils/lambda-attach");
|
|
13
13
|
const lambda_grant_1 = require("./utils/lambda-grant");
|
|
14
|
+
const aws_apigatewayv2_integrations_1 = require("aws-cdk-lib/aws-apigatewayv2-integrations");
|
|
14
15
|
class NodeAppConstruct extends constructs_1.Construct {
|
|
15
16
|
function;
|
|
16
17
|
queue;
|
|
@@ -50,8 +51,13 @@ class NodeAppConstruct extends constructs_1.Construct {
|
|
|
50
51
|
cloudfront(path) {
|
|
51
52
|
throw new Error(`cloudfront not supported for ${this}`);
|
|
52
53
|
}
|
|
54
|
+
cloudfrontPolicy(distributionId) {
|
|
55
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
56
|
+
}
|
|
53
57
|
api(path) {
|
|
54
|
-
|
|
58
|
+
this.function.addEnvironment('BASE_PATH', path);
|
|
59
|
+
const integration = new aws_apigatewayv2_integrations_1.HttpLambdaIntegration('AppIntegration', this.function);
|
|
60
|
+
return { [`${path}/*`]: integration };
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
exports.NodeAppConstruct = NodeAppConstruct;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppConstruct, AppProperties } from './types';
|
|
2
|
+
import { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
3
|
+
import { Attachable, Grantable } from '@fy-stack/types';
|
|
4
|
+
import { ITopicSubscription } from 'aws-cdk-lib/aws-sns';
|
|
5
|
+
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
6
|
+
import { Construct } from 'constructs';
|
|
7
|
+
export declare class ReactStaticConstruct extends Construct implements AppConstruct {
|
|
8
|
+
private readonly static;
|
|
9
|
+
constructor(scope: Construct, id: string, props: AppProperties);
|
|
10
|
+
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
11
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
12
|
+
api(): Record<string, HttpRouteIntegration>;
|
|
13
|
+
attach(attachable: Record<string, Attachable>): void;
|
|
14
|
+
grant(...grants: Grantable[]): void;
|
|
15
|
+
subscription(): ITopicSubscription;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=react-static-construct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-static-construct.d.ts","sourceRoot":"","sources":["../../src/lib/react-static-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,qBAAa,oBAAqB,SAAQ,SAAU,YAAW,YAAY;IACzE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IA0B9D,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;CAGnC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReactStaticConstruct = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
|
|
6
|
+
const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
|
|
7
|
+
const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
|
|
8
|
+
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
9
|
+
const constructs_1 = require("constructs");
|
|
10
|
+
const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
|
|
11
|
+
class ReactStaticConstruct extends constructs_1.Construct {
|
|
12
|
+
static;
|
|
13
|
+
constructor(scope, id, props) {
|
|
14
|
+
super(scope, id);
|
|
15
|
+
this.static = new s3.Bucket(this, `StaticBucket`, {
|
|
16
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
17
|
+
autoDeleteObjects: true,
|
|
18
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS,
|
|
19
|
+
publicReadAccess: true,
|
|
20
|
+
websiteIndexDocument: 'index.html',
|
|
21
|
+
websiteErrorDocument: 'index.html',
|
|
22
|
+
cors: [
|
|
23
|
+
{
|
|
24
|
+
allowedHeaders: ['*'],
|
|
25
|
+
allowedOrigins: ['*'],
|
|
26
|
+
allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
new s3Deploy.BucketDeployment(this, `StaticDeployment`, {
|
|
31
|
+
destinationBucket: this.static,
|
|
32
|
+
sources: [s3Deploy.Source.asset(props.output),],
|
|
33
|
+
retainOnDelete: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
cloudfront(path) {
|
|
37
|
+
const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
|
|
38
|
+
const staticBehavior = {
|
|
39
|
+
origin: staticOrigin,
|
|
40
|
+
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
|
|
41
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
|
|
42
|
+
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
|
|
43
|
+
compress: true,
|
|
44
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
[`${path}/*`]: staticBehavior,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
cloudfrontPolicy(distributionId) {
|
|
51
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
52
|
+
}
|
|
53
|
+
api() {
|
|
54
|
+
throw new Error('api not supported for this construct');
|
|
55
|
+
}
|
|
56
|
+
attach(attachable) {
|
|
57
|
+
throw new Error('attach not supported for this construct');
|
|
58
|
+
}
|
|
59
|
+
grant(...grants) {
|
|
60
|
+
throw new Error('grant not supported for this construct');
|
|
61
|
+
}
|
|
62
|
+
subscription() {
|
|
63
|
+
throw new Error(`subscription not supported for ${this}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ReactStaticConstruct = ReactStaticConstruct;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppConstruct, AppProperties } from './types';
|
|
2
|
+
import { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
3
|
+
import { Attachable, Grantable } from '@fy-stack/types';
|
|
4
|
+
import { ITopicSubscription } from 'aws-cdk-lib/aws-sns';
|
|
5
|
+
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
6
|
+
import { Construct } from 'constructs';
|
|
7
|
+
export declare class StaticWebsiteConstruct extends Construct implements AppConstruct {
|
|
8
|
+
private readonly static;
|
|
9
|
+
constructor(scope: Construct, id: string, props: AppProperties);
|
|
10
|
+
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
11
|
+
cloudfrontPolicy(distributionId: string): void;
|
|
12
|
+
api(): Record<string, HttpRouteIntegration>;
|
|
13
|
+
attach(attachable: Record<string, Attachable>): void;
|
|
14
|
+
grant(...grants: Grantable[]): void;
|
|
15
|
+
subscription(): ITopicSubscription;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=static-website-construct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-website-construct.d.ts","sourceRoot":"","sources":["../../src/lib/static-website-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAC3E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa;IA0B9D,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;CAGnC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StaticWebsiteConstruct = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cloudfront = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront"));
|
|
6
|
+
const cloudfrontOrigin = tslib_1.__importStar(require("aws-cdk-lib/aws-cloudfront-origins"));
|
|
7
|
+
const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
|
|
8
|
+
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
9
|
+
const constructs_1 = require("constructs");
|
|
10
|
+
const cdk = tslib_1.__importStar(require("aws-cdk-lib"));
|
|
11
|
+
class StaticWebsiteConstruct extends constructs_1.Construct {
|
|
12
|
+
static;
|
|
13
|
+
constructor(scope, id, props) {
|
|
14
|
+
super(scope, id);
|
|
15
|
+
this.static = new s3.Bucket(this, `StaticBucket`, {
|
|
16
|
+
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
17
|
+
autoDeleteObjects: true,
|
|
18
|
+
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS,
|
|
19
|
+
publicReadAccess: true,
|
|
20
|
+
websiteIndexDocument: 'index.html',
|
|
21
|
+
websiteErrorDocument: 'index.html',
|
|
22
|
+
cors: [
|
|
23
|
+
{
|
|
24
|
+
allowedHeaders: ['*'],
|
|
25
|
+
allowedOrigins: ['*'],
|
|
26
|
+
allowedMethods: [s3.HttpMethods.GET, s3.HttpMethods.HEAD],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
new s3Deploy.BucketDeployment(this, `StaticDeployment`, {
|
|
31
|
+
destinationBucket: this.static,
|
|
32
|
+
sources: [s3Deploy.Source.asset(props.output),],
|
|
33
|
+
retainOnDelete: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
cloudfront(path) {
|
|
37
|
+
const staticOrigin = new cloudfrontOrigin.S3StaticWebsiteOrigin(this.static);
|
|
38
|
+
const staticBehavior = {
|
|
39
|
+
origin: staticOrigin,
|
|
40
|
+
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
|
|
41
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
|
|
42
|
+
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
|
|
43
|
+
compress: true,
|
|
44
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
[`${path}/*`]: staticBehavior,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
cloudfrontPolicy(distributionId) {
|
|
51
|
+
throw new Error(`cloudfrontPolicy not supported for ${this}`);
|
|
52
|
+
}
|
|
53
|
+
api() {
|
|
54
|
+
throw new Error('api not supported for this construct');
|
|
55
|
+
}
|
|
56
|
+
attach(attachable) {
|
|
57
|
+
throw new Error('attach not supported for this construct');
|
|
58
|
+
}
|
|
59
|
+
grant(...grants) {
|
|
60
|
+
throw new Error('grant not supported for this construct');
|
|
61
|
+
}
|
|
62
|
+
subscription() {
|
|
63
|
+
throw new Error(`subscription not supported for ${this}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.StaticWebsiteConstruct = StaticWebsiteConstruct;
|
package/dist/lib/types.d.ts
CHANGED
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,GA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