@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,1071 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Daily batch desk. Queues, evidence, and commands are a pure projection of the
|
|
3
|
-
* commerce contract. Print payload and tracking links are owner-only. Public
|
|
4
|
-
* events and the desk log never carry a destination.
|
|
5
|
-
*/
|
|
6
|
-
import {
|
|
7
|
-
actorMayCommand,
|
|
8
|
-
admitTrackingRead,
|
|
9
|
-
decideCommerceCommand,
|
|
10
|
-
paginateOrders,
|
|
11
|
-
publicCommerceEvent,
|
|
12
|
-
readOwnerAddress,
|
|
13
|
-
type CommerceActor,
|
|
14
|
-
type CommerceEvidence,
|
|
15
|
-
type CommerceStage,
|
|
16
|
-
type ComplianceState,
|
|
17
|
-
type FulfillmentState,
|
|
18
|
-
type LabelState,
|
|
19
|
-
type PaymentState,
|
|
20
|
-
type ProviderOutcome,
|
|
21
|
-
type PublicCommerceEvent,
|
|
22
|
-
type StockState,
|
|
23
|
-
} from "@tot/public-runtime";
|
|
24
|
-
import { trackingHostsFor } from "../../carrierEvidence.js";
|
|
25
|
-
|
|
26
|
-
export const SCRAPPY_FULFILLMENT_PATH = "/scrappy-fulfillment";
|
|
27
|
-
export const WORKSPACE_PAGE_LIMIT = 4;
|
|
28
|
-
export const TEST_ADAPTER_QUOTE_MINOR = 640;
|
|
29
|
-
|
|
30
|
-
export const WORKSPACE_QUEUES = ["ready", "held", "in_progress", "shipped"] as const;
|
|
31
|
-
export type WorkspaceQueue = (typeof WORKSPACE_QUEUES)[number];
|
|
32
|
-
export type WorkspaceQueueFilter = WorkspaceQueue | "all";
|
|
33
|
-
|
|
34
|
-
export const WORKSPACE_EXCEPTIONS = [
|
|
35
|
-
"carrier-outage",
|
|
36
|
-
"refund-stop",
|
|
37
|
-
"unreadable-destination",
|
|
38
|
-
"other",
|
|
39
|
-
] as const;
|
|
40
|
-
export type WorkspaceException = (typeof WORKSPACE_EXCEPTIONS)[number];
|
|
41
|
-
|
|
42
|
-
export const QUEUE_LABEL: Record<WorkspaceQueue, string> = {
|
|
43
|
-
ready: "Ready",
|
|
44
|
-
held: "Held",
|
|
45
|
-
in_progress: "In progress",
|
|
46
|
-
shipped: "Shipped",
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const ACTOR_SPECS = [
|
|
50
|
-
{ name: "owner", role: "owner" as const, sameTenant: true, sameStage: true },
|
|
51
|
-
{ name: "caller", role: "caller" as const, sameTenant: true, sameStage: true },
|
|
52
|
-
{ name: "denied", role: "denied" as const, sameTenant: true, sameStage: true },
|
|
53
|
-
{ name: "other-tenant", role: "owner" as const, sameTenant: false, sameStage: true },
|
|
54
|
-
{ name: "wrong-stage", role: "owner" as const, sameTenant: true, sameStage: false },
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
const FRESH: CommerceEvidence = {
|
|
58
|
-
verification: "fresh",
|
|
59
|
-
tax: "fresh",
|
|
60
|
-
risk: "fresh",
|
|
61
|
-
stock: "fresh",
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const STALE: CommerceEvidence = {
|
|
65
|
-
verification: "UNKNOWN",
|
|
66
|
-
tax: "stale",
|
|
67
|
-
risk: "unreadable",
|
|
68
|
-
stock: "UNKNOWN",
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const TOTALS = { subtotalMinor: 4000, shippingMinor: 0, taxMinor: 0, totalMinor: 4000 } as const;
|
|
72
|
-
|
|
73
|
-
type PurchaseScript = "admit" | "pending" | "unknown";
|
|
74
|
-
type VoidScript = "approved" | "pending" | "denied";
|
|
75
|
-
type SignatureScript = "accept" | "refuse";
|
|
76
|
-
|
|
77
|
-
export interface WorkspaceLine {
|
|
78
|
-
sku: string;
|
|
79
|
-
quantity: number;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface WorkspaceOrder {
|
|
83
|
-
id: string;
|
|
84
|
-
placedAt: string;
|
|
85
|
-
lines: WorkspaceLine[];
|
|
86
|
-
currency: "USD";
|
|
87
|
-
payment: PaymentState;
|
|
88
|
-
compliance: ComplianceState;
|
|
89
|
-
stock: StockState;
|
|
90
|
-
fulfillment: FulfillmentState;
|
|
91
|
-
label: LabelState;
|
|
92
|
-
providerOutcome: ProviderOutcome | null;
|
|
93
|
-
evidence: CommerceEvidence;
|
|
94
|
-
picked: boolean;
|
|
95
|
-
packed: boolean;
|
|
96
|
-
manualException: WorkspaceException | null;
|
|
97
|
-
adultSignature: "required" | "accepted" | "refused";
|
|
98
|
-
purchaseKey: string | null;
|
|
99
|
-
purchaseId: string | null;
|
|
100
|
-
labelCostMinor: number | null;
|
|
101
|
-
carrier: string | null;
|
|
102
|
-
trackingNumber: string | null;
|
|
103
|
-
trackingUrl: string | null;
|
|
104
|
-
ownerDestination: string;
|
|
105
|
-
purchaseScript: PurchaseScript;
|
|
106
|
-
voidScript: VoidScript;
|
|
107
|
-
signatureScript: SignatureScript;
|
|
108
|
-
slipIssued: boolean;
|
|
109
|
-
results: WorkspaceResult[];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export interface WorkspaceResult {
|
|
113
|
-
orderId: string;
|
|
114
|
-
command: string;
|
|
115
|
-
status: "admitted" | "pending" | "unknown" | "refused";
|
|
116
|
-
reason: string;
|
|
117
|
-
livePurchase: false;
|
|
118
|
-
purchaseId: string | null;
|
|
119
|
-
costMinor: number | null;
|
|
120
|
-
releaseReservation: boolean;
|
|
121
|
-
restock: false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface WorkspaceState {
|
|
125
|
-
tenantId: string;
|
|
126
|
-
stage: CommerceStage;
|
|
127
|
-
carrierAccountConfigured: boolean;
|
|
128
|
-
prohibitedCarriers: readonly ["USPS"];
|
|
129
|
-
adultSignatureRequired: true;
|
|
130
|
-
livePurchase: false;
|
|
131
|
-
currency: "USD";
|
|
132
|
-
quoteMinor: number;
|
|
133
|
-
orders: WorkspaceOrder[];
|
|
134
|
-
events: PublicCommerceEvent[];
|
|
135
|
-
log: string[];
|
|
136
|
-
lastResults: WorkspaceResult[];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface WorkspaceQuery {
|
|
140
|
-
actorName: string;
|
|
141
|
-
queue: WorkspaceQueueFilter;
|
|
142
|
-
q: string;
|
|
143
|
-
cursor: string | null;
|
|
144
|
-
limit: number;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface OwnerPrintPayload {
|
|
148
|
-
purchaseId: string;
|
|
149
|
-
format: "pdf";
|
|
150
|
-
adultSignature: "required";
|
|
151
|
-
livePurchase: false;
|
|
152
|
-
destination: string;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface PackingSlip {
|
|
156
|
-
orderId: string;
|
|
157
|
-
lines: WorkspaceLine[];
|
|
158
|
-
wholeOrder: true;
|
|
159
|
-
destination: string | null;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export interface WorkspaceOrderView {
|
|
163
|
-
id: string;
|
|
164
|
-
placedAt: string;
|
|
165
|
-
lines: WorkspaceLine[];
|
|
166
|
-
unitCount: number;
|
|
167
|
-
currency: "USD";
|
|
168
|
-
payment: PaymentState;
|
|
169
|
-
stock: StockState;
|
|
170
|
-
fulfillment: FulfillmentState;
|
|
171
|
-
label: LabelState;
|
|
172
|
-
providerOutcome: ProviderOutcome | null;
|
|
173
|
-
evidence: CommerceEvidence;
|
|
174
|
-
picked: boolean;
|
|
175
|
-
packed: boolean;
|
|
176
|
-
manualException: WorkspaceException | null;
|
|
177
|
-
adultSignature: "required" | "accepted" | "refused";
|
|
178
|
-
purchaseKey: string | null;
|
|
179
|
-
purchaseId: string | null;
|
|
180
|
-
labelCostMinor: number | null;
|
|
181
|
-
trackingNumber: string | null;
|
|
182
|
-
trackingUrl: string | null;
|
|
183
|
-
queue: WorkspaceQueue;
|
|
184
|
-
holdReasons: string[];
|
|
185
|
-
results: WorkspaceResult[];
|
|
186
|
-
slip: PackingSlip | null;
|
|
187
|
-
printPayload: OwnerPrintPayload | null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface FulfillmentViewModel {
|
|
191
|
-
targetTenant: string;
|
|
192
|
-
stage: CommerceStage;
|
|
193
|
-
actorName: string;
|
|
194
|
-
actorRole: CommerceActor["role"];
|
|
195
|
-
livePurchase: false;
|
|
196
|
-
carrierAccountConfigured: boolean;
|
|
197
|
-
prohibitedCarriers: readonly ["USPS"];
|
|
198
|
-
adultSignatureRequired: true;
|
|
199
|
-
quoteMinor: number;
|
|
200
|
-
currency: "USD";
|
|
201
|
-
queue: WorkspaceQueueFilter;
|
|
202
|
-
q: string;
|
|
203
|
-
limit: number;
|
|
204
|
-
cursor: string | null;
|
|
205
|
-
nextCursor: string | null;
|
|
206
|
-
invalidCursor: boolean;
|
|
207
|
-
storewide: Record<WorkspaceQueue, number>;
|
|
208
|
-
filterCount: number;
|
|
209
|
-
pageCount: number;
|
|
210
|
-
orders: WorkspaceOrderView[];
|
|
211
|
-
pickList: Array<{ orderId: string; sku: string; quantity: number; packed: boolean }>;
|
|
212
|
-
events: PublicCommerceEvent[];
|
|
213
|
-
log: string[];
|
|
214
|
-
lastResults: WorkspaceResult[];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export interface WorkspaceCommand {
|
|
218
|
-
actorName: string;
|
|
219
|
-
command: string;
|
|
220
|
-
orderIds: string[];
|
|
221
|
-
purchaseKey: string | null;
|
|
222
|
-
carrier: string | null;
|
|
223
|
-
quantity: number | null;
|
|
224
|
-
quantityInvalid: boolean;
|
|
225
|
-
lineId: boolean;
|
|
226
|
-
exception: string | null;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export function defaultWorkspaceQuery(): WorkspaceQuery {
|
|
230
|
-
return {
|
|
231
|
-
actorName: "owner",
|
|
232
|
-
queue: "ready",
|
|
233
|
-
q: "",
|
|
234
|
-
cursor: null,
|
|
235
|
-
limit: WORKSPACE_PAGE_LIMIT,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function workspaceActor(tenantId: string, stage: CommerceStage, name: string): CommerceActor {
|
|
240
|
-
const known = ACTOR_SPECS.find((spec) => spec.name === name);
|
|
241
|
-
if (!known) return { role: "denied", tenantId, stage };
|
|
242
|
-
return {
|
|
243
|
-
role: known.role,
|
|
244
|
-
tenantId: known.sameTenant ? tenantId : `${tenantId}-b`,
|
|
245
|
-
stage: known.sameStage ? stage : stage === "preview" ? "publication" : "preview",
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function holdReasons(order: {
|
|
250
|
-
fulfillment: FulfillmentState;
|
|
251
|
-
manualException: WorkspaceException | null;
|
|
252
|
-
adultSignature: "required" | "accepted" | "refused";
|
|
253
|
-
evidence: CommerceEvidence;
|
|
254
|
-
payment: PaymentState;
|
|
255
|
-
stock: StockState;
|
|
256
|
-
label: LabelState;
|
|
257
|
-
providerOutcome: ProviderOutcome | null;
|
|
258
|
-
}): string[] {
|
|
259
|
-
if (order.fulfillment === "handed_off") return [];
|
|
260
|
-
const reasons: string[] = [];
|
|
261
|
-
if (order.fulfillment === "cancelled") reasons.push("Cancelled. The shipment is the whole order.");
|
|
262
|
-
if (order.fulfillment === "held") reasons.push("Fulfillment is held.");
|
|
263
|
-
if (order.fulfillment === "UNKNOWN") reasons.push("Fulfillment is unknown. Reconcile before shipping.");
|
|
264
|
-
if (order.manualException) reasons.push(`Manual exception: ${order.manualException}.`);
|
|
265
|
-
if (order.adultSignature === "refused") reasons.push("Adult signature was refused. The order does not ship.");
|
|
266
|
-
const stale = (["verification", "tax", "risk", "stock"] as const).filter((key) => order.evidence[key] !== "fresh" && order.evidence[key] !== "not-required");
|
|
267
|
-
if (stale.length > 0) {
|
|
268
|
-
reasons.push(`Evidence is not fresh: ${stale.map((key) => `${key} ${order.evidence[key]}`).join(", ")}.`);
|
|
269
|
-
}
|
|
270
|
-
if (order.payment === "refund_requested" || order.payment === "refund_unknown") {
|
|
271
|
-
reasons.push("Refund stop. Reconcile the refund before shipping. Returns are not automated.");
|
|
272
|
-
} else if (order.payment === "capture_unknown") {
|
|
273
|
-
reasons.push("Capture is unknown. Reconcile before shipping.");
|
|
274
|
-
} else if (order.payment !== "captured") {
|
|
275
|
-
reasons.push("Payment is not captured.");
|
|
276
|
-
}
|
|
277
|
-
if (order.stock !== "confirmed") reasons.push("Stock is not confirmed.");
|
|
278
|
-
if (order.label === "UNKNOWN" || order.providerOutcome === "unknown") {
|
|
279
|
-
reasons.push("Label outcome is unknown. Do not buy another label.");
|
|
280
|
-
}
|
|
281
|
-
if (order.label === "intent" || order.providerOutcome === "intent") {
|
|
282
|
-
reasons.push("Label purchase is pending. Do not buy another label.");
|
|
283
|
-
}
|
|
284
|
-
if (order.label === "void_requested") reasons.push("Void is pending. Do not buy another label.");
|
|
285
|
-
return reasons;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export function workspaceQueue(order: {
|
|
289
|
-
fulfillment: FulfillmentState;
|
|
290
|
-
manualException: WorkspaceException | null;
|
|
291
|
-
adultSignature: "required" | "accepted" | "refused";
|
|
292
|
-
evidence: CommerceEvidence;
|
|
293
|
-
payment: PaymentState;
|
|
294
|
-
stock: StockState;
|
|
295
|
-
label: LabelState;
|
|
296
|
-
providerOutcome: ProviderOutcome | null;
|
|
297
|
-
picked: boolean;
|
|
298
|
-
packed: boolean;
|
|
299
|
-
}): WorkspaceQueue {
|
|
300
|
-
if (order.fulfillment === "handed_off") return "shipped";
|
|
301
|
-
if (holdReasons(order).length > 0) return "held";
|
|
302
|
-
if (order.picked || order.packed || order.label === "purchased" || order.label === "printed") return "in_progress";
|
|
303
|
-
return "ready";
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function unitCount(order: WorkspaceOrder): number {
|
|
307
|
-
return order.lines.reduce((sum, line) => sum + line.quantity, 0);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function blankResult(command: string, orderId: string, status: WorkspaceResult["status"], reason: string): WorkspaceResult {
|
|
311
|
-
return {
|
|
312
|
-
orderId,
|
|
313
|
-
command,
|
|
314
|
-
status,
|
|
315
|
-
reason,
|
|
316
|
-
livePurchase: false,
|
|
317
|
-
purchaseId: null,
|
|
318
|
-
costMinor: null,
|
|
319
|
-
releaseReservation: false,
|
|
320
|
-
restock: false,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export function initialWorkspaceState(tenantId: string, stage: CommerceStage = "preview"): WorkspaceState {
|
|
325
|
-
const shippable = {
|
|
326
|
-
payment: "captured" as const,
|
|
327
|
-
compliance: "fresh" as const,
|
|
328
|
-
stock: "confirmed" as const,
|
|
329
|
-
evidence: FRESH,
|
|
330
|
-
fulfillment: "ready" as const,
|
|
331
|
-
};
|
|
332
|
-
const order = (
|
|
333
|
-
id: string,
|
|
334
|
-
placedAt: string,
|
|
335
|
-
sku: string,
|
|
336
|
-
quantity: number,
|
|
337
|
-
extra: Partial<WorkspaceOrder> = {},
|
|
338
|
-
): WorkspaceOrder => ({
|
|
339
|
-
id,
|
|
340
|
-
placedAt,
|
|
341
|
-
lines: [{ sku, quantity }],
|
|
342
|
-
currency: "USD",
|
|
343
|
-
payment: extra.payment ?? shippable.payment,
|
|
344
|
-
compliance: extra.compliance ?? shippable.compliance,
|
|
345
|
-
stock: extra.stock ?? shippable.stock,
|
|
346
|
-
fulfillment: extra.fulfillment ?? shippable.fulfillment,
|
|
347
|
-
label: extra.label ?? "none",
|
|
348
|
-
providerOutcome: extra.providerOutcome ?? null,
|
|
349
|
-
evidence: extra.evidence ?? shippable.evidence,
|
|
350
|
-
picked: extra.picked ?? false,
|
|
351
|
-
packed: extra.packed ?? false,
|
|
352
|
-
manualException: extra.manualException ?? null,
|
|
353
|
-
adultSignature: extra.adultSignature ?? "required",
|
|
354
|
-
purchaseKey: extra.purchaseKey ?? null,
|
|
355
|
-
purchaseId: extra.purchaseId ?? null,
|
|
356
|
-
labelCostMinor: extra.labelCostMinor ?? null,
|
|
357
|
-
carrier: extra.carrier ?? null,
|
|
358
|
-
trackingNumber: extra.trackingNumber ?? null,
|
|
359
|
-
trackingUrl: extra.trackingUrl ?? null,
|
|
360
|
-
ownerDestination: `dest-${id}`,
|
|
361
|
-
purchaseScript: extra.purchaseScript ?? "admit",
|
|
362
|
-
voidScript: extra.voidScript ?? "approved",
|
|
363
|
-
signatureScript: extra.signatureScript ?? "accept",
|
|
364
|
-
slipIssued: false,
|
|
365
|
-
results: [],
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
return {
|
|
369
|
-
tenantId,
|
|
370
|
-
stage,
|
|
371
|
-
carrierAccountConfigured: true,
|
|
372
|
-
prohibitedCarriers: ["USPS"],
|
|
373
|
-
adultSignatureRequired: true,
|
|
374
|
-
livePurchase: false,
|
|
375
|
-
currency: "USD",
|
|
376
|
-
quoteMinor: TEST_ADAPTER_QUOTE_MINOR,
|
|
377
|
-
orders: [
|
|
378
|
-
order("ord-ready-a", "2026-10-15T18:00:00.000Z", "sku-ready", 2),
|
|
379
|
-
order("ord-ready-b", "2026-10-15T17:00:00.000Z", "sku-ready", 1),
|
|
380
|
-
order("ord-ready-pending", "2026-10-15T16:00:00.000Z", "sku-ready", 1, { purchaseScript: "pending" }),
|
|
381
|
-
order("ord-ready-unknown", "2026-10-15T15:30:00.000Z", "sku-ready", 1, { purchaseScript: "unknown" }),
|
|
382
|
-
order("ord-ready-signature", "2026-10-15T15:00:00.000Z", "sku-ready", 1, { signatureScript: "refuse" }),
|
|
383
|
-
order("ord-packed", "2026-10-15T14:00:00.000Z", "sku-pack", 1, { picked: true, packed: true }),
|
|
384
|
-
order("ord-labeled", "2026-10-15T13:00:00.000Z", "sku-label", 1, {
|
|
385
|
-
picked: true,
|
|
386
|
-
packed: true,
|
|
387
|
-
label: "purchased",
|
|
388
|
-
providerOutcome: "accepted",
|
|
389
|
-
adultSignature: "accepted",
|
|
390
|
-
purchaseKey: "key-labeled",
|
|
391
|
-
purchaseId: "test-key-labeled",
|
|
392
|
-
labelCostMinor: TEST_ADAPTER_QUOTE_MINOR,
|
|
393
|
-
}),
|
|
394
|
-
order("ord-void-pending", "2026-10-15T12:40:00.000Z", "sku-void", 1, {
|
|
395
|
-
picked: true,
|
|
396
|
-
packed: true,
|
|
397
|
-
label: "purchased",
|
|
398
|
-
providerOutcome: "accepted",
|
|
399
|
-
adultSignature: "accepted",
|
|
400
|
-
purchaseKey: "key-void-pending",
|
|
401
|
-
purchaseId: "test-key-void-pending",
|
|
402
|
-
labelCostMinor: TEST_ADAPTER_QUOTE_MINOR,
|
|
403
|
-
voidScript: "pending",
|
|
404
|
-
}),
|
|
405
|
-
order("ord-void-denied", "2026-10-15T12:20:00.000Z", "sku-void", 1, {
|
|
406
|
-
picked: true,
|
|
407
|
-
packed: true,
|
|
408
|
-
label: "purchased",
|
|
409
|
-
providerOutcome: "accepted",
|
|
410
|
-
adultSignature: "accepted",
|
|
411
|
-
purchaseKey: "key-void-denied",
|
|
412
|
-
purchaseId: "test-key-void-denied",
|
|
413
|
-
labelCostMinor: TEST_ADAPTER_QUOTE_MINOR,
|
|
414
|
-
voidScript: "denied",
|
|
415
|
-
}),
|
|
416
|
-
order("ord-intent", "2026-10-15T12:00:00.000Z", "sku-intent", 1, {
|
|
417
|
-
label: "intent",
|
|
418
|
-
providerOutcome: "intent",
|
|
419
|
-
purchaseKey: "key-intent",
|
|
420
|
-
}),
|
|
421
|
-
order("ord-unknown-label", "2026-10-15T11:30:00.000Z", "sku-unknown", 1, {
|
|
422
|
-
label: "UNKNOWN",
|
|
423
|
-
providerOutcome: "unknown",
|
|
424
|
-
purchaseKey: "key-unknown",
|
|
425
|
-
}),
|
|
426
|
-
order("ord-evidence", "2026-10-15T11:00:00.000Z", "sku-evidence", 1, {
|
|
427
|
-
payment: "authorized",
|
|
428
|
-
compliance: "UNKNOWN",
|
|
429
|
-
stock: "reserved",
|
|
430
|
-
fulfillment: "held",
|
|
431
|
-
evidence: STALE,
|
|
432
|
-
}),
|
|
433
|
-
order("ord-refund", "2026-10-15T10:00:00.000Z", "sku-refund", 1, { payment: "refund_requested" }),
|
|
434
|
-
order("ord-refund-unknown", "2026-10-15T09:30:00.000Z", "sku-refund-unknown", 1, { payment: "refund_unknown" }),
|
|
435
|
-
order("ord-signature", "2026-10-15T09:00:00.000Z", "sku-signature", 1, {
|
|
436
|
-
adultSignature: "refused",
|
|
437
|
-
signatureScript: "refuse",
|
|
438
|
-
}),
|
|
439
|
-
order("ord-cancelled", "2026-10-15T08:30:00.000Z", "sku-cancelled", 1, { fulfillment: "cancelled" }),
|
|
440
|
-
order("ord-shipped", "2026-10-15T08:00:00.000Z", "sku-shipped", 1, {
|
|
441
|
-
picked: true,
|
|
442
|
-
packed: true,
|
|
443
|
-
fulfillment: "handed_off",
|
|
444
|
-
label: "printed",
|
|
445
|
-
providerOutcome: "accepted",
|
|
446
|
-
adultSignature: "accepted",
|
|
447
|
-
purchaseKey: "key-shipped",
|
|
448
|
-
purchaseId: "test-key-shipped",
|
|
449
|
-
labelCostMinor: TEST_ADAPTER_QUOTE_MINOR,
|
|
450
|
-
carrier: "UPS",
|
|
451
|
-
trackingNumber: "TRK-ord-shipped",
|
|
452
|
-
trackingUrl: "https://www.ups.com/track?tracknum=TRKORDSHIPPED",
|
|
453
|
-
}),
|
|
454
|
-
],
|
|
455
|
-
events: [],
|
|
456
|
-
log: [],
|
|
457
|
-
lastResults: [],
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function matchesQuery(order: WorkspaceOrder, q: string): boolean {
|
|
462
|
-
if (q === "") return true;
|
|
463
|
-
const needle = q.toLowerCase();
|
|
464
|
-
if (order.id.toLowerCase().includes(needle)) return true;
|
|
465
|
-
return order.lines.some((line) => line.sku.toLowerCase().includes(needle));
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function projectOrder(state: WorkspaceState, order: WorkspaceOrder, actor: CommerceActor): WorkspaceOrderView {
|
|
469
|
-
const scope = { tenantId: state.tenantId, stage: state.stage };
|
|
470
|
-
const queue = workspaceQueue(order);
|
|
471
|
-
let trackingUrl: string | null = null;
|
|
472
|
-
if (order.trackingUrl !== null) {
|
|
473
|
-
const admitted = admitTrackingRead({
|
|
474
|
-
actor,
|
|
475
|
-
resource: scope,
|
|
476
|
-
trackingUrl: order.trackingUrl,
|
|
477
|
-
allowedHosts: trackingHostsFor(order.carrier),
|
|
478
|
-
});
|
|
479
|
-
if (admitted.ok) trackingUrl = order.trackingUrl;
|
|
480
|
-
}
|
|
481
|
-
const address = readOwnerAddress(actor, scope, () => order.ownerDestination);
|
|
482
|
-
const printPayload =
|
|
483
|
-
address.ok && order.purchaseId !== null && (order.label === "purchased" || order.label === "printed")
|
|
484
|
-
? {
|
|
485
|
-
purchaseId: order.purchaseId,
|
|
486
|
-
format: "pdf" as const,
|
|
487
|
-
adultSignature: "required" as const,
|
|
488
|
-
livePurchase: false as const,
|
|
489
|
-
destination: address.address,
|
|
490
|
-
}
|
|
491
|
-
: null;
|
|
492
|
-
const slip: PackingSlip | null = order.slipIssued
|
|
493
|
-
? {
|
|
494
|
-
orderId: order.id,
|
|
495
|
-
lines: order.lines.map((line) => ({ sku: line.sku, quantity: line.quantity })),
|
|
496
|
-
wholeOrder: true,
|
|
497
|
-
destination: address.ok ? address.address : null,
|
|
498
|
-
}
|
|
499
|
-
: null;
|
|
500
|
-
return {
|
|
501
|
-
id: order.id,
|
|
502
|
-
placedAt: order.placedAt,
|
|
503
|
-
lines: order.lines.map((line) => ({ sku: line.sku, quantity: line.quantity })),
|
|
504
|
-
unitCount: unitCount(order),
|
|
505
|
-
currency: "USD",
|
|
506
|
-
payment: order.payment,
|
|
507
|
-
stock: order.stock,
|
|
508
|
-
fulfillment: order.fulfillment,
|
|
509
|
-
label: order.label,
|
|
510
|
-
providerOutcome: order.providerOutcome,
|
|
511
|
-
evidence: { ...order.evidence },
|
|
512
|
-
picked: order.picked,
|
|
513
|
-
packed: order.packed,
|
|
514
|
-
manualException: order.manualException,
|
|
515
|
-
adultSignature: order.adultSignature,
|
|
516
|
-
purchaseKey: order.purchaseKey,
|
|
517
|
-
purchaseId: order.purchaseId,
|
|
518
|
-
labelCostMinor: order.labelCostMinor,
|
|
519
|
-
trackingNumber: order.trackingNumber,
|
|
520
|
-
trackingUrl,
|
|
521
|
-
queue,
|
|
522
|
-
holdReasons: holdReasons(order),
|
|
523
|
-
results: order.results.map((result) => ({ ...result })),
|
|
524
|
-
slip,
|
|
525
|
-
printPayload,
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
export function projectWorkspace(state: WorkspaceState, query: WorkspaceQuery): FulfillmentViewModel {
|
|
530
|
-
const actor = workspaceActor(state.tenantId, state.stage, query.actorName);
|
|
531
|
-
const storewide: Record<WorkspaceQueue, number> = { ready: 0, held: 0, in_progress: 0, shipped: 0 };
|
|
532
|
-
for (const order of state.orders) storewide[workspaceQueue(order)] += 1;
|
|
533
|
-
const filtered = state.orders.filter((order) => {
|
|
534
|
-
if (query.queue !== "all" && workspaceQueue(order) !== query.queue) return false;
|
|
535
|
-
return matchesQuery(order, query.q);
|
|
536
|
-
});
|
|
537
|
-
const page = paginateOrders(filtered, query.limit, query.cursor);
|
|
538
|
-
const pickList: FulfillmentViewModel["pickList"] = [];
|
|
539
|
-
for (const order of state.orders) {
|
|
540
|
-
if (!order.picked || order.fulfillment === "handed_off" || order.fulfillment === "cancelled") continue;
|
|
541
|
-
for (const line of order.lines) {
|
|
542
|
-
pickList.push({ orderId: order.id, sku: line.sku, quantity: line.quantity, packed: order.packed });
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
return {
|
|
546
|
-
targetTenant: state.tenantId,
|
|
547
|
-
stage: state.stage,
|
|
548
|
-
actorName: query.actorName,
|
|
549
|
-
actorRole: actor.role,
|
|
550
|
-
livePurchase: false,
|
|
551
|
-
carrierAccountConfigured: state.carrierAccountConfigured,
|
|
552
|
-
prohibitedCarriers: state.prohibitedCarriers,
|
|
553
|
-
adultSignatureRequired: true,
|
|
554
|
-
quoteMinor: state.quoteMinor,
|
|
555
|
-
currency: "USD",
|
|
556
|
-
queue: query.queue,
|
|
557
|
-
q: query.q,
|
|
558
|
-
limit: query.limit,
|
|
559
|
-
cursor: query.cursor,
|
|
560
|
-
nextCursor: page.nextCursor,
|
|
561
|
-
invalidCursor: page.invalidCursor,
|
|
562
|
-
storewide,
|
|
563
|
-
filterCount: filtered.length,
|
|
564
|
-
pageCount: page.orders.length,
|
|
565
|
-
orders: page.orders.map((order) => projectOrder(state, order, actor)),
|
|
566
|
-
pickList,
|
|
567
|
-
events: state.events.map((event) => ({ ...event, totals: { ...event.totals }, verificationDetail: { ...event.verificationDetail } })),
|
|
568
|
-
log: [...state.log],
|
|
569
|
-
lastResults: state.lastResults.map((result) => ({ ...result })),
|
|
570
|
-
};
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
function explicitCarrierReason(carrier: string | null): "usps-prohibited" | "carrier-not-selectable" | null {
|
|
574
|
-
if (carrier === null || carrier.trim() === "") return null;
|
|
575
|
-
if (carrier.trim().toUpperCase() === "USPS") return "usps-prohibited";
|
|
576
|
-
return "carrier-not-selectable";
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function isException(value: string | null): value is WorkspaceException {
|
|
580
|
-
return WORKSPACE_EXCEPTIONS.some((item) => item === value);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
function commerceStamp(order: WorkspaceOrder): string {
|
|
584
|
-
return [
|
|
585
|
-
order.payment,
|
|
586
|
-
order.compliance,
|
|
587
|
-
order.stock,
|
|
588
|
-
order.fulfillment,
|
|
589
|
-
order.label,
|
|
590
|
-
order.evidence.verification,
|
|
591
|
-
order.evidence.tax,
|
|
592
|
-
order.evidence.risk,
|
|
593
|
-
order.evidence.stock,
|
|
594
|
-
].join("|");
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
function emitIfChanged(state: WorkspaceState, order: WorkspaceOrder, before: string): void {
|
|
598
|
-
if (commerceStamp(order) === before) return;
|
|
599
|
-
const eventVersion = state.events.filter((event) => event.orderId === order.id).length + 1;
|
|
600
|
-
state.events.push(
|
|
601
|
-
publicCommerceEvent({
|
|
602
|
-
eventVersion,
|
|
603
|
-
orderId: order.id,
|
|
604
|
-
placedAt: order.placedAt,
|
|
605
|
-
currency: order.currency,
|
|
606
|
-
payment: order.payment,
|
|
607
|
-
compliance: order.compliance,
|
|
608
|
-
stock: order.stock,
|
|
609
|
-
fulfillment: order.fulfillment,
|
|
610
|
-
label: order.label,
|
|
611
|
-
totals: TOTALS,
|
|
612
|
-
verificationDetail: order.evidence,
|
|
613
|
-
}),
|
|
614
|
-
);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function attemptKey(order: WorkspaceOrder, requested: string | null): string {
|
|
618
|
-
if (order.label === "voided") {
|
|
619
|
-
if (requested !== null && requested !== order.purchaseKey) return requested;
|
|
620
|
-
return `${order.purchaseKey ?? `pk-${order.id}`}-2`;
|
|
621
|
-
}
|
|
622
|
-
if (order.purchaseKey !== null) return order.purchaseKey;
|
|
623
|
-
if (requested !== null && requested.trim() !== "") return requested;
|
|
624
|
-
return `pk-${order.id}`;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
function applyToOrder(state: WorkspaceState, order: WorkspaceOrder, command: WorkspaceCommand): WorkspaceResult {
|
|
628
|
-
const before = commerceStamp(order);
|
|
629
|
-
const finish = (result: WorkspaceResult): WorkspaceResult => {
|
|
630
|
-
order.results.push(result);
|
|
631
|
-
emitIfChanged(state, order, before);
|
|
632
|
-
return result;
|
|
633
|
-
};
|
|
634
|
-
const refuse = (reason: string, extra: Partial<WorkspaceResult> = {}): WorkspaceResult =>
|
|
635
|
-
finish({ ...blankResult(command.command, order.id, "refused", reason), purchaseId: order.purchaseId, ...extra, livePurchase: false, restock: false });
|
|
636
|
-
|
|
637
|
-
if (command.quantityInvalid) return refuse("quantity");
|
|
638
|
-
if (command.quantity !== null && command.quantity !== unitCount(order)) return refuse("partial-shipment");
|
|
639
|
-
|
|
640
|
-
if (command.command === "quote-label") {
|
|
641
|
-
const carrierReason = explicitCarrierReason(command.carrier);
|
|
642
|
-
if (carrierReason) return refuse(carrierReason);
|
|
643
|
-
if (!state.carrierAccountConfigured) return refuse("carrier-account");
|
|
644
|
-
return finish({
|
|
645
|
-
...blankResult(command.command, order.id, "admitted", "quote"),
|
|
646
|
-
costMinor: state.quoteMinor,
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
if (command.command === "purchase-label") {
|
|
651
|
-
const carrierReason = explicitCarrierReason(command.carrier);
|
|
652
|
-
if (carrierReason) return refuse(carrierReason);
|
|
653
|
-
if (!state.carrierAccountConfigured) return refuse("carrier-account");
|
|
654
|
-
const decision = decideCommerceCommand({
|
|
655
|
-
command: "purchase-label",
|
|
656
|
-
shipTo: order.ownerDestination ? "present" : "absent",
|
|
657
|
-
payment: order.payment,
|
|
658
|
-
stock: order.stock,
|
|
659
|
-
fulfillment: order.fulfillment,
|
|
660
|
-
label: order.label,
|
|
661
|
-
evidence: order.evidence,
|
|
662
|
-
providerOutcome: order.providerOutcome,
|
|
663
|
-
});
|
|
664
|
-
if (!decision.admit) return refuse(decision.reason);
|
|
665
|
-
if (order.adultSignature === "refused" || order.signatureScript === "refuse") {
|
|
666
|
-
order.adultSignature = "refused";
|
|
667
|
-
return refuse("adult-signature");
|
|
668
|
-
}
|
|
669
|
-
const key = attemptKey(order, command.purchaseKey);
|
|
670
|
-
order.purchaseKey = key;
|
|
671
|
-
if (order.purchaseScript === "pending") {
|
|
672
|
-
order.label = "intent";
|
|
673
|
-
order.providerOutcome = "intent";
|
|
674
|
-
return finish({ ...blankResult(command.command, order.id, "pending", "pending"), purchaseId: null });
|
|
675
|
-
}
|
|
676
|
-
if (order.purchaseScript === "unknown") {
|
|
677
|
-
order.label = "UNKNOWN";
|
|
678
|
-
order.providerOutcome = "unknown";
|
|
679
|
-
return finish({ ...blankResult(command.command, order.id, "unknown", "unknown"), purchaseId: null });
|
|
680
|
-
}
|
|
681
|
-
order.label = "purchased";
|
|
682
|
-
order.providerOutcome = "accepted";
|
|
683
|
-
order.adultSignature = "accepted";
|
|
684
|
-
order.purchaseId = `test-${key}`;
|
|
685
|
-
order.labelCostMinor = state.quoteMinor;
|
|
686
|
-
return finish({
|
|
687
|
-
...blankResult(command.command, order.id, "admitted", "purchased"),
|
|
688
|
-
purchaseId: order.purchaseId,
|
|
689
|
-
costMinor: state.quoteMinor,
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
if (command.command === "print-label" || command.command === "reprint-label") {
|
|
694
|
-
const decision = decideCommerceCommand({
|
|
695
|
-
command: "print-label",
|
|
696
|
-
payment: order.payment,
|
|
697
|
-
stock: order.stock,
|
|
698
|
-
fulfillment: order.fulfillment,
|
|
699
|
-
label: order.label,
|
|
700
|
-
evidence: order.evidence,
|
|
701
|
-
providerOutcome: order.providerOutcome,
|
|
702
|
-
});
|
|
703
|
-
if (!decision.admit) return refuse(decision.reason);
|
|
704
|
-
const reason = command.command === "reprint-label" || order.label === "printed" ? "reprint" : "printed";
|
|
705
|
-
order.label = "printed";
|
|
706
|
-
return finish({ ...blankResult(command.command, order.id, "admitted", reason), purchaseId: order.purchaseId });
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
if (command.command === "void-label") {
|
|
710
|
-
if (order.fulfillment === "handed_off") return refuse("fulfillment");
|
|
711
|
-
if (
|
|
712
|
-
order.label === "UNKNOWN" ||
|
|
713
|
-
order.label === "intent" ||
|
|
714
|
-
order.label === "void_requested" ||
|
|
715
|
-
order.providerOutcome === "unknown" ||
|
|
716
|
-
order.providerOutcome === "intent"
|
|
717
|
-
) {
|
|
718
|
-
return refuse("reconcile");
|
|
719
|
-
}
|
|
720
|
-
if (order.label !== "purchased" && order.label !== "printed") return refuse("label");
|
|
721
|
-
if (order.voidScript === "pending") {
|
|
722
|
-
order.label = "void_requested";
|
|
723
|
-
return finish({ ...blankResult(command.command, order.id, "pending", "void-pending"), purchaseId: order.purchaseId });
|
|
724
|
-
}
|
|
725
|
-
if (order.voidScript === "denied") return refuse("void-denied");
|
|
726
|
-
order.label = "voided";
|
|
727
|
-
order.providerOutcome = "voided";
|
|
728
|
-
return finish({ ...blankResult(command.command, order.id, "admitted", "voided"), purchaseId: order.purchaseId });
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
if (command.command === "hand-off") {
|
|
732
|
-
if (!order.packed) return refuse("not-packed");
|
|
733
|
-
if (order.adultSignature !== "accepted") return refuse("adult-signature");
|
|
734
|
-
const decision = decideCommerceCommand({
|
|
735
|
-
command: "hand-off",
|
|
736
|
-
shipTo: order.ownerDestination ? "present" : "absent",
|
|
737
|
-
payment: order.payment,
|
|
738
|
-
stock: order.stock,
|
|
739
|
-
fulfillment: order.fulfillment,
|
|
740
|
-
label: order.label,
|
|
741
|
-
evidence: order.evidence,
|
|
742
|
-
providerOutcome: order.providerOutcome,
|
|
743
|
-
});
|
|
744
|
-
if (!decision.admit) return refuse(decision.reason);
|
|
745
|
-
order.fulfillment = "handed_off";
|
|
746
|
-
order.carrier = "UPS";
|
|
747
|
-
order.trackingNumber = `TRK-${order.id}`;
|
|
748
|
-
order.trackingUrl = `https://www.ups.com/track?tracknum=${encodeURIComponent(order.id)}`;
|
|
749
|
-
return finish({ ...blankResult(command.command, order.id, "admitted", "handed-off"), purchaseId: order.purchaseId });
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
if (command.command === "cancel") {
|
|
753
|
-
const decision = decideCommerceCommand({
|
|
754
|
-
command: "cancel",
|
|
755
|
-
payment: order.payment,
|
|
756
|
-
stock: order.stock,
|
|
757
|
-
fulfillment: order.fulfillment,
|
|
758
|
-
label: order.label,
|
|
759
|
-
evidence: order.evidence,
|
|
760
|
-
providerOutcome: order.providerOutcome,
|
|
761
|
-
});
|
|
762
|
-
if (!decision.admit) return refuse(decision.reason);
|
|
763
|
-
order.fulfillment = "cancelled";
|
|
764
|
-
return finish({
|
|
765
|
-
...blankResult(command.command, order.id, "admitted", "cancelled"),
|
|
766
|
-
purchaseId: order.purchaseId,
|
|
767
|
-
releaseReservation: decision.releaseReservation,
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
if (command.command === "pick-batch") {
|
|
772
|
-
if (workspaceQueue(order) !== "ready") return refuse("not-ready");
|
|
773
|
-
order.picked = true;
|
|
774
|
-
return finish(blankResult(command.command, order.id, "admitted", "picked"));
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
if (command.command === "confirm-pack") {
|
|
778
|
-
if (order.fulfillment === "handed_off" || order.fulfillment === "cancelled") return refuse("fulfillment");
|
|
779
|
-
if (holdReasons(order).length > 0) return refuse("held");
|
|
780
|
-
if (!order.picked) return refuse("not-picked");
|
|
781
|
-
if (order.packed) return refuse("already-packed");
|
|
782
|
-
order.packed = true;
|
|
783
|
-
return finish(blankResult(command.command, order.id, "admitted", "packed"));
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
if (command.command === "packing-slip") {
|
|
787
|
-
if (order.fulfillment === "cancelled") return refuse("fulfillment");
|
|
788
|
-
order.slipIssued = true;
|
|
789
|
-
return finish(blankResult(command.command, order.id, "admitted", "packing-slip"));
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
if (command.command === "record-exception") {
|
|
793
|
-
if (order.fulfillment === "handed_off") return refuse("fulfillment");
|
|
794
|
-
if (!isException(command.exception)) return refuse("exception");
|
|
795
|
-
order.manualException = command.exception;
|
|
796
|
-
return finish(blankResult(command.command, order.id, "admitted", command.exception));
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
if (command.command === "refund" || command.command === "return") return refuse("returns-not-automated");
|
|
800
|
-
return refuse("unknown-command");
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
function finishCommand(state: WorkspaceState, actorName: string, results: WorkspaceResult[]): WorkspaceState {
|
|
804
|
-
state.lastResults = results;
|
|
805
|
-
for (const result of results) {
|
|
806
|
-
state.log.push(`${actorName} ${result.command} ${result.orderId} ${result.status} ${result.reason}`);
|
|
807
|
-
}
|
|
808
|
-
return state;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
export function applyWorkspaceCommand(input: WorkspaceState, command: WorkspaceCommand): WorkspaceState {
|
|
812
|
-
const state = structuredClone(input);
|
|
813
|
-
const actor = workspaceActor(state.tenantId, state.stage, command.actorName);
|
|
814
|
-
const scope = { tenantId: state.tenantId, stage: state.stage };
|
|
815
|
-
if (!actorMayCommand(actor, scope)) {
|
|
816
|
-
const ids = command.orderIds.length > 0 ? command.orderIds : [""];
|
|
817
|
-
return finishCommand(
|
|
818
|
-
state,
|
|
819
|
-
command.actorName,
|
|
820
|
-
ids.map((orderId) => blankResult(command.command, orderId, "refused", "denied")),
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
if (command.lineId) {
|
|
824
|
-
const ids = command.orderIds.length > 0 ? command.orderIds : [""];
|
|
825
|
-
return finishCommand(
|
|
826
|
-
state,
|
|
827
|
-
command.actorName,
|
|
828
|
-
ids.map((orderId) => blankResult(command.command, orderId, "refused", "partial-shipment")),
|
|
829
|
-
);
|
|
830
|
-
}
|
|
831
|
-
if (command.orderIds.length === 0) {
|
|
832
|
-
return finishCommand(state, command.actorName, [blankResult(command.command, "", "refused", "empty-batch")]);
|
|
833
|
-
}
|
|
834
|
-
const results: WorkspaceResult[] = [];
|
|
835
|
-
const seen = new Set<string>();
|
|
836
|
-
for (const orderId of command.orderIds) {
|
|
837
|
-
if (seen.has(orderId)) continue;
|
|
838
|
-
seen.add(orderId);
|
|
839
|
-
const order = state.orders.find((item) => item.id === orderId);
|
|
840
|
-
if (order === undefined) {
|
|
841
|
-
results.push(blankResult(command.command, orderId, "refused", "missing"));
|
|
842
|
-
continue;
|
|
843
|
-
}
|
|
844
|
-
results.push(applyToOrder(state, order, command));
|
|
845
|
-
}
|
|
846
|
-
return finishCommand(state, command.actorName, results);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
const COMMANDS = new Set([
|
|
850
|
-
"quote-label",
|
|
851
|
-
"purchase-label",
|
|
852
|
-
"print-label",
|
|
853
|
-
"reprint-label",
|
|
854
|
-
"void-label",
|
|
855
|
-
"hand-off",
|
|
856
|
-
"cancel",
|
|
857
|
-
"confirm-pack",
|
|
858
|
-
"pick-batch",
|
|
859
|
-
"packing-slip",
|
|
860
|
-
"record-exception",
|
|
861
|
-
"refund",
|
|
862
|
-
"return",
|
|
863
|
-
]);
|
|
864
|
-
|
|
865
|
-
export function parseWorkspaceQuery(params: URLSearchParams): WorkspaceQuery {
|
|
866
|
-
const queueRaw = params.get("queue");
|
|
867
|
-
const queue: WorkspaceQueueFilter =
|
|
868
|
-
queueRaw === "all" || queueRaw === "ready" || queueRaw === "held" || queueRaw === "in_progress" || queueRaw === "shipped"
|
|
869
|
-
? queueRaw
|
|
870
|
-
: "ready";
|
|
871
|
-
const limitRaw = params.get("limit");
|
|
872
|
-
let limit = WORKSPACE_PAGE_LIMIT;
|
|
873
|
-
if (limitRaw !== null && /^\d+$/.test(limitRaw)) {
|
|
874
|
-
const parsed = Number(limitRaw);
|
|
875
|
-
if (parsed >= 1 && parsed <= 50) limit = parsed;
|
|
876
|
-
}
|
|
877
|
-
const cursorRaw = params.get("cursor");
|
|
878
|
-
return {
|
|
879
|
-
actorName: (params.get("actor") ?? "owner").trim() || "owner",
|
|
880
|
-
queue,
|
|
881
|
-
q: (params.get("q") ?? "").trim(),
|
|
882
|
-
cursor: cursorRaw !== null && cursorRaw.trim() !== "" ? cursorRaw : null,
|
|
883
|
-
limit,
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
export function parseWorkspaceCommand(params: URLSearchParams): { ok: true; command: WorkspaceCommand } | { ok: false; error: string } {
|
|
888
|
-
const command = (params.get("command") ?? "").trim();
|
|
889
|
-
if (!COMMANDS.has(command)) return { ok: false, error: "unknown-command" };
|
|
890
|
-
let quantity: number | null = null;
|
|
891
|
-
let quantityInvalid = false;
|
|
892
|
-
if (params.has("quantity")) {
|
|
893
|
-
const raw = (params.get("quantity") ?? "").trim();
|
|
894
|
-
if (raw !== "") {
|
|
895
|
-
if (!/^\d+$/.test(raw)) quantityInvalid = true;
|
|
896
|
-
else quantity = Number(raw);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
const carrierRaw = params.get("carrier");
|
|
900
|
-
const purchaseRaw = params.get("purchaseKey");
|
|
901
|
-
return {
|
|
902
|
-
ok: true,
|
|
903
|
-
command: {
|
|
904
|
-
actorName: (params.get("actor") ?? "owner").trim() || "owner",
|
|
905
|
-
command,
|
|
906
|
-
orderIds: params.getAll("orderId").map((id) => id.trim()).filter((id) => id !== ""),
|
|
907
|
-
purchaseKey: purchaseRaw !== null && purchaseRaw.trim() !== "" ? purchaseRaw.trim() : null,
|
|
908
|
-
carrier: carrierRaw !== null && carrierRaw.trim() !== "" ? carrierRaw : null,
|
|
909
|
-
quantity,
|
|
910
|
-
quantityInvalid,
|
|
911
|
-
lineId: params.has("lineId"),
|
|
912
|
-
exception: params.get("exception"),
|
|
913
|
-
},
|
|
914
|
-
};
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
function esc(value: string): string {
|
|
918
|
-
return value
|
|
919
|
-
.replace(/&/g, "&")
|
|
920
|
-
.replace(/</g, "<")
|
|
921
|
-
.replace(/>/g, ">")
|
|
922
|
-
.replace(/"/g, """);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
function href(view: FulfillmentViewModel, over: Partial<WorkspaceQuery> = {}): string {
|
|
926
|
-
const next: WorkspaceQuery = {
|
|
927
|
-
actorName: over.actorName ?? view.actorName,
|
|
928
|
-
queue: over.queue ?? view.queue,
|
|
929
|
-
q: over.q ?? view.q,
|
|
930
|
-
limit: over.limit ?? view.limit,
|
|
931
|
-
cursor: "cursor" in over ? (over.cursor ?? null) : view.cursor,
|
|
932
|
-
};
|
|
933
|
-
const params = new URLSearchParams();
|
|
934
|
-
params.set("actor", next.actorName);
|
|
935
|
-
params.set("queue", next.queue);
|
|
936
|
-
params.set("limit", String(next.limit));
|
|
937
|
-
if (next.q !== "") params.set("q", next.q);
|
|
938
|
-
if (next.cursor !== null) params.set("cursor", next.cursor);
|
|
939
|
-
return `${SCRAPPY_FULFILLMENT_PATH}?${params.toString()}`;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
function hiddenFields(view: FulfillmentViewModel, command: string, extras: Array<[string, string]> = []): string {
|
|
943
|
-
const fields: Array<[string, string]> = [
|
|
944
|
-
["actor", view.actorName],
|
|
945
|
-
["queue", view.queue],
|
|
946
|
-
["q", view.q],
|
|
947
|
-
["limit", String(view.limit)],
|
|
948
|
-
["command", command],
|
|
949
|
-
...extras,
|
|
950
|
-
];
|
|
951
|
-
return fields
|
|
952
|
-
.map(([name, value]) => `<input type="hidden" name="${esc(name)}" value="${esc(value)}">`)
|
|
953
|
-
.join("");
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
function orderActions(view: FulfillmentViewModel, order: WorkspaceOrderView, action: string): string {
|
|
957
|
-
const purchaseExtras: Array<[string, string]> = [["orderId", order.id]];
|
|
958
|
-
if (order.purchaseKey !== null) purchaseExtras.push(["purchaseKey", order.purchaseKey]);
|
|
959
|
-
const one = (command: string, label: string, extras: Array<[string, string]> = [["orderId", order.id]]) =>
|
|
960
|
-
`<form method="post" action="${action}">${hiddenFields(view, command, extras)}<button type="submit">${esc(label)}</button></form>`;
|
|
961
|
-
const exceptionOptions = WORKSPACE_EXCEPTIONS.map(
|
|
962
|
-
(reason) => `<option value="${reason}">${esc(reason)}</option>`,
|
|
963
|
-
).join("");
|
|
964
|
-
return `<div data-order-actions="${esc(order.id)}">
|
|
965
|
-
${one("quote-label", "Quote cost")}
|
|
966
|
-
${one("purchase-label", "Purchase label", purchaseExtras)}
|
|
967
|
-
${one("print-label", "Print label")}
|
|
968
|
-
${one("reprint-label", "Reprint label")}
|
|
969
|
-
${one("void-label", "Void label")}
|
|
970
|
-
${one("hand-off", "Hand off")}
|
|
971
|
-
${one("confirm-pack", "Confirm pack")}
|
|
972
|
-
${one("packing-slip", "Packing slip")}
|
|
973
|
-
${one("cancel", "Cancel order")}
|
|
974
|
-
<form method="post" action="${action}">${hiddenFields(view, "record-exception", [["orderId", order.id]])}<label>Manual exception <select name="exception">${exceptionOptions}</select></label><button type="submit">Record manual exception</button></form>
|
|
975
|
-
</div>`;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
export function renderFulfillmentWorkspace(view: FulfillmentViewModel): string {
|
|
979
|
-
const queueLinks = (["ready", "held", "in_progress", "shipped", "all"] as const)
|
|
980
|
-
.map((queue) => {
|
|
981
|
-
const count = queue === "all" ? "" : ` (${view.storewide[queue]})`;
|
|
982
|
-
const label = queue === "all" ? "All" : QUEUE_LABEL[queue];
|
|
983
|
-
return `<a data-queue-link="${queue}" href="${esc(href(view, { queue, cursor: null }))}">${esc(label)}${count}</a>`;
|
|
984
|
-
})
|
|
985
|
-
.join("");
|
|
986
|
-
const action = esc(href(view, { cursor: null }));
|
|
987
|
-
const rows = view.orders
|
|
988
|
-
.map((order) => {
|
|
989
|
-
const pick = order.queue === "ready"
|
|
990
|
-
? `<input form="scrappy-pick" type="checkbox" name="orderId" value="${esc(order.id)}" data-pick-box="${esc(order.id)}">`
|
|
991
|
-
: "";
|
|
992
|
-
const evidence = `verification ${order.evidence.verification}, tax ${order.evidence.tax}, risk ${order.evidence.risk}, stock ${order.evidence.stock}`;
|
|
993
|
-
return `<tr data-order-row="${esc(order.id)}" data-queue="${order.queue}" data-label="${esc(order.label)}" data-payment="${esc(order.payment)}" data-fulfillment="${esc(order.fulfillment)}" data-packed="${order.packed ? "true" : "false"}" data-picked="${order.picked ? "true" : "false"}" data-adult-signature="${order.adultSignature}" data-purchase-id="${esc(order.purchaseId ?? "")}" data-purchase-key="${esc(order.purchaseKey ?? "")}" data-whole-order="true">
|
|
994
|
-
<td>${pick}</td>
|
|
995
|
-
<td>${esc(order.id)}</td>
|
|
996
|
-
<td>${esc(QUEUE_LABEL[order.queue])}</td>
|
|
997
|
-
<td>${order.lines.map((line) => `${esc(line.sku)} × ${line.quantity}`).join(", ")}</td>
|
|
998
|
-
<td>${esc(order.label)}</td>
|
|
999
|
-
<td>${esc(evidence)}</td>
|
|
1000
|
-
<td data-hold="${esc(order.holdReasons.join(" "))}">${order.holdReasons.length === 0 ? "None" : esc(order.holdReasons.join(" "))}</td>
|
|
1001
|
-
<td>${esc(order.trackingNumber ?? "")}</td>
|
|
1002
|
-
</tr>`;
|
|
1003
|
-
})
|
|
1004
|
-
.join("");
|
|
1005
|
-
const details = view.orders
|
|
1006
|
-
.map((order) => {
|
|
1007
|
-
const payload = order.printPayload
|
|
1008
|
-
? `<pre data-print-payload data-order-id="${esc(order.id)}">${esc(JSON.stringify(order.printPayload))}</pre>`
|
|
1009
|
-
: order.label === "purchased" || order.label === "printed"
|
|
1010
|
-
? `<p data-print-denied="owner-only" data-order-id="${esc(order.id)}">Print payload is owner-only.</p>`
|
|
1011
|
-
: "";
|
|
1012
|
-
const slip = order.slip
|
|
1013
|
-
? `<div data-packing-slip data-order-id="${esc(order.id)}" data-whole-order="true"><ul>${order.slip.lines
|
|
1014
|
-
.map((line) => `<li data-slip-sku="${esc(line.sku)}" data-slip-quantity="${line.quantity}">${esc(line.sku)} ${line.quantity}</li>`)
|
|
1015
|
-
.join("")}</ul>${
|
|
1016
|
-
order.slip.destination
|
|
1017
|
-
? `<p data-slip-destination>${esc(order.slip.destination)}</p>`
|
|
1018
|
-
: `<p data-slip-destination-denied="owner-only">Destination is owner-only.</p>`
|
|
1019
|
-
}</div>`
|
|
1020
|
-
: "";
|
|
1021
|
-
const tracking = order.trackingNumber
|
|
1022
|
-
? `<p data-tracking-number data-order-id="${esc(order.id)}">${esc(order.trackingNumber)}</p>${
|
|
1023
|
-
order.trackingUrl
|
|
1024
|
-
? `<a data-tracking-url data-order-id="${esc(order.id)}" href="${esc(order.trackingUrl)}" referrerpolicy="no-referrer">Tracking</a>`
|
|
1025
|
-
: `<p data-tracking-denied="owner-only" data-order-id="${esc(order.id)}">Tracking link is owner-only.</p>`
|
|
1026
|
-
}`
|
|
1027
|
-
: "";
|
|
1028
|
-
return `<section data-order-detail="${esc(order.id)}">${payload}${slip}${tracking}${orderActions(view, order, action)}</section>`;
|
|
1029
|
-
})
|
|
1030
|
-
.join("");
|
|
1031
|
-
const pickItems = view.pickList
|
|
1032
|
-
.map(
|
|
1033
|
-
(line) =>
|
|
1034
|
-
`<li data-pick-order="${esc(line.orderId)}" data-sku="${esc(line.sku)}" data-quantity="${line.quantity}" data-packed="${line.packed ? "true" : "false"}">${esc(line.orderId)} ${esc(line.sku)} ${line.quantity}</li>`,
|
|
1035
|
-
)
|
|
1036
|
-
.join("");
|
|
1037
|
-
const next = view.nextCursor
|
|
1038
|
-
? `<a data-page-next href="${esc(href(view, { cursor: view.nextCursor }))}">Next page</a>`
|
|
1039
|
-
: "";
|
|
1040
|
-
const account = view.carrierAccountConfigured ? "configured" : "missing";
|
|
1041
|
-
return `<div data-scrappy-batch data-target-tenant="${esc(view.targetTenant)}" data-live-purchase="false" data-carrier-account="${account}" data-prohibited-carrier="USPS" data-adult-signature-required="true" data-partial-shipment="unavailable" data-returns="unavailable" data-blind-repurchase="false" data-actor="${esc(view.actorName)}" data-actor-role="${esc(view.actorRole)}" data-storewide-ready="${view.storewide.ready}" data-storewide-held="${view.storewide.held}" data-storewide-in-progress="${view.storewide.in_progress}" data-storewide-shipped="${view.storewide.shipped}" data-filter-count="${view.filterCount}" data-page-count="${view.pageCount}" data-queue="${esc(view.queue)}">
|
|
1042
|
-
<h2 id="fulfillment-title">Daily batch</h2>
|
|
1043
|
-
<p>Not a live label purchase. Carrier account is configuration. USPS is prohibited. Adult signature is required. Shipment is the whole order. Partial shipment is not available. Returns are not automated.</p>
|
|
1044
|
-
<p data-carrier-account-text>${view.carrierAccountConfigured ? "Carrier account: configured." : "Carrier account: not configured. Do not choose a carrier."}</p>
|
|
1045
|
-
<p><a data-refresh href="${esc(href(view))}">Refresh</a></p>
|
|
1046
|
-
<nav data-queue-switch>${queueLinks}</nav>
|
|
1047
|
-
<form method="get" action="${SCRAPPY_FULFILLMENT_PATH}">
|
|
1048
|
-
<input type="hidden" name="actor" value="${esc(view.actorName)}">
|
|
1049
|
-
<input type="hidden" name="limit" value="${view.limit}">
|
|
1050
|
-
<label>Queue <select name="queue">
|
|
1051
|
-
<option value="ready"${view.queue === "ready" ? " selected" : ""}>Ready</option>
|
|
1052
|
-
<option value="held"${view.queue === "held" ? " selected" : ""}>Held</option>
|
|
1053
|
-
<option value="in_progress"${view.queue === "in_progress" ? " selected" : ""}>In progress</option>
|
|
1054
|
-
<option value="shipped"${view.queue === "shipped" ? " selected" : ""}>Shipped</option>
|
|
1055
|
-
<option value="all"${view.queue === "all" ? " selected" : ""}>All</option>
|
|
1056
|
-
</select></label>
|
|
1057
|
-
<label>Filter <input name="q" value="${esc(view.q)}"></label>
|
|
1058
|
-
<button type="submit">Apply filter</button>
|
|
1059
|
-
</form>
|
|
1060
|
-
<p data-counts>Storewide ready ${view.storewide.ready}. Held ${view.storewide.held}. In progress ${view.storewide.in_progress}. Shipped ${view.storewide.shipped}. Filter ${view.filterCount}. This page ${view.pageCount}.</p>
|
|
1061
|
-
${view.invalidCursor ? `<p data-invalid-cursor="1">Unknown page cursor. No rows on this page.</p>` : ""}
|
|
1062
|
-
<form id="scrappy-pick" method="post" action="${action}">${hiddenFields(view, "pick-batch")}<button type="submit">Build pick list</button></form>
|
|
1063
|
-
<table>
|
|
1064
|
-
<thead><tr><th>Pick</th><th>Order</th><th>Queue</th><th>Lines</th><th>Label</th><th>Evidence</th><th>Hold</th><th>Tracking number</th></tr></thead>
|
|
1065
|
-
<tbody>${rows}</tbody>
|
|
1066
|
-
</table>
|
|
1067
|
-
${next}
|
|
1068
|
-
<section data-pick-list><h3>Pick list</h3><ul>${pickItems}</ul></section>
|
|
1069
|
-
${details}
|
|
1070
|
-
</div>`;
|
|
1071
|
-
}
|