sizebay-core-sdk 1.6.0 → 1.8.0

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/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  A modular SDK for integrating Sizebay services into your application. Features environment-based endpoint management, async/await support, built-in retry logic, and full TypeScript definitions.
4
4
 
5
- * Event tracking
6
- * AI image recommendations (similar / complementary / sizing)
7
- * Session & profile management
8
- * Environment-aware endpoints (`-dev` / `-prod`)
9
- * Full TypeScript typings
5
+ - Event tracking
6
+ - AI image recommendations (similar / complementary / sizing)
7
+ - Session & profile management
8
+ - Environment-aware endpoints (`-dev` / `-prod`)
9
+ - Full TypeScript typings
10
10
 
11
11
  ---
12
12
 
@@ -55,18 +55,18 @@ Send an event to the API.
55
55
 
56
56
  | Parameter | Type | Required | Description |
57
57
  | ----------- | ----------- | :------: | ------------------------------- |
58
- | `eventName` | string | Yes | e.g. `"ADD_TO_CART"`, `"ORDER"` |
59
- | `payload` | `TrackData` | Yes | See structure below |
58
+ | `eventName` | string | Yes | e.g. `"ADD_TO_CART"`, `"ORDER"` |
59
+ | `payload` | `TrackData` | Yes | See structure below |
60
60
 
61
61
  #### `TrackData`
62
62
 
63
63
  | Field | Type | Required | Description |
64
64
  | ------------ | --------------------------- | :------: | ------------------------------------------------------------------ |
65
- | `sid` | string | Yes | String user ID (`catalogUser.id`) |
66
- | `tenantId` | number | Yes | Tenant (client) ID |
65
+ | `sid` | string | Yes | String user ID (`catalogUser.id`) |
66
+ | `tenantId` | number | Yes | Tenant (client) ID |
67
67
  | `sessionId` | number | No | Numeric session ID |
68
- | `permalink` | string | Cond.\* | Required for product-related events (e.g. `"RECOMMENDATION_DONE"`) |
69
- | `properties` | `Record<string, JSONValue>` | Yes | Additional event data |
68
+ | `permalink` | string | Cond.\* | Required for product-related events (e.g. `"RECOMMENDATION_DONE"`) |
69
+ | `properties` | `Record<string, JSONValue>` | Yes | Additional event data |
70
70
 
71
71
  \*Condition: enforced by SDK when needed.
72
72
 
@@ -74,8 +74,8 @@ Send an event to the API.
74
74
 
75
75
  > **Returns:** `TrackResponse`
76
76
  >
77
- > * `statusCode`: `number`
78
- > * `message`: `string`
77
+ > - `statusCode`: `number`
78
+ > - `message`: `string`
79
79
 
80
80
  #### Example
81
81
 
@@ -102,27 +102,28 @@ Fetch products similar to a reference.
102
102
 
103
103
  #### Parameters
104
104
 
105
- | Field | Type | Required | Description |
106
- | -------------------- | ----------- | :------: | ----------------------------------------------- |
107
- | `tenantId` | number | Yes | Tenant ID |
108
- | `collectionName` | string | Yes | Embeddings collection |
109
- | `sid` | string | Yes | String user ID |
110
- | `permalink` | string | Yes | Reference product URL |
111
- | `sizeSystem` | string | Yes | e.g. `"BR"`, `"EU"` |
112
- | `similarityThreshold`| number | Yes | Threshold for similarity-by-image search |
113
- | `page` | number | No | Page number |
114
- | `perPage` | number | No | Items per page |
115
- | `filterByWhatFitsMe` | boolean | No | Enable “What Fits Me” filter (default: `false`) |
116
- | `personaHash` | string | Cond.\* | Required when `filterByWhatFitsMe` is `true` |
105
+ | Field | Type | Required | Description |
106
+ | --------------------- | ------- | :------: | ----------------------------------------------- |
107
+ | `tenantId` | number | Yes | Tenant ID |
108
+ | `collectionName` | string | Yes | Embeddings collection |
109
+ | `sid` | string | Yes | String user ID |
110
+ | `permalink` | string | Yes | Reference product URL |
111
+ | `sizeSystem` | string | Yes | e.g. `"BR"`, `"EU"` |
112
+ | `similarityThreshold` | number | Yes | Threshold for similarity-by-image search |
113
+ | `page` | number | No | Page number |
114
+ | `perPage` | number | No | Items per page |
115
+ | `filterByWhatFitsMe` | boolean | No | Enable “What Fits Me” filter (default: `false`) |
116
+ | `personaHash` | string | Cond.\* | Required when `filterByWhatFitsMe` is `true` |
117
117
 
118
118
  #### Returns
119
119
 
120
120
  > **Returns:** `GetSimilarProductsResponse`
121
121
  >
122
- > * `data`: `ProductDto[]` — Similar items
123
- > * `page`: `number` — Current page
124
- > * `perPage`: `number` — Items per page
125
- > * `total`: `number` — Total matched items
122
+ > - `data`: `ProductDto[]` — Similar items
123
+ > - `page`: `number` — Current page
124
+ > - `perPage`: `number` — Items per page
125
+ > - `total`: `number` — Total matched items
126
+ > - `invalidPersonaHash: boolean` - If the provided persona hash is invalid
126
127
 
