@camstack/addon-export-google 0.1.95 → 0.1.96

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.
@@ -7874,6 +7874,12 @@ function normalizeAddonInitResult(result) {
7874
7874
  if (Array.isArray(result)) return { providers: result };
7875
7875
  return result;
7876
7876
  }
7877
+ /**
7878
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7879
+ * and validates them (`share-token.service.ts` builds its enum from this
7880
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7881
+ */
7882
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7877
7883
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7878
7884
  var PeerBytesTicketSchema = object({
7879
7885
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12614,6 +12620,229 @@ var ConvertResultSchema = object({
12614
12620
  function scopesAllowDeviceCap(scopes, access) {
12615
12621
  return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
12616
12622
  }
12623
+ /**
12624
+ * Zod schemas for persisted record types.
12625
+ *
12626
+ * These schemas serve as the single source of truth for types that are
12627
+ * stored in the settings-store backend and retrieved via tRPC. They
12628
+ * replace the manual TypeScript interfaces with schema-derived types,
12629
+ * enabling runtime validation when reading from the backend.
12630
+ *
12631
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12632
+ * keeps the original name for backward compatibility.
12633
+ */
12634
+ /**
12635
+ * Auth model (v2 — 2026-05-12 caps-only):
12636
+ *
12637
+ * Two principals:
12638
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12639
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12640
+ *
12641
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12642
+ * `super_admin` — collapsed onto the single boolean because every
12643
+ * non-admin caller is governed by the same scope-check rules; the
12644
+ * distinction was only ever used to route role-specific procedures
12645
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12646
+ * with `isAdmin: false` + an explicit scope list.
12647
+ */
12648
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12649
+ var MethodAccessSchema = _enum([
12650
+ "view",
12651
+ "create",
12652
+ "delete"
12653
+ ]);
12654
+ /**
12655
+ * A single scope grant. Three forms — checked in matcher with OR
12656
+ * semantics; the first match decides whether the call passes:
12657
+ *
12658
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12659
+ * cap with the matching `scope` declaration. New caps inherit grants
12660
+ * automatically — adding a device cap to the codebase makes it
12661
+ * reachable to every user with `category:device [...]` without a
12662
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12663
+ *
12664
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12665
+ * useful when an integration needs to interact with one specific
12666
+ * addon's surface regardless of how many caps it exports.
12667
+ *
12668
+ * - `capability` — the most precise form. Single cap name. Use for
12669
+ * integration tokens where you want to grant `addons.installPackage`
12670
+ * and nothing else.
12671
+ *
12672
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12673
+ * "give me everything" escape; there is no wildcard scope.
12674
+ */
12675
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12676
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12677
+ var CapScopeSchema = _enum(["device", "system"]);
12678
+ /**
12679
+ * DeviceSelector (scope model v3 — 2026-08-12).
12680
+ *
12681
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12682
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12683
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12684
+ * AFTER the grant was minted — no re-grant, no re-login.
12685
+ *
12686
+ * - `all` — every device in the deployment. The broad viewer/operator
12687
+ * lever without a `category` grant (a `category` grant also covers device
12688
+ * caps that carry no deviceId; `all` is specifically the device set).
12689
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12690
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12691
+ * is NOT covered until the grant is edited.
12692
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12693
+ * DYNAMIC. A device that changes type, or a new device of the type,
12694
+ * re-resolves on the next request.
12695
+ * - `locations` — every device whose operator-assigned `location` label is
12696
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12697
+ * null/unset location matches NO `locations` selector.
12698
+ */
12699
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12700
+ object({ kind: literal("all") }),
12701
+ object({
12702
+ kind: literal("ids"),
12703
+ ids: array(number().int()).min(1)
12704
+ }),
12705
+ object({
12706
+ kind: literal("types"),
12707
+ types: array(_enum(DeviceType)).min(1)
12708
+ }),
12709
+ object({
12710
+ kind: literal("locations"),
12711
+ locations: array(string().min(1)).min(1)
12712
+ })
12713
+ ]);
12714
+ var DeviceTokenScopeSchema = object({
12715
+ type: literal("device"),
12716
+ /** The device SET this grant covers — resolved against the live fleet. */
12717
+ selector: DeviceSelectorSchema,
12718
+ access: array(MethodAccessSchema).min(1),
12719
+ /**
12720
+ * Whether a grant on a PARENT device transparently covers its accessory
12721
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12722
+ * Direction is parent → children ONLY.
12723
+ *
12724
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12725
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12726
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12727
+ * operator must grant on the child, not inherit from the parent). Set it
12728
+ * explicitly to override that default per grant.
12729
+ */
12730
+ includeLinked: boolean().optional()
12731
+ });
12732
+ /**
12733
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12734
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12735
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12736
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12737
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12738
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12739
+ * migration cannot reach a JWT already in a client's hands; parse-time
12740
+ * migration covers both without a flag day. No cast — the raw object is read
12741
+ * through `Reflect.get` (its static type is `unknown`).
12742
+ */
12743
+ function migrateLegacyTokenScope(raw) {
12744
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12745
+ if (Reflect.get(raw, "type") !== "device") return raw;
12746
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12747
+ const targets = Reflect.get(raw, "targets");
12748
+ if (!Array.isArray(targets)) return raw;
12749
+ return {
12750
+ type: "device",
12751
+ selector: {
12752
+ kind: "ids",
12753
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12754
+ },
12755
+ access: Reflect.get(raw, "access")
12756
+ };
12757
+ }
12758
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12759
+ object({
12760
+ type: literal("category"),
12761
+ target: CapScopeSchema,
12762
+ access: array(MethodAccessSchema).min(1)
12763
+ }),
12764
+ object({
12765
+ type: literal("capability"),
12766
+ target: string(),
12767
+ access: array(MethodAccessSchema).min(1)
12768
+ }),
12769
+ object({
12770
+ type: literal("addon"),
12771
+ target: string(),
12772
+ access: array(MethodAccessSchema).min(1)
12773
+ }),
12774
+ DeviceTokenScopeSchema
12775
+ ]));
12776
+ object({
12777
+ id: string(),
12778
+ username: string(),
12779
+ passwordHash: string(),
12780
+ /**
12781
+ * Admin bypass. When true, the middleware skips the scope-access
12782
+ * check entirely. There is no other axis of privilege; the legacy
12783
+ * role enum collapsed onto this boolean in v2.
12784
+ */
12785
+ isAdmin: boolean().default(false),
12786
+ allowedProviders: AllowedProviderSchema,
12787
+ allowedDevices: AllowedDevicesSchema,
12788
+ /**
12789
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12790
+ * ignored. Non-admins without scopes are locked out of every
12791
+ * protected call.
12792
+ */
12793
+ scopes: array(TokenScopeSchema).default([]),
12794
+ createdAt: number(),
12795
+ updatedAt: number()
12796
+ });
12797
+ object({
12798
+ id: string(),
12799
+ label: string(),
12800
+ isAdmin: boolean().default(false),
12801
+ allowedProviders: AllowedProviderSchema,
12802
+ allowedDevices: AllowedDevicesSchema,
12803
+ tokenHash: string(),
12804
+ tokenPrefix: string(),
12805
+ createdAt: number(),
12806
+ lastUsedAt: number().optional()
12807
+ });
12808
+ object({
12809
+ id: string(),
12810
+ userId: string(),
12811
+ name: string(),
12812
+ tokenHash: string(),
12813
+ tokenPrefix: string(),
12814
+ scopes: array(TokenScopeSchema),
12815
+ expiresAt: number().nullish(),
12816
+ lastUsedAt: number().nullish(),
12817
+ createdAt: number()
12818
+ });
12819
+ /** What a share-view grant lets its holder see. */
12820
+ var ShareViewGrantSchema = object({
12821
+ kind: _enum(SHARE_VIEW_KINDS),
12822
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12823
+ /** Talk-back, opt-in at mint time; absent means off. */
12824
+ talk: boolean().optional()
12825
+ });
12826
+ var ShareViewScopeSchema = object({
12827
+ type: literal("share-view"),
12828
+ grant: ShareViewGrantSchema
12829
+ });
12830
+ var AddonRoutesScopeSchema = object({
12831
+ type: literal("addon-routes"),
12832
+ access: array(MethodAccessSchema).min(1)
12833
+ });
12834
+ var CredentialScopeSchema = union([
12835
+ literal("*"),
12836
+ ShareViewScopeSchema,
12837
+ AddonRoutesScopeSchema,
12838
+ TokenScopeSchema
12839
+ ]);
12840
+ object({
12841
+ kind: literal("credential"),
12842
+ sub: string().min(1),
12843
+ jti: string().min(16),
12844
+ scopes: array(CredentialScopeSchema).min(1)
12845
+ });
12617
12846
  _enum(["new-session", "step-up"]);
