@viu/emporix-sdk 2.1.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/dist/availability.d.cts +1 -1
  3. package/dist/availability.d.ts +1 -1
  4. package/dist/cart.d.cts +1 -1
  5. package/dist/cart.d.ts +1 -1
  6. package/dist/category.d.cts +1 -1
  7. package/dist/category.d.ts +1 -1
  8. package/dist/checkout.d.cts +1 -1
  9. package/dist/checkout.d.ts +1 -1
  10. package/dist/{chunk-JTJV7WUW.js → chunk-5JHTZBOC.js} +42 -2
  11. package/dist/chunk-5JHTZBOC.js.map +1 -0
  12. package/dist/companies.d.cts +1 -1
  13. package/dist/companies.d.ts +1 -1
  14. package/dist/contacts.d.cts +1 -1
  15. package/dist/contacts.d.ts +1 -1
  16. package/dist/{context-CGuxSb56.d.cts → context-CQFcPZnt.d.cts} +1 -1
  17. package/dist/{context-CGuxSb56.d.ts → context-CQFcPZnt.d.ts} +1 -1
  18. package/dist/customer-groups.d.cts +1 -1
  19. package/dist/customer-groups.d.ts +1 -1
  20. package/dist/customer.d.cts +1 -1
  21. package/dist/customer.d.ts +1 -1
  22. package/dist/index.cjs +1028 -6
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +2014 -3
  25. package/dist/index.d.ts +2014 -3
  26. package/dist/index.js +983 -10
  27. package/dist/index.js.map +1 -1
  28. package/dist/locations.d.cts +1 -1
  29. package/dist/locations.d.ts +1 -1
  30. package/dist/media.d.cts +1 -1
  31. package/dist/media.d.ts +1 -1
  32. package/dist/orders.d.cts +1 -1
  33. package/dist/orders.d.ts +1 -1
  34. package/dist/payment.d.cts +1 -1
  35. package/dist/payment.d.ts +1 -1
  36. package/dist/price.d.cts +1 -1
  37. package/dist/price.d.ts +1 -1
  38. package/dist/product.cjs +40 -0
  39. package/dist/product.cjs.map +1 -1
  40. package/dist/product.d.cts +14 -1
  41. package/dist/product.d.ts +14 -1
  42. package/dist/product.js +1 -1
  43. package/dist/segment.d.cts +1 -1
  44. package/dist/segment.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/dist/chunk-JTJV7WUW.js.map +0 -1
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ import { PaymentGatewayService } from './chunk-HKPZI7Y5.js';
8
8
  export { PaymentGatewayService } from './chunk-HKPZI7Y5.js';
9
9
  import { PriceService } from './chunk-SCI7D74B.js';
10
10
  export { PriceService } from './chunk-SCI7D74B.js';
11
- import { ProductService } from './chunk-JTJV7WUW.js';
12
- export { ProductService } from './chunk-JTJV7WUW.js';
11
+ import { ProductService } from './chunk-5JHTZBOC.js';
12
+ export { ProductService } from './chunk-5JHTZBOC.js';
13
13
  import { SegmentService } from './chunk-Z6PNI5VT.js';
14
14
  export { SegmentService } from './chunk-Z6PNI5VT.js';
15
15
  import { AvailabilityService } from './chunk-XMEP74BU.js';
@@ -30,7 +30,7 @@ export { CustomerGroupsService } from './chunk-SKX7KCMH.js';
30
30
  import { CustomerService } from './chunk-TLH6SLAF.js';
31
31
  export { CustomerService } from './chunk-TLH6SLAF.js';
32
32
  import './chunk-BFQ732VZ.js';
33
- import { EmporixAuthError, errorFromResponse } from './chunk-KTODT6DV.js';
33
+ import { EmporixAuthError, errorFromResponse, EmporixNotFoundError } from './chunk-KTODT6DV.js';
34
34
  export { EmporixAuthError, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNotFoundError, EmporixServerError, EmporixValidationError, errorFromResponse } from './chunk-KTODT6DV.js';
35
35
 
36
36
  // src/core/config.ts
@@ -707,12 +707,12 @@ var SessionContextService = class {
707
707
  * update). Non-404 errors propagate.
708
708
  */
