@camstack/addon-pipeline-orchestrator 1.2.604 → 1.2.605

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/dist/index.js CHANGED
@@ -7976,6 +7976,12 @@ function normalizeAddonInitResult(result) {
7976
7976
  if (Array.isArray(result)) return { providers: result };
7977
7977
  return result;
7978
7978
  }
7979
+ /**
7980
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7981
+ * and validates them (`share-token.service.ts` builds its enum from this
7982
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7983
+ */
7984
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7979
7985
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7980
7986
  var PeerBytesTicketSchema = object({
7981
7987
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13825,6 +13831,229 @@ var ConvertResultSchema = object({
13825
13831
  files: array(string()).readonly()
13826
13832
  })).readonly()
13827
13833
  });
13834
+ /**
13835
+ * Zod schemas for persisted record types.
13836
+ *
13837
+ * These schemas serve as the single source of truth for types that are
13838
+ * stored in the settings-store backend and retrieved via tRPC. They
13839
+ * replace the manual TypeScript interfaces with schema-derived types,
13840
+ * enabling runtime validation when reading from the backend.
13841
+ *
13842
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13843
+ * keeps the original name for backward compatibility.
13844
+ */
13845
+ /**
13846
+ * Auth model (v2 — 2026-05-12 caps-only):
13847
+ *
13848
+ * Two principals:
13849
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
13850
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
13851
+ *
13852
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
13853
+ * `super_admin` — collapsed onto the single boolean because every
13854
+ * non-admin caller is governed by the same scope-check rules; the
13855
+ * distinction was only ever used to route role-specific procedures
13856
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
13857
+ * with `isAdmin: false` + an explicit scope list.
13858
+ */
13859
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
13860
+ var MethodAccessSchema = _enum([
13861
+ "view",
13862
+ "create",
13863
+ "delete"
13864
+ ]);
13865
+ /**
13866
+ * A single scope grant. Three forms — checked in matcher with OR
13867
+ * semantics; the first match decides whether the call passes:
13868
+ *
13869
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
13870
+ * cap with the matching `scope` declaration. New caps inherit grants
13871
+ * automatically — adding a device cap to the codebase makes it
13872
+ * reachable to every user with `category:device [...]` without a
13873
+ * re-grant. Use this for "family viewer" / "operator" tiers.
13874
+ *
13875
+ * - `addon` — every cap that ships inside a given addon id. Niche;
13876
+ * useful when an integration needs to interact with one specific
13877
+ * addon's surface regardless of how many caps it exports.
13878
+ *
13879
+ * - `capability` — the most precise form. Single cap name. Use for
13880
+ * integration tokens where you want to grant `addons.installPackage`
13881
+ * and nothing else.
13882
+ *
13883
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
13884
+ * "give me everything" escape; there is no wildcard scope.
13885
+ */
13886
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
13887
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
13888
+ var CapScopeSchema = _enum(["device", "system"]);
13889
+ /**
13890
+ * DeviceSelector (scope model v3 — 2026-08-12).
13891
+ *
13892
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
13893
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
13894
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
13895
+ * AFTER the grant was minted — no re-grant, no re-login.
13896
+ *
13897
+ * - `all` — every device in the deployment. The broad viewer/operator
13898
+ * lever without a `category` grant (a `category` grant also covers device
13899
+ * caps that carry no deviceId; `all` is specifically the device set).
13900
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
13901
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
13902
+ * is NOT covered until the grant is edited.
13903
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
13904
+ * DYNAMIC. A device that changes type, or a new device of the type,
13905
+ * re-resolves on the next request.
13906
+ * - `locations` — every device whose operator-assigned `location` label is
13907
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
13908
+ * null/unset location matches NO `locations` selector.
13909
+ */
13910
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
13911
+ object({ kind: literal("all") }),
13912
+ object({
13913
+ kind: literal("ids"),
13914
+ ids: array(number().int()).min(1)
13915
+ }),
13916
+ object({
13917
+ kind: literal("types"),
13918
+ types: array(_enum(DeviceType)).min(1)
13919
+ }),
13920
+ object({
13921
+ kind: literal("locations"),
13922
+ locations: array(string().min(1)).min(1)
13923
+ })
13924
+ ]);
13925
+ var DeviceTokenScopeSchema = object({
13926
+ type: literal("device"),
13927
+ /** The device SET this grant covers — resolved against the live fleet. */
13928
+ selector: DeviceSelectorSchema,
13929
+ access: array(MethodAccessSchema).min(1),
13930
+ /**
13931
+ * Whether a grant on a PARENT device transparently covers its accessory
13932
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
13933
+ * Direction is parent → children ONLY.
13934
+ *
13935
+ * Absent → the matcher DERIVES it from the access flavour: `view`
13936
+ * inherits (a camera viewer sees the camera's accessories), `create` /
13937
+ * `delete` do NOT (actuating/removing a child is an explicit act the
13938
+ * operator must grant on the child, not inherit from the parent). Set it
13939
+ * explicitly to override that default per grant.
13940
+ */
13941
+ includeLinked: boolean().optional()
13942
+ });
13943
+ /**
13944
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
13945
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
13946
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
13947
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
13948
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
13949
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
13950
+ * migration cannot reach a JWT already in a client's hands; parse-time
13951
+ * migration covers both without a flag day. No cast — the raw object is read
13952
+ * through `Reflect.get` (its static type is `unknown`).
13953
+ */
13954
+ function migrateLegacyTokenScope(raw) {
13955
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
13956
+ if (Reflect.get(raw, "type") !== "device") return raw;
13957
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
13958
+ const targets = Reflect.get(raw, "targets");
13959
+ if (!Array.isArray(targets)) return raw;
13960
+ return {
13961
+ type: "device",
13962
+ selector: {
13963
+ kind: "ids",
13964
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
13965
+ },
13966
+ access: Reflect.get(raw, "access")
13967
+ };
13968
+ }
13969
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
13970
+ object({
13971
+ type: literal("category"),
13972
+ target: CapScopeSchema,
13973
+ access: array(MethodAccessSchema).min(1)
13974
+ }),
13975
+ object({
13976
+ type: literal("capability"),
13977
+ target: string(),
13978
+ access: array(MethodAccessSchema).min(1)
13979
+ }),
13980
+ object({
13981
+ type: literal("addon"),
13982
+ target: string(),
13983
+ access: array(MethodAccessSchema).min(1)
13984
+ }),
13985
+ DeviceTokenScopeSchema
13986
+ ]));
13987
+ object({
13988
+ id: string(),
13989
+ username: string(),
13990
+ passwordHash: string(),
13991
+ /**
13992
+ * Admin bypass. When true, the middleware skips the scope-access
13993
+ * check entirely. There is no other axis of privilege; the legacy
13994
+ * role enum collapsed onto this boolean in v2.
13995
+ */
13996
+ isAdmin: boolean().default(false),
13997
+ allowedProviders: AllowedProviderSchema,
13998
+ allowedDevices: AllowedDevicesSchema,
13999
+ /**
14000
+ * Scopes granted to this user. Admins bypass; their `scopes` is
14001
+ * ignored. Non-admins without scopes are locked out of every
14002
+ * protected call.
14003
+ */
14004
+ scopes: array(TokenScopeSchema).default([]),
14005
+ createdAt: number(),
14006
+ updatedAt: number()
14007
+ });
14008
+ object({
14009
+ id: string(),
14010
+ label: string(),
14011
+ isAdmin: boolean().default(false),
14012
+ allowedProviders: AllowedProviderSchema,
14013
+ allowedDevices: AllowedDevicesSchema,
14014
+ tokenHash: string(),
14015
+ tokenPrefix: string(),
14016
+ createdAt: number(),
14017
+ lastUsedAt: number().optional()
14018
+ });
14019
+ object({
14020
+ id: string(),
14021
+ userId: string(),
14022
+ name: string(),
14023
+ tokenHash: string(),
14024
+ tokenPrefix: string(),
14025
+ scopes: array(TokenScopeSchema),
14026
+ expiresAt: number().nullish(),
14027
+ lastUsedAt: number().nullish(),
14028
+ createdAt: number()
14029
+ });
14030
+ /** What a share-view grant lets its holder see. */
14031
+ var ShareViewGrantSchema = object({
14032
+ kind: _enum(SHARE_VIEW_KINDS),
14033
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
14034
+ /** Talk-back, opt-in at mint time; absent means off. */
14035
+ talk: boolean().optional()
14036
+ });
14037
+ var ShareViewScopeSchema = object({
14038
+ type: literal("share-view"),
14039
+ grant: ShareViewGrantSchema
14040
+ });
14041
+ var AddonRoutesScopeSchema = object({
14042
+ type: literal("addon-routes"),
14043
+ access: array(MethodAccessSchema).min(1)
14044
+ });
14045
+ var CredentialScopeSchema = union([
14046
+ literal("*"),
14047
+ ShareViewScopeSchema,
14048
+ AddonRoutesScopeSchema,
14049
+ TokenScopeSchema
14050
+ ]);
14051
+ object({
14052
+ kind: literal("credential"),
14053
+ sub: string().min(1),
14054
+ jti: string().min(16),
14055
+ scopes: array(CredentialScopeSchema).min(1)
14056
+ });
13828
14057
  _enum(["new-session", "step-up"]);
