@awsless/awsless 0.0.207 → 0.0.209

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
@@ -69,7 +69,7 @@ var debug = (...parts) => {
69
69
  };
70
70
 
71
71
  // src/config/app.ts
72
- import { z as z13 } from "zod";
72
+ import { z as z15 } from "zod";
73
73
 
74
74
  // src/config/schema/resource-id.ts
75
75
  import { paramCase } from "change-case";
@@ -565,25 +565,45 @@ var HttpDefaultSchema = z12.record(
565
565
  ).optional().describe("Define your global HTTP API's.");
566
566
  var HttpSchema = z12.record(ResourceIdSchema, z12.record(RouteSchema, FunctionSchema)).optional().describe("Define routes in your stack for your global HTTP API.");
567
567
 
568
+ // src/feature/rest/schema.ts
569
+ import { z as z14 } from "zod";
570
+
571
+ // src/config/schema/route.ts
572
+ import { z as z13 } from "zod";
573
+ var RouteSchema2 = z13.union([
574
+ z13.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
575
+ z13.literal("$default")
576
+ ]);
577
+
578
+ // src/feature/rest/schema.ts
579
+ var RestDefaultSchema = z14.record(
580
+ ResourceIdSchema,
581
+ z14.object({
582
+ domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
583
+ subDomain: z14.string().optional()
584
+ })
585
+ ).optional().describe("Define your global REST API's.");
586
+ var RestSchema = z14.record(ResourceIdSchema, z14.record(RouteSchema2, FunctionSchema)).optional().describe("Define routes in your stack for your global REST API.");
587
+
568
588
  // src/config/app.ts
