oneentry 1.0.157 → 1.0.159

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.
Files changed (48) hide show
  1. package/README.md +20 -0
  2. package/changelog.md +89 -0
  3. package/dist/admins/adminsApi.js +36 -2
  4. package/dist/attribute-sets/attributeSetsApi.d.ts +2 -2
  5. package/dist/attribute-sets/attributeSetsApi.js +40 -6
  6. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +19 -7
  7. package/dist/auth-provider/authProviderApi.js +38 -4
  8. package/dist/base/asyncModules.d.ts +6 -4
  9. package/dist/base/asyncModules.js +44 -8
  10. package/dist/base/syncModules.d.ts +2 -1
  11. package/dist/base/syncModules.js +10 -1
  12. package/dist/base/timeIntervals.js +6 -5
  13. package/dist/base/utils.d.ts +12 -8
  14. package/dist/blocks/blocksApi.d.ts +21 -21
  15. package/dist/blocks/blocksApi.js +48 -14
  16. package/dist/blocks/blocksInterfaces.d.ts +20 -20
  17. package/dist/blocks/blocksSchemas.d.ts +2 -0
  18. package/dist/discounts/discountsInterfaces.d.ts +4 -4
  19. package/dist/events/eventsApi.d.ts +3 -3
  20. package/dist/events/eventsApi.js +1 -1
  21. package/dist/events/eventsInterfaces.d.ts +16 -5
  22. package/dist/file-uploading/fileUploadingApi.js +36 -2
  23. package/dist/filters/filtersApi.js +36 -2
  24. package/dist/forms/formsApi.js +37 -3
  25. package/dist/forms/formsInterfaces.d.ts +22 -20
  26. package/dist/forms-data/formsDataApi.js +38 -4
  27. package/dist/general-types/generalTypesApi.js +36 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/integration-collections/integrationCollectionsApi.js +43 -9
  30. package/dist/locales/localesApi.js +36 -2
  31. package/dist/menus/menusApi.js +36 -2
  32. package/dist/orders/ordersApi.js +39 -5
  33. package/dist/orders/ordersInterfaces.d.ts +11 -3
  34. package/dist/pages/pagesApi.js +42 -8
  35. package/dist/payments/paymentsApi.js +39 -5
  36. package/dist/product-statuses/productStatusesApi.js +38 -4
  37. package/dist/products/productsApi.d.ts +2 -2
  38. package/dist/products/productsApi.js +42 -8
  39. package/dist/products/productsInterfaces.d.ts +23 -15
  40. package/dist/products/productsSchemas.d.ts +1 -0
  41. package/dist/products/productsSchemas.js +1 -0
  42. package/dist/subscriptions/subscriptionsApi.js +38 -4
  43. package/dist/templates/templatesApi.js +38 -4
  44. package/dist/templates-preview/templatesPreviewApi.js +37 -3
  45. package/dist/users/usersApi.js +45 -11
  46. package/dist/web-socket/wsApi.d.ts +2 -0
  47. package/dist/web-socket/wsApi.js +47 -10
  48. package/package.json +6 -1
@@ -106,6 +106,7 @@ export declare const ProductsResponseSchema: z.ZodObject<{
106
106
  discountConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
107
107
  }, z.core.$strip>>;
108
108
  total: z.ZodNumber;
109
+ totalFound: z.ZodOptional<z.ZodNumber>;
109
110
  }, z.core.$strip>;
110
111
  /**
111
112
  * Single product response schema
@@ -74,6 +74,7 @@ exports.ProductEntitySchema = zod_1.z.object({
74
74
  exports.ProductsResponseSchema = zod_1.z.object({
75
75
  items: zod_1.z.array(exports.ProductEntitySchema),
76
76
  total: zod_1.z.number(),
77
+ totalFound: zod_1.z.number().optional(),
77
78
  });
78
79
  /**
79
80
  * Single product response schema
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
- const subscriptionsSchemas_1 = require("./subscriptionsSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./subscriptionsSchemas'))));
8
42
  /**
9
43
  * Controllers for working with paid subscriptions.
10
44
  * @handle /api/content/subscriptions
@@ -34,7 +68,7 @@ class SubscriptionsApi extends asyncModules_1.default {
34
68
  */