127
128
  #### Example
128
129
 
@@ -135,7 +136,7 @@ const similarResponse = await client.getSimilarProducts({
135
136
  sizeSystem: 'US',
136
137
  similarityThreshold: 0.5,
137
138
  page: 1,
138
- perPage: 10
139
+ perPage: 10,
139
140
  });
140
141
  console.log(similarResponse.data, similarResponse.total);
141
142
  ```
@@ -148,30 +149,32 @@ Retrieve pairs of complementary products.
148
149
 
149
150
  #### Parameters
150
151
 
151
- | Field | Type | Required | Description |
152
- | -------------------- | ----------- | :------: | ------------------------------ |
153
- | `tenantId` | number | Yes | Tenant ID |
154
- | `collectionName` | string | Yes | Embeddings collection |
155
- | `sid` | string | Yes | String user ID |
156
- | `permalink` | string | Yes | Reference product URL |
157
- | `sizeSystem` | string | Yes | e.g. `"BR"`, `"EU"` |
158
- | `similarityThreshold`| number | Yes | Threshold for similarity-by-image search |
159
- | `limit` | number | No | Max number of pairs |
160
- | `filterByWhatFitsMe` | boolean | No | Enable WFM filter |
161
- | `personaHash` | string | Cond.\* | Required when WFM filter is on |
152
+ | Field | Type | Required | Description |
153
+ | --------------------- | ------- | :------: | ---------------------------------------- |
154
+ | `tenantId` | number | Yes | Tenant ID |
155
+ | `collectionName` | string | Yes | Embeddings collection |
156
+ | `sid` | string | Yes | String user ID |
157
+ | `permalink` | string | Yes | Reference product URL |
158
+ | `sizeSystem` | string | Yes | e.g. `"BR"`, `"EU"` |
159
+ | `similarityThreshold` | number | Yes | Threshold for similarity-by-image search |
160
+ | `limit` | number | No | Max number of pairs |
161
+ | `filterByWhatFitsMe` | boolean | No | Enable WFM filter |
162
+ | `personaHash` | string | Cond.\* | Required when WFM filter is on |
162
163
 
163
164
  #### Returns
164
165
 
165
166
  > **Returns:** `GetComplementaryProductsResponse`
166
167
  >
167
- > * `baseProduct`: `ProductDto`
168
- > * `complementary`: `ComplementaryPairDto[]`
168
+ > - `baseProduct`: `ProductDto`
169
+ > - `complementary`: `ComplementaryPairDto[]`
169
170
  >
170
- > * `first`: `ProductDto` (required)
171
- > * `secondary`: `ProductDto` (optional)
172
- > * `page`: `number` — Current page
173
- > * `perPage`: `number` — Items per page
174
- > * `total`: `number` — Total matched items
171
+ > - `first`: `ProductDto` (required)
172
+ > - `secondary`: `ProductDto` (optional)
173
+ >
174
+ > - `page`: `number` — Current page
175
+ > - `perPage`: `number` — Items per page
176
+ > - `total`: `number` — Total matched items
177
+ > - `invalidPersonaHash: boolean` - If the provided persona hash is invalid
175
178
 
176
179
  #### Example
177
180
 
@@ -183,7 +186,7 @@ const compResponse = await client.getComplementaryProducts({
183
186
  permalink: 'https://domain.com/product/xyz',
184
187
  sizeSystem: 'US',
185
188
  similarityThreshold: 0.5,
186
- limit: 5
189
+ limit: 5,
187
190
  });
188
191
  console.log(compResponse.baseProduct, compResponse.complementary);
189
192
  ```
@@ -198,31 +201,34 @@ Find visually similar items from an uploaded image.
198
201
 
199
202
  #### Payload
200
203
 
201
- | Field | Type | Required | Description |
202
- | -------------------- | ----------- | :------: | ----------------------------------- |
203
- | `image` | string | Yes | Base-64 data URL (`data:image/...`) |
204
- | `tenantId` | number | Yes | Tenant ID |
205
- | `collectionName` | string | Yes | Embeddings collection |
206
- | `sid` | string | Yes | String user ID |
207
- | `sizeSystem` | string | Yes | Size system |
208
- | `similarityThreshold`| number | Yes | Threshold for similarity-by-image search |
209
- | `filterByWhatFitsMe` | boolean | No | Apply WFM filter |
210
- | `personaHash` | string | Cond.\* | Required when WFM is on |
211
- | `gender` | string | No | User gender context |
212
- | `style` | string | No | Preferred style |
213
- | `color` | string | No | Main color hint |
214
- | `category` | string | No | High-level category |
215
- | `page` | number | No | Page number |
216
- | `perPage` | number | No | Items per page |
204
+ | Field | Type | Required | Description |
205
+ | --------------------- | ------- | :------: | ---------------------------------------- |
206
+ | `image` | string | Yes | Base-64 data URL (`data:image/...`) |
207
+ | `tenantId` | number | Yes | Tenant ID |
208
+ | `collectionName` | string | Yes | Embeddings collection |
209
+ | `sid` | string | Yes | String user ID |
210
+ | `sizeSystem` | string | Yes | Size system |
211
+ | `similarityThreshold` | number | Yes | Threshold for similarity-by-image search |
212
+ | `filterByWhatFitsMe` | boolean | No | Apply WFM filter |
213
+ | `personaHash` | string | Cond.\* | Required when WFM is on |
214
+ | `ageRange` | string | No | Age range context |
215
+ | `gender` | string | No | User gender context |
216
+ | `style` | string | No | Preferred style |
217
+ | `color` | string | No | Main color hint |
218
+ | `productClass` | string | No | Product class. eg. shirt, jeans, dress |
219
+ | `clothType` | string | No | Cloth type. eg. Top, Bottom |
220
+ | `page` | number | No | Page number |
221
+ | `perPage` | number | No | Items per page |
217
222
 
