@aglyn/aglyn 1.12.0 → 1.14.0

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 (64) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/crm.js +8 -7
  3. package/src/lib/app-utils/crm.js.map +1 -1
  4. package/src/lib/app-utils/docs-help-sections.generated.js +8 -2
  5. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  6. package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
  7. package/src/lib/app-utils/docs-help.generated.js +7 -0
  8. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  9. package/src/lib/app-utils/docs-index.generated.js +48 -34
  10. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  11. package/src/lib/app-utils/dynamic-list-rule.js +9 -5
  12. package/src/lib/app-utils/dynamic-list-rule.js.map +1 -1
  13. package/src/lib/app-utils/host-permissions.d.ts +12 -0
  14. package/src/lib/app-utils/host-permissions.js +26 -1
  15. package/src/lib/app-utils/host-permissions.js.map +1 -1
  16. package/src/lib/app-utils/media-asset-facts.d.ts +2 -2
  17. package/src/lib/app-utils/media-asset-facts.js +4 -3
  18. package/src/lib/app-utils/media-asset-facts.js.map +1 -1
  19. package/src/lib/app-utils/media-cdn-scope.d.ts +19 -4
  20. package/src/lib/app-utils/media-cdn-scope.js +19 -5
  21. package/src/lib/app-utils/media-cdn-scope.js.map +1 -1
  22. package/src/lib/app-utils/media-ref.d.ts +10 -6
  23. package/src/lib/app-utils/media-ref.js +34 -8
  24. package/src/lib/app-utils/media-ref.js.map +1 -1
  25. package/src/lib/app-utils/native-nav.d.ts +2 -2
  26. package/src/lib/app-utils/native-nav.js +2 -2
  27. package/src/lib/app-utils/native-nav.js.map +1 -1
  28. package/src/lib/app-utils/org-permissions.d.ts +7 -0
  29. package/src/lib/app-utils/org-permissions.js +2 -0
  30. package/src/lib/app-utils/org-permissions.js.map +1 -1
  31. package/src/lib/app-utils/org-role-grants.d.ts +7 -0
  32. package/src/lib/app-utils/org-role-grants.js +7 -5
  33. package/src/lib/app-utils/org-role-grants.js.map +1 -1
  34. package/src/lib/app-utils/scope-tokens.d.ts +132 -3
  35. package/src/lib/app-utils/scope-tokens.js +276 -3
  36. package/src/lib/app-utils/scope-tokens.js.map +1 -1
  37. package/src/lib/app-utils/site-placement.d.ts +74 -0
  38. package/src/lib/app-utils/site-placement.js +80 -0
  39. package/src/lib/app-utils/site-placement.js.map +1 -0
  40. package/src/lib/app-utils/transfer-launcher-context.d.ts +17 -1
  41. package/src/lib/app-utils/transfer-launcher-context.js.map +1 -1
  42. package/src/lib/data-transfer/access.d.ts +10 -18
  43. package/src/lib/data-transfer/access.js +21 -25
  44. package/src/lib/data-transfer/access.js.map +1 -1
  45. package/src/lib/data-transfer/resource.d.ts +13 -14
  46. package/src/lib/data-transfer/resource.js +9 -10
  47. package/src/lib/data-transfer/resource.js.map +1 -1
  48. package/src/lib/plugin-manager/first-party-plugins.generated.js +3 -4
  49. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  50. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +10 -0
  51. package/src/lib/plugin-manager/plugin-contact-capture.js +11 -0
  52. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
  53. package/src/lib/plugin-manager/plugin-entitlements.d.ts +12 -0
  54. package/src/lib/plugin-manager/plugin-entitlements.js +3 -1
  55. package/src/lib/plugin-manager/plugin-entitlements.js.map +1 -1
  56. package/src/lib/plugin-manager/plugin-scope-sharing.d.ts +52 -0
  57. package/src/lib/plugin-manager/plugin-scope-sharing.generated.d.ts +10 -0
  58. package/src/lib/plugin-manager/plugin-scope-sharing.generated.js +82 -0
  59. package/src/lib/plugin-manager/plugin-scope-sharing.generated.js.map +1 -0
  60. package/src/lib/plugin-manager/plugin-scope-sharing.js +85 -0
  61. package/src/lib/plugin-manager/plugin-scope-sharing.js.map +1 -0
  62. package/src/lib/plugin-manager/plugin-transfer-resources.d.ts +56 -1
  63. package/src/lib/plugin-manager/plugin-transfer-resources.js +13 -0
  64. package/src/lib/plugin-manager/plugin-transfer-resources.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/access.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 type { TransferImportRole, TransferResourceDescriptor } from './resource'\nimport { TRANSFER_PLAN_REQUIRED, type TransferApiRoute, type TransferPlanRequiredResponse } from './transfer-api'\n\n/*==========================================\n * WHO MAY MOVE A RESOURCE'S RECORDS (AGL-3546)\n *\n * Two intents, answered the same way by the transfer routes' gate and by the\n * console's display of Import and Export, so a button is never offered that\n * the route refuses:\n *\n * - IMPORT (upload, analyze, plan, apply, status, undo — and the job list\n * and packages, which the gate asks with the same intent) writes records, and\n * needs `data.manage` — on the named site, or on the workspace. A\n * resource stricter than that names its `importRoles` (AGL-3554): the\n * member's role where the records are must also be one of them (gift\n * cards: a site's admins, which a workspace's owners and admins are).\n * - EXPORT (export, and `fields`, which the export dialog opens with) only\n * reads them, and asks what the resource declares: `readableByMembers`\n * admits any member (a collaborator who reaches the named site), the\n * way datasets are read; a `readPermission` admits whoever holds it; and\n * a resource that declares neither keeps `data.manage`, because its\n * records may be ones the rules let only managers read (CRM contacts).\n * `data.manage` always admits. Which records a reader then sees is the\n * resource's own business: `readPage` and `count` honor the reader's\n * `scopeTokens`, as every other door onto the records does.\n *\n * And one question of the WORKSPACE, asked after the member's (AGL-3555):\n * a resource that declares a `featureFlag` is moved only by a workspace\n * whose plan carries that feature, for every intent but the ones it lists\n * in `featureFlagExempt`. {@link transferPlanFeature} names the feature an\n * intent needs; the gate refuses without it (403 `plan_required`, the\n * feature as `code`), staff included, and the console's `can` answers\n * `false`, so neither button is offered on a plan the route refuses.\n *==========================================*/\n\n/** What a resource declares about who may read and import its records. */\nexport type TransferReadDeclaration = Pick<TransferResourceDescriptor, 'readPermission' | 'readableByMembers' | 'importRoles'>\n\n/** What a resource declares about the plan that moves its records. */\nexport type TransferPlanDeclaration = Pick<TransferResourceDescriptor, 'featureFlag' | 'featureFlagExempt'>\n\n/** What a member is doing with a resource's records. */\nexport type TransferAccessIntent = 'import' | 'export'\n\n/** The permission every import asks for. */\nexport const TRANSFER_MANAGE_PERMISSION = 'data.manage'\n\n/** The routes that only read records, and so ask for export access. */\nexport const TRANSFER_EXPORT_ROUTES: readonly TransferApiRoute[] = ['fields', 'export']\n\n/** The intent a transfer route asks with. */\nexport function transferRouteIntent(route: TransferApiRoute): TransferAccessIntent {\n return TRANSFER_EXPORT_ROUTES.includes(route) ? 'export' : 'import'\n}\n\n/**\n * The permissions any ONE of which admits a member to `intent` on a\n * resource. Empty means membership is enough (and, for a collaborator,\n * reaching the named site).\n */\nexport function transferAccessPermissions(\n intent: TransferAccessIntent,\n descriptor: TransferReadDeclaration | null | undefined,\n): readonly string[] {\n if (intent === 'import') return [TRANSFER_MANAGE_PERMISSION]\n if (descriptor?.readableByMembers === true) return []\n const read = descriptor?.readPermission?.trim()\n // Whoever may write the records may read them.\n return read && read !== TRANSFER_MANAGE_PERMISSION ? [read, TRANSFER_MANAGE_PERMISSION] : [TRANSFER_MANAGE_PERMISSION]\n}\n\n/** How one member's permissions resolve where the records are. */\nexport interface TransferMemberAxis {\n /** Whether the member holds `permission` on the named site, or on the workspace when none is named. */\n holds(permission: string): boolean\n /** Whether the member reaches the named site; `true` when none is named or the member is org-wide. */\n reachesSite: boolean\n /**\n * The member's role where the records are — on the named site\n * (`hostRoleFor`), or on the workspace (`transferWorkspaceRole`) — for a\n * resource that names `importRoles`; `null` for none.\n */\n role?: TransferImportRole | null\n}\n\n/** Whether a member may `intent` a resource's records: see the block above. */\nexport function transferAccessAllowed(\n intent: TransferAccessIntent,\n descriptor: TransferReadDeclaration | null | undefined,\n axis: TransferMemberAxis,\n): boolean {\n if (!axis.reachesSite) return false\n if (!transferImportRoleAllowed(intent, descriptor, axis.role ?? null)) return false\n const needed = transferAccessPermissions(intent, descriptor)\n return !needed.length || needed.some((permission) => axis.holds(permission))\n}\n\n/**\n * Whether a member in `role` may `intent` the records, as far as the\n * resource's `importRoles` say: always for an export, or a resource that\n * names none (AGL-3554).\n */\nexport function transferImportRoleAllowed(\n intent: TransferAccessIntent,\n descriptor: Pick<TransferResourceDescriptor, 'importRoles'> | null | undefined,\n role: TransferImportRole | null,\n): boolean {\n const roles = descriptor?.importRoles\n if (intent !== 'import' || !roles?.length) return true\n return role !== null && roles.includes(role)\n}\n\n/**\n * A workspace role as the site role it is on every site, for a workspace's\n * records: an owner or an admin is every site's admin (`hostRoleFor`), and\n * any other role is itself.\n */\nexport function transferWorkspaceRole(role: string | null | undefined): TransferImportRole | null {\n if (role === 'owner' || role === 'admin') return 'admin'\n return role === 'editor' || role === 'author' || role === 'viewer' ? role : null\n}\n\n/** The sentence refusing a member whose role is not among the resource's `importRoles`. */\nexport function transferImportRoleRefusal(\n descriptor: Pick<TransferResourceDescriptor, 'importRoles' | 'label' | 'scope'>,\n): string {\n const roles = descriptor.importRoles ?? []\n const what = /^[A-Z][a-z]/.test(descriptor.label)\n ? descriptor.label.charAt(0).toLowerCase() + descriptor.label.slice(1)\n : descriptor.label\n if (roles.length === 1 && roles[0] === 'admin') {\n return descriptor.scope === 'host'\n ? `Only the workspace’s owners and admins, and the site’s admins, can import ${what}.`\n : `Only the workspace’s owners and admins can import ${what}.`\n }\n const named = roles.map((role) => role.charAt(0).toUpperCase() + role.slice(1)).join(', ')\n return `Importing ${what} needs one of these roles${descriptor.scope === 'host' ? ' on the site' : ''}: ${named}.`\n}\n\n/**\n * The plan feature a workspace needs to `intent` a resource's records, or\n * `null` when every plan may — no `featureFlag`, or an intent the resource\n * exempts. The entitlement itself is the caller's to resolve\n * (`checkEntitlement`), from the workspace document it already holds.\n */\nexport function transferPlanFeature(\n intent: TransferAccessIntent,\n descriptor: TransferPlanDeclaration | null | undefined,\n): string | null {\n const feature = descriptor?.featureFlag?.trim()\n if (!feature) return null\n return descriptor?.featureFlagExempt?.includes(intent) ? null : feature\n}\n\n/** Whether a refusal's body is one for the workspace's plan. */\nexport function isTransferPlanRequired(body: unknown): body is TransferPlanRequiredResponse {\n return Boolean(body && typeof body === 'object' && (body as { reason?: unknown }).reason === TRANSFER_PLAN_REQUIRED)\n}\n"],"names":["TRANSFER_PLAN_REQUIRED","TRANSFER_MANAGE_PERMISSION","TRANSFER_EXPORT_ROUTES","transferRouteIntent","route","includes","transferAccessPermissions","intent","descriptor","readableByMembers","read","readPermission","trim","transferAccessAllowed","axis","reachesSite","transferImportRoleAllowed","role","needed","length","some","permission","holds","roles","importRoles","transferWorkspaceRole","transferImportRoleRefusal","what","test","label","charAt","toLowerCase","slice","scope","named","map","toUpperCase","join","transferPlanFeature","feature","featureFlag","featureFlagExempt","isTransferPlanRequired","body","Boolean","reason"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,sBAAsB,QAAkE,oBAAgB;AA2CjH,0CAA0C,GAC1C,OAAO,MAAMC,6BAA6B,cAAa;AAEvD,qEAAqE,GACrE,OAAO,MAAMC,yBAAsD;IAAC;IAAU;CAAS,CAAA;AAEvF,2CAA2C,GAC3C,OAAO,SAASC,oBAAoBC,KAAuB;IACzD,OAAOF,uBAAuBG,QAAQ,CAACD,SAAS,WAAW;AAC7D;AAEA;;;;CAIC,GACD,OAAO,SAASE,0BACdC,MAA4B,EAC5BC,UAAsD;QAIzCA;IAFb,IAAID,WAAW,UAAU,OAAO;QAACN;KAA2B;IAC5D,IAAIO,CAAAA,8BAAAA,WAAYC,iBAAiB,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C,KAClExB,WAAWqB,KAAK;IACpB,IAAIN,MAAMJ,MAAM,KAAK,KAAKI,KAAK,CAAC,EAAE,KAAK,SAAS;QAC9C,OAAOf,WAAWyB,KAAK,KAAK,SACxB,CAAC,0EAA0E,EAAEN,KAAK,CAAC,CAAC,GACpF,CAAC,kDAAkD,EAAEA,KAAK,CAAC,CAAC;IAClE;IACA,MAAMO,QAAQX,MAAMY,GAAG,CAAC,CAAClB,OAASA,KAAKa,MAAM,CAAC,GAAGM,WAAW,KAAKnB,KAAKe,KAAK,CAAC,IAAIK,IAAI,CAAC;IACrF,OAAO,CAAC,UAAU,EAAEV,KAAK,yBAAyB,EAAEnB,WAAWyB,KAAK,KAAK,SAAS,iBAAiB,GAAG,EAAE,EAAEC,MAAM,CAAC,CAAC;AACpH;AAEA;;;;;CAKC,GACD,OAAO,SAASI,oBACd/B,MAA4B,EAC5BC,UAAsD;QAEtCA,yBAETA;IAFP,MAAM+B,UAAU/B,+BAAAA,0BAAAA,WAAYgC,WAAW,qBAAvBhC,wBAAyBI,IAAI;IAC7C,IAAI,CAAC2B,SAAS,OAAO;IACrB,OAAO/B,CAAAA,+BAAAA,gCAAAA,WAAYiC,iBAAiB,qBAA7BjC,8BAA+BH,QAAQ,CAACE,WAAU,OAAOgC;AAClE;AAEA,8DAA8D,GAC9D,OAAO,SAASG,uBAAuBC,IAAa;IAClD,OAAOC,QAAQD,QAAQ,OAAOA,SAAS,YAAY,AAACA,KAA8BE,MAAM,KAAK7C;AAC/F"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/access.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 type { TransferResourceDescriptor } from './resource'\nimport { TRANSFER_PLAN_REQUIRED, type TransferApiRoute, type TransferPlanRequiredResponse } from './transfer-api'\n\n/*==========================================\n * WHO MAY MOVE A RESOURCE'S RECORDS (AGL-3546)\n *\n * Two intents, answered the same way by the transfer routes' gate and by the\n * console's display of Import and Export, so a button is never offered that\n * the route refuses:\n *\n * - IMPORT (upload, analyze, plan, apply, status, undo — and the job list\n * and packages, which the gate asks with the same intent) writes records, and\n * needs `data.manage` — on the named site, or on the workspace. A\n * resource stricter than that names its `importPermission` (AGL-4047):\n * the member must also hold that key where the records are (gift cards:\n * \"Import gift cards\", whose preset is the site's Admin).\n * - EXPORT (export, and `fields`, which the export dialog opens with) only\n * reads them, and asks what the resource declares: `readableByMembers`\n * admits any member (a collaborator who reaches the named site), the\n * way datasets are read; a `readPermission` admits whoever holds it; and\n * a resource that declares neither keeps `data.manage`, because its\n * records may be ones the rules let only managers read (CRM contacts).\n * `data.manage` always admits, unless the resource declares\n * `readPermissionOnly`, where only `readPermission` does. Which records a reader then sees is the\n * resource's own business: `readPage` and `count` honor the reader's\n * `scopeTokens`, as every other door onto the records does.\n *\n * And one question of the WORKSPACE, asked after the member's (AGL-3555):\n * a resource that declares a `featureFlag` is moved only by a workspace\n * whose plan carries that feature, for every intent but the ones it lists\n * in `featureFlagExempt`. {@link transferPlanFeature} names the feature an\n * intent needs; the gate refuses without it (403 `plan_required`, the\n * feature as `code`), staff included, and the console's `can` answers\n * `false`, so neither button is offered on a plan the route refuses.\n *==========================================*/\n\n/** What a resource declares about who may read and import its records. */\nexport type TransferReadDeclaration = Pick<\n TransferResourceDescriptor,\n 'readPermission' | 'readPermissionOnly' | 'readableByMembers' | 'importPermission'\n>\n\n/** What a resource declares about the plan that moves its records. */\nexport type TransferPlanDeclaration = Pick<TransferResourceDescriptor, 'featureFlag' | 'featureFlagExempt'>\n\n/** What a member is doing with a resource's records. */\nexport type TransferAccessIntent = 'import' | 'export'\n\n/** The permission every import asks for. */\nexport const TRANSFER_MANAGE_PERMISSION = 'data.manage'\n\n/** The routes that only read records, and so ask for export access. */\nexport const TRANSFER_EXPORT_ROUTES: readonly TransferApiRoute[] = ['fields', 'export']\n\n/** The intent a transfer route asks with. */\nexport function transferRouteIntent(route: TransferApiRoute): TransferAccessIntent {\n return TRANSFER_EXPORT_ROUTES.includes(route) ? 'export' : 'import'\n}\n\n/**\n * The permissions any ONE of which admits a member to `intent` on a\n * resource. Empty means membership is enough (and, for a collaborator,\n * reaching the named site).\n */\nexport function transferAccessPermissions(\n intent: TransferAccessIntent,\n descriptor: TransferReadDeclaration | null | undefined,\n): readonly string[] {\n if (intent === 'import') return [TRANSFER_MANAGE_PERMISSION]\n if (descriptor?.readableByMembers === true) return []\n const read = descriptor?.readPermission?.trim()\n if (read && descriptor?.readPermissionOnly === true) return [read]\n // Whoever may write the records may read them.\n return read && read !== TRANSFER_MANAGE_PERMISSION ? [read, TRANSFER_MANAGE_PERMISSION] : [TRANSFER_MANAGE_PERMISSION]\n}\n\n/** How one member's permissions resolve where the records are. */\nexport interface TransferMemberAxis {\n /** Whether the member holds `permission` on the named site, or on the workspace when none is named. */\n holds(permission: string): boolean\n /** Whether the member reaches the named site; `true` when none is named or the member is org-wide. */\n reachesSite: boolean\n}\n\n/** Whether a member may `intent` a resource's records: see the block above. */\nexport function transferAccessAllowed(\n intent: TransferAccessIntent,\n descriptor: TransferReadDeclaration | null | undefined,\n axis: TransferMemberAxis,\n): boolean {\n if (!axis.reachesSite) return false\n const stricter = transferImportPermission(intent, descriptor)\n if (stricter && !axis.holds(stricter)) return false\n const needed = transferAccessPermissions(intent, descriptor)\n return !needed.length || needed.some((permission) => axis.holds(permission))\n}\n\n/**\n * The permission to name when a member may not `intent` the records, or `null`\n * when their permissions are not what refuses them: they hold what it takes, or\n * they do not reach the site, which no key decides. Asked in the gate's order.\n */\nexport function transferMissingPermission(\n intent: TransferAccessIntent,\n descriptor: TransferReadDeclaration | null | undefined,\n axis: TransferMemberAxis,\n): string | null {\n if (!axis.reachesSite) return null\n const needed = transferAccessPermissions(intent, descriptor)\n if (needed.length && !needed.some((permission) => axis.holds(permission))) return needed[0]\n const stricter = transferImportPermission(intent, descriptor)\n return stricter && !axis.holds(stricter) ? stricter : null\n}\n\n/**\n * The key a member must also hold to `intent` the records, on top of\n * `data.manage` (AGL-4047): the resource's `importPermission` for an import,\n * and nothing for an export or a resource that names none.\n */\nexport function transferImportPermission(\n intent: TransferAccessIntent,\n descriptor: Pick<TransferResourceDescriptor, 'importPermission'> | null | undefined,\n): string | null {\n const key = descriptor?.importPermission?.trim()\n return intent === 'import' && key ? key : null\n}\n\n/**\n * The plan feature a workspace needs to `intent` a resource's records, or\n * `null` when every plan may — no `featureFlag`, or an intent the resource\n * exempts. The entitlement itself is the caller's to resolve\n * (`checkEntitlement`), from the workspace document it already holds.\n */\nexport function transferPlanFeature(\n intent: TransferAccessIntent,\n descriptor: TransferPlanDeclaration | null | undefined,\n): string | null {\n const feature = descriptor?.featureFlag?.trim()\n if (!feature) return null\n return descriptor?.featureFlagExempt?.includes(intent) ? null : feature\n}\n\n/** Whether a refusal's body is one for the workspace's plan. */\nexport function isTransferPlanRequired(body: unknown): body is TransferPlanRequiredResponse {\n return Boolean(body && typeof body === 'object' && (body as { reason?: unknown }).reason === TRANSFER_PLAN_REQUIRED)\n}\n"],"names":["TRANSFER_PLAN_REQUIRED","TRANSFER_MANAGE_PERMISSION","TRANSFER_EXPORT_ROUTES","transferRouteIntent","route","includes","transferAccessPermissions","intent","descriptor","readableByMembers","read","readPermission","trim","readPermissionOnly","transferAccessAllowed","axis","reachesSite","stricter","transferImportPermission","holds","needed","length","some","permission","transferMissingPermission","key","importPermission","transferPlanFeature","feature","featureFlag","featureFlagExempt","isTransferPlanRequired","body","Boolean","reason"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,sBAAsB,QAAkE,oBAA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C,CAACC,aAAeR,KAAKI,KAAK,CAACI,cAAc,OAAOH,MAAM,CAAC,EAAE;IAC3F,MAAMH,WAAWC,yBAAyBX,QAAQC;IAClD,OAAOS,YAAY,CAACF,KAAKI,KAAK,CAACF,YAAYA,WAAW;AACxD;AAEA;;;;CAIC,GACD,OAAO,SAASC,yBACdX,MAA4B,EAC5BC,UAAmF;QAEvEA;IAAZ,MAAMiB,MAAMjB,+BAAAA,+BAAAA,WAAYkB,gBAAgB,qBAA5BlB,6BAA8BI,IAAI;IAC9C,OAAOL,WAAW,YAAYkB,MAAMA,MAAM;AAC5C;AAEA;;;;;CAKC,GACD,OAAO,SAASE,oBACdpB,MAA4B,EAC5BC,UAAsD;QAEtCA,yBAETA;IAFP,MAAMoB,UAAUpB,+BAAAA,0BAAAA,WAAYqB,WAAW,qBAAvBrB,wBAAyBI,IAAI;IAC7C,IAAI,CAACgB,SAAS,OAAO;IACrB,OAAOpB,CAAAA,+BAAAA,gCAAAA,WAAYsB,iBAAiB,qBAA7BtB,8BAA+BH,QAAQ,CAACE,WAAU,OAAOqB;AAClE;AAEA,8DAA8D,GAC9D,OAAO,SAASG,uBAAuBC,IAAa;IAClD,OAAOC,QAAQD,QAAQ,OAAOA,SAAS,YAAY,AAACA,KAA8BE,MAAM,KAAKlC;AAC/F"}
@@ -65,6 +65,12 @@ export interface TransferResourceDescriptor {
65
65
  * `data.manage` either way.
66
66
  */
67
67
  readPermission?: string;
68
+ /**
69
+ * `readPermission` alone decides an export (AGL-4047): `data.manage` does
70
+ * not also admit, so taking the permission away from someone who may write
71
+ * the records stops the export too. Needs `readPermission`.
72
+ */
73
+ readPermissionOnly?: boolean;
68
74
  /**
69
75
  * The resource is exported and never imported — a record of work done (a
70
76
  * CRM's logged activities) or a setup edited on its own page. The upload
@@ -88,22 +94,15 @@ export interface TransferResourceDescriptor {
88
94
  */
89
95
  featureFlagExempt?: readonly ('import' | 'export')[];
90
96
  /**
91
- * The only roles that may IMPORT the records, where the records are —
92
- * the member's role on the named site (`hostRoleFor`: a workspace owner or
93
- * admin is every site's admin), or on the workspace for a workspace's
94
- * records — on top of `data.manage`, for a resource stricter than the
95
- * permission: gift cards, which an import issues as spendable money, are
96
- * imported by `["admin"]` alone (AGL-3554). The transfer gate refuses
97
- * anyone else on every import step, the console's `can('import')` answers
98
- * `false` for them, and the hub offers them no Import. See
99
- * `data-transfer/access.ts`.
97
+ * A catalog key a member must also hold to IMPORT the records, where the
98
+ * records are, on top of `data.manage`, for a resource stricter than that
99
+ * permission: gift cards, which an import issues as spendable money, ask
100
+ * "Import gift cards" (AGL-4047). The transfer gate refuses anyone else on
101
+ * every import step, the console's `can('import')` answers `false` for
102
+ * them, and the hub offers them no Import. See `data-transfer/access.ts`.
100
103
  */
101
- importRoles?: readonly TransferImportRole[];
104
+ importPermission?: string;
102
105
  }
103
- /** A role {@link TransferResourceDescriptor.importRoles} names: a site role. */
104
- export type TransferImportRole = 'admin' | 'editor' | 'author' | 'viewer';
105
- /** Every {@link TransferImportRole}, strongest first. */
106
- export declare const TRANSFER_IMPORT_ROLES: readonly TransferImportRole[];
107
106
  /** Whether a file may be imported into the resource. */
108
107
  export declare function transferResourceImports(descriptor: Pick<TransferResourceDescriptor, 'exportOnly'>): boolean;
109
108
  /** What a field means, which decides how a cell is read and written. */
@@ -43,12 +43,6 @@
43
43
  'json',
44
44
  'ndjson'
45
45
  ];
