@awsless/awsless 0.0.225 → 0.0.227
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 +94 -75
- 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 +11 -10
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";
|
|
@@ -3171,7 +3186,7 @@ type Store<Name extends string> = {
|
|
|
3171
3186
|
readonly put: (key: string, body: Body, options?: Pick<PutObjectProps, 'metadata' | 'storageClass'>) => Promise<void>
|
|
3172
3187
|
readonly get: (key: string) => Promise<BodyStream | undefined>
|
|
3173
3188
|
readonly delete: (key: string) => Promise<void>
|
|
3174
|
-
readonly createPresignedPost: key: string, contentLengthRange: [Size, Size], expires?: Duration, fields?: Record<string, string>) => Promise<PresignedPost>
|
|
3189
|
+
readonly createPresignedPost: (key: string, contentLengthRange: [Size, Size], expires?: Duration, fields?: Record<string, string>) => Promise<PresignedPost>
|
|
3175
3190
|
}
|
|
3176
3191
|
`;
|
|
3177
3192
|
var storeFeature = defineFeature({
|
|
@@ -3195,35 +3210,39 @@ var storeFeature = defineFeature({
|
|
|
3195
3210
|
for (const [id, props] of Object.entries(ctx.stackConfig.stores ?? {})) {
|
|
3196
3211
|
const group = new Node10(ctx.stack, "store", id);
|
|
3197
3212
|
const lambdaConfigs = [];
|
|
3198
|
-
|
|
3199
|
-
|
|
3213
|
+
const eventMap = {
|
|
3214
|
+
"created:*": "s3:ObjectCreated:*",
|
|
3215
|
+
"created:put": "s3:ObjectCreated:Put",
|
|
3216
|
+
"created:post": "s3:ObjectCreated:Post",
|
|
3217
|
+
"created:copy": "s3:ObjectCreated:Copy",
|
|
3218
|
+
"created:upload": "s3:ObjectCreated:CompleteMultipartUpload",
|
|
3219
|
+
"removed:*": "s3:ObjectRemoved:*",
|
|
3220
|
+
"removed:delete": "s3:ObjectRemoved:Delete",
|
|
3221
|
+
"removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
|
|
3222
|
+
};
|
|
3223
|
+
for (const [event, funcProps] of Object.entries(props.events ?? {})) {
|
|
3224
|
+
const { lambda } = createLambdaFunction(group, ctx, `store`, id, funcProps);
|
|
3200
3225
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
3201
|
-
let event;
|
|
3202
|
-
if (lambdaConfig.event === "created") {
|
|
3203
|
-
event = "s3:ObjectCreated:*";
|
|
3204
|
-
} else if (lambdaConfig.event === "removed") {
|
|
3205
|
-
event = "s3:ObjectRemoved:*";
|
|
3206
|
-
}
|
|
3207
3226
|
lambdaConfigs.push({
|
|
3208
|
-
event,
|
|
3227
|
+
event: eventMap[event],
|
|
3209
3228
|
function: lambda.arn
|
|
3210
3229
|
});
|
|
3211
3230
|
}
|
|
3212
3231
|
const bucket = new aws10.s3.Bucket(group, "store", {
|
|
3213
3232
|
name: formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "store", id),
|
|
3214
3233
|
versioning: props.versioning,
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3234
|
+
lambdaConfigs,
|
|
3235
|
+
// cors: props.cors,
|
|
3236
|
+
cors: [
|
|
3237
|
+
// ---------------------------------------------
|
|
3238
|
+
// Support for presigned post requests
|
|
3239
|
+
// ---------------------------------------------
|
|
3240
|
+
{
|
|
3241
|
+
origins: ["*"],
|
|
3242
|
+
methods: ["POST"]
|
|
3243
|
+
}
|
|
3244
|
+
// ---------------------------------------------
|
|
3245
|
+
]
|
|
3227
3246
|
});
|
|
3228
3247
|
ctx.onFunction(({ policy }) => {
|
|
3229
3248
|
policy.addStatement(bucket.permissions);
|
|
@@ -3787,7 +3806,7 @@ var searchFeature = defineFeature({
|
|
|
3787
3806
|
|
|
3788
3807
|
// src/feature/site/index.ts
|
|
3789
3808
|
import { Asset as Asset3, Node as Node17, aws as aws17 } from "@awsless/formation";
|
|
3790
|
-
import { days as days3, seconds as
|
|
3809
|
+
import { days as days3, seconds as seconds3 } from "@awsless/duration";
|
|
3791
3810
|
import { glob as glob2 } from "glob";
|
|
3792
3811
|
import { join as join8 } from "path";
|
|
3793
3812
|
|
|
@@ -3900,7 +3919,7 @@ var siteFeature = defineFeature({
|
|
|
3900
3919
|
}
|
|
3901
3920
|
const cache = new aws17.cloudFront.CachePolicy(group, "cache", {
|
|
3902
3921
|
name,
|
|
3903
|
-
minTtl:
|
|
3922
|
+
minTtl: seconds3(1),
|
|
3904
3923
|
maxTtl: days3(365),
|
|
3905
3924
|
defaultTtl: days3(1),
|
|
3906
3925
|
...props.cache
|
|
@@ -4575,7 +4594,7 @@ var del2 = (program2) => {
|
|
|
4575
4594
|
import { confirm as confirm4 } from "@clack/prompts";
|
|
4576
4595
|
|
|
4577
4596
|
// src/cli/ui/complex/run-tests.ts
|
|
4578
|
-
import { join as
|
|
4597
|
+
import { join as join11 } from "path";
|
|
4579
4598
|
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile3 } from "fs/promises";
|
|
4580
4599
|
|
|
4581
4600
|
// src/test/reporter.ts
|
|
@@ -4633,14 +4652,8 @@ var CustomReporter = class {
|
|
|
4633
4652
|
this.cache = cache;
|
|
4634
4653
|
}
|
|
4635
4654
|
}
|
|
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());
|
|
4655
|
+
onUserConsoleLog(log9) {
|
|
4656
|
+
this.logs.push(log9.content.trimEnd());
|
|
4644
4657
|
}
|
|
4645
4658
|
runningTask(tasks) {
|
|
4646
4659
|
return tasks.find((t) => t.result?.state === "run");
|
|
@@ -4664,7 +4677,10 @@ import { startVitest } from "vitest/node";
|
|
|
4664
4677
|
import commonjs3 from "@rollup/plugin-commonjs";
|
|
4665
4678
|
import nodeResolve3 from "@rollup/plugin-node-resolve";
|
|
4666
4679
|
import json3 from "@rollup/plugin-json";
|
|
4680
|
+
import { dirname as dirname9, join as join10 } from "path";
|
|
4681
|
+
import { fileURLToPath } from "url";
|
|
4667
4682
|
var startTest = async (props) => {
|
|
4683
|
+
const __dirname = dirname9(fileURLToPath(import.meta.url));
|
|
4668
4684
|
const result = await startVitest(
|
|
4669
4685
|
"test",
|
|
4670
4686
|
props.filters,
|
|
@@ -4677,7 +4693,11 @@ var startTest = async (props) => {
|
|
|
4677
4693
|
include: ["**/*.{js,jsx,ts,tsx}"],
|
|
4678
4694
|
exclude: ["**/_*", "**/_*/**", ...configDefaults.exclude],
|
|
4679
4695
|
globals: true,
|
|
4680
|
-
reporters: props.reporter
|
|
4696
|
+
reporters: props.reporter,
|
|
4697
|
+
globalSetup: join10(__dirname, "test-global-setup.js")
|
|
4698
|
+
// env: {
|
|
4699
|
+
// TZ: 'UTC',
|
|
4700
|
+
// },
|
|
4681
4701
|
// typecheck: {
|
|
4682
4702
|
// enabled: true,
|
|
4683
4703
|
// // ignoreSourceErrors: false,
|
|
@@ -4732,7 +4752,7 @@ var logTestLogs = (event) => {
|
|
|
4732
4752
|
log8.message(color.info.bold.inverse(" LOGS "), {
|
|
4733
4753
|
symbol: color.dim(icon.dot)
|
|
4734
4754
|
});
|
|
4735
|
-
log8.message(event.logs.map((
|
|
4755
|
+
log8.message(event.logs.map((log9) => wrap(log9, { hard: true })).join("\n"));
|
|
4736
4756
|
}
|
|
4737
4757
|
};
|
|
4738
4758
|
var logTestErrors = (event) => {
|
|
@@ -4770,7 +4790,7 @@ var logTestErrors = (event) => {
|
|
|
4770
4790
|
var runTest = async (stack, dir, filters) => {
|
|
4771
4791
|
await mkdir3(directories.test, { recursive: true });
|
|
4772
4792
|
const fingerprint = await fingerprintFromDirectory(dir);
|
|
4773
|
-
const file =
|
|
4793
|
+
const file = join11(directories.test, `${stack}.json`);
|
|
4774
4794
|
const exists = await fileExist(file);
|
|
4775
4795
|
if (exists && !process.env.NO_CACHE) {
|
|
4776
4796
|
const raw = await readFile7(file, { encoding: "utf8" });
|
|
@@ -4945,12 +4965,9 @@ var diff = (program2) => {
|
|
|
4945
4965
|
});
|
|
4946
4966
|
};
|
|
4947
4967
|
|
|
4948
|
-
// src/cli/ui/complex/build-types.ts
|
|
4949
|
-
import { log as log9 } from "@clack/prompts";
|
|
4950
|
-
|
|
4951
4968
|
// src/type-gen/generate.ts
|
|
4952
4969
|
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
4953
|
-
import { dirname as
|
|
4970
|
+
import { dirname as dirname10, join as join12, relative as relative5 } from "path";
|
|
4954
4971
|
var generateTypes = async (props) => {
|
|
4955
4972
|
const files = [];
|
|
4956
4973
|
await Promise.all(
|
|
@@ -4959,12 +4976,12 @@ var generateTypes = async (props) => {
|
|
|
4959
4976
|
...props,
|
|
4960
4977
|
async write(file, data, include = false) {
|
|
4961
4978
|
const code = data?.toString("utf8");
|
|
4962
|
-
const path =
|
|
4979
|
+
const path = join12(directories.types, file);
|
|
4963
4980
|
if (code) {
|
|
4964
4981
|
if (include) {
|
|
4965
4982
|
files.push(relative5(directories.root, path));
|
|
4966
4983
|
}
|
|
4967
|
-
await mkdir4(
|
|
4984
|
+
await mkdir4(dirname10(path), { recursive: true });
|
|
4968
4985
|
await writeFile4(path, code);
|
|
4969
4986
|
}
|
|
4970
4987
|
}
|
|
@@ -4973,14 +4990,16 @@ var generateTypes = async (props) => {
|
|
|
4973
4990
|
);
|
|
4974
4991
|
if (files.length) {
|
|
4975
4992
|
const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
|
|
4976
|
-
await writeFile4(
|
|
4993
|
+
await writeFile4(join12(directories.root, `awsless.d.ts`), code);
|
|
4977
4994
|
}
|
|
4978
4995
|
};
|
|
4979
4996
|
|
|
4980
4997
|
// src/cli/ui/complex/build-types.ts
|
|
4981
4998
|
var buildTypes = async (props) => {
|
|
4982
|
-
await
|
|
4983
|
-
|
|
4999
|
+
await task("Generate type definition files", async (update) => {
|
|
5000
|
+
await generateTypes(props);
|
|
5001
|
+
update("Done generating type definition files.");
|
|
5002
|
+
});
|
|
4984
5003
|
};
|
|
4985
5004
|
|
|
4986
5005
|
// 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(
|