pocketsflow 1.0.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 +354 -0
- package/dist/index.d.mts +483 -0
- package/dist/index.d.ts +483 -0
- package/dist/index.js +337 -0
- package/dist/index.mjs +309 -0
- package/package.json +52 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
interface PocketsflowConfig {
|
|
2
|
+
/** Your Pocketsflow API key (pk_live_... or pk_test_...) */
|
|
3
|
+
apiKey: string;
|
|
4
|
+
/** Base URL for the API (defaults to https://api.pocketsflow.com) */
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
/** Request timeout in milliseconds (defaults to 30000) */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
interface PaginationParams {
|
|
10
|
+
page?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
}
|
|
13
|
+
interface PaginatedResponse<T> {
|
|
14
|
+
data: T[];
|
|
15
|
+
pagination: {
|
|
16
|
+
totalCount: number;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
currentPage: number;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
hasMore: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
interface DateRangeParams {
|
|
24
|
+
startDate?: string;
|
|
25
|
+
endDate?: string;
|
|
26
|
+
}
|
|
27
|
+
interface Product {
|
|
28
|
+
_id: string;
|
|
29
|
+
userId: string;
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
price: number;
|
|
33
|
+
currency: string;
|
|
34
|
+
type: 'one-time' | 'subscription';
|
|
35
|
+
billingInterval?: 'month' | 'year';
|
|
36
|
+
active: boolean;
|
|
37
|
+
published: boolean;
|
|
38
|
+
slug?: string;
|
|
39
|
+
images?: string[];
|
|
40
|
+
files?: ProductFile[];
|
|
41
|
+
testMode: boolean;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
interface ProductFile {
|
|
46
|
+
name: string;
|
|
47
|
+
url: string;
|
|
48
|
+
size?: number;
|
|
49
|
+
}
|
|
50
|
+
interface CreateProductParams {
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
price: number;
|
|
54
|
+
currency?: string;
|
|
55
|
+
type?: 'one-time' | 'subscription';
|
|
56
|
+
billingInterval?: 'month' | 'year';
|
|
57
|
+
active?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface UpdateProductParams {
|
|
60
|
+
name?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
price?: number;
|
|
63
|
+
currency?: string;
|
|
64
|
+
active?: boolean;
|
|
65
|
+
published?: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface ProductVariant {
|
|
68
|
+
_id: string;
|
|
69
|
+
productId: string;
|
|
70
|
+
name: string;
|
|
71
|
+
price: number;
|
|
72
|
+
description?: string;
|
|
73
|
+
active: boolean;
|
|
74
|
+
createdAt: string;
|
|
75
|
+
updatedAt: string;
|
|
76
|
+
}
|
|
77
|
+
interface CreateVariantParams {
|
|
78
|
+
productId: string;
|
|
79
|
+
name: string;
|
|
80
|
+
price: number;
|
|
81
|
+
description?: string;
|
|
82
|
+
}
|
|
83
|
+
interface Order {
|
|
84
|
+
_id: string;
|
|
85
|
+
userId: string;
|
|
86
|
+
productId: string;
|
|
87
|
+
buyerEmail: string;
|
|
88
|
+
grossAmount: number;
|
|
89
|
+
netAmount: number;
|
|
90
|
+
taxAmount: number;
|
|
91
|
+
stripeFee?: number;
|
|
92
|
+
paypalFee?: number;
|
|
93
|
+
affiliateCut?: number;
|
|
94
|
+
currency: string;
|
|
95
|
+
country?: string;
|
|
96
|
+
isRefunded: boolean;
|
|
97
|
+
isDisputed: boolean;
|
|
98
|
+
testMode: boolean;
|
|
99
|
+
product?: Product;
|
|
100
|
+
customer?: {
|
|
101
|
+
_id: string;
|
|
102
|
+
buyerEmail: string;
|
|
103
|
+
};
|
|
104
|
+
createdAt: string;
|
|
105
|
+
}
|
|
106
|
+
interface ListOrdersParams extends PaginationParams, DateRangeParams {
|
|
107
|
+
productId?: string;
|
|
108
|
+
}
|
|
109
|
+
interface OrdersResponse {
|
|
110
|
+
orders: Order[];
|
|
111
|
+
pagination: {
|
|
112
|
+
totalCount: number;
|
|
113
|
+
totalPages: number;
|
|
114
|
+
currentPage: number;
|
|
115
|
+
pageSize: number;
|
|
116
|
+
hasMore: boolean;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface Customer {
|
|
120
|
+
_id: string;
|
|
121
|
+
userId: string;
|
|
122
|
+
buyerEmail: string;
|
|
123
|
+
country?: string;
|
|
124
|
+
numberOfOrders: number;
|
|
125
|
+
totalSpent: number;
|
|
126
|
+
testMode: boolean;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
}
|
|
129
|
+
interface ListCustomersParams {
|
|
130
|
+
email?: string;
|
|
131
|
+
productId?: string;
|
|
132
|
+
sortBy?: 'email' | 'country' | 'numberOfOrders' | 'createdAt';
|
|
133
|
+
sortOrder?: 'asc' | 'desc';
|
|
134
|
+
limit?: number;
|
|
135
|
+
offset?: number;
|
|
136
|
+
}
|
|
137
|
+
interface Review {
|
|
138
|
+
_id: string;
|
|
139
|
+
productId: string;
|
|
140
|
+
userId: string;
|
|
141
|
+
buyerEmail: string;
|
|
142
|
+
rating: number;
|
|
143
|
+
review?: string;
|
|
144
|
+
testMode: boolean;
|
|
145
|
+
createdAt: string;
|
|
146
|
+
}
|
|
147
|
+
interface ListReviewsParams {
|
|
148
|
+
productId?: string;
|
|
149
|
+
}
|
|
150
|
+
interface Discount {
|
|
151
|
+
_id: string;
|
|
152
|
+
userId: string;
|
|
153
|
+
name: string;
|
|
154
|
+
code: string;
|
|
155
|
+
value: number;
|
|
156
|
+
valueType: 'percentage' | 'fixed';
|
|
157
|
+
active: boolean;
|
|
158
|
+
mainProductIds: string[];
|
|
159
|
+
expiration?: string;
|
|
160
|
+
used?: number;
|
|
161
|
+
testMode: boolean;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
}
|
|
164
|
+
interface CreateDiscountParams {
|
|
165
|
+
name: string;
|
|
166
|
+
code: string;
|
|
167
|
+
value: number;
|
|
168
|
+
valueType: 'percentage' | 'fixed';
|
|
169
|
+
active?: boolean;
|
|
170
|
+
mainProductIds: string[];
|
|
171
|
+
expiration?: string;
|
|
172
|
+
}
|
|
173
|
+
interface UpdateDiscountParams {
|
|
174
|
+
name?: string;
|
|
175
|
+
code?: string;
|
|
176
|
+
value?: number;
|
|
177
|
+
valueType?: 'percentage' | 'fixed';
|
|
178
|
+
active?: boolean;
|
|
179
|
+
mainProductIds?: string[];
|
|
180
|
+
expiration?: string;
|
|
181
|
+
}
|
|
182
|
+
interface Upsell {
|
|
183
|
+
_id: string;
|
|
184
|
+
userId: string;
|
|
185
|
+
name: string;
|
|
186
|
+
mainProductIds: string[];
|
|
187
|
+
upsellProductId: string;
|
|
188
|
+
upsellPrice: number;
|
|
189
|
+
upsellDescription?: string;
|
|
190
|
+
primaryButtonText?: string;
|
|
191
|
+
secondaryButtonText?: string;
|
|
192
|
+
offer?: string;
|
|
193
|
+
active: boolean;
|
|
194
|
+
testMode: boolean;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
}
|
|
197
|
+
interface UpsellsResponse {
|
|
198
|
+
upsells: Upsell[];
|
|
199
|
+
salesWithUpsells: any[];
|
|
200
|
+
}
|
|
201
|
+
interface CreateUpsellParams {
|
|
202
|
+
name: string;
|
|
203
|
+
mainProductIds: string[];
|
|
204
|
+
upsellProductId: string;
|
|
205
|
+
upsellPrice: number;
|
|
206
|
+
upsellDescription?: string;
|
|
207
|
+
primaryButtonText?: string;
|
|
208
|
+
secondaryButtonText?: string;
|
|
209
|
+
offer?: string;
|
|
210
|
+
active?: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface UpdateUpsellParams {
|
|
213
|
+
name?: string;
|
|
214
|
+
mainProductIds?: string[];
|
|
215
|
+
upsellProductId?: string;
|
|
216
|
+
upsellPrice?: number;
|
|
217
|
+
upsellDescription?: string;
|
|
218
|
+
primaryButtonText?: string;
|
|
219
|
+
secondaryButtonText?: string;
|
|
220
|
+
offer?: string;
|
|
221
|
+
active?: boolean;
|
|
222
|
+
}
|
|
223
|
+
interface Subscription {
|
|
224
|
+
_id: string;
|
|
225
|
+
userId: string;
|
|
226
|
+
customerId: string;
|
|
227
|
+
productId: string;
|
|
228
|
+
stripeSubscriptionId?: string;
|
|
229
|
+
status: 'active' | 'canceled' | 'paused' | 'past_due';
|
|
230
|
+
currentPeriodStart: string;
|
|
231
|
+
currentPeriodEnd: string;
|
|
232
|
+
cancelAtPeriodEnd: boolean;
|
|
233
|
+
testMode: boolean;
|
|
234
|
+
createdAt: string;
|
|
235
|
+
}
|
|
236
|
+
interface ListSubscriptionsParams extends PaginationParams, DateRangeParams {
|
|
237
|
+
status?: 'active' | 'canceled' | 'paused';
|
|
238
|
+
}
|
|
239
|
+
interface Webhook {
|
|
240
|
+
_id: string;
|
|
241
|
+
userId: string;
|
|
242
|
+
url: string;
|
|
243
|
+
events: string[];
|
|
244
|
+
description?: string;
|
|
245
|
+
active: boolean;
|
|
246
|
+
secret: string;
|
|
247
|
+
testMode: boolean;
|
|
248
|
+
createdAt: string;
|
|
249
|
+
}
|
|
250
|
+
interface CreateWebhookParams {
|
|
251
|
+
url: string;
|
|
252
|
+
events: string[];
|
|
253
|
+
description?: string;
|
|
254
|
+
active?: boolean;
|
|
255
|
+
}
|
|
256
|
+
interface UpdateWebhookParams {
|
|
257
|
+
url?: string;
|
|
258
|
+
events?: string[];
|
|
259
|
+
description?: string;
|
|
260
|
+
active?: boolean;
|
|
261
|
+
}
|
|
262
|
+
interface User {
|
|
263
|
+
_id: string;
|
|
264
|
+
userId: string;
|
|
265
|
+
email: string;
|
|
266
|
+
name?: string;
|
|
267
|
+
firstName?: string;
|
|
268
|
+
lastName?: string;
|
|
269
|
+
subdomain?: string;
|
|
270
|
+
currency: string;
|
|
271
|
+
country?: string;
|
|
272
|
+
testMode: boolean;
|
|
273
|
+
hasSales: boolean;
|
|
274
|
+
createdFirstProduct?: boolean;
|
|
275
|
+
}
|
|
276
|
+
interface UpdateUserParams {
|
|
277
|
+
firstName?: string;
|
|
278
|
+
lastName?: string;
|
|
279
|
+
currency?: string;
|
|
280
|
+
country?: string;
|
|
281
|
+
subdomain?: string;
|
|
282
|
+
contactEmail?: string;
|
|
283
|
+
}
|
|
284
|
+
interface CreateCheckoutParams {
|
|
285
|
+
productId: string;
|
|
286
|
+
successUrl: string;
|
|
287
|
+
cancelUrl: string;
|
|
288
|
+
customerEmail?: string;
|
|
289
|
+
discountCode?: string;
|
|
290
|
+
metadata?: Record<string, any>;
|
|
291
|
+
}
|
|
292
|
+
interface CheckoutSession {
|
|
293
|
+
id: string;
|
|
294
|
+
url: string;
|
|
295
|
+
}
|
|
296
|
+
interface Refund {
|
|
297
|
+
_id: string;
|
|
298
|
+
orderId: string;
|
|
299
|
+
amount: number;
|
|
300
|
+
reason?: string;
|
|
301
|
+
status: 'pending' | 'completed' | 'failed';
|
|
302
|
+
createdAt: string;
|
|
303
|
+
}
|
|
304
|
+
interface CreateRefundParams {
|
|
305
|
+
orderId: string;
|
|
306
|
+
amount?: number;
|
|
307
|
+
reason?: string;
|
|
308
|
+
}
|
|
309
|
+
interface ApiError {
|
|
310
|
+
message: string;
|
|
311
|
+
code?: string;
|
|
312
|
+
status?: number;
|
|
313
|
+
}
|
|
314
|
+
declare class PocketsflowError extends Error {
|
|
315
|
+
code?: string;
|
|
316
|
+
status?: number;
|
|
317
|
+
constructor(message: string, code?: string, status?: number);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
declare class Pocketsflow {
|
|
321
|
+
private apiKey;
|
|
322
|
+
private baseUrl;
|
|
323
|
+
private timeout;
|
|
324
|
+
products: ProductsResource;
|
|
325
|
+
variants: VariantsResource;
|
|
326
|
+
orders: OrdersResource;
|
|
327
|
+
customers: CustomersResource;
|
|
328
|
+
reviews: ReviewsResource;
|
|
329
|
+
discounts: DiscountsResource;
|
|
330
|
+
upsells: UpsellsResource;
|
|
331
|
+
subscriptions: SubscriptionsResource;
|
|
332
|
+
webhooks: WebhooksResource;
|
|
333
|
+
users: UsersResource;
|
|
334
|
+
checkout: CheckoutResource;
|
|
335
|
+
refunds: RefundsResource;
|
|
336
|
+
constructor(config: PocketsflowConfig);
|
|
337
|
+
request<T>(method: string, path: string, options?: {
|
|
338
|
+
body?: any;
|
|
339
|
+
params?: Record<string, any>;
|
|
340
|
+
}): Promise<T>;
|
|
341
|
+
}
|
|
342
|
+
declare class ProductsResource {
|
|
343
|
+
private client;
|
|
344
|
+
constructor(client: Pocketsflow);
|
|
345
|
+
/** List all products */
|
|
346
|
+
list(): Promise<Product[]>;
|
|
347
|
+
/** Get a product by ID */
|
|
348
|
+
get(id: string): Promise<Product>;
|
|
349
|
+
/** Create a new product */
|
|
350
|
+
create(params: CreateProductParams): Promise<Product>;
|
|
351
|
+
/** Update a product */
|
|
352
|
+
update(id: string, params: UpdateProductParams): Promise<Product>;
|
|
353
|
+
/** Delete a product */
|
|
354
|
+
delete(id: string): Promise<{
|
|
355
|
+
message: string;
|
|
356
|
+
}>;
|
|
357
|
+
}
|
|
358
|
+
declare class VariantsResource {
|
|
359
|
+
private client;
|
|
360
|
+
constructor(client: Pocketsflow);
|
|
361
|
+
/** Create a product variant */
|
|
362
|
+
create(params: CreateVariantParams): Promise<ProductVariant>;
|
|
363
|
+
/** Delete a product variant */
|
|
364
|
+
delete(id: string): Promise<{
|
|
365
|
+
message: string;
|
|
366
|
+
}>;
|
|
367
|
+
}
|
|
368
|
+
declare class OrdersResource {
|
|
369
|
+
private client;
|
|
370
|
+
constructor(client: Pocketsflow);
|
|
371
|
+
/** List all orders with optional filters */
|
|
372
|
+
list(params?: ListOrdersParams): Promise<OrdersResponse>;
|
|
373
|
+
/** Get an order by ID */
|
|
374
|
+
get(id: string): Promise<Order>;
|
|
375
|
+
}
|
|
376
|
+
declare class CustomersResource {
|
|
377
|
+
private client;
|
|
378
|
+
constructor(client: Pocketsflow);
|
|
379
|
+
/** List all customers */
|
|
380
|
+
list(params?: ListCustomersParams): Promise<Customer[]>;
|
|
381
|
+
/** Get a customer by ID */
|
|
382
|
+
get(id: string): Promise<Customer>;
|
|
383
|
+
}
|
|
384
|
+
declare class ReviewsResource {
|
|
385
|
+
private client;
|
|
386
|
+
constructor(client: Pocketsflow);
|
|
387
|
+
/** List all reviews */
|
|
388
|
+
list(params?: ListReviewsParams): Promise<Review[]>;
|
|
389
|
+
}
|
|
390
|
+
declare class DiscountsResource {
|
|
391
|
+
private client;
|
|
392
|
+
constructor(client: Pocketsflow);
|
|
393
|
+
/** List all discounts */
|
|
394
|
+
list(): Promise<Discount[]>;
|
|
395
|
+
/** Get a discount by ID */
|
|
396
|
+
get(id: string): Promise<Discount>;
|
|
397
|
+
/** Create a new discount */
|
|
398
|
+
create(params: CreateDiscountParams): Promise<Discount>;
|
|
399
|
+
/** Update a discount */
|
|
400
|
+
update(id: string, params: UpdateDiscountParams): Promise<Discount>;
|
|
401
|
+
/** Delete a discount */
|
|
402
|
+
delete(id: string): Promise<{
|
|
403
|
+
message: string;
|
|
404
|
+
}>;
|
|
405
|
+
}
|
|
406
|
+
declare class UpsellsResource {
|
|
407
|
+
private client;
|
|
408
|
+
constructor(client: Pocketsflow);
|
|
409
|
+
/** List all upsells */
|
|
410
|
+
list(): Promise<UpsellsResponse>;
|
|
411
|
+
/** Get an upsell by ID */
|
|
412
|
+
get(id: string): Promise<Upsell>;
|
|
413
|
+
/** Create a new upsell */
|
|
414
|
+
create(params: CreateUpsellParams): Promise<Upsell>;
|
|
415
|
+
/** Update an upsell */
|
|
416
|
+
update(id: string, params: UpdateUpsellParams): Promise<Upsell>;
|
|
417
|
+
/** Delete an upsell */
|
|
418
|
+
delete(id: string): Promise<{
|
|
419
|
+
message: string;
|
|
420
|
+
}>;
|
|
421
|
+
}
|
|
422
|
+
declare class SubscriptionsResource {
|
|
423
|
+
private client;
|
|
424
|
+
constructor(client: Pocketsflow);
|
|
425
|
+
/** List subscription customers */
|
|
426
|
+
list(params?: ListSubscriptionsParams): Promise<any>;
|
|
427
|
+
/** Get a subscription by ID */
|
|
428
|
+
get(id: string): Promise<Subscription>;
|
|
429
|
+
/** Cancel a subscription */
|
|
430
|
+
cancel(stripeSubscriptionId: string): Promise<{
|
|
431
|
+
message: string;
|
|
432
|
+
}>;
|
|
433
|
+
/** Refund a subscription */
|
|
434
|
+
refund(stripeSubscriptionId: string): Promise<{
|
|
435
|
+
message: string;
|
|
436
|
+
}>;
|
|
437
|
+
}
|
|
438
|
+
declare class WebhooksResource {
|
|
439
|
+
private client;
|
|
440
|
+
constructor(client: Pocketsflow);
|
|
441
|
+
/** List all webhooks */
|
|
442
|
+
list(): Promise<Webhook[]>;
|
|
443
|
+
/** Get a webhook by ID */
|
|
444
|
+
get(id: string): Promise<Webhook>;
|
|
445
|
+
/** Create a new webhook */
|
|
446
|
+
create(params: CreateWebhookParams): Promise<Webhook>;
|
|
447
|
+
/** Update a webhook */
|
|
448
|
+
update(id: string, params: UpdateWebhookParams): Promise<Webhook>;
|
|
449
|
+
/** Delete a webhook */
|
|
450
|
+
delete(id: string): Promise<{
|
|
451
|
+
message: string;
|
|
452
|
+
}>;
|
|
453
|
+
/** Test a webhook */
|
|
454
|
+
test(id: string): Promise<{
|
|
455
|
+
message: string;
|
|
456
|
+
}>;
|
|
457
|
+
}
|
|
458
|
+
declare class UsersResource {
|
|
459
|
+
private client;
|
|
460
|
+
constructor(client: Pocketsflow);
|
|
461
|
+
/** Get current user information */
|
|
462
|
+
me(): Promise<User>;
|
|
463
|
+
/** Update current user */
|
|
464
|
+
update(params: UpdateUserParams): Promise<User>;
|
|
465
|
+
}
|
|
466
|
+
declare class CheckoutResource {
|
|
467
|
+
private client;
|
|
468
|
+
constructor(client: Pocketsflow);
|
|
469
|
+
/** Create a checkout session */
|
|
470
|
+
create(params: CreateCheckoutParams): Promise<CheckoutSession>;
|
|
471
|
+
}
|
|
472
|
+
declare class RefundsResource {
|
|
473
|
+
private client;
|
|
474
|
+
constructor(client: Pocketsflow);
|
|
475
|
+
/** List all refunds */
|
|
476
|
+
list(): Promise<Refund[]>;
|
|
477
|
+
/** Get a refund by ID */
|
|
478
|
+
get(id: string): Promise<Refund>;
|
|
479
|
+
/** Create a refund */
|
|
480
|
+
create(params: CreateRefundParams): Promise<Refund>;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export { type ApiError, type CheckoutSession, type CreateCheckoutParams, type CreateDiscountParams, type CreateProductParams, type CreateRefundParams, type CreateUpsellParams, type CreateVariantParams, type CreateWebhookParams, type Customer, type DateRangeParams, type Discount, type ListCustomersParams, type ListOrdersParams, type ListReviewsParams, type ListSubscriptionsParams, type Order, type OrdersResponse, type PaginatedResponse, type PaginationParams, Pocketsflow, type PocketsflowConfig, PocketsflowError, type Product, type ProductFile, type ProductVariant, type Refund, type Review, type Subscription, type UpdateDiscountParams, type UpdateProductParams, type UpdateUpsellParams, type UpdateUserParams, type UpdateWebhookParams, type Upsell, type UpsellsResponse, type User, type Webhook };
|