@pubflow/core 0.4.0 → 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.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Client for interacting with Bridge Payments API
5
5
  */
6
- import { BridgePaymentConfig, PaymentRequestOptions, CreatePaymentIntentRequest, PaymentIntent, Payment, PaymentMethod, UpdatePaymentMethodRequest, Address, CreateAddressRequest, UpdateAddressRequest, Customer, CreateCustomerRequest, UpdateCustomerRequest, Subscription, CreateSubscriptionRequest, CancelSubscriptionRequest, Organization, CreateOrganizationRequest, UpdateOrganizationRequest, OrganizationMember, AddOrganizationMemberRequest, UpdateOrganizationMemberRoleRequest, ConvertGuestToUserRequest, ConvertGuestToUserResponse, PaginationParams } from './types';
6
+ import { BridgePaymentConfig, PaymentRequestOptions, CreatePaymentIntentRequest, PaymentIntent, Payment, PaymentMethod, UpdatePaymentMethodRequest, Address, CreateAddressRequest, UpdateAddressRequest, Customer, CreateCustomerRequest, UpdateCustomerRequest, Subscription, CreateSubscriptionRequest, CancelSubscriptionRequest, Organization, CreateOrganizationRequest, UpdateOrganizationRequest, OrganizationMember, AddOrganizationMemberRequest, UpdateOrganizationMemberRoleRequest, ConvertGuestToUserRequest, ConvertGuestToUserResponse, PaginationParams, BillingSchedule, CreateBillingScheduleRequest, UpdateBillingScheduleRequest, BillingExecution, AccountBalance, CreateAccountBalanceRequest, UpdateAccountBalanceRequest, CreditBalanceRequest, DebitBalanceRequest, AccountTransaction, ProductCost, CreateProductCostRequest, UpdateProductCostRequest, OrderCost, CreateOrderCostRequest, TotalCostResponse } from './types';
7
7
  /**
8
8
  * Bridge Payment Client
9
9
  *
@@ -298,4 +298,226 @@ export declare class BridgePaymentClient {
298
298
  * @returns Conversion result
299
299
  */
300
300
  convertGuestToUser(data: ConvertGuestToUserRequest, options?: PaymentRequestOptions): Promise<ConvertGuestToUserResponse>;