12618
12847
  /** The languages the hub's app landing pages are written in (D858). */
12619
12848
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43795,202 +44024,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43795
44024
  auth: "admin"
43796
44025
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43797
44026
  /**
43798
- * Zod schemas for persisted record types.
43799
- *
43800
- * These schemas serve as the single source of truth for types that are
43801
- * stored in the settings-store backend and retrieved via tRPC. They
43802
- * replace the manual TypeScript interfaces with schema-derived types,
43803
- * enabling runtime validation when reading from the backend.
43804
- *
43805
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43806
- * keeps the original name for backward compatibility.
43807
- */
43808
- /**
43809
- * Auth model (v2 — 2026-05-12 caps-only):
43810
- *
43811
- * Two principals:
43812
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43813
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43814
- *
43815
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43816
- * `super_admin` — collapsed onto the single boolean because every
43817
- * non-admin caller is governed by the same scope-check rules; the
43818
- * distinction was only ever used to route role-specific procedures
43819
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43820
- * with `isAdmin: false` + an explicit scope list.
43821
- */
43822
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43823
- var MethodAccessSchema = _enum([
43824
- "view",
43825
- "create",
43826
- "delete"
43827
- ]);
43828
- /**
43829
- * A single scope grant. Three forms — checked in matcher with OR
43830
- * semantics; the first match decides whether the call passes:
43831
- *
43832
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43833
- * cap with the matching `scope` declaration. New caps inherit grants
43834
- * automatically — adding a device cap to the codebase makes it
43835
- * reachable to every user with `category:device [...]` without a
43836
- * re-grant. Use this for "family viewer" / "operator" tiers.
43837
- *
43838
- * - `addon` — every cap that ships inside a given addon id. Niche;
43839
- * useful when an integration needs to interact with one specific
43840
- * addon's surface regardless of how many caps it exports.
43841
- *
43842
- * - `capability` — the most precise form. Single cap name. Use for
43843
- * integration tokens where you want to grant `addons.installPackage`
43844
- * and nothing else.
43845
- *
43846
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43847
- * "give me everything" escape; there is no wildcard scope.
43848
- */
43849
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43850
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43851
- var CapScopeSchema = _enum(["device", "system"]);
43852
- /**
43853
- * DeviceSelector (scope model v3 — 2026-08-12).
43854
- *
43855
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43856
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43857
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43858
- * AFTER the grant was minted — no re-grant, no re-login.
43859
- *
43860
- * - `all` — every device in the deployment. The broad viewer/operator
43861
- * lever without a `category` grant (a `category` grant also covers device
43862
- * caps that carry no deviceId; `all` is specifically the device set).
43863
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43864
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43865
- * is NOT covered until the grant is edited.
43866
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43867
- * DYNAMIC. A device that changes type, or a new device of the type,
43868
- * re-resolves on the next request.
43869
- * - `locations` — every device whose operator-assigned `location` label is
43870
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43871
- * null/unset location matches NO `locations` selector.
43872
- */
43873
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43874
- object({ kind: literal("all") }),
43875
- object({
43876
- kind: literal("ids"),
43877
- ids: array(number().int()).min(1)
43878
- }),
43879
- object({
43880
- kind: literal("types"),
43881
- types: array(_enum(DeviceType)).min(1)
43882
- }),
43883
- object({
43884
- kind: literal("locations"),
43885
- locations: array(string().min(1)).min(1)
43886
- })
43887
- ]);
43888
- var DeviceTokenScopeSchema = object({
43889
- type: literal("device"),
43890
- /** The device SET this grant covers — resolved against the live fleet. */
43891
- selector: DeviceSelectorSchema,
43892
- access: array(MethodAccessSchema).min(1),
43893
- /**
43894
- * Whether a grant on a PARENT device transparently covers its accessory
43895
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43896
- * Direction is parent → children ONLY.
43897
- *
43898
- * Absent → the matcher DERIVES it from the access flavour: `view`
43899
- * inherits (a camera viewer sees the camera's accessories), `create` /
43900
- * `delete` do NOT (actuating/removing a child is an explicit act the
43901
- * operator must grant on the child, not inherit from the parent). Set it
43902
- * explicitly to override that default per grant.
43903
- */
43904
- includeLinked: boolean().optional()
43905
- });
43906
- /**
43907
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43908
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43909
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43910
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43911
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43912
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43913
- * migration cannot reach a JWT already in a client's hands; parse-time
43914
- * migration covers both without a flag day. No cast — the raw object is read
43915
- * through `Reflect.get` (its static type is `unknown`).
43916
- */
43917
- function migrateLegacyTokenScope(raw) {
43918
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43919
- if (Reflect.get(raw, "type") !== "device") return raw;
43920
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43921
- const targets = Reflect.get(raw, "targets");
43922
- if (!Array.isArray(targets)) return raw;
43923
- return {
43924
- type: "device",
43925
- selector: {
43926
- kind: "ids",
43927
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43928
- },
43929
- access: Reflect.get(raw, "access")
43930
- };
43931
- }
43932
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43933
- object({
43934
- type: literal("category"),
43935
- target: CapScopeSchema,
43936
- access: array(MethodAccessSchema).min(1)
43937
- }),
43938
- object({
43939
- type: literal("capability"),
43940
- target: string(),
43941
- access: array(MethodAccessSchema).min(1)
43942
- }),
43943
- object({
43944
- type: literal("addon"),
43945
- target: string(),
43946
- access: array(MethodAccessSchema).min(1)
43947
- }),
43948
- DeviceTokenScopeSchema
43949
- ]));
43950
- object({
43951
- id: string(),
43952
- username: string(),
43953
- passwordHash: string(),
43954
- /**
43955
- * Admin bypass. When true, the middleware skips the scope-access
43956
- * check entirely. There is no other axis of privilege; the legacy
43957
- * role enum collapsed onto this boolean in v2.
43958
- */
43959
- isAdmin: boolean().default(false),
43960
- allowedProviders: AllowedProviderSchema,
43961
- allowedDevices: AllowedDevicesSchema,
43962
- /**
43963
- * Scopes granted to this user. Admins bypass; their `scopes` is
43964
- * ignored. Non-admins without scopes are locked out of every
43965
- * protected call.
43966
- */
43967
- scopes: array(TokenScopeSchema).default([]),
43968
- createdAt: number(),
43969
- updatedAt: number()
43970
- });
43971
- object({
43972
- id: string(),
43973
- label: string(),
43974
- isAdmin: boolean().default(false),
43975
- allowedProviders: AllowedProviderSchema,
43976
- allowedDevices: AllowedDevicesSchema,
43977
- tokenHash: string(),
43978
- tokenPrefix: string(),
43979
- createdAt: number(),
43980
- lastUsedAt: number().optional()
43981
- });
43982
- object({
43983
- id: string(),
43984
- userId: string(),
43985
- name: string(),
43986
- tokenHash: string(),
43987
- tokenPrefix: string(),
43988
- scopes: array(TokenScopeSchema),
43989
- expiresAt: number().nullish(),
43990
- lastUsedAt: number().nullish(),
43991
- createdAt: number()
43992
- });
43993
- /**
43994
44027
  * `oauth-integration` — a collection cap by which an addon declares
43995
44028
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43996
44029
  * Each provider returns a static descriptor; the core enumerates them
@@ -7870,6 +7870,12 @@ function normalizeAddonInitResult(result) {
7870
7870
  if (Array.isArray(result)) return { providers: result };
7871
7871
  return result;
7872
7872
  }
7873
+ /**
7874
+ * The share-view scope kinds a `csv_*` share token can carry. The hub mints
7875
+ * and validates them (`share-token.service.ts` builds its enum from this
7876
+ * list); a data plane names the kinds it ACCEPTS in `share`.
7877
+ */
7878
+ var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
7873
7879
  /** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
7874
7880
  var PeerBytesTicketSchema = object({
7875
7881
  /** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
@@ -12610,6 +12616,229 @@ var ConvertResultSchema = object({
12610
12616
  function scopesAllowDeviceCap(scopes, access) {
12611
12617
  return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
12612
12618
  }
12619
+ /**
12620
+ * Zod schemas for persisted record types.
12621
+ *
12622
+ * These schemas serve as the single source of truth for types that are
12623
+ * stored in the settings-store backend and retrieved via tRPC. They
12624
+ * replace the manual TypeScript interfaces with schema-derived types,
12625
+ * enabling runtime validation when reading from the backend.
12626
+ *
12627
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
12628
+ * keeps the original name for backward compatibility.
12629
+ */
12630
+ /**
12631
+ * Auth model (v2 — 2026-05-12 caps-only):
12632
+ *
12633
+ * Two principals:
12634
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
12635
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
12636
+ *
12637
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
12638
+ * `super_admin` — collapsed onto the single boolean because every
12639
+ * non-admin caller is governed by the same scope-check rules; the
12640
+ * distinction was only ever used to route role-specific procedures
12641
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
12642
+ * with `isAdmin: false` + an explicit scope list.
12643
+ */
12644
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
12645
+ var MethodAccessSchema = _enum([
12646
+ "view",
12647
+ "create",
12648
+ "delete"
12649
+ ]);
12650
+ /**
12651
+ * A single scope grant. Three forms — checked in matcher with OR
12652
+ * semantics; the first match decides whether the call passes:
12653
+ *
12654
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
12655
+ * cap with the matching `scope` declaration. New caps inherit grants
12656
+ * automatically — adding a device cap to the codebase makes it
12657
+ * reachable to every user with `category:device [...]` without a
12658
+ * re-grant. Use this for "family viewer" / "operator" tiers.
12659
+ *
12660
+ * - `addon` — every cap that ships inside a given addon id. Niche;
12661
+ * useful when an integration needs to interact with one specific
12662
+ * addon's surface regardless of how many caps it exports.
12663
+ *
12664
+ * - `capability` — the most precise form. Single cap name. Use for
12665
+ * integration tokens where you want to grant `addons.installPackage`
12666
+ * and nothing else.
12667
+ *
12668
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
12669
+ * "give me everything" escape; there is no wildcard scope.
12670
+ */
12671
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
12672
+ var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
12673
+ var CapScopeSchema = _enum(["device", "system"]);
12674
+ /**
12675
+ * DeviceSelector (scope model v3 — 2026-08-12).
12676
+ *
12677
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
12678
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
12679
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
12680
+ * AFTER the grant was minted — no re-grant, no re-login.
12681
+ *
12682
+ * - `all` — every device in the deployment. The broad viewer/operator
12683
+ * lever without a `category` grant (a `category` grant also covers device
12684
+ * caps that carry no deviceId; `all` is specifically the device set).
12685
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
12686
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
12687
+ * is NOT covered until the grant is edited.
12688
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
12689
+ * DYNAMIC. A device that changes type, or a new device of the type,
12690
+ * re-resolves on the next request.
12691
+ * - `locations` — every device whose operator-assigned `location` label is
12692
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
12693
+ * null/unset location matches NO `locations` selector.
12694
+ */
12695
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
12696
+ object({ kind: literal("all") }),
12697
+ object({
12698
+ kind: literal("ids"),
12699
+ ids: array(number().int()).min(1)
12700
+ }),
12701
+ object({
12702
+ kind: literal("types"),
12703
+ types: array(_enum(DeviceType)).min(1)
12704
+ }),
12705
+ object({
12706
+ kind: literal("locations"),
12707
+ locations: array(string().min(1)).min(1)
12708
+ })
12709
+ ]);
12710
+ var DeviceTokenScopeSchema = object({
12711
+ type: literal("device"),
12712
+ /** The device SET this grant covers — resolved against the live fleet. */
12713
+ selector: DeviceSelectorSchema,
12714
+ access: array(MethodAccessSchema).min(1),
12715
+ /**
12716
+ * Whether a grant on a PARENT device transparently covers its accessory
12717
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
12718
+ * Direction is parent → children ONLY.
12719
+ *
12720
+ * Absent → the matcher DERIVES it from the access flavour: `view`
12721
+ * inherits (a camera viewer sees the camera's accessories), `create` /
12722
+ * `delete` do NOT (actuating/removing a child is an explicit act the
12723
+ * operator must grant on the child, not inherit from the parent). Set it
12724
+ * explicitly to override that default per grant.
12725
+ */
12726
+ includeLinked: boolean().optional()
12727
+ });
12728
+ /**
12729
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
12730
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
12731
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
12732
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
12733
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
12734
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
12735
+ * migration cannot reach a JWT already in a client's hands; parse-time
12736
+ * migration covers both without a flag day. No cast — the raw object is read
12737
+ * through `Reflect.get` (its static type is `unknown`).
12738
+ */
12739
+ function migrateLegacyTokenScope(raw) {
12740
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
12741
+ if (Reflect.get(raw, "type") !== "device") return raw;
12742
+ if (Reflect.get(raw, "selector") !== void 0) return raw;
12743
+ const targets = Reflect.get(raw, "targets");
12744
+ if (!Array.isArray(targets)) return raw;
12745
+ return {
12746
+ type: "device",
12747
+ selector: {
12748
+ kind: "ids",
12749
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
12750
+ },
12751
+ access: Reflect.get(raw, "access")
12752
+ };
12753
+ }
12754
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
12755
+ object({
12756
+ type: literal("category"),
12757
+ target: CapScopeSchema,
12758
+ access: array(MethodAccessSchema).min(1)
12759
+ }),
12760
+ object({
12761
+ type: literal("capability"),
12762
+ target: string(),
12763
+ access: array(MethodAccessSchema).min(1)
12764
+ }),
12765
+ object({
12766
+ type: literal("addon"),
12767
+ target: string(),
12768
+ access: array(MethodAccessSchema).min(1)
12769
+ }),
12770
+ DeviceTokenScopeSchema
12771
+ ]));
12772
+ object({
12773
+ id: string(),
12774
+ username: string(),
12775
+ passwordHash: string(),
12776
+ /**
12777
+ * Admin bypass. When true, the middleware skips the scope-access
12778
+ * check entirely. There is no other axis of privilege; the legacy
12779
+ * role enum collapsed onto this boolean in v2.
12780
+ */
12781
+ isAdmin: boolean().default(false),
12782
+ allowedProviders: AllowedProviderSchema,
12783
+ allowedDevices: AllowedDevicesSchema,
12784
+ /**
12785
+ * Scopes granted to this user. Admins bypass; their `scopes` is
12786
+ * ignored. Non-admins without scopes are locked out of every
12787
+ * protected call.
12788
+ */
12789
+ scopes: array(TokenScopeSchema).default([]),
12790
+ createdAt: number(),
12791
+ updatedAt: number()
12792
+ });
12793
+ object({
12794
+ id: string(),
12795
+ label: string(),
12796
+ isAdmin: boolean().default(false),
12797
+ allowedProviders: AllowedProviderSchema,
12798
+ allowedDevices: AllowedDevicesSchema,
12799
+ tokenHash: string(),
12800
+ tokenPrefix: string(),
12801
+ createdAt: number(),
12802
+ lastUsedAt: number().optional()
12803
+ });
12804
+ object({
12805
+ id: string(),
12806
+ userId: string(),
12807
+ name: string(),
12808
+ tokenHash: string(),
12809
+ tokenPrefix: string(),
12810
+ scopes: array(TokenScopeSchema),
12811
+ expiresAt: number().nullish(),
12812
+ lastUsedAt: number().nullish(),
12813
+ createdAt: number()
12814
+ });
12815
+ /** What a share-view grant lets its holder see. */
12816
+ var ShareViewGrantSchema = object({
12817
+ kind: _enum(SHARE_VIEW_KINDS),
12818
+ deviceIds: array(number().int().nonnegative()).min(1).max(64),
12819
+ /** Talk-back, opt-in at mint time; absent means off. */
12820
+ talk: boolean().optional()
12821
+ });
12822
+ var ShareViewScopeSchema = object({
12823
+ type: literal("share-view"),
12824
+ grant: ShareViewGrantSchema
12825
+ });
12826
+ var AddonRoutesScopeSchema = object({
12827
+ type: literal("addon-routes"),
12828
+ access: array(MethodAccessSchema).min(1)
12829
+ });
12830
+ var CredentialScopeSchema = union([
12831
+ literal("*"),
12832
+ ShareViewScopeSchema,
12833
+ AddonRoutesScopeSchema,
12834
+ TokenScopeSchema
12835
+ ]);
12836
+ object({
12837
+ kind: literal("credential"),
12838
+ sub: string().min(1),
12839
+ jti: string().min(16),
12840
+ scopes: array(CredentialScopeSchema).min(1)
12841
+ });
12613
12842
  _enum(["new-session", "step-up"]);