35
69
  async subscribe(body) {
36
70
  const data = await this._fetchPost(``, body);
37
- const validated = this._validateResponse(data, subscriptionsSchemas_1.CreatedSubscriptionSchema);
71
+ const validated = await this._validateResponse(data, schema('CreatedSubscriptionSchema'));
38
72
  return this._normalizeData(validated);
39
73
  }
40
74
  /**
@@ -61,7 +95,7 @@ class SubscriptionsApi extends asyncModules_1.default {
61
95
  */
62
96
  async getAllSubscriptions() {
63
97
  const data = await this._fetchGet(``);
64
- const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionsListSchema);
98
+ const validated = await this._validateResponse(data, schema('SubscriptionsListSchema'));
65
99
  return this._normalizeData(validated);
66
100
  }
67
101
  /**
@@ -75,7 +109,7 @@ class SubscriptionsApi extends asyncModules_1.default {
75
109
  */
76
110
  async getActiveSubscriptions() {
77
111
  const data = await this._fetchGet(`/active`);
78
- const validated = this._validateResponse(data, subscriptionsSchemas_1.SubscriptionMarkersSchema);
112
+ const validated = await this._validateResponse(data, schema('SubscriptionMarkersSchema'));
79
113
  return this._normalizeData(validated);
80
114
  }
81
115
  /**
@@ -1,11 +1,45 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  /* eslint-disable @typescript-eslint/no-explicit-any */
7
40
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
- const templatesSchemas_1 = require("./templatesSchemas");
41
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
42
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./templatesSchemas'))));
9
43
  /**
10
44
  * Controllers for working with template objects
11
45
  * @module TemplateController
@@ -34,7 +68,7 @@ class TemplatesPreviewApi extends asyncModules_1.default {
34
68
  async getAllTemplates(langCode = this.state.lang) {
35
69
  const response = await this._fetchGet(`/all?langCode=${langCode}`);
36
70
  // Validate response if validation is enabled
37
- const validated = this._validateResponse(response, templatesSchemas_1.GroupedTemplatesResponseSchema);
71
+ const validated = await this._validateResponse(response, schema('GroupedTemplatesResponseSchema'));
38
72
  const result = {};
39
73
  if (validated &&
40
74
  typeof validated === 'object' &&
@@ -60,7 +94,7 @@ class TemplatesPreviewApi extends asyncModules_1.default {
60
94
  async getTemplateByType(type, langCode = this.state.lang) {
61
95
  const result = await this._fetchGet(`?type=${type}&langCode=${langCode}`);
62
96
  // Validate response if validation is enabled
63
- const validated = this._validateResponse(result, templatesSchemas_1.TemplatesResponseSchema);
97
+ const validated = await this._validateResponse(result, schema('TemplatesResponseSchema'));
64
98
  return this._normalizeData(validated);
65
99
  }
66
100
  /**
@@ -76,7 +110,7 @@ class TemplatesPreviewApi extends asyncModules_1.default {
76
110
  async getTemplateByMarker(marker, langCode = this.state.lang) {
77
111
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
78
112
  // Validate response if validation is enabled
79
- const validated = this._validateResponse(result, templatesSchemas_1.TemplateEntitySchema);
113
+ const validated = await this._validateResponse(result, schema('TemplateEntitySchema'));
80
114
  return this._normalizeData(validated);
81
115
  }
82
116
  }
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
- const templatesPreviewSchemas_1 = require("./templatesPreviewSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./templatesPreviewSchemas'))));
8
42
  /**
9
43
  * Controllers for working with template objects for preview.
10
44
  * @handle /api/content/template-previews
@@ -32,7 +66,7 @@ class TemplatePreviewsApi extends asyncModules_1.default {
32
66
  async getTemplatePreviews(langCode = this.state.lang) {
33
67
  const result = await this._fetchGet(`?langCode=${langCode}`);
34
68
  // Validate response if validation is enabled
35
- const validated = this._validateResponse(result, templatesPreviewSchemas_1.TemplatePreviewsResponseSchema);
69
+ const validated = await this._validateResponse(result, schema('TemplatePreviewsResponseSchema'));
36
70
  return this._normalizeData(validated, langCode);
37
71
  }
38
72
  /**
@@ -48,7 +82,7 @@ class TemplatePreviewsApi extends asyncModules_1.default {
48
82
  async getTemplatePreviewByMarker(marker, langCode = this.state.lang) {
49
83
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
50
84
  // Validate response if validation is enabled
51
- const validated = this._validateResponse(result, templatesPreviewSchemas_1.TemplatePreviewEntitySchema);
85
+ const validated = await this._validateResponse(result, schema('TemplatePreviewEntitySchema'));
52
86
  return this._normalizeData(validated, langCode);
53
87
  }
54
88
  }
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
39
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
- const usersSchemas_1 = require("./usersSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./usersSchemas'))));
8
42
  /**
9
43
  * Controllers for working with users
10
44
  * @handle /api/content/users
@@ -33,7 +67,7 @@ class UsersApi extends asyncModules_1.default {
33
67
  async getUser(langCode = this.state.lang) {
34
68
  const result = await this._fetchGet(`/me?langCode=${langCode}`);
35
69
  // Validate response if validation is enabled
36
- const validated = this._validateResponse(result, usersSchemas_1.UserResponseSchema);
70
+ const validated = await this._validateResponse(result, schema('UserResponseSchema'));
37
71
  return this._normalizeData(validated);
38
72
  }
39
73
  /**
@@ -116,7 +150,7 @@ class UsersApi extends asyncModules_1.default {
116
150
  if (!('langCode' in body))
117
151
  body['langCode'] = langCode;
118
152
  const result = await this._fetchPut('/me', this._normalizePostBody(body, langCode));
119
- const validated = this._validateResponse(result, usersSchemas_1.UpdateUserResponseSchema);
153
+ const validated = await this._validateResponse(result, schema('UpdateUserResponseSchema'));
120
154
  return validated;
121
155
  }
122
156
  /**
@@ -184,7 +218,7 @@ class UsersApi extends asyncModules_1.default {
184
218
  */
