@innvoid/getmarket-sdk 0.2.1 → 0.2.3
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/cache/index.js +1 -1
- package/dist/{chunk-P2U3MT2E.js → chunk-KXXIMSON.js} +1 -1
- package/dist/{chunk-P2U3MT2E.js.map → chunk-KXXIMSON.js.map} +1 -1
- package/dist/{chunk-IYFWQDHD.js → chunk-QVPPDOXY.js} +2 -1
- package/dist/chunk-R3RR4RLK.js +384 -0
- package/dist/chunk-R3RR4RLK.js.map +1 -0
- package/dist/{chunk-NZDMYJRS.js → chunk-S44JVJZS.js} +2 -2
- package/dist/clients/index.cjs +669 -0
- package/dist/clients/index.cjs.map +1 -0
- package/dist/clients/index.d.cts +69 -0
- package/dist/clients/index.d.ts +69 -0
- package/dist/clients/index.js +21 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/headers/index.cjs.map +1 -1
- package/dist/headers/index.d.cts +3 -16
- package/dist/headers/index.d.ts +3 -16
- package/dist/headers/index.js +1 -1
- package/dist/index.cjs +379 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -2
- package/dist/index.d.ts +51 -2
- package/dist/index.js +30 -8
- package/dist/middlewares/index.cjs +4 -7
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.js +2 -2
- package/dist/parse-C4vk-fmH.d.cts +16 -0
- package/dist/parse-C4vk-fmH.d.ts +16 -0
- package/package.json +11 -3
- /package/dist/{chunk-IYFWQDHD.js.map → chunk-QVPPDOXY.js.map} +0 -0
- /package/dist/{chunk-NZDMYJRS.js.map → chunk-S44JVJZS.js.map} +0 -0
package/dist/cache/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/headers/constants.ts","../src/headers/parse.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/headers/constants.ts","../src/headers/parse.ts"],"sourcesContent":["// packages/sdk/src/constants.ts\nexport const HEADER_REQUEST_ID = \"x-request-id\";\n\nexport const HEADER_COMPANY_UID = \"x-company\";\nexport const HEADER_BRANCH_UID = \"x-branch\";\nexport const HEADER_EMPLOYEE_UID = \"x-employee-uid\";\n\nexport const HEADER_INTERNAL_API_KEY = \"x-internal-api-key\";\nexport const HEADER_AUTHORIZATION = \"authorization\";\n","// packages/sdk/src/parse.ts\nimport {\n HEADER_BRANCH_UID,\n HEADER_COMPANY_UID,\n HEADER_EMPLOYEE_UID,\n HEADER_REQUEST_ID,\n} from \"./constants\";\n\nexport type RequestContext = {\n requestId?: string | null;\n company_uid?: string | null;\n branch_uid?: string | null;\n employee_uid?: string | null;\n};\n\nfunction normalizeHeaderValue(v: unknown): string | null {\n if (typeof v !== \"string\") return null;\n const s = v.trim();\n if (!s) return null;\n\n // ✅ NO-LEGACY: bloquea JSON en headers\n if (s.startsWith(\"{\") || s.startsWith(\"[\") || s.includes('\"')) return null;\n\n // Evitar valores demasiado cortos (basura)\n if (s.length < 6) return null;\n\n return s;\n}\n\n/**\n * Lee header aunque venga en mayúsculas/minúsculas (Express suele bajar a lower-case).\n */\nfunction h(headers: Record<string, any>, key: string): unknown {\n return headers[key] ?? headers[key.toLowerCase()] ?? headers[key.toUpperCase()];\n}\n\n/**\n * ✅ NO-LEGACY:\n * - x-company: <UID>\n * - x-branch: <UID>\n * - x-employee-uid: <UID> (opcional; NO reemplaza JWT)\n * - x-request-id: string (opcional)\n */\nexport function getRequestContextFromHeaders(headers: Record<string, any>): RequestContext {\n return {\n requestId: normalizeHeaderValue(h(headers, HEADER_REQUEST_ID)) ?? null,\n company_uid: normalizeHeaderValue(h(headers, HEADER_COMPANY_UID)) ?? null,\n branch_uid: normalizeHeaderValue(h(headers, HEADER_BRANCH_UID)) ?? null,\n employee_uid: normalizeHeaderValue(h(headers, HEADER_EMPLOYEE_UID)) ?? null,\n };\n}\n"],"mappings":";AACO,IAAM,oBAAoB;AAE1B,IAAM,qBAAqB;AAC3B,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAE5B,IAAM,0BAA0B;AAChC,IAAM,uBAAuB;;;ACOpC,SAAS,qBAAqB,GAA2B;AACrD,MAAI,OAAO,MAAM,SAAU,QAAO;AAClC,QAAM,IAAI,EAAE,KAAK;AACjB,MAAI,CAAC,EAAG,QAAO;AAGf,MAAI,EAAE,WAAW,GAAG,KAAK,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,EAAG,QAAO;AAGtE,MAAI,EAAE,SAAS,EAAG,QAAO;AAEzB,SAAO;AACX;AAKA,SAAS,EAAE,SAA8B,KAAsB;AAC3D,SAAO,QAAQ,GAAG,KAAK,QAAQ,IAAI,YAAY,CAAC,KAAK,QAAQ,IAAI,YAAY,CAAC;AAClF;AASO,SAAS,6BAA6B,SAA8C;AACvF,SAAO;AAAA,IACH,WAAW,qBAAqB,EAAE,SAAS,iBAAiB,CAAC,KAAK;AAAA,IAClE,aAAa,qBAAqB,EAAE,SAAS,kBAAkB,CAAC,KAAK;AAAA,IACrE,YAAY,qBAAqB,EAAE,SAAS,iBAAiB,CAAC,KAAK;AAAA,IACnE,cAAc,qBAAqB,EAAE,SAAS,mBAAmB,CAAC,KAAK;AAAA,EAC3E;AACJ;","names":[]}
|
|
@@ -286,9 +286,10 @@ async function closeCache() {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
export {
|
|
289
|
+
createCacheProvider,
|
|
289
290
|
TwoLevelCache,
|
|
290
291
|
getTwoLevelCache,
|
|
291
292
|
getOrSet,
|
|
292
293
|
closeCache
|
|
293
294
|
};
|
|
294
|
-
//# sourceMappingURL=chunk-
|
|
295
|
+
//# sourceMappingURL=chunk-QVPPDOXY.js.map
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TwoLevelCache,
|
|
3
|
+
createCacheProvider
|
|
4
|
+
} from "./chunk-QVPPDOXY.js";
|
|
5
|
+
import {
|
|
6
|
+
HEADER_BRANCH_UID,
|
|
7
|
+
HEADER_COMPANY_UID,
|
|
8
|
+
HEADER_EMPLOYEE_UID,
|
|
9
|
+
HEADER_INTERNAL_API_KEY,
|
|
10
|
+
HEADER_REQUEST_ID
|
|
11
|
+
} from "./chunk-KXXIMSON.js";
|
|
12
|
+
|
|
13
|
+
// src/clients/env.ts
|
|
14
|
+
function must(v, name) {
|
|
15
|
+
const s = (v || "").trim();
|
|
16
|
+
if (!s) throw new Error(`Missing env var: ${name}`);
|
|
17
|
+
return s;
|
|
18
|
+
}
|
|
19
|
+
function readServiceEnv(prefix, defaults) {
|
|
20
|
+
const baseURL = (process.env[`${prefix}_BASE_URL`] || defaults?.baseURL || "").trim();
|
|
21
|
+
const apiPrefix = (process.env[`${prefix}_API_PREFIX`] || defaults?.apiPrefix || "/internal/v1").trim();
|
|
22
|
+
return {
|
|
23
|
+
baseURL: must(baseURL, `${prefix}_BASE_URL`),
|
|
24
|
+
apiPrefix
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/internalHttpClient.ts
|
|
29
|
+
import fs from "fs";
|
|
30
|
+
var InternalHttpError = class extends Error {
|
|
31
|
+
status;
|
|
32
|
+
code;
|
|
33
|
+
details;
|
|
34
|
+
constructor(status, code, message, details) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.status = status;
|
|
37
|
+
this.code = code;
|
|
38
|
+
this.details = details ?? null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function readSecretFile(path) {
|
|
42
|
+
if (!path) return null;
|
|
43
|
+
try {
|
|
44
|
+
const v = fs.readFileSync(path, "utf8").trim();
|
|
45
|
+
return v.length ? v : null;
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function splitKeys(v) {
|
|
51
|
+
if (!v) return [];
|
|
52
|
+
return v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
53
|
+
}
|
|
54
|
+
function getInternalApiKey(override) {
|
|
55
|
+
if (override && override.trim()) return override.trim();
|
|
56
|
+
const fileKey = readSecretFile(process.env.INTERNAL_API_KEY_FILE);
|
|
57
|
+
const envKey = (process.env.INTERNAL_API_KEY || "").trim();
|
|
58
|
+
const raw = fileKey || envKey;
|
|
59
|
+
const keys = splitKeys(raw);
|
|
60
|
+
return keys[0] || null;
|
|
61
|
+
}
|
|
62
|
+
function normalizeBaseURL(baseURL) {
|
|
63
|
+
const b = (baseURL || "").trim();
|
|
64
|
+
if (!b) throw new Error("InternalHttpClient: baseURL is required");
|
|
65
|
+
return b.replace(/\/+$/g, "");
|
|
66
|
+
}
|
|
67
|
+
function normalizePrefix(prefix) {
|
|
68
|
+
const p = (prefix || "").trim();
|
|
69
|
+
if (!p) return "";
|
|
70
|
+
const withSlash = p.startsWith("/") ? p : `/${p}`;
|
|
71
|
+
return withSlash.replace(/\/+$/g, "");
|
|
72
|
+
}
|
|
73
|
+
function buildQuery(query) {
|
|
74
|
+
if (!query) return "";
|
|
75
|
+
const params = new URLSearchParams();
|
|
76
|
+
for (const [k, v] of Object.entries(query)) {
|
|
77
|
+
if (v === null || v === void 0) continue;
|
|
78
|
+
params.set(k, String(v));
|
|
79
|
+
}
|
|
80
|
+
const s = params.toString();
|
|
81
|
+
return s ? `?${s}` : "";
|
|
82
|
+
}
|
|
83
|
+
function buildInternalHeaders(ctx, extra, idempotencyKey) {
|
|
84
|
+
const h = {
|
|
85
|
+
"Content-Type": "application/json"
|
|
86
|
+
};
|
|
87
|
+
if (ctx?.requestId) h[HEADER_REQUEST_ID] = String(ctx.requestId);
|
|
88
|
+
if (ctx?.company_uid) h[HEADER_COMPANY_UID] = String(ctx.company_uid);
|
|
89
|
+
if (ctx?.branch_uid) h[HEADER_BRANCH_UID] = String(ctx.branch_uid);
|
|
90
|
+
if (ctx?.employee_uid) h[HEADER_EMPLOYEE_UID] = String(ctx.employee_uid);
|
|
91
|
+
if (idempotencyKey && idempotencyKey.trim()) {
|
|
92
|
+
h["Idempotency-Key"] = idempotencyKey.trim();
|
|
93
|
+
}
|
|
94
|
+
for (const [k, v] of Object.entries(extra || {})) {
|
|
95
|
+
if (v === void 0) continue;
|
|
96
|
+
const vv = String(v).trim();
|
|
97
|
+
if (!vv) continue;
|
|
98
|
+
h[k] = vv;
|
|
99
|
+
}
|
|
100
|
+
return h;
|
|
101
|
+
}
|
|
102
|
+
async function sleep(ms) {
|
|
103
|
+
await new Promise((r) => setTimeout(r, ms));
|
|
104
|
+
}
|
|
105
|
+
function shouldRetry(status, err) {
|
|
106
|
+
if (err?.name === "AbortError") return true;
|
|
107
|
+
if (!status) return true;
|
|
108
|
+
if (status >= 500) return true;
|
|
109
|
+
if (status === 429) return true;
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
async function safeReadJson(res) {
|
|
113
|
+
const text = await res.text();
|
|
114
|
+
if (!text) return null;
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(text);
|
|
117
|
+
} catch {
|
|
118
|
+
return { raw: text };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function createInternalHttpClient(opts) {
|
|
122
|
+
const baseURL = normalizeBaseURL(opts.baseURL);
|
|
123
|
+
const apiPrefix = normalizePrefix(opts.apiPrefix);
|
|
124
|
+
const timeoutMs = typeof opts.timeoutMs === "number" ? opts.timeoutMs : 15e3;
|
|
125
|
+
const retries = typeof opts.retries === "number" ? opts.retries : 2;
|
|
126
|
+
const retryDelayMs = typeof opts.retryDelayMs === "number" ? opts.retryDelayMs : 250;
|
|
127
|
+
const apiKey = getInternalApiKey(opts.apiKey ?? null);
|
|
128
|
+
if (!apiKey) {
|
|
129
|
+
throw new Error(
|
|
130
|
+
"InternalHttpClient: INTERNAL_API_KEY or INTERNAL_API_KEY_FILE is required to call internal endpoints."
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
async function request(r) {
|
|
134
|
+
const path = (r.path || "").trim();
|
|
135
|
+
if (!path.startsWith("/")) {
|
|
136
|
+
throw new Error(`InternalHttpClient: path must start with '/': ${path}`);
|
|
137
|
+
}
|
|
138
|
+
const url = `${baseURL}${apiPrefix}${path}${buildQuery(r.query)}`;
|
|
139
|
+
const headers = buildInternalHeaders(r.ctx ?? null, r.headers, r.idempotencyKey ?? null);
|
|
140
|
+
if (apiKey != null) {
|
|
141
|
+
headers[HEADER_INTERNAL_API_KEY] = apiKey;
|
|
142
|
+
}
|
|
143
|
+
const method = r.method;
|
|
144
|
+
const expectJson = r.expectJson !== false;
|
|
145
|
+
const body = method === "GET" || method === "DELETE" ? void 0 : r.body !== void 0 ? JSON.stringify(r.body) : void 0;
|
|
146
|
+
let attempt = 0;
|
|
147
|
+
let lastErr = null;
|
|
148
|
+
while (attempt <= retries) {
|
|
149
|
+
attempt++;
|
|
150
|
+
const ac = new AbortController();
|
|
151
|
+
const to = setTimeout(() => ac.abort(), timeoutMs);
|
|
152
|
+
try {
|
|
153
|
+
const res = await fetch(url, {
|
|
154
|
+
method,
|
|
155
|
+
headers,
|
|
156
|
+
body,
|
|
157
|
+
signal: ac.signal
|
|
158
|
+
});
|
|
159
|
+
clearTimeout(to);
|
|
160
|
+
if (res.ok) {
|
|
161
|
+
if (!expectJson) return void 0;
|
|
162
|
+
const data = await safeReadJson(res);
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
const errBody = await safeReadJson(res);
|
|
166
|
+
const status = res.status;
|
|
167
|
+
if (attempt <= retries && shouldRetry(status, null)) {
|
|
168
|
+
lastErr = new InternalHttpError(
|
|
169
|
+
status,
|
|
170
|
+
"INTERNAL_HTTP_RETRY",
|
|
171
|
+
`Retryable internal HTTP error (${status})`,
|
|
172
|
+
{ url, status, response: errBody, attempt }
|
|
173
|
+
);
|
|
174
|
+
await sleep(retryDelayMs * attempt);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
throw new InternalHttpError(
|
|
178
|
+
status,
|
|
179
|
+
"INTERNAL_HTTP_ERROR",
|
|
180
|
+
`Internal HTTP error (${status})`,
|
|
181
|
+
{ url, status, response: errBody }
|
|
182
|
+
);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
clearTimeout(to);
|
|
185
|
+
if (attempt <= retries && shouldRetry(null, e)) {
|
|
186
|
+
lastErr = e;
|
|
187
|
+
await sleep(retryDelayMs * attempt);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (e instanceof InternalHttpError) throw e;
|
|
191
|
+
throw new InternalHttpError(
|
|
192
|
+
0,
|
|
193
|
+
"INTERNAL_HTTP_NETWORK_ERROR",
|
|
194
|
+
e?.message || "Internal HTTP network error",
|
|
195
|
+
{ url, attempt, error: String(e) }
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
throw lastErr || new InternalHttpError(0, "INTERNAL_HTTP_FAILED", "Internal request failed");
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
request,
|
|
203
|
+
get: (path, o) => request({ ...o || {}, method: "GET", path }),
|
|
204
|
+
post: (path, body, o) => request({ ...o || {}, method: "POST", path, body }),
|
|
205
|
+
put: (path, body, o) => request({ ...o || {}, method: "PUT", path, body }),
|
|
206
|
+
patch: (path, body, o) => request({ ...o || {}, method: "PATCH", path, body }),
|
|
207
|
+
del: (path, o) => request({ ...o || {}, method: "DELETE", path })
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/clients/cacheFactory.ts
|
|
212
|
+
function makeRefsCache(namespace) {
|
|
213
|
+
const l2 = createCacheProvider();
|
|
214
|
+
return new TwoLevelCache(l2, {
|
|
215
|
+
namespace,
|
|
216
|
+
ttlMsL1: 3e4,
|
|
217
|
+
ttlMsL2: 3e5,
|
|
218
|
+
negativeTtlMsL1: 3e4,
|
|
219
|
+
negativeTtlMsL2: 3e4
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// src/clients/bulkRefsClient.ts
|
|
224
|
+
function uniq(arr) {
|
|
225
|
+
return Array.from(new Set(arr.filter(Boolean)));
|
|
226
|
+
}
|
|
227
|
+
function createBulkRefsClient(args) {
|
|
228
|
+
const http = createInternalHttpClient({
|
|
229
|
+
baseURL: args.baseURL,
|
|
230
|
+
apiPrefix: args.apiPrefix
|
|
231
|
+
});
|
|
232
|
+
const cache = makeRefsCache(args.namespace);
|
|
233
|
+
async function bulkRefs(uids, opts) {
|
|
234
|
+
const list = uniq(uids);
|
|
235
|
+
if (list.length === 0) {
|
|
236
|
+
return { ok: true, refs: [], meta: { requested: 0, returned: 0, missing: [] } };
|
|
237
|
+
}
|
|
238
|
+
const hits = [];
|
|
239
|
+
const missing = [];
|
|
240
|
+
for (const uid of list) {
|
|
241
|
+
const v = await cache.get(uid);
|
|
242
|
+
if (v) hits.push(v);
|
|
243
|
+
else missing.push(uid);
|
|
244
|
+
}
|
|
245
|
+
let fetched = [];
|
|
246
|
+
if (missing.length) {
|
|
247
|
+
const resp = await http.post(
|
|
248
|
+
args.path,
|
|
249
|
+
{ uids: missing },
|
|
250
|
+
{
|
|
251
|
+
ctx: opts?.ctx ?? null
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
const refs = resp.refs ?? resp.items ?? [];
|
|
255
|
+
fetched = refs;
|
|
256
|
+
const ttlMsL1 = opts?.ttlMsL1 ?? args.defaultTtlMsL1;
|
|
257
|
+
const ttlMsL2 = opts?.ttlMsL2 ?? args.defaultTtlMsL2;
|
|
258
|
+
for (const ref of refs) {
|
|
259
|
+
const uid = String(ref?.uid || "").trim();
|
|
260
|
+
if (!uid) continue;
|
|
261
|
+
await cache.set(uid, ref, {
|
|
262
|
+
ttlMsL1,
|
|
263
|
+
ttlMsL2
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const all = [...hits, ...fetched];
|
|
268
|
+
const returnedSet = new Set(all.map((r) => String(r?.uid || "")));
|
|
269
|
+
const missingFinal = list.filter((u) => !returnedSet.has(u));
|
|
270
|
+
return {
|
|
271
|
+
ok: true,
|
|
272
|
+
refs: all,
|
|
273
|
+
meta: {
|
|
274
|
+
requested: list.length,
|
|
275
|
+
returned: all.length,
|
|
276
|
+
missing: missingFinal
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return { bulkRefs };
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/clients/platformClient.ts
|
|
284
|
+
function createPlatformClient(env) {
|
|
285
|
+
const http = createInternalHttpClient(env);
|
|
286
|
+
const cache = makeRefsCache("platform:tenant");
|
|
287
|
+
async function resolveTenant(input, ctx) {
|
|
288
|
+
const key = `${input.company_uid}:${input.service}`;
|
|
289
|
+
const cached = await cache.get(key);
|
|
290
|
+
if (cached) return cached;
|
|
291
|
+
const resp = await http.post(
|
|
292
|
+
"/tenants/resolve",
|
|
293
|
+
input,
|
|
294
|
+
{ ctx: ctx ?? null }
|
|
295
|
+
);
|
|
296
|
+
await cache.set(key, resp);
|
|
297
|
+
return resp;
|
|
298
|
+
}
|
|
299
|
+
return { resolveTenant };
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/clients/resClient.ts
|
|
303
|
+
function createResClient() {
|
|
304
|
+
const env = readServiceEnv("RES", { apiPrefix: "/internal/v1" });
|
|
305
|
+
const varieties = createBulkRefsClient({
|
|
306
|
+
namespace: "res:variety",
|
|
307
|
+
baseURL: env.baseURL,
|
|
308
|
+
apiPrefix: env.apiPrefix,
|
|
309
|
+
path: "/refs/varieties"
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
varietiesRefs: (uids, opts) => varieties.bulkRefs(uids, opts)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// src/clients/mdClient.ts
|
|
317
|
+
function createMdClient() {
|
|
318
|
+
const env = readServiceEnv("MD", { apiPrefix: "/internal/v1" });
|
|
319
|
+
const measures = createBulkRefsClient({
|
|
320
|
+
namespace: "md:measure",
|
|
321
|
+
baseURL: env.baseURL,
|
|
322
|
+
apiPrefix: env.apiPrefix,
|
|
323
|
+
path: "/refs/measures"
|
|
324
|
+
});
|
|
325
|
+
const measureTypes = createBulkRefsClient({
|
|
326
|
+
namespace: "md:measure_type",
|
|
327
|
+
baseURL: env.baseURL,
|
|
328
|
+
apiPrefix: env.apiPrefix,
|
|
329
|
+
path: "/refs/measure-types"
|
|
330
|
+
});
|
|
331
|
+
const countries = createBulkRefsClient({
|
|
332
|
+
namespace: "md:country",
|
|
333
|
+
baseURL: env.baseURL,
|
|
334
|
+
apiPrefix: env.apiPrefix,
|
|
335
|
+
path: "/refs/countries"
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
measuresRefs: (uids, opts) => measures.bulkRefs(uids, opts),
|
|
339
|
+
measureTypesRefs: (uids, opts) => measureTypes.bulkRefs(uids, opts),
|
|
340
|
+
countriesRefs: (uids, opts) => countries.bulkRefs(uids, opts)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/clients/fisClient.ts
|
|
345
|
+
function createFisClient() {
|
|
346
|
+
const env = readServiceEnv("FIS", { apiPrefix: "/internal/v1" });
|
|
347
|
+
const taxes = createBulkRefsClient({
|
|
348
|
+
namespace: "fis:tax",
|
|
349
|
+
baseURL: env.baseURL,
|
|
350
|
+
apiPrefix: env.apiPrefix,
|
|
351
|
+
path: "/refs/taxes"
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
taxesRefs: (uids, opts) => taxes.bulkRefs(uids, opts)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/clients/mediaClient.ts
|
|
359
|
+
function createMediaClient() {
|
|
360
|
+
const env = readServiceEnv("MEDIA", { apiPrefix: "/internal/v1" });
|
|
361
|
+
const files = createBulkRefsClient({
|
|
362
|
+
namespace: "media:file",
|
|
363
|
+
baseURL: env.baseURL,
|
|
364
|
+
apiPrefix: env.apiPrefix,
|
|
365
|
+
path: "/refs/files"
|
|
366
|
+
});
|
|
367
|
+
return {
|
|
368
|
+
filesRefs: (uids, opts) => files.bulkRefs(uids, opts)
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export {
|
|
373
|
+
InternalHttpError,
|
|
374
|
+
buildInternalHeaders,
|
|
375
|
+
createInternalHttpClient,
|
|
376
|
+
readServiceEnv,
|
|
377
|
+
createBulkRefsClient,
|
|
378
|
+
createPlatformClient,
|
|
379
|
+
createResClient,
|
|
380
|
+
createMdClient,
|
|
381
|
+
createFisClient,
|
|
382
|
+
createMediaClient
|
|
383
|
+
};
|
|
384
|
+
//# sourceMappingURL=chunk-R3RR4RLK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/clients/env.ts","../src/internalHttpClient.ts","../src/clients/cacheFactory.ts","../src/clients/bulkRefsClient.ts","../src/clients/platformClient.ts","../src/clients/resClient.ts","../src/clients/mdClient.ts","../src/clients/fisClient.ts","../src/clients/mediaClient.ts"],"sourcesContent":["// packages/sdk/src/clients/env.ts\nimport type {ServiceClientEnv} from \"./types\";\n\nfunction must(v: string | undefined, name: string): string {\n const s = (v || \"\").trim();\n if (!s) throw new Error(`Missing env var: ${name}`);\n return s;\n}\n\nexport function readServiceEnv(prefix: string, defaults?: Partial<ServiceClientEnv>): ServiceClientEnv {\n const baseURL = (process.env[`${prefix}_BASE_URL`] || defaults?.baseURL || \"\").trim();\n const apiPrefix = (process.env[`${prefix}_API_PREFIX`] || defaults?.apiPrefix || \"/internal/v1\").trim();\n\n return {\n baseURL: must(baseURL, `${prefix}_BASE_URL`),\n apiPrefix,\n };\n}\n","// packages/sdk/src/internalHttpClient.ts\nimport fs from \"fs\";\nimport {\n HEADER_INTERNAL_API_KEY,\n HEADER_REQUEST_ID,\n HEADER_COMPANY_UID,\n HEADER_BRANCH_UID,\n HEADER_EMPLOYEE_UID\n} from \"./headers\";\nimport type {RequestContext} from \"./headers\";\n\nexport type InternalHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\nexport type InternalHttpClientOptions = {\n baseURL: string; // ej: http://platform:3010\n apiPrefix?: string; // ej: /internal/v1\n timeoutMs?: number; // default 15000\n retries?: number; // default 2\n retryDelayMs?: number; // default 250\n apiKey?: string | null; // override opcional\n};\n\nexport type InternalRequestOptions = {\n method: InternalHttpMethod;\n path: string; // \"/tenants/provision\"\n query?: Record<string, string | number | boolean | null | undefined>;\n body?: any; // JSON\n headers?: Record<string, string | undefined>;\n ctx?: RequestContext | null;\n\n idempotencyKey?: string | null;\n\n expectJson?: boolean; // default true\n};\n\nexport class InternalHttpError extends Error {\n status: number;\n code: string;\n details: any;\n\n constructor(status: number, code: string, message: string, details?: any) {\n super(message);\n this.status = status;\n this.code = code;\n this.details = details ?? null;\n }\n}\n\nfunction readSecretFile(path?: string): string | null {\n if (!path) return null;\n try {\n const v = fs.readFileSync(path, \"utf8\").trim();\n return v.length ? v : null;\n } catch {\n return null;\n }\n}\n\nfunction splitKeys(v?: string | null): string[] {\n if (!v) return [];\n return v.split(\",\").map((s) => s.trim()).filter(Boolean);\n}\n\n/**\n * ✅ MISMA lógica que internalAuth.ts:\n * - INTERNAL_API_KEY_FILE tiene prioridad\n * - fallback a INTERNAL_API_KEY\n * - permite CSV\n *\n * Nota: Para enviar, usamos la primera key disponible.\n */\nfunction getInternalApiKey(override?: string | null): string | null {\n if (override && override.trim()) return override.trim();\n\n const fileKey = readSecretFile(process.env.INTERNAL_API_KEY_FILE);\n const envKey = (process.env.INTERNAL_API_KEY || \"\").trim();\n const raw = fileKey || envKey;\n const keys = splitKeys(raw);\n return keys[0] || null;\n}\n\nfunction normalizeBaseURL(baseURL: string): string {\n const b = (baseURL || \"\").trim();\n if (!b) throw new Error(\"InternalHttpClient: baseURL is required\");\n return b.replace(/\\/+$/g, \"\");\n}\n\nfunction normalizePrefix(prefix?: string): string {\n const p = (prefix || \"\").trim();\n if (!p) return \"\";\n const withSlash = p.startsWith(\"/\") ? p : `/${p}`;\n return withSlash.replace(/\\/+$/g, \"\");\n}\n\nfunction buildQuery(query?: InternalRequestOptions[\"query\"]): string {\n if (!query) return \"\";\n const params = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (v === null || v === undefined) continue;\n params.set(k, String(v));\n }\n const s = params.toString();\n return s ? `?${s}` : \"\";\n}\n\n/**\n * ✅ Propaga contexto estándar (SDK)\n * - x-request-id\n * - x-company\n * - x-branch\n * - x-employee-uid\n */\nexport function buildInternalHeaders(\n ctx?: RequestContext | null,\n extra?: Record<string, string | undefined>,\n idempotencyKey?: string | null\n): Record<string, string> {\n const h: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n\n if (ctx?.requestId) h[HEADER_REQUEST_ID] = String(ctx.requestId);\n if (ctx?.company_uid) h[HEADER_COMPANY_UID] = String(ctx.company_uid);\n if (ctx?.branch_uid) h[HEADER_BRANCH_UID] = String(ctx.branch_uid);\n if (ctx?.employee_uid) h[HEADER_EMPLOYEE_UID] = String(ctx.employee_uid);\n\n if (idempotencyKey && idempotencyKey.trim()) {\n h[\"Idempotency-Key\"] = idempotencyKey.trim();\n }\n\n for (const [k, v] of Object.entries(extra || {})) {\n if (v === undefined) continue;\n const vv = String(v).trim();\n if (!vv) continue;\n h[k] = vv;\n }\n\n return h;\n}\n\nasync function sleep(ms: number) {\n await new Promise((r) => setTimeout(r, ms));\n}\n\nfunction shouldRetry(status: number | null, err: any): boolean {\n if (err?.name === \"AbortError\") return true;\n if (!status) return true;\n if (status >= 500) return true;\n if (status === 429) return true;\n return false;\n}\n\nasync function safeReadJson(res: Response): Promise<any> {\n const text = await res.text();\n if (!text) return null;\n try {\n return JSON.parse(text);\n } catch {\n return {raw: text};\n }\n}\n\n/**\n * Cliente interno universal (fetch)\n */\nexport function createInternalHttpClient(opts: InternalHttpClientOptions) {\n const baseURL = normalizeBaseURL(opts.baseURL);\n const apiPrefix = normalizePrefix(opts.apiPrefix);\n const timeoutMs = typeof opts.timeoutMs === \"number\" ? opts.timeoutMs : 15000;\n const retries = typeof opts.retries === \"number\" ? opts.retries : 2;\n const retryDelayMs = typeof opts.retryDelayMs === \"number\" ? opts.retryDelayMs : 250;\n\n const apiKey = getInternalApiKey(opts.apiKey ?? null);\n if (!apiKey) {\n throw new Error(\n \"InternalHttpClient: INTERNAL_API_KEY or INTERNAL_API_KEY_FILE is required to call internal endpoints.\"\n );\n }\n\n async function request<T = any>(r: InternalRequestOptions): Promise<T> {\n const path = (r.path || \"\").trim();\n if (!path.startsWith(\"/\")) {\n throw new Error(`InternalHttpClient: path must start with '/': ${path}`);\n }\n\n const url = `${baseURL}${apiPrefix}${path}${buildQuery(r.query)}`;\n\n const headers = buildInternalHeaders(r.ctx ?? null, r.headers, r.idempotencyKey ?? null);\n if (apiKey != null) {\n headers[HEADER_INTERNAL_API_KEY] = apiKey;\n }\n\n const method = r.method;\n const expectJson = r.expectJson !== false;\n\n const body =\n method === \"GET\" || method === \"DELETE\"\n ? undefined\n : r.body !== undefined\n ? JSON.stringify(r.body)\n : undefined;\n\n let attempt = 0;\n let lastErr: any = null;\n\n while (attempt <= retries) {\n attempt++;\n\n const ac = new AbortController();\n const to = setTimeout(() => ac.abort(), timeoutMs);\n\n try {\n const res = await fetch(url, {\n method,\n headers,\n body,\n signal: ac.signal,\n });\n\n clearTimeout(to);\n\n if (res.ok) {\n if (!expectJson) return (undefined as any) as T;\n const data = await safeReadJson(res);\n return data as T;\n }\n\n const errBody = await safeReadJson(res);\n const status = res.status;\n\n if (attempt <= retries && shouldRetry(status, null)) {\n lastErr = new InternalHttpError(\n status,\n \"INTERNAL_HTTP_RETRY\",\n `Retryable internal HTTP error (${status})`,\n {url, status, response: errBody, attempt}\n );\n await sleep(retryDelayMs * attempt);\n continue;\n }\n\n throw new InternalHttpError(\n status,\n \"INTERNAL_HTTP_ERROR\",\n `Internal HTTP error (${status})`,\n {url, status, response: errBody}\n );\n } catch (e: any) {\n clearTimeout(to);\n\n if (attempt <= retries && shouldRetry(null, e)) {\n lastErr = e;\n await sleep(retryDelayMs * attempt);\n continue;\n }\n\n if (e instanceof InternalHttpError) throw e;\n\n throw new InternalHttpError(\n 0,\n \"INTERNAL_HTTP_NETWORK_ERROR\",\n e?.message || \"Internal HTTP network error\",\n {url, attempt, error: String(e)}\n );\n }\n }\n\n throw lastErr || new InternalHttpError(0, \"INTERNAL_HTTP_FAILED\", \"Internal request failed\");\n }\n\n return {\n request,\n get: <T = any>(path: string, o?: Omit<InternalRequestOptions, \"method\" | \"path\">) =>\n request<T>({...(o || {}), method: \"GET\", path}),\n post: <T = any>(path: string, body?: any, o?: Omit<InternalRequestOptions, \"method\" | \"path\" | \"body\">) =>\n request<T>({...(o || {}), method: \"POST\", path, body}),\n put: <T = any>(path: string, body?: any, o?: Omit<InternalRequestOptions, \"method\" | \"path\" | \"body\">) =>\n request<T>({...(o || {}), method: \"PUT\", path, body}),\n patch: <T = any>(path: string, body?: any, o?: Omit<InternalRequestOptions, \"method\" | \"path\" | \"body\">) =>\n request<T>({...(o || {}), method: \"PATCH\", path, body}),\n del: <T = any>(path: string, o?: Omit<InternalRequestOptions, \"method\" | \"path\">) =>\n request<T>({...(o || {}), method: \"DELETE\", path}),\n };\n}\n","// packages/sdk/src/clients/cacheFactory.ts\nimport {TwoLevelCache} from \"../cache\";\nimport {createCacheProvider} from \"../cache/cacheProvider\";\n\n/**\n * Crea un TwoLevelCache por \"namespace\" (ej: \"res:variety\")\n * - L1: in-memory (TTL corto)\n * - L2: redis (TTL medio)\n *\n * Nota: createCacheProvider ya aplica REDIS_KEY_PREFIX desde env,\n * y además TwoLevelCache agrega namespace como prefijo lógico.\n */\nexport function makeRefsCache<T>(namespace: string) {\n const l2 = createCacheProvider(); // redis o noop según env\n return new TwoLevelCache<T>(l2, {\n namespace,\n ttlMsL1: 30_000,\n ttlMsL2: 300_000,\n negativeTtlMsL1: 30_000,\n negativeTtlMsL2: 30_000,\n });\n}\n","// packages/sdk/src/clients/bulkRefsClient.ts\nimport type {RequestContext} from \"../headers\";\nimport {createInternalHttpClient} from \"../internalHttpClient\";\nimport type {BulkRefsResponse, BulkUidsRequest, InternalBulkRefsOptions} from \"./types\";\nimport {makeRefsCache} from \"./cacheFactory\";\n\nfunction uniq(arr: string[]) {\n return Array.from(new Set(arr.filter(Boolean)));\n}\n\nexport function createBulkRefsClient<TRef extends { uid: string }>(args: {\n namespace: string; // cache namespace e.g. \"res:variety\"\n baseURL: string;\n apiPrefix: string;\n path: string; // e.g. \"/refs/varieties\"\n defaultTtlMsL1?: number;\n defaultTtlMsL2?: number;\n}) {\n const http = createInternalHttpClient({\n baseURL: args.baseURL,\n apiPrefix: args.apiPrefix,\n });\n\n // ✅ cache tipado\n const cache = makeRefsCache<TRef>(args.namespace);\n\n async function bulkRefs(\n uids: string[],\n opts?: InternalBulkRefsOptions\n ): Promise<BulkRefsResponse<TRef>> {\n const list = uniq(uids);\n if (list.length === 0) {\n return {ok: true, refs: [], meta: {requested: 0, returned: 0, missing: []}};\n }\n\n // 1) cache hits\n const hits: TRef[] = [];\n const missing: string[] = [];\n\n for (const uid of list) {\n const v = await cache.get(uid); // ✅ sin genéricos\n if (v) hits.push(v);\n else missing.push(uid);\n }\n\n // 2) fetch missing\n let fetched: TRef[] = [];\n if (missing.length) {\n const resp = await http.post<BulkRefsResponse<TRef>>(\n args.path,\n {uids: missing} as BulkUidsRequest,\n {\n ctx: (opts?.ctx ?? null) as RequestContext | null,\n }\n );\n\n const refs = (resp.refs ?? resp.items ?? []) as TRef[];\n fetched = refs;\n\n const ttlMsL1 = opts?.ttlMsL1 ?? args.defaultTtlMsL1;\n const ttlMsL2 = opts?.ttlMsL2 ?? args.defaultTtlMsL2;\n\n for (const ref of refs) {\n const uid = String(ref?.uid || \"\").trim();\n if (!uid) continue;\n\n await cache.set(uid, ref, {\n ttlMsL1,\n ttlMsL2,\n });\n }\n }\n\n const all = [...hits, ...fetched];\n\n // missing final (uids requested but not returned)\n const returnedSet = new Set(all.map((r) => String(r?.uid || \"\")));\n const missingFinal = list.filter((u) => !returnedSet.has(u));\n\n return {\n ok: true,\n refs: all,\n meta: {\n requested: list.length,\n returned: all.length,\n missing: missingFinal,\n },\n };\n }\n\n return {bulkRefs};\n}\n","// packages/sdk/src/clients/platformClient.ts\nimport type {PlatformResolveTenantResponse, PlatformServiceCode} from \"@innvoid/getmarket-contracts\";\nimport type {RequestContext} from \"../headers\";\nimport {createInternalHttpClient} from \"../internalHttpClient\";\nimport {makeRefsCache} from \"./cacheFactory\";\n\nexport function createPlatformClient(env: { baseURL: string; apiPrefix: string }) {\n const http = createInternalHttpClient(env);\n\n // ✅ cache tipado\n const cache = makeRefsCache<PlatformResolveTenantResponse>(\"platform:tenant\");\n\n async function resolveTenant(\n input: { company_uid: string; service: PlatformServiceCode },\n ctx?: RequestContext | null\n ) {\n const key = `${input.company_uid}:${input.service}`;\n\n const cached = await cache.get(key); // ✅ sin genéricos\n if (cached) return cached;\n\n const resp = await http.post<PlatformResolveTenantResponse>(\n \"/tenants/resolve\",\n input,\n {ctx: ctx ?? null}\n );\n\n await cache.set(key, resp);\n return resp;\n }\n\n return {resolveTenant};\n}\n","// packages/sdk/src/clients/resClient.ts\nimport type {ResVarietyRef, ResVarietiesRefsResponse} from \"@innvoid/getmarket-contracts\";\nimport {readServiceEnv} from \"./env\";\nimport {createBulkRefsClient} from \"./bulkRefsClient\";\n\nexport function createResClient() {\n const env = readServiceEnv(\"RES\", {apiPrefix: \"/internal/v1\"});\n\n const varieties = createBulkRefsClient<ResVarietyRef>({\n namespace: \"res:variety\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/varieties\",\n });\n\n return {\n varietiesRefs: (uids: string[], opts?: any) => varieties.bulkRefs(uids, opts) as Promise<ResVarietiesRefsResponse>,\n };\n}\n","// packages/sdk/src/clients/mdClient.ts\nimport type {\n MdMeasureRef,\n MdMeasuresRefsResponse,\n MdMeasureTypeRef,\n MdMeasureTypesRefsResponse,\n MdCountryRef,\n MdCountriesRefsResponse,\n} from \"@innvoid/getmarket-contracts\";\n\nimport {readServiceEnv} from \"./env\";\nimport {createBulkRefsClient} from \"./bulkRefsClient\";\n\nexport function createMdClient() {\n const env = readServiceEnv(\"MD\", {apiPrefix: \"/internal/v1\"});\n\n const measures = createBulkRefsClient<MdMeasureRef>({\n namespace: \"md:measure\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/measures\",\n });\n\n const measureTypes = createBulkRefsClient<MdMeasureTypeRef>({\n namespace: \"md:measure_type\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/measure-types\",\n });\n\n const countries = createBulkRefsClient<MdCountryRef>({\n namespace: \"md:country\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/countries\",\n });\n\n return {\n measuresRefs: (uids: string[], opts?: any) => measures.bulkRefs(uids, opts) as Promise<MdMeasuresRefsResponse>,\n measureTypesRefs: (uids: string[], opts?: any) => measureTypes.bulkRefs(uids, opts) as Promise<MdMeasureTypesRefsResponse>,\n countriesRefs: (uids: string[], opts?: any) => countries.bulkRefs(uids, opts) as Promise<MdCountriesRefsResponse>,\n };\n}\n","// packages/sdk/src/clients/fisClient.ts\nimport type {FisTaxRef, FisTaxesRefsResponse} from \"@innvoid/getmarket-contracts\";\nimport {readServiceEnv} from \"./env\";\nimport {createBulkRefsClient} from \"./bulkRefsClient\";\n\nexport function createFisClient() {\n const env = readServiceEnv(\"FIS\", {apiPrefix: \"/internal/v1\"});\n\n const taxes = createBulkRefsClient<FisTaxRef>({\n namespace: \"fis:tax\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/taxes\",\n });\n\n return {\n taxesRefs: (uids: string[], opts?: any) => taxes.bulkRefs(uids, opts) as Promise<FisTaxesRefsResponse>,\n };\n}\n","// packages/sdk/src/clients/mediaClient.ts\nimport type {MediaFileRef, MediaFilesRefsResponse} from \"@innvoid/getmarket-contracts\";\nimport {readServiceEnv} from \"./env\";\nimport {createBulkRefsClient} from \"./bulkRefsClient\";\n\nexport function createMediaClient() {\n const env = readServiceEnv(\"MEDIA\", {apiPrefix: \"/internal/v1\"});\n\n const files = createBulkRefsClient<MediaFileRef>({\n namespace: \"media:file\",\n baseURL: env.baseURL,\n apiPrefix: env.apiPrefix,\n path: \"/refs/files\",\n });\n\n return {\n filesRefs: (uids: string[], opts?: any) =>\n files.bulkRefs(uids, opts) as Promise<MediaFilesRefsResponse>,\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,SAAS,KAAK,GAAuB,MAAsB;AACzD,QAAM,KAAK,KAAK,IAAI,KAAK;AACzB,MAAI,CAAC,EAAG,OAAM,IAAI,MAAM,oBAAoB,IAAI,EAAE;AAClD,SAAO;AACT;AAEO,SAAS,eAAe,QAAgB,UAAwD;AACrG,QAAM,WAAW,QAAQ,IAAI,GAAG,MAAM,WAAW,KAAK,UAAU,WAAW,IAAI,KAAK;AACpF,QAAM,aAAa,QAAQ,IAAI,GAAG,MAAM,aAAa,KAAK,UAAU,aAAa,gBAAgB,KAAK;AAEtG,SAAO;AAAA,IACL,SAAS,KAAK,SAAS,GAAG,MAAM,WAAW;AAAA,IAC3C;AAAA,EACF;AACF;;;AChBA,OAAO,QAAQ;AAkCR,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,QAAgB,MAAc,SAAiB,SAAe;AACxE,UAAM,OAAO;AACb,SAAK,SAAS;AACd,SAAK,OAAO;AACZ,SAAK,UAAU,WAAW;AAAA,EAC5B;AACF;AAEA,SAAS,eAAe,MAA8B;AACpD,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI;AACF,UAAM,IAAI,GAAG,aAAa,MAAM,MAAM,EAAE,KAAK;AAC7C,WAAO,EAAE,SAAS,IAAI;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,UAAU,GAA6B;AAC9C,MAAI,CAAC,EAAG,QAAO,CAAC;AAChB,SAAO,EAAE,MAAM,GAAG,EAAE,IAA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;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HEADER_INTERNAL_API_KEY,
|
|
3
3
|
getRequestContextFromHeaders
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KXXIMSON.js";
|
|
5
5
|
|
|
6
6
|
// src/middlewares/parseHeaders.ts
|
|
7
7
|
function parseHeaders(req, _res, next) {
|
|
@@ -648,4 +648,4 @@ export {
|
|
|
648
648
|
allowSysAdminOrRolesOrAnyPermission,
|
|
649
649
|
allowAuthAdminOrPerm
|
|
650
650
|
};
|
|
651
|
-
//# sourceMappingURL=chunk-
|
|
651
|
+
//# sourceMappingURL=chunk-S44JVJZS.js.map
|