569
- var AppSchema = z13.object({
570
- $schema: z13.string().optional(),
589
+ var AppSchema = z15.object({
590
+ $schema: z15.string().optional(),
571
591
  name: ResourceIdSchema.describe("App name."),
572
592
  region: RegionSchema.describe("The AWS region to deploy to."),
573
- profile: z13.string().describe("The AWS profile to deploy to."),
593
+ profile: z15.string().describe("The AWS profile to deploy to."),
574
594
  // stage: z
575
595
  // .string()
576
596
  // .regex(/^[a-z]+$/)
577
597
  // .default('prod')
578
598
  // .describe('The deployment stage.'),
579
- defaults: z13.object({
599
+ defaults: z15.object({
580
600
  auth: AuthDefaultSchema,
581
601
  domains: DomainsDefaultSchema,
582
602
  function: FunctionDefaultSchema,
583
603
  queue: QueueDefaultSchema,
584
604
  graphql: GraphQLDefaultSchema,
585
- http: HttpDefaultSchema
586
- // rest: RestDefaultSchema,
605
+ http: HttpDefaultSchema,
606
+ rest: RestDefaultSchema
587
607
  }).default({}).describe("Default properties")
588
608
  });
589
609
 
@@ -591,7 +611,7 @@ var AppSchema = z13.object({
591
611
  import { glob } from "glob";
592
612
 
593
613
  // src/config/stack.ts
594
- import { z as z26 } from "zod";
614
+ import { z as z28 } from "zod";
595
615
 
596
616
  // src/feature/on-failure/schema.ts
597
617
  var OnFailureSchema = FunctionSchema.optional().describe(
@@ -599,41 +619,41 @@ var OnFailureSchema = FunctionSchema.optional().describe(
599
619
  );
600
620
 
601
621
  // src/feature/config/schema.ts
602
- import { z as z14 } from "zod";
603
- var ConfigNameSchema = z14.string().regex(/[a-z0-9\-]/g, "Invalid config name");
604
- var ConfigsSchema = z14.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
622
+ import { z as z16 } from "zod";
623
+ var ConfigNameSchema = z16.string().regex(/[a-z0-9\-]/g, "Invalid config name");
624
+ var ConfigsSchema = z16.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
605
625
 
606
626
  // src/feature/table/schema.ts
607
- import { z as z15 } from "zod";
608
- var KeySchema = z15.string().min(1).max(255);
609
- var TablesSchema = z15.record(
627
+ import { z as z17 } from "zod";
628
+ var KeySchema = z17.string().min(1).max(255);
629
+ var TablesSchema = z17.record(
610
630
  ResourceIdSchema,
611
- z15.object({
631
+ z17.object({
612
632
  hash: KeySchema.describe(
613
633
  "Specifies the name of the partition / hash key that makes up the primary key for the table."
614
634
  ),
615
635
  sort: KeySchema.optional().describe(
616
636
  "Specifies the name of the range / sort key that makes up the primary key for the table."
617
637
  ),
618
- fields: z15.record(z15.string(), z15.enum(["string", "number", "binary"])).optional().describe(
638
+ fields: z17.record(z17.string(), z17.enum(["string", "number", "binary"])).optional().describe(
619
639
  'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
620
640
  ),
621
- class: z15.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
622
- pointInTimeRecovery: z15.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
641
+ class: z17.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
642
+ pointInTimeRecovery: z17.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
623
643
  timeToLiveAttribute: KeySchema.optional().describe(
624
644
  "The name of the TTL attribute used to store the expiration time for items in the table. To update this property, you must first disable TTL and then enable TTL with the new attribute name."
625
645
  ),
626
- stream: z15.object({
627
- type: z15.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
646
+ stream: z17.object({
647
+ type: z17.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
628
648
  "When an item in the table is modified, stream.type determines what information is written to the stream for this table. Valid values are:\n- keys-only - Only the key attributes of the modified item are written to the stream.\n- new-image - The entire item, as it appears after it was modified, is written to the stream.\n- old-image - The entire item, as it appeared before it was modified, is written to the stream.\n- new-and-old-images - Both the new and the old item images of the item are written to the stream."
629
649
  ),
630
650
  consumer: FunctionSchema.describe("The consuming lambda function for the stream")
631
651
  }).optional().describe(
632
652
  "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
633
653
  ),
634
- indexes: z15.record(
635
- z15.string(),
636
- z15.object({
654
+ indexes: z17.record(
655
+ z17.string(),
656
+ z17.object({
637
657
  /** Specifies the name of the partition / hash key that makes up the primary key for the global secondary index. */
638
658
  hash: KeySchema,
639
659
  /** Specifies the name of the range / sort key that makes up the primary key for the global secondary index. */
@@ -643,34 +663,34 @@ var TablesSchema = z15.record(
643
663
  * - keys-only - Only the index and primary keys are projected into the index.
644
664
  * @default 'all'
645
665
  */
646
- projection: z15.enum(["all", "keys-only"]).default("all")
666
+ projection: z17.enum(["all", "keys-only"]).default("all")
647
667
  })
648
668
  ).optional().describe("Specifies the global secondary indexes to be created on the table.")
649
669
  })
650
670
  ).optional().describe("Define the tables in your stack.");
651
671
 
652
672
  // src/feature/store/schema.ts
653
- import { z as z16 } from "zod";
654
- var StoresSchema = z16.array(ResourceIdSchema).optional().describe("Define the stores in your stack.");
673
+ import { z as z18 } from "zod";
674
+ var StoresSchema = z18.array(ResourceIdSchema).optional().describe("Define the stores in your stack.");
655
675
 
656
676
  // src/feature/pubsub/schema.ts
657
- import { z as z17 } from "zod";
658
- var PubSubSchema = z17.record(
677
+ import { z as z19 } from "zod";
678
+ var PubSubSchema = z19.record(
659
679
  ResourceIdSchema,
660
- z17.object({
661
- sql: z17.string().describe("The SQL statement used to query the IOT topic."),
662
- 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."),
680
+ z19.object({
681
+ sql: z19.string().describe("The SQL statement used to query the IOT topic."),
682
+ sqlVersion: z19.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."),
663
683
  consumer: FunctionSchema.describe("The consuming lambda function properties.")
664
684
  })
665
685
  ).optional().describe("Define the pubsub subscriber in your stack.");
666
686
 
667
687
  // src/feature/test/schema.ts
668
- import { z as z19 } from "zod";
688
+ import { z as z21 } from "zod";
669
689
 
670
690
  // src/config/schema/local-directory.ts
671
691
  import { stat as stat2 } from "fs/promises";
672
- import { z as z18 } from "zod";
673
- var LocalDirectorySchema = z18.string().transform((path) => resolvePath(path)).refine(async (path) => {
692
+ import { z as z20 } from "zod";
693
+ var LocalDirectorySchema = z20.string().transform((path) => resolvePath(path)).refine(async (path) => {
674
694
  try {
675
695
  const s = await stat2(path);
676
696
  return s.isDirectory();
@@ -680,26 +700,26 @@ var LocalDirectorySchema = z18.string().transform((path) => resolvePath(path)).r
680
700
  }, `Directory doesn't exist`);
681
701
 
682
702
  // src/feature/test/schema.ts
683
- var TestsSchema = z19.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
703
+ var TestsSchema = z21.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
684
704
 
685
705
  // src/feature/topic/schema.ts
686
706
  import { paramCase as paramCase2 } from "change-case";
687
- import { z as z20 } from "zod";
688
- var TopicNameSchema = z20.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase2(value)).describe("Define event topic name.");
689
- var TopicsSchema = z20.array(TopicNameSchema).refine((topics) => {
707
+ import { z as z22 } from "zod";
708
+ var TopicNameSchema = z22.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase2(value)).describe("Define event topic name.");
709
+ var TopicsSchema = z22.array(TopicNameSchema).refine((topics) => {
690
710
  return topics.length === new Set(topics).size;
691
711
  }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
692
- var SubscribersSchema = z20.record(TopicNameSchema, z20.union([EmailSchema, FunctionSchema])).optional().describe("Define the events to subscribe too in your stack.");
712
+ var SubscribersSchema = z22.record(TopicNameSchema, z22.union([EmailSchema, FunctionSchema])).optional().describe("Define the events to subscribe too in your stack.");
693
713
 
694
714
  // src/feature/cron/schema/index.ts
695
- import { z as z22 } from "zod";
715
+ import { z as z24 } from "zod";
696
716
 
697
717
  // src/feature/cron/schema/schedule.ts
698
- import { z as z21 } from "zod";
718
+ import { z as z23 } from "zod";
699
719
  import { awsCronExpressionValidator } from "aws-cron-expression-validator";
700
- var RateExpressionSchema = z21.custom(
720
+ var RateExpressionSchema = z23.custom(
701
721
  (value) => {
702
- return z21.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
722
+ return z23.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
703
723
  const [str] = rate.split(" ");
704
724
  const number = parseInt(str);
705
725
  return number > 0;
@@ -715,9 +735,9 @@ var RateExpressionSchema = z21.custom(
715
735
  }
716
736
  return `rate(${rate})`;
717
737
  });
718
- var CronExpressionSchema = z21.custom(
738
+ var CronExpressionSchema = z23.custom(
719
739
  (value) => {
720
- return z21.string().safeParse(value).success;
740
+ return z23.string().safeParse(value).success;
721
741
  },
722
742
  { message: "Invalid cron expression" }
723
743
  ).superRefine((value, ctx) => {
@@ -726,12 +746,12 @@ var CronExpressionSchema = z21.custom(
726
746
  } catch (error) {
727
747
  if (error instanceof Error) {
728
748
  ctx.addIssue({
729
- code: z21.ZodIssueCode.custom,
749
+ code: z23.ZodIssueCode.custom,
730
750
  message: `Invalid cron expression: ${error.message}`
731
751
  });
732
752
  } else {
733
753
  ctx.addIssue({
734
- code: z21.ZodIssueCode.custom,
754
+ code: z23.ZodIssueCode.custom,
735
755
  message: "Invalid cron expression"
736
756
  });
737
757
  }
@@ -742,21 +762,21 @@ var CronExpressionSchema = z21.custom(
742
762
  var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
743
763
 
744
764
  // src/feature/cron/schema/index.ts
745
- var CronsSchema = z22.record(
765
+ var CronsSchema = z24.record(
746
766
  ResourceIdSchema,
747
- z22.object({
748
- enabled: z22.boolean().default(true).describe("If the cron is enabled."),
767
+ z24.object({
768
+ enabled: z24.boolean().default(true).describe("If the cron is enabled."),
749
769
  consumer: FunctionSchema.describe("The consuming lambda function properties."),
750
770
  schedule: ScheduleExpressionSchema.describe(
751
771
  'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
752
772
  ),
753
- payload: z22.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
773
+ payload: z24.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
754
774
  })
755
775
  ).optional();
756
776
 
757
777
  // src/feature/cache/schema.ts
758
- import { z as z23 } from "zod";
759
- var TypeSchema = z23.enum([
778
+ import { z as z25 } from "zod";
779
+ var TypeSchema = z25.enum([
760
780
  "t4g.small",
761
781
  "t4g.medium",
762
782
  "r6g.large",
@@ -771,27 +791,27 @@ var TypeSchema = z23.enum([
771
791
  "r6gd.4xlarge",
772
792
  "r6gd.8xlarge"
773
793
  ]);
774
- var PortSchema = z23.number().int().min(1).max(5e4);
775
- var ShardsSchema = z23.number().int().min(0).max(100);
776
- var ReplicasPerShardSchema = z23.number().int().min(0).max(5);
777
- var EngineSchema = z23.enum(["7.0", "6.2"]);
778
- var CachesSchema = z23.record(
794
+ var PortSchema = z25.number().int().min(1).max(5e4);
795
+ var ShardsSchema = z25.number().int().min(0).max(100);
796
+ var ReplicasPerShardSchema = z25.number().int().min(0).max(5);
797
+ var EngineSchema = z25.enum(["7.0", "6.2"]);
798
+ var CachesSchema = z25.record(
779
799
  ResourceIdSchema,
780
- z23.object({
800
+ z25.object({
781
801
  type: TypeSchema.default("t4g.small"),
782
802
  port: PortSchema.default(6379),
783
803
  shards: ShardsSchema.default(1),
784
804
  replicasPerShard: ReplicasPerShardSchema.default(1),
785
805
  engine: EngineSchema.default("7.0"),
786
- dataTiering: z23.boolean().default(false)
806
+ dataTiering: z25.boolean().default(false)
787
807
  })
788
808
  ).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
789
809
 
790
810
  // src/feature/search/schema.ts
791
- import { z as z24 } from "zod";
811
+ import { z as z26 } from "zod";
792
812
  import { gibibytes as gibibytes2 } from "@awsless/size";
793
- var VersionSchema = z24.enum(["2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
794
- var TypeSchema2 = z24.enum([
813
+ var VersionSchema = z26.enum(["2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
814
+ var TypeSchema2 = z26.enum([
795
815
  "t3.small",
796
816
  "t3.medium",
797
817
  "t3.large",
@@ -892,41 +912,41 @@ var TypeSchema2 = z24.enum([
892
912
  "r6gd.16xlarge"
893
913
  ]);
894
914
  var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes2(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes2(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.");
895
- var SearchsSchema = z24.record(
915
+ var SearchsSchema = z26.record(
896
916
  ResourceIdSchema,
897
- z24.object({
917
+ z26.object({
898
918
  type: TypeSchema2.default("t3.small"),
899
- count: z24.number().int().min(1).default(1),
919
+ count: z26.number().int().min(1).default(1),
900
920
  version: VersionSchema.default("2.11"),
901
921
  storage: StorageSizeSchema.default("10 GB"),
902
- vpc: z24.boolean().default(false)
922
+ vpc: z26.boolean().default(false)
903
923
  })
904
924
  ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
905
925
 
906
926
  // src/feature/site/schema.ts
907
- import { z as z25 } from "zod";
908
- var ErrorResponsePathSchema = z25.string().describe(
927
+ import { z as z27 } from "zod";
928
+ var ErrorResponsePathSchema = z27.string().describe(
909
929
  "The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.\n - We recommend that you store custom error pages in an Amazon S3 bucket. 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."
910
930
  );
911
- var StatusCodeSchema = z25.number().int().positive().optional().describe(
931
+ var StatusCodeSchema = z27.number().int().positive().optional().describe(
912
932
  "The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. 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:\n- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200, the response typically won't be intercepted.\n- If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.\n- You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down."
913
933
  );
914
934
  var MinTTLSchema = DurationSchema.describe(
915
935
  "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."
916
936
  );
917
- var ErrorResponseSchema = z25.union([
937
+ var ErrorResponseSchema = z27.union([
918
938
  ErrorResponsePathSchema,
919
- z25.object({
939
+ z27.object({
920
940
  path: ErrorResponsePathSchema,
921
941
  statusCode: StatusCodeSchema.optional(),
922
942
  minTTL: MinTTLSchema.optional()
923
943
  })
924
944
  ]).optional();
925
- var SitesSchema = z25.record(
945
+ var SitesSchema = z27.record(
926
946
  ResourceIdSchema,
927
- z25.object({
947
+ z27.object({
928
948
  domain: ResourceIdSchema.describe("The domain id to link your site with."),
929
- subDomain: z25.string().optional(),
949
+ subDomain: z27.string().optional(),
930
950
  static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
931
951
  ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
932
952
  // bind: z.object({
@@ -941,7 +961,7 @@ var SitesSchema = z25.record(
941
961
  // build: z.string().optional(),
942
962
  // }),
943
963
  // ]),
944
- errors: z25.object({
964
+ errors: z27.object({
945
965
  400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
946
966
  403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
947
967
  404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
@@ -954,16 +974,16 @@ var SitesSchema = z25.record(
954
974
  503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
955
975
  504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
956
976
  }).optional().describe("Customize the error responses for specific HTTP status codes."),
957
- cors: z25.object({
958
- override: z25.boolean().default(false),
977
+ cors: z27.object({
978
+ override: z27.boolean().default(false),
959
979
  maxAge: DurationSchema.default("365 days"),
960
- exposeHeaders: z25.string().array().optional(),
961
- credentials: z25.boolean().default(false),
962
- headers: z25.string().array().default(["*"]),
963
- origins: z25.string().array().default(["*"]),
964
- methods: z25.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
980
+ exposeHeaders: z27.string().array().optional(),
981
+ credentials: z27.boolean().default(false),
982
+ headers: z27.string().array().default(["*"]),
983
+ origins: z27.string().array().default(["*"]),
984
+ methods: z27.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
965
985
  }).optional().describe("Define the cors headers."),
966
- security: z25.object({
986
+ security: z27.object({
967
987
  // contentSecurityPolicy: z.object({
968
988
  // override: z.boolean().default(false),
969
989
  // policy: z.string(),
@@ -1005,10 +1025,10 @@ var SitesSchema = z25.record(
1005
1025
  // reportUri?: string
1006
1026
  // }
1007
1027
  }).optional().describe("Define the security policy."),
1008
- cache: z25.object({
1009
- cookies: z25.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1010
- headers: z25.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1011
- queries: z25.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1028
+ cache: z27.object({
1029
+ cookies: z27.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1030
+ headers: z27.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1031
+ queries: z27.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1012
1032
  }).optional().describe(
1013
1033
  "Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
1014
1034
  )
@@ -1020,15 +1040,15 @@ var DependsSchema = ResourceIdSchema.array().optional().describe("Define the sta
1020
1040
  var NameSchema = ResourceIdSchema.refine((name) => !["base"].includes(name), {
1021
1041
  message: `Stack name can't be a reserved name.`
1022
1042
  }).describe("Stack name.");
1023
- var StackSchema = z26.object({
1024
- $schema: z26.string().optional(),
1043
+ var StackSchema = z28.object({
1044
+ $schema: z28.string().optional(),
1025
1045
  name: NameSchema,
1026
1046
  depends: DependsSchema,
1027
1047
  onFailure: OnFailureSchema,
1028
1048
  auth: AuthSchema,
1029
1049
  graphql: GraphQLSchema,
1030
1050
  http: HttpSchema,
1031
- // rest: RestSchema,
1051
+ rest: RestSchema,
1032
1052
  configs: ConfigsSchema,
1033
1053
  crons: CronsSchema,
1034
1054
  caches: CachesSchema,
@@ -1099,13 +1119,13 @@ var readConfigWithStage = async (file, stage) => {
1099
1119
  };
1100
1120
 
1101
1121
  // src/config/load/validate.ts
1102
- import { z as z27 } from "zod";
1122
+ import { z as z29 } from "zod";
1103
1123
  var validateConfig = async (schema, file, data) => {
1104
1124
  try {
1105
1125
  const result = await schema.parseAsync(data);
1106
1126
  return result;
1107
1127
  } catch (error) {
1108
- if (error instanceof z27.ZodError) {
1128
+ if (error instanceof z29.ZodError) {
1109
1129
  throw new ConfigError(file, error, data);
1110
1130
  }
1111
1131
  throw error;
@@ -3906,6 +3926,90 @@ var siteFeature = defineFeature({
3906
3926
  }
3907
3927
  });
3908
3928
 
3929
+ // src/feature/rest/index.ts
3930
+ import { Node as Node18, aws as aws18 } from "@awsless/formation";
3931
+ var restFeature = defineFeature({
3932
+ name: "rest",
3933
+ onApp(ctx) {
3934
+ for (const [id, props] of Object.entries(ctx.appConfig.defaults?.rest ?? {})) {
3935
+ const group = new Node18(ctx.base, "rest", id);
3936
+ const api = new aws18.apiGatewayV2.Api(group, "api", {
3937
+ name: formatGlobalResourceName(ctx.app.name, "rest", id),
3938
+ protocolType: "HTTP"
3939
+ });
3940
+ const stage = new aws18.apiGatewayV2.Stage(group, "stage", {
3941
+ name: "v1",
3942
+ apiId: api.id
3943
+ });
3944
+ ctx.shared.set(`rest-${id}-id`, api.id);
3945
+ if (props.domain) {
3946
+ const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
3947
+ const hostedZoneId = ctx.shared.get(`hosted-zone-${props.domain}-id`);
3948
+ const certificateArn = ctx.shared.get(`certificate-${props.domain}-arn`);
3949
+ const domain = new aws18.apiGatewayV2.DomainName(group, "domain", {
3950
+ name: domainName,
3951
+ certificates: [
3952
+ {
3953
+ certificateArn
3954
+ }
3955
+ ]
3956
+ });
3957
+ const mapping = new aws18.apiGatewayV2.ApiMapping(group, "mapping", {
3958
+ apiId: api.id,
3959
+ domainName: domain.name,
3960
+ stage: stage.name
3961
+ });
3962
+ const record = new aws18.route53.RecordSet(group, "record", {
3963
+ hostedZoneId,
3964
+ type: "A",
3965
+ name: domainName,
3966
+ alias: {
3967
+ dnsName: domain.regionalDomainName,
3968
+ hostedZoneId: domain.regionalHostedZoneId,
3969
+ evaluateTargetHealth: false
3970
+ }
3971
+ });
3972
+ record.dependsOn(domain, mapping);
3973
+ }
3974
+ }
3975
+ },
3976
+ onStack(ctx) {
3977
+ for (const [id, routes] of Object.entries(ctx.stackConfig.rest ?? {})) {
3978
+ const restGroup = new Node18(ctx.base, "rest", id);
3979
+ for (const [routeKey, props] of Object.entries(routes)) {
3980
+ const group = new Node18(restGroup, "route", routeKey);
3981
+ const apiId = ctx.shared.get(`rest-${id}-id`);
3982
+ const routeId = shortId(routeKey);
3983
+ const { lambda } = createLambdaFunction(group, ctx, "rest", `${id}-${routeId}`, {
3984
+ ...props,
3985
+ description: `${id} ${routeKey}`
3986
+ });
3987
+ const permission = new aws18.lambda.Permission(group, "permission", {
3988
+ action: "lambda:InvokeFunction",
3989
+ principal: "apigateway.amazonaws.com",
3990
+ functionArn: lambda.arn
3991
+ });
3992
+ const integration = new aws18.apiGatewayV2.Integration(group, "integration", {
3993
+ apiId,
3994
+ description: `${id} ${routeKey}`,
3995
+ method: "POST",
3996
+ payloadFormatVersion: "2.0",
3997
+ type: "AWS_PROXY",
3998
+ uri: lambda.arn.apply((arn) => {
3999
+ return `arn:aws:apigateway:${ctx.appConfig.region}:lambda:path/2015-03-31/functions/${arn}/invocations`;
4000
+ })
4001
+ });
4002
+ const route = new aws18.apiGatewayV2.Route(group, "route", {
4003
+ apiId,
4004
+ routeKey,
4005
+ target: integration.id.apply((id2) => `integrations/${id2}`)
4006
+ });
4007
+ route.dependsOn(lambda, permission);
4008
+ }
4009
+ }
4010
+ }
4011
+ });
4012
+
3909
4013
  // src/feature/index.ts
3910
4014
  var features = [
3911
4015
  // 1
@@ -3928,6 +4032,7 @@ var features = [
3928
4032
  cronFeature,
3929
4033
  cacheFeature,
3930
4034
  httpFeature,
4035
+ restFeature,
3931
4036
  siteFeature
3932
4037
  ];
3933
4038
 
@@ -4227,20 +4332,20 @@ var config = (program2) => {
4227
4332
  import { confirm as confirm3 } from "@clack/prompts";
4228
4333
 
4229
4334
  // src/util/workspace.ts
4230
- import { WorkSpace, aws as aws18, local } from "@awsless/formation";
4335
+ import { WorkSpace, aws as aws19, local } from "@awsless/formation";
4231
4336
  import { minutes as minutes4 } from "@awsless/duration";
4232
4337
  import { dirname as dirname8, join as join9 } from "path";
4233
4338
  import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
4234
4339
  var createWorkSpace = (props) => {
4235
- const lockProvider = new aws18.dynamodb.LockProvider({
4340
+ const lockProvider = new aws19.dynamodb.LockProvider({
4236
4341
  ...props,
4237
4342
  tableName: "awsless-locks"
4238
4343
  });
4239
- const stateProvider = new aws18.s3.StateProvider({
4344
+ const stateProvider = new aws19.s3.StateProvider({
4240
4345
  ...props,
4241
4346
  bucket: "awsless-state"
4242
4347
  });
4243
- const cloudProviders = aws18.createCloudProviders({
4348
+ const cloudProviders = aws19.createCloudProviders({
4244
4349
  ...props,
4245
4350
  timeout: minutes4(60)
4246
4351
  });
@@ -4417,6 +4522,14 @@ var startTest = async (props) => {
4417
4522
  exclude: ["**/_*", "**/_*/**", ...configDefaults.exclude],
4418
4523
  globals: true,
4419
4524
  reporters: props.reporter
4525
+ // typecheck: {
4526
+ // enabled: true,
4527
+ // // ignoreSourceErrors: false,
4528
+ // // checker: 'tsc',
4529
+ // // include: ['**/*.{js,jsx,ts,tsx}'],
4530
+ // // only: true,
4531
+ // // allowJs: true,
4532
+ // },
4420
4533
  // outputFile: {
4421
4534
  // json: './.awsless/test/output.json',
4422
4535
  // },
@@ -4608,7 +4721,7 @@ var deploy = (program2) => {
4608
4721
  };
4609
4722
 
4610
4723
  // src/cli/command/diff.ts
4611
- import { WorkSpace as WorkSpace2, aws as aws19 } from "@awsless/formation";
4724
+ import { WorkSpace as WorkSpace2, aws as aws20 } from "@awsless/formation";
4612
4725
  import chalk7 from "chalk";
4613
4726
  var diff = (program2) => {
4614
4727
  program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
@@ -4620,12 +4733,12 @@ var diff = (program2) => {
4620
4733
  const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
4621
4734
  await buildAssets(builders);
4622
4735
  const workspace = new WorkSpace2({
4623
- stateProvider: new aws19.dynamodb.DynamoDBStateProvider({
4736
+ stateProvider: new aws20.dynamodb.DynamoDBStateProvider({
4624
4737
  credentials,
4625
4738
  region,
4626
4739
  tableName: "awsless-state"
4627
4740
  }),
4628
- cloudProviders: aws19.createCloudProviders({
4741
+ cloudProviders: aws20.createCloudProviders({
4629
4742
  credentials,
4630
4743
  region: appConfig.region
4631
4744
  })