@camstack/types 1.2.533 → 1.2.534
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 +23 -0
- package/dist/addon/base-addon.d.ts +1 -20
- package/dist/addon/notification-targets.d.ts +34 -9
- package/dist/addon.js +1 -1
- package/dist/addon.mjs +1 -1
- package/dist/capabilities/addon-settings.cap.d.ts +0 -41
- package/dist/capabilities/capability-definition.d.ts +26 -2
- package/dist/capabilities/integration-instances.cap.d.ts +22 -7
- package/dist/capabilities/integrations.cap.d.ts +13 -0
- package/dist/capabilities/smtp-provider.cap.d.ts +2 -10
- package/dist/client.js +0 -7
- package/dist/client.mjs +0 -7
- package/dist/generated/addon-api.d.ts +2 -17
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +1 -1
- package/dist/i18n/camstack-error.d.ts +8 -0
- package/dist/index.d.ts +1 -3
- package/dist/index.js +206 -70
- package/dist/index.mjs +201 -70
- package/dist/interfaces/addon.d.ts +0 -6
- package/dist/{sleep-CS5Xp1iQ.mjs → sleep-CkinsFFb.mjs} +66 -95
- package/dist/{sleep-ComzlWyT.js → sleep-DhZXJtPH.js} +77 -94
- package/package.json +1 -1
- package/dist/addon/integration-instance-ref.d.ts +0 -21
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { IntegrationInstanceRef } from '../addon/integration-instance-ref.js';
|
|
3
2
|
import type { PackageRequires } from '../addon/package-requires.js';
|
|
4
3
|
import type { ScopedSettingsDeclaration, ScopedSettingsScope } from '../addon/scoped-settings.js';
|
|
5
4
|
import type { CapabilityDefinition, InferProvider } from '../capabilities/capability-definition.js';
|
|
@@ -899,11 +898,6 @@ export interface ICamstackAddon {
|
|
|
899
898
|
*/
|
|
900
899
|
onHubReachable?(): Promise<void> | void;
|
|
901
900
|
shutdown(): Promise<void>;
|
|
902
|
-
/**
|
|
903
|
-
* The form of ONE integration instance (create wizard or edit page): the addon's per-instance
|
|
904
|
-
* schema when it declares one, else its global schema. See `BaseAddon.getIntegrationFormSchema`.
|
|
905
|
-
*/
|
|
906
|
-
getIntegrationFormSchema?(instance: IntegrationInstanceRef, nodeId?: string): Promise<ConfigUISchemaWithValues | null>;
|
|
907
901
|
/**
|
|
908
902
|
* D986: the schema one capability this addon provides declares for a settings scope
|
|
909
903
|
* (`cluster`, `node`, `device-defaults`), or `null`. See `BaseAddon.getScopedSettingsSchema`.
|
|
@@ -3309,16 +3309,6 @@ var BaseAddon = class {
|
|
|
3309
3309
|
return null;
|
|
3310
3310
|
}
|
|
3311
3311
|
/**
|
|
3312
|
-
* The form schema of ONE integration instance, or `null` to use the scoped form.
|
|
3313
|
-
*
|
|
3314
|
-
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
3315
|
-
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
3316
|
-
* SHAPE of the form only — the values live on the instance record.
|
|
3317
|
-
*/
|
|
3318
|
-
async integrationFormSchema(_instance) {
|
|
3319
|
-
return null;
|
|
3320
|
-
}
|
|
3321
|
-
/**
|
|
3322
3312
|
* D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
|
|
3323
3313
|
* provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
|
|
3324
3314
|
* declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
|
|
@@ -3346,8 +3336,7 @@ var BaseAddon = class {
|
|
|
3346
3336
|
}
|
|
3347
3337
|
/**
|
|
3348
3338
|
* The host's read of the scoped declarations: the schema one capability declares for `scope`,
|
|
3349
|
-
* or `null`.
|
|
3350
|
-
* host asks this method.
|
|
3339
|
+
* or `null`. The hook is protected, the host asks this method.
|
|
3351
3340
|
*/
|
|
3352
3341
|
async getScopedSettingsSchema(scope, cap) {
|
|
3353
3342
|
switch (scope) {
|
|
@@ -3515,22 +3504,6 @@ var BaseAddon = class {
|
|
|
3515
3504
|
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
3516
3505
|
}
|
|
3517
3506
|
/**
|
|
3518
|
-
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
3519
|
-
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
3520
|
-
*/
|
|
3521
|
-
async getIntegrationFormSchema(instance, nodeId) {
|
|
3522
|
-
const scoped = await this.integrationFormSchema(instance);
|
|
3523
|
-
if (scoped === null) return this.scopedForm(nodeId);
|
|
3524
|
-
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
3525
|
-
}
|
|
3526
|
-
/** The form of the scoped schemas this addon declared, hydrated from its store. */
|
|
3527
|
-
async scopedForm(nodeId) {
|
|
3528
|
-
await this.loadScopedSchemas();
|
|
3529
|
-
const schema = this.scopedFormSchema();
|
|
3530
|
-
if (!schema) return { sections: [] };
|
|
3531
|
-
return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
|
|
3532
|
-
}
|
|
3533
|
-
/**
|
|
3534
3507
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
3535
3508
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
3536
3509
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -3717,12 +3690,6 @@ var BaseAddon = class {
|
|
|
3717
3690
|
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
3718
3691
|
this._addonSecretTree = null;
|
|
3719
3692
|
}
|
|
3720
|
-
/** The form of an addon's scoped schemas: their sections, each shown once. */
|
|
3721
|
-
scopedFormSchema(cap) {
|
|
3722
|
-
const byId = /* @__PURE__ */ new Map();
|
|
3723
|
-
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
3724
|
-
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
3725
|
-
}
|
|
3726
3693
|
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
3727
3694
|
loadedScopedSchemas(cap) {
|
|
3728
3695
|
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
@@ -4312,6 +4279,70 @@ function normalizeAddonInitResult(result) {
|
|
|
4312
4279
|
if (Array.isArray(result)) return { providers: result };
|
|
4313
4280
|
return result;
|
|
4314
4281
|
}
|
|
4282
|
+
//#endregion
|
|
4283
|
+
//#region src/i18n/camstack-error.ts
|
|
4284
|
+
/**
|
|
4285
|
+
* A user-facing error with a STABLE code (D863).
|
|
4286
|
+
*
|
|
4287
|
+
* `message` is always the English text, so every consumer that knows nothing
|
|
4288
|
+
* of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
|
|
4289
|
+
* tRPC error formatter reads `code` + `params` and, when the request language
|
|
4290
|
+
* has a text for `server:<code>`, replaces the response `message`; the code
|
|
4291
|
+
* stays in the payload (`data.i18n`).
|
|
4292
|
+
*/
|
|
4293
|
+
/** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
|
|
4294
|
+
var ErrorCodeSchema = z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
|
|
4295
|
+
/** What travels in the error payload next to the message. */
|
|
4296
|
+
var ErrorI18nPayloadSchema = z.object({
|
|
4297
|
+
code: ErrorCodeSchema,
|
|
4298
|
+
params: z.record(z.string(), z.union([z.string(), z.number()])).optional()
|
|
4299
|
+
});
|
|
4300
|
+
var CamstackError = class extends Error {
|
|
4301
|
+
i18nCode;
|
|
4302
|
+
i18nParams;
|
|
4303
|
+
constructor(code, params, englishMessage) {
|
|
4304
|
+
super(englishMessage);
|
|
4305
|
+
this.name = "CamstackError";
|
|
4306
|
+
this.i18nCode = code;
|
|
4307
|
+
this.i18nParams = params;
|
|
4308
|
+
}
|
|
4309
|
+
};
|
|
4310
|
+
/** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
|
|
4311
|
+
function userError(code, params, englishFallback) {
|
|
4312
|
+
return new CamstackError(code, params, englishFallback);
|
|
4313
|
+
}
|
|
4314
|
+
/**
|
|
4315
|
+
* Finds a code on `err` or anywhere down its `.cause` chain. Duck-typed on
|
|
4316
|
+
* the field so it survives a module boundary (self-contained addons).
|
|
4317
|
+
*/
|
|
4318
|
+
function readErrorI18n(err) {
|
|
4319
|
+
let current = err;
|
|
4320
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
4321
|
+
if (typeof current !== "object" || current === null) return null;
|
|
4322
|
+
const code = Reflect.get(current, "i18nCode");
|
|
4323
|
+
if (typeof code === "string") {
|
|
4324
|
+
const parsed = ErrorI18nPayloadSchema.safeParse({
|
|
4325
|
+
code,
|
|
4326
|
+
params: Reflect.get(current, "i18nParams")
|
|
4327
|
+
});
|
|
4328
|
+
return parsed.success ? parsed.data : null;
|
|
4329
|
+
}
|
|
4330
|
+
const cause = Reflect.get(current, "cause");
|
|
4331
|
+
if (cause === current) return null;
|
|
4332
|
+
current = cause;
|
|
4333
|
+
}
|
|
4334
|
+
return null;
|
|
4335
|
+
}
|
|
4336
|
+
/**
|
|
4337
|
+
* A provider that refuses a caller throws an Error whose message starts with this prefix. The
|
|
4338
|
+
* class does not survive the UDS hop to a forked addon, the message does, so the hub's tRPC
|
|
4339
|
+
* error formatter answers FORBIDDEN (403) for it instead of a 500.
|
|
4340
|
+
*/
|
|
4341
|
+
var FORBIDDEN_MESSAGE_PREFIX = "forbidden: ";
|
|
4342
|
+
/** `throw forbiddenError('target not owned: tg-1')` */
|
|
4343
|
+
function forbiddenError(reason) {
|
|
4344
|
+
return /* @__PURE__ */ new Error(`${FORBIDDEN_MESSAGE_PREFIX}${reason}`);
|
|
4345
|
+
}
|
|
4315
4346
|
z.object({
|
|
4316
4347
|
field: z.string().min(1),
|
|
4317
4348
|
on: z.literal("advance")
|
|
@@ -4509,12 +4540,6 @@ function systemMethod(input, output, options) {
|
|
|
4509
4540
|
systemOnly: true
|
|
4510
4541
|
};
|
|
4511
4542
|
}
|
|
4512
|
-
/**
|
|
4513
|
-
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
4514
|
-
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
4515
|
-
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
4516
|
-
* for when this is the honest answer and when it is a soft stub.
|
|
4517
|
-
*/
|
|
4518
4543
|
function optionalMethod(input, output, options) {
|
|
4519
4544
|
return {
|
|
4520
4545
|
...method(input, output, options),
|
|
@@ -16395,60 +16420,6 @@ function isDeviceScopedCap(capName) {
|
|
|
16395
16420
|
return DEVICE_SCOPED_CAPS.has(capName);
|
|
16396
16421
|
}
|
|
16397
16422
|
//#endregion
|
|
16398
|
-
//#region src/i18n/camstack-error.ts
|
|
16399
|
-
/**
|
|
16400
|
-
* A user-facing error with a STABLE code (D863).
|
|
16401
|
-
*
|
|
16402
|
-
* `message` is always the English text, so every consumer that knows nothing
|
|
16403
|
-
* of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
|
|
16404
|
-
* tRPC error formatter reads `code` + `params` and, when the request language
|
|
16405
|
-
* has a text for `server:<code>`, replaces the response `message`; the code
|
|
16406
|
-
* stays in the payload (`data.i18n`).
|
|
16407
|
-
*/
|
|
16408
|
-
/** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
|
|
16409
|
-
var ErrorCodeSchema = z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
|
|
16410
|
-
/** What travels in the error payload next to the message. */
|
|
16411
|
-
var ErrorI18nPayloadSchema = z.object({
|
|
16412
|
-
code: ErrorCodeSchema,
|
|
16413
|
-
params: z.record(z.string(), z.union([z.string(), z.number()])).optional()
|
|
16414
|
-
});
|
|
16415
|
-
var CamstackError = class extends Error {
|
|
16416
|
-
i18nCode;
|
|
16417
|
-
i18nParams;
|
|
16418
|
-
constructor(code, params, englishMessage) {
|
|
16419
|
-
super(englishMessage);
|
|
16420
|
-
this.name = "CamstackError";
|
|
16421
|
-
this.i18nCode = code;
|
|
16422
|
-
this.i18nParams = params;
|
|
16423
|
-
}
|
|
16424
|
-
};
|
|
16425
|
-
/** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
|
|
16426
|
-
function userError(code, params, englishFallback) {
|
|
16427
|
-
return new CamstackError(code, params, englishFallback);
|
|
16428
|
-
}
|
|
16429
|
-
/**
|
|
16430
|
-
* Finds a code on `err` or anywhere down its `.cause` chain. Duck-typed on
|
|
16431
|
-
* the field so it survives a module boundary (self-contained addons).
|
|
16432
|
-
*/
|
|
16433
|
-
function readErrorI18n(err) {
|
|
16434
|
-
let current = err;
|
|
16435
|
-
for (let depth = 0; depth < 8; depth++) {
|
|
16436
|
-
if (typeof current !== "object" || current === null) return null;
|
|
16437
|
-
const code = Reflect.get(current, "i18nCode");
|
|
16438
|
-
if (typeof code === "string") {
|
|
16439
|
-
const parsed = ErrorI18nPayloadSchema.safeParse({
|
|
16440
|
-
code,
|
|
16441
|
-
params: Reflect.get(current, "i18nParams")
|
|
16442
|
-
});
|
|
16443
|
-
return parsed.success ? parsed.data : null;
|
|
16444
|
-
}
|
|
16445
|
-
const cause = Reflect.get(current, "cause");
|
|
16446
|
-
if (cause === current) return null;
|
|
16447
|
-
current = cause;
|
|
16448
|
-
}
|
|
16449
|
-
return null;
|
|
16450
|
-
}
|
|
16451
|
-
//#endregion
|
|
16452
16423
|
//#region src/util/boot-recovery-backoff.ts
|
|
16453
16424
|
/**
|
|
16454
16425
|
* The ONE retry schedule for work that can fail simply because the node was
|
|
@@ -16680,4 +16651,4 @@ function sleepCancellable(ms, signal) {
|
|
|
16680
16651
|
});
|
|
16681
16652
|
}
|
|
16682
16653
|
//#endregion
|
|
16683
|
-
export {
|
|
16654
|
+
export { DEVICE_CHILDREN_BATCH_MAX as $, collectHydratedFieldValues as $i, event as $n, RECORD_DELETE_BATCH as $r, displayUnitFor as $t, CAP_ADVANCE_FIELDS as A, RecordUniqueViolationError as Ai, SHARE_VIEW_KINDS as An, resolvedValues as Ar, CAM_PROFILE_ORDER as At, CAP_COMMAND_ORIGIN_CONTEXT_KEY as B, recordsOverMigrationApi as Bi, StoredRecordKindDeclarationSchema as Bn, REMOVE_LEAF as Br, StreamSourceEntrySchema$1 as Bt, auditedFields as C, expandAudioChunkToF32le as Ca, InvalidRecordError as Ci, PEER_BYTES_CHUNK_BYTES as Cn, collectSecretMarkerRefs as Cr, createDebugEmitter as Ct, HF_BASE_URL as D, RecordNotFoundError as Di, PeerBytesTicketSchema as Dn, SCOPED_SETTINGS_SCOPES as Dr, AudioStreamPickSchema as Dt, DEFAULT_TOKEN_EXPIRY as E, RECORDS_ERROR_CODES as Ei, PEER_BYTES_TICKET_TTL_MS as En, transformSecretWrite as Er, AudioChunkFormatSchema as Et, withoutCallerStamp as F, UnknownRecordKindError as Fi, RecordFieldPathSchema as Fn, registrySwitchToBodyId as Fr, DecodedAudioChunkSchema as Ft, readNodePin as G, defineAddonMigrations as Gi, collectZodSecretPaths as Gn, recordSecretCollection as Gr, makeSourceBrokerId as Gt, commandOrigin as H, secretsOverMigrationApi as Hi, declarationsOf as Hn, mapSecretLeaves as Hr, SubscribeAudioChunksInputSchema as Ht, customAction as I, asRecordsError as Ii, RecordIndexSchema as In, registrySwitchToBodyMigration as Ir, FrameHandleSchema as It, PipelineRunResultBridge as J, emitReadiness as Ji, DEVICE_SETTINGS_CONTRIBUTION_METHODS as Jn, RECORD_BATCH_MAX as Jr, DEFAULT_DISPLAY_PREFERENCE as Jt, toNodeId as K, runAddonMigrations as Ki, isZodSecret as Kn, recordSecretRef as Kr, parseProfileBrokerId as Kt, defineCustomActions as L, recordsErrorFromMessage as Li, RecordKindDeclarationSchema as Ln, RecordIntegrationInstances as Lr, ProfileRtspEntrySchema as Lt, CAP_NAMES as M, RevConflictError as Mi, defineEntryKind as Mn, createDurableState as Mr, CamStreamKindSchema as Mt, CAP_STATE_LEAVES as N, TransactRefusedError as Ni, entryBody as Nn, moveRegistrySwitchToBody as Nr, CamStreamResolutionSchema as Nt, HF_REPO as O, RecordSecretUnavailableError as Oi, CALLER_USERNAME_HEADER as On, nodeIdOfScopedKey as Or, BrokerStatsSchema as Ot, CALLER_STAMPED_CAPABILITIES as P, UnindexedFilterError as Pi, EntryDescriptorSchema as Pn, registrySwitchPortsOver as Pr, CameraStreamSchema as Pt, deviceOpsCapability as Q, collectHydratedFieldEntries as Qi, PROVIDER_PIN_FIELD as Qn, RECORD_DEFAULT_MAX_DATA_BYTES as Qr, baseUnitOf as Qt, describeCustomActions as R, defaultIntegrationDepsOver as Ri, RecordKindNameSchema as Rn, isInstanceEnabled as Rr, ProfileSlotSchema as Rt, createSliceHandle as S, audioChunkBytesPerSample as Sa, ForeignSecretMarkerError as Si, shortSecretRefHash as Sn, KeychainWriteRefusedError as Sr, __resetDebugInterestForTests as St, isCommand as T, PlaintextSecretError as Ti, PEER_BYTES_STALL_MS as Tn, resolveSecretMarkers as Tr, isDebugChannelName as Tt, nodePin as U, switchRecordsOverMigrationApi as Ui, defineRecordKinds as Un, parseSecretPath as Ur, SubscribeAudioChunksResultSchema as Ut, CAP_NODE_PIN_CONTEXT_KEY as V, rowsDepsOver as Vi, assertValidDeclaration as Vn, collectSecretLeaves as Vr, StreamSourceSchema as Vt, readCommandOrigin as W, AddonMigrationDefinitionError as Wi, SECRET_META as Wn, recordArrayItemPath as Wr, makeProfileBrokerId as Wt, MIGRATION_API_VERSION as X, WELL_KNOWN_TABS as Xi, HISTORY_DEFAULT_MIN_INTERVAL_MS as Xn, RECORD_CLASSES as Xr, QUANTITY_BASE as Xt, PipelineStepInputSchema as Y, isEvent as Yi, DEVICE_STATUS_METHOD as Yn, RECORD_BATCH_MAX_BYTES as Yr, DISPLAY_PREFERENCES as Yt, RawStateResultSchema as Z, WELL_KNOWN_TAB_MAP as Zi, HISTORY_UNIT_LABELS as Zn, RECORD_DATABASES as Zr, ReadingQuantitySchema as Zt, invokeTrpcLeaf as _, omitTransientConfig as _a, linksOfKind as _i, clearKnownSecrets as _n, normalizeAddonInitResult as _r, DEBUG_WATCH_HARD_CAP_MS as _t, asJsonArray as a, classifySecretWrite as aa, RECORD_SECRET_COLLECTION_PREFIX as ai, TransitionActorSchema as an, resolveCapMount as ar, findVocabAction as at, createLazyTrpcSource as b, findMigrationsBlocked as ba, DeclarationRefusedError as bi, registerKnownSecret as bn, secretTreeFromPaths as br, DebugInterest as bt, asString as c, isSecretMarker as ca, SECRET_REF_SCHEME as ci, TransitionValueSchema as cn, ErrorCodeSchema as cr, CAP_VOCABULARY_BY_NAME as ct, parseJsonUnknown as d, toSecretFieldView as da, formatSecretScope as di, createRecordsAccess as dn, forbiddenError as dr, ReadinessRegistry as dt, dehydrateConfigField as ea, RECORD_ID_MAX_LENGTH as ei, historyUnitFor as en, expandCapMethods as er, adminUiCapability as et, hfModelUrl as f, REDACTED_SECRET as fa, globalSecretScope as fi, assertTransactScope as fn, readErrorI18n as fr, ReadinessTimeoutError as ft, createDeviceProxy as g, isSecretConfigField as ga, linkField as gi, MIN_SCRUBBED_LENGTH as gn, migrationSet as gr, DEBUG_CHANNEL_PREFIX as gt, isDeviceScopedCap as h, isKeychainStoredField as ha, parseSecretRef as hi, createSecretsAccess as hn, classifyStoreError as hr, scopeKey as ht, asBoolean as i, SECRET_CLEAR as ia, RECORD_QUERY_MAX as ii, TransitionActorKindSchema as in, optionalMethod as ir, allVocabActions as it, CAP_METHOD_TIMEOUTS_MS as j, RecordsError as ji, DisposerChain as jn, normalizeNodeId as jr, CamProfileSchema as jt, RUNTIME_DEFAULTS as k, RecordTooLargeError as ki, DATAPLANE_SECRET_HEADER as kn, resolveDeviceSettings as kr, BrokerStatusSchema as kt, parseJsonArray as l, isSecretMarkerLike as la, arrayItemFieldPath as li, CommandOriginClaimSchema as ln, ErrorI18nPayloadSchema as lr, t as lt, DEVICE_SCOPED_CAPS as m, collectSecretConfigKeys as ma, normalizeSecretOwner as mi, REVALIDATE_AFTER_MS as mn, BaseAddon as mr, readinessKey as mt, sleepCancellable as n, hydrateSchema as na, RECORD_MAX_INDEXES as ni, readingMeta as nn, isDeviceConfigCap as nr, addonPagesSourceCapability as nt, asJsonObject as o, isSecretClear as oa, RECORD_SETTINGS_MAX_ROWS as oi, TransitionCommandSchema as on, systemMethod as or, vocabActionIdFor as ot, BOOT_RECOVERY_BACKOFF_MS as p, collectKeychainStoredKeys as pa, isSecretRef as pi, resolveSecretViewsIn as pn, userError as pr, emitDownForOwnedCaps as pt, viewerUiCapability as q, createEvent as qi, DEFAULT_RUNTIME_STATE_DURABILITY as qn, secretArrayPrefixes as qr, selectAssignedProfileSlots as qt, maskUrlCredentials as r, resolveHydratedFieldValue as ra, RECORD_MAX_INDEX_FIELDS as ri, DeviceTransitionSchema as rn, method as rr, actionEffect as rt, asNumber as s, isSecretFieldView as sa, RECORD_SWEEP_INTERVAL_MS as si, TransitionOutcomeSchema as sn, CamstackError as sr, CAP_VOCABULARY as st, sleep as t, dehydrateSchema as ta, RECORD_MAX_DATA_BYTES as ti, isReadingQuantity as tn, historyItemFieldPath as tr, AddonPageDeclarationSchema as tt, parseJsonObject as u, makeSecretMarker as ua, buildSecretRef as ui, makeInMemoryRecords as un, FORBIDDEN_MESSAGE_PREFIX as ur, MODEL_FORMATS as ut, addonSliceHandleApi as v, schemaDeclaresAnyField as va, optionalLinkField as vi, forgetKnownSecret as vn, mergeSecretStatePaths as vr, DEBUG_WATCH_REARM_EVERY_MS as vt, commandEffect as w, isAudioChunkFormat as wa, NoCallerError as wi, PEER_BYTES_MAX_OUTSTANDING as wn, isSecretRefOwnedBy as wr, getDebugInterest as wt, createMirrorSource as x, AUDIO_CHUNK_FORMATS as xa, FilterRequiredError as xi, scrubKnownSecrets as xn, secretTreeFromSchema as xr, DebugWatchTable as xt, createEventBusSliceSource as y, AddonMigrationsBlockedError as ya, BatchTooLargeError as yi, knownSecretCount as yn, parseSecretStatePath as yr, DEBUG_WATCH_WINDOW_MS as yt, deviceCustomAction as z, integrationRowsApiOver as zi, RecordRetentionSchema as zn, secretViewsOf as zr, ProfileSlotStatusSchema as zt };
|
|
@@ -3309,16 +3309,6 @@ var BaseAddon = class {
|
|
|
3309
3309
|
return null;
|
|
3310
3310
|
}
|
|
3311
3311
|
/**
|
|
3312
|
-
* The form schema of ONE integration instance, or `null` to use the scoped form.
|
|
3313
|
-
*
|
|
3314
|
-
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
3315
|
-
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
3316
|
-
* SHAPE of the form only — the values live on the instance record.
|
|
3317
|
-
*/
|
|
3318
|
-
async integrationFormSchema(_instance) {
|
|
3319
|
-
return null;
|
|
3320
|
-
}
|
|
3321
|
-
/**
|
|
3322
3312
|
* D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
|
|
3323
3313
|
* provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
|
|
3324
3314
|
* declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
|
|
@@ -3346,8 +3336,7 @@ var BaseAddon = class {
|
|
|
3346
3336
|
}
|
|
3347
3337
|
/**
|
|
3348
3338
|
* The host's read of the scoped declarations: the schema one capability declares for `scope`,
|
|
3349
|
-
* or `null`.
|
|
3350
|
-
* host asks this method.
|
|
3339
|
+
* or `null`. The hook is protected, the host asks this method.
|
|
3351
3340
|
*/
|
|
3352
3341
|
async getScopedSettingsSchema(scope, cap) {
|
|
3353
3342
|
switch (scope) {
|
|
@@ -3515,22 +3504,6 @@ var BaseAddon = class {
|
|
|
3515
3504
|
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
3516
3505
|
}
|
|
3517
3506
|
/**
|
|
3518
|
-
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
3519
|
-
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
3520
|
-
*/
|
|
3521
|
-
async getIntegrationFormSchema(instance, nodeId) {
|
|
3522
|
-
const scoped = await this.integrationFormSchema(instance);
|
|
3523
|
-
if (scoped === null) return this.scopedForm(nodeId);
|
|
3524
|
-
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
3525
|
-
}
|
|
3526
|
-
/** The form of the scoped schemas this addon declared, hydrated from its store. */
|
|
3527
|
-
async scopedForm(nodeId) {
|
|
3528
|
-
await this.loadScopedSchemas();
|
|
3529
|
-
const schema = this.scopedFormSchema();
|
|
3530
|
-
if (!schema) return { sections: [] };
|
|
3531
|
-
return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
|
|
3532
|
-
}
|
|
3533
|
-
/**
|
|
3534
3507
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
3535
3508
|
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
3536
3509
|
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
@@ -3717,12 +3690,6 @@ var BaseAddon = class {
|
|
|
3717
3690
|
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
3718
3691
|
this._addonSecretTree = null;
|
|
3719
3692
|
}
|
|
3720
|
-
/** The form of an addon's scoped schemas: their sections, each shown once. */
|
|
3721
|
-
scopedFormSchema(cap) {
|
|
3722
|
-
const byId = /* @__PURE__ */ new Map();
|
|
3723
|
-
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
3724
|
-
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
3725
|
-
}
|
|
3726
3693
|
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
3727
3694
|
loadedScopedSchemas(cap) {
|
|
3728
3695
|
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
@@ -4312,6 +4279,70 @@ function normalizeAddonInitResult(result) {
|
|
|
4312
4279
|
if (Array.isArray(result)) return { providers: result };
|
|
4313
4280
|
return result;
|
|
4314
4281
|
}
|
|
4282
|
+
//#endregion
|
|
4283
|
+
//#region src/i18n/camstack-error.ts
|
|
4284
|
+
/**
|
|
4285
|
+
* A user-facing error with a STABLE code (D863).
|
|
4286
|
+
*
|
|
4287
|
+
* `message` is always the English text, so every consumer that knows nothing
|
|
4288
|
+
* of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
|
|
4289
|
+
* tRPC error formatter reads `code` + `params` and, when the request language
|
|
4290
|
+
* has a text for `server:<code>`, replaces the response `message`; the code
|
|
4291
|
+
* stays in the payload (`data.i18n`).
|
|
4292
|
+
*/
|
|
4293
|
+
/** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
|
|
4294
|
+
var ErrorCodeSchema = zod.z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
|
|
4295
|
+
/** What travels in the error payload next to the message. */
|
|
4296
|
+
var ErrorI18nPayloadSchema = zod.z.object({
|
|
4297
|
+
code: ErrorCodeSchema,
|
|
4298
|
+
params: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.number()])).optional()
|
|
4299
|
+
});
|
|
4300
|
+
var CamstackError = class extends Error {
|
|
4301
|
+
i18nCode;
|
|
4302
|
+
i18nParams;
|
|
4303
|
+
constructor(code, params, englishMessage) {
|
|
4304
|
+
super(englishMessage);
|
|
4305
|
+
this.name = "CamstackError";
|
|
4306
|
+
this.i18nCode = code;
|
|
4307
|
+
this.i18nParams = params;
|
|
4308
|
+
}
|
|
4309
|
+
};
|
|
4310
|
+
/** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
|
|
4311
|
+
function userError(code, params, englishFallback) {
|
|
4312
|
+
return new CamstackError(code, params, englishFallback);
|
|
4313
|
+
}
|
|
4314
|
+
/**
|
|
4315
|
+
* Finds a code on `err` or anywhere down its `.cause` chain. Duck-typed on
|
|
4316
|
+
* the field so it survives a module boundary (self-contained addons).
|
|
4317
|
+
*/
|
|
4318
|
+
function readErrorI18n(err) {
|
|
4319
|
+
let current = err;
|
|
4320
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
4321
|
+
if (typeof current !== "object" || current === null) return null;
|
|
4322
|
+
const code = Reflect.get(current, "i18nCode");
|
|
4323
|
+
if (typeof code === "string") {
|
|
4324
|
+
const parsed = ErrorI18nPayloadSchema.safeParse({
|
|
4325
|
+
code,
|
|
4326
|
+
params: Reflect.get(current, "i18nParams")
|
|
4327
|
+
});
|
|
4328
|
+
return parsed.success ? parsed.data : null;
|
|
4329
|
+
}
|
|
4330
|
+
const cause = Reflect.get(current, "cause");
|
|
4331
|
+
if (cause === current) return null;
|
|
4332
|
+
current = cause;
|
|
4333
|
+
}
|
|
4334
|
+
return null;
|
|
4335
|
+
}
|
|
4336
|
+
/**
|
|
4337
|
+
* A provider that refuses a caller throws an Error whose message starts with this prefix. The
|
|
4338
|
+
* class does not survive the UDS hop to a forked addon, the message does, so the hub's tRPC
|
|
4339
|
+
* error formatter answers FORBIDDEN (403) for it instead of a 500.
|
|
4340
|
+
*/
|
|
4341
|
+
var FORBIDDEN_MESSAGE_PREFIX = "forbidden: ";
|
|
4342
|
+
/** `throw forbiddenError('target not owned: tg-1')` */
|
|
4343
|
+
function forbiddenError(reason) {
|
|
4344
|
+
return /* @__PURE__ */ new Error(`${FORBIDDEN_MESSAGE_PREFIX}${reason}`);
|
|
4345
|
+
}
|
|
4315
4346
|
zod.z.object({
|
|
4316
4347
|
field: zod.z.string().min(1),
|
|
4317
4348
|
on: zod.z.literal("advance")
|
|
@@ -4509,12 +4540,6 @@ function systemMethod(input, output, options) {
|
|
|
4509
4540
|
systemOnly: true
|
|
4510
4541
|
};
|
|
4511
4542
|
}
|
|
4512
|
-
/**
|
|
4513
|
-
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
4514
|
-
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
4515
|
-
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
4516
|
-
* for when this is the honest answer and when it is a soft stub.
|
|
4517
|
-
*/
|
|
4518
4543
|
function optionalMethod(input, output, options) {
|
|
4519
4544
|
return {
|
|
4520
4545
|
...method(input, output, options),
|
|
@@ -16395,60 +16420,6 @@ function isDeviceScopedCap(capName) {
|
|
|
16395
16420
|
return DEVICE_SCOPED_CAPS.has(capName);
|
|
16396
16421
|
}
|
|
16397
16422
|
//#endregion
|
|
16398
|
-
//#region src/i18n/camstack-error.ts
|
|
16399
|
-
/**
|
|
16400
|
-
* A user-facing error with a STABLE code (D863).
|
|
16401
|
-
*
|
|
16402
|
-
* `message` is always the English text, so every consumer that knows nothing
|
|
16403
|
-
* of codes (old clients, logs, the mesh) behaves exactly as before. The hub's
|
|
16404
|
-
* tRPC error formatter reads `code` + `params` and, when the request language
|
|
16405
|
-
* has a text for `server:<code>`, replaces the response `message`; the code
|
|
16406
|
-
* stays in the payload (`data.i18n`).
|
|
16407
|
-
*/
|
|
16408
|
-
/** Dotted lower-case code, e.g. `auth.invalid-credentials`. It is the key in the `server` catalog. */
|
|
16409
|
-
var ErrorCodeSchema = zod.z.string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/);
|
|
16410
|
-
/** What travels in the error payload next to the message. */
|
|
16411
|
-
var ErrorI18nPayloadSchema = zod.z.object({
|
|
16412
|
-
code: ErrorCodeSchema,
|
|
16413
|
-
params: zod.z.record(zod.z.string(), zod.z.union([zod.z.string(), zod.z.number()])).optional()
|
|
16414
|
-
});
|
|
16415
|
-
var CamstackError = class extends Error {
|
|
16416
|
-
i18nCode;
|
|
16417
|
-
i18nParams;
|
|
16418
|
-
constructor(code, params, englishMessage) {
|
|
16419
|
-
super(englishMessage);
|
|
16420
|
-
this.name = "CamstackError";
|
|
16421
|
-
this.i18nCode = code;
|
|
16422
|
-
this.i18nParams = params;
|
|
16423
|
-
}
|
|
16424
|
-
};
|
|
16425
|
-
/** `throw userError('device.not-found', { id }, 'Device 12 not found')` */
|
|
16426
|
-
function userError(code, params, englishFallback) {
|
|
16427
|
-
return new CamstackError(code, params, englishFallback);
|
|
16428
|
-
}
|
|
16429
|
-
/**
|
|
16430
|
-
* Finds a code on `err` or anywhere down its `.cause` chain. Duck-typed on
|
|
16431
|
-
* the field so it survives a module boundary (self-contained addons).
|
|
16432
|
-
*/
|
|
16433
|
-
function readErrorI18n(err) {
|
|
16434
|
-
let current = err;
|
|
16435
|
-
for (let depth = 0; depth < 8; depth++) {
|
|
16436
|
-
if (typeof current !== "object" || current === null) return null;
|
|
16437
|
-
const code = Reflect.get(current, "i18nCode");
|
|
16438
|
-
if (typeof code === "string") {
|
|
16439
|
-
const parsed = ErrorI18nPayloadSchema.safeParse({
|
|
16440
|
-
code,
|
|
16441
|
-
params: Reflect.get(current, "i18nParams")
|
|
16442
|
-
});
|
|
16443
|
-
return parsed.success ? parsed.data : null;
|
|
16444
|
-
}
|
|
16445
|
-
const cause = Reflect.get(current, "cause");
|
|
16446
|
-
if (cause === current) return null;
|
|
16447
|
-
current = cause;
|
|
16448
|
-
}
|
|
16449
|
-
return null;
|
|
16450
|
-
}
|
|
16451
|
-
//#endregion
|
|
16452
16423
|
//#region src/util/boot-recovery-backoff.ts
|
|
16453
16424
|
/**
|
|
16454
16425
|
* The ONE retry schedule for work that can fail simply because the node was
|
|
@@ -16980,6 +16951,12 @@ Object.defineProperty(exports, "ErrorI18nPayloadSchema", {
|
|
|
16980
16951
|
return ErrorI18nPayloadSchema;
|
|
16981
16952
|
}
|
|
16982
16953
|
});
|
|
16954
|
+
Object.defineProperty(exports, "FORBIDDEN_MESSAGE_PREFIX", {
|
|
16955
|
+
enumerable: true,
|
|
16956
|
+
get: function() {
|
|
16957
|
+
return FORBIDDEN_MESSAGE_PREFIX;
|
|
16958
|
+
}
|
|
16959
|
+
});
|
|
16983
16960
|
Object.defineProperty(exports, "FilterRequiredError", {
|
|
16984
16961
|
enumerable: true,
|
|
16985
16962
|
get: function() {
|
|
@@ -17838,6 +17815,12 @@ Object.defineProperty(exports, "findVocabAction", {
|
|
|
17838
17815
|
return findVocabAction;
|
|
17839
17816
|
}
|
|
17840
17817
|
});
|
|
17818
|
+
Object.defineProperty(exports, "forbiddenError", {
|
|
17819
|
+
enumerable: true,
|
|
17820
|
+
get: function() {
|
|
17821
|
+
return forbiddenError;
|
|
17822
|
+
}
|
|
17823
|
+
});
|
|
17841
17824
|
Object.defineProperty(exports, "forgetKnownSecret", {
|
|
17842
17825
|
enumerable: true,
|
|
17843
17826
|
get: function() {
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
/**
|
|
3
|
-
* Which integration instance a settings form is for. An addon that serves several instances
|
|
4
|
-
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
5
|
-
* needs its connection, the default integration needs the addon's own sections.
|
|
6
|
-
*
|
|
7
|
-
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
8
|
-
* setting up a NEW instance.
|
|
9
|
-
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
10
|
-
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
11
|
-
*/
|
|
12
|
-
export declare const IntegrationInstanceRefSchema: z.ZodObject<{
|
|
13
|
-
integrationId: z.ZodNullable<z.ZodString>;
|
|
14
|
-
mode: z.ZodEnum<{
|
|
15
|
-
account: "account";
|
|
16
|
-
broker: "broker";
|
|
17
|
-
standalone: "standalone";
|
|
18
|
-
}>;
|
|
19
|
-
candidateStableId: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
export type IntegrationInstanceRef = z.infer<typeof IntegrationInstanceRefSchema>;
|