sizebay-core-sdk 1.11.0-dev.1 → 1.11.0-dev.3

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
@@ -296,6 +296,133 @@ 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
+
299
426
  ## Session Module
300
427
 
301
428
  Retrieves and caches session context:
@@ -1,5 +1,5 @@
1
- import { TrackData, TrackResponse } from '../types';
2
1
  import { Config } from '../config';
2
+ import { TrackData, TrackResponse } from '../types';
3
3
  export declare class Tracker {
4
4
  private endpoint;
5
5
  constructor(config: Config);
@@ -56,7 +56,14 @@ class S {
56
56
  const o = await i.text();
57
57
  throw new Error(`Request error: ${i.status} - ${o}`);
58
58
  }
59
- return await i.json();
59
+ try {
60
+ return await i.json();
61
+ } catch {
62
+ return {
63
+ statusCode: 201,
64
+ message: "Event successfully created."
65
+ };
66
+ }
60
67
  } catch (i) {
61
68
  throw i;
62
69
  }
@@ -310,7 +317,7 @@ class T {
310
317
  });
311
318
  }
312
319
  }
313
- class O {
320
+ class u {
314
321
  constructor(t) {
315
322
  this.sid = null, this.sessionId = null;
316
323
  const e = t.getEndpoint("session");
@@ -366,13 +373,13 @@ class O {
366
373
  }
367
374
  }
368
375
  }
369
- const u = [
376
+ const O = [
370
377
  S,
371
378
  T,
372
- O
379
+ u
373
380
  ];
374
381
  function m(r = {}) {
375
- const t = new l(r), e = u.map((n) => new n(t)), s = {};
382
+ const t = new l(r), e = O.map((n) => new n(t)), s = {};
376
383
  return e.forEach((n) => {
377
384
  [
378
385
  ...Object.getOwnPropertyNames(n),
@@ -395,7 +402,7 @@ const E = {
395
402
  WETSUIT_FULL_BODY: "WETSUIT_FULL_BODY",
396
403
  WETSUIT_BOTTOM: "WETSUIT_BOTTOM",
397
404
  WETSUIT_TOP: "WETSUIT_TOP"
398
- }, f = {
405
+ }, y = {
399
406
  T_SHIRT: "t-shirt",
400
407
  SHIRT: "shirt",
401
408
  BLOUSE: "blouse",
@@ -438,6 +445,6 @@ const E = {
438
445
  };
439
446
  export {
440
447
  E as ClothType,
441
- f as ProductClass,
448
+ y as ProductClass,
442
449
  m as createClient
443
450
  };
@@ -1 +1 @@
1
- (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o["sizebay-core-sdk"]={}))})(this,(function(o){"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 i=a[s][t];if(!i)continue;this.endpoints[s]=i}}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 S{constructor(e){this.endpoint=e.getEndpoint("tracker")}async track(e,t){const s={eventName:e,...t},n=new URL(`${this.endpoint}/events`);try{const i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const r=await i.text();throw new Error(`Request error: ${i.status} - ${r}`)}return await i.json()}catch(i){throw i}}}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 u{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"}})}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)})}searchSimilarByPermalink(e){const t=`${this.endpoint}/image-search/similar-by-permalink`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByPermalink(e){const t=`${this.endpoint}/image-search/complementary-by-permalink`;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 i=await fetch(n.toString(),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:s,id:null,...e})});if(!i.ok){const r=await i.text();throw new Error(`Failed to send profile: ${i.status} – ${r}`)}}}const O=[S,u,T];function m(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"},E={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"};o.ClothType=f,o.ProductClass=E,o.createClient=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o["sizebay-core-sdk"]={}))})(this,(function(o){"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 i=a[s][t];if(!i)continue;this.endpoints[s]=i}}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 i=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!i.ok){const r=await i.text();throw new Error(`Request error: ${i.status} - ${r}`)}try{return await i.json()}catch{return{statusCode:201,message:"Event successfully created."}}}catch(i){throw i}}}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"}})}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)})}searchSimilarByPermalink(e){const t=`${this.endpoint}/image-search/similar-by-permalink`;return d(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByPermalink(e){const t=`${this.endpoint}/image-search/complementary-by-permalink`;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 i=await fetch(n.toString(),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:s,id:null,...e})});if(!i.ok){const r=await i.text();throw new Error(`Failed to send profile: ${i.status} – ${r}`)}}}const O=[u,S,T];function m(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"},E={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"};o.ClothType=f,o.ProductClass=E,o.createClient=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
@@ -1,4 +1,4 @@
1
- import { TrackSuccessResponse } from './track-success-response.dto';
2
1
  import { TrackBadRequestResponse } from './track-bad-request-response.dto';
3
2
  import { TrackServerErrorResponse } from './track-server-error-response.dto';
3
+ import { TrackSuccessResponse } from './track-success-response.dto';
4
4
  export type TrackResponse = TrackSuccessResponse | TrackBadRequestResponse | TrackServerErrorResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.11.0-dev.1",
3
+ "version": "1.11.0-dev.3",
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",