kintone-migrator 0.34.1 → 0.34.3

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
@@ -6724,12 +6724,26 @@ async function applyPlugin({ container }) {
6724
6724
  if (!result.exists) throw new ValidationError(ValidationErrorCode.InvalidInput, "Plugin config file not found");
6725
6725
  const config = parsePluginConfigText(container.configCodec, result.content);
6726
6726
  const current = await container.pluginConfigurator.getPlugins();
6727
- const currentIds = new Set(current.plugins.map((p) => p.id));
6728
- const missingIds = config.plugins.map((p) => p.id).filter((id) => !currentIds.has(id));
6729
- if (missingIds.length > 0) await container.pluginConfigurator.addPlugins({
6730
- ids: missingIds,
6727
+ const remoteById = new Map(current.plugins.map((p) => [p.id, p]));
6728
+ const idsToAdd = [];
6729
+ const skipped = [];
6730
+ for (const plugin of config.plugins) {
6731
+ const remote = remoteById.get(plugin.id);
6732
+ if (plugin.enabled) {
6733
+ if (remote === void 0) idsToAdd.push(plugin.id);
6734
+ } else if (remote === void 0 || remote.enabled) skipped.push({
6735
+ pluginId: plugin.id,
6736
+ reason: "disabled"
6737
+ });
6738
+ }
6739
+ if (idsToAdd.length > 0) await container.pluginConfigurator.addPlugins({
6740
+ ids: idsToAdd,
6731
6741
  revision: current.revision
6732
6742
  });
6743
+ return {
6744
+ addedPluginIds: idsToAdd,
6745
+ skipped
6746
+ };
6733
6747
  }
6734
6748
  //#endregion
6735
6749
  //#region src/core/domain/processManagement/services/configParser.ts
@@ -7428,6 +7442,7 @@ function buildPhases$1(args) {
7428
7442
  storageExists: async () => (await c.schema.schemaStorage.get()).exists,
7429
7443
  run: async () => {
7430
7444
  await executeMigration({ container: c.schema });
7445
+ return [];
7431
7446
  }
7432
7447
  }]
7433
7448
  },
@@ -7441,12 +7456,14 @@ function buildPhases$1(args) {
7441
7456
  container: c.customization,
7442
7457
  input: { basePath: args.customizeBasePath }
7443
7458
  });
7459
+ return [];
7444
7460
  }
7445
7461
  }, {
7446
7462
  domain: "view",
7447
7463
  storageExists: async () => (await c.view.viewStorage.get()).exists,
7448
7464
  run: async () => {
7449
7465
  await applyView({ container: c.view });
7466
+ return [];
7450
7467
  }
7451
7468
  }]
7452
7469
  },
@@ -7458,6 +7475,7 @@ function buildPhases$1(args) {
7458
7475
  storageExists: async () => (await c.fieldPermission.fieldPermissionStorage.get()).exists,
7459
7476
  run: async () => {
7460
7477
  await applyFieldPermission({ container: c.fieldPermission });
7478
+ return [];
7461
7479
  }
7462
7480
  },
7463
7481
  {
@@ -7465,6 +7483,7 @@ function buildPhases$1(args) {
7465
7483
  storageExists: async () => (await c.appPermission.appPermissionStorage.get()).exists,
7466
7484
  run: async () => {
7467
7485
  await applyAppPermission({ container: c.appPermission });
7486
+ return [];
7468
7487
  }
7469
7488
  },
7470
7489
  {
@@ -7472,6 +7491,7 @@ function buildPhases$1(args) {
7472
7491
  storageExists: async () => (await c.recordPermission.recordPermissionStorage.get()).exists,
7473
7492
  run: async () => {
7474
7493
  await applyRecordPermission({ container: c.recordPermission });
7494
+ return [];
7475
7495
  }
7476
7496
  }
7477
7497
  ]
@@ -7484,6 +7504,7 @@ function buildPhases$1(args) {
7484
7504
  storageExists: async () => (await c.settings.generalSettingsStorage.get()).exists,
7485
7505
  run: async () => {
7486
7506
  await applyGeneralSettings({ container: c.settings });
7507
+ return [];
7487
7508
  }
7488
7509
  },
7489
7510
  {
@@ -7491,6 +7512,7 @@ function buildPhases$1(args) {
7491
7512
  storageExists: async () => (await c.notification.notificationStorage.get()).exists,
7492
7513
  run: async () => {
7493
7514
  await applyNotification({ container: c.notification });
7515
+ return [];
7494
7516
  }
7495
7517
  },
7496
7518
  {
@@ -7498,6 +7520,7 @@ function buildPhases$1(args) {
7498
7520
  storageExists: async () => (await c.report.reportStorage.get()).exists,
7499
7521
  run: async () => {
7500
7522
  await applyReport({ container: c.report });
7523
+ return [];
7501
7524
  }
7502
7525
  },
7503
7526
  {
@@ -7505,6 +7528,7 @@ function buildPhases$1(args) {
7505
7528
  storageExists: async () => (await c.action.actionStorage.get()).exists,
7506
7529
  run: async () => {
7507
7530
  await applyAction({ container: c.action });
7531
+ return [];
7508
7532
  }
7509
7533
  },
7510
7534
  {
@@ -7512,6 +7536,7 @@ function buildPhases$1(args) {
7512
7536
  storageExists: async () => (await c.process.processManagementStorage.get()).exists,
7513
7537
  run: async () => {
7514
7538
  await applyProcessManagement({ container: c.process });
7539
+ return [];
7515
7540
  }
7516
7541
  },
7517
7542
  {
@@ -7519,13 +7544,19 @@ function buildPhases$1(args) {
7519
7544
  storageExists: async () => (await c.adminNotes.adminNotesStorage.get()).exists,
7520
7545
  run: async () => {
7521
7546
  await applyAdminNotes({ container: c.adminNotes });
7547
+ return [];
7522
7548
  }
7523
7549
  },
7524
7550
  {
7525
7551
  domain: "plugin",
7526
7552
  storageExists: async () => (await c.plugin.pluginStorage.get()).exists,
7527
7553
  run: async () => {
7528
- await applyPlugin({ container: c.plugin });
7554
+ const disabled = (await applyPlugin({ container: c.plugin })).skipped.map((s) => s.pluginId);
7555
+ if (disabled.length === 0) return [];
7556
+ return [{
7557
+ domain: "plugin",
7558
+ message: `enabled: false is not supported by the kintone plugin API (add-only; cannot disable); handle in the kintone admin UI: ${disabled.join(", ")}`
7559
+ }];
7529
7560
  }
7530
7561
  }
7531
7562
  ]
@@ -7540,6 +7571,7 @@ function buildPhases$1(args) {
7540
7571
  container: c.seed,
7541
7572
  input: {}
7542
7573
  });
7574
+ return [];
7543
7575
  }
7544
7576
  }]
7545
7577
  }
