@camstack/server 1.2.841 → 1.2.843
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/api/oauth2/oauth2-routes.js +50 -6
- package/dist/core/addon/addon-registry.service.js +4 -0
- package/dist/core/addon/addon-route-request.js +18 -0
- package/dist/main.js +8 -5
- package/package.json +9 -18
- package/system/dist/addon-routes/addon-route-registry.d.ts +27 -1
- package/system/dist/addon-runner.js +3 -1
- package/system/dist/addon-runner.mjs +3 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +21 -7
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +21 -7
- package/system/dist/builtins/local-auth/oauth-grants.d.ts +9 -1
- package/system/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -0
- package/system/dist/builtins/local-auth/record-kinds.d.ts +2 -0
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-CGU4rnN-.js → capture-engine-BT9BCK3T.js} +1 -1
- package/system/dist/{capture-engine-CLrh3FG0.mjs → capture-engine-DIevRhU_.mjs} +1 -1
- package/system/dist/{composition-sources-bhWIz4Rp.js → composition-sources-BANqJW1j.js} +1 -1
- package/system/dist/{composition-sources-CoLbBru1.mjs → composition-sources-ByiNqtqC.mjs} +1 -1
- package/system/dist/{constants-DZwpZY5J.js → constants-6l3U2agy.js} +1 -1
- package/system/dist/{constants-CfAS4Qm6.mjs → constants-B7ZCfRiI.mjs} +1 -1
- package/system/dist/{device-ca-ksS811fC.js → device-ca-B6x-SNd5.js} +1 -1
- package/system/dist/{device-ca-CAbEBLyf.mjs → device-ca-BRzIzcHo.mjs} +1 -1
- package/system/dist/{dist-ByiDJLen.mjs → dist-CIih-HqD.mjs} +712 -84
- package/system/dist/{dist-DlRUArVs.js → dist-WNMdvnXD.js} +717 -83
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-Bh28ooQx.mjs → hub-identity-0E4bXr1T.mjs} +1 -1
- package/system/dist/{hub-identity-C-1NeWlr.js → hub-identity-DNHQmALh.js} +1 -1
- package/system/dist/{hub-mdns-ciao-OWO6Bw-X.mjs → hub-mdns-ciao-0pnoEm4s.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-CL-Z9yMs.js → hub-mdns-ciao-CbIiNR-t.js} +2 -2
- package/system/dist/index.d.ts +1 -1
- package/system/dist/index.js +55 -9
- package/system/dist/index.mjs +54 -10
- package/system/dist/kernel/moleculer/child-addon-call-dispatch.d.ts +1 -0
- package/system/dist/{legacy-integration-rows-door-Be_QKUlY.mjs → legacy-integration-rows-door-BQKvWTO6.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-CDPH26e8.js → legacy-integration-rows-door-Bb04BZ2c.js} +1 -1
- package/system/dist/{rename-composition-block-Bs5KT3Gn.js → rename-composition-block-CQAUtljP.js} +1 -1
- package/system/dist/{rename-composition-block-CncvFIHl.mjs → rename-composition-block-DF8RskLi.mjs} +1 -1
- package/system/dist/{restore-archive-CHUKcl3T.js → restore-archive-B2HPMYjR.js} +1 -1
- package/system/dist/{restore-archive-DX7kK3LQ.mjs → restore-archive-D1N1Ef6G.mjs} +82 -82
- package/system/dist/{wal-maintenance-Fibm7rsM.mjs → wal-maintenance-BgZyg4QK.mjs} +0 -0
- package/system/dist/{wal-maintenance-GNE9Oqdu.js → wal-maintenance-CCaPLd9x.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1243,7 +1243,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1243
1243
|
*/
|
|
1244
1244
|
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
1245
1245
|
//#endregion
|
|
1246
|
-
//#region ../types/dist/sleep-
|
|
1246
|
+
//#region ../types/dist/sleep-D0roI_CZ.mjs
|
|
1247
1247
|
/**
|
|
1248
1248
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1249
1249
|
* window to float samples (D455).
|
|
@@ -12508,6 +12508,10 @@ Object.freeze({
|
|
|
12508
12508
|
"path": "lastEvent.eventType",
|
|
12509
12509
|
"valueType": "string"
|
|
12510
12510
|
},
|
|
12511
|
+
{
|
|
12512
|
+
"path": "lastEvent.sourceId",
|
|
12513
|
+
"valueType": "string"
|
|
12514
|
+
},
|
|
12511
12515
|
{
|
|
12512
12516
|
"path": "lastEvent.timestamp",
|
|
12513
12517
|
"valueType": "number"
|
|
@@ -17259,6 +17263,21 @@ function describeUnmet(unmet) {
|
|
|
17259
17263
|
}
|
|
17260
17264
|
}
|
|
17261
17265
|
/**
|
|
17266
|
+
* The integration instance of an addon, as it appears in an address or on an
|
|
17267
|
+
* OAuth link (planning#415, D1046).
|
|
17268
|
+
*
|
|
17269
|
+
* The DEFAULT instance has two spellings on the wire and one in the code: a
|
|
17270
|
+
* path with no instance segment and a link with no instance both mean it, and
|
|
17271
|
+
* its id is the addon id. {@link oauthLinkServesInstance} is the one
|
|
17272
|
+
* comparison a per-instance route is meant to call, so nobody compares
|
|
17273
|
+
* `undefined` with an id. The Alexa export's routes are its first caller.
|
|
17274
|
+
*/
|
|
17275
|
+
/** An instance id as it may appear in a path or a query: no separator, no escape, bounded. */
|
|
17276
|
+
var ADDON_INSTANCE_ID_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
17277
|
+
function isAddonInstanceId(value) {
|
|
17278
|
+
return ADDON_INSTANCE_ID_RE.test(value);
|
|
17279
|
+
}
|
|
17280
|
+
/**
|
|
17262
17281
|
* notification-output — canonical, capability-gated notification delivery.
|
|
17263
17282
|
*
|
|
17264
17283
|
* Apprise-derived model (see
|
|
@@ -43177,6 +43196,41 @@ function anySubjectMatches(subjects, observed) {
|
|
|
43177
43196
|
reason: subjects.length === 1 ? lastReason : `none of [${subjects.map(describeSubject).join(", ")}] matches (${observed.className || "unknown"})`
|
|
43178
43197
|
};
|
|
43179
43198
|
}
|
|
43199
|
+
var EventVocabularyKindSchema = zod.z.enum([
|
|
43200
|
+
"press",
|
|
43201
|
+
"long-press",
|
|
43202
|
+
"long-press-start",
|
|
43203
|
+
"release",
|
|
43204
|
+
"repeat",
|
|
43205
|
+
"double-press",
|
|
43206
|
+
"other"
|
|
43207
|
+
]);
|
|
43208
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
43209
|
+
var EventVocabularySourceSchema = zod.z.object({
|
|
43210
|
+
id: zod.z.string().min(1),
|
|
43211
|
+
label: zod.z.string().min(1)
|
|
43212
|
+
});
|
|
43213
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
43214
|
+
var EventVocabularyFieldSchema = zod.z.object({
|
|
43215
|
+
path: zod.z.string().min(1),
|
|
43216
|
+
kind: zod.z.enum([
|
|
43217
|
+
"string",
|
|
43218
|
+
"number",
|
|
43219
|
+
"boolean",
|
|
43220
|
+
"enum"
|
|
43221
|
+
]),
|
|
43222
|
+
enumValues: zod.z.array(zod.z.string()).optional(),
|
|
43223
|
+
label: zod.z.string().min(1).optional()
|
|
43224
|
+
});
|
|
43225
|
+
var EventVocabularyEntrySchema = zod.z.object({
|
|
43226
|
+
/** The native token, verbatim. */
|
|
43227
|
+
id: zod.z.string().min(1),
|
|
43228
|
+
source: EventVocabularySourceSchema.optional(),
|
|
43229
|
+
label: zod.z.string().min(1),
|
|
43230
|
+
description: zod.z.string().optional(),
|
|
43231
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
43232
|
+
payload: zod.z.array(EventVocabularyFieldSchema).optional()
|
|
43233
|
+
});
|
|
43180
43234
|
/**
|
|
43181
43235
|
* Where the sun is, from a latitude and a longitude — the one solar
|
|
43182
43236
|
* calculation in the repo. Compact NOAA sunrise equation (accurate to about a
|
|
@@ -43645,6 +43699,33 @@ var ScheduleLeafSchema = zod.z.object({
|
|
|
43645
43699
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
43646
43700
|
cron: zod.z.string().min(1).max(120).optional()
|
|
43647
43701
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
43702
|
+
/**
|
|
43703
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
43704
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
43705
|
+
*/
|
|
43706
|
+
var DeviceFiredMatchSchema = zod.z.object({
|
|
43707
|
+
path: zod.z.string().min(1).max(120),
|
|
43708
|
+
equals: zod.z.union([
|
|
43709
|
+
zod.z.string(),
|
|
43710
|
+
zod.z.number(),
|
|
43711
|
+
zod.z.boolean()
|
|
43712
|
+
])
|
|
43713
|
+
});
|
|
43714
|
+
/**
|
|
43715
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
43716
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
43717
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
43718
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
43719
|
+
*/
|
|
43720
|
+
var DeviceFiredLeafSchema = zod.z.object({
|
|
43721
|
+
kind: zod.z.literal("device-fired"),
|
|
43722
|
+
...eventLeafId,
|
|
43723
|
+
deviceId: zod.z.number().int().nonnegative(),
|
|
43724
|
+
eventIds: zod.z.array(zod.z.string().min(1)).min(1).max(64).optional(),
|
|
43725
|
+
sourceIds: zod.z.array(zod.z.string().min(1)).min(1).max(64).optional(),
|
|
43726
|
+
kinds: zod.z.array(EventVocabularyKindSchema).min(1).optional(),
|
|
43727
|
+
match: zod.z.array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
43728
|
+
});
|
|
43648
43729
|
var ManualLeafSchema = zod.z.object({
|
|
43649
43730
|
kind: zod.z.literal("manual"),
|
|
43650
43731
|
...eventLeafId
|
|
@@ -43786,6 +43867,7 @@ var AutomationWhenSchema = zod.z.lazy(() => zod.z.discriminatedUnion("kind", [
|
|
|
43786
43867
|
}),
|
|
43787
43868
|
DeviceBecomesLeafSchema,
|
|
43788
43869
|
DeviceEventLeafSchema,
|
|
43870
|
+
DeviceFiredLeafSchema,
|
|
43789
43871
|
ScheduleLeafSchema,
|
|
43790
43872
|
ManualLeafSchema,
|
|
43791
43873
|
IntervalLeafSchema,
|
|
@@ -43800,6 +43882,7 @@ var AutomationWhenSchema = zod.z.lazy(() => zod.z.discriminatedUnion("kind", [
|
|
|
43800
43882
|
var EVENT_KINDS = new Set([
|
|
43801
43883
|
"device-becomes",
|
|
43802
43884
|
"device-event",
|
|
43885
|
+
"device-fired",
|
|
43803
43886
|
"schedule",
|
|
43804
43887
|
"manual",
|
|
43805
43888
|
"interval",
|
|
@@ -43884,6 +43967,7 @@ function hasEmptyContainer(node) {
|
|
|
43884
43967
|
var LEAF_WORDS = {
|
|
43885
43968
|
"device-becomes": "a device value that becomes",
|
|
43886
43969
|
"device-event": "a device event",
|
|
43970
|
+
"device-fired": "a device firing an event",
|
|
43887
43971
|
schedule: "a schedule",
|
|
43888
43972
|
manual: "a manual run",
|
|
43889
43973
|
interval: "an interval",
|
|
@@ -44149,9 +44233,12 @@ function convertLegacyWhen(half) {
|
|
|
44149
44233
|
* every caller — automations, Actions, and the notification centre, which runs
|
|
44150
44234
|
* only Actions (planning#473).
|
|
44151
44235
|
*/
|
|
44236
|
+
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
44237
|
+
var WAIT_MAX_SECONDS = 3600;
|
|
44238
|
+
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
44152
44239
|
var AutomationWaitStepSchema = zod.z.object({
|
|
44153
44240
|
kind: zod.z.literal("wait"),
|
|
44154
|
-
seconds: zod.z.number().min(0).max(
|
|
44241
|
+
seconds: zod.z.number().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
44155
44242
|
});
|
|
44156
44243
|
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
44157
44244
|
var LegacyStepDeviceSchema = zod.z.union([
|
|
@@ -44281,20 +44368,210 @@ var ActionStepSchema = zod.z.discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
|
44281
44368
|
path: ["if"]
|
|
44282
44369
|
});
|
|
44283
44370
|
});
|
|
44371
|
+
/**
|
|
44372
|
+
* Flow control of an AUTOMATION's list (#500). A standalone list (an action, a
|
|
44373
|
+
* scheduler point, a preset) stays `wait` and `cap`: it has no run of its own
|
|
44374
|
+
* to end and no variable bag to write.
|
|
44375
|
+
*/
|
|
44376
|
+
var continueOnErrorShape = {
|
|
44377
|
+
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
44378
|
+
continueOnError: zod.z.literal(true).optional() };
|
|
44379
|
+
/** An automation's cap step: the shared guarded cap step, plus `continueOnError`. */
|
|
44380
|
+
var AutomationGuardedCapStepSchema = AutomationCapStepBaseSchema.extend({
|
|
44381
|
+
...stepGuardShape,
|
|
44382
|
+
...continueOnErrorShape
|
|
44383
|
+
}).refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
44384
|
+
message: "a cap step needs a target",
|
|
44385
|
+
path: ["target"]
|
|
44386
|
+
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44387
|
+
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44388
|
+
path: ["actionId"]
|
|
44389
|
+
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44390
|
+
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
44391
|
+
var AutomationStopStepSchema = zod.z.object({
|
|
44392
|
+
kind: zod.z.literal("stop"),
|
|
44393
|
+
reason: zod.z.string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
44394
|
+
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
44395
|
+
outcome: zod.z.enum(["ok", "failed"]),
|
|
44396
|
+
/** Stop only when this reads true; false or unknown does not stop. */
|
|
44397
|
+
if: AutomationWhenSchema.optional()
|
|
44398
|
+
});
|
|
44399
|
+
var SET_VAR_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]{0,39}$/;
|
|
44400
|
+
/** Names the run itself writes and reads (`leaf` is what `triggered-by` judges): a step may not overwrite them. */
|
|
44401
|
+
var RESERVED_RUN_VARS = [
|
|
44402
|
+
"kind",
|
|
44403
|
+
"leaf",
|
|
44404
|
+
"at"
|
|
44405
|
+
];
|
|
44406
|
+
/**
|
|
44407
|
+
* Write variables into the run's bag, for the steps after it. SUBSTITUTION
|
|
44408
|
+
* only, never evaluation: a text value may carry `{{vars.x}}` slots.
|
|
44409
|
+
*/
|
|
44410
|
+
var AutomationSetStepSchema = zod.z.object({
|
|
44411
|
+
kind: zod.z.literal("set"),
|
|
44412
|
+
vars: zod.z.record(zod.z.string(), zod.z.union([
|
|
44413
|
+
zod.z.string().max(500),
|
|
44414
|
+
zod.z.number(),
|
|
44415
|
+
zod.z.boolean()
|
|
44416
|
+
])).refine((vars) => Object.keys(vars).every((name) => SET_VAR_NAME_RE.test(name)), { message: "a variable name is letters, digits and _, not starting with a digit (max 40)" }).refine((vars) => Object.keys(vars).length >= 1, { message: "set needs at least one variable" }).refine((vars) => Object.keys(vars).length <= 20, { message: `set holds at most 20 variables` }).refine((vars) => Object.keys(vars).every((name) => !RESERVED_RUN_VARS.includes(name)), { message: `the names ${RESERVED_RUN_VARS.join(", ")} belong to the run and cannot be set` }),
|
|
44417
|
+
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
44418
|
+
if: AutomationWhenSchema.optional()
|
|
44419
|
+
});
|
|
44420
|
+
var AutomationRunActionStepSchema = zod.z.object({
|
|
44421
|
+
kind: zod.z.literal("action"),
|
|
44422
|
+
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
44423
|
+
actionId: zod.z.string().min(1),
|
|
44424
|
+
/** Values for the action's declared variables; the others take their default. */
|
|
44425
|
+
variables: zod.z.record(zod.z.string(), zod.z.union([
|
|
44426
|
+
zod.z.string(),
|
|
44427
|
+
zod.z.number(),
|
|
44428
|
+
zod.z.boolean()
|
|
44429
|
+
])).optional(),
|
|
44430
|
+
...continueOnErrorShape
|
|
44431
|
+
});
|
|
44432
|
+
/**
|
|
44433
|
+
* A step INSIDE a branch of a `choose`: a flow step with no condition of its
|
|
44434
|
+
* own (the branch is the condition) and no block inside it. Strict, so an `if`
|
|
44435
|
+
* written on such a step is refused rather than dropped.
|
|
44436
|
+
*/
|
|
44437
|
+
/** The longest a `wait-until` may wait: six hours. */
|
|
44438
|
+
var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
44439
|
+
/**
|
|
44440
|
+
* Pause the run until a condition is true (#500). The timeout is mandatory: a
|
|
44441
|
+
* run never waits without an end. `onTimeout` says what a wait that ran out
|
|
44442
|
+
* does: `continue` goes on to the next step, `stop` ends the run as a failure.
|
|
44443
|
+
* A condition that cannot be read is not "true": the wait goes on (D49).
|
|
44444
|
+
*/
|
|
44445
|
+
var AutomationWaitUntilStepSchema = zod.z.object({
|
|
44446
|
+
kind: zod.z.literal("wait-until"),
|
|
44447
|
+
when: AutomationWhenSchema,
|
|
44448
|
+
timeoutS: zod.z.number().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
|
|
44449
|
+
onTimeout: zod.z.enum(["continue", "stop"])
|
|
44450
|
+
}).strict();
|
|
44451
|
+
/** The step kinds that hold steps of their own, or pause on a condition: they nest two levels at most. */
|
|
44452
|
+
var BLOCK_STEP_KINDS = [
|
|
44453
|
+
"choose",
|
|
44454
|
+
"repeat",
|
|
44455
|
+
"parallel",
|
|
44456
|
+
"wait-until"
|
|
44457
|
+
];
|
|
44458
|
+
var NEST_TOO_DEEP = `steps nest two levels at most: a step inside a nested choose or repeat can be a plain step only`;
|
|
44459
|
+
function kindOf(input) {
|
|
44460
|
+
return typeof input === "object" && input !== null ? Reflect.get(input, "kind") : void 0;
|
|
44461
|
+
}
|
|
44462
|
+
/** Where the nesting ends, a block step is refused in words rather than as an unknown kind. */
|
|
44463
|
+
function nestTooDeep(issue) {
|
|
44464
|
+
const kind = kindOf(issue.input);
|
|
44465
|
+
return typeof kind === "string" && BLOCK_STEP_KINDS.includes(kind) ? NEST_TOO_DEEP : void 0;
|
|
44466
|
+
}
|
|
44467
|
+
var plainStepSchemas = [
|
|
44468
|
+
AutomationWaitStepSchema.strict(),
|
|
44469
|
+
AutomationCapStepBaseSchema.extend(continueOnErrorShape).strict().refine((step) => step.target !== void 0 || step.deviceId !== void 0, {
|
|
44470
|
+
message: "a cap step needs a target",
|
|
44471
|
+
path: ["target"]
|
|
44472
|
+
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44473
|
+
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44474
|
+
path: ["actionId"]
|
|
44475
|
+
}),
|
|
44476
|
+
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
44477
|
+
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
44478
|
+
AutomationRunActionStepSchema.strict()
|
|
44479
|
+
];
|
|
44480
|
+
/**
|
|
44481
|
+
* A plain step: a flow step with no condition of its own and no step inside
|
|
44482
|
+
* it. The second (last) level of nesting holds these only.
|
|
44483
|
+
*/
|
|
44484
|
+
var AutomationBranchStepSchema = zod.z.discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
44485
|
+
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
44486
|
+
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "cap" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
44487
|
+
/**
|
|
44488
|
+
* Several steps at once (#500): all are started together and all are awaited.
|
|
44489
|
+
* A failure fails the run once the others finished, as in a sequence; a member
|
|
44490
|
+
* marked "continue if this fails" does not.
|
|
44491
|
+
*/
|
|
44492
|
+
var AutomationParallelStepSchema = zod.z.object({
|
|
44493
|
+
kind: zod.z.literal("parallel"),
|
|
44494
|
+
steps: zod.z.array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
44495
|
+
}).strict();
|
|
44496
|
+
var REPEAT_NEEDS_MAX = "a repeat on a condition needs a maximum number of iterations";
|
|
44497
|
+
/** A loop on a condition: the bound is mandatory, so a run never loops without an end. */
|
|
44498
|
+
var repeatConditionShape = {
|
|
44499
|
+
when: AutomationWhenSchema,
|
|
44500
|
+
maxIterations: zod.z.number({ error: REPEAT_NEEDS_MAX }).int().min(1, REPEAT_NEEDS_MAX).max(50, `a repeat on a condition runs at most 50 times`),
|
|
44501
|
+
/** A pause between two iterations, never after the last. */
|
|
44502
|
+
waitS: zod.z.number().int().min(1).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG).optional()
|
|
44503
|
+
};
|
|
44504
|
+
/** What decides how many times a `repeat` runs. */
|
|
44505
|
+
var AutomationRepeatLoopSchema = zod.z.discriminatedUnion("by", [
|
|
44506
|
+
zod.z.object({
|
|
44507
|
+
by: zod.z.literal("count"),
|
|
44508
|
+
count: zod.z.number().int().min(1).max(20, `a repeat runs at most 20 times`)
|
|
44509
|
+
}).strict(),
|
|
44510
|
+
zod.z.object({
|
|
44511
|
+
by: zod.z.literal("while"),
|
|
44512
|
+
...repeatConditionShape
|
|
44513
|
+
}).strict(),
|
|
44514
|
+
zod.z.object({
|
|
44515
|
+
by: zod.z.literal("until"),
|
|
44516
|
+
...repeatConditionShape
|
|
44517
|
+
}).strict(),
|
|
44518
|
+
zod.z.object({
|
|
44519
|
+
by: zod.z.literal("forEach"),
|
|
44520
|
+
target: zod.z.object({
|
|
44521
|
+
kind: zod.z.literal("devices"),
|
|
44522
|
+
ids: zod.z.array(zod.z.number().int()).min(1, "a repeat over devices needs at least one device").max(50, `a repeat over devices takes at most 50 devices`)
|
|
44523
|
+
}).strict()
|
|
44524
|
+
}).strict()
|
|
44525
|
+
]);
|
|
44526
|
+
/**
|
|
44527
|
+
* The same steps several times (#500). Every form is bounded at save, so a
|
|
44528
|
+
* run cannot loop without an end. A failure or a `stop` in the steps ends the
|
|
44529
|
+
* loop and the run, as in a sequence.
|
|
44530
|
+
*/
|
|
44531
|
+
function repeatSchemaOf(step) {
|
|
44532
|
+
return zod.z.object({
|
|
44533
|
+
kind: zod.z.literal("repeat"),
|
|
44534
|
+
loop: AutomationRepeatLoopSchema,
|
|
44535
|
+
steps: zod.z.array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
44536
|
+
}).strict();
|
|
44537
|
+
}
|
|
44538
|
+
/**
|
|
44539
|
+
* One step, several ways (#500): the branches are read in order and the FIRST
|
|
44540
|
+
* whose condition is true runs; `else` runs when every branch is false. A
|
|
44541
|
+
* branch that cannot be read ends the choice: nothing runs, not the branches
|
|
44542
|
+
* after it and not the else (D49). The #472 `if` / `else` of a wait or cap
|
|
44543
|
+
* step is the one-branch case and stays as it is stored.
|
|
44544
|
+
*/
|
|
44545
|
+
function chooseSchemaOf(step) {
|
|
44546
|
+
const steps = zod.z.array(step).max(10);
|
|
44547
|
+
return zod.z.object({
|
|
44548
|
+
kind: zod.z.literal("choose"),
|
|
44549
|
+
branches: zod.z.array(zod.z.object({
|
|
44550
|
+
if: AutomationWhenSchema,
|
|
44551
|
+
steps: steps.min(1, "a branch needs at least one step")
|
|
44552
|
+
})).min(1, "a choose needs at least one branch").max(6, `a choose takes at most 6 branches`),
|
|
44553
|
+
else: steps.optional()
|
|
44554
|
+
});
|
|
44555
|
+
}
|
|
44556
|
+
var AutomationBodyStepSchema = zod.z.discriminatedUnion("kind", [
|
|
44557
|
+
...plainStepSchemas,
|
|
44558
|
+
AutomationWaitUntilStepSchema,
|
|
44559
|
+
AutomationParallelStepSchema,
|
|
44560
|
+
chooseSchemaOf(AutomationBranchStepSchema),
|
|
44561
|
+
repeatSchemaOf(AutomationBranchStepSchema)
|
|
44562
|
+
]);
|
|
44563
|
+
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
44564
|
+
var AutomationChooseStepSchema = chooseSchemaOf(AutomationBodyStepSchema);
|
|
44284
44565
|
var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
|
|
44285
44566
|
GuardedWaitStepSchema,
|
|
44286
|
-
|
|
44287
|
-
|
|
44288
|
-
|
|
44289
|
-
|
|
44290
|
-
|
|
44291
|
-
|
|
44292
|
-
|
|
44293
|
-
|
|
44294
|
-
zod.z.number(),
|
|
44295
|
-
zod.z.boolean()
|
|
44296
|
-
])).optional()
|
|
44297
|
-
}),
|
|
44567
|
+
AutomationGuardedCapStepSchema,
|
|
44568
|
+
AutomationStopStepSchema,
|
|
44569
|
+
AutomationSetStepSchema,
|
|
44570
|
+
AutomationChooseStepSchema,
|
|
44571
|
+
AutomationWaitUntilStepSchema,
|
|
44572
|
+
AutomationParallelStepSchema,
|
|
44573
|
+
AutomationRepeatStepSchema,
|
|
44574
|
+
AutomationRunActionStepSchema,
|
|
44298
44575
|
zod.z.object({
|
|
44299
44576
|
kind: zod.z.literal("code"),
|
|
44300
44577
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
@@ -44357,11 +44634,6 @@ function convertLegacyRecipe(legacy) {
|
|
|
44357
44634
|
...rest
|
|
44358
44635
|
};
|
|
44359
44636
|
}
|
|
44360
|
-
/**
|
|
44361
|
-
* Where recipes are PARSED (the core-blocks cap, the MCP tool, the literal a
|
|
44362
|
-
* saved block carries): the new shape as it is, or the old shape converted to
|
|
44363
|
-
* it. The output type is always the new one.
|
|
44364
|
-
*/
|
|
44365
44637
|
var AutomationRecipeSchema = zod.z.union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
44366
44638
|
/**
|
|
44367
44639
|
* A daily window as a STATE: is this instant inside it, and when does that
|
|
@@ -45032,6 +45304,16 @@ var BECOMES_DESCRIPTIONS = {
|
|
|
45032
45304
|
from: "the value before the change, empty when it is not known",
|
|
45033
45305
|
to: "the value it changed to"
|
|
45034
45306
|
};
|
|
45307
|
+
/**
|
|
45308
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
45309
|
+
* those names depend on the device, so they are not in this list.
|
|
45310
|
+
*/
|
|
45311
|
+
var FIRED_DESCRIPTIONS = {
|
|
45312
|
+
deviceId: "the device that fired",
|
|
45313
|
+
eventType: "the event, as the device names it",
|
|
45314
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
45315
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
45316
|
+
};
|
|
45035
45317
|
function describe$1(descriptions) {
|
|
45036
45318
|
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45037
45319
|
name,
|
|
@@ -45040,12 +45322,74 @@ function describe$1(descriptions) {
|
|
|
45040
45322
|
}
|
|
45041
45323
|
describe$1(DETECTION_DESCRIPTIONS);
|
|
45042
45324
|
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45325
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45326
|
+
...v,
|
|
45327
|
+
hintKey: "firedDeviceId"
|
|
45328
|
+
} : v);
|
|
45043
45329
|
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45044
45330
|
...v,
|
|
45045
45331
|
hintKey: "becomesDeviceId"
|
|
45046
45332
|
} : v);
|
|
45047
45333
|
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45048
45334
|
/**
|
|
45335
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
45336
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
45337
|
+
* (NO normalization). Two shapes:
|
|
45338
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
45339
|
+
* declared set (e.g. press_short, press_long, …).
|
|
45340
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
45341
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
45342
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
45343
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
45344
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
45345
|
+
* vocabulary declares sources (a remote's buttons).
|
|
45346
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
45347
|
+
*/
|
|
45348
|
+
var EventFireSchema = zod.z.object({
|
|
45349
|
+
deviceId: zod.z.number(),
|
|
45350
|
+
eventType: zod.z.string(),
|
|
45351
|
+
sourceId: zod.z.string().optional(),
|
|
45352
|
+
data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
45353
|
+
timestamp: zod.z.number().meta(readingMeta("none")),
|
|
45354
|
+
seq: zod.z.number().meta(readingMeta("count"))
|
|
45355
|
+
});
|
|
45356
|
+
var EventEmitterStatusSchema = zod.z.object({
|
|
45357
|
+
eventTypes: zod.z.array(zod.z.string()),
|
|
45358
|
+
/**
|
|
45359
|
+
* Required of a provider by the type. A status written before the field
|
|
45360
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
45361
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
45362
|
+
*/
|
|
45363
|
+
vocabulary: zod.z.array(EventVocabularyEntrySchema).default([]),
|
|
45364
|
+
lastEvent: EventFireSchema.nullable(),
|
|
45365
|
+
eventCountSinceStart: zod.z.number().meta(readingMeta("count"))
|
|
45366
|
+
});
|
|
45367
|
+
var eventEmitterCapability = {
|
|
45368
|
+
name: "event-emitter",
|
|
45369
|
+
scope: "device",
|
|
45370
|
+
deviceNative: true,
|
|
45371
|
+
mode: "singleton",
|
|
45372
|
+
deviceTypes: [DeviceType.EventEmitter],
|
|
45373
|
+
methods: {},
|
|
45374
|
+
events: { onEvent: { data: EventFireSchema } },
|
|
45375
|
+
status: {
|
|
45376
|
+
schema: EventEmitterStatusSchema,
|
|
45377
|
+
kind: "push"
|
|
45378
|
+
},
|
|
45379
|
+
runtimeState: EventEmitterStatusSchema,
|
|
45380
|
+
/**
|
|
45381
|
+
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
45382
|
+
*
|
|
45383
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
45384
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
45385
|
+
*/
|
|
45386
|
+
durability: "session",
|
|
45387
|
+
/**
|
|
45388
|
+
* History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
|
|
45389
|
+
*/
|
|
45390
|
+
history: "none"
|
|
45391
|
+
};
|
|
45392
|
+
/**
|
|
45049
45393
|
* Save-time check of a `when` tree against the SITE: a `time-is` window
|
|
45050
45394
|
* bounded by a sun event needs the site location, and any window needs a known
|
|
45051
45395
|
* time zone. Refused before the save with a typed reason — at run time the
|
|
@@ -45125,12 +45469,16 @@ var HoldOverrideSchema = zod.z.discriminatedUnion("mode", [zod.z.object({ mode:
|
|
|
45125
45469
|
var DEFAULT_HOLD_OVERRIDE = { mode: "respect" };
|
|
45126
45470
|
/** A missed edge up to this late still runs. */
|
|
45127
45471
|
var DEFAULT_MAX_LATE_MS = 10 * 6e4;
|
|
45472
|
+
var SchedulerStepSchema = ActionStepSchema.refine((step) => step.kind !== "wait" || step.seconds <= 300, {
|
|
45473
|
+
message: `a scheduler point waits at most five minutes (300 s); put a longer wait in an action`,
|
|
45474
|
+
path: ["seconds"]
|
|
45475
|
+
});
|
|
45128
45476
|
var SchedulerPointSchema = zod.z.object({
|
|
45129
45477
|
id: zod.z.string().min(1).max(64),
|
|
45130
45478
|
at: SchedulerTimeSpecSchema,
|
|
45131
45479
|
mode: SchedulerPointModeSchema,
|
|
45132
45480
|
/** The actions of an `edge` or `hold`; a `release` has none. */
|
|
45133
|
-
steps: zod.z.array(
|
|
45481
|
+
steps: zod.z.array(SchedulerStepSchema).max(20).default([]),
|
|
45134
45482
|
/** Checked when the point runs (an edge) or is applied (a hold). */
|
|
45135
45483
|
conditions: SchedulerStateTreeSchema.optional(),
|
|
45136
45484
|
/** Hold only; absent means `respect`. */
|
|
@@ -45432,6 +45780,7 @@ var AutomationConditionTraceNodeSchema = zod.z.object({
|
|
|
45432
45780
|
"triggered-by",
|
|
45433
45781
|
"device-becomes",
|
|
45434
45782
|
"device-event",
|
|
45783
|
+
"device-fired",
|
|
45435
45784
|
"schedule",
|
|
45436
45785
|
"interval",
|
|
45437
45786
|
"manual",
|
|
@@ -45502,18 +45851,46 @@ var StepTraceBaseSchema = zod.z.object({
|
|
|
45502
45851
|
]).optional(),
|
|
45503
45852
|
/** Why the condition read what it read, in the evaluator's own words. */
|
|
45504
45853
|
conditionReason: zod.z.string().optional(),
|
|
45505
|
-
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. */
|
|
45854
|
+
/** `empty`: the target resolved to no device, so nothing was done — never silently `ok`. `skipped`: its `if` was false (or unknown) and nothing ran in its place. `failed-continued`: it failed and was marked to be passed over (#500). */
|
|
45506
45855
|
outcome: zod.z.enum([
|
|
45507
45856
|
"ok",
|
|
45508
45857
|
"error",
|
|
45509
45858
|
"not-run",
|
|
45510
45859
|
"empty",
|
|
45511
|
-
"skipped"
|
|
45860
|
+
"skipped",
|
|
45861
|
+
"failed-continued",
|
|
45862
|
+
"timed-out"
|
|
45512
45863
|
]),
|
|
45513
45864
|
message: zod.z.string().optional()
|
|
45514
45865
|
});
|
|
45866
|
+
/** What a block step adds to its row: which list ran, what each branch read, how many rounds. */
|
|
45867
|
+
var blockTraceShape = {
|
|
45868
|
+
/** A `choose` step (#500): the list that ran, `branches.<n>` or `else`. Absent when none did. */
|
|
45869
|
+
branch: zod.z.string().optional(),
|
|
45870
|
+
/** A `choose` step: what each branch read, in order, up to the one that decided. */
|
|
45871
|
+
branchChecks: zod.z.array(zod.z.object({
|
|
45872
|
+
condition: zod.z.enum([
|
|
45873
|
+
"true",
|
|
45874
|
+
"false",
|
|
45875
|
+
"unknown"
|
|
45876
|
+
]),
|
|
45877
|
+
conditionReason: zod.z.string().optional()
|
|
45878
|
+
})).optional(),
|
|
45879
|
+
/** A `repeat` step (#500): how many times its steps ran. */
|
|
45880
|
+
iterations: zod.z.number().int().optional()
|
|
45881
|
+
};
|
|
45882
|
+
/** A step one level down: it may be a block step itself, whose own steps are plain rows (the nesting ends there). */
|
|
45883
|
+
var NestedStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45884
|
+
...blockTraceShape,
|
|
45885
|
+
steps: zod.z.array(StepTraceBaseSchema).optional()
|
|
45886
|
+
});
|
|
45515
45887
|
/** A step trace; the `else` steps that ran are one level of the same shape (the nesting is bounded at one). */
|
|
45516
|
-
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45888
|
+
var AutomationStepTraceSchema = StepTraceBaseSchema.extend({
|
|
45889
|
+
else: zod.z.array(StepTraceBaseSchema).optional(),
|
|
45890
|
+
...blockTraceShape,
|
|
45891
|
+
/** A `choose` step: the steps of the list that ran. A `parallel`: its members. A `repeat`: the LAST iteration. */
|
|
45892
|
+
steps: zod.z.array(NestedStepTraceSchema).optional()
|
|
45893
|
+
});
|
|
45517
45894
|
var AutomationRunTraceSchema = zod.z.object({
|
|
45518
45895
|
runId: zod.z.string().min(1),
|
|
45519
45896
|
startedAt: zod.z.number(),
|
|
@@ -45882,6 +46259,46 @@ async function evaluateStepCondition(when, fetchers, now = Date.now, history, si
|
|
|
45882
46259
|
reason: first ?? "the condition does not hold"
|
|
45883
46260
|
};
|
|
45884
46261
|
}
|
|
46262
|
+
/**
|
|
46263
|
+
* Read the branches in order and stop at the first that decides: `true` runs
|
|
46264
|
+
* it, `unknown` ends the choice with nothing run (D49). All `false` runs the
|
|
46265
|
+
* else list, when there is one.
|
|
46266
|
+
*/
|
|
46267
|
+
async function readChoose(choose) {
|
|
46268
|
+
const checks = [];
|
|
46269
|
+
for (const [index, branch] of choose.branches.entries()) {
|
|
46270
|
+
const verdict = await readGuard(branch.guard);
|
|
46271
|
+
checks.push({
|
|
46272
|
+
condition: verdict.result,
|
|
46273
|
+
conditionReason: verdict.reason
|
|
46274
|
+
});
|
|
46275
|
+
if (verdict.result === "true") return {
|
|
46276
|
+
checks,
|
|
46277
|
+
decision: {
|
|
46278
|
+
kind: "run",
|
|
46279
|
+
branch: `branches.${index}`,
|
|
46280
|
+
steps: branch.steps
|
|
46281
|
+
}
|
|
46282
|
+
};
|
|
46283
|
+
if (verdict.result === "unknown") return {
|
|
46284
|
+
checks,
|
|
46285
|
+
decision: {
|
|
46286
|
+
kind: "unknown",
|
|
46287
|
+
index,
|
|
46288
|
+
reason: verdict.reason
|
|
46289
|
+
}
|
|
46290
|
+
};
|
|
46291
|
+
}
|
|
46292
|
+
const otherwise = choose.otherwise ?? [];
|
|
46293
|
+
return {
|
|
46294
|
+
checks,
|
|
46295
|
+
decision: otherwise.length === 0 ? { kind: "none" } : {
|
|
46296
|
+
kind: "run",
|
|
46297
|
+
branch: "else",
|
|
46298
|
+
steps: otherwise
|
|
46299
|
+
}
|
|
46300
|
+
};
|
|
46301
|
+
}
|
|
45885
46302
|
function errorMessage(err) {
|
|
45886
46303
|
return err instanceof Error ? err.message : String(err);
|
|
45887
46304
|
}
|
|
@@ -45896,17 +46313,105 @@ async function readGuard(guard) {
|
|
|
45896
46313
|
};
|
|
45897
46314
|
}
|
|
45898
46315
|
}
|
|
46316
|
+
/** A loop condition that throws ends the loop as unreadable, never a crash of the run. */
|
|
46317
|
+
async function readRepeatCheck(check, iteration) {
|
|
46318
|
+
if (check === void 0) return { go: true };
|
|
46319
|
+
try {
|
|
46320
|
+
return await check(iteration);
|
|
46321
|
+
} catch (err) {
|
|
46322
|
+
return {
|
|
46323
|
+
go: false,
|
|
46324
|
+
reason: `the condition could not be read: ${errorMessage(err)}`,
|
|
46325
|
+
unknown: true
|
|
46326
|
+
};
|
|
46327
|
+
}
|
|
46328
|
+
}
|
|
46329
|
+
/** Run a loop's steps until its count, its condition, its bound, a failure, a stop or an abort ends it. */
|
|
46330
|
+
async function runRepeat(repeat, options, path) {
|
|
46331
|
+
let iterations = 0;
|
|
46332
|
+
let last;
|
|
46333
|
+
for (;;) {
|
|
46334
|
+
if (options.isAborted()) return {
|
|
46335
|
+
iterations,
|
|
46336
|
+
last,
|
|
46337
|
+
timedOut: false
|
|
46338
|
+
};
|
|
46339
|
+
const before = await readRepeatCheck(repeat.before, iterations);
|
|
46340
|
+
if (!before.go) return {
|
|
46341
|
+
iterations,
|
|
46342
|
+
last,
|
|
46343
|
+
ended: before.reason,
|
|
46344
|
+
timedOut: false,
|
|
46345
|
+
...before.unknown === true ? { unknown: before.reason } : {}
|
|
46346
|
+
};
|
|
46347
|
+
if (iterations >= repeat.limit) return repeat.limitIsTimeout ? {
|
|
46348
|
+
iterations,
|
|
46349
|
+
last,
|
|
46350
|
+
ended: `stopped at ${repeat.limit} iterations`,
|
|
46351
|
+
timedOut: true
|
|
46352
|
+
} : {
|
|
46353
|
+
iterations,
|
|
46354
|
+
last,
|
|
46355
|
+
ended: "",
|
|
46356
|
+
timedOut: false
|
|
46357
|
+
};
|
|
46358
|
+
last = await runSteps(repeat.steps, {
|
|
46359
|
+
...options,
|
|
46360
|
+
pathPrefix: `${path}.steps`,
|
|
46361
|
+
indexOffset: 0
|
|
46362
|
+
});
|
|
46363
|
+
iterations += 1;
|
|
46364
|
+
if (last.failed || last.aborted || last.stopped !== void 0) return {
|
|
46365
|
+
iterations,
|
|
46366
|
+
last,
|
|
46367
|
+
timedOut: false
|
|
46368
|
+
};
|
|
46369
|
+
const after = await readRepeatCheck(repeat.after, iterations - 1);
|
|
46370
|
+
if (!after.go) return {
|
|
46371
|
+
iterations,
|
|
46372
|
+
last,
|
|
46373
|
+
ended: after.reason,
|
|
46374
|
+
timedOut: false,
|
|
46375
|
+
...after.unknown === true ? { unknown: after.reason } : {}
|
|
46376
|
+
};
|
|
46377
|
+
if (repeat.between !== void 0 && iterations < repeat.limit) await repeat.between();
|
|
46378
|
+
}
|
|
46379
|
+
}
|
|
45899
46380
|
/** The else level of a trace is one level deep: a nested trace carries no `else` of its own. */
|
|
45900
46381
|
function withoutElse(trace) {
|
|
45901
46382
|
const { else: _else, ...rest } = trace;
|
|
45902
46383
|
return rest;
|
|
45903
46384
|
}
|
|
46385
|
+
/** A plain row: the last level of a trace carries no list of its own. */
|
|
46386
|
+
function plainRow(trace) {
|
|
46387
|
+
const { else: _else, steps: _steps, ...rest } = trace;
|
|
46388
|
+
return rest;
|
|
46389
|
+
}
|
|
46390
|
+
/** A row one level down: it keeps its own steps as plain rows, and no `else`. */
|
|
46391
|
+
function withoutNested(trace) {
|
|
46392
|
+
const { else: _else, steps, ...rest } = trace;
|
|
46393
|
+
return steps === void 0 ? rest : {
|
|
46394
|
+
...rest,
|
|
46395
|
+
steps: steps.map(plainRow)
|
|
46396
|
+
};
|
|
46397
|
+
}
|
|
45904
46398
|
async function runSteps(steps, options) {
|
|
45905
46399
|
const traces = [];
|
|
45906
46400
|
let failed = false;
|
|
45907
46401
|
let aborted = false;
|
|
45908
|
-
|
|
46402
|
+
let stopped;
|
|
46403
|
+
for (const [position, step] of steps.entries()) {
|
|
46404
|
+
const index = position + (options.indexOffset ?? 0);
|
|
45909
46405
|
const path = `${options.pathPrefix}.${index}`;
|
|
46406
|
+
if (stopped !== void 0) {
|
|
46407
|
+
traces.push({
|
|
46408
|
+
...step.meta,
|
|
46409
|
+
path,
|
|
46410
|
+
outcome: "not-run",
|
|
46411
|
+
message: `stopped at ${stopped.path}: ${stopped.reason}`
|
|
46412
|
+
});
|
|
46413
|
+
continue;
|
|
46414
|
+
}
|
|
45910
46415
|
if (failed || aborted || options.isAborted()) {
|
|
45911
46416
|
if (!failed) aborted = true;
|
|
45912
46417
|
traces.push({
|
|
@@ -45918,6 +46423,96 @@ async function runSteps(steps, options) {
|
|
|
45918
46423
|
continue;
|
|
45919
46424
|
}
|
|
45920
46425
|
const startedAt = options.now();
|
|
46426
|
+
if (step.parallel !== void 0) {
|
|
46427
|
+
const members = await Promise.all(step.parallel.map((member, at) => runSteps([member], {
|
|
46428
|
+
...options,
|
|
46429
|
+
pathPrefix: `${path}.steps`,
|
|
46430
|
+
indexOffset: at
|
|
46431
|
+
})));
|
|
46432
|
+
const anyFailed = members.some((m) => m.failed);
|
|
46433
|
+
if (anyFailed) failed = true;
|
|
46434
|
+
else if (members.some((m) => m.aborted)) aborted = true;
|
|
46435
|
+
traces.push({
|
|
46436
|
+
...step.meta,
|
|
46437
|
+
path,
|
|
46438
|
+
startedAt,
|
|
46439
|
+
endedAt: options.now(),
|
|
46440
|
+
outcome: anyFailed ? "error" : "ok",
|
|
46441
|
+
...anyFailed ? { message: "a parallel step failed" } : {},
|
|
46442
|
+
steps: members.flatMap((m) => m.steps.map(withoutNested))
|
|
46443
|
+
});
|
|
46444
|
+
continue;
|
|
46445
|
+
}
|
|
46446
|
+
if (step.repeat !== void 0) {
|
|
46447
|
+
const loop = await runRepeat(step.repeat, options, path);
|
|
46448
|
+
const sub = loop.last;
|
|
46449
|
+
if (loop.unknown !== void 0) options.onGuardUnknown?.({
|
|
46450
|
+
index,
|
|
46451
|
+
path: `${path}.loop.when`,
|
|
46452
|
+
reason: loop.unknown,
|
|
46453
|
+
deviceId: step.meta.deviceId
|
|
46454
|
+
});
|
|
46455
|
+
const bodyFailed = loop.ended === void 0 && sub?.failed === true;
|
|
46456
|
+
if (bodyFailed) failed = true;
|
|
46457
|
+
else if (loop.ended === void 0 && sub?.stopped !== void 0) stopped = sub.stopped;
|
|
46458
|
+
else if (loop.ended === void 0) aborted = true;
|
|
46459
|
+
const times = `ran ${loop.iterations} times`;
|
|
46460
|
+
const message = bodyFailed ? `a step failed in iteration ${loop.iterations}` : loop.ended === void 0 ? times : loop.timedOut ? loop.ended : loop.ended === "" ? times : `${times}: ${loop.ended}`;
|
|
46461
|
+
traces.push({
|
|
46462
|
+
...step.meta,
|
|
46463
|
+
path,
|
|
46464
|
+
startedAt,
|
|
46465
|
+
endedAt: options.now(),
|
|
46466
|
+
outcome: bodyFailed ? "error" : loop.timedOut ? "timed-out" : "ok",
|
|
46467
|
+
message,
|
|
46468
|
+
iterations: loop.iterations,
|
|
46469
|
+
...sub === void 0 ? {} : { steps: sub.steps.map(withoutNested) }
|
|
46470
|
+
});
|
|
46471
|
+
continue;
|
|
46472
|
+
}
|
|
46473
|
+
if (step.choose !== void 0) {
|
|
46474
|
+
const reading = await readChoose(step.choose);
|
|
46475
|
+
const base = {
|
|
46476
|
+
...step.meta,
|
|
46477
|
+
path,
|
|
46478
|
+
startedAt,
|
|
46479
|
+
branchChecks: [...reading.checks]
|
|
46480
|
+
};
|
|
46481
|
+
const { decision } = reading;
|
|
46482
|
+
if (decision.kind !== "run") {
|
|
46483
|
+
if (decision.kind === "unknown") options.onGuardUnknown?.({
|
|
46484
|
+
index,
|
|
46485
|
+
path: `${path}.branches.${decision.index}.if`,
|
|
46486
|
+
reason: decision.reason,
|
|
46487
|
+
deviceId: step.meta.deviceId
|
|
46488
|
+
});
|
|
46489
|
+
traces.push({
|
|
46490
|
+
...base,
|
|
46491
|
+
endedAt: options.now(),
|
|
46492
|
+
outcome: "skipped",
|
|
46493
|
+
message: decision.kind === "unknown" ? `not run: branch ${decision.index + 1} could not be read (${decision.reason})` : "not run: no branch is true"
|
|
46494
|
+
});
|
|
46495
|
+
continue;
|
|
46496
|
+
}
|
|
46497
|
+
const listPath = decision.branch === "else" ? `${path}.else` : `${path}.${decision.branch}.steps`;
|
|
46498
|
+
const sub = await runSteps(decision.steps, {
|
|
46499
|
+
...options,
|
|
46500
|
+
pathPrefix: listPath,
|
|
46501
|
+
indexOffset: 0
|
|
46502
|
+
});
|
|
46503
|
+
if (sub.failed) failed = true;
|
|
46504
|
+
else if (sub.aborted) aborted = true;
|
|
46505
|
+
if (sub.stopped !== void 0) stopped = sub.stopped;
|
|
46506
|
+
traces.push({
|
|
46507
|
+
...base,
|
|
46508
|
+
endedAt: options.now(),
|
|
46509
|
+
outcome: sub.failed ? "error" : "ok",
|
|
46510
|
+
...sub.failed ? { message: "a step of the branch failed" } : {},
|
|
46511
|
+
branch: decision.branch,
|
|
46512
|
+
steps: sub.steps.map(withoutNested)
|
|
46513
|
+
});
|
|
46514
|
+
continue;
|
|
46515
|
+
}
|
|
45921
46516
|
let guardTrace = {};
|
|
45922
46517
|
if (step.guard !== void 0) {
|
|
45923
46518
|
const verdict = await readGuard(step.guard);
|
|
@@ -45947,10 +46542,12 @@ async function runSteps(steps, options) {
|
|
|
45947
46542
|
}
|
|
45948
46543
|
const sub = await runSteps(branch, {
|
|
45949
46544
|
...options,
|
|
45950
|
-
pathPrefix: `${path}.else
|
|
46545
|
+
pathPrefix: `${path}.else`,
|
|
46546
|
+
indexOffset: 0
|
|
45951
46547
|
});
|
|
45952
46548
|
if (sub.failed) failed = true;
|
|
45953
46549
|
else if (sub.aborted) aborted = true;
|
|
46550
|
+
if (sub.stopped !== void 0) stopped = sub.stopped;
|
|
45954
46551
|
traces.push({
|
|
45955
46552
|
...step.meta,
|
|
45956
46553
|
...guardTrace,
|
|
@@ -45968,6 +46565,7 @@ async function runSteps(steps, options) {
|
|
|
45968
46565
|
let sent;
|
|
45969
46566
|
const perDevice = [];
|
|
45970
46567
|
let emptyReason;
|
|
46568
|
+
let timedOutReason;
|
|
45971
46569
|
let templateNotes = [];
|
|
45972
46570
|
const scope = {
|
|
45973
46571
|
setDeviceId: (id) => {
|
|
@@ -45984,6 +46582,16 @@ async function runSteps(steps, options) {
|
|
|
45984
46582
|
},
|
|
45985
46583
|
setTemplateNotes: (notes) => {
|
|
45986
46584
|
templateNotes = notes.slice(0, 20);
|
|
46585
|
+
},
|
|
46586
|
+
stop: (reason, outcome) => {
|
|
46587
|
+
stopped = {
|
|
46588
|
+
reason,
|
|
46589
|
+
outcome,
|
|
46590
|
+
path
|
|
46591
|
+
};
|
|
46592
|
+
},
|
|
46593
|
+
markTimedOut: (reason) => {
|
|
46594
|
+
timedOutReason = reason;
|
|
45987
46595
|
}
|
|
45988
46596
|
};
|
|
45989
46597
|
const templatesTrace = () => templateNotes.length === 0 ? {} : { templates: [...templateNotes] };
|
|
@@ -45991,6 +46599,29 @@ async function runSteps(steps, options) {
|
|
|
45991
46599
|
const devicesTrace = () => perDevice.length === 0 ? {} : { devices: perDevice.slice(0, 200) };
|
|
45992
46600
|
try {
|
|
45993
46601
|
await step.run(scope);
|
|
46602
|
+
const stop = (() => stopped)();
|
|
46603
|
+
if (stop !== void 0) {
|
|
46604
|
+
const message = `stopped: ${stop.reason}`;
|
|
46605
|
+
if (stop.outcome === "failed") {
|
|
46606
|
+
failed = true;
|
|
46607
|
+
options.onFailure({
|
|
46608
|
+
index,
|
|
46609
|
+
path,
|
|
46610
|
+
message,
|
|
46611
|
+
deviceId
|
|
46612
|
+
});
|
|
46613
|
+
}
|
|
46614
|
+
traces.push({
|
|
46615
|
+
...step.meta,
|
|
46616
|
+
...guardTrace,
|
|
46617
|
+
path,
|
|
46618
|
+
startedAt,
|
|
46619
|
+
endedAt: options.now(),
|
|
46620
|
+
outcome: stop.outcome === "failed" ? "error" : "ok",
|
|
46621
|
+
message
|
|
46622
|
+
});
|
|
46623
|
+
continue;
|
|
46624
|
+
}
|
|
45994
46625
|
traces.push({
|
|
45995
46626
|
...step.meta,
|
|
45996
46627
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
@@ -46001,18 +46632,27 @@ async function runSteps(steps, options) {
|
|
|
46001
46632
|
path,
|
|
46002
46633
|
startedAt,
|
|
46003
46634
|
endedAt: options.now(),
|
|
46004
|
-
outcome: emptyReason === void 0 ? "ok" : "empty",
|
|
46005
|
-
...emptyReason === void 0 ? {} : { message: emptyReason }
|
|
46635
|
+
outcome: timedOutReason !== void 0 ? "timed-out" : emptyReason === void 0 ? "ok" : "empty",
|
|
46636
|
+
...timedOutReason !== void 0 ? { message: timedOutReason } : emptyReason === void 0 ? {} : { message: emptyReason }
|
|
46006
46637
|
});
|
|
46007
46638
|
} catch (err) {
|
|
46008
|
-
failed = true;
|
|
46009
46639
|
const message = errorMessage(err);
|
|
46010
|
-
|
|
46640
|
+
const continued = step.continueOnError === true;
|
|
46641
|
+
if (continued) options.onContinuedFailure?.({
|
|
46011
46642
|
index,
|
|
46012
46643
|
path,
|
|
46013
46644
|
message,
|
|
46014
46645
|
deviceId
|
|
46015
46646
|
});
|
|
46647
|
+
else {
|
|
46648
|
+
failed = true;
|
|
46649
|
+
options.onFailure({
|
|
46650
|
+
index,
|
|
46651
|
+
path,
|
|
46652
|
+
message,
|
|
46653
|
+
deviceId
|
|
46654
|
+
});
|
|
46655
|
+
}
|
|
46016
46656
|
traces.push({
|
|
46017
46657
|
...step.meta,
|
|
46018
46658
|
...deviceId === void 0 || perDevice.length > 1 ? {} : { deviceId },
|
|
@@ -46023,7 +46663,7 @@ async function runSteps(steps, options) {
|
|
|
46023
46663
|
path,
|
|
46024
46664
|
startedAt,
|
|
46025
46665
|
endedAt: options.now(),
|
|
46026
|
-
outcome: "error",
|
|
46666
|
+
outcome: continued ? "failed-continued" : "error",
|
|
46027
46667
|
message
|
|
46028
46668
|
});
|
|
46029
46669
|
}
|
|
@@ -46031,7 +46671,8 @@ async function runSteps(steps, options) {
|
|
|
46031
46671
|
return {
|
|
46032
46672
|
steps: traces,
|
|
46033
46673
|
failed,
|
|
46034
|
-
aborted: aborted && !failed
|
|
46674
|
+
aborted: aborted && !failed,
|
|
46675
|
+
...stopped === void 0 ? {} : { stopped }
|
|
46035
46676
|
};
|
|
46036
46677
|
}
|
|
46037
46678
|
function isVarRef(value) {
|
|
@@ -46039,7 +46680,8 @@ function isVarRef(value) {
|
|
|
46039
46680
|
const keys = Object.keys(value);
|
|
46040
46681
|
return keys.length === 1 && keys[0] === "$var" && typeof Reflect.get(value, "$var") === "string";
|
|
46041
46682
|
}
|
|
46042
|
-
|
|
46683
|
+
/** `{{vars.name}}`, or a dotted name (`{{vars.data.channel}}`): the bag is flat, the dots are part of the key. */
|
|
46684
|
+
var TEMPLATE_RE = /\{\{\s*vars\.([A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*)\s*\}\}/g;
|
|
46043
46685
|
/**
|
|
46044
46686
|
* Substitute a step's args from the run's variables. SUBSTITUTION only, never
|
|
46045
46687
|
* evaluation:
|
|
@@ -46089,7 +46731,7 @@ function newSlotNonce() {
|
|
|
46089
46731
|
return Math.random().toString(36).slice(2, 12);
|
|
46090
46732
|
}
|
|
46091
46733
|
function slotPattern(nonce) {
|
|
46092
|
-
return new RegExp(`${VAR_SLOT_OPEN}${nonce}:([A-Za-z_][A-Za-z0-9_]*)${VAR_SLOT_CLOSE}`, "g");
|
|
46734
|
+
return new RegExp(`${VAR_SLOT_OPEN}${nonce}:([A-Za-z_][A-Za-z0-9_.]*)${VAR_SLOT_CLOSE}`, "g");
|
|
46093
46735
|
}
|
|
46094
46736
|
/** True when a string, once its `{{vars.x}}` slots are set aside, still carries template markup. */
|
|
46095
46737
|
function carriesDeviceTemplate(text) {
|
|
@@ -46803,7 +47445,9 @@ var AddonHttpRouteSchema = zod.z.object({
|
|
|
46803
47445
|
]).optional(),
|
|
46804
47446
|
description: zod.z.string().optional(),
|
|
46805
47447
|
/** The hub limits this route per client address before the handler runs. */
|
|
46806
|
-
rateLimit: zod.z.enum(["auth"]).optional()
|
|
47448
|
+
rateLimit: zod.z.enum(["auth"]).optional(),
|
|
47449
|
+
/** Served once per integration instance; the handler reads `instanceId`. */
|
|
47450
|
+
perInstance: zod.z.boolean().optional()
|
|
46807
47451
|
});
|
|
46808
47452
|
/**
|
|
46809
47453
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -46820,6 +47464,8 @@ var InvokeRequestSchema = zod.z.object({
|
|
|
46820
47464
|
query: zod.z.record(zod.z.string(), zod.z.string()),
|
|
46821
47465
|
body: zod.z.unknown(),
|
|
46822
47466
|
headers: zod.z.record(zod.z.string(), zod.z.string()),
|
|
47467
|
+
/** The instance the hub resolved for a `perInstance` route. */
|
|
47468
|
+
instanceId: zod.z.string().optional(),
|
|
46823
47469
|
user: zod.z.object({
|
|
46824
47470
|
id: zod.z.string(),
|
|
46825
47471
|
username: zod.z.string(),
|
|
@@ -63785,53 +64431,6 @@ var enumSensorCapability = {
|
|
|
63785
64431
|
* whether persisting is worth a SQLite commit. */
|
|
63786
64432
|
volatileStateFields: ["lastFetchedAt", "timestamp"]
|
|
63787
64433
|
};
|
|
63788
|
-
/**
|
|
63789
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
63790
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
63791
|
-
* (NO normalization). Two shapes:
|
|
63792
|
-
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
63793
|
-
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
63794
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
63795
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
63796
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
63797
|
-
*/
|
|
63798
|
-
var EventFireSchema = zod.z.object({
|
|
63799
|
-
deviceId: zod.z.number(),
|
|
63800
|
-
eventType: zod.z.string(),
|
|
63801
|
-
data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
63802
|
-
timestamp: zod.z.number().meta(readingMeta("none")),
|
|
63803
|
-
seq: zod.z.number().meta(readingMeta("count"))
|
|
63804
|
-
});
|
|
63805
|
-
var EventEmitterStatusSchema = zod.z.object({
|
|
63806
|
-
eventTypes: zod.z.array(zod.z.string()),
|
|
63807
|
-
lastEvent: EventFireSchema.nullable(),
|
|
63808
|
-
eventCountSinceStart: zod.z.number().meta(readingMeta("count"))
|
|
63809
|
-
});
|
|
63810
|
-
var eventEmitterCapability = {
|
|
63811
|
-
name: "event-emitter",
|
|
63812
|
-
scope: "device",
|
|
63813
|
-
deviceNative: true,
|
|
63814
|
-
mode: "singleton",
|
|
63815
|
-
deviceTypes: [DeviceType.EventEmitter],
|
|
63816
|
-
methods: {},
|
|
63817
|
-
events: { onEvent: { data: EventFireSchema } },
|
|
63818
|
-
status: {
|
|
63819
|
-
schema: EventEmitterStatusSchema,
|
|
63820
|
-
kind: "push"
|
|
63821
|
-
},
|
|
63822
|
-
runtimeState: EventEmitterStatusSchema,
|
|
63823
|
-
/**
|
|
63824
|
-
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
63825
|
-
*
|
|
63826
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
63827
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
63828
|
-
*/
|
|
63829
|
-
durability: "session",
|
|
63830
|
-
/**
|
|
63831
|
-
* History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
|
|
63832
|
-
*/
|
|
63833
|
-
history: "none"
|
|
63834
|
-
};
|
|
63835
64434
|
var IdentitySchema = zod.z.object({
|
|
63836
64435
|
id: zod.z.string(),
|
|
63837
64436
|
name: zod.z.string(),
|
|
@@ -82632,7 +83231,18 @@ var OauthIntegrationDescriptorSchema = zod.z.object({
|
|
|
82632
83231
|
* The value is baked into the authorization code at `/authorize` and travels
|
|
82633
83232
|
* on the tokens, so editing this field changes FUTURE links only.
|
|
82634
83233
|
*/
|
|
82635
|
-
refreshTokenTtlSec: zod.z.union([zod.z.number().int().positive(), zod.z.literal("never")]).optional()
|
|
83234
|
+
refreshTokenTtlSec: zod.z.union([zod.z.number().int().positive(), zod.z.literal("never")]).optional(),
|
|
83235
|
+
/**
|
|
83236
|
+
* The integration instances an account can be linked to (planning#415),
|
|
83237
|
+
* beside the default one. `/api/oauth2/authorize?instance=<id>` is accepted
|
|
83238
|
+
* only for an id listed here; with no `instance=` the link is made to the
|
|
83239
|
+
* default instance, which is never listed and always accepted — it is the
|
|
83240
|
+
* address third parties already hold. Omit for a single-instance integration.
|
|
83241
|
+
*/
|
|
83242
|
+
instances: zod.z.array(zod.z.object({
|
|
83243
|
+
id: zod.z.string(),
|
|
83244
|
+
displayName: zod.z.string()
|
|
83245
|
+
})).optional()
|
|
82636
83246
|
});
|
|
82637
83247
|
var oauthIntegrationCapability = {
|
|
82638
83248
|
name: "oauth-integration",
|
|
@@ -91358,6 +91968,13 @@ var SsoBridgeClaimsSchema = zod.z.object({
|
|
|
91358
91968
|
/** OAuth authorization-code binding — set only on `oauth-code` tokens. */
|
|
91359
91969
|
redirectUri: zod.z.string().optional(),
|
|
91360
91970
|
integrationId: zod.z.string().optional(),
|
|
91971
|
+
/**
|
|
91972
|
+
* The integration INSTANCE an OAuth link was made for (planning#415). Set on
|
|
91973
|
+
* `oauth-code`, `oauth-access` and `oauth-refresh` tokens of a link made
|
|
91974
|
+
* with `instance=`; absent on a link to the default instance. A cloud relay
|
|
91975
|
+
* reads it off the access token to route; the hub answers from the session.
|
|
91976
|
+
*/
|
|
91977
|
+
instanceId: zod.z.string().optional(),
|
|
91361
91978
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
91362
91979
|
jti: zod.z.string().optional(),
|
|
91363
91980
|
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
@@ -94329,6 +94946,8 @@ var OauthSessionSummarySchema = zod.z.object({
|
|
|
94329
94946
|
userId: zod.z.string(),
|
|
94330
94947
|
username: zod.z.string(),
|
|
94331
94948
|
integrationId: zod.z.string(),
|
|
94949
|
+
/** The instance the link was made for; `null` = the default instance. */
|
|
94950
|
+
instanceId: zod.z.string().nullable().optional(),
|
|
94332
94951
|
scopes: zod.z.array(TokenScopeSchema),
|
|
94333
94952
|
createdAt: zod.z.number(),
|
|
94334
94953
|
lastUsedAt: zod.z.number(),
|
|
@@ -94457,6 +95076,9 @@ var userManagementCapability = {
|
|
|
94457
95076
|
}),
|
|
94458
95077
|
oauthIssueCode: method(zod.z.object({
|
|
94459
95078
|
integrationId: zod.z.string(),
|
|
95079
|
+
/** The integration instance the link is for. Omit for the default
|
|
95080
|
+
* instance — never pass the addon id to mean it. */
|
|
95081
|
+
instanceId: zod.z.string().optional(),
|
|
94460
95082
|
userId: zod.z.string(),
|
|
94461
95083
|
username: zod.z.string(),
|
|
94462
95084
|
scopes: zod.z.array(TokenScopeSchema),
|
|
@@ -94498,7 +95120,13 @@ var userManagementCapability = {
|
|
|
94498
95120
|
oauthVerifyAccessToken: method(zod.z.object({ token: zod.z.string() }), zod.z.object({
|
|
94499
95121
|
userId: zod.z.string(),
|
|
94500
95122
|
username: zod.z.string(),
|
|
94501
|
-
scopes: zod.z.array(TokenScopeSchema)
|
|
95123
|
+
scopes: zod.z.array(TokenScopeSchema),
|
|
95124
|
+
/** The instance the link was made for, read from the SESSION.
|
|
95125
|
+
* Absent = the default instance. `oauthLinkServesInstance` is the
|
|
95126
|
+
* helper a per-instance route calls to compare it with the instance
|
|
95127
|
+
* of its path; no route declares `perInstance` yet (the Alexa
|
|
95128
|
+
* per-instance route, T3, is the first consumer). */
|
|
95129
|
+
instanceId: zod.z.string().optional()
|
|
94502
95130
|
}).nullable(), { access: "view" }),
|
|
94503
95131
|
listExternalIdentities: method(zod.z.object({ userId: zod.z.string() }), zod.z.array(ExternalIdentitySchema), { auth: "admin" }),
|
|
94504
95132
|
/** The user an identity is linked to, or `null`. */
|
|
@@ -122069,6 +122697,12 @@ Object.defineProperty(exports, "interpolate", {
|
|
|
122069
122697
|
return interpolate;
|
|
122070
122698
|
}
|
|
122071
122699
|
});
|
|
122700
|
+
Object.defineProperty(exports, "isAddonInstanceId", {
|
|
122701
|
+
enumerable: true,
|
|
122702
|
+
get: function() {
|
|
122703
|
+
return isAddonInstanceId;
|
|
122704
|
+
}
|
|
122705
|
+
});
|
|
122072
122706
|
Object.defineProperty(exports, "isAlertEpisodeOpen", {
|
|
122073
122707
|
enumerable: true,
|
|
122074
122708
|
get: function() {
|