kintone-migrator 0.35.5 → 0.35.7

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
@@ -1494,6 +1494,12 @@ function readKintoneLookupList(value, fieldPath) {
1494
1494
  if (list === void 0) throw new SystemError(SystemErrorCode.ExternalApiError, `Expected array at ${fieldPath}, got ${typeof value}`);
1495
1495
  return list;
1496
1496
  }
1497
+ /** Reads a filter condition or sort order; a missing one is `""`. */
1498
+ function readKintoneQueryClause(value, fieldPath) {
1499
+ if (value === void 0) return "";
1500
+ assertString(value, fieldPath);
1501
+ return value;
1502
+ }
1497
1503
  function fromKintoneLookup(value, fieldPath) {
1498
1504
  assertRecord(value, fieldPath);
1499
1505
  assertRecord(value.relatedApp, `${fieldPath}.relatedApp`);
@@ -1513,16 +1519,13 @@ function fromKintoneLookup(value, fieldPath) {
1513
1519
  });
1514
1520
  const lookupPickerFields = readKintoneLookupList(value.lookupPickerFields, `${fieldPath}.lookupPickerFields`);
1515
1521
  assertStringArray(lookupPickerFields, `${fieldPath}.lookupPickerFields`);
1516
- const { filterCond, sort } = value;
1517
- if (filterCond !== void 0) assertString(filterCond, `${fieldPath}.filterCond`);
1518
- if (sort !== void 0) assertString(sort, `${fieldPath}.sort`);
1519
1522
  return {
1520
1523
  relatedApp: LookupRelatedApp.create(app, code),
1521
1524
  relatedKeyField: value.relatedKeyField,
1522
1525
  fieldMappings,
1523
1526
  lookupPickerFields,
1524
- ...filterCond !== void 0 ? { filterCond } : {},
1525
- ...sort !== void 0 ? { sort } : {}
1527
+ filterCond: readKintoneQueryClause(value.filterCond, `${fieldPath}.filterCond`),
1528
+ sort: readKintoneQueryClause(value.sort, `${fieldPath}.sort`)
1526
1529
  };
1527
1530
  }
1528
1531
  function fromKintoneProperty(prop) {
@@ -1566,9 +1569,9 @@ function fromKintoneProperty(prop) {
1566
1569
  field: FieldCode.create(condition.field),
1567
1570
  relatedField: FieldCode.create(condition.relatedField)
1568
1571
  },
1569
- ...rt.filterCond !== void 0 ? { filterCond: String(rt.filterCond) } : {},
1572
+ filterCond: readKintoneQueryClause(rt.filterCond, "REFERENCE_TABLE.referenceTable.filterCond"),
1570
1573
  displayFields,
1571
- ...rt.sort !== void 0 ? { sort: String(rt.sort) } : {},
1574
+ sort: readKintoneQueryClause(rt.sort, "REFERENCE_TABLE.referenceTable.sort"),
1572
1575
  ...rt.size !== void 0 ? { size: String(rt.size) } : {}
1573
1576
  } }
1574
1577
  };
@@ -1611,9 +1614,9 @@ function toKintoneProperty(field) {
1611
1614
  field: ref.condition.field,
1612
1615
  relatedField: ref.condition.relatedField
1613
1616
  },
1614
- ...ref.filterCond !== void 0 ? { filterCond: ref.filterCond } : {},
1617
+ filterCond: ref.filterCond,
1615
1618
  displayFields: ref.displayFields.map((f) => f),
1616
- ...ref.sort !== void 0 ? { sort: ref.sort } : {},
1619
+ sort: ref.sort,
1617
1620
  ...ref.size !== void 0 ? { size: ref.size } : {}
1618
1621
  }
1619
1622
  };
@@ -2621,6 +2624,15 @@ function resolveSingleApp(config, appName) {
2621
2624
  return { orderedApps: [entry] };
2622
2625
  }
2623
2626
  //#endregion
2627
+ //#region src/core/domain/recordPermission/valueObject.ts
2628
+ /**
2629
+ * Display form of a right's filterCond. filterCond is a query expression, so
2630
+ * it is quoted as a value; the empty condition targets all records.
2631
+ */
2632
+ function describeRecordPermissionFilter(filterCond) {
2633
+ return filterCond === "" ? "(all records)" : formatValue(filterCond);
2634
+ }
2635
+ //#endregion
2624
2636
  //#region src/cli/handleError.ts
