@aglyn/tenant-feature-instance 1.0.0-beta.143

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 (154) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/jest.config.d.ts +36 -0
  4. package/package.json +45 -0
  5. package/src/index.d.ts +17 -0
  6. package/src/index.js +18 -0
  7. package/src/index.js.map +1 -0
  8. package/src/lib/components/duplicate-resource-dialog.d.ts +77 -0
  9. package/src/lib/components/duplicate-resource-dialog.js +217 -0
  10. package/src/lib/components/duplicate-resource-dialog.js.map +1 -0
  11. package/src/lib/constants/firebase-config.d.ts +68 -0
  12. package/src/lib/constants/firebase-config.js +155 -0
  13. package/src/lib/constants/firebase-config.js.map +1 -0
  14. package/src/lib/constants/firebase-emulator-hosts.d.ts +60 -0
  15. package/src/lib/constants/firebase-emulator-hosts.js +81 -0
  16. package/src/lib/constants/firebase-emulator-hosts.js.map +1 -0
  17. package/src/lib/constants/mock-data.d.ts +24 -0
  18. package/src/lib/constants/mock-data.js +49 -0
  19. package/src/lib/constants/mock-data.js.map +1 -0
  20. package/src/lib/constants/site-paths.d.ts +47 -0
  21. package/src/lib/constants/site-paths.js +66 -0
  22. package/src/lib/constants/site-paths.js.map +1 -0
  23. package/src/lib/hooks/firebase/auth-persistence.d.ts +74 -0
  24. package/src/lib/hooks/firebase/auth-persistence.js +117 -0
  25. package/src/lib/hooks/firebase/auth-persistence.js.map +1 -0
  26. package/src/lib/hooks/firebase/firebase-services.d.ts +172 -0
  27. package/src/lib/hooks/firebase/firebase-services.js +522 -0
  28. package/src/lib/hooks/firebase/firebase-services.js.map +1 -0
  29. package/src/lib/hooks/firebase/firestore-cache.d.ts +125 -0
  30. package/src/lib/hooks/firebase/firestore-cache.js +152 -0
  31. package/src/lib/hooks/firebase/firestore-cache.js.map +1 -0
  32. package/src/lib/hooks/firebase/firestore-shared-client-state.d.ts +169 -0
  33. package/src/lib/hooks/firebase/firestore-shared-client-state.js +316 -0
  34. package/src/lib/hooks/firebase/firestore-shared-client-state.js.map +1 -0
  35. package/src/lib/hooks/firestore-denial-reporter.d.ts +192 -0
  36. package/src/lib/hooks/firestore-denial-reporter.js +293 -0
  37. package/src/lib/hooks/firestore-denial-reporter.js.map +1 -0
  38. package/src/lib/hooks/helpers/besigner-nodes-converter.d.ts +62 -0
  39. package/src/lib/hooks/helpers/besigner-nodes-converter.js +91 -0
  40. package/src/lib/hooks/helpers/besigner-nodes-converter.js.map +1 -0
  41. package/src/lib/hooks/helpers/guarded-nodes-save.d.ts +80 -0
  42. package/src/lib/hooks/helpers/guarded-nodes-save.js +89 -0
  43. package/src/lib/hooks/helpers/guarded-nodes-save.js.map +1 -0
  44. package/src/lib/hooks/helpers/guarded-seed-write.d.ts +125 -0
  45. package/src/lib/hooks/helpers/guarded-seed-write.js +193 -0
  46. package/src/lib/hooks/helpers/guarded-seed-write.js.map +1 -0
  47. package/src/lib/hooks/helpers/listen-options.d.ts +91 -0
  48. package/src/lib/hooks/helpers/listen-options.js +92 -0
  49. package/src/lib/hooks/helpers/listen-options.js.map +1 -0
  50. package/src/lib/hooks/helpers/use-doc.d.ts +38 -0
  51. package/src/lib/hooks/helpers/use-doc.js +213 -0
  52. package/src/lib/hooks/helpers/use-doc.js.map +1 -0
  53. package/src/lib/hooks/helpers/use-modify-doc-callback.d.ts +28 -0
  54. package/src/lib/hooks/helpers/use-modify-doc-callback.js +110 -0
  55. package/src/lib/hooks/helpers/use-modify-doc-callback.js.map +1 -0
  56. package/src/lib/hooks/host-collection-queries.d.ts +125 -0
  57. package/src/lib/hooks/host-collection-queries.js +126 -0
  58. package/src/lib/hooks/host-collection-queries.js.map +1 -0
  59. package/src/lib/hooks/list-filter-constraints.d.ts +64 -0
  60. package/src/lib/hooks/list-filter-constraints.js +288 -0
  61. package/src/lib/hooks/list-filter-constraints.js.map +1 -0
  62. package/src/lib/hooks/sorted-collection-window.d.ts +207 -0
  63. package/src/lib/hooks/sorted-collection-window.js +150 -0
  64. package/src/lib/hooks/sorted-collection-window.js.map +1 -0
  65. package/src/lib/hooks/use-component-version.d.ts +43 -0
  66. package/src/lib/hooks/use-component-version.js +73 -0
  67. package/src/lib/hooks/use-component-version.js.map +1 -0
  68. package/src/lib/hooks/use-component.d.ts +39 -0
  69. package/src/lib/hooks/use-component.js +55 -0
  70. package/src/lib/hooks/use-component.js.map +1 -0
  71. package/src/lib/hooks/use-console-host-route.d.ts +24 -0
  72. package/src/lib/hooks/use-console-host-route.js +77 -0
  73. package/src/lib/hooks/use-console-host-route.js.map +1 -0
  74. package/src/lib/hooks/use-duplicate-resource-api.d.ts +43 -0
  75. package/src/lib/hooks/use-duplicate-resource-api.js +61 -0
  76. package/src/lib/hooks/use-duplicate-resource-api.js.map +1 -0
  77. package/src/lib/hooks/use-firestore-collection.d.ts +62 -0
  78. package/src/lib/hooks/use-firestore-collection.js +307 -0
  79. package/src/lib/hooks/use-firestore-collection.js.map +1 -0
  80. package/src/lib/hooks/use-firestore-doc.d.ts +42 -0
  81. package/src/lib/hooks/use-firestore-doc.js +192 -0
  82. package/src/lib/hooks/use-firestore-doc.js.map +1 -0
  83. package/src/lib/hooks/use-form-version.d.ts +44 -0
  84. package/src/lib/hooks/use-form-version.js +73 -0
  85. package/src/lib/hooks/use-form-version.js.map +1 -0
  86. package/src/lib/hooks/use-host-activity-logger.d.ts +35 -0
  87. package/src/lib/hooks/use-host-activity-logger.js +96 -0
  88. package/src/lib/hooks/use-host-activity-logger.js.map +1 -0
  89. package/src/lib/hooks/use-host-campaigns.d.ts +53 -0
  90. package/src/lib/hooks/use-host-campaigns.js +93 -0
  91. package/src/lib/hooks/use-host-campaigns.js.map +1 -0
  92. package/src/lib/hooks/use-host-org-id.d.ts +96 -0
  93. package/src/lib/hooks/use-host-org-id.js +154 -0
  94. package/src/lib/hooks/use-host-org-id.js.map +1 -0
  95. package/src/lib/hooks/use-host-resource-api.d.ts +43 -0
  96. package/src/lib/hooks/use-host-resource-api.js +60 -0
  97. package/src/lib/hooks/use-host-resource-api.js.map +1 -0
  98. package/src/lib/hooks/use-host-template.d.ts +44 -0
  99. package/src/lib/hooks/use-host-template.js +82 -0
  100. package/src/lib/hooks/use-host-template.js.map +1 -0
  101. package/src/lib/hooks/use-host-version-api.d.ts +59 -0
  102. package/src/lib/hooks/use-host-version-api.js +69 -0
  103. package/src/lib/hooks/use-host-version-api.js.map +1 -0
  104. package/src/lib/hooks/use-host.d.ts +101 -0
  105. package/src/lib/hooks/use-host.js +45 -0
  106. package/src/lib/hooks/use-host.js.map +1 -0
  107. package/src/lib/hooks/use-layout-version.d.ts +33 -0
  108. package/src/lib/hooks/use-layout-version.js +64 -0
  109. package/src/lib/hooks/use-layout-version.js.map +1 -0
  110. package/src/lib/hooks/use-layout.d.ts +41 -0
  111. package/src/lib/hooks/use-layout.js +49 -0
  112. package/src/lib/hooks/use-layout.js.map +1 -0
  113. package/src/lib/hooks/use-live-artifact-count.d.ts +50 -0
  114. package/src/lib/hooks/use-live-artifact-count.js +102 -0
  115. package/src/lib/hooks/use-live-artifact-count.js.map +1 -0
  116. package/src/lib/hooks/use-org-member-options.d.ts +57 -0
  117. package/src/lib/hooks/use-org-member-options.js +112 -0
  118. package/src/lib/hooks/use-org-member-options.js.map +1 -0
  119. package/src/lib/hooks/use-org-plan.d.ts +46 -0
  120. package/src/lib/hooks/use-org-plan.js +86 -0
  121. package/src/lib/hooks/use-org-plan.js.map +1 -0
  122. package/src/lib/hooks/use-paged-collection.d.ts +95 -0
  123. package/src/lib/hooks/use-paged-collection.js +130 -0
  124. package/src/lib/hooks/use-paged-collection.js.map +1 -0
  125. package/src/lib/hooks/use-plugin-config.d.ts +38 -0
  126. package/src/lib/hooks/use-plugin-config.js +120 -0
  127. package/src/lib/hooks/use-plugin-config.js.map +1 -0
  128. package/src/lib/hooks/use-scope-tokens.d.ts +28 -0
  129. package/src/lib/hooks/use-scope-tokens.js +100 -0
  130. package/src/lib/hooks/use-scope-tokens.js.map +1 -0
  131. package/src/lib/hooks/use-screen-version.d.ts +33 -0
  132. package/src/lib/hooks/use-screen-version.js +65 -0
  133. package/src/lib/hooks/use-screen-version.js.map +1 -0
  134. package/src/lib/hooks/use-screen.d.ts +68 -0
  135. package/src/lib/hooks/use-screen.js +50 -0
  136. package/src/lib/hooks/use-screen.js.map +1 -0
  137. package/src/lib/hooks/use-sending-identity-api.d.ts +197 -0
  138. package/src/lib/hooks/use-sending-identity-api.js +95 -0
  139. package/src/lib/hooks/use-sending-identity-api.js.map +1 -0
  140. package/src/lib/hooks/use-sorted-paged-collection.d.ts +48 -0
  141. package/src/lib/hooks/use-sorted-paged-collection.js +213 -0
  142. package/src/lib/hooks/use-sorted-paged-collection.js.map +1 -0
  143. package/src/lib/hooks/use-switcher-collection.d.ts +105 -0
  144. package/src/lib/hooks/use-switcher-collection.js +275 -0
  145. package/src/lib/hooks/use-switcher-collection.js.map +1 -0
  146. package/src/lib/hooks/use-user-name.d.ts +51 -0
  147. package/src/lib/hooks/use-user-name.js +90 -0
  148. package/src/lib/hooks/use-user-name.js.map +1 -0
  149. package/src/lib/hooks/use-user-photo.d.ts +50 -0
  150. package/src/lib/hooks/use-user-photo.js +87 -0
  151. package/src/lib/hooks/use-user-photo.js.map +1 -0
  152. package/src/lib/tenant.d.ts +61 -0
  153. package/src/lib/tenant.js +62 -0
  154. package/src/lib/tenant.js.map +1 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Parents that carry besigner version history (AGL-1369).
