sizebay-core-sdk 1.11.0-dev.3 → 1.11.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 +2 -128
- package/dist/modules/ai-image-service.d.ts +1 -3
- package/dist/sizebay-core-sdk.es.js +24 -165
- package/dist/sizebay-core-sdk.umd.js +1 -1
- package/dist/types/ai-image/index.d.ts +0 -2
- package/dist/types/product/product.dto.d.ts +1 -0
- package/package.json +1 -1
- package/dist/types/ai-image/params/get-complementary-by-permalink.dto.d.ts +0 -17
- package/dist/types/ai-image/params/get-similar-by-permalink.dto.d.ts +0 -16
package/README.md
CHANGED
|
@@ -296,133 +296,6 @@ console.log(imgComp.baseProduct, imgComp.complementary);
|
|
|
296
296
|
|
|
297
297
|
---
|
|
298
298
|
|
|
299
|
-
## Permalink Search Services
|
|
300
|
-
|
|
301
|
-
### `searchSimilarByPermalink(payload: GetSimilarByPermalinkBodyDto): Promise<GetSimilarProductsResponse>`
|
|
302
|
-
|
|
303
|
-
Find visually similar items from a product permalink or productId using AI-powered image analysis.
|
|
304
|
-
|
|
305
|
-
#### Payload
|
|
306
|
-
|
|
307
|
-
<!-- DOCGEN:params GetSimilarByPermalinkBodyDto -->
|
|
308
|
-
| Field | Type | Required | Description |
|
|
309
|
-
| ----- | ---- | :------: | ----------- |
|
|
310
|
-
| `permalink` | string | No | The URL permalink of the reference product for the similarity search. |
|
|
311
|
-
| `productId` | string | No | Product ID (either permalink or productId must be provided). |
|
|
312
|
-
| `ageRange` | string | No | Target age range. |
|
|
313
|
-
| `gender` | string | No | User gender (optional). |
|
|
314
|
-
| `style` | string | No | Preferred style hint. |
|
|
315
|
-
| `color` | string | No | Main color of interest. |
|
|
316
|
-
| `productClass` | ProductClass | No | Target product class. |
|
|
317
|
-
| `clothType` | ClothType | No | Target cloth type for filtering results. |
|
|
318
|
-
| `page` | number | No | Current page number. |
|
|
319
|
-
| `perPage` | number | No | Number of results per page. |
|
|
320
|
-
| `similarityThreshold` | number | No | Similarity threshold for matching (0-1). |
|
|
321
|
-
| `tenantId` | number | Yes | Tenant (client) ID. |
|
|
322
|
-
| `collectionName` | string | Yes | Embeddings collection name (namespace). |
|
|
323
|
-
| `sid` | string | Yes | Session identifier (`sid`) for the user. |
|
|
324
|
-
| `sizeSystem` | string | Yes | Size system code (e.g., 'BR', 'EU', 'US'). |
|
|
325
|
-
| `locale` | string | Yes | Locale for internationalized responses (language and region). |
|
|
326
|
-
| `currency` | string | Yes | Currency code for pricing information in responses. |
|
|
327
|
-
| `filterByWhatFitsMe` | boolean | No | Whether to apply What Fits Me logic. |
|
|
328
|
-
| `personaHash` | string | No | Hash representing the user persona (required if WFM is enabled). |
|
|
329
|
-
<!-- /DOCGEN -->
|
|
330
|
-
|
|
331
|
-
#### Returns
|
|
332
|
-
|
|
333
|
-
<!-- DOCGEN:returns GetSimilarProductsResponse -->
|
|
334
|
-
> **`GetSimilarProductsResponse`**
|
|
335
|
-
> * `data`: `ProductDto[]` — An array of products that are visually similar to the reference item.<br>The results are ordered by their similarity score.
|
|
336
|
-
> * `page`: `number` — The current page number of the results.
|
|
337
|
-
> * `perPage`: `number` — The number of items per page.
|
|
338
|
-
> * `total`: `number` — The total number of similar products found.
|
|
339
|
-
> * `invalidPersonaHash`: `boolean` — Indicates if the provided persona hash is invalid or expired,<br>which may affect personalized results.
|
|
340
|
-
<!-- /DOCGEN -->
|
|
341
|
-
|
|
342
|
-
#### Example
|
|
343
|
-
|
|
344
|
-
```typescript
|
|
345
|
-
const similarProducts = await client.searchSimilarByPermalink({
|
|
346
|
-
tenantId: 123,
|
|
347
|
-
collectionName: "products",
|
|
348
|
-
sid: "session123",
|
|
349
|
-
sizeSystem: "BR",
|
|
350
|
-
locale: "pt-BR",
|
|
351
|
-
currency: "BRL",
|
|
352
|
-
permalink: "https://example.com/products/red-dress-456",
|
|
353
|
-
similarityThreshold: 0.7,
|
|
354
|
-
page: 1,
|
|
355
|
-
perPage: 10,
|
|
356
|
-
style: "Casual",
|
|
357
|
-
color: "red"
|
|
358
|
-
});
|
|
359
|
-
console.log(similarProducts.data);
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### `searchComplementaryByPermalink(payload: GetComplementaryByPermalinkBodyDto): Promise<GetComplementaryProductsResponse>`
|
|
363
|
-
|
|
364
|
-
Find complementary products from a product permalink or productId using AI-powered analysis.
|
|
365
|
-
|
|
366
|
-
#### Payload
|
|
367
|
-
|
|
368
|
-
<!-- DOCGEN:params GetComplementaryByPermalinkBodyDto -->
|
|
369
|
-
| Field | Type | Required | Description |
|
|
370
|
-
| ----- | ---- | :------: | ----------- |
|
|
371
|
-
| `permalink` | string | No | The URL permalink of the reference product. |
|
|
372
|
-
| `productId` | string | No | Product ID (either permalink or productId must be provided). |
|
|
373
|
-
| `similarityThreshold` | number | Yes | The minimum similarity score (0-1) for recommended products.<br>A higher value yields more similar items, while a lower value provides more variety. |
|
|
374
|
-
| `baseClothType` | ClothType | No | Base cloth type for the reference product. |
|
|
375
|
-
| `targetClothType` | ClothType | No | Target cloth type for complementary products. |
|
|
376
|
-
| `ageRange` | string | No | Target age range. |
|
|
377
|
-
| `gender` | string | No | User gender (optional). |
|
|
378
|
-
| `style` | string | No | Preferred style hint. |
|
|
379
|
-
| `color` | string | No | Main color of interest. |
|
|
380
|
-
| `productClass` | ProductClass | No | Target product class. |
|
|
381
|
-
| `page` | number | No | Current page number. |
|
|
382
|
-
| `perPage` | number | No | Number of results per page. |
|
|
383
|
-
| `tenantId` | number | Yes | Tenant (client) ID. |
|
|
384
|
-
| `collectionName` | string | Yes | Embeddings collection name (namespace). |
|
|
385
|
-
| `sid` | string | Yes | Session identifier (`sid`) for the user. |
|
|
386
|
-
| `sizeSystem` | string | Yes | Size system code (e.g., 'BR', 'EU', 'US'). |
|
|
387
|
-
| `locale` | string | Yes | Locale for internationalized responses (language and region). |
|
|
388
|
-
| `currency` | string | Yes | Currency code for pricing information in responses. |
|
|
389
|
-
| `filterByWhatFitsMe` | boolean | No | Whether to apply What Fits Me logic. |
|
|
390
|
-
| `personaHash` | string | No | Hash representing the user persona (required if WFM is enabled). |
|
|
391
|
-
<!-- /DOCGEN -->
|
|
392
|
-
|
|
393
|
-
#### Returns
|
|
394
|
-
|
|
395
|
-
<!-- DOCGEN:returns GetComplementaryProductsResponse -->
|
|
396
|
-
> **`GetComplementaryProductsResponse`**
|
|
397
|
-
> * `baseProduct`: `ProductDto` — The reference product used to generate recommendations.<br>This is the item that corresponds to the permalink from the request.
|
|
398
|
-
> * `complementary`: `ComplementaryPairDto[]` — A list of recommended pairs of products that are complementary to the base product.
|
|
399
|
-
> * `invalidPersonaHash`: `boolean` — Indicates if the provided persona hash is invalid or has expired.<br>If true, personalization may be affected.
|
|
400
|
-
<!-- /DOCGEN -->
|
|
401
|
-
|
|
402
|
-
#### Example
|
|
403
|
-
|
|
404
|
-
```typescript
|
|
405
|
-
const complementaryProducts = await client.searchComplementaryByPermalink({
|
|
406
|
-
tenantId: 123,
|
|
407
|
-
collectionName: "products",
|
|
408
|
-
sid: "session123",
|
|
409
|
-
sizeSystem: "BR",
|
|
410
|
-
locale: "pt-BR",
|
|
411
|
-
currency: "BRL",
|
|
412
|
-
productId: "12345",
|
|
413
|
-
similarityThreshold: 0.3,
|
|
414
|
-
baseClothType: ClothType.BOTTOM,
|
|
415
|
-
targetClothType: ClothType.TOP,
|
|
416
|
-
page: 1,
|
|
417
|
-
perPage: 10,
|
|
418
|
-
style: "Casual",
|
|
419
|
-
color: "blue"
|
|
420
|
-
});
|
|
421
|
-
console.log(complementaryProducts.baseProduct, complementaryProducts.complementary);
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
299
|
## Session Module
|
|
427
300
|
|
|
428
301
|
Retrieves and caches session context:
|
|
@@ -532,6 +405,7 @@ await client.sendProfile(profilePayload);
|
|
|
532
405
|
| `additionalImageLinks` | string[] | Yes | A list of additional image URLs for the product. |
|
|
533
406
|
| `suitableSizes` | SuitableSizeDto[] | No | Size recommendations from Sizebay's What Fits Me feature, including comfort scores.<br>This is populated when personalized sizing is available. |
|
|
534
407
|
| `clothType` | ClothType | No | The standardized clothing type, used for recommendations and size chart matching. |
|
|
408
|
+
| `catalogTableCode` | number | No | The id of the modeling table of the product |
|
|
535
409
|
<!-- /DOCGEN -->
|
|
536
410
|
|
|
537
411
|
#### `TrackData`
|
|
@@ -587,4 +461,4 @@ ClothType.TOP // For shirts, blouses, jackets
|
|
|
587
461
|
ClothType.BOTTOM // For pants, skirts, shorts
|
|
588
462
|
ClothType.FULL_BODY // For dresses, jumpsuits
|
|
589
463
|
ClothType.SHOE_ACCESSORY // For shoes, accessories
|
|
590
|
-
```
|
|
464
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Config } from '../config';
|
|
2
|
-
import { GetSimilarProductsParams, GetComplementaryProductsParams, GetSimilarByImageBodyDto, GetComplementaryByImageBodyDto,
|
|
2
|
+
import { GetSimilarProductsParams, GetComplementaryProductsParams, GetSimilarByImageBodyDto, GetComplementaryByImageBodyDto, GetSimilarProductsResponse, GetComplementaryProductsResponse, GetComplementaryProductsByImageResponse } from '../types/ai-image';
|
|
3
3
|
export declare class AIImageService {
|
|
4
4
|
private endpoint;
|
|
5
5
|
constructor(config: Config);
|
|
@@ -8,6 +8,4 @@ export declare class AIImageService {
|
|
|
8
8
|
getComplementaryProducts(params: GetComplementaryProductsParams): Promise<GetComplementaryProductsResponse>;
|
|
9
9
|
searchSimilarByImage(payload: GetSimilarByImageBodyDto): Promise<GetSimilarProductsResponse>;
|
|
10
10
|
searchComplementaryByImage(payload: GetComplementaryByImageBodyDto): Promise<GetComplementaryProductsByImageResponse>;
|
|
11
|
-
searchSimilarByPermalink(payload: GetSimilarByPermalinkBodyDto): Promise<GetSimilarProductsResponse>;
|
|
12
|
-
searchComplementaryByPermalink(payload: GetComplementaryByPermalinkBodyDto): Promise<GetComplementaryProductsResponse>;
|
|
13
11
|
}
|
|
@@ -19,10 +19,10 @@ class l {
|
|
|
19
19
|
this.serviceOverrides = t.services || {}, this.endpoints = {};
|
|
20
20
|
for (const s in p)
|
|
21
21
|
if (Object.prototype.hasOwnProperty.call(p, s)) {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
22
|
+
const o = p[s][e];
|
|
23
|
+
if (!o)
|
|
24
24
|
continue;
|
|
25
|
-
this.endpoints[s] =
|
|
25
|
+
this.endpoints[s] = o;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
getEndpoint(t) {
|
|
@@ -47,25 +47,25 @@ class S {
|
|
|
47
47
|
...e
|
|
48
48
|
}, n = new URL(`${this.endpoint}/events`);
|
|
49
49
|
try {
|
|
50
|
-
const
|
|
50
|
+
const o = await fetch(n, {
|
|
51
51
|
method: "POST",
|
|
52
52
|
headers: { "Content-Type": "application/json" },
|
|
53
53
|
body: JSON.stringify(s)
|
|
54
54
|
});
|
|
55
|
-
if (!
|
|
56
|
-
const
|
|
57
|
-
throw new Error(`Request error: ${
|
|
55
|
+
if (!o.ok) {
|
|
56
|
+
const i = await o.text();
|
|
57
|
+
throw new Error(`Request error: ${o.status} - ${i}`);
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
60
|
-
return await
|
|
60
|
+
return await o.json();
|
|
61
61
|
} catch {
|
|
62
62
|
return {
|
|
63
63
|
statusCode: 201,
|
|
64
64
|
message: "Event successfully created."
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
} catch (
|
|
68
|
-
throw
|
|
67
|
+
} catch (o) {
|
|
68
|
+
throw o;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -175,147 +175,6 @@ class T {
|
|
|
175
175
|
body: JSON.stringify(t)
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Fetches similar product recommendations by permalink or productId.
|
|
180
|
-
*
|
|
181
|
-
* This method searches for products that are visually similar to a reference product
|
|
182
|
-
* identified by either its permalink URL or productId. The search uses AI-powered
|
|
183
|
-
* image analysis to find products with similar visual characteristics like color,
|
|
184
|
-
* style, pattern, and overall appearance.
|
|
185
|
-
*
|
|
186
|
-
* Sends a POST request to `/image-search/similar-by-permalink` with the search parameters.
|
|
187
|
-
* At least one of permalink or productId must be provided in the payload.
|
|
188
|
-
*
|
|
189
|
-
* @param payload - Search parameters including:
|
|
190
|
-
* - `permalink` (optional): Full URL of the reference product
|
|
191
|
-
* - `productId` (optional): Unique identifier of the reference product
|
|
192
|
-
* - `tenantId`: Client/tenant identifier
|
|
193
|
-
* - `collectionName`: Embeddings collection namespace
|
|
194
|
-
* - `sid`: Session identifier for the user
|
|
195
|
-
* - `sizeSystem`: Size system code (e.g., 'BR', 'EU', 'US')
|
|
196
|
-
* - `locale`: Language and region (e.g., 'en-US', 'pt-BR')
|
|
197
|
-
* - `currency`: Currency code for pricing (e.g., 'USD', 'BRL')
|
|
198
|
-
* - `similarityThreshold`: Minimum similarity score (0-1, default: 0.5)
|
|
199
|
-
* - `page`: Page number for pagination (default: 1)
|
|
200
|
-
* - `perPage`: Items per page (default: 20)
|
|
201
|
-
* - `ageRange`: Target age range (optional)
|
|
202
|
-
* - `gender`: User gender (optional)
|
|
203
|
-
* - `style`: Preferred style hint (optional)
|
|
204
|
-
* - `color`: Main color of interest (optional)
|
|
205
|
-
* - `productClass`: Target product class (optional)
|
|
206
|
-
* - `clothType`: Target cloth type for filtering (optional)
|
|
207
|
-
* - `filterByWhatFitsMe`: Apply What Fits Me logic (optional)
|
|
208
|
-
* - `personaHash`: User persona hash for personalization (optional)
|
|
209
|
-
*
|
|
210
|
-
* @returns Promise resolving to a paginated list of similar products with:
|
|
211
|
-
* - `data`: Array of similar products ordered by similarity score
|
|
212
|
-
* - `page`: Current page number
|
|
213
|
-
* - `perPage`: Number of items per page
|
|
214
|
-
* - `total`: Total number of similar products found
|
|
215
|
-
* - `invalidPersonaHash`: Whether the persona hash is invalid/expired
|
|
216
|
-
*
|
|
217
|
-
* @throws {ApiError} if the HTTP status is not 2xx or on network failure
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* ```typescript
|
|
221
|
-
* const similarProducts = await aiImageService.searchSimilarByPermalink({
|
|
222
|
-
* tenantId: 123,
|
|
223
|
-
* collectionName: "products",
|
|
224
|
-
* sid: "session123",
|
|
225
|
-
* sizeSystem: "BR",
|
|
226
|
-
* locale: "pt-BR",
|
|
227
|
-
* currency: "BRL",
|
|
228
|
-
* permalink: "https://example.com/products/red-dress-456",
|
|
229
|
-
* similarityThreshold: 0.7,
|
|
230
|
-
* page: 1,
|
|
231
|
-
* perPage: 10,
|
|
232
|
-
* style: "Casual",
|
|
233
|
-
* color: "red"
|
|
234
|
-
* });
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
searchSimilarByPermalink(t) {
|
|
238
|
-
const e = `${this.endpoint}/image-search/similar-by-permalink`;
|
|
239
|
-
return a(e, {
|
|
240
|
-
method: "POST",
|
|
241
|
-
headers: { "Content-Type": "application/json" },
|
|
242
|
-
body: JSON.stringify(t)
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Fetches complementary product recommendations by permalink or productId.
|
|
247
|
-
*
|
|
248
|
-
* This method finds products that complement a reference product identified by either
|
|
249
|
-
* its permalink URL or productId. Complementary products are items that work well
|
|
250
|
-
* together in an outfit or ensemble, such as tops that go with bottoms, shoes that
|
|
251
|
-
* match a dress, or accessories that complement a main piece.
|
|
252
|
-
*
|
|
253
|
-
* The AI analyzes the reference product's style, color, and category to suggest
|
|
254
|
-
* complementary items that would create cohesive and fashionable combinations.
|
|
255
|
-
*
|
|
256
|
-
* Sends a POST request to `/image-search/complementary-by-permalink` with the search parameters.
|
|
257
|
-
* At least one of permalink or productId must be provided in the payload.
|
|
258
|
-
*
|
|
259
|
-
* @param payload - Search parameters including:
|
|
260
|
-
* - `permalink` (optional): Full URL of the reference product
|
|
261
|
-
* - `productId` (optional): Unique identifier of the reference product
|
|
262
|
-
* - `tenantId`: Client/tenant identifier
|
|
263
|
-
* - `collectionName`: Embeddings collection namespace
|
|
264
|
-
* - `sid`: Session identifier for the user
|
|
265
|
-
* - `sizeSystem`: Size system code (e.g., 'BR', 'EU', 'US')
|
|
266
|
-
* - `locale`: Language and region (e.g., 'en-US', 'pt-BR')
|
|
267
|
-
* - `currency`: Currency code for pricing (e.g., 'USD', 'BRL')
|
|
268
|
-
* - `similarityThreshold`: Minimum similarity score (0-1, default: 0.2)
|
|
269
|
-
* - `baseClothType` (optional): Cloth type of the reference product (e.g., ClothType.BOTTOM)
|
|
270
|
-
* - `targetClothType` (optional): Desired cloth type for complementary products (e.g., ClothType.TOP)
|
|
271
|
-
* - `page`: Page number for pagination (default: 1)
|
|
272
|
-
* - `perPage`: Items per page (default: 20)
|
|
273
|
-
* - `ageRange`: Target age range (optional)
|
|
274
|
-
* - `gender`: User gender (optional)
|
|
275
|
-
* - `style`: Preferred style hint (optional)
|
|
276
|
-
* - `color`: Main color of interest (optional)
|
|
277
|
-
* - `productClass`: Target product class (optional)
|
|
278
|
-
* - `filterByWhatFitsMe`: Apply What Fits Me logic (optional)
|
|
279
|
-
* - `personaHash`: User persona hash for personalization (optional)
|
|
280
|
-
*
|
|
281
|
-
* @returns Promise resolving to complementary product recommendations with:
|
|
282
|
-
* - `baseProduct`: The reference product information
|
|
283
|
-
* - `complementary`: Array of complementary product pairs
|
|
284
|
-
* - `page`: Current page number
|
|
285
|
-
* - `perPage`: Number of items per page
|
|
286
|
-
* - `total`: Total number of complementary products found
|
|
287
|
-
* - `invalidPersonaHash`: Whether the persona hash is invalid/expired
|
|
288
|
-
*
|
|
289
|
-
* @throws {ApiError} if the HTTP status is not 2xx or on network failure
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```typescript
|
|
293
|
-
* const complementaryProducts = await aiImageService.searchComplementaryByPermalink({
|
|
294
|
-
* tenantId: 123,
|
|
295
|
-
* collectionName: "products",
|
|
296
|
-
* sid: "session123",
|
|
297
|
-
* sizeSystem: "BR",
|
|
298
|
-
* locale: "pt-BR",
|
|
299
|
-
* currency: "BRL",
|
|
300
|
-
* productId: "12345",
|
|
301
|
-
* similarityThreshold: 0.3,
|
|
302
|
-
* baseClothType: ClothType.BOTTOM,
|
|
303
|
-
* targetClothType: ClothType.TOP,
|
|
304
|
-
* page: 1,
|
|
305
|
-
* perPage: 10,
|
|
306
|
-
* style: "Casual",
|
|
307
|
-
* color: "blue"
|
|
308
|
-
* });
|
|
309
|
-
* ```
|
|
310
|
-
*/
|
|
311
|
-
searchComplementaryByPermalink(t) {
|
|
312
|
-
const e = `${this.endpoint}/image-search/complementary-by-permalink`;
|
|
313
|
-
return a(e, {
|
|
314
|
-
method: "POST",
|
|
315
|
-
headers: { "Content-Type": "application/json" },
|
|
316
|
-
body: JSON.stringify(t)
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
178
|
}
|
|
320
179
|
class u {
|
|
321
180
|
constructor(t) {
|
|
@@ -359,16 +218,16 @@ class u {
|
|
|
359
218
|
async sendProfile(t, e) {
|
|
360
219
|
const s = e ?? (await this.getSessionInfo()).sid, n = new URL(this.profileEndpoint);
|
|
361
220
|
n.searchParams.set("sid", s);
|
|
362
|
-
const
|
|
221
|
+
const o = await fetch(n.toString(), {
|
|
363
222
|
credentials: "include",
|
|
364
223
|
method: "POST",
|
|
365
224
|
headers: { "Content-Type": "application/json" },
|
|
366
225
|
body: JSON.stringify({ userId: s, id: null, ...t })
|
|
367
226
|
});
|
|
368
|
-
if (!
|
|
369
|
-
const
|
|
227
|
+
if (!o.ok) {
|
|
228
|
+
const i = await o.text();
|
|
370
229
|
throw new Error(
|
|
371
|
-
`Failed to send profile: ${
|
|
230
|
+
`Failed to send profile: ${o.status} – ${i}`
|
|
372
231
|
);
|
|
373
232
|
}
|
|
374
233
|
}
|
|
@@ -378,20 +237,20 @@ const O = [
|
|
|
378
237
|
T,
|
|
379
238
|
u
|
|
380
239
|
];
|
|
381
|
-
function
|
|
240
|
+
function E(r = {}) {
|
|
382
241
|
const t = new l(r), e = O.map((n) => new n(t)), s = {};
|
|
383
242
|
return e.forEach((n) => {
|
|
384
243
|
[
|
|
385
244
|
...Object.getOwnPropertyNames(n),
|
|
386
245
|
...Object.getOwnPropertyNames(Object.getPrototypeOf(n))
|
|
387
|
-
].forEach((
|
|
388
|
-
if (
|
|
389
|
-
const d = n[
|
|
390
|
-
typeof d == "function" && (s[
|
|
246
|
+
].forEach((i) => {
|
|
247
|
+
if (i === "constructor") return;
|
|
248
|
+
const d = n[i];
|
|
249
|
+
typeof d == "function" && (s[i] || (s[i] = (...h) => d.apply(n, h)));
|
|
391
250
|
});
|
|
392
251
|
}), s;
|
|
393
252
|
}
|
|
394
|
-
const
|
|
253
|
+
const m = {
|
|
395
254
|
TOP: "TOP",
|
|
396
255
|
BOTTOM: "BOTTOM",
|
|
397
256
|
SHOE_ACCESSORY: "SHOE_ACCESSORY",
|
|
@@ -402,7 +261,7 @@ const E = {
|
|
|
402
261
|
WETSUIT_FULL_BODY: "WETSUIT_FULL_BODY",
|
|
403
262
|
WETSUIT_BOTTOM: "WETSUIT_BOTTOM",
|
|
404
263
|
WETSUIT_TOP: "WETSUIT_TOP"
|
|
405
|
-
},
|
|
264
|
+
}, f = {
|
|
406
265
|
T_SHIRT: "t-shirt",
|
|
407
266
|
SHIRT: "shirt",
|
|
408
267
|
BLOUSE: "blouse",
|
|
@@ -444,7 +303,7 @@ const E = {
|
|
|
444
303
|
WETSUIT: "wetsuit"
|
|
445
304
|
};
|
|
446
305
|
export {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
306
|
+
m as ClothType,
|
|
307
|
+
f as ProductClass,
|
|
308
|
+
E as createClient
|
|
450
309
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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}`)}try{return await o.json()}catch{return{statusCode:201,message:"Event successfully created."}}}catch(o){throw o}}}class d 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,d.prototype)}}async function p(c,e){let t;try{t=await fetch(c,e)}catch(n){throw new d(0,n.message)}const s=await t.text();if(!t.ok)throw new d(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),p(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getComplementaryProducts(e){const t=new URL(`${this.endpoint}/recommendations/complementary`);return this.appendQueryParams(t,e),p(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(e){const t=`${this.endpoint}/image-search/similar`;return p(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByImage(e){const t=`${this.endpoint}/image-search/complementary`;return p(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 E(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 f={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=f,i.ProductClass=m,i.createClient=E,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -4,8 +4,6 @@ export * from './params/get-similar-products.dto';
|
|
|
4
4
|
export * from './params/get-complementary-products.dto';
|
|
5
5
|
export * from './params/get-similar-by-image.dto';
|
|
6
6
|
export * from './params/get-complementary-by-image.dto';
|
|
7
|
-
export * from './params/get-similar-by-permalink.dto';
|
|
8
|
-
export * from './params/get-complementary-by-permalink.dto';
|
|
9
7
|
export * from './responses/get-similar-products-response.dto';
|
|
10
8
|
export * from './responses/get-complementary-products-response.dto';
|
|
11
9
|
export * from './responses/get-complementary-products-by-image-response.dto';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sizebay-core-sdk",
|
|
3
|
-
"version": "1.11.0
|
|
3
|
+
"version": "1.11.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,17 +0,0 @@
|
|
|
1
|
-
import { BaseSearchParams } from '../base/base-search.dto';
|
|
2
|
-
import { ProductClass } from '../../common/product-class.type';
|
|
3
|
-
import { ClothType } from '../../common/cloth-type.type';
|
|
4
|
-
export interface GetComplementaryByPermalinkBodyDto extends BaseSearchParams {
|
|
5
|
-
permalink?: string;
|
|
6
|
-
productId?: string;
|
|
7
|
-
similarityThreshold: number;
|
|
8
|
-
baseClothType?: ClothType;
|
|
9
|
-
targetClothType?: ClothType;
|
|
10
|
-
ageRange?: string;
|
|
11
|
-
gender?: string;
|
|
12
|
-
style?: string;
|
|
13
|
-
color?: string;
|
|
14
|
-
productClass?: ProductClass;
|
|
15
|
-
page?: number;
|
|
16
|
-
perPage?: number;
|
|
17
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BaseSearchParams } from '../base/base-search.dto';
|
|
2
|
-
import { ProductClass } from '../../common/product-class.type';
|
|
3
|
-
import { ClothType } from '../../common/cloth-type.type';
|
|
4
|
-
export interface GetSimilarByPermalinkBodyDto extends BaseSearchParams {
|
|
5
|
-
permalink?: string;
|
|
6
|
-
productId?: string;
|
|
7
|
-
ageRange?: string;
|
|
8
|
-
gender?: string;
|
|
9
|
-
style?: string;
|
|
10
|
-
color?: string;
|
|
11
|
-
productClass?: ProductClass;
|
|
12
|
-
clothType?: ClothType;
|
|
13
|
-
page?: number;
|
|
14
|
-
perPage?: number;
|
|
15
|
-
similarityThreshold?: number;
|
|
16
|
-
}
|