oneentry 1.0.158 → 1.0.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -175,12 +175,32 @@ const api = defineOneEntry('your-url', {
175
175
  })
176
176
  ```
177
177
 
178
+ ## TypeScript Types
179
+
180
+ All public interfaces and types are re-exported from the package root, so deep paths are not needed:
181
+
182
+ ```ts
183
+ import type { IAttributeSchemaItem, IAttributeSetsEntity } from 'oneentry'
184
+ ```
185
+
186
+ The same set is also available from a types-only entry point, if you prefer to keep type imports separate from the runtime import:
187
+
188
+ ```ts
189
+ import type { IProductsEntity, IUserEntity } from 'oneentry/types'
190
+ ```
191
+
192
+ Deep imports such as `oneentry/dist/attribute-sets/attributeSetsInterfaces` still work and remain supported.
193
+
178
194
  ## Optional Features
179
195
 
180
196
  ### API Response Validation
181
197
 
182
198
  OneEntry SDK supports optional validation of API responses using Zod. This feature is disabled by default and can be enabled for development or critical operations.
183
199
 
200
+ Zod and the response schemas are loaded on demand, the first time a response actually has to be validated. Leaving validation off — the default — keeps them out of the code your app loads. Socket.io is deferred the same way, until the first `WS.connect()`.
201
+
202
+ Together that means a project calling a single SDK method loads about **43 kB minified (9.7 kB gzip)** instead of 536 kB, with Zod, the schemas and Socket.io landing in chunks that are never requested. The SDK is published as both CommonJS and ESM (`sideEffects: false`), so bundlers can tree-shake the rest.
203
+
184
204
  ### Time Intervals
185
205
 
186
206
  Attributes of type `timeInterval` return a compact recurrence rule (an anchor date, daily time ranges and repeat flags), not a ready list of slots. The SDK does not expand it eagerly — a single attribute can materialize into megabytes of slots — so resolve it on demand with `expandAttributeTimeIntervals`, passing the window you actually render:
package/changelog.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # SDK Change Log
2
2
 
3
+ ## v.1.0.160
4
+
5
+ > Re-release of v.1.0.159. The 1.0.159 tarball was published from a stale build directory: the files changed by that release were updated, but the files it added (`dist/base/lazySchema.js`, `dist/web-socket/lazySocket.js`, `dist/types.js`, the root `types.js` / `types.d.ts` stubs and the whole `esm/` build) never made it into the package, so `require('oneentry')` threw `Cannot find module '../base/lazySchema'`. Use 1.0.160 instead — same feature set, complete build.
6
+
7
+ ### Packaging
8
+
9
+ Beyond the missing files, the packaging of 1.0.159 is now correct for every way the SDK can be consumed:
10
+
11
+ - **The ESM build is loadable by Node**, not only by bundlers. It used to be emitted with extensionless relative imports (`import './adminsSchemas'`) and no module marker, so the Node ESM loader could neither resolve those paths nor treat the files as ESM. The build now emits full specifiers and an `esm/package.json` with `{"type": "module"}`.
12
+ - **The ESM build ships its own type declarations**, so `import` resolves ESM types and `require` resolves CommonJS ones instead of both sharing the CommonJS set.
13
+ - **An `exports` map** now routes `oneentry` and `oneentry/types` to the right build per condition. Deep imports (`oneentry/dist/<module>/<module>Interfaces`) are covered by explicit patterns and keep working, in both the bare and the `.js` spelling, as do `main` / `module` / `types` for resolvers that ignore `exports`. Verified against `moduleResolution` `node`, `node16` (CommonJS and ESM) and `bundler`.
14
+ - **The published `dependencies` are taken from the repository's `package.json`**, so the declared ranges can no longer drift from the ones the SDK is built and tested against.
15
+ - **`npm run build` wipes `output/` first**, and the new `npm run smoke` packs the result and exercises the tarball as a consumer would — every deep path through `require` and `import`, both entry points, and a type check under the four resolution modes. It runs as part of `productionBuild`.
16
+
17
+ ### What's New
18
+
19
+ - All public types are now re-exported from the package root and from a new `oneentry/types` entry point, so deep paths are no longer required:
20
+
21
+ ```ts
22
+ // before
23
+ import type { IAttributeSchemaItem, IAttributeSetsEntity } from 'oneentry/dist/attribute-sets/attributeSetsInterfaces';
24
+
25
+ // now — either of these
26
+ import type { IAttributeSchemaItem, IAttributeSetsEntity } from 'oneentry';
27
+ import type { IAttributeSchemaItem, IAttributeSetsEntity } from 'oneentry/types';
28
+ ```
29
+
30
+ Every interface and type of every module (`base/utils` included) is available under both entry points. Old `oneentry/dist/<module>/<module>Interfaces` imports keep working — nothing is removed.
31
+
32
+ - The package now ships an ESM build alongside the CommonJS one (`"module": "esm/index.js"`, `"sideEffects": false`), so bundlers can tree-shake the SDK. Node keeps resolving the CommonJS build through `"main"` — there is no `"exports"` map, so every existing deep import resolves exactly as before.
33
+
34
+ ### What's Changed
35
+
36
+ - **Zod is no longer part of the import graph unless validation is enabled.** Response schemas used to be imported statically by every `*Api` module, which pulled Zod into every consumer's bundle even though `validation.enabled` defaults to `false`. Schemas and the validation helpers are now loaded on demand, the first time a response actually has to be validated.
37
+
38
+ For a project that calls a single method and leaves validation off, the code that actually loads drops from **536 kB to 83 kB** minified (110 kB → 22 kB gzip): Zod and the per-module schemas (341 kB) end up in chunks that are never requested. That figure assumes a bundler doing code splitting — the default in webpack, Vite and Rollup. A bundle forced into a single file still shrinks, but only to ~427 kB, since Zod is then inlined even though it never runs.
39
+
40
+ With `validation.enabled: true` the behaviour is unchanged; the schemas are simply fetched when first needed. In Node, `require('oneentry')` no longer loads Zod at startup either.
41
+
42
+ No public API changed. The internal `_validateResponse` helper became `async` — relevant only if you extended the SDK's base classes yourself.
43
+
44
+ - **Socket.io is no longer bundled unless you open a socket.** `WS.connect()` keeps its synchronous signature and still returns a `Socket`, but `socket.io-client` (~41 kB) is now imported the first time `connect()` is called. Until the chunk resolves, the returned object queues whatever you do with it — `on`, `emit`, `disconnect` — and replays it onto the real socket in the same tick it is created, before the connection can deliver anything, so no event is lost.
45
+
46
+ Reading connection state early stays accurate, because a freshly created socket is not connected either: `id` is `undefined` and `connected` is `false` in both the old and the new behaviour. The one difference: a method that has to *return* something (e.g. `listeners()`) cannot answer before the chunk arrives, and nested objects such as `socket.io` are reachable only once loaded. Registering handlers and emitting — the normal use — is unaffected.
47
+
48
+ Together with the Zod change, a project that calls one method and never opens a socket now loads **43 kB minified (9.7 kB gzip), down from 536 kB (110 kB gzip)**.
49
+
3
50
  ## v.1.0.158
4
51
 
5
52
  ### What's New
@@ -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 adminsSchemas_1 = require("./adminsSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./adminsSchemas'))));
8
42
  /**
9
43
  * Controllers for working with users - admins.
10
44
  * @class AdminsApi
@@ -59,7 +93,7 @@ class AdminsApi extends asyncModules_1.default {
59
93
  };
60
94
  const response = await this._fetchPost(`?` + this._queryParamsToString(query), body);
61
95
  // Validate response if validation is enabled
62
- const validated = this._validateResponse(response, adminsSchemas_1.AdminsResponseSchema);
96
+ const validated = await this._validateResponse(response, schema('AdminsResponseSchema'));
63
97
  return this._normalizeData(validated, langCode);
64
98
  }
65
99
  }
@@ -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 attributeSetsSchemas_1 = require("./attributeSetsSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./attributeSetsSchemas'))));
8
42
  /**
9
43
  * Controllers for working with attributes - AttributesSetsApi.
10
44
  * @class AttributesSetsApi
@@ -49,7 +83,7 @@ class AttributesSetsApi extends asyncModules_1.default {
49
83
  };
50
84
  const result = await this._fetchGet(`?` + this._queryParamsToString(query));
51
85
  // Validate response if validation is enabled
52
- const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetsResponseSchema);
86
+ const validated = await this._validateResponse(result, schema('AttributeSetsResponseSchema'));
53
87
  return this._normalizeData(validated, langCode);
54
88
  }
55
89
  /**
@@ -64,7 +98,7 @@ class AttributesSetsApi extends asyncModules_1.default {
64
98
  async getAttributesByMarker(marker, langCode = this.state.lang) {
65
99
  const result = await this._fetchGet(`/${marker}/attributes?langCode=${langCode}`);
66
100
  // Validate response if validation is enabled
67
- const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributesArrayResponseSchema);
101
+ const validated = await this._validateResponse(result, schema('AttributesArrayResponseSchema'));
68
102
  return this._normalizeData(validated, langCode);
69
103
  }
70
104
  /**
@@ -80,7 +114,7 @@ class AttributesSetsApi extends asyncModules_1.default {
80
114
  async getSingleAttributeByMarkerSet(setMarker, attributeMarker, langCode = this.state.lang) {
81
115
  const result = await this._fetchGet(`/${setMarker}/attributes/${attributeMarker}?langCode=${langCode}`);
82
116
  // Validate response if validation is enabled
83
- const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeEntitySchema);
117
+ const validated = await this._validateResponse(result, schema('AttributeEntitySchema'));
84
118
  return this._normalizeData(validated, langCode);
85
119
  }
86
120
  /**
@@ -95,7 +129,7 @@ class AttributesSetsApi extends asyncModules_1.default {
95
129
  async getAttributeSetByMarker(marker, langCode = this.state.lang) {
96
130
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
97
131
  // Validate response if validation is enabled
98
- const validated = this._validateResponse(result, attributeSetsSchemas_1.AttributeSetEntitySchema);
132
+ const validated = await this._validateResponse(result, schema('AttributeSetEntitySchema'));
99
133
  return this._normalizeData(validated, langCode);
100
134
  }
101
135
  }
@@ -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 jsdoc/no-undefined-types */
7
40
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
- const authProviderSchemas_1 = require("./authProviderSchemas");
41
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
42
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./authProviderSchemas'))));
9
43
  /**
10
44
  * Controllers for working with auth services.
11
45
  * @handle /api/content/users-auth-providers
@@ -93,7 +127,7 @@ class AuthProviderApi extends asyncModules_1.default {
93
127
  body['langCode'] = langCode;
94
128
  const result = await this._fetchPost(`/marker/${marker}/users/sign-up`, this._normalizePostBody(body, langCode));
95
129
  // Validate response if validation is enabled
96
- const validated = this._validateResponse(result, authProviderSchemas_1.SignUpResponseSchema);
130
+ const validated = await this._validateResponse(result, schema('SignUpResponseSchema'));
97
131
  return this._normalizeData(validated);
98
132
  }
99
133
  /**
@@ -191,7 +225,7 @@ class AuthProviderApi extends asyncModules_1.default {
191
225
  async auth(marker, body) {
192
226
  const result = await this._fetchPost(`/marker/${marker}/users/auth`, body);
193
227
  // Validate response if validation is enabled
194
- const validated = this._validateResponse(result, authProviderSchemas_1.AuthResponseSchema);
228
+ const validated = await this._validateResponse(result, schema('AuthResponseSchema'));
195
229
  if (!('statusCode' in validated)) {
196
230
  this.state.accessToken = validated.accessToken;
197
231
  this.state.refreshToken = validated.refreshToken;
@@ -310,7 +344,7 @@ class AuthProviderApi extends asyncModules_1.default {
310
344
  async getAuthProviders(langCode = this.state.lang, offset = 0, limit = 30) {
311
345
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
312
346
  // Validate response if validation is enabled
313
- const validated = this._validateResponse(result, authProviderSchemas_1.AuthProvidersResponseSchema);
347
+ const validated = await this._validateResponse(result, schema('AuthProvidersResponseSchema'));
314
348
  return this._normalizeData(validated);
315
349
  }
316
350
  /**
@@ -29,11 +29,13 @@ export default abstract class AsyncModules extends SyncModules {
29
29
  /**
30
30
  * Validates API response against a Zod schema (optional)
31
31
  * @param {unknown} data - The data to validate
32
- * @param {z.ZodSchema<T>} [schema] - Optional Zod schema for validation
33
- * @returns {T | IError} Validated data or error object
34
- * @description Validates response data if validation is enabled in config
32
+ * @param {() => Promise<z.ZodSchema<T>>} [loadSchema] - Optional loader resolving to the Zod schema for validation
33
+ * @returns {Promise<T | IError>} Validated data or error object
34
+ * @description Validates response data if validation is enabled in config.
35
+ * The schema — and Zod itself — are imported on demand, so a project that leaves
36
+ * validation disabled (the default) never pulls Zod into its bundle.
35
37
  */
36
- protected _validateResponse<T>(data: unknown, schema?: z.ZodSchema<T>): T | IError;
38
+ protected _validateResponse<T>(data: unknown, loadSchema?: () => Promise<z.ZodSchema<T>>): Promise<T | IError>;
37
39
  /**
38
40
  * Performs an HTTP GET request.
39
41
  * @param {string} path - The path to append to the base URL.
@@ -1,10 +1,42 @@
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 syncModules_1 = __importDefault(require("./syncModules"));
7
- const validation_1 = require("./validation");
8
40
  /**
9
41
  * Abstract class AsyncModules extends SyncModules to provide asynchronous HTTP request functionalities.
10
42
  * @description Abstract class AsyncModules extends SyncModules to provide asynchronous HTTP request functionalities.
@@ -43,22 +75,26 @@ class AsyncModules extends syncModules_1.default {
43
75
  /**
44
76
  * Validates API response against a Zod schema (optional)
45
77
  * @param {unknown} data - The data to validate
46
- * @param {z.ZodSchema<T>} [schema] - Optional Zod schema for validation
47
- * @returns {T | IError} Validated data or error object
48
- * @description Validates response data if validation is enabled in config
78
+ * @param {() => Promise<z.ZodSchema<T>>} [loadSchema] - Optional loader resolving to the Zod schema for validation
79
+ * @returns {Promise<T | IError>} Validated data or error object
80
+ * @description Validates response data if validation is enabled in config.
81
+ * The schema — and Zod itself — are imported on demand, so a project that leaves
82
+ * validation disabled (the default) never pulls Zod into its bundle.
49
83
  */
50
- _validateResponse(data, schema) {
84
+ async _validateResponse(data, loadSchema) {
51
85
  // Skip validation if not enabled or no schema provided
52
- if (!this.state.validationEnabled || !schema) {
86
+ if (!this.state.validationEnabled || !loadSchema) {
53
87
  return data;
54
88
  }
55
89
  // Skip validation for error responses (statusCode indicates API error)
56
90
  if (this._isErrorResponse(data)) {
57
91
  return data;
58
92
  }
93
+ // Pull the schema and the Zod-backed validators only now that they are needed
94
+ const [schema, { validateResponse, validateResponseSafe }] = await Promise.all([loadSchema(), Promise.resolve().then(() => __importStar(require('./validation')))]);
59
95
  // Use strict or safe validation based on config
60
96
  if (this.state.validationStrictMode) {
61
- const result = (0, validation_1.validateResponse)(schema, data, {
97
+ const result = validateResponse(schema, data, {
62
98
  logErrors: this.state.validationLogErrors,
63
99
  });
64
100
  if (!result.success) {
@@ -78,7 +114,7 @@ class AsyncModules extends syncModules_1.default {
78
114
  }
79
115
  else {
80
116
  // Non-strict mode: log errors but return original data
81
- return (0, validation_1.validateResponseSafe)(schema, data, this.state.validationLogErrors);
117
+ return validateResponseSafe(schema, data, this.state.validationLogErrors);
82
118
  }
83
119
  }
84
120
  /**
@@ -1,4 +1,37 @@
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
  };
@@ -6,7 +39,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
39
  /* eslint-disable jsdoc/reject-any-type */
7
40
  /* eslint-disable @typescript-eslint/no-explicit-any */
8
41
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
9
- const blocksSchemas_1 = require("./blocksSchemas");
42
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
43
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./blocksSchemas'))));
10
44
  /**
11
45
  * Controllers for working with blocks.
12
46
  * @handle /api/content/blocks
@@ -40,7 +74,7 @@ class BlocksApi extends asyncModules_1.default {
40
74
  const query = this._queryParamsToString({ langCode, type, offset, limit });
41
75
  const response = await this._fetchPost(`?${query}`);
42
76
  // Validate response if validation is enabled
43
- const validated = this._validateResponse(response, blocksSchemas_1.BlocksResponseSchema);
77
+ const validated = await this._validateResponse(response, schema('BlocksResponseSchema'));
44
78
  if (!this.state.traficLimit) {
45
79
  const normalizeResponse = this._normalizeData(validated);
46
80
  // On API error responses (e.g. 403 without list permission, 422) the
@@ -68,7 +102,7 @@ class BlocksApi extends asyncModules_1.default {
68
102
  async getBlockByMarker(marker, langCode = this.state.lang, offset = 0, limit = 30) {
69
103
  const response = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
70
104
  // Validate response if validation is enabled
71
- const validated = this._validateResponse(response, blocksSchemas_1.BlockEntitySchema);
105
+ const validated = await this._validateResponse(response, schema('BlockEntitySchema'));
72
106
  const normalizeResponse = this._normalizeData(validated);
73
107
  await this._enrichBlock(normalizeResponse, langCode, offset, limit, !this.state.traficLimit);
74
108
  return normalizeResponse;
@@ -214,7 +248,7 @@ class BlocksApi extends asyncModules_1.default {
214
248
  async searchBlock(name, langCode = this.state.lang) {
215
249
  const result = await this._fetchGet(`/quick/search?langCode=${encodeURIComponent(langCode)}&name=${encodeURIComponent(name)}`);
216
250
  // Validate response if validation is enabled
217
- const validated = this._validateResponse(result, blocksSchemas_1.SearchBlocksResponseSchema);
251
+ const validated = await this._validateResponse(result, schema('SearchBlocksResponseSchema'));
218
252
  return validated;
219
253
  }
220
254
  /**
@@ -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
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./fileUploadingSchemas'))));
7
42
  // import { IFileEntity } from './fileUploadingInterfaces';
8
- const fileUploadingSchemas_1 = require("./fileUploadingSchemas");
9
43
  /**
10
44
  * Controllers for working with file uploading
11
45
  * @handle /api/content/files
@@ -63,7 +97,7 @@ class FileUploadingApi extends asyncModules_1.default {
63
97
  body.append('files', file);
64
98
  const result = await this._fetchPost('?' + this._queryParamsToString(query), body);
65
99
  // Validate response if validation is enabled
66
- const validated = this._validateResponse(result, fileUploadingSchemas_1.UploadResponseSchema);
100
+ const validated = await this._validateResponse(result, schema('UploadResponseSchema'));
67
101
  return validated;
68
102
  }
69
103
  /**
@@ -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 filtersSchemas_1 = require("./filtersSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./filtersSchemas'))));
8
42
  /**
9
43
  * Controllers for working with content filters.
10
44
  * @handle /api/content/filters
@@ -34,7 +68,7 @@ class FiltersApi extends asyncModules_1.default {
34
68
  */
35
69
  async getFilterByMarker(marker, langCode = this.state.lang) {
36
70
  const data = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
37
- const validated = this._validateResponse(data, filtersSchemas_1.ContentFilterSchema);
71
+ const validated = await this._validateResponse(data, schema('ContentFilterSchema'));
38
72
  return this._normalizeData(validated);
39
73
  }
40
74
  }
@@ -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 formsSchemas_1 = require("./formsSchemas");
40
+ const lazySchema_1 = __importDefault(require("../base/lazySchema"));
41
+ const schema = (0, lazySchema_1.default)(() => Promise.resolve().then(() => __importStar(require('./formsSchemas'))));
8
42
  /**
9
43
  * Controllers for forms objects
10
44
  * @class FormsApi
@@ -37,7 +71,7 @@ class FormsApi extends asyncModules_1.default {
37
71
  async getAllForms(langCode = this.state.lang, offset = 0, limit = 30) {
38
72
  const result = await this._fetchGet(`?langCode=${langCode}&offset=${offset}&limit=${limit}`);
39
73
  // Validate response if validation is enabled
40
- const validated = this._validateResponse(result, formsSchemas_1.FormsResponseSchema);
74
+ const validated = await this._validateResponse(result, schema('FormsResponseSchema'));
41
75
  return this._normalizeData(validated, langCode);
42
76
  }
43
77
  /**
@@ -52,7 +86,7 @@ class FormsApi extends asyncModules_1.default {
52
86
  async getFormByMarker(marker, langCode = this.state.lang) {
53
87
  const result = await this._fetchGet(`/marker/${marker}?langCode=${langCode}`);
54
88
  // Validate response if validation is enabled
55
- const validated = this._validateResponse(result, formsSchemas_1.FormEntitySchema);
89
+ const validated = await this._validateResponse(result, schema('FormEntitySchema'));
56
90
  return this._normalizeData(validated, langCode);
57
91
  }
58
92
  }