46
- /** Every {@link TransferImportRole}, strongest first. */ export const TRANSFER_IMPORT_ROLES = [
47
- 'admin',
48
- 'editor',
49
- 'author',
50
- 'viewer'
51
- ];
52
46
  /** Whether a file may be imported into the resource. */ export function transferResourceImports(descriptor) {
53
47
  return descriptor.exportOnly !== true;
54
48
  }
@@ -145,17 +139,22 @@ const RESOURCE_KEY = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
145
139
  if (descriptor.readableByMembers === true && descriptor.readPermission !== undefined) {
146
140
  problems.push(`${descriptor.key} is readable by every member and names a read permission; say one.`);
147
141
  }
142
+ if (descriptor.readPermissionOnly !== undefined && typeof descriptor.readPermissionOnly !== 'boolean') {
143
+ problems.push(`${descriptor.key} says "readPermissionOnly" with something other than true or false.`);
144
+ }
145
+ if (descriptor.readPermissionOnly === true && descriptor.readPermission === undefined) {
146
+ problems.push(`${descriptor.key} says "readPermissionOnly" and names no read permission.`);
147
+ }
148
148
  if (descriptor.exportOnly !== undefined && typeof descriptor.exportOnly !== 'boolean') {
149
149
  problems.push(`${descriptor.key} says "exportOnly" with something other than true or false.`);
150
150
  }