218
223
  #### Returns
219
224
 
220
225
  > **Returns:** `GetSimilarProductsResponse`
221
226
  >
222
- > * `data`: `ProductDto[]`
223
- > * `page`: `number`
224
- > * `perPage`: `number`
225
- > * `total`: `number`
227
+ > - `data`: `ProductDto[]`
228
+ > - `page`: `number`
229
+ > - `perPage`: `number`
230
+ > - `total`: `number`
231
+ > - `invalidPersonaHash: boolean` - If the provided persona hash is invalid
226
232
 
227
233
  #### Example
228
234
 
@@ -232,7 +238,7 @@ const imgSimilar = await client.searchSimilarByImage({
232
238
  tenantId: 123,
233
239
  collectionName: 'clothing',
234
240
  sid: 'abc123',
235
- sizeSystem: 'US'
241
+ sizeSystem: 'US',
236
242
  });
237
243
  console.log(imgSimilar.data);
238
244
  ```
@@ -245,32 +251,35 @@ Get products that complete a look from an image.
245
251
 
246
252
  #### Payload
247
253
 
248
- | Field | Type | Required | Description |
249
- | -------------------- | ------------------------------------------- | :------: | ----------------------- |
250
- | `image` | string | Yes | Base-64 data URL |
251
- | `tenantId` | number | Yes | Tenant ID |
252
- | `collectionName` | string | Yes | Embeddings collection |
253
- | `sid` | string | Yes | String user ID |
254
- | `sizeSystem` | string | Yes | Size system |
255
- | `similarityThreshold`| number | Yes | Threshold for similarity-by-image search |
256
- | `productClass` | `"top" \| "bottom" \| "shoe" \| "fullbody"` | Yes | Base item class |
257
- | `filterByWhatFitsMe` | boolean | No | Apply WFM filter |
258
- | `personaHash` | string | Cond.\* | Required when WFM is on |
259
- | `gender` | string | No | User gender context |
260
- | `style` | string | No | Preferred style |
261
- | `color` | string | No | Main color hint |
262
- | `page` | number | No | Page number |
263
- | `perPage` | number | No | Items per page |
254
+ | Field | Type | Required | Description |
255
+ | --------------------- | ------- | :------: | ---------------------------------------- |
256
+ | `image` | string | Yes | Base-64 data URL |
257
+ | `tenantId` | number | Yes | Tenant ID |
258
+ | `collectionName` | string | Yes | Embeddings collection |
259
+ | `sid` | string | Yes | String user ID |
260
+ | `sizeSystem` | string | Yes | Size system |
261
+ | `similarityThreshold` | number | Yes | Threshold for similarity-by-image search |
262
+ | `clothType` | string | Yes | Cloth type. eg. Top, Bottom |
263
+ | `filterByWhatFitsMe` | boolean | No | Apply WFM filter |
264
+ | `personaHash` | string | Cond.\* | Required when WFM is on |
265
+ | `ageRange` | string | No | Age range context |
266
+ | `gender` | string | No | User gender context |
267
+ | `style` | string | No | Preferred style |
268
+ | `color` | string | No | Main color hint |
269
+ | `productClass` | string | No | Product class. eg. shirt, jeans, dress |
270
+ | `page` | number | No | Page number |
271
+ | `perPage` | number | No | Items per page |
264
272
 
265
273
  #### Returns
266
274
 
267
275
  > **Returns:** `GetComplementaryProductsByImageResponse`
268
276
  >
269
- > * `baseProduct`: `ProductDto`
270
- > * `complementary`: `ProductDto[]`
271
- > * `page`: `number`
272
- > * `perPage`: `number`
273
- > * `total`: `number`
277
+ > - `baseProduct`: `ProductDto`
278
+ > - `complementary`: `ProductDto[]`
279
+ > - `page`: `number`
280
+ > - `perPage`: `number`
281
+ > - `total`: `number`
282
+ > - `invalidPersonaHash: boolean` - If the provided persona hash is invalid
274
283
 
275
284
  #### Example
276
285
 
@@ -282,7 +291,7 @@ const imgComp = await client.searchComplementaryByImage({
282
291
  sid: 'abc123',
283
292
  sizeSystem: 'US',
284
293
  similarityThreshold: 0.5,
285
- productClass: 'top'
294
+ clothType: 'TOP',
286
295
  });
287
296
  console.log(imgComp.complementary);
288
297
  ```
