@pubflow/core 0.3.1 → 0.4.1
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 +45 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/payments/client.d.ts +523 -0
- package/dist/payments/client.js +804 -0
- package/dist/payments/index.d.ts +7 -0
- package/dist/payments/index.js +11 -0
- package/dist/payments/types.d.ts +649 -0
- package/dist/payments/types.js +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Payments Module
|
|
3
|
+
*
|
|
4
|
+
* Exports for Bridge Payments client and types
|
|
5
|
+
*/
|
|
6
|
+
export { BridgePaymentClient } from './client';
|
|
7
|
+
export type { BridgePaymentConfig, PaymentRequestOptions, CreatePaymentIntentRequest, PaymentIntent, Payment, PaymentMethodType, PaymentMethod, UpdatePaymentMethodRequest, AddressType, Address, CreateAddressRequest, UpdateAddressRequest, Customer, CreateCustomerRequest, UpdateCustomerRequest, SubscriptionStatus, Subscription, CreateSubscriptionRequest, CancelSubscriptionRequest, OrganizationRole, Organization, CreateOrganizationRequest, UpdateOrganizationRequest, OrganizationMember, AddOrganizationMemberRequest, UpdateOrganizationMemberRoleRequest, ConvertGuestToUserRequest, ConvertGuestToUserResponse, PaginationParams, ListResponse, ScheduleType, IntervalType, BillingScheduleStatus, BillingSchedule, CreateBillingScheduleRequest, UpdateBillingScheduleRequest, BillingExecution, BalanceType, BalanceStatus, TransactionType, AccountBalance, CreateAccountBalanceRequest, UpdateAccountBalanceRequest, CreditBalanceRequest, DebitBalanceRequest, AccountTransaction, CostType, ProductCost, CreateProductCostRequest, UpdateProductCostRequest, OrderCost, CreateOrderCostRequest, TotalCostResponse } from './types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bridge Payments Module
|
|
4
|
+
*
|
|
5
|
+
* Exports for Bridge Payments client and types
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BridgePaymentClient = void 0;
|
|
9
|
+
// Export client
|
|
10
|
+
var client_1 = require("./client");
|
|
11
|
+
Object.defineProperty(exports, "BridgePaymentClient", { enumerable: true, get: function () { return client_1.BridgePaymentClient; } });
|
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Payments Types
|
|
3
|
+
*
|
|
4
|
+
* TypeScript interfaces for Bridge Payments API
|
|
5
|
+
*/
|
|
6
|
+
import { RequestOptions } from '../api/types';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for Bridge Payment Client
|
|
9
|
+
*/
|
|
10
|
+
export interface BridgePaymentConfig {
|
|
11
|
+
/**
|
|
12
|
+
* Base URL of the Bridge Payments instance
|
|
13
|
+
* Example: 'https://your-instance.pubflow.com'
|
|
14
|
+
*/
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
/**
|
|
17
|
+
* Guest token (optional)
|
|
18
|
+
* If provided, all requests will use X-Guest-Token header
|
|
19
|
+
*/
|
|
20
|
+
guestToken?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Organization ID (optional)
|
|
23
|
+
*
|
|
24
|
+
* ✅ SUPPORTED IN:
|
|
25
|
+
* - Subscriptions (complete)
|
|
26
|
+
* - Customers (complete)
|
|
27
|
+
*
|
|
28
|
+
* ⚠️ NOT SUPPORTED IN (backend hardcoded null):
|
|
29
|
+
* - Addresses
|
|
30
|
+
* - Payments (partial - only customers)
|
|
31
|
+
* - Payment Methods
|
|
32
|
+
*
|
|
33
|
+
* The client is prepared for when the backend is updated.
|
|
34
|
+
*/
|
|
35
|
+
organizationId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Pubflow instance ID (optional)
|
|
38
|
+
* Default: 'bridge-payments'
|
|
39
|
+
*/
|
|
40
|
+
instanceId?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Custom headers (optional)
|
|
43
|
+
*/
|
|
44
|
+
headers?: Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Storage adapter (optional, uses Pubflow default)
|
|
47
|
+
*/
|
|
48
|
+
storage?: any;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Request options for payment operations
|
|
52
|
+
*/
|
|
53
|
+
export interface PaymentRequestOptions extends RequestOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Guest token for this specific request
|
|
56
|
+
* Overrides the client's guestToken
|
|
57
|
+
*/
|
|
58
|
+
guestToken?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Organization ID for this specific request
|
|
61
|
+
* Overrides the client's organizationId
|
|
62
|
+
*/
|
|
63
|
+
organizationId?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Request to create a payment intent
|
|
67
|
+
*/
|
|
68
|
+
export interface CreatePaymentIntentRequest {
|
|
69
|
+
total_cents?: number;
|
|
70
|
+
subtotal_cents?: number;
|
|
71
|
+
tax_cents?: number;
|
|
72
|
+
discount_cents?: number;
|
|
73
|
+
shipping_cents?: number;
|
|
74
|
+
currency: string;
|
|
75
|
+
provider_id: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
concept?: string;
|
|
78
|
+
reference_code?: string;
|
|
79
|
+
category?: string;
|
|
80
|
+
guest_data?: {
|
|
81
|
+
email: string;
|
|
82
|
+
name: string;
|
|
83
|
+
phone?: string;
|
|
84
|
+
};
|
|
85
|
+
payment_method_id?: string;
|
|
86
|
+
save_payment_method?: boolean;
|
|
87
|
+
metadata?: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Payment Intent response
|
|
91
|
+
*/
|
|
92
|
+
export interface PaymentIntent {
|
|
93
|
+
id: string;
|
|
94
|
+
client_secret: string;
|
|
95
|
+
status: string;
|
|
96
|
+
total_cents: number;
|
|
97
|
+
currency: string;
|
|
98
|
+
provider_id: string;
|
|
99
|
+
user_id?: string;
|
|
100
|
+
guest_email?: string;
|
|
101
|
+
guest_token?: string;
|
|
102
|
+
created_at: string;
|
|
103
|
+
updated_at: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Payment response
|
|
107
|
+
*/
|
|
108
|
+
export interface Payment {
|
|
109
|
+
id: string;
|
|
110
|
+
user_id?: string;
|
|
111
|
+
guest_email?: string;
|
|
112
|
+
provider_id: string;
|
|
113
|
+
provider_payment_id: string;
|
|
114
|
+
total_cents: number;
|
|
115
|
+
currency: string;
|
|
116
|
+
status: string;
|
|
117
|
+
description?: string;
|
|
118
|
+
metadata?: Record<string, any>;
|
|
119
|
+
created_at: string;
|
|
120
|
+
updated_at: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Payment method type
|
|
124
|
+
*/
|
|
125
|
+
export type PaymentMethodType = 'card' | 'bank_account' | 'paypal' | 'apple_pay' | 'google_pay';
|
|
126
|
+
/**
|
|
127
|
+
* Payment Method response
|
|
128
|
+
*/
|
|
129
|
+
export interface PaymentMethod {
|
|
130
|
+
id: string;
|
|
131
|
+
user_id?: string;
|
|
132
|
+
guest_email?: string;
|
|
133
|
+
organization_id?: string;
|
|
134
|
+
provider_id: string;
|
|
135
|
+
provider_payment_method_id: string;
|
|
136
|
+
type: PaymentMethodType;
|
|
137
|
+
last4?: string;
|
|
138
|
+
brand?: string;
|
|
139
|
+
exp_month?: number;
|
|
140
|
+
exp_year?: number;
|
|
141
|
+
alias?: string;
|
|
142
|
+
is_default: boolean;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Request to update a payment method
|
|
148
|
+
*/
|
|
149
|
+
export interface UpdatePaymentMethodRequest {
|
|
150
|
+
alias?: string;
|
|
151
|
+
is_default?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Address type
|
|
155
|
+
*/
|
|
156
|
+
export type AddressType = 'billing' | 'shipping';
|
|
157
|
+
/**
|
|
158
|
+
* Address response
|
|
159
|
+
*/
|
|
160
|
+
export interface Address {
|
|
161
|
+
id: string;
|
|
162
|
+
user_id?: string;
|
|
163
|
+
guest_email?: string;
|
|
164
|
+
organization_id?: string;
|
|
165
|
+
address_type: AddressType;
|
|
166
|
+
name: string;
|
|
167
|
+
line1: string;
|
|
168
|
+
line2?: string;
|
|
169
|
+
city: string;
|
|
170
|
+
state?: string;
|
|
171
|
+
postal_code: string;
|
|
172
|
+
country: string;
|
|
173
|
+
phone?: string;
|
|
174
|
+
is_default: boolean;
|
|
175
|
+
created_at: string;
|
|
176
|
+
updated_at: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Request to create an address
|
|
180
|
+
*/
|
|
181
|
+
export interface CreateAddressRequest {
|
|
182
|
+
address_type: AddressType;
|
|
183
|
+
name: string;
|
|
184
|
+
line1: string;
|
|
185
|
+
line2?: string;
|
|
186
|
+
city: string;
|
|
187
|
+
state?: string;
|
|
188
|
+
postal_code: string;
|
|
189
|
+
country: string;
|
|
190
|
+
phone?: string;
|
|
191
|
+
is_default?: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Request to update an address
|
|
195
|
+
*/
|
|
196
|
+
export interface UpdateAddressRequest {
|
|
197
|
+
address_type?: AddressType;
|
|
198
|
+
name?: string;
|
|
199
|
+
line1?: string;
|
|
200
|
+
line2?: string;
|
|
201
|
+
city?: string;
|
|
202
|
+
state?: string;
|
|
203
|
+
postal_code?: string;
|
|
204
|
+
country?: string;
|
|
205
|
+
phone?: string;
|
|
206
|
+
is_default?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Customer response
|
|
210
|
+
*/
|
|
211
|
+
export interface Customer {
|
|
212
|
+
id: string;
|
|
213
|
+
user_id?: string;
|
|
214
|
+
guest_email?: string;
|
|
215
|
+
organization_id?: string;
|
|
216
|
+
provider_id: string;
|
|
217
|
+
provider_customer_id: string;
|
|
218
|
+
email: string;
|
|
219
|
+
name: string;
|
|
220
|
+
phone?: string;
|
|
221
|
+
metadata?: Record<string, any>;
|
|
222
|
+
created_at: string;
|
|
223
|
+
updated_at: string;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Request to create a customer
|
|
227
|
+
*/
|
|
228
|
+
export interface CreateCustomerRequest {
|
|
229
|
+
email: string;
|
|
230
|
+
name: string;
|
|
231
|
+
phone?: string;
|
|
232
|
+
provider_id?: string;
|
|
233
|
+
metadata?: Record<string, any>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Request to update a customer
|
|
237
|
+
*/
|
|
238
|
+
export interface UpdateCustomerRequest {
|
|
239
|
+
email?: string;
|
|
240
|
+
name?: string;
|
|
241
|
+
phone?: string;
|
|
242
|
+
metadata?: Record<string, any>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Subscription status
|
|
246
|
+
*/
|
|
247
|
+
export type SubscriptionStatus = 'active' | 'canceled' | 'past_due' | 'unpaid' | 'incomplete' | 'trialing';
|
|
248
|
+
/**
|
|
249
|
+
* Subscription response
|
|
250
|
+
*/
|
|
251
|
+
export interface Subscription {
|
|
252
|
+
id: string;
|
|
253
|
+
user_id?: string;
|
|
254
|
+
organization_id?: string;
|
|
255
|
+
customer_id: string;
|
|
256
|
+
product_id?: string;
|
|
257
|
+
provider_id: string;
|
|
258
|
+
provider_subscription_id: string;
|
|
259
|
+
status: SubscriptionStatus;
|
|
260
|
+
current_period_start: string;
|
|
261
|
+
current_period_end: string;
|
|
262
|
+
cancel_at_period_end: boolean;
|
|
263
|
+
canceled_at?: string;
|
|
264
|
+
metadata?: Record<string, any>;
|
|
265
|
+
created_at: string;
|
|
266
|
+
updated_at: string;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Request to create a subscription
|
|
270
|
+
*/
|
|
271
|
+
export interface CreateSubscriptionRequest {
|
|
272
|
+
customer_id: string;
|
|
273
|
+
product_id?: string;
|
|
274
|
+
payment_method_id: string;
|
|
275
|
+
provider_id?: string;
|
|
276
|
+
trial_days?: number;
|
|
277
|
+
metadata?: Record<string, any>;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Request to cancel a subscription
|
|
281
|
+
*/
|
|
282
|
+
export interface CancelSubscriptionRequest {
|
|
283
|
+
cancel_at_period_end?: boolean;
|
|
284
|
+
reason?: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Organization role
|
|
288
|
+
*/
|
|
289
|
+
export type OrganizationRole = 'owner' | 'admin' | 'billing' | 'member';
|
|
290
|
+
/**
|
|
291
|
+
* Organization response
|
|
292
|
+
*/
|
|
293
|
+
export interface Organization {
|
|
294
|
+
id: string;
|
|
295
|
+
name: string;
|
|
296
|
+
business_email?: string;
|
|
297
|
+
business_phone?: string;
|
|
298
|
+
tax_id?: string;
|
|
299
|
+
address?: string;
|
|
300
|
+
metadata?: Record<string, any>;
|
|
301
|
+
created_at: string;
|
|
302
|
+
updated_at: string;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Request to create an organization
|
|
306
|
+
*/
|
|
307
|
+
export interface CreateOrganizationRequest {
|
|
308
|
+
name: string;
|
|
309
|
+
business_email?: string;
|
|
310
|
+
business_phone?: string;
|
|
311
|
+
tax_id?: string;
|
|
312
|
+
address?: string;
|
|
313
|
+
metadata?: Record<string, any>;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Request to update an organization
|
|
317
|
+
*/
|
|
318
|
+
export interface UpdateOrganizationRequest {
|
|
319
|
+
name?: string;
|
|
320
|
+
business_email?: string;
|
|
321
|
+
business_phone?: string;
|
|
322
|
+
tax_id?: string;
|
|
323
|
+
address?: string;
|
|
324
|
+
metadata?: Record<string, any>;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Organization member response
|
|
328
|
+
*/
|
|
329
|
+
export interface OrganizationMember {
|
|
330
|
+
id: string;
|
|
331
|
+
organization_id: string;
|
|
332
|
+
user_id: string;
|
|
333
|
+
role: OrganizationRole;
|
|
334
|
+
created_at: string;
|
|
335
|
+
updated_at: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Request to add an organization member
|
|
339
|
+
*/
|
|
340
|
+
export interface AddOrganizationMemberRequest {
|
|
341
|
+
email: string;
|
|
342
|
+
role: OrganizationRole;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Request to update an organization member role
|
|
346
|
+
*/
|
|
347
|
+
export interface UpdateOrganizationMemberRoleRequest {
|
|
348
|
+
role: OrganizationRole;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Request to convert guest to user
|
|
352
|
+
*/
|
|
353
|
+
export interface ConvertGuestToUserRequest {
|
|
354
|
+
guest_email: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Response from guest conversion
|
|
358
|
+
*/
|
|
359
|
+
export interface ConvertGuestToUserResponse {
|
|
360
|
+
success: boolean;
|
|
361
|
+
message: string;
|
|
362
|
+
payments_count: number;
|
|
363
|
+
payment_methods_count: number;
|
|
364
|
+
addresses_count: number;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Pagination parameters
|
|
368
|
+
*/
|
|
369
|
+
export interface PaginationParams {
|
|
370
|
+
page?: number;
|
|
371
|
+
limit?: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* List response with pagination
|
|
375
|
+
*/
|
|
376
|
+
export interface ListResponse<T> {
|
|
377
|
+
data: T[];
|
|
378
|
+
pagination: {
|
|
379
|
+
page: number;
|
|
380
|
+
limit: number;
|
|
381
|
+
total: number;
|
|
382
|
+
hasMore: boolean;
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Schedule type
|
|
387
|
+
*/
|
|
388
|
+
export type ScheduleType = 'subscription' | 'installment' | 'recurring_invoice' | 'custom';
|
|
389
|
+
/**
|
|
390
|
+
* Interval type
|
|
391
|
+
*/
|
|
392
|
+
export type IntervalType = 'daily' | 'weekly' | 'monthly' | 'yearly' | 'custom';
|
|
393
|
+
/**
|
|
394
|
+
* Billing schedule status
|
|
395
|
+
*/
|
|
396
|
+
export type BillingScheduleStatus = 'active' | 'paused' | 'completed' | 'failed' | 'canceled';
|
|
397
|
+
/**
|
|
398
|
+
* Billing schedule response
|
|
399
|
+
*/
|
|
400
|
+
export interface BillingSchedule {
|
|
401
|
+
id: string;
|
|
402
|
+
user_id?: string;
|
|
403
|
+
organization_id?: string;
|
|
404
|
+
schedule_type: ScheduleType;
|
|
405
|
+
amount_cents: number;
|
|
406
|
+
currency: string;
|
|
407
|
+
interval_type: IntervalType;
|
|
408
|
+
interval_count: number;
|
|
409
|
+
next_billing_date: string;
|
|
410
|
+
end_date?: string;
|
|
411
|
+
max_occurrences?: number;
|
|
412
|
+
current_occurrence: number;
|
|
413
|
+
payment_method_id?: string;
|
|
414
|
+
account_balance_id?: string;
|
|
415
|
+
auto_charge: boolean;
|
|
416
|
+
send_invoice: boolean;
|
|
417
|
+
retry_on_failure: boolean;
|
|
418
|
+
max_retries: number;
|
|
419
|
+
status: BillingScheduleStatus;
|
|
420
|
+
last_billing_date?: string;
|
|
421
|
+
last_billing_status?: string;
|
|
422
|
+
description?: string;
|
|
423
|
+
metadata?: Record<string, any>;
|
|
424
|
+
created_at: string;
|
|
425
|
+
updated_at: string;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Request to create a billing schedule
|
|
429
|
+
*/
|
|
430
|
+
export interface CreateBillingScheduleRequest {
|
|
431
|
+
user_id?: string;
|
|
432
|
+
organization_id?: string;
|
|
433
|
+
schedule_type: ScheduleType;
|
|
434
|
+
amount_cents: number;
|
|
435
|
+
currency?: string;
|
|
436
|
+
interval_type: IntervalType;
|
|
437
|
+
interval_count?: number;
|
|
438
|
+
next_billing_date: string;
|
|
439
|
+
end_date?: string;
|
|
440
|
+
max_occurrences?: number;
|
|
441
|
+
payment_method_id?: string;
|
|
442
|
+
account_balance_id?: string;
|
|
443
|
+
auto_charge?: boolean;
|
|
444
|
+
send_invoice?: boolean;
|
|
445
|
+
retry_on_failure?: boolean;
|
|
446
|
+
max_retries?: number;
|
|
447
|
+
description?: string;
|
|
448
|
+
metadata?: Record<string, any>;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Request to update a billing schedule
|
|
452
|
+
*/
|
|
453
|
+
export interface UpdateBillingScheduleRequest {
|
|
454
|
+
amount_cents?: number;
|
|
455
|
+
next_billing_date?: string;
|
|
456
|
+
end_date?: string;
|
|
457
|
+
max_occurrences?: number;
|
|
458
|
+
payment_method_id?: string;
|
|
459
|
+
account_balance_id?: string;
|
|
460
|
+
auto_charge?: boolean;
|
|
461
|
+
send_invoice?: boolean;
|
|
462
|
+
retry_on_failure?: boolean;
|
|
463
|
+
max_retries?: number;
|
|
464
|
+
description?: string;
|
|
465
|
+
metadata?: Record<string, any>;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Billing execution response
|
|
469
|
+
*/
|
|
470
|
+
export interface BillingExecution {
|
|
471
|
+
id: string;
|
|
472
|
+
billing_schedule_id: string;
|
|
473
|
+
execution_date: string;
|
|
474
|
+
amount_cents: number;
|
|
475
|
+
currency: string;
|
|
476
|
+
status: string;
|
|
477
|
+
payment_id?: string;
|
|
478
|
+
receipt_id?: string;
|
|
479
|
+
error_message?: string;
|
|
480
|
+
retry_count: number;
|
|
481
|
+
created_at: string;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Balance type
|
|
485
|
+
*/
|
|
486
|
+
export type BalanceType = 'general' | 'credits' | 'promotional' | 'refund';
|
|
487
|
+
/**
|
|
488
|
+
* Balance status
|
|
489
|
+
*/
|
|
490
|
+
export type BalanceStatus = 'active' | 'suspended' | 'expired' | 'closed';
|
|
491
|
+
/**
|
|
492
|
+
* Transaction type
|
|
493
|
+
*/
|
|
494
|
+
export type TransactionType = 'credit' | 'debit' | 'transfer' | 'expiration' | 'adjustment';
|
|
495
|
+
/**
|
|
496
|
+
* Account balance response
|
|
497
|
+
*/
|
|
498
|
+
export interface AccountBalance {
|
|
499
|
+
id: string;
|
|
500
|
+
user_id?: string;
|
|
501
|
+
organization_id?: string;
|
|
502
|
+
customer_id?: string;
|
|
503
|
+
balance_cents: number;
|
|
504
|
+
currency: string;
|
|
505
|
+
balance_type: BalanceType;
|
|
506
|
+
reference_code?: string;
|
|
507
|
+
status: BalanceStatus;
|
|
508
|
+
expires_at?: string;
|
|
509
|
+
metadata?: Record<string, any>;
|
|
510
|
+
created_at: string;
|
|
511
|
+
updated_at: string;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Request to create an account balance
|
|
515
|
+
*/
|
|
516
|
+
export interface CreateAccountBalanceRequest {
|
|
517
|
+
user_id?: string;
|
|
518
|
+
organization_id?: string;
|
|
519
|
+
customer_id?: string;
|
|
520
|
+
balance_type?: BalanceType;
|
|
521
|
+
balance_cents?: number;
|
|
522
|
+
currency?: string;
|
|
523
|
+
reference_code?: string;
|
|
524
|
+
expires_at?: string;
|
|
525
|
+
status?: BalanceStatus;
|
|
526
|
+
metadata?: Record<string, any>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Request to update an account balance
|
|
530
|
+
*/
|
|
531
|
+
export interface UpdateAccountBalanceRequest {
|
|
532
|
+
status?: BalanceStatus;
|
|
533
|
+
expires_at?: string;
|
|
534
|
+
metadata?: Record<string, any>;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Request to credit a balance
|
|
538
|
+
*/
|
|
539
|
+
export interface CreditBalanceRequest {
|
|
540
|
+
amount_cents: number;
|
|
541
|
+
description?: string;
|
|
542
|
+
reference_code?: string;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Request to debit a balance
|
|
546
|
+
*/
|
|
547
|
+
export interface DebitBalanceRequest {
|
|
548
|
+
amount_cents: number;
|
|
549
|
+
description?: string;
|
|
550
|
+
allow_negative?: boolean;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Account transaction response
|
|
554
|
+
*/
|
|
555
|
+
export interface AccountTransaction {
|
|
556
|
+
id: string;
|
|
557
|
+
account_balance_id: string;
|
|
558
|
+
transaction_type: TransactionType;
|
|
559
|
+
amount_cents: number;
|
|
560
|
+
balance_before_cents: number;
|
|
561
|
+
balance_after_cents: number;
|
|
562
|
+
currency: string;
|
|
563
|
+
description?: string;
|
|
564
|
+
reference_code?: string;
|
|
565
|
+
status: string;
|
|
566
|
+
metadata?: Record<string, any>;
|
|
567
|
+
created_at: string;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Cost type
|
|
571
|
+
*/
|
|
572
|
+
export type CostType = 'fixed' | 'per_unit' | 'per_hour' | 'percentage';
|
|
573
|
+
/**
|
|
574
|
+
* Product cost response
|
|
575
|
+
*/
|
|
576
|
+
export interface ProductCost {
|
|
577
|
+
id: string;
|
|
578
|
+
product_id: string;
|
|
579
|
+
cost_type: CostType;
|
|
580
|
+
cost_cents: number;
|
|
581
|
+
currency: string;
|
|
582
|
+
effective_from: string;
|
|
583
|
+
effective_until?: string;
|
|
584
|
+
category?: string;
|
|
585
|
+
notes?: string;
|
|
586
|
+
metadata?: Record<string, any>;
|
|
587
|
+
created_at: string;
|
|
588
|
+
updated_at: string;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Request to create a product cost
|
|
592
|
+
*/
|
|
593
|
+
export interface CreateProductCostRequest {
|
|
594
|
+
product_id: string;
|
|
595
|
+
cost_type: CostType;
|
|
596
|
+
cost_cents: number;
|
|
597
|
+
currency?: string;
|
|
598
|
+
effective_from?: string;
|
|
599
|
+
effective_until?: string;
|
|
600
|
+
category?: string;
|
|
601
|
+
notes?: string;
|
|
602
|
+
metadata?: Record<string, any>;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Request to update a product cost
|
|
606
|
+
*/
|
|
607
|
+
export interface UpdateProductCostRequest {
|
|
608
|
+
cost_cents?: number;
|
|
609
|
+
effective_until?: string;
|
|
610
|
+
category?: string;
|
|
611
|
+
notes?: string;
|
|
612
|
+
metadata?: Record<string, any>;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Order cost response
|
|
616
|
+
*/
|
|
617
|
+
export interface OrderCost {
|
|
618
|
+
id: string;
|
|
619
|
+
order_id: string;
|
|
620
|
+
cost_type: CostType;
|
|
621
|
+
cost_cents: number;
|
|
622
|
+
currency: string;
|
|
623
|
+
category?: string;
|
|
624
|
+
description?: string;
|
|
625
|
+
metadata?: Record<string, any>;
|
|
626
|
+
created_at: string;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Request to create an order cost
|
|
630
|
+
*/
|
|
631
|
+
export interface CreateOrderCostRequest {
|
|
632
|
+
order_id: string;
|
|
633
|
+
cost_type: CostType;
|
|
634
|
+
cost_cents: number;
|
|
635
|
+
currency?: string;
|
|
636
|
+
category?: string;
|
|
637
|
+
description?: string;
|
|
638
|
+
metadata?: Record<string, any>;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Total cost response
|
|
642
|
+
*/
|
|
643
|
+
export interface TotalCostResponse {
|
|
644
|
+
product_id?: string;
|
|
645
|
+
order_id?: string;
|
|
646
|
+
total_cost_cents: number;
|
|
647
|
+
total_cost_dollars: number;
|
|
648
|
+
calculated_at?: string;
|
|
649
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubflow/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Core functionality for Pubflow framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"url": "https://github.com/pubflow/core/issues"
|
|
44
44
|
},
|
|
45
45
|
"homepage": "https://github.com/pubflow/core#readme"
|
|
46
|
-
}
|
|
46
|
+
}
|