@marteye/studiojs 1.1.37 → 1.1.39

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$n(_) {
78
78
  const actions = {
79
79
  /***
80
80
  * This is used to construct the action from the request body
@@ -104,7 +104,59 @@ function create$k(_) {
104
104
  return actions;
105
105
  }
106
106
 
107
- function create$j(httpClient) {
107
+ function create$m(httpClient) {
108
+ let activity = {
109
+ /**
110
+ * List activity logs for a market with pagination and filtering
111
+ * @param marketId - ID of the market
112
+ * @param params - Optional filtering and pagination parameters
113
+ * @returns Paginated list of activity logs
114
+ */
115
+ list: async (marketId, params) => {
116
+ let queryParams = {};
117
+ if (params === null || params === void 0 ? void 0 : params.saleId) {
118
+ queryParams.saleId = params.saleId;
119
+ }
120
+ if (params === null || params === void 0 ? void 0 : params.entityType) {
121
+ queryParams.entityType = params.entityType;
122
+ }
123
+ if (params === null || params === void 0 ? void 0 : params.entityId) {
124
+ queryParams.entityId = params.entityId;
125
+ }
126
+ if (params === null || params === void 0 ? void 0 : params.operation) {
127
+ queryParams.operation = params.operation;
128
+ }
129
+ if (params === null || params === void 0 ? void 0 : params.memberId) {
130
+ queryParams.memberId = params.memberId;
131
+ }
132
+ if (params === null || params === void 0 ? void 0 : params.from) {
133
+ queryParams.from = params.from;
134
+ }
135
+ if (params === null || params === void 0 ? void 0 : params.to) {
136
+ queryParams.to = params.to;
137
+ }
138
+ if ((params === null || params === void 0 ? void 0 : params.limit) !== undefined) {
139
+ queryParams.limit = String(params.limit);
140
+ }
141
+ if (params === null || params === void 0 ? void 0 : params.lastId) {
142
+ queryParams.lastId = params.lastId;
143
+ }
144
+ return httpClient.get(`/${marketId}/activity`, queryParams);
145
+ },
146
+ /**
147
+ * Get a specific activity log by ID
148
+ * @param marketId - ID of the market
149
+ * @param activityId - ID of the activity log entry
150
+ * @returns The activity log details
151
+ */
152
+ get: async (marketId, activityId) => {
153
+ return httpClient.get(`/${marketId}/activity/${activityId}`);
154
+ },
155
+ };
156
+ return activity;
157
+ }
158
+
159
+ function create$l(httpClient) {
108
160
  return {
109
161
  list: async (marketId) => {
110
162
  return httpClient.get(`/${marketId}/adjustments`);
@@ -121,7 +173,30 @@ function create$j(httpClient) {
121
173
  };
122
174
  }
123
175
 
124
- function create$i(httpClient) {
176
+ function create$k(httpClient) {
177
+ return {
178
+ /**
179
+ * Get the full cart for a customer including extras and uninvoiced lots
180
+ */
181
+ get: async (marketId, customerId) => {
182
+ return httpClient.get(`/${marketId}/carts/${customerId}`);
183
+ },
184
+ /**
185
+ * Add an extra product to the customer's cart
186
+ */
187
+ addExtra: async (marketId, customerId, data) => {
188
+ return httpClient.post(`/${marketId}/carts/${customerId}`, data);
189
+ },
190
+ /**
191
+ * Remove an extra from the customer's cart
192
+ */
193
+ removeExtra: async (marketId, customerId, itemId) => {
194
+ return httpClient.delete(`/${marketId}/carts/${customerId}/${itemId}`);
195
+ },
196
+ };
197
+ }
198
+
199
+ function create$j(httpClient) {
125
200
  return {
126
201
  list: async (marketId) => {
127
202
  return httpClient.get(`/${marketId}/extras`);
@@ -141,7 +216,7 @@ function create$i(httpClient) {
141
216
  /***
142
217
  * Bidder applications
143
218
  */
144
- function create$h(httpClient) {
219
+ function create$i(httpClient) {
145
220
  let applications = {
146
221
  /**
147
222
  * List applications for a market with optional filtering
@@ -208,7 +283,7 @@ function create$h(httpClient) {
208
283
  }
209
284
 
210
285
  // Path: studiojs/src/resources/markets.ts
211
- function create$g(httpClient) {
286
+ function create$h(httpClient) {
212
287
  let customers = {
213
288
  list: async (marketId, lastId) => {
214
289
  let params = {};
@@ -5045,7 +5120,7 @@ const uploadSingleFile = async (input, token) => {
5045
5120
  };
5046
5121
 
5047
5122
  // Multipart Upload for Media to the MARTEYE Media Service
5048
- function create$f() {
5123
+ function create$g() {
5049
5124
  const files = {
5050
5125
  uploadSingleFile: async (input, token) => {
5051
5126
  return await uploadSingleFile(input, token);
@@ -5060,7 +5135,7 @@ function create$f() {
5060
5135
  return files;
5061
5136
  }
5062
5137
 
5063
- function create$e(httpClient) {
5138
+ function create$f(httpClient) {
5064
5139
  const invoices = {
5065
5140
  /**
5066
5141
  * List all invoices for a market with pagination
@@ -5088,7 +5163,7 @@ function create$e(httpClient) {
5088
5163
  return invoices;
5089
5164
  }
5090
5165
 
5091
- function create$d(httpClient) {
5166
+ function create$e(httpClient) {
5092
5167
  return {
5093
5168
  create: async (marketId, saleId, lotId, data) => {
5094
5169
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -5105,7 +5180,7 @@ function create$d(httpClient) {
5105
5180
  /**
5106
5181
  * Defines the possible status values for a lot in a sale
5107
5182
  */
5108
- function create$c(httpClient) {
5183
+ function create$d(httpClient) {
5109
5184
  return {
5110
5185
  get: async (marketId, saleId, lotId) => {
5111
5186
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -5125,7 +5200,7 @@ function create$c(httpClient) {
5125
5200
  };
5126
5201
  }
5127
5202
 
5128
- function create$b(httpClient) {
5203
+ function create$c(httpClient) {
5129
5204
  const markets = {
5130
5205
  get: async (marketId) => {
5131
5206
  return httpClient.get(`/${marketId}`);
@@ -5147,7 +5222,7 @@ function create$b(httpClient) {
5147
5222
  return markets;
5148
5223
  }
5149
5224
 
5150
- function create$a(httpClient) {
5225
+ function create$b(httpClient) {
5151
5226
  const payments = {
5152
5227
  /**
5153
5228
  * List all payments for a market with pagination
@@ -5175,7 +5250,7 @@ function create$a(httpClient) {
5175
5250
  return payments;
5176
5251
  }
5177
5252
 
5178
- function create$9(httpClient) {
5253
+ function create$a(httpClient) {
5179
5254
  const payouts = {
5180
5255
  /**
5181
5256
  * List all payouts for a market with pagination
@@ -5199,28 +5274,39 @@ function create$9(httpClient) {
5199
5274
  get: async (marketId, payoutId) => {
5200
5275
  return httpClient.get(`/${marketId}/payouts/${payoutId}`);
5201
5276
  },
5277
+ /**
5278
+ * Create a payout for one or more seller invoices.
5279
+ * Use this to re-create a payout after voiding (e.g., lost cheque).
5280
+ * Payment details will fall back to customer defaults if not provided.
5281
+ * @param marketId - ID of the market
5282
+ * @param data - Payout creation data
5283
+ * @returns The created payout
5284
+ */
5285
+ create: async (marketId, data) => {
5286
+ return httpClient.post(`/${marketId}/payouts`, data);
5287
+ },
5202
5288
  };
5203
5289
  return payouts;
5204
5290
  }
5205
5291
 
5206
- function create$8(httpClient) {
5292
+ function create$9(httpClient) {
5207
5293
  return {
5208
5294
  list: async (marketId) => {
5209
- return httpClient.get(`/${marketId}/product_codes`);
5295
+ return httpClient.get(`/${marketId}/product-codes`);
5210
5296
  },
5211
5297
  get: async (marketId, id) => {
5212
- return httpClient.get(`/${marketId}/product_codes/${id}`);
5298
+ return httpClient.get(`/${marketId}/product-codes/${id}`);
5213
5299
  },
5214
5300
  create: async (marketId, data) => {
5215
- return httpClient.post(`/${marketId}/product_codes`, data);
5301
+ return httpClient.post(`/${marketId}/product-codes`, data);
5216
5302
  },
5217
5303
  update: async (marketId, id, data) => {
5218
- return httpClient.post(`/${marketId}/product_codes/${id}`, data);
5304
+ return httpClient.post(`/${marketId}/product-codes/${id}`, data);
5219
5305
  },
5220
5306
  };
5221
5307
  }
5222
5308
 
5223
- function create$7(httpClient) {
5309
+ function create$8(httpClient) {
5224
5310
  return {
5225
5311
  get: async (marketId, saleId) => {
5226
5312
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -5237,7 +5323,7 @@ function create$7(httpClient) {
5237
5323
  };
5238
5324
  }
5239
5325
 
5240
- function create$6(httpClient) {
5326
+ function create$7(httpClient) {
5241
5327
  return {
5242
5328
  list: async (marketId) => {
5243
5329
  return httpClient.get(`/${marketId}/sale-templates`);
@@ -5257,7 +5343,7 @@ function create$6(httpClient) {
5257
5343
  };
5258
5344
  }
5259
5345
 
5260
- function create$5(httpClient) {
5346
+ function create$6(httpClient) {
5261
5347
  let search = {
5262
5348
  /**
5263
5349
  * Search for documents within a market
@@ -5272,7 +5358,7 @@ function create$5(httpClient) {
5272
5358
  return search;
5273
5359
  }
5274
5360
 
5275
- function create$4(httpClient) {
5361
+ function create$5(httpClient) {
5276
5362
  return {
5277
5363
  get: async (marketId) => {
5278
5364
  return httpClient.get(`/${marketId}/settings`);
@@ -5280,7 +5366,7 @@ function create$4(httpClient) {
5280
5366
  };
5281
5367
  }
5282
5368
 
5283
- function create$3(httpClient) {
5369
+ function create$4(httpClient) {
5284
5370
  return {
5285
5371
  list: async (marketId) => {
5286
5372
  return httpClient.get(`/${marketId}/tax_rates`);
@@ -5292,7 +5378,7 @@ function create$3(httpClient) {
5292
5378
  }
5293
5379
 
5294
5380
  // Path: studiojs/src/resources/markets.ts
5295
- function create$2(_) {
5381
+ function create$3(_) {
5296
5382
  const webhooks = {
5297
5383
  /***
5298
5384
  * This is used to construct the webhook event from the request body
@@ -5327,13 +5413,13 @@ function create$2(_) {
5327
5413
  return webhooks;
5328
5414
  }
5329
5415
 
5330
- function create$1(httpClient) {
5416
+ function create$2(httpClient) {
5331
5417
  return {
5332
5418
  lookup: async (marketId, cph) => httpClient.get(`/${marketId}/cph`, { cph }),
5333
5419
  };
5334
5420
  }
5335
5421
 
5336
- function create(httpClient) {
5422
+ function create$1(httpClient) {
5337
5423
  return {
5338
5424
  list: async (marketId, customerId, params) => {
5339
5425
  const query = {};
@@ -5358,29 +5444,87 @@ function create(httpClient) {
5358
5444
  };
5359
5445
  }
5360
5446
 
5447
+ function create(httpClient) {
5448
+ let ledger = {
5449
+ /**
5450
+ * Get the current balance for a ledger account
5451
+ * @param marketId - ID of the market
5452
+ * @param account - Full account string (format: owner:accountType:accountName)
5453
+ * e.g. "customerId:asset:trade receivable" or "market:liability:trade payable"
5454
+ * @returns The current balance in cents
5455
+ */
5456
+ getBalance: async (marketId, account) => {
5457
+ return httpClient.get(`/${marketId}/ledger/balance`, { account });
5458
+ },
5459
+ /**
5460
+ * Get a transaction by ID
5461
+ * @param marketId - ID of the market
5462
+ * @param transactionId - ID of the transaction
5463
+ * @returns The transaction details
5464
+ */
5465
+ getTransaction: async (marketId, transactionId) => {
5466
+ return httpClient.get(`/${marketId}/ledger/transactions/${transactionId}`);
5467
+ },
5468
+ /**
5469
+ * Get the latest transaction on an account
5470
+ * @param marketId - ID of the market
5471
+ * @param account - Full account string (format: owner:accountType:accountName)
5472
+ * @returns The latest transaction on the account
5473
+ */
5474
+ getLatestTransaction: async (marketId, account) => {
5475
+ return httpClient.get(`/${marketId}/ledger/transactions/latest`, { account });
5476
+ },
5477
+ /**
5478
+ * List transactions for an account with optional date range and pagination
5479
+ * @param marketId - ID of the market
5480
+ * @param params - Query parameters
5481
+ * @param params.account - Full account string (format: owner:accountType:accountName)
5482
+ * @param params.dateFrom - Optional start date (ISO 8601 format, e.g. "2024-01-01")
5483
+ * @param params.dateTo - Optional end date (ISO 8601 format, e.g. "2024-12-31")
5484
+ * @param params.limit - Optional max results (default 50, max 100)
5485
+ * @param params.cursor - Optional cursor for pagination
5486
+ * @returns List of transactions with pagination info
5487
+ */
5488
+ listTransactions: async (marketId, params) => {
5489
+ let queryParams = {
5490
+ account: params.account,
5491
+ dateFrom: params.dateFrom,
5492
+ dateTo: params.dateTo,
5493
+ limit: params.limit,
5494
+ cursor: params.cursor,
5495
+ };
5496
+ return httpClient.get(`/${marketId}/ledger/transactions`, queryParams);
5497
+ },
5498
+ };
5499
+ return ledger;
5500
+ }
5501
+
5361
5502
  function resources(httpClient) {
5362
5503
  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),
5504
+ activity: create$m(httpClient),
5505
+ markets: create$c(httpClient),
5506
+ sales: create$8(httpClient),
5507
+ lots: create$d(httpClient),
5508
+ lotitems: create$e(httpClient),
5509
+ carts: create$k(httpClient),
5510
+ cph: create$2(httpClient),
5511
+ webhooks: create$3(),
5512
+ actions: create$n(),
5513
+ bidderApplications: create$i(httpClient),
5514
+ settings: create$5(httpClient),
5515
+ adjustments: create$l(httpClient),
5516
+ extras: create$j(httpClient),
5517
+ productCodes: create$9(httpClient),
5518
+ saleTemplates: create$7(httpClient),
5519
+ taxRates: create$4(httpClient),
5520
+ customers: create$h(httpClient),
5521
+ invoices: create$f(httpClient),
5522
+ payments: create$b(httpClient),
5523
+ payouts: create$a(httpClient),
5524
+ search: create$6(httpClient),
5525
+ files: create$g(),
5526
+ contacts: create$1(httpClient),
5527
+ ledger: create(httpClient),
5384
5528
  };
5385
5529
  }
5386
5530
 
@@ -5754,28 +5898,70 @@ function sortByLotNumber(lots) {
5754
5898
  return [...lots].sort(lotComparator);
5755
5899
  }
5756
5900
  /***
5757
- * Generate the next lot number in a sequence:
5901
+ * Generate the next lot number in a sequence.
5902
+ * Handles various formats:
5903
+ * - Simple: "7" -> "8"
5904
+ * - Alphanumeric: "7A" -> "7B"
5905
+ * - Range: "1-3" -> "4", "1 - 3" -> "4" (flexible whitespace)
5906
+ * - Range with alpha: "1-3A" -> "3B"
5907
+ * - Compound: "1-3, 10" -> "11", "1-5, 7-9" -> "10"
5758
5908
  */
5759
5909
  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();
5910
+ // Helper to compare alpha suffixes (longer = greater, then alphabetically)
5911
+ function isGreaterAlpha(a, b) {
5912
+ let aUpper = a.toUpperCase();
5913
+ let bUpper = b.toUpperCase();
5914
+ if (aUpper.length !== bUpper.length) {
5915
+ return aUpper.length > bUpper.length;
5916
+ }
5917
+ return aUpper > bUpper;
5918
+ }
5919
+ // Split by comma (handles "7-8, 10" format), flexible with whitespace
5920
+ let segments = previousLotNumber.split(/\s*,\s*/);
5921
+ let maxNum = null;
5922
+ let maxAlpha = "";
5923
+ for (let segment of segments) {
5924
+ // Check if segment is a range (contains hyphen with numbers on both sides)
5925
+ // Flexible with whitespace: "1-3", "1 - 3", "1- 3", "1 -3", "1 -3"
5926
+ let rangeMatch = segment.trim().match(/^(\d+)\s*-\s*(\d+)(\D*)$/);
5927
+ if (rangeMatch) {
5928
+ // Range format: take the end number
5929
+ let endNum = parseInt(rangeMatch[2], 10);
5930
+ let alphaPart = rangeMatch[3] || "";
5931
+ if (maxNum === null ||
5932
+ endNum > maxNum ||
5933
+ (endNum === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
5934
+ maxNum = endNum;
5935
+ maxAlpha = alphaPart;
5936
+ }
5768
5937
  }
5769
5938
  else {
5770
- // Alphanumeric: increment the alpha part
5771
- const nextAlpha = incrementAlphaSequence(alphaPart);
5772
- return numPart + nextAlpha;
5939
+ // Single value: "7" or "7A"
5940
+ let singleMatch = segment.trim().match(/^(\d+)(\D*)$/);
5941
+ if (singleMatch) {
5942
+ let num = parseInt(singleMatch[1], 10);
5943
+ let alphaPart = singleMatch[2] || "";
5944
+ if (maxNum === null ||
5945
+ num > maxNum ||
5946
+ (num === maxNum && isGreaterAlpha(alphaPart, maxAlpha))) {
5947
+ maxNum = num;
5948
+ maxAlpha = alphaPart;
5949
+ }
5950
+ }
5773
5951
  }
5774
5952
  }
5775
- else {
5776
- // Pure alphabetic: A -> B, Z -> AA, etc.
5777
- return incrementAlphaSequence(previousLotNumber);
5953
+ // If we found numeric parts, increment
5954
+ if (maxNum !== null) {
5955
+ if (maxAlpha === "") {
5956
+ return (maxNum + 1).toString();
5957
+ }
5958
+ else {
5959
+ let nextAlpha = incrementAlphaSequence(maxAlpha);
5960
+ return maxNum + nextAlpha;
5961
+ }
5778
5962
  }
5963
+ // Fallback: treat as pure alphabetic (e.g., "A" -> "B")
5964
+ return incrementAlphaSequence(previousLotNumber);
5779
5965
  }
5780
5966
  function incrementAlphaSequence(alpha) {
5781
5967
  if (alpha === "") {