kintone-migrator 0.35.7 → 0.35.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/index.mjs CHANGED
@@ -2846,11 +2846,32 @@ function printDiffResult(result) {
2846
2846
  });
2847
2847
  p.note(lines.join("\n"), "Diff Details", { format: (v) => v });
2848
2848
  }
2849
+ const plainThreeWayKeyStyle = {
2850
+ bracket: (text) => text,
2851
+ key: (text) => text
2852
+ };
2853
+ /**
2854
+ * Frames a 3-way entry's key (its display form, see `ThreeWayDiffEntry.key`)
2855
+ * as it appears on the 3-way diff line. Pull prompts reuse it so a conflict is
2856
+ * named exactly as its diff line names it.
2857
+ */
2858
+ function frameThreeWayKey(key, style = plainThreeWayKeyStyle) {
2859
+ return `${style.bracket("[")}${style.key(key)}${style.bracket("]")}`;
2860
+ }
2849
2861
  function formatThreeWayEntry(entry) {
2850
2862
  switch (entry.kind) {
2851
- case "localOnly": return `${pc.green("L")} ${pc.dim("[")}${pc.green(entry.key)}${pc.dim("]")} ${entry.label}${pc.dim(":")} local change`;
2852
- case "remoteOnly": return `${pc.yellow("R")} ${pc.dim("[")}${pc.yellow(entry.key)}${pc.dim("]")} ${entry.label}${pc.dim(":")} remote drift`;
2853
- case "conflict": return `${pc.red("C")} ${pc.dim("[")}${pc.red(entry.key)}${pc.dim("]")} ${entry.label}${pc.dim(":")} conflict`;
2863
+ case "localOnly": return `${pc.green("L")} ${frameThreeWayKey(entry.key, {
2864
+ bracket: pc.dim,
2865
+ key: pc.green
2866
+ })} ${entry.label}${pc.dim(":")} local change`;
2867
+ case "remoteOnly": return `${pc.yellow("R")} ${frameThreeWayKey(entry.key, {
2868
+ bracket: pc.dim,
2869
+ key: pc.yellow
2870
+ })} ${entry.label}${pc.dim(":")} remote drift`;
2871
+ case "conflict": return `${pc.red("C")} ${frameThreeWayKey(entry.key, {
2872
+ bracket: pc.dim,
2873
+ key: pc.red
2874
+ })} ${entry.label}${pc.dim(":")} conflict`;
2854
2875
  }
2855
2876
  }
