@spritz-finance/service-client 0.37.0 → 0.38.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.
@@ -86,6 +86,7 @@ export declare enum ReferralTier {
86
86
  Vip = "VIP"
87
87
  }
88
88
  export interface UsBankAccountDetails {
89
+ __typename?: "USBankAccountDetails";
89
90
  routingNumber: string;
90
91
  swiftCode?: string | null;
91
92
  }
@@ -1,7 +1,20 @@
1
1
  export * as LiabilitiesClient from "./liabilitiesServiceClient";
2
2
  import { CheckbookUser } from "../lib/graphClient/generated";
3
3
  import { ExternalBillInput } from "../payableAccounts/types";
4
- import { CheckbookCardResponse, CheckbookDebitCardResponse, CheckbookDigitalAccountResponse, CheckbookUpdateCardResponse, CreateCheckbookUserParams, CreateDebitCardInput, CreateDigitalAccountInput, CreateEntityParams, CreateTokenizedDebitCardInput, DirectPaymentResponse, IssueRefundCreditInput, IssueRefundCreditResult, MethodFiEntity, RewardTransaction, TokenizedDebitCardResponse } from "./types";
4
+ import { ApiResponse } from "../types";
5
+ import { CheckbookCardResponse, CheckbookDebitCardResponse, CheckbookDigitalAccountResponse, CheckbookUpdateCardResponse, CreateCheckbookUserParams, CreateDebitCardInput, CreateDigitalAccountInput, CreateEntityParams, CreateTokenizedDebitCardInput, DirectPaymentResponse, IssueRefundCreditInput, IssueRefundCreditResult, MethodFiEntity, RewardTransaction, TokenizedDebitCardResponse, CreditsBalance, PaymentDetails, DirectPaymentDetails, PaymentHistoryOptions, PaymentHistoryPage } from "./types";
6
+ /** Returns the envelope, including INVALID_INPUT and upstream service errors. */
7
+ export declare function getCreditsBalance(userId: string): Promise<ApiResponse<CreditsBalance>>;
8
+ /** Missing payments succeed with null; DATABASE_ERROR/SERVICE_CLIENT_ERROR remain failures. */
9
+ export declare function getPaymentDetails(paymentId: string): Promise<ApiResponse<PaymentDetails | null>>;
10
+ /** Looks up Payment.externalPaymentId, which may differ from externalPayment.id. */
11
+ export declare function getPaymentDetailsByExternalId(externalPaymentId: string): Promise<ApiResponse<PaymentDetails | null>>;
12
+ export declare function getDirectPaymentDetails(directPaymentId: string): Promise<ApiResponse<DirectPaymentDetails | null>>;
13
+ /**
14
+ * All statuses and sources. Keep sort unchanged while following nextCursor;
15
+ * no nextCursor means the final page. The server defaults to 20 rows, descending.
16
+ */
17
+ export declare function getUserPaymentHistory(userId: string, options?: PaymentHistoryOptions): Promise<ApiResponse<PaymentHistoryPage>>;
5
18
  /**
6
19
  * The bare transaction, as the legacy `/reward-transactions/:id` route returned
7
20
  * it. That route answered a missing transaction with a 404, so throw on a
@@ -34,6 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.LiabilitiesClient = void 0;
37
+ exports.getCreditsBalance = getCreditsBalance;
38
+ exports.getPaymentDetails = getPaymentDetails;
39
+ exports.getPaymentDetailsByExternalId = getPaymentDetailsByExternalId;
40
+ exports.getDirectPaymentDetails = getDirectPaymentDetails;
41
+ exports.getUserPaymentHistory = getUserPaymentHistory;
37
42
  exports.getRewardTransaction = getRewardTransaction;
38
43
  exports.createMethodFiEntity = createMethodFiEntity;
39
44
  exports.getMethodFiEntity = getMethodFiEntity;
@@ -58,6 +63,38 @@ const restClient_1 = require("../restClient");
58
63
  const baseClient = (0, restClient_1.getRestClient)(process.env.LIABILITIES_SERVICE_API_IAM_URL, "/v2/liabilities/api");
59
64
  const LIABILITIES_ENDPOINT = "/liabilities";
60
65
  const LIABILITIES_V2_ENDPOINT = "/v2/liabilities/api";
66
+ /** Returns the envelope, including INVALID_INPUT and upstream service errors. */
67
+ async function getCreditsBalance(userId) {
68
+ return baseClient
69
+ .get(`${LIABILITIES_V2_ENDPOINT}/rewards/users/${encodeURIComponent(userId)}/credits/balance`)
70
+ .then((res) => res.data);
71
+ }
72
+ /** Missing payments succeed with null; DATABASE_ERROR/SERVICE_CLIENT_ERROR remain failures. */
73
+ async function getPaymentDetails(paymentId) {
74
+ return baseClient
75
+ .get(`${LIABILITIES_V2_ENDPOINT}/payments/${encodeURIComponent(paymentId)}/details`)
76
+ .then((res) => res.data);
77
+ }
78
+ /** Looks up Payment.externalPaymentId, which may differ from externalPayment.id. */
79
+ async function getPaymentDetailsByExternalId(externalPaymentId) {
80
+ return baseClient
81
+ .get(`${LIABILITIES_V2_ENDPOINT}/payments/external/${encodeURIComponent(externalPaymentId)}/details`)
82
+ .then((res) => res.data);
83
+ }
84
+ async function getDirectPaymentDetails(directPaymentId) {
85
+ return baseClient
86
+ .get(`${LIABILITIES_V2_ENDPOINT}/direct-payment/${encodeURIComponent(directPaymentId)}/details`)
87
+ .then((res) => res.data);
88
+ }
89
+ /**
90
+ * All statuses and sources. Keep sort unchanged while following nextCursor;
91
+ * no nextCursor means the final page. The server defaults to 20 rows, descending.
92
+ */
93
+ async function getUserPaymentHistory(userId, options = {}) {
94
+ return baseClient
95
+ .get(`${LIABILITIES_V2_ENDPOINT}/payments/users/${encodeURIComponent(userId)}/history`, { params: options })
96
+ .then((res) => res.data);
97
+ }
61
98
  /**
62
99
  * The bare transaction, as the legacy `/reward-transactions/:id` route returned
63
100
  * it. That route answered a missing transaction with a 404, so throw on a
@@ -1,4 +1,126 @@
1
1
  import { DigitalAccountType } from "../lib/graphClient/generated";
2
+ import type { PayableAccountType, PaymentDeliveryMethod, PaymentStatus } from "../graphTypes";
3
+ import type { PaymentAsset } from "../payments/types";
4
+ /** JSON contracts for liabilities' enriched reads; dates are ISO 8601 UTC strings. */
5
+ export type CreditsBalance = {
6
+ balance: number;
7
+ };
8
+ export type PaymentHistoryOptions = {
9
+ /** Integer from 1 to 100; defaults to 20. */
10
+ limit?: number;
11
+ /** Opaque cursor returned by the previous page. */
12
+ cursor?: string;
13
+ /** Defaults to desc. Keep the direction unchanged between pages. */
14
+ sort?: "asc" | "desc";
15
+ };
16
+ export type PaymentHistoryPage = {
17
+ data: PaymentSummary[];
18
+ nextCursor?: string;
19
+ };
20
+ export type PaymentSummary = {
21
+ id: string;
22
+ userId: string;
23
+ accountId: string;
24
+ directPaymentId: string | null;
25
+ status: `${PaymentStatus}`;
26
+ deliveryDate: string | null;
27
+ /** USD, as are rewardsAmount and feeAmount. */
28
+ amount: number | null;
29
+ rewardsAmount: number | null;
30
+ feeAmount: number | null;
31
+ createdAt: string;
32
+ subscriptionId: string | null;
33
+ targetCurrency: string;
34
+ targetCurrencyAmount: number;
35
+ targetCurrencyRate: number;
36
+ deliveryMethod: `${PaymentDeliveryMethod}`;
37
+ };
38
+ export type PaymentUserDetails = {
39
+ id: string;
40
+ firstName: string | null;
41
+ lastName: string | null;
42
+ email: string | null;
43
+ timezone: string | null;
44
+ membership: string | null;
45
+ attributionSource: string | null;
46
+ };
47
+ export type PaymentAccountDetails = {
48
+ id: string;
49
+ __typename: `${PayableAccountType}`;
50
+ type: `${PayableAccountType}`;
51
+ name: string;
52
+ mask: string | null;
53
+ externalId: string | null;
54
+ country: string;
55
+ currency: string;
56
+ provider: string;
57
+ institution: {
58
+ name: string;
59
+ } | null;
60
+ billType: string | null;
61
+ bankAccountType: string | null;
62
+ bankAccountSubType: string | null;
63
+ ownedByUser: boolean | null;
64
+ balance: number | null;
65
+ };
66
+ export type PaymentTransactionDetails = {
67
+ link: string;
68
+ network: string;
69
+ to: string | null;
70
+ /** Display units, not raw token units. */
71
+ sourceToken: {
72
+ symbol: string;
73
+ amount: number;
74
+ } | null;
75
+ };
76
+ export type PaymentInvoiceDetails = {
77
+ network: string;
78
+ address: string;
79
+ amountFiat: number | null;
80
+ amountFiatAdjusted: number | null;
81
+ amount: number | null;
82
+ transaction: {
83
+ amount: number;
84
+ transactionId: string;
85
+ } | null;
86
+ };
87
+ export type DirectPaymentLink = {
88
+ id: string;
89
+ transaction: PaymentTransactionDetails | null;
90
+ invoice: PaymentInvoiceDetails | null;
91
+ };
92
+ export type DirectPaymentDetails = DirectPaymentLink & {
93
+ user: PaymentUserDetails | null;
94
+ payableAccount: PaymentAccountDetails | null;
95
+ };
96
+ export type LiabilitiesPaymentProvider = "METHOD_FI" | "CHECKBOOK" | "MODERN_TREASURY" | "UNBLOCK" | "BRIDGE" | "RAIN" | "TABAPAY";
97
+ export type LiabilitiesPaymentSource = "Web" | "Mobile" | "MobileIOS" | "MobileAndroid" | "ExodusDappBrowser" | "SuiWalletDappBrowser" | "Integrator" | "Widget" | "PaymentAddress" | "Subscription" | "External" | "Admin" | "Refund";
98
+ export type PaymentDetails = PaymentSummary & {
99
+ externalPaymentId: string | null;
100
+ feeSubsidyAmount: number | null;
101
+ partnerFee: number;
102
+ paymentProvider: LiabilitiesPaymentProvider;
103
+ source: LiabilitiesPaymentSource;
104
+ paymentAsset: PaymentAsset | null;
105
+ outputAsset: PaymentAsset | null;
106
+ user: PaymentUserDetails | null;
107
+ payableAccount: PaymentAccountDetails | null;
108
+ externalPayment: {
109
+ id: string;
110
+ amount: number;
111
+ estimatedCompletionDate: string | null;
112
+ completionDate: string | null;
113
+ paymentProvider: LiabilitiesPaymentProvider;
114
+ createdAt: string;
115
+ } | null;
116
+ transaction: PaymentTransactionDetails | null;
117
+ directPayment: DirectPaymentLink | null;
118
+ refund: {
119
+ hash: string | null;
120
+ amount: number | null;
121
+ to: string | null;
122
+ } | null;
123
+ };
2
124
  export declare enum RewardProvider {
3
125
  INTERNAL = "INTERNAL",
4
126
  REFERRAL_ROCK = "REFERRAL_ROCK",
@@ -149,7 +149,9 @@ export type PayableAccountInstitution = GraphInstitution & {
149
149
  };
150
150
  export declare enum VirtualCardType {
151
151
  USVirtualDebitCard = "USVirtualDebitCard",
152
- USPhysicalDebitCard = "USPhysicalDebitCard"
152
+ USPhysicalDebitCard = "USPhysicalDebitCard",
153
+ UsVirtualDebitCard = "USVirtualDebitCard",
154
+ UsPhysicalDebitCard = "USPhysicalDebitCard"
153
155
  }
154
156
  export declare enum VirtualCardStatus {
155
157
  Active = "Active",
@@ -20,6 +20,9 @@ var VirtualCardType;
20
20
  (function (VirtualCardType) {
21
21
  VirtualCardType["USVirtualDebitCard"] = "USVirtualDebitCard";
22
22
  VirtualCardType["USPhysicalDebitCard"] = "USPhysicalDebitCard";
23
+ // Preserve generated GraphQL member names for consumers moving to top-level imports.
24
+ VirtualCardType["UsVirtualDebitCard"] = "USVirtualDebitCard";
25
+ VirtualCardType["UsPhysicalDebitCard"] = "USPhysicalDebitCard";
23
26
  })(VirtualCardType || (exports.VirtualCardType = VirtualCardType = {}));
24
27
  var VirtualCardStatus;
25
28
  (function (VirtualCardStatus) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "gitHead": "06f8e96b7b38c34df26a38da329331940675e4f8",
5
5
  "description": "Service client",
6
6
  "license": "ISC",
@@ -13,6 +13,7 @@
13
13
  "scripts": {
14
14
  "prebuild": "rm -rf lib",
15
15
  "test": "vitest run",
16
+ "typecheck": "tsc --project tsconfig.test.json",
16
17
  "test:watch": "vitest",
17
18
  "test:coverage": "vitest run --coverage",
18
19
  "build": "tsc",