@camstack/server 1.2.876 → 1.2.878

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +2 -1
  3. package/dist/api/trpc/generated-cap-routers.js +308 -256
  4. package/package.json +10 -9
  5. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/system/dist/builtins/autotrack/index.js +1 -1
  12. package/system/dist/builtins/autotrack/index.mjs +1 -1
  13. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  15. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  16. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  17. package/system/dist/builtins/camera-grid/index.js +1 -1
  18. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  19. package/system/dist/builtins/composer/composer.addon.js +4 -4
  20. package/system/dist/builtins/composer/composer.addon.mjs +4 -4
  21. package/system/dist/builtins/console-logging/index.js +1 -1
  22. package/system/dist/builtins/console-logging/index.mjs +1 -1
  23. package/system/dist/builtins/core-blocks/actions-store.d.ts +2 -0
  24. package/system/dist/builtins/core-blocks/core-block-store.d.ts +6 -0
  25. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +3 -0
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.js +410 -9
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +410 -9
  28. package/system/dist/builtins/core-blocks/record-kinds.d.ts +11 -1
  29. package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +6 -0
  30. package/system/dist/builtins/core-blocks/tags-service.d.ts +50 -0
  31. package/system/dist/builtins/core-blocks/tags-wiring.d.ts +16 -0
  32. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  33. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  34. package/system/dist/builtins/device-manager/device-manager.addon.js +59 -5
  35. package/system/dist/builtins/device-manager/device-manager.addon.mjs +59 -5
  36. package/system/dist/builtins/device-manager/device-meta-actions.d.ts +6 -0
  37. package/system/dist/builtins/device-manager/device-meta-types.d.ts +2 -0
  38. package/system/dist/builtins/device-manager/device-row-store.d.ts +1 -0
  39. package/system/dist/builtins/device-manager/device-template/template-grammar.d.ts +15 -1
  40. package/system/dist/builtins/device-manager/device-template/template-protocol.d.ts +8 -0
  41. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  42. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  43. package/system/dist/builtins/keychain/index.js +4 -4
  44. package/system/dist/builtins/keychain/index.mjs +4 -4
  45. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  46. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  47. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  48. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  49. package/system/dist/builtins/local-network/local-network.addon.js +3 -3
  50. package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
  51. package/system/dist/builtins/loki-logging/index.js +1 -1
  52. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  53. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  54. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  55. package/system/dist/builtins/platform-probe/index.js +1 -1
  56. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  57. package/system/dist/builtins/record-entries/index.js +1 -1
  58. package/system/dist/builtins/record-entries/index.mjs +1 -1
  59. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  60. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  61. package/system/dist/builtins/snapshot/index.js +1 -1
  62. package/system/dist/builtins/snapshot/index.mjs +1 -1
  63. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  64. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  65. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  66. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  67. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  68. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  69. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  70. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  71. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  72. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  73. package/system/dist/builtins/winston-logging/index.js +1 -1
  74. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  75. package/system/dist/{capture-engine-DtuMWHR3.js → capture-engine-DAGmlBmJ.js} +1 -1
  76. package/system/dist/{capture-engine-Bao8AioF.mjs → capture-engine-vlouhBCY.mjs} +1 -1
  77. package/system/dist/{composition-sources-DPSSQaGb.js → composition-sources-Rm8xDXjA.js} +1 -1
  78. package/system/dist/{composition-sources-CCoQYZna.mjs → composition-sources-TeHa4THk.mjs} +1 -1
  79. package/system/dist/{constants-BQNuuICz.mjs → constants-Bq1Xl_Ku.mjs} +1 -1
  80. package/system/dist/{constants-wcqPhWGp.js → constants-DnUpXvIY.js} +1 -1
  81. package/system/dist/{device-ca-CDsYbRF8.js → device-ca-DMudhY-2.js} +1 -1
  82. package/system/dist/{device-ca-DvK5zoNx.mjs → device-ca-yHLgyutP.mjs} +1 -1
  83. package/system/dist/device-template-worker.js +26 -3
  84. package/system/dist/device-template-worker.mjs +26 -3
  85. package/system/dist/{dist-CdW0TjIj.js → dist-Bh5JIimH.js} +1704 -1178
  86. package/system/dist/{dist-DcH8pKL-.mjs → dist-DemZNuSJ.mjs} +1651 -1179
  87. package/system/dist/file-host-worker.js +1 -1
  88. package/system/dist/file-host-worker.mjs +1 -1
  89. package/system/dist/{hub-identity-DOyLUW_7.mjs → hub-identity-BxaJKDQk.mjs} +1 -1
  90. package/system/dist/{hub-identity-BRxxw7hh.js → hub-identity-YfGdAaBm.js} +1 -1
  91. package/system/dist/{hub-mdns-ciao-lO2BAONK.js → hub-mdns-ciao-BkWOmG6H.js} +2 -2
  92. package/system/dist/{hub-mdns-ciao-9IzOmoit.mjs → hub-mdns-ciao-aIsTpo0F.mjs} +2 -2
  93. package/system/dist/index.js +8 -8
  94. package/system/dist/index.mjs +8 -8
  95. package/system/dist/{legacy-integration-rows-door-DBL83TzQ.js → legacy-integration-rows-door-C9PZZiKH.js} +1 -1
  96. package/system/dist/{legacy-integration-rows-door-CTxk0fz7.mjs → legacy-integration-rows-door-DrfZZHWq.mjs} +1 -1
  97. package/system/dist/{rename-composition-block-DK9CVk1U.mjs → rename-composition-block-C2KFIOMP.mjs} +1 -1
  98. package/system/dist/{rename-composition-block-CKZqCPQF.js → rename-composition-block-Qp1dW4FP.js} +1 -1
  99. package/system/dist/{restore-archive-2OReGcRK.js → restore-archive-DGgj7aqA.js} +1 -1
  100. package/system/dist/{restore-archive-CruwV_-u.mjs → restore-archive-D_K6PqRk.mjs} +1 -1
  101. package/system/dist/{template-protocol-DRZ4cm95.js → template-protocol-D5ogm1rj.js} +8 -44
  102. package/system/dist/{template-protocol-D_6uVHKs.mjs → template-protocol-SgPDx3Hw.mjs} +8 -44
  103. package/system/dist/{wal-maintenance-DgFSFQH0.mjs → wal-maintenance-BuiSFfF2.mjs} +0 -0
  104. package/system/dist/{wal-maintenance-CN7sdJj-.js → wal-maintenance-DD8mfRDn.js} +0 -0
  105. package/system/package.json +4 -1
