@delopay/sdk 0.481.0 → 0.482.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/dist/airwallexCard.cjs.map +1 -1
- package/dist/branding.cjs.map +1 -1
- package/dist/cardFormStyles.cjs.map +1 -1
- package/dist/checkoutSession.cjs +2 -2
- package/dist/checkoutSession.cjs.map +1 -1
- package/dist/checkoutSession.js +1 -1
- package/dist/chunk-244VZFFO.cjs.map +1 -1
- package/dist/chunk-2IJRBJXW.cjs.map +1 -1
- package/dist/{chunk-U72OIM7A.cjs → chunk-2OVTWQ3B.cjs} +7 -2
- package/dist/chunk-2OVTWQ3B.cjs.map +1 -0
- package/dist/{chunk-TSAQN7I5.js → chunk-2W55GSRP.js} +2 -2
- package/dist/chunk-2W55GSRP.js.map +1 -0
- package/dist/chunk-34PC72O7.cjs.map +1 -1
- package/dist/chunk-3GBWQWTP.cjs.map +1 -1
- package/dist/chunk-3YBBJT3Y.cjs.map +1 -1
- package/dist/chunk-44QBWVRS.cjs.map +1 -1
- package/dist/chunk-4EKAWNYI.cjs.map +1 -1
- package/dist/chunk-4LN4BR2T.cjs.map +1 -1
- package/dist/chunk-4T4XHPYN.cjs.map +1 -1
- package/dist/chunk-5CITBN33.cjs.map +1 -1
- package/dist/chunk-5HCKC4HF.cjs.map +1 -1
- package/dist/{chunk-LZUHCGJ3.js → chunk-5LSXCHJU.js} +5 -2
- package/dist/chunk-5LSXCHJU.js.map +1 -0
- package/dist/chunk-5O2JSQYA.cjs.map +1 -1
- package/dist/chunk-5QS67SBO.cjs.map +1 -1
- package/dist/chunk-6BFZS4YP.cjs.map +1 -1
- package/dist/chunk-6EBY2KKL.cjs.map +1 -1
- package/dist/{chunk-6MXPGE7O.cjs → chunk-6EOKEO6F.cjs} +9 -9
- package/dist/chunk-6EOKEO6F.cjs.map +1 -0
- package/dist/chunk-6LFOM6HV.cjs.map +1 -1
- package/dist/chunk-6LOWE2YI.cjs.map +1 -1
- package/dist/chunk-6LSG5Z4T.cjs.map +1 -1
- package/dist/chunk-6SU2MTN2.cjs.map +1 -1
- package/dist/chunk-6YCDLSIU.cjs.map +1 -1
- package/dist/chunk-75E5WNJG.cjs.map +1 -1
- package/dist/chunk-7JV6VVO7.cjs.map +1 -1
- package/dist/chunk-7NKJD5ST.cjs.map +1 -1
- package/dist/chunk-7QZCUXWB.cjs.map +1 -1
- package/dist/chunk-7VXF5D67.cjs.map +1 -1
- package/dist/chunk-ABWAYMN5.cjs.map +1 -1
- package/dist/chunk-ACZ2R47X.cjs.map +1 -1
- package/dist/chunk-AYUYJO3I.cjs.map +1 -1
- package/dist/chunk-BCA3TCGS.cjs.map +1 -1
- package/dist/chunk-BP6KDQ6I.cjs.map +1 -1
- package/dist/chunk-BRY3W7N3.cjs.map +1 -1
- package/dist/{chunk-FDHLDKNY.cjs → chunk-BT3UAUEV.cjs} +2 -2
- package/dist/chunk-BT3UAUEV.cjs.map +1 -0
- package/dist/chunk-CAMALM35.cjs.map +1 -1
- package/dist/chunk-CCN44NZJ.cjs.map +1 -1
- package/dist/{chunk-EK7RLJZB.js → chunk-CQ5WZMCN.js} +7 -2
- package/dist/chunk-CQ5WZMCN.js.map +1 -0
- package/dist/chunk-CR3JBTP3.cjs.map +1 -1
- package/dist/chunk-CYH4HZ4Y.cjs.map +1 -1
- package/dist/chunk-DJASVBOJ.cjs.map +1 -1
- package/dist/chunk-EEB2HDYL.cjs.map +1 -1
- package/dist/chunk-ENPSUWTS.cjs.map +1 -1
- package/dist/chunk-EQ6P6ZND.cjs.map +1 -1
- package/dist/chunk-EXPWQBI3.cjs.map +1 -1
- package/dist/{chunk-OPOSNWK4.cjs → chunk-EYHSXJMJ.cjs} +4 -2
- package/dist/chunk-EYHSXJMJ.cjs.map +1 -0
- package/dist/chunk-F3I5DOWV.cjs.map +1 -1
- package/dist/chunk-F46K5H3U.cjs.map +1 -1
- package/dist/chunk-F6S3WCCB.cjs.map +1 -1
- package/dist/chunk-FQRC4NJG.cjs.map +1 -1
- package/dist/chunk-FTWGI7UZ.cjs.map +1 -1
- package/dist/chunk-FYISDU2Y.cjs.map +1 -1
- package/dist/chunk-GG52SAHA.cjs.map +1 -1
- package/dist/chunk-GK5FWN4H.cjs.map +1 -1
- package/dist/chunk-GSQN5EOO.cjs.map +1 -1
- package/dist/chunk-GW7IHYXR.cjs.map +1 -1
- package/dist/chunk-GWSVQXEY.cjs.map +1 -1
- package/dist/chunk-HLHML5ES.cjs.map +1 -1
- package/dist/chunk-HLKFUOAQ.cjs.map +1 -1
- package/dist/chunk-HLYGHP6F.cjs.map +1 -1
- package/dist/chunk-HSJABE7X.cjs.map +1 -1
- package/dist/{chunk-ABDDRKOT.js → chunk-HYQXNRST.js} +3 -2
- package/dist/chunk-HYQXNRST.js.map +1 -0
- package/dist/chunk-I2W7AO4B.cjs.map +1 -1
- package/dist/chunk-I2XGNALG.cjs.map +1 -1
- package/dist/chunk-IGHAJNC6.cjs.map +1 -1
- package/dist/chunk-IKXGA2Z5.cjs.map +1 -1
- package/dist/chunk-IR2LFKKA.cjs.map +1 -1
- package/dist/{chunk-NH2TUO7X.js → chunk-J3NCUUG7.js} +5 -5
- package/dist/chunk-J4ZB7MU4.cjs.map +1 -1
- package/dist/{chunk-E2TF7JDB.cjs → chunk-J5RPSRBQ.cjs} +9 -8
- package/dist/chunk-J5RPSRBQ.cjs.map +1 -0
- package/dist/chunk-JPPRDMTJ.cjs.map +1 -1
- package/dist/chunk-K5Q2H3VD.cjs.map +1 -1
- package/dist/{chunk-CPGGSHNB.js → chunk-K5WRCYXA.js} +4 -2
- package/dist/chunk-K5WRCYXA.js.map +1 -0
- package/dist/chunk-KD5Y2YWK.cjs.map +1 -1
- package/dist/chunk-KJDMNF2T.cjs.map +1 -1
- package/dist/chunk-KLONGJCL.cjs.map +1 -1
- package/dist/{chunk-EHRQSUIK.js → chunk-KRP467VJ.js} +2 -2
- package/dist/chunk-LJ2EG6JK.cjs.map +1 -1
- package/dist/chunk-LLYY4TCZ.cjs.map +1 -1
- package/dist/chunk-LYIBTVK6.cjs.map +1 -1
- package/dist/chunk-M3HWE7KT.cjs.map +1 -1
- package/dist/chunk-M3SJHFT4.cjs.map +1 -1
- package/dist/chunk-MCNDMK7F.cjs.map +1 -1
- package/dist/chunk-MLG6NXI6.cjs.map +1 -1
- package/dist/chunk-MYAXAWBQ.cjs.map +1 -1
- package/dist/chunk-NFB3S2E6.cjs.map +1 -1
- package/dist/chunk-NYL3BNHR.cjs.map +1 -1
- package/dist/chunk-O4AYHLQX.cjs.map +1 -1
- package/dist/chunk-OAEKP665.cjs.map +1 -1
- package/dist/chunk-ODPNVNYE.cjs.map +1 -1
- package/dist/chunk-OG2KJAYD.cjs.map +1 -1
- package/dist/chunk-OYZP6NF6.cjs.map +1 -1
- package/dist/chunk-P4UILJVU.cjs.map +1 -1
- package/dist/chunk-P7DYLUUI.cjs.map +1 -1
- package/dist/chunk-PKAE6AQT.cjs.map +1 -1
- package/dist/chunk-PYNHK6AP.cjs.map +1 -1
- package/dist/chunk-Q7M7DO7M.cjs.map +1 -1
- package/dist/chunk-QKUWFMZP.cjs.map +1 -1
- package/dist/chunk-QRSA72B3.cjs.map +1 -1
- package/dist/chunk-QYNRNDIY.cjs.map +1 -1
- package/dist/chunk-R4GA6BVP.cjs.map +1 -1
- package/dist/chunk-R5VYSZ3Q.cjs.map +1 -1
- package/dist/chunk-RHFUXHQN.cjs.map +1 -1
- package/dist/chunk-RI42IDRR.cjs.map +1 -1
- package/dist/chunk-S77LQWYC.cjs.map +1 -1
- package/dist/chunk-S7SBNOGS.cjs.map +1 -1
- package/dist/chunk-TMAJE5P2.cjs.map +1 -1
- package/dist/chunk-TNIJ6OSH.cjs.map +1 -1
- package/dist/chunk-U3JK7NBG.cjs.map +1 -1
- package/dist/chunk-UGSM7RJ2.cjs.map +1 -1
- package/dist/chunk-UKLZAOLW.cjs.map +1 -1
- package/dist/chunk-V47G7P6L.cjs.map +1 -1
- package/dist/chunk-VH5A6SMU.cjs.map +1 -1
- package/dist/chunk-VHMH4QMY.cjs.map +1 -1
- package/dist/chunk-VYC7WUM5.cjs.map +1 -1
- package/dist/chunk-VZ3BSIVU.cjs.map +1 -1
- package/dist/chunk-W457XUA6.cjs.map +1 -1
- package/dist/chunk-WHDI3TMP.cjs.map +1 -1
- package/dist/chunk-WITCPKNL.cjs.map +1 -1
- package/dist/chunk-WX6NP7UU.cjs.map +1 -1
- package/dist/chunk-XQLRIBVR.cjs.map +1 -1
- package/dist/{chunk-2MSCXFWD.cjs → chunk-Y6LKUYGJ.cjs} +3 -3
- package/dist/chunk-Y6LKUYGJ.cjs.map +1 -0
- package/dist/chunk-Y7LSSRNJ.cjs.map +1 -1
- package/dist/chunk-YK3P5QNZ.cjs.map +1 -1
- package/dist/{chunk-OWP7XBY2.cjs → chunk-YW4DVKNT.cjs} +5 -2
- package/dist/chunk-YW4DVKNT.cjs.map +1 -0
- package/dist/chunk-ZKPVUCQV.cjs.map +1 -1
- package/dist/chunk-ZUULK36E.cjs.map +1 -1
- package/dist/client.cjs +2 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/currencies.cjs.map +1 -1
- package/dist/enigmaCardForm.cjs.map +1 -1
- package/dist/error.cjs.map +1 -1
- package/dist/eventStream.cjs.map +1 -1
- package/dist/exportDownload.cjs.map +1 -1
- package/dist/feeProgram.cjs.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -6
- package/dist/internal/resources/admin.cjs.map +1 -1
- package/dist/internal/resources/admin.d.cts +1 -1
- package/dist/internal/resources/admin.d.ts +1 -1
- package/dist/internal/resources/adminBranding.cjs.map +1 -1
- package/dist/internal/resources/adminBranding.d.cts +1 -1
- package/dist/internal/resources/adminBranding.d.ts +1 -1
- package/dist/internal/resources/adminCheckoutDomains.cjs.map +1 -1
- package/dist/internal/resources/adminCheckoutDomains.d.cts +1 -1
- package/dist/internal/resources/adminCheckoutDomains.d.ts +1 -1
- package/dist/internal/resources/adminFeePlans.cjs.map +1 -1
- package/dist/internal/resources/adminFeePlans.d.cts +1 -1
- package/dist/internal/resources/adminFeePlans.d.ts +1 -1
- package/dist/internal/resources/adminFileScans.cjs.map +1 -1
- package/dist/internal/resources/adminFileScans.d.cts +1 -1
- package/dist/internal/resources/adminFileScans.d.ts +1 -1
- package/dist/internal/resources/adminIndustries.cjs.map +1 -1
- package/dist/internal/resources/adminIndustries.d.cts +1 -1
- package/dist/internal/resources/adminIndustries.d.ts +1 -1
- package/dist/internal/resources/adminLive.cjs.map +1 -1
- package/dist/internal/resources/adminNotices.cjs.map +1 -1
- package/dist/internal/resources/adminNotices.d.cts +1 -1
- package/dist/internal/resources/adminNotices.d.ts +1 -1
- package/dist/internal/resources/adminPortal.cjs +2 -2
- package/dist/internal/resources/adminPortal.cjs.map +1 -1
- package/dist/internal/resources/adminPortal.d.cts +1 -1
- package/dist/internal/resources/adminPortal.d.ts +1 -1
- package/dist/internal/resources/adminPortal.js +1 -1
- package/dist/internal/resources/adminPricing.cjs.map +1 -1
- package/dist/internal/resources/adminPricing.d.cts +1 -1
- package/dist/internal/resources/adminPricing.d.ts +1 -1
- package/dist/internal/resources/adminSupport.cjs.map +1 -1
- package/dist/internal/resources/adminSupport.d.cts +1 -1
- package/dist/internal/resources/adminSupport.d.ts +1 -1
- package/dist/internal/resources/auditLogs.cjs.map +1 -1
- package/dist/internal/resources/auditLogs.d.cts +1 -1
- package/dist/internal/resources/auditLogs.d.ts +1 -1
- package/dist/internal/resources/cache.cjs.map +1 -1
- package/dist/internal/resources/cardIssuers.cjs.map +1 -1
- package/dist/internal/resources/cardIssuers.d.cts +1 -1
- package/dist/internal/resources/cardIssuers.d.ts +1 -1
- package/dist/internal/resources/configs.cjs.map +1 -1
- package/dist/internal/resources/connectorRestrictionRules.cjs.map +1 -1
- package/dist/internal/resources/connectorRestrictionRules.d.cts +1 -1
- package/dist/internal/resources/connectorRestrictionRules.d.ts +1 -1
- package/dist/internal/resources/connectorRestrictions.cjs.map +1 -1
- package/dist/internal/resources/connectorRestrictions.d.cts +1 -1
- package/dist/internal/resources/connectorRestrictions.d.ts +1 -1
- package/dist/internal/resources/diagnostic.cjs.map +1 -1
- package/dist/internal/resources/diagnostic.d.cts +1 -1
- package/dist/internal/resources/diagnostic.d.ts +1 -1
- package/dist/internal/resources/gsm.cjs.map +1 -1
- package/dist/internal/resources/gsm.d.cts +1 -1
- package/dist/internal/resources/gsm.d.ts +1 -1
- package/dist/internal/resources/nativeRenewals.cjs.map +1 -1
- package/dist/internal/resources/nativeRenewals.d.cts +1 -1
- package/dist/internal/resources/nativeRenewals.d.ts +1 -1
- package/dist/internal/resources/platformBilling.cjs.map +1 -1
- package/dist/internal/resources/platformBilling.d.cts +1 -1
- package/dist/internal/resources/platformBilling.d.ts +1 -1
- package/dist/internal/resources/platformFees.cjs.map +1 -1
- package/dist/internal/resources/platformMessageTemplates.cjs.map +1 -1
- package/dist/internal/resources/platformSettings.cjs.map +1 -1
- package/dist/internal/resources/platformSettings.d.cts +1 -1
- package/dist/internal/resources/platformSettings.d.ts +1 -1
- package/dist/internal.cjs +10 -10
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +7 -7
- package/dist/listQuery.cjs.map +1 -1
- package/dist/panes.cjs.map +1 -1
- package/dist/paymentPresentation.cjs.map +1 -1
- package/dist/recordCounter.cjs.map +1 -1
- package/dist/resources/aiTools.cjs.map +1 -1
- package/dist/resources/analytics.cjs.map +1 -1
- package/dist/resources/analyticsDashboard.cjs.map +1 -1
- package/dist/resources/apiKeys.cjs.map +1 -1
- package/dist/resources/audit.cjs.map +1 -1
- package/dist/resources/authentication.cjs.map +1 -1
- package/dist/resources/availabilityOverrides.cjs.map +1 -1
- package/dist/resources/billing.cjs.map +1 -1
- package/dist/resources/buyerAccount.cjs.map +1 -1
- package/dist/resources/buyerBlocklist.cjs +2 -2
- package/dist/resources/buyerBlocklist.cjs.map +1 -1
- package/dist/resources/buyerBlocklist.js +1 -1
- package/dist/resources/buyerConversations.cjs.map +1 -1
- package/dist/resources/buyerEvidenceReviews.cjs.map +1 -1
- package/dist/resources/buyerPortal.cjs.map +1 -1
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/chargebackPrevention.cjs.map +1 -1
- package/dist/resources/checkoutDomains.cjs.map +1 -1
- package/dist/resources/checkoutMethods.cjs.map +1 -1
- package/dist/resources/checkoutRecovery.cjs.map +1 -1
- package/dist/resources/checkoutTemplates.cjs.map +1 -1
- package/dist/resources/connectors.cjs.map +1 -1
- package/dist/resources/contentEncryption.cjs.map +1 -1
- package/dist/resources/costRules.cjs.map +1 -1
- package/dist/resources/customers.cjs +2 -2
- package/dist/resources/customers.cjs.map +1 -1
- package/dist/resources/customers.js +1 -1
- package/dist/resources/deploymentBranding.cjs.map +1 -1
- package/dist/resources/disputes.cjs +2 -2
- package/dist/resources/disputes.cjs.map +1 -1
- package/dist/resources/disputes.js +1 -1
- package/dist/resources/ephemeralKeys.cjs.map +1 -1
- package/dist/resources/events.cjs.map +1 -1
- package/dist/resources/export.cjs.map +1 -1
- package/dist/resources/externalRecords.cjs.map +1 -1
- package/dist/resources/featureMatrix.cjs.map +1 -1
- package/dist/resources/fees.cjs.map +1 -1
- package/dist/resources/files.cjs.map +1 -1
- package/dist/resources/forex.cjs.map +1 -1
- package/dist/resources/identityVerifications.cjs.map +1 -1
- package/dist/resources/industries.cjs.map +1 -1
- package/dist/resources/invoiceSettings.cjs.map +1 -1
- package/dist/resources/invoices.cjs.map +1 -1
- package/dist/resources/live.cjs.map +1 -1
- package/dist/resources/mandates.cjs.map +1 -1
- package/dist/resources/merchantAccounts.cjs.map +1 -1
- package/dist/resources/messageTemplates.cjs.map +1 -1
- package/dist/resources/notices.cjs.map +1 -1
- package/dist/resources/operationLimits.cjs.map +1 -1
- package/dist/resources/paymentLinks.cjs.map +1 -1
- package/dist/resources/paymentMethods.cjs.map +1 -1
- package/dist/resources/payments.cjs.map +1 -1
- package/dist/resources/payoutDestinations.cjs.map +1 -1
- package/dist/resources/payouts.cjs.map +1 -1
- package/dist/resources/paypalDisputes.cjs.map +1 -1
- package/dist/resources/persons.cjs +2 -2
- package/dist/resources/persons.cjs.map +1 -1
- package/dist/resources/persons.js +1 -1
- package/dist/resources/poll.cjs.map +1 -1
- package/dist/resources/processorCosts.cjs.map +1 -1
- package/dist/resources/processorImports.cjs.map +1 -1
- package/dist/resources/products.cjs.map +1 -1
- package/dist/resources/profileAcquirers.cjs.map +1 -1
- package/dist/resources/profiles.cjs.map +1 -1
- package/dist/resources/projects.cjs.map +1 -1
- package/dist/resources/refunds.cjs.map +1 -1
- package/dist/resources/regions.cjs.map +1 -1
- package/dist/resources/relay.cjs.map +1 -1
- package/dist/resources/risk.cjs.map +1 -1
- package/dist/resources/routing.cjs.map +1 -1
- package/dist/resources/search.cjs.map +1 -1
- package/dist/resources/sellToRestrictions.cjs.map +1 -1
- package/dist/resources/settings.cjs.map +1 -1
- package/dist/resources/settlement.cjs.map +1 -1
- package/dist/resources/shareLinks.cjs.map +1 -1
- package/dist/resources/shopLabels.cjs.map +1 -1
- package/dist/resources/shopify.cjs.map +1 -1
- package/dist/resources/shops.cjs.map +1 -1
- package/dist/resources/stripeConnect.cjs.map +1 -1
- package/dist/resources/subscriptions.cjs.map +1 -1
- package/dist/resources/support.cjs.map +1 -1
- package/dist/resources/threeDsRules.cjs.map +1 -1
- package/dist/resources/users.cjs.map +1 -1
- package/dist/resources/vatRates.cjs.map +1 -1
- package/dist/resources/verification.cjs.map +1 -1
- package/dist/resources/webhooks.cjs.map +1 -1
- package/dist/resources/whopResolutionCases.cjs.map +1 -1
- package/dist/trustedOrigins.cjs.map +1 -1
- package/dist/{types-yDOfhGt3.d.cts → types-JtFGu9hw.d.cts} +8 -2
- package/dist/{types-fgHam_o6.d.ts → types-T_iCK6Xn.d.ts} +8 -2
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +44 -0
- package/dist/types.d.ts +44 -0
- package/package.json +1 -1
- package/dist/chunk-2MSCXFWD.cjs.map +0 -1
- package/dist/chunk-6MXPGE7O.cjs.map +0 -1
- package/dist/chunk-ABDDRKOT.js.map +0 -1
- package/dist/chunk-CPGGSHNB.js.map +0 -1
- package/dist/chunk-E2TF7JDB.cjs.map +0 -1
- package/dist/chunk-EK7RLJZB.js.map +0 -1
- package/dist/chunk-FDHLDKNY.cjs.map +0 -1
- package/dist/chunk-LZUHCGJ3.js.map +0 -1
- package/dist/chunk-OPOSNWK4.cjs.map +0 -1
- package/dist/chunk-OWP7XBY2.cjs.map +0 -1
- package/dist/chunk-TSAQN7I5.js.map +0 -1
- package/dist/chunk-U72OIM7A.cjs.map +0 -1
- /package/dist/{chunk-NH2TUO7X.js.map → chunk-J3NCUUG7.js.map} +0 -0
- /package/dist/{chunk-EHRQSUIK.js.map → chunk-KRP467VJ.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/sdkpub/delopay-typescript-sdk/dist/chunk-HLHML5ES.cjs","../src/resources/analytics.ts"],"names":[],"mappings":"AAAA;ACyBO,IAAM,UAAA,EAAN,MAAgB;AAAA,EACrB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAalD,MAAM,KAAA,CAAM,MAAA,EAAiE;AAC3E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,kBAAA,EAAoB;AAAA,MAC7C,KAAA,EAAO;AAAA,IACT,CAAC,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,OAAA,CAAQ,MAAA,EAAiE;AAC7E,IAAA,OAAO,IAAA,CAAK,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opay-typescript-sdk/dist/chunk-HLHML5ES.cjs","sourcesContent":[null,"import type { RequestExtras, RequestFn } from '../client';\nimport type {\n AnalyticsScopeRequest,\n AnalyticsScopeResponse,\n AnalyticsShopsRequest,\n AnalyticsShopsResponse,\n AnalyticsConnectorsRequest,\n AnalyticsConnectorsResponse,\n ClientAnalyticsRequest,\n IndustryAnalytics,\n IndustryAnalyticsRequest,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n SubscriptionAnalyticsRequest,\n SubscriptionAnalyticsResponse,\n SubscriptionDrillRequest,\n ScopeDrillRequest,\n AnalyticsExclusionRequest,\n AnalyticsExclusionResponse,\n AnalyticsExclusionsResponse,\n} from '../types';\n\nexport class Analytics {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Scoped, drill-level analytics dashboard for the authenticated merchant\n * (the same engine as the admin portal, pinned server-side to your own\n * merchant). The server ignores `merchant_id` — it always scopes to your\n * merchant, and to your single shop for profile-scoped users — so pass only\n * `project_id` / `shop_id` to drill and the window / `sections` fields.\n * Returns one drill level: the scope's daily series + previous window,\n * processor mix and direct children. Accepts a dashboard session or an API\n * key, including a `statistics_read` key; a shop-bound key reads only its\n * shop. `GET /analytics/scope`\n */\n async scope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Period Reports: the scoped daily series, pinned exactly like `scope`, but\n * gated on the Period Reports permission area instead of Payment\n * Performance. Pass `timezone` and each day bucket is a local calendar day,\n * which sums exactly into calendar weeks and months. Answers only the\n * `series`, `previous` and `children` blocks and ignores country and device\n * filters. Accepts a dashboard session or an API key, including a\n * `statistics_read` key. `GET /analytics/reports`\n */\n async reports(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/reports', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Shop comparison: one series per shop over one window, with whole-window\n * and previous-window totals, so shops can be drawn side by side. Pinned\n * server-side to your own merchant (`merchant_id` is ignored), and to your\n * single shop for a shop-scoped user; `project_id` / `shop_id` narrow it.\n * Shops without activity are included, sorted by name. Hourly buckets are\n * refused for windows over 7 days. Accepts an API key like `scope`.\n * `GET /analytics/shops`\n */\n async shops(params?: AnalyticsShopsRequest): Promise<AnalyticsShopsResponse> {\n return this.request('GET', '/analytics/shops', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * PSP analytics: routed payments, outcomes, volume and payment sizes per\n * connector and per connector account over one window, with the breakdown\n * by project and shop. Pinned server-side to your own merchant\n * (`merchant_id` is ignored) and to your shop for a shop-scoped user. Live\n * payments unless `test_mode` is `true`. Amounts are in USD unless\n * `currency` names one. Pass `sections` to compute only some blocks.\n * A role that may see no processor gets a 403.\n * `GET /analytics/connectors`\n */\n async connectors(params?: AnalyticsConnectorsRequest): Promise<AnalyticsConnectorsResponse> {\n return this.request('GET', '/analytics/connectors', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Industry analytics: payments, volume, outcomes, refunds and disputes by\n * the industry each shop had on the UTC day a payment was created, as a tree\n * of industries, sub-industries, the merchant's own industries and the\n * shops without one, each with the previous window, a series, the processor\n * and country split and the largest shops. Pinned server-side to your own\n * merchant (`merchant_id` is ignored). Needs the `IndustryAnalytics` area,\n * which no other analytics grant implies, at merchant level: a shop-scoped\n * role or a shop-bound key gets a 403 (`IR_22`). Live payments unless\n * `test_mode` is `true`; amounts in USD unless `currency` names one.\n * `GET /analytics/industries`\n */\n async industries(params?: IndustryAnalyticsRequest): Promise<IndustryAnalytics> {\n return this.request('GET', '/analytics/industries', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment (browser/platform families, device classes and models, checkout\n * channel mix, time-to-pay), pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`. Gated on the\n * client-context optimisation-use switch: when it is off the server answers\n * 200 with `enabled: false` and a caveat naming the switch. Accepts an API\n * key like `scope`. `GET /analytics/devices`\n */\n async devices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment:\n * country totals, city bubbles (IP mode), buyer languages, buyer-local\n * purchase hours and the IP-vs-billing mismatch share. `mode` selects the\n * location claim (`ip` default, `billing`); the two are never coalesced.\n * Same drill, window, gating and API-key contract as `devices`.\n * `GET /analytics/geo`\n */\n async geo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target: a map country (in the\n * active claim mode), optionally narrowed to an IP-resolved city, or one\n * buyer-local heatmap cell (`dow` + `hour`, paid sessions only). Same\n * window/scope/filter and gating contract as `geo`; capped at 50 rows,\n * newest first, with the full match count alongside.\n * `GET /analytics/geo/transactions`\n */\n async geoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target: exactly one of a\n * browser family, a platform family, an identified device-model label, or\n * a device class. Family/model targets are resolved server-side with the\n * same classifiers the cards use. Same window/scope/filter and gating\n * contract as `devices`; 50 rows per page (`offset` for the next page),\n * newest first, with the full match count alongside.\n * `GET /analytics/devices/transactions`\n */\n async deviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/devices/transactions', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The payments behind one clicked element of the payments dashboard: a\n * processor-donut slice, a payment-method slice, an outcome segment of a\n * series bar, a series bucket, or a breakdown row — combinable, with\n * `target_bucket` narrowing every other target. The outcome mapping is the\n * one the series and donuts are folded with, expanded server-side, so the\n * list is what the clicked number was made of. Rows and the whole-match\n * `summary` carry USD figures converted with the dashboard's own rates.\n * Same window/scope/chip contract as `scope`; sorted per `sort_on` /\n * `sort_by`, `limit` rows (default 50) per page, `offset` for the next.\n * `GET /analytics/scope/transactions`\n */\n async scopeTransactions(params: ScopeDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/scope/transactions', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Subscription analytics over `subscription` and `invoice`: estimated\n * recurring volume, the invoice funnel, movement (new / expansion /\n * contraction / churn), both processor axes, plan mix and the breakdown one\n * level below the scope. Pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`.\n *\n * Half the figures are **stocks** — a snapshot at the window's end rather\n * than a sum over it — so `est_monthly_volume_usd` and `active` can match\n * across a 7-day and a 30-day window while `billed_volume_usd` does not.\n * Day granularity only. Accepts an API key like `scope`.\n * `GET /analytics/subscriptions`\n */\n async subscriptions(\n params?: SubscriptionAnalyticsRequest,\n ): Promise<SubscriptionAnalyticsResponse> {\n return this.request('GET', '/analytics/subscriptions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The billing cycles behind one clicked element of the subscription\n * dashboard: an invoice outcome, a processor slice on either axis, a plan\n * row, a subscription status, a movement component, a series bucket or a\n * breakdown row. Same window/scope/filter contract as `subscriptions`; 50\n * rows per page (`offset` for the next), newest first, with the full match\n * count alongside.\n *\n * A cycle that never reached a payment is listed too — that is what \"still\n * unpaid\" means — and carries its invoice id as `payment_id` with\n * `invoice_id` set to the same value, so you can always tell which you got.\n * `GET /analytics/subscriptions/list`\n */\n async subscriptionsList(params: SubscriptionDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/subscriptions/list', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Every analytics exclusion of the merchant, with the payments each one\n * matched in the lookback window.\n *\n * These rules change what the merchant's own dashboards count. Financial\n * records and transaction lists are never filtered by them.\n *\n * `matched_payments` counts overlap between rules: a payment matched by\n * three rules is counted once by each, so the values are not additive. The\n * envelope's `best_effort` and `lookback_days` apply to every row — matching\n * runs on client signals that may be absent or expired, within that window.\n * `GET /analytics/exclusions`\n */\n async listExclusions(): Promise<AnalyticsExclusionsResponse> {\n return this.request('GET', '/analytics/exclusions');\n }\n\n /**\n * Write a new exclusion. A shop-scoped user must name their own shop in\n * `profile_id`; omitting it applies the rule to every shop of the merchant.\n * Omitting `surfaces` means **all five**, not none.\n * `POST /analytics/exclusions`\n */\n async createExclusion(rule: AnalyticsExclusionRequest): Promise<AnalyticsExclusionResponse> {\n return this.request('POST', '/analytics/exclusions', { body: rule });\n }\n\n /**\n * Replace a stored exclusion **completely**. This is not a patch: every\n * field you leave out reverts to its default rather than keeping its stored\n * value, so send the whole rule — including an explicit `null` for a\n * `profile_id`, `value`, `valid_from`, `valid_until` or `note` you mean to\n * clear, and the full `surfaces` list you mean to keep.\n * `PUT /analytics/exclusions/{id}`\n */\n async updateExclusion(\n id: string,\n rule: AnalyticsExclusionRequest,\n options?: RequestExtras,\n ): Promise<AnalyticsExclusionResponse> {\n return this.request('PUT', `/analytics/exclusions/${encodeURIComponent(id)}`, {\n body: rule,\n ...options,\n });\n }\n\n /**\n * Delete a stored exclusion. Returns the rule as it was, so a caller can\n * say what it removed. `DELETE /analytics/exclusions/{id}`\n */\n async deleteExclusion(id: string): Promise<AnalyticsExclusionResponse> {\n return this.request('DELETE', `/analytics/exclusions/${encodeURIComponent(id)}`);\n }\n\n /** Global search. `POST /analytics/search` */\n async search(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/search', { body: params });\n }\n\n /** Domain-specific search. `POST /analytics/search/{domain}` */\n async searchDomain(\n domain: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/analytics/search/${encodeURIComponent(domain)}`, {\n body: params,\n });\n }\n\n /** Get analytics info. `GET /analytics/{domain}/info` */\n async getInfo(domain: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/analytics/${encodeURIComponent(domain)}/info`);\n }\n\n /** Get API event logs. `GET /analytics/api-event-logs` */\n async apiEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/api-event-logs', { query: params });\n }\n\n /** Get SDK event logs. `POST /analytics/sdk-event-logs` */\n async sdkEventLogs(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/sdk-event-logs', { body: params });\n }\n\n /** Get connector event logs. `GET /analytics/connector-event-logs` */\n async connectorEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/connector-event-logs', { query: params });\n }\n\n /**\n * Get routing event logs. `GET /analytics/routing-event-logs`\n *\n * @deprecated The service answers this only from a ClickHouse analytics\n * store; with SQL analytics, the default configuration, it answers an\n * error. To learn why a payment used a connector, read\n * `payments.routingDecisions(paymentId)`,\n * the routing decision recorded behind each attempt. This method stays for\n * compatibility and still sends the same request.\n */\n async routingEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/routing-event-logs', { query: params });\n }\n\n /** Get outgoing webhook event logs. `GET /analytics/outgoing-webhook-event-logs` */\n async outgoingWebhookEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/outgoing-webhook-event-logs', { query: params });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-HL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AA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAMuE,EAAA;AACK,IAAA;AAC5E,EAAA;AAAA;AAGgF,EAAA;AACb,IAAA;AACnE,EAAA;AAAA;AAMoC,EAAA;AACyC,IAAA;AACnE,MAAA;AACP,IAAA;AACH,EAAA;AAAA;AAGgE,EAAA;AACY,IAAA;AAC5E,EAAA;AAAA;AAKoC,EAAA;AACuC,IAAA;AAC3E,EAAA;AAAA;AAGsF,EAAA;AACX,IAAA;AAC3E,EAAA;AAAA;AAKoC,EAAA;AACqC,IAAA;AACzE,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcoC,EAAA;AACmC,IAAA;AACvE,EAAA;AAAA;AAKoC,EAAA;AACqC,IAAA;AACzE,EAAA;AACF;AD9D+E;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-HLHML5ES.cjs","sourcesContent":[null,"import type { RequestExtras, RequestFn } from '../client';\nimport type {\n AnalyticsScopeRequest,\n AnalyticsScopeResponse,\n AnalyticsShopsRequest,\n AnalyticsShopsResponse,\n AnalyticsConnectorsRequest,\n AnalyticsConnectorsResponse,\n ClientAnalyticsRequest,\n IndustryAnalytics,\n IndustryAnalyticsRequest,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n SubscriptionAnalyticsRequest,\n SubscriptionAnalyticsResponse,\n SubscriptionDrillRequest,\n ScopeDrillRequest,\n AnalyticsExclusionRequest,\n AnalyticsExclusionResponse,\n AnalyticsExclusionsResponse,\n} from '../types';\n\nexport class Analytics {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Scoped, drill-level analytics dashboard for the authenticated merchant\n * (the same engine as the admin portal, pinned server-side to your own\n * merchant). The server ignores `merchant_id` — it always scopes to your\n * merchant, and to your single shop for profile-scoped users — so pass only\n * `project_id` / `shop_id` to drill and the window / `sections` fields.\n * Returns one drill level: the scope's daily series + previous window,\n * processor mix and direct children. Accepts a dashboard session or an API\n * key, including a `statistics_read` key; a shop-bound key reads only its\n * shop. `GET /analytics/scope`\n */\n async scope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Period Reports: the scoped daily series, pinned exactly like `scope`, but\n * gated on the Period Reports permission area instead of Payment\n * Performance. Pass `timezone` and each day bucket is a local calendar day,\n * which sums exactly into calendar weeks and months. Answers only the\n * `series`, `previous` and `children` blocks and ignores country and device\n * filters. Accepts a dashboard session or an API key, including a\n * `statistics_read` key. `GET /analytics/reports`\n */\n async reports(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/reports', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Shop comparison: one series per shop over one window, with whole-window\n * and previous-window totals, so shops can be drawn side by side. Pinned\n * server-side to your own merchant (`merchant_id` is ignored), and to your\n * single shop for a shop-scoped user; `project_id` / `shop_id` narrow it.\n * Shops without activity are included, sorted by name. Hourly buckets are\n * refused for windows over 7 days. Accepts an API key like `scope`.\n * `GET /analytics/shops`\n */\n async shops(params?: AnalyticsShopsRequest): Promise<AnalyticsShopsResponse> {\n return this.request('GET', '/analytics/shops', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * PSP analytics: routed payments, outcomes, volume and payment sizes per\n * connector and per connector account over one window, with the breakdown\n * by project and shop. Pinned server-side to your own merchant\n * (`merchant_id` is ignored) and to your shop for a shop-scoped user. Live\n * payments unless `test_mode` is `true`. Amounts are in USD unless\n * `currency` names one. Pass `sections` to compute only some blocks.\n * A role that may see no processor gets a 403.\n * `GET /analytics/connectors`\n */\n async connectors(params?: AnalyticsConnectorsRequest): Promise<AnalyticsConnectorsResponse> {\n return this.request('GET', '/analytics/connectors', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Industry analytics: payments, volume, outcomes, refunds and disputes by\n * the industry each shop had on the UTC day a payment was created, as a tree\n * of industries, sub-industries, the merchant's own industries and the\n * shops without one, each with the previous window, a series, the processor\n * and country split and the largest shops. Pinned server-side to your own\n * merchant (`merchant_id` is ignored). Needs the `IndustryAnalytics` area,\n * which no other analytics grant implies, at merchant level: a shop-scoped\n * role or a shop-bound key gets a 403 (`IR_22`). Live payments unless\n * `test_mode` is `true`; amounts in USD unless `currency` names one.\n * `GET /analytics/industries`\n */\n async industries(params?: IndustryAnalyticsRequest): Promise<IndustryAnalytics> {\n return this.request('GET', '/analytics/industries', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment (browser/platform families, device classes and models, checkout\n * channel mix, time-to-pay), pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`. Gated on the\n * client-context optimisation-use switch: when it is off the server answers\n * 200 with `enabled: false` and a caveat naming the switch. Accepts an API\n * key like `scope`. `GET /analytics/devices`\n */\n async devices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment:\n * country totals, city bubbles (IP mode), buyer languages, buyer-local\n * purchase hours and the IP-vs-billing mismatch share. `mode` selects the\n * location claim (`ip` default, `billing`); the two are never coalesced.\n * Same drill, window, gating and API-key contract as `devices`.\n * `GET /analytics/geo`\n */\n async geo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target: a map country (in the\n * active claim mode), optionally narrowed to an IP-resolved city, or one\n * buyer-local heatmap cell (`dow` + `hour`, paid sessions only). Same\n * window/scope/filter and gating contract as `geo`; capped at 50 rows,\n * newest first, with the full match count alongside.\n * `GET /analytics/geo/transactions`\n */\n async geoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target: exactly one of a\n * browser family, a platform family, an identified device-model label, or\n * a device class. Family/model targets are resolved server-side with the\n * same classifiers the cards use. Same window/scope/filter and gating\n * contract as `devices`; 50 rows per page (`offset` for the next page),\n * newest first, with the full match count alongside.\n * `GET /analytics/devices/transactions`\n */\n async deviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/devices/transactions', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The payments behind one clicked element of the payments dashboard: a\n * processor-donut slice, a payment-method slice, an outcome segment of a\n * series bar, a series bucket, or a breakdown row — combinable, with\n * `target_bucket` narrowing every other target. The outcome mapping is the\n * one the series and donuts are folded with, expanded server-side, so the\n * list is what the clicked number was made of. Rows and the whole-match\n * `summary` carry USD figures converted with the dashboard's own rates.\n * Same window/scope/chip contract as `scope`; sorted per `sort_on` /\n * `sort_by`, `limit` rows (default 50) per page, `offset` for the next.\n * `GET /analytics/scope/transactions`\n */\n async scopeTransactions(params: ScopeDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/scope/transactions', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Subscription analytics over `subscription` and `invoice`: estimated\n * recurring volume, the invoice funnel, movement (new / expansion /\n * contraction / churn), both processor axes, plan mix and the breakdown one\n * level below the scope. Pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`.\n *\n * Half the figures are **stocks** — a snapshot at the window's end rather\n * than a sum over it — so `est_monthly_volume_usd` and `active` can match\n * across a 7-day and a 30-day window while `billed_volume_usd` does not.\n * Day granularity only. Accepts an API key like `scope`.\n * `GET /analytics/subscriptions`\n */\n async subscriptions(\n params?: SubscriptionAnalyticsRequest,\n ): Promise<SubscriptionAnalyticsResponse> {\n return this.request('GET', '/analytics/subscriptions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The billing cycles behind one clicked element of the subscription\n * dashboard: an invoice outcome, a processor slice on either axis, a plan\n * row, a subscription status, a movement component, a series bucket or a\n * breakdown row. Same window/scope/filter contract as `subscriptions`; 50\n * rows per page (`offset` for the next), newest first, with the full match\n * count alongside.\n *\n * A cycle that never reached a payment is listed too — that is what \"still\n * unpaid\" means — and carries its invoice id as `payment_id` with\n * `invoice_id` set to the same value, so you can always tell which you got.\n * `GET /analytics/subscriptions/list`\n */\n async subscriptionsList(params: SubscriptionDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/subscriptions/list', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Every analytics exclusion of the merchant, with the payments each one\n * matched in the lookback window.\n *\n * These rules change what the merchant's own dashboards count. Financial\n * records and transaction lists are never filtered by them.\n *\n * `matched_payments` counts overlap between rules: a payment matched by\n * three rules is counted once by each, so the values are not additive. The\n * envelope's `best_effort` and `lookback_days` apply to every row — matching\n * runs on client signals that may be absent or expired, within that window.\n * `GET /analytics/exclusions`\n */\n async listExclusions(): Promise<AnalyticsExclusionsResponse> {\n return this.request('GET', '/analytics/exclusions');\n }\n\n /**\n * Write a new exclusion. A shop-scoped user must name their own shop in\n * `profile_id`; omitting it applies the rule to every shop of the merchant.\n * Omitting `surfaces` means **all five**, not none.\n * `POST /analytics/exclusions`\n */\n async createExclusion(rule: AnalyticsExclusionRequest): Promise<AnalyticsExclusionResponse> {\n return this.request('POST', '/analytics/exclusions', { body: rule });\n }\n\n /**\n * Replace a stored exclusion **completely**. This is not a patch: every\n * field you leave out reverts to its default rather than keeping its stored\n * value, so send the whole rule — including an explicit `null` for a\n * `profile_id`, `value`, `valid_from`, `valid_until` or `note` you mean to\n * clear, and the full `surfaces` list you mean to keep.\n * `PUT /analytics/exclusions/{id}`\n */\n async updateExclusion(\n id: string,\n rule: AnalyticsExclusionRequest,\n options?: RequestExtras,\n ): Promise<AnalyticsExclusionResponse> {\n return this.request('PUT', `/analytics/exclusions/${encodeURIComponent(id)}`, {\n body: rule,\n ...options,\n });\n }\n\n /**\n * Delete a stored exclusion. Returns the rule as it was, so a caller can\n * say what it removed. `DELETE /analytics/exclusions/{id}`\n */\n async deleteExclusion(id: string): Promise<AnalyticsExclusionResponse> {\n return this.request('DELETE', `/analytics/exclusions/${encodeURIComponent(id)}`);\n }\n\n /** Global search. `POST /analytics/search` */\n async search(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/search', { body: params });\n }\n\n /** Domain-specific search. `POST /analytics/search/{domain}` */\n async searchDomain(\n domain: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/analytics/search/${encodeURIComponent(domain)}`, {\n body: params,\n });\n }\n\n /** Get analytics info. `GET /analytics/{domain}/info` */\n async getInfo(domain: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/analytics/${encodeURIComponent(domain)}/info`);\n }\n\n /** Get API event logs. `GET /analytics/api-event-logs` */\n async apiEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/api-event-logs', { query: params });\n }\n\n /** Get SDK event logs. `POST /analytics/sdk-event-logs` */\n async sdkEventLogs(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/sdk-event-logs', { body: params });\n }\n\n /** Get connector event logs. `GET /analytics/connector-event-logs` */\n async connectorEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/connector-event-logs', { query: params });\n }\n\n /**\n * Get routing event logs. `GET /analytics/routing-event-logs`\n *\n * @deprecated The service answers this only from a ClickHouse analytics\n * store; with SQL analytics, the default configuration, it answers an\n * error. To learn why a payment used a connector, read\n * `payments.routingDecisions(paymentId)`,\n * the routing decision recorded behind each attempt. This method stays for\n * compatibility and still sends the same request.\n */\n async routingEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/routing-event-logs', { query: params });\n }\n\n /** Get outgoing webhook event logs. `GET /analytics/outgoing-webhook-event-logs` */\n async outgoingWebhookEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/outgoing-webhook-event-logs', { query: params });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-HLKFUOAQ.cjs","../src/internal/resources/configs.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,MAAA,CAAO,MAAA,EAAmE;AAC9E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,UAAA,EAAY,EAAE,IAAA,EAAM,OAAO,CAAC,CAAA;AAAA,EAC1D;AAAA;AAAA,EAGA,MAAM,QAAA,CAAS,GAAA,EAA+C;AAC5D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,SAAA,EAAY,kBAAA,CAAmB,GAAG,CAAC,CAAA,CAAA;AAChE,EAAA;AAAA;AAG6F,EAAA;AAC7B,IAAA;AAChE,EAAA;AAAA;AAG4D,EAAA;AACG,IAAA;AAC/D,EAAA;AACF;ADFmE;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-HLKFUOAQ.cjs","sourcesContent":[null,"import type { RequestFn } from '../../client';\n\nexport class Configs {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a config. `POST /configs` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/configs', { body: params });\n }\n\n /** Retrieve a config by key. `GET /configs/{key}` */\n async retrieve(key: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/configs/${encodeURIComponent(key)}`);\n }\n\n /** Update a config. `PUT /configs/{key}` */\n async update(key: string, params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', `/configs/${encodeURIComponent(key)}`, { body: params });\n }\n\n /** Delete a config. `DELETE /configs/{key}` */\n async delete(key: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/configs/${encodeURIComponent(key)}`);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-HLYGHP6F.cjs","../src/internal/resources/platformFees.ts"],"names":[],"mappings":"AAAA;ACoBO,IAAM,aAAA,EAAN,MAAmB;AAAA,EAIxB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAC3B,IAAA,IAAA,CAAK,MAAA,EAAQ,IAAI,uBAAA,CAAwB,OAAO,CAAA;AAAA,EAClD;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,MAAA,EAAkC,UAAA,EAAkD;AAC/F,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,aAAA,EAAe;AAAA,MACzC,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,EAAE,WAAA,EAAa,WAAW;AAAA,IACnC,CAAC,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,IAAA,CAAK,UAAA,EAAoD;AAC7D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,kBAAA,EAAoB;AAAA,MAC7C,KAAA,EAAO,EAAE,WAAA,EAAa,WAAW;AAAA,IACnC,CAAC,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,QAAA,CAAS,KAAA,EAA6C;AAC1D,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,YAAA,EAAe,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AACrE,EAAA;AAAA;AAG4F,EAAA;AACvB,IAAA;AACrE,EAAA;AAAA;AAG0D,EAAA;AACQ,IAAA;AAClE,EAAA;AACF;AASqC;AACc,EAAA;AAApB,IAAA;AAAqB,EAAA;AAAA;AAG+C,EAAA;AACvB,IAAA;AACxB,IAAA;AAC9C,MAAA;AACiC,MAAA;AAClC,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAMgG,EAAA;AAC9C,IAAA;AACU,MAAA;AACzD,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAMoE,EAAA;AAChB,IAAA;AACQ,MAAA;AACzD,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOiG,EAAA;AACtC,IAAA;AACjD,MAAA;AAC2B,MAAA;AAClC,IAAA;AACH,EAAA;AACF;ADnCwE;AACA;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-HLYGHP6F.cjs","sourcesContent":[null,"import type {\n FeeRulePreviewRequest,\n FeeRulePreviewResponse,\n FeeScheduleCreateRequest,\n FeeScheduleResponse,\n FeeScheduleUpdateRequest,\n PlatformFeeRuleInput,\n PlatformFeeRuleResponse,\n PlatformFeeRuleRequest,\n} from '../../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Platform-wide fee schedule management. Admin-only routes under\n * `/admin/fees/*`. Exposed only via `'@delopay/sdk/internal'`.\n *\n * `platformFees.rules` manages the platform-owned Euclid fee-rule program per\n * merchant, which takes precedence over the flat platform schedules. Build the\n * program with `feeProgram()`.\n */\nexport class PlatformFees {\n /** Platform-owned Euclid fee-rule program (`/admin/fees/rules`). */\n readonly rules: PlatformFeeRulesManager;\n\n constructor(private readonly request: RequestFn) {\n this.rules = new PlatformFeeRulesManager(request);\n }\n\n /** Create a platform fee schedule for a specific merchant. */\n async create(params: FeeScheduleCreateRequest, merchantId: string): Promise<FeeScheduleResponse> {\n return this.request('POST', '/admin/fees', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /** List every platform fee schedule assigned to a merchant. */\n async list(merchantId: string): Promise<FeeScheduleResponse[]> {\n return this.request('GET', '/admin/fees/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /** Retrieve a single platform fee schedule by ID. */\n async retrieve(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('GET', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n\n /** Update a platform fee schedule. */\n async update(feeId: string, params: FeeScheduleUpdateRequest): Promise<FeeScheduleResponse> {\n return this.request('PUT', `/admin/fees/${encodeURIComponent(feeId)}`, { body: params });\n }\n\n /** Delete a platform fee schedule. */\n async delete(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('DELETE', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n}\n\n/**\n * Manages a merchant's platform-owned Euclid fee-rule programs (admin surface),\n * merchant-wide or per-shop (one active program per scope; a shop-scoped\n * program wins for its shop, else the merchant-wide one applies). Build the\n * `algorithm` with `feeProgram()`. The SDK injects `fee_owner: 'platform'`; set\n * `profile_id` on the input to scope a program to a shop.\n */\nexport class PlatformFeeRulesManager {\n constructor(private readonly request: RequestFn) {}\n\n /** Create or replace the platform fee-rule program for a merchant. */\n async upsert(params: PlatformFeeRuleInput, merchantId: string): Promise<PlatformFeeRuleResponse> {\n const body: PlatformFeeRuleRequest = { ...params, fee_owner: 'platform' };\n return this.request('PUT', '/admin/fees/rules', {\n body,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve the active platform fee-rule program for a scope, or `null`.\n * `profileId` omitted = merchant-wide program; set = that shop's program.\n */\n async retrieve(merchantId: string, profileId?: string): Promise<PlatformFeeRuleResponse | null> {\n return this.request('GET', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Deactivate a platform fee-rule program. Idempotent. `profileId` omitted\n * targets the merchant-wide program; set targets only that shop's program.\n */\n async delete(merchantId: string, profileId?: string): Promise<void> {\n await this.request('DELETE', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Dry-run a candidate fee-rule program against a sample transaction.\n * Returns the matched rule name, whether it fell through, and the computed fee.\n * Does not persist anything.\n */\n async preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse> {\n return this.request('POST', '/admin/fees/rules/preview', {\n body: input,\n query: { merchant_id: merchantId },\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/sdkpub/delopay-typescript-sdk/dist/chunk-HSJABE7X.cjs","../src/core.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACDA,IAAM,eAAA,EAAiB,yBAAA;AACvB,IAAM,YAAA,EAAc,iCAAA;AAEpB,IAAM,mBAAA,EAAqB,IAAA;AAC3B,IAAM,mBAAA,EAAqB,GAAA;AAE3B,SAAS,eAAA,CAAgB,MAAA,EAAsC;AAC7D,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,IAAA;AACpB,EAAA,MAAM,QAAA,EAAU,MAAA,CAAO,IAAA,CAAK,CAAA;AAC5B,EAAA,MAAM,QAAA,EAAU,MAAA,CAAO,OAAO,CAAA;AAC9B,EAAA,GAAA,CAAI,MAAA,CAAO,QAAA,CAAS,OAAO,EAAA,GAAK,QAAA,GAAW,CAAA,EAAG;AAC5C,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,QAAA,EAAU,GAAA,EAAM,k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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CqB,EAAA;AACgD,IAAA;AACH,IAAA;AACnD,IAAA;AACT,IAAA;AACS,IAAA;AAC8C,MAAA;AAK3C,MAAA;AACmC,QAAA;AAC1C,MAAA;AACS,QAAA;AAChB,MAAA;AACgC,MAAA;AACsB,MAAA;AAC9B,MAAA;AACE,MAAA;AAClB,QAAA;AACR,MAAA;AAC6B,MAAA;AACf,MAAA;AACuB,QAAA;AACX,QAAA;AACH,QAAA;AACI,QAAA;AACpB,MAAA;AACW,QAAA;AAClB,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADjc+E;AACA;AACA;AACA","file":"/tmp/sdkpub/delopay-typescript-sdk/dist/chunk-HSJABE7X.cjs","sourcesContent":[null,"import { DelopayError, DelopayAuthenticationError } from './error';\nimport { EventStreamParser } from './eventStream';\nimport type { EventStreamDispatch } from './eventStream';\nimport type { TokenResponse } from './types';\n\nexport { DelopayError, DelopayAuthenticationError } from './error';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net/api';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\n/**\n * The error a non-2xx response stands for, read off its body.\n *\n * The API wraps errors as `{ error: { message, code, type, data? } }`; a body\n * that is not JSON (an HTML 502 from a proxy) is kept, truncated, as\n * `rawBody`. A 401 is a {@link DelopayAuthenticationError} unless it is a\n * connector's passthrough.\n */\nasync function errorFromResponse(\n response: Response,\n requestId: string | undefined,\n): Promise<DelopayError> {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message = (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n return new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n return new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\n/**\n * A `onDownloadProgress` listener threw. Carried out of the transport as-is so\n * the retry logic never mistakes the caller's own failure — a `TypeError` in a\n * progress bar, say — for a network error and downloads the body again.\n */\nclass ListenerFailure {\n constructor(readonly cause: unknown) {}\n}\n\n/**\n * The body stream failed after the headers arrived: the connection dropped, or\n * the server aborted it because it could not finish the body it had started.\n * Surfaced as the transport's ordinary network error, so it is retried on\n * exactly the same terms as a failure before the first byte.\n */\nclass BodyStreamFailure {\n constructor(readonly cause: unknown) {}\n}\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted');\n error.name = 'AbortError';\n return error;\n}\n\n/** `Content-Length` as a byte count, or `null` when absent or unreadable. */\nfunction parseContentLength(header: string | null): number | null {\n if (header === null || !/^\\s*\\d+\\s*$/.test(header)) return null;\n const value = Number(header);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/**\n * One `reader.read()`, raced against the request's signal.\n *\n * A conforming `fetch` errors the body stream itself when its signal aborts,\n * but not every stream a runtime or a polyfill hands back does, and a read\n * that never settles would hold a timed-out or cancelled download open for\n * good. The race makes the abort reach the reader either way.\n */\nfunction readChunk(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n signal: AbortSignal,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener('abort', onAbort, { once: true });\n reader.read().then(\n (result) => {\n signal.removeEventListener('abort', onAbort);\n resolve(result);\n },\n (cause: unknown) => {\n signal.removeEventListener('abort', onAbort);\n reject(signal.aborted ? abortError() : new BodyStreamFailure(cause));\n },\n );\n });\n}\n\n/** The chunks as one buffer of exactly `length` bytes. */\nfunction concatChunks(chunks: Uint8Array[], length: number): ArrayBuffer {\n const out = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n}\n\n/**\n * Read a 2xx body chunk by chunk, reporting each one, and decode it as\n * `responseType` asks — the `onDownloadProgress` path of `request()`.\n *\n * `onActivity` is called when the headers arrive and on every chunk; the\n * caller uses it to restart its idle timer.\n */\nasync function receiveWithProgress(\n response: Response,\n responseType: RequestOptions['responseType'],\n listener: (event: DownloadProgressEvent) => void,\n attempt: number,\n signal: AbortSignal,\n onActivity: () => void,\n): Promise<unknown> {\n const headers = response.headers ?? new Headers();\n const total = parseContentLength(headers.get('content-length'));\n let loaded = 0;\n const notify = (chunk: Uint8Array) => {\n try {\n // A copy: the request resolves to the bytes it read, whatever a\n // listener does with the ones it was shown.\n listener({ loaded, total, chunk: chunk.slice(), headers, attempt });\n } catch (cause) {\n throw new ListenerFailure(cause);\n }\n };\n\n onActivity();\n notify(new Uint8Array(0));\n\n const body = response.body;\n if (!body || typeof body.getReader !== 'function') {\n // No readable stream: a null-body status, or a runtime whose `fetch` does\n // not expose one. The body is read whole, and reported as one chunk.\n if (responseType === 'blob') {\n const blob = await response.blob();\n const bytes = new Uint8Array(await blob.arrayBuffer());\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return blob;\n }\n if (responseType === 'arraybuffer') {\n const buffer = await response.arrayBuffer();\n loaded = buffer.byteLength;\n if (loaded > 0) notify(new Uint8Array(buffer));\n return buffer;\n }\n const text = await response.text();\n const bytes = new TextEncoder().encode(text);\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return text ? JSON.parse(text) : undefined;\n }\n\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n try {\n for (;;) {\n const { done, value } = await readChunk(reader, signal);\n if (done) break;\n if (!value || value.byteLength === 0) continue;\n chunks.push(value);\n loaded += value.byteLength;\n onActivity();\n notify(value);\n }\n } catch (err) {\n // Release the connection rather than leave a half-read body behind it.\n reader.cancel().catch(noop);\n throw err;\n }\n\n const bytes = concatChunks(chunks, loaded);\n if (responseType === 'blob') {\n return new Blob([bytes], { type: headers.get('content-type') ?? '' });\n }\n if (responseType === 'arraybuffer') {\n return bytes;\n }\n const text = new TextDecoder().decode(bytes);\n return text ? JSON.parse(text) : undefined;\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /**\n * Use the sandbox environment (`https://sandbox.delopay.net/api`). Defaults\n * to `false` (production). Request paths are appended to that address, so a\n * payment is created at `https://sandbox.delopay.net/api/payments`.\n */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n /**\n * The shop (business profile) every request acts on, sent as `X-Profile-Id`.\n * An API key bound to several shops must name one of them on every request;\n * create one client per shop. A header a call sets itself takes precedence.\n */\n profileId?: string;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * One step of a response body's download, reported to\n * {@link RequestOptions.onDownloadProgress}.\n */\nexport interface DownloadProgressEvent {\n /** Body bytes received so far on this attempt, `chunk` included. */\n loaded: number;\n /**\n * `Content-Length`, when the response carried one — a buffered body such as\n * a PDF. `null` for a streamed (chunked) body, whose size is not known\n * until it ends. With a compressed transfer it is the compressed size, so\n * `loaded` can pass it.\n */\n total: number | null;\n /**\n * The bytes this event reports. Empty on the first event of an attempt,\n * which fires as soon as the headers arrive, before any of the body.\n * A copy: changing it cannot change the value the request resolves to.\n */\n chunk: Uint8Array;\n /** The response headers, available from the first event on. */\n headers: Headers;\n /**\n * Which attempt this is, from `0`. A retried request reports its body\n * again from the start under the next number, so a listener that\n * accumulates state resets it when this changes.\n */\n attempt: number;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * @internal Resource assertion that this operation deduplicates by the JSON\n * body's idempotency_key. Null means that optional key is absent, so the write\n * must not be retried. The transport checks the assertion against the body;\n * it does not send this option or copy a JSON key into an HTTP header.\n */\n bodyIdempotencyKey?: string | null;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /**\n * Override the client-level timeout for this request, in milliseconds.\n *\n * Covers the whole request, body included — unless `onDownloadProgress` is\n * set, in which case it is an **idle** timeout: it restarts when the\n * headers arrive and on every chunk of the body, so a long download that\n * keeps making progress is never cut off, and one that stalls still is.\n */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n /**\n * Report a 2xx response body as it downloads. Called once as soon as the\n * headers arrive (with an empty `chunk` and `loaded: 0`), then once per\n * chunk of the body; the value the request resolves to is decoded from\n * those same bytes, per `responseType`. Error responses are not reported.\n *\n * Setting it turns `timeout` into an idle timeout (see there). A body that\n * fails part-way rejects with the ordinary `NETWORK` error and is retried\n * on the usual terms, starting again under the next `attempt`. A listener\n * that throws rejects the request with that error, unretried.\n */\n onDownloadProgress?: (event: DownloadProgressEvent) => void;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * an `AbortSignal` for cancellation, and a download-progress listener — the\n * last is what a file download (a statement PDF, a report CSV) reports its\n * bytes through.\n */\nexport type RequestExtras = Pick<\n RequestOptions,\n 'headers' | 'timeout' | 'signal' | 'onDownloadProgress'\n>;\n\n/** How long an event stream may stay silent before it is given up. */\nconst DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45_000;\n\n/** Options of one `text/event-stream` request. */\nexport interface EventStreamRequestOptions {\n /** Query-string parameters, as {@link RequestOptions.query}. */\n query?: RequestOptions['query'];\n /** Additional HTTP headers, merged over the auth header. */\n headers?: Record<string, string>;\n /**\n * Aborting it before the response arrives rejects with code `ABORTED`;\n * aborting it later ends the dispatches without an error.\n */\n signal?: AbortSignal;\n /**\n * How long the stream may stay silent, response headers included, before\n * it fails with code `TIMEOUT`. Paused while the consumer holds a dispatch.\n * Defaults to 45 seconds.\n */\n idleTimeoutMs?: number;\n /** Sent as `Last-Event-ID`, and the id the stream starts from. */\n lastEventId?: string | null;\n}\n\n/**\n * An open event stream. Its body is read as it is iterated and never kept:\n * only the line and the event in progress are held.\n */\nexport interface EventStreamConnection {\n /**\n * The stream's dispatches, in order. Ends when the server closes the\n * stream or the caller aborts or closes it; throws a `DelopayError` with\n * code `TIMEOUT` when the stream is silent too long, and `NETWORK` when\n * the connection fails. Iterate it once.\n */\n readonly dispatches: AsyncIterable<EventStreamDispatch>;\n /** Close the stream: the iteration ends and the connection is released. */\n close(): void;\n}\n\n/** Opens a `GET` event stream; what resources that stream receive. */\nexport type EventStreamFn = (\n path: string,\n options?: EventStreamRequestOptions,\n) => Promise<EventStreamConnection>;\n\n/**\n * What a resource class is built from: the client's request and event-stream\n * functions. Every resource takes the request function first; the few that\n * stream (`Live`, `ProcessorImports`) also take the stream opener.\n */\nexport interface DelopayTransport {\n /** Send one request with the client's credentials, retries and timeout. */\n readonly request: RequestFn;\n /** Open one `text/event-stream` request with the client's credentials. */\n readonly openStream: EventStreamFn;\n /** The resolved base URL every request goes to. */\n readonly baseUrl: string;\n}\n\n/** A resource class that {@link DelopayCore.use} can build. */\nexport type ResourceConstructor<T> = new (request: RequestFn, openStream: EventStreamFn) => T;\n\n/**\n * The Delopay client without its resources: credentials, configuration,\n * transport, sessions and pagination.\n *\n * {@link Delopay} extends it with every resource as a property, which puts\n * every resource in the application's bundle. An application that wants only\n * the resources it calls builds them from this class instead, importing each\n * one from its own module, so a bundler leaves the rest out and can load each\n * one with the code that uses it:\n *\n * @example\n * ```typescript\n * import { DelopayCore } from '@delopay/sdk/core';\n * import { Refunds } from '@delopay/sdk/resources/refunds';\n *\n * const client = new DelopayCore('snd_...', { sandbox: true });\n * const refunds = client.use(Refunds);\n * const refund = await refunds.create({ payment_id: 'pay_abc123' });\n * ```\n *\n * A resource built this way shares the client's credentials: a token set with\n * {@link DelopayCore.setJwtToken} applies to it at once.\n */\nexport class DelopayCore {\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private readonly profileId?: string;\n private jwtToken?: string;\n\n /** The functions every resource is built from; see {@link DelopayCore.use}. */\n readonly transport: DelopayTransport;\n\n private readonly resources = new Map<ResourceConstructor<unknown>, unknown>();\n\n /**\n * Create a new client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n if (options?.profileId !== undefined && options.profileId !== '') {\n this.profileId = options.profileId;\n }\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n this.transport = {\n request: this.request.bind(this) as RequestFn,\n openStream: this.openEventStream.bind(this),\n baseUrl: this.baseUrl,\n };\n }\n\n /**\n * The client's instance of a resource class, built on first use from this\n * client's transport. Later calls with the same class return the same\n * instance.\n *\n * A resource whose constructor takes something else besides the transport\n * (`Branding` takes the base URL) is built directly instead:\n * `new Branding(client.transport.request, client.baseUrl)`.\n *\n * @param Resource - The resource class, imported from its own module.\n * @returns The resource, bound to this client.\n */\n use<T>(Resource: ResourceConstructor<T>): T {\n let resource = this.resources.get(Resource) as T | undefined;\n if (resource === undefined) {\n resource = new Resource(this.transport.request, this.transport.openStream);\n this.resources.set(Resource, resource);\n }\n return resource;\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * End the current login session on the server (`POST /user/signout`), the\n * same request as {@link Users.signOut}. The token stays set on this\n * client: clear it with {@link DelopayCore.clearJwtToken} afterwards. The\n * request's `Authorization` header is built when this is called, so\n * clearing the token straight after still signs out the session it held.\n */\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.request<TokenResponse>('POST', '/user/token/refresh');\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /** `path` on the base URL, with the query string `query` makes. */\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n let url = `${this.baseUrl}${path}`;\n if (query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n return url;\n }\n\n /** The credential header: the JWT when one is set, else the API key. */\n /**\n * The client's `X-Profile-Id`, unless the call names one itself (in any\n * letter case: two spellings would be sent as one joined value).\n */\n private profileHeaders(callHeaders?: Record<string, string>): Record<string, string> {\n if (this.profileId === undefined) return {};\n const named = Object.keys(callHeaders ?? {}).some(\n (name) => name.toLowerCase() === 'x-profile-id',\n );\n return named ? {} : { 'X-Profile-Id': this.profileId };\n }\n\n private authHeaders(): Record<string, string> {\n if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };\n if (this.apiKey) return { 'api-key': this.apiKey };\n return {};\n }\n\n /** One debug event, when `debug` is on. */\n private log(event: 'request' | 'response' | 'retry', data: Record<string, unknown>): void {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n }\n\n /**\n * Open a `GET` `text/event-stream` and read it as it arrives.\n *\n * `request()` keeps every chunk of a body until the body ends, which a\n * stream that stays open for half an hour must not do; this reads the body\n * chunk by chunk through {@link EventStreamParser} and keeps nothing it has\n * dispatched. Credentials, the base URL, debug logging and the mapping of a\n * non-2xx answer to `DelopayError` / `DelopayAuthenticationError` are the\n * ones `request()` uses.\n *\n * Never retried, and never reconnected: the caller owns reconnection.\n * Resolves once the response headers arrive; rejects on a non-2xx answer,\n * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and\n * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.\n */\n protected async openEventStream(\n path: string,\n options: EventStreamRequestOptions = {},\n ): Promise<EventStreamConnection> {\n const url = this.buildUrl(path, options.query);\n const lastEventId = options.lastEventId ?? '';\n const headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options.headers),\n Accept: 'text/event-stream',\n ...(lastEventId ? { 'Last-Event-ID': lastEventId } : {}),\n ...options.headers,\n };\n const idleMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;\n const callerSignal = options.signal;\n const aborted = () =>\n new DelopayError('Request aborted', { status: 0, code: 'ABORTED', type: 'abort_error' });\n if (callerSignal?.aborted) throw aborted();\n\n const idleCtrl = new AbortController();\n const closeCtrl = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stopIdleTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const startIdleTimer = () => {\n stopIdleTimer();\n if (!idleCtrl.signal.aborted) timer = setTimeout(() => idleCtrl.abort(), idleMs);\n };\n const combined = combineSignals(\n callerSignal\n ? [idleCtrl.signal, closeCtrl.signal, callerSignal]\n : [idleCtrl.signal, closeCtrl.signal],\n );\n const release = () => {\n stopIdleTimer();\n combined.dispose();\n };\n const timedOut = () =>\n new DelopayError(`Event stream silent for ${idleMs} ms`, {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n const network = (cause: unknown) =>\n new DelopayError(\n `Network error: ${cause instanceof Error ? cause.message : String(cause ?? 'stream failed')}`,\n { status: 0, code: 'NETWORK', type: 'network_error' },\n );\n\n this.log('request', { method: 'GET', url: redactUrlForLogging(url), path });\n startIdleTimer();\n let response: Response;\n try {\n response = await fetch(url, { method: 'GET', headers, signal: combined.signal });\n } catch (err) {\n release();\n if (callerSignal?.aborted) throw aborted();\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err);\n }\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n this.log('response', { status: response.status, method: 'GET', path, requestId });\n\n if (!response.ok) {\n // Read under the idle timer: a body that never ends gives up as empty.\n const error = await errorFromResponse(response, requestId);\n release();\n throw error;\n }\n\n const body = response.body;\n const contentType = response.headers?.get('content-type') ?? '';\n const mediaType = (contentType.split(';')[0] ?? '').trim().toLowerCase();\n if (mediaType !== 'text/event-stream' || !body || typeof body.getReader !== 'function') {\n release();\n body?.cancel().catch(noop);\n throw new DelopayError(\n mediaType === 'text/event-stream'\n ? 'The event stream has no readable body'\n : `Expected a text/event-stream response, got ${contentType ? `\"${contentType}\"` : 'no content type'}`,\n {\n status: response.status,\n code: 'NOT_EVENT_STREAM',\n type: 'invalid_response',\n requestId,\n },\n );\n }\n\n // The idle timer runs only while a read is pending: a consumer busy with\n // an event, or one that has not started iterating, is not silence.\n stopIdleTimer();\n const reader = body.getReader();\n const parser = new EventStreamParser(lastEventId);\n const decoder = new TextDecoder();\n const stopped = () => Boolean(callerSignal?.aborted) || closeCtrl.signal.aborted;\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n release();\n reader.cancel().catch(noop);\n };\n\n async function* dispatches(): AsyncGenerator<EventStreamDispatch, void, undefined> {\n try {\n for (;;) {\n let result: ReadableStreamReadResult<Uint8Array>;\n startIdleTimer();\n try {\n result = await readChunk(reader, combined.signal);\n } catch (err) {\n if (callerSignal?.aborted || closeCtrl.signal.aborted) return;\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err instanceof BodyStreamFailure ? err.cause : err);\n } finally {\n stopIdleTimer();\n }\n if (result.done) {\n // An event the stream did not finish with a blank line is\n // discarded, as the standard has it; only completed ones count.\n for (const dispatch of parser.push(decoder.decode())) {\n if (stopped()) return;\n yield dispatch;\n }\n return;\n }\n if (!result.value || result.value.byteLength === 0) continue;\n for (const dispatch of parser.push(decoder.decode(result.value, { stream: true }))) {\n // Aborted or closed while the consumer held the previous one.\n if (stopped()) return;\n yield dispatch;\n }\n }\n } finally {\n finish();\n }\n }\n\n return {\n dispatches: dispatches(),\n close: () => {\n closeCtrl.abort();\n finish();\n },\n };\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options?.query);\n\n let headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options?.headers),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n let idempotencyKey = findIdempotencyKey(headers)?.trim();\n if (options && Object.prototype.hasOwnProperty.call(options, 'bodyIdempotencyKey')) {\n const bodyKey = options?.bodyIdempotencyKey;\n const serialized: unknown =\n !isRawBody && typeof serializedBody === 'string' ? JSON.parse(serializedBody) : null;\n const actualKey =\n serialized && typeof serialized === 'object' && !Array.isArray(serialized)\n ? ((serialized as Record<string, unknown>).idempotency_key ?? null)\n : null;\n const suppliedHeaders = Object.keys(headers).filter(\n (name) => name.toLowerCase() === 'idempotency-key',\n );\n if (\n (bodyKey !== null && typeof bodyKey !== 'string') ||\n actualKey !== bodyKey ||\n suppliedHeaders.some(\n (name) => headers[name] !== bodyKey || headers[name]?.trim() !== headers[name],\n )\n ) {\n throw new DelopayError('Request retry keys must match the JSON body key', {\n status: 0,\n code: 'IDEMPOTENCY_KEY_MISMATCH',\n type: 'invalid_request',\n });\n }\n idempotencyKey = bodyKey?.trim();\n // Collapse differently cased copies so fetch cannot combine them into a\n // different header value. Other caller headers remain untouched.\n if (suppliedHeaders.length > 0) {\n headers = {\n ...Object.fromEntries(\n Object.entries(headers).filter(([name]) => name.toLowerCase() !== 'idempotency-key'),\n ),\n 'Idempotency-Key': idempotencyKey ?? '',\n };\n }\n }\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) =>\n this.log(event, data);\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n // With a progress listener the timeout measures silence, not the whole\n // download: each sign of life restarts it.\n const restartIdleTimer = () => {\n if (timeoutCtrl.signal.aborted) return;\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n };\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n // A 401 that is our credential's comes back as a\n // DelopayAuthenticationError; its status is never transient, so it\n // is thrown below without a retry.\n const error = await errorFromResponse(response, requestId);\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.onDownloadProgress) {\n return (await receiveWithProgress(\n response,\n options.responseType,\n options.onDownloadProgress,\n attempt,\n combined.signal,\n restartIdleTimer,\n )) as T;\n }\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof ListenerFailure) {\n throw err.cause;\n }\n if (err instanceof BodyStreamFailure) {\n const cause = err.cause;\n const detail =\n cause instanceof Error ? cause.message : String(cause ?? 'body stream failed');\n lastError = new DelopayError(`Network error: ${detail}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-HSJABE7X.cjs","../src/core.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACDA,IAAM,eAAA,EAAiB,yBAAA;AACvB,IAAM,YAAA,EAAc,iCAAA;AAEpB,IAAM,mBAAA,EAAqB,IAAA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YAAA;AACP,UAAA;AAC6C,UAAA;AACxC,UAAA;AACR,QAAA;AAC8B,QAAA;AACkC,UAAA;AACpD,YAAA;AACF,YAAA;AACA,YAAA;AACP,UAAA;AAC6C,UAAA;AACxC,UAAA;AACR,QAAA;AACM,QAAA;AACN,MAAA;AACsB,QAAA;AACL,QAAA;AACnB,MAAA;AACF,IAAA;AAEM,IAAA;AACR,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2CqB,EAAA;AACgD,IAAA;AACH,IAAA;AACnD,IAAA;AACT,IAAA;AACS,IAAA;AAC8C,MAAA;AAK3C,MAAA;AACmC,QAAA;AAC1C,MAAA;AACS,QAAA;AAChB,MAAA;AACgC,MAAA;AACsB,MAAA;AAC9B,MAAA;AACE,MAAA;AAClB,QAAA;AACR,MAAA;AAC6B,MAAA;AACf,MAAA;AACuB,QAAA;AACX,QAAA;AACH,QAAA;AACI,QAAA;AACpB,MAAA;AACW,QAAA;AAClB,MAAA;AACF,IAAA;AACF,EAAA;AACF;ADjc+E;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-HSJABE7X.cjs","sourcesContent":[null,"import { DelopayError, DelopayAuthenticationError } from './error';\nimport { EventStreamParser } from './eventStream';\nimport type { EventStreamDispatch } from './eventStream';\nimport type { TokenResponse } from './types';\n\nexport { DelopayError, DelopayAuthenticationError } from './error';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net/api';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\n/**\n * The error a non-2xx response stands for, read off its body.\n *\n * The API wraps errors as `{ error: { message, code, type, data? } }`; a body\n * that is not JSON (an HTML 502 from a proxy) is kept, truncated, as\n * `rawBody`. A 401 is a {@link DelopayAuthenticationError} unless it is a\n * connector's passthrough.\n */\nasync function errorFromResponse(\n response: Response,\n requestId: string | undefined,\n): Promise<DelopayError> {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message = (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n return new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n return new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\n/**\n * A `onDownloadProgress` listener threw. Carried out of the transport as-is so\n * the retry logic never mistakes the caller's own failure — a `TypeError` in a\n * progress bar, say — for a network error and downloads the body again.\n */\nclass ListenerFailure {\n constructor(readonly cause: unknown) {}\n}\n\n/**\n * The body stream failed after the headers arrived: the connection dropped, or\n * the server aborted it because it could not finish the body it had started.\n * Surfaced as the transport's ordinary network error, so it is retried on\n * exactly the same terms as a failure before the first byte.\n */\nclass BodyStreamFailure {\n constructor(readonly cause: unknown) {}\n}\n\nfunction abortError(): Error {\n const error = new Error('The operation was aborted');\n error.name = 'AbortError';\n return error;\n}\n\n/** `Content-Length` as a byte count, or `null` when absent or unreadable. */\nfunction parseContentLength(header: string | null): number | null {\n if (header === null || !/^\\s*\\d+\\s*$/.test(header)) return null;\n const value = Number(header);\n return Number.isSafeInteger(value) ? value : null;\n}\n\n/**\n * One `reader.read()`, raced against the request's signal.\n *\n * A conforming `fetch` errors the body stream itself when its signal aborts,\n * but not every stream a runtime or a polyfill hands back does, and a read\n * that never settles would hold a timed-out or cancelled download open for\n * good. The race makes the abort reach the reader either way.\n */\nfunction readChunk(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n signal: AbortSignal,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n if (signal.aborted) return Promise.reject(abortError());\n return new Promise((resolve, reject) => {\n const onAbort = () => reject(abortError());\n signal.addEventListener('abort', onAbort, { once: true });\n reader.read().then(\n (result) => {\n signal.removeEventListener('abort', onAbort);\n resolve(result);\n },\n (cause: unknown) => {\n signal.removeEventListener('abort', onAbort);\n reject(signal.aborted ? abortError() : new BodyStreamFailure(cause));\n },\n );\n });\n}\n\n/** The chunks as one buffer of exactly `length` bytes. */\nfunction concatChunks(chunks: Uint8Array[], length: number): ArrayBuffer {\n const out = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out.buffer;\n}\n\n/**\n * Read a 2xx body chunk by chunk, reporting each one, and decode it as\n * `responseType` asks — the `onDownloadProgress` path of `request()`.\n *\n * `onActivity` is called when the headers arrive and on every chunk; the\n * caller uses it to restart its idle timer.\n */\nasync function receiveWithProgress(\n response: Response,\n responseType: RequestOptions['responseType'],\n listener: (event: DownloadProgressEvent) => void,\n attempt: number,\n signal: AbortSignal,\n onActivity: () => void,\n): Promise<unknown> {\n const headers = response.headers ?? new Headers();\n const total = parseContentLength(headers.get('content-length'));\n let loaded = 0;\n const notify = (chunk: Uint8Array) => {\n try {\n // A copy: the request resolves to the bytes it read, whatever a\n // listener does with the ones it was shown.\n listener({ loaded, total, chunk: chunk.slice(), headers, attempt });\n } catch (cause) {\n throw new ListenerFailure(cause);\n }\n };\n\n onActivity();\n notify(new Uint8Array(0));\n\n const body = response.body;\n if (!body || typeof body.getReader !== 'function') {\n // No readable stream: a null-body status, or a runtime whose `fetch` does\n // not expose one. The body is read whole, and reported as one chunk.\n if (responseType === 'blob') {\n const blob = await response.blob();\n const bytes = new Uint8Array(await blob.arrayBuffer());\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return blob;\n }\n if (responseType === 'arraybuffer') {\n const buffer = await response.arrayBuffer();\n loaded = buffer.byteLength;\n if (loaded > 0) notify(new Uint8Array(buffer));\n return buffer;\n }\n const text = await response.text();\n const bytes = new TextEncoder().encode(text);\n loaded = bytes.byteLength;\n if (loaded > 0) notify(bytes);\n return text ? JSON.parse(text) : undefined;\n }\n\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n try {\n for (;;) {\n const { done, value } = await readChunk(reader, signal);\n if (done) break;\n if (!value || value.byteLength === 0) continue;\n chunks.push(value);\n loaded += value.byteLength;\n onActivity();\n notify(value);\n }\n } catch (err) {\n // Release the connection rather than leave a half-read body behind it.\n reader.cancel().catch(noop);\n throw err;\n }\n\n const bytes = concatChunks(chunks, loaded);\n if (responseType === 'blob') {\n return new Blob([bytes], { type: headers.get('content-type') ?? '' });\n }\n if (responseType === 'arraybuffer') {\n return bytes;\n }\n const text = new TextDecoder().decode(bytes);\n return text ? JSON.parse(text) : undefined;\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /**\n * Use the sandbox environment (`https://sandbox.delopay.net/api`). Defaults\n * to `false` (production). Request paths are appended to that address, so a\n * payment is created at `https://sandbox.delopay.net/api/payments`.\n */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n /**\n * The shop (business profile) every request acts on, sent as `X-Profile-Id`.\n * An API key bound to several shops must name one of them on every request;\n * create one client per shop. A header a call sets itself takes precedence.\n */\n profileId?: string;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * One step of a response body's download, reported to\n * {@link RequestOptions.onDownloadProgress}.\n */\nexport interface DownloadProgressEvent {\n /** Body bytes received so far on this attempt, `chunk` included. */\n loaded: number;\n /**\n * `Content-Length`, when the response carried one — a buffered body such as\n * a PDF. `null` for a streamed (chunked) body, whose size is not known\n * until it ends. With a compressed transfer it is the compressed size, so\n * `loaded` can pass it.\n */\n total: number | null;\n /**\n * The bytes this event reports. Empty on the first event of an attempt,\n * which fires as soon as the headers arrive, before any of the body.\n * A copy: changing it cannot change the value the request resolves to.\n */\n chunk: Uint8Array;\n /** The response headers, available from the first event on. */\n headers: Headers;\n /**\n * Which attempt this is, from `0`. A retried request reports its body\n * again from the start under the next number, so a listener that\n * accumulates state resets it when this changes.\n */\n attempt: number;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * @internal Resource assertion that this operation deduplicates by the JSON\n * body's idempotency_key. Null means that optional key is absent, so the write\n * must not be retried. The transport checks the assertion against the body;\n * it does not send this option or copy a JSON key into an HTTP header.\n */\n bodyIdempotencyKey?: string | null;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /**\n * Override the client-level timeout for this request, in milliseconds.\n *\n * Covers the whole request, body included — unless `onDownloadProgress` is\n * set, in which case it is an **idle** timeout: it restarts when the\n * headers arrive and on every chunk of the body, so a long download that\n * keeps making progress is never cut off, and one that stalls still is.\n */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n /**\n * Report a 2xx response body as it downloads. Called once as soon as the\n * headers arrive (with an empty `chunk` and `loaded: 0`), then once per\n * chunk of the body; the value the request resolves to is decoded from\n * those same bytes, per `responseType`. Error responses are not reported.\n *\n * Setting it turns `timeout` into an idle timeout (see there). A body that\n * fails part-way rejects with the ordinary `NETWORK` error and is retried\n * on the usual terms, starting again under the next `attempt`. A listener\n * that throws rejects the request with that error, unretried.\n */\n onDownloadProgress?: (event: DownloadProgressEvent) => void;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * an `AbortSignal` for cancellation, and a download-progress listener — the\n * last is what a file download (a statement PDF, a report CSV) reports its\n * bytes through.\n */\nexport type RequestExtras = Pick<\n RequestOptions,\n 'headers' | 'timeout' | 'signal' | 'onDownloadProgress'\n>;\n\n/** How long an event stream may stay silent before it is given up. */\nconst DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45_000;\n\n/** Options of one `text/event-stream` request. */\nexport interface EventStreamRequestOptions {\n /** Query-string parameters, as {@link RequestOptions.query}. */\n query?: RequestOptions['query'];\n /** Additional HTTP headers, merged over the auth header. */\n headers?: Record<string, string>;\n /**\n * Aborting it before the response arrives rejects with code `ABORTED`;\n * aborting it later ends the dispatches without an error.\n */\n signal?: AbortSignal;\n /**\n * How long the stream may stay silent, response headers included, before\n * it fails with code `TIMEOUT`. Paused while the consumer holds a dispatch.\n * Defaults to 45 seconds.\n */\n idleTimeoutMs?: number;\n /** Sent as `Last-Event-ID`, and the id the stream starts from. */\n lastEventId?: string | null;\n}\n\n/**\n * An open event stream. Its body is read as it is iterated and never kept:\n * only the line and the event in progress are held.\n */\nexport interface EventStreamConnection {\n /**\n * The stream's dispatches, in order. Ends when the server closes the\n * stream or the caller aborts or closes it; throws a `DelopayError` with\n * code `TIMEOUT` when the stream is silent too long, and `NETWORK` when\n * the connection fails. Iterate it once.\n */\n readonly dispatches: AsyncIterable<EventStreamDispatch>;\n /** Close the stream: the iteration ends and the connection is released. */\n close(): void;\n}\n\n/** Opens a `GET` event stream; what resources that stream receive. */\nexport type EventStreamFn = (\n path: string,\n options?: EventStreamRequestOptions,\n) => Promise<EventStreamConnection>;\n\n/**\n * What a resource class is built from: the client's request and event-stream\n * functions. Every resource takes the request function first; the few that\n * stream (`Live`, `ProcessorImports`) also take the stream opener.\n */\nexport interface DelopayTransport {\n /** Send one request with the client's credentials, retries and timeout. */\n readonly request: RequestFn;\n /** Open one `text/event-stream` request with the client's credentials. */\n readonly openStream: EventStreamFn;\n /** The resolved base URL every request goes to. */\n readonly baseUrl: string;\n}\n\n/** A resource class that {@link DelopayCore.use} can build. */\nexport type ResourceConstructor<T> = new (request: RequestFn, openStream: EventStreamFn) => T;\n\n/**\n * The Delopay client without its resources: credentials, configuration,\n * transport, sessions and pagination.\n *\n * {@link Delopay} extends it with every resource as a property, which puts\n * every resource in the application's bundle. An application that wants only\n * the resources it calls builds them from this class instead, importing each\n * one from its own module, so a bundler leaves the rest out and can load each\n * one with the code that uses it:\n *\n * @example\n * ```typescript\n * import { DelopayCore } from '@delopay/sdk/core';\n * import { Refunds } from '@delopay/sdk/resources/refunds';\n *\n * const client = new DelopayCore('snd_...', { sandbox: true });\n * const refunds = client.use(Refunds);\n * const refund = await refunds.create({ payment_id: 'pay_abc123' });\n * ```\n *\n * A resource built this way shares the client's credentials: a token set with\n * {@link DelopayCore.setJwtToken} applies to it at once.\n */\nexport class DelopayCore {\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private readonly profileId?: string;\n private jwtToken?: string;\n\n /** The functions every resource is built from; see {@link DelopayCore.use}. */\n readonly transport: DelopayTransport;\n\n private readonly resources = new Map<ResourceConstructor<unknown>, unknown>();\n\n /**\n * Create a new client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n if (options?.profileId !== undefined && options.profileId !== '') {\n this.profileId = options.profileId;\n }\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n this.transport = {\n request: this.request.bind(this) as RequestFn,\n openStream: this.openEventStream.bind(this),\n baseUrl: this.baseUrl,\n };\n }\n\n /**\n * The client's instance of a resource class, built on first use from this\n * client's transport. Later calls with the same class return the same\n * instance.\n *\n * A resource whose constructor takes something else besides the transport\n * (`Branding` takes the base URL) is built directly instead:\n * `new Branding(client.transport.request, client.baseUrl)`.\n *\n * @param Resource - The resource class, imported from its own module.\n * @returns The resource, bound to this client.\n */\n use<T>(Resource: ResourceConstructor<T>): T {\n let resource = this.resources.get(Resource) as T | undefined;\n if (resource === undefined) {\n resource = new Resource(this.transport.request, this.transport.openStream);\n this.resources.set(Resource, resource);\n }\n return resource;\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * End the current login session on the server (`POST /user/signout`), the\n * same request as {@link Users.signOut}. The token stays set on this\n * client: clear it with {@link DelopayCore.clearJwtToken} afterwards. The\n * request's `Authorization` header is built when this is called, so\n * clearing the token straight after still signs out the session it held.\n */\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.request<TokenResponse>('POST', '/user/token/refresh');\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /** `path` on the base URL, with the query string `query` makes. */\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n let url = `${this.baseUrl}${path}`;\n if (query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n return url;\n }\n\n /** The credential header: the JWT when one is set, else the API key. */\n /**\n * The client's `X-Profile-Id`, unless the call names one itself (in any\n * letter case: two spellings would be sent as one joined value).\n */\n private profileHeaders(callHeaders?: Record<string, string>): Record<string, string> {\n if (this.profileId === undefined) return {};\n const named = Object.keys(callHeaders ?? {}).some(\n (name) => name.toLowerCase() === 'x-profile-id',\n );\n return named ? {} : { 'X-Profile-Id': this.profileId };\n }\n\n private authHeaders(): Record<string, string> {\n if (this.jwtToken) return { Authorization: `Bearer ${this.jwtToken}` };\n if (this.apiKey) return { 'api-key': this.apiKey };\n return {};\n }\n\n /** One debug event, when `debug` is on. */\n private log(event: 'request' | 'response' | 'retry', data: Record<string, unknown>): void {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n }\n\n /**\n * Open a `GET` `text/event-stream` and read it as it arrives.\n *\n * `request()` keeps every chunk of a body until the body ends, which a\n * stream that stays open for half an hour must not do; this reads the body\n * chunk by chunk through {@link EventStreamParser} and keeps nothing it has\n * dispatched. Credentials, the base URL, debug logging and the mapping of a\n * non-2xx answer to `DelopayError` / `DelopayAuthenticationError` are the\n * ones `request()` uses.\n *\n * Never retried, and never reconnected: the caller owns reconnection.\n * Resolves once the response headers arrive; rejects on a non-2xx answer,\n * on a 2xx that is not `text/event-stream` (code `NOT_EVENT_STREAM`), and\n * with `TIMEOUT`, `NETWORK` or `ABORTED` like `request()`.\n */\n protected async openEventStream(\n path: string,\n options: EventStreamRequestOptions = {},\n ): Promise<EventStreamConnection> {\n const url = this.buildUrl(path, options.query);\n const lastEventId = options.lastEventId ?? '';\n const headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options.headers),\n Accept: 'text/event-stream',\n ...(lastEventId ? { 'Last-Event-ID': lastEventId } : {}),\n ...options.headers,\n };\n const idleMs = options.idleTimeoutMs ?? DEFAULT_STREAM_IDLE_TIMEOUT_MS;\n const callerSignal = options.signal;\n const aborted = () =>\n new DelopayError('Request aborted', { status: 0, code: 'ABORTED', type: 'abort_error' });\n if (callerSignal?.aborted) throw aborted();\n\n const idleCtrl = new AbortController();\n const closeCtrl = new AbortController();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stopIdleTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const startIdleTimer = () => {\n stopIdleTimer();\n if (!idleCtrl.signal.aborted) timer = setTimeout(() => idleCtrl.abort(), idleMs);\n };\n const combined = combineSignals(\n callerSignal\n ? [idleCtrl.signal, closeCtrl.signal, callerSignal]\n : [idleCtrl.signal, closeCtrl.signal],\n );\n const release = () => {\n stopIdleTimer();\n combined.dispose();\n };\n const timedOut = () =>\n new DelopayError(`Event stream silent for ${idleMs} ms`, {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n const network = (cause: unknown) =>\n new DelopayError(\n `Network error: ${cause instanceof Error ? cause.message : String(cause ?? 'stream failed')}`,\n { status: 0, code: 'NETWORK', type: 'network_error' },\n );\n\n this.log('request', { method: 'GET', url: redactUrlForLogging(url), path });\n startIdleTimer();\n let response: Response;\n try {\n response = await fetch(url, { method: 'GET', headers, signal: combined.signal });\n } catch (err) {\n release();\n if (callerSignal?.aborted) throw aborted();\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err);\n }\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n this.log('response', { status: response.status, method: 'GET', path, requestId });\n\n if (!response.ok) {\n // Read under the idle timer: a body that never ends gives up as empty.\n const error = await errorFromResponse(response, requestId);\n release();\n throw error;\n }\n\n const body = response.body;\n const contentType = response.headers?.get('content-type') ?? '';\n const mediaType = (contentType.split(';')[0] ?? '').trim().toLowerCase();\n if (mediaType !== 'text/event-stream' || !body || typeof body.getReader !== 'function') {\n release();\n body?.cancel().catch(noop);\n throw new DelopayError(\n mediaType === 'text/event-stream'\n ? 'The event stream has no readable body'\n : `Expected a text/event-stream response, got ${contentType ? `\"${contentType}\"` : 'no content type'}`,\n {\n status: response.status,\n code: 'NOT_EVENT_STREAM',\n type: 'invalid_response',\n requestId,\n },\n );\n }\n\n // The idle timer runs only while a read is pending: a consumer busy with\n // an event, or one that has not started iterating, is not silence.\n stopIdleTimer();\n const reader = body.getReader();\n const parser = new EventStreamParser(lastEventId);\n const decoder = new TextDecoder();\n const stopped = () => Boolean(callerSignal?.aborted) || closeCtrl.signal.aborted;\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n release();\n reader.cancel().catch(noop);\n };\n\n async function* dispatches(): AsyncGenerator<EventStreamDispatch, void, undefined> {\n try {\n for (;;) {\n let result: ReadableStreamReadResult<Uint8Array>;\n startIdleTimer();\n try {\n result = await readChunk(reader, combined.signal);\n } catch (err) {\n if (callerSignal?.aborted || closeCtrl.signal.aborted) return;\n if (idleCtrl.signal.aborted) throw timedOut();\n throw network(err instanceof BodyStreamFailure ? err.cause : err);\n } finally {\n stopIdleTimer();\n }\n if (result.done) {\n // An event the stream did not finish with a blank line is\n // discarded, as the standard has it; only completed ones count.\n for (const dispatch of parser.push(decoder.decode())) {\n if (stopped()) return;\n yield dispatch;\n }\n return;\n }\n if (!result.value || result.value.byteLength === 0) continue;\n for (const dispatch of parser.push(decoder.decode(result.value, { stream: true }))) {\n // Aborted or closed while the consumer held the previous one.\n if (stopped()) return;\n yield dispatch;\n }\n }\n } finally {\n finish();\n }\n }\n\n return {\n dispatches: dispatches(),\n close: () => {\n closeCtrl.abort();\n finish();\n },\n };\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options?.query);\n\n let headers: Record<string, string> = {\n ...this.authHeaders(),\n ...this.profileHeaders(options?.headers),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n let idempotencyKey = findIdempotencyKey(headers)?.trim();\n if (options && Object.prototype.hasOwnProperty.call(options, 'bodyIdempotencyKey')) {\n const bodyKey = options?.bodyIdempotencyKey;\n const serialized: unknown =\n !isRawBody && typeof serializedBody === 'string' ? JSON.parse(serializedBody) : null;\n const actualKey =\n serialized && typeof serialized === 'object' && !Array.isArray(serialized)\n ? ((serialized as Record<string, unknown>).idempotency_key ?? null)\n : null;\n const suppliedHeaders = Object.keys(headers).filter(\n (name) => name.toLowerCase() === 'idempotency-key',\n );\n if (\n (bodyKey !== null && typeof bodyKey !== 'string') ||\n actualKey !== bodyKey ||\n suppliedHeaders.some(\n (name) => headers[name] !== bodyKey || headers[name]?.trim() !== headers[name],\n )\n ) {\n throw new DelopayError('Request retry keys must match the JSON body key', {\n status: 0,\n code: 'IDEMPOTENCY_KEY_MISMATCH',\n type: 'invalid_request',\n });\n }\n idempotencyKey = bodyKey?.trim();\n // Collapse differently cased copies so fetch cannot combine them into a\n // different header value. Other caller headers remain untouched.\n if (suppliedHeaders.length > 0) {\n headers = {\n ...Object.fromEntries(\n Object.entries(headers).filter(([name]) => name.toLowerCase() !== 'idempotency-key'),\n ),\n 'Idempotency-Key': idempotencyKey ?? '',\n };\n }\n }\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) =>\n this.log(event, data);\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n let timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n // With a progress listener the timeout measures silence, not the whole\n // download: each sign of life restarts it.\n const restartIdleTimer = () => {\n if (timeoutCtrl.signal.aborted) return;\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n };\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n // A 401 that is our credential's comes back as a\n // DelopayAuthenticationError; its status is never transient, so it\n // is thrown below without a retry.\n const error = await errorFromResponse(response, requestId);\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.onDownloadProgress) {\n return (await receiveWithProgress(\n response,\n options.responseType,\n options.onDownloadProgress,\n attempt,\n combined.signal,\n restartIdleTimer,\n )) as T;\n }\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof ListenerFailure) {\n throw err.cause;\n }\n if (err instanceof BodyStreamFailure) {\n const cause = err.cause;\n const detail =\n cause instanceof Error ? cause.message : String(cause ?? 'body stream failed');\n lastError = new DelopayError(`Network error: ${detail}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n"]}
|
|
@@ -7,10 +7,11 @@ import {
|
|
|
7
7
|
// src/resources/disputes.ts
|
|
8
8
|
function workspaceQuery(params) {
|
|
9
9
|
if (!params) return void 0;
|
|
10
|
-
const { connector, currency, dispute_status, dispute_stage, profile_ids, ...query } = params;
|
|
10
|
+
const { connector, currency, dispute_status, dispute_stage, profile_ids, industry, ...query } = params;
|
|
11
11
|
return {
|
|
12
12
|
...query,
|
|
13
13
|
...profile_ids?.length ? { profile_ids: profile_ids.join(",") } : {},
|
|
14
|
+
...industry?.length ? { industry: industry.join(",") } : {},
|
|
14
15
|
...connector?.length ? { connector: connector.join(",") } : {},
|
|
15
16
|
...currency?.length ? { currency: currency.join(",") } : {},
|
|
16
17
|
...dispute_status?.length ? { dispute_status: dispute_status.join(",") } : {},
|
|
@@ -226,4 +227,4 @@ var Disputes = class {
|
|
|
226
227
|
export {
|
|
227
228
|
Disputes
|
|
228
229
|
};
|
|
229
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-HYQXNRST.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resources/disputes.ts"],"sourcesContent":["import type {\n DisputeReconcileRequest,\n DisputeResponse,\n DisputeListParams,\n DisputeEvidenceRequest,\n DeleteEvidenceRequest,\n DisputeEvidenceBlock,\n DisputeRefundDeclaration,\n DisputeRefundAssociationRequest,\n DisputeRefundAssociationsResponse,\n DisputeWorkspaceRequest,\n DisputeWorkspaceResponse,\n DisputeWorkspaceFilters,\n DisputeWorkspaceAggregate,\n DisputeWorkspaceExport,\n DisputeBulkAcceptRequest,\n DisputeBulkAcceptResponse,\n DisputeBulkBlockBuyerRequest,\n DisputeBulkBlockBuyerResponse,\n DisputeBulkPreviewRequest,\n DisputeBulkPreviewResponse,\n DynamicWorkspaceExportOptions,\n JsonExportOptions,\n PdfExportOptions,\n} from '../types';\nimport type { RequestFn, RequestOptions } from '../client';\nimport { WORKSPACE_ENVELOPE, downloadExport, negotiated } from '../exportDownload';\n\n/** Workspace filters use CSV values, unlike the transport's repeated-key arrays. */\nfunction workspaceQuery(params?: DisputeWorkspaceRequest): RequestOptions['query'] {\n if (!params) return undefined;\n const { connector, currency, dispute_status, dispute_stage, profile_ids, industry, ...query } =\n params;\n return {\n ...query,\n ...(profile_ids?.length ? { profile_ids: profile_ids.join(',') } : {}),\n ...(industry?.length ? { industry: industry.join(',') } : {}),\n ...(connector?.length ? { connector: connector.join(',') } : {}),\n ...(currency?.length ? { currency: currency.join(',') } : {}),\n ...(dispute_status?.length ? { dispute_status: dispute_status.join(',') } : {}),\n ...(dispute_stage?.length ? { dispute_stage: dispute_stage.join(',') } : {}),\n };\n}\n\n/** View and respond to payment disputes and chargebacks. */\nexport class Disputes {\n constructor(private readonly request: RequestFn) {}\n\n /** Read native disputes and provider-only cases once, after shared authorization and filters. */\n async workspace(params?: DisputeWorkspaceRequest): Promise<DisputeWorkspaceResponse> {\n return this.request('GET', '/disputes/workspace', { query: workspaceQuery(params) });\n }\n\n /** Read filter options over the same scoped case set; pagination is ignored. */\n async workspaceFilters(params?: DisputeWorkspaceRequest): Promise<DisputeWorkspaceFilters> {\n return this.request('GET', '/disputes/workspace/filters', { query: workspaceQuery(params) });\n }\n\n /** Count the filtered case set, including unknown outcomes; pagination is ignored. */\n async workspaceAggregate(params?: DisputeWorkspaceRequest): Promise<DisputeWorkspaceAggregate> {\n return this.request('GET', '/disputes/workspace/aggregate', { query: workspaceQuery(params) });\n }\n\n /**\n * Export the complete filtered set, or throw on the server's explicit\n * export-limit refusal. `GET /disputes/workspace/export`\n *\n * The body is streamed, and held to the `X-Delopay-Record-Count` the server\n * announces and to its own `total_count`: a set that arrives short rejects\n * with `EXPORT_INCOMPLETE` rather than resolving. `options` reports the\n * download's progress and takes a signal and an idle timeout — see\n * {@link ExportTransferOptions}.\n *\n * `format: 'pdf'` resolves to the same set laid out as a document (a\n * `Blob`), with the words in `options.presentation` — see\n * {@link ExportPresentation}. This route offers no CSV.\n */\n async workspaceExport(\n params?: DisputeWorkspaceRequest,\n options?: JsonExportOptions,\n ): Promise<DisputeWorkspaceExport>;\n async workspaceExport(\n params: DisputeWorkspaceRequest | undefined,\n options: PdfExportOptions,\n ): Promise<Blob>;\n async workspaceExport(\n params: DisputeWorkspaceRequest | undefined,\n options: DynamicWorkspaceExportOptions,\n ): Promise<DisputeWorkspaceExport | Blob>;\n async workspaceExport(\n params?: DisputeWorkspaceRequest,\n options?: JsonExportOptions | PdfExportOptions | DynamicWorkspaceExportOptions,\n ): Promise<DisputeWorkspaceExport | Blob> {\n const format = options?.format ?? 'json';\n return downloadExport(\n this.request,\n {\n method: 'GET',\n path: '/disputes/workspace/export',\n request: negotiated({ query: workspaceQuery(params) }, format, options?.presentation),\n format,\n envelope: WORKSPACE_ENVELOPE,\n },\n options,\n );\n }\n\n /**\n * What a bulk action would do to the selected cases, changing nothing:\n * each case as eligible or skipped with a reason, and what the eligible ones\n * add up to per currency. Name the cases by `ids` or by the list's\n * `filters`, exactly one of the two; at most `max_cases` are read.\n *\n * `POST /disputes/workspace/bulk/preview`. Needs a dashboard JWT.\n */\n async bulkPreview(request: DisputeBulkPreviewRequest): Promise<DisputeBulkPreviewResponse> {\n // The body's filters take CSV values, as the list's query does.\n const { filters, ...rest } = request;\n return this.request('POST', '/disputes/workspace/bulk/preview', {\n body: filters ? { ...rest, filters: workspaceQuery(filters) } : rest,\n });\n }\n\n /**\n * Accept the listed cases at their processors, at most the preview's\n * `max_run_cases` per call; send a larger set in parts under one\n * `request_id`. Eligibility is decided again at run time, and every case\n * gets its own result. An `unknown` result means the processor may have\n * acted: read the case before acting on it again.\n *\n * `POST /disputes/workspace/bulk/accept`. Needs a dashboard JWT.\n */\n async bulkAccept(request: DisputeBulkAcceptRequest): Promise<DisputeBulkAcceptResponse> {\n return this.request('POST', '/disputes/workspace/bulk/accept', { body: request });\n }\n\n /**\n * Add the buyer of each listed case's payment to the buyer blocklist: the\n * payment's email and customer id, and the device ids and IP address of the\n * browser that paid, when DeloPay can tie them to it. Identifiers already\n * blocked are not added again, and `unattributed` names those it could not\n * tie to the buyer.\n *\n * `POST /disputes/workspace/bulk/block-buyer`. Needs a dashboard JWT.\n */\n async bulkBlockBuyer(\n request: DisputeBulkBlockBuyerRequest,\n ): Promise<DisputeBulkBlockBuyerResponse> {\n return this.request('POST', '/disputes/workspace/bulk/block-buyer', { body: request });\n }\n\n /**\n * Retrieve a dispute by its ID.\n *\n * @param disputeId - The unique dispute ID.\n * @returns The dispute.\n */\n async retrieve(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`);\n }\n\n /** Read declared links and provider-reported refund references. Empty means unknown. */\n async listRefundAssociations(disputeId: string): Promise<DisputeRefundAssociationsResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}/refund-associations`);\n }\n\n /** Declare or clear an allocation against a successful refund of this payment. */\n async setRefundAssociation(\n disputeId: string,\n params: DisputeRefundAssociationRequest,\n ): Promise<DisputeRefundDeclaration> {\n return this.request('PUT', `/disputes/${encodeURIComponent(disputeId)}/refund-associations`, {\n body: params,\n });\n }\n\n /**\n * List disputes, optionally filtered by status, stage, or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of disputes.\n */\n async list(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * Accept a dispute, conceding the chargeback to the customer.\n *\n * @param disputeId - The dispute ID to accept.\n * @returns The updated dispute.\n */\n async accept(disputeId: string): Promise<DisputeResponse> {\n return this.request('POST', `/disputes/accept/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Correct the exchange rate of a dispute the processor reported in another\n * currency, or record its final settled amount. Until it is settled, the\n * reserved amount is an estimate and no other dispute on the same payment\n * attempt can take a new reservation. Signed-in users with the\n * external-record permission only.\n *\n * @param disputeId - The dispute to reconcile.\n * @param request - `correct_rate` with the processor's rate, or `settle`\n * with the final amount and a reason.\n * @returns The updated dispute.\n */\n async reconcile(disputeId: string, request: DisputeReconcileRequest): Promise<DisputeResponse> {\n return this.request('POST', `/disputes/${encodeURIComponent(disputeId)}/reconcile`, {\n body: request,\n });\n }\n\n /**\n * Submit evidence to challenge a dispute.\n *\n * @param params - Evidence details and the dispute ID to contest.\n * @returns The updated dispute.\n */\n async submitEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('POST', '/disputes/evidence', { body: params });\n }\n\n /**\n * Attach evidence (e.g. file upload metadata) to a dispute.\n *\n * Uses `PUT /disputes/evidence`.\n */\n async attachEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('PUT', '/disputes/evidence', { body: params });\n }\n\n /**\n * Retrieve previously stored evidence for a dispute.\n *\n * Returns an ARRAY of file-evidence blocks (this was previously mistyped\n * as the flat submit-request shape). Only file evidence is reported —\n * text evidence is not retrievable once submitted.\n *\n * @param disputeId - The dispute ID.\n * @returns The stored file-evidence blocks.\n */\n async retrieveEvidence(disputeId: string): Promise<DisputeEvidenceBlock[]> {\n return this.request('GET', `/disputes/evidence/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Delete submitted evidence for a dispute.\n *\n * @param params - Evidence request body identifying what to delete.\n * @returns The updated dispute.\n */\n async deleteEvidence(params: DeleteEvidenceRequest): Promise<DisputeResponse> {\n return this.request('DELETE', '/disputes/evidence', { body: params });\n }\n\n // --- OLAP extensions (Task 4.4) ---\n\n /** List disputes (profile-scoped). `GET /disputes/profile/list` */\n async listByProfile(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** Get dispute filter options. `GET /disputes/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/filter', { query: params });\n }\n\n /** Get dispute filters (profile-scoped). `GET /disputes/profile/filter` */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/filter', { query: params });\n }\n\n /** Get dispute aggregates. `GET /disputes/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/aggregate', { query: params });\n }\n\n /** Get dispute aggregates (profile-scoped). `GET /disputes/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/aggregate', { query: params });\n }\n\n /**\n * Fetch the latest dispute state from the connector (gateway) and persist it.\n * `GET /disputes/{disputeId}?force_sync=true`\n *\n * The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the\n * backend to pull the dispute from the connector (supported where the connector\n * implements the dispute-sync flow, e.g. Stripe) and update the stored record\n * before returning it.\n *\n * Note: this method previously called `GET /disputes/{id}/fetch`, which is a\n * different backend route — a bulk import keyed by **merchant connector account\n * id** with a required date range — so every call with a dispute id failed.\n */\n async fetchFromConnector(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`, {\n query: { force_sync: 'true' },\n });\n }\n}\n"],"mappings":";;;;;;;AA6BA,SAAS,eAAe,QAA2D;AACjF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,EAAE,WAAW,UAAU,gBAAgB,eAAe,aAAa,UAAU,GAAG,MAAM,IAC1F;AACF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAI,aAAa,SAAS,EAAE,aAAa,YAAY,KAAK,GAAG,EAAE,IAAI,CAAC;AAAA,IACpE,GAAI,UAAU,SAAS,EAAE,UAAU,SAAS,KAAK,GAAG,EAAE,IAAI,CAAC;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AAA,CAAK,KAAA,EAAO,OAAA,CAAQ,IAAA;AAAA,EACtD;AACF,CAAA;AAYO,IAAM,2BAAA,EAAN,MAAA,QAAyC,aAAa;AAAA,EAC3D,WAAA,CACE,QAAA,EAAU,iBAAA,EACV,OAAA,EAOA;AACA,IAAA,KAAA,CAAM,OAAA,EAAS;AAAA,MACb,MAAA,EAAQ,GAAA;AAAA;AAAA;AAAA;AAAA,MAIR,IAAA,kBAAM,OAAA,2BAAS,OAAA,GAAQ,SAAA;AAAA,MACvB,IAAA,kBAAM,OAAA,6BAAS,OAAA,GAAQ,sBAAA;AAAA,MACvB,SAAA,kBAAW,OAAA,6BAAS,WAAA;AAAA,MACpB,OAAA,kBAAS,OAAA,6BAAS,SAAA;AAAA,MAClB,IAAA,kBAAM,OAAA,6BAAS;AAAA,IACjB,CAAC,CAAA;AACD,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAChD,IAAA,IAAA,CAAK,KAAA,EAAO,4BAAA;AAAA,EACd;AACF,CAAA;ADhEA;AACA;AACE;AACA;AACF,qGAAC","file":"/tmp/w2-sdk-publish-0482/dist/chunk-I2W7AO4B.cjs","sourcesContent":[null,"/**\n * Error thrown when the Delopay API returns a non-2xx response, or when a\n * timeout or network error occurs.\n *\n * @example\n * ```typescript\n * try {\n * await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * } catch (e) {\n * if (e instanceof DelopayError) {\n * console.error(e.status, e.code, e.requestId, e.message);\n * }\n * }\n * ```\n */\nexport class DelopayError extends Error {\n /** HTTP status code returned by the API, or `0` for timeout/network errors. */\n readonly status: number;\n /** Machine-readable error code returned by the API (e.g. `'HE_00'`). */\n readonly code: string;\n /** Error category (e.g. `'invalid_request'`, `'timeout_error'`). */\n readonly type: string;\n /** Value of the `x-request-id` response header, when present. Include this when contacting support. */\n readonly requestId?: string;\n /**\n * Raw response body (truncated to ~2 KB). Populated when the server returns a\n * non-JSON error body (e.g. an HTML 502 from an upstream proxy) so debugging\n * still has something to go on.\n */\n readonly rawBody?: string;\n /**\n * Structured error context the API attaches under `error.data` for select\n * codes — e.g. `{ retry_after_secs: 248 }` on rate-limit / max-attempt\n * lockouts. Schema is per-code; consult the API reference for the shape.\n */\n readonly data?: Record<string, unknown>;\n\n constructor(\n message: string,\n options: {\n status: number;\n code: string;\n type: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayError';\n this.status = options.status;\n this.code = options.code;\n this.type = options.type;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.rawBody !== undefined) this.rawBody = options.rawBody;\n if (options.data !== undefined) this.data = options.data;\n }\n}\n\n/**\n * Thrown when the API key is missing, invalid, or revoked (HTTP 401).\n *\n * @example\n * ```typescript\n * if (e instanceof DelopayAuthenticationError) {\n * // Prompt user to re-enter their API key.\n * }\n * ```\n */\nexport class DelopayAuthenticationError extends DelopayError {\n constructor(\n message = 'Invalid API key',\n options?: {\n code?: string;\n type?: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message, {\n status: 401,\n // Default to the generic \"invalid API key\" code, but let callers pass\n // through the server-reported code (e.g. `UR_05` for unverified-email\n // 401s) so they can differentiate between auth failure reasons.\n code: options?.code || 'AUTH_01',\n type: options?.type || 'authentication_error',\n requestId: options?.requestId,\n rawBody: options?.rawBody,\n data: options?.data,\n });\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayAuthenticationError';\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-I2XGNALG.cjs","../src/resources/forex.ts"],"names":[],"mappings":"AAAA;ACEO,IAAM,MAAA,EAAN,MAAY;AAAA,EACjB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,cAAA,EAAgB,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC9D;AAAA;AAAA,EAGA,MAAM,gBAAA,CACJ,MAAA,EACkC;AAClC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,2BAAA,EAA6B,EAAE,KAAA,EAAO,OAAO,CAAC,CAAA;AAAA,EAC3E;AACF,CAAA;ADJA;AACA;AACE;AACF,sBAAC","file":"/tmp/w2-sdk-publish-0482/dist/chunk-I2XGNALG.cjs","sourcesContent":[null,"import type { RequestFn } from '../client';\n\nexport class Forex {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve forex rates. `GET /forex/rates` */\n async getRates(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/rates', { query: params });\n }\n\n /** Convert from minor currency. `GET /forex/convert-from-minor` */\n async convertFromMinor(\n params: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/convert-from-minor', { query: params });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-IGHAJNC6.cjs","../src/resources/shopify.ts"],"names":[],"mappings":"AAAA;AC0BO,IAAM,QAAA,EAAN,MAAc;AAAA,EACnB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,MAAM,kBAAA,CACJ,SAAA,EACA,OAAA,EACoC;AACpC,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,qBAAA,EAAwB,kBAAA,CAAmB,SAAS,CAAC,CAAA,CAAA;AAClF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBmC,EAAA;AAC+C,IAAA;AAC3E,MAAA;AACG,MAAA;AACP,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc8B,EAAA;AACqD,IAAA;AAC5E,MAAA;AACG,MAAA;AACP,IAAA;AACH,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ4E,EAAA;AACD,IAAA;AAC3E,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBsC,EAAA;AACxB,IAAA;AACV,MAAA;AACqD,MAAA;AACrD,MAAA;AACK,QAAA;AACe,QAAA;AACpB,MAAA;AACF,IAAA;AACF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc6B,EAAA;AACf,IAAA;AACV,MAAA;AACqE,MAAA;AACrE,MAAA;AACF,IAAA;AACF,EAAA;AACF;AD/CqF;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-IGHAJNC6.cjs","sourcesContent":[null,"import type {\n ShopifyConnectRequest,\n ShopifyConnectResponse,\n ShopifyConnection,\n ShopifyConnectionResponse,\n ShopifySettingsUpdate,\n ShopifySyncEvent,\n ShopifySyncEventsQuery,\n ShopifySyncEventsResponse,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * A shop's link to the merchant's Shopify store: the merchant creates an app\n * in their own Shopify account, saves its keys here, approves it in Shopify,\n * and the storefront script sends the store's buyers to this shop's hosted\n * checkout. Every route names the shop by its profile id.\n *\n * Reading the connection, the sync log and its retry take an API key or a\n * dashboard session; a session needs the shop's Read permission to read and\n * its Write to retry. Connecting, changing the settings and disconnecting take\n * a signed-in dashboard session only, never an API key, with the shop's Write\n * permission. A key or role pinned to another shop, or a checkout template's\n * profile, is refused as unknown (404). No answer carries the app's client\n * secret or the store's access token.\n */\nexport class Shopify {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * The shop's connection, if any, with the storefront's last reports, and\n * what the merchant's app must list (redirect URL, access scopes). Takes an\n * API key or a dashboard session with the shop's Read permission; a server\n * that predates API-key access refuses a key with 401. Read-only: never\n * returns a secret or a token.\n *\n * `GET /shopify/connections/{profileId}`\n */\n async retrieveConnection(\n profileId: string,\n options?: RequestExtras,\n ): Promise<ShopifyConnectionResponse> {\n return this.request('GET', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * Save the app's keys and get the Shopify page the merchant approves the app\n * on. Refused while the shop is connected (412), except to approve again in\n * place: when the connection's `authorization_expired` is `true`, saving the\n * same store's keys for the same app (same `shop_domain` and `client_id`)\n * starts a new approval while the store stays connected with its settings\n * and script. Saving the keys renews nothing by itself: the merchant must\n * open the returned `authorize_url` and approve the app again, so neither a\n * successful call nor the `connected` status proves the approval is done;\n * `authorization_expired` turns `false` once it is. Refused when the store\n * is connected to another shop (409).\n *\n * `PUT /shopify/connections/{profileId}`\n */\n async connect(\n profileId: string,\n params: ShopifyConnectRequest,\n options?: RequestExtras,\n ): Promise<ShopifyConnectResponse> {\n return this.request('PUT', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Change the storefront settings: the takeover switch, the mode, the\n * appearance, the accepted terms. Switching the takeover on needs an\n * approved connection, and in `skip_checkout` mode the accepted terms\n * (412 otherwise).\n *\n * `PATCH /shopify/connections/{profileId}`\n */\n async updateSettings(\n profileId: string,\n params: ShopifySettingsUpdate,\n options?: RequestExtras,\n ): Promise<ShopifyConnection> {\n return this.request('PATCH', `/shopify/connections/${encodeURIComponent(profileId)}`, {\n ...options,\n body: params,\n });\n }\n\n /**\n * Disconnect the store. Buyers go back to Shopify checkout at once, and the\n * stored keys are wiped.\n *\n * `DELETE /shopify/connections/{profileId}`\n */\n async disconnect(profileId: string, options?: RequestExtras): Promise<void> {\n return this.request('DELETE', `/shopify/connections/${encodeURIComponent(profileId)}`, options);\n }\n\n /**\n * The shop's recent syncs with its store, newest first: the order of each\n * paid storefront payment, refunds in both directions, dispute flags and\n * webhook registrations. A `held` or `failed` entry was told to the\n * merchant; a `pending` one with a `reason` is retrying by itself. For the\n * next page, pass the answer's `next_cursor` as `cursor` with the same\n * filters; it is set on every full page and absent on a short one. Never\n * page by the oldest `created_at` as `before`: that skips entries sharing\n * its time.\n *\n * `GET /shopify/connections/{profileId}/sync_events`\n */\n async listSyncEvents(\n profileId: string,\n query?: ShopifySyncEventsQuery,\n options?: RequestExtras,\n ): Promise<ShopifySyncEventsResponse> {\n return this.request(\n 'GET',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events`,\n {\n ...options,\n query: { ...query },\n },\n );\n }\n\n /**\n * Run a failed, held or waiting sync again within a minute, as a first\n * attempt would: a held order whose total still differs from what was paid\n * is held again. Never makes a second order or a second refund. An entry\n * that cannot be retried answers 404.\n *\n * `POST /shopify/connections/{profileId}/sync_events/{eventId}/retry`\n */\n async retrySyncEvent(\n profileId: string,\n eventId: string,\n options?: RequestExtras,\n ): Promise<ShopifySyncEvent> {\n return this.request(\n 'POST',\n `/shopify/connections/${encodeURIComponent(profileId)}/sync_events/${encodeURIComponent(eventId)}/retry`,\n options,\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/tmp/
|
|
1
|
+
{"version":3,"sources":["/tmp/w2-sdk-publish-0482/dist/chunk-IKXGA2Z5.cjs","../src/resources/featureMatrix.ts"],"names":[],"mappings":"AAAA;ACOO,IAAM,cAAA,EAAN,MAAoB;AAAA,EACzB,WAAA,CAA6B,OAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,QAAA,EAAA,OAAA;AAAA,EAAqB;AAAA;AAAA,EAGlD,MAAM,QAAA,CAAA,EAA2C;AAC/C,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,iBAAiB,CAAA;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,mBAAA,CAAoB,UAAA,EAAoD;AAC5E,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,CAAA,gBAAA,EAAmB,kBAAA,CAAmB,UAAU,CAAC,CAAA,CAAA;AAC9E,EAAA;AACF;ADLiF;AACA;AACA;AACA","file":"/tmp/w2-sdk-publish-0482/dist/chunk-IKXGA2Z5.cjs","sourcesContent":[null,"import type { FeatureMatrixResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * What each connector can do: payment methods, capture methods, webhook\n * flows, and whether an unverified webhook is acted on.\n */\nexport class FeatureMatrix {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve the feature matrix. `GET /feature-matrix` */\n async retrieve(): Promise<FeatureMatrixResponse> {\n return this.request('GET', '/feature-matrix');\n }\n\n /**\n * Retrieve the feature matrix scoped to a merchant. Beta connectors\n * are filtered against the merchant's allowlist so the dashboard only\n * surfaces connectors the merchant can actually attach.\n * `GET /feature-matrix/{merchantId}`\n */\n async retrieveForMerchant(merchantId: string): Promise<FeatureMatrixResponse> {\n return this.request('GET', `/feature-matrix/${encodeURIComponent(merchantId)}`);\n }\n}\n"]}
|