@camstack/addon-google-services 0.2.37 → 0.2.39
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 +13 -0
- package/dist/google-services.addon.js +942 -800
- package/dist/google-services.addon.mjs +942 -800
- package/package.json +2 -2
|
@@ -5981,7 +5981,7 @@ var ZodIssueCode = {
|
|
|
5981
5981
|
var ZodFirstPartyTypeKind;
|
|
5982
5982
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5983
5983
|
//#endregion
|
|
5984
|
-
//#region ../types/dist/sleep-
|
|
5984
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
5985
5985
|
/**
|
|
5986
5986
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5987
5987
|
* window to float samples (D455).
|
|
@@ -6581,7 +6581,7 @@ var NOT_RUN = {
|
|
|
6581
6581
|
* throws: an unreachable or refusing engine is logged and reported `declared: false`,
|
|
6582
6582
|
* because the hub (and this addon's boot) must not hang on a migration.
|
|
6583
6583
|
*/
|
|
6584
|
-
async function runAddonMigrations(host, migrations, logger) {
|
|
6584
|
+
async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
6585
6585
|
const first = migrations[0];
|
|
6586
6586
|
if (first === void 0) return NOT_RUN;
|
|
6587
6587
|
const owner = first.meta.owner;
|
|
@@ -6610,7 +6610,9 @@ async function runAddonMigrations(host, migrations, logger) {
|
|
|
6610
6610
|
else if (status === "blocked") blocked.push(id);
|
|
6611
6611
|
else skipped.push(id);
|
|
6612
6612
|
};
|
|
6613
|
+
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6613
6614
|
for (const step of declaration.steps) {
|
|
6615
|
+
if (selected !== null && !selected.has(step.id)) continue;
|
|
6614
6616
|
const bound = byId.get(step.id);
|
|
6615
6617
|
if (bound === void 0 || step.action === "skip") {
|
|
6616
6618
|
skipped.push(step.id);
|
|
@@ -6788,6 +6790,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6788
6790
|
}
|
|
6789
6791
|
return out;
|
|
6790
6792
|
}
|
|
6793
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
6794
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
6795
|
+
"cluster",
|
|
6796
|
+
"device-defaults",
|
|
6797
|
+
"node"
|
|
6798
|
+
];
|
|
6791
6799
|
/**
|
|
6792
6800
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6793
6801
|
*
|
|
@@ -7602,6 +7610,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7602
7610
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7603
7611
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7604
7612
|
/**
|
|
7613
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
7614
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
7615
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
7616
|
+
*/
|
|
7617
|
+
function migrationSet(catalogue, bindPorts) {
|
|
7618
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
7619
|
+
}
|
|
7620
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
7621
|
+
function refuseMixed(form, kept, dropped) {
|
|
7622
|
+
if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
|
|
7623
|
+
}
|
|
7624
|
+
function catalogueOf(list) {
|
|
7625
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
7626
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
7627
|
+
return kept;
|
|
7628
|
+
}
|
|
7629
|
+
function boundOf(list) {
|
|
7630
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
7631
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
7632
|
+
return kept;
|
|
7633
|
+
}
|
|
7634
|
+
/**
|
|
7605
7635
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7606
7636
|
*
|
|
7607
7637
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7679,6 +7709,13 @@ var BaseAddon = class {
|
|
|
7679
7709
|
*/
|
|
7680
7710
|
secretStatePaths = [];
|
|
7681
7711
|
_addonSecretTree = null;
|
|
7712
|
+
/**
|
|
7713
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
7714
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
7715
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
7716
|
+
*/
|
|
7717
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
7718
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7682
7719
|
_deviceSecretTree = null;
|
|
7683
7720
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7684
7721
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7748,6 +7785,7 @@ var BaseAddon = class {
|
|
|
7748
7785
|
this._ctx = context;
|
|
7749
7786
|
this._secretSettings = null;
|
|
7750
7787
|
}
|
|
7788
|
+
await this.loadScopedSchemas();
|
|
7751
7789
|
await this.resolveConfig();
|
|
7752
7790
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7753
7791
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7757,27 +7795,30 @@ var BaseAddon = class {
|
|
|
7757
7795
|
const normalized = normalizeAddonInitResult(result);
|
|
7758
7796
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7759
7797
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
7798
|
+
await this.loadScopedSchemas();
|
|
7760
7799
|
return normalized;
|
|
7761
7800
|
}
|
|
7801
|
+
async runMigrations(first, second, third) {
|
|
7802
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
7803
|
+
return this.runBound(boundOf(first), second);
|
|
7804
|
+
}
|
|
7762
7805
|
/**
|
|
7763
|
-
*
|
|
7764
|
-
*
|
|
7765
|
-
*
|
|
7766
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7767
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7768
|
-
*
|
|
7769
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7770
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7771
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7772
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7806
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
7807
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
7808
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7773
7809
|
*/
|
|
7774
|
-
async
|
|
7810
|
+
async runMigrationSets(sets, options) {
|
|
7811
|
+
const api = this.ctx.migrationApi;
|
|
7812
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7813
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7814
|
+
}
|
|
7815
|
+
async runBound(migrations, options) {
|
|
7775
7816
|
const api = this.ctx.api.migrations;
|
|
7776
7817
|
const report = await runAddonMigrations({
|
|
7777
7818
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7778
7819
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7779
7820
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7780
|
-
}, migrations, this.ctx.logger);
|
|
7821
|
+
}, migrations, this.ctx.logger, options);
|
|
7781
7822
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7782
7823
|
return report;
|
|
7783
7824
|
}
|
|
@@ -7841,6 +7882,16 @@ var BaseAddon = class {
|
|
|
7841
7882
|
schema(schema) {
|
|
7842
7883
|
return schema;
|
|
7843
7884
|
}
|
|
7885
|
+
/**
|
|
7886
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
7887
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
7888
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
7889
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
7890
|
+
* once known.
|
|
7891
|
+
*/
|
|
7892
|
+
scopedSettingsCapabilities() {
|
|
7893
|
+
return [];
|
|
7894
|
+
}
|
|
7844
7895
|
/** Override to provide global-level settings UI schema. */
|
|
7845
7896
|
globalSettingsSchema(_cap) {
|
|
7846
7897
|
return null;
|
|
@@ -7884,7 +7935,8 @@ var BaseAddon = class {
|
|
|
7884
7935
|
return [];
|
|
7885
7936
|
}
|
|
7886
7937
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7887
|
-
|
|
7938
|
+
await this.loadScopedSchemas(cap);
|
|
7939
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7888
7940
|
if (!schema) return { sections: [] };
|
|
7889
7941
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7890
7942
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -7919,10 +7971,9 @@ var BaseAddon = class {
|
|
|
7919
7971
|
*
|
|
7920
7972
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
7921
7973
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
7922
|
-
* SHAPE of the form only — the values live
|
|
7923
|
-
* unchanged (`integrations.setSettings` for an account integration).
|
|
7974
|
+
* SHAPE of the form only — the values live on the instance record.
|
|
7924
7975
|
*/
|
|
7925
|
-
async
|
|
7976
|
+
async integrationFormSchema(_instance) {
|
|
7926
7977
|
return null;
|
|
7927
7978
|
}
|
|
7928
7979
|
/**
|
|
@@ -7968,7 +8019,7 @@ var BaseAddon = class {
|
|
|
7968
8019
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
7969
8020
|
*/
|
|
7970
8021
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
7971
|
-
const scoped = await this.
|
|
8022
|
+
const scoped = await this.integrationFormSchema(instance);
|
|
7972
8023
|
if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
|
|
7973
8024
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
7974
8025
|
}
|
|
@@ -8016,6 +8067,7 @@ var BaseAddon = class {
|
|
|
8016
8067
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8017
8068
|
*/
|
|
8018
8069
|
async resolveGlobalStore(nodeId, cap) {
|
|
8070
|
+
await this.loadScopedSchemas(cap);
|
|
8019
8071
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8020
8072
|
return this.projectForNode(raw, nodeId, cap);
|
|
8021
8073
|
}
|
|
@@ -8026,6 +8078,7 @@ var BaseAddon = class {
|
|
|
8026
8078
|
}
|
|
8027
8079
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8028
8080
|
async readRawProjectedStore(nodeId, cap) {
|
|
8081
|
+
await this.loadScopedSchemas(cap);
|
|
8029
8082
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8030
8083
|
return this.projectForNode(raw, nodeId, cap);
|
|
8031
8084
|
}
|
|
@@ -8128,6 +8181,7 @@ var BaseAddon = class {
|
|
|
8128
8181
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8129
8182
|
}
|
|
8130
8183
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8184
|
+
await this.loadScopedSchemas();
|
|
8131
8185
|
const keys = this.perNodeKeys();
|
|
8132
8186
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8133
8187
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8141,7 +8195,8 @@ var BaseAddon = class {
|
|
|
8141
8195
|
await this.resolveConfig();
|
|
8142
8196
|
await this.onConfigChanged();
|
|
8143
8197
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8144
|
-
|
|
8198
|
+
const legacy = this.globalSettingsSchema();
|
|
8199
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8145
8200
|
}
|
|
8146
8201
|
/**
|
|
8147
8202
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8149,14 +8204,67 @@ var BaseAddon = class {
|
|
|
8149
8204
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8150
8205
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8151
8206
|
*/
|
|
8152
|
-
|
|
8207
|
+
/**
|
|
8208
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8209
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8210
|
+
* derived from the previous set. Idempotent.
|
|
8211
|
+
*/
|
|
8212
|
+
async loadScopedSchemas(extraCap) {
|
|
8213
|
+
const caps = new Set([
|
|
8214
|
+
...this.scopedSettingsCapabilities(),
|
|
8215
|
+
...this._registeredCapNames,
|
|
8216
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8217
|
+
]);
|
|
8218
|
+
let added = false;
|
|
8219
|
+
for (const cap of caps) {
|
|
8220
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8221
|
+
const loaded = [];
|
|
8222
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8223
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8224
|
+
if (schema !== null) loaded.push({
|
|
8225
|
+
scope,
|
|
8226
|
+
schema
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8229
|
+
this._scopedByCap.set(cap, loaded);
|
|
8230
|
+
added = true;
|
|
8231
|
+
}
|
|
8232
|
+
if (!added) return;
|
|
8233
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8234
|
+
this._addonSecretTree = null;
|
|
8235
|
+
}
|
|
8236
|
+
/**
|
|
8237
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8238
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8239
|
+
*/
|
|
8240
|
+
scopedFormSchema(cap) {
|
|
8241
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8242
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8243
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8244
|
+
}
|
|
8245
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8246
|
+
loadedScopedSchemas(cap) {
|
|
8247
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8248
|
+
return [...this._scopedByCap.values()].flat();
|
|
8249
|
+
}
|
|
8250
|
+
/**
|
|
8251
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8252
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8253
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8254
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8255
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8256
|
+
*/
|
|
8153
8257
|
perNodeKeys(cap) {
|
|
8154
8258
|
const cacheKey = cap ?? "";
|
|
8155
|
-
const cached = this.
|
|
8259
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8156
8260
|
if (cached) return cached;
|
|
8157
|
-
const
|
|
8158
|
-
const keys = new Set(
|
|
8159
|
-
this.
|
|
8261
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8262
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8263
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8264
|
+
if (scope !== "node") continue;
|
|
8265
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8266
|
+
}
|
|
8267
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8160
8268
|
return keys;
|
|
8161
8269
|
}
|
|
8162
8270
|
/**
|
|
@@ -8166,10 +8274,9 @@ var BaseAddon = class {
|
|
|
8166
8274
|
* time to return its response before the addon is torn down and
|
|
8167
8275
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8168
8276
|
*/
|
|
8169
|
-
maybeAutoRestart(patchKeys,
|
|
8170
|
-
if (!schema) return;
|
|
8277
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8171
8278
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8172
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8279
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8173
8280
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8174
8281
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8175
8282
|
}
|
|
@@ -8365,12 +8472,14 @@ var BaseAddon = class {
|
|
|
8365
8472
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8366
8473
|
*/
|
|
8367
8474
|
async getDeclaredSettingsKeys() {
|
|
8475
|
+
await this.loadScopedSchemas();
|
|
8368
8476
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8369
8477
|
}
|
|
8370
8478
|
declaredKeySet() {
|
|
8371
8479
|
const keys = new Set(Object.keys(this.defaults));
|
|
8372
8480
|
const schema = this.globalSettingsSchema();
|
|
8373
8481
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8482
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8374
8483
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8375
8484
|
for (const path of this.secretStatePaths) {
|
|
8376
8485
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8466,7 +8575,11 @@ var BaseAddon = class {
|
|
|
8466
8575
|
}
|
|
8467
8576
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8468
8577
|
addonSecretTree() {
|
|
8469
|
-
this._addonSecretTree
|
|
8578
|
+
if (this._addonSecretTree === null) {
|
|
8579
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
8580
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
8581
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
8582
|
+
}
|
|
8470
8583
|
return this._addonSecretTree;
|
|
8471
8584
|
}
|
|
8472
8585
|
deviceSecretTree() {
|
|
@@ -8716,6 +8829,23 @@ function dropPerNodeFields(fields) {
|
|
|
8716
8829
|
}
|
|
8717
8830
|
return kept;
|
|
8718
8831
|
}
|
|
8832
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
8833
|
+
function collectValueFieldKeys(fields) {
|
|
8834
|
+
const collected = [];
|
|
8835
|
+
for (const field of fields) {
|
|
8836
|
+
if (field.type === "group") {
|
|
8837
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
8838
|
+
continue;
|
|
8839
|
+
}
|
|
8840
|
+
if (field.type === "sub-tabs") {
|
|
8841
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
8842
|
+
continue;
|
|
8843
|
+
}
|
|
8844
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
8845
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
8846
|
+
}
|
|
8847
|
+
return collected;
|
|
8848
|
+
}
|
|
8719
8849
|
function collectFieldKeys(fields) {
|
|
8720
8850
|
const collected = [];
|
|
8721
8851
|
for (const field of fields) {
|
|
@@ -8817,6 +8947,10 @@ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
|
8817
8947
|
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8818
8948
|
* (`auth.accessToken`, `headers[].value`).
|
|
8819
8949
|
*
|
|
8950
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8951
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8952
|
+
* key releases exactly that key's secret.
|
|
8953
|
+
*
|
|
8820
8954
|
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8821
8955
|
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8822
8956
|
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
@@ -8829,11 +8963,13 @@ function parseSecretPath(path) {
|
|
|
8829
8963
|
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8830
8964
|
return path.split(".").map((raw) => {
|
|
8831
8965
|
const each = raw.endsWith("[]");
|
|
8832
|
-
const
|
|
8966
|
+
const map = raw.endsWith("{}");
|
|
8967
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8833
8968
|
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8834
8969
|
return {
|
|
8835
8970
|
key,
|
|
8836
|
-
each
|
|
8971
|
+
each,
|
|
8972
|
+
map
|
|
8837
8973
|
};
|
|
8838
8974
|
});
|
|
8839
8975
|
}
|
|
@@ -8885,6 +9021,22 @@ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arra
|
|
|
8885
9021
|
[segment.key]: mapped
|
|
8886
9022
|
};
|
|
8887
9023
|
}
|
|
9024
|
+
if (segment.map) {
|
|
9025
|
+
if (!isRecord$4(child)) return node;
|
|
9026
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
9027
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
9028
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
9029
|
+
return [mapKey, visit({
|
|
9030
|
+
declared,
|
|
9031
|
+
concrete,
|
|
9032
|
+
value
|
|
9033
|
+
})];
|
|
9034
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
9035
|
+
return {
|
|
9036
|
+
...node,
|
|
9037
|
+
[segment.key]: Object.fromEntries(kept)
|
|
9038
|
+
};
|
|
9039
|
+
}
|
|
8888
9040
|
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8889
9041
|
if (last) {
|
|
8890
9042
|
const replacement = visit({
|
|
@@ -9026,7 +9178,8 @@ function isZodSecret(schema) {
|
|
|
9026
9178
|
}
|
|
9027
9179
|
/**
|
|
9028
9180
|
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9029
|
-
* element of this array" (`connection.password`, `rows[].token`)
|
|
9181
|
+
* element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
|
|
9182
|
+
* map" (`applianceSecrets{}`). A declared
|
|
9030
9183
|
* object or array is reported as one path and not descended into — everything
|
|
9031
9184
|
* under it is secret.
|
|
9032
9185
|
*/
|
|
@@ -9037,6 +9190,7 @@ function collectZodSecretPaths(schema, prefix = "") {
|
|
|
9037
9190
|
const def = defOf(layer);
|
|
9038
9191
|
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9039
9192
|
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9193
|
+
else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
|
|
9040
9194
|
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9041
9195
|
else if (def.type === "intersection") {
|
|
9042
9196
|
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
@@ -9218,6 +9372,7 @@ function defineEntryKind(name, spec) {
|
|
|
9218
9372
|
class: "config",
|
|
9219
9373
|
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9220
9374
|
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9375
|
+
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9221
9376
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9222
9377
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9223
9378
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
@@ -11897,7 +12052,7 @@ function userError(code, params, englishFallback) {
|
|
|
11897
12052
|
return new CamstackError(code, params, englishFallback);
|
|
11898
12053
|
}
|
|
11899
12054
|
//#endregion
|
|
11900
|
-
//#region ../types/dist/composition-
|
|
12055
|
+
//#region ../types/dist/composition-pOHbTzRB.mjs
|
|
11901
12056
|
/**
|
|
11902
12057
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11903
12058
|
*
|
|
@@ -13361,11 +13516,49 @@ function buildCapturingReply(envelope) {
|
|
|
13361
13516
|
};
|
|
13362
13517
|
return wrapper;
|
|
13363
13518
|
}
|
|
13519
|
+
/**
|
|
13520
|
+
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13521
|
+
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13522
|
+
*
|
|
13523
|
+
* Every instance is one record of the addon's own kind, keyed by the
|
|
13524
|
+
* `integrations` registry id. The records door does the secret work: a field the
|
|
13525
|
+
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13526
|
+
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13527
|
+
*
|
|
13528
|
+
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13529
|
+
* token or the view the form was given KEEP the stored secret;
|
|
13530
|
+
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13531
|
+
*/
|
|
13364
13532
|
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13365
13533
|
var INSTANCES_LIST_MAX = 1e3;
|
|
13366
13534
|
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13367
13535
|
function topLevelSecretKeys(paths) {
|
|
13368
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[")));
|
|
13536
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13537
|
+
}
|
|
13538
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13539
|
+
function secretMapKeys(paths) {
|
|
13540
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13541
|
+
}
|
|
13542
|
+
/**
|
|
13543
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13544
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13545
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13546
|
+
*/
|
|
13547
|
+
function secretMapPatch(value) {
|
|
13548
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13549
|
+
const out = {};
|
|
13550
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13551
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13552
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
13553
|
+
}
|
|
13554
|
+
/** Does the kind's body schema carry an `enabled` field? */
|
|
13555
|
+
function declaresEnabled(kind) {
|
|
13556
|
+
const json = toJSONSchema(kind.schema, {
|
|
13557
|
+
unrepresentable: "any",
|
|
13558
|
+
io: "input"
|
|
13559
|
+
});
|
|
13560
|
+
const properties = Reflect.get(json, "properties");
|
|
13561
|
+
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13369
13562
|
}
|
|
13370
13563
|
var RecordIntegrationInstances = class {
|
|
13371
13564
|
records;
|
|
@@ -13373,14 +13566,20 @@ var RecordIntegrationInstances = class {
|
|
|
13373
13566
|
hooks;
|
|
13374
13567
|
handle;
|
|
13375
13568
|
secretKeys;
|
|
13569
|
+
secretMaps;
|
|
13376
13570
|
nameField;
|
|
13571
|
+
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13572
|
+
registryOwnsEnabled;
|
|
13377
13573
|
constructor(records, kind, hooks) {
|
|
13378
13574
|
this.records = records;
|
|
13379
13575
|
this.kind = kind;
|
|
13380
13576
|
this.hooks = hooks;
|
|
13381
13577
|
this.handle = records.kind(kind);
|
|
13382
13578
|
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13579
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13383
13580
|
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13581
|
+
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13582
|
+
if (this.registryOwnsEnabled && declaresEnabled(kind)) throw new Error(`kind "${kind.name}": the integrations registry owns the on/off switch of a role "devices" addon, so the body must not declare "enabled"`);
|
|
13384
13583
|
}
|
|
13385
13584
|
/**
|
|
13386
13585
|
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
@@ -13431,7 +13630,7 @@ var RecordIntegrationInstances = class {
|
|
|
13431
13630
|
id: record.id,
|
|
13432
13631
|
name: typeof rawName === "string" ? rawName : record.id,
|
|
13433
13632
|
configured: this.hooks.configured(record.data),
|
|
13434
|
-
enabled: record.data.enabled !== false,
|
|
13633
|
+
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13435
13634
|
formValues: shown,
|
|
13436
13635
|
...kind !== void 0 ? { kind } : {},
|
|
13437
13636
|
...health?.status !== void 0 ? { status: health.status } : {},
|
|
@@ -13451,7 +13650,7 @@ var RecordIntegrationInstances = class {
|
|
|
13451
13650
|
return record === null ? null : this.viewOf(record);
|
|
13452
13651
|
};
|
|
13453
13652
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13454
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13653
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13455
13654
|
const minted = id ?? this.hooks.mintId?.({
|
|
13456
13655
|
name,
|
|
13457
13656
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13461,32 +13660,43 @@ var RecordIntegrationInstances = class {
|
|
|
13461
13660
|
id: minted,
|
|
13462
13661
|
data: this.hooks.initialBody(name, kind)
|
|
13463
13662
|
}, { ifRev: 0 });
|
|
13464
|
-
|
|
13663
|
+
const patch = this.patchOf(values ?? {});
|
|
13664
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13665
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
13465
13666
|
return { id: minted };
|
|
13466
13667
|
};
|
|
13467
13668
|
updateInstance = async ({ id, name, values }) => {
|
|
13669
|
+
const patch = this.patchOf(values);
|
|
13670
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13671
|
+
await this.handle.patch(id, patch);
|
|
13672
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13673
|
+
return { ok: true };
|
|
13674
|
+
};
|
|
13675
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13676
|
+
patchOf(values) {
|
|
13468
13677
|
const patch = {};
|
|
13469
13678
|
for (const [key, value] of Object.entries(values)) {
|
|
13470
13679
|
if (value === void 0) continue;
|
|
13471
|
-
if (
|
|
13680
|
+
if (this.secretMaps.has(key)) {
|
|
13681
|
+
const entries = secretMapPatch(value);
|
|
13682
|
+
if (entries !== null) patch[key] = entries;
|
|
13683
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13472
13684
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13473
13685
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13474
13686
|
}
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
await this.hooks.onChanged?.(id);
|
|
13478
|
-
return { ok: true };
|
|
13479
|
-
};
|
|
13687
|
+
return patch;
|
|
13688
|
+
}
|
|
13480
13689
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13481
13690
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13691
|
+
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13482
13692
|
await this.handle.patch(id, { enabled });
|
|
13483
|
-
await this.hooks.onChanged?.(id);
|
|
13693
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
13484
13694
|
return { ok: true };
|
|
13485
13695
|
};
|
|
13486
13696
|
/** The row and its keychain refs go together (the records door). */
|
|
13487
13697
|
deleteInstance = async ({ id }) => {
|
|
13488
13698
|
await this.handle.delete(id);
|
|
13489
|
-
await this.hooks.onChanged?.(id);
|
|
13699
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
13490
13700
|
return { ok: true };
|
|
13491
13701
|
};
|
|
13492
13702
|
testInstance = async (input) => {
|
|
@@ -14557,7 +14767,13 @@ var MigrationLedgerEntrySchema = object({
|
|
|
14557
14767
|
* joined by the engine from the catalogues it knows this boot. Absent when no
|
|
14558
14768
|
* catalogue lists the id (a newer database).
|
|
14559
14769
|
*/
|
|
14560
|
-
meta: MigrationMetaSchema.optional()
|
|
14770
|
+
meta: MigrationMetaSchema.optional(),
|
|
14771
|
+
/**
|
|
14772
|
+
* Set when this is an applied row of an addon owner whose catalogue the answering
|
|
14773
|
+
* process has not loaded (the owner has not declared yet): the row is applied, the
|
|
14774
|
+
* process just cannot judge it. Never `skipped-newer` — that needs the owner loaded.
|
|
14775
|
+
*/
|
|
14776
|
+
ownerNotLoaded: boolean().optional()
|
|
14561
14777
|
});
|
|
14562
14778
|
/** A catalogued migration that is not applied, with where it stands. */
|
|
14563
14779
|
var MigrationPendingEntrySchema = object({
|
|
@@ -15678,6 +15894,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15678
15894
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15679
15895
|
total: number().int().nonnegative().nullable()
|
|
15680
15896
|
}).nullable();
|
|
15897
|
+
/**
|
|
15898
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
15899
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
15900
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
15901
|
+
* that was not asked about (a deleted or never-listed one).
|
|
15902
|
+
*
|
|
15903
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
15904
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
15905
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
15906
|
+
* it is a deleted location only when every location id was asked.
|
|
15907
|
+
* `null` is "could not be measured", never zero.
|
|
15908
|
+
*/
|
|
15909
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
15910
|
+
var MediaLocationCensusSchema = object({
|
|
15911
|
+
locations: array(object({
|
|
15912
|
+
locationId: string(),
|
|
15913
|
+
rows: number().int().nonnegative(),
|
|
15914
|
+
bytes: number().nonnegative()
|
|
15915
|
+
})).readonly(),
|
|
15916
|
+
unstamped: object({
|
|
15917
|
+
rows: number().int().nonnegative(),
|
|
15918
|
+
bytes: number().nonnegative()
|
|
15919
|
+
}),
|
|
15920
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
15921
|
+
unlisted: object({
|
|
15922
|
+
rows: number().int().nonnegative(),
|
|
15923
|
+
bytes: number().nonnegative()
|
|
15924
|
+
}),
|
|
15925
|
+
total: object({
|
|
15926
|
+
rows: number().int().nonnegative(),
|
|
15927
|
+
bytes: number().nonnegative()
|
|
15928
|
+
})
|
|
15929
|
+
});
|
|
15681
15930
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15682
15931
|
/** The independently selectable logical storage classes — every class
|
|
15683
15932
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -46217,52 +46466,7 @@ DeviceType.Light, method(object({
|
|
|
46217
46466
|
level: number().min(0).max(100),
|
|
46218
46467
|
lastChangedAt: number()
|
|
46219
46468
|
});
|
|
46220
|
-
|
|
46221
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
46222
|
-
*
|
|
46223
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
46224
|
-
* register and that other addons might consume. The first two kinds
|
|
46225
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
46226
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
46227
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
46228
|
-
* the same surface.
|
|
46229
|
-
*
|
|
46230
|
-
* Why one cap, not one cap per kind:
|
|
46231
|
-
* - The integrations page wants a single table of "every broker"
|
|
46232
|
-
* across kinds; a unified cap drives it without join logic.
|
|
46233
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
46234
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
46235
|
-
* - The `network-access` cap precedent: same interface, many
|
|
46236
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
46237
|
-
*
|
|
46238
|
-
* What stays kind-specific:
|
|
46239
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
46240
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
46241
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
46242
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
46243
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
46244
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
46245
|
-
* without rebreaking the cap signature.
|
|
46246
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
46247
|
-
* the kind-specific provider).
|
|
46248
|
-
*
|
|
46249
|
-
* Bidirectionality:
|
|
46250
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
46251
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
46252
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
46253
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
46254
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
46255
|
-
* provider re-subscribes upstream after a transport drop.
|
|
46256
|
-
*
|
|
46257
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
46258
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
46259
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
46260
|
-
* drop is recoverable via `getState({key})`).
|
|
46261
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
46262
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
46263
|
-
* per-broker wire-shaping needed.
|
|
46264
|
-
*/
|
|
46265
|
-
var BrokerStatusEnum = _enum([
|
|
46469
|
+
_enum([
|
|
46266
46470
|
"connected",
|
|
46267
46471
|
"disconnected",
|
|
46268
46472
|
"connecting",
|
|
@@ -46270,141 +46474,12 @@ var BrokerStatusEnum = _enum([
|
|
|
46270
46474
|
"unreachable",
|
|
46271
46475
|
"error"
|
|
46272
46476
|
]);
|
|
46273
|
-
var BrokerInfoSchema = object({
|
|
46274
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
46275
|
-
id: string(),
|
|
46276
|
-
/** Addon id of the provider that OWNS this broker.
|
|
46277
|
-
*
|
|
46278
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
46279
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
46280
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
46281
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
46282
|
-
* device belongs to one integration. The admin UI threads this id
|
|
46283
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
46284
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
46285
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
46286
|
-
* instead of defaulting to the first-registered one. */
|
|
46287
|
-
addonId: string(),
|
|
46288
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
46289
|
-
name: string(),
|
|
46290
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
46291
|
-
kind: string(),
|
|
46292
|
-
status: BrokerStatusEnum,
|
|
46293
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
46294
|
-
* flavour, latency, mTLS active, …). */
|
|
46295
|
-
info: record(string(), unknown()),
|
|
46296
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
46297
|
-
lastCheckedAt: number().nullable(),
|
|
46298
|
-
/** Last error message, when `status` indicates failure. */
|
|
46299
|
-
error: string().nullable()
|
|
46300
|
-
});
|
|
46301
46477
|
var RegistryStatusSchema = object({
|
|
46302
46478
|
brokerCount: number().int().nonnegative(),
|
|
46303
46479
|
connectedCount: number().int().nonnegative()
|
|
46304
46480
|
});
|
|
46305
|
-
/**
|
|
46306
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
46307
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
46308
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
46309
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
46310
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
46311
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
46312
|
-
* offers a kind whose creation form can't be rendered).
|
|
46313
|
-
*/
|
|
46314
|
-
var BrokerProviderInfoSchema = object({
|
|
46315
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
46316
|
-
addonId: string(),
|
|
46317
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
46318
|
-
kinds: array(object({
|
|
46319
|
-
kind: string(),
|
|
46320
|
-
label: string(),
|
|
46321
|
-
/**
|
|
46322
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
46323
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
46324
|
-
*/
|
|
46325
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
46326
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
46327
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
46328
|
-
/**
|
|
46329
|
-
* The kind signs in through a server-held interactive session instead of
|
|
46330
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
46331
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
46332
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
46333
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
46334
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
46335
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
46336
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
46337
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
46338
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
46339
|
-
* offers it as the default path; the fields the session fills are
|
|
46340
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
46341
|
-
*
|
|
46342
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
46343
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
46344
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
46345
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
46346
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
46347
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
46348
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
46349
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
46350
|
-
* `['proxy']`.
|
|
46351
|
-
*/
|
|
46352
|
-
signIn: object({
|
|
46353
|
-
basePath: string().min(1),
|
|
46354
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
46355
|
-
}).optional()
|
|
46356
|
-
}))
|
|
46357
|
-
});
|
|
46358
|
-
var ListInputSchema = object({
|
|
46359
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
46360
|
-
* only HA brokers. Omit to list every broker. */
|
|
46361
|
-
kind: string().optional() });
|
|
46362
46481
|
var GetInputSchema = object({ id: string() });
|
|
46363
|
-
var AddInputSchema = object({
|
|
46364
|
-
kind: string().min(1),
|
|
46365
|
-
name: string().min(1),
|
|
46366
|
-
/**
|
|
46367
|
-
* ADOPT an existing id instead of minting a new one.
|
|
46368
|
-
*
|
|
46369
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
46370
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
46371
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
46372
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
46373
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
46374
|
-
* password.
|
|
46375
|
-
*
|
|
46376
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
46377
|
-
* broker's id would silently take it over.
|
|
46378
|
-
*/
|
|
46379
|
-
id: string().min(1).optional(),
|
|
46380
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
46381
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
46382
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
46383
|
-
settings: record(string(), unknown())
|
|
46384
|
-
});
|
|
46385
|
-
var AddResultSchema = object({ id: string() });
|
|
46386
|
-
var RemoveInputSchema = object({ id: string() });
|
|
46387
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
46388
|
-
ok: literal(true),
|
|
46389
|
-
latencyMs: number().nonnegative()
|
|
46390
|
-
}), object({
|
|
46391
|
-
ok: literal(false),
|
|
46392
|
-
error: string()
|
|
46393
|
-
})]);
|
|
46394
46482
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
46395
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
46396
|
-
var TestSettingsInputSchema = object({
|
|
46397
|
-
kind: string(),
|
|
46398
|
-
settings: SettingsRecordSchema$1
|
|
46399
|
-
});
|
|
46400
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
46401
|
-
ok: literal(true),
|
|
46402
|
-
latencyMs: number().nonnegative().optional()
|
|
46403
|
-
}).strict(), object({
|
|
46404
|
-
ok: literal(false),
|
|
46405
|
-
error: string()
|
|
46406
|
-
})]);
|
|
46407
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
46408
46483
|
var PublishInputSchema = object({
|
|
46409
46484
|
brokerId: string(),
|
|
46410
46485
|
/** Kind-specific routing target.
|
|
@@ -46448,51 +46523,12 @@ var brokerCapability = {
|
|
|
46448
46523
|
kind: "poll"
|
|
46449
46524
|
},
|
|
46450
46525
|
methods: {
|
|
46451
|
-
list: method(ListInputSchema, array(BrokerInfoSchema)),
|
|
46452
|
-
get: method(GetInputSchema, BrokerInfoSchema.nullable()),
|
|
46453
|
-
/** Enumerate which addon provides which broker kind(s) for the
|
|
46454
|
-
* unified create picker. The auto-mount fans this array across
|
|
46455
|
-
* every registered `broker` provider (array-output method), so the
|
|
46456
|
-
* picker sees every kind from every provider in one call. */
|
|
46457
|
-
listProviders: method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }),
|
|
46458
|
-
add: method(AddInputSchema, AddResultSchema, {
|
|
46459
|
-
kind: "mutation",
|
|
46460
|
-
auth: "admin"
|
|
46461
|
-
}),
|
|
46462
|
-
remove: method(RemoveInputSchema, _void(), {
|
|
46463
|
-
kind: "mutation",
|
|
46464
|
-
auth: "admin"
|
|
46465
|
-
}),
|
|
46466
|
-
testConnection: method(GetInputSchema, TestConnectionResultSchema, {
|
|
46467
|
-
kind: "mutation",
|
|
46468
|
-
auth: "admin"
|
|
46469
|
-
}),
|
|
46470
|
-
/** Read the persisted settings record for a broker (kind-specific
|
|
46471
|
-
* shape). Admin-only — settings may contain secrets. Returns `null`
|
|
46472
|
-
* when the broker id is unknown to the provider (the collection
|
|
46473
|
-
* fallback may route a foreign id to the first provider). */
|
|
46474
|
-
getSettings: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46475
|
-
/** Overwrite the persisted settings record. The kind-specific
|
|
46476
|
-
* provider validates the shape and applies the change (reconnects
|
|
46477
|
-
* if credentials changed). */
|
|
46478
|
-
setSettings: method(object({
|
|
46479
|
-
id: string(),
|
|
46480
|
-
settings: SettingsRecordSchema$1
|
|
46481
|
-
}), _void(), {
|
|
46482
|
-
kind: "mutation",
|
|
46483
|
-
auth: "admin"
|
|
46484
|
-
}),
|
|
46485
46526
|
/** Returns the kind-specific connection config the consumer needs
|
|
46486
46527
|
* to open its own client (MQTT pattern: `{url, username, password,
|
|
46487
46528
|
* clientIdPrefix}`). HA providers MAY return the auth envelope
|
|
46488
46529
|
* but typical HA consumers use `publish` / `subscribe` instead.
|
|
46489
46530
|
* Returns `null` when the broker id is unknown to the provider. */
|
|
46490
46531
|
getBrokerConfig: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46491
|
-
getSettingsSchema: method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }),
|
|
46492
|
-
testSettings: method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
46493
|
-
kind: "mutation",
|
|
46494
|
-
auth: "admin"
|
|
46495
|
-
}),
|
|
46496
46532
|
publish: method(PublishInputSchema, unknown(), {
|
|
46497
46533
|
kind: "mutation",
|
|
46498
46534
|
auth: "admin"
|
|
@@ -49126,6 +49162,9 @@ var RunningProposalEvidenceSchema = object({
|
|
|
49126
49162
|
runsFound: number().int().nonnegative(),
|
|
49127
49163
|
pausesFound: number().int().nonnegative(),
|
|
49128
49164
|
longestPauseMs: number().nonnegative(),
|
|
49165
|
+
/** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
|
|
49166
|
+
pulsesFound: number().int().nonnegative(),
|
|
49167
|
+
longestPulseMs: number().nonnegative(),
|
|
49129
49168
|
idleFloorW: number(),
|
|
49130
49169
|
noiseCeilingW: number(),
|
|
49131
49170
|
plateauW: number(),
|
|
@@ -50572,7 +50611,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
50572
50611
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
50573
50612
|
parentStableId: string().optional(),
|
|
50574
50613
|
/** `false` = shown for context but not pickable. Default true. */
|
|
50575
|
-
selectable: boolean().optional()
|
|
50614
|
+
selectable: boolean().optional(),
|
|
50615
|
+
/**
|
|
50616
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
50617
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
50618
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
50619
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
50620
|
+
*/
|
|
50621
|
+
needsParams: array(string()).optional()
|
|
50576
50622
|
});
|
|
50577
50623
|
/**
|
|
50578
50624
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -50631,12 +50677,24 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
|
|
|
50631
50677
|
}), array(DiscoveryCandidateSchema), {
|
|
50632
50678
|
kind: "mutation",
|
|
50633
50679
|
auth: "admin"
|
|
50634
|
-
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50680
|
+
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50681
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50682
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
|
|
50683
|
+
candidate: DiscoveryCandidateSchema,
|
|
50684
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
50685
|
+
integrationId: string().optional()
|
|
50686
|
+
}), DeviceSummarySchema, {
|
|
50635
50687
|
kind: "mutation",
|
|
50636
50688
|
auth: "admin"
|
|
50637
|
-
}), method(object({}), boolean()), method(object({
|
|
50689
|
+
}), method(object({}), boolean()), method(object({
|
|
50638
50690
|
type: _enum(DeviceType),
|
|
50639
|
-
|
|
50691
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50692
|
+
integrationId: string().optional()
|
|
50693
|
+
}), CreationSchemaOutputSchema), method(object({
|
|
50694
|
+
type: _enum(DeviceType),
|
|
50695
|
+
config: record(string(), unknown()),
|
|
50696
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
50697
|
+
integrationId: string().optional()
|
|
50640
50698
|
}), DeviceSummarySchema, {
|
|
50641
50699
|
kind: "mutation",
|
|
50642
50700
|
auth: "admin"
|
|
@@ -51346,7 +51404,10 @@ method(object({
|
|
|
51346
51404
|
auth: "admin"
|
|
51347
51405
|
}), method(object({
|
|
51348
51406
|
addonId: string(),
|
|
51349
|
-
type: _enum(DeviceType)
|
|
51407
|
+
type: _enum(DeviceType),
|
|
51408
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
51409
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
51410
|
+
integrationId: string().optional()
|
|
51350
51411
|
}), unknown().nullable()), method(object({
|
|
51351
51412
|
addonId: string(),
|
|
51352
51413
|
type: _enum(DeviceType),
|
|
@@ -51430,7 +51491,11 @@ method(object({
|
|
|
51430
51491
|
kind: "mutation",
|
|
51431
51492
|
auth: "admin",
|
|
51432
51493
|
timeoutMs: 12e4
|
|
51433
|
-
}), method(object({
|
|
51494
|
+
}), method(object({
|
|
51495
|
+
addonId: string(),
|
|
51496
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
51497
|
+
integrationId: string().optional()
|
|
51498
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
51434
51499
|
deviceId: number(),
|
|
51435
51500
|
key: string(),
|
|
51436
51501
|
value: unknown()
|
|
@@ -54026,7 +54091,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
54026
54091
|
"inconclusive",
|
|
54027
54092
|
"unsupported"
|
|
54028
54093
|
]);
|
|
54029
|
-
var TestConnectionResultSchema
|
|
54094
|
+
var TestConnectionResultSchema = object({
|
|
54030
54095
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
54031
54096
|
success: boolean(),
|
|
54032
54097
|
error: string().optional(),
|
|
@@ -54047,11 +54112,7 @@ var CreateIntegrationInputSchema = object({
|
|
|
54047
54112
|
info: record(string(), unknown()).optional(),
|
|
54048
54113
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54049
54114
|
originStableId: string().optional(),
|
|
54050
|
-
settings: record(string(), unknown()).optional()
|
|
54051
|
-
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
54052
|
-
* the keychain, not the table (D787). */
|
|
54053
|
-
secretKeys: array(string()).optional(),
|
|
54054
|
-
skipRestart: boolean().optional()
|
|
54115
|
+
settings: record(string(), unknown()).optional()
|
|
54055
54116
|
});
|
|
54056
54117
|
var UpdateIntegrationInputSchema = object({
|
|
54057
54118
|
id: string(),
|
|
@@ -54072,20 +54133,10 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54072
54133
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
54073
54134
|
kind: "mutation",
|
|
54074
54135
|
auth: "admin"
|
|
54075
|
-
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
54076
|
-
id: string(),
|
|
54077
|
-
settings: record(string(), unknown()),
|
|
54078
|
-
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
54079
|
-
secretKeys: array(string()).optional(),
|
|
54080
|
-
/** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
|
|
54081
|
-
skipRestart: boolean().optional()
|
|
54082
|
-
}), object({ success: boolean() }), {
|
|
54083
|
-
kind: "mutation",
|
|
54084
|
-
auth: "admin"
|
|
54085
54136
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
54086
54137
|
addonId: string(),
|
|
54087
54138
|
settings: record(string(), unknown())
|
|
54088
|
-
}), TestConnectionResultSchema
|
|
54139
|
+
}), TestConnectionResultSchema, {
|
|
54089
54140
|
kind: "mutation",
|
|
54090
54141
|
auth: "admin"
|
|
54091
54142
|
});
|
|
@@ -54112,6 +54163,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
54112
54163
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54113
54164
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54114
54165
|
/**
|
|
54166
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54167
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
54168
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54169
|
+
* Integrations.
|
|
54170
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
54171
|
+
*/
|
|
54172
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
54173
|
+
/**
|
|
54115
54174
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54116
54175
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54117
54176
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -54122,6 +54181,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54122
54181
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54123
54182
|
id: string().min(1),
|
|
54124
54183
|
label: string().min(1),
|
|
54184
|
+
/**
|
|
54185
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
54186
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
54187
|
+
* provider with more than one section must name it on every kind.
|
|
54188
|
+
*/
|
|
54189
|
+
functionCap: string().min(1),
|
|
54190
|
+
/**
|
|
54191
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
54192
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
54193
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
54194
|
+
*/
|
|
54195
|
+
brokerKind: string().min(1).optional(),
|
|
54196
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
54197
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
54198
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
54199
|
+
canTest: boolean().optional(),
|
|
54125
54200
|
/** The kind signs in through a server-held interactive session. */
|
|
54126
54201
|
signIn: object({
|
|
54127
54202
|
basePath: string().min(1),
|
|
@@ -54133,6 +54208,17 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54133
54208
|
disconnectPath: string().min(1).optional()
|
|
54134
54209
|
});
|
|
54135
54210
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54211
|
+
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54212
|
+
role: IntegrationInstanceRoleSchema,
|
|
54213
|
+
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54214
|
+
discovery: object({
|
|
54215
|
+
mode: _enum([
|
|
54216
|
+
"none",
|
|
54217
|
+
"lan",
|
|
54218
|
+
"account"
|
|
54219
|
+
]),
|
|
54220
|
+
scopedToInstance: boolean()
|
|
54221
|
+
}).optional(),
|
|
54136
54222
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54137
54223
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54138
54224
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54172,10 +54258,11 @@ var IntegrationInstanceSchema = object({
|
|
|
54172
54258
|
/** The addon's own rule (an URL is present, a client id is present...). */
|
|
54173
54259
|
configured: boolean(),
|
|
54174
54260
|
/**
|
|
54175
|
-
* The instance's own on/off switch (D996)
|
|
54176
|
-
*
|
|
54261
|
+
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54262
|
+
* so a row written before the field existed is on). Absent when the `integrations` registry
|
|
54263
|
+
* owns the switch (`describe().role` is `devices`): read it from the registry row.
|
|
54177
54264
|
*/
|
|
54178
|
-
enabled: boolean(),
|
|
54265
|
+
enabled: boolean().optional(),
|
|
54179
54266
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
54180
54267
|
kind: string().optional(),
|
|
54181
54268
|
/** Values for the instance form; a secret is a `SecretFieldView`, never text. */
|
|
@@ -54197,7 +54284,11 @@ var integrationInstancesCapability = {
|
|
|
54197
54284
|
methods: {
|
|
54198
54285
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
54199
54286
|
/** The form; `id: null` is the create form. */
|
|
54200
|
-
instanceFormSchema: method(object({
|
|
54287
|
+
instanceFormSchema: method(object({
|
|
54288
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
54289
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
54290
|
+
kind: string().min(1).optional()
|
|
54291
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54201
54292
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54202
54293
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54203
54294
|
/**
|
|
@@ -54207,7 +54298,9 @@ var integrationInstancesCapability = {
|
|
|
54207
54298
|
createInstance: method(object({
|
|
54208
54299
|
id: IntegrationInstanceIdSchema.optional(),
|
|
54209
54300
|
name: string().min(1),
|
|
54210
|
-
kind: string().min(1).optional()
|
|
54301
|
+
kind: string().min(1).optional(),
|
|
54302
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
54303
|
+
values: record(string(), unknown()).optional()
|
|
54211
54304
|
}), object({ id: string() }), {
|
|
54212
54305
|
kind: "mutation",
|
|
54213
54306
|
auth: "admin"
|
|
@@ -54234,8 +54327,10 @@ var integrationInstancesCapability = {
|
|
|
54234
54327
|
}),
|
|
54235
54328
|
testInstance: optionalMethod(object({
|
|
54236
54329
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
54237
|
-
values: record(string(), unknown())
|
|
54238
|
-
|
|
54330
|
+
values: record(string(), unknown()),
|
|
54331
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
54332
|
+
kind: string().min(1).optional()
|
|
54333
|
+
}), TestConnectionResultSchema, {
|
|
54239
54334
|
kind: "mutation",
|
|
54240
54335
|
auth: "admin"
|
|
54241
54336
|
})
|
|
@@ -56740,6 +56835,380 @@ var SystemMetricsSchema = object({
|
|
|
56740
56835
|
gpuMemoryPercent: number().optional()
|
|
56741
56836
|
});
|
|
56742
56837
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
|
|
56838
|
+
/**
|
|
56839
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
56840
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
56841
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
56842
|
+
*
|
|
56843
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
56844
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
56845
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
56846
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
56847
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
56848
|
+
* addons go through the owner's capability.
|
|
56849
|
+
*
|
|
56850
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
56851
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
56852
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
56853
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
56854
|
+
* row's own ref.
|
|
56855
|
+
*
|
|
56856
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
56857
|
+
*/
|
|
56858
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
56859
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
56860
|
+
var RecordBodySchema = record(string(), unknown());
|
|
56861
|
+
var RecordInputSchema = object({
|
|
56862
|
+
id: RecordIdSchema,
|
|
56863
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
56864
|
+
deviceId: number().int().optional(),
|
|
56865
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
56866
|
+
at: number().int().optional(),
|
|
56867
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
56868
|
+
expiresAt: number().int().optional(),
|
|
56869
|
+
data: RecordBodySchema
|
|
56870
|
+
});
|
|
56871
|
+
var RecordViewSchema = object({
|
|
56872
|
+
id: string(),
|
|
56873
|
+
deviceId: number().int().nullable(),
|
|
56874
|
+
at: number().nullable(),
|
|
56875
|
+
expiresAt: number().nullable(),
|
|
56876
|
+
rev: number().int(),
|
|
56877
|
+
updatedAt: number(),
|
|
56878
|
+
data: RecordBodySchema
|
|
56879
|
+
});
|
|
56880
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
56881
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
56882
|
+
string(),
|
|
56883
|
+
number(),
|
|
56884
|
+
boolean(),
|
|
56885
|
+
object({ in: array(union([
|
|
56886
|
+
string(),
|
|
56887
|
+
number(),
|
|
56888
|
+
boolean()
|
|
56889
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
56890
|
+
object({
|
|
56891
|
+
gt: union([string(), number()]).optional(),
|
|
56892
|
+
gte: union([string(), number()]).optional(),
|
|
56893
|
+
lt: union([string(), number()]).optional(),
|
|
56894
|
+
lte: union([string(), number()]).optional()
|
|
56895
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
56896
|
+
]));
|
|
56897
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
56898
|
+
var TimeWindowShape = {
|
|
56899
|
+
deviceId: number().int().optional(),
|
|
56900
|
+
atFrom: number().optional(),
|
|
56901
|
+
atTo: number().optional()
|
|
56902
|
+
};
|
|
56903
|
+
var RecordQueryInputSchema = object({
|
|
56904
|
+
...KindShape,
|
|
56905
|
+
...TimeWindowShape,
|
|
56906
|
+
where: RecordWhereSchema.optional(),
|
|
56907
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
56908
|
+
order: _enum(["at", "id"]).optional(),
|
|
56909
|
+
desc: boolean().optional(),
|
|
56910
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
56911
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
56912
|
+
cursor: string().min(1).optional()
|
|
56913
|
+
});
|
|
56914
|
+
var RecordQueryResultSchema = object({
|
|
56915
|
+
records: array(RecordViewSchema),
|
|
56916
|
+
nextCursor: string().nullable()
|
|
56917
|
+
});
|
|
56918
|
+
var RecordKindStateSchema = _enum([
|
|
56919
|
+
"created",
|
|
56920
|
+
"unchanged",
|
|
56921
|
+
"updated"
|
|
56922
|
+
]);
|
|
56923
|
+
var DeclareKindResultSchema = object({
|
|
56924
|
+
kindId: number().int(),
|
|
56925
|
+
state: RecordKindStateSchema,
|
|
56926
|
+
createdIndexes: array(string())
|
|
56927
|
+
});
|
|
56928
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
56929
|
+
var SecretRefsList = array(string());
|
|
56930
|
+
/**
|
|
56931
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
56932
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
56933
|
+
*/
|
|
56934
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
56935
|
+
object({
|
|
56936
|
+
op: literal("put"),
|
|
56937
|
+
kind: RecordKindNameSchema,
|
|
56938
|
+
record: RecordInputSchema,
|
|
56939
|
+
ifRev: number().int().min(0).optional()
|
|
56940
|
+
}),
|
|
56941
|
+
object({
|
|
56942
|
+
op: literal("patch"),
|
|
56943
|
+
kind: RecordKindNameSchema,
|
|
56944
|
+
id: RecordIdSchema,
|
|
56945
|
+
data: RecordBodySchema,
|
|
56946
|
+
at: number().int().nullable().optional(),
|
|
56947
|
+
expiresAt: number().int().nullable().optional(),
|
|
56948
|
+
ifRev: number().int().min(1).optional()
|
|
56949
|
+
}),
|
|
56950
|
+
object({
|
|
56951
|
+
op: literal("delete"),
|
|
56952
|
+
kind: RecordKindNameSchema,
|
|
56953
|
+
id: RecordIdSchema
|
|
56954
|
+
})
|
|
56955
|
+
]);
|
|
56956
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
56957
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
56958
|
+
kind: "mutation",
|
|
56959
|
+
auth: "admin"
|
|
56960
|
+
}), method(object({
|
|
56961
|
+
...KindShape,
|
|
56962
|
+
id: RecordIdSchema
|
|
56963
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
56964
|
+
...KindShape,
|
|
56965
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
56966
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
56967
|
+
...KindShape,
|
|
56968
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
56969
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
56970
|
+
...KindShape,
|
|
56971
|
+
record: RecordInputSchema,
|
|
56972
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
56973
|
+
ifRev: number().int().min(0).optional()
|
|
56974
|
+
}), object({
|
|
56975
|
+
rev: number().int(),
|
|
56976
|
+
releasedRefs: SecretRefsList
|
|
56977
|
+
}), {
|
|
56978
|
+
kind: "mutation",
|
|
56979
|
+
auth: "admin"
|
|
56980
|
+
}), method(object({
|
|
56981
|
+
...KindShape,
|
|
56982
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
56983
|
+
}), object({
|
|
56984
|
+
count: number().int(),
|
|
56985
|
+
releasedRefs: SecretRefsList
|
|
56986
|
+
}), {
|
|
56987
|
+
kind: "mutation",
|
|
56988
|
+
auth: "admin"
|
|
56989
|
+
}), method(object({
|
|
56990
|
+
...KindShape,
|
|
56991
|
+
id: RecordIdSchema,
|
|
56992
|
+
data: RecordBodySchema,
|
|
56993
|
+
at: number().int().nullable().optional(),
|
|
56994
|
+
expiresAt: number().int().nullable().optional(),
|
|
56995
|
+
ifRev: number().int().min(1).optional()
|
|
56996
|
+
}), object({
|
|
56997
|
+
rev: number().int(),
|
|
56998
|
+
releasedRefs: SecretRefsList
|
|
56999
|
+
}), {
|
|
57000
|
+
kind: "mutation",
|
|
57001
|
+
auth: "admin"
|
|
57002
|
+
}), method(object({
|
|
57003
|
+
...KindShape,
|
|
57004
|
+
id: RecordIdSchema
|
|
57005
|
+
}), object({
|
|
57006
|
+
deleted: boolean(),
|
|
57007
|
+
secretRefs: SecretRefsList
|
|
57008
|
+
}), {
|
|
57009
|
+
kind: "mutation",
|
|
57010
|
+
auth: "admin"
|
|
57011
|
+
}), method(object({
|
|
57012
|
+
...KindShape,
|
|
57013
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57014
|
+
}), object({
|
|
57015
|
+
deleted: number().int(),
|
|
57016
|
+
secretRefs: SecretRefsList
|
|
57017
|
+
}), {
|
|
57018
|
+
kind: "mutation",
|
|
57019
|
+
auth: "admin"
|
|
57020
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
57021
|
+
...KindShape,
|
|
57022
|
+
...TimeWindowShape,
|
|
57023
|
+
where: RecordWhereSchema.optional()
|
|
57024
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
57025
|
+
...KindShape,
|
|
57026
|
+
deviceId: number().int().optional(),
|
|
57027
|
+
from: number(),
|
|
57028
|
+
to: number(),
|
|
57029
|
+
bucketMs: number().int().positive()
|
|
57030
|
+
}), object({ buckets: array(object({
|
|
57031
|
+
bucketStart: number(),
|
|
57032
|
+
count: number().int()
|
|
57033
|
+
})) }), { auth: "admin" }), method(object({
|
|
57034
|
+
...KindShape,
|
|
57035
|
+
op: _enum([
|
|
57036
|
+
"sum",
|
|
57037
|
+
"min",
|
|
57038
|
+
"max",
|
|
57039
|
+
"count"
|
|
57040
|
+
]),
|
|
57041
|
+
field: RecordFieldPathSchema.optional(),
|
|
57042
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
57043
|
+
where: RecordWhereSchema.optional()
|
|
57044
|
+
}), object({ rows: array(object({
|
|
57045
|
+
group: union([
|
|
57046
|
+
string(),
|
|
57047
|
+
number(),
|
|
57048
|
+
_null()
|
|
57049
|
+
]),
|
|
57050
|
+
value: number().nullable()
|
|
57051
|
+
})) }), { auth: "admin" }), method(object({
|
|
57052
|
+
...KindShape,
|
|
57053
|
+
deviceId: number().int().optional(),
|
|
57054
|
+
atBefore: number().optional(),
|
|
57055
|
+
where: RecordWhereSchema.optional()
|
|
57056
|
+
}), object({
|
|
57057
|
+
deleted: number().int(),
|
|
57058
|
+
secretRefs: SecretRefsList
|
|
57059
|
+
}), {
|
|
57060
|
+
kind: "mutation",
|
|
57061
|
+
auth: "admin"
|
|
57062
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
57063
|
+
results: array(object({
|
|
57064
|
+
rev: number().int().nullable(),
|
|
57065
|
+
deleted: boolean()
|
|
57066
|
+
})),
|
|
57067
|
+
releasedRefs: SecretRefsList,
|
|
57068
|
+
secretRefs: SecretRefsList
|
|
57069
|
+
}), {
|
|
57070
|
+
kind: "mutation",
|
|
57071
|
+
auth: "admin"
|
|
57072
|
+
}), method(object({
|
|
57073
|
+
deviceId: number().int(),
|
|
57074
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
57075
|
+
}), object({
|
|
57076
|
+
deleted: record(string(), number().int()),
|
|
57077
|
+
secretRefs: SecretRefsList
|
|
57078
|
+
}), {
|
|
57079
|
+
kind: "mutation",
|
|
57080
|
+
auth: "admin"
|
|
57081
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
57082
|
+
kind: "mutation",
|
|
57083
|
+
auth: "admin"
|
|
57084
|
+
});
|
|
57085
|
+
/**
|
|
57086
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
57087
|
+
*
|
|
57088
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
57089
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
57090
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
57091
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
57092
|
+
*
|
|
57093
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
57094
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
57095
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
57096
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
57097
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
57098
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
57099
|
+
*/
|
|
57100
|
+
var Rows = record(string(), unknown());
|
|
57101
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
57102
|
+
var RecordId = object({ id: string().min(1) });
|
|
57103
|
+
var RecordRowSchema = object({
|
|
57104
|
+
id: string(),
|
|
57105
|
+
deviceId: number().int().nullable(),
|
|
57106
|
+
at: number().nullable(),
|
|
57107
|
+
expiresAt: number().nullable(),
|
|
57108
|
+
rev: number().int(),
|
|
57109
|
+
updatedAt: number(),
|
|
57110
|
+
data: Rows
|
|
57111
|
+
});
|
|
57112
|
+
var RecordPutShape = {
|
|
57113
|
+
id: string().min(1),
|
|
57114
|
+
deviceId: number().int().optional(),
|
|
57115
|
+
at: number().int().optional(),
|
|
57116
|
+
expiresAt: number().int().optional(),
|
|
57117
|
+
data: Rows
|
|
57118
|
+
};
|
|
57119
|
+
var MigrationIntegrationSchema = object({
|
|
57120
|
+
id: string(),
|
|
57121
|
+
addonId: string(),
|
|
57122
|
+
name: string(),
|
|
57123
|
+
info: Rows,
|
|
57124
|
+
originStableId: string().optional()
|
|
57125
|
+
});
|
|
57126
|
+
var MigrationDeviceSchema = object({
|
|
57127
|
+
id: number().int(),
|
|
57128
|
+
integrationId: string().nullable().optional(),
|
|
57129
|
+
/** The owning device; null or absent for a root. */
|
|
57130
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
57131
|
+
type: string().optional(),
|
|
57132
|
+
name: string().optional(),
|
|
57133
|
+
stableId: string().optional()
|
|
57134
|
+
});
|
|
57135
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
57136
|
+
var MigrationApiInfoSchema = object({
|
|
57137
|
+
version: number().int(),
|
|
57138
|
+
methods: array(string())
|
|
57139
|
+
});
|
|
57140
|
+
object({
|
|
57141
|
+
message: string(),
|
|
57142
|
+
meta: Rows.optional(),
|
|
57143
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
57144
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
57145
|
+
});
|
|
57146
|
+
object({
|
|
57147
|
+
owner: string().min(1),
|
|
57148
|
+
metas: array(MigrationMetaSchema)
|
|
57149
|
+
}), object({
|
|
57150
|
+
bootId: string(),
|
|
57151
|
+
snapshot: _enum([
|
|
57152
|
+
"none",
|
|
57153
|
+
"written",
|
|
57154
|
+
"refused"
|
|
57155
|
+
]),
|
|
57156
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57157
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
57158
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
57159
|
+
}), object({ id: string().min(1) }), object({
|
|
57160
|
+
proceed: boolean(),
|
|
57161
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
57162
|
+
reason: string().nullable()
|
|
57163
|
+
}), object({
|
|
57164
|
+
id: string().min(1),
|
|
57165
|
+
result: MigrationOwnerResultSchema
|
|
57166
|
+
}), object({
|
|
57167
|
+
status: MigrationStatusSchema,
|
|
57168
|
+
error: string().nullable(),
|
|
57169
|
+
rowsChanged: number().int().nonnegative()
|
|
57170
|
+
}), object({
|
|
57171
|
+
rows: number().int().nonnegative(),
|
|
57172
|
+
secrets: number().int().nonnegative()
|
|
57173
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
57174
|
+
present: boolean(),
|
|
57175
|
+
removed: Rows
|
|
57176
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
57177
|
+
...RecordPutShape,
|
|
57178
|
+
ifRev: number().int().optional()
|
|
57179
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
57180
|
+
partial: Rows,
|
|
57181
|
+
ifRev: number().int().optional()
|
|
57182
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
57183
|
+
deviceId: number().int().optional(),
|
|
57184
|
+
atFrom: number().optional(),
|
|
57185
|
+
atTo: number().optional(),
|
|
57186
|
+
where: RecordWhereSchema.optional(),
|
|
57187
|
+
limit: number().int().min(1).optional(),
|
|
57188
|
+
cursor: string().min(1).optional(),
|
|
57189
|
+
resolveSecrets: boolean().optional()
|
|
57190
|
+
}), object({
|
|
57191
|
+
records: array(RecordRowSchema),
|
|
57192
|
+
nextCursor: string().nullable()
|
|
57193
|
+
}), object({
|
|
57194
|
+
deviceId: number().int().optional(),
|
|
57195
|
+
atBefore: number().optional(),
|
|
57196
|
+
where: RecordWhereSchema.optional()
|
|
57197
|
+
}), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
|
|
57198
|
+
ref: string().min(1),
|
|
57199
|
+
value: string()
|
|
57200
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
57201
|
+
addonId: string().min(1),
|
|
57202
|
+
integrationId: string().min(1).optional()
|
|
57203
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
57204
|
+
id: number().int(),
|
|
57205
|
+
integrationId: string().nullable(),
|
|
57206
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
57207
|
+
hasConfig: boolean()
|
|
57208
|
+
}).nullable(), object({
|
|
57209
|
+
deviceId: number().int(),
|
|
57210
|
+
integrationId: string().min(1)
|
|
57211
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
56743
57212
|
method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
|
|
56744
57213
|
id: string().min(1),
|
|
56745
57214
|
error: string().min(1)
|
|
@@ -56769,7 +57238,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
56769
57238
|
"written",
|
|
56770
57239
|
"refused"
|
|
56771
57240
|
]),
|
|
56772
|
-
steps: array(MigrationOwnerStepSchema)
|
|
57241
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57242
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
57243
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
56773
57244
|
}), {
|
|
56774
57245
|
kind: "mutation",
|
|
56775
57246
|
auth: "admin"
|
|
@@ -56790,6 +57261,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
56790
57261
|
}), {
|
|
56791
57262
|
kind: "mutation",
|
|
56792
57263
|
auth: "admin"
|
|
57264
|
+
}), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
|
|
57265
|
+
rows: number().int().nonnegative(),
|
|
57266
|
+
secrets: number().int().nonnegative()
|
|
57267
|
+
}), {
|
|
57268
|
+
kind: "mutation",
|
|
57269
|
+
auth: "admin"
|
|
57270
|
+
}), method(object({
|
|
57271
|
+
integrationId: string().min(1),
|
|
57272
|
+
patch: record(string(), unknown())
|
|
57273
|
+
}), object({ written: boolean() }), {
|
|
57274
|
+
kind: "mutation",
|
|
57275
|
+
auth: "admin"
|
|
57276
|
+
}), method(object({
|
|
57277
|
+
integrationId: string().min(1),
|
|
57278
|
+
keys: array(string().min(1))
|
|
57279
|
+
}), object({
|
|
57280
|
+
present: boolean(),
|
|
57281
|
+
removed: record(string(), unknown())
|
|
57282
|
+
}), {
|
|
57283
|
+
kind: "mutation",
|
|
57284
|
+
auth: "admin"
|
|
56793
57285
|
});
|
|
56794
57286
|
method(object({
|
|
56795
57287
|
sourceUrl: string(),
|
|
@@ -59415,7 +59907,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
59415
59907
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
59416
59908
|
kind: "mutation",
|
|
59417
59909
|
auth: "admin"
|
|
59418
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
59910
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
59911
|
+
kind: "query",
|
|
59912
|
+
auth: "admin"
|
|
59913
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
59419
59914
|
kind: "query",
|
|
59420
59915
|
auth: "admin"
|
|
59421
59916
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -61822,7 +62317,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
61822
62317
|
"unreachable",
|
|
61823
62318
|
"tls-error"
|
|
61824
62319
|
]);
|
|
61825
|
-
var BrokerInfoSchema
|
|
62320
|
+
var BrokerInfoSchema = object({
|
|
61826
62321
|
id: string(),
|
|
61827
62322
|
name: string(),
|
|
61828
62323
|
url: string(),
|
|
@@ -61885,7 +62380,7 @@ var StatusSchema = object({
|
|
|
61885
62380
|
brokerCount: number(),
|
|
61886
62381
|
embeddedRunning: boolean()
|
|
61887
62382
|
});
|
|
61888
|
-
method(_void(), array(BrokerInfoSchema
|
|
62383
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
61889
62384
|
kind: "mutation",
|
|
61890
62385
|
auth: "admin"
|
|
61891
62386
|
}), method(IdInputSchema, _void(), {
|
|
@@ -68203,253 +68698,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
68203
68698
|
auth: "admin"
|
|
68204
68699
|
});
|
|
68205
68700
|
/**
|
|
68206
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
68207
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
68208
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
68209
|
-
*
|
|
68210
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
68211
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
68212
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
68213
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
68214
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
68215
|
-
* addons go through the owner's capability.
|
|
68216
|
-
*
|
|
68217
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
68218
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
68219
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
68220
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
68221
|
-
* row's own ref.
|
|
68222
|
-
*
|
|
68223
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
68224
|
-
*/
|
|
68225
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
68226
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
68227
|
-
var RecordBodySchema = record(string(), unknown());
|
|
68228
|
-
var RecordInputSchema = object({
|
|
68229
|
-
id: RecordIdSchema,
|
|
68230
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
68231
|
-
deviceId: number().int().optional(),
|
|
68232
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
68233
|
-
at: number().int().optional(),
|
|
68234
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
68235
|
-
expiresAt: number().int().optional(),
|
|
68236
|
-
data: RecordBodySchema
|
|
68237
|
-
});
|
|
68238
|
-
var RecordViewSchema = object({
|
|
68239
|
-
id: string(),
|
|
68240
|
-
deviceId: number().int().nullable(),
|
|
68241
|
-
at: number().nullable(),
|
|
68242
|
-
expiresAt: number().nullable(),
|
|
68243
|
-
rev: number().int(),
|
|
68244
|
-
updatedAt: number(),
|
|
68245
|
-
data: RecordBodySchema
|
|
68246
|
-
});
|
|
68247
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
68248
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
68249
|
-
string(),
|
|
68250
|
-
number(),
|
|
68251
|
-
boolean(),
|
|
68252
|
-
object({ in: array(union([
|
|
68253
|
-
string(),
|
|
68254
|
-
number(),
|
|
68255
|
-
boolean()
|
|
68256
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
68257
|
-
object({
|
|
68258
|
-
gt: union([string(), number()]).optional(),
|
|
68259
|
-
gte: union([string(), number()]).optional(),
|
|
68260
|
-
lt: union([string(), number()]).optional(),
|
|
68261
|
-
lte: union([string(), number()]).optional()
|
|
68262
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
68263
|
-
]));
|
|
68264
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
68265
|
-
var TimeWindowShape = {
|
|
68266
|
-
deviceId: number().int().optional(),
|
|
68267
|
-
atFrom: number().optional(),
|
|
68268
|
-
atTo: number().optional()
|
|
68269
|
-
};
|
|
68270
|
-
var RecordQueryInputSchema = object({
|
|
68271
|
-
...KindShape,
|
|
68272
|
-
...TimeWindowShape,
|
|
68273
|
-
where: RecordWhereSchema.optional(),
|
|
68274
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
68275
|
-
order: _enum(["at", "id"]).optional(),
|
|
68276
|
-
desc: boolean().optional(),
|
|
68277
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
68278
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
68279
|
-
cursor: string().min(1).optional()
|
|
68280
|
-
});
|
|
68281
|
-
var RecordQueryResultSchema = object({
|
|
68282
|
-
records: array(RecordViewSchema),
|
|
68283
|
-
nextCursor: string().nullable()
|
|
68284
|
-
});
|
|
68285
|
-
var RecordKindStateSchema = _enum([
|
|
68286
|
-
"created",
|
|
68287
|
-
"unchanged",
|
|
68288
|
-
"updated"
|
|
68289
|
-
]);
|
|
68290
|
-
var DeclareKindResultSchema = object({
|
|
68291
|
-
kindId: number().int(),
|
|
68292
|
-
state: RecordKindStateSchema,
|
|
68293
|
-
createdIndexes: array(string())
|
|
68294
|
-
});
|
|
68295
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
68296
|
-
var SecretRefsList = array(string());
|
|
68297
|
-
/**
|
|
68298
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
68299
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
68300
|
-
*/
|
|
68301
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
68302
|
-
object({
|
|
68303
|
-
op: literal("put"),
|
|
68304
|
-
kind: RecordKindNameSchema,
|
|
68305
|
-
record: RecordInputSchema,
|
|
68306
|
-
ifRev: number().int().min(0).optional()
|
|
68307
|
-
}),
|
|
68308
|
-
object({
|
|
68309
|
-
op: literal("patch"),
|
|
68310
|
-
kind: RecordKindNameSchema,
|
|
68311
|
-
id: RecordIdSchema,
|
|
68312
|
-
data: RecordBodySchema,
|
|
68313
|
-
at: number().int().nullable().optional(),
|
|
68314
|
-
expiresAt: number().int().nullable().optional(),
|
|
68315
|
-
ifRev: number().int().min(1).optional()
|
|
68316
|
-
}),
|
|
68317
|
-
object({
|
|
68318
|
-
op: literal("delete"),
|
|
68319
|
-
kind: RecordKindNameSchema,
|
|
68320
|
-
id: RecordIdSchema
|
|
68321
|
-
})
|
|
68322
|
-
]);
|
|
68323
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
68324
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
68325
|
-
kind: "mutation",
|
|
68326
|
-
auth: "admin"
|
|
68327
|
-
}), method(object({
|
|
68328
|
-
...KindShape,
|
|
68329
|
-
id: RecordIdSchema
|
|
68330
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
68331
|
-
...KindShape,
|
|
68332
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68333
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
68334
|
-
...KindShape,
|
|
68335
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68336
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
68337
|
-
...KindShape,
|
|
68338
|
-
record: RecordInputSchema,
|
|
68339
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
68340
|
-
ifRev: number().int().min(0).optional()
|
|
68341
|
-
}), object({
|
|
68342
|
-
rev: number().int(),
|
|
68343
|
-
releasedRefs: SecretRefsList
|
|
68344
|
-
}), {
|
|
68345
|
-
kind: "mutation",
|
|
68346
|
-
auth: "admin"
|
|
68347
|
-
}), method(object({
|
|
68348
|
-
...KindShape,
|
|
68349
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68350
|
-
}), object({
|
|
68351
|
-
count: number().int(),
|
|
68352
|
-
releasedRefs: SecretRefsList
|
|
68353
|
-
}), {
|
|
68354
|
-
kind: "mutation",
|
|
68355
|
-
auth: "admin"
|
|
68356
|
-
}), method(object({
|
|
68357
|
-
...KindShape,
|
|
68358
|
-
id: RecordIdSchema,
|
|
68359
|
-
data: RecordBodySchema,
|
|
68360
|
-
at: number().int().nullable().optional(),
|
|
68361
|
-
expiresAt: number().int().nullable().optional(),
|
|
68362
|
-
ifRev: number().int().min(1).optional()
|
|
68363
|
-
}), object({
|
|
68364
|
-
rev: number().int(),
|
|
68365
|
-
releasedRefs: SecretRefsList
|
|
68366
|
-
}), {
|
|
68367
|
-
kind: "mutation",
|
|
68368
|
-
auth: "admin"
|
|
68369
|
-
}), method(object({
|
|
68370
|
-
...KindShape,
|
|
68371
|
-
id: RecordIdSchema
|
|
68372
|
-
}), object({
|
|
68373
|
-
deleted: boolean(),
|
|
68374
|
-
secretRefs: SecretRefsList
|
|
68375
|
-
}), {
|
|
68376
|
-
kind: "mutation",
|
|
68377
|
-
auth: "admin"
|
|
68378
|
-
}), method(object({
|
|
68379
|
-
...KindShape,
|
|
68380
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68381
|
-
}), object({
|
|
68382
|
-
deleted: number().int(),
|
|
68383
|
-
secretRefs: SecretRefsList
|
|
68384
|
-
}), {
|
|
68385
|
-
kind: "mutation",
|
|
68386
|
-
auth: "admin"
|
|
68387
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
68388
|
-
...KindShape,
|
|
68389
|
-
...TimeWindowShape,
|
|
68390
|
-
where: RecordWhereSchema.optional()
|
|
68391
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
68392
|
-
...KindShape,
|
|
68393
|
-
deviceId: number().int().optional(),
|
|
68394
|
-
from: number(),
|
|
68395
|
-
to: number(),
|
|
68396
|
-
bucketMs: number().int().positive()
|
|
68397
|
-
}), object({ buckets: array(object({
|
|
68398
|
-
bucketStart: number(),
|
|
68399
|
-
count: number().int()
|
|
68400
|
-
})) }), { auth: "admin" }), method(object({
|
|
68401
|
-
...KindShape,
|
|
68402
|
-
op: _enum([
|
|
68403
|
-
"sum",
|
|
68404
|
-
"min",
|
|
68405
|
-
"max",
|
|
68406
|
-
"count"
|
|
68407
|
-
]),
|
|
68408
|
-
field: RecordFieldPathSchema.optional(),
|
|
68409
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
68410
|
-
where: RecordWhereSchema.optional()
|
|
68411
|
-
}), object({ rows: array(object({
|
|
68412
|
-
group: union([
|
|
68413
|
-
string(),
|
|
68414
|
-
number(),
|
|
68415
|
-
_null()
|
|
68416
|
-
]),
|
|
68417
|
-
value: number().nullable()
|
|
68418
|
-
})) }), { auth: "admin" }), method(object({
|
|
68419
|
-
...KindShape,
|
|
68420
|
-
deviceId: number().int().optional(),
|
|
68421
|
-
atBefore: number().optional(),
|
|
68422
|
-
where: RecordWhereSchema.optional()
|
|
68423
|
-
}), object({
|
|
68424
|
-
deleted: number().int(),
|
|
68425
|
-
secretRefs: SecretRefsList
|
|
68426
|
-
}), {
|
|
68427
|
-
kind: "mutation",
|
|
68428
|
-
auth: "admin"
|
|
68429
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
68430
|
-
results: array(object({
|
|
68431
|
-
rev: number().int().nullable(),
|
|
68432
|
-
deleted: boolean()
|
|
68433
|
-
})),
|
|
68434
|
-
releasedRefs: SecretRefsList,
|
|
68435
|
-
secretRefs: SecretRefsList
|
|
68436
|
-
}), {
|
|
68437
|
-
kind: "mutation",
|
|
68438
|
-
auth: "admin"
|
|
68439
|
-
}), method(object({
|
|
68440
|
-
deviceId: number().int(),
|
|
68441
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
68442
|
-
}), object({
|
|
68443
|
-
deleted: record(string(), number().int()),
|
|
68444
|
-
secretRefs: SecretRefsList
|
|
68445
|
-
}), {
|
|
68446
|
-
kind: "mutation",
|
|
68447
|
-
auth: "admin"
|
|
68448
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
68449
|
-
kind: "mutation",
|
|
68450
|
-
auth: "admin"
|
|
68451
|
-
});
|
|
68452
|
-
/**
|
|
68453
68701
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
68454
68702
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
68455
68703
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -75964,11 +76212,15 @@ discriminatedUnion("kind", [object({
|
|
|
75964
76212
|
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
75965
76213
|
* near F. A device that is not near one level most of the time has no floor.
|
|
75966
76214
|
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
75967
|
-
* 3.
|
|
75968
|
-
*
|
|
76215
|
+
* 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
|
|
76216
|
+
* display waking): it is neither a run nor a pause. Among the remaining
|
|
76217
|
+
* episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
|
|
76218
|
+
* two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
|
|
76219
|
+
* a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
|
|
76220
|
+
* is no run.
|
|
75969
76221
|
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
75970
|
-
* grid a person would type; stop dwell covers the longest pause
|
|
75971
|
-
* covers the longest standby blip above T.
|
|
76222
|
+
* grid a person would type; stop dwell covers the longest pause and the
|
|
76223
|
+
* kind's floor; start dwell covers the longest pulse and standby blip above T.
|
|
75972
76224
|
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
75973
76225
|
* run must hold exactly one true interval and nothing may flap outside.
|
|
75974
76226
|
*/
|
|
@@ -75979,6 +76231,10 @@ var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
|
75979
76231
|
30 * SECOND_MS;
|
|
75980
76232
|
60 * SECOND_MS;
|
|
75981
76233
|
20 * MINUTE_MS$1;
|
|
76234
|
+
90 * SECOND_MS;
|
|
76235
|
+
30 * MINUTE_MS$1;
|
|
76236
|
+
10 * MINUTE_MS$1;
|
|
76237
|
+
DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
|
|
75982
76238
|
10 * SECOND_MS;
|
|
75983
76239
|
10 * SECOND_MS;
|
|
75984
76240
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
@@ -76997,20 +77253,6 @@ Object.freeze({
|
|
|
76997
77253
|
access: "create",
|
|
76998
77254
|
role: "viewer"
|
|
76999
77255
|
},
|
|
77000
|
-
"broker.add": {
|
|
77001
|
-
capName: "broker",
|
|
77002
|
-
capScope: "system",
|
|
77003
|
-
addonId: null,
|
|
77004
|
-
access: "create",
|
|
77005
|
-
role: "admin"
|
|
77006
|
-
},
|
|
77007
|
-
"broker.get": {
|
|
77008
|
-
capName: "broker",
|
|
77009
|
-
capScope: "system",
|
|
77010
|
-
addonId: null,
|
|
77011
|
-
access: "view",
|
|
77012
|
-
role: "admin"
|
|
77013
|
-
},
|
|
77014
77256
|
"broker.getBrokerConfig": {
|
|
77015
77257
|
capName: "broker",
|
|
77016
77258
|
capScope: "system",
|
|
@@ -77018,20 +77260,6 @@ Object.freeze({
|
|
|
77018
77260
|
access: "view",
|
|
77019
77261
|
role: "admin"
|
|
77020
77262
|
},
|
|
77021
|
-
"broker.getSettings": {
|
|
77022
|
-
capName: "broker",
|
|
77023
|
-
capScope: "system",
|
|
77024
|
-
addonId: null,
|
|
77025
|
-
access: "view",
|
|
77026
|
-
role: "admin"
|
|
77027
|
-
},
|
|
77028
|
-
"broker.getSettingsSchema": {
|
|
77029
|
-
capName: "broker",
|
|
77030
|
-
capScope: "system",
|
|
77031
|
-
addonId: null,
|
|
77032
|
-
access: "view",
|
|
77033
|
-
role: "admin"
|
|
77034
|
-
},
|
|
77035
77263
|
"broker.getState": {
|
|
77036
77264
|
capName: "broker",
|
|
77037
77265
|
capScope: "system",
|
|
@@ -77046,20 +77274,6 @@ Object.freeze({
|
|
|
77046
77274
|
access: "view",
|
|
77047
77275
|
role: "admin"
|
|
77048
77276
|
},
|
|
77049
|
-
"broker.list": {
|
|
77050
|
-
capName: "broker",
|
|
77051
|
-
capScope: "system",
|
|
77052
|
-
addonId: null,
|
|
77053
|
-
access: "view",
|
|
77054
|
-
role: "admin"
|
|
77055
|
-
},
|
|
77056
|
-
"broker.listProviders": {
|
|
77057
|
-
capName: "broker",
|
|
77058
|
-
capScope: "system",
|
|
77059
|
-
addonId: null,
|
|
77060
|
-
access: "view",
|
|
77061
|
-
role: "admin"
|
|
77062
|
-
},
|
|
77063
77277
|
"broker.publish": {
|
|
77064
77278
|
capName: "broker",
|
|
77065
77279
|
capScope: "system",
|
|
@@ -77067,20 +77281,6 @@ Object.freeze({
|
|
|
77067
77281
|
access: "create",
|
|
77068
77282
|
role: "admin"
|
|
77069
77283
|
},
|
|
77070
|
-
"broker.remove": {
|
|
77071
|
-
capName: "broker",
|
|
77072
|
-
capScope: "system",
|
|
77073
|
-
addonId: null,
|
|
77074
|
-
access: "delete",
|
|
77075
|
-
role: "admin"
|
|
77076
|
-
},
|
|
77077
|
-
"broker.setSettings": {
|
|
77078
|
-
capName: "broker",
|
|
77079
|
-
capScope: "system",
|
|
77080
|
-
addonId: null,
|
|
77081
|
-
access: "create",
|
|
77082
|
-
role: "admin"
|
|
77083
|
-
},
|
|
77084
77284
|
"broker.subscribe": {
|
|
77085
77285
|
capName: "broker",
|
|
77086
77286
|
capScope: "system",
|
|
@@ -77088,20 +77288,6 @@ Object.freeze({
|
|
|
77088
77288
|
access: "create",
|
|
77089
77289
|
role: "admin"
|
|
77090
77290
|
},
|
|
77091
|
-
"broker.testConnection": {
|
|
77092
|
-
capName: "broker",
|
|
77093
|
-
capScope: "system",
|
|
77094
|
-
addonId: null,
|
|
77095
|
-
access: "create",
|
|
77096
|
-
role: "admin"
|
|
77097
|
-
},
|
|
77098
|
-
"broker.testSettings": {
|
|
77099
|
-
capName: "broker",
|
|
77100
|
-
capScope: "system",
|
|
77101
|
-
addonId: null,
|
|
77102
|
-
access: "create",
|
|
77103
|
-
role: "admin"
|
|
77104
|
-
},
|
|
77105
77291
|
"broker.unsubscribe": {
|
|
77106
77292
|
capName: "broker",
|
|
77107
77293
|
capScope: "system",
|
|
@@ -79734,13 +79920,6 @@ Object.freeze({
|
|
|
79734
79920
|
access: "view",
|
|
79735
79921
|
role: "admin"
|
|
79736
79922
|
},
|
|
79737
|
-
"integrations.getSettings": {
|
|
79738
|
-
capName: "integrations",
|
|
79739
|
-
capScope: "system",
|
|
79740
|
-
addonId: null,
|
|
79741
|
-
access: "view",
|
|
79742
|
-
role: "admin"
|
|
79743
|
-
},
|
|
79744
79923
|
"integrations.list": {
|
|
79745
79924
|
capName: "integrations",
|
|
79746
79925
|
capScope: "system",
|
|
@@ -79748,13 +79927,6 @@ Object.freeze({
|
|
|
79748
79927
|
access: "view",
|
|
79749
79928
|
role: "admin"
|
|
79750
79929
|
},
|
|
79751
|
-
"integrations.setSettings": {
|
|
79752
|
-
capName: "integrations",
|
|
79753
|
-
capScope: "system",
|
|
79754
|
-
addonId: null,
|
|
79755
|
-
access: "create",
|
|
79756
|
-
role: "admin"
|
|
79757
|
-
},
|
|
79758
79930
|
"integrations.testConnection": {
|
|
79759
79931
|
capName: "integrations",
|
|
79760
79932
|
capScope: "system",
|
|
@@ -80749,6 +80921,13 @@ Object.freeze({
|
|
|
80749
80921
|
access: "view",
|
|
80750
80922
|
role: "admin"
|
|
80751
80923
|
},
|
|
80924
|
+
"migrations.clearLegacyIntegrationRows": {
|
|
80925
|
+
capName: "migrations",
|
|
80926
|
+
capScope: "system",
|
|
80927
|
+
addonId: null,
|
|
80928
|
+
access: "delete",
|
|
80929
|
+
role: "admin"
|
|
80930
|
+
},
|
|
80752
80931
|
"migrations.declareOwner": {
|
|
80753
80932
|
capName: "migrations",
|
|
80754
80933
|
capScope: "system",
|
|
@@ -80756,6 +80935,13 @@ Object.freeze({
|
|
|
80756
80935
|
access: "create",
|
|
80757
80936
|
role: "admin"
|
|
80758
80937
|
},
|
|
80938
|
+
"migrations.deleteLegacyIntegrationRowKeys": {
|
|
80939
|
+
capName: "migrations",
|
|
80940
|
+
capScope: "system",
|
|
80941
|
+
addonId: null,
|
|
80942
|
+
access: "delete",
|
|
80943
|
+
role: "admin"
|
|
80944
|
+
},
|
|
80759
80945
|
"migrations.dryRun": {
|
|
80760
80946
|
capName: "migrations",
|
|
80761
80947
|
capScope: "system",
|
|
@@ -80791,6 +80977,20 @@ Object.freeze({
|
|
|
80791
80977
|
access: "create",
|
|
80792
80978
|
role: "admin"
|
|
80793
80979
|
},
|
|
80980
|
+
"migrations.patchLegacyIntegrationRows": {
|
|
80981
|
+
capName: "migrations",
|
|
80982
|
+
capScope: "system",
|
|
80983
|
+
addonId: null,
|
|
80984
|
+
access: "create",
|
|
80985
|
+
role: "admin"
|
|
80986
|
+
},
|
|
80987
|
+
"migrations.readLegacyIntegrationRows": {
|
|
80988
|
+
capName: "migrations",
|
|
80989
|
+
capScope: "system",
|
|
80990
|
+
addonId: null,
|
|
80991
|
+
access: "view",
|
|
80992
|
+
role: "admin"
|
|
80993
|
+
},
|
|
80794
80994
|
"migrations.restorePreMigration": {
|
|
80795
80995
|
capName: "migrations",
|
|
80796
80996
|
capScope: "system",
|
|
@@ -82051,6 +82251,13 @@ Object.freeze({
|
|
|
82051
82251
|
access: "view",
|
|
82052
82252
|
role: "viewer"
|
|
82053
82253
|
},
|
|
82254
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
82255
|
+
capName: "pipeline-analytics",
|
|
82256
|
+
capScope: "device",
|
|
82257
|
+
addonId: null,
|
|
82258
|
+
access: "view",
|
|
82259
|
+
role: "admin"
|
|
82260
|
+
},
|
|
82054
82261
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
82055
82262
|
capName: "pipeline-analytics",
|
|
82056
82263
|
capScope: "device",
|
|
@@ -91023,6 +91230,7 @@ object({
|
|
|
91023
91230
|
delay: number().nonnegative().optional(),
|
|
91024
91231
|
commands: record(string(), unknown())
|
|
91025
91232
|
});
|
|
91233
|
+
entryBody({ brokerId: string() });
|
|
91026
91234
|
//#endregion
|
|
91027
91235
|
//#region src/google-types.ts
|
|
91028
91236
|
/** One Google account connection (broker entry). Credentials for the OAuth
|
|
@@ -91108,6 +91316,10 @@ var OAUTH_START_PATH = `/addon/google-services/oauth/start`;
|
|
|
91108
91316
|
var OAUTH_CALLBACK_SUFFIX = `/addon/google-services/oauth/callback`;
|
|
91109
91317
|
//#endregion
|
|
91110
91318
|
//#region src/google-broker-registry.ts
|
|
91319
|
+
/**
|
|
91320
|
+
* Google broker registry — N Google accounts under kind `google`.
|
|
91321
|
+
* No live WS; "connected" means a refresh token exists for the broker id.
|
|
91322
|
+
*/
|
|
91111
91323
|
var GoogleAddSettingsSchema = object({
|
|
91112
91324
|
clientId: string().min(1),
|
|
91113
91325
|
clientSecret: string().min(1).meta({ secret: true }),
|
|
@@ -91215,7 +91427,7 @@ function parseStampedCalendarId(stamped) {
|
|
|
91215
91427
|
}
|
|
91216
91428
|
/**
|
|
91217
91429
|
* In-memory index over broker entries + oauth accounts. The addon owns
|
|
91218
|
-
* persistence; this class only allocates ids and
|
|
91430
|
+
* persistence; this class only allocates ids and tracks the OAuth state.
|
|
91219
91431
|
*/
|
|
91220
91432
|
var GoogleBrokerRegistry = class {
|
|
91221
91433
|
nextIdCounter = 1;
|
|
@@ -91312,28 +91524,6 @@ var GoogleBrokerRegistry = class {
|
|
|
91312
91524
|
this.entries = entries.map((e) => GoogleBrokerEntrySchema.parse(e));
|
|
91313
91525
|
this.seedCounterFromEntries(this.entries);
|
|
91314
91526
|
}
|
|
91315
|
-
toBrokerInfo(entry, addonId) {
|
|
91316
|
-
const oauth = this.oauthById.get(entry.id);
|
|
91317
|
-
const connected = this.isConnected(entry.id);
|
|
91318
|
-
const reauth = this.needsReauth(entry.id);
|
|
91319
|
-
return {
|
|
91320
|
-
id: entry.id,
|
|
91321
|
-
addonId,
|
|
91322
|
-
name: entry.name,
|
|
91323
|
-
kind: GOOGLE_BROKER_KIND,
|
|
91324
|
-
status: connected ? "connected" : reauth ? "auth-failed" : "disconnected",
|
|
91325
|
-
info: {
|
|
91326
|
-
accountEmail: oauth?.accountEmail ?? "",
|
|
91327
|
-
hasClient: entry.clientId.length > 0
|
|
91328
|
-
},
|
|
91329
|
-
lastCheckedAt: connected ? Date.now() : null,
|
|
91330
|
-
error: connected ? null : reauth ? "Google session expired — sign in again" : entry.clientId.length === 0 ? "Configure Client ID / secret, then Connect Google" : "Not connected — open Connect Google on this broker"
|
|
91331
|
-
};
|
|
91332
|
-
}
|
|
91333
|
-
listBrokerInfos(addonId, kind) {
|
|
91334
|
-
if (kind !== void 0 && kind !== "google") return [];
|
|
91335
|
-
return this.entries.map((e) => this.toBrokerInfo(e, addonId));
|
|
91336
|
-
}
|
|
91337
91527
|
size() {
|
|
91338
91528
|
return this.entries.length;
|
|
91339
91529
|
}
|
|
@@ -91439,8 +91629,8 @@ function escapeHtml$1(s) {
|
|
|
91439
91629
|
//#region src/google-broker-settings-schema.ts
|
|
91440
91630
|
/**
|
|
91441
91631
|
* Per-kind broker creation/edit form for kind=`google`.
|
|
91442
|
-
* Account linking (Sign in) is driven by `
|
|
91443
|
-
*
|
|
91632
|
+
* Account linking (Sign in) is driven by the kind's `connectPath`
|
|
91633
|
+
* on the instances page — not a hard-coded Connect link in this form.
|
|
91444
91634
|
*/
|
|
91445
91635
|
function consoleLinksHtml() {
|
|
91446
91636
|
return [
|
|
@@ -92066,12 +92256,15 @@ function asTestResult(r) {
|
|
|
92066
92256
|
function buildGoogleInstances(records, deps) {
|
|
92067
92257
|
return new RecordIntegrationInstances(records, googleBrokersEntryKind, {
|
|
92068
92258
|
description: {
|
|
92259
|
+
role: "services",
|
|
92069
92260
|
instanceMode: "multiple",
|
|
92070
92261
|
kind: "account",
|
|
92071
92262
|
canTest: true,
|
|
92072
92263
|
kinds: [{
|
|
92073
92264
|
id: GOOGLE_BROKER_KIND,
|
|
92074
92265
|
label: GOOGLE_BROKER_KIND_LABEL,
|
|
92266
|
+
functionCap: "broker",
|
|
92267
|
+
brokerKind: GOOGLE_BROKER_KIND,
|
|
92075
92268
|
connectPath: deps.connectPath,
|
|
92076
92269
|
disconnectPath: deps.disconnectPath
|
|
92077
92270
|
}],
|
|
@@ -92496,7 +92689,6 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92496
92689
|
}
|
|
92497
92690
|
/** The accounts as `integration-instances`, over the same `brokers` records (planning#408 P3). */
|
|
92498
92691
|
buildInstances(records) {
|
|
92499
|
-
const brokerProvider = this.buildBrokerProvider();
|
|
92500
92692
|
return buildGoogleInstances(records, {
|
|
92501
92693
|
connectPath: `/addon/${ADDON_ID}${START_PATH}?brokerId={{brokerId}}`,
|
|
92502
92694
|
disconnectPath: `/addon/${ADDON_ID}${DISCONNECT_PATH}?brokerId={{brokerId}}`,
|
|
@@ -92509,131 +92701,19 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92509
92701
|
this.registry.seedFrom(this.activeBrokers, accounts);
|
|
92510
92702
|
await this.persistOauthAccounts();
|
|
92511
92703
|
},
|
|
92512
|
-
testSaved:
|
|
92513
|
-
testClient:
|
|
92514
|
-
kind: GOOGLE_BROKER_KIND,
|
|
92515
|
-
settings: {
|
|
92516
|
-
clientId,
|
|
92517
|
-
clientSecret
|
|
92518
|
-
}
|
|
92519
|
-
})
|
|
92704
|
+
testSaved: (id) => this.probeSavedAccount(id),
|
|
92705
|
+
testClient: (clientId, clientSecret) => this.probeOauthClient(clientId, clientSecret)
|
|
92520
92706
|
});
|
|
92521
92707
|
}
|
|
92708
|
+
/**
|
|
92709
|
+
* The `broker` cap is the bus only (D1013): the accounts are the `integration-instances`
|
|
92710
|
+
* provider; calendar and mail go through their own caps, so publish and subscribe are refused.
|
|
92711
|
+
*/
|
|
92522
92712
|
buildBrokerProvider() {
|
|
92523
|
-
const ownerAddonId = this.ctx.id;
|
|
92524
|
-
const owns = (id) => this.registry.getEntry(id) !== null;
|
|
92525
92713
|
const notSupported = async () => {
|
|
92526
92714
|
throw new Error("google-services broker: publish/subscribe/getState are not supported — use calendar-source / smtp-provider");
|
|
92527
92715
|
};
|
|
92528
92716
|
return {
|
|
92529
|
-
list: async ({ kind }) => this.registry.listBrokerInfos(ownerAddonId, kind),
|
|
92530
|
-
get: async ({ id }) => {
|
|
92531
|
-
const entry = this.registry.getEntry(id);
|
|
92532
|
-
return entry ? this.registry.toBrokerInfo(entry, ownerAddonId) : null;
|
|
92533
|
-
},
|
|
92534
|
-
listProviders: async () => [{
|
|
92535
|
-
addonId: ownerAddonId,
|
|
92536
|
-
kinds: [{
|
|
92537
|
-
kind: GOOGLE_BROKER_KIND,
|
|
92538
|
-
label: GOOGLE_BROKER_KIND_LABEL,
|
|
92539
|
-
interactiveConnectPath: `/addon/${ADDON_ID}${START_PATH}?brokerId={{brokerId}}`,
|
|
92540
|
-
interactiveDisconnectPath: `/addon/${ADDON_ID}${DISCONNECT_PATH}?brokerId={{brokerId}}`
|
|
92541
|
-
}]
|
|
92542
|
-
}],
|
|
92543
|
-
add: async ({ kind, name, settings, id }) => {
|
|
92544
|
-
if (kind !== "google") throw new Error(`google-services: only kind '${GOOGLE_BROKER_KIND}' is handled here (got '${kind}')`);
|
|
92545
|
-
const entry = this.registry.createEntry(name, settings, id !== void 0 ? { id } : {});
|
|
92546
|
-
await this.persistBrokers();
|
|
92547
|
-
return { id: entry.id };
|
|
92548
|
-
},
|
|
92549
|
-
remove: async ({ id }) => {
|
|
92550
|
-
if (!owns(id)) return;
|
|
92551
|
-
this.registry.removeEntry(id);
|
|
92552
|
-
await this.persistBrokers();
|
|
92553
|
-
await this.persistOauthAccounts();
|
|
92554
|
-
},
|
|
92555
|
-
testConnection: async ({ id }) => {
|
|
92556
|
-
if (!owns(id)) return {
|
|
92557
|
-
ok: false,
|
|
92558
|
-
error: "unknown broker"
|
|
92559
|
-
};
|
|
92560
|
-
const entry = this.registry.getEntry(id);
|
|
92561
|
-
if (entry === null) return {
|
|
92562
|
-
ok: false,
|
|
92563
|
-
error: "unknown broker"
|
|
92564
|
-
};
|
|
92565
|
-
if (!entry.clientId || !entry.clientSecret) return {
|
|
92566
|
-
ok: false,
|
|
92567
|
-
error: "Configure Client ID and Client secret first"
|
|
92568
|
-
};
|
|
92569
|
-
let redirectUri;
|
|
92570
|
-
try {
|
|
92571
|
-
redirectUri = await this.resolveRedirectUri();
|
|
92572
|
-
} catch (err) {
|
|
92573
|
-
return {
|
|
92574
|
-
ok: false,
|
|
92575
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92576
|
-
};
|
|
92577
|
-
}
|
|
92578
|
-
if (!this.registry.isConnected(id)) return probeGoogleOauthClient({
|
|
92579
|
-
clientId: entry.clientId,
|
|
92580
|
-
clientSecret: entry.clientSecret,
|
|
92581
|
-
redirectUri
|
|
92582
|
-
});
|
|
92583
|
-
try {
|
|
92584
|
-
const started = Date.now();
|
|
92585
|
-
const token = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92586
|
-
if (token.trim().length === 0) return {
|
|
92587
|
-
ok: false,
|
|
92588
|
-
error: "No access token after refresh — Sign out and Sign in again"
|
|
92589
|
-
};
|
|
92590
|
-
let res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${token}` } });
|
|
92591
|
-
if (res.status === 401) {
|
|
92592
|
-
const retryToken = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92593
|
-
res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${retryToken}` } });
|
|
92594
|
-
}
|
|
92595
|
-
if (!res.ok) {
|
|
92596
|
-
const text = await res.text();
|
|
92597
|
-
return {
|
|
92598
|
-
ok: false,
|
|
92599
|
-
error: `Google Calendar probe failed (${res.status}): ${text.slice(0, 200)}`
|
|
92600
|
-
};
|
|
92601
|
-
}
|
|
92602
|
-
const email = await this.fetchAccountEmail(token);
|
|
92603
|
-
if (email.length > 0) {
|
|
92604
|
-
const oauth = this.registry.getOauth(id);
|
|
92605
|
-
if (oauth !== null && oauth.accountEmail !== email) {
|
|
92606
|
-
this.registry.setOauth({
|
|
92607
|
-
...oauth,
|
|
92608
|
-
accountEmail: email
|
|
92609
|
-
});
|
|
92610
|
-
await this.persistOauthAccounts();
|
|
92611
|
-
}
|
|
92612
|
-
}
|
|
92613
|
-
return {
|
|
92614
|
-
ok: true,
|
|
92615
|
-
latencyMs: Date.now() - started
|
|
92616
|
-
};
|
|
92617
|
-
} catch (err) {
|
|
92618
|
-
return {
|
|
92619
|
-
ok: false,
|
|
92620
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92621
|
-
};
|
|
92622
|
-
}
|
|
92623
|
-
},
|
|
92624
|
-
getSettings: async ({ id }) => {
|
|
92625
|
-
const entry = this.registry.getEntry(id);
|
|
92626
|
-
if (entry === null) return null;
|
|
92627
|
-
return {
|
|
92628
|
-
...brokerEntryToSettings(entry),
|
|
92629
|
-
_calendarCatalog: await this.loadStampedCalendarCatalog(id)
|
|
92630
|
-
};
|
|
92631
|
-
},
|
|
92632
|
-
setSettings: async ({ id, settings }) => {
|
|
92633
|
-
if (!owns(id)) return;
|
|
92634
|
-
this.registry.updateEntry(id, settings);
|
|
92635
|
-
await this.persistBrokers();
|
|
92636
|
-
},
|
|
92637
92717
|
getBrokerConfig: async ({ id }) => {
|
|
92638
92718
|
const entry = this.registry.getEntry(id);
|
|
92639
92719
|
if (entry === null) return null;
|
|
@@ -92645,33 +92725,6 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92645
92725
|
connected: this.registry.isConnected(id)
|
|
92646
92726
|
};
|
|
92647
92727
|
},
|
|
92648
|
-
getSettingsSchema: async ({ kind }) => {
|
|
92649
|
-
if (kind !== "google") return null;
|
|
92650
|
-
return buildGoogleBrokerSettingsSchema(this.publicOrigin);
|
|
92651
|
-
},
|
|
92652
|
-
testSettings: async ({ kind, settings }) => {
|
|
92653
|
-
if (kind !== "google") return {
|
|
92654
|
-
ok: false,
|
|
92655
|
-
error: `unsupported kind: ${kind}`
|
|
92656
|
-
};
|
|
92657
|
-
try {
|
|
92658
|
-
const parsed = object({
|
|
92659
|
-
clientId: string().min(1),
|
|
92660
|
-
clientSecret: string().min(1).meta({ secret: true })
|
|
92661
|
-
}).parse(settings);
|
|
92662
|
-
const redirectUri = await this.resolveRedirectUri();
|
|
92663
|
-
return probeGoogleOauthClient({
|
|
92664
|
-
clientId: parsed.clientId,
|
|
92665
|
-
clientSecret: parsed.clientSecret,
|
|
92666
|
-
redirectUri
|
|
92667
|
-
});
|
|
92668
|
-
} catch (err) {
|
|
92669
|
-
return {
|
|
92670
|
-
ok: false,
|
|
92671
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92672
|
-
};
|
|
92673
|
-
}
|
|
92674
|
-
},
|
|
92675
92728
|
publish: notSupported,
|
|
92676
92729
|
subscribe: notSupported,
|
|
92677
92730
|
unsubscribe: notSupported,
|
|
@@ -92682,6 +92735,95 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92682
92735
|
})
|
|
92683
92736
|
};
|
|
92684
92737
|
}
|
|
92738
|
+
/** Probe a saved account: the OAuth client, then (when signed in) a Calendar call. */
|
|
92739
|
+
async probeSavedAccount(id) {
|
|
92740
|
+
const entry = this.registry.getEntry(id);
|
|
92741
|
+
if (entry === null) return {
|
|
92742
|
+
ok: false,
|
|
92743
|
+
error: "unknown broker"
|
|
92744
|
+
};
|
|
92745
|
+
if (!entry.clientId || !entry.clientSecret) return {
|
|
92746
|
+
ok: false,
|
|
92747
|
+
error: "Configure Client ID and Client secret first"
|
|
92748
|
+
};
|
|
92749
|
+
let redirectUri;
|
|
92750
|
+
try {
|
|
92751
|
+
redirectUri = await this.resolveRedirectUri();
|
|
92752
|
+
} catch (err) {
|
|
92753
|
+
return {
|
|
92754
|
+
ok: false,
|
|
92755
|
+
error: err instanceof Error ? err.message : String(err)
|
|
92756
|
+
};
|
|
92757
|
+
}
|
|
92758
|
+
if (!this.registry.isConnected(id)) return probeGoogleOauthClient({
|
|
92759
|
+
clientId: entry.clientId,
|
|
92760
|
+
clientSecret: entry.clientSecret,
|
|
92761
|
+
redirectUri
|
|
92762
|
+
});
|
|
92763
|
+
try {
|
|
92764
|
+
const started = Date.now();
|
|
92765
|
+
const token = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92766
|
+
if (token.trim().length === 0) return {
|
|
92767
|
+
ok: false,
|
|
92768
|
+
error: "No access token after refresh — Sign out and Sign in again"
|
|
92769
|
+
};
|
|
92770
|
+
let res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${token}` } });
|
|
92771
|
+
if (res.status === 401) {
|
|
92772
|
+
const retryToken = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92773
|
+
res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${retryToken}` } });
|
|
92774
|
+
}
|
|
92775
|
+
if (!res.ok) {
|
|
92776
|
+
const text = await res.text();
|
|
92777
|
+
return {
|
|
92778
|
+
ok: false,
|
|
92779
|
+
error: `Google Calendar probe failed (${res.status}): ${text.slice(0, 200)}`
|
|
92780
|
+
};
|
|
92781
|
+
}
|
|
92782
|
+
const email = await this.fetchAccountEmail(token);
|
|
92783
|
+
if (email.length > 0) {
|
|
92784
|
+
const oauth = this.registry.getOauth(id);
|
|
92785
|
+
if (oauth !== null && oauth.accountEmail !== email) {
|
|
92786
|
+
this.registry.setOauth({
|
|
92787
|
+
...oauth,
|
|
92788
|
+
accountEmail: email
|
|
92789
|
+
});
|
|
92790
|
+
await this.persistOauthAccounts();
|
|
92791
|
+
}
|
|
92792
|
+
}
|
|
92793
|
+
return {
|
|
92794
|
+
ok: true,
|
|
92795
|
+
latencyMs: Date.now() - started
|
|
92796
|
+
};
|
|
92797
|
+
} catch (err) {
|
|
92798
|
+
return {
|
|
92799
|
+
ok: false,
|
|
92800
|
+
error: err instanceof Error ? err.message : String(err)
|
|
92801
|
+
};
|
|
92802
|
+
}
|
|
92803
|
+
}
|
|
92804
|
+
/** Probe an OAuth client that is not saved yet. */
|
|
92805
|
+
async probeOauthClient(clientId, clientSecret) {
|
|
92806
|
+
try {
|
|
92807
|
+
const parsed = object({
|
|
92808
|
+
clientId: string().min(1),
|
|
92809
|
+
clientSecret: string().min(1).meta({ secret: true })
|
|
92810
|
+
}).parse({
|
|
92811
|
+
clientId,
|
|
92812
|
+
clientSecret
|
|
92813
|
+
});
|
|
92814
|
+
const redirectUri = await this.resolveRedirectUri();
|
|
92815
|
+
return probeGoogleOauthClient({
|
|
92816
|
+
clientId: parsed.clientId,
|
|
92817
|
+
clientSecret: parsed.clientSecret,
|
|
92818
|
+
redirectUri
|
|
92819
|
+
});
|
|
92820
|
+
} catch (err) {
|
|
92821
|
+
return {
|
|
92822
|
+
ok: false,
|
|
92823
|
+
error: err instanceof Error ? err.message : String(err)
|
|
92824
|
+
};
|
|
92825
|
+
}
|
|
92826
|
+
}
|
|
92685
92827
|
async handleStart(req, reply) {
|
|
92686
92828
|
const brokerIdRaw = req.query["brokerId"];
|
|
92687
92829
|
const brokerId = typeof brokerIdRaw === "string" ? brokerIdRaw.trim() : "";
|