2625
2637
  /**
2626
2638
  * Log error details without terminating the process.
@@ -2885,7 +2897,7 @@ function printProcessDiffResult(result) {
2885
2897
  printGenericDiffResult(result, "Process Management Diff Details", (entry, colorize, prefix) => `${colorize(prefix)} ${pc.dim("[")}${colorize(entry.category)}${pc.dim("]")} ${entry.name}${pc.dim(":")} ${entry.details}`);
2886
2898
  }
2887
2899
  function printRecordPermissionDiffResult(result) {
2888
- printGenericDiffResult(result, "Record Permission Diff Details", (entry, colorize, prefix) => `${colorize(prefix)} ${pc.dim("[")}${colorize(entry.filterCond === "" ? "(all records)" : entry.filterCond)}${pc.dim("]:")} ${entry.details}`);
2900
+ printGenericDiffResult(result, "Record Permission Diff Details", (entry, colorize, prefix) => `${colorize(prefix)} ${pc.dim("[")}${colorize(describeRecordPermissionFilter(entry.filterCond))}${pc.dim("]:")} ${entry.details}`);
2889
2901
  }
2890
2902
  function printReportDiffResult(result) {
2891
2903
  printGenericDiffResult(result, "Report Diff Details", (entry, colorize, prefix) => `${colorize(prefix)} ${colorize(entry.reportName)}${pc.dim(":")} ${entry.details}`);
@@ -5716,7 +5728,7 @@ function describePropertiesChanges(before, after) {
5716
5728
  function describeChanges$1(before, after) {
5717
5729
  const changes = [];
5718
5730
  if (before.type !== after.type) changes.push(`type: ${before.type} -> ${after.type}`);
5719
- if (before.label !== after.label) changes.push(`label: ${before.label} -> ${after.label}`);
5731
+ if (before.label !== after.label) changes.push(`label: ${formatValue(before.label)} -> ${formatValue(after.label)}`);
5720
5732
  if ((before.noLabel ?? false) !== (after.noLabel ?? false)) changes.push(`noLabel: ${before.noLabel ?? false} -> ${after.noLabel ?? false}`);
5721
5733
  if (!isPropertiesEqual(before, after)) changes.push(...describePropertiesChanges(before, after));
5722
5734
  return changes.length > 0 ? changes.join("\n") : "no visible changes";
@@ -6277,6 +6289,13 @@ function invalidLookup(code, detail) {
6277
6289
  function optionalString(value) {
6278
6290
  return value === void 0 || value === null ? void 0 : String(value);
6279
6291
  }
6292
+ /**
6293
+ * Reads a filter condition or sort order; an omitted or valueless one is `""`,
6294
+ * the value kintone returns when it is unset.
6295
+ */
6296
+ function optionalQueryClause(value) {
6297
+ return optionalString(value) ?? "";
6298
+ }
6280
6299
  /** Reads a lookup list; an omitted or valueless list is the empty list. */
6281
6300
  function optionalLookupList(code, key, value) {
6282
6301
  if (value === void 0 || value === null) return [];
@@ -6296,15 +6315,13 @@ function parseLookup(code, raw) {
6296
6315
  relatedField: String(mapping.relatedField ?? "")
6297
6316
  };
6298
6317
  });
6299
- const filterCond = optionalString(raw.filterCond);
6300
- const sort = optionalString(raw.sort);
6301
6318
  return {
6302
6319
  relatedApp: LookupRelatedApp.create(String(raw.relatedApp.app ?? ""), optionalString(raw.relatedApp.code)),
6303
6320
  relatedKeyField: String(raw.relatedKeyField ?? ""),
6304
6321
  fieldMappings,
6305
6322
  lookupPickerFields,
6306
- ...filterCond !== void 0 ? { filterCond } : {},
6307
- ...sort !== void 0 ? { sort } : {}
6323
+ filterCond: optionalQueryClause(raw.filterCond),
6324
+ sort: optionalQueryClause(raw.sort)
6308
6325
  };
6309
6326
  }
