sizebay-core-sdk 1.2.1 → 1.3.0-dev.1

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
@@ -51,11 +51,11 @@ Sends an event to the designated API endpoint, returning a standardized response
51
51
 
52
52
  | Property | Type | Required | Description |
53
53
  |-------------|-------------------------------|----------|-----------------------------------------------------------------------|
54
- | **sid** | `string` | Yes | Unique session identifier. |
54
+ | **sid** | `string` | Yes | Unique user identifier. |
55
55
  | **tenantId**| `number` | Yes | Identifier of the tenant (client) sending the event. |
56
- | **sessionId**| `number` | Yes | Internal session identifier. |
57
- | **permalink**| `string` (optional) | No | Product URL associated with the event. When the event is linked to product (e.g., ADD_TO_CART RECOMMENDATION_DONE), it is required. |
58
56
  | **properties**| `Record<string, JSONValue>` | Yes | Object containing additional properties as key-value pairs. |
57
+ | **sessionId**| `number` | No | Sizebay session identifier. |
58
+ | **permalink**| `string` (optional) | No | Product URL associated with the event. When the event is linked to product (e.g., ADD_TO_CART RECOMMENDATION_DONE), it is required. |
59
59
 
60
60
  **Returns**
61
61
 
@@ -123,32 +123,46 @@ async function trackEvent() {
123
123
  trackEvent();
124
124
  ```
125
125
 
126
- ## AI Image Service Module
126
+ Thought for a couple of seconds
127
127
 
128
- ### `getSimilarProducts(params: GetSimilarProductsParams): Promise<GetSimilarProductsResponse>`
129
128
 
130
- Fetches similar products based on the given parameters, returning a paginated result.
129
+ Segue a documentação atualizada com os parâmetros `filterByWhatFitsMe`, `personaHash` e o campo de resposta `suitableSizes`.
131
130
 
132
- #### Parameters
131
+ ---
133
132
 
134
- | Parameter | Type | Required | Description |
135
- |------------------|--------------------------------|:--------:|------------------------------------------------------------------------------------------|
136
- | `tenantId` | `number` | **Yes** | The tenant ID that initiated the request. |
137
- | `collectionName` | `string` | **Yes** | The name of the relevant product collection. |
138
- | `sessionId` | `number` | **Yes** | The session ID, typically required for internal event tracking. |
139
- | `permalink` | `string` | **Yes** | A permanent link representing the main product. |
140
- | `page` | `number` (optional) | No | Page number for pagination. |
141
- | `perPage` | `number` (optional) | No | Number of items per page. |
133
+ Thought for a couple of seconds
142
134
 
143
- #### Returns
144
135
 
145
- **`Promise<GetSimilarProductsResponse>`**
146
- An object containing:
136
+ Here’s a cleaned-up, fully English version with consistent terminology, corrected typos, and improved clarity:
147
137
 
148
- - `data`: An array of `Product` objects.
149
- - `page`: The current page number.
150
- - `perPage`: The number of items per page.
151
- - `total`: The total number of items available.
138
+ ---
139
+
140
+ ## AI Image Service Module
141
+
142
+ ### `getSimilarProducts(params: GetSimilarProductsParams): Promise<GetSimilarProductsResponse>`
143
+
144
+ Fetch similar products based on the given parameters, returning a paginated result and—when requested—size recommendations.
145
+
146
+ #### Parameters
147
+
148
+ | Parameter | Type | Required | Description |
149
+ | -------------------- | --------- | :------: | ---------------------------------------------------------------------------- |
150
+ | `tenantId` | `number` | **Yes** | Tenant ID initiating the request. |
151
+ | `collectionName` | `string` | **Yes** | Name of the product collection. |
152
+ | `sessionId` | `number` | **Yes** | Session ID for internal event tracking. |
153
+ | `permalink` | `string` | **Yes** | Permanent link (URL) of the main product. |
154
+ | `page` | `number` | No | Page number (pagination). |
155
+ | `perPage` | `number` | No | Number of items per page. |
156
+ | `filterByWhatFitsMe` | `boolean` | No | If `true`, apply “What Fits Me” size filter. Defaults to `false`. |
157
+ | `personaHash` | `string` | Cond.\* | Persona hash from Size & Fit; **required** when `filterByWhatFitsMe = true`. |
158
+
159
+ > **Returns:** `Promise<GetSimilarProductsResponse>`
160
+ >
161
+ > * `data`: `Product[]` — Array of product objects.
162
+ > * `page`: `number` — Current page.
163
+ > * `perPage`: `number` — Items per page.
164
+ > * `total`: `number` — Total available items.
165
+ > * `suitableSizes?`: `SuitableSizeDto[]` — Size recommendations (only if `filterByWhatFitsMe = true`).
152
166
 
153
167
  #### Example
154
168
 
@@ -157,48 +171,51 @@ import { GetSimilarProductsParams } from 'sizebay-core-sdk';
157
171
 
158
172
  const params: GetSimilarProductsParams = {
159
173
  tenantId: 123,
160
- permalink: 'https://example.com/product',
161
174
  collectionName: 'summer-collection',
162
175
  sessionId: 456,
176
+ permalink: 'https://example.com/product',
163
177
  page: 1,
164
178
  perPage: 10,
179
+ filterByWhatFitsMe: true,
180
+ personaHash: '6b4f2e8b-0bb2-43d1-8bea-7f6d1c5d5a71',
165
181
  };
166
182
 
167
- async function fetchSimilarProducts() {
183
+ async function fetchSimilar() {
168
184
  try {
169
185
  const response = await client.getSimilarProducts(params);
170
- console.log('Similar products:', response.data);
171
- } catch (error: any) {
172
- console.error('Error fetching similar products:', error.message);
186
+ console.log('Products:', response.data);
187
+ if (response.suitableSizes) {
188
+ console.log('Recommended sizes:', response.suitableSizes);
189
+ }
190
+ } catch (err: any) {
191
+ console.error('Error:', err.message);
173
192
  }
174
193
  }
175
194
 
176
- fetchSimilarProducts();
195
+ fetchSimilar();
177
196
  ```
178
197
 
179
198
  ---
180
199
 
181
- ### `GetRecommendedSizeByProducts(payload: GetRecommendedSizeByProductsParams): Promise<GetRecommendedSizeByProductsResponse[]>`
200
+ ### `getRecommendedSizeByProducts(payload: GetRecommendedSizeByProductsParams): Promise<GetRecommendedSizeByProductsResponse[]>`
182
201
 
183
- Retrieves the recommended sizes for one or more products based on the provided parameters.
202
+ Retrieve recommended sizes for multiple products.
184
203
 
185
204
  #### Parameters
186
205
 
187
- | Parameter | Type | Required | Description |
188
- |-------------:|-------------------------|:--------:|----------------------------------------------------------------------------------------------------------------|
189
- | `tenantId` | `number` | **Yes** | The tenant ID that initiated the request. |
190
- | `sid` | `string` (optional) | No | The session ID for internal events, if needed. |
191
- | `sizeSystem` | `string` | **Yes** | The size system (e.g., 'BR', 'US', 'EU'). |
192
- | `permalinks` | `string[]` | **Yes** | A list of product permalinks for which size recommendations are requested. |
193
-
194
- #### Returns
206
+ | Parameter | Type | Required | Description |
207
+ | ------------ | ---------- | :------: | ------------------------------------------------ |
208
+ | `tenantId` | `number` | **Yes** | Tenant ID initiating the request. |
209
+ | `sid` | `string` | No | Session ID for internal events. |
210
+ | `sizeSystem` | `string` | **Yes** | Size system code (e.g., `'BR'`, `'US'`, `'EU'`). |
211
+ | `permalinks` | `string[]` | **Yes** | Array of product permalinks. |
195
212
 
196
- **`Promise<GetRecommendedSizeByProductsResponse[]>`**
197
- An array of objects, each containing:
198
-
199
- - `id`: The internal identifier for the product.
200
- - `permalink`: The product permalink from the request.
201
- - `recommendedSize`: The recommended size (`string`) or `null` if no recommendation is available.
213
+ > **Returns:** `Promise<GetRecommendedSizeByProductsResponse[]>`
214
+ > Each item includes:
215
+ >
216
+ > * `id`: `string` Internal product identifier.
217
+ > * `permalink`: `string` Product’s permalink.
218
+ > * `recommendedSize`: `string \| null` — The suggested size or `null` if unavailable.
202
219
 
203
220
  #### Example
204
221
 
@@ -215,46 +232,43 @@ const payload: GetRecommendedSizeByProductsParams = {
215
232
  ],
216
233
  };
