@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
|
@@ -14,32 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
/**
|
|
18
|
-
* READING A SPREADSHEET INTO A CRM COLLECTION — the part that does not care
|
|
19
|
-
* which collection (AGL-2621).
|
|
20
|
-
*
|
|
21
|
-
* The contact import (AGL-2602) settled how a file becomes records: a
|
|
22
|
-
* header row is matched against an alias table to PROPOSE a column → field
|
|
23
|
-
* mapping, the operator corrects it, one line is mapped to a raw row of
|
|
24
|
-
* verbatim strings, and the server judges each row and tallies what it did.
|
|
25
|
-
* A companies file goes through the same three stages with a different
|
|
26
|
-
* field list, so the stages live here, parametric over the field union, and
|
|
27
|
-
* the CRM plugin's contact and company importers each supply their vocabulary
|
|
28
|
-
* — the fields, their aliases, their labels — and nothing else.
|
|
29
|
-
*
|
|
30
|
-
* ## A custom target is `custom:<key>`
|
|
31
|
-
*
|
|
32
|
-
* A column may also map to a custom field the merchant defined, which has
|
|
33
|
-
* no standard name. The target is one string rather than a discriminated
|
|
34
|
-
* object because it is the VALUE of a select control and travels through a
|
|
35
|
-
* form; the prefix is what tells the two apart on the way back.
|
|
36
|
-
*
|
|
37
|
-
* ## The ceilings are shared numbers
|
|
38
|
-
*
|
|
39
|
-
* One file, one request and one preview are bounded the same way for every
|
|
40
|
-
* collection, because the bounds are about the browser's memory and a
|
|
41
|
-
* console request's budget, not about what the rows hold.
|
|
42
|
-
*/
|
|
43
17
|
/**
|
|
44
18
|
* The most rows one uploaded file may carry.
|
|
45
19
|
*
|
|
@@ -114,14 +88,7 @@ export declare function mapImportRow<F extends string>(cells: readonly string[],
|
|
|
114
88
|
* imported `VIP` and a typed `vip` are one tag and not two.
|
|
115
89
|
*/
|
|
116
90
|
export declare function parseImportTags(value: unknown, max: number): string[];
|
|
117
|
-
|
|
118
|
-
* A yes/no cell as a boolean, or `null` when it is neither.
|
|
119
|
-
*
|
|
120
|
-
* The affirmatives are the ones consent and checkbox columns actually
|
|
121
|
-
* carry; the negatives are listed so that an explicit `no` is a `false`
|
|
122
|
-
* rather than an unreadable value that gets reported as dropped.
|
|
123
|
-
*/
|
|
124
|
-
export declare function parseImportFlag(value: unknown): boolean | null;
|
|
91
|
+
export { parseImportFlag } from '../data-transfer/derive';
|
|
125
92
|
/** A cell as trimmed text capped at `max`, or `undefined` when blank. */
|
|
126
93
|
export declare function importTextValue(value: unknown, max: number): string | undefined;
|
|
127
94
|
/** A cell the file carried that could not be read as the field it was mapped to. */
|
|
@@ -130,7 +97,11 @@ export interface ImportDroppedValue {
|
|
|
130
97
|
field: string;
|
|
131
98
|
value: string;
|
|
132
99
|
}
|
|
133
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* A CSV cell through {@link escapeCsvCell}: guarded against running as a
|
|
102
|
+
* spreadsheet formula, quoted only when it has to be. A number value is
|
|
103
|
+
* written as the number it is (`-5`, not `'-5`).
|
|
104
|
+
*/
|
|
134
105
|
export declare function csvCell(value: unknown): string;
|
|
135
106
|
/**
|
|
136
107
|
* A whole CSV — the header, then one line per row — through {@link csvCell}.
|
|
@@ -140,9 +111,10 @@ export declare function csvCell(value: unknown): string;
|
|
|
140
111
|
* table's export.
|
|
141
112
|
* Quoting is decided in {@link csvCell} and nowhere else — a cell holding a
|
|
142
113
|
* comma, a quote or a line break is wrapped in quotes with its quotes
|
|
143
|
-
* doubled,
|
|
144
|
-
*
|
|
145
|
-
* open the same way in a
|
|
114
|
+
* doubled, a text cell a spreadsheet would run as a formula gets a leading
|
|
115
|
+
* `'`, and a `null` or `undefined` cell is empty rather than the word — so
|
|
116
|
+
* that a report's file and a contacts file open the same way in a
|
|
117
|
+
* spreadsheet.
|
|
146
118
|
*/
|
|
147
119
|
export declare function csvDocument(header: readonly unknown[], rows: readonly (readonly unknown[])[]): string;
|
|
148
120
|
/**
|
|
@@ -39,7 +39,8 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
39
39
|
* One file, one request and one preview are bounded the same way for every
|
|
40
40
|
* collection, because the bounds are about the browser's memory and a
|
|
41
41
|
* console request's budget, not about what the rows hold.
|
|
42
|
-
*/
|
|
42
|
+
*/ import { escapeCsvCell } from "./csv.js";
|
|
43
|
+
/**
|
|
43
44
|
* The most rows one uploaded file may carry.
|
|
44
45
|
*
|
|
45
46
|
* A bound on the work one import represents and on the memory the browser
|
|
@@ -152,48 +153,21 @@ export function guessImportMapping(columns, fields, aliasKeys, customFields = []
|
|
|
152
153
|
...new Set(parts.map((tag)=>tag.trim().toLowerCase()).filter(Boolean))
|
|
153
154
|
].slice(0, max);
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
* The affirmatives are the ones consent and checkbox columns actually
|
|
159
|
-
* carry; the negatives are listed so that an explicit `no` is a `false`
|
|
160
|
-
* rather than an unreadable value that gets reported as dropped.
|
|
161
|
-
*/ export function parseImportFlag(value) {
|
|
162
|
-
if (typeof value === 'boolean') return value;
|
|
163
|
-
if (typeof value === 'number') return value === 1 ? true : value === 0 ? false : null;
|
|
164
|
-
const text = String(value != null ? value : '').trim().toLowerCase();
|
|
165
|
-
if ([
|
|
166
|
-
'yes',
|
|
167
|
-
'y',
|
|
168
|
-
'true',
|
|
169
|
-
'1',
|
|
170
|
-
'on',
|
|
171
|
-
'subscribed',
|
|
172
|
-
'opted in',
|
|
173
|
-
'opted-in'
|
|
174
|
-
].includes(text)) {
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
if ([
|
|
178
|
-
'no',
|
|
179
|
-
'n',
|
|
180
|
-
'false',
|
|
181
|
-
'0',
|
|
182
|
-
'off',
|
|
183
|
-
'unsubscribed',
|
|
184
|
-
''
|
|
185
|
-
].includes(text)) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
156
|
+
// The yes/no reader moved to the import/export core with the other cell
|
|
157
|
+
// parsers (AGL-3522); this name stays for every importer that reads it here.
|
|
158
|
+
export { parseImportFlag } from "../data-transfer/derive.js";
|
|
190
159
|
/** A cell as trimmed text capped at `max`, or `undefined` when blank. */ export function importTextValue(value, max) {
|
|
191
160
|
const text = String(value != null ? value : '').trim().slice(0, max);
|
|
192
161
|
return text || undefined;
|
|
193
162
|
}
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
|
|
163
|
+
/**
|
|
164
|
+
* A CSV cell through {@link escapeCsvCell}: guarded against running as a
|
|
165
|
+
* spreadsheet formula, quoted only when it has to be. A number value is
|
|
166
|
+
* written as the number it is (`-5`, not `'-5`).
|
|
167
|
+
*/ export function csvCell(value) {
|
|
168
|
+
return escapeCsvCell(String(value != null ? value : ''), {
|
|
169
|
+
numeric: typeof value === 'number' || typeof value === 'bigint'
|
|
170
|
+
});
|
|
197
171
|
}
|
|
198
172
|
/**
|
|
199
173
|
* A whole CSV — the header, then one line per row — through {@link csvCell}.
|
|
@@ -203,9 +177,10 @@ export function guessImportMapping(columns, fields, aliasKeys, customFields = []
|
|
|
203
177
|
* table's export.
|
|
204
178
|
* Quoting is decided in {@link csvCell} and nowhere else — a cell holding a
|
|
205
179
|
* comma, a quote or a line break is wrapped in quotes with its quotes
|
|
206
|
-
* doubled,
|
|
207
|
-
*
|
|
208
|
-
* open the same way in a
|
|
180
|
+
* doubled, a text cell a spreadsheet would run as a formula gets a leading
|
|
181
|
+
* `'`, and a `null` or `undefined` cell is empty rather than the word — so
|
|
182
|
+
* that a report's file and a contacts file open the same way in a
|
|
183
|
+
* spreadsheet.
|
|
209
184
|
*/ export function csvDocument(header, rows) {
|
|
210
185
|
return [
|
|
211
186
|
header,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/csv-import.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 * READING A SPREADSHEET INTO A CRM COLLECTION — the part that does not care\n * which collection (AGL-2621).\n *\n * The contact import (AGL-2602) settled how a file becomes records: a\n * header row is matched against an alias table to PROPOSE a column → field\n * mapping, the operator corrects it, one line is mapped to a raw row of\n * verbatim strings, and the server judges each row and tallies what it did.\n * A companies file goes through the same three stages with a different\n * field list, so the stages live here, parametric over the field union, and\n * the CRM plugin's contact and company importers each supply their vocabulary\n * — the fields, their aliases, their labels — and nothing else.\n *\n * ## A custom target is `custom:<key>`\n *\n * A column may also map to a custom field the merchant defined, which has\n * no standard name. The target is one string rather than a discriminated\n * object because it is the VALUE of a select control and travels through a\n * form; the prefix is what tells the two apart on the way back.\n *\n * ## The ceilings are shared numbers\n *\n * One file, one request and one preview are bounded the same way for every\n * collection, because the bounds are about the browser's memory and a\n * console request's budget, not about what the rows hold.\n */\n\n/**\n * The most rows one uploaded file may carry.\n *\n * A bound on the work one import represents and on the memory the browser\n * holds while mapping it — five thousand rows of a wide export is already\n * several megabytes of cells in a tab. A larger list is split and imported\n * in pieces; the drawer says so on the file, before a single row is sent.\n */\nexport const CSV_IMPORT_MAX_ROWS = 5_000\n\n/**\n * Rows per request.\n *\n * Each row costs the server a lookup and a write, plus whatever a name it\n * has not seen in this request costs to resolve; two hundred of those sit\n * comfortably inside a console request's budget and give the progress bar\n * twenty-five steps on the largest file the drawer accepts.\n */\nexport const CSV_IMPORT_CHUNK_SIZE = 200\n\n/**\n * The most bytes one request may carry, checked before the body is judged.\n *\n * Two hundred rows of a wide export with long values is well under a\n * megabyte; two megabytes is the line past which a request is not a chunk\n * of a file but something else being pushed through this door.\n */\nexport const CSV_IMPORT_MAX_BODY_BYTES = 2_000_000\n\n/** How many mapped rows the drawer shows before the operator commits. */\nexport const CSV_IMPORT_PREVIEW_ROWS = 10\n\n/** The prefix a custom-field target id carries. */\nconst CUSTOM_TARGET_PREFIX = 'custom:'\n\n/** The custom-field target id for a definition key. */\nexport function customImportTarget(key: string): `custom:${string}` {\n return `${CUSTOM_TARGET_PREFIX}${key}`\n}\n\n/** The definition key a custom target names, or `null` for a standard field. */\nexport function customImportTargetKey(target: string): string | null {\n return target.startsWith(CUSTOM_TARGET_PREFIX)\n ? target.slice(CUSTOM_TARGET_PREFIX.length)\n : null\n}\n\n/**\n * Normalizes a header cell for alias matching.\n *\n * Underscores, dots and hyphens all become one space, so `e-mail`,\n * `email_address` and `Email Address` compare as the words they are. The\n * alias tables are written in the human spelling and pass through the same\n * function, so a table stays readable and the comparison stays exact.\n */\nexport function importHeaderKey(value: unknown): string {\n return String(value ?? '')\n .trim()\n .toLowerCase()\n .replace(/[_.\\-/]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** An alias table, normalized once through {@link importHeaderKey}. */\nexport function importAliasKeys<F extends string>(\n fields: readonly F[],\n aliases: Record<F, readonly string[]>,\n): Record<F, ReadonlySet<string>> {\n const keys = {} as Record<F, ReadonlySet<string>>\n for (const field of fields) {\n keys[field] = new Set(aliases[field].map(importHeaderKey))\n }\n return keys\n}\n\n/**\n * A proposed mapping from a file's header row.\n *\n * Custom fields win over standard aliases when a header matches a\n * definition's label or key exactly — a merchant who defined a field called\n * \"Status\" meant THEIR status, not our lifecycle stage. Each target is\n * taken at most once, by the first column that claims it, so a file with two\n * columns named \"Email\" maps the first and leaves the second for the\n * operator to decide.\n */\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n): Record<number, F>\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n customFields: readonly { key: string; label: string }[],\n): Record<number, F | `custom:${string}`>\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n customFields: readonly { key: string; label: string }[] = [],\n): Record<number, F | `custom:${string}`> {\n const mapping: Record<number, F | `custom:${string}`> = {}\n const taken = new Set<string>()\n const customByHeader = new Map<string, string>()\n for (const field of customFields) {\n customByHeader.set(importHeaderKey(field.label), field.key)\n customByHeader.set(importHeaderKey(field.key), field.key)\n }\n columns.forEach((column, index) => {\n const key = importHeaderKey(column)\n if (!key) return\n const customKey = customByHeader.get(key)\n if (customKey) {\n const target = customImportTarget(customKey)\n if (!taken.has(target)) {\n mapping[index] = target\n taken.add(target)\n }\n return\n }\n for (const field of fields) {\n if (taken.has(field)) continue\n if (aliasKeys[field].has(key)) {\n mapping[index] = field\n taken.add(field)\n return\n }\n }\n })\n return mapping\n}\n\n/**\n * One parsed line under a mapping: the cells the mapping selected, under the\n * field they were mapped to, verbatim, with custom values gathered under\n * `custom` by definition key. Empty cells are left absent.\n */\nexport function mapImportRow<F extends string>(\n cells: readonly string[],\n mapping: Record<number, F | `custom:${string}`>,\n): Partial<Record<F, string>> & { custom?: Record<string, string> } {\n const standard: Partial<Record<F, string>> = {}\n const custom: Record<string, string> = {}\n for (const [indexText, target] of Object.entries(mapping)) {\n const value = String(cells[Number(indexText)] ?? '')\n if (!value.trim()) continue\n const customKey = customImportTargetKey(target)\n if (customKey) {\n custom[customKey] = value\n } else {\n standard[target as F] = value\n }\n }\n return Object.keys(custom).length ? { ...standard, custom } : standard\n}\n\n/**\n * A tag cell as the tags it names.\n *\n * `|` or `,` separated — the CSV export writes `|`, most other products\n * write `,` — lowercased and trimmed like a record's own tag field, so an\n * imported `VIP` and a typed `vip` are one tag and not two.\n */\nexport function parseImportTags(value: unknown, max: number): string[] {\n const parts = Array.isArray(value)\n ? value.map((entry) => String(entry ?? ''))\n : String(value ?? '').split(/[|,]/)\n return [\n ...new Set(parts.map((tag) => tag.trim().toLowerCase()).filter(Boolean)),\n ].slice(0, max)\n}\n\n/**\n * A yes/no cell as a boolean, or `null` when it is neither.\n *\n * The affirmatives are the ones consent and checkbox columns actually\n * carry; the negatives are listed so that an explicit `no` is a `false`\n * rather than an unreadable value that gets reported as dropped.\n */\nexport function parseImportFlag(value: unknown): boolean | null {\n if (typeof value === 'boolean') return value\n if (typeof value === 'number') return value === 1 ? true : value === 0 ? false : null\n const text = String(value ?? '')\n .trim()\n .toLowerCase()\n if (['yes', 'y', 'true', '1', 'on', 'subscribed', 'opted in', 'opted-in'].includes(text)) {\n return true\n }\n if (['no', 'n', 'false', '0', 'off', 'unsubscribed', ''].includes(text)) {\n return false\n }\n return null\n}\n\n/** A cell as trimmed text capped at `max`, or `undefined` when blank. */\nexport function importTextValue(value: unknown, max: number): string | undefined {\n const text = String(value ?? '')\n .trim()\n .slice(0, max)\n return text || undefined\n}\n\n/** A cell the file carried that could not be read as the field it was mapped to. */\nexport interface ImportDroppedValue {\n /** The standard field name, or `custom:<key>`. */\n field: string\n value: string\n}\n\n/** A CSV cell, quoted only when it has to be. */\nexport function csvCell(value: unknown): string {\n const text = String(value ?? '')\n return /[\",\\r\\n]/.test(text) ? `\"${text.replace(/\"/g, '\"\"')}\"` : text\n}\n\n/**\n * A whole CSV — the header, then one line per row — through {@link csvCell}.\n *\n * The one serializer for every CSV the console writes: each CRM section's\n * export, the skipped-rows file an import hands back and each report\n * table's export.\n * Quoting is decided in {@link csvCell} and nowhere else — a cell holding a\n * comma, a quote or a line break is wrapped in quotes with its quotes\n * doubled, no other cell is touched, and a `null` or `undefined` cell is\n * empty rather than the word — so that a report's file and a contacts file\n * open the same way in a spreadsheet.\n */\nexport function csvDocument(\n header: readonly unknown[],\n rows: readonly (readonly unknown[])[],\n): string {\n return [header, ...rows]\n .map((line) => line.map(csvCell).join(','))\n .join('\\n')\n}\n\n/**\n * The skipped rows as a file the operator can fix and re-import.\n *\n * The original columns verbatim plus a trailing `Skipped because` column,\n * so the file round-trips: correct the cell, delete the last column or\n * leave it unmapped, and import it again.\n */\nexport function importSkippedCsv<R extends string>(\n columns: readonly string[],\n entries: readonly { cells: readonly string[]; reason: R }[],\n labels: Record<R, string>,\n): string {\n return csvDocument(\n [...columns, 'Skipped because'],\n entries.map((entry) => [\n ...columns.map((_column, index) => entry.cells[index] ?? ''),\n labels[entry.reason] ?? entry.reason,\n ]),\n )\n}\n\n/**\n * One row the server did not store, by its index in the request. Each\n * collection names the row back to the operator in its own field — an\n * address, a company name — beside these two.\n */\nexport interface ImportSkippedRow<R extends string> {\n index: number\n reason: R\n}\n\n/**\n * What one request did, in the shape every collection's import reports.\n * The drawer sums these across a file; a collection with more to say\n * extends the shape and folds its own field beside {@link mergeImportResults}.\n */\nexport interface ImportChunkResult<S extends ImportSkippedRow<string>> {\n received: number\n created: number\n merged: number\n skipped: S[]\n /** Unreadable cells, tallied by field. */\n dropped: Record<string, number>\n /** Owner addresses that matched no member of the organization. */\n ownersUnresolved: string[]\n /**\n * Of the rows stored, how many carry an address whose domain has no mail\n * server (AGL-3328) — records that now read \"Would bounce\". Absent for a\n * collection whose rows carry no address, and for a request whose check\n * did not answer in time.\n */\n noMailServer?: number\n}\n\n/** An empty tally, for the drawer to fold chunk results into. */\nexport function emptyImportResult<\n S extends ImportSkippedRow<string>,\n>(): ImportChunkResult<S> {\n return {\n received: 0,\n created: 0,\n merged: 0,\n skipped: [],\n dropped: {},\n ownersUnresolved: [],\n }\n}\n\n/**\n * Two results as one.\n *\n * `offset` is where the chunk started in the file, so a skipped row's index\n * comes back as its position in the FILE rather than in the request — which\n * is what the download of skipped rows has to look up.\n */\nexport function mergeImportResults<S extends ImportSkippedRow<string>>(\n total: ImportChunkResult<S>,\n chunk: Partial<ImportChunkResult<S>>,\n offset = 0,\n): ImportChunkResult<S> {\n const dropped = { ...total.dropped }\n for (const [field, count] of Object.entries(chunk.dropped ?? {})) {\n dropped[field] = (dropped[field] ?? 0) + Number(count ?? 0)\n }\n return {\n received: total.received + Number(chunk.received ?? 0),\n created: total.created + Number(chunk.created ?? 0),\n merged: total.merged + Number(chunk.merged ?? 0),\n skipped: [\n ...total.skipped,\n ...(chunk.skipped ?? []).map((entry) => ({\n ...entry,\n index: Number(entry.index) + offset,\n })),\n ],\n dropped,\n ownersUnresolved: [\n ...new Set([...total.ownersUnresolved, ...(chunk.ownersUnresolved ?? [])]),\n ],\n ...(total.noMailServer !== undefined || chunk.noMailServer !== undefined\n ? { noMailServer: Number(total.noMailServer ?? 0) + Number(chunk.noMailServer ?? 0) }\n : {}),\n }\n}\n\n/**\n * What an import's result says about the addresses that would bounce\n * (AGL-3328), or `null` when none does.\n */\nexport function importNoMailServerSentence(count: number | null | undefined): string | null {\n const n = Math.max(0, Math.floor(Number(count) || 0))\n if (!n) return null\n return n === 1\n ? '1 address has no mail server. Its record reads \"Would bounce\", and campaigns and sequences skip it.'\n : `${n.toLocaleString('en-US')} addresses have no mail server. Their records read \"Would bounce\", ` +\n 'and campaigns and sequences skip them.'\n}\n"],"names":["CSV_IMPORT_MAX_ROWS","CSV_IMPORT_CHUNK_SIZE","CSV_IMPORT_MAX_BODY_BYTES","CSV_IMPORT_PREVIEW_ROWS","CUSTOM_TARGET_PREFIX","customImportTarget","key","customImportTargetKey","target","startsWith","slice","length","importHeaderKey","value","String","trim","toLowerCase","replace","importAliasKeys","fields","aliases","keys","field","Set","map","guessImportMapping","columns","aliasKeys","customFields","mapping","taken","customByHeader","Map","set","label","forEach","column","index","customKey","get","has","add","mapImportRow","cells","standard","custom","indexText","Object","entries","Number","parseImportTags","max","parts","Array","isArray","entry","split","tag","filter","Boolean","parseImportFlag","text","includes","importTextValue","undefined","csvCell","test","csvDocument","header","rows","line","join","importSkippedCsv","labels","_column","reason","emptyImportResult","received","created","merged","skipped","dropped","ownersUnresolved","mergeImportResults","total","chunk","offset","count","noMailServer","importNoMailServerSentence","n","Math","floor","toLocaleString"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;CAyBC,GAED;;;;;;;CAOC,GACD,OAAO,MAAMA,sBAAsB,KAAK;AAExC;;;;;;;CAOC,GACD,OAAO,MAAMC,wBAAwB,IAAG;AAExC;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4B,QAAS;AAElD,uEAAuE,GACvE,OAAO,MAAMC,0BAA0B,GAAE;AAEzC,iDAAiD,GACjD,MAAMC,uBAAuB;AAE7B,qDAAqD,GACrD,OAAO,SAASC,mBAAmBC,GAAW;IAC5C,OAAO,GAAGF,uBAAuBE,KAAK;AACxC;AAEA,8EAA8E,GAC9E,OAAO,SAASC,sBAAsBC,MAAc;IAClD,OAAOA,OAAOC,UAAU,CAACL,wBACrBI,OAAOE,KAAK,CAACN,qBAAqBO,MAAM,IACxC;AACN;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,OAAOC,OAAOD,gBAAAA,QAAS,IACpBE,IAAI,GACJC,WAAW,GACXC,OAAO,CAAC,aAAa,KACrBA,OAAO,CAAC,QAAQ,KAChBF,IAAI;AACT;AAEA,qEAAqE,GACrE,OAAO,SAASG,gBACdC,MAAoB,EACpBC,OAAqC;IAErC,MAAMC,OAAO,CAAC;IACd,KAAK,MAAMC,SAASH,OAAQ;QAC1BE,IAAI,CAACC,MAAM,GAAG,IAAIC,IAAIH,OAAO,CAACE,MAAM,CAACE,GAAG,CAACZ;IA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,GAC/F;AACR"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/csv-import.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 * READING A SPREADSHEET INTO A CRM COLLECTION — the part that does not care\n * which collection (AGL-2621).\n *\n * The contact import (AGL-2602) settled how a file becomes records: a\n * header row is matched against an alias table to PROPOSE a column → field\n * mapping, the operator corrects it, one line is mapped to a raw row of\n * verbatim strings, and the server judges each row and tallies what it did.\n * A companies file goes through the same three stages with a different\n * field list, so the stages live here, parametric over the field union, and\n * the CRM plugin's contact and company importers each supply their vocabulary\n * — the fields, their aliases, their labels — and nothing else.\n *\n * ## A custom target is `custom:<key>`\n *\n * A column may also map to a custom field the merchant defined, which has\n * no standard name. The target is one string rather than a discriminated\n * object because it is the VALUE of a select control and travels through a\n * form; the prefix is what tells the two apart on the way back.\n *\n * ## The ceilings are shared numbers\n *\n * One file, one request and one preview are bounded the same way for every\n * collection, because the bounds are about the browser's memory and a\n * console request's budget, not about what the rows hold.\n */\n\nimport { escapeCsvCell } from './csv'\n\n/**\n * The most rows one uploaded file may carry.\n *\n * A bound on the work one import represents and on the memory the browser\n * holds while mapping it — five thousand rows of a wide export is already\n * several megabytes of cells in a tab. A larger list is split and imported\n * in pieces; the drawer says so on the file, before a single row is sent.\n */\nexport const CSV_IMPORT_MAX_ROWS = 5_000\n\n/**\n * Rows per request.\n *\n * Each row costs the server a lookup and a write, plus whatever a name it\n * has not seen in this request costs to resolve; two hundred of those sit\n * comfortably inside a console request's budget and give the progress bar\n * twenty-five steps on the largest file the drawer accepts.\n */\nexport const CSV_IMPORT_CHUNK_SIZE = 200\n\n/**\n * The most bytes one request may carry, checked before the body is judged.\n *\n * Two hundred rows of a wide export with long values is well under a\n * megabyte; two megabytes is the line past which a request is not a chunk\n * of a file but something else being pushed through this door.\n */\nexport const CSV_IMPORT_MAX_BODY_BYTES = 2_000_000\n\n/** How many mapped rows the drawer shows before the operator commits. */\nexport const CSV_IMPORT_PREVIEW_ROWS = 10\n\n/** The prefix a custom-field target id carries. */\nconst CUSTOM_TARGET_PREFIX = 'custom:'\n\n/** The custom-field target id for a definition key. */\nexport function customImportTarget(key: string): `custom:${string}` {\n return `${CUSTOM_TARGET_PREFIX}${key}`\n}\n\n/** The definition key a custom target names, or `null` for a standard field. */\nexport function customImportTargetKey(target: string): string | null {\n return target.startsWith(CUSTOM_TARGET_PREFIX)\n ? target.slice(CUSTOM_TARGET_PREFIX.length)\n : null\n}\n\n/**\n * Normalizes a header cell for alias matching.\n *\n * Underscores, dots and hyphens all become one space, so `e-mail`,\n * `email_address` and `Email Address` compare as the words they are. The\n * alias tables are written in the human spelling and pass through the same\n * function, so a table stays readable and the comparison stays exact.\n */\nexport function importHeaderKey(value: unknown): string {\n return String(value ?? '')\n .trim()\n .toLowerCase()\n .replace(/[_.\\-/]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** An alias table, normalized once through {@link importHeaderKey}. */\nexport function importAliasKeys<F extends string>(\n fields: readonly F[],\n aliases: Record<F, readonly string[]>,\n): Record<F, ReadonlySet<string>> {\n const keys = {} as Record<F, ReadonlySet<string>>\n for (const field of fields) {\n keys[field] = new Set(aliases[field].map(importHeaderKey))\n }\n return keys\n}\n\n/**\n * A proposed mapping from a file's header row.\n *\n * Custom fields win over standard aliases when a header matches a\n * definition's label or key exactly — a merchant who defined a field called\n * \"Status\" meant THEIR status, not our lifecycle stage. Each target is\n * taken at most once, by the first column that claims it, so a file with two\n * columns named \"Email\" maps the first and leaves the second for the\n * operator to decide.\n */\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n): Record<number, F>\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n customFields: readonly { key: string; label: string }[],\n): Record<number, F | `custom:${string}`>\nexport function guessImportMapping<F extends string>(\n columns: readonly string[],\n fields: readonly F[],\n aliasKeys: Record<F, ReadonlySet<string>>,\n customFields: readonly { key: string; label: string }[] = [],\n): Record<number, F | `custom:${string}`> {\n const mapping: Record<number, F | `custom:${string}`> = {}\n const taken = new Set<string>()\n const customByHeader = new Map<string, string>()\n for (const field of customFields) {\n customByHeader.set(importHeaderKey(field.label), field.key)\n customByHeader.set(importHeaderKey(field.key), field.key)\n }\n columns.forEach((column, index) => {\n const key = importHeaderKey(column)\n if (!key) return\n const customKey = customByHeader.get(key)\n if (customKey) {\n const target = customImportTarget(customKey)\n if (!taken.has(target)) {\n mapping[index] = target\n taken.add(target)\n }\n return\n }\n for (const field of fields) {\n if (taken.has(field)) continue\n if (aliasKeys[field].has(key)) {\n mapping[index] = field\n taken.add(field)\n return\n }\n }\n })\n return mapping\n}\n\n/**\n * One parsed line under a mapping: the cells the mapping selected, under the\n * field they were mapped to, verbatim, with custom values gathered under\n * `custom` by definition key. Empty cells are left absent.\n */\nexport function mapImportRow<F extends string>(\n cells: readonly string[],\n mapping: Record<number, F | `custom:${string}`>,\n): Partial<Record<F, string>> & { custom?: Record<string, string> } {\n const standard: Partial<Record<F, string>> = {}\n const custom: Record<string, string> = {}\n for (const [indexText, target] of Object.entries(mapping)) {\n const value = String(cells[Number(indexText)] ?? '')\n if (!value.trim()) continue\n const customKey = customImportTargetKey(target)\n if (customKey) {\n custom[customKey] = value\n } else {\n standard[target as F] = value\n }\n }\n return Object.keys(custom).length ? { ...standard, custom } : standard\n}\n\n/**\n * A tag cell as the tags it names.\n *\n * `|` or `,` separated — the CSV export writes `|`, most other products\n * write `,` — lowercased and trimmed like a record's own tag field, so an\n * imported `VIP` and a typed `vip` are one tag and not two.\n */\nexport function parseImportTags(value: unknown, max: number): string[] {\n const parts = Array.isArray(value)\n ? value.map((entry) => String(entry ?? ''))\n : String(value ?? '').split(/[|,]/)\n return [\n ...new Set(parts.map((tag) => tag.trim().toLowerCase()).filter(Boolean)),\n ].slice(0, max)\n}\n\n// The yes/no reader moved to the import/export core with the other cell\n// parsers (AGL-3522); this name stays for every importer that reads it here.\nexport { parseImportFlag } from '../data-transfer/derive'\n\n/** A cell as trimmed text capped at `max`, or `undefined` when blank. */\nexport function importTextValue(value: unknown, max: number): string | undefined {\n const text = String(value ?? '')\n .trim()\n .slice(0, max)\n return text || undefined\n}\n\n/** A cell the file carried that could not be read as the field it was mapped to. */\nexport interface ImportDroppedValue {\n /** The standard field name, or `custom:<key>`. */\n field: string\n value: string\n}\n\n/**\n * A CSV cell through {@link escapeCsvCell}: guarded against running as a\n * spreadsheet formula, quoted only when it has to be. A number value is\n * written as the number it is (`-5`, not `'-5`).\n */\nexport function csvCell(value: unknown): string {\n return escapeCsvCell(String(value ?? ''), { numeric: typeof value === 'number' || typeof value === 'bigint' })\n}\n\n/**\n * A whole CSV — the header, then one line per row — through {@link csvCell}.\n *\n * The one serializer for every CSV the console writes: each CRM section's\n * export, the skipped-rows file an import hands back and each report\n * table's export.\n * Quoting is decided in {@link csvCell} and nowhere else — a cell holding a\n * comma, a quote or a line break is wrapped in quotes with its quotes\n * doubled, a text cell a spreadsheet would run as a formula gets a leading\n * `'`, and a `null` or `undefined` cell is empty rather than the word — so\n * that a report's file and a contacts file open the same way in a\n * spreadsheet.\n */\nexport function csvDocument(\n header: readonly unknown[],\n rows: readonly (readonly unknown[])[],\n): string {\n return [header, ...rows]\n .map((line) => line.map(csvCell).join(','))\n .join('\\n')\n}\n\n/**\n * The skipped rows as a file the operator can fix and re-import.\n *\n * The original columns verbatim plus a trailing `Skipped because` column,\n * so the file round-trips: correct the cell, delete the last column or\n * leave it unmapped, and import it again.\n */\nexport function importSkippedCsv<R extends string>(\n columns: readonly string[],\n entries: readonly { cells: readonly string[]; reason: R }[],\n labels: Record<R, string>,\n): string {\n return csvDocument(\n [...columns, 'Skipped because'],\n entries.map((entry) => [\n ...columns.map((_column, index) => entry.cells[index] ?? ''),\n labels[entry.reason] ?? entry.reason,\n ]),\n )\n}\n\n/**\n * One row the server did not store, by its index in the request. Each\n * collection names the row back to the operator in its own field — an\n * address, a company name — beside these two.\n */\nexport interface ImportSkippedRow<R extends string> {\n index: number\n reason: R\n}\n\n/**\n * What one request did, in the shape every collection's import reports.\n * The drawer sums these across a file; a collection with more to say\n * extends the shape and folds its own field beside {@link mergeImportResults}.\n */\nexport interface ImportChunkResult<S extends ImportSkippedRow<string>> {\n received: number\n created: number\n merged: number\n skipped: S[]\n /** Unreadable cells, tallied by field. */\n dropped: Record<string, number>\n /** Owner addresses that matched no member of the organization. */\n ownersUnresolved: string[]\n /**\n * Of the rows stored, how many carry an address whose domain has no mail\n * server (AGL-3328) — records that now read \"Would bounce\". Absent for a\n * collection whose rows carry no address, and for a request whose check\n * did not answer in time.\n */\n noMailServer?: number\n}\n\n/** An empty tally, for the drawer to fold chunk results into. */\nexport function emptyImportResult<\n S extends ImportSkippedRow<string>,\n>(): ImportChunkResult<S> {\n return {\n received: 0,\n created: 0,\n merged: 0,\n skipped: [],\n dropped: {},\n ownersUnresolved: [],\n }\n}\n\n/**\n * Two results as one.\n *\n * `offset` is where the chunk started in the file, so a skipped row's index\n * comes back as its position in the FILE rather than in the request — which\n * is what the download of skipped rows has to look up.\n */\nexport function mergeImportResults<S extends ImportSkippedRow<string>>(\n total: ImportChunkResult<S>,\n chunk: Partial<ImportChunkResult<S>>,\n offset = 0,\n): ImportChunkResult<S> {\n const dropped = { ...total.dropped }\n for (const [field, count] of Object.entries(chunk.dropped ?? {})) {\n dropped[field] = (dropped[field] ?? 0) + Number(count ?? 0)\n }\n return {\n received: total.received + Number(chunk.received ?? 0),\n created: total.created + Number(chunk.created ?? 0),\n merged: total.merged + Number(chunk.merged ?? 0),\n skipped: [\n ...total.skipped,\n ...(chunk.skipped ?? []).map((entry) => ({\n ...entry,\n index: Number(entry.index) + offset,\n })),\n ],\n dropped,\n ownersUnresolved: [\n ...new Set([...total.ownersUnresolved, ...(chunk.ownersUnresolved ?? [])]),\n ],\n ...(total.noMailServer !== undefined || chunk.noMailServer !== undefined\n ? { noMailServer: Number(total.noMailServer ?? 0) + Number(chunk.noMailServer ?? 0) }\n : {}),\n }\n}\n\n/**\n * What an import's result says about the addresses that would bounce\n * (AGL-3328), or `null` when none does.\n */\nexport function importNoMailServerSentence(count: number | null | undefined): string | null {\n const n = Math.max(0, Math.floor(Number(count) || 0))\n if (!n) return null\n return n === 1\n ? '1 address has no mail server. Its record reads \"Would bounce\", and campaigns and sequences skip it.'\n : `${n.toLocaleString('en-US')} addresses have no mail server. Their records read \"Would bounce\", ` +\n 'and campaigns and sequences skip them.'\n}\n"],"names":["escapeCsvCell","CSV_IMPORT_MAX_ROWS","CSV_IMPORT_CHUNK_SIZE","CSV_IMPORT_MAX_BODY_BYTES","CSV_IMPORT_PREVIEW_ROWS","CUSTOM_TARGET_PREFIX","customImportTarget","key","customImportTargetKey","target","startsWith","slice","length","importHeaderKey","value","String","trim","toLowerCase","replace","importAliasKeys","fields","aliases","keys","field","Set","map","guessImportMapping","columns","aliasKeys","customFields","mapping","taken","customByHeader","Map","set","label","forEach","column","index","customKey","get","has","add","mapImportRow","cells","standard","custom","indexText","Object","entries","Number","parseImportTags","max","parts","Array","isArray","entry","split","tag","filter","Boolean","parseImportFlag","importTextValue","text","undefined","csvCell","numeric","csvDocument","header","rows","line","join","importSkippedCsv","labels","_column","reason","emptyImportResult","received","created","merged","skipped","dropped","ownersUnresolved","mergeImportResults","total","chunk","offset","count","noMailServer","importNoMailServerSentence","n","Math","floor","toLocaleString"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;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E;SAC1E;OACGD,MAAMI,YAAY,KAAKxB,aAAaqB,MAAMG,YAAY,KAAKxB,YAC3D;QAAEwB,cAActC,QAAOkC,sBAAAA,MAAMI,YAAY,YAAlBJ,sBAAsB,KAAKlC,QAAOmC,sBAAAA,MAAMG,YAAY,YAAlBH,sBAAsB;IAAG,IAClF,CAAC;AAET;AAEA;;;CAGC,GACD,OAAO,SAASI,2BAA2BF,KAAgC;IACzE,MAAMG,IAAIC,KAAKvC,GAAG,CAAC,GAAGuC,KAAKC,KAAK,CAAC1C,OAAOqC,UAAU;IAClD,IAAI,CAACG,GAAG,OAAO;IACf,OAAOA,MAAM,IACT,wGACA,GAAGA,EAAEG,cAAc,CAAC,SAAS,mEAAmE,CAAC,GAC/F;AACR"}
|
|
@@ -14,19 +14,39 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
export interface CsvCellOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The cell holds a number (a number value, or a number, currency or
|
|
20
|
+
* percent field). A cell that reads as a plain number is then written as
|
|
21
|
+
* is — `-5` stays a negative number in the spreadsheet — and anything else
|
|
22
|
+
* is still guarded.
|
|
23
|
+
*/
|
|
24
|
+
numeric?: boolean;
|
|
25
|
+
}
|
|
17
26
|
/**
|
|
18
|
-
*
|
|
27
|
+
* A cell that cannot run as a spreadsheet formula (AGL-3548).
|
|
19
28
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* itself and escapes it here.
|
|
29
|
+
* Every CSV the platform writes may hold text a stranger typed — a form
|
|
30
|
+
* answer, a lead's company name — and a spreadsheet that opens the file runs
|
|
31
|
+
* `=HYPERLINK(...)` or `@SUM(...)` as a formula. A leading `'` makes the
|
|
32
|
+
* spreadsheet show the cell as text instead. Only the CSV gets this; a JSON
|
|
33
|
+
* or NDJSON file is read by programs, so it keeps the value as it is.
|
|
34
|
+
* {@link restoreCsvFormulaCell} takes the `'` back off on import.
|
|
27
35
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
export declare function neutralizeCsvFormula(cell: string, options?: CsvCellOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* A CSV cell as it was before {@link neutralizeCsvFormula}: one leading `'`
|
|
39
|
+
* dropped when it guards a formula character (or another guard), so a file
|
|
40
|
+
* exported and imported again holds the same text. A `'` before anything
|
|
41
|
+
* else is part of the value and stays.
|
|
42
|
+
*/
|
|
43
|
+
export declare function restoreCsvFormulaCell(cell: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* One cell: guarded against running as a formula (see
|
|
46
|
+
* {@link neutralizeCsvFormula}), then quoted when it has to be — a comma, a
|
|
47
|
+
* quote or a line break. Every CSV writer goes through this.
|
|
48
|
+
*/
|
|
49
|
+
export declare const escapeCsvCell: (cell: string, options?: CsvCellOptions) => string;
|
|
30
50
|
/**
|
|
31
51
|
* Data rows in a CSV document — the header excluded, quoted newlines not
|
|
32
52
|
* counted as row breaks (AGL-2335).
|
|
@@ -67,7 +87,8 @@ export declare function exportShortfall(promisedHeader: string | null | undefine
|
|
|
67
87
|
*
|
|
68
88
|
* The inverse of the escaper above, and the one parser in the repo — see the
|
|
69
89
|
* module note for why the email list importer reaches this rather than
|
|
70
|
-
* writing its own.
|
|
90
|
+
* writing its own. A cell the escaper guarded against running as a formula
|
|
91
|
+
* comes back without its guard ({@link restoreCsvFormulaCell}).
|
|
71
92
|
*
|
|
72
93
|
* A wholly blank row is dropped. Every spreadsheet writes a trailing newline
|
|
73
94
|
* and a row of empty cells is not a record; carrying it through would give
|
package/src/lib/app-utils/csv.js
CHANGED
|
@@ -23,7 +23,44 @@
|
|
|
23
23
|
* against the row count its server promised. Nothing here knows what the rows
|
|
24
24
|
* are; a plugin that writes its own records into a file formats each value
|
|
25
25
|
* itself and escapes it here.
|
|
26
|
-
*/ /**
|
|
26
|
+
*/ /**
|
|
27
|
+
* A cell a spreadsheet would run as a formula: one that opens with `=`, `+`,
|
|
28
|
+
* `-` or `@`, or with a tab or carriage return (which some spreadsheets strip
|
|
29
|
+
* before reading the rest as a formula). Leading `'`s are looked through, so
|
|
30
|
+
* a cell that already starts with the guard is guarded again and the reader
|
|
31
|
+
* below can always take exactly one back off.
|
|
32
|
+
*/ const CSV_FORMULA_LEAD = /^'*[=+\-@\t\r]/;
|
|
33
|
+
/** A plain number as text: `-5`, `+1.5`, `.25`, `1e-3`. */ const CSV_NUMBER = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;
|
|
34
|
+
/**
|
|
35
|
+
* A cell that cannot run as a spreadsheet formula (AGL-3548).
|
|
36
|
+
*
|
|
37
|
+
* Every CSV the platform writes may hold text a stranger typed — a form
|
|
38
|
+
* answer, a lead's company name — and a spreadsheet that opens the file runs
|
|
39
|
+
* `=HYPERLINK(...)` or `@SUM(...)` as a formula. A leading `'` makes the
|
|
40
|
+
* spreadsheet show the cell as text instead. Only the CSV gets this; a JSON
|
|
41
|
+
* or NDJSON file is read by programs, so it keeps the value as it is.
|
|
42
|
+
* {@link restoreCsvFormulaCell} takes the `'` back off on import.
|
|
43
|
+
*/ export function neutralizeCsvFormula(cell, options) {
|
|
44
|
+
if (!CSV_FORMULA_LEAD.test(cell)) return cell;
|
|
45
|
+
if ((options == null ? void 0 : options.numeric) && CSV_NUMBER.test(cell)) return cell;
|
|
46
|
+
return `'${cell}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A CSV cell as it was before {@link neutralizeCsvFormula}: one leading `'`
|
|
50
|
+
* dropped when it guards a formula character (or another guard), so a file
|
|
51
|
+
* exported and imported again holds the same text. A `'` before anything
|
|
52
|
+
* else is part of the value and stays.
|
|
53
|
+
*/ export function restoreCsvFormulaCell(cell) {
|
|
54
|
+
return /^'+[=+\-@\t\r]/.test(cell) ? cell.slice(1) : cell;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* One cell: guarded against running as a formula (see
|
|
58
|
+
* {@link neutralizeCsvFormula}), then quoted when it has to be — a comma, a
|
|
59
|
+
* quote or a line break. Every CSV writer goes through this.
|
|
60
|
+
*/ export const escapeCsvCell = (cell, options)=>{
|
|
61
|
+
const safe = neutralizeCsvFormula(cell, options);
|
|
62
|
+
return /[",\r\n]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe;
|
|
63
|
+
};
|
|
27
64
|
/**
|
|
28
65
|
* Data rows in a CSV document — the header excluded, quoted newlines not
|
|
29
66
|
* counted as row breaks (AGL-2335).
|
|
@@ -113,7 +150,8 @@
|
|
|
113
150
|
*
|
|
114
151
|
* The inverse of the escaper above, and the one parser in the repo — see the
|
|
115
152
|
* module note for why the email list importer reaches this rather than
|
|
116
|
-
* writing its own.
|
|
153
|
+
* writing its own. A cell the escaper guarded against running as a formula
|
|
154
|
+
* comes back without its guard ({@link restoreCsvFormulaCell}).
|
|
117
155
|
*
|
|
118
156
|
* A wholly blank row is dropped. Every spreadsheet writes a trailing newline
|
|
119
157
|
* and a row of empty cells is not a record; carrying it through would give
|
|
@@ -142,11 +180,11 @@
|
|
|
142
180
|
if (char === '"') {
|
|
143
181
|
quoted = true;
|
|
144
182
|
} else if (char === ',') {
|
|
145
|
-
row.push(cell);
|
|
183
|
+
row.push(restoreCsvFormulaCell(cell));
|
|
146
184
|
cell = '';
|
|
147
185
|
} else if (char === '\n' || char === '\r') {
|
|
148
186
|
if (char === '\r' && source[index + 1] === '\n') index += 1;
|
|
149
|
-
row.push(cell);
|
|
187
|
+
row.push(restoreCsvFormulaCell(cell));
|
|
150
188
|
cell = '';
|
|
151
189
|
rows.push(row);
|
|
152
190
|
row = [];
|
|
@@ -155,7 +193,7 @@
|
|
|
155
193
|
}
|
|
156
194
|
}
|
|
157
195
|
if (cell !== '' || row.length) {
|
|
158
|
-
row.push(cell);
|
|
196
|
+
row.push(restoreCsvFormulaCell(cell));
|
|
159
197
|
rows.push(row);
|
|
160
198
|
}
|
|
161
199
|
return rows.filter((cells)=>cells.some((value)=>value.trim() !== ''));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/csv.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 * CSV, read and written the one way the platform does it (AGL-2335).\n *\n * There were five divergent hand-rolled CSV escapers in this repo; this is\n * the one escaper and the one parser every plugin and app reaches — the data\n * plugin's dataset export and import, the email list import, the commerce\n * catalog import, the CRM's contact import — and the check a download runs\n * against the row count its server promised. Nothing here knows what the rows\n * are; a plugin that writes its own records into a file formats each value\n * itself and escapes it here.\n */\n\n/** One cell, quoted when it has to be: a comma, a quote or a line break. */\nexport const escapeCsvCell = (cell: string): string =>\n /[\",\\r\\n]/.test(cell) ? `\"${cell.replace(/\"/g, '\"\"')}\"` : cell\n\n/**\n * Data rows in a CSV document — the header excluded, quoted newlines not\n * counted as row breaks (AGL-2335).\n *\n * This exists so a download can be CHECKED against the row count the server\n * promised, rather than trusted. A truncated export is the defect this whole\n * area is about, and a stream that dies halfway produces a perfectly\n * well-formed shorter file: nothing about the bytes says they are short.\n *\n * Single pass, no array building — {@link parseCsv} answers the same\n * question but materializes every cell, which is the wrong trade when the\n * file may be hundreds of thousands of rows and the only thing wanted is\n * how many there are.\n */\nexport function countCsvDataRows(text: string): number {\n const source = String(text ?? '')\n if (!source) return 0\n let rows = 0\n let quoted = false\n let cellsSeen = false\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]\n if (quoted) {\n if (char === '\"') {\n if (source[index + 1] === '\"') index += 1\n else quoted = false\n }\n cellsSeen = true\n continue\n }\n if (char === '\"') {\n quoted = true\n cellsSeen = true\n continue\n }\n if (char === '\\n') {\n rows += 1\n cellsSeen = false\n continue\n }\n if (char !== '\\r') cellsSeen = true\n }\n // A file that does not end in a newline still has a final row.\n if (cellsSeen) rows += 1\n // The header is not data.\n return Math.max(0, rows - 1)\n}\n\n/**\n * Did a downloaded export arrive whole? (AGL-2335)\n *\n * The server streams and reports its `count()` aggregate in a header, so the\n * client can CHECK rather than trust. This is the check, kept here as a pure\n * function because a guard living inline in a component is a guard nobody\n * can force red — and this one exists precisely to catch a silent shortfall.\n *\n * `short` is only true when the count is both KNOWN and lower. A missing or\n * unparseable header is not evidence of truncation, and refusing a download\n * on the strength of a header that never arrived would fail the user for the\n * server's bookkeeping. More rows than promised is not short either — the\n * count is a snapshot taken before the first page, so a concurrent insert\n * can legitimately overtake it.\n */\nexport function exportShortfall(\n promisedHeader: string | null | undefined,\n body: string,\n format: 'csv' | 'json',\n): { promised: number; received: number; short: boolean } {\n const promised = Number(promisedHeader)\n let received: number\n if (format === 'csv') {\n received = countCsvDataRows(body)\n } else {\n try {\n const parsed = JSON.parse(body) as unknown\n received = Array.isArray(parsed) ? parsed.length : 0\n } catch {\n // A body that is not JSON at all did not arrive whole.\n return { promised, received: 0, short: true }\n }\n }\n return {\n promised,\n received,\n short: Number.isFinite(promised) && promisedHeader != null && received < promised,\n }\n}\n\n/**\n * Minimal RFC-4180 CSV parser (quoted fields, escaped quotes, CRLF).\n *\n * The inverse of the escaper above, and the one parser in the repo — see the\n * module note for why the email list importer reaches this rather than\n * writing its own.\n *\n * A wholly blank row is dropped. Every spreadsheet writes a trailing newline\n * and a row of empty cells is not a record; carrying it through would give\n * every caller the same off-by-one to remember.\n */\nexport function parseCsv(text: string): string[][] {\n const rows: string[][] = []\n let row: string[] = []\n let cell = ''\n let quoted = false\n const source = String(text ?? '')\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]\n if (quoted) {\n if (char === '\"') {\n if (source[index + 1] === '\"') {\n cell += '\"'\n index += 1\n } else {\n quoted = false\n }\n } else {\n cell += char\n }\n continue\n }\n if (char === '\"') {\n quoted = true\n } else if (char === ',') {\n row.push(cell)\n cell = ''\n } else if (char === '\\n' || char === '\\r') {\n if (char === '\\r' && source[index + 1] === '\\n') index += 1\n row.push(cell)\n cell = ''\n rows.push(row)\n row = []\n } else {\n cell += char\n }\n }\n if (cell !== '' || row.length) {\n row.push(cell)\n rows.push(row)\n }\n return rows.filter((cells) => cells.some((value) => value.trim() !== ''))\n}\n"],"names":["escapeCsvCell","cell","test","replace","countCsvDataRows","text","source","String","rows","quoted","cellsSeen","index","length","char","Math","max","exportShortfall","promisedHeader","body","format","promised","Number","received","parsed","JSON","parse","Array","isArray","short","isFinite","parseCsv","row","push","filter","cells","some","value","trim"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,GAED,0EAA0E,GAC1E,OAAO,MAAMA,gBAAgB,CAACC,OAC5B,WAAWC,IAAI,CAACD,QAAQ,CAAC,CAAC,EAAEA,KAAKE,OAAO,CAAC,MAAM,MAAM,CAAC,CAAC,GAAGF,KAAI;AAEhE;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASG,iBAAiBC,IAAY;IAC3C,MAAMC,SAASC,OAAOF,eAAAA,OAAQ;IAC9B,IAAI,CAACC,QAAQ,OAAO;IACpB,IAAIE,OAAO;IACX,IAAIC,SAAS;IACb,IAAIC,YAAY;IAChB,IAAK,IAAIC,QAAQ,GAAGA,QAAQL,OAAOM,MAAM,EAAED,SAAS,EAAG;QACrD,MAAME,OAAOP,MAAM,CAACK,MAAM;QAC1B,IAAIF,QAAQ;YACV,IAAII,SAAS,KAAK;gBAChB,IAAIP,MAAM,CAACK,QAAQ,EAAE,KAAK,KAAKA,SAAS;qBACnCF,SAAS;YAChB;YACAC,YAAY;YACZ;QACF;QACA,IAAIG,SAAS,KAAK;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YACV;YACA;QACF;QACA,IAAIA,SAAS,KAAK;YAChBJ,SAAS;QACX,OAAO,IAAII,SAAS,KAAK;YACvBkB,IAAIC,IAAI,CAAC/B;YACTA,OAAO;QACT,OAAO,IAAIY,SAAS,QAAQA,SAAS,MAAM;YACzC,IAAIA,SAAS,QAAQP,MAAM,CAACK,QAAQ,EAAE,KAAK,MAAMA,SAAS;YAC1DoB,IAAIC,IAAI,CAAC/B;YACTA,OAAO;YACPO,KAAKwB,IAAI,CAACD;YACVA,MAAM,EAAE;QACV,OAAO;YACL9B,QAAQY;QACV;IACF;IACA,IAAIZ,SAAS,MAAM8B,IAAInB,MAAM,EAAE;QAC7BmB,IAAIC,IAAI,CAAC/B;QACTO,KAAKwB,IAAI,CAACD;IACZ;IACA,OAAOvB,KAAKyB,MAAM,CAAC,CAACC,QAAUA,MAAMC,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,OAAO;AACvE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/csv.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 * CSV, read and written the one way the platform does it (AGL-2335).\n *\n * There were five divergent hand-rolled CSV escapers in this repo; this is\n * the one escaper and the one parser every plugin and app reaches — the data\n * plugin's dataset export and import, the email list import, the commerce\n * catalog import, the CRM's contact import — and the check a download runs\n * against the row count its server promised. Nothing here knows what the rows\n * are; a plugin that writes its own records into a file formats each value\n * itself and escapes it here.\n */\n\n/**\n * A cell a spreadsheet would run as a formula: one that opens with `=`, `+`,\n * `-` or `@`, or with a tab or carriage return (which some spreadsheets strip\n * before reading the rest as a formula). Leading `'`s are looked through, so\n * a cell that already starts with the guard is guarded again and the reader\n * below can always take exactly one back off.\n */\nconst CSV_FORMULA_LEAD = /^'*[=+\\-@\\t\\r]/\n\n/** A plain number as text: `-5`, `+1.5`, `.25`, `1e-3`. */\nconst CSV_NUMBER = /^[-+]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][-+]?\\d+)?$/\n\nexport interface CsvCellOptions {\n /**\n * The cell holds a number (a number value, or a number, currency or\n * percent field). A cell that reads as a plain number is then written as\n * is — `-5` stays a negative number in the spreadsheet — and anything else\n * is still guarded.\n */\n numeric?: boolean\n}\n\n/**\n * A cell that cannot run as a spreadsheet formula (AGL-3548).\n *\n * Every CSV the platform writes may hold text a stranger typed — a form\n * answer, a lead's company name — and a spreadsheet that opens the file runs\n * `=HYPERLINK(...)` or `@SUM(...)` as a formula. A leading `'` makes the\n * spreadsheet show the cell as text instead. Only the CSV gets this; a JSON\n * or NDJSON file is read by programs, so it keeps the value as it is.\n * {@link restoreCsvFormulaCell} takes the `'` back off on import.\n */\nexport function neutralizeCsvFormula(cell: string, options?: CsvCellOptions): string {\n if (!CSV_FORMULA_LEAD.test(cell)) return cell\n if (options?.numeric && CSV_NUMBER.test(cell)) return cell\n return `'${cell}`\n}\n\n/**\n * A CSV cell as it was before {@link neutralizeCsvFormula}: one leading `'`\n * dropped when it guards a formula character (or another guard), so a file\n * exported and imported again holds the same text. A `'` before anything\n * else is part of the value and stays.\n */\nexport function restoreCsvFormulaCell(cell: string): string {\n return /^'+[=+\\-@\\t\\r]/.test(cell) ? cell.slice(1) : cell\n}\n\n/**\n * One cell: guarded against running as a formula (see\n * {@link neutralizeCsvFormula}), then quoted when it has to be — a comma, a\n * quote or a line break. Every CSV writer goes through this.\n */\nexport const escapeCsvCell = (cell: string, options?: CsvCellOptions): string => {\n const safe = neutralizeCsvFormula(cell, options)\n return /[\",\\r\\n]/.test(safe) ? `\"${safe.replace(/\"/g, '\"\"')}\"` : safe\n}\n\n/**\n * Data rows in a CSV document — the header excluded, quoted newlines not\n * counted as row breaks (AGL-2335).\n *\n * This exists so a download can be CHECKED against the row count the server\n * promised, rather than trusted. A truncated export is the defect this whole\n * area is about, and a stream that dies halfway produces a perfectly\n * well-formed shorter file: nothing about the bytes says they are short.\n *\n * Single pass, no array building — {@link parseCsv} answers the same\n * question but materializes every cell, which is the wrong trade when the\n * file may be hundreds of thousands of rows and the only thing wanted is\n * how many there are.\n */\nexport function countCsvDataRows(text: string): number {\n const source = String(text ?? '')\n if (!source) return 0\n let rows = 0\n let quoted = false\n let cellsSeen = false\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]\n if (quoted) {\n if (char === '\"') {\n if (source[index + 1] === '\"') index += 1\n else quoted = false\n }\n cellsSeen = true\n continue\n }\n if (char === '\"') {\n quoted = true\n cellsSeen = true\n continue\n }\n if (char === '\\n') {\n rows += 1\n cellsSeen = false\n continue\n }\n if (char !== '\\r') cellsSeen = true\n }\n // A file that does not end in a newline still has a final row.\n if (cellsSeen) rows += 1\n // The header is not data.\n return Math.max(0, rows - 1)\n}\n\n/**\n * Did a downloaded export arrive whole? (AGL-2335)\n *\n * The server streams and reports its `count()` aggregate in a header, so the\n * client can CHECK rather than trust. This is the check, kept here as a pure\n * function because a guard living inline in a component is a guard nobody\n * can force red — and this one exists precisely to catch a silent shortfall.\n *\n * `short` is only true when the count is both KNOWN and lower. A missing or\n * unparseable header is not evidence of truncation, and refusing a download\n * on the strength of a header that never arrived would fail the user for the\n * server's bookkeeping. More rows than promised is not short either — the\n * count is a snapshot taken before the first page, so a concurrent insert\n * can legitimately overtake it.\n */\nexport function exportShortfall(\n promisedHeader: string | null | undefined,\n body: string,\n format: 'csv' | 'json',\n): { promised: number; received: number; short: boolean } {\n const promised = Number(promisedHeader)\n let received: number\n if (format === 'csv') {\n received = countCsvDataRows(body)\n } else {\n try {\n const parsed = JSON.parse(body) as unknown\n received = Array.isArray(parsed) ? parsed.length : 0\n } catch {\n // A body that is not JSON at all did not arrive whole.\n return { promised, received: 0, short: true }\n }\n }\n return {\n promised,\n received,\n short: Number.isFinite(promised) && promisedHeader != null && received < promised,\n }\n}\n\n/**\n * Minimal RFC-4180 CSV parser (quoted fields, escaped quotes, CRLF).\n *\n * The inverse of the escaper above, and the one parser in the repo — see the\n * module note for why the email list importer reaches this rather than\n * writing its own. A cell the escaper guarded against running as a formula\n * comes back without its guard ({@link restoreCsvFormulaCell}).\n *\n * A wholly blank row is dropped. Every spreadsheet writes a trailing newline\n * and a row of empty cells is not a record; carrying it through would give\n * every caller the same off-by-one to remember.\n */\nexport function parseCsv(text: string): string[][] {\n const rows: string[][] = []\n let row: string[] = []\n let cell = ''\n let quoted = false\n const source = String(text ?? '')\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]\n if (quoted) {\n if (char === '\"') {\n if (source[index + 1] === '\"') {\n cell += '\"'\n index += 1\n } else {\n quoted = false\n }\n } else {\n cell += char\n }\n continue\n }\n if (char === '\"') {\n quoted = true\n } else if (char === ',') {\n row.push(restoreCsvFormulaCell(cell))\n cell = ''\n } else if (char === '\\n' || char === '\\r') {\n if (char === '\\r' && source[index + 1] === '\\n') index += 1\n row.push(restoreCsvFormulaCell(cell))\n cell = ''\n rows.push(row)\n row = []\n } else {\n cell += char\n }\n }\n if (cell !== '' || row.length) {\n row.push(restoreCsvFormulaCell(cell))\n rows.push(row)\n }\n return rows.filter((cells) => cells.some((value) => value.trim() !== ''))\n}\n"],"names":["CSV_FORMULA_LEAD","CSV_NUMBER","neutralizeCsvFormula","cell","options","test","numeric","restoreCsvFormulaCell","slice","escapeCsvCell","safe","replace","countCsvDataRows","text","source","String","rows","quoted","cellsSeen","index","length","char","Math","max","exportShortfall","promisedHeader","body","format","promised","Number","received","parsed","JSON","parse","Array","isArray","short","isFinite","parseCsv","row","push","filter","cells","some","value","trim"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;CAUC,G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AACjC,sBAAsBJ;YAC/BA,OAAO;QACT,OAAO,IAAIkB,SAAS,QAAQA,SAAS,MAAM;YACzC,IAAIA,SAAS,QAAQP,MAAM,CAACK,QAAQ,EAAE,KAAK,MAAMA,SAAS;YAC1DoB,IAAIC,IAAI,CAACjC,sBAAsBJ;YAC/BA,OAAO;YACPa,KAAKwB,IAAI,CAACD;YACVA,MAAM,EAAE;QACV,OAAO;YACLpC,QAAQkB;QACV;IACF;IACA,IAAIlB,SAAS,MAAMoC,IAAInB,MAAM,EAAE;QAC7BmB,IAAIC,IAAI,CAACjC,sBAAsBJ;QAC/Ba,KAAKwB,IAAI,CAACD;IACZ;IACA,OAAOvB,KAAKyB,MAAM,CAAC,CAACC,QAAUA,MAAMC,IAAI,CAAC,CAACC,QAAUA,MAAMC,IAAI,OAAO;AACvE"}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import type { HostTheme } from '@aglyn/shared-data-types';
|
|
18
|
+
import { type StarterTemplateScreen } from './starter-template-nodes';
|
|
19
|
+
/**
|
|
20
|
+
* The website every new site is born with (AGL-3497).
|
|
21
|
+
*
|
|
22
|
+
* It used to be one heading and "our new website is on its way" (AGL-3408):
|
|
23
|
+
* a site that answered `/` instead of 404ing, and showed an owner nothing of
|
|
24
|
+
* what the product does. Now a site starts as a real one — a shared header
|
|
25
|
+
* and footer, a home page with the sections an ordinary business site has,
|
|
26
|
+
* photos, a theme and its SEO — and each section says, to the owner, how to
|
|
27
|
+
* make it theirs.
|
|
28
|
+
*
|
|
29
|
+
* It is published and open to search engines from the first request, as every
|
|
30
|
+
* new site's home page has been since AGL-3408.
|
|
31
|
+
*
|
|
32
|
+
* The photos ship with the apps under `/_static/starter/` (see the CREDITS
|
|
33
|
+
* file there). A published page's `img-src` admits only its own origin and
|
|
34
|
+
* the media CDN, so a stock-photo URL would be blocked, and there is no
|
|
35
|
+
* platform-wide media scope to hold them. Both the tenant and the console
|
|
36
|
+
* serve the same files at the same path, so they draw on the live site and in
|
|
37
|
+
* the Besigner alike.
|
|
38
|
+
*
|
|
39
|
+
* PERSISTED IDENTIFIERS: every node id below is stored on every new site.
|
|
40
|
+
*/
|
|
41
|
+
/** Where the starter photos are served from, on every tenant and in the console. */
|
|
42
|
+
export declare const DEFAULT_SITE_IMAGE_BASE = "/_static/starter";
|
|
43
|
+
/** The starter photos, with the sizes the files actually are. */
|
|
44
|
+
export declare const DEFAULT_SITE_IMAGES: {
|
|
45
|
+
readonly hero: {
|
|
46
|
+
readonly src: "/_static/starter/hero-team.jpg";
|
|
47
|
+
readonly width: 1600;
|
|
48
|
+
readonly height: 1067;
|
|
49
|
+
};
|
|
50
|
+
readonly about: {
|
|
51
|
+
readonly src: "/_static/starter/about-owner.jpg";
|
|
52
|
+
readonly width: 1600;
|
|
53
|
+
readonly height: 900;
|
|
54
|
+
};
|
|
55
|
+
readonly desk: {
|
|
56
|
+
readonly src: "/_static/starter/gallery-desk.jpg";
|
|
57
|
+
readonly width: 1600;
|
|
58
|
+
readonly height: 1068;
|
|
59
|
+
};
|
|
60
|
+
readonly plants: {
|
|
61
|
+
readonly src: "/_static/starter/gallery-plants.jpg";
|
|
62
|
+
readonly width: 1200;
|
|
63
|
+
readonly height: 900;
|
|
64
|
+
};
|
|
65
|
+
readonly craft: {
|
|
66
|
+
readonly src: "/_static/starter/gallery-craft.jpg";
|
|
67
|
+
readonly width: 1600;
|
|
68
|
+
readonly height: 1065;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** The node a call to action scrolls to, and the one the features link names. */
|
|
72
|
+
export declare const DEFAULT_HOME_CONTACT_SECTION_ID = "dh_contactSection";
|
|
73
|
+
export declare const DEFAULT_HOME_FEATURES_SECTION_ID = "dh_featuresSection";
|
|
74
|
+
/** What a search result and a shared link say about the home page. */
|
|
75
|
+
export declare function defaultHomeDescription(siteName: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* The home page every new site is born with (AGL-3497, after AGL-3408).
|
|
78
|
+
*
|
|
79
|
+
* Its `seo` is written onto the screen, and the site's header and footer come
|
|
80
|
+
* from the layout `buildDefaultSiteLayout` makes, which the provisioning
|
|
81
|
+
* write binds it to.
|
|
82
|
+
*
|
|
83
|
+
* The site's name is written in as text, not bound: a page has no token for
|
|
84
|
+
* it, and the heading is the first thing an owner rewrites anyway.
|
|
85
|
+
*/
|
|
86
|
+
export declare function buildDefaultHomeScreen(siteName: string): StarterTemplateScreen;
|
|
87
|
+
/** The shared header and footer every page of a new site renders inside. */
|
|
88
|
+
export interface DefaultSiteLayout {
|
|
89
|
+
displayName: string;
|
|
90
|
+
description: string;
|
|
91
|
+
nodes: Record<string, any>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The header and footer a new site is born with (AGL-3497).
|
|
95
|
+
*
|
|
96
|
+
* The brand reads `{{host.businessName}}`, so it follows the site's name in
|
|
97
|
+
* Setup rather than freezing the one it was created under. The header's
|
|
98
|
+
* Contact button scrolls to the home page's contact section; on another page
|
|
99
|
+
* it has nothing to scroll to and does nothing, which is the step's own rule.
|
|
100
|
+
*
|
|
101
|
+
* `homeScreenId` is the home page the brand and the footer's Home link point
|
|
102
|
+
* at — a link by id, so it survives a slug change.
|
|
103
|
+
*/
|
|
104
|
+
export declare function buildDefaultSiteLayout(homeScreenId: string): DefaultSiteLayout;
|
|
105
|
+
/**
|
|
106
|
+
* The theme a new site starts with (AGL-3497): an indigo and teal palette on
|
|
107
|
+
* a soft neutral ground, one Google family, rounder corners and buttons that
|
|
108
|
+
* do not shout. Written as the site's own `theme`, so the theme library files
|
|
109
|
+
* it as "Site theme" and keeps it when the owner switches to another.
|
|
110
|
+
*
|
|
111
|
+
* Dark is authored too, because a visitor's device decides which one they
|
|
112
|
+
* see, and the header's switcher lets them choose.
|
|
113
|
+
*/
|
|
114
|
+
export declare const DEFAULT_SITE_THEME: HostTheme;
|
|
115
|
+
/** The site-wide SEO a new site starts with: its name, a description and a sharing image. */
|
|
116
|
+
export declare function defaultSiteSeo(siteName: string): Record<string, unknown>;
|