@awsless/cli 0.0.46-next.15 → 0.0.46-next.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +317 -114
- package/dist/handlers/bundle.js +2 -13
- package/dist/handlers/pubsub-server.js +4 -9
- package/dist/prebuild/on-failure/HASH +1 -0
- package/dist/prebuild/on-failure/bundle.zip +0 -0
- package/package.json +11 -11
- package/dist/handlers/on-failure.js +0 -216
package/dist/bin.js
CHANGED
|
@@ -55542,8 +55542,8 @@ var require_client2 = __commonJS((exports) => {
|
|
|
55542
55542
|
return value;
|
|
55543
55543
|
};
|
|
55544
55544
|
};
|
|
55545
|
-
var sleep2 = (
|
|
55546
|
-
return new Promise((resolve4) => setTimeout(resolve4,
|
|
55545
|
+
var sleep2 = (seconds9) => {
|
|
55546
|
+
return new Promise((resolve4) => setTimeout(resolve4, seconds9 * 1000));
|
|
55547
55547
|
};
|
|
55548
55548
|
var waiterServiceDefaults = {
|
|
55549
55549
|
minDelay: 2,
|
|
@@ -58183,11 +58183,11 @@ var require_serde = __commonJS((exports) => {
|
|
|
58183
58183
|
if (!match3) {
|
|
58184
58184
|
throw new TypeError("Invalid RFC-3339 date-time value");
|
|
58185
58185
|
}
|
|
58186
|
-
const [_4, yearStr, monthStr, dayStr, hours, minutes9,
|
|
58186
|
+
const [_4, yearStr, monthStr, dayStr, hours, minutes9, seconds9, fractionalMilliseconds] = match3;
|
|
58187
58187
|
const year2 = strictParseShort(stripLeadingZeroes(yearStr));
|
|
58188
58188
|
const month = parseDateValue(monthStr, "month", 1, 12);
|
|
58189
58189
|
const day = parseDateValue(dayStr, "day", 1, 31);
|
|
58190
|
-
return buildDate(year2, month, day, { hours, minutes: minutes9, seconds:
|
|
58190
|
+
return buildDate(year2, month, day, { hours, minutes: minutes9, seconds: seconds9, fractionalMilliseconds });
|
|
58191
58191
|
};
|
|
58192
58192
|
var RFC3339_WITH_OFFSET$1 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(([-+]\d{2}:\d{2})|[zZ])$/);
|
|
58193
58193
|
var parseRfc3339DateTimeWithOffset = (value) => {
|
|
@@ -58201,11 +58201,11 @@ var require_serde = __commonJS((exports) => {
|
|
|
58201
58201
|
if (!match3) {
|
|
58202
58202
|
throw new TypeError("Invalid RFC-3339 date-time value");
|
|
58203
58203
|
}
|
|
58204
|
-
const [_4, yearStr, monthStr, dayStr, hours, minutes9,
|
|
58204
|
+
const [_4, yearStr, monthStr, dayStr, hours, minutes9, seconds9, fractionalMilliseconds, offsetStr] = match3;
|
|
58205
58205
|
const year2 = strictParseShort(stripLeadingZeroes(yearStr));
|
|
58206
58206
|
const month = parseDateValue(monthStr, "month", 1, 12);
|
|
58207
58207
|
const day = parseDateValue(dayStr, "day", 1, 31);
|
|
58208
|
-
const date2 = buildDate(year2, month, day, { hours, minutes: minutes9, seconds:
|
|
58208
|
+
const date2 = buildDate(year2, month, day, { hours, minutes: minutes9, seconds: seconds9, fractionalMilliseconds });
|
|
58209
58209
|
if (offsetStr.toUpperCase() != "Z") {
|
|
58210
58210
|
date2.setTime(date2.getTime() - parseOffsetToMilliseconds(offsetStr));
|
|
58211
58211
|
}
|
|
@@ -58223,23 +58223,23 @@ var require_serde = __commonJS((exports) => {
|
|
|
58223
58223
|
}
|
|
58224
58224
|
let match3 = IMF_FIXDATE$1.exec(value);
|
|
58225
58225
|
if (match3) {
|
|
58226
|
-
const [_4, dayStr, monthStr, yearStr, hours, minutes9,
|
|
58227
|
-
return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), { hours, minutes: minutes9, seconds:
|
|
58226
|
+
const [_4, dayStr, monthStr, yearStr, hours, minutes9, seconds9, fractionalMilliseconds] = match3;
|
|
58227
|
+
return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), { hours, minutes: minutes9, seconds: seconds9, fractionalMilliseconds });
|
|
58228
58228
|
}
|
|
58229
58229
|
match3 = RFC_850_DATE$1.exec(value);
|
|
58230
58230
|
if (match3) {
|
|
58231
|
-
const [_4, dayStr, monthStr, yearStr, hours, minutes9,
|
|
58231
|
+
const [_4, dayStr, monthStr, yearStr, hours, minutes9, seconds9, fractionalMilliseconds] = match3;
|
|
58232
58232
|
return adjustRfc850Year(buildDate(parseTwoDigitYear(yearStr), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), {
|
|
58233
58233
|
hours,
|
|
58234
58234
|
minutes: minutes9,
|
|
58235
|
-
seconds:
|
|
58235
|
+
seconds: seconds9,
|
|
58236
58236
|
fractionalMilliseconds
|
|
58237
58237
|
}));
|
|
58238
58238
|
}
|
|
58239
58239
|
match3 = ASC_TIME$1.exec(value);
|
|
58240
58240
|
if (match3) {
|
|
58241
|
-
const [_4, monthStr, dayStr, hours, minutes9,
|
|
58242
|
-
return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr.trimLeft(), "day", 1, 31), { hours, minutes: minutes9, seconds:
|
|
58241
|
+
const [_4, monthStr, dayStr, hours, minutes9, seconds9, fractionalMilliseconds, yearStr] = match3;
|
|
58242
|
+
return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr.trimLeft(), "day", 1, 31), { hours, minutes: minutes9, seconds: seconds9, fractionalMilliseconds });
|
|
58243
58243
|
}
|
|
58244
58244
|
throw new TypeError("Invalid RFC-7231 date-time value");
|
|
58245
58245
|
};
|
|
@@ -58409,13 +58409,13 @@ var require_serde = __commonJS((exports) => {
|
|
|
58409
58409
|
if (!matches) {
|
|
58410
58410
|
throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
|
|
58411
58411
|
}
|
|
58412
|
-
const [, yearStr, monthStr, dayStr, hours, minutes9,
|
|
58412
|
+
const [, yearStr, monthStr, dayStr, hours, minutes9, seconds9, , ms, offsetStr] = matches;
|
|
58413
58413
|
range(monthStr, 1, 12);
|
|
58414
58414
|
range(dayStr, 1, 31);
|
|
58415
58415
|
range(hours, 0, 23);
|
|
58416
58416
|
range(minutes9, 0, 59);
|
|
58417
|
-
range(
|
|
58418
|
-
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes9), Number(
|
|
58417
|
+
range(seconds9, 0, 60);
|
|
58418
|
+
const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes9), Number(seconds9), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1000) : 0));
|
|
58419
58419
|
date2.setUTCFullYear(Number(yearStr));
|
|
58420
58420
|
if (offsetStr.toUpperCase() != "Z") {
|
|
58421
58421
|
const [, sign, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [undefined, "+", 0, 0];
|
|
@@ -104651,10 +104651,205 @@ var onErrorLogFeature = defineFeature({
|
|
|
104651
104651
|
});
|
|
104652
104652
|
|
|
104653
104653
|
// src/feature/on-failure/index.ts
|
|
104654
|
-
import { days as days8, toSeconds as
|
|
104655
|
-
import { formatRouteEnvName as formatRouteEnvName2 } from "awsless";
|
|
104654
|
+
import { days as days8, toSeconds as toSeconds5 } from "@awsless/duration";
|
|
104656
104655
|
import { dirname as dirname8, join as join13 } from "path";
|
|
104657
104656
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
104657
|
+
|
|
104658
|
+
// src/feature/function/prebuild.ts
|
|
104659
|
+
import { seconds as seconds4, toDays as toDays6, toSeconds as toSeconds4 } from "@awsless/duration";
|
|
104660
|
+
var createPrebuildLambdaFunction = (parentGroup, ctx, ns, id, props) => {
|
|
104661
|
+
let name;
|
|
104662
|
+
let roleName;
|
|
104663
|
+
const group = new Group(parentGroup, "function", id);
|
|
104664
|
+
if ("stack" in ctx) {
|
|
104665
|
+
name = formatLocalResourceName({
|
|
104666
|
+
appName: ctx.app.name,
|
|
104667
|
+
stackName: ctx.stack.name,
|
|
104668
|
+
resourceType: ns,
|
|
104669
|
+
resourceName: id
|
|
104670
|
+
});
|
|
104671
|
+
roleName = formatLocalResourceName({
|
|
104672
|
+
appName: ctx.app.name,
|
|
104673
|
+
stackName: ctx.stack.name,
|
|
104674
|
+
resourceType: ns,
|
|
104675
|
+
resourceName: id,
|
|
104676
|
+
postfix: ctx.appId
|
|
104677
|
+
});
|
|
104678
|
+
} else {
|
|
104679
|
+
name = formatGlobalResourceName({
|
|
104680
|
+
appName: ctx.app.name,
|
|
104681
|
+
resourceType: ns,
|
|
104682
|
+
resourceName: id
|
|
104683
|
+
});
|
|
104684
|
+
roleName = formatGlobalResourceName({
|
|
104685
|
+
appName: ctx.app.name,
|
|
104686
|
+
resourceType: ns,
|
|
104687
|
+
resourceName: id,
|
|
104688
|
+
postfix: ctx.appId
|
|
104689
|
+
});
|
|
104690
|
+
}
|
|
104691
|
+
const sourceHash = $file(props.bundleHash);
|
|
104692
|
+
const code = new aws.s3.BucketObject(group, "code", {
|
|
104693
|
+
bucket: ctx.shared.get("asset", "bucket").name,
|
|
104694
|
+
key: `lambda/${name}.zip`,
|
|
104695
|
+
source: relativePath(props.bundleFile),
|
|
104696
|
+
sourceHash
|
|
104697
|
+
}, {
|
|
104698
|
+
replaceOnChanges: ["bucket", "key"]
|
|
104699
|
+
});
|
|
104700
|
+
const role = new aws.iam.Role(group, "role", {
|
|
104701
|
+
name: roleName,
|
|
104702
|
+
description: name,
|
|
104703
|
+
assumeRolePolicy: JSON.stringify({
|
|
104704
|
+
Version: "2012-10-17",
|
|
104705
|
+
Statement: [
|
|
104706
|
+
{
|
|
104707
|
+
Effect: "Allow",
|
|
104708
|
+
Action: "sts:AssumeRole",
|
|
104709
|
+
Principal: {
|
|
104710
|
+
Service: ["lambda.amazonaws.com"]
|
|
104711
|
+
}
|
|
104712
|
+
}
|
|
104713
|
+
]
|
|
104714
|
+
})
|
|
104715
|
+
});
|
|
104716
|
+
const statements = [];
|
|
104717
|
+
const statementDeps = new Set;
|
|
104718
|
+
const addPermission = (...permissions) => {
|
|
104719
|
+
statements.push(...permissions);
|
|
104720
|
+
for (const dep of findInputDeps(permissions)) {
|
|
104721
|
+
statementDeps.add(dep);
|
|
104722
|
+
}
|
|
104723
|
+
};
|
|
104724
|
+
const policy = new aws.iam.RolePolicy(group, "policy", {
|
|
104725
|
+
role: role.name,
|
|
104726
|
+
name: "lambda-policy",
|
|
104727
|
+
policy: new Output(statementDeps, async (resolve3) => {
|
|
104728
|
+
const list2 = await resolveInputs(statements);
|
|
104729
|
+
resolve3(JSON.stringify({
|
|
104730
|
+
Version: "2012-10-17",
|
|
104731
|
+
Statement: compactPolicyStatements(list2).map((statement) => ({
|
|
104732
|
+
Effect: pascalCase(statement.effect ?? "allow"),
|
|
104733
|
+
Action: statement.actions,
|
|
104734
|
+
Resource: statement.resources,
|
|
104735
|
+
Condition: statement.conditions
|
|
104736
|
+
}))
|
|
104737
|
+
}));
|
|
104738
|
+
})
|
|
104739
|
+
});
|
|
104740
|
+
const dependsOn = [];
|
|
104741
|
+
if (props.vpc) {
|
|
104742
|
+
dependsOn.push(new aws.iam.RolePolicy(group, "vpc-policy", {
|
|
104743
|
+
role: role.name,
|
|
104744
|
+
name: "lambda-vpc-policy",
|
|
104745
|
+
policy: JSON.stringify({
|
|
104746
|
+
Version: "2012-10-17",
|
|
104747
|
+
Statement: [
|
|
104748
|
+
{
|
|
104749
|
+
Effect: "Allow",
|
|
104750
|
+
Action: [
|
|
104751
|
+
"ec2:CreateNetworkInterface",
|
|
104752
|
+
"ec2:DescribeNetworkInterfaces",
|
|
104753
|
+
"ec2:DescribeSubnets",
|
|
104754
|
+
"ec2:DeleteNetworkInterface",
|
|
104755
|
+
"ec2:AssignPrivateIpAddresses",
|
|
104756
|
+
"ec2:UnassignPrivateIpAddresses"
|
|
104757
|
+
],
|
|
104758
|
+
Resource: ["*"]
|
|
104759
|
+
}
|
|
104760
|
+
]
|
|
104761
|
+
})
|
|
104762
|
+
}));
|
|
104763
|
+
}
|
|
104764
|
+
const variables = {};
|
|
104765
|
+
const logFormats = {
|
|
104766
|
+
text: "Text",
|
|
104767
|
+
json: "JSON"
|
|
104768
|
+
};
|
|
104769
|
+
const lambda = new aws.lambda.Function(group, "function", {
|
|
104770
|
+
functionName: name,
|
|
104771
|
+
description: name,
|
|
104772
|
+
role: role.arn,
|
|
104773
|
+
runtime: props.runtime,
|
|
104774
|
+
handler: props.handler,
|
|
104775
|
+
timeout: toSeconds4(props.timeout ?? seconds4(10)),
|
|
104776
|
+
memorySize: toMebibytes(props.memorySize ?? mebibytes(128)),
|
|
104777
|
+
architectures: [props.architecture ?? "arm64"],
|
|
104778
|
+
timeouts: {
|
|
104779
|
+
create: "30s",
|
|
104780
|
+
update: "30s",
|
|
104781
|
+
delete: "30s"
|
|
104782
|
+
},
|
|
104783
|
+
s3Bucket: code.bucket,
|
|
104784
|
+
s3ObjectVersion: code.versionId,
|
|
104785
|
+
s3Key: code.key.pipe((name2) => {
|
|
104786
|
+
if (name2.startsWith("/")) {
|
|
104787
|
+
return name2.substring(1);
|
|
104788
|
+
}
|
|
104789
|
+
return name2;
|
|
104790
|
+
}),
|
|
104791
|
+
sourceCodeHash: sourceHash,
|
|
104792
|
+
environment: {
|
|
104793
|
+
variables
|
|
104794
|
+
},
|
|
104795
|
+
vpcConfig: props.vpc ? {
|
|
104796
|
+
securityGroupIds: [ctx.shared.get("vpc", "security-group-id")],
|
|
104797
|
+
subnetIds: ctx.shared.get("vpc", "private-subnets"),
|
|
104798
|
+
ipv6AllowedForDualStack: true
|
|
104799
|
+
} : undefined,
|
|
104800
|
+
loggingConfig: {
|
|
104801
|
+
logGroup: `/aws/lambda/${name}`,
|
|
104802
|
+
logFormat: logFormats[props.log?.format ?? "json"],
|
|
104803
|
+
applicationLogLevel: (props.log?.format ?? "json") === "json" ? props.log?.level?.toUpperCase() : undefined,
|
|
104804
|
+
systemLogLevel: (props.log?.format ?? "json") === "json" ? props.log?.system?.toUpperCase() : undefined
|
|
104805
|
+
}
|
|
104806
|
+
}, {
|
|
104807
|
+
dependsOn
|
|
104808
|
+
});
|
|
104809
|
+
variables.APP = ctx.appConfig.name;
|
|
104810
|
+
variables.APP_ID = ctx.appId;
|
|
104811
|
+
variables.AWS_ACCOUNT_ID = ctx.accountId;
|
|
104812
|
+
if ("stackConfig" in ctx) {
|
|
104813
|
+
variables.STACK = ctx.stackConfig.name;
|
|
104814
|
+
}
|
|
104815
|
+
if (props.vpc) {
|
|
104816
|
+
variables.AWS_USE_DUALSTACK_ENDPOINT = "true";
|
|
104817
|
+
}
|
|
104818
|
+
const retention = props.log?.retention;
|
|
104819
|
+
if (retention && retention.value > 0n) {
|
|
104820
|
+
const logGroup = new aws.cloudwatch.LogGroup(group, "log", {
|
|
104821
|
+
name: `/aws/lambda/${name}`,
|
|
104822
|
+
retentionInDays: toDays6(retention)
|
|
104823
|
+
});
|
|
104824
|
+
addPermission({
|
|
104825
|
+
actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
|
|
104826
|
+
resources: [logGroup.arn.pipe((arn) => `${arn}:*`)]
|
|
104827
|
+
});
|
|
104828
|
+
if (ctx.shared.has("on-error-log", "subscriber-arn")) {
|
|
104829
|
+
new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
|
|
104830
|
+
name: "error-log-subscription",
|
|
104831
|
+
destinationArn: ctx.shared.get("on-error-log", "subscriber-arn"),
|
|
104832
|
+
logGroupName: logGroup.name,
|
|
104833
|
+
filterPattern
|
|
104834
|
+
});
|
|
104835
|
+
}
|
|
104836
|
+
}
|
|
104837
|
+
return {
|
|
104838
|
+
name,
|
|
104839
|
+
group,
|
|
104840
|
+
lambda,
|
|
104841
|
+
policy,
|
|
104842
|
+
code,
|
|
104843
|
+
setEnvironment(name2, value) {
|
|
104844
|
+
variables[name2] = value;
|
|
104845
|
+
},
|
|
104846
|
+
addPermission(...permissions) {
|
|
104847
|
+
addPermission(...permissions);
|
|
104848
|
+
}
|
|
104849
|
+
};
|
|
104850
|
+
};
|
|
104851
|
+
|
|
104852
|
+
// src/feature/on-failure/index.ts
|
|
104658
104853
|
var onFailureFeature = defineFeature({
|
|
104659
104854
|
name: "on-failure",
|
|
104660
104855
|
onBefore(ctx) {
|
|
@@ -104665,9 +104860,9 @@ var onFailureFeature = defineFeature({
|
|
|
104665
104860
|
resourceType: "on-failure",
|
|
104666
104861
|
resourceName: "deadletter"
|
|
104667
104862
|
}),
|
|
104668
|
-
messageRetentionSeconds:
|
|
104863
|
+
messageRetentionSeconds: toSeconds5(days8(14))
|
|
104669
104864
|
});
|
|
104670
|
-
const bundleTimeout =
|
|
104865
|
+
const bundleTimeout = toSeconds5(ctx.appConfig.defaults.function.timeout);
|
|
104671
104866
|
const queue2 = new aws.sqs.Queue(group, "on-failure", {
|
|
104672
104867
|
name: formatGlobalResourceName({
|
|
104673
104868
|
appName: ctx.app.name,
|
|
@@ -104801,21 +104996,29 @@ var onFailureFeature = defineFeature({
|
|
|
104801
104996
|
}
|
|
104802
104997
|
const bundle = ctx.shared.get("bundle", "main");
|
|
104803
104998
|
const { group, bucket, queue: queue2 } = ctx.shared.get("on-failure", "resources");
|
|
104804
|
-
|
|
104805
|
-
const
|
|
104806
|
-
const
|
|
104807
|
-
|
|
104808
|
-
|
|
104809
|
-
|
|
104810
|
-
|
|
104811
|
-
|
|
104812
|
-
|
|
104813
|
-
|
|
104814
|
-
|
|
104999
|
+
registerBundleFunction(ctx, formatRouteKey("base", "on-failure", "consumer"), props.consumer);
|
|
105000
|
+
const distDir = dirname8(fileURLToPath5(import.meta.url));
|
|
105001
|
+
const handler = createPrebuildLambdaFunction(group, ctx, "on-failure", "handler", {
|
|
105002
|
+
bundleFile: join13(distDir, "/prebuild/on-failure/bundle.zip"),
|
|
105003
|
+
bundleHash: join13(distDir, "/prebuild/on-failure/HASH"),
|
|
105004
|
+
runtime: "nodejs24.x",
|
|
105005
|
+
handler: "index.default",
|
|
105006
|
+
memorySize: mebibytes(256),
|
|
105007
|
+
timeout: ctx.appConfig.defaults.function.timeout,
|
|
105008
|
+
log: {
|
|
105009
|
+
format: "json",
|
|
105010
|
+
level: "warn",
|
|
105011
|
+
system: "warn",
|
|
105012
|
+
retention: days8(3)
|
|
105013
|
+
}
|
|
105014
|
+
});
|
|
105015
|
+
handler.addPermission({
|
|
105016
|
+
actions: ["lambda:InvokeFunction"],
|
|
105017
|
+
resources: [bundle.alias.arn]
|
|
105018
|
+
}, {
|
|
104815
105019
|
actions: ["s3:GetObject", "s3:DeleteObject"],
|
|
104816
105020
|
resources: [$interpolate`${bucket.arn}/*`]
|
|
104817
|
-
}
|
|
104818
|
-
bundle.addPermission({
|
|
105021
|
+
}, {
|
|
104819
105022
|
actions: [
|
|
104820
105023
|
"sqs:DeleteMessage",
|
|
104821
105024
|
"sqs:ReceiveMessage",
|
|
@@ -104825,11 +105028,11 @@ var onFailureFeature = defineFeature({
|
|
|
104825
105028
|
resources: [queue2.arn]
|
|
104826
105029
|
});
|
|
104827
105030
|
new aws.lambda.EventSourceMapping(group, "on-failure", {
|
|
104828
|
-
functionName:
|
|
105031
|
+
functionName: handler.lambda.arn,
|
|
104829
105032
|
eventSourceArn: queue2.arn,
|
|
104830
105033
|
batchSize: 10
|
|
104831
105034
|
}, {
|
|
104832
|
-
dependsOn: [
|
|
105035
|
+
dependsOn: [handler.policy]
|
|
104833
105036
|
});
|
|
104834
105037
|
const queuePolicy = new aws.sqs.QueuePolicy(group, "bucket-notification", {
|
|
104835
105038
|
queueUrl: queue2.url,
|
|
@@ -104873,10 +105076,10 @@ var onFailureFeature = defineFeature({
|
|
|
104873
105076
|
import { createHmac as createHmac2 } from "crypto";
|
|
104874
105077
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
104875
105078
|
import { dirname as dirname10, join as join16 } from "path";
|
|
104876
|
-
import { formatRouteEnvName as
|
|
105079
|
+
import { formatRouteEnvName as formatRouteEnvName2 } from "awsless";
|
|
104877
105080
|
|
|
104878
105081
|
// src/feature/pubsub/util.ts
|
|
104879
|
-
import { toDays as
|
|
105082
|
+
import { toDays as toDays7 } from "@awsless/duration";
|
|
104880
105083
|
import { stringify } from "@awsless/json";
|
|
104881
105084
|
import { createHash as createHash11 } from "crypto";
|
|
104882
105085
|
import { readFile as readFile10 } from "fs/promises";
|
|
@@ -105057,7 +105260,7 @@ var createPubSubService = (parentGroup, ctx, id, props, inputs) => {
|
|
|
105057
105260
|
if (props.log.retention && props.log.retention.value > 0n) {
|
|
105058
105261
|
logGroup = new aws.cloudwatch.LogGroup(group, "log", {
|
|
105059
105262
|
name: `/aws/ecs/${name}`,
|
|
105060
|
-
retentionInDays:
|
|
105263
|
+
retentionInDays: toDays7(props.log.retention)
|
|
105061
105264
|
});
|
|
105062
105265
|
if (ctx.shared.has("on-error-log", "subscriber-arn")) {
|
|
105063
105266
|
new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
|
|
@@ -105483,9 +105686,9 @@ var pubsubFeature = defineFeature({
|
|
|
105483
105686
|
file: join16(__dirname3, "/handlers/pubsub-publisher.js"),
|
|
105484
105687
|
exportName: "default"
|
|
105485
105688
|
});
|
|
105486
|
-
bundle.addEnv(
|
|
105487
|
-
bundle.addEnv(
|
|
105488
|
-
bundle.addEnv(
|
|
105689
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_HOST"), redisHost);
|
|
105690
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_PORT"), redisPort.pipe((port) => port.toString()));
|
|
105691
|
+
bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "CHANNEL"), channel);
|
|
105489
105692
|
const routerProps = ctx.appConfig.defaults.router?.[props.router];
|
|
105490
105693
|
if (!routerProps?.domain) {
|
|
105491
105694
|
throw new FileError("app.json", `The pubsub "${id}" requires the "${props.router}" router to have a domain configured.`);
|
|
@@ -105525,7 +105728,7 @@ var pubsubFeature = defineFeature({
|
|
|
105525
105728
|
// src/feature/queue/index.ts
|
|
105526
105729
|
var import_deepmerge2 = __toESM(require_cjs2(), 1);
|
|
105527
105730
|
import { relative as relative4 } from "path";
|
|
105528
|
-
import { minutes as minutes7, seconds as
|
|
105731
|
+
import { minutes as minutes7, seconds as seconds5, toSeconds as toSeconds6 } from "@awsless/duration";
|
|
105529
105732
|
var typeGenCode5 = `
|
|
105530
105733
|
import {
|
|
105531
105734
|
SendMessageOptions,
|
|
@@ -105591,7 +105794,7 @@ var queueFeature = defineFeature({
|
|
|
105591
105794
|
await ctx.write("queue.d.ts", gen, true);
|
|
105592
105795
|
},
|
|
105593
105796
|
onStack(ctx) {
|
|
105594
|
-
const bundleTimeout =
|
|
105797
|
+
const bundleTimeout = toSeconds6(ctx.appConfig.defaults.function.timeout);
|
|
105595
105798
|
for (const [id, local] of Object.entries(ctx.stackConfig.queues || {})) {
|
|
105596
105799
|
const props = import_deepmerge2.default(ctx.appConfig.defaults.queue, typeof local === "object" ? local : {});
|
|
105597
105800
|
const group = new Group(ctx.stack, "queue", id);
|
|
@@ -105603,9 +105806,9 @@ var queueFeature = defineFeature({
|
|
|
105603
105806
|
});
|
|
105604
105807
|
const queue2 = new aws.sqs.Queue(group, "queue", {
|
|
105605
105808
|
name: `${baseName}.fifo`,
|
|
105606
|
-
visibilityTimeoutSeconds: bundleTimeout +
|
|
105607
|
-
receiveWaitTimeSeconds:
|
|
105608
|
-
messageRetentionSeconds:
|
|
105809
|
+
visibilityTimeoutSeconds: bundleTimeout + toSeconds6(minutes7(1)),
|
|
105810
|
+
receiveWaitTimeSeconds: toSeconds6(props.receiveMessageWaitTime ?? seconds5(0)),
|
|
105811
|
+
messageRetentionSeconds: toSeconds6(props.retentionPeriod),
|
|
105609
105812
|
maxMessageSize: toBytes(props.maxMessageSize),
|
|
105610
105813
|
fifoQueue: true,
|
|
105611
105814
|
deduplicationScope: "messageGroup",
|
|
@@ -105740,10 +105943,10 @@ var restFeature = defineFeature({
|
|
|
105740
105943
|
});
|
|
105741
105944
|
|
|
105742
105945
|
// src/feature/rpc/index.ts
|
|
105743
|
-
import { formatRouteEnvName as
|
|
105946
|
+
import { formatRouteEnvName as formatRouteEnvName3 } from "awsless";
|
|
105744
105947
|
import { dirname as dirname11, join as join17, relative as relative5 } from "path";
|
|
105745
105948
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
105746
|
-
import { toSeconds as
|
|
105949
|
+
import { toSeconds as toSeconds7 } from "@awsless/duration";
|
|
105747
105950
|
var rpcFeature = defineFeature({
|
|
105748
105951
|
name: "rpc",
|
|
105749
105952
|
async onTypeGen(ctx) {
|
|
@@ -105797,7 +106000,7 @@ var rpcFeature = defineFeature({
|
|
|
105797
106000
|
file: join17(dirname11(fileURLToPath8(import.meta.url)), "/handlers/rpc.js"),
|
|
105798
106001
|
exportName: "default"
|
|
105799
106002
|
});
|
|
105800
|
-
bundle.addEnv(
|
|
106003
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "TIMEOUT"), toSeconds7(ctx.appConfig.defaults.function.timeout).toString());
|
|
105801
106004
|
const lockTable = new aws.dynamodb.Table(group, "lock", {
|
|
105802
106005
|
name: formatGlobalResourceName({
|
|
105803
106006
|
appName: ctx.app.name,
|
|
@@ -105817,7 +106020,7 @@ var rpcFeature = defineFeature({
|
|
|
105817
106020
|
}
|
|
105818
106021
|
]
|
|
105819
106022
|
});
|
|
105820
|
-
bundle.addEnv(
|
|
106023
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "LOCK_TABLE"), lockTable.name);
|
|
105821
106024
|
bundle.addPermission({
|
|
105822
106025
|
effect: "allow",
|
|
105823
106026
|
actions: ["dynamodb:UpdateItem", "dynamodb:DeleteItem"],
|
|
@@ -105826,7 +106029,7 @@ var rpcFeature = defineFeature({
|
|
|
105826
106029
|
if (props.auth) {
|
|
105827
106030
|
const authRouteKey = formatRouteKey("base", "rpc", `${id}-auth`);
|
|
105828
106031
|
registerBundleFunction(ctx, authRouteKey, props.auth);
|
|
105829
|
-
bundle.addEnv(
|
|
106032
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, "AUTH"), authRouteKey);
|
|
105830
106033
|
}
|
|
105831
106034
|
const addRoutes = ctx.shared.entry("router", "addRoutes", props.router);
|
|
105832
106035
|
addRoutes({
|
|
@@ -105851,7 +106054,7 @@ var rpcFeature = defineFeature({
|
|
|
105851
106054
|
const entryId = kebabCase(`${id}-${shortId(name)}`);
|
|
105852
106055
|
const routeKey = formatRouteKey(ctx.stack.name, "rpc", entryId);
|
|
105853
106056
|
registerBundleFunction(ctx, routeKey, props.function);
|
|
105854
|
-
bundle.addEnv(
|
|
106057
|
+
bundle.addEnv(formatRouteEnvName3(serverRouteKey, `QUERY:${name}`), JSON.stringify({ function: routeKey, lock: props.lock }));
|
|
105855
106058
|
}
|
|
105856
106059
|
}
|
|
105857
106060
|
}
|
|
@@ -106121,7 +106324,7 @@ ${(errors3.trim() || output.trim()).slice(-2000)}`);
|
|
|
106121
106324
|
|
|
106122
106325
|
// src/feature/store/index.ts
|
|
106123
106326
|
import { join as join20 } from "path";
|
|
106124
|
-
import { toDays as
|
|
106327
|
+
import { toDays as toDays8 } from "@awsless/duration";
|
|
106125
106328
|
|
|
106126
106329
|
// src/feature/store/util.ts
|
|
106127
106330
|
import { extname as extname6 } from "path";
|
|
@@ -106228,7 +106431,7 @@ var storeFeature = defineFeature({
|
|
|
106228
106431
|
id: rule.prefix ? `expire-${kebabCase(`${id}-${rule.prefix}`)}` : `expire-${id}-rule-${index}`,
|
|
106229
106432
|
enabled: true,
|
|
106230
106433
|
prefix: `${folder}${rule.prefix ?? ""}`,
|
|
106231
|
-
expiration: { days:
|
|
106434
|
+
expiration: { days: toDays8(rule.expiration) }
|
|
106232
106435
|
});
|
|
106233
106436
|
}
|
|
106234
106437
|
ctx.onReady(() => {
|
|
@@ -106261,7 +106464,7 @@ var storeFeature = defineFeature({
|
|
|
106261
106464
|
});
|
|
106262
106465
|
|
|
106263
106466
|
// src/feature/table/index.ts
|
|
106264
|
-
import { toSeconds as
|
|
106467
|
+
import { toSeconds as toSeconds8 } from "@awsless/duration";
|
|
106265
106468
|
var tableFeature = defineFeature({
|
|
106266
106469
|
name: "table",
|
|
106267
106470
|
async onTypeGen(ctx) {
|
|
@@ -106390,7 +106593,7 @@ var tableFeature = defineFeature({
|
|
|
106390
106593
|
functionName: bundle.alias.arn,
|
|
106391
106594
|
eventSourceArn: table3.streamArn,
|
|
106392
106595
|
batchSize: props.stream.batchSize,
|
|
106393
|
-
maximumBatchingWindowInSeconds: props.stream.batchWindow ?
|
|
106596
|
+
maximumBatchingWindowInSeconds: props.stream.batchWindow ? toSeconds8(props.stream.batchWindow) : undefined,
|
|
106394
106597
|
maximumRetryAttempts: props.stream.retryAttempts,
|
|
106395
106598
|
parallelizationFactor: props.stream.concurrencyPerShard,
|
|
106396
106599
|
functionResponseTypes: ["ReportBatchItemFailures"],
|
|
@@ -106867,8 +107070,8 @@ var layerFeature = defineFeature({
|
|
|
106867
107070
|
});
|
|
106868
107071
|
|
|
106869
107072
|
// src/feature/image/index.ts
|
|
106870
|
-
import { toDays as
|
|
106871
|
-
import { formatRouteEnvName as
|
|
107073
|
+
import { toDays as toDays9 } from "@awsless/duration";
|
|
107074
|
+
import { formatRouteEnvName as formatRouteEnvName4 } from "awsless";
|
|
106872
107075
|
import { dirname as dirname13, join as join21 } from "path";
|
|
106873
107076
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
106874
107077
|
var imageFeature = defineFeature({
|
|
@@ -106942,7 +107145,7 @@ var imageFeature = defineFeature({
|
|
|
106942
107145
|
enabled: true,
|
|
106943
107146
|
prefix: `${folder}cache/`,
|
|
106944
107147
|
expiration: {
|
|
106945
|
-
days:
|
|
107148
|
+
days: toDays9(props.cacheDuration)
|
|
106946
107149
|
}
|
|
106947
107150
|
});
|
|
106948
107151
|
}
|
|
@@ -106965,17 +107168,17 @@ var imageFeature = defineFeature({
|
|
|
106965
107168
|
}
|
|
106966
107169
|
}
|
|
106967
107170
|
});
|
|
106968
|
-
bundle.addEnv(
|
|
107171
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_CONFIG"), JSON.stringify({
|
|
106969
107172
|
presets: props.presets,
|
|
106970
107173
|
extensions: props.extensions
|
|
106971
107174
|
}));
|
|
106972
|
-
bundle.addEnv(
|
|
106973
|
-
bundle.addEnv(
|
|
107175
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_BUCKET"), bucket.name);
|
|
107176
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_FOLDER"), folder);
|
|
106974
107177
|
if (originRouteKey) {
|
|
106975
|
-
bundle.addEnv(
|
|
107178
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN"), originRouteKey);
|
|
106976
107179
|
}
|
|
106977
107180
|
if (props.origin.static) {
|
|
106978
|
-
bundle.addEnv(
|
|
107181
|
+
bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN_S3"), "true");
|
|
106979
107182
|
}
|
|
106980
107183
|
ctx.onReady(() => {
|
|
106981
107184
|
if (props.origin.static) {
|
|
@@ -107002,8 +107205,8 @@ var imageFeature = defineFeature({
|
|
|
107002
107205
|
});
|
|
107003
107206
|
|
|
107004
107207
|
// src/feature/icon/index.ts
|
|
107005
|
-
import { toDays as
|
|
107006
|
-
import { formatRouteEnvName as
|
|
107208
|
+
import { toDays as toDays10 } from "@awsless/duration";
|
|
107209
|
+
import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
|
|
107007
107210
|
import { dirname as dirname14, join as join22 } from "path";
|
|
107008
107211
|
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
107009
107212
|
var iconFeature = defineFeature({
|
|
@@ -107029,7 +107232,7 @@ var iconFeature = defineFeature({
|
|
|
107029
107232
|
enabled: true,
|
|
107030
107233
|
prefix: `${folder}cache/`,
|
|
107031
107234
|
expiration: {
|
|
107032
|
-
days:
|
|
107235
|
+
days: toDays10(props.cacheDuration)
|
|
107033
107236
|
}
|
|
107034
107237
|
});
|
|
107035
107238
|
}
|
|
@@ -107051,17 +107254,17 @@ var iconFeature = defineFeature({
|
|
|
107051
107254
|
}
|
|
107052
107255
|
}
|
|
107053
107256
|
});
|
|
107054
|
-
bundle.addEnv(
|
|
107257
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_CONFIG"), JSON.stringify({
|
|
107055
107258
|
preserveIds: props.preserveIds,
|
|
107056
107259
|
symbols: props.symbols
|
|
107057
107260
|
}));
|
|
107058
|
-
bundle.addEnv(
|
|
107059
|
-
bundle.addEnv(
|
|
107261
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_BUCKET"), bucket.name);
|
|
107262
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_FOLDER"), folder);
|
|
107060
107263
|
if (originRouteKey) {
|
|
107061
|
-
bundle.addEnv(
|
|
107264
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN"), originRouteKey);
|
|
107062
107265
|
}
|
|
107063
107266
|
if (props.origin.static) {
|
|
107064
|
-
bundle.addEnv(
|
|
107267
|
+
bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN_S3"), "true");
|
|
107065
107268
|
}
|
|
107066
107269
|
ctx.onReady(() => {
|
|
107067
107270
|
if (props.origin.static) {
|
|
@@ -107096,7 +107299,7 @@ import { relative as relative7 } from "path";
|
|
|
107096
107299
|
|
|
107097
107300
|
// src/feature/job/util.ts
|
|
107098
107301
|
import { createHash as createHash14 } from "crypto";
|
|
107099
|
-
import { toDays as
|
|
107302
|
+
import { toDays as toDays11, toSeconds as toSeconds9 } from "@awsless/duration";
|
|
107100
107303
|
import { stringify as stringify2 } from "@awsless/json";
|
|
107101
107304
|
import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
|
|
107102
107305
|
var import_deepmerge3 = __toESM(require_cjs2(), 1);
|
|
@@ -107283,7 +107486,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
|
|
|
107283
107486
|
if (props.log.retention && props.log.retention.value > 0n) {
|
|
107284
107487
|
logGroup = new aws.cloudwatch.LogGroup(group, "log", {
|
|
107285
107488
|
name: `/aws/ecs/${name}`,
|
|
107286
|
-
retentionInDays:
|
|
107489
|
+
retentionInDays: toDays11(props.log.retention)
|
|
107287
107490
|
});
|
|
107288
107491
|
if (ctx.shared.has("on-error-log", "subscriber-arn")) {
|
|
107289
107492
|
new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
|
|
@@ -107371,7 +107574,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
|
|
|
107371
107574
|
[
|
|
107372
107575
|
...props.startupCommand?.length ? [props.startupCommand.join(" && ")] : [],
|
|
107373
107576
|
`if [ "$(cat /root/.code-hash 2>/dev/null)" != "$CODE_HASH" ]; then command -v aws >/dev/null 2>&1 || dnf install -y awscli && aws s3 cp s3://${s3Bucket}/${s3Key} /root/program.tmp && mv /root/program.tmp /root/program && chmod +x /root/program && echo "$CODE_HASH" > /root/.code-hash; fi`,
|
|
107374
|
-
`exec timeout --kill-after=10 ${
|
|
107577
|
+
`exec timeout --kill-after=10 ${toSeconds9(props.timeout)} /root/program`
|
|
107375
107578
|
].join(" && ")
|
|
107376
107579
|
],
|
|
107377
107580
|
environment: Object.entries(data).map(([name2, value]) => ({
|
|
@@ -107609,10 +107812,10 @@ var jobFeature = defineFeature({
|
|
|
107609
107812
|
});
|
|
107610
107813
|
|
|
107611
107814
|
// src/feature/instance/index.ts
|
|
107612
|
-
import { days as days9, seconds as
|
|
107815
|
+
import { days as days9, seconds as seconds6, toSeconds as toSeconds11 } from "@awsless/duration";
|
|
107613
107816
|
|
|
107614
107817
|
// src/feature/instance/util.ts
|
|
107615
|
-
import { toDays as
|
|
107818
|
+
import { toDays as toDays12, toSeconds as toSeconds10 } from "@awsless/duration";
|
|
107616
107819
|
import { stringify as stringify3 } from "@awsless/json";
|
|
107617
107820
|
import { generateFileHash as generateFileHash3 } from "@awsless/ts-file-cache";
|
|
107618
107821
|
var import_deepmerge5 = __toESM(require_cjs2(), 1);
|
|
@@ -107735,7 +107938,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
107735
107938
|
if (props.log.retention && props.log.retention.value > 0n) {
|
|
107736
107939
|
logGroup = new aws.cloudwatch.LogGroup(group, "log", {
|
|
107737
107940
|
name: `/aws/ecs/${name}`,
|
|
107738
|
-
retentionInDays:
|
|
107941
|
+
retentionInDays: toDays12(props.log.retention)
|
|
107739
107942
|
});
|
|
107740
107943
|
if (ctx.shared.has("on-error-log", "subscriber-arn")) {
|
|
107741
107944
|
new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
|
|
@@ -107824,10 +108027,10 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
107824
108027
|
"CMD-SHELL",
|
|
107825
108028
|
`curl -f http://${join24("localhost", props.healthCheck.path)} || exit 1`
|
|
107826
108029
|
],
|
|
107827
|
-
interval:
|
|
108030
|
+
interval: toSeconds10(props.healthCheck.interval),
|
|
107828
108031
|
retries: props.healthCheck.retries,
|
|
107829
|
-
startPeriod:
|
|
107830
|
-
timeout:
|
|
108032
|
+
startPeriod: toSeconds10(props.healthCheck.startPeriod),
|
|
108033
|
+
timeout: toSeconds10(props.healthCheck.timeout)
|
|
107831
108034
|
} : undefined
|
|
107832
108035
|
}
|
|
107833
108036
|
]));
|
|
@@ -107992,10 +108195,10 @@ var instanceFeature = defineFeature({
|
|
|
107992
108195
|
const task2 = createFargateTask(group, ctx, "instance", id, props);
|
|
107993
108196
|
const queue2 = new aws.sqs.Queue(group, "queue", {
|
|
107994
108197
|
name: task2.name,
|
|
107995
|
-
visibilityTimeoutSeconds:
|
|
107996
|
-
messageRetentionSeconds:
|
|
108198
|
+
visibilityTimeoutSeconds: toSeconds11(seconds6(30)),
|
|
108199
|
+
messageRetentionSeconds: toSeconds11(days9(4)),
|
|
107997
108200
|
maxMessageSize: toBytes(kibibytes(256)),
|
|
107998
|
-
receiveWaitTimeSeconds:
|
|
108201
|
+
receiveWaitTimeSeconds: toSeconds11(seconds6(20))
|
|
107999
108202
|
});
|
|
108000
108203
|
task2.addPermission({
|
|
108001
108204
|
actions: [
|
|
@@ -108017,7 +108220,7 @@ var instanceFeature = defineFeature({
|
|
|
108017
108220
|
});
|
|
108018
108221
|
|
|
108019
108222
|
// src/feature/metric/index.ts
|
|
108020
|
-
import { toSeconds as
|
|
108223
|
+
import { toSeconds as toSeconds12 } from "@awsless/duration";
|
|
108021
108224
|
var typeGenCode13 = `
|
|
108022
108225
|
import { type PutDataProps, putData, batchPutData } from '@awsless/cloudwatch'
|
|
108023
108226
|
import { type Duration } from '@awsless/duration'
|
|
@@ -108130,7 +108333,7 @@ var metricFeature = defineFeature({
|
|
|
108130
108333
|
alarmDescription: alarmProps.description,
|
|
108131
108334
|
statistic: alarmProps.where.stat,
|
|
108132
108335
|
threshold: alarmProps.where.value,
|
|
108133
|
-
period:
|
|
108336
|
+
period: toSeconds12(alarmProps.period),
|
|
108134
108337
|
evaluationPeriods: alarmProps.minDataPoints,
|
|
108135
108338
|
comparisonOperator: alarmProps.where.op,
|
|
108136
108339
|
alarmActions: [alarmAction]
|
|
@@ -108151,12 +108354,12 @@ var metricFeature = defineFeature({
|
|
|
108151
108354
|
});
|
|
108152
108355
|
|
|
108153
108356
|
// src/feature/router/index.ts
|
|
108154
|
-
import { days as days10, seconds as
|
|
108357
|
+
import { days as days10, seconds as seconds8, toSeconds as toSeconds14, years } from "@awsless/duration";
|
|
108155
108358
|
|
|
108156
108359
|
// src/feature/router/router-code.ts
|
|
108157
|
-
import { minutes as minutes8, seconds as
|
|
108158
|
-
var ORIGIN_READ_TIMEOUT =
|
|
108159
|
-
var ORIGIN_CONNECTION_TIMEOUT =
|
|
108360
|
+
import { minutes as minutes8, seconds as seconds7, toSeconds as toSeconds13 } from "@awsless/duration";
|
|
108361
|
+
var ORIGIN_READ_TIMEOUT = toSeconds13(minutes8(2));
|
|
108362
|
+
var ORIGIN_CONNECTION_TIMEOUT = toSeconds13(seconds7(10));
|
|
108160
108363
|
var getViewerRequestFunctionCode = (props) => {
|
|
108161
108364
|
return CODE([
|
|
108162
108365
|
props.blockDirectAccess ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
|
|
@@ -108703,9 +108906,9 @@ var routerFeature = defineFeature({
|
|
|
108703
108906
|
});
|
|
108704
108907
|
const cache = new aws.cloudfront.CachePolicy(group, "cache", {
|
|
108705
108908
|
name,
|
|
108706
|
-
minTtl:
|
|
108707
|
-
maxTtl:
|
|
108708
|
-
defaultTtl:
|
|
108909
|
+
minTtl: toSeconds14(seconds8(0)),
|
|
108910
|
+
maxTtl: toSeconds14(days10(365)),
|
|
108911
|
+
defaultTtl: toSeconds14(days10(0)),
|
|
108709
108912
|
parametersInCacheKeyAndForwardedToOrigin: {
|
|
108710
108913
|
enableAcceptEncodingBrotli: true,
|
|
108711
108914
|
enableAcceptEncodingGzip: true,
|
|
@@ -108754,7 +108957,7 @@ var routerFeature = defineFeature({
|
|
|
108754
108957
|
name,
|
|
108755
108958
|
corsConfig: {
|
|
108756
108959
|
originOverride: props.cors?.override ?? true,
|
|
108757
|
-
accessControlMaxAgeSec:
|
|
108960
|
+
accessControlMaxAgeSec: toSeconds14(props.cors?.maxAge ?? years(1)),
|
|
108758
108961
|
accessControlAllowHeaders: { items: props.cors?.headers ?? ["*"] },
|
|
108759
108962
|
accessControlAllowMethods: { items: props.cors?.methods ?? ["ALL"] },
|
|
108760
108963
|
accessControlAllowOrigins: { items: props.cors?.origins ?? ["*"] },
|
|
@@ -108779,7 +108982,7 @@ var routerFeature = defineFeature({
|
|
|
108779
108982
|
strictTransportSecurity: {
|
|
108780
108983
|
override: true,
|
|
108781
108984
|
preload: true,
|
|
108782
|
-
accessControlMaxAgeSec:
|
|
108985
|
+
accessControlMaxAgeSec: toSeconds14(years(1)),
|
|
108783
108986
|
includeSubdomains: true
|
|
108784
108987
|
},
|
|
108785
108988
|
xssProtection: {
|
|
@@ -108799,7 +109002,7 @@ var routerFeature = defineFeature({
|
|
|
108799
109002
|
rateBasedStatement: {
|
|
108800
109003
|
limit: wafSettingsConfig.rateLimiter.limit,
|
|
108801
109004
|
aggregateKeyType: "IP",
|
|
108802
|
-
evaluationWindowSec:
|
|
109005
|
+
evaluationWindowSec: toSeconds14(wafSettingsConfig.rateLimiter.window)
|
|
108803
109006
|
}
|
|
108804
109007
|
},
|
|
108805
109008
|
action: {
|
|
@@ -108889,12 +109092,12 @@ var routerFeature = defineFeature({
|
|
|
108889
109092
|
rule: wafRules,
|
|
108890
109093
|
captchaConfig: {
|
|
108891
109094
|
immunityTimeProperty: {
|
|
108892
|
-
immunityTime:
|
|
109095
|
+
immunityTime: toSeconds14(wafSettingsConfig.captchaImmunityTime)
|
|
108893
109096
|
}
|
|
108894
109097
|
},
|
|
108895
109098
|
challengeConfig: {
|
|
108896
109099
|
immunityTimeProperty: {
|
|
108897
|
-
immunityTime:
|
|
109100
|
+
immunityTime: toSeconds14(wafSettingsConfig.challengeImmunityTime)
|
|
108898
109101
|
}
|
|
108899
109102
|
},
|
|
108900
109103
|
visibilityConfig: {
|
|
@@ -108936,7 +109139,7 @@ var routerFeature = defineFeature({
|
|
|
108936
109139
|
}
|
|
108937
109140
|
return {
|
|
108938
109141
|
errorCode: Number(errorCode),
|
|
108939
|
-
errorCachingMinTtl: item.minTTL ?
|
|
109142
|
+
errorCachingMinTtl: item.minTTL ? toSeconds14(item.minTTL) : undefined,
|
|
108940
109143
|
responseCode: item.statusCode?.toString() ?? errorCode,
|
|
108941
109144
|
responsePagePath: item.path
|
|
108942
109145
|
};
|
|
@@ -109019,7 +109222,7 @@ var routerFeature = defineFeature({
|
|
|
109019
109222
|
}
|
|
109020
109223
|
return {
|
|
109021
109224
|
errorCode: Number(errorCode),
|
|
109022
|
-
errorCachingMinTtl: item.minTTL ?
|
|
109225
|
+
errorCachingMinTtl: item.minTTL ? toSeconds14(item.minTTL) : undefined,
|
|
109023
109226
|
responseCode: item.statusCode ?? Number(errorCode),
|
|
109024
109227
|
responsePagePath: item.path
|
|
109025
109228
|
};
|
|
@@ -112529,7 +112732,7 @@ var getRecursionDetectionPlugin = (options) => ({
|
|
|
112529
112732
|
});
|
|
112530
112733
|
|
|
112531
112734
|
// ../../node_modules/.pnpm/@aws-sdk+middleware-user-agent@3.972.28/node_modules/@aws-sdk/middleware-user-agent/dist-es/configurations.js
|
|
112532
|
-
var
|
|
112735
|
+
var import_core46 = __toESM(require_dist_cjs2(), 1);
|
|
112533
112736
|
var DEFAULT_UA_APP_ID = undefined;
|
|
112534
112737
|
function isValidUserAgentAppId(appId) {
|
|
112535
112738
|
if (appId === undefined) {
|
|
@@ -112538,7 +112741,7 @@ function isValidUserAgentAppId(appId) {
|
|
|
112538
112741
|
return typeof appId === "string" && appId.length <= 50;
|
|
112539
112742
|
}
|
|
112540
112743
|
function resolveUserAgentConfig(input) {
|
|
112541
|
-
const normalizedAppIdProvider =
|
|
112744
|
+
const normalizedAppIdProvider = import_core46.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
|
|
112542
112745
|
const { customUserAgent } = input;
|
|
112543
112746
|
return Object.assign(input, {
|
|
112544
112747
|
customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
|
|
@@ -113974,7 +114177,7 @@ var resolveRegionConfig = (input) => {
|
|
|
113974
114177
|
};
|
|
113975
114178
|
|
|
113976
114179
|
// ../../node_modules/.pnpm/@aws-sdk+client-iot-data-plane@3.1023.0_aws-crt@1.30.0_supports-color@8.1.1_/node_modules/@aws-sdk/client-iot-data-plane/dist-es/IoTDataPlaneClient.js
|
|
113977
|
-
var
|
|
114180
|
+
var import_core47 = __toESM(require_dist_cjs2(), 1);
|
|
113978
114181
|
var import_schema62 = __toESM(require_schema(), 1);
|
|
113979
114182
|
|
|
113980
114183
|
// ../../node_modules/.pnpm/@smithy+middleware-content-length@4.2.12/node_modules/@smithy/middleware-content-length/dist-es/index.js
|
|
@@ -116969,13 +117172,13 @@ class IoTDataPlaneClient extends Client {
|
|
|
116969
117172
|
this.middlewareStack.use(getHostHeaderPlugin(this.config));
|
|
116970
117173
|
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
116971
117174
|
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
116972
|
-
this.middlewareStack.use(
|
|
117175
|
+
this.middlewareStack.use(import_core47.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
116973
117176
|
httpAuthSchemeParametersProvider: defaultIoTDataPlaneHttpAuthSchemeParametersProvider,
|
|
116974
|
-
identityProviderConfigProvider: async (config2) => new
|
|
117177
|
+
identityProviderConfigProvider: async (config2) => new import_core47.DefaultIdentityProviderConfig({
|
|
116975
117178
|
"aws.auth#sigv4": config2.credentials
|
|
116976
117179
|
})
|
|
116977
117180
|
}));
|
|
116978
|
-
this.middlewareStack.use(
|
|
117181
|
+
this.middlewareStack.use(import_core47.getHttpSigningPlugin(this.config));
|
|
116979
117182
|
}
|
|
116980
117183
|
destroy() {
|
|
116981
117184
|
super.destroy();
|
|
@@ -117010,7 +117213,7 @@ import { LambdaClient as LambdaClient5, lambdaClient } from "@awsless/lambda";
|
|
|
117010
117213
|
import { S3Client as S3Client4, s3Client } from "@awsless/s3";
|
|
117011
117214
|
|
|
117012
117215
|
// ../../node_modules/.pnpm/@aws-sdk+client-sns@3.1023.0_aws-crt@1.30.0_supports-color@8.1.1_/node_modules/@aws-sdk/client-sns/dist-es/SNSClient.js
|
|
117013
|
-
var
|
|
117216
|
+
var import_core48 = __toESM(require_dist_cjs2(), 1);
|
|
117014
117217
|
var import_schema64 = __toESM(require_schema(), 1);
|
|
117015
117218
|
|
|
117016
117219
|
// ../../node_modules/.pnpm/@aws-sdk+client-sns@3.1023.0_aws-crt@1.30.0_supports-color@8.1.1_/node_modules/@aws-sdk/client-sns/dist-es/auth/httpAuthSchemeProvider.js
|
|
@@ -118426,13 +118629,13 @@ class SNSClient extends Client {
|
|
|
118426
118629
|
this.middlewareStack.use(getHostHeaderPlugin(this.config));
|
|
118427
118630
|
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
118428
118631
|
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
118429
|
-
this.middlewareStack.use(
|
|
118632
|
+
this.middlewareStack.use(import_core48.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
118430
118633
|
httpAuthSchemeParametersProvider: defaultSNSHttpAuthSchemeParametersProvider,
|
|
118431
|
-
identityProviderConfigProvider: async (config2) => new
|
|
118634
|
+
identityProviderConfigProvider: async (config2) => new import_core48.DefaultIdentityProviderConfig({
|
|
118432
118635
|
"aws.auth#sigv4": config2.credentials
|
|
118433
118636
|
})
|
|
118434
118637
|
}));
|
|
118435
|
-
this.middlewareStack.use(
|
|
118638
|
+
this.middlewareStack.use(import_core48.getHttpSigningPlugin(this.config));
|
|
118436
118639
|
}
|
|
118437
118640
|
destroy() {
|
|
118438
118641
|
super.destroy();
|
|
@@ -130819,7 +131022,7 @@ var getQueueUrlPlugin = (config2) => ({
|
|
|
130819
131022
|
});
|
|
130820
131023
|
|
|
130821
131024
|
// ../../node_modules/.pnpm/@aws-sdk+client-sqs@3.1022.0_aws-crt@1.30.0_supports-color@8.1.1_/node_modules/@aws-sdk/client-sqs/dist-es/SQSClient.js
|
|
130822
|
-
var
|
|
131025
|
+
var import_core49 = __toESM(require_dist_cjs2(), 1);
|
|
130823
131026
|
var import_schema66 = __toESM(require_schema(), 1);
|
|
130824
131027
|
|
|
130825
131028
|
// ../../node_modules/.pnpm/@aws-sdk+client-sqs@3.1022.0_aws-crt@1.30.0_supports-color@8.1.1_/node_modules/@aws-sdk/client-sqs/dist-es/auth/httpAuthSchemeProvider.js
|
|
@@ -132403,13 +132606,13 @@ class SQSClient extends Client {
|
|
|
132403
132606
|
this.middlewareStack.use(getLoggerPlugin(this.config));
|
|
132404
132607
|
this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
|
|
132405
132608
|
this.middlewareStack.use(getQueueUrlPlugin(this.config));
|
|
132406
|
-
this.middlewareStack.use(
|
|
132609
|
+
this.middlewareStack.use(import_core49.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
|
|
132407
132610
|
httpAuthSchemeParametersProvider: defaultSQSHttpAuthSchemeParametersProvider,
|
|
132408
|
-
identityProviderConfigProvider: async (config2) => new
|
|
132611
|
+
identityProviderConfigProvider: async (config2) => new import_core49.DefaultIdentityProviderConfig({
|
|
132409
132612
|
"aws.auth#sigv4": config2.credentials
|
|
132410
132613
|
})
|
|
132411
132614
|
}));
|
|
132412
|
-
this.middlewareStack.use(
|
|
132615
|
+
this.middlewareStack.use(import_core49.getHttpSigningPlugin(this.config));
|
|
132413
132616
|
}
|
|
132414
132617
|
destroy() {
|
|
132415
132618
|
super.destroy();
|
|
@@ -132418,7 +132621,7 @@ class SQSClient extends Client {
|
|
|
132418
132621
|
|
|
132419
132622
|
// ../sqs/dist/index.js
|
|
132420
132623
|
var import_chunk2 = __toESM(require_chunk(), 1);
|
|
132421
|
-
import { seconds as
|
|
132624
|
+
import { seconds as seconds9, toSeconds as toSeconds15 } from "@awsless/duration";
|
|
132422
132625
|
import { parse as parse6, stringify as stringify5 } from "@awsless/json";
|
|
132423
132626
|
var sqsClient = globalClient(() => {
|
|
132424
132627
|
return new SQSClient({});
|
package/dist/handlers/bundle.js
CHANGED
|
@@ -115,19 +115,8 @@ var metricHandler = (event) => {
|
|
|
115
115
|
// src/feature/bundle/server/resource/on-failure.ts
|
|
116
116
|
var onFailureHandler = (event) => {
|
|
117
117
|
const route = event?.["$awsless-route"];
|
|
118
|
-
if (typeof route === "string") {
|
|
119
|
-
|
|
120
|
-
return asyncRoute(route, event.event);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (typeof event?.headers?.["x-awsless-route"] === "string") {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const record = event?.Records?.[0];
|
|
128
|
-
const eventSourceArn = record?.eventSourceARN;
|
|
129
|
-
if (record?.eventSource === "aws:sqs" && typeof eventSourceArn === "string" && eventSourceArn.endsWith(":" + process.env.APP + "--on-failure--failure")) {
|
|
130
|
-
return asyncRoute("base:on-failure:normalizer", event);
|
|
118
|
+
if (typeof route === "string" && routeType(route) === "on-failure") {
|
|
119
|
+
return asyncRoute(route, event.event);
|
|
131
120
|
}
|
|
132
121
|
return;
|
|
133
122
|
};
|
|
@@ -56588,6 +56588,7 @@ class InvokeCommand extends Command.classBuilder().ep(commonParams3).m(function(
|
|
|
56588
56588
|
}
|
|
56589
56589
|
|
|
56590
56590
|
// ../lambda/dist/index.js
|
|
56591
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
56591
56592
|
var ExpectedError = class extends Error {
|
|
56592
56593
|
constructor(type, message) {
|
|
56593
56594
|
super(message);
|
|
@@ -56643,18 +56644,12 @@ var invoke = async ({
|
|
|
56643
56644
|
return response;
|
|
56644
56645
|
};
|
|
56645
56646
|
var GlobalContext = class {
|
|
56646
|
-
#
|
|
56647
|
+
#storage = new AsyncLocalStorage;
|
|
56647
56648
|
async run(store, callback) {
|
|
56648
|
-
this.#store
|
|
56649
|
-
try {
|
|
56650
|
-
const res = await callback();
|
|
56651
|
-
return res;
|
|
56652
|
-
} finally {
|
|
56653
|
-
this.#store = undefined;
|
|
56654
|
-
}
|
|
56649
|
+
return this.#storage.run(store, callback);
|
|
56655
56650
|
}
|
|
56656
56651
|
get() {
|
|
56657
|
-
return this.#
|
|
56652
|
+
return this.#storage.getStore();
|
|
56658
56653
|
}
|
|
56659
56654
|
};
|
|
56660
56655
|
var eventContext = new GlobalContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
00d5cb0528e3ab1b644f8d2a6865dd8505c78944
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/cli",
|
|
3
|
-
"version": "0.0.46-next.
|
|
3
|
+
"version": "0.0.46-next.16",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"@awsless/big-float": "^0.1.7",
|
|
42
42
|
"@awsless/duration": "^0.0.4",
|
|
43
43
|
"@awsless/dynamodb": "^0.3.21",
|
|
44
|
+
"@awsless/lambda": "^0.0.47",
|
|
44
45
|
"@awsless/json": "^0.0.11",
|
|
45
|
-
"@awsless/lambda": "^0.0.46",
|
|
46
|
-
"@awsless/s3": "^0.0.22",
|
|
47
46
|
"@awsless/validate": "^0.1.7",
|
|
48
|
-
"awsless": "^0.0.15-next.
|
|
49
|
-
"@awsless/weak-cache": "^0.0.1"
|
|
47
|
+
"awsless": "^0.0.15-next.3",
|
|
48
|
+
"@awsless/weak-cache": "^0.0.1",
|
|
49
|
+
"@awsless/s3": "^0.0.22"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@clack/prompts": "^0.7.0",
|
|
@@ -100,25 +100,25 @@
|
|
|
100
100
|
"zip-a-folder": "^3.1.6",
|
|
101
101
|
"zod": "^3.24.2",
|
|
102
102
|
"zod-to-json-schema": "^3.24.3",
|
|
103
|
-
"@awsless/
|
|
103
|
+
"@awsless/clui": "^0.0.9",
|
|
104
104
|
"@awsless/cloudwatch": "^0.0.1",
|
|
105
|
+
"@awsless/big-float": "^0.1.7",
|
|
105
106
|
"@awsless/duration": "^0.0.4",
|
|
106
|
-
"@awsless/clui": "^0.0.9",
|
|
107
107
|
"@awsless/dynamodb": "^0.3.21",
|
|
108
108
|
"@awsless/iot": "^0.0.5",
|
|
109
109
|
"@awsless/json": "^0.0.11",
|
|
110
|
-
"@awsless/lambda": "^0.0.
|
|
110
|
+
"@awsless/lambda": "^0.0.47",
|
|
111
111
|
"@awsless/open-search": "^0.0.24",
|
|
112
112
|
"@awsless/redis": "^0.1.13",
|
|
113
113
|
"@awsless/s3": "^0.0.22",
|
|
114
114
|
"@awsless/size": "^0.0.2",
|
|
115
|
+
"@awsless/sqs": "^0.0.24",
|
|
115
116
|
"@awsless/scheduler": "^0.0.5",
|
|
116
117
|
"@awsless/sns": "^0.0.11",
|
|
117
|
-
"@awsless/sqs": "^0.0.24",
|
|
118
118
|
"@awsless/ssm": "^0.0.8",
|
|
119
|
+
"@awsless/weak-cache": "^0.0.1",
|
|
119
120
|
"@awsless/validate": "^0.1.7",
|
|
120
|
-
"awsless": "^0.0.15-next.
|
|
121
|
-
"@awsless/weak-cache": "^0.0.1"
|
|
121
|
+
"awsless": "^0.0.15-next.3"
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
124
124
|
"test": "bun cli/build-handlers.ts && pnpm vitest",
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
// src/feature/on-failure/server/handle.ts
|
|
2
|
-
import { parse as parse2, patch } from "@awsless/json";
|
|
3
|
-
import { invoke } from "@awsless/lambda";
|
|
4
|
-
import { deleteObject, getObject } from "@awsless/s3";
|
|
5
|
-
import { formatRoutePayload, getRouteEnv } from "awsless";
|
|
6
|
-
|
|
7
|
-
// src/feature/on-failure/server/util.ts
|
|
8
|
-
import { parse } from "@awsless/json";
|
|
9
|
-
var isDynamoDBFailureEvent = (event) => {
|
|
10
|
-
return "DDBStreamBatchInfo" in event;
|
|
11
|
-
};
|
|
12
|
-
var logicalResourceName = (physical) => {
|
|
13
|
-
const segments = physical.replace(/\.fifo$/, "").split("--");
|
|
14
|
-
if (segments.length === 4) {
|
|
15
|
-
return `${segments[1]}:${segments[2]}:${segments[3]}`;
|
|
16
|
-
}
|
|
17
|
-
if (segments.length === 3) {
|
|
18
|
-
return `${segments[1]}:${segments[2]}`;
|
|
19
|
-
}
|
|
20
|
-
return physical;
|
|
21
|
-
};
|
|
22
|
-
var getFailureSource = (payload) => {
|
|
23
|
-
const record = getDeliveryRecord(payload);
|
|
24
|
-
if (!record) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (isTopicRecord(record)) {
|
|
28
|
-
return {
|
|
29
|
-
resource: record.Sns.TopicArn ? logicalResourceName(lastArnSegment(record.Sns.TopicArn)) : "topic",
|
|
30
|
-
event: parseEvent(record.Sns.Message)
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
if (isStreamRecord(record)) {
|
|
34
|
-
const table = record.eventSourceARN.split("/")[1];
|
|
35
|
-
return {
|
|
36
|
-
resource: table ? logicalResourceName(table) : "table-stream"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
if (isQueueRecord(record)) {
|
|
40
|
-
return {
|
|
41
|
-
resource: logicalResourceName(lastArnSegment(record.eventSourceARN)),
|
|
42
|
-
event: parseEvent(record.body)
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return;
|
|
46
|
-
};
|
|
47
|
-
var getDeliveryRecord = (payload) => {
|
|
48
|
-
if (!payload || typeof payload !== "object") {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const records = payload.Records;
|
|
52
|
-
const record = Array.isArray(records) ? records[0] : undefined;
|
|
53
|
-
return record && typeof record === "object" ? record : undefined;
|
|
54
|
-
};
|
|
55
|
-
var isTopicRecord = (record) => {
|
|
56
|
-
return "Sns" in record && typeof record.Sns === "object" && record.Sns !== null;
|
|
57
|
-
};
|
|
58
|
-
var isStreamRecord = (record) => {
|
|
59
|
-
return "eventSource" in record && record.eventSource === "aws:dynamodb" && "eventSourceARN" in record;
|
|
60
|
-
};
|
|
61
|
-
var isQueueRecord = (record) => {
|
|
62
|
-
return "eventSource" in record && record.eventSource === "aws:sqs" && "eventSourceARN" in record;
|
|
63
|
-
};
|
|
64
|
-
var lastArnSegment = (arn) => {
|
|
65
|
-
return arn.split(":").at(-1);
|
|
66
|
-
};
|
|
67
|
-
var parseEvent = (value) => {
|
|
68
|
-
if (typeof value !== "string") {
|
|
69
|
-
return value;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
return parse(value);
|
|
73
|
-
} catch {
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// src/feature/on-failure/server/handle.ts
|
|
79
|
-
var handle_default = async (event, context) => {
|
|
80
|
-
if (!Array.isArray(event.Records)) {
|
|
81
|
-
throw new TypeError(`Unknown Event Type: ${JSON.stringify(event)}`);
|
|
82
|
-
}
|
|
83
|
-
await Promise.all(event.Records.map((record) => {
|
|
84
|
-
return unknownRecord(record, context);
|
|
85
|
-
}));
|
|
86
|
-
};
|
|
87
|
-
var unknownRecord = (record, context) => {
|
|
88
|
-
if (typeof record.eventSource === "string") {
|
|
89
|
-
if (record.eventSource.startsWith("aws:sqs")) {
|
|
90
|
-
return sqsRecord(record, context);
|
|
91
|
-
}
|
|
92
|
-
if (record.eventSource.startsWith("aws:s3")) {
|
|
93
|
-
return s3Record(record, context);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
throw new TypeError(`Unknown Record Type: ${JSON.stringify(record)}`);
|
|
97
|
-
};
|
|
98
|
-
var sqsRecord = async (record, context) => {
|
|
99
|
-
const s3Records = parseS3Records(record.body);
|
|
100
|
-
if (s3Records) {
|
|
101
|
-
await Promise.all(s3Records.map((record2) => s3Record(record2, context)));
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const queueName = record.messageAttributes.queueName?.stringValue;
|
|
105
|
-
const body = parsePayload(record.body);
|
|
106
|
-
const payload = {
|
|
107
|
-
type: "queue",
|
|
108
|
-
id: record.messageId,
|
|
109
|
-
date: new Date(Number(record.attributes.SentTimestamp)),
|
|
110
|
-
payload: body,
|
|
111
|
-
source: queueName ? { resource: logicalResourceName(queueName), event: body } : undefined,
|
|
112
|
-
queue: {
|
|
113
|
-
name: queueName,
|
|
114
|
-
url: record.messageAttributes.queueUrl?.stringValue
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
await invokeConsumer(payload, context);
|
|
118
|
-
};
|
|
119
|
-
var parseS3Records = (body) => {
|
|
120
|
-
try {
|
|
121
|
-
const event = JSON.parse(body);
|
|
122
|
-
if (event?.Event === "s3:TestEvent") {
|
|
123
|
-
return [];
|
|
124
|
-
}
|
|
125
|
-
if (Array.isArray(event?.Records) && event.Records[0]?.eventSource === "aws:s3") {
|
|
126
|
-
return event.Records;
|
|
127
|
-
}
|
|
128
|
-
} catch {}
|
|
129
|
-
return;
|
|
130
|
-
};
|
|
131
|
-
var s3Record = async (record, context) => {
|
|
132
|
-
const key = decodeURIComponent(record.s3.object.key.replace(/\+/g, " "));
|
|
133
|
-
const object = await getObject({
|
|
134
|
-
bucket: record.s3.bucket.name,
|
|
135
|
-
key
|
|
136
|
-
});
|
|
137
|
-
if (!object) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const json = await object.body.transformToString();
|
|
141
|
-
const unknownEvent = JSON.parse(json);
|
|
142
|
-
const payload = formatUnknownFailureEvent(unknownEvent);
|
|
143
|
-
await invokeConsumer(payload, context);
|
|
144
|
-
await deleteObject({
|
|
145
|
-
bucket: record.s3.bucket.name,
|
|
146
|
-
key
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
var formatUnknownFailureEvent = (event) => {
|
|
150
|
-
if (isDynamoDBFailureEvent(event)) {
|
|
151
|
-
return formatDynamoDBStreamFailureEvent(event);
|
|
152
|
-
}
|
|
153
|
-
return formatAsyncLambdaFailureEvent(event);
|
|
154
|
-
};
|
|
155
|
-
var formatAsyncLambdaFailureEvent = (event) => {
|
|
156
|
-
const payload = patchPayload(event.requestPayload);
|
|
157
|
-
const route = payload && typeof payload === "object" ? payload["$awsless-route"] : undefined;
|
|
158
|
-
return {
|
|
159
|
-
type: "async-lambda",
|
|
160
|
-
date: new Date(event.timestamp),
|
|
161
|
-
id: event.requestContext.requestId,
|
|
162
|
-
function: {
|
|
163
|
-
name: typeof route === "string" ? route : event.requestContext.functionArn.split(":")[6]
|
|
164
|
-
},
|
|
165
|
-
payload: typeof route === "string" ? payload.event ?? {} : payload,
|
|
166
|
-
source: typeof route === "string" ? { resource: route, event: payload.event ?? {} } : getFailureSource(payload),
|
|
167
|
-
error: {
|
|
168
|
-
type: event.responsePayload.errorType,
|
|
169
|
-
message: event.responsePayload.errorMessage,
|
|
170
|
-
stackTrace: event.responsePayload.stackTrace
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
var formatDynamoDBStreamFailureEvent = (event) => {
|
|
175
|
-
const payload = parsePayload(event.payload);
|
|
176
|
-
const streamArn = event.DDBStreamBatchInfo?.streamArn;
|
|
177
|
-
const table = streamArn?.split("/")[1];
|
|
178
|
-
return {
|
|
179
|
-
type: "dynamodb-stream",
|
|
180
|
-
date: new Date(event.timestamp),
|
|
181
|
-
id: event.requestContext.requestId,
|
|
182
|
-
function: {
|
|
183
|
-
name: event.requestContext.functionArn.split(":")[6]
|
|
184
|
-
},
|
|
185
|
-
payload,
|
|
186
|
-
source: table ? { resource: logicalResourceName(table) } : getFailureSource(payload)
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
var parsePayload = (payload) => {
|
|
190
|
-
try {
|
|
191
|
-
return parse2(payload);
|
|
192
|
-
} catch {
|
|
193
|
-
return payload;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
var patchPayload = (payload) => {
|
|
197
|
-
try {
|
|
198
|
-
return patch(payload);
|
|
199
|
-
} catch {
|
|
200
|
-
return payload;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var invokeConsumer = async (payload, context) => {
|
|
204
|
-
const consumerRoute = getRouteEnv("CONSUMER");
|
|
205
|
-
if (!consumerRoute) {
|
|
206
|
-
throw new Error("The CONSUMER route env is not set");
|
|
207
|
-
}
|
|
208
|
-
await invoke({
|
|
209
|
-
name: context.invokedFunctionArn,
|
|
210
|
-
type: "RequestResponse",
|
|
211
|
-
payload: formatRoutePayload(consumerRoute, payload)
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
export {
|
|
215
|
-
handle_default as default
|
|
216
|
-
};
|