@awsless/cli 0.0.46-next.2 → 0.0.46-next.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1963 +0,0 @@
1
- // cli/build-json-schema.ts
2
- import { writeFileSync } from "fs";
3
- import { join as join2 } from "path";
4
- import { zodToJsonSchema } from "zod-to-json-schema";
5
-
6
- // src/config/app.ts
7
- import { z as z25 } from "zod";
8
-
9
- // src/feature/alert/schema.ts
10
- import { kebabCase } from "change-case";
11
- import { z as z2 } from "zod";
12
-
13
- // src/config/schema/email.ts
14
- import { z } from "zod";
15
- var EmailSchema = z.string().email();
16
-
17
- // src/feature/alert/schema.ts
18
- var AlertNameSchema = z2.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid alert name").transform((value) => kebabCase(value)).describe("Define alert name.");
19
- var AlertsDefaultSchema = z2.record(
20
- AlertNameSchema,
21
- z2.union([
22
- //
23
- EmailSchema.transform((v) => [v]),
24
- EmailSchema.array()
25
- ])
26
- ).optional().describe("Define the alerts in your app. Alerts are a way to send messages to one or more email addresses.");
27
-
28
- // src/feature/auth/schema.ts
29
- import { z as z5 } from "zod";
30
-
31
- // src/config/schema/resource-id.ts
32
- import { kebabCase as kebabCase2 } from "change-case";
33
- import { z as z3 } from "zod";
34
- var ResourceIdSchema = z3.string().min(3).max(24).regex(/^[a-z0-9\-]+$/i, "Invalid resource ID").transform((value) => kebabCase2(value));
35
-
36
- // src/config/schema/duration.ts
37
- import { parse } from "@awsless/duration";
38
- import { z as z4 } from "zod";
39
- var DurationSchema = z4.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?|weeks?)$/, "Invalid duration").transform((v) => parse(v));
40
- var durationMin = (min) => {
41
- return (duration) => {
42
- return duration.value >= min.value;
43
- };
44
- };
45
- var durationMax = (max) => {
46
- return (duration) => {
47
- return duration.value <= max.value;
48
- };
49
- };
50
-
51
- // src/feature/auth/schema.ts
52
- var AuthDefaultSchema = z5.record(
53
- ResourceIdSchema,
54
- z5.object({
55
- allowUserRegistration: z5.boolean().default(true).describe("Specifies whether users can create an user account or if only the administrator can."),
56
- // messaging: z
57
- // .object({
58
- // fromEmail: EmailSchema.describe("Specifies the sender's email address."),
59
- // fromName: z.string().optional().describe("Specifies the sender's name."),
60
- // replyTo: EmailSchema.optional().describe(
61
- // 'The destination to which the receiver of the email should reply.'
62
- // ),
63
- // })
64
- // .optional()
65
- // .describe('The email configuration for sending messages.'),
66
- // secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
67
- groups: z5.string().array().default([]).describe("Specifies a list of groups that a user can belong to."),
68
- username: z5.object({
69
- // emailAlias: z.boolean().default(true).describe('Allow the user email to be used as username.'),
70
- caseSensitive: z5.boolean().default(false).describe(
71
- "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."
72
- )
73
- }).default({}).describe("The username policy."),
74
- password: z5.object({
75
- minLength: z5.number().int().min(6).max(99).default(12).describe("Required users to have at least the minimum password length."),
76
- uppercase: z5.boolean().default(true).describe("Required users to use at least one uppercase letter in their password."),
77
- lowercase: z5.boolean().default(true).describe("Required users to use at least one lowercase letter in their password."),
78
- numbers: z5.boolean().default(true).describe("Required users to use at least one number in their password."),
79
- symbols: z5.boolean().default(true).describe("Required users to use at least one symbol in their password."),
80
- temporaryPasswordValidity: DurationSchema.default("7 days").describe(
81
- "The duration a temporary password is valid. If the user doesn't sign in during this time, an administrator must reset their password."
82
- )
83
- }).default({}).describe("The password policy."),
84
- validity: z5.object({
85
- idToken: DurationSchema.default("1 hour").describe(
86
- "The ID token time limit. After this limit expires, your user can't use their ID token."
87
- ),
88
- accessToken: DurationSchema.default("1 hour").describe(
89
- "The access token time limit. After this limit expires, your user can't use their access token."
90
- ),
91
- refreshToken: DurationSchema.default("365 days").describe(
92
- "The refresh token time limit. After this limit expires, your user can't use their refresh token."
93
- )
94
- }).default({}).describe("Specifies the validity duration for every JWT token.")
95
- // triggers: TriggersSchema.optional(),
96
- })
97
- ).default({}).describe("Define the authenticatable users in your app.");
98
-
99
- // src/feature/domain/schema.ts
100
- import { z as z6 } from "zod";
101
- var DomainNameSchema = z6.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
102
- "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."
103
- );
104
- var DNSTypeSchema = z6.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
105
- var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
106
- var RecordsSchema = z6.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
107
- var DomainsDefaultSchema = z6.record(
108
- ResourceIdSchema,
109
- z6.object({
110
- domain: DomainNameSchema.describe("Define the domain name"),
111
- dns: z6.object({
112
- name: DomainNameSchema.optional(),
113
- type: DNSTypeSchema,
114
- ttl: TTLSchema,
115
- records: RecordsSchema
116
- }).array().optional().describe("Define the domain dns records")
117
- })
118
- ).optional().describe("Define the domains for your application.");
119
-
120
- // src/feature/function/schema.ts
121
- import { days, minutes, seconds, toDays } from "@awsless/duration";
122
- import { gibibytes, mebibytes } from "@awsless/size";
123
- import { z as z10 } from "zod";
124
-
125
- // src/config/schema/local-file.ts
126
- import { stat } from "fs/promises";
127
- import { z as z8 } from "zod";
128
-
129
- // src/config/schema/relative-path.ts
130
- import { join } from "path";
131
- import { z as z7 } from "zod";
132
- var basePath;
133
- var resolvePath = (path) => {
134
- if (path.startsWith(".") && basePath) {
135
- return join(basePath, path);
136
- }
137
- return path;
138
- };
139
- var RelativePathSchema = z7.string().transform((path) => resolvePath(path));
140
-
141
- // src/config/schema/local-file.ts
142
- var LocalFileSchema = z8.union([
143
- RelativePathSchema.refine(async (path) => {
144
- try {
145
- const s = await stat(path);
146
- return s.isFile();
147
- } catch (error) {
148
- return false;
149
- }
150
- }, `File doesn't exist`),
151
- z8.object({
152
- nocheck: RelativePathSchema.describe("Specifies a local file without checking if the file exists.")
153
- }).transform((v) => v.nocheck)
154
- ]);
155
-
156
- // src/config/schema/size.ts
157
- import { parse as parse2 } from "@awsless/size";
158
- import { z as z9 } from "zod";
159
- var SizeSchema = z9.string().regex(/^[0-9]+ (B|KB|MB|GB|TB|PB)$/, "Invalid size").transform((v) => parse2(v));
160
- var sizeMin = (min) => {
161
- return (size) => {
162
- return size.value >= min.value;
163
- };
164
- };
165
- var sizeMax = (max) => {
166
- return (size) => {
167
- return size.value <= max.value;
168
- };
169
- };
170
-
171
- // src/feature/function/schema.ts
172
- var MemorySizeSchema = SizeSchema.refine(sizeMin(mebibytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(gibibytes(10)), "Maximum memory size is 10 GB").describe(
173
- "The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The value can be any multiple of 1 MB. You can specify a size value from 128 MB to 10 GB."
174
- );
175
- var TimeoutSchema = DurationSchema.refine(durationMin(seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes(15)), "Maximum timeout duration is 15 minutes").describe(
176
- "The amount of time that Lambda allows a function to run before stopping it. You can specify a size value from 1 second to 15 minutes."
177
- );
178
- var EnvironmentSchema = z10.record(z10.string(), z10.string()).optional().describe("Environment variable key-value pairs.");
179
- var ArchitectureSchema = z10.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
180
- var RuntimeSchema = z10.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x", "nodejs24.x"]).or(z10.literal("container")).or(z10.string()).describe("The identifier of the function's runtime.");
181
- var ActionSchema = z10.string();
182
- var ActionsSchema = z10.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
183
- var ArnSchema = z10.string().startsWith("arn:");
184
- var WildcardSchema = z10.literal("*");
185
- var ResourceSchema = z10.union([ArnSchema, WildcardSchema]);
186
- var ResourcesSchema = z10.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
187
- var PermissionSchema = z10.object({
188
- effect: z10.enum(["allow", "deny"]).default("allow"),
189
- actions: ActionsSchema,
190
- resources: ResourcesSchema
191
- });
192
- var PermissionsSchema = z10.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
193
- var MinifySchema = z10.boolean().describe("Minify the function code.");
194
- var HandlerSchema = z10.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
195
- var validLogRetentionDays = [
196
- ...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
197
- ...[180, 365, 400, 545, 731, 1096, 1827, 2192],
198
- ...[2557, 2922, 3288, 3653]
199
- ];
200
- var LogRetentionSchema = DurationSchema.refine(
201
- durationMin(days(0)),
202
- "Minimum log retention is 0 day, which will disable logging."
203
- ).refine(
204
- (duration) => {
205
- return validLogRetentionDays.includes(toDays(duration));
206
- },
207
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days8) => `${days8}`).join(", ")}`
208
- ).describe("The log retention duration.");
209
- var LogSchema = z10.union([
210
- z10.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
211
- LogRetentionSchema.transform((retention) => ({ retention })),
212
- z10.object({
213
- retention: LogRetentionSchema.optional(),
214
- format: z10.enum(["text", "json"]).describe(
215
- `The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
216
- ).optional(),
217
- system: z10.enum(["debug", "info", "warn"]).describe(
218
- "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."
219
- ).optional(),
220
- level: z10.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
221
- "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."
222
- ).optional()
223
- })
224
- ]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
225
- var FileCodeSchema = z10.object({
226
- file: LocalFileSchema.describe("The file path of the function code."),
227
- minify: MinifySchema.optional().default(true),
228
- external: z10.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`),
229
- importAsString: z10.string().array().optional().describe(`A list of glob patterns, which specifies the files that should be imported as string.`)
230
- });
231
- var CodeSchema = z10.union([
232
- LocalFileSchema.transform((file) => ({
233
- file
234
- })).pipe(FileCodeSchema),
235
- FileCodeSchema
236
- ]).describe("Specify the code of your function.");
237
- var FnSchema = z10.object({
238
- code: CodeSchema,
239
- handler: HandlerSchema.optional()
240
- });
241
- var FunctionSchema = z10.union([
242
- LocalFileSchema.transform((code) => ({
243
- code
244
- })).pipe(FnSchema),
245
- FnSchema
246
- ]);
247
- var FunctionsSchema = z10.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
248
- var FunctionDefaultSchema = z10.object({
249
- runtime: RuntimeSchema.default("nodejs24.x"),
250
- handler: HandlerSchema.default("index.default"),
251
- minify: MinifySchema.default(true),
252
- external: z10.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`),
253
- log: LogSchema.default(true).transform((log) => ({
254
- retention: log.retention ?? days(7),
255
- level: "level" in log ? log.level : "error",
256
- system: "system" in log ? log.system : "warn",
257
- format: "format" in log ? log.format : "json"
258
- })),
259
- // The defaults size the shared bundle lambda, which also serves queues, crons & tasks.
260
- timeout: TimeoutSchema.default("15 minutes"),
261
- memorySize: MemorySizeSchema.default("1024 MB"),
262
- architecture: ArchitectureSchema.default("arm64"),
263
- environment: EnvironmentSchema.optional(),
264
- permissions: PermissionsSchema.optional()
265
- }).default({});
266
-
267
- // src/feature/layer/schema.ts
268
- import { z as z12 } from "zod";
269
-
270
- // src/config/schema/lambda.ts
271
- import { z as z11 } from "zod";
272
- var ArchitectureSchema2 = z11.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
273
- var NodeRuntimeSchema = z11.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]).describe("The identifier of the function's runtime.");
274
-
275
- // src/feature/layer/schema.ts
276
- var Schema = z12.object({
277
- file: LocalFileSchema,
278
- runtimes: NodeRuntimeSchema.array().optional(),
279
- architecture: ArchitectureSchema2.optional(),
280
- packages: z12.string().array().optional().describe(
281
- "Define the package names that are available bundled in the layer. Those packages are not bundled while bundling the lambda."
282
- )
283
- });
284
- var LayerSchema = z12.record(
285
- z12.string(),
286
- z12.union([
287
- LocalFileSchema.transform((file) => ({
288
- file,
289
- description: void 0
290
- })),
291
- Schema
292
- ])
293
- ).optional().describe("Define the lambda layers in your stack.");
294
-
295
- // src/feature/task/schema.ts
296
- import { z as z13 } from "zod";
297
- var TaskSchema = z13.union([
298
- FunctionSchema.transform((consumer) => ({
299
- consumer
300
- })),
301
- z13.object({
302
- consumer: FunctionSchema
303
- })
304
- ]);
305
- var TasksSchema = z13.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
306
-
307
- // src/feature/on-error-log/schema.ts
308
- var OnErrorLogDefaultSchema = TaskSchema.optional().describe(
309
- "Define a subscription on all Lambda functions logs."
310
- );
311
-
312
- // src/feature/on-failure/schema.ts
313
- import { z as z14 } from "zod";
314
- var NotifySchema = z14.union([
315
- //
316
- EmailSchema.transform((v) => [v]),
317
- EmailSchema.array()
318
- ]).describe("Receive an email notification when consuming failure entries goes wrong.");
319
- var OnFailureDefaultSchema = z14.union([
320
- FunctionSchema.transform((consumer) => ({
321
- consumer,
322
- notify: []
323
- })),
324
- z14.object({
325
- consumer: FunctionSchema,
326
- notify: NotifySchema.optional()
327
- })
328
- ]).optional().describe(
329
- [
330
- "Defining a onFailure handler will add a global onFailure handler for the following resources:",
331
- "- Tasks",
332
- "- Crons",
333
- "- Queues",
334
- "- Topics",
335
- "- Pubsub",
336
- "- Table streams"
337
- ].join("\n")
338
- );
339
-
340
- // src/feature/pubsub/schema.ts
341
- import { days as days4 } from "@awsless/duration";
342
- import { z as z17 } from "zod";
343
-
344
- // src/feature/instance/schema.ts
345
- import { days as days2, toDays as toDays2 } from "@awsless/duration";
346
- import { toMebibytes } from "@awsless/size";
347
- import { z as z15 } from "zod";
348
- var CpuSchema = z15.union([z15.literal(0.25), z15.literal(0.5), z15.literal(1), z15.literal(2), z15.literal(4), z15.literal(8), z15.literal(16)]).transform((v) => `${v} vCPU`).describe(
349
- "The number of virtual CPU units (vCPU) used by the instance. Valid values: 0.25, 0.5, 1, 2, 4, 8, 16 vCPU."
350
- );
351
- var validMemorySize = [
352
- // 0.25 vCPU
353
- 512,
354
- 1024,
355
- 2048,
356
- // 0.5 vCPU
357
- 1024,
358
- 2048,
359
- 3072,
360
- 4096,
361
- // 1 vCPU
362
- 2048,
363
- 3072,
364
- 4096,
365
- 5120,
366
- 6144,
367
- 7168,
368
- 8192,
369
- // 2 vCPU
370
- 4096,
371
- 5120,
372
- 6144,
373
- 7168,
374
- 8192,
375
- 9216,
376
- 10240,
377
- 11264,
378
- 12288,
379
- 13312,
380
- 14336,
381
- 15360,
382
- 16384
383
- ];
384
- var MemorySizeSchema2 = SizeSchema.refine(
385
- (s) => validMemorySize.includes(toMebibytes(s)),
386
- `Invalid memory size. Allowed sizes: ${validMemorySize.join(", ")} MiB`
387
- ).describe("The amount of memory (in MiB) used by the instance. Valid memory values depend on the CPU configuration.");
388
- var HealthCheckSchema = z15.object({
389
- path: z15.string().describe("The path that the container runs to determine if it is healthy."),
390
- interval: DurationSchema.describe("The time period in seconds between each health check execution."),
391
- retries: z15.number().int().min(1).max(10).describe(
392
- "The number of times to retry a failed health check before the container is considered unhealthy."
393
- ),
394
- startPeriod: DurationSchema.describe(
395
- "The optional grace period to provide containers time to bootstrap before failed health checks count towards the maximum number of retries."
396
- ),
397
- timeout: DurationSchema.describe(
398
- "The time period in seconds to wait for a health check to succeed before it is considered a failure."
399
- )
400
- }).describe("The health check command and associated configuration parameters for the container.");
401
- var EnvironmentSchema2 = z15.record(z15.string(), z15.string()).optional().describe("Environment variable key-value pairs.");
402
- var ArchitectureSchema3 = z15.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the instance supports.");
403
- var ActionSchema2 = z15.string();
404
- var ActionsSchema2 = z15.union([ActionSchema2.transform((v) => [v]), ActionSchema2.array()]);
405
- var ArnSchema2 = z15.string().startsWith("arn:");
406
- var WildcardSchema2 = z15.literal("*");
407
- var ResourceSchema2 = z15.union([ArnSchema2, WildcardSchema2]);
408
- var ResourcesSchema2 = z15.union([ResourceSchema2.transform((v) => [v]), ResourceSchema2.array()]);
409
- var PermissionSchema2 = z15.object({
410
- effect: z15.enum(["allow", "deny"]).default("allow"),
411
- actions: ActionsSchema2,
412
- resources: ResourcesSchema2
413
- });
414
- var PermissionsSchema2 = z15.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
415
- var DescriptionSchema = z15.string().describe("A description of the instance.");
416
- var ImageSchema = z15.string().optional().describe("The URL of the container image to use. Default: public.ecr.aws/aws-cli/aws-cli:{architecture}");
417
- var validLogRetentionDays2 = [
418
- ...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
419
- ...[180, 365, 400, 545, 731, 1096, 1827, 2192],
420
- ...[2557, 2922, 3288, 3653]
421
- ];
422
- var LogRetentionSchema2 = DurationSchema.refine(
423
- durationMin(days2(0)),
424
- "Minimum log retention is 0 day, which will disable logging."
425
- ).refine(
426
- (duration) => {
427
- return validLogRetentionDays2.includes(toDays2(duration));
428
- },
429
- `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days8) => `${days8}`).join(", ")}`
430
- ).describe("The log retention duration.");
431
- var LogSchema2 = z15.union([
432
- z15.boolean().transform((enabled) => ({ retention: enabled ? days2(7) : days2(0) })),
433
- LogRetentionSchema2.transform((retention) => ({ retention })),
434
- z15.object({
435
- retention: LogRetentionSchema2.optional()
436
- })
437
- ]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
438
- var FileCodeSchema2 = z15.object({
439
- file: LocalFileSchema.describe("The file path of the instance code.")
440
- });
441
- var CodeSchema2 = z15.union([
442
- LocalFileSchema.transform((file) => ({
443
- file
444
- })).pipe(FileCodeSchema2),
445
- FileCodeSchema2
446
- ]).describe("Specify the code of your instance.");
447
- var StartupCommandSchema = z15.union([z15.string().transform((v) => [v]), z15.string().array()]).describe("Optional shell commands to run before the instance program starts.");
448
- var ISchema = z15.object({
449
- code: CodeSchema2,
450
- description: DescriptionSchema.optional(),
451
- image: ImageSchema.optional(),
452
- startupCommand: StartupCommandSchema.optional(),
453
- log: LogSchema2.optional(),
454
- cpu: CpuSchema.optional(),
455
- memorySize: MemorySizeSchema2.optional(),
456
- architecture: ArchitectureSchema3.optional(),
457
- environment: EnvironmentSchema2.optional(),
458
- permissions: PermissionsSchema2.optional(),
459
- healthCheck: HealthCheckSchema.optional()
460
- // restartPolicy: RestartPolicySchema.optional(),
461
- });
462
- var InstanceSchema = z15.union([
463
- LocalFileSchema.transform((code) => ({
464
- code
465
- })).pipe(ISchema),
466
- ISchema
467
- ]);
468
- var InstancesSchema = z15.record(ResourceIdSchema, InstanceSchema).optional().describe("Define the instances in your stack.");
469
- var InstanceDefaultSchema = z15.object({
470
- image: ImageSchema.optional(),
471
- cpu: CpuSchema.default(0.25),
472
- memorySize: MemorySizeSchema2.default("512 MB"),
473
- architecture: ArchitectureSchema3.default("arm64"),
474
- environment: EnvironmentSchema2.optional(),
475
- permissions: PermissionsSchema2.optional(),
476
- healthCheck: HealthCheckSchema.optional(),
477
- // restartPolicy: RestartPolicySchema.default({ enabled: true }),
478
- log: LogSchema2.default(true).transform((log) => ({
479
- retention: log.retention ?? days2(7)
480
- }))
481
- }).default({});
482
-
483
- // src/feature/router/schema.ts
484
- import { days as days3, minutes as minutes2, parse as parse3 } from "@awsless/duration";
485
- import { z as z16 } from "zod";
486
- var ErrorResponsePathSchema = z16.string().describe(
487
- [
488
- "The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.",
489
- "- We recommend that you store custom error pages in an Amazon S3 bucket.",
490
- "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."
491
- ].join("\n")
492
- );
493
- var StatusCodeSchema = z16.number().int().positive().optional().describe(
494
- [
495
- "The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.",
496
- "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:",
497
- "- 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.",
498
- "If you substitute 200, the response typically won't be intercepted.",
499
- `- 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.`,
500
- `- You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down.`
501
- ].join("\n")
502
- );
503
- var MinTTLSchema = DurationSchema.describe(
504
- "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."
505
- );
506
- var ErrorResponseSchema = z16.union([
507
- ErrorResponsePathSchema,
508
- z16.object({
509
- path: ErrorResponsePathSchema,
510
- statusCode: StatusCodeSchema.optional(),
511
- minTTL: MinTTLSchema.optional()
512
- })
513
- ]).optional();
514
- var RouteSchema = z16.string().regex(/^\//, "Route must start with a slash (/)");
515
- var VisibilitySchema = z16.boolean().default(false).describe("Whether to enable CloudWatch metrics for the WAF rule.");
516
- var WafSettingsSchema = z16.object({
517
- rateLimiter: z16.object({
518
- limit: z16.number().min(10).max(2e9).default(10).describe(
519
- "The limit on requests during the specified evaluation window for a single aggregation instance for the rate-based rule."
520
- ),
521
- window: z16.union([
522
- z16.literal("1 minute"),
523
- z16.literal("2 minutes"),
524
- z16.literal("5 minutes"),
525
- z16.literal("10 minutes")
526
- ]).default("5 minutes").transform((v) => parse3(v)).describe(
527
- "The amount of time, in seconds, that AWS WAF should include in its request counts, looking back from the current time."
528
- ),
529
- visibility: VisibilitySchema
530
- }).optional().describe(
531
- "A rate-based rule counts incoming requests and rate limits requests when they are coming at too fast a rate."
532
- ),
533
- ddosProtection: z16.object({
534
- sensitivity: z16.object({
535
- challenge: z16.enum(["low", "medium", "high"]).default("low").transform((v) => v.toUpperCase()).describe("The sensitivity level for challenge requests."),
536
- block: z16.enum(["low", "medium", "high"]).default("low").transform((v) => v.toUpperCase()).describe("The sensitivity level for block requests.")
537
- }),
538
- exemptUriRegex: z16.string().default("^$"),
539
- visibility: VisibilitySchema
540
- }).optional().describe(
541
- "Provides protection against DDoS attacks targeting the application layer, also known as Layer 7 attacks. Uses 50 WCU."
542
- ),
543
- botProtection: z16.object({
544
- inspectionLevel: z16.enum(["common", "targeted"]).default("common").transform((v) => v.toUpperCase()),
545
- visibility: VisibilitySchema
546
- }).optional().describe(
547
- "Provides protection against automated bots that can consume excess resources, skew business metrics, cause downtime, or perform malicious activities. Bot Control provides additional visibility through Amazon CloudWatch and generates labels that you can use to control bot traffic to your applications. Uses 50 WCU."
548
- ),
549
- captchaImmunityTime: DurationSchema.refine(durationMin(minutes2(1)), "Minimum timeout duration is 1 minute").refine(durationMax(days3(3)), "Maximum timeout duration is 3 days").default("5 minutes").describe(
550
- "The amount of time that a CAPTCHA timestamp is considered valid by AWS WAF. The default setting is 5 minutes."
551
- ),
552
- challengeImmunityTime: DurationSchema.refine(durationMin(minutes2(1)), "Minimum timeout duration is 1 minute").refine(durationMax(days3(3)), "Maximum timeout duration is 3 days").default("5 minutes").describe(
553
- "The amount of time that a challenge timestamp is considered valid by AWS WAF. The default setting is 5 minutes."
554
- )
555
- }).describe(
556
- "WAF settings for the router. Each rule consumes Web ACL capacity units (WCUs). The total WCUs for a web ACL can't exceed 5000. Using over 1500 WCUs affects your costs."
557
- );
558
- var RouterDefaultSchema = z16.record(
559
- ResourceIdSchema,
560
- z16.object({
561
- domain: ResourceIdSchema.describe("The domain id to link your Router.").optional(),
562
- subDomain: z16.string().optional(),
563
- redirectWww: z16.boolean().default(false).describe("Redirect all www subdomain requests to your root domain."),
564
- waf: WafSettingsSchema.optional(),
565
- geoRestrictions: z16.array(z16.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
566
- errors: z16.object({
567
- 400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
568
- 403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
569
- 404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
570
- 405: ErrorResponseSchema.describe("Customize a `405 Method Not Allowed` response."),
571
- 414: ErrorResponseSchema.describe("Customize a `414 Request-URI` response."),
572
- 416: ErrorResponseSchema.describe("Customize a `416 Range Not` response."),
573
- 500: ErrorResponseSchema.describe("Customize a `500 Internal Server` response."),
574
- 501: ErrorResponseSchema.describe("Customize a `501 Not Implemented` response."),
575
- 502: ErrorResponseSchema.describe("Customize a `502 Bad Gateway` response."),
576
- 503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
577
- 504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
578
- }).optional().describe("Customize the error responses for specific HTTP status codes."),
579
- cors: z16.object({
580
- override: z16.boolean().default(false),
581
- maxAge: DurationSchema.default("365 days"),
582
- exposeHeaders: z16.string().array().optional(),
583
- credentials: z16.boolean().default(false),
584
- headers: z16.string().array().default(["*"]),
585
- origins: z16.string().array().default(["*"]),
586
- methods: z16.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
587
- }).optional().describe("Specify the cors headers."),
588
- passwordAuth: z16.object({
589
- password: z16.string().describe("Password.")
590
- }).optional().describe(
591
- [
592
- "Enable password authentication for the router.",
593
- 'You can authenicate by adding a "authorization" header with the value "Password [YOUR_PASSWORD]".'
594
- ].join("\n")
595
- ),
596
- basicAuth: z16.object({
597
- username: z16.string().describe("Basic auth username."),
598
- password: z16.string().describe("Basic auth password.")
599
- }).optional().describe("Enable basic authentication for the router."),
600
- // security: z
601
- // .object({
602
- // contentSecurityPolicy: z.object({
603
- // override: z.boolean().default(false),
604
- // policy: z.string(),
605
- // })
606
- // contentSecurityPolicy?: {
607
- // override?: boolean
608
- // contentSecurityPolicy: string
609
- // }
610
- // contentTypeOptions?: {
611
- // override?: boolean
612
- // }
613
- // frameOptions?: {
614
- // override?: boolean
615
- // frameOption?: 'deny' | 'same-origin'
616
- // }
617
- // referrerPolicy?: {
618
- // override?: boolean
619
- // referrerPolicy?: (
620
- // 'no-referrer' |
621
- // 'no-referrer-when-downgrade' |
622
- // 'origin' |
623
- // 'origin-when-cross-origin' |
624
- // 'same-origin' |
625
- // 'strict-origin' |
626
- // 'strict-origin-when-cross-origin' |
627
- // 'unsafe-url'
628
- // )
629
- // }
630
- // strictTransportSecurity?: {
631
- // maxAge?: Duration
632
- // includeSubdomains?: boolean
633
- // override?: boolean
634
- // preload?: boolean
635
- // }
636
- // xssProtection?: {
637
- // override?: boolean
638
- // enable?: boolean
639
- // modeBlock?: boolean
640
- // reportUri?: string
641
- // }
642
- // })
643
- // .optional()
644
- // .describe('Specify the security policy.'),
645
- cache: z16.object({
646
- cookies: z16.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
647
- headers: z16.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
648
- queries: z16.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
649
- }).optional().describe(
650
- "Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
651
- )
652
- }).superRefine((props, ctx) => {
653
- if (props.redirectWww && !props.domain) {
654
- ctx.addIssue({
655
- code: z16.ZodIssueCode.custom,
656
- path: ["redirectWww"],
657
- message: "The redirectWww option requires a domain to be set."
658
- });
659
- }
660
- if (props.redirectWww && props.subDomain) {
661
- ctx.addIssue({
662
- code: z16.ZodIssueCode.custom,
663
- path: ["redirectWww"],
664
- message: `The redirectWww option can't be combined with a subDomain, because the domain certificate only covers single level subdomains.`
665
- });
666
- }
667
- })
668
- ).optional().describe(`Define the global Router. Backed by AWS CloudFront.`);
669
-
670
- // src/feature/pubsub/schema.ts
671
- var PubSubDefaultSchema = z17.record(
672
- ResourceIdSchema,
673
- z17.object({
674
- auth: FunctionSchema.describe(
675
- "The authorizer that validates the client auth token and returns the allowed topics."
676
- ),
677
- router: ResourceIdSchema.describe("The router id to route pubsub traffic through."),
678
- path: RouteSchema.default("/ws").describe("The base path on the router that exposes the pubsub endpoint."),
679
- log: LogSchema2.default(true).transform((log) => ({
680
- retention: log.retention ?? days4(7)
681
- }))
682
- })
683
- ).optional().describe("Define the pubsub API for your app. Backed by a websocket server on AWS Fargate.");
684
- var PubSubSchema = z17.record(
685
- ResourceIdSchema,
686
- z17.object({
687
- connected: FunctionSchema.optional().describe("Subscribe to the event when a client connects."),
688
- disconnected: FunctionSchema.optional().describe("Subscribe to the event when a client disconnects."),
689
- subscribed: FunctionSchema.optional().describe(
690
- "Subscribe to the event when a client subscribes to topics."
691
- ),
692
- unsubscribed: FunctionSchema.optional().describe(
693
- "Subscribe to the event when a client unsubscribes from topics."
694
- )
695
- })
696
- ).optional().describe("Define the pubsub event listeners in your stack.");
697
-
698
- // src/feature/queue/schema.ts
699
- import { days as days5, minutes as minutes3, seconds as seconds2 } from "@awsless/duration";
700
- import { kibibytes } from "@awsless/size";
701
- import { z as z18 } from "zod";
702
- var RetentionPeriodSchema = DurationSchema.refine(durationMin(minutes3(1)), "Minimum retention period is 1 minute").refine(durationMax(days5(14)), "Maximum retention period is 14 days").describe(
703
- "The number of seconds that Amazon SQS retains a message. You can specify a duration from 1 minute to 14 days."
704
- );
705
- var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
706
- durationMin(seconds2(1)),
707
- "Minimum receive message wait time is 1 second"
708
- ).refine(durationMax(seconds2(20)), "Maximum receive message wait time is 20 seconds").describe("Long-polling wait time. You can specify a duration from 1 to 20 seconds.");
709
- 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("Message size limit. You can specify a size from 1 KB to 256 KB.");
710
- var BatchSizeSchema = z18.number().int().min(1, "Minimum batch size is 1").max(10, "FIFO queues support a maximum batch size of 10").describe("The maximum number of records per batch. FIFO queues are capped at 10.");
711
- var QueueDefaultSchema = z18.object({
712
- retentionPeriod: RetentionPeriodSchema.default("7 days"),
713
- // The visibility timeout is derived from the bundle timeout.
714
- receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
715
- maxMessageSize: MaxMessageSizeSchema.default("256 KB"),
716
- batchSize: BatchSizeSchema.default(10)
717
- }).default({});
718
- var QueueSchema = z18.object({
719
- consumer: FunctionSchema.optional().describe("The consuming lambda function properties."),
720
- retentionPeriod: RetentionPeriodSchema.optional(),
721
- receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
722
- maxMessageSize: MaxMessageSizeSchema.optional(),
723
- batchSize: BatchSizeSchema.optional()
724
- });
725
- var QueuesSchema = z18.record(
726
- ResourceIdSchema,
727
- z18.union([
728
- LocalFileSchema.transform((consumer) => ({
729
- consumer
730
- })).pipe(QueueSchema),
731
- QueueSchema
732
- ])
733
- ).optional().describe(
734
- "Define the queues in your stack. Queues are FIFO with required per-message groupId: messages with the same groupId are processed strictly in order; different groupIds parallelize."
735
- );
736
-
737
- // src/feature/rest/schema.ts
738
- import { z as z20 } from "zod";
739
-
740
- // src/config/schema/route.ts
741
- import { z as z19 } from "zod";
742
- var RouteSchema2 = z19.union([
743
- z19.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS|ANY)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
744
- z19.literal("$default")
745
- ]);
746
-
747
- // src/feature/rest/schema.ts
748
- var RestDefaultSchema = z20.record(
749
- ResourceIdSchema,
750
- z20.object({
751
- domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
752
- subDomain: z20.string().optional()
753
- })
754
- ).optional().describe("Define your global REST API's.");
755
- var RestSchema = z20.record(
756
- ResourceIdSchema,
757
- z20.record(
758
- RouteSchema2.describe(
759
- [
760
- "The REST API route that is comprised by the http method and http path.",
761
- "The possible http methods are POST, GET,PUT, DELETE, HEAD, OPTIONS, ANY.",
762
- "Example: GET /posts/{id}"
763
- ].join("\n")
764
- ),
765
- FunctionSchema
766
- )
767
- ).optional().describe("Define routes in your stack for your global REST API.");
768
-
769
- // src/feature/rpc/schema.ts
770
- import { z as z21 } from "zod";
771
- var RpcDefaultSchema = z21.record(
772
- ResourceIdSchema,
773
- z21.object({
774
- // domain: ResourceIdSchema.describe('The domain id to link your RPC API with.').optional(),
775
- // subDomain: z.string().optional(),
776
- //
777
- router: ResourceIdSchema.describe("The router id to link your RPC API with."),
778
- path: RouteSchema.describe("The path inside the router to link your RPC API to."),
779
- auth: FunctionSchema.optional().describe("The authentication handler for your RPC API.")
780
- // timeout: TimeoutSchema.default('1 minutes'),
781
- })
782
- ).describe(`Define the global RPC API's.`).optional();
783
- var RpcSchema = z21.record(
784
- ResourceIdSchema,
785
- z21.record(
786
- z21.string(),
787
- z21.union([
788
- FunctionSchema.transform((f) => ({
789
- function: f,
790
- lock: false
791
- })),
792
- z21.object({
793
- function: FunctionSchema.describe("The RPC function to execute."),
794
- lock: z21.boolean().describe(
795
- [
796
- "Specify if the function should be locked on the `lockKey` returned from the auth function.",
797
- "An example would be returning the user ID as `lockKey`."
798
- ].join("\n")
799
- )
800
- })
801
- ])
802
- ).describe("The queries for your global RPC API.")
803
- ).describe("Define the schema in your stack for your global RPC API.").optional();
804
-
805
- // src/feature/job/schema.ts
806
- import { days as days6, toDays as toDays3 } from "@awsless/duration";
807
- import { toMebibytes as toMebibytes2 } from "@awsless/size";
808
- import { z as z22 } from "zod";
809
- var CpuSchema2 = z22.union([z22.literal(0.25), z22.literal(0.5), z22.literal(1), z22.literal(2), z22.literal(4), z22.literal(8), z22.literal(16)]).transform((v) => `${v} vCPU`).describe("The number of virtual CPU units (vCPU) used by the job. Valid values: 0.25, 0.5, 1, 2, 4, 8, 16 vCPU.");
810
- var validMemorySize2 = [
811
- // 0.25 vCPU
812
- 512,
813
- 1024,
814
- 2048,
815
- // 0.5 vCPU
816
- 1024,
817
- 2048,
818
- 3072,
819
- 4096,
820
- // 1 vCPU
821
- 2048,
822
- 3072,
823
- 4096,
824
- 5120,
825
- 6144,
826
- 7168,
827
- 8192,
828
- // 2 vCPU
829
- 4096,
830
- 5120,
831
- 6144,
832
- 7168,
833
- 8192,
834
- 9216,
835
- 10240,
836
- 11264,
837
- 12288,
838
- 13312,
839
- 14336,
840
- 15360,
841
- 16384
842
- ];
843
- var MemorySizeSchema3 = SizeSchema.refine(
844
- (s) => validMemorySize2.includes(toMebibytes2(s)),
845
- `Invalid memory size. Allowed sizes: ${validMemorySize2.join(", ")} MiB`
846
- ).describe("The amount of memory (in MiB) used by the job. Valid memory values depend on the CPU configuration.");
847
- var EnvironmentSchema3 = z22.record(z22.string(), z22.string()).optional().describe("Environment variable key-value pairs.");
848
- var ArchitectureSchema4 = z22.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the job supports.");
849
- var ActionSchema3 = z22.string();
850
- var ActionsSchema3 = z22.union([ActionSchema3.transform((v) => [v]), ActionSchema3.array()]);
851
- var ArnSchema3 = z22.string().startsWith("arn:");
852
- var WildcardSchema3 = z22.literal("*");
853
- var ResourceSchema3 = z22.union([ArnSchema3, WildcardSchema3]);
854
- var ResourcesSchema3 = z22.union([ResourceSchema3.transform((v) => [v]), ResourceSchema3.array()]);
855
- var PermissionSchema3 = z22.object({
856
- effect: z22.enum(["allow", "deny"]).default("allow"),
857
- actions: ActionsSchema3,
858
- resources: ResourcesSchema3
859
- });
860
- var PermissionsSchema3 = z22.union([PermissionSchema3.transform((v) => [v]), PermissionSchema3.array()]).describe("Add IAM permissions to your job.");
861
- var validLogRetentionDays3 = [
862
- ...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
863
- ...[180, 365, 400, 545, 731, 1096, 1827, 2192],
864
- ...[2557, 2922, 3288, 3653]
865
- ];
866
- var LogRetentionSchema3 = DurationSchema.refine(
867
- durationMin(days6(0)),
868
- "Minimum log retention is 0 day, which will disable logging."
869
- ).refine(
870
- (duration) => {
871
- return validLogRetentionDays3.includes(toDays3(duration));
872
- },
873
- `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days8) => `${days8}`).join(", ")}`
874
- ).describe("The log retention duration.");
875
- var LogSchema3 = z22.union([
876
- z22.boolean().transform((enabled) => ({ retention: enabled ? days6(7) : days6(0) })),
877
- LogRetentionSchema3.transform((retention) => ({ retention })),
878
- z22.object({
879
- retention: LogRetentionSchema3.optional()
880
- })
881
- ]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
882
- var FileCodeSchema3 = z22.object({
883
- file: LocalFileSchema.describe("The file path of the job code.")
884
- });
885
- var CodeSchema3 = z22.union([
886
- LocalFileSchema.transform((file) => ({
887
- file
888
- })).pipe(FileCodeSchema3),
889
- FileCodeSchema3
890
- ]).describe("Specify the code of your job.");
891
- var TimeoutSchema2 = DurationSchema.describe("The maximum time the job is allowed to run before being stopped.");
892
- var ImageSchema2 = z22.string().describe("The URL of the container image to use. Default: public.ecr.aws/aws-cli/aws-cli:{architecture}");
893
- var PersistentStorageSchema = z22.boolean().describe("Mount persistent storage for the job at a fixed internal path.");
894
- var StartupCommandSchema2 = z22.union([z22.string().transform((v) => [v]), z22.string().array()]).describe("Optional shell commands to run before the job executable is downloaded and started.");
895
- var ASchema = z22.object({
896
- code: CodeSchema3,
897
- image: ImageSchema2.optional(),
898
- persistentStorage: PersistentStorageSchema.optional(),
899
- startupCommand: StartupCommandSchema2.optional(),
900
- log: LogSchema3.optional(),
901
- cpu: CpuSchema2.optional(),
902
- memorySize: MemorySizeSchema3.optional(),
903
- architecture: ArchitectureSchema4.optional(),
904
- environment: EnvironmentSchema3.optional(),
905
- permissions: PermissionsSchema3.optional(),
906
- timeout: TimeoutSchema2.default("30 minutes").describe("The maximum time the job is allowed to run before being stopped. Default: 30 minutes.")
907
- });
908
- var JobSchema = z22.union([
909
- LocalFileSchema.transform((code) => ({
910
- code
911
- })).pipe(ASchema),
912
- ASchema
913
- ]);
914
- var JobsSchema = z22.record(ResourceIdSchema, JobSchema).optional().describe("Define the jobs in your stack.");
915
- var JobDefaultSchema = z22.object({
916
- image: ImageSchema2.optional(),
917
- persistentStorage: PersistentStorageSchema.optional(),
918
- cpu: CpuSchema2.default(0.25),
919
- memorySize: MemorySizeSchema3.default("512 MB"),
920
- architecture: ArchitectureSchema4.default("arm64"),
921
- environment: EnvironmentSchema3.optional(),
922
- permissions: PermissionsSchema3.optional(),
923
- timeout: TimeoutSchema2.optional(),
924
- log: LogSchema3.default(true).transform((log) => ({
925
- retention: log.retention ?? days6(7)
926
- }))
927
- }).default({});
928
-
929
- // src/feature/topic/schema.ts
930
- import { kebabCase as kebabCase3 } from "change-case";
931
- import { z as z23 } from "zod";
932
- var TopicNameSchema = z23.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
933
- var TopicsDefaultSchema = z23.array(TopicNameSchema).refine((topics) => {
934
- return topics.length === new Set(topics).size;
935
- }, "Must be a list of unique topic names").optional().describe("Define the event topics for your app.");
936
- var SubscribersSchema = z23.record(TopicNameSchema, TaskSchema).optional().describe("Define the event topics to subscribe too in your stack.");
937
-
938
- // src/config/schema/region.ts
939
- import { z as z24 } from "zod";
940
- var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
941
- var AF = ["af-south-1"];
942
- var AP = [
943
- "ap-east-1",
944
- "ap-south-2",
945
- "ap-southeast-3",
946
- "ap-southeast-4",
947
- "ap-south-1",
948
- "ap-northeast-3",
949
- "ap-northeast-2",
950
- "ap-southeast-1",
951
- "ap-southeast-2",
952
- "ap-northeast-1"
953
- ];
954
- var CA = ["ca-central-1"];
955
- var EU = [
956
- "eu-central-1",
957
- "eu-west-1",
958
- "eu-west-2",
959
- "eu-south-1",
960
- "eu-west-3",
961
- "eu-south-2",
962
- "eu-north-1",
963
- "eu-central-2"
964
- ];
965
- var ME = ["me-south-1", "me-central-1"];
966
- var SA = ["sa-east-1"];
967
- var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
968
- var RegionSchema = z24.enum(regions);
969
-
970
- // src/config/app.ts
971
- var AppSchema = z25.object({
972
- $schema: z25.string().optional(),
973
- name: ResourceIdSchema.describe("App name."),
974
- region: RegionSchema.describe("The AWS region to deploy to."),
975
- profile: z25.string().describe("The AWS profile to deploy to."),
976
- protect: z25.boolean().default(false).describe("Protect your app & stacks from being deleted."),
977
- removal: z25.enum(["remove", "retain"]).default("remove").describe(
978
- [
979
- "Configure how your resources are handled when they have to be removed.",
980
- "",
981
- "remove: Removes all underlying resources.",
982
- "retain: Retains the following resources: stores, tables, auth, searchs, and caches."
983
- ].join("\n")
984
- ),
985
- // stage: z
986
- // .string()
987
- // .regex(/^[a-z]+$/)
988
- // .default('prod')
989
- // .describe('The deployment stage.'),
990
- // onFailure: OnFailureSchema,
991
- defaults: z25.object({
992
- onFailure: OnFailureDefaultSchema,
993
- onErrorLog: OnErrorLogDefaultSchema,
994
- auth: AuthDefaultSchema,
995
- domains: DomainsDefaultSchema,
996
- function: FunctionDefaultSchema,
997
- instance: InstanceDefaultSchema,
998
- job: JobDefaultSchema,
999
- queue: QueueDefaultSchema,
1000
- // graphql: GraphQLDefaultSchema,
1001
- // http: HttpDefaultSchema,
1002
- rest: RestDefaultSchema,
1003
- rpc: RpcDefaultSchema,
1004
- pubsub: PubSubDefaultSchema,
1005
- // table: TableDefaultSchema,
1006
- // store: StoreDefaultSchema,
1007
- alerts: AlertsDefaultSchema,
1008
- topics: TopicsDefaultSchema,
1009
- layers: LayerSchema,
1010
- router: RouterDefaultSchema
1011
- // dataRetention: z.boolean().describe('Configure how your resources are handled on delete.').default(false),
1012
- }).default({}).describe("Default properties")
1013
- });
1014
-
1015
- // src/config/stack.ts
1016
- import { z as z41 } from "zod";
1017
-
1018
- // src/feature/cache/schema.ts
1019
- import { gibibytes as gibibytes2 } from "@awsless/size";
1020
- import { z as z26 } from "zod";
1021
- var StorageSchema = SizeSchema.refine(sizeMin(gibibytes2(1)), "Minimum storage size is 1 GB").refine(
1022
- sizeMax(gibibytes2(5e3)),
1023
- "Maximum storage size is 5000 GB"
1024
- );
1025
- var MinimumStorageSchema = StorageSchema.describe(
1026
- "The lower limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
1027
- );
1028
- var MaximumStorageSchema = StorageSchema.describe(
1029
- "The upper limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
1030
- );
1031
- var EcpuSchema = z26.number().int().min(1e3).max(15e6);
1032
- var MinimumEcpuSchema = EcpuSchema.describe(
1033
- "The minimum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1034
- );
1035
- var MaximumEcpuSchema = EcpuSchema.describe(
1036
- "The maximum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
1037
- );
1038
- var CachesSchema = z26.record(
1039
- ResourceIdSchema,
1040
- z26.object({
1041
- minStorage: MinimumStorageSchema.optional(),
1042
- maxStorage: MaximumStorageSchema.optional(),
1043
- minECPU: MinimumEcpuSchema.optional(),
1044
- maxECPU: MaximumEcpuSchema.optional(),
1045
- snapshotRetentionLimit: z26.number().int().positive().default(1)
1046
- })
1047
- ).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
1048
-
1049
- // src/feature/command/schema.ts
1050
- import { z as z27 } from "zod";
1051
- var CommandSchema = z27.union([
1052
- z27.object({
1053
- file: LocalFileSchema,
1054
- handler: z27.string().default("default").describe("The name of the handler that needs to run"),
1055
- description: z27.string().optional().describe("A description of the command")
1056
- // options: z.record(ResourceIdSchema, OptionSchema).optional(),
1057
- // arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
1058
- }),
1059
- LocalFileSchema.transform((file) => ({
1060
- file,
1061
- handler: "default",
1062
- description: void 0
1063
- }))
1064
- ]);
1065
- var CommandsSchema = z27.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
1066
-
1067
- // src/feature/config/schema.ts
1068
- import { z as z28 } from "zod";
1069
- var ConfigNameSchema = z28.string().regex(/[a-z0-9\-]/g, "Invalid config name");
1070
- var ConfigsSchema = z28.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
1071
-
1072
- // src/feature/cron/schema/index.ts
1073
- import { z as z30 } from "zod";
1074
-
1075
- // src/feature/cron/schema/schedule.ts
1076
- import { z as z29 } from "zod";
1077
- import { awsCronExpressionValidator } from "aws-cron-expression-validator";
1078
- var RateExpressionSchema = z29.custom(
1079
- (value) => {
1080
- return z29.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
1081
- const [str] = rate.split(" ");
1082
- const number = parseInt(str);
1083
- return number > 0;
1084
- }).safeParse(value).success;
1085
- },
1086
- { message: "Invalid rate expression" }
1087
- ).transform((rate) => {
1088
- const [str] = rate.split(" ");
1089
- const number = parseInt(str);
1090
- const more = rate.endsWith("s");
1091
- if (more && number === 1) {
1092
- return `rate(${rate.substring(0, rate.length - 1)})`;
1093
- }
1094
- return `rate(${rate})`;
1095
- });
1096
- var CronExpressionSchema = z29.custom(
1097
- (value) => {
1098
- return z29.string().safeParse(value).success;
1099
- },
1100
- { message: "Invalid cron expression" }
1101
- ).superRefine((value, ctx) => {
1102
- try {
1103
- awsCronExpressionValidator(value);
1104
- } catch (error) {
1105
- if (error instanceof Error) {
1106
- ctx.addIssue({
1107
- code: z29.ZodIssueCode.custom,
1108
- message: `Invalid cron expression: ${error.message}`
1109
- });
1110
- } else {
1111
- ctx.addIssue({
1112
- code: z29.ZodIssueCode.custom,
1113
- message: "Invalid cron expression"
1114
- });
1115
- }
1116
- }
1117
- }).transform((value) => {
1118
- return `cron(${value.trim()})`;
1119
- });
1120
- var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
1121
-
1122
- // src/feature/cron/schema/index.ts
1123
- var CronsSchema = z30.record(
1124
- ResourceIdSchema,
1125
- z30.object({
1126
- enabled: z30.boolean().default(true).describe("If the cron is enabled."),
1127
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
1128
- schedule: ScheduleExpressionSchema.describe(
1129
- 'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
1130
- ),
1131
- payload: z30.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
1132
- })
1133
- ).optional().describe(`Define the cron jobs in your stack.`);
1134
-
1135
- // src/feature/search/schema.ts
1136
- import { gibibytes as gibibytes3 } from "@awsless/size";
1137
- import { z as z31 } from "zod";
1138
- var VersionSchema = z31.union([
1139
- //
1140
- z31.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
1141
- z31.string()
1142
- ]).describe("Specify the OpenSearch engine version.");
1143
- var TypeSchema = z31.union([
1144
- z31.enum([
1145
- "t3.small",
1146
- "t3.medium",
1147
- "m3.medium",
1148
- "m3.large",
1149
- "m3.xlarge",
1150
- "m3.2xlarge",
1151
- "m4.large",
1152
- "m4.xlarge",
1153
- "m4.2xlarge",
1154
- "m4.4xlarge",
1155
- "m4.10xlarge",
1156
- "m5.large",
1157
- "m5.xlarge",
1158
- "m5.2xlarge",
1159
- "m5.4xlarge",
1160
- "m5.12xlarge",
1161
- "m5.24xlarge",
1162
- "r5.large",
1163
- "r5.xlarge",
1164
- "r5.2xlarge",
1165
- "r5.4xlarge",
1166
- "r5.12xlarge",
1167
- "r5.24xlarge",
1168
- "c5.large",
1169
- "c5.xlarge",
1170
- "c5.2xlarge",
1171
- "c5.4xlarge",
1172
- "c5.9xlarge",
1173
- "c5.18xlarge",
1174
- "or1.medium",
1175
- "or1.large",
1176
- "or1.xlarge",
1177
- "or1.2xlarge",
1178
- "or1.4xlarge",
1179
- "or1.8xlarge",
1180
- "or1.12xlarge",
1181
- "or1.16xlarge",
1182
- "ultrawarm1.medium",
1183
- "ultrawarm1.large",
1184
- "ultrawarm1.xlarge",
1185
- "r3.large",
1186
- "r3.xlarge",
1187
- "r3.2xlarge",
1188
- "r3.4xlarge",
1189
- "r3.8xlarge",
1190
- "i2.xlarge",
1191
- "i2.2xlarge",
1192
- "i3.large",
1193
- "i3.xlarge",
1194
- "i3.2xlarge",
1195
- "i3.4xlarge",
1196
- "i3.8xlarge",
1197
- "i3.16xlarge",
1198
- "r6g.large",
1199
- "r6g.xlarge",
1200
- "r6g.2xlarge",
1201
- "r6g.4xlarge",
1202
- "r6g.8xlarge",
1203
- "r6g.12xlarge",
1204
- "m6g.large",
1205
- "m6g.xlarge",
1206
- "m6g.2xlarge",
1207
- "m6g.4xlarge",
1208
- "m6g.8xlarge",
1209
- "m6g.12xlarge",
1210
- "r6gd.large",
1211
- "r6gd.xlarge",
1212
- "r6gd.2xlarge",
1213
- "r6gd.4xlarge",
1214
- "r6gd.8xlarge",
1215
- "r6gd.12xlarge",
1216
- "r6gd.16xlarge"
1217
- ]),
1218
- z31.string()
1219
- ]).describe("Instance type of data nodes in the cluster.");
1220
- var CountSchema = z31.number().int().min(1).describe("Number of instances in the cluster.");
1221
- 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.");
1222
- var SearchsSchema = z31.record(
1223
- ResourceIdSchema,
1224
- z31.object({
1225
- type: TypeSchema.default("t3.small"),
1226
- count: CountSchema.default(1),
1227
- version: VersionSchema.default("2.13"),
1228
- storage: StorageSizeSchema.default("10 GB")
1229
- // vpc: z.boolean().default(false),
1230
- // migration: FunctionSchema.optional(),
1231
- })
1232
- ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
1233
-
1234
- // src/feature/site/schema.ts
1235
- import { z as z34 } from "zod";
1236
-
1237
- // src/config/schema/local-directory.ts
1238
- import { stat as stat2 } from "fs/promises";
1239
- import { z as z32 } from "zod";
1240
- var LocalDirectorySchema = z32.union([
1241
- RelativePathSchema.refine(async (path) => {
1242
- try {
1243
- const s = await stat2(path);
1244
- return s.isDirectory();
1245
- } catch (error) {
1246
- return false;
1247
- }
1248
- }, `Directory doesn't exist`),
1249
- z32.object({
1250
- nocheck: RelativePathSchema.describe(
1251
- "Specifies a local directory without checking if the directory exists."
1252
- )
1253
- }).transform((v) => v.nocheck)
1254
- ]);
1255
-
1256
- // src/config/schema/local-entry.ts
1257
- import { stat as stat3 } from "fs/promises";
1258
- import { z as z33 } from "zod";
1259
- var LocalEntrySchema = z33.union([
1260
- RelativePathSchema.refine(async (path) => {
1261
- try {
1262
- const s = await stat3(path);
1263
- return s.isFile() || s.isDirectory();
1264
- } catch (error) {
1265
- return false;
1266
- }
1267
- }, `File or directory doesn't exist`),
1268
- z33.object({
1269
- nocheck: RelativePathSchema.describe(
1270
- "Specifies a local file or directory without checking if the file or directory exists."
1271
- )
1272
- }).transform((v) => v.nocheck)
1273
- ]);
1274
-
1275
- // src/feature/site/schema.ts
1276
- var SitesSchema = z34.record(
1277
- ResourceIdSchema,
1278
- z34.object({
1279
- router: ResourceIdSchema.describe("The router id to link your site with."),
1280
- path: RouteSchema.describe("The path inside the router to link your site to."),
1281
- build: z34.object({
1282
- command: z34.string().describe(
1283
- `Specifies the files and directories to generate the cache key for your custom build command.`
1284
- ),
1285
- cacheKey: z34.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
1286
- `Specifies the files and directories to generate the cache key for your custom build command.`
1287
- ),
1288
- configs: z34.string().array().optional().describe("Define the config values for your build command.")
1289
- }).optional().describe(`Specifies the build process for sites that need a build step.`),
1290
- static: z34.union([LocalDirectorySchema, z34.boolean()]).optional().describe(
1291
- "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."
1292
- ),
1293
- ssr: FunctionSchema.optional().describe("Specifies the file that will render the site on the server.")
1294
- })
1295
- ).optional().describe("Define the sites in your stack.");
1296
-
1297
- // src/feature/store/schema.ts
1298
- import { days as days7 } from "@awsless/duration";
1299
- import { z as z35 } from "zod";
1300
- var LifecycleRuleSchema = z35.object({
1301
- prefix: z35.string().optional().describe("Object-key prefix this rule applies to. Omit to apply bucket-wide."),
1302
- expiration: DurationSchema.refine(durationMin(days7(1)), "Minimum expiration is 1 day").describe(
1303
- "How long objects matching this rule live before S3 deletes them."
1304
- )
1305
- });
1306
- var StoresSchema = z35.union([
1307
- z35.array(ResourceIdSchema).transform((list) => {
1308
- const stores = {};
1309
- for (const key of list) {
1310
- stores[key] = {};
1311
- }
1312
- return stores;
1313
- }),
1314
- z35.record(
1315
- ResourceIdSchema,
1316
- z35.object({
1317
- static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
1318
- lifecycle: z35.array(LifecycleRuleSchema).optional().describe("S3 lifecycle rules for this store. Each rule expires objects matching an optional prefix."),
1319
- events: z35.object({
1320
- // create
1321
- "created:*": TaskSchema.optional().describe(
1322
- "Subscribe to notifications regardless of the API that was used to create an object."
1323
- ),
1324
- "created:put": TaskSchema.optional().describe(
1325
- "Subscribe to notifications when an object is created using the PUT API operation."
1326
- ),
1327
- "created:post": TaskSchema.optional().describe(
1328
- "Subscribe to notifications when an object is created using the POST API operation."
1329
- ),
1330
- "created:copy": TaskSchema.optional().describe(
1331
- "Subscribe to notifications when an object is created using the COPY API operation."
1332
- ),
1333
- "created:upload": TaskSchema.optional().describe(
1334
- "Subscribe to notifications when an object multipart upload has been completed."
1335
- ),
1336
- // remove
1337
- "removed:*": TaskSchema.optional().describe(
1338
- "Subscribe to notifications when an object is deleted or a delete marker for a versioned object is created."
1339
- ),
1340
- "removed:delete": TaskSchema.optional().describe(
1341
- "Subscribe to notifications when an object is deleted"
1342
- ),
1343
- "removed:marker": TaskSchema.optional().describe(
1344
- "Subscribe to notifications when a delete marker for a versioned object is created."
1345
- )
1346
- }).optional().describe("Describes the store events you want to subscribe too.")
1347
- })
1348
- )
1349
- ]).optional().describe("Define the stores in your stack.");
1350
-
1351
- // src/feature/icon/schema.ts
1352
- import { z as z36 } from "zod";
1353
- var staticOriginSchema = LocalDirectorySchema.describe(
1354
- "Specifies the path to a local image directory that will be uploaded in S3."
1355
- );
1356
- var functionOriginSchema = FunctionSchema.describe(
1357
- "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1358
- );
1359
- var IconsSchema = z36.record(
1360
- ResourceIdSchema,
1361
- z36.object({
1362
- // domain: ResourceIdSchema.describe('The domain id to link your site with.').optional(),
1363
- // subDomain: z.string().optional(),
1364
- router: ResourceIdSchema.describe("The router id to link your icon proxy."),
1365
- path: RouteSchema.describe("The path inside the router to link your icon proxy to."),
1366
- cacheDuration: DurationSchema.optional().describe("The cache duration of the cached icons."),
1367
- preserveIds: z36.boolean().optional().default(false).describe("Preserve the IDs of the icons."),
1368
- symbols: z36.boolean().optional().default(false).describe(`Convert the SVG's to SVG symbols.`),
1369
- origin: z36.union([
1370
- z36.object({
1371
- static: staticOriginSchema,
1372
- function: functionOriginSchema.optional()
1373
- }),
1374
- z36.object({
1375
- static: staticOriginSchema.optional(),
1376
- function: functionOriginSchema
1377
- })
1378
- // z.object({
1379
- // static: staticOriginSchema,
1380
- // function: functionOriginSchema,
1381
- // }),
1382
- ]).describe(
1383
- "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."
1384
- )
1385
- // cors: z
1386
- // .object({
1387
- // override: z.boolean().default(true),
1388
- // maxAge: DurationSchema.default('365 days'),
1389
- // exposeHeaders: z.string().array().optional(),
1390
- // credentials: z.boolean().default(false),
1391
- // headers: z.string().array().default(['*']),
1392
- // origins: z.string().array().default(['*']),
1393
- // })
1394
- // .optional()
1395
- // .describe('Specify the cors headers.'),
1396
- // version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
1397
- })
1398
- ).optional().describe("Define an svg icon proxy in your stack. Store, optimize, and deliver svg icons at scale.");
1399
-
1400
- // src/feature/image/schema.ts
1401
- import { z as z37 } from "zod";
1402
- var transformationOptionsSchema = z37.object({
1403
- width: z37.number().int().positive().optional(),
1404
- height: z37.number().int().positive().optional(),
1405
- fit: z37.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1406
- position: z37.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1407
- quality: z37.number().int().min(1).max(100).optional()
1408
- });
1409
- var staticOriginSchema2 = LocalDirectorySchema.describe(
1410
- "Specifies the path to a local image directory that will be uploaded in S3."
1411
- );
1412
- var functionOriginSchema2 = FunctionSchema.describe(
1413
- "Specifies the file that will be called when an image isn't found in the (cache) bucket."
1414
- );
1415
- var ImagesSchema = z37.record(
1416
- ResourceIdSchema,
1417
- z37.object({
1418
- // domain: ResourceIdSchema.describe('The domain id to link your site with.').optional(),
1419
- // subDomain: z.string().optional(),
1420
- router: ResourceIdSchema.describe("The router id to link your image proxy."),
1421
- path: RouteSchema.describe("The path inside the router to link your image proxy to."),
1422
- cacheDuration: DurationSchema.optional().describe("Cache duration of the cached images."),
1423
- presets: z37.record(z37.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1424
- extensions: z37.object({
1425
- jpg: z37.object({
1426
- mozjpeg: z37.boolean().optional(),
1427
- progressive: z37.boolean().optional()
1428
- }).optional(),
1429
- webp: z37.object({
1430
- effort: z37.number().int().min(1).max(10).default(7).optional(),
1431
- lossless: z37.boolean().optional(),
1432
- nearLossless: z37.boolean().optional()
1433
- }).optional(),
1434
- png: z37.object({
1435
- compressionLevel: z37.number().int().min(0).max(9).default(6).optional()
1436
- }).optional()
1437
- }).refine((data) => {
1438
- return Object.keys(data).length > 0;
1439
- }, "At least one extension must be defined.").describe("Specify the allowed extensions."),
1440
- origin: z37.union([
1441
- z37.object({
1442
- static: staticOriginSchema2,
1443
- function: functionOriginSchema2.optional()
1444
- }),
1445
- z37.object({
1446
- static: staticOriginSchema2.optional(),
1447
- function: functionOriginSchema2
1448
- })
1449
- // z.object({
1450
- // static: staticOriginSchema,
1451
- // function: functionOriginSchema,
1452
- // }),
1453
- ]).describe(
1454
- "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."
1455
- )
1456
- })
1457
- ).optional().describe("Define an image proxy in your stack. Store, transform, optimize, and deliver images at scale.");
1458
-
1459
- // src/feature/metric/schema.ts
1460
- import { z as z38 } from "zod";
1461
- var ops = {
1462
- ">": "GreaterThanThreshold",
1463
- ">=": "GreaterThanOrEqualToThreshold",
1464
- "<": "LessThanThreshold",
1465
- "<=": "LessThanOrEqualToThreshold"
1466
- };
1467
- var stats = {
1468
- count: "SampleCount",
1469
- avg: "Average",
1470
- sum: "Sum",
1471
- min: "Minimum",
1472
- max: "Maximum"
1473
- };
1474
- var WhereSchema = z38.union([
1475
- z38.string().regex(/(count|avg|sum|min|max) (>|>=|<|<=) (\d)/, "Invalid where query").transform((where) => {
1476
- const [stat4, op, value] = where.split(" ");
1477
- return { stat: stat4, op, value: parseFloat(value) };
1478
- }),
1479
- z38.object({
1480
- stat: z38.enum(["count", "avg", "sum", "min", "max"]),
1481
- op: z38.enum([">", ">=", "<", "<="]),
1482
- value: z38.number()
1483
- })
1484
- ]).transform((where) => {
1485
- return {
1486
- stat: stats[where.stat],
1487
- op: ops[where.op],
1488
- value: where.value
1489
- };
1490
- });
1491
- var AlarmSchema = z38.object({
1492
- description: z38.string().optional(),
1493
- where: WhereSchema,
1494
- period: DurationSchema,
1495
- minDataPoints: z38.number().int().default(1),
1496
- trigger: z38.union([EmailSchema.transform((v) => [v]), EmailSchema.array(), FunctionSchema])
1497
- });
1498
- var MetricsSchema = z38.record(
1499
- ResourceIdSchema,
1500
- z38.object({
1501
- type: z38.enum(["number", "size", "duration"]),
1502
- alarms: AlarmSchema.array().optional()
1503
- })
1504
- ).optional().describe("Define the metrics in your stack.");
1505
-
1506
- // src/feature/table/schema.ts
1507
- import { minutes as minutes4, seconds as seconds3 } from "@awsless/duration";
1508
- import { z as z39 } from "zod";
1509
- var KeySchema = z39.string().min(1).max(255);
1510
- var TablesSchema = z39.record(
1511
- ResourceIdSchema,
1512
- z39.object({
1513
- hash: KeySchema.describe(
1514
- "Specifies the name of the partition / hash key that makes up the primary key for the table."
1515
- ),
1516
- sort: KeySchema.optional().describe(
1517
- "Specifies the name of the range / sort key that makes up the primary key for the table."
1518
- ),
1519
- fields: z39.record(z39.string(), z39.enum(["string", "number", "binary"])).optional().describe(
1520
- 'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
1521
- ),
1522
- class: z39.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1523
- pointInTimeRecovery: z39.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1524
- ttl: KeySchema.optional().describe(
1525
- [
1526
- "The name of the TTL attribute used to store the expiration time for items in the table.",
1527
- "To update this property, you must first disable TTL and then enable TTL with the new attribute name."
1528
- ].join("\n")
1529
- ),
1530
- // deletionProtection: DeletionProtectionSchema.optional(),
1531
- stream: z39.object({
1532
- type: z39.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1533
- [
1534
- "When an item in the table is modified, you can determines what information is written to the stream for this table.",
1535
- "Valid values are:",
1536
- "- keys-only - Only the key attributes of the modified item are written to the stream.",
1537
- "- new-image - The entire item, as it appears after it was modified, is written to the stream.",
1538
- "- old-image - The entire item, as it appeared before it was modified, is written to the stream.",
1539
- "- new-and-old-images - Both the new and the old item images of the item are written to the stream."
1540
- ].join("\n")
1541
- ),
1542
- batchSize: z39.number().min(1).max(1e4).default(1).describe(
1543
- [
1544
- "The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
1545
- "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).",
1546
- "You can specify a number from 1 to 10000."
1547
- ].join("\n")
1548
- ),
1549
- batchWindow: DurationSchema.refine(
1550
- durationMin(seconds3(1)),
1551
- "Minimum batch window duration is 1 second"
1552
- ).refine(durationMax(minutes4(5)), "Maximum batch window duration is 5 minutes").optional().describe(
1553
- [
1554
- "The maximum amount of time that is spend gathering records before invoking the function.",
1555
- "You can specify a duration from 1 seconds to 5 minutes."
1556
- ].join("\n")
1557
- ),
1558
- // maxRecordAge: DurationSchema.refine(
1559
- // durationMin(seconds(1)),
1560
- // 'Minimum record age duration is 1 second'
1561
- // )
1562
- // .refine(durationMax(minutes(1)), 'Maximum record age duration is 1 minute')
1563
- // .default('60 seconds')
1564
- // .describe(
1565
- // [
1566
- // 'Discard records older than the specified age.',
1567
- // 'The maximum valid value for maximum record age is 60s.',
1568
- // 'The default value is 60s',
1569
- // ].join('\n')
1570
- // ),
1571
- retryAttempts: z39.number().min(-1).max(1e4).default(2).describe(
1572
- [
1573
- "Discard records after the specified number of retries.",
1574
- "-1 will sets the maximum number of retries to infinite.",
1575
- "When maxRetryAttempts is infinite, Lambda retries failed records until the record expires in the event source.",
1576
- "You can specify a number from -1 to 10000.",
1577
- "The default value is 2"
1578
- ].join("\n")
1579
- ),
1580
- concurrencyPerShard: z39.number().min(1).max(10).default(1).describe(
1581
- [
1582
- "The number of batches to process concurrently from each shard.",
1583
- "You can specify a number from 1 to 10."
1584
- ].join("\n")
1585
- ),
1586
- consumer: FunctionSchema.describe("The consuming lambda function for the stream")
1587
- }).optional().describe(
1588
- "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
1589
- ),
1590
- indexes: z39.record(
1591
- z39.string(),
1592
- z39.object({
1593
- hash: z39.union([KeySchema.transform((v) => [v]), KeySchema.array()]).describe(
1594
- "Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
1595
- ),
1596
- sort: z39.union([KeySchema.transform((v) => [v]), KeySchema.array()]).optional().describe(
1597
- "Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
1598
- ),
1599
- projection: z39.enum(["all", "keys-only"]).default("all").describe(
1600
- [
1601
- "The set of attributes that are projected into the index:",
1602
- "- all - All of the table attributes are projected into the index.",
1603
- "- keys-only - Only the index and primary keys are projected into the index.",
1604
- '@default "all"'
1605
- ].join("\n")
1606
- )
1607
- })
1608
- ).optional().describe("Specifies the global secondary indexes to be created on the table.")
1609
- })
1610
- ).optional().describe("Define the tables in your stack.");
1611
-
1612
- // src/feature/test/schema.ts
1613
- import { z as z40 } from "zod";
1614
- var TestsSchema = z40.union([
1615
- //
1616
- LocalDirectorySchema.transform((v) => [v]),
1617
- LocalDirectorySchema.array(),
1618
- z40.literal(false)
1619
- ]).describe("Define the location of your tests for your stack.").optional();
1620
-
1621
- // src/config/stack.ts
1622
- var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
1623
- var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
1624
- message: `Stack name can't be a reserved name.`
1625
- }).describe("Stack name.");
1626
- var StackSchema = z41.object({
1627
- $schema: z41.string().optional(),
1628
- name: NameSchema,
1629
- depends: DependsSchema,
1630
- commands: CommandsSchema,
1631
- // auth: AuthSchema,
1632
- // http: HttpSchema,
1633
- rest: RestSchema,
1634
- rpc: RpcSchema,
1635
- configs: ConfigsSchema,
1636
- crons: CronsSchema,
1637
- caches: CachesSchema,
1638
- // topics: TopicsSchema,
1639
- subscribers: SubscribersSchema,
1640
- functions: FunctionsSchema,
1641
- instances: InstancesSchema,
1642
- jobs: JobsSchema,
1643
- tasks: TasksSchema,
1644
- tables: TablesSchema,
1645
- stores: StoresSchema,
1646
- // streams: StreamsSchema,
1647
- queues: QueuesSchema,
1648
- pubsub: PubSubSchema,
1649
- searchs: SearchsSchema,
1650
- sites: SitesSchema,
1651
- tests: TestsSchema,
1652
- images: ImagesSchema,
1653
- icons: IconsSchema,
1654
- metrics: MetricsSchema
1655
- });
1656
-
1657
- // src/config/stage-patch-json-schema.ts
1658
- var clone = (value) => {
1659
- return JSON.parse(JSON.stringify(value));
1660
- };
1661
- var escapePointerSegment = (value) => {
1662
- return value.replaceAll("~", "~0").replaceAll("/", "~1");
1663
- };
1664
- var escapeRegexSegment = (value) => {
1665
- return value.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
1666
- };
1667
- var makeExactPath = (prefix, segment) => {
1668
- return `${prefix}/${escapePointerSegment(segment)}`;
1669
- };
1670
- var makeExactPattern = (path) => {
1671
- return `^${path.split("/").map(escapeRegexSegment).join("/")}$`;
1672
- };
1673
- var makePatternPath = (prefix, segmentPattern) => {
1674
- return prefix ? `${prefix}/${segmentPattern}` : `/${segmentPattern}`;
1675
- };
1676
- var appendExactPattern = (pattern, segment) => {
1677
- const base = pattern.slice(1, -1);
1678
- return `^${base}/${escapeRegexSegment(segment)}$`;
1679
- };
1680
- var appendRegexPattern = (pattern, segmentPattern) => {
1681
- const base = pattern.slice(1, -1);
1682
- return `^${base}/${segmentPattern}$`;
1683
- };
1684
- var mergeSchemas = (schemas) => {
1685
- const list = schemas.map((schema) => clone(schema));
1686
- if (list.length === 1) {
1687
- return list[0];
1688
- }
1689
- return {
1690
- anyOf: list
1691
- };
1692
- };
1693
- var dereference = (schema, root) => {
1694
- if (typeof schema.$ref !== "string" || !schema.$ref.startsWith("#/")) {
1695
- return schema;
1696
- }
1697
- const target = schema.$ref.slice(2).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~")).reduce((value, segment) => {
1698
- if (typeof value === "object" && value !== null) {
1699
- return value[segment];
1700
- }
1701
- return void 0;
1702
- }, root);
1703
- if (!target || typeof target !== "object") {
1704
- return schema;
1705
- }
1706
- const { $ref: _, ...rest } = schema;
1707
- return {
1708
- ...clone(target),
1709
- ...rest
1710
- };
1711
- };
1712
- var listBranches = (schema) => {
1713
- const groups = [schema.anyOf, schema.oneOf, schema.allOf].filter(Boolean);
1714
- if (groups.length === 0) {
1715
- return [schema];
1716
- }
1717
- return groups.flatMap((group) => group);
1718
- };
1719
- var childSegmentPattern = (schema) => {
1720
- const propertyNameSchema = schema.propertyNames;
1721
- if (propertyNameSchema && typeof propertyNameSchema.pattern === "string") {
1722
- return propertyNameSchema.pattern;
1723
- }
1724
- const firstPattern = Object.keys(schema.patternProperties ?? {})[0];
1725
- if (firstPattern) {
1726
- return firstPattern;
1727
- }
1728
- return "[^/]+";
1729
- };
1730
- var joinEntries = (entries) => {
1731
- const map = /* @__PURE__ */ new Map();
1732
- for (const entry of entries) {
1733
- const key = [entry.path, entry.pattern ?? "", entry.addOnly ? "1" : "0"].join("|");
1734
- const previous = map.get(key);
1735
- if (!previous) {
1736
- map.set(key, {
1737
- ...entry,
1738
- schema: clone(entry.schema)
1739
- });
1740
- continue;
1741
- }
1742
- previous.schema = mergeSchemas([previous.schema, entry.schema]);
1743
- }
1744
- return [...map.values()];
1745
- };
1746
- var collectEntries = (schema, pointer = "", pattern = makeExactPattern(pointer), root = schema) => {
1747
- const resolved = dereference(schema, root);
1748
- const entries = [
1749
- {
1750
- path: pointer,
1751
- pattern,
1752
- schema: clone(resolved)
1753
- }
1754
- ];
1755
- for (const branch of listBranches(resolved)) {
1756
- const branchType = Array.isArray(branch.type) ? branch.type : branch.type ? [branch.type] : [];
1757
- const isObject = branchType.includes("object") || branch.properties !== void 0 || branch.additionalProperties !== void 0 || branch.patternProperties !== void 0;
1758
- const isArray = branchType.includes("array") || branch.items !== void 0 || branch.prefixItems !== void 0;
1759
- if (isObject) {
1760
- for (const [property, propertySchema] of Object.entries(branch.properties ?? {})) {
1761
- const path = makeExactPath(pointer, property);
1762
- entries.push(...collectEntries(propertySchema, path, appendExactPattern(pattern, property), root));
1763
- }
1764
- for (const [propertyPattern, propertySchema] of Object.entries(branch.patternProperties ?? {})) {
1765
- const path = makePatternPath(pointer, propertyPattern);
1766
- entries.push(...collectEntries(propertySchema, path, appendRegexPattern(pattern, propertyPattern), root));
1767
- }
1768
- if (branch.additionalProperties && typeof branch.additionalProperties === "object") {
1769
- const segmentPattern = childSegmentPattern(branch);
1770
- const path = makePatternPath(pointer, segmentPattern);
1771
- entries.push(...collectEntries(branch.additionalProperties, path, appendRegexPattern(pattern, segmentPattern), root));
1772
- }
1773
- }
1774
- if (isArray) {
1775
- if (Array.isArray(branch.items)) {
1776
- branch.items.forEach((itemSchema, index) => {
1777
- entries.push(...collectEntries(itemSchema, `${pointer}/${index}`, appendExactPattern(pattern, `${index}`), root));
1778
- });
1779
- } else if (branch.items && typeof branch.items === "object") {
1780
- entries.push(...collectEntries(branch.items, `${pointer}/\\d+`, appendRegexPattern(pattern, "\\d+"), root));
1781
- entries.push({
1782
- path: `${pointer}/-`,
1783
- pattern: makeExactPattern(`${pointer}/-`),
1784
- schema: clone(branch.items),
1785
- addOnly: true
1786
- });
1787
- }
1788
- for (const [index, itemSchema] of (branch.prefixItems ?? []).entries()) {
1789
- entries.push(...collectEntries(itemSchema, `${pointer}/${index}`, appendExactPattern(pattern, `${index}`), root));
1790
- }
1791
- }
1792
- }
1793
- return joinEntries(entries);
1794
- };
1795
- var pathMatcherSchema = (entry) => {
1796
- if (entry.pattern && entry.pattern !== makeExactPattern(entry.path)) {
1797
- return {
1798
- type: "string",
1799
- pattern: entry.pattern
1800
- };
1801
- }
1802
- return {
1803
- type: "string",
1804
- const: entry.path
1805
- };
1806
- };
1807
- var objectSchema = (properties, required) => {
1808
- return {
1809
- type: "object",
1810
- properties,
1811
- required,
1812
- additionalProperties: false
1813
- };
1814
- };
1815
- var conditionalValueSchema = (entry) => {
1816
- return {
1817
- if: {
1818
- type: "object",
1819
- properties: {
1820
- path: pathMatcherSchema(entry)
1821
- },
1822
- required: ["path"]
1823
- },
1824
- then: {
1825
- properties: {
1826
- value: clone(entry.schema)
1827
- }
1828
- }
1829
- };
1830
- };
1831
- var matchersSchema = (entries) => {
1832
- return {
1833
- oneOf: entries.map(pathMatcherSchema)
1834
- };
1835
- };
1836
- var patchOperationSchema = (op, entries) => {
1837
- const props = {
1838
- op: {
1839
- type: "string",
1840
- const: op
1841
- },
1842
- path: matchersSchema(entries)
1843
- };
1844
- const required = ["op", "path"];
1845
- const schema = objectSchema(props, required);
1846
- switch (op) {
1847
- case "add":
1848
- case "replace":
1849
- case "test":
1850
- schema.properties = {
1851
- ...schema.properties,
1852
- value: {}
1853
- };
1854
- schema.required = [...required, "value"];
1855
- schema.allOf = entries.map(conditionalValueSchema);
1856
- return schema;
1857
- case "move":
1858
- case "copy":
1859
- schema.properties = {
1860
- ...schema.properties,
1861
- from: matchersSchema(entries)
1862
- };
1863
- schema.required = ["op", "from", "path"];
1864
- return schema;
1865
- default:
1866
- return schema;
1867
- }
1868
- };
1869
- var normalizeEntry = (entry) => {
1870
- return {
1871
- ...entry,
1872
- pattern: entry.pattern ?? makeExactPattern(entry.path)
1873
- };
1874
- };
1875
- var isSchemaMetadataPath = (entry) => {
1876
- return entry.path === "/$schema" || entry.path.startsWith("/$schema/");
1877
- };
1878
- var createStagePatchJsonSchema = (baseSchema, title) => {
1879
- const entries = collectEntries(baseSchema).map(normalizeEntry).filter((entry) => !isSchemaMetadataPath(entry));
1880
- const standardEntries = entries.filter((entry) => !entry.addOnly);
1881
- const addEntries = entries;
1882
- const moveCopyEntries = standardEntries.filter((entry) => entry.path !== "");
1883
- return {
1884
- $schema: "http://json-schema.org/draft-07/schema#",
1885
- title,
1886
- type: "object",
1887
- additionalProperties: false,
1888
- properties: {
1889
- $schema: {
1890
- type: "string"
1891
- },
1892
- operations: {
1893
- type: "array",
1894
- items: {
1895
- oneOf: [
1896
- patchOperationSchema("add", addEntries),
1897
- patchOperationSchema("remove", standardEntries),
1898
- patchOperationSchema("replace", standardEntries),
1899
- patchOperationSchema("move", moveCopyEntries),
1900
- patchOperationSchema("copy", moveCopyEntries),
1901
- patchOperationSchema("test", standardEntries)
1902
- ]
1903
- }
1904
- }
1905
- },
1906
- required: ["operations"]
1907
- };
1908
- };
1909
-
1910
- // cli/build-json-schema.ts
1911
- var generateJsonSchema = (props) => {
1912
- const file = join2(process.cwd(), `dist/${props.name}.json`);
1913
- const schema = zodToJsonSchema(props.schema, {
1914
- name: props.name,
1915
- // errorMessages: true,
1916
- markdownDescription: true,
1917
- pipeStrategy: "input",
1918
- $refStrategy: "none"
1919
- });
1920
- appendDefaults(schema);
1921
- schema.title = props.title;
1922
- writeFileSync(file, JSON.stringify(schema));
1923
- return schema;
1924
- };
1925
- var appendDefaults = (object) => {
1926
- if (Array.isArray(object)) {
1927
- object.forEach(appendDefaults);
1928
- }
1929
- if (typeof object === "object" && object !== null) {
1930
- if ("default" in object && "type" in object) {
1931
- if ("description" in object) {
1932
- object.description += `
1933
-
1934
- @default ${JSON.stringify(object.default)}`;
1935
- }
1936
- if ("markdownDescription" in object) {
1937
- object.markdownDescription += `
1938
-
1939
- @default \`\`\`${JSON.stringify(object.default)}\`\`\``;
1940
- }
1941
- } else {
1942
- Object.values(object).forEach(appendDefaults);
1943
- }
1944
- }
1945
- };
1946
- var appSchema = generateJsonSchema({
1947
- schema: AppSchema,
1948
- name: "app",
1949
- title: "Awsless App Config"
1950
- });
1951
- var stackSchema = generateJsonSchema({
1952
- schema: StackSchema,
1953
- name: "stack",
1954
- title: "Awsless Stack Config"
1955
- });
1956
- writeFileSync(
1957
- join2(process.cwd(), "dist/app.stage.json"),
1958
- JSON.stringify(createStagePatchJsonSchema(appSchema, "Awsless App Stage Patch Config"))
1959
- );
1960
- writeFileSync(
1961
- join2(process.cwd(), "dist/stack.stage.json"),
1962
- JSON.stringify(createStagePatchJsonSchema(stackSchema, "Awsless Stack Stage Patch Config"))
1963
- );