oneentry 1.0.139 → 1.0.140

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 (143) hide show
  1. package/README.md +16 -1
  2. package/configure.js +40 -21
  3. package/package.json +15 -12
  4. package/dist/admins/adminsApi.d.ts +0 -50
  5. package/dist/admins/adminsApi.js +0 -65
  6. package/dist/admins/adminsInterfaces.d.ts +0 -99
  7. package/dist/admins/adminsInterfaces.js +0 -2
  8. package/dist/admins/adminsSchemas.d.ts +0 -30
  9. package/dist/admins/adminsSchemas.js +0 -27
  10. package/dist/attribute-sets/attributeSetsApi.d.ts +0 -63
  11. package/dist/attribute-sets/attributeSetsApi.js +0 -98
  12. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +0 -187
  13. package/dist/attribute-sets/attributeSetsInterfaces.js +0 -2
  14. package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -90
  15. package/dist/attribute-sets/attributeSetsSchemas.js +0 -74
  16. package/dist/auth-provider/authProviderApi.d.ts +0 -249
  17. package/dist/auth-provider/authProviderApi.js +0 -351
  18. package/dist/auth-provider/authProviderSchemas.d.ts +0 -137
  19. package/dist/auth-provider/authProviderSchemas.js +0 -85
  20. package/dist/auth-provider/authProvidersInterfaces.d.ts +0 -417
  21. package/dist/auth-provider/authProvidersInterfaces.js +0 -2
  22. package/dist/base/asyncModules.d.ts +0 -80
  23. package/dist/base/asyncModules.js +0 -440
  24. package/dist/base/result.d.ts +0 -39
  25. package/dist/base/result.js +0 -154
  26. package/dist/base/stateModule.d.ts +0 -41
  27. package/dist/base/stateModule.js +0 -128
  28. package/dist/base/syncModules.d.ts +0 -149
  29. package/dist/base/syncModules.js +0 -549
  30. package/dist/base/utils.d.ts +0 -197
  31. package/dist/base/utils.js +0 -2
  32. package/dist/base/validation.d.ts +0 -118
  33. package/dist/base/validation.js +0 -132
  34. package/dist/blocks/blocksApi.d.ts +0 -74
  35. package/dist/blocks/blocksApi.js +0 -184
  36. package/dist/blocks/blocksInterfaces.d.ts +0 -173
  37. package/dist/blocks/blocksInterfaces.js +0 -2
  38. package/dist/blocks/blocksSchemas.d.ts +0 -187
  39. package/dist/blocks/blocksSchemas.js +0 -43
  40. package/dist/events/eventsApi.d.ts +0 -60
  41. package/dist/events/eventsApi.js +0 -97
  42. package/dist/events/eventsInterfaces.d.ts +0 -87
  43. package/dist/events/eventsInterfaces.js +0 -2
  44. package/dist/file-uploading/fileUploadingApi.d.ts +0 -88
  45. package/dist/file-uploading/fileUploadingApi.js +0 -132
  46. package/dist/file-uploading/fileUploadingInterfaces.d.ts +0 -117
  47. package/dist/file-uploading/fileUploadingInterfaces.js +0 -2
  48. package/dist/file-uploading/fileUploadingSchemas.d.ts +0 -22
  49. package/dist/file-uploading/fileUploadingSchemas.js +0 -21
  50. package/dist/forms/formsApi.d.ts +0 -42
  51. package/dist/forms/formsApi.js +0 -57
  52. package/dist/forms/formsInterfaces.d.ts +0 -132
  53. package/dist/forms/formsInterfaces.js +0 -2
  54. package/dist/forms/formsSchemas.d.ts +0 -65
  55. package/dist/forms/formsSchemas.js +0 -36
  56. package/dist/forms-data/formsDataApi.d.ts +0 -106
  57. package/dist/forms-data/formsDataApi.js +0 -189
  58. package/dist/forms-data/formsDataInterfaces.d.ts +0 -525
  59. package/dist/forms-data/formsDataInterfaces.js +0 -2
  60. package/dist/forms-data/formsDataSchemas.d.ts +0 -115
  61. package/dist/forms-data/formsDataSchemas.js +0 -86
  62. package/dist/general-types/generalTypesApi.d.ts +0 -28
  63. package/dist/general-types/generalTypesApi.js +0 -38
  64. package/dist/general-types/generalTypesInterfaces.d.ts +0 -30
  65. package/dist/general-types/generalTypesInterfaces.js +0 -2
  66. package/dist/general-types/generalTypesSchemas.d.ts +0 -50
  67. package/dist/general-types/generalTypesSchemas.js +0 -35
  68. package/dist/index.d.ts +0 -94
  69. package/dist/index.js +0 -97
  70. package/dist/integration-collections/integrationCollectionsApi.d.ts +0 -173
  71. package/dist/integration-collections/integrationCollectionsApi.js +0 -220
  72. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +0 -313
  73. package/dist/integration-collections/integrationCollectionsInterfaces.js +0 -2
  74. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -84
  75. package/dist/integration-collections/integrationCollectionsSchemas.js +0 -63
  76. package/dist/locales/localesApi.d.ts +0 -27
  77. package/dist/locales/localesApi.js +0 -37
  78. package/dist/locales/localesInterfaces.d.ts +0 -41
  79. package/dist/locales/localesInterfaces.js +0 -2
  80. package/dist/locales/localesSchemas.d.ts +0 -32
  81. package/dist/locales/localesSchemas.js +0 -26
  82. package/dist/menus/menusApi.d.ts +0 -29
  83. package/dist/menus/menusApi.js +0 -39
  84. package/dist/menus/menusInterfaces.d.ts +0 -88
  85. package/dist/menus/menusInterfaces.js +0 -4
  86. package/dist/menus/menusSchemas.d.ts +0 -16
  87. package/dist/menus/menusSchemas.js +0 -28
  88. package/dist/orders/ordersApi.d.ts +0 -126
  89. package/dist/orders/ordersApi.js +0 -169
  90. package/dist/orders/ordersInterfaces.d.ts +0 -427
  91. package/dist/orders/ordersInterfaces.js +0 -2
  92. package/dist/orders/ordersSchemas.d.ts +0 -158
  93. package/dist/orders/ordersSchemas.js +0 -120
  94. package/dist/pages/pagesApi.d.ts +0 -151
  95. package/dist/pages/pagesApi.js +0 -390
  96. package/dist/pages/pagesInterfaces.d.ts +0 -292
  97. package/dist/pages/pagesInterfaces.js +0 -2
  98. package/dist/pages/pagesSchemas.d.ts +0 -85
  99. package/dist/pages/pagesSchemas.js +0 -46
  100. package/dist/payments/paymentsApi.d.ts +0 -82
  101. package/dist/payments/paymentsApi.js +0 -121
  102. package/dist/payments/paymentsInterfaces.d.ts +0 -206
  103. package/dist/payments/paymentsInterfaces.js +0 -2
  104. package/dist/payments/paymentsSchemas.d.ts +0 -137
  105. package/dist/payments/paymentsSchemas.js +0 -78
  106. package/dist/product-statuses/productStatusesApi.d.ts +0 -47
  107. package/dist/product-statuses/productStatusesApi.js +0 -70
  108. package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -66
  109. package/dist/product-statuses/productStatusesInterfaces.js +0 -2
  110. package/dist/product-statuses/productStatusesSchemas.d.ts +0 -34
  111. package/dist/product-statuses/productStatusesSchemas.js +0 -30
  112. package/dist/products/productsApi.d.ts +0 -364
  113. package/dist/products/productsApi.js +0 -455
  114. package/dist/products/productsInterfaces.d.ts +0 -583
  115. package/dist/products/productsInterfaces.js +0 -2
  116. package/dist/products/productsSchemas.d.ts +0 -212
  117. package/dist/products/productsSchemas.js +0 -85
  118. package/dist/system/systemApi.d.ts +0 -65
  119. package/dist/system/systemApi.js +0 -82
  120. package/dist/system/systemInterfaces.d.ts +0 -23
  121. package/dist/system/systemInterfaces.js +0 -2
  122. package/dist/templates/templatesApi.d.ts +0 -49
  123. package/dist/templates/templatesApi.js +0 -75
  124. package/dist/templates/templatesInterfaces.d.ts +0 -70
  125. package/dist/templates/templatesInterfaces.js +0 -2
  126. package/dist/templates/templatesSchemas.d.ts +0 -48
  127. package/dist/templates/templatesSchemas.js +0 -31
  128. package/dist/templates-preview/templatesPreviewApi.d.ts +0 -38
  129. package/dist/templates-preview/templatesPreviewApi.js +0 -53
  130. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -121
  131. package/dist/templates-preview/templatesPreviewInterfaces.js +0 -2
  132. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -83
  133. package/dist/templates-preview/templatesPreviewSchemas.js +0 -48
  134. package/dist/users/usersApi.d.ts +0 -143
  135. package/dist/users/usersApi.js +0 -174
  136. package/dist/users/usersInterfaces.d.ts +0 -235
  137. package/dist/users/usersInterfaces.js +0 -2
  138. package/dist/users/usersSchemas.d.ts +0 -38
  139. package/dist/users/usersSchemas.js +0 -28
  140. package/dist/web-socket/wsApi.d.ts +0 -25
  141. package/dist/web-socket/wsApi.js +0 -45
  142. package/dist/web-socket/wsInterfaces.d.ts +0 -17
  143. package/dist/web-socket/wsInterfaces.js +0 -2
