@awsless/cli 0.0.12 → 0.0.15

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
@@ -1175,7 +1175,7 @@ var LogRetentionSchema = DurationSchema.refine(
1175
1175
  (duration) => {
1176
1176
  return validLogRetentionDays.includes(toDays(duration));
1177
1177
  },
1178
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days10) => `${days10}`).join(", ")}`
1178
+ `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days11) => `${days11}`).join(", ")}`
1179
1179
  ).describe("The log retention duration.");
1180
1180
  var LogSchema = z15.union([
1181
1181
  z15.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
@@ -1788,7 +1788,7 @@ var LogRetentionSchema2 = DurationSchema.refine(
1788
1788
  (duration) => {
1789
1789
  return validLogRetentionDays2.includes(toDays2(duration));
1790
1790
  },
1791
- `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days10) => `${days10}`).join(", ")}`
1791
+ `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days11) => `${days11}`).join(", ")}`
1792
1792
  ).describe("The log retention duration.");
1793
1793
  var LogSchema2 = z26.union([
1794
1794
  z26.boolean().transform((enabled) => ({ retention: enabled ? days4(7) : days4(0) })),
@@ -1929,7 +1929,7 @@ var LogRetentionSchema3 = DurationSchema.refine(
1929
1929
  (duration) => {
1930
1930
  return validLogRetentionDays3.includes(toDays3(duration));
1931
1931
  },
1932
- `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days10) => `${days10}`).join(", ")}`
1932
+ `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days11) => `${days11}`).join(", ")}`
1933
1933
  ).describe("The log retention duration.");
1934
1934
  var LogSchema3 = z27.union([
1935
1935
  z27.boolean().transform((enabled) => ({ retention: enabled ? days5(7) : days5(0) })),
@@ -2337,7 +2337,14 @@ var SitesSchema = z38.record(
2337
2337
  ).optional().describe("Define the sites in your stack.");
2338
2338
 
2339
2339
  // src/feature/store/schema.ts
2340
+ import { days as days6 } from "@awsless/duration";
2340
2341
  import { z as z39 } from "zod";
2342
+ var LifecycleRuleSchema = z39.object({
2343
+ prefix: z39.string().optional().describe("Object-key prefix this rule applies to. Omit to apply bucket-wide."),
2344
+ expiration: DurationSchema.refine(durationMin(days6(1)), "Minimum expiration is 1 day").describe(
2345
+ "How long objects matching this rule live before S3 deletes them."
2346
+ )
2347
+ });
2341
2348
  var StoresSchema = z39.union([
2342
2349
  z39.array(ResourceIdSchema).transform((list3) => {
2343
2350
  const stores = {};
@@ -2351,6 +2358,7 @@ var StoresSchema = z39.union([
2351
2358
  z39.object({
2352
2359
  static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
2353
2360
  versioning: z39.boolean().default(false).describe("Enable versioning of your store."),
2361
+ lifecycle: z39.array(LifecycleRuleSchema).optional().describe("S3 lifecycle rules for this store. Each rule expires objects matching an optional prefix."),
2354
2362
  events: z39.object({
2355
2363
  // create
2356
2364
  "created:*": TaskSchema.optional().describe(
@@ -4574,7 +4582,7 @@ var functionFeature = defineFeature({
4574
4582
  });
4575
4583
 
4576
4584
  // src/feature/function/prebuild.ts
4577
- import { days as days6, seconds as seconds5, toDays as toDays6, toSeconds as toSeconds3 } from "@awsless/duration";
4585
+ import { days as days7, seconds as seconds5, toDays as toDays6, toSeconds as toSeconds3 } from "@awsless/duration";
4578
4586
  import { mebibytes as mebibytes2, toMebibytes as toMebibytes4 } from "@awsless/size";
4579
4587
  import { aws as aws8 } from "@terraforge/aws";
4580
4588
  import { Output as Output4, findInputDeps as findInputDeps2, resolveInputs as resolveInputs2 } from "@terraforge/core";
@@ -4706,7 +4714,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4706
4714
  if (props.log?.retention && props.log?.retention?.value > 0n) {
4707
4715
  const logGroup = new aws8.cloudwatch.LogGroup(group, "log", {
4708
4716
  name: `/aws/lambda/${name}`,
4709
- retentionInDays: toDays6(props.log.retention ?? days6(7))
4717
+ retentionInDays: toDays6(props.log.retention ?? days7(7))
4710
4718
  });
4711
4719
  addPermission({
4712
4720
  actions: ["logs:PutLogEvents", "logs:CreateLogStream"],
@@ -4763,7 +4771,7 @@ import { Group as Group8 } from "@terraforge/core";
4763
4771
  import { aws as aws9 } from "@terraforge/aws";
4764
4772
  import { join as join10 } from "path";
4765
4773
  import { mebibytes as mebibytes3 } from "@awsless/size";
4766
- import { days as days7, seconds as seconds6 } from "@awsless/duration";
4774
+ import { days as days8, seconds as seconds6 } from "@awsless/duration";
4767
4775
  var onErrorLogFeature = defineFeature({
4768
4776
  name: "on-error-log",
4769
4777
  onApp(ctx) {
@@ -4778,7 +4786,7 @@ var onErrorLogFeature = defineFeature({
4778
4786
  log: {
4779
4787
  format: "json",
4780
4788
  level: "warn",
4781
- retention: days7(3),
4789
+ retention: days8(3),
4782
4790
  system: "warn"
4783
4791
  }
4784
4792
  });
@@ -4835,7 +4843,7 @@ import { Group as Group9 } from "@terraforge/core";
4835
4843
  import { aws as aws10 } from "@terraforge/aws";
4836
4844
  import { join as join11 } from "path";
4837
4845
  import { mebibytes as mebibytes4 } from "@awsless/size";
4838
- import { days as days8, toSeconds as toSeconds4 } from "@awsless/duration";
4846
+ import { days as days9, toSeconds as toSeconds4 } from "@awsless/duration";
4839
4847
  var onFailureFeature = defineFeature({
4840
4848
  name: "on-failure",
4841
4849
  onApp(ctx) {
@@ -4846,7 +4854,7 @@ var onFailureFeature = defineFeature({
4846
4854
  resourceType: "on-failure",
4847
4855
  resourceName: "deadletter"
4848
4856
  }),
4849
- messageRetentionSeconds: toSeconds4(days8(14))
4857
+ messageRetentionSeconds: toSeconds4(days9(14))
4850
4858
  });
4851
4859
  const queue2 = new aws10.sqs.Queue(group, "on-failure", {
4852
4860
  name: formatGlobalResourceName({
@@ -4994,7 +5002,7 @@ var onFailureFeature = defineFeature({
4994
5002
  log: {
4995
5003
  format: "json",
4996
5004
  level: "warn",
4997
- retention: days8(3),
5005
+ retention: days9(3),
4998
5006
  system: "warn"
4999
5007
  }
5000
5008
  });
@@ -5986,6 +5994,7 @@ var siteFeature = defineFeature({
5986
5994
 
5987
5995
  // src/feature/store/index.ts
5988
5996
  import { Group as Group16 } from "@terraforge/core";
5997
+ import { toDays as toDays7 } from "@awsless/duration";
5989
5998
  import { kebabCase as kebabCase7 } from "change-case";
5990
5999
  import { aws as aws17 } from "@terraforge/aws";
5991
6000
  import { glob as glob3 } from "glob";
@@ -6087,6 +6096,12 @@ var storeFeature = defineFeature({
6087
6096
  resourceName: id,
6088
6097
  postfix: ctx.appId
6089
6098
  });
6099
+ const lifecycleRule = props.lifecycle?.map((rule, index) => ({
6100
+ id: rule.prefix ? `expire-${kebabCase7(rule.prefix)}` : `expire-rule-${index}`,
6101
+ enabled: true,
6102
+ ...rule.prefix ? { prefix: rule.prefix } : {},
6103
+ expiration: { days: toDays7(rule.expiration) }
6104
+ }));
6090
6105
  const bucket = new aws17.s3.Bucket(
6091
6106
  group,
6092
6107
  "store",
@@ -6104,7 +6119,8 @@ var storeFeature = defineFeature({
6104
6119
  allowedOrigins: ["*"],
6105
6120
  allowedMethods: ["POST"]
6106
6121
  }
6107
- ]
6122
+ ],
6123
+ ...lifecycleRule?.length ? { lifecycleRule } : {}
6108
6124
  },
6109
6125
  {
6110
6126
  retainOnDelete: ctx.appConfig.removal === "retain",
@@ -6893,7 +6909,7 @@ import { Group as Group23 } from "@terraforge/core";
6893
6909
  import { aws as aws24 } from "@terraforge/aws";
6894
6910
  import { join as join15, dirname as dirname7 } from "path";
6895
6911
  import { mebibytes as mebibytes6 } from "@awsless/size";
6896
- import { seconds as seconds8, toDays as toDays7 } from "@awsless/duration";
6912
+ import { seconds as seconds8, toDays as toDays8 } from "@awsless/duration";
6897
6913
  import { fileURLToPath as fileURLToPath2 } from "url";
6898
6914
  import { glob as glob4 } from "glob";
6899
6915
  var __dirname3 = dirname7(fileURLToPath2(import.meta.url));
@@ -6984,7 +7000,7 @@ var imageFeature = defineFeature({
6984
7000
  enabled: true,
6985
7001
  id: "image-cache-duration",
6986
7002
  expiration: {
6987
- days: toDays7(props.cacheDuration)
7003
+ days: toDays8(props.cacheDuration)
6988
7004
  }
6989
7005
  }
6990
7006
  ]
@@ -7090,7 +7106,7 @@ import { Group as Group24 } from "@terraforge/core";
7090
7106
  import { aws as aws25 } from "@terraforge/aws";
7091
7107
  import { join as join16, dirname as dirname8 } from "path";
7092
7108
  import { mebibytes as mebibytes7 } from "@awsless/size";
7093
- import { seconds as seconds9, toDays as toDays8 } from "@awsless/duration";
7109
+ import { seconds as seconds9, toDays as toDays9 } from "@awsless/duration";
7094
7110
  import { fileURLToPath as fileURLToPath3 } from "url";
7095
7111
  import { glob as glob5 } from "glob";
7096
7112
  var __dirname4 = dirname8(fileURLToPath3(import.meta.url));
@@ -7135,7 +7151,7 @@ var iconFeature = defineFeature({
7135
7151
  enabled: true,
7136
7152
  id: "icon-cache-duration",
7137
7153
  expiration: {
7138
- days: toDays8(props.cacheDuration)
7154
+ days: toDays9(props.cacheDuration)
7139
7155
  }
7140
7156
  }
7141
7157
  ]
@@ -7242,7 +7258,7 @@ import { relative as relative8 } from "path";
7242
7258
 
7243
7259
  // src/feature/job/util.ts
7244
7260
  import { createHash as createHash4 } from "crypto";
7245
- import { toDays as toDays9, toSeconds as toSeconds9 } from "@awsless/duration";
7261
+ import { toDays as toDays10, toSeconds as toSeconds9 } from "@awsless/duration";
7246
7262
  import { stringify } from "@awsless/json";
7247
7263
  import { toMebibytes as toMebibytes5 } from "@awsless/size";
7248
7264
  import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
@@ -7442,7 +7458,7 @@ var createFargateJob = (parentGroup, ctx, ns, id, local) => {
7442
7458
  if (props.log.retention && props.log.retention.value > 0n) {
7443
7459
  logGroup = new aws26.cloudwatch.LogGroup(group, "log", {
7444
7460
  name: `/aws/ecs/${name}`,
7445
- retentionInDays: toDays9(props.log.retention)
7461
+ retentionInDays: toDays10(props.log.retention)
7446
7462
  });
7447
7463
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
7448
7464
  new aws26.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -7818,7 +7834,7 @@ import { Group as Group28 } from "@terraforge/core";
7818
7834
  import { aws as aws29 } from "@terraforge/aws";
7819
7835
 
7820
7836
  // src/feature/instance/util.ts
7821
- import { toDays as toDays10, toSeconds as toSeconds10 } from "@awsless/duration";
7837
+ import { toDays as toDays11, toSeconds as toSeconds10 } from "@awsless/duration";
7822
7838
  import { stringify as stringify2 } from "@awsless/json";
7823
7839
  import { toMebibytes as toMebibytes6 } from "@awsless/size";
7824
7840
  import { generateFileHash as generateFileHash3 } from "@awsless/ts-file-cache";
@@ -8003,7 +8019,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
8003
8019
  logGroup = new aws28.cloudwatch.LogGroup(group, "log", {
8004
8020
  name: `/aws/ecs/${name}`,
8005
8021
  // name: `/aws/lambda/${name}`,
8006
- retentionInDays: toDays10(props.log.retention)
8022
+ retentionInDays: toDays11(props.log.retention)
8007
8023
  });
8008
8024
  if (ctx.shared.has("on-error-log", "subscriber-arn")) {
8009
8025
  new aws28.cloudwatch.LogSubscriptionFilter(group, "on-error-log", {
@@ -8390,7 +8406,7 @@ var metricFeature = defineFeature({
8390
8406
  });
8391
8407
 
8392
8408
  // src/feature/router/index.ts
8393
- import { days as days9, seconds as seconds10, toSeconds as toSeconds12, years } from "@awsless/duration";
8409
+ import { days as days10, seconds as seconds10, toSeconds as toSeconds12, years } from "@awsless/duration";
8394
8410
  import { Future, Group as Group30 } from "@terraforge/core";
8395
8411
  import { aws as aws31 } from "@terraforge/aws";
8396
8412
  import { camelCase as camelCase9, constantCase as constantCase15 } from "change-case";
@@ -8685,8 +8701,8 @@ var routerFeature = defineFeature({
8685
8701
  const cache = new aws31.cloudfront.CachePolicy(group, "cache", {
8686
8702
  name,
8687
8703
  minTtl: toSeconds12(seconds10(0)),
8688
- maxTtl: toSeconds12(days9(365)),
8689
- defaultTtl: toSeconds12(days9(0)),
8704
+ maxTtl: toSeconds12(days10(365)),
8705
+ defaultTtl: toSeconds12(days10(0)),
8690
8706
  parametersInCacheKeyAndForwardedToOrigin: {
8691
8707
  enableAcceptEncodingBrotli: true,
8692
8708
  enableAcceptEncodingGzip: true,
@@ -233,7 +233,7 @@ var LogRetentionSchema = DurationSchema.refine(
233
233
  (duration) => {
234
234
  return validLogRetentionDays.includes(toDays(duration));
235
235
  },
236
- `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days6) => `${days6}`).join(", ")}`
236
+ `Invalid log retention. Valid days are: ${validLogRetentionDays.map((days7) => `${days7}`).join(", ")}`
237
237
  ).describe("The log retention duration.");
238
238
  var LogSchema = z11.union([
239
239
  z11.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
@@ -846,7 +846,7 @@ var LogRetentionSchema2 = DurationSchema.refine(
846
846
  (duration) => {
847
847
  return validLogRetentionDays2.includes(toDays2(duration));
848
848
  },
849
- `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days6) => `${days6}`).join(", ")}`
849
+ `Invalid log retention. Valid days are: ${validLogRetentionDays2.map((days7) => `${days7}`).join(", ")}`
850
850
  ).describe("The log retention duration.");
851
851
  var LogSchema2 = z22.union([
852
852
  z22.boolean().transform((enabled) => ({ retention: enabled ? days4(7) : days4(0) })),
@@ -987,7 +987,7 @@ var LogRetentionSchema3 = DurationSchema.refine(
987
987
  (duration) => {
988
988
  return validLogRetentionDays3.includes(toDays3(duration));
989
989
  },
990
- `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days6) => `${days6}`).join(", ")}`
990
+ `Invalid log retention. Valid days are: ${validLogRetentionDays3.map((days7) => `${days7}`).join(", ")}`
991
991
  ).describe("The log retention duration.");
992
992
  var LogSchema3 = z23.union([
993
993
  z23.boolean().transform((enabled) => ({ retention: enabled ? days5(7) : days5(0) })),
@@ -1395,7 +1395,14 @@ var SitesSchema = z34.record(
1395
1395
  ).optional().describe("Define the sites in your stack.");
1396
1396
 
1397
1397
  // src/feature/store/schema.ts
1398
+ import { days as days6 } from "@awsless/duration";
1398
1399
  import { z as z35 } from "zod";
1400
+ var LifecycleRuleSchema = z35.object({
1401
+ prefix: z35.string().optional().describe("Object-key prefix this rule applies to. Omit to apply bucket-wide."),
1402
+ expiration: DurationSchema.refine(durationMin(days6(1)), "Minimum expiration is 1 day").describe(
1403
+ "How long objects matching this rule live before S3 deletes them."
1404
+ )
1405
+ });
1399
1406
  var StoresSchema = z35.union([
1400
1407
  z35.array(ResourceIdSchema).transform((list) => {
1401
1408
  const stores = {};
@@ -1409,6 +1416,7 @@ var StoresSchema = z35.union([
1409
1416
  z35.object({
1410
1417
  static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
1411
1418
  versioning: z35.boolean().default(false).describe("Enable versioning of your store."),
1419
+ lifecycle: z35.array(LifecycleRuleSchema).optional().describe("S3 lifecycle rules for this store. Each rule expires objects matching an optional prefix."),
1412
1420
  events: z35.object({
1413
1421
  // create
1414
1422
  "created:*": TaskSchema.optional().describe(
Binary file
Binary file
Binary file
Binary file