@revturbine/cli 0.14.0 → 0.15.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +97 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -9554,10 +9554,106 @@ function renderHandlesModule(byType, opts) {
9554
9554
  );
9555
9555
  return lines.join("\n");
9556
9556
  }
9557
+ function collectStrings(values) {
9558
+ const out = /* @__PURE__ */ new Set();
9559
+ for (const value of values) {
9560
+ const s = nonEmptyString(value);
9561
+ if (s) out.add(s);
9562
+ }
9563
+ return [...out].sort();
9564
+ }
9565
+ function extractPlanHandles(config) {
9566
+ if (!isRecord4(config) || !Array.isArray(config.plans)) return [];
9567
+ return collectStrings(
9568
+ config.plans.map(
9569
+ (p) => isRecord4(p) ? nonEmptyString(p.unique_handle) ?? nonEmptyString(p.handle) ?? p.id : null
9570
+ )
9571
+ );
9572
+ }
9573
+ function extractSegmentHandles(config) {
9574
+ if (!isRecord4(config) || !Array.isArray(config.segments)) return [];
9575
+ return collectStrings(
9576
+ config.segments.map((s) => isRecord4(s) ? nonEmptyString(s.handle) ?? s.id : null)
9577
+ );
9578
+ }
9579
+ function extractSurfaceTemplateIds(config) {
9580
+ if (!isRecord4(config)) return [];
9581
+ const ids = [];
9582
+ if (Array.isArray(config.surface_templates)) {
9583
+ for (const t of config.surface_templates) {
9584
+ if (isRecord4(t)) ids.push(t.id ?? t.template_id);
9585
+ }
9586
+ }
9587
+ const surfacesOf = (payload) => {
9588
+ if (!isRecord4(payload) || !Array.isArray(payload.surfaces)) return;
9589
+ for (const surface of payload.surfaces) {
9590
+ if (isRecord4(surface)) ids.push(surface.template_id);
9591
+ }
9592
+ };
9593
+ if (Array.isArray(config.placements)) {
9594
+ for (const placement of config.placements) {
9595
+ if (!isRecord4(placement) || !Array.isArray(placement.payloads)) continue;
9596
+ for (const payload of placement.payloads) surfacesOf(payload);
9597
+ }
9598
+ }
9599
+ if (Array.isArray(config.placement_payloads)) {
9600
+ for (const payload of config.placement_payloads) surfacesOf(payload);
9601
+ }
9602
+ return collectStrings(ids);
9603
+ }
9604
+ function extractUiPathActionTypes(config) {
9605
+ if (!isRecord4(config) || !Array.isArray(config.content_ui_paths)) return [];
9606
+ return collectStrings(
9607
+ config.content_ui_paths.map((p) => isRecord4(p) ? p.action_type : null)
9608
+ );
9609
+ }
9610
+ function renderFlatFamily(lines, opts) {
9611
+ lines.push("", `/** ${opts.doc} */`);
9612
+ if (opts.values.length === 0) {
9613
+ lines.push(`export const ${opts.constName} = {} as const;`);
9614
+ lines.push(`export type ${opts.typeName} = never;`);
9615
+ return;
9616
+ }
9617
+ lines.push(`export const ${opts.constName} = {`);
9618
+ for (const value of opts.values) {
9619
+ lines.push(` ${key(value)}: ${quote(value)},`);
9620
+ }
9621
+ lines.push("} as const;");
9622
+ lines.push(`export type ${opts.typeName} =`);
9623
+ opts.values.forEach((value, i) => {
9624
+ lines.push(` | ${quote(value)}${i === opts.values.length - 1 ? ";" : ""}`);
9625
+ });
9626
+ }
9557
9627
  function generateHandleTypes(config, opts) {
9558
9628
  const byType = extractEntitlementHandles(config);
9559
9629
  const handles = [...new Set(Object.values(byType).flat())].sort();
9560
- return { byType, handles, ts: renderHandlesModule(byType, opts) };
9630
+ const lines = [renderHandlesModule(byType, opts).trimEnd()];
9631
+ renderFlatFamily(lines, {
9632
+ doc: "Plan handles \u2014 the values plan targeting and planHandle options take.",
9633
+ constName: "Plans",
9634
+ typeName: "PlanHandle",
9635
+ values: extractPlanHandles(config)
9636
+ });
9637
+ renderFlatFamily(lines, {
9638
+ doc: "Segment handles.",
9639
+ constName: "Segments",
9640
+ typeName: "SegmentHandle",
9641
+ values: extractSegmentHandles(config)
9642
+ });
9643
+ renderFlatFamily(lines, {
9644
+ doc: "Surface-template ids \u2014 catalog entries plus every template a payload references.",
9645
+ constName: "SurfaceTemplates",
9646
+ typeName: "SurfaceTemplateId",
9647
+ values: extractSurfaceTemplateIds(config)
9648
+ });
9649
+ renderFlatFamily(lines, {
9650
+ doc: "Authored ui-path action types \u2014 exactly the key set uiPathResolvers must cover.",
9651
+ constName: "UiPathActionTypes",
9652
+ typeName: "UiPathActionType",
9653
+ values: extractUiPathActionTypes(config)
9654
+ });
9655
+ lines.push("");
9656
+ return { byType, handles, ts: lines.join("\n") };
9561
9657
  }
9562
9658
 
9563
9659
  // src/lib/output.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revturbine/cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "revturbine — verify RevTurbine ExportedConfig files and ship them to a RevTurbine instance through the Change Set lifecycle.",
5
5
  "license": "MIT",
6
6
  "repository": {