@awsless/awsless 0.0.214 → 0.0.215
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 +35 -30
- package/dist/build-json-schema.js +35 -17
- package/dist/stack.json +1 -1
- package/package.json +8 -8
package/dist/bin.js
CHANGED
|
@@ -611,7 +611,7 @@ var AppSchema = z15.object({
|
|
|
611
611
|
import { glob } from "glob";
|
|
612
612
|
|
|
613
613
|
// src/config/stack.ts
|
|
614
|
-
import { z as
|
|
614
|
+
import { z as z29 } from "zod";
|
|
615
615
|
|
|
616
616
|
// src/feature/on-failure/schema.ts
|
|
617
617
|
var OnFailureSchema = FunctionSchema.optional().describe(
|
|
@@ -1035,13 +1035,30 @@ var SitesSchema = z27.record(
|
|
|
1035
1035
|
})
|
|
1036
1036
|
).optional().describe("Define the sites in your stack.");
|
|
1037
1037
|
|
|
1038
|
+
// src/feature/task/schema.ts
|
|
1039
|
+
import { z as z28 } from "zod";
|
|
1040
|
+
var RetryAttemptsSchema2 = z28.number().int().min(0).max(2).describe(
|
|
1041
|
+
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
1042
|
+
);
|
|
1043
|
+
var TaskSchema = z28.union([
|
|
1044
|
+
LocalFileSchema.transform((file) => ({
|
|
1045
|
+
consumer: { file },
|
|
1046
|
+
retryAttempts: void 0
|
|
1047
|
+
})),
|
|
1048
|
+
z28.object({
|
|
1049
|
+
consumer: FunctionSchema,
|
|
1050
|
+
retryAttempts: RetryAttemptsSchema2.optional()
|
|
1051
|
+
})
|
|
1052
|
+
]);
|
|
1053
|
+
var TasksSchema = z28.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
1054
|
+
|
|
1038
1055
|
// src/config/stack.ts
|
|
1039
1056
|
var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
|
|
1040
1057
|
var NameSchema = ResourceIdSchema.refine((name) => !["base"].includes(name), {
|
|
1041
1058
|
message: `Stack name can't be a reserved name.`
|
|
1042
1059
|
}).describe("Stack name.");
|
|
1043
|
-
var StackSchema =
|
|
1044
|
-
$schema:
|
|
1060
|
+
var StackSchema = z29.object({
|
|
1061
|
+
$schema: z29.string().optional(),
|
|
1045
1062
|
name: NameSchema,
|
|
1046
1063
|
depends: DependsSchema,
|
|
1047
1064
|
onFailure: OnFailureSchema,
|
|
@@ -1055,6 +1072,7 @@ var StackSchema = z28.object({
|
|
|
1055
1072
|
topics: TopicsSchema,
|
|
1056
1073
|
subscribers: SubscribersSchema,
|
|
1057
1074
|
functions: FunctionsSchema,
|
|
1075
|
+
tasks: TasksSchema,
|
|
1058
1076
|
tables: TablesSchema,
|
|
1059
1077
|
stores: StoresSchema,
|
|
1060
1078
|
queues: QueuesSchema,
|
|
@@ -1119,13 +1137,13 @@ var readConfigWithStage = async (file, stage) => {
|
|
|
1119
1137
|
};
|
|
1120
1138
|
|
|
1121
1139
|
// src/config/load/validate.ts
|
|
1122
|
-
import { z as
|
|
1140
|
+
import { z as z30 } from "zod";
|
|
1123
1141
|
var validateConfig = async (schema, file, data) => {
|
|
1124
1142
|
try {
|
|
1125
1143
|
const result = await schema.parseAsync(data);
|
|
1126
1144
|
return result;
|
|
1127
1145
|
} catch (error) {
|
|
1128
|
-
if (error instanceof
|
|
1146
|
+
if (error instanceof z30.ZodError) {
|
|
1129
1147
|
throw new ConfigError(file, error, data);
|
|
1130
1148
|
}
|
|
1131
1149
|
throw error;
|
|
@@ -2051,17 +2069,6 @@ var build = (type, name, builder) => {
|
|
|
2051
2069
|
});
|
|
2052
2070
|
};
|
|
2053
2071
|
|
|
2054
|
-
// src/feature/on-failure/util.ts
|
|
2055
|
-
var getGlobalOnFailure = (ctx) => {
|
|
2056
|
-
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
2057
|
-
};
|
|
2058
|
-
var hasOnFailure = (stacks) => {
|
|
2059
|
-
const onFailure = stacks.find((stack) => {
|
|
2060
|
-
return typeof stack.onFailure !== "undefined";
|
|
2061
|
-
});
|
|
2062
|
-
return !!onFailure;
|
|
2063
|
-
};
|
|
2064
|
-
|
|
2065
2072
|
// src/feature/function/util.ts
|
|
2066
2073
|
var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
2067
2074
|
let name;
|
|
@@ -2072,7 +2079,6 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2072
2079
|
}
|
|
2073
2080
|
const props = deepmerge(ctx.appConfig.defaults.function, local2);
|
|
2074
2081
|
ctx.registerBuild("function", name, async (build3) => {
|
|
2075
|
-
props.file;
|
|
2076
2082
|
const version = await fingerprintFromFile(props.file);
|
|
2077
2083
|
return build3(version, async (write) => {
|
|
2078
2084
|
const bundle = await bundleTypeScript({ file: props.file });
|
|
@@ -2122,18 +2128,6 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2122
2128
|
if ("stackConfig" in ctx) {
|
|
2123
2129
|
lambda.addEnvironment("STACK", ctx.stackConfig.name);
|
|
2124
2130
|
}
|
|
2125
|
-
const invokeConfig = new aws2.lambda.EventInvokeConfig(group, "async", {
|
|
2126
|
-
functionArn: lambda.arn,
|
|
2127
|
-
retryAttempts: props.retryAttempts,
|
|
2128
|
-
onFailure: getGlobalOnFailure(ctx)
|
|
2129
|
-
});
|
|
2130
|
-
invokeConfig.dependsOn(policy);
|
|
2131
|
-
if (hasOnFailure(ctx.stackConfigs)) {
|
|
2132
|
-
policy.addStatement({
|
|
2133
|
-
actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
|
|
2134
|
-
resources: [getGlobalOnFailure(ctx)]
|
|
2135
|
-
});
|
|
2136
|
-
}
|
|
2137
2131
|
if (props.log.retention.value > 0n) {
|
|
2138
2132
|
const logGroup = new aws2.cloudWatch.LogGroup(group, "log", {
|
|
2139
2133
|
name: lambda.name.apply((name2) => `/aws/lambda/${name2}`),
|
|
@@ -2521,7 +2515,7 @@ var functionFeature = defineFeature({
|
|
|
2521
2515
|
const mockResponse = new TypeObject(2);
|
|
2522
2516
|
for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
|
|
2523
2517
|
const varName = camelCase3(`${stack.name}-${name}`);
|
|
2524
|
-
const funcName = formatLocalResourceName(ctx.appConfig.name, stack.name, "
|
|
2518
|
+
const funcName = formatLocalResourceName(ctx.appConfig.name, stack.name, "function", name);
|
|
2525
2519
|
const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
|
|
2526
2520
|
const relFile = relative(directories.types, file);
|
|
2527
2521
|
types2.addImport(varName, relFile);
|
|
@@ -2966,6 +2960,17 @@ var graphqlFeature = defineFeature({
|
|
|
2966
2960
|
}
|
|
2967
2961
|
});
|
|
2968
2962
|
|
|
2963
|
+
// src/feature/on-failure/util.ts
|
|
2964
|
+
var getGlobalOnFailure = (ctx) => {
|
|
2965
|
+
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
2966
|
+
};
|
|
2967
|
+
var hasOnFailure = (stacks) => {
|
|
2968
|
+
const onFailure = stacks.find((stack) => {
|
|
2969
|
+
return typeof stack.onFailure !== "undefined";
|
|
2970
|
+
});
|
|
2971
|
+
return !!onFailure;
|
|
2972
|
+
};
|
|
2973
|
+
|
|
2969
2974
|
// src/feature/on-failure/index.ts
|
|
2970
2975
|
import { Node as Node7, aws as aws7 } from "@awsless/formation";
|
|
2971
2976
|
var onFailureFeature = defineFeature({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
3
|
|
|
4
4
|
// src/config/stack.ts
|
|
5
|
-
import { z as
|
|
5
|
+
import { z as z26 } from "zod";
|
|
6
6
|
|
|
7
7
|
// src/config/schema/resource-id.ts
|
|
8
8
|
import { paramCase } from "change-case";
|
|
@@ -852,13 +852,30 @@ var SitesSchema = z24.record(
|
|
|
852
852
|
})
|
|
853
853
|
).optional().describe("Define the sites in your stack.");
|
|
854
854
|
|
|
855
|
+
// src/feature/task/schema.ts
|
|
856
|
+
import { z as z25 } from "zod";
|
|
857
|
+
var RetryAttemptsSchema2 = z25.number().int().min(0).max(2).describe(
|
|
858
|
+
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
859
|
+
);
|
|
860
|
+
var TaskSchema = z25.union([
|
|
861
|
+
LocalFileSchema.transform((file) => ({
|
|
862
|
+
consumer: { file },
|
|
863
|
+
retryAttempts: void 0
|
|
864
|
+
})),
|
|
865
|
+
z25.object({
|
|
866
|
+
consumer: FunctionSchema,
|
|
867
|
+
retryAttempts: RetryAttemptsSchema2.optional()
|
|
868
|
+
})
|
|
869
|
+
]);
|
|
870
|
+
var TasksSchema = z25.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
871
|
+
|
|
855
872
|
// src/config/stack.ts
|
|
856
873
|
var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
|
|
857
874
|
var NameSchema = ResourceIdSchema.refine((name) => !["base"].includes(name), {
|
|
858
875
|
message: `Stack name can't be a reserved name.`
|
|
859
876
|
}).describe("Stack name.");
|
|
860
|
-
var StackSchema =
|
|
861
|
-
$schema:
|
|
877
|
+
var StackSchema = z26.object({
|
|
878
|
+
$schema: z26.string().optional(),
|
|
862
879
|
name: NameSchema,
|
|
863
880
|
depends: DependsSchema,
|
|
864
881
|
onFailure: OnFailureSchema,
|
|
@@ -872,6 +889,7 @@ var StackSchema = z25.object({
|
|
|
872
889
|
topics: TopicsSchema,
|
|
873
890
|
subscribers: SubscribersSchema,
|
|
874
891
|
functions: FunctionsSchema,
|
|
892
|
+
tasks: TasksSchema,
|
|
875
893
|
tables: TablesSchema,
|
|
876
894
|
stores: StoresSchema,
|
|
877
895
|
queues: QueuesSchema,
|
|
@@ -882,10 +900,10 @@ var StackSchema = z25.object({
|
|
|
882
900
|
});
|
|
883
901
|
|
|
884
902
|
// src/config/app.ts
|
|
885
|
-
import { z as
|
|
903
|
+
import { z as z29 } from "zod";
|
|
886
904
|
|
|
887
905
|
// src/config/schema/region.ts
|
|
888
|
-
import { z as
|
|
906
|
+
import { z as z27 } from "zod";
|
|
889
907
|
var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
|
|
890
908
|
var AF = ["af-south-1"];
|
|
891
909
|
var AP = [
|
|
@@ -914,21 +932,21 @@ var EU = [
|
|
|
914
932
|
var ME = ["me-south-1", "me-central-1"];
|
|
915
933
|
var SA = ["sa-east-1"];
|
|
916
934
|
var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
|
|
917
|
-
var RegionSchema =
|
|
935
|
+
var RegionSchema = z27.enum(regions);
|
|
918
936
|
|
|
919
937
|
// src/feature/domain/schema.ts
|
|
920
|
-
import { z as
|
|
921
|
-
var DomainNameSchema =
|
|
938
|
+
import { z as z28 } from "zod";
|
|
939
|
+
var DomainNameSchema = z28.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
|
|
922
940
|
"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."
|
|
923
941
|
);
|
|
924
|
-
var DNSTypeSchema =
|
|
942
|
+
var DNSTypeSchema = z28.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
|
|
925
943
|
var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
|
|
926
|
-
var RecordsSchema =
|
|
927
|
-
var DomainsDefaultSchema =
|
|
944
|
+
var RecordsSchema = z28.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
|
|
945
|
+
var DomainsDefaultSchema = z28.record(
|
|
928
946
|
ResourceIdSchema,
|
|
929
|
-
|
|
947
|
+
z28.object({
|
|
930
948
|
domain: DomainNameSchema.describe("Define the domain name"),
|
|
931
|
-
dns:
|
|
949
|
+
dns: z28.object({
|
|
932
950
|
name: DomainNameSchema.optional(),
|
|
933
951
|
type: DNSTypeSchema,
|
|
934
952
|
ttl: TTLSchema,
|
|
@@ -938,17 +956,17 @@ var DomainsDefaultSchema = z27.record(
|
|
|
938
956
|
).optional().describe("Define the domains for your application.");
|
|
939
957
|
|
|
940
958
|
// src/config/app.ts
|
|
941
|
-
var AppSchema =
|
|
942
|
-
$schema:
|
|
959
|
+
var AppSchema = z29.object({
|
|
960
|
+
$schema: z29.string().optional(),
|
|
943
961
|
name: ResourceIdSchema.describe("App name."),
|
|
944
962
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
945
|
-
profile:
|
|
963
|
+
profile: z29.string().describe("The AWS profile to deploy to."),
|
|
946
964
|
// stage: z
|
|
947
965
|
// .string()
|
|
948
966
|
// .regex(/^[a-z]+$/)
|
|
949
967
|
// .default('prod')
|
|
950
968
|
// .describe('The deployment stage.'),
|
|
951
|
-
defaults:
|
|
969
|
+
defaults: z29.object({
|
|
952
970
|
auth: AuthDefaultSchema,
|
|
953
971
|
domains: DomainsDefaultSchema,
|
|
954
972
|
function: FunctionDefaultSchema,
|