185
219
  async getCart() {
186
220
  const result = await this._fetchGet('/me/cart');
187
- const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
221
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
188
222
  return this._normalizeData(validated);
189
223
  }
190
224
  /**
@@ -199,7 +233,7 @@ class UsersApi extends asyncModules_1.default {
199
233
  */
200
234
  async setCart(body) {
201
235
  const result = await this._fetchPut('/me/cart', body);
202
- const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
236
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
203
237
  return this._normalizeData(validated);
204
238
  }
205
239
  /**
@@ -214,7 +248,7 @@ class UsersApi extends asyncModules_1.default {
214
248
  */
215
249
  async addCartItem(body) {
216
250
  const result = await this._fetchPost('/me/cart/items', body);
217
- const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
251
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
218
252
  return this._normalizeData(validated);
219
253
  }
220
254
  /**
@@ -229,7 +263,7 @@ class UsersApi extends asyncModules_1.default {
229
263
  */
230
264
  async removeCartItem(productId) {
231
265
  const result = await this._fetchDelete(`/me/cart/items/${productId}`);
232
- const validated = this._validateResponse(result, usersSchemas_1.CartResponseSchema);
266
+ const validated = await this._validateResponse(result, schema('CartResponseSchema'));
233
267
  return this._normalizeData(validated);
234
268
  }
235
269
  /**
@@ -243,7 +277,7 @@ class UsersApi extends asyncModules_1.default {
243
277
  */
244
278
  async getWishlist() {
245
279
  const result = await this._fetchGet('/me/wishlist');
246
- const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
280
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
247
281
  return this._normalizeData(validated);
248
282
  }
249
283
  /**
@@ -258,7 +292,7 @@ class UsersApi extends asyncModules_1.default {
258
292
  */
