@awsless/awsless 0.0.617 → 0.0.619

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
@@ -333,42 +333,70 @@ var createCloudFrontKvsProvider = ({ credentials, region }) => {
333
333
  };
334
334
 
335
335
  // src/formation/cloudfront.ts
336
- import { CloudFrontClient, CreateInvalidationForDistributionTenantCommand } from "@aws-sdk/client-cloudfront";
336
+ import {
337
+ CloudFrontClient,
338
+ CreateInvalidationForDistributionTenantCommand,
339
+ ListDistributionTenantsCommand
340
+ } from "@aws-sdk/client-cloudfront";
337
341
  import { createCustomProvider as createCustomProvider2, createCustomResourceClass as createCustomResourceClass2 } from "@terraforge/core";
342
+ import { randomUUID } from "crypto";
338
343
  import { z as z2 } from "zod";
339
344
  var Invalidation = createCustomResourceClass2(
340
345
  "cloudfront",
341
346
  "invalidation"
342
347
  );
343
- var createCloudFrontProvider = ({ credentials, region }) => {
344
- const cloudFront = new CloudFrontClient({ credentials, region });
348
+ var createCloudFrontProvider = (props) => {
345
349
  return createCustomProvider2("cloudfront", {
346
350
  invalidation: {
347
- async updateResource(props) {
351
+ async updateResource(input) {
348
352
  const state2 = z2.object({
349
353
  distributionId: z2.string(),
350
354
  paths: z2.string().array().min(1)
351
- }).parse(props.proposedState);
352
- const result = await cloudFront.send(
353
- new CreateInvalidationForDistributionTenantCommand({
354
- Id: state2.distributionId,
355
- InvalidationBatch: {
356
- Paths: {
357
- Quantity: state2.paths.length,
358
- Items: state2.paths
359
- },
360
- CallerReference: props.idempotantToken
361
- }
362
- })
363
- );
364
- return {
365
- ...state2,
366
- id: result.Invalidation?.Id
367
- };
355
+ }).parse(input.proposedState);
356
+ await createInvalidationForDistributionTenants({
357
+ ...props,
358
+ ...state2
359
+ });
360
+ return {};
368
361
  }
369
362
  }
370
363
  });
371
364
  };
365
+ var createInvalidationForDistributionTenants = async ({
366
+ distributionId,
367
+ credentials,
368
+ region,
369
+ paths
370
+ }) => {
371
+ const client = new CloudFrontClient({ credentials, region });
372
+ let cursor;
373
+ do {
374
+ const result = await client.send(
375
+ new ListDistributionTenantsCommand({
376
+ AssociationFilter: {
377
+ DistributionId: distributionId
378
+ },
379
+ MaxItems: 10,
380
+ Marker: cursor
381
+ })
382
+ );
383
+ cursor = result.NextMarker;
384
+ for (const tenant of result.DistributionTenantList ?? []) {
385
+ await client.send(
386
+ new CreateInvalidationForDistributionTenantCommand({
387
+ Id: tenant.Id,
388
+ InvalidationBatch: {
389
+ Paths: {
390
+ Quantity: paths.length,
391
+ Items: paths
392
+ },
393
+ CallerReference: randomUUID()
394
+ }
395
+ })
396
+ );
397
+ }
398
+ } while (cursor);
399
+ };
372
400
 
373
401
  // src/formation/lambda.ts
374
402
  import { LambdaClient, UpdateFunctionCodeCommand } from "@aws-sdk/client-lambda";
@@ -3086,7 +3114,7 @@ import { aws as aws5 } from "@terraforge/aws";
3086
3114
  // src/feature/function/util.ts
3087
3115
  import { generateFileHash } from "@awsless/ts-file-cache";
3088
3116
  import { aws as aws4 } from "@terraforge/aws";
3089
- import { findInputDeps, Group as Group3, Output as Output4, resolveInputs } from "@terraforge/core";
3117
+ import { findInputDeps, Group as Group3, Output as Output3, resolveInputs } from "@terraforge/core";
3090
3118
  import deepmerge from "deepmerge";
3091
3119
  import { basename as basename3 } from "path";
3092
3120
 
