@awsless/awsless 0.0.512 → 0.0.515

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
@@ -1688,8 +1688,8 @@ var IconsSchema = z34.record(
1688
1688
  })
1689
1689
  ]).describe(
1690
1690
  "Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
1691
- ),
1692
- version: z34.number().int().min(1).optional().describe("Version of the icon configuration.")
1691
+ )
1692
+ // version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
1693
1693
  })
1694
1694
  ).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
1695
1695
 
@@ -6048,8 +6048,7 @@ var imageFeature = defineFeature({
6048
6048
  appName: ctx.app.name,
6049
6049
  stackName: ctx.stack.name,
6050
6050
  resourceType: "image",
6051
- resourceName: id,
6052
- postfix: ctx.appId
6051
+ resourceName: shortId(`${id}-${ctx.appId}`)
6053
6052
  }),
6054
6053
  forceDestroy: true
6055
6054
  });
@@ -6061,6 +6060,9 @@ var imageFeature = defineFeature({
6061
6060
  resourceType: "image",
6062
6061
  resourceName: shortId(`cache-${id}-${ctx.appId}`)
6063
6062
  }),
6063
+ tags: {
6064
+ cache: "true"
6065
+ },
6064
6066
  forceDestroy: true
6065
6067
  });
6066
6068
  const sharpLayerId = formatGlobalResourceName({
@@ -6168,6 +6170,12 @@ var imageFeature = defineFeature({
6168
6170
  aliases: domainName ? [domainName] : void 0,
6169
6171
  priceClass: "PriceClass_All",
6170
6172
  httpVersion: "http2and3",
6173
+ restrictions: {
6174
+ geoRestriction: {
6175
+ restrictionType: "none",
6176
+ locations: []
6177
+ }
6178
+ },
6171
6179
  viewerCertificate: certificateArn ? {
6172
6180
  sslSupportMethod: "sni-only",
6173
6181
  minimumProtocolVersion: "TLSv1.2_2021",
@@ -6298,8 +6306,7 @@ var iconFeature = defineFeature({
6298
6306
  appName: ctx.app.name,
6299
6307
  stackName: ctx.stack.name,
6300
6308
  resourceType: "icon",
6301
- resourceName: id,
6302
- postfix: ctx.appId
6309
+ resourceName: shortId(`${id}-${ctx.appId}`)
6303
6310
  }),
6304
6311
  forceDestroy: true
6305
6312
  });
@@ -6360,8 +6367,7 @@ var iconFeature = defineFeature({
6360
6367
  "ICON_CONFIG",
6361
6368
  JSON.stringify({
6362
6369
  preserveId: props.preserveId,
6363
- symbols: props.symbols,
6364
- version: props.version
6370
+ symbols: props.symbols
6365
6371
  })
6366
6372
  );
6367
6373
  serverLambda.setEnvironment("ICON_CACHE_BUCKET", cacheBucket.bucket);
@@ -6416,6 +6422,12 @@ var iconFeature = defineFeature({
6416
6422
  aliases: domainName ? [domainName] : void 0,
6417
6423
  priceClass: "PriceClass_All",
6418
6424
  httpVersion: "http2and3",
6425
+ restrictions: {
6426
+ geoRestriction: {
6427
+ restrictionType: "none",
6428
+ locations: []
6429
+ }
6430
+ },
6419
6431
  viewerCertificate: certificateArn ? {
6420
6432
  sslSupportMethod: "sni-only",
6421
6433
  minimumProtocolVersion: "TLSv1.2_2021",
@@ -8481,6 +8493,7 @@ var parseJsonLog = (message) => {
8481
8493
  import { CloudFrontClient as CloudFrontClient2, CreateInvalidationCommand as CreateInvalidationCommand2 } from "@aws-sdk/client-cloudfront";
8482
8494
  import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
8483
8495
  import { Cancelled as Cancelled2, log as log23, prompt as prompt10 } from "@awsless/clui";
8496
+ import { randomUUID } from "crypto";
8484
8497
  var clearCache = (program2) => {
8485
8498
  program2.command("cache-clear").argument("[stack]", "The stack name of the image proxy").argument("[name]", "The name of the image proxy").description("Clears the cache of the image proxy").action(async (stack, name) => {
8486
8499
  await layout("image cache-clear", async ({ appConfig, stackConfigs }) => {
@@ -8496,7 +8509,7 @@ var clearCache = (program2) => {
8496
8509
  return;
8497
8510
  });
8498
8511
  stack = await prompt10.select({
8499
- message: "Select the image proxy:",
8512
+ message: "Select the stack:",
8500
8513
  options: imageStacks.map((stack2) => ({
8501
8514
  label: stack2.name,
8502
8515
  value: stack2.name
@@ -8510,10 +8523,10 @@ var clearCache = (program2) => {
8510
8523
  }
8511
8524
  const names = Object.keys(stackConfig.images ?? {});
8512
8525
  if (!names) {
8513
- throw new ExpectedError(`No images are defined in stack "${stack}".`);
8526
+ throw new ExpectedError(`No image resources are defined in stack "${stack}".`);
8514
8527
  }
8515
8528
  name = await prompt10.select({
8516
- message: "Select the image:",
8529
+ message: "Select the image resource:",
8517
8530
  options: names.map((name2) => ({
8518
8531
  label: name2,
8519
8532
  value: name2
@@ -8540,59 +8553,65 @@ var clearCache = (program2) => {
8540
8553
  distributionId = await shared.entry("image", "distribution-id", name);
8541
8554
  cacheBucket = await shared.entry("image", "cache-bucket", name);
8542
8555
  } catch (_) {
8543
- throw new ExpectedError(`The image proxy hasn't been deployed yet.`);
8556
+ throw new ExpectedError(`The image resource hasn't been deployed yet.`);
8544
8557
  }
8545
8558
  const s3Client2 = new S3Client3({
8546
8559
  credentials,
8547
8560
  region
8548
8561
  });
8549
- let continuationToken;
8550
- let totalDeleted = 0;
8551
- let hasMore = true;
8552
- while (hasMore) {
8553
- const result = await s3Client2.send(
8554
- new ListObjectsV2Command({
8555
- Bucket: cacheBucket,
8556
- ContinuationToken: continuationToken,
8557
- MaxKeys: 1e3
8558
- // Maximum allowed per request
8559
- })
8560
- );
8561
- if (result.Contents && result.Contents.length > 0) {
8562
- await s3Client2.send(
8563
- new DeleteObjectsCommand({
8564
- Bucket: cacheBucket,
8565
- Delete: {
8566
- Objects: result.Contents.map((obj) => ({
8567
- Key: obj.Key
8568
- })),
8569
- Quiet: true
8570
- }
8571
- })
8572
- );
8573
- totalDeleted += result.Contents.length;
8574
- log23.info(`${result.Contents.length} objects deleted from cache.`);
8575
- }
8576
- continuationToken = result.NextContinuationToken;
8577
- hasMore = !!continuationToken;
8578
- }
8579
8562
  const cloudFrontClient = new CloudFrontClient2({
8580
8563
  credentials,
8581
8564
  region: "us-east-1"
8582
8565
  });
8583
- await cloudFrontClient.send(
8584
- new CreateInvalidationCommand2({
8585
- DistributionId: distributionId,
8586
- InvalidationBatch: {
8587
- CallerReference: `image-cache-clear-${Date.now()}`,
8588
- Paths: {
8589
- Quantity: 1,
8590
- Items: ["/*"]
8566
+ let totalDeleted = 0;
8567
+ await log23.task({
8568
+ initialMessage: "Clearing cache...",
8569
+ successMessage: "Cache successfully cleared.",
8570
+ task: async () => {
8571
+ let continuationToken;
8572
+ while (true) {
8573
+ const result = await s3Client2.send(
8574
+ new ListObjectsV2Command({
8575
+ Bucket: cacheBucket,
8576
+ ContinuationToken: continuationToken,
8577
+ MaxKeys: 1e3
8578
+ // Maximum allowed per request
8579
+ })
8580
+ );
8581
+ if (result.Contents && result.Contents.length > 0) {
8582
+ await s3Client2.send(
8583
+ new DeleteObjectsCommand({
8584
+ Bucket: cacheBucket,
8585
+ Delete: {
8586
+ Objects: result.Contents.map((obj) => ({
8587
+ Key: obj.Key
8588
+ })),
8589
+ Quiet: true
8590
+ }
8591
+ })
8592
+ );
8593
+ totalDeleted += result.Contents.length;
8594
+ }
8595
+ continuationToken = result.NextContinuationToken;
8596
+ if (!continuationToken) {
8597
+ break;
8591
8598
  }
8592
8599
  }
8593
- })
8594
- );
8595
- return "Cache has been cleared";
8600
+ await cloudFrontClient.send(
8601
+ new CreateInvalidationCommand2({
8602
+ DistributionId: distributionId,
8603
+ InvalidationBatch: {
8604
+ CallerReference: randomUUID(),
8605
+ Paths: {
8606
+ Quantity: 1,
8607
+ Items: ["/*"]
8608
+ }
8609
+ }
8610
+ })
8611
+ );
8612
+ }
8613
+ });
8614
+ return `${totalDeleted} objects deleted from cache.`;
8596
8615
  });
8597
8616
  });
8598
8617
  };
@@ -8608,6 +8627,7 @@ var image = (program2) => {
8608
8627
  import { CloudFrontClient as CloudFrontClient3, CreateInvalidationCommand as CreateInvalidationCommand3 } from "@aws-sdk/client-cloudfront";
8609
8628
  import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
8610
8629
  import { Cancelled as Cancelled3, log as log24, prompt as prompt11 } from "@awsless/clui";
8630
+ import { randomUUID as randomUUID2 } from "crypto";
8611
8631
  var clearCache2 = (program2) => {
8612
8632
  program2.command("cache-clear").argument("[stack]", "The stack name of the icon proxy").argument("[name]", "The name of the icon proxy").description("Clears the cache of the icon proxy").action(async (stack, name) => {
8613
8633
  await layout("icon cache-clear", async ({ appConfig, stackConfigs }) => {
@@ -8623,7 +8643,7 @@ var clearCache2 = (program2) => {
8623
8643
  return;
8624
8644
  });
8625
8645
  stack = await prompt11.select({
8626
- message: "Select the icon proxy:",
8646
+ message: "Select the stack:",
8627
8647
  options: iconStacks.map((stack2) => ({
8628
8648
  label: stack2.name,
8629
8649
  value: stack2.name
@@ -8637,10 +8657,10 @@ var clearCache2 = (program2) => {
8637
8657
  }
8638
8658
  const names = Object.keys(stackConfig.icons ?? {});
8639
8659
  if (!names) {
8640
- throw new ExpectedError(`No icons are defined in stack "${stack}".`);
8660
+ throw new ExpectedError(`No icon resources are defined in stack "${stack}".`);
8641
8661
  }
8642
8662
  name = await prompt11.select({
8643
- message: "Select the icon:",
8663
+ message: "Select the icon resource:",
8644
8664
  options: names.map((name2) => ({
8645
8665
  label: name2,
8646
8666
  value: name2
@@ -8667,59 +8687,65 @@ var clearCache2 = (program2) => {
8667
8687
  distributionId = await shared.entry("icon", "distribution-id", name);
8668
8688
  cacheBucket = await shared.entry("icon", "cache-bucket", name);
8669
8689
  } catch (_) {
8670
- throw new ExpectedError(`The icon proxy hasn't been deployed yet.`);
8690
+ throw new ExpectedError(`The icon resource hasn't been deployed yet.`);
8671
8691
  }
8672
8692
  const s3Client2 = new S3Client4({
8673
8693
  credentials,
8674
8694
  region
8675
8695
  });
8676
- let continuationToken;
8677
- let totalDeleted = 0;
8678
- let hasMore = true;
8679
- while (hasMore) {
8680
- const result = await s3Client2.send(
8681
- new ListObjectsV2Command2({
8682
- Bucket: cacheBucket,
8683
- ContinuationToken: continuationToken,
8684
- MaxKeys: 1e3
8685
- // Maximum allowed per request
8686
- })
8687
- );
8688
- if (result.Contents && result.Contents.length > 0) {
8689
- await s3Client2.send(
8690
- new DeleteObjectsCommand2({
8691
- Bucket: cacheBucket,
8692
- Delete: {
8693
- Objects: result.Contents.map((obj) => ({
8694
- Key: obj.Key
8695
- })),
8696
- Quiet: true
8697
- }
8698
- })
8699
- );
8700
- totalDeleted += result.Contents.length;
8701
- log24.info(`${result.Contents.length} objects deleted from cache.`);
8702
- }
8703
- continuationToken = result.NextContinuationToken;
8704
- hasMore = !!continuationToken;
8705
- }
8706
8696
  const cloudFrontClient = new CloudFrontClient3({
8707
8697
  credentials,
8708
8698
  region: "us-east-1"
8709
8699
  });
8710
- await cloudFrontClient.send(
8711
- new CreateInvalidationCommand3({
8712
- DistributionId: distributionId,
8713
- InvalidationBatch: {
8714
- CallerReference: `icon-cache-clear-${Date.now()}`,
8715
- Paths: {
8716
- Quantity: 1,
8717
- Items: ["/*"]
8700
+ let totalDeleted = 0;
8701
+ await log24.task({
8702
+ initialMessage: "Clearing cache...",
8703
+ successMessage: "Cache successfully cleared.",
8704
+ task: async () => {
8705
+ let continuationToken;
8706
+ while (true) {
8707
+ const result = await s3Client2.send(
8708
+ new ListObjectsV2Command2({
8709
+ Bucket: cacheBucket,
8710
+ ContinuationToken: continuationToken,
8711
+ MaxKeys: 1e3
8712
+ // Maximum allowed per request
8713
+ })
8714
+ );
8715
+ if (result.Contents && result.Contents.length > 0) {
8716
+ await s3Client2.send(
8717
+ new DeleteObjectsCommand2({
8718
+ Bucket: cacheBucket,
8719
+ Delete: {
8720
+ Objects: result.Contents.map((obj) => ({
8721
+ Key: obj.Key
8722
+ })),
8723
+ Quiet: true
8724
+ }
8725
+ })
8726
+ );
8727
+ totalDeleted += result.Contents.length;
8728
+ }
8729
+ continuationToken = result.NextContinuationToken;
8730
+ if (!continuationToken) {
8731
+ break;
8718
8732
  }
8719
8733
  }
8720
- })
8721
- );
8722
- return "Cache has been cleared";
8734
+ await cloudFrontClient.send(
8735
+ new CreateInvalidationCommand3({
8736
+ DistributionId: distributionId,
8737
+ InvalidationBatch: {
8738
+ CallerReference: randomUUID2(),
8739
+ Paths: {
8740
+ Quantity: 1,
8741
+ Items: ["/*"]
8742
+ }
8743
+ }
8744
+ })
8745
+ );
8746
+ }
8747
+ });
8748
+ return `${totalDeleted} objects deleted from cache.`;
8723
8749
  });
8724
8750
  });
8725
8751
  };
@@ -1090,8 +1090,8 @@ var IconsSchema = z31.record(
1090
1090
  })
1091
1091
  ]).describe(
1092
1092
  "Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
1093
- ),
1094
- version: z31.number().int().min(1).optional().describe("Version of the icon configuration.")
1093
+ )
1094
+ // version: z.number().int().min(1).optional().describe('Version of the icon configuration.'),
1095
1095
  })
1096
1096
  ).optional().describe("Define an icon proxy in your stack. Store, optimize, and deliver icons at scale.");
1097
1097
 
@@ -1 +1 @@
1
- e657f7b86864d8615a7f7439663a94419d048c1f
1
+ 335545401eb807d040031352ed637833c4aba83e
Binary file
Binary file
Binary file