@fabriktor/client 0.0.92 → 0.0.94

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,9 +1,10 @@
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
+ export type OnboardingStatusOptions = Pick<Payment, "recipient_id"> & Pick<RequestOptions, "signal">;
7
8
  export type OnboardingOptions = CompletePayload<PLPaymentsOnboarding>;
8
9
  export type PaymentsBalance = SortStripeBalanceResult;
9
10
  export type OpenPmtPublicSessionOptions = CompletePayload<PLPaymentsOpenPublicSession>;
@@ -64,7 +65,8 @@ export interface PaymentsOperator {
64
65
  replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
65
66
  deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
66
67
  searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
67
- balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
68
+ balance(opts: BalanceOptions, request?: RequestOptions): Promise<OperationResultOf<PaymentsBalance>>;
69
+ onboardingStatus(opts: OnboardingStatusOptions): Promise<OperationResultOf<boolean>>;
68
70
  onboarding(opts: OnboardingOptions): Promise<OperationResultOf<RPPaymentsOnboarding>>;
69
71
  openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
70
72
  paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
@@ -132,7 +134,8 @@ export declare class PaymentsClient implements PaymentsOperator {
132
134
  replaceOneCreditLedgerEntry(opts: ReplaceOneOptionsCRUD<InCreditLedgerEntry>): Promise<OperationResult>;
133
135
  deleteOneCreditLedgerEntry(opts: DeleteOneOptionsCRUD): Promise<OperationResult>;
134
136
  searchManyCreditLedger(opts?: SearchManyOptionsCRUD): Promise<OperationResultOf<SearchResultOf<CreditLedgerEntry>>>;
135
- balance(opts: BalanceOptions): Promise<OperationResultOf<PaymentsBalance>>;
137
+ balance(opts: BalanceOptions, request?: RequestOptions): Promise<OperationResultOf<PaymentsBalance>>;
138
+ onboardingStatus(opts: OnboardingStatusOptions): Promise<OperationResultOf<boolean>>;
136
139
  onboarding(opts: OnboardingOptions): Promise<OperationResultOf<RPPaymentsOnboarding>>;
137
140
  openPmtPublicSession(opts: OpenPmtPublicSessionOptions): Promise<OperationResultOf<PmtPublicSession> | void>;
138
141
  paymentFromPublicSession(opts: PaymentFromPublicSessionOptions): Promise<OperationResult>;
@@ -3,9 +3,11 @@
3
3
  // Licensed under the Apache License, Version 2.0 (the "License"); you may
4
4
  // not use this file except in compliance with the License. You may obtain
5
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, PathPaymentsOnboarding, PathPaymentsOpen, PathPaymentsPurchase, PathPaymentsTotal, SvcPayments, } from "@fabriktor/schema";
6
+ import { ColPaymentsCreditLedger, ColPaymentsPayments, ColPaymentsPmtAccounts, ColPaymentsPmtBankAccounts, ColPaymentsPmtCards, ColPaymentsPmtCustomers, ColPaymentsPmtPublicSessions, ColPaymentsPmtRefunds, HTTPMethodPost, HTTPMethodGet, 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";
10
+ import { queryParam, withQuery } from "../core/col.js";
9
11
  import { buildPath } from "../core/path.js";
10
12
  export class PaymentsClient {
11
13
  payments;
@@ -224,7 +226,7 @@ export class PaymentsClient {
224
226
  async searchManyCreditLedger(opts) {
225
227
  return await this.credit_ledger.searchMany(opts);
226
228
  }
227
- async balance(opts) {
229
+ async balance(opts, request) {
228
230
  const token = await requiredToken(this.get_token);
229
231
  return await this.http.do({
230
232
  base_url: this.base_url,
@@ -232,6 +234,21 @@ export class PaymentsClient {
232
234
  method: HTTPMethodPost,
233
235
  token,
234
236
  body: opts,
237
+ signal: request?.signal,
238
+ // Balance is a read-only POST; canceled reads must not reuse a stored key.
239
+ idempotency_key: request?.idempotency_key ?? newIdempotencyKey(),
240
+ });
241
+ }
242
+ async onboardingStatus(opts) {
243
+ const token = await requiredToken(this.get_token);
244
+ return await this.http.do({
245
+ base_url: this.base_url,
246
+ path: withQuery(pmtAccountPath(PathPaymentsOnboarding), {
247
+ query: queryParam("recipient_id", opts.recipient_id),
248
+ }),
249
+ method: HTTPMethodGet,
250
+ token,
251
+ signal: opts.signal,
235
252
  });
236
253
  }
237
254
  async onboarding(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {