@awsless/awsless 0.0.246 → 0.0.247
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/app.json +1 -0
- package/dist/bin.js +5315 -0
- package/dist/build-json-schema.js +1068 -0
- package/dist/client.js +46 -0
- package/dist/server.js +461 -0
- package/dist/stack.json +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
// cli/build-json-schema.ts
|
|
2
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
3
|
+
|
|
4
|
+
// src/config/stack.ts
|
|
5
|
+
import { z as z26 } from "zod";
|
|
6
|
+
|
|
7
|
+
// src/config/schema/resource-id.ts
|
|
8
|
+
import { paramCase } from "change-case";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
var ResourceIdSchema = z.string().min(3).max(24).regex(/^[a-z0-9\-]+$/i, "Invalid resource ID").transform((value) => paramCase(value));
|
|
11
|
+
|
|
12
|
+
// src/feature/function/schema.ts
|
|
13
|
+
import { z as z5 } from "zod";
|
|
14
|
+
|
|
15
|
+
// src/config/schema/duration.ts
|
|
16
|
+
import { z as z2 } from "zod";
|
|
17
|
+
import { parse } from "@awsless/duration";
|
|
18
|
+
var DurationSchema = z2.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/, "Invalid duration").transform((v) => parse(v));
|
|
19
|
+
var durationMin = (min) => {
|
|
20
|
+
return (duration) => {
|
|
21
|
+
return duration.value >= min.value;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
var durationMax = (max) => {
|
|
25
|
+
return (duration) => {
|
|
26
|
+
return duration.value <= max.value;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/config/schema/local-file.ts
|
|
31
|
+
import { stat } from "fs/promises";
|
|
32
|
+
import { z as z3 } from "zod";
|
|
33
|
+
|
|
34
|
+
// src/util/path.ts
|
|
35
|
+
import { join, normalize } from "path";
|
|
36
|
+
var root = process.cwd();
|
|
37
|
+
var directories = {
|
|
38
|
+
root,
|
|
39
|
+
get output() {
|
|
40
|
+
return join(this.root, ".awsless");
|
|
41
|
+
},
|
|
42
|
+
get cache() {
|
|
43
|
+
return join(this.output, "cache");
|
|
44
|
+
},
|
|
45
|
+
get state() {
|
|
46
|
+
return join(this.output, "state");
|
|
47
|
+
},
|
|
48
|
+
get build() {
|
|
49
|
+
return join(this.output, "build");
|
|
50
|
+
},
|
|
51
|
+
get types() {
|
|
52
|
+
return join(this.output, "types");
|
|
53
|
+
},
|
|
54
|
+
// get template() {
|
|
55
|
+
// return join(this.output, 'template')
|
|
56
|
+
// },
|
|
57
|
+
get test() {
|
|
58
|
+
return join(this.output, "test");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/config/schema/local-file.ts
|
|
63
|
+
import { join as join2 } from "path";
|
|
64
|
+
var basePath;
|
|
65
|
+
var resolvePath = (path) => {
|
|
66
|
+
if (path.startsWith(".") && basePath) {
|
|
67
|
+
return join2(basePath, path);
|
|
68
|
+
}
|
|
69
|
+
return join2(directories.root, path);
|
|
70
|
+
};
|
|
71
|
+
var LocalFileSchema = z3.string().transform((path) => resolvePath(path)).refine(async (path) => {
|
|
72
|
+
try {
|
|
73
|
+
const s = await stat(path);
|
|
74
|
+
return s.isFile();
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}, `File doesn't exist`);
|
|
79
|
+
|
|
80
|
+
// src/config/schema/size.ts
|
|
81
|
+
import { z as z4 } from "zod";
|
|
82
|
+
import { parse as parse2 } from "@awsless/size";
|
|
83
|
+
var SizeSchema = z4.string().regex(/^[0-9]+ (B|KB|MB|GB|TB|PB)$/, "Invalid size").transform((v) => parse2(v));
|
|
84
|
+
var sizeMin = (min) => {
|
|
85
|
+
return (size) => {
|
|
86
|
+
return size.value >= min.value;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var sizeMax = (max) => {
|
|
90
|
+
return (size) => {
|
|
91
|
+
return size.value <= max.value;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/feature/function/schema.ts
|
|
96
|
+
import { days, minutes, seconds } from "@awsless/duration";
|
|
97
|
+
import { gibibytes, mebibytes } from "@awsless/size";
|
|
98
|
+
var MemorySizeSchema = SizeSchema.refine(sizeMin(mebibytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(gibibytes(10)), "Maximum memory size is 10 GB").describe(
|
|
99
|
+
"The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The value can be any multiple of 1 MB. You can specify a size value from 128 MB to 10 GB."
|
|
100
|
+
);
|
|
101
|
+
var TimeoutSchema = DurationSchema.refine(durationMin(seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(minutes(15)), "Maximum timeout duration is 15 minutes").describe(
|
|
102
|
+
"The amount of time that Lambda allows a function to run before stopping it. You can specify a size value from 1 second to 15 minutes."
|
|
103
|
+
);
|
|
104
|
+
var EphemeralStorageSizeSchema = SizeSchema.refine(
|
|
105
|
+
sizeMin(mebibytes(512)),
|
|
106
|
+
"Minimum ephemeral storage size is 512 MB"
|
|
107
|
+
).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.");
|
|
108
|
+
var ReservedConcurrentExecutionsSchema = z5.number().int().min(0).describe(
|
|
109
|
+
"The number of simultaneous executions to reserve for the function. You can specify a number from 0."
|
|
110
|
+
);
|
|
111
|
+
var EnvironmentSchema = z5.record(z5.string(), z5.string()).optional().describe("Environment variable key-value pairs.");
|
|
112
|
+
var ArchitectureSchema = z5.enum(["x86_64", "arm64"]).describe("The instruction set architecture that the function supports.");
|
|
113
|
+
var RetryAttemptsSchema = z5.number().int().min(0).max(2).describe(
|
|
114
|
+
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
115
|
+
);
|
|
116
|
+
var RuntimeSchema = z5.enum(["nodejs18.x", "nodejs20.x"]).describe("The identifier of the function's runtime.");
|
|
117
|
+
var ActionSchema = z5.string();
|
|
118
|
+
var ActionsSchema = z5.union([ActionSchema.transform((v) => [v]), ActionSchema.array()]);
|
|
119
|
+
var ArnSchema = z5.string().startsWith("arn:");
|
|
120
|
+
var WildcardSchema = z5.literal("*");
|
|
121
|
+
var ResourceSchema = z5.union([ArnSchema, WildcardSchema]).transform((v) => v);
|
|
122
|
+
var ResourcesSchema = z5.union([ResourceSchema.transform((v) => [v]), ResourceSchema.array()]);
|
|
123
|
+
var PermissionSchema = z5.object({
|
|
124
|
+
effect: z5.enum(["allow", "deny"]).default("allow"),
|
|
125
|
+
actions: ActionsSchema,
|
|
126
|
+
resources: ResourcesSchema
|
|
127
|
+
});
|
|
128
|
+
var PermissionsSchema = z5.union([PermissionSchema.transform((v) => [v]), PermissionSchema.array()]).describe("Add IAM permissions to your function.");
|
|
129
|
+
var WarmSchema = z5.number().int().min(0).max(10).describe(
|
|
130
|
+
"Specify how many functions you want to warm up each 5 minutes. You can specify a number from 0 to 10."
|
|
131
|
+
);
|
|
132
|
+
var VPCSchema = z5.boolean().describe("Put the function inside your global VPC.");
|
|
133
|
+
var MinifySchema = z5.boolean().describe("Minify the function code.");
|
|
134
|
+
var HandlerSchema = z5.string().describe("The name of the exported method within your code that Lambda calls to run your function.");
|
|
135
|
+
var FileSchema = LocalFileSchema.describe("The file path of the function code.");
|
|
136
|
+
var DescriptionSchema = z5.string().describe("A description of the function.");
|
|
137
|
+
var LogRetentionSchema = DurationSchema.refine(
|
|
138
|
+
durationMin(days(0)),
|
|
139
|
+
"Minimum log retention is 0 day, which will disable logging."
|
|
140
|
+
);
|
|
141
|
+
var LogSchema = z5.union([
|
|
142
|
+
z5.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
|
|
143
|
+
LogRetentionSchema.transform((retention) => ({ retention })),
|
|
144
|
+
z5.object({
|
|
145
|
+
retention: LogRetentionSchema.describe("The log retention duration."),
|
|
146
|
+
format: z5.enum(["text", "json"]).describe(
|
|
147
|
+
`The format in which Lambda sends your function's application and system logs to CloudWatch. Select between plain text and structured JSON.`
|
|
148
|
+
).optional(),
|
|
149
|
+
system: z5.enum(["debug", "info", "warn"]).describe(
|
|
150
|
+
"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."
|
|
151
|
+
).optional(),
|
|
152
|
+
level: z5.enum(["trace", "debug", "info", "warn", "error", "fatal"]).describe(
|
|
153
|
+
"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."
|
|
154
|
+
).optional()
|
|
155
|
+
})
|
|
156
|
+
]).describe(
|
|
157
|
+
"Enable logging to a CloudWatch log group. Providing a duration value will set the log retention time."
|
|
158
|
+
);
|
|
159
|
+
var FunctionSchema = z5.union([
|
|
160
|
+
LocalFileSchema.transform((file) => ({
|
|
161
|
+
file
|
|
162
|
+
})),
|
|
163
|
+
z5.object({
|
|
164
|
+
file: FileSchema,
|
|
165
|
+
description: DescriptionSchema.optional(),
|
|
166
|
+
handler: HandlerSchema.optional(),
|
|
167
|
+
minify: MinifySchema.optional(),
|
|
168
|
+
warm: WarmSchema.optional(),
|
|
169
|
+
vpc: VPCSchema.optional(),
|
|
170
|
+
log: LogSchema.optional(),
|
|
171
|
+
timeout: TimeoutSchema.optional(),
|
|
172
|
+
runtime: RuntimeSchema.optional(),
|
|
173
|
+
memorySize: MemorySizeSchema.optional(),
|
|
174
|
+
architecture: ArchitectureSchema.optional(),
|
|
175
|
+
ephemeralStorageSize: EphemeralStorageSizeSchema.optional(),
|
|
176
|
+
retryAttempts: RetryAttemptsSchema.optional(),
|
|
177
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
178
|
+
environment: EnvironmentSchema.optional(),
|
|
179
|
+
permissions: PermissionsSchema.optional()
|
|
180
|
+
})
|
|
181
|
+
]);
|
|
182
|
+
var FunctionsSchema = z5.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
|
|
183
|
+
var FunctionDefaultSchema = z5.object({
|
|
184
|
+
handler: HandlerSchema.default("index.default"),
|
|
185
|
+
minify: MinifySchema.default(true),
|
|
186
|
+
warm: WarmSchema.default(0),
|
|
187
|
+
vpc: VPCSchema.default(false),
|
|
188
|
+
log: LogSchema.default({
|
|
189
|
+
retention: "7 days",
|
|
190
|
+
level: "error",
|
|
191
|
+
system: "warn",
|
|
192
|
+
format: "json"
|
|
193
|
+
}),
|
|
194
|
+
timeout: TimeoutSchema.default("10 seconds"),
|
|
195
|
+
runtime: RuntimeSchema.default("nodejs20.x"),
|
|
196
|
+
memorySize: MemorySizeSchema.default("128 MB"),
|
|
197
|
+
architecture: ArchitectureSchema.default("arm64"),
|
|
198
|
+
ephemeralStorageSize: EphemeralStorageSizeSchema.default("512 MB"),
|
|
199
|
+
retryAttempts: RetryAttemptsSchema.default(2),
|
|
200
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
201
|
+
environment: EnvironmentSchema.optional(),
|
|
202
|
+
permissions: PermissionsSchema.optional()
|
|
203
|
+
}).default({});
|
|
204
|
+
|
|
205
|
+
// src/feature/on-failure/schema.ts
|
|
206
|
+
var OnFailureSchema = FunctionSchema.optional().describe(
|
|
207
|
+
"Defining a onFailure handler will add a global onFailure handler for the following resources:\n- Async lambda functions\n- SQS queues\n- DynamoDB streams"
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
// src/feature/config/schema.ts
|
|
211
|
+
import { z as z6 } from "zod";
|
|
212
|
+
var ConfigNameSchema = z6.string().regex(/[a-z0-9\-]/g, "Invalid config name");
|
|
213
|
+
var ConfigsSchema = z6.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
|
|
214
|
+
|
|
215
|
+
// src/feature/graphql/schema.ts
|
|
216
|
+
import { z as z7 } from "zod";
|
|
217
|
+
var AuthorizerTtl = DurationSchema.describe(
|
|
218
|
+
`The number of seconds a response should be cached for. The maximum value is one hour (3600 seconds). The Lambda function can override this by returning a ttlOverride key in its response.`
|
|
219
|
+
);
|
|
220
|
+
var GraphQLDefaultSchema = z7.record(
|
|
221
|
+
ResourceIdSchema,
|
|
222
|
+
z7.object({
|
|
223
|
+
domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
|
|
224
|
+
subDomain: z7.string().optional(),
|
|
225
|
+
auth: z7.union([
|
|
226
|
+
ResourceIdSchema,
|
|
227
|
+
z7.object({
|
|
228
|
+
authorizer: FunctionSchema,
|
|
229
|
+
ttl: AuthorizerTtl.default("1 hour")
|
|
230
|
+
})
|
|
231
|
+
]).optional(),
|
|
232
|
+
// authorization: z.object({
|
|
233
|
+
// authorizer: FunctionSchema,
|
|
234
|
+
// ttl: DurationSchema.default('1 hour'),
|
|
235
|
+
// }).optional(),
|
|
236
|
+
resolver: LocalFileSchema.optional()
|
|
237
|
+
})
|
|
238
|
+
).describe(`Define the global GraphQL API's.`).optional();
|
|
239
|
+
var GraphQLSchema = z7.record(
|
|
240
|
+
ResourceIdSchema,
|
|
241
|
+
z7.object({
|
|
242
|
+
// schema: z.union([LocalFileSchema.transform(v => [v]), z.array(LocalFileSchema).min(1)]).optional(),
|
|
243
|
+
schema: LocalFileSchema.describe("The graphql schema file."),
|
|
244
|
+
resolvers: z7.record(
|
|
245
|
+
// TypeName
|
|
246
|
+
z7.string(),
|
|
247
|
+
z7.record(
|
|
248
|
+
// FieldName
|
|
249
|
+
z7.string(),
|
|
250
|
+
z7.union([
|
|
251
|
+
FunctionSchema.transform((consumer) => ({
|
|
252
|
+
consumer
|
|
253
|
+
})),
|
|
254
|
+
z7.object({
|
|
255
|
+
consumer: FunctionSchema,
|
|
256
|
+
resolver: LocalFileSchema.optional()
|
|
257
|
+
})
|
|
258
|
+
])
|
|
259
|
+
)
|
|
260
|
+
).describe("The resolvers for your global GraphQL API.").optional()
|
|
261
|
+
})
|
|
262
|
+
).describe("Define the schema & resolvers in your stack for your global GraphQL API.").optional();
|
|
263
|
+
|
|
264
|
+
// src/feature/table/schema.ts
|
|
265
|
+
import { z as z8 } from "zod";
|
|
266
|
+
var KeySchema = z8.string().min(1).max(255);
|
|
267
|
+
var TablesSchema = z8.record(
|
|
268
|
+
ResourceIdSchema,
|
|
269
|
+
z8.object({
|
|
270
|
+
hash: KeySchema.describe(
|
|
271
|
+
"Specifies the name of the partition / hash key that makes up the primary key for the table."
|
|
272
|
+
),
|
|
273
|
+
sort: KeySchema.optional().describe(
|
|
274
|
+
"Specifies the name of the range / sort key that makes up the primary key for the table."
|
|
275
|
+
),
|
|
276
|
+
fields: z8.record(z8.string(), z8.enum(["string", "number", "binary"])).optional().describe(
|
|
277
|
+
'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
|
|
278
|
+
),
|
|
279
|
+
class: z8.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
|
|
280
|
+
pointInTimeRecovery: z8.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
|
|
281
|
+
timeToLiveAttribute: KeySchema.optional().describe(
|
|
282
|
+
"The name of the TTL attribute used to store the expiration time for items in the table. To update this property, you must first disable TTL and then enable TTL with the new attribute name."
|
|
283
|
+
),
|
|
284
|
+
stream: z8.object({
|
|
285
|
+
type: z8.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
|
|
286
|
+
"When an item in the table is modified, stream.type determines what information is written to the stream for this table. Valid values are:\n- keys-only - Only the key attributes of the modified item are written to the stream.\n- new-image - The entire item, as it appears after it was modified, is written to the stream.\n- old-image - The entire item, as it appeared before it was modified, is written to the stream.\n- new-and-old-images - Both the new and the old item images of the item are written to the stream."
|
|
287
|
+
),
|
|
288
|
+
consumer: FunctionSchema.describe("The consuming lambda function for the stream")
|
|
289
|
+
}).optional().describe(
|
|
290
|
+
"The settings for the DynamoDB table stream, which capture changes to items stored in the table."
|
|
291
|
+
),
|
|
292
|
+
indexes: z8.record(
|
|
293
|
+
z8.string(),
|
|
294
|
+
z8.object({
|
|
295
|
+
/** Specifies the name of the partition / hash key that makes up the primary key for the global secondary index. */
|
|
296
|
+
hash: KeySchema,
|
|
297
|
+
/** Specifies the name of the range / sort key that makes up the primary key for the global secondary index. */
|
|
298
|
+
sort: KeySchema.optional(),
|
|
299
|
+
/** The set of attributes that are projected into the index:
|
|
300
|
+
* - all - All of the table attributes are projected into the index.
|
|
301
|
+
* - keys-only - Only the index and primary keys are projected into the index.
|
|
302
|
+
* @default 'all'
|
|
303
|
+
*/
|
|
304
|
+
projection: z8.enum(["all", "keys-only"]).default("all")
|
|
305
|
+
})
|
|
306
|
+
).optional().describe("Specifies the global secondary indexes to be created on the table.")
|
|
307
|
+
})
|
|
308
|
+
).optional().describe("Define the tables in your stack.");
|
|
309
|
+
|
|
310
|
+
// src/feature/store/schema.ts
|
|
311
|
+
import { z as z9 } from "zod";
|
|
312
|
+
var StoresSchema = z9.union([
|
|
313
|
+
z9.array(ResourceIdSchema).transform((list) => {
|
|
314
|
+
const stores = {};
|
|
315
|
+
for (const key of list) {
|
|
316
|
+
stores[key] = {};
|
|
317
|
+
}
|
|
318
|
+
return stores;
|
|
319
|
+
}),
|
|
320
|
+
z9.record(
|
|
321
|
+
ResourceIdSchema,
|
|
322
|
+
z9.object({
|
|
323
|
+
// cors: CorsSchema,
|
|
324
|
+
versioning: z9.boolean().default(false).describe("Enable versioning of your store."),
|
|
325
|
+
events: z9.object({
|
|
326
|
+
// create
|
|
327
|
+
"created:*": FunctionSchema.optional().describe(
|
|
328
|
+
"Subscribe to notifications regardless of the API that was used to create an object."
|
|
329
|
+
),
|
|
330
|
+
"created:put": FunctionSchema.optional().describe(
|
|
331
|
+
"Subscribe to notifications when an object is created using the PUT API operation."
|
|
332
|
+
),
|
|
333
|
+
"created:post": FunctionSchema.optional().describe(
|
|
334
|
+
"Subscribe to notifications when an object is created using the POST API operation."
|
|
335
|
+
),
|
|
336
|
+
"created:copy": FunctionSchema.optional().describe(
|
|
337
|
+
"Subscribe to notifications when an object is created using the COPY API operation."
|
|
338
|
+
),
|
|
339
|
+
"created:upload": FunctionSchema.optional().describe(
|
|
340
|
+
"Subscribe to notifications when an object multipart upload has been completed."
|
|
341
|
+
),
|
|
342
|
+
// remove
|
|
343
|
+
"removed:*": FunctionSchema.optional().describe(
|
|
344
|
+
"Subscribe to notifications when an object is deleted or a delete marker for a versioned object is created."
|
|
345
|
+
),
|
|
346
|
+
"removed:delete": FunctionSchema.optional().describe(
|
|
347
|
+
"Subscribe to notifications when an object is deleted"
|
|
348
|
+
),
|
|
349
|
+
"removed:marker": FunctionSchema.optional().describe(
|
|
350
|
+
"Subscribe to notifications when a delete marker for a versioned object is created."
|
|
351
|
+
)
|
|
352
|
+
}).optional().describe("Describes the store events you want to subscribe too.")
|
|
353
|
+
})
|
|
354
|
+
)
|
|
355
|
+
]).optional().describe("Define the stores in your stack.");
|
|
356
|
+
|
|
357
|
+
// src/feature/queue/schema.ts
|
|
358
|
+
import { z as z10 } from "zod";
|
|
359
|
+
import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
|
|
360
|
+
import { kibibytes } from "@awsless/size";
|
|
361
|
+
var RetentionPeriodSchema = DurationSchema.refine(
|
|
362
|
+
durationMin(minutes2(1)),
|
|
363
|
+
"Minimum retention period is 1 minute"
|
|
364
|
+
).refine(durationMax(days2(14)), "Maximum retention period is 14 days").describe(
|
|
365
|
+
"The number of seconds that Amazon SQS retains a message. You can specify a duration from 1 minute to 14 days."
|
|
366
|
+
);
|
|
367
|
+
var VisibilityTimeoutSchema = DurationSchema.refine(
|
|
368
|
+
durationMax(hours(12)),
|
|
369
|
+
"Maximum visibility timeout is 12 hours"
|
|
370
|
+
).describe(
|
|
371
|
+
"The length of time during which a message will be unavailable after a message is delivered from the queue. This blocks other components from receiving the same message and gives the initial component time to process and delete the message from the queue. You can specify a duration from 0 to 12 hours."
|
|
372
|
+
);
|
|
373
|
+
var DeliveryDelaySchema = DurationSchema.refine(
|
|
374
|
+
durationMax(minutes2(15)),
|
|
375
|
+
"Maximum delivery delay is 15 minutes"
|
|
376
|
+
).describe(
|
|
377
|
+
"The time in seconds for which the delivery of all messages in the queue is delayed. You can specify a duration from 0 to 15 minutes."
|
|
378
|
+
);
|
|
379
|
+
var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
|
|
380
|
+
durationMin(seconds2(1)),
|
|
381
|
+
"Minimum receive message wait time is 1 second"
|
|
382
|
+
).refine(durationMax(seconds2(20)), "Maximum receive message wait time is 20 seconds").describe(
|
|
383
|
+
"Specifies the duration, that the ReceiveMessage action call waits until a message is in the queue in order to include it in the response, rather than returning an empty response if a message isn't yet available. You can specify a duration from 1 to 20 seconds. Short polling is used as the default."
|
|
384
|
+
);
|
|
385
|
+
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(
|
|
386
|
+
"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."
|
|
387
|
+
);
|
|
388
|
+
var BatchSizeSchema = z10.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000").describe(
|
|
389
|
+
"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."
|
|
390
|
+
);
|
|
391
|
+
var MaxConcurrencySchema = z10.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000").describe(
|
|
392
|
+
"Limits the number of concurrent instances that the queue worker can invoke. You can specify an integer from 2 to 1000."
|
|
393
|
+
);
|
|
394
|
+
var MaxBatchingWindow = DurationSchema.refine(
|
|
395
|
+
durationMax(minutes2(5)),
|
|
396
|
+
"Maximum max batching window is 5 minutes"
|
|
397
|
+
).describe(
|
|
398
|
+
"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."
|
|
399
|
+
);
|
|
400
|
+
var QueueDefaultSchema = z10.object({
|
|
401
|
+
retentionPeriod: RetentionPeriodSchema.default("7 days"),
|
|
402
|
+
visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
|
|
403
|
+
deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
|
|
404
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
405
|
+
maxMessageSize: MaxMessageSizeSchema.default("256 KB"),
|
|
406
|
+
batchSize: BatchSizeSchema.default(10),
|
|
407
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
408
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
409
|
+
}).default({});
|
|
410
|
+
var QueuesSchema = z10.record(
|
|
411
|
+
ResourceIdSchema,
|
|
412
|
+
z10.union([
|
|
413
|
+
LocalFileSchema.transform((file) => ({
|
|
414
|
+
consumer: {
|
|
415
|
+
file
|
|
416
|
+
}
|
|
417
|
+
})),
|
|
418
|
+
z10.object({
|
|
419
|
+
consumer: FunctionSchema.describe("he consuming lambda function properties."),
|
|
420
|
+
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
421
|
+
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
422
|
+
deliveryDelay: DeliveryDelaySchema.optional(),
|
|
423
|
+
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
424
|
+
maxMessageSize: MaxMessageSizeSchema.optional(),
|
|
425
|
+
batchSize: BatchSizeSchema.optional(),
|
|
426
|
+
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
427
|
+
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
428
|
+
})
|
|
429
|
+
])
|
|
430
|
+
).optional().describe("Define the queues in your stack.");
|
|
431
|
+
|
|
432
|
+
// src/feature/pubsub/schema.ts
|
|
433
|
+
import { z as z11 } from "zod";
|
|
434
|
+
var PubSubSchema = z11.record(
|
|
435
|
+
ResourceIdSchema,
|
|
436
|
+
z11.object({
|
|
437
|
+
sql: z11.string().describe("The SQL statement used to query the IOT topic."),
|
|
438
|
+
sqlVersion: z11.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."),
|
|
439
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties.")
|
|
440
|
+
})
|
|
441
|
+
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
442
|
+
|
|
443
|
+
// src/feature/rest/schema.ts
|
|
444
|
+
import { z as z13 } from "zod";
|
|
445
|
+
|
|
446
|
+
// src/config/schema/route.ts
|
|
447
|
+
import { z as z12 } from "zod";
|
|
448
|
+
var RouteSchema = z12.union([
|
|
449
|
+
z12.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
|
|
450
|
+
z12.literal("$default")
|
|
451
|
+
]);
|
|
452
|
+
|
|
453
|
+
// src/feature/rest/schema.ts
|
|
454
|
+
var RestDefaultSchema = z13.record(
|
|
455
|
+
ResourceIdSchema,
|
|
456
|
+
z13.object({
|
|
457
|
+
domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
|
|
458
|
+
subDomain: z13.string().optional()
|
|
459
|
+
})
|
|
460
|
+
).optional().describe("Define your global REST API's.");
|
|
461
|
+
var RestSchema = z13.record(ResourceIdSchema, z13.record(RouteSchema, FunctionSchema)).optional().describe("Define routes in your stack for your global REST API.");
|
|
462
|
+
|
|
463
|
+
// src/feature/test/schema.ts
|
|
464
|
+
import { z as z15 } from "zod";
|
|
465
|
+
|
|
466
|
+
// src/config/schema/local-directory.ts
|
|
467
|
+
import { stat as stat2 } from "fs/promises";
|
|
468
|
+
import { z as z14 } from "zod";
|
|
469
|
+
var LocalDirectorySchema = z14.string().transform((path) => resolvePath(path)).refine(async (path) => {
|
|
470
|
+
try {
|
|
471
|
+
const s = await stat2(path);
|
|
472
|
+
return s.isDirectory();
|
|
473
|
+
} catch (error) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
}, `Directory doesn't exist`);
|
|
477
|
+
|
|
478
|
+
// src/feature/test/schema.ts
|
|
479
|
+
var TestsSchema = z15.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
|
|
480
|
+
|
|
481
|
+
// src/feature/topic/schema.ts
|
|
482
|
+
import { paramCase as paramCase2 } from "change-case";
|
|
483
|
+
import { z as z17 } from "zod";
|
|
484
|
+
|
|
485
|
+
// src/config/schema/email.ts
|
|
486
|
+
import { z as z16 } from "zod";
|
|
487
|
+
var EmailSchema = z16.string().email();
|
|
488
|
+
|
|
489
|
+
// src/feature/topic/schema.ts
|
|
490
|
+
var TopicNameSchema = z17.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase2(value)).describe("Define event topic name.");
|
|
491
|
+
var TopicsSchema = z17.array(TopicNameSchema).refine((topics) => {
|
|
492
|
+
return topics.length === new Set(topics).size;
|
|
493
|
+
}, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
|
|
494
|
+
var SubscribersSchema = z17.record(TopicNameSchema, z17.union([EmailSchema, FunctionSchema])).optional().describe("Define the event topics to subscribe too in your stack.");
|
|
495
|
+
|
|
496
|
+
// src/feature/cron/schema/index.ts
|
|
497
|
+
import { z as z19 } from "zod";
|
|
498
|
+
|
|
499
|
+
// src/feature/cron/schema/schedule.ts
|
|
500
|
+
import { z as z18 } from "zod";
|
|
501
|
+
import { awsCronExpressionValidator } from "aws-cron-expression-validator";
|
|
502
|
+
var RateExpressionSchema = z18.custom(
|
|
503
|
+
(value) => {
|
|
504
|
+
return z18.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
|
|
505
|
+
const [str] = rate.split(" ");
|
|
506
|
+
const number = parseInt(str);
|
|
507
|
+
return number > 0;
|
|
508
|
+
}).safeParse(value).success;
|
|
509
|
+
},
|
|
510
|
+
{ message: "Invalid rate expression" }
|
|
511
|
+
).transform((rate) => {
|
|
512
|
+
const [str] = rate.split(" ");
|
|
513
|
+
const number = parseInt(str);
|
|
514
|
+
const more = rate.endsWith("s");
|
|
515
|
+
if (more && number === 1) {
|
|
516
|
+
return `rate(${rate.substring(0, rate.length - 1)})`;
|
|
517
|
+
}
|
|
518
|
+
return `rate(${rate})`;
|
|
519
|
+
});
|
|
520
|
+
var CronExpressionSchema = z18.custom(
|
|
521
|
+
(value) => {
|
|
522
|
+
return z18.string().safeParse(value).success;
|
|
523
|
+
},
|
|
524
|
+
{ message: "Invalid cron expression" }
|
|
525
|
+
).superRefine((value, ctx) => {
|
|
526
|
+
try {
|
|
527
|
+
awsCronExpressionValidator(value);
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (error instanceof Error) {
|
|
530
|
+
ctx.addIssue({
|
|
531
|
+
code: z18.ZodIssueCode.custom,
|
|
532
|
+
message: `Invalid cron expression: ${error.message}`
|
|
533
|
+
});
|
|
534
|
+
} else {
|
|
535
|
+
ctx.addIssue({
|
|
536
|
+
code: z18.ZodIssueCode.custom,
|
|
537
|
+
message: "Invalid cron expression"
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}).transform((value) => {
|
|
542
|
+
return `cron(${value.trim()})`;
|
|
543
|
+
});
|
|
544
|
+
var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
545
|
+
|
|
546
|
+
// src/feature/cron/schema/index.ts
|
|
547
|
+
var CronsSchema = z19.record(
|
|
548
|
+
ResourceIdSchema,
|
|
549
|
+
z19.object({
|
|
550
|
+
enabled: z19.boolean().default(true).describe("If the cron is enabled."),
|
|
551
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
552
|
+
schedule: ScheduleExpressionSchema.describe(
|
|
553
|
+
'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
|
|
554
|
+
),
|
|
555
|
+
payload: z19.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
556
|
+
})
|
|
557
|
+
).optional();
|
|
558
|
+
|
|
559
|
+
// src/feature/cache/schema.ts
|
|
560
|
+
import { z as z20 } from "zod";
|
|
561
|
+
var TypeSchema = z20.enum([
|
|
562
|
+
"t4g.small",
|
|
563
|
+
"t4g.medium",
|
|
564
|
+
"r6g.large",
|
|
565
|
+
"r6g.xlarge",
|
|
566
|
+
"r6g.2xlarge",
|
|
567
|
+
"r6g.4xlarge",
|
|
568
|
+
"r6g.8xlarge",
|
|
569
|
+
"r6g.12xlarge",
|
|
570
|
+
"r6g.16xlarge",
|
|
571
|
+
"r6gd.xlarge",
|
|
572
|
+
"r6gd.2xlarge",
|
|
573
|
+
"r6gd.4xlarge",
|
|
574
|
+
"r6gd.8xlarge"
|
|
575
|
+
]);
|
|
576
|
+
var PortSchema = z20.number().int().min(1).max(5e4);
|
|
577
|
+
var ShardsSchema = z20.number().int().min(0).max(100);
|
|
578
|
+
var ReplicasPerShardSchema = z20.number().int().min(0).max(5);
|
|
579
|
+
var EngineSchema = z20.enum(["7.0", "6.2"]);
|
|
580
|
+
var CachesSchema = z20.record(
|
|
581
|
+
ResourceIdSchema,
|
|
582
|
+
z20.object({
|
|
583
|
+
type: TypeSchema.default("t4g.small"),
|
|
584
|
+
port: PortSchema.default(6379),
|
|
585
|
+
shards: ShardsSchema.default(1),
|
|
586
|
+
replicasPerShard: ReplicasPerShardSchema.default(1),
|
|
587
|
+
engine: EngineSchema.default("7.0"),
|
|
588
|
+
dataTiering: z20.boolean().default(false)
|
|
589
|
+
})
|
|
590
|
+
).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
|
|
591
|
+
|
|
592
|
+
// src/feature/auth/schema.ts
|
|
593
|
+
import { z as z21 } from "zod";
|
|
594
|
+
var TriggersSchema = z21.object({
|
|
595
|
+
beforeToken: FunctionSchema.optional().describe("A pre jwt token generation AWS Lambda trigger."),
|
|
596
|
+
beforeLogin: FunctionSchema.optional().describe("A pre user login AWS Lambda trigger."),
|
|
597
|
+
afterLogin: FunctionSchema.optional().describe("A post user login AWS Lambda trigger."),
|
|
598
|
+
beforeRegister: FunctionSchema.optional().describe("A pre user register AWS Lambda trigger."),
|
|
599
|
+
afterRegister: FunctionSchema.optional().describe("A post user register AWS Lambda trigger."),
|
|
600
|
+
customMessage: FunctionSchema.optional().describe("A custom message AWS Lambda trigger."),
|
|
601
|
+
// /** A custom email sender AWS Lambda trigger */
|
|
602
|
+
// emailSender: FunctionSchema.optional(),
|
|
603
|
+
defineChallenge: FunctionSchema.optional().describe("Defines the authentication challenge."),
|
|
604
|
+
createChallenge: FunctionSchema.optional().describe("Creates an authentication challenge."),
|
|
605
|
+
verifyChallenge: FunctionSchema.optional().describe("Verifies the authentication challenge response.")
|
|
606
|
+
}).describe("Specifies the configuration for AWS Lambda triggers.");
|
|
607
|
+
var AuthSchema = z21.record(
|
|
608
|
+
ResourceIdSchema,
|
|
609
|
+
z21.object({
|
|
610
|
+
access: z21.boolean().default(false).describe("Give access to every function in this stack to your cognito instance."),
|
|
611
|
+
triggers: TriggersSchema.optional()
|
|
612
|
+
})
|
|
613
|
+
).optional().describe("Define the auth triggers in your stack.");
|
|
614
|
+
var AuthDefaultSchema = z21.record(
|
|
615
|
+
ResourceIdSchema,
|
|
616
|
+
z21.object({
|
|
617
|
+
allowUserRegistration: z21.boolean().default(true).describe("Specifies whether users can create an user account or if only the administrator can."),
|
|
618
|
+
messaging: z21.object({
|
|
619
|
+
fromEmail: EmailSchema.describe("Specifies the sender's email address."),
|
|
620
|
+
fromName: z21.string().optional().describe("Specifies the sender's name."),
|
|
621
|
+
replyTo: EmailSchema.optional().describe(
|
|
622
|
+
"The destination to which the receiver of the email should reply."
|
|
623
|
+
)
|
|
624
|
+
}).optional().describe("The email configuration for sending messages."),
|
|
625
|
+
// secret: z.boolean().default(false).describe('Specifies whether you want to generate a client secret.'),
|
|
626
|
+
username: z21.object({
|
|
627
|
+
emailAlias: z21.boolean().default(true).describe("Allow the user email to be used as username."),
|
|
628
|
+
caseSensitive: z21.boolean().default(false).describe(
|
|
629
|
+
"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."
|
|
630
|
+
)
|
|
631
|
+
}).default({}).describe("The username policy."),
|
|
632
|
+
password: z21.object({
|
|
633
|
+
minLength: z21.number().int().min(6).max(99).default(12).describe("Required users to have at least the minimum password length."),
|
|
634
|
+
uppercase: z21.boolean().default(true).describe("Required users to use at least one uppercase letter in their password."),
|
|
635
|
+
lowercase: z21.boolean().default(true).describe("Required users to use at least one lowercase letter in their password."),
|
|
636
|
+
numbers: z21.boolean().default(true).describe("Required users to use at least one number in their password."),
|
|
637
|
+
symbols: z21.boolean().default(true).describe("Required users to use at least one symbol in their password."),
|
|
638
|
+
temporaryPasswordValidity: DurationSchema.default("7 days").describe(
|
|
639
|
+
"The duration a temporary password is valid. If the user doesn't sign in during this time, an administrator must reset their password."
|
|
640
|
+
)
|
|
641
|
+
}).default({}).describe("The password policy."),
|
|
642
|
+
validity: z21.object({
|
|
643
|
+
idToken: DurationSchema.default("1 hour").describe(
|
|
644
|
+
"The ID token time limit. After this limit expires, your user can't use their ID token."
|
|
645
|
+
),
|
|
646
|
+
accessToken: DurationSchema.default("1 hour").describe(
|
|
647
|
+
"The access token time limit. After this limit expires, your user can't use their access token."
|
|
648
|
+
),
|
|
649
|
+
refreshToken: DurationSchema.default("365 days").describe(
|
|
650
|
+
"The refresh token time limit. After this limit expires, your user can't use their refresh token."
|
|
651
|
+
)
|
|
652
|
+
}).default({}).describe("Specifies the validity duration for every JWT token."),
|
|
653
|
+
triggers: TriggersSchema.optional()
|
|
654
|
+
})
|
|
655
|
+
).default({}).describe("Define the authenticatable users in your app.");
|
|
656
|
+
|
|
657
|
+
// src/feature/http/schema.ts
|
|
658
|
+
import { z as z22 } from "zod";
|
|
659
|
+
var RouteSchema2 = z22.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route").transform((v) => v);
|
|
660
|
+
var HttpDefaultSchema = z22.record(
|
|
661
|
+
ResourceIdSchema,
|
|
662
|
+
z22.object({
|
|
663
|
+
domain: ResourceIdSchema.describe("The domain id to link your API with."),
|
|
664
|
+
subDomain: z22.string().optional()
|
|
665
|
+
// auth: ResourceIdSchema.optional(),
|
|
666
|
+
})
|
|
667
|
+
).optional().describe("Define your global HTTP API's.");
|
|
668
|
+
var HttpSchema = z22.record(ResourceIdSchema, z22.record(RouteSchema2, FunctionSchema)).optional().describe("Define routes in your stack for your global HTTP API.");
|
|
669
|
+
|
|
670
|
+
// src/feature/search/schema.ts
|
|
671
|
+
import { z as z23 } from "zod";
|
|
672
|
+
import { gibibytes as gibibytes2 } from "@awsless/size";
|
|
673
|
+
var VersionSchema = z23.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
|
|
674
|
+
var TypeSchema2 = z23.enum([
|
|
675
|
+
"t3.small",
|
|
676
|
+
"t3.medium",
|
|
677
|
+
"t3.large",
|
|
678
|
+
"t3.xlarge",
|
|
679
|
+
"t3.2xlarge",
|
|
680
|
+
"t4g.small",
|
|
681
|
+
"t4g.medium",
|
|
682
|
+
"m3.medium",
|
|
683
|
+
"m3.large",
|
|
684
|
+
"m3.xlarge",
|
|
685
|
+
"m3.2xlarge",
|
|
686
|
+
"m4.large",
|
|
687
|
+
"m4.xlarge",
|
|
688
|
+
"m4.2xlarge",
|
|
689
|
+
"m4.4xlarge",
|
|
690
|
+
"m4.10xlarge",
|
|
691
|
+
"m5.large",
|
|
692
|
+
"m5.xlarge",
|
|
693
|
+
"m5.2xlarge",
|
|
694
|
+
"m5.4xlarge",
|
|
695
|
+
"m5.12xlarge",
|
|
696
|
+
"m5.24xlarge",
|
|
697
|
+
"r5.large",
|
|
698
|
+
"r5.xlarge",
|
|
699
|
+
"r5.2xlarge",
|
|
700
|
+
"r5.4xlarge",
|
|
701
|
+
"r5.12xlarge",
|
|
702
|
+
"r5.24xlarge",
|
|
703
|
+
"c5.large",
|
|
704
|
+
"c5.xlarge",
|
|
705
|
+
"c5.2xlarge",
|
|
706
|
+
"c5.4xlarge",
|
|
707
|
+
"c5.9xlarge",
|
|
708
|
+
"c5.18xlarge",
|
|
709
|
+
"or1.medium",
|
|
710
|
+
"or1.large",
|
|
711
|
+
"or1.xlarge",
|
|
712
|
+
"or1.2xlarge",
|
|
713
|
+
"or1.4xlarge",
|
|
714
|
+
"or1.8xlarge",
|
|
715
|
+
"or1.12xlarge",
|
|
716
|
+
"or1.16xlarge",
|
|
717
|
+
"ultrawarm1.medium",
|
|
718
|
+
"ultrawarm1.large",
|
|
719
|
+
"ultrawarm1.xlarge",
|
|
720
|
+
"r3.large",
|
|
721
|
+
"r3.xlarge",
|
|
722
|
+
"r3.2xlarge",
|
|
723
|
+
"r3.4xlarge",
|
|
724
|
+
"r3.8xlarge",
|
|
725
|
+
"i2.xlarge",
|
|
726
|
+
"i2.2xlarge",
|
|
727
|
+
"d2.xlarge",
|
|
728
|
+
"d2.2xlarge",
|
|
729
|
+
"d2.4xlarge",
|
|
730
|
+
"d2.8xlarge",
|
|
731
|
+
"c4.large",
|
|
732
|
+
"c4.xlarge",
|
|
733
|
+
"c4.2xlarge",
|
|
734
|
+
"c4.4xlarge",
|
|
735
|
+
"c4.8xlarge",
|
|
736
|
+
"r4.large",
|
|
737
|
+
"r4.xlarge",
|
|
738
|
+
"r4.2xlarge",
|
|
739
|
+
"r4.4xlarge",
|
|
740
|
+
"r4.8xlarge",
|
|
741
|
+
"r4.16xlarge",
|
|
742
|
+
"i3.large",
|
|
743
|
+
"i3.xlarge",
|
|
744
|
+
"i3.2xlarge",
|
|
745
|
+
"i3.4xlarge",
|
|
746
|
+
"i3.8xlarge",
|
|
747
|
+
"i3.16xlarge",
|
|
748
|
+
"r6g.large",
|
|
749
|
+
"r6g.xlarge",
|
|
750
|
+
"r6g.2xlarge",
|
|
751
|
+
"r6g.4xlarge",
|
|
752
|
+
"r6g.8xlarge",
|
|
753
|
+
"r6g.12xlarge",
|
|
754
|
+
"m6g.large",
|
|
755
|
+
"m6g.xlarge",
|
|
756
|
+
"m6g.2xlarge",
|
|
757
|
+
"m6g.4xlarge",
|
|
758
|
+
"m6g.8xlarge",
|
|
759
|
+
"m6g.12xlarge",
|
|
760
|
+
"c6g.large",
|
|
761
|
+
"c6g.xlarge",
|
|
762
|
+
"c6g.2xlarge",
|
|
763
|
+
"c6g.4xlarge",
|
|
764
|
+
"c6g.8xlarge",
|
|
765
|
+
"c6g.12xlarge",
|
|
766
|
+
"r6gd.large",
|
|
767
|
+
"r6gd.xlarge",
|
|
768
|
+
"r6gd.2xlarge",
|
|
769
|
+
"r6gd.4xlarge",
|
|
770
|
+
"r6gd.8xlarge",
|
|
771
|
+
"r6gd.12xlarge",
|
|
772
|
+
"r6gd.16xlarge"
|
|
773
|
+
]);
|
|
774
|
+
var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes2(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes2(100)), "Maximum storage size is 100 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GiB.");
|
|
775
|
+
var SearchsSchema = z23.record(
|
|
776
|
+
ResourceIdSchema,
|
|
777
|
+
z23.object({
|
|
778
|
+
type: TypeSchema2.default("t3.small"),
|
|
779
|
+
count: z23.number().int().min(1).default(1),
|
|
780
|
+
version: VersionSchema.default("2.13"),
|
|
781
|
+
storage: StorageSizeSchema.default("10 GB"),
|
|
782
|
+
vpc: z23.boolean().default(false)
|
|
783
|
+
})
|
|
784
|
+
).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
|
|
785
|
+
|
|
786
|
+
// src/feature/site/schema.ts
|
|
787
|
+
import { z as z24 } from "zod";
|
|
788
|
+
var ErrorResponsePathSchema = z24.string().describe(
|
|
789
|
+
"The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.\n - We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable."
|
|
790
|
+
);
|
|
791
|
+
var StatusCodeSchema = z24.number().int().positive().optional().describe(
|
|
792
|
+
"The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:\n- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200, the response typically won't be intercepted.\n- If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.\n- You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down."
|
|
793
|
+
);
|
|
794
|
+
var MinTTLSchema = DurationSchema.describe(
|
|
795
|
+
"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."
|
|
796
|
+
);
|
|
797
|
+
var ErrorResponseSchema = z24.union([
|
|
798
|
+
ErrorResponsePathSchema,
|
|
799
|
+
z24.object({
|
|
800
|
+
path: ErrorResponsePathSchema,
|
|
801
|
+
statusCode: StatusCodeSchema.optional(),
|
|
802
|
+
minTTL: MinTTLSchema.optional()
|
|
803
|
+
})
|
|
804
|
+
]).optional();
|
|
805
|
+
var SitesSchema = z24.record(
|
|
806
|
+
ResourceIdSchema,
|
|
807
|
+
z24.object({
|
|
808
|
+
domain: ResourceIdSchema.describe("The domain id to link your site with."),
|
|
809
|
+
subDomain: z24.string().optional(),
|
|
810
|
+
static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
|
|
811
|
+
ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
|
|
812
|
+
// bind: z.object({
|
|
813
|
+
// auth:
|
|
814
|
+
// h
|
|
815
|
+
// }).optional(),
|
|
816
|
+
// ssr: z.union([
|
|
817
|
+
// FunctionSchema.optional(),
|
|
818
|
+
// z.object({
|
|
819
|
+
// consumer: FunctionSchema.optional(),
|
|
820
|
+
// responseStreaming: z.boolean().default(false),
|
|
821
|
+
// build: z.string().optional(),
|
|
822
|
+
// }),
|
|
823
|
+
// ]),
|
|
824
|
+
errors: z24.object({
|
|
825
|
+
400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
|
|
826
|
+
403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
|
|
827
|
+
404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
|
|
828
|
+
405: ErrorResponseSchema.describe("Customize a `405 Method Not Allowed` response."),
|
|
829
|
+
414: ErrorResponseSchema.describe("Customize a `414 Request-URI` response."),
|
|
830
|
+
416: ErrorResponseSchema.describe("Customize a `416 Range Not` response."),
|
|
831
|
+
500: ErrorResponseSchema.describe("Customize a `500 Internal Server` response."),
|
|
832
|
+
501: ErrorResponseSchema.describe("Customize a `501 Not Implemented` response."),
|
|
833
|
+
502: ErrorResponseSchema.describe("Customize a `502 Bad Gateway` response."),
|
|
834
|
+
503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
|
|
835
|
+
504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
|
|
836
|
+
}).optional().describe("Customize the error responses for specific HTTP status codes."),
|
|
837
|
+
cors: z24.object({
|
|
838
|
+
override: z24.boolean().default(false),
|
|
839
|
+
maxAge: DurationSchema.default("365 days"),
|
|
840
|
+
exposeHeaders: z24.string().array().optional(),
|
|
841
|
+
credentials: z24.boolean().default(false),
|
|
842
|
+
headers: z24.string().array().default(["*"]),
|
|
843
|
+
origins: z24.string().array().default(["*"]),
|
|
844
|
+
methods: z24.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
|
|
845
|
+
}).optional().describe("Define the cors headers."),
|
|
846
|
+
security: z24.object({
|
|
847
|
+
// contentSecurityPolicy: z.object({
|
|
848
|
+
// override: z.boolean().default(false),
|
|
849
|
+
// policy: z.string(),
|
|
850
|
+
// })
|
|
851
|
+
// contentSecurityPolicy?: {
|
|
852
|
+
// override?: boolean
|
|
853
|
+
// contentSecurityPolicy: string
|
|
854
|
+
// }
|
|
855
|
+
// contentTypeOptions?: {
|
|
856
|
+
// override?: boolean
|
|
857
|
+
// }
|
|
858
|
+
// frameOptions?: {
|
|
859
|
+
// override?: boolean
|
|
860
|
+
// frameOption?: 'deny' | 'same-origin'
|
|
861
|
+
// }
|
|
862
|
+
// referrerPolicy?: {
|
|
863
|
+
// override?: boolean
|
|
864
|
+
// referrerPolicy?: (
|
|
865
|
+
// 'no-referrer' |
|
|
866
|
+
// 'no-referrer-when-downgrade' |
|
|
867
|
+
// 'origin' |
|
|
868
|
+
// 'origin-when-cross-origin' |
|
|
869
|
+
// 'same-origin' |
|
|
870
|
+
// 'strict-origin' |
|
|
871
|
+
// 'strict-origin-when-cross-origin' |
|
|
872
|
+
// 'unsafe-url'
|
|
873
|
+
// )
|
|
874
|
+
// }
|
|
875
|
+
// strictTransportSecurity?: {
|
|
876
|
+
// maxAge?: Duration
|
|
877
|
+
// includeSubdomains?: boolean
|
|
878
|
+
// override?: boolean
|
|
879
|
+
// preload?: boolean
|
|
880
|
+
// }
|
|
881
|
+
// xssProtection?: {
|
|
882
|
+
// override?: boolean
|
|
883
|
+
// enable?: boolean
|
|
884
|
+
// modeBlock?: boolean
|
|
885
|
+
// reportUri?: string
|
|
886
|
+
// }
|
|
887
|
+
}).optional().describe("Define the security policy."),
|
|
888
|
+
cache: z24.object({
|
|
889
|
+
cookies: z24.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
|
|
890
|
+
headers: z24.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
|
|
891
|
+
queries: z24.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
|
|
892
|
+
}).optional().describe(
|
|
893
|
+
"Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
|
|
894
|
+
)
|
|
895
|
+
})
|
|
896
|
+
).optional().describe("Define the sites in your stack.");
|
|
897
|
+
|
|
898
|
+
// src/feature/task/schema.ts
|
|
899
|
+
import { z as z25 } from "zod";
|
|
900
|
+
var RetryAttemptsSchema2 = z25.number().int().min(0).max(2).describe(
|
|
901
|
+
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
902
|
+
);
|
|
903
|
+
var TaskSchema = z25.union([
|
|
904
|
+
LocalFileSchema.transform((file) => ({
|
|
905
|
+
consumer: { file },
|
|
906
|
+
retryAttempts: void 0
|
|
907
|
+
})),
|
|
908
|
+
z25.object({
|
|
909
|
+
consumer: FunctionSchema,
|
|
910
|
+
retryAttempts: RetryAttemptsSchema2.optional()
|
|
911
|
+
})
|
|
912
|
+
]);
|
|
913
|
+
var TasksSchema = z25.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
914
|
+
|
|
915
|
+
// src/config/stack.ts
|
|
916
|
+
var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
|
|
917
|
+
var NameSchema = ResourceIdSchema.refine((name) => !["base"].includes(name), {
|
|
918
|
+
message: `Stack name can't be a reserved name.`
|
|
919
|
+
}).describe("Stack name.");
|
|
920
|
+
var StackSchema = z26.object({
|
|
921
|
+
$schema: z26.string().optional(),
|
|
922
|
+
name: NameSchema,
|
|
923
|
+
depends: DependsSchema,
|
|
924
|
+
onFailure: OnFailureSchema,
|
|
925
|
+
auth: AuthSchema,
|
|
926
|
+
graphql: GraphQLSchema,
|
|
927
|
+
http: HttpSchema,
|
|
928
|
+
rest: RestSchema,
|
|
929
|
+
configs: ConfigsSchema,
|
|
930
|
+
crons: CronsSchema,
|
|
931
|
+
caches: CachesSchema,
|
|
932
|
+
topics: TopicsSchema,
|
|
933
|
+
subscribers: SubscribersSchema,
|
|
934
|
+
functions: FunctionsSchema,
|
|
935
|
+
tasks: TasksSchema,
|
|
936
|
+
tables: TablesSchema,
|
|
937
|
+
stores: StoresSchema,
|
|
938
|
+
queues: QueuesSchema,
|
|
939
|
+
pubsub: PubSubSchema,
|
|
940
|
+
searchs: SearchsSchema,
|
|
941
|
+
sites: SitesSchema,
|
|
942
|
+
tests: TestsSchema
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// src/config/app.ts
|
|
946
|
+
import { z as z29 } from "zod";
|
|
947
|
+
|
|
948
|
+
// src/config/schema/region.ts
|
|
949
|
+
import { z as z27 } from "zod";
|
|
950
|
+
var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
|
|
951
|
+
var AF = ["af-south-1"];
|
|
952
|
+
var AP = [
|
|
953
|
+
"ap-east-1",
|
|
954
|
+
"ap-south-2",
|
|
955
|
+
"ap-southeast-3",
|
|
956
|
+
"ap-southeast-4",
|
|
957
|
+
"ap-south-1",
|
|
958
|
+
"ap-northeast-3",
|
|
959
|
+
"ap-northeast-2",
|
|
960
|
+
"ap-southeast-1",
|
|
961
|
+
"ap-southeast-2",
|
|
962
|
+
"ap-northeast-1"
|
|
963
|
+
];
|
|
964
|
+
var CA = ["ca-central-1"];
|
|
965
|
+
var EU = [
|
|
966
|
+
"eu-central-1",
|
|
967
|
+
"eu-west-1",
|
|
968
|
+
"eu-west-2",
|
|
969
|
+
"eu-south-1",
|
|
970
|
+
"eu-west-3",
|
|
971
|
+
"eu-south-2",
|
|
972
|
+
"eu-north-1",
|
|
973
|
+
"eu-central-2"
|
|
974
|
+
];
|
|
975
|
+
var ME = ["me-south-1", "me-central-1"];
|
|
976
|
+
var SA = ["sa-east-1"];
|
|
977
|
+
var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
|
|
978
|
+
var RegionSchema = z27.enum(regions);
|
|
979
|
+
|
|
980
|
+
// src/feature/domain/schema.ts
|
|
981
|
+
import { z as z28 } from "zod";
|
|
982
|
+
var DomainNameSchema = z28.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
|
|
983
|
+
"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."
|
|
984
|
+
);
|
|
985
|
+
var DNSTypeSchema = z28.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
|
|
986
|
+
var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
|
|
987
|
+
var RecordsSchema = z28.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
|
|
988
|
+
var DomainsDefaultSchema = z28.record(
|
|
989
|
+
ResourceIdSchema,
|
|
990
|
+
z28.object({
|
|
991
|
+
domain: DomainNameSchema.describe("Define the domain name"),
|
|
992
|
+
dns: z28.object({
|
|
993
|
+
name: DomainNameSchema.optional(),
|
|
994
|
+
type: DNSTypeSchema,
|
|
995
|
+
ttl: TTLSchema,
|
|
996
|
+
records: RecordsSchema
|
|
997
|
+
}).array().optional().describe("Define the domain dns records")
|
|
998
|
+
})
|
|
999
|
+
).optional().describe("Define the domains for your application.");
|
|
1000
|
+
|
|
1001
|
+
// src/config/app.ts
|
|
1002
|
+
var AppSchema = z29.object({
|
|
1003
|
+
$schema: z29.string().optional(),
|
|
1004
|
+
name: ResourceIdSchema.describe("App name."),
|
|
1005
|
+
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
1006
|
+
profile: z29.string().describe("The AWS profile to deploy to."),
|
|
1007
|
+
// stage: z
|
|
1008
|
+
// .string()
|
|
1009
|
+
// .regex(/^[a-z]+$/)
|
|
1010
|
+
// .default('prod')
|
|
1011
|
+
// .describe('The deployment stage.'),
|
|
1012
|
+
defaults: z29.object({
|
|
1013
|
+
auth: AuthDefaultSchema,
|
|
1014
|
+
domains: DomainsDefaultSchema,
|
|
1015
|
+
function: FunctionDefaultSchema,
|
|
1016
|
+
queue: QueueDefaultSchema,
|
|
1017
|
+
graphql: GraphQLDefaultSchema,
|
|
1018
|
+
http: HttpDefaultSchema,
|
|
1019
|
+
rest: RestDefaultSchema
|
|
1020
|
+
}).default({}).describe("Default properties")
|
|
1021
|
+
});
|
|
1022
|
+
|
|
1023
|
+
// cli/build-json-schema.ts
|
|
1024
|
+
import { writeFileSync } from "fs";
|
|
1025
|
+
import { join as join3 } from "path";
|
|
1026
|
+
var generateJsonSchema = (props) => {
|
|
1027
|
+
const file = join3(process.cwd(), `dist/${props.name}.json`);
|
|
1028
|
+
const schema = zodToJsonSchema(props.schema, {
|
|
1029
|
+
name: props.name,
|
|
1030
|
+
// errorMessages: true,
|
|
1031
|
+
markdownDescription: true,
|
|
1032
|
+
$refStrategy: "none"
|
|
1033
|
+
});
|
|
1034
|
+
appendDefaults(schema);
|
|
1035
|
+
schema.title = props.title;
|
|
1036
|
+
writeFileSync(file, JSON.stringify(schema));
|
|
1037
|
+
};
|
|
1038
|
+
var appendDefaults = (object) => {
|
|
1039
|
+
if (Array.isArray(object)) {
|
|
1040
|
+
object.forEach(appendDefaults);
|
|
1041
|
+
}
|
|
1042
|
+
if (typeof object === "object" && object !== null) {
|
|
1043
|
+
if ("default" in object && "type" in object) {
|
|
1044
|
+
if ("description" in object) {
|
|
1045
|
+
object.description += `
|
|
1046
|
+
|
|
1047
|
+
@default ${JSON.stringify(object.default)}`;
|
|
1048
|
+
}
|
|
1049
|
+
if ("markdownDescription" in object) {
|
|
1050
|
+
object.markdownDescription += `
|
|
1051
|
+
|
|
1052
|
+
@default \`\`\`${JSON.stringify(object.default)}\`\`\``;
|
|
1053
|
+
}
|
|
1054
|
+
} else {
|
|
1055
|
+
Object.values(object).forEach(appendDefaults);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
generateJsonSchema({
|
|
1060
|
+
schema: AppSchema,
|
|
1061
|
+
name: "app",
|
|
1062
|
+
title: "Awsless App Config"
|
|
1063
|
+
});
|
|
1064
|
+
generateJsonSchema({
|
|
1065
|
+
schema: StackSchema,
|
|
1066
|
+
name: "stack",
|
|
1067
|
+
title: "Awsless Stack Config"
|
|
1068
|
+
});
|