@marteye/studiojs 1.1.10 → 1.1.12

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.d.ts CHANGED
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Search result interface based on the API implementation
3
+ */
4
+ interface SearchResult {
5
+ hits: Array<{
6
+ id: string;
7
+ marketId: string;
8
+ title: string;
9
+ [key: string]: any;
10
+ }>;
11
+ processingTimeMs: number;
12
+ query: string;
13
+ }
14
+
1
15
  type Timestamp = string;
2
16
  type ClientType = "Seller" | "Buyer";
3
17
  type SuperType = "Sheep" | "Goats" | "Cattle" | "Pigs" | "Horses" | "Deer" | "Poultry" | "Machinery" | "Antiques" | "Other";
@@ -1024,6 +1038,30 @@ declare namespace types {
1024
1038
  export { type types_Accessory as Accessory, type types_Address as Address, type types_AddressWrapper as AddressWrapper, type types_AdjustmentTarget as AdjustmentTarget, type types_AdjustmentTotalTarget as AdjustmentTotalTarget, type types_AdjustmentsConfiguration as AdjustmentsConfiguration, type types_AppParameterConfig as AppParameterConfig, type types_AttributeDefinition as AttributeDefinition, type types_AttributeValueType as AttributeValueType, type types_BankDetails as BankDetails, type types_Cart as Cart, type types_CartItem as CartItem, type types_ChequeField as ChequeField, type types_ClientType as ClientType, type types_CurrenciesWithGuinea as CurrenciesWithGuinea, type types_Currency as Currency, type types_Customer as Customer, type types_CustomerFromSearch as CustomerFromSearch, type types_DeviceType as DeviceType, type types_DraftInvoice as DraftInvoice, type types_EmailWrapper as EmailWrapper, type types_FarmAssurances as FarmAssurances, type types_FieldPositions as FieldPositions, type types_IncrementLadder as IncrementLadder, type types_IncrementLadderItem as IncrementLadderItem, type types_Invoice as Invoice, type types_InvoiceField as InvoiceField, type types_InvoiceLineItem as InvoiceLineItem, type types_InvoiceTotalAdjustmentConfiguration as InvoiceTotalAdjustmentConfiguration, type types_InvoiceTotals as InvoiceTotals, type types_LineItemAdjustmentConfiguration as LineItemAdjustmentConfiguration, types_LivestockSuperTypes as LivestockSuperTypes, type types_Lot as Lot, type types_LotGeneratedValues as LotGeneratedValues, type types_LotIssue as LotIssue, type types_LotItem as LotItem, type types_LotSaleStatus as LotSaleStatus, type types_LotWithItemsAsArray as LotWithItemsAsArray, type types_Market as Market, type types_MarketBankDetails as MarketBankDetails, type types_MarketReportHeaders as MarketReportHeaders, type types_MartEyeLiveSaleSettings as MartEyeLiveSaleSettings, type types_MartEyeTimedSaleSettings as MartEyeTimedSaleSettings, type types_Media as Media, type types_MemberSharingConfiguration as MemberSharingConfiguration, type types_ObjectType as ObjectType, type types_Payment as Payment, type types_PaymentMethod as PaymentMethod, type types_Payout as Payout, type types_PayoutMethod as PayoutMethod, type types_PhoneNumberWrapper as PhoneNumberWrapper, type types_Printer as Printer, type types_Product as Product, type types_ProductCodeConfiguration as ProductCodeConfiguration, type types_ProductConfiguration as ProductConfiguration, type types_Sale as Sale, type types_SaleFromSearch as SaleFromSearch, type types_SettingsAccessories as SettingsAccessories, type types_SettingsAdjustmentsConfiguration as SettingsAdjustmentsConfiguration, type types_SettingsGlobalAttributes as SettingsGlobalAttributes, type types_SettingsMarketDefaults as SettingsMarketDefaults, type types_SettingsPrinters as SettingsPrinters, type types_SettingsProductCodes as SettingsProductCodes, type types_SettingsTaxRates as SettingsTaxRates, type types_ShortCustomerDetails as ShortCustomerDetails, type types_SimplePaymentIn as SimplePaymentIn, type types_SimplePaymentOut as SimplePaymentOut, type types_StudioAppPartial as StudioAppPartial, type types_SubtotalGroups as SubtotalGroups, type types_SuperType as SuperType, type types_SupportedAttributeTypes as SupportedAttributeTypes, type types_SupportedCountryCode as SupportedCountryCode, types_SupportedCurrencyCodes as SupportedCurrencyCodes, types_SupportedPaymentMethods as SupportedPaymentMethods, types_SupportedSuperTypes as SupportedSuperTypes, types_SupportedUnitsOfSale as SupportedUnitsOfSale, type types_TablePosition as TablePosition, type types_TaxRate as TaxRate, type types_UnitOfSale as UnitOfSale, type types_WebhookEvent as WebhookEvent, type types_WebhookEventName as WebhookEventName, types_supportedWebhookEvents as supportedWebhookEvents };
1025
1039
  }