151
151
  if (descriptor.featureFlag !== undefined && !String(descriptor.featureFlag).trim()) {
152
152
  problems.push(`${descriptor.key} names an empty plan feature.`);
153
153
  }
154
- if (descriptor.importRoles !== undefined) {
155
- const roles = descriptor.importRoles;
154
+ if (descriptor.importPermission !== undefined) {
156
155
  if (descriptor.exportOnly === true) problems.push(`${descriptor.key} names who may import records it never imports.`);
157
- if (!Array.isArray(roles) || !roles.length || roles.some((role)=>!TRANSFER_IMPORT_ROLES.includes(role))) {
158
- problems.push(`${descriptor.key} names an import role that is not ${TRANSFER_IMPORT_ROLES.join(', ')}.`);
156
+ if (typeof descriptor.importPermission !== 'string' || !descriptor.importPermission.trim()) {
157
+ problems.push(`${descriptor.key} names an empty import permission.`);
159
158
  }
160
159
  }
161
160
  if (descriptor.featureFlagExempt !== undefined) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/resource.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\n/*==========================================\n * TRANSFER RESOURCES — what can be imported or exported, and its fields.\n *\n * A resource is one kind of thing a person moves in or out of Aglyn: a\n * collection of records (rows in a file) or a set of site items (a\n * package). The plugin that owns the thing declares it; this module only\n * says what a declaration looks like and what a field may be, so every\n * importer, exporter and wizard reads the same shape.\n *\n * ## A field says what it is, not how it is stored\n *\n * `type` is the field's meaning to a person — an email, a currency amount,\n * a picklist — which is what decides how a cell is read (`derive.ts`), how\n * a header is guessed (`header-match.ts`) and which policies make sense\n * (`policy.ts`: only a list can be appended to). Where the value lives in\n * storage is the owning plugin's business.\n *\n * ## Read-only, derived and system fields export but never import\n *\n * A derived field (a score, a count) is computed from others; a system\n * field (the Aglyn id, created/updated times) is written by the platform.\n * Both are offered on export because a person wants them in the file, and\n * neither is ever written from a file. A `matchKey` field — the Aglyn id\n * above all — may still be MAPPED on import, because it identifies which\n * existing record a row is about; it is read, never written.\n *=========================================*/\n\n/** Where the records of a resource live: the organization, or one site. */\nexport type TransferScope = 'org' | 'host'\n\n/** Rows in a file, or a set of site items carried as a package. */\nexport type TransferKind = 'records' | 'package'\n\n/** The file formats a resource can be read from and written to. */\nexport type TransferFormat = 'csv' | 'json' | 'ndjson'\n\nexport const TRANSFER_FORMATS: readonly TransferFormat[] = ['csv', 'json', 'ndjson']\n\n/** The bounds one transfer of a resource is held to. */\nexport interface TransferLimits {\n /** The most rows (or items) one file may carry. */\n maxRows: number\n /** The most bytes one uploaded file may carry, when the resource bounds it. */\n maxBytes?: number\n}\n\n/** One resource as its owning plugin declares it. */\nexport interface TransferResourceDescriptor {\n /** Stable key, lowercase words joined by `-` or `.` — the URL and storage name. */\n key: string\n /** What a person calls one batch of it (\"People\", \"Pages\"). */\n label: string\n /** One record (\"Person\", \"Page\"); defaults to `label`. */\n singularLabel?: string\n scope: TransferScope\n kinds: readonly TransferKind[]\n formats: readonly TransferFormat[]\n limits?: TransferLimits\n /** One sentence on what moves, shown on the hub. */\n description?: string\n /**\n * The resource is moved one instance at a time — one dataset's records, not\n * every dataset's — so every key that reaches it names the instance as\n * `<key>:<instance>` ({@link transferResourceInstanceKey}). A job, a\n * person's remembered choices and the one-running-import rule are then kept\n * per instance, and the plugin's hooks read which one from the context's\n * `resource` ({@link transferResourceInstanceOf}).\n */\n instances?: boolean\n /**\n * Any member may EXPORT the records (and open the export dialog), as far\n * as their scope lets them see them — a collaborator only on a site they\n * reach — because the rules let every member read them (a dataset's\n * records). See `data-transfer/access.ts`.\n */\n readableByMembers?: boolean\n /**\n * The permission that admits a member to EXPORT the records, beside\n * `data.manage`, which always does. A resource that declares neither this\n * nor `readableByMembers` exports for `data.manage` alone. Importing needs\n * `data.manage` either way.\n */\n readPermission?: string\n /**\n * The resource is exported and never imported — a record of work done (a\n * CRM's logged activities) or a setup edited on its own page. The upload\n * refuses it, its plugin registers no `apply` or `revert`, and a surface\n * offers only Export (AGL-3528).\n */\n exportOnly?: boolean\n /**\n * The plan feature (an `OrgFeatureFlags` key, `crm`) a workspace's plan\n * must carry to move these records — the flag the owning plugin's console\n * surfaces are gated by. Without it every route of every intent refuses\n * with 403 `plan_required` and the feature as `code`, staff included, and\n * the console offers neither button (AGL-3555). See `data-transfer/access.ts`.\n */\n featureFlag?: string\n /**\n * The intents that stay open on every plan despite `featureFlag` — an\n * obligation rather than a feature: the CRM's people files are exported\n * on Free, because taking out the people a workspace holds is every\n * plan's right, while importing them is the CRM.\n */\n featureFlagExempt?: readonly ('import' | 'export')[]\n /**\n * The only roles that may IMPORT the records, where the records are —\n * the member's role on the named site (`hostRoleFor`: a workspace owner or\n * admin is every site's admin), or on the workspace for a workspace's\n * records — on top of `data.manage`, for a resource stricter than the\n * permission: gift cards, which an import issues as spendable money, are\n * imported by `[\"admin\"]` alone (AGL-3554). The transfer gate refuses\n * anyone else on every import step, the console's `can('import')` answers\n * `false` for them, and the hub offers them no Import. See\n * `data-transfer/access.ts`.\n */\n importRoles?: readonly TransferImportRole[]\n}\n\n/** A role {@link TransferResourceDescriptor.importRoles} names: a site role. */\nexport type TransferImportRole = 'admin' | 'editor' | 'author' | 'viewer'\n\n/** Every {@link TransferImportRole}, strongest first. */\nexport const TRANSFER_IMPORT_ROLES: readonly TransferImportRole[] = ['admin', 'editor', 'author', 'viewer']\n\n/** Whether a file may be imported into the resource. */\nexport function transferResourceImports(descriptor: Pick<TransferResourceDescriptor, 'exportOnly'>): boolean {\n return descriptor.exportOnly !== true\n}\n\n/** What a field means, which decides how a cell is read and written. */\nexport type TransferFieldType =\n | 'text'\n | 'longText'\n | 'email'\n | 'phone'\n | 'url'\n | 'number'\n | 'integer'\n | 'currency'\n | 'percent'\n | 'boolean'\n | 'date'\n | 'datetime'\n | 'picklist'\n | 'multiPicklist'\n | 'tags'\n | 'address'\n | 'lookup'\n | 'json'\n | 'list'\n\nexport const TRANSFER_FIELD_TYPES: readonly TransferFieldType[] = [\n 'text',\n 'longText',\n 'email',\n 'phone',\n 'url',\n 'number',\n 'integer',\n 'currency',\n 'percent',\n 'boolean',\n 'date',\n 'datetime',\n 'picklist',\n 'multiPicklist',\n 'tags',\n 'address',\n 'lookup',\n 'json',\n 'list',\n]\n\n/**\n * The types whose value is a list, and so the only ones a file can append to:\n * picklist values, tags (kept lower-case), and a `list` of free text items\n * kept as typed.\n */\nexport const TRANSFER_LIST_FIELD_TYPES: readonly TransferFieldType[] = ['multiPicklist', 'tags', 'list']\n\n/**\n * What a lookup field points at: another resource, found by one of its\n * match keys (a company by domain, an owner by email). A `lookup` field\n * holds one record; a `list` field that names a target holds several, each\n * item resolved on its own (a dataset's multi-reference).\n */\nexport interface TransferLookupTarget {\n /** The resource key of the target. */\n resource: string\n /** The target's field ids a cell may name it by, in the order they are tried. */\n by: readonly string[]\n /** Whether an unresolved value may be offered \"create it\" in the wizard. */\n creatable?: boolean\n}\n\n/** One field of a resource. */\nexport interface TransferField {\n /** Stable id; a custom field's id is `custom:<key>`. */\n id: string\n label: string\n /** The group id the field is listed under in a picker. */\n group?: string\n type: TransferFieldType\n /** A new record cannot be created without it. */\n required?: boolean\n /** Exported, never written from a file. */\n readOnly?: boolean\n /** Computed from other fields; exported, never written from a file. */\n derived?: boolean\n /** Written by the platform (id, created, updated); exported, never written. */\n system?: boolean\n /** Defined by the organization rather than the resource. */\n custom?: boolean\n /** May be mapped on import to identify an existing record even when it is never written. */\n matchKey?: boolean\n /** Header spellings that mean this field, beside its label and id. */\n aliases?: readonly string[]\n /** The picklist whose values a `picklist` or `multiPicklist` field holds. */\n picklistId?: string\n /** What a `lookup` field resolves to. */\n lookup?: TransferLookupTarget\n /** The longest text the field stores. */\n maxLength?: number\n /** One sentence shown beside the field in a picker. */\n description?: string\n}\n\n/** The field id every resource uses for the record's Aglyn id. */\nexport const TRANSFER_ID_FIELD = 'id'\n\n/** Whether values of `type` are lists. */\nexport function isTransferListType(type: TransferFieldType): boolean {\n return TRANSFER_LIST_FIELD_TYPES.includes(type)\n}\n\n/**\n * Whether `field` names records of a target — a `lookup` field, or a `list`\n * field whose items do — so the job engine resolves its values to ids.\n */\nexport function isTransferLookupField(\n field: TransferField | null | undefined,\n): field is TransferField & { lookup: TransferLookupTarget } {\n return Boolean(\n field &&\n (field.type === 'lookup' || field.type === 'list') &&\n field.lookup?.resource &&\n field.lookup.by?.length,\n )\n}\n\n/** Whether a file's cell may be WRITTEN to `field`. */\nexport function isTransferFieldWritable(field: TransferField): boolean {\n return !field.readOnly && !field.derived && !field.system\n}\n\n/** Whether a file's column may be MAPPED to `field` on import — written, or read to match. */\nexport function isTransferFieldImportable(field: TransferField): boolean {\n return isTransferFieldWritable(field) || Boolean(field.matchKey)\n}\n\nconst RESOURCE_KEY = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/\n\n/** Whether `key` is a well-formed resource key. */\nexport function isTransferResourceKey(key: unknown): key is string {\n return typeof key === 'string' && key.length <= 64 && RESOURCE_KEY.test(key)\n}\n\n/**\n * What is wrong with a declaration, as sentences; empty when nothing is.\n * Checked when a plugin registers, so a malformed one fails loudly at\n * startup rather than in a person's wizard.\n */\nexport function transferResourceProblems(descriptor: TransferResourceDescriptor): string[] {\n const problems: string[] = []\n if (!isTransferResourceKey(descriptor.key)) {\n problems.push(`\"${String(descriptor.key)}\" is not a resource key (lowercase words joined by - or .).`)\n }\n if (!String(descriptor.label ?? '').trim()) problems.push(`${descriptor.key} has no label.`)\n if (descriptor.scope !== 'org' && descriptor.scope !== 'host') {\n problems.push(`${descriptor.key} has scope \"${String(descriptor.scope)}\"; it must be org or host.`)\n }\n if (!descriptor.kinds?.length) problems.push(`${descriptor.key} declares no kind.`)\n for (const kind of descriptor.kinds ?? []) {\n if (kind !== 'records' && kind !== 'package') problems.push(`${descriptor.key} has unknown kind \"${String(kind)}\".`)\n }\n if (!descriptor.formats?.length) problems.push(`${descriptor.key} declares no format.`)\n for (const format of descriptor.formats ?? []) {\n if (!TRANSFER_FORMATS.includes(format)) problems.push(`${descriptor.key} has unknown format \"${String(format)}\".`)\n }\n const limits = descriptor.limits\n if (limits && !(Number.isInteger(limits.maxRows) && limits.maxRows > 0)) {\n problems.push(`${descriptor.key} has a row limit that is not a positive whole number.`)\n }\n if (limits?.maxBytes !== undefined && !(Number.isInteger(limits.maxBytes) && limits.maxBytes > 0)) {\n problems.push(`${descriptor.key} has a byte limit that is not a positive whole number.`)\n }\n if (descriptor.instances !== undefined && typeof descriptor.instances !== 'boolean') {\n problems.push(`${descriptor.key} says \"instances\" with something other than true or false.`)\n }\n if (descriptor.readPermission !== undefined && !String(descriptor.readPermission).trim()) {\n problems.push(`${descriptor.key} names an empty read permission.`)\n }\n if (descriptor.readableByMembers !== undefined && typeof descriptor.readableByMembers !== 'boolean') {\n problems.push(`${descriptor.key} says \"readableByMembers\" with something other than true or false.`)\n }\n if (descriptor.readableByMembers === true && descriptor.readPermission !== undefined) {\n problems.push(`${descriptor.key} is readable by every member and names a read permission; say one.`)\n }\n if (descriptor.exportOnly !== undefined && typeof descriptor.exportOnly !== 'boolean') {\n problems.push(`${descriptor.key} says \"exportOnly\" with something other than true or false.`)\n }\n if (descriptor.featureFlag !== undefined && !String(descriptor.featureFlag).trim()) {\n problems.push(`${descriptor.key} names an empty plan feature.`)\n }\n if (descriptor.importRoles !== undefined) {\n const roles = descriptor.importRoles\n if (descriptor.exportOnly === true) problems.push(`${descriptor.key} names who may import records it never imports.`)\n if (!Array.isArray(roles) || !roles.length || roles.some((role) => !TRANSFER_IMPORT_ROLES.includes(role))) {\n problems.push(`${descriptor.key} names an import role that is not ${TRANSFER_IMPORT_ROLES.join(', ')}.`)\n }\n }\n if (descriptor.featureFlagExempt !== undefined) {\n const exempt = descriptor.featureFlagExempt\n if (descriptor.featureFlag === undefined) {\n problems.push(`${descriptor.key} exempts intents from a plan feature it does not name.`)\n }\n if (!Array.isArray(exempt) || !exempt.length || exempt.some((intent) => intent !== 'import' && intent !== 'export')) {\n problems.push(`${descriptor.key} exempts something other than import or export from its plan feature.`)\n }\n }\n return problems\n}\n\n/** What separates a resource's key from the instance it names: `data.dataset:<datasetId>`. */\nexport const TRANSFER_INSTANCE_SEPARATOR = ':'\n\nconst INSTANCE_ID = /^[A-Za-z0-9_-]{1,128}$/\n\n/** Whether `instance` can be named in a key: letters, digits, `_` and `-`, at most 128. */\nexport function isTransferResourceInstance(instance: unknown): instance is string {\n return typeof instance === 'string' && INSTANCE_ID.test(instance)\n}\n\n/**\n * The key that names one instance of a resource declared with `instances`:\n * `data.dataset` and `abc123` make `data.dataset:abc123`. Throws for an\n * instance a key cannot carry, so a malformed id never becomes a job's key.\n */\nexport function transferResourceInstanceKey(key: string, instance: string): string {\n if (!isTransferResourceInstance(instance)) {\n throw new Error(`\"${String(instance)}\" cannot name an instance of ${key}.`)\n }\n return `${key}${TRANSFER_INSTANCE_SEPARATOR}${instance}`\n}\n\n/**\n * A key read as the declared resource and the instance it names, if any:\n * `data.dataset:abc123` is `{ key: 'data.dataset', instance: 'abc123' }`, and\n * `people` is `{ key: 'people', instance: null }`. A suffix that is not a\n * well-formed instance is left in `key`, which then names no declaration.\n */\nexport function parseTransferResourceKey(key: string): { key: string; instance: string | null } {\n const text = String(key ?? '').trim()\n const at = text.indexOf(TRANSFER_INSTANCE_SEPARATOR)\n if (at < 0) return { key: text, instance: null }\n const instance = text.slice(at + 1)\n return isTransferResourceInstance(instance) ? { key: text.slice(0, at), instance } : { key: text, instance: null }\n}\n\n/** The instance a hook's context names (`ctx.resource`), or `null` for a resource without instances. */\nexport function transferResourceInstanceOf(context: { resource: string }): string | null {\n return parseTransferResourceKey(context.resource).instance\n}\n\n/** What is wrong with a field list, as sentences; empty when nothing is. */\nexport function transferFieldProblems(fields: readonly TransferField[]): string[] {\n const problems: string[] = []\n const seen = new Set<string>()\n for (const field of fields) {\n const id = String(field.id ?? '')\n if (!id.trim()) {\n problems.push(`A field labeled \"${field.label}\" has no id.`)\n continue\n }\n if (seen.has(id)) problems.push(`Field \"${id}\" is declared twice.`)\n seen.add(id)\n if (!TRANSFER_FIELD_TYPES.includes(field.type)) problems.push(`Field \"${id}\" has unknown type \"${String(field.type)}\".`)\n if ((field.type === 'picklist' || field.type === 'multiPicklist') && !field.picklistId) {\n problems.push(`Field \"${id}\" is a picklist with no picklistId.`)\n }\n if ((field.type === 'lookup' || (field.type === 'list' && field.lookup)) && !field.lookup?.by?.length) {\n problems.push(`Field \"${id}\" is a lookup that names no target field.`)\n }\n if (field.lookup && field.type !== 'lookup' && field.type !== 'list') {\n problems.push(`Field \"${id}\" names a lookup target, which only a lookup or list field may.`)\n }\n if (field.required && !isTransferFieldWritable(field)) {\n problems.push(`Field \"${id}\" is required but can never be written.`)\n }\n }\n return problems\n}\n"],"names":["TRANSFER_FORMATS","TRANSFER_IMPORT_ROLES","transferResourceImports","descriptor","exportOnly","TRANSFER_FIELD_TYPES","TRANSFER_LIST_FIELD_TYPES","TRANSFER_ID_FIELD","isTransferListType","type","includes","isTransferLookupField","field","Boolean","lookup","resource","by","length","isTransferFieldWritable","readOnly","derived","system","isTransferFieldImportable","matchKey","RESOURCE_KEY","isTransferResourceKey","key","test","transferResourceProblems","problems","push","String","label","trim","scope","kinds","kind","formats","format","limits","Number","isInteger","maxRows","maxBytes","undefined","instances","readPermission","readableByMembers","featureFlag","importRoles","roles","Array","isArray","some","role","join","featureFlagExempt","exempt","intent","TRANSFER_INSTANCE_SEPARATOR","INSTANCE_ID","isTransferResourceInstance","instance","transferResourceInstanceKey","Error","parseTransferResourceKey","text","at","indexOf","slice","transferResourceInstanceOf","context","transferFieldProblems","fields","seen","Set","id","has","add","picklistId","required"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;2CAyB2C,GAE3C,yEAAyE,GASzE,OAAO,MAAMA,mBAA8C;IAAC;IAAO;IAAQ;CAAS,CAAA;AAsFpF,uDAAuD,GACvD,OAAO,MAAMC,wBAAuD;IAAC;IAAS;IAAU;IAAU;CAAS,CAAA;AAE3G,sDAAsD,GACtD,OAAO,SAASC,wBAAwBC,UAA0D;IAChG,OAAOA,WAAWC,UAAU,KAAK;AACnC;AAwBA,OAAO,MAAMC,uBAAqD;IAChE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMC,4BAA0D;IAAC;IAAiB;IAAQ;CAAO,CAAA;AAiDxG,gEAAgE,GAChE,OAAO,MAAMC,oBAAoB,KAAI;AAErC,wCAAwC,GACxC,OAAO,SAASC,mBAAmBC,IAAuB;IACxD,OAAOH,0BAA0BI,QAAQ,CAACD;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASE,sBACdC,KAAuC;QAKnCA,eACAA;IAJJ,OAAOC,QACLD,SACGA,CAAAA,MAAMH,IAAI,KAAK,YAAYG,MAAMH,IAAI,KAAK,MAAK,OAChDG,gBAAAA,MAAME,MAAM,qBAAZF,cAAcG,QAAQ,OACtBH,mBAAAA,MAAME,MAAM,CAACE,EAAE,qBAAfJ,iBAAiBK,MAAM;AAE7B;AAEA,qDAAqD,GACrD,OAAO,SAASC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MAAMoE,QAAQ,IAAI,CAAC9D,wBAAwBN,QAAQ;YACrDiB,SAASC,IAAI,CAAC,CAAC,OAAO,EAAE8C,GAAG,uCAAuC,CAAC;QACrE;IACF;IACA,OAAO/C;AACT"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/resource.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\n/*==========================================\n * TRANSFER RESOURCES — what can be imported or exported, and its fields.\n *\n * A resource is one kind of thing a person moves in or out of Aglyn: a\n * collection of records (rows in a file) or a set of site items (a\n * package). The plugin that owns the thing declares it; this module only\n * says what a declaration looks like and what a field may be, so every\n * importer, exporter and wizard reads the same shape.\n *\n * ## A field says what it is, not how it is stored\n *\n * `type` is the field's meaning to a person — an email, a currency amount,\n * a picklist — which is what decides how a cell is read (`derive.ts`), how\n * a header is guessed (`header-match.ts`) and which policies make sense\n * (`policy.ts`: only a list can be appended to). Where the value lives in\n * storage is the owning plugin's business.\n *\n * ## Read-only, derived and system fields export but never import\n *\n * A derived field (a score, a count) is computed from others; a system\n * field (the Aglyn id, created/updated times) is written by the platform.\n * Both are offered on export because a person wants them in the file, and\n * neither is ever written from a file. A `matchKey` field — the Aglyn id\n * above all — may still be MAPPED on import, because it identifies which\n * existing record a row is about; it is read, never written.\n *=========================================*/\n\n/** Where the records of a resource live: the organization, or one site. */\nexport type TransferScope = 'org' | 'host'\n\n/** Rows in a file, or a set of site items carried as a package. */\nexport type TransferKind = 'records' | 'package'\n\n/** The file formats a resource can be read from and written to. */\nexport type TransferFormat = 'csv' | 'json' | 'ndjson'\n\nexport const TRANSFER_FORMATS: readonly TransferFormat[] = ['csv', 'json', 'ndjson']\n\n/** The bounds one transfer of a resource is held to. */\nexport interface TransferLimits {\n /** The most rows (or items) one file may carry. */\n maxRows: number\n /** The most bytes one uploaded file may carry, when the resource bounds it. */\n maxBytes?: number\n}\n\n/** One resource as its owning plugin declares it. */\nexport interface TransferResourceDescriptor {\n /** Stable key, lowercase words joined by `-` or `.` — the URL and storage name. */\n key: string\n /** What a person calls one batch of it (\"People\", \"Pages\"). */\n label: string\n /** One record (\"Person\", \"Page\"); defaults to `label`. */\n singularLabel?: string\n scope: TransferScope\n kinds: readonly TransferKind[]\n formats: readonly TransferFormat[]\n limits?: TransferLimits\n /** One sentence on what moves, shown on the hub. */\n description?: string\n /**\n * The resource is moved one instance at a time — one dataset's records, not\n * every dataset's — so every key that reaches it names the instance as\n * `<key>:<instance>` ({@link transferResourceInstanceKey}). A job, a\n * person's remembered choices and the one-running-import rule are then kept\n * per instance, and the plugin's hooks read which one from the context's\n * `resource` ({@link transferResourceInstanceOf}).\n */\n instances?: boolean\n /**\n * Any member may EXPORT the records (and open the export dialog), as far\n * as their scope lets them see them — a collaborator only on a site they\n * reach — because the rules let every member read them (a dataset's\n * records). See `data-transfer/access.ts`.\n */\n readableByMembers?: boolean\n /**\n * The permission that admits a member to EXPORT the records, beside\n * `data.manage`, which always does. A resource that declares neither this\n * nor `readableByMembers` exports for `data.manage` alone. Importing needs\n * `data.manage` either way.\n */\n readPermission?: string\n /**\n * `readPermission` alone decides an export (AGL-4047): `data.manage` does\n * not also admit, so taking the permission away from someone who may write\n * the records stops the export too. Needs `readPermission`.\n */\n readPermissionOnly?: boolean\n /**\n * The resource is exported and never imported — a record of work done (a\n * CRM's logged activities) or a setup edited on its own page. The upload\n * refuses it, its plugin registers no `apply` or `revert`, and a surface\n * offers only Export (AGL-3528).\n */\n exportOnly?: boolean\n /**\n * The plan feature (an `OrgFeatureFlags` key, `crm`) a workspace's plan\n * must carry to move these records — the flag the owning plugin's console\n * surfaces are gated by. Without it every route of every intent refuses\n * with 403 `plan_required` and the feature as `code`, staff included, and\n * the console offers neither button (AGL-3555). See `data-transfer/access.ts`.\n */\n featureFlag?: string\n /**\n * The intents that stay open on every plan despite `featureFlag` — an\n * obligation rather than a feature: the CRM's people files are exported\n * on Free, because taking out the people a workspace holds is every\n * plan's right, while importing them is the CRM.\n */\n featureFlagExempt?: readonly ('import' | 'export')[]\n /**\n * A catalog key a member must also hold to IMPORT the records, where the\n * records are, on top of `data.manage`, for a resource stricter than that\n * permission: gift cards, which an import issues as spendable money, ask\n * \"Import gift cards\" (AGL-4047). The transfer gate refuses anyone else on\n * every import step, the console's `can('import')` answers `false` for\n * them, and the hub offers them no Import. See `data-transfer/access.ts`.\n */\n importPermission?: string\n}\n\n/** Whether a file may be imported into the resource. */\nexport function transferResourceImports(descriptor: Pick<TransferResourceDescriptor, 'exportOnly'>): boolean {\n return descriptor.exportOnly !== true\n}\n\n/** What a field means, which decides how a cell is read and written. */\nexport type TransferFieldType =\n | 'text'\n | 'longText'\n | 'email'\n | 'phone'\n | 'url'\n | 'number'\n | 'integer'\n | 'currency'\n | 'percent'\n | 'boolean'\n | 'date'\n | 'datetime'\n | 'picklist'\n | 'multiPicklist'\n | 'tags'\n | 'address'\n | 'lookup'\n | 'json'\n | 'list'\n\nexport const TRANSFER_FIELD_TYPES: readonly TransferFieldType[] = [\n 'text',\n 'longText',\n 'email',\n 'phone',\n 'url',\n 'number',\n 'integer',\n 'currency',\n 'percent',\n 'boolean',\n 'date',\n 'datetime',\n 'picklist',\n 'multiPicklist',\n 'tags',\n 'address',\n 'lookup',\n 'json',\n 'list',\n]\n\n/**\n * The types whose value is a list, and so the only ones a file can append to:\n * picklist values, tags (kept lower-case), and a `list` of free text items\n * kept as typed.\n */\nexport const TRANSFER_LIST_FIELD_TYPES: readonly TransferFieldType[] = ['multiPicklist', 'tags', 'list']\n\n/**\n * What a lookup field points at: another resource, found by one of its\n * match keys (a company by domain, an owner by email). A `lookup` field\n * holds one record; a `list` field that names a target holds several, each\n * item resolved on its own (a dataset's multi-reference).\n */\nexport interface TransferLookupTarget {\n /** The resource key of the target. */\n resource: string\n /** The target's field ids a cell may name it by, in the order they are tried. */\n by: readonly string[]\n /** Whether an unresolved value may be offered \"create it\" in the wizard. */\n creatable?: boolean\n}\n\n/** One field of a resource. */\nexport interface TransferField {\n /** Stable id; a custom field's id is `custom:<key>`. */\n id: string\n label: string\n /** The group id the field is listed under in a picker. */\n group?: string\n type: TransferFieldType\n /** A new record cannot be created without it. */\n required?: boolean\n /** Exported, never written from a file. */\n readOnly?: boolean\n /** Computed from other fields; exported, never written from a file. */\n derived?: boolean\n /** Written by the platform (id, created, updated); exported, never written. */\n system?: boolean\n /** Defined by the organization rather than the resource. */\n custom?: boolean\n /** May be mapped on import to identify an existing record even when it is never written. */\n matchKey?: boolean\n /** Header spellings that mean this field, beside its label and id. */\n aliases?: readonly string[]\n /** The picklist whose values a `picklist` or `multiPicklist` field holds. */\n picklistId?: string\n /** What a `lookup` field resolves to. */\n lookup?: TransferLookupTarget\n /** The longest text the field stores. */\n maxLength?: number\n /** One sentence shown beside the field in a picker. */\n description?: string\n}\n\n/** The field id every resource uses for the record's Aglyn id. */\nexport const TRANSFER_ID_FIELD = 'id'\n\n/** Whether values of `type` are lists. */\nexport function isTransferListType(type: TransferFieldType): boolean {\n return TRANSFER_LIST_FIELD_TYPES.includes(type)\n}\n\n/**\n * Whether `field` names records of a target — a `lookup` field, or a `list`\n * field whose items do — so the job engine resolves its values to ids.\n */\nexport function isTransferLookupField(\n field: TransferField | null | undefined,\n): field is TransferField & { lookup: TransferLookupTarget } {\n return Boolean(\n field &&\n (field.type === 'lookup' || field.type === 'list') &&\n field.lookup?.resource &&\n field.lookup.by?.length,\n )\n}\n\n/** Whether a file's cell may be WRITTEN to `field`. */\nexport function isTransferFieldWritable(field: TransferField): boolean {\n return !field.readOnly && !field.derived && !field.system\n}\n\n/** Whether a file's column may be MAPPED to `field` on import — written, or read to match. */\nexport function isTransferFieldImportable(field: TransferField): boolean {\n return isTransferFieldWritable(field) || Boolean(field.matchKey)\n}\n\nconst RESOURCE_KEY = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/\n\n/** Whether `key` is a well-formed resource key. */\nexport function isTransferResourceKey(key: unknown): key is string {\n return typeof key === 'string' && key.length <= 64 && RESOURCE_KEY.test(key)\n}\n\n/**\n * What is wrong with a declaration, as sentences; empty when nothing is.\n * Checked when a plugin registers, so a malformed one fails loudly at\n * startup rather than in a person's wizard.\n */\nexport function transferResourceProblems(descriptor: TransferResourceDescriptor): string[] {\n const problems: string[] = []\n if (!isTransferResourceKey(descriptor.key)) {\n problems.push(`\"${String(descriptor.key)}\" is not a resource key (lowercase words joined by - or .).`)\n }\n if (!String(descriptor.label ?? '').trim()) problems.push(`${descriptor.key} has no label.`)\n if (descriptor.scope !== 'org' && descriptor.scope !== 'host') {\n problems.push(`${descriptor.key} has scope \"${String(descriptor.scope)}\"; it must be org or host.`)\n }\n if (!descriptor.kinds?.length) problems.push(`${descriptor.key} declares no kind.`)\n for (const kind of descriptor.kinds ?? []) {\n if (kind !== 'records' && kind !== 'package') problems.push(`${descriptor.key} has unknown kind \"${String(kind)}\".`)\n }\n if (!descriptor.formats?.length) problems.push(`${descriptor.key} declares no format.`)\n for (const format of descriptor.formats ?? []) {\n if (!TRANSFER_FORMATS.includes(format)) problems.push(`${descriptor.key} has unknown format \"${String(format)}\".`)\n }\n const limits = descriptor.limits\n if (limits && !(Number.isInteger(limits.maxRows) && limits.maxRows > 0)) {\n problems.push(`${descriptor.key} has a row limit that is not a positive whole number.`)\n }\n if (limits?.maxBytes !== undefined && !(Number.isInteger(limits.maxBytes) && limits.maxBytes > 0)) {\n problems.push(`${descriptor.key} has a byte limit that is not a positive whole number.`)\n }\n if (descriptor.instances !== undefined && typeof descriptor.instances !== 'boolean') {\n problems.push(`${descriptor.key} says \"instances\" with something other than true or false.`)\n }\n if (descriptor.readPermission !== undefined && !String(descriptor.readPermission).trim()) {\n problems.push(`${descriptor.key} names an empty read permission.`)\n }\n if (descriptor.readableByMembers !== undefined && typeof descriptor.readableByMembers !== 'boolean') {\n problems.push(`${descriptor.key} says \"readableByMembers\" with something other than true or false.`)\n }\n if (descriptor.readableByMembers === true && descriptor.readPermission !== undefined) {\n problems.push(`${descriptor.key} is readable by every member and names a read permission; say one.`)\n }\n if (descriptor.readPermissionOnly !== undefined && typeof descriptor.readPermissionOnly !== 'boolean') {\n problems.push(`${descriptor.key} says \"readPermissionOnly\" with something other than true or false.`)\n }\n if (descriptor.readPermissionOnly === true && descriptor.readPermission === undefined) {\n problems.push(`${descriptor.key} says \"readPermissionOnly\" and names no read permission.`)\n }\n if (descriptor.exportOnly !== undefined && typeof descriptor.exportOnly !== 'boolean') {\n problems.push(`${descriptor.key} says \"exportOnly\" with something other than true or false.`)\n }\n if (descriptor.featureFlag !== undefined && !String(descriptor.featureFlag).trim()) {\n problems.push(`${descriptor.key} names an empty plan feature.`)\n }\n if (descriptor.importPermission !== undefined) {\n if (descriptor.exportOnly === true) problems.push(`${descriptor.key} names who may import records it never imports.`)\n if (typeof descriptor.importPermission !== 'string' || !descriptor.importPermission.trim()) {\n problems.push(`${descriptor.key} names an empty import permission.`)\n }\n }\n if (descriptor.featureFlagExempt !== undefined) {\n const exempt = descriptor.featureFlagExempt\n if (descriptor.featureFlag === undefined) {\n problems.push(`${descriptor.key} exempts intents from a plan feature it does not name.`)\n }\n if (!Array.isArray(exempt) || !exempt.length || exempt.some((intent) => intent !== 'import' && intent !== 'export')) {\n problems.push(`${descriptor.key} exempts something other than import or export from its plan feature.`)\n }\n }\n return problems\n}\n\n/** What separates a resource's key from the instance it names: `data.dataset:<datasetId>`. */\nexport const TRANSFER_INSTANCE_SEPARATOR = ':'\n\nconst INSTANCE_ID = /^[A-Za-z0-9_-]{1,128}$/\n\n/** Whether `instance` can be named in a key: letters, digits, `_` and `-`, at most 128. */\nexport function isTransferResourceInstance(instance: unknown): instance is string {\n return typeof instance === 'string' && INSTANCE_ID.test(instance)\n}\n\n/**\n * The key that names one instance of a resource declared with `instances`:\n * `data.dataset` and `abc123` make `data.dataset:abc123`. Throws for an\n * instance a key cannot carry, so a malformed id never becomes a job's key.\n */\nexport function transferResourceInstanceKey(key: string, instance: string): string {\n if (!isTransferResourceInstance(instance)) {\n throw new Error(`\"${String(instance)}\" cannot name an instance of ${key}.`)\n }\n return `${key}${TRANSFER_INSTANCE_SEPARATOR}${instance}`\n}\n\n/**\n * A key read as the declared resource and the instance it names, if any:\n * `data.dataset:abc123` is `{ key: 'data.dataset', instance: 'abc123' }`, and\n * `people` is `{ key: 'people', instance: null }`. A suffix that is not a\n * well-formed instance is left in `key`, which then names no declaration.\n */\nexport function parseTransferResourceKey(key: string): { key: string; instance: string | null } {\n const text = String(key ?? '').trim()\n const at = text.indexOf(TRANSFER_INSTANCE_SEPARATOR)\n if (at < 0) return { key: text, instance: null }\n const instance = text.slice(at + 1)\n return isTransferResourceInstance(instance) ? { key: text.slice(0, at), instance } : { key: text, instance: null }\n}\n\n/** The instance a hook's context names (`ctx.resource`), or `null` for a resource without instances. */\nexport function transferResourceInstanceOf(context: { resource: string }): string | null {\n return parseTransferResourceKey(context.resource).instance\n}\n\n/** What is wrong with a field list, as sentences; empty when nothing is. */\nexport function transferFieldProblems(fields: readonly TransferField[]): string[] {\n const problems: string[] = []\n const seen = new Set<string>()\n for (const field of fields) {\n const id = String(field.id ?? '')\n if (!id.trim()) {\n problems.push(`A field labeled \"${field.label}\" has no id.`)\n continue\n }\n if (seen.has(id)) problems.push(`Field \"${id}\" is declared twice.`)\n seen.add(id)\n if (!TRANSFER_FIELD_TYPES.includes(field.type)) problems.push(`Field \"${id}\" has unknown type \"${String(field.type)}\".`)\n if ((field.type === 'picklist' || field.type === 'multiPicklist') && !field.picklistId) {\n problems.push(`Field \"${id}\" is a picklist with no picklistId.`)\n }\n if ((field.type === 'lookup' || (field.type === 'list' && field.lookup)) && !field.lookup?.by?.length) {\n problems.push(`Field \"${id}\" is a lookup that names no target field.`)\n }\n if (field.lookup && field.type !== 'lookup' && field.type !== 'list') {\n problems.push(`Field \"${id}\" names a lookup target, which only a lookup or list field may.`)\n }\n if (field.required && !isTransferFieldWritable(field)) {\n problems.push(`Field \"${id}\" is required but can never be written.`)\n }\n }\n return problems\n}\n"],"names":["TRANSFER_FORMATS","transferResourceImports","descriptor","exportOnly","TRANSFER_FIELD_TYPES","TRANSFER_LIST_FIELD_TYPES","TRANSFER_ID_FIELD","isTransferListType","type","includes","isTransferLookupField","field","Boolean","lookup","resource","by","length","isTransferFieldWritable","readOnly","derived","system","isTransferFieldImportable","matchKey","RESOURCE_KEY","isTransferResourceKey","key","test","transferResourceProblems","problems","push","String","label","trim","scope","kinds","kind","formats","format","limits","Number","isInteger","maxRows","maxBytes","undefined","instances","readPermission","readableByMembers","readPermissionOnly","featureFlag","importPermission","featureFlagExempt","exempt","Array","isArray","some","intent","TRANSFER_INSTANCE_SEPARATOR","INSTANCE_ID","isTransferResourceInstance","instance","transferResourceInstanceKey","Error","parseTransferResourceKey","text","at","indexOf","slice","transferResourceInstanceOf","context","transferFieldProblems","fields","seen","Set","id","has","add","picklistId","required"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;2CAyB2C,GAE3C,yEAAyE,GASzE,OAAO,MAAMA,mBAA8C;IAAC;IAAO;IAAQ;CAAS,CAAA;AAsFpF,sDAAsD,GACtD,OAAO,SAASC,wBAAwBC,UAA0D;IAChG,OAAOA,WAAWC,UAAU,KAAK;AACnC;AAwBA,OAAO,MAAMC,uBAAqD;IAChE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMC,4BAA0D;IAAC;IAAiB;IAAQ;CAAO,CAAA;AAiDxG,gEAAgE,GA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AACG,CAAAA,MAAMH,IAAI,KAAK,cAAcG,MAAMH,IAAI,KAAK,eAAc,KAAM,CAACG,MAAMiE,UAAU,EAAE;YACtFhD,SAASC,IAAI,CAAC,CAAC,OAAO,EAAE4C,GAAG,mCAAmC,CAAC;QACjE;QACA,IAAI,AAAC9D,CAAAA,MAAMH,IAAI,KAAK,YAAaG,MAAMH,IAAI,KAAK,UAAUG,MAAME,MAAM,KAAM,GAACF,gBAAAA,MAAME,MAAM,sBAAZF,mBAAAA,cAAcI,EAAE,qBAAhBJ,iBAAkBK,MAAM,GAAE;YACrGY,SAASC,IAAI,CAAC,CAAC,OAAO,EAAE4C,GAAG,yCAAyC,CAAC;QACvE;QACA,IAAI9D,MAAME,MAAM,IAAIF,MAAMH,IAAI,KAAK,YAAYG,MAAMH,IAAI,KAAK,QAAQ;YACpEoB,SAASC,IAAI,CAAC,CAAC,OAAO,EAAE4C,GAAG,+DAA+D,CAAC;QAC7F;QACA,IAAI9D,MAAMkE,QAAQ,IAAI,CAAC5D,wBAAwBN,QAAQ;YACrDiB,SAASC,IAAI,CAAC,CAAC,OAAO,EAAE4C,GAAG,uCAAuC,CAAC;QACrE;IACF;IACA,OAAO7C;AACT"}
@@ -1419,9 +1419,7 @@ export const PUBLISHED_SITE_IMPACT = {
1419
1419
  "featureFlagExempt": [
1420
1420
  "export"
1421
1421
  ],
1422
- "importRoles": [
1423
- "admin"
1424
- ],
1422
+ "importPermission": "commerce.giftCards.import",
1425
1423
  "label": "Gift cards",
1426
1424
  "singularLabel": "Gift card",
1427
1425
  "scope": "host",
@@ -1690,7 +1688,8 @@ export const PUBLISHED_SITE_IMPACT = {
1690
1688
  "maxRows": 50000
1691
1689
  },
1692
1690
  "instances": true,
1693
- "readableByMembers": true
1691
+ "readPermission": "data.export",
1692
+ "readPermissionOnly": true
1694
1693
  },
1695
1694
  {
1696
1695
  "pluginId": "email",