@awsless/awsless 0.0.399 → 0.0.401

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
@@ -278,13 +278,13 @@ var require_directives = __commonJS({
278
278
  * @param onError - May be called even if the action was successful
279
279
  * @returns `true` on success
280
280
  */
281
- add(line, onError) {
281
+ add(line2, onError) {
282
282
  if (this.atNextDocument) {
283
283
  this.yaml = { explicit: _Directives.defaultYaml.explicit, version: "1.1" };
284
284
  this.tags = Object.assign({}, _Directives.defaultTags);
285
285
  this.atNextDocument = false;
286
286
  }
287
- const parts = line.trim().split(/[ \t]+/);
287
+ const parts = line2.trim().split(/[ \t]+/);
288
288
  const name = parts.shift();
289
289
  switch (name) {
290
290
  case "%TAG": {
@@ -1645,7 +1645,7 @@ var require_log = __commonJS({
1645
1645
  var require_addPairToJSMap = __commonJS({
1646
1646
  "../../node_modules/.pnpm/yaml@2.5.0/node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
1647
1647
  "use strict";
1648
- var log11 = require_log();
1648
+ var log12 = require_log();
1649
1649
  var stringify = require_stringify();
1650
1650
  var identity = require_identity();
1651
1651
  var Scalar = require_Scalar();
@@ -1724,7 +1724,7 @@ var require_addPairToJSMap = __commonJS({
1724
1724
  let jsonStr = JSON.stringify(strKey);
1725
1725
  if (jsonStr.length > 40)
1726
1726
  jsonStr = jsonStr.substring(0, 36) + '..."';
1727
- log11.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
1727
+ log12.warn(ctx.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${jsonStr}. Set mapAsMap: true to use object keys.`);
1728
1728
  ctx.mapKeyWarned = true;
1729
1729
  }
1730
1730
  return strKey;
@@ -1823,9 +1823,9 @@ var require_stringifyCollection = __commonJS({
1823
1823
  } else {
1824
1824
  str = lines[0];
1825
1825
  for (let i = 1; i < lines.length; ++i) {
1826
- const line = lines[i];
1827
- str += line ? `
1828
- ${indent}${line}` : "\n";
1826
+ const line2 = lines[i];
1827
+ str += line2 ? `
1828
+ ${indent}${line2}` : "\n";
1829
1829
  }
1830
1830
  }
1831
1831
  if (comment) {
@@ -1892,14 +1892,14 @@ ${indent}${line}` : "\n";
1892
1892
  return start + end;
1893
1893
  } else {
1894
1894
  if (!reqNewline) {
1895
- const len = lines.reduce((sum, line) => sum + line.length + 2, 2);
1895
+ const len = lines.reduce((sum, line2) => sum + line2.length + 2, 2);
1896
1896
  reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
1897
1897
  }
1898
1898
  if (reqNewline) {
1899
1899
  let str = start;
1900
- for (const line of lines)
1901
- str += line ? `
1902
- ${indentStep}${indent}${line}` : "\n";
1900
+ for (const line2 of lines)
1901
+ str += line2 ? `
1902
+ ${indentStep}${indent}${line2}` : "\n";
1903
1903
  return `${str}
1904
1904
  ${indent}${end}`;
1905
1905
  } else {
@@ -3627,10 +3627,10 @@ var require_errors = __commonJS({
3627
3627
  if (error.pos[0] === -1)
3628
3628
  return;
3629
3629
  error.linePos = error.pos.map((pos) => lc.linePos(pos));
3630
- const { line, col } = error.linePos[0];
3631
- error.message += ` at line ${line}, column ${col}`;
3630
+ const { line: line2, col } = error.linePos[0];
3631
+ error.message += ` at line ${line2}, column ${col}`;
3632
3632
  let ci = col - 1;
3633
- let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, "");
3633
+ let lineStr = src.substring(lc.lineStarts[line2 - 1], lc.lineStarts[line2]).replace(/[\n\r]+$/, "");
3634
3634
  if (ci >= 60 && lineStr.length > 80) {
3635
3635
  const trimStart = Math.min(ci - 39, lineStr.length - 79);
3636
3636
  lineStr = "\u2026" + lineStr.substring(trimStart);
@@ -3638,8 +3638,8 @@ var require_errors = __commonJS({
3638
3638
  }
3639
3639
  if (lineStr.length > 80)
3640
3640
  lineStr = lineStr.substring(0, 79) + "\u2026";
3641
- if (line > 1 && /^ *$/.test(lineStr.substring(0, ci))) {
3642
- let prev = src.substring(lc.lineStarts[line - 2], lc.lineStarts[line - 1]);
3641
+ if (line2 > 1 && /^ *$/.test(lineStr.substring(0, ci))) {
3642
+ let prev = src.substring(lc.lineStarts[line2 - 2], lc.lineStarts[line2 - 1]);
3643
3643
  if (prev.length > 80)
3644
3644
  prev = prev.substring(0, 79) + "\u2026\n";
3645
3645
  lineStr = prev + lineStr;
@@ -3647,7 +3647,7 @@ var require_errors = __commonJS({
3647
3647
  if (/[^ ]/.test(lineStr)) {
3648
3648
  let count = 1;
3649
3649
  const end = error.linePos[1];
3650
- if (end && end.line === line && end.col > col) {
3650
+ if (end && end.line === line2 && end.col > col) {
3651
3651
  count = Math.max(1, Math.min(end.col - col, 80 - ci));
3652
3652
  }
3653
3653
  const pointer = " ".repeat(ci) + "^".repeat(count);
@@ -4588,13 +4588,13 @@ var require_resolve_flow_scalar = __commonJS({
4588
4588
  return foldLines(source.slice(1, -1)).replace(/''/g, "'");
4589
4589
  }
4590
4590
  function foldLines(source) {
4591
- let first, line;
4591
+ let first, line2;
4592
4592
  try {
4593
4593
  first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
4594
- line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
4594
+ line2 = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
4595
4595
  } catch (_) {
4596
4596
  first = /(.*?)[ \t]*\r?\n/sy;
4597
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
4597
+ line2 = /[ \t]*(.*?)[ \t]*\r?\n/sy;
4598
4598
  }
4599
4599
  let match = first.exec(source);
4600
4600
  if (!match)
@@ -4602,8 +4602,8 @@ var require_resolve_flow_scalar = __commonJS({
4602
4602
  let res = match[1];
4603
4603
  let sep = " ";
4604
4604
  let pos = first.lastIndex;
4605
- line.lastIndex = pos;
4606
- while (match = line.exec(source)) {
4605
+ line2.lastIndex = pos;
4606
+ while (match = line2.exec(source)) {
4607
4607
  if (match[1] === "") {
4608
4608
  if (sep === "\n")
4609
4609
  res += sep;
@@ -4613,7 +4613,7 @@ var require_resolve_flow_scalar = __commonJS({
4613
4613
  res += sep + match[1];
4614
4614
  sep = " ";
4615
4615
  }
4616
- pos = line.lastIndex;
4616
+ pos = line2.lastIndex;
4617
4617
  }
4618
4618
  const last = /[ \t]*(.*)/sy;
4619
4619
  last.lastIndex = pos;
@@ -5720,40 +5720,40 @@ var require_lexer = __commonJS({
5720
5720
  }
5721
5721
  }
5722
5722
  *parseStream() {
5723
- let line = this.getLine();
5724
- if (line === null)
5723
+ let line2 = this.getLine();
5724
+ if (line2 === null)
5725
5725
  return this.setNext("stream");
5726
- if (line[0] === cst.BOM) {
5726
+ if (line2[0] === cst.BOM) {
5727
5727
  yield* this.pushCount(1);
5728
- line = line.substring(1);
5728
+ line2 = line2.substring(1);
5729
5729
  }
5730
- if (line[0] === "%") {
5731
- let dirEnd = line.length;
5732
- let cs = line.indexOf("#");
5730
+ if (line2[0] === "%") {
5731
+ let dirEnd = line2.length;
5732
+ let cs = line2.indexOf("#");
5733
5733
  while (cs !== -1) {
5734
- const ch = line[cs - 1];
5734
+ const ch = line2[cs - 1];
5735
5735
  if (ch === " " || ch === " ") {
5736
5736
  dirEnd = cs - 1;
5737
5737
  break;
5738
5738
  } else {
5739
- cs = line.indexOf("#", cs + 1);
5739
+ cs = line2.indexOf("#", cs + 1);
5740
5740
  }
5741
5741
  }
5742
5742
  while (true) {
5743
- const ch = line[dirEnd - 1];
5743
+ const ch = line2[dirEnd - 1];
5744
5744
  if (ch === " " || ch === " ")
5745
5745
  dirEnd -= 1;
5746
5746
  else
5747
5747
  break;
5748
5748
  }
5749
5749
  const n = (yield* this.pushCount(dirEnd)) + (yield* this.pushSpaces(true));
5750
- yield* this.pushCount(line.length - n);
5750
+ yield* this.pushCount(line2.length - n);
5751
5751
  this.pushNewline();
5752
5752
  return "stream";
5753
5753
  }
5754
5754
  if (this.atLineEnd()) {
5755
5755
  const sp = yield* this.pushSpaces(true);
5756
- yield* this.pushCount(line.length - sp);
5756
+ yield* this.pushCount(line2.length - sp);
5757
5757
  yield* this.pushNewline();
5758
5758
  return "stream";
5759
5759
  }
@@ -5794,13 +5794,13 @@ var require_lexer = __commonJS({
5794
5794
  }
5795
5795
  *parseDocument() {
5796
5796
  yield* this.pushSpaces(true);
5797
- const line = this.getLine();
5798
- if (line === null)
5797
+ const line2 = this.getLine();
5798
+ if (line2 === null)
5799
5799
  return this.setNext("doc");
5800
5800
  let n = yield* this.pushIndicators();
5801
- switch (line[n]) {
5801
+ switch (line2[n]) {
5802
5802
  case "#":
5803
- yield* this.pushCount(line.length - n);
5803
+ yield* this.pushCount(line2.length - n);
5804
5804
  // fallthrough
5805
5805
  case void 0:
5806
5806
  yield* this.pushNewline();
@@ -5825,7 +5825,7 @@ var require_lexer = __commonJS({
5825
5825
  case ">":
5826
5826
  n += yield* this.parseBlockScalarHeader();
5827
5827
  n += yield* this.pushSpaces(true);
5828
- yield* this.pushCount(line.length - n);
5828
+ yield* this.pushCount(line2.length - n);
5829
5829
  yield* this.pushNewline();
5830
5830
  return yield* this.parseBlockScalar();
5831
5831
  default:
@@ -5845,11 +5845,11 @@ var require_lexer = __commonJS({
5845
5845
  }
5846
5846
  sp += yield* this.pushSpaces(true);
5847
5847
  } while (nl + sp > 0);
5848
- const line = this.getLine();
5849
- if (line === null)
5848
+ const line2 = this.getLine();
5849
+ if (line2 === null)
5850
5850
  return this.setNext("flow");
5851
- if (indent !== -1 && indent < this.indentNext && line[0] !== "#" || indent === 0 && (line.startsWith("---") || line.startsWith("...")) && isEmpty(line[3])) {
5852
- const atFlowEndMarker = indent === this.indentNext - 1 && this.flowLevel === 1 && (line[0] === "]" || line[0] === "}");
5851
+ if (indent !== -1 && indent < this.indentNext && line2[0] !== "#" || indent === 0 && (line2.startsWith("---") || line2.startsWith("...")) && isEmpty(line2[3])) {
5852
+ const atFlowEndMarker = indent === this.indentNext - 1 && this.flowLevel === 1 && (line2[0] === "]" || line2[0] === "}");
5853
5853
  if (!atFlowEndMarker) {
5854
5854
  this.flowLevel = 0;
5855
5855
  yield cst.FLOW_END;
@@ -5857,17 +5857,17 @@ var require_lexer = __commonJS({
5857
5857
  }
5858
5858
  }
5859
5859
  let n = 0;
5860
- while (line[n] === ",") {
5860
+ while (line2[n] === ",") {
5861
5861
  n += yield* this.pushCount(1);
5862
5862
  n += yield* this.pushSpaces(true);
5863
5863
  this.flowKey = false;
5864
5864
  }
5865
5865
  n += yield* this.pushIndicators();
5866
- switch (line[n]) {
5866
+ switch (line2[n]) {
5867
5867
  case void 0:
5868
5868
  return "flow";
5869
5869
  case "#":
5870
- yield* this.pushCount(line.length - n);
5870
+ yield* this.pushCount(line2.length - n);
5871
5871
  return "flow";
5872
5872
  case "{":
5873
5873
  case "[":
@@ -7058,7 +7058,7 @@ var require_public_api = __commonJS({
7058
7058
  var composer = require_composer();
7059
7059
  var Document = require_Document();
7060
7060
  var errors = require_errors();
7061
- var log11 = require_log();
7061
+ var log12 = require_log();
7062
7062
  var lineCounter = require_line_counter();
7063
7063
  var parser = require_parser();
7064
7064
  function parseOptions(options) {
@@ -7109,7 +7109,7 @@ var require_public_api = __commonJS({
7109
7109
  const doc = parseDocument(src, options);
7110
7110
  if (!doc)
7111
7111
  return null;
7112
- doc.warnings.forEach((warning) => log11.warn(doc.options.logLevel, warning));
7112
+ doc.warnings.forEach((warning) => log12.warn(doc.options.logLevel, warning));
7113
7113
  if (doc.errors.length > 0) {
7114
7114
  if (doc.options.logLevel !== "silent")
7115
7115
  throw doc.errors[0];
@@ -7408,9 +7408,12 @@ var list = (data) => {
7408
7408
  const padName = padText(Object.keys(data));
7409
7409
  return Object.entries(data).map(([name, value]) => [color.label(padName(name + ":", 2)), value].join("")).join(char.br);
7410
7410
  };
7411
+ var line = (message) => {
7412
+ console.log(color.line("\u2502 "), message);
7413
+ };
7411
7414
  var table = (props) => {
7412
7415
  console.log(color.line("\u2502"));
7413
- const table2 = new Table({
7416
+ const table3 = new Table({
7414
7417
  // wordWrap: true,
7415
7418
  // wrapOnWordBoundary: false,
7416
7419
  // truncate: '...',
@@ -7433,7 +7436,7 @@ var table = (props) => {
7433
7436
  // 'right-mid': '',
7434
7437
  }
7435
7438
  });
7436
- table2.push(
7439
+ table3.push(
7437
7440
  ...props.body.map(
7438
7441
  (row) => row.map((v) => {
7439
7442
  if (typeof v === "boolean") {
@@ -7443,7 +7446,7 @@ var table = (props) => {
7443
7446
  })
7444
7447
  )
7445
7448
  );
7446
- return table2.toString();
7449
+ return table3.toString();
7447
7450
  };
7448
7451
 
7449
7452
  // src/cli/ui/complex/bootstrap-awsless.ts
@@ -7509,12 +7512,12 @@ var createStateBucket = (client, accountId) => {
7509
7512
  var bootstrapAwsless = async (props) => {
7510
7513
  const dynamo = new DynamoDB(props);
7511
7514
  const s3 = new S3Client(props);
7512
- const [table2, bucket] = await Promise.all([
7515
+ const [table3, bucket] = await Promise.all([
7513
7516
  //
7514
7517
  hasLockTable(dynamo),
7515
7518
  hasStateBucket(s3, props.accountId)
7516
7519
  ]);
7517
- if (!table2 || !bucket) {
7520
+ if (!table3 || !bucket) {
7518
7521
  log.warn(`Awsless hasn't been bootstrapped yet.`);
7519
7522
  if (!process.env.SKIP_PROMPT) {
7520
7523
  const confirmed = await confirm({
@@ -7525,7 +7528,7 @@ var bootstrapAwsless = async (props) => {
7525
7528
  }
7526
7529
  }
7527
7530
  await task("Bootstrapping", async (update) => {
7528
- if (!table2) {
7531
+ if (!table3) {
7529
7532
  await createLockTable(dynamo);
7530
7533
  }
7531
7534
  if (!bucket) {
@@ -8021,19 +8024,22 @@ var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub
8021
8024
  var PubSubDefaultSchema = z14.record(
8022
8025
  ResourceIdSchema,
8023
8026
  z14.object({
8027
+ auth: FunctionSchema,
8024
8028
  domain: DomainSchema.optional(),
8025
- subDomain: z14.string().optional(),
8026
- auth: z14.union([
8027
- ResourceIdSchema,
8028
- z14.object({
8029
- authorizer: FunctionSchema
8030
- // ttl: AuthorizerTtl.default('1 hour'),
8031
- })
8032
- ]),
8033
- policy: z14.object({
8034
- publish: z14.array(z14.string()).optional(),
8035
- subscribe: z14.array(z14.string()).optional()
8036
- }).optional()
8029
+ subDomain: z14.string().optional()
8030
+ // auth: z.union([
8031
+ // ResourceIdSchema,
8032
+ // z.object({
8033
+ // authorizer: FunctionSchema,
8034
+ // // ttl: AuthorizerTtl.default('1 hour'),
8035
+ // }),
8036
+ // ]),
8037
+ // policy: z
8038
+ // .object({
8039
+ // publish: z.array(z.string()).optional(),
8040
+ // subscribe: z.array(z.string()).optional(),
8041
+ // })
8042
+ // .optional(),
8037
8043
  })
8038
8044
  ).optional().describe("Define the pubsub subscriber in your stack.");
8039
8045
  var PubSubSchema = z14.record(
@@ -12273,10 +12279,7 @@ var pubsubFeature = defineFeature({
12273
12279
  onApp(ctx) {
12274
12280
  for (const [id, props] of Object.entries(ctx.appConfig.defaults.pubsub ?? {})) {
12275
12281
  const group = new Node12(ctx.base, "pubsub", id);
12276
- const functionProps = typeof props.auth === "string" ? { file: "" } : props.auth.authorizer;
12277
- const { lambda } = createLambdaFunction(group, ctx, "pubsub-authorizer", id, functionProps);
12278
- lambda.addEnvironment("PUBSUB_POLICY", JSON.stringify(props.policy));
12279
- lambda.addEnvironment("AWS_ACCOUNT_ID", ctx.accountId);
12282
+ const { lambda } = createLambdaFunction(group, ctx, "pubsub-authorizer", id, props.auth);
12280
12283
  const name = formatGlobalResourceName({
12281
12284
  appName: ctx.app.name,
12282
12285
  resourceType: "pubsub",
@@ -12321,7 +12324,11 @@ var pubsubFeature = defineFeature({
12321
12324
  ctx.onGlobalPolicy((policy) => {
12322
12325
  policy.addStatement({
12323
12326
  actions: [`iot:Publish`],
12324
- resources: [`arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`]
12327
+ resources: [
12328
+ //
12329
+ `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`,
12330
+ `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/${ctx.app.name}/pubsub/*`
12331
+ ]
12325
12332
  // resources: [`arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/${ctx.app.name}/*`],
12326
12333
  });
12327
12334
  });
@@ -13370,14 +13377,14 @@ var tableFeature = defineFeature({
13370
13377
  resourceName: id
13371
13378
  });
13372
13379
  const deletionProtection = props.deletionProtection ?? ctx.appConfig.defaults.table?.deletionProtection;
13373
- const table2 = new aws22.dynamodb.Table(group, "table", {
13380
+ const table3 = new aws22.dynamodb.Table(group, "table", {
13374
13381
  ...props,
13375
13382
  name,
13376
13383
  stream: props.stream?.type,
13377
13384
  deletionProtection
13378
13385
  });
13379
13386
  if (deletionProtection) {
13380
- table2.deletionPolicy = "retain";
13387
+ table3.deletionPolicy = "retain";
13381
13388
  }
13382
13389
  if (props.stream) {
13383
13390
  const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
@@ -13385,7 +13392,7 @@ var tableFeature = defineFeature({
13385
13392
  const onFailure = getGlobalOnFailure(ctx);
13386
13393
  const source = new aws22.lambda.EventSourceMapping(group, id, {
13387
13394
  functionArn: lambda.arn,
13388
- sourceArn: table2.streamArn,
13395
+ sourceArn: table3.streamArn,
13389
13396
  batchSize: 100,
13390
13397
  bisectBatchOnError: true,
13391
13398
  // retryAttempts: props.stream.consumer.retryAttempts ?? -1,
@@ -13393,7 +13400,7 @@ var tableFeature = defineFeature({
13393
13400
  startingPosition: "latest",
13394
13401
  onFailure
13395
13402
  });
13396
- policy.addStatement(table2.streamPermissions);
13403
+ policy.addStatement(table3.streamPermissions);
13397
13404
  source.dependsOn(policy);
13398
13405
  if (onFailure) {
13399
13406
  policy.addStatement({
@@ -13403,7 +13410,7 @@ var tableFeature = defineFeature({
13403
13410
  }
13404
13411
  }
13405
13412
  ctx.onStackPolicy((policy) => {
13406
- policy.addStatement(...table2.permissions);
13413
+ policy.addStatement(...table3.permissions);
13407
13414
  });
13408
13415
  }
13409
13416
  }
@@ -13652,12 +13659,12 @@ var vpcFeature = defineFeature({
13652
13659
  const zones = ["a", "b"];
13653
13660
  const tables = [privateRouteTable, publicRouteTable];
13654
13661
  let block = 0n;
13655
- for (const table2 of tables) {
13662
+ for (const table3 of tables) {
13656
13663
  for (const i in zones) {
13657
13664
  const index = Number(i) + 1;
13658
- const id = `${table2.identifier}-${index}`;
13665
+ const id = `${table3.identifier}-${index}`;
13659
13666
  const subnet = new aws24.ec2.Subnet(group, id, {
13660
- name: `${ctx.app.name}--${table2.identifier}-${index}`,
13667
+ name: `${ctx.app.name}--${table3.identifier}-${index}`,
13661
13668
  vpcId: vpc.id,
13662
13669
  cidrBlock: aws24.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
13663
13670
  // ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
@@ -13666,14 +13673,14 @@ var vpcFeature = defineFeature({
13666
13673
  // ipv6CidrBlock: slices.apply(list => aws.ec2.Peer.ipv6(list.get(block++).toString())),
13667
13674
  // assignIpv6AddressOnCreation: true,
13668
13675
  // ipv6Native: true,
13669
- mapPublicIpOnLaunch: table2.identifier === "public",
13676
+ mapPublicIpOnLaunch: table3.identifier === "public",
13670
13677
  availabilityZone: ctx.appConfig.region + zones[i]
13671
13678
  });
13672
13679
  new aws24.ec2.SubnetRouteTableAssociation(group, id, {
13673
- routeTableId: table2.id,
13680
+ routeTableId: table3.id,
13674
13681
  subnetId: subnet.id
13675
13682
  });
13676
- ctx.shared.set(`vpc-${table2.identifier}-subnet-id-${index}`, subnet.id);
13683
+ ctx.shared.set(`vpc-${table3.identifier}-subnet-id-${index}`, subnet.id);
13677
13684
  }
13678
13685
  }
13679
13686
  }
@@ -14594,8 +14601,8 @@ var CustomReporter = class {
14594
14601
  this.cache = cache;
14595
14602
  }
14596
14603
  }
14597
- onUserConsoleLog(log11) {
14598
- this.logs.push(log11.content.trimEnd());
14604
+ onUserConsoleLog(log12) {
14605
+ this.logs.push(log12.content.trimEnd());
14599
14606
  }
14600
14607
  runningTask(tasks) {
14601
14608
  return tasks.find((t) => t.result?.state === "run");
@@ -14675,24 +14682,24 @@ var startTest = async (props) => {
14675
14682
 
14676
14683
  // src/cli/ui/complex/run-tests.ts
14677
14684
  var formatResult = (props) => {
14678
- const line = [`Test ${chalk6.magenta(props.stack)}`];
14685
+ const line2 = [`Test ${chalk6.magenta(props.stack)}`];
14679
14686
  if (props.cached) {
14680
- line.push(color.warning(`(from cache)`));
14687
+ line2.push(color.warning(`(from cache)`));
14681
14688
  }
14682
14689
  if (props.event.passed > 0) {
14683
- line.push(color.success(`${props.event.passed} passed`));
14690
+ line2.push(color.success(`${props.event.passed} passed`));
14684
14691
  }
14685
14692
  if (props.event.failed > 0) {
14686
- line.push(color.error(`${props.event.failed} failed`));
14693
+ line2.push(color.error(`${props.event.failed} failed`));
14687
14694
  }
14688
- return line.join(` `);
14695
+ return line2.join(` `);
14689
14696
  };
14690
14697
  var logTestLogs = (event) => {
14691
14698
  if (event.logs.length > 0) {
14692
14699
  log8.message(color.info.bold.inverse(" LOGS "), {
14693
14700
  symbol: color.dim(icon.dot)
14694
14701
  });
14695
- log8.message(event.logs.map((log11) => wrap(log11, { hard: true })).join("\n"));
14702
+ log8.message(event.logs.map((log12) => wrap(log12, { hard: true })).join("\n"));
14696
14703
  }
14697
14704
  };
14698
14705
  var logTestErrors = (event) => {
@@ -15095,9 +15102,10 @@ var dev = (program2) => {
15095
15102
  };
15096
15103
 
15097
15104
  // src/cli/command/resource/list.ts
15105
+ import { log as log11 } from "@clack/prompts";
15098
15106
  import chalk7 from "chalk";
15099
15107
  var list3 = (program2) => {
15100
- program2.command("list").description(`List all defined resources`).action(async () => {
15108
+ program2.command("list").argument("[stacks...]", "Optionally filter stack resources to list").description(`List all defined resources`).action(async (filters) => {
15101
15109
  await layout("resource list", async ({ appConfig, stackConfigs }) => {
15102
15110
  const region = appConfig.region;
15103
15111
  const credentials = getCredentials(appConfig.profile);
@@ -15110,21 +15118,15 @@ var list3 = (program2) => {
15110
15118
  }).replaceAll(":", color.dim(":"));
15111
15119
  };
15112
15120
  for (const stack of app.stacks) {
15121
+ if (filters.length > 0 && !filters.includes(stack.name)) {
15122
+ continue;
15123
+ }
15124
+ log11.step(chalk7.magenta(stack.name));
15125
+ line("");
15113
15126
  for (const resource2 of stack.resources) {
15114
- resources.push([
15115
- chalk7.magenta(stack.name),
15116
- // resource.type,
15117
- formatResource(stack, resource2.urn)
15118
- ]);
15119
- }
15120
- }
15121
- console.log(
15122
- table({
15123
- // colWidths,
15124
- head: ["stack", "urn"],
15125
- body: resources
15126
- })
15127
- );
15127
+ line(formatResource(stack, resource2.urn));
15128
+ }
15129
+ }
15128
15130
  });
15129
15131
  });
15130
15132
  };
@@ -566,19 +566,22 @@ var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub
566
566
  var PubSubDefaultSchema = z17.record(
567
567
  ResourceIdSchema,
568
568
  z17.object({
569
+ auth: FunctionSchema,
569
570
  domain: DomainSchema.optional(),
570
- subDomain: z17.string().optional(),
571
- auth: z17.union([
572
- ResourceIdSchema,
573
- z17.object({
574
- authorizer: FunctionSchema
575
- // ttl: AuthorizerTtl.default('1 hour'),
576
- })
577
- ]),
578
- policy: z17.object({
579
- publish: z17.array(z17.string()).optional(),
580
- subscribe: z17.array(z17.string()).optional()
581
- }).optional()
571
+ subDomain: z17.string().optional()
572
+ // auth: z.union([
573
+ // ResourceIdSchema,
574
+ // z.object({
575
+ // authorizer: FunctionSchema,
576
+ // // ttl: AuthorizerTtl.default('1 hour'),
577
+ // }),
578
+ // ]),
579
+ // policy: z
580
+ // .object({
581
+ // publish: z.array(z.string()).optional(),
582
+ // subscribe: z.array(z.string()).optional(),
583
+ // })
584
+ // .optional(),
582
585
  })
583
586
  ).optional().describe("Define the pubsub subscriber in your stack.");
584
587
  var PubSubSchema = z17.record(
package/dist/client.d.ts CHANGED
@@ -56,9 +56,10 @@ declare const createHttpClient: <S extends Schema>(fetcher: HttpFetcher) => {
56
56
 
57
57
  type MessageCallback = (payload: any) => void;
58
58
  type ClientProps = {
59
+ app: string;
59
60
  endpoint: string;
60
61
  authorizer: string;
61
- token: string;
62
+ token?: string;
62
63
  };
63
64
  type ClientPropsProvider = () => Promise<ClientProps> | ClientProps;
64
65
  declare const createPubSubClient: (props: ClientProps | ClientPropsProvider) => {
package/dist/client.js CHANGED
@@ -81,21 +81,26 @@ var createHttpClient = (fetcher) => {
81
81
  // src/lib/client/pubsub.ts
82
82
  import { createClient } from "@awsless/mqtt";
83
83
  var createPubSubClient = (props) => {
84
+ let app;
84
85
  const mqtt = createClient(async () => {
85
86
  const config = typeof props === "function" ? await props() : props;
87
+ app = config.app;
86
88
  return {
87
89
  endpoint: `wss://${config.endpoint}/mqtt`,
88
90
  username: `?x-amz-customauthorizer-name=${config.authorizer}`,
89
91
  password: config.token
90
92
  };
91
93
  });
94
+ const getPubSubTopic = (name) => {
95
+ return `${app}/pubsub/${name}`;
96
+ };
92
97
  return {
93
98
  ...mqtt,
94
99
  publish(topic, event, payload, qos) {
95
- return mqtt.publish(topic, JSON.stringify([event, payload]), qos);
100
+ return mqtt.publish(getPubSubTopic(topic), JSON.stringify([event, payload]), qos);
96
101
  },
97
102
  subscribe(topic, event, callback) {
98
- return mqtt.subscribe(topic, (message) => {
103
+ return mqtt.subscribe(getPubSubTopic(topic), (message) => {
99
104
  const [eventName, payload] = JSON.parse(message.toString("utf8"));
100
105
  if (event === eventName) {
101
106
  callback(payload);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.399",
3
+ "version": "0.0.401",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,17 +28,17 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/lambda": "^0.0.27",
32
- "@awsless/mqtt": "^0.0.2",
33
31
  "@awsless/iot": "^0.0.2",
32
+ "@awsless/lambda": "^0.0.27",
34
33
  "@awsless/redis": "^0.0.13",
35
- "@awsless/validate": "^0.0.16",
36
- "@awsless/open-search": "^0.0.15",
37
- "@awsless/weak-cache": "^0.0.1",
34
+ "@awsless/mqtt": "^0.0.2",
38
35
  "@awsless/s3": "^0.0.18",
36
+ "@awsless/sns": "^0.0.7",
39
37
  "@awsless/sqs": "^0.0.7",
40
38
  "@awsless/ssm": "^0.0.7",
41
- "@awsless/sns": "^0.0.7"
39
+ "@awsless/open-search": "^0.0.15",
40
+ "@awsless/validate": "^0.0.16",
41
+ "@awsless/weak-cache": "^0.0.1"
42
42
  },
43
43
  "dependencies": {
44
44
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -112,12 +112,12 @@
112
112
  "zip-a-folder": "^3.1.6",
113
113
  "zod": "^3.21.4",
114
114
  "zod-to-json-schema": "^3.22.3",
115
+ "@awsless/code": "^0.0.10",
115
116
  "@awsless/duration": "^0.0.1",
116
117
  "@awsless/formation": "^0.0.57",
117
118
  "@awsless/size": "^0.0.1",
118
- "@awsless/validate": "^0.0.16",
119
119
  "@awsless/ts-file-cache": "^0.0.10",
120
- "@awsless/code": "^0.0.10",
120
+ "@awsless/validate": "^0.0.16",
121
121
  "@awsless/graphql": "^0.0.9"
122
122
  },
123
123
  "devDependencies": {