@aglyn/tenant-feature-instance 1.0.0-beta.227 → 1.0.0-beta.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/tenant-feature-instance",
3
- "version": "1.0.0-beta.227",
3
+ "version": "1.0.0-beta.228",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,12 +25,12 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.227",
29
- "@aglyn/shared-data-enums": "1.0.0-beta.227",
30
- "@aglyn/shared-ui-jsx": "1.0.0-beta.227",
31
- "@aglyn/shared-util-email": "1.0.0-beta.227",
32
- "@aglyn/shared-util-http": "1.0.0-beta.227",
33
- "@aglyn/shared-util-timestamp": "1.0.0-beta.227",
28
+ "@aglyn/aglyn": "1.0.0-beta.228",
29
+ "@aglyn/shared-data-enums": "1.0.0-beta.228",
30
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.228",
31
+ "@aglyn/shared-util-email": "1.0.0-beta.228",
32
+ "@aglyn/shared-util-http": "1.0.0-beta.228",
33
+ "@aglyn/shared-util-timestamp": "1.0.0-beta.228",
34
34
  "@swc/helpers": "0.5.23",
35
35
  "lodash-es": "^4.18.1"
36
36
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-host-resource-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 * Quota-governed host resource kinds served by `POST /api/hosts/resources`\n * (AGL-473). Firestore rules deny client-side `create` on these\n * collections, so creation MUST go through the API — it enforces the\n * per-plan quota (and entitlement, where the feature is paid) with the\n * Admin SDK. Updates and deletes stay client-direct.\n */\nexport type HostResourceKind =\n | 'screen'\n | 'layout'\n | 'variable'\n | 'function'\n | 'workflow'\n | 'service'\n | 'redirect'\n | 'location'\n | 'product'\n | 'reusableComponent'\n // A form, which rides the `reusableComponents` entitlement and the\n // `formsPerHost` ceiling. The route entry existed before any typed caller\n // did, so creating one from the console was unreachable through this hook.\n | 'form'\n | 'register'\n | 'template'\n | 'webhook'\n // AGL-2266: two client-direct classes with no cap on any plan. `action`\n // is a flat host subcollection; `entry` is the one nested resource here\n // and needs `parentId` (the content collection it belongs to).\n | 'action'\n | 'entry'\n // AGL-2486: custom content authors, a flat host subcollection with a flat\n // platform cap — the `action` shape (create denied, update/delete open).\n | 'author'\n\n/**\n * Creates a quota-governed host resource through the console API\n * (AGL-473). `data` must be JSON-plain — no Firestore Timestamps; the\n * route stamps `createdAt`/`updatedAt` server-side when absent. Pass `id`\n * when the caller pre-generates the id (e.g. to write a first `versions`\n * doc under it). Pass `parentId` for a nested resource — `entry`, which\n * hangs off `hosts/{hostId}/collections/{parentId}` (AGL-2266). Throws with\n * the server's message on denial (quota, entitlement, role), for the\n * caller's snackbar.\n */\nexport function useHostResourceApi(): (options: {\n hostId: string\n resource: HostResourceKind\n data: Record<string, unknown>\n id?: string\n parentId?: string\n}) => Promise<{ id: string }> {\n const { data: user } = useUser()\n return useCallback(\n async ({ hostId, resource, data, id, parentId }) => {\n const response = await authorizedFetch(user, '/api/hosts/resources', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n resource,\n data,\n ...(id ? { id } : {}),\n ...(parentId ? { parentId } : {}),\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"],"names":["useCallback","useUser","authorizedFetch","useHostResourceApi","data","user","hostId","resource","id","parentId","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;AAoC1E;;;;;;;;;CASC,GACD,OAAO,SAASC;IAOd,MAAM,EAAEC,MAAMC,IAAI,EAAE,GAAGJ;IACvB,OAAOD,YACL,OAAO,EAAEM,MAAM,EAAEC,QAAQ,EAAEH,IAAI,EAAEI,EAAE,EAAEC,QAAQ,EAAE;QAC7C,MAAMC,WAAW,MAAMR,gBAAgBG,MAAM,wBAAwB;YACnEM,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBACnBT;gBACAC;gBACAH;eACII,KAAK;gBAAEA;YAAG,IAAI,CAAC,GACfC,WAAW;gBAAEA;YAAS,IAAI,CAAC;QAEnC;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;QAACH;KAAK;AAEV"}
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/hooks/use-host-resource-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 * Quota-governed host resource kinds served by `POST /api/hosts/resources`\n * (AGL-473). Firestore rules deny client-side `create` on these\n * collections, so creation MUST go through the API — it enforces the\n * per-plan quota (and entitlement, where the feature is paid) with the\n * Admin SDK. Updates and deletes stay client-direct.\n */\nexport type HostResourceKind =\n | 'screen'\n | 'layout'\n | 'variable'\n | 'function'\n | 'workflow'\n | 'service'\n | 'redirect'\n | 'location'\n | 'product'\n | 'reusableComponent'\n // A form, counted against the plan's `formsPerHost` allowance (Free 1\n // through 500, AGL-3597). The route entry existed before any typed caller\n // did, so creating one from the console was unreachable through this hook.\n | 'form'\n | 'register'\n | 'template'\n | 'webhook'\n // AGL-2266: two client-direct classes with no cap on any plan. `action`\n // is a flat host subcollection; `entry` is the one nested resource here\n // and needs `parentId` (the content collection it belongs to).\n | 'action'\n | 'entry'\n // AGL-2486: custom content authors, a flat host subcollection with a flat\n // platform cap — the `action` shape (create denied, update/delete open).\n | 'author'\n\n/**\n * Creates a quota-governed host resource through the console API\n * (AGL-473). `data` must be JSON-plain — no Firestore Timestamps; the\n * route stamps `createdAt`/`updatedAt` server-side when absent. Pass `id`\n * when the caller pre-generates the id (e.g. to write a first `versions`\n * doc under it). Pass `parentId` for a nested resource — `entry`, which\n * hangs off `hosts/{hostId}/collections/{parentId}` (AGL-2266). Throws with\n * the server's message on denial (quota, entitlement, role), for the\n * caller's snackbar.\n */\nexport function useHostResourceApi(): (options: {\n hostId: string\n resource: HostResourceKind\n data: Record<string, unknown>\n id?: string\n parentId?: string\n}) => Promise<{ id: string }> {\n const { data: user } = useUser()\n return useCallback(\n async ({ hostId, resource, data, id, parentId }) => {\n const response = await authorizedFetch(user, '/api/hosts/resources', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n hostId,\n resource,\n data,\n ...(id ? { id } : {}),\n ...(parentId ? { parentId } : {}),\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"],"names":["useCallback","useUser","authorizedFetch","useHostResourceApi","data","user","hostId","resource","id","parentId","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;AAoC1E;;;;;;;;;CASC,GACD,OAAO,SAASC;IAOd,MAAM,EAAEC,MAAMC,IAAI,EAAE,GAAGJ;IACvB,OAAOD,YACL,OAAO,EAAEM,MAAM,EAAEC,QAAQ,EAAEH,IAAI,EAAEI,EAAE,EAAEC,QAAQ,EAAE;QAC7C,MAAMC,WAAW,MAAMR,gBAAgBG,MAAM,wBAAwB;YACnEM,QAAQ;YACRC,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CC,MAAMC,KAAKC,SAAS,CAAC;gBACnBT;gBACAC;gBACAH;eACII,KAAK;gBAAEA;YAAG,IAAI,CAAC,GACfC,WAAW;gBAAEA;YAAS,IAAI,CAAC;QAEnC;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;QAACH;KAAK;AAEV"}