@camstack/addon-post-analysis 1.2.609 → 1.2.610

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.
@@ -8025,6 +8025,12 @@ function normalizeAddonInitResult(result) {
8025
8025
  if (Array.isArray(result)) return { providers: result };
8026
8026
  return result;
8027
8027
  }
8028
+ /**
8029
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
8030
+ * and validates them (`share-token.service.ts` builds its enum from this
8031
+ * list); a data plane names the kinds it ACCEPTS in `share`.
8032
+ */
8033
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
8028
8034
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
8029
8035
  var PeerBytesTicketSchema = object({
8030
8036
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -13978,6 +13984,229 @@ var ConvertResultSchema = object({
13978
13984
  files: array(string()).readonly()
13979
13985
  })).readonly()
13980
13986
  });
13987
+ /**
13988
+ * Zod schemas for persisted record types.
13989
+ *
13990
+ * These schemas serve as the single source of truth for types that are
13991
+ * stored in the settings-store backend and retrieved via tRPC. They
13992
+ * replace the manual TypeScript interfaces with schema-derived types,
13993
+ * enabling runtime validation when reading from the backend.
13994
+ *
13995
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
13996
+ * keeps the original name for backward compatibility.
13997
+ */
13998
+ /**
13999
+ * Auth model (v2 — 2026-05-12 caps-only):
14000
+ *
14001
+ * Two principals:
14002
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
14003
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
14004
+ *
14005
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
14006
+ * `super_admin` — collapsed onto the single boolean because every
14007
+ * non-admin caller is governed by the same scope-check rules; the
14008
+ * distinction was only ever used to route role-specific procedures
14009
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
14010
+ * with `isAdmin: false` + an explicit scope list.
14011
+ */
14012
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
14013
+ var MethodAccessSchema = _enum([
14014
+ "view",
14015
+ "create",
14016
+ "delete"
14017
+ ]);
14018
+ /**
14019
+ * A single scope grant. Three forms — checked in matcher with OR
14020
+ * semantics; the first match decides whether the call passes:
14021
+ *
14022
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
14023
+ * cap with the matching `scope` declaration. New caps inherit grants
14024
+ * automatically — adding a device cap to the codebase makes it
14025
+ * reachable to every user with `category:device [...]` without a
14026
+ * re-grant. Use this for "family viewer" / "operator" tiers.
14027
+ *
14028
+ * - `addon` — every cap that ships inside a given addon id. Niche;
14029
+ * useful when an integration needs to interact with one specific
14030
+ * addon's surface regardless of how many caps it exports.
14031
+ *
14032
+ * - `capability` — the most precise form. Single cap name. Use for
14033
+ * integration tokens where you want to grant `addons.installPackage`
14034
+ * and nothing else.
14035
+ *
14036
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
14037
+ * "give me everything" escape; there is no wildcard scope.
14038
+ */
14039
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
14040
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
14041
+ var CapScopeSchema = _enum(["device", "system"]);
14042
+ /**
14043
+ * DeviceSelector (scope model v3 — 2026-08-12).
14044
+ *
14045
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
14046
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
14047
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
14048
+ * AFTER the grant was minted — no re-grant, no re-login.
14049
+ *
14050
+ * - `all` — every device in the deployment. The broad viewer/operator
14051
+ * lever without a `category` grant (a `category` grant also covers device
14052
+ * caps that carry no deviceId; `all` is specifically the device set).
14053
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
14054
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
14055
+ * is NOT covered until the grant is edited.
14056
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
14057
+ * DYNAMIC. A device that changes type, or a new device of the type,
14058
+ * re-resolves on the next request.
14059
+ * - `locations` — every device whose operator-assigned `location` label is
14060
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
14061
+ * null/unset location matches NO `locations` selector.
14062
+ */
14063
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
14064
+ object({ kind: literal("all") }),
14065
+ object({
14066
+ kind: literal("ids"),
14067
+ ids: array(number().int()).min(1)
14068
+ }),
14069
+ object({
14070
+ kind: literal("types"),
14071
+ types: array(_enum(DeviceType)).min(1)
14072
+ }),
14073
+ object({
14074
+ kind: literal("locations"),
14075
+ locations: array(string().min(1)).min(1)
14076
+ })
14077
+ ]);
14078
+ var DeviceTokenScopeSchema = object({
14079
+ type: literal("device"),
14080
+ /** The device SET this grant covers — resolved against the live fleet. */
14081
+ selector: DeviceSelectorSchema,
14082
+ access: array(MethodAccessSchema).min(1),
14083
+ /**
14084
+ * Whether a grant on a PARENT device transparently covers its accessory
14085
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
14086
+ * Direction is parent → children ONLY.
14087
+ *
14088
+ * Absent → the matcher DERIVES it from the access flavour: `view`
14089
+ * inherits (a camera viewer sees the camera's accessories), `create` /
14090
+ * `delete` do NOT (actuating/removing a child is an explicit act the
14091
+ * operator must grant on the child, not inherit from the parent). Set it
14092
+ * explicitly to override that default per grant.
14093
+ */
14094
+ includeLinked: boolean().optional()
14095
+ });
14096
+ /**
14097
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
14098
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
14099
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
14100
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
14101
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
14102
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
14103
+ * migration cannot reach a JWT already in a client's hands; parse-time
14104
+ * migration covers both without a flag day. No cast — the raw object is read
14105
+ * through `Reflect.get` (its static type is `unknown`).
14106
+ */
14107
+ function migrateLegacyTokenScope(raw) {
14108
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
14109
+ if (Reflect.get(raw, "type") !== "device") return raw;
14110
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
14111
+ const targets = Reflect.get(raw, "targets");
14112
+ if (!Array.isArray(targets)) return raw;
14113
+ return {
14114
+ type: "device",
14115
+ selector: {
14116
+ kind: "ids",
14117
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
14118
+ },
14119
+ access: Reflect.get(raw, "access")
14120
+ };
14121
+ }
14122
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
14123
+ object({
14124
+ type: literal("category"),
14125
+ target: CapScopeSchema,
14126
+ access: array(MethodAccessSchema).min(1)
14127
+ }),
14128
+ object({
14129
+ type: literal("capability"),
14130
+ target: string(),
14131
+ access: array(MethodAccessSchema).min(1)
14132
+ }),
14133
+ object({
14134
+ type: literal("addon"),
14135
+ target: string(),
14136
+ access: array(MethodAccessSchema).min(1)
14137
+ }),
14138
+ DeviceTokenScopeSchema
14139
+ ]));
14140
+ object({
14141
+ id: string(),
14142
+ username: string(),
14143
+ passwordHash: string(),
14144
+ /**
14145
+ * Admin bypass. When true, the middleware skips the scope-access
14146
+ * check entirely. There is no other axis of privilege; the legacy
14147
+ * role enum collapsed onto this boolean in v2.
14148
+ */
14149
+ isAdmin: boolean().default(false),
14150
+ allowedProviders: AllowedProviderSchema,
14151
+ allowedDevices: AllowedDevicesSchema,
14152
+ /**
14153
+ * Scopes granted to this user. Admins bypass; their `scopes` is
14154
+ * ignored. Non-admins without scopes are locked out of every
14155
+ * protected call.
14156
+ */
14157
+ scopes: array(TokenScopeSchema).default([]),
14158
+ createdAt: number(),
14159
+ updatedAt: number()
14160
+ });
14161
+ object({
14162
+ id: string(),
14163
+ label: string(),
14164
+ isAdmin: boolean().default(false),
14165
+ allowedProviders: AllowedProviderSchema,
14166
+ allowedDevices: AllowedDevicesSchema,
14167
+ tokenHash: string(),
14168
+ tokenPrefix: string(),
14169
+ createdAt: number(),
14170
+ lastUsedAt: number().optional()
14171
+ });
14172
+ object({
14173
+ id: string(),
14174
+ userId: string(),
14175
+ name: string(),
14176
+ tokenHash: string(),
14177
+ tokenPrefix: string(),
14178
+ scopes: array(TokenScopeSchema),
14179
+ expiresAt: number().nullish(),
14180
+ lastUsedAt: number().nullish(),
14181
+ createdAt: number()
14182
+ });
14183
+ /** What a share-view grant lets its holder see. */
14184
+ var ShareViewGrantSchema = object({
14185
+ kind: _enum(SHARE_VIEW_KINDS),
14186
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
14187
+ /** Talk-back, opt-in at mint time; absent means off. */
14188
+ talk: boolean().optional()
14189
+ });
14190
+ var ShareViewScopeSchema = object({
14191
+ type: literal("share-view"),
14192
+ grant: ShareViewGrantSchema
14193
+ });
14194
+ var AddonRoutesScopeSchema = object({
14195
+ type: literal("addon-routes"),
14196
+ access: array(MethodAccessSchema).min(1)
14197
+ });
14198
+ var CredentialScopeSchema = union([
14199
+ literal("*"),
14200
+ ShareViewScopeSchema,
14201
+ AddonRoutesScopeSchema,
14202
+ TokenScopeSchema
14203
+ ]);
14204
+ object({
14205
+ kind: literal("credential"),
14206
+ sub: string().min(1),
14207
+ jti: string().min(16),
14208
+ scopes: array(CredentialScopeSchema).min(1)
14209
+ });
13981
14210
  _enum(["new-session", "step-up"]);
