@fincuratech/stedi-sdk-js 1.4.2 → 1.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/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/client.js +5 -4
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/errors.js +35 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/client.d.ts.map +1 -1
- package/dist/types/lib/errors.d.ts +17 -0
- package/dist/types/lib/errors.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { payers } from './endpoints/payers.js';
|
|
|
4
4
|
import { provider } from './endpoints/provider.js';
|
|
5
5
|
import { transactions } from './endpoints/transactions.js';
|
|
6
6
|
import { stediClient } from './lib/client.js';
|
|
7
|
+
export { StediApiError } from './lib/errors.js';
|
|
7
8
|
export { createConsoleLogger, createNoOpLogger, setLogger, } from './lib/logger.js';
|
|
8
9
|
export * from './lib/types.js';
|
|
9
10
|
export const createStediClient = (apiKey) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAEhB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,sCAAsC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;IAEzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACnD,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAC9C,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AAIF,eAAe,iBAAiB,CAAC","sourcesContent":["import { eligibility } from './endpoints/eligibility.js';\nimport { enrollment } from './endpoints/enrollment.js';\nimport { payers } from './endpoints/payers.js';\nimport { provider } from './endpoints/provider.js';\nimport { transactions } from './endpoints/transactions.js';\nimport { stediClient } from './lib/client.js';\n\nexport {\n createConsoleLogger,\n createNoOpLogger,\n type Logger,\n setLogger,\n} from './lib/logger.js';\nexport * from './lib/types.js';\n\nexport const createStediClient = (apiKey: string) => {\n const coreBaseUrl = 'https://core.us.stedi.com/2023-08-01';\n const healthcareBaseUrl = 'https://healthcare.us.stedi.com/2024-04-01';\n const enrollmentsBaseUrl = 'https://enrollments.us.stedi.com/2024-09-01';\n\n const client = stediClient(apiKey);\n return {\n downloadFile: client.downloadFile,\n eligibility: eligibility(client, healthcareBaseUrl),\n enrollment: enrollment(client, enrollmentsBaseUrl),\n payers: payers(client, healthcareBaseUrl),\n provider: provider(client, enrollmentsBaseUrl),\n transactions: transactions(client, coreBaseUrl),\n };\n};\n\nexport type StediClient = ReturnType<typeof createStediClient>;\n\nexport default createStediClient;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAEhB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;IAClD,MAAM,WAAW,GAAG,sCAAsC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,MAAM,kBAAkB,GAAG,6CAA6C,CAAC;IAEzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACnD,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;QACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;QAC9C,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AAIF,eAAe,iBAAiB,CAAC","sourcesContent":["import { eligibility } from './endpoints/eligibility.js';\nimport { enrollment } from './endpoints/enrollment.js';\nimport { payers } from './endpoints/payers.js';\nimport { provider } from './endpoints/provider.js';\nimport { transactions } from './endpoints/transactions.js';\nimport { stediClient } from './lib/client.js';\n\nexport { StediApiError, type StediErrorBody } from './lib/errors.js';\nexport {\n createConsoleLogger,\n createNoOpLogger,\n type Logger,\n setLogger,\n} from './lib/logger.js';\nexport * from './lib/types.js';\n\nexport const createStediClient = (apiKey: string) => {\n const coreBaseUrl = 'https://core.us.stedi.com/2023-08-01';\n const healthcareBaseUrl = 'https://healthcare.us.stedi.com/2024-04-01';\n const enrollmentsBaseUrl = 'https://enrollments.us.stedi.com/2024-09-01';\n\n const client = stediClient(apiKey);\n return {\n downloadFile: client.downloadFile,\n eligibility: eligibility(client, healthcareBaseUrl),\n enrollment: enrollment(client, enrollmentsBaseUrl),\n payers: payers(client, healthcareBaseUrl),\n provider: provider(client, enrollmentsBaseUrl),\n transactions: transactions(client, coreBaseUrl),\n };\n};\n\nexport type StediClient = ReturnType<typeof createStediClient>;\n\nexport default createStediClient;\n"]}
|
package/dist/lib/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosError } from 'axios';
|
|
2
|
+
import { StediApiError } from './errors.js';
|
|
2
3
|
import { getLogger } from './logger.js';
|
|
3
4
|
export const stediClient = (apiKey) => {
|
|
4
5
|
const defaultHeaders = {
|
|
@@ -27,9 +28,9 @@ export const stediClient = (apiKey) => {
|
|
|
27
28
|
delete error.config;
|
|
28
29
|
delete error.request;
|
|
29
30
|
delete error.response?.request;
|
|
30
|
-
throw new
|
|
31
|
+
throw new StediApiError(`Request to Stedi API failed: ${error.response?.data.message ||
|
|
31
32
|
error.response?.data.detail ||
|
|
32
|
-
error.message}`,
|
|
33
|
+
error.message}`, error.response?.status ?? 0, error.response?.data, error);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
throw error;
|
|
@@ -63,9 +64,9 @@ export const stediClient = (apiKey) => {
|
|
|
63
64
|
delete error.config;
|
|
64
65
|
delete error.request;
|
|
65
66
|
delete error.response?.request;
|
|
66
|
-
throw new
|
|
67
|
+
throw new StediApiError(`Request to Stedi API failed: ${error.response?.data.message ||
|
|
67
68
|
error.response?.data.detail ||
|
|
68
|
-
error.message}`,
|
|
69
|
+
error.message}`, error.response?.status ?? 0, error.response?.data, error);
|
|
69
70
|
}
|
|
70
71
|
else {
|
|
71
72
|
throw error;
|
package/dist/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAwC,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAOxC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE;YACP,aAAa,EAAE,MAAM;YACrB,cAAc,EAAE,kBAAkB;SACnC;KACF,CAAC;IAQF,MAAM,YAAY,GAAG,KAAK,EAAE,GAAW,EAAmB,EAAE;QAE1D,MAAM,aAAa,GAAG,+CAA+C,CAAC;QACtE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,GAAG,cAAc;gBACjB,YAAY,EAAE,aAAa;aAC5B,CAAC,CAAC;YAEH,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;YAED,O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BACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;aACxB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC,MAAM,CAAC;gBACpB,OAAO,KAAK,CAAC,OAAO,CAAC;gBACrB,OAAO,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAE/B,MAAM,IAAI,aAAa,CACrB,gCACE,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO;oBAC5B,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM;oBAC3B,KAAK,CAAC,OACR,EAAE,EACF,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,EAC3B,KAAK,CAAC,QAAQ,EAAE,IAAI,EACpB,KAAK,CACN,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,OAAO;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import axios, { AxiosError, type AxiosRequestConfig, type Method } from 'axios';\n\nimport { StediApiError } from './errors.js';\nimport { getLogger } from './logger.js';\n\n/**\n * Create a client for the Stedi API.\n *\n * @returns The Stedi client.\n */\nexport const stediClient = (apiKey: string) => {\n const defaultHeaders = {\n headers: {\n Authorization: apiKey,\n 'Content-Type': 'application/json',\n },\n };\n\n /**\n * Download a file from the Stedi API.\n *\n * @param url - The URL to download the file from.\n * @returns The file content.\n */\n const downloadFile = async (url: string): Promise<string> => {\n // Validate that the URL is from stedi.com or its subdomains\n const stediUrlRegex = /^https:\\/\\/(?:[\\dA-Za-z-]+\\.)*stedi\\.com\\/.*/u;\n if (!stediUrlRegex.test(url)) {\n throw new Error(\n 'Invalid URL: The URL must be from the Stedi API (stedi.com or its subdomains)',\n );\n }\n\n try {\n const response = await axios.get(url, {\n ...defaultHeaders,\n responseType: 'arraybuffer',\n });\n // Convert buffer to string if it's a buffer\n if (Buffer.isBuffer(response.data)) {\n return response.data.toString('utf8');\n }\n\n return response.data;\n } catch (error) {\n if (error instanceof AxiosError) {\n delete error.config;\n delete error.request;\n delete error.response?.request;\n\n throw new StediApiError(\n `Request to Stedi API failed: ${\n error.response?.data.message ||\n error.response?.data.detail ||\n error.message\n }`,\n error.response?.status ?? 0,\n error.response?.data,\n error,\n );\n } else {\n throw error;\n }\n }\n };\n\n /**\n * Execute a request to the Stedi API.\n *\n * @param baseUrl - The base URL to use.\n * @param method - The HTTP method to use.\n * @param path - The path to request.\n * @param [config] - custom configuration for the request.\n * @returns The result of the request.\n */\n const request = async <T>(\n baseUrl: string,\n method: Method,\n path: string,\n config?: AxiosRequestConfig,\n ): Promise<T> => {\n const log = getLogger();\n\n try {\n log.debug('Stedi API request', { config, method, path });\n\n const response = await axios.request<T>({\n ...config,\n headers: {\n ...defaultHeaders.headers,\n ...config?.headers,\n },\n method,\n // Serialize arrays without brackets\n paramsSerializer: {\n indexes: null,\n },\n url: `${baseUrl}/${path.replace(/^\\//u, '')}`,\n });\n\n log.debug('Stedi API response', {\n data: response.data,\n status: response.status,\n });\n\n return response.data;\n } catch (error) {\n if (error instanceof AxiosError) {\n delete error.config;\n delete error.request;\n delete error.response?.request;\n\n throw new StediApiError(\n `Request to Stedi API failed: ${\n error.response?.data.message ||\n error.response?.data.detail ||\n error.message\n }`,\n error.response?.status ?? 0,\n error.response?.data,\n error,\n );\n } else {\n throw error;\n }\n }\n };\n\n return {\n downloadFile,\n request,\n };\n};\n\nexport type StediClient = ReturnType<typeof stediClient>;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const extractErrorCode = (body) => {
|
|
2
|
+
if (typeof body !== 'object' || body === null) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const record = body;
|
|
6
|
+
if (typeof record.error === 'string') {
|
|
7
|
+
return record.error;
|
|
8
|
+
}
|
|
9
|
+
if (typeof record.code === 'string') {
|
|
10
|
+
return record.code;
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
const extractResponseMessage = (body) => {
|
|
15
|
+
if (typeof body !== 'object' || body === null) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const candidate = body.message;
|
|
19
|
+
return typeof candidate === 'string' ? candidate : undefined;
|
|
20
|
+
};
|
|
21
|
+
export class StediApiError extends Error {
|
|
22
|
+
errorCode;
|
|
23
|
+
responseBody;
|
|
24
|
+
responseMessage;
|
|
25
|
+
statusCode;
|
|
26
|
+
constructor(message, statusCode, responseBody, cause) {
|
|
27
|
+
super(message, { cause });
|
|
28
|
+
this.name = 'StediApiError';
|
|
29
|
+
this.errorCode = extractErrorCode(responseBody);
|
|
30
|
+
this.responseBody = responseBody;
|
|
31
|
+
this.responseMessage = extractResponseMessage(responseBody);
|
|
32
|
+
this.statusCode = statusCode;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAmBA,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAsB,EAAE;IAC7D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAA+B,CAAC;IAE/C,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,IAAa,EAAsB,EAAE;IACnE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAI,IAAgC,CAAC,OAAO,CAAC;IAC5D,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,OAAO,aAAc,SAAQ,KAAK;IAKtB,SAAS,CAAqB;IAE9B,YAAY,CAAU;IAKtB,eAAe,CAAqB;IAEpC,UAAU,CAAS;IAEnC,YACE,OAAe,EACf,UAAkB,EAClB,YAAqB,EACrB,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF","sourcesContent":["/**\n * Shape of a standard Stedi API error response body.\n *\n * The machine-readable code appears as `error` (per the docs) or `code`\n * (observed on some endpoints like enrollments). `message` is always\n * human-readable. When multiple issues are reported the `errors` array\n * is present, but `error`/`code` and `message` are at the top level.\n */\nexport type StediErrorBody = {\n code?: string;\n error?: string;\n errors?: ReadonlyArray<{ error: string; message: string }>;\n message: string;\n};\n\n/**\n * Extract a machine-readable error code from `error` or `code`,\n * whichever is present (preferring `error`).\n */\nconst extractErrorCode = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n\n const record = body as Record<string, unknown>;\n\n if (typeof record.error === 'string') {\n return record.error;\n }\n\n if (typeof record.code === 'string') {\n return record.code;\n }\n\n return undefined;\n};\n\nconst extractResponseMessage = (body: unknown): string | undefined => {\n if (typeof body !== 'object' || body === null) {\n return undefined;\n }\n\n const candidate = (body as Record<string, unknown>).message;\n return typeof candidate === 'string' ? candidate : undefined;\n};\n\nexport class StediApiError extends Error {\n /**\n * Machine-readable error code from the Stedi response, if available.\n * Extracted from the `error` or `code` field of the response body.\n */\n public readonly errorCode: string | undefined;\n\n public readonly responseBody: unknown;\n\n /**\n * The upstream `message` field from the Stedi response body, if present.\n */\n public readonly responseMessage: string | undefined;\n\n public readonly statusCode: number;\n\n constructor(\n message: string,\n statusCode: number,\n responseBody: unknown,\n cause?: unknown,\n ) {\n super(message, { cause });\n this.name = 'StediApiError';\n this.errorCode = extractErrorCode(responseBody);\n this.responseBody = responseBody;\n this.responseMessage = extractResponseMessage(responseBody);\n this.statusCode = statusCode;\n }\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,MAAM,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,MAAM,EACX,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;oBAW3B,CAAC;qBAA2B,CAAC;;;8BAQwW,CAAC;;;CAL1Z,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE/D,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAc,KAAK,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAc,KAAK,kBAAkB,EAAE,KAAK,MAAM,EAAE,MAAM,OAAO,CAAC;AAUhF,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM;wBAcP,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;cAmDlC,CAAC,WACb,MAAM,UACP,MAAM,QACR,MAAM,WACH,kBAAkB,KAC1B,OAAO,CAAC,CAAC,CAAC;CAoDd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type StediErrorBody = {
|
|
2
|
+
code?: string;
|
|
3
|
+
error?: string;
|
|
4
|
+
errors?: ReadonlyArray<{
|
|
5
|
+
error: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class StediApiError extends Error {
|
|
11
|
+
readonly errorCode: string | undefined;
|
|
12
|
+
readonly responseBody: unknown;
|
|
13
|
+
readonly responseMessage: string | undefined;
|
|
14
|
+
readonly statusCode: number;
|
|
15
|
+
constructor(message: string, statusCode: number, responseBody: unknown, cause?: unknown);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAiCF,qBAAa,aAAc,SAAQ,KAAK;IAKtC,SAAgB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,SAAgB,YAAY,EAAE,OAAO,CAAC;IAKtC,SAAgB,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpD,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,EACrB,KAAK,CAAC,EAAE,OAAO;CASlB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Fincura Technologies, Inc.",
|
|
3
3
|
"packageManager": "pnpm@10.11.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"axios": "1.13.
|
|
5
|
+
"axios": "1.13.6"
|
|
6
6
|
},
|
|
7
7
|
"description": "Stedi SDK JS",
|
|
8
8
|
"devDependencies": {
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
},
|
|
44
44
|
"type": "module",
|
|
45
45
|
"types": "dist/types/index.d.ts",
|
|
46
|
-
"version": "1.
|
|
46
|
+
"version": "1.5.0"
|
|
47
47
|
}
|