@tokenoftrust/storefront-runner 7.3.2 → 7.5.1
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 +32 -8
- package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
- 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/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/agent/checkoutProtocol.ts +196 -0
- package/apps/storefront/src/lib/checkout/agent/checkoutSession.ts +296 -0
- package/apps/storefront/src/lib/checkout/agent/webBotAuth.ts +347 -0
- 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 +522 -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 +7 -3
- 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/checkout-sessions/[id].ts +9 -0
- package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +8 -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/agentStoreEntry.ts +0 -253
- package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
- package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
- package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
- 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/agentGrantAttestation.ts +0 -74
- 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,367 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser wiring for operational settings' draft/live state in /admin.
|
|
3
|
-
*
|
|
4
|
-
* - Under each Settings panel, one setting's block: "Live" when the draft equals live, otherwise
|
|
5
|
-
* the pending changes in plain words with Publish to live and Discard draft.
|
|
6
|
-
* - On the Publish tab, "Settings waiting to go live": every pending setting with its changes,
|
|
7
|
-
* Publish settings, and Roll back to a prior live value. Each pending setting carries
|
|
8
|
-
* `[data-settings-pin]` with the versionIds it shows, which the publish-live dialog pins.
|
|
9
|
-
*
|
|
10
|
-
* Each action echoes back the versionIds shown, so the server refuses it when the draft or live
|
|
11
|
-
* value moved since. A save announces itself with `SETTING_SAVED_EVENT`, and the blocks re-read.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export const SETTING_SAVED_EVENT = "operational-setting:saved";
|
|
15
|
-
|
|
16
|
-
export interface SettingChangeView {
|
|
17
|
-
label: string;
|
|
18
|
-
live: string;
|
|
19
|
-
draft: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface SettingHistoryView {
|
|
23
|
-
versionId: string;
|
|
24
|
-
at: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface SettingStatusView {
|
|
28
|
-
kind: string;
|
|
29
|
-
title?: string;
|
|
30
|
-
path?: string;
|
|
31
|
-
draftVersionId: string | null;
|
|
32
|
-
liveVersionId: string | null;
|
|
33
|
-
pending: boolean;
|
|
34
|
-
changes: SettingChangeView[];
|
|
35
|
-
history?: SettingHistoryView[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface StatusResponse {
|
|
39
|
-
hasLiveSite?: boolean;
|
|
40
|
-
settings?: SettingStatusView[];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface ActionResponse {
|
|
44
|
-
readBack?: string;
|
|
45
|
-
notice?: string;
|
|
46
|
-
error?: string;
|
|
47
|
-
settings?: StatusResponse;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type StatusState = "ok" | "err";
|
|
51
|
-
|
|
52
|
-
/** "Enforce compliance rules: live off → draft on". */
|
|
53
|
-
export function changeSentence(change: SettingChangeView): string {
|
|
54
|
-
return `${change.label}: live ${change.live} → draft ${change.draft}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Tell the other settings blocks on the page that a setting's draft or live value changed. */
|
|
58
|
-
export function announceSettingChanged(kind: string): void {
|
|
59
|
-
document.dispatchEvent(new CustomEvent(SETTING_SAVED_EVENT, { detail: { kind } }));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** A prior live value, by when it went live: "Live from 2026-10-24 09:12 UTC". */
|
|
63
|
-
export function historyLabel(entry: SettingHistoryView): string {
|
|
64
|
-
const at = new Date(entry.at);
|
|
65
|
-
const when = Number.isNaN(at.getTime()) ? entry.at : `${at.toISOString().slice(0, 16).replace("T", " ")} UTC`;
|
|
66
|
-
return `Live from ${when}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** What a save reports, by the envs it is in effect on. */
|
|
70
|
-
export function savedMessage(inEffect: readonly string[] | undefined): string {
|
|
71
|
-
return inEffect?.includes("live")
|
|
72
|
-
? "Saved. In effect on your preview and live store."
|
|
73
|
-
: "Saved to your draft. Your preview shows it; publish it to put it on your live store.";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function publishBody(setting: SettingStatusView, targetTenant: string): Record<string, unknown> {
|
|
77
|
-
return {
|
|
78
|
-
kind: setting.kind,
|
|
79
|
-
action: "publish",
|
|
80
|
-
versionId: setting.draftVersionId,
|
|
81
|
-
expectedLiveVersionId: setting.liveVersionId,
|
|
82
|
-
...(targetTenant ? { targetTenant } : {}),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function rollbackBody(setting: SettingStatusView, versionId: string, targetTenant: string): Record<string, unknown> {
|
|
87
|
-
return {
|
|
88
|
-
kind: setting.kind,
|
|
89
|
-
action: "rollback",
|
|
90
|
-
versionId,
|
|
91
|
-
expectedLiveVersionId: setting.liveVersionId,
|
|
92
|
-
...(targetTenant ? { targetTenant } : {}),
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function discardBody(setting: SettingStatusView, targetTenant: string): Record<string, unknown> {
|
|
97
|
-
return {
|
|
98
|
-
kind: setting.kind,
|
|
99
|
-
expectedDraftVersionId: setting.draftVersionId,
|
|
100
|
-
...(targetTenant ? { targetTenant } : {}),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/** What a publish, rollback or discard reports. "Done" only when the server read it back in effect. */
|
|
105
|
-
export function actionResultStatus(
|
|
106
|
-
action: "publish" | "rollback" | "discard",
|
|
107
|
-
httpOk: boolean,
|
|
108
|
-
status: number,
|
|
109
|
-
data: ActionResponse,
|
|
110
|
-
): { message: string; state?: StatusState } {
|
|
111
|
-
if (!httpOk) return { message: data.error || `That didn't work (${status}). Reload and try again.`, state: "err" };
|
|
112
|
-
if (data.readBack === "pending") return { message: data.notice || "Accepted. Reload to confirm it is in effect." };
|
|
113
|
-
if (data.readBack !== "in-effect") return { message: "It could not be confirmed in effect. Reload to check.", state: "err" };
|
|
114
|
-
if (action === "discard") return { message: "Draft discarded. Your preview shows the live value again.", state: "ok" };
|
|
115
|
-
if (action === "rollback") return { message: "Rolled back. Your live store reads the version you picked.", state: "ok" };
|
|
116
|
-
return { message: "Published. Your live store reads it now.", state: "ok" };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function readJson<T>(res: Response): Promise<T> {
|
|
120
|
-
try {
|
|
121
|
-
return (await res.json()) as T;
|
|
122
|
-
} catch {
|
|
123
|
-
return {} as T;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function readSetting(el: HTMLElement): SettingStatusView {
|
|
128
|
-
return {
|
|
129
|
-
kind: el.dataset.kind ?? "",
|
|
130
|
-
draftVersionId: el.dataset.draftVersionId || null,
|
|
131
|
-
liveVersionId: el.dataset.liveVersionId || null,
|
|
132
|
-
pending: el.dataset.pending === "true",
|
|
133
|
-
changes: [],
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Render a status into the block's existing markup: text only, never HTML. */
|
|
138
|
-
export function renderSettingStatus(el: HTMLElement, setting: SettingStatusView): void {
|
|
139
|
-
el.dataset.draftVersionId = setting.draftVersionId ?? "";
|
|
140
|
-
el.dataset.liveVersionId = setting.liveVersionId ?? "";
|
|
141
|
-
el.dataset.pending = setting.pending ? "true" : "false";
|
|
142
|
-
const live = el.querySelector<HTMLElement>("[data-setting-draft-live]");
|
|
143
|
-
const pending = el.querySelector<HTMLElement>("[data-setting-draft-pending]");
|
|
144
|
-
const list = el.querySelector<HTMLElement>("[data-setting-draft-changes]");
|
|
145
|
-
if (live) live.hidden = setting.pending;
|
|
146
|
-
if (pending) pending.hidden = !setting.pending;
|
|
147
|
-
if (list) {
|
|
148
|
-
list.replaceChildren(
|
|
149
|
-
...setting.changes.map((change) => {
|
|
150
|
-
const li = document.createElement("li");
|
|
151
|
-
li.textContent = changeSentence(change);
|
|
152
|
-
return li;
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function mountSettingDraftStatus(el: HTMLElement): void {
|
|
159
|
-
const endpoint = el.dataset.endpoint || "/api/preview/settings-live";
|
|
160
|
-
const targetTenant = el.dataset.targetTenant || "";
|
|
161
|
-
const status = el.querySelector<HTMLElement>("[data-setting-draft-status]");
|
|
162
|
-
const buttons = [...el.querySelectorAll<HTMLButtonElement>("[data-setting-draft-publish], [data-setting-draft-discard]")];
|
|
163
|
-
const setStatus = (message: string, state?: StatusState) => {
|
|
164
|
-
if (!status) return;
|
|
165
|
-
status.textContent = message;
|
|
166
|
-
if (state) status.dataset.state = state;
|
|
167
|
-
else delete status.dataset.state;
|
|
168
|
-
};
|
|
169
|
-
const apply = (data: StatusResponse | undefined) => {
|
|
170
|
-
const next = data?.settings?.find((s) => s.kind === el.dataset.kind);
|
|
171
|
-
if (next) renderSettingStatus(el, next);
|
|
172
|
-
};
|
|
173
|
-
const refresh = async (): Promise<string | null> => {
|
|
174
|
-
try {
|
|
175
|
-
apply(await readStatus(endpoint, targetTenant));
|
|
176
|
-
return null;
|
|
177
|
-
} catch (e) {
|
|
178
|
-
return reasonOf(e);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const act = async (action: "publish" | "discard") => {
|
|
182
|
-
const setting = readSetting(el);
|
|
183
|
-
setStatus(action === "publish" ? "Publishing…" : "Discarding…");
|
|
184
|
-
for (const b of buttons) b.disabled = true;
|
|
185
|
-
try {
|
|
186
|
-
const res = await fetch(endpoint, {
|
|
187
|
-
method: action === "publish" ? "POST" : "DELETE",
|
|
188
|
-
headers: { "content-type": "application/json" },
|
|
189
|
-
body: JSON.stringify(action === "publish" ? publishBody(setting, targetTenant) : discardBody(setting, targetTenant)),
|
|
190
|
-
});
|
|
191
|
-
const data = await readJson<ActionResponse>(res);
|
|
192
|
-
let result = actionResultStatus(action, res.ok, res.status, data);
|
|
193
|
-
if (res.ok) apply(data.settings);
|
|
194
|
-
else result = withStale(result, await refresh());
|
|
195
|
-
setStatus(result.message, result.state);
|
|
196
|
-
if (res.ok) announceSettingChanged(el.dataset.kind ?? "");
|
|
197
|
-
// The form above still shows the discarded draft; reload it onto the value the preview reads now.
|
|
198
|
-
if (res.ok && action === "discard") window.location.reload();
|
|
199
|
-
} catch {
|
|
200
|
-
setStatus("That didn't work — network error", "err");
|
|
201
|
-
} finally {
|
|
202
|
-
for (const b of buttons) b.disabled = false;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
el.querySelector("[data-setting-draft-publish]")?.addEventListener("click", () => void act("publish"));
|
|
206
|
-
el.querySelector("[data-setting-draft-discard]")?.addEventListener("click", () => void act("discard"));
|
|
207
|
-
document.addEventListener(SETTING_SAVED_EVENT, (event) => {
|
|
208
|
-
if ((event as CustomEvent<{ kind?: string }>).detail?.kind !== el.dataset.kind) return;
|
|
209
|
-
void refresh().then((stale) => stale && setStatus(staleMessage(stale), "err"));
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function statusSetter(el: Element | null) {
|
|
214
|
-
return (message: string, state?: StatusState) => {
|
|
215
|
-
if (!(el instanceof HTMLElement)) return;
|
|
216
|
-
el.textContent = message;
|
|
217
|
-
if (state) el.dataset.state = state;
|
|
218
|
-
else delete el.dataset.state;
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const reasonOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
223
|
-
|
|
224
|
-
const staleMessage = (reason: string): string => `Could not refresh the settings status (${reason}). Reload the page before acting on it.`;
|
|
225
|
-
|
|
226
|
-
/** An action's result, told that the status shown beside it could not be refreshed. */
|
|
227
|
-
function withStale(result: { message: string; state?: StatusState }, stale: string | null): { message: string; state?: StatusState } {
|
|
228
|
-
return stale ? { message: `${result.message} ${staleMessage(stale)}`, state: "err" } : result;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/** The settings status; throws with the reason when it cannot be read. */
|
|
232
|
-
export async function readStatus(endpoint: string, targetTenant: string): Promise<StatusResponse> {
|
|
233
|
-
const query = targetTenant ? `?targetTenant=${encodeURIComponent(targetTenant)}` : "";
|
|
234
|
-
const res = await fetch(`${endpoint}${query}`, { headers: { accept: "application/json" } });
|
|
235
|
-
const data = await readJson<StatusResponse & { error?: string }>(res);
|
|
236
|
-
if (!res.ok || !Array.isArray(data.settings)) throw new Error(data.error ?? `HTTP ${res.status}`);
|
|
237
|
-
return data;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** Render the Publish tab's pending list and rollback pickers: text only, never HTML. */
|
|
241
|
-
export function renderSettingsGoLive(el: HTMLElement, status: StatusResponse): void {
|
|
242
|
-
const settings = status.settings ?? [];
|
|
243
|
-
const pending = settings.filter((s) => s.pending);
|
|
244
|
-
const list = el.querySelector<HTMLElement>("[data-settings-go-live-list]");
|
|
245
|
-
const none = el.querySelector<HTMLElement>("[data-settings-go-live-none]");
|
|
246
|
-
const publish = el.querySelector<HTMLButtonElement>("[data-settings-go-live-publish]");
|
|
247
|
-
if (list) {
|
|
248
|
-
list.replaceChildren(
|
|
249
|
-
...pending.map((setting) => {
|
|
250
|
-
const li = document.createElement("li");
|
|
251
|
-
li.dataset.settingsPin = "";
|
|
252
|
-
li.dataset.kind = setting.kind;
|
|
253
|
-
li.dataset.settingsPath = setting.path ?? "";
|
|
254
|
-
li.dataset.draftVersionId = setting.draftVersionId ?? "";
|
|
255
|
-
li.dataset.liveVersionId = setting.liveVersionId ?? "";
|
|
256
|
-
const title = document.createElement("b");
|
|
257
|
-
title.textContent = setting.title ?? setting.kind;
|
|
258
|
-
const changes = document.createElement("ul");
|
|
259
|
-
changes.replaceChildren(
|
|
260
|
-
...setting.changes.map((change) => {
|
|
261
|
-
const item = document.createElement("li");
|
|
262
|
-
item.textContent = changeSentence(change);
|
|
263
|
-
return item;
|
|
264
|
-
}),
|
|
265
|
-
);
|
|
266
|
-
li.append(title, changes);
|
|
267
|
-
return li;
|
|
268
|
-
}),
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
if (none) none.hidden = pending.length > 0;
|
|
272
|
-
if (publish) publish.hidden = pending.length === 0;
|
|
273
|
-
for (const row of el.querySelectorAll<HTMLElement>("[data-settings-rollback]")) {
|
|
274
|
-
const setting = settings.find((s) => s.kind === row.dataset.kind);
|
|
275
|
-
const select = row.querySelector<HTMLSelectElement>("select");
|
|
276
|
-
row.dataset.liveVersionId = setting?.liveVersionId ?? "";
|
|
277
|
-
const history = setting?.history ?? [];
|
|
278
|
-
row.hidden = history.length === 0;
|
|
279
|
-
if (select) {
|
|
280
|
-
select.replaceChildren(
|
|
281
|
-
...history.map((entry) => {
|
|
282
|
-
const option = document.createElement("option");
|
|
283
|
-
option.value = entry.versionId;
|
|
284
|
-
option.textContent = historyLabel(entry);
|
|
285
|
-
return option;
|
|
286
|
-
}),
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/** The Publish tab's "Settings waiting to go live" block. */
|
|
293
|
-
export function mountSettingsGoLive(el: HTMLElement): void {
|
|
294
|
-
const endpoint = el.dataset.endpoint || "/api/preview/settings-live";
|
|
295
|
-
const targetTenant = el.dataset.targetTenant || "";
|
|
296
|
-
const setStatus = statusSetter(el.querySelector("[data-settings-go-live-status]"));
|
|
297
|
-
const buttons = () => [...el.querySelectorAll<HTMLButtonElement>("button")];
|
|
298
|
-
const refresh = async (): Promise<string | null> => {
|
|
299
|
-
try {
|
|
300
|
-
renderSettingsGoLive(el, await readStatus(endpoint, targetTenant));
|
|
301
|
-
return null;
|
|
302
|
-
} catch (e) {
|
|
303
|
-
return reasonOf(e);
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
const post = async (body: Record<string, unknown>) => {
|
|
307
|
-
const res = await fetch(endpoint, {
|
|
308
|
-
method: "POST",
|
|
309
|
-
headers: { "content-type": "application/json" },
|
|
310
|
-
body: JSON.stringify(body),
|
|
311
|
-
});
|
|
312
|
-
return { res, data: await readJson<ActionResponse>(res) };
|
|
313
|
-
};
|
|
314
|
-
const run = async (work: () => Promise<{ message: string; state?: StatusState }>) => {
|
|
315
|
-
for (const b of buttons()) b.disabled = true;
|
|
316
|
-
let result: { message: string; state?: StatusState };
|
|
317
|
-
try {
|
|
318
|
-
result = await work();
|
|
319
|
-
} catch {
|
|
320
|
-
result = { message: "That didn't work — network error", state: "err" };
|
|
321
|
-
}
|
|
322
|
-
const shown = withStale(result, await refresh());
|
|
323
|
-
setStatus(shown.message, shown.state);
|
|
324
|
-
for (const b of buttons()) b.disabled = false;
|
|
325
|
-
for (const row of el.querySelectorAll<HTMLElement>("[data-settings-rollback]")) announceSettingChanged(row.dataset.kind ?? "");
|
|
326
|
-
};
|
|
327
|
-
el.querySelector("[data-settings-go-live-publish]")?.addEventListener("click", () =>
|
|
328
|
-
void run(async () => {
|
|
329
|
-
// Exactly the drafts this block shows; each is CAS against the live value shown beside it.
|
|
330
|
-
const pins = [...el.querySelectorAll<HTMLElement>("[data-settings-pin]")];
|
|
331
|
-
setStatus("Publishing settings…");
|
|
332
|
-
let last: { message: string; state?: StatusState } = { message: "Nothing to publish." };
|
|
333
|
-
for (const pin of pins) {
|
|
334
|
-
const setting: SettingStatusView = {
|
|
335
|
-
kind: pin.dataset.kind ?? "",
|
|
336
|
-
draftVersionId: pin.dataset.draftVersionId || null,
|
|
337
|
-
liveVersionId: pin.dataset.liveVersionId || null,
|
|
338
|
-
pending: true,
|
|
339
|
-
changes: [],
|
|
340
|
-
};
|
|
341
|
-
const { res, data } = await post(publishBody(setting, targetTenant));
|
|
342
|
-
last = actionResultStatus("publish", res.ok, res.status, data);
|
|
343
|
-
if (last.state !== "ok") return last;
|
|
344
|
-
}
|
|
345
|
-
return pins.length > 1 ? { message: "Published. Your live store reads these settings now.", state: "ok" } : last;
|
|
346
|
-
}),
|
|
347
|
-
);
|
|
348
|
-
for (const row of el.querySelectorAll<HTMLElement>("[data-settings-rollback]")) {
|
|
349
|
-
row.querySelector("[data-settings-rollback-apply]")?.addEventListener("click", () =>
|
|
350
|
-
void run(async () => {
|
|
351
|
-
const versionId = row.querySelector<HTMLSelectElement>("select")?.value;
|
|
352
|
-
if (!versionId) return { message: "Pick a version to roll back to.", state: "err" };
|
|
353
|
-
setStatus("Rolling back…");
|
|
354
|
-
const setting: SettingStatusView = {
|
|
355
|
-
kind: row.dataset.kind ?? "",
|
|
356
|
-
draftVersionId: null,
|
|
357
|
-
liveVersionId: row.dataset.liveVersionId || null,
|
|
358
|
-
pending: false,
|
|
359
|
-
changes: [],
|
|
360
|
-
};
|
|
361
|
-
const { res, data } = await post(rollbackBody(setting, versionId, targetTenant));
|
|
362
|
-
return actionResultStatus("rollback", res.ok, res.status, data);
|
|
363
|
-
}),
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
document.addEventListener(SETTING_SAVED_EVENT, () => void refresh().then((stale) => stale && setStatus(staleMessage(stale), "err")));
|
|
367
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed checkout settings model — the admin "Cart & Checkout appearance" section.
|
|
3
|
-
*
|
|
4
|
-
* Mirrors the settings surface that the commerce service actually manages, and
|
|
5
|
-
* defines how each field is PREPOPULATED from the tenant's theme (the
|
|
6
|
-
* style-guide), OVERRIDDEN, and RESET.
|
|
7
|
-
*
|
|
8
|
-
* The remote settings are three groups:
|
|
9
|
-
* 1. `colors` — provider-native brand colors (primary/secondary/tertiary +
|
|
10
|
-
* usage), applied via the hosted checkout theme.
|
|
11
|
-
* 2. `templates`— per-template-type `contentUrl` pointers (checkout / cart /
|
|
12
|
-
* cart_include[drawer] / receipt / email), set and refreshed
|
|
13
|
-
* through the commerce service.
|
|
14
|
-
* The colors/fonts/logo live INSIDE the hosted template file.
|
|
15
|
-
* 3. `store` — storeSubDomain + the age/ID verification loader toggle.
|
|
16
|
-
* Non-visual; no theme default.
|
|
17
|
-
*
|
|
18
|
-
* Prepopulation lands on the parts with a theme default — the brand colors and
|
|
19
|
-
* the template pointers (defaulted to a ToT-hosted, theme-derived template URL).
|
|
20
|
-
* The feature toggles are mirrored as plain config (no default → not resettable).
|
|
21
|
-
*
|
|
22
|
-
* The ACTUAL persistence — PATCHing provider colors + PUT/refresh of template
|
|
23
|
-
* URLs — is the commerce-service seam, intentionally NOT wired here; this module
|
|
24
|
-
* is the pure model the admin renders and edits.
|
|
25
|
-
*/
|
|
26
|
-
import type { ResolvedManagedCheckout, ThemeTokens } from "@tot/public-runtime";
|
|
27
|
-
|
|
28
|
-
/** Checkout template types exposed by the commerce service. */
|
|
29
|
-
export type CheckoutTemplateType =
|
|
30
|
-
| "checkout"
|
|
31
|
-
| "cart"
|
|
32
|
-
| "cart_include"
|
|
33
|
-
| "receipt"
|
|
34
|
-
| "email";
|
|
35
|
-
|
|
36
|
-
export const CHECKOUT_TEMPLATE_TYPES: readonly CheckoutTemplateType[] = [
|
|
37
|
-
"checkout",
|
|
38
|
-
"cart",
|
|
39
|
-
"cart_include",
|
|
40
|
-
"receipt",
|
|
41
|
-
"email",
|
|
42
|
-
] as const;
|
|
43
|
-
|
|
44
|
-
export const CHECKOUT_TEMPLATE_LABELS: Record<CheckoutTemplateType, string> = {
|
|
45
|
-
checkout: "Checkout page",
|
|
46
|
-
cart: "Full cart page",
|
|
47
|
-
cart_include: "Cart drawer (slide-out)",
|
|
48
|
-
receipt: "Receipt page",
|
|
49
|
-
email: "Order email",
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** Hosted checkout brand-color fields. */
|
|
53
|
-
export interface CheckoutBrandColors {
|
|
54
|
-
primary: string;
|
|
55
|
-
secondary: string;
|
|
56
|
-
tertiary: string;
|
|
57
|
-
/** How broadly the colors apply. "none" keeps the provider default look. */
|
|
58
|
-
usage: "none" | "all";
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** A per-template-type pointer managed by the commerce service. */
|
|
62
|
-
export interface CheckoutTemplatePointer {
|
|
63
|
-
contentUrl: string;
|
|
64
|
-
templateSet: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Store + loader feature config. Non-visual. */
|
|
68
|
-
export interface CheckoutStoreConfig {
|
|
69
|
-
storeSubDomain: string;
|
|
70
|
-
verificationEnabled: boolean;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** The full checkout settings mirror. */
|
|
74
|
-
export interface CheckoutSettings {
|
|
75
|
-
colors: CheckoutBrandColors;
|
|
76
|
-
templates: Record<CheckoutTemplateType, CheckoutTemplatePointer>;
|
|
77
|
-
store: CheckoutStoreConfig;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** Overrides are a deep-partial of the mirror; anything unset falls back to the
|
|
81
|
-
* theme-derived default. Reset === delete the key here. */
|
|
82
|
-
export type CheckoutSettingsOverrides = {
|
|
83
|
-
colors?: Partial<CheckoutBrandColors>;
|
|
84
|
-
templates?: Partial<Record<CheckoutTemplateType, Partial<CheckoutTemplatePointer>>>;
|
|
85
|
-
store?: Partial<CheckoutStoreConfig>;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// ---------------------------------------------------------------------------
|
|
89
|
-
// Prepopulation: theme (style-guide) → checkout settings defaults.
|
|
90
|
-
// ---------------------------------------------------------------------------
|
|
91
|
-
|
|
92
|
-
export interface DeriveOptions {
|
|
93
|
-
/**
|
|
94
|
-
* Absolute origin the ToT-hosted, theme-derived templates are served from —
|
|
95
|
-
* the tenant's own storefront origin (e.g. `https://sample-store.example`). Templates
|
|
96
|
-
* live at `${originBase}/checkout-templates/<type>.html`.
|
|
97
|
-
*/
|
|
98
|
-
originBase: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Build the theme-derived DEFAULTS. This is the "prepopulate from the style-guide"
|
|
103
|
-
* step: brand colors come straight from the theme tokens; each template pointer
|
|
104
|
-
* defaults to a stable ToT-hosted URL for that tenant's theme-derived template.
|
|
105
|
-
*/
|
|
106
|
-
export function deriveCheckoutSettings(
|
|
107
|
-
theme: ThemeTokens,
|
|
108
|
-
commerce: ResolvedManagedCheckout | null,
|
|
109
|
-
opts: DeriveOptions,
|
|
110
|
-
): CheckoutSettings {
|
|
111
|
-
const base = opts.originBase.replace(/\/$/, "");
|
|
112
|
-
const templateUrl = (type: CheckoutTemplateType) =>
|
|
113
|
-
`${base}/checkout-templates/${type}.html`;
|
|
114
|
-
|
|
115
|
-
const templates = Object.fromEntries(
|
|
116
|
-
CHECKOUT_TEMPLATE_TYPES.map((type) => [
|
|
117
|
-
type,
|
|
118
|
-
{ contentUrl: templateUrl(type), templateSet: "DEFAULT" },
|
|
119
|
-
]),
|
|
120
|
-
) as Record<CheckoutTemplateType, CheckoutTemplatePointer>;
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
colors: {
|
|
124
|
-
// Checkout primary/secondary/tertiary ← the tenant's brand tokens.
|
|
125
|
-
primary: theme.color.primary,
|
|
126
|
-
secondary: theme.color.accent,
|
|
127
|
-
tertiary: theme.color.sale,
|
|
128
|
-
usage: "all",
|
|
129
|
-
},
|
|
130
|
-
templates,
|
|
131
|
-
store: {
|
|
132
|
-
storeSubDomain: commerce?.storeSubDomain ?? "",
|
|
133
|
-
// Feature toggles have no theme default — start off; not prepopulatable.
|
|
134
|
-
verificationEnabled: false,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// ---------------------------------------------------------------------------
|
|
140
|
-
// Resolve with provenance: defaults + overrides → renderable field descriptors.
|
|
141
|
-
// ---------------------------------------------------------------------------
|
|
142
|
-
|
|
143
|
-
export type CheckoutFieldKind = "color" | "url" | "text" | "boolean" | "select";
|
|
144
|
-
export type CheckoutFieldGroup = "colors" | "templates" | "store";
|
|
145
|
-
|
|
146
|
-
/** One renderable settings row: resolved value + provenance + reset affordance. */
|
|
147
|
-
export interface CheckoutSettingsField {
|
|
148
|
-
group: CheckoutFieldGroup;
|
|
149
|
-
/** Dot path into CheckoutSettings, e.g. "colors.primary" / "templates.checkout.contentUrl". */
|
|
150
|
-
key: string;
|
|
151
|
-
label: string;
|
|
152
|
-
kind: CheckoutFieldKind;
|
|
153
|
-
value: string | boolean;
|
|
154
|
-
/** The theme-derived default; undefined when the field has no theme default. */
|
|
155
|
-
default?: string | boolean;
|
|
156
|
-
source: "theme" | "override";
|
|
157
|
-
/** True when there is a theme default to reset back to. */
|
|
158
|
-
resettable: boolean;
|
|
159
|
-
options?: string[];
|
|
160
|
-
help?: string;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function readPath(obj: unknown, path: string): unknown {
|
|
164
|
-
return path.split(".").reduce<unknown>((o, k) => {
|
|
165
|
-
if (o && typeof o === "object" && k in (o as Record<string, unknown>)) {
|
|
166
|
-
return (o as Record<string, unknown>)[k];
|
|
167
|
-
}
|
|
168
|
-
return undefined;
|
|
169
|
-
}, obj);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Merge defaults + overrides into the flat field list the admin renders. Each
|
|
174
|
-
* field's `source` is "override" when the overrides object supplies that exact
|
|
175
|
-
* path, else "theme". `resettable` marks fields with a real theme default (the
|
|
176
|
-
* visual ones) so the UI can show/hide the "Reset to theme" control.
|
|
177
|
-
*/
|
|
178
|
-
export function buildCheckoutSettingsFields(
|
|
179
|
-
defaults: CheckoutSettings,
|
|
180
|
-
overrides: CheckoutSettingsOverrides,
|
|
181
|
-
): CheckoutSettingsField[] {
|
|
182
|
-
const field = (
|
|
183
|
-
group: CheckoutFieldGroup,
|
|
184
|
-
key: string,
|
|
185
|
-
label: string,
|
|
186
|
-
kind: CheckoutFieldKind,
|
|
187
|
-
opts: { resettable?: boolean; options?: string[]; help?: string } = {},
|
|
188
|
-
): CheckoutSettingsField => {
|
|
189
|
-
const def = readPath(defaults, key);
|
|
190
|
-
const ov = readPath(overrides, key);
|
|
191
|
-
const overridden = ov !== undefined;
|
|
192
|
-
const resettable = opts.resettable ?? true;
|
|
193
|
-
return {
|
|
194
|
-
group,
|
|
195
|
-
key,
|
|
196
|
-
label,
|
|
197
|
-
kind,
|
|
198
|
-
value: (overridden ? ov : def) as string | boolean,
|
|
199
|
-
default: resettable ? (def as string | boolean) : undefined,
|
|
200
|
-
source: overridden ? "override" : "theme",
|
|
201
|
-
resettable,
|
|
202
|
-
options: opts.options,
|
|
203
|
-
help: opts.help,
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const fields: CheckoutSettingsField[] = [
|
|
208
|
-
// Group 1 — brand colors (theme-derived; the "make it look bigd" surface).
|
|
209
|
-
field("colors", "colors.primary", "Primary color", "color", {
|
|
210
|
-
help: "Checkout/cart primary buttons and accents. From --color-primary.",
|
|
211
|
-
}),
|
|
212
|
-
field("colors", "colors.secondary", "Secondary color", "color", {
|
|
213
|
-
help: "Secondary accents. From --color-accent.",
|
|
214
|
-
}),
|
|
215
|
-
field("colors", "colors.tertiary", "Tertiary color", "color", {
|
|
216
|
-
help: "Sale/clearance accent. From --color-sale.",
|
|
217
|
-
}),
|
|
218
|
-
field("colors", "colors.usage", "Apply brand colors", "select", {
|
|
219
|
-
options: ["all", "none"],
|
|
220
|
-
help: '"all" applies the brand palette to hosted checkout; "none" keeps checkout defaults.',
|
|
221
|
-
}),
|
|
222
|
-
];
|
|
223
|
-
|
|
224
|
-
// Group 2 — template pointers (default = ToT-hosted theme-derived template).
|
|
225
|
-
for (const type of CHECKOUT_TEMPLATE_TYPES) {
|
|
226
|
-
fields.push(
|
|
227
|
-
field("templates", `templates.${type}.contentUrl`, CHECKOUT_TEMPLATE_LABELS[type], "url", {
|
|
228
|
-
help: `Hosted template URL for the ${CHECKOUT_TEMPLATE_LABELS[type].toLowerCase()}. Defaults to the ToT theme-derived template; override with a custom URL.`,
|
|
229
|
-
}),
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// Group 3 — store/feature config (no theme default → not resettable).
|
|
234
|
-
fields.push(
|
|
235
|
-
field("store", "store.storeSubDomain", "Checkout store subdomain", "text", {
|
|
236
|
-
resettable: false,
|
|
237
|
-
help: "Internal checkout store identifier for this tenant.",
|
|
238
|
-
}),
|
|
239
|
-
field("store", "store.verificationEnabled", "Age / identity verification", "boolean", {
|
|
240
|
-
resettable: false,
|
|
241
|
-
help: "Token of Trust verification at checkout.",
|
|
242
|
-
}),
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
return fields;
|
|
246
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock service for the admin "Cart & Checkout appearance" section. Resolves the
|
|
3
|
-
* TARGET tenant's theme (the style-guide) and any saved overrides into the flat
|
|
4
|
-
* field list the panel renders — so each row shows its theme default, current
|
|
5
|
-
* value, provenance (theme vs override), and a reset affordance.
|
|
6
|
-
*
|
|
7
|
-
* The target tenant's config is INJECTED by the panel boundary (resolved through
|
|
8
|
-
* the `TenantResolver` seam via `config/adminTargetTenant`), never looked up from
|
|
9
|
-
* the static tenant map here: `lib/**` stays behind the `tenancy-resolver-fence`
|
|
10
|
-
* so a single-tenant extraction stays a drop-in. A null tenant (or one with no
|
|
11
|
-
* checkout store) renders the panel's inert "no store" state.
|
|
12
|
-
*
|
|
13
|
-
* Overrides are read from a mock store here (no live persistence yet — the save
|
|
14
|
-
* hop is the commerce service's theme PUT/refresh seam). One example override is
|
|
15
|
-
* seeded so the panel demonstrates the theme/override/reset states without a backend.
|
|
16
|
-
*/
|
|
17
|
-
import { resolveManagedCheckout } from "@tot/public-runtime";
|
|
18
|
-
import type { TenantConfig } from "@tot/public-runtime";
|
|
19
|
-
import { referenceTheme } from "@/themes/reference";
|
|
20
|
-
import { mergeTheme } from "@/themes/schema";
|
|
21
|
-
import type { AdminTenantEnvelope } from "../../access/admin/envelope";
|
|
22
|
-
import {
|
|
23
|
-
buildCheckoutSettingsFields,
|
|
24
|
-
deriveCheckoutSettings,
|
|
25
|
-
type CheckoutSettingsOverrides,
|
|
26
|
-
type CheckoutSettingsField,
|
|
27
|
-
} from "@/lib/checkout/commerce/checkoutSettings";
|
|
28
|
-
|
|
29
|
-
export interface CheckoutSettingsViewModel {
|
|
30
|
-
targetTenant: string;
|
|
31
|
-
/** True when the tenant has a checkout store (else the section is inert). */
|
|
32
|
-
hasStore: boolean;
|
|
33
|
-
fields: CheckoutSettingsField[];
|
|
34
|
-
overrideCount: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Mock override store. Keyed by tenant id. Seeded with one override for the
|
|
39
|
-
* generic sample tenant so the panel shows a mixed theme/override state out of
|
|
40
|
-
* the box. Real overrides would come from the tenant's saved cart settings.
|
|
41
|
-
*/
|
|
42
|
-
const MOCK_OVERRIDES: Record<string, CheckoutSettingsOverrides> = {
|
|
43
|
-
"sample-store.example": {
|
|
44
|
-
// Example: the merchant pinned a custom tertiary accent, overriding the
|
|
45
|
-
// theme's --color-sale default — the panel renders this row as "Overridden"
|
|
46
|
-
// with a Reset control.
|
|
47
|
-
colors: { tertiary: "#e11d48" },
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Build the checkout appearance view model from the resolved TARGET tenant
|
|
53
|
-
* config. `tenant` is the target's resolved `TenantConfig` (or null when no
|
|
54
|
-
* tenant claims the id) — resolved by the caller through the resolver seam.
|
|
55
|
-
*/
|
|
56
|
-
export function getCheckoutSettingsViewModel(
|
|
57
|
-
envelope: AdminTenantEnvelope,
|
|
58
|
-
tenant: TenantConfig | null,
|
|
59
|
-
): CheckoutSettingsViewModel {
|
|
60
|
-
const { targetTenant } = envelope;
|
|
61
|
-
const checkout = tenant?.commerce?.checkout ?? null;
|
|
62
|
-
|
|
63
|
-
if (!tenant || !checkout) {
|
|
64
|
-
return { targetTenant, hasStore: false, fields: [], overrideCount: 0 };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const theme = mergeTheme(referenceTheme, tenant.theme_tokens);
|
|
68
|
-
const commerce = resolveManagedCheckout(checkout);
|
|
69
|
-
const defaults = deriveCheckoutSettings(theme, commerce, {
|
|
70
|
-
originBase: `https://${targetTenant}`,
|
|
71
|
-
});
|
|
72
|
-
const overrides = MOCK_OVERRIDES[targetTenant] ?? {};
|
|
73
|
-
const fields = buildCheckoutSettingsFields(defaults, overrides);
|
|
74
|
-
const overrideCount = fields.filter((f) => f.source === "override").length;
|
|
75
|
-
|
|
76
|
-
return { targetTenant, hasStore: true, fields, overrideCount };
|
|
77
|
-
}
|