@aglyn/aglyn 1.0.0-beta.220 → 1.0.0-beta.222
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 +15 -11
- package/src/lib/app-utils/agent-openapi.js +1 -1
- package/src/lib/app-utils/agent-openapi.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +3 -2
- package/src/lib/app-utils/analytics-events.js +3 -2
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/api-plugins.d.ts +30 -0
- package/src/lib/app-utils/api-plugins.js +24 -1
- package/src/lib/app-utils/api-plugins.js.map +1 -1
- package/src/lib/app-utils/author-html.d.ts +1 -1
- package/src/lib/app-utils/author-html.js.map +1 -1
- package/src/lib/app-utils/bandwidth-cap.d.ts +12 -1
- package/src/lib/app-utils/bandwidth-cap.js +17 -1
- package/src/lib/app-utils/bandwidth-cap.js.map +1 -1
- package/src/lib/app-utils/compose-reusable-components.d.ts +19 -0
- package/src/lib/app-utils/compose-reusable-components.js +116 -26
- package/src/lib/app-utils/compose-reusable-components.js.map +1 -1
- package/src/lib/app-utils/console-routes.d.ts +4 -0
- package/src/lib/app-utils/console-routes.js +3 -0
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/contacts.d.ts +71 -0
- package/src/lib/app-utils/contacts.js +55 -0
- package/src/lib/app-utils/contacts.js.map +1 -1
- package/src/lib/app-utils/contexts.d.ts +1 -0
- package/src/lib/app-utils/contexts.js +1 -0
- package/src/lib/app-utils/contexts.js.map +1 -1
- package/src/lib/app-utils/crm-email-templates.js +21 -4
- package/src/lib/app-utils/crm-email-templates.js.map +1 -1
- package/src/lib/app-utils/crm-kinds.d.ts +2 -0
- package/src/lib/app-utils/crm-kinds.js +1 -0
- package/src/lib/app-utils/crm-kinds.js.map +1 -1
- package/src/lib/app-utils/crm.d.ts +1199 -67
- package/src/lib/app-utils/crm.js +1951 -310
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/csv-import.d.ts +10 -38
- package/src/lib/app-utils/csv-import.js +17 -42
- package/src/lib/app-utils/csv-import.js.map +1 -1
- package/src/lib/app-utils/csv.d.ts +32 -11
- package/src/lib/app-utils/csv.js +43 -5
- package/src/lib/app-utils/csv.js.map +1 -1
- package/src/lib/app-utils/default-site.d.ts +116 -0
- package/src/lib/app-utils/default-site.js +1024 -0
- package/src/lib/app-utils/default-site.js.map +1 -0
- package/src/lib/app-utils/docs-help.generated.d.ts +23 -23
- package/src/lib/app-utils/docs-help.generated.js +47 -10
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +746 -151
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/draft-placeholders.d.ts +76 -0
- package/src/lib/app-utils/draft-placeholders.js +115 -0
- package/src/lib/app-utils/draft-placeholders.js.map +1 -0
- package/src/lib/app-utils/entity-picker-context.d.ts +19 -15
- package/src/lib/app-utils/entity-picker-context.js +4 -4
- package/src/lib/app-utils/entity-picker-context.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.d.ts +66 -10
- package/src/lib/app-utils/expand-repeatables.js +88 -14
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/forms.d.ts +33 -22
- package/src/lib/app-utils/forms.js +47 -28
- package/src/lib/app-utils/forms.js.map +1 -1
- package/src/lib/app-utils/full-use-cost.d.ts +277 -0
- package/src/lib/app-utils/full-use-cost.js +421 -0
- package/src/lib/app-utils/full-use-cost.js.map +1 -0
- package/src/lib/app-utils/health-report.js +33 -0
- package/src/lib/app-utils/health-report.js.map +1 -1
- package/src/lib/app-utils/leaving-notice.d.ts +96 -0
- package/src/lib/app-utils/leaving-notice.js +157 -0
- package/src/lib/app-utils/leaving-notice.js.map +1 -0
- package/src/lib/app-utils/llms-txt.d.ts +20 -0
- package/src/lib/app-utils/llms-txt.js +7 -1
- package/src/lib/app-utils/llms-txt.js.map +1 -1
- package/src/lib/app-utils/media-asset-facts.d.ts +16 -1
- package/src/lib/app-utils/media-asset-facts.js +40 -13
- package/src/lib/app-utils/media-asset-facts.js.map +1 -1
- package/src/lib/app-utils/media-bandwidth.d.ts +52 -0
- package/src/lib/app-utils/media-bandwidth.js +94 -0
- package/src/lib/app-utils/media-bandwidth.js.map +1 -0
- package/src/lib/app-utils/media-ref.d.ts +241 -33
- package/src/lib/app-utils/media-ref.js +324 -43
- package/src/lib/app-utils/media-ref.js.map +1 -1
- package/src/lib/app-utils/media-src.d.ts +8 -8
- package/src/lib/app-utils/media-src.js +27 -11
- package/src/lib/app-utils/media-src.js.map +1 -1
- package/src/lib/app-utils/media-takedown-reach.d.ts +4 -1
- package/src/lib/app-utils/media-takedown-reach.js +6 -3
- package/src/lib/app-utils/media-takedown-reach.js.map +1 -1
- package/src/lib/app-utils/notifications.d.ts +1 -1
- package/src/lib/app-utils/notifications.js +2 -0
- package/src/lib/app-utils/notifications.js.map +1 -1
- package/src/lib/app-utils/operator-alerts.js +17 -0
- package/src/lib/app-utils/operator-alerts.js.map +1 -1
- package/src/lib/app-utils/organizations.d.ts +51 -2
- package/src/lib/app-utils/organizations.js +56 -3
- package/src/lib/app-utils/organizations.js.map +1 -1
- package/src/lib/app-utils/page-record-sources.d.ts +87 -0
- package/src/lib/app-utils/page-record-sources.js +53 -0
- package/src/lib/app-utils/page-record-sources.js.map +1 -0
- package/src/lib/app-utils/paid-media-source.d.ts +3 -7
- package/src/lib/app-utils/paid-media-source.js +5 -19
- package/src/lib/app-utils/paid-media-source.js.map +1 -1
- package/src/lib/app-utils/person-erasure.d.ts +5 -2
- package/src/lib/app-utils/person-erasure.js.map +1 -1
- package/src/lib/app-utils/picklists.d.ts +187 -0
- package/src/lib/app-utils/picklists.js +320 -0
- package/src/lib/app-utils/picklists.js.map +1 -0
- package/src/lib/app-utils/plan-entitlements.d.ts +220 -50
- package/src/lib/app-utils/plan-entitlements.js +309 -115
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/realm-host-surface.generated.js +2 -0
- package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +1 -1
- package/src/lib/app-utils/release-flags.js +11 -0
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/rendered-widths.d.ts +121 -0
- package/src/lib/app-utils/rendered-widths.js +211 -0
- package/src/lib/app-utils/rendered-widths.js.map +1 -0
- package/src/lib/app-utils/repeat-sources.d.ts +2 -1
- package/src/lib/app-utils/repeat-sources.js.map +1 -1
- package/src/lib/app-utils/screen-link-context-value.d.ts +7 -0
- package/src/lib/app-utils/screen-link-context-value.js.map +1 -1
- package/src/lib/app-utils/screen-link-context.js +14 -2
- package/src/lib/app-utils/screen-link-context.js.map +1 -1
- package/src/lib/app-utils/screen-route.d.ts +157 -36
- package/src/lib/app-utils/screen-route.js +191 -41
- package/src/lib/app-utils/screen-route.js.map +1 -1
- package/src/lib/app-utils/seo-audit.d.ts +11 -1
- package/src/lib/app-utils/seo-audit.js +33 -13
- package/src/lib/app-utils/seo-audit.js.map +1 -1
- package/src/lib/app-utils/seo-keywords.d.ts +11 -0
- package/src/lib/app-utils/seo-keywords.js +19 -5
- package/src/lib/app-utils/seo-keywords.js.map +1 -1
- package/src/lib/app-utils/seo-page-facts.d.ts +47 -4
- package/src/lib/app-utils/seo-page-facts.js +136 -31
- package/src/lib/app-utils/seo-page-facts.js.map +1 -1
- package/src/lib/app-utils/seo-site-scan.d.ts +42 -4
- package/src/lib/app-utils/seo-site-scan.js +113 -12
- package/src/lib/app-utils/seo-site-scan.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +5 -4
- package/src/lib/app-utils/server.js +14 -5
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-icon-set.d.ts +195 -0
- package/src/lib/app-utils/site-icon-set.js +351 -0
- package/src/lib/app-utils/site-icon-set.js.map +1 -0
- package/src/lib/app-utils/site-interactions.d.ts +101 -4
- package/src/lib/app-utils/site-interactions.js +120 -4
- package/src/lib/app-utils/site-interactions.js.map +1 -1
- package/src/lib/app-utils/starter-template-nodes.d.ts +7 -0
- package/src/lib/app-utils/starter-template-nodes.js +3 -0
- package/src/lib/app-utils/starter-template-nodes.js.map +1 -1
- package/src/lib/app-utils/starter-templates.d.ts +5 -19
- package/src/lib/app-utils/starter-templates.js +5 -49
- package/src/lib/app-utils/starter-templates.js.map +1 -1
- package/src/lib/app-utils/transfer-launcher-context.d.ts +136 -0
- package/src/lib/app-utils/transfer-launcher-context.js +23 -0
- package/src/lib/app-utils/transfer-launcher-context.js.map +1 -0
- package/src/lib/app-utils/transfer-resume-import.d.ts +39 -0
- package/src/lib/app-utils/transfer-resume-import.js +128 -0
- package/src/lib/app-utils/transfer-resume-import.js.map +1 -0
- package/src/lib/app-utils/upgrade-proposal.d.ts +66 -0
- package/src/lib/app-utils/upgrade-proposal.js +95 -0
- package/src/lib/app-utils/upgrade-proposal.js.map +1 -0
- package/src/lib/app-utils/utc-month.d.ts +33 -0
- package/src/lib/app-utils/utc-month.js +35 -0
- package/src/lib/app-utils/utc-month.js.map +1 -0
- package/src/lib/app-utils/visitor-record-ceiling.d.ts +4 -4
- package/src/lib/app-utils/visitor-record-ceiling.js +4 -4
- package/src/lib/app-utils/visitor-record-ceiling.js.map +1 -1
- package/src/lib/app-utils/wire-nodes.d.ts +39 -19
- package/src/lib/app-utils/wire-nodes.js +120 -34
- package/src/lib/app-utils/wire-nodes.js.map +1 -1
- package/src/lib/data-transfer/access.d.ts +74 -0
- package/src/lib/data-transfer/access.js +93 -0
- package/src/lib/data-transfer/access.js.map +1 -0
- package/src/lib/data-transfer/derive.d.ts +246 -0
- package/src/lib/data-transfer/derive.js +1007 -0
- package/src/lib/data-transfer/derive.js.map +1 -0
- package/src/lib/data-transfer/export-file.d.ts +46 -0
- package/src/lib/data-transfer/export-file.js +146 -0
- package/src/lib/data-transfer/export-file.js.map +1 -0
- package/src/lib/data-transfer/field-catalog.d.ts +134 -0
- package/src/lib/data-transfer/field-catalog.js +278 -0
- package/src/lib/data-transfer/field-catalog.js.map +1 -0
- package/src/lib/data-transfer/header-match.d.ts +129 -0
- package/src/lib/data-transfer/header-match.js +367 -0
- package/src/lib/data-transfer/header-match.js.map +1 -0
- package/src/lib/data-transfer/index.d.ts +34 -0
- package/src/lib/data-transfer/index.js +40 -0
- package/src/lib/data-transfer/index.js.map +1 -0
- package/src/lib/data-transfer/job.d.ts +190 -0
- package/src/lib/data-transfer/job.js +229 -0
- package/src/lib/data-transfer/job.js.map +1 -0
- package/src/lib/data-transfer/lookup.d.ts +45 -0
- package/src/lib/data-transfer/lookup.js +71 -0
- package/src/lib/data-transfer/lookup.js.map +1 -0
- package/src/lib/data-transfer/match.d.ts +99 -0
- package/src/lib/data-transfer/match.js +244 -0
- package/src/lib/data-transfer/match.js.map +1 -0
- package/src/lib/data-transfer/package-plan.d.ts +205 -0
- package/src/lib/data-transfer/package-plan.js +475 -0
- package/src/lib/data-transfer/package-plan.js.map +1 -0
- package/src/lib/data-transfer/package.d.ts +181 -0
- package/src/lib/data-transfer/package.js +426 -0
- package/src/lib/data-transfer/package.js.map +1 -0
- package/src/lib/data-transfer/picklist-map.d.ts +139 -0
- package/src/lib/data-transfer/picklist-map.js +271 -0
- package/src/lib/data-transfer/picklist-map.js.map +1 -0
- package/src/lib/data-transfer/plan.d.ts +176 -0
- package/src/lib/data-transfer/plan.js +451 -0
- package/src/lib/data-transfer/plan.js.map +1 -0
- package/src/lib/data-transfer/policy.d.ts +170 -0
- package/src/lib/data-transfer/policy.js +378 -0
- package/src/lib/data-transfer/policy.js.map +1 -0
- package/src/lib/data-transfer/resource.d.ts +211 -0
- package/src/lib/data-transfer/resource.js +241 -0
- package/src/lib/data-transfer/resource.js.map +1 -0
- package/src/lib/data-transfer/review.d.ts +70 -0
- package/src/lib/data-transfer/review.js +233 -0
- package/src/lib/data-transfer/review.js.map +1 -0
- package/src/lib/data-transfer/similarity.d.ts +40 -0
- package/src/lib/data-transfer/similarity.js +106 -0
- package/src/lib/data-transfer/similarity.js.map +1 -0
- package/src/lib/data-transfer/site-package.d.ts +365 -0
- package/src/lib/data-transfer/site-package.js +1077 -0
- package/src/lib/data-transfer/site-package.js.map +1 -0
- package/src/lib/data-transfer/source.d.ts +74 -0
- package/src/lib/data-transfer/source.js +293 -0
- package/src/lib/data-transfer/source.js.map +1 -0
- package/src/lib/data-transfer/transfer-api.d.ts +898 -0
- package/src/lib/data-transfer/transfer-api.js +107 -0
- package/src/lib/data-transfer/transfer-api.js.map +1 -0
- package/src/lib/foundation/definitions/org-billing.types.d.ts +31 -0
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +42 -1
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +6 -4
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +91 -2
- package/src/lib/plugin-manager/feature-plugins.js +48 -3
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +56 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +1132 -27
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/index.d.ts +0 -1
- package/src/lib/plugin-manager/index.js +0 -1
- package/src/lib/plugin-manager/index.js.map +1 -1
- package/src/lib/plugin-manager/interaction-recipes.d.ts +142 -0
- package/src/lib/plugin-manager/interaction-recipes.js +104 -0
- package/src/lib/plugin-manager/interaction-recipes.js.map +1 -0
- package/src/lib/plugin-manager/interaction-step-checks.d.ts +66 -0
- package/src/lib/plugin-manager/interaction-step-checks.js +86 -0
- package/src/lib/plugin-manager/interaction-step-checks.js.map +1 -0
- package/src/lib/plugin-manager/plugin-artifact-types.d.ts +235 -0
- package/src/lib/plugin-manager/plugin-artifact-types.js +99 -0
- package/src/lib/plugin-manager/plugin-artifact-types.js.map +1 -0
- package/src/lib/plugin-manager/plugin-contact-capture.d.ts +8 -0
- package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
- package/src/lib/plugin-manager/plugin-conversion-credit.d.ts +216 -0
- package/src/lib/plugin-manager/plugin-conversion-credit.js +91 -0
- package/src/lib/plugin-manager/plugin-conversion-credit.js.map +1 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.d.ts +83 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.js +87 -0
- package/src/lib/plugin-manager/plugin-entity-pickers.js.map +1 -0
- package/src/lib/plugin-manager/plugin-host-resources.d.ts +6 -0
- package/src/lib/plugin-manager/plugin-host-resources.js +6 -1
- package/src/lib/plugin-manager/plugin-host-resources.js.map +1 -1
- package/src/lib/plugin-manager/plugin-intake-gates.d.ts +75 -0
- package/src/lib/plugin-manager/plugin-intake-gates.js +49 -0
- package/src/lib/plugin-manager/plugin-intake-gates.js.map +1 -0
- package/src/lib/plugin-manager/plugin-jobs.d.ts +5 -5
- package/src/lib/plugin-manager/plugin-jobs.js +7 -7
- package/src/lib/plugin-manager/plugin-jobs.js.map +1 -1
- package/src/lib/plugin-manager/plugin-live-paths.d.ts +70 -0
- package/src/lib/plugin-manager/plugin-live-paths.js +66 -0
- package/src/lib/plugin-manager/plugin-live-paths.js.map +1 -0
- package/src/lib/plugin-manager/plugin-org-erasure.d.ts +3 -2
- package/src/lib/plugin-manager/plugin-org-erasure.js +30 -5
- package/src/lib/plugin-manager/plugin-org-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-person-erasure.d.ts +68 -9
- package/src/lib/plugin-manager/plugin-person-erasure.js +196 -51
- package/src/lib/plugin-manager/plugin-person-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-person-records.d.ts +275 -0
- package/src/lib/plugin-manager/plugin-person-records.js +107 -0
- package/src/lib/plugin-manager/plugin-person-records.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-counts.d.ts +76 -0
- package/src/lib/plugin-manager/plugin-record-counts.js +49 -0
- package/src/lib/plugin-manager/plugin-record-counts.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-email-state.d.ts +26 -0
- package/src/lib/plugin-manager/plugin-record-email-state.js +16 -0
- package/src/lib/plugin-manager/plugin-record-email-state.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-index.d.ts +10 -0
- package/src/lib/plugin-manager/plugin-record-index.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-lists.d.ts +86 -6
- package/src/lib/plugin-manager/plugin-record-lists.js +42 -5
- package/src/lib/plugin-manager/plugin-record-lists.js.map +1 -1
- package/src/lib/plugin-manager/plugin-record-origin.d.ts +79 -0
- package/src/lib/plugin-manager/plugin-record-origin.js +46 -0
- package/src/lib/plugin-manager/plugin-record-origin.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-pages.d.ts +37 -0
- package/src/lib/plugin-manager/plugin-record-pages.js +52 -0
- package/src/lib/plugin-manager/plugin-record-pages.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-timeline.d.ts +60 -0
- package/src/lib/plugin-manager/plugin-record-timeline.js +16 -0
- package/src/lib/plugin-manager/plugin-record-timeline.js.map +1 -1
- package/src/lib/plugin-manager/plugin-resource-drafts.d.ts +5 -5
- package/src/lib/plugin-manager/plugin-resource-drafts.js.map +1 -1
- package/src/lib/plugin-manager/plugin-revocations.d.ts +64 -0
- package/src/lib/plugin-manager/plugin-revocations.js +47 -0
- package/src/lib/plugin-manager/plugin-revocations.js.map +1 -0
- package/src/lib/plugin-manager/plugin-send-tallies.d.ts +69 -0
- package/src/lib/plugin-manager/plugin-send-tallies.js +45 -0
- package/src/lib/plugin-manager/plugin-send-tallies.js.map +1 -0
- package/src/lib/plugin-manager/plugin-server-steps.d.ts +170 -0
- package/src/lib/plugin-manager/plugin-server-steps.js +116 -0
- package/src/lib/plugin-manager/plugin-server-steps.js.map +1 -0
- package/src/lib/plugin-manager/plugin-site-bundle.d.ts +40 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js +4 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-export.d.ts +57 -1
- package/src/lib/plugin-manager/plugin-site-export.js +23 -10
- package/src/lib/plugin-manager/plugin-site-export.js.map +1 -1
- package/src/lib/plugin-manager/plugin-sitemap-readers.d.ts +146 -0
- package/src/lib/plugin-manager/plugin-sitemap-readers.js +110 -0
- package/src/lib/plugin-manager/plugin-sitemap-readers.js.map +1 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.d.ts +714 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.js +443 -0
- package/src/lib/plugin-manager/plugin-transfer-resources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-usage-axes.d.ts +54 -5
- package/src/lib/plugin-manager/plugin-usage-axes.js +11 -3
- package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -1
- package/src/lib/plugin-manager/plugin-user-erasure.js +9 -1
- package/src/lib/plugin-manager/plugin-user-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-visitor-doors.d.ts +104 -0
- package/src/lib/plugin-manager/plugin-visitor-doors.js +108 -0
- package/src/lib/plugin-manager/plugin-visitor-doors.js.map +1 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js +2 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
- package/src/lib/plugin-manager/repeat-rows.d.ts +5 -6
- package/src/lib/plugin-manager/repeat-rows.js.map +1 -1
- package/src/lib/app-utils/actions.d.ts +0 -310
- package/src/lib/app-utils/actions.js +0 -506
- package/src/lib/app-utils/actions.js.map +0 -1
- package/src/lib/app-utils/automation-placeholders.d.ts +0 -72
- package/src/lib/app-utils/automation-placeholders.js +0 -207
- package/src/lib/app-utils/automation-placeholders.js.map +0 -1
- package/src/lib/app-utils/dataset-models.d.ts +0 -339
- package/src/lib/app-utils/dataset-models.js +0 -722
- package/src/lib/app-utils/dataset-models.js.map +0 -1
- package/src/lib/app-utils/datasets.d.ts +0 -171
- package/src/lib/app-utils/datasets.js +0 -227
- package/src/lib/app-utils/datasets.js.map +0 -1
- package/src/lib/app-utils/form-abuse-ceiling.d.ts +0 -146
- package/src/lib/app-utils/form-abuse-ceiling.js +0 -158
- package/src/lib/app-utils/form-abuse-ceiling.js.map +0 -1
- package/src/lib/plugin-manager/order-fulfilment.d.ts +0 -142
- package/src/lib/plugin-manager/order-fulfilment.js +0 -104
- package/src/lib/plugin-manager/order-fulfilment.js.map +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A SERVER STEP ANOTHER PLUGIN RUNS (AGL-3080).
|
|
19
|
+
*
|
|
20
|
+
* An interaction's steps are the platform's client steps plus whatever steps
|
|
21
|
+
* the plugins add (`site-interactions.ts`), and every step that is not a
|
|
22
|
+
* client step is the server's to run. The plugin that runs a server run — the
|
|
23
|
+
* automation engine — knows its own steps. A step that acts on ANOTHER
|
|
24
|
+
* plugin's records is that plugin's: writing a dataset row is the data
|
|
25
|
+
* plugin's, moving a contact's stage is the CRM's. The engine used to carry
|
|
26
|
+
* each of those writes itself, which made it the keeper of every plugin's
|
|
27
|
+
* storage.
|
|
28
|
+
*
|
|
29
|
+
* So the plugin that owns a step REGISTERS ITS EXECUTOR here, by step type,
|
|
30
|
+
* and the engine hands it the step when a run reaches one. The engine keeps
|
|
31
|
+
* what every step shares — the step's guard, the run's order, its history,
|
|
32
|
+
* the nesting cap — and the executor does the step's one write. Neither
|
|
33
|
+
* imports the other: both meet at this module, which names no plugin, so a
|
|
34
|
+
* marketplace plugin adds a step the same way a first-party one does.
|
|
35
|
+
*
|
|
36
|
+
* ## Declared, then registered — and an absent executor is refused
|
|
37
|
+
*
|
|
38
|
+
* The executor is registered from the owning plugin's `serverDeclarations`
|
|
39
|
+
* entry, which every app runs at boot. An empty registry must not read as an
|
|
40
|
+
* answer: a step whose executor never registered would otherwise fall through
|
|
41
|
+
* the engine as a step nobody runs, and a run history would say the record
|
|
42
|
+
* was written when it was not.
|
|
43
|
+
*
|
|
44
|
+
* So a first-party plugin also DECLARES the steps it runs, under
|
|
45
|
+
* `serverSteps` in `plugins.config.json`, compiled into core. The three cases
|
|
46
|
+
* are kept apart:
|
|
47
|
+
*
|
|
48
|
+
* - registered — the executor runs the step, declared or not (a marketplace
|
|
49
|
+
* plugin's steps are registered and never compiled);
|
|
50
|
+
* - declared and NOT registered — the boot failed. The app's declarations
|
|
51
|
+
* step is run again ({@link runPluginDeclarationsRepair}); if the executor
|
|
52
|
+
* is still missing, {@link pluginServerStepExecutor} THROWS
|
|
53
|
+
* {@link ServerStepUnavailableError}, which the engine records as the
|
|
54
|
+
* step's failure;
|
|
55
|
+
* - neither — no plugin runs the type, and the caller answers `null` as it
|
|
56
|
+
* would for any step it does not know.
|
|
57
|
+
*
|
|
58
|
+
* A type the engine runs itself never reaches this registry, so a
|
|
59
|
+
* registration cannot replace one of the engine's own steps.
|
|
60
|
+
*
|
|
61
|
+
* Reached by path, never through a barrel: only server code asks.
|
|
62
|
+
*/
|
|
63
|
+
/** The automation a step belongs to, as its history and its records name it. */
|
|
64
|
+
export interface ServerStepRunRef {
|
|
65
|
+
/** Which kind of automation is running — the engine's own vocabulary. */
|
|
66
|
+
kind: string;
|
|
67
|
+
/** The automation's document id. */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Its name at the time of the run. */
|
|
70
|
+
name: string;
|
|
71
|
+
}
|
|
72
|
+
/** One step, handed to the plugin that runs it. */
|
|
73
|
+
export interface ServerStepRequest {
|
|
74
|
+
/** The site the run is on. Every write is scoped to what this site may see. */
|
|
75
|
+
hostId: string;
|
|
76
|
+
/**
|
|
77
|
+
* The owning organization's billing document, already read by the gate
|
|
78
|
+
* that admitted the run, and its id beside it — so an executor gating on
|
|
79
|
+
* the plan or counting against a cap pays no second read. Null when the
|
|
80
|
+
* site has no resolvable organization, which every gate reads as Free.
|
|
81
|
+
*/
|
|
82
|
+
org: unknown;
|
|
83
|
+
orgId: string | null;
|
|
84
|
+
/** The automation whose step this is. */
|
|
85
|
+
run: ServerStepRunRef;
|
|
86
|
+
/** The event the run is answering. */
|
|
87
|
+
event: string;
|
|
88
|
+
/** The event's payload: the values a step reads. */
|
|
89
|
+
payload: Record<string, unknown>;
|
|
90
|
+
/** The step exactly as it is stored. */
|
|
91
|
+
step: {
|
|
92
|
+
type: string;
|
|
93
|
+
[field: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What one step did.
|
|
98
|
+
*
|
|
99
|
+
* Nothing set is a step that did its work. `error` is a step that did not —
|
|
100
|
+
* the run records it and goes on to the next step, so an executor answers a
|
|
101
|
+
* refusal rather than throwing one; a throw is read the same way.
|
|
102
|
+
*/
|
|
103
|
+
export interface ServerStepAnswer {
|
|
104
|
+
/** Why nothing was written, when nothing was — a line of the run history. */
|
|
105
|
+
error?: string;
|
|
106
|
+
/** The one fact worth carrying into the run summary: a record's name, a status. */
|
|
107
|
+
detail?: string;
|
|
108
|
+
/**
|
|
109
|
+
* An event this step's write earned, for the ENGINE to raise. Not raised
|
|
110
|
+
* by the executor: an automation whose step causes the event it listens
|
|
111
|
+
* for would otherwise run until a meter stopped it, and only the engine
|
|
112
|
+
* holds the nesting cap that stops it first.
|
|
113
|
+
*/
|
|
114
|
+
emit?: {
|
|
115
|
+
event: string;
|
|
116
|
+
payload: Record<string, unknown>;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Runs one step of the types it was registered for. */
|
|
120
|
+
export type ServerStepExecutor = (request: ServerStepRequest) => Promise<ServerStepAnswer>;
|
|
121
|
+
/** The compiled declaration: which plugin runs which step type. */
|
|
122
|
+
export interface ServerStepDeclaration {
|
|
123
|
+
pluginId: string;
|
|
124
|
+
/** The stored step `type`. */
|
|
125
|
+
type: string;
|
|
126
|
+
}
|
|
127
|
+
/** Every server step a first-party plugin declares, in `plugins.config.json` order. */
|
|
128
|
+
export declare function declaredServerSteps(): readonly ServerStepDeclaration[];
|
|
129
|
+
/** The declaration of this step type, or `null` for one no plugin declares. */
|
|
130
|
+
export declare function declaredServerStep(type: string): ServerStepDeclaration | null;
|
|
131
|
+
/** A registered executor, with the plugin it belongs to. */
|
|
132
|
+
export interface RegisteredServerStepExecutor {
|
|
133
|
+
pluginId: string;
|
|
134
|
+
run: ServerStepExecutor;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Registers the executor of one or more step types. Returns the unregister,
|
|
138
|
+
* which removes each type only while this executor still holds it.
|
|
139
|
+
*
|
|
140
|
+
* The owner is the plugin whose register fn is running, or the `pluginId`
|
|
141
|
+
* passed for a boot declaration, where the loader's marker is not set. A
|
|
142
|
+
* registration with neither is refused; so is a type another plugin declares
|
|
143
|
+
* or already holds, because two executors for one step would each write the
|
|
144
|
+
* other's records. The same plugin registering again replaces its own (a
|
|
145
|
+
* second surface, a repeated boot). Nothing is registered unless every type
|
|
146
|
+
* is accepted.
|
|
147
|
+
*/
|
|
148
|
+
export declare function registerServerStepExecutor(types: readonly string[], run: ServerStepExecutor, options?: {
|
|
149
|
+
pluginId?: string;
|
|
150
|
+
}): () => void;
|
|
151
|
+
/** The executor registered for a step type, with its owner, or `null`. Never repairs. */
|
|
152
|
+
export declare function registeredServerStepExecutor(type: string): RegisteredServerStepExecutor | null;
|
|
153
|
+
/** Only for specs: forgets every registered executor. */
|
|
154
|
+
export declare function resetServerStepExecutorsForTests(): void;
|
|
155
|
+
/**
|
|
156
|
+
* The declared step's executor was not registered, even after the app's
|
|
157
|
+
* declarations step ran again. Its message is the step's line in the run
|
|
158
|
+
* history, so it says what happened in the words a site owner reads.
|
|
159
|
+
*/
|
|
160
|
+
export declare class ServerStepUnavailableError extends Error {
|
|
161
|
+
readonly declaration: ServerStepDeclaration;
|
|
162
|
+
constructor(declaration: ServerStepDeclaration);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The executor for a step type, for a run that has reached one. See the
|
|
166
|
+
* module note for the three cases: registered answers it, declared but
|
|
167
|
+
* missing throws after the repair has had its turn, and neither answers
|
|
168
|
+
* `null`.
|
|
169
|
+
*/
|
|
170
|
+
export declare function pluginServerStepExecutor(type: string): Promise<RegisteredServerStepExecutor | null>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var _globalScope_EXECUTORS_KEY;
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2026 Aglyn LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/ import { getRegisteringPluginId } from "../app-utils/registering-plugin.js";
|
|
18
|
+
import { PLUGIN_SERVER_STEPS_DECLARED } from "./first-party-plugins.generated.js";
|
|
19
|
+
import { runPluginDeclarationsRepair } from "./plugin-declarations-repair.js";
|
|
20
|
+
/** Every server step a first-party plugin declares, in `plugins.config.json` order. */ export function declaredServerSteps() {
|
|
21
|
+
return PLUGIN_SERVER_STEPS_DECLARED;
|
|
22
|
+
}
|
|
23
|
+
/** The declaration of this step type, or `null` for one no plugin declares. */ export function declaredServerStep(type) {
|
|
24
|
+
var _PLUGIN_SERVER_STEPS_DECLARED_find;
|
|
25
|
+
return (_PLUGIN_SERVER_STEPS_DECLARED_find = PLUGIN_SERVER_STEPS_DECLARED.find((declaration)=>declaration.type === type)) != null ? _PLUGIN_SERVER_STEPS_DECLARED_find : null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* One table per process, on `globalThis` (AGL-3412): the app registers from
|
|
29
|
+
* `instrumentation.ts`, which Next compiles apart from the routes that run
|
|
30
|
+
* steps, and a module-scoped map would be filled in one copy and read empty
|
|
31
|
+
* in the other.
|
|
32
|
+
*/ const EXECUTORS_KEY = Symbol.for('@aglyn/aglyn:server-step-executors');
|
|
33
|
+
const globalScope = globalThis;
|
|
34
|
+
const executors = (_globalScope_EXECUTORS_KEY = globalScope[EXECUTORS_KEY]) != null ? _globalScope_EXECUTORS_KEY : globalScope[EXECUTORS_KEY] = new Map();
|
|
35
|
+
const PLAIN_TYPE = /^[a-z][A-Za-z0-9]*$/;
|
|
36
|
+
/**
|
|
37
|
+
* Registers the executor of one or more step types. Returns the unregister,
|
|
38
|
+
* which removes each type only while this executor still holds it.
|
|
39
|
+
*
|
|
40
|
+
* The owner is the plugin whose register fn is running, or the `pluginId`
|
|
41
|
+
* passed for a boot declaration, where the loader's marker is not set. A
|
|
42
|
+
* registration with neither is refused; so is a type another plugin declares
|
|
43
|
+
* or already holds, because two executors for one step would each write the
|
|
44
|
+
* other's records. The same plugin registering again replaces its own (a
|
|
45
|
+
* second surface, a repeated boot). Nothing is registered unless every type
|
|
46
|
+
* is accepted.
|
|
47
|
+
*/ export function registerServerStepExecutor(types, run, options) {
|
|
48
|
+
var _ref, _getRegisteringPluginId;
|
|
49
|
+
const pluginId = ((_ref = (_getRegisteringPluginId = getRegisteringPluginId()) != null ? _getRegisteringPluginId : options == null ? void 0 : options.pluginId) != null ? _ref : '').trim();
|
|
50
|
+
if (!pluginId) {
|
|
51
|
+
throw new Error('a server step executor was registered with no owner: pass { pluginId } ' + 'when registering outside a plugin register fn');
|
|
52
|
+
}
|
|
53
|
+
const list = [
|
|
54
|
+
...new Set(types.map((type)=>type.trim()))
|
|
55
|
+
];
|
|
56
|
+
if (!list.length) throw new Error(`"${pluginId}" registered a server step executor for no step type`);
|
|
57
|
+
for (const type of list){
|
|
58
|
+
if (!PLAIN_TYPE.test(type)) {
|
|
59
|
+
throw new Error(`"${pluginId}" registered a server step executor for "${type}", which is not a plain step type`);
|
|
60
|
+
}
|
|
61
|
+
const declared = declaredServerStep(type);
|
|
62
|
+
if (declared && declared.pluginId !== pluginId) {
|
|
63
|
+
throw new Error(`server step "${type}" is declared by "${declared.pluginId}"; refused an executor from "${pluginId}"`);
|
|
64
|
+
}
|
|
65
|
+
const held = executors.get(type);
|
|
66
|
+
if (held && held.pluginId !== pluginId) {
|
|
67
|
+
throw new Error(`server step "${type}" already has an executor from "${held.pluginId}"; refused "${pluginId}"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const entry = {
|
|
71
|
+
pluginId,
|
|
72
|
+
run
|
|
73
|
+
};
|
|
74
|
+
for (const type of list)executors.set(type, entry);
|
|
75
|
+
return ()=>{
|
|
76
|
+
for (const type of list)if (executors.get(type) === entry) executors.delete(type);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The executor registered for a step type, with its owner, or `null`. Never repairs. */ export function registeredServerStepExecutor(type) {
|
|
80
|
+
var _executors_get;
|
|
81
|
+
return (_executors_get = executors.get(type)) != null ? _executors_get : null;
|
|
82
|
+
}
|
|
83
|
+
/** Only for specs: forgets every registered executor. */ export function resetServerStepExecutorsForTests() {
|
|
84
|
+
executors.clear();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The declared step's executor was not registered, even after the app's
|
|
88
|
+
* declarations step ran again. Its message is the step's line in the run
|
|
89
|
+
* history, so it says what happened in the words a site owner reads.
|
|
90
|
+
*/ export class ServerStepUnavailableError extends Error {
|
|
91
|
+
constructor(declaration){
|
|
92
|
+
super(`the "${declaration.type}" step did not run: the plugin that runs it ` + `("${declaration.pluginId}") is not loaded on this server`), this.declaration = declaration;
|
|
93
|
+
this.name = 'ServerStepUnavailableError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The executor for a step type, for a run that has reached one. See the
|
|
98
|
+
* module note for the three cases: registered answers it, declared but
|
|
99
|
+
* missing throws after the repair has had its turn, and neither answers
|
|
100
|
+
* `null`.
|
|
101
|
+
*/ export async function pluginServerStepExecutor(type) {
|
|
102
|
+
const registered = executors.get(type);
|
|
103
|
+
if (registered) return registered;
|
|
104
|
+
const declared = declaredServerStep(type);
|
|
105
|
+
if (!declared) return null;
|
|
106
|
+
try {
|
|
107
|
+
await runPluginDeclarationsRepair();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('[server-steps] the declarations repair failed', error);
|
|
110
|
+
}
|
|
111
|
+
const repaired = executors.get(type);
|
|
112
|
+
if (!repaired) throw new ServerStepUnavailableError(declared);
|
|
113
|
+
return repaired;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=plugin-server-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-server-steps.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 { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport { PLUGIN_SERVER_STEPS_DECLARED } from './first-party-plugins.generated'\nimport { runPluginDeclarationsRepair } from './plugin-declarations-repair'\n\n/**\n * A SERVER STEP ANOTHER PLUGIN RUNS (AGL-3080).\n *\n * An interaction's steps are the platform's client steps plus whatever steps\n * the plugins add (`site-interactions.ts`), and every step that is not a\n * client step is the server's to run. The plugin that runs a server run — the\n * automation engine — knows its own steps. A step that acts on ANOTHER\n * plugin's records is that plugin's: writing a dataset row is the data\n * plugin's, moving a contact's stage is the CRM's. The engine used to carry\n * each of those writes itself, which made it the keeper of every plugin's\n * storage.\n *\n * So the plugin that owns a step REGISTERS ITS EXECUTOR here, by step type,\n * and the engine hands it the step when a run reaches one. The engine keeps\n * what every step shares — the step's guard, the run's order, its history,\n * the nesting cap — and the executor does the step's one write. Neither\n * imports the other: both meet at this module, which names no plugin, so a\n * marketplace plugin adds a step the same way a first-party one does.\n *\n * ## Declared, then registered — and an absent executor is refused\n *\n * The executor is registered from the owning plugin's `serverDeclarations`\n * entry, which every app runs at boot. An empty registry must not read as an\n * answer: a step whose executor never registered would otherwise fall through\n * the engine as a step nobody runs, and a run history would say the record\n * was written when it was not.\n *\n * So a first-party plugin also DECLARES the steps it runs, under\n * `serverSteps` in `plugins.config.json`, compiled into core. The three cases\n * are kept apart:\n *\n * - registered — the executor runs the step, declared or not (a marketplace\n * plugin's steps are registered and never compiled);\n * - declared and NOT registered — the boot failed. The app's declarations\n * step is run again ({@link runPluginDeclarationsRepair}); if the executor\n * is still missing, {@link pluginServerStepExecutor} THROWS\n * {@link ServerStepUnavailableError}, which the engine records as the\n * step's failure;\n * - neither — no plugin runs the type, and the caller answers `null` as it\n * would for any step it does not know.\n *\n * A type the engine runs itself never reaches this registry, so a\n * registration cannot replace one of the engine's own steps.\n *\n * Reached by path, never through a barrel: only server code asks.\n */\n\n/** The automation a step belongs to, as its history and its records name it. */\nexport interface ServerStepRunRef {\n /** Which kind of automation is running — the engine's own vocabulary. */\n kind: string\n /** The automation's document id. */\n id: string\n /** Its name at the time of the run. */\n name: string\n}\n\n/** One step, handed to the plugin that runs it. */\nexport interface ServerStepRequest {\n /** The site the run is on. Every write is scoped to what this site may see. */\n hostId: string\n /**\n * The owning organization's billing document, already read by the gate\n * that admitted the run, and its id beside it — so an executor gating on\n * the plan or counting against a cap pays no second read. Null when the\n * site has no resolvable organization, which every gate reads as Free.\n */\n org: unknown\n orgId: string | null\n /** The automation whose step this is. */\n run: ServerStepRunRef\n /** The event the run is answering. */\n event: string\n /** The event's payload: the values a step reads. */\n payload: Record<string, unknown>\n /** The step exactly as it is stored. */\n step: { type: string; [field: string]: unknown }\n}\n\n/**\n * What one step did.\n *\n * Nothing set is a step that did its work. `error` is a step that did not —\n * the run records it and goes on to the next step, so an executor answers a\n * refusal rather than throwing one; a throw is read the same way.\n */\nexport interface ServerStepAnswer {\n /** Why nothing was written, when nothing was — a line of the run history. */\n error?: string\n /** The one fact worth carrying into the run summary: a record's name, a status. */\n detail?: string\n /**\n * An event this step's write earned, for the ENGINE to raise. Not raised\n * by the executor: an automation whose step causes the event it listens\n * for would otherwise run until a meter stopped it, and only the engine\n * holds the nesting cap that stops it first.\n */\n emit?: { event: string; payload: Record<string, unknown> }\n}\n\n/** Runs one step of the types it was registered for. */\nexport type ServerStepExecutor = (request: ServerStepRequest) => Promise<ServerStepAnswer>\n\n/** The compiled declaration: which plugin runs which step type. */\nexport interface ServerStepDeclaration {\n pluginId: string\n /** The stored step `type`. */\n type: string\n}\n\n/** Every server step a first-party plugin declares, in `plugins.config.json` order. */\nexport function declaredServerSteps(): readonly ServerStepDeclaration[] {\n return PLUGIN_SERVER_STEPS_DECLARED\n}\n\n/** The declaration of this step type, or `null` for one no plugin declares. */\nexport function declaredServerStep(type: string): ServerStepDeclaration | null {\n return PLUGIN_SERVER_STEPS_DECLARED.find((declaration) => declaration.type === type) ?? null\n}\n\n/** A registered executor, with the plugin it belongs to. */\nexport interface RegisteredServerStepExecutor {\n pluginId: string\n run: ServerStepExecutor\n}\n\n/**\n * One table per process, on `globalThis` (AGL-3412): the app registers from\n * `instrumentation.ts`, which Next compiles apart from the routes that run\n * steps, and a module-scoped map would be filled in one copy and read empty\n * in the other.\n */\nconst EXECUTORS_KEY = Symbol.for('@aglyn/aglyn:server-step-executors')\n\nconst globalScope = globalThis as typeof globalThis & {\n [EXECUTORS_KEY]?: Map<string, RegisteredServerStepExecutor>\n}\n\nconst executors: Map<string, RegisteredServerStepExecutor> =\n globalScope[EXECUTORS_KEY] ?? (globalScope[EXECUTORS_KEY] = new Map())\n\nconst PLAIN_TYPE = /^[a-z][A-Za-z0-9]*$/\n\n/**\n * Registers the executor of one or more step types. Returns the unregister,\n * which removes each type only while this executor still holds it.\n *\n * The owner is the plugin whose register fn is running, or the `pluginId`\n * passed for a boot declaration, where the loader's marker is not set. A\n * registration with neither is refused; so is a type another plugin declares\n * or already holds, because two executors for one step would each write the\n * other's records. The same plugin registering again replaces its own (a\n * second surface, a repeated boot). Nothing is registered unless every type\n * is accepted.\n */\nexport function registerServerStepExecutor(\n types: readonly string[],\n run: ServerStepExecutor,\n options?: { pluginId?: string },\n): () => void {\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n if (!pluginId) {\n throw new Error(\n 'a server step executor was registered with no owner: pass { pluginId } ' +\n 'when registering outside a plugin register fn',\n )\n }\n const list = [...new Set(types.map((type) => type.trim()))]\n if (!list.length) throw new Error(`\"${pluginId}\" registered a server step executor for no step type`)\n for (const type of list) {\n if (!PLAIN_TYPE.test(type)) {\n throw new Error(`\"${pluginId}\" registered a server step executor for \"${type}\", which is not a plain step type`)\n }\n const declared = declaredServerStep(type)\n if (declared && declared.pluginId !== pluginId) {\n throw new Error(\n `server step \"${type}\" is declared by \"${declared.pluginId}\"; refused an executor from \"${pluginId}\"`,\n )\n }\n const held = executors.get(type)\n if (held && held.pluginId !== pluginId) {\n throw new Error(\n `server step \"${type}\" already has an executor from \"${held.pluginId}\"; refused \"${pluginId}\"`,\n )\n }\n }\n const entry: RegisteredServerStepExecutor = { pluginId, run }\n for (const type of list) executors.set(type, entry)\n return () => {\n for (const type of list) if (executors.get(type) === entry) executors.delete(type)\n }\n}\n\n/** The executor registered for a step type, with its owner, or `null`. Never repairs. */\nexport function registeredServerStepExecutor(type: string): RegisteredServerStepExecutor | null {\n return executors.get(type) ?? null\n}\n\n/** Only for specs: forgets every registered executor. */\nexport function resetServerStepExecutorsForTests(): void {\n executors.clear()\n}\n\n/**\n * The declared step's executor was not registered, even after the app's\n * declarations step ran again. Its message is the step's line in the run\n * history, so it says what happened in the words a site owner reads.\n */\nexport class ServerStepUnavailableError extends Error {\n constructor(readonly declaration: ServerStepDeclaration) {\n super(\n `the \"${declaration.type}\" step did not run: the plugin that runs it ` +\n `(\"${declaration.pluginId}\") is not loaded on this server`,\n )\n this.name = 'ServerStepUnavailableError'\n }\n}\n\n/**\n * The executor for a step type, for a run that has reached one. See the\n * module note for the three cases: registered answers it, declared but\n * missing throws after the repair has had its turn, and neither answers\n * `null`.\n */\nexport async function pluginServerStepExecutor(\n type: string,\n): Promise<RegisteredServerStepExecutor | null> {\n const registered = executors.get(type)\n if (registered) return registered\n const declared = declaredServerStep(type)\n if (!declared) return null\n try {\n await runPluginDeclarationsRepair()\n } catch (error) {\n console.error('[server-steps] the declarations repair failed', error)\n }\n const repaired = executors.get(type)\n if (!repaired) throw new ServerStepUnavailableError(declared)\n return repaired\n}\n"],"names":["globalScope","getRegisteringPluginId","PLUGIN_SERVER_STEPS_DECLARED","runPluginDeclarationsRepair","declaredServerSteps","declaredServerStep","type","find","declaration","EXECUTORS_KEY","Symbol","for","globalThis","executors","Map","PLAIN_TYPE","registerServerStepExecutor","types","run","options","pluginId","trim","Error","list","Set","map","length","test","declared","held","get","entry","set","delete","registeredServerStepExecutor","resetServerStepExecutorsForTests","clear","ServerStepUnavailableError","name","pluginServerStepExecutor","registered","error","console","repaired"],"mappings":"IAgKEA;AAhKF;;;;;;;;;;;;;;;CAeC,GAED,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SAASC,4BAA4B,QAAQ,qCAAiC;AAC9E,SAASC,2BAA2B,QAAQ,kCAA8B;AAgH1E,qFAAqF,GACrF,OAAO,SAASC;IACd,OAAOF;AACT;AAEA,6EAA6E,GAC7E,OAAO,SAASG,mBAAmBC,IAAY;QACtCJ;IAAP,QAAOA,qCAAAA,6BAA6BK,IAAI,CAAC,CAACC,cAAgBA,YAAYF,IAAI,KAAKA,iBAAxEJ,qCAAiF;AAC1F;AAQA;;;;;CAKC,GACD,MAAMO,gBAAgBC,OAAOC,GAAG,CAAC;AAEjC,MAAMX,cAAcY;AAIpB,MAAMC,aACJb,6BAAAA,WAAW,CAACS,cAAc,YAA1BT,6BAA+BA,WAAW,CAACS,cAAc,GAAG,IAAIK;AAElE,MAAMC,aAAa;AAEnB;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,2BACdC,KAAwB,EACxBC,GAAuB,EACvBC,OAA+B;QAEblB,MAAAA;IAAlB,MAAMmB,WAAW,EAACnB,QAAAA,0BAAAA,oCAAAA,0BAA4BkB,2BAAAA,QAASC,QAAQ,YAA7CnB,OAAiD,IAAIoB,IAAI;IAC3E,IAAI,CAACD,UAAU;QACb,MAAM,IAAIE,MACR,4EACE;IAEN;IACA,MAAMC,OAAO;WAAI,IAAIC,IAAIP,MAAMQ,GAAG,CAAC,CAACnB,OAASA,KAAKe,IAAI;KAAK;IAC3D,IAAI,CAACE,KAAKG,MAAM,EAAE,MAAM,IAAIJ,MAAM,CAAC,CAAC,EAAEF,SAAS,oDAAoD,CAAC;IACpG,KAAK,MAAMd,QAAQiB,KAAM;QACvB,IAAI,CAACR,WAAWY,IAAI,CAACrB,OAAO;YAC1B,MAAM,IAAIgB,MAAM,CAAC,CAAC,EAAEF,SAAS,yCAAyC,EAAEd,KAAK,iCAAiC,CAAC;QACjH;QACA,MAAMsB,WAAWvB,mBAAmBC;QACpC,IAAIsB,YAAYA,SAASR,QAAQ,KAAKA,UAAU;YAC9C,MAAM,IAAIE,MACR,CAAC,aAAa,EAAEhB,KAAK,kBAAkB,EAAEsB,SAASR,QAAQ,CAAC,6BAA6B,EAAEA,SAAS,CAAC,CAAC;QAEzG;QACA,MAAMS,OAAOhB,UAAUiB,GAAG,CAACxB;QAC3B,IAAIuB,QAAQA,KAAKT,QAAQ,KAAKA,UAAU;YACtC,MAAM,IAAIE,MACR,CAAC,aAAa,EAAEhB,KAAK,gCAAgC,EAAEuB,KAAKT,QAAQ,CAAC,YAAY,EAAEA,SAAS,CAAC,CAAC;QAElG;IACF;IACA,MAAMW,QAAsC;QAAEX;QAAUF;IAAI;IAC5D,KAAK,MAAMZ,QAAQiB,KAAMV,UAAUmB,GAAG,CAAC1B,MAAMyB;IAC7C,OAAO;QACL,KAAK,MAAMzB,QAAQiB,KAAM,IAAIV,UAAUiB,GAAG,CAACxB,UAAUyB,OAAOlB,UAAUoB,MAAM,CAAC3B;IAC/E;AACF;AAEA,uFAAuF,GACvF,OAAO,SAAS4B,6BAA6B5B,IAAY;QAChDO;IAAP,QAAOA,iBAAAA,UAAUiB,GAAG,CAACxB,iBAAdO,iBAAuB;AAChC;AAEA,uDAAuD,GACvD,OAAO,SAASsB;IACdtB,UAAUuB,KAAK;AACjB;AAEA;;;;CAIC,GACD,OAAO,MAAMC,mCAAmCf;IAC9C,YAAY,AAASd,WAAkC,CAAE;QACvD,KAAK,CACH,CAAC,KAAK,EAAEA,YAAYF,IAAI,CAAC,4CAA4C,CAAC,GACpE,CAAC,EAAE,EAAEE,YAAYY,QAAQ,CAAC,+BAA+B,CAAC,QAH3CZ,cAAAA;QAKnB,IAAI,CAAC8B,IAAI,GAAG;IACd;AACF;AAEA;;;;;CAKC,GACD,OAAO,eAAeC,yBACpBjC,IAAY;IAEZ,MAAMkC,aAAa3B,UAAUiB,GAAG,CAACxB;IACjC,IAAIkC,YAAY,OAAOA;IACvB,MAAMZ,WAAWvB,mBAAmBC;IACpC,IAAI,CAACsB,UAAU,OAAO;IACtB,IAAI;QACF,MAAMzB;IACR,EAAE,OAAOsC,OAAO;QACdC,QAAQD,KAAK,CAAC,iDAAiDA;IACjE;IACA,MAAME,WAAW9B,UAAUiB,GAAG,CAACxB;IAC/B,IAAI,CAACqC,UAAU,MAAM,IAAIN,2BAA2BT;IACpD,OAAOe;AACT"}
|
|
@@ -61,6 +61,23 @@ export interface PluginSiteBundleSectionDeclaration {
|
|
|
61
61
|
key: string;
|
|
62
62
|
/** The most items one bundle carries; a restore reads no more. */
|
|
63
63
|
limit: number;
|
|
64
|
+
/**
|
|
65
|
+
* What a site package calls each item (AGL-3533): its kind, the plural
|
|
66
|
+
* label the import screen groups them under, and the field an item with a
|
|
67
|
+
* new id is matched by. Its references are the plugin's to name, through
|
|
68
|
+
* the section's registered {@link PluginSiteBundleSection.package} hooks.
|
|
69
|
+
*/
|
|
70
|
+
package: {
|
|
71
|
+
kind: string;
|
|
72
|
+
label: string;
|
|
73
|
+
nameField?: string;
|
|
74
|
+
slugField?: string;
|
|
75
|
+
/** Node props that place one of its items in a design, as a host collection's declare them. */
|
|
76
|
+
placements?: ReadonlyArray<{
|
|
77
|
+
componentId?: string;
|
|
78
|
+
prop: string;
|
|
79
|
+
}>;
|
|
80
|
+
};
|
|
64
81
|
}
|
|
65
82
|
/** A declaration with the plugin that made it. */
|
|
66
83
|
export type ResolvedPluginSiteBundleSectionDeclaration = PluginSiteBundleSectionDeclaration & {
|
|
@@ -104,8 +121,31 @@ export interface SiteBundleImportRequest extends SiteBundleRestoreRequest {
|
|
|
104
121
|
}
|
|
105
122
|
/** A row the restore reports without refusing: a document restored as it was, and why it is worth a look. */
|
|
106
123
|
export type SiteBundleReportRow = Record<string, unknown>;
|
|
124
|
+
/** An item another item names: its package kind and id. */
|
|
125
|
+
export interface SiteBundleItemReference {
|
|
126
|
+
kind: string;
|
|
127
|
+
id: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A section's answers about its items as package items (AGL-3533): what each
|
|
131
|
+
* one refers to — another of its own items, a page, a media file — and the
|
|
132
|
+
* item with those references moved to new ids, for an item kept beside an
|
|
133
|
+
* existing one or mapped onto one the site already holds.
|
|
134
|
+
*/
|
|
135
|
+
export interface PluginSiteBundleSectionPackage {
|
|
136
|
+
/** The site items this item names, by package kind and id. */
|
|
137
|
+
dependencies(item: SiteBundleItem): SiteBundleItemReference[];
|
|
138
|
+
/**
|
|
139
|
+
* The item with every reference in `idMap` moved: `idMap` maps an item key
|
|
140
|
+
* (`<kind>/<id>`) to the id it now has, or to `null` when the reference is
|
|
141
|
+
* dropped. The item's own `$id` is the restore's to set, not this hook's.
|
|
142
|
+
*/
|
|
143
|
+
remapIds(item: SiteBundleItem, idMap: ReadonlyMap<string, string | null>): SiteBundleItem;
|
|
144
|
+
}
|
|
107
145
|
/** A plugin's answers for one section. */
|
|
108
146
|
export interface PluginSiteBundleSection {
|
|
147
|
+
/** Its items as package items; required, since every section declares a package kind. */
|
|
148
|
+
package: PluginSiteBundleSectionPackage;
|
|
109
149
|
/** The site's share, read whole or not at all: throw rather than return a short list. */
|
|
110
150
|
export(request: SiteBundleRequest): Promise<SiteBundleItem[]>;
|
|
111
151
|
/**
|
|
@@ -38,6 +38,7 @@ const sections = (_globalScope_SECTIONS_KEY = globalScope[SECTIONS_KEY]) != null
|
|
|
38
38
|
* replaces its answers.
|
|
39
39
|
*/ export function registerPluginSiteBundleSection(key, section, options) {
|
|
40
40
|
var _ref, _getRegisteringPluginId;
|
|
41
|
+
var _section_package, _section_package1;
|
|
41
42
|
const name = key.trim();
|
|
42
43
|
const pluginId = ((_ref = (_getRegisteringPluginId = getRegisteringPluginId()) != null ? _getRegisteringPluginId : options == null ? void 0 : options.pluginId) != null ? _ref : '').trim();
|
|
43
44
|
if (!pluginId) {
|
|
@@ -50,6 +51,9 @@ const sections = (_globalScope_SECTIONS_KEY = globalScope[SECTIONS_KEY]) != null
|
|
|
50
51
|
if (declared.pluginId !== pluginId) {
|
|
51
52
|
throw new Error(`site bundle section "${name}" is declared by "${declared.pluginId}"; ` + `refused "${pluginId}"`);
|
|
52
53
|
}
|
|
54
|
+
if (typeof ((_section_package = section.package) == null ? void 0 : _section_package.dependencies) !== 'function' || typeof ((_section_package1 = section.package) == null ? void 0 : _section_package1.remapIds) !== 'function') {
|
|
55
|
+
throw new Error(`site bundle section "${name}" declares package kind "${declared.package.kind}" ` + 'and registers no package hooks (dependencies, remapIds), so a package ' + 'could neither list what its items need nor keep a copy beside an existing one');
|
|
56
|
+
}
|
|
53
57
|
sections.set(name, {
|
|
54
58
|
pluginId,
|
|
55
59
|
section
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-bundle.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 { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport { PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED } from './first-party-plugins.generated'\nimport { runPluginDeclarationsRepair } from './plugin-declarations-repair'\n\n/**\n * A plugin's SECTION of the whole-site backup (AGL-3080): what it carries in\n * the bundle and restores from it, when a host collection's `siteExport`\n * cannot say so.\n *\n * A plain host collection is copied by the export and restore routes\n * themselves (`plugin-site-export.ts`). Some plugin data is not that shape:\n * it lives under the ORGANIZATION and is narrowed to the site being backed up,\n * it carries a subcollection, a restore has to validate it against its own\n * model and derive what the model implies, and its count is sold as an add-on\n * rather than read off the plan. Only the plugin knows any of that. So the\n * plugin declares the section and answers for it: the export asks it for the\n * site's share, and the restore asks it — before the first write — whether\n * the bundle would cross what the organization has paid for, then hands it the\n * bundle's items and the restore's writer.\n *\n * ## Declared, then registered — and an absent section is refused\n *\n * The plugin declares the section in `plugins.config.json`\n * (`siteBundleSections`: the bundle key and the most items it carries), which\n * the generator compiles, and registers the answer from its\n * `serverDeclarations` entry. A backup that silently lacks a section is worse\n * than a failed one — the file looks whole until the day it is restored — so\n * a section declared and not registered is not read as \"nothing to carry\":\n * {@link resolveSiteBundleSections} runs the app's declarations step again,\n * and throws if the section is still missing, which fails the export or the\n * restore out loud.\n *\n * ## What the restore owns\n *\n * The section writes through {@link SiteBundleImportRequest.write}, never\n * with a writer of its own: the restore's chunked batches, its document count\n * and its all-or-nothing refusal are the restore's, and a write that went\n * around them would land after a refusal or be missing from the total. The\n * restore's own stamps (`createdAt`, `updatedAt`) come from\n * {@link SiteBundleImportRequest.stamps}, so a restored document is dated the\n * way every other one is.\n *\n * Reached by its own subpath, never the barrel: its readers are the two\n * console routes and the plugins that answer them.\n */\n\n/** A section as declared: its key in the bundle and the most items it carries. */\nexport interface PluginSiteBundleSectionDeclaration {\n /** The bundle's top-level key for this section's items, e.g. `datasets`. */\n key: string\n /** The most items one bundle carries; a restore reads no more. */\n limit: number\n}\n\n/** A declaration with the plugin that made it. */\nexport type ResolvedPluginSiteBundleSectionDeclaration =\n PluginSiteBundleSectionDeclaration & { pluginId: string }\n\n/** One item of a section, as the bundle carries it: a document with its `$id`. */\nexport type SiteBundleItem = Record<string, any>\n\n/** Whose backup this is. */\nexport interface SiteBundleRequest {\n hostId: string\n /**\n * The site's organization, or `null` for a site with none — which holds no\n * organization data, a known-empty answer rather than a failure.\n */\n orgId: string | null\n /** The section's declared limit: the most items one bundle carries. */\n limit: number\n}\n\n/** The restore's question: this bundle's items, for this site. */\nexport interface SiteBundleRestoreRequest extends SiteBundleRequest {\n /** The organization's document, for the plan and add-ons a count is met against. */\n org: unknown\n /** The bundle's items under the section's key, already capped at its declared limit. */\n items: readonly SiteBundleItem[]\n}\n\n/** What the restore hands a section to write with. */\nexport interface SiteBundleImportRequest extends SiteBundleRestoreRequest {\n /**\n * Writes one document, whole (`merge: false`), by its full path\n * (`orgs/{orgId}/…`), on the restore's batches and counted in its total.\n */\n write(documentPath: string, data: Record<string, unknown>): Promise<void>\n /** The restore's own stamps for a document it writes: its creation and update times. */\n stamps(): Record<string, unknown>\n /**\n * Loads every plugin's console server surface, for a section that checks\n * what it restores against something other plugins register there (a\n * custom field type). Costs a load, so a section asks only when it needs to.\n */\n loadPluginSurfaces(): Promise<void>\n}\n\n/** A row the restore reports without refusing: a document restored as it was, and why it is worth a look. */\nexport type SiteBundleReportRow = Record<string, unknown>\n\n/** A plugin's answers for one section. */\nexport interface PluginSiteBundleSection {\n /** The site's share, read whole or not at all: throw rather than return a short list. */\n export(request: SiteBundleRequest): Promise<SiteBundleItem[]>\n /**\n * Before the restore writes anything: the sentence it answers 403 with when\n * restoring these items would cross what the organization may hold, or\n * `null`. A bundle refused here writes nothing at all.\n */\n refusal?(request: SiteBundleRestoreRequest): Promise<string | null>\n /** Writes the items back through `request.write`; answers the rows worth reporting. */\n import(request: SiteBundleImportRequest): Promise<readonly SiteBundleReportRow[]>\n}\n\ninterface Registered {\n pluginId: string\n section: PluginSiteBundleSection\n}\n\n/**\n * One table per process, on `globalThis` (AGL-3412): a plugin registers from\n * its declarations at boot, which Next compiles apart from the routes that\n * read, and a module-scoped map would be filled in one copy and read empty in\n * the other.\n */\nconst SECTIONS_KEY = Symbol.for('@aglyn/aglyn:site-bundle-sections')\n\nconst globalScope = globalThis as typeof globalThis & {\n [SECTIONS_KEY]?: Map<string, Registered>\n}\n\nconst sections: Map<string, Registered> =\n globalScope[SECTIONS_KEY] ?? (globalScope[SECTIONS_KEY] = new Map())\n\n/** Every declared section, in config order — the order the bundle carries them. */\nexport function listDeclaredSiteBundleSections(): readonly ResolvedPluginSiteBundleSectionDeclaration[] {\n return PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED\n}\n\n/**\n * Registers a plugin's answers for a section it declared. The owner is the\n * plugin whose register fn is running, or the `pluginId` passed from a boot\n * declaration. Refused: no owner, a key nobody declared (only a declared\n * section is ever read, so an undeclared one would be carried by nothing),\n * and a key another plugin declared. The same plugin registering again\n * replaces its answers.\n */\nexport function registerPluginSiteBundleSection(\n key: string,\n section: PluginSiteBundleSection,\n options?: { pluginId?: string },\n): void {\n const name = key.trim()\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n if (!pluginId) {\n throw new Error(\n `site bundle section \"${name}\" registered with no owner: pass { pluginId } ` +\n 'when registering outside a plugin register fn',\n )\n }\n const declared = listDeclaredSiteBundleSections().find((one) => one.key === name)\n if (!declared) {\n throw new Error(\n `site bundle section \"${name}\" is not declared in plugins.config.json ` +\n '(siteBundleSections), so no export would ever carry it',\n )\n }\n if (declared.pluginId !== pluginId) {\n throw new Error(\n `site bundle section \"${name}\" is declared by \"${declared.pluginId}\"; ` +\n `refused \"${pluginId}\"`,\n )\n }\n sections.set(name, { pluginId, section })\n}\n\n/** A declared section with the answers its plugin registered. */\nexport type ResolvedSiteBundleSection = ResolvedPluginSiteBundleSectionDeclaration & {\n section: PluginSiteBundleSection\n}\n\n/**\n * Every declared section with its answers, in config order. A declared\n * section with nothing registered runs the app's declarations step once and\n * asks again; still missing, this THROWS naming it — an export that carried\n * the rest would be a backup missing a section with nothing to say so.\n */\nexport async function resolveSiteBundleSections(): Promise<ResolvedSiteBundleSection[]> {\n const missing = () =>\n listDeclaredSiteBundleSections().filter((declared) => !sections.has(declared.key))\n if (missing().length) await runPluginDeclarationsRepair()\n const absent = missing()\n if (absent.length) {\n throw new Error(\n `[plugins] site bundle section(s) ${absent.map((one) => `\"${one.key}\" (${one.pluginId})`).join(', ')} ` +\n 'declared and not registered in this process',\n )\n }\n return listDeclaredSiteBundleSections().map((declared) => ({\n ...declared,\n section: (sections.get(declared.key) as Registered).section,\n }))\n}\n\n/** Only for specs: forgets every registered section. */\nexport function resetSiteBundleSectionsForTests(): void {\n sections.clear()\n}\n"],"names":["globalScope","getRegisteringPluginId","PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED","runPluginDeclarationsRepair","SECTIONS_KEY","Symbol","for","globalThis","sections","Map","listDeclaredSiteBundleSections","registerPluginSiteBundleSection","key","section","options","name","trim","pluginId","Error","declared","find","one","set","resolveSiteBundleSections","missing","filter","has","length","absent","map","join","get","resetSiteBundleSectionsForTests","clear"],"mappings":";IAsJEA;AAtJF;;;;;;;;;;;;;;;CAeC,GAED,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SAASC,oCAAoC,QAAQ,qCAAiC;AACtF,SAASC,2BAA2B,QAAQ,kCAA8B;AAsH1E;;;;;CAKC,GACD,MAAMC,eAAeC,OAAOC,GAAG,CAAC;AAEhC,MAAMN,cAAcO;AAIpB,MAAMC,YACJR,4BAAAA,WAAW,CAACI,aAAa,YAAzBJ,4BAA8BA,WAAW,CAACI,aAAa,GAAG,IAAIK;AAEhE,iFAAiF,GACjF,OAAO,SAASC;IACd,OAAOR;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASS,gCACdC,GAAW,EACXC,OAAgC,EAChCC,OAA+B;QAGbb,MAAAA;IADlB,MAAMc,OAAOH,IAAII,IAAI;IACrB,MAAMC,WAAW,EAAChB,QAAAA,0BAAAA,oCAAAA,0BAA4Ba,2BAAAA,QAASG,QAAQ,YAA7ChB,OAAiD,IAAIe,IAAI;IAC3E,IAAI,CAACC,UAAU;QACb,MAAM,IAAIC,MACR,CAAC,qBAAqB,EAAEH,KAAK,8CAA8C,CAAC,GAC1E;IAEN;IACA,MAAMI,WAAWT,iCAAiCU,IAAI,CAAC,CAACC,MAAQA,IAAIT,GAAG,KAAKG;IAC5E,IAAI,CAACI,UAAU;QACb,MAAM,IAAID,MACR,CAAC,qBAAqB,EAAEH,KAAK,yCAAyC,CAAC,GACrE;IAEN;IACA,IAAII,SAASF,QAAQ,KAAKA,UAAU;QAClC,MAAM,IAAIC,MACR,CAAC,qBAAqB,EAAEH,KAAK,kBAAkB,EAAEI,SAASF,QAAQ,CAAC,GAAG,CAAC,GACrE,CAAC,SAAS,EAAEA,SAAS,CAAC,CAAC;IAE7B;IACAT,SAASc,GAAG,CAACP,MAAM;QAAEE;QAAUJ;IAAQ;AACzC;AAOA;;;;;CAKC,GACD,OAAO,eAAeU;IACpB,MAAMC,UAAU,IACdd,iCAAiCe,MAAM,CAAC,CAACN,WAAa,CAACX,SAASkB,GAAG,CAACP,SAASP,GAAG;IAClF,IAAIY,UAAUG,MAAM,EAAE,MAAMxB;IAC5B,MAAMyB,SAASJ;IACf,IAAII,OAAOD,MAAM,EAAE;QACjB,MAAM,IAAIT,MACR,CAAC,iCAAiC,EAAEU,OAAOC,GAAG,CAAC,CAACR,MAAQ,CAAC,CAAC,EAAEA,IAAIT,GAAG,CAAC,GAAG,EAAES,IAAIJ,QAAQ,CAAC,CAAC,CAAC,EAAEa,IAAI,CAAC,MAAM,CAAC,CAAC,GACrG;IAEN;IACA,OAAOpB,iCAAiCmB,GAAG,CAAC,CAACV,WAAc,aACtDA;YACHN,SAAS,AAACL,SAASuB,GAAG,CAACZ,SAASP,GAAG,EAAiBC,OAAO;;AAE/D;AAEA,sDAAsD,GACtD,OAAO,SAASmB;IACdxB,SAASyB,KAAK;AAChB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-bundle.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 { getRegisteringPluginId } from '../app-utils/registering-plugin'\nimport { PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED } from './first-party-plugins.generated'\nimport { runPluginDeclarationsRepair } from './plugin-declarations-repair'\n\n/**\n * A plugin's SECTION of the whole-site backup (AGL-3080): what it carries in\n * the bundle and restores from it, when a host collection's `siteExport`\n * cannot say so.\n *\n * A plain host collection is copied by the export and restore routes\n * themselves (`plugin-site-export.ts`). Some plugin data is not that shape:\n * it lives under the ORGANIZATION and is narrowed to the site being backed up,\n * it carries a subcollection, a restore has to validate it against its own\n * model and derive what the model implies, and its count is sold as an add-on\n * rather than read off the plan. Only the plugin knows any of that. So the\n * plugin declares the section and answers for it: the export asks it for the\n * site's share, and the restore asks it — before the first write — whether\n * the bundle would cross what the organization has paid for, then hands it the\n * bundle's items and the restore's writer.\n *\n * ## Declared, then registered — and an absent section is refused\n *\n * The plugin declares the section in `plugins.config.json`\n * (`siteBundleSections`: the bundle key and the most items it carries), which\n * the generator compiles, and registers the answer from its\n * `serverDeclarations` entry. A backup that silently lacks a section is worse\n * than a failed one — the file looks whole until the day it is restored — so\n * a section declared and not registered is not read as \"nothing to carry\":\n * {@link resolveSiteBundleSections} runs the app's declarations step again,\n * and throws if the section is still missing, which fails the export or the\n * restore out loud.\n *\n * ## What the restore owns\n *\n * The section writes through {@link SiteBundleImportRequest.write}, never\n * with a writer of its own: the restore's chunked batches, its document count\n * and its all-or-nothing refusal are the restore's, and a write that went\n * around them would land after a refusal or be missing from the total. The\n * restore's own stamps (`createdAt`, `updatedAt`) come from\n * {@link SiteBundleImportRequest.stamps}, so a restored document is dated the\n * way every other one is.\n *\n * Reached by its own subpath, never the barrel: its readers are the two\n * console routes and the plugins that answer them.\n */\n\n/** A section as declared: its key in the bundle and the most items it carries. */\nexport interface PluginSiteBundleSectionDeclaration {\n /** The bundle's top-level key for this section's items, e.g. `datasets`. */\n key: string\n /** The most items one bundle carries; a restore reads no more. */\n limit: number\n /**\n * What a site package calls each item (AGL-3533): its kind, the plural\n * label the import screen groups them under, and the field an item with a\n * new id is matched by. Its references are the plugin's to name, through\n * the section's registered {@link PluginSiteBundleSection.package} hooks.\n */\n package: {\n kind: string\n label: string\n nameField?: string\n slugField?: string\n /** Node props that place one of its items in a design, as a host collection's declare them. */\n placements?: ReadonlyArray<{ componentId?: string; prop: string }>\n }\n}\n\n/** A declaration with the plugin that made it. */\nexport type ResolvedPluginSiteBundleSectionDeclaration =\n PluginSiteBundleSectionDeclaration & { pluginId: string }\n\n/** One item of a section, as the bundle carries it: a document with its `$id`. */\nexport type SiteBundleItem = Record<string, any>\n\n/** Whose backup this is. */\nexport interface SiteBundleRequest {\n hostId: string\n /**\n * The site's organization, or `null` for a site with none — which holds no\n * organization data, a known-empty answer rather than a failure.\n */\n orgId: string | null\n /** The section's declared limit: the most items one bundle carries. */\n limit: number\n}\n\n/** The restore's question: this bundle's items, for this site. */\nexport interface SiteBundleRestoreRequest extends SiteBundleRequest {\n /** The organization's document, for the plan and add-ons a count is met against. */\n org: unknown\n /** The bundle's items under the section's key, already capped at its declared limit. */\n items: readonly SiteBundleItem[]\n}\n\n/** What the restore hands a section to write with. */\nexport interface SiteBundleImportRequest extends SiteBundleRestoreRequest {\n /**\n * Writes one document, whole (`merge: false`), by its full path\n * (`orgs/{orgId}/…`), on the restore's batches and counted in its total.\n */\n write(documentPath: string, data: Record<string, unknown>): Promise<void>\n /** The restore's own stamps for a document it writes: its creation and update times. */\n stamps(): Record<string, unknown>\n /**\n * Loads every plugin's console server surface, for a section that checks\n * what it restores against something other plugins register there (a\n * custom field type). Costs a load, so a section asks only when it needs to.\n */\n loadPluginSurfaces(): Promise<void>\n}\n\n/** A row the restore reports without refusing: a document restored as it was, and why it is worth a look. */\nexport type SiteBundleReportRow = Record<string, unknown>\n\n/** An item another item names: its package kind and id. */\nexport interface SiteBundleItemReference {\n kind: string\n id: string\n}\n\n/**\n * A section's answers about its items as package items (AGL-3533): what each\n * one refers to — another of its own items, a page, a media file — and the\n * item with those references moved to new ids, for an item kept beside an\n * existing one or mapped onto one the site already holds.\n */\nexport interface PluginSiteBundleSectionPackage {\n /** The site items this item names, by package kind and id. */\n dependencies(item: SiteBundleItem): SiteBundleItemReference[]\n /**\n * The item with every reference in `idMap` moved: `idMap` maps an item key\n * (`<kind>/<id>`) to the id it now has, or to `null` when the reference is\n * dropped. The item's own `$id` is the restore's to set, not this hook's.\n */\n remapIds(item: SiteBundleItem, idMap: ReadonlyMap<string, string | null>): SiteBundleItem\n}\n\n/** A plugin's answers for one section. */\nexport interface PluginSiteBundleSection {\n /** Its items as package items; required, since every section declares a package kind. */\n package: PluginSiteBundleSectionPackage\n /** The site's share, read whole or not at all: throw rather than return a short list. */\n export(request: SiteBundleRequest): Promise<SiteBundleItem[]>\n /**\n * Before the restore writes anything: the sentence it answers 403 with when\n * restoring these items would cross what the organization may hold, or\n * `null`. A bundle refused here writes nothing at all.\n */\n refusal?(request: SiteBundleRestoreRequest): Promise<string | null>\n /** Writes the items back through `request.write`; answers the rows worth reporting. */\n import(request: SiteBundleImportRequest): Promise<readonly SiteBundleReportRow[]>\n}\n\ninterface Registered {\n pluginId: string\n section: PluginSiteBundleSection\n}\n\n/**\n * One table per process, on `globalThis` (AGL-3412): a plugin registers from\n * its declarations at boot, which Next compiles apart from the routes that\n * read, and a module-scoped map would be filled in one copy and read empty in\n * the other.\n */\nconst SECTIONS_KEY = Symbol.for('@aglyn/aglyn:site-bundle-sections')\n\nconst globalScope = globalThis as typeof globalThis & {\n [SECTIONS_KEY]?: Map<string, Registered>\n}\n\nconst sections: Map<string, Registered> =\n globalScope[SECTIONS_KEY] ?? (globalScope[SECTIONS_KEY] = new Map())\n\n/** Every declared section, in config order — the order the bundle carries them. */\nexport function listDeclaredSiteBundleSections(): readonly ResolvedPluginSiteBundleSectionDeclaration[] {\n return PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED\n}\n\n/**\n * Registers a plugin's answers for a section it declared. The owner is the\n * plugin whose register fn is running, or the `pluginId` passed from a boot\n * declaration. Refused: no owner, a key nobody declared (only a declared\n * section is ever read, so an undeclared one would be carried by nothing),\n * and a key another plugin declared. The same plugin registering again\n * replaces its answers.\n */\nexport function registerPluginSiteBundleSection(\n key: string,\n section: PluginSiteBundleSection,\n options?: { pluginId?: string },\n): void {\n const name = key.trim()\n const pluginId = (getRegisteringPluginId() ?? options?.pluginId ?? '').trim()\n if (!pluginId) {\n throw new Error(\n `site bundle section \"${name}\" registered with no owner: pass { pluginId } ` +\n 'when registering outside a plugin register fn',\n )\n }\n const declared = listDeclaredSiteBundleSections().find((one) => one.key === name)\n if (!declared) {\n throw new Error(\n `site bundle section \"${name}\" is not declared in plugins.config.json ` +\n '(siteBundleSections), so no export would ever carry it',\n )\n }\n if (declared.pluginId !== pluginId) {\n throw new Error(\n `site bundle section \"${name}\" is declared by \"${declared.pluginId}\"; ` +\n `refused \"${pluginId}\"`,\n )\n }\n if (\n typeof section.package?.dependencies !== 'function' ||\n typeof section.package?.remapIds !== 'function'\n ) {\n throw new Error(\n `site bundle section \"${name}\" declares package kind \"${declared.package.kind}\" ` +\n 'and registers no package hooks (dependencies, remapIds), so a package ' +\n 'could neither list what its items need nor keep a copy beside an existing one',\n )\n }\n sections.set(name, { pluginId, section })\n}\n\n/** A declared section with the answers its plugin registered. */\nexport type ResolvedSiteBundleSection = ResolvedPluginSiteBundleSectionDeclaration & {\n section: PluginSiteBundleSection\n}\n\n/**\n * Every declared section with its answers, in config order. A declared\n * section with nothing registered runs the app's declarations step once and\n * asks again; still missing, this THROWS naming it — an export that carried\n * the rest would be a backup missing a section with nothing to say so.\n */\nexport async function resolveSiteBundleSections(): Promise<ResolvedSiteBundleSection[]> {\n const missing = () =>\n listDeclaredSiteBundleSections().filter((declared) => !sections.has(declared.key))\n if (missing().length) await runPluginDeclarationsRepair()\n const absent = missing()\n if (absent.length) {\n throw new Error(\n `[plugins] site bundle section(s) ${absent.map((one) => `\"${one.key}\" (${one.pluginId})`).join(', ')} ` +\n 'declared and not registered in this process',\n )\n }\n return listDeclaredSiteBundleSections().map((declared) => ({\n ...declared,\n section: (sections.get(declared.key) as Registered).section,\n }))\n}\n\n/** Only for specs: forgets every registered section. */\nexport function resetSiteBundleSectionsForTests(): void {\n sections.clear()\n}\n"],"names":["globalScope","getRegisteringPluginId","PLUGIN_SITE_BUNDLE_SECTIONS_DECLARED","runPluginDeclarationsRepair","SECTIONS_KEY","Symbol","for","globalThis","sections","Map","listDeclaredSiteBundleSections","registerPluginSiteBundleSection","key","section","options","name","trim","pluginId","Error","declared","find","one","package","dependencies","remapIds","kind","set","resolveSiteBundleSections","missing","filter","has","length","absent","map","join","get","resetSiteBundleSectionsForTests","clear"],"mappings":";IA6LEA;AA7LF;;;;;;;;;;;;;;;CAeC,GAED,SAASC,sBAAsB,QAAQ,qCAAiC;AACxE,SAASC,oCAAoC,QAAQ,qCAAiC;AACtF,SAASC,2BAA2B,QAAQ,kCAA8B;AA6J1E;;;;;CAKC,GACD,MAAMC,eAAeC,OAAOC,GAAG,CAAC;AAEhC,MAAMN,cAAcO;AAIpB,MAAMC,YACJR,4BAAAA,WAAW,CAACI,aAAa,YAAzBJ,4BAA8BA,WAAW,CAACI,aAAa,GAAG,IAAIK;AAEhE,iFAAiF,GACjF,OAAO,SAASC;IACd,OAAOR;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASS,gCACdC,GAAW,EACXC,OAAgC,EAChCC,OAA+B;QAGbb,MAAAA;QAqBTY,kBACAA;IAvBT,MAAME,OAAOH,IAAII,IAAI;IACrB,MAAMC,WAAW,EAAChB,QAAAA,0BAAAA,oCAAAA,0BAA4Ba,2BAAAA,QAASG,QAAQ,YAA7ChB,OAAiD,IAAIe,IAAI;IAC3E,IAAI,CAACC,UAAU;QACb,MAAM,IAAIC,MACR,CAAC,qBAAqB,EAAEH,KAAK,8CAA8C,CAAC,GAC1E;IAEN;IACA,MAAMI,WAAWT,iCAAiCU,IAAI,CAAC,CAACC,MAAQA,IAAIT,GAAG,KAAKG;IAC5E,IAAI,CAACI,UAAU;QACb,MAAM,IAAID,MACR,CAAC,qBAAqB,EAAEH,KAAK,yCAAyC,CAAC,GACrE;IAEN;IACA,IAAII,SAASF,QAAQ,KAAKA,UAAU;QAClC,MAAM,IAAIC,MACR,CAAC,qBAAqB,EAAEH,KAAK,kBAAkB,EAAEI,SAASF,QAAQ,CAAC,GAAG,CAAC,GACrE,CAAC,SAAS,EAAEA,SAAS,CAAC,CAAC;IAE7B;IACA,IACE,SAAOJ,mBAAAA,QAAQS,OAAO,qBAAfT,iBAAiBU,YAAY,MAAK,cACzC,SAAOV,oBAAAA,QAAQS,OAAO,qBAAfT,kBAAiBW,QAAQ,MAAK,YACrC;QACA,MAAM,IAAIN,MACR,CAAC,qBAAqB,EAAEH,KAAK,yBAAyB,EAAEI,SAASG,OAAO,CAACG,IAAI,CAAC,EAAE,CAAC,GAC/E,2EACA;IAEN;IACAjB,SAASkB,GAAG,CAACX,MAAM;QAAEE;QAAUJ;IAAQ;AACzC;AAOA;;;;;CAKC,GACD,OAAO,eAAec;IACpB,MAAMC,UAAU,IACdlB,iCAAiCmB,MAAM,CAAC,CAACV,WAAa,CAACX,SAASsB,GAAG,CAACX,SAASP,GAAG;IAClF,IAAIgB,UAAUG,MAAM,EAAE,MAAM5B;IAC5B,MAAM6B,SAASJ;IACf,IAAII,OAAOD,MAAM,EAAE;QACjB,MAAM,IAAIb,MACR,CAAC,iCAAiC,EAAEc,OAAOC,GAAG,CAAC,CAACZ,MAAQ,CAAC,CAAC,EAAEA,IAAIT,GAAG,CAAC,GAAG,EAAES,IAAIJ,QAAQ,CAAC,CAAC,CAAC,EAAEiB,IAAI,CAAC,MAAM,CAAC,CAAC,GACrG;IAEN;IACA,OAAOxB,iCAAiCuB,GAAG,CAAC,CAACd,WAAc,aACtDA;YACHN,SAAS,AAACL,SAAS2B,GAAG,CAAChB,SAASP,GAAG,EAAiBC,OAAO;;AAE/D;AAEA,sDAAsD,GACtD,OAAO,SAASuB;IACd5B,SAAS6B,KAAK;AAChB"}
|
|
@@ -54,6 +54,49 @@ export interface PluginHostCollectionSiteExport {
|
|
|
54
54
|
limit: number;
|
|
55
55
|
/** The keys a restore writes back. Anything else a bundle carries is dropped. */
|
|
56
56
|
fields: readonly string[];
|
|
57
|
+
/** What a site package calls each document (AGL-3533). */
|
|
58
|
+
package: PluginSitePackageItemDeclaration;
|
|
59
|
+
/**
|
|
60
|
+
* What a restore is met against when the collection has no `resource`: a
|
|
61
|
+
* plan counter, a flat platform cap by core's name for it, or `uncapped`
|
|
62
|
+
* with the reason a count adds nothing (the browser already creates the
|
|
63
|
+
* collection without one).
|
|
64
|
+
*/
|
|
65
|
+
count?: {
|
|
66
|
+
quotaKey: string;
|
|
67
|
+
} | {
|
|
68
|
+
platformCap: string;
|
|
69
|
+
} | {
|
|
70
|
+
uncapped: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* How a site package lists a plugin's items (AGL-3533): the kind, the plural
|
|
75
|
+
* label the import screen groups them under, the field an item with a new id
|
|
76
|
+
* is matched by (a slug first, then a name), the fields that hold ids of
|
|
77
|
+
* other site items, the binding token (`var`, `fn`) that names one of these
|
|
78
|
+
* items inside a design, and the node props that place one. Compiled, and checked by the generator: one
|
|
79
|
+
* owner per kind, none of the platform's own.
|
|
80
|
+
*/
|
|
81
|
+
export interface PluginSitePackageItemDeclaration {
|
|
82
|
+
kind: string;
|
|
83
|
+
label: string;
|
|
84
|
+
nameField?: string;
|
|
85
|
+
slugField?: string;
|
|
86
|
+
references?: ReadonlyArray<{
|
|
87
|
+
field: string;
|
|
88
|
+
kind: string;
|
|
89
|
+
}>;
|
|
90
|
+
bindingToken?: 'var' | 'fn';
|
|
91
|
+
/**
|
|
92
|
+
* Node props that place one of these items in a design: a `form` node's
|
|
93
|
+
* `formId`, any node's `repeatDataset`. `componentId` narrows it to one
|
|
94
|
+
* element; absent, any node's prop counts.
|
|
95
|
+
*/
|
|
96
|
+
placements?: ReadonlyArray<{
|
|
97
|
+
componentId?: string;
|
|
98
|
+
prop: string;
|
|
99
|
+
}>;
|
|
57
100
|
}
|
|
58
101
|
/** What a restore of a declared collection is counted against. */
|
|
59
102
|
export type PluginSiteExportCount =
|
|
@@ -67,15 +110,28 @@ export type PluginSiteExportCount =
|
|
|
67
110
|
*/
|
|
68
111
|
| {
|
|
69
112
|
max: number | null;
|
|
113
|
+
}
|
|
114
|
+
/** Nothing to count, for the reason the declaration gives. */
|
|
115
|
+
| {
|
|
116
|
+
uncapped: string;
|
|
70
117
|
};
|
|
71
118
|
/** A declared collection with the plugin that made it and its count. */
|
|
72
|
-
export interface ResolvedPluginSiteExportCollection extends PluginHostCollectionSiteExport {
|
|
119
|
+
export interface ResolvedPluginSiteExportCollection extends Omit<PluginHostCollectionSiteExport, 'count'> {
|
|
73
120
|
pluginId: string;
|
|
74
121
|
/** The subcollection under `hosts/{hostId}`, and its key in the bundle. */
|
|
75
122
|
collection: string;
|
|
76
123
|
/** Plural, for a restore's refusal: "this backup holds 40 {label}". */
|
|
77
124
|
label: string;
|
|
78
125
|
count: PluginSiteExportCount;
|
|
126
|
+
/**
|
|
127
|
+
* The field that may send traffic off the platform, and the field its
|
|
128
|
+
* approver lands in: a restore stamps the importing admin there, since a
|
|
129
|
+
* file's approver is provenance it cannot supply.
|
|
130
|
+
*/
|
|
131
|
+
externalDestination?: {
|
|
132
|
+
field: string;
|
|
133
|
+
approvedByField: string;
|
|
134
|
+
};
|
|
79
135
|
}
|
|
80
136
|
/** Every collection a plugin declares for the site backup, in config order. */
|
|
81
137
|
export declare function listPluginSiteExportCollections(): ResolvedPluginSiteExportCollection[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2026 Aglyn LLC
|
|
@@ -15,24 +16,36 @@
|
|
|
15
16
|
* limitations under the License.
|
|
16
17
|
*/ import { PLUGIN_HOST_COLLECTIONS_DECLARED } from "./first-party-plugins.generated.js";
|
|
17
18
|
import { hostResourcePlatformCap } from "./plugin-host-resources.js";
|
|
19
|
+
function siteExportCount(resource, count) {
|
|
20
|
+
var _ref, _ref1;
|
|
21
|
+
const source = (_ref = resource != null ? resource : count) != null ? _ref : {};
|
|
22
|
+
if ('uncapped' in source && source.uncapped) return {
|
|
23
|
+
uncapped: source.uncapped
|
|
24
|
+
};
|
|
25
|
+
if ('quotaKey' in source && source.quotaKey) return {
|
|
26
|
+
quotaKey: source.quotaKey
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
max: hostResourcePlatformCap((_ref1 = 'platformCap' in source ? source.platformCap : '') != null ? _ref1 : '')
|
|
30
|
+
};
|
|
31
|
+
}
|
|
18
32
|
/** Every collection a plugin declares for the site backup, in config order. */ export function listPluginSiteExportCollections() {
|
|
19
33
|
const out = [];
|
|
20
34
|
for (const row of PLUGIN_HOST_COLLECTIONS_DECLARED){
|
|
21
|
-
var
|
|
35
|
+
var _ref;
|
|
22
36
|
const { siteExport, resource } = row;
|
|
23
|
-
if (!siteExport || !resource) continue;
|
|
24
|
-
out.push({
|
|
37
|
+
if (!siteExport || !resource && !siteExport.count) continue;
|
|
38
|
+
out.push(_extends({
|
|
25
39
|
pluginId: row.pluginId,
|
|
26
40
|
collection: row.name,
|
|
27
41
|
limit: siteExport.limit,
|
|
28
42
|
fields: siteExport.fields,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
43
|
+
package: siteExport.package,
|
|
44
|
+
label: (_ref = resource == null ? void 0 : resource.label) != null ? _ref : siteExport.package.label.toLowerCase(),
|
|
45
|
+
count: siteExportCount(resource, siteExport.count)
|
|
46
|
+
}, (resource == null ? void 0 : resource.externalDestination) ? {
|
|
47
|
+
externalDestination: resource.externalDestination
|
|
48
|
+
} : {}));
|
|
36
49
|
}
|
|
37
50
|
return out;
|
|
38
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-export.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 { PLUGIN_HOST_COLLECTIONS_DECLARED } from './first-party-plugins.generated'\nimport { hostResourcePlatformCap } from './plugin-host-resources'\n\n/**\n * A plugin's host collection in the platform's whole-site backup (AGL-3080).\n *\n * `/api/hosts/export` writes one JSON bundle of everything designable on a\n * site and `/api/hosts/import` restores it (AGL-163). The platform's own\n * documents — screens, layouts, components, authors, content collections,\n * media — are the routes' to carry. A plugin whose site documents belong in\n * a backup declares so beside the collection, in the `hostCollections` block\n * of `plugins.config.json` (a host collection's `siteExport`), and both\n * routes walk the declarations: the export reads up to `limit` live documents\n * into the bundle under the collection's own name, and the restore writes each\n * one back through `fields` and counts the result against the collection's\n * declared `resource`.\n *\n * ## `fields` is the round trip, not the create\n *\n * A restore writes with `merge: false`, so the list is every key a live\n * document carries — which can be narrower than what a create admits, and is\n * often wider — and a key left off is ERASED from every restored document\n * (AGL-1382). Nothing the restore stamps (`createdAt`, `updatedAt`,\n * `deletedAt`) or scopes (`visibleTo`) is on it; the generator refuses them.\n *\n * ## Compiled, and counted\n *\n * A backup that silently lacks a collection is worse than a failed one: the\n * file looks whole until the day it is restored. So the declarations are\n * compiled, present the moment this module is imported, and a runtime\n * `registerPluginHostCollections` carrying a `siteExport` throws. A restore\n * creates documents with the Admin SDK, past the rules, so the generator also\n * refuses a `siteExport` on a collection with no `resource`: the resource's\n * plan counter or flat platform cap is what the restore is met against.\n *\n * Reached by its own subpath, never the barrel: its readers are the two\n * console routes.\n */\nexport interface PluginHostCollectionSiteExport {\n /** The most live documents one bundle carries; a restore writes no more. */\n limit: number\n /** The keys a restore writes back. Anything else a bundle carries is dropped. */\n fields: readonly string[]\n}\n\n/** What a restore of a declared collection is counted against. */\nexport type PluginSiteExportCount =\n /** A plan counter, an `OrgEntitlements` key core resolves. */\n | { quotaKey: string }\n /**\n * A flat platform cap, resolved from the name the resource declares, or\n * `null` for a name core does not hold — which a restore refuses.\n */\n | { max: number | null }\n\n/** A declared collection with the plugin that made it and its count. */\nexport interface ResolvedPluginSiteExportCollection extends PluginHostCollectionSiteExport {\n pluginId: string\n /** The subcollection under `hosts/{hostId}`, and its key in the bundle. */\n collection: string\n /** Plural, for a restore's refusal: \"this backup holds 40 {label}\". */\n label: string\n count: PluginSiteExportCount\n}\n\n/** Every collection a plugin declares for the site backup, in config order. */\nexport function listPluginSiteExportCollections(): ResolvedPluginSiteExportCollection[] {\n const out: ResolvedPluginSiteExportCollection[] = []\n for (const row of PLUGIN_HOST_COLLECTIONS_DECLARED) {\n const { siteExport, resource } = row\n if (!siteExport || !resource) continue\n out.push({\n pluginId: row.pluginId,\n collection: row.name,\n limit: siteExport.limit,\n fields: siteExport.fields,\n label: resource.label,\n count: resource.
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/plugin-manager/plugin-site-export.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 { PLUGIN_HOST_COLLECTIONS_DECLARED } from './first-party-plugins.generated'\nimport { hostResourcePlatformCap } from './plugin-host-resources'\n\n/**\n * A plugin's host collection in the platform's whole-site backup (AGL-3080).\n *\n * `/api/hosts/export` writes one JSON bundle of everything designable on a\n * site and `/api/hosts/import` restores it (AGL-163). The platform's own\n * documents — screens, layouts, components, authors, content collections,\n * media — are the routes' to carry. A plugin whose site documents belong in\n * a backup declares so beside the collection, in the `hostCollections` block\n * of `plugins.config.json` (a host collection's `siteExport`), and both\n * routes walk the declarations: the export reads up to `limit` live documents\n * into the bundle under the collection's own name, and the restore writes each\n * one back through `fields` and counts the result against the collection's\n * declared `resource`.\n *\n * ## `fields` is the round trip, not the create\n *\n * A restore writes with `merge: false`, so the list is every key a live\n * document carries — which can be narrower than what a create admits, and is\n * often wider — and a key left off is ERASED from every restored document\n * (AGL-1382). Nothing the restore stamps (`createdAt`, `updatedAt`,\n * `deletedAt`) or scopes (`visibleTo`) is on it; the generator refuses them.\n *\n * ## Compiled, and counted\n *\n * A backup that silently lacks a collection is worse than a failed one: the\n * file looks whole until the day it is restored. So the declarations are\n * compiled, present the moment this module is imported, and a runtime\n * `registerPluginHostCollections` carrying a `siteExport` throws. A restore\n * creates documents with the Admin SDK, past the rules, so the generator also\n * refuses a `siteExport` on a collection with no `resource`: the resource's\n * plan counter or flat platform cap is what the restore is met against.\n *\n * Reached by its own subpath, never the barrel: its readers are the two\n * console routes.\n */\nexport interface PluginHostCollectionSiteExport {\n /** The most live documents one bundle carries; a restore writes no more. */\n limit: number\n /** The keys a restore writes back. Anything else a bundle carries is dropped. */\n fields: readonly string[]\n /** What a site package calls each document (AGL-3533). */\n package: PluginSitePackageItemDeclaration\n /**\n * What a restore is met against when the collection has no `resource`: a\n * plan counter, a flat platform cap by core's name for it, or `uncapped`\n * with the reason a count adds nothing (the browser already creates the\n * collection without one).\n */\n count?: { quotaKey: string } | { platformCap: string } | { uncapped: string }\n}\n\n/**\n * How a site package lists a plugin's items (AGL-3533): the kind, the plural\n * label the import screen groups them under, the field an item with a new id\n * is matched by (a slug first, then a name), the fields that hold ids of\n * other site items, the binding token (`var`, `fn`) that names one of these\n * items inside a design, and the node props that place one. Compiled, and checked by the generator: one\n * owner per kind, none of the platform's own.\n */\nexport interface PluginSitePackageItemDeclaration {\n kind: string\n label: string\n nameField?: string\n slugField?: string\n references?: ReadonlyArray<{ field: string; kind: string }>\n bindingToken?: 'var' | 'fn'\n /**\n * Node props that place one of these items in a design: a `form` node's\n * `formId`, any node's `repeatDataset`. `componentId` narrows it to one\n * element; absent, any node's prop counts.\n */\n placements?: ReadonlyArray<{ componentId?: string; prop: string }>\n}\n\n/** What a restore of a declared collection is counted against. */\nexport type PluginSiteExportCount =\n /** A plan counter, an `OrgEntitlements` key core resolves. */\n | { quotaKey: string }\n /**\n * A flat platform cap, resolved from the name the resource declares, or\n * `null` for a name core does not hold — which a restore refuses.\n */\n | { max: number | null }\n /** Nothing to count, for the reason the declaration gives. */\n | { uncapped: string }\n\n/** A declared collection with the plugin that made it and its count. */\nexport interface ResolvedPluginSiteExportCollection extends Omit<PluginHostCollectionSiteExport, 'count'> {\n pluginId: string\n /** The subcollection under `hosts/{hostId}`, and its key in the bundle. */\n collection: string\n /** Plural, for a restore's refusal: \"this backup holds 40 {label}\". */\n label: string\n count: PluginSiteExportCount\n /**\n * The field that may send traffic off the platform, and the field its\n * approver lands in: a restore stamps the importing admin there, since a\n * file's approver is provenance it cannot supply.\n */\n externalDestination?: { field: string; approvedByField: string }\n}\n\nfunction siteExportCount(\n resource: { quotaKey?: string; platformCap?: string } | undefined,\n count: PluginHostCollectionSiteExport['count'],\n): PluginSiteExportCount {\n const source = resource ?? count ?? {}\n if ('uncapped' in source && source.uncapped) return { uncapped: source.uncapped }\n if ('quotaKey' in source && source.quotaKey) return { quotaKey: source.quotaKey }\n return { max: hostResourcePlatformCap(('platformCap' in source ? source.platformCap : '') ?? '') }\n}\n\n/** Every collection a plugin declares for the site backup, in config order. */\nexport function listPluginSiteExportCollections(): ResolvedPluginSiteExportCollection[] {\n const out: ResolvedPluginSiteExportCollection[] = []\n for (const row of PLUGIN_HOST_COLLECTIONS_DECLARED) {\n const { siteExport, resource } = row\n if (!siteExport || (!resource && !siteExport.count)) continue\n out.push({\n pluginId: row.pluginId,\n collection: row.name,\n limit: siteExport.limit,\n fields: siteExport.fields,\n package: siteExport.package,\n label: resource?.label ?? siteExport.package.label.toLowerCase(),\n count: siteExportCount(resource, siteExport.count),\n ...(resource?.externalDestination ? { externalDestination: resource.externalDestination } : {}),\n })\n }\n return out\n}\n"],"names":["PLUGIN_HOST_COLLECTIONS_DECLARED","hostResourcePlatformCap","siteExportCount","resource","count","source","uncapped","quotaKey","max","platformCap","listPluginSiteExportCollections","out","row","siteExport","push","pluginId","collection","name","limit","fields","package","label","toLowerCase","externalDestination"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,gCAAgC,QAAQ,qCAAiC;AAClF,SAASC,uBAAuB,QAAQ,6BAAyB;AAwGjE,SAASC,gBACPC,QAAiE,EACjEC,KAA8C;QAE/BD,MAGwB;IAHvC,MAAME,UAASF,OAAAA,mBAAAA,WAAYC,iBAAZD,OAAqB,CAAC;IACrC,IAAI,cAAcE,UAAUA,OAAOC,QAAQ,EAAE,OAAO;QAAEA,UAAUD,OAAOC,QAAQ;IAAC;IAChF,IAAI,cAAcD,UAAUA,OAAOE,QAAQ,EAAE,OAAO;QAAEA,UAAUF,OAAOE,QAAQ;IAAC;IAChF,OAAO;QAAEC,KAAKP,yBAAyB,QAAA,iBAAiBI,SAASA,OAAOI,WAAW,GAAG,cAA/C,QAAsD;IAAI;AACnG;AAEA,6EAA6E,GAC7E,OAAO,SAASC;IACd,MAAMC,MAA4C,EAAE;IACpD,KAAK,MAAMC,OAAOZ,iCAAkC;;QAClD,MAAM,EAAEa,UAAU,EAAEV,QAAQ,EAAE,GAAGS;QACjC,IAAI,CAACC,cAAe,CAACV,YAAY,CAACU,WAAWT,KAAK,EAAG;QACrDO,IAAIG,IAAI,CAAC;YACPC,UAAUH,IAAIG,QAAQ;YACtBC,YAAYJ,IAAIK,IAAI;YACpBC,OAAOL,WAAWK,KAAK;YACvBC,QAAQN,WAAWM,MAAM;YACzBC,SAASP,WAAWO,OAAO;YAC3BC,KAAK,UAAElB,4BAAAA,SAAUkB,KAAK,mBAAIR,WAAWO,OAAO,CAACC,KAAK,CAACC,WAAW;YAC9DlB,OAAOF,gBAAgBC,UAAUU,WAAWT,KAAK;WAC7CD,CAAAA,4BAAAA,SAAUoB,mBAAmB,IAAG;YAAEA,qBAAqBpB,SAASoB,mBAAmB;QAAC,IAAI,CAAC;IAEjG;IACA,OAAOZ;AACT"}
|