@go-to-k/cdkd 0.161.1 → 0.161.2

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
@@ -43106,9 +43106,14 @@ function substituteAgainstState(value, contextOrResources) {
43106
43106
  if (intrinsic === "Fn::GetAtt") return resolveGetAtt(arg, context);
43107
43107
  if (intrinsic === "Fn::Sub") return resolveSub(arg, context);
43108
43108
  if (intrinsic === "Fn::Join") return resolveJoin(arg, context);
43109
+ if (intrinsic === "Fn::Select") return resolveSelect(arg, context);
43110
+ if (intrinsic === "Fn::Split") return {
43111
+ kind: "unresolved",
43112
+ reason: `Fn::Split returns an array, which is not a valid env-var value (use Fn::Select to pick one element)`
43113
+ };
43109
43114
  return {
43110
43115
  kind: "unresolved",
43111
- reason: `unsupported intrinsic '${intrinsic}' (supported: Ref, Fn::GetAtt, Fn::Sub, Fn::Join)`
43116
+ reason: `unsupported intrinsic '${intrinsic}' (supported: Ref, Fn::GetAtt, Fn::Sub, Fn::Join, Fn::Select, Fn::Split)`
43112
43117
  };
43113
43118
  }
43114
43119
  function isContext(v) {
@@ -43322,6 +43327,121 @@ function resolveJoin(arg, context) {
43322
43327
  };
43323
43328
  }
