sizebay-core-sdk 1.17.0 → 1.19.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
@@ -207,6 +207,7 @@ Find visually similar items from an uploaded image.
207
207
  | `page` | number | No | Current page number. |
208
208
  | `perPage` | number | No | Number of results per page. |
209
209
  | `similarityThreshold` | number | No | Similarity threshold for matching (0-1). |
210
+ | `trigger` | string | Yes | trigger |
210
211
  | `tenantId` | number | Yes | Tenant (client) ID. |
211
212
  | `collectionName` | string | Yes | Embeddings collection name (namespace). |
212
213
  | `sid` | string | Yes | Session identifier (`sid`) for the user. |
@@ -264,6 +265,7 @@ Get products that complete a look from an image.
264
265
  | `clothType` | ClothType | No | Target cloth type for filtering results. |
265
266
  | `page` | number | No | Current page number. |
266
267
  | `perPage` | number | No | Number of results per page. |
268
+ | `trigger` | string | Yes | trigger |
267
269
  | `tenantId` | number | Yes | Tenant (client) ID. |
268
270
  | `collectionName` | string | Yes | Embeddings collection name (namespace). |
269
271
  | `sid` | string | Yes | Session identifier (`sid`) for the user. |
@@ -441,6 +443,7 @@ Get grouped looks with optional filters and pagination (Public endpoint).
441
443
  | `offset` | number | No | Number of looks to skip before returning results.<br>Use with limit to implement pagination: page 2 = offset 50 (if limit is 50). |
442
444
  | `order` | SortOrder | No | Sort order by creation date.<br>Use 'desc' to show newest looks first, 'asc' for oldest first. |
443
445
  | `permalink` | string | No | Filter by product permalink.<br>Find all looks that include this specific product. Useful for showing<br>styling suggestions when a user views a product page. |
446
+ | `productId` | string | No | Filter by product id.<br>Find all looks that include this specific product. Useful for showing<br>styling suggestions when a user views a product page. |
444
447
  | `gender` | Gender | No | Filter by target gender.<br>Show only looks designed for MALE or FEMALE audiences. |
445
448
  | `ageGroup` | AgeGroup | No | Filter by target age group.<br>Show only looks appropriate for the specified age range. |
446
449
  | `style` | Style | No | Filter by style category.<br>Show only looks matching the desired style (casual, formal, party, etc.). |
@@ -4,3 +4,4 @@ export declare class ApiError extends Error {
4
4
  constructor(statusCode: number, details: string);
5
5
  }
6
6
  export declare function safeFetchJson<T>(url: string, init: RequestInit): Promise<T>;