@@ -1,7 +1,7 @@
1
- import { $o as COMPOSER_ADDON_ID, $t as RemoteAssumedStateSchema, Aa as readStoredRemoteConfig, Ac as collectSecretMarkerRefs, Ai as kebabToCamel, Al as vocabActionIdFor, B as DEFAULT_HOLD_OVERRIDE, Ba as replacedFieldKeys, Bi as lockDoorLinkOfComposition, Ca as problemsBlockSave, Cl as secretTreeFromSchema, Cs as helperMembers, D as CORE_BLOCK_ADDON_PREFIX, Da as proposeRunningThreshold, E as CORE_BLOCKS_ADDON_ID, Ea as projectDeviceRow, Et as INTERNAL_ACTION_PREFIX, Fa as reexpandAutomationInstance, Fl as DeviceRole, Fo as timedRunLimitOf, Ft as MediaPlayerStatusSchema, Ga as resolveCoreBlockFiles, Hc as entryBody, Ho as validateComposition, Hr as evaluateWhenTree, Ia as remoteCapability, Ic as defineAddonMigrations, Ii as localDateOf, Il as DeviceType$1, Io as timedRunMaxIn, Jc as hydrateSchema, Jn as capUnitResolver, Jr as fanAxisPath, Jt as QuantityUnitError, Ka as resolveHeroLayout, La as remoteLayoutComponentsCapability, Ll as errMsg$1, Ln as buildActionSteps, Lo as timedRunQuickRun, Ls as BaseAddon, N as CoreBlockSchema, Nc as commandOrigin$1, No as templateCapability, Ol as transformSecretWrite, Po as timedRunCapability, Qa as resolveRemoteSource, Qn as checkTemplatePayload, Qo as zoneOnlySite, Ra as remoteSourceSteps, Rc as defineEntryKind, Rn as buildCapabilityLookup, Ro as timedRunSeconds, Sa as prepareRecipeUnits, Sn as addonIdOfActionId, So as stableIdMapOf, T as COMPOSER_RUNNER_ID, Tr as describeComposableCaps, Tt as IDLE_ACTION_STATUS, Un as builtinAutomationTemplate, Va as resolveActionVariables, Vn as buildHeroModel, Vr as evaluateStepCondition, Wa as resolveCoreBlockEntry, Wo as validateSchedulerInput, Wt as PowerSourceInfoSchema, Xt as REMOTE_MEDIA_COMMANDS, Yo as weekdayOfLocalDate, Zr as fanPresetsCapability, _ as BUILTIN_REMOTE_COMPONENTS, _r as customKeyOfRole, ai as generateAutomationBlock, an as SchedulerError, ba as powerSourceLinkOfComposition, bc as actionEffect, bi as isBuiltinTemplateId, bl as ruleFireOfClaim, bn as actionWaitTotalMs, c as ActionError, ca as occurrenceOn, cr as compositionUnionReads, ct as EMPTY_REMOTE_CONFIG, d as ActionTargetResolver, di as instanceCodeHash, do as seedInstanceOnce, dr as coreBlockComposition, dt as FAN_OSCILLATION_AXES, ei as findChannelSource, en as RemoteLayoutPayloadSchema, eo as resolveStepArgs, er as collectDeviceTemplates, es as CompositionSchema, f as ActionVariableSchema, fi as integrationInstancesCapability, fr as coreBlockIdFromAddonId, ft as FAN_OSCILLATION_AXIS_SETTABLE, g as BUILTIN_AUTOMATION_TEMPLATES, ga as planComposition, gt as FanPresetSchema, h as AutomationTemplatePayloadSchema, hn as TemplateKindSchema, hs as compositionFeatureEnabled, ia as normalizeCoreBlockWrite, il as isSecretMarker, ir as compileScalarOverride, j as ConditionMirror, jl as vocabCall, jn as assertStepsOffered, ka as readRecipeLiteral, kn as appendTrace, l as ActionMinDelaySecSchema, li as hasTimeLeaves, ln as SetOscillationAxisInputSchema, ls as canonicalStoredBlockTarget, m as AutomationStateDocSchema, mr as coreBlocksCapability, ms as composedDeviceStableId, mt as FanControlStatusSchema, n as ACTION_TARGET_INVALIDATION_EVENTS, na as nextTimeBoundaryInMs, ol as isSecretRefOwnedBy, on as SchedulerSchema, oo as schedulersCapability, os as HelperMemberSchema, ot as EMPTY_AUTOMATION_STATE, pi as internalActionId, pr as coreBlockSourceKind, ps as composedDeviceRef, qn as canonicalStoredStepTargets, ra as normalizeActionUnits, ro as runSteps, s as ALL_CAPABILITY_DEFINITIONS, sc as RecordIntegrationInstances, sr as compositionSourceRefs, st as EMPTY_REMOTE_ASSUMED_STATE, ta as nextOccurrence, tn as RunningStateStatusSchema, tr as collectWhenMirrorSources, ts as DAY_MS, tt as DeclaredDevices, u as ActionStepSchema, ui as heroLayoutCapability, ur as coreBlockAddonId, ut as FAN_CAPTURE_FIELDS, va as powerSourceActuatorConflicts, vc as VocabActionError, vo as siteFor, vs as compositionSourceKey, wi as isInternalActionId, ws as historyRetentionFromSettings, xn as actionsCapability, ya as powerSourceCapability, yl as resolveSecretMarkers, yn as actionSourceCapability, za as replaceRecipeLiteral, zc as defineRecordKinds, zl as EventCategory$1, zo as toTimings } from "../../dist-DcH8pKL-.mjs";
1
+ import { $a as resolveHeroLayout, $o as validateSchedulerInput, $t as RemoteAssumedStateSchema, B as DEFAULT_HOLD_OVERRIDE, Ba as reexpandAutomationInstance, Bi as localDateOf, Bl as vocabCall, Bn as buildActionSteps, Bo as tagKey, Ca as powerSourceActuatorConflicts, Cn as actionWaitTotalMs, Cs as composedDeviceStableId, D as CORE_BLOCK_ADDON_PREFIX, Da as prepareRecipeUnits, Dc as VocabActionError, Ds as compositionSourceKey, E as CORE_BLOCKS_ADDON_ID, Er as defaultTagColorId, Et as INTERNAL_ACTION_PREFIX, Fa as readStoredRemoteConfig, Ft as MediaPlayerStatusSchema, Ga as renameInTags, Gc as defineAddonMigrations, Gl as DeviceType$1, Go as timedRunMaxIn, Gr as evaluateStepCondition, Ha as remoteLayoutComponentsCapability, Hc as commandOrigin$1, Ho as templateCapability, Ja as resolveActionVariables, Jc as defineRecordKinds, Jl as EventCategory$1, Jo as toTimings, Jt as QuantityUnitError, Ka as replaceRecipeLiteral, Kl as errMsg$1, Kn as builtinAutomationTemplate, Ko as timedRunQuickRun, Kr as evaluateWhenTree, Ks as BaseAddon, Ll as transformSecretWrite, Ma as proposeRunningThreshold, Ml as secretTreeFromSchema, Mn as appendTrace, Ms as helperMembers, N as CoreBlockSchema, Ns as historyRetentionFromSettings, Oa as problemsBlockSave, Oi as isInternalActionId, Ol as resolveSecretMarkers, Pa as readRecipeLiteral, Pi as kebabToCamel, Pn as assertStepsOffered, Qa as resolveCoreBlockFiles, Qr as fanAxisPath, Sn as actionSourceCapability, Ss as composedDeviceRef, T as COMPOSER_RUNNER_ID, Ta as powerSourceLinkOfComposition, Tn as addonIdOfActionId, To as siteFor, Tt as IDLE_ACTION_STATUS, Ua as remoteSourceSteps, Uo as timedRunCapability, Va as remoteCapability, Vn as buildCapabilityLookup, Vo as tagsCapability, Wa as removeFromTags, Wi as lockDoorLinkOfComposition, Wl as DeviceRole, Wn as buildHeroModel, Wo as timedRunLimitOf, Wt as PowerSourceInfoSchema, Xn as canonicalStoredStepTargets, Xt as REMOTE_MEDIA_COMMANDS, Za as resolveCoreBlockEntry, Zc as entryBody, Zn as capUnitResolver, Zo as validateComposition, _ as BUILTIN_REMOTE_COMPONENTS, _i as internalActionId, _n as TagsFieldSchema, _r as coreBlocksCapability, aa as nextOccurrence, an as SchedulerError, ao as resolveRemoteSource, br as customKeyOfRole, c as ActionError, ca as normalizeCoreBlockWrite, cs as COMPOSER_ADDON_ID, ct as EMPTY_REMOTE_CONFIG, d as ActionTargetResolver, dr as compositionUnionReads, dt as FAN_OSCILLATION_AXES, en as RemoteLayoutPayloadSchema, f as ActionVariableSchema, ft as FAN_OSCILLATION_AXIS_SETTABLE, g as BUILTIN_AUTOMATION_TEMPLATES, gc as RecordIntegrationInstances, gi as integrationInstancesCapability, gn as TagStyleSchema, gr as coreBlockSourceKind, gt as FanPresetSchema, h as AutomationTemplatePayloadSchema, hi as instanceCodeHash, hl as isSecretRefOwnedBy, hn as TagNameSchema, hr as coreBlockIdFromAddonId, hs as HelperMemberSchema, ii as findChannelSource, ir as collectWhenMirrorSources, is as weekdayOfLocalDate, j as ConditionMirror, ja as projectDeviceRow, kc as actionEffect, kl as ruleFireOfClaim, ko as stableIdMapOf, kr as describeComposableCaps, l as ActionMinDelaySecSchema, la as normalizeTags, li as generateAutomationBlock, ln as SetOscillationAxisInputSchema, ls as CompositionSchema, m as AutomationStateDocSchema, mi as heroLayoutCapability, mr as coreBlockComposition, mt as FanControlStatusSchema, n as ACTION_TARGET_INVALIDATION_EVENTS, oa as nextTimeBoundaryInMs, on as SchedulerSchema, ot as EMPTY_AUTOMATION_STATE, pa as occurrenceOn, pi as hasTimeLeaves, pl as isSecretMarker, po as schedulersCapability, pr as coreBlockAddonId, qa as replacedFieldKeys, qc as defineEntryKind, qo as timedRunSeconds, rl as hydrateSchema, rr as collectDeviceTemplates, s as ALL_CAPABILITY_DEFINITIONS, sa as normalizeActionUnits, so as resolveStepArgs, sr as compileScalarOverride, ss as zoneOnlySite, st as EMPTY_REMOTE_ASSUMED_STATE, ti as fanPresetsCapability, tn as RunningStateStatusSchema, tr as checkTemplatePayload, tt as DeclaredDevices, u as ActionStepSchema, uo as runSteps, ur as compositionSourceRefs, us as DAY_MS, ut as FAN_CAPTURE_FIELDS, vn as TemplateKindSchema, vo as seedInstanceOnce, vs as canonicalStoredBlockTarget, wa as powerSourceCapability, wi as isBuiltinTemplateId, wn as actionsCapability, ws as compositionFeatureEnabled, xa as planComposition, zc as collectSecretMarkerRefs, zl as vocabActionIdFor } from "../../dist-DemZNuSJ.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-CCoQYZna.mjs";
4
- import { i as capSeriesKey } from "../../capture-engine-Bao8AioF.mjs";
3
+ import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-TeHa4THk.mjs";
4
+ import { i as capSeriesKey } from "../../capture-engine-vlouhBCY.mjs";
5
5
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
6
6
  import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