@@ -293,8 +302,8 @@ console.log(imgComp.complementary);
293
302
 
294
303
  Retrieves and caches session context:
295
304
 
296
- * **sid** (`string`): Catalog user ID returned by session endpoint
297
- * **sessionId** (`number`): Numeric session identifier
305
+ - **sid** (`string`): Catalog user ID returned by session endpoint
306
+ - **sessionId** (`number`): Numeric session identifier
298
307
 
299
308
  ### `getSessionInfo(): Promise<SessionContext>`
300
309
 
@@ -324,7 +333,7 @@ Sends user profile data. Uses cached `sid` if not provided.
324
333
 
325
334
  | Field | Type | Required | Description |
326
335
  | --------- | --------------------- | :------: | ------------------------------------ |
327
- | `payload` | SessionProfilePayload | Yes | Profile details |
336
+ | `payload` | SessionProfilePayload | Yes | Profile details |
328
337
  | `sid` | string | No | Catalog user ID (defaults to cached) |
329
338
 
330
339
  #### Example
@@ -383,11 +392,11 @@ await client.sendProfile(profilePayload);
383
392
 
384
393
  ### `SuitableSizeDto`
385
394
 
386
- | Field | Type | Description |
387
- | ------------- | ------ | ------------------------- |
388
- | `size` | string | Recommended size label |
389
- | `comfortable` | number | Comfort score (0–1) |
390
- | `value?` | boolean| if is suitable |
395
+ | Field | Type | Description |
396
+ | ------------- | ------- | ---------------------- |
397
+ | `size` | string | Recommended size label |
398
+ | `comfortable` | number | Comfort score (0–1) |
399
+ | `value?` | boolean | if is suitable |
391
400
 
392
401
  ### `ComplementaryPairDto`
393
402
 
@@ -402,20 +411,20 @@ interface ComplementaryPairDto {
402
411
 
403
412
  | Field | Type | Required | Description |
404
413
  | ---------------- | ----------------------------------------------------- | :------: | ------------------------ |
405
- | `userId` | string | Yes | User’s unique ID |
406
- | `name` | string | Yes | Profile name |
407
- | `skinType` | number | Yes | Skin type category |
414
+ | `userId` | string | Yes | User’s unique ID |
415
+ | `name` | string | Yes | Profile name |
416
+ | `skinType` | number | Yes | Skin type category |
408
417
  | `footShape` | string \| null | No | Optional foot shape |
409
- | `gender` | string | Yes | `'M'` or `'F'` |
410
- | `age` | string | Yes | Age as string |
411
- | `is3dFeel` | boolean | Yes | 3D feel enabled |
412
- | `weight` | string | Yes | Weight as string |
413
- | `height` | string | Yes | Height as string |
414
- | `measures` | `{ insoleLength: number; poundWeight: number\|null }` | Yes | Additional measurements |
418
+ | `gender` | string | Yes | `'M'` or `'F'` |
419
+ | `age` | string | Yes | Age as string |
420
+ | `is3dFeel` | boolean | Yes | 3D feel enabled |
421
+ | `weight` | string | Yes | Weight as string |
422
+ | `height` | string | Yes | Height as string |
423
+ | `measures` | `{ insoleLength: number; poundWeight: number\|null }` | Yes | Additional measurements |
415
424
  | `product` | string \| null | No | Optional product context |
416
- | `isMetric` | boolean | Yes | Metric system enabled |
417
- | `bodyShapeChest` | number | Yes | Chest shape index |
418
- | `bodyShapeWaist` | number | Yes | Waist shape index |
419
- | `bodyShapeHip` | number | Yes | Hip shape index |
425
+ | `isMetric` | boolean | Yes | Metric system enabled |
426
+ | `bodyShapeChest` | number | Yes | Chest shape index |
427
+ | `bodyShapeWaist` | number | Yes | Waist shape index |
428
+ | `bodyShapeHip` | number | Yes | Hip shape index |
420
429
 
421
430
  ---
@@ -13,7 +13,7 @@ const d = {
13
13
  }
14
14
  // Adicione outros serviços conforme necessário
15
15
  };
