oneentry 1.0.141 → 1.0.142
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/configure.js +107 -15
- package/package.json +81 -3
- package/dist/admins/adminsApi.d.ts +0 -50
- package/dist/admins/adminsApi.js +0 -65
- package/dist/admins/adminsInterfaces.d.ts +0 -99
- package/dist/admins/adminsInterfaces.js +0 -2
- package/dist/admins/adminsSchemas.d.ts +0 -30
- package/dist/admins/adminsSchemas.js +0 -27
- package/dist/attribute-sets/attributeSetsApi.d.ts +0 -63
- package/dist/attribute-sets/attributeSetsApi.js +0 -98
- package/dist/attribute-sets/attributeSetsInterfaces.d.ts +0 -187
- package/dist/attribute-sets/attributeSetsInterfaces.js +0 -2
- package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -90
- package/dist/attribute-sets/attributeSetsSchemas.js +0 -74
- package/dist/auth-provider/authProviderApi.d.ts +0 -249
- package/dist/auth-provider/authProviderApi.js +0 -351
- package/dist/auth-provider/authProviderSchemas.d.ts +0 -131
- package/dist/auth-provider/authProviderSchemas.js +0 -82
- package/dist/auth-provider/authProvidersInterfaces.d.ts +0 -425
- package/dist/auth-provider/authProvidersInterfaces.js +0 -2
- package/dist/base/asyncModules.d.ts +0 -80
- package/dist/base/asyncModules.js +0 -440
- package/dist/base/result.d.ts +0 -39
- package/dist/base/result.js +0 -154
- package/dist/base/stateModule.d.ts +0 -41
- package/dist/base/stateModule.js +0 -128
- package/dist/base/syncModules.d.ts +0 -149
- package/dist/base/syncModules.js +0 -549
- package/dist/base/utils.d.ts +0 -197
- package/dist/base/utils.js +0 -2
- package/dist/base/validation.d.ts +0 -118
- package/dist/base/validation.js +0 -132
- package/dist/blocks/blocksApi.d.ts +0 -76
- package/dist/blocks/blocksApi.js +0 -188
- package/dist/blocks/blocksInterfaces.d.ts +0 -173
- package/dist/blocks/blocksInterfaces.js +0 -2
- package/dist/blocks/blocksSchemas.d.ts +0 -187
- package/dist/blocks/blocksSchemas.js +0 -43
- package/dist/discounts/discountsApi.d.ts +0 -56
- package/dist/discounts/discountsApi.js +0 -82
- package/dist/discounts/discountsInterfaces.d.ts +0 -145
- package/dist/discounts/discountsInterfaces.js +0 -2
- package/dist/events/eventsApi.d.ts +0 -60
- package/dist/events/eventsApi.js +0 -97
- package/dist/events/eventsInterfaces.d.ts +0 -87
- package/dist/events/eventsInterfaces.js +0 -2
- package/dist/file-uploading/fileUploadingApi.d.ts +0 -88
- package/dist/file-uploading/fileUploadingApi.js +0 -132
- package/dist/file-uploading/fileUploadingInterfaces.d.ts +0 -117
- package/dist/file-uploading/fileUploadingInterfaces.js +0 -2
- package/dist/file-uploading/fileUploadingSchemas.d.ts +0 -22
- package/dist/file-uploading/fileUploadingSchemas.js +0 -21
- package/dist/forms/formsApi.d.ts +0 -42
- package/dist/forms/formsApi.js +0 -57
- package/dist/forms/formsInterfaces.d.ts +0 -132
- package/dist/forms/formsInterfaces.js +0 -2
- package/dist/forms/formsSchemas.d.ts +0 -50
- package/dist/forms/formsSchemas.js +0 -31
- package/dist/forms-data/formsDataApi.d.ts +0 -106
- package/dist/forms-data/formsDataApi.js +0 -189
- package/dist/forms-data/formsDataInterfaces.d.ts +0 -525
- package/dist/forms-data/formsDataInterfaces.js +0 -2
- package/dist/forms-data/formsDataSchemas.d.ts +0 -115
- package/dist/forms-data/formsDataSchemas.js +0 -86
- package/dist/general-types/generalTypesApi.d.ts +0 -28
- package/dist/general-types/generalTypesApi.js +0 -38
- package/dist/general-types/generalTypesInterfaces.d.ts +0 -30
- package/dist/general-types/generalTypesInterfaces.js +0 -2
- package/dist/general-types/generalTypesSchemas.d.ts +0 -50
- package/dist/general-types/generalTypesSchemas.js +0 -35
- package/dist/index.d.ts +0 -100
- package/dist/index.js +0 -103
- package/dist/integration-collections/integrationCollectionsApi.d.ts +0 -173
- package/dist/integration-collections/integrationCollectionsApi.js +0 -220
- package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +0 -313
- package/dist/integration-collections/integrationCollectionsInterfaces.js +0 -2
- package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -80
- package/dist/integration-collections/integrationCollectionsSchemas.js +0 -61
- package/dist/locales/localesApi.d.ts +0 -27
- package/dist/locales/localesApi.js +0 -37
- package/dist/locales/localesInterfaces.d.ts +0 -41
- package/dist/locales/localesInterfaces.js +0 -2
- package/dist/locales/localesSchemas.d.ts +0 -32
- package/dist/locales/localesSchemas.js +0 -26
- package/dist/menus/menusApi.d.ts +0 -29
- package/dist/menus/menusApi.js +0 -39
- package/dist/menus/menusInterfaces.d.ts +0 -88
- package/dist/menus/menusInterfaces.js +0 -4
- package/dist/menus/menusSchemas.d.ts +0 -16
- package/dist/menus/menusSchemas.js +0 -28
- package/dist/orders/ordersApi.d.ts +0 -149
- package/dist/orders/ordersApi.js +0 -203
- package/dist/orders/ordersInterfaces.d.ts +0 -527
- package/dist/orders/ordersInterfaces.js +0 -2
- package/dist/orders/ordersSchemas.d.ts +0 -120
- package/dist/orders/ordersSchemas.js +0 -101
- package/dist/pages/pagesApi.d.ts +0 -151
- package/dist/pages/pagesApi.js +0 -390
- package/dist/pages/pagesInterfaces.d.ts +0 -292
- package/dist/pages/pagesInterfaces.js +0 -2
- package/dist/pages/pagesSchemas.d.ts +0 -85
- package/dist/pages/pagesSchemas.js +0 -46
- package/dist/payments/paymentsApi.d.ts +0 -82
- package/dist/payments/paymentsApi.js +0 -121
- package/dist/payments/paymentsInterfaces.d.ts +0 -206
- package/dist/payments/paymentsInterfaces.js +0 -2
- package/dist/payments/paymentsSchemas.d.ts +0 -100
- package/dist/payments/paymentsSchemas.js +0 -65
- package/dist/product-statuses/productStatusesApi.d.ts +0 -47
- package/dist/product-statuses/productStatusesApi.js +0 -70
- package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -66
- package/dist/product-statuses/productStatusesInterfaces.js +0 -2
- package/dist/product-statuses/productStatusesSchemas.d.ts +0 -34
- package/dist/product-statuses/productStatusesSchemas.js +0 -30
- package/dist/products/productsApi.d.ts +0 -365
- package/dist/products/productsApi.js +0 -459
- package/dist/products/productsInterfaces.d.ts +0 -586
- package/dist/products/productsInterfaces.js +0 -2
- package/dist/products/productsSchemas.d.ts +0 -192
- package/dist/products/productsSchemas.js +0 -96
- package/dist/sitemap/sitemapApi.d.ts +0 -35
- package/dist/sitemap/sitemapApi.js +0 -45
- package/dist/sitemap/sitemapInterfaces.d.ts +0 -40
- package/dist/sitemap/sitemapInterfaces.js +0 -2
- package/dist/system/systemApi.d.ts +0 -43
- package/dist/system/systemApi.js +0 -58
- package/dist/system/systemInterfaces.d.ts +0 -31
- package/dist/system/systemInterfaces.js +0 -5
- package/dist/templates/templatesApi.d.ts +0 -49
- package/dist/templates/templatesApi.js +0 -75
- package/dist/templates/templatesInterfaces.d.ts +0 -70
- package/dist/templates/templatesInterfaces.js +0 -2
- package/dist/templates/templatesSchemas.d.ts +0 -48
- package/dist/templates/templatesSchemas.js +0 -31
- package/dist/templates-preview/templatesPreviewApi.d.ts +0 -38
- package/dist/templates-preview/templatesPreviewApi.js +0 -53
- package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -121
- package/dist/templates-preview/templatesPreviewInterfaces.js +0 -2
- package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -83
- package/dist/templates-preview/templatesPreviewSchemas.js +0 -48
- package/dist/users/usersApi.d.ts +0 -143
- package/dist/users/usersApi.js +0 -173
- package/dist/users/usersInterfaces.d.ts +0 -235
- package/dist/users/usersInterfaces.js +0 -2
- package/dist/users/usersSchemas.d.ts +0 -38
- package/dist/users/usersSchemas.js +0 -28
- package/dist/web-socket/wsApi.d.ts +0 -25
- package/dist/web-socket/wsApi.js +0 -45
- package/dist/web-socket/wsInterfaces.d.ts +0 -17
- package/dist/web-socket/wsInterfaces.js +0 -2
package/configure.js
CHANGED
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
* OneEntry SDK Configuration Tool
|
|
5
5
|
*
|
|
6
6
|
* Interactive CLI tool for initial SDK setup. Prompts the user for:
|
|
7
|
+
* - Project type (Node.js or Next.js)
|
|
7
8
|
* - Project URL (must include https://)
|
|
8
9
|
* - Authentication token
|
|
9
10
|
*
|
|
10
|
-
* Generates an example.
|
|
11
|
-
*
|
|
11
|
+
* Node.js: Generates an example.mjs file with a ready-to-use SDK setup.
|
|
12
|
+
* Next.js: Initializes a new Next.js project via create-next-app and adds
|
|
13
|
+
* oneentry configuration in lib/oneentry.ts and .env.local.
|
|
12
14
|
*
|
|
13
15
|
* Usage:
|
|
14
16
|
* npx oneentry
|
|
@@ -22,6 +24,7 @@
|
|
|
22
24
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
23
25
|
|
|
24
26
|
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
25
28
|
const readline = require('readline');
|
|
26
29
|
const { spawn } = require('child_process');
|
|
27
30
|
|
|
@@ -30,26 +33,41 @@ const rl = readline.createInterface({
|
|
|
30
33
|
output: process.stdout,
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
console.log('\nOneEntry SDK setup\n');
|
|
37
|
+
console.log('1) Node.js');
|
|
38
|
+
console.log('2) Next.js\n');
|
|
39
|
+
|
|
40
|
+
rl.question('Choose project type (1/2): ', (type) => {
|
|
41
|
+
const isNext = type.trim() === '2';
|
|
42
|
+
|
|
43
|
+
if (isNext) {
|
|
44
|
+
rl.question('Enter Next.js project name: ', (projectName) => {
|
|
45
|
+
rl.question('Enter project URL with https://... : ', (url) => {
|
|
46
|
+
rl.question('Enter token: ', (token) => {
|
|
47
|
+
rl.close();
|
|
48
|
+
initNextProject(projectName.trim(), url.trim(), token.trim());
|
|
49
|
+
});
|
|
50
|
+
});
|
|
38
51
|
});
|
|
39
|
-
}
|
|
52
|
+
} else {
|
|
53
|
+
rl.question('Enter project URL with https://... : ', (url) => {
|
|
54
|
+
rl.question('Enter token: ', (token) => {
|
|
55
|
+
rl.question('Run example after creating? (y/n): ', (answer) => {
|
|
56
|
+
rl.close();
|
|
57
|
+
createNodeExample(url.trim(), token.trim(), answer.trim().toLowerCase() === 'y');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
40
62
|
});
|
|
41
63
|
|
|
42
64
|
/**
|
|
43
65
|
* Creates an example JavaScript file with SDK initialization and sample requests
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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")
|
|
49
|
-
* @param {string} token - Authentication token for API access
|
|
66
|
+
* @param {string} url - Project URL with https://
|
|
67
|
+
* @param {string} token - Authentication token
|
|
50
68
|
* @param {boolean} run - Whether to run the generated file immediately
|
|
51
69
|
*/
|
|
52
|
-
function
|
|
70
|
+
function createNodeExample(url, token, run) {
|
|
53
71
|
const filePath = 'example.mjs';
|
|
54
72
|
const tokenLine = token ? `\n token: '${token}',` : '';
|
|
55
73
|
fs.writeFile(
|
|
@@ -88,3 +106,77 @@ console.log('Products:', JSON.stringify(products, null, 2));
|
|
|
88
106
|
},
|
|
89
107
|
);
|
|
90
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Initializes a Next.js project and adds OneEntry SDK configuration
|
|
112
|
+
* @param {string} projectName - Directory name for the new Next.js project
|
|
113
|
+
* @param {string} url - Project URL with https://
|
|
114
|
+
* @param {string} token - Authentication token
|
|
115
|
+
*/
|
|
116
|
+
function initNextProject(projectName, url, token) {
|
|
117
|
+
console.log(`\nRunning create-next-app for "${projectName}"...\n`);
|
|
118
|
+
|
|
119
|
+
const child = spawn(
|
|
120
|
+
'npx',
|
|
121
|
+
['create-next-app@latest', projectName, '--ts', '--app', '--eslint', '--no-tailwind', '--src-dir', '--import-alias', '@/*'],
|
|
122
|
+
{ stdio: 'inherit', shell: true },
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
child.on('error', (e) => {
|
|
126
|
+
console.error('Failed to run create-next-app:', e.message);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
child.on('close', (code) => {
|
|
130
|
+
if (code !== 0) {
|
|
131
|
+
console.error(`create-next-app exited with code ${code}`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
addOneEntryConfig(projectName, url, token);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Writes oneentry config files into the newly created Next.js project
|
|
140
|
+
* @param {string} projectName - Project directory name
|
|
141
|
+
* @param {string} url - Project URL with https://
|
|
142
|
+
* @param {string} token - Authentication token
|
|
143
|
+
*/
|
|
144
|
+
function addOneEntryConfig(projectName, url, token) {
|
|
145
|
+
const libDir = path.join(projectName, 'src', 'lib');
|
|
146
|
+
fs.mkdirSync(libDir, { recursive: true });
|
|
147
|
+
|
|
148
|
+
const tokenLine = token ? `\n token: process.env.ONEENTRY_TOKEN,` : '';
|
|
149
|
+
const libContent = `import { defineOneEntry } from 'oneentry';
|
|
150
|
+
|
|
151
|
+
const { Admins, Pages, Products } = defineOneEntry(
|
|
152
|
+
process.env.NEXT_PUBLIC_ONEENTRY_URL ?? '',
|
|
153
|
+
{${tokenLine}
|
|
154
|
+
langCode: 'en_US',
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
export { Admins, Pages, Products };
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
const envContent = `NEXT_PUBLIC_ONEENTRY_URL=${url}\n${token ? `ONEENTRY_TOKEN=${token}\n` : ''}`;
|
|
162
|
+
|
|
163
|
+
fs.writeFile(path.join(libDir, 'oneentry.ts'), libContent, (err) => {
|
|
164
|
+
if (err) {
|
|
165
|
+
console.error('Failed to create lib/oneentry.ts:', err.message);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
console.log(`Created ${projectName}/src/lib/oneentry.ts`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
fs.writeFile(path.join(projectName, '.env.local'), envContent, (err) => {
|
|
172
|
+
if (err) {
|
|
173
|
+
console.error('Failed to create .env.local:', err.message);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
console.log(`Created ${projectName}/.env.local`);
|
|
177
|
+
console.log(`\nNext steps:`);
|
|
178
|
+
console.log(` cd ${projectName}`);
|
|
179
|
+
console.log(` npm install oneentry`);
|
|
180
|
+
console.log(` npm run dev`);
|
|
181
|
+
});
|
|
182
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oneentry",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.142",
|
|
4
4
|
"description": "OneEntry NPM package",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"/dist"
|
|
9
9
|
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"productionBuild": "run-s lint testAll build",
|
|
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
|
+
"admins": "npx jest src/admins/tests/admins.spec.ts",
|
|
14
|
+
"update admins": "npx jest src/admins/tests/admins.spec.ts --updateSnapshot",
|
|
15
|
+
"attributesets": "npx jest src/attribute-sets/tests/attributesets.spec.ts",
|
|
16
|
+
"update attributesets": "npx jest src/attribute-sets/tests/attributesets.spec.ts --updateSnapshot",
|
|
17
|
+
"authProvider": "npx jest src/auth-provider/tests/authProvider.spec.ts",
|
|
18
|
+
"update authProvider": "npx jest src/auth-provider/tests/authProvider.spec.ts --updateSnapshot",
|
|
19
|
+
"blocks": "npx jest src/blocks/tests/blocks.spec.ts",
|
|
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",
|
|
23
|
+
"events": "npx jest src/events/tests/events.spec.ts",
|
|
24
|
+
"update events": "npx jest src/events/tests/events.spec.ts --updateSnapshot",
|
|
25
|
+
"fileuploading": "npx jest src/file-uploading/tests/fileuploading.spec.ts",
|
|
26
|
+
"update fileuploading": "npx jest src/file-uploading/tests/fileuploading.spec.ts --updateSnapshot",
|
|
27
|
+
"forms": "npx jest src/forms/tests/forms.spec.ts",
|
|
28
|
+
"update forms": "npx jest src/forms/tests/forms.spec.ts --updateSnapshot",
|
|
29
|
+
"formsdata": "npx jest src/forms-data/tests/formsdata.spec.ts",
|
|
30
|
+
"update formsdata": "npx jest src/forms-data/tests/formsdata.spec.ts --updateSnapshot",
|
|
31
|
+
"generaltypes": "npx jest src/general-types/tests/generaltypes.spec.ts",
|
|
32
|
+
"update generaltypes": "npx jest src/general-types/tests/generaltypes.spec.ts --updateSnapshot",
|
|
33
|
+
"integrationcollections": "npx jest src/integration-collections/tests/integrationcollections.spec.ts",
|
|
34
|
+
"update integrationcollections": "npx jest src/integration-collections/tests/integrationcollections.spec.ts --updateSnapshot",
|
|
35
|
+
"locales": "npx jest src/locales/tests/locales.spec.ts",
|
|
36
|
+
"update locales": "npx jest src/locales/tests/locales.spec.ts --updateSnapshot",
|
|
37
|
+
"menus": "npx jest src/menus/tests/menus.spec.ts",
|
|
38
|
+
"update menus": "npx jest src/menus/tests/menus.spec.ts --updateSnapshot",
|
|
39
|
+
"orders": "npx jest src/orders/tests/orders.spec.ts",
|
|
40
|
+
"update orders": "npx jest src/orders/tests/orders.spec.ts --updateSnapshot",
|
|
41
|
+
"pages": "npx jest src/pages/tests/pages.spec.ts",
|
|
42
|
+
"update pages": "npx jest src/pages/tests/pages.spec.ts --updateSnapshot",
|
|
43
|
+
"payments": "npx jest src/payments/tests/payments.spec.ts",
|
|
44
|
+
"update payments": "npx jest src/payments/tests/payments.spec.ts --updateSnapshot",
|
|
45
|
+
"productstatuses": "npx jest src/product-statuses/tests/productstatuses.spec.ts",
|
|
46
|
+
"update productstatuses": "npx jest src/product-statuses/tests/productstatuses.spec.ts --updateSnapshot",
|
|
47
|
+
"products": "npx jest src/products/tests/products.spec.ts",
|
|
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",
|
|
51
|
+
"templates": "npx jest src/templates/tests/templates.spec.ts",
|
|
52
|
+
"update templates": "npx jest src/templates/tests/templates.spec.ts --updateSnapshot",
|
|
53
|
+
"templatespreview": "npx jest src/templates-preview/tests/templatespreview.spec.ts",
|
|
54
|
+
"update templatespreview": "npx jest src/templates-preview/tests/templatespreview.spec.ts --updateSnapshot",
|
|
55
|
+
"users": "npx jest src/users/tests/users.spec.ts",
|
|
56
|
+
"update users": "npx jest src/users/tests/users.spec.ts --updateSnapshot",
|
|
57
|
+
"lint": "npx eslint .",
|
|
58
|
+
"tsc": "npx tsc --noEmit --watch false",
|
|
59
|
+
"lintFix": "npx eslint . --fix",
|
|
60
|
+
"build": "npx tsc && node scripts/copy-to-output.js",
|
|
61
|
+
"updateSnapshots": "npx jest --updateSnapshot"
|
|
62
|
+
},
|
|
10
63
|
"bin": {
|
|
11
64
|
"oneentry": "./configure.js"
|
|
12
65
|
},
|
|
13
|
-
"author": "ONEENTRY PORTAL
|
|
66
|
+
"author": "ONEENTRY PORTAL CO.",
|
|
14
67
|
"license": "ISC",
|
|
15
68
|
"dependencies": {
|
|
16
69
|
"socket.io-client": "^4.8.3",
|
|
17
70
|
"zod": "^4.3.6"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
74
|
+
"@jest/globals": "^30.3.0",
|
|
75
|
+
"@types/eslint-config-prettier": "^6.11.3",
|
|
76
|
+
"@types/jest": "^30.0.0",
|
|
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",
|
|
81
|
+
"eslint-config-prettier": "^10.1.8",
|
|
82
|
+
"eslint-plugin-import": "^2.32.0",
|
|
83
|
+
"eslint-plugin-jest": "^29.15.0",
|
|
84
|
+
"eslint-plugin-jest-extended": "^3.0.1",
|
|
85
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
86
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
87
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
88
|
+
"jest": "^30.3.0",
|
|
89
|
+
"jest-extended": "^7.0.0",
|
|
90
|
+
"jsdoc": "^4.0.5",
|
|
91
|
+
"npm-run-all": "^4.1.5",
|
|
92
|
+
"prettier": "^3.8.1",
|
|
93
|
+
"ts-jest": "^29.4.6",
|
|
94
|
+
"ts-node": "^10.9.2",
|
|
95
|
+
"typescript": "^5.9.3"
|
|
18
96
|
}
|
|
19
|
-
}
|
|
97
|
+
}
|
|
@@ -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
|
-
}
|
package/dist/admins/adminsApi.js
DELETED
|
@@ -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,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
|
-
}
|