301
+ /**
302
+ * List my billing schedules
303
+ *
304
+ * @param params Pagination parameters
305
+ * @param options Request options
306
+ * @returns List of billing schedules
307
+ */
308
+ listMySchedules(params?: PaginationParams, options?: PaymentRequestOptions): Promise<BillingSchedule[]>;
309
+ /**
310
+ * Get a billing schedule by ID
311
+ *
312
+ * @param id Schedule ID
313
+ * @param options Request options
314
+ * @returns Billing schedule
315
+ */
316
+ getSchedule(id: string, options?: PaymentRequestOptions): Promise<BillingSchedule>;
317
+ /**
318
+ * Create a billing schedule
319
+ *
320
+ * @param data Schedule data
321
+ * @param options Request options
322
+ * @returns Created billing schedule
323
+ */
324
+ createSchedule(data: CreateBillingScheduleRequest, options?: PaymentRequestOptions): Promise<BillingSchedule>;
325
+ /**
326
+ * Update a billing schedule
327
+ *
328
+ * @param id Schedule ID
329
+ * @param data Update data
330
+ * @param options Request options
331
+ * @returns Updated billing schedule
332
+ */
333
+ updateSchedule(id: string, data: UpdateBillingScheduleRequest, options?: PaymentRequestOptions): Promise<BillingSchedule>;
334
+ /**
335
+ * Pause a billing schedule
336
+ *
337
+ * @param id Schedule ID
338
+ * @param options Request options
339
+ * @returns Updated billing schedule
340
+ */
341
+ pauseSchedule(id: string, options?: PaymentRequestOptions): Promise<BillingSchedule>;
342
+ /**
343
+ * Resume a billing schedule
344
+ *
345
+ * @param id Schedule ID
346
+ * @param options Request options
347
+ * @returns Updated billing schedule
348
+ */
349
+ resumeSchedule(id: string, options?: PaymentRequestOptions): Promise<BillingSchedule>;
350
+ /**
351
+ * Delete a billing schedule
352
+ *
353
+ * @param id Schedule ID
354
+ * @param options Request options
355
+ */
356
+ deleteSchedule(id: string, options?: PaymentRequestOptions): Promise<void>;
357
+ /**
358
+ * Get execution history for a billing schedule
359
+ *
360
+ * @param id Schedule ID
361
+ * @param params Pagination parameters
362
+ * @param options Request options
363
+ * @returns List of billing executions
364
+ */
365
+ getScheduleExecutions(id: string, params?: PaginationParams, options?: PaymentRequestOptions): Promise<BillingExecution[]>;
366
+ /**
367
+ * List my account balances
368
+ *
369
+ * @param params Pagination parameters
370
+ * @param options Request options
371
+ * @returns List of account balances
372
+ */
373
+ listMyBalances(params?: PaginationParams, options?: PaymentRequestOptions): Promise<AccountBalance[]>;
374
+ /**
375
+ * Get an account balance by ID
376
+ *
377
+ * @param id Balance ID
378
+ * @param options Request options
379
+ * @returns Account balance
380
+ */
381
+ getBalance(id: string, options?: PaymentRequestOptions): Promise<AccountBalance>;
382
+ /**
383
+ * Create an account balance
384
+ *
385
+ * @param data Balance data
386
+ * @param options Request options
387
+ * @returns Created account balance
388
+ */
389
+ createBalance(data: CreateAccountBalanceRequest, options?: PaymentRequestOptions): Promise<AccountBalance>;
390
+ /**
391
+ * Credit an account balance
392
+ *
393
+ * @param id Balance ID
394
+ * @param data Credit data
395
+ * @param options Request options
396
+ * @returns Updated balance and transaction
397
+ */
398
+ creditBalance(id: string, data: CreditBalanceRequest, options?: PaymentRequestOptions): Promise<{
399
+ balance: AccountBalance;
400
+ transaction: AccountTransaction;
401
+ }>;
402
+ /**
403
+ * Debit an account balance
404
+ *
405
+ * @param id Balance ID
406
+ * @param data Debit data
407
+ * @param options Request options
408
+ * @returns Updated balance and transaction
409
+ */
410
+ debitBalance(id: string, data: DebitBalanceRequest, options?: PaymentRequestOptions): Promise<{
411
+ balance: AccountBalance;
412
+ transaction: AccountTransaction;
413
+ }>;
414
+ /**
415
+ * Update an account balance
416
+ *
417
+ * @param id Balance ID
418
+ * @param data Update data
419
+ * @param options Request options
420
+ * @returns Updated account balance
421
+ */
422
+ updateBalance(id: string, data: UpdateAccountBalanceRequest, options?: PaymentRequestOptions): Promise<AccountBalance>;
423
+ /**
424
+ * Delete an account balance
425
+ *
426
+ * @param id Balance ID
427
+ * @param options Request options
428
+ */
429
+ deleteBalance(id: string, options?: PaymentRequestOptions): Promise<void>;
430
+ /**
431
+ * List my account transactions
432
+ *
433
+ * @param params Pagination parameters
434
+ * @param options Request options
435
+ * @returns List of account transactions
436
+ */
437
+ listMyTransactions(params?: PaginationParams, options?: PaymentRequestOptions): Promise<AccountTransaction[]>;
438
+ /**
439
+ * Get transactions for a specific balance
440
+ *
441
+ * @param id Balance ID
442
+ * @param params Pagination parameters
443
+ * @param options Request options
444
+ * @returns List of account transactions
445
+ */
446
+ getBalanceTransactions(id: string, params?: PaginationParams, options?: PaymentRequestOptions): Promise<AccountTransaction[]>;
447
+ /**
448
+ * Get all costs for a product
449
+ *
450
+ * @param productId Product ID
451
+ * @param params Pagination parameters
452
+ * @param options Request options
453
+ * @returns List of product costs
454
+ */
455
+ getProductCosts(productId: string, params?: PaginationParams, options?: PaymentRequestOptions): Promise<ProductCost[]>;
456
+ /**
457
+ * Get active cost for a product
458
+ *
459
+ * @param productId Product ID
460
+ * @param date Date to check (ISO 8601)
461
+ * @param options Request options
462
+ * @returns Active product cost
463
+ */
464
+ getActiveProductCost(productId: string, date?: string, options?: PaymentRequestOptions): Promise<ProductCost>;
465
+ /**
466
+ * Get total cost for a product
467
+ *
468
+ * @param productId Product ID
469
+ * @param date Date to check (ISO 8601)
470
+ * @param options Request options
471
+ * @returns Total cost response
472
+ */
473
+ getTotalProductCost(productId: string, date?: string, options?: PaymentRequestOptions): Promise<TotalCostResponse>;
474
+ /**
475
+ * Create a product cost
476
+ *
477
+ * @param data Product cost data
478
+ * @param options Request options
479
+ * @returns Created product cost
480
+ */
481
+ createProductCost(data: CreateProductCostRequest, options?: PaymentRequestOptions): Promise<ProductCost>;
482
+ /**
483
+ * Update a product cost
484
+ *
485
+ * @param id Cost ID
486
+ * @param data Update data
487
+ * @param options Request options
488
+ * @returns Updated product cost
489
+ */
490
+ updateProductCost(id: string, data: UpdateProductCostRequest, options?: PaymentRequestOptions): Promise<ProductCost>;
491
+ /**
492
+ * Delete a product cost
493
+ *
494
+ * @param id Cost ID
495
+ * @param options Request options
496
+ */
497
+ deleteProductCost(id: string, options?: PaymentRequestOptions): Promise<void>;
498
+ /**
499
+ * Get all costs for an order
500
+ *
501
+ * @param orderId Order ID
502
+ * @param params Pagination parameters
503
+ * @param options Request options
504
+ * @returns List of order costs
505
+ */
506
+ getOrderCosts(orderId: string, params?: PaginationParams, options?: PaymentRequestOptions): Promise<OrderCost[]>;
507
+ /**
508
+ * Get total cost for an order
509
+ *
510
+ * @param orderId Order ID
511
+ * @param options Request options
512
+ * @returns Total cost response
513
+ */
514
+ getTotalOrderCost(orderId: string, options?: PaymentRequestOptions): Promise<TotalCostResponse>;
515
+ /**
516
+ * Create an order cost
517
+ *
518
+ * @param data Order cost data
519
+ * @param options Request options
520
+ * @returns Created order cost
521
+ */
522
+ createOrderCost(data: CreateOrderCostRequest, options?: PaymentRequestOptions): Promise<OrderCost>;
301
523
  }
