@awsless/awsless 0.0.485 → 0.0.487

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/bin.js CHANGED
@@ -47,22 +47,157 @@ import { mkdir, readFile, rm, writeFile } from "fs/promises";
47
47
  import { homedir } from "os";
48
48
  import { dirname, join as join2 } from "path";
49
49
 
50
- // src/formation/cloudfront.ts
51
- import { CloudFrontClient, CreateInvalidationCommand } from "@aws-sdk/client-cloudfront";
50
+ // src/formation/cloudfront-kvs.ts
51
+ import {
52
+ CloudFrontKeyValueStoreClient,
53
+ DescribeKeyValueStoreCommand,
54
+ ListKeysCommand,
55
+ UpdateKeysCommand
56
+ } from "@aws-sdk/client-cloudfront-keyvaluestore";
52
57
  import { createCustomProvider, createCustomResourceClass } from "@awsless/formation";
58
+ import chunk from "chunk";
53
59
  import { z } from "zod";
54
- var Invalidation = createCustomResourceClass(
60
+ import "@aws-sdk/signature-v4-crt";
61
+ var ImportKeys = createCustomResourceClass("cloudfront-kvs", "import-keys");
62
+ var createCloudFrontKvsProvider = ({ profile, region }) => {
63
+ const client = new CloudFrontKeyValueStoreClient({ profile, region });
64
+ const validateInput = (state2) => {
65
+ return z.object({
66
+ kvsArn: z.string(),
67
+ keys: z.array(z.object({ key: z.string(), value: z.string() })),
68
+ eTag: z.string().optional()
69
+ }).parse(state2);
70
+ };
71
+ const formatOutput = (output) => {
72
+ return {
73
+ eTag: output.ETag,
74
+ itemCount: output.ItemCount,
75
+ totalSizeInBytes: output.TotalSizeInBytes
76
+ };
77
+ };
78
+ const bulkUpdate = async (props) => {
79
+ const batches = chunk(props.mutations, 50);
80
+ let prev = await client.send(
81
+ new DescribeKeyValueStoreCommand({
82
+ KvsARN: props.arn
83
+ })
84
+ );
85
+ let result;
86
+ let ifMatch = prev.ETag;
87
+ for (const mutations of batches) {
88
+ result = await client.send(
89
+ new UpdateKeysCommand({
90
+ KvsARN: props.arn,
91
+ IfMatch: ifMatch,
92
+ Puts: mutations.filter((item) => item.type === "put").map((item) => ({
93
+ Key: item.key,
94
+ Value: item.value
95
+ })),
96
+ Deletes: mutations.filter((item) => item.type === "delete").map((item) => ({
97
+ Key: item.key
98
+ }))
99
+ })
100
+ );
101
+ ifMatch = result.ETag;
102
+ }
103
+ return result;
104
+ };
105
+ return createCustomProvider("cloudfront-kvs", {
106
+ "import-keys": {
107
+ async getResource(props) {
108
+ const state2 = z.object({ kvsArn: z.string() }).parse(props.state);
109
+ const result = await client.send(
110
+ new DescribeKeyValueStoreCommand({
111
+ KvsARN: state2.kvsArn
112
+ })
113
+ );
114
+ const keys = [];
115
+ let nextToken;
116
+ while (true) {
117
+ const result2 = await client.send(
118
+ new ListKeysCommand({
119
+ KvsARN: state2.kvsArn,
120
+ NextToken: nextToken,
121
+ MaxResults: 50
122
+ })
123
+ );
124
+ for (const item of result2.Items ?? []) {
125
+ keys.push({
126
+ key: item.Key,
127
+ value: item.Value
128
+ });
129
+ }
130
+ if (result2.NextToken) {
131
+ nextToken = result2.NextToken;
132
+ } else {
133
+ break;
134
+ }
135
+ }
136
+ return {
137
+ keys,
138
+ ...state2,
139
+ ...formatOutput(result)
140
+ };
141
+ },
142
+ async createResource(props) {
143
+ const state2 = validateInput(props.state);
144
+ const result = await bulkUpdate({
145
+ arn: state2.kvsArn,
146
+ mutations: state2.keys.map((item) => ({ ...item, type: "put" }))
147
+ });
148
+ return {
149
+ ...state2,
150
+ ...formatOutput(result)
151
+ };
152
+ },
153
+ async updateResource(props) {
154
+ const priorState = validateInput(props.priorState);
155
+ const proposedState = validateInput(props.proposedState);
156
+ const puts = proposedState.keys.filter((a) => {
157
+ return !priorState.keys.find((b) => a.key === b.key);
158
+ });
159
+ const deletes = priorState.keys.filter((a) => {
160
+ return !proposedState.keys.find((b) => a.key === b.key);
161
+ });
162
+ const result = await bulkUpdate({
163
+ arn: proposedState.kvsArn,
164
+ mutations: [
165
+ ...puts.map((i) => ({ ...i, type: "put" })),
166
+ ...deletes.map((i) => ({ ...i, type: "delete" }))
167
+ ]
168
+ });
169
+ return {
170
+ ...proposedState,
171
+ ...formatOutput(result)
172
+ };
173
+ },
174
+ async deleteResource(props) {
175
+ const state2 = validateInput(props.state);
176
+ await bulkUpdate({
177
+ arn: state2.kvsArn,
178
+ mutations: state2.keys.map((i) => ({ ...i, type: "delete" }))
179
+ });
180
+ }
181
+ }
182
+ });
183
+ };
184
+
185
+ // src/formation/cloudfront.ts
186
+ import { CloudFrontClient, CreateInvalidationCommand } from "@aws-sdk/client-cloudfront";
187
+ import { createCustomProvider as createCustomProvider2, createCustomResourceClass as createCustomResourceClass2 } from "@awsless/formation";
188
+ import { z as z2 } from "zod";
189
+ var Invalidation = createCustomResourceClass2(
55
190
  "cloudfront",
56
191
  "invalidation"
57
192
  );
58
193
  var createCloudFrontProvider = ({ profile, region }) => {
59
194
  const cloudFront = new CloudFrontClient({ profile, region });
60
- return createCustomProvider("cloudfront", {
195
+ return createCustomProvider2("cloudfront", {
61
196
  invalidation: {
62
197
  async updateResource(props) {
63
- const state2 = z.object({
64
- distributionId: z.string(),
65
- paths: z.string().array().min(1)
198
+ const state2 = z2.object({
199
+ distributionId: z2.string(),
200
+ paths: z2.string().array().min(1)
66
201
  }).parse(props.proposedState);
67
202
  const result = await cloudFront.send(
68
203
  new CreateInvalidationCommand({
@@ -87,24 +222,24 @@ var createCloudFrontProvider = ({ profile, region }) => {
87
222
 
88
223
  // src/formation/lambda.ts
89
224
  import { LambdaClient, UpdateFunctionCodeCommand } from "@aws-sdk/client-lambda";
90
- import { createCustomProvider as createCustomProvider2, createCustomResourceClass as createCustomResourceClass2 } from "@awsless/formation";
91
- import { z as z2 } from "zod";
92
- var UpdateFunctionCode = createCustomResourceClass2(
225
+ import { createCustomProvider as createCustomProvider3, createCustomResourceClass as createCustomResourceClass3 } from "@awsless/formation";
226
+ import { z as z3 } from "zod";
227
+ var UpdateFunctionCode = createCustomResourceClass3(
93
228
  "lambda",
94
229
  "update-function-code"
95
230
  );
96
231
  var createLambdaProvider = ({ credentials, region }) => {
97
232
  const lambda = new LambdaClient({ credentials, region });
98
- return createCustomProvider2("lambda", {
233
+ return createCustomProvider3("lambda", {
99
234
  "update-function-code": {
100
235
  async updateResource(props) {
101
- const state2 = z2.object({
102
- functionName: z2.string(),
103
- architectures: z2.string().array(),
104
- s3Bucket: z2.string().optional().transform((v) => v ? v : void 0),
105
- s3Key: z2.string().optional().transform((v) => v ? v : void 0),
106
- s3ObjectVersion: z2.string().optional().transform((v) => v ? v : void 0),
107
- imageUri: z2.string().optional().transform((v) => v ? v : void 0)
236
+ const state2 = z3.object({
237
+ functionName: z3.string(),
238
+ architectures: z3.string().array(),
239
+ s3Bucket: z3.string().optional().transform((v) => v ? v : void 0),
240
+ s3Key: z3.string().optional().transform((v) => v ? v : void 0),
241
+ s3ObjectVersion: z3.string().optional().transform((v) => v ? v : void 0),
242
+ imageUri: z3.string().optional().transform((v) => v ? v : void 0)
108
243
  }).parse(props.proposedState);
109
244
  await lambda.send(
110
245
  new UpdateFunctionCodeCommand({
@@ -202,11 +337,12 @@ var createWorkSpace = async (props) => {
202
337
  if (process.env.VERBOSE) {
203
338
  enableDebug();
204
339
  }
205
- const aws = await terraform.install("hashicorp", "aws", "5.94.1");
340
+ const aws = await terraform.install("hashicorp", "aws", "5.98.0");
206
341
  const workspace = new WorkSpace({
207
342
  providers: [
208
343
  createLambdaProvider(props),
209
344
  createCloudFrontProvider(props),
345
+ createCloudFrontKvsProvider(props),
210
346
  aws(
211
347
  {
212
348
  profile: props.profile,
@@ -491,21 +627,21 @@ var debug = (...parts) => {
491
627
  };
492
628
 
493
629
  // src/config/app.ts
494
- import { z as z23 } from "zod";
630
+ import { z as z24 } from "zod";
495
631
 
496
632
  // src/feature/alert/schema.ts
497
633
  import { kebabCase } from "change-case";
498
- import { z as z4 } from "zod";
634
+ import { z as z5 } from "zod";
499
635
 
500
636
  // src/config/schema/email.ts
501
- import { z as z3 } from "zod";
502
- var EmailSchema = z3.string().email();
637
+ import { z as z4 } from "zod";
638
+ var EmailSchema = z4.string().email();
503
639
 
504
640
  // src/feature/alert/schema.ts
505
- var AlertNameSchema = z4.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid alert name").transform((value) => kebabCase(value)).describe("Define alert name.");
506
- var AlertsDefaultSchema = z4.record(
641
+ var AlertNameSchema = z5.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid alert name").transform((value) => kebabCase(value)).describe("Define alert name.");
642
+ var AlertsDefaultSchema = z5.record(
507
643
  AlertNameSchema,
508
- z4.union([
644
+ z5.union([
509
645
  //
510
646
  EmailSchema.transform((v) => [v]),
511
647
  EmailSchema.array()
@@ -513,17 +649,17 @@ var AlertsDefaultSchema = z4.record(
513
649
  ).optional().describe("Define the alerts in your app. Alerts are a way to send messages to one or more email addresses.");
514
650
 
515
651
  // src/feature/auth/schema.ts
516
- import { z as z7 } from "zod";
652
+ import { z as z8 } from "zod";
517
653
 
518
654
  // src/config/schema/resource-id.ts
519
655
  import { kebabCase as kebabCase2 } from "change-case";
520
- import { z as z5 } from "zod";
521
- var ResourceIdSchema = z5.string().min(3).max(24).regex(/^[a-z0-9\-]+$/i, "Invalid resource ID").transform((value) => kebabCase2(value));
656
+ import { z as z6 } from "zod";
657
+ var ResourceIdSchema = z6.string().min(3).max(24).regex(/^[a-z0-9\-]+$/i, "Invalid resource ID").transform((value) => kebabCase2(value));
522
658
 
523
659
  // src/config/schema/duration.ts
524
660
  import { parse } from "@awsless/duration";
525
- import { z as z6 } from "zod";
526
- var DurationSchema = z6.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?|weeks?)$/, "Invalid duration").transform((v) => parse(v));
661
+ import { z as z7 } from "zod";
662
+ var DurationSchema = z7.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?|weeks?)$/, "Invalid duration").transform((v) => parse(v));
527
663
  var durationMin = (min) => {
528
664
  return (duration) => {
529
665
  return duration.value >= min.value;
@@ -536,10 +672,10 @@ var durationMax = (max) => {
536
672
  };
537
673
 
538
674
  // src/feature/auth/schema.ts
539
- var AuthDefaultSchema = z7.record(
675
+ var AuthDefaultSchema = z8.record(
540
676
  ResourceIdSchema,
541
- z7.object({
542
- allowUserRegistration: z7.boolean().default(true).describe("Specifies whether users can create an user account or if only the administrator can."),
677
+ z8.object({
678
+ allowUserRegistration: z8.boolean().default(true).describe("Specifies whether users can create an user account or if only the administrator can."),
543
679
  // messaging: z
544
680
  // .object({
545
681
  // fromEmail: EmailSchema.describe("Specifies the sender's email address."),
@@ -551,23 +687,23 @@ var AuthDefaultSchema = z7.record(
551
687
  // .optional()
552
688
  // .describe('The email configuration for sending messages.'),
553
689
  // secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
554
- username: z7.object({
690
+ username: z8.object({
555
691
  // emailAlias: z.boolean().default(true).describe('Allow the user email to be used as username.'),
556
- caseSensitive: z7.boolean().default(false).describe(
692
+ caseSensitive: z8.boolean().default(false).describe(
557
693
  "Specifies whether username case sensitivity will be enabled. When usernames and email addresses are case insensitive, users can sign in as the same user when they enter a different capitalization of their user name."
558
694
  )
559
695
  }).default({}).describe("The username policy."),
560
- password: z7.object({
561
- minLength: z7.number().int().min(6).max(99).default(12).describe("Required users to have at least the minimum password length."),
562
- uppercase: z7.boolean().default(true).describe("Required users to use at least one uppercase letter in their password."),
563
- lowercase: z7.boolean().default(true).describe("Required users to use at least one lowercase letter in their password."),
564
- numbers: z7.boolean().default(true).describe("Required users to use at least one number in their password."),
565
- symbols: z7.boolean().default(true).describe("Required users to use at least one symbol in their password."),
696
+ password: z8.object({
697
+ minLength: z8.number().int().min(6).max(99).default(12).describe("Required users to have at least the minimum password length."),
698
+ uppercase: z8.boolean().default(true).describe("Required users to use at least one uppercase letter in their password."),
699
+ lowercase: z8.boolean().default(true).describe("Required users to use at least one lowercase letter in their password."),
700
+ numbers: z8.boolean().default(true).describe("Required users to use at least one number in their password."),
701
+ symbols: z8.boolean().default(true).describe("Required users to use at least one symbol in their password."),
566
702
  temporaryPasswordValidity: DurationSchema.default("7 days").describe(
567
703
  "The duration a temporary password is valid. If the user doesn't sign in during this time, an administrator must reset their password."
568
704
  )
569
705
  }).default({}).describe("The password policy."),
570
- validity: z7.object({
706
+ validity: z8.object({
571
707
  idToken: DurationSchema.default("1 hour").describe(
572
708
  "The ID token time limit. After this limit expires, your user can't use their ID token."
573
709
  ),
@@ -583,18 +719,18 @@ var AuthDefaultSchema = z7.record(
583
719
  ).default({}).describe("Define the authenticatable users in your app.");
584
720
 
585
721
  // src/feature/domain/schema.ts
586
- import { z as z8 } from "zod";
587
- var DomainNameSchema = z8.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
722
+ import { z as z9 } from "zod";
723
+ var DomainNameSchema = z9.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
588
724
  "Enter a fully qualified domain name, for example, www.example.com. You can optionally include a trailing dot. If you omit the trailing dot, Amazon Route 53 assumes that the domain name that you specify is fully qualified. This means that Route 53 treats www.example.com (without a trailing dot) and www.example.com. (with a trailing dot) as identical."
589
725
  );
590
- var DNSTypeSchema = z8.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
726
+ var DNSTypeSchema = z9.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
591
727
  var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
592
- var RecordsSchema = z8.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
593
- var DomainsDefaultSchema = z8.record(
728
+ var RecordsSchema = z9.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
729
+ var DomainsDefaultSchema = z9.record(
594
730
  ResourceIdSchema,
595
- z8.object({
731
+ z9.object({
596
732
  domain: DomainNameSchema.describe("Define the domain name"),
597
- dns: z8.object({
733
+ dns: z9.object({
598
734
  name: DomainNameSchema.optional(),
599
735
  type: DNSTypeSchema,
600
736
  ttl: TTLSchema,
@@ -606,15 +742,15 @@ var DomainsDefaultSchema = z8.record(
606
742
  // src/feature/function/schema.ts
607
743
  import { days, minutes, seconds, toDays } from "@awsless/duration";
608
744
  import { gibibytes, mebibytes } from "@awsless/size";
609
- import { z as z13 } from "zod";
745
+ import { z as z14 } from "zod";
610
746
 
611
747
  // src/config/schema/local-directory.ts
612
748
  import { stat } from "fs/promises";
613
- import { z as z10 } from "zod";
749
+ import { z as z11 } from "zod";
614
750
 
615
751
  // src/config/schema/relative-path.ts
616
752
  import { join as join3 } from "path";
617
- import { z as z9 } from "zod";
753
+ import { z as z10 } from "zod";
618
754
  var basePath;
619
755
  var setLocalBasePath = (path) => {
620
756
  basePath = path;
@@ -625,10 +761,10 @@ var resolvePath = (path) => {
625
761
  }
626
762
  return path;
627
763
  };
628
- var RelativePathSchema = z9.string().transform((path) => resolvePath(path));
764
+ var RelativePathSchema = z10.string().transform((path) => resolvePath(path));
629
765
 
630
766
  // src/config/schema/local-directory.ts
631
- var LocalDirectorySchema = z10.union([
767
+ var LocalDirectorySchema = z11.union([
632
768
  RelativePathSchema.refine(async (path) => {
633
769
  try {
634
770
  const s = await stat(path);
@@ -637,7 +773,7 @@ var LocalDirectorySchema = z10.union([
637
773
  return false;
638
774
  }
639
775
  }, `Directory doesn't exist`),
640
- z10.object({
776
+ z11.object({
641
777
  nocheck: RelativePathSchema.describe(
642
778
  "Specifies a local directory without checking if the directory exists."
643
779
  )
@@ -646,8 +782,8 @@ var LocalDirectorySchema = z10.union([
646
782
 
647
783
  // src/config/schema/local-file.ts
648
784
  import { stat as stat2 } from "fs/promises";
649
- import { z as z11 } from "zod";
650
- var LocalFileSchema = z11.union([
785
+ import { z as z12 } from "zod";
786
+ var LocalFileSchema = z12.union([
651
787
  RelativePathSchema.refine(async (path) => {
652
788
  try {
653
789
  const s = await stat2(path);
@@ -656,15 +792,15 @@ var LocalFileSchema = z11.union([
656
792
  return false;
657
793
  }
658
794
  }, `File doesn't exist`),
659
- z11.object({
795
+ z12.object({
660
796
  nocheck: RelativePathSchema.describe("Specifies a local file without checking if the file exists.")
661
797
  }).transform((v) => v.nocheck)
662
798
  ]);
663
799
 
664
800
  // src/config/schema/size.ts
665
801
  import { parse as parse2 } from "@awsless/size";
666
- import { z as z12 } from "zod";
667
- var SizeSchema = z12.string().regex(/^[0-9]+ (B|KB|MB|GB|TB|PB)$/, "Invalid size").transform((v) => parse2(v));
802
+ import { z as z13 } from "zod";
803
+ var SizeSchema = z13.string().regex(/^[0-9]+ (B|KB|MB|GB|TB|PB)$/, "Invalid size").transform((v) => parse2(v));
668
804
  var sizeMin = (min) => {
669
805
  return (size) => {
670
806
  return size.value >= min.value;
@@ -687,32 +823,32 @@ var EphemeralStorageSizeSchema = SizeSchema.refine(
687
823
  sizeMin(mebibytes(512)),
688
824
  "Minimum ephemeral storage size is 512 MB"
689
825
  ).refine(sizeMax(gibibytes(10)), "Minimum ephemeral storage size is 10 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GB.");
690
- var ReservedConcurrentExecutionsSchema = z13.number().int().min(0).describe("The number of simultaneous executions to reserve for the function. You can specify a number from 0.");
691
- var EnvironmentSchema = z13.record(z13.string(), z13.string()).optional().describe("Environment variable key-value pairs.");
692
- var ArchitectureSchema = z13.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
693
- var RetryAttemptsSchema = z13.number().int().min(0).max(2).describe(
826
+ var ReservedConcurrentExecutionsSchema = z14.number().int().min(0).describe("The number of simultaneous executions to reserve for the function. You can specify a number from 0.");
827
+ var EnvironmentSchema = z14.record(z14.string(), z14.string()).optional().describe("Environment variable key-value pairs.");
828
+ var ArchitectureSchema = z14.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
829
+ var RetryAttemptsSchema = z14.number().int().min(0).max(2).describe(
694
830
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
695
831
  );
696
- var NodeRuntimeSchema = z13.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]);
697
- var ContainerRuntimeSchema = z13.literal("container");
698
- var RuntimeSchema = NodeRuntimeSchema.or(ContainerRuntimeSchema).or(z13.string()).describe("The identifier of the function's runtime.");
699
- var ActionSchema = z13.string();
700
- var ActionsSchema = z13.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
701
- var ArnSchema = z13.string().startsWith("arn:");
702
- var WildcardSchema = z13.literal("*");
703
- var ResourceSchema = z13.union([ArnSchema, WildcardSchema]);
704
- var ResourcesSchema = z13.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
705
- var PermissionSchema = z13.object({
706
- effect: z13.enum(["allow", "deny"]).default("allow"),
832
+ var NodeRuntimeSchema = z14.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]);
833
+ var ContainerRuntimeSchema = z14.literal("container");
834
+ var RuntimeSchema = NodeRuntimeSchema.or(ContainerRuntimeSchema).or(z14.string()).describe("The identifier of the function's runtime.");
835
+ var ActionSchema = z14.string();
836
+ var ActionsSchema = z14.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
837
+ var ArnSchema = z14.string().startsWith("arn:");
838
+ var WildcardSchema = z14.literal("*");
839
+ var ResourceSchema = z14.union([ArnSchema, WildcardSchema]);
840
+ var ResourcesSchema = z14.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
841
+ var PermissionSchema = z14.object({
842
+ effect: z14.enum(["allow", "deny"]).default("allow"),
707
843
  actions: ActionsSchema,
708
844
  resources: ResourcesSchema
709
845
  });
710
- var PermissionsSchema = z13.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
711
- var WarmSchema = z13.number().int().min(0).max(10).describe("Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10.");
712
- var VPCSchema = z13.boolean().describe("Put the function inside your global VPC.");
713
- var MinifySchema = z13.boolean().describe("Minify the function code.");
714
- var HandlerSchema = z13.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
715
- var DescriptionSchema = z13.string().describe("A description of the function.");
846
+ var PermissionsSchema = z14.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
847
+ var WarmSchema = z14.number().int().min(0).max(10).describe("Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10.");
848
+ var VPCSchema = z14.boolean().describe("Put the function inside your global VPC.");
849
+ var MinifySchema = z14.boolean().describe("Minify the function code.");
850
+ var HandlerSchema = z14.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
851
+ var DescriptionSchema = z14.string().describe("A description of the function.");
716
852
  var validLogRetentionDays = [
717
853
  ...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
718
854
  ...[180, 365, 400, 545, 731, 1096, 1827, 2192],
@@ -727,43 +863,43 @@ var LogRetentionSchema = DurationSchema.refine(
727
863
  },
728
864
  `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days6) => `${days6}`).join(", ")}`
729
865
  ).describe("The log retention duration.");
730
- var LogSchema = z13.union([
731
- z13.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
866
+ var LogSchema = z14.union([
867
+ z14.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
732
868
  LogRetentionSchema.transform((retention) => ({ retention })),
733
- z13.object({
869
+ z14.object({
734
870
  // subscription: LogSubscriptionSchema.optional(),
735
871
  retention: LogRetentionSchema.optional(),
736
- format: z13.enum(["text", "json"]).describe(
872
+ format: z14.enum(["text", "json"]).describe(
737
873
  `The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
738
874
  ).optional(),
739
- system: z13.enum(["debug", "info", "warn"]).describe(
875
+ system: z14.enum(["debug", "info", "warn"]).describe(
740
876
  "Set this property to filter the system logs for your function that Lambda sends to CloudWatch. Lambda only sends system logs at the selected level of detail and lower, where DEBUG is the highest level and WARN is the lowest."
741
877
  ).optional(),
742
- level: z13.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
878
+ level: z14.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
743
879
  "Set this property to filter the application logs for your function that Lambda sends to CloudWatch. Lambda only sends application logs at the selected level of detail and lower, where TRACE is the highest level and FATAL is the lowest."
744
880
  ).optional()
745
881
  })
746
882
  ]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
747
- var LayersSchema = z13.string().array().describe(
883
+ var LayersSchema = z14.string().array().describe(
748
884
  // `A list of function layers to add to the function's execution environment..`
749
885
  `A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.`
750
886
  );
751
- var FileCodeSchema = z13.object({
887
+ var FileCodeSchema = z14.object({
752
888
  file: LocalFileSchema.describe("The file path of the function code."),
753
889
  minify: MinifySchema.optional().default(true),
754
- external: z13.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`)
890
+ external: z14.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`)
755
891
  });
756
- var BundleCodeSchema = z13.object({
892
+ var BundleCodeSchema = z14.object({
757
893
  bundle: LocalDirectorySchema.describe("The directory that needs to be bundled.")
758
894
  });
759
- var CodeSchema = z13.union([
895
+ var CodeSchema = z14.union([
760
896
  LocalFileSchema.transform((file) => ({
761
897
  file
762
898
  })).pipe(FileCodeSchema),
763
899
  FileCodeSchema,
764
900
  BundleCodeSchema
765
901
  ]).describe("Specify the code of your function.");
766
- var FnSchema = z13.object({
902
+ var FnSchema = z14.object({
767
903
  code: CodeSchema,
768
904
  // node
769
905
  handler: HandlerSchema.optional(),
@@ -786,14 +922,14 @@ var FnSchema = z13.object({
786
922
  environment: EnvironmentSchema.optional(),
787
923
  permissions: PermissionsSchema.optional()
788
924
  });
789
- var FunctionSchema = z13.union([
925
+ var FunctionSchema = z14.union([
790
926
  LocalFileSchema.transform((code) => ({
791
927
  code
792
928
  })).pipe(FnSchema),
793
929
  FnSchema
794
930
  ]);
795
- var FunctionsSchema = z13.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
796
- var FunctionDefaultSchema = z13.object({
931
+ var FunctionsSchema = z14.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
932
+ var FunctionDefaultSchema = z14.object({
797
933
  runtime: RuntimeSchema.default("nodejs20.x"),
798
934
  // node
799
935
  handler: HandlerSchema.default("index.default"),
@@ -822,25 +958,25 @@ var FunctionDefaultSchema = z13.object({
822
958
  }).default({});
823
959
 
824
960
  // src/feature/layer/schema.ts
825
- import { z as z15 } from "zod";
961
+ import { z as z16 } from "zod";
826
962
 
827
963
  // src/config/schema/lambda.ts
828
- import { z as z14 } from "zod";
829
- var ArchitectureSchema2 = z14.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
830
- var NodeRuntimeSchema2 = z14.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]).describe("The identifier of the function's runtime.");
964
+ import { z as z15 } from "zod";
965
+ var ArchitectureSchema2 = z15.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
966
+ var NodeRuntimeSchema2 = z15.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]).describe("The identifier of the function's runtime.");
831
967
 
832
968
  // src/feature/layer/schema.ts
833
- var Schema = z15.object({
969
+ var Schema = z16.object({
834
970
  file: LocalFileSchema,
835
971
  runtimes: NodeRuntimeSchema2.array().optional(),
836
972
  architecture: ArchitectureSchema2.optional(),
837
- packages: z15.string().array().optional().describe(
973
+ packages: z16.string().array().optional().describe(
838
974
  "Define the package names that are available bundled in the layer. Those packages are not bundled while bundling the lambda."
839
975
  )
840
976
  });
841
- var LayerSchema = z15.record(
842
- z15.string(),
843
- z15.union([
977
+ var LayerSchema = z16.record(
978
+ z16.string(),
979
+ z16.union([
844
980
  LocalFileSchema.transform((file) => ({
845
981
  file,
846
982
  description: void 0
@@ -855,28 +991,28 @@ var OnFailureDefaultSchema = FunctionSchema.optional().describe(
855
991
  );
856
992
 
857
993
  // src/feature/on-log/schema.ts
858
- import { z as z16 } from "zod";
859
- var FilterSchema = z16.enum(["trace", "debug", "info", "warn", "error", "fatal"]).array().describe("The log level that will gets delivered to the consumer.");
860
- var OnLogDefaultSchema = z16.union([
994
+ import { z as z17 } from "zod";
995
+ var FilterSchema = z17.enum(["trace", "debug", "info", "warn", "error", "fatal"]).array().describe("The log level that will gets delivered to the consumer.");
996
+ var OnLogDefaultSchema = z17.union([
861
997
  FunctionSchema.transform((consumer) => ({
862
998
  consumer,
863
999
  filter: ["error", "fatal"]
864
1000
  })),
865
- z16.object({
1001
+ z17.object({
866
1002
  consumer: FunctionSchema,
867
1003
  filter: FilterSchema
868
1004
  })
869
1005
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
870
1006
 
871
1007
  // src/feature/pubsub/schema.ts
872
- import { z as z17 } from "zod";
1008
+ import { z as z18 } from "zod";
873
1009
  var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
874
- var PubSubDefaultSchema = z17.record(
1010
+ var PubSubDefaultSchema = z18.record(
875
1011
  ResourceIdSchema,
876
- z17.object({
1012
+ z18.object({
877
1013
  auth: FunctionSchema,
878
1014
  domain: DomainSchema.optional(),
879
- subDomain: z17.string().optional()
1015
+ subDomain: z18.string().optional()
880
1016
  // auth: z.union([
881
1017
  // ResourceIdSchema,
882
1018
  // z.object({
@@ -892,11 +1028,11 @@ var PubSubDefaultSchema = z17.record(
892
1028
  // .optional(),
893
1029
  })
894
1030
  ).optional().describe("Define the pubsub subscriber in your stack.");
895
- var PubSubSchema = z17.record(
1031
+ var PubSubSchema = z18.record(
896
1032
  ResourceIdSchema,
897
- z17.object({
898
- sql: z17.string().describe("The SQL statement used to query the IOT topic."),
899
- sqlVersion: z17.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
1033
+ z18.object({
1034
+ sql: z18.string().describe("The SQL statement used to query the IOT topic."),
1035
+ sqlVersion: z18.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
900
1036
  consumer: FunctionSchema.describe("The consuming lambda function properties.")
901
1037
  })
902
1038
  ).optional().describe("Define the pubsub subscriber in your stack.");
@@ -904,7 +1040,7 @@ var PubSubSchema = z17.record(
904
1040
  // src/feature/queue/schema.ts
905
1041
  import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
906
1042
  import { kibibytes } from "@awsless/size";
907
- import { z as z18 } from "zod";
1043
+ import { z as z19 } from "zod";
908
1044
  var RetentionPeriodSchema = DurationSchema.refine(
909
1045
  durationMin(minutes2(1)),
910
1046
  "Minimum retention period is 1 minute"
@@ -932,10 +1068,10 @@ var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
932
1068
  var MaxMessageSizeSchema = SizeSchema.refine(sizeMin(kibibytes(1)), "Minimum max message size is 1 KB").refine(sizeMax(kibibytes(256)), "Maximum max message size is 256 KB").describe(
933
1069
  "The limit of how many bytes that a message can contain before Amazon SQS rejects it. You can specify an size from 1 KB to 256 KB."
934
1070
  );
935
- var BatchSizeSchema = z18.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000").describe(
1071
+ var BatchSizeSchema = z19.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000").describe(
936
1072
  "The maximum number of records in each batch that Lambda pulls from your queue and sends to your function. Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB). You can specify an integer from 1 to 10000."
937
1073
  );
938
- var MaxConcurrencySchema = z18.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000").describe(
1074
+ var MaxConcurrencySchema = z19.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000").describe(
939
1075
  "Limits the number of concurrent instances that the queue worker can invoke. You can specify an integer from 2 to 1000."
940
1076
  );
941
1077
  var MaxBatchingWindow = DurationSchema.refine(
@@ -944,7 +1080,7 @@ var MaxBatchingWindow = DurationSchema.refine(
944
1080
  ).describe(
945
1081
  "The maximum amount of time, that Lambda spends gathering records before invoking the function. You can specify an duration from 0 seconds to 5 minutes."
946
1082
  );
947
- var QueueDefaultSchema = z18.object({
1083
+ var QueueDefaultSchema = z19.object({
948
1084
  retentionPeriod: RetentionPeriodSchema.default("7 days"),
949
1085
  visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
950
1086
  deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
@@ -954,7 +1090,7 @@ var QueueDefaultSchema = z18.object({
954
1090
  maxConcurrency: MaxConcurrencySchema.optional(),
955
1091
  maxBatchingWindow: MaxBatchingWindow.optional()
956
1092
  }).default({});
957
- var QueueSchema = z18.object({
1093
+ var QueueSchema = z19.object({
958
1094
  consumer: FunctionSchema.describe("The consuming lambda function properties."),
959
1095
  retentionPeriod: RetentionPeriodSchema.optional(),
960
1096
  visibilityTimeout: VisibilityTimeoutSchema.optional(),
@@ -965,9 +1101,9 @@ var QueueSchema = z18.object({
965
1101
  maxConcurrency: MaxConcurrencySchema.optional(),
966
1102
  maxBatchingWindow: MaxBatchingWindow.optional()
967
1103
  });
968
- var QueuesSchema = z18.record(
1104
+ var QueuesSchema = z19.record(
969
1105
  ResourceIdSchema,
970
- z18.union([
1106
+ z19.union([
971
1107
  LocalFileSchema.transform((consumer) => ({
972
1108
  consumer
973
1109
  })).pipe(QueueSchema),
@@ -976,26 +1112,26 @@ var QueuesSchema = z18.record(
976
1112
  ).optional().describe("Define the queues in your stack.");
977
1113
 
978
1114
  // src/feature/rest/schema.ts
979
- import { z as z20 } from "zod";
1115
+ import { z as z21 } from "zod";
980
1116
 
981
1117
  // src/config/schema/route.ts
982
- import { z as z19 } from "zod";
983
- var RouteSchema = z19.union([
984
- z19.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS|ANY)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
985
- z19.literal("$default")
1118
+ import { z as z20 } from "zod";
1119
+ var RouteSchema = z20.union([
1120
+ z20.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS|ANY)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
1121
+ z20.literal("$default")
986
1122
  ]);
987
1123
 
988
1124
  // src/feature/rest/schema.ts
989
- var RestDefaultSchema = z20.record(
1125
+ var RestDefaultSchema = z21.record(
990
1126
  ResourceIdSchema,
991
- z20.object({
1127
+ z21.object({
992
1128
  domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
993
- subDomain: z20.string().optional()
1129
+ subDomain: z21.string().optional()
994
1130
  })
995
1131
  ).optional().describe("Define your global REST API's.");
996
- var RestSchema = z20.record(
1132
+ var RestSchema = z21.record(
997
1133
  ResourceIdSchema,
998
- z20.record(
1134
+ z21.record(
999
1135
  RouteSchema.describe(
1000
1136
  [
1001
1137
  "The REST API route that is comprised by the http method and http path.",
@@ -1008,7 +1144,7 @@ var RestSchema = z20.record(
1008
1144
  ).optional().describe("Define routes in your stack for your global REST API.");
1009
1145
 
1010
1146
  // src/feature/rpc/schema.ts
1011
- import { z as z21 } from "zod";
1147
+ import { z as z22 } from "zod";
1012
1148
  import { minutes as minutes3, seconds as seconds3 } from "@awsless/duration";
1013
1149
  var TimeoutSchema2 = DurationSchema.refine(durationMin(seconds3(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes3(5)), "Maximum timeout duration is 5 minutes").describe(
1014
1150
  [
@@ -1017,21 +1153,21 @@ var TimeoutSchema2 = DurationSchema.refine(durationMin(seconds3(10)), "Minimum t
1017
1153
  "The timeouts of all inner RPC functions will be capped at 80% of this timeout."
1018
1154
  ].join(" ")
1019
1155
  );
1020
- var RpcDefaultSchema = z21.record(
1156
+ var RpcDefaultSchema = z22.record(
1021
1157
  ResourceIdSchema,
1022
- z21.object({
1158
+ z22.object({
1023
1159
  domain: ResourceIdSchema.describe("The domain id to link your RPC API with.").optional(),
1024
- subDomain: z21.string().optional(),
1160
+ subDomain: z22.string().optional(),
1025
1161
  auth: FunctionSchema.optional(),
1026
1162
  log: LogSchema.optional(),
1027
1163
  timeout: TimeoutSchema2.default("1 minutes"),
1028
- geoRestrictions: z21.array(z21.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
1164
+ geoRestrictions: z22.array(z22.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
1029
1165
  })
1030
1166
  ).describe(`Define the global RPC API's.`).optional();
1031
- var RpcSchema = z21.record(ResourceIdSchema, z21.record(z21.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1167
+ var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1032
1168
 
1033
1169
  // src/config/schema/region.ts
1034
- import { z as z22 } from "zod";
1170
+ import { z as z23 } from "zod";
1035
1171
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
1036
1172
  var AF = ["af-south-1"];
1037
1173
  var AP = [
@@ -1060,16 +1196,16 @@ var EU = [
1060
1196
  var ME = ["me-south-1", "me-central-1"];
1061
1197
  var SA = ["sa-east-1"];
1062
1198
  var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
1063
- var RegionSchema = z22.enum(regions);
1199
+ var RegionSchema = z23.enum(regions);
1064
1200
 
1065
1201
  // src/config/app.ts
1066
- var AppSchema = z23.object({
1067
- $schema: z23.string().optional(),
1202
+ var AppSchema = z24.object({
1203
+ $schema: z24.string().optional(),
1068
1204
  name: ResourceIdSchema.describe("App name."),
1069
1205
  region: RegionSchema.describe("The AWS region to deploy to."),
1070
- profile: z23.string().describe("The AWS profile to deploy to."),
1071
- protect: z23.boolean().default(false).describe("Protect your app & stacks from being deleted."),
1072
- removal: z23.enum(["remove", "retain"]).default("remove").describe(
1206
+ profile: z24.string().describe("The AWS profile to deploy to."),
1207
+ protect: z24.boolean().default(false).describe("Protect your app & stacks from being deleted."),
1208
+ removal: z24.enum(["remove", "retain"]).default("remove").describe(
1073
1209
  [
1074
1210
  "Configure how your resources are handled when they have to be removed.",
1075
1211
  "",
@@ -1083,7 +1219,7 @@ var AppSchema = z23.object({
1083
1219
  // .default('prod')
1084
1220
  // .describe('The deployment stage.'),
1085
1221
  // onFailure: OnFailureSchema,
1086
- defaults: z23.object({
1222
+ defaults: z24.object({
1087
1223
  onFailure: OnFailureDefaultSchema,
1088
1224
  onLog: OnLogDefaultSchema,
1089
1225
  auth: AuthDefaultSchema,
@@ -1105,11 +1241,11 @@ var AppSchema = z23.object({
1105
1241
  });
1106
1242
 
1107
1243
  // src/config/stack.ts
1108
- import { z as z37 } from "zod";
1244
+ import { z as z38 } from "zod";
1109
1245
 
1110
1246
  // src/feature/cache/schema.ts
1111
1247
  import { gibibytes as gibibytes2 } from "@awsless/size";
1112
- import { z as z24 } from "zod";
1248
+ import { z as z25 } from "zod";
1113
1249
  var StorageSchema = SizeSchema.refine(sizeMin(gibibytes2(1)), "Minimum storage size is 1 GB").refine(
1114
1250
  sizeMax(gibibytes2(5e3)),
1115
1251
  "Maximum storage size is 5000 GB"
@@ -1120,31 +1256,31 @@ var MinimumStorageSchema = StorageSchema.describe(
1120
1256
  var MaximumStorageSchema = StorageSchema.describe(
1121
1257
  "The upper limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
1122
1258
  );
1123
- var EcpuSchema = z24.number().int().min(1e3).max(15e6);
1259
+ var EcpuSchema = z25.number().int().min(1e3).max(15e6);
1124
1260
  var MinimumEcpuSchema = EcpuSchema.describe(
1125
1261
  "The minimum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1126
1262
  );
1127
1263
  var MaximumEcpuSchema = EcpuSchema.describe(
1128
1264
  "The maximum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1129
1265
  );
1130
- var CachesSchema = z24.record(
1266
+ var CachesSchema = z25.record(
1131
1267
  ResourceIdSchema,
1132
- z24.object({
1268
+ z25.object({
1133
1269
  minStorage: MinimumStorageSchema.optional(),
1134
1270
  maxStorage: MaximumStorageSchema.optional(),
1135
1271
  minECPU: MinimumEcpuSchema.optional(),
1136
1272
  maxECPU: MaximumEcpuSchema.optional(),
1137
- snapshotRetentionLimit: z24.number().int().positive().default(1)
1273
+ snapshotRetentionLimit: z25.number().int().positive().default(1)
1138
1274
  })
1139
1275
  ).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
1140
1276
 
1141
1277
  // src/feature/command/schema.ts
1142
- import { z as z25 } from "zod";
1143
- var CommandSchema = z25.union([
1144
- z25.object({
1278
+ import { z as z26 } from "zod";
1279
+ var CommandSchema = z26.union([
1280
+ z26.object({
1145
1281
  file: LocalFileSchema,
1146
- handler: z25.string().default("default").describe("The name of the handler that needs to run"),
1147
- description: z25.string().optional().describe("A description of the command")
1282
+ handler: z26.string().default("default").describe("The name of the handler that needs to run"),
1283
+ description: z26.string().optional().describe("A description of the command")
1148
1284
  // options: z.record(ResourceIdSchema, OptionSchema).optional(),
1149
1285
  // arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
1150
1286
  }),
@@ -1154,22 +1290,22 @@ var CommandSchema = z25.union([
1154
1290
  description: void 0
1155
1291
  }))
1156
1292
  ]);
1157
- var CommandsSchema = z25.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
1293
+ var CommandsSchema = z26.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
1158
1294
 
1159
1295
  // src/feature/config/schema.ts
1160
- import { z as z26 } from "zod";
1161
- var ConfigNameSchema = z26.string().regex(/[a-z0-9\-]/g, "Invalid config name");
1162
- var ConfigsSchema = z26.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
1296
+ import { z as z27 } from "zod";
1297
+ var ConfigNameSchema = z27.string().regex(/[a-z0-9\-]/g, "Invalid config name");
1298
+ var ConfigsSchema = z27.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
1163
1299
 
1164
1300
  // src/feature/cron/schema/index.ts
1165
- import { z as z28 } from "zod";
1301
+ import { z as z29 } from "zod";
1166
1302
 
1167
1303
  // src/feature/cron/schema/schedule.ts
1168
- import { z as z27 } from "zod";
1304
+ import { z as z28 } from "zod";
1169
1305
  import { awsCronExpressionValidator } from "aws-cron-expression-validator";
1170
- var RateExpressionSchema = z27.custom(
1306
+ var RateExpressionSchema = z28.custom(
1171
1307
  (value) => {
1172
- return z27.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
1308
+ return z28.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
1173
1309
  const [str] = rate.split(" ");
1174
1310
  const number = parseInt(str);
1175
1311
  return number > 0;
@@ -1185,9 +1321,9 @@ var RateExpressionSchema = z27.custom(
1185
1321
  }
1186
1322
  return `rate(${rate})`;
1187
1323
  });
1188
- var CronExpressionSchema = z27.custom(
1324
+ var CronExpressionSchema = z28.custom(
1189
1325
  (value) => {
1190
- return z27.string().safeParse(value).success;
1326
+ return z28.string().safeParse(value).success;
1191
1327
  },
1192
1328
  { message: "Invalid cron expression" }
1193
1329
  ).superRefine((value, ctx) => {
@@ -1196,12 +1332,12 @@ var CronExpressionSchema = z27.custom(
1196
1332
  } catch (error) {
1197
1333
  if (error instanceof Error) {
1198
1334
  ctx.addIssue({
1199
- code: z27.ZodIssueCode.custom,
1335
+ code: z28.ZodIssueCode.custom,
1200
1336
  message: `Invalid cron expression: ${error.message}`
1201
1337
  });
1202
1338
  } else {
1203
1339
  ctx.addIssue({
1204
- code: z27.ZodIssueCode.custom,
1340
+ code: z28.ZodIssueCode.custom,
1205
1341
  message: "Invalid cron expression"
1206
1342
  });
1207
1343
  }
@@ -1212,23 +1348,23 @@ var CronExpressionSchema = z27.custom(
1212
1348
  var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
1213
1349
 
1214
1350
  // src/feature/cron/schema/index.ts
1215
- var CronsSchema = z28.record(
1351
+ var CronsSchema = z29.record(
1216
1352
  ResourceIdSchema,
1217
- z28.object({
1218
- enabled: z28.boolean().default(true).describe("If the cron is enabled."),
1353
+ z29.object({
1354
+ enabled: z29.boolean().default(true).describe("If the cron is enabled."),
1219
1355
  consumer: FunctionSchema.describe("The consuming lambda function properties."),
1220
1356
  schedule: ScheduleExpressionSchema.describe(
1221
1357
  'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
1222
1358
  ),
1223
- payload: z28.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
1359
+ payload: z29.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
1224
1360
  })
1225
1361
  ).optional().describe(`Define the cron jobs in your stack.`);
1226
1362
 
1227
1363
  // src/feature/search/schema.ts
1228
1364
  import { gibibytes as gibibytes3 } from "@awsless/size";
1229
- import { z as z29 } from "zod";
1230
- var VersionSchema = z29.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
1231
- var TypeSchema = z29.enum([
1365
+ import { z as z30 } from "zod";
1366
+ var VersionSchema = z30.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
1367
+ var TypeSchema = z30.enum([
1232
1368
  "t3.small",
1233
1369
  "t3.medium",
1234
1370
  "m3.medium",
@@ -1303,11 +1439,11 @@ var TypeSchema = z29.enum([
1303
1439
  "r6gd.16xlarge"
1304
1440
  ]);
1305
1441
  var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes3(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes3(100)), "Maximum storage size is 100 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GiB.");
1306
- var SearchsSchema = z29.record(
1442
+ var SearchsSchema = z30.record(
1307
1443
  ResourceIdSchema,
1308
- z29.object({
1444
+ z30.object({
1309
1445
  type: TypeSchema.default("t3.small"),
1310
- count: z29.number().int().min(1).default(1),
1446
+ count: z30.number().int().min(1).default(1),
1311
1447
  version: VersionSchema.default("2.13"),
1312
1448
  storage: StorageSizeSchema.default("10 GB")
1313
1449
  // vpc: z.boolean().default(false),
@@ -1315,12 +1451,12 @@ var SearchsSchema = z29.record(
1315
1451
  ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
1316
1452
 
1317
1453
  // src/feature/site/schema.ts
1318
- import { z as z31 } from "zod";
1454
+ import { z as z32 } from "zod";
1319
1455
 
1320
1456
  // src/config/schema/local-entry.ts
1321
1457
  import { stat as stat3 } from "fs/promises";
1322
- import { z as z30 } from "zod";
1323
- var LocalEntrySchema = z30.union([
1458
+ import { z as z31 } from "zod";
1459
+ var LocalEntrySchema = z31.union([
1324
1460
  RelativePathSchema.refine(async (path) => {
1325
1461
  try {
1326
1462
  const s = await stat3(path);
@@ -1329,7 +1465,7 @@ var LocalEntrySchema = z30.union([
1329
1465
  return false;
1330
1466
  }
1331
1467
  }, `File or directory doesn't exist`),
1332
- z30.object({
1468
+ z31.object({
1333
1469
  nocheck: RelativePathSchema.describe(
1334
1470
  "Specifies a local file or directory without checking if the file or directory exists."
1335
1471
  )
@@ -1337,14 +1473,14 @@ var LocalEntrySchema = z30.union([
1337
1473
  ]);
1338
1474
 
1339
1475
  // src/feature/site/schema.ts
1340
- var ErrorResponsePathSchema = z31.string().describe(
1476
+ var ErrorResponsePathSchema = z32.string().describe(
1341
1477
  [
1342
1478
  "The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.",
1343
1479
  "- We recommend that you store custom error pages in an Amazon S3 bucket.",
1344
1480
  "If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable."
1345
1481
  ].join("\n")
1346
1482
  );
1347
- var StatusCodeSchema = z31.number().int().positive().optional().describe(
1483
+ var StatusCodeSchema = z32.number().int().positive().optional().describe(
1348
1484
  [
1349
1485
  "The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.",
1350
1486
  "There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:",
@@ -1357,19 +1493,19 @@ var StatusCodeSchema = z31.number().int().positive().optional().describe(
1357
1493
  var MinTTLSchema = DurationSchema.describe(
1358
1494
  "The minimum amount of time, that you want to cache the error response. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available."
1359
1495
  );
1360
- var ErrorResponseSchema = z31.union([
1496
+ var ErrorResponseSchema = z32.union([
1361
1497
  ErrorResponsePathSchema,
1362
- z31.object({
1498
+ z32.object({
1363
1499
  path: ErrorResponsePathSchema,
1364
1500
  statusCode: StatusCodeSchema.optional(),
1365
1501
  minTTL: MinTTLSchema.optional()
1366
1502
  })
1367
1503
  ]).optional();
1368
- var SitesSchema = z31.record(
1504
+ var SitesSchema = z32.record(
1369
1505
  ResourceIdSchema,
1370
- z31.object({
1506
+ z32.object({
1371
1507
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1372
- subDomain: z31.string().optional(),
1508
+ subDomain: z32.string().optional(),
1373
1509
  // bind: z
1374
1510
  // .object({
1375
1511
  // auth: z.array(ResourceIdSchema),
@@ -1378,20 +1514,23 @@ var SitesSchema = z31.record(
1378
1514
  // // rest: z.array(ResourceIdSchema),
1379
1515
  // })
1380
1516
  // .optional(),
1381
- build: z31.object({
1382
- command: z31.string().describe(
1517
+ build: z32.object({
1518
+ command: z32.string().describe(
1383
1519
  `Specifies the files and directories to generate the cache key for your custom build command.`
1384
1520
  ),
1385
- cacheKey: z31.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1521
+ cacheKey: z32.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1386
1522
  `Specifies the files and directories to generate the cache key for your custom build command.`
1387
1523
  )
1388
1524
  }).optional().describe(`Specifies the build process for sites that need a build step.`),
1389
- static: z31.union([LocalDirectorySchema, z31.boolean()]).optional().describe(
1525
+ static: z32.union([LocalDirectorySchema, z32.boolean()]).optional().describe(
1390
1526
  "Specifies the path to the static files directory. Additionally you can also pass `true` when you don't have local static files, but still want to make an S3 bucket."
1391
1527
  ),
1392
1528
  ssr: FunctionSchema.optional().describe("Specifies the file that will render the site on the server."),
1393
1529
  // envPrefix: z.string().optional().describe('Specifies a prefix for all '),
1394
- origin: z31.enum(["ssr-first", "static-first"]).default("static-first").describe("Specifies the origin fallback ordering."),
1530
+ // origin: z
1531
+ // .enum(['ssr-first', 'static-first'])
1532
+ // .default('static-first')
1533
+ // .describe('Specifies the origin fallback ordering.'),
1395
1534
  // bind: z.object({
1396
1535
  // auth:
1397
1536
  // h
@@ -1404,15 +1543,18 @@ var SitesSchema = z31.record(
1404
1543
  // build: z.string().optional(),
1405
1544
  // }),
1406
1545
  // ]),
1407
- geoRestrictions: z31.array(z31.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1408
- forwardHost: z31.boolean().default(false).describe(
1409
- [
1410
- "Specify if the original `host` header should be forwarded to the SSR function.",
1411
- "The original `host` header will be forwarded as `x-forwarded-host`.",
1412
- "Keep in mind that this requires an extra CloudFront Function."
1413
- ].join("\n")
1414
- ),
1415
- errors: z31.object({
1546
+ geoRestrictions: z32.array(z32.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1547
+ // forwardHost: z
1548
+ // .boolean()
1549
+ // .default(false)
1550
+ // .describe(
1551
+ // [
1552
+ // 'Specify if the original `host` header should be forwarded to the SSR function.',
1553
+ // 'The original `host` header will be forwarded as `x-forwarded-host`.',
1554
+ // 'Keep in mind that this requires an extra CloudFront Function.',
1555
+ // ].join('\n')
1556
+ // ),
1557
+ errors: z32.object({
1416
1558
  400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
1417
1559
  403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
1418
1560
  404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
@@ -1425,16 +1567,16 @@ var SitesSchema = z31.record(
1425
1567
  503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
1426
1568
  504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
1427
1569
  }).optional().describe("Customize the error responses for specific HTTP status codes."),
1428
- cors: z31.object({
1429
- override: z31.boolean().default(false),
1570
+ cors: z32.object({
1571
+ override: z32.boolean().default(false),
1430
1572
  maxAge: DurationSchema.default("365 days"),
1431
- exposeHeaders: z31.string().array().optional(),
1432
- credentials: z31.boolean().default(false),
1433
- headers: z31.string().array().default(["*"]),
1434
- origins: z31.string().array().default(["*"]),
1435
- methods: z31.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1573
+ exposeHeaders: z32.string().array().optional(),
1574
+ credentials: z32.boolean().default(false),
1575
+ headers: z32.string().array().default(["*"]),
1576
+ origins: z32.string().array().default(["*"]),
1577
+ methods: z32.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1436
1578
  }).optional().describe("Specify the cors headers."),
1437
- security: z31.object({
1579
+ security: z32.object({
1438
1580
  // contentSecurityPolicy: z.object({
1439
1581
  // override: z.boolean().default(false),
1440
1582
  // policy: z.string(),
@@ -1476,10 +1618,10 @@ var SitesSchema = z31.record(
1476
1618
  // reportUri?: string
1477
1619
  // }
1478
1620
  }).optional().describe("Specify the security policy."),
1479
- cache: z31.object({
1480
- cookies: z31.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1481
- headers: z31.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1482
- queries: z31.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1621
+ cache: z32.object({
1622
+ cookies: z32.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1623
+ headers: z32.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1624
+ queries: z32.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1483
1625
  }).optional().describe(
1484
1626
  "Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
1485
1627
  )
@@ -1487,22 +1629,22 @@ var SitesSchema = z31.record(
1487
1629
  ).optional().describe("Define the sites in your stack.");
1488
1630
 
1489
1631
  // src/feature/store/schema.ts
1490
- import { z as z32 } from "zod";
1491
- var StoresSchema = z32.union([
1492
- z32.array(ResourceIdSchema).transform((list4) => {
1632
+ import { z as z33 } from "zod";
1633
+ var StoresSchema = z33.union([
1634
+ z33.array(ResourceIdSchema).transform((list4) => {
1493
1635
  const stores = {};
1494
1636
  for (const key of list4) {
1495
1637
  stores[key] = {};
1496
1638
  }
1497
1639
  return stores;
1498
1640
  }),
1499
- z32.record(
1641
+ z33.record(
1500
1642
  ResourceIdSchema,
1501
- z32.object({
1643
+ z33.object({
1502
1644
  // cors: CorsSchema,
1503
1645
  // deletionProtection: DeletionProtectionSchema.optional(),
1504
- versioning: z32.boolean().default(false).describe("Enable versioning of your store."),
1505
- events: z32.object({
1646
+ versioning: z33.boolean().default(false).describe("Enable versioning of your store."),
1647
+ events: z33.object({
1506
1648
  // create
1507
1649
  "created:*": FunctionSchema.optional().describe(
1508
1650
  "Subscribe to notifications regardless of the API that was used to create an object."
@@ -1536,22 +1678,22 @@ var StoresSchema = z32.union([
1536
1678
 
1537
1679
  // src/feature/table/schema.ts
1538
1680
  import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
1539
- import { z as z33 } from "zod";
1540
- var KeySchema = z33.string().min(1).max(255);
1541
- var TablesSchema = z33.record(
1681
+ import { z as z34 } from "zod";
1682
+ var KeySchema = z34.string().min(1).max(255);
1683
+ var TablesSchema = z34.record(
1542
1684
  ResourceIdSchema,
1543
- z33.object({
1685
+ z34.object({
1544
1686
  hash: KeySchema.describe(
1545
1687
  "Specifies the name of the partition / hash key that makes up the primary key for the table."
1546
1688
  ),
1547
1689
  sort: KeySchema.optional().describe(
1548
1690
  "Specifies the name of the range / sort key that makes up the primary key for the table."
1549
1691
  ),
1550
- fields: z33.record(z33.string(), z33.enum(["string", "number", "binary"])).optional().describe(
1692
+ fields: z34.record(z34.string(), z34.enum(["string", "number", "binary"])).optional().describe(
1551
1693
  'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
1552
1694
  ),
1553
- class: z33.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1554
- pointInTimeRecovery: z33.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1695
+ class: z34.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1696
+ pointInTimeRecovery: z34.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1555
1697
  ttl: KeySchema.optional().describe(
1556
1698
  [
1557
1699
  "The name of the TTL attribute used to store the expiration time for items in the table.",
@@ -1559,8 +1701,8 @@ var TablesSchema = z33.record(
1559
1701
  ].join("\n")
1560
1702
  ),
1561
1703
  // deletionProtection: DeletionProtectionSchema.optional(),
1562
- stream: z33.object({
1563
- type: z33.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1704
+ stream: z34.object({
1705
+ type: z34.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1564
1706
  [
1565
1707
  "When an item in the table is modified, you can determines what information is written to the stream for this table.",
1566
1708
  "Valid values are:",
@@ -1570,7 +1712,7 @@ var TablesSchema = z33.record(
1570
1712
  "- new-and-old-images - Both the new and the old item images of the item are written to the stream."
1571
1713
  ].join("\n")
1572
1714
  ),
1573
- batchSize: z33.number().min(1).max(1e4).default(1).describe(
1715
+ batchSize: z34.number().min(1).max(1e4).default(1).describe(
1574
1716
  [
1575
1717
  "The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
1576
1718
  "Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).",
@@ -1600,7 +1742,7 @@ var TablesSchema = z33.record(
1600
1742
  // 'You can specify a number from -1 to 10000.',
1601
1743
  // ].join('\n')
1602
1744
  // ),
1603
- retryAttempts: z33.number().min(-1).max(1e4).default(-1).describe(
1745
+ retryAttempts: z34.number().min(-1).max(1e4).default(-1).describe(
1604
1746
  [
1605
1747
  "Discard records after the specified number of retries.",
1606
1748
  "The default value is -1, which sets the maximum number of retries to infinite.",
@@ -1608,7 +1750,7 @@ var TablesSchema = z33.record(
1608
1750
  "You can specify a number from -1 to 10000."
1609
1751
  ].join("\n")
1610
1752
  ),
1611
- concurrencyPerShard: z33.number().min(1).max(10).default(1).describe(
1753
+ concurrencyPerShard: z34.number().min(1).max(10).default(1).describe(
1612
1754
  [
1613
1755
  "The number of batches to process concurrently from each shard.",
1614
1756
  "You can specify a number from 1 to 10."
@@ -1618,16 +1760,16 @@ var TablesSchema = z33.record(
1618
1760
  }).optional().describe(
1619
1761
  "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
1620
1762
  ),
1621
- indexes: z33.record(
1622
- z33.string(),
1623
- z33.object({
1763
+ indexes: z34.record(
1764
+ z34.string(),
1765
+ z34.object({
1624
1766
  hash: KeySchema.describe(
1625
1767
  "Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
1626
1768
  ),
1627
1769
  sort: KeySchema.optional().describe(
1628
1770
  "Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
1629
1771
  ),
1630
- projection: z33.enum(["all", "keys-only"]).default("all").describe(
1772
+ projection: z34.enum(["all", "keys-only"]).default("all").describe(
1631
1773
  [
1632
1774
  "The set of attributes that are projected into the index:",
1633
1775
  "- all - All of the table attributes are projected into the index.",
@@ -1641,11 +1783,11 @@ var TablesSchema = z33.record(
1641
1783
  ).optional().describe("Define the tables in your stack.");
1642
1784
 
1643
1785
  // src/feature/task/schema.ts
1644
- import { z as z34 } from "zod";
1645
- var RetryAttemptsSchema2 = z34.number().int().min(0).max(2).describe(
1786
+ import { z as z35 } from "zod";
1787
+ var RetryAttemptsSchema2 = z35.number().int().min(0).max(2).describe(
1646
1788
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
1647
1789
  );
1648
- var TaskSchema = z34.union([
1790
+ var TaskSchema = z35.union([
1649
1791
  LocalFileSchema.transform((file) => ({
1650
1792
  consumer: {
1651
1793
  code: {
@@ -1656,33 +1798,33 @@ var TaskSchema = z34.union([
1656
1798
  },
1657
1799
  retryAttempts: void 0
1658
1800
  })),
1659
- z34.object({
1801
+ z35.object({
1660
1802
  consumer: FunctionSchema,
1661
1803
  retryAttempts: RetryAttemptsSchema2.optional()
1662
1804
  })
1663
1805
  ]);
1664
- var TasksSchema = z34.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1806
+ var TasksSchema = z35.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1665
1807
 
1666
1808
  // src/feature/test/schema.ts
1667
- import { z as z35 } from "zod";
1668
- var TestsSchema = z35.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1809
+ import { z as z36 } from "zod";
1810
+ var TestsSchema = z36.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1669
1811
 
1670
1812
  // src/feature/topic/schema.ts
1671
1813
  import { kebabCase as kebabCase3 } from "change-case";
1672
- import { z as z36 } from "zod";
1673
- var TopicNameSchema = z36.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
1674
- var TopicsSchema = z36.array(TopicNameSchema).refine((topics) => {
1814
+ import { z as z37 } from "zod";
1815
+ var TopicNameSchema = z37.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
1816
+ var TopicsSchema = z37.array(TopicNameSchema).refine((topics) => {
1675
1817
  return topics.length === new Set(topics).size;
1676
1818
  }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
1677
- var SubscribersSchema = z36.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1819
+ var SubscribersSchema = z37.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1678
1820
 
1679
1821
  // src/config/stack.ts
1680
1822
  var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
1681
1823
  var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
1682
1824
  message: `Stack name can't be a reserved name.`
1683
1825
  }).describe("Stack name.");
1684
- var StackSchema = z37.object({
1685
- $schema: z37.string().optional(),
1826
+ var StackSchema = z38.object({
1827
+ $schema: z38.string().optional(),
1686
1828
  name: NameSchema,
1687
1829
  depends: DependsSchema,
1688
1830
  commands: CommandsSchema,
@@ -1749,13 +1891,13 @@ var readConfigWithStage = async (file, stage) => {
1749
1891
  };
1750
1892
 
1751
1893
  // src/config/load/validate.ts
1752
- import { z as z38 } from "zod";
1894
+ import { z as z39 } from "zod";
1753
1895
  var validateConfig = async (schema, file, data) => {
1754
1896
  try {
1755
1897
  const result = await schema.parseAsync(data);
1756
1898
  return result;
1757
1899
  } catch (error) {
1758
- if (error instanceof z38.ZodError) {
1900
+ if (error instanceof z39.ZodError) {
1759
1901
  throw new ConfigError(file, error, data);
1760
1902
  }
1761
1903
  throw error;
@@ -4396,20 +4538,140 @@ var getCacheControl = (file) => {
4396
4538
  var getContentType = (file) => {
4397
4539
  return contentType(extname2(file)) || "text/html; charset=utf-8";
4398
4540
  };
4399
- var getForwardHostFunctionCode = () => {
4400
- return [
4401
- "function handler(event) {",
4402
- "const request = event.request",
4403
- "const headers = request.headers",
4404
- "const host = request.headers.host.value",
4405
- 'headers["x-forwarded-host"] = { value: host }',
4406
- "return request",
4407
- "}"
4408
- ].join("\n");
4541
+ var getViewerRequestFunctionCode = (domain2, bucket, functionUrl) => {
4542
+ return $resolve([bucket?.bucketRegionalDomainName, functionUrl?.functionUrl], (bucketDomain, lambdaUrl) => {
4543
+ return CF_FUNC_WRAP([
4544
+ // --------------------------------------------------------
4545
+ // Block direct access to cloudfront.
4546
+ domain2 ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
4547
+ // --------------------------------------------------------
4548
+ // Define functions.
4549
+ bucketDomain ? GET_PREFIXES : "",
4550
+ bucketDomain ? SET_S3_ORIGIN : "",
4551
+ lambdaUrl ? SET_LAMBDA_ORIGIN : "",
4552
+ // --------------------------------------------------------
4553
+ // Route asset requests to the s3 bucket.
4554
+ bucketDomain ? ROUTE_TO_S3_ORIGIN_IF_STATIC_ASSET(bucketDomain) : "",
4555
+ // --------------------------------------------------------
4556
+ // Route SSR requests.
4557
+ lambdaUrl ? ROUTE_TO_LAMBDA_ORIGIN(lambdaUrl.split("/")[2]) : "",
4558
+ // --------------------------------------------------------
4559
+ // Return original response
4560
+ bucketDomain && !lambdaUrl ? ROUTE_TO_S3_ORIGIN(bucketDomain) : ""
4561
+ ]);
4562
+ });
4409
4563
  };
4564
+ var CF_FUNC_WRAP = (code) => `
4565
+ import cf from "cloudfront";
4566
+
4567
+ async function handler(event) {
4568
+ ${code.join("\n")}
4569
+
4570
+ return event.request;
4571
+ }
4572
+ `;
4573
+ var BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT = `
4574
+ if (event.request.headers.host.value.includes('cloudfront.net')) {
4575
+ return {
4576
+ statusCode: 403,
4577
+ statusDescription: 'Forbidden',
4578
+ body: {
4579
+ encoding: 'text',
4580
+ data: '<html><head><title>403 Forbidden</title></head><body><center><h1>403 Forbidden</h1></center></body></html>'
4581
+ }
4582
+ };
4583
+ }`;
4584
+ var SET_S3_ORIGIN = `
4585
+ function setS3Origin(s3Domain) {
4586
+ const origin = {
4587
+ domainName: s3Domain,
4588
+ originAccessControlConfig: {
4589
+ enabled: true,
4590
+ signingBehavior: 'always',
4591
+ signingProtocol: 'sigv4',
4592
+ originType: 's3',
4593
+ }
4594
+ };
4595
+
4596
+ console.log("s3 origin")
4597
+ console.log(origin)
4598
+ cf.updateRequestOrigin(origin);
4599
+ }`;
4600
+ var SET_LAMBDA_ORIGIN = `
4601
+ function setLambdaOrigin(urlHost) {
4602
+ cf.updateRequestOrigin({
4603
+ domainName: urlHost,
4604
+ customOriginConfig: {
4605
+ port: 443,
4606
+ protocol: 'https',
4607
+ sslProtocols: ['TLSv1.2'],
4608
+ },
4609
+ originAccessControlConfig: {
4610
+ enabled: true,
4611
+ signingBehavior: 'always',
4612
+ signingProtocol: 'sigv4',
4613
+ originType: 'lambda',
4614
+ }
4615
+ });
4616
+ }`;
4617
+ var GET_PREFIXES = `
4618
+ function getPostfixes(path) {
4619
+ if(path === '') {
4620
+ return ['/index.html'];
4621
+ }
4622
+
4623
+ if(path.endsWith('/')) {
4624
+ return ['index.html'];
4625
+ }
4626
+
4627
+ const parts = path.split('/');
4628
+ const lastPart = parts[parts.length - 1];
4629
+
4630
+ if(lastPart.includes('.')) {
4631
+ return [''];
4632
+ }
4633
+
4634
+ return ['', '.html', '/index.html'];
4635
+ }`;
4636
+ var ROUTE_TO_S3_ORIGIN_IF_STATIC_ASSET = (bucketDomain) => `
4637
+ if (event.request.method === 'GET' || event.request.method === 'HEAD') {
4638
+ const s3Domain = '${bucketDomain}';
4639
+ const path = decodeURIComponent(event.request.uri);
4640
+ const postfixes = getPostfixes(path);
4641
+
4642
+ try {
4643
+ const postfix = await Promise.any(
4644
+ postfixes.map(p => {
4645
+ return cf
4646
+ .kvs()
4647
+ .get(path + p)
4648
+ .then(v => p);
4649
+ })
4650
+ );
4651
+
4652
+ event.request.uri = event.request.uri + postfix;
4653
+ setS3Origin(s3Domain);
4654
+ return event.request;
4655
+ } catch (e) {}
4656
+ }`;
4657
+ var ROUTE_TO_S3_ORIGIN = (bucketDomain) => `
4658
+ setS3Origin('${bucketDomain}');`;
4659
+ var ROUTE_TO_LAMBDA_ORIGIN = (url) => `
4660
+ for (var key in event.request.querystring) {
4661
+ if (key.includes('/')) {
4662
+ event.request.querystring[encodeURIComponent(key)] = event.request.querystring[key];
4663
+ delete event.request.querystring[key];
4664
+ }
4665
+ }
4666
+
4667
+ if (event.request.headers.host) {
4668
+ event.request.headers['x-forwarded-host'] = event.request.headers.host;
4669
+ }
4670
+
4671
+ setLambdaOrigin('${url}');`;
4410
4672
 
4411
4673
  // src/feature/site/index.ts
4412
- import { camelCase as camelCase6, constantCase as constantCase10 } from "change-case";
4674
+ import { camelCase as camelCase6 } from "change-case";
4413
4675
 
4414
4676
  // src/util/exec.ts
4415
4677
  import { exec } from "promisify-child-process";
@@ -4448,10 +4710,17 @@ var siteFeature = defineFeature({
4448
4710
  });
4449
4711
  });
4450
4712
  }
4451
- const origins = [];
4452
- const originGroups = [];
4453
- let bucket;
4713
+ const kvs = new $15.aws.cloudfront.KeyValueStore(group, "kvs", {
4714
+ name,
4715
+ comment: "Store for static assets"
4716
+ });
4717
+ const keys = [];
4718
+ new ImportKeys(group, "keys", {
4719
+ kvsArn: kvs.arn,
4720
+ keys
4721
+ });
4454
4722
  const versions = [];
4723
+ let functionUrl;
4455
4724
  if (props.ssr) {
4456
4725
  const result = createLambdaFunction(group, ctx, `site`, id, props.ssr);
4457
4726
  versions.push(result.code.sourceHash);
@@ -4465,28 +4734,12 @@ var siteFeature = defineFeature({
4465
4734
  functionUrlAuthType: "AWS_IAM",
4466
4735
  sourceArn: `arn:aws:cloudfront::${ctx.accountId}:distribution/*`
4467
4736
  });
4468
- const url = new $15.aws.lambda.FunctionUrl(group, "url", {
4737
+ functionUrl = new $15.aws.lambda.FunctionUrl(group, "url", {
4469
4738
  functionName: result.lambda.functionName,
4470
4739
  authorizationType: "AWS_IAM"
4471
4740
  });
4472
- const ssrAccessControl = new $15.aws.cloudfront.OriginAccessControl(group, "ssr-access", {
4473
- name: `${name}-ssr`,
4474
- originAccessControlOriginType: "lambda",
4475
- signingBehavior: "always",
4476
- signingProtocol: "sigv4"
4477
- });
4478
- origins.push({
4479
- originId: "ssr",
4480
- domainName: url.functionUrl.pipe((url2) => url2.split("/")[2]),
4481
- originAccessControlId: ssrAccessControl.id,
4482
- customOriginConfig: {
4483
- originProtocolPolicy: "https-only",
4484
- httpPort: 80,
4485
- httpsPort: 443,
4486
- originSslProtocols: ["TLSv1.2"]
4487
- }
4488
- });
4489
4741
  }
4742
+ let bucket;
4490
4743
  if (props.static) {
4491
4744
  bucket = new $15.aws.s3.Bucket(group, "bucket", {
4492
4745
  bucket: formatLocalResourceName({
@@ -4527,14 +4780,8 @@ var siteFeature = defineFeature({
4527
4780
  bucket.arn.pipe((arn) => `${arn}/*`)
4528
4781
  ]
4529
4782
  });
4530
- const accessControl = new $15.aws.cloudfront.OriginAccessControl(group, `access`, {
4531
- name,
4532
- originAccessControlOriginType: "s3",
4533
- signingBehavior: "always",
4534
- signingProtocol: "sigv4"
4535
- });
4536
4783
  ctx.onReady(() => {
4537
- if (typeof props.static === "string") {
4784
+ if (typeof props.static === "string" && bucket) {
4538
4785
  const files = glob2.sync("**", {
4539
4786
  // cwd: join(directories.root, props.static),
4540
4787
  cwd: props.static,
@@ -4549,29 +4796,12 @@ var siteFeature = defineFeature({
4549
4796
  source: join11(props.static, file),
4550
4797
  sourceHash: $hash(join11(props.static, file))
4551
4798
  });
4799
+ keys.push({ key: `/${file}`, value: "s3" });
4552
4800
  versions.push(object.key);
4553
4801
  versions.push(object.sourceHash);
4554
4802
  }
4555
4803
  }
4556
4804
  });
4557
- origins.push({
4558
- originId: "static",
4559
- domainName: bucket.bucketRegionalDomainName,
4560
- originAccessControlId: accessControl.id,
4561
- s3OriginConfig: {
4562
- // is required to have an value for s3 origins when using origin access control
4563
- originAccessIdentity: ""
4564
- }
4565
- });
4566
- }
4567
- if (props.ssr && props.static) {
4568
- originGroups.push({
4569
- originId: "group",
4570
- member: props.origin === "ssr-first" ? [{ originId: "ssr" }, { originId: "static" }] : [{ originId: "static" }, { originId: "ssr" }],
4571
- failoverCriteria: {
4572
- statusCodes: [403, 404]
4573
- }
4574
- });
4575
4805
  }
4576
4806
  const cache = new $15.aws.cloudfront.CachePolicy(group, "cache", {
4577
4807
  name,
@@ -4655,30 +4885,25 @@ var siteFeature = defineFeature({
4655
4885
  });
4656
4886
  const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
4657
4887
  const certificateArn = props.domain ? ctx.shared.entry("domain", `global-certificate-arn`, props.domain) : void 0;
4658
- const associations = [];
4659
- if (props.forwardHost) {
4660
- const viewerRequest = new $15.aws.cloudfront.Function(group, "forward-host", {
4661
- name: formatLocalResourceName({
4662
- appName: ctx.app.name,
4663
- stackName: ctx.stack.name,
4664
- resourceType: "site",
4665
- resourceName: "forward-host"
4666
- }),
4667
- runtime: `cloudfront-js-2.0`,
4668
- comment: "Forward the host header to the origin",
4669
- publish: true,
4670
- code: getForwardHostFunctionCode()
4671
- });
4672
- associations.push({
4673
- eventType: "viewer-request",
4674
- functionArn: viewerRequest.arn
4675
- });
4676
- }
4888
+ const viewerRequest = new $15.aws.cloudfront.Function(group, "viewer-request", {
4889
+ name: formatLocalResourceName({
4890
+ appName: ctx.app.name,
4891
+ stackName: ctx.stack.name,
4892
+ resourceType: "site",
4893
+ resourceName: `request-${id}`
4894
+ }),
4895
+ runtime: `cloudfront-js-2.0`,
4896
+ comment: `Viewer Request - ${name}`,
4897
+ publish: true,
4898
+ code: getViewerRequestFunctionCode(domainName, bucket, functionUrl),
4899
+ keyValueStoreAssociations: [kvs.arn]
4900
+ });
4677
4901
  const distribution = new $15.aws.cloudfront.Distribution(group, "distribution", {
4678
4902
  // name,
4679
- tags: {
4680
- Name: name
4681
- },
4903
+ // tags: {
4904
+ // Name: name,
4905
+ // },
4906
+ comment: name,
4682
4907
  enabled: true,
4683
4908
  aliases: domainName ? [domainName] : void 0,
4684
4909
  priceClass: "PriceClass_All",
@@ -4690,8 +4915,19 @@ var siteFeature = defineFeature({
4690
4915
  } : {
4691
4916
  cloudfrontDefaultCertificate: true
4692
4917
  },
4693
- origin: origins,
4694
- originGroup: originGroups,
4918
+ origin: [
4919
+ {
4920
+ originId: "default",
4921
+ domainName: "placeholder.awsless.dev",
4922
+ customOriginConfig: {
4923
+ httpPort: 80,
4924
+ httpsPort: 443,
4925
+ originProtocolPolicy: "http-only",
4926
+ originReadTimeout: 20,
4927
+ originSslProtocols: ["TLSv1.2"]
4928
+ }
4929
+ }
4930
+ ],
4695
4931
  customErrorResponse: Object.entries(props.errors ?? {}).map(([errorCode, item]) => {
4696
4932
  if (typeof item === "string") {
4697
4933
  return {
@@ -4715,14 +4951,21 @@ var siteFeature = defineFeature({
4715
4951
  },
4716
4952
  defaultCacheBehavior: {
4717
4953
  compress: true,
4718
- targetOriginId: props.ssr && props.static ? "group" : props.ssr ? "ssr" : "static",
4719
- functionAssociation: associations,
4954
+ targetOriginId: "default",
4955
+ functionAssociation: [
4956
+ {
4957
+ eventType: "viewer-request",
4958
+ functionArn: viewerRequest.arn
4959
+ }
4960
+ ],
4720
4961
  originRequestPolicyId: originRequest.id,
4721
4962
  cachePolicyId: cache.id,
4722
4963
  responseHeadersPolicyId: responseHeaders.id,
4723
4964
  viewerProtocolPolicy: "redirect-to-https",
4724
4965
  allowedMethods: ["GET", "HEAD", "POST", "PUT", "PATCH", "OPTIONS", "DELETE"],
4725
4966
  cachedMethods: ["GET", "HEAD"]
4967
+ // cachedMethods: ['GET', 'HEAD', 'OPTIONS'],
4968
+ // cachedMethods: [],
4726
4969
  }
4727
4970
  });
4728
4971
  new Invalidation(group, "invalidate", {
@@ -4736,7 +4979,7 @@ var siteFeature = defineFeature({
4736
4979
  });
4737
4980
  })
4738
4981
  });
4739
- if (props.static) {
4982
+ if (bucket) {
4740
4983
  new $15.aws.s3.BucketPolicy(
4741
4984
  group,
4742
4985
  `policy`,
@@ -4780,9 +5023,6 @@ var siteFeature = defineFeature({
4780
5023
  }
4781
5024
  });
4782
5025
  }
4783
- if (domainName) {
4784
- ctx.bind(`SITE_${constantCase10(ctx.stack.name)}_${constantCase10(id)}_ENDPOINT`, domainName);
4785
- }
4786
5026
  }
4787
5027
  }
4788
5028
  });
@@ -4939,7 +5179,7 @@ var storeFeature = defineFeature({
4939
5179
 
4940
5180
  // src/feature/table/index.ts
4941
5181
  import { $ as $17, Group as Group17 } from "@awsless/formation";
4942
- import { constantCase as constantCase11 } from "change-case";
5182
+ import { constantCase as constantCase10 } from "change-case";
4943
5183
  import { toSeconds as toSeconds7 } from "@awsless/duration";
4944
5184
  var tableFeature = defineFeature({
4945
5185
  name: "table",
@@ -5021,8 +5261,8 @@ var tableFeature = defineFeature({
5021
5261
  name,
5022
5262
  billingMode: "PAY_PER_REQUEST",
5023
5263
  streamEnabled: !!props.stream,
5024
- streamViewType: props.stream && constantCase11(props.stream?.type),
5025
- tableClass: constantCase11(props.class),
5264
+ streamViewType: props.stream && constantCase10(props.stream?.type),
5265
+ tableClass: constantCase10(props.class),
5026
5266
  hashKey: props.hash,
5027
5267
  rangeKey: props.sort,
5028
5268
  attribute: attributeDefinitions(),
@@ -5037,7 +5277,7 @@ var tableFeature = defineFeature({
5037
5277
  name: name2,
5038
5278
  hashKey: index.hash,
5039
5279
  rangeKey: index.sort,
5040
- projectionType: constantCase11(index.projection)
5280
+ projectionType: constantCase10(index.projection)
5041
5281
  })),
5042
5282
  deletionProtectionEnabled: ctx.appConfig.removal === "retain"
5043
5283
  },
@@ -6923,7 +7163,7 @@ var auth = (program2) => {
6923
7163
 
6924
7164
  // src/cli/command/bind.ts
6925
7165
  import { log as log10, note as note3 } from "@clack/prompts";
6926
- import { constantCase as constantCase12 } from "change-case";
7166
+ import { constantCase as constantCase11 } from "change-case";
6927
7167
  import { spawn } from "child_process";
6928
7168
  var bind = (program2) => {
6929
7169
  program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands7 = [], opts) => {
@@ -6952,10 +7192,10 @@ var bind = (program2) => {
6952
7192
  const configList = opts.config ?? [];
6953
7193
  const configs = {};
6954
7194
  for (const name of configList) {
6955
- configs[`CONFIG_${constantCase12(name)}`] = name;
7195
+ configs[`CONFIG_${constantCase11(name)}`] = name;
6956
7196
  }
6957
7197
  if (configList.length ?? 0 > 0) {
6958
- note3(wrap(configList.map((v) => color.label(constantCase12(v)))), "Bind Config");
7198
+ note3(wrap(configList.map((v) => color.label(constantCase11(v)))), "Bind Config");
6959
7199
  }
6960
7200
  if (commands7.length === 0) {
6961
7201
  return "No command to execute.";
@@ -7367,7 +7607,7 @@ var domain = (program2) => {
7367
7607
  import { CloudWatchLogsClient, StartLiveTailCommand } from "@aws-sdk/client-cloudwatch-logs";
7368
7608
  import { log as log15 } from "@clack/prompts";
7369
7609
  import chalk7 from "chalk";
7370
- import chunk from "chunk";
7610
+ import chunk2 from "chunk";
7371
7611
  import { formatDate } from "date-fns";
7372
7612
  import wildstring6 from "wildstring";
7373
7613
  var logs = (program2) => {
@@ -7409,7 +7649,7 @@ var logs = (program2) => {
7409
7649
  });
7410
7650
  const streams = await task("Connecting to the log stream...", async (update) => {
7411
7651
  const result = await Promise.all(
7412
- chunk(logGroupArns, 10).map(async (arns) => {
7652
+ chunk2(logGroupArns, 10).map(async (arns) => {
7413
7653
  const command = new StartLiveTailCommand({
7414
7654
  logGroupIdentifiers: arns
7415
7655
  });