@awsless/cli 0.0.46-next.15 → 0.0.46-next.17

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 CHANGED
@@ -55542,8 +55542,8 @@ var require_client2 = __commonJS((exports) => {
55542
55542
  return value;
55543
55543
  };
55544
55544
  };
55545
- var sleep2 = (seconds8) => {
55546
- return new Promise((resolve4) => setTimeout(resolve4, seconds8 * 1000));
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, seconds8, fractionalMilliseconds] = match3;
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: seconds8, fractionalMilliseconds });
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, seconds8, fractionalMilliseconds, offsetStr] = match3;
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: seconds8, fractionalMilliseconds });
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, seconds8, fractionalMilliseconds] = match3;
58227
- return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr, "day", 1, 31), { hours, minutes: minutes9, seconds: seconds8, fractionalMilliseconds });
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, seconds8, fractionalMilliseconds] = match3;
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: seconds8,
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, seconds8, fractionalMilliseconds, yearStr] = match3;
58242
- return buildDate(strictParseShort(stripLeadingZeroes(yearStr)), parseMonthByShortName(monthStr), parseDateValue(dayStr.trimLeft(), "day", 1, 31), { hours, minutes: minutes9, seconds: seconds8, fractionalMilliseconds });
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, seconds8, , ms, offsetStr] = matches;
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(seconds8, 0, 60);
58418
- const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes9), Number(seconds8), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1000) : 0));
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,207 @@ var onErrorLogFeature = defineFeature({
104651
104651
  });
104652
104652
 
104653
104653
  // src/feature/on-failure/index.ts
