@viu/emporix-sdk 2.2.0 → 2.4.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.js CHANGED
@@ -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
@@ -852,8 +852,2130 @@ var ClientConfigService = class {
852
852
  }
853
853
  };
854
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
+ // src/services/tax.ts
1693
+ var SERVICE9 = { kind: "service" };
1694
+ var TaxService = class {
1695
+ constructor(ctx) {
1696
+ this.ctx = ctx;
1697
+ }
1698
+ ctx;
1699
+ base() {
1700
+ return `/tax/${this.ctx.tenant}`;
1701
+ }
1702
+ /** List all per-location tax configurations. */
1703
+ async listTaxConfigs(auth2 = SERVICE9) {
1704
+ return this.ctx.http.request({
1705
+ method: "GET",
1706
+ path: `${this.base()}/taxes`,
1707
+ auth: auth2
1708
+ });
1709
+ }
1710
+ /** Retrieve one tax configuration by its location (country) code. */
1711
+ async getTaxConfig(locationCode, auth2 = SERVICE9) {
1712
+ return this.ctx.http.request({
1713
+ method: "GET",
1714
+ path: `${this.base()}/taxes/${encodeURIComponent(locationCode)}`,
1715
+ auth: auth2
1716
+ });
1717
+ }
1718
+ /** Create a tax configuration (`POST`). Returns the created `{ locationCode }`. */
1719
+ async createTaxConfig(input, auth2 = SERVICE9) {
1720
+ return this.ctx.http.request({
1721
+ method: "POST",
1722
+ path: `${this.base()}/taxes`,
1723
+ auth: auth2,
1724
+ body: input
1725
+ });
1726
+ }
1727
+ /**
1728
+ * Update a tax configuration by location code (`PUT`). `metadata.version` is
1729
+ * required (optimistic locking — a stale version yields 409).
1730
+ */
1731
+ async updateTaxConfig(locationCode, input, auth2 = SERVICE9) {
1732
+ return this.ctx.http.request({
1733
+ method: "PUT",
1734
+ path: `${this.base()}/taxes/${encodeURIComponent(locationCode)}`,
1735
+ auth: auth2,
1736
+ body: input
1737
+ });
1738
+ }
1739
+ /** Delete a tax configuration by location code. */
1740
+ async deleteTaxConfig(locationCode, auth2 = SERVICE9) {
1741
+ await this.ctx.http.request({
1742
+ method: "DELETE",
1743
+ path: `${this.base()}/taxes/${encodeURIComponent(locationCode)}`,
1744
+ auth: auth2
1745
+ });
1746
+ }
1747
+ /**
1748
+ * Calculate net/gross values for a price (`PUT /taxes/calculation-commands`).
1749
+ * Single command in, single result out.
1750
+ */
1751
+ async calculateTax(request, auth2 = SERVICE9) {
1752
+ return this.ctx.http.request({
1753
+ method: "PUT",
1754
+ path: `${this.base()}/taxes/calculation-commands`,
1755
+ auth: auth2,
1756
+ body: request
1757
+ });
1758
+ }
1759
+ };
1760
+
1761
+ // src/services/coupon.ts
1762
+ var SERVICE10 = { kind: "service" };
1763
+ var CouponService = class {
1764
+ constructor(ctx) {
1765
+ this.ctx = ctx;
1766
+ }
1767
+ ctx;
1768
+ base() {
1769
+ return `/coupon/${this.ctx.tenant}`;
1770
+ }
1771
+ /** List coupons by criteria. Returns a plain array. */
1772
+ async listCoupons(query = {}, auth2 = SERVICE10) {
1773
+ return this.ctx.http.request({
1774
+ method: "GET",
1775
+ path: `${this.base()}/coupons`,
1776
+ auth: auth2,
1777
+ ...Object.keys(query).length ? { query } : {}
1778
+ });
1779
+ }
1780
+ /** Retrieve one coupon by code. */
1781
+ async getCoupon(code, auth2 = SERVICE10) {
1782
+ return this.ctx.http.request({
1783
+ method: "GET",
1784
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}`,
1785
+ auth: auth2
1786
+ });
1787
+ }
1788
+ /** Create a coupon (`POST`, HTTP 201). Returns the created resource's `{ id?, yrn? }`. */
1789
+ async createCoupon(input, auth2 = SERVICE10) {
1790
+ return this.ctx.http.request({
1791
+ method: "POST",
1792
+ path: `${this.base()}/coupons`,
1793
+ auth: auth2,
1794
+ body: input
1795
+ });
1796
+ }
1797
+ /** Replace a coupon by code (`PUT`). Resolves once the update is accepted. */
1798
+ async updateCoupon(code, input, auth2 = SERVICE10) {
1799
+ await this.ctx.http.request({
1800
+ method: "PUT",
1801
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}`,
1802
+ auth: auth2,
1803
+ body: input
1804
+ });
1805
+ }
1806
+ /** Partially update a coupon by code (`PATCH` merge body). */
1807
+ async patchCoupon(code, patch, auth2 = SERVICE10) {
1808
+ await this.ctx.http.request({
1809
+ method: "PATCH",
1810
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}`,
1811
+ auth: auth2,
1812
+ body: patch
1813
+ });
1814
+ }
1815
+ /** Delete a coupon by code. */
1816
+ async deleteCoupon(code, auth2 = SERVICE10) {
1817
+ await this.ctx.http.request({
1818
+ method: "DELETE",
1819
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}`,
1820
+ auth: auth2
1821
+ });
1822
+ }
1823
+ /**
1824
+ * Check whether a coupon can be redeemed (`POST /validation`). Resolves when
1825
+ * redeemable; throws an `EmporixError` otherwise (no response body).
1826
+ */
1827
+ async validateCoupon(code, redemption, auth2 = SERVICE10) {
1828
+ await this.ctx.http.request({
1829
+ method: "POST",
1830
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}/validation`,
1831
+ auth: auth2,
1832
+ body: redemption
1833
+ });
1834
+ }
1835
+ /** List a coupon's redemptions by criteria. */
1836
+ async listRedemptions(code, query = {}, auth2 = SERVICE10) {
1837
+ return this.ctx.http.request({
1838
+ method: "GET",
1839
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}/redemptions`,
1840
+ auth: auth2,
1841
+ ...Object.keys(query).length ? { query } : {}
1842
+ });
1843
+ }
1844
+ /** Redeem a coupon by creating a redemption (`POST`, HTTP 201). Returns the resource location. */
1845
+ async redeemCoupon(code, redemption, auth2 = SERVICE10) {
1846
+ return this.ctx.http.request({
1847
+ method: "POST",
1848
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}/redemptions`,
1849
+ auth: auth2,
1850
+ body: redemption
1851
+ });
1852
+ }
1853
+ /** Retrieve one redemption by id. */
1854
+ async getRedemption(code, id, auth2 = SERVICE10) {
1855
+ return this.ctx.http.request({
1856
+ method: "GET",
1857
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}/redemptions/${encodeURIComponent(id)}`,
1858
+ auth: auth2
1859
+ });
1860
+ }
1861
+ /** Delete a redemption by id. */
1862
+ async deleteRedemption(code, id, auth2 = SERVICE10) {
1863
+ await this.ctx.http.request({
1864
+ method: "DELETE",
1865
+ path: `${this.base()}/coupons/${encodeURIComponent(code)}/redemptions/${encodeURIComponent(id)}`,
1866
+ auth: auth2
1867
+ });
1868
+ }
1869
+ /** Retrieve a customer's referral coupon (resolves to an empty body when none exists). */
1870
+ async getReferralCoupon(customerNumber, auth2 = SERVICE10) {
1871
+ return this.ctx.http.request({
1872
+ method: "GET",
1873
+ path: `${this.base()}/referral-coupons/${encodeURIComponent(customerNumber)}`,
1874
+ auth: auth2
1875
+ });
1876
+ }
1877
+ /** Create a referral coupon code for a customer (no request body). */
1878
+ async createReferralCoupon(customerNumber, auth2 = SERVICE10) {
1879
+ return this.ctx.http.request({
1880
+ method: "POST",
1881
+ path: `${this.base()}/referral-coupons/${encodeURIComponent(customerNumber)}`,
1882
+ auth: auth2
1883
+ });
1884
+ }
1885
+ };
1886
+
1887
+ // src/services/reward-points.ts
1888
+ var SERVICE11 = { kind: "service" };
1889
+ var RewardPointsService = class {
1890
+ constructor(ctx) {
1891
+ this.ctx = ctx;
1892
+ }
1893
+ ctx;
1894
+ /** Base without tenant (customer / public / batch endpoints). */
1895
+ base() {
1896
+ return `/reward-points`;
1897
+ }
1898
+ /** Tenant-scoped base (redeem options only). */
1899
+ tenantBase() {
1900
+ return `/reward-points/${this.ctx.tenant}`;
1901
+ }
1902
+ // --- Admin: customer points management (service token) ---
1903
+ /** Batch summary across all customers. */
1904
+ async listAllSummaries(query = {}, auth2 = SERVICE11) {
1905
+ return this.ctx.http.request({
1906
+ method: "GET",
1907
+ path: `${this.base()}/summaryBatch`,
1908
+ auth: auth2,
1909
+ ...Object.keys(query).length ? { query } : {}
1910
+ });
1911
+ }
1912
+ /** Retrieve one customer's reward-points balance. */
1913
+ async getCustomerPoints(customerId, auth2 = SERVICE11) {
1914
+ return this.ctx.http.request({
1915
+ method: "GET",
1916
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}`,
1917
+ auth: auth2
1918
+ });
1919
+ }
1920
+ /** Create a reward-points entry for a customer. */
1921
+ async createCustomerPoints(customerId, input, auth2 = SERVICE11) {
1922
+ await this.ctx.http.request({
1923
+ method: "POST",
1924
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}`,
1925
+ auth: auth2,
1926
+ body: input
1927
+ });
1928
+ }
1929
+ /** Delete a customer's reward points. */
1930
+ async deleteCustomerPoints(customerId, auth2 = SERVICE11) {
1931
+ await this.ctx.http.request({
1932
+ method: "DELETE",
1933
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}`,
1934
+ auth: auth2
1935
+ });
1936
+ }
1937
+ /** Retrieve a reward-points summary for one customer. */
1938
+ async getCustomerSummary(customerId, auth2 = SERVICE11) {
1939
+ return this.ctx.http.request({
1940
+ method: "GET",
1941
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}/summary`,
1942
+ auth: auth2
1943
+ });
1944
+ }
1945
+ /** Add reward points for a customer. */
1946
+ async addPoints(customerId, input, auth2 = SERVICE11) {
1947
+ await this.ctx.http.request({
1948
+ method: "POST",
1949
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}/addPoints`,
1950
+ auth: auth2,
1951
+ body: input
1952
+ });
1953
+ }
1954
+ /** Redeem a customer's reward points (on behalf). */
1955
+ async redeemPoints(customerId, input, auth2 = SERVICE11) {
1956
+ await this.ctx.http.request({
1957
+ method: "POST",
1958
+ path: `${this.base()}/customer/${encodeURIComponent(customerId)}/redeemPoints`,
1959
+ auth: auth2,
1960
+ body: input
1961
+ });
1962
+ }
1963
+ // --- Storefront: the signed-in customer's own points (customer token required) ---
1964
+ /** The signed-in customer's reward-points balance. Requires a customer `auth`. */
1965
+ async getMyPoints(auth2) {
1966
+ return this.ctx.http.request({
1967
+ method: "GET",
1968
+ path: `${this.base()}/public/customer`,
1969
+ auth: auth2
1970
+ });
1971
+ }
1972
+ /** The signed-in customer's reward-points summary. Requires a customer `auth`. */
1973
+ async getMySummary(auth2) {
1974
+ return this.ctx.http.request({
1975
+ method: "GET",
1976
+ path: `${this.base()}/public/customer/summary`,
1977
+ auth: auth2
1978
+ });
1979
+ }
1980
+ /**
1981
+ * Redeem the signed-in customer's points for a coupon code. Requires a
1982
+ * customer `auth`. Returns the issued coupon `{ code }`.
1983
+ */
1984
+ async redeemMyPoints(input, auth2) {
1985
+ return this.ctx.http.request({
1986
+ method: "POST",
1987
+ path: `${this.base()}/public/customer/redeem`,
1988
+ auth: auth2,
1989
+ body: input
1990
+ });
1991
+ }
1992
+ // --- Redeem options (tenant-scoped; read open to customer, management service-only) ---
1993
+ /** List redeem options. Defaults to the service token; pass a customer `auth` for storefront reads. */
1994
+ async listRedeemOptions(auth2 = SERVICE11) {
1995
+ return this.ctx.http.request({
1996
+ method: "GET",
1997
+ path: `${this.tenantBase()}/redeemOptions`,
1998
+ auth: auth2
1999
+ });
2000
+ }
2001
+ /** Create a redeem option. Returns the updated options list. */
2002
+ async createRedeemOption(input, auth2 = SERVICE11) {
2003
+ return this.ctx.http.request({
2004
+ method: "POST",
2005
+ path: `${this.tenantBase()}/redeemOptions`,
2006
+ auth: auth2,
2007
+ body: input
2008
+ });
2009
+ }
2010
+ /** Update a redeem option by id. Resolves once accepted (no response body). */
2011
+ async updateRedeemOption(redeemOptionId, input, auth2 = SERVICE11) {
2012
+ await this.ctx.http.request({
2013
+ method: "PUT",
2014
+ path: `${this.tenantBase()}/redeemOptions/${encodeURIComponent(redeemOptionId)}`,
2015
+ auth: auth2,
2016
+ body: input
2017
+ });
2018
+ }
2019
+ /** Delete a redeem option by id. */
2020
+ async deleteRedeemOption(redeemOptionId, auth2 = SERVICE11) {
2021
+ await this.ctx.http.request({
2022
+ method: "DELETE",
2023
+ path: `${this.tenantBase()}/redeemOptions/${encodeURIComponent(redeemOptionId)}`,
2024
+ auth: auth2
2025
+ });
2026
+ }
2027
+ };
2028
+
2029
+ // src/services/brand.ts
2030
+ var SERVICE12 = { kind: "service" };
2031
+ var BrandService = class {
2032
+ constructor(ctx) {
2033
+ this.ctx = ctx;
2034
+ }
2035
+ ctx;
2036
+ base() {
2037
+ return `/brand/brands`;
2038
+ }
2039
+ /** List all brands. */
2040
+ async listBrands(query = {}, auth2 = SERVICE12) {
2041
+ return this.ctx.http.request({
2042
+ method: "GET",
2043
+ path: this.base(),
2044
+ auth: auth2,
2045
+ ...Object.keys(query).length ? { query } : {}
2046
+ });
2047
+ }
2048
+ /** Retrieve one brand by id. */
2049
+ async getBrand(brandId, auth2 = SERVICE12) {
2050
+ return this.ctx.http.request({
2051
+ method: "GET",
2052
+ path: `${this.base()}/${encodeURIComponent(brandId)}`,
2053
+ auth: auth2
2054
+ });
2055
+ }
2056
+ /** Create a brand. */
2057
+ async createBrand(input, auth2 = SERVICE12) {
2058
+ return this.ctx.http.request({
2059
+ method: "POST",
2060
+ path: this.base(),
2061
+ auth: auth2,
2062
+ body: input
2063
+ });
2064
+ }
2065
+ /** Replace a brand by id. */
2066
+ async updateBrand(brandId, input, auth2 = SERVICE12) {
2067
+ return this.ctx.http.request({
2068
+ method: "PUT",
2069
+ path: `${this.base()}/${encodeURIComponent(brandId)}`,
2070
+ auth: auth2,
2071
+ body: input
2072
+ });
2073
+ }
2074
+ /** Partially update a brand by id. */
2075
+ async patchBrand(brandId, patch, auth2 = SERVICE12) {
2076
+ return this.ctx.http.request({
2077
+ method: "PATCH",
2078
+ path: `${this.base()}/${encodeURIComponent(brandId)}`,
2079
+ auth: auth2,
2080
+ body: patch
2081
+ });
2082
+ }
2083
+ /** Delete a brand by id. */
2084
+ async deleteBrand(brandId, auth2 = SERVICE12) {
2085
+ await this.ctx.http.request({
2086
+ method: "DELETE",
2087
+ path: `${this.base()}/${encodeURIComponent(brandId)}`,
2088
+ auth: auth2
2089
+ });
2090
+ }
2091
+ };
2092
+
2093
+ // src/services/label.ts
2094
+ var SERVICE13 = { kind: "service" };
2095
+ var LabelService = class {
2096
+ constructor(ctx) {
2097
+ this.ctx = ctx;
2098
+ }
2099
+ ctx;
2100
+ base() {
2101
+ return `/label/labels`;
2102
+ }
2103
+ /** List all labels. */
2104
+ async listLabels(query = {}, auth2 = SERVICE13) {
2105
+ return this.ctx.http.request({
2106
+ method: "GET",
2107
+ path: this.base(),
2108
+ auth: auth2,
2109
+ ...Object.keys(query).length ? { query } : {}
2110
+ });
2111
+ }
2112
+ /** Retrieve one label by id. */
2113
+ async getLabel(labelId, auth2 = SERVICE13) {
2114
+ return this.ctx.http.request({
2115
+ method: "GET",
2116
+ path: `${this.base()}/${encodeURIComponent(labelId)}`,
2117
+ auth: auth2
2118
+ });
2119
+ }
2120
+ /** Create a label. */
2121
+ async createLabel(input, auth2 = SERVICE13) {
2122
+ return this.ctx.http.request({
2123
+ method: "POST",
2124
+ path: this.base(),
2125
+ auth: auth2,
2126
+ body: input
2127
+ });
2128
+ }
2129
+ /** Replace a label by id. */
2130
+ async updateLabel(labelId, input, auth2 = SERVICE13) {
2131
+ return this.ctx.http.request({
2132
+ method: "PUT",
2133
+ path: `${this.base()}/${encodeURIComponent(labelId)}`,
2134
+ auth: auth2,
2135
+ body: input
2136
+ });
2137
+ }
2138
+ /** Partially update a label by id. */
2139
+ async patchLabel(labelId, patch, auth2 = SERVICE13) {
2140
+ return this.ctx.http.request({
2141
+ method: "PATCH",
2142
+ path: `${this.base()}/${encodeURIComponent(labelId)}`,
2143
+ auth: auth2,
2144
+ body: patch
2145
+ });
2146
+ }
2147
+ /** Delete a label by id. */
2148
+ async deleteLabel(labelId, auth2 = SERVICE13) {
2149
+ await this.ctx.http.request({
2150
+ method: "DELETE",
2151
+ path: `${this.base()}/${encodeURIComponent(labelId)}`,
2152
+ auth: auth2
2153
+ });
2154
+ }
2155
+ };
2156
+
2157
+ // src/services/country.ts
2158
+ var SERVICE14 = { kind: "service" };
2159
+ var CountryService = class {
2160
+ constructor(ctx) {
2161
+ this.ctx = ctx;
2162
+ }
2163
+ ctx;
2164
+ base() {
2165
+ return `/country/${this.ctx.tenant}`;
2166
+ }
2167
+ /** List all countries. */
2168
+ async listCountries(query = {}, auth2 = SERVICE14) {
2169
+ return this.ctx.http.request({
2170
+ method: "GET",
2171
+ path: `${this.base()}/countries`,
2172
+ auth: auth2,
2173
+ ...Object.keys(query).length ? { query } : {}
2174
+ });
2175
+ }
2176
+ /** Retrieve one country by code. */
2177
+ async getCountry(countryCode, auth2 = SERVICE14) {
2178
+ return this.ctx.http.request({
2179
+ method: "GET",
2180
+ path: `${this.base()}/countries/${encodeURIComponent(countryCode)}`,
2181
+ auth: auth2
2182
+ });
2183
+ }
2184
+ /** Partially update a country by code. Resolves once accepted (no response body). */
2185
+ async patchCountry(countryCode, patch, auth2 = SERVICE14) {
2186
+ await this.ctx.http.request({
2187
+ method: "PATCH",
2188
+ path: `${this.base()}/countries/${encodeURIComponent(countryCode)}`,
2189
+ auth: auth2,
2190
+ body: patch
2191
+ });
2192
+ }
2193
+ /** List all regions. */
2194
+ async listRegions(query = {}, auth2 = SERVICE14) {
2195
+ return this.ctx.http.request({
2196
+ method: "GET",
2197
+ path: `${this.base()}/regions`,
2198
+ auth: auth2,
2199
+ ...Object.keys(query).length ? { query } : {}
2200
+ });
2201
+ }
2202
+ /** Retrieve one region by code. */
2203
+ async getRegion(regionCode, auth2 = SERVICE14) {
2204
+ return this.ctx.http.request({
2205
+ method: "GET",
2206
+ path: `${this.base()}/regions/${encodeURIComponent(regionCode)}`,
2207
+ auth: auth2
2208
+ });
2209
+ }
2210
+ };
2211
+
2212
+ // src/services/currency.ts
2213
+ var SERVICE15 = { kind: "service" };
2214
+ var CurrencyService = class {
2215
+ constructor(ctx) {
2216
+ this.ctx = ctx;
2217
+ }
2218
+ ctx;
2219
+ base() {
2220
+ return `/currency/${this.ctx.tenant}`;
2221
+ }
2222
+ // --- Currencies ---
2223
+ /** List all currencies. */
2224
+ async listCurrencies(query = {}, auth2 = SERVICE15) {
2225
+ return this.ctx.http.request({
2226
+ method: "GET",
2227
+ path: `${this.base()}/currencies`,
2228
+ auth: auth2,
2229
+ ...Object.keys(query).length ? { query } : {}
2230
+ });
2231
+ }
2232
+ /** Retrieve one currency by code. */
2233
+ async getCurrency(code, auth2 = SERVICE15) {
2234
+ return this.ctx.http.request({
2235
+ method: "GET",
2236
+ path: `${this.base()}/currencies/${encodeURIComponent(code)}`,
2237
+ auth: auth2
2238
+ });
2239
+ }
2240
+ /** Create a currency. */
2241
+ async createCurrency(input, auth2 = SERVICE15) {
2242
+ return this.ctx.http.request({
2243
+ method: "POST",
2244
+ path: `${this.base()}/currencies`,
2245
+ auth: auth2,
2246
+ body: input
2247
+ });
2248
+ }
2249
+ /** Update a currency by code. */
2250
+ async updateCurrency(code, input, auth2 = SERVICE15) {
2251
+ return this.ctx.http.request({
2252
+ method: "PUT",
2253
+ path: `${this.base()}/currencies/${encodeURIComponent(code)}`,
2254
+ auth: auth2,
2255
+ body: input
2256
+ });
2257
+ }
2258
+ /** Delete a currency by code. */
2259
+ async deleteCurrency(code, auth2 = SERVICE15) {
2260
+ await this.ctx.http.request({
2261
+ method: "DELETE",
2262
+ path: `${this.base()}/currencies/${encodeURIComponent(code)}`,
2263
+ auth: auth2
2264
+ });
2265
+ }
2266
+ // --- Exchange rates ---
2267
+ /** List all exchange rates. */
2268
+ async listExchangeRates(query = {}, auth2 = SERVICE15) {
2269
+ return this.ctx.http.request({
2270
+ method: "GET",
2271
+ path: `${this.base()}/exchanges`,
2272
+ auth: auth2,
2273
+ ...Object.keys(query).length ? { query } : {}
2274
+ });
2275
+ }
2276
+ /** Retrieve one exchange rate by code. */
2277
+ async getExchangeRate(code, auth2 = SERVICE15) {
2278
+ return this.ctx.http.request({
2279
+ method: "GET",
2280
+ path: `${this.base()}/exchanges/${encodeURIComponent(code)}`,
2281
+ auth: auth2
2282
+ });
2283
+ }
2284
+ /** Create an exchange rate. */
2285
+ async createExchangeRate(input, auth2 = SERVICE15) {
2286
+ return this.ctx.http.request({
2287
+ method: "POST",
2288
+ path: `${this.base()}/exchanges`,
2289
+ auth: auth2,
2290
+ body: input
2291
+ });
2292
+ }
2293
+ /** Update an exchange rate by code. */
2294
+ async updateExchangeRate(code, input, auth2 = SERVICE15) {
2295
+ return this.ctx.http.request({
2296
+ method: "PUT",
2297
+ path: `${this.base()}/exchanges/${encodeURIComponent(code)}`,
2298
+ auth: auth2,
2299
+ body: input
2300
+ });
2301
+ }
2302
+ /** Delete an exchange rate by code. */
2303
+ async deleteExchangeRate(code, auth2 = SERVICE15) {
2304
+ await this.ctx.http.request({
2305
+ method: "DELETE",
2306
+ path: `${this.base()}/exchanges/${encodeURIComponent(code)}`,
2307
+ auth: auth2
2308
+ });
2309
+ }
2310
+ };
2311
+
2312
+ // src/services/shipping.ts
2313
+ var SERVICE16 = { kind: "service" };
2314
+ var ShippingService = class {
2315
+ constructor(ctx) {
2316
+ this.ctx = ctx;
2317
+ }
2318
+ ctx;
2319
+ base() {
2320
+ return `/shipping/${this.ctx.tenant}`;
2321
+ }
2322
+ siteBase(site) {
2323
+ return `${this.base()}/${encodeURIComponent(site)}`;
2324
+ }
2325
+ // --- Sites ---
2326
+ /** Find shipping-related sites by postal code (`POST /findSite`). */
2327
+ async findSites(input, auth2 = SERVICE16) {
2328
+ return this.ctx.http.request({
2329
+ method: "POST",
2330
+ path: `${this.base()}/findSite`,
2331
+ auth: auth2,
2332
+ body: input
2333
+ });
2334
+ }
2335
+ // --- Zones ---
2336
+ /** List shipping zones for a site. */
2337
+ async listZones(site, query = {}, auth2 = SERVICE16) {
2338
+ return this.ctx.http.request({
2339
+ method: "GET",
2340
+ path: `${this.siteBase(site)}/zones`,
2341
+ auth: auth2,
2342
+ ...Object.keys(query).length ? { query } : {}
2343
+ });
2344
+ }
2345
+ /** Retrieve one shipping zone. */
2346
+ async getZone(site, zoneId, auth2 = SERVICE16) {
2347
+ return this.ctx.http.request({
2348
+ method: "GET",
2349
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}`,
2350
+ auth: auth2
2351
+ });
2352
+ }
2353
+ /** Create a shipping zone. */
2354
+ async createZone(site, zone, auth2 = SERVICE16) {
2355
+ return this.ctx.http.request({
2356
+ method: "POST",
2357
+ path: `${this.siteBase(site)}/zones`,
2358
+ auth: auth2,
2359
+ body: zone
2360
+ });
2361
+ }
2362
+ /** Replace a shipping zone. */
2363
+ async updateZone(site, zoneId, zone, auth2 = SERVICE16) {
2364
+ await this.ctx.http.request({
2365
+ method: "PUT",
2366
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}`,
2367
+ auth: auth2,
2368
+ body: zone
2369
+ });
2370
+ }
2371
+ /** Partially update a shipping zone. */
2372
+ async patchZone(site, zoneId, patch, auth2 = SERVICE16) {
2373
+ await this.ctx.http.request({
2374
+ method: "PATCH",
2375
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}`,
2376
+ auth: auth2,
2377
+ body: patch
2378
+ });
2379
+ }
2380
+ /** Delete a shipping zone. */
2381
+ async deleteZone(site, zoneId, auth2 = SERVICE16) {
2382
+ await this.ctx.http.request({
2383
+ method: "DELETE",
2384
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}`,
2385
+ auth: auth2
2386
+ });
2387
+ }
2388
+ // --- Methods (per zone) ---
2389
+ /** List shipping methods of a zone. */
2390
+ async listMethods(site, zoneId, query = {}, auth2 = SERVICE16) {
2391
+ return this.ctx.http.request({
2392
+ method: "GET",
2393
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods`,
2394
+ auth: auth2,
2395
+ ...Object.keys(query).length ? { query } : {}
2396
+ });
2397
+ }
2398
+ /** Retrieve one shipping method. */
2399
+ async getMethod(site, zoneId, methodId, auth2 = SERVICE16) {
2400
+ return this.ctx.http.request({
2401
+ method: "GET",
2402
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods/${encodeURIComponent(methodId)}`,
2403
+ auth: auth2
2404
+ });
2405
+ }
2406
+ /** Create a shipping method in a zone. */
2407
+ async createMethod(site, zoneId, method, auth2 = SERVICE16) {
2408
+ return this.ctx.http.request({
2409
+ method: "POST",
2410
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods`,
2411
+ auth: auth2,
2412
+ body: method
2413
+ });
2414
+ }
2415
+ /** Replace a shipping method. */
2416
+ async updateMethod(site, zoneId, methodId, method, auth2 = SERVICE16) {
2417
+ await this.ctx.http.request({
2418
+ method: "PUT",
2419
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods/${encodeURIComponent(methodId)}`,
2420
+ auth: auth2,
2421
+ body: method
2422
+ });
2423
+ }
2424
+ /** Partially update a shipping method. */
2425
+ async patchMethod(site, zoneId, methodId, patch, auth2 = SERVICE16) {
2426
+ await this.ctx.http.request({
2427
+ method: "PATCH",
2428
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods/${encodeURIComponent(methodId)}`,
2429
+ auth: auth2,
2430
+ body: patch
2431
+ });
2432
+ }
2433
+ /** Delete a shipping method. */
2434
+ async deleteMethod(site, zoneId, methodId, auth2 = SERVICE16) {
2435
+ await this.ctx.http.request({
2436
+ method: "DELETE",
2437
+ path: `${this.siteBase(site)}/zones/${encodeURIComponent(zoneId)}/methods/${encodeURIComponent(methodId)}`,
2438
+ auth: auth2
2439
+ });
2440
+ }
2441
+ // --- Cost / quote ---
2442
+ /** Calculate the final shipping cost (`POST /quote`). */
2443
+ async quote(site, input, auth2 = SERVICE16) {
2444
+ return this.ctx.http.request({
2445
+ method: "POST",
2446
+ path: `${this.siteBase(site)}/quote`,
2447
+ auth: auth2,
2448
+ body: input
2449
+ });
2450
+ }
2451
+ /** Calculate the minimum shipping cost (`POST /quote/minimum`). */
2452
+ async quoteMinimum(site, input, auth2 = SERVICE16) {
2453
+ return this.ctx.http.request({
2454
+ method: "POST",
2455
+ path: `${this.siteBase(site)}/quote/minimum`,
2456
+ auth: auth2,
2457
+ body: input
2458
+ });
2459
+ }
2460
+ /** Calculate the shipping cost for a given slot (`POST /quote/slot`). */
2461
+ async quoteSlot(site, input, auth2 = SERVICE16) {
2462
+ return this.ctx.http.request({
2463
+ method: "POST",
2464
+ path: `${this.siteBase(site)}/quote/slot`,
2465
+ auth: auth2,
2466
+ body: input
2467
+ });
2468
+ }
2469
+ // --- Groups ---
2470
+ /** List shipping groups for a site. */
2471
+ async listGroups(site, query = {}, auth2 = SERVICE16) {
2472
+ return this.ctx.http.request({
2473
+ method: "GET",
2474
+ path: `${this.siteBase(site)}/groups`,
2475
+ auth: auth2,
2476
+ ...Object.keys(query).length ? { query } : {}
2477
+ });
2478
+ }
2479
+ /** Retrieve one shipping group. */
2480
+ async getGroup(site, groupId, auth2 = SERVICE16) {
2481
+ return this.ctx.http.request({
2482
+ method: "GET",
2483
+ path: `${this.siteBase(site)}/groups/${encodeURIComponent(groupId)}`,
2484
+ auth: auth2
2485
+ });
2486
+ }
2487
+ /** Create a shipping group. */
2488
+ async createGroup(site, group, auth2 = SERVICE16) {
2489
+ return this.ctx.http.request({
2490
+ method: "POST",
2491
+ path: `${this.siteBase(site)}/groups`,
2492
+ auth: auth2,
2493
+ body: group
2494
+ });
2495
+ }
2496
+ /** Replace a shipping group. */
2497
+ async updateGroup(site, groupId, group, auth2 = SERVICE16) {
2498
+ await this.ctx.http.request({
2499
+ method: "PUT",
2500
+ path: `${this.siteBase(site)}/groups/${encodeURIComponent(groupId)}`,
2501
+ auth: auth2,
2502
+ body: group
2503
+ });
2504
+ }
2505
+ /** Delete a shipping group. */
2506
+ async deleteGroup(site, groupId, auth2 = SERVICE16) {
2507
+ await this.ctx.http.request({
2508
+ method: "DELETE",
2509
+ path: `${this.siteBase(site)}/groups/${encodeURIComponent(groupId)}`,
2510
+ auth: auth2
2511
+ });
2512
+ }
2513
+ // --- Customer-group relations ---
2514
+ /** List customer-group relations for a site. */
2515
+ async listCgRelations(site, query = {}, auth2 = SERVICE16) {
2516
+ return this.ctx.http.request({
2517
+ method: "GET",
2518
+ path: `${this.siteBase(site)}/cgrelations`,
2519
+ auth: auth2,
2520
+ ...Object.keys(query).length ? { query } : {}
2521
+ });
2522
+ }
2523
+ /** Retrieve a customer's customer-group relations. */
2524
+ async getCgRelations(site, customerId, auth2 = SERVICE16) {
2525
+ return this.ctx.http.request({
2526
+ method: "GET",
2527
+ path: `${this.siteBase(site)}/cgrelations/${encodeURIComponent(customerId)}`,
2528
+ auth: auth2
2529
+ });
2530
+ }
2531
+ /** Create a customer-group relation. */
2532
+ async createCgRelation(site, relation, auth2 = SERVICE16) {
2533
+ return this.ctx.http.request({
2534
+ method: "POST",
2535
+ path: `${this.siteBase(site)}/cgrelations`,
2536
+ auth: auth2,
2537
+ body: relation
2538
+ });
2539
+ }
2540
+ /** Update a customer's customer-group relations. */
2541
+ async updateCgRelations(site, customerId, relation, auth2 = SERVICE16) {
2542
+ await this.ctx.http.request({
2543
+ method: "PUT",
2544
+ path: `${this.siteBase(site)}/cgrelations/${encodeURIComponent(customerId)}`,
2545
+ auth: auth2,
2546
+ body: relation
2547
+ });
2548
+ }
2549
+ /** Delete a customer's customer-group relation. */
2550
+ async deleteCgRelation(site, customerId, auth2 = SERVICE16) {
2551
+ await this.ctx.http.request({
2552
+ method: "DELETE",
2553
+ path: `${this.siteBase(site)}/cgrelations/${encodeURIComponent(customerId)}`,
2554
+ auth: auth2
2555
+ });
2556
+ }
2557
+ // --- Phase 2: delivery windows ---
2558
+ /** Retrieve delivery windows for a delivery area + cart. */
2559
+ async getAreaDeliveryWindows(deliveryAreaId, cartId, auth2 = SERVICE16) {
2560
+ return this.ctx.http.request({
2561
+ method: "GET",
2562
+ path: `${this.base()}/areaDeliveryTimes/${encodeURIComponent(deliveryAreaId)}/${encodeURIComponent(cartId)}`,
2563
+ auth: auth2
2564
+ });
2565
+ }
2566
+ /** Retrieve delivery windows for a cart. */
2567
+ async getCartDeliveryWindows(cartId, auth2 = SERVICE16) {
2568
+ return this.ctx.http.request({
2569
+ method: "GET",
2570
+ path: `${this.base()}/actualDeliveryWindows/${encodeURIComponent(cartId)}`,
2571
+ auth: auth2
2572
+ });
2573
+ }
2574
+ /** Increment the delivery-window counter. */
2575
+ async incrementDeliveryWindowCounter(input, auth2 = SERVICE16) {
2576
+ await this.ctx.http.request({
2577
+ method: "POST",
2578
+ path: `${this.base()}/actualDeliveryWindows/incrementCounter`,
2579
+ auth: auth2,
2580
+ body: input
2581
+ });
2582
+ }
2583
+ /** Validate a delivery window. Resolves when valid; throws otherwise. */
2584
+ async validateDeliveryWindow(input, auth2 = SERVICE16) {
2585
+ await this.ctx.http.request({
2586
+ method: "POST",
2587
+ path: `${this.base()}/deliveryWindowValidation`,
2588
+ auth: auth2,
2589
+ body: input
2590
+ });
2591
+ }
2592
+ // --- Phase 2: delivery times ---
2593
+ /** List all delivery times. */
2594
+ async listDeliveryTimes(query = {}, auth2 = SERVICE16) {
2595
+ return this.ctx.http.request({
2596
+ method: "GET",
2597
+ path: `${this.base()}/delivery-times`,
2598
+ auth: auth2,
2599
+ ...Object.keys(query).length ? { query } : {}
2600
+ });
2601
+ }
2602
+ /** Retrieve one delivery time. */
2603
+ async getDeliveryTime(deliveryTimeId, auth2 = SERVICE16) {
2604
+ return this.ctx.http.request({
2605
+ method: "GET",
2606
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}`,
2607
+ auth: auth2
2608
+ });
2609
+ }
2610
+ /** Create a delivery time. */
2611
+ async createDeliveryTime(input, auth2 = SERVICE16) {
2612
+ return this.ctx.http.request({
2613
+ method: "POST",
2614
+ path: `${this.base()}/delivery-times`,
2615
+ auth: auth2,
2616
+ body: input
2617
+ });
2618
+ }
2619
+ /** Create multiple delivery times (`POST /delivery-times/bulk`). */
2620
+ async createDeliveryTimesBulk(inputs, auth2 = SERVICE16) {
2621
+ return this.ctx.http.request({
2622
+ method: "POST",
2623
+ path: `${this.base()}/delivery-times/bulk`,
2624
+ auth: auth2,
2625
+ body: inputs
2626
+ });
2627
+ }
2628
+ /** Replace a delivery time. */
2629
+ async updateDeliveryTime(deliveryTimeId, input, auth2 = SERVICE16) {
2630
+ await this.ctx.http.request({
2631
+ method: "PUT",
2632
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}`,
2633
+ auth: auth2,
2634
+ body: input
2635
+ });
2636
+ }
2637
+ /** Partially update a delivery time (JSON-Patch op array). */
2638
+ async patchDeliveryTime(deliveryTimeId, ops, auth2 = SERVICE16) {
2639
+ await this.ctx.http.request({
2640
+ method: "PATCH",
2641
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}`,
2642
+ auth: auth2,
2643
+ body: ops
2644
+ });
2645
+ }
2646
+ /** Delete a delivery time. */
2647
+ async deleteDeliveryTime(deliveryTimeId, auth2 = SERVICE16) {
2648
+ await this.ctx.http.request({
2649
+ method: "DELETE",
2650
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}`,
2651
+ auth: auth2
2652
+ });
2653
+ }
2654
+ // --- Phase 2: delivery time slots ---
2655
+ /** List slots of a delivery time. */
2656
+ async listSlots(deliveryTimeId, auth2 = SERVICE16) {
2657
+ return this.ctx.http.request({
2658
+ method: "GET",
2659
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots`,
2660
+ auth: auth2
2661
+ });
2662
+ }
2663
+ /** Retrieve one slot. */
2664
+ async getSlot(deliveryTimeId, slotId, auth2 = SERVICE16) {
2665
+ return this.ctx.http.request({
2666
+ method: "GET",
2667
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots/${encodeURIComponent(slotId)}`,
2668
+ auth: auth2
2669
+ });
2670
+ }
2671
+ /** Create a slot in a delivery time. */
2672
+ async createSlot(deliveryTimeId, input, auth2 = SERVICE16) {
2673
+ return this.ctx.http.request({
2674
+ method: "POST",
2675
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots`,
2676
+ auth: auth2,
2677
+ body: input
2678
+ });
2679
+ }
2680
+ /** Replace a slot. */
2681
+ async updateSlot(deliveryTimeId, slotId, input, auth2 = SERVICE16) {
2682
+ await this.ctx.http.request({
2683
+ method: "PUT",
2684
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots/${encodeURIComponent(slotId)}`,
2685
+ auth: auth2,
2686
+ body: input
2687
+ });
2688
+ }
2689
+ /** Partially update a slot (JSON-Patch op array). */
2690
+ async patchSlot(deliveryTimeId, slotId, ops, auth2 = SERVICE16) {
2691
+ await this.ctx.http.request({
2692
+ method: "PATCH",
2693
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots/${encodeURIComponent(slotId)}`,
2694
+ auth: auth2,
2695
+ body: ops
2696
+ });
2697
+ }
2698
+ /** Delete a slot. */
2699
+ async deleteSlot(deliveryTimeId, slotId, auth2 = SERVICE16) {
2700
+ await this.ctx.http.request({
2701
+ method: "DELETE",
2702
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots/${encodeURIComponent(slotId)}`,
2703
+ auth: auth2
2704
+ });
2705
+ }
2706
+ /** Delete all slots of a delivery time. */
2707
+ async deleteAllSlots(deliveryTimeId, auth2 = SERVICE16) {
2708
+ await this.ctx.http.request({
2709
+ method: "DELETE",
2710
+ path: `${this.base()}/delivery-times/${encodeURIComponent(deliveryTimeId)}/slots`,
2711
+ auth: auth2
2712
+ });
2713
+ }
2714
+ // --- Phase 2: delivery cycles ---
2715
+ /** Generate a delivery cycle (`POST /delivery-cycles/generate`). Returns the cycle id. */
2716
+ async generateDeliveryCycle(input, auth2 = SERVICE16) {
2717
+ return this.ctx.http.request({
2718
+ method: "POST",
2719
+ path: `${this.base()}/delivery-cycles/generate`,
2720
+ auth: auth2,
2721
+ body: input
2722
+ });
2723
+ }
2724
+ };
2725
+
2726
+ // src/services/returns.ts
2727
+ var SERVICE17 = { kind: "service" };
2728
+ var ReturnsService = class {
2729
+ constructor(ctx) {
2730
+ this.ctx = ctx;
2731
+ }
2732
+ ctx;
2733
+ base() {
2734
+ return `/return/${this.ctx.tenant}/returns`;
2735
+ }
2736
+ /** List returns (paged; supports `pageSize`/`pageNumber`/`sort`/`q`). */
2737
+ async listReturns(query = {}, auth2 = SERVICE17) {
2738
+ return this.ctx.http.request({
2739
+ method: "GET",
2740
+ path: this.base(),
2741
+ auth: auth2,
2742
+ ...Object.keys(query).length ? { query } : {}
2743
+ });
2744
+ }
2745
+ /** Retrieve one return by id. */
2746
+ async getReturn(returnId, auth2 = SERVICE17) {
2747
+ return this.ctx.http.request({
2748
+ method: "GET",
2749
+ path: `${this.base()}/${encodeURIComponent(returnId)}`,
2750
+ auth: auth2
2751
+ });
2752
+ }
2753
+ /** Create a return. Returns the created `{ id }`. */
2754
+ async createReturn(input, auth2 = SERVICE17) {
2755
+ return this.ctx.http.request({
2756
+ method: "POST",
2757
+ path: this.base(),
2758
+ auth: auth2,
2759
+ body: input
2760
+ });
2761
+ }
2762
+ /** Replace a return by id (`PUT`). */
2763
+ async updateReturn(returnId, input, auth2 = SERVICE17) {
2764
+ await this.ctx.http.request({
2765
+ method: "PUT",
2766
+ path: `${this.base()}/${encodeURIComponent(returnId)}`,
2767
+ auth: auth2,
2768
+ body: input
2769
+ });
2770
+ }
2771
+ /** Partially update a return by id (`PATCH`, JSON-Patch op-array). */
2772
+ async patchReturn(returnId, ops, auth2 = SERVICE17) {
2773
+ await this.ctx.http.request({
2774
+ method: "PATCH",
2775
+ path: `${this.base()}/${encodeURIComponent(returnId)}`,
2776
+ auth: auth2,
2777
+ body: ops
2778
+ });
2779
+ }
2780
+ /** Delete a return by id. */
2781
+ async deleteReturn(returnId, auth2 = SERVICE17) {
2782
+ await this.ctx.http.request({
2783
+ method: "DELETE",
2784
+ path: `${this.base()}/${encodeURIComponent(returnId)}`,
2785
+ auth: auth2
2786
+ });
2787
+ }
2788
+ };
2789
+
2790
+ // src/services/sepa-export.ts
2791
+ var SERVICE18 = { kind: "service" };
2792
+ var SepaExportService = class {
2793
+ constructor(ctx) {
2794
+ this.ctx = ctx;
2795
+ }
2796
+ ctx;
2797
+ base() {
2798
+ return `/sepa-export/${this.ctx.tenant}`;
2799
+ }
2800
+ /** Retrieve a SEPA export file by id. Returns the raw file content (text). */
2801
+ async getFile(fileId, auth2 = SERVICE18) {
2802
+ const path = `${this.base()}/files/${encodeURIComponent(fileId)}`;
2803
+ const res = await this.ctx.http.requestRaw({ method: "GET", path, auth: auth2 });
2804
+ if (!res.ok) {
2805
+ const errBody = await res.text().catch(() => void 0);
2806
+ throw errorFromResponse(res.status, `GET ${path} \u2192 ${res.status}`, errBody);
2807
+ }
2808
+ return res.text();
2809
+ }
2810
+ /** List export jobs. */
2811
+ async listJobs(query = {}, auth2 = SERVICE18) {
2812
+ return this.ctx.http.request({
2813
+ method: "GET",
2814
+ path: `${this.base()}/jobs`,
2815
+ auth: auth2,
2816
+ ...Object.keys(query).length ? { query } : {}
2817
+ });
2818
+ }
2819
+ /** Create an export job. */
2820
+ async createJob(input, auth2 = SERVICE18) {
2821
+ return this.ctx.http.request({
2822
+ method: "POST",
2823
+ path: `${this.base()}/jobs`,
2824
+ auth: auth2,
2825
+ body: input
2826
+ });
2827
+ }
2828
+ };
2829
+
2830
+ // src/services/indexing.ts
2831
+ var SERVICE19 = { kind: "service" };
2832
+ var IndexingService = class {
2833
+ constructor(ctx) {
2834
+ this.ctx = ctx;
2835
+ }
2836
+ ctx;
2837
+ base() {
2838
+ return `/indexing/${this.ctx.tenant}`;
2839
+ }
2840
+ /** List indexing configurations. */
2841
+ async listConfigurations(auth2 = SERVICE19) {
2842
+ return this.ctx.http.request({ method: "GET", path: `${this.base()}/configurations`, auth: auth2 });
2843
+ }
2844
+ /** Get a configuration by provider name. */
2845
+ async getConfiguration(provider, auth2 = SERVICE19) {
2846
+ return this.ctx.http.request({
2847
+ method: "GET",
2848
+ path: `${this.base()}/configurations/${encodeURIComponent(provider)}`,
2849
+ auth: auth2
2850
+ });
2851
+ }
2852
+ /** Create a configuration. */
2853
+ async createConfiguration(input, auth2 = SERVICE19) {
2854
+ return this.ctx.http.request({
2855
+ method: "POST",
2856
+ path: `${this.base()}/configurations`,
2857
+ auth: auth2,
2858
+ body: input
2859
+ });
2860
+ }
2861
+ /** Update a configuration by provider name. */
2862
+ async updateConfiguration(provider, input, auth2 = SERVICE19) {
2863
+ await this.ctx.http.request({
2864
+ method: "PUT",
2865
+ path: `${this.base()}/configurations/${encodeURIComponent(provider)}`,
2866
+ auth: auth2,
2867
+ body: input
2868
+ });
2869
+ }
2870
+ /** Delete a configuration by provider name. */
2871
+ async deleteConfiguration(provider, auth2 = SERVICE19) {
2872
+ await this.ctx.http.request({
2873
+ method: "DELETE",
2874
+ path: `${this.base()}/configurations/${encodeURIComponent(provider)}`,
2875
+ auth: auth2
2876
+ });
2877
+ }
2878
+ /** List public indexing configurations. */
2879
+ async listPublicConfigurations(auth2 = SERVICE19) {
2880
+ return this.ctx.http.request({ method: "GET", path: `${this.base()}/public/configurations`, auth: auth2 });
2881
+ }
2882
+ /** Get a public configuration by provider name. */
2883
+ async getPublicConfiguration(provider, auth2 = SERVICE19) {
2884
+ return this.ctx.http.request({
2885
+ method: "GET",
2886
+ path: `${this.base()}/public/configurations/${encodeURIComponent(provider)}`,
2887
+ auth: auth2
2888
+ });
2889
+ }
2890
+ /** Trigger a reindex. */
2891
+ async reindex(input, auth2 = SERVICE19) {
2892
+ await this.ctx.http.request({ method: "POST", path: `${this.base()}/reindex`, auth: auth2, body: input });
2893
+ }
2894
+ };
2895
+
2896
+ // src/services/unit-handling.ts
2897
+ var SERVICE20 = { kind: "service" };
2898
+ var UnitHandlingService = class {
2899
+ constructor(ctx) {
2900
+ this.ctx = ctx;
2901
+ }
2902
+ ctx;
2903
+ base() {
2904
+ return `/unit-handling/${this.ctx.tenant}`;
2905
+ }
2906
+ /** Find units (filter/sort/page). */
2907
+ async listUnits(query = {}, auth2 = SERVICE20) {
2908
+ return this.ctx.http.request({
2909
+ method: "GET",
2910
+ path: `${this.base()}/units`,
2911
+ auth: auth2,
2912
+ ...Object.keys(query).length ? { query } : {}
2913
+ });
2914
+ }
2915
+ /** Retrieve a unit by code. */
2916
+ async getUnit(unitCode, auth2 = SERVICE20) {
2917
+ return this.ctx.http.request({
2918
+ method: "GET",
2919
+ path: `${this.base()}/units/${encodeURIComponent(unitCode)}`,
2920
+ auth: auth2
2921
+ });
2922
+ }
2923
+ /** Add a new unit. */
2924
+ async createUnit(input, auth2 = SERVICE20) {
2925
+ return this.ctx.http.request({ method: "POST", path: `${this.base()}/units`, auth: auth2, body: input });
2926
+ }
2927
+ /** Update a unit by code. */
2928
+ async updateUnit(unitCode, input, auth2 = SERVICE20) {
2929
+ await this.ctx.http.request({
2930
+ method: "PUT",
2931
+ path: `${this.base()}/units/${encodeURIComponent(unitCode)}`,
2932
+ auth: auth2,
2933
+ body: input
2934
+ });
2935
+ }
2936
+ /** Delete a unit by code. */
2937
+ async deleteUnit(unitCode, auth2 = SERVICE20) {
2938
+ await this.ctx.http.request({
2939
+ method: "DELETE",
2940
+ path: `${this.base()}/units/${encodeURIComponent(unitCode)}`,
2941
+ auth: auth2
2942
+ });
2943
+ }
2944
+ /** Delete multiple units by code (bulk). The codes are sent as the request body. */
2945
+ async deleteUnits(codes, auth2 = SERVICE20) {
2946
+ await this.ctx.http.request({
2947
+ method: "DELETE",
2948
+ path: `${this.base()}/units`,
2949
+ auth: auth2,
2950
+ body: codes
2951
+ });
2952
+ }
2953
+ /** Fetch a conversion factor (`PUT /units/conversion-factor-commands`). */
2954
+ async getConversionFactor(input, auth2 = SERVICE20) {
2955
+ return this.ctx.http.request({
2956
+ method: "PUT",
2957
+ path: `${this.base()}/units/conversion-factor-commands`,
2958
+ auth: auth2,
2959
+ body: input
2960
+ });
2961
+ }
2962
+ /** Convert a value between units (`PUT /units/convert-unit-commands`). */
2963
+ async convertUnit(input, auth2 = SERVICE20) {
2964
+ return this.ctx.http.request({
2965
+ method: "PUT",
2966
+ path: `${this.base()}/units/convert-unit-commands`,
2967
+ auth: auth2,
2968
+ body: input
2969
+ });
2970
+ }
2971
+ /** List all unit types. */
2972
+ async listUnitTypes(auth2 = SERVICE20) {
2973
+ return this.ctx.http.request({ method: "GET", path: `${this.base()}/types`, auth: auth2 });
2974
+ }
2975
+ };
2976
+
855
2977
  // package.json
