@fabriktor/client 0.0.92 → 0.0.93
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
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 PLPaymentsOnboarding, type PLPaymentsOpenPublicSession, type PLPaymentsPaymentFromPublicSession, type PLPaymentsPurchaseCredits, type PLPaymentsTotalCredits, type PmtAccount, type PmtBankAccount, type PmtCard, type PmtCustomer, type PmtPublicSession, type PmtRefund, type RPPaymentsOnboarding, type RPPaymentsTotalCredits, type SortStripeBalanceResult } from "@fabriktor/schema";
|
|
2
2
|
import type { TokenProvider } from "../core/auth.js";
|
|
3
3
|
import type { DeleteOneOptionsCRUD, FindOneOptionsCRUD, InsertOneOptionsCRUD, OperationResultOf, QueryOptionsCRUD, ReplaceOneOptionsCRUD, SearchManyOptionsCRUD, SearchResultOf } from "../core/crud.js";
|
|
4
|
-
import type { HTTPDoer } from "../core/http.js";
|
|
4
|
+
import type { HTTPDoer, RequestOptions } from "../core/http.js";
|
|
5
5
|
import type { CompletePayload } from "../core/type.js";
|
|
6
6
|
export type BalanceOptions = CompletePayload<PLPaymentsBalance>;
|
|
7
7
|
export type OnboardingOptions = CompletePayload<PLPaymentsOnboarding>;
|
|
@@ -64,7 +64,7 @@ export interface PaymentsOperator {
|
|
|
64
64
|
replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
|
|
65
65
|
deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
66
66
|
searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
|
|
67
|
-
balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
|
|
67
|
+
balance(opts: BalanceOptions, request?: RequestOptions): Promise<OperationResultOf<PaymentsBalance>>;
|
|
68
68
|
onboarding(opts: OnboardingOptions): Promise<OperationResultOf<RPPaymentsOnboarding>>;
|
|
69
69
|
openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
|
|
70
70
|
paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
|
|
@@ -132,7 +132,7 @@ export declare class PaymentsClient implements PaymentsOperator {
|
|
|
132
132
|
replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
|
|
133
133
|
deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
|
|
134
134
|
searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
|
|
135
|
-
balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
|
|
135
|
+
balance(opts: BalanceOptions, request?: RequestOptions): Promise<OperationResultOf<PaymentsBalance>>;
|
|
136
136
|
onboarding(opts: OnboardingOptions): Promise<OperationResultOf<RPPaymentsOnboarding>>;
|
|
137
137
|
openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
|
|
138
138
|
paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { ColPaymentsCreditLedger, ColPaymentsPayments, ColPaymentsPmtAccounts, ColPaymentsPmtBankAccounts, ColPaymentsPmtCards, ColPaymentsPmtCustomers, ColPaymentsPmtPublicSessions, ColPaymentsPmtRefunds, HTTPMethodPost, PathPaymentsBalance, PathPaymentsFromPublicSession, PathPaymentsOnboarding, PathPaymentsOpen, PathPaymentsPurchase, PathPaymentsTotal, SvcPayments, } from "@fabriktor/schema";
|
|
7
7
|
import { requiredToken } from "../core/auth.js";
|
|
8
8
|
import { newCRUDClient } from "../core/crud.js";
|
|
9
|
+
import { newIdempotencyKey } from "../core/idempotency.js";
|
|
9
10
|
import { buildPath } from "../core/path.js";
|
|
10
11
|
export class PaymentsClient {
|
|
11
12
|
payments;
|
|
@@ -224,7 +225,7 @@ export class PaymentsClient {
|
|
|
224
225
|
async searchManyCreditLedger(opts) {
|
|
225
226
|
return await this.credit_ledger.searchMany(opts);
|
|
226
227
|
}
|
|
227
|
-
async balance(opts) {
|
|
228
|
+
async balance(opts, request) {
|
|
228
229
|
const token = await requiredToken(this.get_token);
|
|
229
230
|
return await this.http.do({
|
|
230
231
|
base_url: this.base_url,
|
|
@@ -232,6 +233,9 @@ export class PaymentsClient {
|
|
|
232
233
|
method: HTTPMethodPost,
|
|
233
234
|
token,
|
|
234
235
|
body: opts,
|
|
236
|
+
signal: request?.signal,
|
|
237
|
+
// Balance is a read-only POST; canceled reads must not reuse a stored key.
|
|
238
|
+
idempotency_key: request?.idempotency_key ?? newIdempotencyKey(),
|
|
235
239
|
});
|
|
236
240
|
}
|
|
237
241
|
async onboarding(opts) {
|