709
709
  async patch(input, authCtx = ANON2) {
710
- let version = input.version;
711
- if (version === void 0) {
710
+ let version2 = input.version;
711
+ if (version2 === void 0) {
712
712
  const current = await this.get(authCtx);
713
713
  if (current === null) return false;
714
- version = current.metadata?.version;
715
- if (version === void 0) {
714
+ version2 = current.metadata?.version;
715
+ if (version2 === void 0) {
716
716
  throw new Error(
717
717
  "SessionContextService.patch: no metadata.version in server response"
718
718
  );
@@ -724,7 +724,7 @@ var SessionContextService = class {
724
724
  path: `/session-context/${this.ctx.tenant}/me/context`,
725
725
  body: {
726
726
  ...fields,
727
- metadata: { version }
727
+ metadata: { version: version2 }
728
728
  },
729
729
  auth: authCtx
730
730
  });
@@ -739,8 +739,963 @@ function isNotFound(err) {
739
739
  return false;
740
740
  }
741
741
 
742
+ // src/services/tenant-config.ts
743
+ var SERVICE = { kind: "service" };
744
+ var TenantConfigService = class {
745
+ constructor(ctx) {
746
+ this.ctx = ctx;
747
+ }
748
+ ctx;
749
+ base() {
750
+ return `/configuration/${this.ctx.tenant}/configurations`;
751
+ }
752
+ /** List tenant configurations, optionally filtered by `keys`. */
753
+ async list(opts = {}, auth2 = SERVICE) {
754
+ const query = opts.keys && opts.keys.length > 0 ? { keys: opts.keys.join(",") } : void 0;
755
+ return this.ctx.http.request({
756
+ method: "GET",
757
+ path: this.base(),
758
+ auth: auth2,
759
+ ...query ? { query } : {}
760
+ });
761
+ }
762
+ /** Retrieve one tenant configuration by key. */
763
+ async get(key, auth2 = SERVICE) {
764
+ return this.ctx.http.request({
765
+ method: "GET",
766
+ path: `${this.base()}/${encodeURIComponent(key)}`,
767
+ auth: auth2
768
+ });
769
+ }
770
+ /** Create one or more tenant configurations (array in, array out). */
771
+ async create(drafts, auth2 = SERVICE) {
772
+ return this.ctx.http.request({
773
+ method: "POST",
774
+ path: this.base(),
775
+ auth: auth2,
776
+ body: drafts
777
+ });
778
+ }
779
+ /** Update one tenant configuration by key. */
780
+ async update(key, draft, auth2 = SERVICE) {
781
+ return this.ctx.http.request({
782
+ method: "PUT",
783
+ path: `${this.base()}/${encodeURIComponent(key)}`,
784
+ auth: auth2,
785
+ body: draft
786
+ });
787
+ }
788
+ /** Delete one tenant configuration by key. */
789
+ async delete(key, auth2 = SERVICE) {
790
+ await this.ctx.http.request({
791
+ method: "DELETE",
792
+ path: `${this.base()}/${encodeURIComponent(key)}`,
793
+ auth: auth2
794
+ });
795
+ }
796
+ };
797
+
798
+ // src/services/client-config.ts
799
+ var SERVICE2 = { kind: "service" };
800
+ var ClientConfigService = class {
801
+ constructor(ctx) {
802
+ this.ctx = ctx;
803
+ }
804
+ ctx;
805
+ base(client) {
806
+ return `/configuration/${this.ctx.tenant}/clients/${encodeURIComponent(client)}/configurations`;
807
+ }
808
+ /** List a client's configurations, optionally filtered by `keys`. */
809
+ async list(client, opts = {}, auth2 = SERVICE2) {
810
+ const query = opts.keys && opts.keys.length > 0 ? { keys: opts.keys.join(",") } : void 0;
811
+ return this.ctx.http.request({
812
+ method: "GET",
813
+ path: this.base(client),
814
+ auth: auth2,
815
+ ...query ? { query } : {}
816
+ });
817
+ }
818
+ /** Retrieve one client configuration by key. */
819
+ async get(client, key, auth2 = SERVICE2) {
820
+ return this.ctx.http.request({
821
+ method: "GET",
822
+ path: `${this.base(client)}/${encodeURIComponent(key)}`,
823
+ auth: auth2
824
+ });
825
+ }
826
+ /** Create one or more client configurations. Injects `client` into each item. */
827
+ async create(client, drafts, auth2 = SERVICE2) {
828
+ const body = drafts.map((d) => ({ ...d, client }));
829
+ return this.ctx.http.request({
830
+ method: "POST",
831
+ path: this.base(client),
832
+ auth: auth2,
833
+ body
834
+ });
835
+ }
836
+ /** Update one client configuration by key. Injects `client` into the body. */
837
+ async update(client, key, draft, auth2 = SERVICE2) {
838
+ return this.ctx.http.request({
839
+ method: "PUT",
840
+ path: `${this.base(client)}/${encodeURIComponent(key)}`,
841
+ auth: auth2,
842
+ body: { ...draft, client }
843
+ });
844
+ }
845
+ /** Delete one client configuration by key. */
846
+ async delete(client, key, auth2 = SERVICE2) {
847
+ await this.ctx.http.request({
848
+ method: "DELETE",
849
+ path: `${this.base(client)}/${encodeURIComponent(key)}`,
850
+ auth: auth2
851
+ });
852
+ }
853
+ };
854
+
855
+ // src/services/shopping-list.ts
856
+ var RESERVED = /* @__PURE__ */ new Set(["customerId", "metadata"]);
857
+ var ShoppingListService = class {
858
+ constructor(ctx) {
859
+ this.ctx = ctx;
860
+ }
861
+ ctx;
862
+ base() {
863
+ return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
864
+ }
865
+ /** The caller's lists (or, with employee scope, all), normalized to an array. */
866
+ async list(auth2, opts = {}) {
867
+ const envelopes = await this.ctx.http.request({
868
+ method: "GET",
869
+ path: this.base(),
870
+ auth: auth2,
871
+ ...opts.name ? { query: { name: opts.name } } : {}
872
+ });
873
+ const out = [];
874
+ for (const env of envelopes ?? []) {
875
+ for (const [key, value] of Object.entries(env)) {
876
+ if (RESERVED.has(key) || value === null || typeof value !== "object") continue;
877
+ const v = value;
878
+ out.push({
879
+ key,
880
+ name: v.name ?? key,
881
+ items: v.items ?? [],
882
+ ...v.mixins ? { mixins: v.mixins } : {},
883
+ ...v.metadata ? { metadata: v.metadata } : {}
884
+ });
885
+ }
886
+ }
887
+ return out;
888
+ }
889
+ /** Create a list; returns the new list id. */
890
+ async create(draft, auth2) {
891
+ return this.ctx.http.request({
892
+ method: "POST",
893
+ path: this.base(),
894
+ auth: auth2,
895
+ body: draft
896
+ });
897
+ }
898
+ /** Replace the named list (low-level PUT). */
899
+ async replace(customerId, draft, auth2) {
900
+ await this.ctx.http.request({
901
+ method: "PUT",
902
+ path: `${this.base()}/${encodeURIComponent(customerId)}`,
903
+ auth: auth2,
904
+ body: draft
905
+ });
906
+ }
907
+ /** Delete the named list, or all the customer's lists when `name` is omitted. */
908
+ async delete(customerId, auth2, opts = {}) {
909
+ await this.ctx.http.request({
910
+ method: "DELETE",
911
+ path: `${this.base()}/${encodeURIComponent(customerId)}`,
912
+ auth: auth2,
913
+ ...opts.name ? { query: { name: opts.name } } : {}
914
+ });
915
+ }
916
+ async loadList(listName, auth2) {
917
+ const lists = await this.list(auth2, { name: listName });
918
+ const found = lists.find((l) => l.name === listName);
919
+ if (!found) throw new EmporixNotFoundError(`Shopping list "${listName}" not found`, 404);
920
+ return found;
921
+ }
922
+ async put(customerId, list, items, auth2) {
923
+ await this.replace(
924
+ customerId,
925
+ { name: list.name, items, ...list.mixins ? { mixins: list.mixins } : {} },
926
+ auth2
927
+ );
928
+ }
929
+ /** Add/replace an item by `productId` (read-modify-write, last-write-wins). */
930
+ async addItem(customerId, listName, item, auth2) {
931
+ const list = await this.loadList(listName, auth2);
932
+ const items = [...list.items.filter((i) => i.productId !== item.productId), item];
933
+ await this.put(customerId, list, items, auth2);
934
+ }
935
+ /** Remove an item by `productId` (no-op if absent). */
936
+ async removeItem(customerId, listName, productId, auth2) {
937
+ const list = await this.loadList(listName, auth2);
938
+ const items = list.items.filter((i) => i.productId !== productId);
939
+ await this.put(customerId, list, items, auth2);
940
+ }
941
+ /** Set an item's quantity; `quantity <= 0` removes it. Adds the item if absent. */
942
+ async setItemQuantity(customerId, listName, productId, quantity, auth2) {
943
+ if (quantity <= 0) return this.removeItem(customerId, listName, productId, auth2);
944
+ const list = await this.loadList(listName, auth2);
945
+ let items = list.items.map((i) => i.productId === productId ? { ...i, quantity } : i);
946
+ if (!items.some((i) => i.productId === productId)) items = [...items, { productId, quantity }];
947
+ await this.put(customerId, list, items, auth2);
948
+ }
949
+ };
950
+
951
+ // src/services/ai-rag-indexer.ts
952
+ var SERVICE3 = { kind: "service" };
953
+ var RagIndexerService = class {
954
+ constructor(ctx) {
955
+ this.ctx = ctx;
956
+ }
957
+ ctx;
958
+ base(type) {
959
+ return `/ai-rag-indexer/${this.ctx.tenant}/${encodeURIComponent(type)}`;
960
+ }
961
+ /** The indexable embedding field names for `type` (default `"PRODUCT"`). */
962
+ async ragMetadata(type = "PRODUCT", auth2 = SERVICE3) {
963
+ return this.ctx.http.request({
964
+ method: "GET",
965
+ path: `${this.base(type)}/rag-metadata`,
966
+ auth: auth2
967
+ });
968
+ }
969
+ /** The filterable metadata fields for `type` (default `"PRODUCT"`). */
970
+ async filterMetadata(type = "PRODUCT", auth2 = SERVICE3) {
971
+ return this.ctx.http.request({
972
+ method: "GET",
973
+ path: `${this.base(type)}/filter-metadata`,
974
+ auth: auth2
975
+ });
976
+ }
977
+ /**
978
+ * Schedule a full asynchronous re-index for `type` (default `"PRODUCT"`).
979
+ * Resolves once the rebuild is *scheduled* (HTTP 204); there is no progress
980
+ * to await or poll. Costly — avoid calling on a hot path.
981
+ */
982
+ async reindex(type = "PRODUCT", auth2 = SERVICE3) {
983
+ await this.ctx.http.request({
984
+ method: "POST",
985
+ path: `${this.base(type)}/reindex`,
986
+ auth: auth2
987
+ });
988
+ }
989
+ };
990
+
991
+ // src/services/sequential-id.ts
992
+ var SERVICE4 = { kind: "service" };
993
+ var SequentialIdService = class {
994
+ constructor(ctx) {
995
+ this.ctx = ctx;
996
+ }
997
+ ctx;
998
+ base() {
999
+ return `/sequential-id/${this.ctx.tenant}/schemas`;
1000
+ }
1001
+ /** List all sequence schemas for the tenant. */
1002
+ async listSchemas(auth2 = SERVICE4) {
1003
+ return this.ctx.http.request({
1004
+ method: "GET",
1005
+ path: this.base(),
1006
+ auth: auth2
1007
+ });
1008
+ }
1009
+ /** Retrieve one sequence schema by id. */
1010
+ async getSchema(schemaId, auth2 = SERVICE4) {
1011
+ return this.ctx.http.request({
1012
+ method: "GET",
1013
+ path: `${this.base()}/${encodeURIComponent(schemaId)}`,
1014
+ auth: auth2
1015
+ });
1016
+ }
1017
+ /** Create a sequence schema. Schemas are immutable — there is no update. */
1018
+ async createSchema(schema, auth2 = SERVICE4) {
1019
+ return this.ctx.http.request({
1020
+ method: "POST",
1021
+ path: this.base(),
1022
+ auth: auth2,
1023
+ body: schema
1024
+ });
1025
+ }
1026
+ /** Delete a sequence schema by id. */
1027
+ async deleteSchema(schemaId, auth2 = SERVICE4) {
1028
+ await this.ctx.http.request({
1029
+ method: "DELETE",
1030
+ path: `${this.base()}/${encodeURIComponent(schemaId)}`,
1031
+ auth: auth2
1032
+ });
1033
+ }
1034
+ /** Mark a schema active for its type (only one schema may be active per type). */
1035
+ async setActiveSchema(schemaId, auth2 = SERVICE4) {
1036
+ await this.ctx.http.request({
1037
+ method: "POST",
1038
+ path: `${this.base()}/${encodeURIComponent(schemaId)}/setActive`,
1039
+ auth: auth2
1040
+ });
1041
+ }
1042
+ /** Get the active schema for a given schema type. */
1043
+ async listSchemasByType(schemaType, auth2 = SERVICE4) {
1044
+ return this.ctx.http.request({
1045
+ method: "GET",
1046
+ path: `${this.base()}/types/${encodeURIComponent(schemaType)}`,
1047
+ auth: auth2
1048
+ });
1049
+ }
1050
+ /**
1051
+ * Generate the next id for a schema type. `body` carries an optional
1052
+ * `sequenceKey` (independent sub-pool counter) and `placeholders`.
1053
+ * `opts.siteCode` derives time/country placeholders from the site's settings.
1054
+ */
1055
+ async nextId(schemaType, body = {}, opts = {}, auth2 = SERVICE4) {
1056
+ const query = opts.siteCode ? { siteCode: opts.siteCode } : void 0;
1057
+ return this.ctx.http.request({
1058
+ method: "POST",
1059
+ path: `${this.base()}/types/${encodeURIComponent(schemaType)}/nextId`,
1060
+ auth: auth2,
1061
+ body,
1062
+ ...query ? { query } : {}
1063
+ });
1064
+ }
1065
+ /**
1066
+ * Generate next ids for multiple schema types in one call. NOTE: the batch
1067
+ * endpoint path omits the `{tenant}` segment — the service derives the
1068
+ * tenant from the token.
1069
+ */
1070
+ async nextIdsBatch(req, auth2 = SERVICE4) {
1071
+ return this.ctx.http.request({
1072
+ method: "POST",
1073
+ path: `/sequential-id/sequenceSchemaBatch/nextIds`,
1074
+ auth: auth2,
1075
+ body: req
1076
+ });
1077
+ }
1078
+ };
1079
+
1080
+ // src/services/fee.ts
1081
+ var SERVICE5 = { kind: "service" };
1082
+ var FeeService = class {
1083
+ constructor(ctx) {
1084
+ this.ctx = ctx;
1085
+ }
1086
+ ctx;
1087
+ feesBase() {
1088
+ return `/fee/${this.ctx.tenant}/fees`;
1089
+ }
1090
+ itemFeesBase() {
1091
+ return `/fee/${this.ctx.tenant}/itemFees`;
1092
+ }
1093
+ productFeesBase() {
1094
+ return `/fee/${this.ctx.tenant}/productFees`;
1095
+ }
1096
+ // --- Fee definitions ---
1097
+ /**
1098
+ * List fee definitions, wrapped in the shared {@link PaginatedItems}
1099
+ * envelope (same heuristic as `media.list`: `hasNextPage` is true when the
1100
+ * returned page is full). Defaults match Emporix server defaults
1101
+ * (`pageNumber: 1`, `pageSize: 60`).
1102
+ */
1103
+ async list(query = {}, auth2 = SERVICE5) {
1104
+ const pageNumber = query.pageNumber ?? 1;
1105
+ const pageSize = query.pageSize ?? 60;
1106
+ const items = await this.ctx.http.request({
1107
+ method: "GET",
1108
+ path: this.feesBase(),
1109
+ auth: auth2,
1110
+ query: { ...query, pageNumber, pageSize }
1111
+ });
1112
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1113
+ }
1114
+ /** Retrieve one fee definition by id. */
1115
+ async get(id, auth2 = SERVICE5) {
1116
+ return this.ctx.http.request({
1117
+ method: "GET",
1118
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
1119
+ auth: auth2
1120
+ });
1121
+ }
1122
+ /** Create a fee definition. */
1123
+ async create(draft, auth2 = SERVICE5) {
1124
+ return this.ctx.http.request({
1125
+ method: "POST",
1126
+ path: this.feesBase(),
1127
+ auth: auth2,
1128
+ body: draft
1129
+ });
1130
+ }
1131
+ /** Update a fee definition by id. */
1132
+ async update(id, draft, auth2 = SERVICE5) {
1133
+ return this.ctx.http.request({
1134
+ method: "PUT",
1135
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
1136
+ auth: auth2,
1137
+ body: draft
1138
+ });
1139
+ }
1140
+ /** Delete a fee definition by id. */
1141
+ async delete(id, auth2 = SERVICE5) {
1142
+ await this.ctx.http.request({
1143
+ method: "DELETE",
1144
+ path: `${this.feesBase()}/${encodeURIComponent(id)}`,
1145
+ auth: auth2
1146
+ });
1147
+ }
1148
+ // --- Item-fee mappings ---
1149
+ /** List all item-fee mappings. */
1150
+ async listItemFees(auth2 = SERVICE5) {
1151
+ return this.ctx.http.request({
1152
+ method: "GET",
1153
+ path: this.itemFeesBase(),
1154
+ auth: auth2
1155
+ });
1156
+ }
1157
+ /** Fee mappings for one item YRN. */
1158
+ async getItemFees(itemYrn, auth2 = SERVICE5) {
1159
+ return this.ctx.http.request({
1160
+ method: "GET",
1161
+ path: `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`,
1162
+ auth: auth2
1163
+ });
1164
+ }
1165
+ /** Create an item-fee mapping. */
1166
+ async createItemFee(draft, auth2 = SERVICE5) {
1167
+ return this.ctx.http.request({
1168
+ method: "POST",
1169
+ path: this.itemFeesBase(),
1170
+ auth: auth2,
1171
+ body: draft
1172
+ });
1173
+ }
1174
+ /**
1175
+ * Set the fee list for an item YRN. Destructive replace by default; pass
1176
+ * `{ partial: true }` to merge (`?partial=true`).
1177
+ */
1178
+ async setItemFees(itemYrn, feeIds, opts = {}, auth2 = SERVICE5) {
1179
+ return this.ctx.http.request({
1180
+ method: "PUT",
1181
+ path: `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`,
1182
+ auth: auth2,
1183
+ body: { feeIds },
1184
+ ...opts.partial ? { query: { partial: "true" } } : {}
1185
+ });
1186
+ }
1187
+ /**
1188
+ * Delete item-fee mappings for a YRN. Without `feeId`, removes all mappings
1189
+ * for the YRN; with `feeId`, removes that single fee from the mapping.
1190
+ */
1191
+ async deleteItemFees(itemYrn, feeId, auth2 = SERVICE5) {
1192
+ const base = `${this.itemFeesBase()}/${encodeURIComponent(itemYrn)}/fees`;
1193
+ await this.ctx.http.request({
1194
+ method: "DELETE",
1195
+ path: feeId ? `${base}/${encodeURIComponent(feeId)}` : base,
1196
+ auth: auth2
1197
+ });
1198
+ }
1199
+ /** Search item-fee mappings by item YRNs + site. */
1200
+ async searchItemFees(search, auth2 = SERVICE5) {
1201
+ return this.ctx.http.request({
1202
+ method: "POST",
1203
+ path: `${this.itemFeesBase()}/search`,
1204
+ auth: auth2,
1205
+ body: search
1206
+ });
1207
+ }
1208
+ // --- Product-fee mappings ---
1209
+ /** Fee mappings for a product id. */
1210
+ async getProductFees(productId, auth2 = SERVICE5) {
1211
+ return this.ctx.http.request({
1212
+ method: "GET",
1213
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
1214
+ auth: auth2
1215
+ });
1216
+ }
1217
+ /**
1218
+ * Set the fee list for a product id. Destructive replace by default; pass
1219
+ * `{ partial: true }` to merge (`?partial=true`).
1220
+ */
1221
+ async setProductFees(productId, feeIds, opts = {}, auth2 = SERVICE5) {
1222
+ return this.ctx.http.request({
1223
+ method: "PUT",
1224
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
1225
+ auth: auth2,
1226
+ body: { feeIds },
1227
+ ...opts.partial ? { query: { partial: "true" } } : {}
1228
+ });
1229
+ }
1230
+ /** Delete all fee mappings for a product id. */
1231
+ async deleteProductFees(productId, auth2 = SERVICE5) {
1232
+ await this.ctx.http.request({
1233
+ method: "DELETE",
1234
+ path: `${this.productFeesBase()}/${encodeURIComponent(productId)}/fees`,
1235
+ auth: auth2
1236
+ });
1237
+ }
1238
+ };
1239
+
1240
+ // src/services/webhook.ts
1241
+ var SERVICE6 = { kind: "service" };
1242
+ var WebhookService = class {
1243
+ constructor(ctx) {
1244
+ this.ctx = ctx;
1245
+ }
1246
+ ctx;
1247
+ base() {
1248
+ return `/webhook/${this.ctx.tenant}`;
1249
+ }
1250
+ /** List the event-subscription catalog with each event's on/off state. */
1251
+ async listEventSubscriptions(auth2 = SERVICE6) {
1252
+ return this.ctx.http.request({
1253
+ method: "GET",
1254
+ path: `${this.base()}/event-subscriptions`,
1255
+ auth: auth2
1256
+ });
1257
+ }
1258
+ /**
1259
+ * Batch subscribe/unsubscribe events. Returns the **207** per-item result
1260
+ * array verbatim — the batch can partially fail, so inspect each element's
1261
+ * `code`/`status` (e.g. `results.filter(r => (r.code ?? 0) >= 400)`). Does
1262
+ * NOT throw on a 207 with failed items; only a non-2xx HTTP status throws.
1263
+ */
1264
+ async updateEventSubscriptions(items, auth2 = SERVICE6) {
1265
+ return this.ctx.http.request({
1266
+ method: "PATCH",
1267
+ path: `${this.base()}/event-subscriptions`,
1268
+ auth: auth2,
1269
+ body: items
1270
+ });
1271
+ }
1272
+ /** List delivery configurations. */
1273
+ async listConfigs(auth2 = SERVICE6) {
1274
+ return this.ctx.http.request({
1275
+ method: "GET",
1276
+ path: `${this.base()}/config`,
1277
+ auth: auth2
1278
+ });
1279
+ }
1280
+ /** Retrieve one delivery configuration by code. */
1281
+ async getConfig(code, auth2 = SERVICE6) {
1282
+ return this.ctx.http.request({
1283
+ method: "GET",
1284
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
1285
+ auth: auth2
1286
+ });
1287
+ }
1288
+ /** Create a delivery configuration. Returns the server-assigned `{ code }`. */
1289
+ async createConfig(draft, auth2 = SERVICE6) {
1290
+ return this.ctx.http.request({
1291
+ method: "POST",
1292
+ path: `${this.base()}/config`,
1293
+ auth: auth2,
1294
+ body: draft
1295
+ });
1296
+ }
1297
+ /** Replace a delivery configuration by code (204). */
1298
+ async replaceConfig(code, draft, auth2 = SERVICE6) {
1299
+ await this.ctx.http.request({
1300
+ method: "PUT",
1301
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
1302
+ auth: auth2,
1303
+ body: draft
1304
+ });
1305
+ }
1306
+ /**
1307
+ * Partially update a delivery configuration by code (204). The body is an
1308
+ * **array** of `{ op, path, value }` operations (UPSERT / REMOVE).
1309
+ */
1310
+ async patchConfig(code, patches, auth2 = SERVICE6) {
1311
+ await this.ctx.http.request({
1312
+ method: "PATCH",
1313
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
1314
+ auth: auth2,
1315
+ body: patches
1316
+ });
1317
+ }
1318
+ /**
1319
+ * Delete a delivery configuration by code. Pass `{ force: true }` to delete
1320
+ * the currently-active config (the server otherwise rejects it).
1321
+ */
1322
+ async deleteConfig(code, opts = {}, auth2 = SERVICE6) {
1323
+ await this.ctx.http.request({
1324
+ method: "DELETE",
1325
+ path: `${this.base()}/config/${encodeURIComponent(code)}`,
1326
+ auth: auth2,
1327
+ ...opts.force === true ? { query: { force: "true" } } : {}
1328
+ });
1329
+ }
1330
+ /** Read delivery statistics over an optional `YYYY-MM` range. */
1331
+ async getStatistics(query = {}, auth2 = SERVICE6) {
1332
+ const q = {};
1333
+ if (query.fromYearMonth) q.fromYearMonth = query.fromYearMonth;
1334
+ if (query.toYearMonth) q.toYearMonth = query.toYearMonth;
1335
+ return this.ctx.http.request({
1336
+ method: "GET",
1337
+ path: `${this.base()}/statistics`,
1338
+ auth: auth2,
1339
+ ...Object.keys(q).length > 0 ? { query: q } : {}
1340
+ });
1341
+ }
1342
+ /** Obtain Svix dashboard access (URL / token). */
1343
+ async getDashboardAccess(auth2 = SERVICE6) {
1344
+ return this.ctx.http.request({
1345
+ method: "GET",
1346
+ path: `${this.base()}/dashboard-access`,
1347
+ auth: auth2
1348
+ });
1349
+ }
1350
+ };
1351
+
1352
+ // src/services/schema.ts
1353
+ var SERVICE7 = { kind: "service" };
1354
+ var SchemaService = class {
1355
+ constructor(ctx) {
1356
+ this.ctx = ctx;
1357
+ }
1358
+ ctx;
1359
+ schemasBase() {
1360
+ return `/schema/${this.ctx.tenant}/schemas`;
1361
+ }
1362
+ entitiesBase() {
1363
+ return `/schema/${this.ctx.tenant}/custom-entities`;
1364
+ }
1365
+ instancesBase(type) {
1366
+ return `${this.entitiesBase()}/${encodeURIComponent(type)}/instances`;
1367
+ }
1368
+ // --- (A) Schemas ---------------------------------------------------------
1369
+ /**
1370
+ * List schemas, wrapped in the shared {@link PaginatedItems} envelope.
1371
+ * `hasNextPage` is the standard SDK heuristic (`items.length === pageSize`).
1372
+ * Pagination defaults match the rest of the SDK (`pageNumber: 1`,
1373
+ * `pageSize: 60`).
1374
+ */
1375
+ async listSchemas(query = {}, auth2 = SERVICE7) {
1376
+ const pageNumber = query.pageNumber ?? 1;
1377
+ const pageSize = query.pageSize ?? 60;
1378
+ const q = { pageNumber, pageSize };
1379
+ if (query.q) q.q = query.q;
1380
+ if (query.type) q.type = query.type;
1381
+ const items = await this.ctx.http.request({
1382
+ method: "GET",
1383
+ path: this.schemasBase(),
1384
+ auth: auth2,
1385
+ query: q
1386
+ });
1387
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1388
+ }
1389
+ /** Retrieve one schema by id. */
1390
+ async getSchema(id, auth2 = SERVICE7) {
1391
+ return this.ctx.http.request({
1392
+ method: "GET",
1393
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
1394
+ auth: auth2
1395
+ });
1396
+ }
1397
+ /** Create a schema. */
1398
+ async createSchema(draft, auth2 = SERVICE7) {
1399
+ return this.ctx.http.request({
1400
+ method: "POST",
1401
+ path: this.schemasBase(),
1402
+ auth: auth2,
1403
+ body: draft
1404
+ });
1405
+ }
1406
+ /**
1407
+ * Update a schema. The upstream API requires `draft.metadata.version`; a
1408
+ * stale version yields 409 Conflict (propagated as the standard conflict
1409
+ * error).
1410
+ */
1411
+ async updateSchema(id, draft, auth2 = SERVICE7) {
1412
+ return this.ctx.http.request({
1413
+ method: "PUT",
1414
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
1415
+ auth: auth2,
1416
+ body: draft
1417
+ });
1418
+ }
1419
+ /** Delete a schema by id. */
1420
+ async deleteSchema(id, auth2 = SERVICE7) {
1421
+ await this.ctx.http.request({
1422
+ method: "DELETE",
1423
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}`,
1424
+ auth: auth2
1425
+ });
1426
+ }
1427
+ /**
1428
+ * Validate a schema document without persisting it (`POST /schemas/file`).
1429
+ * Returns the server's validation result verbatim.
1430
+ */
1431
+ async validateSchemaFile(body, auth2 = SERVICE7) {
1432
+ return this.ctx.http.request({
1433
+ method: "POST",
1434
+ path: `${this.schemasBase()}/file`,
1435
+ auth: auth2,
1436
+ body
1437
+ });
1438
+ }
1439
+ // --- (B) Types -----------------------------------------------------------
1440
+ /** List entity types that currently have at least one schema. */
1441
+ async listTypes(auth2 = SERVICE7) {
1442
+ return this.ctx.http.request({
1443
+ method: "GET",
1444
+ path: `/schema/${this.ctx.tenant}/types`,
1445
+ auth: auth2
1446
+ });
1447
+ }
1448
+ /** Set the entity types a schema applies to (`PUT /schemas/{id}/types`). */
1449
+ async setSchemaTypes(id, types, auth2 = SERVICE7) {
1450
+ return this.ctx.http.request({
1451
+ method: "PUT",
1452
+ path: `${this.schemasBase()}/${encodeURIComponent(id)}/types`,
1453
+ auth: auth2,
1454
+ body: { types }
1455
+ });
1456
+ }
1457
+ // --- (C) Custom entities -------------------------------------------------
1458
+ /** List custom-entity definitions. `expandSchemas` inlines each schema body. */
1459
+ async listCustomEntities(opts = {}, auth2 = SERVICE7) {
1460
+ return this.ctx.http.request({
1461
+ method: "GET",
1462
+ path: this.entitiesBase(),
1463
+ auth: auth2,
1464
+ ...opts.expandSchemas ? { query: { expandSchemas: "true" } } : {}
1465
+ });
1466
+ }
1467
+ /** Retrieve one custom-entity definition by id. */
1468
+ async getCustomEntity(id, auth2 = SERVICE7) {
1469
+ return this.ctx.http.request({
1470
+ method: "GET",
1471
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
1472
+ auth: auth2
1473
+ });
1474
+ }
1475
+ /** Create a custom-entity definition. */
1476
+ async createCustomEntity(draft, auth2 = SERVICE7) {
1477
+ return this.ctx.http.request({
1478
+ method: "POST",
1479
+ path: this.entitiesBase(),
1480
+ auth: auth2,
1481
+ body: draft
1482
+ });
1483
+ }
1484
+ /** Update a custom-entity definition. */
1485
+ async updateCustomEntity(id, draft, auth2 = SERVICE7) {
1486
+ return this.ctx.http.request({
1487
+ method: "PUT",
1488
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
1489
+ auth: auth2,
1490
+ body: draft
1491
+ });
1492
+ }
1493
+ /**
1494
+ * Delete a custom-entity definition. The server rejects with 409 if
1495
+ * instances or schemas still reference it (propagated as the standard
1496
+ * conflict error).
1497
+ */
1498
+ async deleteCustomEntity(id, auth2 = SERVICE7) {
1499
+ await this.ctx.http.request({
1500
+ method: "DELETE",
1501
+ path: `${this.entitiesBase()}/${encodeURIComponent(id)}`,
1502
+ auth: auth2
1503
+ });
1504
+ }
1505
+ // --- (D) Custom instances ------------------------------------------------
1506
+ /**
1507
+ * List a custom entity's instances, wrapped in {@link PaginatedItems}.
1508
+ * `type` is the custom-entity type and is always the first argument.
1509
+ */
1510
+ async listInstances(type, query = {}, auth2 = SERVICE7) {
1511
+ const pageNumber = query.pageNumber ?? 1;
1512
+ const pageSize = query.pageSize ?? 60;
1513
+ const items = await this.ctx.http.request({
1514
+ method: "GET",
1515
+ path: this.instancesBase(type),
1516
+ auth: auth2,
1517
+ query: { ...query, pageNumber, pageSize }
1518
+ });
1519
+ return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
1520
+ }
1521
+ /** Retrieve one instance by id. */
1522
+ async getInstance(type, id, auth2 = SERVICE7) {
1523
+ return this.ctx.http.request({
1524
+ method: "GET",
1525
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
1526
+ auth: auth2
1527
+ });
1528
+ }
1529
+ /** Create an instance of a custom entity. */
1530
+ async createInstance(type, draft, auth2 = SERVICE7) {
1531
+ return this.ctx.http.request({
1532
+ method: "POST",
1533
+ path: this.instancesBase(type),
1534
+ auth: auth2,
1535
+ body: draft
1536
+ });
1537
+ }
1538
+ /** Replace an instance (full `PUT`). */
1539
+ async replaceInstance(type, id, draft, auth2 = SERVICE7) {
1540
+ return this.ctx.http.request({
1541
+ method: "PUT",
1542
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
1543
+ auth: auth2,
1544
+ body: draft
1545
+ });
1546
+ }
1547
+ /** Partially update an instance (`PATCH`). */
1548
+ async patchInstance(type, id, patch, auth2 = SERVICE7) {
1549
+ return this.ctx.http.request({
1550
+ method: "PATCH",
1551
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
1552
+ auth: auth2,
1553
+ body: patch
1554
+ });
1555
+ }
1556
+ /** Delete an instance by id. */
1557
+ async deleteInstance(type, id, auth2 = SERVICE7) {
1558
+ await this.ctx.http.request({
1559
+ method: "DELETE",
1560
+ path: `${this.instancesBase(type)}/${encodeURIComponent(id)}`,
1561
+ auth: auth2
1562
+ });
1563
+ }
1564
+ /**
1565
+ * Structured search over a custom entity's instances
1566
+ * (`POST /instances/search`), wrapped in {@link PaginatedItems}.
1567
+ */
1568
+ async searchInstances(type, body, auth2 = SERVICE7) {
1569
+ const items = await this.ctx.http.request({
1570
+ method: "POST",
1571
+ path: `${this.instancesBase(type)}/search`,
1572
+ auth: auth2,
1573
+ body
1574
+ });
1575
+ return { items, pageNumber: 1, pageSize: items.length, hasNextPage: false };
1576
+ }
1577
+ };
1578
+
1579
+ // src/services/ai.ts
1580
+ var SERVICE8 = { kind: "service" };
1581
+ var AiService = class {
1582
+ constructor(ctx) {
1583
+ this.ctx = ctx;
1584
+ }
1585
+ ctx;
1586
+ base() {
1587
+ return `/ai-service/${this.ctx.tenant}`;
1588
+ }
1589
+ /** Generate text from a single prompt (`POST /texts`). Honors `maxTokens`. */
1590
+ async generateText(input, auth2 = SERVICE8) {
1591
+ return this.ctx.http.request({
1592
+ method: "POST",
1593
+ path: `${this.base()}/texts`,
1594
+ auth: auth2,
1595
+ body: input
1596
+ });
1597
+ }
1598
+ /** Run a chat completion over a message list (`POST /completions`). No `maxTokens`. */
1599
+ async complete(input, auth2 = SERVICE8) {
1600
+ return this.ctx.http.request({
1601
+ method: "POST",
1602
+ path: `${this.base()}/completions`,
1603
+ auth: auth2,
1604
+ body: input
1605
+ });
1606
+ }
1607
+ /** List all agentic agents. */
1608
+ async listAgents(auth2 = SERVICE8) {
1609
+ return this.ctx.http.request({
1610
+ method: "GET",
1611
+ path: `${this.base()}/agentic/agents`,
1612
+ auth: auth2
1613
+ });
1614
+ }
1615
+ /** Retrieve one agent by id. */
1616
+ async getAgent(id, auth2 = SERVICE8) {
1617
+ return this.ctx.http.request({
1618
+ method: "GET",
1619
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
1620
+ auth: auth2
1621
+ });
1622
+ }
1623
+ /** Create-or-replace an agent by id (`PUT`). Takes the agent write shape. */
1624
+ async upsertAgent(id, agent, auth2 = SERVICE8) {
1625
+ return this.ctx.http.request({
1626
+ method: "PUT",
1627
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
1628
+ auth: auth2,
1629
+ body: agent
1630
+ });
1631
+ }
1632
+ /**
1633
+ * Patch an agent with an op array (`PATCH`). `ops` use the upstream
1634
+ * UPPERCASE enum (`ADD | REMOVE | REPLACE`) and are sent verbatim — this is
1635
+ * NOT RFC-6902 JSON-Patch.
1636
+ */
1637
+ async patchAgent(id, ops, auth2 = SERVICE8) {
1638
+ return this.ctx.http.request({
1639
+ method: "PATCH",
1640
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
1641
+ auth: auth2,
1642
+ body: ops
1643
+ });
1644
+ }
1645
+ /**
1646
+ * Delete an agent by id. Pass `{ force: true }` to delete an agent that is
1647
+ * still referenced elsewhere (`?force=true`).
1648
+ */
1649
+ async deleteAgent(id, auth2 = SERVICE8, opts = {}) {
1650
+ await this.ctx.http.request({
1651
+ method: "DELETE",
1652
+ path: `${this.base()}/agentic/agents/${encodeURIComponent(id)}`,
1653
+ auth: auth2,
1654
+ ...opts.force ? { query: { force: "true" } } : {}
1655
+ });
1656
+ }
1657
+ /** Server-side agent search (`POST /agentic/agents/search`). */
1658
+ async searchAgents(query, auth2 = SERVICE8) {
1659
+ return this.ctx.http.request({
1660
+ method: "POST",
1661
+ path: `${this.base()}/agentic/agents/search`,
1662
+ auth: auth2,
1663
+ body: query
1664
+ });
1665
+ }
1666
+ /**
1667
+ * Synchronous agent chat (`POST /agentic/chat`). Returns the response
1668
+ * ARRAY verbatim (the upstream contract is an array, not a single object).
1669
+ */
1670
+ async chat(input, auth2 = SERVICE8) {
1671
+ return this.ctx.http.request({
1672
+ method: "POST",
1673
+ path: `${this.base()}/agentic/chat`,
1674
+ auth: auth2,
1675
+ body: input
1676
+ });
1677
+ }
1678
+ /**
1679
+ * Fire-and-forget agent chat (`POST /agentic/chat-async`, HTTP 201).
1680
+ * Returns the job-id ARRAY verbatim.
1681
+ */
1682
+ async chatAsync(input, auth2 = SERVICE8) {
1683
+ return this.ctx.http.request({
1684
+ method: "POST",
1685
+ path: `${this.base()}/agentic/chat-async`,
1686
+ auth: auth2,
1687
+ body: input
1688
+ });
1689
+ }
1690
+ };
1691
+
1692
+ // package.json
1693
+ var version = "2.3.0";
1694
+
1695
+ // src/version.ts
1696
+ var SDK_VERSION = version;
1697
+
742
1698
  // src/client.ts
743
- var SDK_VERSION = "0.0.0";
744
1699
  var EmporixClient = class {
745
1700
  customers;
746
1701
  products;
@@ -760,6 +1715,15 @@ var EmporixClient = class {
760
1715
  orders;
761
1716
  salesOrders;
762
1717
  availability;
1718
+ tenantConfig;
1719
+ clientConfig;
1720
+ shoppingLists;
1721
+ ragIndexer;
1722
+ sequentialIds;
1723
+ fees;
1724
+ webhooks;
1725
+ schemas;
1726
+ ai;
763
1727
  /** The validated tenant this client is bound to. */
764
1728
  tenant;
765
1729
  /**
@@ -830,6 +1794,15 @@ var EmporixClient = class {
830
1794
  this.orders = new OrdersService(mk("orders"));
831
1795
  this.salesOrders = new SalesOrdersService(mk("sales-orders"));
832
1796
  this.availability = new AvailabilityService(mk("availability"));
1797
+ this.tenantConfig = new TenantConfigService(mk("configuration"));
1798
+ this.clientConfig = new ClientConfigService(mk("configuration"));
1799
+ this.shoppingLists = new ShoppingListService(mk("shopping-list"));
1800
+ this.ragIndexer = new RagIndexerService(mk("ai-rag-indexer"));
1801
+ this.sequentialIds = new SequentialIdService(mk("sequential-id"));
1802
+ this.fees = new FeeService(mk("fee"));
1803
+ this.webhooks = new WebhookService(mk("webhook"));
1804
+ this.schemas = new SchemaService(mk("schema"));
1805
+ this.ai = new AiService(mk("ai"));
833
1806
  }
834
1807
  /** Sets the runtime log level globally or for one service. */
835
1808
  setLogLevel(level, opts = {}) {
@@ -841,6 +1814,6 @@ var EmporixClient = class {
841
1814
  }
842
1815
  };
843
1816
 
844
- export { DEFAULT_HOST, DefaultTokenProvider, EmporixClient, HttpClient, LEVEL, LevelResolver, SessionContextService, SiteService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
1817
+ export { AiService, ClientConfigService, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, LEVEL, LevelResolver, RagIndexerService, SchemaService, SequentialIdService, SessionContextService, ShoppingListService, SiteService, TenantConfigService, WebhookService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
845
1818
  //# sourceMappingURL=index.js.map
846
1819
  //# sourceMappingURL=index.js.map