@b3dotfun/sdk 0.1.68-alpha.3 → 0.1.68-alpha.4

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 (109) hide show
  1. package/dist/cjs/anyspend/platform/client.d.ts +35 -0
  2. package/dist/cjs/anyspend/platform/client.js +158 -0
  3. package/dist/cjs/anyspend/platform/errors.d.ts +38 -0
  4. package/dist/cjs/anyspend/platform/errors.js +77 -0
  5. package/dist/cjs/anyspend/platform/index.d.ts +87 -0
  6. package/dist/cjs/anyspend/platform/index.js +85 -0
  7. package/dist/cjs/anyspend/platform/resources/analytics.d.ts +7 -0
  8. package/dist/cjs/anyspend/platform/resources/analytics.js +12 -0
  9. package/dist/cjs/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  10. package/dist/cjs/anyspend/platform/resources/checkout-sessions.js +27 -0
  11. package/dist/cjs/anyspend/platform/resources/customers.d.ts +19 -0
  12. package/dist/cjs/anyspend/platform/resources/customers.js +34 -0
  13. package/dist/cjs/anyspend/platform/resources/discount-codes.d.ts +29 -0
  14. package/dist/cjs/anyspend/platform/resources/discount-codes.js +31 -0
  15. package/dist/cjs/anyspend/platform/resources/events.d.ts +14 -0
  16. package/dist/cjs/anyspend/platform/resources/events.js +16 -0
  17. package/dist/cjs/anyspend/platform/resources/notifications.d.ts +18 -0
  18. package/dist/cjs/anyspend/platform/resources/notifications.js +27 -0
  19. package/dist/cjs/anyspend/platform/resources/organization.d.ts +17 -0
  20. package/dist/cjs/anyspend/platform/resources/organization.js +15 -0
  21. package/dist/cjs/anyspend/platform/resources/payment-links.d.ts +21 -0
  22. package/dist/cjs/anyspend/platform/resources/payment-links.js +49 -0
  23. package/dist/cjs/anyspend/platform/resources/products.d.ts +27 -0
  24. package/dist/cjs/anyspend/platform/resources/products.js +31 -0
  25. package/dist/cjs/anyspend/platform/resources/transactions.d.ts +11 -0
  26. package/dist/cjs/anyspend/platform/resources/transactions.js +25 -0
  27. package/dist/cjs/anyspend/platform/resources/webhooks.d.ts +14 -0
  28. package/dist/cjs/anyspend/platform/resources/webhooks.js +33 -0
  29. package/dist/cjs/anyspend/platform/resources/widgets.d.ts +38 -0
  30. package/dist/cjs/anyspend/platform/resources/widgets.js +31 -0
  31. package/dist/cjs/anyspend/platform/types.d.ts +478 -0
  32. package/dist/cjs/anyspend/platform/types.js +5 -0
  33. package/dist/cjs/anyspend/platform/utils/idempotency.d.ts +4 -0
  34. package/dist/cjs/anyspend/platform/utils/idempotency.js +17 -0
  35. package/dist/cjs/anyspend/platform/utils/pagination.d.ts +12 -0
  36. package/dist/cjs/anyspend/platform/utils/pagination.js +22 -0
  37. package/dist/esm/anyspend/platform/client.d.ts +35 -0
  38. package/dist/esm/anyspend/platform/client.js +153 -0
  39. package/dist/esm/anyspend/platform/errors.d.ts +38 -0
  40. package/dist/esm/anyspend/platform/errors.js +67 -0
  41. package/dist/esm/anyspend/platform/index.d.ts +87 -0
  42. package/dist/esm/anyspend/platform/index.js +75 -0
  43. package/dist/esm/anyspend/platform/resources/analytics.d.ts +7 -0
  44. package/dist/esm/anyspend/platform/resources/analytics.js +8 -0
  45. package/dist/esm/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  46. package/dist/esm/anyspend/platform/resources/checkout-sessions.js +23 -0
  47. package/dist/esm/anyspend/platform/resources/customers.d.ts +19 -0
  48. package/dist/esm/anyspend/platform/resources/customers.js +30 -0
  49. package/dist/esm/anyspend/platform/resources/discount-codes.d.ts +29 -0
  50. package/dist/esm/anyspend/platform/resources/discount-codes.js +27 -0
  51. package/dist/esm/anyspend/platform/resources/events.d.ts +14 -0
  52. package/dist/esm/anyspend/platform/resources/events.js +12 -0
  53. package/dist/esm/anyspend/platform/resources/notifications.d.ts +18 -0
  54. package/dist/esm/anyspend/platform/resources/notifications.js +23 -0
  55. package/dist/esm/anyspend/platform/resources/organization.d.ts +17 -0
  56. package/dist/esm/anyspend/platform/resources/organization.js +11 -0
  57. package/dist/esm/anyspend/platform/resources/payment-links.d.ts +21 -0
  58. package/dist/esm/anyspend/platform/resources/payment-links.js +45 -0
  59. package/dist/esm/anyspend/platform/resources/products.d.ts +27 -0
  60. package/dist/esm/anyspend/platform/resources/products.js +27 -0
  61. package/dist/esm/anyspend/platform/resources/transactions.d.ts +11 -0
  62. package/dist/esm/anyspend/platform/resources/transactions.js +21 -0
  63. package/dist/esm/anyspend/platform/resources/webhooks.d.ts +14 -0
  64. package/dist/esm/anyspend/platform/resources/webhooks.js +29 -0
  65. package/dist/esm/anyspend/platform/resources/widgets.d.ts +38 -0
  66. package/dist/esm/anyspend/platform/resources/widgets.js +27 -0
  67. package/dist/esm/anyspend/platform/types.d.ts +478 -0
  68. package/dist/esm/anyspend/platform/types.js +4 -0
  69. package/dist/esm/anyspend/platform/utils/idempotency.d.ts +4 -0
  70. package/dist/esm/anyspend/platform/utils/idempotency.js +14 -0
  71. package/dist/esm/anyspend/platform/utils/pagination.d.ts +12 -0
  72. package/dist/esm/anyspend/platform/utils/pagination.js +19 -0
  73. package/dist/types/anyspend/platform/client.d.ts +35 -0
  74. package/dist/types/anyspend/platform/errors.d.ts +38 -0
  75. package/dist/types/anyspend/platform/index.d.ts +87 -0
  76. package/dist/types/anyspend/platform/resources/analytics.d.ts +7 -0
  77. package/dist/types/anyspend/platform/resources/checkout-sessions.d.ts +17 -0
  78. package/dist/types/anyspend/platform/resources/customers.d.ts +19 -0
  79. package/dist/types/anyspend/platform/resources/discount-codes.d.ts +29 -0
  80. package/dist/types/anyspend/platform/resources/events.d.ts +14 -0
  81. package/dist/types/anyspend/platform/resources/notifications.d.ts +18 -0
  82. package/dist/types/anyspend/platform/resources/organization.d.ts +17 -0
  83. package/dist/types/anyspend/platform/resources/payment-links.d.ts +21 -0
  84. package/dist/types/anyspend/platform/resources/products.d.ts +27 -0
  85. package/dist/types/anyspend/platform/resources/transactions.d.ts +11 -0
  86. package/dist/types/anyspend/platform/resources/webhooks.d.ts +14 -0
  87. package/dist/types/anyspend/platform/resources/widgets.d.ts +38 -0
  88. package/dist/types/anyspend/platform/types.d.ts +478 -0
  89. package/dist/types/anyspend/platform/utils/idempotency.d.ts +4 -0
  90. package/dist/types/anyspend/platform/utils/pagination.d.ts +12 -0
  91. package/package.json +6 -1
  92. package/src/anyspend/platform/client.ts +198 -0
  93. package/src/anyspend/platform/errors.ts +92 -0
  94. package/src/anyspend/platform/index.ts +129 -0
  95. package/src/anyspend/platform/resources/analytics.ts +10 -0
  96. package/src/anyspend/platform/resources/checkout-sessions.ts +36 -0
  97. package/src/anyspend/platform/resources/customers.ts +54 -0
  98. package/src/anyspend/platform/resources/discount-codes.ts +63 -0
  99. package/src/anyspend/platform/resources/events.ts +22 -0
  100. package/src/anyspend/platform/resources/notifications.ts +37 -0
  101. package/src/anyspend/platform/resources/organization.ts +24 -0
  102. package/src/anyspend/platform/resources/payment-links.ts +74 -0
  103. package/src/anyspend/platform/resources/products.ts +59 -0
  104. package/src/anyspend/platform/resources/transactions.ts +33 -0
  105. package/src/anyspend/platform/resources/webhooks.ts +47 -0
  106. package/src/anyspend/platform/resources/widgets.ts +63 -0
  107. package/src/anyspend/platform/types.ts +532 -0
  108. package/src/anyspend/platform/utils/idempotency.ts +15 -0
  109. package/src/anyspend/platform/utils/pagination.ts +32 -0
