@rawdash/connector-stripe 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.js +187 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -40,16 +40,60 @@ Authenticates with a Stripe restricted API key that has read-only access to the
|
|
|
40
40
|
- **`stripe_subscription`** _(entity)_ - Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).
|
|
41
41
|
- Endpoint: `GET /v1/subscriptions`
|
|
42
42
|
- mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).
|
|
43
|
+
- `customerId`: Customer the subscription belongs to.
|
|
44
|
+
- `status`: Subscription status (active, canceled, ...).
|
|
45
|
+
- `planId`: Price id of the first subscription item.
|
|
46
|
+
- `currentPeriodStart`: Current period start (unix seconds).
|
|
47
|
+
- `currentPeriodEnd`: Current period end (unix seconds).
|
|
48
|
+
- `cancelAtPeriodEnd`: Whether the subscription cancels at period end.
|
|
49
|
+
- `canceledAt`: Cancellation time (unix seconds), if canceled.
|
|
50
|
+
- `trialEnd`: Trial end time (unix seconds), if any.
|
|
51
|
+
- `mrrAmount` _(cents)_: Monthly recurring revenue in the smallest currency unit.
|
|
52
|
+
- `currency`: ISO currency code.
|
|
53
|
+
- `created`: Creation time (unix seconds).
|
|
43
54
|
- **`stripe_invoice`** _(entity)_ - Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.
|
|
44
55
|
- Endpoint: `GET /v1/invoices`
|
|
56
|
+
- `customerId`: Customer the invoice belongs to.
|
|
57
|
+
- `subscriptionId`: Subscription the invoice belongs to, if any.
|
|
58
|
+
- `status`: Invoice status (draft, open, paid, ...).
|
|
59
|
+
- `amountDue` _(cents)_: Amount due in the smallest currency unit.
|
|
60
|
+
- `amountPaid` _(cents)_: Amount paid in the smallest currency unit.
|
|
61
|
+
- `currency`: ISO currency code.
|
|
62
|
+
- `created`: Creation time (unix seconds).
|
|
63
|
+
- `dueDate`: Due date (unix seconds), if any.
|
|
64
|
+
- `hostedInvoiceUrl`: Hosted invoice URL, if any.
|
|
45
65
|
- **`stripe_charge`** _(event)_ - Charge attempts with amount, currency, status, and failure code, timestamped at creation.
|
|
46
66
|
- Endpoint: `GET /v1/charges`
|
|
67
|
+
- `id`: Stripe charge id.
|
|
68
|
+
- `customerId`: Customer charged, if any.
|
|
69
|
+
- `amount` _(cents)_: Charge amount in the smallest currency unit.
|
|
70
|
+
- `currency`: ISO currency code.
|
|
71
|
+
- `status`: Charge status (succeeded, failed, ...).
|
|
72
|
+
- `failureCode`: Failure code, if the charge failed.
|
|
73
|
+
- `paymentIntentId`: Associated payment intent id, if any.
|
|
47
74
|
- **`stripe_payment_intent`** _(event)_ - Payment intents with amount, currency, and status, timestamped at creation.
|
|
48
75
|
- Endpoint: `GET /v1/payment_intents`
|
|
76
|
+
- `id`: Stripe payment intent id.
|
|
77
|
+
- `customerId`: Customer, if any.
|
|
78
|
+
- `amount` _(cents)_: Intent amount in the smallest currency unit.
|
|
79
|
+
- `currency`: ISO currency code.
|
|
80
|
+
- `status`: Payment intent status.
|
|
49
81
|
- **`stripe_dispute`** _(event)_ - Disputes with amount, currency, reason, and status, linked to the disputed charge.
|
|
50
82
|
- Endpoint: `GET /v1/disputes`
|
|
83
|
+
- `id`: Stripe dispute id.
|
|
84
|
+
- `chargeId`: Disputed charge id.
|
|
85
|
+
- `amount` _(cents)_: Disputed amount in the smallest currency unit.
|
|
86
|
+
- `currency`: ISO currency code.
|
|
87
|
+
- `reason`: Dispute reason.
|
|
88
|
+
- `status`: Dispute status.
|
|
51
89
|
- **`stripe_refund`** _(event)_ - Refunds with amount, currency, reason, and status, linked to the refunded charge.
|
|
52
90
|
- Endpoint: `GET /v1/refunds`
|
|
91
|
+
- `id`: Stripe refund id.
|
|
92
|
+
- `chargeId`: Refunded charge id, if any.
|
|
93
|
+
- `amount` _(cents)_: Refunded amount in the smallest currency unit.
|
|
94
|
+
- `currency`: ISO currency code.
|
|
95
|
+
- `reason`: Refund reason, if any.
|
|
96
|
+
- `status`: Refund status, if any.
|
|
53
97
|
|
|
54
98
|
## Example
|
|
55
99
|
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,7 @@ declare function computeMrrAmountCents(subscription: StripeSubscription): number
|
|
|
69
69
|
declare const stripeResources: {
|
|
70
70
|
readonly stripe_customer: {
|
|
71
71
|
readonly shape: "entity";
|
|
72
|
+
readonly filterable: [];
|
|
72
73
|
readonly description: "Customers with email, name, default currency, and delinquency state.";
|
|
73
74
|
readonly endpoint: "GET /v1/customers";
|
|
74
75
|
readonly responses: {
|
|
@@ -85,6 +86,11 @@ declare const stripeResources: {
|
|
|
85
86
|
};
|
|
86
87
|
readonly stripe_product: {
|
|
87
88
|
readonly shape: "entity";
|
|
89
|
+
readonly filterable: [{
|
|
90
|
+
readonly field: "active";
|
|
91
|
+
readonly ops: ["eq"];
|
|
92
|
+
readonly values: ["true", "false"];
|
|
93
|
+
}];
|
|
88
94
|
readonly description: "Products in your catalog, including active state.";
|
|
89
95
|
readonly endpoint: "GET /v1/products";
|
|
90
96
|
readonly responses: {
|
|
@@ -98,6 +104,11 @@ declare const stripeResources: {
|
|
|
98
104
|
};
|
|
99
105
|
readonly stripe_price: {
|
|
100
106
|
readonly shape: "entity";
|
|
107
|
+
readonly filterable: [{
|
|
108
|
+
readonly field: "active";
|
|
109
|
+
readonly ops: ["eq"];
|
|
110
|
+
readonly values: ["true", "false"];
|
|
111
|
+
}];
|
|
101
112
|
readonly description: "Prices with unit amount, currency, and recurring interval, linked to their product.";
|
|
102
113
|
readonly endpoint: "GET /v1/prices";
|
|
103
114
|
readonly responses: {
|
|
@@ -122,9 +133,49 @@ declare const stripeResources: {
|
|
|
122
133
|
};
|
|
123
134
|
readonly stripe_subscription: {
|
|
124
135
|
readonly shape: "entity";
|
|
136
|
+
readonly filterable: [{
|
|
137
|
+
readonly field: "status";
|
|
138
|
+
readonly ops: ["eq"];
|
|
139
|
+
readonly values: ["active", "past_due", "unpaid", "canceled", "incomplete", "incomplete_expired", "trialing", "paused"];
|
|
140
|
+
}];
|
|
125
141
|
readonly description: "Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).";
|
|
126
142
|
readonly endpoint: "GET /v1/subscriptions";
|
|
127
143
|
readonly notes: "mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).";
|
|
144
|
+
readonly fields: [{
|
|
145
|
+
readonly name: "customerId";
|
|
146
|
+
readonly description: "Customer the subscription belongs to.";
|
|
147
|
+
}, {
|
|
148
|
+
readonly name: "status";
|
|
149
|
+
readonly description: "Subscription status (active, canceled, ...).";
|
|
150
|
+
}, {
|
|
151
|
+
readonly name: "planId";
|
|
152
|
+
readonly description: "Price id of the first subscription item.";
|
|
153
|
+
}, {
|
|
154
|
+
readonly name: "currentPeriodStart";
|
|
155
|
+
readonly description: "Current period start (unix seconds).";
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "currentPeriodEnd";
|
|
158
|
+
readonly description: "Current period end (unix seconds).";
|
|
159
|
+
}, {
|
|
160
|
+
readonly name: "cancelAtPeriodEnd";
|
|
161
|
+
readonly description: "Whether the subscription cancels at period end.";
|
|
162
|
+
}, {
|
|
163
|
+
readonly name: "canceledAt";
|
|
164
|
+
readonly description: "Cancellation time (unix seconds), if canceled.";
|
|
165
|
+
}, {
|
|
166
|
+
readonly name: "trialEnd";
|
|
167
|
+
readonly description: "Trial end time (unix seconds), if any.";
|
|
168
|
+
}, {
|
|
169
|
+
readonly name: "mrrAmount";
|
|
170
|
+
readonly description: "Monthly recurring revenue in the smallest currency unit.";
|
|
171
|
+
readonly unit: "cents";
|
|
172
|
+
}, {
|
|
173
|
+
readonly name: "currency";
|
|
174
|
+
readonly description: "ISO currency code.";
|
|
175
|
+
}, {
|
|
176
|
+
readonly name: "created";
|
|
177
|
+
readonly description: "Creation time (unix seconds).";
|
|
178
|
+
}];
|
|
128
179
|
readonly responses: {
|
|
129
180
|
readonly subscriptions: z.ZodArray<z.ZodObject<{
|
|
130
181
|
id: z.ZodString;
|
|
@@ -164,8 +215,43 @@ declare const stripeResources: {
|
|
|
164
215
|
};
|
|
165
216
|
readonly stripe_invoice: {
|
|
166
217
|
readonly shape: "entity";
|
|
218
|
+
readonly filterable: [{
|
|
219
|
+
readonly field: "status";
|
|
220
|
+
readonly ops: ["eq"];
|
|
221
|
+
readonly values: ["draft", "open", "paid", "uncollectible", "void"];
|
|
222
|
+
}];
|
|
167
223
|
readonly description: "Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.";
|
|
168
224
|
readonly endpoint: "GET /v1/invoices";
|
|
225
|
+
readonly fields: [{
|
|
226
|
+
readonly name: "customerId";
|
|
227
|
+
readonly description: "Customer the invoice belongs to.";
|
|
228
|
+
}, {
|
|
229
|
+
readonly name: "subscriptionId";
|
|
230
|
+
readonly description: "Subscription the invoice belongs to, if any.";
|
|
231
|
+
}, {
|
|
232
|
+
readonly name: "status";
|
|
233
|
+
readonly description: "Invoice status (draft, open, paid, ...).";
|
|
234
|
+
}, {
|
|
235
|
+
readonly name: "amountDue";
|
|
236
|
+
readonly description: "Amount due in the smallest currency unit.";
|
|
237
|
+
readonly unit: "cents";
|
|
238
|
+
}, {
|
|
239
|
+
readonly name: "amountPaid";
|
|
240
|
+
readonly description: "Amount paid in the smallest currency unit.";
|
|
241
|
+
readonly unit: "cents";
|
|
242
|
+
}, {
|
|
243
|
+
readonly name: "currency";
|
|
244
|
+
readonly description: "ISO currency code.";
|
|
245
|
+
}, {
|
|
246
|
+
readonly name: "created";
|
|
247
|
+
readonly description: "Creation time (unix seconds).";
|
|
248
|
+
}, {
|
|
249
|
+
readonly name: "dueDate";
|
|
250
|
+
readonly description: "Due date (unix seconds), if any.";
|
|
251
|
+
}, {
|
|
252
|
+
readonly name: "hostedInvoiceUrl";
|
|
253
|
+
readonly description: "Hosted invoice URL, if any.";
|
|
254
|
+
}];
|
|
169
255
|
readonly responses: {
|
|
170
256
|
readonly invoices: z.ZodArray<z.ZodObject<{
|
|
171
257
|
id: z.ZodString;
|
|
@@ -183,8 +269,32 @@ declare const stripeResources: {
|
|
|
183
269
|
};
|
|
184
270
|
readonly stripe_charge: {
|
|
185
271
|
readonly shape: "event";
|
|
272
|
+
readonly filterable: [];
|
|
186
273
|
readonly description: "Charge attempts with amount, currency, status, and failure code, timestamped at creation.";
|
|
187
274
|
readonly endpoint: "GET /v1/charges";
|
|
275
|
+
readonly fields: [{
|
|
276
|
+
readonly name: "id";
|
|
277
|
+
readonly description: "Stripe charge id.";
|
|
278
|
+
}, {
|
|
279
|
+
readonly name: "customerId";
|
|
280
|
+
readonly description: "Customer charged, if any.";
|
|
281
|
+
}, {
|
|
282
|
+
readonly name: "amount";
|
|
283
|
+
readonly description: "Charge amount in the smallest currency unit.";
|
|
284
|
+
readonly unit: "cents";
|
|
285
|
+
}, {
|
|
286
|
+
readonly name: "currency";
|
|
287
|
+
readonly description: "ISO currency code.";
|
|
288
|
+
}, {
|
|
289
|
+
readonly name: "status";
|
|
290
|
+
readonly description: "Charge status (succeeded, failed, ...).";
|
|
291
|
+
}, {
|
|
292
|
+
readonly name: "failureCode";
|
|
293
|
+
readonly description: "Failure code, if the charge failed.";
|
|
294
|
+
}, {
|
|
295
|
+
readonly name: "paymentIntentId";
|
|
296
|
+
readonly description: "Associated payment intent id, if any.";
|
|
297
|
+
}];
|
|
188
298
|
readonly responses: {
|
|
189
299
|
readonly charges: z.ZodArray<z.ZodObject<{
|
|
190
300
|
id: z.ZodString;
|
|
@@ -200,8 +310,26 @@ declare const stripeResources: {
|
|
|
200
310
|
};
|
|
201
311
|
readonly stripe_payment_intent: {
|
|
202
312
|
readonly shape: "event";
|
|
313
|
+
readonly filterable: [];
|
|
203
314
|
readonly description: "Payment intents with amount, currency, and status, timestamped at creation.";
|
|
204
315
|
readonly endpoint: "GET /v1/payment_intents";
|
|
316
|
+
readonly fields: [{
|
|
317
|
+
readonly name: "id";
|
|
318
|
+
readonly description: "Stripe payment intent id.";
|
|
319
|
+
}, {
|
|
320
|
+
readonly name: "customerId";
|
|
321
|
+
readonly description: "Customer, if any.";
|
|
322
|
+
}, {
|
|
323
|
+
readonly name: "amount";
|
|
324
|
+
readonly description: "Intent amount in the smallest currency unit.";
|
|
325
|
+
readonly unit: "cents";
|
|
326
|
+
}, {
|
|
327
|
+
readonly name: "currency";
|
|
328
|
+
readonly description: "ISO currency code.";
|
|
329
|
+
}, {
|
|
330
|
+
readonly name: "status";
|
|
331
|
+
readonly description: "Payment intent status.";
|
|
332
|
+
}];
|
|
205
333
|
readonly responses: {
|
|
206
334
|
readonly payment_intents: z.ZodArray<z.ZodObject<{
|
|
207
335
|
id: z.ZodString;
|
|
@@ -215,8 +343,29 @@ declare const stripeResources: {
|
|
|
215
343
|
};
|
|
216
344
|
readonly stripe_dispute: {
|
|
217
345
|
readonly shape: "event";
|
|
346
|
+
readonly filterable: [];
|
|
218
347
|
readonly description: "Disputes with amount, currency, reason, and status, linked to the disputed charge.";
|
|
219
348
|
readonly endpoint: "GET /v1/disputes";
|
|
349
|
+
readonly fields: [{
|
|
350
|
+
readonly name: "id";
|
|
351
|
+
readonly description: "Stripe dispute id.";
|
|
352
|
+
}, {
|
|
353
|
+
readonly name: "chargeId";
|
|
354
|
+
readonly description: "Disputed charge id.";
|
|
355
|
+
}, {
|
|
356
|
+
readonly name: "amount";
|
|
357
|
+
readonly description: "Disputed amount in the smallest currency unit.";
|
|
358
|
+
readonly unit: "cents";
|
|
359
|
+
}, {
|
|
360
|
+
readonly name: "currency";
|
|
361
|
+
readonly description: "ISO currency code.";
|
|
362
|
+
}, {
|
|
363
|
+
readonly name: "reason";
|
|
364
|
+
readonly description: "Dispute reason.";
|
|
365
|
+
}, {
|
|
366
|
+
readonly name: "status";
|
|
367
|
+
readonly description: "Dispute status.";
|
|
368
|
+
}];
|
|
220
369
|
readonly responses: {
|
|
221
370
|
readonly disputes: z.ZodArray<z.ZodObject<{
|
|
222
371
|
id: z.ZodString;
|
|
@@ -231,8 +380,29 @@ declare const stripeResources: {
|
|
|
231
380
|
};
|
|
232
381
|
readonly stripe_refund: {
|
|
233
382
|
readonly shape: "event";
|
|
383
|
+
readonly filterable: [];
|
|
234
384
|
readonly description: "Refunds with amount, currency, reason, and status, linked to the refunded charge.";
|
|
235
385
|
readonly endpoint: "GET /v1/refunds";
|
|
386
|
+
readonly fields: [{
|
|
387
|
+
readonly name: "id";
|
|
388
|
+
readonly description: "Stripe refund id.";
|
|
389
|
+
}, {
|
|
390
|
+
readonly name: "chargeId";
|
|
391
|
+
readonly description: "Refunded charge id, if any.";
|
|
392
|
+
}, {
|
|
393
|
+
readonly name: "amount";
|
|
394
|
+
readonly description: "Refunded amount in the smallest currency unit.";
|
|
395
|
+
readonly unit: "cents";
|
|
396
|
+
}, {
|
|
397
|
+
readonly name: "currency";
|
|
398
|
+
readonly description: "ISO currency code.";
|
|
399
|
+
}, {
|
|
400
|
+
readonly name: "reason";
|
|
401
|
+
readonly description: "Refund reason, if any.";
|
|
402
|
+
}, {
|
|
403
|
+
readonly name: "status";
|
|
404
|
+
readonly description: "Refund status, if any.";
|
|
405
|
+
}];
|
|
236
406
|
readonly responses: {
|
|
237
407
|
readonly refunds: z.ZodArray<z.ZodObject<{
|
|
238
408
|
id: z.ZodString;
|
|
@@ -252,6 +422,7 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
252
422
|
static readonly resources: {
|
|
253
423
|
readonly stripe_customer: {
|
|
254
424
|
readonly shape: "entity";
|
|
425
|
+
readonly filterable: [];
|
|
255
426
|
readonly description: "Customers with email, name, default currency, and delinquency state.";
|
|
256
427
|
readonly endpoint: "GET /v1/customers";
|
|
257
428
|
readonly responses: {
|
|
@@ -268,6 +439,11 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
268
439
|
};
|
|
269
440
|
readonly stripe_product: {
|
|
270
441
|
readonly shape: "entity";
|
|
442
|
+
readonly filterable: [{
|
|
443
|
+
readonly field: "active";
|
|
444
|
+
readonly ops: ["eq"];
|
|
445
|
+
readonly values: ["true", "false"];
|
|
446
|
+
}];
|
|
271
447
|
readonly description: "Products in your catalog, including active state.";
|
|
272
448
|
readonly endpoint: "GET /v1/products";
|
|
273
449
|
readonly responses: {
|
|
@@ -281,6 +457,11 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
281
457
|
};
|
|
282
458
|
readonly stripe_price: {
|
|
283
459
|
readonly shape: "entity";
|
|
460
|
+
readonly filterable: [{
|
|
461
|
+
readonly field: "active";
|
|
462
|
+
readonly ops: ["eq"];
|
|
463
|
+
readonly values: ["true", "false"];
|
|
464
|
+
}];
|
|
284
465
|
readonly description: "Prices with unit amount, currency, and recurring interval, linked to their product.";
|
|
285
466
|
readonly endpoint: "GET /v1/prices";
|
|
286
467
|
readonly responses: {
|
|
@@ -305,9 +486,49 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
305
486
|
};
|
|
306
487
|
readonly stripe_subscription: {
|
|
307
488
|
readonly shape: "entity";
|
|
489
|
+
readonly filterable: [{
|
|
490
|
+
readonly field: "status";
|
|
491
|
+
readonly ops: ["eq"];
|
|
492
|
+
readonly values: ["active", "past_due", "unpaid", "canceled", "incomplete", "incomplete_expired", "trialing", "paused"];
|
|
493
|
+
}];
|
|
308
494
|
readonly description: "Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).";
|
|
309
495
|
readonly endpoint: "GET /v1/subscriptions";
|
|
310
496
|
readonly notes: "mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).";
|
|
497
|
+
readonly fields: [{
|
|
498
|
+
readonly name: "customerId";
|
|
499
|
+
readonly description: "Customer the subscription belongs to.";
|
|
500
|
+
}, {
|
|
501
|
+
readonly name: "status";
|
|
502
|
+
readonly description: "Subscription status (active, canceled, ...).";
|
|
503
|
+
}, {
|
|
504
|
+
readonly name: "planId";
|
|
505
|
+
readonly description: "Price id of the first subscription item.";
|
|
506
|
+
}, {
|
|
507
|
+
readonly name: "currentPeriodStart";
|
|
508
|
+
readonly description: "Current period start (unix seconds).";
|
|
509
|
+
}, {
|
|
510
|
+
readonly name: "currentPeriodEnd";
|
|
511
|
+
readonly description: "Current period end (unix seconds).";
|
|
512
|
+
}, {
|
|
513
|
+
readonly name: "cancelAtPeriodEnd";
|
|
514
|
+
readonly description: "Whether the subscription cancels at period end.";
|
|
515
|
+
}, {
|
|
516
|
+
readonly name: "canceledAt";
|
|
517
|
+
readonly description: "Cancellation time (unix seconds), if canceled.";
|
|
518
|
+
}, {
|
|
519
|
+
readonly name: "trialEnd";
|
|
520
|
+
readonly description: "Trial end time (unix seconds), if any.";
|
|
521
|
+
}, {
|
|
522
|
+
readonly name: "mrrAmount";
|
|
523
|
+
readonly description: "Monthly recurring revenue in the smallest currency unit.";
|
|
524
|
+
readonly unit: "cents";
|
|
525
|
+
}, {
|
|
526
|
+
readonly name: "currency";
|
|
527
|
+
readonly description: "ISO currency code.";
|
|
528
|
+
}, {
|
|
529
|
+
readonly name: "created";
|
|
530
|
+
readonly description: "Creation time (unix seconds).";
|
|
531
|
+
}];
|
|
311
532
|
readonly responses: {
|
|
312
533
|
readonly subscriptions: z.ZodArray<z.ZodObject<{
|
|
313
534
|
id: z.ZodString;
|
|
@@ -347,8 +568,43 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
347
568
|
};
|
|
348
569
|
readonly stripe_invoice: {
|
|
349
570
|
readonly shape: "entity";
|
|
571
|
+
readonly filterable: [{
|
|
572
|
+
readonly field: "status";
|
|
573
|
+
readonly ops: ["eq"];
|
|
574
|
+
readonly values: ["draft", "open", "paid", "uncollectible", "void"];
|
|
575
|
+
}];
|
|
350
576
|
readonly description: "Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.";
|
|
351
577
|
readonly endpoint: "GET /v1/invoices";
|
|
578
|
+
readonly fields: [{
|
|
579
|
+
readonly name: "customerId";
|
|
580
|
+
readonly description: "Customer the invoice belongs to.";
|
|
581
|
+
}, {
|
|
582
|
+
readonly name: "subscriptionId";
|
|
583
|
+
readonly description: "Subscription the invoice belongs to, if any.";
|
|
584
|
+
}, {
|
|
585
|
+
readonly name: "status";
|
|
586
|
+
readonly description: "Invoice status (draft, open, paid, ...).";
|
|
587
|
+
}, {
|
|
588
|
+
readonly name: "amountDue";
|
|
589
|
+
readonly description: "Amount due in the smallest currency unit.";
|
|
590
|
+
readonly unit: "cents";
|
|
591
|
+
}, {
|
|
592
|
+
readonly name: "amountPaid";
|
|
593
|
+
readonly description: "Amount paid in the smallest currency unit.";
|
|
594
|
+
readonly unit: "cents";
|
|
595
|
+
}, {
|
|
596
|
+
readonly name: "currency";
|
|
597
|
+
readonly description: "ISO currency code.";
|
|
598
|
+
}, {
|
|
599
|
+
readonly name: "created";
|
|
600
|
+
readonly description: "Creation time (unix seconds).";
|
|
601
|
+
}, {
|
|
602
|
+
readonly name: "dueDate";
|
|
603
|
+
readonly description: "Due date (unix seconds), if any.";
|
|
604
|
+
}, {
|
|
605
|
+
readonly name: "hostedInvoiceUrl";
|
|
606
|
+
readonly description: "Hosted invoice URL, if any.";
|
|
607
|
+
}];
|
|
352
608
|
readonly responses: {
|
|
353
609
|
readonly invoices: z.ZodArray<z.ZodObject<{
|
|
354
610
|
id: z.ZodString;
|
|
@@ -366,8 +622,32 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
366
622
|
};
|
|
367
623
|
readonly stripe_charge: {
|
|
368
624
|
readonly shape: "event";
|
|
625
|
+
readonly filterable: [];
|
|
369
626
|
readonly description: "Charge attempts with amount, currency, status, and failure code, timestamped at creation.";
|
|
370
627
|
readonly endpoint: "GET /v1/charges";
|
|
628
|
+
readonly fields: [{
|
|
629
|
+
readonly name: "id";
|
|
630
|
+
readonly description: "Stripe charge id.";
|
|
631
|
+
}, {
|
|
632
|
+
readonly name: "customerId";
|
|
633
|
+
readonly description: "Customer charged, if any.";
|
|
634
|
+
}, {
|
|
635
|
+
readonly name: "amount";
|
|
636
|
+
readonly description: "Charge amount in the smallest currency unit.";
|
|
637
|
+
readonly unit: "cents";
|
|
638
|
+
}, {
|
|
639
|
+
readonly name: "currency";
|
|
640
|
+
readonly description: "ISO currency code.";
|
|
641
|
+
}, {
|
|
642
|
+
readonly name: "status";
|
|
643
|
+
readonly description: "Charge status (succeeded, failed, ...).";
|
|
644
|
+
}, {
|
|
645
|
+
readonly name: "failureCode";
|
|
646
|
+
readonly description: "Failure code, if the charge failed.";
|
|
647
|
+
}, {
|
|
648
|
+
readonly name: "paymentIntentId";
|
|
649
|
+
readonly description: "Associated payment intent id, if any.";
|
|
650
|
+
}];
|
|
371
651
|
readonly responses: {
|
|
372
652
|
readonly charges: z.ZodArray<z.ZodObject<{
|
|
373
653
|
id: z.ZodString;
|
|
@@ -383,8 +663,26 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
383
663
|
};
|
|
384
664
|
readonly stripe_payment_intent: {
|
|
385
665
|
readonly shape: "event";
|
|
666
|
+
readonly filterable: [];
|
|
386
667
|
readonly description: "Payment intents with amount, currency, and status, timestamped at creation.";
|
|
387
668
|
readonly endpoint: "GET /v1/payment_intents";
|
|
669
|
+
readonly fields: [{
|
|
670
|
+
readonly name: "id";
|
|
671
|
+
readonly description: "Stripe payment intent id.";
|
|
672
|
+
}, {
|
|
673
|
+
readonly name: "customerId";
|
|
674
|
+
readonly description: "Customer, if any.";
|
|
675
|
+
}, {
|
|
676
|
+
readonly name: "amount";
|
|
677
|
+
readonly description: "Intent amount in the smallest currency unit.";
|
|
678
|
+
readonly unit: "cents";
|
|
679
|
+
}, {
|
|
680
|
+
readonly name: "currency";
|
|
681
|
+
readonly description: "ISO currency code.";
|
|
682
|
+
}, {
|
|
683
|
+
readonly name: "status";
|
|
684
|
+
readonly description: "Payment intent status.";
|
|
685
|
+
}];
|
|
388
686
|
readonly responses: {
|
|
389
687
|
readonly payment_intents: z.ZodArray<z.ZodObject<{
|
|
390
688
|
id: z.ZodString;
|
|
@@ -398,8 +696,29 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
398
696
|
};
|
|
399
697
|
readonly stripe_dispute: {
|
|
400
698
|
readonly shape: "event";
|
|
699
|
+
readonly filterable: [];
|
|
401
700
|
readonly description: "Disputes with amount, currency, reason, and status, linked to the disputed charge.";
|
|
402
701
|
readonly endpoint: "GET /v1/disputes";
|
|
702
|
+
readonly fields: [{
|
|
703
|
+
readonly name: "id";
|
|
704
|
+
readonly description: "Stripe dispute id.";
|
|
705
|
+
}, {
|
|
706
|
+
readonly name: "chargeId";
|
|
707
|
+
readonly description: "Disputed charge id.";
|
|
708
|
+
}, {
|
|
709
|
+
readonly name: "amount";
|
|
710
|
+
readonly description: "Disputed amount in the smallest currency unit.";
|
|
711
|
+
readonly unit: "cents";
|
|
712
|
+
}, {
|
|
713
|
+
readonly name: "currency";
|
|
714
|
+
readonly description: "ISO currency code.";
|
|
715
|
+
}, {
|
|
716
|
+
readonly name: "reason";
|
|
717
|
+
readonly description: "Dispute reason.";
|
|
718
|
+
}, {
|
|
719
|
+
readonly name: "status";
|
|
720
|
+
readonly description: "Dispute status.";
|
|
721
|
+
}];
|
|
403
722
|
readonly responses: {
|
|
404
723
|
readonly disputes: z.ZodArray<z.ZodObject<{
|
|
405
724
|
id: z.ZodString;
|
|
@@ -414,8 +733,29 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
414
733
|
};
|
|
415
734
|
readonly stripe_refund: {
|
|
416
735
|
readonly shape: "event";
|
|
736
|
+
readonly filterable: [];
|
|
417
737
|
readonly description: "Refunds with amount, currency, reason, and status, linked to the refunded charge.";
|
|
418
738
|
readonly endpoint: "GET /v1/refunds";
|
|
739
|
+
readonly fields: [{
|
|
740
|
+
readonly name: "id";
|
|
741
|
+
readonly description: "Stripe refund id.";
|
|
742
|
+
}, {
|
|
743
|
+
readonly name: "chargeId";
|
|
744
|
+
readonly description: "Refunded charge id, if any.";
|
|
745
|
+
}, {
|
|
746
|
+
readonly name: "amount";
|
|
747
|
+
readonly description: "Refunded amount in the smallest currency unit.";
|
|
748
|
+
readonly unit: "cents";
|
|
749
|
+
}, {
|
|
750
|
+
readonly name: "currency";
|
|
751
|
+
readonly description: "ISO currency code.";
|
|
752
|
+
}, {
|
|
753
|
+
readonly name: "reason";
|
|
754
|
+
readonly description: "Refund reason, if any.";
|
|
755
|
+
}, {
|
|
756
|
+
readonly name: "status";
|
|
757
|
+
readonly description: "Refund status, if any.";
|
|
758
|
+
}];
|
|
419
759
|
readonly responses: {
|
|
420
760
|
readonly refunds: z.ZodArray<z.ZodObject<{
|
|
421
761
|
id: z.ZodString;
|
|
@@ -566,6 +906,7 @@ declare class StripeConnector extends BaseConnector<StripeSettings, StripeCreden
|
|
|
566
906
|
private buildListUrl;
|
|
567
907
|
private entityCreatedGte;
|
|
568
908
|
private eventCreatedGt;
|
|
909
|
+
private singleSpec;
|
|
569
910
|
private buildPhaseUrl;
|
|
570
911
|
private clearScopeOnFirstPage;
|
|
571
912
|
private writePhase;
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var doc = defineConnectorDoc({
|
|
|
55
55
|
tagline: "Sync customers, products, prices, subscriptions, and invoices alongside charge, payment, dispute, and refund events from your Stripe account.",
|
|
56
56
|
vendor: {
|
|
57
57
|
name: "Stripe",
|
|
58
|
+
domain: "stripe.com",
|
|
58
59
|
apiDocs: "https://stripe.com/docs/api",
|
|
59
60
|
website: "https://stripe.com"
|
|
60
61
|
},
|
|
@@ -104,6 +105,17 @@ var EVENT_NAME_BY_PHASE = {
|
|
|
104
105
|
disputes: "stripe_dispute",
|
|
105
106
|
refunds: "stripe_refund"
|
|
106
107
|
};
|
|
108
|
+
function pushableEq(filter, field) {
|
|
109
|
+
if (!filter) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
for (const clause of filter) {
|
|
113
|
+
if ("field" in clause && clause.field === field && clause.op === "eq" && typeof clause.value === "string") {
|
|
114
|
+
return clause.value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
107
119
|
function computeMrrAmountCents(subscription) {
|
|
108
120
|
let sum = 0;
|
|
109
121
|
let counted = 0;
|
|
@@ -242,57 +254,210 @@ var refundSchema = z.object({
|
|
|
242
254
|
var stripeResources = defineResources({
|
|
243
255
|
stripe_customer: {
|
|
244
256
|
shape: "entity",
|
|
257
|
+
filterable: [],
|
|
245
258
|
description: "Customers with email, name, default currency, and delinquency state.",
|
|
246
259
|
endpoint: "GET /v1/customers",
|
|
247
260
|
responses: { customers: z.array(customerSchema) }
|
|
248
261
|
},
|
|
249
262
|
stripe_product: {
|
|
250
263
|
shape: "entity",
|
|
264
|
+
filterable: [{ field: "active", ops: ["eq"], values: ["true", "false"] }],
|
|
251
265
|
description: "Products in your catalog, including active state.",
|
|
252
266
|
endpoint: "GET /v1/products",
|
|
253
267
|
responses: { products: z.array(productSchema) }
|
|
254
268
|
},
|
|
255
269
|
stripe_price: {
|
|
256
270
|
shape: "entity",
|
|
271
|
+
filterable: [{ field: "active", ops: ["eq"], values: ["true", "false"] }],
|
|
257
272
|
description: "Prices with unit amount, currency, and recurring interval, linked to their product.",
|
|
258
273
|
endpoint: "GET /v1/prices",
|
|
259
274
|
responses: { prices: z.array(priceSchema) }
|
|
260
275
|
},
|
|
261
276
|
stripe_subscription: {
|
|
262
277
|
shape: "entity",
|
|
278
|
+
filterable: [
|
|
279
|
+
{
|
|
280
|
+
field: "status",
|
|
281
|
+
ops: ["eq"],
|
|
282
|
+
values: [
|
|
283
|
+
"active",
|
|
284
|
+
"past_due",
|
|
285
|
+
"unpaid",
|
|
286
|
+
"canceled",
|
|
287
|
+
"incomplete",
|
|
288
|
+
"incomplete_expired",
|
|
289
|
+
"trialing",
|
|
290
|
+
"paused"
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
],
|
|
263
294
|
description: "Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).",
|
|
264
295
|
endpoint: "GET /v1/subscriptions",
|
|
265
296
|
notes: "mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).",
|
|
297
|
+
fields: [
|
|
298
|
+
{
|
|
299
|
+
name: "customerId",
|
|
300
|
+
description: "Customer the subscription belongs to."
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "status",
|
|
304
|
+
description: "Subscription status (active, canceled, ...)."
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: "planId",
|
|
308
|
+
description: "Price id of the first subscription item."
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "currentPeriodStart",
|
|
312
|
+
description: "Current period start (unix seconds)."
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: "currentPeriodEnd",
|
|
316
|
+
description: "Current period end (unix seconds)."
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "cancelAtPeriodEnd",
|
|
320
|
+
description: "Whether the subscription cancels at period end."
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "canceledAt",
|
|
324
|
+
description: "Cancellation time (unix seconds), if canceled."
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "trialEnd",
|
|
328
|
+
description: "Trial end time (unix seconds), if any."
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "mrrAmount",
|
|
332
|
+
description: "Monthly recurring revenue in the smallest currency unit.",
|
|
333
|
+
unit: "cents"
|
|
334
|
+
},
|
|
335
|
+
{ name: "currency", description: "ISO currency code." },
|
|
336
|
+
{ name: "created", description: "Creation time (unix seconds)." }
|
|
337
|
+
],
|
|
266
338
|
responses: { subscriptions: z.array(subscriptionSchema) }
|
|
267
339
|
},
|
|
268
340
|
stripe_invoice: {
|
|
269
341
|
shape: "entity",
|
|
342
|
+
filterable: [
|
|
343
|
+
{
|
|
344
|
+
field: "status",
|
|
345
|
+
ops: ["eq"],
|
|
346
|
+
values: ["draft", "open", "paid", "uncollectible", "void"]
|
|
347
|
+
}
|
|
348
|
+
],
|
|
270
349
|
description: "Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.",
|
|
271
350
|
endpoint: "GET /v1/invoices",
|
|
351
|
+
fields: [
|
|
352
|
+
{ name: "customerId", description: "Customer the invoice belongs to." },
|
|
353
|
+
{
|
|
354
|
+
name: "subscriptionId",
|
|
355
|
+
description: "Subscription the invoice belongs to, if any."
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
name: "status",
|
|
359
|
+
description: "Invoice status (draft, open, paid, ...)."
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
name: "amountDue",
|
|
363
|
+
description: "Amount due in the smallest currency unit.",
|
|
364
|
+
unit: "cents"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "amountPaid",
|
|
368
|
+
description: "Amount paid in the smallest currency unit.",
|
|
369
|
+
unit: "cents"
|
|
370
|
+
},
|
|
371
|
+
{ name: "currency", description: "ISO currency code." },
|
|
372
|
+
{ name: "created", description: "Creation time (unix seconds)." },
|
|
373
|
+
{ name: "dueDate", description: "Due date (unix seconds), if any." },
|
|
374
|
+
{ name: "hostedInvoiceUrl", description: "Hosted invoice URL, if any." }
|
|
375
|
+
],
|
|
272
376
|
responses: { invoices: z.array(invoiceSchema) }
|
|
273
377
|
},
|
|
274
378
|
stripe_charge: {
|
|
275
379
|
shape: "event",
|
|
380
|
+
filterable: [],
|
|
276
381
|
description: "Charge attempts with amount, currency, status, and failure code, timestamped at creation.",
|
|
277
382
|
endpoint: "GET /v1/charges",
|
|
383
|
+
fields: [
|
|
384
|
+
{ name: "id", description: "Stripe charge id." },
|
|
385
|
+
{ name: "customerId", description: "Customer charged, if any." },
|
|
386
|
+
{
|
|
387
|
+
name: "amount",
|
|
388
|
+
description: "Charge amount in the smallest currency unit.",
|
|
389
|
+
unit: "cents"
|
|
390
|
+
},
|
|
391
|
+
{ name: "currency", description: "ISO currency code." },
|
|
392
|
+
{
|
|
393
|
+
name: "status",
|
|
394
|
+
description: "Charge status (succeeded, failed, ...)."
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
name: "failureCode",
|
|
398
|
+
description: "Failure code, if the charge failed."
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
name: "paymentIntentId",
|
|
402
|
+
description: "Associated payment intent id, if any."
|
|
403
|
+
}
|
|
404
|
+
],
|
|
278
405
|
responses: { charges: z.array(chargeSchema) }
|
|
279
406
|
},
|
|
280
407
|
stripe_payment_intent: {
|
|
281
408
|
shape: "event",
|
|
409
|
+
filterable: [],
|
|
282
410
|
description: "Payment intents with amount, currency, and status, timestamped at creation.",
|
|
283
411
|
endpoint: "GET /v1/payment_intents",
|
|
412
|
+
fields: [
|
|
413
|
+
{ name: "id", description: "Stripe payment intent id." },
|
|
414
|
+
{ name: "customerId", description: "Customer, if any." },
|
|
415
|
+
{
|
|
416
|
+
name: "amount",
|
|
417
|
+
description: "Intent amount in the smallest currency unit.",
|
|
418
|
+
unit: "cents"
|
|
419
|
+
},
|
|
420
|
+
{ name: "currency", description: "ISO currency code." },
|
|
421
|
+
{ name: "status", description: "Payment intent status." }
|
|
422
|
+
],
|
|
284
423
|
responses: { payment_intents: z.array(paymentIntentSchema) }
|
|
285
424
|
},
|
|
286
425
|
stripe_dispute: {
|
|
287
426
|
shape: "event",
|
|
427
|
+
filterable: [],
|
|
288
428
|
description: "Disputes with amount, currency, reason, and status, linked to the disputed charge.",
|
|
289
429
|
endpoint: "GET /v1/disputes",
|
|
430
|
+
fields: [
|
|
431
|
+
{ name: "id", description: "Stripe dispute id." },
|
|
432
|
+
{ name: "chargeId", description: "Disputed charge id." },
|
|
433
|
+
{
|
|
434
|
+
name: "amount",
|
|
435
|
+
description: "Disputed amount in the smallest currency unit.",
|
|
436
|
+
unit: "cents"
|
|
437
|
+
},
|
|
438
|
+
{ name: "currency", description: "ISO currency code." },
|
|
439
|
+
{ name: "reason", description: "Dispute reason." },
|
|
440
|
+
{ name: "status", description: "Dispute status." }
|
|
441
|
+
],
|
|
290
442
|
responses: { disputes: z.array(disputeSchema) }
|
|
291
443
|
},
|
|
292
444
|
stripe_refund: {
|
|
293
445
|
shape: "event",
|
|
446
|
+
filterable: [],
|
|
294
447
|
description: "Refunds with amount, currency, reason, and status, linked to the refunded charge.",
|
|
295
448
|
endpoint: "GET /v1/refunds",
|
|
449
|
+
fields: [
|
|
450
|
+
{ name: "id", description: "Stripe refund id." },
|
|
451
|
+
{ name: "chargeId", description: "Refunded charge id, if any." },
|
|
452
|
+
{
|
|
453
|
+
name: "amount",
|
|
454
|
+
description: "Refunded amount in the smallest currency unit.",
|
|
455
|
+
unit: "cents"
|
|
456
|
+
},
|
|
457
|
+
{ name: "currency", description: "ISO currency code." },
|
|
458
|
+
{ name: "reason", description: "Refund reason, if any." },
|
|
459
|
+
{ name: "status", description: "Refund status, if any." }
|
|
460
|
+
],
|
|
296
461
|
responses: { refunds: z.array(refundSchema) }
|
|
297
462
|
}
|
|
298
463
|
});
|
|
@@ -358,10 +523,31 @@ var StripeConnector = class _StripeConnector extends BaseConnector {
|
|
|
358
523
|
}
|
|
359
524
|
return String(Math.floor(new Date(options.since).getTime() / 1e3));
|
|
360
525
|
}
|
|
526
|
+
singleSpec(options, resource) {
|
|
527
|
+
const specs = options.fetchSpecs?.[resource];
|
|
528
|
+
return specs && specs.length === 1 ? specs[0] : void 0;
|
|
529
|
+
}
|
|
361
530
|
buildPhaseUrl(phase, page, options) {
|
|
362
531
|
const startingAfter = page ?? void 0;
|
|
363
532
|
if (phase in ENTITY_TYPE_BY_PHASE) {
|
|
364
|
-
const extra =
|
|
533
|
+
const extra = {};
|
|
534
|
+
const filter = this.singleSpec(
|
|
535
|
+
options,
|
|
536
|
+
ENTITY_TYPE_BY_PHASE[phase]
|
|
537
|
+
)?.filter;
|
|
538
|
+
if (phase === "subscriptions" || phase === "invoices") {
|
|
539
|
+
const status = pushableEq(filter, "status");
|
|
540
|
+
if (phase === "subscriptions") {
|
|
541
|
+
extra.status = status ?? "all";
|
|
542
|
+
} else if (status !== null) {
|
|
543
|
+
extra.status = status;
|
|
544
|
+
}
|
|
545
|
+
} else if (phase === "products" || phase === "prices") {
|
|
546
|
+
const active = pushableEq(filter, "active");
|
|
547
|
+
if (active !== null) {
|
|
548
|
+
extra.active = active;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
365
551
|
return this.buildListUrl(phase, {
|
|
366
552
|
...extra,
|
|
367
553
|
starting_after: startingAfter,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../connector-shared/src/errors.ts","../../../connector-shared/src/retry.ts","../../../connector-shared/src/version.ts","../../../connector-shared/src/request.ts","../../../connector-shared/src/rate-limit.ts","../../../connector-shared/src/map-concurrent.ts","../../../connector-shared/src/sanitize.ts","../../../connector-shared/src/epoch.ts","../../../connector-shared/src/pagination.ts","../../../connector-shared/src/logger.ts","../src/stripe.ts","../src/index.ts"],"sourcesContent":["import type { HttpResponse } from './types';\n\nexport type HttpErrorKind =\n | 'transient'\n | 'rate_limit'\n | 'auth'\n | 'upstream_bug'\n | 'client_bug';\n\nexport abstract class HttpClientError extends Error {\n abstract readonly kind: HttpErrorKind;\n readonly response?: HttpResponse;\n\n constructor(message: string, response?: HttpResponse) {\n super(message);\n this.name = new.target.name;\n this.response = response;\n }\n}\n\nexport class TransientError extends HttpClientError {\n readonly kind = 'transient' as const;\n}\n\nexport class RateLimitError extends HttpClientError {\n readonly kind = 'rate_limit' as const;\n readonly retryAfter?: Date;\n\n constructor(message: string, response?: HttpResponse, retryAfter?: Date) {\n super(message, response);\n this.retryAfter = retryAfter;\n }\n}\n\nexport class AuthError extends HttpClientError {\n readonly kind = 'auth' as const;\n}\n\nexport class UpstreamBugError extends HttpClientError {\n readonly kind = 'upstream_bug' as const;\n}\n\nexport class ClientBugError extends HttpClientError {\n readonly kind = 'client_bug' as const;\n}\n\nexport function classifyStatus(status: number): HttpErrorKind {\n if (status === 429) {\n return 'rate_limit';\n }\n if (status === 401 || status === 403) {\n return 'auth';\n }\n if (status === 408) {\n return 'transient';\n }\n if (status >= 500) {\n return 'upstream_bug';\n }\n if (status >= 400) {\n return 'client_bug';\n }\n return 'client_bug';\n}\n\nexport function errorForStatus(\n message: string,\n response: HttpResponse,\n retryAfter?: Date,\n): HttpClientError {\n const kind = classifyStatus(response.status);\n switch (kind) {\n case 'rate_limit':\n return new RateLimitError(message, response, retryAfter);\n case 'auth':\n return new AuthError(message, response);\n case 'transient':\n return new TransientError(message, response);\n case 'upstream_bug':\n return new UpstreamBugError(message, response);\n case 'client_bug':\n return new ClientBugError(message, response);\n }\n}\n","import { HttpClientError, RateLimitError, TransientError } from './errors';\n\nexport interface RetryPolicy {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n retryOn?: (status: number | null, err?: Error) => boolean;\n}\n\nexport const defaultRetryOn = (status: number | null, err?: Error): boolean => {\n if (err instanceof RateLimitError) {\n return true;\n }\n if (err instanceof TransientError) {\n return true;\n }\n if (status === null) {\n return err instanceof Error && !(err instanceof HttpClientError);\n }\n if (status === 408 || status === 429) {\n return true;\n }\n if (status >= 500) {\n return true;\n }\n return false;\n};\n\nexport function backoffDelayMs(\n attempt: number,\n policy: Required<Pick<RetryPolicy, 'initialDelayMs' | 'maxDelayMs'>>,\n): number {\n const base = policy.initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, policy.maxDelayMs);\n}\n\nexport function parseRetryAfter(\n headerValue: string | null,\n now: Date = new Date(),\n): Date | undefined {\n if (!headerValue) {\n return undefined;\n }\n const trimmed = headerValue.trim();\n if (/^\\d+$/.test(trimmed)) {\n return new Date(now.getTime() + Number(trimmed) * 1000);\n }\n const parsed = Date.parse(trimmed);\n if (Number.isNaN(parsed)) {\n return undefined;\n }\n return new Date(parsed);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (signal?.aborted) {\n return Promise.reject(signal.reason ?? new Error('Aborted'));\n }\n return new Promise<void>((resolve, reject) => {\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal!.reason ?? new Error('Aborted'));\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n","export const HTTP_CLIENT_VERSION = '0.0.0';\n\nexport const DEFAULT_USER_AGENT = `rawdash-connector/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n\nexport function connectorUserAgent(connectorId: string): string {\n return `rawdash-connector-${connectorId}/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n}\n","import {\n AuthError,\n ClientBugError,\n HttpClientError,\n RateLimitError,\n TransientError,\n UpstreamBugError,\n errorForStatus,\n} from './errors';\nimport { defaultRetryOn, parseRetryAfter, sleep } from './retry';\nimport type { FetchLike, HttpMethod, HttpRequest, HttpResponse } from './types';\nimport { DEFAULT_USER_AGENT } from './version';\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_MAX_ATTEMPTS = 3;\nconst DEFAULT_INITIAL_DELAY_MS = 1000;\nconst DEFAULT_MAX_DELAY_MS = 60_000;\nconst OBSERVER_TIMEOUT_MS = 250;\n\nexport interface RequestObservation {\n url: string;\n method: HttpMethod;\n status: number;\n resource: string;\n requestId: string;\n body: unknown;\n}\n\nexport type RequestObserver = (\n event: RequestObservation,\n) => void | Promise<void>;\n\nexport interface RequestOptions {\n fetch?: FetchLike;\n observer?: RequestObserver;\n resource: string;\n requestId?: string;\n}\n\nasync function notifyObserver(\n observer: RequestObserver,\n event: RequestObservation,\n): Promise<void> {\n let result: void | Promise<void>;\n try {\n result = observer(event);\n } catch (err) {\n console.warn('[connector-shared] request observer threw:', err);\n return;\n }\n if (!(result instanceof Promise)) {\n return;\n }\n const guarded = result.catch((err) => {\n console.warn('[connector-shared] request observer rejected:', err);\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<void>((resolve) => {\n timer = setTimeout(resolve, OBSERVER_TIMEOUT_MS);\n });\n try {\n await Promise.race([guarded, timeout]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n\nfunction newRequestId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) {\n return c.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nfunction mergeHeaders(\n defaults: Record<string, string>,\n overrides: Record<string, string> | undefined,\n): Record<string, string> {\n const merged: Record<string, string> = {};\n for (const [k, v] of Object.entries(defaults)) {\n merged[k.toLowerCase()] = v;\n }\n if (overrides) {\n for (const [k, v] of Object.entries(overrides)) {\n merged[k.toLowerCase()] = v;\n }\n }\n return merged;\n}\n\nfunction linkTimeoutSignal(\n parent: AbortSignal | undefined,\n timeoutMs: number,\n): { signal: AbortSignal; cancel: () => void } {\n const controller = new AbortController();\n const onParentAbort = () => {\n controller.abort(parent?.reason);\n };\n if (parent) {\n if (parent.aborted) {\n controller.abort(parent.reason);\n } else {\n parent.addEventListener('abort', onParentAbort, { once: true });\n }\n }\n const timer = setTimeout(() => {\n controller.abort(new Error(`Request timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n return {\n signal: controller.signal,\n cancel: () => {\n clearTimeout(timer);\n if (parent) {\n parent.removeEventListener('abort', onParentAbort);\n }\n },\n };\n}\n\nasync function readBody(res: Response, parseJson: boolean): Promise<unknown> {\n if (res.status === 204 || res.status === 205) {\n return null;\n }\n const contentType = res.headers.get('content-type') ?? '';\n if (parseJson && contentType.includes('application/json')) {\n const text = await res.text();\n if (text.length === 0) {\n return null;\n }\n return JSON.parse(text);\n }\n return res.text();\n}\n\nexport async function request<T = unknown>(\n req: HttpRequest,\n options: RequestOptions,\n): Promise<HttpResponse<T>> {\n const fetchImpl: FetchLike = options.fetch ?? (globalThis.fetch as FetchLike);\n const retry = req.retry ?? {};\n const maxAttempts = retry.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;\n const initialDelayMs = retry.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;\n const maxDelayMs = retry.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;\n const retryOn = retry.retryOn ?? defaultRetryOn;\n const timeoutMs = req.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const parseJson = req.parseJson ?? true;\n\n const headers = mergeHeaders(\n {\n 'User-Agent': DEFAULT_USER_AGENT,\n Accept: 'application/json',\n },\n req.headers,\n );\n\n let lastErr: Error | undefined;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n req.signal?.throwIfAborted();\n\n const { signal, cancel } = linkTimeoutSignal(req.signal, timeoutMs);\n let res: Response;\n try {\n res = await fetchImpl(req.url, {\n method: req.method ?? 'GET',\n headers,\n body: req.body as RequestInit['body'],\n signal,\n });\n } catch (err) {\n cancel();\n if (req.signal?.aborted) {\n throw req.signal.reason ?? err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n lastErr = error;\n if (attempt < maxAttempts - 1 && retryOn(null, error)) {\n const delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n await sleep(delay, req.signal);\n continue;\n }\n throw new TransientError(error.message);\n }\n cancel();\n\n const body = await readBody(res, parseJson);\n const httpResponse: HttpResponse<T> = {\n status: res.status,\n headers: res.headers,\n body: body as T,\n };\n if (req.rateLimit) {\n const state = req.rateLimit.parse(res.headers);\n if (state) {\n httpResponse.rateLimitState = state;\n }\n }\n\n if (options.observer) {\n await notifyObserver(options.observer, {\n url: req.url,\n method: req.method ?? 'GET',\n status: res.status,\n resource: options.resource,\n requestId: options.requestId ?? newRequestId(),\n body,\n });\n }\n\n if (res.ok) {\n return httpResponse;\n }\n\n const retryAfter = parseRetryAfter(res.headers.get('retry-after'));\n const message = `HTTP ${res.status} ${res.statusText} for ${req.method ?? 'GET'} ${req.url}`;\n const err = errorForStatus(message, httpResponse, retryAfter);\n\n if (\n attempt < maxAttempts - 1 &&\n retryOn(res.status, err) &&\n !(err instanceof AuthError) &&\n !(err instanceof ClientBugError)\n ) {\n lastErr = err;\n let delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n if (err instanceof RateLimitError && retryAfter) {\n const wait = retryAfter.getTime() - Date.now();\n if (wait > 0) {\n delay = Math.min(wait, maxDelayMs);\n }\n }\n await sleep(delay, req.signal);\n continue;\n }\n\n throw err;\n }\n\n throw lastErr ?? new UpstreamBugError('Exhausted retry attempts');\n}\n\nfunction computeDelay(\n attempt: number,\n initialDelayMs: number,\n maxDelayMs: number,\n): number {\n const base = initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, maxDelayMs);\n}\n\nexport { HttpClientError };\n","export interface RateLimitState {\n remaining: number;\n resetAt: Date;\n}\n\nexport interface RateLimitPolicy {\n parse(headers: Headers): RateLimitState | null;\n}\n\nexport interface StandardRateLimitPolicyConfig {\n remainingHeader: string;\n resetHeader: string;\n resetUnit: 's' | 'ms';\n resetFallbackMs?: number;\n}\n\nexport function standardRateLimitPolicy(\n config: StandardRateLimitPolicyConfig,\n): RateLimitPolicy {\n const { remainingHeader, resetHeader, resetUnit, resetFallbackMs } = config;\n const multiplier = resetUnit === 's' ? 1000 : 1;\n return {\n parse(h) {\n const remainingRaw = h.get(remainingHeader);\n if (remainingRaw === null || remainingRaw.trim() === '') {\n return null;\n }\n const remaining = Number(remainingRaw);\n if (!Number.isFinite(remaining)) {\n return null;\n }\n const resetRaw = h.get(resetHeader);\n if (resetRaw === null) {\n if (resetFallbackMs === undefined) {\n return null;\n }\n return {\n remaining,\n resetAt: new Date(Date.now() + resetFallbackMs),\n };\n }\n if (resetRaw.trim() === '') {\n return null;\n }\n const reset = Number(resetRaw);\n if (!Number.isFinite(reset) || reset < 0) {\n return null;\n }\n const resetMs = reset * multiplier;\n if (!Number.isFinite(resetMs)) {\n return null;\n }\n return { remaining, resetAt: new Date(resetMs) };\n },\n };\n}\n","export async function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n if (items.length === 0) {\n return results;\n }\n const normalized = Number.isFinite(concurrency) ? Math.floor(concurrency) : 1;\n const limit = Math.max(1, Math.min(normalized, items.length));\n let next = 0;\n let failed = false;\n\n async function worker(): Promise<void> {\n while (!failed) {\n const i = next++;\n if (i >= items.length) {\n return;\n }\n try {\n results[i] = await fn(items[i]!, i);\n } catch (err) {\n failed = true;\n throw err;\n }\n }\n }\n\n const workers: Promise<void>[] = [];\n for (let w = 0; w < limit; w++) {\n workers.push(worker());\n }\n await Promise.all(workers);\n return results;\n}\n","export interface SanitizeAllowedUrlOptions {\n url: string | null;\n host: string;\n pathname: string;\n protocol?: 'https:' | 'http:';\n}\n\nexport function sanitizeAllowedUrl(\n options: SanitizeAllowedUrlOptions,\n): string | null {\n const { url, host, pathname, protocol = 'https:' } = options;\n if (url === null) {\n return null;\n }\n try {\n const u = new URL(url);\n if (u.protocol !== protocol || u.host !== host || u.pathname !== pathname) {\n return null;\n }\n return u.toString();\n } catch {\n return null;\n }\n}\n","export type EpochUnit = 'ms' | 's' | 'iso';\n\nexport function parseEpoch(\n value: number | string | null | undefined,\n unit: EpochUnit,\n): number | null {\n if (value === null || value === undefined) {\n return null;\n }\n if (unit === 'iso') {\n if (typeof value !== 'string') {\n return null;\n }\n const ms = new Date(value).getTime();\n return Number.isFinite(ms) ? ms : null;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return null;\n }\n const n = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(n)) {\n return null;\n }\n const result = unit === 's' ? n * 1000 : n;\n return Number.isFinite(result) ? result : null;\n}\n","import { request } from './request';\nimport type { HttpRequest } from './types';\n\nexport function parseLinkHeader(header: string | null): Record<string, string> {\n if (!header) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const part of header.split(',')) {\n const match = part.match(/<([^>]+)>\\s*;\\s*rel=\"([^\"]+)\"/);\n if (match) {\n result[match[2]!] = match[1]!;\n }\n }\n return result;\n}\n\nexport async function* paginateLink<T>(\n initial: HttpRequest,\n parse: (body: unknown) => T[],\n options: { resource: string },\n): AsyncIterable<T> {\n let next: string | null = initial.url;\n while (next) {\n const res: Awaited<ReturnType<typeof request>> = await request(\n {\n ...initial,\n url: next,\n },\n { resource: options.resource },\n );\n for (const item of parse(res.body)) {\n yield item;\n }\n const links = parseLinkHeader(res.headers.get('link'));\n next = links['next'] ?? null;\n }\n}\n\nexport async function* paginateCursor<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; nextCursor: string | null },\n buildNext: (req: HttpRequest, cursor: string) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let req: HttpRequest = initial;\n while (true) {\n const res = await request(req, { resource: options.resource });\n const { items, nextCursor } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!nextCursor) {\n return;\n }\n req = buildNext(req, nextCursor);\n }\n}\n\nexport async function* paginatePage<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; hasMore: boolean },\n buildPage: (req: HttpRequest, page: number) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let page = 1;\n while (true) {\n const req = page === 1 ? initial : buildPage(initial, page);\n const res = await request(req, { resource: options.resource });\n const { items, hasMore } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!hasMore || items.length === 0) {\n return;\n }\n page++;\n }\n}\n","export type LogFields = Record<string, unknown>;\n\nexport interface ConnectorLogger {\n info(event: string, fields?: LogFields): void;\n warn(event: string, fields?: LogFields): void;\n}\n\nexport interface ConnectorLoggerOptions {\n scope: string;\n}\n\nconst MAX_VALUE_LEN = 120;\n\nfunction truncate(s: string, max = MAX_VALUE_LEN): string {\n if (s.length <= max) {\n return s;\n }\n return `${s.slice(0, max - 1)}…`;\n}\n\nfunction formatValue(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return '';\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'string') {\n const t = truncate(value);\n if (/[\\s\"=]/.test(t)) {\n return JSON.stringify(t);\n }\n return t;\n }\n if (typeof value === 'bigint') {\n return value.toString();\n }\n let json: string | undefined;\n try {\n json = JSON.stringify(value);\n } catch {\n json = undefined;\n }\n return truncate(json ?? String(value));\n}\n\nexport function formatLogFields(fields?: LogFields): string {\n if (!fields) {\n return '';\n }\n const parts: string[] = [];\n for (const [k, v] of Object.entries(fields)) {\n if (v === undefined) {\n continue;\n }\n parts.push(`${k}=${formatValue(v)}`);\n }\n return parts.length > 0 ? ` ${parts.join(' ')}` : '';\n}\n\nexport function formatLogLine(\n scope: string,\n event: string,\n fields?: LogFields,\n): string {\n return `[${scope}] ${event}${formatLogFields(fields)}`;\n}\n\nexport function createDefaultConnectorLogger(\n opts: ConnectorLoggerOptions,\n): ConnectorLogger {\n return {\n info(event, fields) {\n console.info(formatLogLine(opts.scope, event, fields));\n },\n warn(event, fields) {\n console.warn(formatLogLine(opts.scope, event, fields));\n },\n };\n}\n\nconst NOOP_LOGGER: ConnectorLogger = {\n info() {},\n warn() {},\n};\n\nexport function noopConnectorLogger(): ConnectorLogger {\n return NOOP_LOGGER;\n}\n","import {\n type HttpResponse,\n connectorUserAgent,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ConnectorContext,\n type ConnectorDoc,\n type CredentialsSchema,\n type StorageHandle,\n type SyncOptions,\n type SyncResult,\n defineConfigFields,\n defineConnectorDoc,\n defineResources,\n makeChunkedCursorGuard,\n paginateChunked,\n schemasFromResources,\n selectActivePhases,\n} from '@rawdash/core';\nimport { z } from 'zod';\n\nexport const configFields = defineConfigFields(\n z.object({\n apiKey: z.object({ $secret: z.string() }).meta({\n label: 'API Key',\n description:\n 'Stripe Restricted API key with read-only access. Create one at Dashboard → Developers → API keys.',\n placeholder: 'rk_live_...',\n secret: true,\n }),\n accountId: z.string().optional().meta({\n label: 'Account ID (optional)',\n description:\n 'Stripe Connect account ID. Only needed if you are a platform accessing a connected account.',\n placeholder: 'acct_...',\n }),\n resources: z\n .array(\n z.enum([\n 'customers',\n 'products',\n 'prices',\n 'subscriptions',\n 'invoices',\n 'charges',\n 'payment_intents',\n 'disputes',\n 'refunds',\n ]),\n )\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n 'Which Stripe resources to sync. Omit to sync all resources. The API key only needs Read scope for the resources listed here.',\n }),\n }),\n);\n\nexport const doc: ConnectorDoc = defineConnectorDoc({\n displayName: 'Stripe',\n category: 'finance',\n brandColor: '#635BFF',\n tagline:\n 'Sync customers, products, prices, subscriptions, and invoices alongside charge, payment, dispute, and refund events from your Stripe account.',\n vendor: {\n name: 'Stripe',\n apiDocs: 'https://stripe.com/docs/api',\n website: 'https://stripe.com',\n },\n auth: {\n summary:\n 'Authenticates with a Stripe restricted API key that has read-only access to the resources you want to sync.',\n setup: [\n 'Open the Stripe Dashboard → Developers → API keys.',\n 'Create a restricted key with Read access for the resources you plan to sync (customers, products, prices, subscriptions, invoices, charges, payment intents, disputes, refunds).',\n 'Store the key as a secret and reference it from the connector config as `apiKey: secret(\"STRIPE_API_KEY\")`.',\n ],\n },\n rateLimit:\n 'Stripe 429 responses carry a Retry-After header; requests are retried with exponential backoff. List pagination uses the starting_after cursor (limit 100).',\n limitations: [\n 'Monetary amounts are stored in the smallest currency unit (e.g. cents), matching the Stripe API.',\n 'The set of synced resources is controlled by the `resources` config field; omit it to sync all of them.',\n 'Incremental syncs use a 7-day lookback for entities and created[gt] for events.',\n ],\n});\n\nexport interface StripeSettings {\n accountId?: string;\n resources?: readonly StripeResource[];\n}\n\ninterface StripeListResponse<T> {\n object: 'list';\n data: T[];\n has_more: boolean;\n url: string;\n}\n\ninterface StripeCustomer {\n id: string;\n email: string | null;\n name: string | null;\n created: number;\n currency: string | null;\n delinquent: boolean | null;\n livemode: boolean;\n}\n\ninterface StripePriceRecurring {\n interval: 'day' | 'week' | 'month' | 'year';\n interval_count: number;\n}\n\ninterface StripePrice {\n id: string;\n product: string;\n unit_amount: number | null;\n currency: string;\n recurring: StripePriceRecurring | null;\n active: boolean;\n created: number;\n}\n\ninterface StripeSubscriptionItem {\n price: StripePrice;\n quantity: number | null;\n}\n\ninterface StripeSubscription {\n id: string;\n customer: string;\n status: string;\n items: { data: StripeSubscriptionItem[] };\n current_period_start: number;\n current_period_end: number;\n cancel_at_period_end: boolean;\n canceled_at: number | null;\n trial_end: number | null;\n currency: string;\n created: number;\n}\n\ninterface StripeInvoice {\n id: string;\n customer: string | null;\n subscription: string | null;\n status: string | null;\n amount_due: number;\n amount_paid: number;\n currency: string;\n created: number;\n due_date: number | null;\n hosted_invoice_url: string | null;\n}\n\ninterface StripeCharge {\n id: string;\n customer: string | null;\n amount: number;\n currency: string;\n status: string;\n failure_code: string | null;\n created: number;\n payment_intent: string | null;\n}\n\ninterface StripePaymentIntent {\n id: string;\n customer: string | null;\n amount: number;\n currency: string;\n status: string;\n created: number;\n}\n\ninterface StripeProduct {\n id: string;\n name: string;\n active: boolean;\n created: number;\n}\n\ninterface StripeDispute {\n id: string;\n charge: string;\n amount: number;\n currency: string;\n reason: string;\n status: string;\n created: number;\n}\n\ninterface StripeRefund {\n id: string;\n charge: string | null;\n amount: number;\n currency: string;\n reason: string | null;\n status: string | null;\n created: number;\n}\n\nconst stripeCredentials = {\n apiKey: {\n description: 'Stripe API key',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype StripeCredentials = typeof stripeCredentials;\n\nconst PHASE_ORDER = [\n 'customers',\n 'products',\n 'prices',\n 'subscriptions',\n 'invoices',\n 'charges',\n 'payment_intents',\n 'disputes',\n 'refunds',\n] as const;\n\ntype StripePhase = (typeof PHASE_ORDER)[number];\n\nexport type StripeResource = StripePhase;\n\nconst isStripeSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\nconst ENTITY_TYPE_BY_PHASE: Partial<Record<StripePhase, string>> = {\n customers: 'stripe_customer',\n products: 'stripe_product',\n prices: 'stripe_price',\n subscriptions: 'stripe_subscription',\n invoices: 'stripe_invoice',\n};\n\nconst EVENT_NAME_BY_PHASE: Partial<Record<StripePhase, string>> = {\n charges: 'stripe_charge',\n payment_intents: 'stripe_payment_intent',\n disputes: 'stripe_dispute',\n refunds: 'stripe_refund',\n};\n\nexport function computeMrrAmountCents(\n subscription: StripeSubscription,\n): number | null {\n let sum = 0;\n let counted = 0;\n for (const item of subscription.items.data) {\n const { unit_amount, recurring } = item.price;\n if (unit_amount === null || unit_amount === undefined || !recurring) {\n continue;\n }\n const quantity = item.quantity ?? 1;\n const total = unit_amount * quantity;\n const intervalCount = recurring.interval_count || 1;\n let monthly: number | null;\n switch (recurring.interval) {\n case 'month':\n monthly = total / intervalCount;\n break;\n case 'year':\n monthly = total / (12 * intervalCount);\n break;\n case 'week':\n monthly = (total * 52) / (12 * intervalCount);\n break;\n case 'day':\n monthly = (total * 365) / (12 * intervalCount);\n break;\n default:\n monthly = null;\n }\n if (monthly === null) {\n continue;\n }\n sum += monthly;\n counted++;\n }\n if (counted === 0) {\n return null;\n }\n return Math.round(sum);\n}\n\nconst idString = z.string().min(1);\n\nconst customerSchema = z.object({\n id: idString,\n email: z.string().nullable(),\n name: z.string().nullable(),\n created: z.number().int().nonnegative(),\n currency: z.string().nullable(),\n delinquent: z.boolean().nullable(),\n livemode: z.boolean(),\n});\n\nconst productSchema = z.object({\n id: idString,\n name: z.string(),\n active: z.boolean(),\n created: z.number().int().nonnegative(),\n});\n\nconst priceSchema = z.object({\n id: idString,\n product: idString,\n unit_amount: z.number().int().nullable(),\n currency: z.string(),\n recurring: z\n .object({\n interval: z.enum(['day', 'week', 'month', 'year']),\n interval_count: z.number().int().positive(),\n })\n .nullable(),\n active: z.boolean(),\n created: z.number().int().nonnegative(),\n});\n\nconst subscriptionSchema = z.object({\n id: idString,\n customer: idString,\n status: z.string(),\n items: z.object({\n data: z.array(\n z.object({\n price: priceSchema,\n quantity: z.number().int().nullable(),\n }),\n ),\n }),\n current_period_start: z.number().int().nonnegative(),\n current_period_end: z.number().int().nonnegative(),\n cancel_at_period_end: z.boolean(),\n canceled_at: z.number().int().nullable(),\n trial_end: z.number().int().nullable(),\n currency: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst invoiceSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n subscription: idString.nullable(),\n status: z.string().nullable(),\n amount_due: z.number().int(),\n amount_paid: z.number().int(),\n currency: z.string(),\n created: z.number().int().nonnegative(),\n due_date: z.number().int().nullable(),\n hosted_invoice_url: z.string().nullable(),\n});\n\nconst chargeSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n status: z.string(),\n failure_code: z.string().nullable(),\n created: z.number().int().nonnegative(),\n payment_intent: idString.nullable(),\n});\n\nconst paymentIntentSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n status: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst disputeSchema = z.object({\n id: idString,\n charge: idString,\n amount: z.number().int(),\n currency: z.string(),\n reason: z.string(),\n status: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst refundSchema = z.object({\n id: idString,\n charge: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n reason: z.string().nullable(),\n status: z.string().nullable(),\n created: z.number().int().nonnegative(),\n});\n\nexport const stripeResources = defineResources({\n stripe_customer: {\n shape: 'entity',\n description:\n 'Customers with email, name, default currency, and delinquency state.',\n endpoint: 'GET /v1/customers',\n responses: { customers: z.array(customerSchema) },\n },\n stripe_product: {\n shape: 'entity',\n description: 'Products in your catalog, including active state.',\n endpoint: 'GET /v1/products',\n responses: { products: z.array(productSchema) },\n },\n stripe_price: {\n shape: 'entity',\n description:\n 'Prices with unit amount, currency, and recurring interval, linked to their product.',\n endpoint: 'GET /v1/prices',\n responses: { prices: z.array(priceSchema) },\n },\n stripe_subscription: {\n shape: 'entity',\n description:\n 'Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).',\n endpoint: 'GET /v1/subscriptions',\n notes:\n 'mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).',\n responses: { subscriptions: z.array(subscriptionSchema) },\n },\n stripe_invoice: {\n shape: 'entity',\n description:\n 'Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.',\n endpoint: 'GET /v1/invoices',\n responses: { invoices: z.array(invoiceSchema) },\n },\n stripe_charge: {\n shape: 'event',\n description:\n 'Charge attempts with amount, currency, status, and failure code, timestamped at creation.',\n endpoint: 'GET /v1/charges',\n responses: { charges: z.array(chargeSchema) },\n },\n stripe_payment_intent: {\n shape: 'event',\n description:\n 'Payment intents with amount, currency, and status, timestamped at creation.',\n endpoint: 'GET /v1/payment_intents',\n responses: { payment_intents: z.array(paymentIntentSchema) },\n },\n stripe_dispute: {\n shape: 'event',\n description:\n 'Disputes with amount, currency, reason, and status, linked to the disputed charge.',\n endpoint: 'GET /v1/disputes',\n responses: { disputes: z.array(disputeSchema) },\n },\n stripe_refund: {\n shape: 'event',\n description:\n 'Refunds with amount, currency, reason, and status, linked to the refunded charge.',\n endpoint: 'GET /v1/refunds',\n responses: { refunds: z.array(refundSchema) },\n },\n});\n\nexport const id = 'stripe';\n\nexport class StripeConnector extends BaseConnector<\n StripeSettings,\n StripeCredentials\n> {\n static readonly id = id;\n\n static readonly resources = stripeResources;\n\n static readonly schemas = schemasFromResources(stripeResources);\n\n static create(input: unknown, ctx?: ConnectorContext): StripeConnector {\n const parsed = configFields.parse(input);\n return new StripeConnector(\n { accountId: parsed.accountId, resources: parsed.resources },\n { apiKey: parsed.apiKey },\n ctx,\n );\n }\n\n readonly id = id;\n override readonly credentials = stripeCredentials;\n\n private buildHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.creds.apiKey}`,\n 'Stripe-Version': '2024-06-20',\n 'User-Agent': connectorUserAgent('stripe'),\n };\n if (this.settings.accountId) {\n headers['Stripe-Account'] = this.settings.accountId;\n }\n return headers;\n }\n\n private fetch<T>(\n url: string,\n resource: string,\n signal?: AbortSignal,\n ): Promise<HttpResponse<T>> {\n return this.get<T>(url, {\n resource,\n headers: this.buildHeaders(),\n signal,\n });\n }\n\n private buildListUrl(\n path: string,\n params: Record<string, string | undefined>,\n ): string {\n const url = new URL(`https://api.stripe.com/v1/${path}`);\n url.searchParams.set('limit', '100');\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n return url.toString();\n }\n\n private entityCreatedGte(\n phase: StripePhase,\n options: SyncOptions,\n ): string | undefined {\n if (!options.since) {\n return undefined;\n }\n const sinceMs = new Date(options.since).getTime();\n if (options.mode === 'latest') {\n return String(Math.floor((sinceMs - 7 * 24 * 60 * 60 * 1000) / 1000));\n }\n if (phase === 'subscriptions') {\n return undefined;\n }\n return String(Math.floor(sinceMs / 1000));\n }\n\n private eventCreatedGt(options: SyncOptions): string | undefined {\n if (!options.since) {\n return undefined;\n }\n return String(Math.floor(new Date(options.since).getTime() / 1000));\n }\n\n private buildPhaseUrl(\n phase: StripePhase,\n page: string | null,\n options: SyncOptions,\n ): string {\n const startingAfter = page ?? undefined;\n if (phase in ENTITY_TYPE_BY_PHASE) {\n const extra: Record<string, string | undefined> =\n phase === 'subscriptions' ? { status: 'all' } : {};\n return this.buildListUrl(phase, {\n ...extra,\n starting_after: startingAfter,\n 'created[gte]': this.entityCreatedGte(phase, options),\n });\n }\n return this.buildListUrl(phase, {\n starting_after: startingAfter,\n 'created[gt]': this.eventCreatedGt(options),\n });\n }\n\n private async clearScopeOnFirstPage(\n storage: StorageHandle,\n phase: StripePhase,\n ): Promise<void> {\n const entityType = ENTITY_TYPE_BY_PHASE[phase];\n if (entityType) {\n await storage.entities([], { types: [entityType] });\n return;\n }\n const eventName = EVENT_NAME_BY_PHASE[phase];\n if (eventName) {\n await storage.events([], { names: [eventName] });\n }\n }\n\n private async writePhase(\n storage: StorageHandle,\n phase: StripePhase,\n items: unknown[],\n ): Promise<void> {\n switch (phase) {\n case 'customers':\n for (const c of items as StripeCustomer[]) {\n await storage.entity({\n type: 'stripe_customer',\n id: c.id,\n attributes: {\n email: c.email ?? null,\n name: c.name ?? null,\n created: c.created,\n currency: c.currency ?? null,\n delinquent: c.delinquent ?? false,\n livemode: c.livemode,\n },\n updated_at: c.created * 1000,\n });\n }\n return;\n case 'products':\n for (const p of items as StripeProduct[]) {\n await storage.entity({\n type: 'stripe_product',\n id: p.id,\n attributes: { name: p.name, active: p.active, created: p.created },\n updated_at: p.created * 1000,\n });\n }\n return;\n case 'prices':\n for (const p of items as StripePrice[]) {\n await storage.entity({\n type: 'stripe_price',\n id: p.id,\n attributes: {\n productId: p.product,\n unitAmount: p.unit_amount ?? null,\n currency: p.currency,\n interval: p.recurring?.interval ?? null,\n intervalCount: p.recurring?.interval_count ?? null,\n active: p.active,\n created: p.created,\n },\n updated_at: p.created * 1000,\n });\n }\n return;\n case 'subscriptions':\n for (const s of items as StripeSubscription[]) {\n await storage.entity({\n type: 'stripe_subscription',\n id: s.id,\n attributes: {\n customerId: s.customer,\n status: s.status,\n planId: s.items.data[0]?.price.id ?? null,\n currentPeriodStart: s.current_period_start,\n currentPeriodEnd: s.current_period_end,\n cancelAtPeriodEnd: s.cancel_at_period_end,\n canceledAt: s.canceled_at ?? null,\n trialEnd: s.trial_end ?? null,\n mrrAmount: computeMrrAmountCents(s),\n currency: s.currency,\n created: s.created,\n },\n updated_at: s.current_period_end * 1000,\n });\n }\n return;\n case 'invoices':\n for (const inv of items as StripeInvoice[]) {\n await storage.entity({\n type: 'stripe_invoice',\n id: inv.id,\n attributes: {\n customerId: inv.customer ?? null,\n subscriptionId: inv.subscription ?? null,\n status: inv.status ?? null,\n amountDue: inv.amount_due,\n amountPaid: inv.amount_paid,\n currency: inv.currency,\n created: inv.created,\n dueDate: inv.due_date ?? null,\n hostedInvoiceUrl: inv.hosted_invoice_url ?? null,\n },\n updated_at: inv.created * 1000,\n });\n }\n return;\n case 'charges':\n for (const c of items as StripeCharge[]) {\n await storage.event({\n name: 'stripe_charge',\n start_ts: c.created * 1000,\n end_ts: null,\n attributes: {\n id: c.id,\n customerId: c.customer ?? null,\n amount: c.amount,\n currency: c.currency,\n status: c.status,\n failureCode: c.failure_code ?? null,\n paymentIntentId: c.payment_intent ?? null,\n },\n });\n }\n return;\n case 'payment_intents':\n for (const pi of items as StripePaymentIntent[]) {\n await storage.event({\n name: 'stripe_payment_intent',\n start_ts: pi.created * 1000,\n end_ts: null,\n attributes: {\n id: pi.id,\n customerId: pi.customer ?? null,\n amount: pi.amount,\n currency: pi.currency,\n status: pi.status,\n },\n });\n }\n return;\n case 'disputes':\n for (const d of items as StripeDispute[]) {\n await storage.event({\n name: 'stripe_dispute',\n start_ts: d.created * 1000,\n end_ts: null,\n attributes: {\n id: d.id,\n chargeId: d.charge,\n amount: d.amount,\n currency: d.currency,\n reason: d.reason,\n status: d.status,\n },\n });\n }\n return;\n case 'refunds':\n for (const r of items as StripeRefund[]) {\n await storage.event({\n name: 'stripe_refund',\n start_ts: r.created * 1000,\n end_ts: null,\n attributes: {\n id: r.id,\n chargeId: r.charge ?? null,\n amount: r.amount,\n currency: r.currency,\n reason: r.reason ?? null,\n status: r.status ?? null,\n },\n });\n }\n return;\n }\n }\n\n async sync(\n options: SyncOptions,\n storage: StorageHandle,\n signal?: AbortSignal,\n ): Promise<SyncResult> {\n const cursor = isStripeSyncCursor(options.cursor)\n ? options.cursor\n : undefined;\n const isFull = options.mode === 'full';\n\n const phases = selectActivePhases<StripeResource, StripePhase>(\n (r) => r,\n PHASE_ORDER,\n this.settings.resources,\n );\n\n return paginateChunked<StripePhase, string>({\n phases,\n cursor,\n signal,\n logger: this.logger,\n fetchPage: async (phase, page, sig) => {\n const url = this.buildPhaseUrl(phase, page, options);\n const res = await this.fetch<StripeListResponse<{ id: string }>>(\n url,\n phase,\n sig,\n );\n const { data, has_more } = res.body;\n const next = has_more && data.length > 0 ? data.at(-1)!.id : null;\n return { items: data, next };\n },\n writeBatch: async (phase, items, page) => {\n if (isFull && page === null) {\n await this.clearScopeOnFirstPage(storage, phase);\n }\n await this.writePhase(storage, phase, items);\n },\n });\n }\n}\n","import { StripeConnector } from './stripe';\n\nexport {\n configFields,\n doc,\n StripeConnector,\n computeMrrAmountCents,\n stripeResources as resources,\n id,\n} from './stripe';\nexport type { StripeSettings } from './stripe';\nexport default StripeConnector;\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AAEnE,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,qBAAqB,WAAW,IAAI,mBAAmB;AAChE;;;AQFA;AAAA,EACE;AAAA,EAOA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAEX,IAAM,eAAe;AAAA,EAC1B,EAAE,OAAO;AAAA,IACP,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK;AAAA,MAC7C,OAAO;AAAA,MACP,aACE;AAAA,MACF,aAAa;AAAA,MACb,QAAQ;AAAA,IACV,CAAC;AAAA,IACD,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK;AAAA,MACpC,OAAO;AAAA,MACP,aACE;AAAA,MACF,aAAa;AAAA,IACf,CAAC;AAAA,IACD,WAAW,EACR;AAAA,MACC,EAAE,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAC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MACA;AAAA,MACA;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,WAAW,OAAO,OAAO,MAAM,QAAQ;AACrC,cAAM,MAAM,KAAK,cAAc,OAAO,MAAM,OAAO;AACnD,cAAM,MAAM,MAAM,KAAK;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AACA,cAAM,EAAE,MAAM,SAAS,IAAI,IAAI;AAC/B,cAAM,OAAO,YAAY,KAAK,SAAS,IAAI,KAAK,GAAG,EAAE,EAAG,KAAK;AAC7D,eAAO,EAAE,OAAO,MAAM,KAAK;AAAA,MAC7B;AAAA,MACA,YAAY,OAAO,OAAO,OAAO,SAAS;AACxC,YAAI,UAAU,SAAS,MAAM;AAC3B,gBAAM,KAAK,sBAAsB,SAAS,KAAK;AAAA,QACjD;AACA,cAAM,KAAK,WAAW,SAAS,OAAO,KAAK;AAAA,MAC7C;AAAA,IACF,CAAC;AAAA,EACH;AACF;;;AC5wBA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../connector-shared/src/errors.ts","../../../connector-shared/src/retry.ts","../../../connector-shared/src/version.ts","../../../connector-shared/src/request.ts","../../../connector-shared/src/rate-limit.ts","../../../connector-shared/src/map-concurrent.ts","../../../connector-shared/src/sanitize.ts","../../../connector-shared/src/epoch.ts","../../../connector-shared/src/pagination.ts","../../../connector-shared/src/logger.ts","../src/stripe.ts","../src/index.ts"],"sourcesContent":["import type { HttpResponse } from './types';\n\nexport type HttpErrorKind =\n | 'transient'\n | 'rate_limit'\n | 'auth'\n | 'upstream_bug'\n | 'client_bug';\n\nexport abstract class HttpClientError extends Error {\n abstract readonly kind: HttpErrorKind;\n readonly response?: HttpResponse;\n\n constructor(message: string, response?: HttpResponse) {\n super(message);\n this.name = new.target.name;\n this.response = response;\n }\n}\n\nexport class TransientError extends HttpClientError {\n readonly kind = 'transient' as const;\n}\n\nexport class RateLimitError extends HttpClientError {\n readonly kind = 'rate_limit' as const;\n readonly retryAfter?: Date;\n\n constructor(message: string, response?: HttpResponse, retryAfter?: Date) {\n super(message, response);\n this.retryAfter = retryAfter;\n }\n}\n\nexport class AuthError extends HttpClientError {\n readonly kind = 'auth' as const;\n}\n\nexport class UpstreamBugError extends HttpClientError {\n readonly kind = 'upstream_bug' as const;\n}\n\nexport class ClientBugError extends HttpClientError {\n readonly kind = 'client_bug' as const;\n}\n\nexport function classifyStatus(status: number): HttpErrorKind {\n if (status === 429) {\n return 'rate_limit';\n }\n if (status === 401 || status === 403) {\n return 'auth';\n }\n if (status === 408) {\n return 'transient';\n }\n if (status >= 500) {\n return 'upstream_bug';\n }\n if (status >= 400) {\n return 'client_bug';\n }\n return 'client_bug';\n}\n\nexport function errorForStatus(\n message: string,\n response: HttpResponse,\n retryAfter?: Date,\n): HttpClientError {\n const kind = classifyStatus(response.status);\n switch (kind) {\n case 'rate_limit':\n return new RateLimitError(message, response, retryAfter);\n case 'auth':\n return new AuthError(message, response);\n case 'transient':\n return new TransientError(message, response);\n case 'upstream_bug':\n return new UpstreamBugError(message, response);\n case 'client_bug':\n return new ClientBugError(message, response);\n }\n}\n","import { HttpClientError, RateLimitError, TransientError } from './errors';\n\nexport interface RetryPolicy {\n maxAttempts?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n retryOn?: (status: number | null, err?: Error) => boolean;\n}\n\nexport const defaultRetryOn = (status: number | null, err?: Error): boolean => {\n if (err instanceof RateLimitError) {\n return true;\n }\n if (err instanceof TransientError) {\n return true;\n }\n if (status === null) {\n return err instanceof Error && !(err instanceof HttpClientError);\n }\n if (status === 408 || status === 429) {\n return true;\n }\n if (status >= 500) {\n return true;\n }\n return false;\n};\n\nexport function backoffDelayMs(\n attempt: number,\n policy: Required<Pick<RetryPolicy, 'initialDelayMs' | 'maxDelayMs'>>,\n): number {\n const base = policy.initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, policy.maxDelayMs);\n}\n\nexport function parseRetryAfter(\n headerValue: string | null,\n now: Date = new Date(),\n): Date | undefined {\n if (!headerValue) {\n return undefined;\n }\n const trimmed = headerValue.trim();\n if (/^\\d+$/.test(trimmed)) {\n return new Date(now.getTime() + Number(trimmed) * 1000);\n }\n const parsed = Date.parse(trimmed);\n if (Number.isNaN(parsed)) {\n return undefined;\n }\n return new Date(parsed);\n}\n\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n if (signal?.aborted) {\n return Promise.reject(signal.reason ?? new Error('Aborted'));\n }\n return new Promise<void>((resolve, reject) => {\n const onAbort = () => {\n clearTimeout(timer);\n reject(signal!.reason ?? new Error('Aborted'));\n };\n const timer = setTimeout(() => {\n signal?.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n","export const HTTP_CLIENT_VERSION = '0.0.0';\n\nexport const DEFAULT_USER_AGENT = `rawdash-connector/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n\nexport function connectorUserAgent(connectorId: string): string {\n return `rawdash-connector-${connectorId}/${HTTP_CLIENT_VERSION} (+https://rawdash.dev)`;\n}\n","import {\n AuthError,\n ClientBugError,\n HttpClientError,\n RateLimitError,\n TransientError,\n UpstreamBugError,\n errorForStatus,\n} from './errors';\nimport { defaultRetryOn, parseRetryAfter, sleep } from './retry';\nimport type { FetchLike, HttpMethod, HttpRequest, HttpResponse } from './types';\nimport { DEFAULT_USER_AGENT } from './version';\n\nconst DEFAULT_TIMEOUT_MS = 10_000;\nconst DEFAULT_MAX_ATTEMPTS = 3;\nconst DEFAULT_INITIAL_DELAY_MS = 1000;\nconst DEFAULT_MAX_DELAY_MS = 60_000;\nconst OBSERVER_TIMEOUT_MS = 250;\n\nexport interface RequestObservation {\n url: string;\n method: HttpMethod;\n status: number;\n resource: string;\n requestId: string;\n body: unknown;\n}\n\nexport type RequestObserver = (\n event: RequestObservation,\n) => void | Promise<void>;\n\nexport interface RequestOptions {\n fetch?: FetchLike;\n observer?: RequestObserver;\n resource: string;\n requestId?: string;\n}\n\nasync function notifyObserver(\n observer: RequestObserver,\n event: RequestObservation,\n): Promise<void> {\n let result: void | Promise<void>;\n try {\n result = observer(event);\n } catch (err) {\n console.warn('[connector-shared] request observer threw:', err);\n return;\n }\n if (!(result instanceof Promise)) {\n return;\n }\n const guarded = result.catch((err) => {\n console.warn('[connector-shared] request observer rejected:', err);\n });\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<void>((resolve) => {\n timer = setTimeout(resolve, OBSERVER_TIMEOUT_MS);\n });\n try {\n await Promise.race([guarded, timeout]);\n } finally {\n if (timer) {\n clearTimeout(timer);\n }\n }\n}\n\nfunction newRequestId(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) {\n return c.randomUUID();\n }\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\nfunction mergeHeaders(\n defaults: Record<string, string>,\n overrides: Record<string, string> | undefined,\n): Record<string, string> {\n const merged: Record<string, string> = {};\n for (const [k, v] of Object.entries(defaults)) {\n merged[k.toLowerCase()] = v;\n }\n if (overrides) {\n for (const [k, v] of Object.entries(overrides)) {\n merged[k.toLowerCase()] = v;\n }\n }\n return merged;\n}\n\nfunction linkTimeoutSignal(\n parent: AbortSignal | undefined,\n timeoutMs: number,\n): { signal: AbortSignal; cancel: () => void } {\n const controller = new AbortController();\n const onParentAbort = () => {\n controller.abort(parent?.reason);\n };\n if (parent) {\n if (parent.aborted) {\n controller.abort(parent.reason);\n } else {\n parent.addEventListener('abort', onParentAbort, { once: true });\n }\n }\n const timer = setTimeout(() => {\n controller.abort(new Error(`Request timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n return {\n signal: controller.signal,\n cancel: () => {\n clearTimeout(timer);\n if (parent) {\n parent.removeEventListener('abort', onParentAbort);\n }\n },\n };\n}\n\nasync function readBody(res: Response, parseJson: boolean): Promise<unknown> {\n if (res.status === 204 || res.status === 205) {\n return null;\n }\n const contentType = res.headers.get('content-type') ?? '';\n if (parseJson && contentType.includes('application/json')) {\n const text = await res.text();\n if (text.length === 0) {\n return null;\n }\n return JSON.parse(text);\n }\n return res.text();\n}\n\nexport async function request<T = unknown>(\n req: HttpRequest,\n options: RequestOptions,\n): Promise<HttpResponse<T>> {\n const fetchImpl: FetchLike = options.fetch ?? (globalThis.fetch as FetchLike);\n const retry = req.retry ?? {};\n const maxAttempts = retry.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;\n const initialDelayMs = retry.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;\n const maxDelayMs = retry.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;\n const retryOn = retry.retryOn ?? defaultRetryOn;\n const timeoutMs = req.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const parseJson = req.parseJson ?? true;\n\n const headers = mergeHeaders(\n {\n 'User-Agent': DEFAULT_USER_AGENT,\n Accept: 'application/json',\n },\n req.headers,\n );\n\n let lastErr: Error | undefined;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n req.signal?.throwIfAborted();\n\n const { signal, cancel } = linkTimeoutSignal(req.signal, timeoutMs);\n let res: Response;\n try {\n res = await fetchImpl(req.url, {\n method: req.method ?? 'GET',\n headers,\n body: req.body as RequestInit['body'],\n signal,\n });\n } catch (err) {\n cancel();\n if (req.signal?.aborted) {\n throw req.signal.reason ?? err;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n lastErr = error;\n if (attempt < maxAttempts - 1 && retryOn(null, error)) {\n const delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n await sleep(delay, req.signal);\n continue;\n }\n throw new TransientError(error.message);\n }\n cancel();\n\n const body = await readBody(res, parseJson);\n const httpResponse: HttpResponse<T> = {\n status: res.status,\n headers: res.headers,\n body: body as T,\n };\n if (req.rateLimit) {\n const state = req.rateLimit.parse(res.headers);\n if (state) {\n httpResponse.rateLimitState = state;\n }\n }\n\n if (options.observer) {\n await notifyObserver(options.observer, {\n url: req.url,\n method: req.method ?? 'GET',\n status: res.status,\n resource: options.resource,\n requestId: options.requestId ?? newRequestId(),\n body,\n });\n }\n\n if (res.ok) {\n return httpResponse;\n }\n\n const retryAfter = parseRetryAfter(res.headers.get('retry-after'));\n const message = `HTTP ${res.status} ${res.statusText} for ${req.method ?? 'GET'} ${req.url}`;\n const err = errorForStatus(message, httpResponse, retryAfter);\n\n if (\n attempt < maxAttempts - 1 &&\n retryOn(res.status, err) &&\n !(err instanceof AuthError) &&\n !(err instanceof ClientBugError)\n ) {\n lastErr = err;\n let delay = computeDelay(attempt, initialDelayMs, maxDelayMs);\n if (err instanceof RateLimitError && retryAfter) {\n const wait = retryAfter.getTime() - Date.now();\n if (wait > 0) {\n delay = Math.min(wait, maxDelayMs);\n }\n }\n await sleep(delay, req.signal);\n continue;\n }\n\n throw err;\n }\n\n throw lastErr ?? new UpstreamBugError('Exhausted retry attempts');\n}\n\nfunction computeDelay(\n attempt: number,\n initialDelayMs: number,\n maxDelayMs: number,\n): number {\n const base = initialDelayMs * 2 ** attempt;\n const jitter = base * 0.25 * Math.random();\n return Math.min(base + jitter, maxDelayMs);\n}\n\nexport { HttpClientError };\n","export interface RateLimitState {\n remaining: number;\n resetAt: Date;\n}\n\nexport interface RateLimitPolicy {\n parse(headers: Headers): RateLimitState | null;\n}\n\nexport interface StandardRateLimitPolicyConfig {\n remainingHeader: string;\n resetHeader: string;\n resetUnit: 's' | 'ms';\n resetFallbackMs?: number;\n}\n\nexport function standardRateLimitPolicy(\n config: StandardRateLimitPolicyConfig,\n): RateLimitPolicy {\n const { remainingHeader, resetHeader, resetUnit, resetFallbackMs } = config;\n const multiplier = resetUnit === 's' ? 1000 : 1;\n return {\n parse(h) {\n const remainingRaw = h.get(remainingHeader);\n if (remainingRaw === null || remainingRaw.trim() === '') {\n return null;\n }\n const remaining = Number(remainingRaw);\n if (!Number.isFinite(remaining)) {\n return null;\n }\n const resetRaw = h.get(resetHeader);\n if (resetRaw === null) {\n if (resetFallbackMs === undefined) {\n return null;\n }\n return {\n remaining,\n resetAt: new Date(Date.now() + resetFallbackMs),\n };\n }\n if (resetRaw.trim() === '') {\n return null;\n }\n const reset = Number(resetRaw);\n if (!Number.isFinite(reset) || reset < 0) {\n return null;\n }\n const resetMs = reset * multiplier;\n if (!Number.isFinite(resetMs)) {\n return null;\n }\n return { remaining, resetAt: new Date(resetMs) };\n },\n };\n}\n","export async function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n fn: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n if (items.length === 0) {\n return results;\n }\n const normalized = Number.isFinite(concurrency) ? Math.floor(concurrency) : 1;\n const limit = Math.max(1, Math.min(normalized, items.length));\n let next = 0;\n let failed = false;\n\n async function worker(): Promise<void> {\n while (!failed) {\n const i = next++;\n if (i >= items.length) {\n return;\n }\n try {\n results[i] = await fn(items[i]!, i);\n } catch (err) {\n failed = true;\n throw err;\n }\n }\n }\n\n const workers: Promise<void>[] = [];\n for (let w = 0; w < limit; w++) {\n workers.push(worker());\n }\n await Promise.all(workers);\n return results;\n}\n","export interface SanitizeAllowedUrlOptions {\n url: string | null;\n host: string;\n pathname: string;\n protocol?: 'https:' | 'http:';\n}\n\nexport function sanitizeAllowedUrl(\n options: SanitizeAllowedUrlOptions,\n): string | null {\n const { url, host, pathname, protocol = 'https:' } = options;\n if (url === null) {\n return null;\n }\n try {\n const u = new URL(url);\n if (u.protocol !== protocol || u.host !== host || u.pathname !== pathname) {\n return null;\n }\n return u.toString();\n } catch {\n return null;\n }\n}\n","export type EpochUnit = 'ms' | 's' | 'iso';\n\nexport function parseEpoch(\n value: number | string | null | undefined,\n unit: EpochUnit,\n): number | null {\n if (value === null || value === undefined) {\n return null;\n }\n if (unit === 'iso') {\n if (typeof value !== 'string') {\n return null;\n }\n const ms = new Date(value).getTime();\n return Number.isFinite(ms) ? ms : null;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return null;\n }\n const n = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(n)) {\n return null;\n }\n const result = unit === 's' ? n * 1000 : n;\n return Number.isFinite(result) ? result : null;\n}\n","import { request } from './request';\nimport type { HttpRequest } from './types';\n\nexport function parseLinkHeader(header: string | null): Record<string, string> {\n if (!header) {\n return {};\n }\n const result: Record<string, string> = {};\n for (const part of header.split(',')) {\n const match = part.match(/<([^>]+)>\\s*;\\s*rel=\"([^\"]+)\"/);\n if (match) {\n result[match[2]!] = match[1]!;\n }\n }\n return result;\n}\n\nexport async function* paginateLink<T>(\n initial: HttpRequest,\n parse: (body: unknown) => T[],\n options: { resource: string },\n): AsyncIterable<T> {\n let next: string | null = initial.url;\n while (next) {\n const res: Awaited<ReturnType<typeof request>> = await request(\n {\n ...initial,\n url: next,\n },\n { resource: options.resource },\n );\n for (const item of parse(res.body)) {\n yield item;\n }\n const links = parseLinkHeader(res.headers.get('link'));\n next = links['next'] ?? null;\n }\n}\n\nexport async function* paginateCursor<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; nextCursor: string | null },\n buildNext: (req: HttpRequest, cursor: string) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let req: HttpRequest = initial;\n while (true) {\n const res = await request(req, { resource: options.resource });\n const { items, nextCursor } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!nextCursor) {\n return;\n }\n req = buildNext(req, nextCursor);\n }\n}\n\nexport async function* paginatePage<T>(\n initial: HttpRequest,\n parse: (body: unknown) => { items: T[]; hasMore: boolean },\n buildPage: (req: HttpRequest, page: number) => HttpRequest,\n options: { resource: string },\n): AsyncIterable<T> {\n let page = 1;\n while (true) {\n const req = page === 1 ? initial : buildPage(initial, page);\n const res = await request(req, { resource: options.resource });\n const { items, hasMore } = parse(res.body);\n for (const item of items) {\n yield item;\n }\n if (!hasMore || items.length === 0) {\n return;\n }\n page++;\n }\n}\n","export type LogFields = Record<string, unknown>;\n\nexport interface ConnectorLogger {\n info(event: string, fields?: LogFields): void;\n warn(event: string, fields?: LogFields): void;\n}\n\nexport interface ConnectorLoggerOptions {\n scope: string;\n}\n\nconst MAX_VALUE_LEN = 120;\n\nfunction truncate(s: string, max = MAX_VALUE_LEN): string {\n if (s.length <= max) {\n return s;\n }\n return `${s.slice(0, max - 1)}…`;\n}\n\nfunction formatValue(value: unknown): string {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return '';\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'string') {\n const t = truncate(value);\n if (/[\\s\"=]/.test(t)) {\n return JSON.stringify(t);\n }\n return t;\n }\n if (typeof value === 'bigint') {\n return value.toString();\n }\n let json: string | undefined;\n try {\n json = JSON.stringify(value);\n } catch {\n json = undefined;\n }\n return truncate(json ?? String(value));\n}\n\nexport function formatLogFields(fields?: LogFields): string {\n if (!fields) {\n return '';\n }\n const parts: string[] = [];\n for (const [k, v] of Object.entries(fields)) {\n if (v === undefined) {\n continue;\n }\n parts.push(`${k}=${formatValue(v)}`);\n }\n return parts.length > 0 ? ` ${parts.join(' ')}` : '';\n}\n\nexport function formatLogLine(\n scope: string,\n event: string,\n fields?: LogFields,\n): string {\n return `[${scope}] ${event}${formatLogFields(fields)}`;\n}\n\nexport function createDefaultConnectorLogger(\n opts: ConnectorLoggerOptions,\n): ConnectorLogger {\n return {\n info(event, fields) {\n console.info(formatLogLine(opts.scope, event, fields));\n },\n warn(event, fields) {\n console.warn(formatLogLine(opts.scope, event, fields));\n },\n };\n}\n\nconst NOOP_LOGGER: ConnectorLogger = {\n info() {},\n warn() {},\n};\n\nexport function noopConnectorLogger(): ConnectorLogger {\n return NOOP_LOGGER;\n}\n","import {\n type HttpResponse,\n connectorUserAgent,\n} from '@rawdash/connector-shared';\nimport {\n BaseConnector,\n type ConnectorContext,\n type ConnectorDoc,\n type CredentialsSchema,\n type FetchSpec,\n type FilterClause,\n type StorageHandle,\n type SyncOptions,\n type SyncResult,\n defineConfigFields,\n defineConnectorDoc,\n defineResources,\n makeChunkedCursorGuard,\n paginateChunked,\n schemasFromResources,\n selectActivePhases,\n} from '@rawdash/core';\nimport { z } from 'zod';\n\nexport const configFields = defineConfigFields(\n z.object({\n apiKey: z.object({ $secret: z.string() }).meta({\n label: 'API Key',\n description:\n 'Stripe Restricted API key with read-only access. Create one at Dashboard → Developers → API keys.',\n placeholder: 'rk_live_...',\n secret: true,\n }),\n accountId: z.string().optional().meta({\n label: 'Account ID (optional)',\n description:\n 'Stripe Connect account ID. Only needed if you are a platform accessing a connected account.',\n placeholder: 'acct_...',\n }),\n resources: z\n .array(\n z.enum([\n 'customers',\n 'products',\n 'prices',\n 'subscriptions',\n 'invoices',\n 'charges',\n 'payment_intents',\n 'disputes',\n 'refunds',\n ]),\n )\n .nonempty()\n .optional()\n .meta({\n label: 'Resources',\n description:\n 'Which Stripe resources to sync. Omit to sync all resources. The API key only needs Read scope for the resources listed here.',\n }),\n }),\n);\n\nexport const doc: ConnectorDoc = defineConnectorDoc({\n displayName: 'Stripe',\n category: 'finance',\n brandColor: '#635BFF',\n tagline:\n 'Sync customers, products, prices, subscriptions, and invoices alongside charge, payment, dispute, and refund events from your Stripe account.',\n vendor: {\n name: 'Stripe',\n domain: 'stripe.com',\n apiDocs: 'https://stripe.com/docs/api',\n website: 'https://stripe.com',\n },\n auth: {\n summary:\n 'Authenticates with a Stripe restricted API key that has read-only access to the resources you want to sync.',\n setup: [\n 'Open the Stripe Dashboard → Developers → API keys.',\n 'Create a restricted key with Read access for the resources you plan to sync (customers, products, prices, subscriptions, invoices, charges, payment intents, disputes, refunds).',\n 'Store the key as a secret and reference it from the connector config as `apiKey: secret(\"STRIPE_API_KEY\")`.',\n ],\n },\n rateLimit:\n 'Stripe 429 responses carry a Retry-After header; requests are retried with exponential backoff. List pagination uses the starting_after cursor (limit 100).',\n limitations: [\n 'Monetary amounts are stored in the smallest currency unit (e.g. cents), matching the Stripe API.',\n 'The set of synced resources is controlled by the `resources` config field; omit it to sync all of them.',\n 'Incremental syncs use a 7-day lookback for entities and created[gt] for events.',\n ],\n});\n\nexport interface StripeSettings {\n accountId?: string;\n resources?: readonly StripeResource[];\n}\n\ninterface StripeListResponse<T> {\n object: 'list';\n data: T[];\n has_more: boolean;\n url: string;\n}\n\ninterface StripeCustomer {\n id: string;\n email: string | null;\n name: string | null;\n created: number;\n currency: string | null;\n delinquent: boolean | null;\n livemode: boolean;\n}\n\ninterface StripePriceRecurring {\n interval: 'day' | 'week' | 'month' | 'year';\n interval_count: number;\n}\n\ninterface StripePrice {\n id: string;\n product: string;\n unit_amount: number | null;\n currency: string;\n recurring: StripePriceRecurring | null;\n active: boolean;\n created: number;\n}\n\ninterface StripeSubscriptionItem {\n price: StripePrice;\n quantity: number | null;\n}\n\ninterface StripeSubscription {\n id: string;\n customer: string;\n status: string;\n items: { data: StripeSubscriptionItem[] };\n current_period_start: number;\n current_period_end: number;\n cancel_at_period_end: boolean;\n canceled_at: number | null;\n trial_end: number | null;\n currency: string;\n created: number;\n}\n\ninterface StripeInvoice {\n id: string;\n customer: string | null;\n subscription: string | null;\n status: string | null;\n amount_due: number;\n amount_paid: number;\n currency: string;\n created: number;\n due_date: number | null;\n hosted_invoice_url: string | null;\n}\n\ninterface StripeCharge {\n id: string;\n customer: string | null;\n amount: number;\n currency: string;\n status: string;\n failure_code: string | null;\n created: number;\n payment_intent: string | null;\n}\n\ninterface StripePaymentIntent {\n id: string;\n customer: string | null;\n amount: number;\n currency: string;\n status: string;\n created: number;\n}\n\ninterface StripeProduct {\n id: string;\n name: string;\n active: boolean;\n created: number;\n}\n\ninterface StripeDispute {\n id: string;\n charge: string;\n amount: number;\n currency: string;\n reason: string;\n status: string;\n created: number;\n}\n\ninterface StripeRefund {\n id: string;\n charge: string | null;\n amount: number;\n currency: string;\n reason: string | null;\n status: string | null;\n created: number;\n}\n\nconst stripeCredentials = {\n apiKey: {\n description: 'Stripe API key',\n auth: 'required' as const,\n },\n} satisfies CredentialsSchema;\n\ntype StripeCredentials = typeof stripeCredentials;\n\nconst PHASE_ORDER = [\n 'customers',\n 'products',\n 'prices',\n 'subscriptions',\n 'invoices',\n 'charges',\n 'payment_intents',\n 'disputes',\n 'refunds',\n] as const;\n\ntype StripePhase = (typeof PHASE_ORDER)[number];\n\nexport type StripeResource = StripePhase;\n\nconst isStripeSyncCursor = makeChunkedCursorGuard(PHASE_ORDER);\n\nconst ENTITY_TYPE_BY_PHASE: Partial<Record<StripePhase, string>> = {\n customers: 'stripe_customer',\n products: 'stripe_product',\n prices: 'stripe_price',\n subscriptions: 'stripe_subscription',\n invoices: 'stripe_invoice',\n};\n\nconst EVENT_NAME_BY_PHASE: Partial<Record<StripePhase, string>> = {\n charges: 'stripe_charge',\n payment_intents: 'stripe_payment_intent',\n disputes: 'stripe_dispute',\n refunds: 'stripe_refund',\n};\n\nfunction pushableEq(\n filter: FilterClause[] | undefined,\n field: string,\n): string | null {\n if (!filter) {\n return null;\n }\n for (const clause of filter) {\n if (\n 'field' in clause &&\n clause.field === field &&\n clause.op === 'eq' &&\n typeof clause.value === 'string'\n ) {\n return clause.value;\n }\n }\n return null;\n}\n\nexport function computeMrrAmountCents(\n subscription: StripeSubscription,\n): number | null {\n let sum = 0;\n let counted = 0;\n for (const item of subscription.items.data) {\n const { unit_amount, recurring } = item.price;\n if (unit_amount === null || unit_amount === undefined || !recurring) {\n continue;\n }\n const quantity = item.quantity ?? 1;\n const total = unit_amount * quantity;\n const intervalCount = recurring.interval_count || 1;\n let monthly: number | null;\n switch (recurring.interval) {\n case 'month':\n monthly = total / intervalCount;\n break;\n case 'year':\n monthly = total / (12 * intervalCount);\n break;\n case 'week':\n monthly = (total * 52) / (12 * intervalCount);\n break;\n case 'day':\n monthly = (total * 365) / (12 * intervalCount);\n break;\n default:\n monthly = null;\n }\n if (monthly === null) {\n continue;\n }\n sum += monthly;\n counted++;\n }\n if (counted === 0) {\n return null;\n }\n return Math.round(sum);\n}\n\nconst idString = z.string().min(1);\n\nconst customerSchema = z.object({\n id: idString,\n email: z.string().nullable(),\n name: z.string().nullable(),\n created: z.number().int().nonnegative(),\n currency: z.string().nullable(),\n delinquent: z.boolean().nullable(),\n livemode: z.boolean(),\n});\n\nconst productSchema = z.object({\n id: idString,\n name: z.string(),\n active: z.boolean(),\n created: z.number().int().nonnegative(),\n});\n\nconst priceSchema = z.object({\n id: idString,\n product: idString,\n unit_amount: z.number().int().nullable(),\n currency: z.string(),\n recurring: z\n .object({\n interval: z.enum(['day', 'week', 'month', 'year']),\n interval_count: z.number().int().positive(),\n })\n .nullable(),\n active: z.boolean(),\n created: z.number().int().nonnegative(),\n});\n\nconst subscriptionSchema = z.object({\n id: idString,\n customer: idString,\n status: z.string(),\n items: z.object({\n data: z.array(\n z.object({\n price: priceSchema,\n quantity: z.number().int().nullable(),\n }),\n ),\n }),\n current_period_start: z.number().int().nonnegative(),\n current_period_end: z.number().int().nonnegative(),\n cancel_at_period_end: z.boolean(),\n canceled_at: z.number().int().nullable(),\n trial_end: z.number().int().nullable(),\n currency: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst invoiceSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n subscription: idString.nullable(),\n status: z.string().nullable(),\n amount_due: z.number().int(),\n amount_paid: z.number().int(),\n currency: z.string(),\n created: z.number().int().nonnegative(),\n due_date: z.number().int().nullable(),\n hosted_invoice_url: z.string().nullable(),\n});\n\nconst chargeSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n status: z.string(),\n failure_code: z.string().nullable(),\n created: z.number().int().nonnegative(),\n payment_intent: idString.nullable(),\n});\n\nconst paymentIntentSchema = z.object({\n id: idString,\n customer: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n status: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst disputeSchema = z.object({\n id: idString,\n charge: idString,\n amount: z.number().int(),\n currency: z.string(),\n reason: z.string(),\n status: z.string(),\n created: z.number().int().nonnegative(),\n});\n\nconst refundSchema = z.object({\n id: idString,\n charge: idString.nullable(),\n amount: z.number().int(),\n currency: z.string(),\n reason: z.string().nullable(),\n status: z.string().nullable(),\n created: z.number().int().nonnegative(),\n});\n\nexport const stripeResources = defineResources({\n stripe_customer: {\n shape: 'entity',\n filterable: [],\n description:\n 'Customers with email, name, default currency, and delinquency state.',\n endpoint: 'GET /v1/customers',\n responses: { customers: z.array(customerSchema) },\n },\n stripe_product: {\n shape: 'entity',\n filterable: [{ field: 'active', ops: ['eq'], values: ['true', 'false'] }],\n description: 'Products in your catalog, including active state.',\n endpoint: 'GET /v1/products',\n responses: { products: z.array(productSchema) },\n },\n stripe_price: {\n shape: 'entity',\n filterable: [{ field: 'active', ops: ['eq'], values: ['true', 'false'] }],\n description:\n 'Prices with unit amount, currency, and recurring interval, linked to their product.',\n endpoint: 'GET /v1/prices',\n responses: { prices: z.array(priceSchema) },\n },\n stripe_subscription: {\n shape: 'entity',\n filterable: [\n {\n field: 'status',\n ops: ['eq'],\n values: [\n 'active',\n 'past_due',\n 'unpaid',\n 'canceled',\n 'incomplete',\n 'incomplete_expired',\n 'trialing',\n 'paused',\n ],\n },\n ],\n description:\n 'Subscriptions with status, current period, cancellation state, and computed monthly recurring revenue (mrrAmount, in the smallest currency unit).',\n endpoint: 'GET /v1/subscriptions',\n notes:\n 'mrrAmount is computed as unit_amount x quantity, normalized to a monthly cadence (yearly / 12, weekly x 52 / 12, etc.).',\n fields: [\n {\n name: 'customerId',\n description: 'Customer the subscription belongs to.',\n },\n {\n name: 'status',\n description: 'Subscription status (active, canceled, ...).',\n },\n {\n name: 'planId',\n description: 'Price id of the first subscription item.',\n },\n {\n name: 'currentPeriodStart',\n description: 'Current period start (unix seconds).',\n },\n {\n name: 'currentPeriodEnd',\n description: 'Current period end (unix seconds).',\n },\n {\n name: 'cancelAtPeriodEnd',\n description: 'Whether the subscription cancels at period end.',\n },\n {\n name: 'canceledAt',\n description: 'Cancellation time (unix seconds), if canceled.',\n },\n {\n name: 'trialEnd',\n description: 'Trial end time (unix seconds), if any.',\n },\n {\n name: 'mrrAmount',\n description: 'Monthly recurring revenue in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n { name: 'created', description: 'Creation time (unix seconds).' },\n ],\n responses: { subscriptions: z.array(subscriptionSchema) },\n },\n stripe_invoice: {\n shape: 'entity',\n filterable: [\n {\n field: 'status',\n ops: ['eq'],\n values: ['draft', 'open', 'paid', 'uncollectible', 'void'],\n },\n ],\n description:\n 'Invoices with amount due, amount paid, status, and due date, linked to their customer and subscription.',\n endpoint: 'GET /v1/invoices',\n fields: [\n { name: 'customerId', description: 'Customer the invoice belongs to.' },\n {\n name: 'subscriptionId',\n description: 'Subscription the invoice belongs to, if any.',\n },\n {\n name: 'status',\n description: 'Invoice status (draft, open, paid, ...).',\n },\n {\n name: 'amountDue',\n description: 'Amount due in the smallest currency unit.',\n unit: 'cents',\n },\n {\n name: 'amountPaid',\n description: 'Amount paid in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n { name: 'created', description: 'Creation time (unix seconds).' },\n { name: 'dueDate', description: 'Due date (unix seconds), if any.' },\n { name: 'hostedInvoiceUrl', description: 'Hosted invoice URL, if any.' },\n ],\n responses: { invoices: z.array(invoiceSchema) },\n },\n stripe_charge: {\n shape: 'event',\n filterable: [],\n description:\n 'Charge attempts with amount, currency, status, and failure code, timestamped at creation.',\n endpoint: 'GET /v1/charges',\n fields: [\n { name: 'id', description: 'Stripe charge id.' },\n { name: 'customerId', description: 'Customer charged, if any.' },\n {\n name: 'amount',\n description: 'Charge amount in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n {\n name: 'status',\n description: 'Charge status (succeeded, failed, ...).',\n },\n {\n name: 'failureCode',\n description: 'Failure code, if the charge failed.',\n },\n {\n name: 'paymentIntentId',\n description: 'Associated payment intent id, if any.',\n },\n ],\n responses: { charges: z.array(chargeSchema) },\n },\n stripe_payment_intent: {\n shape: 'event',\n filterable: [],\n description:\n 'Payment intents with amount, currency, and status, timestamped at creation.',\n endpoint: 'GET /v1/payment_intents',\n fields: [\n { name: 'id', description: 'Stripe payment intent id.' },\n { name: 'customerId', description: 'Customer, if any.' },\n {\n name: 'amount',\n description: 'Intent amount in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n { name: 'status', description: 'Payment intent status.' },\n ],\n responses: { payment_intents: z.array(paymentIntentSchema) },\n },\n stripe_dispute: {\n shape: 'event',\n filterable: [],\n description:\n 'Disputes with amount, currency, reason, and status, linked to the disputed charge.',\n endpoint: 'GET /v1/disputes',\n fields: [\n { name: 'id', description: 'Stripe dispute id.' },\n { name: 'chargeId', description: 'Disputed charge id.' },\n {\n name: 'amount',\n description: 'Disputed amount in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n { name: 'reason', description: 'Dispute reason.' },\n { name: 'status', description: 'Dispute status.' },\n ],\n responses: { disputes: z.array(disputeSchema) },\n },\n stripe_refund: {\n shape: 'event',\n filterable: [],\n description:\n 'Refunds with amount, currency, reason, and status, linked to the refunded charge.',\n endpoint: 'GET /v1/refunds',\n fields: [\n { name: 'id', description: 'Stripe refund id.' },\n { name: 'chargeId', description: 'Refunded charge id, if any.' },\n {\n name: 'amount',\n description: 'Refunded amount in the smallest currency unit.',\n unit: 'cents',\n },\n { name: 'currency', description: 'ISO currency code.' },\n { name: 'reason', description: 'Refund reason, if any.' },\n { name: 'status', description: 'Refund status, if any.' },\n ],\n responses: { refunds: z.array(refundSchema) },\n },\n});\n\nexport const id = 'stripe';\n\nexport class StripeConnector extends BaseConnector<\n StripeSettings,\n StripeCredentials\n> {\n static readonly id = id;\n\n static readonly resources = stripeResources;\n\n static readonly schemas = schemasFromResources(stripeResources);\n\n static create(input: unknown, ctx?: ConnectorContext): StripeConnector {\n const parsed = configFields.parse(input);\n return new StripeConnector(\n { accountId: parsed.accountId, resources: parsed.resources },\n { apiKey: parsed.apiKey },\n ctx,\n );\n }\n\n readonly id = id;\n override readonly credentials = stripeCredentials;\n\n private buildHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.creds.apiKey}`,\n 'Stripe-Version': '2024-06-20',\n 'User-Agent': connectorUserAgent('stripe'),\n };\n if (this.settings.accountId) {\n headers['Stripe-Account'] = this.settings.accountId;\n }\n return headers;\n }\n\n private fetch<T>(\n url: string,\n resource: string,\n signal?: AbortSignal,\n ): Promise<HttpResponse<T>> {\n return this.get<T>(url, {\n resource,\n headers: this.buildHeaders(),\n signal,\n });\n }\n\n private buildListUrl(\n path: string,\n params: Record<string, string | undefined>,\n ): string {\n const url = new URL(`https://api.stripe.com/v1/${path}`);\n url.searchParams.set('limit', '100');\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n return url.toString();\n }\n\n private entityCreatedGte(\n phase: StripePhase,\n options: SyncOptions,\n ): string | undefined {\n if (!options.since) {\n return undefined;\n }\n const sinceMs = new Date(options.since).getTime();\n if (options.mode === 'latest') {\n return String(Math.floor((sinceMs - 7 * 24 * 60 * 60 * 1000) / 1000));\n }\n if (phase === 'subscriptions') {\n return undefined;\n }\n return String(Math.floor(sinceMs / 1000));\n }\n\n private eventCreatedGt(options: SyncOptions): string | undefined {\n if (!options.since) {\n return undefined;\n }\n return String(Math.floor(new Date(options.since).getTime() / 1000));\n }\n\n private singleSpec(\n options: SyncOptions,\n resource: string,\n ): FetchSpec | undefined {\n const specs = options.fetchSpecs?.[resource];\n return specs && specs.length === 1 ? specs[0] : undefined;\n }\n\n private buildPhaseUrl(\n phase: StripePhase,\n page: string | null,\n options: SyncOptions,\n ): string {\n const startingAfter = page ?? undefined;\n if (phase in ENTITY_TYPE_BY_PHASE) {\n const extra: Record<string, string | undefined> = {};\n const filter = this.singleSpec(\n options,\n ENTITY_TYPE_BY_PHASE[phase]!,\n )?.filter;\n if (phase === 'subscriptions' || phase === 'invoices') {\n const status = pushableEq(filter, 'status');\n if (phase === 'subscriptions') {\n extra.status = status ?? 'all';\n } else if (status !== null) {\n extra.status = status;\n }\n } else if (phase === 'products' || phase === 'prices') {\n const active = pushableEq(filter, 'active');\n if (active !== null) {\n extra.active = active;\n }\n }\n return this.buildListUrl(phase, {\n ...extra,\n starting_after: startingAfter,\n 'created[gte]': this.entityCreatedGte(phase, options),\n });\n }\n return this.buildListUrl(phase, {\n starting_after: startingAfter,\n 'created[gt]': this.eventCreatedGt(options),\n });\n }\n\n private async clearScopeOnFirstPage(\n storage: StorageHandle,\n phase: StripePhase,\n ): Promise<void> {\n const entityType = ENTITY_TYPE_BY_PHASE[phase];\n if (entityType) {\n await storage.entities([], { types: [entityType] });\n return;\n }\n const eventName = EVENT_NAME_BY_PHASE[phase];\n if (eventName) {\n await storage.events([], { names: [eventName] });\n }\n }\n\n private async writePhase(\n storage: StorageHandle,\n phase: StripePhase,\n items: unknown[],\n ): Promise<void> {\n switch (phase) {\n case 'customers':\n for (const c of items as StripeCustomer[]) {\n await storage.entity({\n type: 'stripe_customer',\n id: c.id,\n attributes: {\n email: c.email ?? null,\n name: c.name ?? null,\n created: c.created,\n currency: c.currency ?? null,\n delinquent: c.delinquent ?? false,\n livemode: c.livemode,\n },\n updated_at: c.created * 1000,\n });\n }\n return;\n case 'products':\n for (const p of items as StripeProduct[]) {\n await storage.entity({\n type: 'stripe_product',\n id: p.id,\n attributes: { name: p.name, active: p.active, created: p.created },\n updated_at: p.created * 1000,\n });\n }\n return;\n case 'prices':\n for (const p of items as StripePrice[]) {\n await storage.entity({\n type: 'stripe_price',\n id: p.id,\n attributes: {\n productId: p.product,\n unitAmount: p.unit_amount ?? null,\n currency: p.currency,\n interval: p.recurring?.interval ?? null,\n intervalCount: p.recurring?.interval_count ?? null,\n active: p.active,\n created: p.created,\n },\n updated_at: p.created * 1000,\n });\n }\n return;\n case 'subscriptions':\n for (const s of items as StripeSubscription[]) {\n await storage.entity({\n type: 'stripe_subscription',\n id: s.id,\n attributes: {\n customerId: s.customer,\n status: s.status,\n planId: s.items.data[0]?.price.id ?? null,\n currentPeriodStart: s.current_period_start,\n currentPeriodEnd: s.current_period_end,\n cancelAtPeriodEnd: s.cancel_at_period_end,\n canceledAt: s.canceled_at ?? null,\n trialEnd: s.trial_end ?? null,\n mrrAmount: computeMrrAmountCents(s),\n currency: s.currency,\n created: s.created,\n },\n updated_at: s.current_period_end * 1000,\n });\n }\n return;\n case 'invoices':\n for (const inv of items as StripeInvoice[]) {\n await storage.entity({\n type: 'stripe_invoice',\n id: inv.id,\n attributes: {\n customerId: inv.customer ?? null,\n subscriptionId: inv.subscription ?? null,\n status: inv.status ?? null,\n amountDue: inv.amount_due,\n amountPaid: inv.amount_paid,\n currency: inv.currency,\n created: inv.created,\n dueDate: inv.due_date ?? null,\n hostedInvoiceUrl: inv.hosted_invoice_url ?? null,\n },\n updated_at: inv.created * 1000,\n });\n }\n return;\n case 'charges':\n for (const c of items as StripeCharge[]) {\n await storage.event({\n name: 'stripe_charge',\n start_ts: c.created * 1000,\n end_ts: null,\n attributes: {\n id: c.id,\n customerId: c.customer ?? null,\n amount: c.amount,\n currency: c.currency,\n status: c.status,\n failureCode: c.failure_code ?? null,\n paymentIntentId: c.payment_intent ?? null,\n },\n });\n }\n return;\n case 'payment_intents':\n for (const pi of items as StripePaymentIntent[]) {\n await storage.event({\n name: 'stripe_payment_intent',\n start_ts: pi.created * 1000,\n end_ts: null,\n attributes: {\n id: pi.id,\n customerId: pi.customer ?? null,\n amount: pi.amount,\n currency: pi.currency,\n status: pi.status,\n },\n });\n }\n return;\n case 'disputes':\n for (const d of items as StripeDispute[]) {\n await storage.event({\n name: 'stripe_dispute',\n start_ts: d.created * 1000,\n end_ts: null,\n attributes: {\n id: d.id,\n chargeId: d.charge,\n amount: d.amount,\n currency: d.currency,\n reason: d.reason,\n status: d.status,\n },\n });\n }\n return;\n case 'refunds':\n for (const r of items as StripeRefund[]) {\n await storage.event({\n name: 'stripe_refund',\n start_ts: r.created * 1000,\n end_ts: null,\n attributes: {\n id: r.id,\n chargeId: r.charge ?? null,\n amount: r.amount,\n currency: r.currency,\n reason: r.reason ?? null,\n status: r.status ?? null,\n },\n });\n }\n return;\n }\n }\n\n async sync(\n options: SyncOptions,\n storage: StorageHandle,\n signal?: AbortSignal,\n ): Promise<SyncResult> {\n const cursor = isStripeSyncCursor(options.cursor)\n ? options.cursor\n : undefined;\n const isFull = options.mode === 'full';\n\n const phases = selectActivePhases<StripeResource, StripePhase>(\n (r) => r,\n PHASE_ORDER,\n this.settings.resources,\n );\n\n return paginateChunked<StripePhase, string>({\n phases,\n cursor,\n signal,\n logger: this.logger,\n fetchPage: async (phase, page, sig) => {\n const url = this.buildPhaseUrl(phase, page, options);\n const res = await this.fetch<StripeListResponse<{ id: string }>>(\n url,\n phase,\n sig,\n );\n const { data, has_more } = res.body;\n const next = has_more && data.length > 0 ? data.at(-1)!.id : null;\n return { items: data, next };\n },\n writeBatch: async (phase, items, page) => {\n if (isFull && page === null) {\n await this.clearScopeOnFirstPage(storage, phase);\n }\n await this.writePhase(storage, phase, items);\n },\n });\n }\n}\n","import { StripeConnector } from './stripe';\n\nexport {\n configFields,\n doc,\n StripeConnector,\n computeMrrAmountCents,\n stripeResources as resources,\n id,\n} from './stripe';\nexport type { StripeSettings } from './stripe';\nexport default StripeConnector;\n"],"mappings":";AEAO,IAAM,sBAAsB;AAE5B,IAAM,qBAAqB,qBAAqB,mBAAmB;AAEnE,SAAS,mBAAmB,aAA6B;AAC9D,SAAO,qBAAqB,WAAW,IAAI,mBAAmB;AAChE;;;AQFA;AAAA,EACE;AAAA,EASA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,SAAS;AAEX,IAAM,eAAe;AAAA,EAC1B,EAAE,OAAO;AAAA,IACP,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK;AAAA,MAC7C,OAAO;AAAA,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name": "@rawdash/connector-stripe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Rawdash connector for Stripe — billing, subscriptions, and payments",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"zod": "^4.4.3",
|
|
27
|
-
"@rawdash/core": "0.
|
|
27
|
+
"@rawdash/core": "0.23.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"fast-check": "^4.8.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typescript": "^5.7.2",
|
|
33
33
|
"vitest": "^4.1.4",
|
|
34
34
|
"@rawdash/connector-shared": "0.3.1",
|
|
35
|
-
"@rawdash/connector-test-utils": "0.0.
|
|
35
|
+
"@rawdash/connector-test-utils": "0.0.10"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup",
|