@camstack/addon-google-services 0.2.38 → 0.2.40
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 +1410 -963
- package/dist/google-services.addon.mjs +1411 -964
- package/i18n/en.json +0 -4
- package/i18n/it.json +0 -4
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
2
|
//#region ../types/dist/event-category-BmPm98n0.mjs
|
|
3
3
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4
4
|
EventCategory["SystemBoot"] = "system.boot";
|
|
@@ -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) {
|
|
@@ -9242,6 +9372,7 @@ function defineEntryKind(name, spec) {
|
|
|
9242
9372
|
class: "config",
|
|
9243
9373
|
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9244
9374
|
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9375
|
+
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9245
9376
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9246
9377
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9247
9378
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
@@ -11921,7 +12052,7 @@ function userError(code, params, englishFallback) {
|
|
|
11921
12052
|
return new CamstackError(code, params, englishFallback);
|
|
11922
12053
|
}
|
|
11923
12054
|
//#endregion
|
|
11924
|
-
//#region ../types/dist/composition-
|
|
12055
|
+
//#region ../types/dist/composition-pOHbTzRB.mjs
|
|
11925
12056
|
/**
|
|
11926
12057
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11927
12058
|
*
|
|
@@ -13386,6 +13517,39 @@ function buildCapturingReply(envelope) {
|
|
|
13386
13517
|
return wrapper;
|
|
13387
13518
|
}
|
|
13388
13519
|
/**
|
|
13520
|
+
* The link primitive's declaration half (D1013 rule 5): what a link field names and how a kind
|
|
13521
|
+
* records it. Split from `instance-link.ts` so `RecordIntegrationInstances` can read the links of
|
|
13522
|
+
* its kind without importing the builders that import it.
|
|
13523
|
+
*/
|
|
13524
|
+
/** The body field of a link: the id of the instance it names; the target rides in the field meta. */
|
|
13525
|
+
function linkField(target) {
|
|
13526
|
+
return string().meta({ link: target });
|
|
13527
|
+
}
|
|
13528
|
+
function linkTargetOf(meta) {
|
|
13529
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
13530
|
+
const link = Reflect.get(meta, "link");
|
|
13531
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
13532
|
+
return parsed.success ? parsed.data : void 0;
|
|
13533
|
+
}
|
|
13534
|
+
var LinkTargetSchema = object({
|
|
13535
|
+
cap: string().min(1),
|
|
13536
|
+
kind: string().min(1).optional()
|
|
13537
|
+
});
|
|
13538
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
13539
|
+
function linksOfKind(kind) {
|
|
13540
|
+
const schema = kind.schema;
|
|
13541
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
13542
|
+
const links = [];
|
|
13543
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
13544
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
13545
|
+
if (to !== void 0) links.push({
|
|
13546
|
+
field,
|
|
13547
|
+
to
|
|
13548
|
+
});
|
|
13549
|
+
}
|
|
13550
|
+
return links;
|
|
13551
|
+
}
|
|
13552
|
+
/**
|
|
13389
13553
|
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13390
13554
|
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13391
13555
|
*
|
|
@@ -13506,9 +13670,18 @@ var RecordIntegrationInstances = class {
|
|
|
13506
13670
|
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13507
13671
|
};
|
|
13508
13672
|
}
|
|
13509
|
-
describe = async () =>
|
|
13510
|
-
|
|
13511
|
-
|
|
13673
|
+
describe = async () => {
|
|
13674
|
+
const declared = linksOfKind(this.kind);
|
|
13675
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
13676
|
+
kind: this.kind.name,
|
|
13677
|
+
field: link.field,
|
|
13678
|
+
to: link.to
|
|
13679
|
+
})) };
|
|
13680
|
+
return {
|
|
13681
|
+
...this.hooks.description,
|
|
13682
|
+
...links,
|
|
13683
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
13684
|
+
};
|
|
13512
13685
|
};
|
|
13513
13686
|
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13514
13687
|
listInstances = async () => {
|
|
@@ -13519,7 +13692,7 @@ var RecordIntegrationInstances = class {
|
|
|
13519
13692
|
return record === null ? null : this.viewOf(record);
|
|
13520
13693
|
};
|
|
13521
13694
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13522
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13695
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13523
13696
|
const minted = id ?? this.hooks.mintId?.({
|
|
13524
13697
|
name,
|
|
13525
13698
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13529,10 +13702,20 @@ var RecordIntegrationInstances = class {
|
|
|
13529
13702
|
id: minted,
|
|
13530
13703
|
data: this.hooks.initialBody(name, kind)
|
|
13531
13704
|
}, { ifRev: 0 });
|
|
13705
|
+
const patch = this.patchOf(values ?? {});
|
|
13706
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13532
13707
|
await this.hooks.onChanged?.(minted, "created");
|
|
13533
13708
|
return { id: minted };
|
|
13534
13709
|
};
|
|
13535
13710
|
updateInstance = async ({ id, name, values }) => {
|
|
13711
|
+
const patch = this.patchOf(values);
|
|
13712
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13713
|
+
await this.handle.patch(id, patch);
|
|
13714
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13715
|
+
return { ok: true };
|
|
13716
|
+
};
|
|
13717
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13718
|
+
patchOf(values) {
|
|
13536
13719
|
const patch = {};
|
|
13537
13720
|
for (const [key, value] of Object.entries(values)) {
|
|
13538
13721
|
if (value === void 0) continue;
|
|
@@ -13543,11 +13726,8 @@ var RecordIntegrationInstances = class {
|
|
|
13543
13726
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13544
13727
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13545
13728
|
}
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13549
|
-
return { ok: true };
|
|
13550
|
-
};
|
|
13729
|
+
return patch;
|
|
13730
|
+
}
|
|
13551
13731
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13552
13732
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13553
13733
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -13584,6 +13764,80 @@ var RecordIntegrationInstances = class {
|
|
|
13584
13764
|
};
|
|
13585
13765
|
}
|
|
13586
13766
|
};
|
|
13767
|
+
/** No part holds the id a call named. */
|
|
13768
|
+
var UnknownInstanceError = class extends Error {
|
|
13769
|
+
instanceId;
|
|
13770
|
+
constructor(instanceId) {
|
|
13771
|
+
super(`Unknown instance '${instanceId}'`);
|
|
13772
|
+
this.instanceId = instanceId;
|
|
13773
|
+
this.name = "UnknownInstanceError";
|
|
13774
|
+
}
|
|
13775
|
+
};
|
|
13776
|
+
/** A create or a form named no kind, or a kind no part serves. */
|
|
13777
|
+
var UnknownInstanceKindError = class extends Error {
|
|
13778
|
+
kindId;
|
|
13779
|
+
constructor(kindId) {
|
|
13780
|
+
super(kindId === void 0 ? "This provider has several kinds: name one" : `Unknown instance kind '${kindId}'`);
|
|
13781
|
+
this.kindId = kindId;
|
|
13782
|
+
this.name = "UnknownInstanceKindError";
|
|
13783
|
+
}
|
|
13784
|
+
};
|
|
13785
|
+
function composeInstanceKinds(parts, base) {
|
|
13786
|
+
const byKind = (kindId) => {
|
|
13787
|
+
if (kindId === void 0) {
|
|
13788
|
+
const only = parts.length === 1 ? parts[0] : void 0;
|
|
13789
|
+
if (only === void 0) throw new UnknownInstanceKindError(void 0);
|
|
13790
|
+
return only;
|
|
13791
|
+
}
|
|
13792
|
+
const part = parts.find((candidate) => candidate.kind.id === kindId);
|
|
13793
|
+
if (part === void 0) throw new UnknownInstanceKindError(kindId);
|
|
13794
|
+
return part;
|
|
13795
|
+
};
|
|
13796
|
+
const holderOf = async (id) => {
|
|
13797
|
+
for (const part of parts) if (await part.provider.getInstance({ id }) !== null) return part;
|
|
13798
|
+
throw new UnknownInstanceError(id);
|
|
13799
|
+
};
|
|
13800
|
+
const tagged = (part, instance) => ({
|
|
13801
|
+
...instance,
|
|
13802
|
+
kind: part.kind.id
|
|
13803
|
+
});
|
|
13804
|
+
return {
|
|
13805
|
+
describe: async () => {
|
|
13806
|
+
const links = (await Promise.all(parts.map(async (part) => (await part.provider.describe()).links ?? []))).flat();
|
|
13807
|
+
return {
|
|
13808
|
+
...base,
|
|
13809
|
+
kinds: parts.map((part) => part.kind),
|
|
13810
|
+
...links.length > 0 ? { links } : {}
|
|
13811
|
+
};
|
|
13812
|
+
},
|
|
13813
|
+
instanceFormSchema: async ({ id, kind }) => {
|
|
13814
|
+
return (id === null ? byKind(kind) : await holderOf(id)).provider.instanceFormSchema({ id });
|
|
13815
|
+
},
|
|
13816
|
+
listInstances: async () => {
|
|
13817
|
+
return (await Promise.all(parts.map(async (part) => (await part.provider.listInstances()).map((instance) => tagged(part, instance))))).flat();
|
|
13818
|
+
},
|
|
13819
|
+
getInstance: async ({ id }) => {
|
|
13820
|
+
for (const part of parts) {
|
|
13821
|
+
const found = await part.provider.getInstance({ id });
|
|
13822
|
+
if (found !== null) return tagged(part, found);
|
|
13823
|
+
}
|
|
13824
|
+
return null;
|
|
13825
|
+
},
|
|
13826
|
+
createInstance: async (input) => byKind(input.kind).provider.createInstance(input),
|
|
13827
|
+
updateInstance: async (input) => (await holderOf(input.id)).provider.updateInstance(input),
|
|
13828
|
+
setInstanceEnabled: async (input) => (await holderOf(input.id)).provider.setInstanceEnabled(input),
|
|
13829
|
+
deleteInstance: async (input) => (await holderOf(input.id)).provider.deleteInstance(input),
|
|
13830
|
+
testInstance: async (input) => {
|
|
13831
|
+
const test = (input.id === null ? byKind(input.kind) : await holderOf(input.id)).provider.testInstance;
|
|
13832
|
+
if (test === void 0) return {
|
|
13833
|
+
success: false,
|
|
13834
|
+
status: "inconclusive",
|
|
13835
|
+
error: "This kind cannot be tested"
|
|
13836
|
+
};
|
|
13837
|
+
return test(input);
|
|
13838
|
+
}
|
|
13839
|
+
};
|
|
13840
|
+
}
|
|
13587
13841
|
var EncodeProfileSchema = object({
|
|
13588
13842
|
video: object({
|
|
13589
13843
|
codec: _enum([
|
|
@@ -14629,7 +14883,13 @@ var MigrationLedgerEntrySchema = object({
|
|
|
14629
14883
|
* joined by the engine from the catalogues it knows this boot. Absent when no
|
|
14630
14884
|
* catalogue lists the id (a newer database).
|
|
14631
14885
|
*/
|
|
14632
|
-
meta: MigrationMetaSchema.optional()
|
|
14886
|
+
meta: MigrationMetaSchema.optional(),
|
|
14887
|
+
/**
|
|
14888
|
+
* Set when this is an applied row of an addon owner whose catalogue the answering
|
|
14889
|
+
* process has not loaded (the owner has not declared yet): the row is applied, the
|
|
14890
|
+
* process just cannot judge it. Never `skipped-newer` — that needs the owner loaded.
|
|
14891
|
+
*/
|
|
14892
|
+
ownerNotLoaded: boolean().optional()
|
|
14633
14893
|
});
|
|
14634
14894
|
/** A catalogued migration that is not applied, with where it stands. */
|
|
14635
14895
|
var MigrationPendingEntrySchema = object({
|
|
@@ -15750,6 +16010,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15750
16010
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15751
16011
|
total: number().int().nonnegative().nullable()
|
|
15752
16012
|
}).nullable();
|
|
16013
|
+
/**
|
|
16014
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16015
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16016
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16017
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16018
|
+
*
|
|
16019
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16020
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16021
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16022
|
+
* it is a deleted location only when every location id was asked.
|
|
16023
|
+
* `null` is "could not be measured", never zero.
|
|
16024
|
+
*/
|
|
16025
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16026
|
+
var MediaLocationCensusSchema = object({
|
|
16027
|
+
locations: array(object({
|
|
16028
|
+
locationId: string(),
|
|
16029
|
+
rows: number().int().nonnegative(),
|
|
16030
|
+
bytes: number().nonnegative()
|
|
16031
|
+
})).readonly(),
|
|
16032
|
+
unstamped: object({
|
|
16033
|
+
rows: number().int().nonnegative(),
|
|
16034
|
+
bytes: number().nonnegative()
|
|
16035
|
+
}),
|
|
16036
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16037
|
+
unlisted: object({
|
|
16038
|
+
rows: number().int().nonnegative(),
|
|
16039
|
+
bytes: number().nonnegative()
|
|
16040
|
+
}),
|
|
16041
|
+
total: object({
|
|
16042
|
+
rows: number().int().nonnegative(),
|
|
16043
|
+
bytes: number().nonnegative()
|
|
16044
|
+
})
|
|
16045
|
+
});
|
|
15753
16046
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15754
16047
|
/** The independently selectable logical storage classes — every class
|
|
15755
16048
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -46289,52 +46582,7 @@ DeviceType.Light, method(object({
|
|
|
46289
46582
|
level: number().min(0).max(100),
|
|
46290
46583
|
lastChangedAt: number()
|
|
46291
46584
|
});
|
|
46292
|
-
|
|
46293
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
46294
|
-
*
|
|
46295
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
46296
|
-
* register and that other addons might consume. The first two kinds
|
|
46297
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
46298
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
46299
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
46300
|
-
* the same surface.
|
|
46301
|
-
*
|
|
46302
|
-
* Why one cap, not one cap per kind:
|
|
46303
|
-
* - The integrations page wants a single table of "every broker"
|
|
46304
|
-
* across kinds; a unified cap drives it without join logic.
|
|
46305
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
46306
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
46307
|
-
* - The `network-access` cap precedent: same interface, many
|
|
46308
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
46309
|
-
*
|
|
46310
|
-
* What stays kind-specific:
|
|
46311
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
46312
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
46313
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
46314
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
46315
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
46316
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
46317
|
-
* without rebreaking the cap signature.
|
|
46318
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
46319
|
-
* the kind-specific provider).
|
|
46320
|
-
*
|
|
46321
|
-
* Bidirectionality:
|
|
46322
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
46323
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
46324
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
46325
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
46326
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
46327
|
-
* provider re-subscribes upstream after a transport drop.
|
|
46328
|
-
*
|
|
46329
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
46330
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
46331
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
46332
|
-
* drop is recoverable via `getState({key})`).
|
|
46333
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
46334
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
46335
|
-
* per-broker wire-shaping needed.
|
|
46336
|
-
*/
|
|
46337
|
-
var BrokerStatusEnum = _enum([
|
|
46585
|
+
_enum([
|
|
46338
46586
|
"connected",
|
|
46339
46587
|
"disconnected",
|
|
46340
46588
|
"connecting",
|
|
@@ -46342,141 +46590,12 @@ var BrokerStatusEnum = _enum([
|
|
|
46342
46590
|
"unreachable",
|
|
46343
46591
|
"error"
|
|
46344
46592
|
]);
|
|
46345
|
-
var BrokerInfoSchema = object({
|
|
46346
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
46347
|
-
id: string(),
|
|
46348
|
-
/** Addon id of the provider that OWNS this broker.
|
|
46349
|
-
*
|
|
46350
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
46351
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
46352
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
46353
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
46354
|
-
* device belongs to one integration. The admin UI threads this id
|
|
46355
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
46356
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
46357
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
46358
|
-
* instead of defaulting to the first-registered one. */
|
|
46359
|
-
addonId: string(),
|
|
46360
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
46361
|
-
name: string(),
|
|
46362
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
46363
|
-
kind: string(),
|
|
46364
|
-
status: BrokerStatusEnum,
|
|
46365
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
46366
|
-
* flavour, latency, mTLS active, …). */
|
|
46367
|
-
info: record(string(), unknown()),
|
|
46368
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
46369
|
-
lastCheckedAt: number().nullable(),
|
|
46370
|
-
/** Last error message, when `status` indicates failure. */
|
|
46371
|
-
error: string().nullable()
|
|
46372
|
-
});
|
|
46373
46593
|
var RegistryStatusSchema = object({
|
|
46374
46594
|
brokerCount: number().int().nonnegative(),
|
|
46375
46595
|
connectedCount: number().int().nonnegative()
|
|
46376
46596
|
});
|
|
46377
|
-
/**
|
|
46378
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
46379
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
46380
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
46381
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
46382
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
46383
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
46384
|
-
* offers a kind whose creation form can't be rendered).
|
|
46385
|
-
*/
|
|
46386
|
-
var BrokerProviderInfoSchema = object({
|
|
46387
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
46388
|
-
addonId: string(),
|
|
46389
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
46390
|
-
kinds: array(object({
|
|
46391
|
-
kind: string(),
|
|
46392
|
-
label: string(),
|
|
46393
|
-
/**
|
|
46394
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
46395
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
46396
|
-
*/
|
|
46397
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
46398
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
46399
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
46400
|
-
/**
|
|
46401
|
-
* The kind signs in through a server-held interactive session instead of
|
|
46402
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
46403
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
46404
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
46405
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
46406
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
46407
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
46408
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
46409
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
46410
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
46411
|
-
* offers it as the default path; the fields the session fills are
|
|
46412
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
46413
|
-
*
|
|
46414
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
46415
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
46416
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
46417
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
46418
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
46419
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
46420
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
46421
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
46422
|
-
* `['proxy']`.
|
|
46423
|
-
*/
|
|
46424
|
-
signIn: object({
|
|
46425
|
-
basePath: string().min(1),
|
|
46426
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
46427
|
-
}).optional()
|
|
46428
|
-
}))
|
|
46429
|
-
});
|
|
46430
|
-
var ListInputSchema = object({
|
|
46431
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
46432
|
-
* only HA brokers. Omit to list every broker. */
|
|
46433
|
-
kind: string().optional() });
|
|
46434
46597
|
var GetInputSchema = object({ id: string() });
|
|
46435
|
-
var AddInputSchema = object({
|
|
46436
|
-
kind: string().min(1),
|
|
46437
|
-
name: string().min(1),
|
|
46438
|
-
/**
|
|
46439
|
-
* ADOPT an existing id instead of minting a new one.
|
|
46440
|
-
*
|
|
46441
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
46442
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
46443
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
46444
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
46445
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
46446
|
-
* password.
|
|
46447
|
-
*
|
|
46448
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
46449
|
-
* broker's id would silently take it over.
|
|
46450
|
-
*/
|
|
46451
|
-
id: string().min(1).optional(),
|
|
46452
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
46453
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
46454
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
46455
|
-
settings: record(string(), unknown())
|
|
46456
|
-
});
|
|
46457
|
-
var AddResultSchema = object({ id: string() });
|
|
46458
|
-
var RemoveInputSchema = object({ id: string() });
|
|
46459
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
46460
|
-
ok: literal(true),
|
|
46461
|
-
latencyMs: number().nonnegative()
|
|
46462
|
-
}), object({
|
|
46463
|
-
ok: literal(false),
|
|
46464
|
-
error: string()
|
|
46465
|
-
})]);
|
|
46466
46598
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
46467
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
46468
|
-
var TestSettingsInputSchema = object({
|
|
46469
|
-
kind: string(),
|
|
46470
|
-
settings: SettingsRecordSchema$1
|
|
46471
|
-
});
|
|
46472
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
46473
|
-
ok: literal(true),
|
|
46474
|
-
latencyMs: number().nonnegative().optional()
|
|
46475
|
-
}).strict(), object({
|
|
46476
|
-
ok: literal(false),
|
|
46477
|
-
error: string()
|
|
46478
|
-
})]);
|
|
46479
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
46480
46599
|
var PublishInputSchema = object({
|
|
46481
46600
|
brokerId: string(),
|
|
46482
46601
|
/** Kind-specific routing target.
|
|
@@ -46520,51 +46639,12 @@ var brokerCapability = {
|
|
|
46520
46639
|
kind: "poll"
|
|
46521
46640
|
},
|
|
46522
46641
|
methods: {
|
|
46523
|
-
list: method(ListInputSchema, array(BrokerInfoSchema)),
|
|
46524
|
-
get: method(GetInputSchema, BrokerInfoSchema.nullable()),
|
|
46525
|
-
/** Enumerate which addon provides which broker kind(s) for the
|
|
46526
|
-
* unified create picker. The auto-mount fans this array across
|
|
46527
|
-
* every registered `broker` provider (array-output method), so the
|
|
46528
|
-
* picker sees every kind from every provider in one call. */
|
|
46529
|
-
listProviders: method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }),
|
|
46530
|
-
add: method(AddInputSchema, AddResultSchema, {
|
|
46531
|
-
kind: "mutation",
|
|
46532
|
-
auth: "admin"
|
|
46533
|
-
}),
|
|
46534
|
-
remove: method(RemoveInputSchema, _void(), {
|
|
46535
|
-
kind: "mutation",
|
|
46536
|
-
auth: "admin"
|
|
46537
|
-
}),
|
|
46538
|
-
testConnection: method(GetInputSchema, TestConnectionResultSchema, {
|
|
46539
|
-
kind: "mutation",
|
|
46540
|
-
auth: "admin"
|
|
46541
|
-
}),
|
|
46542
|
-
/** Read the persisted settings record for a broker (kind-specific
|
|
46543
|
-
* shape). Admin-only — settings may contain secrets. Returns `null`
|
|
46544
|
-
* when the broker id is unknown to the provider (the collection
|
|
46545
|
-
* fallback may route a foreign id to the first provider). */
|
|
46546
|
-
getSettings: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46547
|
-
/** Overwrite the persisted settings record. The kind-specific
|
|
46548
|
-
* provider validates the shape and applies the change (reconnects
|
|
46549
|
-
* if credentials changed). */
|
|
46550
|
-
setSettings: method(object({
|
|
46551
|
-
id: string(),
|
|
46552
|
-
settings: SettingsRecordSchema$1
|
|
46553
|
-
}), _void(), {
|
|
46554
|
-
kind: "mutation",
|
|
46555
|
-
auth: "admin"
|
|
46556
|
-
}),
|
|
46557
46642
|
/** Returns the kind-specific connection config the consumer needs
|
|
46558
46643
|
* to open its own client (MQTT pattern: `{url, username, password,
|
|
46559
46644
|
* clientIdPrefix}`). HA providers MAY return the auth envelope
|
|
46560
46645
|
* but typical HA consumers use `publish` / `subscribe` instead.
|
|
46561
46646
|
* Returns `null` when the broker id is unknown to the provider. */
|
|
46562
46647
|
getBrokerConfig: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46563
|
-
getSettingsSchema: method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }),
|
|
46564
|
-
testSettings: method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
46565
|
-
kind: "mutation",
|
|
46566
|
-
auth: "admin"
|
|
46567
|
-
}),
|
|
46568
46648
|
publish: method(PublishInputSchema, unknown(), {
|
|
46569
46649
|
kind: "mutation",
|
|
46570
46650
|
auth: "admin"
|
|
@@ -49198,6 +49278,9 @@ var RunningProposalEvidenceSchema = object({
|
|
|
49198
49278
|
runsFound: number().int().nonnegative(),
|
|
49199
49279
|
pausesFound: number().int().nonnegative(),
|
|
49200
49280
|
longestPauseMs: number().nonnegative(),
|
|
49281
|
+
/** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
|
|
49282
|
+
pulsesFound: number().int().nonnegative(),
|
|
49283
|
+
longestPulseMs: number().nonnegative(),
|
|
49201
49284
|
idleFloorW: number(),
|
|
49202
49285
|
noiseCeilingW: number(),
|
|
49203
49286
|
plateauW: number(),
|
|
@@ -50644,7 +50727,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
50644
50727
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
50645
50728
|
parentStableId: string().optional(),
|
|
50646
50729
|
/** `false` = shown for context but not pickable. Default true. */
|
|
50647
|
-
selectable: boolean().optional()
|
|
50730
|
+
selectable: boolean().optional(),
|
|
50731
|
+
/**
|
|
50732
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
50733
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
50734
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
50735
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
50736
|
+
*/
|
|
50737
|
+
needsParams: array(string()).optional()
|
|
50648
50738
|
});
|
|
50649
50739
|
/**
|
|
50650
50740
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -50703,12 +50793,24 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
|
|
|
50703
50793
|
}), array(DiscoveryCandidateSchema), {
|
|
50704
50794
|
kind: "mutation",
|
|
50705
50795
|
auth: "admin"
|
|
50706
|
-
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50796
|
+
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50797
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50798
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
|
|
50799
|
+
candidate: DiscoveryCandidateSchema,
|
|
50800
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
50801
|
+
integrationId: string().optional()
|
|
50802
|
+
}), DeviceSummarySchema, {
|
|
50707
50803
|
kind: "mutation",
|
|
50708
50804
|
auth: "admin"
|
|
50709
|
-
}), method(object({}), boolean()), method(object({
|
|
50805
|
+
}), method(object({}), boolean()), method(object({
|
|
50710
50806
|
type: _enum(DeviceType),
|
|
50711
|
-
|
|
50807
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50808
|
+
integrationId: string().optional()
|
|
50809
|
+
}), CreationSchemaOutputSchema), method(object({
|
|
50810
|
+
type: _enum(DeviceType),
|
|
50811
|
+
config: record(string(), unknown()),
|
|
50812
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
50813
|
+
integrationId: string().optional()
|
|
50712
50814
|
}), DeviceSummarySchema, {
|
|
50713
50815
|
kind: "mutation",
|
|
50714
50816
|
auth: "admin"
|
|
@@ -51418,7 +51520,10 @@ method(object({
|
|
|
51418
51520
|
auth: "admin"
|
|
51419
51521
|
}), method(object({
|
|
51420
51522
|
addonId: string(),
|
|
51421
|
-
type: _enum(DeviceType)
|
|
51523
|
+
type: _enum(DeviceType),
|
|
51524
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
51525
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
51526
|
+
integrationId: string().optional()
|
|
51422
51527
|
}), unknown().nullable()), method(object({
|
|
51423
51528
|
addonId: string(),
|
|
51424
51529
|
type: _enum(DeviceType),
|
|
@@ -51502,7 +51607,11 @@ method(object({
|
|
|
51502
51607
|
kind: "mutation",
|
|
51503
51608
|
auth: "admin",
|
|
51504
51609
|
timeoutMs: 12e4
|
|
51505
|
-
}), method(object({
|
|
51610
|
+
}), method(object({
|
|
51611
|
+
addonId: string(),
|
|
51612
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
51613
|
+
integrationId: string().optional()
|
|
51614
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
51506
51615
|
deviceId: number(),
|
|
51507
51616
|
key: string(),
|
|
51508
51617
|
value: unknown()
|
|
@@ -54098,7 +54207,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
54098
54207
|
"inconclusive",
|
|
54099
54208
|
"unsupported"
|
|
54100
54209
|
]);
|
|
54101
|
-
var TestConnectionResultSchema
|
|
54210
|
+
var TestConnectionResultSchema = object({
|
|
54102
54211
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
54103
54212
|
success: boolean(),
|
|
54104
54213
|
error: string().optional(),
|
|
@@ -54119,11 +54228,7 @@ var CreateIntegrationInputSchema = object({
|
|
|
54119
54228
|
info: record(string(), unknown()).optional(),
|
|
54120
54229
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54121
54230
|
originStableId: string().optional(),
|
|
54122
|
-
settings: record(string(), unknown()).optional()
|
|
54123
|
-
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
54124
|
-
* the keychain, not the table (D787). */
|
|
54125
|
-
secretKeys: array(string()).optional(),
|
|
54126
|
-
skipRestart: boolean().optional()
|
|
54231
|
+
settings: record(string(), unknown()).optional()
|
|
54127
54232
|
});
|
|
54128
54233
|
var UpdateIntegrationInputSchema = object({
|
|
54129
54234
|
id: string(),
|
|
@@ -54144,20 +54249,10 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54144
54249
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
54145
54250
|
kind: "mutation",
|
|
54146
54251
|
auth: "admin"
|
|
54147
|
-
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
54148
|
-
id: string(),
|
|
54149
|
-
settings: record(string(), unknown()),
|
|
54150
|
-
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
54151
|
-
secretKeys: array(string()).optional(),
|
|
54152
|
-
/** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
|
|
54153
|
-
skipRestart: boolean().optional()
|
|
54154
|
-
}), object({ success: boolean() }), {
|
|
54155
|
-
kind: "mutation",
|
|
54156
|
-
auth: "admin"
|
|
54157
54252
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
54158
54253
|
addonId: string(),
|
|
54159
54254
|
settings: record(string(), unknown())
|
|
54160
|
-
}), TestConnectionResultSchema
|
|
54255
|
+
}), TestConnectionResultSchema, {
|
|
54161
54256
|
kind: "mutation",
|
|
54162
54257
|
auth: "admin"
|
|
54163
54258
|
});
|
|
@@ -54184,6 +54279,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
54184
54279
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54185
54280
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54186
54281
|
/**
|
|
54282
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54283
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
54284
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54285
|
+
* Integrations.
|
|
54286
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
54287
|
+
*/
|
|
54288
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
54289
|
+
/**
|
|
54187
54290
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54188
54291
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54189
54292
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -54194,6 +54297,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54194
54297
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54195
54298
|
id: string().min(1),
|
|
54196
54299
|
label: string().min(1),
|
|
54300
|
+
/**
|
|
54301
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
54302
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
54303
|
+
* provider with more than one section must name it on every kind.
|
|
54304
|
+
*/
|
|
54305
|
+
functionCap: string().min(1),
|
|
54306
|
+
/**
|
|
54307
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
54308
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
54309
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
54310
|
+
*/
|
|
54311
|
+
brokerKind: string().min(1).optional(),
|
|
54312
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
54313
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
54314
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
54315
|
+
canTest: boolean().optional(),
|
|
54197
54316
|
/** The kind signs in through a server-held interactive session. */
|
|
54198
54317
|
signIn: object({
|
|
54199
54318
|
basePath: string().min(1),
|
|
@@ -54204,22 +54323,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54204
54323
|
/** Relative hub path to disconnect that account. */
|
|
54205
54324
|
disconnectPath: string().min(1).optional()
|
|
54206
54325
|
});
|
|
54326
|
+
/**
|
|
54327
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
54328
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
54329
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
54330
|
+
* instance and its candidates are claimed by it.
|
|
54331
|
+
*/
|
|
54332
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
54333
|
+
mode: _enum([
|
|
54334
|
+
"none",
|
|
54335
|
+
"lan",
|
|
54336
|
+
"account"
|
|
54337
|
+
]),
|
|
54338
|
+
scopedToInstance: boolean()
|
|
54339
|
+
});
|
|
54340
|
+
/**
|
|
54341
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
54342
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
54343
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
54344
|
+
*/
|
|
54345
|
+
var IntegrationInstanceLinkSchema = object({
|
|
54346
|
+
kind: string().min(1),
|
|
54347
|
+
field: string().min(1),
|
|
54348
|
+
to: object({
|
|
54349
|
+
cap: string().min(1),
|
|
54350
|
+
kind: string().min(1).optional()
|
|
54351
|
+
})
|
|
54352
|
+
});
|
|
54207
54353
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54208
54354
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54209
|
-
role:
|
|
54210
|
-
"devices",
|
|
54211
|
-
"services",
|
|
54212
|
-
"both"
|
|
54213
|
-
]),
|
|
54355
|
+
role: IntegrationInstanceRoleSchema,
|
|
54214
54356
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54215
|
-
discovery:
|
|
54216
|
-
mode: _enum([
|
|
54217
|
-
"none",
|
|
54218
|
-
"lan",
|
|
54219
|
-
"account"
|
|
54220
|
-
]),
|
|
54221
|
-
scopedToInstance: boolean()
|
|
54222
|
-
}).optional(),
|
|
54357
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
54223
54358
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54224
54359
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54225
54360
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54240,7 +54375,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
54240
54375
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54241
54376
|
* send an id (the UI then mints an opaque one).
|
|
54242
54377
|
*/
|
|
54243
|
-
mintsId: boolean().optional()
|
|
54378
|
+
mintsId: boolean().optional(),
|
|
54379
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
54380
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
54244
54381
|
});
|
|
54245
54382
|
var IntegrationInstanceStatusSchema = object({
|
|
54246
54383
|
state: _enum([
|
|
@@ -54285,7 +54422,11 @@ var integrationInstancesCapability = {
|
|
|
54285
54422
|
methods: {
|
|
54286
54423
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
54287
54424
|
/** The form; `id: null` is the create form. */
|
|
54288
|
-
instanceFormSchema: method(object({
|
|
54425
|
+
instanceFormSchema: method(object({
|
|
54426
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
54427
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
54428
|
+
kind: string().min(1).optional()
|
|
54429
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54289
54430
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54290
54431
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54291
54432
|
/**
|
|
@@ -54295,7 +54436,9 @@ var integrationInstancesCapability = {
|
|
|
54295
54436
|
createInstance: method(object({
|
|
54296
54437
|
id: IntegrationInstanceIdSchema.optional(),
|
|
54297
54438
|
name: string().min(1),
|
|
54298
|
-
kind: string().min(1).optional()
|
|
54439
|
+
kind: string().min(1).optional(),
|
|
54440
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
54441
|
+
values: record(string(), unknown()).optional()
|
|
54299
54442
|
}), object({ id: string() }), {
|
|
54300
54443
|
kind: "mutation",
|
|
54301
54444
|
auth: "admin"
|
|
@@ -54322,8 +54465,10 @@ var integrationInstancesCapability = {
|
|
|
54322
54465
|
}),
|
|
54323
54466
|
testInstance: optionalMethod(object({
|
|
54324
54467
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
54325
|
-
values: record(string(), unknown())
|
|
54326
|
-
|
|
54468
|
+
values: record(string(), unknown()),
|
|
54469
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
54470
|
+
kind: string().min(1).optional()
|
|
54471
|
+
}), TestConnectionResultSchema, {
|
|
54327
54472
|
kind: "mutation",
|
|
54328
54473
|
auth: "admin"
|
|
54329
54474
|
})
|
|
@@ -56828,6 +56973,380 @@ var SystemMetricsSchema = object({
|
|
|
56828
56973
|
gpuMemoryPercent: number().optional()
|
|
56829
56974
|
});
|
|
56830
56975
|
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);
|
|
56976
|
+
/**
|
|
56977
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
56978
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
56979
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
56980
|
+
*
|
|
56981
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
56982
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
56983
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
56984
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
56985
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
56986
|
+
* addons go through the owner's capability.
|
|
56987
|
+
*
|
|
56988
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
56989
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
56990
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
56991
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
56992
|
+
* row's own ref.
|
|
56993
|
+
*
|
|
56994
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
56995
|
+
*/
|
|
56996
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
56997
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
56998
|
+
var RecordBodySchema = record(string(), unknown());
|
|
56999
|
+
var RecordInputSchema = object({
|
|
57000
|
+
id: RecordIdSchema,
|
|
57001
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
57002
|
+
deviceId: number().int().optional(),
|
|
57003
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
57004
|
+
at: number().int().optional(),
|
|
57005
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
57006
|
+
expiresAt: number().int().optional(),
|
|
57007
|
+
data: RecordBodySchema
|
|
57008
|
+
});
|
|
57009
|
+
var RecordViewSchema = object({
|
|
57010
|
+
id: string(),
|
|
57011
|
+
deviceId: number().int().nullable(),
|
|
57012
|
+
at: number().nullable(),
|
|
57013
|
+
expiresAt: number().nullable(),
|
|
57014
|
+
rev: number().int(),
|
|
57015
|
+
updatedAt: number(),
|
|
57016
|
+
data: RecordBodySchema
|
|
57017
|
+
});
|
|
57018
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
57019
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
57020
|
+
string(),
|
|
57021
|
+
number(),
|
|
57022
|
+
boolean(),
|
|
57023
|
+
object({ in: array(union([
|
|
57024
|
+
string(),
|
|
57025
|
+
number(),
|
|
57026
|
+
boolean()
|
|
57027
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
57028
|
+
object({
|
|
57029
|
+
gt: union([string(), number()]).optional(),
|
|
57030
|
+
gte: union([string(), number()]).optional(),
|
|
57031
|
+
lt: union([string(), number()]).optional(),
|
|
57032
|
+
lte: union([string(), number()]).optional()
|
|
57033
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
57034
|
+
]));
|
|
57035
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
57036
|
+
var TimeWindowShape = {
|
|
57037
|
+
deviceId: number().int().optional(),
|
|
57038
|
+
atFrom: number().optional(),
|
|
57039
|
+
atTo: number().optional()
|
|
57040
|
+
};
|
|
57041
|
+
var RecordQueryInputSchema = object({
|
|
57042
|
+
...KindShape,
|
|
57043
|
+
...TimeWindowShape,
|
|
57044
|
+
where: RecordWhereSchema.optional(),
|
|
57045
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
57046
|
+
order: _enum(["at", "id"]).optional(),
|
|
57047
|
+
desc: boolean().optional(),
|
|
57048
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
57049
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
57050
|
+
cursor: string().min(1).optional()
|
|
57051
|
+
});
|
|
57052
|
+
var RecordQueryResultSchema = object({
|
|
57053
|
+
records: array(RecordViewSchema),
|
|
57054
|
+
nextCursor: string().nullable()
|
|
57055
|
+
});
|
|
57056
|
+
var RecordKindStateSchema = _enum([
|
|
57057
|
+
"created",
|
|
57058
|
+
"unchanged",
|
|
57059
|
+
"updated"
|
|
57060
|
+
]);
|
|
57061
|
+
var DeclareKindResultSchema = object({
|
|
57062
|
+
kindId: number().int(),
|
|
57063
|
+
state: RecordKindStateSchema,
|
|
57064
|
+
createdIndexes: array(string())
|
|
57065
|
+
});
|
|
57066
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
57067
|
+
var SecretRefsList = array(string());
|
|
57068
|
+
/**
|
|
57069
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
57070
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
57071
|
+
*/
|
|
57072
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
57073
|
+
object({
|
|
57074
|
+
op: literal("put"),
|
|
57075
|
+
kind: RecordKindNameSchema,
|
|
57076
|
+
record: RecordInputSchema,
|
|
57077
|
+
ifRev: number().int().min(0).optional()
|
|
57078
|
+
}),
|
|
57079
|
+
object({
|
|
57080
|
+
op: literal("patch"),
|
|
57081
|
+
kind: RecordKindNameSchema,
|
|
57082
|
+
id: RecordIdSchema,
|
|
57083
|
+
data: RecordBodySchema,
|
|
57084
|
+
at: number().int().nullable().optional(),
|
|
57085
|
+
expiresAt: number().int().nullable().optional(),
|
|
57086
|
+
ifRev: number().int().min(1).optional()
|
|
57087
|
+
}),
|
|
57088
|
+
object({
|
|
57089
|
+
op: literal("delete"),
|
|
57090
|
+
kind: RecordKindNameSchema,
|
|
57091
|
+
id: RecordIdSchema
|
|
57092
|
+
})
|
|
57093
|
+
]);
|
|
57094
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
57095
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
57096
|
+
kind: "mutation",
|
|
57097
|
+
auth: "admin"
|
|
57098
|
+
}), method(object({
|
|
57099
|
+
...KindShape,
|
|
57100
|
+
id: RecordIdSchema
|
|
57101
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
57102
|
+
...KindShape,
|
|
57103
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57104
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
57105
|
+
...KindShape,
|
|
57106
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57107
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
57108
|
+
...KindShape,
|
|
57109
|
+
record: RecordInputSchema,
|
|
57110
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
57111
|
+
ifRev: number().int().min(0).optional()
|
|
57112
|
+
}), object({
|
|
57113
|
+
rev: number().int(),
|
|
57114
|
+
releasedRefs: SecretRefsList
|
|
57115
|
+
}), {
|
|
57116
|
+
kind: "mutation",
|
|
57117
|
+
auth: "admin"
|
|
57118
|
+
}), method(object({
|
|
57119
|
+
...KindShape,
|
|
57120
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57121
|
+
}), object({
|
|
57122
|
+
count: number().int(),
|
|
57123
|
+
releasedRefs: SecretRefsList
|
|
57124
|
+
}), {
|
|
57125
|
+
kind: "mutation",
|
|
57126
|
+
auth: "admin"
|
|
57127
|
+
}), method(object({
|
|
57128
|
+
...KindShape,
|
|
57129
|
+
id: RecordIdSchema,
|
|
57130
|
+
data: RecordBodySchema,
|
|
57131
|
+
at: number().int().nullable().optional(),
|
|
57132
|
+
expiresAt: number().int().nullable().optional(),
|
|
57133
|
+
ifRev: number().int().min(1).optional()
|
|
57134
|
+
}), object({
|
|
57135
|
+
rev: number().int(),
|
|
57136
|
+
releasedRefs: SecretRefsList
|
|
57137
|
+
}), {
|
|
57138
|
+
kind: "mutation",
|
|
57139
|
+
auth: "admin"
|
|
57140
|
+
}), method(object({
|
|
57141
|
+
...KindShape,
|
|
57142
|
+
id: RecordIdSchema
|
|
57143
|
+
}), object({
|
|
57144
|
+
deleted: boolean(),
|
|
57145
|
+
secretRefs: SecretRefsList
|
|
57146
|
+
}), {
|
|
57147
|
+
kind: "mutation",
|
|
57148
|
+
auth: "admin"
|
|
57149
|
+
}), method(object({
|
|
57150
|
+
...KindShape,
|
|
57151
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57152
|
+
}), object({
|
|
57153
|
+
deleted: number().int(),
|
|
57154
|
+
secretRefs: SecretRefsList
|
|
57155
|
+
}), {
|
|
57156
|
+
kind: "mutation",
|
|
57157
|
+
auth: "admin"
|
|
57158
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
57159
|
+
...KindShape,
|
|
57160
|
+
...TimeWindowShape,
|
|
57161
|
+
where: RecordWhereSchema.optional()
|
|
57162
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
57163
|
+
...KindShape,
|
|
57164
|
+
deviceId: number().int().optional(),
|
|
57165
|
+
from: number(),
|
|
57166
|
+
to: number(),
|
|
57167
|
+
bucketMs: number().int().positive()
|
|
57168
|
+
}), object({ buckets: array(object({
|
|
57169
|
+
bucketStart: number(),
|
|
57170
|
+
count: number().int()
|
|
57171
|
+
})) }), { auth: "admin" }), method(object({
|
|
57172
|
+
...KindShape,
|
|
57173
|
+
op: _enum([
|
|
57174
|
+
"sum",
|
|
57175
|
+
"min",
|
|
57176
|
+
"max",
|
|
57177
|
+
"count"
|
|
57178
|
+
]),
|
|
57179
|
+
field: RecordFieldPathSchema.optional(),
|
|
57180
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
57181
|
+
where: RecordWhereSchema.optional()
|
|
57182
|
+
}), object({ rows: array(object({
|
|
57183
|
+
group: union([
|
|
57184
|
+
string(),
|
|
57185
|
+
number(),
|
|
57186
|
+
_null()
|
|
57187
|
+
]),
|
|
57188
|
+
value: number().nullable()
|
|
57189
|
+
})) }), { auth: "admin" }), method(object({
|
|
57190
|
+
...KindShape,
|
|
57191
|
+
deviceId: number().int().optional(),
|
|
57192
|
+
atBefore: number().optional(),
|
|
57193
|
+
where: RecordWhereSchema.optional()
|
|
57194
|
+
}), object({
|
|
57195
|
+
deleted: number().int(),
|
|
57196
|
+
secretRefs: SecretRefsList
|
|
57197
|
+
}), {
|
|
57198
|
+
kind: "mutation",
|
|
57199
|
+
auth: "admin"
|
|
57200
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
57201
|
+
results: array(object({
|
|
57202
|
+
rev: number().int().nullable(),
|
|
57203
|
+
deleted: boolean()
|
|
57204
|
+
})),
|
|
57205
|
+
releasedRefs: SecretRefsList,
|
|
57206
|
+
secretRefs: SecretRefsList
|
|
57207
|
+
}), {
|
|
57208
|
+
kind: "mutation",
|
|
57209
|
+
auth: "admin"
|
|
57210
|
+
}), method(object({
|
|
57211
|
+
deviceId: number().int(),
|
|
57212
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
57213
|
+
}), object({
|
|
57214
|
+
deleted: record(string(), number().int()),
|
|
57215
|
+
secretRefs: SecretRefsList
|
|
57216
|
+
}), {
|
|
57217
|
+
kind: "mutation",
|
|
57218
|
+
auth: "admin"
|
|
57219
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
57220
|
+
kind: "mutation",
|
|
57221
|
+
auth: "admin"
|
|
57222
|
+
});
|
|
57223
|
+
/**
|
|
57224
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
57225
|
+
*
|
|
57226
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
57227
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
57228
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
57229
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
57230
|
+
*
|
|
57231
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
57232
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
57233
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
57234
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
57235
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
57236
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
57237
|
+
*/
|
|
57238
|
+
var Rows = record(string(), unknown());
|
|
57239
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
57240
|
+
var RecordId = object({ id: string().min(1) });
|
|
57241
|
+
var RecordRowSchema = object({
|
|
57242
|
+
id: string(),
|
|
57243
|
+
deviceId: number().int().nullable(),
|
|
57244
|
+
at: number().nullable(),
|
|
57245
|
+
expiresAt: number().nullable(),
|
|
57246
|
+
rev: number().int(),
|
|
57247
|
+
updatedAt: number(),
|
|
57248
|
+
data: Rows
|
|
57249
|
+
});
|
|
57250
|
+
var RecordPutShape = {
|
|
57251
|
+
id: string().min(1),
|
|
57252
|
+
deviceId: number().int().optional(),
|
|
57253
|
+
at: number().int().optional(),
|
|
57254
|
+
expiresAt: number().int().optional(),
|
|
57255
|
+
data: Rows
|
|
57256
|
+
};
|
|
57257
|
+
var MigrationIntegrationSchema = object({
|
|
57258
|
+
id: string(),
|
|
57259
|
+
addonId: string(),
|
|
57260
|
+
name: string(),
|
|
57261
|
+
info: Rows,
|
|
57262
|
+
originStableId: string().optional()
|
|
57263
|
+
});
|
|
57264
|
+
var MigrationDeviceSchema = object({
|
|
57265
|
+
id: number().int(),
|
|
57266
|
+
integrationId: string().nullable().optional(),
|
|
57267
|
+
/** The owning device; null or absent for a root. */
|
|
57268
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
57269
|
+
type: string().optional(),
|
|
57270
|
+
name: string().optional(),
|
|
57271
|
+
stableId: string().optional()
|
|
57272
|
+
});
|
|
57273
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
57274
|
+
var MigrationApiInfoSchema = object({
|
|
57275
|
+
version: number().int(),
|
|
57276
|
+
methods: array(string())
|
|
57277
|
+
});
|
|
57278
|
+
object({
|
|
57279
|
+
message: string(),
|
|
57280
|
+
meta: Rows.optional(),
|
|
57281
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
57282
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
57283
|
+
});
|
|
57284
|
+
object({
|
|
57285
|
+
owner: string().min(1),
|
|
57286
|
+
metas: array(MigrationMetaSchema)
|
|
57287
|
+
}), object({
|
|
57288
|
+
bootId: string(),
|
|
57289
|
+
snapshot: _enum([
|
|
57290
|
+
"none",
|
|
57291
|
+
"written",
|
|
57292
|
+
"refused"
|
|
57293
|
+
]),
|
|
57294
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57295
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
57296
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
57297
|
+
}), object({ id: string().min(1) }), object({
|
|
57298
|
+
proceed: boolean(),
|
|
57299
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
57300
|
+
reason: string().nullable()
|
|
57301
|
+
}), object({
|
|
57302
|
+
id: string().min(1),
|
|
57303
|
+
result: MigrationOwnerResultSchema
|
|
57304
|
+
}), object({
|
|
57305
|
+
status: MigrationStatusSchema,
|
|
57306
|
+
error: string().nullable(),
|
|
57307
|
+
rowsChanged: number().int().nonnegative()
|
|
57308
|
+
}), object({
|
|
57309
|
+
rows: number().int().nonnegative(),
|
|
57310
|
+
secrets: number().int().nonnegative()
|
|
57311
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
57312
|
+
present: boolean(),
|
|
57313
|
+
removed: Rows
|
|
57314
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
57315
|
+
...RecordPutShape,
|
|
57316
|
+
ifRev: number().int().optional()
|
|
57317
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
57318
|
+
partial: Rows,
|
|
57319
|
+
ifRev: number().int().optional()
|
|
57320
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
57321
|
+
deviceId: number().int().optional(),
|
|
57322
|
+
atFrom: number().optional(),
|
|
57323
|
+
atTo: number().optional(),
|
|
57324
|
+
where: RecordWhereSchema.optional(),
|
|
57325
|
+
limit: number().int().min(1).optional(),
|
|
57326
|
+
cursor: string().min(1).optional(),
|
|
57327
|
+
resolveSecrets: boolean().optional()
|
|
57328
|
+
}), object({
|
|
57329
|
+
records: array(RecordRowSchema),
|
|
57330
|
+
nextCursor: string().nullable()
|
|
57331
|
+
}), object({
|
|
57332
|
+
deviceId: number().int().optional(),
|
|
57333
|
+
atBefore: number().optional(),
|
|
57334
|
+
where: RecordWhereSchema.optional()
|
|
57335
|
+
}), 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({
|
|
57336
|
+
ref: string().min(1),
|
|
57337
|
+
value: string()
|
|
57338
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
57339
|
+
addonId: string().min(1),
|
|
57340
|
+
integrationId: string().min(1).optional()
|
|
57341
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
57342
|
+
id: number().int(),
|
|
57343
|
+
integrationId: string().nullable(),
|
|
57344
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
57345
|
+
hasConfig: boolean()
|
|
57346
|
+
}).nullable(), object({
|
|
57347
|
+
deviceId: number().int(),
|
|
57348
|
+
integrationId: string().min(1)
|
|
57349
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
56831
57350
|
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({
|
|
56832
57351
|
id: string().min(1),
|
|
56833
57352
|
error: string().min(1)
|
|
@@ -56857,7 +57376,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
56857
57376
|
"written",
|
|
56858
57377
|
"refused"
|
|
56859
57378
|
]),
|
|
56860
|
-
steps: array(MigrationOwnerStepSchema)
|
|
57379
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57380
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
57381
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
56861
57382
|
}), {
|
|
56862
57383
|
kind: "mutation",
|
|
56863
57384
|
auth: "admin"
|
|
@@ -56878,6 +57399,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
56878
57399
|
}), {
|
|
56879
57400
|
kind: "mutation",
|
|
56880
57401
|
auth: "admin"
|
|
57402
|
+
}), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
|
|
57403
|
+
rows: number().int().nonnegative(),
|
|
57404
|
+
secrets: number().int().nonnegative()
|
|
57405
|
+
}), {
|
|
57406
|
+
kind: "mutation",
|
|
57407
|
+
auth: "admin"
|
|
57408
|
+
}), method(object({
|
|
57409
|
+
integrationId: string().min(1),
|
|
57410
|
+
patch: record(string(), unknown())
|
|
57411
|
+
}), object({ written: boolean() }), {
|
|
57412
|
+
kind: "mutation",
|
|
57413
|
+
auth: "admin"
|
|
57414
|
+
}), method(object({
|
|
57415
|
+
integrationId: string().min(1),
|
|
57416
|
+
keys: array(string().min(1))
|
|
57417
|
+
}), object({
|
|
57418
|
+
present: boolean(),
|
|
57419
|
+
removed: record(string(), unknown())
|
|
57420
|
+
}), {
|
|
57421
|
+
kind: "mutation",
|
|
57422
|
+
auth: "admin"
|
|
56881
57423
|
});
|
|
56882
57424
|
method(object({
|
|
56883
57425
|
sourceUrl: string(),
|
|
@@ -59503,7 +60045,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
59503
60045
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
59504
60046
|
kind: "mutation",
|
|
59505
60047
|
auth: "admin"
|
|
59506
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
60048
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
60049
|
+
kind: "query",
|
|
60050
|
+
auth: "admin"
|
|
60051
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
59507
60052
|
kind: "query",
|
|
59508
60053
|
auth: "admin"
|
|
59509
60054
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -61910,7 +62455,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
61910
62455
|
"unreachable",
|
|
61911
62456
|
"tls-error"
|
|
61912
62457
|
]);
|
|
61913
|
-
var BrokerInfoSchema
|
|
62458
|
+
var BrokerInfoSchema = object({
|
|
61914
62459
|
id: string(),
|
|
61915
62460
|
name: string(),
|
|
61916
62461
|
url: string(),
|
|
@@ -61973,7 +62518,7 @@ var StatusSchema = object({
|
|
|
61973
62518
|
brokerCount: number(),
|
|
61974
62519
|
embeddedRunning: boolean()
|
|
61975
62520
|
});
|
|
61976
|
-
method(_void(), array(BrokerInfoSchema
|
|
62521
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
61977
62522
|
kind: "mutation",
|
|
61978
62523
|
auth: "admin"
|
|
61979
62524
|
}), method(IdInputSchema, _void(), {
|
|
@@ -68291,253 +68836,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
68291
68836
|
auth: "admin"
|
|
68292
68837
|
});
|
|
68293
68838
|
/**
|
|
68294
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
68295
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
68296
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
68297
|
-
*
|
|
68298
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
68299
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
68300
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
68301
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
68302
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
68303
|
-
* addons go through the owner's capability.
|
|
68304
|
-
*
|
|
68305
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
68306
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
68307
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
68308
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
68309
|
-
* row's own ref.
|
|
68310
|
-
*
|
|
68311
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
68312
|
-
*/
|
|
68313
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
68314
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
68315
|
-
var RecordBodySchema = record(string(), unknown());
|
|
68316
|
-
var RecordInputSchema = object({
|
|
68317
|
-
id: RecordIdSchema,
|
|
68318
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
68319
|
-
deviceId: number().int().optional(),
|
|
68320
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
68321
|
-
at: number().int().optional(),
|
|
68322
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
68323
|
-
expiresAt: number().int().optional(),
|
|
68324
|
-
data: RecordBodySchema
|
|
68325
|
-
});
|
|
68326
|
-
var RecordViewSchema = object({
|
|
68327
|
-
id: string(),
|
|
68328
|
-
deviceId: number().int().nullable(),
|
|
68329
|
-
at: number().nullable(),
|
|
68330
|
-
expiresAt: number().nullable(),
|
|
68331
|
-
rev: number().int(),
|
|
68332
|
-
updatedAt: number(),
|
|
68333
|
-
data: RecordBodySchema
|
|
68334
|
-
});
|
|
68335
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
68336
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
68337
|
-
string(),
|
|
68338
|
-
number(),
|
|
68339
|
-
boolean(),
|
|
68340
|
-
object({ in: array(union([
|
|
68341
|
-
string(),
|
|
68342
|
-
number(),
|
|
68343
|
-
boolean()
|
|
68344
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
68345
|
-
object({
|
|
68346
|
-
gt: union([string(), number()]).optional(),
|
|
68347
|
-
gte: union([string(), number()]).optional(),
|
|
68348
|
-
lt: union([string(), number()]).optional(),
|
|
68349
|
-
lte: union([string(), number()]).optional()
|
|
68350
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
68351
|
-
]));
|
|
68352
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
68353
|
-
var TimeWindowShape = {
|
|
68354
|
-
deviceId: number().int().optional(),
|
|
68355
|
-
atFrom: number().optional(),
|
|
68356
|
-
atTo: number().optional()
|
|
68357
|
-
};
|
|
68358
|
-
var RecordQueryInputSchema = object({
|
|
68359
|
-
...KindShape,
|
|
68360
|
-
...TimeWindowShape,
|
|
68361
|
-
where: RecordWhereSchema.optional(),
|
|
68362
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
68363
|
-
order: _enum(["at", "id"]).optional(),
|
|
68364
|
-
desc: boolean().optional(),
|
|
68365
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
68366
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
68367
|
-
cursor: string().min(1).optional()
|
|
68368
|
-
});
|
|
68369
|
-
var RecordQueryResultSchema = object({
|
|
68370
|
-
records: array(RecordViewSchema),
|
|
68371
|
-
nextCursor: string().nullable()
|
|
68372
|
-
});
|
|
68373
|
-
var RecordKindStateSchema = _enum([
|
|
68374
|
-
"created",
|
|
68375
|
-
"unchanged",
|
|
68376
|
-
"updated"
|
|
68377
|
-
]);
|
|
68378
|
-
var DeclareKindResultSchema = object({
|
|
68379
|
-
kindId: number().int(),
|
|
68380
|
-
state: RecordKindStateSchema,
|
|
68381
|
-
createdIndexes: array(string())
|
|
68382
|
-
});
|
|
68383
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
68384
|
-
var SecretRefsList = array(string());
|
|
68385
|
-
/**
|
|
68386
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
68387
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
68388
|
-
*/
|
|
68389
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
68390
|
-
object({
|
|
68391
|
-
op: literal("put"),
|
|
68392
|
-
kind: RecordKindNameSchema,
|
|
68393
|
-
record: RecordInputSchema,
|
|
68394
|
-
ifRev: number().int().min(0).optional()
|
|
68395
|
-
}),
|
|
68396
|
-
object({
|
|
68397
|
-
op: literal("patch"),
|
|
68398
|
-
kind: RecordKindNameSchema,
|
|
68399
|
-
id: RecordIdSchema,
|
|
68400
|
-
data: RecordBodySchema,
|
|
68401
|
-
at: number().int().nullable().optional(),
|
|
68402
|
-
expiresAt: number().int().nullable().optional(),
|
|
68403
|
-
ifRev: number().int().min(1).optional()
|
|
68404
|
-
}),
|
|
68405
|
-
object({
|
|
68406
|
-
op: literal("delete"),
|
|
68407
|
-
kind: RecordKindNameSchema,
|
|
68408
|
-
id: RecordIdSchema
|
|
68409
|
-
})
|
|
68410
|
-
]);
|
|
68411
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
68412
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
68413
|
-
kind: "mutation",
|
|
68414
|
-
auth: "admin"
|
|
68415
|
-
}), method(object({
|
|
68416
|
-
...KindShape,
|
|
68417
|
-
id: RecordIdSchema
|
|
68418
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
68419
|
-
...KindShape,
|
|
68420
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68421
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
68422
|
-
...KindShape,
|
|
68423
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68424
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
68425
|
-
...KindShape,
|
|
68426
|
-
record: RecordInputSchema,
|
|
68427
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
68428
|
-
ifRev: number().int().min(0).optional()
|
|
68429
|
-
}), object({
|
|
68430
|
-
rev: number().int(),
|
|
68431
|
-
releasedRefs: SecretRefsList
|
|
68432
|
-
}), {
|
|
68433
|
-
kind: "mutation",
|
|
68434
|
-
auth: "admin"
|
|
68435
|
-
}), method(object({
|
|
68436
|
-
...KindShape,
|
|
68437
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68438
|
-
}), object({
|
|
68439
|
-
count: number().int(),
|
|
68440
|
-
releasedRefs: SecretRefsList
|
|
68441
|
-
}), {
|
|
68442
|
-
kind: "mutation",
|
|
68443
|
-
auth: "admin"
|
|
68444
|
-
}), method(object({
|
|
68445
|
-
...KindShape,
|
|
68446
|
-
id: RecordIdSchema,
|
|
68447
|
-
data: RecordBodySchema,
|
|
68448
|
-
at: number().int().nullable().optional(),
|
|
68449
|
-
expiresAt: number().int().nullable().optional(),
|
|
68450
|
-
ifRev: number().int().min(1).optional()
|
|
68451
|
-
}), object({
|
|
68452
|
-
rev: number().int(),
|
|
68453
|
-
releasedRefs: SecretRefsList
|
|
68454
|
-
}), {
|
|
68455
|
-
kind: "mutation",
|
|
68456
|
-
auth: "admin"
|
|
68457
|
-
}), method(object({
|
|
68458
|
-
...KindShape,
|
|
68459
|
-
id: RecordIdSchema
|
|
68460
|
-
}), object({
|
|
68461
|
-
deleted: boolean(),
|
|
68462
|
-
secretRefs: SecretRefsList
|
|
68463
|
-
}), {
|
|
68464
|
-
kind: "mutation",
|
|
68465
|
-
auth: "admin"
|
|
68466
|
-
}), method(object({
|
|
68467
|
-
...KindShape,
|
|
68468
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68469
|
-
}), object({
|
|
68470
|
-
deleted: number().int(),
|
|
68471
|
-
secretRefs: SecretRefsList
|
|
68472
|
-
}), {
|
|
68473
|
-
kind: "mutation",
|
|
68474
|
-
auth: "admin"
|
|
68475
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
68476
|
-
...KindShape,
|
|
68477
|
-
...TimeWindowShape,
|
|
68478
|
-
where: RecordWhereSchema.optional()
|
|
68479
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
68480
|
-
...KindShape,
|
|
68481
|
-
deviceId: number().int().optional(),
|
|
68482
|
-
from: number(),
|
|
68483
|
-
to: number(),
|
|
68484
|
-
bucketMs: number().int().positive()
|
|
68485
|
-
}), object({ buckets: array(object({
|
|
68486
|
-
bucketStart: number(),
|
|
68487
|
-
count: number().int()
|
|
68488
|
-
})) }), { auth: "admin" }), method(object({
|
|
68489
|
-
...KindShape,
|
|
68490
|
-
op: _enum([
|
|
68491
|
-
"sum",
|
|
68492
|
-
"min",
|
|
68493
|
-
"max",
|
|
68494
|
-
"count"
|
|
68495
|
-
]),
|
|
68496
|
-
field: RecordFieldPathSchema.optional(),
|
|
68497
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
68498
|
-
where: RecordWhereSchema.optional()
|
|
68499
|
-
}), object({ rows: array(object({
|
|
68500
|
-
group: union([
|
|
68501
|
-
string(),
|
|
68502
|
-
number(),
|
|
68503
|
-
_null()
|
|
68504
|
-
]),
|
|
68505
|
-
value: number().nullable()
|
|
68506
|
-
})) }), { auth: "admin" }), method(object({
|
|
68507
|
-
...KindShape,
|
|
68508
|
-
deviceId: number().int().optional(),
|
|
68509
|
-
atBefore: number().optional(),
|
|
68510
|
-
where: RecordWhereSchema.optional()
|
|
68511
|
-
}), object({
|
|
68512
|
-
deleted: number().int(),
|
|
68513
|
-
secretRefs: SecretRefsList
|
|
68514
|
-
}), {
|
|
68515
|
-
kind: "mutation",
|
|
68516
|
-
auth: "admin"
|
|
68517
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
68518
|
-
results: array(object({
|
|
68519
|
-
rev: number().int().nullable(),
|
|
68520
|
-
deleted: boolean()
|
|
68521
|
-
})),
|
|
68522
|
-
releasedRefs: SecretRefsList,
|
|
68523
|
-
secretRefs: SecretRefsList
|
|
68524
|
-
}), {
|
|
68525
|
-
kind: "mutation",
|
|
68526
|
-
auth: "admin"
|
|
68527
|
-
}), method(object({
|
|
68528
|
-
deviceId: number().int(),
|
|
68529
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
68530
|
-
}), object({
|
|
68531
|
-
deleted: record(string(), number().int()),
|
|
68532
|
-
secretRefs: SecretRefsList
|
|
68533
|
-
}), {
|
|
68534
|
-
kind: "mutation",
|
|
68535
|
-
auth: "admin"
|
|
68536
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
68537
|
-
kind: "mutation",
|
|
68538
|
-
auth: "admin"
|
|
68539
|
-
});
|
|
68540
|
-
/**
|
|
68541
68839
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
68542
68840
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
68543
68841
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -76052,11 +76350,15 @@ discriminatedUnion("kind", [object({
|
|
|
76052
76350
|
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
76053
76351
|
* near F. A device that is not near one level most of the time has no floor.
|
|
76054
76352
|
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
76055
|
-
* 3.
|
|
76056
|
-
*
|
|
76353
|
+
* 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
|
|
76354
|
+
* display waking): it is neither a run nor a pause. Among the remaining
|
|
76355
|
+
* episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
|
|
76356
|
+
* two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
|
|
76357
|
+
* a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
|
|
76358
|
+
* is no run.
|
|
76057
76359
|
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
76058
|
-
* grid a person would type; stop dwell covers the longest pause
|
|
76059
|
-
* covers the longest standby blip above T.
|
|
76360
|
+
* grid a person would type; stop dwell covers the longest pause and the
|
|
76361
|
+
* kind's floor; start dwell covers the longest pulse and standby blip above T.
|
|
76060
76362
|
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
76061
76363
|
* run must hold exactly one true interval and nothing may flap outside.
|
|
76062
76364
|
*/
|
|
@@ -76067,6 +76369,10 @@ var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
|
76067
76369
|
30 * SECOND_MS;
|
|
76068
76370
|
60 * SECOND_MS;
|
|
76069
76371
|
20 * MINUTE_MS$1;
|
|
76372
|
+
90 * SECOND_MS;
|
|
76373
|
+
30 * MINUTE_MS$1;
|
|
76374
|
+
10 * MINUTE_MS$1;
|
|
76375
|
+
DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
|
|
76070
76376
|
10 * SECOND_MS;
|
|
76071
76377
|
10 * SECOND_MS;
|
|
76072
76378
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
@@ -77085,20 +77391,6 @@ Object.freeze({
|
|
|
77085
77391
|
access: "create",
|
|
77086
77392
|
role: "viewer"
|
|
77087
77393
|
},
|
|
77088
|
-
"broker.add": {
|
|
77089
|
-
capName: "broker",
|
|
77090
|
-
capScope: "system",
|
|
77091
|
-
addonId: null,
|
|
77092
|
-
access: "create",
|
|
77093
|
-
role: "admin"
|
|
77094
|
-
},
|
|
77095
|
-
"broker.get": {
|
|
77096
|
-
capName: "broker",
|
|
77097
|
-
capScope: "system",
|
|
77098
|
-
addonId: null,
|
|
77099
|
-
access: "view",
|
|
77100
|
-
role: "admin"
|
|
77101
|
-
},
|
|
77102
77394
|
"broker.getBrokerConfig": {
|
|
77103
77395
|
capName: "broker",
|
|
77104
77396
|
capScope: "system",
|
|
@@ -77106,20 +77398,6 @@ Object.freeze({
|
|
|
77106
77398
|
access: "view",
|
|
77107
77399
|
role: "admin"
|
|
77108
77400
|
},
|
|
77109
|
-
"broker.getSettings": {
|
|
77110
|
-
capName: "broker",
|
|
77111
|
-
capScope: "system",
|
|
77112
|
-
addonId: null,
|
|
77113
|
-
access: "view",
|
|
77114
|
-
role: "admin"
|
|
77115
|
-
},
|
|
77116
|
-
"broker.getSettingsSchema": {
|
|
77117
|
-
capName: "broker",
|
|
77118
|
-
capScope: "system",
|
|
77119
|
-
addonId: null,
|
|
77120
|
-
access: "view",
|
|
77121
|
-
role: "admin"
|
|
77122
|
-
},
|
|
77123
77401
|
"broker.getState": {
|
|
77124
77402
|
capName: "broker",
|
|
77125
77403
|
capScope: "system",
|
|
@@ -77134,20 +77412,6 @@ Object.freeze({
|
|
|
77134
77412
|
access: "view",
|
|
77135
77413
|
role: "admin"
|
|
77136
77414
|
},
|
|
77137
|
-
"broker.list": {
|
|
77138
|
-
capName: "broker",
|
|
77139
|
-
capScope: "system",
|
|
77140
|
-
addonId: null,
|
|
77141
|
-
access: "view",
|
|
77142
|
-
role: "admin"
|
|
77143
|
-
},
|
|
77144
|
-
"broker.listProviders": {
|
|
77145
|
-
capName: "broker",
|
|
77146
|
-
capScope: "system",
|
|
77147
|
-
addonId: null,
|
|
77148
|
-
access: "view",
|
|
77149
|
-
role: "admin"
|
|
77150
|
-
},
|
|
77151
77415
|
"broker.publish": {
|
|
77152
77416
|
capName: "broker",
|
|
77153
77417
|
capScope: "system",
|
|
@@ -77155,20 +77419,6 @@ Object.freeze({
|
|
|
77155
77419
|
access: "create",
|
|
77156
77420
|
role: "admin"
|
|
77157
77421
|
},
|
|
77158
|
-
"broker.remove": {
|
|
77159
|
-
capName: "broker",
|
|
77160
|
-
capScope: "system",
|
|
77161
|
-
addonId: null,
|
|
77162
|
-
access: "delete",
|
|
77163
|
-
role: "admin"
|
|
77164
|
-
},
|
|
77165
|
-
"broker.setSettings": {
|
|
77166
|
-
capName: "broker",
|
|
77167
|
-
capScope: "system",
|
|
77168
|
-
addonId: null,
|
|
77169
|
-
access: "create",
|
|
77170
|
-
role: "admin"
|
|
77171
|
-
},
|
|
77172
77422
|
"broker.subscribe": {
|
|
77173
77423
|
capName: "broker",
|
|
77174
77424
|
capScope: "system",
|
|
@@ -77176,20 +77426,6 @@ Object.freeze({
|
|
|
77176
77426
|
access: "create",
|
|
77177
77427
|
role: "admin"
|
|
77178
77428
|
},
|
|
77179
|
-
"broker.testConnection": {
|
|
77180
|
-
capName: "broker",
|
|
77181
|
-
capScope: "system",
|
|
77182
|
-
addonId: null,
|
|
77183
|
-
access: "create",
|
|
77184
|
-
role: "admin"
|
|
77185
|
-
},
|
|
77186
|
-
"broker.testSettings": {
|
|
77187
|
-
capName: "broker",
|
|
77188
|
-
capScope: "system",
|
|
77189
|
-
addonId: null,
|
|
77190
|
-
access: "create",
|
|
77191
|
-
role: "admin"
|
|
77192
|
-
},
|
|
77193
77429
|
"broker.unsubscribe": {
|
|
77194
77430
|
capName: "broker",
|
|
77195
77431
|
capScope: "system",
|
|
@@ -79822,13 +80058,6 @@ Object.freeze({
|
|
|
79822
80058
|
access: "view",
|
|
79823
80059
|
role: "admin"
|
|
79824
80060
|
},
|
|
79825
|
-
"integrations.getSettings": {
|
|
79826
|
-
capName: "integrations",
|
|
79827
|
-
capScope: "system",
|
|
79828
|
-
addonId: null,
|
|
79829
|
-
access: "view",
|
|
79830
|
-
role: "admin"
|
|
79831
|
-
},
|
|
79832
80061
|
"integrations.list": {
|
|
79833
80062
|
capName: "integrations",
|
|
79834
80063
|
capScope: "system",
|
|
@@ -79836,13 +80065,6 @@ Object.freeze({
|
|
|
79836
80065
|
access: "view",
|
|
79837
80066
|
role: "admin"
|
|
79838
80067
|
},
|
|
79839
|
-
"integrations.setSettings": {
|
|
79840
|
-
capName: "integrations",
|
|
79841
|
-
capScope: "system",
|
|
79842
|
-
addonId: null,
|
|
79843
|
-
access: "create",
|
|
79844
|
-
role: "admin"
|
|
79845
|
-
},
|
|
79846
80068
|
"integrations.testConnection": {
|
|
79847
80069
|
capName: "integrations",
|
|
79848
80070
|
capScope: "system",
|
|
@@ -80837,6 +81059,13 @@ Object.freeze({
|
|
|
80837
81059
|
access: "view",
|
|
80838
81060
|
role: "admin"
|
|
80839
81061
|
},
|
|
81062
|
+
"migrations.clearLegacyIntegrationRows": {
|
|
81063
|
+
capName: "migrations",
|
|
81064
|
+
capScope: "system",
|
|
81065
|
+
addonId: null,
|
|
81066
|
+
access: "delete",
|
|
81067
|
+
role: "admin"
|
|
81068
|
+
},
|
|
80840
81069
|
"migrations.declareOwner": {
|
|
80841
81070
|
capName: "migrations",
|
|
80842
81071
|
capScope: "system",
|
|
@@ -80844,6 +81073,13 @@ Object.freeze({
|
|
|
80844
81073
|
access: "create",
|
|
80845
81074
|
role: "admin"
|
|
80846
81075
|
},
|
|
81076
|
+
"migrations.deleteLegacyIntegrationRowKeys": {
|
|
81077
|
+
capName: "migrations",
|
|
81078
|
+
capScope: "system",
|
|
81079
|
+
addonId: null,
|
|
81080
|
+
access: "delete",
|
|
81081
|
+
role: "admin"
|
|
81082
|
+
},
|
|
80847
81083
|
"migrations.dryRun": {
|
|
80848
81084
|
capName: "migrations",
|
|
80849
81085
|
capScope: "system",
|
|
@@ -80879,6 +81115,20 @@ Object.freeze({
|
|
|
80879
81115
|
access: "create",
|
|
80880
81116
|
role: "admin"
|
|
80881
81117
|
},
|
|
81118
|
+
"migrations.patchLegacyIntegrationRows": {
|
|
81119
|
+
capName: "migrations",
|
|
81120
|
+
capScope: "system",
|
|
81121
|
+
addonId: null,
|
|
81122
|
+
access: "create",
|
|
81123
|
+
role: "admin"
|
|
81124
|
+
},
|
|
81125
|
+
"migrations.readLegacyIntegrationRows": {
|
|
81126
|
+
capName: "migrations",
|
|
81127
|
+
capScope: "system",
|
|
81128
|
+
addonId: null,
|
|
81129
|
+
access: "view",
|
|
81130
|
+
role: "admin"
|
|
81131
|
+
},
|
|
80882
81132
|
"migrations.restorePreMigration": {
|
|
80883
81133
|
capName: "migrations",
|
|
80884
81134
|
capScope: "system",
|
|
@@ -82139,6 +82389,13 @@ Object.freeze({
|
|
|
82139
82389
|
access: "view",
|
|
82140
82390
|
role: "viewer"
|
|
82141
82391
|
},
|
|
82392
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
82393
|
+
capName: "pipeline-analytics",
|
|
82394
|
+
capScope: "device",
|
|
82395
|
+
addonId: null,
|
|
82396
|
+
access: "view",
|
|
82397
|
+
role: "admin"
|
|
82398
|
+
},
|
|
82142
82399
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
82143
82400
|
capName: "pipeline-analytics",
|
|
82144
82401
|
capScope: "device",
|
|
@@ -91111,6 +91368,165 @@ object({
|
|
|
91111
91368
|
delay: number().nonnegative().optional(),
|
|
91112
91369
|
commands: record(string(), unknown())
|
|
91113
91370
|
});
|
|
91371
|
+
/** The `instance-select` field of a link, keyed like the body field it fills. */
|
|
91372
|
+
function linkFieldDescriptor(key, target, labels) {
|
|
91373
|
+
return {
|
|
91374
|
+
type: "instance-select",
|
|
91375
|
+
key,
|
|
91376
|
+
label: labels.label,
|
|
91377
|
+
...labels.description !== void 0 ? { description: labels.description } : {},
|
|
91378
|
+
required: labels.required ?? true,
|
|
91379
|
+
...labels.noneLabel !== void 0 ? { noneLabel: labels.noneLabel } : {},
|
|
91380
|
+
functionCap: target.cap,
|
|
91381
|
+
...target.kind !== void 0 ? { kind: target.kind } : {}
|
|
91382
|
+
};
|
|
91383
|
+
}
|
|
91384
|
+
/**
|
|
91385
|
+
* Declare the record kind of a service that links to other instances. The body is
|
|
91386
|
+
* `{ name, ...links, ...fields }`; the links are recorded in the kind (read back by
|
|
91387
|
+
* {@link linksOfKind}) so the hub can index who points at what.
|
|
91388
|
+
*/
|
|
91389
|
+
function declareLinkKind(spec) {
|
|
91390
|
+
const linkShape = {};
|
|
91391
|
+
for (const [field, target] of Object.entries(spec.links)) linkShape[field] = linkField(target);
|
|
91392
|
+
const typed = entryBody({
|
|
91393
|
+
...linkShape,
|
|
91394
|
+
...spec.fields
|
|
91395
|
+
});
|
|
91396
|
+
return defineEntryKind(spec.name, {
|
|
91397
|
+
title: spec.title,
|
|
91398
|
+
schema: typed,
|
|
91399
|
+
writeTrigger: spec.writeTrigger
|
|
91400
|
+
});
|
|
91401
|
+
}
|
|
91402
|
+
/** The id a record holds in a link field; undefined while it names none. */
|
|
91403
|
+
function linkedId(body, field) {
|
|
91404
|
+
const value = body[field];
|
|
91405
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
91406
|
+
}
|
|
91407
|
+
/** The `integration-instances` provider of a service whose records link to other instances. */
|
|
91408
|
+
function buildLinkedInstances(records, spec) {
|
|
91409
|
+
const links = linksOfKind(spec.kind);
|
|
91410
|
+
const kindId = spec.instanceKind ?? spec.kind.name;
|
|
91411
|
+
const instances = new RecordIntegrationInstances(records, spec.kind, {
|
|
91412
|
+
description: {
|
|
91413
|
+
...spec.description,
|
|
91414
|
+
links: links.map((link) => ({
|
|
91415
|
+
kind: kindId,
|
|
91416
|
+
field: link.field,
|
|
91417
|
+
to: link.to
|
|
91418
|
+
}))
|
|
91419
|
+
},
|
|
91420
|
+
formSchema: async (id) => {
|
|
91421
|
+
const first = links[0];
|
|
91422
|
+
const chosen = id === null || first === void 0 || spec.dynamicSections === void 0 ? void 0 : linkedId(await instances.getResolved(id) ?? {}, first.field);
|
|
91423
|
+
const dynamic = chosen !== void 0 && spec.dynamicSections !== void 0 ? await spec.dynamicSections(chosen) : [];
|
|
91424
|
+
return { sections: [
|
|
91425
|
+
{
|
|
91426
|
+
id: "links",
|
|
91427
|
+
title: "Linked instances",
|
|
91428
|
+
columns: 1,
|
|
91429
|
+
fields: links.map((link) => linkFieldDescriptor(link.field, link.to, spec.labels?.[link.field] ?? { label: link.field }))
|
|
91430
|
+
},
|
|
91431
|
+
...spec.linkSections ?? [],
|
|
91432
|
+
...dynamic
|
|
91433
|
+
] };
|
|
91434
|
+
},
|
|
91435
|
+
initialBody: (name) => spec.kind.schema.parse({
|
|
91436
|
+
name,
|
|
91437
|
+
...Object.fromEntries(links.map((link) => [link.field, ""]))
|
|
91438
|
+
}),
|
|
91439
|
+
configured: (body) => links.every((link) => linkedId(body, link.field) !== void 0) && (spec.alsoConfigured?.(body) ?? true),
|
|
91440
|
+
...spec.mintId !== void 0 ? { mintId: spec.mintId } : {},
|
|
91441
|
+
...spec.onChanged !== void 0 ? { onChanged: spec.onChanged } : {}
|
|
91442
|
+
});
|
|
91443
|
+
return instances;
|
|
91444
|
+
}
|
|
91445
|
+
entryBody({ brokerId: string() });
|
|
91446
|
+
/**
|
|
91447
|
+
* The calendars an account imports leave the account (D1013). An account record used to carry a
|
|
91448
|
+
* `calendarIds` array; each calendar is now a record of its own that LINKS to the account
|
|
91449
|
+
* (`calendars`, one per account and calendar). For every account row with an array:
|
|
91450
|
+
*
|
|
91451
|
+
* 1. each entry becomes a calendar record under a deterministic id (an existing one is kept);
|
|
91452
|
+
* 2. each record is read back and must name this account and calendar;
|
|
91453
|
+
* 3. only then is the array cleared (a patch: nothing else on the account is touched).
|
|
91454
|
+
*
|
|
91455
|
+
* An entry that names another account, or is not a calendar id at all, selected nothing before
|
|
91456
|
+
* (the reader only matched its own account's ids): it is counted, named in a warning and goes with
|
|
91457
|
+
* the array. An array that is not a list of strings is left where it is. A failure on one account
|
|
91458
|
+
* does not stop the others; the run then throws, and the accounts that failed keep their array.
|
|
91459
|
+
* Accounts are never created or deleted. Idempotent: with the arrays cleared nothing is left to do.
|
|
91460
|
+
*/
|
|
91461
|
+
/** The id of the calendar record of one (account, calendar): the same pair is always the same row. */
|
|
91462
|
+
function calendarRecordId(accountId, calendarId) {
|
|
91463
|
+
return `cal_${createHash("sha1").update(`${accountId}\0${calendarId}`).digest("hex").slice(0, 16)}`;
|
|
91464
|
+
}
|
|
91465
|
+
function entriesOf(value) {
|
|
91466
|
+
if (!Array.isArray(value)) return null;
|
|
91467
|
+
const out = [];
|
|
91468
|
+
for (const item of value) {
|
|
91469
|
+
if (typeof item !== "string") return null;
|
|
91470
|
+
out.push(item);
|
|
91471
|
+
}
|
|
91472
|
+
return out;
|
|
91473
|
+
}
|
|
91474
|
+
async function moveCalendarIdsToRecords(ports, spec) {
|
|
91475
|
+
let created = 0;
|
|
91476
|
+
let cleared = 0;
|
|
91477
|
+
let dropped = 0;
|
|
91478
|
+
const failed = [];
|
|
91479
|
+
for (const account of await ports.listAccounts()) {
|
|
91480
|
+
if (account.calendarIds === void 0 || account.calendarIds === null) continue;
|
|
91481
|
+
const entries = entriesOf(account.calendarIds);
|
|
91482
|
+
if (entries === null) {
|
|
91483
|
+
ports.warn(`account '${account.id}': calendarIds is not a list of ids and stays as it is`);
|
|
91484
|
+
failed.push(account.id);
|
|
91485
|
+
continue;
|
|
91486
|
+
}
|
|
91487
|
+
try {
|
|
91488
|
+
const own = /* @__PURE__ */ new Set();
|
|
91489
|
+
const inert = [];
|
|
91490
|
+
for (const entry of entries) {
|
|
91491
|
+
const calendarId = spec.calendarIdOf(account.id, entry);
|
|
91492
|
+
if (calendarId === null || calendarId === "") inert.push(entry);
|
|
91493
|
+
else own.add(calendarId);
|
|
91494
|
+
}
|
|
91495
|
+
for (const calendarId of own) {
|
|
91496
|
+
const recordId = calendarRecordId(account.id, calendarId);
|
|
91497
|
+
const body = {
|
|
91498
|
+
name: calendarId,
|
|
91499
|
+
accountId: account.id,
|
|
91500
|
+
calendarId
|
|
91501
|
+
};
|
|
91502
|
+
if (await ports.readCalendar(recordId) === null) {
|
|
91503
|
+
await ports.putCalendar(recordId, body);
|
|
91504
|
+
created += 1;
|
|
91505
|
+
}
|
|
91506
|
+
const back = await ports.readCalendar(recordId);
|
|
91507
|
+
if (back?.accountId !== account.id || back.calendarId !== calendarId) throw new Error(`account '${account.id}': the calendar record '${recordId}' did not read back; the array stays`);
|
|
91508
|
+
}
|
|
91509
|
+
if (inert.length > 0) {
|
|
91510
|
+
ports.warn(`account '${account.id}': ${inert.length} entr${inert.length === 1 ? "y" : "ies"} of calendarIds named another account or no calendar and selected nothing: ${inert.join(", ")}`);
|
|
91511
|
+
dropped += inert.length;
|
|
91512
|
+
}
|
|
91513
|
+
await ports.clearCalendarIds(account.id);
|
|
91514
|
+
cleared += 1;
|
|
91515
|
+
} catch (error) {
|
|
91516
|
+
ports.warn(error instanceof Error ? error.message : String(error));
|
|
91517
|
+
failed.push(account.id);
|
|
91518
|
+
}
|
|
91519
|
+
}
|
|
91520
|
+
if (failed.length > 0) throw new Error(`calendarIds kept on ${failed.length} account(s) (${failed.join(", ")}); ${created} calendar record(s) written, ${cleared} account(s) cleared`);
|
|
91521
|
+
return {
|
|
91522
|
+
outcome: created === 0 && cleared === 0 ? "already-done" : "done",
|
|
91523
|
+
summary: {
|
|
91524
|
+
created,
|
|
91525
|
+
cleared,
|
|
91526
|
+
dropped
|
|
91527
|
+
}
|
|
91528
|
+
};
|
|
91529
|
+
}
|
|
91114
91530
|
//#endregion
|
|
91115
91531
|
//#region src/google-types.ts
|
|
91116
91532
|
/** One Google account connection (broker entry). Credentials for the OAuth
|
|
@@ -91121,28 +91537,16 @@ var GoogleBrokerEntrySchema = object({
|
|
|
91121
91537
|
clientId: string().default(""),
|
|
91122
91538
|
clientSecret: string().default("").meta({ secret: true }),
|
|
91123
91539
|
/**
|
|
91124
|
-
* @deprecated Per-broker filter;
|
|
91125
|
-
*
|
|
91540
|
+
* @deprecated Per-broker filter; the calendars an account imports are `calendars` records
|
|
91541
|
+
* (Connectivity → Calendars). Kept for migrate only.
|
|
91126
91542
|
*/
|
|
91127
91543
|
calendarFilter: string().default(""),
|
|
91128
91544
|
/** Default From for Gmail send — usually the connected account email. */
|
|
91129
91545
|
fromAddress: string().default(""),
|
|
91130
|
-
fromName: string().default("")
|
|
91131
|
-
/**
|
|
91132
|
-
* The stamped calendar ids (`<brokerId>:<googleCalendarId>`) this broker imports. `undefined`
|
|
91133
|
-
* means "not moved here yet": the reader falls back to the shared `calendarIds` setting of
|
|
91134
|
-
* the addon until the migration copied it. Empty = import none.
|
|
91135
|
-
*/
|
|
91136
|
-
calendarIds: array(string()).optional()
|
|
91546
|
+
fromName: string().default("")
|
|
91137
91547
|
});
|
|
91138
91548
|
var GoogleServicesConfigSchema = object({
|
|
91139
91549
|
brokers: array(GoogleBrokerEntrySchema).default([]),
|
|
91140
|
-
/**
|
|
91141
|
-
* @deprecated The shared set (`brokerId:googleCalendarId`). Each broker owns its own
|
|
91142
|
-
* `calendarIds` now; this key is read only while a broker has none, and the migration
|
|
91143
|
-
* `google-services/2026-11-03-drop-shared-calendar-ids` deletes it.
|
|
91144
|
-
*/
|
|
91145
|
-
calendarIds: array(string()).default([]),
|
|
91146
91550
|
/** @deprecated Pre-broker singleton — cleared after migrateLegacyToBrokers. */
|
|
91147
91551
|
clientId: string().optional(),
|
|
91148
91552
|
/** @deprecated Pre-broker singleton — cleared after migrateLegacyToBrokers. */
|
|
@@ -91196,37 +91600,32 @@ var OAUTH_START_PATH = `/addon/google-services/oauth/start`;
|
|
|
91196
91600
|
var OAUTH_CALLBACK_SUFFIX = `/addon/google-services/oauth/callback`;
|
|
91197
91601
|
//#endregion
|
|
91198
91602
|
//#region src/google-broker-registry.ts
|
|
91603
|
+
/**
|
|
91604
|
+
* Google broker registry — N Google accounts under kind `google`.
|
|
91605
|
+
* No live WS; "connected" means a refresh token exists for the broker id.
|
|
91606
|
+
*/
|
|
91199
91607
|
var GoogleAddSettingsSchema = object({
|
|
91200
91608
|
clientId: string().min(1),
|
|
91201
91609
|
clientSecret: string().min(1).meta({ secret: true }),
|
|
91202
|
-
/**
|
|
91203
|
-
calendarIds: array(string()).optional(),
|
|
91204
|
-
/** @deprecated Prefer calendarIds — still accepted on save. */
|
|
91610
|
+
/** @deprecated Calendars are `calendars` records now — still accepted on save. */
|
|
91205
91611
|
calendarFilter: string().optional(),
|
|
91206
91612
|
fromAddress: string().optional(),
|
|
91207
91613
|
fromName: string().optional()
|
|
91208
91614
|
});
|
|
91209
|
-
/** Persist UI calendarIds (or legacy filter string) as comma-separated filter. */
|
|
91210
|
-
function calendarIdsToFilter(settings) {
|
|
91211
|
-
if (settings.calendarIds !== void 0) return settings.calendarIds.map((s) => s.trim()).filter((s) => s.length > 0).join(",");
|
|
91212
|
-
return settings.calendarFilter ?? "";
|
|
91213
|
-
}
|
|
91214
91615
|
function settingsToBrokerFields(settings) {
|
|
91215
91616
|
const parsed = GoogleAddSettingsSchema.parse(settings);
|
|
91216
91617
|
return {
|
|
91217
91618
|
clientId: parsed.clientId,
|
|
91218
91619
|
clientSecret: parsed.clientSecret,
|
|
91219
|
-
calendarFilter:
|
|
91620
|
+
calendarFilter: parsed.calendarFilter ?? "",
|
|
91220
91621
|
fromAddress: parsed.fromAddress ?? "",
|
|
91221
|
-
fromName: parsed.fromName ?? ""
|
|
91222
|
-
...parsed.calendarIds !== void 0 ? { calendarIds: [...parsed.calendarIds] } : {}
|
|
91622
|
+
fromName: parsed.fromName ?? ""
|
|
91223
91623
|
};
|
|
91224
91624
|
}
|
|
91225
91625
|
function brokerEntryToSettings(entry) {
|
|
91226
91626
|
return {
|
|
91227
91627
|
clientId: entry.clientId,
|
|
91228
91628
|
clientSecret: entry.clientSecret,
|
|
91229
|
-
calendarIds: [...entry.calendarIds ?? parseCalendarFilter(entry.calendarFilter)],
|
|
91230
91629
|
fromAddress: entry.fromAddress,
|
|
91231
91630
|
fromName: entry.fromName
|
|
91232
91631
|
};
|
|
@@ -91277,18 +91676,6 @@ function migrateLegacyToBrokers(rawConfig, legacyOauth) {
|
|
|
91277
91676
|
didMigrate: true
|
|
91278
91677
|
};
|
|
91279
91678
|
}
|
|
91280
|
-
/**
|
|
91281
|
-
* The stamped calendar ids one broker imports: its own set, or — while the migration has not
|
|
91282
|
-
* reached it — the shared setting older versions wrote, so the move never changes what is imported.
|
|
91283
|
-
*/
|
|
91284
|
-
function calendarIdsOfEntry(entry, shared) {
|
|
91285
|
-
return new Set(entry?.calendarIds ?? shared);
|
|
91286
|
-
}
|
|
91287
|
-
function parseCalendarFilter(raw) {
|
|
91288
|
-
const trimmed = raw.trim();
|
|
91289
|
-
if (!trimmed) return /* @__PURE__ */ new Set();
|
|
91290
|
-
return new Set(trimmed.split(",").map((s) => s.trim()).filter((s) => s.length > 0));
|
|
91291
|
-
}
|
|
91292
91679
|
/** Local calendar id stamped as `brokerId:googleCalendarId`. */
|
|
91293
91680
|
function stampCalendarId(brokerId, googleCalendarId) {
|
|
91294
91681
|
return `${brokerId}:${googleCalendarId}`;
|
|
@@ -91303,7 +91690,7 @@ function parseStampedCalendarId(stamped) {
|
|
|
91303
91690
|
}
|
|
91304
91691
|
/**
|
|
91305
91692
|
* In-memory index over broker entries + oauth accounts. The addon owns
|
|
91306
|
-
* persistence; this class only allocates ids and
|
|
91693
|
+
* persistence; this class only allocates ids and tracks the OAuth state.
|
|
91307
91694
|
*/
|
|
91308
91695
|
var GoogleBrokerRegistry = class {
|
|
91309
91696
|
nextIdCounter = 1;
|
|
@@ -91370,7 +91757,6 @@ var GoogleBrokerRegistry = class {
|
|
|
91370
91757
|
const entry = GoogleBrokerEntrySchema.parse({
|
|
91371
91758
|
id,
|
|
91372
91759
|
name,
|
|
91373
|
-
calendarIds: [],
|
|
91374
91760
|
...fields
|
|
91375
91761
|
});
|
|
91376
91762
|
this.entries = [...this.entries, entry];
|
|
@@ -91384,7 +91770,6 @@ var GoogleBrokerRegistry = class {
|
|
|
91384
91770
|
const next = GoogleBrokerEntrySchema.parse({
|
|
91385
91771
|
id: prev.id,
|
|
91386
91772
|
name: prev.name,
|
|
91387
|
-
...prev.calendarIds !== void 0 ? { calendarIds: prev.calendarIds } : {},
|
|
91388
91773
|
...fields
|
|
91389
91774
|
});
|
|
91390
91775
|
this.entries = this.entries.map((e, i) => i === idx ? next : e);
|
|
@@ -91400,39 +91785,14 @@ var GoogleBrokerRegistry = class {
|
|
|
91400
91785
|
this.entries = entries.map((e) => GoogleBrokerEntrySchema.parse(e));
|
|
91401
91786
|
this.seedCounterFromEntries(this.entries);
|
|
91402
91787
|
}
|
|
91403
|
-
toBrokerInfo(entry, addonId) {
|
|
91404
|
-
const oauth = this.oauthById.get(entry.id);
|
|
91405
|
-
const connected = this.isConnected(entry.id);
|
|
91406
|
-
const reauth = this.needsReauth(entry.id);
|
|
91407
|
-
return {
|
|
91408
|
-
id: entry.id,
|
|
91409
|
-
addonId,
|
|
91410
|
-
name: entry.name,
|
|
91411
|
-
kind: GOOGLE_BROKER_KIND,
|
|
91412
|
-
status: connected ? "connected" : reauth ? "auth-failed" : "disconnected",
|
|
91413
|
-
info: {
|
|
91414
|
-
accountEmail: oauth?.accountEmail ?? "",
|
|
91415
|
-
hasClient: entry.clientId.length > 0
|
|
91416
|
-
},
|
|
91417
|
-
lastCheckedAt: connected ? Date.now() : null,
|
|
91418
|
-
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"
|
|
91419
|
-
};
|
|
91420
|
-
}
|
|
91421
|
-
listBrokerInfos(addonId, kind) {
|
|
91422
|
-
if (kind !== void 0 && kind !== "google") return [];
|
|
91423
|
-
return this.entries.map((e) => this.toBrokerInfo(e, addonId));
|
|
91424
|
-
}
|
|
91425
91788
|
size() {
|
|
91426
91789
|
return this.entries.length;
|
|
91427
91790
|
}
|
|
91428
91791
|
connectedSize() {
|
|
91429
91792
|
return this.entries.filter((e) => this.isConnected(e.id)).length;
|
|
91430
91793
|
}
|
|
91431
|
-
toConfig(
|
|
91432
|
-
return {
|
|
91433
|
-
brokers: [...this.entries],
|
|
91434
|
-
calendarIds: [...calendarIds]
|
|
91435
|
-
};
|
|
91794
|
+
toConfig() {
|
|
91795
|
+
return { brokers: [...this.entries] };
|
|
91436
91796
|
}
|
|
91437
91797
|
seedCounterFromEntries(entries) {
|
|
91438
91798
|
let maxSeen = 0;
|
|
@@ -91527,8 +91887,8 @@ function escapeHtml$1(s) {
|
|
|
91527
91887
|
//#region src/google-broker-settings-schema.ts
|
|
91528
91888
|
/**
|
|
91529
91889
|
* Per-kind broker creation/edit form for kind=`google`.
|
|
91530
|
-
* Account linking (Sign in) is driven by `
|
|
91531
|
-
*
|
|
91890
|
+
* Account linking (Sign in) is driven by the kind's `connectPath`
|
|
91891
|
+
* on the instances page — not a hard-coded Connect link in this form.
|
|
91532
91892
|
*/
|
|
91533
91893
|
function consoleLinksHtml() {
|
|
91534
91894
|
return [
|
|
@@ -91590,24 +91950,6 @@ function buildGoogleBrokerSettingsSchema(publicOrigin) {
|
|
|
91590
91950
|
showToggle: true
|
|
91591
91951
|
}]
|
|
91592
91952
|
},
|
|
91593
|
-
{
|
|
91594
|
-
id: "google-calendars-import",
|
|
91595
|
-
title: "Calendars to import",
|
|
91596
|
-
titleKey: "google-services:googleBrokerSettings.s_google-calendars-import.title",
|
|
91597
|
-
description: "Nothing selected = no calendars imported from this account. Options appear once the account is signed in.",
|
|
91598
|
-
descriptionKey: "google-services:googleBrokerSettings.s_google-calendars-import.description",
|
|
91599
|
-
columns: 1,
|
|
91600
|
-
fields: [{
|
|
91601
|
-
type: "multiselect",
|
|
91602
|
-
key: "calendarIds",
|
|
91603
|
-
label: "Calendars",
|
|
91604
|
-
labelKey: "google-services:googleBrokerSettings.s_google-calendars-import.calendarIds.label",
|
|
91605
|
-
options: [],
|
|
91606
|
-
optionsFrom: "_calendarCatalog",
|
|
91607
|
-
description: "The calendars of this Google account that CamStack imports.",
|
|
91608
|
-
descriptionKey: "google-services:googleBrokerSettings.s_google-calendars-import.calendarIds.description"
|
|
91609
|
-
}]
|
|
91610
|
-
},
|
|
91611
91953
|
{
|
|
91612
91954
|
id: "gmail-send",
|
|
91613
91955
|
title: "Gmail send",
|
|
@@ -91647,7 +91989,7 @@ function buildGoogleFeatureSettingsSchema(cap, publicOrigin) {
|
|
|
91647
91989
|
format: "html",
|
|
91648
91990
|
content: [
|
|
91649
91991
|
"<p>Link a Google account under Connectivity → <strong>Brokers</strong> ",
|
|
91650
|
-
"(Client ID / secret + Sign in)
|
|
91992
|
+
"(Client ID / secret + Sign in), then add a calendar under Connectivity → <strong>Calendars</strong>. ",
|
|
91651
91993
|
`OAuth redirect URI: <code>${redirect}</code>.</p>`
|
|
91652
91994
|
].join("")
|
|
91653
91995
|
}]
|
|
@@ -92127,11 +92469,76 @@ var googleBrokersEntryKind = defineEntryKind("brokers", {
|
|
|
92127
92469
|
clientSecret: GoogleBrokerEntrySchema.shape.clientSecret,
|
|
92128
92470
|
calendarFilter: GoogleBrokerEntrySchema.shape.calendarFilter,
|
|
92129
92471
|
fromAddress: GoogleBrokerEntrySchema.shape.fromAddress,
|
|
92130
|
-
fromName: GoogleBrokerEntrySchema.shape.fromName
|
|
92131
|
-
calendarIds: GoogleBrokerEntrySchema.shape.calendarIds
|
|
92472
|
+
fromName: GoogleBrokerEntrySchema.shape.fromName
|
|
92132
92473
|
}),
|
|
92133
92474
|
writeTrigger: "an operator adds or edits a Google OAuth broker"
|
|
92134
92475
|
});
|
|
92476
|
+
/**
|
|
92477
|
+
* One calendar an account imports (D1013): a record that LINKS to the account it belongs to and
|
|
92478
|
+
* names the Google calendar by its own id (`primary`, `name@group.calendar.google.com`). The id the
|
|
92479
|
+
* calendar answers to elsewhere stays `<accountId>:<calendarId>` (`stampCalendarId`).
|
|
92480
|
+
*/
|
|
92481
|
+
var googleCalendarsEntryKind = declareLinkKind({
|
|
92482
|
+
name: "calendars",
|
|
92483
|
+
title: "Google calendars",
|
|
92484
|
+
writeTrigger: "an operator adds or removes a calendar an account imports",
|
|
92485
|
+
links: { accountId: {
|
|
92486
|
+
cap: "broker",
|
|
92487
|
+
kind: GOOGLE_BROKER_KIND
|
|
92488
|
+
} },
|
|
92489
|
+
fields: { calendarId: string().default("") }
|
|
92490
|
+
});
|
|
92491
|
+
//#endregion
|
|
92492
|
+
//#region src/google-calendar-instances.ts
|
|
92493
|
+
/**
|
|
92494
|
+
* The calendars a Google account imports as `integration-instances` (D1013): one `calendars`
|
|
92495
|
+
* record per (account, calendar), linking to its account through the link primitive. The calendar
|
|
92496
|
+
* source reads the records; nothing is stored on the account.
|
|
92497
|
+
*/
|
|
92498
|
+
var GOOGLE_CALENDAR_INSTANCE_KIND = "calendar";
|
|
92499
|
+
/** The stamped ids each account imports, from the calendar records. */
|
|
92500
|
+
function selectedStampedIds(rows) {
|
|
92501
|
+
const out = /* @__PURE__ */ new Map();
|
|
92502
|
+
for (const row of rows) {
|
|
92503
|
+
const { accountId, calendarId } = row.body;
|
|
92504
|
+
if (!row.enabled || accountId === "" || calendarId === "") continue;
|
|
92505
|
+
const set = out.get(accountId) ?? /* @__PURE__ */ new Set();
|
|
92506
|
+
set.add(stampCalendarId(accountId, calendarId));
|
|
92507
|
+
out.set(accountId, set);
|
|
92508
|
+
}
|
|
92509
|
+
return out;
|
|
92510
|
+
}
|
|
92511
|
+
function buildGoogleCalendarInstances(records, deps) {
|
|
92512
|
+
return buildLinkedInstances(records, {
|
|
92513
|
+
kind: googleCalendarsEntryKind,
|
|
92514
|
+
instanceKind: GOOGLE_CALENDAR_INSTANCE_KIND,
|
|
92515
|
+
description: {
|
|
92516
|
+
role: "services",
|
|
92517
|
+
instanceMode: "multiple",
|
|
92518
|
+
kind: GOOGLE_CALENDAR_INSTANCE_KIND,
|
|
92519
|
+
canTest: false
|
|
92520
|
+
},
|
|
92521
|
+
labels: { accountId: {
|
|
92522
|
+
label: "Google account",
|
|
92523
|
+
description: "The account this calendar belongs to."
|
|
92524
|
+
} },
|
|
92525
|
+
alsoConfigured: (body) => body.calendarId !== "",
|
|
92526
|
+
dynamicSections: async (accountId) => [{
|
|
92527
|
+
id: "google-calendar-pick",
|
|
92528
|
+
title: "Calendar",
|
|
92529
|
+
columns: 1,
|
|
92530
|
+
fields: [{
|
|
92531
|
+
type: "select",
|
|
92532
|
+
key: "calendarId",
|
|
92533
|
+
label: "Calendar",
|
|
92534
|
+
options: [...await deps.catalog(accountId)],
|
|
92535
|
+
description: "The calendars of that account. Sign the account in to see them."
|
|
92536
|
+
}]
|
|
92537
|
+
}],
|
|
92538
|
+
mintId: () => `cal_${randomBytes(6).toString("hex")}`,
|
|
92539
|
+
onChanged: deps.onChanged
|
|
92540
|
+
});
|
|
92541
|
+
}
|
|
92135
92542
|
//#endregion
|
|
92136
92543
|
//#region src/google-instances.ts
|
|
92137
92544
|
/**
|
|
@@ -92151,6 +92558,17 @@ function asTestResult(r) {
|
|
|
92151
92558
|
error: r.error ?? "Google rejected the check"
|
|
92152
92559
|
};
|
|
92153
92560
|
}
|
|
92561
|
+
/** The `account` kind of the composed provider: where the OAuth sign-in starts and ends. */
|
|
92562
|
+
function googleAccountKind(deps) {
|
|
92563
|
+
return {
|
|
92564
|
+
id: GOOGLE_BROKER_KIND,
|
|
92565
|
+
label: GOOGLE_BROKER_KIND_LABEL,
|
|
92566
|
+
functionCap: "broker",
|
|
92567
|
+
brokerKind: GOOGLE_BROKER_KIND,
|
|
92568
|
+
connectPath: deps.connectPath,
|
|
92569
|
+
disconnectPath: deps.disconnectPath
|
|
92570
|
+
};
|
|
92571
|
+
}
|
|
92154
92572
|
function buildGoogleInstances(records, deps) {
|
|
92155
92573
|
return new RecordIntegrationInstances(records, googleBrokersEntryKind, {
|
|
92156
92574
|
description: {
|
|
@@ -92158,29 +92576,16 @@ function buildGoogleInstances(records, deps) {
|
|
|
92158
92576
|
instanceMode: "multiple",
|
|
92159
92577
|
kind: "account",
|
|
92160
92578
|
canTest: true,
|
|
92161
|
-
kinds: [{
|
|
92162
|
-
id: GOOGLE_BROKER_KIND,
|
|
92163
|
-
label: GOOGLE_BROKER_KIND_LABEL,
|
|
92164
|
-
connectPath: deps.connectPath,
|
|
92165
|
-
disconnectPath: deps.disconnectPath
|
|
92166
|
-
}],
|
|
92167
92579
|
allowRestoreId: true
|
|
92168
92580
|
},
|
|
92169
|
-
formSchema: () =>
|
|
92170
|
-
const full = buildGoogleBrokerSettingsSchema(deps.publicOrigin());
|
|
92171
|
-
return {
|
|
92172
|
-
...full,
|
|
92173
|
-
sections: full.sections.filter((s) => s.id !== "google-calendars-import")
|
|
92174
|
-
};
|
|
92175
|
-
},
|
|
92581
|
+
formSchema: () => buildGoogleBrokerSettingsSchema(deps.publicOrigin()),
|
|
92176
92582
|
initialBody: (name) => ({
|
|
92177
92583
|
name,
|
|
92178
92584
|
clientId: "",
|
|
92179
92585
|
clientSecret: "",
|
|
92180
92586
|
calendarFilter: "",
|
|
92181
92587
|
fromAddress: "",
|
|
92182
|
-
fromName: ""
|
|
92183
|
-
calendarIds: []
|
|
92588
|
+
fromName: ""
|
|
92184
92589
|
}),
|
|
92185
92590
|
mintId: deps.mintId,
|
|
92186
92591
|
kindOf: () => GOOGLE_BROKER_KIND,
|
|
@@ -92299,42 +92704,66 @@ async function planDropSharedCalendarIds(ports) {
|
|
|
92299
92704
|
} })
|
|
92300
92705
|
}] };
|
|
92301
92706
|
}
|
|
92302
|
-
//#endregion
|
|
92303
|
-
//#region src/migrations/index.ts
|
|
92304
92707
|
/** The `google-services` catalogue (D987): offered to the engine when the addon initialises. */
|
|
92305
|
-
var ADDON_MIGRATIONS = [
|
|
92306
|
-
|
|
92307
|
-
|
|
92308
|
-
|
|
92309
|
-
|
|
92310
|
-
|
|
92311
|
-
|
|
92312
|
-
|
|
92313
|
-
|
|
92314
|
-
|
|
92315
|
-
|
|
92316
|
-
|
|
92317
|
-
|
|
92318
|
-
|
|
92319
|
-
|
|
92320
|
-
|
|
92321
|
-
|
|
92322
|
-
|
|
92323
|
-
|
|
92324
|
-
|
|
92325
|
-
|
|
92326
|
-
|
|
92327
|
-
|
|
92328
|
-
|
|
92329
|
-
|
|
92330
|
-
|
|
92331
|
-
|
|
92332
|
-
|
|
92333
|
-
|
|
92334
|
-
|
|
92335
|
-
}
|
|
92708
|
+
var ADDON_MIGRATIONS = [
|
|
92709
|
+
{
|
|
92710
|
+
meta: {
|
|
92711
|
+
id: "google-services/2026-11-03-calendar-ids-to-brokers",
|
|
92712
|
+
owner: "google-services",
|
|
92713
|
+
level: "addon-state",
|
|
92714
|
+
seq: 1,
|
|
92715
|
+
dependsOn: [],
|
|
92716
|
+
store: "settings",
|
|
92717
|
+
scope: "cluster",
|
|
92718
|
+
onFailure: "tolerate",
|
|
92719
|
+
bodyKind: "procedure",
|
|
92720
|
+
description: "Copy the shared calendar set to every Google broker record that has none of its own",
|
|
92721
|
+
fixtureMark: "the client secret marker of a broker record the migration does not know"
|
|
92722
|
+
},
|
|
92723
|
+
procedure: copyCalendarIdsToBrokers
|
|
92724
|
+
},
|
|
92725
|
+
{
|
|
92726
|
+
meta: {
|
|
92727
|
+
id: "google-services/2026-11-03-drop-shared-calendar-ids",
|
|
92728
|
+
owner: "google-services",
|
|
92729
|
+
level: "addon-state",
|
|
92730
|
+
seq: 2,
|
|
92731
|
+
dependsOn: ["google-services/2026-11-03-calendar-ids-to-brokers"],
|
|
92732
|
+
store: "settings",
|
|
92733
|
+
scope: "cluster",
|
|
92734
|
+
onFailure: "tolerate",
|
|
92735
|
+
bodyKind: "plan",
|
|
92736
|
+
description: "Delete the shared calendar set once every broker shows its own",
|
|
92737
|
+
fixtureMark: "the shared set parked when a broker holds a different one"
|
|
92738
|
+
},
|
|
92739
|
+
plan: planDropSharedCalendarIds
|
|
92740
|
+
},
|
|
92741
|
+
{
|
|
92742
|
+
meta: {
|
|
92743
|
+
id: "google-services/2026-11-07-calendar-ids-to-calendar-records",
|
|
92744
|
+
owner: "google-services",
|
|
92745
|
+
level: "addon-state",
|
|
92746
|
+
seq: 3,
|
|
92747
|
+
dependsOn: ["google-services/2026-11-03-drop-shared-calendar-ids"],
|
|
92748
|
+
store: "settings",
|
|
92749
|
+
scope: "cluster",
|
|
92750
|
+
onFailure: "tolerate",
|
|
92751
|
+
bodyKind: "procedure",
|
|
92752
|
+
description: "Write one calendar record per calendar an account imports (linked to the account), read each back, then clear the calendar array of the account row",
|
|
92753
|
+
fixtureMark: "the client secret marker of the account that keeps its calendars"
|
|
92754
|
+
},
|
|
92755
|
+
procedure: (ports) => moveCalendarIdsToRecords(ports, { calendarIdOf: (accountId, entry) => {
|
|
92756
|
+
const parsed = parseStampedCalendarId(entry);
|
|
92757
|
+
return parsed?.brokerId === accountId ? parsed.googleCalendarId : null;
|
|
92758
|
+
} })
|
|
92759
|
+
}
|
|
92760
|
+
];
|
|
92336
92761
|
//#endregion
|
|
92337
92762
|
//#region src/migrations/ports.ts
|
|
92763
|
+
function listOf(value) {
|
|
92764
|
+
if (!Array.isArray(value)) return void 0;
|
|
92765
|
+
return value.filter((item) => typeof item === "string");
|
|
92766
|
+
}
|
|
92338
92767
|
/** The migration's ports over the `brokers` record kind and the addon's raw settings read. */
|
|
92339
92768
|
function calendarIdsPortsOver(kind, readStored) {
|
|
92340
92769
|
return {
|
|
@@ -92342,18 +92771,43 @@ function calendarIdsPortsOver(kind, readStored) {
|
|
|
92342
92771
|
listBrokers: async () => {
|
|
92343
92772
|
return (await kind.query({ limit: 1e3 })).records.map((record) => ({
|
|
92344
92773
|
id: record.id,
|
|
92345
|
-
calendarIds: record.data
|
|
92774
|
+
calendarIds: listOf(record.data["calendarIds"])
|
|
92346
92775
|
}));
|
|
92347
92776
|
},
|
|
92348
92777
|
setBrokerCalendarIds: async (id, ids) => {
|
|
92349
92778
|
const row = await kind.get(id);
|
|
92350
92779
|
if (row === null) return false;
|
|
92351
|
-
if (row.data
|
|
92780
|
+
if (row.data["calendarIds"] !== void 0) return true;
|
|
92352
92781
|
await kind.patch(id, { calendarIds: [...ids] });
|
|
92353
92782
|
return true;
|
|
92354
92783
|
}
|
|
92355
92784
|
};
|
|
92356
92785
|
}
|
|
92786
|
+
/** The ports of the calendars move: the raw `brokers` rows and the `calendars` records. */
|
|
92787
|
+
function calendarRecordPortsOver(deps) {
|
|
92788
|
+
return {
|
|
92789
|
+
warn: deps.warn,
|
|
92790
|
+
listAccounts: async () => {
|
|
92791
|
+
return (await deps.brokers.query({ limit: 1e3 })).records.map((record) => ({
|
|
92792
|
+
id: record.id,
|
|
92793
|
+
calendarIds: record.data["calendarIds"]
|
|
92794
|
+
}));
|
|
92795
|
+
},
|
|
92796
|
+
readCalendar: async (recordId) => {
|
|
92797
|
+
const row = await deps.calendars.get(recordId);
|
|
92798
|
+
return row === null ? null : row.data;
|
|
92799
|
+
},
|
|
92800
|
+
putCalendar: async (recordId, body) => {
|
|
92801
|
+
await deps.calendars.put({
|
|
92802
|
+
id: recordId,
|
|
92803
|
+
data: body
|
|
92804
|
+
}, { ifRev: 0 });
|
|
92805
|
+
},
|
|
92806
|
+
clearCalendarIds: async (accountId) => {
|
|
92807
|
+
await deps.brokers.patch(accountId, { calendarIds: null });
|
|
92808
|
+
}
|
|
92809
|
+
};
|
|
92810
|
+
}
|
|
92357
92811
|
//#endregion
|
|
92358
92812
|
//#region src/google-broker-store.ts
|
|
92359
92813
|
function rowToEntry(id, data) {
|
|
@@ -92392,15 +92846,14 @@ var GoogleBrokerStore = class GoogleBrokerStore {
|
|
|
92392
92846
|
const nextIds = new Set(entries.map((e) => e.id));
|
|
92393
92847
|
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
92394
92848
|
for (const entry of entries) {
|
|
92395
|
-
const { id, name, clientId, clientSecret, calendarFilter, fromAddress, fromName
|
|
92849
|
+
const { id, name, clientId, clientSecret, calendarFilter, fromAddress, fromName } = entry;
|
|
92396
92850
|
const body = {
|
|
92397
92851
|
name,
|
|
92398
92852
|
clientId,
|
|
92399
92853
|
clientSecret,
|
|
92400
92854
|
calendarFilter,
|
|
92401
92855
|
fromAddress,
|
|
92402
|
-
fromName
|
|
92403
|
-
...calendarIds !== void 0 ? { calendarIds } : {}
|
|
92856
|
+
fromName
|
|
92404
92857
|
};
|
|
92405
92858
|
const parsed = googleBrokersEntryKind.schema.safeParse(body);
|
|
92406
92859
|
if (!parsed.success) throw new Error(`invalid Google broker '${id}': ${parsed.error.message}`);
|
|
@@ -92446,6 +92899,9 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92446
92899
|
registry = new GoogleBrokerRegistry();
|
|
92447
92900
|
brokerStore = null;
|
|
92448
92901
|
instances = null;
|
|
92902
|
+
calendarInstances = null;
|
|
92903
|
+
/** The stamped calendar ids each account imports, from the `calendars` records. */
|
|
92904
|
+
calendarSelection = /* @__PURE__ */ new Map();
|
|
92449
92905
|
activeBrokers = [];
|
|
92450
92906
|
/** CSRF state → { brokerId, issuedAt } for the in-flight OAuth consents. */
|
|
92451
92907
|
pendingStates = /* @__PURE__ */ new Map();
|
|
@@ -92491,15 +92947,23 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92491
92947
|
}
|
|
92492
92948
|
const records = this.ctx.records;
|
|
92493
92949
|
if (records === void 0) throw new Error("google-services: ctx.records is required (hub-only addon)");
|
|
92494
|
-
await records.declare({
|
|
92950
|
+
await records.declare({
|
|
92951
|
+
brokers: googleBrokersEntryKind,
|
|
92952
|
+
calendars: googleCalendarsEntryKind
|
|
92953
|
+
});
|
|
92495
92954
|
this.brokerStore = GoogleBrokerStore.of(records);
|
|
92496
92955
|
this.instances = this.buildInstances(records);
|
|
92956
|
+
this.calendarInstances = buildGoogleCalendarInstances(records, {
|
|
92957
|
+
catalog: (accountId) => this.loadCalendarCatalog(accountId),
|
|
92958
|
+
onChanged: () => this.refreshCalendarSelection()
|
|
92959
|
+
});
|
|
92497
92960
|
this.activeBrokers = await this.loadPersistedBrokers();
|
|
92498
92961
|
if ((await this.brokerStore.listResolved()).length === 0 && this.config.brokers.length > 0) {
|
|
92499
92962
|
await this.brokerStore.replaceAll(this.config.brokers);
|
|
92500
92963
|
this.activeBrokers = await this.loadPersistedBrokers();
|
|
92501
92964
|
}
|
|
92502
92965
|
await this.migrateCalendarIds(records);
|
|
92966
|
+
await this.refreshCalendarSelection();
|
|
92503
92967
|
this.registry.seedFrom(this.activeBrokers, oauthAccounts.accounts);
|
|
92504
92968
|
await this.refreshPublicOrigin();
|
|
92505
92969
|
const calendarProvider = createGoogleCalendarSource({
|
|
@@ -92509,7 +92973,7 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92509
92973
|
connected: this.registry.isConnected(entry.id),
|
|
92510
92974
|
api: createGoogleCalendarApi(() => this.ensureAccessToken(entry.id))
|
|
92511
92975
|
})),
|
|
92512
|
-
selectedCalendarIds: (brokerId) => this.
|
|
92976
|
+
selectedCalendarIds: (brokerId) => this.calendarSelection.get(brokerId) ?? /* @__PURE__ */ new Set()
|
|
92513
92977
|
});
|
|
92514
92978
|
const smtpProvider = createGmailSmtpProvider({ accounts: () => this.registry.listEntries().map((entry) => {
|
|
92515
92979
|
const oauth = this.registry.getOauth(entry.id);
|
|
@@ -92558,7 +93022,7 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92558
93022
|
},
|
|
92559
93023
|
{
|
|
92560
93024
|
capability: integrationInstancesCapability,
|
|
92561
|
-
provider: this.
|
|
93025
|
+
provider: this.buildInstancesProvider()
|
|
92562
93026
|
},
|
|
92563
93027
|
{
|
|
92564
93028
|
capability: calendarSourceCapability,
|
|
@@ -92583,9 +93047,43 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92583
93047
|
if (this.instances === null) throw new Error("google-services: instances used before initialize");
|
|
92584
93048
|
return this.instances;
|
|
92585
93049
|
}
|
|
93050
|
+
/** One provider over the two record kinds: the Google accounts and the calendars they import. */
|
|
93051
|
+
buildInstancesProvider() {
|
|
93052
|
+
const calendars = this.calendarInstances;
|
|
93053
|
+
if (calendars === null) throw new Error("google-services: instances used before initialize");
|
|
93054
|
+
return composeInstanceKinds([{
|
|
93055
|
+
kind: {
|
|
93056
|
+
...googleAccountKind({
|
|
93057
|
+
connectPath: `/addon/${ADDON_ID}${START_PATH}?brokerId={{brokerId}}`,
|
|
93058
|
+
disconnectPath: `/addon/${ADDON_ID}${DISCONNECT_PATH}?brokerId={{brokerId}}`
|
|
93059
|
+
}),
|
|
93060
|
+
functionCap: "broker"
|
|
93061
|
+
},
|
|
93062
|
+
provider: this.requireInstances().toProvider()
|
|
93063
|
+
}, {
|
|
93064
|
+
kind: {
|
|
93065
|
+
id: GOOGLE_CALENDAR_INSTANCE_KIND,
|
|
93066
|
+
label: "Google calendar",
|
|
93067
|
+
functionCap: "calendar-source",
|
|
93068
|
+
role: "services"
|
|
93069
|
+
},
|
|
93070
|
+
provider: calendars.toProvider()
|
|
93071
|
+
}], {
|
|
93072
|
+
role: "services",
|
|
93073
|
+
instanceMode: "multiple",
|
|
93074
|
+
kind: "account",
|
|
93075
|
+
canTest: true,
|
|
93076
|
+
allowRestoreId: true
|
|
93077
|
+
});
|
|
93078
|
+
}
|
|
93079
|
+
/** Re-read which calendars each account imports from the records. */
|
|
93080
|
+
async refreshCalendarSelection() {
|
|
93081
|
+
const calendars = this.calendarInstances;
|
|
93082
|
+
if (calendars === null) return;
|
|
93083
|
+
this.calendarSelection = selectedStampedIds(await calendars.listResolved());
|
|
93084
|
+
}
|
|
92586
93085
|
/** The accounts as `integration-instances`, over the same `brokers` records (planning#408 P3). */
|
|
92587
93086
|
buildInstances(records) {
|
|
92588
|
-
const brokerProvider = this.buildBrokerProvider();
|
|
92589
93087
|
return buildGoogleInstances(records, {
|
|
92590
93088
|
connectPath: `/addon/${ADDON_ID}${START_PATH}?brokerId={{brokerId}}`,
|
|
92591
93089
|
disconnectPath: `/addon/${ADDON_ID}${DISCONNECT_PATH}?brokerId={{brokerId}}`,
|
|
@@ -92598,169 +93096,29 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92598
93096
|
this.registry.seedFrom(this.activeBrokers, accounts);
|
|
92599
93097
|
await this.persistOauthAccounts();
|
|
92600
93098
|
},
|
|
92601
|
-
testSaved:
|
|
92602
|
-
testClient:
|
|
92603
|
-
kind: GOOGLE_BROKER_KIND,
|
|
92604
|
-
settings: {
|
|
92605
|
-
clientId,
|
|
92606
|
-
clientSecret
|
|
92607
|
-
}
|
|
92608
|
-
})
|
|
93099
|
+
testSaved: (id) => this.probeSavedAccount(id),
|
|
93100
|
+
testClient: (clientId, clientSecret) => this.probeOauthClient(clientId, clientSecret)
|
|
92609
93101
|
});
|
|
92610
93102
|
}
|
|
93103
|
+
/**
|
|
93104
|
+
* The `broker` cap is the bus only (D1013): the accounts are the `integration-instances`
|
|
93105
|
+
* provider; calendar and mail go through their own caps, so publish and subscribe are refused.
|
|
93106
|
+
*/
|
|
92611
93107
|
buildBrokerProvider() {
|
|
92612
|
-
const ownerAddonId = this.ctx.id;
|
|
92613
|
-
const owns = (id) => this.registry.getEntry(id) !== null;
|
|
92614
93108
|
const notSupported = async () => {
|
|
92615
93109
|
throw new Error("google-services broker: publish/subscribe/getState are not supported — use calendar-source / smtp-provider");
|
|
92616
93110
|
};
|
|
92617
93111
|
return {
|
|
92618
|
-
list: async ({ kind }) => this.registry.listBrokerInfos(ownerAddonId, kind),
|
|
92619
|
-
get: async ({ id }) => {
|
|
92620
|
-
const entry = this.registry.getEntry(id);
|
|
92621
|
-
return entry ? this.registry.toBrokerInfo(entry, ownerAddonId) : null;
|
|
92622
|
-
},
|
|
92623
|
-
listProviders: async () => [{
|
|
92624
|
-
addonId: ownerAddonId,
|
|
92625
|
-
kinds: [{
|
|
92626
|
-
kind: GOOGLE_BROKER_KIND,
|
|
92627
|
-
label: GOOGLE_BROKER_KIND_LABEL,
|
|
92628
|
-
interactiveConnectPath: `/addon/${ADDON_ID}${START_PATH}?brokerId={{brokerId}}`,
|
|
92629
|
-
interactiveDisconnectPath: `/addon/${ADDON_ID}${DISCONNECT_PATH}?brokerId={{brokerId}}`
|
|
92630
|
-
}]
|
|
92631
|
-
}],
|
|
92632
|
-
add: async ({ kind, name, settings, id }) => {
|
|
92633
|
-
if (kind !== "google") throw new Error(`google-services: only kind '${GOOGLE_BROKER_KIND}' is handled here (got '${kind}')`);
|
|
92634
|
-
const entry = this.registry.createEntry(name, settings, id !== void 0 ? { id } : {});
|
|
92635
|
-
await this.persistBrokers();
|
|
92636
|
-
return { id: entry.id };
|
|
92637
|
-
},
|
|
92638
|
-
remove: async ({ id }) => {
|
|
92639
|
-
if (!owns(id)) return;
|
|
92640
|
-
this.registry.removeEntry(id);
|
|
92641
|
-
await this.persistBrokers();
|
|
92642
|
-
await this.persistOauthAccounts();
|
|
92643
|
-
},
|
|
92644
|
-
testConnection: async ({ id }) => {
|
|
92645
|
-
if (!owns(id)) return {
|
|
92646
|
-
ok: false,
|
|
92647
|
-
error: "unknown broker"
|
|
92648
|
-
};
|
|
92649
|
-
const entry = this.registry.getEntry(id);
|
|
92650
|
-
if (entry === null) return {
|
|
92651
|
-
ok: false,
|
|
92652
|
-
error: "unknown broker"
|
|
92653
|
-
};
|
|
92654
|
-
if (!entry.clientId || !entry.clientSecret) return {
|
|
92655
|
-
ok: false,
|
|
92656
|
-
error: "Configure Client ID and Client secret first"
|
|
92657
|
-
};
|
|
92658
|
-
let redirectUri;
|
|
92659
|
-
try {
|
|
92660
|
-
redirectUri = await this.resolveRedirectUri();
|
|
92661
|
-
} catch (err) {
|
|
92662
|
-
return {
|
|
92663
|
-
ok: false,
|
|
92664
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92665
|
-
};
|
|
92666
|
-
}
|
|
92667
|
-
if (!this.registry.isConnected(id)) return probeGoogleOauthClient({
|
|
92668
|
-
clientId: entry.clientId,
|
|
92669
|
-
clientSecret: entry.clientSecret,
|
|
92670
|
-
redirectUri
|
|
92671
|
-
});
|
|
92672
|
-
try {
|
|
92673
|
-
const started = Date.now();
|
|
92674
|
-
const token = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92675
|
-
if (token.trim().length === 0) return {
|
|
92676
|
-
ok: false,
|
|
92677
|
-
error: "No access token after refresh — Sign out and Sign in again"
|
|
92678
|
-
};
|
|
92679
|
-
let res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${token}` } });
|
|
92680
|
-
if (res.status === 401) {
|
|
92681
|
-
const retryToken = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
92682
|
-
res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${retryToken}` } });
|
|
92683
|
-
}
|
|
92684
|
-
if (!res.ok) {
|
|
92685
|
-
const text = await res.text();
|
|
92686
|
-
return {
|
|
92687
|
-
ok: false,
|
|
92688
|
-
error: `Google Calendar probe failed (${res.status}): ${text.slice(0, 200)}`
|
|
92689
|
-
};
|
|
92690
|
-
}
|
|
92691
|
-
const email = await this.fetchAccountEmail(token);
|
|
92692
|
-
if (email.length > 0) {
|
|
92693
|
-
const oauth = this.registry.getOauth(id);
|
|
92694
|
-
if (oauth !== null && oauth.accountEmail !== email) {
|
|
92695
|
-
this.registry.setOauth({
|
|
92696
|
-
...oauth,
|
|
92697
|
-
accountEmail: email
|
|
92698
|
-
});
|
|
92699
|
-
await this.persistOauthAccounts();
|
|
92700
|
-
}
|
|
92701
|
-
}
|
|
92702
|
-
return {
|
|
92703
|
-
ok: true,
|
|
92704
|
-
latencyMs: Date.now() - started
|
|
92705
|
-
};
|
|
92706
|
-
} catch (err) {
|
|
92707
|
-
return {
|
|
92708
|
-
ok: false,
|
|
92709
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92710
|
-
};
|
|
92711
|
-
}
|
|
92712
|
-
},
|
|
92713
|
-
getSettings: async ({ id }) => {
|
|
92714
|
-
const entry = this.registry.getEntry(id);
|
|
92715
|
-
if (entry === null) return null;
|
|
92716
|
-
return {
|
|
92717
|
-
...brokerEntryToSettings(entry),
|
|
92718
|
-
_calendarCatalog: await this.loadStampedCalendarCatalog(id)
|
|
92719
|
-
};
|
|
92720
|
-
},
|
|
92721
|
-
setSettings: async ({ id, settings }) => {
|
|
92722
|
-
if (!owns(id)) return;
|
|
92723
|
-
this.registry.updateEntry(id, settings);
|
|
92724
|
-
await this.persistBrokers();
|
|
92725
|
-
},
|
|
92726
93112
|
getBrokerConfig: async ({ id }) => {
|
|
92727
93113
|
const entry = this.registry.getEntry(id);
|
|
92728
93114
|
if (entry === null) return null;
|
|
92729
93115
|
const oauth = this.registry.getOauth(id);
|
|
92730
93116
|
return {
|
|
92731
93117
|
...brokerEntryToSettings(entry),
|
|
92732
|
-
_calendarCatalog: await this.loadStampedCalendarCatalog(id),
|
|
92733
93118
|
accountEmail: oauth?.accountEmail ?? "",
|
|
92734
93119
|
connected: this.registry.isConnected(id)
|
|
92735
93120
|
};
|
|
92736
93121
|
},
|
|
92737
|
-
getSettingsSchema: async ({ kind }) => {
|
|
92738
|
-
if (kind !== "google") return null;
|
|
92739
|
-
return buildGoogleBrokerSettingsSchema(this.publicOrigin);
|
|
92740
|
-
},
|
|
92741
|
-
testSettings: async ({ kind, settings }) => {
|
|
92742
|
-
if (kind !== "google") return {
|
|
92743
|
-
ok: false,
|
|
92744
|
-
error: `unsupported kind: ${kind}`
|
|
92745
|
-
};
|
|
92746
|
-
try {
|
|
92747
|
-
const parsed = object({
|
|
92748
|
-
clientId: string().min(1),
|
|
92749
|
-
clientSecret: string().min(1).meta({ secret: true })
|
|
92750
|
-
}).parse(settings);
|
|
92751
|
-
const redirectUri = await this.resolveRedirectUri();
|
|
92752
|
-
return probeGoogleOauthClient({
|
|
92753
|
-
clientId: parsed.clientId,
|
|
92754
|
-
clientSecret: parsed.clientSecret,
|
|
92755
|
-
redirectUri
|
|
92756
|
-
});
|
|
92757
|
-
} catch (err) {
|
|
92758
|
-
return {
|
|
92759
|
-
ok: false,
|
|
92760
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92761
|
-
};
|
|
92762
|
-
}
|
|
92763
|
-
},
|
|
92764
93122
|
publish: notSupported,
|
|
92765
93123
|
subscribe: notSupported,
|
|
92766
93124
|
unsubscribe: notSupported,
|
|
@@ -92771,6 +93129,95 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92771
93129
|
})
|
|
92772
93130
|
};
|
|
92773
93131
|
}
|
|
93132
|
+
/** Probe a saved account: the OAuth client, then (when signed in) a Calendar call. */
|
|
93133
|
+
async probeSavedAccount(id) {
|
|
93134
|
+
const entry = this.registry.getEntry(id);
|
|
93135
|
+
if (entry === null) return {
|
|
93136
|
+
ok: false,
|
|
93137
|
+
error: "unknown broker"
|
|
93138
|
+
};
|
|
93139
|
+
if (!entry.clientId || !entry.clientSecret) return {
|
|
93140
|
+
ok: false,
|
|
93141
|
+
error: "Configure Client ID and Client secret first"
|
|
93142
|
+
};
|
|
93143
|
+
let redirectUri;
|
|
93144
|
+
try {
|
|
93145
|
+
redirectUri = await this.resolveRedirectUri();
|
|
93146
|
+
} catch (err) {
|
|
93147
|
+
return {
|
|
93148
|
+
ok: false,
|
|
93149
|
+
error: err instanceof Error ? err.message : String(err)
|
|
93150
|
+
};
|
|
93151
|
+
}
|
|
93152
|
+
if (!this.registry.isConnected(id)) return probeGoogleOauthClient({
|
|
93153
|
+
clientId: entry.clientId,
|
|
93154
|
+
clientSecret: entry.clientSecret,
|
|
93155
|
+
redirectUri
|
|
93156
|
+
});
|
|
93157
|
+
try {
|
|
93158
|
+
const started = Date.now();
|
|
93159
|
+
const token = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
93160
|
+
if (token.trim().length === 0) return {
|
|
93161
|
+
ok: false,
|
|
93162
|
+
error: "No access token after refresh — Sign out and Sign in again"
|
|
93163
|
+
};
|
|
93164
|
+
let res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${token}` } });
|
|
93165
|
+
if (res.status === 401) {
|
|
93166
|
+
const retryToken = await this.ensureAccessToken(id, { forceRefresh: true });
|
|
93167
|
+
res = await fetch(GOOGLE_CALENDAR_LIST_URL, { headers: { Authorization: `Bearer ${retryToken}` } });
|
|
93168
|
+
}
|
|
93169
|
+
if (!res.ok) {
|
|
93170
|
+
const text = await res.text();
|
|
93171
|
+
return {
|
|
93172
|
+
ok: false,
|
|
93173
|
+
error: `Google Calendar probe failed (${res.status}): ${text.slice(0, 200)}`
|
|
93174
|
+
};
|
|
93175
|
+
}
|
|
93176
|
+
const email = await this.fetchAccountEmail(token);
|
|
93177
|
+
if (email.length > 0) {
|
|
93178
|
+
const oauth = this.registry.getOauth(id);
|
|
93179
|
+
if (oauth !== null && oauth.accountEmail !== email) {
|
|
93180
|
+
this.registry.setOauth({
|
|
93181
|
+
...oauth,
|
|
93182
|
+
accountEmail: email
|
|
93183
|
+
});
|
|
93184
|
+
await this.persistOauthAccounts();
|
|
93185
|
+
}
|
|
93186
|
+
}
|
|
93187
|
+
return {
|
|
93188
|
+
ok: true,
|
|
93189
|
+
latencyMs: Date.now() - started
|
|
93190
|
+
};
|
|
93191
|
+
} catch (err) {
|
|
93192
|
+
return {
|
|
93193
|
+
ok: false,
|
|
93194
|
+
error: err instanceof Error ? err.message : String(err)
|
|
93195
|
+
};
|
|
93196
|
+
}
|
|
93197
|
+
}
|
|
93198
|
+
/** Probe an OAuth client that is not saved yet. */
|
|
93199
|
+
async probeOauthClient(clientId, clientSecret) {
|
|
93200
|
+
try {
|
|
93201
|
+
const parsed = object({
|
|
93202
|
+
clientId: string().min(1),
|
|
93203
|
+
clientSecret: string().min(1).meta({ secret: true })
|
|
93204
|
+
}).parse({
|
|
93205
|
+
clientId,
|
|
93206
|
+
clientSecret
|
|
93207
|
+
});
|
|
93208
|
+
const redirectUri = await this.resolveRedirectUri();
|
|
93209
|
+
return probeGoogleOauthClient({
|
|
93210
|
+
clientId: parsed.clientId,
|
|
93211
|
+
clientSecret: parsed.clientSecret,
|
|
93212
|
+
redirectUri
|
|
93213
|
+
});
|
|
93214
|
+
} catch (err) {
|
|
93215
|
+
return {
|
|
93216
|
+
ok: false,
|
|
93217
|
+
error: err instanceof Error ? err.message : String(err)
|
|
93218
|
+
};
|
|
93219
|
+
}
|
|
93220
|
+
}
|
|
92774
93221
|
async handleStart(req, reply) {
|
|
92775
93222
|
const brokerIdRaw = req.query["brokerId"];
|
|
92776
93223
|
const brokerId = typeof brokerIdRaw === "string" ? brokerIdRaw.trim() : "";
|
|
@@ -92936,11 +93383,25 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92936
93383
|
for (const [k, v] of this.pendingStates) if (v.issuedAt < cutoff) this.pendingStates.delete(k);
|
|
92937
93384
|
}
|
|
92938
93385
|
/**
|
|
92939
|
-
* The shared calendar set becomes each broker's own (D985, D987)
|
|
92940
|
-
*
|
|
93386
|
+
* The shared calendar set becomes each broker's own (D985, D987), then each broker's set becomes
|
|
93387
|
+
* `calendars` records linked to the account (D1013). Brokers are reloaded once a migration
|
|
93388
|
+
* landed, so the registry is seeded with what it wrote.
|
|
92941
93389
|
*/
|
|
92942
93390
|
async migrateCalendarIds(records) {
|
|
92943
|
-
|
|
93391
|
+
const brokers = records.kind({
|
|
93392
|
+
name: googleBrokersEntryKind.name,
|
|
93393
|
+
declaration: googleBrokersEntryKind.declaration,
|
|
93394
|
+
schema: record(string(), unknown())
|
|
93395
|
+
});
|
|
93396
|
+
const ports = {
|
|
93397
|
+
...calendarIdsPortsOver(brokers, (key) => this.readStoredGlobalKey(key)),
|
|
93398
|
+
...calendarRecordPortsOver({
|
|
93399
|
+
brokers,
|
|
93400
|
+
calendars: records.kind(googleCalendarsEntryKind),
|
|
93401
|
+
warn: (message) => this.ctx.logger.warn(message)
|
|
93402
|
+
})
|
|
93403
|
+
};
|
|
93404
|
+
if ((await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, ports))).applied.length > 0) this.activeBrokers = await this.loadPersistedBrokers();
|
|
92944
93405
|
}
|
|
92945
93406
|
async loadPersistedBrokers() {
|
|
92946
93407
|
const store = this.brokerStore;
|
|
@@ -92964,30 +93425,24 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
92964
93425
|
if (!this.oauthAccountsHandle) return;
|
|
92965
93426
|
await this.oauthAccountsHandle.set({ accounts: [...this.registry.listOauthAccounts()] });
|
|
92966
93427
|
}
|
|
92967
|
-
/**
|
|
92968
|
-
async
|
|
92969
|
-
const
|
|
92970
|
-
|
|
92971
|
-
|
|
92972
|
-
|
|
92973
|
-
|
|
92974
|
-
|
|
92975
|
-
|
|
92976
|
-
|
|
92977
|
-
|
|
92978
|
-
|
|
92979
|
-
|
|
92980
|
-
|
|
92981
|
-
|
|
92982
|
-
|
|
92983
|
-
|
|
92984
|
-
this.ctx.logger.warn("google calendar catalog failed", { meta: {
|
|
92985
|
-
brokerId: entry.id,
|
|
92986
|
-
error: err instanceof Error ? err.message : String(err)
|
|
92987
|
-
} });
|
|
92988
|
-
}
|
|
93428
|
+
/** The calendars one signed-in account lists, by their own id (the picker of a calendar record). */
|
|
93429
|
+
async loadCalendarCatalog(accountId) {
|
|
93430
|
+
const entry = this.registry.getEntry(accountId);
|
|
93431
|
+
if (entry === null || !this.registry.isConnected(entry.id)) return [];
|
|
93432
|
+
try {
|
|
93433
|
+
const api = createGoogleCalendarApi(() => this.ensureAccessToken(entry.id));
|
|
93434
|
+
const accountLabel = this.registry.getOauth(entry.id)?.accountEmail || entry.name;
|
|
93435
|
+
return (await api.listCalendars()).map((c) => ({
|
|
93436
|
+
value: c.id,
|
|
93437
|
+
label: `${c.summary.trim().length > 0 ? c.summary : c.id} (${accountLabel})`
|
|
93438
|
+
})).toSorted((a, b) => a.label.localeCompare(b.label));
|
|
93439
|
+
} catch (err) {
|
|
93440
|
+
this.ctx.logger.warn("google calendar catalog failed", { meta: {
|
|
93441
|
+
brokerId: entry.id,
|
|
93442
|
+
error: err instanceof Error ? err.message : String(err)
|
|
93443
|
+
} });
|
|
93444
|
+
return [];
|
|
92989
93445
|
}
|
|
92990
|
-
return out.toSorted((a, b) => a.label.localeCompare(b.label));
|
|
92991
93446
|
}
|
|
92992
93447
|
async emitGoogleBrokerReconnectAlert(brokerId, brokerName) {
|
|
92993
93448
|
const emit = this.ctx.api.alerts?.emit;
|
|
@@ -93110,14 +93565,6 @@ var GoogleServicesAddon = class extends BaseAddon {
|
|
|
93110
93565
|
await this.refreshPublicOrigin();
|
|
93111
93566
|
return super.getGlobalSettings(overlay, cap, nodeId);
|
|
93112
93567
|
}
|
|
93113
|
-
/**
|
|
93114
|
-
* The stamped calendar ids ONE broker imports. A broker the migration has not reached yet
|
|
93115
|
-
* (no `calendarIds` of its own) reads the shared setting older versions wrote, so the move
|
|
93116
|
-
* never changes what is imported mid-way.
|
|
93117
|
-
*/
|
|
93118
|
-
calendarIdsOf(brokerId) {
|
|
93119
|
-
return calendarIdsOfEntry(this.registry.getEntry(brokerId), this.config.calendarIds ?? []);
|
|
93120
|
-
}
|
|
93121
93568
|
};
|
|
93122
93569
|
function asSettingsCap(cap) {
|
|
93123
93570
|
if (cap === "calendar-source" || cap === "smtp-provider") return cap;
|