@venturekit/billing 0.0.0-dev.20260825184900

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.
Files changed (66) hide show
  1. package/README.md +218 -0
  2. package/dist/client.d.ts +109 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +139 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/errors.d.ts +102 -0
  7. package/dist/errors.d.ts.map +1 -0
  8. package/dist/errors.js +133 -0
  9. package/dist/errors.js.map +1 -0
  10. package/dist/events.d.ts +170 -0
  11. package/dist/events.d.ts.map +1 -0
  12. package/dist/events.js +47 -0
  13. package/dist/events.js.map +1 -0
  14. package/dist/index.d.ts +48 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +52 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/provider.d.ts +178 -0
  19. package/dist/provider.d.ts.map +1 -0
  20. package/dist/provider.js +93 -0
  21. package/dist/provider.js.map +1 -0
  22. package/dist/providers/index.d.ts +15 -0
  23. package/dist/providers/index.d.ts.map +1 -0
  24. package/dist/providers/index.js +15 -0
  25. package/dist/providers/index.js.map +1 -0
  26. package/dist/providers/mock.d.ts +79 -0
  27. package/dist/providers/mock.d.ts.map +1 -0
  28. package/dist/providers/mock.js +536 -0
  29. package/dist/providers/mock.js.map +1 -0
  30. package/dist/providers/zazu/adapter.d.ts +39 -0
  31. package/dist/providers/zazu/adapter.d.ts.map +1 -0
  32. package/dist/providers/zazu/adapter.js +233 -0
  33. package/dist/providers/zazu/adapter.js.map +1 -0
  34. package/dist/providers/zazu/client.d.ts +76 -0
  35. package/dist/providers/zazu/client.d.ts.map +1 -0
  36. package/dist/providers/zazu/client.js +163 -0
  37. package/dist/providers/zazu/client.js.map +1 -0
  38. package/dist/providers/zazu/config.d.ts +54 -0
  39. package/dist/providers/zazu/config.d.ts.map +1 -0
  40. package/dist/providers/zazu/config.js +55 -0
  41. package/dist/providers/zazu/config.js.map +1 -0
  42. package/dist/providers/zazu/correlation.d.ts +65 -0
  43. package/dist/providers/zazu/correlation.d.ts.map +1 -0
  44. package/dist/providers/zazu/correlation.js +178 -0
  45. package/dist/providers/zazu/correlation.js.map +1 -0
  46. package/dist/providers/zazu/index.d.ts +18 -0
  47. package/dist/providers/zazu/index.d.ts.map +1 -0
  48. package/dist/providers/zazu/index.js +21 -0
  49. package/dist/providers/zazu/index.js.map +1 -0
  50. package/dist/providers/zazu/maps.d.ts +36 -0
  51. package/dist/providers/zazu/maps.d.ts.map +1 -0
  52. package/dist/providers/zazu/maps.js +450 -0
  53. package/dist/providers/zazu/maps.js.map +1 -0
  54. package/dist/providers/zazu/types.d.ts +365 -0
  55. package/dist/providers/zazu/types.d.ts.map +1 -0
  56. package/dist/providers/zazu/types.js +13 -0
  57. package/dist/providers/zazu/types.js.map +1 -0
  58. package/dist/providers/zazu/webhooks.d.ts +73 -0
  59. package/dist/providers/zazu/webhooks.d.ts.map +1 -0
  60. package/dist/providers/zazu/webhooks.js +259 -0
  61. package/dist/providers/zazu/webhooks.js.map +1 -0
  62. package/dist/types.d.ts +512 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +16 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +66 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @venturekit/billing — Zazu correlation transport
