@marteye/studiojs 1.1.37 → 1.1.38

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
@@ -74,7 +74,7 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
74
74
  }
75
75
 
76
76
  // Path: studiojs/src/resources/markets.ts
77
- function create$k(_) {
77
+ function create$m(_) {
78
78
  const actions = {
79
79
  /***
80
80
  * This is used to construct the action from the request body
@@ -104,7 +104,7 @@ function create$k(_) {
104
104
  return actions;
105
105
  }
106
106
 
107
- function create$j(httpClient) {
107
+ function create$l(httpClient) {
108
108
  return {
109
109
  list: async (marketId) => {
110
110
  return httpClient.get(`/${marketId}/adjustments`);
@@ -121,7 +121,30 @@ function create$j(httpClient) {
121
121
  };
122
122
  }
123
123
 
124
- function create$i(httpClient) {
124
+ function create$k(httpClient) {
125
+ return {
126
+ /**
127
+ * Get the full cart for a customer including extras and uninvoiced lots
128
+ */
129
+ get: async (marketId, customerId) => {
130
+ return httpClient.get(`/${marketId}/carts/${customerId}`);
131
+ },
132
+ /**
133
+ * Add an extra product to the customer's cart
134
+ */
135
+ addExtra: async (marketId, customerId, data) => {
136
+ return httpClient.post(`/${marketId}/carts/${customerId}`, data);
137
+ },
138
+ /**
139
+ * Remove an extra from the customer's cart
140
+ */
141
+ removeExtra: async (marketId, customerId, itemId) => {
142
+ return httpClient.delete(`/${marketId}/carts/${customerId}/${itemId}`);
143
+ },
144
+ };
145
+ }
146
+
147
+ function create$j(httpClient) {
125
148
  return {
126
149
  list: async (marketId) => {
127
150
  return httpClient.get(`/${marketId}/extras`);
@@ -141,7 +164,7 @@ function create$i(httpClient) {
141
164
  /***
142
165
  * Bidder applications
143
166
  */
144
- function create$h(httpClient) {
167
+ function create$i(httpClient) {
145
168
  let applications = {
146
169
  /**
147
170
  * List applications for a market with optional filtering
@@ -208,7 +231,7 @@ function create$h(httpClient) {
208
231
  }
209
232
 
210
233
  // Path: studiojs/src/resources/markets.ts
211
- function create$g(httpClient) {
234
+ function create$h(httpClient) {
212
235
  let customers = {
213
236
  list: async (marketId, lastId) => {
214
237
  let params = {};
@@ -5045,7 +5068,7 @@ const uploadSingleFile = async (input, token) => {
5045
5068
  };
5046
5069
 
5047
5070
  // Multipart Upload for Media to the MARTEYE Media Service
5048
- function create$f() {
5071
+ function create$g() {
5049
5072
  const files = {
5050
5073
  uploadSingleFile: async (input, token) => {
5051
5074
  return await uploadSingleFile(input, token);
@@ -5060,7 +5083,7 @@ function create$f() {
5060
5083
  return files;
5061
5084
  }
5062
5085
 
5063
- function create$e(httpClient) {
5086
+ function create$f(httpClient) {
5064
5087
  const invoices = {
5065
5088
  /**
5066
5089
  * List all invoices for a market with pagination
@@ -5088,7 +5111,7 @@ function create$e(httpClient) {
5088
5111
  return invoices;
5089
5112
  }
5090
5113
 
5091
- function create$d(httpClient) {
5114
+ function create$e(httpClient) {
5092
5115
  return {
5093
5116
  create: async (marketId, saleId, lotId, data) => {
5094
5117
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5105,7 +5128,7 @@ function create$d(httpClient) {
5105
5128
  /**
5106
5129
  * Defines the possible status values for a lot in a sale
5107
5130
  */
5108
- function create$c(httpClient) {
5131
+ function create$d(httpClient) {
5109
5132
  return {
5110
5133
  get: async (marketId, saleId, lotId) => {
5111
5134
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5125,7 +5148,7 @@ function create$c(httpClient) {
5125
5148
  };
5126
5149
  }
5127
5150
 
5128
- function create$b(httpClient) {
5151
+ function create$c(httpClient) {
5129
5152
  const markets = {
5130
5153
  get: async (marketId) => {
5131
5154
  return httpClient.get(`/${marketId}`);
@@ -5147,7 +5170,7 @@ function create$b(httpClient) {
5147
5170
  return markets;
5148
5171
  }
5149
5172
 
5150
- function create$a(httpClient) {
5173
+ function create$b(httpClient) {
5151
5174
  const payments = {
5152
5175
  /**
5153
5176
  * List all payments for a market with pagination
@@ -5175,7 +5198,7 @@ function create$a(httpClient) {
5175
5198
  return payments;
5176
5199
  }
5177
5200
 
5178
- function create$9(httpClient) {
5201
+ function create$a(httpClient) {
5179
5202
  const payouts = {
5180
5203
  /**
5181
5204
  * List all payouts for a market with pagination
@@ -5203,24 +5226,24 @@ function create$9(httpClient) {
5203
5226
  return payouts;
5204
5227
  }
5205
5228
 
5206
- function create$8(httpClient) {
5229
+ function create$9(httpClient) {
5207
5230
  return {
5208
5231
  list: async (marketId) => {
5209
- return httpClient.get(`/${marketId}/product_codes`);
5232
+ return httpClient.get(`/${marketId}/product-codes`);
5210
5233
  },
5211
5234
  get: async (marketId, id) => {
5212
- return httpClient.get(`/${marketId}/product_codes/${id}`);
5235
+ return httpClient.get(`/${marketId}/product-codes/${id}`);
5213
5236
  },
5214
5237
  create: async (marketId, data) => {
5215
- return httpClient.post(`/${marketId}/product_codes`, data);
5238
+ return httpClient.post(`/${marketId}/product-codes`, data);
5216
5239
  },
5217
5240
  update: async (marketId, id, data) => {
5218
- return httpClient.post(`/${marketId}/product_codes/${id}`, data);
5241
+ return httpClient.post(`/${marketId}/product-codes/${id}`, data);
5219
5242
  },
5220
5243
  };
5221
5244
  }
5222
5245
 
5223
- function create$7(httpClient) {
5246
+ function create$8(httpClient) {
5224
5247
  return {
5225
5248
  get: async (marketId, saleId) => {
5226
5249
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5237,7 +5260,7 @@ function create$7(httpClient) {
5237
5260
  };
5238
5261
  }
5239
5262
 
5240
- function create$6(httpClient) {
5263
+ function create$7(httpClient) {
5241
5264
  return {
5242
5265
  list: async (marketId) => {
5243
5266
  return httpClient.get(`/${marketId}/sale-templates`);
@@ -5257,7 +5280,7 @@ function create$6(httpClient) {
5257
5280
  };
5258
5281
  }
5259
5282
 
5260
- function create$5(httpClient) {
5283
+ function create$6(httpClient) {
5261
5284
  let search = {
5262
5285
  /**
5263
5286
  * Search for documents within a market
@@ -5272,7 +5295,7 @@ function create$5(httpClient) {
5272
5295
  return search;
5273
5296
  }
5274
5297
 
5275
- function create$4(httpClient) {
5298
+ function create$5(httpClient) {
5276
5299
  return {
5277
5300
  get: async (marketId) => {
5278
5301
  return httpClient.get(`/${marketId}/settings`);
@@ -5280,7 +5303,7 @@ function create$4(httpClient) {
5280
5303
  };
5281
5304
  }
5282
5305
 
5283
- function create$3(httpClient) {
5306
+ function create$4(httpClient) {
5284
5307
  return {
5285
5308
  list: async (marketId) => {
5286
5309
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5292,7 +5315,7 @@ function create$3(httpClient) {
5292
5315
  }
5293
5316
 
5294
5317
  // Path: studiojs/src/resources/markets.ts
5295
- function create$2(_) {
5318
+ function create$3(_) {
5296
5319
  const webhooks = {
5297
5320
  /***
5298
5321
  * This is used to construct the webhook event from the request body
@@ -5327,13 +5350,13 @@ function create$2(_) {
5327
5350
  return webhooks;
5328
5351
  }
5329
5352
 
5330
- function create$1(httpClient) {
5353
+ function create$2(httpClient) {
5331
5354
  return {
5332
5355
  lookup: async (marketId, cph) => httpClient.get(`/${marketId}/cph`, { cph }),
5333
5356
  };
5334
5357
  }
5335
5358
 
5336
- function create(httpClient) {
5359
+ function create$1(httpClient) {
5337
5360
  return {
5338
5361
  list: async (marketId, customerId, params) => {
5339
5362
  const query = {};
@@ -5358,29 +5381,47 @@ function create(httpClient) {
5358
5381
  };
5359
5382
  }
5360
5383
 
5384
+ function create(httpClient) {
5385
+ let ledger = {
5386
+ /**
5387
+ * Get the current balance for a ledger account
5388
+ * @param marketId - ID of the market
5389
+ * @param account - Full account string (format: owner:accountType:accountName)
5390
+ * e.g. "customerId:asset:trade receivable" or "market:liability:trade payable"
5391
+ * @returns The current balance in cents
5392
+ */
5393
+ getBalance: async (marketId, account) => {
5394
+ return httpClient.get(`/${marketId}/ledger/balance`, { account });
5395
+ },
5396
+ };
5397
+ return ledger;
5398
+ }
5399
+
5361
5400
  function resources(httpClient) {
5362
5401
  return {
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),
5402
+ markets: create$c(httpClient),
5403
+ sales: create$8(httpClient),
5404
+ lots: create$d(httpClient),
5405
+ lotitems: create$e(httpClient),
5406
+ carts: create$k(httpClient),
5407
+ cph: create$2(httpClient),
5408
+ webhooks: create$3(),
5409
+ actions: create$m(),
5410
+ bidderApplications: create$i(httpClient),
5411
+ settings: create$5(httpClient),
5412
+ adjustments: create$l(httpClient),
5413
+ extras: create$j(httpClient),
5414
+ productCodes: create$9(httpClient),
5415
+ saleTemplates: create$7(httpClient),
5416
+ taxRates: create$4(httpClient),
5417
+ customers: create$h(httpClient),
5418
+ invoices: create$f(httpClient),
5419
+ payments: create$b(httpClient),
5420
+ payouts: create$a(httpClient),
5421
+ search: create$6(httpClient),
5422
+ files: create$g(),
5423
+ contacts: create$1(httpClient),
5424
+ ledger: create(httpClient),
5384
5425
  };
5385
5426
  }
5386
5427
 
@@ -5754,28 +5795,70 @@ function sortByLotNumber(lots) {
5754
5795
  return [...lots].sort(lotComparator);
5755
5796
  }
5756
5797
  /***
5757
- * Generate the next lot number in a sequence:
5798
+ * Generate the next lot number in a sequence.
5799
+ * Handles various formats:
5800
+ * - Simple: "7" -> "8"
5801
+ * - Alphanumeric: "7A" -> "7B"
5802
+ * - Range: "1-3" -> "4", "1 - 3" -> "4" (flexible whitespace)
5803
+ * - Range with alpha: "1-3A" -> "3B"
5804
+ * - Compound: "1-3, 10" -> "11", "1-5, 7-9" -> "10"
5758
5805
  */
5759
5806
  function nextLotNumber(previousLotNumber) {
5760
- const match = previousLotNumber.match(/^(\d+)(\D*)$/);
5761
- if (match) {
5762
- // Has numeric part
5763
- const numPart = parseInt(match[1], 10);
5764
- const alphaPart = match[2];
5765
- if (alphaPart === "") {
5766
- // Just a number: 1 -> 2
5767
- return (numPart + 1).toString();
5807
+ // Helper to compare alpha suffixes (longer = greater, then alphabetically)
5808
+ function isGreaterAlpha(a, b) {
5809
+ let aUpper = a.toUpperCase();
5810
+ let bUpper = b.toUpperCase();
5811
+ if (aUpper.length !== bUpper.length) {
5812
+ return aUpper.length > bUpper.length;
5813
+ }
5814
+ return aUpper > bUpper;
5815
+ }
5816
+ // Split by comma (handles "7-8, 10" format), flexible with whitespace
5817
+ let segments = previousLotNumber.split(/\s*,\s*/);
5818
+ let maxNum = null;
5819
+ let maxAlpha = "";
5820
+ for (let segment of segments) {
5821
+ // Check if segment is a range (contains hyphen with numbers on both sides)
5822
+ // Flexible with whitespace: "1-3", "1 - 3", "1- 3", "1 -3", "1 -3"
5823
+ let rangeMatch = segment.trim().match(/^(\d+)\s*-\s*(\d+)(\D*)$/);
5824
+ if (rangeMatch) {
5825
+ // Range format: take the end number
5826
+ let endNum = parseInt(rangeMatch[2], 10);
5827
+ let alphaPart = rangeMatch[3] || "";
5828
+ if (maxNum === null ||
5829
+ endNum > maxNum ||
5830
+ (endNum === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
5831
+ maxNum = endNum;
5832
+ maxAlpha = alphaPart;
5833
+ }
5768
5834
  }
5769
5835
  else {
5770
- // Alphanumeric: increment the alpha part
5771
- const nextAlpha = incrementAlphaSequence(alphaPart);
5772
- return numPart + nextAlpha;
5836
+ // Single value: "7" or "7A"
5837
+ let singleMatch = segment.trim().match(/^(\d+)(\D*)$/);
5838
+ if (singleMatch) {
5839
+ let num = parseInt(singleMatch[1], 10);
5840
+ let alphaPart = singleMatch[2] || "";
5841
+ if (maxNum === null ||
5842
+ num > maxNum ||
5843
+ (num === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
5844
+ maxNum = num;
5845
+ maxAlpha = alphaPart;
5846
+ }
5847
+ }
5773
5848
  }
5774
5849
  }
5775
- else {
5776
- // Pure alphabetic: A -> B, Z -> AA, etc.
5777
- return incrementAlphaSequence(previousLotNumber);
5850
+ // If we found numeric parts, increment
5851
+ if (maxNum !== null) {
5852
+ if (maxAlpha === "") {
5853
+ return (maxNum + 1).toString();
5854
+ }
5855
+ else {
5856
+ let nextAlpha = incrementAlphaSequence(maxAlpha);
5857
+ return maxNum + nextAlpha;
5858
+ }
5778
5859
  }
5860
+ // Fallback: treat as pure alphabetic (e.g., "A" -> "B")
5861
+ return incrementAlphaSequence(previousLotNumber);
5779
5862
  }
5780
5863
  function incrementAlphaSequence(alpha) {
5781
5864
  if (alpha === "") {