@viu/emporix-sdk 2.2.0 → 2.3.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.cjs CHANGED
@@ -2385,8 +2385,845 @@ var ClientConfigService = class {
2385
2385
  }
2386
2386
  };
2387
2387
 
2388
+ // src/services/shopping-list.ts
2389
+ var RESERVED = /* @__PURE__ */ new Set(["customerId", "metadata"]);
2390
+ var ShoppingListService = class {
2391
+ constructor(ctx) {
2392
+ this.ctx = ctx;
2393
+ }
2394
+ ctx;
2395
+ base() {
2396
+ return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
2397
+ }
2398
+ /** The caller's lists (or, with employee scope, all), normalized to an array. */
2399
+ async list(auth2, opts = {}) {
2400
+ const envelopes = await this.ctx.http.request({
2401
+ method: "GET",
2402
+ path: this.base(),
2403
+ auth: auth2,
2404
+ ...opts.name ? { query: { name: opts.name } } : {}
2405
+ });
2406
+ const out = [];
2407
+ for (const env of envelopes ?? []) {
2408
+ for (const [key, value] of Object.entries(env)) {
2409
+ if (RESERVED.has(key) || value === null || typeof value !== "object") continue;
2410
+ const v = value;
2411
+ out.push({
2412
+ key,
2413
+ name: v.name ?? key,
2414
+ items: v.items ?? [],
2415
+ ...v.mixins ? { mixins: v.mixins } : {},
2416
+ ...v.metadata ? { metadata: v.metadata } : {}
2417
+ });
2418
+ }
2419
+ }
2420
+ return out;
2421
+ }
2422
+ /** Create a list; returns the new list id. */
2423
+ async create(draft, auth2) {
2424
+ return this.ctx.http.request({
2425
+ method: "POST",
2426
+ path: this.base(),
2427
+ auth: auth2,
2428
+ body: draft
2429
+ });
2430
+ }
2431
+ /** Replace the named list (low-level PUT). */
2432
+ async replace(customerId, draft, auth2) {
2433
+ await this.ctx.http.request({
2434
+ method: "PUT",
2435
+ path: `${this.base()}/${encodeURIComponent(customerId)}`,
2436
+ auth: auth2,
2437
+ body: draft
2438
+ });
2439
+ }
2440
+ /** Delete the named list, or all the customer's lists when `name` is omitted. */
2441
+ async delete(customerId, auth2, opts = {}) {
2442
+ await this.ctx.http.request({
2443
+ method: "DELETE",
2444
+ path: `${this.base()}/${encodeURIComponent(customerId)}`,
2445
+ auth: auth2,
2446
+ ...opts.name ? { query: { name: opts.name } } : {}
2447
+ });
2448
+ }
2449
+ async loadList(listName, auth2) {
2450
+ const lists = await this.list(auth2, { name: listName });
2451
+ const found = lists.find((l) => l.name === listName);
2452
+ if (!found) throw new EmporixNotFoundError(`Shopping list "${listName}" not found`, 404);
2453
+ return found;
2454
+ }
2455
+ async put(customerId, list, items, auth2) {
2456
+ await this.replace(
2457
+ customerId,
2458
+ { name: list.name, items, ...list.mixins ? { mixins: list.mixins } : {} },
2459
+ auth2
2460
+ );
2461
+ }
2462
+ /** Add/replace an item by `productId` (read-modify-write, last-write-wins). */
2463
+ async addItem(customerId, listName, item, auth2) {
2464
+ const list = await this.loadList(listName, auth2);
2465
+ const items = [...list.items.filter((i) => i.productId !== item.productId), item];
2466
+ await this.put(customerId, list, items, auth2);
2467
+ }
2468
+ /** Remove an item by `productId` (no-op if absent). */
2469
+ async removeItem(customerId, listName, productId, auth2) {
2470
+ const list = await this.loadList(listName, auth2);
2471
+ const items = list.items.filter((i) => i.productId !== productId);
2472
+ await this.put(customerId, list, items, auth2);
2473
+ }
2474
+ /** Set an item's quantity; `quantity <= 0` removes it. Adds the item if absent. */
2475
+ async setItemQuantity(customerId, listName, productId, quantity, auth2) {
2476
+ if (quantity <= 0) return this.removeItem(customerId, listName, productId, auth2);
2477
+ const list = await this.loadList(listName, auth2);
2478
+ let items = list.items.map((i) => i.productId === productId ? { ...i, quantity } : i);
2479
+ if (!items.some((i) => i.productId === productId)) items = [...items, { productId, quantity }];
2480
+ await this.put(customerId, list, items, auth2);
2481
+ }
2482
+ };
2483
+
2484
+ // src/services/ai-rag-indexer.ts
2485
+ var SERVICE5 = { kind: "service" };
2486
+ var RagIndexerService = class {
2487
+ constructor(ctx) {
2488
+ this.ctx = ctx;
2489
+ }
2490
+ ctx;
2491
+ base(type) {
2492
+ return `/ai-rag-indexer/${this.ctx.tenant}/${encodeURIComponent(type)}`;
2493
+ }
2494
+ /** The indexable embedding field names for `type` (default `"PRODUCT"`). */
2495
+ async ragMetadata(type = "PRODUCT", auth2 = SERVICE5) {
2496
+ return this.ctx.http.request({
2497
+ method: "GET",
2498
+ path: `${this.base(type)}/rag-metadata`,
2499
+ auth: auth2
2500
+ });
2501
+ }
2502
+ /** The filterable metadata fields for `type` (default `"PRODUCT"`). */
2503
+ async filterMetadata(type = "PRODUCT", auth2 = SERVICE5) {
2504
+ return this.ctx.http.request({
2505
+ method: "GET",
2506
+ path: `${this.base(type)}/filter-metadata`,
2507
+ auth: auth2
2508
+ });
2509
+ }
2510
+ /**
2511
+ * Schedule a full asynchronous re-index for `type` (default `"PRODUCT"`).
2512
+ * Resolves once the rebuild is *scheduled* (HTTP 204); there is no progress
2513
+ * to await or poll. Costly — avoid calling on a hot path.
2514
+ */
2515
+ async reindex(type = "PRODUCT", auth2 = SERVICE5) {
2516
+ await this.ctx.http.request({
2517
+ method: "POST",
2518
+ path: `${this.base(type)}/reindex`,
2519
+ auth: auth2
2520
+ });
2521
+ }
2522
+ };
2523
+
2524
+ // src/services/sequential-id.ts
2525
+ var SERVICE6 = { kind: "service" };
2526
+ var SequentialIdService = class {
2527
+ constructor(ctx) {
2528
+ this.ctx = ctx;
2529
+ }
2530
+ ctx;
2531
+ base() {
2532
+ return `/sequential-id/${this.ctx.tenant}/schemas`;
2533
+ }
2534
+ /** List all sequence schemas for the tenant. */
2535
+ async listSchemas(auth2 = SERVICE6) {
2536
+ return this.ctx.http.request({
2537
+ method: "GET",
2538
+ path: this.base(),
2539
+ auth: auth2
2540
+ });
2541
+ }
2542
+ /** Retrieve one sequence schema by id. */
2543
+ async getSchema(schemaId, auth2 = SERVICE6) {
2544
+ return this.ctx.http.request({
2545
+ method: "GET",
2546
+ path: `${this.base()}/${encodeURIComponent(schemaId)}`,
2547
+ auth: auth2
2548
+ });
2549
+ }
2550
+ /** Create a sequence schema. Schemas are immutable — there is no update. */
2551
+ async createSchema(schema, auth2 = SERVICE6) {
2552
+ return this.ctx.http.request({
2553
+ method: "POST",
2554
+ path: this.base(),
2555
+ auth: auth2,
2556
+ body: schema
2557
+ });
2558
+ }
2559
+ /** Delete a sequence schema by id. */
2560
+ async deleteSchema(schemaId, auth2 = SERVICE6) {
2561
+ await this.ctx.http.request({
2562
+ method: "DELETE",
2563
+ path: `${this.base()}/${encodeURIComponent(schemaId)}`,
2564
+ auth: auth2
2565
+ });
2566
+ }
2567
+ /** Mark a schema active for its type (only one schema may be active per type). */
2568
+ async setActiveSchema(schemaId, auth2 = SERVICE6) {
2569
+ await this.ctx.http.request({
2570
+ method: "POST",
2571
+ path: `${this.base()}/${encodeURIComponent(schemaId)}/setActive`,
2572
+ auth: auth2
2573
+ });
2574
+ }
2575
+ /** Get the active schema for a given schema type. */
2576
+ async listSchemasByType(schemaType, auth2 = SERVICE6) {
2577
+ return this.ctx.http.request({
2578
+ method: "GET",
2579
+ path: `${this.base()}/types/${encodeURIComponent(schemaType)}`,
2580
+ auth: auth2
2581
+ });
2582
+ }
2583
+ /**
2584
+ * Generate the next id for a schema type. `body` carries an optional
2585
+ * `sequenceKey` (independent sub-pool counter) and `placeholders`.
2586
+ * `opts.siteCode` derives time/country placeholders from the site's settings.
2587
+ */
2588
+ async nextId(schemaType, body = {}, opts = {}, auth2 = SERVICE6) {
2589
+ const query = opts.siteCode ? { siteCode: opts.siteCode } : void 0;
2590
+ return this.ctx.http.request({
2591
+ method: "POST",
2592
+ path: `${this.base()}/types/${encodeURIComponent(schemaType)}/nextId`,
2593
+ auth: auth2,
2594
+ body,
2595
+ ...query ? { query } : {}
2596
+ });
2597
+ }
2598
+ /**
2599
+ * Generate next ids for multiple schema types in one call. NOTE: the batch
2600
+ * endpoint path omits the `{tenant}` segment — the service derives the
2601
+ * tenant from the token.
2602
+ */
2603
+ async nextIdsBatch(req, auth2 = SERVICE6) {
2604
+ return this.ctx.http.request({
2605
+ method: "POST",
2606
+ path: `/sequential-id/sequenceSchemaBatch/nextIds`,
2607
+ auth: auth2,
2608
+ body: req
2609
+ });
2610
+ }
2611
+ };
2612
+
2613
+ // src/services/fee.ts
2614
+ var SERVICE7 = { kind: "service" };
2615
+ var FeeService = class {
2616
+ constructor(ctx) {
2617
+ this.ctx = ctx;
2618
+ }
2619
+ ctx;
2620
+ feesBase() {
2621
+ return `/fee/${this.ctx.tenant}/fees`;
2622
+ }
2623
+ itemFeesBase() {
2624
+ return `/fee/${this.ctx.tenant}/itemFees`;
2625
+ }
2626
+ productFeesBase() {
2627
+ return `/fee/${this.ctx.tenant}/productFees`;
2628
+ }
2629
+ // --- Fee definitions ---
2630
+ /**
2631
+ * List fee definitions, wrapped in the shared {@link PaginatedItems}
2632
+ * envelope (same heuristic as `media.list`: `hasNextPage` is true when the
2633
+ * returned page is full). Defaults match Emporix server defaults
2634
+ * (`pageNumber: 1`, `pageSize: 60`).
2635
+ */
2636
+ async list(query = {}, auth2 = SERVICE7) {
2637
+ const pageNumber = query.pageNumber ?? 1;
2638
+ const pageSize = query.pageSize ?? 60;
2639
+ const items = await this.ctx.http.request({
2640
+ method: "GET",
2641
+ path: this.feesBase(),
2642
+ auth: auth2,
2643
+ query: { ...query, pageNumber, pageSize }
2644
+ });
2645
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
2646
+ }
2647
+ /** Retrieve one fee definition by id. */
2648
+ async get(id, auth2 = SERVICE7) {
2649
+ return this.ctx.http.request({
2650
+ method: "GET",
2651
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
2652
+ auth: auth2
2653
+ });
2654
+ }
2655
+ /** Create a fee definition. */
2656
+ async create(draft, auth2 = SERVICE7) {
2657
+ return this.ctx.http.request({
2658
+ method: "POST",
2659
+ path: this.feesBase(),
2660
+ auth: auth2,
2661
+ body: draft
2662
+ });
2663
+ }
2664
+ /** Update a fee definition by id. */
2665
+ async update(id, draft, auth2 = SERVICE7) {
2666
+ return this.ctx.http.request({
2667
+ method: "PUT",
2668
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
2669
+ auth: auth2,
2670
+ body: draft
2671
+ });
2672
+ }
2673
+ /** Delete a fee definition by id. */
2674
+ async delete(id, auth2 = SERVICE7) {
2675
+ await this.ctx.http.request({
2676
+ method: "DELETE",
2677
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
2678
+ auth: auth2
2679
+ });
2680
+ }
2681
+ // --- Item-fee mappings ---
2682
+ /** List all item-fee mappings. */
2683
+ async listItemFees(auth2 = SERVICE7) {
2684
+ return this.ctx.http.request({
2685
+ method: "GET",
2686
+ path: this.itemFeesBase(),
2687
+ auth: auth2
2688
+ });
2689
+ }
2690
+ /** Fee mappings for one item YRN. */
2691
+ async getItemFees(itemYrn, auth2 = SERVICE7) {
2692
+ return this.ctx.http.request({
2693
+ method: "GET",
2694
+ path: `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`,
2695
+ auth: auth2
2696
+ });
2697
+ }
2698
+ /** Create an item-fee mapping. */
2699
+ async createItemFee(draft, auth2 = SERVICE7) {
2700
+ return this.ctx.http.request({
2701
+ method: "POST",
2702
+ path: this.itemFeesBase(),
2703
+ auth: auth2,
2704
+ body: draft
2705
+ });
2706
+ }
2707
+ /**
2708
+ * Set the fee list for an item YRN. Destructive replace by default; pass
2709
+ * `{ partial: true }` to merge (`?partial=true`).
2710
+ */
2711
+ async setItemFees(itemYrn, feeIds, opts = {}, auth2 = SERVICE7) {
2712
+ return this.ctx.http.request({
2713
+ method: "PUT",
2714
+ path: `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`,
2715
+ auth: auth2,
2716
+ body: { feeIds },
2717
+ ...opts.partial ? { query: { partial: "true" } } : {}
2718
+ });
2719
+ }
2720
+ /**
2721
+ * Delete item-fee mappings for a YRN. Without `feeId`, removes all mappings
2722
+ * for the YRN; with `feeId`, removes that single fee from the mapping.
2723
+ */
2724
+ async deleteItemFees(itemYrn, feeId, auth2 = SERVICE7) {
2725
+ const base = `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`;
2726
+ await this.ctx.http.request({
2727
+ method: "DELETE",
2728
+ path: feeId ? `${base}/${encodeURIComponent(feeId)}` : base,
2729
+ auth: auth2
2730
+ });
2731
+ }
2732
+ /** Search item-fee mappings by item YRNs + site. */
2733
+ async searchItemFees(search, auth2 = SERVICE7) {
2734
+ return this.ctx.http.request({
2735
+ method: "POST",
2736
+ path: `${this.itemFeesBase()}/search`,
2737
+ auth: auth2,
2738
+ body: search
2739
+ });
2740
+ }
2741
+ // --- Product-fee mappings ---
2742
+ /** Fee mappings for a product id. */
2743
+ async getProductFees(productId, auth2 = SERVICE7) {
2744
+ return this.ctx.http.request({
2745
+ method: "GET",
2746
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
2747
+ auth: auth2
2748
+ });
2749
+ }
2750
+ /**
2751
+ * Set the fee list for a product id. Destructive replace by default; pass
2752
+ * `{ partial: true }` to merge (`?partial=true`).
2753
+ */
2754
+ async setProductFees(productId, feeIds, opts = {}, auth2 = SERVICE7) {
2755
+ return this.ctx.http.request({
2756
+ method: "PUT",
2757
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
2758
+ auth: auth2,
2759
+ body: { feeIds },
2760
+ ...opts.partial ? { query: { partial: "true" } } : {}
2761
+ });
2762
+ }
2763
+ /** Delete all fee mappings for a product id. */
2764
+ async deleteProductFees(productId, auth2 = SERVICE7) {
2765
+ await this.ctx.http.request({
2766
+ method: "DELETE",
2767
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
2768
+ auth: auth2
2769
+ });
2770
+ }
2771
+ };
2772
+
2773
+ // src/services/webhook.ts
2774
+ var SERVICE8 = { kind: "service" };
2775
+ var WebhookService = class {
2776
+ constructor(ctx) {
2777
+ this.ctx = ctx;
2778
+ }
2779
+ ctx;
2780
+ base() {
2781
+ return `/webhook/${this.ctx.tenant}`;
2782
+ }
2783
+ /** List the event-subscription catalog with each event's on/off state. */
2784
+ async listEventSubscriptions(auth2 = SERVICE8) {
2785
+ return this.ctx.http.request({
2786
+ method: "GET",
2787
+ path: `${this.base()}/event-subscriptions`,
2788
+ auth: auth2
2789
+ });
2790
+ }
2791
+ /**
2792
+ * Batch subscribe/unsubscribe events. Returns the **207** per-item result
2793
+ * array verbatim — the batch can partially fail, so inspect each element's
2794
+ * `code`/`status` (e.g. `results.filter(r => (r.code ?? 0) >= 400)`). Does
2795
+ * NOT throw on a 207 with failed items; only a non-2xx HTTP status throws.
2796
+ */
2797
+ async updateEventSubscriptions(items, auth2 = SERVICE8) {
2798
+ return this.ctx.http.request({
2799
+ method: "PATCH",
2800
+ path: `${this.base()}/event-subscriptions`,
2801
+ auth: auth2,
2802
+ body: items
2803
+ });
2804
+ }
2805
+ /** List delivery configurations. */
2806
+ async listConfigs(auth2 = SERVICE8) {
2807
+ return this.ctx.http.request({
2808
+ method: "GET",
2809
+ path: `${this.base()}/config`,
2810
+ auth: auth2
2811
+ });
2812
+ }
2813
+ /** Retrieve one delivery configuration by code. */
2814
+ async getConfig(code, auth2 = SERVICE8) {
2815
+ return this.ctx.http.request({
2816
+ method: "GET",
2817
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
2818
+ auth: auth2
2819
+ });
2820
+ }
2821
+ /** Create a delivery configuration. Returns the server-assigned `{ code }`. */
2822
+ async createConfig(draft, auth2 = SERVICE8) {
2823
+ return this.ctx.http.request({
2824
+ method: "POST",
2825
+ path: `${this.base()}/config`,
2826
+ auth: auth2,
2827
+ body: draft
2828
+ });
2829
+ }
2830
+ /** Replace a delivery configuration by code (204). */
2831
+ async replaceConfig(code, draft, auth2 = SERVICE8) {
2832
+ await this.ctx.http.request({
2833
+ method: "PUT",
2834
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
2835
+ auth: auth2,
2836
+ body: draft
2837
+ });
2838
+ }
2839
+ /**
2840
+ * Partially update a delivery configuration by code (204). The body is an
2841
+ * **array** of `{ op, path, value }` operations (UPSERT / REMOVE).
2842
+ */
2843
+ async patchConfig(code, patches, auth2 = SERVICE8) {
2844
+ await this.ctx.http.request({
2845
+ method: "PATCH",
2846
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
2847
+ auth: auth2,
2848
+ body: patches
2849
+ });
2850
+ }
2851
+ /**
2852
+ * Delete a delivery configuration by code. Pass `{ force: true }` to delete
2853
+ * the currently-active config (the server otherwise rejects it).
2854
+ */
2855
+ async deleteConfig(code, opts = {}, auth2 = SERVICE8) {
2856
+ await this.ctx.http.request({
2857
+ method: "DELETE",
2858
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
2859
+ auth: auth2,
2860
+ ...opts.force === true ? { query: { force: "true" } } : {}
2861
+ });
2862
+ }
2863
+ /** Read delivery statistics over an optional `YYYY-MM` range. */
2864
+ async getStatistics(query = {}, auth2 = SERVICE8) {
2865
+ const q = {};
2866
+ if (query.fromYearMonth) q.fromYearMonth = query.fromYearMonth;
2867
+ if (query.toYearMonth) q.toYearMonth = query.toYearMonth;
2868
+ return this.ctx.http.request({
2869
+ method: "GET",
2870
+ path: `${this.base()}/statistics`,
2871
+ auth: auth2,
2872
+ ...Object.keys(q).length > 0 ? { query: q } : {}
2873
+ });
2874
+ }
2875
+ /** Obtain Svix dashboard access (URL / token). */
2876
+ async getDashboardAccess(auth2 = SERVICE8) {
2877
+ return this.ctx.http.request({
2878
+ method: "GET",
2879
+ path: `${this.base()}/dashboard-access`,
2880
+ auth: auth2
2881
+ });
2882
+ }
2883
+ };
2884
+
2885
+ // src/services/schema.ts
2886
+ var SERVICE9 = { kind: "service" };
2887
+ var SchemaService = class {
2888
+ constructor(ctx) {
2889
+ this.ctx = ctx;
2890
+ }
2891
+ ctx;
2892
+ schemasBase() {
2893
+ return `/schema/${this.ctx.tenant}/schemas`;
2894
+ }
2895
+ entitiesBase() {
2896
+ return `/schema/${this.ctx.tenant}/custom-entities`;
2897
+ }
2898
+ instancesBase(type) {
2899
+ return `${this.entitiesBase()}/${encodeURIComponent(type)}/instances`;
2900
+ }
2901
+ // --- (A) Schemas ---------------------------------------------------------
2902
+ /**
2903
+ * List schemas, wrapped in the shared {@link PaginatedItems} envelope.
2904
+ * `hasNextPage` is the standard SDK heuristic (`items.length === pageSize`).
2905
+ * Pagination defaults match the rest of the SDK (`pageNumber: 1`,
2906
+ * `pageSize: 60`).
2907
+ */
2908
+ async listSchemas(query = {}, auth2 = SERVICE9) {
2909
+ const pageNumber = query.pageNumber ?? 1;
2910
+ const pageSize = query.pageSize ?? 60;
2911
+ const q = { pageNumber, pageSize };
2912
+ if (query.q) q.q = query.q;
2913
+ if (query.type) q.type = query.type;
2914
+ const items = await this.ctx.http.request({
2915
+ method: "GET",
2916
+ path: this.schemasBase(),
2917
+ auth: auth2,
2918
+ query: q
2919
+ });
2920
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
2921
+ }
2922
+ /** Retrieve one schema by id. */
2923
+ async getSchema(id, auth2 = SERVICE9) {
2924
+ return this.ctx.http.request({
2925
+ method: "GET",
2926
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
2927
+ auth: auth2
2928
+ });
2929
+ }
2930
+ /** Create a schema. */
2931
+ async createSchema(draft, auth2 = SERVICE9) {
2932
+ return this.ctx.http.request({
2933
+ method: "POST",
2934
+ path: this.schemasBase(),
2935
+ auth: auth2,
2936
+ body: draft
2937
+ });
2938
+ }
2939
+ /**
2940
+ * Update a schema. The upstream API requires `draft.metadata.version`; a
2941
+ * stale version yields 409 Conflict (propagated as the standard conflict
2942
+ * error).
2943
+ */
2944
+ async updateSchema(id, draft, auth2 = SERVICE9) {
2945
+ return this.ctx.http.request({
2946
+ method: "PUT",
2947
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
2948
+ auth: auth2,
2949
+ body: draft
2950
+ });
2951
+ }
2952
+ /** Delete a schema by id. */
2953
+ async deleteSchema(id, auth2 = SERVICE9) {
2954
+ await this.ctx.http.request({
2955
+ method: "DELETE",
2956
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
2957
+ auth: auth2
2958
+ });
2959
+ }
2960
+ /**
2961
+ * Validate a schema document without persisting it (`POST /schemas/file`).
2962
+ * Returns the server's validation result verbatim.
2963
+ */
2964
+ async validateSchemaFile(body, auth2 = SERVICE9) {
2965
+ return this.ctx.http.request({
2966
+ method: "POST",
2967
+ path: `${this.schemasBase()}/file`,
2968
+ auth: auth2,
2969
+ body
2970
+ });
2971
+ }
2972
+ // --- (B) Types -----------------------------------------------------------
2973
+ /** List entity types that currently have at least one schema. */
2974
+ async listTypes(auth2 = SERVICE9) {
2975
+ return this.ctx.http.request({
2976
+ method: "GET",
2977
+ path: `/schema/${this.ctx.tenant}/types`,
2978
+ auth: auth2
2979
+ });
2980
+ }
2981
+ /** Set the entity types a schema applies to (`PUT /schemas/{id}/types`). */
2982
+ async setSchemaTypes(id, types, auth2 = SERVICE9) {
2983
+ return this.ctx.http.request({
2984
+ method: "PUT",
2985
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}/types`,
2986
+ auth: auth2,
2987
+ body: { types }
2988
+ });
2989
+ }
2990
+ // --- (C) Custom entities -------------------------------------------------
2991
+ /** List custom-entity definitions. `expandSchemas` inlines each schema body. */
2992
+ async listCustomEntities(opts = {}, auth2 = SERVICE9) {
2993
+ return this.ctx.http.request({
2994
+ method: "GET",
2995
+ path: this.entitiesBase(),
2996
+ auth: auth2,
2997
+ ...opts.expandSchemas ? { query: { expandSchemas: "true" } } : {}
2998
+ });
2999
+ }
3000
+ /** Retrieve one custom-entity definition by id. */
3001
+ async getCustomEntity(id, auth2 = SERVICE9) {
3002
+ return this.ctx.http.request({
3003
+ method: "GET",
3004
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
3005
+ auth: auth2
3006
+ });
3007
+ }
3008
+ /** Create a custom-entity definition. */
3009
+ async createCustomEntity(draft, auth2 = SERVICE9) {
3010
+ return this.ctx.http.request({
3011
+ method: "POST",
3012
+ path: this.entitiesBase(),
3013
+ auth: auth2,
3014
+ body: draft
3015
+ });
3016
+ }
3017
+ /** Update a custom-entity definition. */
3018
+ async updateCustomEntity(id, draft, auth2 = SERVICE9) {
3019
+ return this.ctx.http.request({
3020
+ method: "PUT",
3021
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
3022
+ auth: auth2,
3023
+ body: draft
3024
+ });
3025
+ }
3026
+ /**
3027
+ * Delete a custom-entity definition. The server rejects with 409 if
3028
+ * instances or schemas still reference it (propagated as the standard
3029
+ * conflict error).
3030
+ */
3031
+ async deleteCustomEntity(id, auth2 = SERVICE9) {
3032
+ await this.ctx.http.request({
3033
+ method: "DELETE",
3034
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
3035
+ auth: auth2
3036
+ });
3037
+ }
3038
+ // --- (D) Custom instances ------------------------------------------------
3039
+ /**
3040
+ * List a custom entity's instances, wrapped in {@link PaginatedItems}.
3041
+ * `type` is the custom-entity type and is always the first argument.
3042
+ */
3043
+ async listInstances(type, query = {}, auth2 = SERVICE9) {
3044
+ const pageNumber = query.pageNumber ?? 1;
3045
+ const pageSize = query.pageSize ?? 60;
3046
+ const items = await this.ctx.http.request({
3047
+ method: "GET",
3048
+ path: this.instancesBase(type),
3049
+ auth: auth2,
3050
+ query: { ...query, pageNumber, pageSize }
3051
+ });
3052
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
3053
+ }
3054
+ /** Retrieve one instance by id. */
3055
+ async getInstance(type, id, auth2 = SERVICE9) {
3056
+ return this.ctx.http.request({
3057
+ method: "GET",
3058
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
3059
+ auth: auth2
3060
+ });
3061
+ }
3062
+ /** Create an instance of a custom entity. */
3063
+ async createInstance(type, draft, auth2 = SERVICE9) {
3064
+ return this.ctx.http.request({
3065
+ method: "POST",
3066
+ path: this.instancesBase(type),
3067
+ auth: auth2,
3068
+ body: draft
3069
+ });
3070
+ }
3071
+ /** Replace an instance (full `PUT`). */
3072
+ async replaceInstance(type, id, draft, auth2 = SERVICE9) {
3073
+ return this.ctx.http.request({
3074
+ method: "PUT",
3075
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
3076
+ auth: auth2,
3077
+ body: draft
3078
+ });
3079
+ }
3080
+ /** Partially update an instance (`PATCH`). */
3081
+ async patchInstance(type, id, patch, auth2 = SERVICE9) {
3082
+ return this.ctx.http.request({
3083
+ method: "PATCH",
3084
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
3085
+ auth: auth2,
3086
+ body: patch
3087
+ });
3088
+ }
3089
+ /** Delete an instance by id. */
3090
+ async deleteInstance(type, id, auth2 = SERVICE9) {
3091
+ await this.ctx.http.request({
3092
+ method: "DELETE",
3093
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
3094
+ auth: auth2
3095
+ });
3096
+ }
3097
+ /**
3098
+ * Structured search over a custom entity's instances
3099
+ * (`POST /instances/search`), wrapped in {@link PaginatedItems}.
3100
+ */
3101
+ async searchInstances(type, body, auth2 = SERVICE9) {
3102
+ const items = await this.ctx.http.request({
3103
+ method: "POST",
3104
+ path: `${this.instancesBase(type)}/search`,
3105
+ auth: auth2,
3106
+ body
3107
+ });
3108
+ return { items, pageNumber: 1, pageSize: items.length, hasNextPage: false };
3109
+ }
3110
+ };
3111
+
3112
+ // src/services/ai.ts
3113
+ var SERVICE10 = { kind: "service" };
3114
+ var AiService = class {
3115
+ constructor(ctx) {
3116
+ this.ctx = ctx;
3117
+ }
3118
+ ctx;
3119
+ base() {
3120
+ return `/ai-service/${this.ctx.tenant}`;
3121
+ }
3122
+ /** Generate text from a single prompt (`POST /texts`). Honors `maxTokens`. */
3123
+ async generateText(input, auth2 = SERVICE10) {
3124
+ return this.ctx.http.request({
3125
+ method: "POST",
3126
+ path: `${this.base()}/texts`,
3127
+ auth: auth2,
3128
+ body: input
3129
+ });
3130
+ }
3131
+ /** Run a chat completion over a message list (`POST /completions`). No `maxTokens`. */
3132
+ async complete(input, auth2 = SERVICE10) {
3133
+ return this.ctx.http.request({
3134
+ method: "POST",
3135
+ path: `${this.base()}/completions`,
3136
+ auth: auth2,
3137
+ body: input
3138
+ });
3139
+ }
3140
+ /** List all agentic agents. */
3141
+ async listAgents(auth2 = SERVICE10) {
3142
+ return this.ctx.http.request({
3143
+ method: "GET",
3144
+ path: `${this.base()}/agentic/agents`,
3145
+ auth: auth2
3146
+ });
3147
+ }
3148
+ /** Retrieve one agent by id. */
3149
+ async getAgent(id, auth2 = SERVICE10) {
3150
+ return this.ctx.http.request({
3151
+ method: "GET",
3152
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
3153
+ auth: auth2
3154
+ });
3155
+ }
3156
+ /** Create-or-replace an agent by id (`PUT`). Takes the agent write shape. */
3157
+ async upsertAgent(id, agent, auth2 = SERVICE10) {
3158
+ return this.ctx.http.request({
3159
+ method: "PUT",
3160
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
3161
+ auth: auth2,
3162
+ body: agent
3163
+ });
3164
+ }
3165
+ /**
3166
+ * Patch an agent with an op array (`PATCH`). `ops` use the upstream
3167
+ * UPPERCASE enum (`ADD | REMOVE | REPLACE`) and are sent verbatim — this is
3168
+ * NOT RFC-6902 JSON-Patch.
3169
+ */
3170
+ async patchAgent(id, ops, auth2 = SERVICE10) {
3171
+ return this.ctx.http.request({
3172
+ method: "PATCH",
3173
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
3174
+ auth: auth2,
3175
+ body: ops
3176
+ });
3177
+ }
3178
+ /**
3179
+ * Delete an agent by id. Pass `{ force: true }` to delete an agent that is
3180
+ * still referenced elsewhere (`?force=true`).
3181
+ */
3182
+ async deleteAgent(id, auth2 = SERVICE10, opts = {}) {
3183
+ await this.ctx.http.request({
3184
+ method: "DELETE",
3185
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
3186
+ auth: auth2,
3187
+ ...opts.force ? { query: { force: "true" } } : {}
3188
+ });
3189
+ }
3190
+ /** Server-side agent search (`POST /agentic/agents/search`). */
3191
+ async searchAgents(query, auth2 = SERVICE10) {
3192
+ return this.ctx.http.request({
3193
+ method: "POST",
3194
+ path: `${this.base()}/agentic/agents/search`,
3195
+ auth: auth2,
3196
+ body: query
3197
+ });
3198
+ }
3199
+ /**
3200
+ * Synchronous agent chat (`POST /agentic/chat`). Returns the response
3201
+ * ARRAY verbatim (the upstream contract is an array, not a single object).
3202
+ */
3203
+ async chat(input, auth2 = SERVICE10) {
3204
+ return this.ctx.http.request({
3205
+ method: "POST",
3206
+ path: `${this.base()}/agentic/chat`,
3207
+ auth: auth2,
3208
+ body: input
3209
+ });
3210
+ }
3211
+ /**
3212
+ * Fire-and-forget agent chat (`POST /agentic/chat-async`, HTTP 201).
3213
+ * Returns the job-id ARRAY verbatim.
3214
+ */
3215
+ async chatAsync(input, auth2 = SERVICE10) {
3216
+ return this.ctx.http.request({
3217
+ method: "POST",
3218
+ path: `${this.base()}/agentic/chat-async`,
3219
+ auth: auth2,
3220
+ body: input
3221
+ });
3222
+ }
3223
+ };
3224
+
2388
3225
  // package.json
2389
- var version = "2.2.0";
3226
+ var version = "2.3.0";
2390
3227
 
2391
3228
  // src/version.ts
2392
3229
  var SDK_VERSION = version;
@@ -2413,6 +3250,13 @@ var EmporixClient = class {
2413
3250
  availability;
2414
3251
  tenantConfig;
2415
3252
  clientConfig;
3253
+ shoppingLists;
3254
+ ragIndexer;
3255
+ sequentialIds;
3256
+ fees;
3257
+ webhooks;
3258
+ schemas;
3259
+ ai;
2416
3260
  /** The validated tenant this client is bound to. */
2417
3261
  tenant;
2418
3262
  /**
@@ -2485,6 +3329,13 @@ var EmporixClient = class {
2485
3329
  this.availability = new AvailabilityService(mk("availability"));
2486
3330
  this.tenantConfig = new TenantConfigService(mk("configuration"));
2487
3331
  this.clientConfig = new ClientConfigService(mk("configuration"));
3332
+ this.shoppingLists = new ShoppingListService(mk("shopping-list"));
3333
+ this.ragIndexer = new RagIndexerService(mk("ai-rag-indexer"));
3334
+ this.sequentialIds = new SequentialIdService(mk("sequential-id"));
3335
+ this.fees = new FeeService(mk("fee"));
3336
+ this.webhooks = new WebhookService(mk("webhook"));
3337
+ this.schemas = new SchemaService(mk("schema"));
3338
+ this.ai = new AiService(mk("ai"));
2488
3339
  }
2489
3340
  /** Sets the runtime log level globally or for one service. */
2490
3341
  setLogLevel(level, opts = {}) {
@@ -2496,6 +3347,7 @@ var EmporixClient = class {
2496
3347
  }
2497
3348
  };
2498
3349
 
3350
+ exports.AiService = AiService;
2499
3351
  exports.AvailabilityService = AvailabilityService;
2500
3352
  exports.CartService = CartService;
2501
3353
  exports.CategoryService = CategoryService;
@@ -2515,6 +3367,7 @@ exports.EmporixInsufficientScopeError = EmporixInsufficientScopeError;
2515
3367
  exports.EmporixNotFoundError = EmporixNotFoundError;
2516
3368
  exports.EmporixServerError = EmporixServerError;
2517
3369
  exports.EmporixValidationError = EmporixValidationError;
3370
+ exports.FeeService = FeeService;
2518
3371
  exports.HttpClient = HttpClient;
2519
3372
  exports.LEVEL = LEVEL;
2520
3373
  exports.LevelResolver = LevelResolver;
@@ -2524,11 +3377,16 @@ exports.OrdersService = OrdersService;
2524
3377
  exports.PaymentGatewayService = PaymentGatewayService;
2525
3378
  exports.PriceService = PriceService;
2526
3379
  exports.ProductService = ProductService;
3380
+ exports.RagIndexerService = RagIndexerService;
2527
3381
  exports.SalesOrdersService = SalesOrdersService;
3382
+ exports.SchemaService = SchemaService;
2528
3383
  exports.SegmentService = SegmentService;
3384
+ exports.SequentialIdService = SequentialIdService;
2529
3385
  exports.SessionContextService = SessionContextService;
3386
+ exports.ShoppingListService = ShoppingListService;
2530
3387
  exports.SiteService = SiteService;
2531
3388
  exports.TenantConfigService = TenantConfigService;
3389
+ exports.WebhookService = WebhookService;
2532
3390
  exports.auth = auth;
2533
3391
  exports.createConsoleLogger = createConsoleLogger;
2534
3392
  exports.createNoopLogger = createNoopLogger;