@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 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/site-package.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 { REUSABLE_INSTANCE_COMPONENT_ID } from '../app-utils/reusable-component-keys'\nimport { SCREEN_KIND_EMAIL } from '../app-utils/screen-route'\nimport { listPluginSiteExportCollections } from '../plugin-manager/plugin-site-export'\nimport {\n listDeclaredSiteBundleSections,\n type PluginSiteBundleSectionPackage,\n} from '../plugin-manager/plugin-site-bundle'\nimport {\n contentHash,\n keepBothSlug,\n matchPackageItems,\n packageDecisionsFor,\n packageDependencyClosure,\n packageItemKey,\n proposePackageDecision,\n readPackageManifest,\n TRANSFER_PACKAGE_FORMAT,\n TRANSFER_PACKAGE_VERSION,\n type ExistingPackageItem,\n type PackageDependency,\n type PackageItemComparison,\n type PackageItemDecision,\n type PackageItemStatus,\n type PackageManifest,\n type PackageManifestItem,\n type TransferPackage,\n} from './package'\n\n/*==========================================\n * SITE PACKAGES — a site's items as one `aglyn-package` file (AGL-3533).\n *\n * The whole-site backup used to be one all-or-nothing bundle restored by\n * id. A site package lists every item instead — each page, layout,\n * component, form, redirect, dataset… — with a content hash and the items\n * it depends on, so an export can carry a chosen few (with what they\n * need) and an import can say, before it writes anything, which items are\n * new, which the site already holds unchanged, and which differ.\n *\n * This module is pure: no Firestore, no Node builtin, no React. The console\n * routes read and write; here is what the items ARE, how one names\n * another, how references move when an item lands under a new id, and what\n * the import would do with each item.\n *\n * Reached by its own subpath (`@aglyn/aglyn/data-transfer/site-package`),\n * never through `@aglyn/aglyn/data-transfer`: it reads the compiled plugin\n * declarations, which the generic core does not.\n *\n * ## Kinds\n *\n * The platform's own (`settings`, `theme`, `page`, `email`, `emailTemplate`,\n * `layout`, `component`, `author`, `collection`, the four media kinds and\n * `savedTheme`) are listed here. A plugin's are declared beside its data in\n * `plugins.config.json` — a host collection's `siteExport.package`, or a\n * backup section's `package` — and read from the compiled declarations, so\n * this module names no plugin.\n *\n * ## Item content\n *\n * An item's content is the document a v1 backup carried for it, without\n * its `$id` (the manifest holds that): a page with its published `version`\n * and its address in the routing map as `route`, a collection with its\n * `entries`, a section's item as the plugin exported it. The site's own\n * fields are two singleton items, `settings/settings` and `theme/theme`.\n *\n * ## References\n *\n * An item depends on another when it names its id. The kinds say where\n * names are typed (`layoutId` is a layout, a reusable component placement's\n * `refId` is a component, `{{var:id}}` is the kind that declares the `var`\n * token), so a dependency on an item that exists nowhere can still be\n * reported. Beyond those, any string or map key in the content that is, or\n * contains as a whole token, the id of another known item is a dependency:\n * links (`screen:<id>`), media references and the long tail of id-bearing\n * props are covered without a list that would always be one prop short.\n * Ids that are words (a catalog key, `default`) are never searched for.\n *\n * Moving references is the same walk: every exact id and every whole\n * token naming one is rewritten through an id map, and a reference the\n * person chose to drop becomes `null` (a field), disappears (a map key, a\n * list entry, a binding token) or empties the string that held it.\n *=========================================*/\n\n/*==========================================\n * KINDS\n *=========================================*/\n\n/** Where a kind is declared. */\nexport type SitePackageKindSource = 'platform' | 'collection' | 'section'\n\n/** A field of an item that holds the id of another item. */\nexport interface SitePackageReferenceField {\n field: string\n /** The kinds the id may name, tried in order against what is known. */\n kinds: readonly string[]\n /** `values`: the field is a map whose values are ids; `items`: a list of ids. */\n each?: 'values' | 'items'\n}\n\n/** A node prop that names an item of the kind that declares it. */\nexport interface SitePackagePlacement {\n /** Only nodes of this component; any node when absent. */\n componentId?: string\n prop: string\n}\n\n/** One kind of item a site package carries. */\nexport interface SitePackageKind {\n kind: string\n /** Plural, for the import screen. */\n label: string\n source: SitePackageKindSource\n /**\n * Where a v1 backup carries the kind: its array (`screens`, a plugin\n * collection's name, a section's key), or `host` for the site's fields.\n */\n bundleKey: string\n /** The field an item with a new id is matched by first. */\n slugField?: string\n /** …and second. */\n nameField?: string\n /** Settings and the theme merge key by key. */\n mergeable?: boolean\n /** A replace writes the incoming design as a new version. */\n versioned?: boolean\n /** Its ids are words, never searched for inside other items' text. */\n wordIds?: boolean\n /** Its own id inside its own content is left alone when it moves (a stored file's address). */\n keepsOwnId?: boolean\n references?: readonly SitePackageReferenceField[]\n bindingToken?: 'var' | 'fn'\n placements?: readonly SitePackagePlacement[]\n /** The one id a singleton kind is filed under. */\n singletonId?: string\n /** Its ids are fixed (a singleton, a catalog key): an item cannot be kept as a copy. */\n noCopies?: boolean\n}\n\n/** The singleton id of the site's settings item. */\nexport const SITE_SETTINGS_ITEM_ID = 'settings'\n/** The singleton id of the site's theme item. */\nexport const SITE_THEME_ITEM_ID = 'theme'\n\n/** The two kinds a site's screens are listed as. */\nexport const SITE_SCREEN_KINDS = ['page', 'email'] as const\n\nconst SCREEN_REFS = SITE_SCREEN_KINDS\n\n/** The platform's own kinds, in the order an export lists them. */\nexport const PLATFORM_SITE_PACKAGE_KINDS: readonly SitePackageKind[] = [\n {\n kind: 'settings',\n label: 'Site settings',\n source: 'platform',\n bundleKey: 'host',\n mergeable: true,\n wordIds: true,\n noCopies: true,\n singletonId: SITE_SETTINGS_ITEM_ID,\n references: [\n { field: 'notFoundScreenId', kinds: SCREEN_REFS },\n { field: 'errorScreens', kinds: SCREEN_REFS, each: 'values' },\n ],\n },\n {\n kind: 'theme',\n label: 'Theme',\n source: 'platform',\n bundleKey: 'host',\n mergeable: true,\n wordIds: true,\n noCopies: true,\n singletonId: SITE_THEME_ITEM_ID,\n },\n {\n kind: 'page',\n label: 'Pages',\n source: 'platform',\n bundleKey: 'screens',\n slugField: 'slug',\n nameField: 'displayName',\n versioned: true,\n references: [\n { field: 'layoutId', kinds: ['layout'] },\n { field: 'parentId', kinds: SCREEN_REFS },\n { field: 'localeVariants', kinds: SCREEN_REFS, each: 'values' },\n ],\n },\n {\n kind: 'email',\n label: 'Email designs',\n source: 'platform',\n bundleKey: 'screens',\n slugField: 'slug',\n nameField: 'displayName',\n versioned: true,\n references: [\n { field: 'layoutId', kinds: ['layout'] },\n { field: 'parentId', kinds: SCREEN_REFS },\n ],\n },\n {\n kind: 'emailTemplate',\n label: 'Site emails',\n source: 'platform',\n bundleKey: 'emailTemplates',\n versioned: true,\n wordIds: true,\n noCopies: true,\n },\n {\n kind: 'layout',\n label: 'Layouts',\n source: 'platform',\n bundleKey: 'layouts',\n nameField: 'displayName',\n versioned: true,\n references: [{ field: 'layoutId', kinds: ['layout'] }],\n },\n {\n kind: 'component',\n label: 'Components',\n source: 'platform',\n bundleKey: 'components',\n nameField: 'displayName',\n },\n {\n kind: 'author',\n label: 'Authors',\n source: 'platform',\n bundleKey: 'authors',\n slugField: 'slug',\n nameField: 'name',\n },\n {\n kind: 'collection',\n label: 'Collections',\n source: 'platform',\n bundleKey: 'collections',\n slugField: 'slug',\n nameField: 'displayName',\n references: [\n { field: 'listScreenId', kinds: SCREEN_REFS },\n { field: 'entryScreenId', kinds: SCREEN_REFS },\n { field: 'templateScreenId', kinds: SCREEN_REFS },\n ],\n },\n {\n kind: 'mediaFolder',\n label: 'Media folders (workspace library)',\n source: 'platform',\n bundleKey: 'mediaFolders',\n references: [{ field: 'parentId', kinds: ['mediaFolder'] }],\n },\n {\n kind: 'media',\n label: 'Media (workspace library)',\n source: 'platform',\n bundleKey: 'media',\n keepsOwnId: true,\n references: [{ field: 'folderId', kinds: ['mediaFolder'] }],\n },\n {\n kind: 'siteMediaFolder',\n label: 'Media folders (site library)',\n source: 'platform',\n bundleKey: 'hostMediaFolders',\n references: [{ field: 'parentId', kinds: ['siteMediaFolder'] }],\n },\n {\n kind: 'siteMedia',\n label: 'Media (site library)',\n source: 'platform',\n bundleKey: 'hostMedia',\n keepsOwnId: true,\n references: [{ field: 'folderId', kinds: ['siteMediaFolder'] }],\n },\n {\n kind: 'savedTheme',\n label: 'Saved themes',\n source: 'platform',\n bundleKey: 'themes',\n nameField: 'name',\n wordIds: true,\n },\n]\n\n/**\n * Every kind a site package carries: the platform's, then each host\n * collection a plugin declares for the backup, then each backup section, in\n * config order. Throws when two declare one kind — the generator refuses\n * that, so it only fires for a hand-edited catalog.\n */\nexport function listSitePackageKinds(): SitePackageKind[] {\n const kinds: SitePackageKind[] = [...PLATFORM_SITE_PACKAGE_KINDS]\n for (const declared of listPluginSiteExportCollections()) {\n const pkg = declared.package\n kinds.push({\n kind: pkg.kind,\n label: pkg.label,\n source: 'collection',\n bundleKey: declared.collection,\n ...(pkg.slugField ? { slugField: pkg.slugField } : {}),\n ...(pkg.nameField ? { nameField: pkg.nameField } : {}),\n references: (pkg.references ?? []).map((ref) => ({ field: ref.field, kinds: [ref.kind] })),\n ...(pkg.bindingToken ? { bindingToken: pkg.bindingToken } : {}),\n ...(pkg.placements?.length ? { placements: pkg.placements } : {}),\n })\n }\n for (const declared of listDeclaredSiteBundleSections()) {\n const pkg = declared.package\n kinds.push({\n kind: pkg.kind,\n label: pkg.label,\n source: 'section',\n bundleKey: declared.key,\n ...(pkg.slugField ? { slugField: pkg.slugField } : {}),\n ...(pkg.nameField ? { nameField: pkg.nameField } : {}),\n ...(pkg.placements?.length ? { placements: pkg.placements } : {}),\n })\n }\n const seen = new Set<string>()\n for (const one of kinds) {\n if (seen.has(one.kind)) throw new Error(`site package kind \"${one.kind}\" is declared twice`)\n seen.add(one.kind)\n }\n return kinds\n}\n\n/** The kinds by name. */\nexport function sitePackageKindMap(kinds = listSitePackageKinds()): ReadonlyMap<string, SitePackageKind> {\n return new Map(kinds.map((one) => [one.kind, one]))\n}\n\n/*==========================================\n * ITEMS, AND THE v1 BACKUP THEY ARE READ FROM AND WRITTEN AS\n *=========================================*/\n\n/** One item: its kind, its id and its content (the document, without `$id`). */\nexport interface SitePackageItem<T = Record<string, unknown>> {\n kind: string\n id: string\n content: T\n}\n\n/**\n * What the console's write path decides and this module must agree with:\n * the site fields each singleton carries and the most items of each v1\n * array an import reads.\n */\nexport interface SitePackageContract {\n /** The host fields the `settings` item carries (the routing map is the pages'). */\n settingsFields: readonly string[]\n /** The host fields the `theme` item carries. */\n themeFields: readonly string[]\n /** The most items one array carries, by v1 key; a key absent is not capped here. */\n limits: Readonly<Record<string, number>>\n}\n\n/** The routing map's host field: screen id → address. */\nexport const SITE_ROUTING_MAP_FIELD = 'screens'\n\n/** A v1 backup's arrays and host block, as far as this module reads them. */\nexport type SiteBundle = Record<string, unknown> & { host?: Record<string, unknown> }\n\ntype Doc = Record<string, unknown>\n\n/**\n * A plain object, from any realm: one whose prototype is some realm's\n * `Object.prototype` (itself prototype-less) or `null`. A request body parsed\n * by the platform's fetch is a plain object of the host realm, not the\n * module's, so identity with this realm's `Object.prototype` is not the test.\n * Class instances — a `Timestamp`, a `Buffer` — are not plain.\n */\nexport function isPlainSiteObject(value: unknown): value is Doc {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n const proto = Object.getPrototypeOf(value)\n return proto === null || Object.getPrototypeOf(proto) === null\n}\n\nfunction asDoc(value: unknown): Doc {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Doc) : {}\n}\n\nfunction pick(source: Doc, fields: readonly string[]): Doc | null {\n const out: Doc = {}\n for (const field of fields) if (source[field] !== undefined) out[field] = source[field]\n return Object.keys(out).length ? out : null\n}\n\n/** The kind a screen is listed as: an email design, or a page. */\nexport function screenPackageKind(screen: Doc): 'page' | 'email' {\n return screen['kind'] === SCREEN_KIND_EMAIL ? 'email' : 'page'\n}\n\n/**\n * A v1 backup's documents as package items, in kind order. Each array is\n * capped at the contract's limit for it; a document with no `$id` is not an\n * item. A screen's address in the routing map travels with it as `route`;\n * an address naming a screen the backup does not carry is not an item and\n * is dropped.\n */\nexport function siteBundleItems(\n bundle: SiteBundle,\n contract: SitePackageContract,\n kinds: readonly SitePackageKind[] = listSitePackageKinds(),\n): SitePackageItem[] {\n const host = asDoc(bundle.host)\n const routes = asDoc(host[SITE_ROUTING_MAP_FIELD])\n const items: SitePackageItem[] = []\n const arrays = new Map<string, Doc[]>()\n const array = (key: string): Doc[] => {\n if (!arrays.has(key)) {\n const raw = Array.isArray(bundle[key]) ? (bundle[key] as unknown[]) : []\n const limit = contract.limits[key]\n arrays.set(key, (limit === undefined ? raw : raw.slice(0, limit)).map(asDoc))\n }\n return arrays.get(key) as Doc[]\n }\n for (const kind of kinds) {\n if (kind.singletonId) {\n const fields = kind.kind === 'theme' ? contract.themeFields : kind.kind === 'settings' ? contract.settingsFields : []\n const content = pick(host, fields)\n if (content) items.push({ kind: kind.kind, id: kind.singletonId, content })\n continue\n }\n for (const doc of array(kind.bundleKey)) {\n const id = doc['$id']\n if (typeof id !== 'string' && typeof id !== 'number') continue\n if (kind.bundleKey === 'screens' && screenPackageKind(doc) !== kind.kind) continue\n const { $id: _id, ...rest } = doc\n const content: Doc = { ...rest }\n if (kind.bundleKey === 'screens') {\n const route = routes[String(id)]\n if (typeof route === 'string') content['route'] = route\n else delete content['route']\n }\n items.push({ kind: kind.kind, id: String(id), content })\n }\n }\n return items\n}\n\n/** An item as an import writes it: under `targetId`, its references moved. */\nexport interface SitePackageWrite {\n /** `<kind>/<id>` in the package. */\n key: string\n kind: string\n /** Its id in the package. */\n sourceId: string\n /** The id it is written under. */\n targetId: string\n decision: Exclude<PackageItemDecision, 'skip'>\n content: Doc\n /** The site item it replaces or merges into, by key. */\n existingKey?: string\n}\n\n/** What a v1-shaped write needs: the arrays, and the host fields to merge. */\nexport interface SiteBundleWrite {\n bundle: Record<string, Doc[]>\n /**\n * The host fields to write with `merge: true`: settings and theme fields,\n * and `screens` holding the address of each page written with one.\n */\n hostPatch: Doc\n}\n\n/**\n * Writes as the v1 shape the restore's writers read: each kind's documents\n * under its array, with `$id` set to the id it is written under, and the\n * site's own fields as one host patch.\n */\nexport function siteWritesToBundle(\n writes: readonly SitePackageWrite[],\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n): SiteBundleWrite {\n const bundle: Record<string, Doc[]> = {}\n const hostPatch: Doc = {}\n const routes: Doc = {}\n for (const write of writes) {\n const kind = kinds.get(write.kind)\n if (!kind) throw new Error(`site package kind \"${write.kind}\" is not one this site reads`)\n if (kind.singletonId) {\n Object.assign(hostPatch, write.content)\n continue\n }\n const { route, ...rest } = write.content\n if (kind.bundleKey === 'screens' && typeof route === 'string') routes[write.targetId] = route\n // The id last: a content's own `$id` never chooses where it is written.\n ;(bundle[kind.bundleKey] ??= []).push({ ...(kind.bundleKey === 'screens' ? rest : write.content), $id: write.targetId })\n }\n if (Object.keys(routes).length) hostPatch[SITE_ROUTING_MAP_FIELD] = routes\n return { bundle, hostPatch }\n}\n\n/*==========================================\n * REFERENCES\n *=========================================*/\n\n/** Ids searched for inside text are at least this long, so a word is never one. */\nexport const SITE_REFERENCE_MIN_ID_LENGTH = 8\n\nconst ID_TOKEN = /[A-Za-z0-9_-]+/g\nconst VAR_TOKEN = /\\{\\{\\s*var:([a-zA-Z0-9_-]{1,64})\\s*\\}\\}/g\nconst FN_TOKEN = /\\{\\{\\s*fn:([a-zA-Z0-9_-]{1,64})(?: [a-zA-Z0-9_-]{1,64})*\\s*\\([^)]*\\)\\s*\\}\\}/g\n\n/** What the items being described can see: every item's kind by its id. */\nexport interface SiteReferenceIndex {\n /** The kinds an id is known as, among the items this description can see. */\n kindsOf(id: string): readonly string[]\n /** Whether ids of this kind are searched for inside text. */\n searchable(id: string): boolean\n}\n\n/** An index over items (the package's, and the site's when importing). */\nexport function siteReferenceIndex(\n items: Iterable<{ kind: string; id: string }>,\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n): SiteReferenceIndex {\n const byId = new Map<string, string[]>()\n for (const item of items) {\n const list = byId.get(item.id) ?? []\n if (!list.includes(item.kind)) list.push(item.kind)\n byId.set(item.id, list)\n }\n return {\n kindsOf: (id) => byId.get(id) ?? [],\n searchable: (id) =>\n id.length >= SITE_REFERENCE_MIN_ID_LENGTH &&\n (byId.get(id) ?? []).some((kind) => !kinds.get(kind)?.wordIds),\n }\n}\n\nfunction eachString(value: unknown, visit: (text: string) => void, keys = true): void {\n if (typeof value === 'string') {\n visit(value)\n return\n }\n if (Array.isArray(value)) {\n for (const entry of value) eachString(entry, visit, keys)\n return\n }\n if (value && typeof value === 'object' && !ArrayBuffer.isView(value)) {\n for (const [key, entry] of Object.entries(value)) {\n if (keys) visit(key)\n eachString(entry, visit, keys)\n }\n }\n}\n\n/** The node maps an item's content holds: its own, and its published version's. */\nfunction nodeMaps(content: Doc): Doc[] {\n const maps: Doc[] = []\n for (const holder of [content, asDoc(content['version'])]) {\n for (const key of ['nodes', 'elements']) {\n const nodes = holder[key]\n if (nodes && typeof nodes === 'object' && !Array.isArray(nodes) && !ArrayBuffer.isView(nodes)) {\n maps.push(nodes as Doc)\n }\n }\n }\n return maps\n}\n\n/** What a section answers for its items, by kind. */\nexport type SitePackageSectionHooks = Readonly<Record<string, PluginSiteBundleSectionPackage>>\n\n/**\n * The items one item depends on: its typed references (fields, node\n * placements, binding tokens) whether or not the item they name is known,\n * then every other known id its content names. Never itself.\n */\nexport function siteItemDependencies(\n item: SitePackageItem,\n index: SiteReferenceIndex,\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n sections: SitePackageSectionHooks = {},\n): PackageDependency[] {\n const kind = kinds.get(item.kind)\n const found = new Map<string, PackageDependency>()\n const add = (depKind: string, id: unknown) => {\n if (typeof id !== 'string' || !id) return\n if (depKind === item.kind && id === item.id) return\n found.set(`${depKind}/${id}`, { kind: depKind, id })\n }\n const typed = (candidates: readonly string[], id: unknown) => {\n if (typeof id !== 'string' || !id) return\n const known = index.kindsOf(id)\n add(candidates.find((one) => known.includes(one)) ?? (candidates[0] as string), id)\n }\n const content = item.content\n for (const ref of kind?.references ?? []) {\n const value = content[ref.field]\n if (ref.each === 'values') for (const entry of Object.values(asDoc(value))) typed(ref.kinds, entry)\n else if (ref.each === 'items') for (const entry of Array.isArray(value) ? value : []) typed(ref.kinds, entry)\n else typed(ref.kinds, value)\n }\n if (kind?.versioned) typed(['layout'], asDoc(content['version'])['layoutId'])\n if (item.kind === 'collection') {\n for (const entry of Array.isArray(content['entries']) ? content['entries'] : []) {\n typed(['author'], asDoc(entry)['authorId'])\n }\n }\n const placements: Array<{ kind: string } & SitePackagePlacement> = []\n const tokenKinds: Record<string, string> = {}\n for (const one of kinds.values()) {\n for (const placement of one.placements ?? []) placements.push({ kind: one.kind, ...placement })\n if (one.bindingToken) tokenKinds[one.bindingToken] = one.kind\n }\n for (const nodes of nodeMaps(content)) {\n for (const node of Object.values(nodes)) {\n const shape = asDoc(node)\n const props = asDoc(shape['props'])\n if (shape['componentId'] === REUSABLE_INSTANCE_COMPONENT_ID) typed(['component'], props['refId'])\n for (const placement of placements) {\n if (placement.componentId && placement.componentId !== shape['componentId']) continue\n typed([placement.kind], props[placement.prop])\n }\n }\n }\n eachString(\n content,\n (text) => {\n if (!text.includes('{{')) return\n if (tokenKinds['var']) for (const match of text.matchAll(VAR_TOKEN)) typed([tokenKinds['var']], match[1])\n if (tokenKinds['fn']) for (const match of text.matchAll(FN_TOKEN)) typed([tokenKinds['fn']], match[1])\n },\n false,\n )\n const section = sections[item.kind]\n if (section) {\n for (const dep of section.dependencies({ $id: item.id, ...content })) add(dep.kind, dep.id)\n }\n eachString(content, (text) => {\n for (const token of text.match(ID_TOKEN) ?? []) {\n if (token === item.id || !index.searchable(token)) continue\n for (const known of index.kindsOf(token)) {\n if (!found.has(`${known}/${token}`) && !kinds.get(known)?.wordIds) add(known, token)\n }\n }\n })\n return [...found.values()]\n}\n\n/** An id map for moving references: an id to its new id, or `null` to drop the reference. */\nexport type SiteIdMap = ReadonlyMap<string, string | null>\n\nfunction remapString(text: string, ids: SiteIdMap): string | null {\n if (ids.has(text)) return ids.get(text) as string | null\n let dropped = false\n const withoutTokens = text\n .replace(VAR_TOKEN, (whole, id: string) => (ids.has(id) ? (ids.get(id) === null ? '' : whole.replace(id, ids.get(id) as string)) : whole))\n .replace(FN_TOKEN, (whole, id: string) => (ids.has(id) ? (ids.get(id) === null ? '' : whole.replace(id, ids.get(id) as string)) : whole))\n const next = withoutTokens.replace(ID_TOKEN, (token) => {\n // Inside text only an id long enough never to be a word is moved; an\n // exact value or a map key is moved whatever its length.\n if (token.length < SITE_REFERENCE_MIN_ID_LENGTH || !ids.has(token)) return token\n const moved = ids.get(token)\n if (moved === null) dropped = true\n return moved ?? token\n })\n return dropped ? '' : next\n}\n\n/**\n * The value with every reference in `ids` moved: an exact id, a whole\n * token inside a string, a map key. A dropped reference is `null` in a\n * field, gone from a list or a map, gone as a binding token, and empties\n * any other string it sat in. Unchanged parts keep their identity.\n */\nexport function remapSiteReferences<T>(value: T, ids: SiteIdMap): T {\n if (!ids.size) return value\n const walk = (current: unknown): unknown => {\n if (typeof current === 'string') return remapString(current, ids)\n if (Array.isArray(current)) {\n let changed = false\n const next: unknown[] = []\n for (const entry of current) {\n const moved = walk(entry)\n if (moved !== entry) changed = true\n if (moved === null && typeof entry === 'string') continue\n next.push(moved)\n }\n return changed ? next : current\n }\n if (isPlainSiteObject(current)) {\n let changed = false\n const next: Doc = {}\n for (const [key, entry] of Object.entries(current)) {\n let target = key\n if (ids.has(key)) {\n changed = true\n const moved = ids.get(key)\n if (moved === null) continue\n target = moved as string\n }\n const value = walk(entry)\n if (value !== entry) changed = true\n next[target] = value\n }\n return changed ? next : current\n }\n return current\n }\n return walk(value) as T\n}\n\n/*==========================================\n * PACKAGES\n *=========================================*/\n\n/** How an item is hashed: by default its content as is. */\nexport type SiteItemHasher = (item: SitePackageItem) => Promise<string>\n\n/** What an item is called on the import screen, and matched by. */\nexport function describeSiteItem(\n item: SitePackageItem,\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n): { slug?: string; name?: string } {\n const kind = kinds.get(item.kind)\n const text = (value: unknown) => (typeof value === 'string' && value.trim() ? value : undefined)\n if (kind?.singletonId) return { name: kind.label }\n const slug = kind?.slugField ? text(item.content[kind.slugField]) : undefined\n const name =\n (kind?.nameField ? text(item.content[kind.nameField]) : undefined) ??\n text(item.content['displayName']) ??\n text(item.content['name']) ??\n text(item.content['title']) ??\n text(item.content['fileName'])\n return { ...(slug ? { slug } : {}), ...(name ? { name } : {}) }\n}\n\n/** A site package: the manifest, and each item's content by `<kind>/<id>`. */\nexport type SitePackage = TransferPackage<Doc>\n\n/**\n * Builds a package from items: each hashed (by `hash`, or its content), named,\n * and given its dependencies against `index` — the items themselves, and the\n * site's own when an import is describing what it received.\n */\nexport async function buildSitePackage(\n items: readonly SitePackageItem[],\n options: {\n hash?: SiteItemHasher\n index?: SiteReferenceIndex\n kinds?: ReadonlyMap<string, SitePackageKind>\n sections?: SitePackageSectionHooks\n createdAt?: number\n source?: string\n } = {},\n): Promise<SitePackage> {\n const kinds = options.kinds ?? sitePackageKindMap()\n const index = options.index ?? siteReferenceIndex(items, kinds)\n const hash = options.hash ?? ((item: SitePackageItem) => contentHash(item.content))\n const manifestItems: PackageManifestItem[] = []\n const contents: Record<string, Doc> = {}\n for (const item of items) {\n const entry: PackageManifestItem = {\n kind: item.kind,\n $id: item.id,\n ...describeSiteItem(item, kinds),\n contentHash: await hash(item),\n deps: siteItemDependencies(item, index, kinds, options.sections),\n }\n const key = packageItemKey(entry)\n if (contents[key]) {\n // Two documents under one id are one document on the site: the later\n // one is what a v1 restore left standing, so it is what is kept.\n const at = manifestItems.findIndex((one) => packageItemKey(one) === key)\n manifestItems.splice(at, 1)\n }\n manifestItems.push(entry)\n contents[key] = item.content\n }\n return {\n manifest: {\n format: TRANSFER_PACKAGE_FORMAT,\n version: TRANSFER_PACKAGE_VERSION,\n items: manifestItems,\n ...(options.createdAt !== undefined ? { createdAt: options.createdAt } : {}),\n ...(options.source ? { source: options.source } : {}),\n },\n items: contents,\n }\n}\n\n/** The package's items, back as items. */\nexport function sitePackageItems(pkg: SitePackage): SitePackageItem[] {\n return pkg.manifest.items.map((entry) => ({\n kind: entry.kind,\n id: entry.$id,\n content: asDoc(pkg.items[packageItemKey(entry)]),\n }))\n}\n\n/**\n * The chosen items, and — with `includeDependencies` — everything they need\n * inside the package, transitively. Keys are `<kind>/<id>`; an unknown key\n * is ignored. The manifest keeps every item's full dependency list, so an\n * import can say which ones the file does not carry.\n */\nexport function selectSitePackage(\n pkg: SitePackage,\n keys: Iterable<string>,\n includeDependencies: boolean,\n): SitePackage {\n const wanted = new Set(\n includeDependencies ? packageDependencyClosure(pkg.manifest.items, keys) : [...keys],\n )\n const items = pkg.manifest.items.filter((entry) => wanted.has(packageItemKey(entry)))\n return {\n manifest: { ...pkg.manifest, items },\n items: Object.fromEntries(items.map((entry) => [packageItemKey(entry), pkg.items[packageItemKey(entry)]])),\n }\n}\n\n/** The manifest without the content: the export picker's catalog. */\nexport function sitePackageCatalog(pkg: SitePackage): PackageManifest {\n return pkg.manifest\n}\n\n/** A package read from a file, or why it cannot be. */\nexport type SitePackageRead =\n | { ok: true; items: SitePackageItem[]; manifest: PackageManifest; unknownKinds: string[] }\n | { ok: false; problems: string[] }\n\n/**\n * A v2 package from untrusted JSON: the manifest checked by the core, every\n * listed item's content present and an object, and items of kinds this\n * site does not read set aside (named in `unknownKinds`) rather than\n * refusing the file — a package from a site with a plugin this one lacks\n * still imports the rest.\n */\nexport function readSitePackage(\n raw: unknown,\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n): SitePackageRead {\n const file = asDoc(raw)\n const read = readPackageManifest(file['manifest'])\n if (read.ok === false) return { ok: false, problems: read.problems }\n const contents = asDoc(file['items'])\n const problems: string[] = []\n const items: SitePackageItem[] = []\n const unknown = new Set<string>()\n for (const entry of read.manifest.items) {\n const key = packageItemKey(entry)\n const content = contents[key]\n if (!content || typeof content !== 'object' || Array.isArray(content)) {\n problems.push(`${key} is listed and its content is missing.`)\n continue\n }\n if (!kinds.has(entry.kind)) {\n unknown.add(entry.kind)\n continue\n }\n const kind = kinds.get(entry.kind) as SitePackageKind\n if (kind.singletonId && entry.$id !== kind.singletonId) {\n problems.push(`${key} is a ${entry.kind} item filed under an id other than \"${kind.singletonId}\".`)\n continue\n }\n // The manifest names the item; an `$id` inside its content is not a second say.\n const { $id: _ignored, ...rest } = content as Doc\n items.push({ kind: entry.kind, id: entry.$id, content: rest })\n }\n if (problems.length) return { ok: false, problems }\n return { ok: true, items, manifest: read.manifest, unknownKinds: [...unknown] }\n}\n\n/*==========================================\n * THE IMPORT PLAN — nothing written\n *=========================================*/\n\n/** One item of the plan the import screen shows. */\nexport interface SitePackagePlanItem {\n key: string\n kind: string\n id: string\n name?: string\n slug?: string\n status: PackageItemStatus\n comparison: PackageItemComparison\n /** The site item it was matched to, and how. */\n existing?: { id: string; name?: string; slug?: string }\n matchedBy?: 'id' | 'slug' | 'name'\n /** What it needs, and of that what neither the package nor the site holds. */\n deps: PackageDependency[]\n missing: PackageDependency[]\n /** The decision proposed, and whether the person must make one. */\n proposed: PackageItemDecision\n needsChoice: boolean\n /** Every decision the item may take. */\n choices: PackageItemDecision[]\n}\n\n/** The plan for a whole package. */\nexport interface SitePackagePlan {\n items: SitePackagePlanItem[]\n counts: Record<PackageItemStatus, number>\n /** Each kind present, with its label and how many items. */\n kinds: Array<{ kind: string; label: string; count: number }>\n}\n\n/** A site item as the plan compares against it. */\nexport type SiteExistingItem = ExistingPackageItem\n\n/**\n * Every incoming item against the site: matched by id, then slug, then name\n * within its kind; `identical` when the hashes agree; `missingDependency`\n * when it names an item neither side holds. Proposes create for new items\n * and skip for everything else — replacing is never assumed.\n */\nexport function planSitePackageImport(\n incoming: SitePackage,\n existing: readonly SiteExistingItem[],\n kinds: ReadonlyMap<string, SitePackageKind> = sitePackageKindMap(),\n): SitePackagePlan {\n const matches = matchPackageItems(incoming.manifest, existing)\n const counts: Record<PackageItemStatus, number> = { new: 0, identical: 0, differs: 0, missingDependency: 0 }\n const perKind = new Map<string, number>()\n const items = matches.map((match): SitePackagePlanItem => {\n const kind = kinds.get(match.item.kind)\n const proposed = proposePackageDecision(match)\n counts[match.status] += 1\n perKind.set(match.item.kind, (perKind.get(match.item.kind) ?? 0) + 1)\n return {\n key: packageItemKey(match.item),\n kind: match.item.kind,\n id: match.item.$id,\n ...(match.item.name ? { name: match.item.name } : {}),\n ...(match.item.slug ? { slug: match.item.slug } : {}),\n status: match.status,\n comparison: match.comparison,\n ...(match.existing\n ? {\n existing: {\n id: match.existing.id,\n ...(match.existing.name ? { name: match.existing.name } : {}),\n ...(match.existing.slug ? { slug: match.existing.slug } : {}),\n },\n matchedBy: match.matchedBy,\n }\n : {}),\n deps: match.item.deps,\n missing: match.missing,\n proposed: proposed.decision,\n needsChoice: proposed.needsChoice,\n choices: packageDecisionsFor(match, Boolean(kind?.mergeable)).filter(\n // A singleton or a catalog key has one place to be: a second copy\n // has nowhere to go.\n (choice) => !(kind?.noCopies && choice === 'keepBoth'),\n ),\n }\n })\n return {\n items,\n counts,\n kinds: [...perKind.entries()].map(([kind, count]) => ({\n kind,\n label: kinds.get(kind)?.label ?? kind,\n count,\n })),\n }\n}\n\n/*==========================================\n * DECISIONS → WRITES\n *=========================================*/\n\n/**\n * What to do about a dependency neither side will hold after the import:\n * `import` the package's copy (when the package carries it and the person\n * skipped it), map it to an item the site holds (`mapTo`), `drop` the\n * reference, or `keep` it as it is — pointing at nothing until that item\n * exists.\n */\nexport type SitePackageDependencyChoice = 'import' | 'keep' | 'drop' | { mapTo: string }\n\n/** Whose value one key of a merged item takes. */\nexport type SitePackageMergeChoice = 'site' | 'package'\n\n/** How the import decides. */\nexport type SitePackageImportMode =\n /**\n * The person's decisions, each item's own or the proposed one: the\n * import plan's way.\n */\n | 'decide'\n /**\n * A whole-site restore: every item under its own id — created where the\n * site lacks the id, replaced where it holds it — whatever its slug or\n * name, exactly as a v1 backup restored.\n */\n | 'restore'\n\nexport interface ResolveSitePackageInput {\n incoming: SitePackage\n plan: SitePackagePlan\n mode: SitePackageImportMode\n /** The person's decision per item key; the proposed one where absent. */\n decisions?: Readonly<Record<string, PackageItemDecision>>\n /** The person's choice per dependency key (`<kind>/<id>`). */\n dependencyChoices?: Readonly<Record<string, SitePackageDependencyChoice>>\n /**\n * For a merged item, whose value each top-level key takes, by item key\n * then key: `site` keeps the site's, `package` takes the file's. A key\n * not named merges as {@link mergeSiteFields} does.\n */\n mergeChoices?: Readonly<Record<string, Readonly<Record<string, SitePackageMergeChoice>>>>\n /** The site's items: their content (for merge) and slugs (for keep both). */\n existing: readonly (SiteExistingItem & { content?: Doc })[]\n /** A new id for an item kept beside an existing one. */\n newId: () => string\n kinds?: ReadonlyMap<string, SitePackageKind>\n sections?: SitePackageSectionHooks\n}\n\n/** A warning the import reports beside its writes. */\nexport interface SitePackageWarning {\n code: 'droppedReference' | 'danglingReference' | 'mappedReference'\n item: string\n dependency: string\n message: string\n}\n\nexport interface ResolvedSitePackageImport {\n writes: SitePackageWrite[]\n skipped: string[]\n warnings: SitePackageWarning[]\n /** Item key → the id it is written under, for every item that moved. */\n moved: Record<string, string>\n}\n\n/** Why the decisions cannot be applied. */\nexport class SitePackageDecisionError extends Error {\n constructor(readonly problems: string[]) {\n super(problems.join(' '))\n this.name = 'SitePackageDecisionError'\n }\n}\n\n/**\n * Site fields filled from the incoming item only where the site holds\n * none, at every depth of a plain object: the site's own value wins\n * wherever it has one.\n */\nexport function mergeSiteFields(existing: unknown, incoming: unknown): unknown {\n if (existing === undefined || existing === null) return incoming\n if (!isPlainSiteObject(existing) || !isPlainSiteObject(incoming)) return existing\n const out: Doc = { ...(existing as Doc) }\n for (const [key, value] of Object.entries(incoming as Doc)) out[key] = mergeSiteFields(out[key], value)\n return out\n}\n\n/**\n * The writes an import makes: which items are written, under which ids,\n * with every reference moved — to an item kept beside an existing one, to\n * the site item an incoming one was matched to, to an item the person\n * mapped a missing dependency onto — and the references dropped.\n */\nexport function resolveSitePackageImport(input: ResolveSitePackageInput): ResolvedSitePackageImport {\n const kinds = input.kinds ?? sitePackageKindMap()\n const problems: string[] = []\n const planByKey = new Map(input.plan.items.map((item) => [item.key, item]))\n const existingByKey = new Map(input.existing.map((item) => [`${item.kind}/${item.id}`, item]))\n const decided = new Map<string, PackageItemDecision>()\n for (const item of input.plan.items) {\n let decision: PackageItemDecision\n if (input.mode === 'restore') {\n decision = existingByKey.has(item.key) ? 'replace' : 'create'\n } else {\n decision = input.decisions?.[item.key] ?? item.proposed\n if (!item.choices.includes(decision)) {\n problems.push(`${item.key} cannot be \"${decision}\"; it may be ${item.choices.join(', ')}.`)\n }\n }\n decided.set(item.key, decision)\n }\n for (const key of Object.keys(input.decisions ?? {})) {\n if (!planByKey.has(key)) problems.push(`${key} is not in the package.`)\n }\n for (const [key, choices] of Object.entries(input.mergeChoices ?? {})) {\n if (decided.get(key) !== 'merge') {\n problems.push(`${key} is not merged, so its keys cannot be chosen.`)\n continue\n }\n for (const [field, choice] of Object.entries(choices ?? {})) {\n if (choice !== 'site' && choice !== 'package') {\n problems.push(`${key} key \"${field}\" cannot take \"${String(choice)}\"; it may take site or package.`)\n }\n }\n }\n\n // A dependency the person asked to import from the package is created\n // when it was new and set aside.\n for (const [depKey, choice] of Object.entries(input.dependencyChoices ?? {})) {\n if (choice !== 'import') continue\n const dep = planByKey.get(depKey)\n if (!dep) {\n problems.push(`${depKey} is not in the package, so it cannot be imported from it.`)\n continue\n }\n if (decided.get(depKey) === 'skip') decided.set(depKey, dep.comparison === 'new' ? 'create' : 'replace')\n }\n if (problems.length) throw new SitePackageDecisionError(problems)\n\n const takenSlugs = new Map<string, Set<string>>()\n const slugsOf = (kind: string) => {\n if (!takenSlugs.has(kind)) {\n takenSlugs.set(\n kind,\n new Set(\n [\n ...input.existing.filter((one) => one.kind === kind).map((one) => one.slug),\n ...input.plan.items.filter((one) => one.kind === kind).map((one) => one.slug),\n ].filter((slug): slug is string => Boolean(slug)),\n ),\n )\n }\n return takenSlugs.get(kind) as Set<string>\n }\n\n // Where each incoming item lands, and so where references to it go.\n const target = new Map<string, string>()\n const moved: Record<string, string> = {}\n for (const item of input.plan.items) {\n const decision = decided.get(item.key) as PackageItemDecision\n let id = item.id\n if (decision === 'keepBoth') id = input.newId()\n else if (item.existing && input.mode === 'decide') id = item.existing.id\n target.set(item.key, id)\n if (id !== item.id) moved[item.key] = id\n }\n\n // Every dependency that will exist nowhere after the import.\n const written = new Set(\n input.plan.items.filter((item) => decided.get(item.key) !== 'skip').map((item) => item.key),\n )\n const onSite = new Set(existingByKey.keys())\n const warnings: SitePackageWarning[] = []\n // Moves by item key; the raw id map below is what content walks use.\n const keyed = new Map<string, string | null>()\n for (const [key, id] of target) {\n const item = planByKey.get(key) as SitePackagePlanItem\n // A skipped item that matched nothing on the site leaves its references\n // to the dependency step below.\n if (decided.get(key) === 'skip' && !item.existing) continue\n if (id !== item.id) keyed.set(key, id)\n }\n for (const item of input.plan.items) {\n if (!written.has(item.key)) continue\n for (const dep of item.deps) {\n const depKey = `${dep.kind}/${dep.id}`\n if (written.has(depKey) || onSite.has(depKey)) continue\n if (planByKey.get(depKey)?.existing) continue\n const choice = input.dependencyChoices?.[depKey] ?? 'keep'\n if (typeof choice === 'object') {\n keyed.set(depKey, choice.mapTo)\n warnings.push({\n code: 'mappedReference',\n item: item.key,\n dependency: depKey,\n message: `${item.key} pointed at ${depKey}, which this site does not hold; it now points at ${dep.kind}/${choice.mapTo}.`,\n })\n } else if (choice === 'drop') {\n keyed.set(depKey, null)\n warnings.push({\n code: 'droppedReference',\n item: item.key,\n dependency: depKey,\n message: `${item.key} pointed at ${depKey}, which this site does not hold; the reference was removed.`,\n })\n } else {\n warnings.push({\n code: 'danglingReference',\n item: item.key,\n dependency: depKey,\n message: `${item.key} points at ${depKey}, which this site does not hold, and will until it does.`,\n })\n }\n }\n }\n // Ids that are words (a catalog key, `default`) are never moved through\n // content: the word would be rewritten wherever it is written.\n const idMap = new Map<string, string | null>()\n for (const [key, id] of keyed) {\n const kindName = key.slice(0, key.indexOf('/'))\n if (kinds.get(kindName)?.wordIds) continue\n idMap.set(key.slice(key.indexOf('/') + 1), id)\n }\n\n const writes: SitePackageWrite[] = []\n const skipped: string[] = []\n const contents = input.incoming.items\n for (const item of input.plan.items) {\n const decision = decided.get(item.key) as PackageItemDecision\n if (decision === 'skip') {\n skipped.push(item.key)\n continue\n }\n const kind = kinds.get(item.kind)\n const targetId = target.get(item.key) as string\n let ids: Map<string, string | null> = idMap\n if (kind?.keepsOwnId && idMap.has(item.id)) {\n ids = new Map(idMap)\n ids.delete(item.id)\n }\n let content = remapSiteReferences(asDoc(contents[item.key]), ids)\n const section = input.sections?.[item.kind]\n if (section && keyed.size) {\n const { $id: _id, ...rest } = section.remapIds({ $id: item.id, ...content }, keyed)\n content = rest\n }\n if (decision === 'keepBoth') {\n if (kind?.slugField && typeof content[kind.slugField] === 'string') {\n const slug = content[kind.slugField] as string\n const fresh = keepBothSlug(slug, slugsOf(item.kind))\n slugsOf(item.kind).add(fresh)\n content = { ...content, [kind.slugField]: fresh }\n if (typeof content['route'] === 'string') {\n content = { ...content, route: movedRoute(content['route'] as string, slug, fresh) }\n if (content['route'] === null) delete content['route']\n }\n } else if (kind?.nameField && typeof content[kind.nameField] === 'string') {\n content = { ...content, [kind.nameField]: `${content[kind.nameField] as string} (copy)` }\n }\n }\n let existingKey: string | undefined\n if (decision === 'replace' || decision === 'merge') {\n existingKey = `${item.kind}/${targetId}`\n }\n if (decision === 'merge') {\n const current = asDoc(existingByKey.get(existingKey as string)?.content)\n const incomingContent = content\n content = mergeSiteFields(current, incomingContent) as Doc\n for (const [field, choice] of Object.entries(input.mergeChoices?.[item.key] ?? {})) {\n const value = choice === 'package' ? incomingContent[field] : current[field]\n if (value === undefined) delete content[field]\n else content[field] = value\n }\n }\n writes.push({\n key: item.key,\n kind: item.kind,\n sourceId: item.id,\n targetId,\n decision,\n content,\n ...(existingKey ? { existingKey } : {}),\n })\n }\n return { writes, skipped, warnings, moved }\n}\n\n/**\n * A kept-both page's address: the original's with its last segment moved\n * to the copy's slug, or `null` — no address — when the original's address\n * does not end in its slug and so says nothing about where a copy goes.\n */\nfunction movedRoute(route: string, slug: string, fresh: string): string | null {\n const trim = (value: string) => value.replace(/^\\/+|\\/+$/g, '')\n const from = trim(slug)\n const to = trim(fresh)\n const segments = route.split('/')\n if (!from || segments[segments.length - 1] !== from) return null\n segments[segments.length - 1] = to\n return segments.join('/')\n}\n\n/** Whether a package carries the format and version this module writes. */\nexport function isSitePackageFile(raw: unknown): boolean {\n const manifest = asDoc(asDoc(raw)['manifest'])\n return manifest['format'] === TRANSFER_PACKAGE_FORMAT && manifest['version'] === TRANSFER_PACKAGE_VERSION\n}\n"],"names":["REUSABLE_INSTANCE_COMPONENT_ID","SCREEN_KIND_EMAIL","listPluginSiteExportCollections","listDeclaredSiteBundleSections","contentHash","keepBothSlug","matchPackageItems","packageDecisionsFor","packageDependencyClosure","packageItemKey","proposePackageDecision","readPackageManifest","TRANSFER_PACKAGE_FORMAT","TRANSFER_PACKAGE_VERSION","SITE_SETTINGS_ITEM_ID","SITE_THEME_ITEM_ID","SITE_SCREEN_KINDS","SCREEN_REFS","PLATFORM_SITE_PACKAGE_KINDS","kind","label","source","bundleKey","mergeable","wordIds","noCopies","singletonId","references","field","kinds","each","slugField","nameField","versioned","keepsOwnId","listSitePackageKinds","declared","pkg","package","push","collection","map","ref","bindingToken","placements","length","key","seen","Set","one","has","Error","add","sitePackageKindMap","Map","SITE_ROUTING_MAP_FIELD","isPlainSiteObject","value","Array","isArray","proto","Object","getPrototypeOf","asDoc","pick","fields","out","undefined","keys","screenPackageKind","screen","siteBundleItems","bundle","contract","host","routes","items","arrays","array","raw","limit","limits","set","slice","get","themeFields","settingsFields","content","id","doc","$id","_id","rest","route","String","siteWritesToBundle","writes","hostPatch","write","assign","targetId","SITE_REFERENCE_MIN_ID_LENGTH","ID_TOKEN","VAR_TOKEN","FN_TOKEN","siteReferenceIndex","byId","item","list","includes","kindsOf","searchable","some","eachString","visit","entry","ArrayBuffer","isView","entries","nodeMaps","maps","holder","nodes","siteItemDependencies","index","sections","found","depKind","typed","candidates","known","find","values","tokenKinds","placement","node","shape","props","componentId","prop","text","match","matchAll","section","dep","dependencies","token","remapString","ids","dropped","withoutTokens","replace","whole","next","moved","remapSiteReferences","size","walk","current","changed","target","describeSiteItem","trim","name","slug","buildSitePackage","options","hash","manifestItems","contents","deps","at","findIndex","splice","manifest","format","version","createdAt","sitePackageItems","selectSitePackage","includeDependencies","wanted","filter","fromEntries","sitePackageCatalog","readSitePackage","file","read","ok","problems","unknown","_ignored","unknownKinds","planSitePackageImport","incoming","existing","matches","counts","new","identical","differs","missingDependency","perKind","proposed","status","comparison","matchedBy","missing","decision","needsChoice","choices","Boolean","choice","count","SitePackageDecisionError","join","mergeSiteFields","resolveSitePackageImport","input","planByKey","plan","existingByKey","decided","mode","decisions","mergeChoices","depKey","dependencyChoices","takenSlugs","slugsOf","newId","written","onSite","warnings","keyed","mapTo","code","dependency","message","idMap","kindName","indexOf","skipped","delete","remapIds","fresh","movedRoute","existingKey","incomingContent","sourceId","from","to","segments","split","isSitePackageFile"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,8BAA8B,QAAQ,0CAAsC;AACrF,SAASC,iBAAiB,QAAQ,+BAA2B;AAC7D,SAASC,+BAA+B,QAAQ,0CAAsC;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ache 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
|
+
import type { TransferFormat } from './resource';
|
|
18
|
+
/** A delimiter a CSV may use. A pipe is read when the person names it; detection never guesses it. */
|
|
19
|
+
export type TransferCsvDelimiter = ',' | ';' | '\t' | '|';
|
|
20
|
+
/** The delimiters detection chooses among. */
|
|
21
|
+
export declare const TRANSFER_CSV_DELIMITERS: readonly TransferCsvDelimiter[];
|
|
22
|
+
/** How the person confirmed a CSV is read, over what detection would guess. */
|
|
23
|
+
export interface TransferSourceOptions {
|
|
24
|
+
/** The cell separator; detected from the header line when absent. */
|
|
25
|
+
delimiter?: TransferCsvDelimiter;
|
|
26
|
+
/** `false` when the first line is a row, not names: the columns are then "Column 1", "Column 2"… Default `true`. */
|
|
27
|
+
headerRow?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** A file read into a header and rows. */
|
|
30
|
+
export interface TransferSourceTable {
|
|
31
|
+
format: TransferFormat;
|
|
32
|
+
/** The delimiter a CSV was read with. */
|
|
33
|
+
delimiter?: TransferCsvDelimiter;
|
|
34
|
+
headers: string[];
|
|
35
|
+
/** Cells in header order; a short CSV line is padded with `''`. */
|
|
36
|
+
rows: unknown[][];
|
|
37
|
+
}
|
|
38
|
+
/** A file that could not be read, with a sentence the person reads. */
|
|
39
|
+
export interface TransferSourceProblem {
|
|
40
|
+
code: 'empty' | 'invalidJson' | 'notRows' | 'noHeader';
|
|
41
|
+
message: string;
|
|
42
|
+
/** The 1-based line, where one is to blame. */
|
|
43
|
+
line?: number;
|
|
44
|
+
}
|
|
45
|
+
export type TransferSourceRead = {
|
|
46
|
+
ok: true;
|
|
47
|
+
table: TransferSourceTable;
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
problem: TransferSourceProblem;
|
|
51
|
+
};
|
|
52
|
+
/** The format a file name says, or `null` when its extension says nothing. */
|
|
53
|
+
export declare function transferFormatFromFileName(fileName: string | null | undefined): TransferFormat | null;
|
|
54
|
+
/** The format a file's first characters suggest: `[` is JSON, `{` NDJSON, anything else CSV. */
|
|
55
|
+
export declare function sniffTransferFormat(text: string): TransferFormat;
|
|
56
|
+
/** The media type an upload of `format` is inspected and stored as. */
|
|
57
|
+
export declare function transferContentType(format: TransferFormat): string;
|
|
58
|
+
/** The delimiter that splits the header line most; comma on a tie or a one-column file. */
|
|
59
|
+
export declare function detectCsvDelimiter(text: string): TransferCsvDelimiter;
|
|
60
|
+
/**
|
|
61
|
+
* CSV text into rows of cells (header included), wholly blank lines dropped.
|
|
62
|
+
* A cell an export guarded against running as a spreadsheet formula (`'=…`)
|
|
63
|
+
* reads back as it was (`=…`), so an export imported again is unchanged.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseTransferCsv(text: string, delimiter?: TransferCsvDelimiter): string[][];
|
|
66
|
+
/**
|
|
67
|
+
* A file's text read as `format` (see the block header). For a CSV,
|
|
68
|
+
* `options` carries what the person confirmed in the upload step — the
|
|
69
|
+
* delimiter, and whether the first line names the columns — so the server
|
|
70
|
+
* reads the file exactly as the browser previewed it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function readTransferSource(text: string, format: TransferFormat, options?: TransferSourceOptions): TransferSourceRead;
|
|
73
|
+
/** A cell as the text a sample, a result file or a preview shows. */
|
|
74
|
+
export declare function transferCellText(value: unknown): string;
|
|
@@ -0,0 +1,293 @@
|
|
|
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
|
+
* THE SOURCE FILE — an uploaded file read as a header and rows of cells.
|
|
18
|
+
*
|
|
19
|
+
* Every import reads its file the same way, in the browser (to show the
|
|
20
|
+
* upload step's counts before anything is sent) and on the server (to plan
|
|
21
|
+
* and apply), so the two can never disagree about which line is row 3.
|
|
22
|
+
*
|
|
23
|
+
* - CSV: RFC 4180 (quoted cells, doubled quotes, CRLF or LF), a leading
|
|
24
|
+
* byte-order mark dropped, and the delimiter detected from the header
|
|
25
|
+
* line — comma, semicolon or tab, whichever splits it most outside
|
|
26
|
+
* quotes. A wholly blank line is not a row. A cell an export guarded
|
|
27
|
+
* against running as a formula (a `'` before `=`, `+`, `-`, `@`, a tab
|
|
28
|
+
* or a carriage return) loses that one `'`.
|
|
29
|
+
* - JSON: an array of objects (or `{ "rows": [...] }`). The header is
|
|
30
|
+
* every key in first-seen order; a cell keeps its JSON value, so a nested
|
|
31
|
+
* object reaches a `json` field intact.
|
|
32
|
+
* - NDJSON: one object per line, read the same way.
|
|
33
|
+
*
|
|
34
|
+
* Rows are numbered from 0 in file order, not counting the header; that
|
|
35
|
+
* index is the row every plan, ledger entry and result names.
|
|
36
|
+
*=========================================*/ import { restoreCsvFormulaCell } from "../app-utils/csv.js";
|
|
37
|
+
/** The delimiters detection chooses among. */ export const TRANSFER_CSV_DELIMITERS = [
|
|
38
|
+
',',
|
|
39
|
+
';',
|
|
40
|
+
'\t'
|
|
41
|
+
];
|
|
42
|
+
/** The format a file name says, or `null` when its extension says nothing. */ export function transferFormatFromFileName(fileName) {
|
|
43
|
+
var _exec_, _exec;
|
|
44
|
+
const extension = (_exec = /\.([a-z0-9]+)$/i.exec(String(fileName != null ? fileName : '').trim())) == null ? void 0 : (_exec_ = _exec[1]) == null ? void 0 : _exec_.toLowerCase();
|
|
45
|
+
if (extension === 'csv' || extension === 'tsv' || extension === 'txt') return 'csv';
|
|
46
|
+
if (extension === 'json') return 'json';
|
|
47
|
+
if (extension === 'ndjson' || extension === 'jsonl') return 'ndjson';
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
/** The format a file's first characters suggest: `[` is JSON, `{` NDJSON, anything else CSV. */ export function sniffTransferFormat(text) {
|
|
51
|
+
const start = stripBom(text).trimStart();
|
|
52
|
+
if (start.startsWith('[')) return 'json';
|
|
53
|
+
if (start.startsWith('{')) {
|
|
54
|
+
var _start_split_;
|
|
55
|
+
const firstLine = (_start_split_ = start.split(/\r?\n/, 1)[0]) != null ? _start_split_ : '';
|
|
56
|
+
// `{ "rows": [...] }` spread over lines is JSON; one object per line is NDJSON.
|
|
57
|
+
try {
|
|
58
|
+
JSON.parse(firstLine);
|
|
59
|
+
return 'ndjson';
|
|
60
|
+
} catch (unused) {
|
|
61
|
+
return 'json';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return 'csv';
|
|
65
|
+
}
|
|
66
|
+
/** The media type an upload of `format` is inspected and stored as. */ export function transferContentType(format) {
|
|
67
|
+
if (format === 'json') return 'application/json';
|
|
68
|
+
if (format === 'ndjson') return 'application/x-ndjson';
|
|
69
|
+
return 'text/csv';
|
|
70
|
+
}
|
|
71
|
+
function stripBom(text) {
|
|
72
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
73
|
+
}
|
|
74
|
+
/** How many times `delimiter` splits `line` outside quotes. */ function countOutsideQuotes(line, delimiter) {
|
|
75
|
+
let count = 0;
|
|
76
|
+
let quoted = false;
|
|
77
|
+
for (const char of line){
|
|
78
|
+
if (char === '"') quoted = !quoted;
|
|
79
|
+
else if (!quoted && char === delimiter) count += 1;
|
|
80
|
+
}
|
|
81
|
+
return count;
|
|
82
|
+
}
|
|
83
|
+
/** The delimiter that splits the header line most; comma on a tie or a one-column file. */ export function detectCsvDelimiter(text) {
|
|
84
|
+
var _stripBom_split_;
|
|
85
|
+
const header = (_stripBom_split_ = stripBom(text).split(/\r?\n/, 1)[0]) != null ? _stripBom_split_ : '';
|
|
86
|
+
let best = ',';
|
|
87
|
+
let bestCount = countOutsideQuotes(header, ',');
|
|
88
|
+
for (const delimiter of TRANSFER_CSV_DELIMITERS){
|
|
89
|
+
const count = countOutsideQuotes(header, delimiter);
|
|
90
|
+
if (count > bestCount) {
|
|
91
|
+
best = delimiter;
|
|
92
|
+
bestCount = count;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return best;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* CSV text into rows of cells (header included), wholly blank lines dropped.
|
|
99
|
+
* A cell an export guarded against running as a spreadsheet formula (`'=…`)
|
|
100
|
+
* reads back as it was (`=…`), so an export imported again is unchanged.
|
|
101
|
+
*/ export function parseTransferCsv(text, delimiter = ',') {
|
|
102
|
+
const source = stripBom(String(text != null ? text : ''));
|
|
103
|
+
const rows = [];
|
|
104
|
+
let row = [];
|
|
105
|
+
let cell = '';
|
|
106
|
+
let quoted = false;
|
|
107
|
+
const endRow = ()=>{
|
|
108
|
+
row.push(restoreCsvFormulaCell(cell));
|
|
109
|
+
if (row.some((entry)=>entry.trim() !== '')) rows.push(row);
|
|
110
|
+
row = [];
|
|
111
|
+
cell = '';
|
|
112
|
+
};
|
|
113
|
+
for(let at = 0; at < source.length; at += 1){
|
|
114
|
+
const char = source[at];
|
|
115
|
+
if (quoted) {
|
|
116
|
+
if (char === '"') {
|
|
117
|
+
if (source[at + 1] === '"') {
|
|
118
|
+
cell += '"';
|
|
119
|
+
at += 1;
|
|
120
|
+
} else {
|
|
121
|
+
quoted = false;
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
cell += char;
|
|
125
|
+
}
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (char === '"' && cell === '') quoted = true;
|
|
129
|
+
else if (char === delimiter) {
|
|
130
|
+
row.push(restoreCsvFormulaCell(cell));
|
|
131
|
+
cell = '';
|
|
132
|
+
} else if (char === '\n') endRow();
|
|
133
|
+
else if (char === '\r') {
|
|
134
|
+
if (source[at + 1] !== '\n') endRow();
|
|
135
|
+
} else cell += char;
|
|
136
|
+
}
|
|
137
|
+
if (cell !== '' || row.length) endRow();
|
|
138
|
+
return rows;
|
|
139
|
+
}
|
|
140
|
+
/** Objects into a header (keys in first-seen order) and rows. */ function tableFromObjects(format, objects) {
|
|
141
|
+
const headers = [];
|
|
142
|
+
const seen = new Set();
|
|
143
|
+
for (const [index, object] of objects.entries()){
|
|
144
|
+
if (!object || typeof object !== 'object' || Array.isArray(object)) {
|
|
145
|
+
return {
|
|
146
|
+
ok: false,
|
|
147
|
+
problem: {
|
|
148
|
+
code: 'notRows',
|
|
149
|
+
message: `Entry ${index + 1} is not an object with named values.`
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
for (const key of Object.keys(object)){
|
|
154
|
+
if (seen.has(key)) continue;
|
|
155
|
+
seen.add(key);
|
|
156
|
+
headers.push(key);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (!headers.length) return {
|
|
160
|
+
ok: false,
|
|
161
|
+
problem: {
|
|
162
|
+
code: 'noHeader',
|
|
163
|
+
message: 'The file names no fields.'
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const rows = objects.map((object)=>headers.map((key)=>{
|
|
167
|
+
const value = object[key];
|
|
168
|
+
return value === undefined || value === null ? '' : value;
|
|
169
|
+
}));
|
|
170
|
+
return {
|
|
171
|
+
ok: true,
|
|
172
|
+
table: {
|
|
173
|
+
format,
|
|
174
|
+
headers,
|
|
175
|
+
rows
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A file's text read as `format` (see the block header). For a CSV,
|
|
181
|
+
* `options` carries what the person confirmed in the upload step — the
|
|
182
|
+
* delimiter, and whether the first line names the columns — so the server
|
|
183
|
+
* reads the file exactly as the browser previewed it.
|
|
184
|
+
*/ export function readTransferSource(text, format, options = {}) {
|
|
185
|
+
var _options_delimiter;
|
|
186
|
+
const source = stripBom(String(text != null ? text : ''));
|
|
187
|
+
if (!source.trim()) return {
|
|
188
|
+
ok: false,
|
|
189
|
+
problem: {
|
|
190
|
+
code: 'empty',
|
|
191
|
+
message: 'The file is empty.'
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
if (format === 'json') {
|
|
195
|
+
let parsed;
|
|
196
|
+
try {
|
|
197
|
+
parsed = JSON.parse(source);
|
|
198
|
+
} catch (unused) {
|
|
199
|
+
return {
|
|
200
|
+
ok: false,
|
|
201
|
+
problem: {
|
|
202
|
+
code: 'invalidJson',
|
|
203
|
+
message: 'The file is not valid JSON.'
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
const list = Array.isArray(parsed) ? parsed : parsed && typeof parsed === 'object' && Array.isArray(parsed['rows']) ? parsed['rows'] : null;
|
|
208
|
+
if (!list) {
|
|
209
|
+
return {
|
|
210
|
+
ok: false,
|
|
211
|
+
problem: {
|
|
212
|
+
code: 'notRows',
|
|
213
|
+
message: 'The file is not a list of records (an array, or an object with "rows").'
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return tableFromObjects('json', list);
|
|
218
|
+
}
|
|
219
|
+
if (format === 'ndjson') {
|
|
220
|
+
const objects = [];
|
|
221
|
+
const lines = source.split(/\r?\n/);
|
|
222
|
+
for (const [index, line] of lines.entries()){
|
|
223
|
+
if (!line.trim()) continue;
|
|
224
|
+
try {
|
|
225
|
+
objects.push(JSON.parse(line));
|
|
226
|
+
} catch (unused) {
|
|
227
|
+
return {
|
|
228
|
+
ok: false,
|
|
229
|
+
problem: {
|
|
230
|
+
code: 'invalidJson',
|
|
231
|
+
message: `Line ${index + 1} is not valid JSON.`,
|
|
232
|
+
line: index + 1
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return tableFromObjects('ndjson', objects);
|
|
238
|
+
}
|
|
239
|
+
const delimiter = (_options_delimiter = options.delimiter) != null ? _options_delimiter : detectCsvDelimiter(source);
|
|
240
|
+
if (options.headerRow === false) {
|
|
241
|
+
const lines = parseTransferCsv(source, delimiter);
|
|
242
|
+
const width = lines.reduce((most, line)=>Math.max(most, line.length), 0);
|
|
243
|
+
const headers = Array.from({
|
|
244
|
+
length: width
|
|
245
|
+
}, (_unused, index)=>`Column ${index + 1}`);
|
|
246
|
+
const rows = lines.map((cells)=>cells.length >= width ? cells : [
|
|
247
|
+
...cells,
|
|
248
|
+
...new Array(width - cells.length).fill('')
|
|
249
|
+
]);
|
|
250
|
+
return {
|
|
251
|
+
ok: true,
|
|
252
|
+
table: {
|
|
253
|
+
format: 'csv',
|
|
254
|
+
delimiter,
|
|
255
|
+
headers,
|
|
256
|
+
rows
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const [header, ...body] = parseTransferCsv(source, delimiter);
|
|
261
|
+
if (!header || !header.some((cell)=>cell.trim())) {
|
|
262
|
+
return {
|
|
263
|
+
ok: false,
|
|
264
|
+
problem: {
|
|
265
|
+
code: 'noHeader',
|
|
266
|
+
message: 'The file has no header row.',
|
|
267
|
+
line: 1
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const headers = header.map((cell, index)=>cell.trim() || `Column ${index + 1}`);
|
|
272
|
+
const rows = body.map((cells)=>cells.length >= headers.length ? cells : [
|
|
273
|
+
...cells,
|
|
274
|
+
...new Array(headers.length - cells.length).fill('')
|
|
275
|
+
]);
|
|
276
|
+
return {
|
|
277
|
+
ok: true,
|
|
278
|
+
table: {
|
|
279
|
+
format: 'csv',
|
|
280
|
+
delimiter,
|
|
281
|
+
headers,
|
|
282
|
+
rows
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/** A cell as the text a sample, a result file or a preview shows. */ export function transferCellText(value) {
|
|
287
|
+
if (value === null || value === undefined) return '';
|
|
288
|
+
if (typeof value === 'string') return value;
|
|
289
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
290
|
+
return JSON.stringify(value);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/data-transfer/source.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE SOURCE FILE — an uploaded file read as a header and rows of cells.\n *\n * Every import reads its file the same way, in the browser (to show the\n * upload step's counts before anything is sent) and on the server (to plan\n * and apply), so the two can never disagree about which line is row 3.\n *\n * - CSV: RFC 4180 (quoted cells, doubled quotes, CRLF or LF), a leading\n * byte-order mark dropped, and the delimiter detected from the header\n * line — comma, semicolon or tab, whichever splits it most outside\n * quotes. A wholly blank line is not a row. A cell an export guarded\n * against running as a formula (a `'` before `=`, `+`, `-`, `@`, a tab\n * or a carriage return) loses that one `'`.\n * - JSON: an array of objects (or `{ \"rows\": [...] }`). The header is\n * every key in first-seen order; a cell keeps its JSON value, so a nested\n * object reaches a `json` field intact.\n * - NDJSON: one object per line, read the same way.\n *\n * Rows are numbered from 0 in file order, not counting the header; that\n * index is the row every plan, ledger entry and result names.\n *=========================================*/\n\nimport { restoreCsvFormulaCell } from '../app-utils/csv'\nimport type { TransferFormat } from './resource'\n\n/** A delimiter a CSV may use. A pipe is read when the person names it; detection never guesses it. */\nexport type TransferCsvDelimiter = ',' | ';' | '\\t' | '|'\n\n/** The delimiters detection chooses among. */\nexport const TRANSFER_CSV_DELIMITERS: readonly TransferCsvDelimiter[] = [',', ';', '\\t']\n\n/** How the person confirmed a CSV is read, over what detection would guess. */\nexport interface TransferSourceOptions {\n /** The cell separator; detected from the header line when absent. */\n delimiter?: TransferCsvDelimiter\n /** `false` when the first line is a row, not names: the columns are then \"Column 1\", \"Column 2\"… Default `true`. */\n headerRow?: boolean\n}\n\n/** A file read into a header and rows. */\nexport interface TransferSourceTable {\n format: TransferFormat\n /** The delimiter a CSV was read with. */\n delimiter?: TransferCsvDelimiter\n headers: string[]\n /** Cells in header order; a short CSV line is padded with `''`. */\n rows: unknown[][]\n}\n\n/** A file that could not be read, with a sentence the person reads. */\nexport interface TransferSourceProblem {\n code: 'empty' | 'invalidJson' | 'notRows' | 'noHeader'\n message: string\n /** The 1-based line, where one is to blame. */\n line?: number\n}\n\nexport type TransferSourceRead =\n | { ok: true; table: TransferSourceTable }\n | { ok: false; problem: TransferSourceProblem }\n\n/** The format a file name says, or `null` when its extension says nothing. */\nexport function transferFormatFromFileName(fileName: string | null | undefined): TransferFormat | null {\n const extension = /\\.([a-z0-9]+)$/i.exec(String(fileName ?? '').trim())?.[1]?.toLowerCase()\n if (extension === 'csv' || extension === 'tsv' || extension === 'txt') return 'csv'\n if (extension === 'json') return 'json'\n if (extension === 'ndjson' || extension === 'jsonl') return 'ndjson'\n return null\n}\n\n/** The format a file's first characters suggest: `[` is JSON, `{` NDJSON, anything else CSV. */\nexport function sniffTransferFormat(text: string): TransferFormat {\n const start = stripBom(text).trimStart()\n if (start.startsWith('[')) return 'json'\n if (start.startsWith('{')) {\n const firstLine = start.split(/\\r?\\n/, 1)[0] ?? ''\n // `{ \"rows\": [...] }` spread over lines is JSON; one object per line is NDJSON.\n try {\n JSON.parse(firstLine)\n return 'ndjson'\n } catch {\n return 'json'\n }\n }\n return 'csv'\n}\n\n/** The media type an upload of `format` is inspected and stored as. */\nexport function transferContentType(format: TransferFormat): string {\n if (format === 'json') return 'application/json'\n if (format === 'ndjson') return 'application/x-ndjson'\n return 'text/csv'\n}\n\nfunction stripBom(text: string): string {\n return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text\n}\n\n/** How many times `delimiter` splits `line` outside quotes. */\nfunction countOutsideQuotes(line: string, delimiter: string): number {\n let count = 0\n let quoted = false\n for (const char of line) {\n if (char === '\"') quoted = !quoted\n else if (!quoted && char === delimiter) count += 1\n }\n return count\n}\n\n/** The delimiter that splits the header line most; comma on a tie or a one-column file. */\nexport function detectCsvDelimiter(text: string): TransferCsvDelimiter {\n const header = stripBom(text).split(/\\r?\\n/, 1)[0] ?? ''\n let best: TransferCsvDelimiter = ','\n let bestCount = countOutsideQuotes(header, ',')\n for (const delimiter of TRANSFER_CSV_DELIMITERS) {\n const count = countOutsideQuotes(header, delimiter)\n if (count > bestCount) {\n best = delimiter\n bestCount = count\n }\n }\n return best\n}\n\n/**\n * CSV text into rows of cells (header included), wholly blank lines dropped.\n * A cell an export guarded against running as a spreadsheet formula (`'=…`)\n * reads back as it was (`=…`), so an export imported again is unchanged.\n */\nexport function parseTransferCsv(text: string, delimiter: TransferCsvDelimiter = ','): string[][] {\n const source = stripBom(String(text ?? ''))\n const rows: string[][] = []\n let row: string[] = []\n let cell = ''\n let quoted = false\n const endRow = () => {\n row.push(restoreCsvFormulaCell(cell))\n if (row.some((entry) => entry.trim() !== '')) rows.push(row)\n row = []\n cell = ''\n }\n for (let at = 0; at < source.length; at += 1) {\n const char = source[at]\n if (quoted) {\n if (char === '\"') {\n if (source[at + 1] === '\"') {\n cell += '\"'\n at += 1\n } else {\n quoted = false\n }\n } else {\n cell += char\n }\n continue\n }\n if (char === '\"' && cell === '') quoted = true\n else if (char === delimiter) {\n row.push(restoreCsvFormulaCell(cell))\n cell = ''\n } else if (char === '\\n') endRow()\n else if (char === '\\r') {\n if (source[at + 1] !== '\\n') endRow()\n } else cell += char\n }\n if (cell !== '' || row.length) endRow()\n return rows\n}\n\n/** Objects into a header (keys in first-seen order) and rows. */\nfunction tableFromObjects(format: TransferFormat, objects: readonly unknown[]): TransferSourceRead {\n const headers: string[] = []\n const seen = new Set<string>()\n for (const [index, object] of objects.entries()) {\n if (!object || typeof object !== 'object' || Array.isArray(object)) {\n return {\n ok: false,\n problem: { code: 'notRows', message: `Entry ${index + 1} is not an object with named values.` },\n }\n }\n for (const key of Object.keys(object)) {\n if (seen.has(key)) continue\n seen.add(key)\n headers.push(key)\n }\n }\n if (!headers.length) return { ok: false, problem: { code: 'noHeader', message: 'The file names no fields.' } }\n const rows = objects.map((object) =>\n headers.map((key) => {\n const value = (object as Record<string, unknown>)[key]\n return value === undefined || value === null ? '' : value\n }),\n )\n return { ok: true, table: { format, headers, rows } }\n}\n\n/**\n * A file's text read as `format` (see the block header). For a CSV,\n * `options` carries what the person confirmed in the upload step — the\n * delimiter, and whether the first line names the columns — so the server\n * reads the file exactly as the browser previewed it.\n */\nexport function readTransferSource(\n text: string,\n format: TransferFormat,\n options: TransferSourceOptions = {},\n): TransferSourceRead {\n const source = stripBom(String(text ?? ''))\n if (!source.trim()) return { ok: false, problem: { code: 'empty', message: 'The file is empty.' } }\n\n if (format === 'json') {\n let parsed: unknown\n try {\n parsed = JSON.parse(source)\n } catch {\n return { ok: false, problem: { code: 'invalidJson', message: 'The file is not valid JSON.' } }\n }\n const list = Array.isArray(parsed)\n ? parsed\n : parsed && typeof parsed === 'object' && Array.isArray((parsed as Record<string, unknown>)['rows'])\n ? ((parsed as Record<string, unknown>)['rows'] as unknown[])\n : null\n if (!list) {\n return {\n ok: false,\n problem: { code: 'notRows', message: 'The file is not a list of records (an array, or an object with \"rows\").' },\n }\n }\n return tableFromObjects('json', list)\n }\n\n if (format === 'ndjson') {\n const objects: unknown[] = []\n const lines = source.split(/\\r?\\n/)\n for (const [index, line] of lines.entries()) {\n if (!line.trim()) continue\n try {\n objects.push(JSON.parse(line))\n } catch {\n return {\n ok: false,\n problem: { code: 'invalidJson', message: `Line ${index + 1} is not valid JSON.`, line: index + 1 },\n }\n }\n }\n return tableFromObjects('ndjson', objects)\n }\n\n const delimiter = options.delimiter ?? detectCsvDelimiter(source)\n if (options.headerRow === false) {\n const lines = parseTransferCsv(source, delimiter)\n const width = lines.reduce((most, line) => Math.max(most, line.length), 0)\n const headers = Array.from({ length: width }, (_unused, index) => `Column ${index + 1}`)\n const rows = lines.map((cells) =>\n cells.length >= width ? cells : [...cells, ...new Array<string>(width - cells.length).fill('')],\n )\n return { ok: true, table: { format: 'csv', delimiter, headers, rows } }\n }\n const [header, ...body] = parseTransferCsv(source, delimiter)\n if (!header || !header.some((cell) => cell.trim())) {\n return { ok: false, problem: { code: 'noHeader', message: 'The file has no header row.', line: 1 } }\n }\n const headers = header.map((cell, index) => cell.trim() || `Column ${index + 1}`)\n const rows = body.map((cells) =>\n cells.length >= headers.length ? cells : [...cells, ...new Array<string>(headers.length - cells.length).fill('')],\n )\n return { ok: true, table: { format: 'csv', delimiter, headers, rows } }\n}\n\n/** A cell as the text a sample, a result file or a preview shows. */\nexport function transferCellText(value: unknown): string {\n if (value === null || value === undefined) return ''\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n return JSON.stringify(value)\n}\n"],"names":["restoreCsvFormulaCell","TRANSFER_CSV_DELIMITERS","transferFormatFromFileName","fileName","extension","exec","String","trim","toLowerCase","sniffTransferFormat","text","start","stripBom","trimStart","startsWith","firstLine","split","JSON","parse","transferContentType","format","charCodeAt","slice","countOutsideQuotes","line","delimiter","count","quoted","char","detectCsvDelimiter","header","best","bestCount","parseTransferCsv","source","rows","row","cell","endRow","push","some","entry","at","length","tableFromObjects","objects","headers","seen","Set","index","object","entries","Array","isArray","ok","problem","code","message","key","Object","keys","has","add","map","value","undefined","table","readTransferSource","options","parsed","list","lines","headerRow","width","reduce","most","Math","max","from","_unused","cells","fill","body","transferCellText","stringify"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;2CAoB2C,GAE3C,SAASA,qBAAqB,QAAQ,sBAAkB;AAMxD,4CAA4C,GAC5C,OAAO,MAAMC,0BAA2D;IAAC;IAAK;IAAK;CAAK,CAAA;AAgCxF,4EAA4E,GAC5E,OAAO,SAASC,2BAA2BC,QAAmC;QAC1D,QAAA;IAAlB,MAAMC,aAAY,QAAA,kBAAkBC,IAAI,CAACC,OAAOH,mBAAAA,WAAY,IAAII,IAAI,yBAAlD,SAAA,KAAuD,CAAC,EAAE,qBAA1D,OAA4DC,WAAW;IACzF,IAAIJ,cAAc,SAASA,cAAc,SAASA,cAAc,OAAO,OAAO;IAC9E,IAAIA,cAAc,QAAQ,OAAO;IACjC,IAAIA,cAAc,YAAYA,cAAc,SAAS,OAAO;IAC5D,OAAO;AACT;AAEA,8FAA8F,GAC9F,OAAO,SAASK,oBAAoBC,IAAY;IAC9C,MAAMC,QAAQC,SAASF,MAAMG,SAAS;IACtC,IAAIF,MAAMG,UAAU,CAAC,MAAM,OAAO;IAClC,IAAIH,MAAMG,UAAU,CAAC,MAAM;YACPH;QAAlB,MAAMI,aAAYJ,gBAAAA,MAAMK,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,YAA1BL,gBAA8B;QAChD,gFAAgF;QAChF,IAAI;YACFM,KAAKC,KAAK,CAACH;YACX,OAAO;QACT,EAAE,eAAM;YACN,OAAO;QACT;IACF;IACA,OAAO;AACT;AAEA,qEAAqE,GACrE,OAAO,SAASI,oBAAoBC,MAAsB;IACxD,IAAIA,W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