@camstack/addon-pipeline-orchestrator 1.2.708 → 1.2.709
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/CHANGELOG.md +6 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-C_9hNznz.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-Cy30Rzqj.mjs} +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DNSPEN-1.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CmdMWHWD.mjs +26 -0
- package/dist/{hostInit-_VWK1zem.mjs → hostInit-wjkPXHbU.mjs} +2 -2
- package/dist/index.js +369 -22
- package/dist/index.mjs +369 -22
- package/dist/remoteEntry.js +1 -1
- package/package.json +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DbE7FiOY.mjs +0 -26
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C0FbsQqI.mjs +0 -26
package/dist/index.js
CHANGED
|
@@ -6154,7 +6154,7 @@ var ZodIssueCode = {
|
|
|
6154
6154
|
var ZodFirstPartyTypeKind;
|
|
6155
6155
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6156
6156
|
//#endregion
|
|
6157
|
-
//#region ../types/dist/runtime-capabilities-
|
|
6157
|
+
//#region ../types/dist/runtime-capabilities-ql3VRzQu.mjs
|
|
6158
6158
|
/**
|
|
6159
6159
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6160
6160
|
* window to float samples (D455).
|
|
@@ -6249,6 +6249,57 @@ var AddonMigrationsBlockedError = class extends Error {
|
|
|
6249
6249
|
this.migrationIds = migrationIds;
|
|
6250
6250
|
}
|
|
6251
6251
|
};
|
|
6252
|
+
var SWITCHES = /* @__PURE__ */ new Map();
|
|
6253
|
+
/** The ids the registry is known to hold a row for (hydrated, or told by the hub). */
|
|
6254
|
+
var ROWS = /* @__PURE__ */ new Set();
|
|
6255
|
+
/** The owner addon of an id, learned from its rows and from the helper that serves it. */
|
|
6256
|
+
var OWNER_OF = /* @__PURE__ */ new Map();
|
|
6257
|
+
/** The addons whose registry read answered at least once. */
|
|
6258
|
+
var ANSWERED = /* @__PURE__ */ new Set();
|
|
6259
|
+
/** The addons whose boot has begun reading the registry: only they can be held back. */
|
|
6260
|
+
var HYDRATING = /* @__PURE__ */ new Set();
|
|
6261
|
+
/**
|
|
6262
|
+
* The addons that serve an instance kind and have not been answered by the registry yet. Scoped
|
|
6263
|
+
* per owner: one addon's failed read never turns off another addon's instances, and an addon that
|
|
6264
|
+
* serves no instance kind never enters it.
|
|
6265
|
+
*/
|
|
6266
|
+
var PENDING = /* @__PURE__ */ new Set();
|
|
6267
|
+
/**
|
|
6268
|
+
* An addon's boot is about to read the registry for its rows. From now on, until the registry
|
|
6269
|
+
* answers, its served instance kinds (already built or built later in its boot) fail closed. A
|
|
6270
|
+
* helper used with no addon boot around it (a spec, a tool) is never held back.
|
|
6271
|
+
*/
|
|
6272
|
+
function beginHydration(ownerId) {
|
|
6273
|
+
if (ANSWERED.has(ownerId)) return;
|
|
6274
|
+
HYDRATING.add(ownerId);
|
|
6275
|
+
if (KINDS.has(ownerId)) PENDING.add(ownerId);
|
|
6276
|
+
}
|
|
6277
|
+
/** Whether `ownerId` still waits for the registry to answer (it serves a kind and has no rows yet). */
|
|
6278
|
+
function isHydrationPending(ownerId) {
|
|
6279
|
+
return PENDING.has(ownerId);
|
|
6280
|
+
}
|
|
6281
|
+
/** Record what the hub told: the registry holds a row of `id` in this state. */
|
|
6282
|
+
function recordRegistrySwitch(id, enabled) {
|
|
6283
|
+
SWITCHES.set(id, enabled);
|
|
6284
|
+
ROWS.add(id);
|
|
6285
|
+
}
|
|
6286
|
+
/** Seed the store from the registry rows of `ownerId`; the registry answered, so the owner is known. */
|
|
6287
|
+
function hydrateInstanceSwitches(ownerId, rows) {
|
|
6288
|
+
ANSWERED.add(ownerId);
|
|
6289
|
+
for (const row of rows) {
|
|
6290
|
+
recordRegistrySwitch(row.id, row.enabled);
|
|
6291
|
+
OWNER_OF.set(row.id, ownerId);
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
/** The addon's boot has built every instance kind and read the registry: unknown ids now read on. */
|
|
6295
|
+
function settleHydration(ownerId) {
|
|
6296
|
+
PENDING.delete(ownerId);
|
|
6297
|
+
}
|
|
6298
|
+
var KINDS = /* @__PURE__ */ new Map();
|
|
6299
|
+
/** The instance kinds announced for `ownerId` so far. */
|
|
6300
|
+
function servedInstanceKindsOf(ownerId) {
|
|
6301
|
+
return [...KINDS.get(ownerId)?.values() ?? []];
|
|
6302
|
+
}
|
|
6252
6303
|
/** Is this field's stored value a credential? */
|
|
6253
6304
|
function isSecretConfigField(field) {
|
|
6254
6305
|
if (field.type === "password") return true;
|
|
@@ -6938,6 +6989,32 @@ function switchRecordsOverMigrationApi(api) {
|
|
|
6938
6989
|
};
|
|
6939
6990
|
} };
|
|
6940
6991
|
}
|
|
6992
|
+
/** The record calls the body-to-registry switch migration makes, over the migration API. */
|
|
6993
|
+
function bodySwitchRecordsOverMigrationApi(api) {
|
|
6994
|
+
return { kind: (definition) => {
|
|
6995
|
+
const handle = api.records.kind(definition);
|
|
6996
|
+
return {
|
|
6997
|
+
query: async () => {
|
|
6998
|
+
const rows = [];
|
|
6999
|
+
let cursor;
|
|
7000
|
+
do {
|
|
7001
|
+
const page = await handle.query({
|
|
7002
|
+
limit: 500,
|
|
7003
|
+
...cursor === void 0 ? {} : { cursor }
|
|
7004
|
+
});
|
|
7005
|
+
rows.push(...page.records);
|
|
7006
|
+
cursor = page.nextCursor ?? void 0;
|
|
7007
|
+
} while (cursor !== void 0);
|
|
7008
|
+
return { records: rows };
|
|
7009
|
+
},
|
|
7010
|
+
get: (id) => handle.get({ id }),
|
|
7011
|
+
put: (input, opts) => handle.put({
|
|
7012
|
+
...input,
|
|
7013
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
7014
|
+
})
|
|
7015
|
+
};
|
|
7016
|
+
} };
|
|
7017
|
+
}
|
|
6941
7018
|
function integrationRowsApiOver(api) {
|
|
6942
7019
|
return {
|
|
6943
7020
|
list: async () => (await api.integrations.list({})).integrations,
|
|
@@ -7150,7 +7227,10 @@ function secretArrayPrefixes(path) {
|
|
|
7150
7227
|
}
|
|
7151
7228
|
return prefixes;
|
|
7152
7229
|
}
|
|
7153
|
-
/**
|
|
7230
|
+
/**
|
|
7231
|
+
* The body key the switch USED to live under (D1007, D1015). Nothing writes or reads it any more;
|
|
7232
|
+
* the migrations that move it between the body and the registry name it.
|
|
7233
|
+
*/
|
|
7154
7234
|
var SWITCH_KEY = "enabled";
|
|
7155
7235
|
/**
|
|
7156
7236
|
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
@@ -7260,6 +7340,107 @@ function registrySwitchPortsOver(deps) {
|
|
|
7260
7340
|
};
|
|
7261
7341
|
}
|
|
7262
7342
|
/**
|
|
7343
|
+
* The switch comes back to the registry (D1066), the reverse of {@link registrySwitchToBodyMigration}.
|
|
7344
|
+
* An instance's on/off state lived in its record body (`enabled`, D1007 superseded by D1015); the hub
|
|
7345
|
+
* registry row, keyed by (addon, integration id) like a device, is now the only stored switch.
|
|
7346
|
+
*
|
|
7347
|
+
* For every record of the addon's kind:
|
|
7348
|
+
* - the state is the body's `enabled` (absent means on). When the registry row of that id disagrees,
|
|
7349
|
+
* the BODY wins: it was the only live copy while the body held the switch, and the registry
|
|
7350
|
+
* column of a migrated row was never read;
|
|
7351
|
+
* - a record with no registry row gets one (a services instance, under its addon-minted id);
|
|
7352
|
+
* - the key is then removed from the body, so no second copy remains.
|
|
7353
|
+
* A rerun finds no body that states `enabled` and writes nothing. The registry write goes first, so
|
|
7354
|
+
* a crash between the two steps repeats the pair (idempotent) and never loses a switched-off state.
|
|
7355
|
+
*
|
|
7356
|
+
* It runs in the addon process, after {@link registrySwitchToBodyMigration}, BEFORE the addon
|
|
7357
|
+
* registers its provider.
|
|
7358
|
+
*/
|
|
7359
|
+
function bodySwitchToRegistryId(addonId, date, kindName) {
|
|
7360
|
+
return `${addonId}/${date}-body-switch-to-registry-${kindName}`;
|
|
7361
|
+
}
|
|
7362
|
+
async function moveBodySwitchToRegistry(ports, spec) {
|
|
7363
|
+
const records = await ports.listRecords();
|
|
7364
|
+
const adopted = records.length === 0 ? {
|
|
7365
|
+
created: 0,
|
|
7366
|
+
updated: 0,
|
|
7367
|
+
conflicts: []
|
|
7368
|
+
} : await ports.adoptRows(spec.addonId, records.map((r) => ({
|
|
7369
|
+
id: r.id,
|
|
7370
|
+
name: r.name,
|
|
7371
|
+
enabled: r.enabled,
|
|
7372
|
+
stated: r.stated
|
|
7373
|
+
})));
|
|
7374
|
+
const foreign = new Map(adopted.conflicts.map((c) => [c.id, c.ownerAddonId]));
|
|
7375
|
+
for (const [id, owner] of foreign) await ports.warn(`body switch kept: the registry row "${id}" belongs to addon "${owner}", not "${spec.addonId}"`);
|
|
7376
|
+
const stated = records.filter((r) => r.stated && !foreign.has(r.id));
|
|
7377
|
+
for (const row of stated) await ports.stripSwitch(row.id);
|
|
7378
|
+
const summary = {
|
|
7379
|
+
records: records.length,
|
|
7380
|
+
stripped: stated.length,
|
|
7381
|
+
rowsCreated: adopted.created,
|
|
7382
|
+
rowsCorrected: adopted.updated,
|
|
7383
|
+
conflicts: adopted.conflicts.length
|
|
7384
|
+
};
|
|
7385
|
+
return stated.length === 0 && adopted.created === 0 && adopted.updated === 0 ? {
|
|
7386
|
+
outcome: "already-done",
|
|
7387
|
+
summary
|
|
7388
|
+
} : {
|
|
7389
|
+
outcome: "done",
|
|
7390
|
+
summary
|
|
7391
|
+
};
|
|
7392
|
+
}
|
|
7393
|
+
/** A migration entry: an addon states its kind, nothing else. */
|
|
7394
|
+
function bodySwitchToRegistryMigration(spec) {
|
|
7395
|
+
return {
|
|
7396
|
+
meta: {
|
|
7397
|
+
id: bodySwitchToRegistryId(spec.addonId, spec.date, spec.kindName),
|
|
7398
|
+
owner: spec.addonId,
|
|
7399
|
+
level: "addon-state",
|
|
7400
|
+
seq: spec.seq,
|
|
7401
|
+
dependsOn: spec.followsDate === void 0 ? [] : [registrySwitchToBodyId(spec.addonId, spec.followsDate)],
|
|
7402
|
+
store: "settings",
|
|
7403
|
+
scope: "cluster",
|
|
7404
|
+
onFailure: "block-owner",
|
|
7405
|
+
bodyKind: "procedure",
|
|
7406
|
+
description: "Move the switch of every instance record back to its registry row (creating the row of a services instance) and remove it from the body",
|
|
7407
|
+
fixtureMark: "enabled"
|
|
7408
|
+
},
|
|
7409
|
+
procedure: (ports) => moveBodySwitchToRegistry(ports, { addonId: spec.addonId })
|
|
7410
|
+
};
|
|
7411
|
+
}
|
|
7412
|
+
function bodySwitchPortsOver(deps) {
|
|
7413
|
+
const handle = deps.records.kind({
|
|
7414
|
+
name: deps.kind.name,
|
|
7415
|
+
declaration: deps.kind.declaration,
|
|
7416
|
+
schema: record(string(), unknown())
|
|
7417
|
+
});
|
|
7418
|
+
return {
|
|
7419
|
+
listRecords: async () => {
|
|
7420
|
+
return (await handle.query({ limit: 1e3 })).records.map((r) => {
|
|
7421
|
+
const name = r.data[deps.nameField];
|
|
7422
|
+
return {
|
|
7423
|
+
id: r.id,
|
|
7424
|
+
name: typeof name === "string" ? name : r.id,
|
|
7425
|
+
enabled: r.data[SWITCH_KEY] !== false,
|
|
7426
|
+
stated: SWITCH_KEY in r.data
|
|
7427
|
+
};
|
|
7428
|
+
});
|
|
7429
|
+
},
|
|
7430
|
+
adoptRows: deps.adopt,
|
|
7431
|
+
warn: deps.warn,
|
|
7432
|
+
stripSwitch: async (id) => {
|
|
7433
|
+
const row = await handle.get(id);
|
|
7434
|
+
if (row === null || !("enabled" in row.data)) return;
|
|
7435
|
+
const { [SWITCH_KEY]: _dropped, ...rest } = row.data;
|
|
7436
|
+
await handle.put({
|
|
7437
|
+
id,
|
|
7438
|
+
data: rest
|
|
7439
|
+
}, { ifRev: row.rev });
|
|
7440
|
+
}
|
|
7441
|
+
};
|
|
7442
|
+
}
|
|
7443
|
+
/**
|
|
7263
7444
|
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7264
7445
|
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7265
7446
|
* validated value round-trips on every read/write — the schema is the
|
|
@@ -7291,6 +7472,20 @@ function createDurableState(deps) {
|
|
|
7291
7472
|
};
|
|
7292
7473
|
}
|
|
7293
7474
|
/**
|
|
7475
|
+
* The registry could not be read for the switches of an addon that serves instance kinds, so its
|
|
7476
|
+
* instances read off (D1066). A forked runner treats it as a failed boot: the supervisor respawns
|
|
7477
|
+
* it, bounded and marked terminally failed (D6), rather than leave instances off silently.
|
|
7478
|
+
*/
|
|
7479
|
+
var INSTANCE_SWITCHES_UNREAD_ERROR_NAME = "InstanceSwitchesUnreadError";
|
|
7480
|
+
var InstanceSwitchesUnreadError = class extends Error {
|
|
7481
|
+
ownerId;
|
|
7482
|
+
constructor(ownerId) {
|
|
7483
|
+
super(`'${ownerId}': the registry did not answer for the instance switches; its instances stay off`);
|
|
7484
|
+
this.ownerId = ownerId;
|
|
7485
|
+
this.name = INSTANCE_SWITCHES_UNREAD_ERROR_NAME;
|
|
7486
|
+
}
|
|
7487
|
+
};
|
|
7488
|
+
/**
|
|
7294
7489
|
* Per-node scoping for the shared addon-settings blob.
|
|
7295
7490
|
*
|
|
7296
7491
|
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
@@ -8274,7 +8469,14 @@ var BaseAddon = class {
|
|
|
8274
8469
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
8275
8470
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
8276
8471
|
});
|
|
8472
|
+
await this.hydrateSwitches();
|
|
8277
8473
|
const result = await this.onInitialize();
|
|
8474
|
+
await this.moveLateInstanceKinds();
|
|
8475
|
+
await this.adoptUnrowed();
|
|
8476
|
+
if (this.switchesHydrated) {
|
|
8477
|
+
settleHydration(this.ctx.id);
|
|
8478
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) await served.reapply();
|
|
8479
|
+
}
|
|
8278
8480
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
8279
8481
|
const normalized = normalizeAddonInitResult(result);
|
|
8280
8482
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
@@ -8314,17 +8516,22 @@ var BaseAddon = class {
|
|
|
8314
8516
|
this.retiredMigrationIds = ids;
|
|
8315
8517
|
}
|
|
8316
8518
|
registrySwitchSpec = null;
|
|
8519
|
+
/** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
|
|
8520
|
+
switchMoved = /* @__PURE__ */ new Set();
|
|
8521
|
+
lastDeclared = [];
|
|
8317
8522
|
registrySwitchBound() {
|
|
8318
|
-
const spec = this.registrySwitchSpec;
|
|
8319
|
-
if (spec === null) return [];
|
|
8320
8523
|
const api = this.ctx.migrationApi;
|
|
8524
|
+
const spec = this.registrySwitchSpec;
|
|
8525
|
+
const kinds = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
|
|
8526
|
+
if (spec === null && kinds.length === 0) return [];
|
|
8321
8527
|
if (api === void 0) {
|
|
8322
8528
|
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8323
8529
|
return [];
|
|
8324
8530
|
}
|
|
8325
|
-
|
|
8531
|
+
const date = "2026-11-06";
|
|
8532
|
+
const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
|
|
8326
8533
|
addonId: this.ctx.id,
|
|
8327
|
-
date
|
|
8534
|
+
date,
|
|
8328
8535
|
seq: 1e3,
|
|
8329
8536
|
initialBody: spec.initialBody
|
|
8330
8537
|
})], (a) => registrySwitchPortsOver({
|
|
@@ -8332,13 +8539,53 @@ var BaseAddon = class {
|
|
|
8332
8539
|
records: switchRecordsOverMigrationApi(a),
|
|
8333
8540
|
kind: spec.kind
|
|
8334
8541
|
})).bind(api);
|
|
8542
|
+
const moveBack = kinds.flatMap(({ kind }, index) => {
|
|
8543
|
+
this.switchMoved.add(kind.name);
|
|
8544
|
+
return migrationSet([bodySwitchToRegistryMigration({
|
|
8545
|
+
addonId: this.ctx.id,
|
|
8546
|
+
date: "2026-11-19",
|
|
8547
|
+
seq: 1001 + index,
|
|
8548
|
+
kindName: kind.name,
|
|
8549
|
+
...spec === null ? {} : { followsDate: date }
|
|
8550
|
+
})], (a) => bodySwitchPortsOver({
|
|
8551
|
+
records: bodySwitchRecordsOverMigrationApi(a),
|
|
8552
|
+
kind,
|
|
8553
|
+
nameField: kind.declaration.entry?.nameField ?? "name",
|
|
8554
|
+
adopt: (addonId, rows) => this.ctx.api.integrations.adoptInstanceRows.mutate({
|
|
8555
|
+
addonId,
|
|
8556
|
+
rows: [...rows]
|
|
8557
|
+
}),
|
|
8558
|
+
warn: async (message) => {
|
|
8559
|
+
await a.log.warn({ message });
|
|
8560
|
+
}
|
|
8561
|
+
})).bind(api);
|
|
8562
|
+
});
|
|
8563
|
+
return [...moveIn, ...moveBack];
|
|
8564
|
+
}
|
|
8565
|
+
/**
|
|
8566
|
+
* A helper built AFTER the addon's migrations ran has a kind that moved nothing yet. Run its
|
|
8567
|
+
* switch move now (the engine replaces an owner's catalogue on every declare, so the whole
|
|
8568
|
+
* declared set goes with it, phased to the late ids), read the registry again, and tell the
|
|
8569
|
+
* addon about every instance that is off so it stops what it started on the default.
|
|
8570
|
+
*/
|
|
8571
|
+
async moveLateInstanceKinds() {
|
|
8572
|
+
const late = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
|
|
8573
|
+
if (late.length === 0) return;
|
|
8574
|
+
try {
|
|
8575
|
+
const only = late.map((k) => bodySwitchToRegistryId(this.ctx.id, "2026-11-19", k.kind.name));
|
|
8576
|
+
await this.runBound(this.lastDeclared, { only });
|
|
8577
|
+
} catch (err) {
|
|
8578
|
+
if (err instanceof AddonMigrationsBlockedError) throw err;
|
|
8579
|
+
this.ctx.logger.error("the late instance switch move failed", { meta: { error: errMsg$2(err) } });
|
|
8580
|
+
}
|
|
8335
8581
|
}
|
|
8336
8582
|
async runBound(declared, options) {
|
|
8583
|
+
this.lastDeclared = declared;
|
|
8337
8584
|
const added = this.registrySwitchBound();
|
|
8338
8585
|
const migrations = [...declared, ...added];
|
|
8339
8586
|
const widened = options?.only === void 0 || added.length === 0 ? options : {
|
|
8340
8587
|
...options,
|
|
8341
|
-
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8588
|
+
only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
|
|
8342
8589
|
};
|
|
8343
8590
|
const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
|
|
8344
8591
|
...widened,
|
|
@@ -8351,9 +8598,87 @@ var BaseAddon = class {
|
|
|
8351
8598
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
8352
8599
|
}, migrations, this.ctx.logger, phased);
|
|
8353
8600
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
8601
|
+
await this.hydrateSwitches();
|
|
8602
|
+
await this.adoptUnrowed();
|
|
8354
8603
|
return report;
|
|
8355
8604
|
}
|
|
8356
8605
|
/**
|
|
8606
|
+
* Learn the on/off state of this addon's instances from the registry rows (D1066), at boot, after
|
|
8607
|
+
* a migration run, and again through {@link rehydrateSwitches}. It runs on the addon's own boot
|
|
8608
|
+
* path, never inside a method the hub calls into. A registry that cannot answer leaves the
|
|
8609
|
+
* instances of THIS addon reading off (fail closed, per owner) until a read answers.
|
|
8610
|
+
*/
|
|
8611
|
+
switchesHydrated = false;
|
|
8612
|
+
async hydrateSwitches() {
|
|
8613
|
+
beginHydration(this.ctx.id);
|
|
8614
|
+
try {
|
|
8615
|
+
const rows = await this.ctx.api.integrations.listByAddon.query({ addonId: this.ctx.id });
|
|
8616
|
+
hydrateInstanceSwitches(this.ctx.id, rows);
|
|
8617
|
+
this.switchesHydrated = true;
|
|
8618
|
+
return true;
|
|
8619
|
+
} catch (err) {
|
|
8620
|
+
this.ctx.logger.warn("instance switches not read from the registry: instances stay off", { meta: { error: errMsg$2(err) } });
|
|
8621
|
+
return false;
|
|
8622
|
+
}
|
|
8623
|
+
}
|
|
8624
|
+
/**
|
|
8625
|
+
* Every record of a served kind the registry holds no row for (created outside the hub door:
|
|
8626
|
+
* a seed, a store write) is adopted with the state it effectively had, on unless this process
|
|
8627
|
+
* stated it off, so the hub can switch it. A failure is logged; the next hydration retries.
|
|
8628
|
+
*/
|
|
8629
|
+
async adoptUnrowed() {
|
|
8630
|
+
if (!this.switchesHydrated) return;
|
|
8631
|
+
try {
|
|
8632
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) {
|
|
8633
|
+
const rows = await served.unrowed();
|
|
8634
|
+
if (rows.length === 0) continue;
|
|
8635
|
+
await this.ctx.api.integrations.adoptInstanceRows.mutate({
|
|
8636
|
+
addonId: this.ctx.id,
|
|
8637
|
+
rows: rows.map((r) => ({
|
|
8638
|
+
id: r.id,
|
|
8639
|
+
name: r.name,
|
|
8640
|
+
enabled: r.enabled,
|
|
8641
|
+
stated: false
|
|
8642
|
+
}))
|
|
8643
|
+
});
|
|
8644
|
+
for (const r of rows) recordRegistrySwitch(r.id, r.enabled);
|
|
8645
|
+
}
|
|
8646
|
+
} catch (err) {
|
|
8647
|
+
this.ctx.logger.warn("records without a registry row were not adopted", { meta: { error: errMsg$2(err) } });
|
|
8648
|
+
}
|
|
8649
|
+
}
|
|
8650
|
+
/**
|
|
8651
|
+
* Read the switches from the registry again and announce the states now known, so an addon that
|
|
8652
|
+
* started on the fail-closed default (off) starts what is on. Throws
|
|
8653
|
+
* {@link InstanceSwitchesUnreadError} when the registry still does not answer while this addon
|
|
8654
|
+
* serves instance kinds: a forked runner turns that into a failed boot (the supervisor respawns
|
|
8655
|
+
* it, bounded, D6), an agent or the hub reads again on the next hub connect (event-driven, D3).
|
|
8656
|
+
* An addon with no instance kind has nothing waiting and never throws.
|
|
8657
|
+
*/
|
|
8658
|
+
async rehydrateSwitches() {
|
|
8659
|
+
if (this._ctx === null) return;
|
|
8660
|
+
if (await this.hydrateSwitches()) {
|
|
8661
|
+
await this.adoptUnrowed();
|
|
8662
|
+
settleHydration(this.ctx.id);
|
|
8663
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) await served.reapply();
|
|
8664
|
+
return;
|
|
8665
|
+
}
|
|
8666
|
+
if (isHydrationPending(this.ctx.id)) throw new InstanceSwitchesUnreadError(this.ctx.id);
|
|
8667
|
+
}
|
|
8668
|
+
/**
|
|
8669
|
+
* Called on the hub-reachable event (instead of `onHubReachable` directly): the switches are
|
|
8670
|
+
* read again, then `onHubReachable` runs. A registry that still does not answer is logged and
|
|
8671
|
+
* left for the next connect.
|
|
8672
|
+
*/
|
|
8673
|
+
async hubReachable() {
|
|
8674
|
+
try {
|
|
8675
|
+
await this.rehydrateSwitches();
|
|
8676
|
+
} catch (err) {
|
|
8677
|
+
this.ctx.logger.warn("instance switches still unread at the hub connect", { meta: { error: errMsg$2(err) } });
|
|
8678
|
+
}
|
|
8679
|
+
await this.onHubReachable();
|
|
8680
|
+
}
|
|
8681
|
+
/**
|
|
8357
8682
|
* Called by the isolated-process runner AFTER `broker.start()`.
|
|
8358
8683
|
* In-process addons never need this because the hub broker is already
|
|
8359
8684
|
* running when `initialize()` fires. For forked children the broker
|
|
@@ -67157,14 +67482,8 @@ var IntegrationWithStateSchema = object({
|
|
|
67157
67482
|
id: string(),
|
|
67158
67483
|
addonId: string(),
|
|
67159
67484
|
name: string(),
|
|
67160
|
-
/**
|
|
67485
|
+
/** THE switch of the instance: the hub registry row is its only stored copy (D1066). */
|
|
67161
67486
|
enabled: boolean(),
|
|
67162
|
-
/**
|
|
67163
|
-
* True when the addon that holds the switch did not answer (down, failed, or keeps no record for
|
|
67164
|
-
* this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
|
|
67165
|
-
* must not draw it as on or off (D315).
|
|
67166
|
-
*/
|
|
67167
|
-
switchUnknown: literal(true).optional(),
|
|
67168
67487
|
info: record(string(), unknown()).readonly(),
|
|
67169
67488
|
/** The discovery candidate this integration was set up from (D984). */
|
|
67170
67489
|
originStableId: string().optional(),
|
|
@@ -67176,14 +67495,8 @@ var IntegrationLiteSchema = object({
|
|
|
67176
67495
|
id: string(),
|
|
67177
67496
|
addonId: string(),
|
|
67178
67497
|
name: string(),
|
|
67179
|
-
/**
|
|
67498
|
+
/** THE switch of the instance: the hub registry row is its only stored copy (D1066). */
|
|
67180
67499
|
enabled: boolean(),
|
|
67181
|
-
/**
|
|
67182
|
-
* True when the addon that holds the switch did not answer (down, failed, or keeps no record for
|
|
67183
|
-
* this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
|
|
67184
|
-
* must not draw it as on or off (D315).
|
|
67185
|
-
*/
|
|
67186
|
-
switchUnknown: literal(true).optional(),
|
|
67187
67500
|
info: record(string(), unknown()).readonly(),
|
|
67188
67501
|
/** The discovery candidate this integration was set up from (D984). */
|
|
67189
67502
|
originStableId: string().optional(),
|
|
@@ -67299,7 +67612,27 @@ var DeleteIntegrationResultSchema = object({
|
|
|
67299
67612
|
success: boolean(),
|
|
67300
67613
|
deletedId: string()
|
|
67301
67614
|
});
|
|
67302
|
-
method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string() }), IntegrationWithStateSchema), method(object({ addonId: string() }), IntegrationLiteSchema.nullable()), method(
|
|
67615
|
+
method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string() }), IntegrationWithStateSchema), method(object({ addonId: string() }), IntegrationLiteSchema.nullable()), method(object({ addonId: string() }), array(IntegrationLiteSchema)), method(object({
|
|
67616
|
+
addonId: string(),
|
|
67617
|
+
rows: array(object({
|
|
67618
|
+
id: string().min(1),
|
|
67619
|
+
name: string(),
|
|
67620
|
+
enabled: boolean(),
|
|
67621
|
+
/** True when the record body STATED the switch: only then does it override an existing row. */
|
|
67622
|
+
stated: boolean()
|
|
67623
|
+
}))
|
|
67624
|
+
}), object({
|
|
67625
|
+
created: number$1().int(),
|
|
67626
|
+
updated: number$1().int(),
|
|
67627
|
+
/** Rows whose id belongs to ANOTHER addon: left untouched, so the caller keeps its own copy. */
|
|
67628
|
+
conflicts: array(object({
|
|
67629
|
+
id: string(),
|
|
67630
|
+
ownerAddonId: string()
|
|
67631
|
+
}))
|
|
67632
|
+
}), {
|
|
67633
|
+
kind: "mutation",
|
|
67634
|
+
auth: "admin"
|
|
67635
|
+
}), method(UpdateIntegrationInputSchema, IntegrationLiteSchema, {
|
|
67303
67636
|
kind: "mutation",
|
|
67304
67637
|
auth: "admin"
|
|
67305
67638
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
@@ -100135,6 +100468,13 @@ Object.freeze({
|
|
|
100135
100468
|
access: "create",
|
|
100136
100469
|
role: "admin"
|
|
100137
100470
|
},
|
|
100471
|
+
"integrations.adoptInstanceRows": {
|
|
100472
|
+
capName: "integrations",
|
|
100473
|
+
capScope: "system",
|
|
100474
|
+
addonId: null,
|
|
100475
|
+
access: "create",
|
|
100476
|
+
role: "admin"
|
|
100477
|
+
},
|
|
100138
100478
|
"integrations.delete": {
|
|
100139
100479
|
capName: "integrations",
|
|
100140
100480
|
capScope: "system",
|
|
@@ -100170,6 +100510,13 @@ Object.freeze({
|
|
|
100170
100510
|
access: "view",
|
|
100171
100511
|
role: "admin"
|
|
100172
100512
|
},
|
|
100513
|
+
"integrations.listByAddon": {
|
|
100514
|
+
capName: "integrations",
|
|
100515
|
+
capScope: "system",
|
|
100516
|
+
addonId: null,
|
|
100517
|
+
access: "view",
|
|
100518
|
+
role: "admin"
|
|
100519
|
+
},
|
|
100173
100520
|
"integrations.update": {
|
|
100174
100521
|
capName: "integrations",
|
|
100175
100522
|
capScope: "system",
|