@awsless/cli 0.0.46-next.34 → 0.0.46-next.35
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 +406 -278
- package/dist/handlers/bundle.js +0 -26
- package/dist/handlers/on-error-log.js +28 -71
- package/dist/handlers/on-failure.js +205 -0
- package/package.json +13 -13
- 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
|
|
@@ -161547,7 +161565,7 @@ var FunctionDefaultSchema = exports_external.object({
|
|
|
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,9 +173411,9 @@ 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",
|
|
173312
173419
|
timeout: ctx.appConfig.defaults.function.timeout,
|
|
@@ -173330,9 +173437,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173330
173437
|
}
|
|
173331
173438
|
const configs = local.sandbox.configs ?? [];
|
|
173332
173439
|
if (configs.length > 0) {
|
|
173333
|
-
|
|
173334
|
-
variables[`CONFIG_${constantCase(configName)}`] = configName;
|
|
173335
|
-
}
|
|
173440
|
+
variables.CONFIGS = configs.join(",");
|
|
173336
173441
|
addPermission({
|
|
173337
173442
|
actions: [
|
|
173338
173443
|
"ssm:GetParameter",
|
|
@@ -173362,6 +173467,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173362
173467
|
logGroupName: logGroup.name,
|
|
173363
173468
|
filterPattern
|
|
173364
173469
|
}, {
|
|
173470
|
+
replaceOnChanges: ["destinationArn"],
|
|
173365
173471
|
dependsOn: [ctx.shared.get("on-error-log", "permission")]
|
|
173366
173472
|
});
|
|
173367
173473
|
}
|
|
@@ -173380,7 +173486,7 @@ var createLambdaFunction = (ctx, id, local) => {
|
|
|
173380
173486
|
}
|
|
173381
173487
|
};
|
|
173382
173488
|
};
|
|
173383
|
-
var
|
|
173489
|
+
var createLambdaFunctionFromZip = (parentGroup, ctx, ns, id, props) => {
|
|
173384
173490
|
let name;
|
|
173385
173491
|
let roleName;
|
|
173386
173492
|
const group4 = new Group(parentGroup, "function", id);
|
|
@@ -173411,12 +173517,11 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173411
173517
|
postfix: ctx.appId
|
|
173412
173518
|
});
|
|
173413
173519
|
}
|
|
173414
|
-
const sourceHash = $file(props.bundleHash);
|
|
173415
173520
|
const code = new aws3.s3.BucketObject(group4, "code", {
|
|
173416
173521
|
bucket: ctx.shared.get("asset", "bucket").name,
|
|
173417
173522
|
key: `lambda/${name}.zip`,
|
|
173418
|
-
source: relativePath(props.
|
|
173419
|
-
sourceHash
|
|
173523
|
+
source: relativePath(props.zipFile),
|
|
173524
|
+
sourceHash: props.sourceHash
|
|
173420
173525
|
}, {
|
|
173421
173526
|
replaceOnChanges: ["bucket", "key"]
|
|
173422
173527
|
});
|
|
@@ -173505,13 +173610,8 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173505
173610
|
},
|
|
173506
173611
|
s3Bucket: code.bucket,
|
|
173507
173612
|
s3ObjectVersion: code.versionId,
|
|
173508
|
-
s3Key: code.key
|
|
173509
|
-
|
|
173510
|
-
return name2.substring(1);
|
|
173511
|
-
}
|
|
173512
|
-
return name2;
|
|
173513
|
-
}),
|
|
173514
|
-
sourceCodeHash: sourceHash,
|
|
173613
|
+
s3Key: code.key,
|
|
173614
|
+
sourceCodeHash: props.sourceHash,
|
|
173515
173615
|
environment: {
|
|
173516
173616
|
variables
|
|
173517
173617
|
},
|
|
@@ -173529,11 +173629,35 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173529
173629
|
}, {
|
|
173530
173630
|
dependsOn
|
|
173531
173631
|
});
|
|
173632
|
+
const onFailure = getGlobalOnFailure(ctx);
|
|
173633
|
+
if (onFailure) {
|
|
173634
|
+
new aws3.lambda.FunctionEventInvokeConfig(group4, "async", {
|
|
173635
|
+
functionName: lambda.functionName,
|
|
173636
|
+
maximumRetryAttempts: 2,
|
|
173637
|
+
destinationConfig: {
|
|
173638
|
+
onFailure: {
|
|
173639
|
+
destination: onFailure
|
|
173640
|
+
}
|
|
173641
|
+
}
|
|
173642
|
+
}, {
|
|
173643
|
+
dependsOn: [policy]
|
|
173644
|
+
});
|
|
173645
|
+
addPermission({
|
|
173646
|
+
actions: ["s3:PutObject", "s3:ListBucket"],
|
|
173647
|
+
resources: [onFailure, $interpolate`${onFailure}/*`],
|
|
173648
|
+
conditions: {
|
|
173649
|
+
StringEquals: {
|
|
173650
|
+
"s3:ResourceAccount": ctx.accountId
|
|
173651
|
+
}
|
|
173652
|
+
}
|
|
173653
|
+
});
|
|
173654
|
+
}
|
|
173532
173655
|
variables.APP = ctx.appConfig.name;
|
|
173533
173656
|
variables.APP_ID = ctx.appId;
|
|
173534
173657
|
variables.AWS_ACCOUNT_ID = ctx.accountId;
|
|
173535
173658
|
variables.REGION = ctx.appConfig.region;
|
|
173536
173659
|
variables.STAGE = ctx.appConfig.stage ?? "default";
|
|
173660
|
+
variables.STANDALONE = "true";
|
|
173537
173661
|
if ("stackConfig" in ctx) {
|
|
173538
173662
|
variables.STACK = ctx.stackConfig.name;
|
|
173539
173663
|
}
|
|
@@ -173557,6 +173681,7 @@ var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
|
173557
173681
|
logGroupName: logGroup.name,
|
|
173558
173682
|
filterPattern
|
|
173559
173683
|
}, {
|
|
173684
|
+
replaceOnChanges: ["destinationArn"],
|
|
173560
173685
|
dependsOn: [ctx.shared.get("on-error-log", "permission")]
|
|
173561
173686
|
});
|
|
173562
173687
|
}
|
|
@@ -173674,7 +173799,7 @@ var functionFeature = defineFeature({
|
|
|
173674
173799
|
});
|
|
173675
173800
|
|
|
173676
173801
|
// src/feature/on-error-log/index.ts
|
|
173677
|
-
import {
|
|
173802
|
+
import { days as days9 } from "@awsless/duration";
|
|
173678
173803
|
import { dirname as dirname9, join as join24 } from "path";
|
|
173679
173804
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
173680
173805
|
var onErrorLogFeature = defineFeature({
|
|
@@ -173685,73 +173810,61 @@ var onErrorLogFeature = defineFeature({
|
|
|
173685
173810
|
return;
|
|
173686
173811
|
}
|
|
173687
173812
|
const group4 = new Group(ctx.base, "on-error-log", "main");
|
|
173688
|
-
const bundle = ctx.shared.get("bundle", "main");
|
|
173689
173813
|
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
|
-
]
|
|
173814
|
+
const name = formatGlobalResourceName({
|
|
173815
|
+
appName: ctx.app.name,
|
|
173816
|
+
resourceType: "on-error-log",
|
|
173817
|
+
resourceName: "handler"
|
|
173818
|
+
});
|
|
173819
|
+
const build2 = registerFunctionBuild(ctx, name, {
|
|
173820
|
+
code: consumer.code,
|
|
173821
|
+
handler: consumer.handler,
|
|
173822
|
+
wrapper: join24(dirname9(fileURLToPath5(import.meta.url)), "/handlers/on-error-log.js")
|
|
173716
173823
|
});
|
|
173717
|
-
|
|
173718
|
-
|
|
173719
|
-
|
|
173720
|
-
|
|
173721
|
-
|
|
173824
|
+
const handler = createLambdaFunctionFromZip(group4, ctx, "on-error-log", "handler", {
|
|
173825
|
+
zipFile: build2.zipFile,
|
|
173826
|
+
sourceHash: build2.sourceHash,
|
|
173827
|
+
runtime: "nodejs24.x",
|
|
173828
|
+
handler: "index.default",
|
|
173829
|
+
memorySize: consumer.memorySize ?? ctx.appConfig.defaults.function.memorySize,
|
|
173830
|
+
timeout: consumer.timeout ?? ctx.appConfig.defaults.function.timeout,
|
|
173831
|
+
architecture: consumer.architecture ?? ctx.appConfig.defaults.function.architecture,
|
|
173832
|
+
vpc: consumer.vpc,
|
|
173833
|
+
log: {
|
|
173834
|
+
format: consumer.log?.format ?? "json",
|
|
173835
|
+
level: consumer.log?.level ?? "warn",
|
|
173836
|
+
system: consumer.log?.system ?? "warn",
|
|
173837
|
+
retention: consumer.log?.retention ?? days9(3)
|
|
173838
|
+
}
|
|
173722
173839
|
});
|
|
173723
|
-
|
|
173840
|
+
ctx.onEnv(build2.addEnv);
|
|
173841
|
+
ctx.onBind(build2.addEnv);
|
|
173842
|
+
ctx.onPermission((statement) => handler.addPermission(statement));
|
|
173843
|
+
ctx.restartOnConfigChange(handler.lambda);
|
|
173724
173844
|
const permission = new aws3.lambda.Permission(group4, "permission", {
|
|
173725
173845
|
action: "lambda:InvokeFunction",
|
|
173726
173846
|
principal: "logs.amazonaws.com",
|
|
173727
|
-
functionName:
|
|
173728
|
-
qualifier: bundle.alias.name,
|
|
173847
|
+
functionName: handler.lambda.functionName,
|
|
173729
173848
|
sourceArn: `arn:aws:logs:${ctx.appConfig.region}:${ctx.accountId}:log-group:/aws/*/${ctx.app.name}--*`
|
|
173730
173849
|
}, {
|
|
173731
|
-
replaceOnChanges: ["functionName"
|
|
173850
|
+
replaceOnChanges: ["functionName"]
|
|
173732
173851
|
});
|
|
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);
|
|
173852
|
+
ctx.shared.set("on-error-log", "subscriber-arn", handler.lambda.arn);
|
|
173744
173853
|
ctx.shared.set("on-error-log", "permission", permission);
|
|
173745
173854
|
}
|
|
173746
173855
|
});
|
|
173747
173856
|
|
|
173748
173857
|
// src/feature/on-failure/index.ts
|
|
173749
|
-
import { days as
|
|
173858
|
+
import { days as days10, toSeconds as toSeconds5 } from "@awsless/duration";
|
|
173750
173859
|
import { dirname as dirname10, join as join25 } from "path";
|
|
173751
173860
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
173752
173861
|
var onFailureFeature = defineFeature({
|
|
173753
173862
|
name: "on-failure",
|
|
173754
173863
|
onBefore(ctx) {
|
|
173864
|
+
const props = ctx.appConfig.defaults.onFailure;
|
|
173865
|
+
if (!props) {
|
|
173866
|
+
return;
|
|
173867
|
+
}
|
|
173755
173868
|
const group4 = new Group(ctx.base, "on-failure", "main");
|
|
173756
173869
|
const deadletter = new aws3.sqs.Queue(group4, "deadletter", {
|
|
173757
173870
|
name: formatGlobalResourceName({
|
|
@@ -173759,16 +173872,16 @@ var onFailureFeature = defineFeature({
|
|
|
173759
173872
|
resourceType: "on-failure",
|
|
173760
173873
|
resourceName: "deadletter"
|
|
173761
173874
|
}),
|
|
173762
|
-
messageRetentionSeconds: toSeconds5(
|
|
173875
|
+
messageRetentionSeconds: toSeconds5(days10(14))
|
|
173763
173876
|
});
|
|
173764
|
-
const
|
|
173877
|
+
const handlerTimeout = toSeconds5(props.consumer.timeout ?? ctx.appConfig.defaults.function.timeout);
|
|
173765
173878
|
const queue2 = new aws3.sqs.Queue(group4, "on-failure", {
|
|
173766
173879
|
name: formatGlobalResourceName({
|
|
173767
173880
|
appName: ctx.app.name,
|
|
173768
173881
|
resourceType: "on-failure",
|
|
173769
173882
|
resourceName: "failure"
|
|
173770
173883
|
}),
|
|
173771
|
-
visibilityTimeoutSeconds:
|
|
173884
|
+
visibilityTimeoutSeconds: handlerTimeout * 2,
|
|
173772
173885
|
redrivePolicy: deadletter.arn.pipe((deadLetterTargetArn) => {
|
|
173773
173886
|
return JSON.stringify({
|
|
173774
173887
|
deadLetterTargetArn,
|
|
@@ -173793,13 +173906,12 @@ var onFailureFeature = defineFeature({
|
|
|
173793
173906
|
}
|
|
173794
173907
|
]
|
|
173795
173908
|
});
|
|
173796
|
-
ctx.shared.set("on-failure", "bucket-arn", bucket.arn);
|
|
173797
173909
|
ctx.shared.set("on-failure", "resources", {
|
|
173798
173910
|
group: group4,
|
|
173799
173911
|
bucket,
|
|
173800
173912
|
queue: queue2
|
|
173801
173913
|
});
|
|
173802
|
-
const notify =
|
|
173914
|
+
const notify = props.notify;
|
|
173803
173915
|
if (notify) {
|
|
173804
173916
|
const topic = new aws3.sns.Topic(group4, "deadletter-topic", {
|
|
173805
173917
|
name: formatGlobalResourceName({
|
|
@@ -173893,28 +174005,39 @@ var onFailureFeature = defineFeature({
|
|
|
173893
174005
|
if (!props) {
|
|
173894
174006
|
return;
|
|
173895
174007
|
}
|
|
173896
|
-
const bundle = ctx.shared.get("bundle", "main");
|
|
173897
174008
|
const { group: group4, bucket, queue: queue2 } = ctx.shared.get("on-failure", "resources");
|
|
173898
|
-
|
|
173899
|
-
|
|
173900
|
-
|
|
173901
|
-
|
|
173902
|
-
|
|
174009
|
+
const name = formatGlobalResourceName({
|
|
174010
|
+
appName: ctx.app.name,
|
|
174011
|
+
resourceType: "on-failure",
|
|
174012
|
+
resourceName: "handler"
|
|
174013
|
+
});
|
|
174014
|
+
const consumer = props.consumer;
|
|
174015
|
+
const build2 = registerFunctionBuild(ctx, name, {
|
|
174016
|
+
code: consumer.code,
|
|
174017
|
+
handler: consumer.handler,
|
|
174018
|
+
wrapper: join25(dirname10(fileURLToPath6(import.meta.url)), "/handlers/on-failure.js")
|
|
174019
|
+
});
|
|
174020
|
+
const handler = createLambdaFunctionFromZip(group4, ctx, "on-failure", "handler", {
|
|
174021
|
+
zipFile: build2.zipFile,
|
|
174022
|
+
sourceHash: build2.sourceHash,
|
|
173903
174023
|
runtime: "nodejs24.x",
|
|
173904
174024
|
handler: "index.default",
|
|
173905
|
-
memorySize:
|
|
173906
|
-
timeout: ctx.appConfig.defaults.function.timeout,
|
|
174025
|
+
memorySize: consumer.memorySize ?? ctx.appConfig.defaults.function.memorySize,
|
|
174026
|
+
timeout: consumer.timeout ?? ctx.appConfig.defaults.function.timeout,
|
|
174027
|
+
architecture: consumer.architecture ?? ctx.appConfig.defaults.function.architecture,
|
|
174028
|
+
vpc: consumer.vpc,
|
|
173907
174029
|
log: {
|
|
173908
|
-
format: "json",
|
|
173909
|
-
level: "warn",
|
|
173910
|
-
system: "warn",
|
|
173911
|
-
retention:
|
|
174030
|
+
format: consumer.log?.format ?? "json",
|
|
174031
|
+
level: consumer.log?.level ?? "warn",
|
|
174032
|
+
system: consumer.log?.system ?? "warn",
|
|
174033
|
+
retention: consumer.log?.retention ?? days10(3)
|
|
173912
174034
|
}
|
|
173913
174035
|
});
|
|
174036
|
+
ctx.onEnv(build2.addEnv);
|
|
174037
|
+
ctx.onBind(build2.addEnv);
|
|
174038
|
+
ctx.onPermission((statement) => handler.addPermission(statement));
|
|
174039
|
+
ctx.restartOnConfigChange(handler.lambda);
|
|
173914
174040
|
handler.addPermission({
|
|
173915
|
-
actions: ["lambda:InvokeFunction"],
|
|
173916
|
-
resources: [bundle.alias.arn]
|
|
173917
|
-
}, {
|
|
173918
174041
|
actions: ["s3:GetObject", "s3:DeleteObject"],
|
|
173919
174042
|
resources: [$interpolate`${bucket.arn}/*`]
|
|
173920
174043
|
}, {
|
|
@@ -173968,6 +174091,7 @@ var onFailureFeature = defineFeature({
|
|
|
173968
174091
|
}
|
|
173969
174092
|
]
|
|
173970
174093
|
}, { dependsOn: [queuePolicy] });
|
|
174094
|
+
ctx.shared.set("on-failure", "bucket-arn", bucket.arn);
|
|
173971
174095
|
}
|
|
173972
174096
|
});
|
|
173973
174097
|
|
|
@@ -173975,19 +174099,19 @@ var onFailureFeature = defineFeature({
|
|
|
173975
174099
|
import { createHmac as createHmac5 } from "crypto";
|
|
173976
174100
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
173977
174101
|
import { dirname as dirname12, join as join28 } from "path";
|
|
173978
|
-
import { formatRouteEnvName as
|
|
174102
|
+
import { formatRouteEnvName as formatRouteEnvName2 } from "awsless";
|
|
173979
174103
|
|
|
173980
174104
|
// src/feature/pubsub/util.ts
|
|
173981
174105
|
import { toDays as toDays7 } from "@awsless/duration";
|
|
173982
174106
|
import { stringify as stringify2 } from "@awsless/json";
|
|
173983
174107
|
import { createHash as createHash18 } from "crypto";
|
|
173984
|
-
import { readFile as
|
|
174108
|
+
import { readFile as readFile18 } from "fs/promises";
|
|
173985
174109
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
173986
174110
|
import { dirname as dirname11, join as join27 } from "path";
|
|
173987
174111
|
|
|
173988
174112
|
// src/feature/instance/build/executable.ts
|
|
173989
174113
|
import { createHash as createHash17 } from "crypto";
|
|
173990
|
-
import { readFile as
|
|
174114
|
+
import { readFile as readFile17 } from "fs/promises";
|
|
173991
174115
|
import { join as join26 } from "path";
|
|
173992
174116
|
var buildExecutable = async (input, outputPath, architecture) => {
|
|
173993
174117
|
const filePath = join26(outputPath, "program");
|
|
@@ -174027,7 +174151,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
|
|
|
174027
174151
|
${result.logs?.map((log) => log.message).join(`
|
|
174028
174152
|
`)}`);
|
|
174029
174153
|
}
|
|
174030
|
-
const file2 = await
|
|
174154
|
+
const file2 = await readFile17(filePath);
|
|
174031
174155
|
return {
|
|
174032
174156
|
hash: createHash17("sha1").update(file2).update("x86_64").digest("hex"),
|
|
174033
174157
|
file: file2
|
|
@@ -174053,7 +174177,7 @@ var createPubSubService = (parentGroup, ctx, id, props, inputs) => {
|
|
|
174053
174177
|
const image = "public.ecr.aws/aws-cli/aws-cli:arm64";
|
|
174054
174178
|
const bundleFile = join27(__dirname2, "handlers/pubsub-server.js");
|
|
174055
174179
|
ctx.registerBuild("pubsub", name, async (build2) => {
|
|
174056
|
-
const hash2 = createHash18("sha1").update(await
|
|
174180
|
+
const hash2 = createHash18("sha1").update(await readFile18(bundleFile)).digest("hex");
|
|
174057
174181
|
const fingerprint = `${hash2}-${ARCHITECTURE}`;
|
|
174058
174182
|
return build2(fingerprint, async (write) => {
|
|
174059
174183
|
const temp = await createTempFolder(`pubsub--${name}`);
|
|
@@ -174585,9 +174709,9 @@ var pubsubFeature = defineFeature({
|
|
|
174585
174709
|
file: join28(__dirname3, "/handlers/pubsub-publisher.js"),
|
|
174586
174710
|
exportName: "default"
|
|
174587
174711
|
});
|
|
174588
|
-
bundle.addEnv(
|
|
174589
|
-
bundle.addEnv(
|
|
174590
|
-
bundle.addEnv(
|
|
174712
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_HOST"), redisHost);
|
|
174713
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_PORT"), redisPort.pipe((port) => port.toString()));
|
|
174714
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "CHANNEL"), channel);
|
|
174591
174715
|
const routerProps = ctx.appConfig.defaults.router?.[props.router];
|
|
174592
174716
|
if (!routerProps?.domain) {
|
|
174593
174717
|
throw new FileError("app.json", `The pubsub "${id}" requires the "${props.router}" router to have a domain configured.`);
|
|
@@ -174842,7 +174966,7 @@ var restFeature = defineFeature({
|
|
|
174842
174966
|
});
|
|
174843
174967
|
|
|
174844
174968
|
// src/feature/rpc/index.ts
|
|
174845
|
-
import { formatRouteEnvName as
|
|
174969
|
+
import { formatRouteEnvName as formatRouteEnvName3 } from "awsless";
|
|
174846
174970
|
import { dirname as dirname13, join as join29, relative as relative5 } from "path";
|
|
174847
174971
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
174848
174972
|
import { toSeconds as toSeconds7 } from "@awsless/duration";
|
|
@@ -174899,7 +175023,7 @@ var rpcFeature = defineFeature({
|
|
|
174899
175023
|
file: join29(dirname13(fileURLToPath9(import.meta.url)), "/handlers/rpc.js"),
|
|
174900
175024
|
exportName: "default"
|
|
174901
175025
|
});
|
|
174902
|
-
bundle.addEnv(
|
|
175026
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "TIMEOUT"), toSeconds7(ctx.appConfig.defaults.function.timeout).toString());
|
|
174903
175027
|
const lockTable = new aws3.dynamodb.Table(group4, "lock", {
|
|
174904
175028
|
name: formatGlobalResourceName({
|
|
174905
175029
|
appName: ctx.app.name,
|
|
@@ -174919,7 +175043,7 @@ var rpcFeature = defineFeature({
|
|
|
174919
175043
|
}
|
|
174920
175044
|
]
|
|
174921
175045
|
});
|
|
174922
|
-
bundle.addEnv(
|
|
175046
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "LOCK_TABLE"), lockTable.name);
|
|
174923
175047
|
bundle.addPermission({
|
|
174924
175048
|
effect: "allow",
|
|
174925
175049
|
actions: ["dynamodb:UpdateItem", "dynamodb:DeleteItem"],
|
|
@@ -174928,7 +175052,7 @@ var rpcFeature = defineFeature({
|
|
|
174928
175052
|
if (props.auth) {
|
|
174929
175053
|
const authRouteKey = formatRouteKey("base", "rpc", `${id}-auth`);
|
|
174930
175054
|
registerBundleFunction(ctx, authRouteKey, props.auth);
|
|
174931
|
-
bundle.addEnv(
|
|
175055
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "AUTH"), authRouteKey);
|
|
174932
175056
|
}
|
|
174933
175057
|
const addRoutes = ctx.shared.entry("router", "addRoutes", props.router);
|
|
174934
175058
|
addRoutes({
|
|
@@ -174953,7 +175077,7 @@ var rpcFeature = defineFeature({
|
|
|
174953
175077
|
const entryId = kebabCase(`${id}-${shortId(name)}`);
|
|
174954
175078
|
const routeKey = formatRouteKey(ctx.stack.name, "rpc", entryId);
|
|
174955
175079
|
registerBundleFunction(ctx, routeKey, props.function);
|
|
174956
|
-
bundle.addEnv(
|
|
175080
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, `QUERY:${name}`), JSON.stringify({ function: routeKey, lock: props.lock }));
|
|
174957
175081
|
}
|
|
174958
175082
|
}
|
|
174959
175083
|
}
|
|
@@ -175049,7 +175173,7 @@ import { createHash as createHash19 } from "crypto";
|
|
|
175049
175173
|
import { dirname as dirname15, join as join32 } from "path";
|
|
175050
175174
|
|
|
175051
175175
|
// src/util/cache.ts
|
|
175052
|
-
import { lstat as lstat3, readdir as
|
|
175176
|
+
import { lstat as lstat3, readdir as readdir5 } from "fs/promises";
|
|
175053
175177
|
import { join as join30 } from "path";
|
|
175054
175178
|
var generateCacheKey = async (directories2) => {
|
|
175055
175179
|
const files = await listAllFiles(directories2);
|
|
@@ -175073,7 +175197,7 @@ var listAllFiles = async (list2) => {
|
|
|
175073
175197
|
for (const entry of list2) {
|
|
175074
175198
|
const stat5 = await lstat3(entry);
|
|
175075
175199
|
if (stat5.isDirectory()) {
|
|
175076
|
-
const dirents = await
|
|
175200
|
+
const dirents = await readdir5(entry, {
|
|
175077
175201
|
recursive: true,
|
|
175078
175202
|
withFileTypes: true
|
|
175079
175203
|
});
|
|
@@ -175155,11 +175279,9 @@ var siteFeature = defineFeature({
|
|
|
175155
175279
|
AWS_SECRET_ACCESS_KEY: credentials4.secretAccessKey,
|
|
175156
175280
|
AWS_SESSION_TOKEN: credentials4.sessionToken
|
|
175157
175281
|
};
|
|
175158
|
-
|
|
175159
|
-
|
|
175160
|
-
|
|
175161
|
-
for (const name2 of ctx.stackConfig.configs ?? []) {
|
|
175162
|
-
env5[`CONFIG_${constantCase(name2)}`] = name2;
|
|
175282
|
+
const configs = props.build?.configs ?? [];
|
|
175283
|
+
if (configs.length > 0) {
|
|
175284
|
+
env5.CONFIGS = configs.join(",");
|
|
175163
175285
|
}
|
|
175164
175286
|
const instance = Bun.spawn(buildProps.command.split(" "), {
|
|
175165
175287
|
cwd,
|
|
@@ -175565,11 +175687,11 @@ var tableFeature = defineFeature({
|
|
|
175565
175687
|
parallelizationFactor: props.stream.concurrencyPerShard,
|
|
175566
175688
|
functionResponseTypes: ["ReportBatchItemFailures"],
|
|
175567
175689
|
startingPosition: "LATEST",
|
|
175568
|
-
destinationConfig: {
|
|
175690
|
+
destinationConfig: onFailure ? {
|
|
175569
175691
|
onFailure: {
|
|
175570
175692
|
destinationArn: onFailure
|
|
175571
175693
|
}
|
|
175572
|
-
}
|
|
175694
|
+
} : undefined
|
|
175573
175695
|
}, {
|
|
175574
175696
|
dependsOn: [bundle.policy]
|
|
175575
175697
|
});
|
|
@@ -176081,9 +176203,9 @@ var layerFeature = defineFeature({
|
|
|
176081
176203
|
|
|
176082
176204
|
// src/feature/image/index.ts
|
|
176083
176205
|
import { toDays as toDays9 } from "@awsless/duration";
|
|
176084
|
-
import { formatRouteEnvName as
|
|
176206
|
+
import { formatRouteEnvName as formatRouteEnvName4 } from "awsless";
|
|
176085
176207
|
import { createHash as createHash20 } from "crypto";
|
|
176086
|
-
import { readFile as
|
|
176208
|
+
import { readFile as readFile19 } from "fs/promises";
|
|
176087
176209
|
import { dirname as dirname16, join as join34 } from "path";
|
|
176088
176210
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
176089
176211
|
var imageFeature = defineFeature({
|
|
@@ -176106,7 +176228,7 @@ var imageFeature = defineFeature({
|
|
|
176106
176228
|
resourceName: "sharp"
|
|
176107
176229
|
});
|
|
176108
176230
|
ctx.registerBuild("image", layerId, async (build2) => {
|
|
176109
|
-
const file2 = await
|
|
176231
|
+
const file2 = await readFile19(path2);
|
|
176110
176232
|
const fingerprint = createHash20("sha1").update(file2).digest("hex");
|
|
176111
176233
|
return build2(fingerprint, async (write) => {
|
|
176112
176234
|
await Promise.all([
|
|
@@ -176195,17 +176317,17 @@ var imageFeature = defineFeature({
|
|
|
176195
176317
|
}
|
|
176196
176318
|
}
|
|
176197
176319
|
});
|
|
176198
|
-
bundle.addEnv(
|
|
176320
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_CONFIG"), JSON.stringify({
|
|
176199
176321
|
presets: props.presets,
|
|
176200
176322
|
extensions: props.extensions
|
|
176201
176323
|
}));
|
|
176202
|
-
bundle.addEnv(
|
|
176203
|
-
bundle.addEnv(
|
|
176324
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_BUCKET"), bucket.name);
|
|
176325
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_FOLDER"), folder);
|
|
176204
176326
|
if (originRouteKey) {
|
|
176205
|
-
bundle.addEnv(
|
|
176327
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN"), originRouteKey);
|
|
176206
176328
|
}
|
|
176207
176329
|
if (props.origin.static) {
|
|
176208
|
-
bundle.addEnv(
|
|
176330
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN_S3"), "true");
|
|
176209
176331
|
}
|
|
176210
176332
|
ctx.onReady(() => {
|
|
176211
176333
|
if (props.origin.static) {
|
|
@@ -176233,7 +176355,7 @@ var imageFeature = defineFeature({
|
|
|
176233
176355
|
|
|
176234
176356
|
// src/feature/icon/index.ts
|
|
176235
176357
|
import { toDays as toDays10 } from "@awsless/duration";
|
|
176236
|
-
import { formatRouteEnvName as
|
|
176358
|
+
import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
|
|
176237
176359
|
import { dirname as dirname17, join as join35 } from "path";
|
|
176238
176360
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
176239
176361
|
var iconFeature = defineFeature({
|
|
@@ -176281,17 +176403,17 @@ var iconFeature = defineFeature({
|
|
|
176281
176403
|
}
|
|
176282
176404
|
}
|
|
176283
176405
|
});
|
|
176284
|
-
bundle.addEnv(
|
|
176406
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_CONFIG"), JSON.stringify({
|
|
176285
176407
|
preserveIds: props.preserveIds,
|
|
176286
176408
|
symbols: props.symbols
|
|
176287
176409
|
}));
|
|
176288
|
-
bundle.addEnv(
|
|
176289
|
-
bundle.addEnv(
|
|
176410
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_BUCKET"), bucket.name);
|
|
176411
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_FOLDER"), folder);
|
|
176290
176412
|
if (originRouteKey) {
|
|
176291
|
-
bundle.addEnv(
|
|
176413
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN"), originRouteKey);
|
|
176292
176414
|
}
|
|
176293
176415
|
if (props.origin.static) {
|
|
176294
|
-
bundle.addEnv(
|
|
176416
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN_S3"), "true");
|
|
176295
176417
|
}
|
|
176296
176418
|
ctx.onReady(() => {
|
|
176297
176419
|
if (props.origin.static) {
|
|
@@ -176333,13 +176455,13 @@ var import_deepmerge4 = __toESM(require_cjs2(), 1);
|
|
|
176333
176455
|
|
|
176334
176456
|
// src/feature/job/build/executable.ts
|
|
176335
176457
|
import { createHash as createHash21 } from "crypto";
|
|
176336
|
-
import { readFile as
|
|
176458
|
+
import { readFile as readFile20, writeFile as writeFile11 } from "fs/promises";
|
|
176337
176459
|
import { join as join36, resolve as resolve3 } from "path";
|
|
176338
176460
|
var buildJobExecutable = async (input, outputPath, architecture) => {
|
|
176339
176461
|
const filePath = join36(outputPath, "program");
|
|
176340
176462
|
const wrapperPath = join36(outputPath, "wrapper.ts");
|
|
176341
176463
|
const handlerPath = resolve3(input);
|
|
176342
|
-
await
|
|
176464
|
+
await writeFile11(wrapperPath, `import { parse } from '@awsless/json'
|
|
176343
176465
|
import { getObject } from '@awsless/s3'
|
|
176344
176466
|
import handler from '${handlerPath}'
|
|
176345
176467
|
|
|
@@ -176388,7 +176510,7 @@ await handler(payload)
|
|
|
176388
176510
|
${result.logs?.map((log) => log.message).join(`
|
|
176389
176511
|
`)}`);
|
|
176390
176512
|
}
|
|
176391
|
-
const file2 = await
|
|
176513
|
+
const file2 = await readFile20(filePath);
|
|
176392
176514
|
return {
|
|
176393
176515
|
hash: createHash21("sha1").update(file2).update(target2).digest("hex"),
|
|
176394
176516
|
file: file2
|
|
@@ -176841,7 +176963,7 @@ var jobFeature = defineFeature({
|
|
|
176841
176963
|
});
|
|
176842
176964
|
|
|
176843
176965
|
// src/feature/instance/index.ts
|
|
176844
|
-
import { days as
|
|
176966
|
+
import { days as days11, seconds as seconds6, toSeconds as toSeconds11 } from "@awsless/duration";
|
|
176845
176967
|
|
|
176846
176968
|
// src/feature/instance/util.ts
|
|
176847
176969
|
import { toDays as toDays12, toSeconds as toSeconds10 } from "@awsless/duration";
|
|
@@ -177225,7 +177347,7 @@ var instanceFeature = defineFeature({
|
|
|
177225
177347
|
const queue2 = new aws3.sqs.Queue(group4, "queue", {
|
|
177226
177348
|
name: task2.name,
|
|
177227
177349
|
visibilityTimeoutSeconds: toSeconds11(seconds6(30)),
|
|
177228
|
-
messageRetentionSeconds: toSeconds11(
|
|
177350
|
+
messageRetentionSeconds: toSeconds11(days11(4)),
|
|
177229
177351
|
maxMessageSize: toBytes(kibibytes(256)),
|
|
177230
177352
|
receiveWaitTimeSeconds: toSeconds11(seconds6(20))
|
|
177231
177353
|
});
|
|
@@ -177383,7 +177505,7 @@ var metricFeature = defineFeature({
|
|
|
177383
177505
|
});
|
|
177384
177506
|
|
|
177385
177507
|
// src/feature/router/index.ts
|
|
177386
|
-
import { days as
|
|
177508
|
+
import { days as days12, seconds as seconds8, toSeconds as toSeconds14, years } from "@awsless/duration";
|
|
177387
177509
|
|
|
177388
177510
|
// src/feature/router/router-code.ts
|
|
177389
177511
|
import { minutes as minutes8, seconds as seconds7, toSeconds as toSeconds13 } from "@awsless/duration";
|
|
@@ -177939,8 +178061,8 @@ var routerFeature = defineFeature({
|
|
|
177939
178061
|
const cache7 = new aws3.cloudfront.CachePolicy(group4, "cache", {
|
|
177940
178062
|
name,
|
|
177941
178063
|
minTtl: toSeconds14(seconds8(0)),
|
|
177942
|
-
maxTtl: toSeconds14(
|
|
177943
|
-
defaultTtl: toSeconds14(
|
|
178064
|
+
maxTtl: toSeconds14(days12(365)),
|
|
178065
|
+
defaultTtl: toSeconds14(days12(0)),
|
|
177944
178066
|
parametersInCacheKeyAndForwardedToOrigin: {
|
|
177945
178067
|
enableAcceptEncodingBrotli: true,
|
|
177946
178068
|
enableAcceptEncodingGzip: true,
|
|
@@ -178417,11 +178539,11 @@ var features = [
|
|
|
178417
178539
|
routerFeature,
|
|
178418
178540
|
commandFeature,
|
|
178419
178541
|
layerFeature,
|
|
178542
|
+
onFailureFeature,
|
|
178543
|
+
onErrorLogFeature,
|
|
178544
|
+
bundleFeature,
|
|
178420
178545
|
authFeature,
|
|
178421
178546
|
functionFeature,
|
|
178422
|
-
bundleFeature,
|
|
178423
|
-
onErrorLogFeature,
|
|
178424
|
-
onFailureFeature,
|
|
178425
178547
|
instanceFeature,
|
|
178426
178548
|
jobFeature,
|
|
178427
178549
|
configFeature,
|
|
@@ -179226,6 +179348,12 @@ var createApp = (props) => {
|
|
|
179226
179348
|
registerDomainZone(zone) {
|
|
179227
179349
|
domainZones.push(zone);
|
|
179228
179350
|
},
|
|
179351
|
+
restartOnConfigChange(lambda) {
|
|
179352
|
+
for (const configName of props.appConfig.configs ?? []) {
|
|
179353
|
+
functionsByConfig[configName] ??= [];
|
|
179354
|
+
functionsByConfig[configName].push(lambda);
|
|
179355
|
+
}
|
|
179356
|
+
},
|
|
179229
179357
|
bind(name, value) {
|
|
179230
179358
|
binds.push({ name, value });
|
|
179231
179359
|
},
|
|
@@ -179272,7 +179400,7 @@ var createApp = (props) => {
|
|
|
179272
179400
|
addWarning(props2) {
|
|
179273
179401
|
warnings.push(props2);
|
|
179274
179402
|
},
|
|
179275
|
-
|
|
179403
|
+
restartOnConfigChange(lambda) {
|
|
179276
179404
|
for (const configName of props.appConfig.configs ?? []) {
|
|
179277
179405
|
functionsByConfig[configName] ??= [];
|
|
179278
179406
|
functionsByConfig[configName].push(lambda);
|
|
@@ -179787,7 +179915,7 @@ import { DynamoDBClient as DynamoDBClient4 } from "@awsless/dynamodb";
|
|
|
179787
179915
|
|
|
179788
179916
|
// src/cli/ui/complex/run-tests.ts
|
|
179789
179917
|
var import_wildstring3 = __toESM(require_wildstring(), 1);
|
|
179790
|
-
import { mkdir as mkdir6, readFile as
|
|
179918
|
+
import { mkdir as mkdir6, readFile as readFile21, writeFile as writeFile12 } from "fs/promises";
|
|
179791
179919
|
import { join as join39 } from "path";
|
|
179792
179920
|
import { parse as parse8, stringify as stringify5 } from "@awsless/json";
|
|
179793
179921
|
import { generateFolderHash, loadWorkspace as loadWorkspace2 } from "@awsless/ts-file-cache";
|
|
@@ -179974,7 +180102,7 @@ var runTest = async (stack, dir, filters, workspace, opts) => {
|
|
|
179974
180102
|
if (!process.env.NO_CACHE) {
|
|
179975
180103
|
const exists2 = await fileExist(file2);
|
|
179976
180104
|
if (exists2) {
|
|
179977
|
-
const raw = await
|
|
180105
|
+
const raw = await readFile21(file2, { encoding: "utf8" });
|
|
179978
180106
|
const data = parse8(raw);
|
|
179979
180107
|
if (data.fingerprint === fingerprint) {
|
|
179980
180108
|
logs_exports.step(formatResult({
|
|
@@ -180014,7 +180142,7 @@ var runTest = async (stack, dir, filters, workspace, opts) => {
|
|
|
180014
180142
|
logTestLogs(result);
|
|
180015
180143
|
}
|
|
180016
180144
|
logTestErrors(result);
|
|
180017
|
-
await
|
|
180145
|
+
await writeFile12(file2, stringify5({
|
|
180018
180146
|
...result,
|
|
180019
180147
|
fingerprint
|
|
180020
180148
|
}));
|
|
@@ -185710,8 +185838,8 @@ var bind = (program3) => {
|
|
|
185710
185838
|
}
|
|
185711
185839
|
const configList = opts.config ?? [];
|
|
185712
185840
|
const configs = {};
|
|
185713
|
-
|
|
185714
|
-
configs
|
|
185841
|
+
if (configList.length > 0) {
|
|
185842
|
+
configs.CONFIGS = configList.join(",");
|
|
185715
185843
|
}
|
|
185716
185844
|
if (configList.length ?? 0 > 0) {
|
|
185717
185845
|
logs_exports.note("Bind Config", configList.map((v7) => color2.label(constantCase(v7))).join(`
|
|
@@ -185793,7 +185921,7 @@ var {
|
|
|
185793
185921
|
isIBMi
|
|
185794
185922
|
} = require_constants7();
|
|
185795
185923
|
var stat5 = promisify4(fs3.stat);
|
|
185796
|
-
var
|
|
185924
|
+
var readdir6 = promisify4(fs3.readdir);
|
|
185797
185925
|
var arrify = (value = []) => Array.isArray(value) ? value : [value];
|
|
185798
185926
|
var flatten = (list3, result = []) => {
|
|
185799
185927
|
list3.forEach((item) => {
|
|
@@ -185865,7 +185993,7 @@ class DirEntry {
|
|
|
185865
185993
|
return;
|
|
185866
185994
|
const dir = this.path;
|
|
185867
185995
|
try {
|
|
185868
|
-
await
|
|
185996
|
+
await readdir6(dir);
|
|
185869
185997
|
} catch (err) {
|
|
185870
185998
|
if (this._removeWatcher) {
|
|
185871
185999
|
this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
|
@@ -186451,7 +186579,7 @@ var watchConfig = async (options, resolve4, reject) => {
|
|
|
186451
186579
|
};
|
|
186452
186580
|
|
|
186453
186581
|
// src/type-gen/generate.ts
|
|
186454
|
-
import { mkdir as mkdir7, writeFile as
|
|
186582
|
+
import { mkdir as mkdir7, writeFile as writeFile13 } from "fs/promises";
|
|
186455
186583
|
import { dirname as dirname19, join as join40, relative as relative8 } from "path";
|
|
186456
186584
|
var generateTypes = async (props) => {
|
|
186457
186585
|
const files = [];
|
|
@@ -186466,7 +186594,7 @@ var generateTypes = async (props) => {
|
|
|
186466
186594
|
files.push(relative8(directories.root, path2));
|
|
186467
186595
|
}
|
|
186468
186596
|
await mkdir7(dirname19(path2), { recursive: true });
|
|
186469
|
-
await
|
|
186597
|
+
await writeFile13(path2, code);
|
|
186470
186598
|
}
|
|
186471
186599
|
}
|
|
186472
186600
|
});
|
|
@@ -186474,7 +186602,7 @@ var generateTypes = async (props) => {
|
|
|
186474
186602
|
if (files.length) {
|
|
186475
186603
|
const code = files.map((file2) => `/// <reference path='${file2}' />`).join(`
|
|
186476
186604
|
`);
|
|
186477
|
-
await
|
|
186605
|
+
await writeFile13(join40(directories.root, `awsless.d.ts`), code);
|
|
186478
186606
|
}
|
|
186479
186607
|
};
|
|
186480
186608
|
|