@@ -3480,7 +3508,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3480
3508
  const policy = new aws4.iam.RolePolicy(group, "policy", {
3481
3509
  role: role.name,
3482
3510
  name: "lambda-policy",
3483
- policy: new Output4(statementDeps, async (resolve) => {
3511
+ policy: new Output3(statementDeps, async (resolve) => {
3484
3512
  const list3 = await resolveInputs(statements);
3485
3513
  resolve(
3486
3514
  JSON.stringify({
@@ -4567,7 +4595,7 @@ import { fileURLToPath } from "node:url";
4567
4595
  import { days as days6, seconds as seconds6, toDays as toDays5, toSeconds as toSeconds5 } from "@awsless/duration";
4568
4596
  import { mebibytes as mebibytes2, toMebibytes as toMebibytes3 } from "@awsless/size";
4569
4597
  import { aws as aws13 } from "@terraforge/aws";
4570
- import { Output as Output5, findInputDeps as findInputDeps2, resolveInputs as resolveInputs2 } from "@terraforge/core";
4598
+ import { Output as Output4, findInputDeps as findInputDeps2, resolveInputs as resolveInputs2 } from "@terraforge/core";
4571
4599
  import { pascalCase as pascalCase2 } from "change-case";
4572
4600
  var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4573
4601
  let name;
@@ -4635,7 +4663,7 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
4635
4663
  const policy = new aws13.iam.RolePolicy(group, "policy", {
4636
4664
  role: role.name,
4637
4665
  name: "lambda-policy",
4638
- policy: new Output5(statementDeps, async (resolve) => {
4666
+ policy: new Output4(statementDeps, async (resolve) => {
4639
4667
  const list3 = await resolveInputs2(statements);
4640
4668
  resolve(
4641
4669
  JSON.stringify({
@@ -6517,7 +6545,7 @@ import { toDays as toDays8, toSeconds as toSeconds8 } from "@awsless/duration";
6517
6545
  import { toMebibytes as toMebibytes4 } from "@awsless/size";
6518
6546
  import { generateFileHash as generateFileHash2 } from "@awsless/ts-file-cache";
6519
6547
  import { aws as aws26 } from "@terraforge/aws";
6520
- import { Group as Group25, Output as Output7, findInputDeps as findInputDeps3, resolveInputs as resolveInputs3 } from "@terraforge/core";
6548
+ import { Group as Group25, Output as Output6, findInputDeps as findInputDeps3, resolveInputs as resolveInputs3 } from "@terraforge/core";
6521
6549
  import { constantCase as constantCase12, pascalCase as pascalCase3 } from "change-case";
6522
6550
  import deepmerge4 from "deepmerge";
6523
6551
  import { join as join16 } from "path";
@@ -6651,7 +6679,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
6651
6679
  const policy = new aws26.iam.RolePolicy(group, "policy", {
6652
6680
  role: role.name,
6653
6681
  name: "task-policy",
6654
- policy: new Output7(statementDeps, async (resolve) => {
6682
+ policy: new Output6(statementDeps, async (resolve) => {
6655
6683
  const list3 = await resolveInputs3(statements);
6656
6684
  resolve(
6657
6685
  JSON.stringify({
@@ -6715,7 +6743,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
6715
6743
  operatingSystemFamily: "LINUX"
6716
6744
  },
6717
6745
  trackLatest: true,
6718
- containerDefinitions: new Output7(variableDeps, async (resolve) => {
6746
+ containerDefinitions: new Output6(variableDeps, async (resolve) => {
6719
6747
  const data = await resolveInputs3(variables);
6720
6748
  const { s3Bucket, s3Key } = await resolveInputs3({
6721
6749
  s3Bucket: code.bucket,
@@ -10090,10 +10118,8 @@ var parseJsonLog = (message) => {
10090
10118
  };
10091
10119
 
10092
10120
  // src/cli/command/image/clear-cache.ts
10093
- import { CloudFrontClient as CloudFrontClient2, CreateInvalidationForDistributionTenantCommand as CreateInvalidationForDistributionTenantCommand2 } from "@aws-sdk/client-cloudfront";
10094
10121
  import { DeleteObjectsCommand, ListObjectsV2Command, S3Client as S3Client3 } from "@aws-sdk/client-s3";
10095
10122
  import { Cancelled as Cancelled3, log as log28, prompt as prompt14 } from "@awsless/clui";
10096
- import { randomUUID } from "crypto";
10097
10123
  var clearCache = (program2) => {
10098
10124
  program2.command("clear-cache").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) => {
10099
10125
  await layout("image clear-cache", async ({ appConfig, stackConfigs }) => {
@@ -10158,10 +10184,6 @@ var clearCache = (program2) => {
10158
10184
  credentials,
10159
10185
  region
10160
10186
  });
10161
- const cloudFrontClient = new CloudFrontClient2({
10162
- credentials,
10163
- region: "us-east-1"
10164
- });
10165
10187
  let totalDeleted = 0;
10166
10188
  await log28.task({
10167
10189
  initialMessage: "Clearing cache...",
@@ -10196,18 +10218,12 @@ var clearCache = (program2) => {
10196
10218
  break;
10197
10219
  }
10198
10220
  }
10199
- await cloudFrontClient.send(
10200
- new CreateInvalidationForDistributionTenantCommand2({
10201
- Id: distributionId,
10202
- InvalidationBatch: {
10203
- CallerReference: randomUUID(),
10204
- Paths: {
10205
- Quantity: 1,
10206
- Items: [shared.entry("image", "path", name)]
10207
- }
10208
- }
10209
- })
10210
- );
10221
+ await createInvalidationForDistributionTenants({
10222
+ credentials,
10223
+ region,
10224
+ distributionId,
10225
+ paths: [shared.entry("image", "path", name)]
10226
+ });
10211
10227
  }
10212
10228
  });
10213
10229
  return `${totalDeleted} objects deleted from cache.`;
@@ -10223,10 +10239,8 @@ var image = (program2) => {
10223
10239
  };
10224
10240
 
10225
10241
  // src/cli/command/icon/clear-cache.ts
10226
- import { CloudFrontClient as CloudFrontClient3, CreateInvalidationForDistributionTenantCommand as CreateInvalidationForDistributionTenantCommand3 } from "@aws-sdk/client-cloudfront";
10227
10242
  import { DeleteObjectsCommand as DeleteObjectsCommand2, ListObjectsV2Command as ListObjectsV2Command2, S3Client as S3Client4 } from "@aws-sdk/client-s3";
10228
10243
  import { Cancelled as Cancelled4, log as log29, prompt as prompt15 } from "@awsless/clui";
10229
- import { randomUUID as randomUUID2 } from "crypto";
10230
10244
  var clearCache2 = (program2) => {
10231
10245
  program2.command("clear-cache").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) => {
10232
10246
  await layout("icon clear-cache", async ({ appConfig, stackConfigs }) => {
@@ -10291,10 +10305,6 @@ var clearCache2 = (program2) => {
10291
10305
  credentials,
10292
10306
  region
10293
10307
  });
10294
- const cloudFrontClient = new CloudFrontClient3({
10295
- credentials,
10296
- region: "us-east-1"
10297
- });
10298
10308
  let totalDeleted = 0;
10299
10309
  await log29.task({
10300
10310
  initialMessage: "Clearing cache...",
@@ -10329,18 +10339,12 @@ var clearCache2 = (program2) => {
10329
10339
  break;
10330
10340
  }
10331
10341
  }
10332
- await cloudFrontClient.send(
10333
- new CreateInvalidationForDistributionTenantCommand3({
10334
- Id: distributionId,
10335
- InvalidationBatch: {
10336
- CallerReference: randomUUID2(),
10337
- Paths: {
10338
- Quantity: 1,
10339
- Items: [shared.entry("icon", "path", name)]
10340
- }
10341
- }
10342
- })
10343
- );
10342
+ await createInvalidationForDistributionTenants({
10343
+ credentials,
10344
+ region,
10345
+ distributionId,
10346
+ paths: [shared.entry("icon", "path", name)]
10347
+ });
10344
10348
  }
10345
10349
  });
10346
10350
  return `${totalDeleted} objects deleted from cache.`;
Binary file
Binary file
@@ -1 +1 @@
1
- 9737a7bc89cf998c23ff5f3a2173040adfb7443e
1
+ 29e42274e3589b52fe72c8c4bdca163acdcb3a97
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.617",
3
+ "version": "0.0.619",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,23 +33,23 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@awsless/big-float": "^0.1.5",
37
36
  "@awsless/clui": "^0.0.8",
38
- "@awsless/duration": "^0.0.4",
39
- "@awsless/cloudwatch": "^0.0.1",
40
- "@awsless/dynamodb": "^0.3.8",
41
- "@awsless/lambda": "^0.0.35",
37
+ "@awsless/big-float": "^0.1.5",
38
+ "@awsless/dynamodb": "^0.3.11",
42
39
  "@awsless/iot": "^0.0.3",
40
+ "@awsless/duration": "^0.0.4",
43
41
  "@awsless/json": "^0.0.10",
42
+ "@awsless/lambda": "^0.0.35",
44
43
  "@awsless/open-search": "^0.0.21",
45
44
  "@awsless/mqtt": "^0.0.2",
46
- "@awsless/validate": "^0.1.3",
47
- "@awsless/redis": "^0.0.14",
48
45
  "@awsless/s3": "^0.0.21",
49
- "@awsless/sns": "^0.0.10",
46
+ "@awsless/cloudwatch": "^0.0.1",
50
47
  "@awsless/sqs": "^0.0.16",
51
- "@awsless/weak-cache": "^0.0.1",
52
- "@awsless/ssm": "^0.0.7"
48
+ "@awsless/ssm": "^0.0.7",
49
+ "@awsless/redis": "^0.0.14",
50
+ "@awsless/sns": "^0.0.10",
51
+ "@awsless/validate": "^0.1.3",
52
+ "@awsless/weak-cache": "^0.0.1"
53
53
  },
54
54
  "dependencies": {
55
55
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -140,14 +140,14 @@
140
140
  "zod": "^3.24.2",
141
141
  "zod-to-json-schema": "^3.24.3",
142
142
  "@awsless/big-float": "^0.1.5",
143
- "@awsless/cloudwatch": "^0.0.1",
144
143
  "@awsless/duration": "^0.0.4",
145
- "@awsless/graphql": "^0.0.9",
146
- "@awsless/clui": "^0.0.8",
147
144
  "@awsless/json": "^0.0.10",
145
+ "@awsless/graphql": "^0.0.9",
146
+ "@awsless/scheduler": "^0.0.4",
148
147
  "@awsless/size": "^0.0.2",
149
148
  "@awsless/validate": "^0.1.3",
150
- "@awsless/scheduler": "^0.0.4",
149
+ "@awsless/cloudwatch": "^0.0.1",
150
+ "@awsless/clui": "^0.0.8",
151
151
  "@awsless/ts-file-cache": "^0.0.12"
152
152
  },
153
153
  "devDependencies": {