@viu/emporix-sdk 2.18.0 → 2.20.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/CHANGELOG.md +35 -0
- package/dist/availability.cjs.map +1 -1
- package/dist/availability.d.cts +95 -9
- package/dist/availability.d.ts +95 -9
- package/dist/availability.js +1 -1
- package/dist/cart.d.cts +1 -1
- package/dist/cart.d.ts +1 -1
- package/dist/category.cjs +12 -0
- package/dist/category.cjs.map +1 -1
- package/dist/category.d.cts +12 -2
- package/dist/category.d.ts +12 -2
- package/dist/category.js +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/{chunk-K3VQLW3P.js → chunk-IVCCGJN5.js} +2 -2
- package/dist/chunk-IVCCGJN5.js.map +1 -0
- package/dist/{chunk-6XND7SYV.js → chunk-ZNLHLFQM.js} +14 -2
- package/dist/chunk-ZNLHLFQM.js.map +1 -0
- package/dist/companies.d.cts +1 -1
- package/dist/companies.d.ts +1 -1
- package/dist/contacts.d.cts +1 -1
- package/dist/contacts.d.ts +1 -1
- package/dist/{context-DhoFgoKf.d.cts → context-Dawv2AtS.d.cts} +16 -0
- package/dist/{context-DhoFgoKf.d.ts → context-Dawv2AtS.d.ts} +16 -0
- package/dist/customer-groups.d.cts +1 -1
- package/dist/customer-groups.d.ts +1 -1
- package/dist/customer.d.cts +1 -1
- package/dist/customer.d.ts +1 -1
- package/dist/index.cjs +501 -297
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +439 -35
- package/dist/index.d.ts +439 -35
- package/dist/index.js +198 -6
- package/dist/index.js.map +1 -1
- package/dist/locations.d.cts +1 -1
- package/dist/locations.d.ts +1 -1
- package/dist/media.d.cts +17 -2
- package/dist/media.d.ts +17 -2
- package/dist/orders.d.cts +10 -27
- package/dist/orders.d.ts +10 -27
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/price.d.cts +5 -18
- package/dist/price.d.ts +5 -18
- package/dist/product.d.cts +7 -1
- package/dist/product.d.ts +7 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-6XND7SYV.js.map +0 -1
- package/dist/chunk-K3VQLW3P.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -12,12 +12,12 @@ import { ProductService } from './chunk-FZMP5NQZ.js';
|
|
|
12
12
|
export { ProductService } from './chunk-FZMP5NQZ.js';
|
|
13
13
|
import { SegmentService } from './chunk-NE7MIZPR.js';
|
|
14
14
|
export { SegmentService } from './chunk-NE7MIZPR.js';
|
|
15
|
-
import { AvailabilityService } from './chunk-
|
|
16
|
-
export { AvailabilityService } from './chunk-
|
|
15
|
+
import { AvailabilityService } from './chunk-IVCCGJN5.js';
|
|
16
|
+
export { AvailabilityService } from './chunk-IVCCGJN5.js';
|
|
17
17
|
import { CartService } from './chunk-PAT4CS36.js';
|
|
18
18
|
export { CartService } from './chunk-PAT4CS36.js';
|
|
19
|
-
import { CategoryService } from './chunk-
|
|
20
|
-
export { CategoryService } from './chunk-
|
|
19
|
+
import { CategoryService } from './chunk-ZNLHLFQM.js';
|
|
20
|
+
export { CategoryService } from './chunk-ZNLHLFQM.js';
|
|
21
21
|
export { iterateAll } from './chunk-GWJ2U2CP.js';
|
|
22
22
|
import { resolveQuery } from './chunk-S5HEIQDK.js';
|
|
23
23
|
export { resolveQuery } from './chunk-S5HEIQDK.js';
|
|
@@ -296,6 +296,47 @@ function createNoopLogger() {
|
|
|
296
296
|
return new NoopLogger();
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
// src/core/sse.ts
|
|
300
|
+
function parseFrame(frame) {
|
|
301
|
+
const ev = { data: "" };
|
|
302
|
+
const dataLines = [];
|
|
303
|
+
let saw = false;
|
|
304
|
+
for (const line of frame.split("\n")) {
|
|
305
|
+
if (line === "" || line.startsWith(":")) continue;
|
|
306
|
+
const colon = line.indexOf(":");
|
|
307
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
308
|
+
let value = colon === -1 ? "" : line.slice(colon + 1);
|
|
309
|
+
if (value.startsWith(" ")) value = value.slice(1);
|
|
310
|
+
if (field === "data") {
|
|
311
|
+
dataLines.push(value);
|
|
312
|
+
saw = true;
|
|
313
|
+
} else if (field === "event") {
|
|
314
|
+
ev.event = value;
|
|
315
|
+
saw = true;
|
|
316
|
+
} else if (field === "id") {
|
|
317
|
+
ev.id = value;
|
|
318
|
+
saw = true;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (!saw) return void 0;
|
|
322
|
+
ev.data = dataLines.join("\n");
|
|
323
|
+
return ev;
|
|
324
|
+
}
|
|
325
|
+
async function* parseSseStream(chunks) {
|
|
326
|
+
let buf = "";
|
|
327
|
+
for await (const chunk of chunks) {
|
|
328
|
+
buf += chunk.replace(/\r\n/g, "\n");
|
|
329
|
+
let idx;
|
|
330
|
+
while ((idx = buf.indexOf("\n\n")) !== -1) {
|
|
331
|
+
const ev = parseFrame(buf.slice(0, idx));
|
|
332
|
+
buf = buf.slice(idx + 2);
|
|
333
|
+
if (ev) yield ev;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const tail = parseFrame(buf);
|
|
337
|
+
if (tail) yield tail;
|
|
338
|
+
}
|
|
339
|
+
|
|
299
340
|
// src/core/http.ts
|
|
300
341
|
var requestSeq = 0;
|
|
301
342
|
function safeJson(text) {
|
|
@@ -485,10 +526,72 @@ var HttpClient = class {
|
|
|
485
526
|
clearTimeout(timer);
|
|
486
527
|
}
|
|
487
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* Open a Server-Sent Events stream (`text/event-stream`) and yield parsed
|
|
531
|
+
* events. Unlike {@link request}, no overall read budget applies (streams are
|
|
532
|
+
* long-lived) — only `connectMs` bounds time-to-headers, and the consumer
|
|
533
|
+
* breaking the iterator aborts the fetch. Like {@link requestRaw}, it does
|
|
534
|
+
* NOT retry or re-auth on 401; a non-2xx maps to a typed error before the
|
|
535
|
+
* stream begins.
|
|
536
|
+
*/
|
|
537
|
+
async *requestStream(o) {
|
|
538
|
+
const log = this.opts.logger.child({ requestId: `req-${++requestSeq}` });
|
|
539
|
+
const url = new URL(this.opts.host + o.path);
|
|
540
|
+
for (const [k, v] of Object.entries(o.query ?? {})) {
|
|
541
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
542
|
+
}
|
|
543
|
+
const token = await resolveToken(o.auth, this.opts.provider);
|
|
544
|
+
const controller = new AbortController();
|
|
545
|
+
const connectTimer = setTimeout(() => controller.abort(), this.opts.timeouts.connectMs);
|
|
546
|
+
const headers = this.buildHeaders(o, token, false);
|
|
547
|
+
headers["Accept"] = "text/event-stream";
|
|
548
|
+
let res;
|
|
549
|
+
try {
|
|
550
|
+
res = await fetch(url, {
|
|
551
|
+
method: o.method,
|
|
552
|
+
headers,
|
|
553
|
+
signal: controller.signal,
|
|
554
|
+
...o.body !== void 0 ? { body: JSON.stringify(o.body) } : {}
|
|
555
|
+
});
|
|
556
|
+
} catch (err) {
|
|
557
|
+
clearTimeout(connectTimer);
|
|
558
|
+
if (err.name === "AbortError") {
|
|
559
|
+
throw new EmporixTimeoutError(`${o.method} ${o.path} timed out opening stream`);
|
|
560
|
+
}
|
|
561
|
+
throw new EmporixNetworkError(
|
|
562
|
+
`${o.method} ${o.path} network failure: ${err.message}`
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
clearTimeout(connectTimer);
|
|
566
|
+
if (!res.ok) {
|
|
567
|
+
const text = await res.text().catch(() => "");
|
|
568
|
+
throw errorFromResponse(
|
|
569
|
+
res.status,
|
|
570
|
+
`${o.method} ${o.path} \u2192 ${res.status}`,
|
|
571
|
+
text ? safeJson(text) : void 0
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
log.debug("http stream open", { status: res.status });
|
|
575
|
+
if (!res.body) return;
|
|
576
|
+
const reader = res.body.getReader();
|
|
577
|
+
const decoder = new TextDecoder();
|
|
578
|
+
async function* readChunks() {
|
|
579
|
+
try {
|
|
580
|
+
for (; ; ) {
|
|
581
|
+
const { done, value } = await reader.read();
|
|
582
|
+
if (done) break;
|
|
583
|
+
yield decoder.decode(value, { stream: true });
|
|
584
|
+
}
|
|
585
|
+
} finally {
|
|
586
|
+
controller.abort();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
yield* parseSseStream(readChunks());
|
|
590
|
+
}
|
|
488
591
|
};
|
|
489
592
|
|
|
490
593
|
// package.json
|
|
491
|
-
var version = "2.
|
|
594
|
+
var version = "2.20.0";
|
|
492
595
|
|
|
493
596
|
// src/version.ts
|
|
494
597
|
var SDK_VERSION = version;
|
|
@@ -903,6 +1006,8 @@ var RagIndexerService = class {
|
|
|
903
1006
|
* Schedule a full asynchronous re-index for `type` (default `"PRODUCT"`).
|
|
904
1007
|
* Resolves once the rebuild is *scheduled* (HTTP 204); there is no progress
|
|
905
1008
|
* to await or poll. Costly — avoid calling on a hot path.
|
|
1009
|
+
* @deprecated since 2026-06-18, removal 2026-12-01 — use the indexing service:
|
|
1010
|
+
* `client.indexing.createReindexJob({ entityType: "PRODUCT", rag: true })`.
|
|
906
1011
|
*/
|
|
907
1012
|
async reindex(type = "PRODUCT", auth2 = SERVICE3) {
|
|
908
1013
|
await this.ctx.http.request({
|
|
@@ -1505,6 +1610,20 @@ var SchemaService = class {
|
|
|
1505
1610
|
body: patch
|
|
1506
1611
|
});
|
|
1507
1612
|
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Patch up to 200 custom instances of `type` in one call
|
|
1615
|
+
* (`PATCH /custom-entities/{type}/instances/bulk`). Returns a 207 envelope:
|
|
1616
|
+
* a per-item result array — a 207 is success, individual failures live in
|
|
1617
|
+
* each item's `code`/`status`.
|
|
1618
|
+
*/
|
|
1619
|
+
async bulkPatchInstances(type, items, auth2 = SERVICE7) {
|
|
1620
|
+
return this.ctx.http.request({
|
|
1621
|
+
method: "PATCH",
|
|
1622
|
+
path: `${this.instancesBase(type)}/bulk`,
|
|
1623
|
+
auth: auth2,
|
|
1624
|
+
body: items
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1508
1627
|
/** Delete an instance by id. */
|
|
1509
1628
|
async deleteInstance(type, id, auth2 = SERVICE7) {
|
|
1510
1629
|
await this.ctx.http.request({
|
|
@@ -1640,6 +1759,39 @@ var AiService = class {
|
|
|
1640
1759
|
body: input
|
|
1641
1760
|
});
|
|
1642
1761
|
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Streaming agent chat (`POST /agentic/chat-stream`, `text/event-stream`).
|
|
1764
|
+
* Yields each SSE `data` payload verbatim — the upstream contract types the
|
|
1765
|
+
* stream body as an opaque string, so chunks are raw strings, not parsed
|
|
1766
|
+
* objects. Consume with `for await`.
|
|
1767
|
+
*/
|
|
1768
|
+
async *chatStream(input, opts = {}, auth2 = SERVICE8) {
|
|
1769
|
+
const events = this.ctx.http.requestStream({
|
|
1770
|
+
method: "POST",
|
|
1771
|
+
path: `${this.base()}/agentic/chat-stream`,
|
|
1772
|
+
auth: auth2,
|
|
1773
|
+
body: input,
|
|
1774
|
+
...opts.sessionId ? { headers: { "session-id": opts.sessionId } } : {}
|
|
1775
|
+
});
|
|
1776
|
+
for await (const ev of events) yield ev.data;
|
|
1777
|
+
}
|
|
1778
|
+
/** List stored agentic conversations (`GET /agentic/conversations`). */
|
|
1779
|
+
async listConversations(auth2 = SERVICE8) {
|
|
1780
|
+
return this.ctx.http.request({
|
|
1781
|
+
method: "GET",
|
|
1782
|
+
path: `${this.base()}/agentic/conversations`,
|
|
1783
|
+
auth: auth2
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
/** Server-side conversation search (`POST /agentic/conversations/search`). */
|
|
1787
|
+
async searchConversations(query, auth2 = SERVICE8) {
|
|
1788
|
+
return this.ctx.http.request({
|
|
1789
|
+
method: "POST",
|
|
1790
|
+
path: `${this.base()}/agentic/conversations/search`,
|
|
1791
|
+
auth: auth2,
|
|
1792
|
+
body: query
|
|
1793
|
+
});
|
|
1794
|
+
}
|
|
1643
1795
|
};
|
|
1644
1796
|
|
|
1645
1797
|
// src/services/tax.ts
|
|
@@ -2863,7 +3015,47 @@ var IndexingService = class {
|
|
|
2863
3015
|
auth: auth2
|
|
2864
3016
|
});
|
|
2865
3017
|
}
|
|
2866
|
-
/**
|
|
3018
|
+
/**
|
|
3019
|
+
* Create a reindex job (replaces {@link reindex}). A `FULL` reindex of the
|
|
3020
|
+
* given `entityType`; set `rag: true` to also rebuild the RAG vector index
|
|
3021
|
+
* (PRODUCT only). Resolves to the created job (`201`) or, when a job for that
|
|
3022
|
+
* `entityType` is already `IN_PROGRESS`, that running job (`200`).
|
|
3023
|
+
*/
|
|
3024
|
+
async createReindexJob(input, auth2 = SERVICE19) {
|
|
3025
|
+
return this.ctx.http.request({
|
|
3026
|
+
method: "POST",
|
|
3027
|
+
path: `${this.base()}/reindex-jobs`,
|
|
3028
|
+
auth: auth2,
|
|
3029
|
+
body: input
|
|
3030
|
+
});
|
|
3031
|
+
}
|
|
3032
|
+
/** List reindex jobs (paginated). */
|
|
3033
|
+
async listReindexJobs(opts = {}, auth2 = SERVICE19) {
|
|
3034
|
+
const pageNumber = opts.pageNumber ?? 1;
|
|
3035
|
+
const pageSize = opts.pageSize ?? 50;
|
|
3036
|
+
const query = { pageNumber, pageSize };
|
|
3037
|
+
if (opts.q !== void 0) query.q = opts.q;
|
|
3038
|
+
const items = await this.ctx.http.request({
|
|
3039
|
+
method: "GET",
|
|
3040
|
+
path: `${this.base()}/reindex-jobs`,
|
|
3041
|
+
query,
|
|
3042
|
+
auth: auth2
|
|
3043
|
+
});
|
|
3044
|
+
return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
|
|
3045
|
+
}
|
|
3046
|
+
/** Fetch one reindex job by id. */
|
|
3047
|
+
async getReindexJob(reindexJobId, auth2 = SERVICE19) {
|
|
3048
|
+
return this.ctx.http.request({
|
|
3049
|
+
method: "GET",
|
|
3050
|
+
path: `${this.base()}/reindex-jobs/${encodeURIComponent(reindexJobId)}`,
|
|
3051
|
+
auth: auth2
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Trigger a reindex.
|
|
3056
|
+
* @deprecated since 2026-06-18, removal 2026-12-01 — use {@link createReindexJob}
|
|
3057
|
+
* (`createReindexJob({ entityType: "PRODUCT" })`), which returns a trackable job.
|
|
3058
|
+
*/
|
|
2867
3059
|
async reindex(input, auth2 = SERVICE19) {
|
|
2868
3060
|
await this.ctx.http.request({ method: "POST", path: `${this.base()}/reindex`, auth: auth2, body: input });
|
|
2869
3061
|
}
|