@fabriktor/client 0.0.26 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/src/billable/billable.d.ts +213 -0
  2. package/dist/src/billable/billable.js +441 -0
  3. package/dist/src/calls/calls.d.ts +34 -0
  4. package/dist/src/calls/calls.js +65 -0
  5. package/dist/src/chat/chat.d.ts +97 -0
  6. package/dist/src/chat/chat.js +234 -0
  7. package/dist/src/contacts/contacts.d.ts +37 -0
  8. package/dist/src/contacts/contacts.js +94 -0
  9. package/dist/src/core/crud.d.ts +1 -1
  10. package/dist/src/core/crud.js +1 -1
  11. package/dist/src/core/http.d.ts +3 -0
  12. package/dist/src/core/http.js +3 -3
  13. package/dist/src/core/idempotency.js +1 -1
  14. package/dist/src/core/multipart.d.ts +25 -0
  15. package/dist/src/core/multipart.js +93 -0
  16. package/dist/src/feed/feed.d.ts +65 -0
  17. package/dist/src/feed/feed.js +130 -0
  18. package/dist/src/fulfillments/fulfillments.d.ts +36 -0
  19. package/dist/src/fulfillments/fulfillments.js +68 -0
  20. package/dist/src/index.d.ts +16 -0
  21. package/dist/src/index.js +16 -0
  22. package/dist/src/jobs/jobs.d.ts +69 -0
  23. package/dist/src/jobs/jobs.js +143 -0
  24. package/dist/src/marketplace/marketplace.d.ts +49 -0
  25. package/dist/src/marketplace/marketplace.js +94 -0
  26. package/dist/src/payments/payments.d.ts +154 -0
  27. package/dist/src/payments/payments.js +328 -0
  28. package/dist/src/payrolls/payrolls.d.ts +179 -0
  29. package/dist/src/payrolls/payrolls.js +380 -0
  30. package/dist/src/privacy/privacy.d.ts +47 -0
  31. package/dist/src/privacy/privacy.js +90 -0
  32. package/dist/src/processes/processes.d.ts +21 -0
  33. package/dist/src/processes/processes.js +38 -0
  34. package/dist/src/routes/routes.d.ts +93 -0
  35. package/dist/src/routes/routes.js +185 -0
  36. package/dist/src/storage/storage.d.ts +124 -0
  37. package/dist/src/storage/storage.js +249 -0
  38. package/dist/src/timesheets/timesheets.d.ts +49 -0
  39. package/dist/src/timesheets/timesheets.js +105 -0
  40. package/dist/src/users/tmp_phones.d.ts +1 -1
  41. package/dist/src/users/tmp_usernames.d.ts +1 -1
  42. package/dist/src/users/users.d.ts +1 -1
  43. package/package.json +3 -2