@@ -473,5 +473,332 @@ class BridgePaymentClient {
473
473
  async convertGuestToUser(data, options) {
474
474
  return this.request('/guest/convert', 'POST', data, options);
475
475
  }
476
+ // ============================================================================
477
+ // BILLING SCHEDULES
478
+ // ============================================================================
479
+ /**
480
+ * List my billing schedules
481
+ *
482
+ * @param params Pagination parameters
483
+ * @param options Request options
484
+ * @returns List of billing schedules
485
+ */
486
+ async listMySchedules(params, options) {
487
+ const queryParams = new URLSearchParams();
488
+ if (params === null || params === void 0 ? void 0 : params.page)
489
+ queryParams.set('page', params.page.toString());
490
+ if (params === null || params === void 0 ? void 0 : params.limit)
491
+ queryParams.set('limit', params.limit.toString());
492
+ const endpoint = `/billing-schedules/me${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
493
+ return this.request(endpoint, 'GET', undefined, options);
494
+ }
495
+ /**
496
+ * Get a billing schedule by ID
497
+ *
498
+ * @param id Schedule ID
499
+ * @param options Request options
500
+ * @returns Billing schedule
501
+ */
502
+ async getSchedule(id, options) {
503
+ return this.request(`/billing-schedules/${id}`, 'GET', undefined, options);
504
+ }
505
+ /**
506
+ * Create a billing schedule
507
+ *
508
+ * @param data Schedule data
509
+ * @param options Request options
510
+ * @returns Created billing schedule
511
+ */
512
+ async createSchedule(data, options) {
513
+ return this.request('/billing-schedules', 'POST', data, options);
514
+ }
515
+ /**
516
+ * Update a billing schedule
517
+ *
518
+ * @param id Schedule ID
519
+ * @param data Update data
520
+ * @param options Request options
521
+ * @returns Updated billing schedule
522
+ */
523
+ async updateSchedule(id, data, options) {
524
+ return this.request(`/billing-schedules/${id}`, 'PUT', data, options);
525
+ }
526
+ /**
527
+ * Pause a billing schedule
528
+ *
529
+ * @param id Schedule ID
530
+ * @param options Request options
531
+ * @returns Updated billing schedule
532
+ */
533
+ async pauseSchedule(id, options) {
534
+ return this.request(`/billing-schedules/${id}/pause`, 'POST', undefined, options);
535
+ }
536
+ /**
537
+ * Resume a billing schedule
538
+ *
539
+ * @param id Schedule ID
540
+ * @param options Request options
541
+ * @returns Updated billing schedule
542
+ */
543
+ async resumeSchedule(id, options) {
544
+ return this.request(`/billing-schedules/${id}/resume`, 'POST', undefined, options);
545
+ }
546
+ /**
547
+ * Delete a billing schedule
548
+ *
549
+ * @param id Schedule ID
550
+ * @param options Request options
551
+ */
552
+ async deleteSchedule(id, options) {
553
+ await this.request(`/billing-schedules/${id}`, 'DELETE', undefined, options);
554
+ }
555
+ /**
556
+ * Get execution history for a billing schedule
557
+ *
558
+ * @param id Schedule ID
559
+ * @param params Pagination parameters
560
+ * @param options Request options
561
+ * @returns List of billing executions
562
+ */
563
+ async getScheduleExecutions(id, params, options) {
564
+ const queryParams = new URLSearchParams();
565
+ if (params === null || params === void 0 ? void 0 : params.page)
566
+ queryParams.set('page', params.page.toString());
567
+ if (params === null || params === void 0 ? void 0 : params.limit)
568
+ queryParams.set('limit', params.limit.toString());
569
+ const endpoint = `/billing-schedules/${id}/executions${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
570
+ return this.request(endpoint, 'GET', undefined, options);
571
+ }
572
+ // ============================================================================
573
+ // ACCOUNT BALANCE
574
+ // ============================================================================
575
+ /**
576
+ * List my account balances
577
+ *
578
+ * @param params Pagination parameters
579
+ * @param options Request options
580
+ * @returns List of account balances
581
+ */
582
+ async listMyBalances(params, options) {
583
+ const queryParams = new URLSearchParams();
584
+ if (params === null || params === void 0 ? void 0 : params.page)
585
+ queryParams.set('page', params.page.toString());
586
+ if (params === null || params === void 0 ? void 0 : params.limit)
587
+ queryParams.set('limit', params.limit.toString());
588
+ const endpoint = `/account-balance/me/balances${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
589
+ return this.request(endpoint, 'GET', undefined, options);
590
+ }
591
+ /**
592
+ * Get an account balance by ID
593
+ *
594
+ * @param id Balance ID
595
+ * @param options Request options
596
+ * @returns Account balance
597
+ */
598
+ async getBalance(id, options) {
599
+ return this.request(`/account-balance/${id}`, 'GET', undefined, options);
600
+ }
601
+ /**
602
+ * Create an account balance
603
+ *
604
+ * @param data Balance data
605
+ * @param options Request options
606
+ * @returns Created account balance
607
+ */
608
+ async createBalance(data, options) {
609
+ return this.request('/account-balance', 'POST', data, options);
610
+ }
611
+ /**
612
+ * Credit an account balance
613
+ *
614
+ * @param id Balance ID
615
+ * @param data Credit data
616
+ * @param options Request options
617
+ * @returns Updated balance and transaction
618
+ */
619
+ async creditBalance(id, data, options) {
620
+ return this.request(`/account-balance/${id}/credit`, 'POST', data, options);
621
+ }
622
+ /**
623
+ * Debit an account balance
624
+ *
625
+ * @param id Balance ID
626
+ * @param data Debit data
627
+ * @param options Request options
628
+ * @returns Updated balance and transaction
629
+ */
630
+ async debitBalance(id, data, options) {
631
+ return this.request(`/account-balance/${id}/debit`, 'POST', data, options);
632
+ }
633
+ /**
634
+ * Update an account balance
635
+ *
636
+ * @param id Balance ID
637
+ * @param data Update data
638
+ * @param options Request options
639
+ * @returns Updated account balance
640
+ */
641
+ async updateBalance(id, data, options) {
642
+ return this.request(`/account-balance/${id}`, 'PUT', data, options);
643
+ }
644
+ /**
645
+ * Delete an account balance
646
+ *
647
+ * @param id Balance ID
648
+ * @param options Request options
649
+ */
650
+ async deleteBalance(id, options) {
651
+ await this.request(`/account-balance/${id}`, 'DELETE', undefined, options);
652
+ }
653
+ /**
654
+ * List my account transactions
655
+ *
656
+ * @param params Pagination parameters
657
+ * @param options Request options
658
+ * @returns List of account transactions
659
+ */
660
+ async listMyTransactions(params, options) {
661
+ const queryParams = new URLSearchParams();
662
+ if (params === null || params === void 0 ? void 0 : params.page)
663
+ queryParams.set('page', params.page.toString());
664
+ if (params === null || params === void 0 ? void 0 : params.limit)
665
+ queryParams.set('limit', params.limit.toString());
666
+ const endpoint = `/account-balance/me/transactions${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
667
+ return this.request(endpoint, 'GET', undefined, options);
668
+ }
669
+ /**
670
+ * Get transactions for a specific balance
671
+ *
672
+ * @param id Balance ID
673
+ * @param params Pagination parameters
674
+ * @param options Request options
675
+ * @returns List of account transactions
676
+ */
677
+ async getBalanceTransactions(id, params, options) {
678
+ const queryParams = new URLSearchParams();
679
+ if (params === null || params === void 0 ? void 0 : params.page)
680
+ queryParams.set('page', params.page.toString());
681
+ if (params === null || params === void 0 ? void 0 : params.limit)
682
+ queryParams.set('limit', params.limit.toString());
683
+ const endpoint = `/account-balance/${id}/transactions${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
684
+ return this.request(endpoint, 'GET', undefined, options);
685
+ }
686
+ // ============================================================================
687
+ // COST TRACKING
688
+ // ============================================================================
689
+ /**
690
+ * Get all costs for a product
691
+ *
692
+ * @param productId Product ID
693
+ * @param params Pagination parameters
694
+ * @param options Request options
695
+ * @returns List of product costs
696
+ */
697
+ async getProductCosts(productId, params, options) {
698
+ const queryParams = new URLSearchParams();
699
+ if (params === null || params === void 0 ? void 0 : params.page)
700
+ queryParams.set('page', params.page.toString());
701
+ if (params === null || params === void 0 ? void 0 : params.limit)
702
+ queryParams.set('limit', params.limit.toString());
703
+ const endpoint = `/cost-tracking/products/${productId}/costs${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
704
+ return this.request(endpoint, 'GET', undefined, options);
705
+ }
706
+ /**
707
+ * Get active cost for a product
708
+ *
709
+ * @param productId Product ID
710
+ * @param date Date to check (ISO 8601)
711
+ * @param options Request options
712
+ * @returns Active product cost
713
+ */
714
+ async getActiveProductCost(productId, date, options) {
715
+ const queryParams = new URLSearchParams();
716
+ if (date)
717
+ queryParams.set('date', date);
718
+ const endpoint = `/cost-tracking/products/${productId}/costs/active${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
719
+ return this.request(endpoint, 'GET', undefined, options);
720
+ }
721
+ /**
722
+ * Get total cost for a product
723
+ *
724
+ * @param productId Product ID
725
+ * @param date Date to check (ISO 8601)
726
+ * @param options Request options
727
+ * @returns Total cost response
728
+ */
729
+ async getTotalProductCost(productId, date, options) {
730
+ const queryParams = new URLSearchParams();
731
+ if (date)
732
+ queryParams.set('date', date);
733
+ const endpoint = `/cost-tracking/products/${productId}/costs/total${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
734
+ return this.request(endpoint, 'GET', undefined, options);
735
+ }
736
+ /**
737
+ * Create a product cost
738
+ *
739
+ * @param data Product cost data
740
+ * @param options Request options
741
+ * @returns Created product cost
742
+ */
743
+ async createProductCost(data, options) {
744
+ return this.request('/cost-tracking/products/costs', 'POST', data, options);
745
+ }
746
+ /**
747
+ * Update a product cost
748
+ *
749
+ * @param id Cost ID
750
+ * @param data Update data
751
+ * @param options Request options
752
+ * @returns Updated product cost
753
+ */
754
+ async updateProductCost(id, data, options) {
755
+ return this.request(`/cost-tracking/products/costs/${id}`, 'PUT', data, options);
756
+ }
757
+ /**
758
+ * Delete a product cost
759
+ *
760
+ * @param id Cost ID
761
+ * @param options Request options
762
+ */
763
+ async deleteProductCost(id, options) {
764
+ await this.request(`/cost-tracking/products/costs/${id}`, 'DELETE', undefined, options);
765
+ }
766
+ /**
767
+ * Get all costs for an order
768
+ *
769
+ * @param orderId Order ID
770
+ * @param params Pagination parameters
771
+ * @param options Request options
772
+ * @returns List of order costs
773
+ */
774
+ async getOrderCosts(orderId, params, options) {
775
+ const queryParams = new URLSearchParams();
776
+ if (params === null || params === void 0 ? void 0 : params.page)
777
+ queryParams.set('page', params.page.toString());
778
+ if (params === null || params === void 0 ? void 0 : params.limit)
779
+ queryParams.set('limit', params.limit.toString());
780
+ const endpoint = `/cost-tracking/orders/${orderId}/costs${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
781
+ return this.request(endpoint, 'GET', undefined, options);
782
+ }
783
+ /**
784
+ * Get total cost for an order
785
+ *
786
+ * @param orderId Order ID
787
+ * @param options Request options
788
+ * @returns Total cost response
789
+ */
790
+ async getTotalOrderCost(orderId, options) {
791
+ return this.request(`/cost-tracking/orders/${orderId}/costs/total`, 'GET', undefined, options);
792
+ }
793
+ /**
794
+ * Create an order cost
795
+ *
796
+ * @param data Order cost data
797
+ * @param options Request options
798
+ * @returns Created order cost
799
+ */
800
+ async createOrderCost(data, options) {
801
+ return this.request('/cost-tracking/orders/costs', 'POST', data, options);
802
+ }
476
803
  }
477
804
  exports.BridgePaymentClient = BridgePaymentClient;
@@ -4,4 +4,4 @@
4
4
  * Exports for Bridge Payments client and types
5
5
  */
6
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 } from './types';
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';
@@ -382,3 +382,268 @@ export interface ListResponse<T> {
382
382
  hasMore: boolean;
383
383
  };
384
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.4.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
+ }