@tagadapay/headless-sdk 1.17.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/modules/customer.d.ts +26 -4
- package/dist/core/modules/customer.d.ts.map +1 -1
- package/dist/core/modules/customer.js +50 -16
- package/dist/core/modules/customer.js.map +1 -1
- package/dist/core/modules/rx.d.ts +91 -4
- package/dist/core/modules/rx.d.ts.map +1 -1
- package/dist/core/modules/rx.js +74 -2
- package/dist/core/modules/rx.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/provider.d.ts +13 -2
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +35 -7
- package/dist/react/provider.js.map +1 -1
- package/dist/tagada-headless-commerce.min.js +2 -2
- package/dist/tagada-headless-commerce.min.js.map +4 -4
- package/dist/tagada-headless-react.min.js +2 -2
- package/dist/tagada-headless-react.min.js.map +3 -3
- package/dist/tagada-headless.js +68 -7
- package/dist/tagada-headless.min.js +2 -2
- package/dist/tagada-headless.min.js.map +3 -3
- package/dist/tagada-pixels.min.js +1 -1
- package/package.json +4 -1
package/dist/react/provider.js
CHANGED
|
@@ -2,24 +2,52 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useMemo } from 'react';
|
|
3
3
|
import { createHeadlessClient } from '../core/client.js';
|
|
4
4
|
const TagadaHeadlessContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* A string that changes only when a config value does. `bootstrap` is plain JSON from the server,
|
|
7
|
+
* so it is compared by content. The `Record` stops compiling when `HeadlessConfig` gains a field,
|
|
8
|
+
* so a new field cannot be left out of the comparison.
|
|
9
|
+
*/
|
|
10
|
+
function configKey(config) {
|
|
11
|
+
const values = {
|
|
12
|
+
storeId: config.storeId,
|
|
13
|
+
environment: config.environment,
|
|
14
|
+
apiKey: config.apiKey,
|
|
15
|
+
baseUrl: config.baseUrl,
|
|
16
|
+
accountId: config.accountId,
|
|
17
|
+
funnel: config.funnel,
|
|
18
|
+
timeout: config.timeout,
|
|
19
|
+
bootstrap: config.bootstrap,
|
|
20
|
+
};
|
|
21
|
+
return JSON.stringify(values);
|
|
22
|
+
}
|
|
23
|
+
function resolveConfig(props) {
|
|
24
|
+
if (props.config)
|
|
25
|
+
return props.config;
|
|
26
|
+
const { storeId, environment, apiKey, baseUrl } = props;
|
|
27
|
+
return { storeId, environment, apiKey, baseUrl };
|
|
28
|
+
}
|
|
5
29
|
/**
|
|
6
30
|
* Root provider for the TagadaPay Headless SDK React integration.
|
|
7
|
-
* Creates a single HeadlessClient and shares it via context.
|
|
31
|
+
* Creates a single HeadlessClient and shares it via context. The client is rebuilt only
|
|
32
|
+
* when a config value changes, so an inline `config` object keeps the same client.
|
|
8
33
|
*
|
|
9
34
|
* @example
|
|
10
35
|
* ```tsx
|
|
11
36
|
* <TagadaHeadlessProvider storeId="store_abc123" environment="production">
|
|
12
37
|
* <App />
|
|
13
38
|
* </TagadaHeadlessProvider>
|
|
39
|
+
*
|
|
40
|
+
* <TagadaHeadlessProvider config={{ storeId: 'store_abc123', funnel: 'main' }}>
|
|
41
|
+
* <App />
|
|
42
|
+
* </TagadaHeadlessProvider>
|
|
14
43
|
* ```
|
|
15
44
|
*/
|
|
16
|
-
export function TagadaHeadlessProvider(
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, [storeId, environment, apiKey, baseUrl, config]);
|
|
45
|
+
export function TagadaHeadlessProvider(props) {
|
|
46
|
+
const cfg = resolveConfig(props);
|
|
47
|
+
const key = configKey(cfg);
|
|
48
|
+
const client = useMemo(() => createHeadlessClient(cfg), [key]);
|
|
21
49
|
const value = useMemo(() => ({ client }), [client]);
|
|
22
|
-
return (_jsx(TagadaHeadlessContext.Provider, { value: value, children: children }));
|
|
50
|
+
return (_jsx(TagadaHeadlessContext.Provider, { value: value, children: props.children }));
|
|
23
51
|
}
|
|
24
52
|
/** Access the HeadlessClient from context. Throws if used outside the provider. */
|
|
25
53
|
export function useHeadlessClient() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAkB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOzE,MAAM,qBAAqB,GAAG,aAAa,CAAoC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAkB,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOzE,MAAM,qBAAqB,GAAG,aAAa,CAAoC,IAAI,CAAC,CAAC;AAuBrF;;;;GAIG;AACH,SAAS,SAAS,CAAC,MAAsB;IACvC,MAAM,MAAM,GAA0C;QACpD,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,aAAa,CAAC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";var TagadaHeadlessCommerceBundle=(()=>{var
|
|
6
|
+
"use strict";var TagadaHeadlessCommerceBundle=(()=>{var g=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var w=(i,t)=>{for(var e in t)g(i,e,{get:t[e],enumerable:!0})},C=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of v(t))!b.call(i,s)&&s!==e&&g(i,s,{get:()=>t[s],enumerable:!(r=I(t,s))||r.enumerable});return i};var O=i=>C(g({},"__esModule",{value:!0}),i);var R={};w(R,{CustomerModule:()=>h,CustomerPortalModule:()=>l,OffersModule:()=>m});var l=class{constructor(t,e,r){this.http=t;this.storeId=e;this.setToken=r}async requestCode(t){await this.http.post("/api/v1/cms/session/request-code",{email:t,storeId:this.storeId})}async verifyCode(t,e){let r=await this.http.post("/api/v1/cms/session/login",{email:t,code:e,storeId:this.storeId});return this.setToken(r.token),r}async getConfig(){return this.http.get("/api/v1/portal/config",{params:{storeId:this.storeId}})}async getMe(){return this.http.get("/api/v1/portal/me")}async cancelFlow(t){return this.http.post("/api/v1/portal/cancel-flow",t)}async acceptCancelOffer(t){return this.http.post("/api/v1/portal/cancel-flow/accept",t)}async switchOption(t){return this.http.post("/api/v1/portal/switch",t)}async getOffer(t){return this.http.get(`/api/v1/portal/offers/${encodeURIComponent(t)}`)}async acceptOffer(t){return this.http.post("/api/v1/portal/offers/accept",t)}async addToNextOrder(t){return this.http.post("/api/v1/portal/next-order",t)}async getCredits(){return this.http.get("/api/v1/portal/credits")}async redeemCredits(t){return this.http.post("/api/v1/portal/credits/redeem",t)}async buyCreditPack(t){return this.http.post("/api/v1/portal/credits/packs/buy",t)}async requestEmailChangeCode(t){await this.http.post("/api/v1/portal/profile/email-code",{email:t})}async updateProfile(t){await this.http.post("/api/v1/portal/profile",t)}async saveAddress(t){return this.http.post("/api/v1/portal/addresses",t)}async removeAddress(t){await this.http.post("/api/v1/portal/addresses/remove",{addressId:t})}async setDefaultAddress(t){await this.http.post("/api/v1/portal/addresses/default",{addressId:t})}async addCard(t){return this.http.post("/api/v1/portal/payment-methods",t)}async removeCard(t){await this.http.post("/api/v1/portal/payment-methods/remove",{paymentMethodId:t})}async setDefaultPaymentMethod(t){await this.http.post("/api/v1/portal/payment-methods/default",{paymentMethodId:t})}async retryPayment(t){return this.http.post("/api/v1/portal/retry-payment",{subscriptionId:t})}async buyAgain(t){return this.http.post("/api/v1/portal/buy-again",{lines:t.map(({variantId:e,quantity:r})=>({variantId:e,quantity:r}))})}async joinMembership(t){return this.http.post("/api/v1/portal/membership/join",{billing:t})}async buyNow(t,e=1){return this.buyAgain([{variantId:t,quantity:e}])}async sendNow(t){return this.http.post("/api/v1/subscriptions/send-now",{subscriptionId:t})}async reactivateSubscription(t){return this.http.post("/api/v1/subscriptions/reactivate",{subscriptionId:t})}async setSubscriptionCard(t,e){return this.http.post("/api/v1/subscriptions/saved-card",{subscriptionId:t,paymentMethodId:e})}async setSubscriptionAddress(t,e){return this.http.post("/api/v1/subscriptions/shipping-address",{subscriptionId:t,addressId:e})}async skipDate(t,e){return this.http.post("/api/v1/subscriptions/skip-date",{subscriptionId:t,date:e})}async unskipDate(t,e){return this.http.post("/api/v1/subscriptions/unskip",{subscriptionId:t,date:e})}};var m=class{constructor(t,e,r){this.http=t;this.storeId=e;this.payment=r}async getOffer(t){return this.http.get(`/api/v1/offers/${t}`)}async listOffers(t){var n;let e=`/api/v1/stores/${this.storeId}/offers`,r=[];if(t!=null&&t.type&&r.push(`type=${encodeURIComponent(t.type)}`),(n=t==null?void 0:t.ids)!=null&&n.length)for(let d of t.ids)r.push(`ids=${encodeURIComponent(d)}`);return r.length&&(e+=`?${r.join("&")}`),(await this.http.get(e)).offers??[]}async previewOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,funnelSessionId:t.funnelSessionId})}async enterFunnelStep(t){let e=typeof window<"u"?window.location.origin:"http://localhost";return{funnelSessionId:(await this.http.post("/api/v1/funnel/initialize",{cmsSession:{customerId:"anon_placeholder",sessionId:"anon_placeholder",storeId:this.storeId,accountId:t.accountId},funnelId:t.funnelId,funnelStepId:t.stepId,existingSessionId:t.funnelSessionId,currentUrl:t.checkoutToken?`${e}/?checkoutToken=${encodeURIComponent(t.checkoutToken)}`:void 0,draft:!1})).context.sessionId}}async payPreviewedOffer(t){return this.http.post(`/api/v1/offers/${t.offerId}/pay-preview`,{offerId:t.offerId,currency:t.currency??"",lineItems:t.lineItems,returnUrl:t.returnUrl??(typeof window<"u"?window.location.href:""),mainOrderId:t.mainOrderId,paymentInstrumentId:t.paymentInstrumentId,funnelSessionId:t.funnelSessionId})}async processOfferPayment(t){if(!this.payment)throw new Error("OffersModule: no PaymentModule injected. Use createHeadlessClient() instead of constructing OffersModule directly.");let e=t.returnUrl??(typeof window<"u"?window.location.href:void 0),r=await this.payPreviewedOffer({...t,returnUrl:e});return this.payment.finalize({payment:r.payment,order:r.order},{returnUrl:e})}async toggleOrderBump(t){return this.http.post(`/api/v1/checkout-sessions/${t.checkoutSessionId}/toggle-order-bump`,{orderBumpOfferId:t.orderBumpOfferId,selected:t.selected})}async listPostPurchaseOffers(t){let e=await this.http.get(`/api/v1/post-purchase/${t}/offers`);return Array.isArray(e)?e:[]}async acceptPostPurchaseOffer(t){var s,n;let e;if((s=t.items)!=null&&s.length){let d=await this.http.post(`/api/v1/offers/${t.offerId}/preview`,{offerId:t.offerId,currency:""});e=[];for(let u of t.items){let o=d.lineItems.filter(a=>{var c;return a.variantId===u.variantId||((c=d.preview.options[a.productId])==null?void 0:c.some(P=>P.id===u.variantId))});if(o.length!==1||e.some(a=>a.lineItemId===o[0].lineItemId))return{success:!1,error:"Invalid selection"};e.push({...u,lineItemId:o[0].lineItemId,productId:o[0].productId})}}let r=await this.payPreviewedOffer({offerId:t.offerId,mainOrderId:t.orderId,lineItems:e});return r.payment.status==="succeeded"?{success:!0}:{success:!1,error:r.payment.status==="pending"?"Payment pending":r.payment.status==="requires_action"||r.payment.requireAction&&r.payment.requireAction!=="none"?"Payment requires authentication":((n=r.payment.requireActionData)==null?void 0:n.message)||"Payment declined"}}async declinePostPurchaseOffer(t){return{success:!0}}};var p=class extends Error{constructor(t,e,r,s){super(t),this.name="TagadaError",this.code=e,this.statusCode=r,this.details=s}};var f=class extends p{constructor(t,e){super(`${t} "${e}" not found.`,"not_found",404),this.name="TagadaNotFoundError"}};function y(i,t){var e,r;return{...i,storeId:t,amount:((r=(e=i.priceCurrencyOptions)==null?void 0:e[i.currency])==null?void 0:r.amount)??0,interval:i.priceInterval??"",intervalCount:i.priceIntervalCount??1}}var h=class{constructor(t,e){this.http=t;this.storeId=e}async getProfile(t){return(await this.http.get(`/api/v1/customers/${t}`,{params:{storeId:this.storeId}})).customer}async getByEmail(t){throw new p("customer.getByEmail is not available: no API route finds a customer by email for a storefront session.","not_supported")}async updateProfile(t,e){return await this.http.post(`/api/v1/customers/${t}`,{customerId:t,data:{email:e.email}}),this.getProfile(t)}async getOrders(t,e){let{orders:r}=await this.http.get(`/api/v1/orders/customer/${t}`,{params:{storeId:this.storeId}}),s=(e==null?void 0:e.offset)??0,n=(e==null?void 0:e.limit)===void 0?void 0:s+e.limit;return{orders:r.slice(s,n),total:r.length}}async getOrder(t,e){var o,a;let r=async()=>(await this.http.get(`/api/v1/orders/${t}`,{params:{storeId:this.storeId}})).order,s=await r();if(!(e!=null&&e.waitForRelatedOrders)||(o=s.relatedOrders)!=null&&o.length)return s;let n=e.timeoutMs??8e3,d=e.intervalMs??2e3,u=Date.now()+n;for(;Date.now()<u;)if(await new Promise(c=>setTimeout(c,Math.min(d,Math.max(0,u-Date.now())))),s=await r(),(a=s.relatedOrders)!=null&&a.length)return s;return s}async getSubscriptions(t){let{items:e}=await this.http.get("/api/v1/subscriptions");return e.filter(r=>r.customerId===t).map(r=>y(r,this.storeId))}async getSubscription(t){let{items:e}=await this.http.get("/api/v1/subscriptions"),r=e.find(s=>s.id===t);if(!r)throw new f("Subscription",t);return y(r,this.storeId)}async pauseSubscription(t,e){await this.http.post("/api/v1/subscriptions/pause",{subscriptionId:t,resumeAt:e==null?void 0:e.resumeAt})}async resumeSubscription(t){await this.http.post("/api/v1/subscriptions/resume",{subscriptionId:t})}async skipSubscription(t){await this.http.post("/api/v1/subscriptions/skip",{subscriptionId:t})}async rescheduleSubscription(t,e){await this.http.post("/api/v1/subscriptions/reschedule",{subscriptionId:t,nextBillingDate:e})}async updateSubscriptionQuantity(t,e){await this.http.post("/api/v1/subscriptions/quantity",{subscriptionId:t,quantity:e})}async changeSubscriptionFrequency(t,e){let r=typeof e=="string"?{priceId:e}:e;await this.http.post("/api/v1/subscriptions/frequency",{subscriptionId:t,...r})}async swapSubscriptionProduct(t,e){await this.http.post("/api/v1/subscriptions/swap-product",{subscriptionId:t,...e})}async updateSubscriptionPaymentMethod(t,e){await this.http.post("/api/v1/subscriptions/payment-method",{subscriptionId:t,tagadaToken:e})}async cancelSubscription(t,e){await this.http.post("/api/v1/subscriptions/cancel",{subscriptionId:t,cancelAtPeriodEnd:(e==null?void 0:e.cancelAtPeriodEnd)??!0})}};return O(R);})();
|
|
7
7
|
window.TagadaHeadlessCommerce=TagadaHeadlessCommerceBundle;
|
|
8
8
|
//# sourceMappingURL=tagada-headless-commerce.min.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/modules/commerce.ts", "../src/core/modules/portal/index.ts", "../src/core/modules/offers.ts", "../src/core/modules/customer.ts"],
|
|
4
|
-
"sourcesContent": ["// CDN chunk for capabilities that do not need to run during checkout bootstrap.\nexport { CustomerPortalModule } from './portal/index.js';\nexport { OffersModule } from './offers.js';\nexport { CustomerModule } from './customer.js';\n", "import type { HttpClient } from '../../http.js';\nimport type {\n Billing,\n PortalAcceptOfferInput,\n PortalAddToNextOrderInput,\n PortalAcceptOfferResult,\n PortalAddCardInput,\n PortalAddressInput,\n PortalBuyAgainLine,\n PortalBuyCreditPackInput,\n PortalCancelFlowInput,\n PortalCancelOfferInput,\n PortalCheckoutResult,\n PortalCredits,\n PortalCreditsOrderResult,\n PortalMe,\n PortalOffer,\n PortalProfileInput,\n PortalPublicConfig,\n PortalRedeemCreditsInput,\n PortalSubscriptionResult,\n PortalSwitchInput,\n PortalSwitchResult,\n PortalTargetResult,\n PortalVerifyCodeResult,\n} from './types.js';\n\n/**\n * Customer portal (Subscriptions V3): the store's portal config, the logged-in\n * customer, retention, plan switches, upsell links and credits.\n *\n * Log in with `requestCode` then `verifyCode`; every other call except\n * `getConfig` needs that session. Subscription actions (pause, skip, \u2026) live on\n * `client.customer`.\n *\n * Endpoints:\n * GET /api/v1/portal/config\n * GET /api/v1/portal/me\n * POST /api/v1/portal/cancel-flow\n * POST /api/v1/portal/cancel-flow/accept\n * POST /api/v1/portal/switch\n * GET /api/v1/portal/offers/:token\n * POST /api/v1/portal/offers/accept\n * POST /api/v1/portal/next-order\n * GET /api/v1/portal/credits\n * POST /api/v1/portal/credits/redeem\n * POST /api/v1/portal/credits/packs/buy\n * POST /api/v1/portal/profile, /profile/email-code\n * POST /api/v1/portal/addresses, /addresses/remove, /addresses/default\n * POST /api/v1/portal/payment-methods, /payment-methods/remove, /payment-methods/default\n * POST /api/v1/portal/retry-payment\n * POST /api/v1/portal/buy-again\n * POST /api/v1/portal/membership/join\n * POST /api/v1/subscriptions/send-now, /reactivate, /saved-card, /shipping-address, /skip-date, /unskip\n */\nexport class CustomerPortalModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n private readonly setToken: (token: string) => void,\n ) {}\n\n /** Email a login code to the customer. */\n async requestCode(email: string): Promise<void> {\n await this.http.post('/api/v1/cms/session/request-code', { email, storeId: this.storeId });\n }\n\n /** Exchange the emailed code for a session; later calls send it. */\n async verifyCode(email: string, code: string): Promise<PortalVerifyCodeResult> {\n const res = await this.http.post<PortalVerifyCodeResult>('/api/v1/cms/session/login', {\n email,\n code,\n storeId: this.storeId,\n });\n this.setToken(res.token);\n return res;\n }\n\n /** The store's published portal: design, retention, membership program, products. */\n async getConfig(): Promise<PortalPublicConfig> {\n return this.http.get<PortalPublicConfig>('/api/v1/portal/config', { params: { storeId: this.storeId } });\n }\n\n /** The logged-in customer: profile, orders, subscriptions, membership, credit ledger. */\n async getMe(): Promise<PortalMe> {\n return this.http.get<PortalMe>('/api/v1/portal/me');\n }\n\n /** Cancel a subscription or the membership after the reasons step. */\n async cancelFlow(input: PortalCancelFlowInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/cancel-flow', input);\n }\n\n /** Take the retention offer mapped to the chosen reason instead of cancelling. */\n async acceptCancelOffer(input: PortalCancelOfferInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/cancel-flow/accept', input);\n }\n\n /** Move a subscription or the membership to another option now, charged now. */\n async switchOption(input: PortalSwitchInput): Promise<PortalSwitchResult> {\n return this.http.post<PortalSwitchResult>('/api/v1/portal/switch', input);\n }\n\n /** The upsell a signed link (`/account/offer/<token>`) offers. No login: the token is the authorization. */\n async getOffer(token: string): Promise<PortalOffer> {\n return this.http.get<PortalOffer>(`/api/v1/portal/offers/${encodeURIComponent(token)}`);\n }\n\n /** Accept a signed upsell link and pay it with the card of the original order. A second accept charges nothing. */\n async acceptOffer(input: PortalAcceptOfferInput): Promise<PortalAcceptOfferResult> {\n return this.http.post<PortalAcceptOfferResult>('/api/v1/portal/offers/accept', input);\n }\n\n /** Ship a one-time item with the subscription's next renewal, charged with it; quantity 0 takes it off. */\n async addToNextOrder(input: PortalAddToNextOrderInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/next-order', input);\n }\n\n /** Credit balance and ledger of the logged-in customer. */\n async getCredits(): Promise<PortalCredits> {\n return this.http.get<PortalCredits>('/api/v1/portal/credits');\n }\n\n /** Pay a product with credits. */\n async redeemCredits(input: PortalRedeemCreditsInput): Promise<PortalCreditsOrderResult> {\n return this.http.post<PortalCreditsOrderResult>('/api/v1/portal/credits/redeem', input);\n }\n\n /** Buy a credit pack with the stored card. */\n async buyCreditPack(input: PortalBuyCreditPackInput): Promise<PortalCreditsOrderResult> {\n return this.http.post<PortalCreditsOrderResult>('/api/v1/portal/credits/packs/buy', input);\n }\n\n // \u2500\u2500 The customer's own account \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /** Email a code to a new address; `updateProfile` saves that email with it (`emailCode`). */\n async requestEmailChangeCode(email: string): Promise<void> {\n await this.http.post('/api/v1/portal/profile/email-code', { email });\n }\n\n /** The logged-in customer's name, email and phone. */\n async updateProfile(profile: PortalProfileInput): Promise<void> {\n await this.http.post('/api/v1/portal/profile', profile);\n }\n\n /** Add an address, or replace the one with that id; `isDefault` makes it the default. */\n async saveAddress(address: PortalAddressInput): Promise<{ addressId: string }> {\n return this.http.post('/api/v1/portal/addresses', address);\n }\n\n /** Remove an address; the default one stays until another is the default. */\n async removeAddress(addressId: string): Promise<void> {\n await this.http.post('/api/v1/portal/addresses/remove', { addressId });\n }\n\n async setDefaultAddress(addressId: string): Promise<void> {\n await this.http.post('/api/v1/portal/addresses/default', { addressId });\n }\n\n /** Save a card tokenized with `client.payment.tokenizeCard`. */\n async addCard(input: PortalAddCardInput): Promise<{ paymentMethodId: string }> {\n return this.http.post('/api/v1/portal/payment-methods', input);\n }\n\n /** Remove a saved card; refused while a live subscription is paid with it. */\n async removeCard(paymentMethodId: string): Promise<void> {\n await this.http.post('/api/v1/portal/payment-methods/remove', { paymentMethodId });\n }\n\n /** The default card also becomes the card of every live subscription. */\n async setDefaultPaymentMethod(paymentMethodId: string): Promise<void> {\n await this.http.post('/api/v1/portal/payment-methods/default', { paymentMethodId });\n }\n\n /** Charge a past-due subscription again now. */\n async retryPayment(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/portal/retry-payment', { subscriptionId });\n }\n\n /** Order products again at today's one-time price with the default card and address. */\n async buyAgain(lines: readonly PortalBuyAgainLine[]): Promise<PortalCheckoutResult> {\n return this.http.post('/api/v1/portal/buy-again', { lines: lines.map(({ variantId, quantity }) => ({ variantId, quantity })) });\n }\n\n /** Buy the Membership's monthly or yearly option with the default card. */\n async joinMembership(billing: Billing): Promise<PortalCheckoutResult> {\n return this.http.post('/api/v1/portal/membership/join', { billing });\n }\n\n /** Buy one product now at its one-time price with the default card and address. */\n async buyNow(variantId: string, quantity = 1): Promise<PortalCheckoutResult> {\n return this.buyAgain([{ variantId, quantity }]);\n }\n\n /** Charge and ship a subscription's next order today. */\n async sendNow(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/send-now', { subscriptionId });\n }\n\n /** Restart a cancelled subscription, or keep one set to end at its period end. */\n async reactivateSubscription(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/reactivate', { subscriptionId });\n }\n\n /** Bill a subscription on another saved card. */\n async setSubscriptionCard(subscriptionId: string, paymentMethodId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/saved-card', { subscriptionId, paymentMethodId });\n }\n\n /** Ship a subscription to an address of the book; null follows the default address. */\n async setSubscriptionAddress(subscriptionId: string, addressId: string | null): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/shipping-address', { subscriptionId, addressId });\n }\n\n /** Skip one upcoming delivery date (`YYYY-MM-DD`); skipping the next one moves the next charge. */\n async skipDate(subscriptionId: string, date: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/skip-date', { subscriptionId, date });\n }\n\n /** Take back a skipped delivery date (`YYYY-MM-DD`). */\n async unskipDate(subscriptionId: string, date: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/unskip', { subscriptionId, date });\n }\n}\n", "import type { HttpClient } from '../http.js';\nimport type {\n Offer,\n OfferPreview,\n OfferPayResult,\n ProcessPaymentResult,\n} from '../types.js';\nimport type { PaymentModule } from './payment.js';\n\n/**\n * Offers \u2014 upsells, downsells, order bumps, and post-purchase offers.\n *\n * Endpoints align with the plugin-sdk patterns:\n * GET /api/v1/offers/:id \u2014 single offer\n * GET /api/v1/stores/:storeId/offers \u2014 list store offers\n * POST /api/v1/offers/:offerId/preview \u2014 preview pricing\n * POST /api/v1/offers/:offerId/pay-preview \u2014 pay a previewed offer (one-click)\n * POST /api/v1/checkout-sessions/:id/toggle-order-bump \u2014 toggle order bump\n * GET /api/v1/post-purchase/:orderId/offers \u2014 post-purchase offers for an order\n * Post-purchase acceptance uses pay-preview; declining is a local decision.\n */\nexport class OffersModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n private readonly payment?: PaymentModule,\n ) {}\n\n // ---------------------------------------------------------------------------\n // Offer loading\n // ---------------------------------------------------------------------------\n\n /** Get a single offer by ID. */\n async getOffer(offerId: string): Promise<Offer> {\n return this.http.get<Offer>(`/api/v1/offers/${offerId}`);\n }\n\n /** List offers for the current store. Optionally filter by type or a set of IDs. */\n async listOffers(opts?: {\n type?: 'upsell' | 'orderbump';\n ids?: string[];\n }): Promise<Offer[]> {\n let url = `/api/v1/stores/${this.storeId}/offers`;\n\n const queryParts: string[] = [];\n if (opts?.type) queryParts.push(`type=${encodeURIComponent(opts.type)}`);\n if (opts?.ids?.length) {\n for (const id of opts.ids) queryParts.push(`ids=${encodeURIComponent(id)}`);\n }\n if (queryParts.length) url += `?${queryParts.join('&')}`;\n\n const res = await this.http.get<{ offers: Offer[] }>(url);\n return res.offers ?? [];\n }\n\n // ---------------------------------------------------------------------------\n // Preview & pay (one-click upsell flow from plugin-sdk)\n // ---------------------------------------------------------------------------\n\n /**\n * Preview offer pricing. Returns line items with amounts and totals.\n *\n * A Studio offer block is previewed under `blockoffer:<blockId>` and read from\n * the step its funnel session stands on: pass that session's id\n * (see {@link enterFunnelStep}).\n */\n async previewOffer(opts: {\n offerId: string;\n currency?: string;\n lineItems?: Array<{ lineItemId?: string; productId?: string; variantId: string; quantity: number }>;\n funnelSessionId?: string;\n }): Promise<OfferPreview> {\n return this.http.post<OfferPreview>(`/api/v1/offers/${opts.offerId}/preview`, {\n offerId: opts.offerId,\n currency: opts.currency ?? '',\n lineItems: opts.lineItems,\n funnelSessionId: opts.funnelSessionId,\n });\n }\n\n /**\n * Put the buyer on a step of a funnel, for pages the funnel does not serve\n * itself: its offer blocks are then previewed and accepted as\n * `blockoffer:<blockId>` with the returned `funnelSessionId`. Uses the\n * checkout session's token, so the funnel session is the paying customer's.\n * Pass `checkoutToken` at checkout to link that checkout to the funnel\n * session, and `funnelSessionId` to move an open session to another step.\n */\n async enterFunnelStep(opts: {\n funnelId: string;\n stepId: string;\n accountId: string;\n funnelSessionId?: string;\n checkoutToken?: string;\n }): Promise<{ funnelSessionId: string }> {\n const here = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';\n const res = await this.http.post<{ context: { sessionId: string } }>('/api/v1/funnel/initialize', {\n // Placeholder ids: the server takes the customer and the CMS session from the token.\n cmsSession: { customerId: 'anon_placeholder', sessionId: 'anon_placeholder', storeId: this.storeId, accountId: opts.accountId },\n funnelId: opts.funnelId,\n funnelStepId: opts.stepId,\n existingSessionId: opts.funnelSessionId,\n currentUrl: opts.checkoutToken ? `${here}/?checkoutToken=${encodeURIComponent(opts.checkoutToken)}` : undefined,\n draft: false,\n });\n return { funnelSessionId: res.context.sessionId };\n }\n\n /**\n * Pay a previously previewed offer (one-click charge).\n * Used after a main order so the stored payment instrument is reused.\n *\n * **Low-level API.** Returns the raw `OfferPayResult` \u2014 `requireAction`,\n * polling, and 3DS redirects are NOT handled. For most cases, use\n * {@link processOfferPayment} which orchestrates the full lifecycle.\n */\n async payPreviewedOffer(opts: {\n offerId: string;\n mainOrderId: string;\n currency?: string;\n lineItems?: Array<{ lineItemId?: string; productId?: string; variantId: string; quantity: number }>;\n returnUrl?: string;\n paymentInstrumentId?: string;\n funnelSessionId?: string;\n }): Promise<OfferPayResult> {\n return this.http.post<OfferPayResult>(`/api/v1/offers/${opts.offerId}/pay-preview`, {\n offerId: opts.offerId,\n currency: opts.currency ?? '',\n lineItems: opts.lineItems,\n returnUrl: opts.returnUrl ?? (typeof window !== 'undefined' ? window.location.href : ''),\n mainOrderId: opts.mainOrderId,\n paymentInstrumentId: opts.paymentInstrumentId,\n funnelSessionId: opts.funnelSessionId,\n });\n }\n\n /**\n * One-click upsell with full lifecycle handling.\n *\n * Like `payment.processPayment()` but for previewed offers: charges the\n * stored instrument from `mainOrderId`, runs any 3DS challenge or bank\n * redirect, polls until terminal, and returns a typed\n * `ProcessPaymentResult` (`succeeded` / `requires_redirect` /\n * `failed` / `pending`).\n *\n * Use this instead of the lower-level `payPreviewedOffer()` whenever you\n * don't need to inspect the raw `OfferPayResult` shape \u2014 which is most\n * of the time.\n *\n * @example\n * ```ts\n * const result = await tagada.offers.processOfferPayment({\n * offerId: 'offer_xxx',\n * mainOrderId: order.id,\n * returnUrl: window.location.href,\n * });\n *\n * switch (result.status) {\n * case 'succeeded':\n * window.location.href = '/upsell-2';\n * break;\n * case 'requires_redirect':\n * window.location.href = result.redirectUrl;\n * break;\n * case 'failed':\n * showError(result.error);\n * break;\n * }\n * ```\n */\n async processOfferPayment(opts: {\n offerId: string;\n mainOrderId: string;\n currency?: string;\n lineItems?: Array<{\n lineItemId?: string;\n productId?: string;\n variantId: string;\n quantity: number;\n }>;\n returnUrl?: string;\n paymentInstrumentId?: string;\n funnelSessionId?: string;\n }): Promise<ProcessPaymentResult> {\n if (!this.payment) {\n throw new Error(\n 'OffersModule: no PaymentModule injected. ' +\n 'Use createHeadlessClient() instead of constructing OffersModule directly.',\n );\n }\n const returnUrl =\n opts.returnUrl ?? (typeof window !== 'undefined' ? window.location.href : undefined);\n const payResult = await this.payPreviewedOffer({ ...opts, returnUrl });\n return this.payment.finalize(\n { payment: payResult.payment, order: payResult.order },\n { returnUrl },\n );\n }\n\n // ---------------------------------------------------------------------------\n // Order bumps (checkout-session scoped)\n // ---------------------------------------------------------------------------\n\n /** Toggle an order bump on/off within a checkout session. */\n async toggleOrderBump(opts: {\n checkoutSessionId: string;\n orderBumpOfferId: string;\n selected: boolean;\n }): Promise<unknown> {\n return this.http.post(\n `/api/v1/checkout-sessions/${opts.checkoutSessionId}/toggle-order-bump`,\n {\n orderBumpOfferId: opts.orderBumpOfferId,\n selected: opts.selected,\n },\n );\n }\n\n // ---------------------------------------------------------------------------\n // Post-purchase offers (order-scoped)\n // ---------------------------------------------------------------------------\n\n /** List post-purchase offers for an order. */\n async listPostPurchaseOffers(orderId: string): Promise<Offer[]> {\n const res = await this.http.get<Offer[]>(`/api/v1/post-purchase/${orderId}/offers`);\n return Array.isArray(res) ? res : [];\n }\n\n /** Accept a post-purchase offer. Only a confirmed charge returns success. */\n async acceptPostPurchaseOffer(opts: {\n orderId: string;\n offerId: string;\n items?: Array<{ variantId: string; quantity: number }>;\n }): Promise<{ success: boolean; error?: string }> {\n // The server matches overrides by line-item/product ID, not variant alone.\n // Resolve against this offer's quote so an unrelated variant cannot silently\n // fall back to charging the offer's default selection.\n let lineItems: Array<{ lineItemId: string; productId: string; variantId: string; quantity: number }> | undefined;\n if (opts.items?.length) {\n const quote = await this.http.post<{\n lineItems: Array<{ lineItemId: string; productId: string; variantId: string }>;\n preview: { options: Record<string, Array<{ id: string }>> };\n }>(`/api/v1/offers/${opts.offerId}/preview`, { offerId: opts.offerId, currency: '' });\n lineItems = [];\n for (const item of opts.items) {\n const matches = quote.lineItems.filter(line => line.variantId === item.variantId ||\n quote.preview.options[line.productId]?.some(variant => variant.id === item.variantId));\n if (matches.length !== 1 || lineItems.some(line => line.lineItemId === matches[0].lineItemId)) {\n return { success: false, error: 'Invalid selection' };\n }\n lineItems.push({ ...item, lineItemId: matches[0].lineItemId, productId: matches[0].productId });\n }\n }\n const result = await this.payPreviewedOffer({\n offerId: opts.offerId,\n mainOrderId: opts.orderId,\n lineItems,\n });\n if (result.payment.status === 'succeeded') return { success: true };\n return {\n success: false,\n error: result.payment.status === 'pending'\n ? 'Payment pending'\n : result.payment.status === 'requires_action' ||\n (result.payment.requireAction && result.payment.requireAction !== 'none')\n ? 'Payment requires authentication'\n : result.payment.requireActionData?.message || 'Payment declined',\n };\n }\n\n /** Decline locally; the backend has no persisted refusal and no charge is made. */\n async declinePostPurchaseOffer(opts: {\n orderId: string;\n offerId: string;\n }): Promise<{ success: boolean; error?: string }> {\n return { success: true };\n }\n}\n", "import type { HttpClient } from '../http.js';\nimport type { Customer, Order, Subscription } from '../types.js';\n\n/**\n * Customer data -- profile, orders, subscriptions.\n *\n * Requires either an API key or a session token for authentication.\n */\nexport class CustomerModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n ) {}\n\n /** Get customer profile by ID. */\n async getProfile(customerId: string): Promise<Customer> {\n const res = await this.http.get<{ customer: Customer }>(\n `/api/v1/customers/${customerId}`,\n { params: { storeId: this.storeId } },\n );\n return res.customer;\n }\n\n /** Get customer profile by email. */\n async getByEmail(email: string): Promise<Customer | null> {\n try {\n const res = await this.http.get<{ customer: Customer }>(\n '/api/v1/customers/by-email',\n { params: { email, storeId: this.storeId } },\n );\n return res.customer;\n } catch {\n return null;\n }\n }\n\n /**\n * Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the\n * route stores the email only. A portal customer's name and phone go through `portal.updateProfile`.\n */\n async updateProfile(\n customerId: string,\n data: Partial<Pick<Customer, 'email' | 'firstName' | 'lastName' | 'phone' | 'metadata'>>,\n ): Promise<Customer> {\n await this.http.post(`/api/v1/customers/${customerId}`, { customerId, data: { email: data.email } });\n return this.getProfile(customerId);\n }\n\n /** List orders for a customer. */\n async getOrders(\n customerId: string,\n opts?: { limit?: number; offset?: number },\n ): Promise<{ orders: Order[]; total: number }> {\n return this.http.get<{ orders: Order[]; total: number }>(\n `/api/v1/customers/${customerId}/orders`,\n { params: { storeId: this.storeId, limit: opts?.limit, offset: opts?.offset } },\n );\n }\n\n /**\n * Get a single order by ID.\n *\n * **Thank-you pages:** accepted one-click upsells create *child orders*\n * (`metadata.mainOrderId` = this order's id) that land asynchronously \u2014\n * the first fetch right after an accept usually misses them. Pass\n * `waitForRelatedOrders: true` to poll until `order.relatedOrders` is\n * non-empty or the timeout elapses. On timeout the latest snapshot is\n * returned (never throws), so an order with no accepted upsell simply\n * comes back with an empty `relatedOrders` after `timeoutMs`.\n *\n * @example\n * ```ts\n * // Thank-you page: show the main order AND the upsells\n * const order = await tagada.customer.getOrder(orderId, {\n * waitForRelatedOrders: true,\n * });\n * renderOrders([order, ...(order.relatedOrders ?? [])]);\n * ```\n */\n async getOrder(\n orderId: string,\n opts?: {\n /** Poll until `relatedOrders` is non-empty (or `timeoutMs` elapses). */\n waitForRelatedOrders?: boolean;\n /** Max total wait in ms. Default: 8000. */\n timeoutMs?: number;\n /** Delay between polls in ms. Default: 2000. */\n intervalMs?: number;\n },\n ): Promise<Order> {\n const fetchOrder = async (): Promise<Order> => {\n const res = await this.http.get<{ order: Order }>(`/api/v1/orders/${orderId}`, {\n params: { storeId: this.storeId },\n });\n return res.order;\n };\n\n let order = await fetchOrder();\n if (!opts?.waitForRelatedOrders || order.relatedOrders?.length) return order;\n\n const timeoutMs = opts.timeoutMs ?? 8000;\n const intervalMs = opts.intervalMs ?? 2000;\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, Math.max(0, deadline - Date.now()))));\n order = await fetchOrder();\n if (order.relatedOrders?.length) return order;\n }\n return order;\n }\n\n /** List subscriptions for a customer. */\n async getSubscriptions(customerId: string): Promise<Subscription[]> {\n const res = await this.http.get<{ subscriptions: Subscription[] }>(\n `/api/v1/customers/${customerId}/subscriptions`,\n { params: { storeId: this.storeId } },\n );\n return res.subscriptions;\n }\n\n /** Get a single subscription by ID. */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const res = await this.http.get<{ subscription: Subscription }>(\n `/api/v1/subscriptions/${subscriptionId}`,\n { params: { storeId: this.storeId } },\n );\n return res.subscription;\n }\n\n // ---------------------------------------------------------------------------\n // Subscription actions of the logged-in customer (customer portal session).\n // Each one is refused when the store turned that action off.\n // ---------------------------------------------------------------------------\n\n /** Pause billing. `resumeAt` (ISO date) resumes it on that day. */\n async pauseSubscription(subscriptionId: string, opts?: { resumeAt?: string }): Promise<void> {\n await this.http.post('/api/v1/subscriptions/pause', { subscriptionId, resumeAt: opts?.resumeAt });\n }\n\n /** Resume a paused subscription, or one scheduled for cancellation. */\n async resumeSubscription(subscriptionId: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/resume', { subscriptionId });\n }\n\n /** Defer the next charge by one billing period. */\n async skipSubscription(subscriptionId: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/skip', { subscriptionId });\n }\n\n /** Move the next billing date (ISO date, within a year). */\n async rescheduleSubscription(subscriptionId: string, nextBillingDate: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/reschedule', { subscriptionId, nextBillingDate });\n }\n\n /** Change how many units each delivery bills for. */\n async updateSubscriptionQuantity(subscriptionId: string, quantity: number): Promise<void> {\n await this.http.post('/api/v1/subscriptions/quantity', { subscriptionId, quantity });\n }\n\n /**\n * Move to another frequency of the same product: a recurring price id, or `{ optionId }` (a\n * purchase option of the product, priced for the subscription's variant).\n */\n async changeSubscriptionFrequency(\n subscriptionId: string,\n target: string | { optionId: string } | { priceId: string },\n ): Promise<void> {\n const body = typeof target === 'string' ? { priceId: target } : target;\n await this.http.post('/api/v1/subscriptions/frequency', { subscriptionId, ...body });\n }\n\n /**\n * Swap the product a subscription bills for: at one of its recurring prices, or at one of its\n * purchase options (`variantId` defaults to the product's default variant).\n */\n async swapSubscriptionProduct(\n subscriptionId: string,\n target: { productId: string; priceId: string } | { productId: string; optionId: string; variantId?: string },\n ): Promise<void> {\n await this.http.post('/api/v1/subscriptions/swap-product', { subscriptionId, ...target });\n }\n\n /** Attach a newly tokenized card to a subscription. */\n async updateSubscriptionPaymentMethod(subscriptionId: string, tagadaToken: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/payment-method', { subscriptionId, tagadaToken });\n }\n\n /**\n * Cancel a subscription, at the end of the paid period by default. Refused with HTTP 403 when the\n * store does not offer it for this product, or before the subscription's minimum paid orders\n * (error `name` `MINIMUM_ORDERS_NOT_REACHED`).\n */\n async cancelSubscription(subscriptionId: string, opts?: { cancelAtPeriodEnd?: boolean }): Promise<void> {\n await this.http.post('/api/v1/subscriptions/cancel', {\n subscriptionId,\n cancelAtPeriodEnd: opts?.cancelAtPeriodEnd ?? true,\n });\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;gdAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,yBAAAC,EAAA,iBAAAC,ICuDO,IAAMC,EAAN,KAA2B,CAChC,YACmBC,EACAC,EACAC,EACjB,CAHiB,UAAAF,EACA,aAAAC,EACA,cAAAC,CAChB,CAGH,MAAM,YAAYC,EAA8B,CAC9C,MAAM,KAAK,KAAK,KAAK,mCAAoC,CAAE,MAAAA,EAAO,QAAS,KAAK,OAAQ,CAAC,CAC3F,CAGA,MAAM,WAAWA,EAAeC,EAA+C,CAC7E,IAAMC,EAAM,MAAM,KAAK,KAAK,KAA6B,4BAA6B,CACpF,MAAAF,EACA,KAAAC,EACA,QAAS,KAAK,OAChB,CAAC,EACD,YAAK,SAASC,EAAI,KAAK,EAChBA,CACT,CAGA,MAAM,WAAyC,CAC7C,OAAO,KAAK,KAAK,IAAwB,wBAAyB,CAAE,OAAQ,CAAE,QAAS,KAAK,OAAQ,CAAE,CAAC,CACzG,CAGA,MAAM,OAA2B,CAC/B,OAAO,KAAK,KAAK,IAAc,mBAAmB,CACpD,CAG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AL,MAAAC,EAAY,OAAQ,CACtB,IAAMW,EAAQ,MAAM,KAAK,KAAK,KAG3B,kBAAkBZ,EAAK,OAAO,WAAY,CAAE,QAASA,EAAK,QAAS,SAAU,EAAG,CAAC,EACpFW,EAAY,CAAC,EACb,QAAWE,KAAQb,EAAK,MAAO,CAC7B,IAAMc,EAAUF,EAAM,UAAU,OAAOG,GAAK,CArPpD,IAAAd,EAqPuD,OAAAc,EAAK,YAAcF,EAAK,aACrEZ,EAAAW,EAAM,QAAQ,QAAQG,EAAK,SAAS,IAApC,YAAAd,EAAuC,KAAKe,GAAWA,EAAQ,KAAOH,EAAK,YAAU,EACvF,GAAIC,EAAQ,SAAW,GAAKH,EAAU,KAAKI,GAAQA,EAAK,aAAeD,EAAQ,CAAC,EAAE,UAAU,EAC1F,MAAO,CAAE,QAAS,GAAO,MAAO,mBAAoB,EAEtDH,EAAU,KAAK,CAAE,GAAGE,EAAM,WAAYC,EAAQ,CAAC,EAAE,WAAY,UAAWA,EAAQ,CAAC,EAAE,SAAU,CAAC,CAChG,CACF,CACA,IAAMG,EAAS,MAAM,KAAK,kBAAkB,CAC1C,QAASjB,EAAK,QACd,YAAaA,EAAK,QAClB,UAAAW,CACF,CAAC,EACD,OAAIM,EAAO,QAAQ,SAAW,YAAoB,CAAE,QAAS,EAAK,EAC3D,CACL,QAAS,GACT,MAAOA,EAAO,QAAQ,SAAW,UAC7B,kBACAA,EAAO,QAAQ,SAAW,mBACvBA,EAAO,QAAQ,eAAiBA,EAAO,QAAQ,gBAAkB,OAClE,oCACAP,EAAAO,EAAO,QAAQ,oBAAf,YAAAP,EAAkC,UAAW,kBACrD,CACF,CAGA,MAAM,yBAAyBV,EAGmB,CAChD,MAAO,CAAE,QAAS,EAAK,CACzB,CACF,
|
|
6
|
-
"names": ["commerce_exports", "__export", "CustomerModule", "CustomerPortalModule", "OffersModule", "CustomerPortalModule", "http", "storeId", "setToken", "email", "code", "res", "input", "token", "profile", "address", "addressId", "paymentMethodId", "subscriptionId", "lines", "variantId", "quantity", "billing", "date", "OffersModule", "http", "storeId", "payment", "offerId", "opts", "_a", "url", "queryParts", "id", "here", "returnUrl", "payResult", "orderId", "res", "_b", "lineItems", "quote", "item", "matches", "line", "variant", "result", "
|
|
3
|
+
"sources": ["../src/core/modules/commerce.ts", "../src/core/modules/portal/index.ts", "../src/core/modules/offers.ts", "../src/core/errors.ts", "../src/core/modules/customer.ts"],
|
|
4
|
+
"sourcesContent": ["// CDN chunk for capabilities that do not need to run during checkout bootstrap.\nexport { CustomerPortalModule } from './portal/index.js';\nexport { OffersModule } from './offers.js';\nexport { CustomerModule } from './customer.js';\n", "import type { HttpClient } from '../../http.js';\nimport type {\n Billing,\n PortalAcceptOfferInput,\n PortalAddToNextOrderInput,\n PortalAcceptOfferResult,\n PortalAddCardInput,\n PortalAddressInput,\n PortalBuyAgainLine,\n PortalBuyCreditPackInput,\n PortalCancelFlowInput,\n PortalCancelOfferInput,\n PortalCheckoutResult,\n PortalCredits,\n PortalCreditsOrderResult,\n PortalMe,\n PortalOffer,\n PortalProfileInput,\n PortalPublicConfig,\n PortalRedeemCreditsInput,\n PortalSubscriptionResult,\n PortalSwitchInput,\n PortalSwitchResult,\n PortalTargetResult,\n PortalVerifyCodeResult,\n} from './types.js';\n\n/**\n * Customer portal (Subscriptions V3): the store's portal config, the logged-in\n * customer, retention, plan switches, upsell links and credits.\n *\n * Log in with `requestCode` then `verifyCode`; every other call except\n * `getConfig` needs that session. Subscription actions (pause, skip, \u2026) live on\n * `client.customer`.\n *\n * Endpoints:\n * GET /api/v1/portal/config\n * GET /api/v1/portal/me\n * POST /api/v1/portal/cancel-flow\n * POST /api/v1/portal/cancel-flow/accept\n * POST /api/v1/portal/switch\n * GET /api/v1/portal/offers/:token\n * POST /api/v1/portal/offers/accept\n * POST /api/v1/portal/next-order\n * GET /api/v1/portal/credits\n * POST /api/v1/portal/credits/redeem\n * POST /api/v1/portal/credits/packs/buy\n * POST /api/v1/portal/profile, /profile/email-code\n * POST /api/v1/portal/addresses, /addresses/remove, /addresses/default\n * POST /api/v1/portal/payment-methods, /payment-methods/remove, /payment-methods/default\n * POST /api/v1/portal/retry-payment\n * POST /api/v1/portal/buy-again\n * POST /api/v1/portal/membership/join\n * POST /api/v1/subscriptions/send-now, /reactivate, /saved-card, /shipping-address, /skip-date, /unskip\n */\nexport class CustomerPortalModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n private readonly setToken: (token: string) => void,\n ) {}\n\n /** Email a login code to the customer. */\n async requestCode(email: string): Promise<void> {\n await this.http.post('/api/v1/cms/session/request-code', { email, storeId: this.storeId });\n }\n\n /** Exchange the emailed code for a session; later calls send it. */\n async verifyCode(email: string, code: string): Promise<PortalVerifyCodeResult> {\n const res = await this.http.post<PortalVerifyCodeResult>('/api/v1/cms/session/login', {\n email,\n code,\n storeId: this.storeId,\n });\n this.setToken(res.token);\n return res;\n }\n\n /** The store's published portal: design, retention, membership program, products. */\n async getConfig(): Promise<PortalPublicConfig> {\n return this.http.get<PortalPublicConfig>('/api/v1/portal/config', { params: { storeId: this.storeId } });\n }\n\n /** The logged-in customer: profile, orders, subscriptions, membership, credit ledger. */\n async getMe(): Promise<PortalMe> {\n return this.http.get<PortalMe>('/api/v1/portal/me');\n }\n\n /** Cancel a subscription or the membership after the reasons step. */\n async cancelFlow(input: PortalCancelFlowInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/cancel-flow', input);\n }\n\n /** Take the retention offer mapped to the chosen reason instead of cancelling. */\n async acceptCancelOffer(input: PortalCancelOfferInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/cancel-flow/accept', input);\n }\n\n /** Move a subscription or the membership to another option now, charged now. */\n async switchOption(input: PortalSwitchInput): Promise<PortalSwitchResult> {\n return this.http.post<PortalSwitchResult>('/api/v1/portal/switch', input);\n }\n\n /** The upsell a signed link (`/account/offer/<token>`) offers. No login: the token is the authorization. */\n async getOffer(token: string): Promise<PortalOffer> {\n return this.http.get<PortalOffer>(`/api/v1/portal/offers/${encodeURIComponent(token)}`);\n }\n\n /** Accept a signed upsell link and pay it with the card of the original order. A second accept charges nothing. */\n async acceptOffer(input: PortalAcceptOfferInput): Promise<PortalAcceptOfferResult> {\n return this.http.post<PortalAcceptOfferResult>('/api/v1/portal/offers/accept', input);\n }\n\n /** Ship a one-time item with the subscription's next renewal, charged with it; quantity 0 takes it off. */\n async addToNextOrder(input: PortalAddToNextOrderInput): Promise<PortalTargetResult> {\n return this.http.post<PortalTargetResult>('/api/v1/portal/next-order', input);\n }\n\n /** Credit balance and ledger of the logged-in customer. */\n async getCredits(): Promise<PortalCredits> {\n return this.http.get<PortalCredits>('/api/v1/portal/credits');\n }\n\n /** Pay a product with credits. */\n async redeemCredits(input: PortalRedeemCreditsInput): Promise<PortalCreditsOrderResult> {\n return this.http.post<PortalCreditsOrderResult>('/api/v1/portal/credits/redeem', input);\n }\n\n /** Buy a credit pack with the stored card. */\n async buyCreditPack(input: PortalBuyCreditPackInput): Promise<PortalCreditsOrderResult> {\n return this.http.post<PortalCreditsOrderResult>('/api/v1/portal/credits/packs/buy', input);\n }\n\n // \u2500\u2500 The customer's own account \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /** Email a code to a new address; `updateProfile` saves that email with it (`emailCode`). */\n async requestEmailChangeCode(email: string): Promise<void> {\n await this.http.post('/api/v1/portal/profile/email-code', { email });\n }\n\n /** The logged-in customer's name, email and phone. */\n async updateProfile(profile: PortalProfileInput): Promise<void> {\n await this.http.post('/api/v1/portal/profile', profile);\n }\n\n /** Add an address, or replace the one with that id; `isDefault` makes it the default. */\n async saveAddress(address: PortalAddressInput): Promise<{ addressId: string }> {\n return this.http.post('/api/v1/portal/addresses', address);\n }\n\n /** Remove an address; the default one stays until another is the default. */\n async removeAddress(addressId: string): Promise<void> {\n await this.http.post('/api/v1/portal/addresses/remove', { addressId });\n }\n\n async setDefaultAddress(addressId: string): Promise<void> {\n await this.http.post('/api/v1/portal/addresses/default', { addressId });\n }\n\n /** Save a card tokenized with `client.payment.tokenizeCard`. */\n async addCard(input: PortalAddCardInput): Promise<{ paymentMethodId: string }> {\n return this.http.post('/api/v1/portal/payment-methods', input);\n }\n\n /** Remove a saved card; refused while a live subscription is paid with it. */\n async removeCard(paymentMethodId: string): Promise<void> {\n await this.http.post('/api/v1/portal/payment-methods/remove', { paymentMethodId });\n }\n\n /** The default card also becomes the card of every live subscription. */\n async setDefaultPaymentMethod(paymentMethodId: string): Promise<void> {\n await this.http.post('/api/v1/portal/payment-methods/default', { paymentMethodId });\n }\n\n /** Charge a past-due subscription again now. */\n async retryPayment(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/portal/retry-payment', { subscriptionId });\n }\n\n /** Order products again at today's one-time price with the default card and address. */\n async buyAgain(lines: readonly PortalBuyAgainLine[]): Promise<PortalCheckoutResult> {\n return this.http.post('/api/v1/portal/buy-again', { lines: lines.map(({ variantId, quantity }) => ({ variantId, quantity })) });\n }\n\n /** Buy the Membership's monthly or yearly option with the default card. */\n async joinMembership(billing: Billing): Promise<PortalCheckoutResult> {\n return this.http.post('/api/v1/portal/membership/join', { billing });\n }\n\n /** Buy one product now at its one-time price with the default card and address. */\n async buyNow(variantId: string, quantity = 1): Promise<PortalCheckoutResult> {\n return this.buyAgain([{ variantId, quantity }]);\n }\n\n /** Charge and ship a subscription's next order today. */\n async sendNow(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/send-now', { subscriptionId });\n }\n\n /** Restart a cancelled subscription, or keep one set to end at its period end. */\n async reactivateSubscription(subscriptionId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/reactivate', { subscriptionId });\n }\n\n /** Bill a subscription on another saved card. */\n async setSubscriptionCard(subscriptionId: string, paymentMethodId: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/saved-card', { subscriptionId, paymentMethodId });\n }\n\n /** Ship a subscription to an address of the book; null follows the default address. */\n async setSubscriptionAddress(subscriptionId: string, addressId: string | null): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/shipping-address', { subscriptionId, addressId });\n }\n\n /** Skip one upcoming delivery date (`YYYY-MM-DD`); skipping the next one moves the next charge. */\n async skipDate(subscriptionId: string, date: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/skip-date', { subscriptionId, date });\n }\n\n /** Take back a skipped delivery date (`YYYY-MM-DD`). */\n async unskipDate(subscriptionId: string, date: string): Promise<PortalSubscriptionResult> {\n return this.http.post('/api/v1/subscriptions/unskip', { subscriptionId, date });\n }\n}\n", "import type { HttpClient } from '../http.js';\nimport type {\n Offer,\n OfferPreview,\n OfferPayResult,\n ProcessPaymentResult,\n} from '../types.js';\nimport type { PaymentModule } from './payment.js';\n\n/**\n * Offers \u2014 upsells, downsells, order bumps, and post-purchase offers.\n *\n * Endpoints align with the plugin-sdk patterns:\n * GET /api/v1/offers/:id \u2014 single offer\n * GET /api/v1/stores/:storeId/offers \u2014 list store offers\n * POST /api/v1/offers/:offerId/preview \u2014 preview pricing\n * POST /api/v1/offers/:offerId/pay-preview \u2014 pay a previewed offer (one-click)\n * POST /api/v1/checkout-sessions/:id/toggle-order-bump \u2014 toggle order bump\n * GET /api/v1/post-purchase/:orderId/offers \u2014 post-purchase offers for an order\n * Post-purchase acceptance uses pay-preview; declining is a local decision.\n */\nexport class OffersModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n private readonly payment?: PaymentModule,\n ) {}\n\n // ---------------------------------------------------------------------------\n // Offer loading\n // ---------------------------------------------------------------------------\n\n /** Get a single offer by ID. */\n async getOffer(offerId: string): Promise<Offer> {\n return this.http.get<Offer>(`/api/v1/offers/${offerId}`);\n }\n\n /** List offers for the current store. Optionally filter by type or a set of IDs. */\n async listOffers(opts?: {\n type?: 'upsell' | 'orderbump';\n ids?: string[];\n }): Promise<Offer[]> {\n let url = `/api/v1/stores/${this.storeId}/offers`;\n\n const queryParts: string[] = [];\n if (opts?.type) queryParts.push(`type=${encodeURIComponent(opts.type)}`);\n if (opts?.ids?.length) {\n for (const id of opts.ids) queryParts.push(`ids=${encodeURIComponent(id)}`);\n }\n if (queryParts.length) url += `?${queryParts.join('&')}`;\n\n const res = await this.http.get<{ offers: Offer[] }>(url);\n return res.offers ?? [];\n }\n\n // ---------------------------------------------------------------------------\n // Preview & pay (one-click upsell flow from plugin-sdk)\n // ---------------------------------------------------------------------------\n\n /**\n * Preview offer pricing. Returns line items with amounts and totals.\n *\n * A Studio offer block is previewed under `blockoffer:<blockId>` and read from\n * the step its funnel session stands on: pass that session's id\n * (see {@link enterFunnelStep}).\n */\n async previewOffer(opts: {\n offerId: string;\n currency?: string;\n lineItems?: Array<{ lineItemId?: string; productId?: string; variantId: string; quantity: number }>;\n funnelSessionId?: string;\n }): Promise<OfferPreview> {\n return this.http.post<OfferPreview>(`/api/v1/offers/${opts.offerId}/preview`, {\n offerId: opts.offerId,\n currency: opts.currency ?? '',\n lineItems: opts.lineItems,\n funnelSessionId: opts.funnelSessionId,\n });\n }\n\n /**\n * Put the buyer on a step of a funnel, for pages the funnel does not serve\n * itself: its offer blocks are then previewed and accepted as\n * `blockoffer:<blockId>` with the returned `funnelSessionId`. Uses the\n * checkout session's token, so the funnel session is the paying customer's.\n * Pass `checkoutToken` at checkout to link that checkout to the funnel\n * session, and `funnelSessionId` to move an open session to another step.\n */\n async enterFunnelStep(opts: {\n funnelId: string;\n stepId: string;\n accountId: string;\n funnelSessionId?: string;\n checkoutToken?: string;\n }): Promise<{ funnelSessionId: string }> {\n const here = typeof window !== 'undefined' ? window.location.origin : 'http://localhost';\n const res = await this.http.post<{ context: { sessionId: string } }>('/api/v1/funnel/initialize', {\n // Placeholder ids: the server takes the customer and the CMS session from the token.\n cmsSession: { customerId: 'anon_placeholder', sessionId: 'anon_placeholder', storeId: this.storeId, accountId: opts.accountId },\n funnelId: opts.funnelId,\n funnelStepId: opts.stepId,\n existingSessionId: opts.funnelSessionId,\n currentUrl: opts.checkoutToken ? `${here}/?checkoutToken=${encodeURIComponent(opts.checkoutToken)}` : undefined,\n draft: false,\n });\n return { funnelSessionId: res.context.sessionId };\n }\n\n /**\n * Pay a previously previewed offer (one-click charge).\n * Used after a main order so the stored payment instrument is reused.\n *\n * **Low-level API.** Returns the raw `OfferPayResult` \u2014 `requireAction`,\n * polling, and 3DS redirects are NOT handled. For most cases, use\n * {@link processOfferPayment} which orchestrates the full lifecycle.\n */\n async payPreviewedOffer(opts: {\n offerId: string;\n mainOrderId: string;\n currency?: string;\n lineItems?: Array<{ lineItemId?: string; productId?: string; variantId: string; quantity: number }>;\n returnUrl?: string;\n paymentInstrumentId?: string;\n funnelSessionId?: string;\n }): Promise<OfferPayResult> {\n return this.http.post<OfferPayResult>(`/api/v1/offers/${opts.offerId}/pay-preview`, {\n offerId: opts.offerId,\n currency: opts.currency ?? '',\n lineItems: opts.lineItems,\n returnUrl: opts.returnUrl ?? (typeof window !== 'undefined' ? window.location.href : ''),\n mainOrderId: opts.mainOrderId,\n paymentInstrumentId: opts.paymentInstrumentId,\n funnelSessionId: opts.funnelSessionId,\n });\n }\n\n /**\n * One-click upsell with full lifecycle handling.\n *\n * Like `payment.processPayment()` but for previewed offers: charges the\n * stored instrument from `mainOrderId`, runs any 3DS challenge or bank\n * redirect, polls until terminal, and returns a typed\n * `ProcessPaymentResult` (`succeeded` / `requires_redirect` /\n * `failed` / `pending`).\n *\n * Use this instead of the lower-level `payPreviewedOffer()` whenever you\n * don't need to inspect the raw `OfferPayResult` shape \u2014 which is most\n * of the time.\n *\n * @example\n * ```ts\n * const result = await tagada.offers.processOfferPayment({\n * offerId: 'offer_xxx',\n * mainOrderId: order.id,\n * returnUrl: window.location.href,\n * });\n *\n * switch (result.status) {\n * case 'succeeded':\n * window.location.href = '/upsell-2';\n * break;\n * case 'requires_redirect':\n * window.location.href = result.redirectUrl;\n * break;\n * case 'failed':\n * showError(result.error);\n * break;\n * }\n * ```\n */\n async processOfferPayment(opts: {\n offerId: string;\n mainOrderId: string;\n currency?: string;\n lineItems?: Array<{\n lineItemId?: string;\n productId?: string;\n variantId: string;\n quantity: number;\n }>;\n returnUrl?: string;\n paymentInstrumentId?: string;\n funnelSessionId?: string;\n }): Promise<ProcessPaymentResult> {\n if (!this.payment) {\n throw new Error(\n 'OffersModule: no PaymentModule injected. ' +\n 'Use createHeadlessClient() instead of constructing OffersModule directly.',\n );\n }\n const returnUrl =\n opts.returnUrl ?? (typeof window !== 'undefined' ? window.location.href : undefined);\n const payResult = await this.payPreviewedOffer({ ...opts, returnUrl });\n return this.payment.finalize(\n { payment: payResult.payment, order: payResult.order },\n { returnUrl },\n );\n }\n\n // ---------------------------------------------------------------------------\n // Order bumps (checkout-session scoped)\n // ---------------------------------------------------------------------------\n\n /** Toggle an order bump on/off within a checkout session. */\n async toggleOrderBump(opts: {\n checkoutSessionId: string;\n orderBumpOfferId: string;\n selected: boolean;\n }): Promise<unknown> {\n return this.http.post(\n `/api/v1/checkout-sessions/${opts.checkoutSessionId}/toggle-order-bump`,\n {\n orderBumpOfferId: opts.orderBumpOfferId,\n selected: opts.selected,\n },\n );\n }\n\n // ---------------------------------------------------------------------------\n // Post-purchase offers (order-scoped)\n // ---------------------------------------------------------------------------\n\n /** List post-purchase offers for an order. */\n async listPostPurchaseOffers(orderId: string): Promise<Offer[]> {\n const res = await this.http.get<Offer[]>(`/api/v1/post-purchase/${orderId}/offers`);\n return Array.isArray(res) ? res : [];\n }\n\n /** Accept a post-purchase offer. Only a confirmed charge returns success. */\n async acceptPostPurchaseOffer(opts: {\n orderId: string;\n offerId: string;\n items?: Array<{ variantId: string; quantity: number }>;\n }): Promise<{ success: boolean; error?: string }> {\n // The server matches overrides by line-item/product ID, not variant alone.\n // Resolve against this offer's quote so an unrelated variant cannot silently\n // fall back to charging the offer's default selection.\n let lineItems: Array<{ lineItemId: string; productId: string; variantId: string; quantity: number }> | undefined;\n if (opts.items?.length) {\n const quote = await this.http.post<{\n lineItems: Array<{ lineItemId: string; productId: string; variantId: string }>;\n preview: { options: Record<string, Array<{ id: string }>> };\n }>(`/api/v1/offers/${opts.offerId}/preview`, { offerId: opts.offerId, currency: '' });\n lineItems = [];\n for (const item of opts.items) {\n const matches = quote.lineItems.filter(line => line.variantId === item.variantId ||\n quote.preview.options[line.productId]?.some(variant => variant.id === item.variantId));\n if (matches.length !== 1 || lineItems.some(line => line.lineItemId === matches[0].lineItemId)) {\n return { success: false, error: 'Invalid selection' };\n }\n lineItems.push({ ...item, lineItemId: matches[0].lineItemId, productId: matches[0].productId });\n }\n }\n const result = await this.payPreviewedOffer({\n offerId: opts.offerId,\n mainOrderId: opts.orderId,\n lineItems,\n });\n if (result.payment.status === 'succeeded') return { success: true };\n return {\n success: false,\n error: result.payment.status === 'pending'\n ? 'Payment pending'\n : result.payment.status === 'requires_action' ||\n (result.payment.requireAction && result.payment.requireAction !== 'none')\n ? 'Payment requires authentication'\n : result.payment.requireActionData?.message || 'Payment declined',\n };\n }\n\n /** Decline locally; the backend has no persisted refusal and no charge is made. */\n async declinePostPurchaseOffer(opts: {\n orderId: string;\n offerId: string;\n }): Promise<{ success: boolean; error?: string }> {\n return { success: true };\n }\n}\n", "/** Base error for all TagadaPay headless SDK errors. */\nexport class TagadaError extends Error {\n public readonly code: string;\n public readonly statusCode?: number;\n public readonly details?: Record<string, unknown>;\n\n constructor(\n message: string,\n code: string,\n statusCode?: number,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'TagadaError';\n this.code = code;\n this.statusCode = statusCode;\n this.details = details;\n }\n}\n\n/** Thrown when the API returns 401/403. */\nexport class TagadaAuthError extends TagadaError {\n constructor(message = 'Authentication failed. Check your API key or checkout token.') {\n super(message, 'auth_error', 401);\n this.name = 'TagadaAuthError';\n }\n}\n\n/** Thrown when the API returns 422 with validation errors. */\nexport class TagadaValidationError extends TagadaError {\n public readonly errors: Array<{ field: string; message: string }>;\n /**\n * Application error code from the API, when it sends one \u2014 e.g.\n * `MISSING_SHIPPING_ADDRESS` when a cart containing a shippable product is\n * paid with no address (#TAG-1989). Branch on this rather than on the\n * message, which is customer-facing and may be reworded.\n */\n public readonly appCode?: string;\n\n constructor(\n message: string,\n errors: Array<{ field: string; message: string }> = [],\n appCode?: string,\n details?: Record<string, unknown>,\n ) {\n super(message, 'validation_error', 422, { errors, ...details });\n this.name = 'TagadaValidationError';\n this.errors = errors;\n this.appCode = appCode;\n }\n}\n\n/** Thrown when a resource is not found (404). */\nexport class TagadaNotFoundError extends TagadaError {\n constructor(resource: string, id: string) {\n super(`${resource} \"${id}\" not found.`, 'not_found', 404);\n this.name = 'TagadaNotFoundError';\n }\n}\n\n/** Thrown when the API returns 429. */\nexport class TagadaRateLimitError extends TagadaError {\n public readonly retryAfterMs: number;\n\n constructor(retryAfterMs = 1000) {\n super(`Rate limited. Retry after ${retryAfterMs}ms.`, 'rate_limit', 429);\n this.name = 'TagadaRateLimitError';\n this.retryAfterMs = retryAfterMs;\n }\n}\n\n/** Thrown when a payment fails or requires action. */\nexport class TagadaPaymentError extends TagadaError {\n public readonly paymentId?: string;\n public readonly requireAction?: string;\n\n constructor(\n message: string,\n opts?: { paymentId?: string; requireAction?: string; details?: Record<string, unknown> },\n ) {\n super(message, 'payment_error', undefined, opts?.details);\n this.name = 'TagadaPaymentError';\n this.paymentId = opts?.paymentId;\n this.requireAction = opts?.requireAction;\n }\n}\n\n/** Thrown on network / fetch failures. */\nexport class TagadaNetworkError extends TagadaError {\n constructor(message = 'Network request failed. Check your connection.') {\n super(message, 'network_error');\n this.name = 'TagadaNetworkError';\n }\n}\n", "import { TagadaError, TagadaNotFoundError } from '../errors.js';\nimport type { HttpClient } from '../http.js';\nimport type { Customer, Order, Subscription } from '../types.js';\n\n/** One row of `GET /api/v1/subscriptions`. */\ninterface CustomerSubscriptionRow {\n id: string;\n status: Subscription['status'];\n customerId: string;\n priceId: string;\n currency: string;\n cancelAtPeriodEnd: boolean;\n currentPeriodStart: string;\n currentPeriodEnd: string;\n priceInterval: string | null;\n priceIntervalCount: number | null;\n priceCurrencyOptions: Record<string, { amount: number }> | null;\n}\n\nfunction toSubscription(row: CustomerSubscriptionRow, storeId: string): Subscription {\n return {\n ...row,\n storeId,\n amount: row.priceCurrencyOptions?.[row.currency]?.amount ?? 0,\n interval: row.priceInterval ?? '',\n intervalCount: row.priceIntervalCount ?? 1,\n };\n}\n\n/**\n * Customer data -- profile, orders, subscriptions.\n *\n * Requires either an API key or a session token for authentication.\n */\nexport class CustomerModule {\n constructor(\n private readonly http: HttpClient,\n private readonly storeId: string,\n ) {}\n\n /** Get customer profile by ID. */\n async getProfile(customerId: string): Promise<Customer> {\n const res = await this.http.get<{ customer: Customer }>(\n `/api/v1/customers/${customerId}`,\n { params: { storeId: this.storeId } },\n );\n return res.customer;\n }\n\n /**\n * Not available: no route finds a customer by email for a storefront session. The only email\n * search (`POST /api/v1/customers/search`) needs a secret API key of the whole account, which a\n * storefront must never ship. Always rejects with a `TagadaError` of code `not_supported`, without\n * sending a request. For the logged-in customer use `portal.getMe()` (Subscriptions V3 stores) or\n * `getProfile(customerId)`.\n *\n * @deprecated There is no API route behind it.\n */\n async getByEmail(email: string): Promise<Customer | null> {\n throw new TagadaError(\n 'customer.getByEmail is not available: no API route finds a customer by email for a storefront session.',\n 'not_supported',\n );\n }\n\n /**\n * Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the\n * route stores the email only. A portal customer's name and phone go through `portal.updateProfile`.\n */\n async updateProfile(\n customerId: string,\n data: Partial<Pick<Customer, 'email' | 'firstName' | 'lastName' | 'phone' | 'metadata'>>,\n ): Promise<Customer> {\n await this.http.post(`/api/v1/customers/${customerId}`, { customerId, data: { email: data.email } });\n return this.getProfile(customerId);\n }\n\n /**\n * The customer's orders on this store, newest first (`GET /api/v1/orders/customer/:customerId`).\n * Needs a session of that customer: the checkout session, or a portal login\n * (`portal.verifyCode`). Another customer's id rejects with `TagadaNotFoundError`. The route sends\n * every order at once: `limit` and `offset` slice them here, `total` counts them all.\n */\n async getOrders(\n customerId: string,\n opts?: { limit?: number; offset?: number },\n ): Promise<{ orders: Order[]; total: number }> {\n const { orders } = await this.http.get<{ orders: Order[] }>(`/api/v1/orders/customer/${customerId}`, {\n params: { storeId: this.storeId },\n });\n const start = opts?.offset ?? 0;\n const end = opts?.limit === undefined ? undefined : start + opts.limit;\n return { orders: orders.slice(start, end), total: orders.length };\n }\n\n /**\n * Get a single order by ID.\n *\n * **Thank-you pages:** accepted one-click upsells create *child orders*\n * (`metadata.mainOrderId` = this order's id) that land asynchronously \u2014\n * the first fetch right after an accept usually misses them. Pass\n * `waitForRelatedOrders: true` to poll until `order.relatedOrders` is\n * non-empty or the timeout elapses. On timeout the latest snapshot is\n * returned (never throws), so an order with no accepted upsell simply\n * comes back with an empty `relatedOrders` after `timeoutMs`.\n *\n * @example\n * ```ts\n * // Thank-you page: show the main order AND the upsells\n * const order = await tagada.customer.getOrder(orderId, {\n * waitForRelatedOrders: true,\n * });\n * renderOrders([order, ...(order.relatedOrders ?? [])]);\n * ```\n */\n async getOrder(\n orderId: string,\n opts?: {\n /** Poll until `relatedOrders` is non-empty (or `timeoutMs` elapses). */\n waitForRelatedOrders?: boolean;\n /** Max total wait in ms. Default: 8000. */\n timeoutMs?: number;\n /** Delay between polls in ms. Default: 2000. */\n intervalMs?: number;\n },\n ): Promise<Order> {\n const fetchOrder = async (): Promise<Order> => {\n const res = await this.http.get<{ order: Order }>(`/api/v1/orders/${orderId}`, {\n params: { storeId: this.storeId },\n });\n return res.order;\n };\n\n let order = await fetchOrder();\n if (!opts?.waitForRelatedOrders || order.relatedOrders?.length) return order;\n\n const timeoutMs = opts.timeoutMs ?? 8000;\n const intervalMs = opts.intervalMs ?? 2000;\n const deadline = Date.now() + timeoutMs;\n\n while (Date.now() < deadline) {\n await new Promise((resolve) => setTimeout(resolve, Math.min(intervalMs, Math.max(0, deadline - Date.now()))));\n order = await fetchOrder();\n if (order.relatedOrders?.length) return order;\n }\n return order;\n }\n\n /**\n * The customer's subscriptions on this store, newest first (`GET /api/v1/subscriptions`). The\n * route answers for the customer of the session: the checkout session, or a portal login\n * (`portal.verifyCode`), which a Subscriptions V3 store requires. Another customer's id gets `[]`.\n * Only the 20 most recent come back: the route's page size cannot travel in a query string.\n */\n async getSubscriptions(customerId: string): Promise<Subscription[]> {\n const { items } = await this.http.get<{ items: CustomerSubscriptionRow[] }>('/api/v1/subscriptions');\n return items.filter((row) => row.customerId === customerId).map((row) => toSubscription(row, this.storeId));\n }\n\n /**\n * One subscription of the session's customer. No route reads a subscription by id: this picks it\n * from `getSubscriptions`' route, so it needs the same session and finds only the 20 most recent.\n * Rejects with `TagadaNotFoundError` when it is not among them.\n */\n async getSubscription(subscriptionId: string): Promise<Subscription> {\n const { items } = await this.http.get<{ items: CustomerSubscriptionRow[] }>('/api/v1/subscriptions');\n const row = items.find((item) => item.id === subscriptionId);\n if (!row) throw new TagadaNotFoundError('Subscription', subscriptionId);\n return toSubscription(row, this.storeId);\n }\n\n // ---------------------------------------------------------------------------\n // Subscription actions of the logged-in customer (customer portal session).\n // Each one is refused when the store turned that action off.\n // ---------------------------------------------------------------------------\n\n /** Pause billing. `resumeAt` (ISO date) resumes it on that day. */\n async pauseSubscription(subscriptionId: string, opts?: { resumeAt?: string }): Promise<void> {\n await this.http.post('/api/v1/subscriptions/pause', { subscriptionId, resumeAt: opts?.resumeAt });\n }\n\n /** Resume a paused subscription, or one scheduled for cancellation. */\n async resumeSubscription(subscriptionId: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/resume', { subscriptionId });\n }\n\n /** Defer the next charge by one billing period. */\n async skipSubscription(subscriptionId: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/skip', { subscriptionId });\n }\n\n /** Move the next billing date (ISO date, within a year). */\n async rescheduleSubscription(subscriptionId: string, nextBillingDate: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/reschedule', { subscriptionId, nextBillingDate });\n }\n\n /** Change how many units each delivery bills for. */\n async updateSubscriptionQuantity(subscriptionId: string, quantity: number): Promise<void> {\n await this.http.post('/api/v1/subscriptions/quantity', { subscriptionId, quantity });\n }\n\n /**\n * Move to another frequency of the same product: a recurring price id, or `{ optionId }` (a\n * purchase option of the product, priced for the subscription's variant).\n */\n async changeSubscriptionFrequency(\n subscriptionId: string,\n target: string | { optionId: string } | { priceId: string },\n ): Promise<void> {\n const body = typeof target === 'string' ? { priceId: target } : target;\n await this.http.post('/api/v1/subscriptions/frequency', { subscriptionId, ...body });\n }\n\n /**\n * Swap the product a subscription bills for: at one of its recurring prices, or at one of its\n * purchase options (`variantId` defaults to the product's default variant).\n */\n async swapSubscriptionProduct(\n subscriptionId: string,\n target: { productId: string; priceId: string } | { productId: string; optionId: string; variantId?: string },\n ): Promise<void> {\n await this.http.post('/api/v1/subscriptions/swap-product', { subscriptionId, ...target });\n }\n\n /** Attach a newly tokenized card to a subscription. */\n async updateSubscriptionPaymentMethod(subscriptionId: string, tagadaToken: string): Promise<void> {\n await this.http.post('/api/v1/subscriptions/payment-method', { subscriptionId, tagadaToken });\n }\n\n /**\n * Cancel a subscription, at the end of the paid period by default. Refused with HTTP 403 when the\n * store does not offer it for this product, or before the subscription's minimum paid orders\n * (error `name` `MINIMUM_ORDERS_NOT_REACHED`).\n */\n async cancelSubscription(subscriptionId: string, opts?: { cancelAtPeriodEnd?: boolean }): Promise<void> {\n await this.http.post('/api/v1/subscriptions/cancel', {\n subscriptionId,\n cancelAtPeriodEnd: opts?.cancelAtPeriodEnd ?? true,\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;gdAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EA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AW,SAAW,CAAE,QAASA,CAAO,EAAIA,EAChE,MAAM,KAAK,KAAK,KAAK,kCAAmC,CAAE,eAAAL,EAAgB,GAAGM,CAAK,CAAC,CACrF,CAMA,MAAM,wBACJN,EACAK,EACe,CACf,MAAM,KAAK,KAAK,KAAK,qCAAsC,CAAE,eAAAL,EAAgB,GAAGK,CAAO,CAAC,CAC1F,CAGA,MAAM,gCAAgCL,EAAwBO,EAAoC,CAChG,MAAM,KAAK,KAAK,KAAK,uCAAwC,CAAE,eAAAP,EAAgB,YAAAO,CAAY,CAAC,CAC9F,CAOA,MAAM,mBAAmBP,EAAwBZ,EAAuD,CACtG,MAAM,KAAK,KAAK,KAAK,+BAAgC,CACnD,eAAAY,EACA,mBAAmBZ,GAAA,YAAAA,EAAM,oBAAqB,EAChD,CAAC,CACH,CACF",
|
|
6
|
+
"names": ["commerce_exports", "__export", "CustomerModule", "CustomerPortalModule", "OffersModule", "CustomerPortalModule", "http", "storeId", "setToken", "email", "code", "res", "input", "token", "profile", "address", "addressId", "paymentMethodId", "subscriptionId", "lines", "variantId", "quantity", "billing", "date", "OffersModule", "http", "storeId", "payment", "offerId", "opts", "_a", "url", "queryParts", "id", "here", "returnUrl", "payResult", "orderId", "res", "_b", "lineItems", "quote", "item", "matches", "line", "variant", "result", "TagadaError", "message", "code", "statusCode", "details", "TagadaNotFoundError", "TagadaError", "resource", "id", "toSubscription", "row", "storeId", "_a", "_b", "CustomerModule", "http", "customerId", "email", "TagadaError", "data", "opts", "orders", "start", "end", "orderId", "fetchOrder", "order", "timeoutMs", "intervalMs", "deadline", "resolve", "items", "subscriptionId", "item", "TagadaNotFoundError", "nextBillingDate", "quantity", "target", "body", "tagadaToken"]
|
|
7
7
|
}
|