104654
- import { days as days8, toSeconds as toSeconds4 } from "@awsless/duration";
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 = [policy];
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
+ dependsOn: [ctx.shared.get("on-error-log", "permission")]
104836
+ });
104837
+ }
104838
+ }
104839
+ return {
104840
+ name,
104841
+ group,
104842
+ lambda,
104843
+ policy,
104844
+ code,
104845
+ setEnvironment(name2, value) {
104846
+ variables[name2] = value;
104847
+ },
104848
+ addPermission(...permissions) {
104849
+ addPermission(...permissions);
104850
+ }
104851
+ };
104852
+ };
104853
+
104854
+ // src/feature/on-failure/index.ts
104658
104855
  var onFailureFeature = defineFeature({
104659
104856
  name: "on-failure",
104660
104857
  onBefore(ctx) {
@@ -104665,9 +104862,9 @@ var onFailureFeature = defineFeature({
104665
104862
  resourceType: "on-failure",
104666
104863
  resourceName: "deadletter"
104667
104864
  }),
104668
- messageRetentionSeconds: toSeconds4(days8(14))
104865
+ messageRetentionSeconds: toSeconds5(days8(14))
104669
104866
  });
104670
- const bundleTimeout = toSeconds4(ctx.appConfig.defaults.function.timeout);
104867
+ const bundleTimeout = toSeconds5(ctx.appConfig.defaults.function.timeout);
104671
104868
  const queue2 = new aws.sqs.Queue(group, "on-failure", {
104672
104869
  name: formatGlobalResourceName({
104673
104870
  appName: ctx.app.name,
@@ -104801,21 +104998,29 @@ var onFailureFeature = defineFeature({
104801
104998
  }
104802
104999
  const bundle = ctx.shared.get("bundle", "main");
104803
105000
  const { group, bucket, queue: queue2 } = ctx.shared.get("on-failure", "resources");
104804
- const normalizerRoute = formatRouteKey("base", "on-failure", "normalizer");
104805
- const consumerRoute = formatRouteKey("base", "on-failure", "consumer");
104806
- const consumer = props.consumer;
104807
- bundle.addHandler({
104808
- routeKey: normalizerRoute,
104809
- file: join13(dirname8(fileURLToPath5(import.meta.url)), "/handlers/on-failure.js"),
104810
- exportName: "default"
104811
- });
104812
- registerBundleFunction(ctx, consumerRoute, consumer);
104813
- bundle.addEnv(formatRouteEnvName2(normalizerRoute, "CONSUMER"), consumerRoute);
104814
- bundle.addPermission({
105001
+ registerBundleFunction(ctx, formatRouteKey("base", "on-failure", "consumer"), props.consumer);
105002
+ const distDir = dirname8(fileURLToPath5(import.meta.url));
105003
+ const handler = createPrebuildLambdaFunction(group, ctx, "on-failure", "handler", {
105004
+ bundleFile: join13(distDir, "/prebuild/on-failure/bundle.zip"),
105005
+ bundleHash: join13(distDir, "/prebuild/on-failure/HASH"),
105006
+ runtime: "nodejs24.x",
105007
+ handler: "index.default",
105008
+ memorySize: mebibytes(256),
105009
+ timeout: ctx.appConfig.defaults.function.timeout,
105010
+ log: {
105011
+ format: "json",
105012
+ level: "warn",
105013
+ system: "warn",
105014
+ retention: days8(3)
105015
+ }
105016
+ });
105017
+ handler.addPermission({
105018
+ actions: ["lambda:InvokeFunction"],
105019
+ resources: [bundle.alias.arn]
105020
+ }, {
104815
105021
  actions: ["s3:GetObject", "s3:DeleteObject"],
104816
105022
  resources: [$interpolate`${bucket.arn}/*`]
104817
- });
104818
- bundle.addPermission({
105023
+ }, {
104819
105024
  actions: [
104820
105025
  "sqs:DeleteMessage",
104821
105026
  "sqs:ReceiveMessage",
@@ -104825,11 +105030,11 @@ var onFailureFeature = defineFeature({
104825
105030
  resources: [queue2.arn]
104826
105031
  });
104827
105032
  new aws.lambda.EventSourceMapping(group, "on-failure", {
104828
- functionName: bundle.alias.arn,
105033
+ functionName: handler.lambda.arn,
104829
105034
  eventSourceArn: queue2.arn,
104830
105035
  batchSize: 10
104831
105036
  }, {
104832
- dependsOn: [bundle.policy]
105037
+ dependsOn: [handler.policy]
104833
105038
  });
104834
105039
  const queuePolicy = new aws.sqs.QueuePolicy(group, "bucket-notification", {
104835
105040
  queueUrl: queue2.url,
@@ -104873,10 +105078,10 @@ var onFailureFeature = defineFeature({
104873
105078
  import { createHmac as createHmac2 } from "crypto";
104874
105079
  import { fileURLToPath as fileURLToPath7 } from "url";
104875
105080
  import { dirname as dirname10, join as join16 } from "path";
104876
- import { formatRouteEnvName as formatRouteEnvName3 } from "awsless";
105081
+ import { formatRouteEnvName as formatRouteEnvName2 } from "awsless";
104877
105082
 
104878
105083
  // src/feature/pubsub/util.ts
104879
- import { toDays as toDays6 } from "@awsless/duration";
105084
+ import { toDays as toDays7 } from "@awsless/duration";
104880
105085
  import { stringify } from "@awsless/json";
104881
105086
  import { createHash as createHash11 } from "crypto";
104882
105087
  import { readFile as readFile10 } from "fs/promises";
@@ -105057,7 +105262,7 @@ var createPubSubService = (parentGroup, ctx, id, props, inputs) => {
105057
105262
  if (props.log.retention && props.log.retention.value > 0n) {
105058
105263
  logGroup = new aws.cloudwatch.LogGroup(group, "log", {
105059
105264
  name: `/aws/ecs/${name}`,
105060
- retentionInDays: toDays6(props.log.retention)
105265
+ retentionInDays: toDays7(props.log.retention)
105061
105266
  });
105062
105267
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
105063
105268
  new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -105483,9 +105688,9 @@ var pubsubFeature = defineFeature({
105483
105688
  file: join16(__dirname3, "/handlers/pubsub-publisher.js"),
105484
105689
  exportName: "default"
105485
105690
  });
105486
- bundle.addEnv(formatRouteEnvName3(publisherRouteKey, "REDIS_HOST"), redisHost);
105487
- bundle.addEnv(formatRouteEnvName3(publisherRouteKey, "REDIS_PORT"), redisPort.pipe((port) => port.toString()));
105488
- bundle.addEnv(formatRouteEnvName3(publisherRouteKey, "CHANNEL"), channel);
105691
+ bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_HOST"), redisHost);
105692
+ bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "REDIS_PORT"), redisPort.pipe((port) => port.toString()));
105693
+ bundle.addEnv(formatRouteEnvName2(publisherRouteKey, "CHANNEL"), channel);
105489
105694
  const routerProps = ctx.appConfig.defaults.router?.[props.router];
105490
105695
  if (!routerProps?.domain) {
105491
105696
  throw new FileError("app.json", `The pubsub "${id}" requires the "${props.router}" router to have a domain configured.`);
@@ -105525,7 +105730,7 @@ var pubsubFeature = defineFeature({
105525
105730
  // src/feature/queue/index.ts
105526
105731
  var import_deepmerge2 = __toESM(require_cjs2(), 1);
105527
105732
  import { relative as relative4 } from "path";
105528
- import { minutes as minutes7, seconds as seconds4, toSeconds as toSeconds5 } from "@awsless/duration";
105733
+ import { minutes as minutes7, seconds as seconds5, toSeconds as toSeconds6 } from "@awsless/duration";
105529
105734
  var typeGenCode5 = `
105530
105735
  import {
105531
105736
  SendMessageOptions,
@@ -105591,7 +105796,7 @@ var queueFeature = defineFeature({
105591
105796
  await ctx.write("queue.d.ts", gen, true);
105592
105797
  },
105593
105798
  onStack(ctx) {
105594
- const bundleTimeout = toSeconds5(ctx.appConfig.defaults.function.timeout);
105799
+ const bundleTimeout = toSeconds6(ctx.appConfig.defaults.function.timeout);
105595
105800
  for (const [id, local] of Object.entries(ctx.stackConfig.queues || {})) {
105596
105801
  const props = import_deepmerge2.default(ctx.appConfig.defaults.queue, typeof local === "object" ? local : {});
105597
105802
  const group = new Group(ctx.stack, "queue", id);
@@ -105603,9 +105808,9 @@ var queueFeature = defineFeature({
105603
105808
  });
105604
105809
  const queue2 = new aws.sqs.Queue(group, "queue", {
105605
105810
  name: `${baseName}.fifo`,
105606
- visibilityTimeoutSeconds: bundleTimeout + toSeconds5(minutes7(1)),
105607
- receiveWaitTimeSeconds: toSeconds5(props.receiveMessageWaitTime ?? seconds4(0)),
105608
- messageRetentionSeconds: toSeconds5(props.retentionPeriod),
105811
+ visibilityTimeoutSeconds: bundleTimeout + toSeconds6(minutes7(1)),
105812
+ receiveWaitTimeSeconds: toSeconds6(props.receiveMessageWaitTime ?? seconds5(0)),
105813
+ messageRetentionSeconds: toSeconds6(props.retentionPeriod),
105609
105814
  maxMessageSize: toBytes(props.maxMessageSize),
105610
105815
  fifoQueue: true,
105611
105816
  deduplicationScope: "messageGroup",
@@ -105740,10 +105945,10 @@ var restFeature = defineFeature({
105740
105945
  });
105741
105946
 
105742
105947
  // src/feature/rpc/index.ts
105743
- import { formatRouteEnvName as formatRouteEnvName4 } from "awsless";
105948
+ import { formatRouteEnvName as formatRouteEnvName3 } from "awsless";
105744
105949
  import { dirname as dirname11, join as join17, relative as relative5 } from "path";
105745
105950
  import { fileURLToPath as fileURLToPath8 } from "url";
105746
- import { toSeconds as toSeconds6 } from "@awsless/duration";
105951
+ import { toSeconds as toSeconds7 } from "@awsless/duration";
105747
105952
  var rpcFeature = defineFeature({
105748
105953
  name: "rpc",
105749
105954
  async onTypeGen(ctx) {
@@ -105797,7 +106002,7 @@ var rpcFeature = defineFeature({
105797
106002
  file: join17(dirname11(fileURLToPath8(import.meta.url)), "/handlers/rpc.js"),
105798
106003
  exportName: "default"
105799
106004
  });
105800
- bundle.addEnv(formatRouteEnvName4(serverRouteKey, "TIMEOUT"), toSeconds6(ctx.appConfig.defaults.function.timeout).toString());
106005
+ bundle.addEnv(formatRouteEnvName3(serverRouteKey, "TIMEOUT"), toSeconds7(ctx.appConfig.defaults.function.timeout).toString());
105801
106006
  const lockTable = new aws.dynamodb.Table(group, "lock", {
105802
106007
  name: formatGlobalResourceName({
105803
106008
  appName: ctx.app.name,
@@ -105817,7 +106022,7 @@ var rpcFeature = defineFeature({
105817
106022
  }
105818
106023
  ]
105819
106024
  });
105820
- bundle.addEnv(formatRouteEnvName4(serverRouteKey, "LOCK_TABLE"), lockTable.name);
106025
+ bundle.addEnv(formatRouteEnvName3(serverRouteKey, "LOCK_TABLE"), lockTable.name);
105821
106026
  bundle.addPermission({
105822
106027
  effect: "allow",
105823
106028
  actions: ["dynamodb:UpdateItem", "dynamodb:DeleteItem"],
@@ -105826,7 +106031,7 @@ var rpcFeature = defineFeature({
105826
106031
  if (props.auth) {
105827
106032
  const authRouteKey = formatRouteKey("base", "rpc", `${id}-auth`);
105828
106033
  registerBundleFunction(ctx, authRouteKey, props.auth);
105829
- bundle.addEnv(formatRouteEnvName4(serverRouteKey, "AUTH"), authRouteKey);
106034
+ bundle.addEnv(formatRouteEnvName3(serverRouteKey, "AUTH"), authRouteKey);
105830
106035
  }
105831
106036
  const addRoutes = ctx.shared.entry("router", "addRoutes", props.router);
105832
106037
  addRoutes({
@@ -105851,7 +106056,7 @@ var rpcFeature = defineFeature({
105851
106056
  const entryId = kebabCase(`${id}-${shortId(name)}`);
105852
106057
  const routeKey = formatRouteKey(ctx.stack.name, "rpc", entryId);
105853
106058
  registerBundleFunction(ctx, routeKey, props.function);
105854
- bundle.addEnv(formatRouteEnvName4(serverRouteKey, `QUERY:${name}`), JSON.stringify({ function: routeKey, lock: props.lock }));
106059
+ bundle.addEnv(formatRouteEnvName3(serverRouteKey, `QUERY:${name}`), JSON.stringify({ function: routeKey, lock: props.lock }));
105855
106060
  }
105856
106061
  }
105857
106062
  }
@@ -106121,7 +106326,7 @@ ${(errors3.trim() || output.trim()).slice(-2000)}`);
106121
106326
 
106122
106327
  // src/feature/store/index.ts
106123
106328
  import { join as join20 } from "path";
106124
- import { toDays as toDays7 } from "@awsless/duration";
106329
+ import { toDays as toDays8 } from "@awsless/duration";
106125
106330
 
106126
106331
  // src/feature/store/util.ts
106127
106332
  import { extname as extname6 } from "path";
@@ -106228,7 +106433,7 @@ var storeFeature = defineFeature({
106228
106433
  id: rule.prefix ? `expire-${kebabCase(`${id}-${rule.prefix}`)}` : `expire-${id}-rule-${index}`,
106229
106434
  enabled: true,
106230
106435
  prefix: `${folder}${rule.prefix ?? ""}`,
106231
- expiration: { days: toDays7(rule.expiration) }
106436
+ expiration: { days: toDays8(rule.expiration) }
106232
106437
  });
106233
106438
  }
106234
106439
  ctx.onReady(() => {
@@ -106261,7 +106466,7 @@ var storeFeature = defineFeature({
106261
106466
  });
106262
106467
 
106263
106468
  // src/feature/table/index.ts
106264
- import { toSeconds as toSeconds7 } from "@awsless/duration";
106469
+ import { toSeconds as toSeconds8 } from "@awsless/duration";
106265
106470
  var tableFeature = defineFeature({
106266
106471
  name: "table",
106267
106472
  async onTypeGen(ctx) {
@@ -106390,7 +106595,7 @@ var tableFeature = defineFeature({
106390
106595
  functionName: bundle.alias.arn,
106391
106596
  eventSourceArn: table3.streamArn,
106392
106597
  batchSize: props.stream.batchSize,
106393
- maximumBatchingWindowInSeconds: props.stream.batchWindow ? toSeconds7(props.stream.batchWindow) : undefined,
106598
+ maximumBatchingWindowInSeconds: props.stream.batchWindow ? toSeconds8(props.stream.batchWindow) : undefined,
106394
106599
  maximumRetryAttempts: props.stream.retryAttempts,
106395
106600
  parallelizationFactor: props.stream.concurrencyPerShard,
106396
106601
  functionResponseTypes: ["ReportBatchItemFailures"],
@@ -106867,8 +107072,8 @@ var layerFeature = defineFeature({
106867
107072
  });
106868
107073
 
106869
107074
  // src/feature/image/index.ts
106870
- import { toDays as toDays8 } from "@awsless/duration";
106871
- import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
107075
+ import { toDays as toDays9 } from "@awsless/duration";
107076
+ import { formatRouteEnvName as formatRouteEnvName4 } from "awsless";
106872
107077
  import { dirname as dirname13, join as join21 } from "path";
106873
107078
  import { fileURLToPath as fileURLToPath9 } from "url";
106874
107079
  var imageFeature = defineFeature({
@@ -106942,7 +107147,7 @@ var imageFeature = defineFeature({
106942
107147
  enabled: true,
106943
107148
  prefix: `${folder}cache/`,
106944
107149
  expiration: {
106945
- days: toDays8(props.cacheDuration)
107150
+ days: toDays9(props.cacheDuration)
106946
107151
  }
106947
107152
  });
106948
107153
  }
@@ -106965,17 +107170,17 @@ var imageFeature = defineFeature({
106965
107170
  }
106966
107171
  }
106967
107172
  });
106968
- bundle.addEnv(formatRouteEnvName5(serverRouteKey, "IMAGE_CONFIG"), JSON.stringify({
107173
+ bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_CONFIG"), JSON.stringify({
106969
107174
  presets: props.presets,
106970
107175
  extensions: props.extensions
106971
107176
  }));
106972
- bundle.addEnv(formatRouteEnvName5(serverRouteKey, "IMAGE_BUCKET"), bucket.name);
106973
- bundle.addEnv(formatRouteEnvName5(serverRouteKey, "IMAGE_FOLDER"), folder);
107177
+ bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_BUCKET"), bucket.name);
107178
+ bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_FOLDER"), folder);
106974
107179
  if (originRouteKey) {
106975
- bundle.addEnv(formatRouteEnvName5(serverRouteKey, "IMAGE_ORIGIN"), originRouteKey);
107180
+ bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN"), originRouteKey);
106976
107181
  }
106977
107182
  if (props.origin.static) {
106978
- bundle.addEnv(formatRouteEnvName5(serverRouteKey, "IMAGE_ORIGIN_S3"), "true");
107183
+ bundle.addEnv(formatRouteEnvName4(serverRouteKey, "IMAGE_ORIGIN_S3"), "true");
106979
107184
  }
106980
107185
  ctx.onReady(() => {
106981
107186
  if (props.origin.static) {
@@ -107002,8 +107207,8 @@ var imageFeature = defineFeature({
107002
107207
  });
107003
107208
 
107004
107209
  // src/feature/icon/index.ts
107005
- import { toDays as toDays9 } from "@awsless/duration";
107006
- import { formatRouteEnvName as formatRouteEnvName6 } from "awsless";
107210
+ import { toDays as toDays10 } from "@awsless/duration";
107211
+ import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
107007
107212
  import { dirname as dirname14, join as join22 } from "path";
107008
107213
  import { fileURLToPath as fileURLToPath10 } from "url";
107009
107214
  var iconFeature = defineFeature({
@@ -107029,7 +107234,7 @@ var iconFeature = defineFeature({
107029
107234
  enabled: true,
107030
107235
  prefix: `${folder}cache/`,
107031
107236
  expiration: {
107032
- days: toDays9(props.cacheDuration)
107237
+ days: toDays10(props.cacheDuration)
107033
107238
  }
107034
107239
  });
107035
107240
  }
@@ -107051,17 +107256,17 @@ var iconFeature = defineFeature({
107051
107256
  }
107052
107257
  }
107053
107258
  });
107054
- bundle.addEnv(formatRouteEnvName6(serverRouteKey, "ICON_CONFIG"), JSON.stringify({
107259
+ bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_CONFIG"), JSON.stringify({
107055
107260
  preserveIds: props.preserveIds,
107056
107261
  symbols: props.symbols
107057
107262
  }));
107058
- bundle.addEnv(formatRouteEnvName6(serverRouteKey, "ICON_BUCKET"), bucket.name);
107059
- bundle.addEnv(formatRouteEnvName6(serverRouteKey, "ICON_FOLDER"), folder);
107263
+ bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_BUCKET"), bucket.name);
107264
+ bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_FOLDER"), folder);
107060
107265
  if (originRouteKey) {
107061
- bundle.addEnv(formatRouteEnvName6(serverRouteKey, "ICON_ORIGIN"), originRouteKey);
107266
+ bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN"), originRouteKey);
107062
107267
  }
107063
107268
  if (props.origin.static) {
107064
- bundle.addEnv(formatRouteEnvName6(serverRouteKey, "ICON_ORIGIN_S3"), "true");
107269
+ bundle.addEnv(formatRouteEnvName5(serverRouteKey, "ICON_ORIGIN_S3"), "true");
107065
107270
  }
107066
107271
  ctx.onReady(() => {
107067
107272
  if (props.origin.static) {
@@ -107096,7 +107301,7 @@ import { relative as relative7 } from "path";
107096
107301
 
107097
107302
  // src/feature/job/util.ts
107098
107303
  import { createHash as createHash14 } from "crypto";
107099
- import { toDays as toDays10, toSeconds as toSeconds8 } from "@awsless/duration";
107304
+ import { toDays as toDays11, toSeconds as toSeconds9 } from "@awsless/duration";
107100
107305
  import { stringify as stringify2 } from "@awsless/json";
107101
107306
  import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
107102
107307
  var import_deepmerge3 = __toESM(require_cjs2(), 1);
@@ -107283,7 +107488,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
107283
107488
  if (props.log.retention && props.log.retention.value > 0n) {
107284
107489
  logGroup = new aws.cloudwatch.LogGroup(group, "log", {
107285
107490
  name: `/aws/ecs/${name}`,
107286
- retentionInDays: toDays10(props.log.retention)
107491
+ retentionInDays: toDays11(props.log.retention)
107287
107492
  });
107288
107493
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
107289
107494
  new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -107371,7 +107576,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
107371
107576
  [
107372
107577
  ...props.startupCommand?.length ? [props.startupCommand.join(" && ")] : [],
107373
107578
  `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 ${toSeconds8(props.timeout)} /root/program`
107579
+ `exec timeout --kill-after=10 ${toSeconds9(props.timeout)} /root/program`
107375
107580
  ].join(" && ")
107376
107581
  ],
107377
107582
  environment: Object.entries(data).map(([name2, value]) => ({
@@ -107609,10 +107814,10 @@ var jobFeature = defineFeature({
107609
107814
  });
107610
107815
 
107611
107816
  // src/feature/instance/index.ts
107612
- import { days as days9, seconds as seconds5, toSeconds as toSeconds10 } from "@awsless/duration";
107817
+ import { days as days9, seconds as seconds6, toSeconds as toSeconds11 } from "@awsless/duration";
107613
107818
 
107614
107819
  // src/feature/instance/util.ts
107615
- import { toDays as toDays11, toSeconds as toSeconds9 } from "@awsless/duration";
107820
+ import { toDays as toDays12, toSeconds as toSeconds10 } from "@awsless/duration";
107616
107821
  import { stringify as stringify3 } from "@awsless/json";
107617
107822
  import { generateFileHash as generateFileHash3 } from "@awsless/ts-file-cache";
107618
107823
  var import_deepmerge5 = __toESM(require_cjs2(), 1);
@@ -107735,7 +107940,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
107735
107940
  if (props.log.retention && props.log.retention.value > 0n) {
107736
107941
  logGroup = new aws.cloudwatch.LogGroup(group, "log", {
107737
107942
  name: `/aws/ecs/${name}`,
107738
- retentionInDays: toDays11(props.log.retention)
107943
+ retentionInDays: toDays12(props.log.retention)
107739
107944
  });
107740
107945
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
107741
107946
  new aws.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -107824,10 +108029,10 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
107824
108029
  "CMD-SHELL",
107825
108030
  `curl -f http://${join24("localhost", props.healthCheck.path)} || exit 1`
107826
108031
  ],
107827
- interval: toSeconds9(props.healthCheck.interval),
108032
+ interval: toSeconds10(props.healthCheck.interval),
107828
108033
  retries: props.healthCheck.retries,
107829
- startPeriod: toSeconds9(props.healthCheck.startPeriod),
107830
- timeout: toSeconds9(props.healthCheck.timeout)
108034
+ startPeriod: toSeconds10(props.healthCheck.startPeriod),
108035
+ timeout: toSeconds10(props.healthCheck.timeout)
107831
108036
  } : undefined
107832
108037
  }
107833
108038
  ]));
@@ -107992,10 +108197,10 @@ var instanceFeature = defineFeature({
107992
108197
  const task2 = createFargateTask(group, ctx, "instance", id, props);
107993
108198
  const queue2 = new aws.sqs.Queue(group, "queue", {
107994
108199
  name: task2.name,
107995
- visibilityTimeoutSeconds: toSeconds10(seconds5(30)),
107996
- messageRetentionSeconds: toSeconds10(days9(4)),
108200
+ visibilityTimeoutSeconds: toSeconds11(seconds6(30)),
108201
+ messageRetentionSeconds: toSeconds11(days9(4)),
107997
108202
  maxMessageSize: toBytes(kibibytes(256)),
107998
- receiveWaitTimeSeconds: toSeconds10(seconds5(20))
108203
+ receiveWaitTimeSeconds: toSeconds11(seconds6(20))
107999
108204
  });
108000
108205
  task2.addPermission({
108001
108206
  actions: [
@@ -108017,7 +108222,7 @@ var instanceFeature = defineFeature({
108017
108222
  });
108018
108223
 
108019
108224
  // src/feature/metric/index.ts
108020
- import { toSeconds as toSeconds11 } from "@awsless/duration";
108225
+ import { toSeconds as toSeconds12 } from "@awsless/duration";
108021
108226
  var typeGenCode13 = `
108022
108227
  import { type PutDataProps, putData, batchPutData } from '@awsless/cloudwatch'
108023
108228
  import { type Duration } from '@awsless/duration'
@@ -108130,7 +108335,7 @@ var metricFeature = defineFeature({
108130
108335
  alarmDescription: alarmProps.description,
108131
108336
  statistic: alarmProps.where.stat,
108132
108337
  threshold: alarmProps.where.value,
108133
- period: toSeconds11(alarmProps.period),
108338
+ period: toSeconds12(alarmProps.period),
108134
108339
  evaluationPeriods: alarmProps.minDataPoints,
108135
108340
  comparisonOperator: alarmProps.where.op,
108136
108341
  alarmActions: [alarmAction]
@@ -108151,12 +108356,12 @@ var metricFeature = defineFeature({
108151
108356
  });
108152
108357
 
108153
108358
  // src/feature/router/index.ts
108154
- import { days as days10, seconds as seconds7, toSeconds as toSeconds13, years } from "@awsless/duration";
108359
+ import { days as days10, seconds as seconds8, toSeconds as toSeconds14, years } from "@awsless/duration";
108155
108360
 
108156
108361
  // src/feature/router/router-code.ts
108157
- import { minutes as minutes8, seconds as seconds6, toSeconds as toSeconds12 } from "@awsless/duration";
108158
- var ORIGIN_READ_TIMEOUT = toSeconds12(minutes8(2));
108159
- var ORIGIN_CONNECTION_TIMEOUT = toSeconds12(seconds6(10));
108362
+ import { minutes as minutes8, seconds as seconds7, toSeconds as toSeconds13 } from "@awsless/duration";
108363
+ var ORIGIN_READ_TIMEOUT = toSeconds13(minutes8(2));
108364
+ var ORIGIN_CONNECTION_TIMEOUT = toSeconds13(seconds7(10));
108160
108365
  var getViewerRequestFunctionCode = (props) => {
108161
108366
  return CODE([
108162
108367
  props.blockDirectAccess ? BLOCK_DIRECT_ACCESS_TO_CLOUDFRONT : "",
@@ -108703,9 +108908,9 @@ var routerFeature = defineFeature({
108703
108908
  });
108704
108909
  const cache = new aws.cloudfront.CachePolicy(group, "cache", {
108705
108910
  name,
108706
- minTtl: toSeconds13(seconds7(0)),
108707
- maxTtl: toSeconds13(days10(365)),
108708
- defaultTtl: toSeconds13(days10(0)),
108911
+ minTtl: toSeconds14(seconds8(0)),
108912
+ maxTtl: toSeconds14(days10(365)),
108913
+ defaultTtl: toSeconds14(days10(0)),
108709
108914
  parametersInCacheKeyAndForwardedToOrigin: {
108710
108915
  enableAcceptEncodingBrotli: true,
108711
108916
  enableAcceptEncodingGzip: true,
@@ -108754,7 +108959,7 @@ var routerFeature = defineFeature({
108754
108959
  name,
108755
108960
  corsConfig: {
108756
108961
  originOverride: props.cors?.override ?? true,
108757
- accessControlMaxAgeSec: toSeconds13(props.cors?.maxAge ?? years(1)),
108962
+ accessControlMaxAgeSec: toSeconds14(props.cors?.maxAge ?? years(1)),
108758
108963
  accessControlAllowHeaders: { items: props.cors?.headers ?? ["*"] },
108759
108964
  accessControlAllowMethods: { items: props.cors?.methods ?? ["ALL"] },
108760
108965
  accessControlAllowOrigins: { items: props.cors?.origins ?? ["*"] },
@@ -108779,7 +108984,7 @@ var routerFeature = defineFeature({
108779
108984
  strictTransportSecurity: {
108780
108985
  override: true,
108781
108986
  preload: true,
108782
- accessControlMaxAgeSec: toSeconds13(years(1)),
108987
+ accessControlMaxAgeSec: toSeconds14(years(1)),
108783
108988
  includeSubdomains: true
108784
108989
  },
108785
108990
  xssProtection: {
@@ -108799,7 +109004,7 @@ var routerFeature = defineFeature({
108799
109004
  rateBasedStatement: {
108800
109005
  limit: wafSettingsConfig.rateLimiter.limit,
108801
109006
  aggregateKeyType: "IP",
108802
- evaluationWindowSec: toSeconds13(wafSettingsConfig.rateLimiter.window)
109007
+ evaluationWindowSec: toSeconds14(wafSettingsConfig.rateLimiter.window)
108803
109008
  }
108804
109009
  },
108805
109010
  action: {
@@ -108889,12 +109094,12 @@ var routerFeature = defineFeature({
108889
109094
  rule: wafRules,
108890
109095
  captchaConfig: {
108891
109096
  immunityTimeProperty: {
108892
- immunityTime: toSeconds13(wafSettingsConfig.captchaImmunityTime)
109097
+ immunityTime: toSeconds14(wafSettingsConfig.captchaImmunityTime)
108893
109098
  }
108894
109099
  },
108895
109100
  challengeConfig: {
108896
109101
  immunityTimeProperty: {
108897
- immunityTime: toSeconds13(wafSettingsConfig.challengeImmunityTime)
109102
+ immunityTime: toSeconds14(wafSettingsConfig.challengeImmunityTime)
108898
109103
  }
108899
109104
  },
108900
109105
  visibilityConfig: {
@@ -108936,7 +109141,7 @@ var routerFeature = defineFeature({
108936
109141
  }
108937
109142
  return {
108938
109143
  errorCode: Number(errorCode),
108939
- errorCachingMinTtl: item.minTTL ? toSeconds13(item.minTTL) : undefined,
109144
+ errorCachingMinTtl: item.minTTL ? toSeconds14(item.minTTL) : undefined,
108940
109145
  responseCode: item.statusCode?.toString() ?? errorCode,
108941
109146
  responsePagePath: item.path
108942
109147
  };
@@ -109019,7 +109224,7 @@ var routerFeature = defineFeature({
109019
109224
  }
109020
109225
  return {
109021
109226
  errorCode: Number(errorCode),
109022
- errorCachingMinTtl: item.minTTL ? toSeconds13(item.minTTL) : undefined,
109227
+ errorCachingMinTtl: item.minTTL ? toSeconds14(item.minTTL) : undefined,
109023
109228
  responseCode: item.statusCode ?? Number(errorCode),
109024
109229
  responsePagePath: item.path
109025
109230
  };
@@ -112529,7 +112734,7 @@ var getRecursionDetectionPlugin = (options) => ({
112529
112734
  });
112530
112735
 
112531
112736
  // ../../node_modules/.pnpm/@aws-sdk+middleware-user-agent@3.972.28/node_modules/@aws-sdk/middleware-user-agent/dist-es/configurations.js
112532
- var import_core45 = __toESM(require_dist_cjs2(), 1);
112737
+ var import_core46 = __toESM(require_dist_cjs2(), 1);
112533
112738
  var DEFAULT_UA_APP_ID = undefined;
112534
112739
  function isValidUserAgentAppId(appId) {
112535
112740
  if (appId === undefined) {
@@ -112538,7 +112743,7 @@ function isValidUserAgentAppId(appId) {
112538
112743
  return typeof appId === "string" && appId.length <= 50;
112539
112744
  }
112540
112745
  function resolveUserAgentConfig(input) {
112541
- const normalizedAppIdProvider = import_core45.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
112746
+ const normalizedAppIdProvider = import_core46.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
112542
112747
  const { customUserAgent } = input;
112543
112748
  return Object.assign(input, {
112544
112749
  customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
@@ -113974,7 +114179,7 @@ var resolveRegionConfig = (input) => {
113974
114179
  };
113975
114180
 
113976
114181
  // ../../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 import_core46 = __toESM(require_dist_cjs2(), 1);
114182
+ var import_core47 = __toESM(require_dist_cjs2(), 1);
113978
114183
  var import_schema62 = __toESM(require_schema(), 1);
113979
114184
 
113980
114185
  // ../../node_modules/.pnpm/@smithy+middleware-content-length@4.2.12/node_modules/@smithy/middleware-content-length/dist-es/index.js
@@ -116969,13 +117174,13 @@ class IoTDataPlaneClient extends Client {
116969
117174
  this.middlewareStack.use(getHostHeaderPlugin(this.config));
116970
117175
  this.middlewareStack.use(getLoggerPlugin(this.config));
116971
117176
  this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
116972
- this.middlewareStack.use(import_core46.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
117177
+ this.middlewareStack.use(import_core47.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
116973
117178
  httpAuthSchemeParametersProvider: defaultIoTDataPlaneHttpAuthSchemeParametersProvider,
116974
- identityProviderConfigProvider: async (config2) => new import_core46.DefaultIdentityProviderConfig({
117179
+ identityProviderConfigProvider: async (config2) => new import_core47.DefaultIdentityProviderConfig({
116975
117180
  "aws.auth#sigv4": config2.credentials
116976
117181
  })
116977
117182
  }));
116978
- this.middlewareStack.use(import_core46.getHttpSigningPlugin(this.config));
117183
+ this.middlewareStack.use(import_core47.getHttpSigningPlugin(this.config));
116979
117184
  }
116980
117185
  destroy() {
116981
117186
  super.destroy();
@@ -117010,7 +117215,7 @@ import { LambdaClient as LambdaClient5, lambdaClient } from "@awsless/lambda";
117010
117215
  import { S3Client as S3Client4, s3Client } from "@awsless/s3";
117011
117216
 
117012
117217
  // ../../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 import_core47 = __toESM(require_dist_cjs2(), 1);
117218
+ var import_core48 = __toESM(require_dist_cjs2(), 1);
117014
117219
  var import_schema64 = __toESM(require_schema(), 1);
117015
117220
 
117016
117221
  // ../../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 +118631,13 @@ class SNSClient extends Client {
118426
118631
  this.middlewareStack.use(getHostHeaderPlugin(this.config));
118427
118632
  this.middlewareStack.use(getLoggerPlugin(this.config));
118428
118633
  this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
118429
- this.middlewareStack.use(import_core47.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
118634
+ this.middlewareStack.use(import_core48.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
118430
118635
  httpAuthSchemeParametersProvider: defaultSNSHttpAuthSchemeParametersProvider,
118431
- identityProviderConfigProvider: async (config2) => new import_core47.DefaultIdentityProviderConfig({
118636
+ identityProviderConfigProvider: async (config2) => new import_core48.DefaultIdentityProviderConfig({
118432
118637
  "aws.auth#sigv4": config2.credentials
118433
118638
  })
118434
118639
  }));
118435
- this.middlewareStack.use(import_core47.getHttpSigningPlugin(this.config));
118640
+ this.middlewareStack.use(import_core48.getHttpSigningPlugin(this.config));
118436
118641
  }
118437
118642
  destroy() {
118438
118643
  super.destroy();
@@ -130819,7 +131024,7 @@ var getQueueUrlPlugin = (config2) => ({
130819
131024
  });
130820
131025
 
130821
131026
  // ../../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 import_core48 = __toESM(require_dist_cjs2(), 1);
131027
+ var import_core49 = __toESM(require_dist_cjs2(), 1);
130823
131028
  var import_schema66 = __toESM(require_schema(), 1);
130824
131029
 
130825
131030
  // ../../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 +132608,13 @@ class SQSClient extends Client {
132403
132608
  this.middlewareStack.use(getLoggerPlugin(this.config));
132404
132609
  this.middlewareStack.use(getRecursionDetectionPlugin(this.config));
132405
132610
  this.middlewareStack.use(getQueueUrlPlugin(this.config));
132406
- this.middlewareStack.use(import_core48.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
132611
+ this.middlewareStack.use(import_core49.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {
132407
132612
  httpAuthSchemeParametersProvider: defaultSQSHttpAuthSchemeParametersProvider,
132408
- identityProviderConfigProvider: async (config2) => new import_core48.DefaultIdentityProviderConfig({
132613
+ identityProviderConfigProvider: async (config2) => new import_core49.DefaultIdentityProviderConfig({
132409
132614
  "aws.auth#sigv4": config2.credentials
132410
132615
  })
132411
132616
  }));
132412
- this.middlewareStack.use(import_core48.getHttpSigningPlugin(this.config));
132617
+ this.middlewareStack.use(import_core49.getHttpSigningPlugin(this.config));
132413
132618
  }
132414
132619
  destroy() {
132415
132620
  super.destroy();
@@ -132418,7 +132623,7 @@ class SQSClient extends Client {
132418
132623
 
132419
132624
  // ../sqs/dist/index.js
132420
132625
  var import_chunk2 = __toESM(require_chunk(), 1);
132421
- import { seconds as seconds8, toSeconds as toSeconds14 } from "@awsless/duration";
132626
+ import { seconds as seconds9, toSeconds as toSeconds15 } from "@awsless/duration";
132422
132627
  import { parse as parse6, stringify as stringify5 } from "@awsless/json";
132423
132628
  var sqsClient = globalClient(() => {
132424
132629
  return new SQSClient({});
@@ -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
- if (routeType(route) === "on-failure") {
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
- #store;
56647
+ #storage = new AsyncLocalStorage;
56647
56648
  async run(store, callback) {
56648
- this.#store = 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.#store;
56652
+ return this.#storage.getStore();
56658
56653
  }
56659
56654
  };
56660
56655
  var eventContext = new GlobalContext;
@@ -0,0 +1 @@
1
+ 00d5cb0528e3ab1b644f8d2a6865dd8505c78944
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/cli",
3
- "version": "0.0.46-next.15",
3
+ "version": "0.0.46-next.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -40,13 +40,13 @@
40
40
  "peerDependencies": {
41
41
  "@awsless/big-float": "^0.1.7",
42
42
  "@awsless/duration": "^0.0.4",
43
- "@awsless/dynamodb": "^0.3.21",
44
43
  "@awsless/json": "^0.0.11",
45
- "@awsless/lambda": "^0.0.46",
44
+ "@awsless/lambda": "^0.0.47",
46
45
  "@awsless/s3": "^0.0.22",
47
46
  "@awsless/validate": "^0.1.7",
48
- "awsless": "^0.0.15-next.2",
49
- "@awsless/weak-cache": "^0.0.1"
47
+ "@awsless/weak-cache": "^0.0.1",
48
+ "awsless": "^0.0.15-next.3",
49
+ "@awsless/dynamodb": "^0.3.21"
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/big-float": "^0.1.7",
104
103
  "@awsless/cloudwatch": "^0.0.1",
105
104
  "@awsless/duration": "^0.0.4",
106
- "@awsless/clui": "^0.0.9",
107
105
  "@awsless/dynamodb": "^0.3.21",
106
+ "@awsless/big-float": "^0.1.7",
108
107
  "@awsless/iot": "^0.0.5",
108
+ "@awsless/clui": "^0.0.9",
109
109
  "@awsless/json": "^0.0.11",
110
- "@awsless/lambda": "^0.0.46",
111
- "@awsless/open-search": "^0.0.24",
112
- "@awsless/redis": "^0.1.13",
110
+ "@awsless/lambda": "^0.0.47",
113
111
  "@awsless/s3": "^0.0.22",
114
- "@awsless/size": "^0.0.2",
115
- "@awsless/scheduler": "^0.0.5",
112
+ "@awsless/open-search": "^0.0.24",
116
113
  "@awsless/sns": "^0.0.11",
117
- "@awsless/sqs": "^0.0.24",
114
+ "@awsless/redis": "^0.1.13",
118
115
  "@awsless/ssm": "^0.0.8",
116
+ "@awsless/weak-cache": "^0.0.1",
117
+ "@awsless/scheduler": "^0.0.5",
118
+ "awsless": "^0.0.15-next.3",
119
119
  "@awsless/validate": "^0.1.7",
120
- "awsless": "^0.0.15-next.2",
121
- "@awsless/weak-cache": "^0.0.1"
120
+ "@awsless/sqs": "^0.0.24",
121
+ "@awsless/size": "^0.0.2"
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
- };