856
- var version = "2.2.0";
2978
+ var version = "2.4.0";
857
2979
 
858
2980
  // src/version.ts
859
2981
  var SDK_VERSION = version;
@@ -880,6 +3002,25 @@ var EmporixClient = class {
880
3002
  availability;
881
3003
  tenantConfig;
882
3004
  clientConfig;
3005
+ shoppingLists;
3006
+ ragIndexer;
3007
+ sequentialIds;
3008
+ fees;
3009
+ webhooks;
3010
+ schemas;
3011
+ ai;
3012
+ taxes;
3013
+ coupons;
3014
+ rewardPoints;
3015
+ brands;
3016
+ labels;
3017
+ countries;
3018
+ currencies;
3019
+ shipping;
3020
+ returns;
3021
+ sepaExport;
3022
+ indexing;
3023
+ units;
883
3024
  /** The validated tenant this client is bound to. */
884
3025
  tenant;
885
3026
  /**
@@ -952,6 +3093,25 @@ var EmporixClient = class {
952
3093
  this.availability = new AvailabilityService(mk("availability"));
953
3094
  this.tenantConfig = new TenantConfigService(mk("configuration"));
954
3095
  this.clientConfig = new ClientConfigService(mk("configuration"));
3096
+ this.shoppingLists = new ShoppingListService(mk("shopping-list"));
3097
+ this.ragIndexer = new RagIndexerService(mk("ai-rag-indexer"));
3098
+ this.sequentialIds = new SequentialIdService(mk("sequential-id"));
3099
+ this.fees = new FeeService(mk("fee"));
3100
+ this.webhooks = new WebhookService(mk("webhook"));
3101
+ this.schemas = new SchemaService(mk("schema"));
3102
+ this.ai = new AiService(mk("ai"));
3103
+ this.taxes = new TaxService(mk("tax"));
3104
+ this.coupons = new CouponService(mk("coupon"));
3105
+ this.rewardPoints = new RewardPointsService(mk("reward-points"));
3106
+ this.brands = new BrandService(mk("brand"));
3107
+ this.labels = new LabelService(mk("label"));
3108
+ this.countries = new CountryService(mk("country"));
3109
+ this.currencies = new CurrencyService(mk("currency"));
3110
+ this.shipping = new ShippingService(mk("shipping"));
3111
+ this.returns = new ReturnsService(mk("returns"));
3112
+ this.sepaExport = new SepaExportService(mk("sepa-export"));
3113
+ this.indexing = new IndexingService(mk("indexing"));
3114
+ this.units = new UnitHandlingService(mk("unit-handling"));
955
3115
  }
956
3116
  /** Sets the runtime log level globally or for one service. */
957
3117
  setLogLevel(level, opts = {}) {
@@ -963,6 +3123,6 @@ var EmporixClient = class {
963
3123
  }
964
3124
  };
965
3125
 
966
- export { ClientConfigService, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, HttpClient, LEVEL, LevelResolver, SessionContextService, SiteService, TenantConfigService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
3126
+ export { AiService, BrandService, ClientConfigService, CountryService, CouponService, CurrencyService, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, WebhookService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
967
3127
  //# sourceMappingURL=index.js.map
968
3128
  //# sourceMappingURL=index.js.map