3
+ *
4
+ * Zazu carries the caller's identifiers on three different channels, one
5
+ * per flow. This module is the single place that knows which is which,
6
+ * so the adapter and the webhook parser cannot disagree:
7
+ *
8
+ * | Flow | Channel | Metadata |
9
+ * | ---------------- | ------------------------------------ | -------- |
10
+ * | checkout session | `metadata` map in the create body | yes |
11
+ * | payment link | `client_reference_id` URL query param | no |
12
+ * | transfer | `payment_reference` in the body | no |
13
+ *
14
+ * The asymmetry is Zazu's, not ours. Payment links accept only four
15
+ * whitelisted query parameters (`client_reference_id`, `customer_email`,
16
+ * `customer_id`, `customer_name`) and **silently ignore** everything
17
+ * else, so passing metadata there would vanish without an error. We
18
+ * reject it up front instead.
19
+ */
20
+ import type { CorrelationFlow, CorrelationRef, CorrelationSupport } from '../../types.js';
21
+ /**
22
+ * Metadata key holding the caller's reference on the checkout-session
23
+ * flow. Prefixed to avoid colliding with an application's own keys; a
24
+ * collision is rejected rather than silently overwritten.
25
+ */
26
+ export declare const CORRELATION_REFERENCE_KEY = "vk_reference";
27
+ export declare const ZAZU_CORRELATION_SUPPORT: Record<CorrelationFlow, CorrelationSupport>;
28
+ export declare function zazuCorrelationSupport(flow: CorrelationFlow): CorrelationSupport;
29
+ /**
30
+ * Build the `metadata` map for `POST /api/checkout_sessions`, folding the
31
+ * caller's reference in under {@link CORRELATION_REFERENCE_KEY}.
32
+ */
33
+ export declare function encodeCheckoutCorrelation(correlation: CorrelationRef | undefined): Record<string, string> | undefined;
34
+ /**
35
+ * Recover the caller's correlation from a checkout session's metadata.
36
+ * Returns `null` when the reference key is absent — either no
37
+ * correlation was supplied, or the session predates this mechanism.
38
+ */
39
+ export declare function decodeCheckoutCorrelation(metadata: Record<string, string> | null | undefined): CorrelationRef | null;
40
+ /**
41
+ * Attach the caller's reference to a payment link's hosted URL.
42
+ *
43
+ * Zazu stores whitelisted query parameters with the payment and echoes
44
+ * them on `payment_link.paid`, so the correlation lives on the URL rather
45
+ * than in the create body. The customer must therefore be sent to the
46
+ * URL this returns.
47
+ */
48
+ export declare function attachPaymentLinkCorrelation(url: string | undefined, correlation: CorrelationRef | undefined): string | undefined;
49
+ /**
50
+ * Recover correlation from a `payment_link.paid` payload, whose
51
+ * `client_reference_id` is documented as always present and `null` when
52
+ * the payer was not identified.
53
+ */
54
+ export declare function decodePaymentLinkCorrelation(clientReferenceId: string | null | undefined): CorrelationRef | null;
55
+ /**
56
+ * Resolve the `payment_reference` to send for a transfer.
57
+ *
58
+ * Zazu echoes only `payment_reference` on `transfer.executed`, so
59
+ * correlation and the business reference compete for one field. Setting
60
+ * both is rejected rather than silently preferring one.
61
+ */
62
+ export declare function encodeTransferCorrelation(paymentReference: string | undefined, correlation: CorrelationRef | undefined): string | undefined;
63
+ /** Recover correlation from a `transfer.executed` payload. */
64
+ export declare function decodeTransferCorrelation(paymentReference: string | null | undefined): CorrelationRef | null;
65
+ //# sourceMappingURL=correlation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlation.d.ts","sourceRoot":"","sources":["../../../src/providers/zazu/correlation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAUxD,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAIhF,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAIhF;AAmCD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,cAAc,GAAG,SAAS,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAqBpC;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD,cAAc,GAAG,IAAI,CAUvB;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,WAAW,EAAE,cAAc,GAAG,SAAS,GACtC,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,cAAc,GAAG,IAAI,CAGvB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,WAAW,EAAE,cAAc,GAAG,SAAS,GACtC,MAAM,GAAG,SAAS,CAapB;AAED,8DAA8D;AAC9D,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC1C,cAAc,GAAG,IAAI,CAGvB"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * @venturekit/billing — Zazu correlation transport
3
+ *
4
+ * Zazu carries the caller's identifiers on three different channels, one
5
+ * per flow. This module is the single place that knows which is which,
6
+ * so the adapter and the webhook parser cannot disagree:
7
+ *
8
+ * | Flow | Channel | Metadata |
9
+ * | ---------------- | ------------------------------------ | -------- |
10
+ * | checkout session | `metadata` map in the create body | yes |
11
+ * | payment link | `client_reference_id` URL query param | no |
12
+ * | transfer | `payment_reference` in the body | no |
13
+ *
14
+ * The asymmetry is Zazu's, not ours. Payment links accept only four
15
+ * whitelisted query parameters (`client_reference_id`, `customer_email`,
16
+ * `customer_id`, `customer_name`) and **silently ignore** everything
17
+ * else, so passing metadata there would vanish without an error. We
18
+ * reject it up front instead.
19
+ */
20
+ import { URL } from 'node:url';
21
+ import { InvalidCorrelationError, UnsupportedCorrelationError, } from '../../errors.js';
22
+ /**
23
+ * Metadata key holding the caller's reference on the checkout-session
24
+ * flow. Prefixed to avoid colliding with an application's own keys; a
25
+ * collision is rejected rather than silently overwritten.
26
+ */
27
+ export const CORRELATION_REFERENCE_KEY = 'vk_reference';
28
+ /** Documented Zazu metadata limits (checkout sessions). */
29
+ const MAX_METADATA_KEYS = 50;
30
+ const MAX_VALUE_LENGTH = 500;
31
+ const KEY_PATTERN = /^[A-Za-z0-9_]+$/;
32
+ /** Query parameter Zazu echoes as a top-level `payment_link.paid` field. */
33
+ const CLIENT_REFERENCE_PARAM = 'client_reference_id';
34
+ export const ZAZU_CORRELATION_SUPPORT = {
35
+ checkoutSession: { reference: true, metadata: true, channel: 'metadata' },
36
+ paymentLink: { reference: true, metadata: false, channel: 'urlQuery' },
37
+ transfer: { reference: true, metadata: false, channel: 'paymentReference' },
38
+ };
39
+ export function zazuCorrelationSupport(flow) {
40
+ return (ZAZU_CORRELATION_SUPPORT[flow] ?? { reference: false, metadata: false, channel: 'none' });
41
+ }
42
+ /**
43
+ * Validate a metadata map against Zazu's documented limits. Runs locally
44
+ * so a violation names the offending key instead of arriving as an opaque
45
+ * 422 after the request.
46
+ */
47
+ function assertValidMetadata(metadata, budget) {
48
+ const keys = Object.keys(metadata);
49
+ if (keys.length > budget) {
50
+ throw new InvalidCorrelationError(`Zazu accepts at most ${MAX_METADATA_KEYS} metadata keys; received ${keys.length} ` +
51
+ `with ${MAX_METADATA_KEYS - budget} reserved for the correlation reference.`);
52
+ }
53
+ for (const key of keys) {
54
+ if (!KEY_PATTERN.test(key)) {
55
+ throw new InvalidCorrelationError(`Invalid Zazu metadata key "${key}": only letters, numbers, and underscores are allowed.`);
56
+ }
57
+ const value = metadata[key];
58
+ if (typeof value !== 'string') {
59
+ throw new InvalidCorrelationError(`Zazu metadata value for "${key}" must be a string.`);
60
+ }
61
+ if (value.length > MAX_VALUE_LENGTH) {
62
+ throw new InvalidCorrelationError(`Zazu metadata value for "${key}" is ${value.length} characters; the limit is ${MAX_VALUE_LENGTH}.`);
63
+ }
64
+ }
65
+ }
66
+ /**
67
+ * Build the `metadata` map for `POST /api/checkout_sessions`, folding the
68
+ * caller's reference in under {@link CORRELATION_REFERENCE_KEY}.
69
+ */
70
+ export function encodeCheckoutCorrelation(correlation) {
71
+ if (!correlation)
72
+ return undefined;
73
+ const extra = correlation.metadata ?? {};
74
+ if (Object.prototype.hasOwnProperty.call(extra, CORRELATION_REFERENCE_KEY)) {
75
+ throw new InvalidCorrelationError(`Metadata key "${CORRELATION_REFERENCE_KEY}" is reserved for the correlation ` +
76
+ 'reference. Rename it to avoid losing one of the two values.');
77
+ }
78
+ if (correlation.reference.length > MAX_VALUE_LENGTH) {
79
+ throw new InvalidCorrelationError(`Correlation reference is ${correlation.reference.length} characters; Zazu stores it ` +
80
+ `as a metadata value, limited to ${MAX_VALUE_LENGTH}.`);
81
+ }
82
+ // One key is spent on the reference, so the caller's budget is 49.
83
+ assertValidMetadata(extra, MAX_METADATA_KEYS - 1);
84
+ return { ...extra, [CORRELATION_REFERENCE_KEY]: correlation.reference };
85
+ }
86
+ /**
87
+ * Recover the caller's correlation from a checkout session's metadata.
88
+ * Returns `null` when the reference key is absent — either no
89
+ * correlation was supplied, or the session predates this mechanism.
90
+ */
91
+ export function decodeCheckoutCorrelation(metadata) {
92
+ if (!metadata)
93
+ return null;
94
+ const reference = metadata[CORRELATION_REFERENCE_KEY];
95
+ if (typeof reference !== 'string' || reference === '')
96
+ return null;
97
+ const rest = {};
98
+ for (const [key, value] of Object.entries(metadata)) {
99
+ if (key !== CORRELATION_REFERENCE_KEY)
100
+ rest[key] = value;
101
+ }
102
+ return Object.keys(rest).length > 0 ? { reference, metadata: rest } : { reference };
103
+ }
104
+ /**
105
+ * Attach the caller's reference to a payment link's hosted URL.
106
+ *
107
+ * Zazu stores whitelisted query parameters with the payment and echoes
108
+ * them on `payment_link.paid`, so the correlation lives on the URL rather
109
+ * than in the create body. The customer must therefore be sent to the
110
+ * URL this returns.
111
+ */
112
+ export function attachPaymentLinkCorrelation(url, correlation) {
113
+ if (!correlation)
114
+ return url;
115
+ assertNoMetadata('paymentLink', correlation);
116
+ if (!url) {
117
+ throw new InvalidCorrelationError('Zazu returned a payment link without a URL, so the correlation reference could ' +
118
+ 'not be attached. Refusing to return a link that would lose it.');
119
+ }
120
+ try {
121
+ const parsed = new URL(url);
122
+ parsed.searchParams.set(CLIENT_REFERENCE_PARAM, correlation.reference);
123
+ return parsed.toString();
124
+ }
125
+ catch {
126
+ throw new InvalidCorrelationError(`Zazu returned an unparseable payment link URL ("${url}"), so the correlation ` +
127
+ 'reference could not be attached.');
128
+ }
129
+ }
130
+ /**
131
+ * Recover correlation from a `payment_link.paid` payload, whose
132
+ * `client_reference_id` is documented as always present and `null` when
133
+ * the payer was not identified.
134
+ */
135
+ export function decodePaymentLinkCorrelation(clientReferenceId) {
136
+ if (typeof clientReferenceId !== 'string' || clientReferenceId === '')
137
+ return null;
138
+ return { reference: clientReferenceId };
139
+ }
140
+ /**
141
+ * Resolve the `payment_reference` to send for a transfer.
142
+ *
143
+ * Zazu echoes only `payment_reference` on `transfer.executed`, so
144
+ * correlation and the business reference compete for one field. Setting
145
+ * both is rejected rather than silently preferring one.
146
+ */
147
+ export function encodeTransferCorrelation(paymentReference, correlation) {
148
+ if (!correlation)
149
+ return paymentReference;
150
+ assertNoMetadata('transfer', correlation);
151
+ if (paymentReference !== undefined && paymentReference !== correlation.reference) {
152
+ throw new UnsupportedCorrelationError('transfer', 'Zazu echoes only `payment_reference` on transfer.executed, so `paymentReference` ' +
153
+ 'and `correlation.reference` cannot both be set. Use `correlation.reference` — ' +
154
+ 'it travels on the same field and is returned on the event.');
155
+ }
156
+ return correlation.reference;
157
+ }
158
+ /** Recover correlation from a `transfer.executed` payload. */
159
+ export function decodeTransferCorrelation(paymentReference) {
160
+ if (typeof paymentReference !== 'string' || paymentReference === '')
161
+ return null;
162
+ return { reference: paymentReference };
163
+ }
164
+ /**
165
+ * Reject metadata on the flows whose channel is a single string. Zazu
166
+ * drops unknown fields without erroring, so this must fail before the
167
+ * request rather than at webhook time.
168
+ */
169
+ function assertNoMetadata(flow, correlation) {
170
+ const metadata = correlation.metadata;
171
+ if (metadata && Object.keys(metadata).length > 0) {
172
+ const support = zazuCorrelationSupport(flow);
173
+ throw new UnsupportedCorrelationError(flow, `Zazu carries this flow's correlation via ${support.channel}, which holds a single ` +
174
+ 'value, so `correlation.metadata` cannot be round-tripped. Store the extra ' +
175
+ 'fields against `correlation.reference` in your own record instead.');
176
+ }
177
+ }
178
+ //# sourceMappingURL=correlation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlation.js","sourceRoot":"","sources":["../../../src/providers/zazu/correlation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,UAA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AAC,CAAC;QAC7C,MAAM,IAAI,2BAA2B,CACnC,IAAI,EACJ,4CAA4C,OAAO,CAAC,OAAO,yBAAyB;YAClF,4EAA4E;YAC5E,oEAAoE,CACvE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @venturekit/billing — Zazu provider barrel
3
+ *
4
+ * Re-exports the Zazu adapter, HTTP client, webhook helpers, config
5
+ * resolver, and raw types so consumers can import either via the package
6
+ * barrel or the `@venturekit/billing/providers/zazu` subpath (mirrors
7
+ * the `@venturekit/notify/providers/*` layout).
8
+ *
9
+ * Importing this module self-registers the provider under the name
10
+ * `'zazu'` so it becomes available to `createProvider('zazu', …)` and
11
+ * the env-based client helpers.
12
+ */
13
+ export { createZazuAdapter, type ZazuAdapter } from './adapter.js';
14
+ export { createZazuHttpClient, type ZazuHttpClient } from './client.js';
15
+ export { resolveZazuConfig, type ZazuConfig } from './config.js';
16
+ export { verifyZazuSignature, parseZazuWebhook, handleZazuWebhook, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type HandleZazuWebhookOptions, } from './webhooks.js';
17
+ export * from './types.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/zazu/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iCAAiC,EACjC,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC;AACvB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @venturekit/billing — Zazu provider barrel
3
+ *
4
+ * Re-exports the Zazu adapter, HTTP client, webhook helpers, config
5
+ * resolver, and raw types so consumers can import either via the package
6
+ * barrel or the `@venturekit/billing/providers/zazu` subpath (mirrors
7
+ * the `@venturekit/notify/providers/*` layout).
8
+ *
9
+ * Importing this module self-registers the provider under the name
10
+ * `'zazu'` so it becomes available to `createProvider('zazu', …)` and
11
+ * the env-based client helpers.
12
+ */
13
+ import { registerProvider } from '../../provider.js';
14
+ import { createZazuAdapter } from './adapter.js';
15
+ registerProvider('zazu', (cfg) => createZazuAdapter(cfg));
16
+ export { createZazuAdapter } from './adapter.js';
17
+ export { createZazuHttpClient } from './client.js';
18
+ export { resolveZazuConfig } from './config.js';
19
+ export { verifyZazuSignature, parseZazuWebhook, handleZazuWebhook, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, } from './webhooks.js';
20
+ export * from './types.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/zazu/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,gBAAgB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAsC,CAAC,CAAC,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAuB,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAmB,MAAM,aAAa,CAAC;AACjE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iCAAiC,GAElC,MAAM,eAAe,CAAC;AACvB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @venturekit/billing — Zazu ↔ domain mappers
3
+ *
4
+ * The single boundary between Zazu's wire format (`./types.ts`) and the
5
+ * provider-agnostic domain types (`../../types.ts`). Every adapter
6
+ * method calls into here to convert a response or build a request body.
7
+ * If the Zazu API changes, only this file needs updating.
8
+ */
9
+ import type { Account, AccountTransaction, CheckoutSession, CheckoutTransaction, CreateCheckoutSessionInput, CreateCustomerInput, CreateInvoiceInput, CreatePaymentLinkInput, CreateTransferInput, CreateWebhookEndpointInput, Customer, Invoice, Money, PaymentLink, Transfer, UpdateCustomerInput, UpdateWebhookEndpointInput, WebhookEndpoint, WebhookEndpointWithSecret } from '../../types.js';
10
+ import type { ZazuAccount, ZazuAccountTransaction, ZazuCheckoutSession, ZazuCreateCheckoutSessionBody, ZazuCreateCustomerBody, ZazuCreateInvoiceBody, ZazuCreatePaymentLinkBody, ZazuCreateTransferBody, ZazuCreateWebhookEndpointBody, ZazuCustomer, ZazuInvoice, ZazuPaymentLink, ZazuTransfer, ZazuUpdateWebhookEndpointBody, ZazuWebhookEndpoint, ZazuWebhookEndpointWithSecret } from './types.js';
11
+ export declare function money(amount: string, currency: string): Money;
12
+ export declare function nullToUndefined<T>(v: T | null | undefined): T | undefined;
13
+ export declare function mapCheckoutSession(raw: ZazuCheckoutSession): CheckoutSession;
14
+ export declare function mapCheckoutTransaction(raw: NonNullable<ZazuCheckoutSession['transaction']>): CheckoutTransaction;
15
+ export declare function mapCreateCheckoutSessionBody(input: CreateCheckoutSessionInput & {
16
+ accountId: string;
17
+ }): ZazuCreateCheckoutSessionBody;
18
+ export declare function mapPaymentLink(raw: ZazuPaymentLink): PaymentLink;
19
+ export declare function mapCreatePaymentLinkBody(input: CreatePaymentLinkInput & {
20
+ accountId: string;
21
+ }): ZazuCreatePaymentLinkBody;
22
+ export declare function mapCustomer(raw: ZazuCustomer): Customer;
23
+ export declare function mapInvoice(raw: ZazuInvoice): Invoice;
24
+ export declare function mapCreateInvoiceBody(input: CreateInvoiceInput): ZazuCreateInvoiceBody;
25
+ export declare function mapTransfer(raw: ZazuTransfer): Transfer;
26
+ export declare function mapCreateTransferBody(input: CreateTransferInput & {
27
+ accountId: string;
28
+ }): ZazuCreateTransferBody;
29
+ export declare function mapCreateCustomerBody(input: CreateCustomerInput | UpdateCustomerInput): ZazuCreateCustomerBody;
30
+ export declare function mapAccount(raw: ZazuAccount): Account;
31
+ export declare function mapAccountTransaction(raw: ZazuAccountTransaction): AccountTransaction;
32
+ export declare function mapWebhookEndpoint(raw: ZazuWebhookEndpoint): WebhookEndpoint;
33
+ export declare function mapWebhookEndpointWithSecret(raw: ZazuWebhookEndpointWithSecret): WebhookEndpointWithSecret;
34
+ export declare function mapCreateWebhookEndpointBody(input: CreateWebhookEndpointInput): ZazuCreateWebhookEndpointBody;
35
+ export declare function mapUpdateWebhookEndpointBody(input: UpdateWebhookEndpointInput): ZazuUpdateWebhookEndpointBody;
36
+ //# sourceMappingURL=maps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../src/providers/zazu/maps.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,OAAO,KAAK,EACV,OAAO,EAEP,kBAAkB,EAClB,eAAe,EAEf,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,QAAQ,EACR,OAAO,EAGP,KAAK,EACL,WAAW,EAGX,QAAQ,EAER,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EAEf,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,WAAW,EACX,sBAAsB,EAEtB,mBAAmB,EACnB,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,EAGrB,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAC7B,YAAY,EACZ,WAAW,EAGX,eAAe,EACf,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,EACnB,6BAA6B,EAC9B,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