@awsless/cli 0.0.46-next.34 → 0.0.46-next.36
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 -1
- package/dist/app.stage.json +1 -1
- package/dist/bin.js +409 -280
- package/dist/handlers/bundle.js +1 -26
- package/dist/handlers/on-error-log.js +28 -71
- package/dist/handlers/on-failure.js +205 -0
- package/package.json +15 -15
- package/dist/prebuild/on-failure/HASH +0 -1
- package/dist/prebuild/on-failure/bundle.zip +0 -0
package/dist/bin.js
CHANGED
|
@@ -82626,7 +82626,7 @@ var require_readdirp = __commonJS((exports, module) => {
|
|
|
82626
82626
|
var sysPath = __require("path");
|
|
82627
82627
|
var { promisify: promisify4 } = __require("util");
|
|
82628
82628
|
var picomatch = require_picomatch3();
|
|
82629
|
-
var
|
|
82629
|
+
var readdir6 = promisify4(fs3.readdir);
|
|
82630
82630
|
var stat5 = promisify4(fs3.stat);
|
|
82631
82631
|
var lstat4 = promisify4(fs3.lstat);
|
|
82632
82632
|
var realpath2 = promisify4(fs3.realpath);
|
|
@@ -82759,7 +82759,7 @@ var require_readdirp = __commonJS((exports, module) => {
|
|
|
82759
82759
|
async _exploreDir(path2, depth) {
|
|
82760
82760
|
let files;
|
|
82761
82761
|
try {
|
|
82762
|
-
files = await
|
|
82762
|
+
files = await readdir6(path2, this._rdOptions);
|
|
82763
82763
|
} catch (error3) {
|
|
82764
82764
|
this._onError(error3);
|
|
82765
82765
|
}
|
|
@@ -149550,7 +149550,7 @@ var createLambdaProvider = ({ credentials: credentials3, region }) => {
|
|
|
149550
149550
|
deploymentId: exports_external.string(),
|
|
149551
149551
|
functionName: exports_external.string(),
|
|
149552
149552
|
functionVersion: exports_external.string(),
|
|
149553
|
-
onFailureArn: exports_external.string(),
|
|
149553
|
+
onFailureArn: exports_external.string().optional(),
|
|
149554
149554
|
sourceAccount: exports_external.string().optional()
|
|
149555
149555
|
});
|
|
149556
149556
|
const bundleDeploymentStateSchema = bundleDeploymentInputSchema.extend({
|
|
@@ -149579,11 +149579,11 @@ var createLambdaProvider = ({ credentials: credentials3, region }) => {
|
|
|
149579
149579
|
FunctionName: state2.functionName,
|
|
149580
149580
|
Qualifier: state2.functionVersion,
|
|
149581
149581
|
MaximumRetryAttempts: 2,
|
|
149582
|
-
DestinationConfig: {
|
|
149582
|
+
DestinationConfig: state2.onFailureArn ? {
|
|
149583
149583
|
OnFailure: {
|
|
149584
149584
|
Destination: state2.onFailureArn
|
|
149585
149585
|
}
|
|
149586
|
-
}
|
|
149586
|
+
} : undefined
|
|
149587
149587
|
}));
|
|
149588
149588
|
};
|
|
149589
149589
|
const createDeploymentUrl = async (functionName, alias, sourceAccount) => {
|
|
@@ -161499,10 +161499,28 @@ var CodeSchema = exports_external.union([
|
|
|
161499
161499
|
})).pipe(FileCodeSchema),
|
|
161500
161500
|
FileCodeSchema
|
|
161501
161501
|
]).describe("Specify the code of your function.");
|
|
161502
|
-
var
|
|
161502
|
+
var BundledFnSchema = exports_external.object({
|
|
161503
161503
|
code: CodeSchema,
|
|
161504
161504
|
handler: HandlerSchema.optional()
|
|
161505
161505
|
}).strict();
|
|
161506
|
+
var BundledFunctionSchema = exports_external.union([
|
|
161507
|
+
LocalFileSchema.transform((code) => ({
|
|
161508
|
+
code
|
|
161509
|
+
})).pipe(BundledFnSchema),
|
|
161510
|
+
BundledFnSchema
|
|
161511
|
+
]);
|
|
161512
|
+
var FnSchema = BundledFnSchema.extend({
|
|
161513
|
+
timeout: TimeoutSchema.optional(),
|
|
161514
|
+
memorySize: MemorySizeSchema.optional(),
|
|
161515
|
+
architecture: ArchitectureSchema.optional(),
|
|
161516
|
+
vpc: VPCSchema.optional(),
|
|
161517
|
+
log: LogSchema.transform((log) => ({
|
|
161518
|
+
retention: log.retention,
|
|
161519
|
+
format: "format" in log ? log.format : undefined,
|
|
161520
|
+
level: "level" in log ? log.level : undefined,
|
|
161521
|
+
system: "system" in log ? log.system : undefined
|
|
161522
|
+
})).optional()
|
|
161523
|
+
});
|
|
161506
161524
|
var FunctionSchema = exports_external.union([
|
|
161507
161525
|
LocalFileSchema.transform((code) => ({
|
|
161508
161526
|
code
|
|
@@ -161540,14 +161558,14 @@ var FunctionDefaultSchema = exports_external.object({
|
|
|
161540
161558
|
external: exports_external.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`),
|
|
161541
161559
|
log: LogSchema.default(true).transform((log) => ({
|
|
161542
161560
|
retention: log.retention ?? days(7),
|
|
161543
|
-
level: "level" in log ? log.level : "
|
|
161561
|
+
level: "level" in log ? log.level : "trace",
|
|
161544
161562
|
system: "system" in log ? log.system : "warn",
|
|
161545
161563
|
format: "format" in log ? log.format : "json"
|
|
161546
161564
|
})),
|
|
161547
161565
|
timeout: TimeoutSchema.default("15 minutes"),
|
|
161548
161566
|
memorySize: MemorySizeSchema.default("1024 MB"),
|
|
161549
161567
|
architecture: ArchitectureSchema.default("arm64"),
|
|
161550
|
-
vpc: VPCSchema.default(
|
|
161568
|
+
vpc: VPCSchema.default(true),
|
|
161551
161569
|
ephemeralStorageSize: EphemeralStorageSizeSchema.default("512 MB"),
|
|
161552
161570
|
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
161553
161571
|
layers: LayersSchema.optional(),
|
|
@@ -161574,32 +161592,36 @@ var LayerSchema = exports_external.record(exports_external.string(), exports_ext
|
|
|
161574
161592
|
Schema
|
|
161575
161593
|
])).optional().describe("Define the lambda layers in your stack.");
|
|
161576
161594
|
|
|
161577
|
-
// src/feature/
|
|
161578
|
-
var
|
|
161579
|
-
|
|
161595
|
+
// src/feature/on-error-log/schema.ts
|
|
161596
|
+
var ConsumerSchema = FunctionSchema.transform((consumer) => ({
|
|
161597
|
+
...consumer,
|
|
161598
|
+
vpc: consumer.vpc ?? false
|
|
161599
|
+
}));
|
|
161600
|
+
var OnErrorLogDefaultSchema = exports_external.union([
|
|
161601
|
+
ConsumerSchema.transform((consumer) => ({
|
|
161580
161602
|
consumer
|
|
161581
161603
|
})),
|
|
161582
161604
|
exports_external.object({
|
|
161583
|
-
consumer:
|
|
161605
|
+
consumer: ConsumerSchema
|
|
161584
161606
|
})
|
|
161585
|
-
]);
|
|
161586
|
-
var TasksSchema = exports_external.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
161587
|
-
|
|
161588
|
-
// src/feature/on-error-log/schema.ts
|
|
161589
|
-
var OnErrorLogDefaultSchema = TaskSchema.optional().describe("Define a subscription on all Lambda functions logs.");
|
|
161607
|
+
]).optional().describe("Define a subscription on all Lambda functions logs.");
|
|
161590
161608
|
|
|
161591
161609
|
// src/feature/on-failure/schema.ts
|
|
161592
161610
|
var NotifySchema = exports_external.union([
|
|
161593
161611
|
EmailSchema.transform((v7) => [v7]),
|
|
161594
161612
|
EmailSchema.array()
|
|
161595
161613
|
]).describe("Receive an email notification when consuming failure entries goes wrong.");
|
|
161614
|
+
var ConsumerSchema2 = FunctionSchema.transform((consumer) => ({
|
|
161615
|
+
...consumer,
|
|
161616
|
+
vpc: consumer.vpc ?? false
|
|
161617
|
+
}));
|
|
161596
161618
|
var OnFailureDefaultSchema = exports_external.union([
|
|
161597
|
-
|
|
161619
|
+
ConsumerSchema2.transform((consumer) => ({
|
|
161598
161620
|
consumer,
|
|
161599
161621
|
notify: []
|
|
161600
161622
|
})),
|
|
161601
161623
|
exports_external.object({
|
|
161602
|
-
consumer:
|
|
161624
|
+
consumer: ConsumerSchema2,
|
|
161603
161625
|
notify: NotifySchema.optional()
|
|
161604
161626
|
})
|
|
161605
161627
|
]).optional().describe([
|
|
@@ -161813,7 +161835,7 @@ var ErrorResponseSchema = exports_external.union([
|
|
|
161813
161835
|
})
|
|
161814
161836
|
]).optional();
|
|
161815
161837
|
var RouteSchema = exports_external.string().regex(/^\//, "Route must start with a slash (/)").regex(/^\/([^/*.]+)?$/, 'Router paths mount a single segment without dots, like "/api".');
|
|
161816
|
-
var RoutesSchema = exports_external.record(ResourceIdSchema.describe("The router id to add your routes to."), exports_external.record(exports_external.string().regex(/^\//, "Route must start with a slash (/)"),
|
|
161838
|
+
var RoutesSchema = exports_external.record(ResourceIdSchema.describe("The router id to add your routes to."), exports_external.record(exports_external.string().regex(/^\//, "Route must start with a slash (/)"), BundledFunctionSchema).superRefine((routes, ctx) => {
|
|
161817
161839
|
for (const pattern of Object.keys(routes)) {
|
|
161818
161840
|
try {
|
|
161819
161841
|
compileRoutePattern(pattern);
|
|
@@ -161921,7 +161943,7 @@ var RouterDefaultSchema = exports_external.record(ResourceIdSchema, exports_exte
|
|
|
161921
161943
|
|
|
161922
161944
|
// src/feature/pubsub/schema.ts
|
|
161923
161945
|
var PubSubDefaultSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
161924
|
-
auth:
|
|
161946
|
+
auth: BundledFunctionSchema.describe("The authorizer that validates the client auth token and returns the allowed topics."),
|
|
161925
161947
|
router: ResourceIdSchema.describe("The router id to route pubsub traffic through."),
|
|
161926
161948
|
path: RouteSchema.default("/ws").describe("The base path on the router that exposes the pubsub endpoint."),
|
|
161927
161949
|
log: LogSchema2.default(true).transform((log) => ({
|
|
@@ -161929,10 +161951,10 @@ var PubSubDefaultSchema = exports_external.record(ResourceIdSchema, exports_exte
|
|
|
161929
161951
|
}))
|
|
161930
161952
|
})).optional().describe("Define the pubsub API for your app. Backed by a websocket server on AWS Fargate.");
|
|
161931
161953
|
var PubSubSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
161932
|
-
connected:
|
|
161933
|
-
disconnected:
|
|
161934
|
-
subscribed:
|
|
161935
|
-
unsubscribed:
|
|
161954
|
+
connected: BundledFunctionSchema.optional().describe("Subscribe to the event when a client connects."),
|
|
161955
|
+
disconnected: BundledFunctionSchema.optional().describe("Subscribe to the event when a client disconnects."),
|
|
161956
|
+
subscribed: BundledFunctionSchema.optional().describe("Subscribe to the event when a client subscribes to topics."),
|
|
161957
|
+
unsubscribed: BundledFunctionSchema.optional().describe("Subscribe to the event when a client unsubscribes from topics.")
|
|
161936
161958
|
})).optional().describe("Define the pubsub event listeners in your stack.");
|
|
161937
161959
|
var pubsubEventTypes = ["connected", "disconnected", "subscribed", "unsubscribed"];
|
|
161938
161960
|
|
|
@@ -161949,7 +161971,7 @@ var QueueDefaultSchema = exports_external.object({
|
|
|
161949
161971
|
batchSize: BatchSizeSchema.default(10)
|
|
161950
161972
|
}).default({});
|
|
161951
161973
|
var QueueSchema = exports_external.object({
|
|
161952
|
-
consumer:
|
|
161974
|
+
consumer: BundledFunctionSchema.optional().describe("The consuming lambda function properties."),
|
|
161953
161975
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
161954
161976
|
receiveMessageWaitTime: ReceiveMessageWaitTimeSchema.optional(),
|
|
161955
161977
|
maxMessageSize: MaxMessageSizeSchema.optional(),
|
|
@@ -161978,21 +162000,21 @@ var RestSchema = exports_external.record(ResourceIdSchema, exports_external.reco
|
|
|
161978
162000
|
"The possible http methods are POST, GET,PUT, DELETE, HEAD, OPTIONS, ANY.",
|
|
161979
162001
|
"Example: GET /posts/{id}"
|
|
161980
162002
|
].join(`
|
|
161981
|
-
`)),
|
|
162003
|
+
`)), BundledFunctionSchema)).optional().describe("Define routes in your stack for your global REST API.");
|
|
161982
162004
|
|
|
161983
162005
|
// src/feature/rpc/schema.ts
|
|
161984
162006
|
var RpcDefaultSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
161985
162007
|
router: ResourceIdSchema.describe("The router id to link your RPC API with."),
|
|
161986
162008
|
path: RouteSchema.describe("The path inside the router to link your RPC API to."),
|
|
161987
|
-
auth:
|
|
162009
|
+
auth: BundledFunctionSchema.optional().describe("The authentication handler for your RPC API.")
|
|
161988
162010
|
})).describe(`Define the global RPC API's.`).optional();
|
|
161989
162011
|
var RpcSchema = exports_external.record(ResourceIdSchema, exports_external.record(exports_external.string(), exports_external.union([
|
|
161990
|
-
|
|
162012
|
+
BundledFunctionSchema.transform((f11) => ({
|
|
161991
162013
|
function: f11,
|
|
161992
162014
|
lock: false
|
|
161993
162015
|
})),
|
|
161994
162016
|
exports_external.object({
|
|
161995
|
-
function:
|
|
162017
|
+
function: BundledFunctionSchema.describe("The RPC function to execute."),
|
|
161996
162018
|
lock: exports_external.boolean().describe([
|
|
161997
162019
|
"Specify if the function should be locked on the `lockKey` returned from the auth function.",
|
|
161998
162020
|
"An example would be returning the user ID as `lockKey`."
|
|
@@ -162110,6 +162132,17 @@ var JobDefaultSchema = exports_external.object({
|
|
|
162110
162132
|
}))
|
|
162111
162133
|
}).default({});
|
|
162112
162134
|
|
|
162135
|
+
// src/feature/task/schema.ts
|
|
162136
|
+
var TaskSchema = exports_external.union([
|
|
162137
|
+
BundledFunctionSchema.transform((consumer) => ({
|
|
162138
|
+
consumer
|
|
162139
|
+
})),
|
|
162140
|
+
exports_external.object({
|
|
162141
|
+
consumer: BundledFunctionSchema
|
|
162142
|
+
})
|
|
162143
|
+
]);
|
|
162144
|
+
var TasksSchema = exports_external.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
162145
|
+
|
|
162113
162146
|
// src/feature/topic/schema.ts
|
|
162114
162147
|
var TopicNameSchema = exports_external.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase(value)).describe("Define event topic name.");
|
|
162115
162148
|
var TopicsDefaultSchema = exports_external.array(TopicNameSchema).refine((topics) => {
|
|
@@ -162255,7 +162288,7 @@ var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
|
162255
162288
|
// src/feature/cron/schema/index.ts
|
|
162256
162289
|
var CronsSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
162257
162290
|
enabled: exports_external.boolean().default(true).describe("If the cron is enabled."),
|
|
162258
|
-
consumer:
|
|
162291
|
+
consumer: BundledFunctionSchema.describe("The consuming lambda function properties."),
|
|
162259
162292
|
schedule: ScheduleExpressionSchema.describe(`The scheduling expression.
|
|
162260
162293
|
|
|
162261
162294
|
example: "0 20 * * ? *"
|
|
@@ -162431,7 +162464,7 @@ var StoresSchema = exports_external.union([
|
|
|
162431
162464
|
|
|
162432
162465
|
// src/feature/icon/schema.ts
|
|
162433
162466
|
var staticOriginSchema = LocalDirectorySchema.describe("Specifies the path to a local image directory that will be uploaded in S3.");
|
|
162434
|
-
var functionOriginSchema =
|
|
162467
|
+
var functionOriginSchema = BundledFunctionSchema.describe("Specifies the file that will be called when an image isn't found in the (cache) bucket.");
|
|
162435
162468
|
var IconsSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
162436
162469
|
router: ResourceIdSchema.describe("The router id to link your icon proxy."),
|
|
162437
162470
|
path: RouteSchema.describe("The path inside the router to link your icon proxy to."),
|
|
@@ -162459,7 +162492,7 @@ var transformationOptionsSchema = exports_external.object({
|
|
|
162459
162492
|
quality: exports_external.number().int().min(1).max(100).optional()
|
|
162460
162493
|
});
|
|
162461
162494
|
var staticOriginSchema2 = LocalDirectorySchema.describe("Specifies the path to a local image directory that will be uploaded in S3.");
|
|
162462
|
-
var functionOriginSchema2 =
|
|
162495
|
+
var functionOriginSchema2 = BundledFunctionSchema.describe("Specifies the file that will be called when an image isn't found in the (cache) bucket.");
|
|
162463
162496
|
var ImagesSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
162464
162497
|
router: ResourceIdSchema.describe("The router id to link your image proxy."),
|
|
162465
162498
|
path: RouteSchema.describe("The path inside the router to link your image proxy to."),
|
|
@@ -162529,7 +162562,7 @@ var AlarmSchema = exports_external.object({
|
|
|
162529
162562
|
where: WhereSchema,
|
|
162530
162563
|
period: DurationSchema,
|
|
162531
162564
|
minDataPoints: exports_external.number().int().default(1),
|
|
162532
|
-
trigger: exports_external.union([EmailSchema.transform((v7) => [v7]), EmailSchema.array(),
|
|
162565
|
+
trigger: exports_external.union([EmailSchema.transform((v7) => [v7]), EmailSchema.array(), BundledFunctionSchema])
|
|
162533
162566
|
});
|
|
162534
162567
|
var MetricsSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
162535
162568
|
type: exports_external.enum(["number", "size", "duration"]),
|
|
@@ -162584,7 +162617,7 @@ var TablesSchema = exports_external.record(ResourceIdSchema, exports_external.ob
|
|
|
162584
162617
|
"You can specify a number from 1 to 10."
|
|
162585
162618
|
].join(`
|
|
162586
162619
|
`)),
|
|
162587
|
-
consumer:
|
|
162620
|
+
consumer: BundledFunctionSchema.describe("The consuming lambda function for the stream")
|
|
162588
162621
|
}).optional().describe("The settings for the DynamoDB table stream, which capture changes to items stored in the table."),
|
|
162589
162622
|
indexes: exports_external.record(exports_external.string(), exports_external.object({
|
|
162590
162623
|
hash: exports_external.union([KeySchema.transform((v7) => [v7]), KeySchema.array()]).describe("Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."),
|
|
@@ -163786,8 +163819,21 @@ var shortId = (ns) => {
|
|
|
163786
163819
|
return createHash10("md5").update(ns).digest("hex").substring(0, 10);
|
|
163787
163820
|
};
|
|
163788
163821
|
|
|
163822
|
+
// src/feature/on-error-log/util.ts
|
|
163823
|
+
var filterPattern = `{${[
|
|
163824
|
+
`$.level = "WARN"`,
|
|
163825
|
+
`$.level = "ERROR"`,
|
|
163826
|
+
`$.level = "FATAL"`,
|
|
163827
|
+
`($.type = "platform.report" && $.record.status = "timeout")`,
|
|
163828
|
+
`($.type = "platform.report" && $.record.status = "error")`,
|
|
163829
|
+
`($.type = "platform.report" && $.record.status = "failure")`
|
|
163830
|
+
].join(" || ")}}`;
|
|
163831
|
+
|
|
163789
163832
|
// src/feature/on-failure/util.ts
|
|
163790
163833
|
var getGlobalOnFailure = (ctx) => {
|
|
163834
|
+
if (!ctx.shared.has("on-failure", "bucket-arn")) {
|
|
163835
|
+
return;
|
|
163836
|
+
}
|
|
163791
163837
|
return ctx.shared.get("on-failure", "bucket-arn");
|
|
163792
163838
|
};
|
|
163793
163839
|
|
|
@@ -164245,14 +164291,6 @@ var bundleTypeScriptWithRolldown = async (props) => {
|
|
|
164245
164291
|
}
|
|
164246
164292
|
const routeKey = decodeURIComponent(encodedRouteKey);
|
|
164247
164293
|
return `${routeKey.replaceAll(":", "--")}.${extension}`;
|
|
164248
|
-
},
|
|
164249
|
-
codeSplitting: {
|
|
164250
|
-
groups: [
|
|
164251
|
-
{
|
|
164252
|
-
name: "shared",
|
|
164253
|
-
minShareCount: 2
|
|
164254
|
-
}
|
|
164255
|
-
]
|
|
164256
164294
|
}
|
|
164257
164295
|
});
|
|
164258
164296
|
const hash2 = createHash11("sha1");
|
|
@@ -164537,12 +164575,7 @@ var bundleFeature = defineFeature({
|
|
|
164537
164575
|
},
|
|
164538
164576
|
s3Bucket: code.bucket,
|
|
164539
164577
|
s3ObjectVersion: code.versionId,
|
|
164540
|
-
s3Key: code.key
|
|
164541
|
-
if (name2.startsWith("/")) {
|
|
164542
|
-
return name2.substring(1);
|
|
164543
|
-
}
|
|
164544
|
-
return name2;
|
|
164545
|
-
}),
|
|
164578
|
+
s3Key: code.key,
|
|
164546
164579
|
sourceCodeHash: sourceHash,
|
|
164547
164580
|
environment: {
|
|
164548
164581
|
variables: {
|
|
@@ -164588,27 +164621,29 @@ var bundleFeature = defineFeature({
|
|
|
164588
164621
|
}, {
|
|
164589
164622
|
dependsOn: [policy]
|
|
164590
164623
|
});
|
|
164591
|
-
|
|
164592
|
-
|
|
164593
|
-
|
|
164594
|
-
|
|
164595
|
-
|
|
164596
|
-
|
|
164597
|
-
|
|
164624
|
+
if (onFailure) {
|
|
164625
|
+
new aws3.lambda.FunctionEventInvokeConfig(group4, "async", {
|
|
164626
|
+
functionName: lambda.functionName,
|
|
164627
|
+
qualifier: alias.name,
|
|
164628
|
+
maximumRetryAttempts: 2,
|
|
164629
|
+
destinationConfig: {
|
|
164630
|
+
onFailure: {
|
|
164631
|
+
destination: onFailure
|
|
164632
|
+
}
|
|
164598
164633
|
}
|
|
164599
|
-
}
|
|
164600
|
-
|
|
164601
|
-
|
|
164602
|
-
|
|
164603
|
-
|
|
164604
|
-
|
|
164605
|
-
|
|
164606
|
-
|
|
164607
|
-
|
|
164608
|
-
|
|
164634
|
+
}, {
|
|
164635
|
+
dependsOn: [policy]
|
|
164636
|
+
});
|
|
164637
|
+
addPermission({
|
|
164638
|
+
actions: ["s3:PutObject", "s3:ListBucket"],
|
|
164639
|
+
resources: [onFailure, $interpolate`${onFailure}/*`],
|
|
164640
|
+
conditions: {
|
|
164641
|
+
StringEquals: {
|
|
164642
|
+
"s3:ResourceAccount": ctx.accountId
|
|
164643
|
+
}
|
|
164609
164644
|
}
|
|
164610
|
-
}
|
|
164611
|
-
}
|
|
164645
|
+
});
|
|
164646
|
+
}
|
|
164612
164647
|
let logGroup;
|
|
164613
164648
|
if (defaults2.log.retention.value > 0n) {
|
|
164614
164649
|
logGroup = new aws3.cloudwatch.LogGroup(group4, "log", {
|
|
@@ -164619,6 +164654,17 @@ var bundleFeature = defineFeature({
|
|
|
164619
164654
|
actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
|
|
164620
164655
|
resources: [logGroup.arn.pipe((arn) => `${arn}:*`)]
|
|
164621
164656
|
});
|
|
164657
|
+
if (ctx.shared.has("on-error-log", "subscriber-arn")) {
|
|
164658
|
+
new aws3.cloudwatch.LogSubscriptionFilter(group4, "on-error-log", {
|
|
164659
|
+
name: "error-log-subscription",
|
|
164660
|
+
destinationArn: ctx.shared.get("on-error-log", "subscriber-arn"),
|
|
164661
|
+
logGroupName: logGroup.name,
|
|
164662
|
+
filterPattern
|
|
164663
|
+
}, {
|
|
164664
|
+
replaceOnChanges: ["destinationArn"],
|
|
164665
|
+
dependsOn: [ctx.shared.get("on-error-log", "permission")]
|
|
164666
|
+
});
|
|
164667
|
+
}
|
|
164622
164668
|
}
|
|
164623
164669
|
for (const [name2, value] of Object.entries(defaults2.environment ?? {})) {
|
|
164624
164670
|
addEnv(name2, value);
|
|
@@ -172732,9 +172778,12 @@ var configFeature = defineFeature({
|
|
|
172732
172778
|
`arn:aws:ssm:${ctx.appConfig.region}:${ctx.accountId}:parameter${configParameterPrefix(ctx.app.name)}/*`
|
|
172733
172779
|
]
|
|
172734
172780
|
});
|
|
172735
|
-
|
|
172781
|
+
const names = ctx.appConfig.configs ?? [];
|
|
172782
|
+
for (const name of names) {
|
|
172736
172783
|
ctx.registerConfig(name);
|
|
172737
|
-
|
|
172784
|
+
}
|
|
172785
|
+
if (names.length > 0) {
|
|
172786
|
+
ctx.addEnv("CONFIGS", names.join(","));
|
|
172738
172787
|
}
|
|
172739
172788
|
}
|
|
172740
172789
|
});
|
|
@@ -173054,20 +173103,9 @@ import { days as days8, seconds as seconds4, toDays as toDays6, toSeconds as toS
|
|
|
173054
173103
|
import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
|
|
173055
173104
|
var import_deepmerge = __toESM(require_cjs2(), 1);
|
|
173056
173105
|
import { createHash as createHash16 } from "crypto";
|
|
173106
|
+
import { readdir as readdir4, readFile as readFile16, rm as rm7, writeFile as writeFile10 } from "fs/promises";
|
|
173057
173107
|
import { dirname as dirname8, join as join23 } from "path";
|
|
173058
173108
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
173059
|
-
|
|
173060
|
-
// src/feature/on-error-log/util.ts
|
|
173061
|
-
var filterPattern = `{${[
|
|
173062
|
-
`$.level = "WARN"`,
|
|
173063
|
-
`$.level = "ERROR"`,
|
|
173064
|
-
`$.level = "FATAL"`,
|
|
173065
|
-
`($.type = "platform.report" && $.record.status = "timeout")`,
|
|
173066
|
-
`($.type = "platform.report" && $.record.status = "error")`,
|
|
173067
|
-
`($.type = "platform.report" && $.record.status = "failure")`
|
|
173068
|
-
].join(" || ")}}`;
|
|
173069
|
-
|
|
173070
|
-
// src/feature/function/util.ts
|
|
173071
173109
|
var standaloneFields = [
|
|
173072
173110
|
"runtime",
|
|
173073
173111
|
"description",
|
|
@@ -173085,6 +173123,88 @@ var standaloneFields = [
|
|
|
173085
173123
|
var isStandaloneFunction = (props) => {
|
|
173086
173124
|
return standaloneFields.some((field) => typeof props[field] !== "undefined");
|
|
173087
173125
|
};
|
|
173126
|
+
var registerFunctionBuild = (ctx, name, props) => {
|
|
173127
|
+
const exportName = parseExportName(props.handler ?? ctx.appConfig.defaults.function.handler);
|
|
173128
|
+
ctx.registerBuild("function", name, async (build2, { workspace }) => {
|
|
173129
|
+
const fingerprint = createHash16("sha1").update(await generateFileHash2(workspace, props.code.file)).update(props.wrapper ? await readFile16(props.wrapper) : "").update(JSON.stringify([
|
|
173130
|
+
exportName,
|
|
173131
|
+
props.code.minify,
|
|
173132
|
+
props.code.external,
|
|
173133
|
+
props.code.importAsString,
|
|
173134
|
+
props.code.moduleSideEffects,
|
|
173135
|
+
props.external
|
|
173136
|
+
])).digest("hex");
|
|
173137
|
+
return build2(fingerprint, async (write) => {
|
|
173138
|
+
const handlerImport = `const { ${exportName === "default" ? "default: handler" : `${exportName}: handler`} } = await import(${JSON.stringify(props.code.file)})`;
|
|
173139
|
+
const entry = `import env from './awsless-env.mjs'
|
|
173140
|
+
|
|
173141
|
+
for (const name in env) {
|
|
173142
|
+
process.env[name] ??= env[name]
|
|
173143
|
+
}
|
|
173144
|
+
|
|
173145
|
+
${props.wrapper ? `const { createHandler } = await import(${JSON.stringify(props.wrapper)})
|
|
173146
|
+
${handlerImport}
|
|
173147
|
+
|
|
173148
|
+
export default createHandler(handler)` : `${handlerImport}
|
|
173149
|
+
|
|
173150
|
+
export default handler`}
|
|
173151
|
+
`;
|
|
173152
|
+
const temp = await createTempFolder(name);
|
|
173153
|
+
const entryFile = join23(temp.path, "entry.ts");
|
|
173154
|
+
await writeFile10(entryFile, entry);
|
|
173155
|
+
const result = await bundleTypeScriptWithRolldown({
|
|
173156
|
+
file: entryFile,
|
|
173157
|
+
minify: props.code.minify,
|
|
173158
|
+
external: [
|
|
173159
|
+
"./awsless-env.mjs",
|
|
173160
|
+
...props.code.external ?? [],
|
|
173161
|
+
...props.external ?? []
|
|
173162
|
+
],
|
|
173163
|
+
moduleSideEffects: props.code.moduleSideEffects,
|
|
173164
|
+
importAsString: props.code.importAsString
|
|
173165
|
+
});
|
|
173166
|
+
await temp.delete();
|
|
173167
|
+
await rm7(getBuildPath("function", name, "files"), { recursive: true, force: true });
|
|
173168
|
+
await Promise.all([
|
|
173169
|
+
write("HASH", result.hash),
|
|
173170
|
+
...result.files.map((file2) => write(`files/${file2.name}`, file2.code)),
|
|
173171
|
+
...result.files.map((file2) => file2.map && write(`files/${file2.name}.map`, file2.map))
|
|
173172
|
+
]);
|
|
173173
|
+
return {
|
|
173174
|
+
size: formatByteSize(result.files.reduce((total, file2) => total + file2.code.byteLength, 0))
|
|
173175
|
+
};
|
|
173176
|
+
});
|
|
173177
|
+
});
|
|
173178
|
+
const env5 = {};
|
|
173179
|
+
const envDeps = new Set;
|
|
173180
|
+
const addEnv = (name2, value) => {
|
|
173181
|
+
env5[name2] = value;
|
|
173182
|
+
for (const dep of findInputDeps(value)) {
|
|
173183
|
+
envDeps.add(dep);
|
|
173184
|
+
}
|
|
173185
|
+
};
|
|
173186
|
+
const zipFile = getBuildPath("function", name, "bundle.zip");
|
|
173187
|
+
const sourceHash = new Output(envDeps, async (resolve3) => {
|
|
173188
|
+
const buildHash = await readFile16(getBuildPath("function", name, "HASH"), "utf8");
|
|
173189
|
+
const vars = await resolveInputs(env5);
|
|
173190
|
+
const sorted = Object.fromEntries(Object.entries(vars).sort(([a15], [b17]) => a15.localeCompare(b17)));
|
|
173191
|
+
const envFile = `export default ${JSON.stringify(sorted, undefined, "\t")}
|
|
173192
|
+
`;
|
|
173193
|
+
const dir = getBuildPath("function", name, "files");
|
|
173194
|
+
const files = await readdir4(dir);
|
|
173195
|
+
const archive = await zipFiles([
|
|
173196
|
+
...files.filter((file2) => !file2.endsWith(".map")).map((file2) => ({ name: file2, path: join23(dir, file2) })),
|
|
173197
|
+
{ name: "awsless-env.mjs", code: Buffer.from(envFile, "utf8") }
|
|
173198
|
+
]);
|
|
173199
|
+
await writeFile10(zipFile, archive);
|
|
173200
|
+
resolve3(createHash16("sha1").update(buildHash).update(envFile).digest("hex"));
|
|
173201
|
+
});
|
|
173202
|
+
return {
|
|
173203
|
+
zipFile,
|
|
173204
|
+
sourceHash,
|
|
173205
|
+
addEnv
|
|
173206
|
+
};
|
|
173207
|
+
};
|
|
173088
173208
|
var createLambdaFunction = (ctx, id, local) => {
|
|
173089
173209
|
const group4 = new Group(ctx.stack, "function", id);
|
|
173090
173210
|
const props = import_deepmerge.default(ctx.appConfig.defaults.function, local);
|
|
@@ -173103,43 +173223,16 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173103
173223
|
resourceName: id
|
|
173104
173224
|
});
|
|
173105
173225
|
const roleName = shortId(`${ctx.app.name}:${ctx.stack.name}:function:${id}:${ctx.appId}`);
|
|
173106
|
-
const
|
|
173107
|
-
|
|
173108
|
-
|
|
173109
|
-
|
|
173110
|
-
fileCode.external,
|
|
173111
|
-
fileCode.importAsString,
|
|
173112
|
-
fileCode.moduleSideEffects
|
|
173113
|
-
])).digest("hex");
|
|
173114
|
-
return build2(fingerprint, async (write) => {
|
|
173115
|
-
const bundle = await bundleTypeScriptWithRolldown({
|
|
173116
|
-
file: fileCode.file,
|
|
173117
|
-
minify: fileCode.minify,
|
|
173118
|
-
external: [
|
|
173119
|
-
...fileCode.external ?? [],
|
|
173120
|
-
...(props.layers ?? []).flatMap((layerId) => ctx.shared.entry("layer", "packages", layerId))
|
|
173121
|
-
],
|
|
173122
|
-
moduleSideEffects: fileCode.moduleSideEffects,
|
|
173123
|
-
importAsString: fileCode.importAsString
|
|
173124
|
-
});
|
|
173125
|
-
const archive = await zipFiles(bundle.files);
|
|
173126
|
-
await Promise.all([
|
|
173127
|
-
write("HASH", bundle.hash),
|
|
173128
|
-
write("bundle.zip", archive),
|
|
173129
|
-
...bundle.files.map((file2) => write(`files/${file2.name}`, file2.code)),
|
|
173130
|
-
...bundle.files.map((file2) => file2.map && write(`files/${file2.name}.map`, file2.map))
|
|
173131
|
-
]);
|
|
173132
|
-
return {
|
|
173133
|
-
size: formatByteSize(archive.byteLength)
|
|
173134
|
-
};
|
|
173135
|
-
});
|
|
173226
|
+
const build2 = registerFunctionBuild(ctx, name, {
|
|
173227
|
+
code: local.code,
|
|
173228
|
+
handler: props.handler,
|
|
173229
|
+
external: (props.layers ?? []).flatMap((layerId) => ctx.shared.entry("layer", "packages", layerId))
|
|
173136
173230
|
});
|
|
173137
|
-
const sourceHash = $file(getBuildPath("function", name, "HASH"));
|
|
173138
173231
|
const code = new aws3.s3.BucketObject(group4, "code", {
|
|
173139
173232
|
bucket: ctx.shared.get("asset", "bucket").name,
|
|
173140
173233
|
key: `lambda/${name}.zip`,
|
|
173141
|
-
source: relativePath(
|
|
173142
|
-
sourceHash
|
|
173234
|
+
source: relativePath(build2.zipFile),
|
|
173235
|
+
sourceHash: build2.sourceHash
|
|
173143
173236
|
}, {
|
|
173144
173237
|
replaceOnChanges: ["bucket", "key"]
|
|
173145
173238
|
});
|
|
@@ -173168,11 +173261,11 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173168
173261
|
}
|
|
173169
173262
|
};
|
|
173170
173263
|
const sandboxed = typeof local.sandbox !== "undefined" && local.sandbox !== false;
|
|
173171
|
-
|
|
173172
|
-
|
|
173173
|
-
|
|
173174
|
-
|
|
173175
|
-
|
|
173264
|
+
if (sandboxed) {
|
|
173265
|
+
addPermission(...local.permissions ?? []);
|
|
173266
|
+
} else {
|
|
173267
|
+
addPermission(...props.permissions ?? []);
|
|
173268
|
+
ctx.onPermission(addPermission);
|
|
173176
173269
|
}
|
|
173177
173270
|
const policy = new aws3.iam.RolePolicy(group4, "policy", {
|
|
173178
173271
|
role: role.name,
|
|
@@ -173224,7 +173317,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173224
173317
|
description: props.description ?? name,
|
|
173225
173318
|
role: role.arn,
|
|
173226
173319
|
runtime: props.runtime,
|
|
173227
|
-
handler:
|
|
173320
|
+
handler: "index.default",
|
|
173228
173321
|
timeout: toSeconds4(props.timeout),
|
|
173229
173322
|
memorySize: toMebibytes(props.memorySize),
|
|
173230
173323
|
architectures: [props.architecture],
|
|
@@ -173240,13 +173333,8 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173240
173333
|
},
|
|
173241
173334
|
s3Bucket: code.bucket,
|
|
173242
173335
|
s3ObjectVersion: code.versionId,
|
|
173243
|
-
s3Key: code.key
|
|
173244
|
-
|
|
173245
|
-
return name2.substring(1);
|
|
173246
|
-
}
|
|
173247
|
-
return name2;
|
|
173248
|
-
}),
|
|
173249
|
-
sourceCodeHash: sourceHash,
|
|
173336
|
+
s3Key: code.key,
|
|
173337
|
+
sourceCodeHash: build2.sourceHash,
|
|
173250
173338
|
environment: {
|
|
173251
173339
|
variables
|
|
173252
173340
|
},
|
|
@@ -173264,7 +173352,30 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173264
173352
|
}, {
|
|
173265
173353
|
dependsOn
|
|
173266
173354
|
});
|
|
173267
|
-
ctx.
|
|
173355
|
+
ctx.restartOnConfigChange(lambda);
|
|
173356
|
+
const onFailure = getGlobalOnFailure(ctx);
|
|
173357
|
+
if (onFailure) {
|
|
173358
|
+
new aws3.lambda.FunctionEventInvokeConfig(group4, "async", {
|
|
173359
|
+
functionName: lambda.functionName,
|
|
173360
|
+
maximumRetryAttempts: 2,
|
|
173361
|
+
destinationConfig: {
|
|
173362
|
+
onFailure: {
|
|
173363
|
+
destination: onFailure
|
|
173364
|
+
}
|
|
173365
|
+
}
|
|
173366
|
+
}, {
|
|
173367
|
+
dependsOn: [policy]
|
|
173368
|
+
});
|
|
173369
|
+
addPermission({
|
|
173370
|
+
actions: ["s3:PutObject", "s3:ListBucket"],
|
|
173371
|
+
resources: [onFailure, $interpolate`${onFailure}/*`],
|
|
173372
|
+
conditions: {
|
|
173373
|
+
StringEquals: {
|
|
173374
|
+
"s3:ResourceAccount": ctx.accountId
|
|
173375
|
+
}
|
|
173376
|
+
}
|
|
173377
|
+
});
|
|
173378
|
+
}
|
|
173268
173379
|
variables.APP = ctx.appConfig.name;
|
|
173269
173380
|
variables.APP_ID = ctx.appId;
|
|
173270
173381
|
variables.AWS_ACCOUNT_ID = ctx.accountId;
|
|
@@ -173283,12 +173394,8 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173283
173394
|
variables[key] = value;
|
|
173284
173395
|
}
|
|
173285
173396
|
if (!sandboxed) {
|
|
173286
|
-
ctx.onEnv(
|
|
173287
|
-
|
|
173288
|
-
});
|
|
173289
|
-
ctx.onBind((name2, value) => {
|
|
173290
|
-
variables[name2] = value;
|
|
173291
|
-
});
|
|
173397
|
+
ctx.onEnv(build2.addEnv);
|
|
173398
|
+
ctx.onBind(build2.addEnv);
|
|
173292
173399
|
}
|
|
173293
173400
|
if (typeof local.sandbox === "object") {
|
|
173294
173401
|
const routes = [
|
|
@@ -173304,16 +173411,17 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173304
173411
|
if (routes.length > 0) {
|
|
173305
173412
|
const bundle = ctx.shared.get("bundle", "main");
|
|
173306
173413
|
const distDir = dirname8(fileURLToPath4(import.meta.url));
|
|
173307
|
-
const proxy =
|
|
173308
|
-
|
|
173309
|
-
|
|
173414
|
+
const proxy = createLambdaFunctionFromZip(group4, ctx, "function", `${id}-proxy`, {
|
|
173415
|
+
zipFile: join23(distDir, "/prebuild/sandbox-proxy/bundle.zip"),
|
|
173416
|
+
sourceHash: $file(join23(distDir, "/prebuild/sandbox-proxy/HASH")),
|
|
173310
173417
|
runtime: "nodejs24.x",
|
|
173311
173418
|
handler: "index.default",
|
|
173419
|
+
memorySize: mebibytes(512),
|
|
173312
173420
|
timeout: ctx.appConfig.defaults.function.timeout,
|
|
173313
173421
|
log: {
|
|
173314
173422
|
format: "json",
|
|
173315
173423
|
level: "warn",
|
|
173316
|
-
system: "
|
|
173424
|
+
system: "info",
|
|
173317
173425
|
retention: days8(3)
|
|
173318
173426
|
}
|
|
173319
173427
|
});
|
|
@@ -173330,9 +173438,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173330
173438
|
}
|
|
173331
173439
|
const configs = local.sandbox.configs ?? [];
|
|
173332
173440
|
if (configs.length > 0) {
|
|
173333
|
-
|
|
173334
|
-
variables[`CONFIG_${constantCase(configName)}`] = configName;
|
|
173335
|
-
}
|
|
173441
|
+
variables.CONFIGS = configs.join(",");
|
|
173336
173442
|
addPermission({
|
|
173337
173443
|
actions: [
|
|
173338
173444
|
"ssm:GetParameter",
|
|
@@ -173362,6 +173468,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173362
173468
|
logGroupName: logGroup.name,
|
|
173363
173469
|
filterPattern
|
|
173364
173470
|
}, {
|
|
173471
|
+
replaceOnChanges: ["destinationArn"],
|
|
173365
173472
|
dependsOn: [ctx.shared.get("on-error-log", "permission")]
|
|
173366
173473
|
});
|
|
173367
173474
|
}
|
|
@@ -173380,7 +173487,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173380
173487
|
}
|
|
173381
173488
|
};
|
|
173382
173489
|
};
|
|
173383
|
-
var
|
|
173490
|
+
var createLambdaFunctionFromZip = (parentGroup, ctx, ns, id, props) => {
|
|
173384
173491
|
let name;
|
|
173385
173492
|
let roleName;
|
|
173386
173493
|
const group4 = new Group(parentGroup, "function", id);
|
|
@@ -173411,12 +173518,11 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173411
173518
|
postfix: ctx.appId
|
|
173412
173519
|
});
|
|
173413
173520
|
}
|
|
173414
|
-
const sourceHash = $file(props.bundleHash);
|
|
173415
173521
|
const code = new aws3.s3.BucketObject(group4, "code", {
|
|
173416
173522
|
bucket: ctx.shared.get("asset", "bucket").name,
|
|
173417
173523
|
key: `lambda/${name}.zip`,
|
|
173418
|
-
source: relativePath(props.
|
|
173419
|
-
sourceHash
|
|
173524
|
+
source: relativePath(props.zipFile),
|
|
173525
|
+
sourceHash: props.sourceHash
|
|
173420
173526
|
}, {
|
|
173421
173527
|
replaceOnChanges: ["bucket", "key"]
|
|
173422
173528
|
});
|
|
@@ -173505,13 +173611,8 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173505
173611
|
},
|
|
173506
173612
|
s3Bucket: code.bucket,
|
|
173507
173613
|
s3ObjectVersion: code.versionId,
|
|
173508
|
-
s3Key: code.key
|
|
173509
|
-
|
|
173510
|
-
return name2.substring(1);
|
|
173511
|
-
}
|
|
173512
|
-
return name2;
|
|
173513
|
-
}),
|
|
173514
|
-
sourceCodeHash: sourceHash,
|
|
173614
|
+
s3Key: code.key,
|
|
173615
|
+
sourceCodeHash: props.sourceHash,
|
|
173515
173616
|
environment: {
|
|
173516
173617
|
variables
|
|
173517
173618
|
},
|
|
@@ -173529,11 +173630,35 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173529
173630
|
}, {
|
|
173530
173631
|
dependsOn
|
|
173531
173632
|
});
|
|
173633
|
+
const onFailure = getGlobalOnFailure(ctx);
|
|
173634
|
+
if (onFailure) {
|
|
173635
|
+
new aws3.lambda.FunctionEventInvokeConfig(group4, "async", {
|
|
173636
|
+
functionName: lambda.functionName,
|
|
173637
|
+
maximumRetryAttempts: 2,
|
|
173638
|
+
destinationConfig: {
|
|
173639
|
+
onFailure: {
|
|
173640
|
+
destination: onFailure
|
|
173641
|
+
}
|
|
173642
|
+
}
|
|
173643
|
+
}, {
|
|
173644
|
+
dependsOn: [policy]
|
|
173645
|
+
});
|
|
173646
|
+
addPermission({
|
|
173647
|
+
actions: ["s3:PutObject", "s3:ListBucket"],
|
|
173648
|
+
resources: [onFailure, $interpolate`${onFailure}/*`],
|
|
173649
|
+
conditions: {
|
|
173650
|
+
StringEquals: {
|
|
173651
|
+
"s3:ResourceAccount": ctx.accountId
|
|
173652
|
+
}
|
|
173653
|
+
}
|
|
173654
|
+
});
|
|
173655
|
+
}
|
|
173532
173656
|
variables.APP = ctx.appConfig.name;
|
|
173533
173657
|
variables.APP_ID = ctx.appId;
|
|
173534
173658
|
variables.AWS_ACCOUNT_ID = ctx.accountId;
|
|
173535
173659
|
variables.REGION = ctx.appConfig.region;
|
|
173536
173660
|
variables.STAGE = ctx.appConfig.stage ?? "default";
|
|
173661
|
+
variables.STANDALONE = "true";
|
|
173537
173662
|
if ("stackConfig" in ctx) {
|
|
173538
173663
|
variables.STACK = ctx.stackConfig.name;
|
|
173539
173664
|
}
|
|
@@ -173557,6 +173682,7 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173557
173682
|
logGroupName: logGroup.name,
|
|
173558
173683
|
filterPattern
|
|
173559
173684
|
}, {
|
|
173685
|
+
replaceOnChanges: ["destinationArn"],
|
|
173560
173686
|
dependsOn: [ctx.shared.get("on-error-log", "permission")]
|
|
173561
173687
|
});
|
|
173562
173688
|
}
|
|
@@ -173674,7 +173800,7 @@ var functionFeature = defineFeature({
|
|
|
173674
173800
|
});
|
|
173675
173801
|
|
|
173676
173802
|
// src/feature/on-error-log/index.ts
|
|
173677
|
-
import {
|
|
173803
|
+
import { days as days9 } from "@awsless/duration";
|
|
173678
173804
|
import { dirname as dirname9, join as join24 } from "path";
|
|
173679
173805
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
173680
173806
|
var onErrorLogFeature = defineFeature({
|
|
@@ -173685,73 +173811,61 @@ var onErrorLogFeature = defineFeature({
|
|
|
173685
173811
|
return;
|
|
173686
173812
|
}
|
|
173687
173813
|
const group4 = new Group(ctx.base, "on-error-log", "main");
|
|
173688
|
-
const bundle = ctx.shared.get("bundle", "main");
|
|
173689
173814
|
const consumer = props.consumer;
|
|
173690
|
-
const
|
|
173691
|
-
|
|
173692
|
-
|
|
173693
|
-
|
|
173694
|
-
|
|
173695
|
-
|
|
173696
|
-
|
|
173697
|
-
|
|
173698
|
-
|
|
173699
|
-
name: formatGlobalResourceName({
|
|
173700
|
-
appName: ctx.app.name,
|
|
173701
|
-
resourceType: "on-error-log",
|
|
173702
|
-
resourceName: "requests"
|
|
173703
|
-
}),
|
|
173704
|
-
hashKey: "id",
|
|
173705
|
-
billingMode: "PAY_PER_REQUEST",
|
|
173706
|
-
ttl: {
|
|
173707
|
-
enabled: true,
|
|
173708
|
-
attributeName: "ttl"
|
|
173709
|
-
},
|
|
173710
|
-
attribute: [
|
|
173711
|
-
{
|
|
173712
|
-
name: "id",
|
|
173713
|
-
type: "S"
|
|
173714
|
-
}
|
|
173715
|
-
]
|
|
173815
|
+
const name = formatGlobalResourceName({
|
|
173816
|
+
appName: ctx.app.name,
|
|
173817
|
+
resourceType: "on-error-log",
|
|
173818
|
+
resourceName: "handler"
|
|
173819
|
+
});
|
|
173820
|
+
const build2 = registerFunctionBuild(ctx, name, {
|
|
173821
|
+
code: consumer.code,
|
|
173822
|
+
handler: consumer.handler,
|
|
173823
|
+
wrapper: join24(dirname9(fileURLToPath5(import.meta.url)), "/handlers/on-error-log.js")
|
|
173716
173824
|
});
|
|
173717
|
-
|
|
173718
|
-
|
|
173719
|
-
|
|
173720
|
-
|
|
173721
|
-
|
|
173825
|
+
const handler = createLambdaFunctionFromZip(group4, ctx, "on-error-log", "handler", {
|
|
173826
|
+
zipFile: build2.zipFile,
|
|
173827
|
+
sourceHash: build2.sourceHash,
|
|
173828
|
+
runtime: "nodejs24.x",
|
|
173829
|
+
handler: "index.default",
|
|
173830
|
+
memorySize: consumer.memorySize ?? ctx.appConfig.defaults.function.memorySize,
|
|
173831
|
+
timeout: consumer.timeout ?? ctx.appConfig.defaults.function.timeout,
|
|
173832
|
+
architecture: consumer.architecture ?? ctx.appConfig.defaults.function.architecture,
|
|
173833
|
+
vpc: consumer.vpc,
|
|
173834
|
+
log: {
|
|
173835
|
+
format: consumer.log?.format ?? "json",
|
|
173836
|
+
level: consumer.log?.level ?? "warn",
|
|
173837
|
+
system: consumer.log?.system ?? "warn",
|
|
173838
|
+
retention: consumer.log?.retention ?? days9(3)
|
|
173839
|
+
}
|
|
173722
173840
|
});
|
|
173723
|
-
|
|
173841
|
+
ctx.onEnv(build2.addEnv);
|
|
173842
|
+
ctx.onBind(build2.addEnv);
|
|
173843
|
+
ctx.onPermission((statement) => handler.addPermission(statement));
|
|
173844
|
+
ctx.restartOnConfigChange(handler.lambda);
|
|
173724
173845
|
const permission = new aws3.lambda.Permission(group4, "permission", {
|
|
173725
173846
|
action: "lambda:InvokeFunction",
|
|
173726
173847
|
principal: "logs.amazonaws.com",
|
|
173727
|
-
functionName:
|
|
173728
|
-
qualifier: bundle.alias.name,
|
|
173848
|
+
functionName: handler.lambda.functionName,
|
|
173729
173849
|
sourceArn: `arn:aws:logs:${ctx.appConfig.region}:${ctx.accountId}:log-group:/aws/*/${ctx.app.name}--*`
|
|
173730
173850
|
}, {
|
|
173731
|
-
replaceOnChanges: ["functionName"
|
|
173851
|
+
replaceOnChanges: ["functionName"]
|
|
173732
173852
|
});
|
|
173733
|
-
|
|
173734
|
-
new aws3.cloudwatch.LogSubscriptionFilter(group4, "bundle", {
|
|
173735
|
-
name: "error-log-subscription",
|
|
173736
|
-
destinationArn: bundle.alias.arn,
|
|
173737
|
-
logGroupName: bundle.logGroup.name,
|
|
173738
|
-
filterPattern
|
|
173739
|
-
}, {
|
|
173740
|
-
dependsOn: [permission]
|
|
173741
|
-
});
|
|
173742
|
-
}
|
|
173743
|
-
ctx.shared.set("on-error-log", "subscriber-arn", bundle.alias.arn);
|
|
173853
|
+
ctx.shared.set("on-error-log", "subscriber-arn", handler.lambda.arn);
|
|
173744
173854
|
ctx.shared.set("on-error-log", "permission", permission);
|
|
173745
173855
|
}
|
|
173746
173856
|
});
|
|
173747
173857
|
|
|
173748
173858
|
// src/feature/on-failure/index.ts
|
|
173749
|
-
import { days as
|
|
173859
|
+
import { days as days10, toSeconds as toSeconds5 } from "@awsless/duration";
|
|
173750
173860
|
import { dirname as dirname10, join as join25 } from "path";
|
|
173751
173861
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
173752
173862
|
var onFailureFeature = defineFeature({
|
|
173753
173863
|
name: "on-failure",
|
|
173754
173864
|
onBefore(ctx) {
|
|
173865
|
+
const props = ctx.appConfig.defaults.onFailure;
|
|
173866
|
+
if (!props) {
|
|
173867
|
+
return;
|
|
173868
|
+
}
|
|
173755
173869
|
const group4 = new Group(ctx.base, "on-failure", "main");
|
|
173756
173870
|
const deadletter = new aws3.sqs.Queue(group4, "deadletter", {
|
|
173757
173871
|
name: formatGlobalResourceName({
|
|
@@ -173759,16 +173873,16 @@ var onFailureFeature = defineFeature({
|
|
|
173759
173873
|
resourceType: "on-failure",
|
|
173760
173874
|
resourceName: "deadletter"
|
|
173761
173875
|
}),
|
|
173762
|
-
messageRetentionSeconds: toSeconds5(
|
|
173876
|
+
messageRetentionSeconds: toSeconds5(days10(14))
|
|
173763
173877
|
});
|
|
173764
|
-
const
|
|
173878
|
+
const handlerTimeout = toSeconds5(props.consumer.timeout ?? ctx.appConfig.defaults.function.timeout);
|
|
173765
173879
|
const queue2 = new aws3.sqs.Queue(group4, "on-failure", {
|
|
173766
173880
|
name: formatGlobalResourceName({
|
|
173767
173881
|
appName: ctx.app.name,
|
|
173768
173882
|
resourceType: "on-failure",
|
|
173769
173883
|
resourceName: "failure"
|
|
173770
173884
|
}),
|
|
173771
|
-
visibilityTimeoutSeconds:
|
|
173885
|
+
visibilityTimeoutSeconds: handlerTimeout * 2,
|
|
173772
173886
|
redrivePolicy: deadletter.arn.pipe((deadLetterTargetArn) => {
|
|
173773
173887
|
return JSON.stringify({
|
|
173774
173888
|
deadLetterTargetArn,
|
|
@@ -173793,13 +173907,12 @@ var onFailureFeature = defineFeature({
|
|
|
173793
173907
|
}
|
|
173794
173908
|
]
|
|
173795
173909
|
});
|
|
173796
|
-
ctx.shared.set("on-failure", "bucket-arn", bucket.arn);
|
|
173797
173910
|
ctx.shared.set("on-failure", "resources", {
|
|
173798
173911
|
group: group4,
|
|
173799
173912
|
bucket,
|
|
173800
173913
|
queue: queue2
|
|
173801
173914
|
});
|
|
173802
|
-
const notify =
|
|
173915
|
+
const notify = props.notify;
|
|
173803
173916
|
if (notify) {
|
|
173804
173917
|
const topic = new aws3.sns.Topic(group4, "deadletter-topic", {
|
|
173805
173918
|
name: formatGlobalResourceName({
|
|
@@ -173893,28 +174006,39 @@ var onFailureFeature = defineFeature({
|
|
|
173893
174006
|
if (!props) {
|
|
173894
174007
|
return;
|
|
173895
174008
|
}
|
|
173896
|
-
const bundle = ctx.shared.get("bundle", "main");
|
|
173897
174009
|
const { group: group4, bucket, queue: queue2 } = ctx.shared.get("on-failure", "resources");
|
|
173898
|
-
|
|
173899
|
-
|
|
173900
|
-
|
|
173901
|
-
|
|
173902
|
-
|
|
174010
|
+
const name = formatGlobalResourceName({
|
|
174011
|
+
appName: ctx.app.name,
|
|
174012
|
+
resourceType: "on-failure",
|
|
174013
|
+
resourceName: "handler"
|
|
174014
|
+
});
|
|
174015
|
+
const consumer = props.consumer;
|
|
174016
|
+
const build2 = registerFunctionBuild(ctx, name, {
|
|
174017
|
+
code: consumer.code,
|
|
174018
|
+
handler: consumer.handler,
|
|
174019
|
+
wrapper: join25(dirname10(fileURLToPath6(import.meta.url)), "/handlers/on-failure.js")
|
|
174020
|
+
});
|
|
174021
|
+
const handler = createLambdaFunctionFromZip(group4, ctx, "on-failure", "handler", {
|
|
174022
|
+
zipFile: build2.zipFile,
|
|
174023
|
+
sourceHash: build2.sourceHash,
|
|
173903
174024
|
runtime: "nodejs24.x",
|
|
173904
174025
|
handler: "index.default",
|
|
173905
|
-
memorySize:
|
|
173906
|
-
timeout: ctx.appConfig.defaults.function.timeout,
|
|
174026
|
+
memorySize: consumer.memorySize ?? ctx.appConfig.defaults.function.memorySize,
|
|
174027
|
+
timeout: consumer.timeout ?? ctx.appConfig.defaults.function.timeout,
|
|
174028
|
+
architecture: consumer.architecture ?? ctx.appConfig.defaults.function.architecture,
|
|
174029
|
+
vpc: consumer.vpc,
|
|
173907
174030
|
log: {
|
|
173908
|
-
format: "json",
|
|
173909
|
-
level: "warn",
|
|
173910
|
-
system: "warn",
|
|
173911
|
-
retention:
|
|
174031
|
+
format: consumer.log?.format ?? "json",
|
|
174032
|
+
level: consumer.log?.level ?? "warn",
|
|
174033
|
+
system: consumer.log?.system ?? "warn",
|
|
174034
|
+
retention: consumer.log?.retention ?? days10(3)
|
|
173912
174035
|
}
|
|
173913
174036
|
});
|
|
174037
|
+
ctx.onEnv(build2.addEnv);
|
|
174038
|
+
ctx.onBind(build2.addEnv);
|
|
174039
|
+
ctx.onPermission((statement) => handler.addPermission(statement));
|
|
174040
|
+
ctx.restartOnConfigChange(handler.lambda);
|
|
173914
174041
|
handler.addPermission({
|
|
173915
|
-
actions: ["lambda:InvokeFunction"],
|
|
173916
|
-
resources: [bundle.alias.arn]
|
|
173917
|
-
}, {
|
|
173918
174042
|
actions: ["s3:GetObject", "s3:DeleteObject"],
|
|
173919
174043
|
resources: [$interpolate`${bucket.arn}/*`]
|
|
173920
174044
|
}, {
|
|
@@ -173968,6 +174092,7 @@ var onFailureFeature = defineFeature({
|
|
|
173968
174092
|
}
|
|
173969
174093
|
]
|
|
173970
174094
|
}, { dependsOn: [queuePolicy] });
|
|
174095
|
+
ctx.shared.set("on-failure", "bucket-arn", bucket.arn);
|
|
173971
174096
|
}
|
|
173972
174097
|
});
|
|
173973
174098
|
|
|
@@ -173975,19 +174100,19 @@ var onFailureFeature = defineFeature({
|
|
|
173975
174100
|
import { createHmac as createHmac5 } from "crypto";
|
|
173976
174101
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
173977
174102
|
import { dirname as dirname12, join as join28 } from "path";
|
|
173978
|
-
import { formatRouteEnvName as
|
|
174103
|
+
import { formatRouteEnvName as formatRouteEnvName2 } from "awsless";
|
|
173979
174104
|
|
|
173980
174105
|
// src/feature/pubsub/util.ts
|
|
173981
174106
|
import { toDays as toDays7 } from "@awsless/duration";
|
|
173982
174107
|
import { stringify as stringify2 } from "@awsless/json";
|
|
173983
174108
|
import { createHash as createHash18 } from "crypto";
|
|
173984
|
-
import { readFile as
|
|
174109
|
+
import { readFile as readFile18 } from "fs/promises";
|
|
173985
174110
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
173986
174111
|
import { dirname as dirname11, join as join27 } from "path";
|
|
173987
174112
|
|
|
173988
174113
|
// src/feature/instance/build/executable.ts
|
|
173989
174114
|
import { createHash as createHash17 } from "crypto";
|
|
173990
|
-
import { readFile as
|
|
174115
|
+
import { readFile as readFile17 } from "fs/promises";
|
|
173991
174116
|
import { join as join26 } from "path";
|
|
173992
174117
|
var buildExecutable = async (input, outputPath, architecture) => {
|
|
173993
174118
|
const filePath = join26(outputPath, "program");
|
|
@@ -174027,7 +174152,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
|
|
|
174027
174152
|
${result.logs?.map((log) => log.message).join(`
|
|
174028
174153
|
`)}`);
|
|
174029
174154
|
}
|
|
174030
|
-
const file2 = await
|
|
174155
|
+
const file2 = await readFile17(filePath);
|
|
174031
174156
|
return {
|
|
174032
174157
|
hash: createHash17("sha1").update(file2).update("x86_64").digest("hex"),
|
|
174033
174158
|
file: file2
|
|
@@ -174053,7 +174178,7 @@ var createPubSubService = (parentGroup, ctx, id, props, inputs) => {
|
|
|
174053
174178
|
const image = "public.ecr.aws/aws-cli/aws-cli:arm64";
|
|
174054
174179
|
const bundleFile = join27(__dirname2, "handlers/pubsub-server.js");
|
|
174055
174180
|
ctx.registerBuild("pubsub", name, async (build2) => {
|
|
174056
|
-
const hash2 = createHash18("sha1").update(await
|
|
174181
|
+
const hash2 = createHash18("sha1").update(await readFile18(bundleFile)).digest("hex");
|
|
174057
174182
|
const fingerprint = `${hash2}-${ARCHITECTURE}`;
|
|
174058
174183
|
return build2(fingerprint, async (write) => {
|
|
174059
174184
|
const temp = await createTempFolder(`pubsub--${name}`);
|
|
@@ -174585,9 +174710,9 @@ var pubsubFeature = defineFeature({
|
|
|
174585
174710
|
file: join28(__dirname3, "/handlers/pubsub-publisher.js"),
|
|
174586
174711
|
exportName: "default"
|
|
174587
174712
|
});
|
|
174588
|
-
bundle.addEnv(
|
|
174589
|
-
bundle.addEnv(
|
|
174590
|
-
bundle.addEnv(
|
|
174713
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_HOST"), redisHost);
|
|
174714
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_PORT"), redisPort.pipe((port) => port.toString()));
|
|
174715
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "CHANNEL"), channel);
|
|
174591
174716
|
const routerProps = ctx.appConfig.defaults.router?.[props.router];
|
|
174592
174717
|
if (!routerProps?.domain) {
|
|
174593
174718
|
throw new FileError("app.json", `The pubsub "${id}" requires the "${props.router}" router to have a domain configured.`);
|
|
@@ -174842,7 +174967,7 @@ var restFeature = defineFeature({
|
|
|
174842
174967
|
});
|
|
174843
174968
|
|
|
174844
174969
|
// src/feature/rpc/index.ts
|
|
174845
|
-
import { formatRouteEnvName as
|
|
174970
|
+
import { formatRouteEnvName as formatRouteEnvName3 } from "awsless";
|
|
174846
174971
|
import { dirname as dirname13, join as join29, relative as relative5 } from "path";
|
|
174847
174972
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
174848
174973
|
import { toSeconds as toSeconds7 } from "@awsless/duration";
|
|
@@ -174899,7 +175024,7 @@ var rpcFeature = defineFeature({
|
|
|
174899
175024
|
file: join29(dirname13(fileURLToPath9(import.meta.url)), "/handlers/rpc.js"),
|
|
174900
175025
|
exportName: "default"
|
|
174901
175026
|
});
|
|
174902
|
-
bundle.addEnv(
|
|
175027
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "TIMEOUT"), toSeconds7(ctx.appConfig.defaults.function.timeout).toString());
|
|
174903
175028
|
const lockTable = new aws3.dynamodb.Table(group4, "lock", {
|
|
174904
175029
|
name: formatGlobalResourceName({
|
|
174905
175030
|
appName: ctx.app.name,
|
|
@@ -174919,7 +175044,7 @@ var rpcFeature = defineFeature({
|
|
|
174919
175044
|
}
|
|
174920
175045
|
]
|
|
174921
175046
|
});
|
|
174922
|
-
bundle.addEnv(
|
|
175047
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "LOCK_TABLE"), lockTable.name);
|
|
174923
175048
|
bundle.addPermission({
|
|
174924
175049
|
effect: "allow",
|
|
174925
175050
|
actions: ["dynamodb:UpdateItem", "dynamodb:DeleteItem"],
|
|
@@ -174928,7 +175053,7 @@ var rpcFeature = defineFeature({
|
|
|
174928
175053
|
if (props.auth) {
|
|
174929
175054
|
const authRouteKey = formatRouteKey("base", "rpc", `${id}-auth`);
|
|
174930
175055
|
registerBundleFunction(ctx, authRouteKey, props.auth);
|
|
174931
|
-
bundle.addEnv(
|
|
175056
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "AUTH"), authRouteKey);
|
|
174932
175057
|
}
|
|
174933
175058
|
const addRoutes = ctx.shared.entry("router", "addRoutes", props.router);
|
|
174934
175059
|
addRoutes({
|
|
@@ -174953,7 +175078,7 @@ var rpcFeature = defineFeature({
|
|
|
174953
175078
|
const entryId = kebabCase(`${id}-${shortId(name)}`);
|
|
174954
175079
|
const routeKey = formatRouteKey(ctx.stack.name, "rpc", entryId);
|
|
174955
175080
|
registerBundleFunction(ctx, routeKey, props.function);
|
|
174956
|
-
bundle.addEnv(
|
|
175081
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, `QUERY:${name}`), JSON.stringify({ function: routeKey, lock: props.lock }));
|
|
174957
175082
|
}
|
|
174958
175083
|
}
|
|
174959
175084
|
}
|
|
@@ -175049,7 +175174,7 @@ import { createHash as createHash19 } from "crypto";
|
|
|
175049
175174
|
import { dirname as dirname15, join as join32 } from "path";
|
|
175050
175175
|
|
|
175051
175176
|
// src/util/cache.ts
|
|
175052
|
-
import { lstat as lstat3, readdir as
|
|
175177
|
+
import { lstat as lstat3, readdir as readdir5 } from "fs/promises";
|
|
175053
175178
|
import { join as join30 } from "path";
|
|
175054
175179
|
var generateCacheKey = async (directories2) => {
|
|
175055
175180
|
const files = await listAllFiles(directories2);
|
|
@@ -175073,7 +175198,7 @@ var listAllFiles = async (list2) => {
|
|
|
175073
175198
|
for (const entry of list2) {
|
|
175074
175199
|
const stat5 = await lstat3(entry);
|
|
175075
175200
|
if (stat5.isDirectory()) {
|
|
175076
|
-
const dirents = await
|
|
175201
|
+
const dirents = await readdir5(entry, {
|
|
175077
175202
|
recursive: true,
|
|
175078
175203
|
withFileTypes: true
|
|
175079
175204
|
});
|
|
@@ -175155,11 +175280,9 @@ var siteFeature = defineFeature({
|
|
|
175155
175280
|
AWS_SECRET_ACCESS_KEY: credentials4.secretAccessKey,
|
|
175156
175281
|
AWS_SESSION_TOKEN: credentials4.sessionToken
|
|
175157
175282
|
};
|
|
175158
|
-
|
|
175159
|
-
|
|
175160
|
-
|
|
175161
|
-
for (const name2 of ctx.stackConfig.configs ?? []) {
|
|
175162
|
-
env5[`CONFIG_${constantCase(name2)}`] = name2;
|
|
175283
|
+
const configs = props.build?.configs ?? [];
|
|
175284
|
+
if (configs.length > 0) {
|
|
175285
|
+
env5.CONFIGS = configs.join(",");
|
|
175163
175286
|
}
|
|
175164
175287
|
const instance = Bun.spawn(buildProps.command.split(" "), {
|
|
175165
175288
|
cwd,
|
|
@@ -175565,11 +175688,11 @@ var tableFeature = defineFeature({
|
|
|
175565
175688
|
parallelizationFactor: props.stream.concurrencyPerShard,
|
|
175566
175689
|
functionResponseTypes: ["ReportBatchItemFailures"],
|
|
175567
175690
|
startingPosition: "LATEST",
|
|
175568
|
-
destinationConfig: {
|
|
175691
|
+
destinationConfig: onFailure ? {
|
|
175569
175692
|
onFailure: {
|
|
175570
175693
|
destinationArn: onFailure
|
|
175571
175694
|
}
|
|
175572
|
-
}
|
|
175695
|
+
} : undefined
|
|
175573
175696
|
}, {
|
|
175574
175697
|
dependsOn: [bundle.policy]
|
|
175575
175698
|
});
|
|
@@ -176081,9 +176204,9 @@ var layerFeature = defineFeature({
|
|
|
176081
176204
|
|
|
176082
176205
|
// src/feature/image/index.ts
|
|
176083
176206
|
import { toDays as toDays9 } from "@awsless/duration";
|
|
176084
|
-
import { formatRouteEnvName as
|
|
176207
|
+
import { formatRouteEnvName as formatRouteEnvName4 } from "awsless";
|
|
176085
176208
|
import { createHash as createHash20 } from "crypto";
|
|
176086
|
-
import { readFile as
|
|
176209
|
+
import { readFile as readFile19 } from "fs/promises";
|
|
176087
176210
|
import { dirname as dirname16, join as join34 } from "path";
|
|
176088
176211
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
176089
176212
|
var imageFeature = defineFeature({
|
|
@@ -176106,7 +176229,7 @@ var imageFeature = defineFeature({
|
|
|
176106
176229
|
resourceName: "sharp"
|
|
176107
176230
|
});
|
|
176108
176231
|
ctx.registerBuild("image", layerId, async (build2) => {
|
|
176109
|
-
const file2 = await
|
|
176232
|
+
const file2 = await readFile19(path2);
|
|
176110
176233
|
const fingerprint = createHash20("sha1").update(file2).digest("hex");
|
|
176111
176234
|
return build2(fingerprint, async (write) => {
|
|
176112
176235
|
await Promise.all([
|
|
@@ -176195,17 +176318,17 @@ var imageFeature = defineFeature({
|
|
|
176195
176318
|
}
|
|
176196
176319
|
}
|
|
176197
176320
|
});
|
|
176198
|
-
bundle.addEnv(
|
|
176321
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_CONFIG"), JSON.stringify({
|
|
176199
176322
|
presets: props.presets,
|
|
176200
176323
|
extensions: props.extensions
|
|
176201
176324
|
}));
|
|
176202
|
-
bundle.addEnv(
|
|
176203
|
-
bundle.addEnv(
|
|
176325
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_BUCKET"), bucket.name);
|
|
176326
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_FOLDER"), folder);
|
|
176204
176327
|
if (originRouteKey) {
|
|
176205
|
-
bundle.addEnv(
|
|
176328
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN"), originRouteKey);
|
|
176206
176329
|
}
|
|
176207
176330
|
if (props.origin.static) {
|
|
176208
|
-
bundle.addEnv(
|
|
176331
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN_S3"), "true");
|
|
176209
176332
|
}
|
|
176210
176333
|
ctx.onReady(() => {
|
|
176211
176334
|
if (props.origin.static) {
|
|
@@ -176233,7 +176356,7 @@ var imageFeature = defineFeature({
|
|
|
176233
176356
|
|
|
176234
176357
|
// src/feature/icon/index.ts
|
|
176235
176358
|
import { toDays as toDays10 } from "@awsless/duration";
|
|
176236
|
-
import { formatRouteEnvName as
|
|
176359
|
+
import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
|
|
176237
176360
|
import { dirname as dirname17, join as join35 } from "path";
|
|
176238
176361
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
176239
176362
|
var iconFeature = defineFeature({
|
|
@@ -176281,17 +176404,17 @@ var iconFeature = defineFeature({
|
|
|
176281
176404
|
}
|
|
176282
176405
|
}
|
|
176283
176406
|
});
|
|
176284
|
-
bundle.addEnv(
|
|
176407
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_CONFIG"), JSON.stringify({
|
|
176285
176408
|
preserveIds: props.preserveIds,
|
|
176286
176409
|
symbols: props.symbols
|
|
176287
176410
|
}));
|
|
176288
|
-
bundle.addEnv(
|
|
176289
|
-
bundle.addEnv(
|
|
176411
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_BUCKET"), bucket.name);
|
|
176412
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_FOLDER"), folder);
|
|
176290
176413
|
if (originRouteKey) {
|
|
176291
|
-
bundle.addEnv(
|
|
176414
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN"), originRouteKey);
|
|
176292
176415
|
}
|
|
176293
176416
|
if (props.origin.static) {
|
|
176294
|
-
bundle.addEnv(
|
|
176417
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN_S3"), "true");
|
|
176295
176418
|
}
|
|
176296
176419
|
ctx.onReady(() => {
|
|
176297
176420
|
if (props.origin.static) {
|
|
@@ -176333,13 +176456,13 @@ var import_deepmerge4 = __toESM(require_cjs2(), 1);
|
|
|
176333
176456
|
|
|
176334
176457
|
// src/feature/job/build/executable.ts
|
|
176335
176458
|
import { createHash as createHash21 } from "crypto";
|
|
176336
|
-
import { readFile as
|
|
176459
|
+
import { readFile as readFile20, writeFile as writeFile11 } from "fs/promises";
|
|
176337
176460
|
import { join as join36, resolve as resolve3 } from "path";
|
|
176338
176461
|
var buildJobExecutable = async (input, outputPath, architecture) => {
|
|
176339
176462
|
const filePath = join36(outputPath, "program");
|
|
176340
176463
|
const wrapperPath = join36(outputPath, "wrapper.ts");
|
|
176341
176464
|
const handlerPath = resolve3(input);
|
|
176342
|
-
await
|
|
176465
|
+
await writeFile11(wrapperPath, `import { parse } from '@awsless/json'
|
|
176343
176466
|
import { getObject } from '@awsless/s3'
|
|
176344
176467
|
import handler from '${handlerPath}'
|
|
176345
176468
|
|
|
@@ -176388,7 +176511,7 @@ await handler(payload)
|
|
|
176388
176511
|
${result.logs?.map((log) => log.message).join(`
|
|
176389
176512
|
`)}`);
|
|
176390
176513
|
}
|
|
176391
|
-
const file2 = await
|
|
176514
|
+
const file2 = await readFile20(filePath);
|
|
176392
176515
|
return {
|
|
176393
176516
|
hash: createHash21("sha1").update(file2).update(target2).digest("hex"),
|
|
176394
176517
|
file: file2
|
|
@@ -176841,7 +176964,7 @@ var jobFeature = defineFeature({
|
|
|
176841
176964
|
});
|
|
176842
176965
|
|
|
176843
176966
|
// src/feature/instance/index.ts
|
|
176844
|
-
import { days as
|
|
176967
|
+
import { days as days11, seconds as seconds6, toSeconds as toSeconds11 } from "@awsless/duration";
|
|
176845
176968
|
|
|
176846
176969
|
// src/feature/instance/util.ts
|
|
176847
176970
|
import { toDays as toDays12, toSeconds as toSeconds10 } from "@awsless/duration";
|
|
@@ -177225,7 +177348,7 @@ var instanceFeature = defineFeature({
|
|
|
177225
177348
|
const queue2 = new aws3.sqs.Queue(group4, "queue", {
|
|
177226
177349
|
name: task2.name,
|
|
177227
177350
|
visibilityTimeoutSeconds: toSeconds11(seconds6(30)),
|
|
177228
|
-
messageRetentionSeconds: toSeconds11(
|
|
177351
|
+
messageRetentionSeconds: toSeconds11(days11(4)),
|
|
177229
177352
|
maxMessageSize: toBytes(kibibytes(256)),
|
|
177230
177353
|
receiveWaitTimeSeconds: toSeconds11(seconds6(20))
|
|
177231
177354
|
});
|
|
@@ -177383,7 +177506,7 @@ var metricFeature = defineFeature({
|
|
|
177383
177506
|
});
|
|
177384
177507
|
|
|
177385
177508
|
// src/feature/router/index.ts
|
|
177386
|
-
import { days as
|
|
177509
|
+
import { days as days12, seconds as seconds8, toSeconds as toSeconds14, years } from "@awsless/duration";
|
|
177387
177510
|
|
|
177388
177511
|
// src/feature/router/router-code.ts
|
|
177389
177512
|
import { minutes as minutes8, seconds as seconds7, toSeconds as toSeconds13 } from "@awsless/duration";
|
|
@@ -177939,8 +178062,8 @@ var routerFeature = defineFeature({
|
|
|
177939
178062
|
const cache7 = new aws3.cloudfront.CachePolicy(group4, "cache", {
|
|
177940
178063
|
name,
|
|
177941
178064
|
minTtl: toSeconds14(seconds8(0)),
|
|
177942
|
-
maxTtl: toSeconds14(
|
|
177943
|
-
defaultTtl: toSeconds14(
|
|
178065
|
+
maxTtl: toSeconds14(days12(365)),
|
|
178066
|
+
defaultTtl: toSeconds14(days12(0)),
|
|
177944
178067
|
parametersInCacheKeyAndForwardedToOrigin: {
|
|
177945
178068
|
enableAcceptEncodingBrotli: true,
|
|
177946
178069
|
enableAcceptEncodingGzip: true,
|
|
@@ -178417,11 +178540,11 @@ var features = [
|
|
|
178417
178540
|
routerFeature,
|
|
178418
178541
|
commandFeature,
|
|
178419
178542
|
layerFeature,
|
|
178543
|
+
onFailureFeature,
|
|
178544
|
+
onErrorLogFeature,
|
|
178545
|
+
bundleFeature,
|
|
178420
178546
|
authFeature,
|
|
178421
178547
|
functionFeature,
|
|
178422
|
-
bundleFeature,
|
|
178423
|
-
onErrorLogFeature,
|
|
178424
|
-
onFailureFeature,
|
|
178425
178548
|
instanceFeature,
|
|
178426
178549
|
jobFeature,
|
|
178427
178550
|
configFeature,
|
|
@@ -179226,6 +179349,12 @@ var createApp = (props) => {
|
|
|
179226
179349
|
registerDomainZone(zone) {
|
|
179227
179350
|
domainZones.push(zone);
|
|
179228
179351
|
},
|
|
179352
|
+
restartOnConfigChange(lambda) {
|
|
179353
|
+
for (const configName of props.appConfig.configs ?? []) {
|
|
179354
|
+
functionsByConfig[configName] ??= [];
|
|
179355
|
+
functionsByConfig[configName].push(lambda);
|
|
179356
|
+
}
|
|
179357
|
+
},
|
|
179229
179358
|
bind(name, value) {
|
|
179230
179359
|
binds.push({ name, value });
|
|
179231
179360
|
},
|
|
@@ -179272,7 +179401,7 @@ var createApp = (props) => {
|
|
|
179272
179401
|
addWarning(props2) {
|
|
179273
179402
|
warnings.push(props2);
|
|
179274
179403
|
},
|
|
179275
|
-
|
|
179404
|
+
restartOnConfigChange(lambda) {
|
|
179276
179405
|
for (const configName of props.appConfig.configs ?? []) {
|
|
179277
179406
|
functionsByConfig[configName] ??= [];
|
|
179278
179407
|
functionsByConfig[configName].push(lambda);
|
|
@@ -179787,7 +179916,7 @@ import { DynamoDBClient as DynamoDBClient4 } from "@awsless/dynamodb";
|
|
|
179787
179916
|
|
|
179788
179917
|
// src/cli/ui/complex/run-tests.ts
|
|
179789
179918
|
var import_wildstring3 = __toESM(require_wildstring(), 1);
|
|
179790
|
-
import { mkdir as mkdir6, readFile as
|
|
179919
|
+
import { mkdir as mkdir6, readFile as readFile21, writeFile as writeFile12 } from "fs/promises";
|
|
179791
179920
|
import { join as join39 } from "path";
|
|
179792
179921
|
import { parse as parse8, stringify as stringify5 } from "@awsless/json";
|
|
179793
179922
|
import { generateFolderHash, loadWorkspace as loadWorkspace2 } from "@awsless/ts-file-cache";
|
|
@@ -179974,7 +180103,7 @@ var runTest = async (stack, dir, filters, workspace, opts) => {
|
|
|
179974
180103
|
if (!process.env.NO_CACHE) {
|
|
179975
180104
|
const exists2 = await fileExist(file2);
|
|
179976
180105
|
if (exists2) {
|
|
179977
|
-
const raw = await
|
|
180106
|
+
const raw = await readFile21(file2, { encoding: "utf8" });
|
|
179978
180107
|
const data = parse8(raw);
|
|
179979
180108
|
if (data.fingerprint === fingerprint) {
|
|
179980
180109
|
logs_exports.step(formatResult({
|
|
@@ -180014,7 +180143,7 @@ var runTest = async (stack, dir, filters, workspace, opts) => {
|
|
|
180014
180143
|
logTestLogs(result);
|
|
180015
180144
|
}
|
|
180016
180145
|
logTestErrors(result);
|
|
180017
|
-
await
|
|
180146
|
+
await writeFile12(file2, stringify5({
|
|
180018
180147
|
...result,
|
|
180019
180148
|
fingerprint
|
|
180020
180149
|
}));
|
|
@@ -185710,8 +185839,8 @@ var bind = (program3) => {
|
|
|
185710
185839
|
}
|
|
185711
185840
|
const configList = opts.config ?? [];
|
|
185712
185841
|
const configs = {};
|
|
185713
|
-
|
|
185714
|
-
configs
|
|
185842
|
+
if (configList.length > 0) {
|
|
185843
|
+
configs.CONFIGS = configList.join(",");
|
|
185715
185844
|
}
|
|
185716
185845
|
if (configList.length ?? 0 > 0) {
|
|
185717
185846
|
logs_exports.note("Bind Config", configList.map((v7) => color2.label(constantCase(v7))).join(`
|
|
@@ -185793,7 +185922,7 @@ var {
|
|
|
185793
185922
|
isIBMi
|
|
185794
185923
|
} = require_constants7();
|
|
185795
185924
|
var stat5 = promisify4(fs3.stat);
|
|
185796
|
-
var
|
|
185925
|
+
var readdir6 = promisify4(fs3.readdir);
|
|
185797
185926
|
var arrify = (value = []) => Array.isArray(value) ? value : [value];
|
|
185798
185927
|
var flatten = (list3, result = []) => {
|
|
185799
185928
|
list3.forEach((item) => {
|
|
@@ -185865,7 +185994,7 @@ class DirEntry {
|
|
|
185865
185994
|
return;
|
|
185866
185995
|
const dir = this.path;
|
|
185867
185996
|
try {
|
|
185868
|
-
await
|
|
185997
|
+
await readdir6(dir);
|
|
185869
185998
|
} catch (err) {
|
|
185870
185999
|
if (this._removeWatcher) {
|
|
185871
186000
|
this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
|
@@ -186451,7 +186580,7 @@ var watchConfig = async (options, resolve4, reject) => {
|
|
|
186451
186580
|
};
|
|
186452
186581
|
|
|
186453
186582
|
// src/type-gen/generate.ts
|
|
186454
|
-
import { mkdir as mkdir7, writeFile as
|
|
186583
|
+
import { mkdir as mkdir7, writeFile as writeFile13 } from "fs/promises";
|
|
186455
186584
|
import { dirname as dirname19, join as join40, relative as relative8 } from "path";
|
|
186456
186585
|
var generateTypes = async (props) => {
|
|
186457
186586
|
const files = [];
|
|
@@ -186466,7 +186595,7 @@ var generateTypes = async (props) => {
|
|
|
186466
186595
|
files.push(relative8(directories.root, path2));
|
|
186467
186596
|
}
|
|
186468
186597
|
await mkdir7(dirname19(path2), { recursive: true });
|
|
186469
|
-
await
|
|
186598
|
+
await writeFile13(path2, code);
|
|
186470
186599
|
}
|
|
186471
186600
|
}
|
|
186472
186601
|
});
|
|
@@ -186474,7 +186603,7 @@ var generateTypes = async (props) => {
|
|
|
186474
186603
|
if (files.length) {
|
|
186475
186604
|
const code = files.map((file2) => `/// <reference path='${file2}' />`).join(`
|
|
186476
186605
|
`);
|
|
186477
|
-
await
|
|
186606
|
+
await writeFile13(join40(directories.root, `awsless.d.ts`), code);
|
|
186478
186607
|
}
|
|
186479
186608
|
};
|
|
186480
186609
|
|