@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.js CHANGED
@@ -64,6 +64,9 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
64
64
  post: async (path, body) => {
65
65
  return request("POST", path, body);
66
66
  },
67
+ patch: async (path, body) => {
68
+ return request("PATCH", path, body);
69
+ },
67
70
  delete: async (path) => {
68
71
  return request("DELETE", path);
69
72
  },
@@ -71,7 +74,7 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
71
74
  }
72
75
 
73
76
  // Path: studiojs/src/resources/markets.ts
74
- function create$g(_) {
77
+ function create$k(_) {
75
78
  const actions = {
76
79
  /***
77
80
  * This is used to construct the action from the request body
@@ -101,7 +104,7 @@ function create$g(_) {
101
104
  return actions;
102
105
  }
103
106
 
104
- function create$f(httpClient) {
107
+ function create$j(httpClient) {
105
108
  return {
106
109
  list: async (marketId) => {
107
110
  return httpClient.get(`/${marketId}/adjustments`);
@@ -109,13 +112,36 @@ function create$f(httpClient) {
109
112
  get: async (marketId, id) => {
110
113
  return httpClient.get(`/${marketId}/adjustments/${id}`);
111
114
  },
115
+ create: async (marketId, data) => {
116
+ return httpClient.post(`/${marketId}/adjustments`, data);
117
+ },
118
+ update: async (marketId, id, data) => {
119
+ return httpClient.post(`/${marketId}/adjustments/${id}`, data);
120
+ },
121
+ };
122
+ }
123
+
124
+ function create$i(httpClient) {
125
+ return {
126
+ list: async (marketId) => {
127
+ return httpClient.get(`/${marketId}/extras`);
128
+ },
129
+ get: async (marketId, id) => {
130
+ return httpClient.get(`/${marketId}/extras/${id}`);
131
+ },
132
+ create: async (marketId, data) => {
133
+ return httpClient.post(`/${marketId}/extras`, data);
134
+ },
135
+ update: async (marketId, id, data) => {
136
+ return httpClient.post(`/${marketId}/extras/${id}`, data);
137
+ },
112
138
  };
113
139
  }
114
140
 
115
141
  /***
116
142
  * Bidder applications
117
143
  */
118
- function create$e(httpClient) {
144
+ function create$h(httpClient) {
119
145
  let applications = {
120
146
  /**
121
147
  * List applications for a market with optional filtering
@@ -182,7 +208,7 @@ function create$e(httpClient) {
182
208
  }
183
209
 
184
210
  // Path: studiojs/src/resources/markets.ts
185
- function create$d(httpClient) {
211
+ function create$g(httpClient) {
186
212
  let customers = {
187
213
  list: async (marketId, lastId) => {
188
214
  let params = {};
@@ -200,6 +226,9 @@ function create$d(httpClient) {
200
226
  create: async (marketId, customerData) => {
201
227
  return httpClient.post(`/${marketId}/customers`, customerData);
202
228
  },
229
+ update: async (marketId, customerId, customerData) => {
230
+ return httpClient.post(`/${marketId}/customers/${customerId}`, customerData);
231
+ },
203
232
  /**
204
233
  * Get a customer by their account number
205
234
  * @param marketId - ID of the market the customer belongs to
@@ -5016,7 +5045,7 @@ const uploadSingleFile = async (input, token) => {
5016
5045
  };
5017
5046
 
5018
5047
  // Multipart Upload for Media to the MARTEYE Media Service
5019
- function create$c() {
5048
+ function create$f() {
5020
5049
  const files = {
5021
5050
  uploadSingleFile: async (input, token) => {
5022
5051
  return await uploadSingleFile(input, token);
@@ -5031,7 +5060,7 @@ function create$c() {
5031
5060
  return files;
5032
5061
  }
5033
5062
 
5034
- function create$b(httpClient) {
5063
+ function create$e(httpClient) {
5035
5064
  const invoices = {
5036
5065
  /**
5037
5066
  * List all invoices for a market with pagination
@@ -5059,7 +5088,7 @@ function create$b(httpClient) {
5059
5088
  return invoices;
5060
5089
  }
5061
5090
 
5062
- function create$a(httpClient) {
5091
+ function create$d(httpClient) {
5063
5092
  return {
5064
5093
  create: async (marketId, saleId, lotId, data) => {
5065
5094
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5076,7 +5105,7 @@ function create$a(httpClient) {
5076
5105
  /**
5077
5106
  * Defines the possible status values for a lot in a sale
5078
5107
  */
5079
- function create$9(httpClient) {
5108
+ function create$c(httpClient) {
5080
5109
  return {
5081
5110
  get: async (marketId, saleId, lotId) => {
5082
5111
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5096,7 +5125,7 @@ function create$9(httpClient) {
5096
5125
  };
5097
5126
  }
5098
5127
 
5099
- function create$8(httpClient) {
5128
+ function create$b(httpClient) {
5100
5129
  const markets = {
5101
5130
  get: async (marketId) => {
5102
5131
  return httpClient.get(`/${marketId}`);
@@ -5118,7 +5147,7 @@ function create$8(httpClient) {
5118
5147
  return markets;
5119
5148
  }
5120
5149
 
5121
- function create$7(httpClient) {
5150
+ function create$a(httpClient) {
5122
5151
  const payments = {
5123
5152
  /**
5124
5153
  * List all payments for a market with pagination
@@ -5146,7 +5175,7 @@ function create$7(httpClient) {
5146
5175
  return payments;
5147
5176
  }
5148
5177
 
5149
- function create$6(httpClient) {
5178
+ function create$9(httpClient) {
5150
5179
  const payouts = {
5151
5180
  /**
5152
5181
  * List all payouts for a market with pagination
@@ -5174,7 +5203,7 @@ function create$6(httpClient) {
5174
5203
  return payouts;
5175
5204
  }
5176
5205
 
5177
- function create$5(httpClient) {
5206
+ function create$8(httpClient) {
5178
5207
  return {
5179
5208
  list: async (marketId) => {
5180
5209
  return httpClient.get(`/${marketId}/product_codes`);
@@ -5182,10 +5211,16 @@ function create$5(httpClient) {
5182
5211
  get: async (marketId, id) => {
5183
5212
  return httpClient.get(`/${marketId}/product_codes/${id}`);
5184
5213
  },
5214
+ create: async (marketId, data) => {
5215
+ return httpClient.post(`/${marketId}/product_codes`, data);
5216
+ },
5217
+ update: async (marketId, id, data) => {
5218
+ return httpClient.post(`/${marketId}/product_codes/${id}`, data);
5219
+ },
5185
5220
  };
5186
5221
  }
5187
5222
 
5188
- function create$4(httpClient) {
5223
+ function create$7(httpClient) {
5189
5224
  return {
5190
5225
  get: async (marketId, saleId) => {
5191
5226
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5202,7 +5237,27 @@ function create$4(httpClient) {
5202
5237
  };
5203
5238
  }
5204
5239
 
5205
- function create$3(httpClient) {
5240
+ function create$6(httpClient) {
5241
+ return {
5242
+ list: async (marketId) => {
5243
+ return httpClient.get(`/${marketId}/sale-templates`);
5244
+ },
5245
+ get: async (marketId, templateId) => {
5246
+ return httpClient.get(`/${marketId}/sale-templates/${templateId}`);
5247
+ },
5248
+ create: async (marketId, body) => {
5249
+ return httpClient.post(`/${marketId}/sale-templates`, body);
5250
+ },
5251
+ update: async (marketId, templateId, body) => {
5252
+ return httpClient.post(`/${marketId}/sale-templates/${templateId}`, body);
5253
+ },
5254
+ delete: async (marketId, templateId) => {
5255
+ return httpClient.delete(`/${marketId}/sale-templates/${templateId}`);
5256
+ },
5257
+ };
5258
+ }
5259
+
5260
+ function create$5(httpClient) {
5206
5261
  let search = {
5207
5262
  /**
5208
5263
  * Search for documents within a market
@@ -5217,7 +5272,7 @@ function create$3(httpClient) {
5217
5272
  return search;
5218
5273
  }
5219
5274
 
5220
- function create$2(httpClient) {
5275
+ function create$4(httpClient) {
5221
5276
  return {
5222
5277
  get: async (marketId) => {
5223
5278
  return httpClient.get(`/${marketId}/settings`);
@@ -5225,7 +5280,7 @@ function create$2(httpClient) {
5225
5280
  };
5226
5281
  }
5227
5282
 
5228
- function create$1(httpClient) {
5283
+ function create$3(httpClient) {
5229
5284
  return {
5230
5285
  list: async (marketId) => {
5231
5286
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5237,7 +5292,7 @@ function create$1(httpClient) {
5237
5292
  }
5238
5293
 
5239
5294
  // Path: studiojs/src/resources/markets.ts
5240
- function create(_) {
5295
+ function create$2(_) {
5241
5296
  const webhooks = {
5242
5297
  /***
5243
5298
  * This is used to construct the webhook event from the request body
@@ -5272,25 +5327,60 @@ function create(_) {
5272
5327
  return webhooks;
5273
5328
  }
5274
5329
 
5330
+ function create$1(httpClient) {
5331
+ return {
5332
+ lookup: async (marketId, cph) => httpClient.get(`/${marketId}/cph`, { cph }),
5333
+ };
5334
+ }
5335
+
5336
+ function create(httpClient) {
5337
+ return {
5338
+ list: async (marketId, customerId, params) => {
5339
+ const query = {};
5340
+ if (params === null || params === void 0 ? void 0 : params.lastId)
5341
+ query.lastId = params.lastId;
5342
+ if (params === null || params === void 0 ? void 0 : params.limit)
5343
+ query.limit = params.limit;
5344
+ return httpClient.get(`/${marketId}/customers/${customerId}/contacts`, query);
5345
+ },
5346
+ get: async (marketId, customerId, contactId) => {
5347
+ return httpClient.get(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
5348
+ },
5349
+ create: async (marketId, customerId, payload) => {
5350
+ return httpClient.post(`/${marketId}/customers/${customerId}/contacts`, payload);
5351
+ },
5352
+ update: async (marketId, customerId, contactId, payload) => {
5353
+ return httpClient.post(`/${marketId}/customers/${customerId}/contacts/${contactId}`, payload);
5354
+ },
5355
+ delete: async (marketId, customerId, contactId) => {
5356
+ return httpClient.delete(`/${marketId}/customers/${customerId}/contacts/${contactId}`);
5357
+ },
5358
+ };
5359
+ }
5360
+
5275
5361
  function resources(httpClient) {
5276
5362
  return {
5277
- markets: create$8(httpClient),
5278
- sales: create$4(httpClient),
5279
- lots: create$9(httpClient),
5280
- lotitems: create$a(httpClient),
5281
- webhooks: create(),
5282
- actions: create$g(),
5283
- bidderApplications: create$e(httpClient),
5284
- settings: create$2(httpClient),
5285
- adjustments: create$f(httpClient),
5286
- productCodes: create$5(httpClient),
5287
- taxRates: create$1(httpClient),
5288
- customers: create$d(httpClient),
5289
- invoices: create$b(httpClient),
5290
- payments: create$7(httpClient),
5291
- payouts: create$6(httpClient),
5292
- search: create$3(httpClient),
5293
- files: create$c(),
5363
+ markets: create$b(httpClient),
5364
+ sales: create$7(httpClient),
5365
+ lots: create$c(httpClient),
5366
+ lotitems: create$d(httpClient),
5367
+ cph: create$1(httpClient),
5368
+ webhooks: create$2(),
5369
+ actions: create$k(),
5370
+ bidderApplications: create$h(httpClient),
5371
+ settings: create$4(httpClient),
5372
+ adjustments: create$j(httpClient),
5373
+ extras: create$i(httpClient),
5374
+ productCodes: create$8(httpClient),
5375
+ saleTemplates: create$6(httpClient),
5376
+ taxRates: create$3(httpClient),
5377
+ customers: create$g(httpClient),
5378
+ invoices: create$e(httpClient),
5379
+ payments: create$a(httpClient),
5380
+ payouts: create$9(httpClient),
5381
+ search: create$5(httpClient),
5382
+ files: create$f(),
5383
+ contacts: create(httpClient),
5294
5384
  };
5295
5385
  }
5296
5386
 
@@ -5601,32 +5691,64 @@ EarTag.countryCodes = {
5601
5691
  BE: "056",
5602
5692
  };
5603
5693
 
5694
+ /**
5695
+ * Extract the smallest lot number for sorting purposes.
5696
+ * Handles formats:
5697
+ * - Simple: "7" -> 7
5698
+ * - Alpha suffix: "7A" -> 7
5699
+ * - Range: "7-9" -> 7
5700
+ * - Range with alpha: "7A-9A" -> 7
5701
+ * - With gaps: "7-8, 10" -> 7
5702
+ * - Complex: "7A-8A, 10B" -> 7
5703
+ */
5704
+ function extractMinLotNumber(lotNumber) {
5705
+ // Handle empty/null
5706
+ if (!lotNumber)
5707
+ return { num: null, alpha: "" };
5708
+ // Split by comma first (handles "7-8, 10" format), flexible with whitespace
5709
+ let segments = lotNumber.split(/\s*,\s*/);
5710
+ let minNum = null;
5711
+ let minAlpha = "";
5712
+ for (let segment of segments) {
5713
+ // Split by hyphen (handles "7-9" range format), flexible with whitespace
5714
+ let rangeParts = segment.split(/\s*-\s*/);
5715
+ for (let part of rangeParts) {
5716
+ // Extract number and alpha from each part (e.g., "7A" -> 7, "A")
5717
+ let match = part.trim().match(/^(\d+)(\D*)$/);
5718
+ if (match) {
5719
+ let num = parseInt(match[1], 10);
5720
+ let alpha = match[2] || "";
5721
+ if (minNum === null ||
5722
+ num < minNum ||
5723
+ (num === minNum && alpha < minAlpha)) {
5724
+ minNum = num;
5725
+ minAlpha = alpha;
5726
+ }
5727
+ }
5728
+ }
5729
+ }
5730
+ return { num: minNum, alpha: minAlpha };
5731
+ }
5604
5732
  function lotComparator(a, b) {
5605
- const aMatch = a.lotNumber.match(/^(\d+)(\D*)$/);
5606
- const bMatch = b.lotNumber.match(/^(\d+)(\D*)$/);
5607
- // If neither matches the pattern, fall back to string comparison
5608
- if (!aMatch && !bMatch) {
5733
+ let aMin = extractMinLotNumber(a.lotNumber);
5734
+ let bMin = extractMinLotNumber(b.lotNumber);
5735
+ // If neither has numbers, fall back to string comparison
5736
+ if (aMin.num === null && bMin.num === null) {
5609
5737
  return a.lotNumber.localeCompare(b.lotNumber);
5610
5738
  }
5611
- // If only one matches, the one with numbers comes after
5612
- if (!aMatch)
5739
+ // If only one has numbers, the one without comes first
5740
+ if (aMin.num === null)
5613
5741
  return -1;
5614
- if (!bMatch)
5742
+ if (bMin.num === null)
5615
5743
  return 1;
5616
- // Handle cases with numbers
5617
- const aNum = parseInt(aMatch[1], 10);
5618
- const bNum = parseInt(bMatch[1], 10);
5619
- // Compare numeric parts first
5620
- if (aNum !== bNum)
5621
- return aNum - bNum;
5622
- // Get alphabetic suffixes (or empty string if none)
5623
- const aAlpha = (aMatch === null || aMatch === void 0 ? void 0 : aMatch[2]) || "";
5624
- const bAlpha = (bMatch === null || bMatch === void 0 ? void 0 : bMatch[2]) || "";
5625
- // Compare by length first (shorter comes first)
5626
- if (aAlpha.length !== bAlpha.length)
5627
- return aAlpha.length - bAlpha.length;
5628
- // Then compare alphabetically
5629
- return aAlpha.localeCompare(bAlpha);
5744
+ // Compare numeric parts
5745
+ if (aMin.num !== bMin.num)
5746
+ return aMin.num - bMin.num;
5747
+ // Compare alpha suffixes by length then alphabetically
5748
+ if (aMin.alpha.length !== bMin.alpha.length) {
5749
+ return aMin.alpha.length - bMin.alpha.length;
5750
+ }
5751
+ return aMin.alpha.localeCompare(bMin.alpha);
5630
5752
  }
5631
5753
  function sortByLotNumber(lots) {
5632
5754
  return [...lots].sort(lotComparator);