@marteye/studiojs 1.1.36 → 1.1.37

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.esm.js CHANGED
@@ -60,6 +60,9 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
60
60
  post: async (path, body) => {
61
61
  return request("POST", path, body);
62
62
  },
63
+ patch: async (path, body) => {
64
+ return request("PATCH", path, body);
65
+ },
63
66
  delete: async (path) => {
64
67
  return request("DELETE", path);
65
68
  },
@@ -67,7 +70,7 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
67
70
  }
68
71
 
69
72
  // Path: studiojs/src/resources/markets.ts
70
- function create$g(_) {
73
+ function create$k(_) {
71
74
  const actions = {
72
75
  /***
73
76
  * This is used to construct the action from the request body
@@ -97,7 +100,7 @@ function create$g(_) {
97
100
  return actions;
98
101
  }
99
102
 
100
- function create$f(httpClient) {
103
+ function create$j(httpClient) {
101
104
  return {
102
105
  list: async (marketId) => {
103
106
  return httpClient.get(`/${marketId}/adjustments`);
@@ -105,13 +108,36 @@ function create$f(httpClient) {
105
108
  get: async (marketId, id) => {
106
109
  return httpClient.get(`/${marketId}/adjustments/${id}`);
107
110
  },
111
+ create: async (marketId, data) => {
112
+ return httpClient.post(`/${marketId}/adjustments`, data);
113
+ },
114
+ update: async (marketId, id, data) => {
115
+ return httpClient.post(`/${marketId}/adjustments/${id}`, data);
116
+ },
117
+ };
118
+ }
119
+
120
+ function create$i(httpClient) {
121
+ return {
122
+ list: async (marketId) => {
123
+ return httpClient.get(`/${marketId}/extras`);
124
+ },
125
+ get: async (marketId, id) => {
126
+ return httpClient.get(`/${marketId}/extras/${id}`);
127
+ },
128
+ create: async (marketId, data) => {
129
+ return httpClient.post(`/${marketId}/extras`, data);
130
+ },
131
+ update: async (marketId, id, data) => {
132
+ return httpClient.post(`/${marketId}/extras/${id}`, data);
133
+ },
108
134
  };
109
135
  }
110
136
 
111
137
  /***
112
138
  * Bidder applications
113
139
  */
114
- function create$e(httpClient) {
140
+ function create$h(httpClient) {
115
141
  let applications = {
116
142
  /**
117
143
  * List applications for a market with optional filtering
@@ -178,7 +204,7 @@ function create$e(httpClient) {
178
204
  }
179
205
 
180
206
  // Path: studiojs/src/resources/markets.ts
181
- function create$d(httpClient) {
207
+ function create$g(httpClient) {
182
208
  let customers = {
183
209
  list: async (marketId, lastId) => {
184
210
  let params = {};
@@ -196,6 +222,9 @@ function create$d(httpClient) {
196
222
  create: async (marketId, customerData) => {
197
223
  return httpClient.post(`/${marketId}/customers`, customerData);
198
224
  },
225
+ update: async (marketId, customerId, customerData) => {
226
+ return httpClient.post(`/${marketId}/customers/${customerId}`, customerData);
227
+ },
199
228
  /**
200
229
  * Get a customer by their account number
201
230
  * @param marketId - ID of the market the customer belongs to
@@ -5012,7 +5041,7 @@ const uploadSingleFile = async (input, token) => {
5012
5041
  };
5013
5042
 
5014
5043
  // Multipart Upload for Media to the MARTEYE Media Service
5015
- function create$c() {
5044
+ function create$f() {
5016
5045
  const files = {
5017
5046
  uploadSingleFile: async (input, token) => {
5018
5047
  return await uploadSingleFile(input, token);
@@ -5027,7 +5056,7 @@ function create$c() {
5027
5056
  return files;
5028
5057
  }
5029
5058
 
5030
- function create$b(httpClient) {
5059
+ function create$e(httpClient) {
5031
5060
  const invoices = {
5032
5061
  /**
5033
5062
  * List all invoices for a market with pagination
@@ -5055,7 +5084,7 @@ function create$b(httpClient) {
5055
5084
  return invoices;
5056
5085
  }
5057
5086
 
5058
- function create$a(httpClient) {
5087
+ function create$d(httpClient) {
5059
5088
  return {
5060
5089
  create: async (marketId, saleId, lotId, data) => {
5061
5090
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5072,7 +5101,7 @@ function create$a(httpClient) {
5072
5101
  /**
5073
5102
  * Defines the possible status values for a lot in a sale
5074
5103
  */
5075
- function create$9(httpClient) {
5104
+ function create$c(httpClient) {
5076
5105
  return {
5077
5106
  get: async (marketId, saleId, lotId) => {
5078
5107
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5092,7 +5121,7 @@ function create$9(httpClient) {
5092
5121
  };
5093
5122
  }
5094
5123
 
5095
- function create$8(httpClient) {
5124
+ function create$b(httpClient) {
5096
5125
  const markets = {
5097
5126
  get: async (marketId) => {
5098
5127
  return httpClient.get(`/${marketId}`);
@@ -5114,7 +5143,7 @@ function create$8(httpClient) {
5114
5143
  return markets;
5115
5144
  }
5116
5145
 
5117
- function create$7(httpClient) {
5146
+ function create$a(httpClient) {
5118
5147
  const payments = {
5119
5148
  /**
5120
5149
  * List all payments for a market with pagination
@@ -5142,7 +5171,7 @@ function create$7(httpClient) {
5142
5171
  return payments;
5143
5172
  }
5144
5173
 
5145
- function create$6(httpClient) {
5174
+ function create$9(httpClient) {
5146
5175
  const payouts = {
5147
5176
  /**
5148
5177
  * List all payouts for a market with pagination
@@ -5170,7 +5199,7 @@ function create$6(httpClient) {
5170
5199
  return payouts;
5171
5200
  }
5172
5201
 
5173
- function create$5(httpClient) {
5202
+ function create$8(httpClient) {
5174
5203
  return {
5175
5204
  list: async (marketId) => {
5176
5205
  return httpClient.get(`/${marketId}/product_codes`);
@@ -5178,10 +5207,16 @@ function create$5(httpClient) {
5178
5207
  get: async (marketId, id) => {
5179
5208
  return httpClient.get(`/${marketId}/product_codes/${id}`);
5180
5209
  },
5210
+ create: async (marketId, data) => {
5211
+ return httpClient.post(`/${marketId}/product_codes`, data);
5212
+ },
5213
+ update: async (marketId, id, data) => {
5214
+ return httpClient.post(`/${marketId}/product_codes/${id}`, data);
5215
+ },
5181
5216
  };
5182
5217
  }
5183
5218
 
5184
- function create$4(httpClient) {
5219
+ function create$7(httpClient) {
5185
5220
  return {
5186
5221
  get: async (marketId, saleId) => {
5187
5222
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5198,7 +5233,27 @@ function create$4(httpClient) {
5198
5233
  };
5199
5234
  }
5200
5235
 
5201
- function create$3(httpClient) {
5236
+ function create$6(httpClient) {
5237
+ return {
5238
+ list: async (marketId) => {
5239
+ return httpClient.get(`/${marketId}/sale-templates`);
5240
+ },
5241
+ get: async (marketId, templateId) => {
5242
+ return httpClient.get(`/${marketId}/sale-templates/${templateId}`);
5243
+ },
5244
+ create: async (marketId, body) => {
5245
+ return httpClient.post(`/${marketId}/sale-templates`, body);
5246
+ },
5247
+ update: async (marketId, templateId, body) => {
5248
+ return httpClient.post(`/${marketId}/sale-templates/${templateId}`, body);
5249
+ },
5250
+ delete: async (marketId, templateId) => {
5251
+ return httpClient.delete(`/${marketId}/sale-templates/${templateId}`);
5252
+ },
5253
+ };
5254
+ }
5255
+
5256
+ function create$5(httpClient) {
5202
5257
  let search = {
5203
5258
  /**
5204
5259
  * Search for documents within a market
@@ -5213,7 +5268,7 @@ function create$3(httpClient) {
5213
5268
  return search;
5214
5269
  }
5215
5270
 
5216
- function create$2(httpClient) {
5271
+ function create$4(httpClient) {
5217
5272
  return {
5218
5273
  get: async (marketId) => {
5219
5274
  return httpClient.get(`/${marketId}/settings`);
@@ -5221,7 +5276,7 @@ function create$2(httpClient) {
5221
5276
  };
5222
5277
  }
5223
5278
 
5224
- function create$1(httpClient) {
5279
+ function create$3(httpClient) {
5225
5280
  return {
5226
5281
  list: async (marketId) => {
5227
5282
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5233,7 +5288,7 @@ function create$1(httpClient) {
5233
5288
  }
5234
5289
 
5235
5290
  // Path: studiojs/src/resources/markets.ts
5236
- function create(_) {
5291
+ function create$2(_) {
5237
5292
  const webhooks = {
5238
5293
  /***
5239
5294
  * This is used to construct the webhook event from the request body
@@ -5268,25 +5323,60 @@ function create(_) {
5268
5323
  return webhooks;
5269
5324
  }
5270
5325
 
5326
+ function create$1(httpClient) {
5327
+ return {
5328
+ lookup: async (marketId, cph) => httpClient.get(`/${marketId}/cph`, { cph }),
5329
+ };
5330
+ }
5331
+
5332
+ function create(httpClient) {
5333
+ return {
5334
+ list: async (marketId, customerId, params) => {
5335
+ const query = {};
5336
+ if (params === null || params === void 0 ? void 0 : params.lastId)
5337
+ query.lastId = params.lastId;
5338
+ if (params === null || params === void 0 ? void 0 : params.limit)
5339
+ query.limit = params.limit;
5340
+ return httpClient.get(`/${marketId}/customers/${customerId}/contacts`, query);
5341
+ },
5342
+ get: async (marketId, customerId, contactId) => {
5343
+ return httpClient.get(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
5344
+ },
5345
+ create: async (marketId, customerId, payload) => {
5346
+ return httpClient.post(`/${marketId}/customers/${customerId}/contacts`, payload);
5347
+ },
5348
+ update: async (marketId, customerId, contactId, payload) => {
5349
+ return httpClient.post(`/${marketId}/customers/${customerId}/contacts/${contactId}`, payload);
5350
+ },
5351
+ delete: async (marketId, customerId, contactId) => {
5352
+ return httpClient.delete(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
5353
+ },
5354
+ };
5355
+ }
5356
+
5271
5357
  function resources(httpClient) {
5272
5358
  return {
5273
- markets: create$8(httpClient),
5274
- sales: create$4(httpClient),
5275
- lots: create$9(httpClient),
5276
- lotitems: create$a(httpClient),
5277
- webhooks: create(),
5278
- actions: create$g(),
5279
- bidderApplications: create$e(httpClient),
5280
- settings: create$2(httpClient),
5281
- adjustments: create$f(httpClient),
5282
- productCodes: create$5(httpClient),
5283
- taxRates: create$1(httpClient),
5284
- customers: create$d(httpClient),
5285
- invoices: create$b(httpClient),
5286
- payments: create$7(httpClient),
5287
- payouts: create$6(httpClient),
5288
- search: create$3(httpClient),
5289
- files: create$c(),
5359
+ markets: create$b(httpClient),
5360
+ sales: create$7(httpClient),
5361
+ lots: create$c(httpClient),
5362
+ lotitems: create$d(httpClient),
5363
+ cph: create$1(httpClient),
5364
+ webhooks: create$2(),
5365
+ actions: create$k(),
5366
+ bidderApplications: create$h(httpClient),
5367
+ settings: create$4(httpClient),
5368
+ adjustments: create$j(httpClient),
5369
+ extras: create$i(httpClient),
5370
+ productCodes: create$8(httpClient),
5371
+ saleTemplates: create$6(httpClient),
5372
+ taxRates: create$3(httpClient),
5373
+ customers: create$g(httpClient),
5374
+ invoices: create$e(httpClient),
5375
+ payments: create$a(httpClient),
5376
+ payouts: create$9(httpClient),
5377
+ search: create$5(httpClient),
5378
+ files: create$f(),
5379
+ contacts: create(httpClient),
5290
5380
  };
5291
5381
  }
5292
5382
 
@@ -5597,32 +5687,64 @@ EarTag.countryCodes = {
5597
5687
  BE: "056",
5598
5688
  };
5599
5689
 
5690
+ /**
5691
+ * Extract the smallest lot number for sorting purposes.
5692
+ * Handles formats:
5693
+ * - Simple: "7" -> 7
5694
+ * - Alpha suffix: "7A" -> 7
5695
+ * - Range: "7-9" -> 7
5696
+ * - Range with alpha: "7A-9A" -> 7
5697
+ * - With gaps: "7-8, 10" -> 7
5698
+ * - Complex: "7A-8A, 10B" -> 7
5699
+ */
5700
+ function extractMinLotNumber(lotNumber) {
5701
+ // Handle empty/null
5702
+ if (!lotNumber)
5703
+ return { num: null, alpha: "" };
5704
+ // Split by comma first (handles "7-8, 10" format), flexible with whitespace
5705
+ let segments = lotNumber.split(/\s*,\s*/);
5706
+ let minNum = null;
5707
+ let minAlpha = "";
5708
+ for (let segment of segments) {
5709
+ // Split by hyphen (handles "7-9" range format), flexible with whitespace
5710
+ let rangeParts = segment.split(/\s*-\s*/);
5711
+ for (let part of rangeParts) {
5712
+ // Extract number and alpha from each part (e.g., "7A" -> 7, "A")
5713
+ let match = part.trim().match(/^(\d+)(\D*)$/);
5714
+ if (match) {
5715
+ let num = parseInt(match[1], 10);
5716
+ let alpha = match[2] || "";
5717
+ if (minNum === null ||
5718
+ num < minNum ||
5719
+ (num === minNum && alpha < minAlpha)) {
5720
+ minNum = num;
5721
+ minAlpha = alpha;
5722
+ }
5723
+ }
5724
+ }
5725
+ }
5726
+ return { num: minNum, alpha: minAlpha };
5727
+ }
5600
5728
  function lotComparator(a, b) {
5601
- const aMatch = a.lotNumber.match(/^(\d+)(\D*)$/);
5602
- const bMatch = b.lotNumber.match(/^(\d+)(\D*)$/);
5603
- // If neither matches the pattern, fall back to string comparison
5604
- if (!aMatch && !bMatch) {
5729
+ let aMin = extractMinLotNumber(a.lotNumber);
5730
+ let bMin = extractMinLotNumber(b.lotNumber);
5731
+ // If neither has numbers, fall back to string comparison
5732
+ if (aMin.num === null && bMin.num === null) {
5605
5733
  return a.lotNumber.localeCompare(b.lotNumber);
5606
5734
  }
5607
- // If only one matches, the one with numbers comes after
5608
- if (!aMatch)
5735
+ // If only one has numbers, the one without comes first
5736
+ if (aMin.num === null)
5609
5737
  return -1;
5610
- if (!bMatch)
5738
+ if (bMin.num === null)
5611
5739
  return 1;
5612
- // Handle cases with numbers
5613
- const aNum = parseInt(aMatch[1], 10);
5614
- const bNum = parseInt(bMatch[1], 10);
5615
- // Compare numeric parts first
5616
- if (aNum !== bNum)
5617
- return aNum - bNum;
5618
- // Get alphabetic suffixes (or empty string if none)
5619
- const aAlpha = (aMatch === null || aMatch === void 0 ? void 0 : aMatch[2]) || "";
5620
- const bAlpha = (bMatch === null || bMatch === void 0 ? void 0 : bMatch[2]) || "";
5621
- // Compare by length first (shorter comes first)
5622
- if (aAlpha.length !== bAlpha.length)
5623
- return aAlpha.length - bAlpha.length;
5624
- // Then compare alphabetically
5625
- return aAlpha.localeCompare(bAlpha);
5740
+ // Compare numeric parts
5741
+ if (aMin.num !== bMin.num)
5742
+ return aMin.num - bMin.num;
5743
+ // Compare alpha suffixes by length then alphabetically
5744
+ if (aMin.alpha.length !== bMin.alpha.length) {
5745
+ return aMin.alpha.length - bMin.alpha.length;
5746
+ }
5747
+ return aMin.alpha.localeCompare(bMin.alpha);
5626
5748
  }
5627
5749
  function sortByLotNumber(lots) {
5628
5750
  return [...lots].sort(lotComparator);