@camstack/server 1.2.943 → 1.2.945
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 +26 -0
- package/closure-pins.json +350 -0
- package/dist/api/core/auth-sessions.procedures.js +18 -0
- package/dist/api/core/auth.router.js +19 -6
- package/dist/api/server-upload.js +17 -1
- package/dist/api/trpc/generated-cap-mounts.js +18 -1
- package/dist/api/trpc/generated-cap-routers.js +2662 -2542
- package/dist/auth/native-return.js +9 -3
- package/dist/auth/sso-routes.js +5 -1
- package/dist/core/addon/instance-lifecycle.js +4 -1
- package/dist/core/auth/handoff-code.service.js +35 -1
- package/dist/server-root/index.js +313 -70
- package/package.json +15 -11
- package/system/assets/apps-aggregator/icon.svg +5 -0
- package/system/dist/{action-index-B_cLRwXJ.js → action-index-Bcnb-jyg.js} +9 -1
- package/system/dist/{action-index-B1fgpQBt.mjs → action-index-DwPHO2nz.mjs} +9 -1
- package/system/dist/{addon-settings.cap-CZ4MC7ha.mjs → addon-settings.cap-CHpmuaQG.mjs} +1 -1
- package/system/dist/{addon-settings.cap-DrLdMFIe.js → addon-settings.cap-nZVHPo3X.js} +1 -1
- package/system/dist/{alert-episode-Be--PngO.mjs → alert-episode-D-1VUUkZ.mjs} +1 -1
- package/system/dist/{alert-episode-Bqktmt-i.js → alert-episode-DaQ3prSe.js} +1 -1
- package/system/dist/apps.cap-Bqb9NpYx.mjs +130 -0
- package/system/dist/apps.cap-CLjgnuUe.js +141 -0
- package/system/dist/{base-addon-CRsXtYFG.js → base-addon-BG7p06Hb.js} +136 -15
- package/system/dist/{base-addon-BcS6r1cT.mjs → base-addon-BcVoYZbC.mjs} +136 -15
- package/system/dist/{base-device-DAdWzDOl.js → base-device-DeSNiwZ4.js} +4 -4
- package/system/dist/{base-device-DJXF5eDN.mjs → base-device-w_MD0Bf4.mjs} +4 -4
- 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 +3 -3
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/apps-aggregator/aggregate-apps.d.ts +24 -0
- package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.d.ts +16 -0
- package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.js +109 -0
- package/system/dist/builtins/apps-aggregator/apps-aggregator.addon.mjs +103 -0
- package/system/dist/builtins/apps-aggregator/index.d.ts +1 -0
- package/system/dist/builtins/apps-aggregator/index.js +8 -0
- package/system/dist/builtins/apps-aggregator/index.mjs +2 -0
- 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 +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- 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 +3 -3
- package/system/dist/builtins/camera-grid/index.mjs +3 -3
- package/system/dist/builtins/composer/composer.addon.js +7 -7
- package/system/dist/builtins/composer/composer.addon.mjs +7 -7
- 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/actions-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/block-supervisor.d.ts +16 -4
- package/system/dist/builtins/core-blocks/core-block-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +1018 -323
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +986 -291
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -2
- package/system/dist/builtins/core-blocks/migrations/tag-ids.d.ts +42 -0
- package/system/dist/builtins/core-blocks/migrations/tags-as-records.d.ts +47 -0
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +12 -1
- package/system/dist/builtins/core-blocks/runs-api.d.ts +3 -1
- package/system/dist/builtins/core-blocks/runs-ledger.d.ts +3 -1
- package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/tags-service.d.ts +52 -27
- package/system/dist/builtins/core-blocks/tags-wiring.d.ts +2 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +76 -67
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +76 -67
- package/system/dist/builtins/device-history/device-history.addon.js +4 -4
- package/system/dist/builtins/device-history/device-history.addon.mjs +4 -4
- package/system/dist/builtins/device-manager/device-manager.addon.js +1618 -755
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1604 -741
- package/system/dist/builtins/device-manager/device-meta-actions.d.ts +13 -136
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
- package/system/dist/builtins/device-manager/device-provider-context.d.ts +9 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +21 -4
- package/system/dist/builtins/device-manager/device-search.d.ts +6 -0
- package/system/dist/builtins/device-manager/location-alignment.d.ts +9 -2
- package/system/dist/builtins/device-manager/migrate-device.d.ts +7 -2
- package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +132 -1
- package/system/dist/builtins/device-manager/migrations/device-tag-ids.d.ts +25 -0
- package/system/dist/builtins/device-manager/migrations/index.d.ts +16 -0
- package/system/dist/builtins/device-manager/migrations/orphan-children.d.ts +33 -0
- package/system/dist/builtins/device-manager/migrations/ports.d.ts +17 -0
- package/system/dist/builtins/device-manager/migrations/rooms-as-records.d.ts +52 -0
- package/system/dist/builtins/device-manager/record-kinds.d.ts +3 -1
- package/system/dist/builtins/device-manager/removal-cleanup.d.ts +7 -0
- package/system/dist/builtins/device-manager/room-actions.d.ts +27 -0
- package/system/dist/builtins/device-manager/room-store.d.ts +19 -0
- package/system/dist/builtins/device-manager/tag-names.d.ts +32 -0
- package/system/dist/builtins/device-manager/wireable-enum-catalog.d.ts +18 -0
- 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 +3 -3
- package/system/dist/builtins/keychain/index.mjs +3 -3
- 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 +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -2
- package/system/dist/builtins/loki-logging/index.mjs +2 -2
- 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/migrations/migration-engine.d.ts +3 -1
- package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +1 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +15 -10
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +15 -10
- 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 +2 -2
- package/system/dist/builtins/system-config/system-config.addon.mjs +2 -2
- package/system/dist/builtins/winston-logging/index.js +2 -2
- package/system/dist/builtins/winston-logging/index.mjs +2 -2
- package/system/dist/{command-catalog-C29hVOOg.js → command-catalog-A_ONlLfF.js} +1 -1
- package/system/dist/{command-catalog-xAeqxbZk.mjs → command-catalog-CZDlLhxO.mjs} +1 -1
- package/system/dist/{composition-sources-Do5qM6EB.js → composition-sources-D1nPv7dJ.js} +1 -1
- package/system/dist/{composition-sources-C327LGFn.mjs → composition-sources-DubMf_ii.mjs} +1 -1
- package/system/dist/{core-blocks.cap-CdTGUKtr.js → core-blocks.cap-DEYCvF9J.js} +125 -373
- package/system/dist/{core-blocks.cap-DLkEfV5b.mjs → core-blocks.cap-sW5HLDlB.mjs} +109 -327
- package/system/dist/{device-manager.cap-DJs8izI6.js → device-manager.cap-B9qVf7ag.js} +163 -22
- package/system/dist/{device-manager.cap-eYrj1Ezp.mjs → device-manager.cap-CV4KGp3e.mjs} +134 -17
- package/system/dist/{error.cap-CU1FB6uE.mjs → error.cap-B8l7L8e4.mjs} +7 -1
- package/system/dist/{error.cap-BuKbL3Ac.js → error.cap-BqlvgBJd.js} +7 -1
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +7 -7
- package/system/dist/{legacy-integration-rows-door-CdqYAj-o.js → legacy-integration-rows-door-BK8eoGlF.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-LSgpClpX.mjs → legacy-integration-rows-door-CwzC5XNk.mjs} +1 -1
- package/system/dist/{migration-DGAc6ywR.mjs → migration-BvbfW9g-.mjs} +6 -0
- package/system/dist/{migration-BOQlFZCN.js → migration-CHPdAdNh.js} +6 -0
- package/system/dist/{prefix-walk-Mtij0NNT.mjs → named-entity-store-Cq2oVrN5.mjs} +195 -89
- package/system/dist/{prefix-walk-BFnw8NBu.js → named-entity-store-O_hi1y_o.js} +244 -90
- package/system/dist/{notification-rules.cap-BUIuYPlQ.mjs → notification-rules.cap-ClvK6QT1.mjs} +10 -5
- package/system/dist/{notification-rules.cap-BJKUjizS.js → notification-rules.cap-uSLoe2pA.js} +10 -5
- package/system/dist/{notification-targets-DMW7xgR2.js → notification-targets-ChqpBbtR.js} +2 -2
- package/system/dist/{notification-targets-4bGYH5J7.mjs → notification-targets-DUA6-F2t.mjs} +2 -2
- package/system/dist/{device-row-store-CTocYKqC.mjs → record-kinds-BD2xv4Pd.mjs} +222 -93
- package/system/dist/{device-row-store-C0P2H18h.js → record-kinds-BV8Gcpsx.js} +246 -93
- package/system/dist/records/named-entity-store.d.ts +60 -0
- package/system/dist/{rename-composition-block-D9Uc1AF7.js → rename-composition-block-C60O0P16.js} +137 -33
- package/system/dist/{rename-composition-block-Cdh-dRmY.mjs → rename-composition-block-DcX3vkwS.mjs} +137 -33
- package/system/dist/{retention-source.cap-C6Hy0hlM.js → retention-source.cap-A-TMhU5O.js} +1 -1
- package/system/dist/{retention-source.cap-550kkyp5.mjs → retention-source.cap-Ct07pM30.mjs} +1 -1
- package/system/dist/{storage-admin.cap-Ci4QbL6P.mjs → storage-admin.cap-C54s9_B9.mjs} +8 -2
- package/system/dist/{storage-admin.cap-DqW1ol4j.js → storage-admin.cap-DSPHi7ut.js} +8 -2
- package/system/dist/{stream-catalog.cap-CjEQFknc.js → stream-catalog.cap-7WPsugOy.js} +1 -1
- package/system/dist/{stream-catalog.cap-DVniDdRD.mjs → stream-catalog.cap-CzwRDaqT.mjs} +1 -1
- package/system/dist/{tag-BxLazvVb.js → tag-BLraBqvp.js} +12 -0
- package/system/dist/{tag-uZBAq6ox.mjs → tag-DU8pm9Bi.mjs} +7 -1
- package/system/dist/time-window-B6UhCArd.js +679 -0
- package/system/dist/time-window-BnUBULgu.mjs +578 -0
- package/system/dist/{wal-maintenance-BgYiAy5b.js → wal-maintenance-CkPfVApC.js} +0 -0
- package/system/dist/{wal-maintenance-Bey5ChBb.mjs → wal-maintenance-u84_1sVl.mjs} +0 -0
- package/system/package.json +16 -1
- /package/system/dist/{constants-Ba3FTIHl.js → constants-Ba3FTIHl2.js} +0 -0
- /package/system/dist/{constants-DB4piTD5.mjs → constants-DB4piTD52.mjs} +0 -0
|
@@ -1,18 +1,66 @@
|
|
|
1
|
-
import { b as EventCategory } from "./base-addon-
|
|
1
|
+
import { b as EventCategory } from "./base-addon-BcVoYZbC.mjs";
|
|
2
2
|
import { G as isSecretMarkerLike } from "./scoped-settings-DVWUIP7Z.mjs";
|
|
3
3
|
import { c as method, d as systemMethod, l as optionalMethod } from "./capability-definition-C1TLUVJR.mjs";
|
|
4
4
|
import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
|
|
5
5
|
import { a as readingMeta, i as isReadingQuantity, n as baseUnitOf, t as ReadingQuantitySchema } from "./quantity-D3g5SxsZ.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { a as TagsFieldSchema, n as TagIdsFieldSchema } from "./tag-DU8pm9Bi.mjs";
|
|
7
7
|
import { r as DeviceType } from "./device-type-TUGqGmaI.mjs";
|
|
8
8
|
import { i as isSwitchLight, t as canonicalStoredDeviceType } from "./device-kind-C37Ra2wd.mjs";
|
|
9
|
-
import { a as findVocabAction, n as actionEffect } from "./action-index-
|
|
10
|
-
import { a as tryConvertUnit, n as SettingsSchemaWithValuesSchema, o as unitDimension, r as SettingsUpdateResultSchema, t as SettingsPatchSchema, u as locationIconKey } from "./addon-settings.cap-
|
|
9
|
+
import { a as findVocabAction, n as actionEffect } from "./action-index-DwPHO2nz.mjs";
|
|
10
|
+
import { a as tryConvertUnit, n as SettingsSchemaWithValuesSchema, o as unitDimension, r as SettingsUpdateResultSchema, t as SettingsPatchSchema, u as locationIconKey } from "./addon-settings.cap-CHpmuaQG.mjs";
|
|
11
11
|
import { A as compositionSourceKey, B as CompositionSourceRefSchema, D as compositionItemFieldPath, E as compositionFeatureEnabled, F as COMPOSED_DEVICE_STABLE_ID_PREFIX, M as featureSources, N as fieldReads, O as compositionReadKey, P as isForwardInputRef, S as CompositionSchema, _ as refused, b as CompositionFieldReadSchema, dt as compileExpressionSafe, ft as EXPRESSION_IDENTIFIER_RE, g as problem, h as compositionFieldAt, j as featureFieldEntries, m as groupTemplate, mt as EXPRESSION_BUILTINS, n as sameHelperBody, pt as MAX_EXPRESSION_SOURCE_LENGTH, t as compileHelper, ut as validateExpressionSource, v as COMPOSER_ADDON_ID, w as composedDeviceRef, x as CompositionFieldSourceSchema, y as COMPOSITION_ITEM_ARRAY_PATH } from "./compile-OBMHlqD-.mjs";
|
|
12
|
+
import { c as WeekdayKeySchema, m as validateTimeSpecForSite, n as TimeWindowSchema, o as refineTimeWindow, r as expandTimeWindowPreset, s as TimeSpecSchema, t as TimeWindowObjectSchema } from "./time-window-BnUBULgu.mjs";
|
|
12
13
|
import { a as normalizeUnit } from "./source-info-DGB7SdB_.mjs";
|
|
13
14
|
import { t } from "./l10n-Bu6aUvSY.mjs";
|
|
14
15
|
import { n as RawSecretMigrationReportSchema, t as RawSecretMigrationInputSchema } from "./raw-secret-migration-iv88mLoc.mjs";
|
|
15
16
|
import { z } from "zod";
|
|
17
|
+
//#region ../types/dist/esm/automation/on-for.mjs
|
|
18
|
+
/**
|
|
19
|
+
* "On for N" — a command step that turns a device on and takes it back off
|
|
20
|
+
* after a while (D1086 amendment, D1092).
|
|
21
|
+
*
|
|
22
|
+
* A `command` step carries `onFor: { seconds }`. The step does not wait: it
|
|
23
|
+
* hands the device to {@link OnForHolds}, which lives in the block OUTSIDE any
|
|
24
|
+
* run, so the run mode, a restart of the run and the end of the run do not
|
|
25
|
+
* touch the timer.
|
|
26
|
+
*
|
|
27
|
+
* The rules:
|
|
28
|
+
* - the device is read at the event. Off: it is turned on and a hold is
|
|
29
|
+
* taken. On, with no hold: nothing is sent and nothing is taken — what was
|
|
30
|
+
* on before stays on after;
|
|
31
|
+
* - a new event while a hold runs moves its deadline (and turns the device
|
|
32
|
+
* back on if it went off meanwhile);
|
|
33
|
+
* - at the deadline the device is turned off, only because the hold is ours;
|
|
34
|
+
* - a report that the device went off ends the hold: the operator switched it;
|
|
35
|
+
* - a state that cannot be read changes nothing (D49).
|
|
36
|
+
*
|
|
37
|
+
* The holds are persisted through `persist` (the hub's runs ledger row of the
|
|
38
|
+
* block) with their deadline — BEFORE the device is turned on, and rolled back
|
|
39
|
+
* when the send fails — and given back to {@link OnForHolds.restore} when
|
|
40
|
+
* the block starts: a deadline that passed while the block was down is honoured
|
|
41
|
+
* at once.
|
|
42
|
+
*/
|
|
43
|
+
/** The longest a device is held on: one day. */
|
|
44
|
+
var ON_FOR_MAX_SECONDS = 86400;
|
|
45
|
+
var OnForSpecSchema = /* @__PURE__ */ z.object({ seconds: /* @__PURE__ */ z.number().int().min(1).max(ON_FOR_MAX_SECONDS) });
|
|
46
|
+
/** One device this block turned on and owes an off. */
|
|
47
|
+
var OnForHoldSchema = /* @__PURE__ */ z.object({
|
|
48
|
+
deviceId: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
49
|
+
cap: /* @__PURE__ */ z.string().min(1),
|
|
50
|
+
/** When the device is turned off (ms epoch). */
|
|
51
|
+
deadline: /* @__PURE__ */ z.number()
|
|
52
|
+
});
|
|
53
|
+
var OnForHoldsSchema = /* @__PURE__ */ z.array(OnForHoldSchema).max(64);
|
|
54
|
+
var ON_FOR_ACTIONS = { "switch.on": {
|
|
55
|
+
cap: "switch",
|
|
56
|
+
fieldPath: "on",
|
|
57
|
+
offActionId: "switch.off"
|
|
58
|
+
} };
|
|
59
|
+
/** The way back of an `on` action, or null when the action cannot be held. */
|
|
60
|
+
function onForActionOf(actionId) {
|
|
61
|
+
return ON_FOR_ACTIONS[actionId] ?? null;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
16
64
|
//#region ../types/dist/esm/automation/action-target.mjs
|
|
17
65
|
/**
|
|
18
66
|
* WHO an action step acts on (D983) — one target shape for every place that
|
|
@@ -247,293 +295,6 @@ var ExpressionBindingSourceSchema = /* @__PURE__ */ z.union([
|
|
|
247
295
|
ExpressionGlobalBindingSchema
|
|
248
296
|
]);
|
|
249
297
|
//#endregion
|
|
250
|
-
//#region ../types/dist/esm/time/solar.mjs
|
|
251
|
-
/**
|
|
252
|
-
* Where the sun is, from a latitude and a longitude — the one solar
|
|
253
|
-
* calculation in the repo. Compact NOAA sunrise equation (accurate to about a
|
|
254
|
-
* minute away from the poles), so no astronomy dependency is needed.
|
|
255
|
-
*
|
|
256
|
-
* Two consumers read it: the scene-condition resolver (day / night / dawn /
|
|
257
|
-
* dusk of a camera) and a schedule's sun time (`time-spec.ts`).
|
|
258
|
-
*/
|
|
259
|
-
var DEG = Math.PI / 180;
|
|
260
|
-
/** The sun's upper limb on the horizon, refraction included: sunrise and sunset. */
|
|
261
|
-
var SUNRISE_ALTITUDE_DEG = -.833;
|
|
262
|
-
/** Julian day number for a JS Date (UTC). */
|
|
263
|
-
function toJulian(date) {
|
|
264
|
-
return date.getTime() / 864e5 + 2440587.5;
|
|
265
|
-
}
|
|
266
|
-
/** Julian day → epoch ms (UTC). */
|
|
267
|
-
function fromJulian(j) {
|
|
268
|
-
return (j - 2440587.5) * 864e5;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* When the sun crosses `altitudeDeg` on the day `date` falls in at this place.
|
|
272
|
-
* Pass an instant near local midday of the civil day you mean: the day is
|
|
273
|
-
* chosen from the instant, and midday is the one that never straddles two.
|
|
274
|
-
*
|
|
275
|
-
* `null` when the sun never crosses that altitude that day (polar day or polar
|
|
276
|
-
* night, or — for a twilight altitude — a summer night that never gets dark
|
|
277
|
-
* enough). The caller decides what that means; nothing here guesses.
|
|
278
|
-
*/
|
|
279
|
-
function sunCrossings(lat, lng, date, altitudeDeg) {
|
|
280
|
-
const jDate = toJulian(date);
|
|
281
|
-
const jStar = Math.round(jDate - 2451545 + 8e-4) - lng / 360;
|
|
282
|
-
const m = (357.5291 + .98560028 * jStar) % 360;
|
|
283
|
-
const mRad = m * DEG;
|
|
284
|
-
const lambda = (m + (1.9148 * Math.sin(mRad) + .02 * Math.sin(2 * mRad) + 3e-4 * Math.sin(3 * mRad)) + 180 + 102.9372) % 360 * DEG;
|
|
285
|
-
const jTransit = 2451545 + jStar + .0053 * Math.sin(mRad) - .0069 * Math.sin(2 * lambda);
|
|
286
|
-
const declination = Math.asin(Math.sin(lambda) * Math.sin(23.44 * DEG));
|
|
287
|
-
const latRad = lat * DEG;
|
|
288
|
-
const cosOmega = (Math.sin(altitudeDeg * DEG) - Math.sin(latRad) * Math.sin(declination)) / (Math.cos(latRad) * Math.cos(declination));
|
|
289
|
-
if (cosOmega > 1 || cosOmega < -1) return null;
|
|
290
|
-
const omega = Math.acos(cosOmega) / DEG;
|
|
291
|
-
return {
|
|
292
|
-
rise: fromJulian(jTransit - omega / 360),
|
|
293
|
-
set: fromJulian(jTransit + omega / 360)
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region ../types/dist/esm/time/time-spec.mjs
|
|
298
|
-
/**
|
|
299
|
-
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
300
|
-
* scheduler and of an automation's schedule leaf. Three shapes, no cron:
|
|
301
|
-
*
|
|
302
|
-
* - `clock` — a wall-clock time every day (`07:30`), read in the site's zone;
|
|
303
|
-
* - `sun` — a sun event (`sunrise`, `sunset`, `dawn`, `dusk`) plus or minus
|
|
304
|
-
* up to twelve hours, from the site's coordinates;
|
|
305
|
-
* - `date` — one local date and time (`2026-12-24T18:00`), once.
|
|
306
|
-
*
|
|
307
|
-
* A site is a place and its IANA zone ({@link TimeSite}). Every function here
|
|
308
|
-
* is pure: the zone arithmetic uses `Intl`, no date library.
|
|
309
|
-
*
|
|
310
|
-
* Wall-clock honesty across a DST change: a local time that does not exist
|
|
311
|
-
* (02:30 on the spring-forward day) happens at the first minute that does
|
|
312
|
-
* (03:00); one that happens twice (02:30 on the fall-back day) happens at its
|
|
313
|
-
* FIRST occurrence.
|
|
314
|
-
*/
|
|
315
|
-
var SunEventSchema = /* @__PURE__ */ z.enum([
|
|
316
|
-
"sunrise",
|
|
317
|
-
"sunset",
|
|
318
|
-
"dawn",
|
|
319
|
-
"dusk"
|
|
320
|
-
]);
|
|
321
|
-
var LOCAL_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
322
|
-
var LOCAL_DATE_TIME = /^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):([0-5]\d)$/;
|
|
323
|
-
var TimeSpecSchema = /* @__PURE__ */ z.discriminatedUnion("kind", [
|
|
324
|
-
/* @__PURE__ */ z.object({
|
|
325
|
-
kind: /* @__PURE__ */ z.literal("clock"),
|
|
326
|
-
hh: /* @__PURE__ */ z.number().int().min(0).max(23),
|
|
327
|
-
mm: /* @__PURE__ */ z.number().int().min(0).max(59)
|
|
328
|
-
}),
|
|
329
|
-
/* @__PURE__ */ z.object({
|
|
330
|
-
kind: /* @__PURE__ */ z.literal("sun"),
|
|
331
|
-
event: SunEventSchema,
|
|
332
|
-
/** Minutes after the event (negative: before). */
|
|
333
|
-
offsetMin: /* @__PURE__ */ z.number().int().min(-720).max(720)
|
|
334
|
-
}),
|
|
335
|
-
/* @__PURE__ */ z.object({
|
|
336
|
-
kind: /* @__PURE__ */ z.literal("date"),
|
|
337
|
-
/** `YYYY-MM-DDTHH:mm`, site-local. */
|
|
338
|
-
local: /* @__PURE__ */ z.string().regex(LOCAL_DATE_TIME, "expected YYYY-MM-DDTHH:mm")
|
|
339
|
-
})
|
|
340
|
-
]);
|
|
341
|
-
/** A day of the week as a schedule names it. */
|
|
342
|
-
var WeekdayKeySchema = /* @__PURE__ */ z.enum([
|
|
343
|
-
"mon",
|
|
344
|
-
"tue",
|
|
345
|
-
"wed",
|
|
346
|
-
"thu",
|
|
347
|
-
"fri",
|
|
348
|
-
"sat",
|
|
349
|
-
"sun"
|
|
350
|
-
]);
|
|
351
|
-
var WEEKDAY_BY_INDEX = [
|
|
352
|
-
"sun",
|
|
353
|
-
"mon",
|
|
354
|
-
"tue",
|
|
355
|
-
"wed",
|
|
356
|
-
"thu",
|
|
357
|
-
"fri",
|
|
358
|
-
"sat"
|
|
359
|
-
];
|
|
360
|
-
var MINUTE_MS = 6e4;
|
|
361
|
-
var DAY_MS = 864e5;
|
|
362
|
-
var formatters = /* @__PURE__ */ new Map();
|
|
363
|
-
function formatterFor(timeZone) {
|
|
364
|
-
const cached = formatters.get(timeZone);
|
|
365
|
-
if (cached !== void 0) return cached;
|
|
366
|
-
const created = new Intl.DateTimeFormat("en-US", {
|
|
367
|
-
timeZone,
|
|
368
|
-
hourCycle: "h23",
|
|
369
|
-
year: "numeric",
|
|
370
|
-
month: "2-digit",
|
|
371
|
-
day: "2-digit",
|
|
372
|
-
hour: "2-digit",
|
|
373
|
-
minute: "2-digit",
|
|
374
|
-
second: "2-digit"
|
|
375
|
-
});
|
|
376
|
-
formatters.set(timeZone, created);
|
|
377
|
-
return created;
|
|
378
|
-
}
|
|
379
|
-
function wallClockOf(epochMs, timeZone) {
|
|
380
|
-
const out = {};
|
|
381
|
-
for (const part of formatterFor(timeZone).formatToParts(new Date(epochMs))) if (part.type !== "literal") out[part.type] = Number(part.value);
|
|
382
|
-
return {
|
|
383
|
-
year: out["year"] ?? 0,
|
|
384
|
-
month: out["month"] ?? 0,
|
|
385
|
-
day: out["day"] ?? 0,
|
|
386
|
-
hour: out["hour"] ?? 0,
|
|
387
|
-
minute: out["minute"] ?? 0,
|
|
388
|
-
second: out["second"] ?? 0
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
/** The zone's offset from UTC at an instant, in ms (positive east of Greenwich). */
|
|
392
|
-
function offsetMs(epochMs, timeZone) {
|
|
393
|
-
const w = wallClockOf(epochMs, timeZone);
|
|
394
|
-
return Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second) - Math.floor(epochMs / 1e3) * 1e3;
|
|
395
|
-
}
|
|
396
|
-
/** Is `timeZone` a zone this runtime knows? */
|
|
397
|
-
function isKnownTimeZone(timeZone) {
|
|
398
|
-
try {
|
|
399
|
-
formatterFor(timeZone);
|
|
400
|
-
return true;
|
|
401
|
-
} catch {
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
/** `YYYY-MM-DD` of an instant, read in the zone. */
|
|
406
|
-
function localDateOf(epochMs, timeZone) {
|
|
407
|
-
const w = wallClockOf(epochMs, timeZone);
|
|
408
|
-
return `${String(w.year).padStart(4, "0")}-${String(w.month).padStart(2, "0")}-${String(w.day).padStart(2, "0")}`;
|
|
409
|
-
}
|
|
410
|
-
function parseLocalDate(localDate) {
|
|
411
|
-
if (!LOCAL_DATE.test(localDate)) throw new Error(`not a local date (YYYY-MM-DD): ${localDate}`);
|
|
412
|
-
const [y, m, d] = localDate.split("-").map(Number);
|
|
413
|
-
return {
|
|
414
|
-
y: y ?? 0,
|
|
415
|
-
m: m ?? 1,
|
|
416
|
-
d: d ?? 1
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
/** The weekday of a `YYYY-MM-DD` civil date (zone-independent). */
|
|
420
|
-
function weekdayOfLocalDate(localDate) {
|
|
421
|
-
const { y, m, d } = parseLocalDate(localDate);
|
|
422
|
-
return WEEKDAY_BY_INDEX[new Date(Date.UTC(y, m - 1, d)).getUTCDay()] ?? "sun";
|
|
423
|
-
}
|
|
424
|
-
function addDays(localDate, days) {
|
|
425
|
-
const { y, m, d } = parseLocalDate(localDate);
|
|
426
|
-
return new Date(Date.UTC(y, m - 1, d + days)).toISOString().slice(0, 10);
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* The instant a wall-clock time happens in a zone. A time that does not exist
|
|
430
|
-
* happens at the first minute that does; one that happens twice, at its first
|
|
431
|
-
* occurrence.
|
|
432
|
-
*/
|
|
433
|
-
function wallToEpoch(localDate, hh, mm, timeZone) {
|
|
434
|
-
const { y, m, d } = parseLocalDate(localDate);
|
|
435
|
-
const wall = Date.UTC(y, m - 1, d, hh, mm);
|
|
436
|
-
const before = offsetMs(wall - DAY_MS, timeZone);
|
|
437
|
-
const after = offsetMs(wall + DAY_MS, timeZone);
|
|
438
|
-
const valid = [wall - before, wall - after].filter((c) => c + offsetMs(c, timeZone) === wall);
|
|
439
|
-
if (valid.length > 0) return Math.min(...valid);
|
|
440
|
-
let lo = wall - DAY_MS;
|
|
441
|
-
let hi = wall + DAY_MS;
|
|
442
|
-
while (hi - lo > MINUTE_MS) {
|
|
443
|
-
const mid = Math.floor((lo + hi) / 2 / MINUTE_MS) * MINUTE_MS;
|
|
444
|
-
if (offsetMs(mid, timeZone) === before) lo = mid;
|
|
445
|
-
else hi = mid;
|
|
446
|
-
}
|
|
447
|
-
return hi;
|
|
448
|
-
}
|
|
449
|
-
function sunEventAltitude(event) {
|
|
450
|
-
return event === "sunrise" || event === "sunset" ? SUNRISE_ALTITUDE_DEG : -6;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* The moment `spec` happens on the site-local date `localDate` (`YYYY-MM-DD`).
|
|
454
|
-
* See {@link Occurrence} for what `null` means.
|
|
455
|
-
*/
|
|
456
|
-
function occurrenceOn(spec, localDate, site) {
|
|
457
|
-
switch (spec.kind) {
|
|
458
|
-
case "clock": return wallToEpoch(localDate, spec.hh, spec.mm, site.timeZone);
|
|
459
|
-
case "date": {
|
|
460
|
-
const match = LOCAL_DATE_TIME.exec(spec.local);
|
|
461
|
-
if (match === null || match[1] !== localDate) return null;
|
|
462
|
-
return wallToEpoch(localDate, Number(match[2]), Number(match[3]), site.timeZone);
|
|
463
|
-
}
|
|
464
|
-
case "sun": {
|
|
465
|
-
const midday = new Date(wallToEpoch(localDate, 12, 0, site.timeZone));
|
|
466
|
-
const crossings = sunCrossings(site.lat, site.lon, midday, sunEventAltitude(spec.event));
|
|
467
|
-
if (crossings === null) return null;
|
|
468
|
-
return (spec.event === "sunrise" || spec.event === "dawn" ? crossings.rise : crossings.set) + spec.offsetMin * MINUTE_MS;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* The first moment strictly after `afterMs` at which `spec` happens, or `null`
|
|
474
|
-
* when none does within {@link NEXT_OCCURRENCE_HORIZON_DAYS} (a `date` spec in
|
|
475
|
-
* the past, a sun event that never happens, an empty `days` list).
|
|
476
|
-
*/
|
|
477
|
-
function nextOccurrence(spec, afterMs, site, options = {}) {
|
|
478
|
-
const days = options.days;
|
|
479
|
-
if (days !== void 0 && days.length === 0) return null;
|
|
480
|
-
if (spec.kind === "date") {
|
|
481
|
-
const own = LOCAL_DATE_TIME.exec(spec.local)?.[1];
|
|
482
|
-
if (own === void 0 || days !== void 0 && !days.includes(weekdayOfLocalDate(own))) return null;
|
|
483
|
-
const at = occurrenceOn(spec, own, site);
|
|
484
|
-
return at !== null && at > afterMs ? at : null;
|
|
485
|
-
}
|
|
486
|
-
const first = addDays(localDateOf(afterMs, site.timeZone), -1);
|
|
487
|
-
for (let i = 0; i < 400; i += 1) {
|
|
488
|
-
const localDate = addDays(first, i);
|
|
489
|
-
if (days !== void 0 && !days.includes(weekdayOfLocalDate(localDate))) continue;
|
|
490
|
-
const at = occurrenceOn(spec, localDate, site);
|
|
491
|
-
if (at !== null && at > afterMs) return at;
|
|
492
|
-
}
|
|
493
|
-
return null;
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Can `spec` be scheduled at this site? A sun spec without a location is
|
|
497
|
-
* REFUSED with its reason — never read as a guessed sunrise. A clock or date
|
|
498
|
-
* spec needs only a zone, and `site` is `null` in that case when there is no
|
|
499
|
-
* location (it is not needed to place them; use {@link siteFor} to read them).
|
|
500
|
-
*/
|
|
501
|
-
function validateTimeSpecForSite(spec, reading) {
|
|
502
|
-
if (!isKnownTimeZone(reading.timeZone)) return {
|
|
503
|
-
ok: false,
|
|
504
|
-
reason: "unknown-time-zone",
|
|
505
|
-
message: `the site time zone "${reading.timeZone}" is not a known IANA zone`
|
|
506
|
-
};
|
|
507
|
-
const site = siteFor(reading);
|
|
508
|
-
if (spec.kind === "sun" && site === null) return {
|
|
509
|
-
ok: false,
|
|
510
|
-
reason: "sun-needs-site-location",
|
|
511
|
-
message: `a ${spec.event} time needs the site location, and none is set — set it in Settings, or use a clock time`
|
|
512
|
-
};
|
|
513
|
-
return {
|
|
514
|
-
ok: true,
|
|
515
|
-
site
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
/** The site, when it has a location; a clock spec on a site without one uses {@link zoneOnlySite}. */
|
|
519
|
-
function siteFor(reading) {
|
|
520
|
-
if (reading.location === null) return null;
|
|
521
|
-
return {
|
|
522
|
-
lat: reading.location.latitude,
|
|
523
|
-
lon: reading.location.longitude,
|
|
524
|
-
timeZone: reading.timeZone
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
/** A site that can place a clock or date spec but no sun event (coordinates are unused by those). */
|
|
528
|
-
function zoneOnlySite(timeZone) {
|
|
529
|
-
return {
|
|
530
|
-
lat: 0,
|
|
531
|
-
lon: 0,
|
|
532
|
-
timeZone,
|
|
533
|
-
zoneOnly: true
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
//#endregion
|
|
537
298
|
//#region ../types/dist/esm/device/schema-fields.mjs
|
|
538
299
|
/** Unwrap ZodNullable / ZodOptional / ZodDefault wrappers to reach the inner type.
|
|
539
300
|
* Zod v4 exposes `.unwrap()` on all three wrapper classes. */
|
|
@@ -1292,39 +1053,19 @@ var StationaryPresentLeafSchema = /* @__PURE__ */ z.object({
|
|
|
1292
1053
|
minCount: /* @__PURE__ */ z.number().int().positive().optional()
|
|
1293
1054
|
});
|
|
1294
1055
|
/**
|
|
1056
|
+
* What a `time-is` leaf holds beside its kind: the one window model of
|
|
1057
|
+
* `time/time-window.ts`. A template's time-window input stores exactly this.
|
|
1058
|
+
*/
|
|
1059
|
+
var TimeIsWindowSchema = TimeWindowSchema;
|
|
1060
|
+
/**
|
|
1295
1061
|
* True while the site-local clock is inside a daily window and/or on one of
|
|
1296
1062
|
* the named days. `days` names the local day a window STARTS on, so
|
|
1297
1063
|
* 22:00-06:00 on weekdays is still inside at 01:00 Saturday. A one-date spec
|
|
1298
1064
|
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
1299
1065
|
* that repeats every day.
|
|
1066
|
+
* A `preset` (day or night) stands for a sun window and takes the place of `between`.
|
|
1300
1067
|
*/
|
|
1301
|
-
var
|
|
1302
|
-
between: /* @__PURE__ */ z.object({
|
|
1303
|
-
from: TimeSpecSchema,
|
|
1304
|
-
to: TimeSpecSchema
|
|
1305
|
-
}).optional(),
|
|
1306
|
-
days: /* @__PURE__ */ z.array(WeekdayKeySchema).min(1).max(7).optional()
|
|
1307
|
-
};
|
|
1308
|
-
function timeIsWindowProblems(window, ctx) {
|
|
1309
|
-
if (window.between === void 0 && window.days === void 0) ctx.addIssue({
|
|
1310
|
-
code: "custom",
|
|
1311
|
-
message: "a time-is leaf needs a between window, days, or both"
|
|
1312
|
-
});
|
|
1313
|
-
for (const end of ["from", "to"]) if (window.between?.[end].kind === "date") ctx.addIssue({
|
|
1314
|
-
code: "custom",
|
|
1315
|
-
message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
|
|
1316
|
-
path: ["between", end]
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* What a `time-is` leaf holds beside its kind, judged by the leaf's own rules.
|
|
1321
|
-
* A template's time-window input stores exactly this.
|
|
1322
|
-
*/
|
|
1323
|
-
var TimeIsWindowSchema = /* @__PURE__ */ (/* @__PURE__ */ z.object(timeIsWindowShape)).superRefine(timeIsWindowProblems);
|
|
1324
|
-
var TimeIsLeafSchema = /* @__PURE__ */ z.object({
|
|
1325
|
-
kind: /* @__PURE__ */ z.literal("time-is"),
|
|
1326
|
-
...timeIsWindowShape
|
|
1327
|
-
}).superRefine(timeIsWindowProblems);
|
|
1068
|
+
var TimeIsLeafSchema = /* @__PURE__ */ TimeWindowObjectSchema.extend({ kind: /* @__PURE__ */ z.literal("time-is") }).superRefine(refineTimeWindow);
|
|
1328
1069
|
/**
|
|
1329
1070
|
* True for the run that one of the named event leaves started. It reads the
|
|
1330
1071
|
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
@@ -1585,6 +1326,11 @@ var TemplateActionValueSchema = /* @__PURE__ */ z.object({
|
|
|
1585
1326
|
*/
|
|
1586
1327
|
var TemplateTimeWindowValueSchema = TimeIsWindowSchema;
|
|
1587
1328
|
/**
|
|
1329
|
+
* A `device-state` input's value: what a `device-is` leaf holds beside its kind (one device field
|
|
1330
|
+
* compared to a value, now, optionally held). "No limit" is the input left without a value.
|
|
1331
|
+
*/
|
|
1332
|
+
var TemplateDeviceStateValueSchema = /* @__PURE__ */ DeviceIsLeafSchema.omit({ kind: true });
|
|
1333
|
+
/**
|
|
1588
1334
|
* An `entries` input's value: automation elements VERBATIM — event leaves of a
|
|
1589
1335
|
* `when` tree, or steps of a branch. Judged with the automation's own schemas
|
|
1590
1336
|
* (`valueProblem` in the template engine), so there is no second shape here.
|
|
@@ -1599,6 +1345,7 @@ var TemplateScalarValueSchema = /* @__PURE__ */ z.union([
|
|
|
1599
1345
|
/* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int().nonnegative()),
|
|
1600
1346
|
TemplateEventValueSchema,
|
|
1601
1347
|
TemplateActionValueSchema,
|
|
1348
|
+
TemplateDeviceStateValueSchema,
|
|
1602
1349
|
TemplateTimeWindowValueSchema,
|
|
1603
1350
|
TemplateEntriesValueSchema
|
|
1604
1351
|
]);
|
|
@@ -1886,7 +1633,13 @@ var AutomationCommandStepBaseSchema = /* @__PURE__ */ z.object({
|
|
|
1886
1633
|
* value in the unit the method's input DECLARES (`paramMeta`); on a write an
|
|
1887
1634
|
* arg may be a {@link QuantityValue}, which the save boundary converts.
|
|
1888
1635
|
*/
|
|
1889
|
-
argUnits: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string().min(1)).optional()
|
|
1636
|
+
argUnits: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string().min(1)).optional(),
|
|
1637
|
+
/**
|
|
1638
|
+
* "On for N": the device is turned on only if it is off, and taken back off
|
|
1639
|
+
* after `seconds`; a new run restarts the time (`on-for.ts`). The step does
|
|
1640
|
+
* not wait. Only an action `on-for.ts` knows how to undo carries it.
|
|
1641
|
+
*/
|
|
1642
|
+
onFor: /* @__PURE__ */ OnForSpecSchema.optional()
|
|
1890
1643
|
});
|
|
1891
1644
|
/** The vocabulary check every command step passes: the action exists. */
|
|
1892
1645
|
function refineKnownAction(step, ctx) {
|
|
@@ -1895,6 +1648,11 @@ function refineKnownAction(step, ctx) {
|
|
|
1895
1648
|
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
1896
1649
|
path: ["actionId"]
|
|
1897
1650
|
});
|
|
1651
|
+
if (step.onFor !== void 0 && onForActionOf(step.actionId) === null) ctx.addIssue({
|
|
1652
|
+
code: "custom",
|
|
1653
|
+
message: `"${step.actionId}" cannot be held on for a time: only a turn-on action can`,
|
|
1654
|
+
path: ["onFor"]
|
|
1655
|
+
});
|
|
1898
1656
|
}
|
|
1899
1657
|
var AutomationCommandStepSchema = /* @__PURE__ */ AutomationCommandStepBaseSchema.superRefine(refineKnownAction);
|
|
1900
1658
|
/**
|
|
@@ -1928,7 +1686,14 @@ var GuardedCommandStepSchema = /* @__PURE__ */ AutomationCommandStepBaseSchema.e
|
|
|
1928
1686
|
* no place to nest a block, so it is not offered the rest of an Action's steps.
|
|
1929
1687
|
* It is a subset of {@link ActionStep}: a runner built for the wide step runs it.
|
|
1930
1688
|
*/
|
|
1689
|
+
/** Why "on for a time" is refused outside an automation: the off has to outlive the run that turned it on. */
|
|
1690
|
+
var ON_FOR_NEEDS_AUTOMATION = "\"on for a time\" is kept by an automation, which turns the device off later — a list that runs once has nothing left to do that";
|
|
1931
1691
|
var NarrowActionStepSchema = /* @__PURE__ */ z.discriminatedUnion("kind", [GuardedWaitStepSchema, GuardedCommandStepSchema]).superRefine((step, ctx) => {
|
|
1692
|
+
if (step.kind === "command" && step.onFor !== void 0) ctx.addIssue({
|
|
1693
|
+
code: "custom",
|
|
1694
|
+
message: ON_FOR_NEEDS_AUTOMATION,
|
|
1695
|
+
path: ["onFor"]
|
|
1696
|
+
});
|
|
1932
1697
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
1933
1698
|
code: "custom",
|
|
1934
1699
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
@@ -2249,6 +2014,11 @@ var AutomationActionSchema = /* @__PURE__ */ z.discriminatedUnion("kind", [
|
|
|
2249
2014
|
})
|
|
2250
2015
|
]);
|
|
2251
2016
|
var ActionStepSchema = /* @__PURE__ */ AutomationActionSchema.refine((step) => step.kind !== "code", { message: "an action is interpreted, so it has no code step: a code step is bundled into the block of an automation" }).superRefine((step, ctx) => {
|
|
2017
|
+
if ([step, ...nestedStepsOf(step)].some((s) => s.kind === "command" && s.onFor !== void 0)) ctx.addIssue({
|
|
2018
|
+
code: "custom",
|
|
2019
|
+
message: ON_FOR_NEEDS_AUTOMATION,
|
|
2020
|
+
path: ["onFor"]
|
|
2021
|
+
});
|
|
2252
2022
|
for (const condition of stepConditionsOf(step)) if (hasTriggeredByLeaves(condition.when)) ctx.addIssue({
|
|
2253
2023
|
code: "custom",
|
|
2254
2024
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
@@ -2392,9 +2162,11 @@ var WINDOW_ENDS = ["from", "to"];
|
|
|
2392
2162
|
function whenSiteIssues(when, reading, rootPath = "when") {
|
|
2393
2163
|
const issues = [];
|
|
2394
2164
|
forEachLeaf(when, (leaf, path) => {
|
|
2395
|
-
if (leaf.kind !== "time-is"
|
|
2165
|
+
if (leaf.kind !== "time-is") return;
|
|
2166
|
+
const between = expandTimeWindowPreset(leaf).between;
|
|
2167
|
+
if (between === void 0) return;
|
|
2396
2168
|
for (const end of WINDOW_ENDS) {
|
|
2397
|
-
const checked = validateTimeSpecForSite(
|
|
2169
|
+
const checked = validateTimeSpecForSite(between[end], reading);
|
|
2398
2170
|
if (!checked.ok) issues.push({
|
|
2399
2171
|
path: `${path}.between.${end}`,
|
|
2400
2172
|
reason: checked.reason,
|
|
@@ -2497,7 +2269,9 @@ var SchedulerInputSchema = /* @__PURE__ */ z.object({
|
|
|
2497
2269
|
maxLateMs: /* @__PURE__ */ z.number().int().min(1e3).max(24 * 36e5).default(DEFAULT_MAX_LATE_MS),
|
|
2498
2270
|
profiles: /* @__PURE__ */ z.array(SchedulerProfileSchema).max(20),
|
|
2499
2271
|
/** Operator tags (D1054). Absent = no tags. */
|
|
2500
|
-
tags: /* @__PURE__ */ TagsFieldSchema.optional()
|
|
2272
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
2273
|
+
/** The tag ids (D1089); `tags` is kept beside them for one release. */
|
|
2274
|
+
tagIds: /* @__PURE__ */ TagIdsFieldSchema.optional()
|
|
2501
2275
|
});
|
|
2502
2276
|
var SchedulerSchema = /* @__PURE__ */ SchedulerInputSchema.extend({
|
|
2503
2277
|
id: /* @__PURE__ */ z.string().min(1),
|
|
@@ -2918,7 +2692,9 @@ var AutomationRunTraceSchema = /* @__PURE__ */ z.object({
|
|
|
2918
2692
|
var AutomationStateDocSchema = /* @__PURE__ */ z.object({
|
|
2919
2693
|
version: /* @__PURE__ */ z.literal(1),
|
|
2920
2694
|
lastRunStartedAt: /* @__PURE__ */ z.number().nullable(),
|
|
2921
|
-
traces: /* @__PURE__ */ z.array(AutomationRunTraceSchema)
|
|
2695
|
+
traces: /* @__PURE__ */ z.array(AutomationRunTraceSchema),
|
|
2696
|
+
/** The devices the block turned on and still owes an off (`on-for.ts`). Absent = none. */
|
|
2697
|
+
onForHolds: /* @__PURE__ */ OnForHoldsSchema.optional()
|
|
2922
2698
|
});
|
|
2923
2699
|
/** The state of an owner that never reported. */
|
|
2924
2700
|
var EMPTY_AUTOMATION_STATE = {
|
|
@@ -7988,7 +7764,9 @@ var CoreBlockInputFieldsSchema = /* @__PURE__ */ z.object({
|
|
|
7988
7764
|
*/
|
|
7989
7765
|
settingsSchema: /* @__PURE__ */ CoreBlockSettingsSchemaBridge.optional(),
|
|
7990
7766
|
/** Operator tags (D1054), kept on the record. Absent = no tags. */
|
|
7991
|
-
tags: /* @__PURE__ */ TagsFieldSchema.optional()
|
|
7767
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
7768
|
+
/** The tag ids (D1089); `tags` is kept beside them for one release. */
|
|
7769
|
+
tagIds: /* @__PURE__ */ TagIdsFieldSchema.optional()
|
|
7992
7770
|
});
|
|
7993
7771
|
/** Client-authored fields for create — requires `code` or `files[entry]`. */
|
|
7994
7772
|
var CoreBlockInputSchema = /* @__PURE__ */ CoreBlockInputFieldsSchema.superRefine((val, ctx) => {
|
|
@@ -8088,6 +7866,8 @@ var CoreBlockSchema = /* @__PURE__ */ z.object({
|
|
|
8088
7866
|
settingsSchema: /* @__PURE__ */ CoreBlockSettingsSchemaBridge.optional(),
|
|
8089
7867
|
/** Operator tags (D1054). Absent = no tags. */
|
|
8090
7868
|
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
7869
|
+
/** The tag ids (D1089); `tags` is kept beside them for one release. */
|
|
7870
|
+
tagIds: /* @__PURE__ */ TagIdsFieldSchema.optional(),
|
|
8091
7871
|
id: /* @__PURE__ */ z.string(),
|
|
8092
7872
|
createdAt: /* @__PURE__ */ z.number(),
|
|
8093
7873
|
updatedAt: /* @__PURE__ */ z.number(),
|
|
@@ -8417,13 +8197,15 @@ var coreBlocksCapability = {
|
|
|
8417
8197
|
* An automation block reports one run (or one coalesced skip) to the hub's
|
|
8418
8198
|
* `runs` ledger. Only the block itself may: the transport stamps
|
|
8419
8199
|
* `callerAddonId`, and anything but `core-block-<blockId>` is refused.
|
|
8420
|
-
* `keepTraces` bounds the ring; `runStartedAt` moves the cooldown stamp
|
|
8200
|
+
* `keepTraces` bounds the ring; `runStartedAt` moves the cooldown stamp;
|
|
8201
|
+
* `onForHolds` replaces the devices the block holds on (`on-for.ts`).
|
|
8421
8202
|
*/
|
|
8422
8203
|
reportAutomationRun: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
8423
8204
|
blockId: /* @__PURE__ */ z.string().min(1),
|
|
8424
8205
|
trace: /* @__PURE__ */ AutomationRunTraceSchema.optional(),
|
|
8425
8206
|
runStartedAt: /* @__PURE__ */ z.number().optional(),
|
|
8426
|
-
keepTraces: /* @__PURE__ */ z.number().int().min(1).max(100).optional()
|
|
8207
|
+
keepTraces: /* @__PURE__ */ z.number().int().min(1).max(100).optional(),
|
|
8208
|
+
onForHolds: /* @__PURE__ */ OnForHoldsSchema.optional()
|
|
8427
8209
|
}), /* @__PURE__ */ z.void(), {
|
|
8428
8210
|
kind: "mutation",
|
|
8429
8211
|
auth: "admin"
|
|
@@ -8439,4 +8221,4 @@ var coreBlocksCapability = {
|
|
|
8439
8221
|
vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
|
|
8440
8222
|
};
|
|
8441
8223
|
//#endregion
|
|
8442
|
-
export { CAP_RUNTIME_FIELD_UNITS as $,
|
|
8224
|
+
export { CAP_RUNTIME_FIELD_UNITS as $, EventVocabularyEntrySchema as $t, MediaPlayerStatusSchema as A, TemplateEventValueSchema as At, isRemoteCustomKey as B, holdOf as Bt, PowerSourceStateSchema as C, nestedStepsOf as Ct, featureForwards as D, TemplateActionValueSchema as Dt, commandedMethods as E, validateRecipeBounds as Et, irSourceProblem as F, forEachLeaf as Ft, IrNativeFormatSchema as G, QuantityUnitError as Gt, isRemoteWidgetRole as H, faultMatches as Ht, remoteSourceSteps as I, hasEventLeaves as It, capLinkServedFields as J, paramMeta as Jt, IrTimingsSchema as K, convertQuantityInput as Kt, resolveRemoteSource as L, isEventLeaf as Lt, REMOTE_STEP_DELAY_MAX_MS as M, AutomationWhenSchema as Mt, RemoteSourceSchema as N, EVENT_LEAF_ID_RE as Nt, COMPOSED_ITEM_FIXED_FIELDS as O, TemplateDeviceStateValueSchema as Ot, findChannelSource as P, eventLeafIdAt as Pt, CAP_CUSTOMIZE_CATALOG as Q, unwrapSchema as Qt, RemoteRoleSchema as R, compareValues as Rt, PowerSourceInfoSchema as S, REPEAT_ITEM_VAR as St, DEVICE_ID_FIELD as T, stepGuardOf as Tt, toTimings as U, readFault as Ut, isRemoteRole as V, describeWantedFaults as Vt, IrNativeCodeSchema as W, anySubjectMatches as Wt, expandCapLinks as X, enumerateItemArrayFields as Xt, declaredCapLink as Y, paramMetaOf as Yt, projectCapLinkOf as Z, enumerateSchemaFields as Zt, replacedFieldKeys as _, validateSchedulerInput as _t, coreBlockComposition as a, AutomationStateDocSchema as at, powerSourceActuatorConflicts as b, AutomationRecipeSchema as bt, coreBlocksCapability as c, buildStepArgsTrace as ct, resolveCoreBlockFiles as d, SchedulerConflictSchema as dt, ACTION_TARGET_INVALIDATION_EVENTS as en, CompositionBlockStateSchema as et, describeComposableCaps as f, SchedulerError as ft, planComposition as g, SchedulerStatusSchema as gt, compositionUnionReads as h, SchedulerSchema as ht, coreBlockAddonId as i, AutomationRunTraceSchema as it, mediaPlayerCapability as j, TemplateTimeWindowValueSchema as jt, expressionContainsBuiltinCall as k, TemplateEntriesValueSchema as kt, normalizeCoreBlockWrite as l, DEFAULT_HOLD_OVERRIDE as lt, compositionSourceRefs as m, SchedulerPreviewSchema as mt, CORE_BLOCK_ADDON_PREFIX as n, canonicalStoredStepTargets as nn, compositionFieldKey as nt, coreBlockIdFromAddonId as o, EMPTY_AUTOMATION_STATE as ot, buildCapabilityLookup as p, SchedulerInputSchema as pt, TransmitSettingsSchema as q, isQuantityValue as qt, CoreBlockSchema as r, ON_FOR_MAX_SECONDS as rn, AutomationRunOutcomeSchema as rt, coreBlockSourceKind as s, appendTrace as st, CORE_BLOCKS_ADDON_ID as t, ActionTargetResolver as tn, CompositionRunStatusSchema as tt, resolveCoreBlockEntry as u, LOCAL_DATE_PATTERN as ut, topLevelFieldsOf as v, ActionStepSchema as vt, powerSourceCapability as w, stepConditionsOf as wt, powerSourceLinkOfComposition as x, HTTP_TEXT_CAP as xt, validateComposition as y, AutomationBranchStepSchema as yt, customKeyOfRole as z, describeHoldMs as zt };
|