@marteye/studiojs 1.1.35 → 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$d(_) {
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$d(_) {
97
100
  return actions;
98
101
  }
99
102
 
100
- function create$c(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$c(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$b(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$b(httpClient) {
178
204
  }
179
205
 
180
206
  // Path: studiojs/src/resources/markets.ts
181
- function create$a(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$a(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$9() {
5044
+ function create$f() {
5016
5045
  const files = {
5017
5046
  uploadSingleFile: async (input, token) => {
5018
5047
  return await uploadSingleFile(input, token);
@@ -5027,7 +5056,35 @@ function create$9() {
5027
5056
  return files;
5028
5057
  }
5029
5058
 
5030
- function create$8(httpClient) {
5059
+ function create$e(httpClient) {
5060
+ const invoices = {
5061
+ /**
5062
+ * List all invoices for a market with pagination
5063
+ * @param marketId - ID of the market
5064
+ * @param lastId - ID of the last invoice from previous page (for pagination)
5065
+ * @returns Paginated list of invoices
5066
+ */
5067
+ list: async (marketId, lastId) => {
5068
+ let params = {};
5069
+ if (lastId) {
5070
+ params.lastId = lastId;
5071
+ }
5072
+ return httpClient.get(`/${marketId}/invoices`, params);
5073
+ },
5074
+ /**
5075
+ * Get a specific invoice by ID
5076
+ * @param marketId - ID of the market
5077
+ * @param invoiceId - ID of the invoice to fetch
5078
+ * @returns The invoice details
5079
+ */
5080
+ get: async (marketId, invoiceId) => {
5081
+ return httpClient.get(`/${marketId}/invoices/${invoiceId}`);
5082
+ },
5083
+ };
5084
+ return invoices;
5085
+ }
5086
+
5087
+ function create$d(httpClient) {
5031
5088
  return {
5032
5089
  create: async (marketId, saleId, lotId, data) => {
5033
5090
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5044,7 +5101,7 @@ function create$8(httpClient) {
5044
5101
  /**
5045
5102
  * Defines the possible status values for a lot in a sale
5046
5103
  */
5047
- function create$7(httpClient) {
5104
+ function create$c(httpClient) {
5048
5105
  return {
5049
5106
  get: async (marketId, saleId, lotId) => {
5050
5107
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5064,7 +5121,7 @@ function create$7(httpClient) {
5064
5121
  };
5065
5122
  }
5066
5123
 
5067
- function create$6(httpClient) {
5124
+ function create$b(httpClient) {
5068
5125
  const markets = {
5069
5126
  get: async (marketId) => {
5070
5127
  return httpClient.get(`/${marketId}`);
@@ -5086,7 +5143,63 @@ function create$6(httpClient) {
5086
5143
  return markets;
5087
5144
  }
5088
5145
 
5089
- function create$5(httpClient) {
5146
+ function create$a(httpClient) {
5147
+ const payments = {
5148
+ /**
5149
+ * List all payments for a market with pagination
5150
+ * @param marketId - ID of the market
5151
+ * @param lastId - ID of the last payment from previous page (for pagination)
5152
+ * @returns Paginated list of payments
5153
+ */
5154
+ list: async (marketId, lastId) => {
5155
+ let params = {};
5156
+ if (lastId) {
5157
+ params.lastId = lastId;
5158
+ }
5159
+ return httpClient.get(`/${marketId}/payments`, params);
5160
+ },
5161
+ /**
5162
+ * Get a specific payment by ID
5163
+ * @param marketId - ID of the market
5164
+ * @param paymentId - ID of the payment to fetch
5165
+ * @returns The payment details
5166
+ */
5167
+ get: async (marketId, paymentId) => {
5168
+ return httpClient.get(`/${marketId}/payments/${paymentId}`);
5169
+ },
5170
+ };
5171
+ return payments;
5172
+ }
5173
+
5174
+ function create$9(httpClient) {
5175
+ const payouts = {
5176
+ /**
5177
+ * List all payouts for a market with pagination
5178
+ * @param marketId - ID of the market
5179
+ * @param lastId - ID of the last payout from previous page (for pagination)
5180
+ * @returns Paginated list of payouts
5181
+ */
5182
+ list: async (marketId, lastId) => {
5183
+ let params = {};
5184
+ if (lastId) {
5185
+ params.lastId = lastId;
5186
+ }
5187
+ return httpClient.get(`/${marketId}/payouts`, params);
5188
+ },
5189
+ /**
5190
+ * Get a specific payout by ID
5191
+ * @param marketId - ID of the market
5192
+ * @param payoutId - ID of the payout to fetch
5193
+ * @returns The payout details
5194
+ */
5195
+ get: async (marketId, payoutId) => {
5196
+ return httpClient.get(`/${marketId}/payouts/${payoutId}`);
5197
+ },
5198
+ };
5199
+ return payouts;
5200
+ }
5201
+
5202
+ function create$8(httpClient) {
5090
5203
  return {
5091
5204
  list: async (marketId) => {
5092
5205
  return httpClient.get(`/${marketId}/product_codes`);
@@ -5094,10 +5207,16 @@ function create$5(httpClient) {
5094
5207
  get: async (marketId, id) => {
5095
5208
  return httpClient.get(`/${marketId}/product_codes/${id}`);
5096
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
+ },
5097
5216
  };
5098
5217
  }
5099
5218
 
5100
- function create$4(httpClient) {
5219
+ function create$7(httpClient) {
5101
5220
  return {
5102
5221
  get: async (marketId, saleId) => {
5103
5222
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5114,7 +5233,27 @@ function create$4(httpClient) {
5114
5233
  };
5115
5234
  }
5116
5235
 
5117
- 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) {
5118
5257
  let search = {
5119
5258
  /**
5120
5259
  * Search for documents within a market
@@ -5129,7 +5268,7 @@ function create$3(httpClient) {
5129
5268
  return search;
5130
5269
  }
5131
5270
 
5132
- function create$2(httpClient) {
5271
+ function create$4(httpClient) {
5133
5272
  return {
5134
5273
  get: async (marketId) => {
5135
5274
  return httpClient.get(`/${marketId}/settings`);
@@ -5137,7 +5276,7 @@ function create$2(httpClient) {
5137
5276
  };
5138
5277
  }
5139
5278
 
5140
- function create$1(httpClient) {
5279
+ function create$3(httpClient) {
5141
5280
  return {
5142
5281
  list: async (marketId) => {
5143
5282
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5149,7 +5288,7 @@ function create$1(httpClient) {
5149
5288
  }
5150
5289
 
5151
5290
  // Path: studiojs/src/resources/markets.ts
5152
- function create(_) {
5291
+ function create$2(_) {
5153
5292
  const webhooks = {
5154
5293
  /***
5155
5294
  * This is used to construct the webhook event from the request body
@@ -5184,22 +5323,60 @@ function create(_) {
5184
5323
  return webhooks;
5185
5324
  }
5186
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
+
5187
5357
  function resources(httpClient) {
5188
5358
  return {
5189
- markets: create$6(httpClient),
5190
- sales: create$4(httpClient),
5191
- lots: create$7(httpClient),
5192
- lotitems: create$8(httpClient),
5193
- webhooks: create(),
5194
- actions: create$d(),
5195
- bidderApplications: create$b(httpClient),
5196
- settings: create$2(httpClient),
5197
- adjustments: create$c(httpClient),
5198
- productCodes: create$5(httpClient),
5199
- taxRates: create$1(httpClient),
5200
- customers: create$a(httpClient),
5201
- search: create$3(httpClient),
5202
- files: create$9(),
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),
5203
5380
  };
5204
5381
  }
5205
5382
 
@@ -5510,32 +5687,64 @@ EarTag.countryCodes = {
5510
5687
  BE: "056",
5511
5688
  };
5512
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
+ }
5513
5728
  function lotComparator(a, b) {
5514
- const aMatch = a.lotNumber.match(/^(\d+)(\D*)$/);
5515
- const bMatch = b.lotNumber.match(/^(\d+)(\D*)$/);
5516
- // If neither matches the pattern, fall back to string comparison
5517
- 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) {
5518
5733
  return a.lotNumber.localeCompare(b.lotNumber);
5519
5734
  }
5520
- // If only one matches, the one with numbers comes after
5521
- if (!aMatch)
5735
+ // If only one has numbers, the one without comes first
5736
+ if (aMin.num === null)
5522
5737
  return -1;
5523
- if (!bMatch)
5738
+ if (bMin.num === null)
5524
5739
  return 1;
5525
- // Handle cases with numbers
5526
- const aNum = parseInt(aMatch[1], 10);
5527
- const bNum = parseInt(bMatch[1], 10);
5528
- // Compare numeric parts first
5529
- if (aNum !== bNum)
5530
- return aNum - bNum;
5531
- // Get alphabetic suffixes (or empty string if none)
5532
- const aAlpha = (aMatch === null || aMatch === void 0 ? void 0 : aMatch[2]) || "";
5533
- const bAlpha = (bMatch === null || bMatch === void 0 ? void 0 : bMatch[2]) || "";
5534
- // Compare by length first (shorter comes first)
5535
- if (aAlpha.length !== bAlpha.length)
5536
- return aAlpha.length - bAlpha.length;
5537
- // Then compare alphabetically
5538
- 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);
5539
5748
  }
5540
5749
  function sortByLotNumber(lots) {
5541
5750
  return [...lots].sort(lotComparator);