13982
14211
  /** The languages the hub's app landing pages are written in (D858). */
13983
14212
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -46524,202 +46753,6 @@ var notificationRulesCapability = {
46524
46753
  }
46525
46754
  };
46526
46755
  /**
46527
- * Zod schemas for persisted record types.
46528
- *
46529
- * These schemas serve as the single source of truth for types that are
46530
- * stored in the settings-store backend and retrieved via tRPC. They
46531
- * replace the manual TypeScript interfaces with schema-derived types,
46532
- * enabling runtime validation when reading from the backend.
46533
- *
46534
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
46535
- * keeps the original name for backward compatibility.
46536
- */
46537
- /**
46538
- * Auth model (v2 — 2026-05-12 caps-only):
46539
- *
46540
- * Two principals:
46541
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
46542
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
46543
- *
46544
- * No role enum. There used to be `viewer / agent / scoped` and earlier
46545
- * `super_admin` — collapsed onto the single boolean because every
46546
- * non-admin caller is governed by the same scope-check rules; the
46547
- * distinction was only ever used to route role-specific procedures
46548
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
46549
- * with `isAdmin: false` + an explicit scope list.
46550
- */
46551
- /** Per-method access flavour. Materialised on every cap method via codegen. */
46552
- var MethodAccessSchema = _enum([
46553
- "view",
46554
- "create",
46555
- "delete"
46556
- ]);
46557
- /**
46558
- * A single scope grant. Three forms — checked in matcher with OR
46559
- * semantics; the first match decides whether the call passes:
46560
- *
46561
- * - `category` — broadest. `target: 'device' | 'system'` selects every
46562
- * cap with the matching `scope` declaration. New caps inherit grants
46563
- * automatically — adding a device cap to the codebase makes it
46564
- * reachable to every user with `category:device [...]` without a
46565
- * re-grant. Use this for "family viewer" / "operator" tiers.
46566
- *
46567
- * - `addon` — every cap that ships inside a given addon id. Niche;
46568
- * useful when an integration needs to interact with one specific
46569
- * addon's surface regardless of how many caps it exports.
46570
- *
46571
- * - `capability` — the most precise form. Single cap name. Use for
46572
- * integration tokens where you want to grant `addons.installPackage`
46573
- * and nothing else.
46574
- *
46575
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
46576
- * "give me everything" escape; there is no wildcard scope.
46577
- */
46578
- var AllowedProviderSchema = union([literal("*"), array(string())]);
46579
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
46580
- var CapScopeSchema = _enum(["device", "system"]);
46581
- /**
46582
- * DeviceSelector (scope model v3 — 2026-08-12).
46583
- *
46584
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
46585
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
46586
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
46587
- * AFTER the grant was minted — no re-grant, no re-login.
46588
- *
46589
- * - `all` — every device in the deployment. The broad viewer/operator
46590
- * lever without a `category` grant (a `category` grant also covers device
46591
- * caps that carry no deviceId; `all` is specifically the device set).
46592
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
46593
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
46594
- * is NOT covered until the grant is edited.
46595
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
46596
- * DYNAMIC. A device that changes type, or a new device of the type,
46597
- * re-resolves on the next request.
46598
- * - `locations` — every device whose operator-assigned `location` label is
46599
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
46600
- * null/unset location matches NO `locations` selector.
46601
- */
46602
- var DeviceSelectorSchema = discriminatedUnion("kind", [
46603
- object({ kind: literal("all") }),
46604
- object({
46605
- kind: literal("ids"),
46606
- ids: array(number().int()).min(1)
46607
- }),
46608
- object({
46609
- kind: literal("types"),
46610
- types: array(_enum(DeviceType)).min(1)
46611
- }),
46612
- object({
46613
- kind: literal("locations"),
46614
- locations: array(string().min(1)).min(1)
46615
- })
46616
- ]);
46617
- var DeviceTokenScopeSchema = object({
46618
- type: literal("device"),
46619
- /** The device SET this grant covers — resolved against the live fleet. */
46620
- selector: DeviceSelectorSchema,
46621
- access: array(MethodAccessSchema).min(1),
46622
- /**
46623
- * Whether a grant on a PARENT device transparently covers its accessory
46624
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
46625
- * Direction is parent → children ONLY.
46626
- *
46627
- * Absent → the matcher DERIVES it from the access flavour: `view`
46628
- * inherits (a camera viewer sees the camera's accessories), `create` /
46629
- * `delete` do NOT (actuating/removing a child is an explicit act the
46630
- * operator must grant on the child, not inherit from the parent). Set it
46631
- * explicitly to override that default per grant.
46632
- */
46633
- includeLinked: boolean().optional()
46634
- });
46635
- /**
46636
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
46637
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
46638
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
46639
- * EVERY parse path — stored records AND the JWT-carried scope arrays
46640
- * normalised at the request boundary ({@link normalizeTokenScopes} in
46641
- * `device-selector.ts`). Chosen over a one-time DB migration because a
46642
- * migration cannot reach a JWT already in a client's hands; parse-time
46643
- * migration covers both without a flag day. No cast — the raw object is read
46644
- * through `Reflect.get` (its static type is `unknown`).
46645
- */
46646
- function migrateLegacyTokenScope(raw) {
46647
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
46648
- if (Reflect.get(raw, "type") !== "device") return raw;
46649
- if (Reflect.get(raw, "selector") !== void 0) return raw;
46650
- const targets = Reflect.get(raw, "targets");
46651
- if (!Array.isArray(targets)) return raw;
46652
- return {
46653
- type: "device",
46654
- selector: {
46655
- kind: "ids",
46656
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
46657
- },
46658
- access: Reflect.get(raw, "access")
46659
- };
46660
- }
46661
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
46662
- object({
46663
- type: literal("category"),
46664
- target: CapScopeSchema,
46665
- access: array(MethodAccessSchema).min(1)
46666
- }),
46667
- object({
46668
- type: literal("capability"),
46669
- target: string(),
46670
- access: array(MethodAccessSchema).min(1)
46671
- }),
46672
- object({
46673
- type: literal("addon"),
46674
- target: string(),
46675
- access: array(MethodAccessSchema).min(1)
46676
- }),
46677
- DeviceTokenScopeSchema
46678
- ]));
46679
- object({
46680
- id: string(),
46681
- username: string(),
46682
- passwordHash: string(),
46683
- /**
46684
- * Admin bypass. When true, the middleware skips the scope-access
46685
- * check entirely. There is no other axis of privilege; the legacy
46686
- * role enum collapsed onto this boolean in v2.
46687
- */
46688
- isAdmin: boolean().default(false),
46689
- allowedProviders: AllowedProviderSchema,
46690
- allowedDevices: AllowedDevicesSchema,
46691
- /**
46692
- * Scopes granted to this user. Admins bypass; their `scopes` is
46693
- * ignored. Non-admins without scopes are locked out of every
46694
- * protected call.
46695
- */
46696
- scopes: array(TokenScopeSchema).default([]),
46697
- createdAt: number(),
46698
- updatedAt: number()
46699
- });
46700
- object({
46701
- id: string(),
46702
- label: string(),
46703
- isAdmin: boolean().default(false),
46704
- allowedProviders: AllowedProviderSchema,
46705
- allowedDevices: AllowedDevicesSchema,
46706
- tokenHash: string(),
46707
- tokenPrefix: string(),
46708
- createdAt: number(),
46709
- lastUsedAt: number().optional()
46710
- });
46711
- object({
46712
- id: string(),
46713
- userId: string(),
46714
- name: string(),
46715
- tokenHash: string(),
46716
- tokenPrefix: string(),
46717
- scopes: array(TokenScopeSchema),
46718
- expiresAt: number().nullish(),
46719
- lastUsedAt: number().nullish(),
46720
- createdAt: number()
46721
- });
46722
- /**
46723
46756
  * `oauth-integration` — a collection cap by which an addon declares
46724
46757
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
46725
46758
  * Each provider returns a static descriptor; the core enumerates them