43324
43329
  /**
43330
+ * `Fn::Select: [<index>, <list>]` — pick the indexed element of an
43331
+ * array. Mirrors the semantics of `resolveImageIntrinsic`'s `Fn::Select`
43332
+ * branch in `src/local/intrinsic-image.ts` so the two resolvers behave
43333
+ * the same way for the same template shape.
43334
+ *
43335
+ * - Index may be a number (`0`) OR a numeric string (`'0'`) — CFn
43336
+ * templates often carry the string form after a JSON round-trip.
43337
+ * - List may be a resolved-array intrinsic (today only `Fn::Split`
43338
+ * produces a `string[]`) OR a literal `[...]` array of intrinsics
43339
+ * resolved on the fly.
43340
+ * - Out-of-bounds / negative / non-finite index reports unresolved.
43341
+ */
43342
+ function resolveSelect(arg, context) {
43343
+ if (!Array.isArray(arg) || arg.length !== 2) return {
43344
+ kind: "unresolved",
43345
+ reason: `Fn::Select expects [index, list], got ${Array.isArray(arg) ? `array of length ${arg.length}` : typeof arg}`
43346
+ };
43347
+ const [rawIndex, listArg] = arg;
43348
+ let index;
43349
+ if (typeof rawIndex === "number") index = rawIndex;
43350
+ else if (typeof rawIndex === "string" && /^-?\d+$/.test(rawIndex)) index = Number.parseInt(rawIndex, 10);
43351
+ if (index === void 0 || !Number.isFinite(index)) return {
43352
+ kind: "unresolved",
43353
+ reason: `Fn::Select index must be a finite number (or numeric string), got ${typeof rawIndex}`
43354
+ };
43355
+ if (index < 0) return {
43356
+ kind: "unresolved",
43357
+ reason: `Fn::Select index must be non-negative, got ${index}`
43358
+ };
43359
+ const list = resolveAny(listArg, context);
43360
+ if (list.kind === "unresolved") return {
43361
+ kind: "unresolved",
43362
+ reason: `Fn::Select list: ${list.reason}`
43363
+ };
43364
+ if (Array.isArray(list.value)) {
43365
+ if (index >= list.value.length) return {
43366
+ kind: "unresolved",
43367
+ reason: `Fn::Select index ${index} out of bounds (list length ${list.value.length})`
43368
+ };
43369
+ return {
43370
+ kind: "literal",
43371
+ value: list.value[index]
43372
+ };
43373
+ }
43374
+ return {
43375
+ kind: "unresolved",
43376
+ reason: `Fn::Select list must resolve to an array, got ${typeof list.value}`
43377
+ };
43378
+ }
43379
+ /**
43380
+ * `Fn::Split: [<delimiter>, <string>]` — split a string into a
43381
+ * `string[]`. Only callable through `resolveAny` (i.e. inside
43382
+ * `Fn::Select`); the top-level dispatcher rejects bare `Fn::Split`
43383
+ * since an array cannot be an env-var value.
43384
+ *
43385
+ * The string argument can itself be an intrinsic (typical CDK shape:
43386
+ * `Fn::Split: [':', { 'Fn::GetAtt': [<Secret>, 'SecretArn'] }]`); it's
43387
+ * resolved through `substituteAgainstState` so we don't accidentally
43388
+ * admit nested-array shapes there.
43389
+ */
43390
+ function resolveSplitAsArray(arg, context) {
43391
+ if (!Array.isArray(arg) || arg.length !== 2) return {
43392
+ kind: "unresolved",
43393
+ reason: `Fn::Split expects [delimiter, string], got ${Array.isArray(arg) ? `array of length ${arg.length}` : typeof arg}`
43394
+ };
43395
+ const [delim, src] = arg;
43396
+ if (typeof delim !== "string") return {
43397
+ kind: "unresolved",
43398
+ reason: `Fn::Split delimiter must be a string, got ${typeof delim}`
43399
+ };
43400
+ const sub = substituteAgainstState(src, context);
43401
+ if (sub.kind !== "literal") return {
43402
+ kind: "unresolved",
43403
+ reason: `Fn::Split string argument: ${sub.reason}`
43404
+ };
43405
+ if (typeof sub.value !== "string") return {
43406
+ kind: "unresolved",
43407
+ reason: `Fn::Split string argument must resolve to a string, got ${typeof sub.value}`
43408
+ };
43409
+ return {
43410
+ kind: "literal",
43411
+ value: sub.value.split(delim)
43412
+ };
43413
+ }
43414
+ /**
43415
+ * Array-tolerant resolver used by `Fn::Select`'s `list` argument.
43416
+ * Returns either the scalar `StateSubstitutionResult` shape (delegating
43417
+ * to `substituteAgainstState`) OR a `{kind: 'literal', value: string[]}`
43418
+ * when the node is `Fn::Split` / a literal array of intrinsics.
43419
+ *
43420
+ * Top-level `substituteAgainstState` deliberately doesn't go through
43421
+ * this helper — env-var values can't be arrays, and the asymmetry
43422
+ * matches `intrinsic-image.ts`'s `resolveImageIntrinsic` (scalar) vs
43423
+ * `resolveImageIntrinsicAny` (scalar OR array) split.
43424
+ */
43425
+ function resolveAny(value, context) {
43426
+ if (Array.isArray(value)) {
43427
+ const out = [];
43428
+ for (let i = 0; i < value.length; i += 1) {
43429
+ const sub = substituteAgainstState(value[i], context);
43430
+ if (sub.kind !== "literal") return {
43431
+ kind: "unresolved",
43432
+ reason: `list element [${i}]: ${sub.reason}`
43433
+ };
43434
+ out.push(String(sub.value));
43435
+ }
43436
+ return {
43437
+ kind: "literal",
43438
+ value: out
43439
+ };
43440
+ }
43441
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 1 && Object.prototype.hasOwnProperty.call(value, "Fn::Split")) return resolveSplitAsArray(value["Fn::Split"], context);
43442
+ return substituteAgainstState(value, context);
43443
+ }
43444
+ /**
43325
43445
  * Async sibling of {@link substituteAgainstState}. Same semantics for every
43326
43446
  * intrinsic the sync path supports; additionally consults the
43327
43447
  * `crossStackResolver` (when supplied on the context) for `Fn::ImportValue`
@@ -43351,12 +43471,12 @@ async function substituteAgainstStateAsync(value, contextOrResources) {
43351
43471
  };
43352
43472
  const intrinsic = keys[0];
43353
43473
  const arg = obj[intrinsic];
43354
- if (intrinsic === "Ref" || intrinsic === "Fn::GetAtt" || intrinsic === "Fn::Sub" || intrinsic === "Fn::Join") return substituteAgainstState(value, context);
43474
+ if (intrinsic === "Ref" || intrinsic === "Fn::GetAtt" || intrinsic === "Fn::Sub" || intrinsic === "Fn::Join" || intrinsic === "Fn::Select" || intrinsic === "Fn::Split") return substituteAgainstState(value, context);
43355
43475
  if (intrinsic === "Fn::ImportValue") return resolveImportValueAsync(arg, context);
43356
43476
  if (intrinsic === "Fn::GetStackOutput") return resolveGetStackOutputAsync(arg, context);
43357
43477
  return {
43358
43478
  kind: "unresolved",
43359
- reason: `unsupported intrinsic '${intrinsic}' (supported: Ref, Fn::GetAtt, Fn::Sub, Fn::Join, Fn::ImportValue, Fn::GetStackOutput)`
43479
+ reason: `unsupported intrinsic '${intrinsic}' (supported: Ref, Fn::GetAtt, Fn::Sub, Fn::Join, Fn::Select, Fn::Split, Fn::ImportValue, Fn::GetStackOutput)`
43360
43480
  };
43361
43481
  }
43362
43482
  /**
@@ -59644,7 +59764,7 @@ function reorderArgs(argv) {
59644
59764
  */
59645
59765
  async function main() {
59646
59766
  const program = new Command();
59647
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.161.1");
59767
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.161.2");
59648
59768
  program.addCommand(createBootstrapCommand());
59649
59769
  program.addCommand(createSynthCommand());
59650
59770
  program.addCommand(createListCommand());