@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.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$d(_) {
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$d(_) {
101
104
  return actions;
102
105
  }
103
106
 
104
- function create$c(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$c(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$b(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$b(httpClient) {
182
208
  }
183
209
 
184
210
  // Path: studiojs/src/resources/markets.ts
185
- function create$a(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$a(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$9() {
5048
+ function create$f() {
5020
5049
  const files = {
5021
5050
  uploadSingleFile: async (input, token) => {
5022
5051
  return await uploadSingleFile(input, token);
@@ -5031,7 +5060,35 @@ function create$9() {
5031
5060
  return files;
5032
5061
  }
5033
5062
 
5034
- function create$8(httpClient) {
5063
+ function create$e(httpClient) {
5064
+ const invoices = {
5065
+ /**
5066
+ * List all invoices for a market with pagination
5067
+ * @param marketId - ID of the market
5068
+ * @param lastId - ID of the last invoice from previous page (for pagination)
5069
+ * @returns Paginated list of invoices
5070
+ */
5071
+ list: async (marketId, lastId) => {
5072
+ let params = {};
5073
+ if (lastId) {
5074
+ params.lastId = lastId;
5075
+ }
5076
+ return httpClient.get(`/${marketId}/invoices`, params);
5077
+ },
5078
+ /**
5079
+ * Get a specific invoice by ID
5080
+ * @param marketId - ID of the market
5081
+ * @param invoiceId - ID of the invoice to fetch
5082
+ * @returns The invoice details
5083
+ */
5084
+ get: async (marketId, invoiceId) => {
5085
+ return httpClient.get(`/${marketId}/invoices/${invoiceId}`);
5086
+ },
5087
+ };
5088
+ return invoices;
5089
+ }
5090
+
5091
+ function create$d(httpClient) {
5035
5092
  return {
5036
5093
  create: async (marketId, saleId, lotId, data) => {
5037
5094
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5048,7 +5105,7 @@ function create$8(httpClient) {
5048
5105
  /**
5049
5106
  * Defines the possible status values for a lot in a sale
5050
5107
  */
5051
- function create$7(httpClient) {
5108
+ function create$c(httpClient) {
5052
5109
  return {
5053
5110
  get: async (marketId, saleId, lotId) => {
5054
5111
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5068,7 +5125,7 @@ function create$7(httpClient) {
5068
5125
  };
5069
5126
  }
5070
5127
 
5071
- function create$6(httpClient) {
5128
+ function create$b(httpClient) {
5072
5129
  const markets = {
5073
5130
  get: async (marketId) => {
5074
5131
  return httpClient.get(`/${marketId}`);
@@ -5090,7 +5147,63 @@ function create$6(httpClient) {
5090
5147
  return markets;
5091
5148
  }
5092
5149
 
5093
- function create$5(httpClient) {
5150
+ function create$a(httpClient) {
5151
+ const payments = {
5152
+ /**
5153
+ * List all payments for a market with pagination
5154
+ * @param marketId - ID of the market
5155
+ * @param lastId - ID of the last payment from previous page (for pagination)
5156
+ * @returns Paginated list of payments
5157
+ */
5158
+ list: async (marketId, lastId) => {
5159
+ let params = {};
5160
+ if (lastId) {
5161
+ params.lastId = lastId;
5162
+ }
5163
+ return httpClient.get(`/${marketId}/payments`, params);
5164
+ },
5165
+ /**
5166
+ * Get a specific payment by ID
5167
+ * @param marketId - ID of the market
5168
+ * @param paymentId - ID of the payment to fetch
5169
+ * @returns The payment details
5170
+ */
5171
+ get: async (marketId, paymentId) => {
5172
+ return httpClient.get(`/${marketId}/payments/${paymentId}`);
5173
+ },
5174
+ };
5175
+ return payments;
5176
+ }
5177
+
5178
+ function create$9(httpClient) {
5179
+ const payouts = {
5180
+ /**
5181
+ * List all payouts for a market with pagination
5182
+ * @param marketId - ID of the market
5183
+ * @param lastId - ID of the last payout from previous page (for pagination)
5184
+ * @returns Paginated list of payouts
5185
+ */
5186
+ list: async (marketId, lastId) => {
5187
+ let params = {};
5188
+ if (lastId) {
5189
+ params.lastId = lastId;
5190
+ }
5191
+ return httpClient.get(`/${marketId}/payouts`, params);
5192
+ },
5193
+ /**
5194
+ * Get a specific payout by ID
5195
+ * @param marketId - ID of the market
5196
+ * @param payoutId - ID of the payout to fetch
5197
+ * @returns The payout details
5198
+ */
5199
+ get: async (marketId, payoutId) => {
5200
+ return httpClient.get(`/${marketId}/payouts/${payoutId}`);
5201
+ },
5202
+ };
5203
+ return payouts;
5204
+ }
5205
+
5206
+ function create$8(httpClient) {
5094
5207
  return {
5095
5208
  list: async (marketId) => {
5096
5209
  return httpClient.get(`/${marketId}/product_codes`);
@@ -5098,10 +5211,16 @@ function create$5(httpClient) {
5098
5211
  get: async (marketId, id) => {
5099
5212
  return httpClient.get(`/${marketId}/product_codes/${id}`);
5100
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
+ },
5101
5220
  };
5102
5221
  }
5103
5222
 
5104
- function create$4(httpClient) {
5223
+ function create$7(httpClient) {
5105
5224
  return {
5106
5225
  get: async (marketId, saleId) => {
5107
5226
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5118,7 +5237,27 @@ function create$4(httpClient) {
5118
5237
  };
5119
5238
  }
5120
5239
 
5121
- 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) {
5122
5261
  let search = {
5123
5262
  /**
5124
5263
  * Search for documents within a market
@@ -5133,7 +5272,7 @@ function create$3(httpClient) {
5133
5272
  return search;
5134
5273
  }
5135
5274
 
5136
- function create$2(httpClient) {
5275
+ function create$4(httpClient) {
5137
5276
  return {
5138
5277
  get: async (marketId) => {
5139
5278
  return httpClient.get(`/${marketId}/settings`);
@@ -5141,7 +5280,7 @@ function create$2(httpClient) {
5141
5280
  };
5142
5281
  }
5143
5282
 
5144
- function create$1(httpClient) {
5283
+ function create$3(httpClient) {
5145
5284
  return {
5146
5285
  list: async (marketId) => {
5147
5286
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5153,7 +5292,7 @@ function create$1(httpClient) {
5153
5292
  }
5154
5293
 
5155
5294
  // Path: studiojs/src/resources/markets.ts
5156
- function create(_) {
5295
+ function create$2(_) {
5157
5296
  const webhooks = {
5158
5297
  /***
5159
5298
  * This is used to construct the webhook event from the request body
@@ -5188,22 +5327,60 @@ function create(_) {
5188
5327
  return webhooks;
5189
5328
  }
5190
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
+
5191
5361
  function resources(httpClient) {
5192
5362
  return {
5193
- markets: create$6(httpClient),
5194
- sales: create$4(httpClient),
5195
- lots: create$7(httpClient),
5196
- lotitems: create$8(httpClient),
5197
- webhooks: create(),
5198
- actions: create$d(),
5199
- bidderApplications: create$b(httpClient),
5200
- settings: create$2(httpClient),
5201
- adjustments: create$c(httpClient),
5202
- productCodes: create$5(httpClient),
5203
- taxRates: create$1(httpClient),
5204
- customers: create$a(httpClient),
5205
- search: create$3(httpClient),
5206
- files: create$9(),
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),
5207
5384
  };
5208
5385
  }
5209
5386
 
@@ -5514,32 +5691,64 @@ EarTag.countryCodes = {
5514
5691
  BE: "056",
5515
5692
  };
5516
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
+ }
5517
5732
  function lotComparator(a, b) {
5518
- const aMatch = a.lotNumber.match(/^(\d+)(\D*)$/);
5519
- const bMatch = b.lotNumber.match(/^(\d+)(\D*)$/);
5520
- // If neither matches the pattern, fall back to string comparison
5521
- 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) {
5522
5737
  return a.lotNumber.localeCompare(b.lotNumber);
5523
5738
  }
5524
- // If only one matches, the one with numbers comes after
5525
- if (!aMatch)
5739
+ // If only one has numbers, the one without comes first
5740
+ if (aMin.num === null)
5526
5741
  return -1;
5527
- if (!bMatch)
5742
+ if (bMin.num === null)
5528
5743
  return 1;
5529
- // Handle cases with numbers
5530
- const aNum = parseInt(aMatch[1], 10);
5531
- const bNum = parseInt(bMatch[1], 10);
5532
- // Compare numeric parts first
5533
- if (aNum !== bNum)
5534
- return aNum - bNum;
5535
- // Get alphabetic suffixes (or empty string if none)
5536
- const aAlpha = (aMatch === null || aMatch === void 0 ? void 0 : aMatch[2]) || "";
5537
- const bAlpha = (bMatch === null || bMatch === void 0 ? void 0 : bMatch[2]) || "";
5538
- // Compare by length first (shorter comes first)
5539
- if (aAlpha.length !== bAlpha.length)
5540
- return aAlpha.length - bAlpha.length;
5541
- // Then compare alphabetically
5542
- 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);
5543
5752
  }
5544
5753
  function sortByLotNumber(lots) {
5545
5754
  return [...lots].sort(lotComparator);