iobroker.eos-admin 9.0.35 → 9.0.38
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/NEXOWATT_EOS_BUILD_INFO.json +10 -13
- package/README.md +21 -3
- package/adminWww/.vite/manifest.json +114 -114
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13759 -13759
- package/adminWww/assets/{AdapterUpdateDialog-DH6S-kWX.js → AdapterUpdateDialog-D4gUYZep.js} +1 -1
- package/adminWww/assets/{Adapters-CIlqSF5B.js → Adapters-DLxiJc3y.js} +1 -1
- package/adminWww/assets/{ConfigManager-BhVBfM-q.js → ConfigManager-D_YTKUdP.js} +1 -1
- package/adminWww/assets/{Enums-3H97czGs.js → Enums-D79rON6b.js} +1 -1
- package/adminWww/assets/{Fields-vWLKiuvO.js → Fields-CTOv49EU.js} +1 -1
- package/adminWww/assets/{Files-wmjjMXYM.js → Files-DNLzjEG5.js} +1 -1
- package/adminWww/assets/{Hosts-Bk-xmI98.js → Hosts-DHNboUMq.js} +1 -1
- package/adminWww/assets/{Instances-Db6Vgh62.js → Instances-BJxYNJAC.js} +1 -1
- package/adminWww/assets/{Intro-Dc3wAG9V.js → Intro-8R-Q7CR_.js} +1 -1
- package/adminWww/assets/{Logs-CPbEGWNq.js → Logs-CjAPhWuK.js} +1 -1
- package/adminWww/assets/{Objects-DJB-2468.js → Objects-cvdqooGe.js} +1 -1
- package/adminWww/assets/{Overview-DdvghCLQ.js → Overview-JPfBOuKv.js} +1 -1
- package/adminWww/assets/{State-0UzpgKYj.js → State-CGnvMceJ.js} +1 -1
- package/adminWww/assets/{UsedResources-Bcmo58YD.js → UsedResources-FBd9jThR.js} +1 -1
- package/adminWww/assets/{Users-BGHf3Rox.js → Users-BbUu3hZj.js} +1 -1
- package/adminWww/assets/{bootstrap-qkrk_CAn.js → bootstrap-Df_WTIJg.js} +3 -3
- package/adminWww/assets/{hostInit-DlGqatlv.js → hostInit-BQCRqFay.js} +1 -1
- package/adminWww/assets/{icons-material-CUNq6tdT.js → icons-material-DS82xOs8.js} +1 -1
- package/adminWww/assets/{index-BrtKq3UN.js → index-BlBZd8r8.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-DujLjpXt.js → installSVGRenderer-BtlXF9y3.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-3e1cd85c.js → mf-entry-bootstrap-0-8bb11ea2.js} +2 -2
- package/adminWww/index.html +23 -23
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/remoteEntry-eos-9.0.38.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDashboardProcessStatus.js +11 -3
- package/build/lib/eosDashboardProcessStatus.js.map +1 -1
- package/build/lib/eosLegacyMigration.js +476 -92
- package/build/lib/eosLegacyMigration.js.map +1 -1
- package/build/lib/eosLegacySource.js +172 -0
- package/build/lib/eosLegacySource.js.map +1 -0
- package/build/lib/eosLicenseService.js +9 -0
- package/build/lib/eosLicenseService.js.map +1 -1
- package/build/lib/eosModuleConfigStore.js +21 -8
- package/build/lib/eosModuleConfigStore.js.map +1 -1
- package/build/lib/eosModuleHost.js +308 -104
- package/build/lib/eosModuleHost.js.map +1 -1
- package/build/lib/eosModuleHttp.js +77 -12
- package/build/lib/eosModuleHttp.js.map +1 -1
- package/build/lib/eosModuleProcess.js +17 -6
- package/build/lib/eosModuleProcess.js.map +1 -1
- package/build/lib/eosModuleProcessWorker.js +34 -1
- package/build/lib/eosModuleProcessWorker.js.map +1 -1
- package/build/lib/eosRuntimeControl.js +50 -14
- package/build/lib/eosRuntimeControl.js.map +1 -1
- package/build/lib/eosRuntimeHealth.js +35 -7
- package/build/lib/eosRuntimeHealth.js.map +1 -1
- package/build/lib/eosSupervisorNotifications.js +1 -1
- package/build/lib/eosSupervisorNotifications.js.map +1 -1
- package/build/lib/eosUiProcess.js +42 -4
- package/build/lib/eosUiProcess.js.map +1 -1
- package/build/lib/eosUiProcessWorker.js +21 -0
- package/build/lib/eosUiProcessWorker.js.map +1 -1
- package/build/lib/eosUnifiedOwnership.js +10 -8
- package/build/lib/eosUnifiedOwnership.js.map +1 -1
- package/build/lib/web.js +28 -24
- package/build/lib/web.js.map +1 -1
- package/build/main.js +36 -1
- package/build/main.js.map +1 -1
- package/docs/README.md +3 -0
- package/docs/reports/unified-9.0.36/MIGRATION.md +25 -0
- package/docs/reports/unified-9.0.36/PRUEFBERICHT.md +61 -0
- package/docs/reports/unified-9.0.36/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.36/raw/INDEX.json +262 -0
- package/docs/reports/unified-9.0.36/raw/admin-934-legacy-ui-reproduction.json +66 -0
- package/docs/reports/unified-9.0.36/raw/admin-936-legacy-ui-reproduction.json +64 -0
- package/docs/reports/unified-9.0.36/raw/admin-health-browser22.json +49 -0
- package/docs/reports/unified-9.0.36/raw/admin-health-browser24.json +49 -0
- package/docs/reports/unified-9.0.36/raw/admin-runtime-migration-browser22.json +80 -0
- package/docs/reports/unified-9.0.36/raw/admin-runtime-migration-browser24.json +80 -0
- package/docs/reports/unified-9.0.36/raw/backend.log +6 -0
- package/docs/reports/unified-9.0.36/raw/core-final-node22.log +1439 -0
- package/docs/reports/unified-9.0.36/raw/core-final-node24.log +1381 -0
- package/docs/reports/unified-9.0.36/raw/customer-934-node22-final.log +78 -0
- package/docs/reports/unified-9.0.36/raw/customer-934-node22-repeat.log +78 -0
- package/docs/reports/unified-9.0.36/raw/customer-935-node24-final.log +74 -0
- package/docs/reports/unified-9.0.36/raw/customer-935-node24-repeat.log +74 -0
- package/docs/reports/unified-9.0.36/raw/customer-admin-six-controls24.log +24 -0
- package/docs/reports/unified-9.0.36/raw/customer-earlier-pid-stop.log +22 -0
- package/docs/reports/unified-9.0.36/raw/customer-six-process-restart-node22.log +28 -0
- package/docs/reports/unified-9.0.36/raw/customer-six-process-restart-node24.log +24 -0
- package/docs/reports/unified-9.0.36/raw/dashboard-de-en-nl.json +728 -0
- package/docs/reports/unified-9.0.36/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.36/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.36/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.36/raw/legacy-migration-node22.log +630 -0
- package/docs/reports/unified-9.0.36/raw/legacy-migration-node24.log +109 -0
- package/docs/reports/unified-9.0.36/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.36/raw/module-standby-drain22.log +446 -0
- package/docs/reports/unified-9.0.36/raw/module-standby-drain24.log +80 -0
- package/docs/reports/unified-9.0.36/raw/module-standby-linux-memory.log +6 -0
- package/docs/reports/unified-9.0.36/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.36/raw/node22-migration.log +1329 -0
- package/docs/reports/unified-9.0.36/raw/node22-mira.log +222 -0
- package/docs/reports/unified-9.0.36/raw/node22-system-status.log +225 -0
- package/docs/reports/unified-9.0.36/raw/node22-tests-final.log +18358 -0
- package/docs/reports/unified-9.0.36/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.36/raw/node24-migration.log +1301 -0
- package/docs/reports/unified-9.0.36/raw/node24-mira.log +41 -0
- package/docs/reports/unified-9.0.36/raw/node24-system-status.log +42 -0
- package/docs/reports/unified-9.0.36/raw/node24-tests-final.log +3058 -0
- package/docs/reports/unified-9.0.36/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.36/raw/npm-runtime-audit.json +77 -0
- package/docs/reports/unified-9.0.36/raw/ocpp-owner-isolation22.log +109 -0
- package/docs/reports/unified-9.0.36/raw/ocpp-owner-isolation24.log +24 -0
- package/docs/reports/unified-9.0.36/raw/qa-source-check.log +2 -0
- package/docs/reports/unified-9.0.36/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.36/raw/sbom.log +9 -0
- package/docs/reports/unified-9.0.36/raw/standby-independent-drain.log +4 -0
- package/docs/reports/unified-9.0.36/raw/standby-independent-sockets.log +3 -0
- package/docs/reports/unified-9.0.36/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.36/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.37/PRUEFBERICHT.md +59 -0
- package/docs/reports/unified-9.0.37/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.37/raw/INDEX.json +232 -0
- package/docs/reports/unified-9.0.37/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.37/raw/core-final-node22.log +1439 -0
- package/docs/reports/unified-9.0.37/raw/core-final-node24.log +1381 -0
- package/docs/reports/unified-9.0.37/raw/dashboard-935-screenshot.json +15 -0
- package/docs/reports/unified-9.0.37/raw/dashboard-de-en-nl.json +1059 -0
- package/docs/reports/unified-9.0.37/raw/ems-ui-nvp-integration.json +245 -0
- package/docs/reports/unified-9.0.37/raw/farm-and-dashboard-935.json +11 -0
- package/docs/reports/unified-9.0.37/raw/farm-tracking-source-tests.log +80 -0
- package/docs/reports/unified-9.0.37/raw/fixtures-verification.log +39 -0
- package/docs/reports/unified-9.0.37/raw/frontend.log +160 -0
- package/docs/reports/unified-9.0.37/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.37/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.37/raw/measure-storage-display.cjs +47 -0
- package/docs/reports/unified-9.0.37/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.37/raw/node22-isolated-start-deadlines.log +28 -0
- package/docs/reports/unified-9.0.37/raw/node22-migration.log +1329 -0
- package/docs/reports/unified-9.0.37/raw/node22-mira.log +222 -0
- package/docs/reports/unified-9.0.37/raw/node22-parallel-initial.log +13278 -0
- package/docs/reports/unified-9.0.37/raw/node22-startzeiten.json +21 -0
- package/docs/reports/unified-9.0.37/raw/node22-system-status.log +639 -0
- package/docs/reports/unified-9.0.37/raw/node22-tests-final.log +18494 -0
- package/docs/reports/unified-9.0.37/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.37/raw/node24-migration.log +1301 -0
- package/docs/reports/unified-9.0.37/raw/node24-mira.log +41 -0
- package/docs/reports/unified-9.0.37/raw/node24-system-status.log +111 -0
- package/docs/reports/unified-9.0.37/raw/node24-tests-final.log +3080 -0
- package/docs/reports/unified-9.0.37/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.37/raw/npm-runtime-audit.json +77 -0
- package/docs/reports/unified-9.0.37/raw/platform-acl-node22.log +98 -0
- package/docs/reports/unified-9.0.37/raw/platform-acl-node24.log +22 -0
- package/docs/reports/unified-9.0.37/raw/platform-nginx-node22.json +21 -0
- package/docs/reports/unified-9.0.37/raw/platform-nginx-node24.json +21 -0
- package/docs/reports/unified-9.0.37/raw/qa-source-check.log +2 -0
- package/docs/reports/unified-9.0.37/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.37/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.37/raw/speicher-warnschwelle-integration.json +172 -0
- package/docs/reports/unified-9.0.37/raw/sse-backpressure-9.0.35.log +1 -0
- package/docs/reports/unified-9.0.37/raw/sse-backpressure-9.0.37.log +1 -0
- package/docs/reports/unified-9.0.37/raw/storage-display-memory-node22.json +19 -0
- package/docs/reports/unified-9.0.37/raw/storage-display-memory-node24.json +19 -0
- package/docs/reports/unified-9.0.37/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.37/raw/ui-runtime.log +7 -0
- package/docs/reports/unified-9.0.38/PRUEFBERICHT.md +51 -0
- package/docs/reports/unified-9.0.38/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.38/raw/INDEX.json +272 -0
- package/docs/reports/unified-9.0.38/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.38/raw/core-final-node22.log +1439 -0
- package/docs/reports/unified-9.0.38/raw/core-final-node24.log +1381 -0
- package/docs/reports/unified-9.0.38/raw/dashboard-de-en-nl.json +1044 -0
- package/docs/reports/unified-9.0.38/raw/field-upgrade-936-node22.log +21 -0
- package/docs/reports/unified-9.0.38/raw/field-upgrade-936-node24.log +10 -0
- package/docs/reports/unified-9.0.38/raw/fixtures-verification.log +39 -0
- package/docs/reports/unified-9.0.38/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.38/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.38/raw/legacy-historian-provenance.json +44 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-built-influx.log +10 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-misbinding-937.log +1 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-providers-node22.log +326 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-providers-node24.log +58 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-real-influx.log +10 -0
- package/docs/reports/unified-9.0.38/raw/legacy-history-source-comparison.json +12 -0
- package/docs/reports/unified-9.0.38/raw/legacy-template-interfaces.json +21 -0
- package/docs/reports/unified-9.0.38/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.38/raw/migration-admin-browser-node22.log +86 -0
- package/docs/reports/unified-9.0.38/raw/migration-admin-browser-node24.log +84 -0
- package/docs/reports/unified-9.0.38/raw/migration-live-children-node22.log +20 -0
- package/docs/reports/unified-9.0.38/raw/migration-live-children-node24.log +9 -0
- package/docs/reports/unified-9.0.38/raw/migration-process-admin-node22.log +831 -0
- package/docs/reports/unified-9.0.38/raw/migration-process-admin-node24.log +144 -0
- package/docs/reports/unified-9.0.38/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.38/raw/node22-initial-destination-channel.log +13298 -0
- package/docs/reports/unified-9.0.38/raw/node22-migration.log +1443 -0
- package/docs/reports/unified-9.0.38/raw/node22-mira.log +222 -0
- package/docs/reports/unified-9.0.38/raw/node22-system-status.log +639 -0
- package/docs/reports/unified-9.0.38/raw/node22-tests-final.log +18620 -0
- package/docs/reports/unified-9.0.38/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.38/raw/node24-migration.log +1411 -0
- package/docs/reports/unified-9.0.38/raw/node24-mira.log +41 -0
- package/docs/reports/unified-9.0.38/raw/node24-system-status.log +111 -0
- package/docs/reports/unified-9.0.38/raw/node24-tests-final.log +3102 -0
- package/docs/reports/unified-9.0.38/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.38/raw/npm-runtime-audit.json +77 -0
- package/docs/reports/unified-9.0.38/raw/platform-acl-node22.log +98 -0
- package/docs/reports/unified-9.0.38/raw/platform-acl-node24.log +22 -0
- package/docs/reports/unified-9.0.38/raw/platform-nginx-node22.json +21 -0
- package/docs/reports/unified-9.0.38/raw/platform-nginx-node24.json +21 -0
- package/docs/reports/unified-9.0.38/raw/qa-source-check.log +2 -0
- package/docs/reports/unified-9.0.38/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.38/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.38/raw/source-shape-node22.log +438 -0
- package/docs/reports/unified-9.0.38/raw/source-shape-node24.log +78 -0
- package/docs/reports/unified-9.0.38/raw/target-owner-bootstrap-node22.log +509 -0
- package/docs/reports/unified-9.0.38/raw/target-owner-bootstrap-node24.log +92 -0
- package/docs/reports/unified-9.0.38/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.38/raw/ui-runtime.log +7 -0
- package/docs/start/START_HIER_9.0.36.md +32 -0
- package/docs/start/START_HIER_9.0.37.md +38 -0
- package/docs/start/START_HIER_9.0.38.md +21 -0
- package/docs/unified/ARCHITECTURE.md +6 -0
- package/docs/unified/BESTANDSUEBERNAHME_9_0_7.md +2 -0
- package/docs/unified/DEVELOPMENT_FINDINGS.md +3 -1
- package/docs/unified/SECURITY_CRA.md +6 -0
- package/io-package.json +16 -16
- package/package.json +10 -4
- package/public/eos-migration/index.html +11 -4
- package/public/eos-migration/index.js +176 -22
- package/public/eos-runtime/index.js +82 -15
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +343 -174
- package/release-manifests/unified/frontend.cdx.json +6 -6
- package/release-manifests/unified/installer.cdx.json +6 -6
- package/release-manifests/unified/obsolete-admin-assets.json +249 -0
- package/release-manifests/unified/runtime.cdx.json +26 -26
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +1 -1
- package/ui/ems/modules/para14a.js +8 -3
- package/ui/ems/modules/storage-control.js +10 -5
- package/ui/io-package.json +13 -1
- package/ui/lib/hosted-startup-status.js +2 -2
- package/ui/lib/notification-mail.js +95 -8
- package/ui/main.js +339 -21
- package/ui/package.json +1 -1
- package/ui/www/app.js +48 -18
- package/ui/www/dashboard-process-status.js +7 -4
- package/ui/www/i18n/en.json +16 -0
- package/ui/www/i18n/nl.json +16 -0
- package/ui/www/licenses/smarthome-markdown-components.json +156 -156
- package/ui/www/live-display.js +154 -31
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/storagefarm-dispatch.js +59 -8
- package/ui/www/storagefarm-summary.css +3 -1
- package/ui/www/storagefarm.html +2 -0
- package/adminWww/remoteEntry-eos-9.0.35.js +0 -12
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* Copyright (c) 2026 NexoWatt. Confidential and proprietary. */
|
|
2
2
|
'use strict';
|
|
3
|
-
const { createHash } = require('node:crypto');
|
|
3
|
+
const { createHash, randomUUID } = require('node:crypto');
|
|
4
4
|
const { join } = require('node:path');
|
|
5
5
|
const { setTimeout: delay } = require('node:timers/promises');
|
|
6
6
|
const { performance } = require('node:perf_hooks');
|
|
7
|
-
const { isDeepStrictEqual } = require('node:util');
|
|
8
7
|
const { EosModuleConfigStore } = require('./eosModuleConfigStore');
|
|
9
8
|
const SOURCES = Object.freeze({ ui: 'nexowatt-ui', devices: 'nexowatt-devices', eebus: 'eebus', backup: 'nexowatt-backup', ocpp: 'ocpp21' });
|
|
10
9
|
const VERSIONS = Object.freeze({ ui: ['1.0.35', '1.0.36', '1.0.37', '1.0.38'], devices: ['0.5.176'], eebus: ['0.3.0'], backup: ['1.0.10'], ocpp: ['0.4.2', '0.4.3'] });
|
|
10
|
+
const { ownPlaceholder, containsCustomerSettings, cleanVersion, sourceMetadata, sourceIdentity, schemaDriven, validJournalSource, uiShape, devicesShape } = require('./eosLegacySource');
|
|
11
11
|
const ACL = { owner: 'system.user.admin', ownerGroup: 'system.group.administrator', object: 0x600, state: 0x600 };
|
|
12
12
|
const HOST_MAX_AGE_MS = 60000;
|
|
13
13
|
const STARTUP_WINDOW_MS = 45000;
|
|
@@ -37,6 +37,34 @@ function copy(value) {
|
|
|
37
37
|
}
|
|
38
38
|
const fingerprint = value => createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
39
39
|
const nativeHash = object => fingerprint(object.native);
|
|
40
|
+
const reviewStamp = object => fingerprint([object.common?.enabled, object.common?.host, object.common?.version, record(object.native) ? nativeHash(object) : null]);
|
|
41
|
+
/**
|
|
42
|
+
* A later config/metadata edit can postdate a long-disabled UI. For a local
|
|
43
|
+
* noncompact daemon, js-controller resets sigKill before launch, records its PID,
|
|
44
|
+
* requests a stop with -1, and reports alive=false on exit. The latter must
|
|
45
|
+
* follow the same host's most recent lifecycle marker. Callers check host freshness.
|
|
46
|
+
*/
|
|
47
|
+
async function hasConfirmedLegacyStop(reader, object, alive) {
|
|
48
|
+
if (object?.common?.enabled !== false || alive?.val !== false || alive.ack !== true ||
|
|
49
|
+
!Number.isSafeInteger(object.ts) || !Number.isSafeInteger(alive.ts) || alive.ts <= 0 || object.ts <= 0)
|
|
50
|
+
return false;
|
|
51
|
+
const moment = Date.now();
|
|
52
|
+
if (alive.ts > moment + 5000 || object.ts > moment + 5000 || (alive.q ?? 0) !== 0)
|
|
53
|
+
return false;
|
|
54
|
+
if (alive.ts >= object.ts)
|
|
55
|
+
return true;
|
|
56
|
+
const host = object.common.host;
|
|
57
|
+
if (!/^system\.adapter\.nexowatt-ui\.\d+$/.test(object._id || '') ||
|
|
58
|
+
object.common.mode !== 'daemon' || object.common.runAsCompactMode === true ||
|
|
59
|
+
typeof host !== 'string' || !host || host !== reader.host || alive.from !== `system.host.${host}`)
|
|
60
|
+
return false;
|
|
61
|
+
const marker = await reader.getForeignStateAsync(`${object._id}.sigKill`);
|
|
62
|
+
if (!marker || marker.from !== alive.from || !Number.isSafeInteger(marker.ts) || marker.ts <= 0 ||
|
|
63
|
+
marker.ts >= alive.ts || (marker.q ?? 0) !== 0)
|
|
64
|
+
return false;
|
|
65
|
+
return (marker.ack === true && Number.isSafeInteger(marker.val) && marker.val > 0 && marker.val <= 2147483647) ||
|
|
66
|
+
(marker.ack === false && marker.val === -1);
|
|
67
|
+
}
|
|
40
68
|
function decryptNative(owner, object) {
|
|
41
69
|
const native = copy(object.native);
|
|
42
70
|
const protectedFields = object.protectedNative || object.common?.protectedNative || [];
|
|
@@ -87,6 +115,13 @@ class EosLegacyMigration {
|
|
|
87
115
|
this.startupBlocked = false;
|
|
88
116
|
this.recovery = null;
|
|
89
117
|
this.commitPromise = null;
|
|
118
|
+
this.blockedSources = null;
|
|
119
|
+
this.manualRevision = randomUUID();
|
|
120
|
+
this.operation = { state: 'idle', code: '' };
|
|
121
|
+
this.manualPending = null;
|
|
122
|
+
this.manualScopes = null;
|
|
123
|
+
this.manuallyAllowed = null;
|
|
124
|
+
this.uiSaves = 0;
|
|
90
125
|
}
|
|
91
126
|
read(operation) {
|
|
92
127
|
let timer;
|
|
@@ -94,11 +129,22 @@ class EosLegacyMigration {
|
|
|
94
129
|
timer = setTimeout(() => reject(fail('EOS_MIGRATION_DATABASE_TIMEOUT')), Math.min(this.options.readTimeoutMs || 5000, 5000));
|
|
95
130
|
})]).finally(() => clearTimeout(timer));
|
|
96
131
|
}
|
|
97
|
-
allowsStartup() {
|
|
98
|
-
|
|
99
|
-
|
|
132
|
+
allowsStartup(scope) {
|
|
133
|
+
if (this.stopped || this.startupBlocked)
|
|
134
|
+
return false;
|
|
135
|
+
const id = scope === 'ems' ? 'ui' : scope;
|
|
136
|
+
if (id !== undefined && !Object.hasOwn(SOURCES, id))
|
|
137
|
+
return false;
|
|
138
|
+
if (this.manualScopes)
|
|
139
|
+
return id !== undefined && !this.manualScopes.has(id) && this.manuallyAllowed.has(id);
|
|
140
|
+
if (this.phase === 'BLOCKED' && this.blockedSources && id !== undefined)
|
|
141
|
+
return !this.blockedSources.has(id);
|
|
142
|
+
return ['DISABLED', 'NOT_NEEDED', 'TRANSFERRED', 'COMMITTED'].includes(this.phase);
|
|
100
143
|
}
|
|
101
|
-
|
|
144
|
+
allowsSupervisorStartup() {
|
|
145
|
+
return this.allowsStartup() || (!this.stopped && !this.startupBlocked && this.phase === 'BLOCKED' && this.blockedSources !== null);
|
|
146
|
+
}
|
|
147
|
+
allowsWrites(scope) { return this.allowsStartup(scope); }
|
|
102
148
|
block(code) { this.phase = 'ROLLBACK_REQUIRED'; this.journal = { ...this.journal, code: code || this.journal?.code || 'EOS_MIGRATION_RECOVERY_REQUIRED' }; }
|
|
103
149
|
envelope(value, migration) {
|
|
104
150
|
const text = JSON.stringify(copy(value));
|
|
@@ -118,6 +164,8 @@ class EosLegacyMigration {
|
|
|
118
164
|
}
|
|
119
165
|
}
|
|
120
166
|
async persist(phase) {
|
|
167
|
+
if (this.manualPending && this.stopped)
|
|
168
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
121
169
|
this.phase = phase;
|
|
122
170
|
this.journal = { ...this.journal, v: 1, owner: this.owner.namespace, phase, updatedAt: Date.now() };
|
|
123
171
|
await this.store.save('migration', this.envelope(this.journal));
|
|
@@ -140,11 +188,13 @@ class EosLegacyMigration {
|
|
|
140
188
|
try {
|
|
141
189
|
const license = this.owner.eosLicenseService?.statusView?.();
|
|
142
190
|
if (license?.valid === true && license.coreEnabled === true)
|
|
143
|
-
code = 'EOS_MIGRATION_RESTART_REQUIRED';
|
|
191
|
+
code = this.owner.eosRuntimeControl ? 'EOS_MIGRATION_REVIEW_READY' : 'EOS_MIGRATION_RESTART_REQUIRED';
|
|
144
192
|
}
|
|
145
193
|
catch { /* Diagnostic reads never grant permission or expose license internals. */ }
|
|
146
194
|
}
|
|
147
|
-
return { phase: this.phase, code, sources: (this.journal?.sources || []).map(row => ({ id: row.id, source: row.source,
|
|
195
|
+
return { phase: this.phase, code, sources: (this.journal?.sources || []).map(row => ({ id: row.id, source: row.source,
|
|
196
|
+
...Object.fromEntries(['sourceVersion', 'instanceVersion', 'adapterVersion', 'versionCode', 'enabled', 'targetEnabled'].filter(field => Object.hasOwn(row, field)).map(field => [field, row[field]])), namespacePreserved: ['TRANSFERRED', 'COMMITTED'].includes(this.phase) })), updatedAt: this.journal?.updatedAt || null,
|
|
197
|
+
...(this.phase === 'BLOCKED' && this.blockedSources && this.journal?.issues?.length ? { issues: this.journal.issues.map(row => ({ id: row.id, source: row.source, code: row.code })) } : {}) };
|
|
148
198
|
}
|
|
149
199
|
async loadDestinations() {
|
|
150
200
|
for (const id of Object.keys(SOURCES)) {
|
|
@@ -178,6 +228,17 @@ class EosLegacyMigration {
|
|
|
178
228
|
}
|
|
179
229
|
}
|
|
180
230
|
async saveUi(value) {
|
|
231
|
+
if (this.manualPending && this.phase !== 'TRANSFERRED')
|
|
232
|
+
throw fail('EOS_MIGRATION_BUSY');
|
|
233
|
+
this.uiSaves++;
|
|
234
|
+
try {
|
|
235
|
+
await this.persistUi(value);
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
this.uiSaves--;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
async persistUi(value) {
|
|
181
242
|
const config = copy(value);
|
|
182
243
|
// Host TLS, authentication and licensing are never restored from an old UI.
|
|
183
244
|
for (const key of ['licenseKey', 'auth', 'port', 'secure', 'certPublic', 'certPrivate', 'certChained', 'bind'])
|
|
@@ -194,65 +255,138 @@ class EosLegacyMigration {
|
|
|
194
255
|
async stoppedSource(source) {
|
|
195
256
|
const object = await this.reader.getForeignObjectAsync(`system.adapter.${source}`);
|
|
196
257
|
const alive = await this.reader.getForeignStateAsync(`system.adapter.${source}.alive`);
|
|
197
|
-
return
|
|
258
|
+
return await hasConfirmedLegacyStop(this.reader, object, alive) && await this.hostFresh(object.common.host);
|
|
259
|
+
}
|
|
260
|
+
async checkUiDestination() {
|
|
261
|
+
const defaults = require(join(this.options.baseDir, 'io-package.json')).native.eosUi || {};
|
|
262
|
+
if (containsCustomerSettings(this.owner.config.eosUi || {}, defaults))
|
|
263
|
+
throw fail('EOS_MIGRATION_DESTINATION_CONFIGURED');
|
|
264
|
+
const namespace = this.owner.namespace;
|
|
265
|
+
const state = await this.reader.getForeignStateAsync(namespace + '.installer.configJson');
|
|
266
|
+
if (state && state.val != null && state.val !== '') {
|
|
267
|
+
if (typeof state.val !== 'string' || Buffer.byteLength(state.val) > 512 * 1024)
|
|
268
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
269
|
+
let patch;
|
|
270
|
+
try {
|
|
271
|
+
patch = copy(JSON.parse(state.val));
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
275
|
+
}
|
|
276
|
+
if (!record(patch) || containsCustomerSettings(patch, defaults))
|
|
277
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
278
|
+
}
|
|
279
|
+
for (const channel of ['smarthome', 'ems', 'chargepoints', 'energyFlow', 'historie']) {
|
|
280
|
+
const id = namespace + '.' + channel;
|
|
281
|
+
const object = await this.reader.getForeignObjectAsync(id);
|
|
282
|
+
// Historic state objects may be restored without a parent folder.
|
|
283
|
+
if (!object && channel !== 'historie')
|
|
284
|
+
continue;
|
|
285
|
+
if (object && !ownPlaceholder(namespace, channel, object))
|
|
286
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
287
|
+
const prefix = id + '.';
|
|
288
|
+
const result = await this.reader.getObjectViewAsync('system', 'state', { startkey: prefix, endkey: prefix + '\u9999', limit: 513 });
|
|
289
|
+
if (!Array.isArray(result?.rows) || result.rows.length > 512)
|
|
290
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
291
|
+
for (const entry of result.rows) {
|
|
292
|
+
const leaf = entry.value;
|
|
293
|
+
if (leaf?.type !== 'state' || !leaf._id?.startsWith(prefix))
|
|
294
|
+
continue;
|
|
295
|
+
if (channel !== 'historie' || Object.entries(leaf.common?.custom || {}).some(([provider, cfg]) => /^(?:influxdb|sql|history|postgresql)\.\d+$/.test(provider) && record(cfg) &&
|
|
296
|
+
(cfg.enabled === true || typeof cfg.aliasId === 'string' && cfg.aliasId.trim())))
|
|
297
|
+
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
async readUiSource(source, requiredStates) {
|
|
302
|
+
const { readPreservedUiStates } = require(join(this.options.baseDir, 'ui/lib/preserved-ui-config'));
|
|
303
|
+
const states = await readPreservedUiStates(this.reader, source, requiredStates);
|
|
304
|
+
const patch = states.values['installer.configJson'];
|
|
305
|
+
if (patch)
|
|
306
|
+
uiShape(patch, {}, true);
|
|
307
|
+
return states;
|
|
198
308
|
}
|
|
199
|
-
|
|
200
|
-
|
|
309
|
+
async readSourceMetadata(id, object) {
|
|
310
|
+
const name = SOURCES[id];
|
|
311
|
+
sourceIdentity(name, object, true);
|
|
312
|
+
const metadata = await this.reader.getForeignObjectAsync('system.adapter.' + name);
|
|
313
|
+
if (metadata)
|
|
314
|
+
sourceIdentity(name, metadata, false);
|
|
315
|
+
return sourceMetadata(object, metadata);
|
|
201
316
|
}
|
|
202
|
-
async
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
317
|
+
async matchesSource(object, row) {
|
|
318
|
+
if (object?.type !== 'instance' || object._id !== 'system.adapter.' + row.source || !record(object.native) ||
|
|
319
|
+
nativeHash(object) !== row.nativeHash || object.common?.host !== row.host)
|
|
320
|
+
return false;
|
|
321
|
+
if (row.schemaVerified !== true)
|
|
322
|
+
return object.common.version === row.sourceVersion;
|
|
323
|
+
if ((object.common.name !== undefined && object.common.name !== SOURCES[row.id]) ||
|
|
324
|
+
cleanVersion(object.common.version) !== row.instanceVersion)
|
|
325
|
+
return false;
|
|
326
|
+
// Only a handover which used the adapter object's version depends on it.
|
|
327
|
+
// Never use a newly installed local version as a witness for the old source.
|
|
328
|
+
if (row.instanceVersion !== null || row.adapterVersion === null)
|
|
329
|
+
return true;
|
|
330
|
+
const metadata = await this.readSourceMetadata(row.id, object);
|
|
331
|
+
return metadata.adapterVersion === row.adapterVersion;
|
|
332
|
+
}
|
|
333
|
+
async candidate(id, object, activateDevices = false, metadata) {
|
|
334
|
+
metadata ??= await this.readSourceMetadata(id, object);
|
|
335
|
+
if (!schemaDriven(id) && !VERSIONS[id]?.includes(metadata.instanceVersion))
|
|
336
|
+
throw fail('EOS_MIGRATION_MODULE_FORMAT_UNVERIFIED');
|
|
337
|
+
if (!record(object.native) || typeof object.common.enabled !== 'boolean')
|
|
338
|
+
throw fail('EOS_MIGRATION_SOURCE_UNAVAILABLE');
|
|
207
339
|
const source = object._id.slice('system.adapter.'.length);
|
|
208
340
|
if (id !== 'ui' && this.owner.eosLicenseService?.allowsEmbeddedModule?.(id) !== true)
|
|
209
341
|
throw fail('EOS_MIGRATION_MODULE_LICENSE_REQUIRED');
|
|
210
342
|
const ownerObject = await this.reader.getForeignObjectAsync(`system.adapter.${this.owner.namespace}`);
|
|
211
343
|
if (ownerObject?.common?.enabled !== true || !ownerObject.common.host || object.common.host !== ownerObject.common.host || !(await this.hostFresh(object.common.host)))
|
|
212
344
|
throw fail('EOS_MIGRATION_SOURCE_HOST');
|
|
345
|
+
// An already stopped source can supply its configuration without reviving it.
|
|
346
|
+
// Prove its stop before any journal is created or another source is touched.
|
|
347
|
+
if (object.common.enabled === false && !(await this.stoppedSource(source)))
|
|
348
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
213
349
|
const existing = await this.read(this.store.load(id));
|
|
214
350
|
if (existing)
|
|
215
351
|
throw fail('EOS_MIGRATION_DESTINATION_CONFIGURED');
|
|
216
|
-
if (id === 'ui')
|
|
217
|
-
|
|
218
|
-
if (!isDeepStrictEqual(this.owner.config.eosUi || {}, defaults))
|
|
219
|
-
throw fail('EOS_MIGRATION_DESTINATION_CONFIGURED');
|
|
220
|
-
for (const channel of ['smarthome', 'ems', 'chargepoints', 'energyFlow']) {
|
|
221
|
-
if (await this.reader.getForeignObjectAsync(`${this.owner.namespace}.${channel}`))
|
|
222
|
-
throw fail('EOS_MIGRATION_DESTINATION_STATES');
|
|
223
|
-
}
|
|
224
|
-
}
|
|
352
|
+
if (id === 'ui')
|
|
353
|
+
await this.checkUiDestination();
|
|
225
354
|
const config = decryptNative(this.owner, object);
|
|
226
355
|
let prepared;
|
|
356
|
+
const targetEnabled = object.common.enabled || (id === 'devices' && activateDevices === true);
|
|
227
357
|
if (id === 'ui') {
|
|
228
|
-
const
|
|
229
|
-
|
|
358
|
+
const uiDefaults = require(join(this.options.baseDir, 'ui/io-package.json')).native;
|
|
359
|
+
uiShape(config, uiDefaults);
|
|
360
|
+
const states = await this.readUiSource(source);
|
|
230
361
|
prepared = { config: { ...config }, requiredStates: states.requiredStates };
|
|
231
362
|
for (const key of ['licenseKey', 'auth', 'port', 'secure', 'certPublic', 'certPrivate', 'certChained', 'bind'])
|
|
232
363
|
delete prepared.config[key];
|
|
233
364
|
}
|
|
234
365
|
else {
|
|
366
|
+
if (id === 'devices')
|
|
367
|
+
devicesShape(config);
|
|
235
368
|
const factory = this.options.factories?.[id] || require(join(this.options.baseDir, 'modules', id, 'index.js'));
|
|
236
369
|
if (typeof factory.preflightLegacyConfig === 'function')
|
|
237
370
|
prepared = await factory.preflightLegacyConfig(config, {
|
|
238
|
-
owner: this.reader, source, sourceVersion:
|
|
371
|
+
owner: this.reader, source, sourceVersion: metadata.sourceVersion, sourceEnabled: object.common.enabled,
|
|
239
372
|
dataDir: join(this.options.dataDir, 'modules', id), eosDataDir: this.options.dataDir, installationDir: this.options.installationDir,
|
|
240
373
|
});
|
|
241
374
|
else if (id === 'devices')
|
|
242
375
|
prepared = { config: factory.validateConfig({ ...config, enabled: object.common.enabled === true }) };
|
|
243
376
|
else
|
|
244
377
|
throw fail('EOS_MIGRATION_PREFLIGHT_UNAVAILABLE');
|
|
245
|
-
prepared.config.enabled =
|
|
378
|
+
prepared.config.enabled = targetEnabled;
|
|
246
379
|
prepared.config = factory.validateConfig(prepared.config);
|
|
247
380
|
}
|
|
248
381
|
if (!record(prepared?.config))
|
|
249
382
|
throw fail('EOS_MIGRATION_CONFIG_INVALID');
|
|
250
|
-
const migration = { source, sourceVersion:
|
|
383
|
+
const migration = { source, sourceVersion: metadata.sourceVersion, preserveNamespace: true,
|
|
251
384
|
importedAt: new Date().toISOString(), statesCopied: false, mappingsRewritten: false,
|
|
252
385
|
...(id === 'ui' ? { requiredStates: prepared.requiredStates } : {}),
|
|
253
386
|
identityImported: prepared.identityImported === true, omittedFields: id === 'ui' ? ['host transport/authentication/license fields'] : [] };
|
|
254
387
|
return { id, source, enabled: object.common.enabled === true, nativeHash: nativeHash(object),
|
|
255
|
-
host: object.common.host,
|
|
388
|
+
host: object.common.host, ...metadata, ...(schemaDriven(id) ? { schemaVerified: true } : {}),
|
|
389
|
+
...(id === 'devices' && targetEnabled !== object.common.enabled ? { targetEnabled } : {}), envelope: this.envelope(prepared.config, migration),
|
|
256
390
|
prepareFiles: prepared.prepareFiles };
|
|
257
391
|
}
|
|
258
392
|
async rollback(code, stopConfirmed = false) {
|
|
@@ -263,7 +397,7 @@ class EosLegacyMigration {
|
|
|
263
397
|
// Called before any new runtime exists or after confirmed complete shutdown.
|
|
264
398
|
for (const row of this.journal.sources || []) {
|
|
265
399
|
const current = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
266
|
-
if (!this.matchesSource(current, row)) {
|
|
400
|
+
if (!(await this.matchesSource(current, row))) {
|
|
267
401
|
await this.persist('ROLLBACK_REQUIRED');
|
|
268
402
|
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
269
403
|
}
|
|
@@ -273,7 +407,11 @@ class EosLegacyMigration {
|
|
|
273
407
|
// Recheck the exact source immediately before each re-enable. The
|
|
274
408
|
// controller API is not a compare-and-swap transaction; never reuse
|
|
275
409
|
// a previous loop's source/version/host decision.
|
|
276
|
-
if (!this.matchesSource(current, row)) {
|
|
410
|
+
if (!(await this.matchesSource(current, row))) {
|
|
411
|
+
await this.persist('ROLLBACK_REQUIRED');
|
|
412
|
+
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
413
|
+
}
|
|
414
|
+
if (!row.enabled && !(await this.stoppedSource(row.source))) {
|
|
277
415
|
await this.persist('ROLLBACK_REQUIRED');
|
|
278
416
|
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
279
417
|
}
|
|
@@ -285,7 +423,7 @@ class EosLegacyMigration {
|
|
|
285
423
|
const checks = await Promise.all((this.journal.sources || []).filter(row => row.enabled).map(async (row) => {
|
|
286
424
|
const object = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
287
425
|
const alive = await this.reader.getForeignStateAsync(`system.adapter.${row.source}.alive`);
|
|
288
|
-
return this.matchesSource(object, row) && object.common.enabled === true && alive?.val === true && alive.ack === true && alive.ts >= object.ts && await this.hostFresh(row.host);
|
|
426
|
+
return await this.matchesSource(object, row) && object.common.enabled === true && alive?.val === true && alive.ack === true && alive.ts >= object.ts && await this.hostFresh(row.host);
|
|
289
427
|
}));
|
|
290
428
|
if (checks.every(Boolean))
|
|
291
429
|
break;
|
|
@@ -317,15 +455,180 @@ class EosLegacyMigration {
|
|
|
317
455
|
throw error;
|
|
318
456
|
}
|
|
319
457
|
}
|
|
458
|
+
async readInventory(inspectVersions = false) {
|
|
459
|
+
const observed = [], issues = [], proof = [];
|
|
460
|
+
// Inventory every participating family before releasing any independent scope.
|
|
461
|
+
// OCPP has an explicit manual import and a separate live ownership check.
|
|
462
|
+
for (const [id, name] of Object.entries(SOURCES)) {
|
|
463
|
+
if (id === 'ocpp')
|
|
464
|
+
continue;
|
|
465
|
+
const found = await this.reader.getObjectViewAsync('system', 'instance', { startkey: `system.adapter.${name}.`, endkey: `system.adapter.${name}.\u9999` });
|
|
466
|
+
if (!Array.isArray(found?.rows) || found.rows.length > 64)
|
|
467
|
+
throw fail('EOS_MIGRATION_INVENTORY');
|
|
468
|
+
const seen = new Set();
|
|
469
|
+
for (const row of found.rows) {
|
|
470
|
+
const sourceId = row.value?._id;
|
|
471
|
+
if (row.value?.type !== 'instance' || !new RegExp(`^system\\.adapter\\.${name}\\.\\d+$`).test(sourceId || '') || seen.has(sourceId))
|
|
472
|
+
throw fail('EOS_MIGRATION_INVENTORY');
|
|
473
|
+
seen.add(sourceId);
|
|
474
|
+
proof.push([sourceId, reviewStamp(row.value)]);
|
|
475
|
+
const source = sourceId.slice('system.adapter.'.length);
|
|
476
|
+
let metadata = sourceMetadata(row.value, null);
|
|
477
|
+
if (inspectVersions) {
|
|
478
|
+
try {
|
|
479
|
+
metadata = await this.readSourceMetadata(id, row.value);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
issues.push({ id, source, code: safeCode(error) });
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
observed.push({ id, source, ...metadata });
|
|
486
|
+
if (found.rows.length > 1)
|
|
487
|
+
issues.push({ id, source, code: 'EOS_MIGRATION_AMBIGUOUS' });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
proof.sort((a, b) => a[0].localeCompare(b[0]));
|
|
491
|
+
return { observed, issues, stamps: new Map(proof), signature: fingerprint(proof) };
|
|
492
|
+
}
|
|
493
|
+
async manualReview() {
|
|
494
|
+
const view = this.manualView();
|
|
495
|
+
if (!view.canStart)
|
|
496
|
+
return this.status();
|
|
497
|
+
if (this.reviewPending)
|
|
498
|
+
return this.reviewPending;
|
|
499
|
+
this.reviewPending = this.readInventory(true).then(inventory => {
|
|
500
|
+
if (this.manualPending || this.stopped || !this.manualView().canStart)
|
|
501
|
+
return this.status();
|
|
502
|
+
if (this.review?.signature !== inventory.signature)
|
|
503
|
+
this.manualRevision = randomUUID();
|
|
504
|
+
this.review = inventory;
|
|
505
|
+
const status = this.status();
|
|
506
|
+
const sources = inventory.observed.map(row => ({ ...row, namespacePreserved: false }));
|
|
507
|
+
const issues = [...inventory.issues];
|
|
508
|
+
for (const prior of status.issues || []) {
|
|
509
|
+
if (sources.some(row => row.source === prior.source) && !issues.some(row => row.source === prior.source && row.code === prior.code))
|
|
510
|
+
issues.push(prior);
|
|
511
|
+
}
|
|
512
|
+
return { ...status, sources, issues };
|
|
513
|
+
}).finally(() => { this.reviewPending = null; });
|
|
514
|
+
return this.reviewPending;
|
|
515
|
+
}
|
|
516
|
+
manualView() {
|
|
517
|
+
const license = this.owner.eosLicenseService?.statusView?.();
|
|
518
|
+
const selectable = !this.stopped && !this.startupBlocked && !this.manualPending &&
|
|
519
|
+
['BLOCKED', 'NOT_NEEDED', 'DISABLED', 'LICENSE_REQUIRED'].includes(this.phase);
|
|
520
|
+
const canStart = selectable && license?.valid === true && license.coreEnabled === true;
|
|
521
|
+
return { canStart, canActivateDevices: canStart && (this.review?.observed || []).some(row => row.id === 'devices' && row.enabled === false),
|
|
522
|
+
revision: this.manualRevision, operation: { ...this.operation } };
|
|
523
|
+
}
|
|
524
|
+
requestManual(activateDevices, revision, confirmAuthority) {
|
|
525
|
+
const view = this.manualView();
|
|
526
|
+
if (this.manualPending || this.owner.eosRuntimeControl?.pending || this.owner.eosModuleHost?.configurationSavePromise || this.owner.eosModuleHost?.mutation || this.uiSaves) {
|
|
527
|
+
throw fail('EOS_MIGRATION_BUSY');
|
|
528
|
+
}
|
|
529
|
+
if (!view.canStart || !this.owner.eosRuntimeControl || !this.owner.eosModuleHost || !this.owner.eosHostedRuntime)
|
|
530
|
+
throw fail('EOS_MIGRATION_ACTION_UNAVAILABLE');
|
|
531
|
+
if (!this.review || typeof revision !== 'string' || revision !== this.manualRevision)
|
|
532
|
+
throw fail('EOS_MIGRATION_REVISION_CONFLICT');
|
|
533
|
+
if (typeof activateDevices !== 'boolean' || (activateDevices && !view.canActivateDevices))
|
|
534
|
+
throw fail('EOS_MIGRATION_REQUEST_INVALID');
|
|
535
|
+
this.manualRevision = randomUUID();
|
|
536
|
+
this.operation = { state: 'running', code: '' };
|
|
537
|
+
this.manualPending = Promise.resolve().then(async () => {
|
|
538
|
+
await this.prepare({ activateDevices, signature: this.review.signature, confirmAuthority });
|
|
539
|
+
if (this.phase === 'TRANSFERRED') {
|
|
540
|
+
await this.releaseLiveTargets(true);
|
|
541
|
+
await this.verifyRuntime();
|
|
542
|
+
}
|
|
543
|
+
else if (this.manualScopes)
|
|
544
|
+
await this.releaseLiveTargets(false);
|
|
545
|
+
if (this.stopped)
|
|
546
|
+
return;
|
|
547
|
+
const ok = ['COMMITTED', 'NOT_NEEDED'].includes(this.phase);
|
|
548
|
+
this.operation = { state: ok ? 'complete' : 'failed', code: ok ? '' : this.status().code || 'EOS_MIGRATION_FAILED' };
|
|
549
|
+
}).catch(async (error) => {
|
|
550
|
+
const code = safeCode(error);
|
|
551
|
+
if (this.phase === 'TRANSFERRED')
|
|
552
|
+
await this.failStartup(code);
|
|
553
|
+
// A failed drain must not restore write authority. Before any journal was
|
|
554
|
+
// created, all old sources are still intact; the affected targets stay gated.
|
|
555
|
+
if (this.manualScopes) {
|
|
556
|
+
const heldIds = [...this.manualScopes].filter(id => id !== 'ui');
|
|
557
|
+
this.blockedSources = new Set(this.manualScopes);
|
|
558
|
+
if (!this.journal?.phase && !this.stopped) {
|
|
559
|
+
this.phase = 'BLOCKED';
|
|
560
|
+
this.journal = { sources: this.journal?.sources || [], code };
|
|
561
|
+
}
|
|
562
|
+
this.manualScopes = null;
|
|
563
|
+
this.manuallyAllowed = null;
|
|
564
|
+
await this.owner.eosModuleHost?.releaseMigrationModules(heldIds, false).catch(() => { });
|
|
565
|
+
}
|
|
566
|
+
if (code === 'EOS_MIGRATION_JOURNAL_PRESENT')
|
|
567
|
+
this.block(code);
|
|
568
|
+
this.operation = { state: 'failed', code };
|
|
569
|
+
this.owner.log.warn(`EOS_MIGRATION_MANUAL_FAILED: ${code}`);
|
|
570
|
+
if (!this.stopped)
|
|
571
|
+
await this.publish();
|
|
572
|
+
}).finally(() => { this.manualPending = null; this.review = null; });
|
|
573
|
+
}
|
|
574
|
+
async confirmManualAuthority(manual, candidates) {
|
|
575
|
+
const permitted = await Promise.resolve().then(() => manual.confirmAuthority()).catch(() => false);
|
|
576
|
+
if (permitted !== true || this.stopped)
|
|
577
|
+
throw fail('EOS_MIGRATION_AUTHORIZATION_CHANGED');
|
|
578
|
+
const license = this.owner.eosLicenseService?.statusView?.();
|
|
579
|
+
if (license?.valid !== true || license.coreEnabled !== true)
|
|
580
|
+
throw fail('EOS_MIGRATION_LICENSE_REQUIRED');
|
|
581
|
+
if (candidates.some(row => row.id !== 'ui' && this.owner.eosLicenseService.allowsEmbeddedModule?.(row.id) !== true)) {
|
|
582
|
+
throw fail('EOS_MIGRATION_MODULE_LICENSE_REQUIRED');
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
async holdLiveTargets(candidates) {
|
|
586
|
+
const owner = this.owner;
|
|
587
|
+
const ids = candidates.map(row => row.id);
|
|
588
|
+
if (owner.eosRuntimeControl.pending || owner.eosModuleHost.configurationSavePromise || owner.eosModuleHost.mutation || this.uiSaves || this.stopped)
|
|
589
|
+
throw fail('EOS_MIGRATION_BUSY');
|
|
590
|
+
this.manuallyAllowed = new Set(Object.keys(SOURCES).filter(id => this.allowsStartup(id)));
|
|
591
|
+
this.manualScopes = new Set(ids);
|
|
592
|
+
const tasks = [owner.eosModuleHost.holdMigrationModules(ids.filter(id => id !== 'ui'))];
|
|
593
|
+
if (this.manualScopes.has('ui'))
|
|
594
|
+
tasks.push(owner.eosHostedRuntime.pause(), owner.eosHostedRuntime.pauseEms());
|
|
595
|
+
const settled = await Promise.allSettled(tasks);
|
|
596
|
+
if (settled.some(result => result.status === 'rejected') || this.stopped)
|
|
597
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
598
|
+
}
|
|
599
|
+
async releaseLiveTargets(transferred) {
|
|
600
|
+
if (!this.manualScopes || this.stopped)
|
|
601
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
602
|
+
const owner = this.owner;
|
|
603
|
+
const ids = [...this.manualScopes];
|
|
604
|
+
await owner.eosModuleHost.releaseMigrationModules(ids.filter(id => id !== 'ui'), transferred);
|
|
605
|
+
this.manualScopes = null;
|
|
606
|
+
this.manuallyAllowed = null;
|
|
607
|
+
if (!transferred)
|
|
608
|
+
return;
|
|
609
|
+
await owner.eosOwnership.refresh();
|
|
610
|
+
if (ids.includes('ui')) {
|
|
611
|
+
const jobs = [];
|
|
612
|
+
if (owner.eosRuntimeControl.isEnabled('ui'))
|
|
613
|
+
jobs.push(owner.eosHostedRuntime.resume());
|
|
614
|
+
if (owner.eosRuntimeControl.isEnabled('ems'))
|
|
615
|
+
jobs.push(owner.eosHostedRuntime.resumeEms());
|
|
616
|
+
await Promise.all(jobs);
|
|
617
|
+
}
|
|
618
|
+
await owner.eosModuleHost.start();
|
|
619
|
+
await owner.eosModuleHost.reconcile();
|
|
620
|
+
}
|
|
320
621
|
async checkLegacyRpc(candidates) {
|
|
321
622
|
const sources = new Set(candidates.map(row => row.source));
|
|
322
623
|
const inventory = await this.reader.getObjectViewAsync('system', 'instance', { startkey: 'system.adapter.', endkey: 'system.adapter.\u9999' });
|
|
323
624
|
if (!Array.isArray(inventory?.rows) || inventory.rows.length > 512)
|
|
324
625
|
throw fail('EOS_MIGRATION_RPC_INVENTORY');
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
626
|
+
const referenced = new Set();
|
|
627
|
+
const checkReferences = value => {
|
|
628
|
+
if (typeof value === 'string' && sources.has(value))
|
|
629
|
+
referenced.add(value);
|
|
630
|
+
if (value && typeof value === 'object')
|
|
631
|
+
Object.values(value).forEach(checkReferences);
|
|
329
632
|
};
|
|
330
633
|
for (const row of inventory.rows) {
|
|
331
634
|
const object = row.value;
|
|
@@ -335,8 +638,7 @@ class EosLegacyMigration {
|
|
|
335
638
|
}
|
|
336
639
|
if (!object?._id || object._id === `system.adapter.${this.owner.namespace}` || sources.has(object._id.slice('system.adapter.'.length)) || object.common?.enabled !== true)
|
|
337
640
|
continue;
|
|
338
|
-
|
|
339
|
-
throw fail('EOS_MIGRATION_EXTERNAL_RPC_REFERENCE');
|
|
641
|
+
checkReferences(copy(object.native || {}));
|
|
340
642
|
}
|
|
341
643
|
const scripts = await this.reader.getObjectViewAsync('system', 'script', { startkey: 'script.', endkey: 'script.\u9999' });
|
|
342
644
|
if (!Array.isArray(scripts?.rows) || scripts.rows.length > 5000)
|
|
@@ -348,18 +650,25 @@ class EosLegacyMigration {
|
|
|
348
650
|
const text = script.common.source;
|
|
349
651
|
if (typeof text !== 'string' || Buffer.byteLength(text) > 2 * 1024 * 1024)
|
|
350
652
|
throw fail('EOS_MIGRATION_SCRIPT_REVIEW');
|
|
351
|
-
if (text.includes('sendTo')
|
|
352
|
-
|
|
653
|
+
if (text.includes('sendTo'))
|
|
654
|
+
for (const source of sources)
|
|
655
|
+
if (text.includes(source))
|
|
656
|
+
referenced.add(source);
|
|
353
657
|
}
|
|
658
|
+
return referenced;
|
|
354
659
|
}
|
|
355
|
-
async prepare() {
|
|
356
|
-
|
|
660
|
+
async prepare(manual = null) {
|
|
661
|
+
if (!manual)
|
|
662
|
+
await this.loadDestinations();
|
|
357
663
|
const prior = await this.read(this.store.load('migration'));
|
|
358
664
|
if (prior) {
|
|
665
|
+
// Only adapter startup may recover a journal that predates this process.
|
|
666
|
+
if (manual)
|
|
667
|
+
throw fail('EOS_MIGRATION_JOURNAL_PRESENT');
|
|
359
668
|
const journal = this.decode(prior);
|
|
360
669
|
if (journal.v !== 1 || journal.owner !== this.owner.namespace || !['PREPARED', 'STOPPING', 'TRANSFERRED', 'COMMITTED', 'ROLLING_BACK', 'ROLLBACK_REQUIRED', 'ROLLED_BACK'].includes(journal.phase) ||
|
|
361
670
|
(journal.runtimeStopConfirmed !== undefined && typeof journal.runtimeStopConfirmed !== 'boolean') ||
|
|
362
|
-
!Array.isArray(journal.sources) || journal.sources.length > Object.keys(SOURCES).length || new Set(journal.sources.map(row => row
|
|
671
|
+
!Array.isArray(journal.sources) || journal.sources.length > Object.keys(SOURCES).length || new Set(journal.sources.map(row => row?.id)).size !== journal.sources.length || journal.sources.some(row => !validJournalSource(row, SOURCES, VERSIONS)))
|
|
363
672
|
throw fail('EOS_MIGRATION_JOURNAL_INVALID');
|
|
364
673
|
this.journal = journal;
|
|
365
674
|
this.phase = journal.phase;
|
|
@@ -381,7 +690,7 @@ class EosLegacyMigration {
|
|
|
381
690
|
await this.publish();
|
|
382
691
|
return;
|
|
383
692
|
}
|
|
384
|
-
if (this.owner.config.eosAutoMigrate === false) {
|
|
693
|
+
if (!manual && this.owner.config.eosAutoMigrate === false) {
|
|
385
694
|
this.phase = 'DISABLED';
|
|
386
695
|
return;
|
|
387
696
|
}
|
|
@@ -397,62 +706,100 @@ class EosLegacyMigration {
|
|
|
397
706
|
}
|
|
398
707
|
const candidates = [];
|
|
399
708
|
const observed = [];
|
|
709
|
+
const issues = [];
|
|
400
710
|
try {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
711
|
+
const inventory = await this.readInventory();
|
|
712
|
+
observed.push(...inventory.observed);
|
|
713
|
+
issues.push(...inventory.issues);
|
|
714
|
+
if (manual && inventory.signature !== manual.signature)
|
|
715
|
+
throw fail('EOS_MIGRATION_INVENTORY_CHANGED');
|
|
716
|
+
if (!observed.length) {
|
|
717
|
+
this.journal = null;
|
|
718
|
+
this.blockedSources = null;
|
|
719
|
+
this.phase = 'NOT_NEEDED';
|
|
720
|
+
await this.publish();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
// An incomplete/global inventory or another EOS affects every writer.
|
|
724
|
+
// A reference to a known source is attributable to that handover only.
|
|
725
|
+
const referenced = await this.checkLegacyRpc(observed);
|
|
726
|
+
for (const row of observed)
|
|
727
|
+
if (referenced.has(row.source))
|
|
728
|
+
issues.push({ ...row, code: 'EOS_MIGRATION_EXTERNAL_RPC_REFERENCE' });
|
|
729
|
+
for (const row of observed) {
|
|
730
|
+
if (issues.some(issue => issue.id === row.id))
|
|
413
731
|
continue;
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
732
|
+
try {
|
|
733
|
+
const sourceId = `system.adapter.${row.source}`;
|
|
734
|
+
const object = await this.reader.getForeignObjectAsync(sourceId);
|
|
735
|
+
if (object?.type !== 'instance' || object._id !== sourceId)
|
|
736
|
+
throw fail('EOS_MIGRATION_SOURCE_UNAVAILABLE');
|
|
737
|
+
if (manual && inventory.stamps.get(sourceId) !== reviewStamp(object))
|
|
738
|
+
throw fail('EOS_MIGRATION_INVENTORY_CHANGED');
|
|
739
|
+
Object.assign(row, await this.readSourceMetadata(row.id, object));
|
|
740
|
+
candidates.push(await this.candidate(row.id, object, manual?.activateDevices === true, row));
|
|
418
741
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
//
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (!candidates.length) {
|
|
433
|
-
this.phase = 'NOT_NEEDED';
|
|
434
|
-
// Replace a previous diagnostic-only BLOCKED state after the
|
|
435
|
-
// next successful inventory; do not persist a cutover journal.
|
|
742
|
+
catch (error) {
|
|
743
|
+
if (manual && error?.code === 'EOS_MIGRATION_INVENTORY_CHANGED')
|
|
744
|
+
throw error;
|
|
745
|
+
issues.push({ ...row, code: safeCode(error) });
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (issues.length) {
|
|
749
|
+
// The cutover remains atomic: no source from this group is stopped and
|
|
750
|
+
// none of their embedded counterparts may start on package defaults.
|
|
751
|
+
this.blockedSources = new Set(observed.map(row => row.id));
|
|
752
|
+
this.journal = { sources: observed, issues, code: issues[0].code };
|
|
753
|
+
this.phase = 'BLOCKED';
|
|
754
|
+
this.owner.log.warn(`EOS_MIGRATION_BLOCKED: ${issues[0].code}; existing adapters remain unchanged`);
|
|
436
755
|
await this.publish();
|
|
437
756
|
return;
|
|
438
757
|
}
|
|
439
|
-
await this.checkLegacyRpc(candidates);
|
|
440
758
|
}
|
|
441
759
|
catch (error) {
|
|
760
|
+
if (manual && error?.code === 'EOS_MIGRATION_INVENTORY_CHANGED')
|
|
761
|
+
throw error;
|
|
762
|
+
this.blockedSources = null;
|
|
442
763
|
this.phase = 'BLOCKED';
|
|
443
764
|
this.journal = { sources: observed, code: safeCode(error) };
|
|
444
765
|
this.owner.log.warn(`EOS_MIGRATION_BLOCKED: ${safeCode(error)}; existing adapters remain unchanged`);
|
|
445
766
|
await this.publish();
|
|
446
767
|
return;
|
|
447
768
|
}
|
|
448
|
-
|
|
769
|
+
if (manual) {
|
|
770
|
+
await this.confirmManualAuthority(manual, candidates);
|
|
771
|
+
await this.holdLiveTargets(candidates);
|
|
772
|
+
// Prove all candidates again after fencing the new processes. A slow
|
|
773
|
+
// clicked form or a finishing config save cannot bless a replaced source.
|
|
774
|
+
for (const row of candidates) {
|
|
775
|
+
if (manual && this.stopped)
|
|
776
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
777
|
+
const current = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
778
|
+
if (!(await this.matchesSource(current, row)) || current.common.enabled !== row.enabled)
|
|
779
|
+
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
780
|
+
if (await this.read(this.store.load(row.id)))
|
|
781
|
+
throw fail('EOS_MIGRATION_DESTINATION_CONFIGURED');
|
|
782
|
+
if (row.id === 'ui')
|
|
783
|
+
await this.checkUiDestination();
|
|
784
|
+
}
|
|
785
|
+
await this.confirmManualAuthority(manual, candidates);
|
|
786
|
+
}
|
|
787
|
+
this.journal = { sources: candidates.map(({ envelope: _envelope, prepareFiles: _files, ...binding }) => binding) };
|
|
449
788
|
await this.persist('PREPARED');
|
|
450
789
|
try {
|
|
451
790
|
await this.persist('STOPPING');
|
|
452
791
|
for (const row of candidates) {
|
|
792
|
+
if (manual && this.stopped)
|
|
793
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
453
794
|
const current = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
454
|
-
if (!this.matchesSource(current, row) || current.common.enabled !== row.enabled)
|
|
795
|
+
if (!(await this.matchesSource(current, row)) || current.common.enabled !== row.enabled)
|
|
455
796
|
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
797
|
+
if (manual && this.stopped)
|
|
798
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
799
|
+
if (row.id === 'ui') {
|
|
800
|
+
await this.checkUiDestination();
|
|
801
|
+
await this.readUiSource(row.source, row.envelope.migration.requiredStates);
|
|
802
|
+
}
|
|
456
803
|
if (row.enabled)
|
|
457
804
|
await this.owner.extendForeignObjectAsync(current._id, { common: { enabled: false } });
|
|
458
805
|
}
|
|
@@ -463,24 +810,41 @@ class EosLegacyMigration {
|
|
|
463
810
|
await delay(100);
|
|
464
811
|
}
|
|
465
812
|
for (const row of candidates) {
|
|
813
|
+
if (manual && this.stopped)
|
|
814
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
466
815
|
const current = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
467
|
-
if (!this.matchesSource(current, row))
|
|
816
|
+
if (!(await this.matchesSource(current, row)) || current.common.enabled !== false)
|
|
468
817
|
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
469
818
|
if (row.id === 'ui') {
|
|
819
|
+
await this.checkUiDestination();
|
|
470
820
|
// Recheck after confirmed stop: an in-flight old save may have
|
|
471
821
|
// changed the JSON after preflight. Never activate partial data.
|
|
472
|
-
const
|
|
473
|
-
const states = await readPreservedUiStates(this.reader, row.source, row.envelope.migration.requiredStates);
|
|
822
|
+
const states = await this.readUiSource(row.source, row.envelope.migration.requiredStates);
|
|
474
823
|
row.envelope.migration.requiredStates = states.requiredStates;
|
|
475
824
|
}
|
|
825
|
+
if (manual && this.stopped)
|
|
826
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
476
827
|
await row.prepareFiles?.();
|
|
828
|
+
if (manual && this.stopped)
|
|
829
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
477
830
|
await this.store.save(row.id, row.envelope);
|
|
478
831
|
}
|
|
832
|
+
// Recheck after file and asynchronous state reads, before granting write
|
|
833
|
+
// authority to the new runtimes. No disabled source gets enabled here.
|
|
834
|
+
for (const row of candidates) {
|
|
835
|
+
if (manual && this.stopped)
|
|
836
|
+
throw fail('EOS_MIGRATION_STOP_UNCONFIRMED');
|
|
837
|
+
const current = await this.reader.getForeignObjectAsync(`system.adapter.${row.source}`);
|
|
838
|
+
if (!(await this.matchesSource(current, row)) || !(await this.stoppedSource(row.source)))
|
|
839
|
+
throw fail('EOS_MIGRATION_SOURCE_CHANGED');
|
|
840
|
+
}
|
|
479
841
|
await this.persist('TRANSFERRED');
|
|
480
842
|
await this.loadDestinations();
|
|
481
843
|
this.owner.log.info('EOS_MIGRATION_TRANSFERRED: existing namespaces and settings retained; startup verification pending');
|
|
482
844
|
}
|
|
483
845
|
catch (error) {
|
|
846
|
+
if (manual && this.stopped)
|
|
847
|
+
throw error; // journal recovery belongs to the next owner
|
|
484
848
|
// prepare() has not allowed the caller to construct/start any new
|
|
485
849
|
// runtime yet; only configuration transfer has been attempted.
|
|
486
850
|
await this.rollback(safeCode(error), true);
|
|
@@ -549,7 +913,7 @@ class EosLegacyMigration {
|
|
|
549
913
|
}
|
|
550
914
|
}
|
|
551
915
|
async readiness(rows, deadline) {
|
|
552
|
-
const modules = await this.startupRead(Promise.all(rows.filter(row => row.id !== 'ui' && row.enabled)
|
|
916
|
+
const modules = await this.startupRead(Promise.all(rows.filter(row => row.id !== 'ui' && (row.targetEnabled ?? row.enabled))
|
|
553
917
|
.map(row => this.owner.eosModuleHost?.status(row.id))), deadline);
|
|
554
918
|
// Read these live values only after the asynchronous module snapshot.
|
|
555
919
|
const ui = this.owner.eosHostedRuntime?.status?.();
|
|
@@ -559,12 +923,31 @@ class EosLegacyMigration {
|
|
|
559
923
|
const devicesProgress = devices?.reason === 'STARTING' && startup?.pending === true &&
|
|
560
924
|
Number.isSafeInteger(startup.completedObjects) && startup.completedObjects > 0
|
|
561
925
|
? startup.completedObjects : 0;
|
|
926
|
+
const requiresUi = rows.some(row => row.id === 'ui');
|
|
927
|
+
const split = !!ui && (Object.hasOwn(ui, 'ems') || Object.hasOwn(ui, 'ui'));
|
|
928
|
+
const ems = split ? ui.ems : ui;
|
|
929
|
+
const intent = id => this.owner.eosRuntimeControl?.dashboardIntent?.(id);
|
|
930
|
+
const paused = id => {
|
|
931
|
+
const saved = intent(id);
|
|
932
|
+
return saved?.enabled === false && saved.error === '';
|
|
933
|
+
};
|
|
934
|
+
const stoppedChild = child => child?.process?.state === 'stopped' && child.process.pid === null && child.active === false;
|
|
935
|
+
// A disabled *source* is still a real handover. The target uses its own
|
|
936
|
+
// persisted process switches. An uninitialized runtime is never a user pause.
|
|
937
|
+
const emsReady = paused('ems') ? stoppedChild(ems) && ems.canWrite === false : ems?.emsReady === true && ems.canWrite === true;
|
|
938
|
+
const presentationReady = !split || (paused('ui') ? stoppedChild(ui.ui) : ui.ui?.active === true);
|
|
939
|
+
// During process construction the UI reports degraded even when the child
|
|
940
|
+
// is only starting. Only a terminal child error can end this wait early.
|
|
941
|
+
const childFailed = child => child?.process ? child.process.state === 'failed' : child?.state === 'degraded';
|
|
562
942
|
return {
|
|
563
943
|
devicesProgress,
|
|
564
|
-
ready: this.owner.eosOwnership?.canWrite(
|
|
565
|
-
|
|
566
|
-
modules.every(row => row?.active === true && row.reason === 'RUNNING')
|
|
567
|
-
|
|
944
|
+
ready: rows.every(row => this.owner.eosOwnership?.canWrite(row.id === 'ui' ? 'ems' : row.id) === true) &&
|
|
945
|
+
license?.valid === true && license.coreEnabled === true && (!requiresUi || (emsReady && presentationReady)) &&
|
|
946
|
+
modules.every(row => (row?.active === true && row.reason === 'RUNNING') ||
|
|
947
|
+
(row?.enabled === true && row.reason === 'EOS_RUNTIME_DISABLED' && row.active === false && paused(row.id))),
|
|
948
|
+
failed: (requiresUi && (childFailed(ems) || childFailed(ui?.ui))) ||
|
|
949
|
+
modules.some(row => /FAILED/.test(row?.reason || '') || (row?.reason === 'CONFIG_INVALID' &&
|
|
950
|
+
!!row.details?.configuration?.error && row.details.configuration.error !== 'EOS_MODULE_CONFIG_UNAVAILABLE')),
|
|
568
951
|
};
|
|
569
952
|
}
|
|
570
953
|
/** Start this monitor immediately after transfer, before any web startup. */
|
|
@@ -579,7 +962,7 @@ class EosLegacyMigration {
|
|
|
579
962
|
? Math.min(configuredWindow, STARTUP_WINDOW_MS) : STARTUP_WINDOW_MS;
|
|
580
963
|
const startedAt = performance.now();
|
|
581
964
|
let deadline = startedAt + startupWindow;
|
|
582
|
-
const hasDevices = this.journal.sources.some(row => row.id === 'devices' && row.enabled);
|
|
965
|
+
const hasDevices = this.journal.sources.some(row => row.id === 'devices' && (row.targetEnabled ?? row.enabled));
|
|
583
966
|
const absoluteDeadline = deadline + (hasDevices ? DEVICES_PROGRESS_ALLOWANCE_MS : 0);
|
|
584
967
|
let completedObjects = 0;
|
|
585
968
|
while (!this.stopped && !this.startupBlocked && performance.now() < deadline) {
|
|
@@ -627,7 +1010,8 @@ class EosLegacyMigration {
|
|
|
627
1010
|
return this.monitor;
|
|
628
1011
|
}
|
|
629
1012
|
stop() { this.stopped = true; }
|
|
1013
|
+
async whenManualIdle() { await this.manualPending; }
|
|
630
1014
|
}
|
|
631
1015
|
function safeCode(error) { return typeof error?.code === 'string' && /^[A-Z0-9_]{1,80}$/.test(error.code) ? error.code : 'EOS_MIGRATION_FAILED'; }
|
|
632
|
-
module.exports = { EosLegacyMigration, decryptNative };
|
|
1016
|
+
module.exports = { EosLegacyMigration, decryptNative, hasConfirmedLegacyStop };
|
|
633
1017
|
//# sourceMappingURL=eosLegacyMigration.js.map
|