259
293
  async setWishlist(body) {
260
294
  const result = await this._fetchPut('/me/wishlist', body);
261
- const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
295
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
262
296
  return this._normalizeData(validated);
263
297
  }
264
298
  /**
@@ -273,7 +307,7 @@ class UsersApi extends asyncModules_1.default {
273
307
  */
274
308
  async addWishlistItem(body) {
275
309
  const result = await this._fetchPost('/me/wishlist/items', body);
276
- const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
310
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
277
311
  return this._normalizeData(validated);
278
312
  }
279
313
  /**
@@ -288,7 +322,7 @@ class UsersApi extends asyncModules_1.default {
288
322
  */
289
323
  async removeWishlistItem(productId) {
290
324
  const result = await this._fetchDelete(`/me/wishlist/items/${productId}`);
291
- const validated = this._validateResponse(result, usersSchemas_1.WishlistResponseSchema);
325
+ const validated = await this._validateResponse(result, schema('WishlistResponseSchema'));
292
326
  return this._normalizeData(validated);
293
327
  }
294
328
  }
@@ -19,6 +19,8 @@ export default class WsApi extends AsyncModules implements IWS {
19
19
  * @handleName connect
20
20
  * @returns {Socket} Returns a Socket instance.
21
21
  * @description Creates an instance of an object Socket.io with a connection. This method requires user authorization.
22
+ * Socket.io is imported on demand, so projects that never open a socket do not bundle it; the returned
23
+ * value is usable immediately either way (see `createLazySocket`).
22
24
  * @see {@link https://js-sdk.oneentry.cloud/docs/web-socket/connect connect} documentation.
23
25
  */
24
26
  connect(): Socket;
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const socket_io_client_1 = require("socket.io-client");
7
39
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
40
+ const lazySocket_1 = __importDefault(require("./lazySocket"));
8
41
  /**
9
42
  * Controllers for working with users
10
43
  * @handle /api/content/ws
@@ -23,6 +56,8 @@ class WsApi extends asyncModules_1.default {
23
56
  * @handleName connect
24
57
  * @returns {Socket} Returns a Socket instance.
25
58
  * @description Creates an instance of an object Socket.io with a connection. This method requires user authorization.
59
+ * Socket.io is imported on demand, so projects that never open a socket do not bundle it; the returned
60
+ * value is usable immediately either way (see `createLazySocket`).
26
61
  * @see {@link https://js-sdk.oneentry.cloud/docs/web-socket/connect connect} documentation.
27
62
  */
28
63
  connect() {
@@ -30,16 +65,18 @@ class WsApi extends asyncModules_1.default {
30
65
  // eslint-disable-next-line no-undef, no-console
31
66
  console.error('User is unauthorized');
32
67
  }
33
- const socket = (0, socket_io_client_1.io)(this.state.url, {
34
- autoConnect: true,
35
- path: '/api/content/ws',
36
- transports: ['websocket'],
37
- extraHeaders: {
38
- Authorization: 'Bearer ' + this.state.accessToken,
39
- 'x-app-token': this.state.token,
40
- },
68
+ return (0, lazySocket_1.default)(async () => {
69
+ const { io } = await Promise.resolve().then(() => __importStar(require('socket.io-client')));
70
+ return io(this.state.url, {
71
+ autoConnect: true,
72
+ path: '/api/content/ws',
73
+ transports: ['websocket'],
74
+ extraHeaders: {
75
+ Authorization: 'Bearer ' + this.state.accessToken,
76
+ 'x-app-token': this.state.token,
77
+ },
78
+ });
41
79
  });
42
- return socket;
43
80
  }
44
81
  }
45
82
  exports.default = WsApi;
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.157",
3
+ "version": "1.0.159",
4
4
  "description": "OneEntry NPM package",
5
5
  "main": "dist/index.js",
6
+ "module": "esm/index.js",
6
7
  "types": "dist/index.d.ts",
8
+ "sideEffects": false,
7
9
  "files": [
8
10
  "/dist",
11
+ "/esm",
12
+ "/types.js",
13
+ "/types.d.ts",
9
14
  "/changelog.md"
10
15
  ],
11
16
  "bin": {