7
+ export declare function triggerPipeline(): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../config';
2
- import { GetSimilarProductsParams, GetComplementaryProductsParams, GetSimilarByImageBodyDto, GetComplementaryByImageBodyDto, GetSimilarByPermalinkBodyDto, GetComplementaryByPermalinkBodyDto, GetSimilarProductsResponse, GetComplementaryProductsResponse, GetComplementaryProductsByImageResponse } from '../types/ai-image';
2
+ import { GetComplementaryByImageBodyDto, GetComplementaryByPermalinkBodyDto, GetComplementaryProductsByImageResponse, GetComplementaryProductsParams, GetComplementaryProductsResponse, GetSimilarByImageBodyDto, GetSimilarByPermalinkBodyDto, GetSimilarProductsParams, GetSimilarProductsResponse } from '../types/ai-image';
3
3
  export declare class AIImageService {
4
4
  private readonly endpoint;
5
5
  constructor(config: Config);
@@ -12,7 +12,7 @@ const p = {
12
12
  development: "https://vfr-v3-staging.sizebay.eu/api/me"
13
13
  },
14
14
  fashionLooks: {
15
- production: "https://fashion-looks-dev.internalsizebay.com",
15
+ production: "https://fashion-looks.internalsizebay.com",
16
16
  development: "https://fashion-looks-dev.internalsizebay.com"
17
17
  }
18
18
  // Adicione outros serviços conforme necessário
@@ -93,8 +93,8 @@ async function a(i, t) {
93
93
  throw new c(e.status, n);
94
94
  return JSON.parse(n);
95
95
  }
96
- const E = "/recommendations/similar", T = "/recommendations/complementary", u = "/image-search/similar", O = "/image-search/similar-by-permalink", m = "/image-search/complementary", y = "/image-search/complementary-by-permalink";
97
- class f {
96
+ const u = "/recommendations/similar", E = "/recommendations/complementary", T = "/image-search/similar", O = "/image-search/similar-by-permalink", m = "/image-search/complementary", y = "/image-search/complementary-by-permalink";
97
+ class g {
98
98
  constructor(t) {
99
99
  this.endpoint = t.getEndpoint("aiImageService");
100
100
  }
@@ -116,7 +116,7 @@ class f {
116
116
  * @throws {ApiError} when HTTP status is not 2xx or on network failure.
117
117
  */
118
118
  getSimilarProducts(t) {
119
- const e = new URL(`${this.endpoint}${E}`);
119
+ const e = new URL(`${this.endpoint}${u}`);
120
120
  return this.appendQueryParams(e, t), a(e.toString(), {
121
121
  method: "GET",
122
122
  headers: { "Content-Type": "application/json" }
@@ -130,8 +130,10 @@ class f {
130
130
  * @throws {ApiError} when HTTP status is not 2xx or on network failure.
131
131
  */
132
132
  getComplementaryProducts(t) {
133
- const e = new URL(`${this.endpoint}${T}`);
134
- return this.appendQueryParams(e, t), a(e.toString(), {
133
+ const e = new URL(
134
+ `${this.endpoint}${E}`
135
+ );
136
+ return this.appendQueryParams(e, t), console.log("Fetching complementary products with URL:", e.toString()), a(e.toString(), {
135
137
  method: "GET",
136
138
  headers: { "Content-Type": "application/json" }
137
139
  });
@@ -144,7 +146,7 @@ class f {
144
146
  * @throws {ApiError} when HTTP status is not 2xx or on network failure.
145
147
  */
146
148
  searchSimilarByImage(t) {
147
- const e = `${this.endpoint}${u}`;
149
+ const e = `${this.endpoint}${T}`;
148
150
  return a(e, {
149
151
  method: "POST",
150
152
  headers: { "Content-Type": "application/json" },
@@ -197,7 +199,7 @@ class f {
197
199
  });
198
200
  }
199
201
  }
200
- class I {
202
+ class f {
201
203
  constructor(t) {
202
204
  this.sid = null, this.sessionId = null;
203
205
  const e = t.getEndpoint("session");
@@ -253,7 +255,7 @@ class I {
253
255
  }
254
256
  }
255
257
  }
256
- class g {
258
+ class I {
257
259
  constructor(t) {
258
260
  this.endpoint = t.getEndpoint("fashionLooks");
259
261
  }
@@ -313,9 +315,9 @@ class g {
313
315
  }
314
316
  const R = [
315
317
  S,
318
+ g,
316
319
  f,
317
- I,
318
- g
320
+ I
319
321
  ];
320
322
  function P(i = {}) {
321
323
  const t = new l(i), e = R.map((s) => new s(t)), n = {};
@@ -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}`)}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
+ (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.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",m="/image-search/similar-by-permalink",O="/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),console.log("Fetching complementary products with URL:",t.toString()),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}${O}`;return r(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}searchSimilarByPermalink(e){const t=`${this.endpoint}${m}`;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,6 +1,6 @@
1
- import { BaseSearchParams } from './base-search.dto';
2
- import { ProductClass } from '../../common/product-class.type';
3
1
  import { ClothType } from '../../common/cloth-type.type';
2
+ import { ProductClass } from '../../common/product-class.type';
3
+ import { BaseSearchParams } from './base-search.dto';
4
4
  export interface BaseImageSearchParams extends BaseSearchParams {
5
5
  image: string;
6
6
  ageRange?: string;
@@ -12,4 +12,5 @@ export interface BaseImageSearchParams extends BaseSearchParams {
12
12
  page?: number;
13
13
  perPage?: number;
14
14
  similarityThreshold?: number;
15
+ trigger: string | undefined;
15
16
  }
@@ -11,6 +11,7 @@ export interface GetGroupedLooksParams {
11
11
  offset?: number;
12
12
  order?: SortOrder;
13
13
  permalink?: string;
14
+ productId?: string;
14
15
  gender?: Gender;
15
16
  ageGroup?: AgeGroup;
16
17
  style?: Style;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.17.0",
3
+ "version": "1.19.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",