@@ -0,0 +1,49 @@
1
+ import { type InMarketplaceFavorite, type InMarketplacePost, type MarketplaceFavorite, type MarketplacePost, type OperationResult, type PLMarketplacePull, type RPMarketplacePull } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type PullMarketplaceOptions = PLMarketplacePull;
6
+ export type MarketplaceClientOptions = {
7
+ http: HTTPDoer;
8
+ base_url: string;
9
+ get_token?: TokenProvider;
10
+ };
11
+ export interface MarketplaceOperator {
12
+ queryMarketplacePosts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MarketplacePost[]>>;
13
+ insertOneMarketplacePost(opts: InsertOneOptionsCRUD<InMarketplacePost>): Promise<OperationResult>;
14
+ findOneMarketplacePost(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MarketplacePost>>;
15
+ replaceOneMarketplacePost(opts: ReplaceOneOptionsCRUD<InMarketplacePost>): Promise<OperationResult>;
16
+ deleteOneMarketplacePost(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
17
+ deleteManyMarketplacePosts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
18
+ searchManyMarketplacePosts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<MarketplacePost>>>;
19
+ queryMarketplaceFavorites(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MarketplaceFavorite[]>>;
20
+ insertOneMarketplaceFavorite(opts: InsertOneOptionsCRUD<InMarketplaceFavorite>): Promise<OperationResult>;
21
+ findOneMarketplaceFavorite(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MarketplaceFavorite>>;
22
+ replaceOneMarketplaceFavorite(opts: ReplaceOneOptionsCRUD<InMarketplaceFavorite>): Promise<OperationResult>;
23
+ deleteOneMarketplaceFavorite(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
24
+ deleteManyMarketplaceFavorites(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
25
+ pull(opts: PullMarketplaceOptions): Promise<OperationResultOf<RPMarketplacePull>>;
26
+ }
27
+ export declare class MarketplaceClient implements MarketplaceOperator {
28
+ private marketplace_posts;
29
+ private marketplace_favorites;
30
+ private http;
31
+ private base_url;
32
+ private get_token?;
33
+ constructor(opts: MarketplaceClientOptions);
34
+ queryMarketplacePosts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MarketplacePost[]>>;
35
+ insertOneMarketplacePost(opts: InsertOneOptionsCRUD<InMarketplacePost>): Promise<OperationResult>;
36
+ findOneMarketplacePost(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MarketplacePost>>;
37
+ replaceOneMarketplacePost(opts: ReplaceOneOptionsCRUD<InMarketplacePost>): Promise<OperationResult>;
38
+ deleteOneMarketplacePost(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
39
+ deleteManyMarketplacePosts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
40
+ searchManyMarketplacePosts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<MarketplacePost>>>;
41
+ queryMarketplaceFavorites(opts?: QueryOptionsCRUD): Promise<OperationResultOf<MarketplaceFavorite[]>>;
42
+ insertOneMarketplaceFavorite(opts: InsertOneOptionsCRUD<InMarketplaceFavorite>): Promise<OperationResult>;
43
+ findOneMarketplaceFavorite(opts: FindOneOptionsCRUD): Promise<OperationResultOf<MarketplaceFavorite>>;
44
+ replaceOneMarketplaceFavorite(opts: ReplaceOneOptionsCRUD<InMarketplaceFavorite>): Promise<OperationResult>;
45
+ deleteOneMarketplaceFavorite(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
46
+ deleteManyMarketplaceFavorites(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
47
+ pull(opts: PullMarketplaceOptions): Promise<OperationResultOf<RPMarketplacePull>>;
48
+ }
49
+ export declare function newMarketplaceClient(opts: MarketplaceClientOptions): MarketplaceClient;
@@ -0,0 +1,94 @@
1
+ // Copyright (C) Fabriktor, Inc. 2025-present.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+ // not use this file except in compliance with the License. You may obtain
5
+ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ import { ColMarketplaceMarketplaceFavorites, ColMarketplaceMarketplacePosts, HTTPMethodPost, PathPull, SvcMarketplace, } from "@fabriktor/schema";
7
+ import { requiredToken } from "../core/auth.js";
8
+ import { newCRUDClient } from "../core/crud.js";
9
+ import { buildPath } from "../core/path.js";
10
+ export class MarketplaceClient {
11
+ marketplace_posts;
12
+ marketplace_favorites;
13
+ http;
14
+ base_url;
15
+ get_token;
16
+ constructor(opts) {
17
+ this.marketplace_posts = newCRUDClient({
18
+ http: opts.http,
19
+ base_url: opts.base_url,
20
+ svc: SvcMarketplace,
21
+ col: ColMarketplaceMarketplacePosts,
22
+ get_token: opts.get_token,
23
+ });
24
+ this.marketplace_favorites = newCRUDClient({
25
+ http: opts.http,
26
+ base_url: opts.base_url,
27
+ svc: SvcMarketplace,
28
+ col: ColMarketplaceMarketplaceFavorites,
29
+ get_token: opts.get_token,
30
+ });
31
+ this.http = opts.http;
32
+ this.base_url = opts.base_url;
33
+ this.get_token = opts.get_token;
34
+ }
35
+ async queryMarketplacePosts(opts) {
36
+ return await this.marketplace_posts.query(opts);
37
+ }
38
+ async insertOneMarketplacePost(opts) {
39
+ return await this.marketplace_posts.insertOne(opts);
40
+ }
41
+ async findOneMarketplacePost(opts) {
42
+ return await this.marketplace_posts.findOne(opts);
43
+ }
44
+ async replaceOneMarketplacePost(opts) {
45
+ return await this.marketplace_posts.replaceOne(opts);
46
+ }
47
+ async deleteOneMarketplacePost(opts) {
48
+ return await this.marketplace_posts.deleteOne(opts);
49
+ }
50
+ async deleteManyMarketplacePosts(opts) {
51
+ return await this.marketplace_posts.deleteMany(opts);
52
+ }
53
+ async searchManyMarketplacePosts(opts) {
54
+ return await this.marketplace_posts.searchMany(opts);
55
+ }
56
+ async queryMarketplaceFavorites(opts) {
57
+ return await this.marketplace_favorites.query(opts);
58
+ }
59
+ async insertOneMarketplaceFavorite(opts) {
60
+ return await this.marketplace_favorites.insertOne(opts);
61
+ }
62
+ async findOneMarketplaceFavorite(opts) {
63
+ return await this.marketplace_favorites.findOne(opts);
64
+ }
65
+ async replaceOneMarketplaceFavorite(opts) {
66
+ return await this.marketplace_favorites.replaceOne(opts);
67
+ }
68
+ async deleteOneMarketplaceFavorite(opts) {
69
+ return await this.marketplace_favorites.deleteOne(opts);
70
+ }
71
+ async deleteManyMarketplaceFavorites(opts) {
72
+ return await this.marketplace_favorites.deleteMany(opts);
73
+ }
74
+ async pull(opts) {
75
+ const token = await requiredToken(this.get_token);
76
+ return await this.http.do({
77
+ base_url: this.base_url,
78
+ path: marketplacePostPath(PathPull),
79
+ method: HTTPMethodPost,
80
+ token,
81
+ body: opts,
82
+ });
83
+ }
84
+ }
85
+ export function newMarketplaceClient(opts) {
86
+ return new MarketplaceClient(opts);
87
+ }
88
+ function marketplacePostPath(action) {
89
+ return buildPath({
90
+ svc: SvcMarketplace,
91
+ col: ColMarketplaceMarketplacePosts,
92
+ action,
93
+ });
94
+ }
@@ -0,0 +1,154 @@
1
+ import { type CreditLedgerEntry, type InCreditLedgerEntry, type InPayment, type InPmtAccount, type InPmtBankAccount, type InPmtCard, type InPmtCustomer, type InPmtPublicSession, type InPmtRefund, type OperationResult, type Payment, type PLPaymentsBalance, type PLPaymentsOpenPublicSession, type PLPaymentsPaymentFromPublicSession, type PLPaymentsPurchaseCredits, type PLPaymentsTotalCredits, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund, type RPPaymentsTotalCredits, type SortStripeBalanceResult } from "@fabriktor/schema";
2
+ import type { TokenProvider } from "../core/auth.js";
3
+ import type { DeleteManyOptionsCRUD, DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
4
+ import type { HTTPDoer } from "../core/http.js";
5
+ export type BalanceOptions = PLPaymentsBalance;
6
+ export type PaymentsBalance = SortStripeBalanceResult;
7
+ export type OpenPmtPublicSessionOptions = PLPaymentsOpenPublicSession;
8
+ export type PaymentFromPublicSessionOptions = PLPaymentsPaymentFromPublicSession;
9
+ export type PurchaseCreditsOptions = PLPaymentsPurchaseCredits;
10
+ export type TotalCreditsOptions = PLPaymentsTotalCredits;
11
+ export type PaymentsClientOptions = {
12
+ http: HTTPDoer;
13
+ base_url: string;
14
+ get_token?: TokenProvider;
15
+ };
16
+ export interface PaymentsOperator {
17
+ queryPayments(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Payment[]>>;
18
+ insertOnePayment(opts: InsertOneOptionsCRUD<InPayment>): Promise<OperationResult>;
19
+ findOnePayment(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Payment>>;
20
+ replaceOnePayment(opts: ReplaceOneOptionsCRUD<InPayment>): Promise<OperationResult>;
21
+ deleteOnePayment(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
22
+ deleteManyPayments(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
23
+ searchManyPayments(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Payment>>>;
24
+ queryPmtAccounts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtAccount[]>>;
25
+ insertOnePmtAccount(opts: InsertOneOptionsCRUD<InPmtAccount>): Promise<OperationResult>;
26
+ findOnePmtAccount(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtAccount>>;
27
+ replaceOnePmtAccount(opts: ReplaceOneOptionsCRUD<InPmtAccount>): Promise<OperationResult>;
28
+ deleteOnePmtAccount(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
29
+ deleteManyPmtAccounts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
30
+ searchManyPmtAccounts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtAccount>>>;
31
+ queryPmtBankAccounts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtBankAccount[]>>;
32
+ insertOnePmtBankAccount(opts: InsertOneOptionsCRUD<InPmtBankAccount>): Promise<OperationResult>;
33
+ findOnePmtBankAccount(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtBankAccount>>;
34
+ replaceOnePmtBankAccount(opts: ReplaceOneOptionsCRUD<InPmtBankAccount>): Promise<OperationResult>;
35
+ deleteOnePmtBankAccount(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
36
+ deleteManyPmtBankAccounts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
37
+ searchManyPmtBankAccounts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtBankAccount>>>;
38
+ queryPmtCards(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtCard[]>>;
39
+ insertOnePmtCard(opts: InsertOneOptionsCRUD<InPmtCard>): Promise<OperationResult>;
40
+ findOnePmtCard(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtCard>>;
41
+ replaceOnePmtCard(opts: ReplaceOneOptionsCRUD<InPmtCard>): Promise<OperationResult>;
42
+ deleteOnePmtCard(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
43
+ deleteManyPmtCards(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
44
+ searchManyPmtCards(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtCard>>>;
45
+ queryPmtRefunds(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtRefund[]>>;
46
+ insertOnePmtRefund(opts: InsertOneOptionsCRUD<InPmtRefund>): Promise<OperationResult>;
47
+ findOnePmtRefund(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtRefund>>;
48
+ replaceOnePmtRefund(opts: ReplaceOneOptionsCRUD<InPmtRefund>): Promise<OperationResult>;
49
+ deleteOnePmtRefund(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
50
+ deleteManyPmtRefunds(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
51
+ searchManyPmtRefunds(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtRefund>>>;
52
+ queryPmtCustomers(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtCustomer[]>>;
53
+ insertOnePmtCustomer(opts: InsertOneOptionsCRUD<InPmtCustomer>): Promise<OperationResult>;
54
+ findOnePmtCustomer(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtCustomer>>;
55
+ replaceOnePmtCustomer(opts: ReplaceOneOptionsCRUD<InPmtCustomer>): Promise<OperationResult>;
56
+ deleteOnePmtCustomer(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
57
+ deleteManyPmtCustomers(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
58
+ searchManyPmtCustomers(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtCustomer>>>;
59
+ queryPmtPublicSessions(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtPublicSession[]>>;
60
+ insertOnePmtPublicSession(opts: InsertOneOptionsCRUD<InPmtPublicSession>): Promise<OperationResult>;
61
+ findOnePmtPublicSession(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtPublicSession>>;
62
+ replaceOnePmtPublicSession(opts: ReplaceOneOptionsCRUD<InPmtPublicSession>): Promise<OperationResult>;
63
+ deleteOnePmtPublicSession(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
64
+ deleteManyPmtPublicSessions(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
65
+ searchManyPmtPublicSessions(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtPublicSession>>>;
66
+ queryCreditLedger(opts?: QueryOptionsCRUD): Promise<OperationResultOf<CreditLedgerEntry[]>>;
67
+ insertOneCreditLedgerEntry(opts: InsertOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
68
+ findOneCreditLedgerEntry(opts: FindOneOptionsCRUD): Promise<OperationResultOf<CreditLedgerEntry>>;
69
+ replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
70
+ deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
71
+ deleteManyCreditLedger(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
72
+ searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
73
+ balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
74
+ openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
75
+ paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
76
+ purchaseCredits(opts: PurchaseCreditsOptions): Promise<OperationResult>;
77
+ totalCredits(opts: TotalCreditsOptions): Promise<OperationResultOf<RPPaymentsTotalCredits>>;
78
+ }
79
+ export declare class PaymentsClient implements PaymentsOperator {
80
+ private payments;
81
+ private pmt_accounts;
82
+ private pmt_bank_accounts;
83
+ private pmt_cards;
84
+ private pmt_refunds;
85
+ private pmt_customers;
86
+ private pmt_public_sessions;
87
+ private credit_ledger;
88
+ private http;
89
+ private base_url;
90
+ private get_token?;
91
+ constructor(opts: PaymentsClientOptions);
92
+ queryPayments(opts?: QueryOptionsCRUD): Promise<OperationResultOf<Payment[]>>;
93
+ insertOnePayment(opts: InsertOneOptionsCRUD<InPayment>): Promise<OperationResult>;
94
+ findOnePayment(opts: FindOneOptionsCRUD): Promise<OperationResultOf<Payment>>;
95
+ replaceOnePayment(opts: ReplaceOneOptionsCRUD<InPayment>): Promise<OperationResult>;
96
+ deleteOnePayment(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
97
+ deleteManyPayments(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
98
+ searchManyPayments(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<Payment>>>;
99
+ queryPmtAccounts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtAccount[]>>;
100
+ insertOnePmtAccount(opts: InsertOneOptionsCRUD<InPmtAccount>): Promise<OperationResult>;
101
+ findOnePmtAccount(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtAccount>>;
102
+ replaceOnePmtAccount(opts: ReplaceOneOptionsCRUD<InPmtAccount>): Promise<OperationResult>;
103
+ deleteOnePmtAccount(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
104
+ deleteManyPmtAccounts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
105
+ searchManyPmtAccounts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtAccount>>>;
106
+ queryPmtBankAccounts(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtBankAccount[]>>;
107
+ insertOnePmtBankAccount(opts: InsertOneOptionsCRUD<InPmtBankAccount>): Promise<OperationResult>;
108
+ findOnePmtBankAccount(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtBankAccount>>;
109
+ replaceOnePmtBankAccount(opts: ReplaceOneOptionsCRUD<InPmtBankAccount>): Promise<OperationResult>;
110
+ deleteOnePmtBankAccount(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
111
+ deleteManyPmtBankAccounts(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
112
+ searchManyPmtBankAccounts(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtBankAccount>>>;
113
+ queryPmtCards(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtCard[]>>;
114
+ insertOnePmtCard(opts: InsertOneOptionsCRUD<InPmtCard>): Promise<OperationResult>;
115
+ findOnePmtCard(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtCard>>;
116
+ replaceOnePmtCard(opts: ReplaceOneOptionsCRUD<InPmtCard>): Promise<OperationResult>;
117
+ deleteOnePmtCard(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
118
+ deleteManyPmtCards(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
119
+ searchManyPmtCards(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtCard>>>;
120
+ queryPmtRefunds(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtRefund[]>>;
121
+ insertOnePmtRefund(opts: InsertOneOptionsCRUD<InPmtRefund>): Promise<OperationResult>;
122
+ findOnePmtRefund(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtRefund>>;
123
+ replaceOnePmtRefund(opts: ReplaceOneOptionsCRUD<InPmtRefund>): Promise<OperationResult>;
124
+ deleteOnePmtRefund(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
125
+ deleteManyPmtRefunds(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
126
+ searchManyPmtRefunds(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtRefund>>>;
127
+ queryPmtCustomers(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtCustomer[]>>;
128
+ insertOnePmtCustomer(opts: InsertOneOptionsCRUD<InPmtCustomer>): Promise<OperationResult>;
129
+ findOnePmtCustomer(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtCustomer>>;
130
+ replaceOnePmtCustomer(opts: ReplaceOneOptionsCRUD<InPmtCustomer>): Promise<OperationResult>;
131
+ deleteOnePmtCustomer(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
132
+ deleteManyPmtCustomers(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
133
+ searchManyPmtCustomers(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtCustomer>>>;
134
+ queryPmtPublicSessions(opts?: QueryOptionsCRUD): Promise<OperationResultOf<PmtPublicSession[]>>;
135
+ insertOnePmtPublicSession(opts: InsertOneOptionsCRUD<InPmtPublicSession>): Promise<OperationResult>;
136
+ findOnePmtPublicSession(opts: FindOneOptionsCRUD): Promise<OperationResultOf<PmtPublicSession>>;
137
+ replaceOnePmtPublicSession(opts: ReplaceOneOptionsCRUD<InPmtPublicSession>): Promise<OperationResult>;
138
+ deleteOnePmtPublicSession(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
139
+ deleteManyPmtPublicSessions(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
140
+ searchManyPmtPublicSessions(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<PmtPublicSession>>>;
141
+ queryCreditLedger(opts?: QueryOptionsCRUD): Promise<OperationResultOf<CreditLedgerEntry[]>>;
142
+ insertOneCreditLedgerEntry(opts: InsertOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
143
+ findOneCreditLedgerEntry(opts: FindOneOptionsCRUD): Promise<OperationResultOf<CreditLedgerEntry>>;
144
+ replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
145
+ deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
146
+ deleteManyCreditLedger(opts?: DeleteManyOptionsCRUD): Promise<OperationResultOf<number>>;
147
+ searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
148
+ balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
149
+ openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
150
+ paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
151
+ purchaseCredits(opts: PurchaseCreditsOptions): Promise<OperationResult>;
152
+ totalCredits(opts: TotalCreditsOptions): Promise<OperationResultOf<RPPaymentsTotalCredits>>;
153
+ }
154
+ export declare function newPaymentsClient(opts: PaymentsClientOptions): PaymentsClient;
@@ -0,0 +1,328 @@
1
+ // Copyright (C) Fabriktor, Inc. 2025-present.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+ // not use this file except in compliance with the License. You may obtain
5
+ // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ import { ColPaymentsCreditLedger, ColPaymentsPayments, ColPaymentsPmtAccounts, ColPaymentsPmtBankAccounts, ColPaymentsPmtCards, ColPaymentsPmtCustomers, ColPaymentsPmtPublicSessions, ColPaymentsPmtRefunds, HTTPMethodPost, PathPaymentsBalance, PathPaymentsFromPublicSession, PathPaymentsOpen, PathPaymentsPurchase, PathPaymentsTotal, SvcPayments, } from "@fabriktor/schema";
7
+ import { requiredToken } from "../core/auth.js";
8
+ import { newCRUDClient } from "../core/crud.js";
9
+ import { buildPath } from "../core/path.js";
10
+ export class PaymentsClient {
11
+ payments;
12
+ pmt_accounts;
13
+ pmt_bank_accounts;
14
+ pmt_cards;
15
+ pmt_refunds;
16
+ pmt_customers;
17
+ pmt_public_sessions;
18
+ credit_ledger;
19
+ http;
20
+ base_url;
21
+ get_token;
22
+ constructor(opts) {
23
+ this.payments = newCRUDClient({
24
+ http: opts.http,
25
+ base_url: opts.base_url,
26
+ svc: SvcPayments,
27
+ col: ColPaymentsPayments,
28
+ get_token: opts.get_token,
29
+ });
30
+ this.pmt_accounts = newCRUDClient({
31
+ http: opts.http,
32
+ base_url: opts.base_url,
33
+ svc: SvcPayments,
34
+ col: ColPaymentsPmtAccounts,
35
+ get_token: opts.get_token,
36
+ });
37
+ this.pmt_bank_accounts = newCRUDClient({
38
+ http: opts.http,
39
+ base_url: opts.base_url,
40
+ svc: SvcPayments,
41
+ col: ColPaymentsPmtBankAccounts,
42
+ get_token: opts.get_token,
43
+ });
44
+ this.pmt_cards = newCRUDClient({
45
+ http: opts.http,
46
+ base_url: opts.base_url,
47
+ svc: SvcPayments,
48
+ col: ColPaymentsPmtCards,
49
+ get_token: opts.get_token,
50
+ });
51
+ this.pmt_refunds = newCRUDClient({
52
+ http: opts.http,
53
+ base_url: opts.base_url,
54
+ svc: SvcPayments,
55
+ col: ColPaymentsPmtRefunds,
56
+ get_token: opts.get_token,
57
+ });
58
+ this.pmt_customers = newCRUDClient({
59
+ http: opts.http,
60
+ base_url: opts.base_url,
61
+ svc: SvcPayments,
62
+ col: ColPaymentsPmtCustomers,
63
+ get_token: opts.get_token,
64
+ });
65
+ this.pmt_public_sessions = newCRUDClient({
66
+ http: opts.http,
67
+ base_url: opts.base_url,
68
+ svc: SvcPayments,
69
+ col: ColPaymentsPmtPublicSessions,
70
+ get_token: opts.get_token,
71
+ });
72
+ this.credit_ledger = newCRUDClient({
73
+ http: opts.http,
74
+ base_url: opts.base_url,
75
+ svc: SvcPayments,
76
+ col: ColPaymentsCreditLedger,
77
+ get_token: opts.get_token,
78
+ });
79
+ this.http = opts.http;
80
+ this.base_url = opts.base_url;
81
+ this.get_token = opts.get_token;
82
+ }
83
+ async queryPayments(opts) {
84
+ return await this.payments.query(opts);
85
+ }
86
+ async insertOnePayment(opts) {
87
+ return await this.payments.insertOne(opts);
88
+ }
89
+ async findOnePayment(opts) {
90
+ return await this.payments.findOne(opts);
91
+ }
92
+ async replaceOnePayment(opts) {
93
+ return await this.payments.replaceOne(opts);
94
+ }
95
+ async deleteOnePayment(opts) {
96
+ return await this.payments.deleteOne(opts);
97
+ }
98
+ async deleteManyPayments(opts) {
99
+ return await this.payments.deleteMany(opts);
100
+ }
101
+ async searchManyPayments(opts) {
102
+ return await this.payments.searchMany(opts);
103
+ }
104
+ async queryPmtAccounts(opts) {
105
+ return await this.pmt_accounts.query(opts);
106
+ }
107
+ async insertOnePmtAccount(opts) {
108
+ return await this.pmt_accounts.insertOne(opts);
109
+ }
110
+ async findOnePmtAccount(opts) {
111
+ return await this.pmt_accounts.findOne(opts);
112
+ }
113
+ async replaceOnePmtAccount(opts) {
114
+ return await this.pmt_accounts.replaceOne(opts);
115
+ }
116
+ async deleteOnePmtAccount(opts) {
117
+ return await this.pmt_accounts.deleteOne(opts);
118
+ }
119
+ async deleteManyPmtAccounts(opts) {
120
+ return await this.pmt_accounts.deleteMany(opts);
121
+ }
122
+ async searchManyPmtAccounts(opts) {
123
+ return await this.pmt_accounts.searchMany(opts);
124
+ }
125
+ async queryPmtBankAccounts(opts) {
126
+ return await this.pmt_bank_accounts.query(opts);
127
+ }
128
+ async insertOnePmtBankAccount(opts) {
129
+ return await this.pmt_bank_accounts.insertOne(opts);
130
+ }
131
+ async findOnePmtBankAccount(opts) {
132
+ return await this.pmt_bank_accounts.findOne(opts);
133
+ }
134
+ async replaceOnePmtBankAccount(opts) {
135
+ return await this.pmt_bank_accounts.replaceOne(opts);
136
+ }
137
+ async deleteOnePmtBankAccount(opts) {
138
+ return await this.pmt_bank_accounts.deleteOne(opts);
139
+ }
140
+ async deleteManyPmtBankAccounts(opts) {
141
+ return await this.pmt_bank_accounts.deleteMany(opts);
142
+ }
143
+ async searchManyPmtBankAccounts(opts) {
144
+ return await this.pmt_bank_accounts.searchMany(opts);
145
+ }
146
+ async queryPmtCards(opts) {
147
+ return await this.pmt_cards.query(opts);
148
+ }
149
+ async insertOnePmtCard(opts) {
150
+ return await this.pmt_cards.insertOne(opts);
151
+ }
152
+ async findOnePmtCard(opts) {
153
+ return await this.pmt_cards.findOne(opts);
154
+ }
155
+ async replaceOnePmtCard(opts) {
156
+ return await this.pmt_cards.replaceOne(opts);
157
+ }
158
+ async deleteOnePmtCard(opts) {
159
+ return await this.pmt_cards.deleteOne(opts);
160
+ }
161
+ async deleteManyPmtCards(opts) {
162
+ return await this.pmt_cards.deleteMany(opts);
163
+ }
164
+ async searchManyPmtCards(opts) {
165
+ return await this.pmt_cards.searchMany(opts);
166
+ }
167
+ async queryPmtRefunds(opts) {
168
+ return await this.pmt_refunds.query(opts);
169
+ }
170
+ async insertOnePmtRefund(opts) {
171
+ return await this.pmt_refunds.insertOne(opts);
172
+ }
173
+ async findOnePmtRefund(opts) {
174
+ return await this.pmt_refunds.findOne(opts);
175
+ }
176
+ async replaceOnePmtRefund(opts) {
177
+ return await this.pmt_refunds.replaceOne(opts);
178
+ }
179
+ async deleteOnePmtRefund(opts) {
180
+ return await this.pmt_refunds.deleteOne(opts);
181
+ }
182
+ async deleteManyPmtRefunds(opts) {
183
+ return await this.pmt_refunds.deleteMany(opts);
184
+ }
185
+ async searchManyPmtRefunds(opts) {
186
+ return await this.pmt_refunds.searchMany(opts);
187
+ }
188
+ async queryPmtCustomers(opts) {
189
+ return await this.pmt_customers.query(opts);
190
+ }
191
+ async insertOnePmtCustomer(opts) {
192
+ return await this.pmt_customers.insertOne(opts);
193
+ }
194
+ async findOnePmtCustomer(opts) {
195
+ return await this.pmt_customers.findOne(opts);
196
+ }
197
+ async replaceOnePmtCustomer(opts) {
198
+ return await this.pmt_customers.replaceOne(opts);
199
+ }
200
+ async deleteOnePmtCustomer(opts) {
201
+ return await this.pmt_customers.deleteOne(opts);
202
+ }
203
+ async deleteManyPmtCustomers(opts) {
204
+ return await this.pmt_customers.deleteMany(opts);
205
+ }
206
+ async searchManyPmtCustomers(opts) {
207
+ return await this.pmt_customers.searchMany(opts);
208
+ }
209
+ async queryPmtPublicSessions(opts) {
210
+ return await this.pmt_public_sessions.query(opts);
211
+ }
212
+ async insertOnePmtPublicSession(opts) {
213
+ return await this.pmt_public_sessions.insertOne(opts);
214
+ }
215
+ async findOnePmtPublicSession(opts) {
216
+ return await this.pmt_public_sessions.findOne(opts);
217
+ }
218
+ async replaceOnePmtPublicSession(opts) {
219
+ return await this.pmt_public_sessions.replaceOne(opts);
220
+ }
221
+ async deleteOnePmtPublicSession(opts) {
222
+ return await this.pmt_public_sessions.deleteOne(opts);
223
+ }
224
+ async deleteManyPmtPublicSessions(opts) {
225
+ return await this.pmt_public_sessions.deleteMany(opts);
226
+ }
227
+ async searchManyPmtPublicSessions(opts) {
228
+ return await this.pmt_public_sessions.searchMany(opts);
229
+ }
230
+ async queryCreditLedger(opts) {
231
+ return await this.credit_ledger.query(opts);
232
+ }
233
+ async insertOneCreditLedgerEntry(opts) {
234
+ return await this.credit_ledger.insertOne(opts);
235
+ }
236
+ async findOneCreditLedgerEntry(opts) {
237
+ return await this.credit_ledger.findOne(opts);
238
+ }
239
+ async replaceOneCreditLedgerEntry(opts) {
240
+ return await this.credit_ledger.replaceOne(opts);
241
+ }
242
+ async deleteOneCreditLedgerEntry(opts) {
243
+ return await this.credit_ledger.deleteOne(opts);
244
+ }
245
+ async deleteManyCreditLedger(opts) {
246
+ return await this.credit_ledger.deleteMany(opts);
247
+ }
248
+ async searchManyCreditLedger(opts) {
249
+ return await this.credit_ledger.searchMany(opts);
250
+ }
251
+ async balance(opts) {
252
+ const token = await requiredToken(this.get_token);
253
+ return await this.http.do({
254
+ base_url: this.base_url,
255
+ path: pmtAccountPath(PathPaymentsBalance),
256
+ method: HTTPMethodPost,
257
+ token,
258
+ body: opts,
259
+ });
260
+ }
261
+ async openPmtPublicSession(opts) {
262
+ return await this.http.do({
263
+ base_url: this.base_url,
264
+ path: pmtPublicSessionPath(PathPaymentsOpen),
265
+ method: HTTPMethodPost,
266
+ body: opts,
267
+ });
268
+ }
269
+ async paymentFromPublicSession(opts) {
270
+ return await this.http.do({
271
+ base_url: this.base_url,
272
+ path: paymentPath(PathPaymentsFromPublicSession),
273
+ method: HTTPMethodPost,
274
+ body: opts,
275
+ });
276
+ }
277
+ async purchaseCredits(opts) {
278
+ const token = await requiredToken(this.get_token);
279
+ return await this.http.do({
280
+ base_url: this.base_url,
281
+ path: creditLedgerPath(PathPaymentsPurchase),
282
+ method: HTTPMethodPost,
283
+ token,
284
+ body: opts,
285
+ });
286
+ }
287
+ async totalCredits(opts) {
288
+ const token = await requiredToken(this.get_token);
289
+ return await this.http.do({
290
+ base_url: this.base_url,
291
+ path: creditLedgerPath(PathPaymentsTotal),
292
+ method: HTTPMethodPost,
293
+ token,
294
+ body: opts,
295
+ });
296
+ }
297
+ }
298
+ export function newPaymentsClient(opts) {
299
+ return new PaymentsClient(opts);
300
+ }
301
+ function paymentPath(action) {
302
+ return buildPath({
303
+ svc: SvcPayments,
304
+ col: ColPaymentsPayments,
305
+ action,
306
+ });
307
+ }
308
+ function pmtAccountPath(action) {
309
+ return buildPath({
310
+ svc: SvcPayments,
311
+ col: ColPaymentsPmtAccounts,
312
+ action,
313
+ });
314
+ }
315
+ function pmtPublicSessionPath(action) {
316
+ return buildPath({
317
+ svc: SvcPayments,
318
+ col: ColPaymentsPmtPublicSessions,
319
+ action,
320
+ });
321
+ }
322
+ function creditLedgerPath(action) {
323
+ return buildPath({
324
+ svc: SvcPayments,
325
+ col: ColPaymentsCreditLedger,
326
+ action,
327
+ });
328
+ }