sizebay-core-sdk 1.1.3 → 1.1.4

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.
@@ -1,2 +1,2 @@
1
- import { ClientType, SDKConfigOptions } from '../types';
2
- export declare function createClient(options?: SDKConfigOptions): ClientType;
1
+ import { ClientType } from '../types';
2
+ export declare function createClient(options?: {}): ClientType;
@@ -10,9 +10,9 @@ const c = {
10
10
  // Adicione outros serviços conforme necessário
11
11
  };
12
12
  class a {
13
- constructor(e) {
14
- const n = e.env || "development";
15
- this.serviceOverrides = e.services || {}, this.endpoints = {};
13
+ constructor(r) {
14
+ const n = r.env || "development";
15
+ this.serviceOverrides = r.services || {}, this.endpoints = {};
16
16
  for (const t in c)
17
17
  if (Object.prototype.hasOwnProperty.call(c, t)) {
18
18
  const o = c[t][n];
@@ -21,29 +21,29 @@ class a {
21
21
  this.endpoints[t] = o;
22
22
  }
23
23
  }
24
- getEndpoint(e) {
25
- const n = this.endpoints[e];
24
+ getEndpoint(r) {
25
+ const n = this.endpoints[r];
26
26
  if (!n)
27
27
  throw new Error(
28
- `Endpoint for service '${e}' is not configured.`
28
+ `Endpoint for service '${r}' is not configured.`
29
29
  );
30
30
  return n;
31
31
  }
32
- getServiceConfig(e) {
33
- return this.serviceOverrides[e] || {};
32
+ getServiceConfig(r) {
33
+ return this.serviceOverrides[r] || {};
34
34
  }
35
35
  }
36
36
  class p {
37
- constructor(e) {
38
- this.endpoint = e.getEndpoint("tracker");
37
+ constructor(r) {
38
+ this.endpoint = r.getEndpoint("tracker");
39
39
  }
40
- async track(e, n) {
40
+ async track(r, n) {
41
41
  const t = {
42
- eventName: e,
42
+ eventName: r,
43
43
  ...n
44
- }, r = new URL(`${this.endpoint}/events`);
44
+ }, e = new URL(`${this.endpoint}/events`);
45
45
  try {
46
- const o = await fetch(r, {
46
+ const o = await fetch(e, {
47
47
  method: "POST",
48
48
  headers: { "Content-Type": "application/json" },
49
49
  body: JSON.stringify(t)
@@ -59,13 +59,13 @@ class p {
59
59
  }
60
60
  }
61
61
  class d {
62
- constructor(e) {
63
- this.endpoint = e.getEndpoint("aiImageService");
62
+ constructor(r) {
63
+ this.endpoint = r.getEndpoint("aiImageService");
64
64
  }
65
- async getSimilarProducts(e) {
65
+ async getSimilarProducts(r) {
66
66
  const n = new URL(`${this.endpoint}/recommendations/similar`);
67
- Object.entries(e).forEach(([t, r]) => {
68
- r !== void 0 && n.searchParams.append(t, String(r));
67
+ Object.entries(r).forEach(([t, e]) => {
68
+ e !== void 0 && n.searchParams.append(t, String(e));
69
69
  });
70
70
  try {
71
71
  const t = await fetch(n.toString(), {
@@ -75,15 +75,15 @@ class d {
75
75
  }
76
76
  });
77
77
  if (!t.ok) {
78
- const r = await t.text();
79
- throw new Error(`Request error: ${t.status} - ${r}`);
78
+ const e = await t.text();
79
+ throw new Error(`Request error: ${t.status} - ${e}`);
80
80
  }
81
81
  return await t.json();
82
82
  } catch (t) {
83
83
  throw new Error(`Error fetching similar products: ${t.message}`);
84
84
  }
85
85
  }
86
- async getRecommendedSizeByProducts(e) {
86
+ async getRecommendedSizeByProducts(r) {
87
87
  const n = new URL(`${this.endpoint}/recommendations/size-by-products`);
88
88
  try {
89
89
  const t = await fetch(n.toString(), {
@@ -91,11 +91,11 @@ class d {
91
91
  headers: {
92
92
  "Content-Type": "application/json"
93
93
  },
94
- body: JSON.stringify(e)
94
+ body: JSON.stringify(r)
95
95
  });
96
96
  if (!t.ok) {
97
- const r = await t.text();
98
- throw new Error(`Request error: ${t.status} - ${r}`);
97
+ const e = await t.text();
98
+ throw new Error(`Request error: ${t.status} - ${e}`);
99
99
  }
100
100
  return await t.json();
101
101
  } catch (t) {
@@ -108,14 +108,14 @@ const h = [
108
108
  d
109
109
  ];
110
110
  function f(s = {}) {
111
- const e = new a(s), n = h.map((r) => new r(e)), t = { config: e };
112
- return n.forEach((r) => {
113
- Object.getOwnPropertyNames(r).forEach((i) => {
114
- typeof r[i] == "function" && (t[i] = r[i].bind(r));
111
+ const r = new a(s), n = h.map((e) => new e(r)), t = {};
112
+ return n.forEach((e) => {
113
+ Object.getOwnPropertyNames(e).forEach((i) => {
114
+ typeof e[i] == "function" && (t[i] = e[i].bind(e));
115
115
  });
116
- const o = Object.getPrototypeOf(r);
116
+ const o = Object.getPrototypeOf(e);
117
117
  Object.getOwnPropertyNames(o).forEach((i) => {
118
- i !== "constructor" && typeof r[i] == "function" && (t[i] = r[i].bind(r));
118
+ i !== "constructor" && typeof e[i] == "function" && (t[i] = e[i].bind(e));
119
119
  });
120
120
  }), t;
121
121
  }
@@ -1 +1 @@
1
- (function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c["sizebay-core-sdk"]={}))})(this,function(c){"use strict";const s={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"}};class d{constructor(t){const n=t.env||"development";this.serviceOverrides=t.services||{},this.endpoints={};for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)){const o=s[e][n];if(!o)continue;this.endpoints[e]=o}}getEndpoint(t){const n=this.endpoints[t];if(!n)throw new Error(`Endpoint for service '${t}' is not configured.`);return n}getServiceConfig(t){return this.serviceOverrides[t]||{}}}class p{constructor(t){this.endpoint=t.getEndpoint("tracker")}async track(t,n){const e={eventName:t,...n},r=new URL(`${this.endpoint}/events`);try{const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok){const i=await o.text();throw new Error(`Request error: ${o.status} - ${i}`)}return await o.json()}catch(o){throw o}}}class f{constructor(t){this.endpoint=t.getEndpoint("aiImageService")}async getSimilarProducts(t){const n=new URL(`${this.endpoint}/recommendations/similar`);Object.entries(t).forEach(([e,r])=>{r!==void 0&&n.searchParams.append(e,String(r))});try{const e=await fetch(n.toString(),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){const r=await e.text();throw new Error(`Request error: ${e.status} - ${r}`)}return await e.json()}catch(e){throw new Error(`Error fetching similar products: ${e.message}`)}}async getRecommendedSizeByProducts(t){const n=new URL(`${this.endpoint}/recommendations/size-by-products`);try{const e=await fetch(n.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok){const r=await e.text();throw new Error(`Request error: ${e.status} - ${r}`)}return await e.json()}catch(e){throw new Error(`Error fetching recommended product size: ${e.message}`)}}}const h=[p,f];function u(a={}){const t=new d(a),n=h.map(r=>new r(t)),e={config:t};return n.forEach(r=>{Object.getOwnPropertyNames(r).forEach(i=>{typeof r[i]=="function"&&(e[i]=r[i].bind(r))});const o=Object.getPrototypeOf(r);Object.getOwnPropertyNames(o).forEach(i=>{i!=="constructor"&&typeof r[i]=="function"&&(e[i]=r[i].bind(r))})}),e}c.createClient=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
1
+ (function(c,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(c=typeof globalThis<"u"?globalThis:c||self,s(c["sizebay-core-sdk"]={}))})(this,function(c){"use strict";const s={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"}};class d{constructor(r){const n=r.env||"development";this.serviceOverrides=r.services||{},this.endpoints={};for(const e in s)if(Object.prototype.hasOwnProperty.call(s,e)){const o=s[e][n];if(!o)continue;this.endpoints[e]=o}}getEndpoint(r){const n=this.endpoints[r];if(!n)throw new Error(`Endpoint for service '${r}' is not configured.`);return n}getServiceConfig(r){return this.serviceOverrides[r]||{}}}class p{constructor(r){this.endpoint=r.getEndpoint("tracker")}async track(r,n){const e={eventName:r,...n},t=new URL(`${this.endpoint}/events`);try{const o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok){const i=await o.text();throw new Error(`Request error: ${o.status} - ${i}`)}return await o.json()}catch(o){throw o}}}class f{constructor(r){this.endpoint=r.getEndpoint("aiImageService")}async getSimilarProducts(r){const n=new URL(`${this.endpoint}/recommendations/similar`);Object.entries(r).forEach(([e,t])=>{t!==void 0&&n.searchParams.append(e,String(t))});try{const e=await fetch(n.toString(),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){const t=await e.text();throw new Error(`Request error: ${e.status} - ${t}`)}return await e.json()}catch(e){throw new Error(`Error fetching similar products: ${e.message}`)}}async getRecommendedSizeByProducts(r){const n=new URL(`${this.endpoint}/recommendations/size-by-products`);try{const e=await fetch(n.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!e.ok){const t=await e.text();throw new Error(`Request error: ${e.status} - ${t}`)}return await e.json()}catch(e){throw new Error(`Error fetching recommended product size: ${e.message}`)}}}const h=[p,f];function u(a={}){const r=new d(a),n=h.map(t=>new t(r)),e={};return n.forEach(t=>{Object.getOwnPropertyNames(t).forEach(i=>{typeof t[i]=="function"&&(e[i]=t[i].bind(t))});const o=Object.getPrototypeOf(t);Object.getOwnPropertyNames(o).forEach(i=>{i!=="constructor"&&typeof t[i]=="function"&&(e[i]=t[i].bind(t))})}),e}c.createClient=u,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
@@ -1,4 +1,3 @@
1
- import { Config } from '../config';
2
1
  import { moduleClasses } from '../modules';
3
2
  type InstanceTypeOfClass<T> = T extends new (...args: any[]) => infer R ? R : never;
4
3
  type UnionToIntersection<U> = (U extends any ? (x: U) => any : never) extends (x: infer I) => any ? I : never;
@@ -7,7 +6,10 @@ export type PublicAPI<T> = {
7
6
  };
8
7
  type ModulesUnion = PublicAPI<InstanceTypeOfClass<(typeof moduleClasses)[number]>>;
9
8
  type ModulesIntersection = UnionToIntersection<ModulesUnion>;
10
- export type ClientType = {
11
- config: Config;
12
- } & ModulesIntersection;
9
+ export type ClientType = ModulesIntersection;
10
+ export type createClientType = {
11
+ options?: {
12
+ env?: 'development' | 'production';
13
+ };
14
+ };
13
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sizebay-core-sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
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",