@aglyn/plugins-marketplace 1.29.2 → 1.29.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-marketplace",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.29.
|
|
29
|
-
"@aglyn/aglyn-markdown-editor": "1.29.
|
|
30
|
-
"@aglyn/shared-data-enums": "1.29.
|
|
31
|
-
"@aglyn/shared-data-mdi": "1.29.
|
|
32
|
-
"@aglyn/shared-ui-jsx": "1.29.
|
|
33
|
-
"@aglyn/shared-ui-next": "1.29.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.29.
|
|
35
|
-
"@aglyn/shared-util-email": "1.29.
|
|
36
|
-
"@aglyn/shared-util-http": "1.29.
|
|
37
|
-
"@aglyn/shared-util-timestamp": "1.29.
|
|
38
|
-
"@aglyn/shared-util-tools": "1.29.
|
|
39
|
-
"@aglyn/tenant-data-admin": "1.29.
|
|
40
|
-
"@aglyn/tenant-feature-instance": "1.29.
|
|
41
|
-
"@aglyn/tenant-runtime": "1.29.
|
|
28
|
+
"@aglyn/aglyn": "1.29.3",
|
|
29
|
+
"@aglyn/aglyn-markdown-editor": "1.29.3",
|
|
30
|
+
"@aglyn/shared-data-enums": "1.29.3",
|
|
31
|
+
"@aglyn/shared-data-mdi": "1.29.3",
|
|
32
|
+
"@aglyn/shared-ui-jsx": "1.29.3",
|
|
33
|
+
"@aglyn/shared-ui-next": "1.29.3",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.29.3",
|
|
35
|
+
"@aglyn/shared-util-email": "1.29.3",
|
|
36
|
+
"@aglyn/shared-util-http": "1.29.3",
|
|
37
|
+
"@aglyn/shared-util-timestamp": "1.29.3",
|
|
38
|
+
"@aglyn/shared-util-tools": "1.29.3",
|
|
39
|
+
"@aglyn/tenant-data-admin": "1.29.3",
|
|
40
|
+
"@aglyn/tenant-feature-instance": "1.29.3",
|
|
41
|
+
"@aglyn/tenant-runtime": "1.29.3",
|
|
42
42
|
"@swc/helpers": "0.5.24"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -78,10 +78,6 @@ import { MARKETPLACE_CONNECTION_SITE_PERMISSIONS, MARKETPLACE_CONNECTION_SITE_RO
|
|
|
78
78
|
free: false,
|
|
79
79
|
starter: true,
|
|
80
80
|
pro: true,
|
|
81
|
-
business: true,
|
|
82
|
-
scale: true,
|
|
83
|
-
advanced: true,
|
|
84
|
-
agency: true,
|
|
85
81
|
enterprise: true
|
|
86
82
|
};
|
|
87
83
|
/** The feature as the marketplace declares it (`registerPluginEntitlements`). */ export const PLUGIN_CONNECTIONS_FEATURE_DECLARATION = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/plugin-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 {\n pluginConnectionEndpointHosts,\n type PluginConnectionDeclaration,\n} from '@aglyn/aglyn/app-utils/plugin-connections'\nimport type { HostAccessRole } from '@aglyn/aglyn/foundation/definitions/organization.types'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginFeatureDeclaration, PluginOrgPermissionDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-entitlements'\nimport type { PluginPermission } from '@aglyn/aglyn/plugin-manager/plugin-permissions'\nimport { MARKETPLACE_PUBLISHER_PERMISSIONS } from './marketplace-publisher-permissions'\nimport {\n MARKETPLACE_CONNECTION_SITE_PERMISSIONS,\n MARKETPLACE_CONNECTION_SITE_ROLE_PRESET,\n} from './marketplace-site-permissions'\n\n/*\n * DECLARED CONNECTIONS, THE PLATFORM'S HALF (AGL-4193): THE CONTRACT.\n *\n * A marketplace plugin declares a connection in its manifest\n * (`@aglyn/aglyn/app-utils/plugin-connections`); this plugin, the\n * marketplace, runs it for every plugin it distributes: the publisher's OAuth\n * app credentials per listing, the site's sealed grant, the connect routes,\n * the plan feature and the two permission keys. Light and client-safe: the\n * console card imports the names, views and keys from here, and nothing here\n * reaches Firestore, a provider or React.\n *\n * Where the data lives, all server-only (no client rule opens any of it):\n *\n * pluginConnectionCredentials/{listingId}__{connectionId}\n * the publisher's OAuth client id and secret, both sealed, keyed by\n * the publishing workspace in `orgId` so its erasure sweeps them;\n * hosts/{hostId}/pluginConnections/{listingId}__{connectionId}\n * a site's grant: sealed tokens, its choices, status, sync times;\n * hosts/{hostId}/pluginConnections/oauth-{hash}\n * a pending connect's single-use state record;\n * hosts/{hostId}/pluginConnections/record-{listingId}__{connectionId}\n * the record a connection's declared sync last wrote (AGL-4192):\n * written only by the sync, read only on the server (the site's page\n * render and the console's routes), never by a client rule.\n *\n * The sync (AGL-4194) runs in the console on the fifteen-minute\n * `plugin-console-crons` tick as the `marketplace-connection-sync` job, and\n * for one connection on \"Sync now\" (`PLUGIN_CONNECTIONS_API_ROUTES.sync`).\n */\n\n/** Top-level collection of the publisher OAuth app credentials, one per listing and connection. */\nexport const PLUGIN_CONNECTION_CREDENTIALS_COLLECTION = 'pluginConnectionCredentials'\n\n/** A site's connections: `hosts/{hostId}/pluginConnections`. */\nexport const PLUGIN_CONNECTIONS_HOST_COLLECTION = 'pluginConnections'\n\n/** The id shared by a listing's credentials and a site's connection: `{listingId}__{connectionId}`. */\nexport function pluginConnectionDocId(listingId: string, connectionId: string): string {\n return `${listingId}__${connectionId}`\n}\n\n/**\n * The id of the record a connection's sync writes, beside the connection in\n * `hosts/{hostId}/pluginConnections` (AGL-4192). The `record-` prefix keeps\n * it apart from the connection (`{listingId}__{connectionId}`) and from a\n * pending connect (`oauth-…`).\n */\nexport function pluginConnectionRecordDocId(listingId: string, connectionId: string): string {\n return `record-${pluginConnectionDocId(listingId, connectionId)}`\n}\n\n/** One value of a record, typed by its declared field (`datetime` is epoch ms, `url` an https string). */\nexport type PluginConnectionRecordValue = string | number | boolean | null\n\n/**\n * The record a connection's declared sync last wrote for one site: the\n * declared summary `fields` and the declared `items`, each holding only the\n * keys the manifest's `sync.record` declares, already capped to its limits.\n * The sync replaces it whole; a site with no successful sync has none.\n */\nexport interface PluginConnectionRecordDoc {\n kind: 'record'\n listingId: string\n connectionId: string\n /** The listing version whose manifest declared the schema this was mapped with. */\n version: string\n /** When the sync that wrote it finished, epoch ms. */\n syncedAtMs: number\n fields: Record<string, PluginConnectionRecordValue>\n items: Array<Record<string, PluginConnectionRecordValue>>\n}\n\n/** The console API paths (served at `/api/<path>`). The callback is registered at providers; never rename it. */\nexport const PLUGIN_CONNECTIONS_API_ROUTES = {\n connectStart: 'plugin-connections/connect/start',\n connectCallback: 'plugin-connections/connect/callback',\n resources: 'plugin-connections/resources',\n choose: 'plugin-connections/choose',\n disconnect: 'plugin-connections/disconnect',\n status: 'plugin-connections/status',\n credentials: 'plugin-connections/credentials',\n /**\n * POST `{ hostId, listingId, connectionId }`: runs the connection's declared\n * sync once and answers `{ connection: PluginConnectionView, synced }`\n * (AGL-4194). Site key and plan, like connect.\n */\n sync: 'plugin-connections/sync',\n /** A site's record of one connection, for the editor's canvas (AGL-4195). */\n record: 'plugin-connections/record',\n} as const\n\n/** The first path segment every route above shares: the plugin's API prefix. */\nexport const PLUGIN_CONNECTIONS_API_PREFIX = 'plugin-connections'\n\n/**\n * A site connection's state.\n *\n * - `connected`: the grant works. `ready` on the view says whether every\n * declared resource has been chosen, which a sync waits for.\n * - `reconnect_required`: the provider refused the grant (revoked, expired,\n * scopes withdrawn); only the site owner connecting again fixes it.\n * - `error`: the last sync or refresh failed for another reason; the next\n * run tries again.\n */\nexport type PluginConnectionStatus = 'connected' | 'reconnect_required' | 'error'\n\n/** One resource the site owner chose: the id the provider gave it and what the picker showed. */\nexport interface PluginConnectionChoice {\n id: string\n label: string\n}\n\n/** What the console may see of a site's connection: never a token, a lease or a secret. */\nexport interface PluginConnectionView {\n listingId: string\n connectionId: string\n provider: string\n status: PluginConnectionStatus\n /** The choices made so far, by resource id. */\n choices: Record<string, PluginConnectionChoice>\n /** Whether every declared resource is chosen. */\n ready: boolean\n scopes: string[]\n connectedAtMs: number\n lastSyncAtMs: number | null\n lastError: string | null\n}\n\n/** One declared connection of a plugin installed on a site, with where it stands. */\nexport interface PluginConnectionStatusEntry {\n listingId: string\n connectionId: string\n provider: string\n label: string\n description?: string\n /** The resources the owner picks, in order. */\n resources: Array<{ id: string; label: string }>\n /** The site's connection, or `null` before one is made. */\n connection: PluginConnectionView | null\n /** Whether the publisher has set the listing's OAuth app credentials. */\n credentialsSet: boolean\n /** Whether the workspace's plan includes connections. */\n planAllows: boolean\n /** Every host this connection's data goes to or comes from ({@link pluginConnectionRecipients}). */\n hosts: string[]\n}\n\n/** Whether a listing's OAuth app credentials are set: the only thing ever read back. */\nexport interface PluginConnectionCredentialsStatus {\n connectionId: string\n label: string\n set: boolean\n updatedAtMs: number | null\n}\n\n/* ------------------------------------------------------------------ */\n/* The plan feature */\n/* ------------------------------------------------------------------ */\n\n/** The plan feature key: connections are on Starter, Pro and Custom, off on Free. */\nexport const PLUGIN_CONNECTIONS_FEATURE = 'pluginConnections'\n\n/** The plan defaults. The retired plans sit above Pro on the ladder, so they keep it. */\nexport const PLUGIN_CONNECTIONS_BY_PLAN: Readonly<Record<OrgPlan, boolean>> = {\n free: false,\n starter: true,\n pro: true,\n business: true,\n scale: true,\n advanced: true,\n agency: true,\n enterprise: true,\n}\n\n/** The feature as the marketplace declares it (`registerPluginEntitlements`). */\nexport const PLUGIN_CONNECTIONS_FEATURE_DECLARATION: PluginFeatureDeclaration = {\n key: PLUGIN_CONNECTIONS_FEATURE,\n label: 'Plugin connections',\n defaultByPlan: PLUGIN_CONNECTIONS_BY_PLAN,\n}\n\n/**\n * The plans the feature comes with, as every sentence about it names them: the\n * plans on sale that `PLUGIN_CONNECTIONS_BY_PLAN` turns on. Names, never a\n * price.\n */\nexport const PLUGIN_CONNECTIONS_PLANS = 'the Starter, Pro and Custom plans'\n\n/** What a plan without the feature is told. Names the plans, never a price. */\nexport const PLUGIN_CONNECTIONS_PLAN_REFUSAL =\n `Connecting a plugin to another service comes with ${PLUGIN_CONNECTIONS_PLANS}.`\n\n/**\n * What a shopper reads on a listing whose plugin declares connections, before\n * installing (AGL-4197): the plugin installs on any plan, but connecting it,\n * which is what makes it useful, needs one of these plans. \"Google Business\n * Profile\" → \"Connecting Google Business Profile comes with the Starter, Pro\n * and Custom plans\". Null when nothing is declared.\n */\nexport function pluginConnectionsPlanNote(\n labels: readonly string[],\n): string | null {\n const names = Array.from(\n new Set(labels.map((label) => String(label).trim()).filter(Boolean)),\n )\n if (!names.length) return null\n const joined =\n names.length === 1\n ? names[0]\n : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`\n return `Connecting ${joined} comes with ${PLUGIN_CONNECTIONS_PLANS}`\n}\n\n/* ------------------------------------------------------------------ */\n/* The permission keys */\n/* ------------------------------------------------------------------ */\n\n/** The site key: connect, choose, disconnect and read a site's plugin connections. */\nexport const PLUGIN_CONNECTIONS_SITE_PERMISSION = 'marketplace.siteConnections'\n\n/** The publisher key: set a listing's OAuth app credentials. */\nexport const PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION = 'marketplace.connectionCredentials'\n\n/** The site Admin (declared beside the marketplace's other site keys). */\nexport const PLUGIN_CONNECTIONS_SITE_ROLE_PRESET: Readonly<Record<HostAccessRole, boolean>> =\n MARKETPLACE_CONNECTION_SITE_ROLE_PRESET\n\n/** The site key as the plugin declares it into the org permission catalog. */\nexport const PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION: PluginOrgPermissionDeclaration =\n MARKETPLACE_CONNECTION_SITE_PERMISSIONS[0]\n\n/** The publisher key as the plugin declares it; owners and admins hold it by default. */\nexport const PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION: PluginPermission =\n MARKETPLACE_PUBLISHER_PERMISSIONS.find((entry) => entry.key === PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION) as PluginPermission\n\n/** The refusal a door answers without a key: names the permission, never a role. */\nexport function pluginConnectionsPermissionRefusal(\n key: typeof PLUGIN_CONNECTIONS_SITE_PERMISSION | typeof PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION,\n): string {\n const label =\n key === PLUGIN_CONNECTIONS_SITE_PERMISSION\n ? PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION.label\n : PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION.label\n return `Your role does not include \"${label}\" — ask an organization admin`\n}\n\n/* ------------------------------------------------------------------ */\n/* Where a listing's connections send data */\n/* ------------------------------------------------------------------ */\n\n/**\n * One declared connection's recipients, derived from its declaration alone\n * (AGL-4194): the hosts the site owner's browser is sent to for consent and\n * the platform calls with the site's grant — the authorization, token and\n * revocation endpoints and every `apiHosts` entry, wildcards as declared.\n * The listing's own list of where data goes, per listing: it is never part\n * of Aglyn's published subprocessor list, because the site owner chooses the\n * provider and connects their own account to it.\n */\nexport interface PluginConnectionRecipient {\n connectionId: string\n provider: string\n label: string\n /** Sorted, each once. */\n hosts: string[]\n}\n\n/** The hosts one declared connection reaches, sorted. */\nexport function pluginConnectionHosts(connection: PluginConnectionDeclaration): string[] {\n return [...new Set([...pluginConnectionEndpointHosts(connection), ...connection.apiHosts])].sort()\n}\n\n/** Each declared connection of a listing version, with the hosts it reaches. */\nexport function pluginConnectionRecipients(\n connections: readonly PluginConnectionDeclaration[],\n): PluginConnectionRecipient[] {\n return connections.map((connection) => ({\n connectionId: connection.id,\n provider: connection.provider,\n label: connection.label,\n hosts: pluginConnectionHosts(connection),\n }))\n}\n"],"names":["pluginConnectionEndpointHosts","MARKETPLACE_PUBLISHER_PERMISSIONS","MARKETPLACE_CONNECTION_SITE_PERMISSIONS","MARKETPLACE_CONNECTION_SITE_ROLE_PRESET","PLUGIN_CONNECTION_CREDENTIALS_COLLECTION","PLUGIN_CONNECTIONS_HOST_COLLECTION","pluginConnectionDocId","listingId","connectionId","pluginConnectionRecordDocId","PLUGIN_CONNECTIONS_API_ROUTES","connectStart","connectCallback","resources","choose","disconnect","status","credentials","sync","record","PLUGIN_CONNECTIONS_API_PREFIX","PLUGIN_CONNECTIONS_FEATURE","PLUGIN_CONNECTIONS_BY_PLAN","free","starter","pro","business","scale","advanced","agency","enterprise","PLUGIN_CONNECTIONS_FEATURE_DECLARATION","key","label","defaultByPlan","PLUGIN_CONNECTIONS_PLANS","PLUGIN_CONNECTIONS_PLAN_REFUSAL","pluginConnectionsPlanNote","labels","names","Array","from","Set","map","String","trim","filter","Boolean","length","joined","slice","join","PLUGIN_CONNECTIONS_SITE_PERMISSION","PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION","PLUGIN_CONNECTIONS_SITE_ROLE_PRESET","PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION","PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION","find","entry","pluginConnectionsPermissionRefusal","pluginConnectionHosts","connection","apiHosts","sort","pluginConnectionRecipients","connections","id","provider","hosts"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,6BAA6B,QAExB,4CAA2C;AAKlD,SAASC,iCAAiC,QAAQ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AYtB,GAAG,CAAC,CAACkB,aAAgB,CAAA;YACtCrD,cAAcqD,WAAWK,EAAE;YAC3BC,UAAUN,WAAWM,QAAQ;YAC7BlC,OAAO4B,WAAW5B,KAAK;YACvBmC,OAAOR,sBAAsBC;QAC/B,CAAA;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/plugin-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 {\n pluginConnectionEndpointHosts,\n type PluginConnectionDeclaration,\n} from '@aglyn/aglyn/app-utils/plugin-connections'\nimport type { HostAccessRole } from '@aglyn/aglyn/foundation/definitions/organization.types'\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginFeatureDeclaration, PluginOrgPermissionDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-entitlements'\nimport type { PluginPermission } from '@aglyn/aglyn/plugin-manager/plugin-permissions'\nimport { MARKETPLACE_PUBLISHER_PERMISSIONS } from './marketplace-publisher-permissions'\nimport {\n MARKETPLACE_CONNECTION_SITE_PERMISSIONS,\n MARKETPLACE_CONNECTION_SITE_ROLE_PRESET,\n} from './marketplace-site-permissions'\n\n/*\n * DECLARED CONNECTIONS, THE PLATFORM'S HALF (AGL-4193): THE CONTRACT.\n *\n * A marketplace plugin declares a connection in its manifest\n * (`@aglyn/aglyn/app-utils/plugin-connections`); this plugin, the\n * marketplace, runs it for every plugin it distributes: the publisher's OAuth\n * app credentials per listing, the site's sealed grant, the connect routes,\n * the plan feature and the two permission keys. Light and client-safe: the\n * console card imports the names, views and keys from here, and nothing here\n * reaches Firestore, a provider or React.\n *\n * Where the data lives, all server-only (no client rule opens any of it):\n *\n * pluginConnectionCredentials/{listingId}__{connectionId}\n * the publisher's OAuth client id and secret, both sealed, keyed by\n * the publishing workspace in `orgId` so its erasure sweeps them;\n * hosts/{hostId}/pluginConnections/{listingId}__{connectionId}\n * a site's grant: sealed tokens, its choices, status, sync times;\n * hosts/{hostId}/pluginConnections/oauth-{hash}\n * a pending connect's single-use state record;\n * hosts/{hostId}/pluginConnections/record-{listingId}__{connectionId}\n * the record a connection's declared sync last wrote (AGL-4192):\n * written only by the sync, read only on the server (the site's page\n * render and the console's routes), never by a client rule.\n *\n * The sync (AGL-4194) runs in the console on the fifteen-minute\n * `plugin-console-crons` tick as the `marketplace-connection-sync` job, and\n * for one connection on \"Sync now\" (`PLUGIN_CONNECTIONS_API_ROUTES.sync`).\n */\n\n/** Top-level collection of the publisher OAuth app credentials, one per listing and connection. */\nexport const PLUGIN_CONNECTION_CREDENTIALS_COLLECTION = 'pluginConnectionCredentials'\n\n/** A site's connections: `hosts/{hostId}/pluginConnections`. */\nexport const PLUGIN_CONNECTIONS_HOST_COLLECTION = 'pluginConnections'\n\n/** The id shared by a listing's credentials and a site's connection: `{listingId}__{connectionId}`. */\nexport function pluginConnectionDocId(listingId: string, connectionId: string): string {\n return `${listingId}__${connectionId}`\n}\n\n/**\n * The id of the record a connection's sync writes, beside the connection in\n * `hosts/{hostId}/pluginConnections` (AGL-4192). The `record-` prefix keeps\n * it apart from the connection (`{listingId}__{connectionId}`) and from a\n * pending connect (`oauth-…`).\n */\nexport function pluginConnectionRecordDocId(listingId: string, connectionId: string): string {\n return `record-${pluginConnectionDocId(listingId, connectionId)}`\n}\n\n/** One value of a record, typed by its declared field (`datetime` is epoch ms, `url` an https string). */\nexport type PluginConnectionRecordValue = string | number | boolean | null\n\n/**\n * The record a connection's declared sync last wrote for one site: the\n * declared summary `fields` and the declared `items`, each holding only the\n * keys the manifest's `sync.record` declares, already capped to its limits.\n * The sync replaces it whole; a site with no successful sync has none.\n */\nexport interface PluginConnectionRecordDoc {\n kind: 'record'\n listingId: string\n connectionId: string\n /** The listing version whose manifest declared the schema this was mapped with. */\n version: string\n /** When the sync that wrote it finished, epoch ms. */\n syncedAtMs: number\n fields: Record<string, PluginConnectionRecordValue>\n items: Array<Record<string, PluginConnectionRecordValue>>\n}\n\n/** The console API paths (served at `/api/<path>`). The callback is registered at providers; never rename it. */\nexport const PLUGIN_CONNECTIONS_API_ROUTES = {\n connectStart: 'plugin-connections/connect/start',\n connectCallback: 'plugin-connections/connect/callback',\n resources: 'plugin-connections/resources',\n choose: 'plugin-connections/choose',\n disconnect: 'plugin-connections/disconnect',\n status: 'plugin-connections/status',\n credentials: 'plugin-connections/credentials',\n /**\n * POST `{ hostId, listingId, connectionId }`: runs the connection's declared\n * sync once and answers `{ connection: PluginConnectionView, synced }`\n * (AGL-4194). Site key and plan, like connect.\n */\n sync: 'plugin-connections/sync',\n /** A site's record of one connection, for the editor's canvas (AGL-4195). */\n record: 'plugin-connections/record',\n} as const\n\n/** The first path segment every route above shares: the plugin's API prefix. */\nexport const PLUGIN_CONNECTIONS_API_PREFIX = 'plugin-connections'\n\n/**\n * A site connection's state.\n *\n * - `connected`: the grant works. `ready` on the view says whether every\n * declared resource has been chosen, which a sync waits for.\n * - `reconnect_required`: the provider refused the grant (revoked, expired,\n * scopes withdrawn); only the site owner connecting again fixes it.\n * - `error`: the last sync or refresh failed for another reason; the next\n * run tries again.\n */\nexport type PluginConnectionStatus = 'connected' | 'reconnect_required' | 'error'\n\n/** One resource the site owner chose: the id the provider gave it and what the picker showed. */\nexport interface PluginConnectionChoice {\n id: string\n label: string\n}\n\n/** What the console may see of a site's connection: never a token, a lease or a secret. */\nexport interface PluginConnectionView {\n listingId: string\n connectionId: string\n provider: string\n status: PluginConnectionStatus\n /** The choices made so far, by resource id. */\n choices: Record<string, PluginConnectionChoice>\n /** Whether every declared resource is chosen. */\n ready: boolean\n scopes: string[]\n connectedAtMs: number\n lastSyncAtMs: number | null\n lastError: string | null\n}\n\n/** One declared connection of a plugin installed on a site, with where it stands. */\nexport interface PluginConnectionStatusEntry {\n listingId: string\n connectionId: string\n provider: string\n label: string\n description?: string\n /** The resources the owner picks, in order. */\n resources: Array<{ id: string; label: string }>\n /** The site's connection, or `null` before one is made. */\n connection: PluginConnectionView | null\n /** Whether the publisher has set the listing's OAuth app credentials. */\n credentialsSet: boolean\n /** Whether the workspace's plan includes connections. */\n planAllows: boolean\n /** Every host this connection's data goes to or comes from ({@link pluginConnectionRecipients}). */\n hosts: string[]\n}\n\n/** Whether a listing's OAuth app credentials are set: the only thing ever read back. */\nexport interface PluginConnectionCredentialsStatus {\n connectionId: string\n label: string\n set: boolean\n updatedAtMs: number | null\n}\n\n/* ------------------------------------------------------------------ */\n/* The plan feature */\n/* ------------------------------------------------------------------ */\n\n/** The plan feature key: connections are on Starter, Pro and Custom, off on Free. */\nexport const PLUGIN_CONNECTIONS_FEATURE = 'pluginConnections'\n\n/** The plan defaults. The retired plans sit above Pro on the ladder, so they keep it. */\nexport const PLUGIN_CONNECTIONS_BY_PLAN: Readonly<Record<OrgPlan, boolean>> = {\n free: false,\n starter: true,\n pro: true,\n enterprise: true,\n}\n\n/** The feature as the marketplace declares it (`registerPluginEntitlements`). */\nexport const PLUGIN_CONNECTIONS_FEATURE_DECLARATION: PluginFeatureDeclaration = {\n key: PLUGIN_CONNECTIONS_FEATURE,\n label: 'Plugin connections',\n defaultByPlan: PLUGIN_CONNECTIONS_BY_PLAN,\n}\n\n/**\n * The plans the feature comes with, as every sentence about it names them: the\n * plans on sale that `PLUGIN_CONNECTIONS_BY_PLAN` turns on. Names, never a\n * price.\n */\nexport const PLUGIN_CONNECTIONS_PLANS = 'the Starter, Pro and Custom plans'\n\n/** What a plan without the feature is told. Names the plans, never a price. */\nexport const PLUGIN_CONNECTIONS_PLAN_REFUSAL =\n `Connecting a plugin to another service comes with ${PLUGIN_CONNECTIONS_PLANS}.`\n\n/**\n * What a shopper reads on a listing whose plugin declares connections, before\n * installing (AGL-4197): the plugin installs on any plan, but connecting it,\n * which is what makes it useful, needs one of these plans. \"Google Business\n * Profile\" → \"Connecting Google Business Profile comes with the Starter, Pro\n * and Custom plans\". Null when nothing is declared.\n */\nexport function pluginConnectionsPlanNote(\n labels: readonly string[],\n): string | null {\n const names = Array.from(\n new Set(labels.map((label) => String(label).trim()).filter(Boolean)),\n )\n if (!names.length) return null\n const joined =\n names.length === 1\n ? names[0]\n : `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`\n return `Connecting ${joined} comes with ${PLUGIN_CONNECTIONS_PLANS}`\n}\n\n/* ------------------------------------------------------------------ */\n/* The permission keys */\n/* ------------------------------------------------------------------ */\n\n/** The site key: connect, choose, disconnect and read a site's plugin connections. */\nexport const PLUGIN_CONNECTIONS_SITE_PERMISSION = 'marketplace.siteConnections'\n\n/** The publisher key: set a listing's OAuth app credentials. */\nexport const PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION = 'marketplace.connectionCredentials'\n\n/** The site Admin (declared beside the marketplace's other site keys). */\nexport const PLUGIN_CONNECTIONS_SITE_ROLE_PRESET: Readonly<Record<HostAccessRole, boolean>> =\n MARKETPLACE_CONNECTION_SITE_ROLE_PRESET\n\n/** The site key as the plugin declares it into the org permission catalog. */\nexport const PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION: PluginOrgPermissionDeclaration =\n MARKETPLACE_CONNECTION_SITE_PERMISSIONS[0]\n\n/** The publisher key as the plugin declares it; owners and admins hold it by default. */\nexport const PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION: PluginPermission =\n MARKETPLACE_PUBLISHER_PERMISSIONS.find((entry) => entry.key === PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION) as PluginPermission\n\n/** The refusal a door answers without a key: names the permission, never a role. */\nexport function pluginConnectionsPermissionRefusal(\n key: typeof PLUGIN_CONNECTIONS_SITE_PERMISSION | typeof PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION,\n): string {\n const label =\n key === PLUGIN_CONNECTIONS_SITE_PERMISSION\n ? PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION.label\n : PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION.label\n return `Your role does not include \"${label}\" — ask an organization admin`\n}\n\n/* ------------------------------------------------------------------ */\n/* Where a listing's connections send data */\n/* ------------------------------------------------------------------ */\n\n/**\n * One declared connection's recipients, derived from its declaration alone\n * (AGL-4194): the hosts the site owner's browser is sent to for consent and\n * the platform calls with the site's grant — the authorization, token and\n * revocation endpoints and every `apiHosts` entry, wildcards as declared.\n * The listing's own list of where data goes, per listing: it is never part\n * of Aglyn's published subprocessor list, because the site owner chooses the\n * provider and connects their own account to it.\n */\nexport interface PluginConnectionRecipient {\n connectionId: string\n provider: string\n label: string\n /** Sorted, each once. */\n hosts: string[]\n}\n\n/** The hosts one declared connection reaches, sorted. */\nexport function pluginConnectionHosts(connection: PluginConnectionDeclaration): string[] {\n return [...new Set([...pluginConnectionEndpointHosts(connection), ...connection.apiHosts])].sort()\n}\n\n/** Each declared connection of a listing version, with the hosts it reaches. */\nexport function pluginConnectionRecipients(\n connections: readonly PluginConnectionDeclaration[],\n): PluginConnectionRecipient[] {\n return connections.map((connection) => ({\n connectionId: connection.id,\n provider: connection.provider,\n label: connection.label,\n hosts: pluginConnectionHosts(connection),\n }))\n}\n"],"names":["pluginConnectionEndpointHosts","MARKETPLACE_PUBLISHER_PERMISSIONS","MARKETPLACE_CONNECTION_SITE_PERMISSIONS","MARKETPLACE_CONNECTION_SITE_ROLE_PRESET","PLUGIN_CONNECTION_CREDENTIALS_COLLECTION","PLUGIN_CONNECTIONS_HOST_COLLECTION","pluginConnectionDocId","listingId","connectionId","pluginConnectionRecordDocId","PLUGIN_CONNECTIONS_API_ROUTES","connectStart","connectCallback","resources","choose","disconnect","status","credentials","sync","record","PLUGIN_CONNECTIONS_API_PREFIX","PLUGIN_CONNECTIONS_FEATURE","PLUGIN_CONNECTIONS_BY_PLAN","free","starter","pro","enterprise","PLUGIN_CONNECTIONS_FEATURE_DECLARATION","key","label","defaultByPlan","PLUGIN_CONNECTIONS_PLANS","PLUGIN_CONNECTIONS_PLAN_REFUSAL","pluginConnectionsPlanNote","labels","names","Array","from","Set","map","String","trim","filter","Boolean","length","joined","slice","join","PLUGIN_CONNECTIONS_SITE_PERMISSION","PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION","PLUGIN_CONNECTIONS_SITE_ROLE_PRESET","PLUGIN_CONNECTIONS_SITE_PERMISSION_DECLARATION","PLUGIN_CONNECTIONS_CREDENTIALS_PERMISSION_DECLARATION","find","entry","pluginConnectionsPermissionRefusal","pluginConnectionHosts","connection","apiHosts","sort","pluginConnectionRecipients","connections","id","provider","hosts"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,6BAA6B,QAExB,4CAA2C;AAKlD,SAASC,iCAAiC,QAAQ,yCAAqC;AACvF,SACEC,uCAAuC,EACvCC,uCAAuC,QAClC,oCAAgC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GAED,iGAAiG,GACjG,OAAO,MAAMC,2CAA2C,8BAA6B;AAErF,8DAA8D,GAC9D,OAAO,MAAMC,qCAAqC,oBAAmB;AAErE,qGAAqG,GACrG,OAAO,SAASC,sBAAsBC,SAAiB,EAAEC,YAAoB;IAC3E,OAAO,GAAGD,UAAU,EAAE,EAAEC,cAAc;AACxC;AAEA;;;;;CAKC,GACD,OAAO,SAASC,4BAA4BF,SAAiB,EAAEC,YAAoB;IACjF,OAAO,CAAC,OAAO,EAAEF,sBAAsBC,WAAWC,eAAe;AACnE;AAuBA,+GAA+G,GAC/G,OAAO,MAAME,gCAAgC;IAC3CC,cAAc;IACdC,iBAAiB;IACjBC,WAAW;IACXC,QAAQ;IACRC,YAAY;IACZC,QAAQ;IACRC,aAAa;IACb;;;;GAIC,GACDC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C5E,OAAO,MAAMgD,iDACXjD,uCAAuC,CAAC,EAAE,CAAA;AAE5C,uFAAuF,GACvF,OAAO,MAAMkD,wDACXnD,kCAAkCoD,IAAI,CAAC,CAACC,QAAUA,MAAM1B,GAAG,KAAKqB,2CAA8D;AAEhI,kFAAkF,GAClF,OAAO,SAASM,mCACd3B,GAAiG;IAEjG,MAAMC,QACJD,QAAQoB,qCACJG,+CAA+CtB,KAAK,GACpDuB,sDAAsDvB,KAAK;IACjE,OAAO,CAAC,4BAA4B,EAAEA,MAAM,6BAA6B,CAAC;AAC5E;AAuBA,uDAAuD,GACvD,OAAO,SAAS2B,sBAAsBC,UAAuC;IAC3E,OAAO;WAAI,IAAInB,IAAI;eAAItC,8BAA8ByD;eAAgBA,WAAWC,QAAQ;SAAC;KAAE,CAACC,IAAI;AAClG;AAEA,8EAA8E,GAC9E,OAAO,SAASC,2BACdC,WAAmD;IAEnD,OAAOA,YAAYtB,GAAG,CAAC,CAACkB,aAAgB,CAAA;YACtCjD,cAAciD,WAAWK,EAAE;YAC3BC,UAAUN,WAAWM,QAAQ;YAC7BlC,OAAO4B,WAAW5B,KAAK;YACvBmC,OAAOR,sBAAsBC;QAC/B,CAAA;AACF"}
|
|
@@ -23,20 +23,12 @@
|
|
|
23
23
|
free: 30,
|
|
24
24
|
starter: 20,
|
|
25
25
|
pro: 20,
|
|
26
|
-
business: 20,
|
|
27
|
-
scale: 20,
|
|
28
|
-
advanced: 20,
|
|
29
|
-
agency: 20,
|
|
30
26
|
enterprise: 20
|
|
31
27
|
};
|
|
32
28
|
/** Which plans may sell on the marketplace: Pro and up. */ export const MARKETPLACE_SELLING_BY_PLAN = {
|
|
33
29
|
free: false,
|
|
34
30
|
starter: false,
|
|
35
31
|
pro: true,
|
|
36
|
-
business: true,
|
|
37
|
-
scale: true,
|
|
38
|
-
advanced: true,
|
|
39
|
-
agency: true,
|
|
40
32
|
enterprise: true
|
|
41
33
|
};
|
|
42
34
|
/** The marketplace's plan figures, for the manifest generator. */ export function marketplacePlanEntitlements() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/marketplace/src/lib/plan-entitlements.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// Types only: the manifest generator loads this module on its own to compile\n// the plan figures, so nothing here may reach a core module at runtime.\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginPlanEntitlementsDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-plan-entitlements'\n\n/**\n * THE MARKETPLACE'S PLAN TERMS (AGL-3080): which plans may sell on the\n * marketplace, and the take rate on a sale. Compiled into core's\n * `PLAN_ENTITLEMENTS` by the manifest generator\n * (`register.planEntitlements`), so the pricing tables and the checkout read\n * the figures they always have.\n */\ndeclare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {\n interface PluginEntitlementQuotas {\n /**\n * Platform take rate % on the org's MARKETPLACE listing sales (AGL-46,\n * resolved from entitlements per AGL-1543): 20 on paid plans, 30 on\n * free. Distinct from the storefront `transactionFee*Pct` — this is\n * Aglyn's cut of a marketplace sale, priced off the SELLER org.\n */\n marketplaceFeePct?: number\n }\n interface PluginEntitlementFeatures {\n /** Sell listings on the marketplace (AGL-46). */\n marketplaceSelling?: boolean\n }\n}\n\n/** The take rate on a marketplace sale, per plan of the SELLER org. */\nexport const MARKETPLACE_FEE_PCT_BY_PLAN: Readonly<Record<OrgPlan, number>> = {\n // Marketplace take rate (AGL-46/1543): free-plan sellers pay a higher\n // share. `marketplaceSelling` is false here, so this rate only prices an\n // org GRANTED selling via a per-org feature override — and any org whose\n // dead subscription resolved it down to free.\n free: 30,\n starter: 20,\n pro: 20,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/marketplace/src/lib/plan-entitlements.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// Types only: the manifest generator loads this module on its own to compile\n// the plan figures, so nothing here may reach a core module at runtime.\nimport type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types'\nimport type { PluginPlanEntitlementsDeclaration } from '@aglyn/aglyn/plugin-manager/plugin-plan-entitlements'\n\n/**\n * THE MARKETPLACE'S PLAN TERMS (AGL-3080): which plans may sell on the\n * marketplace, and the take rate on a sale. Compiled into core's\n * `PLAN_ENTITLEMENTS` by the manifest generator\n * (`register.planEntitlements`), so the pricing tables and the checkout read\n * the figures they always have.\n */\ndeclare module '@aglyn/aglyn/plugin-manager/plugin-entitlement-keys' {\n interface PluginEntitlementQuotas {\n /**\n * Platform take rate % on the org's MARKETPLACE listing sales (AGL-46,\n * resolved from entitlements per AGL-1543): 20 on paid plans, 30 on\n * free. Distinct from the storefront `transactionFee*Pct` — this is\n * Aglyn's cut of a marketplace sale, priced off the SELLER org.\n */\n marketplaceFeePct?: number\n }\n interface PluginEntitlementFeatures {\n /** Sell listings on the marketplace (AGL-46). */\n marketplaceSelling?: boolean\n }\n}\n\n/** The take rate on a marketplace sale, per plan of the SELLER org. */\nexport const MARKETPLACE_FEE_PCT_BY_PLAN: Readonly<Record<OrgPlan, number>> = {\n // Marketplace take rate (AGL-46/1543): free-plan sellers pay a higher\n // share. `marketplaceSelling` is false here, so this rate only prices an\n // org GRANTED selling via a per-org feature override — and any org whose\n // dead subscription resolved it down to free.\n free: 30,\n starter: 20,\n pro: 20,\n enterprise: 20,\n}\n\n/** Which plans may sell on the marketplace: Pro and up. */\nexport const MARKETPLACE_SELLING_BY_PLAN: Readonly<Record<OrgPlan, boolean>> = {\n free: false,\n starter: false,\n pro: true,\n enterprise: true,\n}\n\n/** The marketplace's plan figures, for the manifest generator. */\nexport function marketplacePlanEntitlements(): PluginPlanEntitlementsDeclaration {\n return {\n quotas: [\n {\n key: 'marketplaceFeePct',\n label: 'Marketplace fee %',\n byPlan: MARKETPLACE_FEE_PCT_BY_PLAN,\n // A percentage of a sale, not a band: an uncapped comp never lifts it.\n price: true,\n },\n ],\n features: [\n {\n key: 'marketplaceSelling',\n label: 'Sell on the marketplace',\n byPlan: MARKETPLACE_SELLING_BY_PLAN,\n },\n ],\n }\n}\n"],"names":["MARKETPLACE_FEE_PCT_BY_PLAN","free","starter","pro","enterprise","MARKETPLACE_SELLING_BY_PLAN","marketplacePlanEntitlements","quotas","key","label","byPlan","price","features"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,6EAA6E;AAC7E,wEAAwE;AA2BxE,qEAAqE,GACrE,OAAO,MAAMA,8BAAiE;IAC5E,sEAAsE;IACtE,yEAAyE;IACzE,yEAAyE;IACzE,8CAA8C;IAC9CC,MAAM;IACNC,SAAS;IACTC,KAAK;IACLC,YAAY;AACd,EAAC;AAED,yDAAyD,GACzD,OAAO,MAAMC,8BAAkE;IAC7EJ,MAAM;IACNC,SAAS;IACTC,KAAK;IACLC,YAAY;AACd,EAAC;AAED,gEAAgE,GAChE,OAAO,SAASE;IACd,OAAO;QACLC,QAAQ;YACN;gBACEC,KAAK;gBACLC,OAAO;gBACPC,QAAQV;gBACR,uEAAuE;gBACvEW,OAAO;YACT;SACD;QACDC,UAAU;YACR;gBACEJ,KAAK;gBACLC,OAAO;gBACPC,QAAQL;YACV;SACD;IACH;AACF"}
|