@tokenoftrust/storefront-runner 7.3.1 → 7.5.0
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/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
- package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
- package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
- package/apps/storefront/astro.config.mjs +8 -2
- package/apps/storefront/package.json +1 -2
- package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
- package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
- package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
- package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
- package/apps/storefront/src/layouts/Layout.astro +17 -0
- package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
- package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +147 -0
- package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +67 -1
- package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
- package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
- package/apps/storefront/src/lib/access/auth/session.ts +79 -0
- package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
- package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
- package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
- package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
- package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
- package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
- package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
- package/apps/storefront/src/lib/activity/store.ts +9 -3
- package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
- package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
- package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
- package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
- package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
- package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
- package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
- package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
- package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
- package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
- package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
- package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
- package/apps/storefront/src/middleware/controlPlane.ts +15 -1
- package/apps/storefront/src/middleware/index.ts +40 -1
- package/apps/storefront/src/middleware/renderChain.ts +46 -33
- package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
- package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
- package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
- package/apps/storefront/src/pages/products/[handle].astro +2 -15
- package/apps/storefront/tsconfig.astro.json +11 -0
- package/package.json +1 -1
- package/packages/public-runtime/src/activity/README.md +12 -0
- package/packages/public-runtime/src/activity/catalog.ts +7 -0
- package/packages/public-runtime/src/activity/event.ts +19 -0
- package/packages/public-runtime/src/activity/redaction.ts +31 -2
- package/packages/public-runtime/src/catalog-files.ts +3 -2
- package/packages/public-runtime/src/checkout-orders.ts +18 -19
- package/packages/public-runtime/src/checkout.ts +70 -0
- package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
- package/packages/public-runtime/src/compliance/index.ts +1 -1
- package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
- package/packages/public-runtime/src/compliance/profile.ts +268 -20
- package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
- package/packages/public-runtime/src/customization-runtime.ts +1 -1
- package/packages/public-runtime/src/product.ts +9 -1
- package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
- package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
- package/pnpm-lock.runner.yaml +0 -15
- package/scripts/tenant/materialize-tenant-content.mjs +3 -0
- package/scripts/tenant/validate.mjs +128 -0
- package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
- package/apps/storefront/drizzle.config.apps.ts +0 -13
- package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
- package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
- package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
- package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
- package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
- package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
- package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
- package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
- package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
- package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
- package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
- package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
- package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
- package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
- package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
- package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
- package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
- package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
- package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
- package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
- package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
- package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
- package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
- package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
- package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
- package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
- package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
- package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
- package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
- package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
- package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
- package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
- package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
- package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
- package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
- package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
- package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
- package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
- package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
- package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
- package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
- package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
- package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
- package/apps/storefront/perf/README.md +0 -64
- package/apps/storefront/perf/assert-budgets.ts +0 -159
- package/apps/storefront/platform-reconcile-tenants.json +0 -3
- package/apps/storefront/playwright.config.ts +0 -23
- package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
- package/apps/storefront/public/js/dashboard-apps.js +0 -183
- package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
- package/apps/storefront/public/js/dashboard-delegate.js +0 -167
- package/apps/storefront/public/js/dashboard-team.js +0 -356
- package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
- package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
- package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
- package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
- package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
- package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
- package/apps/storefront/src/config/storeName.ts +0 -34
- package/apps/storefront/src/lib/access/admin/README.md +0 -122
- package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
- package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
- package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
- package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
- package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
- package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
- package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
- package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
- package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -150
- package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -452
- package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
- package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
- package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
- package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
- package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
- package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
- package/apps/storefront/src/lib/activity/alerts.ts +0 -426
- package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
- package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
- package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
- package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
- package/apps/storefront/src/lib/activity/query.ts +0 -403
- package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
- package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
- package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
- package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
- package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
- package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
- package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
- package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
- package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
- package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
- package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
- package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
- package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
- package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
- package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
- package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
- package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
- package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
- package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
- package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
- package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
- package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
- package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
- package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
- package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
- package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
- package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
- package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
- package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
- package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
- package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
- package/apps/storefront/src/lib/content/index.ts +0 -27
- package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
- package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
- package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
- package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
- package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
- package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
- package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
- package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
- package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
- package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
- package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
- package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
- package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
- package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
- package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
- package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
- package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
- package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
- package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
- package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
- package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
- package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
- package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
- package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
- package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
- package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
- package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
- package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
- package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
- package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
- package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
- package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
- package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
- package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
- package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
- package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
- package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
- package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
- package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
- package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
- package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
- package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
- package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
- package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
- package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
- package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
- package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
- package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
- package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
- package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
- package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
- package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
- package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
- package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
- package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
- package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
- package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
- package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
- package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
- package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
- package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
- package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
- package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
- package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
- package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
- package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
- package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
- package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
- package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
- package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
- package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
- package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
- package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
- package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
- package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
- package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
- package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
- package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
- package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
- package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
- package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
- package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
- package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
- package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
- package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
- package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
- package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
- package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
- package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
- package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
- package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
- package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
- package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
- package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
- package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
- package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
- package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
- package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
- package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
- package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
- package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
- package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
- package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
- package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
- package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
- package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
- package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
- package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
- package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
- package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
- package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
- package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
- package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
- package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
- package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
- package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
- package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
- package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
- package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
- package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
- package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
- package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
- package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
- package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
- package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
- package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
- package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
- package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
- package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
- package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
- package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
- package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
- package/apps/storefront/src/pages/api/contact.ts +0 -144
- package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
- package/apps/storefront/src/styles/admin.css +0 -1161
- package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
- package/apps/storefront/test/pipeline/harness.ts +0 -209
- package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
- package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
- package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
- package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
- package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
- package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
- package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
- package/apps/storefront/vitest.config.cts +0 -44
- package/apps/storefront/vitest.faults.config.cts +0 -13
- package/apps/storefront/vitest.workers.config.cts +0 -7
- package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
- package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
- package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
- package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
- package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
- package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
- package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
- package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
- package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
- package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
- package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
- package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
- package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
- package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
- package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
- package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
- package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
- package/packages/feedback/package.json +0 -35
- package/packages/feedback/scripts/build-player.mjs +0 -28
- package/packages/feedback/src/index.ts +0 -1
- package/packages/feedback/src/primitives/composer.ts +0 -639
- package/packages/feedback/src/primitives/dialog.ts +0 -263
- package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
- package/packages/feedback/src/primitives/index.ts +0 -10
- package/packages/feedback/src/primitives/launcher.ts +0 -200
- package/packages/feedback/src/primitives/picker.ts +0 -663
- package/packages/feedback/src/primitives/redaction.ts +0 -204
- package/packages/feedback/src/primitives/selection.ts +0 -49
- package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
- package/packages/feedback/src/primitives/styles.ts +0 -77
- package/packages/feedback/src/primitives/surface.ts +0 -124
- package/packages/feedback/src/primitives/target.ts +0 -293
- package/packages/feedback/src/tour/canonical.ts +0 -27
- package/packages/feedback/src/tour/index.ts +0 -3
- package/packages/feedback/src/tour/player/browser.ts +0 -5
- package/packages/feedback/src/tour/player/host.ts +0 -12
- package/packages/feedback/src/tour/player/index.ts +0 -205
- package/packages/feedback/src/tour/player/manifest.ts +0 -76
- package/packages/feedback/src/tour/player/player.css +0 -130
- package/packages/feedback/src/tour/player/resolver.ts +0 -12
- package/packages/feedback/src/tour/player/surface.ts +0 -295
- package/packages/feedback/src/tour/player/types.ts +0 -8
- package/packages/feedback/src/tour/resolve/core.ts +0 -267
- package/packages/feedback/src/tour/resolve/dom.ts +0 -115
- package/packages/feedback/src/tour/resolve/index.ts +0 -29
- package/packages/feedback/src/tour/sanitize.ts +0 -76
- package/packages/feedback/src/tour/schema.ts +0 -362
- package/packages/feedback/src/v1/guards.ts +0 -335
- package/packages/feedback/src/v1/index.ts +0 -3
- package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
- package/packages/feedback/src/v1/types.ts +0 -177
- package/packages/feedback/tsconfig.json +0 -9
- package/packages/feedback/vitest.config.cts +0 -21
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `tour-1`: authored tours. Strict objects throughout; the validator refuses and never rewrites;
|
|
3
|
-
* refusals carry a code and a path, never a value. Targets, viewport and page context are validated
|
|
4
|
-
* by the same feedback.v1 functions the annotation bridge uses.
|
|
5
|
-
*/
|
|
6
|
-
import type { FeedbackTarget, PageContext, ViewportSnapshot } from "../v1/types.js";
|
|
7
|
-
import { validatePageAt, validateTargetAt, validateViewportAt } from "../v1/guards.js";
|
|
8
|
-
import { isProtectedPath } from "../v1/protectedSurfaces.js";
|
|
9
|
-
import { canonicalTourBytes, MAX_TOUR_BYTES } from "./canonical.js";
|
|
10
|
-
import { checkText, type TextRule } from "./sanitize.js";
|
|
11
|
-
|
|
12
|
-
export const TOUR_SCHEMA_VERSION = "tour-1" as const;
|
|
13
|
-
export const MAX_STEPS = 20;
|
|
14
|
-
|
|
15
|
-
export type TourId = string;
|
|
16
|
-
export type StepId = string;
|
|
17
|
-
export type ViewportBand = "narrow" | "medium" | "wide";
|
|
18
|
-
export type TourTarget = FeedbackTarget;
|
|
19
|
-
export type RecordedActionRef = { recordId: string; seq: number };
|
|
20
|
-
|
|
21
|
-
export type TourTrigger = { kind: "launcher" } | { kind: "first-visit" } | { kind: "link" };
|
|
22
|
-
export type Placement = "auto" | "top" | "bottom" | "left" | "right" | "center";
|
|
23
|
-
export type Corner = "top-start" | "top-end" | "bottom-start" | "bottom-end";
|
|
24
|
-
export type AdvanceRule = { on: "next" } | { on: "dwell"; ms: number } | { on: "target-click" };
|
|
25
|
-
|
|
26
|
-
interface StepBase {
|
|
27
|
-
id: StepId;
|
|
28
|
-
advance: AdvanceRule;
|
|
29
|
-
bandTargets?: Partial<Record<ViewportBand, TourTarget>>;
|
|
30
|
-
hideIn?: ViewportBand[];
|
|
31
|
-
recordedAction?: RecordedActionRef;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface HighlightStep extends StepBase {
|
|
35
|
-
kind: "highlight";
|
|
36
|
-
target: TourTarget;
|
|
37
|
-
label?: string;
|
|
38
|
-
placement?: Exclude<Placement, "center">;
|
|
39
|
-
tone?: "accent" | "neutral";
|
|
40
|
-
padding?: number;
|
|
41
|
-
onUnresolved?: "skip" | "region";
|
|
42
|
-
}
|
|
43
|
-
export interface ToastStep extends StepBase {
|
|
44
|
-
kind: "toast";
|
|
45
|
-
title?: string;
|
|
46
|
-
body: string;
|
|
47
|
-
target?: TourTarget;
|
|
48
|
-
position?: Corner;
|
|
49
|
-
onUnresolved?: "unanchored";
|
|
50
|
-
}
|
|
51
|
-
export interface ModalStep extends StepBase {
|
|
52
|
-
kind: "modal";
|
|
53
|
-
title: string;
|
|
54
|
-
body: string;
|
|
55
|
-
primaryLabel: string;
|
|
56
|
-
dismissLabel?: string;
|
|
57
|
-
target?: TourTarget;
|
|
58
|
-
placement?: Placement;
|
|
59
|
-
onUnresolved?: "unanchored";
|
|
60
|
-
}
|
|
61
|
-
export interface TextStep extends StepBase {
|
|
62
|
-
kind: "text";
|
|
63
|
-
body: string;
|
|
64
|
-
target: TourTarget;
|
|
65
|
-
placement?: Exclude<Placement, "center">;
|
|
66
|
-
onUnresolved?: "skip" | "unanchored";
|
|
67
|
-
}
|
|
68
|
-
export type TourStep = HighlightStep | ToastStep | ModalStep | TextStep;
|
|
69
|
-
|
|
70
|
-
export interface TourDocument {
|
|
71
|
-
schemaVersion: "tour-1";
|
|
72
|
-
id: TourId;
|
|
73
|
-
revision: number;
|
|
74
|
-
page: PageContext;
|
|
75
|
-
locale?: string;
|
|
76
|
-
title: string;
|
|
77
|
-
trigger: TourTrigger;
|
|
78
|
-
authoredViewport?: ViewportSnapshot;
|
|
79
|
-
steps: TourStep[];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never;
|
|
83
|
-
export type PublishedTour = Omit<TourDocument, "steps"> & {
|
|
84
|
-
steps: Array<DistributiveOmit<TourStep, "recordedAction">>;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export type TourRefusalCode =
|
|
88
|
-
| "TOUR_SHAPE" | "TOUR_SCHEMA_VERSION" | "TOUR_ID" | "TOUR_REVISION" | "TOUR_PAGE" | "TOUR_LOCALE"
|
|
89
|
-
| "TOUR_PAGE_PROTECTED" | "TOUR_STEPS_EMPTY" | "TOUR_STEPS_TOO_MANY" | "TOUR_STEP_ID"
|
|
90
|
-
| "TOUR_STEP_ID_DUPLICATE" | "TOUR_STEP_KIND" | "TOUR_TARGET_REQUIRED" | "TOUR_TARGET_INVALID"
|
|
91
|
-
| "TOUR_TARGET_KIND" | "TOUR_TEXT_LENGTH" | "TOUR_TEXT_BLANK" | "TOUR_TEXT_CONTROL"
|
|
92
|
-
| "TOUR_TEXT_MARKUP" | "TOUR_TEXT_URL" | "TOUR_TEXT_PII" | "TOUR_ADVANCE" | "TOUR_PLACEMENT"
|
|
93
|
-
| "TOUR_FALLBACK" | "TOUR_BAND" | "TOUR_RECORD_REF" | "TOUR_PRIVATE_FIELD" | "TOUR_TOO_LARGE";
|
|
94
|
-
|
|
95
|
-
/** `path` only, never a value. The root of the document is the empty path. */
|
|
96
|
-
export type TourRefusal = { code: TourRefusalCode; path: string };
|
|
97
|
-
export type TourValidation = { ok: true; doc: TourDocument } | { ok: false; refusals: TourRefusal[] };
|
|
98
|
-
|
|
99
|
-
export interface ValidateOptions {
|
|
100
|
-
/** The tenant's declared protected prefixes, added to the platform list. */
|
|
101
|
-
protectedPrefixes?: readonly string[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const MAX_REFUSALS = 20;
|
|
105
|
-
const TOUR_ID = /^tour_[a-z0-9][a-z0-9-]{1,62}$/;
|
|
106
|
-
const STEP_ID = /^s_[a-z0-9][a-z0-9_-]{0,31}$/;
|
|
107
|
-
const LOCALE = /^[a-z]{2,3}(-[A-Z]{2})?$/;
|
|
108
|
-
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
109
|
-
const BANDS: readonly string[] = ["narrow", "medium", "wide"];
|
|
110
|
-
const CORNERS: readonly string[] = ["top-start", "top-end", "bottom-start", "bottom-end"];
|
|
111
|
-
const PLACEMENTS: readonly string[] = ["auto", "top", "bottom", "left", "right", "center"];
|
|
112
|
-
const TRIGGERS: readonly string[] = ["launcher", "first-visit", "link"];
|
|
113
|
-
|
|
114
|
-
type Rec = Record<string, unknown>;
|
|
115
|
-
const isRec = (v: unknown): v is Rec => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
116
|
-
const hasOwn = (o: Rec, k: string) => Object.prototype.hasOwnProperty.call(o, k);
|
|
117
|
-
const isInt = (v: unknown, lo: number, hi: number) =>
|
|
118
|
-
typeof v === "number" && Number.isInteger(v) && v >= lo && v <= hi;
|
|
119
|
-
|
|
120
|
-
const BASE_KEYS = ["id", "kind", "advance", "bandTargets", "hideIn", "recordedAction"];
|
|
121
|
-
const STEP_KEYS: Record<string, readonly string[]> = {
|
|
122
|
-
highlight: [...BASE_KEYS, "target", "label", "placement", "tone", "padding", "onUnresolved"],
|
|
123
|
-
toast: [...BASE_KEYS, "title", "body", "target", "position", "onUnresolved"],
|
|
124
|
-
modal: [...BASE_KEYS, "title", "body", "primaryLabel", "dismissLabel", "target", "placement", "onUnresolved"],
|
|
125
|
-
text: [...BASE_KEYS, "body", "target", "placement", "onUnresolved"],
|
|
126
|
-
};
|
|
127
|
-
const FALLBACKS: Record<string, readonly string[]> = {
|
|
128
|
-
highlight: ["skip", "region"],
|
|
129
|
-
toast: ["unanchored"],
|
|
130
|
-
modal: ["unanchored"],
|
|
131
|
-
text: ["skip", "unanchored"],
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
class Collector {
|
|
135
|
-
readonly list: TourRefusal[] = [];
|
|
136
|
-
add(code: TourRefusalCode, path: string): void {
|
|
137
|
-
if (!this.list.some((r) => r.code === code && r.path === path)) this.list.push({ code, path });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const join = (base: string, key: string | number) => (base === "" ? String(key) : `${base}.${key}`);
|
|
142
|
-
|
|
143
|
-
function text(c: Collector, value: unknown, path: string, rule: TextRule): void {
|
|
144
|
-
if (typeof value !== "string") {
|
|
145
|
-
c.add("TOUR_SHAPE", path);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const refusal = checkText(value, rule);
|
|
149
|
-
if (refusal) c.add(refusal, path);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function onlyKeys(c: Collector, obj: Rec, allowed: readonly string[], base: string): void {
|
|
153
|
-
for (const key of Object.keys(obj)) if (!allowed.includes(key)) c.add("TOUR_SHAPE", join(base, key));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/** Run the shared feedback.v1 target validator and re-root its findings under `path`. */
|
|
157
|
-
function target(c: Collector, value: unknown, path: string, stepKind?: string): void {
|
|
158
|
-
const found: string[] = [];
|
|
159
|
-
validateTargetAt(value, "$", found);
|
|
160
|
-
for (const finding of found) {
|
|
161
|
-
let rest = finding.slice(1).replace(/\[(\d+)\]/g, ".$1");
|
|
162
|
-
const seg = /^\.structuralPath\.(\d+)$/.exec(rest);
|
|
163
|
-
if (seg && isRec(value)) {
|
|
164
|
-
const item = (value.structuralPath as unknown[])[Number(seg[1])];
|
|
165
|
-
rest += isRec(item) && typeof item.tag === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(item.tag) ? ".childIndex" : ".tag";
|
|
166
|
-
}
|
|
167
|
-
c.add("TOUR_TARGET_INVALID", `${path}${rest}`);
|
|
168
|
-
}
|
|
169
|
-
if (found.length === 0 && isRec(value) && value.kind === "page" && (stepKind === "highlight" || stepKind === "text")) {
|
|
170
|
-
c.add("TOUR_TARGET_KIND", join(path, "kind"));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function advance(c: Collector, value: unknown, path: string, hasTarget: boolean): void {
|
|
175
|
-
if (!isRec(value)) {
|
|
176
|
-
c.add("TOUR_SHAPE", path);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (value.on === "next" || value.on === "target-click") {
|
|
180
|
-
onlyKeys(c, value, ["on"], path);
|
|
181
|
-
if (value.on === "target-click" && !hasTarget) c.add("TOUR_ADVANCE", path);
|
|
182
|
-
} else if (value.on === "dwell") {
|
|
183
|
-
onlyKeys(c, value, ["on", "ms"], path);
|
|
184
|
-
if (!isInt(value.ms, 1500, 20000)) c.add("TOUR_ADVANCE", join(path, "ms"));
|
|
185
|
-
} else {
|
|
186
|
-
c.add("TOUR_ADVANCE", join(path, "on"));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function step(c: Collector, s: unknown, path: string, mode: "draft" | "published"): void {
|
|
191
|
-
if (!isRec(s)) {
|
|
192
|
-
c.add("TOUR_SHAPE", path);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const kind = s.kind;
|
|
196
|
-
const allowedKeys = typeof kind === "string" && hasOwn(STEP_KEYS, kind) ? STEP_KEYS[kind] : undefined;
|
|
197
|
-
if (typeof kind !== "string" || !allowedKeys) {
|
|
198
|
-
c.add("TOUR_STEP_KIND", join(path, "kind"));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
onlyKeys(c, s, allowedKeys, path);
|
|
202
|
-
const has = (k: string) => hasOwn(s, k) && s[k] !== undefined;
|
|
203
|
-
|
|
204
|
-
const copyRequired = kind === "toast" || kind === "modal" || kind === "text";
|
|
205
|
-
if (copyRequired && !has("body")) c.add("TOUR_SHAPE", join(path, "body"));
|
|
206
|
-
if (kind === "modal") {
|
|
207
|
-
if (!has("title")) c.add("TOUR_SHAPE", join(path, "title"));
|
|
208
|
-
if (!has("primaryLabel")) c.add("TOUR_SHAPE", join(path, "primaryLabel"));
|
|
209
|
-
}
|
|
210
|
-
if (has("title")) text(c, s.title, join(path, "title"), { min: 1, max: kind === "modal" ? 80 : 60 });
|
|
211
|
-
if (has("body")) text(c, s.body, join(path, "body"), { min: 1, max: kind === "modal" ? 600 : 280, allowLf: true });
|
|
212
|
-
if (has("label")) text(c, s.label, join(path, "label"), { min: 1, max: 120 });
|
|
213
|
-
if (has("primaryLabel")) text(c, s.primaryLabel, join(path, "primaryLabel"), { min: 1, max: 24 });
|
|
214
|
-
if (has("dismissLabel")) text(c, s.dismissLabel, join(path, "dismissLabel"), { min: 1, max: 24 });
|
|
215
|
-
|
|
216
|
-
if (has("target")) target(c, s.target, join(path, "target"), kind);
|
|
217
|
-
else if (kind === "highlight" || kind === "text") c.add("TOUR_TARGET_REQUIRED", join(path, "target"));
|
|
218
|
-
|
|
219
|
-
advance(c, s.advance, join(path, "advance"), has("target"));
|
|
220
|
-
|
|
221
|
-
if (has("placement")) {
|
|
222
|
-
const ok =
|
|
223
|
-
typeof s.placement === "string" &&
|
|
224
|
-
PLACEMENTS.includes(s.placement) &&
|
|
225
|
-
(kind === "modal" || s.placement !== "center");
|
|
226
|
-
if (!ok) c.add("TOUR_PLACEMENT", join(path, "placement"));
|
|
227
|
-
}
|
|
228
|
-
if (has("position") && !(typeof s.position === "string" && CORNERS.includes(s.position))) {
|
|
229
|
-
c.add("TOUR_PLACEMENT", join(path, "position"));
|
|
230
|
-
}
|
|
231
|
-
if (has("tone") && s.tone !== "accent" && s.tone !== "neutral") c.add("TOUR_SHAPE", join(path, "tone"));
|
|
232
|
-
if (has("padding") && !isInt(s.padding, 0, 24)) c.add("TOUR_SHAPE", join(path, "padding"));
|
|
233
|
-
if (has("onUnresolved") && !(typeof s.onUnresolved === "string" && (FALLBACKS[kind] ?? []).includes(s.onUnresolved))) {
|
|
234
|
-
c.add("TOUR_FALLBACK", join(path, "onUnresolved"));
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (has("bandTargets")) {
|
|
238
|
-
const bt = s.bandTargets;
|
|
239
|
-
if (!isRec(bt)) c.add("TOUR_SHAPE", join(path, "bandTargets"));
|
|
240
|
-
else {
|
|
241
|
-
for (const [band, t] of Object.entries(bt)) {
|
|
242
|
-
const bp = join(join(path, "bandTargets"), band);
|
|
243
|
-
if (!BANDS.includes(band)) c.add("TOUR_BAND", bp);
|
|
244
|
-
else target(c, t, bp, kind);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
if (has("hideIn")) {
|
|
249
|
-
const hide = s.hideIn;
|
|
250
|
-
const hp = join(path, "hideIn");
|
|
251
|
-
if (!Array.isArray(hide)) c.add("TOUR_SHAPE", hp);
|
|
252
|
-
else {
|
|
253
|
-
hide.forEach((b, i) => {
|
|
254
|
-
if (typeof b !== "string" || !BANDS.includes(b)) c.add("TOUR_BAND", join(hp, i));
|
|
255
|
-
});
|
|
256
|
-
const known = hide.filter((b): b is string => typeof b === "string" && BANDS.includes(b));
|
|
257
|
-
if (new Set(known).size !== known.length || new Set(known).size === BANDS.length) c.add("TOUR_BAND", hp);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if (has("recordedAction")) {
|
|
261
|
-
const rp = join(path, "recordedAction");
|
|
262
|
-
if (mode === "published") c.add("TOUR_PRIVATE_FIELD", rp);
|
|
263
|
-
else {
|
|
264
|
-
const r = s.recordedAction;
|
|
265
|
-
const ok =
|
|
266
|
-
isRec(r) &&
|
|
267
|
-
Object.keys(r).every((k) => k === "recordId" || k === "seq") &&
|
|
268
|
-
typeof r.recordId === "string" &&
|
|
269
|
-
UUID.test(r.recordId) &&
|
|
270
|
-
isInt(r.seq, 0, Number.MAX_SAFE_INTEGER);
|
|
271
|
-
if (!ok) c.add("TOUR_RECORD_REF", rp);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function page(c: Collector, value: unknown, opts: ValidateOptions): void {
|
|
277
|
-
const found: string[] = [];
|
|
278
|
-
validatePageAt(value, "$", found);
|
|
279
|
-
if (found.length > 0) {
|
|
280
|
-
for (const f of found) {
|
|
281
|
-
if (f === "$.path") c.add("TOUR_PAGE", "page.path");
|
|
282
|
-
else c.add("TOUR_SHAPE", f === "$" ? "page" : `page${f.slice(1)}`);
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const p = (value as PageContext).path;
|
|
287
|
-
if (p.includes("[segment]") || p.includes("[rest]")) c.add("TOUR_PAGE", "page.path");
|
|
288
|
-
else if (isProtectedPath(p, opts.protectedPrefixes)) c.add("TOUR_PAGE_PROTECTED", "page.path");
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
function structure(c: Collector, input: unknown, mode: "draft" | "published", opts: ValidateOptions): void {
|
|
292
|
-
if (!isRec(input)) {
|
|
293
|
-
c.add("TOUR_SHAPE", "");
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
onlyKeys(c, input, ["schemaVersion", "id", "revision", "page", "locale", "title", "trigger", "authoredViewport", "steps"], "");
|
|
297
|
-
if (input.schemaVersion !== TOUR_SCHEMA_VERSION) c.add("TOUR_SCHEMA_VERSION", "schemaVersion");
|
|
298
|
-
if (!(typeof input.id === "string" && TOUR_ID.test(input.id))) c.add("TOUR_ID", "id");
|
|
299
|
-
if (!isInt(input.revision, 1, 2 ** 31 - 1)) c.add("TOUR_REVISION", "revision");
|
|
300
|
-
page(c, input.page, opts);
|
|
301
|
-
if (input.locale !== undefined && !(typeof input.locale === "string" && LOCALE.test(input.locale))) {
|
|
302
|
-
c.add("TOUR_LOCALE", "locale");
|
|
303
|
-
}
|
|
304
|
-
text(c, input.title, "title", { min: 1, max: 80 });
|
|
305
|
-
const t = input.trigger;
|
|
306
|
-
if (!isRec(t) || typeof t.kind !== "string" || !TRIGGERS.includes(t.kind) || Object.keys(t).length !== 1) {
|
|
307
|
-
c.add("TOUR_SHAPE", "trigger");
|
|
308
|
-
}
|
|
309
|
-
if (input.authoredViewport !== undefined) {
|
|
310
|
-
const found: string[] = [];
|
|
311
|
-
validateViewportAt(input.authoredViewport, "$", found);
|
|
312
|
-
for (const f of found) c.add("TOUR_SHAPE", `authoredViewport${f.slice(1)}`);
|
|
313
|
-
}
|
|
314
|
-
const steps = input.steps;
|
|
315
|
-
if (!Array.isArray(steps)) {
|
|
316
|
-
c.add("TOUR_SHAPE", "steps");
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if (steps.length === 0) c.add("TOUR_STEPS_EMPTY", "steps");
|
|
320
|
-
if (steps.length > MAX_STEPS) c.add("TOUR_STEPS_TOO_MANY", "steps");
|
|
321
|
-
const seen = new Set<string>();
|
|
322
|
-
steps.slice(0, MAX_STEPS + 1).forEach((s, i) => {
|
|
323
|
-
const sp = join("steps", i);
|
|
324
|
-
step(c, s, sp, mode);
|
|
325
|
-
if (isRec(s) && s.id !== undefined) {
|
|
326
|
-
if (!(typeof s.id === "string" && STEP_ID.test(s.id))) c.add("TOUR_STEP_ID", join(sp, "id"));
|
|
327
|
-
else if (seen.has(s.id)) c.add("TOUR_STEP_ID_DUPLICATE", join(sp, "id"));
|
|
328
|
-
else seen.add(s.id);
|
|
329
|
-
} else if (isRec(s)) c.add("TOUR_STEP_ID", join(sp, "id"));
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
export function validateTour(input: unknown, mode: "draft" | "published", opts: ValidateOptions = {}): TourValidation {
|
|
334
|
-
const c = new Collector();
|
|
335
|
-
try {
|
|
336
|
-
structure(c, input, mode, opts);
|
|
337
|
-
if (c.list.length === 0) {
|
|
338
|
-
const doc = input as TourDocument;
|
|
339
|
-
if (canonicalTourBytes(publishedProjection(doc)).length > MAX_TOUR_BYTES) c.add("TOUR_TOO_LARGE", "");
|
|
340
|
-
}
|
|
341
|
-
} catch {
|
|
342
|
-
c.list.length = 0;
|
|
343
|
-
c.add("TOUR_SHAPE", "");
|
|
344
|
-
}
|
|
345
|
-
if (c.list.length === 0) return { ok: true, doc: input as TourDocument };
|
|
346
|
-
const refusals = [...c.list]
|
|
347
|
-
.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : a.code < b.code ? -1 : a.code > b.code ? 1 : 0))
|
|
348
|
-
.slice(0, MAX_REFUSALS);
|
|
349
|
-
return { ok: false, refusals };
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/** The same document with authoring-only fields removed. */
|
|
353
|
-
export function publishedProjection(doc: TourDocument): PublishedTour {
|
|
354
|
-
const steps = doc.steps.map((s) => {
|
|
355
|
-
const rest: Record<string, unknown> = { ...s };
|
|
356
|
-
delete rest.recordedAction;
|
|
357
|
-
return rest;
|
|
358
|
-
});
|
|
359
|
-
return { ...doc, steps } as PublishedTour;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export { canonicalTourBytes } from "./canonical.js";
|