sizebay-core-sdk 1.16.1 → 1.17.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
@@ -63,7 +63,7 @@ Send an event to the API.
63
63
 
64
64
  <!-- DOCGEN:returns TrackResponse -->
65
65
  > **`TrackResponse`**
66
- > * `statusCode`: `201` — HTTP status code indicating success (201 Created).
66
+ > * `statusCode`: `number` — HTTP status code returned by the API (e.g. 201 Created).
67
67
  > * `message`: `"Event successfully created."` — Confirmation message.
68
68
  <!-- /DOCGEN -->
69
69
 
@@ -447,6 +447,8 @@ Get grouped looks with optional filters and pagination (Public endpoint).
447
447
  | `collection` | Collection | No | Filter by seasonal collection.<br>Show only looks from a specific season (spring, summer, fall, winter). |
448
448
  | `language` | Language | No | Language/locale for filtering localizations.<br>Use this to get product information in the specified language. |
449
449
  | `currency` | string | No | Currency code for pricing (e.g., EUR, USD, BRL). |
450
+ | `personaHash` | string | No | Persona hash for size-based filtering.<br>Returns only grouped looks whose garments fit the persona's size profile. |
451
+ | `sizeSystem` | string | No | Size system to use when matching catalog sizes against persona recommendations<br>(e.g., BR, US, EU). When provided, only sizes from this system are compared. |
450
452
  <!-- /DOCGEN -->
451
453
 
452
454
  #### Returns
@@ -60,14 +60,10 @@ class S {
60
60
  const r = await o.text();
61
61
  throw new Error(`Request error: ${o.status} - ${r}`);
62
62
  }
63
- try {
64
- return await o.json();
65
- } catch {
66
- return {
67
- statusCode: 201,
68
- message: "Event successfully created."
69
- };
70
- }
63
+ return {
64
+ statusCode: o.status,
65
+ message: "Event successfully created."
66
+ };
71
67
  } catch (o) {
72
68
  throw o;
73
69
  }
@@ -1 +1 @@
1
- (function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i["sizebay-core-sdk"]={}))})(this,(function(i){"use strict";const p={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"},fashionLooks:{production:"https://fashion-looks-dev.internalsizebay.com",development:"https://fashion-looks-dev.internalsizebay.com"}};class l{constructor(e){const t=e.env||"development";this.serviceOverrides=e.services||{},this.endpoints={};for(const n in p)if(Object.prototype.hasOwnProperty.call(p,n)){const o=p[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 c=await o.text();throw new Error(`Request error: ${o.status} - ${c}`)}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 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,d.prototype)}}async function r(a,e){let t;try{t=await fetch(a,e)}catch(s){throw new d(0,s.message)}const n=await t.text();if(!t.ok)throw new d(t.status,n);return JSON.parse(n)}const S="/recommendations/similar",T="/recommendations/complementary",E="/image-search/similar",O="/image-search/similar-by-permalink",m="/image-search/complementary",f="/image-search/complementary-by-permalink";class y{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}${S}`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getComplementaryProducts(e){const t=new URL(`${this.endpoint}${T}`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(e){const t=`${this.endpoint}${E}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByImage(e){const t=`${this.endpoint}${m}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchSimilarByPermalink(e){const t=`${this.endpoint}${O}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByPermalink(e){const t=`${this.endpoint}${f}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}class g{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 c=await o.text();throw new Error(`Failed to send profile: ${o.status} – ${c}`)}}}class I{constructor(e){this.endpoint=e.getEndpoint("fashionLooks")}appendQueryParams(e,t){Object.entries(t).forEach(([n,s])=>{s!=null&&e.searchParams.append(n,String(s))})}getGroupedLooks(e){const t=new URL(`${this.endpoint}/api/public/grouped-looks`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getGroupedLookById(e,t,n){const s=new URL(`${this.endpoint}/api/public/grouped-looks/${e}`);return s.searchParams.set("tenantId",String(t)),s.searchParams.set("language",n),r(s.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}}const R=[u,y,g,I];function P(a={}){const e=new l(a),t=R.map(s=>new s(e)),n={};return t.forEach(s=>{[...Object.getOwnPropertyNames(s),...Object.getOwnPropertyNames(Object.getPrototypeOf(s))].forEach(c=>{if(c==="constructor")return;const h=s[c];typeof h=="function"&&(n[c]||(n[c]=(...C)=>h.apply(s,C)))})}),n}const A={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"},_={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=A,i.ProductClass=_,i.createClient=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(i=typeof globalThis<"u"?globalThis:i||self,p(i["sizebay-core-sdk"]={}))})(this,(function(i){"use strict";const p={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"},fashionLooks:{production:"https://fashion-looks-dev.internalsizebay.com",development:"https://fashion-looks-dev.internalsizebay.com"}};class l{constructor(e){const t=e.env||"development";this.serviceOverrides=e.services||{},this.endpoints={};for(const n in p)if(Object.prototype.hasOwnProperty.call(p,n)){const o=p[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 c=await o.text();throw new Error(`Request error: ${o.status} - ${c}`)}return{statusCode:o.status,message:"Event successfully created."}}catch(o){throw o}}}class d 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,d.prototype)}}async function r(a,e){let t;try{t=await fetch(a,e)}catch(s){throw new d(0,s.message)}const n=await t.text();if(!t.ok)throw new d(t.status,n);return JSON.parse(n)}const S="/recommendations/similar",T="/recommendations/complementary",E="/image-search/similar",O="/image-search/similar-by-permalink",m="/image-search/complementary",f="/image-search/complementary-by-permalink";class y{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}${S}`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getComplementaryProducts(e){const t=new URL(`${this.endpoint}${T}`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(e){const t=`${this.endpoint}${E}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByImage(e){const t=`${this.endpoint}${m}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchSimilarByPermalink(e){const t=`${this.endpoint}${O}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchComplementaryByPermalink(e){const t=`${this.endpoint}${f}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}class g{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 c=await o.text();throw new Error(`Failed to send profile: ${o.status} – ${c}`)}}}class I{constructor(e){this.endpoint=e.getEndpoint("fashionLooks")}appendQueryParams(e,t){Object.entries(t).forEach(([n,s])=>{s!=null&&e.searchParams.append(n,String(s))})}getGroupedLooks(e){const t=new URL(`${this.endpoint}/api/public/grouped-looks`);return this.appendQueryParams(t,e),r(t.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getGroupedLookById(e,t,n){const s=new URL(`${this.endpoint}/api/public/grouped-looks/${e}`);return s.searchParams.set("tenantId",String(t)),s.searchParams.set("language",n),r(s.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}}const R=[u,y,g,I];function P(a={}){const e=new l(a),t=R.map(s=>new s(e)),n={};return t.forEach(s=>{[...Object.getOwnPropertyNames(s),...Object.getOwnPropertyNames(Object.getPrototypeOf(s))].forEach(c=>{if(c==="constructor")return;const h=s[c];typeof h=="function"&&(n[c]||(n[c]=(...C)=>h.apply(s,C)))})}),n}const A={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"},_={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=A,i.ProductClass=_,i.createClient=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
@@ -1,4 +1,4 @@
1
1
  export interface TrackSuccessResponse {
2
- statusCode: 201;
2
+ statusCode: number;
3
3
  message: 'Event successfully created.';
4
4
  }
@@ -17,4 +17,6 @@ export interface GetGroupedLooksParams {
17
17
  collection?: Collection;
18
18
  language?: Language;
19
19
  currency?: string;
20
+ personaHash?: string;
21
+ sizeSystem?: string;
20
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.16.1",
3
+ "version": "1.17.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",