2856
2877
  function formatThreeWayExtra(extra) {
@@ -3567,41 +3588,42 @@ function resolveActionMerge(merge, resolution) {
3567
3588
  //#region src/core/application/threeWay/threeWayDiff.ts
3568
3589
  /**
3569
3590
  * Builds the three-way portion of a {@link ThreeWayDiffResult} from a
3570
- * record-keyed merge (view / report / action / plugin). The caller supplies a
3571
- * `label` extractor (e.g. the view's name) for display.
3591
+ * record-keyed merge (view / report / action / plugin / customization / field
3592
+ * permission / app permission / record permission). The caller supplies a
3593
+ * `label` extractor (e.g. the view's type) for display.
3572
3594
  */
3573
- function buildRecordThreeWayDiff(merge, label, extras = [], notes = []) {
3595
+ function buildRecordThreeWayDiff(merge, label, { describeKey = (key) => key, notes = [] } = {}) {
3574
3596
  const localChanges = [];
3575
3597
  const remoteDrift = [];
3576
3598
  const conflicts = [];
3577
3599
  for (const entry of merge.entries) switch (entry.change.kind) {
3578
3600
  case "localOnly":
3579
3601
  localChanges.push({
3580
- key: entry.key,
3602
+ key: describeKey(entry.key),
3581
3603
  label: label(entry),
3582
3604
  kind: "localOnly"
3583
3605
  });
3584
3606
  break;
3585
3607
  case "remoteOnly":
3586
3608
  remoteDrift.push({
3587
- key: entry.key,
3609
+ key: describeKey(entry.key),
3588
3610
  label: label(entry),
3589
3611
  kind: "remoteOnly"
3590
3612
  });
3591
3613
  break;
3592
3614
  case "conflict": conflicts.push({
3593
- key: entry.key,
3615
+ key: describeKey(entry.key),
3594
3616
  label: label(entry),
3595
3617
  kind: "conflict"
3596
3618
  });
3597
3619
  }
3598
- const isEmpty = localChanges.length === 0 && remoteDrift.length === 0 && conflicts.length === 0 && extras.length === 0;
3620
+ const isEmpty = localChanges.length === 0 && remoteDrift.length === 0 && conflicts.length === 0;
3599
3621
  return {
3600
3622
  mode: "three-way",
3601
3623
  localChanges,
3602
3624
  remoteDrift,
3603
3625
  conflicts,
3604
- extras,
3626
+ extras: [],
3605
3627
  ...notes.length > 0 ? { notes } : {},
3606
3628
  isEmpty
3607
3629
  };
@@ -3913,6 +3935,15 @@ async function applyPulledActionMerge({ container, input }) {
3913
3935
  //#endregion
3914
3936
  //#region src/cli/commands/pullCommandFactory.ts
3915
3937
  /**
3938
+ * Names a conflict as the 3-way diff line does ({@link frameThreeWayKey}), for
3939
+ * domains whose keys embed values quoted in display (see
3940
+ * `ThreeWayDiffEntry.key`): the display form carries its own quotes, so
3941
+ * wrapping it in more quotes would blur where it ends again.
3942
+ */
3943
+ function nameConflictAsDiffLine(describeKey) {
3944
+ return (key) => frameThreeWayKey(describeKey(key));
3945
+ }
3946
+ /**
3916
3947
  * Factory for `pull` commands.
3917
3948
  *
3918
3949
  * Absorbs the boilerplate shared by every config domain: the two-stage pull
@@ -3924,6 +3955,7 @@ async function applyPulledActionMerge({ container, input }) {
3924
3955
  * top-level pull dispatcher.
3925
3956
  */
3926
3957
  function createPullCommand(config) {
3958
+ const nameConflict = config.nameConflict ?? ((key) => `"${key}"`);
3927
3959
  const notSupportedAll = new ValidationError(ValidationErrorCode.InvalidInput, `${config.description} does not support --all yet. Use --app <name> or a single app.`);
3928
3960
  async function resolveConflicts(merge, options) {
3929
3961
  const resolution = /* @__PURE__ */ new Map();
@@ -3937,7 +3969,7 @@ function createPullCommand(config) {
3937
3969
  continue;
3938
3970
  }
3939
3971
  const selected = await p.select({
3940
- message: `Conflict on ${config.conflictNoun} "${conflict.key}". Keep which side?`,
3972
+ message: `Conflict on ${config.conflictNoun} ${nameConflict(conflict.key)}. Keep which side?`,
3941
3973
  options: [{
3942
3974
  value: "local",
3943
3975
  label: "local (ours)"
@@ -12476,7 +12508,7 @@ async function detectCustomizationThreeWayDiff({ container, input }) {
12476
12508
  remote,
12477
12509
  basePath: input.basePath
12478
12510
  });
12479
- return buildRecordThreeWayDiff(merge, (entry) => entry.key, [], buildNotes(estimatedKeys, unreadableLocalKeys, new Set(merge.entries.filter((entry) => entry.change.kind === "localOnly" || entry.change.kind === "remoteOnly" || entry.change.kind === "conflict").map((entry) => entry.key))));
12511
+ return buildRecordThreeWayDiff(merge, (entry) => entry.key, { notes: buildNotes(estimatedKeys, unreadableLocalKeys, new Set(merge.entries.filter((entry) => entry.change.kind === "localOnly" || entry.change.kind === "remoteOnly" || entry.change.kind === "conflict").map((entry) => entry.key))) });
12480
12512
  }
12481
12513
  //#endregion
12482
12514
  //#region src/cli/commands/customize/diff.ts
@@ -13971,6 +14003,26 @@ var capture_default$8 = createCaptureCommand({
13971
14003
  resolveAppContainerConfig: resolveNotificationAppContainerConfig
13972
14004
  });
13973
14005
  //#endregion
14006
+ //#region src/core/domain/services/filterCondKey.ts
14007
+ /**
14008
+ * Merge key of the `index`-th entry among the entries sharing `filterCond`
14009
+ * (record permission rights, perRecord notifications). The index suffix comes
14010
+ * after the full filterCond, so the last `#` always starts the index even when
14011
+ * the filterCond itself contains `#`.
14012
+ */
14013
+ function filterCondKey(filterCond, index) {
14014
+ return `${filterCond}#${index}`;
14015
+ }
14016
+ /**
14017
+ * Display form of a {@link filterCondKey}: the filterCond quoted as a value,
14018
+ * then the index (`"status = \"A\""#0`). Quoting keeps a `]`, `#`, `"` or
14019
+ * newline in the filterCond from blurring where the key ends.
14020
+ */
14021
+ function describeFilterCondKey(key) {
14022
+ const indexStart = key.lastIndexOf("#");
14023
+ return `${formatValue(key.slice(0, indexStart))}${key.slice(indexStart)}`;
14024
+ }
14025
+ //#endregion
13974
14026
  //#region src/core/domain/notification/services/notificationMerge.ts
13975
14027
  /**
13976
14028
  * 3-way merge for the notification domain (general / perRecord / reminder).
@@ -13994,16 +14046,29 @@ var capture_default$8 = createCaptureCommand({
13994
14046
  * the `notifyToCommenter` scalar as a single whole-entity 3-way, so the scalar
13995
14047
  * is never dropped from the 3-way.
13996
14048
  */
13997
- const GENERAL_SCALAR_KEY = "general:notifyToCommenter";
13998
- const REMINDER_TIMEZONE_KEY = "reminder:timezone";
14049
+ const GENERAL_KEY_PREFIX = "general:";
14050
+ const PER_RECORD_KEY_PREFIX = "perRecord:";
14051
+ const REMINDER_KEY_PREFIX = "reminder:";
14052
+ const GENERAL_SCALAR_KEY = `${GENERAL_KEY_PREFIX}notifyToCommenter`;
14053
+ const REMINDER_TIMEZONE_KEY = `${REMINDER_KEY_PREFIX}timezone`;
13999
14054
  function generalEntityKey(notif) {
14000
- return `general:${notif.entity.type}:${notif.entity.code}`;
14055
+ return `${GENERAL_KEY_PREFIX}${notif.entity.type}:${notif.entity.code}`;
14001
14056
  }
14002
14057
  function perRecordCompositeKey(filterCond, index) {
14003
- return `perRecord:${filterCond}#${index}`;
14058
+ return `${PER_RECORD_KEY_PREFIX}${filterCondKey(filterCond, index)}`;
14004
14059
  }
14005
14060
  function reminderKey(notif) {
14006
- return `reminder:${notif.code}`;
14061
+ return `${REMINDER_KEY_PREFIX}${notif.code}`;
14062
+ }
14063
+ /**
14064
+ * Display form of a merge key. A perRecord key carries a filterCond, which is
14065
+ * quoted ({@link describeFilterCondKey}); the other keys are built from names
14066
+ * and are shown as they are.
14067
+ */
14068
+ function describeNotificationMergeKey(key) {
14069
+ if (!key.startsWith(PER_RECORD_KEY_PREFIX)) return key;
14070
+ const filterCondPart = key.slice(10);
14071
+ return `${PER_RECORD_KEY_PREFIX}${describeFilterCondKey(filterCondPart)}`;
14007
14072
  }
14008
14073
  /**
14009
14074
  * General notification equality, matching `compareGeneralNotification`:
@@ -14079,7 +14144,7 @@ function resolveEntryValue(entry, resolution) {
14079
14144
  function collectGeneralNotifications(entries, resolution) {
14080
14145
  const result = [];
14081
14146
  for (const entry of entries) {
14082
- if (!entry.key.startsWith("general:") || entry.key === GENERAL_SCALAR_KEY) continue;
14147
+ if (!entry.key.startsWith(GENERAL_KEY_PREFIX) || entry.key === GENERAL_SCALAR_KEY) continue;
14083
14148
  const value = resolveEntryValue(entry, resolution);
14084
14149
  if (value !== void 0) result.push(value);
14085
14150
  }
@@ -14088,7 +14153,7 @@ function collectGeneralNotifications(entries, resolution) {
14088
14153
  function collectPerRecordNotifications(entries, resolution) {
14089
14154
  const result = [];
14090
14155
  for (const entry of entries) {
14091
- if (!entry.key.startsWith("perRecord:")) continue;
14156
+ if (!entry.key.startsWith(PER_RECORD_KEY_PREFIX)) continue;
14092
14157
  const value = resolveEntryValue(entry, resolution);
14093
14158
  if (value !== void 0) result.push(value);
14094
14159
  }
@@ -14097,7 +14162,7 @@ function collectPerRecordNotifications(entries, resolution) {
14097
14162
  function collectReminderNotifications(entries, resolution) {
14098
14163
  const result = [];
14099
14164
  for (const entry of entries) {
14100
- if (!entry.key.startsWith("reminder:") || entry.key === REMINDER_TIMEZONE_KEY) continue;
14165
+ if (!entry.key.startsWith(REMINDER_KEY_PREFIX) || entry.key === REMINDER_TIMEZONE_KEY) continue;
14101
14166
  const value = resolveEntryValue(entry, resolution);
14102
14167
  if (value !== void 0) result.push(value);
14103
14168
  }
@@ -14222,7 +14287,7 @@ function buildThreeWay(merge) {
14222
14287
  const extras = [];
14223
14288
  for (const entry of merge.entries) {
14224
14289
  const base = {
14225
- key: entry.key,
14290
+ key: describeNotificationMergeKey(entry.key),
14226
14291
  label: entryLabel(entry)
14227
14292
  };
14228
14293
  switch (entry.change.kind) {
@@ -14395,6 +14460,7 @@ var pull_default$8 = createPullCommand({
14395
14460
  args: notificationArgs,
14396
14461
  subject: "notification config",
14397
14462
  conflictNoun: "notification",
14463
+ nameConflict: nameConflictAsDiffLine(describeNotificationMergeKey),
14398
14464
  createContainer: createNotificationCliContainer,
14399
14465
  pullFn: async ({ container, input }) => {
14400
14466
  const result = await pullNotification({
@@ -15835,15 +15901,16 @@ async function applyPulledGeneralSettingsMerge({ container, input }) {
15835
15901
  * means a reordering within a filterCond is seen as content changes at those
15836
15902
  * indices, matching the existing 2-way detector.
15837
15903
  */
15838
- function compositeKey(filterCond, index) {
15839
- return `${filterCond}#${index}`;
15904
+ /** Display form of a merge key, with its filterCond quoted. */
15905
+ function describeRecordPermissionMergeKey(key) {
15906
+ return describeFilterCondKey(key);
15840
15907
  }
15841
15908
  /** Converts the ordered `rights` list into a record keyed by `filterCond#i`. */
15842
15909
  function toRecord(config) {
15843
15910
  const record = {};
15844
15911
  const grouped = groupByKey(config.rights, (r) => r.filterCond);
15845
15912
  for (const [filterCond, group] of grouped) group.forEach((right, i) => {
15846
- record[compositeKey(filterCond, i)] = right;
15913
+ record[filterCondKey(filterCond, i)] = right;
15847
15914
  });
15848
15915
  return record;
15849
15916
  }
@@ -17602,7 +17669,7 @@ async function detectRecordPermissionThreeWayDiff({ container }) {
17602
17669
  return buildRecordThreeWayDiff(computeRecordPermissionThreeWayMerge(state, local, remote.config), (entry) => {
17603
17670
  const right = entry.local ?? entry.remote ?? entry.base;
17604
17671
  return right ? describeRecordPermissionFilter(right.filterCond) : entry.key;
17605
- });
17672
+ }, { describeKey: describeRecordPermissionMergeKey });
17606
17673
  }
17607
17674
  //#endregion
17608
17675
  //#region src/cli/commands/record-acl/diff.ts
@@ -17652,6 +17719,7 @@ var pull_default$4 = createPullCommand({
17652
17719
  args: recordAclArgs,
17653
17720
  subject: "record permission config",
17654
17721
  conflictNoun: "record permission",
17722
+ nameConflict: nameConflictAsDiffLine(describeRecordPermissionMergeKey),
17655
17723
  createContainer: createRecordPermissionCliContainer,
17656
17724
  pullFn: async ({ container, input }) => {
17657
17725
  const result = await pullRecordPermission({