package/README.md CHANGED
@@ -18,6 +18,16 @@ To install the OneEntry SDK in your project, run the following command:
18
18
  npm install oneentry
19
19
  ```
20
20
 
21
+ ## Quick Start with CLI
22
+
23
+ After installation, run the interactive setup tool to generate a working example and see live data from your project:
24
+
25
+ ```bash
26
+ npx oneentry
27
+ ```
28
+
29
+ It will ask for your project URL and API token, generate an `example.mjs` file, and optionally run it immediately — printing admins, pages and products to the console.
30
+
21
31
  ## Get Started
22
32
 
23
33
  To use the OneEntry SDK in your project, import the defineOneEntry function:
@@ -33,18 +43,21 @@ const {
33
43
  AttributesSets,
34
44
  AuthProvider,
35
45
  Blocks,
46
+ Discounts,
36
47
  Events,
48
+ FileUploading,
37
49
  Forms,
38
50
  FormData,
39
- FileUploading,
40
51
  GeneralTypes,
41
52
  IntegrationCollections,
42
53
  Locales,
43
54
  Menus,
44
55
  Orders,
45
56
  Pages,
57
+ Payments,
46
58
  Products,
47
59
  ProductStatuses,
60
+ Sitemap,
48
61
  System,
49
62
  Templates,
50
63
  TemplatePreviews,
@@ -202,6 +215,7 @@ Now you can use the following links to jump to specific entries documentation:
202
215
  - [AttributesSets](https://js-sdk.oneentry.cloud/docs/category/attributessets)
203
216
  - [AuthProvider](https://js-sdk.oneentry.cloud/docs/category/authprovider)
204
217
  - [Blocks](https://js-sdk.oneentry.cloud/docs/category/blocks)
218
+ - [Discounts](https://js-sdk.oneentry.cloud/docs/category/discounts)
205
219
  - [Events](https://js-sdk.oneentry.cloud/docs/category/events)
206
220
  - [FileUploading](https://js-sdk.oneentry.cloud/docs/category/fileuploading)
207
221
  - [Forms](https://js-sdk.oneentry.cloud/docs/category/forms-1)
@@ -215,6 +229,7 @@ Now you can use the following links to jump to specific entries documentation:
215
229
  - [Payments](https://js-sdk.oneentry.cloud/docs/category/payments)
216
230
  - [ProductStatuses](https://js-sdk.oneentry.cloud/docs/category/productstatuses)
217
231
  - [Products](https://js-sdk.oneentry.cloud/docs/category/products-1)
232
+ - [Sitemap](https://js-sdk.oneentry.cloud/docs/category/sitemap)
218
233
  - [System](https://js-sdk.oneentry.cloud/docs/category/system)
219
234
  - [Templates](https://js-sdk.oneentry.cloud/docs/category/templates)
220
235
  - [TemplatePreviews](https://js-sdk.oneentry.cloud/docs/category/templatepreviews)
package/configure.js CHANGED
@@ -22,50 +22,69 @@
22
22
  /* eslint-disable @typescript-eslint/no-require-imports */
23
23
 
24
24
  const fs = require('fs');
25
- // const path = require('path');
26
-
27
25
  const readline = require('readline');
26
+ const { spawn } = require('child_process');
28
27
 
29
28
  const rl = readline.createInterface({
30
29
  input: process.stdin,
31
30
  output: process.stdout,
32
31
  });
33
32
 
34
- rl.question('Enter project name with https://... : ', (name) => {
33
+ rl.question('Enter project name with https://... : ', (url) => {
35
34
  rl.question('Enter token: ', (token) => {
36
- rl.close();
37
- createInterface(name, token);
35
+ rl.question('Run example after creating? (y/n): ', (answer) => {
36
+ rl.close();
37
+ createInterface(url, token, answer.trim().toLowerCase() === 'y');
38
+ });
38
39
  });
39
40
  });
40
41
 
41
42
  /**
42
- * Creates an example TypeScript interface file with SDK configuration
43
- *
44
- * Generates an example.ts file containing a BuildInterface type and
45
- * IAttributesList interface with the provided project name and token.
43
+ * Creates an example JavaScript file with SDK initialization and sample requests
46
44
  *
47
- * @param {string} name - Project URL with https:// (e.g., "https://example.oneentry.cloud")
45
+ * Generates an example.mjs file with a ready-to-use defineOneEntry call
46
+ * that fetches admins, pages and products and prints them to the console.
47
+ * Run with: node example.mjs
48
+ * @param {string} url - Project URL with https:// (e.g., "https://example.oneentry.cloud")
48
49
  * @param {string} token - Authentication token for API access
50
+ * @param {boolean} run - Whether to run the generated file immediately
49
51
  */
50
- function createInterface(name, token) {
51
- const filePath = 'example.ts';
52
+ function createInterface(url, token, run) {
53
+ const filePath = 'example.mjs';
54
+ const tokenLine = token ? `\n token: '${token}',` : '';
52
55
  fs.writeFile(
53
56
  filePath,
54
- `
55
- type BuildInterface<T extends string[]> = {
56
- [K in T[number]]: string | undefined;
57
- }
58
- interface IAttributesList extends BuildInterface<['${name}', '${token}', 'value3']> {}
59
- export {
60
- IAttributesList
61
- }
62
- `,
57
+ `import { defineOneEntry } from 'oneentry';
58
+
59
+ const { Admins, Pages, Products } = defineOneEntry('${url}', {${tokenLine}
60
+ langCode: 'en_US',
61
+ });
62
+
63
+ const [admins, pages, products] = await Promise.all([
64
+ Admins.getAdminsInfo(),
65
+ Pages.getPages(),
66
+ Products.getProducts(),
67
+ ]);
68
+
69
+ console.log('Admins:', JSON.stringify(admins, null, 2));
70
+ console.log('Pages:', JSON.stringify(pages, null, 2));
71
+ console.log('Products:', JSON.stringify(products, null, 2));
72
+ `,
63
73
  (err) => {
64
74
  if (err) {
65
75
  console.error(err);
66
76
  return;
67
77
  }
68
78
  console.log(`Successfully created ${filePath}`);
79
+ if (!run) {
80
+ console.log(`Run it with: node ${filePath}`);
81
+ return;
82
+ }
83
+ console.log(`Running ${filePath}...\n`);
84
+ const child = spawn('node', [filePath], { stdio: 'inherit' });
85
+ child.on('error', (e) =>
86
+ console.error('Failed to run script:', e.message),
87
+ );
69
88
  },
70
89
  );
71
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.139",
3
+ "version": "1.0.140",
4
4
  "description": "OneEntry NPM package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "productionBuild": "run-s lint testAll build",
12
- "testAll": "run-s admins attributesets authProvider blocks events fileuploading forms formsdata generaltypes integrationcollections locales menus orders pages payments productstatuses products templates templatespreview users",
12
+ "testAll": "run-s admins attributesets authProvider blocks discounts events fileuploading forms formsdata generaltypes integrationcollections locales menus orders pages payments productstatuses products templates templatespreview users",
13
13
  "admins": "npx jest src/admins/tests/admins.spec.ts",
14
14
  "update admins": "npx jest src/admins/tests/admins.spec.ts --updateSnapshot",
15
15
  "attributesets": "npx jest src/attribute-sets/tests/attributesets.spec.ts",
@@ -18,6 +18,8 @@
18
18
  "update authProvider": "npx jest src/auth-provider/tests/authProvider.spec.ts --updateSnapshot",
19
19
  "blocks": "npx jest src/blocks/tests/blocks.spec.ts",
20
20
  "update blocks": "npx jest src/blocks/tests/blocks.spec.ts --updateSnapshot",
21
+ "discounts": "npx jest src/discounts/tests/discounts.spec.ts",
22
+ "update discounts": "npx jest src/discounts/tests/discounts.spec.ts --updateSnapshot",
21
23
  "events": "npx jest src/events/tests/events.spec.ts",
22
24
  "update events": "npx jest src/events/tests/events.spec.ts --updateSnapshot",
23
25
  "fileuploading": "npx jest src/file-uploading/tests/fileuploading.spec.ts",
@@ -44,6 +46,8 @@
44
46
  "update productstatuses": "npx jest src/product-statuses/tests/productstatuses.spec.ts --updateSnapshot",
45
47
  "products": "npx jest src/products/tests/products.spec.ts",
46
48
  "update products": "npx jest src/products/tests/products.spec.ts --updateSnapshot",
49
+ "sitemap": "npx jest src/sitemap/tests/sitemap.spec.ts",
50
+ "update sitemap": "npx jest src/sitemap/tests/sitemap.spec.ts --updateSnapshot",
47
51
  "templates": "npx jest src/templates/tests/templates.spec.ts",
48
52
  "update templates": "npx jest src/templates/tests/templates.spec.ts --updateSnapshot",
49
53
  "templatespreview": "npx jest src/templates-preview/tests/templatespreview.spec.ts",
@@ -53,7 +57,7 @@
53
57
  "lint": "npx eslint .",
54
58
  "tsc": "npx tsc --noEmit --watch false",
55
59
  "lintFix": "npx eslint . --fix",
56
- "build": "npx tsc",
60
+ "build": "npx tsc && node scripts/copy-to-output.js",
57
61
  "updateSnapshots": "npx jest --updateSnapshot"
58
62
  },
59
63
  "bin": {
@@ -62,27 +66,26 @@
62
66
  "author": "ONEENTRY PORTAL CO.",
63
67
  "license": "ISC",
64
68
  "dependencies": {
65
- "io": "^1.5.8",
66
69
  "socket.io-client": "^4.8.3",
67
70
  "zod": "^4.3.6"
68
71
  },
69
72
  "devDependencies": {
70
- "@eslint/eslintrc": "^3.3.3",
71
- "@jest/globals": "^30.2.0",
73
+ "@eslint/eslintrc": "^3.3.5",
74
+ "@jest/globals": "^30.3.0",
72
75
  "@types/eslint-config-prettier": "^6.11.3",
73
76
  "@types/jest": "^30.0.0",
74
- "@types/node": "^25.2.3",
75
- "@typescript-eslint/eslint-plugin": "^8.55.0",
76
- "@typescript-eslint/parser": "^8.55.0",
77
- "eslint": "^9.39.2",
77
+ "@types/node": "^25.4.0",
78
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
79
+ "@typescript-eslint/parser": "^8.57.0",
80
+ "eslint": "^9.39.4",
78
81
  "eslint-config-prettier": "^10.1.8",
79
82
  "eslint-plugin-import": "^2.32.0",
80
83
  "eslint-plugin-jest": "^29.15.0",
81
84
  "eslint-plugin-jest-extended": "^3.0.1",
82
- "eslint-plugin-jsdoc": "^62.5.5",
85
+ "eslint-plugin-jsdoc": "^62.7.1",
83
86
  "eslint-plugin-prettier": "^5.5.5",
84
87
  "eslint-plugin-simple-import-sort": "^12.1.1",
85
- "jest": "^30.2.0",
88
+ "jest": "^30.3.0",
86
89
  "jest-extended": "^7.0.0",
87
90
  "jsdoc": "^4.0.5",
88
91
  "npm-run-all": "^4.1.5",
@@ -1,50 +0,0 @@
1
- import AsyncModules from '../base/asyncModules';
2
- import type StateModule from '../base/stateModule';
3
- import type { AttributeType, IError } from '../base/utils';
4
- import type { IAdminEntity, IAdmins } from './adminsInterfaces';
5
- /**
6
- * Controllers for working with users - admins.
7
- * @class AdminsApi
8
- * @augments AsyncModules
9
- * @implements {IAdmins}
10
- * @description This module provides methods for working with users - admins, including retrieving information about all admins.
11
- */
12
- export default class AdminsApi extends AsyncModules implements IAdmins {
13
- protected state: StateModule;
14
- protected _url: string;
15
- /**
16
- * Initializes the AdminsApi with the provided state module.
17
- * @class
18
- * @class AdminsApi
19
- * @param {StateModule} state - The state module containing configuration data.
20
- * @description Constructor initializes the AdminsApi with a given state.
21
- */
22
- constructor(state: StateModule);
23
- /**
24
- * Get all admins objects with filters.
25
- * @handleName getAdminsInfo
26
- * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
27
- * @example
28
- [
29
- {
30
- "attributeMarker": "num",
31
- "conditionMarker": "mth",
32
- "conditionValue": 1
33
- },
34
- {
35
- "attributeMarker": "num",
36
- "conditionMarker": "lth",
37
- "conditionValue": 3
38
- }
39
- ]
40
- * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
41
- * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
42
- * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
43
- * @param {string} [langCode] - Language code. Default: "en_US".
44
- * @param {number} [offset] - Parameter for pagination. Default: 0.
45
- * @param {number} [limit] - Parameter for pagination. Default: 30.
46
- * @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
47
- * @throws {IError} When isShell=false and an error occurs during the fetch
48
- */
49
- getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
50
- }
@@ -1,65 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
- const adminsSchemas_1 = require("./adminsSchemas");
8
- /**
9
- * Controllers for working with users - admins.
10
- * @class AdminsApi
11
- * @augments AsyncModules
12
- * @implements {IAdmins}
13
- * @description This module provides methods for working with users - admins, including retrieving information about all admins.
14
- */
15
- class AdminsApi extends asyncModules_1.default {
16
- /**
17
- * Initializes the AdminsApi with the provided state module.
18
- * @class
19
- * @class AdminsApi
20
- * @param {StateModule} state - The state module containing configuration data.
21
- * @description Constructor initializes the AdminsApi with a given state.
22
- */
23
- constructor(state) {
24
- super(state);
25
- this._url = state.url + '/api/content/admins/all';
26
- }
27
- /**
28
- * Get all admins objects with filters.
29
- * @handleName getAdminsInfo
30
- * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
31
- * @example
32
- [
33
- {
34
- "attributeMarker": "num",
35
- "conditionMarker": "mth",
36
- "conditionValue": 1
37
- },
38
- {
39
- "attributeMarker": "num",
40
- "conditionMarker": "lth",
41
- "conditionValue": 3
42
- }
43
- ]
44
- * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
45
- * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
46
- * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
47
- * @param {string} [langCode] - Language code. Default: "en_US".
48
- * @param {number} [offset] - Parameter for pagination. Default: 0.
49
- * @param {number} [limit] - Parameter for pagination. Default: 30.
50
- * @returns {Promise<IAdminEntity[] | IError>} Returns an array of admin objects.
51
- * @throws {IError} When isShell=false and an error occurs during the fetch
52
- */
53
- async getAdminsInfo(body = [], langCode = this.state.lang, offset = 0, limit = 30) {
54
- const query = {
55
- langCode,
56
- offset,
57
- limit,
58
- };
59
- const response = await this._fetchPost(`?` + this._queryParamsToString(query), body);
60
- // Validate response if validation is enabled
61
- const validated = this._validateResponse(response, adminsSchemas_1.AdminsResponseSchema);
62
- return this._normalizeData(validated, langCode);
63
- }
64
- }
65
- exports.default = AdminsApi;
@@ -1,99 +0,0 @@
1
- import type { AttributeType, IAttributeValues, IError } from '../base/utils';
2
- /**
3
- * @interface IAdmins
4
- * @property {Function} getAdminsInfo - Method to retrieve all admin user objects.
5
- * @description This interface defines the contract for any class that implements it
6
- */
7
- interface IAdmins {
8
- /**
9
- * Get all admins objects with filters.
10
- * @handleName getAdminsInfo
11
- * @param {AttributeType[]} [body] - Array of filter objects with search conditions. Default: [].
12
- * @example
13
- [
14
- {
15
- "attributeMarker": "num",
16
- "conditionMarker": "mth",
17
- "conditionValue": 1
18
- },
19
- {
20
- "attributeMarker": "num",
21
- "conditionMarker": "lth",
22
- "conditionValue": 3
23
- }
24
- ]
25
- * @param {string} [body.attributeMarker] - Text identifier (marker) of the attribute in the set. Example: "num".
26
- * @param {string} [body.conditionMarker] - Text identifier (marker) of the condition in the set. Example: "mth".
27
- * @param {string} [body.conditionValue] - Value of the condition. Example: 1.
28
- * @param {string} [langCode] - Language code. Default: "en_US".
29
- * @param {number} [offset] - Parameter for pagination. Default: 0.
30
- * @param {number} [limit] - Parameter for pagination. Default: 30.
31
- * @returns {IAdminEntity[]} Returns an array of admin objects.
32
- * @throws {IError} - If there is an error during the fetch operation, it will return an error object.
33
- */
34
- getAdminsInfo(body?: AttributeType[], langCode?: string, offset?: number, limit?: number): Promise<IAdminEntity[] | IError>;
35
- }
36
- /**
37
- * Interface representing a Position entity.
38
- * @interface IPosition
39
- * @property {number} id - The unique identifier of the position. Example: 1764.
40
- * @property {boolean} [isLocked] - Indicates whether the position is locked or not. Example: false.
41
- * @property {number} objectId - The unique identifier of the object. Example: 120.
42
- * @property {number} [objectCategoryId] - The unique identifier of the object's category. Example: 5.
43
- * @property {string} objectType - The type of the object. Example: "admin".
44
- * @property {number} position - The position of the object. Example: 192.
45
- * @description This interface outlines the properties associated with a position within a system.
46
- */
47
- interface IPosition {
48
- id: number;
49
- isLocked?: boolean;
50
- objectId: number;
51
- objectCategoryId?: number;
52
- objectType: string;
53
- position: number;
54
- }
55
- /**
56
- * Interface representing an Admin Entity.
57
- * @interface IAdminEntity
58
- * @property {number} id - The identifier of the object. Example: 1764.
59
- * @property {number | null} attributeSetId - The identifier of the attribute set being used. Example: 120.
60
- * @property {string} identifier - The textual identifier for the record field. Example: "admin1".
61
- * @property {string | null} attributeSetIdentifier - The identifier of the attribute set. Example: "admins".
62
- * @property {number | null} position - Position number (for sorting). Example: 1.
63
- * @property {boolean} isSync - Page indexing flag (true or false). Example: true.
64
- * @property {IAttributeValues} attributeValues - Array of attribute values from the index (presented as a pair of user attribute identifier: attribute value).
65
- * @example
66
- [
67
- {
68
- "marker": {
69
- "type": "string",
70
- "value": "Some value"
71
- }
72
- }
73
- ]
74
- * @description This interface captures the essential details and additional attributes of an admin entity.
75
- */
76
- interface IAdminEntity {
77
- id: number;
78
- attributeSetId: number | null;
79
- identifier: string;
80
- attributeSetIdentifier: string | null;
81
- position: number | null;
82
- isSync: boolean;
83
- attributeValues: IAttributeValues;
84
- [key: string]: any;
85
- }
86
- /**
87
- * Interface representing a query for fetching admin data.
88
- * @interface IAdminQuery
89
- * @property {string} langCode - Language code. Default: "en_US".
90
- * @property {number} limit - Parameter for pagination. Default: 30.
91
- * @property {number} offset - Parameter for pagination. Default: 0.
92
- * @description This interface defines the parameters required for querying admin data, including optional defaults.
93
- */
94
- interface IAdminQuery {
95
- langCode: string;
96
- limit: number;
97
- offset: number;
98
- }
99
- export type { IAdminEntity, IAdminQuery, IAdmins, IPosition };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,30 +0,0 @@
1
- /**
2
- * Validation schemas for Admins module
3
- * @description Zod schemas for validating admins-related API responses
4
- */
5
- import { z } from 'zod';
6
- /**
7
- * Admin entity schema
8
- * Includes all fields returned by the API
9
- */
10
- export declare const AdminEntitySchema: z.ZodObject<{
11
- id: z.ZodNumber;
12
- attributeSetId: z.ZodNullable<z.ZodNumber>;
13
- identifier: z.ZodString;
14
- attributeSetIdentifier: z.ZodNullable<z.ZodString>;
15
- position: z.ZodNullable<z.ZodNumber>;
16
- isSync: z.ZodBoolean;
17
- attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
18
- }, z.core.$catchall<z.ZodAny>>;
19
- /**
20
- * Admins response schema (array of admin entities)
21
- */
22
- export declare const AdminsResponseSchema: z.ZodArray<z.ZodObject<{
23
- id: z.ZodNumber;
24
- attributeSetId: z.ZodNullable<z.ZodNumber>;
25
- identifier: z.ZodString;
26
- attributeSetIdentifier: z.ZodNullable<z.ZodString>;
27
- position: z.ZodNullable<z.ZodNumber>;
28
- isSync: z.ZodBoolean;
29
- attributeValues: z.ZodRecord<z.ZodString, z.ZodAny>;
30
- }, z.core.$catchall<z.ZodAny>>>;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdminsResponseSchema = exports.AdminEntitySchema = void 0;
4
- /**
5
- * Validation schemas for Admins module
6
- * @description Zod schemas for validating admins-related API responses
7
- */
8
- const zod_1 = require("zod");
9
- /**
10
- * Admin entity schema
11
- * Includes all fields returned by the API
12
- */
13
- exports.AdminEntitySchema = zod_1.z
14
- .object({
15
- id: zod_1.z.number(),
16
- attributeSetId: zod_1.z.number().nullable(),
17
- identifier: zod_1.z.string(),
18
- attributeSetIdentifier: zod_1.z.string().nullable(),
19
- position: zod_1.z.number().nullable(),
20
- isSync: zod_1.z.boolean(),
21
- attributeValues: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
22
- })
23
- .catchall(zod_1.z.any()); // Allow additional dynamic properties
24
- /**
25
- * Admins response schema (array of admin entities)
26
- */
27
- exports.AdminsResponseSchema = zod_1.z.array(exports.AdminEntitySchema);
@@ -1,63 +0,0 @@
1
- import AsyncModules from '../base/asyncModules';
2
- import type StateModule from '../base/stateModule';
3
- import type { IError } from '../base/utils';
4
- import type { IAttributeSetsEntity, IAttributesSets, IAttributesSetsEntity, IAttributesSetsResponse } from './attributeSetsInterfaces';
5
- /**
6
- * Controllers for working with attributes - AttributesSetsApi.
7
- * @class AttributesSetsApi
8
- * @augments AsyncModules
9
- * @implements {IAttributesSets}
10
- * @description This class provides methods to interact with attribute sets, including fetching attributes, getting attributes by marker, and retrieving single attributes by marker and set.
11
- */
12
- export default class AttributesSetsApi extends AsyncModules implements IAttributesSets {
13
- protected state: StateModule;
14
- protected _url: string;
15
- /**
16
- * Initializes the AttributesSetsApi with the provided state module.
17
- * @class
18
- * @class AttributesSetsApi
19
- * @param {StateModule} state - The state module containing configuration data.
20
- * @description Constructor initializes the AttributesSetsApi with a given state.
21
- */
22
- constructor(state: StateModule);
23
- /**
24
- * Getting all attribute sets objects.
25
- * @handleName getAttributes
26
- * @param {string} [langCode] - Language code. Default: "en_US".
27
- * @param {number} [offset] - parameter offset of record selection. Default: 0.
28
- * @param {number} [limit] - parameter limiting the selection of records. Default: 30.
29
- * @param {number} [typeId] - identifier of the attribute set type. Default: null.
30
- * @param {string} [sortBy] - identifier of the attribute set type. Default: "id".
31
- * @returns {Promise<IAttributesSetsResponse | IError>} Returns object with array of IAttributeSetsEntity and total items count.
32
- * @throws {IError} When isShell=false and an error occurs during the fetch
33
- */
34
- getAttributes(langCode?: string, offset?: number, limit?: number, typeId?: any, sortBy?: string): Promise<IAttributesSetsResponse | IError>;
35
- /**
36
- * Getting all attributes with data from the attribute set.
37
- * @handleName getAttributesByMarker
38
- * @param {string} marker - Attribute marker. Example: "productAttributes".
39
- * @param {string} [langCode] - Language code. Default: "en_US".
40
- * @returns {Promise<IAttributeSetsEntity[] | IError>} Returns an array of Attributes objects.
41
- * @throws {IError} When isShell=false and an error occurs during the fetch
42
- */
43
- getAttributesByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity[] | IError>;
44
- /**
45
- * Get a single attribute with data from the attribute sets.
46
- * @handleName getSingleAttributeByMarkerSet
47
- * @param {string} setMarker - Text identifier (marker) of the attribute set. Example: "productAttributes".
48
- * @param {string} attributeMarker - Text identifier (marker) of the attribute in the set. Example: "color".
49
- * @param {string} [langCode] - Language code. Default: "en_US".
50
- * @returns {Promise<IAttributesSetsEntity | IError>} Returns a single attribute object from the attribute set.
51
- * @throws {IError} When isShell=false and an error occurs during the fetch
52
- */
53
- getSingleAttributeByMarkerSet(setMarker: string, attributeMarker: string, langCode?: string): Promise<IAttributesSetsEntity | IError>;
54
- /**
55
- * Getting a single object from a set of attributes by marker.
56
- * @handleName getAttributeSetByMarker
57
- * @param {string} marker - marker of the attribute set object. Example: "productAttributes".
58
- * @param {string} [langCode] - Language code. Default: "en_US".
59
- * @returns {Promise<IAttributeSetsEntity | IError>} Returns one object of the attribute set.
60
- * @throws {IError} When isShell=false and an error occurs during the fetch
61
- */
62
- getAttributeSetByMarker(marker: string, langCode?: string): Promise<IAttributeSetsEntity | IError>;
63
- }