@fy-stack/app-construct 0.0.145 → 0.0.147-0-preview
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/lib/ecs/apps/image-app-construct.d.ts.map +1 -1
- package/dist/lib/ecs/apps/image-app-construct.js +1 -8
- package/dist/lib/ecs/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/ecs/apps/next-app-router-construct.js +1 -8
- package/dist/lib/ecs/apps/task-construct.d.ts.map +1 -1
- package/dist/lib/ecs/apps/task-construct.js +2 -1
- package/dist/lib/ecs/ecs-construct.d.ts.map +1 -1
- package/dist/lib/ecs/ecs-construct.js +3 -0
- package/dist/lib/ecs/ecs-server-construct.d.ts +3 -0
- package/dist/lib/ecs/ecs-server-construct.d.ts.map +1 -1
- package/dist/lib/ecs/ecs-server-construct.js +4 -2
- package/dist/lib/ecs/shared/taskDefinitionImage.d.ts +3 -2
- package/dist/lib/ecs/shared/taskDefinitionImage.d.ts.map +1 -1
- package/dist/lib/ecs/shared/taskDefinitionImage.js +2 -1
- package/dist/lib/ecs/types.d.ts +5 -1
- package/dist/lib/ecs/types.d.ts.map +1 -1
- package/dist/lib/lambda/apps/image-app-construct.d.ts +10 -10
- package/dist/lib/lambda/apps/image-app-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/image-app-construct.js +11 -5
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts +8 -8
- package/dist/lib/lambda/apps/next-app-router-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/next-app-router-construct.js +8 -9
- package/dist/lib/lambda/apps/node-api-construct.d.ts +8 -8
- package/dist/lib/lambda/apps/node-api-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/node-api-construct.js +14 -15
- package/dist/lib/lambda/apps/node-app-construct.d.ts +8 -8
- package/dist/lib/lambda/apps/node-app-construct.d.ts.map +1 -1
- package/dist/lib/lambda/apps/node-app-construct.js +21 -20
- package/dist/lib/lambda/lambda-construct.d.ts.map +1 -1
- package/dist/lib/lambda/lambda-construct.js +1 -0
- package/dist/lib/lambda/types.d.ts +8 -11
- package/dist/lib/lambda/types.d.ts.map +1 -1
- package/dist/lib/lambda/utils/getDefaultLambda.d.ts +3 -6
- package/dist/lib/lambda/utils/getDefaultLambda.d.ts.map +1 -1
- package/dist/lib/lambda/utils/getDefaultLambda.js +7 -2
- package/dist/lib/shared/next-app-router.d.ts.map +1 -1
- package/dist/lib/shared/next-app-router.js +6 -11
- package/dist/lib/static/apps/static-website-construct.d.ts +11 -2
- package/dist/lib/static/apps/static-website-construct.d.ts.map +1 -1
- package/dist/lib/static/apps/static-website-construct.js +45 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/image-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,YAAY;IAMpE,OAAO,CAAC,KAAK;IALR,SAAS,EAAE,GAAG,CAAC,mBAAmB,CAAC;gBAGxC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/image-app-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,YAAY;IAMpE,OAAO,CAAC,KAAK;IALR,SAAS,EAAE,GAAG,CAAC,mBAAmB,CAAC;gBAGxC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC;IAMvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAOpD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAyBzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAIvD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
|
|
@@ -11,14 +11,7 @@ class ImageAppConstruct extends constructs_1.Construct {
|
|
|
11
11
|
constructor(scope, id, props) {
|
|
12
12
|
super(scope, id);
|
|
13
13
|
this.props = props;
|
|
14
|
-
this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`,
|
|
15
|
-
taskDefinition: props.taskDefinition,
|
|
16
|
-
port: props.port,
|
|
17
|
-
env: props.env,
|
|
18
|
-
output: props.output,
|
|
19
|
-
container: props.container,
|
|
20
|
-
environmentPath: props.environmentPath,
|
|
21
|
-
});
|
|
14
|
+
this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`, props);
|
|
22
15
|
}
|
|
23
16
|
attach(attachable) {
|
|
24
17
|
const params = Object.assign({}, ...(0, params_from_attachable_1.paramsFromAttachable)(attachable));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AASvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,KAAK,kBAAkB,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAEjD,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAOjC,OAAO,CAAC,KAAK;IANhD,SAAS,EAAE,GAAG,CAAC,mBAAmB,CAAC;IACnC,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAU,KAAK,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/next-app-router-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AASvC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvD,KAAK,kBAAkB,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;AAEjD,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAOjC,OAAO,CAAC,KAAK;IANhD,SAAS,EAAE,GAAG,CAAC,mBAAmB,CAAC;IACnC,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAU,KAAK,EAAE,kBAAkB;IAS3E,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAcpE,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;IAO7C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
|
|
@@ -17,14 +17,7 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
17
17
|
const deployment = (0, next_app_router_1.staticDeployment)(this, props.output);
|
|
18
18
|
this.static = deployment.staticBucket;
|
|
19
19
|
this.files = deployment.files;
|
|
20
|
-
this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`,
|
|
21
|
-
taskDefinition: props.taskDefinition,
|
|
22
|
-
port: props.port,
|
|
23
|
-
env: props.env,
|
|
24
|
-
output: props.output,
|
|
25
|
-
container: props.container,
|
|
26
|
-
environmentPath: props.environmentPath,
|
|
27
|
-
});
|
|
20
|
+
this.container = (0, taskDefinitionImage_1.taskDefinitionImage)(`${props.appName}AppContainer`, props);
|
|
28
21
|
}
|
|
29
22
|
cloudfront(path) {
|
|
30
23
|
const { origin, basePath } = this.props.serverOrigin(this.props.port, this.container.containerName, path, '/');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/task-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAI3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,aACX,SAAQ,SACR,YAAW,aAAa,EAAE,KAAK,EAAE,MAAM;IAOrC,OAAO,CAAC,KAAK;IALR,UAAU,EAAE,GAAG,CAAC,qBAAqB,CAAC;gBAG3C,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"task-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/apps/task-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,EACL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAI3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,eAAe,MAAM,mCAAmC,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,aACX,SAAQ,SACR,YAAW,aAAa,EAAE,KAAK,EAAE,MAAM;IAOrC,OAAO,CAAC,KAAK;IALR,UAAU,EAAE,GAAG,CAAC,qBAAqB,CAAC;gBAG3C,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,mBAAmB;IAiCpC,YAAY,CACV,KAAK,EAAE,eAAe,CAAC,iBAAiB,GACvC,GAAG,CAAC,kBAAkB;IA6CzB,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IAS7C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;CAG7B"}
|
|
@@ -34,8 +34,9 @@ class TaskConstruct extends constructs_1.Construct {
|
|
|
34
34
|
...imageProps,
|
|
35
35
|
}),
|
|
36
36
|
logging: new ecs.AwsLogDriver({
|
|
37
|
-
streamPrefix: `${
|
|
37
|
+
streamPrefix: `${props.taskName}TaskContainer`,
|
|
38
38
|
logRetention: logDuration ?? logs.RetentionDays.ONE_DAY,
|
|
39
|
+
logGroup: props.logGroup,
|
|
39
40
|
}),
|
|
40
41
|
...containerProps,
|
|
41
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecs-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,YAAa,SAAQ,SAAS;IAClC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAM;gBAErC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB;
|
|
1
|
+
{"version":3,"file":"ecs-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,qBAAa,YAAa,SAAQ,SAAS;IAClC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAM;gBAErC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB;CAwCnE"}
|
|
@@ -18,6 +18,7 @@ class EcsConstruct extends constructs_1.Construct {
|
|
|
18
18
|
if (props.server) {
|
|
19
19
|
this.server = new ecs_server_construct_1.EcsServerConstruct(this, 'Server', {
|
|
20
20
|
...props.server,
|
|
21
|
+
logGroup: props.logGroup,
|
|
21
22
|
cluster: appCluster,
|
|
22
23
|
environmentPath: props.environmentPath,
|
|
23
24
|
environment: props.environment,
|
|
@@ -29,6 +30,8 @@ class EcsConstruct extends constructs_1.Construct {
|
|
|
29
30
|
return [
|
|
30
31
|
key,
|
|
31
32
|
new task_construct_1.TaskConstruct(this, `${key}Task`, {
|
|
33
|
+
logGroup: props.logGroup,
|
|
34
|
+
taskName: key,
|
|
32
35
|
buildParams: task_construct_1.TaskConstruct.parse(app.buildParams ?? {}),
|
|
33
36
|
cluster: appCluster,
|
|
34
37
|
vpc: props.vpc,
|
|
@@ -2,10 +2,12 @@ import { Grant, Grantable } from '@fy-stack/types';
|
|
|
2
2
|
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
3
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
4
4
|
import * as elbV2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
5
|
+
import type { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
5
6
|
import { Construct } from 'constructs';
|
|
6
7
|
import { AppConstruct, EcsConstructProps } from './types';
|
|
7
8
|
type EcsServerConstructProps = EcsConstructProps['server'] & {
|
|
8
9
|
vpc: ec2.IVpc;
|
|
10
|
+
logGroup: LogGroup;
|
|
9
11
|
environmentPath: string;
|
|
10
12
|
environment: string;
|
|
11
13
|
cluster: ecs.Cluster;
|
|
@@ -14,6 +16,7 @@ export declare class EcsServerConstruct extends Construct implements Grant {
|
|
|
14
16
|
private props;
|
|
15
17
|
apps: Record<string, AppConstruct>;
|
|
16
18
|
definition: ecs.TaskDefinition;
|
|
19
|
+
service: ecs.BaseService;
|
|
17
20
|
loadBalancer?: {
|
|
18
21
|
alb: elbV2.IApplicationLoadBalancer;
|
|
19
22
|
listener: elbV2.IApplicationListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecs-server-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-server-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO1D,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG;IAC3D,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,KAAK;
|
|
1
|
+
{"version":3,"file":"ecs-server-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/ecs-server-construct.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,KAAK,EAAE,SAAS,EAAgB,MAAM,iBAAiB,CAAC;AAG1E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,wCAAwC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAO1D,KAAK,uBAAuB,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GAAG;IAC3D,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,SAAU,YAAW,KAAK;IAa9D,OAAO,CAAC,KAAK;IAZR,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;IACxC,UAAU,EAAE,GAAG,CAAC,cAAc,CAAC;IAC/B,OAAO,EAAE,GAAG,CAAC,WAAW,CAAC;IAEzB,YAAY,CAAC,EAAE;QACpB,GAAG,EAAE,KAAK,CAAC,wBAAwB,CAAC;QACpC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,CAAC;KACtC,CAAC;gBAGA,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,uBAAuB;IAwExC,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAMvC,OAAO,CAAC,YAAY;IA8CpB,gBAAgB;;;;IAuChB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CA+CxC"}
|
|
@@ -21,6 +21,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
21
21
|
props;
|
|
22
22
|
apps = {};
|
|
23
23
|
definition;
|
|
24
|
+
service;
|
|
24
25
|
loadBalancer;
|
|
25
26
|
constructor(scope, id, props) {
|
|
26
27
|
super(scope, id);
|
|
@@ -38,7 +39,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
38
39
|
},
|
|
39
40
|
...(definition ?? {}),
|
|
40
41
|
});
|
|
41
|
-
|
|
42
|
+
this.service = new ecs.FargateService(this, 'ServerService', {
|
|
42
43
|
cluster,
|
|
43
44
|
taskDefinition: this.definition,
|
|
44
45
|
capacityProviderStrategies: [{ capacityProvider: 'FARGATE', weight: 1 }],
|
|
@@ -52,7 +53,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
52
53
|
propagateTags: ecs.PropagatedTagSource.SERVICE,
|
|
53
54
|
...serverProps,
|
|
54
55
|
});
|
|
55
|
-
const serverOrigin = (port, containerName, appPath, healthPath) => this.serverOrigin(service, port, containerName, appPath, healthPath);
|
|
56
|
+
const serverOrigin = (port, containerName, appPath, healthPath) => this.serverOrigin(this.service, port, containerName, appPath, healthPath);
|
|
56
57
|
serverOrigin.bind(this);
|
|
57
58
|
Object.assign(this.apps, Object.fromEntries(Object.entries(apps).map(([key, app]) => {
|
|
58
59
|
const AppTypeConstruct = AppBuilds[app.type];
|
|
@@ -60,6 +61,7 @@ class EcsServerConstruct extends constructs_1.Construct {
|
|
|
60
61
|
key,
|
|
61
62
|
new AppTypeConstruct(this, `${key}App`, {
|
|
62
63
|
appName: key,
|
|
64
|
+
logGroup: props.logGroup,
|
|
63
65
|
environmentPath: props.environmentPath,
|
|
64
66
|
buildParams: AppTypeConstruct.parse(app.buildParams ?? {}),
|
|
65
67
|
serverOrigin,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as ecs from 'aws-cdk-lib/aws-ecs';
|
|
2
|
-
import {
|
|
2
|
+
import type { LogGroup } from 'aws-cdk-lib/aws-logs';
|
|
3
|
+
import type { AppProperties } from '../types';
|
|
3
4
|
type Props = {
|
|
4
5
|
output: string;
|
|
6
|
+
logGroup: LogGroup;
|
|
5
7
|
taskDefinition: ecs.TaskDefinition;
|
|
6
8
|
env?: Record<string, string>;
|
|
7
9
|
port: number;
|
|
8
10
|
container?: AppProperties['container'];
|
|
9
|
-
environmentPath: string;
|
|
10
11
|
};
|
|
11
12
|
export declare function taskDefinitionImage(id: string, props: Props): ecs.ContainerDefinition;
|
|
12
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskDefinitionImage.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/shared/taskDefinitionImage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"taskDefinitionImage.d.ts","sourceRoot":"","sources":["../../../../src/lib/ecs/shared/taskDefinitionImage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,GAAG,CAAC,cAAc,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,2BAoB3D"}
|
|
@@ -14,8 +14,9 @@ function taskDefinitionImage(id, props) {
|
|
|
14
14
|
...(image ?? {}),
|
|
15
15
|
}),
|
|
16
16
|
logging: new ecs.AwsLogDriver({
|
|
17
|
-
streamPrefix:
|
|
17
|
+
streamPrefix: id,
|
|
18
18
|
logRetention: logDuration ?? logs.RetentionDays.ONE_DAY,
|
|
19
|
+
logGroup: props.logGroup,
|
|
19
20
|
}),
|
|
20
21
|
environment: {
|
|
21
22
|
...(props.env ?? {}),
|
package/dist/lib/ecs/types.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { LoadBalancerV2Origin } from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
|
4
4
|
import type { IVpc } from 'aws-cdk-lib/aws-ec2';
|
|
5
5
|
import type { AssetImageProps, Cluster, ContainerDefinitionOptions, FargateServiceProps, FargateTaskDefinitionProps, TaskDefinition } from 'aws-cdk-lib/aws-ecs';
|
|
6
6
|
import type { ApplicationLoadBalancerProps } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
|
|
7
|
-
import type { RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
7
|
+
import type { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
|
|
8
8
|
export type EcsConstructProps = {
|
|
9
|
+
logGroup: LogGroup;
|
|
9
10
|
environmentPath: string;
|
|
10
11
|
environment: string;
|
|
11
12
|
vpc: IVpc;
|
|
@@ -59,6 +60,7 @@ export type TaskApp = {
|
|
|
59
60
|
export type AppProperties<BuildParams = Record<string, unknown>> = {
|
|
60
61
|
appName: string;
|
|
61
62
|
environmentPath: string;
|
|
63
|
+
logGroup: LogGroup;
|
|
62
64
|
taskDefinition: TaskDefinition;
|
|
63
65
|
env?: Record<string, string>;
|
|
64
66
|
buildParams: BuildParams;
|
|
@@ -75,6 +77,8 @@ export type AppProperties<BuildParams = Record<string, unknown>> = {
|
|
|
75
77
|
};
|
|
76
78
|
export type TaskConstructsProps = FargateTaskDefinitionProps & {
|
|
77
79
|
vpc: IVpc;
|
|
80
|
+
logGroup: LogGroup;
|
|
81
|
+
taskName: string;
|
|
78
82
|
cluster: Cluster;
|
|
79
83
|
env?: Record<string, string>;
|
|
80
84
|
/** Directory of build output to be deployed */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EACV,eAAe,EACf,OAAO,EACP,0BAA0B,EAC1B,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/ecs/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Attachable, Grantable } from '@fy-stack/types';
|
|
2
2
|
import type { HttpRouteIntegration } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
3
3
|
import { BehaviorOptions } from 'aws-cdk-lib/aws-cloudfront';
|
|
4
|
-
import {
|
|
4
|
+
import { Function } from 'aws-cdk-lib/aws-lambda';
|
|
5
5
|
import { ITopicSubscription, SubscriptionProps } from 'aws-cdk-lib/aws-sns';
|
|
6
6
|
import { Queue } from 'aws-cdk-lib/aws-sqs';
|
|
7
7
|
import { Construct } from 'constructs';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { AppConstruct, AppProperties } from '../types';
|
|
10
10
|
declare const BuildParamsSchema: z.ZodObject<{
|
|
11
|
-
container: z.ZodObject<{
|
|
11
|
+
container: z.ZodOptional<z.ZodObject<{
|
|
12
12
|
file: z.ZodOptional<z.ZodString>;
|
|
13
13
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
14
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
@@ -17,9 +17,9 @@ declare const BuildParamsSchema: z.ZodObject<{
|
|
|
17
17
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
18
18
|
file: z.ZodOptional<z.ZodString>;
|
|
19
19
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
-
}, z.ZodTypeAny, "passthrough"
|
|
20
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
21
21
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
22
|
-
container: z.ZodObject<{
|
|
22
|
+
container: z.ZodOptional<z.ZodObject<{
|
|
23
23
|
file: z.ZodOptional<z.ZodString>;
|
|
24
24
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
25
25
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
@@ -28,9 +28,9 @@ declare const BuildParamsSchema: z.ZodObject<{
|
|
|
28
28
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
29
29
|
file: z.ZodOptional<z.ZodString>;
|
|
30
30
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
-
}, z.ZodTypeAny, "passthrough"
|
|
31
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
32
32
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
33
|
-
container: z.ZodObject<{
|
|
33
|
+
container: z.ZodOptional<z.ZodObject<{
|
|
34
34
|
file: z.ZodOptional<z.ZodString>;
|
|
35
35
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
36
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
@@ -39,12 +39,12 @@ declare const BuildParamsSchema: z.ZodObject<{
|
|
|
39
39
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
40
40
|
file: z.ZodOptional<z.ZodString>;
|
|
41
41
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
-
}, z.ZodTypeAny, "passthrough"
|
|
42
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
43
43
|
}, z.ZodTypeAny, "passthrough">>;
|
|
44
44
|
export declare class ImageAppConstruct extends Construct implements AppConstruct {
|
|
45
45
|
function: Function;
|
|
46
46
|
queue: Queue | undefined;
|
|
47
|
-
constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema
|
|
47
|
+
constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
|
|
48
48
|
attach(attachable: Record<string, Attachable>): void;
|
|
49
49
|
grant(...grantables: Grantable[]): void;
|
|
50
50
|
subscription(props: SubscriptionProps): ITopicSubscription;
|
|
@@ -52,7 +52,7 @@ export declare class ImageAppConstruct extends Construct implements AppConstruct
|
|
|
52
52
|
cloudfrontPolicy(distributionId: string): void;
|
|
53
53
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
54
54
|
static parse(params: unknown): z.objectOutputType<{
|
|
55
|
-
container: z.ZodObject<{
|
|
55
|
+
container: z.ZodOptional<z.ZodObject<{
|
|
56
56
|
file: z.ZodOptional<z.ZodString>;
|
|
57
57
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
58
58
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
@@ -61,7 +61,7 @@ export declare class ImageAppConstruct extends Construct implements AppConstruct
|
|
|
61
61
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
62
62
|
file: z.ZodOptional<z.ZodString>;
|
|
63
63
|
cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
64
|
-
}, z.ZodTypeAny, "passthrough"
|
|
64
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
65
65
|
}, z.ZodTypeAny, "passthrough">;
|
|
66
66
|
}
|
|
67
67
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/image-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,EAEL,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,
|
|
1
|
+
{"version":3,"file":"image-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/image-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,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;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMvD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAUP,CAAC;AAEjB,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,YAAY;IAC/D,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;gBAG9B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAmCzD,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAIpD,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAIvC,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB;IAW1D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAqBzD,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAIvD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;;;;;;;;;;CAG7B"}
|
|
@@ -22,7 +22,8 @@ const BuildParamsSchema = zod_1.z
|
|
|
22
22
|
file: zod_1.z.string().optional(),
|
|
23
23
|
cmd: zod_1.z.string().array().optional(),
|
|
24
24
|
})
|
|
25
|
-
.passthrough()
|
|
25
|
+
.passthrough()
|
|
26
|
+
.optional(),
|
|
26
27
|
})
|
|
27
28
|
.passthrough();
|
|
28
29
|
class ImageAppConstruct extends constructs_1.Construct {
|
|
@@ -30,21 +31,26 @@ class ImageAppConstruct extends constructs_1.Construct {
|
|
|
30
31
|
queue;
|
|
31
32
|
constructor(scope, id, props) {
|
|
32
33
|
super(scope, id);
|
|
34
|
+
const { container, ...functionProps } = props.buildParams;
|
|
33
35
|
this.function = new aws_lambda_1.Function(this, `AppFunction`, {
|
|
34
|
-
...(0, getDefaultLambda_1.getDefaultLambda)(props),
|
|
36
|
+
...(0, getDefaultLambda_1.getDefaultLambda)(this, props),
|
|
35
37
|
code: aws_lambda_1.Code.fromAssetImage(props.output, {
|
|
36
38
|
platform: aws_ecr_assets_1.Platform.LINUX_AMD64,
|
|
37
|
-
...
|
|
39
|
+
...container,
|
|
38
40
|
}),
|
|
39
41
|
handler: aws_lambda_1.Handler.FROM_IMAGE,
|
|
40
42
|
runtime: aws_lambda_1.Runtime.FROM_IMAGE,
|
|
43
|
+
...functionProps,
|
|
41
44
|
});
|
|
42
45
|
if (props.queue) {
|
|
46
|
+
const { batchSize, ...queueProps } = props.queue;
|
|
43
47
|
this.queue = new aws_sqs_1.Queue(this, 'AppQueue', {
|
|
44
|
-
visibilityTimeout:
|
|
48
|
+
visibilityTimeout: queueProps.visibilityTimeout ??
|
|
49
|
+
aws_cdk_lib_1.Duration.seconds((props.timeout ?? 30) + 30),
|
|
50
|
+
...queueProps,
|
|
45
51
|
});
|
|
46
52
|
this.function.addEventSource(new aws_lambda_event_sources_1.SqsEventSource(this.queue, {
|
|
47
|
-
batchSize
|
|
53
|
+
batchSize,
|
|
48
54
|
}));
|
|
49
55
|
}
|
|
50
56
|
}
|
|
@@ -9,11 +9,11 @@ import { z } from 'zod';
|
|
|
9
9
|
import { AppConstruct, AppProperties } from '../types';
|
|
10
10
|
declare const BuildParamsSchema: z.ZodObject<{
|
|
11
11
|
cmd: z.ZodString;
|
|
12
|
-
}, "
|
|
13
|
-
cmd:
|
|
14
|
-
}, {
|
|
15
|
-
cmd:
|
|
16
|
-
}
|
|
12
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
13
|
+
cmd: z.ZodString;
|
|
14
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
15
|
+
cmd: z.ZodString;
|
|
16
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
17
17
|
export declare class NextAppRouterConstruct extends Construct implements AppConstruct {
|
|
18
18
|
function: lambda.Function;
|
|
19
19
|
queue: sqs.Queue | undefined;
|
|
@@ -26,9 +26,9 @@ export declare class NextAppRouterConstruct extends Construct implements AppCons
|
|
|
26
26
|
attach(attachable: Record<string, Attachable>): void;
|
|
27
27
|
grant(...grants: Grantable[]): void;
|
|
28
28
|
subscription(): ITopicSubscription;
|
|
29
|
-
static parse(params: unknown): {
|
|
30
|
-
cmd:
|
|
31
|
-
}
|
|
29
|
+
static parse(params: unknown): z.objectOutputType<{
|
|
30
|
+
cmd: z.ZodString;
|
|
31
|
+
}, z.ZodTypeAny, "passthrough">;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
34
34
|
//# sourceMappingURL=next-app-router-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AAEjD,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;AAOxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"next-app-router-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AAEjD,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;AAOxB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKvD,QAAA,MAAM,iBAAiB;;;;;;gCAA8C,CAAC;AAEtE,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;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAG9B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAyCzD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IAiBpE,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"}
|
|
@@ -10,11 +10,10 @@ const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
|
|
|
10
10
|
const constructs_1 = require("constructs");
|
|
11
11
|
const zod_1 = require("zod");
|
|
12
12
|
const next_app_router_1 = require("../../shared/next-app-router");
|
|
13
|
+
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
13
14
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
14
15
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
15
|
-
const BuildParamsSchema = zod_1.z.object({
|
|
16
|
-
cmd: zod_1.z.string(),
|
|
17
|
-
});
|
|
16
|
+
const BuildParamsSchema = zod_1.z.object({ cmd: zod_1.z.string() }).passthrough();
|
|
18
17
|
class NextAppRouterConstruct extends constructs_1.Construct {
|
|
19
18
|
function;
|
|
20
19
|
queue;
|
|
@@ -33,18 +32,18 @@ class NextAppRouterConstruct extends constructs_1.Construct {
|
|
|
33
32
|
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
|
|
34
33
|
AWS_LWA_INVOKE_MODE: 'response_stream',
|
|
35
34
|
};
|
|
36
|
-
|
|
35
|
+
const { cmd, ...functionProps } = props.buildParams;
|
|
37
36
|
const serverOutput = path.join(props.output, '/.next/standalone');
|
|
38
|
-
fs.writeFileSync(path.join(serverOutput, 'run.sh'),
|
|
37
|
+
fs.writeFileSync(path.join(serverOutput, 'run.sh'), cmd);
|
|
38
|
+
const defaultProps = (0, getDefaultLambda_1.getDefaultLambda)(this, props);
|
|
39
39
|
this.function = new lambda.Function(this, `AppFunction`, {
|
|
40
|
+
...defaultProps,
|
|
41
|
+
environment: Object.assign({}, defaultProps.environment, environment),
|
|
40
42
|
runtime: lambda.Runtime.NODEJS_20_X,
|
|
41
|
-
memorySize: 512,
|
|
42
43
|
handler: 'run.sh',
|
|
43
|
-
timeout: cdk.Duration.seconds(60),
|
|
44
44
|
code: lambda.Code.fromAsset(serverOutput),
|
|
45
|
-
loggingFormat: lambda.LoggingFormat.JSON,
|
|
46
45
|
layers: [webAdapterLayer],
|
|
47
|
-
|
|
46
|
+
...functionProps,
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
cloudfront(path) {
|
|
@@ -8,11 +8,11 @@ import { z } from 'zod';
|
|
|
8
8
|
import { AppConstruct, AppProperties } from '../types';
|
|
9
9
|
declare const BuildParamsSchema: z.ZodObject<{
|
|
10
10
|
cmd: z.ZodString;
|
|
11
|
-
}, "
|
|
12
|
-
cmd:
|
|
13
|
-
}, {
|
|
14
|
-
cmd:
|
|
15
|
-
}
|
|
11
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
12
|
+
cmd: z.ZodString;
|
|
13
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
14
|
+
cmd: z.ZodString;
|
|
15
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
16
16
|
export declare class NodeApiConstruct extends Construct implements AppConstruct {
|
|
17
17
|
function: lambda.Function;
|
|
18
18
|
queue: sqs.Queue | undefined;
|
|
@@ -35,9 +35,9 @@ export declare class NodeApiConstruct extends Construct implements AppConstruct
|
|
|
35
35
|
api(path: string): {
|
|
36
36
|
[x: string]: cdk.aws_apigatewayv2_integrations.HttpUrlIntegration;
|
|
37
37
|
};
|
|
38
|
-
static parse(params: unknown): {
|
|
39
|
-
cmd:
|
|
40
|
-
}
|
|
38
|
+
static parse(params: unknown): z.objectOutputType<{
|
|
39
|
+
cmd: z.ZodString;
|
|
40
|
+
}, z.ZodTypeAny, "passthrough">;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
43
43
|
//# sourceMappingURL=node-api-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-api-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"node-api-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMvD,QAAA,MAAM,iBAAiB;;;;;;gCAA8C,CAAC;AAEtE,qBAAa,gBAAiB,SAAQ,SAAU,YAAW,YAAY;IAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBAGlC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA+CzD,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;IAI1D,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;IAqBvB,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,CAAC,IAAI,EAAE,MAAM;;;IAIhB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
|
|
@@ -12,37 +12,36 @@ const lambdaEventSource = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda-e
|
|
|
12
12
|
const sqs = tslib_1.__importStar(require("aws-cdk-lib/aws-sqs"));
|
|
13
13
|
const constructs_1 = require("constructs");
|
|
14
14
|
const zod_1 = require("zod");
|
|
15
|
+
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
15
16
|
const lambda_api_1 = require("../utils/lambda-api");
|
|
16
17
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
17
18
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
18
|
-
const BuildParamsSchema = zod_1.z.object({
|
|
19
|
-
cmd: zod_1.z.string(),
|
|
20
|
-
});
|
|
19
|
+
const BuildParamsSchema = zod_1.z.object({ cmd: zod_1.z.string() }).passthrough();
|
|
21
20
|
class NodeApiConstruct extends constructs_1.Construct {
|
|
22
21
|
function;
|
|
23
22
|
queue;
|
|
24
23
|
constructor(scope, id, props) {
|
|
25
24
|
super(scope, id);
|
|
26
25
|
const region = cdk.Stack.of(this).region;
|
|
27
|
-
const environment = {
|
|
28
|
-
Object.assign(environment, props.env);
|
|
29
|
-
const layers = [
|
|
30
|
-
lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:16`)
|
|
31
|
-
];
|
|
32
|
-
Object.assign(environment, {
|
|
26
|
+
const environment = {
|
|
33
27
|
AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
|
|
34
28
|
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
|
|
35
29
|
PORT: '8080',
|
|
36
|
-
}
|
|
37
|
-
|
|
30
|
+
};
|
|
31
|
+
const layers = [
|
|
32
|
+
lambda.LayerVersion.fromLayerVersionArn(this, 'WebAdapterLayer', `arn:aws:lambda:${region}:753240598075:layer:LambdaAdapterLayerX86:16`),
|
|
33
|
+
];
|
|
34
|
+
const { cmd, ...functionProps } = props.buildParams;
|
|
35
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(props.output, 'run.sh'), cmd);
|
|
36
|
+
const defaultProps = (0, getDefaultLambda_1.getDefaultLambda)(this, props);
|
|
38
37
|
this.function = new lambda.Function(this, `AppFunction`, {
|
|
38
|
+
...defaultProps,
|
|
39
|
+
environment: Object.assign({}, defaultProps.environment, environment),
|
|
39
40
|
runtime: lambda.Runtime.NODEJS_20_X,
|
|
40
|
-
memorySize: 512,
|
|
41
41
|
handler: 'run.sh',
|
|
42
|
-
layers,
|
|
43
|
-
timeout: cdk.Duration.seconds(30),
|
|
44
42
|
code: lambda.Code.fromAsset(props.output),
|
|
45
|
-
|
|
43
|
+
layers,
|
|
44
|
+
...functionProps,
|
|
46
45
|
});
|
|
47
46
|
if (props.queue) {
|
|
48
47
|
this.queue = new sqs.Queue(this, 'AppQueue', {
|
|
@@ -9,11 +9,11 @@ import { z } from 'zod';
|
|
|
9
9
|
import { AppConstruct, AppProperties } from '../types';
|
|
10
10
|
declare const BuildParamsSchema: z.ZodObject<{
|
|
11
11
|
handler: z.ZodOptional<z.ZodString>;
|
|
12
|
-
}, "
|
|
13
|
-
handler
|
|
14
|
-
}, {
|
|
15
|
-
handler
|
|
16
|
-
}
|
|
12
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
13
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
15
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
17
17
|
export declare class NodeAppConstruct extends Construct implements AppConstruct {
|
|
18
18
|
function: lambda.Function;
|
|
19
19
|
queue: sqs.Queue | undefined;
|
|
@@ -24,9 +24,9 @@ export declare class NodeAppConstruct extends Construct implements AppConstruct
|
|
|
24
24
|
cloudfront(path: string): Record<string, BehaviorOptions>;
|
|
25
25
|
cloudfrontPolicy(distributionId: string): void;
|
|
26
26
|
api(path: string): Record<string, HttpRouteIntegration>;
|
|
27
|
-
static parse(params: unknown): {
|
|
28
|
-
handler
|
|
29
|
-
}
|
|
27
|
+
static parse(params: unknown): z.objectOutputType<{
|
|
28
|
+
handler: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.ZodTypeAny, "passthrough">;
|
|
30
30
|
}
|
|
31
31
|
export {};
|
|
32
32
|
//# sourceMappingURL=node-app-construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"node-app-construct.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/apps/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;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,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;AAKvD,QAAA,MAAM,iBAAiB;;;;;;gCAEP,CAAC;AAEjB,qBAAa,gBAAiB,SAAQ,SAAU,YAAW,YAAY;IAC9D,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC;gBAGlC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA6BzD,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;IAU1D,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;IAcvD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
|
|
@@ -2,42 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeAppConstruct = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
6
|
const aws_apigatewayv2_integrations_1 = require("aws-cdk-lib/aws-apigatewayv2-integrations");
|
|
7
7
|
const lambda = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda"));
|
|
8
|
-
const
|
|
9
|
-
const lambdaEventSource = tslib_1.__importStar(require("aws-cdk-lib/aws-lambda-event-sources"));
|
|
8
|
+
const aws_lambda_event_sources_1 = require("aws-cdk-lib/aws-lambda-event-sources");
|
|
10
9
|
const snsSubscriptions = tslib_1.__importStar(require("aws-cdk-lib/aws-sns-subscriptions"));
|
|
11
|
-
const
|
|
10
|
+
const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
|
|
12
11
|
const constructs_1 = require("constructs");
|
|
13
12
|
const zod_1 = require("zod");
|
|
13
|
+
const getDefaultLambda_1 = require("../utils/getDefaultLambda");
|
|
14
14
|
const lambda_attach_1 = require("../utils/lambda-attach");
|
|
15
15
|
const lambda_grant_1 = require("../utils/lambda-grant");
|
|
16
|
-
const BuildParamsSchema = zod_1.z
|
|
17
|
-
handler: zod_1.z.string().optional()
|
|
18
|
-
|
|
16
|
+
const BuildParamsSchema = zod_1.z
|
|
17
|
+
.object({ handler: zod_1.z.string().optional() })
|
|
18
|
+
.passthrough();
|
|
19
19
|
class NodeAppConstruct extends constructs_1.Construct {
|
|
20
20
|
function;
|
|
21
21
|
queue;
|
|
22
22
|
constructor(scope, id, props) {
|
|
23
23
|
super(scope, id);
|
|
24
|
-
const environment = {};
|
|
25
|
-
Object.assign(environment, props.env);
|
|
26
24
|
this.function = new lambda.Function(this, `AppFunction`, {
|
|
25
|
+
...(0, getDefaultLambda_1.getDefaultLambda)(this, props),
|
|
27
26
|
runtime: lambda.Runtime.NODEJS_20_X,
|
|
28
|
-
|
|
29
|
-
handler: props.buildParams.handler ?? "index.handler",
|
|
30
|
-
timeout: cdk.Duration.seconds(30),
|
|
27
|
+
handler: props.buildParams.handler ?? 'index.handler',
|
|
31
28
|
code: lambda.Code.fromAsset(props.output),
|
|
32
|
-
loggingFormat: aws_lambda_1.LoggingFormat.JSON,
|
|
33
|
-
environment,
|
|
34
29
|
});
|
|
35
30
|
if (props.queue) {
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const { batchSize, ...queueProps } = props.queue;
|
|
32
|
+
this.queue = new aws_sqs_1.Queue(this, 'AppQueue', {
|
|
33
|
+
visibilityTimeout: queueProps.visibilityTimeout ??
|
|
34
|
+
aws_cdk_lib_1.Duration.seconds((props.timeout ?? 30) + 30),
|
|
35
|
+
...queueProps,
|
|
38
36
|
});
|
|
39
|
-
this.function.addEventSource(new
|
|
40
|
-
batchSize:
|
|
37
|
+
this.function.addEventSource(new aws_lambda_event_sources_1.SqsEventSource(this.queue, {
|
|
38
|
+
batchSize: batchSize,
|
|
41
39
|
}));
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -49,7 +47,10 @@ class NodeAppConstruct extends constructs_1.Construct {
|
|
|
49
47
|
}
|
|
50
48
|
subscription(props) {
|
|
51
49
|
if (this.queue)
|
|
52
|
-
return new snsSubscriptions.SqsSubscription(this.queue, {
|
|
50
|
+
return new snsSubscriptions.SqsSubscription(this.queue, {
|
|
51
|
+
...props,
|
|
52
|
+
rawMessageDelivery: true,
|
|
53
|
+
});
|
|
53
54
|
return new snsSubscriptions.LambdaSubscription(this.function, props);
|
|
54
55
|
}
|
|
55
56
|
cloudfront(path) {
|
|
@@ -63,7 +64,7 @@ class NodeAppConstruct extends constructs_1.Construct {
|
|
|
63
64
|
const integration = new aws_apigatewayv2_integrations_1.HttpLambdaIntegration('AppIntegration', this.function);
|
|
64
65
|
return {
|
|
65
66
|
[path]: integration,
|
|
66
|
-
[`${path}/{proxy+}`]: integration
|
|
67
|
+
[`${path}/{proxy+}`]: integration,
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
static parse(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lambda-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/lambda-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAS7D,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;gBAE5B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;
|
|
1
|
+
{"version":3,"file":"lambda-construct.d.ts","sourceRoot":"","sources":["../../../src/lib/lambda/lambda-construct.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAS7D,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAM;gBAE5B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB;CAuBtE"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ApiResource, AppType, type Attach, type CDNResource, type EventResource, type Grant } from '@fy-stack/types';
|
|
2
2
|
import type { IVpc } from 'aws-cdk-lib/aws-ec2';
|
|
3
|
-
import type { Function } from 'aws-cdk-lib/aws-lambda';
|
|
4
|
-
import {
|
|
3
|
+
import type { Function, FunctionProps } from 'aws-cdk-lib/aws-lambda';
|
|
4
|
+
import type { ILogGroup } from 'aws-cdk-lib/aws-logs';
|
|
5
|
+
import type { Queue, QueueProps } from 'aws-cdk-lib/aws-sqs';
|
|
5
6
|
export type LambdaConstructProps = {
|
|
6
7
|
vpc?: IVpc;
|
|
7
8
|
apps: Record<string, App>;
|
|
9
|
+
logGroup: ILogGroup;
|
|
8
10
|
};
|
|
9
11
|
export interface AppConstruct extends Attach, Grant, CDNResource, EventResource, ApiResource {
|
|
10
12
|
function: Function;
|
|
@@ -12,20 +14,15 @@ export interface AppConstruct extends Attach, Grant, CDNResource, EventResource,
|
|
|
12
14
|
}
|
|
13
15
|
export type App = {
|
|
14
16
|
type: typeof AppType.IMAGE_APP | typeof AppType.NEXT_APP_ROUTER | typeof AppType.NODE_APP | typeof AppType.NODE_API;
|
|
15
|
-
|
|
16
|
-
env?: Record<string, string>;
|
|
17
|
-
queue?: {
|
|
18
|
-
batchSize?: number;
|
|
19
|
-
};
|
|
20
|
-
buildParams?: Record<string, unknown>;
|
|
21
|
-
};
|
|
17
|
+
} & Omit<AppProperties, 'vpc' | 'logGroup'>;
|
|
22
18
|
export type AppProperties<BuildParams = Record<string, unknown>> = {
|
|
19
|
+
logGroup: ILogGroup;
|
|
23
20
|
queue?: {
|
|
24
21
|
batchSize?: number;
|
|
25
|
-
}
|
|
22
|
+
} & Partial<QueueProps>;
|
|
26
23
|
env?: Record<string, string>;
|
|
27
24
|
timeout?: number;
|
|
28
|
-
buildParams: BuildParams
|
|
25
|
+
buildParams: BuildParams & Partial<FunctionProps>;
|
|
29
26
|
output: string;
|
|
30
27
|
vpc?: IVpc;
|
|
31
28
|
};
|
|
@@ -1 +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;
|
|
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,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,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;CAC7B,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;AAE5C,MAAM,MAAM,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionProps } from 'aws-cdk-lib/aws-lambda';
|
|
2
|
+
import type { Construct } from 'constructs';
|
|
2
3
|
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
|
-
};
|
|
4
|
+
export declare function getDefaultLambda(scope: Construct, props: AppProperties<unknown>): Partial<FunctionProps>;
|
|
8
5
|
//# sourceMappingURL=getDefaultLambda.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultLambda.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/getDefaultLambda.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDefaultLambda.d.ts","sourceRoot":"","sources":["../../../../src/lib/lambda/utils/getDefaultLambda.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAiB,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,0BAgB9B"}
|
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultLambda = getDefaultLambda;
|
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
6
|
+
function getDefaultLambda(scope, props) {
|
|
7
|
+
let params = {
|
|
7
8
|
memorySize: 512,
|
|
8
9
|
timeout: aws_cdk_lib_1.Duration.seconds(props.timeout ?? 30),
|
|
9
10
|
environment: props.env,
|
|
10
11
|
};
|
|
12
|
+
if (props.logGroup) {
|
|
13
|
+
params = Object.assign(params, { logGroup: props.logGroup, loggingFormat: aws_lambda_1.LoggingFormat.JSON });
|
|
14
|
+
}
|
|
15
|
+
return params;
|
|
11
16
|
}
|
|
@@ -1 +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;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC9B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;;;;;;EAsC9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO;;
|
|
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;AACzC,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC9B,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;;;;;;EAsC9D;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,SAAS,EACd,YAAY,EAAE,EAAE,CAAC,MAAM,EACvB,YAAY,EAAE,UAAU,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO;;EA2Df"}
|
|
@@ -46,17 +46,17 @@ function staticDeployment(app, output) {
|
|
|
46
46
|
}
|
|
47
47
|
function cloudfrontBehaviours(app, staticBucket, serverOrigin, basePath, files) {
|
|
48
48
|
if (basePath) {
|
|
49
|
-
|
|
49
|
+
const strippedBasePath = basePath.replace(/^\/+|\/+$/g, '');
|
|
50
50
|
new s3Deploy.BucketDeployment(app, `${basePath}StaticDeployment`, {
|
|
51
51
|
destinationBucket: staticBucket,
|
|
52
52
|
sources: [files.staticFiles],
|
|
53
|
-
destinationKeyPrefix: `${
|
|
53
|
+
destinationKeyPrefix: `${strippedBasePath}/_next/static/`,
|
|
54
54
|
retainOnDelete: false,
|
|
55
55
|
});
|
|
56
56
|
new s3Deploy.BucketDeployment(app, `${basePath}PublicDeployment`, {
|
|
57
57
|
destinationBucket: staticBucket,
|
|
58
58
|
sources: [files.publicFiles],
|
|
59
|
-
destinationKeyPrefix:
|
|
59
|
+
destinationKeyPrefix: `${strippedBasePath}/`,
|
|
60
60
|
retainOnDelete: false,
|
|
61
61
|
});
|
|
62
62
|
}
|
|
@@ -86,17 +86,12 @@ function cloudfrontBehaviours(app, staticBucket, serverOrigin, basePath, files)
|
|
|
86
86
|
.CORS_ALLOW_ALL_ORIGINS_WITH_PREFLIGHT_AND_SECURITY_HEADERS,
|
|
87
87
|
};
|
|
88
88
|
return {
|
|
89
|
-
[`${basePath}/_next/image`]: {
|
|
90
|
-
...appBehaviour,
|
|
89
|
+
[`${basePath}/_next/image`]: Object.assign({}, appBehaviour, {
|
|
91
90
|
cachePolicy: imageCachePolicy,
|
|
92
91
|
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
|
|
93
|
-
},
|
|
92
|
+
}),
|
|
94
93
|
[`${basePath}/_next/*`]: staticBehavior,
|
|
95
|
-
[`${basePath}
|
|
96
|
-
[`${basePath}/*.png`]: staticBehavior,
|
|
97
|
-
[`${basePath}/*.svg`]: staticBehavior,
|
|
98
|
-
[`${basePath}/*.jpg`]: staticBehavior,
|
|
99
|
-
[`${basePath}/*.jpeg`]: staticBehavior,
|
|
94
|
+
[`${basePath}/*.*`]: staticBehavior,
|
|
100
95
|
[`${basePath}/*`]: appBehaviour,
|
|
101
96
|
};
|
|
102
97
|
}
|
|
@@ -3,14 +3,23 @@ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
|
3
3
|
import { Construct } from 'constructs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { AppConstruct, AppProperties } from '../types';
|
|
6
|
-
declare const BuildParamsSchema: z.ZodOptional<z.ZodObject<{
|
|
6
|
+
declare const BuildParamsSchema: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
spa: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
spa?: boolean | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
spa?: boolean | undefined;
|
|
12
|
+
}>>;
|
|
7
13
|
export declare class StaticWebsiteConstruct extends Construct implements AppConstruct {
|
|
14
|
+
private props;
|
|
8
15
|
private readonly static;
|
|
9
16
|
constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
|
|
10
17
|
cloudfront(path: string): Record<string, cloudfront.BehaviorOptions>;
|
|
11
18
|
cloudfrontPolicy(distributionId: string): void;
|
|
12
19
|
api(): Record<string, HttpRouteIntegration>;
|
|
13
|
-
static parse(params: unknown): {
|
|
20
|
+
static parse(params: unknown): {
|
|
21
|
+
spa?: boolean | undefined;
|
|
22
|
+
} | undefined;
|
|
14
23
|
}
|
|
15
24
|
export {};
|
|
16
25
|
//# sourceMappingURL=static-website-construct.d.ts.map
|
|
@@ -1 +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
|
|
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;;;;;;GAIV,CAAC;AAEd,qBAAa,sBAAuB,SAAQ,SAAU,YAAW,YAAY;IAMzE,OAAO,CAAC,KAAK;IALf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAGjC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACF,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA2BjE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC;IA2DpE,gBAAgB,CAAC,cAAc,EAAE,MAAM;IAIvC,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAI3C,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO;;;CAG7B"}
|
|
@@ -9,11 +9,17 @@ const s3 = tslib_1.__importStar(require("aws-cdk-lib/aws-s3"));
|
|
|
9
9
|
const s3Deploy = tslib_1.__importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
10
10
|
const constructs_1 = require("constructs");
|
|
11
11
|
const zod_1 = require("zod");
|
|
12
|
-
const BuildParamsSchema = zod_1.z
|
|
12
|
+
const BuildParamsSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
spa: zod_1.z.boolean().optional(),
|
|
15
|
+
})
|
|
16
|
+
.optional();
|
|
13
17
|
class StaticWebsiteConstruct extends constructs_1.Construct {
|
|
18
|
+
props;
|
|
14
19
|
static;
|
|
15
20
|
constructor(scope, id, props) {
|
|
16
21
|
super(scope, id);
|
|
22
|
+
this.props = props;
|
|
17
23
|
this.static = new s3.Bucket(this, `StaticBucket`, {
|
|
18
24
|
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
19
25
|
autoDeleteObjects: true,
|
|
@@ -45,8 +51,45 @@ class StaticWebsiteConstruct extends constructs_1.Construct {
|
|
|
45
51
|
compress: true,
|
|
46
52
|
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
47
53
|
};
|
|
54
|
+
let staticPageBehaviour = Object.assign({}, staticBehavior);
|
|
55
|
+
if (this.props.buildParams?.spa) {
|
|
56
|
+
const spaRewriteFunction = new cloudfront.Function(this, 'SpaRewrite', {
|
|
57
|
+
code: cloudfront.FunctionCode.fromInline(`
|
|
58
|
+
function handler(event) {
|
|
59
|
+
var request = event.request
|
|
60
|
+
|
|
61
|
+
if (!request.uri.endsWith('/')) {
|
|
62
|
+
return {
|
|
63
|
+
statusCode: 301,
|
|
64
|
+
statusDescription: 'Moved Permanently',
|
|
65
|
+
headers: {
|
|
66
|
+
location: {
|
|
67
|
+
value: request.uri + '/'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (request.uri !== "${path || '/'}") {
|
|
74
|
+
request.uri = '/index.html'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return request;
|
|
78
|
+
}
|
|
79
|
+
`),
|
|
80
|
+
});
|
|
81
|
+
staticPageBehaviour = Object.assign(staticPageBehaviour, {
|
|
82
|
+
functionAssociations: [
|
|
83
|
+
{
|
|
84
|
+
eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
|
|
85
|
+
function: spaRewriteFunction,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
48
90
|
return {
|
|
49
|
-
[`${path}
|
|
91
|
+
[`${path}/*.*`]: staticBehavior,
|
|
92
|
+
[`${path}/*`]: staticPageBehaviour,
|
|
50
93
|
};
|
|
51
94
|
}
|
|
52
95
|
cloudfrontPolicy(distributionId) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/app-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.147-0-preview",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.
|
|
6
|
+
"@fy-stack/types": "0.0.147-0-preview",
|
|
7
7
|
"tslib": "^2.3.0",
|
|
8
8
|
"zod": "^3.24.1"
|
|
9
9
|
},
|