@@ -0,0 +1,478 @@
1
+ /**
2
+ * TypeScript types for the AnySpend Platform API.
3
+ */
4
+ export interface ListResponse<T> {
5
+ object: "list";
6
+ data: T[];
7
+ has_more: boolean;
8
+ total_count: number;
9
+ url: string;
10
+ }
11
+ export interface DeletedResponse {
12
+ object: string;
13
+ id: string;
14
+ deleted: true;
15
+ }
16
+ export interface ActionResponse {
17
+ object: "action";
18
+ action: string;
19
+ [key: string]: unknown;
20
+ }
21
+ export interface PaginationParams {
22
+ page?: number;
23
+ limit?: number;
24
+ }
25
+ export interface PaymentLink {
26
+ object: "payment_link";
27
+ id: string;
28
+ short_code: string;
29
+ url?: string;
30
+ name: string;
31
+ description: string | null;
32
+ amount: string | null;
33
+ min_amount: string | null;
34
+ max_amount: string | null;
35
+ suggested_amount: string | null;
36
+ token_address: string;
37
+ chain_id: number;
38
+ recipient_address: string;
39
+ product_id: string | null;
40
+ image_url: string | null;
41
+ theme_color: string | null;
42
+ button_text: string;
43
+ max_uses: number | null;
44
+ current_uses: number;
45
+ expires_at: number | null;
46
+ is_active: boolean;
47
+ form_schema: string | null;
48
+ shipping_options: string | null;
49
+ collect_shipping_address: boolean;
50
+ return_url: string | null;
51
+ return_label: string | null;
52
+ branding: string | null;
53
+ fee_on_top: boolean;
54
+ items?: PaymentLinkItem[];
55
+ created_at: number;
56
+ updated_at: number;
57
+ }
58
+ export interface PaymentLinkItem {
59
+ object: "payment_link_item";
60
+ id: string;
61
+ payment_link_id: string;
62
+ product_id: string | null;
63
+ name: string;
64
+ description: string | null;
65
+ image_url: string | null;
66
+ amount: string;
67
+ quantity: number;
68
+ sort_order: number;
69
+ created_at: number;
70
+ updated_at: number;
71
+ }
72
+ export interface CreatePaymentLinkParams {
73
+ name: string;
74
+ token_address: string;
75
+ chain_id: number;
76
+ recipient_address: string;
77
+ description?: string;
78
+ amount?: string;
79
+ min_amount?: string;
80
+ max_amount?: string;
81
+ suggested_amount?: string;
82
+ product_id?: string;
83
+ image_url?: string;
84
+ theme_color?: string;
85
+ button_text?: string;
86
+ max_uses?: number;
87
+ expires_at?: number;
88
+ form_schema?: Record<string, unknown>;
89
+ shipping_options?: Record<string, unknown>[];
90
+ collect_shipping_address?: boolean;
91
+ return_url?: string;
92
+ return_label?: string;
93
+ branding?: Record<string, unknown>;
94
+ fee_on_top?: boolean;
95
+ items?: CreatePaymentLinkItemParams[];
96
+ }
97
+ export interface CreatePaymentLinkItemParams {
98
+ name: string;
99
+ amount: string;
100
+ description?: string;
101
+ image_url?: string;
102
+ quantity?: number;
103
+ sort_order?: number;
104
+ product_id?: string;
105
+ }
106
+ export interface UpdatePaymentLinkParams extends Partial<Omit<CreatePaymentLinkParams, "items">> {
107
+ is_active?: boolean;
108
+ items?: CreatePaymentLinkItemParams[];
109
+ }
110
+ export interface ListPaymentLinksParams extends PaginationParams {
111
+ search?: string;
112
+ active?: "true" | "false";
113
+ sort?: "created_at" | "updated_at" | "name" | "current_uses";
114
+ order?: "asc" | "desc";
115
+ }
116
+ export interface PaymentLinkStats {
117
+ object: "payment_link_stats";
118
+ payment_link_id: string;
119
+ summary: {
120
+ total_views: number;
121
+ total_sessions: number;
122
+ total_completions: number;
123
+ lifetime_completions: number;
124
+ view_to_session_rate: string;
125
+ session_to_completion_rate: string;
126
+ overall_conversion_rate: string;
127
+ };
128
+ daily: {
129
+ views: {
130
+ date: string;
131
+ view_count: number;
132
+ unique_visitors: number;
133
+ }[];
134
+ sessions: {
135
+ date: string;
136
+ sessions: number;
137
+ completions: number;
138
+ }[];
139
+ };
140
+ utm_breakdown: Record<string, unknown>[];
141
+ }
142
+ export interface Product {
143
+ object: "product";
144
+ id: string;
145
+ name: string;
146
+ description: string | null;
147
+ image_url: string | null;
148
+ amount: string;
149
+ token_address: string;
150
+ chain_id: number;
151
+ recipient_address: string | null;
152
+ product_type: "one_time" | "subscription" | "variable";
153
+ is_active: boolean;
154
+ metadata: Record<string, unknown> | null;
155
+ form_schema: string | null;
156
+ shipping_options: string | null;
157
+ created_at: number;
158
+ updated_at: number;
159
+ }
160
+ export interface CreateProductParams {
161
+ name: string;
162
+ amount: string;
163
+ token_address: string;
164
+ chain_id: number;
165
+ description?: string;
166
+ image_url?: string;
167
+ recipient_address?: string;
168
+ product_type?: "one_time" | "subscription" | "variable";
169
+ metadata?: Record<string, unknown>;
170
+ form_schema?: Record<string, unknown>;
171
+ shipping_options?: Record<string, unknown>[];
172
+ }
173
+ export interface UpdateProductParams extends Partial<CreateProductParams> {
174
+ is_active?: boolean;
175
+ }
176
+ export interface Customer {
177
+ object: "customer";
178
+ id: string;
179
+ wallet_address: string;
180
+ name: string | null;
181
+ email: string | null;
182
+ metadata: Record<string, unknown> | null;
183
+ total_paid: string | null;
184
+ transaction_count: number;
185
+ first_payment_at: number | null;
186
+ last_payment_at: number | null;
187
+ created_at: number;
188
+ updated_at: number;
189
+ }
190
+ export interface CreateCustomerParams {
191
+ wallet_address: string;
192
+ name?: string;
193
+ email?: string;
194
+ metadata?: Record<string, unknown>;
195
+ }
196
+ export interface UpdateCustomerParams {
197
+ name?: string;
198
+ email?: string;
199
+ metadata?: Record<string, unknown>;
200
+ }
201
+ export interface Transaction {
202
+ object: "transaction";
203
+ id: string;
204
+ tx_hash: string;
205
+ chain_id: number;
206
+ from_address: string;
207
+ to_address: string;
208
+ token_address: string;
209
+ amount: string;
210
+ amount_usd: string | null;
211
+ status: "pending" | "confirming" | "completed" | "failed";
212
+ payment_link_id: string | null;
213
+ customer_id: string | null;
214
+ created_at: number;
215
+ updated_at: number;
216
+ }
217
+ export interface TransactionStats {
218
+ object: "transaction_stats";
219
+ totalTransactions: number;
220
+ completedTransactions: number;
221
+ totalVolumeUsd: string;
222
+ last24h: {
223
+ transactions: number;
224
+ volumeUsd: string;
225
+ };
226
+ statusBreakdown: Record<string, number>;
227
+ }
228
+ export interface ListTransactionsParams extends PaginationParams {
229
+ status?: string;
230
+ customer_id?: string;
231
+ payment_link_id?: string;
232
+ from?: number;
233
+ to?: number;
234
+ }
235
+ export interface CheckoutSession {
236
+ object: "checkout_session";
237
+ id: string;
238
+ url: string | null;
239
+ status: "open" | "processing" | "completed" | "expired" | "failed";
240
+ payment_link_id: string | null;
241
+ product_id: string | null;
242
+ amount: string | null;
243
+ token_address: string;
244
+ chain_id: number;
245
+ recipient_address: string;
246
+ success_url: string | null;
247
+ cancel_url: string | null;
248
+ client_reference_id: string | null;
249
+ /** The API returns metadata as a serialized JSON string. Use JSON.parse() to recover the original object. */
250
+ metadata: string | null;
251
+ customer_email: string | null;
252
+ customer_name: string | null;
253
+ tx_hash: string | null;
254
+ completed_at: number | null;
255
+ expires_at: number;
256
+ created_at: number;
257
+ updated_at: number;
258
+ }
259
+ export interface CreateCheckoutSessionParams {
260
+ payment_link_id?: string;
261
+ token_address?: string;
262
+ chain_id?: number;
263
+ recipient_address?: string;
264
+ amount?: string;
265
+ product_id?: string;
266
+ success_url?: string;
267
+ cancel_url?: string;
268
+ client_reference_id?: string;
269
+ metadata?: Record<string, unknown>;
270
+ customer_email?: string;
271
+ customer_name?: string;
272
+ expires_in?: number;
273
+ utm_source?: string;
274
+ utm_medium?: string;
275
+ utm_campaign?: string;
276
+ }
277
+ export interface Webhook {
278
+ object: "webhook";
279
+ id: string;
280
+ url: string;
281
+ events: string[];
282
+ secret?: string;
283
+ is_active: boolean;
284
+ success_count: number;
285
+ failure_count: number;
286
+ last_triggered_at: number | null;
287
+ created_at: number;
288
+ updated_at: number;
289
+ }
290
+ export interface CreateWebhookParams {
291
+ url: string;
292
+ events: string[];
293
+ description?: string;
294
+ }
295
+ export interface UpdateWebhookParams {
296
+ url?: string;
297
+ events?: string[];
298
+ is_active?: boolean;
299
+ }
300
+ export interface DiscountCode {
301
+ object: "discount_code";
302
+ id: string;
303
+ code: string;
304
+ type: "percentage" | "fixed";
305
+ value: string;
306
+ payment_link_id: string | null;
307
+ max_uses: number | null;
308
+ current_uses: number;
309
+ min_order_amount: string | null;
310
+ expires_at: number | null;
311
+ is_active: boolean;
312
+ created_at: number;
313
+ updated_at: number;
314
+ }
315
+ export interface CreateDiscountCodeParams {
316
+ code: string;
317
+ type: "percentage" | "fixed";
318
+ value: string;
319
+ payment_link_id?: string;
320
+ max_uses?: number;
321
+ min_order_amount?: string;
322
+ expires_at?: number;
323
+ }
324
+ export interface BatchCreateDiscountCodesParams {
325
+ codes: string[];
326
+ type: "percentage" | "fixed";
327
+ value: string;
328
+ payment_link_id?: string;
329
+ max_uses?: number;
330
+ min_order_amount?: string;
331
+ expires_at?: number;
332
+ }
333
+ export interface NotificationSettings {
334
+ object: "notification_settings";
335
+ id: string;
336
+ email_enabled: boolean;
337
+ email_address: string | null;
338
+ telegram_enabled: boolean;
339
+ telegram_chat_id: string | null;
340
+ enabled_events: string[];
341
+ }
342
+ export interface UpdateNotificationSettingsParams {
343
+ email_enabled?: boolean;
344
+ email_address?: string;
345
+ telegram_enabled?: boolean;
346
+ enabled_events?: string[];
347
+ }
348
+ export interface WidgetConfig {
349
+ object: "widget_config";
350
+ id: string;
351
+ short_code: string;
352
+ name: string;
353
+ description: string | null;
354
+ widget_type: string;
355
+ config: string;
356
+ theme: string;
357
+ is_active: boolean;
358
+ current_views: number;
359
+ created_at: number;
360
+ updated_at: number;
361
+ }
362
+ export interface CreateWidgetParams {
363
+ name: string;
364
+ widget_type: "swap" | "checkout" | "nft" | "deposit";
365
+ config: Record<string, unknown>;
366
+ description?: string;
367
+ theme?: Record<string, unknown>;
368
+ }
369
+ export interface Organization {
370
+ object: "organization";
371
+ id: string;
372
+ name: string;
373
+ slug: string;
374
+ description: string | null;
375
+ logo_url: string | null;
376
+ website_url: string | null;
377
+ default_recipient_address: string | null;
378
+ default_chain_id: number | null;
379
+ default_token_address: string | null;
380
+ }
381
+ export interface AnalyticsOverview {
382
+ object: "analytics_overview";
383
+ period: string;
384
+ revenue: {
385
+ period_usd: string;
386
+ period_transactions: number;
387
+ all_time_usd: string;
388
+ all_time_transactions: number;
389
+ };
390
+ customers: {
391
+ total: number;
392
+ new_in_period: number;
393
+ };
394
+ payment_links: {
395
+ total: number;
396
+ active: number;
397
+ };
398
+ conversion_rate: string;
399
+ daily: {
400
+ date: string;
401
+ transactions: number;
402
+ revenue_usd: number;
403
+ }[];
404
+ top_payment_links: Record<string, unknown>[];
405
+ top_tokens: Record<string, unknown>[];
406
+ top_chains: Record<string, unknown>[];
407
+ }
408
+ export interface ApiEvent {
409
+ object: "event";
410
+ id: string;
411
+ event_type: string;
412
+ resource_type: string;
413
+ resource_id: string | null;
414
+ ip_address: string | null;
415
+ request_method: string;
416
+ request_path: string;
417
+ status_code: number;
418
+ created_at: number;
419
+ }
420
+ export interface QuickPayParams {
421
+ recipient_address: string;
422
+ amount?: string;
423
+ token_address?: string;
424
+ chain_id?: number;
425
+ name?: string;
426
+ description?: string;
427
+ expires_in?: number;
428
+ }
429
+ export interface ApiKey {
430
+ object: "api_key";
431
+ id: string;
432
+ name: string;
433
+ prefix: string;
434
+ permissions: string[];
435
+ last_used_at: number | null;
436
+ created_at: number;
437
+ updated_at: number;
438
+ }
439
+ export interface WebhookDelivery {
440
+ object: "webhook_delivery";
441
+ id: string;
442
+ webhook_id: string;
443
+ event_type: string;
444
+ url: string;
445
+ status: "pending" | "success" | "failed";
446
+ status_code: number | null;
447
+ response_body: string | null;
448
+ error_message: string | null;
449
+ attempted_at: number;
450
+ created_at: number;
451
+ }
452
+ export interface ValidateDiscountResult {
453
+ object: "discount_validation";
454
+ valid: boolean;
455
+ discount_code?: DiscountCode;
456
+ discount_amount?: string;
457
+ final_amount?: string;
458
+ reason?: string;
459
+ }
460
+ export interface BatchCreateResult {
461
+ object: "batch_result";
462
+ created: DiscountCode[];
463
+ errors: {
464
+ code: string;
465
+ error: string;
466
+ }[];
467
+ }
468
+ export interface ExportTransactionsParams {
469
+ format?: "csv" | "json";
470
+ status?: string;
471
+ from?: number;
472
+ to?: number;
473
+ }
474
+ export interface ExportCustomersParams {
475
+ format?: "csv" | "json";
476
+ from?: number;
477
+ to?: number;
478
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * TypeScript types for the AnySpend Platform API.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Idempotency key generation utility.
3
+ */
4
+ export declare function generateIdempotencyKey(): string;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Idempotency key generation utility.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateIdempotencyKey = generateIdempotencyKey;
7
+ function generateIdempotencyKey() {
8
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
9
+ return crypto.randomUUID();
10
+ }
11
+ // Fallback for environments without crypto.randomUUID
12
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
13
+ const r = (Math.random() * 16) | 0;
14
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
15
+ return v.toString(16);
16
+ });
17
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Auto-pagination async iterator for list endpoints.
3
+ */
4
+ import type { ListResponse } from "../types";
5
+ export interface AutoPaginateOptions {
6
+ startPage?: number;
7
+ limit?: number;
8
+ }
9
+ /**
10
+ * Creates an async iterator that automatically paginates through all results.
11
+ */
12
+ export declare function autoPaginate<T>(fetchPage: (page: number, limit: number) => Promise<ListResponse<T>>, options?: AutoPaginateOptions): AsyncGenerator<T, void, undefined>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-pagination async iterator for list endpoints.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.autoPaginate = autoPaginate;
7
+ /**
8
+ * Creates an async iterator that automatically paginates through all results.
9
+ */
10
+ async function* autoPaginate(fetchPage, options = {}) {
11
+ let page = options.startPage || 1;
12
+ const limit = options.limit || 100;
13
+ while (true) {
14
+ const result = await fetchPage(page, limit);
15
+ for (const item of result.data) {
16
+ yield item;
17
+ }
18
+ if (!result.has_more)
19
+ break;
20
+ page++;
21
+ }
22
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Core HTTP client for the AnySpend Platform API.
3
+ * Handles authentication, retries, error parsing, and idempotency.
4
+ */
5
+ export interface ClientConfig {
6
+ baseUrl?: string;
7
+ timeout?: number;
8
+ maxRetries?: number;
9
+ idempotencyKeyGenerator?: () => string;
10
+ }
11
+ export declare const DEFAULT_BASE_URL = "https://platform-api.anyspend.com/api/v1";
12
+ export declare class HttpClient {
13
+ private apiKey;
14
+ private baseUrl;
15
+ private timeout;
16
+ private maxRetries;
17
+ private generateIdempotencyKey;
18
+ constructor(apiKey: string, config?: ClientConfig);
19
+ get<T>(path: string, params?: object): Promise<T>;
20
+ post<T>(path: string, body?: object): Promise<T>;
21
+ patch<T>(path: string, body: object): Promise<T>;
22
+ delete<T>(path: string, body?: object): Promise<T>;
23
+ postFormData<T>(path: string, formData: FormData): Promise<T>;
24
+ private buildUrl;
25
+ private request;
26
+ private requestRaw;
27
+ private executeWithRetry;
28
+ private sleep;
29
+ }
30
+ /**
31
+ * Static HTTP client for unauthenticated requests (quick-pay).
32
+ */
33
+ export declare class StaticHttpClient {
34
+ static post<T>(baseUrl: string, path: string, body: Record<string, unknown>): Promise<T>;
35
+ }