@fy-stack/app-construct 0.0.139 → 0.0.141

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.
@@ -1,36 +1,68 @@
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 { Function } from 'aws-cdk-lib/aws-lambda';
4
+ import { AssetImageCodeProps, 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
- file: z.ZodOptional<z.ZodString>;
12
- cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
- }, "strip", z.ZodTypeAny, {
14
- cmd?: string[] | undefined;
15
- file?: string | undefined;
16
- }, {
17
- cmd?: string[] | undefined;
18
- file?: string | undefined;
19
- }>;
11
+ container: z.ZodObject<{
12
+ file: z.ZodOptional<z.ZodString>;
13
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
14
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
15
+ file: z.ZodOptional<z.ZodString>;
16
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
17
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
18
+ file: z.ZodOptional<z.ZodString>;
19
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ }, z.ZodTypeAny, "passthrough">>;
21
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
22
+ container: z.ZodObject<{
23
+ file: z.ZodOptional<z.ZodString>;
24
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
25
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
26
+ file: z.ZodOptional<z.ZodString>;
27
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
28
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
29
+ file: z.ZodOptional<z.ZodString>;
30
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
31
+ }, z.ZodTypeAny, "passthrough">>;
32
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
33
+ container: z.ZodObject<{
34
+ file: z.ZodOptional<z.ZodString>;
35
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
36
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
37
+ file: z.ZodOptional<z.ZodString>;
38
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
39
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
40
+ file: z.ZodOptional<z.ZodString>;
41
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
42
+ }, z.ZodTypeAny, "passthrough">>;
43
+ }, z.ZodTypeAny, "passthrough">>;
20
44
  export declare class ImageAppConstruct extends Construct implements AppConstruct {
21
45
  function: Function;
22
46
  queue: Queue | undefined;
23
- constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema>>);
47
+ constructor(scope: Construct, id: string, props: AppProperties<z.infer<typeof BuildParamsSchema> & AssetImageCodeProps>);
24
48
  attach(attachable: Record<string, Attachable>): void;
25
49
  grant(...grantables: Grantable[]): void;
26
50
  subscription(props: SubscriptionProps): ITopicSubscription;
27
51
  cloudfront(path: string): Record<string, BehaviorOptions>;
28
52
  cloudfrontPolicy(distributionId: string): void;
29
53
  api(path: string): Record<string, HttpRouteIntegration>;
30
- static parse(params: unknown): {
31
- cmd?: string[] | undefined;
32
- file?: string | undefined;
33
- };
54
+ static parse(params: unknown): z.objectOutputType<{
55
+ container: z.ZodObject<{
56
+ file: z.ZodOptional<z.ZodString>;
57
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
58
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
59
+ file: z.ZodOptional<z.ZodString>;
60
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
61
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
62
+ file: z.ZodOptional<z.ZodString>;
63
+ cmd: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
64
+ }, z.ZodTypeAny, "passthrough">>;
65
+ }, z.ZodTypeAny, "passthrough">;
34
66
  }
35
67
  export {};
36
68
  //# 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;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMtD,QAAA,MAAM,iBAAiB;;;;;;;;;EAGrB,CAAA;AAEF,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,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,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,CAClB,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,GAAG,mBAAmB,CACxD;IA2BH,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"}
@@ -15,10 +15,16 @@ const getDefaultLambda_1 = require("./utils/getDefaultLambda");
15
15
  const lambda_api_1 = require("./utils/lambda-api");
16
16
  const lambda_attach_1 = require("./utils/lambda-attach");
17
17
  const lambda_grant_1 = require("./utils/lambda-grant");
18
- const BuildParamsSchema = zod_1.z.object({
19
- file: zod_1.z.string().optional(),
20
- cmd: zod_1.z.string().array().optional(),
21
- });
18
+ const BuildParamsSchema = zod_1.z
19
+ .object({
20
+ container: zod_1.z
21
+ .object({
22
+ file: zod_1.z.string().optional(),
23
+ cmd: zod_1.z.string().array().optional(),
24
+ })
25
+ .passthrough(),
26
+ })
27
+ .passthrough();
22
28
  class ImageAppConstruct extends constructs_1.Construct {
23
29
  function;
24
30
  queue;
@@ -27,9 +33,8 @@ class ImageAppConstruct extends constructs_1.Construct {
27
33
  this.function = new aws_lambda_1.Function(this, `AppFunction`, {
28
34
  ...(0, getDefaultLambda_1.getDefaultLambda)(props),
29
35
  code: aws_lambda_1.Code.fromAssetImage(props.output, {
30
- file: props.buildParams.file,
31
36
  platform: aws_ecr_assets_1.Platform.LINUX_AMD64,
32
- cmd: props.buildParams.cmd,
37
+ ...props.buildParams.container,
33
38
  }),
34
39
  handler: aws_lambda_1.Handler.FROM_IMAGE,
35
40
  runtime: aws_lambda_1.Runtime.FROM_IMAGE,
@@ -51,7 +56,10 @@ class ImageAppConstruct extends constructs_1.Construct {
51
56
  }
52
57
  subscription(props) {
53
58
  if (this.queue) {
54
- return new aws_sns_subscriptions_1.SqsSubscription(this.queue, { ...props, rawMessageDelivery: true });
59
+ return new aws_sns_subscriptions_1.SqsSubscription(this.queue, {
60
+ ...props,
61
+ rawMessageDelivery: true,
62
+ });
55
63
  }
56
64
  return new aws_sns_subscriptions_1.LambdaSubscription(this.function, props);
57
65
  }
@@ -72,7 +80,7 @@ class ImageAppConstruct extends constructs_1.Construct {
72
80
  return { [`${path}/*`]: apiBehavior };
73
81
  }
74
82
  cloudfrontPolicy(distributionId) {
75
- throw new Error("cloudfrontPolicy not implemented");
83
+ throw new Error('cloudfrontPolicy not implemented');
76
84
  }
77
85
  api(path) {
78
86
  return (0, lambda_api_1.lambdaApi)(this.function, path);
@@ -6,7 +6,7 @@ function lambdaAttach(func, attachable) {
6
6
  Object.assign(params, ...Object.entries(attachable)
7
7
  .map(([key, val]) => {
8
8
  return Object.fromEntries(Object.entries(val?.attachable() ?? {})
9
- .map(([subKey, subVal]) => [`${key}_${subKey}`, subVal]));
9
+ .map(([subKey, subVal]) => [`${key}_${subKey}`.toUpperCase(), subVal]));
10
10
  }));
11
11
  for (const i in params) {
12
12
  func.addEnvironment(i, params[i]);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@fy-stack/app-construct",
3
- "version": "0.0.139",
3
+ "version": "0.0.141",
4
4
  "repository": "https://github.com/festusyuma/fy-stack",
5
5
  "dependencies": {
6
- "@fy-stack/types": "0.0.139",
6
+ "@fy-stack/types": "0.0.141",
7
7
  "tslib": "^2.3.0",
8
8
  "zod": "^3.24.1"
9
9
  },