@spritz-finance/service-client 0.26.0 → 0.27.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.
@@ -21,7 +21,8 @@ const interceptor = function (tokenProvider, authenticate) {
21
21
  return tokenProvider({ getToken, headerFormatter });
22
22
  };
23
23
  const createGraphClient = (config) => {
24
- const serviceClient = axios_1.default.create(config);
24
+ // See DEFAULT_TIMEOUT_MS in serviceClient.ts — same rationale.
25
+ const serviceClient = axios_1.default.create({ timeout: 10000, ...config });
25
26
  serviceClient.interceptors.request.use(interceptor(axios_token_interceptor_1.default, credentials_1.getGraphCredentials));
26
27
  // Add trace header propagation interceptor
27
28
  serviceClient.interceptors.request.use((requestConfig) => {
@@ -167,9 +167,8 @@ export declare function markUnpayable(accountId: string, code: BankAccountUnpaya
167
167
  unpayableAt?: string | null;
168
168
  }>>;
169
169
  /**
170
- * Permanently mark a debit card unpayable — the network refused a payout for a
171
- * reason no retry can fix ("The card has expired."). `payable: false` is what
172
- * liabilities gates creation, reissue and redirect on; the user must add a
173
- * replacement card. Idempotent.
170
+ * Permanently mark a debit card unpayable when the network reports a durable
171
+ * card verdict. `payable: false` is what liabilities gates creation, reissue
172
+ * and redirect on; the user must add a replacement card. Idempotent.
174
173
  */
175
174
  export declare function markDebitCardUnpayable(cardId: string, code: DebitCardUnpayableCode, reason: string): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<DebitCardDetails>>;
@@ -139,10 +139,9 @@ async function markUnpayable(accountId, code, reason) {
139
139
  .then((res) => res.data);
140
140
  }
141
141
  /**
142
- * Permanently mark a debit card unpayable — the network refused a payout for a
143
- * reason no retry can fix ("The card has expired."). `payable: false` is what
144
- * liabilities gates creation, reissue and redirect on; the user must add a
145
- * replacement card. Idempotent.
142
+ * Permanently mark a debit card unpayable when the network reports a durable
143
+ * card verdict. `payable: false` is what liabilities gates creation, reissue
144
+ * and redirect on; the user must add a replacement card. Idempotent.
146
145
  */
147
146
  async function markDebitCardUnpayable(cardId, code, reason) {
148
147
  return serviceClient_1.baseClient
@@ -103,7 +103,7 @@ type VirtualCardModel = Omit<VirtualCard, "type" | "institution"> & PayableAccou
103
103
  * Mirrors `BankAccountUnpayableCode`; verbatim evidence stays in
104
104
  * `unpayableReason`.
105
105
  */
106
- export type DebitCardUnpayableCode = "card_expired";
106
+ export type DebitCardUnpayableCode = "card_expired" | "card_inactive" | "card_type_unsupported";
107
107
  type DebitCardModel = Omit<DebitCard, "type" | "institution"> & PayableAccountModelExtension & {
108
108
  providerRegistrations?: ProviderRegistration[];
109
109
  /** Set alongside `payable: false` when the card lapsed or the network
@@ -60,6 +60,8 @@ const credentials_1 = require("../credentials");
60
60
  const EXPIRATION_BUFFER_MS = 20 * 60 * 1000;
61
61
  const platformClient = axios_1.default.create({
62
62
  baseURL: config_1.config.platformEndpoint,
63
+ // See DEFAULT_TIMEOUT_MS in serviceClient.ts — same rationale.
64
+ timeout: 10000,
63
65
  });
64
66
  platformClient.interceptors.request.use((0, axios_token_interceptor_1.default)({
65
67
  getToken: axios_token_interceptor_1.default.tokenCache(credentials_1.getServiceCredentials, {
@@ -1,3 +1,4 @@
1
1
  import { AxiosRequestConfig } from "axios";
2
+ export declare const DEFAULT_TIMEOUT_MS = 10000;
2
3
  export declare const createServiceClient: (config: AxiosRequestConfig) => import("axios").AxiosInstance;
3
4
  export declare const baseClient: import("axios").AxiosInstance;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.baseClient = exports.createServiceClient = void 0;
6
+ exports.baseClient = exports.createServiceClient = exports.DEFAULT_TIMEOUT_MS = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  // @ts-expect-error no type declarations for axios-token-interceptor
9
9
  const axios_token_interceptor_1 = __importDefault(require("axios-token-interceptor"));
@@ -13,6 +13,11 @@ const credentials_1 = require("./credentials");
13
13
  const EXPIRATION_BUFFER_MS = 20 * 60 * 1000; // 20 minutes buffer
14
14
  const RETRY_DELAY_MS = 300;
15
15
  const RETRY_STATUS_CODE = 502;
16
+ // Axios defaults to no timeout, so a hung downstream pins the calling Lambda
17
+ // for its full timeout (30s on the Graph lambda) while holding a concurrency
18
+ // slot. 10s + the single 502 retry still fits inside that budget. Callers
19
+ // with a legitimately slow endpoint override `timeout` in their own config.
20
+ exports.DEFAULT_TIMEOUT_MS = 10000;
16
21
  const getMaxAge = () => {
17
22
  return EXPIRATION_BUFFER_MS;
18
23
  };
@@ -25,7 +30,7 @@ const interceptor = function (tokenProvider, authenticate) {
25
30
  };
26
31
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
27
32
  const createServiceClient = (config) => {
28
- const serviceClient = axios_1.default.create(config);
33
+ const serviceClient = axios_1.default.create({ timeout: exports.DEFAULT_TIMEOUT_MS, ...config });
29
34
  serviceClient.interceptors.request.use(interceptor(axios_token_interceptor_1.default, credentials_1.getServiceCredentials));
30
35
  // Add trace header propagation interceptor
31
36
  serviceClient.interceptors.request.use((requestConfig) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/service-client",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "gitHead": "06f8e96b7b38c34df26a38da329331940675e4f8",
5
5
  "description": "Service client",
6
6
  "license": "ISC",