@@ -7575,11 +7607,12 @@ async function executeSchemaPhase$1(phase, containers, state) {
7575
7607
  continue;
7576
7608
  }
7577
7609
  try {
7578
- await task.run();
7610
+ const warnings = await task.run();
7579
7611
  await deployApp({ container: containers.schema });
7580
7612
  results.push({
7581
7613
  domain: task.domain,
7582
- success: true
7614
+ success: true,
7615
+ warnings
7583
7616
  });
7584
7617
  } catch (error) {
7585
7618
  const err = toError$2(error);
@@ -7620,10 +7653,11 @@ async function executeStandardPhase$1(phase, state) {
7620
7653
  continue;
7621
7654
  }
7622
7655
  try {
7623
- await task.run();
7656
+ const warnings = await task.run();
7624
7657
  results.push({
7625
7658
  domain: task.domain,
7626
- success: true
7659
+ success: true,
7660
+ warnings
7627
7661
  });
7628
7662
  } catch (error) {
7629
7663
  const err = toError$2(error);
@@ -9974,6 +10008,7 @@ function printPhaseResult$1(phaseResult) {
9974
10008
  for (const result of phaseResult.results) {
9975
10009
  p.log.message(formatTaskResult$2(result));
9976
10010
  if (!result.success && !result.skipped) logError(result.error);
10011
+ if (result.success) for (const warning of result.warnings) p.log.warn(warning.message);
9977
10012
  }
9978
10013
  }
9979
10014
  function printApplyAllResults(output) {
@@ -13783,6 +13818,11 @@ var apply_default$6 = createApplyCommand({
13783
13818
  successMessage: "Plugins applied successfully.",
13784
13819
  createContainer: createPluginCliContainer,
13785
13820
  applyFn: applyPlugin,
13821
+ onResult: (result) => {
13822
+ if (result.addedPluginIds.length > 0) p.log.info(`Added plugins: ${result.addedPluginIds.join(", ")}`);
13823
+ const disabled = result.skipped.map((s) => s.pluginId);
13824
+ if (disabled.length > 0) p.log.warn(`enabled: false is not supported by the kintone plugin API (add-only; cannot disable); handle in the kintone admin UI: ${disabled.join(", ")}`);
13825
+ },
13786
13826
  diffPreview: {
13787
13827
  detectDiff: detectPluginDiff,
13788
13828
  printResult: printPluginDiffResult
@@ -14064,18 +14104,52 @@ var pull_default$7 = createPullCommand({
14064
14104
  /** Pull command name surfaced in the drift hint message. */
14065
14105
  const PLUGIN_PULL_COMMAND = "plugin pull";
14066
14106
  /**
14107
+ * Splits the local→remote diff into the ids that can actually be added
14108
+ * (`enabled: true`, missing on the remote) and the inexpressible ops surfaced
14109
+ * as `skipped`: `add-disabled` (`enabled: false`, missing), `delete` (remote
14110
+ * plugin absent locally), and `modify` (existing plugin with name/enabled
14111
+ * change).
14112
+ */
14113
+ function partitionPushOps(local, remoteById, localById, remotePlugins) {
14114
+ const idsToAdd = [];
14115
+ const skipped = [];
14116
+ for (const localPlugin of local.plugins) {
14117
+ const remotePlugin = remoteById.get(localPlugin.id);
14118
+ if (remotePlugin === void 0) if (localPlugin.enabled) idsToAdd.push(localPlugin.id);
14119
+ else skipped.push({
14120
+ pluginId: localPlugin.id,
14121
+ reason: "add-disabled"
14122
+ });
14123
+ else if (remotePlugin.name !== localPlugin.name || remotePlugin.enabled !== localPlugin.enabled) skipped.push({
14124
+ pluginId: localPlugin.id,
14125
+ reason: "modify"
14126
+ });
14127
+ }
14128
+ for (const remotePlugin of remotePlugins) if (!localById.has(remotePlugin.id)) skipped.push({
14129
+ pluginId: remotePlugin.id,
14130
+ reason: "delete"
14131
+ });
14132
+ return {
14133
+ idsToAdd,
14134
+ skipped
14135
+ };
14136
+ }
14137
+ /**
14067
14138
  * Applies the local plugin config to the remote with drift detection.
14068
14139
  *
14069
14140
  * The plugin API is **add-only**: `addPlugins` can only install a plugin id
14070
14141
  * that is not yet on the app. It has no remove API and cannot control the
14071
- * `enabled` flag (MEMORY: plugin-enabled-no-disable-api). So this push:
14142
+ * `enabled` flag. So this push:
14072
14143
  *
14073
14144
  * - Loads base/local/remote and rejects on drift (remoteOnly / conflict) unless
14074
14145
  * `--force`.
14075
- * - Adds only the plugin ids that are present locally but missing on the remote.
14076
- * - Surfaces every requested-but-inexpressible operation (a local deletion of a
14077
- * remote plugin, or a name/enabled change to an existing plugin) as a
14078
- * `skipped` warning instead of applying it the only inexpressible case.
14146
+ * - Adds only the `enabled: true` plugin ids that are present locally but
14147
+ * missing on the remote.
14148
+ * - Surfaces every requested-but-inexpressible operation as a `skipped` warning
14149
+ * instead of applying it: a local deletion of a remote plugin (`delete`), a
14150
+ * name/enabled change to an existing plugin (`modify`), and an `enabled: false`
14151
+ * plugin missing on the remote (`add-disabled`, since `addPlugins` would
14152
+ * force-enable it).
14079
14153
  *
14080
14154
  * The expected revision (the observed remote revision) is sent to `addPlugins`
14081
14155
  * as a TOCTOU guard on a normal push; `--force` / first run omit it. When there is nothing to add, the remote is not touched but
@@ -14095,19 +14169,7 @@ async function pushPlugin({ container, input }) {
14095
14169
  }
14096
14170
  const remoteById = new Map(remote.config.plugins.map((p) => [p.id, p]));
14097
14171
  const localById = new Map(local.plugins.map((p) => [p.id, p]));
14098
- const idsToAdd = local.plugins.filter((p) => !remoteById.has(p.id)).map((p) => p.id);
14099
- const skipped = [];
14100
- for (const remotePlugin of remote.config.plugins) if (!localById.has(remotePlugin.id)) skipped.push({
14101
- pluginId: remotePlugin.id,
14102
- reason: "delete"
14103
- });
14104
- for (const localPlugin of local.plugins) {
14105
- const remotePlugin = remoteById.get(localPlugin.id);
14106
- if (remotePlugin !== void 0 && (remotePlugin.name !== localPlugin.name || remotePlugin.enabled !== localPlugin.enabled)) skipped.push({
14107
- pluginId: localPlugin.id,
14108
- reason: "modify"
14109
- });
14110
- }
14172
+ const { idsToAdd, skipped } = partitionPushOps(local, remoteById, localById, remote.config.plugins);
14111
14173
  let newRevision = remote.revision;
14112
14174
  if (idsToAdd.length > 0) {
14113
14175
  const expectedRevision = input.force || firstTime ? void 0 : remote.revision;
@@ -14150,8 +14212,10 @@ var plugin_default = define({
14150
14212
  if (result.addedPluginIds.length > 0) p.log.info(`Added plugins: ${result.addedPluginIds.join(", ")}`);
14151
14213
  const deletions = result.skipped.filter((o) => o.reason === "delete").map((o) => o.pluginId);
14152
14214
  const modifications = result.skipped.filter((o) => o.reason === "modify").map((o) => o.pluginId);
14215
+ const addDisabled = result.skipped.filter((o) => o.reason === "add-disabled").map((o) => o.pluginId);
14153
14216
  if (deletions.length > 0) p.log.warn(`Cannot remove plugins via the kintone API (add-only); left on the app: ${deletions.join(", ")}`);
14154
14217
  if (modifications.length > 0) p.log.warn(`Cannot modify existing plugins (name/enabled) via the kintone API (add-only); unchanged: ${modifications.join(", ")}`);
14218
+ if (addDisabled.length > 0) p.log.warn(`Cannot add plugins in a disabled state via the kintone API (add-only; adding would force-enable them); not added — set enabled: false manually in the kintone admin UI: ${addDisabled.join(", ")}`);
14155
14219
  },
14156
14220
  resolveContainerConfig: resolvePluginContainerConfig,
14157
14221
  resolveAppContainerConfig: resolvePluginAppContainerConfig