@awsless/awsless 0.0.477 → 0.0.479
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +457 -352
- package/dist/build-json-schema.js +20 -5
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/stack.json +1 -1
- package/package.json +14 -14
package/dist/bin.js
CHANGED
|
@@ -47,6 +47,81 @@ import { mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
|
47
47
|
import { homedir } from "os";
|
|
48
48
|
import { dirname, join as join2 } from "path";
|
|
49
49
|
|
|
50
|
+
// src/formation/cloudfront.ts
|
|
51
|
+
import { CloudFrontClient, CreateInvalidationCommand } from "@aws-sdk/client-cloudfront";
|
|
52
|
+
import { createCustomProvider, createCustomResourceClass } from "@awsless/formation";
|
|
53
|
+
import { z } from "zod";
|
|
54
|
+
var Invalidation = createCustomResourceClass(
|
|
55
|
+
"cloudfront",
|
|
56
|
+
"invalidation"
|
|
57
|
+
);
|
|
58
|
+
var createCloudFrontProvider = ({ profile, region }) => {
|
|
59
|
+
const cloudFront = new CloudFrontClient({ profile, region });
|
|
60
|
+
return createCustomProvider("cloudfront", {
|
|
61
|
+
invalidation: {
|
|
62
|
+
async updateResource(props) {
|
|
63
|
+
const state2 = z.object({
|
|
64
|
+
distributionId: z.string(),
|
|
65
|
+
paths: z.string().array().min(1)
|
|
66
|
+
}).parse(props.proposedState);
|
|
67
|
+
const result = await cloudFront.send(
|
|
68
|
+
new CreateInvalidationCommand({
|
|
69
|
+
DistributionId: state2.distributionId,
|
|
70
|
+
InvalidationBatch: {
|
|
71
|
+
Paths: {
|
|
72
|
+
Quantity: state2.paths.length,
|
|
73
|
+
Items: state2.paths
|
|
74
|
+
},
|
|
75
|
+
CallerReference: props.idempotantToken
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
return {
|
|
80
|
+
...state2,
|
|
81
|
+
id: result.Invalidation?.Id
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/formation/lambda.ts
|
|
89
|
+
import { LambdaClient, UpdateFunctionCodeCommand } from "@aws-sdk/client-lambda";
|
|
90
|
+
import { createCustomProvider as createCustomProvider2, createCustomResourceClass as createCustomResourceClass2 } from "@awsless/formation";
|
|
91
|
+
import { z as z2 } from "zod";
|
|
92
|
+
var UpdateFunctionCode = createCustomResourceClass2(
|
|
93
|
+
"lambda",
|
|
94
|
+
"update-function-code"
|
|
95
|
+
);
|
|
96
|
+
var createLambdaProvider = ({ credentials, region }) => {
|
|
97
|
+
const lambda = new LambdaClient({ credentials, region });
|
|
98
|
+
return createCustomProvider2("lambda", {
|
|
99
|
+
"update-function-code": {
|
|
100
|
+
async updateResource(props) {
|
|
101
|
+
const state2 = z2.object({
|
|
102
|
+
functionName: z2.string(),
|
|
103
|
+
architectures: z2.string().array(),
|
|
104
|
+
s3Bucket: z2.string().optional().transform((v) => v ? v : void 0),
|
|
105
|
+
s3Key: z2.string().optional().transform((v) => v ? v : void 0),
|
|
106
|
+
s3ObjectVersion: z2.string().optional().transform((v) => v ? v : void 0),
|
|
107
|
+
imageUri: z2.string().optional().transform((v) => v ? v : void 0)
|
|
108
|
+
}).parse(props.proposedState);
|
|
109
|
+
await lambda.send(
|
|
110
|
+
new UpdateFunctionCodeCommand({
|
|
111
|
+
FunctionName: state2.functionName,
|
|
112
|
+
Architectures: state2.architectures,
|
|
113
|
+
ImageUri: state2.imageUri,
|
|
114
|
+
S3Bucket: state2.s3Bucket,
|
|
115
|
+
S3Key: state2.s3Key,
|
|
116
|
+
S3ObjectVersion: state2.s3ObjectVersion
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
return state2;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
50
125
|
// src/util/path.ts
|
|
51
126
|
import { lstat } from "fs/promises";
|
|
52
127
|
import { join, normalize, relative } from "path";
|
|
@@ -130,6 +205,8 @@ var createWorkSpace = async (props) => {
|
|
|
130
205
|
const aws = await terraform.install("hashicorp", "aws", "5.94.1");
|
|
131
206
|
const workspace = new WorkSpace({
|
|
132
207
|
providers: [
|
|
208
|
+
createLambdaProvider(props),
|
|
209
|
+
createCloudFrontProvider(props),
|
|
133
210
|
aws(
|
|
134
211
|
{
|
|
135
212
|
profile: props.profile,
|
|
@@ -414,21 +491,21 @@ var debug = (...parts) => {
|
|
|
414
491
|
};
|
|
415
492
|
|
|
416
493
|
// src/config/app.ts
|
|
417
|
-
import { z as
|
|
494
|
+
import { z as z23 } from "zod";
|
|
418
495
|
|
|
419
496
|
// src/feature/alert/schema.ts
|
|
420
497
|
import { kebabCase } from "change-case";
|
|
421
|
-
import { z as
|
|
498
|
+
import { z as z4 } from "zod";
|
|
422
499
|
|
|
423
500
|
// src/config/schema/email.ts
|
|
424
|
-
import { z } from "zod";
|
|
425
|
-
var EmailSchema =
|
|
501
|
+
import { z as z3 } from "zod";
|
|
502
|
+
var EmailSchema = z3.string().email();
|
|
426
503
|
|
|
427
504
|
// src/feature/alert/schema.ts
|
|
428
|
-
var AlertNameSchema =
|
|
429
|
-
var AlertsDefaultSchema =
|
|
505
|
+
var AlertNameSchema = z4.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid alert name").transform((value) => kebabCase(value)).describe("Define alert name.");
|
|
506
|
+
var AlertsDefaultSchema = z4.record(
|
|
430
507
|
AlertNameSchema,
|
|
431
|
-
|
|
508
|
+
z4.union([
|
|
432
509
|
//
|
|
433
510
|
EmailSchema.transform((v) => [v]),
|
|
434
511
|
EmailSchema.array()
|
|
@@ -436,17 +513,17 @@ var AlertsDefaultSchema = z2.record(
|
|
|
436
513
|
).optional().describe("Define the alerts in your app. Alerts are a way to send messages to one or more email addresses.");
|
|
437
514
|
|
|
438
515
|
// src/feature/auth/schema.ts
|
|
439
|
-
import { z as
|
|
516
|
+
import { z as z7 } from "zod";
|
|
440
517
|
|
|
441
518
|
// src/config/schema/resource-id.ts
|
|
442
519
|
import { kebabCase as kebabCase2 } from "change-case";
|
|
443
|
-
import { z as
|
|
444
|
-
var ResourceIdSchema =
|
|
520
|
+
import { z as z5 } from "zod";
|
|
521
|
+
var ResourceIdSchema = z5.string().min(3).max(24).regex(/^[a-z0-9\-]+$/i, "Invalid resource ID").transform((value) => kebabCase2(value));
|
|
445
522
|
|
|
446
523
|
// src/config/schema/duration.ts
|
|
447
524
|
import { parse } from "@awsless/duration";
|
|
448
|
-
import { z as
|
|
449
|
-
var DurationSchema =
|
|
525
|
+
import { z as z6 } from "zod";
|
|
526
|
+
var DurationSchema = z6.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?|weeks?)$/, "Invalid duration").transform((v) => parse(v));
|
|
450
527
|
var durationMin = (min) => {
|
|
451
528
|
return (duration) => {
|
|
452
529
|
return duration.value >= min.value;
|
|
@@ -459,10 +536,10 @@ var durationMax = (max) => {
|
|
|
459
536
|
};
|
|
460
537
|
|
|
461
538
|
// src/feature/auth/schema.ts
|
|
462
|
-
var AuthDefaultSchema =
|
|
539
|
+
var AuthDefaultSchema = z7.record(
|
|
463
540
|
ResourceIdSchema,
|
|
464
|
-
|
|
465
|
-
allowUserRegistration:
|
|
541
|
+
z7.object({
|
|
542
|
+
allowUserRegistration: z7.boolean().default(true).describe("Specifies whether users can create an user account or if only the administrator can."),
|
|
466
543
|
// messaging: z
|
|
467
544
|
// .object({
|
|
468
545
|
// fromEmail: EmailSchema.describe("Specifies the sender's email address."),
|
|
@@ -474,23 +551,23 @@ var AuthDefaultSchema = z5.record(
|
|
|
474
551
|
// .optional()
|
|
475
552
|
// .describe('The email configuration for sending messages.'),
|
|
476
553
|
// secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
|
|
477
|
-
username:
|
|
554
|
+
username: z7.object({
|
|
478
555
|
// emailAlias: z.boolean().default(true).describe('Allow the user email to be used as username.'),
|
|
479
|
-
caseSensitive:
|
|
556
|
+
caseSensitive: z7.boolean().default(false).describe(
|
|
480
557
|
"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."
|
|
481
558
|
)
|
|
482
559
|
}).default({}).describe("The username policy."),
|
|
483
|
-
password:
|
|
484
|
-
minLength:
|
|
485
|
-
uppercase:
|
|
486
|
-
lowercase:
|
|
487
|
-
numbers:
|
|
488
|
-
symbols:
|
|
560
|
+
password: z7.object({
|
|
561
|
+
minLength: z7.number().int().min(6).max(99).default(12).describe("Required users to have at least the minimum password length."),
|
|
562
|
+
uppercase: z7.boolean().default(true).describe("Required users to use at least one uppercase letter in their password."),
|
|
563
|
+
lowercase: z7.boolean().default(true).describe("Required users to use at least one lowercase letter in their password."),
|
|
564
|
+
numbers: z7.boolean().default(true).describe("Required users to use at least one number in their password."),
|
|
565
|
+
symbols: z7.boolean().default(true).describe("Required users to use at least one symbol in their password."),
|
|
489
566
|
temporaryPasswordValidity: DurationSchema.default("7 days").describe(
|
|
490
567
|
"The duration a temporary password is valid. If the user doesn't sign in during this time, an administrator must reset their password."
|
|
491
568
|
)
|
|
492
569
|
}).default({}).describe("The password policy."),
|
|
493
|
-
validity:
|
|
570
|
+
validity: z7.object({
|
|
494
571
|
idToken: DurationSchema.default("1 hour").describe(
|
|
495
572
|
"The ID token time limit. After this limit expires, your user can't use their ID token."
|
|
496
573
|
),
|
|
@@ -506,18 +583,18 @@ var AuthDefaultSchema = z5.record(
|
|
|
506
583
|
).default({}).describe("Define the authenticatable users in your app.");
|
|
507
584
|
|
|
508
585
|
// src/feature/domain/schema.ts
|
|
509
|
-
import { z as
|
|
510
|
-
var DomainNameSchema =
|
|
586
|
+
import { z as z8 } from "zod";
|
|
587
|
+
var DomainNameSchema = z8.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
|
|
511
588
|
"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."
|
|
512
589
|
);
|
|
513
|
-
var DNSTypeSchema =
|
|
590
|
+
var DNSTypeSchema = z8.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
|
|
514
591
|
var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
|
|
515
|
-
var RecordsSchema =
|
|
516
|
-
var DomainsDefaultSchema =
|
|
592
|
+
var RecordsSchema = z8.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
|
|
593
|
+
var DomainsDefaultSchema = z8.record(
|
|
517
594
|
ResourceIdSchema,
|
|
518
|
-
|
|
595
|
+
z8.object({
|
|
519
596
|
domain: DomainNameSchema.describe("Define the domain name"),
|
|
520
|
-
dns:
|
|
597
|
+
dns: z8.object({
|
|
521
598
|
name: DomainNameSchema.optional(),
|
|
522
599
|
type: DNSTypeSchema,
|
|
523
600
|
ttl: TTLSchema,
|
|
@@ -529,15 +606,15 @@ var DomainsDefaultSchema = z6.record(
|
|
|
529
606
|
// src/feature/function/schema.ts
|
|
530
607
|
import { days, minutes, seconds, toDays } from "@awsless/duration";
|
|
531
608
|
import { gibibytes, mebibytes } from "@awsless/size";
|
|
532
|
-
import { z as
|
|
609
|
+
import { z as z13 } from "zod";
|
|
533
610
|
|
|
534
611
|
// src/config/schema/local-directory.ts
|
|
535
612
|
import { stat } from "fs/promises";
|
|
536
|
-
import { z as
|
|
613
|
+
import { z as z10 } from "zod";
|
|
537
614
|
|
|
538
615
|
// src/config/schema/relative-path.ts
|
|
539
616
|
import { join as join3 } from "path";
|
|
540
|
-
import { z as
|
|
617
|
+
import { z as z9 } from "zod";
|
|
541
618
|
var basePath;
|
|
542
619
|
var setLocalBasePath = (path) => {
|
|
543
620
|
basePath = path;
|
|
@@ -548,10 +625,10 @@ var resolvePath = (path) => {
|
|
|
548
625
|
}
|
|
549
626
|
return path;
|
|
550
627
|
};
|
|
551
|
-
var RelativePathSchema =
|
|
628
|
+
var RelativePathSchema = z9.string().transform((path) => resolvePath(path));
|
|
552
629
|
|
|
553
630
|
// src/config/schema/local-directory.ts
|
|
554
|
-
var LocalDirectorySchema =
|
|
631
|
+
var LocalDirectorySchema = z10.union([
|
|
555
632
|
RelativePathSchema.refine(async (path) => {
|
|
556
633
|
try {
|
|
557
634
|
const s = await stat(path);
|
|
@@ -560,15 +637,15 @@ var LocalDirectorySchema = z8.union([
|
|
|
560
637
|
return false;
|
|
561
638
|
}
|
|
562
639
|
}, `Directory doesn't exist`),
|
|
563
|
-
|
|
564
|
-
nocheck:
|
|
640
|
+
z10.object({
|
|
641
|
+
nocheck: z10.string().describe("Specifies a local directory without checking if the directory exists.")
|
|
565
642
|
}).transform((v) => v.nocheck)
|
|
566
643
|
]);
|
|
567
644
|
|
|
568
645
|
// src/config/schema/local-file.ts
|
|
569
646
|
import { stat as stat2 } from "fs/promises";
|
|
570
|
-
import { z as
|
|
571
|
-
var LocalFileSchema =
|
|
647
|
+
import { z as z11 } from "zod";
|
|
648
|
+
var LocalFileSchema = z11.union([
|
|
572
649
|
RelativePathSchema.refine(async (path) => {
|
|
573
650
|
try {
|
|
574
651
|
const s = await stat2(path);
|
|
@@ -577,15 +654,15 @@ var LocalFileSchema = z9.union([
|
|
|
577
654
|
return false;
|
|
578
655
|
}
|
|
579
656
|
}, `File doesn't exist`),
|
|
580
|
-
|
|
581
|
-
nocheck:
|
|
657
|
+
z11.object({
|
|
658
|
+
nocheck: z11.string().describe("Specifies a local file without checking if the file exists.")
|
|
582
659
|
}).transform((v) => v.nocheck)
|
|
583
660
|
]);
|
|
584
661
|
|
|
585
662
|
// src/config/schema/size.ts
|
|
586
663
|
import { parse as parse2 } from "@awsless/size";
|
|
587
|
-
import { z as
|
|
588
|
-
var SizeSchema =
|
|
664
|
+
import { z as z12 } from "zod";
|
|
665
|
+
var SizeSchema = z12.string().regex(/^[0-9]+ (B|KB|MB|GB|TB|PB)$/, "Invalid size").transform((v) => parse2(v));
|
|
589
666
|
var sizeMin = (min) => {
|
|
590
667
|
return (size) => {
|
|
591
668
|
return size.value >= min.value;
|
|
@@ -608,32 +685,32 @@ var EphemeralStorageSizeSchema = SizeSchema.refine(
|
|
|
608
685
|
sizeMin(mebibytes(512)),
|
|
609
686
|
"Minimum ephemeral storage size is 512 MB"
|
|
610
687
|
).refine(sizeMax(gibibytes(10)), "Minimum ephemeral storage size is 10 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GB.");
|
|
611
|
-
var ReservedConcurrentExecutionsSchema =
|
|
612
|
-
var EnvironmentSchema =
|
|
613
|
-
var ArchitectureSchema =
|
|
614
|
-
var RetryAttemptsSchema =
|
|
688
|
+
var ReservedConcurrentExecutionsSchema = z13.number().int().min(0).describe("The number of simultaneous executions to reserve for the function. You can specify a number from 0.");
|
|
689
|
+
var EnvironmentSchema = z13.record(z13.string(), z13.string()).optional().describe("Environment variable key-value pairs.");
|
|
690
|
+
var ArchitectureSchema = z13.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
|
|
691
|
+
var RetryAttemptsSchema = z13.number().int().min(0).max(2).describe(
|
|
615
692
|
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
616
693
|
);
|
|
617
|
-
var NodeRuntimeSchema =
|
|
618
|
-
var ContainerRuntimeSchema =
|
|
619
|
-
var RuntimeSchema = NodeRuntimeSchema.or(ContainerRuntimeSchema).or(
|
|
620
|
-
var ActionSchema =
|
|
621
|
-
var ActionsSchema =
|
|
622
|
-
var ArnSchema =
|
|
623
|
-
var WildcardSchema =
|
|
624
|
-
var ResourceSchema =
|
|
625
|
-
var ResourcesSchema =
|
|
626
|
-
var PermissionSchema =
|
|
627
|
-
effect:
|
|
694
|
+
var NodeRuntimeSchema = z13.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]);
|
|
695
|
+
var ContainerRuntimeSchema = z13.literal("container");
|
|
696
|
+
var RuntimeSchema = NodeRuntimeSchema.or(ContainerRuntimeSchema).or(z13.string()).describe("The identifier of the function's runtime.");
|
|
697
|
+
var ActionSchema = z13.string();
|
|
698
|
+
var ActionsSchema = z13.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
|
|
699
|
+
var ArnSchema = z13.string().startsWith("arn:");
|
|
700
|
+
var WildcardSchema = z13.literal("*");
|
|
701
|
+
var ResourceSchema = z13.union([ArnSchema, WildcardSchema]);
|
|
702
|
+
var ResourcesSchema = z13.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
|
|
703
|
+
var PermissionSchema = z13.object({
|
|
704
|
+
effect: z13.enum(["allow", "deny"]).default("allow"),
|
|
628
705
|
actions: ActionsSchema,
|
|
629
706
|
resources: ResourcesSchema
|
|
630
707
|
});
|
|
631
|
-
var PermissionsSchema =
|
|
632
|
-
var WarmSchema =
|
|
633
|
-
var VPCSchema =
|
|
634
|
-
var MinifySchema =
|
|
635
|
-
var HandlerSchema =
|
|
636
|
-
var DescriptionSchema =
|
|
708
|
+
var PermissionsSchema = z13.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
|
|
709
|
+
var WarmSchema = z13.number().int().min(0).max(10).describe("Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10.");
|
|
710
|
+
var VPCSchema = z13.boolean().describe("Put the function inside your global VPC.");
|
|
711
|
+
var MinifySchema = z13.boolean().describe("Minify the function code.");
|
|
712
|
+
var HandlerSchema = z13.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
|
|
713
|
+
var DescriptionSchema = z13.string().describe("A description of the function.");
|
|
637
714
|
var validLogRetentionDays = [
|
|
638
715
|
...[1, 3, 5, 7, 14, 30, 60, 90, 120, 150],
|
|
639
716
|
...[180, 365, 400, 545, 731, 1096, 1827, 2192],
|
|
@@ -648,43 +725,43 @@ var LogRetentionSchema = DurationSchema.refine(
|
|
|
648
725
|
},
|
|
649
726
|
`Invalid log retention. Valid days are: ${validLogRetentionDays.map((days6) => `${days6}`).join(", ")}`
|
|
650
727
|
).describe("The log retention duration.");
|
|
651
|
-
var LogSchema =
|
|
652
|
-
|
|
728
|
+
var LogSchema = z13.union([
|
|
729
|
+
z13.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
|
|
653
730
|
LogRetentionSchema.transform((retention) => ({ retention })),
|
|
654
|
-
|
|
731
|
+
z13.object({
|
|
655
732
|
// subscription: LogSubscriptionSchema.optional(),
|
|
656
733
|
retention: LogRetentionSchema.optional(),
|
|
657
|
-
format:
|
|
734
|
+
format: z13.enum(["text", "json"]).describe(
|
|
658
735
|
`The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
|
|
659
736
|
).optional(),
|
|
660
|
-
system:
|
|
737
|
+
system: z13.enum(["debug", "info", "warn"]).describe(
|
|
661
738
|
"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."
|
|
662
739
|
).optional(),
|
|
663
|
-
level:
|
|
740
|
+
level: z13.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
|
|
664
741
|
"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."
|
|
665
742
|
).optional()
|
|
666
743
|
})
|
|
667
744
|
]).describe("Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time.");
|
|
668
|
-
var LayersSchema =
|
|
745
|
+
var LayersSchema = z13.string().array().describe(
|
|
669
746
|
// `A list of function layers to add to the function's execution environment..`
|
|
670
747
|
`A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.`
|
|
671
748
|
);
|
|
672
|
-
var FileCodeSchema =
|
|
749
|
+
var FileCodeSchema = z13.object({
|
|
673
750
|
file: LocalFileSchema.describe("The file path of the function code."),
|
|
674
751
|
minify: MinifySchema.optional().default(true),
|
|
675
|
-
external:
|
|
752
|
+
external: z13.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`)
|
|
676
753
|
});
|
|
677
|
-
var BundleCodeSchema =
|
|
754
|
+
var BundleCodeSchema = z13.object({
|
|
678
755
|
bundle: LocalDirectorySchema.describe("The directory that needs to be bundled.")
|
|
679
756
|
});
|
|
680
|
-
var CodeSchema =
|
|
757
|
+
var CodeSchema = z13.union([
|
|
681
758
|
LocalFileSchema.transform((file) => ({
|
|
682
759
|
file
|
|
683
760
|
})).pipe(FileCodeSchema),
|
|
684
761
|
FileCodeSchema,
|
|
685
762
|
BundleCodeSchema
|
|
686
763
|
]).describe("Specify the code of your function.");
|
|
687
|
-
var FnSchema =
|
|
764
|
+
var FnSchema = z13.object({
|
|
688
765
|
code: CodeSchema,
|
|
689
766
|
// node
|
|
690
767
|
handler: HandlerSchema.optional(),
|
|
@@ -707,14 +784,14 @@ var FnSchema = z11.object({
|
|
|
707
784
|
environment: EnvironmentSchema.optional(),
|
|
708
785
|
permissions: PermissionsSchema.optional()
|
|
709
786
|
});
|
|
710
|
-
var FunctionSchema =
|
|
787
|
+
var FunctionSchema = z13.union([
|
|
711
788
|
LocalFileSchema.transform((code) => ({
|
|
712
789
|
code
|
|
713
790
|
})).pipe(FnSchema),
|
|
714
791
|
FnSchema
|
|
715
792
|
]);
|
|
716
|
-
var FunctionsSchema =
|
|
717
|
-
var FunctionDefaultSchema =
|
|
793
|
+
var FunctionsSchema = z13.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
|
|
794
|
+
var FunctionDefaultSchema = z13.object({
|
|
718
795
|
runtime: RuntimeSchema.default("nodejs20.x"),
|
|
719
796
|
// node
|
|
720
797
|
handler: HandlerSchema.default("index.default"),
|
|
@@ -743,25 +820,25 @@ var FunctionDefaultSchema = z11.object({
|
|
|
743
820
|
}).default({});
|
|
744
821
|
|
|
745
822
|
// src/feature/layer/schema.ts
|
|
746
|
-
import { z as
|
|
823
|
+
import { z as z15 } from "zod";
|
|
747
824
|
|
|
748
825
|
// src/config/schema/lambda.ts
|
|
749
|
-
import { z as
|
|
750
|
-
var ArchitectureSchema2 =
|
|
751
|
-
var NodeRuntimeSchema2 =
|
|
826
|
+
import { z as z14 } from "zod";
|
|
827
|
+
var ArchitectureSchema2 = z14.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
|
|
828
|
+
var NodeRuntimeSchema2 = z14.enum(["nodejs18.x", "nodejs20.x", "nodejs22.x"]).describe("The identifier of the function's runtime.");
|
|
752
829
|
|
|
753
830
|
// src/feature/layer/schema.ts
|
|
754
|
-
var Schema =
|
|
831
|
+
var Schema = z15.object({
|
|
755
832
|
file: LocalFileSchema,
|
|
756
833
|
runtimes: NodeRuntimeSchema2.array().optional(),
|
|
757
834
|
architecture: ArchitectureSchema2.optional(),
|
|
758
|
-
packages:
|
|
835
|
+
packages: z15.string().array().optional().describe(
|
|
759
836
|
"Define the package names that are available bundled in the layer. Those packages are not bundled while bundling the lambda."
|
|
760
837
|
)
|
|
761
838
|
});
|
|
762
|
-
var LayerSchema =
|
|
763
|
-
|
|
764
|
-
|
|
839
|
+
var LayerSchema = z15.record(
|
|
840
|
+
z15.string(),
|
|
841
|
+
z15.union([
|
|
765
842
|
LocalFileSchema.transform((file) => ({
|
|
766
843
|
file,
|
|
767
844
|
description: void 0
|
|
@@ -776,28 +853,28 @@ var OnFailureDefaultSchema = FunctionSchema.optional().describe(
|
|
|
776
853
|
);
|
|
777
854
|
|
|
778
855
|
// src/feature/on-log/schema.ts
|
|
779
|
-
import { z as
|
|
780
|
-
var FilterSchema =
|
|
781
|
-
var OnLogDefaultSchema =
|
|
856
|
+
import { z as z16 } from "zod";
|
|
857
|
+
var FilterSchema = z16.enum(["trace", "debug", "info", "warn", "error", "fatal"]).array().describe("The log level that will gets delivered to the consumer.");
|
|
858
|
+
var OnLogDefaultSchema = z16.union([
|
|
782
859
|
FunctionSchema.transform((consumer) => ({
|
|
783
860
|
consumer,
|
|
784
861
|
filter: ["error", "fatal"]
|
|
785
862
|
})),
|
|
786
|
-
|
|
863
|
+
z16.object({
|
|
787
864
|
consumer: FunctionSchema,
|
|
788
865
|
filter: FilterSchema
|
|
789
866
|
})
|
|
790
867
|
]).optional().describe("Define a subscription on all Lambda functions logs.");
|
|
791
868
|
|
|
792
869
|
// src/feature/pubsub/schema.ts
|
|
793
|
-
import { z as
|
|
870
|
+
import { z as z17 } from "zod";
|
|
794
871
|
var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
|
|
795
|
-
var PubSubDefaultSchema =
|
|
872
|
+
var PubSubDefaultSchema = z17.record(
|
|
796
873
|
ResourceIdSchema,
|
|
797
|
-
|
|
874
|
+
z17.object({
|
|
798
875
|
auth: FunctionSchema,
|
|
799
876
|
domain: DomainSchema.optional(),
|
|
800
|
-
subDomain:
|
|
877
|
+
subDomain: z17.string().optional()
|
|
801
878
|
// auth: z.union([
|
|
802
879
|
// ResourceIdSchema,
|
|
803
880
|
// z.object({
|
|
@@ -813,11 +890,11 @@ var PubSubDefaultSchema = z15.record(
|
|
|
813
890
|
// .optional(),
|
|
814
891
|
})
|
|
815
892
|
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
816
|
-
var PubSubSchema =
|
|
893
|
+
var PubSubSchema = z17.record(
|
|
817
894
|
ResourceIdSchema,
|
|
818
|
-
|
|
819
|
-
sql:
|
|
820
|
-
sqlVersion:
|
|
895
|
+
z17.object({
|
|
896
|
+
sql: z17.string().describe("The SQL statement used to query the IOT topic."),
|
|
897
|
+
sqlVersion: z17.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
|
|
821
898
|
consumer: FunctionSchema.describe("The consuming lambda function properties.")
|
|
822
899
|
})
|
|
823
900
|
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
@@ -825,7 +902,7 @@ var PubSubSchema = z15.record(
|
|
|
825
902
|
// src/feature/queue/schema.ts
|
|
826
903
|
import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
|
|
827
904
|
import { kibibytes } from "@awsless/size";
|
|
828
|
-
import { z as
|
|
905
|
+
import { z as z18 } from "zod";
|
|
829
906
|
var RetentionPeriodSchema = DurationSchema.refine(
|
|
830
907
|
durationMin(minutes2(1)),
|
|
831
908
|
"Minimum retention period is 1 minute"
|
|
@@ -853,10 +930,10 @@ var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
|
|
|
853
930
|
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(
|
|
854
931
|
"The limit of how many bytes that a message can contain before Amazon SQS rejects it. You can specify an size from 1 KB to 256 KB."
|
|
855
932
|
);
|
|
856
|
-
var BatchSizeSchema =
|
|
933
|
+
var BatchSizeSchema = z18.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000").describe(
|
|
857
934
|
"The maximum number of records in each batch that Lambda pulls from your queue and sends to your function. Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB). You can specify an integer from 1 to 10000."
|
|
858
935
|
);
|
|
859
|
-
var MaxConcurrencySchema =
|
|
936
|
+
var MaxConcurrencySchema = z18.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000").describe(
|
|
860
937
|
"Limits the number of concurrent instances that the queue worker can invoke. You can specify an integer from 2 to 1000."
|
|
861
938
|
);
|
|
862
939
|
var MaxBatchingWindow = DurationSchema.refine(
|
|
@@ -865,7 +942,7 @@ var MaxBatchingWindow = DurationSchema.refine(
|
|
|
865
942
|
).describe(
|
|
866
943
|
"The maximum amount of time, that Lambda spends gathering records before invoking the function. You can specify an duration from 0 seconds to 5 minutes."
|
|
867
944
|
);
|
|
868
|
-
var QueueDefaultSchema =
|
|
945
|
+
var QueueDefaultSchema = z18.object({
|
|
869
946
|
retentionPeriod: RetentionPeriodSchema.default("7 days"),
|
|
870
947
|
visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
|
|
871
948
|
deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
|
|
@@ -875,7 +952,7 @@ var QueueDefaultSchema = z16.object({
|
|
|
875
952
|
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
876
953
|
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
877
954
|
}).default({});
|
|
878
|
-
var QueueSchema =
|
|
955
|
+
var QueueSchema = z18.object({
|
|
879
956
|
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
880
957
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
881
958
|
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
@@ -886,9 +963,9 @@ var QueueSchema = z16.object({
|
|
|
886
963
|
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
887
964
|
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
888
965
|
});
|
|
889
|
-
var QueuesSchema =
|
|
966
|
+
var QueuesSchema = z18.record(
|
|
890
967
|
ResourceIdSchema,
|
|
891
|
-
|
|
968
|
+
z18.union([
|
|
892
969
|
LocalFileSchema.transform((consumer) => ({
|
|
893
970
|
consumer
|
|
894
971
|
})).pipe(QueueSchema),
|
|
@@ -897,26 +974,26 @@ var QueuesSchema = z16.record(
|
|
|
897
974
|
).optional().describe("Define the queues in your stack.");
|
|
898
975
|
|
|
899
976
|
// src/feature/rest/schema.ts
|
|
900
|
-
import { z as
|
|
977
|
+
import { z as z20 } from "zod";
|
|
901
978
|
|
|
902
979
|
// src/config/schema/route.ts
|
|
903
|
-
import { z as
|
|
904
|
-
var RouteSchema =
|
|
905
|
-
|
|
906
|
-
|
|
980
|
+
import { z as z19 } from "zod";
|
|
981
|
+
var RouteSchema = z19.union([
|
|
982
|
+
z19.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS|ANY)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
|
|
983
|
+
z19.literal("$default")
|
|
907
984
|
]);
|
|
908
985
|
|
|
909
986
|
// src/feature/rest/schema.ts
|
|
910
|
-
var RestDefaultSchema =
|
|
987
|
+
var RestDefaultSchema = z20.record(
|
|
911
988
|
ResourceIdSchema,
|
|
912
|
-
|
|
989
|
+
z20.object({
|
|
913
990
|
domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
|
|
914
|
-
subDomain:
|
|
991
|
+
subDomain: z20.string().optional()
|
|
915
992
|
})
|
|
916
993
|
).optional().describe("Define your global REST API's.");
|
|
917
|
-
var RestSchema =
|
|
994
|
+
var RestSchema = z20.record(
|
|
918
995
|
ResourceIdSchema,
|
|
919
|
-
|
|
996
|
+
z20.record(
|
|
920
997
|
RouteSchema.describe(
|
|
921
998
|
[
|
|
922
999
|
"The REST API route that is comprised by the http method and http path.",
|
|
@@ -929,7 +1006,7 @@ var RestSchema = z18.record(
|
|
|
929
1006
|
).optional().describe("Define routes in your stack for your global REST API.");
|
|
930
1007
|
|
|
931
1008
|
// src/feature/rpc/schema.ts
|
|
932
|
-
import { z as
|
|
1009
|
+
import { z as z21 } from "zod";
|
|
933
1010
|
import { minutes as minutes3, seconds as seconds3 } from "@awsless/duration";
|
|
934
1011
|
var TimeoutSchema2 = DurationSchema.refine(durationMin(seconds3(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes3(5)), "Maximum timeout duration is 5 minutes").describe(
|
|
935
1012
|
[
|
|
@@ -938,21 +1015,21 @@ var TimeoutSchema2 = DurationSchema.refine(durationMin(seconds3(10)), "Minimum t
|
|
|
938
1015
|
"The timeouts of all inner RPC functions will be capped at 80% of this timeout."
|
|
939
1016
|
].join(" ")
|
|
940
1017
|
);
|
|
941
|
-
var RpcDefaultSchema =
|
|
1018
|
+
var RpcDefaultSchema = z21.record(
|
|
942
1019
|
ResourceIdSchema,
|
|
943
|
-
|
|
1020
|
+
z21.object({
|
|
944
1021
|
domain: ResourceIdSchema.describe("The domain id to link your RPC API with.").optional(),
|
|
945
|
-
subDomain:
|
|
1022
|
+
subDomain: z21.string().optional(),
|
|
946
1023
|
auth: FunctionSchema.optional(),
|
|
947
1024
|
log: LogSchema.optional(),
|
|
948
1025
|
timeout: TimeoutSchema2.default("1 minutes"),
|
|
949
|
-
geoRestrictions:
|
|
1026
|
+
geoRestrictions: z21.array(z21.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
|
|
950
1027
|
})
|
|
951
1028
|
).describe(`Define the global RPC API's.`).optional();
|
|
952
|
-
var RpcSchema =
|
|
1029
|
+
var RpcSchema = z21.record(ResourceIdSchema, z21.record(z21.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
|
|
953
1030
|
|
|
954
1031
|
// src/config/schema/region.ts
|
|
955
|
-
import { z as
|
|
1032
|
+
import { z as z22 } from "zod";
|
|
956
1033
|
var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
|
|
957
1034
|
var AF = ["af-south-1"];
|
|
958
1035
|
var AP = [
|
|
@@ -981,16 +1058,16 @@ var EU = [
|
|
|
981
1058
|
var ME = ["me-south-1", "me-central-1"];
|
|
982
1059
|
var SA = ["sa-east-1"];
|
|
983
1060
|
var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
|
|
984
|
-
var RegionSchema =
|
|
1061
|
+
var RegionSchema = z22.enum(regions);
|
|
985
1062
|
|
|
986
1063
|
// src/config/app.ts
|
|
987
|
-
var AppSchema =
|
|
988
|
-
$schema:
|
|
1064
|
+
var AppSchema = z23.object({
|
|
1065
|
+
$schema: z23.string().optional(),
|
|
989
1066
|
name: ResourceIdSchema.describe("App name."),
|
|
990
1067
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
991
|
-
profile:
|
|
992
|
-
protect:
|
|
993
|
-
removal:
|
|
1068
|
+
profile: z23.string().describe("The AWS profile to deploy to."),
|
|
1069
|
+
protect: z23.boolean().default(false).describe("Protect your app & stacks from being deleted."),
|
|
1070
|
+
removal: z23.enum(["remove", "retain"]).default("remove").describe(
|
|
994
1071
|
[
|
|
995
1072
|
"Configure how your resources are handled when they have to be removed.",
|
|
996
1073
|
"",
|
|
@@ -1004,7 +1081,7 @@ var AppSchema = z21.object({
|
|
|
1004
1081
|
// .default('prod')
|
|
1005
1082
|
// .describe('The deployment stage.'),
|
|
1006
1083
|
// onFailure: OnFailureSchema,
|
|
1007
|
-
defaults:
|
|
1084
|
+
defaults: z23.object({
|
|
1008
1085
|
onFailure: OnFailureDefaultSchema,
|
|
1009
1086
|
onLog: OnLogDefaultSchema,
|
|
1010
1087
|
auth: AuthDefaultSchema,
|
|
@@ -1026,11 +1103,11 @@ var AppSchema = z21.object({
|
|
|
1026
1103
|
});
|
|
1027
1104
|
|
|
1028
1105
|
// src/config/stack.ts
|
|
1029
|
-
import { z as
|
|
1106
|
+
import { z as z37 } from "zod";
|
|
1030
1107
|
|
|
1031
1108
|
// src/feature/cache/schema.ts
|
|
1032
1109
|
import { gibibytes as gibibytes2 } from "@awsless/size";
|
|
1033
|
-
import { z as
|
|
1110
|
+
import { z as z24 } from "zod";
|
|
1034
1111
|
var StorageSchema = SizeSchema.refine(sizeMin(gibibytes2(1)), "Minimum storage size is 1 GB").refine(
|
|
1035
1112
|
sizeMax(gibibytes2(5e3)),
|
|
1036
1113
|
"Maximum storage size is 5000 GB"
|
|
@@ -1041,31 +1118,31 @@ var MinimumStorageSchema = StorageSchema.describe(
|
|
|
1041
1118
|
var MaximumStorageSchema = StorageSchema.describe(
|
|
1042
1119
|
"The upper limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB."
|
|
1043
1120
|
);
|
|
1044
|
-
var EcpuSchema =
|
|
1121
|
+
var EcpuSchema = z24.number().int().min(1e3).max(15e6);
|
|
1045
1122
|
var MinimumEcpuSchema = EcpuSchema.describe(
|
|
1046
1123
|
"The minimum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
|
|
1047
1124
|
);
|
|
1048
1125
|
var MaximumEcpuSchema = EcpuSchema.describe(
|
|
1049
1126
|
"The maximum number of ECPUs the cache can consume per second. You can specify a integer from 1,000 to 15,000,000."
|
|
1050
1127
|
);
|
|
1051
|
-
var CachesSchema =
|
|
1128
|
+
var CachesSchema = z24.record(
|
|
1052
1129
|
ResourceIdSchema,
|
|
1053
|
-
|
|
1130
|
+
z24.object({
|
|
1054
1131
|
minStorage: MinimumStorageSchema.optional(),
|
|
1055
1132
|
maxStorage: MaximumStorageSchema.optional(),
|
|
1056
1133
|
minECPU: MinimumEcpuSchema.optional(),
|
|
1057
1134
|
maxECPU: MaximumEcpuSchema.optional(),
|
|
1058
|
-
snapshotRetentionLimit:
|
|
1135
|
+
snapshotRetentionLimit: z24.number().int().positive().default(1)
|
|
1059
1136
|
})
|
|
1060
1137
|
).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
|
|
1061
1138
|
|
|
1062
1139
|
// src/feature/command/schema.ts
|
|
1063
|
-
import { z as
|
|
1064
|
-
var CommandSchema =
|
|
1065
|
-
|
|
1140
|
+
import { z as z25 } from "zod";
|
|
1141
|
+
var CommandSchema = z25.union([
|
|
1142
|
+
z25.object({
|
|
1066
1143
|
file: LocalFileSchema,
|
|
1067
|
-
handler:
|
|
1068
|
-
description:
|
|
1144
|
+
handler: z25.string().default("default").describe("The name of the handler that needs to run"),
|
|
1145
|
+
description: z25.string().optional().describe("A description of the command")
|
|
1069
1146
|
// options: z.record(ResourceIdSchema, OptionSchema).optional(),
|
|
1070
1147
|
// arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
|
|
1071
1148
|
}),
|
|
@@ -1075,22 +1152,22 @@ var CommandSchema = z23.union([
|
|
|
1075
1152
|
description: void 0
|
|
1076
1153
|
}))
|
|
1077
1154
|
]);
|
|
1078
|
-
var CommandsSchema =
|
|
1155
|
+
var CommandsSchema = z25.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
|
|
1079
1156
|
|
|
1080
1157
|
// src/feature/config/schema.ts
|
|
1081
|
-
import { z as
|
|
1082
|
-
var ConfigNameSchema =
|
|
1083
|
-
var ConfigsSchema =
|
|
1158
|
+
import { z as z26 } from "zod";
|
|
1159
|
+
var ConfigNameSchema = z26.string().regex(/[a-z0-9\-]/g, "Invalid config name");
|
|
1160
|
+
var ConfigsSchema = z26.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
|
|
1084
1161
|
|
|
1085
1162
|
// src/feature/cron/schema/index.ts
|
|
1086
|
-
import { z as
|
|
1163
|
+
import { z as z28 } from "zod";
|
|
1087
1164
|
|
|
1088
1165
|
// src/feature/cron/schema/schedule.ts
|
|
1089
|
-
import { z as
|
|
1166
|
+
import { z as z27 } from "zod";
|
|
1090
1167
|
import { awsCronExpressionValidator } from "aws-cron-expression-validator";
|
|
1091
|
-
var RateExpressionSchema =
|
|
1168
|
+
var RateExpressionSchema = z27.custom(
|
|
1092
1169
|
(value) => {
|
|
1093
|
-
return
|
|
1170
|
+
return z27.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
|
|
1094
1171
|
const [str] = rate.split(" ");
|
|
1095
1172
|
const number = parseInt(str);
|
|
1096
1173
|
return number > 0;
|
|
@@ -1106,9 +1183,9 @@ var RateExpressionSchema = z25.custom(
|
|
|
1106
1183
|
}
|
|
1107
1184
|
return `rate(${rate})`;
|
|
1108
1185
|
});
|
|
1109
|
-
var CronExpressionSchema =
|
|
1186
|
+
var CronExpressionSchema = z27.custom(
|
|
1110
1187
|
(value) => {
|
|
1111
|
-
return
|
|
1188
|
+
return z27.string().safeParse(value).success;
|
|
1112
1189
|
},
|
|
1113
1190
|
{ message: "Invalid cron expression" }
|
|
1114
1191
|
).superRefine((value, ctx) => {
|
|
@@ -1117,12 +1194,12 @@ var CronExpressionSchema = z25.custom(
|
|
|
1117
1194
|
} catch (error) {
|
|
1118
1195
|
if (error instanceof Error) {
|
|
1119
1196
|
ctx.addIssue({
|
|
1120
|
-
code:
|
|
1197
|
+
code: z27.ZodIssueCode.custom,
|
|
1121
1198
|
message: `Invalid cron expression: ${error.message}`
|
|
1122
1199
|
});
|
|
1123
1200
|
} else {
|
|
1124
1201
|
ctx.addIssue({
|
|
1125
|
-
code:
|
|
1202
|
+
code: z27.ZodIssueCode.custom,
|
|
1126
1203
|
message: "Invalid cron expression"
|
|
1127
1204
|
});
|
|
1128
1205
|
}
|
|
@@ -1133,23 +1210,23 @@ var CronExpressionSchema = z25.custom(
|
|
|
1133
1210
|
var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
1134
1211
|
|
|
1135
1212
|
// src/feature/cron/schema/index.ts
|
|
1136
|
-
var CronsSchema =
|
|
1213
|
+
var CronsSchema = z28.record(
|
|
1137
1214
|
ResourceIdSchema,
|
|
1138
|
-
|
|
1139
|
-
enabled:
|
|
1215
|
+
z28.object({
|
|
1216
|
+
enabled: z28.boolean().default(true).describe("If the cron is enabled."),
|
|
1140
1217
|
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
1141
1218
|
schedule: ScheduleExpressionSchema.describe(
|
|
1142
1219
|
'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
|
|
1143
1220
|
),
|
|
1144
|
-
payload:
|
|
1221
|
+
payload: z28.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
1145
1222
|
})
|
|
1146
1223
|
).optional().describe(`Define the cron jobs in your stack.`);
|
|
1147
1224
|
|
|
1148
1225
|
// src/feature/search/schema.ts
|
|
1149
1226
|
import { gibibytes as gibibytes3 } from "@awsless/size";
|
|
1150
|
-
import { z as
|
|
1151
|
-
var VersionSchema =
|
|
1152
|
-
var TypeSchema =
|
|
1227
|
+
import { z as z29 } from "zod";
|
|
1228
|
+
var VersionSchema = z29.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
|
|
1229
|
+
var TypeSchema = z29.enum([
|
|
1153
1230
|
"t3.small",
|
|
1154
1231
|
"t3.medium",
|
|
1155
1232
|
"m3.medium",
|
|
@@ -1224,11 +1301,11 @@ var TypeSchema = z27.enum([
|
|
|
1224
1301
|
"r6gd.16xlarge"
|
|
1225
1302
|
]);
|
|
1226
1303
|
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.");
|
|
1227
|
-
var SearchsSchema =
|
|
1304
|
+
var SearchsSchema = z29.record(
|
|
1228
1305
|
ResourceIdSchema,
|
|
1229
|
-
|
|
1306
|
+
z29.object({
|
|
1230
1307
|
type: TypeSchema.default("t3.small"),
|
|
1231
|
-
count:
|
|
1308
|
+
count: z29.number().int().min(1).default(1),
|
|
1232
1309
|
version: VersionSchema.default("2.13"),
|
|
1233
1310
|
storage: StorageSizeSchema.default("10 GB")
|
|
1234
1311
|
// vpc: z.boolean().default(false),
|
|
@@ -1236,12 +1313,12 @@ var SearchsSchema = z27.record(
|
|
|
1236
1313
|
).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
|
|
1237
1314
|
|
|
1238
1315
|
// src/feature/site/schema.ts
|
|
1239
|
-
import { z as
|
|
1316
|
+
import { z as z31 } from "zod";
|
|
1240
1317
|
|
|
1241
1318
|
// src/config/schema/local-entry.ts
|
|
1242
1319
|
import { stat as stat3 } from "fs/promises";
|
|
1243
|
-
import { z as
|
|
1244
|
-
var LocalEntrySchema =
|
|
1320
|
+
import { z as z30 } from "zod";
|
|
1321
|
+
var LocalEntrySchema = z30.union([
|
|
1245
1322
|
RelativePathSchema.refine(async (path) => {
|
|
1246
1323
|
try {
|
|
1247
1324
|
const s = await stat3(path);
|
|
@@ -1250,34 +1327,45 @@ var LocalEntrySchema = z28.union([
|
|
|
1250
1327
|
return false;
|
|
1251
1328
|
}
|
|
1252
1329
|
}, `File or directory doesn't exist`),
|
|
1253
|
-
|
|
1254
|
-
nocheck:
|
|
1330
|
+
z30.object({
|
|
1331
|
+
nocheck: z30.string().describe("Specifies a local file or directory without checking if the file or directory exists.")
|
|
1255
1332
|
}).transform((v) => v.nocheck)
|
|
1256
1333
|
]);
|
|
1257
1334
|
|
|
1258
1335
|
// src/feature/site/schema.ts
|
|
1259
|
-
var ErrorResponsePathSchema =
|
|
1260
|
-
|
|
1336
|
+
var ErrorResponsePathSchema = z31.string().describe(
|
|
1337
|
+
[
|
|
1338
|
+
"The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.",
|
|
1339
|
+
"- We recommend that you store custom error pages in an Amazon S3 bucket.",
|
|
1340
|
+
"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."
|
|
1341
|
+
].join("\n")
|
|
1261
1342
|
);
|
|
1262
|
-
var StatusCodeSchema =
|
|
1263
|
-
|
|
1343
|
+
var StatusCodeSchema = z31.number().int().positive().optional().describe(
|
|
1344
|
+
[
|
|
1345
|
+
"The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.",
|
|
1346
|
+
"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:",
|
|
1347
|
+
"- 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.",
|
|
1348
|
+
"If you substitute 200, the response typically won't be intercepted.",
|
|
1349
|
+
`- 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.`,
|
|
1350
|
+
`- You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down.`
|
|
1351
|
+
].join("\n")
|
|
1264
1352
|
);
|
|
1265
1353
|
var MinTTLSchema = DurationSchema.describe(
|
|
1266
1354
|
"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."
|
|
1267
1355
|
);
|
|
1268
|
-
var ErrorResponseSchema =
|
|
1356
|
+
var ErrorResponseSchema = z31.union([
|
|
1269
1357
|
ErrorResponsePathSchema,
|
|
1270
|
-
|
|
1358
|
+
z31.object({
|
|
1271
1359
|
path: ErrorResponsePathSchema,
|
|
1272
1360
|
statusCode: StatusCodeSchema.optional(),
|
|
1273
1361
|
minTTL: MinTTLSchema.optional()
|
|
1274
1362
|
})
|
|
1275
1363
|
]).optional();
|
|
1276
|
-
var SitesSchema =
|
|
1364
|
+
var SitesSchema = z31.record(
|
|
1277
1365
|
ResourceIdSchema,
|
|
1278
|
-
|
|
1366
|
+
z31.object({
|
|
1279
1367
|
domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
|
|
1280
|
-
subDomain:
|
|
1368
|
+
subDomain: z31.string().optional(),
|
|
1281
1369
|
// bind: z
|
|
1282
1370
|
// .object({
|
|
1283
1371
|
// auth: z.array(ResourceIdSchema),
|
|
@@ -1286,20 +1374,20 @@ var SitesSchema = z29.record(
|
|
|
1286
1374
|
// // rest: z.array(ResourceIdSchema),
|
|
1287
1375
|
// })
|
|
1288
1376
|
// .optional(),
|
|
1289
|
-
build:
|
|
1290
|
-
command:
|
|
1377
|
+
build: z31.object({
|
|
1378
|
+
command: z31.string().describe(
|
|
1291
1379
|
`Specifies the files and directories to generate the cache key for your custom build command.`
|
|
1292
1380
|
),
|
|
1293
|
-
cacheKey:
|
|
1381
|
+
cacheKey: z31.union([LocalEntrySchema.transform((v) => [v]), LocalEntrySchema.array()]).describe(
|
|
1294
1382
|
`Specifies the files and directories to generate the cache key for your custom build command.`
|
|
1295
1383
|
)
|
|
1296
1384
|
}).optional().describe(`Specifies the build process for sites that need a build step.`),
|
|
1297
|
-
static:
|
|
1385
|
+
static: z31.union([LocalDirectorySchema, z31.boolean()]).optional().describe(
|
|
1298
1386
|
"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."
|
|
1299
1387
|
),
|
|
1300
1388
|
ssr: FunctionSchema.optional().describe("Specifies the file that will render the site on the server."),
|
|
1301
1389
|
// envPrefix: z.string().optional().describe('Specifies a prefix for all '),
|
|
1302
|
-
origin:
|
|
1390
|
+
origin: z31.enum(["ssr-first", "static-first"]).default("static-first").describe("Specifies the origin fallback ordering."),
|
|
1303
1391
|
// bind: z.object({
|
|
1304
1392
|
// auth:
|
|
1305
1393
|
// h
|
|
@@ -1312,11 +1400,15 @@ var SitesSchema = z29.record(
|
|
|
1312
1400
|
// build: z.string().optional(),
|
|
1313
1401
|
// }),
|
|
1314
1402
|
// ]),
|
|
1315
|
-
geoRestrictions:
|
|
1316
|
-
forwardHost:
|
|
1317
|
-
|
|
1403
|
+
geoRestrictions: z31.array(z31.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked."),
|
|
1404
|
+
forwardHost: z31.boolean().default(false).describe(
|
|
1405
|
+
[
|
|
1406
|
+
"Specify if the original `host` header should be forwarded to the SSR function.",
|
|
1407
|
+
"The original `host` header will be forwarded as `x-forwarded-host`.",
|
|
1408
|
+
"Keep in mind that this requires an extra CloudFront Function."
|
|
1409
|
+
].join("\n")
|
|
1318
1410
|
),
|
|
1319
|
-
errors:
|
|
1411
|
+
errors: z31.object({
|
|
1320
1412
|
400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
|
|
1321
1413
|
403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
|
|
1322
1414
|
404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
|
|
@@ -1329,16 +1421,16 @@ var SitesSchema = z29.record(
|
|
|
1329
1421
|
503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
|
|
1330
1422
|
504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
|
|
1331
1423
|
}).optional().describe("Customize the error responses for specific HTTP status codes."),
|
|
1332
|
-
cors:
|
|
1333
|
-
override:
|
|
1424
|
+
cors: z31.object({
|
|
1425
|
+
override: z31.boolean().default(false),
|
|
1334
1426
|
maxAge: DurationSchema.default("365 days"),
|
|
1335
|
-
exposeHeaders:
|
|
1336
|
-
credentials:
|
|
1337
|
-
headers:
|
|
1338
|
-
origins:
|
|
1339
|
-
methods:
|
|
1340
|
-
}).optional().describe("
|
|
1341
|
-
security:
|
|
1427
|
+
exposeHeaders: z31.string().array().optional(),
|
|
1428
|
+
credentials: z31.boolean().default(false),
|
|
1429
|
+
headers: z31.string().array().default(["*"]),
|
|
1430
|
+
origins: z31.string().array().default(["*"]),
|
|
1431
|
+
methods: z31.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
|
|
1432
|
+
}).optional().describe("Specify the cors headers."),
|
|
1433
|
+
security: z31.object({
|
|
1342
1434
|
// contentSecurityPolicy: z.object({
|
|
1343
1435
|
// override: z.boolean().default(false),
|
|
1344
1436
|
// policy: z.string(),
|
|
@@ -1379,11 +1471,11 @@ var SitesSchema = z29.record(
|
|
|
1379
1471
|
// modeBlock?: boolean
|
|
1380
1472
|
// reportUri?: string
|
|
1381
1473
|
// }
|
|
1382
|
-
}).optional().describe("
|
|
1383
|
-
cache:
|
|
1384
|
-
cookies:
|
|
1385
|
-
headers:
|
|
1386
|
-
queries:
|
|
1474
|
+
}).optional().describe("Specify the security policy."),
|
|
1475
|
+
cache: z31.object({
|
|
1476
|
+
cookies: z31.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
|
|
1477
|
+
headers: z31.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
|
|
1478
|
+
queries: z31.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
|
|
1387
1479
|
}).optional().describe(
|
|
1388
1480
|
"Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
|
|
1389
1481
|
)
|
|
@@ -1391,22 +1483,22 @@ var SitesSchema = z29.record(
|
|
|
1391
1483
|
).optional().describe("Define the sites in your stack.");
|
|
1392
1484
|
|
|
1393
1485
|
// src/feature/store/schema.ts
|
|
1394
|
-
import { z as
|
|
1395
|
-
var StoresSchema =
|
|
1396
|
-
|
|
1486
|
+
import { z as z32 } from "zod";
|
|
1487
|
+
var StoresSchema = z32.union([
|
|
1488
|
+
z32.array(ResourceIdSchema).transform((list4) => {
|
|
1397
1489
|
const stores = {};
|
|
1398
|
-
for (const key of
|
|
1490
|
+
for (const key of list4) {
|
|
1399
1491
|
stores[key] = {};
|
|
1400
1492
|
}
|
|
1401
1493
|
return stores;
|
|
1402
1494
|
}),
|
|
1403
|
-
|
|
1495
|
+
z32.record(
|
|
1404
1496
|
ResourceIdSchema,
|
|
1405
|
-
|
|
1497
|
+
z32.object({
|
|
1406
1498
|
// cors: CorsSchema,
|
|
1407
1499
|
// deletionProtection: DeletionProtectionSchema.optional(),
|
|
1408
|
-
versioning:
|
|
1409
|
-
events:
|
|
1500
|
+
versioning: z32.boolean().default(false).describe("Enable versioning of your store."),
|
|
1501
|
+
events: z32.object({
|
|
1410
1502
|
// create
|
|
1411
1503
|
"created:*": FunctionSchema.optional().describe(
|
|
1412
1504
|
"Subscribe to notifications regardless of the API that was used to create an object."
|
|
@@ -1440,22 +1532,22 @@ var StoresSchema = z30.union([
|
|
|
1440
1532
|
|
|
1441
1533
|
// src/feature/table/schema.ts
|
|
1442
1534
|
import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
|
|
1443
|
-
import { z as
|
|
1444
|
-
var KeySchema =
|
|
1445
|
-
var TablesSchema =
|
|
1535
|
+
import { z as z33 } from "zod";
|
|
1536
|
+
var KeySchema = z33.string().min(1).max(255);
|
|
1537
|
+
var TablesSchema = z33.record(
|
|
1446
1538
|
ResourceIdSchema,
|
|
1447
|
-
|
|
1539
|
+
z33.object({
|
|
1448
1540
|
hash: KeySchema.describe(
|
|
1449
1541
|
"Specifies the name of the partition / hash key that makes up the primary key for the table."
|
|
1450
1542
|
),
|
|
1451
1543
|
sort: KeySchema.optional().describe(
|
|
1452
1544
|
"Specifies the name of the range / sort key that makes up the primary key for the table."
|
|
1453
1545
|
),
|
|
1454
|
-
fields:
|
|
1546
|
+
fields: z33.record(z33.string(), z33.enum(["string", "number", "binary"])).optional().describe(
|
|
1455
1547
|
'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
|
|
1456
1548
|
),
|
|
1457
|
-
class:
|
|
1458
|
-
pointInTimeRecovery:
|
|
1549
|
+
class: z33.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
|
|
1550
|
+
pointInTimeRecovery: z33.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
|
|
1459
1551
|
ttl: KeySchema.optional().describe(
|
|
1460
1552
|
[
|
|
1461
1553
|
"The name of the TTL attribute used to store the expiration time for items in the table.",
|
|
@@ -1463,8 +1555,8 @@ var TablesSchema = z31.record(
|
|
|
1463
1555
|
].join("\n")
|
|
1464
1556
|
),
|
|
1465
1557
|
// deletionProtection: DeletionProtectionSchema.optional(),
|
|
1466
|
-
stream:
|
|
1467
|
-
type:
|
|
1558
|
+
stream: z33.object({
|
|
1559
|
+
type: z33.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
|
|
1468
1560
|
[
|
|
1469
1561
|
"When an item in the table is modified, you can determines what information is written to the stream for this table.",
|
|
1470
1562
|
"Valid values are:",
|
|
@@ -1474,7 +1566,7 @@ var TablesSchema = z31.record(
|
|
|
1474
1566
|
"- new-and-old-images - Both the new and the old item images of the item are written to the stream."
|
|
1475
1567
|
].join("\n")
|
|
1476
1568
|
),
|
|
1477
|
-
batchSize:
|
|
1569
|
+
batchSize: z33.number().min(1).max(1e4).default(1).describe(
|
|
1478
1570
|
[
|
|
1479
1571
|
"The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
|
|
1480
1572
|
"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).",
|
|
@@ -1504,7 +1596,7 @@ var TablesSchema = z31.record(
|
|
|
1504
1596
|
// 'You can specify a number from -1 to 10000.',
|
|
1505
1597
|
// ].join('\n')
|
|
1506
1598
|
// ),
|
|
1507
|
-
retryAttempts:
|
|
1599
|
+
retryAttempts: z33.number().min(-1).max(1e4).default(-1).describe(
|
|
1508
1600
|
[
|
|
1509
1601
|
"Discard records after the specified number of retries.",
|
|
1510
1602
|
"The default value is -1, which sets the maximum number of retries to infinite.",
|
|
@@ -1512,7 +1604,7 @@ var TablesSchema = z31.record(
|
|
|
1512
1604
|
"You can specify a number from -1 to 10000."
|
|
1513
1605
|
].join("\n")
|
|
1514
1606
|
),
|
|
1515
|
-
concurrencyPerShard:
|
|
1607
|
+
concurrencyPerShard: z33.number().min(1).max(10).default(1).describe(
|
|
1516
1608
|
[
|
|
1517
1609
|
"The number of batches to process concurrently from each shard.",
|
|
1518
1610
|
"You can specify a number from 1 to 10."
|
|
@@ -1522,16 +1614,16 @@ var TablesSchema = z31.record(
|
|
|
1522
1614
|
}).optional().describe(
|
|
1523
1615
|
"The settings for the DynamoDB table stream, which capture changes to items stored in the table."
|
|
1524
1616
|
),
|
|
1525
|
-
indexes:
|
|
1526
|
-
|
|
1527
|
-
|
|
1617
|
+
indexes: z33.record(
|
|
1618
|
+
z33.string(),
|
|
1619
|
+
z33.object({
|
|
1528
1620
|
hash: KeySchema.describe(
|
|
1529
1621
|
"Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
|
|
1530
1622
|
),
|
|
1531
1623
|
sort: KeySchema.optional().describe(
|
|
1532
1624
|
"Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
|
|
1533
1625
|
),
|
|
1534
|
-
projection:
|
|
1626
|
+
projection: z33.enum(["all", "keys-only"]).default("all").describe(
|
|
1535
1627
|
[
|
|
1536
1628
|
"The set of attributes that are projected into the index:",
|
|
1537
1629
|
"- all - All of the table attributes are projected into the index.",
|
|
@@ -1545,11 +1637,11 @@ var TablesSchema = z31.record(
|
|
|
1545
1637
|
).optional().describe("Define the tables in your stack.");
|
|
1546
1638
|
|
|
1547
1639
|
// src/feature/task/schema.ts
|
|
1548
|
-
import { z as
|
|
1549
|
-
var RetryAttemptsSchema2 =
|
|
1640
|
+
import { z as z34 } from "zod";
|
|
1641
|
+
var RetryAttemptsSchema2 = z34.number().int().min(0).max(2).describe(
|
|
1550
1642
|
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
1551
1643
|
);
|
|
1552
|
-
var TaskSchema =
|
|
1644
|
+
var TaskSchema = z34.union([
|
|
1553
1645
|
LocalFileSchema.transform((file) => ({
|
|
1554
1646
|
consumer: {
|
|
1555
1647
|
code: {
|
|
@@ -1560,33 +1652,33 @@ var TaskSchema = z32.union([
|
|
|
1560
1652
|
},
|
|
1561
1653
|
retryAttempts: void 0
|
|
1562
1654
|
})),
|
|
1563
|
-
|
|
1655
|
+
z34.object({
|
|
1564
1656
|
consumer: FunctionSchema,
|
|
1565
1657
|
retryAttempts: RetryAttemptsSchema2.optional()
|
|
1566
1658
|
})
|
|
1567
1659
|
]);
|
|
1568
|
-
var TasksSchema =
|
|
1660
|
+
var TasksSchema = z34.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
1569
1661
|
|
|
1570
1662
|
// src/feature/test/schema.ts
|
|
1571
|
-
import { z as
|
|
1572
|
-
var TestsSchema =
|
|
1663
|
+
import { z as z35 } from "zod";
|
|
1664
|
+
var TestsSchema = z35.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
|
|
1573
1665
|
|
|
1574
1666
|
// src/feature/topic/schema.ts
|
|
1575
1667
|
import { kebabCase as kebabCase3 } from "change-case";
|
|
1576
|
-
import { z as
|
|
1577
|
-
var TopicNameSchema =
|
|
1578
|
-
var TopicsSchema =
|
|
1668
|
+
import { z as z36 } from "zod";
|
|
1669
|
+
var TopicNameSchema = z36.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
|
|
1670
|
+
var TopicsSchema = z36.array(TopicNameSchema).refine((topics) => {
|
|
1579
1671
|
return topics.length === new Set(topics).size;
|
|
1580
1672
|
}, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
|
|
1581
|
-
var SubscribersSchema =
|
|
1673
|
+
var SubscribersSchema = z36.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
|
|
1582
1674
|
|
|
1583
1675
|
// src/config/stack.ts
|
|
1584
1676
|
var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
|
|
1585
1677
|
var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
|
|
1586
1678
|
message: `Stack name can't be a reserved name.`
|
|
1587
1679
|
}).describe("Stack name.");
|
|
1588
|
-
var StackSchema =
|
|
1589
|
-
$schema:
|
|
1680
|
+
var StackSchema = z37.object({
|
|
1681
|
+
$schema: z37.string().optional(),
|
|
1590
1682
|
name: NameSchema,
|
|
1591
1683
|
depends: DependsSchema,
|
|
1592
1684
|
commands: CommandsSchema,
|
|
@@ -1653,13 +1745,13 @@ var readConfigWithStage = async (file, stage) => {
|
|
|
1653
1745
|
};
|
|
1654
1746
|
|
|
1655
1747
|
// src/config/load/validate.ts
|
|
1656
|
-
import { z as
|
|
1748
|
+
import { z as z38 } from "zod";
|
|
1657
1749
|
var validateConfig = async (schema, file, data) => {
|
|
1658
1750
|
try {
|
|
1659
1751
|
const result = await schema.parseAsync(data);
|
|
1660
1752
|
return result;
|
|
1661
1753
|
} catch (error) {
|
|
1662
|
-
if (error instanceof
|
|
1754
|
+
if (error instanceof z38.ZodError) {
|
|
1663
1755
|
throw new ConfigError(file, error, data);
|
|
1664
1756
|
}
|
|
1665
1757
|
throw error;
|
|
@@ -1854,11 +1946,11 @@ var authFeature = defineFeature({
|
|
|
1854
1946
|
name: "auth",
|
|
1855
1947
|
async onTypeGen(ctx) {
|
|
1856
1948
|
const gen = new TypeFile("@awsless/awsless");
|
|
1857
|
-
const
|
|
1949
|
+
const resources2 = new TypeObject(1);
|
|
1858
1950
|
for (const name of Object.keys(ctx.appConfig.defaults.auth)) {
|
|
1859
|
-
|
|
1951
|
+
resources2.addType(name, `{ readonly userPoolId: string, readonly clientId: string }`);
|
|
1860
1952
|
}
|
|
1861
|
-
gen.addInterface("AuthResources",
|
|
1953
|
+
gen.addInterface("AuthResources", resources2);
|
|
1862
1954
|
await ctx.write("auth.d.ts", gen, true);
|
|
1863
1955
|
},
|
|
1864
1956
|
// onStack(ctx) {
|
|
@@ -1988,7 +2080,7 @@ var authFeature = defineFeature({
|
|
|
1988
2080
|
deletionProtection: "ACTIVE"
|
|
1989
2081
|
},
|
|
1990
2082
|
{
|
|
1991
|
-
retainOnDelete:
|
|
2083
|
+
retainOnDelete: ctx.appConfig.removal === "retain",
|
|
1992
2084
|
import: ctx.import ? name : void 0
|
|
1993
2085
|
}
|
|
1994
2086
|
);
|
|
@@ -2037,16 +2129,16 @@ var cacheFeature = defineFeature({
|
|
|
2037
2129
|
name: "cache",
|
|
2038
2130
|
async onTypeGen(ctx) {
|
|
2039
2131
|
const gen = new TypeFile("@awsless/awsless");
|
|
2040
|
-
const
|
|
2132
|
+
const resources2 = new TypeObject(1);
|
|
2041
2133
|
for (const stack of ctx.stackConfigs) {
|
|
2042
|
-
const
|
|
2134
|
+
const resource = new TypeObject(2);
|
|
2043
2135
|
for (const name of Object.keys(stack.caches || {})) {
|
|
2044
|
-
|
|
2136
|
+
resource.addType(name, `Command`);
|
|
2045
2137
|
}
|
|
2046
|
-
|
|
2138
|
+
resources2.addType(stack.name, resource);
|
|
2047
2139
|
}
|
|
2048
2140
|
gen.addCode(typeGenCode);
|
|
2049
|
-
gen.addInterface("CacheResources",
|
|
2141
|
+
gen.addInterface("CacheResources", resources2);
|
|
2050
2142
|
await ctx.write("cache.d.ts", gen, true);
|
|
2051
2143
|
},
|
|
2052
2144
|
onStack(ctx) {
|
|
@@ -2281,13 +2373,13 @@ var configFeature = defineFeature({
|
|
|
2281
2373
|
name: "config",
|
|
2282
2374
|
async onTypeGen(ctx) {
|
|
2283
2375
|
const gen = new TypeFile("@awsless/awsless");
|
|
2284
|
-
const
|
|
2376
|
+
const resources2 = new TypeObject(0, false);
|
|
2285
2377
|
for (const stack of ctx.stackConfigs) {
|
|
2286
2378
|
for (const name of stack.configs ?? []) {
|
|
2287
|
-
|
|
2379
|
+
resources2.addConst(name, "string");
|
|
2288
2380
|
}
|
|
2289
2381
|
}
|
|
2290
|
-
gen.addInterface("ConfigResources",
|
|
2382
|
+
gen.addInterface("ConfigResources", resources2.toString());
|
|
2291
2383
|
await ctx.write("config.d.ts", gen, true);
|
|
2292
2384
|
},
|
|
2293
2385
|
onApp(ctx) {
|
|
@@ -2541,9 +2633,9 @@ var createHashFromFile = (file) => {
|
|
|
2541
2633
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
2542
2634
|
});
|
|
2543
2635
|
};
|
|
2544
|
-
var listAllFiles = async (
|
|
2636
|
+
var listAllFiles = async (list4) => {
|
|
2545
2637
|
const files = [];
|
|
2546
|
-
for (const entry of
|
|
2638
|
+
for (const entry of list4) {
|
|
2547
2639
|
const stat5 = await lstat2(entry);
|
|
2548
2640
|
if (stat5.isDirectory()) {
|
|
2549
2641
|
const dirents = await readdir(entry, {
|
|
@@ -2602,11 +2694,11 @@ import { readdir as readdir3 } from "node:fs/promises";
|
|
|
2602
2694
|
import { join as join9, relative as relative2 } from "node:path";
|
|
2603
2695
|
var zipBundle = async ({ directory }) => {
|
|
2604
2696
|
const zip = new JSZip2();
|
|
2605
|
-
const
|
|
2697
|
+
const list4 = await readdir3(directory, {
|
|
2606
2698
|
recursive: true,
|
|
2607
2699
|
withFileTypes: true
|
|
2608
2700
|
});
|
|
2609
|
-
for (const file of
|
|
2701
|
+
for (const file of list4) {
|
|
2610
2702
|
if (file.isFile()) {
|
|
2611
2703
|
const path = join9(file.path, file.name);
|
|
2612
2704
|
const rel = relative2(directory, path);
|
|
@@ -2747,11 +2839,11 @@ var createLambdaFunction = (group, ctx, ns, id, local) => {
|
|
|
2747
2839
|
role: role.name,
|
|
2748
2840
|
name: "lambda-policy",
|
|
2749
2841
|
policy: new Future(async (resolve) => {
|
|
2750
|
-
const
|
|
2842
|
+
const list4 = await resolveInputs(statements);
|
|
2751
2843
|
resolve(
|
|
2752
2844
|
JSON.stringify({
|
|
2753
2845
|
Version: "2012-10-17",
|
|
2754
|
-
Statement:
|
|
2846
|
+
Statement: list4.map((statement) => ({
|
|
2755
2847
|
Effect: pascalCase(statement.effect ?? "allow"),
|
|
2756
2848
|
Action: statement.actions,
|
|
2757
2849
|
Resource: statement.resources
|
|
@@ -3196,11 +3288,11 @@ var functionFeature = defineFeature({
|
|
|
3196
3288
|
name: "function",
|
|
3197
3289
|
async onTypeGen(ctx) {
|
|
3198
3290
|
const types2 = new TypeFile("@awsless/awsless");
|
|
3199
|
-
const
|
|
3291
|
+
const resources2 = new TypeObject(1);
|
|
3200
3292
|
const mocks = new TypeObject(1);
|
|
3201
3293
|
const mockResponses = new TypeObject(1);
|
|
3202
3294
|
for (const stack of ctx.stackConfigs) {
|
|
3203
|
-
const
|
|
3295
|
+
const resource = new TypeObject(2);
|
|
3204
3296
|
const mock = new TypeObject(2);
|
|
3205
3297
|
const mockResponse = new TypeObject(2);
|
|
3206
3298
|
for (const [name, local] of Object.entries(stack.functions || {})) {
|
|
@@ -3215,23 +3307,23 @@ var functionFeature = defineFeature({
|
|
|
3215
3307
|
if ("file" in local.code) {
|
|
3216
3308
|
const relFile = relative3(directories.types, local.code.file);
|
|
3217
3309
|
if (props.runtime === "container") {
|
|
3218
|
-
|
|
3310
|
+
resource.addType(name, `Invoke<'${funcName}', Func>`);
|
|
3219
3311
|
mock.addType(name, `MockBuilder<Func>`);
|
|
3220
3312
|
mockResponse.addType(name, `MockObject<Func>`);
|
|
3221
3313
|
} else {
|
|
3222
3314
|
types2.addImport(varName, relFile);
|
|
3223
|
-
|
|
3315
|
+
resource.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
|
|
3224
3316
|
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
3225
3317
|
mockResponse.addType(name, `MockObject<typeof ${varName}>`);
|
|
3226
3318
|
}
|
|
3227
3319
|
}
|
|
3228
3320
|
}
|
|
3229
3321
|
mocks.addType(stack.name, mock);
|
|
3230
|
-
|
|
3322
|
+
resources2.addType(stack.name, resource);
|
|
3231
3323
|
mockResponses.addType(stack.name, mockResponse);
|
|
3232
3324
|
}
|
|
3233
3325
|
types2.addCode(typeGenCode2);
|
|
3234
|
-
types2.addInterface("FunctionResources",
|
|
3326
|
+
types2.addInterface("FunctionResources", resources2);
|
|
3235
3327
|
types2.addInterface("FunctionMock", mocks);
|
|
3236
3328
|
types2.addInterface("FunctionMockResponse", mockResponses);
|
|
3237
3329
|
await ctx.write("function.d.ts", types2, true);
|
|
@@ -3508,11 +3600,11 @@ var queueFeature = defineFeature({
|
|
|
3508
3600
|
name: "queue",
|
|
3509
3601
|
async onTypeGen(ctx) {
|
|
3510
3602
|
const gen = new TypeFile("@awsless/awsless");
|
|
3511
|
-
const
|
|
3603
|
+
const resources2 = new TypeObject(1);
|
|
3512
3604
|
const mocks = new TypeObject(1);
|
|
3513
3605
|
const mockResponses = new TypeObject(1);
|
|
3514
3606
|
for (const stack of ctx.stackConfigs) {
|
|
3515
|
-
const
|
|
3607
|
+
const resource = new TypeObject(2);
|
|
3516
3608
|
const mock = new TypeObject(2);
|
|
3517
3609
|
const mockResponse = new TypeObject(2);
|
|
3518
3610
|
for (const [name, props] of Object.entries(stack.queues || {})) {
|
|
@@ -3527,16 +3619,16 @@ var queueFeature = defineFeature({
|
|
|
3527
3619
|
const relFile = relative4(directories.types, props.consumer.code.file);
|
|
3528
3620
|
gen.addImport(varName, relFile);
|
|
3529
3621
|
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
3530
|
-
|
|
3622
|
+
resource.addType(name, `Send<'${queueName}', typeof ${varName}>`);
|
|
3531
3623
|
mockResponse.addType(name, `MockObject<typeof ${varName}>`);
|
|
3532
3624
|
}
|
|
3533
3625
|
}
|
|
3534
3626
|
mocks.addType(stack.name, mock);
|
|
3535
|
-
|
|
3627
|
+
resources2.addType(stack.name, resource);
|
|
3536
3628
|
mockResponses.addType(stack.name, mockResponse);
|
|
3537
3629
|
}
|
|
3538
3630
|
gen.addCode(typeGenCode3);
|
|
3539
|
-
gen.addInterface("QueueResources",
|
|
3631
|
+
gen.addInterface("QueueResources", resources2);
|
|
3540
3632
|
gen.addInterface("QueueMock", mocks);
|
|
3541
3633
|
gen.addInterface("QueueMockResponse", mockResponses);
|
|
3542
3634
|
await ctx.write("queue.d.ts", gen, true);
|
|
@@ -3784,11 +3876,11 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
|
|
|
3784
3876
|
role: role.name,
|
|
3785
3877
|
name: "lambda-policy",
|
|
3786
3878
|
policy: new Future2(async (resolve) => {
|
|
3787
|
-
const
|
|
3879
|
+
const list4 = await resolveInputs2(statements);
|
|
3788
3880
|
resolve(
|
|
3789
3881
|
JSON.stringify({
|
|
3790
3882
|
Version: "2012-10-17",
|
|
3791
|
-
Statement:
|
|
3883
|
+
Statement: list4.map((statement) => ({
|
|
3792
3884
|
Effect: pascalCase2(statement.effect ?? "allow"),
|
|
3793
3885
|
Action: statement.actions,
|
|
3794
3886
|
Resource: statement.resources
|
|
@@ -3925,15 +4017,15 @@ var rpcFeature = defineFeature({
|
|
|
3925
4017
|
}
|
|
3926
4018
|
for (const stack of ctx.stackConfigs) {
|
|
3927
4019
|
for (const [id, queries] of Object.entries(stack.rpc ?? {})) {
|
|
3928
|
-
const
|
|
3929
|
-
if (!
|
|
4020
|
+
const list4 = names[id];
|
|
4021
|
+
if (!list4) {
|
|
3930
4022
|
throw new FileError(stack.file, `The RPC API for "${id}" isn't defined on app level.`);
|
|
3931
4023
|
}
|
|
3932
4024
|
for (const [name, props] of Object.entries(queries ?? {})) {
|
|
3933
|
-
if (
|
|
4025
|
+
if (list4.has(name)) {
|
|
3934
4026
|
throw new FileError(stack.file, `Duplicate RPC API function "${id}.${name}"`);
|
|
3935
4027
|
} else {
|
|
3936
|
-
|
|
4028
|
+
list4.add(name);
|
|
3937
4029
|
}
|
|
3938
4030
|
const timeout = toSeconds5(props.timeout ?? ctx.appConfig.defaults.function.timeout);
|
|
3939
4031
|
const maxTimeout = toSeconds5(ctx.appConfig.defaults.rpc[id].timeout) * 0.8;
|
|
@@ -4017,6 +4109,15 @@ var rpcFeature = defineFeature({
|
|
|
4017
4109
|
const authGroup = new Group13(group, "auth", "authorizer");
|
|
4018
4110
|
const auth2 = createLambdaFunction(authGroup, ctx, "rpc", `${id}-auth`, props.auth);
|
|
4019
4111
|
result.setEnvironment("AUTH", auth2.name);
|
|
4112
|
+
new UpdateFunctionCode(group, "update", {
|
|
4113
|
+
version: auth2.code.sourceHash,
|
|
4114
|
+
functionName: result.lambda.functionName,
|
|
4115
|
+
architectures: result.lambda.architectures,
|
|
4116
|
+
s3Bucket: result.lambda.s3Bucket,
|
|
4117
|
+
s3Key: result.lambda.s3Key,
|
|
4118
|
+
s3ObjectVersion: result.lambda.s3ObjectVersion,
|
|
4119
|
+
imageUri: result.lambda.imageUri
|
|
4120
|
+
});
|
|
4020
4121
|
}
|
|
4021
4122
|
const permission = new $13.aws.lambda.Permission(group, "permission", {
|
|
4022
4123
|
principal: "cloudfront.amazonaws.com",
|
|
@@ -4191,16 +4292,16 @@ var searchFeature = defineFeature({
|
|
|
4191
4292
|
name: "search",
|
|
4192
4293
|
async onTypeGen(ctx) {
|
|
4193
4294
|
const gen = new TypeFile("@awsless/awsless");
|
|
4194
|
-
const
|
|
4295
|
+
const resources2 = new TypeObject(1);
|
|
4195
4296
|
for (const stack of ctx.stackConfigs) {
|
|
4196
|
-
const
|
|
4297
|
+
const list4 = new TypeObject(2);
|
|
4197
4298
|
for (const id of Object.keys(stack.searchs ?? {})) {
|
|
4198
|
-
|
|
4299
|
+
list4.addType(id, `Search`);
|
|
4199
4300
|
}
|
|
4200
|
-
|
|
4301
|
+
resources2.addType(stack.name, list4);
|
|
4201
4302
|
}
|
|
4202
4303
|
gen.addCode(typeGenCode4);
|
|
4203
|
-
gen.addInterface("SearchResources",
|
|
4304
|
+
gen.addInterface("SearchResources", resources2);
|
|
4204
4305
|
await ctx.write("search.d.ts", gen, true);
|
|
4205
4306
|
},
|
|
4206
4307
|
onStack(ctx) {
|
|
@@ -4313,6 +4414,8 @@ var execCommand = async ({ cwd, command }) => {
|
|
|
4313
4414
|
};
|
|
4314
4415
|
|
|
4315
4416
|
// src/feature/site/index.ts
|
|
4417
|
+
import { createHash as createHash4 } from "crypto";
|
|
4418
|
+
import { Future as Future3 } from "@awsless/formation";
|
|
4316
4419
|
var siteFeature = defineFeature({
|
|
4317
4420
|
name: "site",
|
|
4318
4421
|
onStack(ctx) {
|
|
@@ -4347,9 +4450,7 @@ var siteFeature = defineFeature({
|
|
|
4347
4450
|
const versions = [];
|
|
4348
4451
|
if (props.ssr) {
|
|
4349
4452
|
const result = createLambdaFunction(group, ctx, `site`, id, props.ssr);
|
|
4350
|
-
|
|
4351
|
-
versions.push(result.code.versionId);
|
|
4352
|
-
}
|
|
4453
|
+
versions.push(result.code.sourceHash);
|
|
4353
4454
|
ctx.onBind((name2, value) => {
|
|
4354
4455
|
result.setEnvironment(name2, value);
|
|
4355
4456
|
});
|
|
@@ -4431,7 +4532,7 @@ var siteFeature = defineFeature({
|
|
|
4431
4532
|
ctx.onReady(() => {
|
|
4432
4533
|
if (typeof props.static === "string") {
|
|
4433
4534
|
const files = glob2.sync("**", {
|
|
4434
|
-
cwd: props.static,
|
|
4535
|
+
cwd: join11(directories.root, props.static),
|
|
4435
4536
|
nodir: true
|
|
4436
4537
|
});
|
|
4437
4538
|
for (const file of files) {
|
|
@@ -4440,11 +4541,11 @@ var siteFeature = defineFeature({
|
|
|
4440
4541
|
key: file,
|
|
4441
4542
|
cacheControl: getCacheControl(file),
|
|
4442
4543
|
contentType: getContentType(file),
|
|
4443
|
-
source: join11(props.static, file),
|
|
4444
|
-
sourceHash: $hash(join11(props.static, file))
|
|
4544
|
+
source: join11(directories.root, props.static, file),
|
|
4545
|
+
sourceHash: $hash(join11(directories.root, props.static, file))
|
|
4445
4546
|
});
|
|
4446
4547
|
versions.push(object.key);
|
|
4447
|
-
versions.push(object.
|
|
4548
|
+
versions.push(object.sourceHash);
|
|
4448
4549
|
}
|
|
4449
4550
|
}
|
|
4450
4551
|
});
|
|
@@ -4619,6 +4720,17 @@ var siteFeature = defineFeature({
|
|
|
4619
4720
|
cachedMethods: ["GET", "HEAD"]
|
|
4620
4721
|
}
|
|
4621
4722
|
});
|
|
4723
|
+
new Invalidation(group, "invalidate", {
|
|
4724
|
+
distributionId: distribution.id,
|
|
4725
|
+
paths: ["/*"],
|
|
4726
|
+
version: new Future3((resolve) => {
|
|
4727
|
+
$combine(...versions).then((versions2) => {
|
|
4728
|
+
const combined = versions2.filter((v) => !!v).sort().join(",");
|
|
4729
|
+
const version = createHash4("sha1").update(combined).digest("hex");
|
|
4730
|
+
resolve(version);
|
|
4731
|
+
});
|
|
4732
|
+
})
|
|
4733
|
+
});
|
|
4622
4734
|
if (props.static) {
|
|
4623
4735
|
new $15.aws.s3.BucketPolicy(
|
|
4624
4736
|
group,
|
|
@@ -4690,9 +4802,9 @@ var storeFeature = defineFeature({
|
|
|
4690
4802
|
name: "store",
|
|
4691
4803
|
async onTypeGen(ctx) {
|
|
4692
4804
|
const gen = new TypeFile("@awsless/awsless");
|
|
4693
|
-
const
|
|
4805
|
+
const resources2 = new TypeObject(1);
|
|
4694
4806
|
for (const stack of ctx.stackConfigs) {
|
|
4695
|
-
const
|
|
4807
|
+
const list4 = new TypeObject(2);
|
|
4696
4808
|
for (const id of Object.keys(stack.stores ?? {})) {
|
|
4697
4809
|
const storeName = formatLocalResourceName({
|
|
4698
4810
|
appName: ctx.appConfig.name,
|
|
@@ -4700,12 +4812,12 @@ var storeFeature = defineFeature({
|
|
|
4700
4812
|
resourceType: "store",
|
|
4701
4813
|
resourceName: id
|
|
4702
4814
|
});
|
|
4703
|
-
|
|
4815
|
+
list4.addType(id, `Store<'${storeName}'>`);
|
|
4704
4816
|
}
|
|
4705
|
-
|
|
4817
|
+
resources2.addType(stack.name, list4);
|
|
4706
4818
|
}
|
|
4707
4819
|
gen.addCode(typeGenCode5);
|
|
4708
|
-
gen.addInterface("StoreResources",
|
|
4820
|
+
gen.addInterface("StoreResources", resources2);
|
|
4709
4821
|
await ctx.write("store.d.ts", gen, true);
|
|
4710
4822
|
},
|
|
4711
4823
|
onApp(ctx) {
|
|
@@ -4829,9 +4941,9 @@ var tableFeature = defineFeature({
|
|
|
4829
4941
|
name: "table",
|
|
4830
4942
|
async onTypeGen(ctx) {
|
|
4831
4943
|
const gen = new TypeFile("@awsless/awsless");
|
|
4832
|
-
const
|
|
4944
|
+
const resources2 = new TypeObject(1);
|
|
4833
4945
|
for (const stack of ctx.stackConfigs) {
|
|
4834
|
-
const
|
|
4946
|
+
const list4 = new TypeObject(2);
|
|
4835
4947
|
for (const name of Object.keys(stack.tables || {})) {
|
|
4836
4948
|
const tableName = formatLocalResourceName({
|
|
4837
4949
|
appName: ctx.appConfig.name,
|
|
@@ -4839,11 +4951,11 @@ var tableFeature = defineFeature({
|
|
|
4839
4951
|
resourceType: "table",
|
|
4840
4952
|
resourceName: name
|
|
4841
4953
|
});
|
|
4842
|
-
|
|
4954
|
+
list4.addType(name, `'${tableName}'`);
|
|
4843
4955
|
}
|
|
4844
|
-
|
|
4956
|
+
resources2.addType(stack.name, list4);
|
|
4845
4957
|
}
|
|
4846
|
-
gen.addInterface("TableResources",
|
|
4958
|
+
gen.addInterface("TableResources", resources2);
|
|
4847
4959
|
await ctx.write("table.d.ts", gen, true);
|
|
4848
4960
|
},
|
|
4849
4961
|
onApp(ctx) {
|
|
@@ -5028,11 +5140,11 @@ var taskFeature = defineFeature({
|
|
|
5028
5140
|
name: "task",
|
|
5029
5141
|
async onTypeGen(ctx) {
|
|
5030
5142
|
const types2 = new TypeFile("@awsless/awsless");
|
|
5031
|
-
const
|
|
5143
|
+
const resources2 = new TypeObject(1);
|
|
5032
5144
|
const mocks = new TypeObject(1);
|
|
5033
5145
|
const mockResponses = new TypeObject(1);
|
|
5034
5146
|
for (const stack of ctx.stackConfigs) {
|
|
5035
|
-
const
|
|
5147
|
+
const resource = new TypeObject(2);
|
|
5036
5148
|
const mock = new TypeObject(2);
|
|
5037
5149
|
const mockResponse = new TypeObject(2);
|
|
5038
5150
|
for (const [name, props] of Object.entries(stack.tasks || {})) {
|
|
@@ -5046,17 +5158,17 @@ var taskFeature = defineFeature({
|
|
|
5046
5158
|
if ("file" in props.consumer.code) {
|
|
5047
5159
|
const relFile = relative6(directories.types, props.consumer.code.file);
|
|
5048
5160
|
types2.addImport(varName, relFile);
|
|
5049
|
-
|
|
5161
|
+
resource.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
|
|
5050
5162
|
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
5051
5163
|
mockResponse.addType(name, `MockObject<typeof ${varName}>`);
|
|
5052
5164
|
}
|
|
5053
5165
|
}
|
|
5054
5166
|
mocks.addType(stack.name, mock);
|
|
5055
|
-
|
|
5167
|
+
resources2.addType(stack.name, resource);
|
|
5056
5168
|
mockResponses.addType(stack.name, mockResponse);
|
|
5057
5169
|
}
|
|
5058
5170
|
types2.addCode(typeGenCode6);
|
|
5059
|
-
types2.addInterface("TaskResources",
|
|
5171
|
+
types2.addInterface("TaskResources", resources2);
|
|
5060
5172
|
types2.addInterface("TaskMock", mocks);
|
|
5061
5173
|
types2.addInterface("TaskMockResponse", mockResponses);
|
|
5062
5174
|
await ctx.write("task.d.ts", types2, true);
|
|
@@ -5096,7 +5208,7 @@ var topicFeature = defineFeature({
|
|
|
5096
5208
|
name: "topic",
|
|
5097
5209
|
async onTypeGen(ctx) {
|
|
5098
5210
|
const gen = new TypeFile("@awsless/awsless");
|
|
5099
|
-
const
|
|
5211
|
+
const resources2 = new TypeObject(1);
|
|
5100
5212
|
const mocks = new TypeObject(1);
|
|
5101
5213
|
const mockResponses = new TypeObject(1);
|
|
5102
5214
|
for (const stack of ctx.stackConfigs) {
|
|
@@ -5107,12 +5219,12 @@ var topicFeature = defineFeature({
|
|
|
5107
5219
|
resourceName: topic
|
|
5108
5220
|
});
|
|
5109
5221
|
mockResponses.addType(topic, "Mock");
|
|
5110
|
-
|
|
5222
|
+
resources2.addType(topic, `Publish<'${name}'>`);
|
|
5111
5223
|
mocks.addType(topic, `MockBuilder`);
|
|
5112
5224
|
}
|
|
5113
5225
|
}
|
|
5114
5226
|
gen.addCode(typeGenCode7);
|
|
5115
|
-
gen.addInterface("TopicResources",
|
|
5227
|
+
gen.addInterface("TopicResources", resources2);
|
|
5116
5228
|
gen.addInterface("TopicMock", mocks);
|
|
5117
5229
|
gen.addInterface("TopicMockResponse", mockResponses);
|
|
5118
5230
|
await ctx.write("topic.d.ts", gen, true);
|
|
@@ -5282,7 +5394,7 @@ var alertFeature = defineFeature({
|
|
|
5282
5394
|
name: "alert",
|
|
5283
5395
|
async onTypeGen(ctx) {
|
|
5284
5396
|
const gen = new TypeFile("@awsless/awsless");
|
|
5285
|
-
const
|
|
5397
|
+
const resources2 = new TypeObject(1);
|
|
5286
5398
|
const mocks = new TypeObject(1);
|
|
5287
5399
|
const mockResponses = new TypeObject(1);
|
|
5288
5400
|
for (const alert of Object.keys(ctx.appConfig.defaults.alerts ?? {})) {
|
|
@@ -5291,12 +5403,12 @@ var alertFeature = defineFeature({
|
|
|
5291
5403
|
resourceType: "alert",
|
|
5292
5404
|
resourceName: alert
|
|
5293
5405
|
});
|
|
5294
|
-
|
|
5406
|
+
resources2.addType(alert, `Alert<'${name}'>`);
|
|
5295
5407
|
mockResponses.addType(alert, "Mock");
|
|
5296
5408
|
mocks.addType(alert, `MockBuilder`);
|
|
5297
5409
|
}
|
|
5298
5410
|
gen.addCode(typeGenCode8);
|
|
5299
|
-
gen.addInterface("AlertResources",
|
|
5411
|
+
gen.addInterface("AlertResources", resources2);
|
|
5300
5412
|
gen.addInterface("AlertMock", mocks);
|
|
5301
5413
|
gen.addInterface("AlertMockResponse", mockResponses);
|
|
5302
5414
|
await ctx.write("alert.d.ts", gen, true);
|
|
@@ -5801,7 +5913,7 @@ var createApp = (props) => {
|
|
|
5801
5913
|
region: props.appConfig.region,
|
|
5802
5914
|
appName: props.appConfig.name
|
|
5803
5915
|
});
|
|
5804
|
-
const
|
|
5916
|
+
const commands7 = [];
|
|
5805
5917
|
const configs = /* @__PURE__ */ new Set();
|
|
5806
5918
|
const tests = [];
|
|
5807
5919
|
const builders = [];
|
|
@@ -5861,7 +5973,7 @@ var createApp = (props) => {
|
|
|
5861
5973
|
});
|
|
5862
5974
|
},
|
|
5863
5975
|
registerCommand(command) {
|
|
5864
|
-
|
|
5976
|
+
commands7.push(command);
|
|
5865
5977
|
},
|
|
5866
5978
|
registerDomainZone(zone) {
|
|
5867
5979
|
domainZones.push(zone);
|
|
@@ -5953,7 +6065,7 @@ var createApp = (props) => {
|
|
|
5953
6065
|
configs.add(name);
|
|
5954
6066
|
},
|
|
5955
6067
|
registerCommand(command) {
|
|
5956
|
-
|
|
6068
|
+
commands7.push(command);
|
|
5957
6069
|
},
|
|
5958
6070
|
registerDomainZone(zone) {
|
|
5959
6071
|
domainZones.push(zone);
|
|
@@ -6041,7 +6153,7 @@ var createApp = (props) => {
|
|
|
6041
6153
|
shared,
|
|
6042
6154
|
configs,
|
|
6043
6155
|
builders,
|
|
6044
|
-
commands:
|
|
6156
|
+
commands: commands7
|
|
6045
6157
|
// deploymentLine,
|
|
6046
6158
|
};
|
|
6047
6159
|
};
|
|
@@ -6304,7 +6416,7 @@ import { join as join14 } from "path";
|
|
|
6304
6416
|
import wildstring3 from "wildstring";
|
|
6305
6417
|
|
|
6306
6418
|
// src/build/__fingerprint.ts
|
|
6307
|
-
import { createHash as
|
|
6419
|
+
import { createHash as createHash5 } from "crypto";
|
|
6308
6420
|
import { readdir as readdir4, readFile as readFile4, stat as stat4 } from "fs/promises";
|
|
6309
6421
|
import { basename as basename4, dirname as dirname8, extname as extname3, join as join12 } from "path";
|
|
6310
6422
|
import parseStaticImports from "parse-static-imports";
|
|
@@ -6315,7 +6427,7 @@ var generateFileHashes = async (file, hashes) => {
|
|
|
6315
6427
|
}
|
|
6316
6428
|
const code = await readModuleFile(file);
|
|
6317
6429
|
const deps = await findDependencies(file, code);
|
|
6318
|
-
const hash =
|
|
6430
|
+
const hash = createHash5("sha1").update(code).digest();
|
|
6319
6431
|
hashes.set(file, hash);
|
|
6320
6432
|
for (const dep of deps) {
|
|
6321
6433
|
if (dep.startsWith("/")) {
|
|
@@ -6332,7 +6444,7 @@ var fingerprintFromDirectory = async (dir) => {
|
|
|
6332
6444
|
}
|
|
6333
6445
|
}
|
|
6334
6446
|
const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
|
|
6335
|
-
return
|
|
6447
|
+
return createHash5("sha1").update(merge2).digest("hex");
|
|
6336
6448
|
};
|
|
6337
6449
|
var readModuleFile = (file) => {
|
|
6338
6450
|
if (file.endsWith(".js")) {
|
|
@@ -6798,7 +6910,7 @@ import { log as log10, note as note3 } from "@clack/prompts";
|
|
|
6798
6910
|
import { constantCase as constantCase12 } from "change-case";
|
|
6799
6911
|
import { spawn } from "child_process";
|
|
6800
6912
|
var bind = (program2) => {
|
|
6801
|
-
program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (
|
|
6913
|
+
program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands7 = [], opts) => {
|
|
6802
6914
|
await layout("bind", async ({ appConfig, stackConfigs }) => {
|
|
6803
6915
|
const region = appConfig.region;
|
|
6804
6916
|
const profile = appConfig.profile;
|
|
@@ -6829,10 +6941,10 @@ var bind = (program2) => {
|
|
|
6829
6941
|
if (configList.length ?? 0 > 0) {
|
|
6830
6942
|
note3(wrap(configList.map((v) => color.label(constantCase12(v)))), "Bind Config");
|
|
6831
6943
|
}
|
|
6832
|
-
if (
|
|
6944
|
+
if (commands7.length === 0) {
|
|
6833
6945
|
return "No command to execute.";
|
|
6834
6946
|
}
|
|
6835
|
-
const command =
|
|
6947
|
+
const command = commands7.join(" ");
|
|
6836
6948
|
const freshCred = await credentials();
|
|
6837
6949
|
spawn(command, {
|
|
6838
6950
|
env: {
|
|
@@ -6943,13 +7055,13 @@ var dev = (program2) => {
|
|
|
6943
7055
|
});
|
|
6944
7056
|
};
|
|
6945
7057
|
|
|
6946
|
-
// src/cli/command/
|
|
7058
|
+
// src/cli/command/resources.ts
|
|
6947
7059
|
import { log as log12 } from "@clack/prompts";
|
|
6948
7060
|
import chalk6 from "chalk";
|
|
6949
7061
|
import wildstring5 from "wildstring";
|
|
6950
|
-
var
|
|
6951
|
-
program2.command("
|
|
6952
|
-
await layout("
|
|
7062
|
+
var resources = (program2) => {
|
|
7063
|
+
program2.command("resources").argument("[stacks...]", "Optionally filter stack resources to list").description(`List all defined resources in your app`).action(async (filters) => {
|
|
7064
|
+
await layout("resources", async ({ appConfig, stackConfigs }) => {
|
|
6953
7065
|
const region = appConfig.region;
|
|
6954
7066
|
const credentials = getCredentials(appConfig.profile);
|
|
6955
7067
|
const accountId = await getAccountId(credentials, region);
|
|
@@ -6968,25 +7080,18 @@ var list3 = (program2) => {
|
|
|
6968
7080
|
}
|
|
6969
7081
|
log12.step(chalk6.magenta(stack.name));
|
|
6970
7082
|
line("");
|
|
6971
|
-
for (const
|
|
6972
|
-
line(formatResource(stack,
|
|
7083
|
+
for (const resource of stack.resources) {
|
|
7084
|
+
line(formatResource(stack, resource.$.urn));
|
|
6973
7085
|
}
|
|
6974
7086
|
}
|
|
6975
7087
|
});
|
|
6976
7088
|
});
|
|
6977
7089
|
};
|
|
6978
7090
|
|
|
6979
|
-
// src/cli/command/resource/index.ts
|
|
6980
|
-
var commands4 = [list3];
|
|
6981
|
-
var resource = (program2) => {
|
|
6982
|
-
const command = program2.command("resource").description(`Manage app resources`);
|
|
6983
|
-
commands4.forEach((cb) => cb(command));
|
|
6984
|
-
};
|
|
6985
|
-
|
|
6986
7091
|
// src/cli/command/run.ts
|
|
6987
7092
|
import { DynamoDBClient, dynamoDBClient } from "@awsless/dynamodb";
|
|
6988
7093
|
import { iotClient, IoTDataPlaneClient } from "@awsless/iot";
|
|
6989
|
-
import { LambdaClient, lambdaClient } from "@awsless/lambda";
|
|
7094
|
+
import { LambdaClient as LambdaClient2, lambdaClient } from "@awsless/lambda";
|
|
6990
7095
|
import { S3Client as S3Client2, s3Client } from "@awsless/s3";
|
|
6991
7096
|
import { SNSClient, snsClient } from "@awsless/sns";
|
|
6992
7097
|
import { SQSClient, sqsClient } from "@awsless/sqs";
|
|
@@ -6998,17 +7103,17 @@ var run = (program2) => {
|
|
|
6998
7103
|
const region = appConfig.region;
|
|
6999
7104
|
const credentials = getCredentials(appConfig.profile);
|
|
7000
7105
|
const accountId = await getAccountId(credentials, region);
|
|
7001
|
-
const { commands:
|
|
7106
|
+
const { commands: commands7 } = createApp({ appConfig, stackConfigs, accountId });
|
|
7002
7107
|
let command;
|
|
7003
7108
|
if (selected) {
|
|
7004
|
-
command =
|
|
7109
|
+
command = commands7.find((cmd) => {
|
|
7005
7110
|
return cmd.name === selected;
|
|
7006
7111
|
});
|
|
7007
7112
|
} else {
|
|
7008
7113
|
const selected2 = await select2({
|
|
7009
7114
|
message: "Pick the command you want to run:",
|
|
7010
|
-
initialValue:
|
|
7011
|
-
options:
|
|
7115
|
+
initialValue: commands7[0],
|
|
7116
|
+
options: commands7.map((cmd) => ({
|
|
7012
7117
|
value: cmd,
|
|
7013
7118
|
label: cmd.name,
|
|
7014
7119
|
hint: cmd.description
|
|
@@ -7033,7 +7138,7 @@ var run = (program2) => {
|
|
|
7033
7138
|
throw new ExpectedError(`No "${command.handler}" handler found.`);
|
|
7034
7139
|
}
|
|
7035
7140
|
dynamoDBClient.set(new DynamoDBClient({ region, credentials }));
|
|
7036
|
-
lambdaClient.set(new
|
|
7141
|
+
lambdaClient.set(new LambdaClient2({ region, credentials }));
|
|
7037
7142
|
snsClient.set(new SNSClient({ region, credentials }));
|
|
7038
7143
|
iotClient.set(new IoTDataPlaneClient({ region, credentials }));
|
|
7039
7144
|
sqsClient.set(new SQSClient({ region, credentials }));
|
|
@@ -7121,10 +7226,10 @@ var unlock = (program2) => {
|
|
|
7121
7226
|
};
|
|
7122
7227
|
|
|
7123
7228
|
// src/cli/command/state/index.ts
|
|
7124
|
-
var
|
|
7229
|
+
var commands4 = [pull, push, unlock];
|
|
7125
7230
|
var state = (program2) => {
|
|
7126
7231
|
const command = program2.command("state").description(`Manage app state`);
|
|
7127
|
-
|
|
7232
|
+
commands4.forEach((cb) => cb(command));
|
|
7128
7233
|
};
|
|
7129
7234
|
|
|
7130
7235
|
// src/cli/command/test.ts
|
|
@@ -7156,7 +7261,7 @@ var types = (program2) => {
|
|
|
7156
7261
|
|
|
7157
7262
|
// src/cli/command/domain/list.ts
|
|
7158
7263
|
import { log as log13 } from "@clack/prompts";
|
|
7159
|
-
var
|
|
7264
|
+
var list3 = (program2) => {
|
|
7160
7265
|
program2.command("list").description("List all domains").action(async () => {
|
|
7161
7266
|
await layout("domain list", async ({ appConfig, stackConfigs }) => {
|
|
7162
7267
|
const region = appConfig.region;
|
|
@@ -7232,14 +7337,14 @@ var deploy2 = (program2) => {
|
|
|
7232
7337
|
};
|
|
7233
7338
|
|
|
7234
7339
|
// src/cli/command/domain/index.ts
|
|
7235
|
-
var
|
|
7340
|
+
var commands5 = [
|
|
7236
7341
|
//
|
|
7237
7342
|
deploy2,
|
|
7238
|
-
|
|
7343
|
+
list3
|
|
7239
7344
|
];
|
|
7240
7345
|
var domain = (program2) => {
|
|
7241
7346
|
const command = program2.command("domain").description(`Manage domains`);
|
|
7242
|
-
|
|
7347
|
+
commands5.forEach((cb) => cb(command));
|
|
7243
7348
|
};
|
|
7244
7349
|
|
|
7245
7350
|
// src/cli/command/logs.ts
|
|
@@ -7267,9 +7372,9 @@ var logs = (program2) => {
|
|
|
7267
7372
|
const logGroupArns = [];
|
|
7268
7373
|
for (const stack of app.stacks) {
|
|
7269
7374
|
if (filters.find((f) => wildstring6.match(f, stack.name))) {
|
|
7270
|
-
for (const
|
|
7271
|
-
if (
|
|
7272
|
-
const logGroup =
|
|
7375
|
+
for (const resource of stack.resources) {
|
|
7376
|
+
if (resource.$.type === "aws_cloudwatch_log_group") {
|
|
7377
|
+
const logGroup = resource;
|
|
7273
7378
|
logGroupArns.push(await logGroup.arn);
|
|
7274
7379
|
}
|
|
7275
7380
|
}
|
|
@@ -7360,10 +7465,10 @@ var parseJsonLog = (message) => {
|
|
|
7360
7465
|
json3 = JSON.parse(message);
|
|
7361
7466
|
} catch (error) {
|
|
7362
7467
|
}
|
|
7363
|
-
if ("level" in json3 && typeof json3.level === "string" && "
|
|
7468
|
+
if ("level" in json3 && typeof json3.level === "string" && "timestamp" in json3 && typeof json3.timestamp === "string" && "message" in json3) {
|
|
7364
7469
|
return {
|
|
7365
7470
|
level: json3.level,
|
|
7366
|
-
message: json3.message,
|
|
7471
|
+
message: typeof json3.message === "string" ? json3.message : JSON.stringify(json3.message, void 0, 2),
|
|
7367
7472
|
date: new Date(json3.timestamp)
|
|
7368
7473
|
};
|
|
7369
7474
|
}
|
|
@@ -7381,7 +7486,7 @@ var parseJsonLog = (message) => {
|
|
|
7381
7486
|
};
|
|
7382
7487
|
|
|
7383
7488
|
// src/cli/command/index.ts
|
|
7384
|
-
var
|
|
7489
|
+
var commands6 = [
|
|
7385
7490
|
bootstrap,
|
|
7386
7491
|
types,
|
|
7387
7492
|
build2,
|
|
@@ -7395,7 +7500,7 @@ var commands7 = [
|
|
|
7395
7500
|
auth,
|
|
7396
7501
|
domain,
|
|
7397
7502
|
state,
|
|
7398
|
-
|
|
7503
|
+
resources,
|
|
7399
7504
|
config,
|
|
7400
7505
|
test
|
|
7401
7506
|
];
|
|
@@ -7420,7 +7525,7 @@ program.on("option:skip-prompt", () => {
|
|
|
7420
7525
|
program.on("option:no-cache", () => {
|
|
7421
7526
|
process.env.NO_CACHE = program.opts().noCache ? "1" : void 0;
|
|
7422
7527
|
});
|
|
7423
|
-
|
|
7528
|
+
commands6.forEach((fn) => fn(program));
|
|
7424
7529
|
|
|
7425
7530
|
// src/bin.ts
|
|
7426
7531
|
program.parse(process.argv);
|