19
+ *
20
+ * `form` is here because a form is designed, not merely declared: it opens in
21
+ * the besigner, saves a draft per version, and publishes a snapshot onto its
22
+ * parent document, which is the component lifecycle exactly.
23
+ */
24
+ export type HostVersionParentKind = 'screen' | 'layout' | 'component' | 'form';
25
+ /**
26
+ * Options for {@link useHostVersionApi}. Either `data` (a version written from
27
+ * scratch — the seed a new screen/layout/component needs to be editable) or
28
+ * `sourceVersionId` (snapshot an existing version; the route copies the stored
29
+ * document server-side, so the node map never crosses the wire).
30
+ */
31
+ export interface CreateHostVersionOptions {
32
+ hostId: string;
33
+ kind: HostVersionParentKind;
34
+ parentId: string;
35
+ /** Pre-generated id, when the caller must reference it immediately. */
36
+ id?: string;
37
+ data?: Record<string, unknown>;
38
+ sourceVersionId?: string;
39
+ }
40
+ /**
41
+ * Creates a besigner version document through the console API (AGL-1369).
42
+ *
43
+ * Firestore rules deny client-side `create` under
44
+ * `hosts/{h}/{screens|layouts|components}/{id}/versions`, so this is the only
45
+ * creation path. SAVING a version stays client-direct — a save is a merge-set
46
+ * onto the document already open, which is an update, and it must keep working
47
+ * on every plan.
48
+ *
49
+ * The route decides whether the create is free or paid by counting what is
50
+ * already there: the first version of a resource is allowed on any plan (a
51
+ * resource with no version cannot be opened), and retaining a second requires
52
+ * `versioning` (Pro+). Callers do not declare which case they are in.
53
+ *
54
+ * Throws with the server's message on denial, for the caller's snackbar.
55
+ */
56
+ export declare function useHostVersionApi(): (options: CreateHostVersionOptions) => Promise<{
57
+ id: string;
58
+ }>;
59
+ export default useHostVersionApi;
@@ -0,0 +1,69 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Aglyn LLC
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */ import { useCallback } from "react";
18
+ import { useUser } from "./firebase/firebase-services.js";
19
+ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
20
+ /**
21
+ * Creates a besigner version document through the console API (AGL-1369).
22
+ *
23
+ * Firestore rules deny client-side `create` under
24
+ * `hosts/{h}/{screens|layouts|components}/{id}/versions`, so this is the only
25
+ * creation path. SAVING a version stays client-direct — a save is a merge-set
26
+ * onto the document already open, which is an update, and it must keep working
27
+ * on every plan.
28
+ *
29
+ * The route decides whether the create is free or paid by counting what is
30
+ * already there: the first version of a resource is allowed on any plan (a
31
+ * resource with no version cannot be opened), and retaining a second requires
32
+ * `versioning` (Pro+). Callers do not declare which case they are in.
33
+ *
34
+ * Throws with the server's message on denial, for the caller's snackbar.
35
+ */ export function useHostVersionApi() {
36
+ const { data: user } = useUser();
37
+ return useCallback(async ({ hostId, kind, parentId, id, data, sourceVersionId })=>{
38
+ const response = await authorizedFetch(user, '/api/hosts/versions', {
39
+ method: 'POST',
40
+ headers: {
41
+ 'Content-Type': 'application/json'
42
+ },
43
+ body: JSON.stringify(_extends({
44
+ hostId,
45
+ kind,
46
+ parentId
47
+ }, id ? {
48
+ id
49
+ } : {}, data ? {
50
+ data
51
+ } : {}, sourceVersionId ? {
52
+ sourceVersionId
53
+ } : {}))
54
+ });
55
+ const result = await response.json().catch(()=>({}));
56
+ if (!response.ok) {
57
+ var _ref;
58
+ throw new Error((_ref = result == null ? void 0 : result.error) != null ? _ref : 'Create failed');
59
+ }
60
+ return {
61
+ id: String(result.id)
62
+ };
63
+ }, [
64
+ user
65
+ ]);
66
+ }
67
+ export default useHostVersionApi;
68
+
69
+ //# sourceMappingURL=use-host-version-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-host-version-api.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback } from 'react'\nimport { useUser } from './firebase/firebase-services'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\n\n/**\n * Parents that carry besigner version history (AGL-1369).\n *\n * `form` is here because a form is designed, not merely declared: it opens in\n * the besigner, saves a draft per version, and publishes a snapshot onto its\n * parent document, which is the component lifecycle exactly.\n */\nexport type HostVersionParentKind =\n | 'screen'\n | 'layout'\n | 'component'\n | 'form'\n\n/**\n * Options for {@link useHostVersionApi}. Either `data` (a version written from\n * scratch — the seed a new screen/layout/component needs to be editable) or\n * `sourceVersionId` (snapshot an existing version; the route copies the stored\n * document server-side, so the node map never crosses the wire).\n */\nexport interface CreateHostVersionOptions {\n hostId: string\n kind: HostVersionParentKind\n parentId: string\n /** Pre-generated id, when the caller must reference it immediately. */\n id?: string\n data?: Record<string, unknown>\n sourceVersionId?: string\n}\n\n/**\n * Creates a besigner version document through the console API (AGL-1369).\n *\n * Firestore rules deny client-side `create` under\n * `hosts/{h}/{screens|layouts|components}/{id}/versions`, so this is the only\n * creation path. SAVING a version stays client-direct — a save is a merge-set\n * onto the document already open, which is an update, and it must keep working\n * on every plan.\n *\n * The route decides whether the create is free or paid by counting what is\n * already there: the first version of a resource is allowed on any plan (a\n * resource with no version cannot be opened), and retaining a second requires\n * `versioning` (Pro+). Callers do not declare which case they are in.\n *\n * Throws with the server's message on denial, for the caller's snackbar.\n */\nexport function useHostVersionApi(): (\n options: CreateHostVersionOptions,\n) => Promise<{ id: string }> {\n const { data: user } = useUser()\n return useCallback(\n async ({ hostId, kind, parentId, id, data, sourceVersionId }) => {\n const response = await authorizedFetch(user, '/api/hosts/versions', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n kind,\n parentId,\n ...(id ? { id } : {}),\n ...(data ? { data } : {}),\n ...(sourceVersionId ? { sourceVersionId } : {}),\n }),\n })\n const result = await response.json().catch(() => ({}))\n if (!response.ok) {\n throw new Error(result?.error ?? 'Create failed')\n }\n return { id: String(result.id) }\n },\n [user],\n )\n}\n\nexport default useHostVersionApi\n"],"names":["useCallback","useUser","authorizedFetch","useHostVersionApi","data","user","hostId","kind","parentId","id","sourceVersionId","response","method","headers","body","JSON","stringify","result","json","catch","ok","Error","error","String"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,QAAO;AACnC,SAASC,OAAO,QAAQ,kCAA8B;AACtD,SAASC,eAAe,QAAQ,2CAA0C;AA+B1E;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC;IAGd,MAAM,EAAEC,MAAMC,IAAI,EAAE,GAAGJ;IACvB,OAAOD,YACL,OAAO,EAAEM,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,EAAE,EAAEL,IAAI,EAAEM,eAAe,EAAE;QAC1D,MAAMC,WAAW,MAAMT,gBAAgBG,MAAM,uBAAuB;YAClEO,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBACnBV;gBACAC;gBACAC;eACIC,KAAK;gBAAEA;YAAG,IAAI,CAAC,GACfL,OAAO;gBAAEA;YAAK,IAAI,CAAC,GACnBM,kBAAkB;gBAAEA;YAAgB,IAAI,CAAC;QAEjD;QACA,MAAMO,SAAS,MAAMN,SAASO,IAAI,GAAGC,KAAK,CAAC,IAAO,CAAA,CAAC,CAAA;QACnD,IAAI,CAACR,SAASS,EAAE,EAAE;;YAChB,MAAM,IAAIC,cAAMJ,0BAAAA,OAAQK,KAAK,mBAAI;QACnC;QACA,OAAO;YAAEb,IAAIc,OAAON,OAAOR,EAAE;QAAE;IACjC,GACA;QAACJ;KAAK;AAEV;AAEA,eAAeF,kBAAiB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type * as Aglyn from '@aglyn/aglyn';
18
+ import { type FirestoreDocOptions } from './firebase/firebase-services';
19
+ export declare const useHostRef: ({ hostId }: {
20
+ hostId: Aglyn.HostUid;
21
+ }) => import("@firebase/firestore").DocumentReference<Aglyn.AglynHost, {
22
+ [field: string]: any;
23
+ orgId?: Aglyn.OrgUid;
24
+ memberRoles?: Record<Aglyn.UserUid, string>;
25
+ subdomain?: string;
26
+ cname?: string;
27
+ announcementBar?: Aglyn.HostAnnouncementBar;
28
+ popup?: Aglyn.HostPopup;
29
+ displayName?: string;
30
+ logoUrl?: string;
31
+ seo?: {
32
+ title?: string;
33
+ description?: string;
34
+ separator?: string;
35
+ favicon?: string;
36
+ appIcon?: string;
37
+ image?: string;
38
+ imageWidth?: number;
39
+ imageHeight?: number;
40
+ imageAlt?: string;
41
+ discourageSearchEngines?: boolean;
42
+ entity?: {
43
+ type?: Aglyn.HostEntityType;
44
+ name?: string;
45
+ logo?: string;
46
+ description?: string;
47
+ url?: string;
48
+ sameAs?: string[];
49
+ email?: string;
50
+ telephone?: string;
51
+ contactType?: string;
52
+ address?: {
53
+ streetAddress?: string;
54
+ addressLocality?: string;
55
+ addressRegion?: string;
56
+ postalCode?: string;
57
+ addressCountry?: string;
58
+ };
59
+ };
60
+ agent?: {
61
+ whenToUse?: string;
62
+ howToUse?: string;
63
+ };
64
+ };
65
+ analytics?: {
66
+ gaMeasurementId?: string;
67
+ gtmContainerId?: string;
68
+ adTags?: Record<string, string> | null;
69
+ };
70
+ consent?: {
71
+ disabled?: boolean;
72
+ mode?: "geo" | "strict";
73
+ advertising?: boolean;
74
+ };
75
+ screens?: Record<Aglyn.ScreenUid, Aglyn.ScreenSlug>;
76
+ notFoundScreenId?: Aglyn.ScreenUid;
77
+ errorScreens?: Aglyn.HostErrorScreens;
78
+ authScreens?: import("@aglyn/aglyn/src/lib/foundation/definitions/platform.types").HostAuthScreens;
79
+ maintenance?: boolean;
80
+ suspendedAt?: number;
81
+ suspendedReasonCode?: string;
82
+ suspendedMessage?: string;
83
+ suspendedUntilMs?: number;
84
+ disabledPlugins?: string[];
85
+ enabledPlugins?: string[];
86
+ approvedImageHosts?: string[];
87
+ locales?: string[];
88
+ defaultLocale?: string;
89
+ layouts?: Record<Aglyn.LayoutUid, string>;
90
+ theme?: Aglyn.AglynHostTheme;
91
+ redirects?: Record<Aglyn.RedirectUid, true>;
92
+ projectId?: Aglyn.ProjectUid;
93
+ projectNumber?: Aglyn.ProjectNumber;
94
+ }>;
95
+ export declare const useHost: (data: {
96
+ hostId: Aglyn.HostUid;
97
+ }, options?: FirestoreDocOptions<Aglyn.AglynHost>) => {
98
+ doc: import("./firebase/firebase-services").ObservableStatus<Aglyn.AglynHost>;
99
+ setDoc: import("./helpers/use-modify-doc-callback").ModifyDocCallback<Aglyn.AglynHost>;
100
+ };
101
+ export default useHost;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ // A TYPE-only namespace: every `Aglyn.` reference below is a type, and held
17
+ // as a VALUE the namespace pins every module the barrel reaches into the
18
+ // console shell that renders these hooks. `import type` erases instead.
19
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
20
+ import { doc } from "firebase/firestore";
21
+ import { useFirestore } from "./firebase/firebase-services.js";
22
+ import useDoc from "./helpers/use-doc.js";
23
+ export const useHostRef = ({ hostId })=>{
24
+ const firestore = useFirestore();
25
+ const ref = doc(firestore, 'hosts', hostId);
26
+ return ref.withConverter({
27
+ toFirestore (data) {
28
+ const { $id } = data, rest = _object_without_properties_loose(data, [
29
+ "$id"
30
+ ]);
31
+ return rest;
32
+ },
33
+ fromFirestore (snapshot, options) {
34
+ if (!snapshot.exists()) return undefined;
35
+ const data = snapshot.data(options);
36
+ return data;
37
+ }
38
+ });
39
+ };
40
+ export const useHost = (data, options)=>{
41
+ return useDoc(useHostRef(data), options);
42
+ };
43
+ export default useHost;
44
+
45
+ //# sourceMappingURL=use-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-host.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// A TYPE-only namespace: every `Aglyn.` reference below is a type, and held\n// as a VALUE the namespace pins every module the barrel reaches into the\n// console shell that renders these hooks. `import type` erases instead.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport {\n doc,\n type DocumentSnapshot,\n type SnapshotOptions,\n} from 'firebase/firestore'\nimport { useFirestore, type FirestoreDocOptions } from './firebase/firebase-services'\nimport useDoc from './helpers/use-doc'\n\nexport const useHostRef = ({ hostId }: { hostId: Aglyn.HostUid }) => {\n const firestore = useFirestore()\n const ref = doc(firestore, 'hosts', hostId)\n return ref.withConverter({\n toFirestore(data: Aglyn.AglynHost) {\n const { $id, ...rest } = data\n return rest\n },\n fromFirestore(\n snapshot: DocumentSnapshot<Aglyn.AglynHost>,\n options: SnapshotOptions,\n ) {\n if (!snapshot.exists()) return undefined\n const data = snapshot.data(options)\n return data as Aglyn.AglynHost\n },\n })\n}\n\nexport const useHost = (\n data: { hostId: Aglyn.HostUid },\n options?: FirestoreDocOptions<Aglyn.AglynHost>,\n) => {\n return useDoc(useHostRef(data), options)\n}\n\nexport default useHost\n"],"names":["doc","useFirestore","useDoc","useHostRef","hostId","firestore","ref","withConverter","toFirestore","data","$id","rest","fromFirestore","snapshot","options","exists","undefined","useHost"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;;AAExE,SACEA,GAAG,QAGE,qBAAoB;AAC3B,SAASC,YAAY,QAAkC,kCAA8B;AACrF,OAAOC,YAAY,uBAAmB;AAEtC,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAA6B;IAC9D,MAAMC,YAAYJ;IAClB,MAAMK,MAAMN,IAAIK,WAAW,SAASD;IACpC,OAAOE,IAAIC,aAAa,CAAC;QACvBC,aAAYC,IAAqB;YAC/B,MAAM,EAAEC,GAAG,EAAW,GAAGD,MAATE,wCAASF;;;YACzB,OAAOE;QACT;QACAC,eACEC,QAA2C,EAC3CC,OAAwB;YAExB,IAAI,CAACD,SAASE,MAAM,IAAI,OAAOC;YAC/B,MAAMP,OAAOI,SAASJ,IAAI,CAACK;YAC3B,OAAOL;QACT;IACF;AACF,EAAC;AAED,OAAO,MAAMQ,UAAU,CACrBR,MACAK;IAEA,OAAOZ,OAAOC,WAAWM,OAAOK;AAClC,EAAC;AAED,eAAeG,QAAO"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type * as Aglyn from '@aglyn/aglyn';
18
+ import type { DocumentReference } from 'firebase/firestore';
19
+ import { type FirestoreDocOptions } from './firebase/firebase-services';
20
+ export declare const useLayoutVersionRef: ({ hostId, layoutId, versionId, }: {
21
+ hostId: string;
22
+ layoutId: string;
23
+ versionId: string;
24
+ }) => DocumentReference<Aglyn.AglynLayoutVersion>;
25
+ export declare const useLayoutVersion: (data: {
26
+ hostId: string;
27
+ layoutId: string;
28
+ versionId: string;
29
+ }, options?: FirestoreDocOptions<Aglyn.AglynLayoutVersion>) => {
30
+ doc: import("./firebase/firebase-services").ObservableStatus<Aglyn.AglynLayoutVersion>;
31
+ setDoc: import("./helpers/use-modify-doc-callback").ModifyDocCallback<Aglyn.AglynLayoutVersion>;
32
+ };
33
+ export default useLayoutVersion;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ // A TYPE-only namespace: every `Aglyn.` reference below is a type, and held
17
+ // as a VALUE the namespace pins every module the barrel reaches into the
18
+ // console shell that renders these hooks. `import type` erases instead.
19
+ import { _ as _extends } from "@swc/helpers/_/_extends";
20
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
21
+ import { compress, decompress } from "@aglyn/aglyn";
22
+ import { Timestamp } from "@aglyn/shared-util-timestamp";
23
+ import { Bytes, doc } from "firebase/firestore";
24
+ import { useFirestore } from "./firebase/firebase-services.js";
25
+ import useDoc from "./helpers/use-doc.js";
26
+ export const useLayoutVersionRef = ({ hostId, layoutId, versionId })=>{
27
+ const firestore = useFirestore();
28
+ const ref = doc(firestore, 'hosts', hostId, 'layouts', layoutId, 'versions', versionId);
29
+ // Same converter behavior as screen versions: nodes are compressed at rest.
30
+ return ref.withConverter({
31
+ toFirestore (data) {
32
+ const { $id } = data, rest = _object_without_properties_loose(data, [
33
+ "$id"
34
+ ]);
35
+ // Only emit `nodes` when the write carries them — see the note in
36
+ // use-screen-version (AGL-1250). A partial merge write otherwise
37
+ // ships an empty compressed map and wipes the document's tree.
38
+ if ((rest == null ? void 0 : rest.nodes) === undefined) return _extends({}, rest, {
39
+ updatedAt: Timestamp.now()
40
+ });
41
+ const nodes = rest.nodes instanceof Bytes ? rest.nodes : Bytes.fromUint8Array(compress(rest.nodes));
42
+ return _extends({}, rest, {
43
+ nodes,
44
+ updatedAt: Timestamp.now()
45
+ });
46
+ },
47
+ fromFirestore (snapshot, options) {
48
+ if (!snapshot.exists()) return undefined;
49
+ const data = snapshot.data(options);
50
+ if ((data == null ? void 0 : data.nodes) instanceof Bytes) {
51
+ return _extends({}, data, {
52
+ nodes: decompress(data.nodes)
53
+ });
54
+ }
55
+ return data;
56
+ }
57
+ });
58
+ };
59
+ export const useLayoutVersion = (data, options)=>{
60
+ return useDoc(useLayoutVersionRef(data), options);
61
+ };
62
+ export default useLayoutVersion;
63
+
64
+ //# sourceMappingURL=use-layout-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-layout-version.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// A TYPE-only namespace: every `Aglyn.` reference below is a type, and held\n// as a VALUE the namespace pins every module the barrel reaches into the\n// console shell that renders these hooks. `import type` erases instead.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { compress, decompress } from '@aglyn/aglyn'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport type { DocumentReference } from 'firebase/firestore'\nimport { Bytes, doc } from 'firebase/firestore'\nimport { useFirestore, type FirestoreDocOptions } from './firebase/firebase-services'\nimport useDoc from './helpers/use-doc'\n\nexport const useLayoutVersionRef = ({\n hostId,\n layoutId,\n versionId,\n}: {\n hostId: string\n layoutId: string\n versionId: string\n}) => {\n const firestore = useFirestore()\n const ref = doc(\n firestore,\n 'hosts',\n hostId,\n 'layouts',\n layoutId,\n 'versions',\n versionId,\n )\n // Same converter behavior as screen versions: nodes are compressed at rest.\n return ref.withConverter({\n toFirestore(data) {\n const { $id, ...rest } = data\n // Only emit `nodes` when the write carries them — see the note in\n // use-screen-version (AGL-1250). A partial merge write otherwise\n // ships an empty compressed map and wipes the document's tree.\n if (rest?.nodes === undefined) return { ...rest, updatedAt: Timestamp.now() }\n const nodes = rest.nodes instanceof Bytes\n ? rest.nodes\n : Bytes.fromUint8Array(compress(rest.nodes))\n return { ...rest, nodes, updatedAt: Timestamp.now() }\n },\n fromFirestore(snapshot, options) {\n if (!snapshot.exists()) return undefined\n const data = snapshot.data(options)\n if (data?.nodes instanceof Bytes) {\n return {\n ...data,\n nodes: decompress(data.nodes),\n } as Aglyn.AglynLayoutVersion\n }\n return data as Aglyn.AglynLayoutVersion\n },\n }) as DocumentReference<Aglyn.AglynLayoutVersion>\n}\n\nexport const useLayoutVersion = (\n data: {\n hostId: string\n layoutId: string\n versionId: string\n },\n options?: FirestoreDocOptions<Aglyn.AglynLayoutVersion>,\n) => {\n return useDoc(useLayoutVersionRef(data), options)\n}\n\nexport default useLayoutVersion\n"],"names":["compress","decompress","Timestamp","Bytes","doc","useFirestore","useDoc","useLayoutVersionRef","hostId","layoutId","versionId","firestore","ref","withConverter","toFirestore","data","$id","rest","nodes","undefined","updatedAt","now","fromUint8Array","fromFirestore","snapshot","options","exists","useLayoutVersion"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;;;AAExE,SAASA,QAAQ,EAAEC,UAAU,QAAQ,eAAc;AACnD,SAASC,SAAS,QAAQ,+BAA8B;AAExD,SAASC,KAAK,EAAEC,GAAG,QAAQ,qBAAoB;AAC/C,SAASC,YAAY,QAAkC,kCAA8B;AACrF,OAAOC,YAAY,uBAAmB;AAEtC,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,MAAM,EACNC,QAAQ,EACRC,SAAS,EAKV;IACC,MAAMC,YAAYN;IAClB,MAAMO,MAAMR,IACVO,WACA,SACAH,QACA,WACAC,UACA,YACAC;IAEF,4EAA4E;IAC5E,OAAOE,IAAIC,aAAa,CAAC;QACvBC,aAAYC,IAAI;YACd,MAAM,EAAEC,GAAG,EAAW,GAAGD,MAATE,wCAASF;;;YACzB,kEAAkE;YAClE,iEAAiE;YACjE,+DAA+D;YAC/D,IAAIE,CAAAA,wBAAAA,KAAMC,KAAK,MAAKC,WAAW,OAAO,aAAKF;gBAAMG,WAAWlB,UAAUmB,GAAG;;YACzE,MAAMH,QAAQD,KAAKC,KAAK,YAAYf,QAChCc,KAAKC,KAAK,GACVf,MAAMmB,cAAc,CAACtB,SAASiB,KAAKC,KAAK;YAC5C,OAAO,aAAKD;gBAAMC;gBAAOE,WAAWlB,UAAUmB,GAAG;;QACnD;QACAE,eAAcC,QAAQ,EAAEC,OAAO;YAC7B,IAAI,CAACD,SAASE,MAAM,IAAI,OAAOP;YAC/B,MAAMJ,OAAOS,SAAST,IAAI,CAACU;YAC3B,IAAIV,CAAAA,wBAAAA,KAAMG,KAAK,aAAYf,OAAO;gBAChC,OAAO,aACFY;oBACHG,OAAOjB,WAAWc,KAAKG,KAAK;;YAEhC;YACA,OAAOH;QACT;IACF;AACF,EAAC;AAED,OAAO,MAAMY,mBAAmB,CAC9BZ,MAKAU;IAEA,OAAOnB,OAAOC,oBAAoBQ,OAAOU;AAC3C,EAAC;AAED,eAAeE,iBAAgB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type * as Aglyn from '@aglyn/aglyn';
18
+ import { Timestamp } from '@aglyn/shared-util-timestamp';
19
+ import { type FirestoreDocOptions } from './firebase/firebase-services';
20
+ export declare const useLayoutRef: ({ hostId, layoutId, }: {
21
+ hostId: Aglyn.HostUid;
22
+ layoutId: Aglyn.LayoutUid;
23
+ }) => import("@firebase/firestore").DocumentReference<Aglyn.AglynLayout, {
24
+ updatedAt: Timestamp;
25
+ hostId?: Aglyn.HostUid;
26
+ versionId?: Aglyn.VersionUid;
27
+ publishSchedule?: Aglyn.PublishSchedule;
28
+ versions?: Array<Aglyn.VersionUid>;
29
+ displayName?: string;
30
+ description?: string;
31
+ layoutId?: Aglyn.LayoutUid;
32
+ createdAt?: import("@aglyn/shared-util-timestamp").ITimestamp;
33
+ }>;
34
+ export declare const useLayout: (data: {
35
+ hostId: Aglyn.HostUid;
36
+ layoutId: Aglyn.LayoutUid;
37
+ }, options?: FirestoreDocOptions<Aglyn.AglynLayout>) => {
38
+ doc: import("./firebase/firebase-services").ObservableStatus<Aglyn.AglynLayout>;
39
+ setDoc: import("./helpers/use-modify-doc-callback").ModifyDocCallback<Aglyn.AglynLayout>;
40
+ };
41
+ export default useLayout;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ // A TYPE-only namespace: every `Aglyn.` reference below is a type, and held
17
+ // as a VALUE the namespace pins every module the barrel reaches into the
18
+ // console shell that renders these hooks. `import type` erases instead.
19
+ import { _ as _extends } from "@swc/helpers/_/_extends";
20
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
21
+ import { Timestamp } from "@aglyn/shared-util-timestamp";
22
+ import { doc } from "firebase/firestore";
23
+ import { useFirestore } from "./firebase/firebase-services.js";
24
+ import useDoc from "./helpers/use-doc.js";
25
+ export const useLayoutRef = ({ hostId, layoutId })=>{
26
+ const firestore = useFirestore();
27
+ const ref = doc(firestore, 'hosts', hostId, 'layouts', layoutId);
28
+ return ref.withConverter({
29
+ toFirestore (data) {
30
+ const { $id } = data, rest = _object_without_properties_loose(data, [
31
+ "$id"
32
+ ]);
33
+ return _extends({}, rest, {
34
+ updatedAt: Timestamp.now()
35
+ });
36
+ },
37
+ fromFirestore (snapshot, options) {
38
+ if (!snapshot.exists()) return undefined;
39
+ const data = snapshot.data(options);
40
+ return data;
41
+ }
42
+ });
43
+ };
44
+ export const useLayout = (data, options)=>{
45
+ return useDoc(useLayoutRef(data), options);
46
+ };
47
+ export default useLayout;
48
+
49
+ //# sourceMappingURL=use-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-layout.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// A TYPE-only namespace: every `Aglyn.` reference below is a type, and held\n// as a VALUE the namespace pins every module the barrel reaches into the\n// console shell that renders these hooks. `import type` erases instead.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { Timestamp } from '@aglyn/shared-util-timestamp'\nimport {\n doc,\n type DocumentSnapshot,\n type SnapshotOptions,\n} from 'firebase/firestore'\nimport { useFirestore, type FirestoreDocOptions } from './firebase/firebase-services'\nimport useDoc from './helpers/use-doc'\n\nexport const useLayoutRef = ({\n hostId,\n layoutId,\n}: {\n hostId: Aglyn.HostUid\n layoutId: Aglyn.LayoutUid\n}) => {\n const firestore = useFirestore()\n const ref = doc(firestore, 'hosts', hostId, 'layouts', layoutId)\n return ref.withConverter({\n toFirestore(data: Aglyn.AglynLayout) {\n const { $id, ...rest } = data\n return { ...rest, updatedAt: Timestamp.now() }\n },\n fromFirestore(\n snapshot: DocumentSnapshot<Aglyn.AglynLayout>,\n options: SnapshotOptions,\n ) {\n if (!snapshot.exists()) return undefined\n const data = snapshot.data(options)\n return data as Aglyn.AglynLayout\n },\n })\n}\n\nexport const useLayout = (\n data: {\n hostId: Aglyn.HostUid\n layoutId: Aglyn.LayoutUid\n },\n options?: FirestoreDocOptions<Aglyn.AglynLayout>,\n) => {\n return useDoc(useLayoutRef(data), options)\n}\n\nexport default useLayout\n"],"names":["Timestamp","doc","useFirestore","useDoc","useLayoutRef","hostId","layoutId","firestore","ref","withConverter","toFirestore","data","$id","rest","updatedAt","now","fromFirestore","snapshot","options","exists","undefined","useLayout"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;;;AAExE,SAASA,SAAS,QAAQ,+BAA8B;AACxD,SACEC,GAAG,QAGE,qBAAoB;AAC3B,SAASC,YAAY,QAAkC,kCAA8B;AACrF,OAAOC,YAAY,uBAAmB;AAEtC,OAAO,MAAMC,eAAe,CAAC,EAC3BC,MAAM,EACNC,QAAQ,EAIT;IACC,MAAMC,YAAYL;IAClB,MAAMM,MAAMP,IAAIM,WAAW,SAASF,QAAQ,WAAWC;IACvD,OAAOE,IAAIC,aAAa,CAAC;QACvBC,aAAYC,IAAuB;YACjC,MAAM,EAAEC,GAAG,EAAW,GAAGD,MAATE,wCAASF;;;YACzB,OAAO,aAAKE;gBAAMC,WAAWd,UAAUe,GAAG;;QAC5C;QACAC,eACEC,QAA6C,EAC7CC,OAAwB;YAExB,IAAI,CAACD,SAASE,MAAM,IAAI,OAAOC;YAC/B,MAAMT,OAAOM,SAASN,IAAI,CAACO;YAC3B,OAAOP;QACT;IACF;AACF,EAAC;AAED,OAAO,MAAMU,YAAY,CACvBV,MAIAO;IAEA,OAAOf,OAAOC,aAAaO,OAAOO;AACpC,EAAC;AAED,eAAeG,UAAS"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The per-site artifact collections that render as a console list.
3
+ *
4
+ * `forms` is one of them: it is created through the same resources route,
5
+ * keyed by the same generated uid, and listed by the same table. Its cap is
6
+ * enforced over the WHOLE collection rather than over live documents — a form
7
+ * is deleted outright, and its submissions keep their `formId` either way —
8
+ * so the aggregate below matches what `/api/hosts/resources` counts, with the
9
+ * tombstone subtraction a no-op because nothing writes `deletedAt` on a form.
10
+ */
11
+ export type HostArtifactCollection = 'screens' | 'layouts' | 'components' | 'templates' | 'forms';
12
+ /**
13
+ * How many artifacts of a kind a site actually holds — a server aggregate,
14
+ * not the length of a page (AGL-1716, the AGL-1706 shape).
15
+ *
16
+ * A list that pages holds ten rows. Handing that ten to a quota readout is a
17
+ * confident wrong number in the flattering direction: "10/10 layouts on your
18
+ * plan" on a site with sixty of them reads as room to spare, right up until
19
+ * `/api/hosts/resources` refuses the create. The list and the count are
20
+ * different questions and are asked separately — one aggregate per mount,
21
+ * re-asked when `epoch` moves.
22
+ *
23
+ * ## Why two aggregates rather than one
24
+ *
25
+ * Deleting an artifact stamps `deletedAt` and leaves the document in place,
26
+ * so a published tenant page keeps grafting until its next revalidate. The
27
+ * enforcing route counts the LIVE ones — `/api/hosts/resources` reads the
28
+ * collection with a `deletedAt` projection and keeps the entries where it is
29
+ * `== null` — so a console count over the whole collection would quote a cap
30
+ * usage the server does not enforce, and would disagree with the list beside
31
+ * it row for row.
32
+ *
33
+ * Firestore cannot express "field is absent" as a predicate, and the two live
34
+ * shapes are not one value: an artifact created through the resources route
35
+ * carries no `deletedAt` at all, while one installed from the marketplace
36
+ * carries an explicit `deletedAt: null` (`install.ts` writes it). So
37
+ * `where('deletedAt', '==', null)` would return the marketplace copies alone.
38
+ * Counting the TOMBSTONES instead is exact, because there is only one shape
39
+ * of tombstone — a `Timestamp` — and subtracting them from the total leaves
40
+ * precisely the documents the server calls live.
41
+ *
42
+ * Both aggregates bill one document read each at these collection sizes.
43
+ *
44
+ * @returns the live count, or `null` while it is pending or if it was
45
+ * refused. A caller must fall back to something that can only UNDERSTATE the
46
+ * truth, never to `0`: an entitlement check answers from whatever it is
47
+ * handed, and zero used is the one wrong answer that opens a gate.
48
+ */
49
+ export declare function useLiveArtifactCount(hostId: string, artifact: HostArtifactCollection, epoch?: number): number | null;
50
+ export default useLiveArtifactCount;