@replohq/canopy-sdk 2.6.0 → 3.0.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/_vendor/replo-utils/lib/fonts.mjs +1 -0
- package/_vendor/replo-utils/lib/geometry.mjs +2 -0
- package/_vendor/replo-utils/lib/json.mjs +1 -0
- package/_vendor/replo-utils/lib/misc.mjs +1 -0
- package/_vendor/replo-utils/lib/posthogReplay.mjs +2 -0
- package/_vendor/replo-utils/lib/url.mjs +1 -0
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +1 -1
- package/_vendor/schemas/designLibrary.mjs +1 -1
- package/_vendor/schemas/generated/consent.d.ts +2 -0
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +8 -0
- package/_vendor/schemas/iframeRpcChannel.mjs +2 -1
- package/_vendor/schemas/loaderKeys.d.ts +1 -1
- package/_vendor/schemas/loaderKeys.mjs +103 -23
- package/_vendor/schemas/money.mjs +1860 -3
- package/_vendor/schemas/pageAnnotations.mjs +1 -1
- package/_vendor/schemas/routing/match.mjs +1 -0
- package/_vendor/schemas/routing/rules.mjs +2 -1
- package/_vendor/schemas/selectMode.d.ts +4 -4
- package/_vendor/schemas/selectMode.mjs +1 -0
- package/_vendor/schemas/selectModeIframeRpc.d.ts +25 -5
- package/_vendor/schemas/selectModeIframeRpc.mjs +12 -3
- package/analytics/analytics-provider.d.ts +5 -10
- package/analytics/analytics-provider.js +14 -101
- package/analytics/analytics-provider.js.map +2 -2
- package/analytics/get-analytics-sinks.d.ts +2 -19
- package/analytics/get-analytics-sinks.js +9 -46
- package/analytics/get-analytics-sinks.js.map +2 -2
- package/analytics/hooks/use-product-viewed-analytics.d.ts +2 -6
- package/analytics/hooks/use-product-viewed-analytics.js +6 -28
- package/analytics/hooks/use-product-viewed-analytics.js.map +2 -2
- package/analytics/replo-first-party-pixel.d.ts +3 -12
- package/analytics/replo-first-party-pixel.js +8 -24
- package/analytics/replo-first-party-pixel.js.map +2 -2
- package/analytics/replo-pixel-script.d.ts +4 -10
- package/analytics/replo-pixel-script.js +9 -23
- package/analytics/replo-pixel-script.js.map +2 -2
- package/analytics/sinks/ga4-sink.d.ts +10 -9
- package/analytics/sinks/ga4-sink.js +99 -50
- package/analytics/sinks/ga4-sink.js.map +2 -2
- package/analytics/sinks/meta-sink.d.ts +5 -4
- package/analytics/sinks/meta-sink.js +82 -29
- package/analytics/sinks/meta-sink.js.map +2 -2
- package/analytics/sinks/pinterest-sink.d.ts +7 -6
- package/analytics/sinks/pinterest-sink.js +82 -49
- package/analytics/sinks/pinterest-sink.js.map +2 -2
- package/analytics/sinks/reddit-sink.d.ts +8 -7
- package/analytics/sinks/reddit-sink.js +82 -53
- package/analytics/sinks/reddit-sink.js.map +2 -2
- package/analytics/sinks/replo-sink.d.ts +9 -8
- package/analytics/sinks/replo-sink.js +89 -37
- package/analytics/sinks/replo-sink.js.map +2 -2
- package/analytics/sinks/snapchat-sink.d.ts +6 -5
- package/analytics/sinks/snapchat-sink.js +82 -40
- package/analytics/sinks/snapchat-sink.js.map +2 -2
- package/analytics/sinks/tiktok-sink.d.ts +8 -7
- package/analytics/sinks/tiktok-sink.js +82 -52
- package/analytics/sinks/tiktok-sink.js.map +2 -2
- package/analytics/sinks/window-sink.d.ts +11 -14
- package/analytics/sinks/window-sink.js +101 -28
- package/analytics/sinks/window-sink.js.map +2 -2
- package/analytics/utils/analytics-utils.d.ts +4 -2
- package/analytics/utils/analytics-utils.js +19 -123
- package/analytics/utils/analytics-utils.js.map +2 -2
- package/analytics/utils/navigation-tracker.d.ts +2 -1
- package/analytics/utils/navigation-tracker.js +37 -30
- package/analytics/utils/navigation-tracker.js.map +2 -2
- package/analytics/utils/shopify-funnel-gate.d.ts +2 -7
- package/analytics/utils/shopify-funnel-gate.js +8 -15
- package/analytics/utils/shopify-funnel-gate.js.map +2 -2
- package/cart/buy-now-action.d.ts +2 -9
- package/cart/buy-now-action.js +5 -97
- package/cart/buy-now-action.js.map +2 -2
- package/cart/cart-actions.d.ts +12 -56
- package/cart/cart-actions.js +88 -68
- package/cart/cart-actions.js.map +2 -2
- package/cart/cart-loader.d.ts +3 -9
- package/cart/cart-loader.js +14 -6
- package/cart/cart-loader.js.map +2 -2
- package/cart/cart-provider.d.ts +6 -58
- package/cart/cart-provider.js +13 -359
- package/cart/cart-provider.js.map +3 -3
- package/cart/cart-schema.d.ts +2 -1
- package/cart/cart-schema.js +12 -64
- package/cart/cart-schema.js.map +2 -2
- package/cart/cart-types.d.ts +1 -1
- package/cart/cart-types.js +5 -4
- package/cart/cart-types.js.map +2 -2
- package/cart/gateways/cart-constants.d.ts +1 -0
- package/cart/gateways/cart-constants.js.map +2 -2
- package/cart/gateways/cart-gateway.d.ts +1 -0
- package/cart/gateways/cart-gateway.js +13 -12
- package/cart/gateways/cart-gateway.js.map +2 -2
- package/cart/gateways/cookie-cart-gateway.d.ts +8 -11
- package/cart/gateways/cookie-cart-gateway.js +93 -97
- package/cart/gateways/cookie-cart-gateway.js.map +2 -2
- package/cart/gateways/default-cart-gateway.d.ts +10 -16
- package/cart/gateways/default-cart-gateway.js +13 -23
- package/cart/gateways/default-cart-gateway.js.map +2 -2
- package/cart/gateways/resolver-cart-gateway.d.ts +1 -0
- package/cart/gateways/resolver-cart-gateway.js +13 -102
- package/cart/gateways/resolver-cart-gateway.js.map +2 -2
- package/cart/gateways/stripe-cart-gateway.d.ts +10 -16
- package/cart/gateways/stripe-cart-gateway.js +13 -21
- package/cart/gateways/stripe-cart-gateway.js.map +2 -2
- package/cart/hooks/use-add-to-cart.d.ts +3 -47
- package/cart/hooks/use-add-to-cart.js +10 -115
- package/cart/hooks/use-add-to-cart.js.map +2 -2
- package/cart/hooks/use-buy-now.d.ts +1 -39
- package/cart/hooks/use-buy-now.js +5 -55
- package/cart/hooks/use-buy-now.js.map +2 -2
- package/cart/utils/cart-utils.d.ts +8 -35
- package/cart/utils/cart-utils.js +21 -35
- package/cart/utils/cart-utils.js.map +2 -2
- package/cart/utils/cookie-cart-persistence.d.ts +16 -41
- package/cart/utils/cookie-cart-persistence.js +38 -143
- package/cart/utils/cookie-cart-persistence.js.map +2 -2
- package/cart/utils/variant-to-cart-line.d.ts +12 -42
- package/cart/utils/variant-to-cart-line.js +31 -147
- package/cart/utils/variant-to-cart-line.js.map +2 -2
- package/chunk-UJCSKKID.mjs +27 -0
- package/{chunk-OFU2QEDR.mjs → chunk-ZZPQ3E7S.mjs} +50 -5
- package/consent/consent-action.d.ts +2 -1
- package/consent/consent-action.js +10 -20
- package/consent/consent-action.js.map +2 -2
- package/consent/consent-actions.d.ts +2 -13
- package/consent/consent-actions.js +9 -29
- package/consent/consent-actions.js.map +2 -2
- package/consent/consent-store.d.ts +9 -36
- package/consent/consent-store.js +12 -182
- package/consent/consent-store.js.map +2 -2
- package/consent/cookie.d.ts +9 -12
- package/consent/cookie.js +32 -64
- package/consent/cookie.js.map +2 -2
- package/consent/replo-scripts.d.ts +5 -18
- package/consent/replo-scripts.js +11 -94
- package/consent/replo-scripts.js.map +2 -2
- package/consent/script-registration-store.d.ts +6 -2
- package/consent/script-registration-store.js +33 -47
- package/consent/script-registration-store.js.map +2 -2
- package/consent/script-snippets.d.ts +4 -18
- package/consent/script-snippets.js +19 -127
- package/consent/script-snippets.js.map +2 -2
- package/consent/window-api.d.ts +4 -15
- package/consent/window-api.js +8 -63
- package/consent/window-api.js.map +2 -2
- package/editor/ClientErrorBoundary.d.ts +4 -10
- package/editor/ClientErrorBoundary.js +7 -55
- package/editor/ClientErrorBoundary.js.map +2 -2
- package/editor/DocumentReadyBeacon.d.ts +3 -1
- package/editor/DocumentReadyBeacon.js +6 -3
- package/editor/DocumentReadyBeacon.js.map +2 -2
- package/editor/LinkInterceptor.d.ts +1 -0
- package/editor/LinkInterceptor.js +6 -121
- package/editor/LinkInterceptor.js.map +2 -2
- package/editor/NextErrorReporter.d.ts +1 -0
- package/editor/NextErrorReporter.js +6 -85
- package/editor/NextErrorReporter.js.map +2 -2
- package/editor/annotations/AnnotationLayerMount.d.ts +1 -0
- package/editor/annotations/AnnotationLayerMount.js +6 -6
- package/editor/annotations/AnnotationLayerMount.js.map +2 -2
- package/editor/annotations/annotationController.d.ts +1 -0
- package/editor/annotations/annotationController.js +6 -378
- package/editor/annotations/annotationController.js.map +2 -2
- package/editor/annotations/bridgeGate.d.ts +4 -7
- package/editor/annotations/bridgeGate.js +13 -15
- package/editor/annotations/bridgeGate.js.map +2 -2
- package/editor/design-library-preview/DesignLibraryPreview.d.ts +1 -0
- package/editor/design-library-preview/DesignLibraryPreview.js +6 -86
- package/editor/design-library-preview/DesignLibraryPreview.js.map +2 -2
- package/editor/posthog-relay.d.ts +1 -10
- package/editor/posthog-relay.js +6 -65
- package/editor/posthog-relay.js.map +2 -2
- package/editor/select-mode/EditorSelection.d.ts +1 -23
- package/editor/select-mode/EditorSelection.js +5 -87
- package/editor/select-mode/EditorSelection.js.map +2 -2
- package/editor/select-mode/annotationFrames.d.ts +9 -9
- package/editor/select-mode/annotationFrames.js +22 -103
- package/editor/select-mode/annotationFrames.js.map +2 -2
- package/editor/select-mode/descriptor/elementDescriptor.d.ts +6 -21
- package/editor/select-mode/descriptor/elementDescriptor.js +19 -192
- package/editor/select-mode/descriptor/elementDescriptor.js.map +3 -3
- package/editor/select-mode/descriptor/styleExtraction.d.ts +4 -2
- package/editor/select-mode/descriptor/styleExtraction.js +11 -262
- package/editor/select-mode/descriptor/styleExtraction.js.map +2 -2
- package/editor/select-mode/displayModeStore.d.ts +2 -0
- package/editor/select-mode/displayModeStore.js +14 -39
- package/editor/select-mode/displayModeStore.js.map +2 -2
- package/editor/select-mode/fast-refresh-relay.d.ts +2 -1
- package/editor/select-mode/fast-refresh-relay.js +7 -28
- package/editor/select-mode/fast-refresh-relay.js.map +2 -2
- package/editor/select-mode/fiber.d.ts +14 -7
- package/editor/select-mode/fiber.js +40 -286
- package/editor/select-mode/fiber.js.map +2 -2
- package/editor/select-mode/hooks/useCrosshairCursor.d.ts +2 -9
- package/editor/select-mode/hooks/useCrosshairCursor.js +7 -15
- package/editor/select-mode/hooks/useCrosshairCursor.js.map +2 -2
- package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +5 -3
- package/editor/select-mode/hooks/useEditModeStateMachine.js +13 -228
- package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
- package/editor/select-mode/hooks/useOptimisticOverrides.d.ts +2 -1
- package/editor/select-mode/hooks/useOptimisticOverrides.js +6 -277
- package/editor/select-mode/hooks/useOptimisticOverrides.js.map +2 -2
- package/editor/select-mode/hooks/useParentMessaging.d.ts +2 -20
- package/editor/select-mode/hooks/useParentMessaging.js +7 -69
- package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
- package/editor/select-mode/hooks/useSelectModeController.d.ts +2 -1
- package/editor/select-mode/hooks/useSelectModeController.js +6 -40
- package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionHover.d.ts +2 -16
- package/editor/select-mode/hooks/useSelectionHover.js +7 -105
- package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionInteractions.d.ts +2 -26
- package/editor/select-mode/hooks/useSelectionInteractions.js +7 -348
- package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionScrollSync.d.ts +2 -22
- package/editor/select-mode/hooks/useSelectionScrollSync.js +7 -65
- package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
- package/editor/select-mode/hooks/useSiblingResolution.d.ts +4 -2
- package/editor/select-mode/hooks/useSiblingResolution.js +13 -52
- package/editor/select-mode/hooks/useSiblingResolution.js.map +2 -2
- package/editor/select-mode/iframeRpcChannel.d.ts +10 -349
- package/editor/select-mode/iframeRpcChannel.js +23 -79
- package/editor/select-mode/iframeRpcChannel.js.map +2 -2
- package/editor/select-mode/inlineTextMarks.d.ts +4 -6
- package/editor/select-mode/inlineTextMarks.js +13 -18
- package/editor/select-mode/inlineTextMarks.js.map +2 -2
- package/editor/select-mode/interactions/selectionGeometry.d.ts +19 -61
- package/editor/select-mode/interactions/selectionGeometry.js +57 -165
- package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
- package/editor/select-mode/selectModeSession.d.ts +1 -0
- package/editor/select-mode/selectModeSession.js +6 -3
- package/editor/select-mode/selectModeSession.js.map +2 -2
- package/editor/select-mode/selectionFrame.d.ts +9 -60
- package/editor/select-mode/selectionFrame.js +28 -116
- package/editor/select-mode/selectionFrame.js.map +2 -2
- package/editor/select-mode/symbolicate.d.ts +2 -1
- package/editor/select-mode/symbolicate.js +7 -195
- package/editor/select-mode/symbolicate.js.map +2 -2
- package/editor/select-mode/tiptapInlineEditor.d.ts +15 -2
- package/editor/select-mode/tiptapInlineEditor.js +6 -114
- package/editor/select-mode/tiptapInlineEditor.js.map +2 -2
- package/env.d.ts +2 -1
- package/env.js +10 -37
- package/env.js.map +2 -2
- package/gateways/canopy-api.d.ts +15 -12
- package/gateways/canopy-api.js +122 -160
- package/gateways/canopy-api.js.map +2 -2
- package/hooks/use-client-value.d.ts +2 -10
- package/hooks/use-client-value.js +10 -7
- package/hooks/use-client-value.js.map +2 -2
- package/hooks/use-formatted-price.d.ts +1 -14
- package/hooks/use-formatted-price.js +6 -14
- package/hooks/use-formatted-price.js.map +2 -2
- package/lib/canopy-error.d.ts +2 -5
- package/lib/canopy-error.js +10 -14
- package/lib/canopy-error.js.map +2 -2
- package/lib/get-query-client.d.ts +2 -1
- package/lib/get-query-client.js +8 -27
- package/lib/get-query-client.js.map +2 -2
- package/lib/integration-utils.d.ts +1 -0
- package/lib/integration-utils.js +9 -3
- package/lib/integration-utils.js.map +2 -2
- package/lib/shopify-utils.d.ts +2 -10
- package/lib/shopify-utils.js +10 -2
- package/lib/shopify-utils.js.map +2 -2
- package/lib/tombstone.d.ts +21 -0
- package/lib/tombstone.js +99 -0
- package/lib/tombstone.js.map +7 -0
- package/lib/url-utils.d.ts +2 -4
- package/lib/url-utils.js +10 -3
- package/lib/url-utils.js.map +2 -2
- package/loaders/collection-loader.d.ts +3 -2
- package/loaders/collection-loader.js +5 -48
- package/loaders/collection-loader.js.map +2 -2
- package/loaders/collection-products-loader.d.ts +3 -2
- package/loaders/collection-products-loader.js +5 -51
- package/loaders/collection-products-loader.js.map +2 -2
- package/loaders/contentful-entries-loader.d.ts +3 -2
- package/loaders/contentful-entries-loader.js +5 -71
- package/loaders/contentful-entries-loader.js.map +2 -2
- package/loaders/contentful-entry-loader.d.ts +3 -2
- package/loaders/contentful-entry-loader.js +5 -53
- package/loaders/contentful-entry-loader.js.map +2 -2
- package/loaders/invoke-loader-action.d.ts +2 -8
- package/loaders/invoke-loader-action.js +13 -8
- package/loaders/invoke-loader-action.js.map +2 -2
- package/loaders/invoke-loader-server.d.ts +2 -14
- package/loaders/invoke-loader-server.js +12 -34
- package/loaders/invoke-loader-server.js.map +2 -2
- package/loaders/invoke-loader.d.ts +6 -12
- package/loaders/invoke-loader.js +27 -29
- package/loaders/invoke-loader.js.map +2 -2
- package/loaders/levanta-product-loader.d.ts +3 -2
- package/loaders/levanta-product-loader.js +5 -46
- package/loaders/levanta-product-loader.js.map +2 -2
- package/loaders/loader-error-boundary.d.ts +9 -15
- package/loaders/loader-error-boundary.js +50 -13
- package/loaders/loader-error-boundary.js.map +2 -2
- package/loaders/loader-keys.d.ts +4 -12
- package/loaders/loader-keys.js +6 -1
- package/loaders/loader-keys.js.map +2 -2
- package/loaders/loader-schemas.d.ts +142 -61
- package/loaders/loader-schemas.js +253 -90
- package/loaders/loader-schemas.js.map +2 -2
- package/loaders/metaobject-loader.d.ts +3 -2
- package/loaders/metaobject-loader.js +5 -47
- package/loaders/metaobject-loader.js.map +2 -2
- package/loaders/metaobjects-loader.d.ts +3 -2
- package/loaders/metaobjects-loader.js +5 -53
- package/loaders/metaobjects-loader.js.map +2 -2
- package/loaders/okendo-review-aggregate-loader.d.ts +9 -10
- package/loaders/okendo-review-aggregate-loader.js +5 -49
- package/loaders/okendo-review-aggregate-loader.js.map +2 -2
- package/loaders/okendo-reviews-loader.d.ts +8 -16
- package/loaders/okendo-reviews-loader.js +5 -47
- package/loaders/okendo-reviews-loader.js.map +2 -2
- package/loaders/prefetch-loaders.d.ts +4 -26
- package/loaders/prefetch-loaders.js +5 -40
- package/loaders/prefetch-loaders.js.map +2 -2
- package/loaders/preview-placeholder.d.ts +8 -22
- package/loaders/preview-placeholder.js +47 -209
- package/loaders/preview-placeholder.js.map +2 -2
- package/loaders/product-loader-args.d.ts +2 -11
- package/loaders/product-loader-args.js +6 -12
- package/loaders/product-loader-args.js.map +2 -2
- package/loaders/product-loader.d.ts +3 -2
- package/loaders/product-loader.js +5 -45
- package/loaders/product-loader.js.map +2 -2
- package/loaders/rebuy-recommendations-loader.d.ts +8 -157
- package/loaders/rebuy-recommendations-loader.js +5 -50
- package/loaders/rebuy-recommendations-loader.js.map +2 -2
- package/loaders/reviews-io-review-aggregate-loader.d.ts +5 -4
- package/loaders/reviews-io-review-aggregate-loader.js +5 -36
- package/loaders/reviews-io-review-aggregate-loader.js.map +2 -2
- package/loaders/reviews-io-reviews-loader.d.ts +5 -4
- package/loaders/reviews-io-reviews-loader.js +5 -58
- package/loaders/reviews-io-reviews-loader.js.map +2 -2
- package/loaders/smile-earning-rules-loader.d.ts +10 -11
- package/loaders/smile-earning-rules-loader.js +5 -37
- package/loaders/smile-earning-rules-loader.js.map +2 -2
- package/loaders/smile-rewards-loader.d.ts +10 -11
- package/loaders/smile-rewards-loader.js +5 -37
- package/loaders/smile-rewards-loader.js.map +2 -2
- package/loaders/smile-vip-tiers-loader.d.ts +9 -10
- package/loaders/smile-vip-tiers-loader.js +5 -36
- package/loaders/smile-vip-tiers-loader.js.map +2 -2
- package/loaders/statsig-experiment-loader.d.ts +3 -8
- package/loaders/statsig-experiment-loader.js +5 -74
- package/loaders/statsig-experiment-loader.js.map +2 -2
- package/loaders/vendor-loader-keys.d.ts +4 -0
- package/loaders/vendor-loader-keys.js +9 -0
- package/loaders/vendor-loader-keys.js.map +7 -0
- package/loaders/yotpo-review-aggregate-loader.d.ts +5 -4
- package/loaders/yotpo-review-aggregate-loader.js +5 -43
- package/loaders/yotpo-review-aggregate-loader.js.map +2 -2
- package/loaders/yotpo-reviews-loader.d.ts +5 -4
- package/loaders/yotpo-reviews-loader.js +5 -58
- package/loaders/yotpo-reviews-loader.js.map +2 -2
- package/money.d.ts +9 -9
- package/money.js +25 -6
- package/money.js.map +2 -2
- package/next/config.d.ts +3 -1
- package/next/config.js +11 -85
- package/next/config.js.map +2 -2
- package/next/image-loader.d.ts +2 -1
- package/next/image-loader.js +7 -47
- package/next/image-loader.js.map +2 -2
- package/next/open-next.d.ts +4 -2
- package/next/open-next.js +6 -19
- package/next/open-next.js.map +2 -2
- package/orders/order-status-schema.d.ts +28 -13
- package/orders/order-status-schema.js +45 -13
- package/orders/order-status-schema.js.map +2 -2
- package/orders/order-status.d.ts +2 -8
- package/orders/order-status.js +6 -36
- package/orders/order-status.js.map +2 -2
- package/package.json +1 -12
- package/providers/query-provider.d.ts +3 -1
- package/providers/query-provider.js +10 -6
- package/providers/query-provider.js.map +2 -2
- package/providers/replo-provider.d.ts +3 -1
- package/providers/replo-provider.js +6 -37
- package/providers/replo-provider.js.map +2 -2
- package/routing/evaluate.d.ts +3 -3
- package/routing/evaluate.js +5 -40
- package/routing/evaluate.js.map +2 -2
- package/routing/rules.d.ts +3 -11
- package/routing/rules.js +7 -1
- package/routing/rules.js.map +2 -2
|
@@ -1,55 +1,30 @@
|
|
|
1
1
|
import type { AddToCartPayload, Cart, CartLine, CartLinePayload, RemoveFromCartPayload, UpdateCartLineItemPayload } from "../cart-types";
|
|
2
|
-
/**
|
|
3
|
-
* Line merge function type - returns index of existing line to merge with, or -1 to add as new line
|
|
4
|
-
*/
|
|
5
2
|
export type LineMergeFn = (existingLines: CartLine[], newLine: CartLinePayload) => number;
|
|
6
|
-
/**
|
|
7
|
-
* Options for creating a cart with persistence
|
|
8
|
-
*/
|
|
9
3
|
interface CreateCartOptions {
|
|
10
4
|
cookieName: string;
|
|
11
5
|
lines?: CartLinePayload[];
|
|
12
6
|
lineIdGenerator: () => string;
|
|
13
7
|
cartIdGenerator: () => string;
|
|
14
8
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Options for adding to cart with persistence
|
|
17
|
-
*/
|
|
18
9
|
interface AddToCartOptions {
|
|
19
10
|
cookieName: string;
|
|
20
11
|
mergeFn: LineMergeFn;
|
|
21
12
|
lineIdGenerator: () => string;
|
|
22
13
|
}
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
export declare function
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
export declare function
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
export declare function
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
export declare function
|
|
39
|
-
/**
|
|
40
|
-
* Create a new cart with persistence
|
|
41
|
-
*/
|
|
42
|
-
export declare function createCartWithPersistence(options: CreateCartOptions): Promise<Cart | null>;
|
|
43
|
-
/**
|
|
44
|
-
* Add lines to cart with configurable line merging strategy
|
|
45
|
-
*/
|
|
46
|
-
export declare function addToCartWithPersistence(payload: AddToCartPayload, options: AddToCartOptions): Promise<Cart | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Update cart line item
|
|
49
|
-
*/
|
|
50
|
-
export declare function updateCartLineItemWithPersistence(payload: UpdateCartLineItemPayload, cookieName: string): Promise<Cart | null>;
|
|
51
|
-
/**
|
|
52
|
-
* Remove cart line items
|
|
53
|
-
*/
|
|
54
|
-
export declare function removeCartLineItemsWithPersistence(payload: RemoveFromCartPayload, cookieName: string): Promise<Cart | null>;
|
|
14
|
+
/** @deprecated Use saveCartToCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
15
|
+
export declare function saveCartToCookie(_cart: Cart, _cookieName: string): Promise<void>;
|
|
16
|
+
/** @deprecated Use loadCartFromCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
17
|
+
export declare function loadCartFromCookie(_cookieName: string): Promise<Cart | null>;
|
|
18
|
+
/** @deprecated Use clearCartCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
19
|
+
export declare function clearCartCookie(_cookieName: string): Promise<void>;
|
|
20
|
+
/** @deprecated Use updateCartInCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
21
|
+
export declare function updateCartInCookie(_cartId: string, _cookieName: string, _updater: (cart: Cart) => Cart): Promise<Cart | null>;
|
|
22
|
+
/** @deprecated Use createCartWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
23
|
+
export declare function createCartWithPersistence(_options: CreateCartOptions): Promise<Cart | null>;
|
|
24
|
+
/** @deprecated Use addToCartWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
25
|
+
export declare function addToCartWithPersistence(_payload: AddToCartPayload, _options: AddToCartOptions): Promise<Cart | null>;
|
|
26
|
+
/** @deprecated Use updateCartLineItemWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
27
|
+
export declare function updateCartLineItemWithPersistence(_payload: UpdateCartLineItemPayload, _cookieName: string): Promise<Cart | null>;
|
|
28
|
+
/** @deprecated Use removeCartLineItemsWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */
|
|
29
|
+
export declare function removeCartLineItemsWithPersistence(_payload: RemoveFromCartPayload, _cookieName: string): Promise<Cart | null>;
|
|
55
30
|
export {};
|
|
@@ -1,157 +1,52 @@
|
|
|
1
1
|
"use server";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
...cart,
|
|
9
|
-
cost: {
|
|
10
|
-
...cart.cost,
|
|
11
|
-
subtotalAmount: subtotal,
|
|
12
|
-
totalAmount: subtotal
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
async function saveCartToCookie(cart, cookieName) {
|
|
17
|
-
const cookieStore = await cookies();
|
|
18
|
-
cookieStore.set(cookieName, JSON.stringify(cart), {
|
|
19
|
-
maxAge: CART_COOKIE_MAX_AGE,
|
|
20
|
-
httpOnly: true,
|
|
21
|
-
secure: process.env.NODE_ENV === "production",
|
|
22
|
-
sameSite: "lax",
|
|
23
|
-
path: "/"
|
|
2
|
+
import { canopyTombstoneError } from "../../lib/tombstone";
|
|
3
|
+
async function saveCartToCookie(_cart, _cookieName) {
|
|
4
|
+
throw canopyTombstoneError({
|
|
5
|
+
symbol: "saveCartToCookie",
|
|
6
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
24
7
|
});
|
|
25
8
|
}
|
|
26
|
-
async function loadCartFromCookie(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
return JSON.parse(cartCookie.value);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.warn("Failed to parse cart cookie:", error);
|
|
36
|
-
await clearCartCookie(cookieName);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function clearCartCookie(cookieName) {
|
|
41
|
-
const cookieStore = await cookies();
|
|
42
|
-
cookieStore.delete(cookieName);
|
|
9
|
+
async function loadCartFromCookie(_cookieName) {
|
|
10
|
+
throw canopyTombstoneError({
|
|
11
|
+
symbol: "loadCartFromCookie",
|
|
12
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
13
|
+
});
|
|
43
14
|
}
|
|
44
|
-
async function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
const updatedCart = recalculateCartCost(updater(existingCart));
|
|
50
|
-
await saveCartToCookie(updatedCart, cookieName);
|
|
51
|
-
return updatedCart;
|
|
15
|
+
async function clearCartCookie(_cookieName) {
|
|
16
|
+
throw canopyTombstoneError({
|
|
17
|
+
symbol: "clearCartCookie",
|
|
18
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
19
|
+
});
|
|
52
20
|
}
|
|
53
|
-
async function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
cost: {
|
|
59
|
-
subtotalAmount: 0,
|
|
60
|
-
totalAmount: 0,
|
|
61
|
-
currencyCode: "USD"
|
|
62
|
-
},
|
|
63
|
-
checkoutUrl: "/checkout"
|
|
64
|
-
};
|
|
65
|
-
for (const line of options.lines ?? []) {
|
|
66
|
-
cart.lines.push(
|
|
67
|
-
convertCartLinePayloadToCartLine(line, options.lineIdGenerator)
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
const cartWithCost = recalculateCartCost(cart);
|
|
71
|
-
await saveCartToCookie(cartWithCost, options.cookieName);
|
|
72
|
-
return cartWithCost;
|
|
21
|
+
async function updateCartInCookie(_cartId, _cookieName, _updater) {
|
|
22
|
+
throw canopyTombstoneError({
|
|
23
|
+
symbol: "updateCartInCookie",
|
|
24
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
25
|
+
});
|
|
73
26
|
}
|
|
74
|
-
async function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
for (const linePayload of payload.lines) {
|
|
80
|
-
const existingLineIndex = options.mergeFn(cart.lines, linePayload);
|
|
81
|
-
if (existingLineIndex >= 0) {
|
|
82
|
-
cart.lines[existingLineIndex].quantity += linePayload.quantity;
|
|
83
|
-
} else {
|
|
84
|
-
const newLine = convertCartLinePayloadToCartLine(
|
|
85
|
-
linePayload,
|
|
86
|
-
options.lineIdGenerator
|
|
87
|
-
);
|
|
88
|
-
cart.lines.push(newLine);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return cart;
|
|
92
|
-
}
|
|
93
|
-
);
|
|
27
|
+
async function createCartWithPersistence(_options) {
|
|
28
|
+
throw canopyTombstoneError({
|
|
29
|
+
symbol: "createCartWithPersistence",
|
|
30
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
31
|
+
});
|
|
94
32
|
}
|
|
95
|
-
async function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
100
|
-
if (lineIndex >= 0) {
|
|
101
|
-
if (payload.line.quantity <= 0) {
|
|
102
|
-
cart.lines.splice(lineIndex, 1);
|
|
103
|
-
} else {
|
|
104
|
-
cart.lines[lineIndex].quantity = payload.line.quantity;
|
|
105
|
-
if (payload.line.properties) {
|
|
106
|
-
cart.lines[lineIndex].attributes = payload.line.properties;
|
|
107
|
-
}
|
|
108
|
-
if (payload.line.merchandise) {
|
|
109
|
-
cart.lines[lineIndex].merchandise = payload.line.merchandise;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return cart;
|
|
33
|
+
async function addToCartWithPersistence(_payload, _options) {
|
|
34
|
+
throw canopyTombstoneError({
|
|
35
|
+
symbol: "addToCartWithPersistence",
|
|
36
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
114
37
|
});
|
|
115
38
|
}
|
|
116
|
-
async function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return cart;
|
|
39
|
+
async function updateCartLineItemWithPersistence(_payload, _cookieName) {
|
|
40
|
+
throw canopyTombstoneError({
|
|
41
|
+
symbol: "updateCartLineItemWithPersistence",
|
|
42
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
121
43
|
});
|
|
122
44
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
title: linePayload.merchandise?.product.title ?? "Product"
|
|
129
|
-
},
|
|
130
|
-
title: linePayload.merchandise?.title ?? "Product Variant",
|
|
131
|
-
price: linePayload.merchandise?.price ?? 0,
|
|
132
|
-
compareAtPrice: linePayload.merchandise?.compareAtPrice ?? null,
|
|
133
|
-
image: linePayload.merchandise?.image ? {
|
|
134
|
-
url: linePayload.merchandise.image.url,
|
|
135
|
-
altText: linePayload.merchandise.image.altText
|
|
136
|
-
} : null,
|
|
137
|
-
selectedOptions: linePayload.merchandise?.selectedOptions ?? []
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
id: lineIdGenerator(),
|
|
141
|
-
quantity: linePayload.quantity,
|
|
142
|
-
merchandise: linePayload.merchandise ?? fallbackMerchandise,
|
|
143
|
-
attributes: linePayload.properties ?? [],
|
|
144
|
-
sellingPlanAllocation: linePayload.sellingPlanId ? {
|
|
145
|
-
sellingPlan: {
|
|
146
|
-
id: linePayload.sellingPlanId,
|
|
147
|
-
name: "Subscription Plan",
|
|
148
|
-
description: null
|
|
149
|
-
},
|
|
150
|
-
priceAdjustments: [],
|
|
151
|
-
checkoutChargeAmount: { amount: 0, currencyCode: "USD" },
|
|
152
|
-
remainingBalanceChargeAmount: { amount: 0, currencyCode: "USD" }
|
|
153
|
-
} : null
|
|
154
|
-
};
|
|
45
|
+
async function removeCartLineItemsWithPersistence(_payload, _cookieName) {
|
|
46
|
+
throw canopyTombstoneError({
|
|
47
|
+
symbol: "removeCartLineItemsWithPersistence",
|
|
48
|
+
subpath: "cart/utils/cookie-cart-persistence"
|
|
49
|
+
});
|
|
155
50
|
}
|
|
156
51
|
export {
|
|
157
52
|
addToCartWithPersistence,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../cart/utils/cookie-cart-persistence.ts"],
|
|
4
|
-
"sourcesContent": ["\"use server\";\n\nimport type {\n AddToCartPayload,\n Cart,\n CartLine,\n CartLinePayload,\n RemoveFromCartPayload,\n UpdateCartLineItemPayload,\n} from \"../cart-types\";\n\nimport {
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use server\";\n\n/* eslint-disable replo/no-void-return-type -- Tombstones preserve canopy 2.3.0's explicit public return types. */\nimport type {\n AddToCartPayload,\n Cart,\n CartLine,\n CartLinePayload,\n RemoveFromCartPayload,\n UpdateCartLineItemPayload,\n} from \"../cart-types\";\n\nimport { canopyTombstoneError } from \"../../lib/tombstone\";\n\nexport type LineMergeFn = (\n existingLines: CartLine[],\n newLine: CartLinePayload,\n) => number;\n\ninterface CreateCartOptions {\n cookieName: string;\n lines?: CartLinePayload[];\n lineIdGenerator: () => string;\n cartIdGenerator: () => string;\n}\n\ninterface AddToCartOptions {\n cookieName: string;\n mergeFn: LineMergeFn;\n lineIdGenerator: () => string;\n}\n\n/** @deprecated Use saveCartToCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function saveCartToCookie(\n _cart: Cart,\n _cookieName: string,\n): Promise<void> {\n throw canopyTombstoneError({\n symbol: \"saveCartToCookie\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use loadCartFromCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function loadCartFromCookie(\n _cookieName: string,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"loadCartFromCookie\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use clearCartCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function clearCartCookie(_cookieName: string): Promise<void> {\n throw canopyTombstoneError({\n symbol: \"clearCartCookie\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use updateCartInCookie from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function updateCartInCookie(\n _cartId: string,\n _cookieName: string,\n _updater: (cart: Cart) => Cart,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"updateCartInCookie\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use createCartWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function createCartWithPersistence(\n _options: CreateCartOptions,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"createCartWithPersistence\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use addToCartWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function addToCartWithPersistence(\n _payload: AddToCartPayload,\n _options: AddToCartOptions,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"addToCartWithPersistence\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use updateCartLineItemWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function updateCartLineItemWithPersistence(\n _payload: UpdateCartLineItemPayload,\n _cookieName: string,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"updateCartLineItemWithPersistence\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n\n/** @deprecated Use removeCartLineItemsWithPersistence from @replohq/sdk/cart/utils/cookie-cart-persistence. */\nexport async function removeCartLineItemsWithPersistence(\n _payload: RemoveFromCartPayload,\n _cookieName: string,\n): Promise<Cart | null> {\n throw canopyTombstoneError({\n symbol: \"removeCartLineItemsWithPersistence\",\n subpath: \"cart/utils/cookie-cart-persistence\",\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,4BAA4B;AAqBrC,eAAsB,iBACpB,OACA,aACe;AACf,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,mBACpB,aACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,gBAAgB,aAAoC;AACxE,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,mBACpB,SACA,aACA,UACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,0BACpB,UACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,yBACpB,UACA,UACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,kCACpB,UACA,aACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGA,eAAsB,mCACpB,UACA,aACsB;AACtB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,54 +1,27 @@
|
|
|
1
1
|
import type { CartLine, CartLineMerchandise, SellingPlanAllocation } from "../cart-types";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @param key - The attribute key to retrieve
|
|
7
|
-
* @returns The attribute value, or undefined if not found
|
|
8
|
-
*/
|
|
9
|
-
export declare function getCartLineAttribute(cartLine: CartLine, key: string): string | number | boolean | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Calculates pricing information for a cart line, including discounts and
|
|
12
|
-
* selling plan adjustments.
|
|
13
|
-
*
|
|
14
|
-
* @param cartLine - The cart line to calculate pricing for
|
|
15
|
-
* @returns Object containing compareAtPrice, discountPercentage, hasDiscount, sellingPlanAdjustedPrice, and finalPrice
|
|
16
|
-
*/
|
|
17
|
-
export declare function getCartLinePricing(cartLine: CartLine): {
|
|
2
|
+
/** @deprecated Use getCartLineAttribute from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
3
|
+
export declare function getCartLineAttribute(_cartLine: CartLine, _key: string): string | number | boolean | undefined;
|
|
4
|
+
/** @deprecated Use getCartLinePricing from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
5
|
+
export declare function getCartLinePricing(_cartLine: CartLine): {
|
|
18
6
|
compareAtPrice: number;
|
|
19
7
|
discountPercentage: number;
|
|
20
8
|
hasDiscount: boolean;
|
|
21
9
|
sellingPlanAdjustedPrice: number;
|
|
22
10
|
finalPrice: number;
|
|
23
11
|
};
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
*
|
|
27
|
-
* @param cartLine - The cart line to get bundle info from
|
|
28
|
-
* @returns Object containing bundle ID, discount, and whether it's a bundle item
|
|
29
|
-
*/
|
|
30
|
-
export declare function getCartLineBundleInfo(cartLine: CartLine): {
|
|
12
|
+
/** @deprecated Use getCartLineBundleInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
13
|
+
export declare function getCartLineBundleInfo(_cartLine: CartLine): {
|
|
31
14
|
bundleId: string;
|
|
32
15
|
bundleDiscount: number;
|
|
33
16
|
isBundleItem: boolean;
|
|
34
17
|
};
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* @param cartLine - The cart line to get special info from
|
|
39
|
-
* @returns Object containing whether it's a special item and any special instructions
|
|
40
|
-
*/
|
|
41
|
-
export declare function getCartLineSpecialInfo(cartLine: CartLine): {
|
|
18
|
+
/** @deprecated Use getCartLineSpecialInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
19
|
+
export declare function getCartLineSpecialInfo(_cartLine: CartLine): {
|
|
42
20
|
isSpecialItem: boolean;
|
|
43
21
|
specialInstructions: string[];
|
|
44
22
|
};
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
*
|
|
48
|
-
* @param cartLine - The cart line to get subscription info from
|
|
49
|
-
* @returns Object containing isSubscription, frequency, discount, and sellingPlan
|
|
50
|
-
*/
|
|
51
|
-
export declare function getCartLineSubscriptionInfo(cartLine: CartLine): {
|
|
23
|
+
/** @deprecated Use getCartLineSubscriptionInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
24
|
+
export declare function getCartLineSubscriptionInfo(_cartLine: CartLine): {
|
|
52
25
|
isSubscription: boolean;
|
|
53
26
|
frequency: string;
|
|
54
27
|
discount: number;
|
|
@@ -63,11 +36,8 @@ export declare function getCartLineSubscriptionInfo(cartLine: CartLine): {
|
|
|
63
36
|
discount: number;
|
|
64
37
|
sellingPlan: null;
|
|
65
38
|
};
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
* This matches the exact structure that Shopify returns so the UI doesn't need conditional logic.
|
|
69
|
-
*/
|
|
70
|
-
export declare function createOptimisticSellingPlanAllocation({ merchandise, sellingPlanId, currencyCode, }: {
|
|
39
|
+
/** @deprecated Use createOptimisticSellingPlanAllocation from @replohq/sdk/cart/utils/variant-to-cart-line. */
|
|
40
|
+
export declare function createOptimisticSellingPlanAllocation(_options: {
|
|
71
41
|
merchandise: CartLineMerchandise;
|
|
72
42
|
sellingPlanId: string | null;
|
|
73
43
|
currencyCode?: string;
|
|
@@ -1,155 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// cart boundary. Percentage is unitless and needs no conversion.
|
|
8
|
-
case "price":
|
|
9
|
-
return fromMajorUnitsToMinorUnits({
|
|
10
|
-
amount: adjustment.value,
|
|
11
|
-
currencyCode
|
|
12
|
-
});
|
|
13
|
-
case "percentage":
|
|
14
|
-
return Math.max(
|
|
15
|
-
0,
|
|
16
|
-
Math.round(variantPrice * (1 - adjustment.value / 100))
|
|
17
|
-
);
|
|
18
|
-
case "fixedAmount":
|
|
19
|
-
return Math.max(
|
|
20
|
-
0,
|
|
21
|
-
variantPrice - fromMajorUnitsToMinorUnits({
|
|
22
|
-
amount: adjustment.value,
|
|
23
|
-
currencyCode
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
}
|
|
1
|
+
import { canopyTombstoneError } from "../../lib/tombstone";
|
|
2
|
+
function getCartLineAttribute(_cartLine, _key) {
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "getCartLineAttribute",
|
|
5
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
6
|
+
});
|
|
27
7
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
8
|
+
function getCartLinePricing(_cartLine) {
|
|
9
|
+
throw canopyTombstoneError({
|
|
10
|
+
symbol: "getCartLinePricing",
|
|
11
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
12
|
+
});
|
|
30
13
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
hasDiscount: false,
|
|
37
|
-
sellingPlanAdjustedPrice: 0,
|
|
38
|
-
finalPrice: 0
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const compareAtPrice = cartLine.merchandise.compareAtPrice ?? 0;
|
|
42
|
-
const currentPrice = cartLine.merchandise.price;
|
|
43
|
-
const discountPercentage = compareAtPrice > currentPrice ? (compareAtPrice - currentPrice) / compareAtPrice * 100 : 0;
|
|
44
|
-
const hasDiscount = compareAtPrice > currentPrice;
|
|
45
|
-
let sellingPlanAdjustedPrice = cartLine.merchandise.price;
|
|
46
|
-
if (cartLine.sellingPlanAllocation && cartLine.sellingPlanAllocation.priceAdjustments.length > 0 && cartLine.sellingPlanAllocation.priceAdjustments[0]?.price) {
|
|
47
|
-
sellingPlanAdjustedPrice = cartLine.sellingPlanAllocation.priceAdjustments[0].price.amount;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
compareAtPrice,
|
|
51
|
-
discountPercentage,
|
|
52
|
-
hasDiscount,
|
|
53
|
-
sellingPlanAdjustedPrice,
|
|
54
|
-
finalPrice: sellingPlanAdjustedPrice
|
|
55
|
-
};
|
|
14
|
+
function getCartLineBundleInfo(_cartLine) {
|
|
15
|
+
throw canopyTombstoneError({
|
|
16
|
+
symbol: "getCartLineBundleInfo",
|
|
17
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
18
|
+
});
|
|
56
19
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
62
|
-
const isBundleItem = getCartLineAttribute(
|
|
63
|
-
cartLine,
|
|
64
|
-
"isBundleItem"
|
|
65
|
-
);
|
|
66
|
-
return {
|
|
67
|
-
bundleId: bundleId ?? null,
|
|
68
|
-
bundleDiscount,
|
|
69
|
-
isBundleItem: isBundleItem ?? false
|
|
70
|
-
};
|
|
20
|
+
function getCartLineSpecialInfo(_cartLine) {
|
|
21
|
+
throw canopyTombstoneError({
|
|
22
|
+
symbol: "getCartLineSpecialInfo",
|
|
23
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
24
|
+
});
|
|
71
25
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
);
|
|
77
|
-
const specialInstructions = getCartLineAttribute(
|
|
78
|
-
cartLine,
|
|
79
|
-
"specialInstructions"
|
|
80
|
-
);
|
|
81
|
-
return {
|
|
82
|
-
isSpecialItem: isSpecialItem ?? false,
|
|
83
|
-
specialInstructions: specialInstructions ? specialInstructions.split("|") : []
|
|
84
|
-
};
|
|
26
|
+
function getCartLineSubscriptionInfo(_cartLine) {
|
|
27
|
+
throw canopyTombstoneError({
|
|
28
|
+
symbol: "getCartLineSubscriptionInfo",
|
|
29
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
30
|
+
});
|
|
85
31
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
discount: 0,
|
|
92
|
-
// Shopify calculates this from price adjustments when available
|
|
93
|
-
sellingPlan: cartLine.sellingPlanAllocation.sellingPlan
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
isSubscription: false,
|
|
98
|
-
frequency: null,
|
|
99
|
-
discount: 0,
|
|
100
|
-
sellingPlan: null
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function createOptimisticSellingPlanAllocation({
|
|
104
|
-
merchandise,
|
|
105
|
-
sellingPlanId,
|
|
106
|
-
currencyCode = "USD"
|
|
107
|
-
}) {
|
|
108
|
-
const { product, price: variantPrice } = merchandise;
|
|
109
|
-
if (!sellingPlanId || !product.sellingPlanGroups) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
for (const group of product.sellingPlanGroups) {
|
|
113
|
-
const sellingPlan = group.sellingPlans.find(
|
|
114
|
-
(sp) => sp.id === sellingPlanId
|
|
115
|
-
);
|
|
116
|
-
if (sellingPlan) {
|
|
117
|
-
return {
|
|
118
|
-
sellingPlan: {
|
|
119
|
-
id: sellingPlan.id,
|
|
120
|
-
name: sellingPlan.name,
|
|
121
|
-
description: sellingPlan.description
|
|
122
|
-
},
|
|
123
|
-
priceAdjustments: sellingPlan.priceAdjustments.map((adj) => {
|
|
124
|
-
const adjustedPrice = variantPrice !== void 0 ? applyPriceAdjustment(variantPrice, adj, currencyCode) : 0;
|
|
125
|
-
return {
|
|
126
|
-
compareAtPrice: {
|
|
127
|
-
amount: variantPrice ?? 0,
|
|
128
|
-
currencyCode
|
|
129
|
-
},
|
|
130
|
-
perDeliveryPrice: {
|
|
131
|
-
amount: adjustedPrice,
|
|
132
|
-
currencyCode
|
|
133
|
-
},
|
|
134
|
-
price: {
|
|
135
|
-
amount: adjustedPrice,
|
|
136
|
-
currencyCode
|
|
137
|
-
},
|
|
138
|
-
unitPrice: null
|
|
139
|
-
};
|
|
140
|
-
}),
|
|
141
|
-
checkoutChargeAmount: {
|
|
142
|
-
amount: 0,
|
|
143
|
-
currencyCode
|
|
144
|
-
},
|
|
145
|
-
remainingBalanceChargeAmount: {
|
|
146
|
-
amount: 0,
|
|
147
|
-
currencyCode
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
32
|
+
function createOptimisticSellingPlanAllocation(_options) {
|
|
33
|
+
throw canopyTombstoneError({
|
|
34
|
+
symbol: "createOptimisticSellingPlanAllocation",
|
|
35
|
+
subpath: "cart/utils/variant-to-cart-line"
|
|
36
|
+
});
|
|
153
37
|
}
|
|
154
38
|
export {
|
|
155
39
|
createOptimisticSellingPlanAllocation,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../cart/utils/variant-to-cart-line.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n CartLine,\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type {\n CartLine,\n CartLineMerchandise,\n SellingPlanAllocation,\n} from \"../cart-types\";\n\nimport { canopyTombstoneError } from \"../../lib/tombstone\";\n\n/** @deprecated Use getCartLineAttribute from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function getCartLineAttribute(\n _cartLine: CartLine,\n _key: string,\n): string | number | boolean | undefined {\n throw canopyTombstoneError({\n symbol: \"getCartLineAttribute\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n\n/** @deprecated Use getCartLinePricing from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function getCartLinePricing(_cartLine: CartLine): {\n compareAtPrice: number;\n discountPercentage: number;\n hasDiscount: boolean;\n sellingPlanAdjustedPrice: number;\n finalPrice: number;\n} {\n throw canopyTombstoneError({\n symbol: \"getCartLinePricing\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n\n/** @deprecated Use getCartLineBundleInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function getCartLineBundleInfo(_cartLine: CartLine): {\n bundleId: string;\n bundleDiscount: number;\n isBundleItem: boolean;\n} {\n throw canopyTombstoneError({\n symbol: \"getCartLineBundleInfo\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n\n/** @deprecated Use getCartLineSpecialInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function getCartLineSpecialInfo(_cartLine: CartLine): {\n isSpecialItem: boolean;\n specialInstructions: string[];\n} {\n throw canopyTombstoneError({\n symbol: \"getCartLineSpecialInfo\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n\n/** @deprecated Use getCartLineSubscriptionInfo from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function getCartLineSubscriptionInfo(_cartLine: CartLine):\n | {\n isSubscription: boolean;\n frequency: string;\n discount: number;\n sellingPlan: {\n id: string;\n name: string;\n description: string | null;\n };\n }\n | {\n isSubscription: boolean;\n frequency: null;\n discount: number;\n sellingPlan: null;\n } {\n throw canopyTombstoneError({\n symbol: \"getCartLineSubscriptionInfo\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n\n/** @deprecated Use createOptimisticSellingPlanAllocation from @replohq/sdk/cart/utils/variant-to-cart-line. */\nexport function createOptimisticSellingPlanAllocation(_options: {\n merchandise: CartLineMerchandise;\n sellingPlanId: string | null;\n currencyCode?: string;\n}): SellingPlanAllocation | null {\n throw canopyTombstoneError({\n symbol: \"createOptimisticSellingPlanAllocation\",\n subpath: \"cart/utils/variant-to-cart-line\",\n });\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,4BAA4B;AAG9B,SAAS,qBACd,WACA,MACuC;AACvC,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGO,SAAS,mBAAmB,WAMjC;AACA,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGO,SAAS,sBAAsB,WAIpC;AACA,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGO,SAAS,uBAAuB,WAGrC;AACA,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGO,SAAS,4BAA4B,WAgBtC;AACJ,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;AAGO,SAAS,sCAAsC,UAIrB;AAC/B,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,EACX,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|