@spritz-finance/service-client 0.10.0 → 0.12.0

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.
@@ -104,12 +104,20 @@ async function createCheckbookDebitCard(input) {
104
104
  * flag). Throws on a non-2xx response.
105
105
  */
106
106
  async function createTokenizedDebitCard(input) {
107
- return serviceClient_1.baseClient
108
- .post(`${LIABILITIES_ENDPOINT}/debit-card/create`, input)
109
- .then((res) => ({
110
- externalId: res.data.checkbookCardId,
111
- cardLast4: res.data.cardLast4,
112
- }));
107
+ var _a, _b;
108
+ // Served by the Hono ServiceApi (30s timeout), which wraps the result in the
109
+ // standard `{ status, data }` envelope. Unwrap it here so callers keep the
110
+ // simple `{ externalId, cardLast4 }` contract; surface the provider error
111
+ // message on failure instead of an opaque error.
112
+ const res = await serviceClient_1.baseClient.post(`${LIABILITIES_V2_ENDPOINT}/checkbook/debit-card/create`, input);
113
+ const body = res.data;
114
+ if (body.status === "failure") {
115
+ throw new Error((_b = (_a = body.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : "Tokenized debit card creation failed");
116
+ }
117
+ return {
118
+ externalId: body.data.checkbookCardId,
119
+ cardLast4: body.data.cardLast4,
120
+ };
113
121
  }
114
122
  async function createCheckbookDigitalAccount(input) {
115
123
  return serviceClient_1.baseClient
@@ -32,6 +32,8 @@ export declare function getAccount(accountId: string): Promise<(Omit<import("../
32
32
  payable: boolean;
33
33
  testPaymentAvailable: boolean;
34
34
  provider: import("../lib/graphClient/generated").AccountProvider;
35
+ } & {
36
+ providerRegistrations?: import("./types").ProviderRegistration[];
35
37
  }) | (Omit<import("../lib/graphClient/generated").OneTimePayment, "type" | "institution"> & {
36
38
  __t: import("../lib/graphClient/generated").PayableAccountType;
37
39
  externalId?: string | null;
@@ -73,6 +75,8 @@ export declare function getAccountByExternalId(externalId: string): Promise<(Omi
73
75
  payable: boolean;
74
76
  testPaymentAvailable: boolean;
75
77
  provider: import("../lib/graphClient/generated").AccountProvider;
78
+ } & {
79
+ providerRegistrations?: import("./types").ProviderRegistration[];
76
80
  }) | (Omit<import("../lib/graphClient/generated").OneTimePayment, "type" | "institution"> & {
77
81
  __t: import("../lib/graphClient/generated").PayableAccountType;
78
82
  externalId?: string | null;
@@ -41,6 +41,26 @@ export type CheckbookAccountInput = {
41
41
  ownedByUser?: boolean;
42
42
  type: BankAccountSubType;
43
43
  };
44
+ export declare enum ProviderRegistrationStatus {
45
+ Pending = "Pending",
46
+ Active = "Active",
47
+ Failed = "Failed"
48
+ }
49
+ /**
50
+ * A card's registration with a single provider (Checkbook, Modern Treasury, …).
51
+ * Embedded in the debit-card payload by payable-accounts `getAccountById` so
52
+ * consumers can resolve a specific provider's externalId/readiness without a
53
+ * second fetch. Dates are serialized as ISO strings over the wire.
54
+ */
55
+ export type ProviderRegistration = {
56
+ provider: AccountProvider;
57
+ externalId?: string | null;
58
+ status: ProviderRegistrationStatus;
59
+ error?: string | null;
60
+ attemptCount: number;
61
+ activatedAt?: string | null;
62
+ lastFailedAt?: string | null;
63
+ };
44
64
  type PayableAccountModelExtension = {
45
65
  __t: PayableAccountType;
46
66
  externalId?: string | null;
@@ -53,7 +73,9 @@ type PayableAccountModelExtension = {
53
73
  type BillModel = Omit<Bill, "type" | "institution"> & PayableAccountModelExtension;
54
74
  type BankAcountModel = Omit<BankAccount, "type" | "institution"> & PayableAccountModelExtension;
55
75
  type VirtualCardModel = Omit<VirtualCard, "type" | "institution"> & PayableAccountModelExtension;
56
- type DebitCardModel = Omit<DebitCard, "type" | "institution"> & PayableAccountModelExtension;
76
+ type DebitCardModel = Omit<DebitCard, "type" | "institution"> & PayableAccountModelExtension & {
77
+ providerRegistrations?: ProviderRegistration[];
78
+ };
57
79
  type DigitalAccountModel = Omit<DigitalAccount, "type" | "institution"> & PayableAccountModelExtension;
58
80
  type OneTimePaymentModel = Omit<OneTimePayment, "type" | "institution"> & PayableAccountModelExtension;
59
81
  export type PayableAccount = BankAcountModel | VirtualCardModel | BillModel | DebitCardModel | OneTimePaymentModel;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VirtualCardStatus = exports.VirtualCardType = exports.BankAccountSubType = exports.PayableAccountOriginator = exports.AccountSyncStatus = void 0;
3
+ exports.VirtualCardStatus = exports.VirtualCardType = exports.ProviderRegistrationStatus = exports.BankAccountSubType = exports.PayableAccountOriginator = exports.AccountSyncStatus = void 0;
4
4
  var generated_1 = require("../lib/graphClient/generated");
5
5
  Object.defineProperty(exports, "AccountSyncStatus", { enumerable: true, get: function () { return generated_1.AccountSyncStatus; } });
6
6
  Object.defineProperty(exports, "PayableAccountOriginator", { enumerable: true, get: function () { return generated_1.PayableAccountOriginator; } });
@@ -10,6 +10,12 @@ var BankAccountSubType;
10
10
  BankAccountSubType["Checking"] = "CHECKING";
11
11
  BankAccountSubType["Savings"] = "SAVINGS";
12
12
  })(BankAccountSubType || (exports.BankAccountSubType = BankAccountSubType = {}));
13
+ var ProviderRegistrationStatus;
14
+ (function (ProviderRegistrationStatus) {
15
+ ProviderRegistrationStatus["Pending"] = "Pending";
16
+ ProviderRegistrationStatus["Active"] = "Active";
17
+ ProviderRegistrationStatus["Failed"] = "Failed";
18
+ })(ProviderRegistrationStatus || (exports.ProviderRegistrationStatus = ProviderRegistrationStatus = {}));
13
19
  var VirtualCardType;
14
20
  (function (VirtualCardType) {
15
21
  VirtualCardType["USVirtualDebitCard"] = "USVirtualDebitCard";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "gitHead": "06f8e96b7b38c34df26a38da329331940675e4f8",
5
5
  "description": "Service client",
6
6
  "license": "ISC",