@awsless/awsless 0.0.548 → 0.0.549

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.
@@ -4,7 +4,7 @@ import { join as join2 } from "node:path";
4
4
  import { zodToJsonSchema } from "zod-to-json-schema";
5
5
 
6
6
  // src/config/app.ts
7
- import { z as z22 } from "zod";
7
+ import { z as z23 } from "zod";
8
8
 
9
9
  // src/feature/alert/schema.ts
10
10
  import { kebabCase } from "change-case";
@@ -361,7 +361,13 @@ var LayerSchema = z13.record(
361
361
 
362
362
  // src/feature/on-failure/schema.ts
363
363
  var OnFailureDefaultSchema = FunctionSchema.optional().describe(
364
- "Defining a onFailure handler will add a global onFailure handler for the following resources:\n- Async lambda functions\n- SQS queues\n- DynamoDB streams"
364
+ [
365
+ "Defining a onFailure handler will add a global onFailure handler for the following resources:",
366
+ "- CloudWatch Scheduler",
367
+ "- Async lambda functions",
368
+ "- SQS queues",
369
+ "- DynamoDB streams"
370
+ ].join("\n")
365
371
  );
366
372
 
367
373
  // src/feature/on-log/schema.ts
@@ -677,8 +683,17 @@ var InstanceDefaultSchema = z20.object({
677
683
  }))
678
684
  }).default({});
679
685
 
680
- // src/config/schema/region.ts
686
+ // src/feature/topic/schema.ts
687
+ import { kebabCase as kebabCase3 } from "change-case";
681
688
  import { z as z21 } from "zod";
689
+ var TopicNameSchema = z21.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
690
+ var TopicsDefaultSchema = z21.array(TopicNameSchema).refine((topics) => {
691
+ return topics.length === new Set(topics).size;
692
+ }, "Must be a list of unique topic names").optional().describe("Define the event topics for your app.");
693
+ var SubscribersSchema = z21.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
694
+
695
+ // src/config/schema/region.ts
696
+ import { z as z22 } from "zod";
682
697
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
683
698
  var AF = ["af-south-1"];
684
699
  var AP = [
@@ -707,16 +722,16 @@ var EU = [
707
722
  var ME = ["me-south-1", "me-central-1"];
708
723
  var SA = ["sa-east-1"];
709
724
  var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
710
- var RegionSchema = z21.enum(regions);
725
+ var RegionSchema = z22.enum(regions);
711
726
 
712
727
  // src/config/app.ts
713
- var AppSchema = z22.object({
714
- $schema: z22.string().optional(),
728
+ var AppSchema = z23.object({
729
+ $schema: z23.string().optional(),
715
730
  name: ResourceIdSchema.describe("App name."),
716
731
  region: RegionSchema.describe("The AWS region to deploy to."),
717
- profile: z22.string().describe("The AWS profile to deploy to."),
718
- protect: z22.boolean().default(false).describe("Protect your app & stacks from being deleted."),
719
- removal: z22.enum(["remove", "retain"]).default("remove").describe(
732
+ profile: z23.string().describe("The AWS profile to deploy to."),
733
+ protect: z23.boolean().default(false).describe("Protect your app & stacks from being deleted."),
734
+ removal: z23.enum(["remove", "retain"]).default("remove").describe(
720
735
  [
721
736
  "Configure how your resources are handled when they have to be removed.",
722
737
  "",
@@ -730,7 +745,7 @@ var AppSchema = z22.object({
730
745
  // .default('prod')
731
746
  // .describe('The deployment stage.'),
732
747
  // onFailure: OnFailureSchema,
733
- defaults: z22.object({
748
+ defaults: z23.object({
734
749
  onFailure: OnFailureDefaultSchema,
735
750
  onLog: OnLogDefaultSchema,
736
751
  auth: AuthDefaultSchema,
@@ -746,17 +761,18 @@ var AppSchema = z22.object({
746
761
  // table: TableDefaultSchema,
747
762
  // store: StoreDefaultSchema,
748
763
  alerts: AlertsDefaultSchema,
764
+ topics: TopicsDefaultSchema,
749
765
  layers: LayerSchema
750
766
  // dataRetention: z.boolean().describe('Configure how your resources are handled on delete.').default(false),
751
767
  }).default({}).describe("Default properties")
752
768
  });
753
769
 
754
770
  // src/config/stack.ts
755
- import { z as z38 } from "zod";
771
+ import { z as z39 } from "zod";
756
772
 
757
773
  // src/feature/cache/schema.ts
758
774
  import { gibibytes as gibibytes2 } from "@awsless/size";
759
- import { z as z23 } from "zod";
775
+ import { z as z24 } from "zod";
760
776
  var StorageSchema = SizeSchema.refine(sizeMin(gibibytes2(1)), "Minimum storage size is 1 GB").refine(
761
777
  sizeMax(gibibytes2(5e3)),
762
778
  "Maximum storage size is 5000 GB"
@@ -767,31 +783,31 @@ var MinimumStorageSchema = StorageSchema.describe(
767
783
  var MaximumStorageSchema = StorageSchema.describe(
768
784
  "The upper limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
769
785
  );
770
- var EcpuSchema = z23.number().int().min(1e3).max(15e6);
786
+ var EcpuSchema = z24.number().int().min(1e3).max(15e6);
771
787
  var MinimumEcpuSchema = EcpuSchema.describe(
772
788
  "The minimum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
773
789
  );
774
790
  var MaximumEcpuSchema = EcpuSchema.describe(
775
791
  "The maximum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
776
792
  );
777
- var CachesSchema = z23.record(
793
+ var CachesSchema = z24.record(
778
794
  ResourceIdSchema,
779
- z23.object({
795
+ z24.object({
780
796
  minStorage: MinimumStorageSchema.optional(),
781
797
  maxStorage: MaximumStorageSchema.optional(),
782
798
  minECPU: MinimumEcpuSchema.optional(),
783
799
  maxECPU: MaximumEcpuSchema.optional(),
784
- snapshotRetentionLimit: z23.number().int().positive().default(1)
800
+ snapshotRetentionLimit: z24.number().int().positive().default(1)
785
801
  })
786
802
  ).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
787
803
 
788
804
  // src/feature/command/schema.ts
789
- import { z as z24 } from "zod";
790
- var CommandSchema = z24.union([
791
- z24.object({
805
+ import { z as z25 } from "zod";
806
+ var CommandSchema = z25.union([
807
+ z25.object({
792
808
  file: LocalFileSchema,
793
- handler: z24.string().default("default").describe("The name of the handler that needs to run"),
794
- description: z24.string().optional().describe("A description of the command")
809
+ handler: z25.string().default("default").describe("The name of the handler that needs to run"),
810
+ description: z25.string().optional().describe("A description of the command")
795
811
  // options: z.record(ResourceIdSchema, OptionSchema).optional(),
796
812
  // arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
797
813
  }),
@@ -801,22 +817,22 @@ var CommandSchema = z24.union([
801
817
  description: void 0
802
818
  }))
803
819
  ]);
804
- var CommandsSchema = z24.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
820
+ var CommandsSchema = z25.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
805
821
 
806
822
  // src/feature/config/schema.ts
807
- import { z as z25 } from "zod";
808
- var ConfigNameSchema = z25.string().regex(/[a-z0-9\-]/g, "Invalid config name");
809
- var ConfigsSchema = z25.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
823
+ import { z as z26 } from "zod";
824
+ var ConfigNameSchema = z26.string().regex(/[a-z0-9\-]/g, "Invalid config name");
825
+ var ConfigsSchema = z26.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
810
826
 
811
827
  // src/feature/cron/schema/index.ts
812
- import { z as z27 } from "zod";
828
+ import { z as z28 } from "zod";
813
829
 
814
830
  // src/feature/cron/schema/schedule.ts
815
- import { z as z26 } from "zod";
831
+ import { z as z27 } from "zod";
816
832
  import { awsCronExpressionValidator } from "aws-cron-expression-validator";
817
- var RateExpressionSchema = z26.custom(
833
+ var RateExpressionSchema = z27.custom(
818
834
  (value) => {
819
- return z26.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
835
+ return z27.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
820
836
  const [str] = rate.split(" ");
821
837
  const number = parseInt(str);
822
838
  return number > 0;
@@ -832,9 +848,9 @@ var RateExpressionSchema = z26.custom(
832
848
  }
833
849
  return `rate(${rate})`;
834
850
  });
835
- var CronExpressionSchema = z26.custom(
851
+ var CronExpressionSchema = z27.custom(
836
852
  (value) => {
837
- return z26.string().safeParse(value).success;
853
+ return z27.string().safeParse(value).success;
838
854
  },
839
855
  { message: "Invalid cron expression" }
840
856
  ).superRefine((value, ctx) => {
@@ -843,12 +859,12 @@ var CronExpressionSchema = z26.custom(
843
859
  } catch (error) {
844
860
  if (error instanceof Error) {
845
861
  ctx.addIssue({
846
- code: z26.ZodIssueCode.custom,
862
+ code: z27.ZodIssueCode.custom,
847
863
  message: `Invalid cron expression: ${error.message}`
848
864
  });
849
865
  } else {
850
866
  ctx.addIssue({
851
- code: z26.ZodIssueCode.custom,
867
+ code: z27.ZodIssueCode.custom,
852
868
  message: "Invalid cron expression"
853
869
  });
854
870
  }
@@ -859,28 +875,28 @@ var CronExpressionSchema = z26.custom(
859
875
  var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
860
876
 
861
877
  // src/feature/cron/schema/index.ts
862
- var CronsSchema = z27.record(
878
+ var CronsSchema = z28.record(
863
879
  ResourceIdSchema,
864
- z27.object({
865
- enabled: z27.boolean().default(true).describe("If the cron is enabled."),
880
+ z28.object({
881
+ enabled: z28.boolean().default(true).describe("If the cron is enabled."),
866
882
  consumer: FunctionSchema.describe("The consuming lambda function properties."),
867
883
  schedule: ScheduleExpressionSchema.describe(
868
884
  'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
869
885
  ),
870
- payload: z27.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
886
+ payload: z28.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
871
887
  })
872
888
  ).optional().describe(`Define the cron jobs in your stack.`);
873
889
 
874
890
  // src/feature/search/schema.ts
875
891
  import { gibibytes as gibibytes3 } from "@awsless/size";
876
- import { z as z28 } from "zod";
877
- var VersionSchema = z28.union([
892
+ import { z as z29 } from "zod";
893
+ var VersionSchema = z29.union([
878
894
  //
879
- z28.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
880
- z28.string()
895
+ z29.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
896
+ z29.string()
881
897
  ]).describe("Specify the OpenSearch engine version.");
882
- var TypeSchema = z28.union([
883
- z28.enum([
898
+ var TypeSchema = z29.union([
899
+ z29.enum([
884
900
  "t3.small",
885
901
  "t3.medium",
886
902
  "m3.medium",
@@ -954,13 +970,13 @@ var TypeSchema = z28.union([
954
970
  "r6gd.12xlarge",
955
971
  "r6gd.16xlarge"
956
972
  ]),
957
- z28.string()
973
+ z29.string()
958
974
  ]).describe("Instance type of data nodes in the cluster.");
959
- var CountSchema = z28.number().int().min(1).describe("Number of instances in the cluster.");
975
+ var CountSchema = z29.number().int().min(1).describe("Number of instances in the cluster.");
960
976
  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.");
961
- var SearchsSchema = z28.record(
977
+ var SearchsSchema = z29.record(
962
978
  ResourceIdSchema,
963
- z28.object({
979
+ z29.object({
964
980
  type: TypeSchema.default("t3.small"),
965
981
  count: CountSchema.default(1),
966
982
  version: VersionSchema.default("2.13"),
@@ -971,12 +987,12 @@ var SearchsSchema = z28.record(
971
987
  ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
972
988
 
973
989
  // src/feature/site/schema.ts
974
- import { z as z30 } from "zod";
990
+ import { z as z31 } from "zod";
975
991
 
976
992
  // src/config/schema/local-entry.ts
977
993
  import { stat as stat3 } from "fs/promises";
978
- import { z as z29 } from "zod";
979
- var LocalEntrySchema = z29.union([
994
+ import { z as z30 } from "zod";
995
+ var LocalEntrySchema = z30.union([
980
996
  RelativePathSchema.refine(async (path) => {
981
997
  try {
982
998
  const s = await stat3(path);
@@ -985,7 +1001,7 @@ var LocalEntrySchema = z29.union([
985
1001
  return false;
986
1002
  }
987
1003
  }, `File or directory doesn't exist`),
988
- z29.object({
1004
+ z30.object({
989
1005
  nocheck: RelativePathSchema.describe(
990
1006
  "Specifies a local file or directory without checking if the file or directory exists."
991
1007
  )
@@ -993,14 +1009,14 @@ var LocalEntrySchema = z29.union([
993
1009
  ]);
994
1010
 
995
1011
  // src/feature/site/schema.ts
996
- var ErrorResponsePathSchema = z30.string().describe(
1012
+ var ErrorResponsePathSchema = z31.string().describe(
997
1013
  [
998
1014
  "The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.",
999
1015
  "- We recommend that you store custom error pages in an Amazon S3 bucket.",
1000
1016
  "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."
1001
1017
  ].join("\n")
1002
1018
  );
1003
- var StatusCodeSchema = z30.number().int().positive().optional().describe(
1019
+ var StatusCodeSchema = z31.number().int().positive().optional().describe(
1004
1020
  [
1005
1021
  "The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.",
1006
1022
  "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:",
@@ -1013,19 +1029,19 @@ var StatusCodeSchema = z30.number().int().positive().optional().describe(
1013
1029
  var MinTTLSchema = DurationSchema.describe(
1014
1030
  "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."
1015
1031
  );
1016
- var ErrorResponseSchema = z30.union([
1032
+ var ErrorResponseSchema = z31.union([
1017
1033
  ErrorResponsePathSchema,
1018
- z30.object({
1034
+ z31.object({
1019
1035
  path: ErrorResponsePathSchema,
1020
1036
  statusCode: StatusCodeSchema.optional(),
1021
1037
  minTTL: MinTTLSchema.optional()
1022
1038
  })
1023
1039
  ]).optional();
1024
- var SitesSchema = z30.record(
1040
+ var SitesSchema = z31.record(
1025
1041
  ResourceIdSchema,
1026
- z30.object({
1042
+ z31.object({
1027
1043
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1028
- subDomain: z30.string().optional(),
1044
+ subDomain: z31.string().optional(),
1029
1045
  // bind: z
1030
1046
  // .object({
1031
1047
  // auth: z.array(ResourceIdSchema),
@@ -1034,16 +1050,16 @@ var SitesSchema = z30.record(
1034
1050
  // // rest: z.array(ResourceIdSchema),
1035
1051
  // })
1036
1052
  // .optional(),
1037
- build: z30.object({
1038
- command: z30.string().describe(
1053
+ build: z31.object({
1054
+ command: z31.string().describe(
1039
1055
  `Specifies the files and directories to generate the cache key for your custom build command.`
1040
1056
  ),
1041
- cacheKey: z30.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1057
+ cacheKey: z31.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1042
1058
  `Specifies the files and directories to generate the cache key for your custom build command.`
1043
1059
  ),
1044
- configs: z30.string().array().describe("Define the config values for your build command.")
1060
+ configs: z31.string().array().describe("Define the config values for your build command.")
1045
1061
  }).optional().describe(`Specifies the build process for sites that need a build step.`),
1046
- static: z30.union([LocalDirectorySchema, z30.boolean()]).optional().describe(
1062
+ static: z31.union([LocalDirectorySchema, z31.boolean()]).optional().describe(
1047
1063
  "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."
1048
1064
  ),
1049
1065
  ssr: FunctionSchema.optional().describe("Specifies the file that will render the site on the server."),
@@ -1064,7 +1080,7 @@ var SitesSchema = z30.record(
1064
1080
  // build: z.string().optional(),
1065
1081
  // }),
1066
1082
  // ]),
1067
- geoRestrictions: z30.array(z30.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1083
+ geoRestrictions: z31.array(z31.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
1068
1084
  // forwardHost: z
1069
1085
  // .boolean()
1070
1086
  // .default(false)
@@ -1075,7 +1091,7 @@ var SitesSchema = z30.record(
1075
1091
  // 'Keep in mind that this requires an extra CloudFront Function.',
1076
1092
  // ].join('\n')
1077
1093
  // ),
1078
- errors: z30.object({
1094
+ errors: z31.object({
1079
1095
  400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
1080
1096
  403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
1081
1097
  404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
@@ -1088,20 +1104,20 @@ var SitesSchema = z30.record(
1088
1104
  503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
1089
1105
  504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
1090
1106
  }).optional().describe("Customize the error responses for specific HTTP status codes."),
1091
- cors: z30.object({
1092
- override: z30.boolean().default(false),
1107
+ cors: z31.object({
1108
+ override: z31.boolean().default(false),
1093
1109
  maxAge: DurationSchema.default("365 days"),
1094
- exposeHeaders: z30.string().array().optional(),
1095
- credentials: z30.boolean().default(false),
1096
- headers: z30.string().array().default(["*"]),
1097
- origins: z30.string().array().default(["*"]),
1098
- methods: z30.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1110
+ exposeHeaders: z31.string().array().optional(),
1111
+ credentials: z31.boolean().default(false),
1112
+ headers: z31.string().array().default(["*"]),
1113
+ origins: z31.string().array().default(["*"]),
1114
+ methods: z31.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
1099
1115
  }).optional().describe("Specify the cors headers."),
1100
- auth: z30.object({
1101
- username: z30.string().describe("Basic auth username"),
1102
- password: z30.string().describe("Basic auth password")
1116
+ auth: z31.object({
1117
+ username: z31.string().describe("Basic auth username"),
1118
+ password: z31.string().describe("Basic auth password")
1103
1119
  }).optional().describe("Enable basic authentication for the site"),
1104
- security: z30.object({
1120
+ security: z31.object({
1105
1121
  // contentSecurityPolicy: z.object({
1106
1122
  // override: z.boolean().default(false),
1107
1123
  // policy: z.string(),
@@ -1143,10 +1159,10 @@ var SitesSchema = z30.record(
1143
1159
  // reportUri?: string
1144
1160
  // }
1145
1161
  }).optional().describe("Specify the security policy."),
1146
- cache: z30.object({
1147
- cookies: z30.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1148
- headers: z30.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1149
- queries: z30.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1162
+ cache: z31.object({
1163
+ cookies: z31.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
1164
+ headers: z31.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
1165
+ queries: z31.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
1150
1166
  }).optional().describe(
1151
1167
  "Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
1152
1168
  )
@@ -1154,22 +1170,22 @@ var SitesSchema = z30.record(
1154
1170
  ).optional().describe("Define the sites in your stack.");
1155
1171
 
1156
1172
  // src/feature/store/schema.ts
1157
- import { z as z31 } from "zod";
1158
- var StoresSchema = z31.union([
1159
- z31.array(ResourceIdSchema).transform((list) => {
1173
+ import { z as z32 } from "zod";
1174
+ var StoresSchema = z32.union([
1175
+ z32.array(ResourceIdSchema).transform((list) => {
1160
1176
  const stores = {};
1161
1177
  for (const key of list) {
1162
1178
  stores[key] = {};
1163
1179
  }
1164
1180
  return stores;
1165
1181
  }),
1166
- z31.record(
1182
+ z32.record(
1167
1183
  ResourceIdSchema,
1168
- z31.object({
1184
+ z32.object({
1169
1185
  // cors: CorsSchema,
1170
1186
  // deletionProtection: DeletionProtectionSchema.optional(),
1171
- versioning: z31.boolean().default(false).describe("Enable versioning of your store."),
1172
- events: z31.object({
1187
+ versioning: z32.boolean().default(false).describe("Enable versioning of your store."),
1188
+ events: z32.object({
1173
1189
  // create
1174
1190
  "created:*": FunctionSchema.optional().describe(
1175
1191
  "Subscribe to notifications regardless of the API that was used to create an object."
@@ -1202,58 +1218,58 @@ var StoresSchema = z31.union([
1202
1218
  ]).optional().describe("Define the stores in your stack.");
1203
1219
 
1204
1220
  // src/feature/icon/schema.ts
1205
- import { z as z32 } from "zod";
1221
+ import { z as z33 } from "zod";
1206
1222
  var staticOriginSchema = LocalDirectorySchema.describe(
1207
1223
  "Specifies the path to a local image directory that will be uploaded in S3."
1208
1224
  );
1209
1225
  var functionOriginSchema = FunctionSchema.describe(
1210
1226
  "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1211
1227
  );
1212
- var IconsSchema = z32.record(
1228
+ var IconsSchema = z33.record(
1213
1229
  ResourceIdSchema,
1214
- z32.object({
1230
+ z33.object({
1215
1231
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1216
- subDomain: z32.string().optional(),
1232
+ subDomain: z33.string().optional(),
1217
1233
  log: LogSchema.optional(),
1218
1234
  cacheDuration: DurationSchema.optional().describe("The cache duration of the cached icons."),
1219
- preserveId: z32.boolean().optional().default(false).describe("Preserve the IDs of the icons."),
1220
- symbols: z32.boolean().optional().default(false).describe("Use SVG symbols for icons."),
1221
- origin: z32.union([
1222
- z32.object({
1235
+ preserveId: z33.boolean().optional().default(false).describe("Preserve the IDs of the icons."),
1236
+ symbols: z33.boolean().optional().default(false).describe("Use SVG symbols for icons."),
1237
+ origin: z33.union([
1238
+ z33.object({
1223
1239
  static: staticOriginSchema,
1224
1240
  function: functionOriginSchema.optional()
1225
1241
  }),
1226
- z32.object({
1242
+ z33.object({
1227
1243
  static: staticOriginSchema.optional(),
1228
1244
  function: functionOriginSchema
1229
1245
  }),
1230
- z32.object({
1246
+ z33.object({
1231
1247
  static: staticOriginSchema,
1232
1248
  function: functionOriginSchema
1233
1249
  })
1234
1250
  ]).describe(
1235
1251
  "Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
1236
1252
  ),
1237
- cors: z32.object({
1238
- override: z32.boolean().default(true),
1253
+ cors: z33.object({
1254
+ override: z33.boolean().default(true),
1239
1255
  maxAge: DurationSchema.default("365 days"),
1240
- exposeHeaders: z32.string().array().optional(),
1241
- credentials: z32.boolean().default(false),
1242
- headers: z32.string().array().default(["*"]),
1243
- origins: z32.string().array().default(["*"])
1256
+ exposeHeaders: z33.string().array().optional(),
1257
+ credentials: z33.boolean().default(false),
1258
+ headers: z33.string().array().default(["*"]),
1259
+ origins: z33.string().array().default(["*"])
1244
1260
  }).optional().describe("Specify the cors headers.")
1245
1261
  // version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
1246
1262
  })
1247
1263
  ).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
1248
1264
 
1249
1265
  // src/feature/image/schema.ts
1250
- import { z as z33 } from "zod";
1251
- var transformationOptionsSchema = z33.object({
1252
- width: z33.number().int().positive().optional(),
1253
- height: z33.number().int().positive().optional(),
1254
- fit: z33.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1255
- position: z33.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1256
- quality: z33.number().int().min(1).max(100).optional()
1266
+ import { z as z34 } from "zod";
1267
+ var transformationOptionsSchema = z34.object({
1268
+ width: z34.number().int().positive().optional(),
1269
+ height: z34.number().int().positive().optional(),
1270
+ fit: z34.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1271
+ position: z34.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1272
+ quality: z34.number().int().min(1).max(100).optional()
1257
1273
  });
1258
1274
  var staticOriginSchema2 = LocalDirectorySchema.describe(
1259
1275
  "Specifies the path to a local image directory that will be uploaded in S3."
@@ -1261,68 +1277,115 @@ var staticOriginSchema2 = LocalDirectorySchema.describe(
1261
1277
  var functionOriginSchema2 = FunctionSchema.describe(
1262
1278
  "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1263
1279
  );
1264
- var ImagesSchema = z33.record(
1280
+ var ImagesSchema = z34.record(
1265
1281
  ResourceIdSchema,
1266
- z33.object({
1282
+ z34.object({
1267
1283
  domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1268
- subDomain: z33.string().optional(),
1284
+ subDomain: z34.string().optional(),
1269
1285
  log: LogSchema.optional(),
1270
1286
  cacheDuration: DurationSchema.optional().describe("Cache duration of the cached images."),
1271
- presets: z33.record(z33.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1272
- extensions: z33.object({
1273
- jpeg: z33.object({
1274
- mozjpeg: z33.boolean().optional(),
1275
- progressive: z33.boolean().optional()
1287
+ presets: z34.record(z34.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1288
+ extensions: z34.object({
1289
+ jpeg: z34.object({
1290
+ mozjpeg: z34.boolean().optional(),
1291
+ progressive: z34.boolean().optional()
1276
1292
  }).optional(),
1277
- webp: z33.object({
1278
- effort: z33.number().int().min(1).max(10).default(7).optional(),
1279
- lossless: z33.boolean().optional(),
1280
- nearLossless: z33.boolean().optional()
1293
+ webp: z34.object({
1294
+ effort: z34.number().int().min(1).max(10).default(7).optional(),
1295
+ lossless: z34.boolean().optional(),
1296
+ nearLossless: z34.boolean().optional()
1281
1297
  }).optional(),
1282
- png: z33.object({
1283
- compressionLevel: z33.number().int().min(0).max(9).default(6).optional()
1298
+ png: z34.object({
1299
+ compressionLevel: z34.number().int().min(0).max(9).default(6).optional()
1284
1300
  }).optional()
1285
1301
  }).refine((data) => {
1286
1302
  return Object.keys(data).length > 0;
1287
1303
  }, "At least one extension must be defined.").describe("Specify the allowed extensions."),
1288
- origin: z33.union([
1289
- z33.object({
1304
+ origin: z34.union([
1305
+ z34.object({
1290
1306
  static: staticOriginSchema2,
1291
1307
  function: functionOriginSchema2.optional()
1292
1308
  }),
1293
- z33.object({
1309
+ z34.object({
1294
1310
  static: staticOriginSchema2.optional(),
1295
1311
  function: functionOriginSchema2
1296
1312
  }),
1297
- z33.object({
1313
+ z34.object({
1298
1314
  static: staticOriginSchema2,
1299
1315
  function: functionOriginSchema2
1300
1316
  })
1301
1317
  ]).describe(
1302
1318
  "Specify the origin of your images. Image transformation will be applied from a base image. Base images can be loaded from a S3 bucket (that is synced from a local directory) or dynamicly from a lambda function."
1303
1319
  ),
1304
- version: z33.number().int().min(1).optional().describe("Version of the image configuration.")
1320
+ version: z34.number().int().min(1).optional().describe("Version of the image configuration.")
1305
1321
  })
1306
1322
  ).optional().describe("Define an image proxy in your stack. Store, transform, optimize, and deliver images at scale.");
1307
1323
 
1324
+ // src/feature/metric/schema.ts
1325
+ import { z as z35 } from "zod";
1326
+ var ops = {
1327
+ ">": "GreaterThanThreshold",
1328
+ ">=": "GreaterThanOrEqualToThreshold",
1329
+ "<": "LessThanThreshold",
1330
+ "<=": "LessThanOrEqualToThreshold"
1331
+ };
1332
+ var stats = {
1333
+ count: "SampleCount",
1334
+ avg: "Average",
1335
+ sum: "Sum",
1336
+ min: "Minimum",
1337
+ max: "Maximum"
1338
+ };
1339
+ var WhereSchema = z35.union([
1340
+ z35.string().regex(/(count|avg|sum|min|max) (>|>=|<|<=) (\d)/, "Invalid where query").transform((where) => {
1341
+ const [stat4, op, value] = where.split(" ");
1342
+ return { stat: stat4, op, value: parseFloat(value) };
1343
+ }),
1344
+ z35.object({
1345
+ stat: z35.enum(["count", "avg", "sum", "min", "max"]),
1346
+ op: z35.enum([">", ">=", "<", "<="]),
1347
+ value: z35.number()
1348
+ })
1349
+ ]).transform((where) => {
1350
+ return {
1351
+ stat: stats[where.stat],
1352
+ op: ops[where.op],
1353
+ value: where.value
1354
+ };
1355
+ });
1356
+ var AlarmSchema = z35.object({
1357
+ description: z35.string().optional(),
1358
+ where: WhereSchema,
1359
+ period: DurationSchema,
1360
+ minDataPoints: z35.number().int().default(1),
1361
+ trigger: z35.union([EmailSchema.transform((v) => [v]), EmailSchema.array(), FunctionSchema])
1362
+ });
1363
+ var MetricsSchema = z35.record(
1364
+ ResourceIdSchema,
1365
+ z35.object({
1366
+ type: z35.enum(["number", "size", "duration"]),
1367
+ alarms: AlarmSchema.array().optional()
1368
+ })
1369
+ ).optional().describe("Define the metrics in your stack.");
1370
+
1308
1371
  // src/feature/table/schema.ts
1309
1372
  import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
1310
- import { z as z34 } from "zod";
1311
- var KeySchema = z34.string().min(1).max(255);
1312
- var TablesSchema = z34.record(
1373
+ import { z as z36 } from "zod";
1374
+ var KeySchema = z36.string().min(1).max(255);
1375
+ var TablesSchema = z36.record(
1313
1376
  ResourceIdSchema,
1314
- z34.object({
1377
+ z36.object({
1315
1378
  hash: KeySchema.describe(
1316
1379
  "Specifies the name of the partition / hash key that makes up the primary key for the table."
1317
1380
  ),
1318
1381
  sort: KeySchema.optional().describe(
1319
1382
  "Specifies the name of the range / sort key that makes up the primary key for the table."
1320
1383
  ),
1321
- fields: z34.record(z34.string(), z34.enum(["string", "number", "binary"])).optional().describe(
1384
+ fields: z36.record(z36.string(), z36.enum(["string", "number", "binary"])).optional().describe(
1322
1385
  'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
1323
1386
  ),
1324
- class: z34.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1325
- pointInTimeRecovery: z34.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1387
+ class: z36.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1388
+ pointInTimeRecovery: z36.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1326
1389
  ttl: KeySchema.optional().describe(
1327
1390
  [
1328
1391
  "The name of the TTL attribute used to store the expiration time for items in the table.",
@@ -1330,8 +1393,8 @@ var TablesSchema = z34.record(
1330
1393
  ].join("\n")
1331
1394
  ),
1332
1395
  // deletionProtection: DeletionProtectionSchema.optional(),
1333
- stream: z34.object({
1334
- type: z34.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1396
+ stream: z36.object({
1397
+ type: z36.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1335
1398
  [
1336
1399
  "When an item in the table is modified, you can determines what information is written to the stream for this table.",
1337
1400
  "Valid values are:",
@@ -1341,7 +1404,7 @@ var TablesSchema = z34.record(
1341
1404
  "- new-and-old-images - Both the new and the old item images of the item are written to the stream."
1342
1405
  ].join("\n")
1343
1406
  ),
1344
- batchSize: z34.number().min(1).max(1e4).default(1).describe(
1407
+ batchSize: z36.number().min(1).max(1e4).default(1).describe(
1345
1408
  [
1346
1409
  "The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
1347
1410
  "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).",
@@ -1371,7 +1434,7 @@ var TablesSchema = z34.record(
1371
1434
  // 'You can specify a number from -1 to 10000.',
1372
1435
  // ].join('\n')
1373
1436
  // ),
1374
- retryAttempts: z34.number().min(-1).max(1e4).default(-1).describe(
1437
+ retryAttempts: z36.number().min(-1).max(1e4).default(-1).describe(
1375
1438
  [
1376
1439
  "Discard records after the specified number of retries.",
1377
1440
  "The default value is -1, which sets the maximum number of retries to infinite.",
@@ -1379,7 +1442,7 @@ var TablesSchema = z34.record(
1379
1442
  "You can specify a number from -1 to 10000."
1380
1443
  ].join("\n")
1381
1444
  ),
1382
- concurrencyPerShard: z34.number().min(1).max(10).default(1).describe(
1445
+ concurrencyPerShard: z36.number().min(1).max(10).default(1).describe(
1383
1446
  [
1384
1447
  "The number of batches to process concurrently from each shard.",
1385
1448
  "You can specify a number from 1 to 10."
@@ -1389,16 +1452,16 @@ var TablesSchema = z34.record(
1389
1452
  }).optional().describe(
1390
1453
  "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
1391
1454
  ),
1392
- indexes: z34.record(
1393
- z34.string(),
1394
- z34.object({
1455
+ indexes: z36.record(
1456
+ z36.string(),
1457
+ z36.object({
1395
1458
  hash: KeySchema.describe(
1396
1459
  "Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
1397
1460
  ),
1398
1461
  sort: KeySchema.optional().describe(
1399
1462
  "Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
1400
1463
  ),
1401
- projection: z34.enum(["all", "keys-only"]).default("all").describe(
1464
+ projection: z36.enum(["all", "keys-only"]).default("all").describe(
1402
1465
  [
1403
1466
  "The set of attributes that are projected into the index:",
1404
1467
  "- all - All of the table attributes are projected into the index.",
@@ -1412,11 +1475,11 @@ var TablesSchema = z34.record(
1412
1475
  ).optional().describe("Define the tables in your stack.");
1413
1476
 
1414
1477
  // src/feature/task/schema.ts
1415
- import { z as z35 } from "zod";
1416
- var RetryAttemptsSchema2 = z35.number().int().min(0).max(2).describe(
1478
+ import { z as z37 } from "zod";
1479
+ var RetryAttemptsSchema2 = z37.number().int().min(0).max(2).describe(
1417
1480
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
1418
1481
  );
1419
- var TaskSchema = z35.union([
1482
+ var TaskSchema = z37.union([
1420
1483
  LocalFileSchema.transform((file) => ({
1421
1484
  consumer: {
1422
1485
  code: {
@@ -1427,33 +1490,24 @@ var TaskSchema = z35.union([
1427
1490
  },
1428
1491
  retryAttempts: void 0
1429
1492
  })),
1430
- z35.object({
1493
+ z37.object({
1431
1494
  consumer: FunctionSchema,
1432
1495
  retryAttempts: RetryAttemptsSchema2.optional()
1433
1496
  })
1434
1497
  ]);
1435
- var TasksSchema = z35.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1498
+ var TasksSchema = z37.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1436
1499
 
1437
1500
  // src/feature/test/schema.ts
1438
- import { z as z36 } from "zod";
1439
- var TestsSchema = z36.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1440
-
1441
- // src/feature/topic/schema.ts
1442
- import { kebabCase as kebabCase3 } from "change-case";
1443
- import { z as z37 } from "zod";
1444
- 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.");
1445
- var TopicsSchema = z37.array(TopicNameSchema).refine((topics) => {
1446
- return topics.length === new Set(topics).size;
1447
- }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
1448
- var SubscribersSchema = z37.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1501
+ import { z as z38 } from "zod";
1502
+ var TestsSchema = z38.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1449
1503
 
1450
1504
  // src/config/stack.ts
1451
1505
  var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
1452
1506
  var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
1453
1507
  message: `Stack name can't be a reserved name.`
1454
1508
  }).describe("Stack name.");
1455
- var StackSchema = z38.object({
1456
- $schema: z38.string().optional(),
1509
+ var StackSchema = z39.object({
1510
+ $schema: z39.string().optional(),
1457
1511
  name: NameSchema,
1458
1512
  depends: DependsSchema,
1459
1513
  commands: CommandsSchema,
@@ -1466,7 +1520,7 @@ var StackSchema = z38.object({
1466
1520
  configs: ConfigsSchema,
1467
1521
  crons: CronsSchema,
1468
1522
  caches: CachesSchema,
1469
- topics: TopicsSchema,
1523
+ // topics: TopicsSchema,
1470
1524
  subscribers: SubscribersSchema,
1471
1525
  functions: FunctionsSchema,
1472
1526
  instances: InstancesSchema,
@@ -1480,7 +1534,8 @@ var StackSchema = z38.object({
1480
1534
  sites: SitesSchema,
1481
1535
  tests: TestsSchema,
1482
1536
  images: ImagesSchema,
1483
- icons: IconsSchema
1537
+ icons: IconsSchema,
1538
+ metrics: MetricsSchema
1484
1539
  });
1485
1540
 
1486
1541
  // cli/build-json-schema.ts