@innvoid/getmarket-sdk 0.2.5 → 0.2.7
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/{chunk-5S2JP7PR.js → chunk-4KD6646F.js} +12 -1
- package/dist/chunk-4KD6646F.js.map +1 -0
- package/dist/{chunk-HA2XKSTP.js → chunk-PBN2JCRX.js} +232 -28
- package/dist/chunk-PBN2JCRX.js.map +1 -0
- package/dist/clients/index.cjs +230 -25
- package/dist/clients/index.cjs.map +1 -1
- package/dist/clients/index.d.cts +45 -16
- package/dist/clients/index.d.ts +45 -16
- package/dist/clients/index.js +4 -2
- package/dist/core/index.cjs +14 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +6 -2
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.js +5 -3
- package/dist/index.cjs +244 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-5S2JP7PR.js.map +0 -1
- package/dist/chunk-HA2XKSTP.js.map +0 -1
package/dist/core/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts","../../src/core/errors.ts","../../src/core/http.ts","../../src/core/internalHttp.ts"],"sourcesContent":["// sdk/src/core/index.ts\n\nexport * from \"./errors\";\nexport * from \"./http\";\nexport * from \"./internalHttp\";\n","export type ClientErrorCode =\n | \"UPSTREAM_TIMEOUT\"\n | \"UPSTREAM_UNAVAILABLE\"\n | \"UPSTREAM_BAD_RESPONSE\"\n | \"UPSTREAM_NOT_FOUND\"\n | \"UPSTREAM_UNAUTHORIZED\"\n | \"UPSTREAM_FORBIDDEN\"\n | \"UPSTREAM_UNKNOWN\";\n\nexport class UpstreamError extends Error {\n public code: ClientErrorCode;\n public status?: number;\n public details?: any;\n\n constructor(message: string, code: ClientErrorCode, status?: number, details?: any) {\n super(message);\n this.name = \"UpstreamError\";\n this.code = code;\n this.status = status;\n this.details = details;\n }\n}\n\nexport function mapAxiosToUpstreamError(err: any, svc: string): UpstreamError {\n const status = err?.response?.status;\n const data = err?.response?.data;\n const isTimeout = err?.code === \"ECONNABORTED\" || String(err?.message || \"\").includes(\"timeout\");\n\n if (isTimeout) {\n return new UpstreamError(`[${svc}] timeout`, \"UPSTREAM_TIMEOUT\", 504, {cause: err?.message});\n }\n if (!err?.response) {\n return new UpstreamError(`[${svc}] unavailable`, \"UPSTREAM_UNAVAILABLE\", 503, {cause: err?.message});\n }\n if (status === 404) return new UpstreamError(`[${svc}] not found`, \"UPSTREAM_NOT_FOUND\", 404, data);\n if (status === 401) return new UpstreamError(`[${svc}] unauthorized`, \"UPSTREAM_UNAUTHORIZED\", 401, data);\n if (status === 403) return new UpstreamError(`[${svc}] forbidden`, \"UPSTREAM_FORBIDDEN\", 403, data);\n if (status >= 400 && status < 600) {\n return new UpstreamError(`[${svc}] bad response`, \"UPSTREAM_BAD_RESPONSE\", status, data);\n }\n return new UpstreamError(`[${svc}] unknown error`, \"UPSTREAM_UNKNOWN\", status, data);\n}\n","// sdk/src/core/http.ts\nimport axios, {AxiosInstance, AxiosRequestConfig} from \"axios\";\n\nexport type HttpClient = AxiosInstance;\n\nexport type HttpClientOpts = {\n baseURL: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n};\n\nexport function createHttpClient(opts: HttpClientOpts): HttpClient {\n return axios.create({\n baseURL: opts.baseURL.replace(/\\/+$/, \"\"),\n timeout: opts.timeoutMs ?? 8000,\n headers: opts.headers ?? {},\n } satisfies AxiosRequestConfig);\n}\n","// clients/internalHttp.ts\n\ntype RetryPolicy = {\n retries: number;\n baseDelayMs: number;\n retryOnStatuses: number[];\n retryOnNetworkErrors: boolean;\n};\n\ntype InternalHttpOptions = {\n baseUrl: string;\n apiKey?: string; // x-internal-api-key\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n};\n\nconst DEFAULT_RETRY: RetryPolicy = {\n retries: 1,\n baseDelayMs: 150,\n retryOnStatuses: [429, 502, 503, 504],\n retryOnNetworkErrors: true,\n};\n\nfunction sleep(ms: number) {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction safeJsonStringify(v: any) {\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\nfunction toHeaders(init?: HeadersInit): Headers {\n return new Headers(init || {});\n}\n\nfunction isJsonContentType(contentType: string | null): boolean {\n if (!contentType) return false;\n const ct = contentType.toLowerCase();\n return ct.includes(\"application/json\") || ct.includes(\"+json\");\n}\n\nfunction isAbortError(e: any): boolean {\n return e?.name === \"AbortError\";\n}\n\nfunction withJitter(ms: number): number {\n // jitter +-20%\n const jitter = ms * 0.2;\n const delta = (Math.random() * 2 - 1) * jitter;\n return Math.max(0, Math.floor(ms + delta));\n}\n\nexport class InternalHttp {\n private readonly baseUrl: string;\n private readonly apiKey: string | undefined;\n private readonly timeoutMs: number;\n private retry: RetryPolicy;\n\n constructor(opts: InternalHttpOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/+$/, \"\");\n this.apiKey = opts.apiKey;\n\n // ✅ Default más seguro para internas (evita cascadas)\n this.timeoutMs = opts.timeoutMs ?? 4000;\n\n this.retry = {...DEFAULT_RETRY, ...(opts.retry || {})};\n }\n\n async request<T>(\n path: string,\n init: RequestInit & {\n requestId?: string;\n idempotencyKey?: string;\n headers?: HeadersInit;\n } = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n\n const baseHeaders = toHeaders(init.headers);\n\n if (!baseHeaders.has(\"Content-Type\")) baseHeaders.set(\"Content-Type\", \"application/json\");\n if (this.apiKey) baseHeaders.set(\"x-internal-api-key\", this.apiKey);\n\n if (init.requestId) baseHeaders.set(\"x-request-id\", init.requestId);\n if (init.idempotencyKey) baseHeaders.set(\"Idempotency-Key\", init.idempotencyKey);\n\n const {headers: _ignored, ...restInit} = init;\n\n const doFetchOnce = async () => {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n\n try {\n const res = await fetch(url, {\n ...restInit,\n headers: baseHeaders,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n const err: any = new Error(\n `HTTP ${res.status} ${res.statusText}${text ? ` - ${text}` : \"\"}`\n );\n err.status = res.status;\n err.body = text;\n throw err;\n }\n\n if (res.status === 204) return undefined as unknown as T;\n\n const contentType = res.headers.get(\"content-type\");\n if (isJsonContentType(contentType)) {\n return (await res.json()) as T;\n }\n\n const text = await res.text().catch(() => \"\");\n return text as unknown as T;\n } finally {\n clearTimeout(timeout);\n }\n };\n\n let attempt = 0;\n\n while (true) {\n try {\n return await doFetchOnce();\n } catch (e: any) {\n attempt++;\n\n const status = e?.status;\n const retryableStatus = !!status && this.retry.retryOnStatuses.includes(status);\n\n const retryableNetwork =\n this.retry.retryOnNetworkErrors &&\n (isAbortError(e) || !status); // sin status suele ser red/dns/timeout\n\n const isRetryable = retryableStatus || retryableNetwork;\n\n if (!isRetryable || attempt > this.retry.retries) {\n console.error(\n `[InternalHttp] request failed: ${url} attempt=${attempt} status=${status ?? \"n/a\"} err=${e?.message\n } body=${safeJsonStringify(e?.body)}`\n );\n throw e;\n }\n\n const backoff = withJitter(this.retry.baseDelayMs * attempt);\n await sleep(backoff);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YAAY,SAAiB,MAAuB,QAAiB,SAAe;AAChF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACnB;AACJ;AAEO,SAAS,wBAAwB,KAAU,KAA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AAc,mBAAmB;AAEvC,YAAI,CAAC,eAAe,UAAU,KAAK,MAAM,SAAS;AAC9C,kBAAQ;AAAA,YACJ,kCAAkC,GAAG,YAAY,OAAO,WAAW,UAAU,KAAK,QAAQ,GAAG,OAC7F,SAAS,kBAAkB,GAAG,IAAI,CAAC;AAAA,UACvC;AACA,gBAAM;AAAA,QACV;AAEA,cAAM,UAAU,WAAW,KAAK,MAAM,cAAc,OAAO;AAC3D,cAAM,MAAM,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["axios","text"]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts","../../src/core/errors.ts","../../src/core/http.ts","../../src/core/internalHttp.ts"],"sourcesContent":["// sdk/src/core/index.ts\n\nexport * from \"./errors\";\nexport * from \"./http\";\nexport * from \"./internalHttp\";\n","export type ClientErrorCode =\n | \"UPSTREAM_TIMEOUT\"\n | \"UPSTREAM_UNAVAILABLE\"\n | \"UPSTREAM_BAD_RESPONSE\"\n | \"UPSTREAM_NOT_FOUND\"\n | \"UPSTREAM_UNAUTHORIZED\"\n | \"UPSTREAM_FORBIDDEN\"\n | \"UPSTREAM_UNKNOWN\";\n\nexport class UpstreamError extends Error {\n public code: ClientErrorCode;\n public status?: number;\n public details?: any;\n\n constructor(message: string, code: ClientErrorCode, status?: number, details?: any) {\n super(message);\n this.name = \"UpstreamError\";\n this.code = code;\n this.status = status;\n this.details = details;\n }\n}\n\nexport function mapAxiosToUpstreamError(err: any, svc: string): UpstreamError {\n const status = err?.response?.status;\n const data = err?.response?.data;\n const isTimeout = err?.code === \"ECONNABORTED\" || String(err?.message || \"\").includes(\"timeout\");\n\n if (isTimeout) {\n return new UpstreamError(`[${svc}] timeout`, \"UPSTREAM_TIMEOUT\", 504, {cause: err?.message});\n }\n if (!err?.response) {\n return new UpstreamError(`[${svc}] unavailable`, \"UPSTREAM_UNAVAILABLE\", 503, {cause: err?.message});\n }\n if (status === 404) return new UpstreamError(`[${svc}] not found`, \"UPSTREAM_NOT_FOUND\", 404, data);\n if (status === 401) return new UpstreamError(`[${svc}] unauthorized`, \"UPSTREAM_UNAUTHORIZED\", 401, data);\n if (status === 403) return new UpstreamError(`[${svc}] forbidden`, \"UPSTREAM_FORBIDDEN\", 403, data);\n if (status >= 400 && status < 600) {\n return new UpstreamError(`[${svc}] bad response`, \"UPSTREAM_BAD_RESPONSE\", status, data);\n }\n return new UpstreamError(`[${svc}] unknown error`, \"UPSTREAM_UNKNOWN\", status, data);\n}\n","import axios, {AxiosInstance, AxiosRequestConfig} from \"axios\";\n\nexport type HttpClient = AxiosInstance;\n\nexport type HttpClientOpts = {\n baseURL: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n};\n\nexport function createHttpClient(opts: HttpClientOpts): HttpClient {\n return axios.create({\n baseURL: opts.baseURL.replace(/\\/+$/, \"\"),\n timeout: opts.timeoutMs ?? 8000,\n headers: opts.headers ?? {},\n } satisfies AxiosRequestConfig);\n}\n\n/**\n * Injects x-request-id into an Axios config while preserving existing headers.\n */\nexport function withRequestIdConfig<T extends AxiosRequestConfig = AxiosRequestConfig>(\n config: T = {} as T,\n requestId?: string\n): T {\n if (!requestId) return config;\n\n return {\n ...config,\n headers: {\n ...(config.headers ?? {}),\n \"x-request-id\": requestId,\n },\n } as T;\n}\n","// clients/internalHttp.ts\n\ntype RetryPolicy = {\n retries: number;\n baseDelayMs: number;\n retryOnStatuses: number[];\n retryOnNetworkErrors: boolean;\n};\n\ntype InternalHttpOptions = {\n baseUrl: string;\n apiKey?: string; // x-internal-api-key\n timeoutMs?: number;\n retry?: Partial<RetryPolicy>;\n};\n\nconst DEFAULT_RETRY: RetryPolicy = {\n retries: 1,\n baseDelayMs: 150,\n retryOnStatuses: [429, 502, 503, 504],\n retryOnNetworkErrors: true,\n};\n\nfunction sleep(ms: number) {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction safeJsonStringify(v: any) {\n try {\n return JSON.stringify(v);\n } catch {\n return String(v);\n }\n}\n\nfunction toHeaders(init?: HeadersInit): Headers {\n return new Headers(init || {});\n}\n\nfunction isJsonContentType(contentType: string | null): boolean {\n if (!contentType) return false;\n const ct = contentType.toLowerCase();\n return ct.includes(\"application/json\") || ct.includes(\"+json\");\n}\n\nfunction isAbortError(e: any): boolean {\n return e?.name === \"AbortError\";\n}\n\nfunction withJitter(ms: number): number {\n // jitter +-20%\n const jitter = ms * 0.2;\n const delta = (Math.random() * 2 - 1) * jitter;\n return Math.max(0, Math.floor(ms + delta));\n}\n\nexport class InternalHttp {\n private readonly baseUrl: string;\n private readonly apiKey: string | undefined;\n private readonly timeoutMs: number;\n private retry: RetryPolicy;\n\n constructor(opts: InternalHttpOptions) {\n this.baseUrl = opts.baseUrl.replace(/\\/+$/, \"\");\n this.apiKey = opts.apiKey;\n\n // ✅ Default más seguro para internas (evita cascadas)\n this.timeoutMs = opts.timeoutMs ?? 4000;\n\n this.retry = {...DEFAULT_RETRY, ...(opts.retry || {})};\n }\n\n async request<T>(\n path: string,\n init: RequestInit & {\n requestId?: string;\n idempotencyKey?: string;\n headers?: HeadersInit;\n } = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${path.startsWith(\"/\") ? \"\" : \"/\"}${path}`;\n\n const baseHeaders = toHeaders(init.headers);\n\n if (!baseHeaders.has(\"Content-Type\")) baseHeaders.set(\"Content-Type\", \"application/json\");\n if (this.apiKey) baseHeaders.set(\"x-internal-api-key\", this.apiKey);\n\n if (init.requestId) baseHeaders.set(\"x-request-id\", init.requestId);\n if (init.idempotencyKey) baseHeaders.set(\"Idempotency-Key\", init.idempotencyKey);\n\n const {headers: _ignored, ...restInit} = init;\n\n const doFetchOnce = async () => {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), this.timeoutMs);\n\n try {\n const res = await fetch(url, {\n ...restInit,\n headers: baseHeaders,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n const text = await res.text().catch(() => \"\");\n const err: any = new Error(\n `HTTP ${res.status} ${res.statusText}${text ? ` - ${text}` : \"\"}`\n );\n err.status = res.status;\n err.body = text;\n throw err;\n }\n\n if (res.status === 204) return undefined as unknown as T;\n\n const contentType = res.headers.get(\"content-type\");\n if (isJsonContentType(contentType)) {\n return (await res.json()) as T;\n }\n\n const text = await res.text().catch(() => \"\");\n return text as unknown as T;\n } finally {\n clearTimeout(timeout);\n }\n };\n\n let attempt = 0;\n\n while (true) {\n try {\n return await doFetchOnce();\n } catch (e: any) {\n attempt++;\n\n const status = e?.status;\n const retryableStatus = !!status && this.retry.retryOnStatuses.includes(status);\n\n const retryableNetwork =\n this.retry.retryOnNetworkErrors &&\n (isAbortError(e) || !status); // sin status suele ser red/dns/timeout\n\n const isRetryable = retryableStatus || retryableNetwork;\n\n if (!isRetryable || attempt > this.retry.retries) {\n console.error(\n `[InternalHttp] request failed: ${url} attempt=${attempt} status=${status ?? \"n/a\"} err=${e?.message\n } body=${safeJsonStringify(e?.body)}`\n );\n throw e;\n }\n\n const backoff = withJitter(this.retry.baseDelayMs * attempt);\n await sleep(backoff);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YAAY,SAAiB,MAAuB,QAAiB,SAAe;AAChF,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACnB;AACJ;AAEO,SAAS,wBAAwB,KAAU,KAA4B;AAC1E,QAAM,SAAS,KAAK,UAAU;AAC9B,QAAM,OAAO,KAAK,UAAU;AAC5B,QAAM,YAAY,KAAK,SAAS,kBAAkB,OAAO,KAAK,WAAW,EAAE,EAAE,SAAS,SAAS;AAE/F,MAAI,WAAW;AACX,WAAO,IAAI,cAAc,IAAI,GAAG,aAAa,oBAAoB,KAAK,EAAC,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C,eAAe,UAAU,KAAK,MAAM,SAAS;AAC9C,kBAAQ;AAAA,YACJ,kCAAkC,GAAG,YAAY,OAAO,WAAW,UAAU,KAAK,QAAQ,GAAG,OAC7F,SAAS,kBAAkB,GAAG,IAAI,CAAC;AAAA,UACvC;AACA,gBAAM;AAAA,QACV;AAEA,cAAM,UAAU,WAAW,KAAK,MAAM,cAAc,OAAO;AAC3D,cAAM,MAAM,OAAO;AAAA,MACvB;AAAA,IACJ;AAAA,EACJ;AACJ;","names":["axios","text"]}
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
2
|
|
|
3
3
|
type ClientErrorCode = "UPSTREAM_TIMEOUT" | "UPSTREAM_UNAVAILABLE" | "UPSTREAM_BAD_RESPONSE" | "UPSTREAM_NOT_FOUND" | "UPSTREAM_UNAUTHORIZED" | "UPSTREAM_FORBIDDEN" | "UPSTREAM_UNKNOWN";
|
|
4
4
|
declare class UpstreamError extends Error {
|
|
@@ -16,6 +16,10 @@ type HttpClientOpts = {
|
|
|
16
16
|
headers?: Record<string, string>;
|
|
17
17
|
};
|
|
18
18
|
declare function createHttpClient(opts: HttpClientOpts): HttpClient;
|
|
19
|
+
/**
|
|
20
|
+
* Injects x-request-id into an Axios config while preserving existing headers.
|
|
21
|
+
*/
|
|
22
|
+
declare function withRequestIdConfig<T extends AxiosRequestConfig = AxiosRequestConfig>(config?: T, requestId?: string): T;
|
|
19
23
|
|
|
20
24
|
type RetryPolicy = {
|
|
21
25
|
retries: number;
|
|
@@ -42,4 +46,4 @@ declare class InternalHttp {
|
|
|
42
46
|
}): Promise<T>;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
export { type ClientErrorCode, type HttpClient, type HttpClientOpts, InternalHttp, UpstreamError, createHttpClient, mapAxiosToUpstreamError };
|
|
49
|
+
export { type ClientErrorCode, type HttpClient, type HttpClientOpts, InternalHttp, UpstreamError, createHttpClient, mapAxiosToUpstreamError, withRequestIdConfig };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
2
|
|
|
3
3
|
type ClientErrorCode = "UPSTREAM_TIMEOUT" | "UPSTREAM_UNAVAILABLE" | "UPSTREAM_BAD_RESPONSE" | "UPSTREAM_NOT_FOUND" | "UPSTREAM_UNAUTHORIZED" | "UPSTREAM_FORBIDDEN" | "UPSTREAM_UNKNOWN";
|
|
4
4
|
declare class UpstreamError extends Error {
|
|
@@ -16,6 +16,10 @@ type HttpClientOpts = {
|
|
|
16
16
|
headers?: Record<string, string>;
|
|
17
17
|
};
|
|
18
18
|
declare function createHttpClient(opts: HttpClientOpts): HttpClient;
|
|
19
|
+
/**
|
|
20
|
+
* Injects x-request-id into an Axios config while preserving existing headers.
|
|
21
|
+
*/
|
|
22
|
+
declare function withRequestIdConfig<T extends AxiosRequestConfig = AxiosRequestConfig>(config?: T, requestId?: string): T;
|
|
19
23
|
|
|
20
24
|
type RetryPolicy = {
|
|
21
25
|
retries: number;
|
|
@@ -42,4 +46,4 @@ declare class InternalHttp {
|
|
|
42
46
|
}): Promise<T>;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
|
-
export { type ClientErrorCode, type HttpClient, type HttpClientOpts, InternalHttp, UpstreamError, createHttpClient, mapAxiosToUpstreamError };
|
|
49
|
+
export { type ClientErrorCode, type HttpClient, type HttpClientOpts, InternalHttp, UpstreamError, createHttpClient, mapAxiosToUpstreamError, withRequestIdConfig };
|
package/dist/core/index.js
CHANGED
|
@@ -2,12 +2,14 @@ import {
|
|
|
2
2
|
InternalHttp,
|
|
3
3
|
UpstreamError,
|
|
4
4
|
createHttpClient,
|
|
5
|
-
mapAxiosToUpstreamError
|
|
6
|
-
|
|
5
|
+
mapAxiosToUpstreamError,
|
|
6
|
+
withRequestIdConfig
|
|
7
|
+
} from "../chunk-4KD6646F.js";
|
|
7
8
|
export {
|
|
8
9
|
InternalHttp,
|
|
9
10
|
UpstreamError,
|
|
10
11
|
createHttpClient,
|
|
11
|
-
mapAxiosToUpstreamError
|
|
12
|
+
mapAxiosToUpstreamError,
|
|
13
|
+
withRequestIdConfig
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -60,6 +60,7 @@ __export(src_exports, {
|
|
|
60
60
|
createMdClient: () => createMdClient,
|
|
61
61
|
createMediaClient: () => createMediaClient,
|
|
62
62
|
createMkpClient: () => createMkpClient,
|
|
63
|
+
createPayClient: () => createPayClient,
|
|
63
64
|
createPlatformClient: () => createPlatformClient,
|
|
64
65
|
createResClient: () => createResClient,
|
|
65
66
|
getOrSet: () => getOrSet,
|
|
@@ -81,7 +82,8 @@ __export(src_exports, {
|
|
|
81
82
|
requireRolesOrAnyPermission: () => requireRolesOrAnyPermission,
|
|
82
83
|
sendError: () => sendError,
|
|
83
84
|
sendOk: () => sendOk,
|
|
84
|
-
verifyBackendJwtRS256: () => verifyBackendJwtRS256
|
|
85
|
+
verifyBackendJwtRS256: () => verifyBackendJwtRS256,
|
|
86
|
+
withRequestIdConfig: () => withRequestIdConfig
|
|
85
87
|
});
|
|
86
88
|
module.exports = __toCommonJS(src_exports);
|
|
87
89
|
|
|
@@ -413,6 +415,16 @@ function createHttpClient(opts) {
|
|
|
413
415
|
headers: opts.headers ?? {}
|
|
414
416
|
});
|
|
415
417
|
}
|
|
418
|
+
function withRequestIdConfig(config = {}, requestId2) {
|
|
419
|
+
if (!requestId2) return config;
|
|
420
|
+
return {
|
|
421
|
+
...config,
|
|
422
|
+
headers: {
|
|
423
|
+
...config.headers ?? {},
|
|
424
|
+
"x-request-id": requestId2
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
416
428
|
|
|
417
429
|
// src/core/internalHttp.ts
|
|
418
430
|
var DEFAULT_RETRY = {
|
|
@@ -1480,8 +1492,43 @@ function createResClient() {
|
|
|
1480
1492
|
apiPrefix: env.apiPrefix,
|
|
1481
1493
|
path: "/refs/varieties"
|
|
1482
1494
|
});
|
|
1495
|
+
const resources = createBulkRefsClient({
|
|
1496
|
+
namespace: "res:resource",
|
|
1497
|
+
baseURL: env.baseURL,
|
|
1498
|
+
apiPrefix: env.apiPrefix,
|
|
1499
|
+
path: "/refs/resources"
|
|
1500
|
+
});
|
|
1501
|
+
const categories = createBulkRefsClient({
|
|
1502
|
+
namespace: "res:category",
|
|
1503
|
+
baseURL: env.baseURL,
|
|
1504
|
+
apiPrefix: env.apiPrefix,
|
|
1505
|
+
path: "/refs/categories"
|
|
1506
|
+
});
|
|
1507
|
+
const attributes = createBulkRefsClient({
|
|
1508
|
+
namespace: "res:attribute",
|
|
1509
|
+
baseURL: env.baseURL,
|
|
1510
|
+
apiPrefix: env.apiPrefix,
|
|
1511
|
+
path: "/refs/attributes"
|
|
1512
|
+
});
|
|
1513
|
+
const attributeOptions = createBulkRefsClient({
|
|
1514
|
+
namespace: "res:attribute_option",
|
|
1515
|
+
baseURL: env.baseURL,
|
|
1516
|
+
apiPrefix: env.apiPrefix,
|
|
1517
|
+
path: "/refs/attribute-options"
|
|
1518
|
+
});
|
|
1519
|
+
const attributeValues = createBulkRefsClient({
|
|
1520
|
+
namespace: "res:attribute_value",
|
|
1521
|
+
baseURL: env.baseURL,
|
|
1522
|
+
apiPrefix: env.apiPrefix,
|
|
1523
|
+
path: "/refs/attribute-values"
|
|
1524
|
+
});
|
|
1483
1525
|
return {
|
|
1484
|
-
varietiesRefs: (uids, opts) => varieties.bulkRefs(uids, opts)
|
|
1526
|
+
varietiesRefs: (uids, opts) => varieties.bulkRefs(uids, opts),
|
|
1527
|
+
resourcesRefs: (uids, opts) => resources.bulkRefs(uids, opts),
|
|
1528
|
+
categoriesRefs: (uids, opts) => categories.bulkRefs(uids, opts),
|
|
1529
|
+
attributesRefs: (uids, opts) => attributes.bulkRefs(uids, opts),
|
|
1530
|
+
attributeOptionsRefs: (uids, opts) => attributeOptions.bulkRefs(uids, opts),
|
|
1531
|
+
attributeValuesRefs: (uids, opts) => attributeValues.bulkRefs(uids, opts)
|
|
1485
1532
|
};
|
|
1486
1533
|
}
|
|
1487
1534
|
|
|
@@ -1506,10 +1553,31 @@ function createMdClient() {
|
|
|
1506
1553
|
apiPrefix: env.apiPrefix,
|
|
1507
1554
|
path: "/refs/countries"
|
|
1508
1555
|
});
|
|
1556
|
+
const currencies = createBulkRefsClient({
|
|
1557
|
+
namespace: "md:currency",
|
|
1558
|
+
baseURL: env.baseURL,
|
|
1559
|
+
apiPrefix: env.apiPrefix,
|
|
1560
|
+
path: "/refs/currencies"
|
|
1561
|
+
});
|
|
1562
|
+
const regions = createBulkRefsClient({
|
|
1563
|
+
namespace: "md:region",
|
|
1564
|
+
baseURL: env.baseURL,
|
|
1565
|
+
apiPrefix: env.apiPrefix,
|
|
1566
|
+
path: "/refs/regions"
|
|
1567
|
+
});
|
|
1568
|
+
const communes = createBulkRefsClient({
|
|
1569
|
+
namespace: "md:commune",
|
|
1570
|
+
baseURL: env.baseURL,
|
|
1571
|
+
apiPrefix: env.apiPrefix,
|
|
1572
|
+
path: "/refs/communes"
|
|
1573
|
+
});
|
|
1509
1574
|
return {
|
|
1510
1575
|
measuresRefs: (uids, opts) => measures.bulkRefs(uids, opts),
|
|
1511
1576
|
measureTypesRefs: (uids, opts) => measureTypes.bulkRefs(uids, opts),
|
|
1512
|
-
countriesRefs: (uids, opts) => countries.bulkRefs(uids, opts)
|
|
1577
|
+
countriesRefs: (uids, opts) => countries.bulkRefs(uids, opts),
|
|
1578
|
+
currenciesRefs: (uids, opts) => currencies.bulkRefs(uids, opts),
|
|
1579
|
+
regionsRefs: (uids, opts) => regions.bulkRefs(uids, opts),
|
|
1580
|
+
communesRefs: (uids, opts) => communes.bulkRefs(uids, opts)
|
|
1513
1581
|
};
|
|
1514
1582
|
}
|
|
1515
1583
|
|
|
@@ -1520,11 +1588,11 @@ function createFisClient() {
|
|
|
1520
1588
|
baseURL: `${env.baseURL}${env.apiPrefix}`,
|
|
1521
1589
|
timeoutMs: 8e3
|
|
1522
1590
|
});
|
|
1523
|
-
const
|
|
1524
|
-
namespace: "fis:
|
|
1591
|
+
const profiles = createBulkRefsClient({
|
|
1592
|
+
namespace: "fis:profile",
|
|
1525
1593
|
baseURL: env.baseURL,
|
|
1526
1594
|
apiPrefix: env.apiPrefix,
|
|
1527
|
-
path: "/refs/
|
|
1595
|
+
path: "/refs/profiles"
|
|
1528
1596
|
});
|
|
1529
1597
|
const documents = createBulkRefsClient({
|
|
1530
1598
|
namespace: "fis:document",
|
|
@@ -1532,77 +1600,113 @@ function createFisClient() {
|
|
|
1532
1600
|
apiPrefix: env.apiPrefix,
|
|
1533
1601
|
path: "/refs/documents"
|
|
1534
1602
|
});
|
|
1603
|
+
const snapshots = createBulkRefsClient({
|
|
1604
|
+
namespace: "fis:snapshot",
|
|
1605
|
+
baseURL: env.baseURL,
|
|
1606
|
+
apiPrefix: env.apiPrefix,
|
|
1607
|
+
path: "/refs/snapshots"
|
|
1608
|
+
});
|
|
1535
1609
|
const submissions = createBulkRefsClient({
|
|
1536
1610
|
namespace: "fis:submission",
|
|
1537
1611
|
baseURL: env.baseURL,
|
|
1538
1612
|
apiPrefix: env.apiPrefix,
|
|
1539
1613
|
path: "/refs/submissions"
|
|
1540
1614
|
});
|
|
1615
|
+
const folioPools = createBulkRefsClient({
|
|
1616
|
+
namespace: "fis:folio_pool",
|
|
1617
|
+
baseURL: env.baseURL,
|
|
1618
|
+
apiPrefix: env.apiPrefix,
|
|
1619
|
+
path: "/refs/folio-pools"
|
|
1620
|
+
});
|
|
1621
|
+
const taxRules = createBulkRefsClient({
|
|
1622
|
+
namespace: "fis:tax_rule",
|
|
1623
|
+
baseURL: env.baseURL,
|
|
1624
|
+
apiPrefix: env.apiPrefix,
|
|
1625
|
+
path: "/refs/tax-rules"
|
|
1626
|
+
});
|
|
1541
1627
|
return {
|
|
1542
1628
|
// -----------------------------------------------------------------------
|
|
1543
1629
|
// Bulk refs
|
|
1544
1630
|
// -----------------------------------------------------------------------
|
|
1545
|
-
|
|
1631
|
+
profilesRefs: (uids, opts) => profiles.bulkRefs(uids, opts),
|
|
1546
1632
|
documentsRefs: (uids, opts) => documents.bulkRefs(uids, opts),
|
|
1633
|
+
snapshotsRefs: (uids, opts) => snapshots.bulkRefs(uids, opts),
|
|
1547
1634
|
submissionsRefs: (uids, opts) => submissions.bulkRefs(uids, opts),
|
|
1635
|
+
folioPoolsRefs: (uids, opts) => folioPools.bulkRefs(uids, opts),
|
|
1636
|
+
taxRulesRefs: (uids, opts) => taxRules.bulkRefs(uids, opts),
|
|
1548
1637
|
// -----------------------------------------------------------------------
|
|
1549
1638
|
// Fiscal calculation / build / lifecycle
|
|
1550
1639
|
// -----------------------------------------------------------------------
|
|
1551
|
-
|
|
1640
|
+
async calculate(body) {
|
|
1552
1641
|
const { data } = await http.post("/calculate", body);
|
|
1553
1642
|
return data;
|
|
1554
1643
|
},
|
|
1555
|
-
|
|
1556
|
-
const { data } = await http.post("/
|
|
1644
|
+
async calculateTaxes(body) {
|
|
1645
|
+
const { data } = await http.post("/tax/calculate", body);
|
|
1557
1646
|
return data;
|
|
1558
1647
|
},
|
|
1559
|
-
|
|
1560
|
-
const { data } = await http.post("/documents
|
|
1648
|
+
async buildDocument(body) {
|
|
1649
|
+
const { data } = await http.post("/documents", body);
|
|
1561
1650
|
return data;
|
|
1562
1651
|
},
|
|
1563
|
-
|
|
1564
|
-
const { data } = await http.post(
|
|
1652
|
+
async signDocument(body) {
|
|
1653
|
+
const { data } = await http.post(
|
|
1654
|
+
`/documents/${body.document_uid}/sign`,
|
|
1655
|
+
body
|
|
1656
|
+
);
|
|
1565
1657
|
return data;
|
|
1566
1658
|
},
|
|
1567
|
-
|
|
1568
|
-
const { data } = await http.post(
|
|
1659
|
+
async submitDocument(body) {
|
|
1660
|
+
const { data } = await http.post(
|
|
1661
|
+
`/documents/${body.document_uid}/submit`,
|
|
1662
|
+
body
|
|
1663
|
+
);
|
|
1664
|
+
return data;
|
|
1665
|
+
},
|
|
1666
|
+
async cancelDocument(body) {
|
|
1667
|
+
const { data } = await http.post(
|
|
1668
|
+
`/documents/${body.document_uid}/cancel`,
|
|
1669
|
+
body
|
|
1670
|
+
);
|
|
1569
1671
|
return data;
|
|
1570
1672
|
},
|
|
1571
1673
|
// -----------------------------------------------------------------------
|
|
1572
1674
|
// Folios / series
|
|
1573
1675
|
// -----------------------------------------------------------------------
|
|
1574
|
-
|
|
1676
|
+
async reserveFolio(body) {
|
|
1575
1677
|
const { data } = await http.post("/folios/reserve", body);
|
|
1576
1678
|
return data;
|
|
1577
1679
|
},
|
|
1578
|
-
|
|
1680
|
+
async consumeFolio(body) {
|
|
1579
1681
|
const { data } = await http.post("/folios/consume", body);
|
|
1580
1682
|
return data;
|
|
1581
1683
|
},
|
|
1582
1684
|
// -----------------------------------------------------------------------
|
|
1583
1685
|
// Queries / detail
|
|
1584
1686
|
// -----------------------------------------------------------------------
|
|
1585
|
-
|
|
1586
|
-
const { data } = await http.
|
|
1687
|
+
async queryDocuments(body) {
|
|
1688
|
+
const { data } = await http.post("/documents/query", body);
|
|
1587
1689
|
return data;
|
|
1588
1690
|
},
|
|
1589
|
-
|
|
1691
|
+
async getDocumentByUid(uid) {
|
|
1590
1692
|
const { data } = await http.get(`/documents/${uid}`);
|
|
1591
1693
|
return data;
|
|
1592
1694
|
},
|
|
1593
|
-
|
|
1695
|
+
async getSnapshotByUid(uid) {
|
|
1594
1696
|
const { data } = await http.get(`/snapshots/${uid}`);
|
|
1595
1697
|
return data;
|
|
1596
1698
|
},
|
|
1597
|
-
|
|
1699
|
+
async getSubmissionByUid(uid) {
|
|
1598
1700
|
const { data } = await http.get(`/submissions/${uid}`);
|
|
1599
1701
|
return data;
|
|
1600
1702
|
},
|
|
1601
|
-
|
|
1602
|
-
const { data } = await http.get(
|
|
1703
|
+
async getStatusEventsByDocumentUid(documentUid) {
|
|
1704
|
+
const { data } = await http.get(
|
|
1705
|
+
`/documents/${documentUid}/status-events`
|
|
1706
|
+
);
|
|
1603
1707
|
return data;
|
|
1604
1708
|
},
|
|
1605
|
-
|
|
1709
|
+
async retrySubmission(body) {
|
|
1606
1710
|
const { data } = await http.post("/submissions/retry", body);
|
|
1607
1711
|
return data;
|
|
1608
1712
|
}
|
|
@@ -1651,6 +1755,117 @@ function createMkpClient() {
|
|
|
1651
1755
|
};
|
|
1652
1756
|
}
|
|
1653
1757
|
|
|
1758
|
+
// src/clients/payClient.ts
|
|
1759
|
+
function createPayClient() {
|
|
1760
|
+
const env = readServiceEnv("PAY", { apiPrefix: "/internal/v1" });
|
|
1761
|
+
const http = createHttpClient({
|
|
1762
|
+
baseURL: `${env.baseURL}${env.apiPrefix}`,
|
|
1763
|
+
timeoutMs: 8e3
|
|
1764
|
+
});
|
|
1765
|
+
const intents = createBulkRefsClient({
|
|
1766
|
+
namespace: "pay:intent",
|
|
1767
|
+
baseURL: env.baseURL,
|
|
1768
|
+
apiPrefix: env.apiPrefix,
|
|
1769
|
+
path: "/refs/intents"
|
|
1770
|
+
});
|
|
1771
|
+
const attempts = createBulkRefsClient({
|
|
1772
|
+
namespace: "pay:attempt",
|
|
1773
|
+
baseURL: env.baseURL,
|
|
1774
|
+
apiPrefix: env.apiPrefix,
|
|
1775
|
+
path: "/refs/attempts"
|
|
1776
|
+
});
|
|
1777
|
+
const transactions = createBulkRefsClient({
|
|
1778
|
+
namespace: "pay:transaction",
|
|
1779
|
+
baseURL: env.baseURL,
|
|
1780
|
+
apiPrefix: env.apiPrefix,
|
|
1781
|
+
path: "/refs/transactions"
|
|
1782
|
+
});
|
|
1783
|
+
const refunds = createBulkRefsClient({
|
|
1784
|
+
namespace: "pay:refund",
|
|
1785
|
+
baseURL: env.baseURL,
|
|
1786
|
+
apiPrefix: env.apiPrefix,
|
|
1787
|
+
path: "/refs/refunds"
|
|
1788
|
+
});
|
|
1789
|
+
const allocations = createBulkRefsClient({
|
|
1790
|
+
namespace: "pay:allocation",
|
|
1791
|
+
baseURL: env.baseURL,
|
|
1792
|
+
apiPrefix: env.apiPrefix,
|
|
1793
|
+
path: "/refs/allocations"
|
|
1794
|
+
});
|
|
1795
|
+
const providerAccounts = createBulkRefsClient({
|
|
1796
|
+
namespace: "pay:provider_account",
|
|
1797
|
+
baseURL: env.baseURL,
|
|
1798
|
+
apiPrefix: env.apiPrefix,
|
|
1799
|
+
path: "/refs/provider-accounts"
|
|
1800
|
+
});
|
|
1801
|
+
const paymentMethods = createBulkRefsClient({
|
|
1802
|
+
namespace: "pay:payment_method",
|
|
1803
|
+
baseURL: env.baseURL,
|
|
1804
|
+
apiPrefix: env.apiPrefix,
|
|
1805
|
+
path: "/refs/payment-methods"
|
|
1806
|
+
});
|
|
1807
|
+
return {
|
|
1808
|
+
// -----------------------------------------------------------------------
|
|
1809
|
+
// Payment intents
|
|
1810
|
+
// -----------------------------------------------------------------------
|
|
1811
|
+
async createIntent(body) {
|
|
1812
|
+
const { data } = await http.post("/payment-intents", body);
|
|
1813
|
+
return data;
|
|
1814
|
+
},
|
|
1815
|
+
async getIntentByUid(uid) {
|
|
1816
|
+
const { data } = await http.get(`/payment-intents/${uid}`);
|
|
1817
|
+
return data;
|
|
1818
|
+
},
|
|
1819
|
+
async confirmIntent(body) {
|
|
1820
|
+
const { data } = await http.post(
|
|
1821
|
+
`/payment-intents/${body.intent_uid}/confirm`,
|
|
1822
|
+
body
|
|
1823
|
+
);
|
|
1824
|
+
return data;
|
|
1825
|
+
},
|
|
1826
|
+
// -----------------------------------------------------------------------
|
|
1827
|
+
// Attempts
|
|
1828
|
+
// -----------------------------------------------------------------------
|
|
1829
|
+
async startAttempt(body) {
|
|
1830
|
+
const { data } = await http.post("/attempts", body);
|
|
1831
|
+
return data;
|
|
1832
|
+
},
|
|
1833
|
+
// -----------------------------------------------------------------------
|
|
1834
|
+
// Methods / availability
|
|
1835
|
+
// -----------------------------------------------------------------------
|
|
1836
|
+
async getAvailableMethods(params) {
|
|
1837
|
+
const { data } = await http.get("/methods/available", {
|
|
1838
|
+
params
|
|
1839
|
+
});
|
|
1840
|
+
return data;
|
|
1841
|
+
},
|
|
1842
|
+
// -----------------------------------------------------------------------
|
|
1843
|
+
// Queries / allocations
|
|
1844
|
+
// -----------------------------------------------------------------------
|
|
1845
|
+
async queryPayments(body) {
|
|
1846
|
+
const { data } = await http.post("/payments/query", body);
|
|
1847
|
+
return data;
|
|
1848
|
+
},
|
|
1849
|
+
async getAllocationsByTarget(body) {
|
|
1850
|
+
const { data } = await http.post(
|
|
1851
|
+
"/allocations/by-target",
|
|
1852
|
+
body
|
|
1853
|
+
);
|
|
1854
|
+
return data;
|
|
1855
|
+
},
|
|
1856
|
+
// -----------------------------------------------------------------------
|
|
1857
|
+
// Bulk refs
|
|
1858
|
+
// -----------------------------------------------------------------------
|
|
1859
|
+
intentsRefs: (uids, opts) => intents.bulkRefs(uids, opts),
|
|
1860
|
+
attemptsRefs: (uids, opts) => attempts.bulkRefs(uids, opts),
|
|
1861
|
+
transactionsRefs: (uids, opts) => transactions.bulkRefs(uids, opts),
|
|
1862
|
+
refundsRefs: (uids, opts) => refunds.bulkRefs(uids, opts),
|
|
1863
|
+
allocationsRefs: (uids, opts) => allocations.bulkRefs(uids, opts),
|
|
1864
|
+
providerAccountsRefs: (uids, opts) => providerAccounts.bulkRefs(uids, opts),
|
|
1865
|
+
paymentMethodsRefs: (uids, opts) => paymentMethods.bulkRefs(uids, opts)
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1654
1869
|
// src/common/ids.ts
|
|
1655
1870
|
var import_uuid = require("uuid");
|
|
1656
1871
|
function newUid() {
|
|
@@ -1694,6 +1909,7 @@ function isUid(value) {
|
|
|
1694
1909
|
createMdClient,
|
|
1695
1910
|
createMediaClient,
|
|
1696
1911
|
createMkpClient,
|
|
1912
|
+
createPayClient,
|
|
1697
1913
|
createPlatformClient,
|
|
1698
1914
|
createResClient,
|
|
1699
1915
|
getOrSet,
|
|
@@ -1715,6 +1931,7 @@ function isUid(value) {
|
|
|
1715
1931
|
requireRolesOrAnyPermission,
|
|
1716
1932
|
sendError,
|
|
1717
1933
|
sendOk,
|
|
1718
|
-
verifyBackendJwtRS256
|
|
1934
|
+
verifyBackendJwtRS256,
|
|
1935
|
+
withRequestIdConfig
|
|
1719
1936
|
});
|
|
1720
1937
|
//# sourceMappingURL=index.cjs.map
|