@camstack/addon-provider-homematic 1.2.184 → 1.2.186
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 +12 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-B5ZdVcAo.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-B2MUy4xX.mjs} +5 -5
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-D0LApVbg.mjs +26 -0
- package/dist/addon-provider-homematic.css +1 -1
- package/dist/addon.js +831 -941
- package/dist/addon.mjs +831 -941
- package/dist/{hostInit-CE_cSCS1.mjs → hostInit-BAkCZOkk.mjs} +4 -4
- package/dist/remoteEntry.js +1 -1
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-C_ngZu53.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-AieCvGW_.mjs} +1 -1
- package/package.json +3 -6
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-TVA-pYMh.mjs +0 -26
package/dist/addon.js
CHANGED
|
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
|
|
|
5990
5990
|
var ZodFirstPartyTypeKind;
|
|
5991
5991
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5992
5992
|
//#endregion
|
|
5993
|
-
//#region ../types/dist/sleep-
|
|
5993
|
+
//#region ../types/dist/sleep-D7ZKm4nb.mjs
|
|
5994
5994
|
/**
|
|
5995
5995
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5996
5996
|
* window to float samples (D455).
|
|
@@ -6699,10 +6699,33 @@ function integrationRowsApiOver(api) {
|
|
|
6699
6699
|
};
|
|
6700
6700
|
}
|
|
6701
6701
|
var PREFIX = "records/";
|
|
6702
|
+
/**
|
|
6703
|
+
* Cross-realm brand. An addon bundles its own copy of this module (D15) while
|
|
6704
|
+
* `ctx.records` is the HOST's door, so an error thrown by the host is an
|
|
6705
|
+
* instance of the host's classes, not of the addon's. The brand plus the code
|
|
6706
|
+
* make `instanceof` answer by identity of the failure, not of the copy.
|
|
6707
|
+
*/
|
|
6708
|
+
var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
|
|
6709
|
+
function carriesBrand(value) {
|
|
6710
|
+
return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
|
|
6711
|
+
}
|
|
6702
6712
|
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6703
6713
|
var RecordsError = class extends Error {
|
|
6714
|
+
/** The code a subclass stands for; the base stands for every code. */
|
|
6715
|
+
static code = void 0;
|
|
6716
|
+
/**
|
|
6717
|
+
* `instanceof` across copies of this module: any branded error is a
|
|
6718
|
+
* `RecordsError`, and is an instance of a subclass only when its code is the
|
|
6719
|
+
* subclass's code. Same-copy answers are unchanged.
|
|
6720
|
+
*/
|
|
6721
|
+
static [Symbol.hasInstance](value) {
|
|
6722
|
+
if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
|
|
6723
|
+
if (!carriesBrand(value)) return false;
|
|
6724
|
+
return this.code === void 0 || value.code === this.code;
|
|
6725
|
+
}
|
|
6704
6726
|
code;
|
|
6705
6727
|
detail;
|
|
6728
|
+
[RECORDS_ERROR_BRAND] = true;
|
|
6706
6729
|
constructor(code, detail) {
|
|
6707
6730
|
super(`${PREFIX}${code}: ${detail}`);
|
|
6708
6731
|
this.name = "RecordsError";
|
|
@@ -6711,29 +6734,33 @@ var RecordsError = class extends Error {
|
|
|
6711
6734
|
}
|
|
6712
6735
|
};
|
|
6713
6736
|
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6714
|
-
var RevConflictError = class extends RecordsError {
|
|
6737
|
+
var RevConflictError = class RevConflictError extends RecordsError {
|
|
6738
|
+
static code = "rev-conflict";
|
|
6715
6739
|
constructor(detail) {
|
|
6716
|
-
super(
|
|
6740
|
+
super(RevConflictError.code, detail);
|
|
6717
6741
|
this.name = "RevConflictError";
|
|
6718
6742
|
}
|
|
6719
6743
|
};
|
|
6720
6744
|
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6721
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6745
|
+
var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
|
|
6746
|
+
static code = "secret-unavailable";
|
|
6722
6747
|
constructor(detail) {
|
|
6723
|
-
super(
|
|
6748
|
+
super(RecordSecretUnavailableError.code, detail);
|
|
6724
6749
|
this.name = "RecordSecretUnavailableError";
|
|
6725
6750
|
}
|
|
6726
6751
|
};
|
|
6727
|
-
var InvalidRecordError = class extends RecordsError {
|
|
6752
|
+
var InvalidRecordError = class InvalidRecordError extends RecordsError {
|
|
6753
|
+
static code = "invalid-record";
|
|
6728
6754
|
constructor(detail) {
|
|
6729
|
-
super(
|
|
6755
|
+
super(InvalidRecordError.code, detail);
|
|
6730
6756
|
this.name = "InvalidRecordError";
|
|
6731
6757
|
}
|
|
6732
6758
|
};
|
|
6733
6759
|
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6734
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
6760
|
+
var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
|
|
6761
|
+
static code = "declaration-refused";
|
|
6735
6762
|
constructor(detail) {
|
|
6736
|
-
super(
|
|
6763
|
+
super(DeclarationRefusedError.code, detail);
|
|
6737
6764
|
this.name = "DeclarationRefusedError";
|
|
6738
6765
|
}
|
|
6739
6766
|
};
|
|
@@ -9537,286 +9564,6 @@ function normalizeAddonInitResult(result) {
|
|
|
9537
9564
|
if (Array.isArray(result)) return { providers: result };
|
|
9538
9565
|
return result;
|
|
9539
9566
|
}
|
|
9540
|
-
/**
|
|
9541
|
-
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9542
|
-
* and validates them (`ShareViewGrantSchema` builds its
|
|
9543
|
-
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9544
|
-
*/
|
|
9545
|
-
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
9546
|
-
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
9547
|
-
var PeerBytesTicketSchema = object({
|
|
9548
|
-
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
9549
|
-
url: string().min(1),
|
|
9550
|
-
/**
|
|
9551
|
-
* The HOST node this URL means something on — the hub or a named agent,
|
|
9552
|
-
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
9553
|
-
* refuses `cross-node` by name when they differ, without dialling.
|
|
9554
|
-
*/
|
|
9555
|
-
hostNodeId: string().min(1),
|
|
9556
|
-
expiresAtMs: number().int().nonnegative(),
|
|
9557
|
-
/**
|
|
9558
|
-
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
9559
|
-
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
9560
|
-
* must be able to tell "the producer did not say" from "the body is empty".
|
|
9561
|
-
*/
|
|
9562
|
-
declaredBytes: number().int().nonnegative().nullable()
|
|
9563
|
-
});
|
|
9564
|
-
function defOf(schema) {
|
|
9565
|
-
const zodBag = Reflect.get(schema, "_zod");
|
|
9566
|
-
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
9567
|
-
const def = Reflect.get(zodBag, "def");
|
|
9568
|
-
if (typeof def !== "object" || def === null) return {};
|
|
9569
|
-
return def;
|
|
9570
|
-
}
|
|
9571
|
-
function declaredHere(schema) {
|
|
9572
|
-
return globalRegistry.get(schema)?.secret === true;
|
|
9573
|
-
}
|
|
9574
|
-
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
9575
|
-
var WRAPPERS = new Set([
|
|
9576
|
-
"optional",
|
|
9577
|
-
"nullable",
|
|
9578
|
-
"default",
|
|
9579
|
-
"prefault",
|
|
9580
|
-
"catch",
|
|
9581
|
-
"readonly",
|
|
9582
|
-
"nonoptional"
|
|
9583
|
-
]);
|
|
9584
|
-
/**
|
|
9585
|
-
* The schema layers that make up ONE field: the schema itself and every
|
|
9586
|
-
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
9587
|
-
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
9588
|
-
* `.transform` on `in`).
|
|
9589
|
-
*/
|
|
9590
|
-
function layersOf(schema) {
|
|
9591
|
-
const out = [];
|
|
9592
|
-
const queue = [schema];
|
|
9593
|
-
while (queue.length > 0) {
|
|
9594
|
-
const s = queue.shift();
|
|
9595
|
-
if (!s || out.includes(s)) continue;
|
|
9596
|
-
out.push(s);
|
|
9597
|
-
const def = defOf(s);
|
|
9598
|
-
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
9599
|
-
if (def.type === "pipe") {
|
|
9600
|
-
if (def.in) queue.push(def.in);
|
|
9601
|
-
if (def.out) queue.push(def.out);
|
|
9602
|
-
}
|
|
9603
|
-
}
|
|
9604
|
-
return out;
|
|
9605
|
-
}
|
|
9606
|
-
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
9607
|
-
function isZodSecret(schema) {
|
|
9608
|
-
return layersOf(schema).some(declaredHere);
|
|
9609
|
-
}
|
|
9610
|
-
/**
|
|
9611
|
-
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9612
|
-
* element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
|
|
9613
|
-
* map" (`applianceSecrets{}`). A declared
|
|
9614
|
-
* object or array is reported as one path and not descended into — everything
|
|
9615
|
-
* under it is secret.
|
|
9616
|
-
*/
|
|
9617
|
-
function collectZodSecretPaths(schema, prefix = "") {
|
|
9618
|
-
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
9619
|
-
const paths = [];
|
|
9620
|
-
for (const layer of layersOf(schema)) {
|
|
9621
|
-
const def = defOf(layer);
|
|
9622
|
-
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9623
|
-
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9624
|
-
else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
|
|
9625
|
-
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9626
|
-
else if (def.type === "intersection") {
|
|
9627
|
-
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
9628
|
-
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
9629
|
-
}
|
|
9630
|
-
}
|
|
9631
|
-
return [...new Set(paths)];
|
|
9632
|
-
}
|
|
9633
|
-
/**
|
|
9634
|
-
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
9635
|
-
* Zod row schema that describes it, and the helper that turns the two into the
|
|
9636
|
-
* JSON the engine stores.
|
|
9637
|
-
*
|
|
9638
|
-
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
9639
|
-
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
9640
|
-
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
9641
|
-
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
9642
|
-
* never a field name (D879).
|
|
9643
|
-
*/
|
|
9644
|
-
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
9645
|
-
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
9646
|
-
var RecordIndexSchema = object({
|
|
9647
|
-
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
9648
|
-
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
9649
|
-
unique: boolean().optional()
|
|
9650
|
-
}).strict();
|
|
9651
|
-
var RecordRetentionSchema = union([
|
|
9652
|
-
object({
|
|
9653
|
-
ttlMs: number().int().positive(),
|
|
9654
|
-
from: _enum(["at", "write"])
|
|
9655
|
-
}).strict(),
|
|
9656
|
-
object({
|
|
9657
|
-
maxRows: number().int().positive().optional(),
|
|
9658
|
-
maxRowsPerDevice: number().int().positive().optional()
|
|
9659
|
-
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
9660
|
-
object({
|
|
9661
|
-
owner: string().min(1),
|
|
9662
|
-
reason: string().min(1)
|
|
9663
|
-
}).strict(),
|
|
9664
|
-
object({ none: string().min(1) }).strict()
|
|
9665
|
-
]);
|
|
9666
|
-
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
9667
|
-
var EntryDescriptorSchema = object({
|
|
9668
|
-
title: string().min(1),
|
|
9669
|
-
/** The record body field shown as the entry's name. */
|
|
9670
|
-
nameField: string().min(1),
|
|
9671
|
-
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
9672
|
-
fields: record(string(), unknown())
|
|
9673
|
-
}).strict();
|
|
9674
|
-
/** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
|
|
9675
|
-
var RecordKindDeclarationSchema = object({
|
|
9676
|
-
database: _enum(RECORD_DATABASES).default("settings"),
|
|
9677
|
-
class: _enum(RECORD_CLASSES),
|
|
9678
|
-
writeTrigger: string().min(1),
|
|
9679
|
-
device: _enum([
|
|
9680
|
-
"required",
|
|
9681
|
-
"optional",
|
|
9682
|
-
"none"
|
|
9683
|
-
]).default("none"),
|
|
9684
|
-
at: _enum(["required", "none"]).default("none"),
|
|
9685
|
-
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
9686
|
-
retention: RecordRetentionSchema,
|
|
9687
|
-
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
9688
|
-
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
9689
|
-
/** Derived from the Zod schema; never written by hand. */
|
|
9690
|
-
secretPaths: array(string().min(1)).default([]),
|
|
9691
|
-
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
9692
|
-
secretArrayKeys: record(string(), string()).default({}),
|
|
9693
|
-
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
9694
|
-
transactFamily: string().min(1).optional(),
|
|
9695
|
-
entry: EntryDescriptorSchema.optional()
|
|
9696
|
-
}).strict();
|
|
9697
|
-
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
9698
|
-
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
9699
|
-
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
9700
|
-
function assertValidDeclaration(name, decl) {
|
|
9701
|
-
const refuse = (why) => {
|
|
9702
|
-
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
9703
|
-
};
|
|
9704
|
-
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
9705
|
-
const seen = /* @__PURE__ */ new Set();
|
|
9706
|
-
for (const index of decl.indexes) {
|
|
9707
|
-
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
9708
|
-
seen.add(index.name);
|
|
9709
|
-
}
|
|
9710
|
-
const { retention } = decl;
|
|
9711
|
-
const hasSecrets = decl.secretPaths.length > 0;
|
|
9712
|
-
if ("ttlMs" in retention) {
|
|
9713
|
-
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
9714
|
-
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
9715
|
-
}
|
|
9716
|
-
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
9717
|
-
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
9718
|
-
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
9719
|
-
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
9720
|
-
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
9721
|
-
if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
|
|
9722
|
-
}
|
|
9723
|
-
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
9724
|
-
for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
|
|
9725
|
-
}
|
|
9726
|
-
function bodyFieldsOf(schema) {
|
|
9727
|
-
return { ...toJSONSchema(schema, {
|
|
9728
|
-
unrepresentable: "any",
|
|
9729
|
-
io: "input"
|
|
9730
|
-
}) };
|
|
9731
|
-
}
|
|
9732
|
-
function isRecordLike(value) {
|
|
9733
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9734
|
-
}
|
|
9735
|
-
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
9736
|
-
function hasNameField(json, field) {
|
|
9737
|
-
const branches = json["oneOf"] ?? json["anyOf"];
|
|
9738
|
-
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
9739
|
-
const properties = json["properties"];
|
|
9740
|
-
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
9741
|
-
}
|
|
9742
|
-
/**
|
|
9743
|
-
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
9744
|
-
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
9745
|
-
* types its handle from.
|
|
9746
|
-
*/
|
|
9747
|
-
function defineRecordKinds(specs) {
|
|
9748
|
-
const out = {};
|
|
9749
|
-
for (const [name, spec] of Object.entries(specs)) {
|
|
9750
|
-
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
9751
|
-
const nameField = spec.entry?.nameField ?? "name";
|
|
9752
|
-
const fields = bodyFieldsOf(spec.schema);
|
|
9753
|
-
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
9754
|
-
const parsed = RecordKindDeclarationSchema.parse({
|
|
9755
|
-
database: spec.database,
|
|
9756
|
-
class: spec.class,
|
|
9757
|
-
writeTrigger: spec.writeTrigger,
|
|
9758
|
-
device: spec.device,
|
|
9759
|
-
at: spec.at,
|
|
9760
|
-
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
9761
|
-
retention: spec.retention,
|
|
9762
|
-
deviceRemoval: spec.deviceRemoval,
|
|
9763
|
-
maxDataBytes: spec.maxDataBytes,
|
|
9764
|
-
secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
|
|
9765
|
-
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
9766
|
-
transactFamily: spec.transactFamily,
|
|
9767
|
-
entry: spec.entry === void 0 ? void 0 : {
|
|
9768
|
-
title: spec.entry.title,
|
|
9769
|
-
nameField,
|
|
9770
|
-
fields
|
|
9771
|
-
}
|
|
9772
|
-
});
|
|
9773
|
-
assertValidDeclaration(name, parsed);
|
|
9774
|
-
out[name] = {
|
|
9775
|
-
name,
|
|
9776
|
-
schema: spec.schema,
|
|
9777
|
-
declaration: parsed
|
|
9778
|
-
};
|
|
9779
|
-
}
|
|
9780
|
-
return out;
|
|
9781
|
-
}
|
|
9782
|
-
/**
|
|
9783
|
-
* Entry kinds (D881): every list of user-created entries (notification
|
|
9784
|
-
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
9785
|
-
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
9786
|
-
* through the `record-entries` capability with password fields derived from
|
|
9787
|
-
* the schema (`.meta({ secret: true })`).
|
|
9788
|
-
*/
|
|
9789
|
-
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
9790
|
-
function entryBody(shape) {
|
|
9791
|
-
return object({
|
|
9792
|
-
name: string().min(1),
|
|
9793
|
-
enabled: boolean().optional(),
|
|
9794
|
-
...shape
|
|
9795
|
-
});
|
|
9796
|
-
}
|
|
9797
|
-
/**
|
|
9798
|
-
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
9799
|
-
* engine, never aged, belonging to no device.
|
|
9800
|
-
*/
|
|
9801
|
-
function defineEntryKind(name, spec) {
|
|
9802
|
-
const defined = defineRecordKinds({ [name]: {
|
|
9803
|
-
schema: spec.schema,
|
|
9804
|
-
class: "config",
|
|
9805
|
-
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9806
|
-
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9807
|
-
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9808
|
-
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9809
|
-
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9810
|
-
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
9811
|
-
...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
|
|
9812
|
-
entry: {
|
|
9813
|
-
title: spec.title,
|
|
9814
|
-
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
9815
|
-
}
|
|
9816
|
-
} })[name];
|
|
9817
|
-
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
9818
|
-
return defined;
|
|
9819
|
-
}
|
|
9820
9567
|
object({
|
|
9821
9568
|
field: string().min(1),
|
|
9822
9569
|
on: literal("advance")
|
|
@@ -9909,6 +9656,286 @@ function optionalMethod(input, output, options) {
|
|
|
9909
9656
|
function event(data) {
|
|
9910
9657
|
return { data };
|
|
9911
9658
|
}
|
|
9659
|
+
function defOf(schema) {
|
|
9660
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
9661
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
9662
|
+
const def = Reflect.get(zodBag, "def");
|
|
9663
|
+
if (typeof def !== "object" || def === null) return {};
|
|
9664
|
+
return def;
|
|
9665
|
+
}
|
|
9666
|
+
function declaredHere(schema) {
|
|
9667
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
9668
|
+
}
|
|
9669
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
9670
|
+
var WRAPPERS = new Set([
|
|
9671
|
+
"optional",
|
|
9672
|
+
"nullable",
|
|
9673
|
+
"default",
|
|
9674
|
+
"prefault",
|
|
9675
|
+
"catch",
|
|
9676
|
+
"readonly",
|
|
9677
|
+
"nonoptional"
|
|
9678
|
+
]);
|
|
9679
|
+
/**
|
|
9680
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
9681
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
9682
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
9683
|
+
* `.transform` on `in`).
|
|
9684
|
+
*/
|
|
9685
|
+
function layersOf(schema) {
|
|
9686
|
+
const out = [];
|
|
9687
|
+
const queue = [schema];
|
|
9688
|
+
while (queue.length > 0) {
|
|
9689
|
+
const s = queue.shift();
|
|
9690
|
+
if (!s || out.includes(s)) continue;
|
|
9691
|
+
out.push(s);
|
|
9692
|
+
const def = defOf(s);
|
|
9693
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
9694
|
+
if (def.type === "pipe") {
|
|
9695
|
+
if (def.in) queue.push(def.in);
|
|
9696
|
+
if (def.out) queue.push(def.out);
|
|
9697
|
+
}
|
|
9698
|
+
}
|
|
9699
|
+
return out;
|
|
9700
|
+
}
|
|
9701
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
9702
|
+
function isZodSecret(schema) {
|
|
9703
|
+
return layersOf(schema).some(declaredHere);
|
|
9704
|
+
}
|
|
9705
|
+
/**
|
|
9706
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9707
|
+
* element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
|
|
9708
|
+
* map" (`applianceSecrets{}`). A declared
|
|
9709
|
+
* object or array is reported as one path and not descended into — everything
|
|
9710
|
+
* under it is secret.
|
|
9711
|
+
*/
|
|
9712
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
9713
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
9714
|
+
const paths = [];
|
|
9715
|
+
for (const layer of layersOf(schema)) {
|
|
9716
|
+
const def = defOf(layer);
|
|
9717
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9718
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9719
|
+
else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
|
|
9720
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9721
|
+
else if (def.type === "intersection") {
|
|
9722
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
9723
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
9724
|
+
}
|
|
9725
|
+
}
|
|
9726
|
+
return [...new Set(paths)];
|
|
9727
|
+
}
|
|
9728
|
+
/**
|
|
9729
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
9730
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
9731
|
+
* JSON the engine stores.
|
|
9732
|
+
*
|
|
9733
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
9734
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
9735
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
9736
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
9737
|
+
* never a field name (D879).
|
|
9738
|
+
*/
|
|
9739
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
9740
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
9741
|
+
var RecordIndexSchema = object({
|
|
9742
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
9743
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
9744
|
+
unique: boolean().optional()
|
|
9745
|
+
}).strict();
|
|
9746
|
+
var RecordRetentionSchema = union([
|
|
9747
|
+
object({
|
|
9748
|
+
ttlMs: number().int().positive(),
|
|
9749
|
+
from: _enum(["at", "write"])
|
|
9750
|
+
}).strict(),
|
|
9751
|
+
object({
|
|
9752
|
+
maxRows: number().int().positive().optional(),
|
|
9753
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
9754
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
9755
|
+
object({
|
|
9756
|
+
owner: string().min(1),
|
|
9757
|
+
reason: string().min(1)
|
|
9758
|
+
}).strict(),
|
|
9759
|
+
object({ none: string().min(1) }).strict()
|
|
9760
|
+
]);
|
|
9761
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
9762
|
+
var EntryDescriptorSchema = object({
|
|
9763
|
+
title: string().min(1),
|
|
9764
|
+
/** The record body field shown as the entry's name. */
|
|
9765
|
+
nameField: string().min(1),
|
|
9766
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
9767
|
+
fields: record(string(), unknown())
|
|
9768
|
+
}).strict();
|
|
9769
|
+
/** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
|
|
9770
|
+
var RecordKindDeclarationSchema = object({
|
|
9771
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
9772
|
+
class: _enum(RECORD_CLASSES),
|
|
9773
|
+
writeTrigger: string().min(1),
|
|
9774
|
+
device: _enum([
|
|
9775
|
+
"required",
|
|
9776
|
+
"optional",
|
|
9777
|
+
"none"
|
|
9778
|
+
]).default("none"),
|
|
9779
|
+
at: _enum(["required", "none"]).default("none"),
|
|
9780
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
9781
|
+
retention: RecordRetentionSchema,
|
|
9782
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
9783
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
9784
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
9785
|
+
secretPaths: array(string().min(1)).default([]),
|
|
9786
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
9787
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
9788
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
9789
|
+
transactFamily: string().min(1).optional(),
|
|
9790
|
+
entry: EntryDescriptorSchema.optional()
|
|
9791
|
+
}).strict();
|
|
9792
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
9793
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
9794
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
9795
|
+
function assertValidDeclaration(name, decl) {
|
|
9796
|
+
const refuse = (why) => {
|
|
9797
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
9798
|
+
};
|
|
9799
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
9800
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9801
|
+
for (const index of decl.indexes) {
|
|
9802
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
9803
|
+
seen.add(index.name);
|
|
9804
|
+
}
|
|
9805
|
+
const { retention } = decl;
|
|
9806
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
9807
|
+
if ("ttlMs" in retention) {
|
|
9808
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
9809
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
9810
|
+
}
|
|
9811
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
9812
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
9813
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
9814
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
9815
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
9816
|
+
if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
|
|
9817
|
+
}
|
|
9818
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
9819
|
+
for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
|
|
9820
|
+
}
|
|
9821
|
+
function bodyFieldsOf(schema) {
|
|
9822
|
+
return { ...toJSONSchema(schema, {
|
|
9823
|
+
unrepresentable: "any",
|
|
9824
|
+
io: "input"
|
|
9825
|
+
}) };
|
|
9826
|
+
}
|
|
9827
|
+
function isRecordLike(value) {
|
|
9828
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9829
|
+
}
|
|
9830
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
9831
|
+
function hasNameField(json, field) {
|
|
9832
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
9833
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
9834
|
+
const properties = json["properties"];
|
|
9835
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
9836
|
+
}
|
|
9837
|
+
/**
|
|
9838
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
9839
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
9840
|
+
* types its handle from.
|
|
9841
|
+
*/
|
|
9842
|
+
function defineRecordKinds(specs) {
|
|
9843
|
+
const out = {};
|
|
9844
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
9845
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
9846
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
9847
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
9848
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
9849
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
9850
|
+
database: spec.database,
|
|
9851
|
+
class: spec.class,
|
|
9852
|
+
writeTrigger: spec.writeTrigger,
|
|
9853
|
+
device: spec.device,
|
|
9854
|
+
at: spec.at,
|
|
9855
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
9856
|
+
retention: spec.retention,
|
|
9857
|
+
deviceRemoval: spec.deviceRemoval,
|
|
9858
|
+
maxDataBytes: spec.maxDataBytes,
|
|
9859
|
+
secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
|
|
9860
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
9861
|
+
transactFamily: spec.transactFamily,
|
|
9862
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
9863
|
+
title: spec.entry.title,
|
|
9864
|
+
nameField,
|
|
9865
|
+
fields
|
|
9866
|
+
}
|
|
9867
|
+
});
|
|
9868
|
+
assertValidDeclaration(name, parsed);
|
|
9869
|
+
out[name] = {
|
|
9870
|
+
name,
|
|
9871
|
+
schema: spec.schema,
|
|
9872
|
+
declaration: parsed
|
|
9873
|
+
};
|
|
9874
|
+
}
|
|
9875
|
+
return out;
|
|
9876
|
+
}
|
|
9877
|
+
/**
|
|
9878
|
+
* Entry kinds (D881): every list of user-created entries (notification
|
|
9879
|
+
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
9880
|
+
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
9881
|
+
* through the `record-entries` capability with password fields derived from
|
|
9882
|
+
* the schema (`.meta({ secret: true })`).
|
|
9883
|
+
*/
|
|
9884
|
+
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
9885
|
+
function entryBody(shape) {
|
|
9886
|
+
return object({
|
|
9887
|
+
name: string().min(1),
|
|
9888
|
+
enabled: boolean().optional(),
|
|
9889
|
+
...shape
|
|
9890
|
+
});
|
|
9891
|
+
}
|
|
9892
|
+
/**
|
|
9893
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
9894
|
+
* engine, never aged, belonging to no device.
|
|
9895
|
+
*/
|
|
9896
|
+
function defineEntryKind(name, spec) {
|
|
9897
|
+
const defined = defineRecordKinds({ [name]: {
|
|
9898
|
+
schema: spec.schema,
|
|
9899
|
+
class: "config",
|
|
9900
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9901
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9902
|
+
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9903
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9904
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9905
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
9906
|
+
...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
|
|
9907
|
+
entry: {
|
|
9908
|
+
title: spec.title,
|
|
9909
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
9910
|
+
}
|
|
9911
|
+
} })[name];
|
|
9912
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
9913
|
+
return defined;
|
|
9914
|
+
}
|
|
9915
|
+
/**
|
|
9916
|
+
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9917
|
+
* and validates them (`ShareViewGrantSchema` builds its
|
|
9918
|
+
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9919
|
+
*/
|
|
9920
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
9921
|
+
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
9922
|
+
var PeerBytesTicketSchema = object({
|
|
9923
|
+
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
9924
|
+
url: string().min(1),
|
|
9925
|
+
/**
|
|
9926
|
+
* The HOST node this URL means something on — the hub or a named agent,
|
|
9927
|
+
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
9928
|
+
* refuses `cross-node` by name when they differ, without dialling.
|
|
9929
|
+
*/
|
|
9930
|
+
hostNodeId: string().min(1),
|
|
9931
|
+
expiresAtMs: number().int().nonnegative(),
|
|
9932
|
+
/**
|
|
9933
|
+
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
9934
|
+
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
9935
|
+
* must be able to tell "the producer did not say" from "the body is empty".
|
|
9936
|
+
*/
|
|
9937
|
+
declaredBytes: number().int().nonnegative().nullable()
|
|
9938
|
+
});
|
|
9912
9939
|
var READING_QUANTITIES = [
|
|
9913
9940
|
"temperature",
|
|
9914
9941
|
"pressure",
|
|
@@ -10526,7 +10553,6 @@ var CAP_NAMES = Object.freeze([
|
|
|
10526
10553
|
"climate-control",
|
|
10527
10554
|
"color",
|
|
10528
10555
|
"composer",
|
|
10529
|
-
"connection-test",
|
|
10530
10556
|
"connectivity",
|
|
10531
10557
|
"consumables",
|
|
10532
10558
|
"contact",
|
|
@@ -12546,8 +12572,7 @@ Object.freeze({
|
|
|
12546
12572
|
"offerArtifact": 3e5,
|
|
12547
12573
|
"readResult": 3e5,
|
|
12548
12574
|
"submitJob": 18e5,
|
|
12549
|
-
"uploadDataset": 72e5
|
|
12550
|
-
"validateCredentials": 3e4
|
|
12575
|
+
"uploadDataset": 72e5
|
|
12551
12576
|
}
|
|
12552
12577
|
});
|
|
12553
12578
|
object({
|
|
@@ -13902,6 +13927,432 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13902
13927
|
]),
|
|
13903
13928
|
candidateStableId: string().optional()
|
|
13904
13929
|
});
|
|
13930
|
+
/**
|
|
13931
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
13932
|
+
*
|
|
13933
|
+
* Apprise-derived model (see
|
|
13934
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
13935
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
13936
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
13937
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
13938
|
+
* message to what the kind supports — callers never special-case a service.
|
|
13939
|
+
*
|
|
13940
|
+
* DESIGN DECISIONS (locked):
|
|
13941
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
13942
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
13943
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
13944
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
13945
|
+
* alternative would fork the UI per addon and cannot host the
|
|
13946
|
+
* discovery→adopt flow.
|
|
13947
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
13948
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
13949
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
13950
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
13951
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
13952
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
13953
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
13954
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
13955
|
+
* base64 fallback needed.
|
|
13956
|
+
*
|
|
13957
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
13958
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
13959
|
+
* admin "Integrations" page.
|
|
13960
|
+
*/
|
|
13961
|
+
/**
|
|
13962
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
13963
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
13964
|
+
*/
|
|
13965
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
13966
|
+
"image",
|
|
13967
|
+
"video",
|
|
13968
|
+
"gif",
|
|
13969
|
+
"audio",
|
|
13970
|
+
"icon"
|
|
13971
|
+
]);
|
|
13972
|
+
/**
|
|
13973
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
13974
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
13975
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
13976
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
13977
|
+
*/
|
|
13978
|
+
var AttachmentSchema = object({
|
|
13979
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
13980
|
+
url: string().optional(),
|
|
13981
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
13982
|
+
mime: string().optional(),
|
|
13983
|
+
name: string().optional()
|
|
13984
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
13985
|
+
var NotificationFormatSchema = _enum([
|
|
13986
|
+
"text",
|
|
13987
|
+
"markdown",
|
|
13988
|
+
"html"
|
|
13989
|
+
]);
|
|
13990
|
+
/**
|
|
13991
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
13992
|
+
*
|
|
13993
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
13994
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
13995
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
13996
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
13997
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
13998
|
+
*
|
|
13999
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
14000
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
14001
|
+
* differently.
|
|
14002
|
+
*
|
|
14003
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
14004
|
+
*
|
|
14005
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
14006
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
14007
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
14008
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
14009
|
+
* decides its glyph, which is the only place that decision can be made
|
|
14010
|
+
* honestly.
|
|
14011
|
+
*
|
|
14012
|
+
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
14013
|
+
* `disarm` straight through; iOS feeds that string to
|
|
14014
|
+
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
14015
|
+
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
14016
|
+
* mapping, and "the field is documented" is not "the value renders".
|
|
14017
|
+
*
|
|
14018
|
+
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
14019
|
+
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
14020
|
+
* so an addon that emits a token the running hub does not know does not lose an
|
|
14021
|
+
* icon — its whole `send` fails Zod validation and the notification never
|
|
14022
|
+
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
14023
|
+
*/
|
|
14024
|
+
var NotificationActionIconSchema = _enum([
|
|
14025
|
+
"acknowledge",
|
|
14026
|
+
"dismiss",
|
|
14027
|
+
"silence",
|
|
14028
|
+
"snooze",
|
|
14029
|
+
"view",
|
|
14030
|
+
"play",
|
|
14031
|
+
"open",
|
|
14032
|
+
"close",
|
|
14033
|
+
"lock",
|
|
14034
|
+
"unlock",
|
|
14035
|
+
"arm",
|
|
14036
|
+
"arm-home",
|
|
14037
|
+
"arm-away",
|
|
14038
|
+
"arm-night",
|
|
14039
|
+
"disarm",
|
|
14040
|
+
"light",
|
|
14041
|
+
"alert",
|
|
14042
|
+
"camera"
|
|
14043
|
+
]);
|
|
14044
|
+
/** A single tap-through action button. */
|
|
14045
|
+
var NotificationActionSchema = object({
|
|
14046
|
+
id: string(),
|
|
14047
|
+
label: string(),
|
|
14048
|
+
url: string().optional(),
|
|
14049
|
+
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
14050
|
+
icon: NotificationActionIconSchema.optional(),
|
|
14051
|
+
/**
|
|
14052
|
+
* Renders in a warning style where the notifier supports it.
|
|
14053
|
+
*
|
|
14054
|
+
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
14055
|
+
* else — see `notification-center/action-token.ts` for what that does and
|
|
14056
|
+
* does not buy.
|
|
14057
|
+
*/
|
|
14058
|
+
destructive: boolean().optional(),
|
|
14059
|
+
/**
|
|
14060
|
+
* How the tap should REACH the url.
|
|
14061
|
+
*
|
|
14062
|
+
* `navigate` (absent, and every button authored before this field) opens it:
|
|
14063
|
+
* the phone leaves the notification and shows whatever the callback returns.
|
|
14064
|
+
* That is right for a button whose answer the operator wants to read.
|
|
14065
|
+
*
|
|
14066
|
+
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
14067
|
+
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
14068
|
+
* an answer to the notification, and being thrown into a browser tab to
|
|
14069
|
+
* confirm it costs more attention than the notification did. A backend that
|
|
14070
|
+
* cannot do a background call renders it as an ordinary link (the adapters
|
|
14071
|
+
* fall back rather than dropping the button), so this is a preference, never
|
|
14072
|
+
* a requirement.
|
|
14073
|
+
*/
|
|
14074
|
+
mode: _enum(["navigate", "background"]).optional()
|
|
14075
|
+
});
|
|
14076
|
+
/** A delivery parameter value: what a notifier declared it takes. */
|
|
14077
|
+
var DeliveryParamValueSchema = union([
|
|
14078
|
+
string(),
|
|
14079
|
+
number(),
|
|
14080
|
+
boolean()
|
|
14081
|
+
]);
|
|
14082
|
+
/**
|
|
14083
|
+
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
14084
|
+
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
14085
|
+
* never handed one. The admin UI derives its control from this descriptor —
|
|
14086
|
+
* no editor knows a service by name.
|
|
14087
|
+
*
|
|
14088
|
+
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
14089
|
+
* run on the addon cap path).
|
|
14090
|
+
*/
|
|
14091
|
+
var DeliveryParamSchema = object({
|
|
14092
|
+
key: string().min(1),
|
|
14093
|
+
label: string(),
|
|
14094
|
+
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
14095
|
+
labelKey: string().optional(),
|
|
14096
|
+
type: _enum([
|
|
14097
|
+
"enum",
|
|
14098
|
+
"number",
|
|
14099
|
+
"boolean",
|
|
14100
|
+
"string"
|
|
14101
|
+
]),
|
|
14102
|
+
/** `enum` only: the closed set of accepted values. */
|
|
14103
|
+
options: array(object({
|
|
14104
|
+
value: string(),
|
|
14105
|
+
label: string()
|
|
14106
|
+
})).optional(),
|
|
14107
|
+
/** `number` only. */
|
|
14108
|
+
min: number().optional(),
|
|
14109
|
+
max: number().optional(),
|
|
14110
|
+
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
14111
|
+
default: DeliveryParamValueSchema.optional()
|
|
14112
|
+
});
|
|
14113
|
+
/**
|
|
14114
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14115
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14116
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14117
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14118
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14119
|
+
* `priority` for that one target.
|
|
14120
|
+
*/
|
|
14121
|
+
var NotificationSchema = object({
|
|
14122
|
+
body: string(),
|
|
14123
|
+
title: string().optional(),
|
|
14124
|
+
format: NotificationFormatSchema.default("text"),
|
|
14125
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14126
|
+
level: string().optional(),
|
|
14127
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14128
|
+
clickUrl: string().optional(),
|
|
14129
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14130
|
+
sound: string().optional(),
|
|
14131
|
+
ttl: number().optional(),
|
|
14132
|
+
tag: string().optional(),
|
|
14133
|
+
deviceId: number().optional(),
|
|
14134
|
+
eventId: string().optional(),
|
|
14135
|
+
metadata: record(string(), unknown()).optional(),
|
|
14136
|
+
/**
|
|
14137
|
+
* Values for the parameters the target's kind DECLARES in
|
|
14138
|
+
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
14139
|
+
* declaration by the sender; a notifier reads only the keys it declared.
|
|
14140
|
+
*/
|
|
14141
|
+
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
14142
|
+
});
|
|
14143
|
+
/** One declared native severity/priority level for a kind. */
|
|
14144
|
+
var TargetKindLevelSchema = object({
|
|
14145
|
+
id: string(),
|
|
14146
|
+
label: string(),
|
|
14147
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14148
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14149
|
+
flags: object({
|
|
14150
|
+
critical: boolean().optional(),
|
|
14151
|
+
silent: boolean().optional(),
|
|
14152
|
+
noPush: boolean().optional()
|
|
14153
|
+
}).optional(),
|
|
14154
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14155
|
+
requires: array(string()).optional(),
|
|
14156
|
+
description: string().optional()
|
|
14157
|
+
});
|
|
14158
|
+
/** The full capability block consulted before dispatch. */
|
|
14159
|
+
var TargetKindCapsSchema = object({
|
|
14160
|
+
attachments: object({
|
|
14161
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14162
|
+
mode: _enum([
|
|
14163
|
+
"url",
|
|
14164
|
+
"bytes",
|
|
14165
|
+
"both"
|
|
14166
|
+
]),
|
|
14167
|
+
max: number().int().nonnegative(),
|
|
14168
|
+
maxBytes: number().int().positive().optional()
|
|
14169
|
+
}),
|
|
14170
|
+
/** Max action buttons (0 = none). */
|
|
14171
|
+
actions: number().int().nonnegative(),
|
|
14172
|
+
/**
|
|
14173
|
+
* Whether this kind renders a per-action ICON.
|
|
14174
|
+
*
|
|
14175
|
+
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
14176
|
+
* run on the addon cap path — three production failures in one day taught
|
|
14177
|
+
* this repo that once. Absent is read as false by the degrade engine, which
|
|
14178
|
+
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
14179
|
+
* assumed and dropped costs the operator's trust in the field.
|
|
14180
|
+
*/
|
|
14181
|
+
actionIcons: boolean().optional(),
|
|
14182
|
+
levels: array(TargetKindLevelSchema),
|
|
14183
|
+
format: array(NotificationFormatSchema),
|
|
14184
|
+
clickUrl: boolean(),
|
|
14185
|
+
sound: boolean(),
|
|
14186
|
+
ttl: boolean(),
|
|
14187
|
+
bodyMaxLen: number().int().positive()
|
|
14188
|
+
});
|
|
14189
|
+
/**
|
|
14190
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14191
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14192
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14193
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14194
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14195
|
+
*/
|
|
14196
|
+
var ConfigSchemaPassthrough$4 = unknown();
|
|
14197
|
+
var TargetKindSchema = object({
|
|
14198
|
+
kind: string(),
|
|
14199
|
+
label: string(),
|
|
14200
|
+
icon: string(),
|
|
14201
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14202
|
+
addonId: string(),
|
|
14203
|
+
/**
|
|
14204
|
+
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
14205
|
+
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
14206
|
+
* when the addon bundles no icon for that kind — the client then falls back
|
|
14207
|
+
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
14208
|
+
*
|
|
14209
|
+
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
14210
|
+
* client, and a native client joins it onto its own hub base.
|
|
14211
|
+
*
|
|
14212
|
+
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
14213
|
+
* field that survived only because the runtime cap-router forwards provider
|
|
14214
|
+
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
14215
|
+
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
14216
|
+
* broken silently the moment output validation was tightened anywhere.
|
|
14217
|
+
*/
|
|
14218
|
+
iconUrl: string().optional(),
|
|
14219
|
+
/**
|
|
14220
|
+
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
14221
|
+
*
|
|
14222
|
+
* The server knows this and therefore says it, because the client cannot
|
|
14223
|
+
* safely guess: a React-Native client renders SVG and raster through two
|
|
14224
|
+
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
14225
|
+
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
14226
|
+
* placeholder glyph for every vector icon while the web build looked fine.
|
|
14227
|
+
*
|
|
14228
|
+
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
14229
|
+
* not been updated — a client that cannot determine the type should prefer
|
|
14230
|
+
* its raster path, which is the safe default for an unknown image.
|
|
14231
|
+
*/
|
|
14232
|
+
iconMediaType: string().optional(),
|
|
14233
|
+
configSchema: ConfigSchemaPassthrough$4,
|
|
14234
|
+
/**
|
|
14235
|
+
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
14236
|
+
* base URL, instance, chat, recipient). A save that changes any of them
|
|
14237
|
+
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
14238
|
+
* editor uses this to ask for the secret on exactly those edits instead of
|
|
14239
|
+
* on every edit.
|
|
14240
|
+
*
|
|
14241
|
+
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
14242
|
+
* kinds) and from a provider older than this field — an editor that finds
|
|
14243
|
+
* it absent must assume ANY edit may need the secret.
|
|
14244
|
+
*/
|
|
14245
|
+
destinationKeys: array(string()).optional(),
|
|
14246
|
+
supportsDiscovery: boolean(),
|
|
14247
|
+
/**
|
|
14248
|
+
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
14249
|
+
* Absent = none; the rule editor then offers nothing.
|
|
14250
|
+
*/
|
|
14251
|
+
deliveryParams: array(DeliveryParamSchema).optional(),
|
|
14252
|
+
caps: TargetKindCapsSchema
|
|
14253
|
+
});
|
|
14254
|
+
/**
|
|
14255
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14256
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14257
|
+
* round-trip a stored secret to the UI.
|
|
14258
|
+
*/
|
|
14259
|
+
var TargetSchema = object({
|
|
14260
|
+
id: string(),
|
|
14261
|
+
name: string(),
|
|
14262
|
+
kind: string(),
|
|
14263
|
+
addonId: string(),
|
|
14264
|
+
enabled: boolean(),
|
|
14265
|
+
config: record(string(), unknown())
|
|
14266
|
+
});
|
|
14267
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14268
|
+
var DiscoveredTargetSchema = object({
|
|
14269
|
+
kind: string(),
|
|
14270
|
+
suggestedName: string(),
|
|
14271
|
+
config: record(string(), unknown())
|
|
14272
|
+
});
|
|
14273
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14274
|
+
var RenderedAsSchema = object({
|
|
14275
|
+
level: string(),
|
|
14276
|
+
format: NotificationFormatSchema,
|
|
14277
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14278
|
+
actionsSent: number().int().nonnegative(),
|
|
14279
|
+
truncated: boolean(),
|
|
14280
|
+
dropped: array(string())
|
|
14281
|
+
});
|
|
14282
|
+
var SendResultSchema = object({
|
|
14283
|
+
success: boolean(),
|
|
14284
|
+
error: string().optional(),
|
|
14285
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14286
|
+
});
|
|
14287
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14288
|
+
var TestResultSchema = SendResultSchema;
|
|
14289
|
+
/**
|
|
14290
|
+
* Pre-save credential probe against a partial (unsaved) target config.
|
|
14291
|
+
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
14292
|
+
*/
|
|
14293
|
+
var ProbeTargetConfigResultSchema = object({
|
|
14294
|
+
ok: boolean(),
|
|
14295
|
+
resolvedUrl: string(),
|
|
14296
|
+
httpStatus: number().int().optional(),
|
|
14297
|
+
stateInstance: string().optional(),
|
|
14298
|
+
error: string().optional()
|
|
14299
|
+
});
|
|
14300
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
|
|
14301
|
+
kind: string(),
|
|
14302
|
+
config: record(string(), unknown()).optional(),
|
|
14303
|
+
/**
|
|
14304
|
+
* When editing / duplicating, the blank password field never round-trips
|
|
14305
|
+
* the stored token. Pass the source target id so the provider can restore
|
|
14306
|
+
* secrets server-side before dialling (same merge as upsert).
|
|
14307
|
+
*/
|
|
14308
|
+
targetId: string().optional()
|
|
14309
|
+
}), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
|
|
14310
|
+
kind: string(),
|
|
14311
|
+
config: record(string(), unknown()),
|
|
14312
|
+
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
14313
|
+
targetId: string().optional()
|
|
14314
|
+
}), ProbeTargetConfigResultSchema, {
|
|
14315
|
+
kind: "mutation",
|
|
14316
|
+
auth: "admin"
|
|
14317
|
+
}), method(object({
|
|
14318
|
+
targetId: string(),
|
|
14319
|
+
notification: NotificationSchema
|
|
14320
|
+
}), SendResultSchema, {
|
|
14321
|
+
kind: "mutation",
|
|
14322
|
+
auth: "admin"
|
|
14323
|
+
}), method(object({
|
|
14324
|
+
targetId: string(),
|
|
14325
|
+
sample: NotificationSchema.optional()
|
|
14326
|
+
}), TestResultSchema, {
|
|
14327
|
+
kind: "mutation",
|
|
14328
|
+
auth: "admin"
|
|
14329
|
+
}), method(object({
|
|
14330
|
+
target: TargetSchema,
|
|
14331
|
+
/**
|
|
14332
|
+
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
14333
|
+
* existing row. The UI never holds the stored token; blank / redacted
|
|
14334
|
+
* password fields are restored from this source (D634 still applies if
|
|
14335
|
+
* destinations diverge without a re-typed secret).
|
|
14336
|
+
*/
|
|
14337
|
+
cloneSecretsFrom: string().optional()
|
|
14338
|
+
}), TargetSchema, {
|
|
14339
|
+
kind: "mutation",
|
|
14340
|
+
auth: "admin"
|
|
14341
|
+
}), method(object({ targetId: string() }), _void(), {
|
|
14342
|
+
kind: "mutation",
|
|
14343
|
+
auth: "admin"
|
|
14344
|
+
}), method(object({
|
|
14345
|
+
targetId: string(),
|
|
14346
|
+
enabled: boolean()
|
|
14347
|
+
}), _void(), {
|
|
14348
|
+
kind: "mutation",
|
|
14349
|
+
auth: "admin"
|
|
14350
|
+
});
|
|
14351
|
+
looseObject({
|
|
14352
|
+
name: string().min(1),
|
|
14353
|
+
enabled: boolean().optional()
|
|
14354
|
+
});
|
|
14355
|
+
TargetSchema.omit({ id: true });
|
|
13905
14356
|
var EncodeProfileSchema = object({
|
|
13906
14357
|
video: object({
|
|
13907
14358
|
codec: _enum([
|
|
@@ -22262,7 +22713,6 @@ var SYSTEM_CAP_VOCABULARY = {
|
|
|
22262
22713
|
"calendar-source": system(INTERNAL),
|
|
22263
22714
|
calendars: system("calendars feed schedules and conditions, not device actions"),
|
|
22264
22715
|
composer: system("device composition — an authoring tool, not an action"),
|
|
22265
|
-
"connection-test": system(INTERNAL),
|
|
22266
22716
|
"core-blocks": system(INTERNAL),
|
|
22267
22717
|
"custom-model-registry": system(ML),
|
|
22268
22718
|
"data-store-provider": system(INTERNAL),
|
|
@@ -44318,427 +44768,6 @@ var UnitWarningSchema = object({
|
|
|
44318
44768
|
assumedUnit: string(),
|
|
44319
44769
|
message: string()
|
|
44320
44770
|
});
|
|
44321
|
-
/**
|
|
44322
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
44323
|
-
*
|
|
44324
|
-
* Apprise-derived model (see
|
|
44325
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
44326
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
44327
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
44328
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
44329
|
-
* message to what the kind supports — callers never special-case a service.
|
|
44330
|
-
*
|
|
44331
|
-
* DESIGN DECISIONS (locked):
|
|
44332
|
-
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
44333
|
-
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
44334
|
-
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
44335
|
-
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
44336
|
-
* alternative would fork the UI per addon and cannot host the
|
|
44337
|
-
* discovery→adopt flow.
|
|
44338
|
-
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
44339
|
-
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
44340
|
-
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
44341
|
-
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
44342
|
-
* `addonId` the generated collection router extracts from the call input.
|
|
44343
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
44344
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
44345
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
44346
|
-
* base64 fallback needed.
|
|
44347
|
-
*
|
|
44348
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
44349
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
44350
|
-
* admin "Integrations" page.
|
|
44351
|
-
*/
|
|
44352
|
-
/**
|
|
44353
|
-
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
44354
|
-
* adapter picks what it supports and the degrade engine filters the rest.
|
|
44355
|
-
*/
|
|
44356
|
-
var AttachmentMediaTypeSchema = _enum([
|
|
44357
|
-
"image",
|
|
44358
|
-
"video",
|
|
44359
|
-
"gif",
|
|
44360
|
-
"audio",
|
|
44361
|
-
"icon"
|
|
44362
|
-
]);
|
|
44363
|
-
/**
|
|
44364
|
-
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
44365
|
-
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
44366
|
-
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
44367
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
44368
|
-
*/
|
|
44369
|
-
var AttachmentSchema = object({
|
|
44370
|
-
mediaType: AttachmentMediaTypeSchema,
|
|
44371
|
-
url: string().optional(),
|
|
44372
|
-
bytes: _instanceof(Uint8Array).optional(),
|
|
44373
|
-
mime: string().optional(),
|
|
44374
|
-
name: string().optional()
|
|
44375
|
-
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
44376
|
-
var NotificationFormatSchema = _enum([
|
|
44377
|
-
"text",
|
|
44378
|
-
"markdown",
|
|
44379
|
-
"html"
|
|
44380
|
-
]);
|
|
44381
|
-
/**
|
|
44382
|
-
* The CLOSED icon vocabulary an action button may use.
|
|
44383
|
-
*
|
|
44384
|
-
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
44385
|
-
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
44386
|
-
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
44387
|
-
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
44388
|
-
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
44389
|
-
*
|
|
44390
|
-
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
44391
|
-
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
44392
|
-
* differently.
|
|
44393
|
-
*
|
|
44394
|
-
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
44395
|
-
*
|
|
44396
|
-
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
44397
|
-
* the whole set onto its own renderer's vocabulary through a
|
|
44398
|
-
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
44399
|
-
* fallback, so adding a member here fails every adapter's build until someone
|
|
44400
|
-
* decides its glyph, which is the only place that decision can be made
|
|
44401
|
-
* honestly.
|
|
44402
|
-
*
|
|
44403
|
-
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
44404
|
-
* `disarm` straight through; iOS feeds that string to
|
|
44405
|
-
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
44406
|
-
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
44407
|
-
* mapping, and "the field is documented" is not "the value renders".
|
|
44408
|
-
*
|
|
44409
|
-
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
44410
|
-
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
44411
|
-
* so an addon that emits a token the running hub does not know does not lose an
|
|
44412
|
-
* icon — its whole `send` fails Zod validation and the notification never
|
|
44413
|
-
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
44414
|
-
*/
|
|
44415
|
-
var NotificationActionIconSchema = _enum([
|
|
44416
|
-
"acknowledge",
|
|
44417
|
-
"dismiss",
|
|
44418
|
-
"silence",
|
|
44419
|
-
"snooze",
|
|
44420
|
-
"view",
|
|
44421
|
-
"play",
|
|
44422
|
-
"open",
|
|
44423
|
-
"close",
|
|
44424
|
-
"lock",
|
|
44425
|
-
"unlock",
|
|
44426
|
-
"arm",
|
|
44427
|
-
"arm-home",
|
|
44428
|
-
"arm-away",
|
|
44429
|
-
"arm-night",
|
|
44430
|
-
"disarm",
|
|
44431
|
-
"light",
|
|
44432
|
-
"alert",
|
|
44433
|
-
"camera"
|
|
44434
|
-
]);
|
|
44435
|
-
/** A single tap-through action button. */
|
|
44436
|
-
var NotificationActionSchema = object({
|
|
44437
|
-
id: string(),
|
|
44438
|
-
label: string(),
|
|
44439
|
-
url: string().optional(),
|
|
44440
|
-
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
44441
|
-
icon: NotificationActionIconSchema.optional(),
|
|
44442
|
-
/**
|
|
44443
|
-
* Renders in a warning style where the notifier supports it.
|
|
44444
|
-
*
|
|
44445
|
-
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
44446
|
-
* else — see `notification-center/action-token.ts` for what that does and
|
|
44447
|
-
* does not buy.
|
|
44448
|
-
*/
|
|
44449
|
-
destructive: boolean().optional(),
|
|
44450
|
-
/**
|
|
44451
|
-
* How the tap should REACH the url.
|
|
44452
|
-
*
|
|
44453
|
-
* `navigate` (absent, and every button authored before this field) opens it:
|
|
44454
|
-
* the phone leaves the notification and shows whatever the callback returns.
|
|
44455
|
-
* That is right for a button whose answer the operator wants to read.
|
|
44456
|
-
*
|
|
44457
|
-
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
44458
|
-
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
44459
|
-
* an answer to the notification, and being thrown into a browser tab to
|
|
44460
|
-
* confirm it costs more attention than the notification did. A backend that
|
|
44461
|
-
* cannot do a background call renders it as an ordinary link (the adapters
|
|
44462
|
-
* fall back rather than dropping the button), so this is a preference, never
|
|
44463
|
-
* a requirement.
|
|
44464
|
-
*/
|
|
44465
|
-
mode: _enum(["navigate", "background"]).optional()
|
|
44466
|
-
});
|
|
44467
|
-
/** A delivery parameter value: what a notifier declared it takes. */
|
|
44468
|
-
var DeliveryParamValueSchema = union([
|
|
44469
|
-
string(),
|
|
44470
|
-
number(),
|
|
44471
|
-
boolean()
|
|
44472
|
-
]);
|
|
44473
|
-
/**
|
|
44474
|
-
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
44475
|
-
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
44476
|
-
* never handed one. The admin UI derives its control from this descriptor —
|
|
44477
|
-
* no editor knows a service by name.
|
|
44478
|
-
*
|
|
44479
|
-
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
44480
|
-
* run on the addon cap path).
|
|
44481
|
-
*/
|
|
44482
|
-
var DeliveryParamSchema = object({
|
|
44483
|
-
key: string().min(1),
|
|
44484
|
-
label: string(),
|
|
44485
|
-
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
44486
|
-
labelKey: string().optional(),
|
|
44487
|
-
type: _enum([
|
|
44488
|
-
"enum",
|
|
44489
|
-
"number",
|
|
44490
|
-
"boolean",
|
|
44491
|
-
"string"
|
|
44492
|
-
]),
|
|
44493
|
-
/** `enum` only: the closed set of accepted values. */
|
|
44494
|
-
options: array(object({
|
|
44495
|
-
value: string(),
|
|
44496
|
-
label: string()
|
|
44497
|
-
})).optional(),
|
|
44498
|
-
/** `number` only. */
|
|
44499
|
-
min: number().optional(),
|
|
44500
|
-
max: number().optional(),
|
|
44501
|
-
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
44502
|
-
default: DeliveryParamValueSchema.optional()
|
|
44503
|
-
});
|
|
44504
|
-
/**
|
|
44505
|
-
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
44506
|
-
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
44507
|
-
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
44508
|
-
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
44509
|
-
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
44510
|
-
* `priority` for that one target.
|
|
44511
|
-
*/
|
|
44512
|
-
var NotificationSchema = object({
|
|
44513
|
-
body: string(),
|
|
44514
|
-
title: string().optional(),
|
|
44515
|
-
format: NotificationFormatSchema.default("text"),
|
|
44516
|
-
priority: number().int().min(1).max(5).default(3),
|
|
44517
|
-
level: string().optional(),
|
|
44518
|
-
attachments: array(AttachmentSchema).optional(),
|
|
44519
|
-
clickUrl: string().optional(),
|
|
44520
|
-
actions: array(NotificationActionSchema).optional(),
|
|
44521
|
-
sound: string().optional(),
|
|
44522
|
-
ttl: number().optional(),
|
|
44523
|
-
tag: string().optional(),
|
|
44524
|
-
deviceId: number().optional(),
|
|
44525
|
-
eventId: string().optional(),
|
|
44526
|
-
metadata: record(string(), unknown()).optional(),
|
|
44527
|
-
/**
|
|
44528
|
-
* Values for the parameters the target's kind DECLARES in
|
|
44529
|
-
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
44530
|
-
* declaration by the sender; a notifier reads only the keys it declared.
|
|
44531
|
-
*/
|
|
44532
|
-
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
44533
|
-
});
|
|
44534
|
-
/** One declared native severity/priority level for a kind. */
|
|
44535
|
-
var TargetKindLevelSchema = object({
|
|
44536
|
-
id: string(),
|
|
44537
|
-
label: string(),
|
|
44538
|
-
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
44539
|
-
ordinal: number().int().min(1).max(5).nullable(),
|
|
44540
|
-
flags: object({
|
|
44541
|
-
critical: boolean().optional(),
|
|
44542
|
-
silent: boolean().optional(),
|
|
44543
|
-
noPush: boolean().optional()
|
|
44544
|
-
}).optional(),
|
|
44545
|
-
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
44546
|
-
requires: array(string()).optional(),
|
|
44547
|
-
description: string().optional()
|
|
44548
|
-
});
|
|
44549
|
-
/** The full capability block consulted before dispatch. */
|
|
44550
|
-
var TargetKindCapsSchema = object({
|
|
44551
|
-
attachments: object({
|
|
44552
|
-
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
44553
|
-
mode: _enum([
|
|
44554
|
-
"url",
|
|
44555
|
-
"bytes",
|
|
44556
|
-
"both"
|
|
44557
|
-
]),
|
|
44558
|
-
max: number().int().nonnegative(),
|
|
44559
|
-
maxBytes: number().int().positive().optional()
|
|
44560
|
-
}),
|
|
44561
|
-
/** Max action buttons (0 = none). */
|
|
44562
|
-
actions: number().int().nonnegative(),
|
|
44563
|
-
/**
|
|
44564
|
-
* Whether this kind renders a per-action ICON.
|
|
44565
|
-
*
|
|
44566
|
-
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
44567
|
-
* run on the addon cap path — three production failures in one day taught
|
|
44568
|
-
* this repo that once. Absent is read as false by the degrade engine, which
|
|
44569
|
-
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
44570
|
-
* assumed and dropped costs the operator's trust in the field.
|
|
44571
|
-
*/
|
|
44572
|
-
actionIcons: boolean().optional(),
|
|
44573
|
-
levels: array(TargetKindLevelSchema),
|
|
44574
|
-
format: array(NotificationFormatSchema),
|
|
44575
|
-
clickUrl: boolean(),
|
|
44576
|
-
sound: boolean(),
|
|
44577
|
-
ttl: boolean(),
|
|
44578
|
-
bodyMaxLen: number().int().positive()
|
|
44579
|
-
});
|
|
44580
|
-
/**
|
|
44581
|
-
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
44582
|
-
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
44583
|
-
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
44584
|
-
* the union is large and not meant for runtime validation here; the exported
|
|
44585
|
-
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
44586
|
-
*/
|
|
44587
|
-
var ConfigSchemaPassthrough$4 = unknown();
|
|
44588
|
-
var TargetKindSchema = object({
|
|
44589
|
-
kind: string(),
|
|
44590
|
-
label: string(),
|
|
44591
|
-
icon: string(),
|
|
44592
|
-
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
44593
|
-
addonId: string(),
|
|
44594
|
-
/**
|
|
44595
|
-
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
44596
|
-
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
44597
|
-
* when the addon bundles no icon for that kind — the client then falls back
|
|
44598
|
-
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
44599
|
-
*
|
|
44600
|
-
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
44601
|
-
* client, and a native client joins it onto its own hub base.
|
|
44602
|
-
*
|
|
44603
|
-
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
44604
|
-
* field that survived only because the runtime cap-router forwards provider
|
|
44605
|
-
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
44606
|
-
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
44607
|
-
* broken silently the moment output validation was tightened anywhere.
|
|
44608
|
-
*/
|
|
44609
|
-
iconUrl: string().optional(),
|
|
44610
|
-
/**
|
|
44611
|
-
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
44612
|
-
*
|
|
44613
|
-
* The server knows this and therefore says it, because the client cannot
|
|
44614
|
-
* safely guess: a React-Native client renders SVG and raster through two
|
|
44615
|
-
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
44616
|
-
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
44617
|
-
* placeholder glyph for every vector icon while the web build looked fine.
|
|
44618
|
-
*
|
|
44619
|
-
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
44620
|
-
* not been updated — a client that cannot determine the type should prefer
|
|
44621
|
-
* its raster path, which is the safe default for an unknown image.
|
|
44622
|
-
*/
|
|
44623
|
-
iconMediaType: string().optional(),
|
|
44624
|
-
configSchema: ConfigSchemaPassthrough$4,
|
|
44625
|
-
/**
|
|
44626
|
-
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
44627
|
-
* base URL, instance, chat, recipient). A save that changes any of them
|
|
44628
|
-
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
44629
|
-
* editor uses this to ask for the secret on exactly those edits instead of
|
|
44630
|
-
* on every edit.
|
|
44631
|
-
*
|
|
44632
|
-
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
44633
|
-
* kinds) and from a provider older than this field — an editor that finds
|
|
44634
|
-
* it absent must assume ANY edit may need the secret.
|
|
44635
|
-
*/
|
|
44636
|
-
destinationKeys: array(string()).optional(),
|
|
44637
|
-
supportsDiscovery: boolean(),
|
|
44638
|
-
/**
|
|
44639
|
-
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
44640
|
-
* Absent = none; the rule editor then offers nothing.
|
|
44641
|
-
*/
|
|
44642
|
-
deliveryParams: array(DeliveryParamSchema).optional(),
|
|
44643
|
-
caps: TargetKindCapsSchema
|
|
44644
|
-
});
|
|
44645
|
-
/**
|
|
44646
|
-
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
44647
|
-
* (return a presence marker only) when serving `listTargets` — never
|
|
44648
|
-
* round-trip a stored secret to the UI.
|
|
44649
|
-
*/
|
|
44650
|
-
var TargetSchema = object({
|
|
44651
|
-
id: string(),
|
|
44652
|
-
name: string(),
|
|
44653
|
-
kind: string(),
|
|
44654
|
-
addonId: string(),
|
|
44655
|
-
enabled: boolean(),
|
|
44656
|
-
config: record(string(), unknown())
|
|
44657
|
-
});
|
|
44658
|
-
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
44659
|
-
var DiscoveredTargetSchema = object({
|
|
44660
|
-
kind: string(),
|
|
44661
|
-
suggestedName: string(),
|
|
44662
|
-
config: record(string(), unknown())
|
|
44663
|
-
});
|
|
44664
|
-
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
44665
|
-
var RenderedAsSchema = object({
|
|
44666
|
-
level: string(),
|
|
44667
|
-
format: NotificationFormatSchema,
|
|
44668
|
-
attachmentsSent: number().int().nonnegative(),
|
|
44669
|
-
actionsSent: number().int().nonnegative(),
|
|
44670
|
-
truncated: boolean(),
|
|
44671
|
-
dropped: array(string())
|
|
44672
|
-
});
|
|
44673
|
-
var SendResultSchema = object({
|
|
44674
|
-
success: boolean(),
|
|
44675
|
-
error: string().optional(),
|
|
44676
|
-
renderedAs: RenderedAsSchema.optional()
|
|
44677
|
-
});
|
|
44678
|
-
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
44679
|
-
var TestResultSchema = SendResultSchema;
|
|
44680
|
-
/**
|
|
44681
|
-
* Pre-save credential probe against a partial (unsaved) target config.
|
|
44682
|
-
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
44683
|
-
*/
|
|
44684
|
-
var ProbeTargetConfigResultSchema = object({
|
|
44685
|
-
ok: boolean(),
|
|
44686
|
-
resolvedUrl: string(),
|
|
44687
|
-
httpStatus: number().int().optional(),
|
|
44688
|
-
stateInstance: string().optional(),
|
|
44689
|
-
error: string().optional()
|
|
44690
|
-
});
|
|
44691
|
-
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
|
|
44692
|
-
kind: string(),
|
|
44693
|
-
config: record(string(), unknown()).optional(),
|
|
44694
|
-
/**
|
|
44695
|
-
* When editing / duplicating, the blank password field never round-trips
|
|
44696
|
-
* the stored token. Pass the source target id so the provider can restore
|
|
44697
|
-
* secrets server-side before dialling (same merge as upsert).
|
|
44698
|
-
*/
|
|
44699
|
-
targetId: string().optional()
|
|
44700
|
-
}), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
|
|
44701
|
-
kind: string(),
|
|
44702
|
-
config: record(string(), unknown()),
|
|
44703
|
-
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
44704
|
-
targetId: string().optional()
|
|
44705
|
-
}), ProbeTargetConfigResultSchema, {
|
|
44706
|
-
kind: "mutation",
|
|
44707
|
-
auth: "admin"
|
|
44708
|
-
}), method(object({
|
|
44709
|
-
targetId: string(),
|
|
44710
|
-
notification: NotificationSchema
|
|
44711
|
-
}), SendResultSchema, {
|
|
44712
|
-
kind: "mutation",
|
|
44713
|
-
auth: "admin"
|
|
44714
|
-
}), method(object({
|
|
44715
|
-
targetId: string(),
|
|
44716
|
-
sample: NotificationSchema.optional()
|
|
44717
|
-
}), TestResultSchema, {
|
|
44718
|
-
kind: "mutation",
|
|
44719
|
-
auth: "admin"
|
|
44720
|
-
}), method(object({
|
|
44721
|
-
target: TargetSchema,
|
|
44722
|
-
/**
|
|
44723
|
-
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
44724
|
-
* existing row. The UI never holds the stored token; blank / redacted
|
|
44725
|
-
* password fields are restored from this source (D634 still applies if
|
|
44726
|
-
* destinations diverge without a re-typed secret).
|
|
44727
|
-
*/
|
|
44728
|
-
cloneSecretsFrom: string().optional()
|
|
44729
|
-
}), TargetSchema, {
|
|
44730
|
-
kind: "mutation",
|
|
44731
|
-
auth: "admin"
|
|
44732
|
-
}), method(object({ targetId: string() }), _void(), {
|
|
44733
|
-
kind: "mutation",
|
|
44734
|
-
auth: "admin"
|
|
44735
|
-
}), method(object({
|
|
44736
|
-
targetId: string(),
|
|
44737
|
-
enabled: boolean()
|
|
44738
|
-
}), _void(), {
|
|
44739
|
-
kind: "mutation",
|
|
44740
|
-
auth: "admin"
|
|
44741
|
-
});
|
|
44742
44771
|
_enum([
|
|
44743
44772
|
"automation",
|
|
44744
44773
|
"action",
|
|
@@ -49278,45 +49307,6 @@ method(object({
|
|
|
49278
49307
|
kind: "mutation",
|
|
49279
49308
|
auth: "admin"
|
|
49280
49309
|
}), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
|
|
49281
|
-
var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
|
|
49282
|
-
object({
|
|
49283
|
-
outcome: literal("validated"),
|
|
49284
|
-
/** Round-trip of the sign-in, when the provider measured it. */
|
|
49285
|
-
latencyMs: number().nonnegative().optional(),
|
|
49286
|
-
/** Optional human detail worth showing next to the tick
|
|
49287
|
-
* ("3 devices visible on this account"). */
|
|
49288
|
-
detail: string().optional()
|
|
49289
|
-
}).strict(),
|
|
49290
|
-
object({
|
|
49291
|
-
outcome: literal("rejected"),
|
|
49292
|
-
error: string()
|
|
49293
|
-
}).strict(),
|
|
49294
|
-
object({
|
|
49295
|
-
outcome: literal("inconclusive"),
|
|
49296
|
-
error: string()
|
|
49297
|
-
}).strict()
|
|
49298
|
-
]);
|
|
49299
|
-
var ConnectionTestInputSchema = object({
|
|
49300
|
-
/** Candidate integration settings, exactly as the create form collected them. */
|
|
49301
|
-
settings: record(string(), unknown()) });
|
|
49302
|
-
/**
|
|
49303
|
-
* What the provider's test actually DOES, so the UI can say it in words before
|
|
49304
|
-
* the operator presses the button ("Signs in to the Dreo cloud"). Purely
|
|
49305
|
-
* descriptive — it never changes routing.
|
|
49306
|
-
*/
|
|
49307
|
-
var ConnectionTestDescriptorSchema = object({ label: string() });
|
|
49308
|
-
var connectionTestCapability = {
|
|
49309
|
-
name: "connection-test",
|
|
49310
|
-
scope: "system",
|
|
49311
|
-
mode: "collection",
|
|
49312
|
-
methods: {
|
|
49313
|
-
testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
|
|
49314
|
-
kind: "mutation",
|
|
49315
|
-
auth: "admin"
|
|
49316
|
-
}),
|
|
49317
|
-
describeTest: method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" })
|
|
49318
|
-
}
|
|
49319
|
-
};
|
|
49320
49310
|
/**
|
|
49321
49311
|
* Upstream-system connectivity sensor — distinct from `device-status`,
|
|
49322
49312
|
* which is the kernel-managed online/offline flag for the device's
|
|
@@ -56491,10 +56481,9 @@ var AvailableIntegrationTypeSchema = object({
|
|
|
56491
56481
|
* locations" checkbox. Provider-declared in the addon manifest. */
|
|
56492
56482
|
supportsLocationImport: boolean(),
|
|
56493
56483
|
/**
|
|
56494
|
-
* True when this integration
|
|
56495
|
-
*
|
|
56496
|
-
*
|
|
56497
|
-
* rather than offering a button that always answers the same nonsense.
|
|
56484
|
+
* True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
|
|
56485
|
+
* D1016). An integration that cannot be tested must say so up front rather than offering a
|
|
56486
|
+
* button that always answers the same nonsense.
|
|
56498
56487
|
*/
|
|
56499
56488
|
canTest: boolean(),
|
|
56500
56489
|
existingInstances: array(object({
|
|
@@ -56548,7 +56537,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
56548
56537
|
info: record(string(), unknown()).optional(),
|
|
56549
56538
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56550
56539
|
originStableId: string().optional(),
|
|
56551
|
-
settings: record(string(), unknown()).optional()
|
|
56540
|
+
settings: record(string(), unknown()).optional(),
|
|
56541
|
+
/** The instance kind being created, for a provider with several; omitted = its only testable kind. */
|
|
56542
|
+
kind: string().min(1).optional()
|
|
56552
56543
|
});
|
|
56553
56544
|
var UpdateIntegrationInputSchema = object({
|
|
56554
56545
|
id: string(),
|
|
@@ -56574,13 +56565,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56574
56565
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
56575
56566
|
kind: "mutation",
|
|
56576
56567
|
auth: "admin"
|
|
56577
|
-
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" })
|
|
56578
|
-
addonId: string(),
|
|
56579
|
-
settings: record(string(), unknown())
|
|
56580
|
-
}), TestConnectionResultSchema, {
|
|
56581
|
-
kind: "mutation",
|
|
56582
|
-
auth: "admin"
|
|
56583
|
-
});
|
|
56568
|
+
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
|
|
56584
56569
|
/**
|
|
56585
56570
|
* `integration-instances` - the connection of an addon that holds ONE or SEVERAL
|
|
56586
56571
|
* (an account, a relay, a destination) as typed records (D985, D986). The addon's
|
|
@@ -65323,13 +65308,6 @@ var AddBrokerInputSchema = object({
|
|
|
65323
65308
|
});
|
|
65324
65309
|
var AddBrokerResultSchema = object({ id: string() });
|
|
65325
65310
|
var IdInputSchema = object({ id: string() });
|
|
65326
|
-
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
65327
|
-
ok: literal(true),
|
|
65328
|
-
latencyMs: number()
|
|
65329
|
-
}), object({
|
|
65330
|
-
ok: literal(false),
|
|
65331
|
-
error: string()
|
|
65332
|
-
})]);
|
|
65333
65311
|
var StartEmbeddedInputSchema = object({
|
|
65334
65312
|
port: number().int().min(1).max(65535).default(1883),
|
|
65335
65313
|
/** Allow anonymous connect (no username/password). Default: false. */
|
|
@@ -65352,9 +65330,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
|
|
|
65352
65330
|
}), method(IdInputSchema, _void(), {
|
|
65353
65331
|
kind: "mutation",
|
|
65354
65332
|
auth: "admin"
|
|
65355
|
-
}), method(IdInputSchema, TestResultSchema$1, {
|
|
65356
|
-
kind: "mutation",
|
|
65357
|
-
auth: "admin"
|
|
65358
65333
|
}), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
|
|
65359
65334
|
kind: "mutation",
|
|
65360
65335
|
auth: "admin"
|
|
@@ -78461,7 +78436,7 @@ var TrainingProviderTypeSchema = object({
|
|
|
78461
78436
|
label: string(),
|
|
78462
78437
|
/** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
|
|
78463
78438
|
iconAsset: string(),
|
|
78464
|
-
/** Owning `training-provider` addon
|
|
78439
|
+
/** Owning `training-provider` addon. */
|
|
78465
78440
|
addonId: string(),
|
|
78466
78441
|
/**
|
|
78467
78442
|
* Fields for one entry of this type (credentials + defaults). Absent on a
|
|
@@ -78506,36 +78481,6 @@ var TrainingProviderDescriptorSchema = object({
|
|
|
78506
78481
|
*/
|
|
78507
78482
|
formValues: record(string(), unknown()).optional()
|
|
78508
78483
|
});
|
|
78509
|
-
/**
|
|
78510
|
-
* Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
|
|
78511
|
-
* An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
|
|
78512
|
-
* `{ $secretClear: true }` clears it.
|
|
78513
|
-
*/
|
|
78514
|
-
var TrainingProviderUpdateEntryInputSchema = object({
|
|
78515
|
-
entryId: string().min(1),
|
|
78516
|
-
name: string().min(1),
|
|
78517
|
-
tokenId: string().optional(),
|
|
78518
|
-
tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
|
|
78519
|
-
environment: string().optional(),
|
|
78520
|
-
gpuType: string().optional(),
|
|
78521
|
-
region: string().optional(),
|
|
78522
|
-
costCapUsd: number().nonnegative().optional(),
|
|
78523
|
-
maxRuntimeSec: number().int().positive().optional(),
|
|
78524
|
-
failedDatasetGraceHours: number().nonnegative().optional()
|
|
78525
|
-
});
|
|
78526
|
-
var TrainingCredentialCheckSchema = object({
|
|
78527
|
-
ok: boolean(),
|
|
78528
|
-
/** Workspace / account name, when the provider says. */
|
|
78529
|
-
account: string().optional(),
|
|
78530
|
-
reason: _enum([
|
|
78531
|
-
"missing",
|
|
78532
|
-
"invalid",
|
|
78533
|
-
"forbidden",
|
|
78534
|
-
"network",
|
|
78535
|
-
"quota"
|
|
78536
|
-
]).optional(),
|
|
78537
|
-
detail: string().optional()
|
|
78538
|
-
});
|
|
78539
78484
|
var ProviderJobStateSchema = _enum([
|
|
78540
78485
|
"pending",
|
|
78541
78486
|
"starting",
|
|
@@ -78583,22 +78528,6 @@ var TrainingLogLineSchema = object({
|
|
|
78583
78528
|
text: string()
|
|
78584
78529
|
});
|
|
78585
78530
|
method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
|
|
78586
|
-
typeId: string().min(1),
|
|
78587
|
-
name: string().min(1)
|
|
78588
|
-
}), object({ entryId: string() }), {
|
|
78589
|
-
kind: "mutation",
|
|
78590
|
-
auth: "admin"
|
|
78591
|
-
}), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
|
|
78592
|
-
kind: "mutation",
|
|
78593
|
-
auth: "admin"
|
|
78594
|
-
}), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
|
|
78595
|
-
kind: "mutation",
|
|
78596
|
-
auth: "admin"
|
|
78597
|
-
}), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
|
|
78598
|
-
kind: "mutation",
|
|
78599
|
-
auth: "admin",
|
|
78600
|
-
timeoutMs: 3e4
|
|
78601
|
-
}), method(object({
|
|
78602
78531
|
entryId: string().min(1),
|
|
78603
78532
|
gpuType: string(),
|
|
78604
78533
|
region: string(),
|
|
@@ -84051,20 +83980,6 @@ Object.freeze({
|
|
|
84051
83980
|
access: "view",
|
|
84052
83981
|
role: "admin"
|
|
84053
83982
|
},
|
|
84054
|
-
"connectionTest.describeTest": {
|
|
84055
|
-
capName: "connection-test",
|
|
84056
|
-
capScope: "system",
|
|
84057
|
-
addonId: null,
|
|
84058
|
-
access: "view",
|
|
84059
|
-
role: "admin"
|
|
84060
|
-
},
|
|
84061
|
-
"connectionTest.testSettings": {
|
|
84062
|
-
capName: "connection-test",
|
|
84063
|
-
capScope: "system",
|
|
84064
|
-
addonId: null,
|
|
84065
|
-
access: "create",
|
|
84066
|
-
role: "admin"
|
|
84067
|
-
},
|
|
84068
83983
|
"connectivity.getStatus": {
|
|
84069
83984
|
capName: "connectivity",
|
|
84070
83985
|
capScope: "device",
|
|
@@ -86431,13 +86346,6 @@ Object.freeze({
|
|
|
86431
86346
|
access: "view",
|
|
86432
86347
|
role: "admin"
|
|
86433
86348
|
},
|
|
86434
|
-
"integrations.testConnection": {
|
|
86435
|
-
capName: "integrations",
|
|
86436
|
-
capScope: "system",
|
|
86437
|
-
addonId: null,
|
|
86438
|
-
access: "create",
|
|
86439
|
-
role: "admin"
|
|
86440
|
-
},
|
|
86441
86349
|
"integrations.update": {
|
|
86442
86350
|
capName: "integrations",
|
|
86443
86351
|
capScope: "system",
|
|
@@ -87670,13 +87578,6 @@ Object.freeze({
|
|
|
87670
87578
|
access: "create",
|
|
87671
87579
|
role: "admin"
|
|
87672
87580
|
},
|
|
87673
|
-
"mqttBroker.testConnection": {
|
|
87674
|
-
capName: "mqtt-broker",
|
|
87675
|
-
capScope: "system",
|
|
87676
|
-
addonId: null,
|
|
87677
|
-
access: "create",
|
|
87678
|
-
role: "admin"
|
|
87679
|
-
},
|
|
87680
87581
|
"nativeObjectDetection.getOptions": {
|
|
87681
87582
|
capName: "native-object-detection",
|
|
87682
87583
|
capScope: "device",
|
|
@@ -92507,20 +92408,6 @@ Object.freeze({
|
|
|
92507
92408
|
access: "create",
|
|
92508
92409
|
role: "admin"
|
|
92509
92410
|
},
|
|
92510
|
-
"trainingProvider.createEntry": {
|
|
92511
|
-
capName: "training-provider",
|
|
92512
|
-
capScope: "system",
|
|
92513
|
-
addonId: null,
|
|
92514
|
-
access: "create",
|
|
92515
|
-
role: "admin"
|
|
92516
|
-
},
|
|
92517
|
-
"trainingProvider.deleteEntry": {
|
|
92518
|
-
capName: "training-provider",
|
|
92519
|
-
capScope: "system",
|
|
92520
|
-
addonId: null,
|
|
92521
|
-
access: "delete",
|
|
92522
|
-
role: "admin"
|
|
92523
|
-
},
|
|
92524
92411
|
"trainingProvider.describe": {
|
|
92525
92412
|
capName: "training-provider",
|
|
92526
92413
|
capScope: "system",
|
|
@@ -92591,13 +92478,6 @@ Object.freeze({
|
|
|
92591
92478
|
access: "create",
|
|
92592
92479
|
role: "admin"
|
|
92593
92480
|
},
|
|
92594
|
-
"trainingProvider.updateEntry": {
|
|
92595
|
-
capName: "training-provider",
|
|
92596
|
-
capScope: "system",
|
|
92597
|
-
addonId: null,
|
|
92598
|
-
access: "create",
|
|
92599
|
-
role: "admin"
|
|
92600
|
-
},
|
|
92601
92481
|
"trainingProvider.uploadDataset": {
|
|
92602
92482
|
capName: "training-provider",
|
|
92603
92483
|
capScope: "system",
|
|
@@ -92605,13 +92485,6 @@ Object.freeze({
|
|
|
92605
92485
|
access: "create",
|
|
92606
92486
|
role: "admin"
|
|
92607
92487
|
},
|
|
92608
|
-
"trainingProvider.validateCredentials": {
|
|
92609
|
-
capName: "training-provider",
|
|
92610
|
-
capScope: "system",
|
|
92611
|
-
addonId: null,
|
|
92612
|
-
access: "create",
|
|
92613
|
-
role: "admin"
|
|
92614
|
-
},
|
|
92615
92488
|
"turnProvider.getTurnServers": {
|
|
92616
92489
|
capName: "turn-provider",
|
|
92617
92490
|
capScope: "system",
|
|
@@ -122253,6 +122126,7 @@ function settingsReadOf(resolved) {
|
|
|
122253
122126
|
};
|
|
122254
122127
|
}
|
|
122255
122128
|
function buildHomematicInstances(records, deps) {
|
|
122129
|
+
const handle = records.kind(homematicConnectionsEntryKind);
|
|
122256
122130
|
return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
|
|
122257
122131
|
description: {
|
|
122258
122132
|
role: "devices",
|
|
@@ -122262,12 +122136,33 @@ function buildHomematicInstances(records, deps) {
|
|
|
122262
122136
|
},
|
|
122263
122137
|
instanceMode: "multiple",
|
|
122264
122138
|
kind: "connection",
|
|
122265
|
-
canTest:
|
|
122139
|
+
canTest: true
|
|
122266
122140
|
},
|
|
122267
122141
|
formSchema: () => buildConnectionFormSchema(),
|
|
122268
122142
|
initialBody: (name) => ({ name }),
|
|
122269
122143
|
configured: (body) => (body.host ?? "").trim().length > 0,
|
|
122270
|
-
onChanged: () => deps.onChanged()
|
|
122144
|
+
onChanged: () => deps.onChanged(),
|
|
122145
|
+
test: async ({ id, values }) => {
|
|
122146
|
+
const stored = id === null ? null : (await handle.getResolved(id))?.data ?? null;
|
|
122147
|
+
const typed = values["password"];
|
|
122148
|
+
const password = typeof typed === "string" && typed !== "" && typed !== "__camstack_redacted__" ? typed : stored?.password ?? "";
|
|
122149
|
+
const outcome = await deps.tester.testSettings({ settings: {
|
|
122150
|
+
...stored === null ? {} : connectionSettingsOf(stored),
|
|
122151
|
+
...values,
|
|
122152
|
+
password
|
|
122153
|
+
} });
|
|
122154
|
+
if (outcome.outcome === "validated") return {
|
|
122155
|
+
success: true,
|
|
122156
|
+
status: "validated",
|
|
122157
|
+
...outcome.latencyMs !== void 0 ? { latencyMs: outcome.latencyMs } : {},
|
|
122158
|
+
...outcome.detail !== void 0 ? { detail: outcome.detail } : {}
|
|
122159
|
+
};
|
|
122160
|
+
return {
|
|
122161
|
+
success: false,
|
|
122162
|
+
status: outcome.outcome,
|
|
122163
|
+
error: outcome.error
|
|
122164
|
+
};
|
|
122165
|
+
}
|
|
122271
122166
|
});
|
|
122272
122167
|
}
|
|
122273
122168
|
/** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
|
|
@@ -125609,7 +125504,6 @@ var HmClientRegistry = class {
|
|
|
125609
125504
|
};
|
|
125610
125505
|
//#endregion
|
|
125611
125506
|
//#region src/homematic-connection-test.ts
|
|
125612
|
-
var TEST_LABEL = "Asks each enabled XML-RPC interface of the CCU for its methods, and signs in to the WebUI when credentials are set";
|
|
125613
125507
|
/** How long one request to the CCU may take before the test gives up on it. */
|
|
125614
125508
|
var PROBE_TIMEOUT_MS = 5e3;
|
|
125615
125509
|
/** The ports the wrapped library binds each interface on (plain, TLS) and the path it serves. */
|
|
@@ -125763,65 +125657,62 @@ function describeSuccess(result) {
|
|
|
125763
125657
|
}
|
|
125764
125658
|
function buildHomematicConnectionTestProvider(deps) {
|
|
125765
125659
|
const { logger, probe = probeCcu } = deps;
|
|
125766
|
-
return {
|
|
125767
|
-
|
|
125768
|
-
|
|
125769
|
-
|
|
125770
|
-
|
|
125771
|
-
|
|
125772
|
-
|
|
125773
|
-
|
|
125774
|
-
|
|
125775
|
-
|
|
125776
|
-
|
|
125777
|
-
|
|
125778
|
-
|
|
125779
|
-
|
|
125780
|
-
|
|
125781
|
-
|
|
125660
|
+
return { testSettings: async ({ settings }) => {
|
|
125661
|
+
if (readHost(settings) === null) return {
|
|
125662
|
+
outcome: "rejected",
|
|
125663
|
+
error: "Enter the CCU host or IP address."
|
|
125664
|
+
};
|
|
125665
|
+
const connection = connectionFromSettings(settings);
|
|
125666
|
+
if (connection === null) return {
|
|
125667
|
+
outcome: "rejected",
|
|
125668
|
+
error: "Some of the connection settings are not valid."
|
|
125669
|
+
};
|
|
125670
|
+
const interfaces = enabledInterfaces(connection);
|
|
125671
|
+
if (interfaces.length === 0) return {
|
|
125672
|
+
outcome: "rejected",
|
|
125673
|
+
error: "Enable at least one interface."
|
|
125674
|
+
};
|
|
125675
|
+
const startedAt = Date.now();
|
|
125676
|
+
try {
|
|
125677
|
+
const result = await probe({
|
|
125678
|
+
host: connection.host,
|
|
125679
|
+
tls: connection.tls,
|
|
125680
|
+
username: connection.username,
|
|
125681
|
+
password: connection.password,
|
|
125682
|
+
interfaces
|
|
125683
|
+
});
|
|
125684
|
+
return {
|
|
125685
|
+
outcome: "validated",
|
|
125686
|
+
latencyMs: Date.now() - startedAt,
|
|
125687
|
+
detail: describeSuccess(result)
|
|
125782
125688
|
};
|
|
125783
|
-
|
|
125784
|
-
|
|
125785
|
-
|
|
125786
|
-
|
|
125787
|
-
|
|
125788
|
-
|
|
125789
|
-
|
|
125790
|
-
|
|
125791
|
-
|
|
125792
|
-
|
|
125793
|
-
|
|
125794
|
-
|
|
125795
|
-
|
|
125689
|
+
} catch (err) {
|
|
125690
|
+
const kind = err instanceof CcuProbeError ? err.kind : "other";
|
|
125691
|
+
logger.warn("Homematic connection test failed", { meta: {
|
|
125692
|
+
host: connection.host,
|
|
125693
|
+
kind,
|
|
125694
|
+
error: errMsg(err)
|
|
125695
|
+
} });
|
|
125696
|
+
switch (kind) {
|
|
125697
|
+
case "bad-credentials": return {
|
|
125698
|
+
outcome: "rejected",
|
|
125699
|
+
error: "The CCU refused the WebUI username or password."
|
|
125700
|
+
};
|
|
125701
|
+
case "not-a-ccu": return {
|
|
125702
|
+
outcome: "rejected",
|
|
125703
|
+
error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
|
|
125704
|
+
};
|
|
125705
|
+
case "unreachable": return {
|
|
125706
|
+
outcome: "inconclusive",
|
|
125707
|
+
error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
|
|
125708
|
+
};
|
|
125709
|
+
case "other": return {
|
|
125710
|
+
outcome: "inconclusive",
|
|
125711
|
+
error: `The CCU test did not finish: ${errMsg(err)}`
|
|
125796
125712
|
};
|
|
125797
|
-
} catch (err) {
|
|
125798
|
-
const kind = err instanceof CcuProbeError ? err.kind : "other";
|
|
125799
|
-
logger.warn("Homematic connection test failed", { meta: {
|
|
125800
|
-
host: connection.host,
|
|
125801
|
-
kind,
|
|
125802
|
-
error: errMsg(err)
|
|
125803
|
-
} });
|
|
125804
|
-
switch (kind) {
|
|
125805
|
-
case "bad-credentials": return {
|
|
125806
|
-
outcome: "rejected",
|
|
125807
|
-
error: "The CCU refused the WebUI username or password."
|
|
125808
|
-
};
|
|
125809
|
-
case "not-a-ccu": return {
|
|
125810
|
-
outcome: "rejected",
|
|
125811
|
-
error: `${connection.host} did not answer as a CCU3 or RaspberryMatic. Check the address.`
|
|
125812
|
-
};
|
|
125813
|
-
case "unreachable": return {
|
|
125814
|
-
outcome: "inconclusive",
|
|
125815
|
-
error: `Could not reach the CCU at ${connection.host}: ${errMsg(err)}`
|
|
125816
|
-
};
|
|
125817
|
-
case "other": return {
|
|
125818
|
-
outcome: "inconclusive",
|
|
125819
|
-
error: `The CCU test did not finish: ${errMsg(err)}`
|
|
125820
|
-
};
|
|
125821
|
-
}
|
|
125822
125713
|
}
|
|
125823
125714
|
}
|
|
125824
|
-
};
|
|
125715
|
+
} };
|
|
125825
125716
|
}
|
|
125826
125717
|
//#endregion
|
|
125827
125718
|
//#region src/homematic-integration-device-cascade.ts
|
|
@@ -125919,7 +125810,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
125919
125810
|
const records = this.ctx.records;
|
|
125920
125811
|
if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
|
|
125921
125812
|
await records.declare(homematicRecordKinds);
|
|
125922
|
-
const instances = buildHomematicInstances(records, {
|
|
125813
|
+
const instances = buildHomematicInstances(records, {
|
|
125814
|
+
onChanged: () => this.reconcileIntegrations(),
|
|
125815
|
+
tester: this.buildConnectionTestProvider()
|
|
125816
|
+
});
|
|
125923
125817
|
this.instances = instances;
|
|
125924
125818
|
this.declareRegistrySwitch({
|
|
125925
125819
|
kind: homematicConnectionsEntryKind,
|
|
@@ -125958,10 +125852,6 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
125958
125852
|
capability: deviceAdoptionCapability,
|
|
125959
125853
|
provider: this.buildAdoptionProvider()
|
|
125960
125854
|
},
|
|
125961
|
-
{
|
|
125962
|
-
capability: connectionTestCapability,
|
|
125963
|
-
provider: this.buildConnectionTestProvider()
|
|
125964
|
-
},
|
|
125965
125855
|
{
|
|
125966
125856
|
capability: addonPagesSourceCapability,
|
|
125967
125857
|
provider: this.buildPagesProvider()
|