217
234
 
218
- async function fetchRecommendedSizes() {
235
+ async function fetchSizes() {
219
236
  try {
220
- const response = await client.GetRecommendedSizeByProducts(payload);
221
- response.forEach((item) => {
222
- console.log(`Product ID: ${item.id}, Recommended Size: ${item.recommendedSize}`);
237
+ const recommendations = await client.getRecommendedSizeByProducts(payload);
238
+ recommendations.forEach(({ id, recommendedSize }) => {
239
+ console.log(`Product ${id}: ${recommendedSize}`);
223
240
  });
224
- } catch (error: any) {
225
- console.error('Error fetching recommended product sizes:', error.message);
241
+ } catch (err: any) {
242
+ console.error('Error:', err.message);
226
243
  }
227
244
  }
228
245
 
229
- fetchRecommendedSizes();
230
- ```
231
- ---
246
+ fetchSizes();
247
+ ```
232
248
 
233
249
  ---
234
250
 
235
251
  ### `getComplementaryProducts(params: GetComplementaryProductsParams): Promise<GetComplementaryProductsResponse>`
236
252
 
237
- Fetches complementary product recommendation pairs based on the given parameters.
253
+ Fetch complementary product pairs, optionally filtered by size.
238
254
 
239
255
  #### Parameters
240
256
 
241
- | Parameter | Type | Required | Description |
242
- |------------------|----------|:--------:|--------------------------------------------------------------------|
243
- | `tenantId` | `string` | **Yes** | The tenant ID that initiated the request. |
244
- | `collectionName` | `string` | **Yes** | The Qdrant collection name where embeddings are stored. |
245
- | `sessionId` | `string` | **Yes** | The session ID for internal event tracking. |
246
- | `permalink` | `string` | **Yes** | A permanent link representing the base product. |
247
-
248
-
249
- #### Returns
250
-
251
- **`Promise<GetComplementaryProductsResponse>`**
252
- An object containing:
253
-
254
- - `baseProduct`: The original product used as the seed for recommendations (`ProductResponseDto`).
255
- - `complementary`: An array of recommendation pairs (`ComplementaryPairDto[]`), each with:
256
- - `first`: The first complementary product.
257
- - `secondary`: The second complementary product.
257
+ | Parameter | Type | Required | Description |
258
+ | -------------------- | --------- | :------: | ---------------------------------------------------------------------------- |
259
+ | `tenantId` | `string` | **Yes** | Tenant ID initiating the request. |
260
+ | `collectionName` | `string` | **Yes** | Qdrant collection name for embeddings. |
261
+ | `sessionId` | `string` | **Yes** | Session ID for event tracking. |
262
+ | `permalink` | `string` | **Yes** | Permanent link (URL) of the base product. |
263
+ | `limit` | `number` | No | Maximum number of complementary pairs. |
264
+ | `filterByWhatFitsMe` | `boolean` | No | If `true`, apply “What Fits Me” size filter. Defaults to `false`. |
265
+ | `personaHash` | `string` | Cond.\* | Persona hash from Size & Fit; **required** when `filterByWhatFitsMe = true`. |
266
+
267
+ > **Returns:** `Promise<GetComplementaryProductsResponse>`
268
+ >
269
+ > * `baseProduct`: `ProductDto` — Seed product.
270
+ > * `complementary`: `ComplementaryPairDto[]` Array of pairs (`first` & `secondary`).
271
+ > * `suitableSizes?`: `SuitableSizeDto[]` Size recommendations when filtering by persona.
258
272
 
259
273
  #### Example
260
274
 
@@ -265,23 +279,64 @@ const params: GetComplementaryProductsParams = {
265
279
  tenantId: '123',
266
280
  collectionName: 'summer-collection',
267
281
  sessionId: 'abc-session-456',
268
- permalink: 'https://example.com/product/base-1'
282
+ permalink: 'https://example.com/product/base-1',
283
+ limit: 5,
284
+ filterByWhatFitsMe: true,
285
+ personaHash: '6b4f2e8b-0bb2-43d1-8bea-7f6d1c5d5a71',
269
286
  };
270
287
 
271
- async function fetchComplementaryPairs() {
288
+ async function fetchPairs() {
272
289
  try {
273
290
  const response = await client.getComplementaryProducts(params);
274
- console.log('Base product:', response.baseProduct);
291
+ console.log('Base:', response.baseProduct);
275
292
  response.complementary.forEach(({ first, secondary }) => {
276
- console.log(`Pair: ${first.title} ↔ ${secondary.title}`);
293
+ console.log(`${first.title} ↔ ${secondary.title}`);
277
294
  });
278
- } catch (error: any) {
279
- console.error('Error fetching complementary products:', error.message);
295
+ if (response.suitableSizes) {
296
+ console.log('Size recommendations:', response.suitableSizes);
297
+ }
298
+ } catch (err: any) {
299
+ console.error('Error:', err.message);
280
300
  }
281
301
  }
282
302
 
283
- fetchComplementaryPairs();
303
+ fetchPairs();
284
304
  ```
305
+
306
+ ---
307
+
308
+ ## DTO Definitions
309
+
310
+ ### `Product` / `ProductDto`
311
+
312
+ | Field | Type | Description |
313
+ | ---------------------- | ------------------- | ------------------------------------------- |
314
+ | `id` | `string` | Unique product identifier. |
315
+ | `title` | `string` | Product title. |
316
+ | `productType` | `string` | Product category/type. |
317
+ | `link` | `string` | Product page URL. |
318
+ | `imageLink` | `string` | Main image URL. |
319
+ | `gender` | `string` | Gender segment (`"male"`, `"female"`, etc). |
320
+ | `availability` | `string` | Stock status (e.g., `"in stock"`). |
321
+ | `productHash` | `string` | Hash for deduplication. |
322
+ | `price` | `string` | Formatted price (e.g., `"29.99 USD"`). |
323
+ | `salePrice?` | `string` | Promotional price, if applicable. |
324
+ | `itemGroupId` | `string` | Variant group ID. |
325
+ | `brand` | `string` | Brand name. |
326
+ | `color` | `string` | Color description. |
327
+ | `gtin` | `string` | Global Trade Item Number. |
328
+ | `additionalImageLinks` | `string[]` | Other image URLs. |
329
+ | `suitableSizes?` | `SuitableSizeDto[]` | Size recommendations (when filtering). |
330
+
331
+
332
+ ### `SuitableSizeDto`
333
+
334
+ | Field | Type | Description |
335
+ | ------------- | --------- | ----------------------------------------------------------------------- |
336
+ | `size` | `string` | The recommended size label (e.g., `"S"`, `"M"`, `"L"`). |
337
+ | `comfortable` | `number` | A comfort score (0–1) indicating how well this size fits the persona. |
338
+ | `value?` | `number` | Optional secondary metric (e.g., normalized preference or confidence). |
339
+
285
340
  ---
286
341
 
287
342
  ## Session Module
@@ -5,8 +5,25 @@ export interface GetSimilarProductsParams {
5
5
  permalink: string;
6
6
  page?: number;
7
7
  perPage?: number;
8
+ filterByWhatFitsMe?: boolean;
9
+ personaHash?: string;
8
10
  }
9
- export interface Product {
11
+ export interface GetComplementaryProductsParams {
12
+ tenantId: string;
13
+ collectionName: string;
14
+ sessionId: string;
15
+ permalink: string;
16
+ limit?: number;
17
+ filterByWhatFitsMe?: boolean;
18
+ personaHash?: string;
19
+ }
20
+ export interface GetRecommendedSizeByProductsParams {
21
+ tenantId: number;
22
+ sid?: string;
23
+ sizeSystem: string;
24
+ permalinks: string[];
25
+ }
26
+ export interface ProductDto {
10
27
  id: string;
11
28
  title: string;
12
29
  productType: string;
@@ -22,52 +39,28 @@ export interface Product {
22
39
  color: string;
23
40
  gtin: string;
24
41
  additionalImageLinks: string[];
42
+ suitableSizes?: Array<{
43
+ size: string;
44
+ comfortable: number;
45
+ value?: number;
46
+ }>;
25
47
  }
26
48
  export interface GetSimilarProductsResponse {
27
- data: Product[];
49
+ data: ProductDto[];
28
50
  page: number;
29
51
  perPage: number;
30
52
  total: number;
31
53
  }
32
- export interface GetRecommendedSizeByProductsParams {
33
- tenantId: number;
34
- sid?: string;
35
- sizeSystem: string;
36
- permalinks: string[];
37
- }
38
54
  export interface GetRecommendedSizeByProductsResponse {
39
55
  id: string;
40
56
  permalink: string;
41
57
  recommendedSize: string | null;
42
58
  }
43
- export interface ProductComplementaryResponseDto {
44
- id: string;
45
- tenantId: number;
46
- title: string;
47
- productType: string;
48
- link: string;
49
- imageLink: string;
50
- gender: string;
51
- availability: string;
52
- productHash: string;
53
- price: string;
54
- itemGroupId: string;
55
- brand: string;
56
- color: string;
57
- gtin: string;
58
- additionalImageLinks: string[];
59
- }
60
- export interface GetComplementaryProductsParams {
61
- tenantId: string;
62
- collectionName: string;
63
- sessionId: string;
64
- permalink: string;
65
- }
66
59
  export interface ComplementaryPairDto {
67
- first: ProductComplementaryResponseDto;
68
- secondary: ProductComplementaryResponseDto;
60
+ first: ProductDto;
61
+ secondary: ProductDto;
69
62
  }
70
63
  export interface GetComplementaryProductsResponse {
71
- baseProduct: ProductComplementaryResponseDto;
64
+ baseProduct: ProductDto;
72
65
  complementary: ComplementaryPairDto[];
73
66
  }
@@ -4,9 +4,9 @@ export type JSONValue = string | number | boolean | null | JSONValue[] | {
4
4
  export interface TrackData {
5
5
  sid: string;
6
6
  tenantId: number;
7
- sessionId: number;
8
- permalink?: string;
9
7
  properties: Record<string, JSONValue>;
8
+ sessionId?: number;
9
+ permalink?: string;
10
10
  }
11
11
  export interface DataEventPayload extends TrackData {
12
12
  eventName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.3.0-dev.1",
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",