6310
6327
  function parseReferenceTableField(raw, code, base) {
@@ -6318,6 +6335,7 @@ function parseReferenceTableField(raw, code, base) {
6318
6335
  const relatedApp = refTable.relatedApp;
6319
6336
  const conditionField = String(condition.field ?? "");
6320
6337
  const conditionRelatedField = String(condition.relatedField ?? "");
6338
+ const size = optionalString(refTable.size);
6321
6339
  if (conditionField.length === 0) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have a non-empty "referenceTable.condition.field"`);
6322
6340
  if (conditionRelatedField.length === 0) throw new BusinessRuleError(FormSchemaErrorCode.FsInvalidSchemaStructure, `Field "${code}" of type REFERENCE_TABLE must have a non-empty "referenceTable.condition.relatedField"`);
6323
6341
  return {
@@ -6329,10 +6347,10 @@ function parseReferenceTableField(raw, code, base) {
6329
6347
  field: FieldCode.create(conditionField),
6330
6348
  relatedField: FieldCode.create(conditionRelatedField)
6331
6349
  },
6332
- ...refTable.filterCond !== void 0 ? { filterCond: String(refTable.filterCond) } : {},
6350
+ filterCond: optionalQueryClause(refTable.filterCond),
6333
6351
  displayFields,
6334
- ...refTable.sort !== void 0 ? { sort: String(refTable.sort) } : {},
6335
- ...refTable.size !== void 0 ? { size: String(refTable.size) } : {}
6352
+ sort: optionalQueryClause(refTable.sort),
6353
+ ...size !== void 0 ? { size } : {}
6336
6354
  } }
6337
6355
  };
6338
6356
  }
@@ -9535,6 +9553,18 @@ function pairByKeyInOrder(local, remote, keyFn) {
9535
9553
  return pairs;
9536
9554
  }
9537
9555
  //#endregion
9556
+ //#region src/core/domain/notification/entity.ts
9557
+ /**
9558
+ * Display name of a per-record notification: the title as a name, otherwise
9559
+ * the filterCond quoted as a value so that it is distinguishable from a title
9560
+ * and its extent is readable.
9561
+ */
9562
+ function describePerRecordNotification(notif) {
9563
+ if (notif.title !== "") return notif.title;
9564
+ if (notif.filterCond !== "") return formatValue(notif.filterCond);
9565
+ return "(empty filter)";
9566
+ }
9567
+ //#endregion
9538
9568
  //#region src/core/domain/notification/services/diffDetector.ts
9539
9569
  function serializeEntity$1(entity) {
9540
9570
  return `${entity.type}:${entity.code}`;
@@ -9588,9 +9618,6 @@ function compareGeneralSection(local, remote) {
9588
9618
  });
9589
9619
  return entries;
9590
9620
  }
9591
- function perRecordLabel(notif) {
9592
- return notif.title || notif.filterCond || "(empty filter)";
9593
- }
9594
9621
  function describePerRecordChanges(local, remote) {
9595
9622
  const diffs = [];
9596
9623
  if (local.title !== remote.title) diffs.push(`title: ${formatValue(remote.title)} -> ${formatValue(local.title)}`);
@@ -9614,7 +9641,7 @@ function comparePerRecordSection(local, remote) {
9614
9641
  entries.push({
9615
9642
  type: "added",
9616
9643
  section: "perRecord",
9617
- name: perRecordLabel(pair.local),
9644
+ name: describePerRecordNotification(pair.local),
9618
9645
  details: "new notification"
9619
9646
  });
9620
9647
  break;
@@ -9622,14 +9649,14 @@ function comparePerRecordSection(local, remote) {
9622
9649
  entries.push({
9623
9650
  type: "deleted",
9624
9651
  section: "perRecord",
9625
- name: perRecordLabel(pair.remote),
9652
+ name: describePerRecordNotification(pair.remote),
9626
9653
  details: "removed"
9627
9654
  });
9628
9655
  break;
9629
9656
  case "both": if (!deepEqual(pair.local, pair.remote)) entries.push({
9630
9657
  type: "modified",
9631
9658
  section: "perRecord",
9632
- name: perRecordLabel(pair.local),
9659
+ name: describePerRecordNotification(pair.local),
9633
9660
  details: describePerRecordChanges(pair.local, pair.remote)
9634
9661
  });
9635
9662
  }
@@ -9858,35 +9885,71 @@ function actionLabel(action, index) {
9858
9885
  const label = describeProcessAction(action);
9859
9886
  return index === 0 ? label : `${label} #${index + 1}`;
9860
9887
  }
9888
+ function withPositions(actions) {
9889
+ return actions.map((action, position) => ({
9890
+ action,
9891
+ position
9892
+ }));
9893
+ }
9894
+ /**
9895
+ * The record screen shows the actions available from the current state as
9896
+ * buttons in `actions` order, so only the relative order of actions sharing a
9897
+ * `from` is observable. Compares that order over the actions present on both
9898
+ * sides; added and deleted actions are reported by their own entries.
9899
+ */
9900
+ function compareActionOrder(localActions, matched, entries) {
9901
+ const localOrders = groupByKey([...matched].sort((a, b) => a.localPosition - b.localPosition), (m) => m.from);
9902
+ for (const from of new Set(localActions.map((a) => a.from))) {
9903
+ const localOrder = localOrders.get(from) ?? [];
9904
+ const remoteOrder = [...localOrder].sort((a, b) => a.remotePosition - b.remotePosition);
9905
+ if (remoteOrder.every((m, i) => m === localOrder[i])) continue;
9906
+ const labels = (order) => order.map((m) => m.label).join(", ");
9907
+ entries.push({
9908
+ type: "modified",
9909
+ category: "actionOrder",
9910
+ name: from,
9911
+ details: `${labels(remoteOrder)} -> ${labels(localOrder)}`
9912
+ });
9913
+ }
9914
+ }
9861
9915
  function compareActionEntries(local, remote, entries) {
9862
- for (const pair of pairByKeyInOrder(local.actions, remote.actions, transitionKey)) switch (pair.kind) {
9916
+ const matched = [];
9917
+ for (const pair of pairByKeyInOrder(withPositions(local.actions), withPositions(remote.actions), (p) => transitionKey(p.action))) switch (pair.kind) {
9863
9918
  case "localOnly":
9864
9919
  entries.push({
9865
9920
  type: "added",
9866
9921
  category: "action",
9867
- name: actionLabel(pair.local, pair.index),
9868
- details: `filterCond: ${formatValue(pair.local.filterCond)}`
9922
+ name: actionLabel(pair.local.action, pair.index),
9923
+ details: `filterCond: ${formatValue(pair.local.action.filterCond)}`
9869
9924
  });
9870
9925
  break;
9871
9926
  case "remoteOnly":
9872
9927
  entries.push({
9873
9928
  type: "deleted",
9874
9929
  category: "action",
9875
- name: actionLabel(pair.remote, pair.index),
9876
- details: `filterCond: ${formatValue(pair.remote.filterCond)}`
9930
+ name: actionLabel(pair.remote.action, pair.index),
9931
+ details: `filterCond: ${formatValue(pair.remote.action.filterCond)}`
9877
9932
  });
9878
9933
  break;
9879
9934
  case "both": {
9880
- const actionDiffs = compareActions(pair.local, pair.remote);
9935
+ const label = actionLabel(pair.local.action, pair.index);
9936
+ const actionDiffs = compareActions(pair.local.action, pair.remote.action);
9881
9937
  if (actionDiffs.length > 0) entries.push({
9882
9938
  type: "modified",
9883
9939
  category: "action",
9884
- name: actionLabel(pair.local, pair.index),
9940
+ name: label,
9885
9941
  details: actionDiffs.join("\n")
9886
9942
  });
9943
+ matched.push({
9944
+ from: pair.local.action.from,
9945
+ label,
9946
+ localPosition: pair.local.position,
9947
+ remotePosition: pair.remote.position
9948
+ });
9887
9949
  break;
9888
9950
  }
9889
9951
  }
9952
+ compareActionOrder(local.actions, matched, entries);
9890
9953
  }
9891
9954
  function compareConfigs(local, remote) {
9892
9955
  const entries = [];
@@ -11160,9 +11223,9 @@ function serializeFlatField(field, size) {
11160
11223
  field: ref.condition.field,
11161
11224
  relatedField: ref.condition.relatedField
11162
11225
  },
11163
- ...ref.filterCond !== void 0 ? { filterCond: ref.filterCond } : {},
11226
+ filterCond: ref.filterCond,
11164
11227
  displayFields: ref.displayFields.map((f) => f),
11165
- ...ref.sort !== void 0 ? { sort: ref.sort } : {},
11228
+ sort: ref.sort,
11166
11229
  ...ref.size !== void 0 ? { size: ref.size } : {}
11167
11230
  };
11168
11231
  return result;
@@ -13924,8 +13987,9 @@ var capture_default$8 = createCaptureCommand({
13924
13987
  * reminder map). Plus the `timezone` scalar as a single whole-entity 3-way
13925
13988
  * when the local config manages it (sets a timezone).
13926
13989
  * - **perRecord** = group by `filterCond`, then within a group match by index
13927
- * (`filterCond#i` composite key — `comparePerRecordSection`). `perRecordLabel`
13928
- * is display-only and is NOT used as a match key.
13990
+ * (`filterCond#i` composite key — `comparePerRecordSection`).
13991
+ * `describePerRecordNotification` is display-only and is NOT used as a match
13992
+ * key.
13929
13993
  * - **general** = entity (`type:code`) keyed list (`compareGeneralSection`) plus
13930
13994
  * the `notifyToCommenter` scalar as a single whole-entity 3-way, so the scalar
13931
13995
  * is never dropped from the 3-way.
@@ -14104,14 +14168,15 @@ async function loadNotificationThreeWayInputs(container) {
14104
14168
  //#region src/core/application/notification/detectNotificationThreeWayDiff.ts
14105
14169
  /**
14106
14170
  * Human label for a merge entry. Uses the section-appropriate display value
14107
- * (`perRecordLabel` semantics for perRecord, `code`/title for reminder, the
14108
- * entity key for general) without affecting the match key.
14171
+ * (`describePerRecordNotification` for perRecord, the title or else the
14172
+ * `code` for reminder, the entity key for general) without affecting the
14173
+ * match key.
14109
14174
  */
14110
14175
  function entryLabel(entry) {
14111
14176
  const value = entry.local ?? entry.remote ?? entry.base;
14112
14177
  if (entry.key.startsWith("perRecord:")) {
14113
14178
  const n = value;
14114
- return n ? n.title || n.filterCond || "(empty filter)" : entry.key;
14179
+ return n ? describePerRecordNotification(n) : entry.key;
14115
14180
  }
14116
14181
  if (entry.key.startsWith("reminder:")) {
14117
14182
  const n = value;
@@ -14994,14 +15059,15 @@ var capture_default$6 = createCaptureCommand({
14994
15059
  /**
14995
15060
  * Equality for two {@link ProcessManagementConfig} values, reusing the 2-way
14996
15061
  * diffDetector's "no changes" semantics (`enable` + order-sensitive entity
14997
- * comparison for states/actions). Two configs are equal exactly when the
14998
- * detector reports no differences, so the whole-entity 3-way merge granularity
14999
- * matches `process diff`.
15062
+ * comparison for states/actions + the order of actions sharing a `from`).
15063
+ * Two configs are equal exactly when the detector reports no differences, so
15064
+ * the whole-entity 3-way merge granularity matches `process diff`.
15000
15065
  *
15001
15066
  * Note: `ProcessManagementDiffDetector.detect` is not symmetric in its output
15002
15067
  * text, but it IS symmetric in `isEmpty` — it enumerates added/modified/deleted
15003
- * over the union of state/action keys, so `detect(a, b).isEmpty` is true iff
15004
- * every key matches, regardless of argument order.
15068
+ * over the union of state/action keys and compares the order of the actions
15069
+ * present on both sides, so `detect(a, b).isEmpty` is true iff every key and
15070
+ * that order match, regardless of argument order.
15005
15071
  */
15006
15072
  function isProcessManagementConfigEqual(a, b) {
15007
15073
  return ProcessManagementDiffDetector.detect(a, b).isEmpty;
@@ -15765,9 +15831,9 @@ async function applyPulledGeneralSettingsMerge({ container, input }) {
15765
15831
  * mirrors that key strategy exactly — group by `filterCond`, then key each entry
15766
15832
  * by its group-local index (`filterCond#i`) — so it is record-keyed (not a
15767
15833
  * coarse ordered-list merge) and the per-entry granularity of `record-acl diff`
15768
- * is preserved (one entry change = one conflict). The `perRecordLabel`-style
15769
- * positional matching means a reordering within a filterCond is seen as content
15770
- * changes at those indices, matching the existing 2-way detector.
15834
+ * is preserved (one entry change = one conflict). The positional matching
15835
+ * means a reordering within a filterCond is seen as content changes at those
15836
+ * indices, matching the existing 2-way detector.
15771
15837
  */
15772
15838
  function compositeKey(filterCond, index) {
15773
15839
  return `${filterCond}#${index}`;
@@ -17534,7 +17600,8 @@ async function detectRecordPermissionThreeWayDiff({ container }) {
17534
17600
  diff: await detectRecordPermissionDiff({ container })
17535
17601
  };
17536
17602
  return buildRecordThreeWayDiff(computeRecordPermissionThreeWayMerge(state, local, remote.config), (entry) => {
17537
- return (entry.local ?? entry.remote ?? entry.base)?.filterCond ?? entry.key;
17603
+ const right = entry.local ?? entry.remote ?? entry.base;
17604
+ return right ? describeRecordPermissionFilter(right.filterCond) : entry.key;
17538
17605
  });
17539
17606
  }
17540
17607
  //#endregion