1026
1040
 
1041
+ interface CreateCustomerPayload {
1042
+ firstName?: string;
1043
+ lastName?: string;
1044
+ email?: string;
1045
+ phone?: string;
1046
+ tradingName: string;
1047
+ accountNumberPrefix?: string;
1048
+ accountNumber?: string;
1049
+ cphNumber?: string;
1050
+ farmName?: string;
1051
+ address: {
1052
+ company?: string;
1053
+ firstName?: string;
1054
+ lastName?: string;
1055
+ address1: string;
1056
+ address2?: string;
1057
+ city: string;
1058
+ province?: string;
1059
+ zip: string;
1060
+ country: string;
1061
+ };
1062
+ marteyeUid?: string;
1063
+ }
1064
+
1027
1065
  declare function Studio(info?: {
1028
1066
  apiKey?: string;
1029
1067
  baseUrl?: string;
@@ -1173,6 +1211,16 @@ declare function Studio(info?: {
1173
1211
  list: (marketId: string) => Promise<TaxRate[]>;
1174
1212
  get: (marketId: string, id: string) => Promise<TaxRate>;
1175
1213
  };
1214
+ customers: {
1215
+ list: (marketId: string) => Promise<Customer>;
1216
+ get: (marketId: string, customerId: string) => Promise<Customer>;
1217
+ avatar: (marketId: string, customerId: string) => Promise<Customer>;
1218
+ create: (marketId: string, customerData: CreateCustomerPayload) => Promise<Customer>;
1219
+ getByAccountNumber: (marketId: string, accountNumber: string) => Promise<Customer | null>;
1220
+ };
1221
+ search: {
1222
+ query: (marketId: string, query: string) => Promise<SearchResult>;
1223
+ };
1176
1224
  };
1177
1225
 
1178
1226
  /**
package/dist/index.esm.js CHANGED
@@ -67,7 +67,7 @@ function SimpleHttpClient(baseUrl, apiKey, fetch, defaultTimeout, debug = false)
67
67
  }
68
68
 
69
69
  // Path: studiojs/src/resources/markets.ts
70
- function create$9(_) {
70
+ function create$b(_) {
71
71
  const actions = {
72
72
  /***
73
73
  * This is used to construct the action from the request body
@@ -97,7 +97,7 @@ function create$9(_) {
97
97
  return actions;
98
98
  }
99
99
 
100
- function create$8(httpClient) {
100
+ function create$a(httpClient) {
101
101
  return {
102
102
  list: async (marketId) => {
103
103
  return httpClient.get(`/${marketId}/adjustments`);
@@ -108,7 +108,41 @@ function create$8(httpClient) {
108
108
  };
109
109
  }
110
110
 
111
- function create$7(httpClient) {
111
+ // Path: studiojs/src/resources/markets.ts
112
+ function create$9(httpClient) {
113
+ let customers = {
114
+ list: async (marketId) => {
115
+ return httpClient.get(`/${marketId}/customers`);
116
+ },
117
+ get: async (marketId, customerId) => {
118
+ return httpClient.get(`/${marketId}/customers/${customerId}`);
119
+ },
120
+ avatar: async (marketId, customerId) => {
121
+ return httpClient.get(`/${marketId}/customers/${customerId}/avatar`);
122
+ },
123
+ create: async (marketId, customerData) => {
124
+ return httpClient.post(`/${marketId}/customers`, customerData);
125
+ },
126
+ /**
127
+ * Get a customer by their account number
128
+ * @param marketId - ID of the market the customer belongs to
129
+ * @param accountNumber - The customer's account number to search for
130
+ * @returns The customer with the specified account number or null if not found
131
+ */
132
+ getByAccountNumber: async (marketId, accountNumber) => {
133
+ const response = await httpClient.get(`/${marketId}/customers`, { accountNumber });
134
+ // API returns a list of customers, but when filtering by account number,
135
+ // we should get at most one customer since account numbers are unique
136
+ if (response.customers && response.customers.length > 0) {
137
+ return response.customers[0];
138
+ }
139
+ return null;
140
+ },
141
+ };
142
+ return customers;
143
+ }
144
+
145
+ function create$8(httpClient) {
112
146
  return {
113
147
  create: async (marketId, saleId, lotId, data) => {
114
148
  return httpClient.post(`/${marketId}/sales/${saleId}/lots/${lotId}/items`, data);
@@ -122,7 +156,7 @@ function create$7(httpClient) {
122
156
  };
123
157
  }
124
158
 
125
- function create$6(httpClient) {
159
+ function create$7(httpClient) {
126
160
  return {
127
161
  get: async (marketId, saleId, lotId) => {
128
162
  return httpClient.get(`/${marketId}/sales/${saleId}/lots/${lotId}`);
@@ -142,7 +176,7 @@ function create$6(httpClient) {
142
176
  };
143
177
  }
144
178
 
145
- function create$5(httpClient) {
179
+ function create$6(httpClient) {
146
180
  const markets = {
147
181
  get: async (marketId) => {
148
182
  return httpClient.get(`/${marketId}`);
@@ -164,7 +198,7 @@ function create$5(httpClient) {
164
198
  return markets;
165
199
  }
166
200
 
167
- function create$4(httpClient) {
201
+ function create$5(httpClient) {
168
202
  return {
169
203
  list: async (marketId) => {
170
204
  return httpClient.get(`/${marketId}/product_codes`);
@@ -175,7 +209,7 @@ function create$4(httpClient) {
175
209
  };
176
210
  }
177
211
 
178
- function create$3(httpClient) {
212
+ function create$4(httpClient) {
179
213
  return {
180
214
  get: async (marketId, saleId) => {
181
215
  return httpClient.get(`/${marketId}/sales/${saleId}`);
@@ -192,6 +226,21 @@ function create$3(httpClient) {
192
226
  };
193
227
  }
194
228
 
229
+ function create$3(httpClient) {
230
+ let search = {
231
+ /**
232
+ * Search for documents within a market
233
+ * @param marketId - ID of the market to search in
234
+ * @param query - Search query string
235
+ * @returns Search results containing matching documents
236
+ */
237
+ query: async (marketId, query) => {
238
+ return httpClient.get(`/${marketId}/search`, { q: query });
239
+ },
240
+ };
241
+ return search;
242
+ }
243
+
195
244
  function create$2(httpClient) {
196
245
  return {
197
246
  get: async (marketId) => {
@@ -249,16 +298,18 @@ function create(_) {
249
298
 
250
299
  function resources(httpClient) {
251
300
  return {
252
- markets: create$5(httpClient),
253
- sales: create$3(httpClient),
254
- lots: create$6(httpClient),
255
- lotitems: create$7(httpClient),
301
+ markets: create$6(httpClient),
302
+ sales: create$4(httpClient),
303
+ lots: create$7(httpClient),
304
+ lotitems: create$8(httpClient),
256
305
  webhooks: create(),
257
- actions: create$9(),
306
+ actions: create$b(),
258
307
  settings: create$2(httpClient),
259
- adjustments: create$8(httpClient),
260
- productCodes: create$4(httpClient),
308
+ adjustments: create$a(httpClient),
309
+ productCodes: create$5(httpClient),
261
310
  taxRates: create$1(httpClient),
311
+ customers: create$9(httpClient),
312
+ search: create$3(httpClient),
262
313
  };
263
314
  }
264
315