sizebay-core-sdk 1.11.0-dev.5 → 1.12.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.
@@ -2,9 +2,11 @@ import { SDKConfigOptions } from '../types';
2
2
  export declare class Config {
3
3
  private endpoints;
4
4
  private serviceOverrides;
5
+ private fashionLooksToken?;
5
6
  constructor(options: SDKConfigOptions);
6
7
  getEndpoint(serviceName: string): string;
7
8
  getServiceConfig(serviceName: string): {
8
9
  [key: string]: any;
9
10
  };
11
+ getFashionLooksToken(): string | undefined;
10
12
  }
@@ -0,0 +1,5 @@
1
+ export interface AuthHeaders {
2
+ Authorization?: string;
3
+ 'x-credit-api-key'?: string;
4
+ }
5
+ export declare function buildAuthHeaders(token?: string, apiKey?: string): AuthHeaders;
@@ -0,0 +1,9 @@
1
+ import { Config } from '../../config';
2
+ import { GenerateTokenDto, TokenResponseDto, ValidateTokenResponseDto } from '../../types/fashion-looks';
3
+ export declare class FashionLooksAuth {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ generateToken(payload: GenerateTokenDto): Promise<TokenResponseDto>;
8
+ validateToken(token?: string): Promise<ValidateTokenResponseDto>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { Config } from '../../config';
2
+ import { CreateGroupedLookFeedbackDto, GroupedLookFeedbackResponseDto } from '../../types/fashion-looks';
3
+ export declare class FashionLooksGroupedLooksFeedback {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ createFeedback(payload: CreateGroupedLookFeedbackDto): Promise<GroupedLookFeedbackResponseDto>;
8
+ }
@@ -0,0 +1,15 @@
1
+ import { Config } from '../../config';
2
+ import { GroupedLookResponseDto, UpdateGroupedLookDto, GetGroupedLooksParams, GetGroupedLooksResponse } from '../../types/fashion-looks';
3
+ export declare class FashionLooksGroupedLooks {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ private appendQueryParams;
8
+ getGroupedLooks(params?: GetGroupedLooksParams): Promise<GetGroupedLooksResponse>;
9
+ getGroupedLookById(id: string): Promise<GroupedLookResponseDto>;
10
+ updateGroupedLook(id: string, payload: UpdateGroupedLookDto): Promise<GroupedLookResponseDto>;
11
+ getPublicGroupedLooks(params: GetGroupedLooksParams & {
12
+ tenantId: number;
13
+ }): Promise<GetGroupedLooksResponse>;
14
+ getPublicGroupedLookById(id: string, tenantId: number): Promise<GroupedLookResponseDto>;
15
+ }
@@ -0,0 +1,6 @@
1
+ export { FashionLooksAuth } from './auth';
2
+ export { FashionLooksWallet } from './wallet';
3
+ export { FashionLooksPlans } from './plans';
4
+ export { FashionLooksTryon } from './tryon';
5
+ export { FashionLooksGroupedLooks } from './grouped-looks';
6
+ export { FashionLooksGroupedLooksFeedback } from './grouped-looks-feedback';
@@ -0,0 +1,10 @@
1
+ import { Config } from '../../config';
2
+ import { Plan } from '../../types/fashion-looks';
3
+ export declare class FashionLooksPlans {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ getAllPlans(): Promise<Plan[]>;
8
+ getPlanById(planId: string): Promise<Plan>;
9
+ getTenantActivePlan(tenantId: number): Promise<Plan>;
10
+ }
@@ -0,0 +1,14 @@
1
+ import { Config } from '../../config';
2
+ import { GenerateTryonDto, TryonTaskResponseDto, TryonDetails, FindProductByTenantDto, ProductItemResponseDto } from '../../types/fashion-looks';
3
+ export declare class FashionLooksTryon {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ generateTryon(payload: GenerateTryonDto): Promise<TryonTaskResponseDto>;
8
+ getTryonById(id: string): Promise<TryonDetails>;
9
+ getTryonHistory(params?: {
10
+ limit?: number;
11
+ offset?: number;
12
+ }): Promise<TryonDetails[]>;
13
+ findProductsByTenant(payload: FindProductByTenantDto): Promise<ProductItemResponseDto>;
14
+ }
@@ -0,0 +1,12 @@
1
+ import { Config } from '../../config';
2
+ import { WalletBalanceDto, TransactionHistoryResponse } from '../../types/fashion-looks';
3
+ export declare class FashionLooksWallet {
4
+ private endpoint;
5
+ private config;
6
+ constructor(config: Config);
7
+ getBalance(): Promise<WalletBalanceDto>;
8
+ getTransactionHistory(params?: {
9
+ limit?: number;
10
+ offset?: number;
11
+ }): Promise<TransactionHistoryResponse>;
12
+ }
@@ -1,4 +1,10 @@
1
1
  import { Tracker } from './tracker';
2
2
  import { AIImageService } from './ai-image-service';
3
3
  import { SessionManager } from './sessions';
4
- export declare const moduleClasses: (typeof Tracker | typeof AIImageService | typeof SessionManager)[];
4
+ import { FashionLooksAuth } from './fashion-looks/auth';
5
+ import { FashionLooksWallet } from './fashion-looks/wallet';
6
+ import { FashionLooksPlans } from './fashion-looks/plans';
7
+ import { FashionLooksTryon } from './fashion-looks/tryon';
8
+ import { FashionLooksGroupedLooks } from './fashion-looks/grouped-looks';
9
+ import { FashionLooksGroupedLooksFeedback } from './fashion-looks/grouped-looks-feedback';
10
+ export declare const moduleClasses: (typeof Tracker | typeof AIImageService | typeof SessionManager | typeof FashionLooksAuth | typeof FashionLooksWallet | typeof FashionLooksPlans | typeof FashionLooksTryon | typeof FashionLooksGroupedLooks | typeof FashionLooksGroupedLooksFeedback)[];
@@ -1,4 +1,4 @@
1
- const p = {
1
+ const d = {
2
2
  tracker: {
3
3
  production: "https://data-event-service.internalsizebay.com",
4
4
  development: "https://data-event-service-dev.internalsizebay.com"
@@ -10,90 +10,100 @@ const p = {
10
10
  session: {
11
11
  production: "https://vfr-v3-production.sizebay.technology/api/me",
12
12
  development: "https://vfr-v3-staging.sizebay.eu/api/me"
13
+ },
14
+ fashionLooks: {
15
+ production: "https://fashion-looks-api.internalsizebay.com",
16
+ development: "https://fashion-looks-dev.internalsizebay.com"
13
17
  }
14
18
  // Adicione outros serviços conforme necessário
15
19
  };
16
- class l {
20
+ class u {
17
21
  constructor(t) {
18
- const e = t.env || "development";
19
- this.serviceOverrides = t.services || {}, this.endpoints = {};
20
- for (const s in p)
21
- if (Object.prototype.hasOwnProperty.call(p, s)) {
22
- const i = p[s][e];
23
- if (!i)
22
+ const o = t.env || "development";
23
+ this.serviceOverrides = t.services || {}, this.fashionLooksToken = t.fashionLooksToken, this.endpoints = {};
24
+ for (const n in d)
25
+ if (Object.prototype.hasOwnProperty.call(d, n)) {
26
+ const r = d[n][o];
27
+ if (!r)
24
28
  continue;
25
- this.endpoints[s] = i;
29
+ this.endpoints[n] = r;
26
30
  }
27
31
  }
28
32
  getEndpoint(t) {
29
- const e = this.endpoints[t];
30
- if (!e)
33
+ const o = this.endpoints[t];
34
+ if (!o)
31
35
  throw new Error(
32
36
  `Endpoint for service '${t}' is not configured.`
33
37
  );
34
- return e;
38
+ return o;
35
39
  }
36
40
  getServiceConfig(t) {
37
41
  return this.serviceOverrides[t] || {};
38
42
  }
43
+ /**
44
+ * Get JWT token for Fashion Looks API authentication
45
+ */
46
+ getFashionLooksToken() {
47
+ return this.fashionLooksToken;
48
+ }
39
49
  }
40
- class S {
50
+ class T {
41
51
  constructor(t) {
42
52
  this.endpoint = t.getEndpoint("tracker");
43
53
  }
44
- async track(t, e) {
45
- const s = {
54
+ async track(t, o) {
55
+ const n = {
46
56
  eventName: t,
47
- ...e
48
- }, n = new URL(`${this.endpoint}/events`);
57
+ ...o
58
+ }, e = new URL(`${this.endpoint}/events`);
49
59
  try {
50
- const i = await fetch(n, {
60
+ const r = await fetch(e, {
51
61
  method: "POST",
52
62
  headers: { "Content-Type": "application/json" },
53
- body: JSON.stringify(s)
63
+ body: JSON.stringify(n)
54
64
  });
55
- if (!i.ok) {
56
- const o = await i.text();
57
- throw new Error(`Request error: ${i.status} - ${o}`);
65
+ if (!r.ok) {
66
+ const c = await r.text();
67
+ throw new Error(`Request error: ${r.status} - ${c}`);
58
68
  }
59
69
  try {
60
- return await i.json();
70
+ return await r.json();
61
71
  } catch {
62
72
  return {
63
73
  statusCode: 201,
64
74
  message: "Event successfully created."
65
75
  };
66
76
  }
67
- } catch (i) {
68
- throw i;
77
+ } catch (r) {
78
+ throw r;
69
79
  }
70
80
  }
71
81
  }
72
- class c extends Error {
73
- constructor(t, e) {
74
- let s;
82
+ class h extends Error {
83
+ constructor(t, o) {
84
+ let n;
75
85
  try {
76
- const n = JSON.parse(e);
77
- s = (n == null ? void 0 : n.message) || e;
86
+ const e = JSON.parse(o);
87
+ n = (e == null ? void 0 : e.message) || o;
78
88
  } catch {
79
- s = e;
89
+ n = o;
80
90
  }
81
- super(s), this.statusCode = t, this.details = e, Object.setPrototypeOf(this, c.prototype);
91
+ super(n), this.statusCode = t, this.details = o, Object.setPrototypeOf(this, h.prototype);
82
92
  }
83
93
  }
84
- async function a(r, t) {
85
- let e;
94
+ async function s(i, t) {
95
+ let o;
86
96
  try {
87
- e = await fetch(r, t);
88
- } catch (n) {
89
- throw new c(0, n.message);
90
- }
91
- const s = await e.text();
92
- if (!e.ok)
93
- throw new c(e.status, s);
94
- return JSON.parse(s);
97
+ o = await fetch(i, t);
98
+ } catch (e) {
99
+ throw new h(0, e.message);
100
+ }
101
+ const n = await o.text();
102
+ if (!o.ok)
103
+ throw new h(o.status, n);
104
+ return JSON.parse(n);
95
105
  }
96
- class T {
106
+ class f {
97
107
  constructor(t) {
98
108
  this.endpoint = t.getEndpoint("aiImageService");
99
109
  }
@@ -102,9 +112,9 @@ class T {
102
112
  * @param url - The URL object to modify.
103
113
  * @param params - A record of key/value pairs to serialize.
104
114
  */
105
- appendQueryParams(t, e) {
106
- Object.entries(e).forEach(([s, n]) => {
107
- n != null && t.searchParams.append(s, String(n));
115
+ appendQueryParams(t, o) {
116
+ Object.entries(o).forEach(([n, e]) => {
117
+ e != null && t.searchParams.append(n, String(e));
108
118
  });
109
119
  }
110
120
  /**
@@ -118,8 +128,8 @@ class T {
118
128
  * @throws {ApiError} if the HTTP status is not 2xx or on network failure
119
129
  */
120
130
  getSimilarProducts(t) {
121
- const e = new URL(`${this.endpoint}/recommendations/similar`);
122
- return this.appendQueryParams(e, t), a(e.toString(), {
131
+ const o = new URL(`${this.endpoint}/recommendations/similar`);
132
+ return this.appendQueryParams(o, t), s(o.toString(), {
123
133
  method: "GET",
124
134
  headers: { "Content-Type": "application/json" }
125
135
  });
@@ -135,8 +145,8 @@ class T {
135
145
  * @throws {ApiError} if the HTTP status is not 2xx or on network failure
136
146
  */
137
147
  getComplementaryProducts(t) {
138
- const e = new URL(`${this.endpoint}/recommendations/complementary`);
139
- return this.appendQueryParams(e, t), a(e.toString(), {
148
+ const o = new URL(`${this.endpoint}/recommendations/complementary`);
149
+ return this.appendQueryParams(o, t), s(o.toString(), {
140
150
  method: "GET",
141
151
  headers: { "Content-Type": "application/json" }
142
152
  });
@@ -151,8 +161,8 @@ class T {
151
161
  * @throws {ApiError} if the HTTP status is not 2xx or on network failure
152
162
  */
153
163
  searchSimilarByImage(t) {
154
- const e = `${this.endpoint}/image-search/similar`;
155
- return a(e, {
164
+ const o = `${this.endpoint}/image-search/similar`;
165
+ return s(o, {
156
166
  method: "POST",
157
167
  headers: { "Content-Type": "application/json" },
158
168
  body: JSON.stringify(t)
@@ -168,8 +178,8 @@ class T {
168
178
  * @throws {ApiError} if the HTTP status is not 2xx or on network failure
169
179
  */
170
180
  searchComplementaryByImage(t) {
171
- const e = `${this.endpoint}/image-search/complementary`;
172
- return a(e, {
181
+ const o = `${this.endpoint}/image-search/complementary`;
182
+ return s(o, {
173
183
  method: "POST",
174
184
  headers: { "Content-Type": "application/json" },
175
185
  body: JSON.stringify(t)
@@ -235,8 +245,8 @@ class T {
235
245
  * ```
236
246
  */
237
247
  searchSimilarByPermalink(t) {
238
- const e = `${this.endpoint}/image-search/similar-by-permalink`;
239
- return a(e, {
248
+ const o = `${this.endpoint}/image-search/similar-by-permalink`;
249
+ return s(o, {
240
250
  method: "POST",
241
251
  headers: { "Content-Type": "application/json" },
242
252
  body: JSON.stringify(t)
@@ -309,19 +319,19 @@ class T {
309
319
  * ```
310
320
  */
311
321
  searchComplementaryByPermalink(t) {
312
- const e = `${this.endpoint}/image-search/complementary-by-permalink`;
313
- return a(e, {
322
+ const o = `${this.endpoint}/image-search/complementary-by-permalink`;
323
+ return s(o, {
314
324
  method: "POST",
315
325
  headers: { "Content-Type": "application/json" },
316
326
  body: JSON.stringify(t)
317
327
  });
318
328
  }
319
329
  }
320
- class u {
330
+ class k {
321
331
  constructor(t) {
322
332
  this.sid = null, this.sessionId = null;
323
- const e = t.getEndpoint("session");
324
- this.sessionEndpoint = `${e}/`, this.profileEndpoint = `${e}/user/profile`;
333
+ const o = t.getEndpoint("session");
334
+ this.sessionEndpoint = `${o}/`, this.profileEndpoint = `${o}/user/profile`;
325
335
  }
326
336
  /**
327
337
  * Retrieves (or reuses) the session context, containing:
@@ -340,13 +350,13 @@ class u {
340
350
  credentials: "include"
341
351
  });
342
352
  if (!t.ok) {
343
- const s = await t.text();
353
+ const n = await t.text();
344
354
  throw new Error(
345
- `Failed to fetch session info: ${t.status} – ${s}`
355
+ `Failed to fetch session info: ${t.status} – ${n}`
346
356
  );
347
357
  }
348
- const e = await t.json();
349
- return this.sid = e.catalogUser.id, this.sessionId = e.sessionId, { sid: this.sid, sessionId: this.sessionId };
358
+ const o = await t.json();
359
+ return this.sid = o.catalogUser.id, this.sessionId = o.sessionId, { sid: this.sid, sessionId: this.sessionId };
350
360
  }
351
361
  /**
352
362
  * Sends the session profile payload to the server.
@@ -356,42 +366,515 @@ class u {
356
366
  * otherwise it will be retrieved via getSessionInfo()
357
367
  * @throws {Error} If the HTTP request fails
358
368
  */
359
- async sendProfile(t, e) {
360
- const s = e ?? (await this.getSessionInfo()).sid, n = new URL(this.profileEndpoint);
361
- n.searchParams.set("sid", s);
362
- const i = await fetch(n.toString(), {
369
+ async sendProfile(t, o) {
370
+ const n = o ?? (await this.getSessionInfo()).sid, e = new URL(this.profileEndpoint);
371
+ e.searchParams.set("sid", n);
372
+ const r = await fetch(e.toString(), {
363
373
  credentials: "include",
364
374
  method: "POST",
365
375
  headers: { "Content-Type": "application/json" },
366
- body: JSON.stringify({ userId: s, id: null, ...t })
376
+ body: JSON.stringify({ userId: n, id: null, ...t })
367
377
  });
368
- if (!i.ok) {
369
- const o = await i.text();
378
+ if (!r.ok) {
379
+ const c = await r.text();
370
380
  throw new Error(
371
- `Failed to send profile: ${i.status} – ${o}`
381
+ `Failed to send profile: ${r.status} – ${c}`
372
382
  );
373
383
  }
374
384
  }
375
385
  }
376
- const O = [
377
- S,
386
+ function a(i, t) {
387
+ const o = {};
388
+ return i && (o.Authorization = `Bearer ${i}`), o;
389
+ }
390
+ class g {
391
+ constructor(t) {
392
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
393
+ }
394
+ /**
395
+ * Generate JWT token (Temporary endpoint)
396
+ *
397
+ * This endpoint will be removed in the future. Used for testing purposes.
398
+ * Sends a POST to `/api/auth/generate-token` with the tenant ID.
399
+ *
400
+ * @param payload - Request payload containing the tenant ID
401
+ * @returns Promise resolving to the token response with access token and expiration
402
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
403
+ */
404
+ async generateToken(t) {
405
+ const o = `${this.endpoint}/api/auth/generate-token`;
406
+ return s(o, {
407
+ method: "POST",
408
+ headers: { "Content-Type": "application/json" },
409
+ body: JSON.stringify(t)
410
+ });
411
+ }
412
+ /**
413
+ * Validate current JWT token
414
+ *
415
+ * Returns token information if valid.
416
+ * Can validate a specific token or use the token from config.
417
+ * Sends a GET to `/api/auth/validate` with the JWT token in the Authorization header.
418
+ *
419
+ * @param token - Optional JWT token to validate (uses config token if not provided)
420
+ * @returns Promise resolving to token validation information
421
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
422
+ * @throws {Error} if no token is provided and config token is not set
423
+ */
424
+ async validateToken(t) {
425
+ const o = t || this.config.getFashionLooksToken();
426
+ if (!o)
427
+ throw new Error(
428
+ "Token is required. Provide it as parameter or set it in SDK config (fashionLooksToken)."
429
+ );
430
+ const n = `${this.endpoint}/api/auth/validate`, e = {
431
+ "Content-Type": "application/json",
432
+ ...a(o)
433
+ };
434
+ return s(n, {
435
+ method: "GET",
436
+ headers: e
437
+ });
438
+ }
439
+ }
440
+ class y {
441
+ constructor(t) {
442
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
443
+ }
444
+ /**
445
+ * Get wallet balance for tenant
446
+ *
447
+ * Retrieves the current wallet balance and last transaction information for the authenticated tenant.
448
+ * Uses the Fashion Looks token from SDK config.
449
+ * Sends a GET to `/api/wallet/balance` with JWT authentication.
450
+ *
451
+ * @returns Promise resolving to wallet balance information
452
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
453
+ * @throws {Error} if Fashion Looks token is not set in SDK config
454
+ */
455
+ async getBalance() {
456
+ const t = this.config.getFashionLooksToken();
457
+ if (!t)
458
+ throw new Error(
459
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
460
+ );
461
+ const o = `${this.endpoint}/api/wallet/balance`, n = {
462
+ "Content-Type": "application/json",
463
+ ...a(t)
464
+ };
465
+ return s(o, {
466
+ method: "GET",
467
+ headers: n
468
+ });
469
+ }
470
+ /**
471
+ * Get wallet transaction history
472
+ *
473
+ * Retrieves the transaction history for the authenticated tenant with optional pagination.
474
+ * Uses the Fashion Looks token from SDK config.
475
+ * Sends a GET to `/api/wallet/history` with JWT authentication and query parameters.
476
+ *
477
+ * @param params - Optional pagination parameters
478
+ * @param params.limit - Maximum number of transactions to return
479
+ * @param params.offset - Number of transactions to skip
480
+ * @returns Promise resolving to array of transaction history items
481
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
482
+ * @throws {Error} if Fashion Looks token is not set in SDK config
483
+ */
484
+ async getTransactionHistory(t) {
485
+ const o = this.config.getFashionLooksToken();
486
+ if (!o)
487
+ throw new Error(
488
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
489
+ );
490
+ const n = new URL(`${this.endpoint}/api/wallet/history`);
491
+ t != null && t.limit && n.searchParams.append("limit", t.limit.toString()), t != null && t.offset && n.searchParams.append("offset", t.offset.toString());
492
+ const e = {
493
+ "Content-Type": "application/json",
494
+ ...a(o)
495
+ };
496
+ return s(n.toString(), {
497
+ method: "GET",
498
+ headers: e
499
+ });
500
+ }
501
+ }
502
+ class S {
503
+ constructor(t) {
504
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
505
+ }
506
+ /**
507
+ * Get all available plans
508
+ *
509
+ * Retrieves a list of all available subscription plans.
510
+ * Sends a GET to `/api/plans`.
511
+ *
512
+ * @returns Promise resolving to array of available plans
513
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
514
+ */
515
+ async getAllPlans() {
516
+ const t = `${this.endpoint}/api/plans`;
517
+ return s(t, {
518
+ method: "GET",
519
+ headers: { "Content-Type": "application/json" }
520
+ });
521
+ }
522
+ /**
523
+ * Get plan by ID
524
+ *
525
+ * Retrieves detailed information about a specific plan by its ID.
526
+ * Sends a GET to `/api/plans/{planId}`.
527
+ *
528
+ * @param planId - Unique identifier of the plan
529
+ * @returns Promise resolving to plan details
530
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
531
+ */
532
+ async getPlanById(t) {
533
+ const o = `${this.endpoint}/api/plans/${t}`;
534
+ return s(o, {
535
+ method: "GET",
536
+ headers: { "Content-Type": "application/json" }
537
+ });
538
+ }
539
+ /**
540
+ * Get active plan for tenant
541
+ *
542
+ * Retrieves the currently active plan for a specific tenant.
543
+ * Sends a GET to `/api/plans/tenants/{tenantId}/active`.
544
+ *
545
+ * @param tenantId - ID of the tenant
546
+ * @returns Promise resolving to active plan details
547
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
548
+ */
549
+ async getTenantActivePlan(t) {
550
+ const o = `${this.endpoint}/api/plans/tenants/${t}/active`;
551
+ return s(o, {
552
+ method: "GET",
553
+ headers: { "Content-Type": "application/json" }
554
+ });
555
+ }
556
+ }
557
+ class E {
558
+ constructor(t) {
559
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
560
+ }
561
+ /**
562
+ * Generate a new try-on
563
+ *
564
+ * Creates an async processing task that generates virtual try-on images.
565
+ * The task is processed asynchronously and returns a task ID for tracking.
566
+ * Uses the Fashion Looks token from SDK config.
567
+ * Sends a POST to `/api/tryons/generate` with JWT authentication.
568
+ *
569
+ * @param payload - Request payload containing tenant ID, avatar details, and garments
570
+ * @returns Promise resolving to task response with task ID and status
571
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
572
+ * @throws {ApiError} with status 402 if insufficient credits
573
+ * @throws {ApiError} with status 404 if product not found
574
+ * @throws {ApiError} with status 503 if AI service unavailable
575
+ * @throws {Error} if Fashion Looks token is not set in SDK config
576
+ */
577
+ async generateTryon(t) {
578
+ const o = this.config.getFashionLooksToken();
579
+ if (!o)
580
+ throw new Error(
581
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
582
+ );
583
+ const n = `${this.endpoint}/api/tryons/generate`, e = {
584
+ "Content-Type": "application/json",
585
+ ...a(o)
586
+ };
587
+ return s(n, {
588
+ method: "POST",
589
+ headers: e,
590
+ body: JSON.stringify(t)
591
+ });
592
+ }
593
+ /**
594
+ * Get try-on by ID
595
+ *
596
+ * Retrieves detailed information about a specific try-on by its ID.
597
+ * Uses the Fashion Looks token from SDK config.
598
+ * Sends a GET to `/api/tryons/{id}` with JWT authentication.
599
+ *
600
+ * @param id - Try-on ID to retrieve
601
+ * @returns Promise resolving to try-on details
602
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
603
+ * @throws {Error} if Fashion Looks token is not set in SDK config
604
+ */
605
+ async getTryonById(t) {
606
+ const o = this.config.getFashionLooksToken();
607
+ if (!o)
608
+ throw new Error(
609
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
610
+ );
611
+ const n = `${this.endpoint}/api/tryons/${t}`, e = {
612
+ "Content-Type": "application/json",
613
+ ...a(o)
614
+ };
615
+ return s(n, {
616
+ method: "GET",
617
+ headers: e
618
+ });
619
+ }
620
+ /**
621
+ * Get try-on history for tenant
622
+ *
623
+ * Retrieves the try-on history for the authenticated tenant with optional pagination.
624
+ * Uses the Fashion Looks token from SDK config.
625
+ * Sends a GET to `/api/tryons` with JWT authentication and query parameters.
626
+ *
627
+ * @param params - Optional pagination parameters
628
+ * @param params.limit - Maximum number of try-ons to return
629
+ * @param params.offset - Number of try-ons to skip
630
+ * @returns Promise resolving to array of try-on details
631
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
632
+ * @throws {Error} if Fashion Looks token is not set in SDK config
633
+ */
634
+ async getTryonHistory(t) {
635
+ const o = this.config.getFashionLooksToken();
636
+ if (!o)
637
+ throw new Error(
638
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
639
+ );
640
+ const n = new URL(`${this.endpoint}/api/tryons`);
641
+ t != null && t.limit && n.searchParams.append("limit", t.limit.toString()), t != null && t.offset && n.searchParams.append("offset", t.offset.toString());
642
+ const e = {
643
+ "Content-Type": "application/json",
644
+ ...a(o)
645
+ };
646
+ return s(n.toString(), {
647
+ method: "GET",
648
+ headers: e
649
+ });
650
+ }
651
+ /**
652
+ * Find product by tenantId, catalogClothType and productId
653
+ *
654
+ * Searches for a specific product in the tenant's catalog by cloth type and product ID.
655
+ * Uses the Fashion Looks token from SDK config.
656
+ * Sends a POST to `/api/tryons/find-products` with JWT authentication.
657
+ *
658
+ * @param payload - Request payload containing catalog cloth type and product ID
659
+ * @returns Promise resolving to product item information
660
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
661
+ * @throws {ApiError} with status 404 if product not found
662
+ * @throws {Error} if Fashion Looks token is not set in SDK config
663
+ */
664
+ async findProductsByTenant(t) {
665
+ const o = this.config.getFashionLooksToken();
666
+ if (!o)
667
+ throw new Error(
668
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
669
+ );
670
+ const n = `${this.endpoint}/api/tryons/find-products`, e = {
671
+ "Content-Type": "application/json",
672
+ ...a(o)
673
+ };
674
+ return s(n, {
675
+ method: "POST",
676
+ headers: e,
677
+ body: JSON.stringify(t)
678
+ });
679
+ }
680
+ }
681
+ class L {
682
+ constructor(t) {
683
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
684
+ }
685
+ appendQueryParams(t, o) {
686
+ Object.entries(o).forEach(([n, e]) => {
687
+ e != null && t.searchParams.append(n, String(e));
688
+ });
689
+ }
690
+ /**
691
+ * Get grouped looks with optional filters and pagination
692
+ *
693
+ * Retrieves a paginated list of grouped looks with optional filters for gender, age group, style, collection, status, and product permalink.
694
+ * Uses the Fashion Looks token from SDK config.
695
+ * Sends a GET to `/api/grouped-looks` with JWT authentication and query parameters.
696
+ *
697
+ * @param params - Optional query parameters for filtering and pagination
698
+ * @returns Promise resolving to paginated grouped looks response
699
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
700
+ * @throws {Error} if Fashion Looks token is not set in SDK config
701
+ */
702
+ async getGroupedLooks(t) {
703
+ const o = this.config.getFashionLooksToken();
704
+ if (!o)
705
+ throw new Error(
706
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
707
+ );
708
+ const n = new URL(`${this.endpoint}/api/grouped-looks`);
709
+ t && Object.keys(t).length > 0 && this.appendQueryParams(n, t);
710
+ const e = {
711
+ "Content-Type": "application/json",
712
+ ...a(o)
713
+ };
714
+ return s(n.toString(), {
715
+ method: "GET",
716
+ headers: e
717
+ });
718
+ }
719
+ /**
720
+ * Get a specific grouped look by ID
721
+ *
722
+ * Retrieves detailed information about a specific grouped look including all associated try-ons.
723
+ * Uses the Fashion Looks token from SDK config.
724
+ * Sends a GET to `/api/grouped-looks/{id}` with JWT authentication.
725
+ *
726
+ * @param id - Grouped look UUID
727
+ * @returns Promise resolving to grouped look details
728
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
729
+ * @throws {ApiError} with status 404 if grouped look not found
730
+ * @throws {Error} if Fashion Looks token is not set in SDK config
731
+ */
732
+ async getGroupedLookById(t) {
733
+ const o = this.config.getFashionLooksToken();
734
+ if (!o)
735
+ throw new Error(
736
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
737
+ );
738
+ const n = `${this.endpoint}/api/grouped-looks/${t}`, e = {
739
+ "Content-Type": "application/json",
740
+ ...a(o)
741
+ };
742
+ return s(n, {
743
+ method: "GET",
744
+ headers: e
745
+ });
746
+ }
747
+ /**
748
+ * Update a grouped look (rate and/or status)
749
+ *
750
+ * Updates the rating and/or status of a grouped look.
751
+ * Uses the Fashion Looks token from SDK config.
752
+ * Sends a PATCH to `/api/grouped-looks/{id}` with JWT authentication.
753
+ *
754
+ * @param id - Grouped look UUID
755
+ * @param payload - Request payload containing rate and/or status to update
756
+ * @returns Promise resolving to updated grouped look details
757
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
758
+ * @throws {ApiError} with status 400 if invalid input data
759
+ * @throws {ApiError} with status 404 if grouped look not found
760
+ * @throws {Error} if Fashion Looks token is not set in SDK config
761
+ */
762
+ async updateGroupedLook(t, o) {
763
+ const n = this.config.getFashionLooksToken();
764
+ if (!n)
765
+ throw new Error(
766
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
767
+ );
768
+ const e = `${this.endpoint}/api/grouped-looks/${t}`, r = {
769
+ "Content-Type": "application/json",
770
+ ...a(n)
771
+ };
772
+ return s(e, {
773
+ method: "PATCH",
774
+ headers: r,
775
+ body: JSON.stringify(o)
776
+ });
777
+ }
778
+ /**
779
+ * Get grouped looks with optional filters and pagination (Public endpoint)
780
+ *
781
+ * Retrieves a paginated list of grouped looks for a specific tenant without requiring authentication.
782
+ * Supports the same filters as the authenticated endpoint.
783
+ * Sends a GET to `/api/public/grouped-looks` with query parameters.
784
+ *
785
+ * @param params - Query parameters including required tenantId and optional filters
786
+ * @param params.tenantId - Required tenant ID
787
+ * @returns Promise resolving to paginated grouped looks response
788
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
789
+ */
790
+ async getPublicGroupedLooks(t) {
791
+ const o = new URL(`${this.endpoint}/api/public/grouped-looks`);
792
+ return this.appendQueryParams(o, t), s(o.toString(), {
793
+ method: "GET",
794
+ headers: { "Content-Type": "application/json" }
795
+ });
796
+ }
797
+ /**
798
+ * Get a specific grouped look by ID (Public endpoint)
799
+ *
800
+ * Retrieves detailed information about a specific grouped look without requiring authentication.
801
+ * Sends a GET to `/api/public/grouped-looks/{id}` with tenantId query parameter.
802
+ *
803
+ * @param id - Grouped look UUID
804
+ * @param tenantId - Tenant ID
805
+ * @returns Promise resolving to grouped look details
806
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
807
+ * @throws {ApiError} with status 404 if grouped look not found
808
+ */
809
+ async getPublicGroupedLookById(t, o) {
810
+ const n = new URL(`${this.endpoint}/api/public/grouped-looks/${t}`);
811
+ return n.searchParams.append("tenantId", o.toString()), s(n.toString(), {
812
+ method: "GET",
813
+ headers: { "Content-Type": "application/json" }
814
+ });
815
+ }
816
+ }
817
+ class O {
818
+ constructor(t) {
819
+ this.endpoint = t.getEndpoint("fashionLooks"), this.config = t;
820
+ }
821
+ /**
822
+ * Create feedback for a grouped look
823
+ *
824
+ * Submit feedback for a specific grouped look. Only one feedback per grouped look is allowed.
825
+ * Uses the Fashion Looks token from SDK config.
826
+ * Sends a POST to `/api/grouped-looks-feedback` with JWT authentication.
827
+ *
828
+ * @param payload - Request payload containing grouped look ID and feedback reason
829
+ * @returns Promise resolving to created feedback information
830
+ * @throws {ApiError} if the HTTP status is not 2xx or on network failure
831
+ * @throws {ApiError} with status 400 if invalid input data
832
+ * @throws {ApiError} with status 404 if grouped look not found
833
+ * @throws {ApiError} with status 409 if feedback already exists for this grouped look
834
+ * @throws {Error} if Fashion Looks token is not set in SDK config
835
+ */
836
+ async createFeedback(t) {
837
+ const o = this.config.getFashionLooksToken();
838
+ if (!o)
839
+ throw new Error(
840
+ "Fashion Looks token is required. Set it in SDK config (fashionLooksToken)."
841
+ );
842
+ const n = `${this.endpoint}/api/grouped-looks-feedback`, e = {
843
+ "Content-Type": "application/json",
844
+ ...a(o)
845
+ };
846
+ return s(n, {
847
+ method: "POST",
848
+ headers: e,
849
+ body: JSON.stringify(t)
850
+ });
851
+ }
852
+ }
853
+ const m = [
378
854
  T,
379
- u
855
+ f,
856
+ k,
857
+ g,
858
+ y,
859
+ S,
860
+ E,
861
+ L,
862
+ O
380
863
  ];
381
- function m(r = {}) {
382
- const t = new l(r), e = O.map((n) => new n(t)), s = {};
383
- return e.forEach((n) => {
864
+ function w(i = {}) {
865
+ const t = new u(i), o = m.map((e) => new e(t)), n = {};
866
+ return o.forEach((e) => {
384
867
  [
385
- ...Object.getOwnPropertyNames(n),
386
- ...Object.getOwnPropertyNames(Object.getPrototypeOf(n))
387
- ].forEach((o) => {
388
- if (o === "constructor") return;
389
- const d = n[o];
390
- typeof d == "function" && (s[o] || (s[o] = (...h) => d.apply(n, h)));
868
+ ...Object.getOwnPropertyNames(e),
869
+ ...Object.getOwnPropertyNames(Object.getPrototypeOf(e))
870
+ ].forEach((c) => {
871
+ if (c === "constructor") return;
872
+ const p = e[c];
873
+ typeof p == "function" && (n[c] || (n[c] = (...l) => p.apply(e, l)));
391
874
  });
392
- }), s;
875
+ }), n;
393
876
  }
394
- const E = {
877
+ const P = {
395
878
  TOP: "TOP",
396
879
  BOTTOM: "BOTTOM",
397
880
  SHOE_ACCESSORY: "SHOE_ACCESSORY",
@@ -402,7 +885,7 @@ const E = {
402
885
  WETSUIT_FULL_BODY: "WETSUIT_FULL_BODY",
403
886
  WETSUIT_BOTTOM: "WETSUIT_BOTTOM",
404
887
  WETSUIT_TOP: "WETSUIT_TOP"
405
- }, y = {
888
+ }, I = {
406
889
  T_SHIRT: "t-shirt",
407
890
  SHIRT: "shirt",
408
891
  BLOUSE: "blouse",
@@ -444,7 +927,7 @@ const E = {
444
927
  WETSUIT: "wetsuit"
445
928
  };
446
929
  export {
447
- E as ClothType,
448
- y as ProductClass,
449
- m as createClient
930
+ P as ClothType,
931
+ I as ProductClass,
932
+ w as createClient
450
933
  };
@@ -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 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
+ (function(c,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(c=typeof globalThis<"u"?globalThis:c||self,d(c["sizebay-core-sdk"]={}))})(this,(function(c){"use strict";const d={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-api.internalsizebay.com",development:"https://fashion-looks-dev.internalsizebay.com"}};class l{constructor(t){const o=t.env||"development";this.serviceOverrides=t.services||{},this.fashionLooksToken=t.fashionLooksToken,this.endpoints={};for(const e in d)if(Object.prototype.hasOwnProperty.call(d,e)){const r=d[e][o];if(!r)continue;this.endpoints[e]=r}}getEndpoint(t){const o=this.endpoints[t];if(!o)throw new Error(`Endpoint for service '${t}' is not configured.`);return o}getServiceConfig(t){return this.serviceOverrides[t]||{}}getFashionLooksToken(){return this.fashionLooksToken}}class T{constructor(t){this.endpoint=t.getEndpoint("tracker")}async track(t,o){const e={eventName:t,...o},n=new URL(`${this.endpoint}/events`);try{const r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){const h=await r.text();throw new Error(`Request error: ${r.status} - ${h}`)}try{return await r.json()}catch{return{statusCode:201,message:"Event successfully created."}}}catch(r){throw r}}}class p extends Error{constructor(t,o){let e;try{const n=JSON.parse(o);e=(n==null?void 0:n.message)||o}catch{e=o}super(e),this.statusCode=t,this.details=o,Object.setPrototypeOf(this,p.prototype)}}async function s(i,t){let o;try{o=await fetch(i,t)}catch(n){throw new p(0,n.message)}const e=await o.text();if(!o.ok)throw new p(o.status,e);return JSON.parse(e)}class f{constructor(t){this.endpoint=t.getEndpoint("aiImageService")}appendQueryParams(t,o){Object.entries(o).forEach(([e,n])=>{n!=null&&t.searchParams.append(e,String(n))})}getSimilarProducts(t){const o=new URL(`${this.endpoint}/recommendations/similar`);return this.appendQueryParams(o,t),s(o.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}getComplementaryProducts(t){const o=new URL(`${this.endpoint}/recommendations/complementary`);return this.appendQueryParams(o,t),s(o.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}searchSimilarByImage(t){const o=`${this.endpoint}/image-search/similar`;return s(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}searchComplementaryByImage(t){const o=`${this.endpoint}/image-search/complementary`;return s(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}searchSimilarByPermalink(t){const o=`${this.endpoint}/image-search/similar-by-permalink`;return s(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}searchComplementaryByPermalink(t){const o=`${this.endpoint}/image-search/complementary-by-permalink`;return s(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}}class k{constructor(t){this.sid=null,this.sessionId=null;const o=t.getEndpoint("session");this.sessionEndpoint=`${o}/`,this.profileEndpoint=`${o}/user/profile`}async getSessionInfo(){if(this.sid&&this.sessionId!==null)return{sid:this.sid,sessionId:this.sessionId};const t=await fetch(this.sessionEndpoint,{credentials:"include"});if(!t.ok){const e=await t.text();throw new Error(`Failed to fetch session info: ${t.status} – ${e}`)}const o=await t.json();return this.sid=o.catalogUser.id,this.sessionId=o.sessionId,{sid:this.sid,sessionId:this.sessionId}}async sendProfile(t,o){const e=o??(await this.getSessionInfo()).sid,n=new URL(this.profileEndpoint);n.searchParams.set("sid",e);const r=await fetch(n.toString(),{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:e,id:null,...t})});if(!r.ok){const h=await r.text();throw new Error(`Failed to send profile: ${r.status} – ${h}`)}}}function a(i,t){const o={};return i&&(o.Authorization=`Bearer ${i}`),o}class y{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}async generateToken(t){const o=`${this.endpoint}/api/auth/generate-token`;return s(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async validateToken(t){const o=t||this.config.getFashionLooksToken();if(!o)throw new Error("Token is required. Provide it as parameter or set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/auth/validate`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"GET",headers:n})}}class g{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}async getBalance(){const t=this.config.getFashionLooksToken();if(!t)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const o=`${this.endpoint}/api/wallet/balance`,e={"Content-Type":"application/json",...a(t)};return s(o,{method:"GET",headers:e})}async getTransactionHistory(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=new URL(`${this.endpoint}/api/wallet/history`);t!=null&&t.limit&&e.searchParams.append("limit",t.limit.toString()),t!=null&&t.offset&&e.searchParams.append("offset",t.offset.toString());const n={"Content-Type":"application/json",...a(o)};return s(e.toString(),{method:"GET",headers:n})}}class S{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}async getAllPlans(){const t=`${this.endpoint}/api/plans`;return s(t,{method:"GET",headers:{"Content-Type":"application/json"}})}async getPlanById(t){const o=`${this.endpoint}/api/plans/${t}`;return s(o,{method:"GET",headers:{"Content-Type":"application/json"}})}async getTenantActivePlan(t){const o=`${this.endpoint}/api/plans/tenants/${t}/active`;return s(o,{method:"GET",headers:{"Content-Type":"application/json"}})}}class E{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}async generateTryon(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/tryons/generate`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"POST",headers:n,body:JSON.stringify(t)})}async getTryonById(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/tryons/${t}`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"GET",headers:n})}async getTryonHistory(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=new URL(`${this.endpoint}/api/tryons`);t!=null&&t.limit&&e.searchParams.append("limit",t.limit.toString()),t!=null&&t.offset&&e.searchParams.append("offset",t.offset.toString());const n={"Content-Type":"application/json",...a(o)};return s(e.toString(),{method:"GET",headers:n})}async findProductsByTenant(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/tryons/find-products`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"POST",headers:n,body:JSON.stringify(t)})}}class O{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}appendQueryParams(t,o){Object.entries(o).forEach(([e,n])=>{n!=null&&t.searchParams.append(e,String(n))})}async getGroupedLooks(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=new URL(`${this.endpoint}/api/grouped-looks`);t&&Object.keys(t).length>0&&this.appendQueryParams(e,t);const n={"Content-Type":"application/json",...a(o)};return s(e.toString(),{method:"GET",headers:n})}async getGroupedLookById(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/grouped-looks/${t}`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"GET",headers:n})}async updateGroupedLook(t,o){const e=this.config.getFashionLooksToken();if(!e)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const n=`${this.endpoint}/api/grouped-looks/${t}`,r={"Content-Type":"application/json",...a(e)};return s(n,{method:"PATCH",headers:r,body:JSON.stringify(o)})}async getPublicGroupedLooks(t){const o=new URL(`${this.endpoint}/api/public/grouped-looks`);return this.appendQueryParams(o,t),s(o.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}async getPublicGroupedLookById(t,o){const e=new URL(`${this.endpoint}/api/public/grouped-looks/${t}`);return e.searchParams.append("tenantId",o.toString()),s(e.toString(),{method:"GET",headers:{"Content-Type":"application/json"}})}}class L{constructor(t){this.endpoint=t.getEndpoint("fashionLooks"),this.config=t}async createFeedback(t){const o=this.config.getFashionLooksToken();if(!o)throw new Error("Fashion Looks token is required. Set it in SDK config (fashionLooksToken).");const e=`${this.endpoint}/api/grouped-looks-feedback`,n={"Content-Type":"application/json",...a(o)};return s(e,{method:"POST",headers:n,body:JSON.stringify(t)})}}const m=[T,f,k,y,g,S,E,O,L];function w(i={}){const t=new l(i),o=m.map(n=>new n(t)),e={};return o.forEach(n=>{[...Object.getOwnPropertyNames(n),...Object.getOwnPropertyNames(Object.getPrototypeOf(n))].forEach(h=>{if(h==="constructor")return;const u=n[h];typeof u=="function"&&(e[h]||(e[h]=(...I)=>u.apply(n,I)))})}),e}const P={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"},b={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"};c.ClothType=P,c.ProductClass=b,c.createClient=w,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
@@ -1,5 +1,6 @@
1
1
  export interface SDKConfigOptions {
2
2
  env?: 'development' | 'production';
3
+ fashionLooksToken?: string;
3
4
  globalOptions?: {
4
5
  [key: string]: any;
5
6
  };
@@ -0,0 +1,13 @@
1
+ export interface GenerateTokenDto {
2
+ tenantId: number;
3
+ }
4
+ export interface TokenResponseDto {
5
+ access_token: string;
6
+ expires_in: number;
7
+ token_type: string;
8
+ }
9
+ export interface ValidateTokenResponseDto {
10
+ tenantId: number;
11
+ valid: boolean;
12
+ exp: number;
13
+ }
@@ -0,0 +1,9 @@
1
+ export type Gender = 'MALE' | 'FEMALE';
2
+ export type AgeGroup = 'NEW_BORN' | 'TODDLER' | 'INFANT' | 'KIDS' | 'ADULT';
3
+ export type Style = 'casual' | 'formal' | 'party' | 'night' | 'sport' | 'beach' | 'winter';
4
+ export type Collection = 'spring' | 'summer' | 'fall' | 'winter';
5
+ export type Status = 'enabled' | 'disabled';
6
+ export type FeedbackReason = 'color' | 'avatar' | 'texture' | 'cloth_fit' | 'didnt_like_the_look';
7
+ export type GarmentType = 'shoe' | 'bottom' | 'top' | 'fullbody';
8
+ export type BMI = 'slim' | 'regular' | 'plus';
9
+ export type SkinTone = 'light' | 'brown' | 'dark';
@@ -0,0 +1,58 @@
1
+ import { Gender, AgeGroup, Style, Collection, Status, FeedbackReason } from './common';
2
+ export interface GroupedLookTryon {
3
+ bmi: string;
4
+ skinTones: Array<{
5
+ skinTone: string;
6
+ tryonDetails: Record<string, any>;
7
+ }>;
8
+ }
9
+ export interface GroupedLookFeedbackResponseDto {
10
+ id: string;
11
+ tenantId: number;
12
+ groupedLookId: string;
13
+ reason: FeedbackReason;
14
+ timestamp: string;
15
+ }
16
+ export interface GroupedLookResponseDto {
17
+ id: string;
18
+ tenantId: number;
19
+ gender: Gender;
20
+ ageGroup: AgeGroup;
21
+ style: Style;
22
+ collection: Collection;
23
+ rate: number;
24
+ status: Status;
25
+ timestamp: string;
26
+ tryons: GroupedLookTryon[];
27
+ feedback?: GroupedLookFeedbackResponseDto;
28
+ }
29
+ export interface UpdateGroupedLookDto {
30
+ rate?: number;
31
+ status?: Status;
32
+ }
33
+ export interface CreateGroupedLookFeedbackDto {
34
+ groupedLookId: string;
35
+ reason: FeedbackReason;
36
+ }
37
+ export interface GetGroupedLooksParams {
38
+ limit?: number;
39
+ offset?: number;
40
+ order?: 'asc' | 'desc';
41
+ permalink?: string;
42
+ gender?: Gender;
43
+ ageGroup?: AgeGroup;
44
+ style?: Style;
45
+ collection?: Collection;
46
+ status?: Status;
47
+ tenantId?: number;
48
+ }
49
+ export interface GetGroupedLooksResponse {
50
+ data: GroupedLookResponseDto[];
51
+ total: number;
52
+ pagination: {
53
+ limit: number;
54
+ offset: number;
55
+ hasNext: boolean;
56
+ hasPrevious: boolean;
57
+ };
58
+ }
@@ -0,0 +1,6 @@
1
+ export * from './common';
2
+ export * from './auth';
3
+ export * from './wallet';
4
+ export * from './plans';
5
+ export * from './tryon';
6
+ export * from './grouped-looks';
@@ -0,0 +1,24 @@
1
+ export interface Plan {
2
+ id: string;
3
+ name: string;
4
+ description?: string;
5
+ price?: number;
6
+ currency?: 'BRL' | 'USD' | 'EUR';
7
+ creditsAmount?: number;
8
+ features?: Record<string, any>;
9
+ [key: string]: any;
10
+ }
11
+ export interface CreatePlanDto {
12
+ id: string;
13
+ name: string;
14
+ description: string;
15
+ price: number;
16
+ currency: 'BRL' | 'USD' | 'EUR';
17
+ creditsAmount: number;
18
+ features?: Record<string, any>;
19
+ }
20
+ export interface CreatePlanResponseDto {
21
+ success: boolean;
22
+ plan: Plan;
23
+ message: string;
24
+ }
@@ -0,0 +1,44 @@
1
+ import { Gender, AgeGroup, GarmentType, BMI, SkinTone } from './common';
2
+ export interface AvatarDetailsDto {
3
+ bmi: BMI;
4
+ skinTone: SkinTone;
5
+ avatarImageUrl?: string;
6
+ }
7
+ export interface GarmentDto {
8
+ type: GarmentType;
9
+ permalink: string;
10
+ imageUrl?: string;
11
+ }
12
+ export interface GenerateTryonDto {
13
+ tenantId: number;
14
+ gender: Gender;
15
+ ageGroup: AgeGroup;
16
+ avatarDetails: AvatarDetailsDto[];
17
+ garments: GarmentDto[];
18
+ bagImageUrl?: string;
19
+ }
20
+ export interface TryonTaskResponseDto {
21
+ taskId: string;
22
+ tasksCreated: number;
23
+ status: string;
24
+ }
25
+ export interface TryonDetails {
26
+ [key: string]: any;
27
+ }
28
+ export interface FindProductByTenantDto {
29
+ catalogClothType: 'TOP' | 'BOTTOM' | 'SHOE_ACCESSORY';
30
+ productId: string;
31
+ }
32
+ export interface ProductItemResponseDto {
33
+ id: string;
34
+ imageLink: string;
35
+ additionalImageLinks: string[];
36
+ productType: string;
37
+ gender: string;
38
+ ageGroup: string;
39
+ productHash: string;
40
+ itemGroupId: string;
41
+ brand: string;
42
+ size: string;
43
+ color: string;
44
+ }
@@ -0,0 +1,9 @@
1
+ export interface WalletBalanceDto {
2
+ balance: number;
3
+ tenantId: number;
4
+ lastTransaction: string;
5
+ }
6
+ export interface TransactionHistoryItem {
7
+ [key: string]: any;
8
+ }
9
+ export type TransactionHistoryResponse = TransactionHistoryItem[];
@@ -1,5 +1,6 @@
1
1
  export * from './ai-image';
2
2
  export * from './common';
3
3
  export * from './event';
4
+ export * from './fashion-looks';
4
5
  export * from './product';
5
6
  export * from './session';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.11.0-dev.5",
3
+ "version": "1.12.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",