12614
12843
  /** The languages the hub's app landing pages are written in (D858). */
12615
12844
  var AppPageLangSchema = _enum(["en", "it"]);
@@ -43791,202 +44020,6 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
43791
44020
  auth: "admin"
43792
44021
  }), method(NcAlarmSensorsInputSchema, NcAlarmSensorsSchema, { auth: "admin" });
43793
44022
  /**
43794
- * Zod schemas for persisted record types.
43795
- *
43796
- * These schemas serve as the single source of truth for types that are
43797
- * stored in the settings-store backend and retrieved via tRPC. They
43798
- * replace the manual TypeScript interfaces with schema-derived types,
43799
- * enabling runtime validation when reading from the backend.
43800
- *
43801
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
43802
- * keeps the original name for backward compatibility.
43803
- */
43804
- /**
43805
- * Auth model (v2 — 2026-05-12 caps-only):
43806
- *
43807
- * Two principals:
43808
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
43809
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
43810
- *
43811
- * No role enum. There used to be `viewer / agent / scoped` and earlier
43812
- * `super_admin` — collapsed onto the single boolean because every
43813
- * non-admin caller is governed by the same scope-check rules; the
43814
- * distinction was only ever used to route role-specific procedures
43815
- * which we no longer have. CLI / webhook integrations are `cst_*` tokens
43816
- * with `isAdmin: false` + an explicit scope list.
43817
- */
43818
- /** Per-method access flavour. Materialised on every cap method via codegen. */
43819
- var MethodAccessSchema = _enum([
43820
- "view",
43821
- "create",
43822
- "delete"
43823
- ]);
43824
- /**
43825
- * A single scope grant. Three forms — checked in matcher with OR
43826
- * semantics; the first match decides whether the call passes:
43827
- *
43828
- * - `category` — broadest. `target: 'device' | 'system'` selects every
43829
- * cap with the matching `scope` declaration. New caps inherit grants
43830
- * automatically — adding a device cap to the codebase makes it
43831
- * reachable to every user with `category:device [...]` without a
43832
- * re-grant. Use this for "family viewer" / "operator" tiers.
43833
- *
43834
- * - `addon` — every cap that ships inside a given addon id. Niche;
43835
- * useful when an integration needs to interact with one specific
43836
- * addon's surface regardless of how many caps it exports.
43837
- *
43838
- * - `capability` — the most precise form. Single cap name. Use for
43839
- * integration tokens where you want to grant `addons.installPackage`
43840
- * and nothing else.
43841
- *
43842
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
43843
- * "give me everything" escape; there is no wildcard scope.
43844
- */
43845
- var AllowedProviderSchema = union([literal("*"), array(string())]);
43846
- var AllowedDevicesSchema = record(string(), union([literal("*"), array(string())]));
43847
- var CapScopeSchema = _enum(["device", "system"]);
43848
- /**
43849
- * DeviceSelector (scope model v3 — 2026-08-12).
43850
- *
43851
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
43852
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
43853
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
43854
- * AFTER the grant was minted — no re-grant, no re-login.
43855
- *
43856
- * - `all` — every device in the deployment. The broad viewer/operator
43857
- * lever without a `category` grant (a `category` grant also covers device
43858
- * caps that carry no deviceId; `all` is specifically the device set).
43859
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
43860
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
43861
- * is NOT covered until the grant is edited.
43862
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
43863
- * DYNAMIC. A device that changes type, or a new device of the type,
43864
- * re-resolves on the next request.
43865
- * - `locations` — every device whose operator-assigned `location` label is
43866
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
43867
- * null/unset location matches NO `locations` selector.
43868
- */
43869
- var DeviceSelectorSchema = discriminatedUnion("kind", [
43870
- object({ kind: literal("all") }),
43871
- object({
43872
- kind: literal("ids"),
43873
- ids: array(number().int()).min(1)
43874
- }),
43875
- object({
43876
- kind: literal("types"),
43877
- types: array(_enum(DeviceType)).min(1)
43878
- }),
43879
- object({
43880
- kind: literal("locations"),
43881
- locations: array(string().min(1)).min(1)
43882
- })
43883
- ]);
43884
- var DeviceTokenScopeSchema = object({
43885
- type: literal("device"),
43886
- /** The device SET this grant covers — resolved against the live fleet. */
43887
- selector: DeviceSelectorSchema,
43888
- access: array(MethodAccessSchema).min(1),
43889
- /**
43890
- * Whether a grant on a PARENT device transparently covers its accessory
43891
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
43892
- * Direction is parent → children ONLY.
43893
- *
43894
- * Absent → the matcher DERIVES it from the access flavour: `view`
43895
- * inherits (a camera viewer sees the camera's accessories), `create` /
43896
- * `delete` do NOT (actuating/removing a child is an explicit act the
43897
- * operator must grant on the child, not inherit from the parent). Set it
43898
- * explicitly to override that default per grant.
43899
- */
43900
- includeLinked: boolean().optional()
43901
- });
43902
- /**
43903
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
43904
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
43905
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
43906
- * EVERY parse path — stored records AND the JWT-carried scope arrays
43907
- * normalised at the request boundary ({@link normalizeTokenScopes} in
43908
- * `device-selector.ts`). Chosen over a one-time DB migration because a
43909
- * migration cannot reach a JWT already in a client's hands; parse-time
43910
- * migration covers both without a flag day. No cast — the raw object is read
43911
- * through `Reflect.get` (its static type is `unknown`).
43912
- */
43913
- function migrateLegacyTokenScope(raw) {
43914
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
43915
- if (Reflect.get(raw, "type") !== "device") return raw;
43916
- if (Reflect.get(raw, "selector") !== void 0) return raw;
43917
- const targets = Reflect.get(raw, "targets");
43918
- if (!Array.isArray(targets)) return raw;
43919
- return {
43920
- type: "device",
43921
- selector: {
43922
- kind: "ids",
43923
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
43924
- },
43925
- access: Reflect.get(raw, "access")
43926
- };
43927
- }
43928
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
43929
- object({
43930
- type: literal("category"),
43931
- target: CapScopeSchema,
43932
- access: array(MethodAccessSchema).min(1)
43933
- }),
43934
- object({
43935
- type: literal("capability"),
43936
- target: string(),
43937
- access: array(MethodAccessSchema).min(1)
43938
- }),
43939
- object({
43940
- type: literal("addon"),
43941
- target: string(),
43942
- access: array(MethodAccessSchema).min(1)
43943
- }),
43944
- DeviceTokenScopeSchema
43945
- ]));
43946
- object({
43947
- id: string(),
43948
- username: string(),
43949
- passwordHash: string(),
43950
- /**
43951
- * Admin bypass. When true, the middleware skips the scope-access
43952
- * check entirely. There is no other axis of privilege; the legacy
43953
- * role enum collapsed onto this boolean in v2.
43954
- */
43955
- isAdmin: boolean().default(false),
43956
- allowedProviders: AllowedProviderSchema,
43957
- allowedDevices: AllowedDevicesSchema,
43958
- /**
43959
- * Scopes granted to this user. Admins bypass; their `scopes` is
43960
- * ignored. Non-admins without scopes are locked out of every
43961
- * protected call.
43962
- */
43963
- scopes: array(TokenScopeSchema).default([]),
43964
- createdAt: number(),
43965
- updatedAt: number()
43966
- });
43967
- object({
43968
- id: string(),
43969
- label: string(),
43970
- isAdmin: boolean().default(false),
43971
- allowedProviders: AllowedProviderSchema,
43972
- allowedDevices: AllowedDevicesSchema,
43973
- tokenHash: string(),
43974
- tokenPrefix: string(),
43975
- createdAt: number(),
43976
- lastUsedAt: number().optional()
43977
- });
43978
- object({
43979
- id: string(),
43980
- userId: string(),
43981
- name: string(),
43982
- tokenHash: string(),
43983
- tokenPrefix: string(),
43984
- scopes: array(TokenScopeSchema),
43985
- expiresAt: number().nullish(),
43986
- lastUsedAt: number().nullish(),
43987
- createdAt: number()
43988
- });
43989
- /**
43990
44023
  * `oauth-integration` — a collection cap by which an addon declares
43991
44024
  * itself a linkable OAuth client of the hub's core `/oauth2/*` server.
43992
44025
  * Each provider returns a static descriptor; the core enumerates them
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-google",
3
- "version": "0.1.95",
3
+ "version": "0.1.96",
4
4
  "description": "Google Home export — hub-side smart-home fulfillment (SYNC / QUERY / EXECUTE / DISCONNECT) for the non-camera fleet, served over the hub's own OAuth account link. No Google credential is stored, sent or required.",
5
5
  "keywords": [
6
6
  "camstack",