@wayai/cli 0.3.226 → 0.3.228

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/index.js CHANGED
@@ -22250,7 +22250,7 @@ function renderDiff(diff) {
22250
22250
  for (const kind of ENTITY_KINDS) {
22251
22251
  const b = bucket(diff, kind);
22252
22252
  if (!b || isEmptyBucket(b)) continue;
22253
- lines.push(`${BOLD}${LABELS[kind]}s${RESET}`);
22253
+ lines.push(`${BOLD}${ENTITY_LABELS[kind]}s${RESET}`);
22254
22254
  for (const e of b.added) lines.push(`${GREEN} + ${sanitizeTerminalText(e.id)}${RESET}`);
22255
22255
  for (const m of b.modified) lines.push(`${YELLOW} ~ ${sanitizeTerminalText(m.after.id)}${RESET}`);
22256
22256
  for (const e of b.removed) {
@@ -22271,14 +22271,14 @@ function renderDiff(diff) {
22271
22271
  }
22272
22272
  return lines.join("\n");
22273
22273
  }
22274
- var LABELS, GREEN, YELLOW, RED, BOLD, RESET;
22274
+ var ENTITY_LABELS, GREEN, YELLOW, RED, BOLD, RESET;
22275
22275
  var init_diff_format = __esm({
22276
22276
  "src/data/config-as-code/diff-format.ts"() {
22277
22277
  "use strict";
22278
22278
  init_terminal_output();
22279
22279
  init_base_id();
22280
22280
  init_types2();
22281
- LABELS = {
22281
+ ENTITY_LABELS = {
22282
22282
  record_types: "record type",
22283
22283
  relationship_types: "relationship type",
22284
22284
  file_types: "file type",
@@ -34590,7 +34590,7 @@ function sameFileType(remote, spec) {
34590
34590
  function isObject(value) {
34591
34591
  return typeof value === "object" && value !== null && !Array.isArray(value);
34592
34592
  }
34593
- function promotionProblems(result, ids, section = "file_types") {
34593
+ function promotionProblems(result, ids, { section = "file_types", createOnly = false } = {}) {
34594
34594
  const answer = isObject(result) ? result : {};
34595
34595
  const problems2 = [];
34596
34596
  for (const [kind, bucket2] of Object.entries(isObject(answer.diff) ? answer.diff : {})) {
@@ -34599,7 +34599,15 @@ function promotionProblems(result, ids, section = "file_types") {
34599
34599
  for (const entry of Array.isArray(bucket2[change]) ? bucket2[change] : []) {
34600
34600
  const row = isObject(entry) ? isObject(entry.after) ? entry.after : entry : {};
34601
34601
  const id = typeof row.id === "string" ? row.id : JSON.stringify(row).slice(0, 80);
34602
- if (kind === section && change !== "removed" && ids.has(id)) continue;
34602
+ if (kind === section && ids.has(id)) {
34603
+ if (change === "added" || change === "modified" && !createOnly) continue;
34604
+ if (change === "modified") {
34605
+ problems2.push(
34606
+ `${ENTITY_LABELS[section]} "${id}" was created in production while the migration ran, and differs from the one it would promote, so the production one is kept`
34607
+ );
34608
+ continue;
34609
+ }
34610
+ }
34603
34611
  problems2.push(`it would also apply ${kind} ${change}: "${id}"`);
34604
34612
  }
34605
34613
  }
@@ -34762,7 +34770,7 @@ Dry run: nothing written (${writes === 0 ? "nothing to write" : `${writes} write
34762
34770
  for (const spec of toWrite) await kb.putFileType(preview, spec);
34763
34771
  if (toPromote.length > 0) {
34764
34772
  const ids = toPromote.map((s) => s.id);
34765
- const problems2 = promotionProblems(await kb.promoteFileTypes(productionId, preview, ids, true), new Set(ids));
34773
+ const problems2 = promotionProblems(await kb.promoteFileTypes(productionId, preview, ids, true), new Set(ids), { createOnly: true });
34766
34774
  if (problems2.length > 0) {
34767
34775
  throw expected(
34768
34776
  `The promotion into "${safe(productionId)}" would not apply as planned (${problems2.map(safe).join("; ")}). Its file types are written in "${safe(preview)}"; nothing reached production.`
@@ -34797,6 +34805,7 @@ var init_migrate2 = __esm({
34797
34805
  "use strict";
34798
34806
  init_resource_files();
34799
34807
  init_api_client();
34808
+ init_diff_format();
34800
34809
  init_expected();
34801
34810
  init_terminal_output();
34802
34811
  init_utils();
@@ -35767,7 +35776,7 @@ Dry run: nothing written (${writes === 0 ? "nothing to write" : `${writes} write
35767
35776
  for (const spec of toolsetsToWrite) await kb.putToolset(preview, spec);
35768
35777
  if (toolsetsToPromote.length > 0) {
35769
35778
  const slugs = toolsetsToPromote.map((s) => s.id);
35770
- const problems2 = promotionProblems(await kb.promoteToolsets(production, preview, slugs, true), new Set(slugs), "toolsets");
35779
+ const problems2 = promotionProblems(await kb.promoteToolsets(production, preview, slugs, true), new Set(slugs), { section: "toolsets" });
35771
35780
  if (problems2.length > 0) {
35772
35781
  throw expected(
35773
35782
  `The promotion into "${safe2(production)}" would not apply as planned (${problems2.map(safe2).join("; ")}). The toolsets are written in "${safe2(preview)}"; nothing reached production, and the hub's agents are unchanged.`
@@ -35964,7 +35973,9 @@ migrate: move knowledge resources into the organization's knowledge base.
35964
35973
  file type, its files keep their paths, and each described folder gains an _index.md. Files are
35965
35974
  written create-only: one created at its path while it runs is kept, and the run stops there,
35966
35975
  naming it. A re-run writes what is left once that file matches its source or is moved or
35967
- removed; until then it stops before any write, naming it.
35976
+ removed; until then it stops before any write, naming it. A file type created in production at
35977
+ an id it would add, after it read production, is kept too: unless it is already what the run
35978
+ would promote, the run stops before promoting, naming it.
35968
35979
 
35969
35980
  --base The knowledge base: its production base, or the preview its file types are
35970
35981
  written in. File types are written in the preview and promoted; files are