16
- class l {
16
+ class S {
17
17
  constructor(t) {
18
18
  const e = t.env || "development";
19
19
  this.serviceOverrides = t.services || {}, this.endpoints = {};
@@ -37,7 +37,7 @@ class l {
37
37
  return this.serviceOverrides[t] || {};
38
38
  }
39
39
  }
40
- class u {
40
+ class l {
41
41
  constructor(t) {
42
42
  this.endpoint = t.getEndpoint("tracker");
43
43
  }
@@ -86,7 +86,7 @@ async function a(r, t) {
86
86
  throw new c(e.status, s);
87
87
  return JSON.parse(s);
88
88
  }
89
- class m {
89
+ class T {
90
90
  constructor(t) {
91
91
  this.endpoint = t.getEndpoint("aiImageService");
92
92
  }
@@ -184,7 +184,7 @@ class m {
184
184
  });
185
185
  }
186
186
  }
187
- class f {
187
+ class O {
188
188
  constructor(t) {
189
189
  this.sid = null, this.sessionId = null;
190
190
  const e = t.getEndpoint("session");
@@ -240,13 +240,13 @@ class f {
240
240
  }
241
241
  }
242
242
  }
243
- const y = [
244
- u,
245
- m,
246
- f
243
+ const u = [
244
+ l,
245
+ T,
246
+ O
247
247
  ];
248
- function g(r = {}) {
249
- const t = new l(r), e = y.map((n) => new n(t)), s = {};
248
+ function E(r = {}) {
249
+ const t = new S(r), e = u.map((n) => new n(t)), s = {};
250
250
  return e.forEach((n) => {
251
251
  [
252
252
  ...Object.getOwnPropertyNames(n),
@@ -258,13 +258,60 @@ function g(r = {}) {
258
258
  });
259
259
  }), s;
260
260
  }
261
- const w = {
262
- FULL_BODY: "fullbody",
263
- BOTTOM: "bottom",
264
- TOP: "top",
265
- SHOE: "shoe"
261
+ const m = {
262
+ TOP: "TOP",
263
+ BOTTOM: "BOTTOM",
264
+ SHOE_ACCESSORY: "SHOE_ACCESSORY",
265
+ FULL_BODY: "FULL_BODY",
266
+ UNDERWEAR_FULL_BODY: "UNDERWEAR_FULL_BODY",
267
+ UNDERWEAR_BOTTOM: "UNDERWEAR_BOTTOM",
268
+ UNDERWEAR_TOP: "UNDERWEAR_TOP",
269
+ WETSUIT_FULL_BODY: "WETSUIT_FULL_BODY",
270
+ WETSUIT_BOTTOM: "WETSUIT_BOTTOM",
271
+ WETSUIT_TOP: "WETSUIT_TOP"
272
+ }, f = {
273
+ T_SHIRT: "t-shirt",
274
+ SHIRT: "shirt",
275
+ BLOUSE: "blouse",
276
+ SWEATER: "sweater",
277
+ HOODIE: "hoodie",
278
+ JACKET: "jacket",
279
+ COAT: "coat",
280
+ CARDIGAN: "cardigan",
281
+ BLAZER: "blazer",
282
+ VEST: "vest",
283
+ SWEATSHIRT: "sweatshirt",
284
+ POLO_SHIRT: "polo shirt",
285
+ TANK_TOP: "tank top",
286
+ SKIRT: "skirt",
287
+ TROUSERS: "trousers",
288
+ JEANS: "jeans",
289
+ SHORTS: "shorts",
290
+ SNEAKERS: "sneakers",
291
+ RUNNING_SHOES: "running shoes",
292
+ BOOTS: "boots",
293
+ ANKLE_BOOTS: "ankle boots",
294
+ HIGH_HEELS: "high heels",
295
+ FLATS: "flats",
296
+ LOAFERS: "loafers",
297
+ OXFORDS: "oxfords",
298
+ SLIPPERS: "slippers",
299
+ SANDALS: "sandals",
300
+ DRESS: "dress",
301
+ JUMPSUIT: "jumpsuit",
302
+ SUIT: "suit",
303
+ PANTIES: "panties",
304
+ BRA: "bra",
305
+ BIKINI: "bikini",
306
+ BRIEFS: "briefs",
307
+ BOXERS: "boxers",
308
+ THONG: "thong",
309
+ SWIMSUIT: "swimsuit",
310
+ ONE_PIECE_SWIMSUIT: "one-piece swimsuit",
311
+ WETSUIT: "wetsuit"
266
312
  };
267
313
  export {
268
- w as ClothType,
269
- g as createClient
314
+ m as ClothType,
315
+ f as ProductClass,
316
+ E as createClient
270
317
  };
@@ -1 +1 @@
1
- (function(r,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(r=typeof globalThis<"u"?globalThis:r||self,a(r["sizebay-core-sdk"]={}))})(this,function(r){"use strict";const a={tracker:{production:"https://data-event-service.internalsizebay.com",development:"https://data-event-service-dev.internalsizebay.com"},aiImageService:{production:"https://ai-image-service.internalsizebay.com",development:"https://ai-image-service-dev.internalsizebay.com"},session:{production:"https://vfr-v3-production.sizebay.technology/api/me",development:"https://vfr-v3-staging.sizebay.eu/api/me"}};class l{constructor(e){const t=e.env||"development";this.serviceOverrides=e.services||{},this.endpoints={};for(const n in a)if(Object.prototype.hasOwnProperty.call(a,n)){const o=a[n][t];if(!o)continue;this.endpoints[n]=o}}getEndpoint(e){const t=this.endpoints[e];if(!t)throw new Error(`Endpoint for service '${e}' is not configured.`);return t}getServiceConfig(e){return this.serviceOverrides[e]||{}}}class u{constructor(e){this.endpoint=e.getEndpoint("tracker")}async track(e,t){const n={eventName:e,...t},s=new URL(`${this.endpoint}/events`);try{const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!o.ok){const i=await o.text();throw new Error(`Request error: ${o.status} - ${i}`)}return await o.json()}catch(o){throw o}}}class p extends Error{constructor(e,t){let n;try{const s=JSON.parse(t);n=(s==null?void 0:s.message)||t}catch{n=t}super(n),this.statusCode=e,this.details=t,Object.setPrototypeOf(this,p.prototype)}}async function d(c,e){let t;try{t=await fetch(c,e)}catch(s){throw new p(0,s.message)}const n=await t.text();if(!t.ok)throw new p(t.status,n);return JSON.parse(n)}class f{constructor(e){this.endpoint=e.getEndpoint("aiImageService")}appendQueryParams(e,t){Object.entries(t).forEach(([n,s])=>{s!=null&&e.searchParams.append(n,String(s))})}getSimilarProducts(e){const t=new URL(`${this.endpoint}/recommendations/similar`);return this.appendQueryParams(t,e),d(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getRecommendedSizeByProducts(e){const t=`${this.endpoint}/recommendations/size-by-products`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}getComplementaryProducts(e){const t=new URL(`${this.endpoint}/recommendations/complementary`);return this.appendQueryParams(t,e),d(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(e){const t=`${this.endpoint}/image-search/similar`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByImage(e){const t=`${this.endpoint}/image-search/complementary`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}class m{constructor(e){this.sid=null,this.sessionId=null;const t=e.getEndpoint("session");this.sessionEndpoint=`${t}/`,this.profileEndpoint=`${t}/user/profile`}async getSessionInfo(){if(this.sid&&this.sessionId!==null)return{sid:this.sid,sessionId:this.sessionId};const e=await fetch(this.sessionEndpoint,{credentials:"include"});if(!e.ok){const n=await e.text();throw new Error(`Failed to fetch session info: ${e.status} – ${n}`)}const t=await e.json();return this.sid=t.catalogUser.id,this.sessionId=t.sessionId,{sid:this.sid,sessionId:this.sessionId}}async sendProfile(e,t){const n=t??(await this.getSessionInfo()).sid,s=new URL(this.profileEndpoint);s.searchParams.set("sid",n);const o=await fetch(s.toString(),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:n,id:null,...e})});if(!o.ok){const i=await o.text();throw new Error(`Failed to send profile: ${o.status} – ${i}`)}}}const y=[u,f,m];function g(c={}){const e=new l(c),t=y.map(s=>new s(e)),n={};return t.forEach(s=>{[...Object.getOwnPropertyNames(s),...Object.getOwnPropertyNames(Object.getPrototypeOf(s))].forEach(i=>{if(i==="constructor")return;const h=s[i];typeof h=="function"&&(n[i]||(n[i]=(...O)=>h.apply(s,O)))})}),n}const w={FULL_BODY:"fullbody",BOTTOM:"bottom",TOP:"top",SHOE:"shoe"};r.ClothType=w,r.createClient=g,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i["sizebay-core-sdk"]={}))})(this,function(i){"use strict";const a={tracker:{production:"https://data-event-service.internalsizebay.com",development:"https://data-event-service-dev.internalsizebay.com"},aiImageService:{production:"https://ai-image-service.internalsizebay.com",development:"https://ai-image-service-dev.internalsizebay.com"},session:{production:"https://vfr-v3-production.sizebay.technology/api/me",development:"https://vfr-v3-staging.sizebay.eu/api/me"}};class l{constructor(e){const t=e.env||"development";this.serviceOverrides=e.services||{},this.endpoints={};for(const s in a)if(Object.prototype.hasOwnProperty.call(a,s)){const o=a[s][t];if(!o)continue;this.endpoints[s]=o}}getEndpoint(e){const t=this.endpoints[e];if(!t)throw new Error(`Endpoint for service '${e}' is not configured.`);return t}getServiceConfig(e){return this.serviceOverrides[e]||{}}}class u{constructor(e){this.endpoint=e.getEndpoint("tracker")}async track(e,t){const s={eventName:e,...t},n=new URL(`${this.endpoint}/events`);try{const o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const r=await o.text();throw new Error(`Request error: ${o.status} - ${r}`)}return await o.json()}catch(o){throw o}}}class p extends Error{constructor(e,t){let s;try{const n=JSON.parse(t);s=(n==null?void 0:n.message)||t}catch{s=t}super(s),this.statusCode=e,this.details=t,Object.setPrototypeOf(this,p.prototype)}}async function d(c,e){let t;try{t=await fetch(c,e)}catch(n){throw new p(0,n.message)}const s=await t.text();if(!t.ok)throw new p(t.status,s);return JSON.parse(s)}class S{constructor(e){this.endpoint=e.getEndpoint("aiImageService")}appendQueryParams(e,t){Object.entries(t).forEach(([s,n])=>{n!=null&&e.searchParams.append(s,String(n))})}getSimilarProducts(e){const t=new URL(`${this.endpoint}/recommendations/similar`);return this.appendQueryParams(t,e),d(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getRecommendedSizeByProducts(e){const t=`${this.endpoint}/recommendations/size-by-products`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}getComplementaryProducts(e){const t=new URL(`${this.endpoint}/recommendations/complementary`);return this.appendQueryParams(t,e),d(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(e){const t=`${this.endpoint}/image-search/similar`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByImage(e){const t=`${this.endpoint}/image-search/complementary`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}class T{constructor(e){this.sid=null,this.sessionId=null;const t=e.getEndpoint("session");this.sessionEndpoint=`${t}/`,this.profileEndpoint=`${t}/user/profile`}async getSessionInfo(){if(this.sid&&this.sessionId!==null)return{sid:this.sid,sessionId:this.sessionId};const e=await fetch(this.sessionEndpoint,{credentials:"include"});if(!e.ok){const s=await e.text();throw new Error(`Failed to fetch session info: ${e.status} – ${s}`)}const t=await e.json();return this.sid=t.catalogUser.id,this.sessionId=t.sessionId,{sid:this.sid,sessionId:this.sessionId}}async sendProfile(e,t){const s=t??(await this.getSessionInfo()).sid,n=new URL(this.profileEndpoint);n.searchParams.set("sid",s);const o=await fetch(n.toString(),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:s,id:null,...e})});if(!o.ok){const r=await o.text();throw new Error(`Failed to send profile: ${o.status} – ${r}`)}}}const O=[u,S,T];function f(c={}){const e=new l(c),t=O.map(n=>new n(e)),s={};return t.forEach(n=>{[...Object.getOwnPropertyNames(n),...Object.getOwnPropertyNames(Object.getPrototypeOf(n))].forEach(r=>{if(r==="constructor")return;const h=n[r];typeof h=="function"&&(s[r]||(s[r]=(...y)=>h.apply(n,y)))})}),s}const E={TOP:"TOP",BOTTOM:"BOTTOM",SHOE_ACCESSORY:"SHOE_ACCESSORY",FULL_BODY:"FULL_BODY",UNDERWEAR_FULL_BODY:"UNDERWEAR_FULL_BODY",UNDERWEAR_BOTTOM:"UNDERWEAR_BOTTOM",UNDERWEAR_TOP:"UNDERWEAR_TOP",WETSUIT_FULL_BODY:"WETSUIT_FULL_BODY",WETSUIT_BOTTOM:"WETSUIT_BOTTOM",WETSUIT_TOP:"WETSUIT_TOP"},m={T_SHIRT:"t-shirt",SHIRT:"shirt",BLOUSE:"blouse",SWEATER:"sweater",HOODIE:"hoodie",JACKET:"jacket",COAT:"coat",CARDIGAN:"cardigan",BLAZER:"blazer",VEST:"vest",SWEATSHIRT:"sweatshirt",POLO_SHIRT:"polo shirt",TANK_TOP:"tank top",SKIRT:"skirt",TROUSERS:"trousers",JEANS:"jeans",SHORTS:"shorts",SNEAKERS:"sneakers",RUNNING_SHOES:"running shoes",BOOTS:"boots",ANKLE_BOOTS:"ankle boots",HIGH_HEELS:"high heels",FLATS:"flats",LOAFERS:"loafers",OXFORDS:"oxfords",SLIPPERS:"slippers",SANDALS:"sandals",DRESS:"dress",JUMPSUIT:"jumpsuit",SUIT:"suit",PANTIES:"panties",BRA:"bra",BIKINI:"bikini",BRIEFS:"briefs",BOXERS:"boxers",THONG:"thong",SWIMSUIT:"swimsuit",ONE_PIECE_SWIMSUIT:"one-piece swimsuit",WETSUIT:"wetsuit"};i.ClothType=E,i.ProductClass=m,i.createClient=f,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,5 @@
1
- import { ClothType } from './clothType.type';
1
+ import { ClothType } from './cloth-type.type';
2
+ import { ProductClass } from './product-class.type';
2
3
  export interface GetSimilarProductsParams {
3
4
  tenantId: number;
4
5
  collectionName: string;
@@ -57,6 +58,7 @@ export interface GetSimilarProductsResponse {
57
58
  page: number;
58
59
  perPage: number;
59
60
  total: number;
61
+ invalidPersonaHash: boolean;
60
62
  }
61
63
  export interface GetRecommendedSizeByProductsResponse {
62
64
  id: string;
@@ -70,6 +72,7 @@ export interface ComplementaryPairDto {
70
72
  export interface GetComplementaryProductsResponse {
71
73
  baseProduct: ProductDto;
72
74
  complementary: ComplementaryPairDto[];
75
+ invalidPersonaHash: boolean;
73
76
  }
74
77
  export interface GetSimilarByImageBodyDto {
75
78
  image: string;
@@ -79,10 +82,12 @@ export interface GetSimilarByImageBodyDto {
79
82
  sizeSystem: string;
80
83
  filterByWhatFitsMe?: boolean;
81
84
  personaHash?: string;
85
+ ageRange?: string;
82
86
  gender?: string;
83
87
  style?: string;
84
88
  color?: string;
85
- category?: string;
89
+ productClass?: ProductClass;
90
+ clothType?: ClothType;
86
91
  page?: number;
87
92
  perPage?: number;
88
93
  similarityThreshold?: number;
@@ -93,15 +98,17 @@ export interface GetComplementaryByImageBodyDto {
93
98
  collectionName: string;
94
99
  sid: string;
95
100
  sizeSystem: string;
101
+ similarityThreshold: number;
96
102
  clothType: ClothType;
97
103
  filterByWhatFitsMe?: boolean;
98
104
  personaHash?: string;
105
+ ageRange?: string;
99
106
  gender?: string;
100
107
  style?: string;
101
108
  color?: string;
109
+ productClass?: ProductClass;
102
110
  page?: number;
103
111
  perPage?: number;
104
- similarityThreshold: number;
105
112
  }
106
113
  export interface GetComplementaryProductsByImageResponse {
107
114
  baseProduct: ProductDto;
@@ -109,4 +116,5 @@ export interface GetComplementaryProductsByImageResponse {
109
116
  page: number;
110
117
  perPage: number;
111
118
  total: number;
119
+ invalidPersonaHash: boolean;
112
120
  }
@@ -0,0 +1,13 @@
1
+ export declare const ClothType: {
2
+ TOP: string;
3
+ BOTTOM: string;
4
+ SHOE_ACCESSORY: string;
5
+ FULL_BODY: string;
6
+ UNDERWEAR_FULL_BODY: string;
7
+ UNDERWEAR_BOTTOM: string;
8
+ UNDERWEAR_TOP: string;
9
+ WETSUIT_FULL_BODY: string;
10
+ WETSUIT_BOTTOM: string;
11
+ WETSUIT_TOP: string;
12
+ };
13
+ export type ClothType = (typeof ClothType)[keyof typeof ClothType];
@@ -1,5 +1,6 @@
1
- export * from './sdk.types';
2
- export * from './event.types';
3
- export * from './client.types';
4
- export * from './clothType.type';
5
1
  export * from './ai-image-service.types';
2
+ export * from './client.types';
3
+ export * from './cloth-type.type';
4
+ export * from './event.types';
5
+ export * from './product-class.type';
6
+ export * from './sdk.types';
@@ -0,0 +1,42 @@
1
+ export declare const ProductClass: {
2
+ readonly T_SHIRT: "t-shirt";
3
+ readonly SHIRT: "shirt";
4
+ readonly BLOUSE: "blouse";
5
+ readonly SWEATER: "sweater";
6
+ readonly HOODIE: "hoodie";
7
+ readonly JACKET: "jacket";
8
+ readonly COAT: "coat";
9
+ readonly CARDIGAN: "cardigan";
10
+ readonly BLAZER: "blazer";
11
+ readonly VEST: "vest";
12
+ readonly SWEATSHIRT: "sweatshirt";
13
+ readonly POLO_SHIRT: "polo shirt";
14
+ readonly TANK_TOP: "tank top";
15
+ readonly SKIRT: "skirt";
16
+ readonly TROUSERS: "trousers";
17
+ readonly JEANS: "jeans";
18
+ readonly SHORTS: "shorts";
19
+ readonly SNEAKERS: "sneakers";
20
+ readonly RUNNING_SHOES: "running shoes";
21
+ readonly BOOTS: "boots";
22
+ readonly ANKLE_BOOTS: "ankle boots";
23
+ readonly HIGH_HEELS: "high heels";
24
+ readonly FLATS: "flats";
25
+ readonly LOAFERS: "loafers";
26
+ readonly OXFORDS: "oxfords";
27
+ readonly SLIPPERS: "slippers";
28
+ readonly SANDALS: "sandals";
29
+ readonly DRESS: "dress";
30
+ readonly JUMPSUIT: "jumpsuit";
31
+ readonly SUIT: "suit";
32
+ readonly PANTIES: "panties";
33
+ readonly BRA: "bra";
34
+ readonly BIKINI: "bikini";
35
+ readonly BRIEFS: "briefs";
36
+ readonly BOXERS: "boxers";
37
+ readonly THONG: "thong";
38
+ readonly SWIMSUIT: "swimsuit";
39
+ readonly ONE_PIECE_SWIMSUIT: "one-piece swimsuit";
40
+ readonly WETSUIT: "wetsuit";
41
+ };
42
+ export type ProductClass = (typeof ProductClass)[keyof typeof ProductClass];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "A SDK designed for integrating multiple services (such as event tracking, AI services, etc.) into your application.",
5
5
  "main": "dist/sizebay-core-sdk.umd.js",
6
6
  "module": "dist/sizebay-core-sdk.es.js",
@@ -1,7 +0,0 @@
1
- export declare const ClothType: {
2
- FULL_BODY: string;
3
- BOTTOM: string;
4
- TOP: string;
5
- SHOE: string;
6
- };
7
- export type ClothType = (typeof ClothType)[keyof typeof ClothType];