13829
14058
  /** The languages the hub's app landing pages are written in (D858). */
13830
14059
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -45019,202 +45248,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
45019
45248
  auth: "admin"
45020
45249
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
45021
45250
  /**
45022
- * Zod schemas for persisted record types.
45023
- *
45024
- * These schemas serve as the single source of truth for types that are
45025
- * stored in the settings-store backend and retrieved via tRPC. They
45026
- * replace the manual TypeScript interfaces with schema-derived types,
45027
- * enabling runtime validation when reading from the backend.
45028
- *
45029
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
45030
- * keeps the original name for backward compatibility.
45031
- */
45032
- /**
45033
- * Auth model (v2 — 2026-05-12 caps-only):
45034
- *
45035
- * Two principals:
45036
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
45037
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
45038
- *
45039
- * No role enum. There used to be `viewer / agent / scoped` and earlier
45040
- * `super_admin` — collapsed onto the single boolean because every
45041
- * non-admin caller is governed by the same scope-check rules; the
45042
- * distinction was only ever used to route role-specific procedures
45043
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
45044
- * with `isAdmin: false` + an explicit scope list.
45045
- */
45046
- /** Per-method access flavour. Materialised on every cap method via codegen. */
45047
- var MethodAccessSchema = _enum([
45048
- "view",
45049
- "create",
45050
- "delete"
45051
- ]);
45052
- /**
45053
- * A single scope grant. Three forms — checked in matcher with OR
45054
- * semantics; the first match decides whether the call passes:
45055
- *
45056
- * - `category` — broadest. `target: 'device' | 'system'` selects every
45057
- * cap with the matching `scope` declaration. New caps inherit grants
45058
- * automatically — adding a device cap to the codebase makes it
45059
- * reachable to every user with `category:device [...]` without a
45060
- * re-grant. Use this for "family viewer" / "operator" tiers.
45061
- *
45062
- * - `addon` — every cap that ships inside a given addon id. Niche;
45063
- * useful when an integration needs to interact with one specific
45064
- * addon's surface regardless of how many caps it exports.
45065
- *
45066
- * - `capability` — the most precise form. Single cap name. Use for
45067
- * integration tokens where you want to grant `addons.installPackage`
45068
- * and nothing else.
45069
- *
45070
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
45071
- * "give me everything" escape; there is no wildcard scope.
45072
- */
45073
- var AllowedProviderSchema = union([literal("*"), array(string())]);
45074
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
45075
- var CapScopeSchema = _enum(["device", "system"]);
45076
- /**
45077
- * DeviceSelector (scope model v3 — 2026-08-12).
45078
- *
45079
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
45080
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
45081
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
45082
- * AFTER the grant was minted — no re-grant, no re-login.
45083
- *
45084
- * - `all` — every device in the deployment. The broad viewer/operator
45085
- * lever without a `category` grant (a `category` grant also covers device
45086
- * caps that carry no deviceId; `all` is specifically the device set).
45087
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
45088
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
45089
- * is NOT covered until the grant is edited.
45090
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
45091
- * DYNAMIC. A device that changes type, or a new device of the type,
45092
- * re-resolves on the next request.
45093
- * - `locations` — every device whose operator-assigned `location` label is
45094
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
45095
- * null/unset location matches NO `locations` selector.
45096
- */
45097
- var DeviceSelectorSchema = discriminatedUnion("kind", [
45098
- object({ kind: literal("all") }),
45099
- object({
45100
- kind: literal("ids"),
45101
- ids: array(number().int()).min(1)
45102
- }),
45103
- object({
45104
- kind: literal("types"),
45105
- types: array(_enum(DeviceType)).min(1)
45106
- }),
45107
- object({
45108
- kind: literal("locations"),
45109
- locations: array(string().min(1)).min(1)
45110
- })
45111
- ]);
45112
- var DeviceTokenScopeSchema = object({
45113
- type: literal("device"),
45114
- /** The device SET this grant covers — resolved against the live fleet. */
45115
- selector: DeviceSelectorSchema,
45116
- access: array(MethodAccessSchema).min(1),
45117
- /**
45118
- * Whether a grant on a PARENT device transparently covers its accessory
45119
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
45120
- * Direction is parent → children ONLY.
45121
- *
45122
- * Absent → the matcher DERIVES it from the access flavour: `view`
45123
- * inherits (a camera viewer sees the camera's accessories), `create` /
45124
- * `delete` do NOT (actuating/removing a child is an explicit act the
45125
- * operator must grant on the child, not inherit from the parent). Set it
45126
- * explicitly to override that default per grant.
45127
- */
45128
- includeLinked: boolean().optional()
45129
- });
45130
- /**
45131
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
45132
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
45133
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
45134
- * EVERY parse path — stored records AND the JWT-carried scope arrays
45135
- * normalised at the request boundary ({@link normalizeTokenScopes} in
45136
- * `device-selector.ts`). Chosen over a one-time DB migration because a
45137
- * migration cannot reach a JWT already in a client's hands; parse-time
45138
- * migration covers both without a flag day. No cast — the raw object is read
45139
- * through `Reflect.get` (its static type is `unknown`).
45140
- */
45141
- function migrateLegacyTokenScope(raw) {
45142
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
45143
- if (Reflect.get(raw, "type") !== "device") return raw;
45144
- if (Reflect.get(raw, "selector") !== void 0) return raw;
45145
- const targets = Reflect.get(raw, "targets");
45146
- if (!Array.isArray(targets)) return raw;
45147
- return {
45148
- type: "device",
45149
- selector: {
45150
- kind: "ids",
45151
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
45152
- },
45153
- access: Reflect.get(raw, "access")
45154
- };
45155
- }
45156
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
45157
- object({
45158
- type: literal("category"),
45159
- target: CapScopeSchema,
45160
- access: array(MethodAccessSchema).min(1)
45161
- }),
45162
- object({
45163
- type: literal("capability"),
45164
- target: string(),
45165
- access: array(MethodAccessSchema).min(1)
45166
- }),
45167
- object({
45168
- type: literal("addon"),
45169
- target: string(),
45170
- access: array(MethodAccessSchema).min(1)
45171
- }),
45172
- DeviceTokenScopeSchema
45173
- ]));
45174
- object({
45175
- id: string(),
45176
- username: string(),
45177
- passwordHash: string(),
45178
- /**
45179
- * Admin bypass. When true, the middleware skips the scope-access
45180
- * check entirely. There is no other axis of privilege; the legacy
45181
- * role enum collapsed onto this boolean in v2.
45182
- */
45183
- isAdmin: boolean().default(false),
45184
- allowedProviders: AllowedProviderSchema,
45185
- allowedDevices: AllowedDevicesSchema,
45186
- /**
45187
- * Scopes granted to this user. Admins bypass; their `scopes` is
45188
- * ignored. Non-admins without scopes are locked out of every
45189
- * protected call.
45190
- */
45191
- scopes: array(TokenScopeSchema).default([]),
45192
- createdAt: number(),
45193
- updatedAt: number()
45194
- });
45195
- object({
45196
- id: string(),
45197
- label: string(),
45198
- isAdmin: boolean().default(false),
45199
- allowedProviders: AllowedProviderSchema,
45200
- allowedDevices: AllowedDevicesSchema,
45201
- tokenHash: string(),
45202
- tokenPrefix: string(),
45203
- createdAt: number(),
45204
- lastUsedAt: number().optional()
45205
- });
45206
- object({
45207
- id: string(),
45208
- userId: string(),
45209
- name: string(),
45210
- tokenHash: string(),
45211
- tokenPrefix: string(),
45212
- scopes: array(TokenScopeSchema),
45213
- expiresAt: number().nullish(),
45214
- lastUsedAt: number().nullish(),
45215
- createdAt: number()
45216
- });
45217
- /**
45218
45251
  * `oauth-integration` — a collection cap by which an addon declares
45219
45252
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
45220
45253
  * Each provider returns a static descriptor; the core enumerates them