@aglyn/plugins-marketplace 1.20.1 → 1.20.3

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 (35) hide show
  1. package/package.json +15 -15
  2. package/src/lib/components/listing-content.component.d.ts +8 -1
  3. package/src/lib/components/listing-content.component.js +52 -12
  4. package/src/lib/components/listing-content.component.js.map +1 -1
  5. package/src/lib/components/listing-detail-page.component.d.ts +6 -0
  6. package/src/lib/components/listing-detail-page.component.js +24 -4
  7. package/src/lib/components/listing-detail-page.component.js.map +1 -1
  8. package/src/lib/components/marketplace-hub.component.js +2 -0
  9. package/src/lib/components/marketplace-hub.component.js.map +1 -1
  10. package/src/lib/components/org-plugin-installs-card.component.js +67 -9
  11. package/src/lib/components/org-plugin-installs-card.component.js.map +1 -1
  12. package/src/lib/components/org-seller-panel.component.js +14 -4
  13. package/src/lib/components/org-seller-panel.component.js.map +1 -1
  14. package/src/lib/components/plugin-reviews-surface.component.js +17 -6
  15. package/src/lib/components/plugin-reviews-surface.component.js.map +1 -1
  16. package/src/lib/components/plugin-site-set-panel.component.d.ts +11 -0
  17. package/src/lib/components/plugin-site-set-panel.component.js +52 -9
  18. package/src/lib/components/plugin-site-set-panel.component.js.map +1 -1
  19. package/src/lib/hooks/use-starter-publish-facts.js +5 -1
  20. package/src/lib/hooks/use-starter-publish-facts.js.map +1 -1
  21. package/src/lib/model/editor-connections.js +2 -1
  22. package/src/lib/model/editor-connections.js.map +1 -1
  23. package/src/lib/model/marketplace-catalog.d.ts +40 -1
  24. package/src/lib/model/marketplace-catalog.js +46 -2
  25. package/src/lib/model/marketplace-catalog.js.map +1 -1
  26. package/src/lib/model/marketplace.d.ts +1 -1
  27. package/src/lib/model/marketplace.js +1 -1
  28. package/src/lib/model/marketplace.js.map +1 -1
  29. package/src/lib/model/starter-publish.d.ts +12 -5
  30. package/src/lib/model/starter-publish.js +18 -6
  31. package/src/lib/model/starter-publish.js.map +1 -1
  32. package/src/lib/server/connect.js +45 -13
  33. package/src/lib/server/connect.js.map +1 -1
  34. package/src/lib/server/starter-publish-facts.js +4 -0
  35. package/src/lib/server/starter-publish-facts.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/plugin-site-set-panel.component.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'use client'\n\nimport { Typography } from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreDoc,\n useHostOrgId,\n} from '@aglyn/tenant-feature-instance'\nimport { offeredPluginVersion } from '@aglyn/aglyn'\nimport { resolveOrgInstallSummary, type OrgInstallHost } from '../model/marketplace'\nimport { useMarketplaceActions } from '../hooks/use-marketplace-actions'\nimport PluginSiteSet from './plugin-site-set.component'\n\nexport interface PluginSiteSetPanelProps {\n /** Acting site — org pins still resolve their org through one. */\n hostId: string\n listingId: string\n /**\n * Every site, with its own `disabledPlugins` when the page has it\n * (AGL-4047): a site that switched this listing off is pinned but does not\n * run it, and the panel says so instead of listing it as running.\n */\n hosts?: ReadonlyArray<OrgInstallHost>\n}\n\n/**\n * The `pluginSiteSet` slot (AGL-1007): the site-set control as something the\n * console can drop onto the installation detail page without importing this\n * plugin.\n *\n * It reads its own pins rather than taking them as props, because the page\n * that hosts it has no other use for them — unlike the listing page, which\n * also gates its pre-install picker and primary button on the same state and\n * therefore keeps ownership of it there.\n */\nexport function PluginSiteSetPanel(props: PluginSiteSetPanelProps) {\n const { hostId, listingId, hosts } = props\n const firestore = useFirestore()\n const orgId = useHostOrgId(hostId)\n const { installPlan, uninstall } = useMarketplaceActions(hostId)\n\n // Held at null while `useHostOrgId` is in flight, never `orgs/-pending-`\n // (AGL-1440): installs are member-gated, so the sentinel was a\n // guaranteed-denied listen on every mount of this panel.\n const { data: orgPin } = useFirestoreDoc<any>(\n () =>\n orgId && listingId\n ? doc(firestore, 'orgs', orgId, 'installs', listingId)\n : null,\n [firestore, orgId, listingId],\n )\n const [sitePins, setSitePins] = useState<Record<string, any>>({})\n const [pinsNonce, setPinsNonce] = useState(0)\n const hostIdsKey = (hosts ?? []).map((host) => host.id).join('|')\n useEffect(() => {\n if (!listingId || !hosts?.length) return\n let active = true\n void Promise.all(\n hosts.map(async (host) => {\n const snapshot = await getDoc(\n doc(firestore, 'hosts', host.id, 'installs', listingId),\n )\n return [host.id, snapshot.exists() ? snapshot.data() : null] as const\n }),\n )\n .then((entries) => {\n if (active) setSitePins(Object.fromEntries(entries))\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [firestore, listingId, hostIdsKey, pinsNonce])\n\n // The listing, for the version actually on offer (AGL-1017). This used to\n // pass a PIN's own version as `latestVersion`, which is by definition the\n // version that pin is already at — so no site ever looked stale and the\n // update control never appeared on this page at all.\n const { data: listing } = useFirestoreDoc<any>(\n () => doc(firestore, 'marketplaceListings', listingId || '-missing-'),\n [firestore, listingId],\n )\n\n // The kill switch (AGL-2368). This panel offers an UPDATE, so it is asking\n // \"what installs today\" and had only the review-verdict mirror to ask —\n // which nothing cleared on revoke, so it offered a version the install\n // route refuses. Listing-scoped and public, one read for the panel.\n const { data: revocation } = useFirestoreDoc<any>(\n () =>\n listingId ? doc(firestore, 'revocations', listingId) : null,\n [firestore, listingId],\n )\n\n const orgInstall = useMemo(\n () =>\n resolveOrgInstallSummary(hosts ?? [], sitePins, orgPin ?? null, listingId),\n [hosts, sitePins, orgPin, listingId],\n )\n // The listing doc the actions need. The pin carries the denormalised copy\n // the actions actually read (`$id`, `displayName`, `pluginId`), so this page\n // does not pay for a second read of the listing itself. `pluginId` is what\n // the uninstall dialog scans published pages by; without it the impact is\n // unknown and every uninstall asks for the typed acknowledgement.\n const anyPin = orgPin ?? Object.values(sitePins).find(Boolean) ?? null\n const actionListing = useMemo(\n () => ({\n $id: listingId,\n displayName: listing?.displayName ?? anyPin?.displayName ?? listingId,\n artifactType: 'plugin',\n latestVersion: listing?.latestVersion ?? anyPin?.version,\n pluginId: listing?.pluginId ?? anyPin?.pluginId,\n }),\n [\n listingId,\n listing?.displayName,\n listing?.latestVersion,\n listing?.pluginId,\n anyPin?.displayName,\n anyPin?.version,\n anyPin?.pluginId,\n ],\n )\n\n if (!orgInstall.installedAnywhere) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Not installed on any site in this organization.'}\n </Typography>\n )\n }\n\n return (\n <PluginSiteSet\n listing={actionListing}\n hosts={hosts ?? []}\n orgInstall={orgInstall}\n // The newest INSTALLABLE version (AGL-1016/2368) — never `latestVersion`,\n // and never the review verdict alone, or the page offers an update the\n // install route refuses.\n latestVersion={offeredPluginVersion(listing, revocation) ?? undefined}\n installPlan={installPlan}\n uninstall={uninstall}\n onChanged={() => setPinsNonce((current) => current + 1)}\n />\n )\n}\n\nPluginSiteSetPanel.displayName = 'PluginSiteSetPanel'\n\nexport default PluginSiteSetPanel\n"],"names":["Typography","doc","getDoc","useEffect","useMemo","useState","useFirestore","useFirestoreDoc","useHostOrgId","offeredPluginVersion","resolveOrgInstallSummary","useMarketplaceActions","PluginSiteSet","PluginSiteSetPanel","props","orgPin","hostId","listingId","hosts","firestore","orgId","installPlan","uninstall","data","sitePins","setSitePins","pinsNonce","setPinsNonce","hostIdsKey","map","host","id","join","length","active","Promise","all","snapshot","exists","then","entries","Object","fromEntries","catch","undefined","listing","revocation","orgInstall","anyPin","values","find","Boolean","actionListing","$id","displayName","artifactType","latestVersion","version","pluginId","installedAnywhere","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a,oBAAIR,0BAAAA,OAAQS,OAAO;YACxDC,QAAQ,WAAEb,2BAAAA,QAASa,QAAQ,oBAAIV,0BAAAA,OAAQU,QAAQ;QACjD;OACA;QACEzC;QACA4B,2BAAAA,QAASS,WAAW;QACpBT,2BAAAA,QAASW,aAAa;QACtBX,2BAAAA,QAASa,QAAQ;QACjBV,0BAAAA,OAAQM,WAAW;QACnBN,0BAAAA,OAAQS,OAAO;QACfT,0BAAAA,OAAQU,QAAQ;KACjB;IAGH,IAAI,CAACX,WAAWY,iBAAiB,EAAE;QACjC,qBACE,KAAC3D;YAAW4D,SAAQ;YAAQC,OAAM;sBAC/B;;IAGP;IAEA,qBACE,KAACjD;QACCiC,SAASO;QACTlC,KAAK,EAAEA,gBAAAA,QAAS,EAAE;QAClB6B,YAAYA;QACZ,0EAA0E;QAC1E,uEAAuE;QACvE,yBAAyB;QACzBS,aAAa,GAAE/C,wBAAAA,qBAAqBoC,SAASC,uBAA9BrC,wBAA6CmC;QAC5DvB,aAAaA;QACbC,WAAWA;QACXwC,WAAW,IAAMnC,aAAa,CAACoC,UAAYA,UAAU;;AAG3D;AAEAlD,mBAAmByC,WAAW,GAAG;AAEjC,eAAezC,mBAAkB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/plugin-site-set-panel.component.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'use client'\n\nimport { Alert, CircularProgress, Stack, Typography } from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n useFirestore,\n useFirestoreDoc,\n useHostOrgIdState,\n} from '@aglyn/tenant-feature-instance'\nimport { offeredPluginVersion } from '@aglyn/aglyn'\nimport {\n installPictureReadPhase,\n resolveOrgInstallSummary,\n type OrgInstallHost,\n} from '../model/marketplace'\nimport { useMarketplaceActions } from '../hooks/use-marketplace-actions'\nimport PluginSiteSet from './plugin-site-set.component'\n\nexport interface PluginSiteSetPanelProps {\n /** Acting site — org pins still resolve their org through one. */\n hostId: string\n listingId: string\n /**\n * Every site, with its own `disabledPlugins` when the page has it\n * (AGL-4047): a site that switched this listing off is pinned but does not\n * run it, and the panel says so instead of listing it as running.\n */\n hosts?: ReadonlyArray<OrgInstallHost>\n /**\n * Whether `hosts` is the whole site list yet (AGL-4047). Absent reads as\n * true, for a caller that only mounts this once its sites are known.\n */\n hostsReady?: boolean\n /**\n * The workspace, when the page knows it (AGL-4047). Read through the\n * acting site otherwise, and that lookup is a one-shot read that settles\n * to \"no org\" when it fails, after which no org pin is ever read.\n */\n orgId?: string\n}\n\n/**\n * The `pluginSiteSet` slot (AGL-1007): the site-set control as something the\n * console can drop onto the installation detail page without importing this\n * plugin.\n *\n * It reads its own pins rather than taking them as props, because the page\n * that hosts it has no other use for them — unlike the listing page, which\n * also gates its pre-install picker and primary button on the same state and\n * therefore keeps ownership of it there.\n */\nexport function PluginSiteSetPanel(props: PluginSiteSetPanelProps) {\n const { hostId, listingId, hosts, hostsReady = true } = props\n const firestore = useFirestore()\n const hostOrg = useHostOrgIdState(props.orgId ? undefined : hostId)\n const orgId = props.orgId || hostOrg.orgId\n const { installPlan, uninstall } = useMarketplaceActions(hostId)\n\n // Held at null while `useHostOrgId` is in flight, never `orgs/-pending-`\n // (AGL-1440): installs are member-gated, so the sentinel was a\n // guaranteed-denied listen on every mount of this panel.\n const orgPinRead = useFirestoreDoc<any>(\n () =>\n orgId && listingId\n ? doc(firestore, 'orgs', orgId, 'installs', listingId)\n : null,\n [firestore, orgId, listingId],\n )\n const orgPin = orgPinRead.data\n const [sitePins, setSitePins] = useState<Record<string, any>>({})\n const [pinsNonce, setPinsNonce] = useState(0)\n const hostIdsKey = (hosts ?? []).map((host) => host.id).join('|')\n /** The site set the pins answer for, or that reading them failed (AGL-4047). */\n const [sitePinsFor, setSitePinsFor] = useState<string | null>(null)\n const [sitePinsFailed, setSitePinsFailed] = useState(false)\n useEffect(() => {\n setSitePinsFailed(false)\n if (!listingId || !hosts?.length) return\n let active = true\n void Promise.all(\n hosts.map(async (host) => {\n const snapshot = await getDoc(\n doc(firestore, 'hosts', host.id, 'installs', listingId),\n )\n return [host.id, snapshot.exists() ? snapshot.data() : null] as const\n }),\n )\n .then((entries) => {\n if (!active) return\n setSitePins(Object.fromEntries(entries))\n setSitePinsFor(`${listingId}:${hostIdsKey}`)\n })\n .catch(() => {\n if (active) setSitePinsFailed(true)\n })\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [firestore, listingId, hostIdsKey, pinsNonce])\n\n // The listing, for the version actually on offer (AGL-1017). This used to\n // pass a PIN's own version as `latestVersion`, which is by definition the\n // version that pin is already at — so no site ever looked stale and the\n // update control never appeared on this page at all.\n const { data: listing } = useFirestoreDoc<any>(\n () => doc(firestore, 'marketplaceListings', listingId || '-missing-'),\n [firestore, listingId],\n )\n\n // The kill switch (AGL-2368). This panel offers an UPDATE, so it is asking\n // \"what installs today\" and had only the review-verdict mirror to ask —\n // which nothing cleared on revoke, so it offered a version the install\n // route refuses. Listing-scoped and public, one read for the panel.\n const { data: revocation } = useFirestoreDoc<any>(\n () =>\n listingId ? doc(firestore, 'revocations', listingId) : null,\n [firestore, listingId],\n )\n\n const orgInstall = useMemo(\n () =>\n resolveOrgInstallSummary(hosts ?? [], sitePins, orgPin ?? null, listingId),\n [hosts, sitePins, orgPin, listingId],\n )\n // The listing doc the actions need. The pin carries the denormalised copy\n // the actions actually read (`$id`, `displayName`, `pluginId`), so this page\n // does not pay for a second read of the listing itself. `pluginId` is what\n // the uninstall dialog scans published pages by; without it the impact is\n // unknown and every uninstall asks for the typed acknowledgement.\n const anyPin = orgPin ?? Object.values(sitePins).find(Boolean) ?? null\n const actionListing = useMemo(\n () => ({\n $id: listingId,\n displayName: listing?.displayName ?? anyPin?.displayName ?? listingId,\n artifactType: 'plugin',\n latestVersion: listing?.latestVersion ?? anyPin?.version,\n pluginId: listing?.pluginId ?? anyPin?.pluginId,\n }),\n [\n listingId,\n listing?.displayName,\n listing?.latestVersion,\n listing?.pluginId,\n anyPin?.displayName,\n anyPin?.version,\n anyPin?.pluginId,\n ],\n )\n\n /*\n * Loading is said as loading (AGL-4047). \"Not installed\" rests on no pin\n * anywhere, and a pin the server has not answered for yet is not absent:\n * this page said \"Not installed on any site\" for seconds about a plugin\n * running org-wide.\n */\n const readPhase = installPictureReadPhase({\n orgPin: !listingId\n ? null\n : orgId\n ? orgPinRead\n : props.orgId || !hostOrg.loaded\n ? 'pending'\n : null,\n sitePins: sitePinsFailed\n ? 'failed'\n : !hostsReady\n ? 'loading'\n : !hosts?.length || sitePinsFor === `${listingId}:${hostIdsKey}`\n ? 'answered'\n : 'loading',\n })\n if (readPhase === 'loading') {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Loading where it is installed…'}\n </Typography>\n </Stack>\n )\n }\n if (readPhase === 'error') {\n return (\n <Alert severity=\"warning\">\n {'Could not load where this plugin is installed. Reload the page to ' +\n 'try again.'}\n </Alert>\n )\n }\n\n if (!orgInstall.installedAnywhere) {\n return (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Not installed on any site in this organization.'}\n </Typography>\n )\n }\n\n return (\n <PluginSiteSet\n listing={actionListing}\n hosts={hosts ?? []}\n orgInstall={orgInstall}\n // The newest INSTALLABLE version (AGL-1016/2368) — never `latestVersion`,\n // and never the review verdict alone, or the page offers an update the\n // install route refuses.\n latestVersion={offeredPluginVersion(listing, revocation) ?? undefined}\n installPlan={installPlan}\n uninstall={uninstall}\n onChanged={() => setPinsNonce((current) => current + 1)}\n />\n )\n}\n\nPluginSiteSetPanel.displayName = 'PluginSiteSetPanel'\n\nexport default PluginSiteSetPanel\n"],"names":["Alert","CircularProgress","Stack","Typography","doc","getDoc","useEffect","useMemo","useState","useFirestore","useFirestoreDoc","useHostOrgIdState","offeredPluginVersion","installPictureReadPhase","resolveOrgInstallSummary","useMarketplaceActions","PluginSiteSet","PluginSiteSetPanel","props","orgPin","hostId","listingId","hosts","hostsReady","firestore","hostOrg","orgId","undefined","installPlan","uninstall","orgPinRead","data","sitePins","setSitePins","pinsNonce","setPinsNonce","hostIdsKey","map","host","id","join","sitePinsFor","setSitePinsFor","sitePinsFailed","setSitePinsFailed","length","active","Promise","all","snapshot","exists","then","entries","Object","fromEntries","catch","listing","revocation","orgInstall","anyPin","values","find","Boolean","actionListing","$id","displayName","artifactType","latestVersion","version","pluginId","readPhase","loaded","direction","spacing","sx","alignItems","size","variant","color","severity","installedAnywhere","onChanged","current"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,KAAK,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAC1E,SAASC,GAAG,EAAEC,MAAM,QAAQ,qBAAoB;AAChD,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACpD,SACEC,YAAY,EACZC,eAAe,EACfC,iBAAiB,QACZ,iCAAgC;AACvC,SAASC,oBAAoB,QAAQ,eAAc;AACnD,SACEC,uBAAuB,EACvBC,wBAAwB,QAEnB,0BAAsB;AAC7B,SAASC,qBAAqB,QAAQ,sCAAkC;AACxE,OAAOC,mBAAmB,iCAA6B;AAyBvD;;;;;;;;;CASC,GACD,OAAO,SAASC,mBAAmBC,KAA8B;QA+EhDC,MA6EIP;IA3JnB,MAAM,EAAEQ,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,aAAa,IAAI,EAAE,G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AQ;QACjBV,0BAAAA,OAAQM,WAAW;QACnBN,0BAAAA,OAAQS,OAAO;QACfT,0BAAAA,OAAQU,QAAQ;KACjB;IAGH;;;;;GAKC,GACD,MAAMC,YAAYzD,wBAAwB;QACxCM,QAAQ,CAACE,YACL,OACAK,QACEI,aACAZ,MAAMQ,KAAK,IAAI,CAACD,QAAQ8C,MAAM,GAC5B,YACA;QACRvC,UAAUW,iBACN,WACA,CAACpB,aACC,YACA,EAACD,yBAAAA,MAAOuB,MAAM,KAAIJ,gBAAgB,GAAGpB,UAAU,CAAC,EAAEe,YAAY,GAC5D,aACA;IACV;IACA,IAAIkC,cAAc,WAAW;QAC3B,qBACE,MAACpE;YAAMsE,WAAU;YAAMC,SAAS;YAAGC,IAAI;gBAAEC,YAAY;YAAS;;8BAC5D,KAAC1E;oBAAiB2E,MAAM;;8BACxB,KAACzE;oBAAW0E,SAAQ;oBAAQC,OAAM;8BAC/B;;;;IAIT;IACA,IAAIR,cAAc,SAAS;QACzB,qBACE,KAACtE;YAAM+E,UAAS;sBACb,uEACC;;IAGR;IAEA,IAAI,CAACrB,WAAWsB,iBAAiB,EAAE;QACjC,qBACE,KAAC7E;YAAW0E,SAAQ;YAAQC,OAAM;sBAC/B;;IAGP;IAEA,qBACE,KAAC9D;QACCwC,SAASO;QACTzC,KAAK,EAAEA,gBAAAA,QAAS,EAAE;QAClBoC,YAAYA;QACZ,0EAA0E;QAC1E,uEAAuE;QACvE,yBAAyB;QACzBS,aAAa,GAAEvD,wBAAAA,qBAAqB4C,SAASC,uBAA9B7C,wBAA6Ce;QAC5DC,aAAaA;QACbC,WAAWA;QACXoD,WAAW,IAAM9C,aAAa,CAAC+C,UAAYA,UAAU;;AAG3D;AAEAjE,mBAAmBgD,WAAW,GAAG;AAEjC,eAAehD,mBAAkB"}
@@ -18,6 +18,7 @@ import { buildRoute, Route } from "@aglyn/aglyn/app-utils/console-routes";
18
18
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
19
19
  import { SITE_STARTER_MAX_SCREENS } from "@aglyn/aglyn/app-utils/site-starter";
20
20
  import { siteStarterBuiltinThemeOf } from "@aglyn/aglyn/app-utils/site-starter-theme";
21
+ import { merchantPaymentsPlatformMode } from "@aglyn/tenant-feature-instance/hooks/merchant-payments-state";
21
22
  import { useConsoleHostRoute, useFirestore, useFirestoreCollection, useFirestoreDoc, usePlanFeature, useUser } from "@aglyn/tenant-feature-instance";
22
23
  import { collection, doc, documentId, query, where } from "firebase/firestore";
23
24
  import { useEffect, useMemo, useState } from "react";
@@ -61,7 +62,8 @@ import { payoutsReady, starterPublishPages } from "../model/starter-publish.js";
61
62
  // has nothing the answer could change, and nearly every publisher does.
62
63
  const { data: user } = useUser();
63
64
  const [sellsAsPlatform, setSellsAsPlatform] = useState(false);
64
- const needsStanding = Boolean(profile.data && !payoutsReady(profile.data));
65
+ const platformMode = merchantPaymentsPlatformMode();
66
+ const needsStanding = Boolean(profile.data && !payoutsReady(profile.data, platformMode));
65
67
  useEffect(()=>{
66
68
  if (!needsStanding || !orgId || !user) return;
67
69
  let current = true;
@@ -87,6 +89,7 @@ import { payoutsReady, starterPublishPages } from "../model/starter-publish.js";
87
89
  plan,
88
90
  profile: profile.status === 'success' ? (_profile_data = profile.data) != null ? _profile_data : null : undefined,
89
91
  sellsAsPlatform,
92
+ platformMode,
90
93
  pages: pagesReady ? starterPublishPages(routing, screens.data) : null,
91
94
  marketplacePath: route.orgSlug ? orgMarketplacePath(route.orgSlug) : null,
92
95
  pagesPath: route.orgSlug && route.subdomain ? buildRoute(Route.HOST_SCREENS, {
@@ -102,6 +105,7 @@ import { payoutsReady, starterPublishPages } from "../model/starter-publish.js";
102
105
  profile.status,
103
106
  profile.data,
104
107
  sellsAsPlatform,
108
+ platformMode,
105
109
  pagesReady,
106
110
  routing,
107
111
  screens.data,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/hooks/use-starter-publish-facts.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'use client'\n\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { SITE_STARTER_MAX_SCREENS } from '@aglyn/aglyn/app-utils/site-starter'\nimport {\n siteStarterBuiltinThemeOf,\n type SiteStarterBuiltinReading,\n} from '@aglyn/aglyn/app-utils/site-starter-theme'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n usePlanFeature,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport { collection, doc, documentId, query, where } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport { orgMarketplacePath } from '../model/marketplace-paths'\nimport {\n payoutsReady,\n starterPublishPages,\n type StarterPublishFacts,\n type StarterPublishScreen,\n} from '../model/starter-publish'\n\n/** Everything \"Publish as a starter\" reads before the click. */\nexport interface StarterPublishFactsState {\n /** The reads; the form adds the price it holds. */\n facts: Omit<StarterPublishFacts, 'priceUsd'>\n /** The site's built-in theme as a starter would carry it, or `null` when it wears none. */\n builtin: SiteStarterBuiltinReading | null\n /** The host document has arrived, so `builtin` is an answer rather than a wait. */\n hostReady: boolean\n}\n\n/**\n * What a starter publish of one site would capture and what stands in its\n * way (AGL-4049): the host (its theme and routing), the routed pages it\n * would take, the publishing org's profile, and its plan.\n *\n * The routed pages are read by id, at most one past the most a starter may\n * have, the same window the door walks: enough to count them and to say a\n * site is past the limit, never the whole screens collection.\n */\nexport function useStarterPublishFacts(input: {\n hostId: string | null | undefined\n orgId: string | null | undefined\n}): StarterPublishFactsState {\n const { hostId, orgId } = input\n const firestore = useFirestore()\n const host = useFirestoreDoc<Record<string, unknown>>(\n () => (hostId ? doc(firestore, 'hosts', hostId) : null),\n [firestore, hostId],\n )\n const routing = host.data?.['screens']\n const routedIds = useMemo(\n () =>\n routing && typeof routing === 'object' && !Array.isArray(routing)\n ? Object.keys(routing).slice(0, SITE_STARTER_MAX_SCREENS + 1)\n : [],\n [routing],\n )\n const routedKey = routedIds.join('|')\n const screens = useFirestoreCollection<StarterPublishScreen>(\n () =>\n hostId && routedIds.length\n ? query(collection(firestore, 'hosts', hostId, 'screens'), where(documentId(), 'in', routedIds))\n : null,\n // `routedKey` stands for the ids: a new array of the same ids is the same read.\n [firestore, hostId, routedKey],\n { idField: '$id' },\n )\n const profile = useFirestoreDoc<Record<string, unknown>>(\n () => (orgId ? doc(firestore, 'publisherProfiles', orgId) : null),\n [firestore, orgId],\n )\n const plan = usePlanFeature(hostId ?? undefined, 'marketplaceSelling')\n // Asked only of a profile with no payout account: a publisher that has one\n // has nothing the answer could change, and nearly every publisher does.\n const { data: user } = useUser()\n const [sellsAsPlatform, setSellsAsPlatform] = useState(false)\n const needsStanding = Boolean(profile.data && !payoutsReady(profile.data))\n useEffect(() => {\n if (!needsStanding || !orgId || !user) return\n let current = true\n authorizedFetch(user, `/api/marketplace/publisher-standing?orgId=${encodeURIComponent(orgId)}`)\n .then((response) => (response.ok ? response.json() : null))\n .then((answer: { sellsAsPlatform?: unknown } | null) => {\n if (current) setSellsAsPlatform(answer?.sellsAsPlatform === true)\n })\n // Not knowing leaves the payouts step up: the door has the last word.\n .catch(() => undefined)\n return () => {\n current = false\n }\n }, [needsStanding, orgId, user])\n const route = useConsoleHostRoute(hostId)\n\n const hostReady = host.status === 'success'\n const pagesReady =\n hostReady && (routedIds.length === 0 || screens.status === 'success')\n return useMemo(\n () => ({\n facts: {\n plan,\n profile:\n profile.status === 'success' ? (profile.data ?? null) : undefined,\n sellsAsPlatform,\n pages: pagesReady ? starterPublishPages(routing, screens.data) : null,\n marketplacePath: route.orgSlug ? orgMarketplacePath(route.orgSlug) : null,\n pagesPath:\n route.orgSlug && route.subdomain\n ? buildRoute(Route.HOST_SCREENS, { orgSlug: route.orgSlug, host: route.subdomain })\n : null,\n },\n builtin: hostReady ? siteStarterBuiltinThemeOf(host.data ?? null) : null,\n hostReady,\n }),\n [plan, profile.status, profile.data, sellsAsPlatform, pagesReady, routing, screens.data, route.orgSlug, route.subdomain, hostReady, host.data],\n )\n}\n\nexport default useStarterPublishFacts\n"],"names":["buildRoute","Route","authorizedFetch","SITE_STARTER_MAX_SCREENS","siteStarterBuiltinThemeOf","useConsoleHostRoute","useFirestore","useFirestoreCollection","useFirestoreDoc","usePlanFeature","useUser","collection","doc","documentId","query","where","useEffect","useMemo","useState","orgMarketplacePath","payoutsReady","starterPublishPages","useStarterPublishFacts","input","host","hostId","orgId","firestore","routing","data","routedIds","Array","isArray","Object","keys","slice","routedKey","join","screens","length","idField","profile","plan","undefined","user","sellsAsPlatform","setSellsAsPlatform","needsStanding","Boolean","current","encodeURIComponent","then","response","ok","json","answer","catch","route","hostReady","status","pagesReady","facts","pages","marketplacePath","orgSlug","pagesPath","subdomain","HOST_SCREENS","builtin"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;AAEA,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,wBAAwB,QAAQ,sCAAqC;AAC9E,SACEC,yBAAyB,QAEpB,4CAA2C;AAClD,SACEC,mBAAmB,EACnBC,YAAY,EACZC,sBAAsB,EACtBC,eAAe,EACfC,cAAc,EACdC,OAAO,QACF,iCAAgC;AACvC,SAASC,UAAU,EAAEC,GAAG,EAAEC,UAAU,EAAEC,KAAK,EAAEC,KAAK,QAAQ,qBAAoB;AAC9E,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACpD,SAASC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ElJ;AAEA,eAAeP,uBAAsB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/hooks/use-starter-publish-facts.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'use client'\n\nimport { buildRoute, Route } from '@aglyn/aglyn/app-utils/console-routes'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { SITE_STARTER_MAX_SCREENS } from '@aglyn/aglyn/app-utils/site-starter'\nimport {\n siteStarterBuiltinThemeOf,\n type SiteStarterBuiltinReading,\n} from '@aglyn/aglyn/app-utils/site-starter-theme'\nimport { merchantPaymentsPlatformMode } from '@aglyn/tenant-feature-instance/hooks/merchant-payments-state'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n usePlanFeature,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport { collection, doc, documentId, query, where } from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport { orgMarketplacePath } from '../model/marketplace-paths'\nimport {\n payoutsReady,\n starterPublishPages,\n type StarterPublishFacts,\n type StarterPublishScreen,\n} from '../model/starter-publish'\n\n/** Everything \"Publish as a starter\" reads before the click. */\nexport interface StarterPublishFactsState {\n /** The reads; the form adds the price it holds. */\n facts: Omit<StarterPublishFacts, 'priceUsd'>\n /** The site's built-in theme as a starter would carry it, or `null` when it wears none. */\n builtin: SiteStarterBuiltinReading | null\n /** The host document has arrived, so `builtin` is an answer rather than a wait. */\n hostReady: boolean\n}\n\n/**\n * What a starter publish of one site would capture and what stands in its\n * way (AGL-4049): the host (its theme and routing), the routed pages it\n * would take, the publishing org's profile, and its plan.\n *\n * The routed pages are read by id, at most one past the most a starter may\n * have, the same window the door walks: enough to count them and to say a\n * site is past the limit, never the whole screens collection.\n */\nexport function useStarterPublishFacts(input: {\n hostId: string | null | undefined\n orgId: string | null | undefined\n}): StarterPublishFactsState {\n const { hostId, orgId } = input\n const firestore = useFirestore()\n const host = useFirestoreDoc<Record<string, unknown>>(\n () => (hostId ? doc(firestore, 'hosts', hostId) : null),\n [firestore, hostId],\n )\n const routing = host.data?.['screens']\n const routedIds = useMemo(\n () =>\n routing && typeof routing === 'object' && !Array.isArray(routing)\n ? Object.keys(routing).slice(0, SITE_STARTER_MAX_SCREENS + 1)\n : [],\n [routing],\n )\n const routedKey = routedIds.join('|')\n const screens = useFirestoreCollection<StarterPublishScreen>(\n () =>\n hostId && routedIds.length\n ? query(collection(firestore, 'hosts', hostId, 'screens'), where(documentId(), 'in', routedIds))\n : null,\n // `routedKey` stands for the ids: a new array of the same ids is the same read.\n [firestore, hostId, routedKey],\n { idField: '$id' },\n )\n const profile = useFirestoreDoc<Record<string, unknown>>(\n () => (orgId ? doc(firestore, 'publisherProfiles', orgId) : null),\n [firestore, orgId],\n )\n const plan = usePlanFeature(hostId ?? undefined, 'marketplaceSelling')\n // Asked only of a profile with no payout account: a publisher that has one\n // has nothing the answer could change, and nearly every publisher does.\n const { data: user } = useUser()\n const [sellsAsPlatform, setSellsAsPlatform] = useState(false)\n const platformMode = merchantPaymentsPlatformMode()\n const needsStanding = Boolean(profile.data && !payoutsReady(profile.data, platformMode))\n useEffect(() => {\n if (!needsStanding || !orgId || !user) return\n let current = true\n authorizedFetch(user, `/api/marketplace/publisher-standing?orgId=${encodeURIComponent(orgId)}`)\n .then((response) => (response.ok ? response.json() : null))\n .then((answer: { sellsAsPlatform?: unknown } | null) => {\n if (current) setSellsAsPlatform(answer?.sellsAsPlatform === true)\n })\n // Not knowing leaves the payouts step up: the door has the last word.\n .catch(() => undefined)\n return () => {\n current = false\n }\n }, [needsStanding, orgId, user])\n const route = useConsoleHostRoute(hostId)\n\n const hostReady = host.status === 'success'\n const pagesReady =\n hostReady && (routedIds.length === 0 || screens.status === 'success')\n return useMemo(\n () => ({\n facts: {\n plan,\n profile:\n profile.status === 'success' ? (profile.data ?? null) : undefined,\n sellsAsPlatform,\n platformMode,\n pages: pagesReady ? starterPublishPages(routing, screens.data) : null,\n marketplacePath: route.orgSlug ? orgMarketplacePath(route.orgSlug) : null,\n pagesPath:\n route.orgSlug && route.subdomain\n ? buildRoute(Route.HOST_SCREENS, { orgSlug: route.orgSlug, host: route.subdomain })\n : null,\n },\n builtin: hostReady ? siteStarterBuiltinThemeOf(host.data ?? null) : null,\n hostReady,\n }),\n [plan, profile.status, profile.data, sellsAsPlatform, platformMode, pagesReady, routing, screens.data, route.orgSlug, route.subdomain, hostReady, host.data],\n )\n}\n\nexport default useStarterPublishFacts\n"],"names":["buildRoute","Route","authorizedFetch","SITE_STARTER_MAX_SCREENS","siteStarterBuiltinThemeOf","merchantPaymentsPlatformMode","useConsoleHostRoute","useFirestore","useFirestoreCollection","useFirestoreDoc","usePlanFeature","useUser","collection","doc","documentId","query","where","useEffect","useMemo","useState","orgMarketplacePath","payoutsReady","starterPublishPages","useStarterPublishFacts","input","host","hostId","orgId","firestore","routing","data","routedIds","Array","isArray","Object","keys","slice","routedKey","join","screens","length","idField","profile","plan","undefined","user","sellsAsPlatform","setSellsAsPlatform","platformMode","needsStanding","Boolean","current","encodeURIComponent","then","response","ok","json","answer","catch","route","hostReady","status","pagesReady","facts","pages","marketplacePath","orgSlug","pagesPath","subdomain","HOST_SCREENS","builtin"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;AAEA,SAASA,UAAU,EAAEC,KAAK,QAAQ,wCAAuC;AACzE,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,wBAAwB,QAAQ,sCAAqC;AAC9E,SACEC,yBAAyB,QAEpB,4CAA2C;AACl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EH,SAASP,MAAMO,OAAO;oBAAEzC,MAAMkC,MAAMS,SAAS;gBAAC,KAC/E;YACR;YACAE,SAASV,YAAYxD,2BAA0BqB,aAAAA,KAAKK,IAAI,YAATL,aAAa,QAAQ;YACpEmC;QACF;OACA;QAACjB;QAAMD,QAAQmB,MAAM;QAAEnB,QAAQZ,IAAI;QAAEgB;QAAiBE;QAAcc;QAAYjC;QAASU,QAAQT,IAAI;QAAE6B,MAAMO,OAAO;QAAEP,MAAMS,SAAS;QAAER;QAAWnC,KAAKK,IAAI;KAAC;AAEhK;AAEA,eAAeP,uBAAsB"}
@@ -82,7 +82,8 @@ import { pluginConnectionRecordVariables, pluginConnectionVariableId, validatePl
82
82
  variables.push({
83
83
  id,
84
84
  label: `${connection.label}: ${connectionFieldLabel(field)}`,
85
- value: (_ref1 = (_values_id = values[id]) == null ? void 0 : _values_id.value) != null ? _ref1 : null
85
+ value: (_ref1 = (_values_id = values[id]) == null ? void 0 : _values_id.value) != null ? _ref1 : null,
86
+ synced: Boolean(record)
86
87
  });
87
88
  }
88
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/editor-connections.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 {\n EditorConnectionRepeatable,\n EditorConnectionVariable,\n EditorPluginConnections,\n} from '@aglyn/aglyn/app-utils/plugin-connection-editor'\nimport { pluginConnectionFieldTypes } from '@aglyn/aglyn/app-utils/plugin-connection-repeat'\nimport type { PluginConnectionSiteRecord } from '@aglyn/aglyn/app-utils/plugin-connection-records'\nimport {\n pluginConnectionRecordVariables,\n pluginConnectionVariableId,\n validatePluginConnections,\n type PluginConnectionDeclaration,\n} from '@aglyn/aglyn/app-utils/plugin-connections'\n\n/*\n * WHAT THE EDITOR IS HANDED OF A SITE'S DECLARED CONNECTIONS (AGL-4196).\n *\n * Pure: the provider reads the site's realm installs, their pins and the\n * records, and this turns them into core's `EditorPluginConnections`, the\n * same attribution and the same variables the published page gets.\n */\n\n/** A realm install as far as the editor needs it: the listing and its namespace. */\nexport interface EditorRealmInstall {\n listingId: string\n identity?: string\n}\n\n/** One installed listing's declared connections that sync, from its pin. */\nexport interface EditorListingConnections {\n listingId: string\n connections: PluginConnectionDeclaration[]\n}\n\n/** The connections a pin's manifest declares that run a sync: only those write a record. */\nexport function syncingConnectionsOf(manifest: unknown): PluginConnectionDeclaration[] {\n const verdict = validatePluginConnections((manifest as { connections?: unknown } | null | undefined)?.connections)\n return verdict.ok ? verdict.value.filter((connection) => Boolean(connection.sync)) : []\n}\n\n/** Words a field name abbreviates that a person reads in capitals: `reviewUrl` → `Review URL`. */\nconst FIELD_ACRONYMS: Readonly<Record<string, string>> = { url: 'URL', uri: 'URI', id: 'ID', api: 'API', sms: 'SMS', html: 'HTML' }\n\n/** A declared field name as a person reads it: `reviewCount` → `Review count`, `reviewUrl` → `Review URL`. */\nexport function connectionFieldLabel(field: string): string {\n const words = field\n .replace(/_/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n .filter(Boolean)\n .map((word) => FIELD_ACRONYMS[word] ?? word)\n .join(' ')\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : field\n}\n\n/** The listing whose namespace `componentId` is in, longest identity first. */\nexport function listingForComponent(installs: readonly EditorRealmInstall[]): (componentId: string) => string | null {\n const namespaces = installs\n .filter((install) => typeof install.identity === 'string' && install.identity)\n .map((install) => ({ prefix: `${install.identity}.`, listingId: install.listingId }))\n .sort((a, b) => b.prefix.length - a.prefix.length)\n return (componentId) => namespaces.find((one) => componentId.startsWith(one.prefix))?.listingId ?? null\n}\n\n/**\n * Core's `EditorPluginConnections` for a site: which listing a component is\n * whose, each listing's records, one variable per declared summary field,\n * named for a person and holding what the last sync wrote (or `null` before\n * one, so an author can bind it before the first sync), and each syncing\n * connection an element can repeat over (AGL-4212).\n */\nexport function editorPluginConnections(input: {\n installs: readonly EditorRealmInstall[]\n listings: readonly EditorListingConnections[]\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n}): EditorPluginConnections {\n const variables: EditorConnectionVariable[] = []\n const repeatables: EditorConnectionRepeatable[] = []\n // `installed`, not `listing`: the listing-field coverage guard reads every `listing.<field>` here as a document read.\n for (const installed of input.listings) {\n // The namespace a `repeatConnection` value names (AGL-4212); an install\n // published before identities existed has none, so nothing to repeat.\n const identity = input.installs.find((install) => install.listingId === installed.listingId)?.identity\n for (const connection of installed.connections) {\n if (identity && connection.sync?.record) {\n repeatables.push({\n identity,\n listingId: installed.listingId,\n connectionId: connection.id,\n label: connection.label,\n types: pluginConnectionFieldTypes(connection),\n })\n }\n const record = input.records[installed.listingId]?.[connection.id]\n const values = pluginConnectionRecordVariables(installed.listingId, connection, record?.fields)\n for (const field of Object.keys(connection.sync?.record.fields ?? {})) {\n const id = pluginConnectionVariableId(installed.listingId, connection.id, field)\n if (!id) continue\n variables.push({ id, label: `${connection.label}: ${connectionFieldLabel(field)}`, value: values[id]?.value ?? null })\n }\n }\n }\n return { listingFor: listingForComponent(input.installs), records: input.records, variables, repeatables }\n}\n"],"names":["pluginConnectionFieldTypes","pluginConnectionRecordVariables","pluginConnectionVariableId","validatePluginConnections","syncingConnectionsOf","manifest","verdict","connections","ok","value","filter","connection","Boolean","sync","FIELD_ACRONYMS","url","uri","id","api","sms","html","connectionFieldLabel","field","words","replace","trim","toLowerCase","split","map","word","join","charAt","toUpperCase","slice","listingForComponent","installs","namespaces","install","identity","prefix","listingId","sort","a","b","length","componentId","find","one","startsWith","editorPluginConnections","input","variables","repeatables","installed","listings","record","push","connectionId","label","types","records","values","fields","Object","keys","listingFor"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAOD,SAASA,0BAA0B,QAAQ,kDAAiD;AAE5F,SACEC,+BAA+B,EAC/BC,0BAA0B,EAC1BC,yBAAyB,QAEpB,4CAA2C;AAsBlD,0FAA0F,GAC1F,OAAO,SAASC,qBAAqBC,QAAiB;IACpD,MAAMC,UAAUH,0BAA2BE,4BAAD,AAACA,SAA2DE,WAAW;IACjH,OAAOD,QAAQE,EAAE,GAAGF,QAAQG,KAAK,CAACC,MAAM,CAAC,CAACC,aAAeC,QAAQD,WAAWE,IAAI,KAAK,EAAE;AACzF;AAEA,gGAAgG,GAChG,MAAMC,iBAAmD;IAAEC,KAAK;IAAOC,KAAK;IAAOC,IAAI;IAAMC,KAAK;IAAOC,KAAK;IAAOC,MAAM;AAAO;AAElI,4GAA4G,GAC5G,OAAO,SAASC,qBAAqBC,KAAa;IAChD,MAAMC,QAAQD,MACXE,OAAO,CAAC,MAAM,KACdA,OAAO,CAAC,sBAAsB,SAC9BC,IAAI,GACJC,WAAW,GACXC,KAAK,CAAC,OACNjB,MAAM,CAACE,SACPgB,GAAG,CAAC,CAACC;YAASf;gBAAAA,uBAAAA,cAAc,CAACe,KAAK,YAApBf,uBAAwBe;OACtCC,IAAI,CAAC;IACR,OAAOP,QAAQA,MAAMQ,MAAM,CAAC,GAAGC,WAAW,KAAKT,MAAMU,KAAK,CAAC,KAAKX;AAClE;AAEA,6EAA6E,GAC7E,OAAO,SAASY,oBAAoBC,QAAuC;IACzE,MAAMC,aAAaD,SAChBzB,MAAM,CAAC,CAAC2B,UAAY,OAAOA,QAAQC,QAAQ,KAAK,YAAYD,QAAQC,QAAQ,EAC5EV,GAAG,CAAC,CAACS,UAAa,CAAA;YAAEE,QAAQ,GAAGF,QAAQC,QAAQ,CAAC,CAAC,CAAC;YAAEE,WAAWH,QAAQG,SAAS;Q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AI,CAAC,GAAI;;oBAGqBD;gBAF1F,MAAM5C,KAAKf,2BAA2BmD,UAAUb,SAAS,EAAE7B,WAAWM,EAAE,EAAEK;gBAC1E,IAAI,CAACL,IAAI;gBACTkC,UAAUK,IAAI,CAAC;oBAAEvC;oBAAIyC,OAAO,GAAG/C,WAAW+C,KAAK,CAAC,EAAE,EAAErC,qBAAqBC,QAAQ;oBAAEb,KAAK,YAAEoD,aAAAA,MAAM,CAAC5C,GAAG,qBAAV4C,WAAYpD,KAAK,oBAAI;gBAAK;YACtH;QACF;IACF;IACA,OAAO;QAAEwD,YAAY/B,oBAAoBgB,MAAMf,QAAQ;QAAGyB,SAASV,MAAMU,OAAO;QAAET;QAAWC;IAAY;AAC3G"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/editor-connections.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 {\n EditorConnectionRepeatable,\n EditorConnectionVariable,\n EditorPluginConnections,\n} from '@aglyn/aglyn/app-utils/plugin-connection-editor'\nimport { pluginConnectionFieldTypes } from '@aglyn/aglyn/app-utils/plugin-connection-repeat'\nimport type { PluginConnectionSiteRecord } from '@aglyn/aglyn/app-utils/plugin-connection-records'\nimport {\n pluginConnectionRecordVariables,\n pluginConnectionVariableId,\n validatePluginConnections,\n type PluginConnectionDeclaration,\n} from '@aglyn/aglyn/app-utils/plugin-connections'\n\n/*\n * WHAT THE EDITOR IS HANDED OF A SITE'S DECLARED CONNECTIONS (AGL-4196).\n *\n * Pure: the provider reads the site's realm installs, their pins and the\n * records, and this turns them into core's `EditorPluginConnections`, the\n * same attribution and the same variables the published page gets.\n */\n\n/** A realm install as far as the editor needs it: the listing and its namespace. */\nexport interface EditorRealmInstall {\n listingId: string\n identity?: string\n}\n\n/** One installed listing's declared connections that sync, from its pin. */\nexport interface EditorListingConnections {\n listingId: string\n connections: PluginConnectionDeclaration[]\n}\n\n/** The connections a pin's manifest declares that run a sync: only those write a record. */\nexport function syncingConnectionsOf(manifest: unknown): PluginConnectionDeclaration[] {\n const verdict = validatePluginConnections((manifest as { connections?: unknown } | null | undefined)?.connections)\n return verdict.ok ? verdict.value.filter((connection) => Boolean(connection.sync)) : []\n}\n\n/** Words a field name abbreviates that a person reads in capitals: `reviewUrl` → `Review URL`. */\nconst FIELD_ACRONYMS: Readonly<Record<string, string>> = { url: 'URL', uri: 'URI', id: 'ID', api: 'API', sms: 'SMS', html: 'HTML' }\n\n/** A declared field name as a person reads it: `reviewCount` → `Review count`, `reviewUrl` → `Review URL`. */\nexport function connectionFieldLabel(field: string): string {\n const words = field\n .replace(/_/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase()\n .split(/\\s+/)\n .filter(Boolean)\n .map((word) => FIELD_ACRONYMS[word] ?? word)\n .join(' ')\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : field\n}\n\n/** The listing whose namespace `componentId` is in, longest identity first. */\nexport function listingForComponent(installs: readonly EditorRealmInstall[]): (componentId: string) => string | null {\n const namespaces = installs\n .filter((install) => typeof install.identity === 'string' && install.identity)\n .map((install) => ({ prefix: `${install.identity}.`, listingId: install.listingId }))\n .sort((a, b) => b.prefix.length - a.prefix.length)\n return (componentId) => namespaces.find((one) => componentId.startsWith(one.prefix))?.listingId ?? null\n}\n\n/**\n * Core's `EditorPluginConnections` for a site: which listing a component is\n * whose, each listing's records, one variable per declared summary field,\n * named for a person and holding what the last sync wrote (or `null` before\n * one, so an author can bind it before the first sync), and each syncing\n * connection an element can repeat over (AGL-4212).\n */\nexport function editorPluginConnections(input: {\n installs: readonly EditorRealmInstall[]\n listings: readonly EditorListingConnections[]\n records: Readonly<Record<string, Readonly<Record<string, PluginConnectionSiteRecord>>>>\n}): EditorPluginConnections {\n const variables: EditorConnectionVariable[] = []\n const repeatables: EditorConnectionRepeatable[] = []\n // `installed`, not `listing`: the listing-field coverage guard reads every `listing.<field>` here as a document read.\n for (const installed of input.listings) {\n // The namespace a `repeatConnection` value names (AGL-4212); an install\n // published before identities existed has none, so nothing to repeat.\n const identity = input.installs.find((install) => install.listingId === installed.listingId)?.identity\n for (const connection of installed.connections) {\n if (identity && connection.sync?.record) {\n repeatables.push({\n identity,\n listingId: installed.listingId,\n connectionId: connection.id,\n label: connection.label,\n types: pluginConnectionFieldTypes(connection),\n })\n }\n const record = input.records[installed.listingId]?.[connection.id]\n const values = pluginConnectionRecordVariables(installed.listingId, connection, record?.fields)\n for (const field of Object.keys(connection.sync?.record.fields ?? {})) {\n const id = pluginConnectionVariableId(installed.listingId, connection.id, field)\n if (!id) continue\n variables.push({\n id,\n label: `${connection.label}: ${connectionFieldLabel(field)}`,\n value: values[id]?.value ?? null,\n synced: Boolean(record),\n })\n }\n }\n }\n return { listingFor: listingForComponent(input.installs), records: input.records, variables, repeatables }\n}\n"],"names":["pluginConnectionFieldTypes","pluginConnectionRecordVariables","pluginConnectionVariableId","validatePluginConnections","syncingConnectionsOf","manifest","verdict","connections","ok","value","filter","connection","Boolean","sync","FIELD_ACRONYMS","url","uri","id","api","sms","html","connectionFieldLabel","field","words","replace","trim","toLowerCase","split","map","word","join","charAt","toUpperCase","slice","listingForComponent","installs","namespaces","install","identity","prefix","listingId","sort","a","b","length","componentId","find","one","startsWith","editorPluginConnections","input","variables","repeatables","installed","listings","record","push","connectionId","label","types","records","values","fields","Object","keys","synced","listingFor"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAOD,SAASA,0BAA0B,QAAQ,kDAAiD;AAE5F,SACEC,+BAA+B,EAC/BC,0BAA0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C,KAAK,CAAC,EAAE,EAAErC,qBAAqBC,QAAQ;oBAC5Db,KAAK,YAAEoD,aAAAA,MAAM,CAAC5C,GAAG,qBAAV4C,WAAYpD,KAAK,oBAAI;oBAC5BwD,QAAQrD,QAAQ2C;gBAClB;YACF;QACF;IACF;IACA,OAAO;QAAEW,YAAYhC,oBAAoBgB,MAAMf,QAAQ;QAAGyB,SAASV,MAAMU,OAAO;QAAET;QAAWC;IAAY;AAC3G"}
@@ -237,6 +237,35 @@ export interface OrgInstallSummary {
237
237
  * picture is the pins alone, as before.
238
238
  */
239
239
  export declare function resolveOrgInstallSummary(hosts: ReadonlyArray<OrgInstallHost>, hostPins: Readonly<Record<string, InstallPin | null | undefined>>, orgPin: InstallPin | null | undefined, listingId?: string): OrgInstallSummary;
240
+ /** A pin's document read, as a live listen reports it. */
241
+ export interface InstallPinRead {
242
+ data?: unknown;
243
+ status?: string;
244
+ /** The answer came from the local cache and the server has not confirmed it. */
245
+ fromCache?: boolean;
246
+ }
247
+ /** Where the install picture of one listing stands: still loading, failed, or answered. */
248
+ export type InstallPictureReadPhase = 'loading' | 'error' | 'ready';
249
+ /**
250
+ * Whether a page may state where a plugin is installed yet (AGL-4047).
251
+ *
252
+ * "Not installed" and "Install" are verdicts, and both rest on ABSENCE: no
253
+ * org pin and no site pin. An absence read too early is not an answer. The
254
+ * cache answers "missing" first for a pin it has never held, and while
255
+ * another tab holds the shared cache that answer can stand for seconds, so a
256
+ * pin is missing only once the server says so, and the sites' pins only once
257
+ * every one of them has been read. Until then a page shows that it is
258
+ * loading, and a read that failed is said as a failure, never as "not
259
+ * installed".
260
+ *
261
+ * `orgPin` is `'pending'` while the org id is still resolving and `null` when
262
+ * there is no org to read a pin under. `sitePins` is the fan-in over the
263
+ * sites' own pins.
264
+ */
265
+ export declare function installPictureReadPhase(input: {
266
+ orgPin: InstallPinRead | null | 'pending';
267
+ sitePins: 'loading' | 'failed' | 'answered';
268
+ }): InstallPictureReadPhase;
240
269
  /** One site an uninstall would touch, and whether it really loses the plugin. */
241
270
  export interface UninstallTarget {
242
271
  hostId: string;
@@ -366,11 +395,21 @@ export declare function installPlanOutcome(input: {
366
395
  tone: 'success' | 'warning' | 'error';
367
396
  text: string;
368
397
  };
369
- /** The row of the plugins list for one install: the version and where it runs. */
398
+ /**
399
+ * The row of the plugins list for one install: the version and where it runs.
400
+ *
401
+ * `switchedOff` (AGL-4047): the sites it covers whose own Admin › Plugins
402
+ * switch has it off. They keep the pin but run nothing, so the row does not
403
+ * call them sites it runs on, the way "Where it runs" and the listing say it.
404
+ * For an org-wide install that is any site of the workspace; for site pins,
405
+ * any pinned site. `siteCount` is how many sites the workspace has.
406
+ */
370
407
  export declare function installedPluginCaption(input: {
371
408
  version?: unknown;
372
409
  orgWide: boolean;
373
410
  siteLabels: readonly string[];
411
+ switchedOff?: readonly string[];
412
+ siteCount?: number;
374
413
  }): string;
375
414
  interface ManifestConfigField {
376
415
  key: string;
@@ -323,6 +323,31 @@
323
323
  installedAnywhere: orgWide || hostPinnedIds.length > 0
324
324
  };
325
325
  }
326
+ /**
327
+ * Whether a page may state where a plugin is installed yet (AGL-4047).
328
+ *
329
+ * "Not installed" and "Install" are verdicts, and both rest on ABSENCE: no
330
+ * org pin and no site pin. An absence read too early is not an answer. The
331
+ * cache answers "missing" first for a pin it has never held, and while
332
+ * another tab holds the shared cache that answer can stand for seconds, so a
333
+ * pin is missing only once the server says so, and the sites' pins only once
334
+ * every one of them has been read. Until then a page shows that it is
335
+ * loading, and a read that failed is said as a failure, never as "not
336
+ * installed".
337
+ *
338
+ * `orgPin` is `'pending'` while the org id is still resolving and `null` when
339
+ * there is no org to read a pin under. `sitePins` is the fan-in over the
340
+ * sites' own pins.
341
+ */ export function installPictureReadPhase(input) {
342
+ const { orgPin, sitePins } = input;
343
+ if (orgPin === 'pending') return 'loading';
344
+ if (orgPin && !orgPin.data) {
345
+ if (orgPin.status === 'error') return 'error';
346
+ if (orgPin.status === 'loading' || orgPin.fromCache === true) return 'loading';
347
+ }
348
+ if (sitePins === 'failed') return 'error';
349
+ return sitePins === 'loading' ? 'loading' : 'ready';
350
+ }
326
351
  /**
327
352
  * Which sites an uninstall actually affects (AGL-1027).
328
353
  *
@@ -481,8 +506,27 @@ const PLACEMENT_NOUNS = {
481
506
  text: (_errors_ = errors[0]) != null ? _errors_ : 'Install failed'
482
507
  };
483
508
  }
484
- /** The row of the plugins list for one install: the version and where it runs. */ export function installedPluginCaption(input) {
485
- return `v${input.version} · ` + (input.orgWide ? 'every site in this organization' : input.siteLabels.length === 1 ? input.siteLabels[0] : `${input.siteLabels.length} sites`);
509
+ /**
510
+ * The row of the plugins list for one install: the version and where it runs.
511
+ *
512
+ * `switchedOff` (AGL-4047): the sites it covers whose own Admin › Plugins
513
+ * switch has it off. They keep the pin but run nothing, so the row does not
514
+ * call them sites it runs on, the way "Where it runs" and the listing say it.
515
+ * For an org-wide install that is any site of the workspace; for site pins,
516
+ * any pinned site. `siteCount` is how many sites the workspace has.
517
+ */ export function installedPluginCaption(input) {
518
+ var _input_switchedOff;
519
+ const off = (_input_switchedOff = input.switchedOff) != null ? _input_switchedOff : [];
520
+ const offNamed = off.length === 1 ? off[0] : `${off.length} of them`;
521
+ let where;
522
+ if (input.orgWide) {
523
+ where = !off.length ? 'every site in this organization' : input.siteCount != null && off.length >= input.siteCount ? 'every site switched it off' : off.length === 1 ? `every site except ${off[0]}, which switched it off` : `every site except ${off.length} that switched it off`;
524
+ } else if (input.siteLabels.length === 1) {
525
+ where = off.length ? `${input.siteLabels[0]}, which switched it off` : input.siteLabels[0];
526
+ } else {
527
+ where = `${input.siteLabels.length} sites` + (off.length ? ` · ${offNamed} switched it off` : '');
528
+ }
529
+ return `v${input.version} · ${where}`;
486
530
  }
487
531
  // ─── A marketplace plugin's settings, from its manifest (AGL-428, AGL-3671) ───
488
532
  const MANIFEST_CONFIG_FIELD_LIMIT = 50;