@spritz-finance/service-client 0.37.0 → 0.39.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.
- package/lib/graphTypes.d.ts +1 -0
- package/lib/liabilities/liabilitiesServiceClient.d.ts +14 -1
- package/lib/liabilities/liabilitiesServiceClient.js +37 -0
- package/lib/liabilities/types.d.ts +121 -0
- package/lib/payableAccounts/types.d.ts +3 -1
- package/lib/payableAccounts/types.js +3 -0
- package/package.json +2 -1
package/lib/graphTypes.d.ts
CHANGED
|
@@ -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 {
|
|
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,125 @@
|
|
|
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
|
+
type: PayableAccountType;
|
|
50
|
+
name: string;
|
|
51
|
+
mask: string | null;
|
|
52
|
+
externalId: string | null;
|
|
53
|
+
country: string;
|
|
54
|
+
currency: string;
|
|
55
|
+
provider: string;
|
|
56
|
+
institution: {
|
|
57
|
+
name: string;
|
|
58
|
+
} | null;
|
|
59
|
+
billType: string | null;
|
|
60
|
+
bankAccountType: string | null;
|
|
61
|
+
bankAccountSubType: string | null;
|
|
62
|
+
ownedByUser: boolean | null;
|
|
63
|
+
balance: number | null;
|
|
64
|
+
};
|
|
65
|
+
export type PaymentTransactionDetails = {
|
|
66
|
+
link: string;
|
|
67
|
+
network: string;
|
|
68
|
+
to: string | null;
|
|
69
|
+
/** Display units, not raw token units. */
|
|
70
|
+
sourceToken: {
|
|
71
|
+
symbol: string;
|
|
72
|
+
amount: number;
|
|
73
|
+
} | null;
|
|
74
|
+
};
|
|
75
|
+
export type PaymentInvoiceDetails = {
|
|
76
|
+
network: string;
|
|
77
|
+
address: string;
|
|
78
|
+
amountFiat: number | null;
|
|
79
|
+
amountFiatAdjusted: number | null;
|
|
80
|
+
amount: number | null;
|
|
81
|
+
transaction: {
|
|
82
|
+
amount: number;
|
|
83
|
+
transactionId: string;
|
|
84
|
+
} | null;
|
|
85
|
+
};
|
|
86
|
+
export type DirectPaymentLink = {
|
|
87
|
+
id: string;
|
|
88
|
+
transaction: PaymentTransactionDetails | null;
|
|
89
|
+
invoice: PaymentInvoiceDetails | null;
|
|
90
|
+
};
|
|
91
|
+
export type DirectPaymentDetails = DirectPaymentLink & {
|
|
92
|
+
user: PaymentUserDetails | null;
|
|
93
|
+
payableAccount: PaymentAccountDetails | null;
|
|
94
|
+
};
|
|
95
|
+
export type LiabilitiesPaymentProvider = "METHOD_FI" | "CHECKBOOK" | "MODERN_TREASURY" | "UNBLOCK" | "BRIDGE" | "RAIN" | "TABAPAY";
|
|
96
|
+
export type LiabilitiesPaymentSource = "Web" | "Mobile" | "MobileIOS" | "MobileAndroid" | "ExodusDappBrowser" | "SuiWalletDappBrowser" | "Integrator" | "Widget" | "PaymentAddress" | "Subscription" | "External" | "Admin" | "Refund";
|
|
97
|
+
export type PaymentDetails = PaymentSummary & {
|
|
98
|
+
externalPaymentId: string | null;
|
|
99
|
+
feeSubsidyAmount: number | null;
|
|
100
|
+
partnerFee: number;
|
|
101
|
+
paymentProvider: LiabilitiesPaymentProvider;
|
|
102
|
+
source: LiabilitiesPaymentSource;
|
|
103
|
+
paymentAsset: PaymentAsset | null;
|
|
104
|
+
outputAsset: PaymentAsset | null;
|
|
105
|
+
user: PaymentUserDetails | null;
|
|
106
|
+
payableAccount: PaymentAccountDetails | null;
|
|
107
|
+
externalPayment: {
|
|
108
|
+
id: string;
|
|
109
|
+
amount: number;
|
|
110
|
+
estimatedCompletionDate: string | null;
|
|
111
|
+
completionDate: string | null;
|
|
112
|
+
paymentProvider: LiabilitiesPaymentProvider;
|
|
113
|
+
createdAt: string;
|
|
114
|
+
} | null;
|
|
115
|
+
transaction: PaymentTransactionDetails | null;
|
|
116
|
+
directPayment: DirectPaymentLink | null;
|
|
117
|
+
refund: {
|
|
118
|
+
hash: string | null;
|
|
119
|
+
amount: number | null;
|
|
120
|
+
to: string | null;
|
|
121
|
+
} | null;
|
|
122
|
+
};
|
|
2
123
|
export declare enum RewardProvider {
|
|
3
124
|
INTERNAL = "INTERNAL",
|
|
4
125
|
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.
|
|
3
|
+
"version": "0.39.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",
|