@wraps.dev/cli 2.19.6 → 2.19.8

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/cli.js CHANGED
@@ -7869,6 +7869,7 @@ __export(mail_manager_exports, {
7869
7869
  createMailManagerArchive: () => createMailManagerArchive
7870
7870
  });
7871
7871
  import {
7872
+ ArchiveState,
7872
7873
  CreateArchiveCommand,
7873
7874
  GetArchiveCommand,
7874
7875
  ListArchivesCommand,
@@ -7918,73 +7919,62 @@ function retentionToAWSPeriod2(retention) {
7918
7919
  }
7919
7920
  async function createMailManagerArchive(config2) {
7920
7921
  const region = config2.region;
7921
- const archiveName = `wraps-${config2.name}-archive`;
7922
+ const baseArchiveName = `wraps-${config2.name}-archive`;
7923
+ const namePattern = new RegExp(`^${baseArchiveName}(-\\d+)?$`);
7924
+ const MAX_NAME_ATTEMPTS = 10;
7922
7925
  const mailManagerClient = new MailManagerClient({ region });
7923
7926
  const sesClient = new SESv2Client3({ region });
7924
7927
  const kmsKeyArn = config2.kmsKeyArn;
7925
- if (!kmsKeyArn) {
7926
- }
7927
7928
  const awsRetention = retentionToAWSPeriod2(config2.retention);
7928
7929
  let archiveId;
7929
7930
  let archiveArn;
7930
7931
  try {
7931
- const listCommand = new ListArchivesCommand({});
7932
- const listResult = await mailManagerClient.send(listCommand);
7933
- const existingArchive = listResult.Archives?.find(
7934
- (archive) => archive.ArchiveName === archiveName
7935
- );
7936
- if (existingArchive?.ArchiveId) {
7937
- console.log(`Using existing Mail Manager archive: ${archiveName}`);
7938
- archiveId = existingArchive.ArchiveId;
7939
- const getCommand = new GetArchiveCommand({ ArchiveId: archiveId });
7940
- const getResult = await mailManagerClient.send(getCommand);
7932
+ const listResult = await mailManagerClient.send(new ListArchivesCommand({}));
7933
+ const existing = listResult.Archives?.find(
7934
+ (a) => a.ArchiveState === ArchiveState.ACTIVE && a.ArchiveName !== void 0 && namePattern.test(a.ArchiveName)
7935
+ );
7936
+ if (existing?.ArchiveId) {
7937
+ console.log(`Using existing Mail Manager archive: ${existing.ArchiveName}`);
7938
+ archiveId = existing.ArchiveId;
7939
+ const getResult = await mailManagerClient.send(
7940
+ new GetArchiveCommand({ ArchiveId: archiveId })
7941
+ );
7941
7942
  archiveArn = getResult.ArchiveArn;
7942
7943
  }
7943
7944
  } catch (error) {
7944
7945
  console.log("Error checking for existing archive:", error);
7945
7946
  }
7946
7947
  if (!archiveId) {
7947
- try {
7948
- const createArchiveCommand = new CreateArchiveCommand({
7949
- ArchiveName: archiveName,
7950
- Retention: {
7951
- RetentionPeriod: awsRetention
7952
- },
7953
- ...kmsKeyArn && { KmsKeyArn: kmsKeyArn },
7954
- Tags: [
7955
- { Key: "ManagedBy", Value: "wraps-cli" },
7956
- { Key: "Name", Value: archiveName },
7957
- { Key: "Retention", Value: config2.retention }
7958
- ]
7959
- });
7960
- const archiveResult = await mailManagerClient.send(createArchiveCommand);
7961
- archiveId = archiveResult.ArchiveId;
7962
- if (!archiveId) {
7963
- throw new Error(
7964
- "Failed to create Mail Manager Archive: No ArchiveId returned"
7965
- );
7966
- }
7967
- console.log(`Created new Mail Manager archive: ${archiveName}`);
7968
- } catch (error) {
7969
- if (error instanceof Error && error.name === "ConflictException" && error.message.includes("Archive already exists")) {
7970
- console.log(
7971
- "Archive was created concurrently, fetching existing archive..."
7972
- );
7973
- const listCommand = new ListArchivesCommand({});
7974
- const listResult = await mailManagerClient.send(listCommand);
7975
- const existingArchive = listResult.Archives?.find(
7976
- (archive) => archive.ArchiveName === archiveName
7948
+ for (let attempt = 1; attempt <= MAX_NAME_ATTEMPTS; attempt++) {
7949
+ const archiveName = attempt === 1 ? baseArchiveName : `${baseArchiveName}-${attempt}`;
7950
+ try {
7951
+ const result = await mailManagerClient.send(
7952
+ new CreateArchiveCommand({
7953
+ ArchiveName: archiveName,
7954
+ Retention: { RetentionPeriod: awsRetention },
7955
+ ...kmsKeyArn && { KmsKeyArn: kmsKeyArn },
7956
+ Tags: [
7957
+ { Key: "ManagedBy", Value: "wraps-cli" },
7958
+ { Key: "Name", Value: archiveName },
7959
+ { Key: "Retention", Value: config2.retention }
7960
+ ]
7961
+ })
7977
7962
  );
7978
- if (!existingArchive?.ArchiveId) {
7963
+ archiveId = result.ArchiveId;
7964
+ if (!archiveId) {
7979
7965
  throw new Error(
7980
- `Archive exists but couldn't find it: ${archiveName}`
7966
+ "Failed to create Mail Manager Archive: No ArchiveId returned"
7981
7967
  );
7982
7968
  }
7983
- archiveId = existingArchive.ArchiveId;
7984
- const getCommand = new GetArchiveCommand({ ArchiveId: archiveId });
7985
- const getResult = await mailManagerClient.send(getCommand);
7986
- archiveArn = getResult.ArchiveArn;
7987
- } else {
7969
+ console.log(`Created new Mail Manager archive: ${archiveName}`);
7970
+ break;
7971
+ } catch (error) {
7972
+ if (error instanceof Error && error.name === "ConflictException" && attempt < MAX_NAME_ATTEMPTS) {
7973
+ console.log(
7974
+ `Archive '${archiveName}' is unavailable, trying '${baseArchiveName}-${attempt + 1}'...`
7975
+ );
7976
+ continue;
7977
+ }
7988
7978
  throw error;
7989
7979
  }
7990
7980
  }
@@ -7993,25 +7983,23 @@ async function createMailManagerArchive(config2) {
7993
7983
  const identity = await import("@aws-sdk/client-sts").then(
7994
7984
  (m) => new m.STSClient({ region }).send(new m.GetCallerIdentityCommand({}))
7995
7985
  );
7996
- const accountId = identity.Account;
7997
- archiveArn = `arn:aws:ses:${region}:${accountId}:mailmanager-archive/${archiveId}`;
7986
+ archiveArn = `arn:aws:ses:${region}:${identity.Account}:mailmanager-archive/${archiveId}`;
7998
7987
  }
7999
7988
  const configSetName = await new Promise((resolve) => {
8000
- config2.configSetName.apply((name) => {
8001
- resolve(name);
8002
- });
7989
+ config2.configSetName.apply((name) => resolve(name));
8003
7990
  });
8004
7991
  if (!configSetName) {
8005
7992
  throw new Error(
8006
7993
  "Failed to resolve SES configuration set name from Pulumi output"
8007
7994
  );
8008
7995
  }
8009
- const putArchivingOptionsCommand = new PutConfigurationSetArchivingOptionsCommand({
8010
- ConfigurationSetName: configSetName,
8011
- ArchiveArn: archiveArn
8012
- });
8013
7996
  try {
8014
- await sesClient.send(putArchivingOptionsCommand);
7997
+ await sesClient.send(
7998
+ new PutConfigurationSetArchivingOptionsCommand({
7999
+ ConfigurationSetName: configSetName,
8000
+ ArchiveArn: archiveArn
8001
+ })
8002
+ );
8015
8003
  } catch (error) {
8016
8004
  const detail = error instanceof Error ? error.message : String(error);
8017
8005
  throw new Error(
@@ -8021,11 +8009,7 @@ async function createMailManagerArchive(config2) {
8021
8009
  if (!(archiveId && archiveArn)) {
8022
8010
  throw new Error("Failed to get archive ID or ARN");
8023
8011
  }
8024
- return {
8025
- archiveId,
8026
- archiveArn,
8027
- kmsKeyArn
8028
- };
8012
+ return { archiveId, archiveArn, kmsKeyArn };
8029
8013
  }
8030
8014
  var init_mail_manager = __esm({
8031
8015
  "src/infrastructure/resources/mail-manager.ts"() {
@@ -14609,7 +14593,15 @@ var DOMAIN_BLACKLISTS = [
14609
14593
  { name: "FRESH URI", zone: "fresh.spameatingmonkey.net", priority: "low" },
14610
14594
  { name: "Mailspike Z", zone: "z.mailspike.net", priority: "medium" },
14611
14595
  { name: "SEM Fresh", zone: "fresh.spameatingmonkey.net", priority: "low" },
14612
- { name: "SEM URI", zone: "uribl.spameatingmonkey.net", priority: "medium" }
14596
+ { name: "SEM URI", zone: "uribl.spameatingmonkey.net", priority: "medium" },
14597
+ { name: "0spam Domain", zone: "bl.0spam.org", priority: "medium" },
14598
+ { name: "ZapBL RHSBL", zone: "rhsbl.zapbl.net", priority: "low" },
14599
+ { name: "Swinog URI", zone: "uribl.swinog.ch", priority: "low" },
14600
+ {
14601
+ name: "ScientificSpam RHSBL",
14602
+ zone: "rhsbl.scientificspam.net",
14603
+ priority: "medium"
14604
+ }
14613
14605
  ];
14614
14606
  var IP_BLACKLISTS = [
14615
14607
  // Spamhaus (most important)
@@ -14639,6 +14631,8 @@ var IP_BLACKLISTS = [
14639
14631
  { name: "WPBL", zone: "db.wpbl.info", priority: "medium" },
14640
14632
  { name: "Mailspike BL", zone: "bl.mailspike.net", priority: "medium" },
14641
14633
  { name: "Mailspike Z", zone: "z.mailspike.net", priority: "medium" },
14634
+ { name: "0spam IP", zone: "rbl.0spam.org", priority: "medium" },
14635
+ { name: "ZapBL", zone: "dnsbl.zapbl.net", priority: "medium" },
14642
14636
  // Additional lists
14643
14637
  { name: "JustSpam", zone: "dnsbl.justspam.org", priority: "low" },
14644
14638
  {
@@ -14655,8 +14649,12 @@ var IP_BLACKLISTS = [
14655
14649
  { name: "BlockList.de", zone: "bl.blocklist.de", priority: "medium" },
14656
14650
  { name: "DroneBL", zone: "dnsbl.dronebl.org", priority: "low" },
14657
14651
  { name: "InterServer", zone: "rbl.interserver.net", priority: "low" },
14652
+ { name: "Suomispam", zone: "bl.suomispam.net", priority: "medium" },
14653
+ { name: "ScientificSpam", zone: "bl.scientificspam.net", priority: "medium" },
14654
+ { name: "Swinog IP", zone: "dnsrbl.swinog.ch", priority: "medium" },
14655
+ { name: "Kempt.net", zone: "dnsbl.kempt.net", priority: "low" },
14656
+ { name: "Anonmails", zone: "spam.dnsbl.anonmails.de", priority: "low" },
14658
14657
  // Reputation lists
14659
- { name: "NiX Spam", zone: "ix.dnsbl.manitu.net", priority: "low" },
14660
14658
  { name: "Composite BL", zone: "cbl.anti-spam.org.cn", priority: "low" }
14661
14659
  ];
14662
14660
  var DEFAULT_TIMEOUT2 = 5e3;
@@ -34594,7 +34592,7 @@ async function destroy(options) {
34594
34592
  spinner10.stop("AWS credentials validation failed");
34595
34593
  throw error;
34596
34594
  }
34597
- const region = await getAWSRegion();
34595
+ const region = options.region || await getAWSRegion();
34598
34596
  const metadata = await loadConnectionMetadata(identity.accountId, region);
34599
34597
  const deployedServices = [];
34600
34598
  if (metadata?.services?.email) {
@@ -34664,7 +34662,7 @@ init_pulumi();
34664
34662
  import * as clack43 from "@clack/prompts";
34665
34663
  import * as pulumi26 from "@pulumi/pulumi";
34666
34664
  import pc46 from "picocolors";
34667
- async function status(_options) {
34665
+ async function status(options) {
34668
34666
  await ensurePulumiInstalled();
34669
34667
  const startTime = Date.now();
34670
34668
  const progress = new DeploymentProgress();
@@ -34678,7 +34676,7 @@ async function status(_options) {
34678
34676
  if (!isJsonMode()) {
34679
34677
  progress.info(`AWS Account: ${pc46.cyan(identity.accountId)}`);
34680
34678
  }
34681
- const region = await getAWSRegion();
34679
+ const region = options.region || await getAWSRegion();
34682
34680
  if (!isJsonMode()) {
34683
34681
  progress.info(`Region: ${pc46.cyan(region)}`);
34684
34682
  }
@@ -37256,7 +37254,7 @@ async function smsTest(options) {
37256
37254
  "Validating AWS credentials",
37257
37255
  async () => validateAWSCredentials()
37258
37256
  );
37259
- const region = await getAWSRegion();
37257
+ const region = options.region || await getAWSRegion();
37260
37258
  const metadata = await loadConnectionMetadata(identity.accountId, region);
37261
37259
  if (!metadata?.services?.sms) {
37262
37260
  progress.stop();
@@ -38438,7 +38436,7 @@ async function smsVerifyNumber(options) {
38438
38436
  "Validating AWS credentials",
38439
38437
  async () => validateAWSCredentials()
38440
38438
  );
38441
- const region = await getAWSRegion();
38439
+ const region = options.region || await getAWSRegion();
38442
38440
  const metadata = await loadConnectionMetadata(identity.accountId, region);
38443
38441
  if (!metadata?.services?.sms) {
38444
38442
  progress.stop();
@@ -39582,7 +39580,7 @@ if (!primaryCommand) {
39582
39580
  });
39583
39581
  break;
39584
39582
  case "status":
39585
- await status({ account: flags.account });
39583
+ await status({ account: flags.account, region: flags.region });
39586
39584
  break;
39587
39585
  case "console":
39588
39586
  await dashboard({ port: flags.port, noOpen: flags.noOpen });
@@ -40073,6 +40071,7 @@ Run ${pc59.cyan("wraps --help")} for available commands.
40073
40071
  case "status":
40074
40072
  await smsStatus({
40075
40073
  account: flags.account,
40074
+ region: flags.region,
40076
40075
  json: flags.json
40077
40076
  });
40078
40077
  break;
@@ -40080,6 +40079,7 @@ Run ${pc59.cyan("wraps --help")} for available commands.
40080
40079
  await smsTest({
40081
40080
  to: flags.to,
40082
40081
  message: flags.message,
40082
+ region: flags.region,
40083
40083
  json: flags.json
40084
40084
  });
40085
40085
  break;
@@ -40111,6 +40111,7 @@ Run ${pc59.cyan("wraps --help")} for available commands.
40111
40111
  list: flags.list,
40112
40112
  delete: flags.delete,
40113
40113
  resend: flags.resend,
40114
+ region: flags.region,
40114
40115
  json: flags.json
40115
40116
  });
40116
40117
  break;
@@ -40345,6 +40346,7 @@ Available commands: ${pc59.cyan("setup")}, ${pc59.cyan("doctor")}
40345
40346
  case "status":
40346
40347
  await status({
40347
40348
  account: flags.account,
40349
+ region: flags.region,
40348
40350
  json: flags.json
40349
40351
  });
40350
40352
  break;
@@ -40358,6 +40360,7 @@ Available commands: ${pc59.cyan("setup")}, ${pc59.cyan("doctor")}
40358
40360
  await destroy({
40359
40361
  force: flags.force,
40360
40362
  preview: flags.preview,
40363
+ region: flags.region,
40361
40364
  json: flags.json
40362
40365
  });
40363
40366
  break;