@awsless/awsless 0.0.226 → 0.0.228
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 +136 -115
- package/dist/build-json-schema.js +48 -33
- package/dist/stack.json +1 -1
- package/dist/test-global-setup.js +7 -0
- package/package.json +12 -11
package/dist/bin.js
CHANGED
|
@@ -671,36 +671,51 @@ var TablesSchema = z17.record(
|
|
|
671
671
|
|
|
672
672
|
// src/feature/store/schema.ts
|
|
673
673
|
import { z as z18 } from "zod";
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
)
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
674
|
+
var StoresSchema = z18.union([
|
|
675
|
+
z18.array(ResourceIdSchema).transform((list4) => {
|
|
676
|
+
const stores = {};
|
|
677
|
+
for (const key in list4) {
|
|
678
|
+
stores[key] = {};
|
|
679
|
+
}
|
|
680
|
+
return stores;
|
|
681
|
+
}),
|
|
682
|
+
z18.record(
|
|
683
|
+
ResourceIdSchema,
|
|
684
|
+
z18.object({
|
|
685
|
+
// lambdaConfigs: LambdaConfigsSchema,
|
|
686
|
+
// cors: CorsSchema,
|
|
687
|
+
versioning: z18.boolean().default(false).describe("Enable versioning of your store."),
|
|
688
|
+
events: z18.object({
|
|
689
|
+
// create
|
|
690
|
+
"created:*": FunctionSchema.describe(
|
|
691
|
+
"Subscribe to notifications regardless of the API that was used to create an object."
|
|
692
|
+
),
|
|
693
|
+
"created:put": FunctionSchema.describe(
|
|
694
|
+
"Subscribe to notifications when an object is created using the PUT API operation."
|
|
695
|
+
),
|
|
696
|
+
"created:post": FunctionSchema.describe(
|
|
697
|
+
"Subscribe to notifications when an object is created using the POST API operation."
|
|
698
|
+
),
|
|
699
|
+
"created:copy": FunctionSchema.describe(
|
|
700
|
+
"Subscribe to notifications when an object is created using the COPY API operation."
|
|
701
|
+
),
|
|
702
|
+
"created:upload": FunctionSchema.describe(
|
|
703
|
+
"Subscribe to notifications when an object multipart upload has been completed."
|
|
704
|
+
),
|
|
705
|
+
// remove
|
|
706
|
+
"removed:*": FunctionSchema.describe(
|
|
707
|
+
"Subscribe to notifications when an object is deleted or a delete marker for a versioned object is created."
|
|
708
|
+
),
|
|
709
|
+
"removed:delete": FunctionSchema.describe(
|
|
710
|
+
"Subscribe to notifications when an object is deleted"
|
|
711
|
+
),
|
|
712
|
+
"removed:marker": FunctionSchema.describe(
|
|
713
|
+
"Subscribe to notifications when a delete marker for a versioned object is created."
|
|
714
|
+
)
|
|
715
|
+
}).optional().describe("Describes the store events you want to subscribe too.")
|
|
716
|
+
})
|
|
717
|
+
)
|
|
718
|
+
]).optional().describe("Define the stores in your stack.");
|
|
704
719
|
|
|
705
720
|
// src/feature/pubsub/schema.ts
|
|
706
721
|
import { z as z19 } from "zod";
|
|
@@ -2098,6 +2113,17 @@ var build = (type, name, builder) => {
|
|
|
2098
2113
|
});
|
|
2099
2114
|
};
|
|
2100
2115
|
|
|
2116
|
+
// src/feature/on-failure/util.ts
|
|
2117
|
+
var getGlobalOnFailure = (ctx) => {
|
|
2118
|
+
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
2119
|
+
};
|
|
2120
|
+
var hasOnFailure = (stacks) => {
|
|
2121
|
+
const onFailure = stacks.find((stack) => {
|
|
2122
|
+
return typeof stack.onFailure !== "undefined";
|
|
2123
|
+
});
|
|
2124
|
+
return !!onFailure;
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2101
2127
|
// src/feature/function/util.ts
|
|
2102
2128
|
var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
2103
2129
|
let name;
|
|
@@ -2227,6 +2253,24 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2227
2253
|
code
|
|
2228
2254
|
};
|
|
2229
2255
|
};
|
|
2256
|
+
var createAsyncLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
2257
|
+
const result = createLambdaFunction(group, ctx, ns, id, local2);
|
|
2258
|
+
const props = deepmerge(ctx.appConfig.defaults.function, local2);
|
|
2259
|
+
result.lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
2260
|
+
const invokeConfig = new aws2.lambda.EventInvokeConfig(group, "async", {
|
|
2261
|
+
functionArn: result.lambda.arn,
|
|
2262
|
+
retryAttempts: props.retryAttempts,
|
|
2263
|
+
onFailure: getGlobalOnFailure(ctx)
|
|
2264
|
+
});
|
|
2265
|
+
invokeConfig.dependsOn(result.policy);
|
|
2266
|
+
if (hasOnFailure(ctx.stackConfigs)) {
|
|
2267
|
+
result.policy.addStatement({
|
|
2268
|
+
actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
|
|
2269
|
+
resources: [getGlobalOnFailure(ctx)]
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
return result;
|
|
2273
|
+
};
|
|
2230
2274
|
|
|
2231
2275
|
// src/feature/cron/index.ts
|
|
2232
2276
|
var cronFeature = defineFeature({
|
|
@@ -2234,8 +2278,7 @@ var cronFeature = defineFeature({
|
|
|
2234
2278
|
onStack(ctx) {
|
|
2235
2279
|
for (const [id, props] of Object.entries(ctx.stackConfig.crons ?? {})) {
|
|
2236
2280
|
const group = new Node3(ctx.stack, "cron", id);
|
|
2237
|
-
const { lambda } =
|
|
2238
|
-
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
2281
|
+
const { lambda } = createAsyncLambdaFunction(group, ctx, "cron", id, props.consumer);
|
|
2239
2282
|
const rule = new aws3.events.Rule(group, "rule", {
|
|
2240
2283
|
name: formatLocalResourceName(ctx.app.name, ctx.stack.name, this.name, id),
|
|
2241
2284
|
schedule: props.schedule,
|
|
@@ -2987,17 +3030,6 @@ var graphqlFeature = defineFeature({
|
|
|
2987
3030
|
}
|
|
2988
3031
|
});
|
|
2989
3032
|
|
|
2990
|
-
// src/feature/on-failure/util.ts
|
|
2991
|
-
var getGlobalOnFailure = (ctx) => {
|
|
2992
|
-
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
2993
|
-
};
|
|
2994
|
-
var hasOnFailure = (stacks) => {
|
|
2995
|
-
const onFailure = stacks.find((stack) => {
|
|
2996
|
-
return typeof stack.onFailure !== "undefined";
|
|
2997
|
-
});
|
|
2998
|
-
return !!onFailure;
|
|
2999
|
-
};
|
|
3000
|
-
|
|
3001
3033
|
// src/feature/on-failure/index.ts
|
|
3002
3034
|
import { Node as Node7, aws as aws7 } from "@awsless/formation";
|
|
3003
3035
|
var onFailureFeature = defineFeature({
|
|
@@ -3057,7 +3089,7 @@ var pubsubFeature = defineFeature({
|
|
|
3057
3089
|
onStack(ctx) {
|
|
3058
3090
|
for (const [id, props] of Object.entries(ctx.stackConfig.pubsub ?? {})) {
|
|
3059
3091
|
const group = new Node8(ctx.stack, "pubsub", id);
|
|
3060
|
-
const { lambda } =
|
|
3092
|
+
const { lambda } = createAsyncLambdaFunction(group, ctx, `pubsub`, id, props.consumer);
|
|
3061
3093
|
const name = formatLocalResourceName(ctx.app.name, ctx.stack.name, "pubsub", id);
|
|
3062
3094
|
const topic = new aws8.iot.TopicRule(group, "rule", {
|
|
3063
3095
|
name: name.replaceAll("-", "_"),
|
|
@@ -3195,35 +3227,38 @@ var storeFeature = defineFeature({
|
|
|
3195
3227
|
for (const [id, props] of Object.entries(ctx.stackConfig.stores ?? {})) {
|
|
3196
3228
|
const group = new Node10(ctx.stack, "store", id);
|
|
3197
3229
|
const lambdaConfigs = [];
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3230
|
+
const eventMap = {
|
|
3231
|
+
"created:*": "s3:ObjectCreated:*",
|
|
3232
|
+
"created:put": "s3:ObjectCreated:Put",
|
|
3233
|
+
"created:post": "s3:ObjectCreated:Post",
|
|
3234
|
+
"created:copy": "s3:ObjectCreated:Copy",
|
|
3235
|
+
"created:upload": "s3:ObjectCreated:CompleteMultipartUpload",
|
|
3236
|
+
"removed:*": "s3:ObjectRemoved:*",
|
|
3237
|
+
"removed:delete": "s3:ObjectRemoved:Delete",
|
|
3238
|
+
"removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
|
|
3239
|
+
};
|
|
3240
|
+
for (const [event, funcProps] of Object.entries(props.events ?? {})) {
|
|
3241
|
+
const { lambda } = createAsyncLambdaFunction(group, ctx, `store`, id, funcProps);
|
|
3207
3242
|
lambdaConfigs.push({
|
|
3208
|
-
event,
|
|
3243
|
+
event: eventMap[event],
|
|
3209
3244
|
function: lambda.arn
|
|
3210
3245
|
});
|
|
3211
3246
|
}
|
|
3212
3247
|
const bucket = new aws10.s3.Bucket(group, "store", {
|
|
3213
3248
|
name: formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "store", id),
|
|
3214
3249
|
versioning: props.versioning,
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3250
|
+
lambdaConfigs,
|
|
3251
|
+
// cors: props.cors,
|
|
3252
|
+
cors: [
|
|
3253
|
+
// ---------------------------------------------
|
|
3254
|
+
// Support for presigned post requests
|
|
3255
|
+
// ---------------------------------------------
|
|
3256
|
+
{
|
|
3257
|
+
origins: ["*"],
|
|
3258
|
+
methods: ["POST"]
|
|
3259
|
+
}
|
|
3260
|
+
// ---------------------------------------------
|
|
3261
|
+
]
|
|
3227
3262
|
});
|
|
3228
3263
|
ctx.onFunction(({ policy }) => {
|
|
3229
3264
|
policy.addStatement(bucket.permissions);
|
|
@@ -3363,8 +3398,7 @@ var topicFeature = defineFeature({
|
|
|
3363
3398
|
endpoint: props
|
|
3364
3399
|
});
|
|
3365
3400
|
} else if (typeof props === "object") {
|
|
3366
|
-
const { lambda } =
|
|
3367
|
-
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
3401
|
+
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
3368
3402
|
new aws12.sns.Subscription(group, id, {
|
|
3369
3403
|
topicArn,
|
|
3370
3404
|
protocol: "lambda",
|
|
@@ -3465,10 +3499,10 @@ var authFeature = defineFeature({
|
|
|
3465
3499
|
const list4 = {};
|
|
3466
3500
|
for (const [trigger, triggerProps] of Object.entries(props.triggers ?? {})) {
|
|
3467
3501
|
const triggerGroup = new Node14(group, "trigger", trigger);
|
|
3468
|
-
const { lambda, policy } =
|
|
3502
|
+
const { lambda, policy } = createAsyncLambdaFunction(
|
|
3469
3503
|
triggerGroup,
|
|
3470
3504
|
ctx,
|
|
3471
|
-
|
|
3505
|
+
"auth",
|
|
3472
3506
|
`${id}-${trigger}`,
|
|
3473
3507
|
triggerProps
|
|
3474
3508
|
);
|
|
@@ -3787,7 +3821,7 @@ var searchFeature = defineFeature({
|
|
|
3787
3821
|
|
|
3788
3822
|
// src/feature/site/index.ts
|
|
3789
3823
|
import { Asset as Asset3, Node as Node17, aws as aws17 } from "@awsless/formation";
|
|
3790
|
-
import { days as days3, seconds as
|
|
3824
|
+
import { days as days3, seconds as seconds3 } from "@awsless/duration";
|
|
3791
3825
|
import { glob as glob2 } from "glob";
|
|
3792
3826
|
import { join as join8 } from "path";
|
|
3793
3827
|
|
|
@@ -3900,7 +3934,7 @@ var siteFeature = defineFeature({
|
|
|
3900
3934
|
}
|
|
3901
3935
|
const cache = new aws17.cloudFront.CachePolicy(group, "cache", {
|
|
3902
3936
|
name,
|
|
3903
|
-
minTtl:
|
|
3937
|
+
minTtl: seconds3(1),
|
|
3904
3938
|
maxTtl: days3(365),
|
|
3905
3939
|
defaultTtl: days3(1),
|
|
3906
3940
|
...props.cache
|
|
@@ -4082,7 +4116,7 @@ var restFeature = defineFeature({
|
|
|
4082
4116
|
// src/feature/task/index.ts
|
|
4083
4117
|
import { camelCase as camelCase6 } from "change-case";
|
|
4084
4118
|
import { relative as relative4 } from "path";
|
|
4085
|
-
import { Node as Node19
|
|
4119
|
+
import { Node as Node19 } from "@awsless/formation";
|
|
4086
4120
|
var typeGenCode7 = `
|
|
4087
4121
|
import { InvokeOptions } from '@awsless/lambda'
|
|
4088
4122
|
import type { Mock } from 'vitest'
|
|
@@ -4131,20 +4165,7 @@ var taskFeature = defineFeature({
|
|
|
4131
4165
|
onStack(ctx) {
|
|
4132
4166
|
for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
|
|
4133
4167
|
const group = new Node19(ctx.stack, "task", id);
|
|
4134
|
-
|
|
4135
|
-
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
4136
|
-
const invokeConfig = new aws19.lambda.EventInvokeConfig(group, "config", {
|
|
4137
|
-
functionArn: lambda.arn,
|
|
4138
|
-
retryAttempts: props.retryAttempts,
|
|
4139
|
-
onFailure: getGlobalOnFailure(ctx)
|
|
4140
|
-
});
|
|
4141
|
-
invokeConfig.dependsOn(policy);
|
|
4142
|
-
if (hasOnFailure(ctx.stackConfigs)) {
|
|
4143
|
-
policy.addStatement({
|
|
4144
|
-
actions: ["sqs:SendMessage", "sqs:GetQueueUrl"],
|
|
4145
|
-
resources: [getGlobalOnFailure(ctx)]
|
|
4146
|
-
});
|
|
4147
|
-
}
|
|
4168
|
+
createAsyncLambdaFunction(group, ctx, "task", id, props.consumer);
|
|
4148
4169
|
}
|
|
4149
4170
|
}
|
|
4150
4171
|
});
|
|
@@ -4488,20 +4509,20 @@ var config = (program2) => {
|
|
|
4488
4509
|
import { confirm as confirm3 } from "@clack/prompts";
|
|
4489
4510
|
|
|
4490
4511
|
// src/util/workspace.ts
|
|
4491
|
-
import { WorkSpace, aws as
|
|
4512
|
+
import { WorkSpace, aws as aws19, local } from "@awsless/formation";
|
|
4492
4513
|
import { minutes as minutes4 } from "@awsless/duration";
|
|
4493
4514
|
import { dirname as dirname8, join as join9 } from "path";
|
|
4494
4515
|
import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4495
4516
|
var createWorkSpace = (props) => {
|
|
4496
|
-
const lockProvider = new
|
|
4517
|
+
const lockProvider = new aws19.dynamodb.LockProvider({
|
|
4497
4518
|
...props,
|
|
4498
4519
|
tableName: "awsless-locks"
|
|
4499
4520
|
});
|
|
4500
|
-
const stateProvider = new
|
|
4521
|
+
const stateProvider = new aws19.s3.StateProvider({
|
|
4501
4522
|
...props,
|
|
4502
4523
|
bucket: "awsless-state"
|
|
4503
4524
|
});
|
|
4504
|
-
const cloudProviders =
|
|
4525
|
+
const cloudProviders = aws19.createCloudProviders({
|
|
4505
4526
|
...props,
|
|
4506
4527
|
timeout: minutes4(60)
|
|
4507
4528
|
});
|
|
@@ -4575,7 +4596,7 @@ var del2 = (program2) => {
|
|
|
4575
4596
|
import { confirm as confirm4 } from "@clack/prompts";
|
|
4576
4597
|
|
|
4577
4598
|
// src/cli/ui/complex/run-tests.ts
|
|
4578
|
-
import { join as
|
|
4599
|
+
import { join as join11 } from "path";
|
|
4579
4600
|
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile3 } from "fs/promises";
|
|
4580
4601
|
|
|
4581
4602
|
// src/test/reporter.ts
|
|
@@ -4633,14 +4654,8 @@ var CustomReporter = class {
|
|
|
4633
4654
|
this.cache = cache;
|
|
4634
4655
|
}
|
|
4635
4656
|
}
|
|
4636
|
-
onUserConsoleLog(
|
|
4637
|
-
|
|
4638
|
-
const test2 = this.ctx?.state.idMap.get(log10.taskId);
|
|
4639
|
-
if (test2) {
|
|
4640
|
-
test2.name;
|
|
4641
|
-
}
|
|
4642
|
-
}
|
|
4643
|
-
this.logs.push(log10.content.trimEnd());
|
|
4657
|
+
onUserConsoleLog(log9) {
|
|
4658
|
+
this.logs.push(log9.content.trimEnd());
|
|
4644
4659
|
}
|
|
4645
4660
|
runningTask(tasks) {
|
|
4646
4661
|
return tasks.find((t) => t.result?.state === "run");
|
|
@@ -4664,7 +4679,10 @@ import { startVitest } from "vitest/node";
|
|
|
4664
4679
|
import commonjs3 from "@rollup/plugin-commonjs";
|
|
4665
4680
|
import nodeResolve3 from "@rollup/plugin-node-resolve";
|
|
4666
4681
|
import json3 from "@rollup/plugin-json";
|
|
4682
|
+
import { dirname as dirname9, join as join10 } from "path";
|
|
4683
|
+
import { fileURLToPath } from "url";
|
|
4667
4684
|
var startTest = async (props) => {
|
|
4685
|
+
const __dirname = dirname9(fileURLToPath(import.meta.url));
|
|
4668
4686
|
const result = await startVitest(
|
|
4669
4687
|
"test",
|
|
4670
4688
|
props.filters,
|
|
@@ -4677,7 +4695,11 @@ var startTest = async (props) => {
|
|
|
4677
4695
|
include: ["**/*.{js,jsx,ts,tsx}"],
|
|
4678
4696
|
exclude: ["**/_*", "**/_*/**", ...configDefaults.exclude],
|
|
4679
4697
|
globals: true,
|
|
4680
|
-
reporters: props.reporter
|
|
4698
|
+
reporters: props.reporter,
|
|
4699
|
+
globalSetup: join10(__dirname, "test-global-setup.js")
|
|
4700
|
+
// env: {
|
|
4701
|
+
// TZ: 'UTC',
|
|
4702
|
+
// },
|
|
4681
4703
|
// typecheck: {
|
|
4682
4704
|
// enabled: true,
|
|
4683
4705
|
// // ignoreSourceErrors: false,
|
|
@@ -4732,7 +4754,7 @@ var logTestLogs = (event) => {
|
|
|
4732
4754
|
log8.message(color.info.bold.inverse(" LOGS "), {
|
|
4733
4755
|
symbol: color.dim(icon.dot)
|
|
4734
4756
|
});
|
|
4735
|
-
log8.message(event.logs.map((
|
|
4757
|
+
log8.message(event.logs.map((log9) => wrap(log9, { hard: true })).join("\n"));
|
|
4736
4758
|
}
|
|
4737
4759
|
};
|
|
4738
4760
|
var logTestErrors = (event) => {
|
|
@@ -4770,7 +4792,7 @@ var logTestErrors = (event) => {
|
|
|
4770
4792
|
var runTest = async (stack, dir, filters) => {
|
|
4771
4793
|
await mkdir3(directories.test, { recursive: true });
|
|
4772
4794
|
const fingerprint = await fingerprintFromDirectory(dir);
|
|
4773
|
-
const file =
|
|
4795
|
+
const file = join11(directories.test, `${stack}.json`);
|
|
4774
4796
|
const exists = await fileExist(file);
|
|
4775
4797
|
if (exists && !process.env.NO_CACHE) {
|
|
4776
4798
|
const raw = await readFile7(file, { encoding: "utf8" });
|
|
@@ -4877,7 +4899,7 @@ var deploy = (program2) => {
|
|
|
4877
4899
|
};
|
|
4878
4900
|
|
|
4879
4901
|
// src/cli/command/diff.ts
|
|
4880
|
-
import { WorkSpace as WorkSpace2, aws as
|
|
4902
|
+
import { WorkSpace as WorkSpace2, aws as aws20 } from "@awsless/formation";
|
|
4881
4903
|
import chalk7 from "chalk";
|
|
4882
4904
|
var diff = (program2) => {
|
|
4883
4905
|
program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
|
|
@@ -4889,12 +4911,12 @@ var diff = (program2) => {
|
|
|
4889
4911
|
const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
|
|
4890
4912
|
await buildAssets(builders);
|
|
4891
4913
|
const workspace = new WorkSpace2({
|
|
4892
|
-
stateProvider: new
|
|
4914
|
+
stateProvider: new aws20.dynamodb.DynamoDBStateProvider({
|
|
4893
4915
|
credentials,
|
|
4894
4916
|
region,
|
|
4895
4917
|
tableName: "awsless-state"
|
|
4896
4918
|
}),
|
|
4897
|
-
cloudProviders:
|
|
4919
|
+
cloudProviders: aws20.createCloudProviders({
|
|
4898
4920
|
credentials,
|
|
4899
4921
|
region: appConfig.region
|
|
4900
4922
|
})
|
|
@@ -4945,12 +4967,9 @@ var diff = (program2) => {
|
|
|
4945
4967
|
});
|
|
4946
4968
|
};
|
|
4947
4969
|
|
|
4948
|
-
// src/cli/ui/complex/build-types.ts
|
|
4949
|
-
import { log as log9 } from "@clack/prompts";
|
|
4950
|
-
|
|
4951
4970
|
// src/type-gen/generate.ts
|
|
4952
4971
|
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
4953
|
-
import { dirname as
|
|
4972
|
+
import { dirname as dirname10, join as join12, relative as relative5 } from "path";
|
|
4954
4973
|
var generateTypes = async (props) => {
|
|
4955
4974
|
const files = [];
|
|
4956
4975
|
await Promise.all(
|
|
@@ -4959,12 +4978,12 @@ var generateTypes = async (props) => {
|
|
|
4959
4978
|
...props,
|
|
4960
4979
|
async write(file, data, include = false) {
|
|
4961
4980
|
const code = data?.toString("utf8");
|
|
4962
|
-
const path =
|
|
4981
|
+
const path = join12(directories.types, file);
|
|
4963
4982
|
if (code) {
|
|
4964
4983
|
if (include) {
|
|
4965
4984
|
files.push(relative5(directories.root, path));
|
|
4966
4985
|
}
|
|
4967
|
-
await mkdir4(
|
|
4986
|
+
await mkdir4(dirname10(path), { recursive: true });
|
|
4968
4987
|
await writeFile4(path, code);
|
|
4969
4988
|
}
|
|
4970
4989
|
}
|
|
@@ -4973,14 +4992,16 @@ var generateTypes = async (props) => {
|
|
|
4973
4992
|
);
|
|
4974
4993
|
if (files.length) {
|
|
4975
4994
|
const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
|
|
4976
|
-
await writeFile4(
|
|
4995
|
+
await writeFile4(join12(directories.root, `awsless.d.ts`), code);
|
|
4977
4996
|
}
|
|
4978
4997
|
};
|
|
4979
4998
|
|
|
4980
4999
|
// src/cli/ui/complex/build-types.ts
|
|
4981
5000
|
var buildTypes = async (props) => {
|
|
4982
|
-
await
|
|
4983
|
-
|
|
5001
|
+
await task("Generate type definition files", async (update) => {
|
|
5002
|
+
await generateTypes(props);
|
|
5003
|
+
update("Done generating type definition files.");
|
|
5004
|
+
});
|
|
4984
5005
|
};
|
|
4985
5006
|
|
|
4986
5007
|
// src/cli/command/types.ts
|
|
@@ -309,40 +309,55 @@ var TablesSchema = z8.record(
|
|
|
309
309
|
|
|
310
310
|
// src/feature/store/schema.ts
|
|
311
311
|
import { z as z9 } from "zod";
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
312
|
+
var StoresSchema = z9.union([
|
|
313
|
+
z9.array(ResourceIdSchema).transform((list) => {
|
|
314
|
+
const stores = {};
|
|
315
|
+
for (const key in list) {
|
|
316
|
+
stores[key] = {};
|
|
317
|
+
}
|
|
318
|
+
return stores;
|
|
319
|
+
}),
|
|
320
|
+
z9.record(
|
|
321
|
+
ResourceIdSchema,
|
|
322
|
+
z9.object({
|
|
323
|
+
// lambdaConfigs: LambdaConfigsSchema,
|
|
324
|
+
// cors: CorsSchema,
|
|
325
|
+
versioning: z9.boolean().default(false).describe("Enable versioning of your store."),
|
|
326
|
+
events: z9.object({
|
|
327
|
+
// create
|
|
328
|
+
"created:*": FunctionSchema.describe(
|
|
329
|
+
"Subscribe to notifications regardless of the API that was used to create an object."
|
|
330
|
+
),
|
|
331
|
+
"created:put": FunctionSchema.describe(
|
|
332
|
+
"Subscribe to notifications when an object is created using the PUT API operation."
|
|
333
|
+
),
|
|
334
|
+
"created:post": FunctionSchema.describe(
|
|
335
|
+
"Subscribe to notifications when an object is created using the POST API operation."
|
|
336
|
+
),
|
|
337
|
+
"created:copy": FunctionSchema.describe(
|
|
338
|
+
"Subscribe to notifications when an object is created using the COPY API operation."
|
|
339
|
+
),
|
|
340
|
+
"created:upload": FunctionSchema.describe(
|
|
341
|
+
"Subscribe to notifications when an object multipart upload has been completed."
|
|
342
|
+
),
|
|
343
|
+
// remove
|
|
344
|
+
"removed:*": FunctionSchema.describe(
|
|
345
|
+
"Subscribe to notifications when an object is deleted or a delete marker for a versioned object is created."
|
|
346
|
+
),
|
|
347
|
+
"removed:delete": FunctionSchema.describe(
|
|
348
|
+
"Subscribe to notifications when an object is deleted"
|
|
349
|
+
),
|
|
350
|
+
"removed:marker": FunctionSchema.describe(
|
|
351
|
+
"Subscribe to notifications when a delete marker for a versioned object is created."
|
|
352
|
+
)
|
|
353
|
+
}).optional().describe("Describes the store events you want to subscribe too.")
|
|
354
|
+
})
|
|
355
|
+
)
|
|
356
|
+
]).optional().describe("Define the stores in your stack.");
|
|
342
357
|
|
|
343
358
|
// src/feature/queue/schema.ts
|
|
344
359
|
import { z as z10 } from "zod";
|
|
345
|
-
import { days as days2, hours, minutes as minutes2, seconds as
|
|
360
|
+
import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
|
|
346
361
|
import { kibibytes } from "@awsless/size";
|
|
347
362
|
var RetentionPeriodSchema = DurationSchema.refine(
|
|
348
363
|
durationMin(minutes2(1)),
|
|
@@ -363,9 +378,9 @@ var DeliveryDelaySchema = DurationSchema.refine(
|
|
|
363
378
|
"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."
|
|
364
379
|
);
|
|
365
380
|
var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
|
|
366
|
-
durationMin(
|
|
381
|
+
durationMin(seconds2(1)),
|
|
367
382
|
"Minimum receive message wait time is 1 second"
|
|
368
|
-
).refine(durationMax(
|
|
383
|
+
).refine(durationMax(seconds2(20)), "Maximum receive message wait time is 20 seconds").describe(
|
|
369
384
|
"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."
|
|
370
385
|
);
|
|
371
386
|
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(
|