@instabrain-sdks/api-client 2.3.3 → 2.5.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/README.md +1140 -85
- package/dist/client/instabrain-client.d.ts +187 -11
- package/dist/client/instabrain-client.js +212 -10
- package/dist/services/application.service.d.ts +41 -3
- package/dist/services/application.service.js +41 -3
- package/dist/services/finalexpense.service.d.ts +129 -0
- package/dist/services/finalexpense.service.js +210 -0
- package/dist/services/gigdb.service.d.ts +25 -3
- package/dist/services/gigdb.service.js +25 -3
- package/dist/services/payment.service.d.ts +94 -0
- package/dist/services/payment.service.js +161 -0
- package/dist/services/pureterm.service.d.ts +96 -10
- package/dist/services/pureterm.service.js +100 -8
- package/dist/services/secure-sign.service.d.ts +19 -3
- package/dist/services/secure-sign.service.js +19 -3
- package/dist/types/enums.d.ts +77 -3
- package/dist/types/enums.js +89 -4
- package/dist/types/errors.js +27 -2
- package/dist/types/finalexpense.types.d.ts +459 -0
- package/dist/types/finalexpense.types.js +2 -0
- package/dist/types/gigdb.types.d.ts +32 -0
- package/dist/types/ibterm.types.d.ts +5 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/payment.types.d.ts +52 -0
- package/dist/types/payment.types.js +3 -0
- package/dist/types/pureterm.types.d.ts +186 -31
- package/dist/types/secure-sign.types.d.ts +25 -3
- package/dist/utils/error-utils.d.ts +9 -1
- package/dist/utils/error-utils.js +18 -3
- package/dist/utils/http-client.js +11 -2
- package/package.json +1 -1
|
@@ -1,59 +1,214 @@
|
|
|
1
1
|
import { Gender, PaymentFrequency, PureTermRateClass, HealthClass } from './enums';
|
|
2
2
|
import { ThirdPartyQuoteReqHeight, ThirdPartyQuoteReqRider } from './quote.types';
|
|
3
|
+
import { IBTermStartApplicationReq } from './ibterm.types';
|
|
4
|
+
/**
|
|
5
|
+
* Query parameters for the Pure Term rider lookup
|
|
6
|
+
* (`GET /api/ThirdPartyIbPureTermLookup/get-rider-details`).
|
|
7
|
+
*
|
|
8
|
+
* The `getPureTermRiderDetails()` facade takes positional arguments to match the
|
|
9
|
+
* IB Term convention; this interface is exported for callers who prefer to type
|
|
10
|
+
* their own request object.
|
|
11
|
+
*/
|
|
12
|
+
export interface PureTermRiderDetailsRequest {
|
|
13
|
+
/** Two-letter US state code (e.g. "TX"). */
|
|
14
|
+
stateCode: string;
|
|
15
|
+
/** Applicant age, integer, 18–60 inclusive. */
|
|
16
|
+
age: number;
|
|
17
|
+
/** Whether the applicant uses nicotine. Must be sent explicitly — not optional. */
|
|
18
|
+
flagNicotineUse: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** A single Pure Term rider option returned for a state/age/nicotine combination. */
|
|
21
|
+
export interface PureTermRider {
|
|
22
|
+
/**
|
|
23
|
+
* Pass into the Pure Term Quote request `riders[n].rider` to include this rider
|
|
24
|
+
* in the quote. Typed as string; tighten to an enum once the concrete value set
|
|
25
|
+
* is known.
|
|
26
|
+
*/
|
|
27
|
+
riderCode: string;
|
|
28
|
+
/** Display title for UI rendering. */
|
|
29
|
+
riderTitle: string;
|
|
30
|
+
/** Display description for UI rendering. */
|
|
31
|
+
riderDescription: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Response from `GET /api/ThirdPartyIbPureTermLookup/get-rider-details`.
|
|
35
|
+
*
|
|
36
|
+
* Optional pre-quote step that filters available Pure Term riders by state, age,
|
|
37
|
+
* and nicotine use. When `flagProductNotAvailableForState` is `true`, the
|
|
38
|
+
* `riders` array is empty and Pure Term is not available for the given inputs —
|
|
39
|
+
* do not proceed to the Quote API.
|
|
40
|
+
*
|
|
41
|
+
* Shape is identical to the IB Term rider lookup response; the two products
|
|
42
|
+
* differ only in endpoint path and underlying availability rules.
|
|
43
|
+
*/
|
|
44
|
+
export interface PureTermRiderDetailsResp {
|
|
45
|
+
/**
|
|
46
|
+
* `true` → Pure Term not available for the given `stateCode` / `age` /
|
|
47
|
+
* `flagNicotineUse` combination (e.g. WY, NY); the SDK returns this response
|
|
48
|
+
* as-is (it is a valid business state, not an error).
|
|
49
|
+
*
|
|
50
|
+
* `false` → Pure Term is available; `riders` lists the eligible rider options
|
|
51
|
+
* (may still be empty if no optional riders are configured for the combo).
|
|
52
|
+
*/
|
|
53
|
+
flagProductNotAvailableForState: boolean;
|
|
54
|
+
/** Available riders for the state/age/nicotine combo. */
|
|
55
|
+
riders: PureTermRider[];
|
|
56
|
+
}
|
|
3
57
|
/**
|
|
4
58
|
* Request body for `POST /api/ThirdPartyIbPureTermQuote/get`.
|
|
5
59
|
*
|
|
6
60
|
* Source of truth: ThirdPartyTermQuoteRequest.cs (InstaPureTerm product).
|
|
7
61
|
*
|
|
8
|
-
* **
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
62
|
+
* Pure Term uses the **same request shape and validation model as IB Term**;
|
|
63
|
+
* what differs is the product data — rate classes (which add Rated C / Rated D),
|
|
64
|
+
* term lengths (which add 15), and the coverage / benefit-period tables.
|
|
65
|
+
*
|
|
66
|
+
* **Validation rules, in the order the server checks them:**
|
|
67
|
+
* 1. `benefitPeriod` is required.
|
|
68
|
+
* 2. `stateCode`, when present, must be a state where Pure Term is available
|
|
69
|
+
* (not available in WY / NY).
|
|
70
|
+
* 3. At least one of `rateClass`, `healthClass`, or (`height` **and**
|
|
71
|
+
* `weightInLbs`) must be provided.
|
|
72
|
+
* 4. `rateClass`, when present, must be a valid Pure Term rate class.
|
|
73
|
+
* 5. `healthClass`, when present, must be valid.
|
|
74
|
+
* 6. `height` / `weightInLbs`, when present, must be a valid combination.
|
|
75
|
+
* 7. Age — derived from `dateOfBirth` when present, else `age` — must be 18–60
|
|
76
|
+
* inclusive.
|
|
77
|
+
* 8. `riders`, when present, must be valid for Pure Term.
|
|
78
|
+
* 9. When `stateCode` and (`age` or `dateOfBirth`) are present, `benefitPeriod`
|
|
79
|
+
* is checked against carrier availability (`BenefitPeriodNotAvailable`) and
|
|
80
|
+
* `faceAmount` against coverage rules (`CoverageNotAvailable`).
|
|
81
|
+
*
|
|
82
|
+
* **Error surfacing happens in two stages.** Request validation issues dedicated
|
|
83
|
+
* top-level codes only for `BenefitPeriodNotAvailable` and
|
|
84
|
+
* `CoverageNotAvailable`; every other failure at that stage — including an
|
|
85
|
+
* invalid rate class — surfaces as `InvalidRequestFormat` with a PascalCase
|
|
86
|
+
* field key under `value.fields`, at most one message per field.
|
|
87
|
+
*
|
|
88
|
+
* Once validation passes, the request runs through the shared quote-eligibility
|
|
89
|
+
* pipeline, which can still return top-level `NotAvailableForState`,
|
|
90
|
+
* `QuoteNotEligibleForGivenConditions`, `RiderNotAvailable`,
|
|
91
|
+
* `RiderFaceAmountNotValid`, or `outsideBuildChart`. Handle the full IB Term
|
|
92
|
+
* code set — do not assume those never occur for Pure Term.
|
|
17
93
|
*/
|
|
18
94
|
export interface ThirdPartyPureTermQuoteReq {
|
|
19
95
|
/**
|
|
20
|
-
* Coverage amount in dollars.
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
96
|
+
* Coverage amount in dollars. **Required.**
|
|
97
|
+
*
|
|
98
|
+
* Allowed range depends on state, age, and nicotine use:
|
|
99
|
+
* up to age 55 — $50,000–$1,000,000; age 56 — max $900,000;
|
|
100
|
+
* 57 — $800,000; 58 — $700,000; 59 — $600,000; 60 — $500,000.
|
|
101
|
+
* Out-of-range values return `CoverageNotAvailable`.
|
|
102
|
+
*/
|
|
103
|
+
faceAmount: number;
|
|
104
|
+
/**
|
|
105
|
+
* Term length in years. **Required.**
|
|
106
|
+
*
|
|
107
|
+
* Availability by age and nicotine use:
|
|
108
|
+
* ages 18–45 → 10, 15, 20, 30; ages 46–50 non-smoker → 10, 15, 20, 30;
|
|
109
|
+
* ages 46–50 smoker → 10, 15, 20; ages 51–60 → 10, 15, 20.
|
|
110
|
+
* Disallowed values return `BenefitPeriodNotAvailable`.
|
|
111
|
+
*
|
|
112
|
+
* Note 15 is a Pure-Term-only term length — IB Term offers 10 / 20 / 30.
|
|
113
|
+
*/
|
|
114
|
+
benefitPeriod: number;
|
|
115
|
+
/** Applicant gender. **Required.** */
|
|
116
|
+
gender: Gender;
|
|
117
|
+
/**
|
|
118
|
+
* 2-letter US state code (e.g. "TX"). **Required.**
|
|
119
|
+
*
|
|
120
|
+
* Pure Term is not available in WY or NY. Send `stateCode` only — do **not**
|
|
121
|
+
* send `zipCode` on the Pure Term quote.
|
|
122
|
+
*/
|
|
123
|
+
stateCode: string;
|
|
124
|
+
/** Payment frequency. **Required.** */
|
|
125
|
+
paymentFreq: PaymentFrequency;
|
|
126
|
+
/**
|
|
127
|
+
* Whether the applicant uses tobacco or nicotine.
|
|
128
|
+
* Defaults to `false` server-side when omitted.
|
|
129
|
+
*/
|
|
130
|
+
flagTobaccoUse?: boolean | null;
|
|
131
|
+
/**
|
|
132
|
+
* Rate class — one of the three rating groups.
|
|
133
|
+
*
|
|
134
|
+
* Pure Term does **not** offer `Guaranteed`, unlike the general IB Term list.
|
|
135
|
+
* An invalid value returns `InvalidRequestFormat` with the field message
|
|
136
|
+
* "Rate class is invalid. Allowed values: Preferred Plus, Preferred, Standard,
|
|
137
|
+
* Standard Extra, Rated C, Rated D."
|
|
138
|
+
*/
|
|
33
139
|
rateClass?: PureTermRateClass | null;
|
|
34
|
-
/** Health class — one of the three rating groups
|
|
140
|
+
/** Health class — one of the three rating groups. Case-insensitive server-side. */
|
|
35
141
|
healthClass?: HealthClass | null;
|
|
36
142
|
/**
|
|
37
143
|
* Applicant height. Required together with `weightInLbs` when using the
|
|
38
144
|
* height/weight rating path. Omit when rating via `rateClass` or `healthClass`.
|
|
145
|
+
* `feet` must be 1–8 and `inches` 0–11.
|
|
39
146
|
*/
|
|
40
147
|
height?: ThirdPartyQuoteReqHeight | null;
|
|
41
148
|
/** Applicant weight in lbs. Required together with `height`. */
|
|
42
149
|
weightInLbs?: number | null;
|
|
43
150
|
/** Applicant age (18–60). Provide `age` OR `dateOfBirth`. */
|
|
44
151
|
age?: number | null;
|
|
45
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Applicant date of birth (ISO 8601, e.g. `1990-10-10`). Must be in the past.
|
|
154
|
+
* Takes priority over `age` when both are provided.
|
|
155
|
+
*/
|
|
46
156
|
dateOfBirth?: string | null;
|
|
47
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* Riders to include. Omit or send `null` to quote without riders — the array is
|
|
159
|
+
* validated only when sent. Use `riderCode` values from
|
|
160
|
+
* {@link PureTermRiderDetailsResp}. A rider's face amount must not exceed
|
|
161
|
+
* `faceAmount`. Typical ranges: ADB Rider $25,000–$250,000;
|
|
162
|
+
* Dependent Child Rider $5,000–$25,000.
|
|
163
|
+
*/
|
|
48
164
|
riders?: ThirdPartyQuoteReqRider[] | null;
|
|
49
|
-
/**
|
|
50
|
-
paymentFreq?: PaymentFrequency | null;
|
|
51
|
-
/** First name — alphabetic only. Lead capture. */
|
|
165
|
+
/** First name — alphabetic only when provided. Lead capture. */
|
|
52
166
|
firstName?: string | null;
|
|
53
|
-
/** Last name — alphabetic only. Lead capture. */
|
|
167
|
+
/** Last name — alphabetic only when provided. Lead capture. */
|
|
54
168
|
lastName?: string | null;
|
|
55
|
-
/** Email address. Lead capture. */
|
|
169
|
+
/** Email address — validated only when provided. Lead capture. */
|
|
56
170
|
email?: string | null;
|
|
57
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Phone number — 10 digits or `+1XXXXXXXXXX` when provided. Formatted on
|
|
173
|
+
* success. Lead capture.
|
|
174
|
+
*/
|
|
58
175
|
phoneNum?: string | null;
|
|
59
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Request shape for the Pure Term Get Existing Quote lookup
|
|
179
|
+
* (`GET /api/ThirdPartyIbPureTermQuote/get-existing-quote?opportunityId={guid}`).
|
|
180
|
+
*
|
|
181
|
+
* The `getPureTermExistingQuote()` facade takes a plain `opportunityId` string to
|
|
182
|
+
* match the IB Term / ADB / GIGDB convention; this interface is exported for
|
|
183
|
+
* callers who prefer to type their own request object. `opportunityId` must be a
|
|
184
|
+
* valid UUID.
|
|
185
|
+
*/
|
|
186
|
+
export interface PureTermGetExistingQuoteRequest {
|
|
187
|
+
opportunityId: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Request body for `POST /api/ThirdPartyPureTermApplication/start-application`.
|
|
191
|
+
*
|
|
192
|
+
* The backend shares one request contract between IB Term and Pure Term
|
|
193
|
+
* start-application — same fields, same nesting, same optionality, same
|
|
194
|
+
* validation messages. This alias exists so Pure Term integrations read
|
|
195
|
+
* naturally; it is structurally the same type as
|
|
196
|
+
* {@link IBTermStartApplicationReq}, not a divergent shape.
|
|
197
|
+
*
|
|
198
|
+
* **Pure Term differences are behavioral, not structural:**
|
|
199
|
+
* - `quoteResponseId` must come from a Pure Term quote and belong to the Pure
|
|
200
|
+
* Term product, otherwise: "QuoteResponseId does not exist or does not belong
|
|
201
|
+
* to the requested product."
|
|
202
|
+
* - `childRiderInfo` is required only when the Dependent Child Rider was selected
|
|
203
|
+
* on the originating quote, and must **not** be sent otherwise — sending it
|
|
204
|
+
* without the rider fails with "Child rider was not included in the quote.
|
|
205
|
+
* Cannot add child rider details."
|
|
206
|
+
* - `tobaccoNicotineUsage.cigarUsagePerYear` is required only when
|
|
207
|
+
* `productTypesUsed` is **exactly** `['cigars']`. When cigars are selected
|
|
208
|
+
* alongside other product types it is not required.
|
|
209
|
+
* - `physicianDetails.stateCode` rejects both `"Outside Of The USA"` and
|
|
210
|
+
* `"OutsideUSA"`.
|
|
211
|
+
* - Pure Term does **not** run the `ApplicationLimitReached` duplicate
|
|
212
|
+
* SSN/email/phone check (that applies to ADB / GIGDB / Final Expense).
|
|
213
|
+
*/
|
|
214
|
+
export type PureTermStartApplicationReq = IBTermStartApplicationReq;
|
|
@@ -71,11 +71,33 @@ export interface ThirdPartyVerifyPinResp {
|
|
|
71
71
|
/** true when the PIN matched and documents are now signed */
|
|
72
72
|
isVerified: boolean;
|
|
73
73
|
}
|
|
74
|
+
import { FinalSubmitApplicationStatus } from './finalexpense.types';
|
|
74
75
|
/**
|
|
75
|
-
* Response from final application submit
|
|
76
|
-
*
|
|
76
|
+
* Response from final application submit.
|
|
77
|
+
*
|
|
78
|
+
* Behavior differs by product:
|
|
79
|
+
* - **Synchronous (ADB, GIGDB):** a successful (`flagStatus: true`) response
|
|
80
|
+
* **guarantees a non-null `policyNumber`**, and `applicationStatus` is absent
|
|
81
|
+
* from the JSON.
|
|
82
|
+
* - **Asynchronous (Final Expense):** `policyNumber` is `null` on the first call
|
|
83
|
+
* and `applicationStatus` is `'InProgress'`. Poll
|
|
84
|
+
* `pollFinalExpenseUnderwritingStatus()` for the terminal decision; the
|
|
85
|
+
* `policyNumber` is issued there once the status is `'Approved'`.
|
|
86
|
+
*
|
|
87
|
+
* Note: a `null` policyNumber is only expected for Final Expense (pending async
|
|
88
|
+
* underwriting) — it is NOT an error.
|
|
77
89
|
*/
|
|
78
90
|
export interface ThirdPartyFinalSubmitResp {
|
|
79
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* The policy number issued by the carrier. **Non-null** for ADB/GIGDB on a
|
|
93
|
+
* successful submit. `null` only for Final Expense on the async first call
|
|
94
|
+
* (the number is issued later via `pollFinalExpenseUnderwritingStatus()`).
|
|
95
|
+
*/
|
|
80
96
|
policyNumber: string | null;
|
|
97
|
+
/**
|
|
98
|
+
* Present only for asynchronous-underwriting products (Final Expense), where
|
|
99
|
+
* it is `'InProgress'` on the first call. Absent for ADB/GIGDB. When
|
|
100
|
+
* `'InProgress'`, call `pollFinalExpenseUnderwritingStatus()`.
|
|
101
|
+
*/
|
|
102
|
+
applicationStatus?: FinalSubmitApplicationStatus;
|
|
81
103
|
}
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
* Extract an error code from an API response.
|
|
3
3
|
*
|
|
4
4
|
* 1. Checks `response.errorCode` first (structured field).
|
|
5
|
-
* 2.
|
|
5
|
+
* 2. Then an exact match against `response.error`.
|
|
6
|
+
* 3. Falls back to scanning `response.error` for known error codes as
|
|
7
|
+
* substrings, preferring the **longest** match.
|
|
8
|
+
*
|
|
9
|
+
* The longest-match rule matters because several codes are prefixes of others —
|
|
10
|
+
* e.g. `PaymentDeclined` is contained in both `PaymentDeclinedPermanent` and
|
|
11
|
+
* `PaymentDeclinedContactBank`. Returning the first match in enum-declaration
|
|
12
|
+
* order would silently report the less specific code, breaking `isErrorType()`
|
|
13
|
+
* and `getUserFriendlyMessage()` for the more specific one.
|
|
6
14
|
*
|
|
7
15
|
* @returns The error code string if found, `null` otherwise.
|
|
8
16
|
*/
|
|
@@ -11,7 +11,15 @@ const ALL_KNOWN_ERROR_CODES = Object.values(enums_1.APIErrorCode);
|
|
|
11
11
|
* Extract an error code from an API response.
|
|
12
12
|
*
|
|
13
13
|
* 1. Checks `response.errorCode` first (structured field).
|
|
14
|
-
* 2.
|
|
14
|
+
* 2. Then an exact match against `response.error`.
|
|
15
|
+
* 3. Falls back to scanning `response.error` for known error codes as
|
|
16
|
+
* substrings, preferring the **longest** match.
|
|
17
|
+
*
|
|
18
|
+
* The longest-match rule matters because several codes are prefixes of others —
|
|
19
|
+
* e.g. `PaymentDeclined` is contained in both `PaymentDeclinedPermanent` and
|
|
20
|
+
* `PaymentDeclinedContactBank`. Returning the first match in enum-declaration
|
|
21
|
+
* order would silently report the less specific code, breaking `isErrorType()`
|
|
22
|
+
* and `getUserFriendlyMessage()` for the more specific one.
|
|
15
23
|
*
|
|
16
24
|
* @returns The error code string if found, `null` otherwise.
|
|
17
25
|
*/
|
|
@@ -20,11 +28,18 @@ function extractErrorCode(response) {
|
|
|
20
28
|
return response.errorCode;
|
|
21
29
|
}
|
|
22
30
|
if (response.error && typeof response.error === 'string') {
|
|
31
|
+
const errorText = response.error;
|
|
32
|
+
// An exact match is unambiguous — take it before any substring scanning.
|
|
33
|
+
if (ALL_KNOWN_ERROR_CODES.includes(errorText)) {
|
|
34
|
+
return errorText;
|
|
35
|
+
}
|
|
36
|
+
let longestMatch = null;
|
|
23
37
|
for (const code of ALL_KNOWN_ERROR_CODES) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
38
|
+
if (errorText.includes(code) && (longestMatch === null || code.length > longestMatch.length)) {
|
|
39
|
+
longestMatch = code;
|
|
26
40
|
}
|
|
27
41
|
}
|
|
42
|
+
return longestMatch;
|
|
28
43
|
}
|
|
29
44
|
return null;
|
|
30
45
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HttpClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const types_1 = require("../types");
|
|
9
|
+
const error_utils_1 = require("./error-utils");
|
|
9
10
|
/**
|
|
10
11
|
* HTTP client for making requests to the InstaBrain API
|
|
11
12
|
*/
|
|
@@ -44,6 +45,7 @@ class HttpClient {
|
|
|
44
45
|
});
|
|
45
46
|
// Response interceptor for error handling
|
|
46
47
|
this.axiosInstance.interceptors.response.use((response) => response, (error) => {
|
|
48
|
+
var _a;
|
|
47
49
|
if (error.response) {
|
|
48
50
|
const { status, data } = error.response;
|
|
49
51
|
// Handle specific error status codes
|
|
@@ -52,8 +54,15 @@ class HttpClient {
|
|
|
52
54
|
// Clear invalid token
|
|
53
55
|
this.jwtToken = null;
|
|
54
56
|
throw new types_1.AuthenticationError((data === null || data === void 0 ? void 0 : data.error) || 'Authentication failed');
|
|
55
|
-
case 400:
|
|
56
|
-
|
|
57
|
+
case 400: {
|
|
58
|
+
// Mirror BaseService's flagStatus-false handling so a 400 and a
|
|
59
|
+
// 200-with-flagStatus-false produce the same error type. Callers
|
|
60
|
+
// documented to use isErrorType() / getUserFriendlyMessage() need
|
|
61
|
+
// APIValidationError, and the body carries value.fields.
|
|
62
|
+
const errorMessage = (data === null || data === void 0 ? void 0 : data.error) || (data === null || data === void 0 ? void 0 : data.errorCode) || 'Validation failed';
|
|
63
|
+
const errorCode = (_a = (0, error_utils_1.extractErrorCode)(data !== null && data !== void 0 ? data : {})) !== null && _a !== void 0 ? _a : errorMessage;
|
|
64
|
+
throw new types_1.APIValidationError(errorMessage, errorCode, data);
|
|
65
|
+
}
|
|
57
66
|
case 404:
|
|
58
67
|
throw new types_1.InstaBrainError('Resource not found', 404, data);
|
|
59
68
|
case 500:
|
package/package.json
CHANGED