7
7
  import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
@@ -591,6 +591,7 @@ var ActionRowBodySchema = z.object({
591
591
  steps: z.array(ActionStepSchema).min(1).max(50),
592
592
  variables: z.array(ActionVariableSchema).max(20).optional(),
593
593
  minDelaySec: ActionMinDelaySecSchema.optional(),
594
+ tags: TagsFieldSchema.optional(),
594
595
  createdAt: z.number(),
595
596
  updatedAt: z.number()
596
597
  });
@@ -601,9 +602,11 @@ var TemplateRowBodySchema = z.object({
601
602
  kind: TemplateKindSchema,
602
603
  name: z.string().min(1).max(120),
603
604
  payload: z.unknown(),
605
+ tags: TagsFieldSchema.optional(),
604
606
  createdAt: z.number(),
605
607
  updatedAt: z.number()
606
608
  });
609
+ var TagStyleRowBodySchema = TagStyleSchema;
607
610
  var _coreBlocksRecordKinds = defineRecordKinds({
608
611
  "timed-runs": {
609
612
  schema: z.object({
@@ -689,6 +692,14 @@ var _coreBlocksRecordKinds = defineRecordKinds({
689
692
  retention: { none: "operator delete only; a template a device still uses is refused" },
690
693
  maxDataBytes: 256 * 1024
691
694
  },
695
+ "tag-styles": {
696
+ schema: TagStyleRowBodySchema,
697
+ class: "config",
698
+ writeTrigger: "the operator styles a tag (setStyle); a rename moves it; a remove deletes it",
699
+ device: "none",
700
+ at: "none",
701
+ retention: { none: "operator action only: removing or renaming the tag" }
702
+ },
692
703
  settings: {
693
704
  schema: CoreBlockSettingsBodySchema,
694
705
  class: "config",
@@ -1706,6 +1717,7 @@ var CoreBlockStore = class CoreBlockStore {
1706
1717
  const block = CoreBlockSchema.parse({
1707
1718
  ...input,
1708
1719
  ...normalized,
1720
+ ...input.tags === void 0 ? {} : { tags: normalizeTags(input.tags) },
1709
1721
  id: this.newId(),
1710
1722
  createdBy,
1711
1723
  createdAt: now,
@@ -1738,6 +1750,7 @@ var CoreBlockStore = class CoreBlockStore {
1738
1750
  files: nextFiles,
1739
1751
  entry: nextEntry
1740
1752
  } : {},
1753
+ ...patch.tags === void 0 ? {} : { tags: normalizeTags(patch.tags) },
1741
1754
  id: existing.id,
1742
1755
  createdBy: existing.createdBy,
1743
1756
  createdAt: existing.createdAt,
@@ -1748,6 +1761,23 @@ var CoreBlockStore = class CoreBlockStore {
1748
1761
  return updated;
1749
1762
  }
1750
1763
  /**
1764
+ * Replace the tags of a block. Unlike {@link update} this does NOT move
1765
+ * `updatedAt`: that stamp is the version an open composition editor holds as
1766
+ * `expectedUpdatedAt`, and a tag rename must not make its next save stale.
1767
+ */
1768
+ async setTags(blockId, tags) {
1769
+ const existing = this.byId.get(blockId);
1770
+ if (!existing) throw new Error(`core block not found: ${blockId}`);
1771
+ const { tags: _previous, ...rest } = existing;
1772
+ const normalized = normalizeTags(tags);
1773
+ const next = CoreBlockSchema.parse(normalized.length === 0 ? rest : {
1774
+ ...rest,
1775
+ tags: normalized
1776
+ });
1777
+ await this.persist(next);
1778
+ this.byId.set(next.id, next);
1779
+ }
1780
+ /**
1751
1781
  * Store a composition block (D659): hub-placed, no code, never `running` on
1752
1782
  * creation — the composer's verdict, mirrored by the supervisor, says that.
1753
1783
  */
@@ -3537,7 +3567,8 @@ var ActionsService = class {
3537
3567
  name: patch.name ?? existing.name,
3538
3568
  steps,
3539
3569
  ...(patch.variables ?? existing.variables) === void 0 ? {} : { variables: patch.variables ?? existing.variables },
3540
- ...(patch.minDelaySec ?? existing.minDelaySec) === void 0 ? {} : { minDelaySec: patch.minDelaySec ?? existing.minDelaySec }
3570
+ ...(patch.minDelaySec ?? existing.minDelaySec) === void 0 ? {} : { minDelaySec: patch.minDelaySec ?? existing.minDelaySec },
3571
+ ...(patch.tags ?? existing.tags) === void 0 ? {} : { tags: patch.tags ?? existing.tags }
3541
3572
  });
3542
3573
  this.logger.info("internal action updated", { meta: { actionId: action.id } });
3543
3574
  return {
@@ -3690,6 +3721,11 @@ var ActionsService = class {
3690
3721
  * write="the operator creates / edits / deletes an internal action, or picks a camera's links"
3691
3722
  * retention="operator delete only; a camera's links go with the camera (deviceRemoval 'delete')"
3692
3723
  */
3724
+ /** The stored `tags` of a write: normalised, and absent when there are none. */
3725
+ function tagsBody$1(tags) {
3726
+ const normalized = normalizeTags(tags ?? []);
3727
+ return normalized.length === 0 ? {} : { tags: normalized };
3728
+ }
3693
3729
  function uuidOf(actionId) {
3694
3730
  return actionId.slice(INTERNAL_ACTION_PREFIX.length);
3695
3731
  }
@@ -3716,6 +3752,7 @@ var ActionsStore = class ActionsStore {
3716
3752
  steps: body.steps,
3717
3753
  ...body.variables === void 0 ? {} : { variables: body.variables },
3718
3754
  ...body.minDelaySec === void 0 || body.minDelaySec === 0 ? {} : { minDelaySec: body.minDelaySec },
3755
+ ...body.tags === void 0 || body.tags.length === 0 ? {} : { tags: body.tags },
3719
3756
  status: IDLE_ACTION_STATUS
3720
3757
  };
3721
3758
  }
@@ -3766,6 +3803,7 @@ var ActionsStore = class ActionsStore {
3766
3803
  steps: input.steps,
3767
3804
  ...input.variables === void 0 ? {} : { variables: input.variables },
3768
3805
  ...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
3806
+ ...tagsBody$1(input.tags),
3769
3807
  createdAt: at,
3770
3808
  updatedAt: at
3771
3809
  };
@@ -3783,6 +3821,7 @@ var ActionsStore = class ActionsStore {
3783
3821
  steps: input.steps,
3784
3822
  ...input.variables === void 0 ? {} : { variables: input.variables },
3785
3823
  ...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
3824
+ ...tagsBody$1(input.tags),
3786
3825
  createdAt: existing.data.createdAt,
3787
3826
  updatedAt: this.now()
3788
3827
  };
@@ -3792,6 +3831,19 @@ var ActionsStore = class ActionsStore {
3792
3831
  });
3793
3832
  return ActionsStore.entryOf(existing.id, body);
3794
3833
  }
3834
+ /** Replace the tags of an internal action; its steps and `updatedAt` are left as they are. */
3835
+ async setTags(actionId, tags) {
3836
+ const existing = isInternalActionId(actionId) ? await this.actions.get(uuidOf(actionId)) : null;
3837
+ if (existing === null) throw new ActionError("not-found", `no internal action "${actionId}"`);
3838
+ const { tags: _previous, ...rest } = existing.data;
3839
+ await this.actions.put({
3840
+ id: existing.id,
3841
+ data: {
3842
+ ...rest,
3843
+ ...tagsBody$1(tags)
3844
+ }
3845
+ });
3846
+ }
3795
3847
  async delete(actionId) {
3796
3848
  if (!isInternalActionId(actionId)) return false;
3797
3849
  return this.actions.delete(uuidOf(actionId));
@@ -5735,7 +5787,12 @@ var SchedulersService = class {
5735
5787
  }
5736
5788
  async update(input) {
5737
5789
  const prepared = await this.prepare(input.scheduler);
5738
- const scheduler = await this.deps.store.update(input.schedulerId, prepared);
5790
+ const existing = await this.deps.store.get(input.schedulerId);
5791
+ const tags = prepared.tags ?? existing?.tags;
5792
+ const scheduler = await this.deps.store.update(input.schedulerId, tags === void 0 ? prepared : {
5793
+ ...prepared,
5794
+ tags
5795
+ });
5739
5796
  this.deps.logger.info("scheduler updated", { meta: { schedulerId: scheduler.id } });
5740
5797
  await this.deps.engine.reload();
5741
5798
  return { scheduler };
@@ -5921,6 +5978,15 @@ var SchedulersService = class {
5921
5978
  * write="the operator creates / edits / deletes / switches a scheduler; the engine advances its processed-until stamp"
5922
5979
  * retention="operator delete only; the stamp goes with its scheduler"
5923
5980
  */
5981
+ /** The input with its tags normalised; an empty list is stored as absent (D1054). */
5982
+ function withNormalizedTags(input) {
5983
+ const { tags, ...rest } = input;
5984
+ const normalized = normalizeTags(tags ?? []);
5985
+ return normalized.length === 0 ? rest : {
5986
+ ...rest,
5987
+ tags: normalized
5988
+ };
5989
+ }
5924
5990
  var SchedulersStore = class SchedulersStore {
5925
5991
  schedulers;
5926
5992
  state;
@@ -5956,7 +6022,7 @@ var SchedulersStore = class SchedulersStore {
5956
6022
  const id = this.newId();
5957
6023
  const at = this.now();
5958
6024
  const body = {
5959
- ...input,
6025
+ ...withNormalizedTags(input),
5960
6026
  createdAt: at,
5961
6027
  updatedAt: at
5962
6028
  };
@@ -5972,7 +6038,7 @@ var SchedulersStore = class SchedulersStore {
5972
6038
  if (existing === null) throw new SchedulerError("not-found", `no scheduler "${schedulerId}"`);
5973
6039
  const at = this.now();
5974
6040
  const body = {
5975
- ...input,
6041
+ ...withNormalizedTags(input),
5976
6042
  createdAt: existing.data.createdAt,
5977
6043
  updatedAt: at
5978
6044
  };
@@ -5983,6 +6049,25 @@ var SchedulersStore = class SchedulersStore {
5983
6049
  await this.setProcessedUntil(existing.id, at);
5984
6050
  return SchedulersStore.of(existing.id, body);
5985
6051
  }
6052
+ /**
6053
+ * Replace the tags of a scheduler without touching its timeline: no
6054
+ * processed-until reset (a tag is not an edit of the timeline) and the same
6055
+ * `updatedAt`.
6056
+ */
6057
+ async setTags(schedulerId, tags) {
6058
+ const existing = await this.schedulers.get(schedulerId);
6059
+ if (existing === null) throw new SchedulerError("not-found", `no scheduler "${schedulerId}"`);
6060
+ const { tags: _previous, ...rest } = existing.data;
6061
+ const normalized = normalizeTags(tags);
6062
+ const body = normalized.length === 0 ? rest : {
6063
+ ...rest,
6064
+ tags: normalized
6065
+ };
6066
+ await this.schedulers.put({
6067
+ id: existing.id,
6068
+ data: body
6069
+ });
6070
+ }
5986
6071
  async delete(schedulerId) {
5987
6072
  const removed = await this.schedulers.delete(schedulerId);
5988
6073
  if (removed) await this.state.delete(schedulerId);
@@ -7317,10 +7402,16 @@ function recordOf(id, body) {
7317
7402
  kind: body.kind,
7318
7403
  name: body.name,
7319
7404
  payload: body.payload,
7405
+ ...body.tags === void 0 || body.tags.length === 0 ? {} : { tags: body.tags },
7320
7406
  createdAt: body.createdAt,
7321
7407
  updatedAt: body.updatedAt
7322
7408
  };
7323
7409
  }
7410
+ /** The stored `tags` of a write: normalised, absent when there are none. */
7411
+ function tagsBody(tags) {
7412
+ const normalized = normalizeTags(tags ?? []);
7413
+ return normalized.length === 0 ? {} : { tags: normalized };
7414
+ }
7324
7415
  /** A shipped template as a record: read-only, timeless. */
7325
7416
  function builtinRecordOf(template) {
7326
7417
  return {
@@ -7362,7 +7453,7 @@ var TemplatesService = class {
7362
7453
  const row = await this.deps.templates.get(id);
7363
7454
  return row === null ? null : recordOf(row.id, row.data);
7364
7455
  };
7365
- create = async ({ kind, name, payload }) => {
7456
+ create = async ({ kind, name, payload, tags }) => {
7366
7457
  const checked = checkTemplatePayload(kind, payload);
7367
7458
  if (!checked.ok) {
7368
7459
  this.deps.logger.warn("template: a payload its kind does not accept was refused", { meta: {
@@ -7380,6 +7471,7 @@ var TemplatesService = class {
7380
7471
  kind,
7381
7472
  name,
7382
7473
  payload: checked.payload,
7474
+ ...tagsBody(tags),
7383
7475
  createdAt: at,
7384
7476
  updatedAt: at
7385
7477
  };
@@ -7393,7 +7485,7 @@ var TemplatesService = class {
7393
7485
  template: recordOf(id, body)
7394
7486
  };
7395
7487
  };
7396
- update = async ({ id, name, payload }) => {
7488
+ update = async ({ id, name, payload, tags }) => {
7397
7489
  if (isBuiltinTemplateId(id)) return {
7398
7490
  status: "refused",
7399
7491
  reason: "read-only",
@@ -7426,6 +7518,7 @@ var TemplatesService = class {
7426
7518
  kind: existing.data.kind,
7427
7519
  name: name ?? existing.data.name,
7428
7520
  payload: nextPayload,
7521
+ ...tagsBody(tags === void 0 ? existing.data.tags : tags),
7429
7522
  createdAt: existing.data.createdAt,
7430
7523
  updatedAt: this.now()
7431
7524
  };
@@ -9145,6 +9238,293 @@ async function writeComposedDeviceName(port, logger, blockId, name) {
9145
9238
  }
9146
9239
  }
9147
9240
  //#endregion
9241
+ //#region src/builtins/core-blocks/tags-service.ts
9242
+ /**
9243
+ * The `tags` cap (D1054). A tag lives on the record it labels — a core block, a
9244
+ * scheduler, a template, an action, a device — and only its STYLE (colour token,
9245
+ * icon) is registered here. This service is the one place that knows every owner
9246
+ * kind, so `rename` and `remove` are ONE server operation that rewrites all of
9247
+ * them; the browser never drives that sequence (a closed tab would split the
9248
+ * fleet across two spellings).
9249
+ *
9250
+ * Owners are reached through {@link TagOwnerPort}s: the local stores directly,
9251
+ * the devices through the device manager over `ctx.api` — never a second copy.
9252
+ * Tags compare trimmed and case-insensitively (`sameTag`).
9253
+ */
9254
+ /** The order owners are read and rewritten in; also the order a first spelling is picked. */
9255
+ var OWNER_KINDS = [
9256
+ "coreBlocks",
9257
+ "schedulers",
9258
+ "templates",
9259
+ "actions",
9260
+ "devices"
9261
+ ];
9262
+ var NO_UPDATES = {
9263
+ coreBlocks: 0,
9264
+ schedulers: 0,
9265
+ templates: 0,
9266
+ actions: 0,
9267
+ devices: 0
9268
+ };
9269
+ function requireName(value, what) {
9270
+ const parsed = TagNameSchema.safeParse(value);
9271
+ if (!parsed.success) throw new Error(`[tags] ${what} is not a valid tag name: ${parsed.error.issues[0]?.message ?? "invalid"}`);
9272
+ return parsed.data;
9273
+ }
9274
+ var TagsService = class {
9275
+ deps;
9276
+ constructor(deps) {
9277
+ this.deps = deps;
9278
+ }
9279
+ async readStyles() {
9280
+ const out = [];
9281
+ let cursor;
9282
+ do {
9283
+ const page = await this.deps.styles.query(cursor === void 0 ? {} : { cursor });
9284
+ for (const row of page.records) out.push(row.data);
9285
+ cursor = page.nextCursor ?? void 0;
9286
+ } while (cursor !== void 0);
9287
+ return out;
9288
+ }
9289
+ list = async () => {
9290
+ const styles = new Map((await this.readStyles()).map((s) => [tagKey(s.name), s]));
9291
+ const entries = /* @__PURE__ */ new Map();
9292
+ for (const style of styles.values()) entries.set(tagKey(style.name), {
9293
+ name: style.name,
9294
+ counts: { ...NO_UPDATES }
9295
+ });
9296
+ for (const kind of OWNER_KINDS) for (const record of await this.deps.owners[kind].list()) {
9297
+ const seen = /* @__PURE__ */ new Set();
9298
+ for (const tag of record.tags) {
9299
+ const key = tagKey(tag);
9300
+ if (key.length === 0 || seen.has(key)) continue;
9301
+ seen.add(key);
9302
+ const entry = entries.get(key) ?? {
9303
+ name: tag.trim(),
9304
+ counts: { ...NO_UPDATES }
9305
+ };
9306
+ entry.counts[kind] += 1;
9307
+ entries.set(key, entry);
9308
+ }
9309
+ }
9310
+ const out = [];
9311
+ for (const [key, entry] of entries) {
9312
+ const style = styles.get(key);
9313
+ out.push({
9314
+ name: entry.name,
9315
+ color: style?.color ?? defaultTagColorId(entry.name),
9316
+ icon: style?.icon ?? "tag",
9317
+ styled: style !== void 0,
9318
+ counts: entry.counts
9319
+ });
9320
+ }
9321
+ return out.toSorted((a, b) => a.name.localeCompare(b.name));
9322
+ };
9323
+ setStyle = async ({ name, color, icon }) => {
9324
+ const trimmed = requireName(name, "a tag name");
9325
+ await this.deps.styles.put({
9326
+ id: tagKey(trimmed),
9327
+ data: {
9328
+ name: trimmed,
9329
+ color,
9330
+ icon
9331
+ }
9332
+ });
9333
+ };
9334
+ rename = async ({ from, to }) => {
9335
+ const source = requireName(from, "the tag to rename");
9336
+ const target = requireName(to, "the new tag name");
9337
+ const updated = await this.rewrite(source, (tags) => renameInTags(tags, source, target));
9338
+ await this.moveStyle(source, target);
9339
+ this.deps.logger.info("tag renamed", { meta: {
9340
+ from: source,
9341
+ to: target,
9342
+ updated
9343
+ } });
9344
+ return { updated };
9345
+ };
9346
+ remove = async ({ name }) => {
9347
+ const target = requireName(name, "the tag to remove");
9348
+ const updated = await this.rewrite(target, (tags) => removeFromTags(tags, target));
9349
+ await this.deps.styles.delete(tagKey(target));
9350
+ this.deps.logger.info("tag removed", { meta: {
9351
+ name: target,
9352
+ updated
9353
+ } });
9354
+ return { updated };
9355
+ };
9356
+ /**
9357
+ * Apply `change` to every record carrying `tag`, on every owner kind. A record
9358
+ * that fails is logged and the rest are still attempted; the call then throws,
9359
+ * and the style is NOT touched — the tag still names the failed records, so the
9360
+ * operator repeats the same call (every step is idempotent).
9361
+ */
9362
+ async rewrite(tag, change) {
9363
+ const updated = { ...NO_UPDATES };
9364
+ const failed = [];
9365
+ const plan = [];
9366
+ for (const kind of OWNER_KINDS) for (const record of await this.deps.owners[kind].list()) {
9367
+ const next = change(record.tags);
9368
+ if (next === null) continue;
9369
+ if (next.length > 20) throw new Error(`[tags] "${tag}" cannot be applied: ${kind}:${record.id} would carry ${next.length} tags (max 20); nothing was written`);
9370
+ plan.push({
9371
+ kind,
9372
+ id: record.id,
9373
+ next
9374
+ });
9375
+ }
9376
+ for (const { kind, id, next } of plan) try {
9377
+ await this.deps.owners[kind].setTags(id, next);
9378
+ updated[kind] += 1;
9379
+ } catch (err) {
9380
+ failed.push(`${kind}:${id}`);
9381
+ const deviceId = kind === "devices" ? Number(id) : void 0;
9382
+ this.deps.logger.error("tag rewrite failed for one record — the rest were still attempted", {
9383
+ ...deviceId === void 0 || !Number.isFinite(deviceId) ? {} : { tags: { deviceId } },
9384
+ meta: {
9385
+ tag,
9386
+ kind,
9387
+ recordId: id,
9388
+ error: err instanceof Error ? err.message : String(err)
9389
+ }
9390
+ });
9391
+ }
9392
+ if (failed.length > 0) throw new Error(`[tags] "${tag}" was not rewritten on ${failed.length} record(s) (${failed.slice(0, 5).join(", ")}); the style was left alone — repeat the call`);
9393
+ return updated;
9394
+ }
9395
+ /** The style follows the tag; a merge onto a styled target keeps the TARGET's style. */
9396
+ async moveStyle(from, to) {
9397
+ const fromKey = tagKey(from);
9398
+ const toKey = tagKey(to);
9399
+ const fromStyle = await this.deps.styles.get(fromKey);
9400
+ if (fromKey === toKey) {
9401
+ if (fromStyle !== null) await this.deps.styles.put({
9402
+ id: toKey,
9403
+ data: {
9404
+ ...fromStyle.data,
9405
+ name: to
9406
+ }
9407
+ });
9408
+ return;
9409
+ }
9410
+ if (fromStyle === null) return;
9411
+ if (await this.deps.styles.get(toKey) === null) await this.deps.styles.put({
9412
+ id: toKey,
9413
+ data: {
9414
+ ...fromStyle.data,
9415
+ name: to
9416
+ }
9417
+ });
9418
+ await this.deps.styles.delete(fromKey);
9419
+ }
9420
+ };
9421
+ //#endregion
9422
+ //#region src/builtins/core-blocks/tags-wiring.ts
9423
+ /**
9424
+ * Builds the `tags` cap provider (D1054) over the stores core-blocks owns and the
9425
+ * device manager (over `ctx.api`, never a copy of its data).
9426
+ */
9427
+ function coreBlocksPort(blocks) {
9428
+ return {
9429
+ list: async () => blocks().list().map((b) => ({
9430
+ id: b.id,
9431
+ tags: b.tags ?? []
9432
+ })),
9433
+ setTags: async (id, tags) => {
9434
+ await blocks().setTags(id, tags);
9435
+ }
9436
+ };
9437
+ }
9438
+ function schedulersPort(store) {
9439
+ return {
9440
+ list: async () => (await store.list()).map((s) => ({
9441
+ id: s.id,
9442
+ tags: s.tags ?? []
9443
+ })),
9444
+ setTags: (id, tags) => store.setTags(id, tags)
9445
+ };
9446
+ }
9447
+ function actionsPort(store) {
9448
+ return {
9449
+ list: async () => (await store.list()).map((a) => ({
9450
+ id: a.id,
9451
+ tags: a.tags ?? []
9452
+ })),
9453
+ setTags: (id, tags) => store.setTags(id, tags)
9454
+ };
9455
+ }
9456
+ function templatesPort(templates) {
9457
+ return {
9458
+ list: async () => {
9459
+ const out = [];
9460
+ let cursor;
9461
+ do {
9462
+ const page = await templates.query(cursor === void 0 ? {} : { cursor });
9463
+ for (const row of page.records) out.push({
9464
+ id: row.id,
9465
+ tags: row.data.tags ?? []
9466
+ });
9467
+ cursor = page.nextCursor ?? void 0;
9468
+ } while (cursor !== void 0);
9469
+ return out;
9470
+ },
9471
+ setTags: async (id, tags) => {
9472
+ const row = await templates.get(id);
9473
+ if (row === null) throw new Error(`no template "${id}"`);
9474
+ const { tags: _previous, ...rest } = row.data;
9475
+ const normalized = normalizeTags(tags);
9476
+ await templates.put({
9477
+ id,
9478
+ data: normalized.length === 0 ? rest : {
9479
+ ...rest,
9480
+ tags: normalized
9481
+ }
9482
+ });
9483
+ }
9484
+ };
9485
+ }
9486
+ function devicesPort(api) {
9487
+ const need = () => {
9488
+ const current = api();
9489
+ if (current === void 0) throw new Error("[tags] the cluster API is not available yet");
9490
+ return current;
9491
+ };
9492
+ return {
9493
+ list: async () => {
9494
+ return (await need().deviceManager.listAll.query({ projection: "slim" })).map((d) => ({
9495
+ id: String(d.id),
9496
+ tags: d.tags ?? []
9497
+ }));
9498
+ },
9499
+ setTags: async (id, tags) => {
9500
+ await need().deviceManager.setTags.mutate({
9501
+ deviceId: Number(id),
9502
+ tags
9503
+ });
9504
+ }
9505
+ };
9506
+ }
9507
+ function buildTagsService(deps) {
9508
+ const { records } = deps;
9509
+ return new TagsService({
9510
+ owners: {
9511
+ coreBlocks: coreBlocksPort(deps.blocks),
9512
+ schedulers: schedulersPort(new SchedulersStore({
9513
+ schedulers: records.kind(coreBlocksRecordKinds.schedulers),
9514
+ state: records.kind(coreBlocksRecordKinds["scheduler-state"])
9515
+ })),
9516
+ templates: templatesPort(records.kind(coreBlocksRecordKinds.templates)),
9517
+ actions: actionsPort(new ActionsStore({
9518
+ actions: records.kind(coreBlocksRecordKinds.actions),
9519
+ links: records.kind(coreBlocksRecordKinds["action-links"])
9520
+ })),
9521
+ devices: deps.devices ?? devicesPort(deps.api)
9522
+ },
9523
+ styles: records.kind(coreBlocksRecordKinds["tag-styles"]),
9524
+ logger: deps.logger
9525
+ });
9526
+ }
9527
+ //#endregion
9148
9528
  //#region src/builtins/core-blocks/extract-settings-schema.ts
9149
9529
  /**
9150
9530
  * Read an optional `settingsSchema` named export from a compiled block bundle.
@@ -9344,6 +9724,7 @@ var CoreBlocksAddon = class extends BaseAddon {
9344
9724
  capability: schedulersCapability,
9345
9725
  provider: schedulers.service
9346
9726
  },
9727
+ ...this.tagsRegistrations(),
9347
9728
  {
9348
9729
  capability: powerSourceCapability,
9349
9730
  provider: this.buildPowerSource()
@@ -9364,6 +9745,26 @@ var CoreBlocksAddon = class extends BaseAddon {
9364
9745
  ...this.fanPresetRegistrations()
9365
9746
  ];
9366
9747
  }
9748
+ /** The tag styles and the one rename / remove that rewrites every owner (D1054). */
9749
+ tagsRegistrations() {
9750
+ const records = this.ctx.records;
9751
+ if (records === void 0) {
9752
+ this.ctx.logger.warn("tags: no ctx.records on this node — the tags cap is not registered");
9753
+ return [];
9754
+ }
9755
+ return [{
9756
+ capability: tagsCapability,
9757
+ provider: this.buildTags(records)
9758
+ }];
9759
+ }
9760
+ buildTags(records) {
9761
+ return buildTagsService({
9762
+ records,
9763
+ blocks: () => this.requireStore(),
9764
+ api: () => this.ctx.api,
9765
+ logger: this.ctx.logger.child("tags")
9766
+ });
9767
+ }
9367
9768
  /** Read-only: the fixed layouts and the model built from the device's bindings and slices. */
9368
9769
  buildHeroLayout() {
9369
9770
  const requireApi = () => {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Record kinds owned by core-blocks (phase 4).
3
3
  */
4
- import { ActionStepSchema, ActionVariableSchema, type Scheduler, AutomationStateDocSchema, TemplateKindSchema, type DefinedRecordKind } from "@camstack/types";
4
+ import { ActionStepSchema, ActionVariableSchema, type TagStyle, type Scheduler, AutomationStateDocSchema, TemplateKindSchema, type DefinedRecordKind } from "@camstack/types";
5
5
  import { z } from "zod";
6
6
  export declare const CORE_BLOCKS_COLLECTION = "core_blocks";
7
7
  export declare const CORE_BLOCK_SETTINGS_COLLECTION = "core-blocks:settings";
@@ -36,6 +36,7 @@ export type ActionRowBody = {
36
36
  readonly steps: z.infer<typeof ActionStepSchema>[];
37
37
  readonly variables?: z.infer<typeof ActionVariableSchema>[];
38
38
  readonly minDelaySec?: number;
39
+ readonly tags?: string[];
39
40
  readonly createdAt: number;
40
41
  readonly updatedAt: number;
41
42
  };
@@ -62,11 +63,19 @@ export type TemplateRowBody = {
62
63
  readonly kind: z.infer<typeof TemplateKindSchema>;
63
64
  readonly name: string;
64
65
  readonly payload: unknown;
66
+ readonly tags?: string[];
65
67
  readonly createdAt: number;
66
68
  readonly updatedAt: number;
67
69
  };
68
70
  export declare const TemplateRowBodySchema: z.ZodType<TemplateRowBody>;
69
71
  /**
72
+ * The style of one tag (D1054): colour token and icon. The row id is the tag's
73
+ * comparison key (`tagKey`: trimmed, lower-cased); `name` keeps the spelling the
74
+ * operator chose. A tag lives on the record it labels — only the style is stored here.
75
+ */
76
+ export type TagStyleRowBody = TagStyle;
77
+ export declare const TagStyleRowBodySchema: z.ZodType<TagStyleRowBody>;
78
+ /**
70
79
  * A pending timed run (D993): the device is on and the hub owes it an off at
71
80
  * `activeUntil`. One row per device, written BEFORE the device is switched on,
72
81
  * so a crash can only ever cost a harmless extra off at boot. Row id = the
@@ -88,6 +97,7 @@ export type CoreBlocksRecordKindsMap = {
88
97
  readonly "scheduler-state": DefinedRecordKind<z.ZodType<SchedulerStateRowBody>>;
89
98
  readonly "action-links": DefinedRecordKind<z.ZodType<ActionLinksRowBody>>;
90
99
  readonly templates: DefinedRecordKind<z.ZodType<TemplateRowBody>>;
100
+ readonly "tag-styles": DefinedRecordKind<z.ZodType<TagStyleRowBody>>;
91
101
  readonly settings: DefinedRecordKind<z.ZodType<CoreBlockSettingsBody>>;
92
102
  };
93
103
  export declare const coreBlocksRecordKinds: CoreBlocksRecordKindsMap;
@@ -17,6 +17,12 @@ export declare class SchedulersStore {
17
17
  get(schedulerId: string): Promise<Scheduler | null>;
18
18
  create(input: SchedulerInput): Promise<Scheduler>;
19
19
  update(schedulerId: string, input: SchedulerInput): Promise<Scheduler>;
20
+ /**
21
+ * Replace the tags of a scheduler without touching its timeline: no
22
+ * processed-until reset (a tag is not an edit of the timeline) and the same
23
+ * `updatedAt`.
24
+ */
25
+ setTags(schedulerId: string, tags: readonly string[]): Promise<void>;
20
26
  delete(schedulerId: string): Promise<boolean>;
21
27
  processedUntil(schedulerId: string): Promise<number | null>;
22
28
  setProcessedUntil(schedulerId: string, at: number): Promise<void>;