oneentry 1.0.120 → 1.0.121

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 (47) hide show
  1. package/README.md +71 -71
  2. package/dist/admins/adminsApi.d.ts +1 -3
  3. package/dist/admins/adminsApi.js +1 -3
  4. package/dist/attribute-sets/attributeSetsApi.d.ts +1 -0
  5. package/dist/attribute-sets/attributeSetsApi.js +1 -0
  6. package/dist/auth-provider/authProviderApi.d.ts +1 -0
  7. package/dist/auth-provider/authProviderApi.js +1 -0
  8. package/dist/base/syncModules.js +140 -9
  9. package/dist/blocks/blocksApi.d.ts +1 -0
  10. package/dist/blocks/blocksApi.js +1 -0
  11. package/dist/events/eventsApi.d.ts +1 -0
  12. package/dist/events/eventsApi.js +1 -0
  13. package/dist/forms/formsApi.d.ts +1 -0
  14. package/dist/forms/formsApi.js +1 -0
  15. package/dist/formsData/formsDataApi.d.ts +19 -10
  16. package/dist/formsData/formsDataApi.js +62 -11
  17. package/dist/formsData/formsDataInterfaces.d.ts +1 -0
  18. package/dist/general-types/generalTypesApi.d.ts +1 -0
  19. package/dist/general-types/generalTypesApi.js +1 -0
  20. package/dist/index.js +1 -1
  21. package/dist/integration-collections/integrationCollectionsApi.d.ts +1 -0
  22. package/dist/integration-collections/integrationCollectionsApi.js +1 -0
  23. package/dist/locales/localesApi.d.ts +1 -0
  24. package/dist/locales/localesApi.js +1 -0
  25. package/dist/menus/menusApi.d.ts +1 -0
  26. package/dist/menus/menusApi.js +1 -0
  27. package/dist/orders/ordersApi.d.ts +1 -0
  28. package/dist/orders/ordersApi.js +1 -0
  29. package/dist/pages/pagesApi.d.ts +1 -0
  30. package/dist/pages/pagesApi.js +1 -0
  31. package/dist/payments/paymentsApi.d.ts +1 -0
  32. package/dist/payments/paymentsApi.js +1 -0
  33. package/dist/product-statuses/productStatusesApi.d.ts +1 -0
  34. package/dist/product-statuses/productStatusesApi.js +1 -0
  35. package/dist/products/productsApi.d.ts +1 -0
  36. package/dist/products/productsApi.js +1 -0
  37. package/dist/system/systemApi.d.ts +1 -0
  38. package/dist/system/systemApi.js +1 -0
  39. package/dist/templates/templatesApi.d.ts +1 -0
  40. package/dist/templates/templatesApi.js +1 -0
  41. package/dist/templates-preview/templatesPreviewApi.d.ts +1 -0
  42. package/dist/templates-preview/templatesPreviewApi.js +1 -0
  43. package/dist/users/usersApi.d.ts +1 -0
  44. package/dist/users/usersApi.js +1 -0
  45. package/dist/web-socket/wsApi.d.ts +1 -0
  46. package/dist/web-socket/wsApi.js +1 -0
  47. package/package.json +8 -9
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # OneEntry SDK
2
2
 
3
- OneEntry Headless CMS SDK is an SDK that provides an easy way to interact with the OneEntry Headless CMS API.
3
+ OneEntry SDK is an SDK that provides an easy way to interact with the OneEntry API.
4
4
 
5
5
  ## Official Site
6
6
 
7
- Visit the official AsyncModules website at [https://oneentry.cloud](https://oneentry.cloud) to learn more about the AsyncModules Headless CMS.
7
+ Visit the official OneEntry website at [https://oneentry.cloud](https://oneentry.cloud) to learn more about the OneEntry Platform.
8
8
 
9
9
  ## Sign Up
10
10
 
11
- To get started with AsyncModules, sign up for an account at [https://account.oneentry.cloud/authentication/register](https://account.oneentry.cloud/authentication/register).
11
+ To get started with OneEntry, sign up for an account at [https://account.oneentry.cloud/authentication/register](https://account.oneentry.cloud/authentication/register).
12
12
 
13
13
  ## Installation
14
14
 
15
- To install the AsyncModules Headless CMS SDK in your project, run the following command:
15
+ To install the OneEntry SDK in your project, run the following command:
16
16
 
17
17
  ```bash
18
18
  npm install oneentry
@@ -20,46 +20,46 @@ npm install oneentry
20
20
 
21
21
  ## Get Started
22
22
 
23
- To use the AsyncModules Headless CMS SDK in your project, import the defineOneEntry function:
23
+ To use the OneEntry SDK in your project, import the defineOneEntry function:
24
24
 
25
25
  ```js
26
26
  import { defineOneEntry } from 'oneentry'
27
27
 
28
28
  const config = {
29
- token:'your-app-token',
30
- };
29
+ token: 'your-app-token',
30
+ }
31
31
  const {
32
- Admins,
33
- AttributesSets,
34
- AuthProvider,
35
- Blocks,
36
- Events,
37
- Forms,
38
- FormData,
39
- FileUploading,
40
- GeneralTypes,
41
- IntegrationCollections,
42
- Locales,
43
- Menus,
44
- Orders,
45
- Pages,
46
- Products,
47
- ProductStatuses,
48
- System,
49
- Templates,
50
- TemplatePreviews,
51
- Users,
52
- WS
53
- } = defineOneEntry('your-url', config);
32
+ Admins,
33
+ AttributesSets,
34
+ AuthProvider,
35
+ Blocks,
36
+ Events,
37
+ Forms,
38
+ FormData,
39
+ FileUploading,
40
+ GeneralTypes,
41
+ IntegrationCollections,
42
+ Locales,
43
+ Menus,
44
+ Orders,
45
+ Pages,
46
+ Products,
47
+ ProductStatuses,
48
+ System,
49
+ Templates,
50
+ TemplatePreviews,
51
+ Users,
52
+ WS,
53
+ } = defineOneEntry('your-url', config)
54
54
  ```
55
55
 
56
56
  Or
57
57
 
58
58
  ```js
59
59
  const config = {
60
- token:'your-app-token',
61
- };
62
- const api = defineOneEntry('your-url', config);
60
+ token: 'your-app-token',
61
+ }
62
+ const api = defineOneEntry('your-url', config)
63
63
  ```
64
64
 
65
65
  ---
@@ -88,16 +88,16 @@ An example of a configuration with token protection and automatic authentication
88
88
 
89
89
  ```js
90
90
  const tokenFunction = (token) => {
91
- localStorage.setItem('refreshToken', token)
91
+ localStorage.setItem('refreshToken', token)
92
92
  }
93
93
 
94
94
  const api = defineOneEntry('https://my-project.oneentry.cloud', {
95
- token:'my-token',
96
- langCode:'en_US',
97
- auth: {
98
- refreshToken: localStorage.getItem('refreshToken'),
99
- saveFunction: tokenFunction
100
- }
95
+ token: 'my-token',
96
+ langCode: 'en_US',
97
+ auth: {
98
+ refreshToken: localStorage.getItem('refreshToken'),
99
+ saveFunction: tokenFunction,
100
+ },
101
101
  })
102
102
  ```
103
103
 
@@ -105,12 +105,12 @@ An example of a configuration that is protected with a certificate allows you to
105
105
 
106
106
  ```js
107
107
  const api = defineOneEntry('https://my-project.oneentry.cloud', {
108
- langCode:'en_US',
109
- traficLimit: true,
110
- auth: {
111
- customAuth: true,
112
- refreshToken: localStorage.getItem('refreshToken')
113
- }
108
+ langCode: 'en_US',
109
+ traficLimit: true,
110
+ auth: {
111
+ customAuth: true,
112
+ refreshToken: localStorage.getItem('refreshToken'),
113
+ },
114
114
  })
115
115
  ```
116
116
 
@@ -122,16 +122,16 @@ This method (setAccessToken) should not be called if the method does not require
122
122
  const user = api.Users.setAccessToken('my.access.token').getUser()
123
123
  ```
124
124
 
125
- >If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
125
+ > If you chose token protection to ensure connection security, just pass your token to the function as an optional parameter.
126
126
 
127
127
  You can get a token as follows
128
128
 
129
- 1) Log in to your personal account
130
- 2) Go to the "Projects" tab and select a project
131
- 3) Go to the "Access" tab
132
- 4) Set the switch to "Security API Token"
133
- 5) Log in to the project, go to the settings section and open the token tab
134
- 6) Get and copy the token of your project
129
+ 1. Log in to your personal account
130
+ 2. Go to the "Projects" tab and select a project
131
+ 3. Go to the "Access" tab
132
+ 4. Set the switch to "Security API Token"
133
+ 5. Log in to the project, go to the settings section and open the token tab
134
+ 6. Get and copy the token of your project
135
135
 
136
136
  You can also connect a tls certificate to protect your project. In this case, do not pass the "token" at all. When using the certificate, set up a proxy in your project. Pass an empty string as an url parameter.
137
137
  [Learn more about security](https://oneentry.cloud/instructions)
@@ -142,14 +142,14 @@ const saveTokenFromLocalStorage = (token) => {
142
142
  }
143
143
 
144
144
  const api = defineOneEntry('your-url', {
145
- token: 'my-token',
146
- langCode:'my-langCode',
147
- auth: {
148
- customAuth: false,
149
- userToken: 'rerfesh.token',
150
- saveFunction: saveTokenFromLocalStorage
151
- }
152
- });
145
+ token: 'my-token',
146
+ langCode: 'my-langCode',
147
+ auth: {
148
+ customAuth: false,
149
+ userToken: 'rerfesh.token',
150
+ saveFunction: saveTokenFromLocalStorage,
151
+ },
152
+ })
153
153
  ```
154
154
 
155
155
  ### Errors
@@ -166,17 +166,17 @@ These functions receive an error object as an argument. You can process it yours
166
166
 
167
167
  ```js
168
168
  const api = defineOneEntry('your-url', {
169
- token: 'my-token',
170
- langCode:'my-langCode',
171
- errors: {
172
- isShell: false,
173
- customErrors: {
174
- 400: (error) => console.error(error.message),
175
- 404: (error) => console.error(error.message),
176
- 500: (error) => console.error(error.message)
177
- }
178
- }
179
- });
169
+ token: 'my-token',
170
+ langCode: 'my-langCode',
171
+ errors: {
172
+ isShell: false,
173
+ customErrors: {
174
+ 400: (error) => console.error(error.message),
175
+ 404: (error) => console.error(error.message),
176
+ 500: (error) => console.error(error.message),
177
+ },
178
+ },
179
+ })
180
180
  ```
181
181
 
182
182
  Now you can use the following links to jump to specific entries documentation:
@@ -4,13 +4,11 @@ import type { AttributeType, IError } from '../base/utils';
4
4
  import type { IAdminEntity, IAdmins } from './adminsInterfaces';
5
5
  /**
6
6
  * Controllers for working with users - admins
7
+ * @handle /api/content/admins
7
8
  */
8
9
  export default class AdminsApi extends AsyncModules implements IAdmins {
9
10
  protected state: StateModule;
10
11
  protected _url: string;
11
- /**
12
- * '/api/content/admins'
13
- */
14
12
  constructor(state: StateModule);
15
13
  /**
16
14
  * Get all user objects - admins.
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with users - admins
9
+ * @handle /api/content/admins
9
10
  */
10
11
  class AdminsApi extends asyncModules_1.default {
11
- /**
12
- * '/api/content/admins'
13
- */
14
12
  constructor(state) {
15
13
  super(state);
16
14
  this._url = state.url + '/api/content/admins';
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IAttributeSetsEntity, IAttributesSets, IAttributesSetsEntity, IAttributesSetsResponse } from './attributeSetsInterfaces';
5
5
  /**
6
6
  * Controllers for working with attributes - AttributesSetsApi.
7
+ * @handle /api/content/attributes-sets
7
8
  * @class
8
9
  */
9
10
  export default class AttributesSetsApi extends AsyncModules implements IAttributesSets {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with attributes - AttributesSetsApi.
10
+ * @handle /api/content/attributes-sets
10
11
  * @class
11
12
  */
12
13
  class AttributesSetsApi extends asyncModules_1.default {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IAuthEntity, IAuthPostBody, IAuthProvider, IAuthProvidersEntity, ISignUpData, ISignUpEntity } from './authProvidersInterfaces';
5
5
  /**
6
6
  * Controllers for working with auth services.
7
+ * @handle /api/content/users-auth-providers
7
8
  */
8
9
  export default class AuthProviderApi extends AsyncModules implements IAuthProvider {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with auth services.
9
+ * @handle /api/content/users-auth-providers
9
10
  */
10
11
  class AuthProviderApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -249,6 +249,138 @@ class SyncModules {
249
249
  });
250
250
  return schedules;
251
251
  }
252
+ // /**
253
+ // * Function to generate intervals for a specific date
254
+ // *
255
+ // * @param date
256
+ // * @param schedule
257
+ // * @param utcIntervals
258
+ // */
259
+ // protected _generateFormIntervalsForDate(
260
+ // date: Date,
261
+ // schedule: { inEveryWeek: boolean; intervals: any[]; inEveryMonth: boolean },
262
+ // utcIntervals: Set<Array<string>>,
263
+ // ) {
264
+ // // inEveryWeek
265
+ // if (schedule.inEveryWeek && !schedule.inEveryMonth) {
266
+ // let currentDate = new Date(date);
267
+ // // Вычисляем последний день текущего месяца
268
+ // const endOfMonth = new Date(
269
+ // currentDate.getFullYear(),
270
+ // currentDate.getMonth() + 1,
271
+ // 0,
272
+ // );
273
+ // while (currentDate <= endOfMonth) {
274
+ // schedule.intervals?.forEach((timeRange: [any, any]) => {
275
+ // const [startTime, endTime] = timeRange;
276
+ // const intervalStart = new Date(currentDate);
277
+ // intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
278
+ // const intervalEnd = new Date(currentDate);
279
+ // intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
280
+ // // Добавляем строку JSON в Set для уникальности
281
+ // utcIntervals.add([
282
+ // intervalStart.toISOString(),
283
+ // intervalEnd.toISOString(),
284
+ // ]);
285
+ // });
286
+ // currentDate = this._addDays(currentDate, 7); // Переходим к следующей неделе
287
+ // }
288
+ // }
289
+ // // inEveryMonth
290
+ // if (schedule.inEveryMonth && !schedule.inEveryWeek) {
291
+ // const startDate = new Date(date); // Начальная дата
292
+ // const targetDayOfMonth = startDate.getUTCDate(); // Определяем день месяца начальной даты
293
+ // const numberOfMonths = 12; // Количество месяцев, на которые нужно повторить
294
+ // for (let i = 0; i < numberOfMonths; i++) {
295
+ // const currentDate = new Date(startDate);
296
+ // currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
297
+ // // Попробуем установить текущую дату на целевой день месяца
298
+ // currentDate.setUTCDate(targetDayOfMonth);
299
+ // // Проверяем, не вышли ли мы за пределы месяца
300
+ // if (currentDate.getUTCMonth() !== (startDate.getUTCMonth() + i) % 12) {
301
+ // continue; // Если вышли, пропускаем этот месяц
302
+ // }
303
+ // schedule.intervals?.forEach((timeRange: [any, any]) => {
304
+ // const [startTime, endTime] = timeRange;
305
+ // const intervalStart = new Date(currentDate);
306
+ // intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
307
+ // const intervalEnd = new Date(currentDate);
308
+ // intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
309
+ // utcIntervals.add([
310
+ // intervalStart.toISOString(),
311
+ // intervalEnd.toISOString(),
312
+ // ]);
313
+ // });
314
+ // }
315
+ // }
316
+ // // inEveryMonth && inEveryWeek
317
+ // if (schedule.inEveryMonth && schedule.inEveryWeek) {
318
+ // const startDate = new Date(date); // Начальная дата
319
+ // const targetDayOfWeek = startDate.getUTCDay(); // Определяем день недели начальной даты
320
+ // const numberOfMonths = 12; // Количество месяцев, на которые нужно повторить
321
+ // console.log(startDate);
322
+ // for (let i = 0; i < numberOfMonths; i++) {
323
+ // const currentDate = new Date(startDate);
324
+ // currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
325
+ // currentDate.setUTCDate(1); // Устанавливаем на первый день месяца
326
+ // // Находим первый целевой день недели в текущем месяце
327
+ // const daysUntilTargetDay =
328
+ // (targetDayOfWeek - currentDate.getUTCDay() + 7) % 7;
329
+ // currentDate.setUTCDate(currentDate.getUTCDate() + daysUntilTargetDay);
330
+ // // Проходим по всем целевым дням недели в текущем месяце
331
+ // while (
332
+ // currentDate.getUTCMonth() ===
333
+ // (startDate.getUTCMonth() + i) % 12
334
+ // ) {
335
+ // schedule.intervals.forEach((timeRange: [any, any]) => {
336
+ // const [startTime, endTime] = timeRange;
337
+ // const intervalStart = new Date(currentDate);
338
+ // intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
339
+ // const intervalEnd = new Date(currentDate);
340
+ // intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
341
+ // utcIntervals.add([
342
+ // intervalStart.toISOString(),
343
+ // intervalEnd.toISOString(),
344
+ // ]);
345
+ // });
346
+ // // Переходим к следующей неделе (следующему такому же дню недели)
347
+ // currentDate.setUTCDate(currentDate.getUTCDate() + 7);
348
+ // }
349
+ // }
350
+ // }
351
+ // }
352
+ // /**
353
+ // * Add TimeIntervals to schedules Form
354
+ // *
355
+ // * @param schedules
356
+ // * @returns schedules with timeIntervals
357
+ // */
358
+ // _addTimeIntervalsToSchedulesForm(schedules: any[]) {
359
+ // schedules?.forEach((schedule: any) => {
360
+ // const utcIntervals: Set<Array<string>> = new Set();
361
+ // const startDate = new Date(schedule.range[0]);
362
+ // const endDate = new Date(schedule.range[1]);
363
+ // const isSameDay = startDate.toISOString() === endDate.toISOString();
364
+ // // console.log(JSON.stringify(schedule));
365
+ // if (isSameDay) {
366
+ // this._generateFormIntervalsForDate(startDate, schedule, utcIntervals);
367
+ // } else {
368
+ // for (
369
+ // let currentDate = new Date(startDate);
370
+ // currentDate <= endDate;
371
+ // currentDate = this._addDays(currentDate, 1)
372
+ // ) {
373
+ // this._generateFormIntervalsForDate(
374
+ // currentDate,
375
+ // schedule,
376
+ // utcIntervals,
377
+ // );
378
+ // }
379
+ // }
380
+ // // schedule.timeIntervals = Array.from(utcIntervals).sort();
381
+ // });
382
+ // return schedules;
383
+ // }
252
384
  /**
253
385
  * normalizeAttr
254
386
  *
@@ -259,10 +391,10 @@ class SyncModules {
259
391
  // for regular attributes
260
392
  if ('attributeValues' in data) {
261
393
  for (const attr in data.attributeValues) {
394
+ const d = data.attributeValues[attr];
262
395
  // normalize numbers
263
- if (data.attributeValues[attr].type === 'integer' ||
264
- data.attributeValues[attr].type === 'float') {
265
- data.attributeValues[attr].value = Number(data.attributeValues[attr].value);
396
+ if (d.type === 'integer' || d.type === 'float') {
397
+ d.value = Number(d.value);
266
398
  }
267
399
  // add timeIntervals
268
400
  if (data.attributeValues[attr].type === 'timeInterval') {
@@ -289,12 +421,11 @@ class SyncModules {
289
421
  }
290
422
  // add timeIntervals
291
423
  if (d[attr].type === 'timeInterval') {
292
- const schedules = d[attr].value;
293
- // console.log(JSON.stringify(schedules));
294
- if (Array.isArray(schedules) && schedules.length > 0) {
295
- const result = this._addTimeIntervalsToSchedules(schedules);
296
- d[attr].value = result;
297
- }
424
+ // const schedules = d[attr].localizeInfos.intervals;
425
+ // if (Array.isArray(schedules) && schedules.length > 0) {
426
+ // const result = this._addTimeIntervalsToSchedulesForm(schedules);
427
+ // d[attr].localizeInfos.intervals = result;
428
+ // }
298
429
  }
299
430
  }
300
431
  return data;
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { BlockType, IBlockEntity, IBlocks, IBlocksResponse, ISearchBlock } from './blocksInterfaces';
5
5
  /**
6
6
  * Controllers for working with blocks
7
+ * @handle /api/content/blocks
7
8
  */
8
9
  export default class BlocksApi extends AsyncModules implements IBlocks {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with blocks
9
+ * @handle /api/content/blocks
9
10
  */
10
11
  class BlocksApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -5,6 +5,7 @@ import type { IEvents } from './eventsInterfaces';
5
5
  import type { ISubscriptions } from './eventsInterfaces';
6
6
  /**
7
7
  * Controllers for working with events
8
+ * @handle /api/content/events
8
9
  */
9
10
  export default class EventsApi extends AsyncModules implements IEvents {
10
11
  protected state: StateModule;
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
9
9
  /**
10
10
  * Controllers for working with events
11
+ * @handle /api/content/events
11
12
  */
12
13
  class EventsApi extends asyncModules_1.default {
13
14
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IForms, IFormsEntity } from './formsInterfaces';
5
5
  /**
6
6
  * Controllers for forms objects
7
+ * @handle /api/content/forms
7
8
  */
8
9
  export default class FormsApi extends AsyncModules implements IForms {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for forms objects
9
+ * @handle /api/content/forms
9
10
  */
10
11
  class FormsApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IFormDataEntity, IFormsData, IFormsDataEntity, IFormsPost } from './formsDataInterfaces';
5
5
  /**
6
6
  * Controllers for working with form data
7
+ * @handle /api/content/form-data
7
8
  */
8
9
  export default class FormsDataApi extends AsyncModules implements IFormsData {
9
10
  protected state: StateModule;
@@ -27,16 +28,24 @@ export default class FormsDataApi extends AsyncModules implements IFormsData {
27
28
  *
28
29
  * @example
29
30
  * const body = {
30
- "formIdentifier": "reg",
31
- "formData": {
32
- "en_US": [
33
- {
34
- "marker": "last_name",
35
- "type": "string",
36
- "value": "Andrey"
37
- }
38
- ]
39
- }
31
+ "formIdentifier": "file",
32
+ "formData": [
33
+ {
34
+ "marker": "name",
35
+ "type": "string",
36
+ "value": "filesArray",
37
+ },
38
+ {
39
+ "marker": "file",
40
+ "type": "file",
41
+ "value": filesArray,
42
+ fileQuery: {
43
+ type: 'page',
44
+ entity: 'editor',
45
+ id: 3492,
46
+ },
47
+ }
48
+ ]
40
49
  }
41
50
  *
42
51
  * @returns - Returns a created FormDataEntity object.
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  /* eslint-disable @typescript-eslint/no-explicit-any */
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
+ const fileUploadingApi_1 = __importDefault(require("../file-uploading/fileUploadingApi"));
8
9
  /**
9
10
  * Controllers for working with form data
11
+ * @handle /api/content/form-data
10
12
  */
11
13
  class FormsDataApi extends asyncModules_1.default {
12
14
  constructor(state) {
@@ -34,26 +36,75 @@ class FormsDataApi extends asyncModules_1.default {
34
36
  *
35
37
  * @example
36
38
  * const body = {
37
- "formIdentifier": "reg",
38
- "formData": {
39
- "en_US": [
40
- {
41
- "marker": "last_name",
42
- "type": "string",
43
- "value": "Andrey"
44
- }
45
- ]
46
- }
39
+ "formIdentifier": "file",
40
+ "formData": [
41
+ {
42
+ "marker": "name",
43
+ "type": "string",
44
+ "value": "filesArray",
45
+ },
46
+ {
47
+ "marker": "file",
48
+ "type": "file",
49
+ "value": filesArray,
50
+ fileQuery: {
51
+ type: 'page',
52
+ entity: 'editor',
53
+ id: 3492,
54
+ },
55
+ }
56
+ ]
47
57
  }
48
58
  *
49
59
  * @returns - Returns a created FormDataEntity object.
50
60
  */
51
61
  async postFormsData(body, langCode = this.state.lang) {
52
62
  const formData = {};
53
- // filter spam and button fields
63
+ // filter spam and button fields, send file
54
64
  formData[langCode] = Array.isArray(body.formData)
55
65
  ? body.formData.filter((fd) => fd.type !== 'spam' && fd.type !== 'button')
56
66
  : [body.formData].filter((fd) => fd.type !== 'spam' && fd.type !== 'button');
67
+ // Handle file uploads if fileQuery is present
68
+ // Check if there is any element in formData[langCode] that contains one of the specified types
69
+ if (formData[langCode].find((fd) => ['file', 'image', 'groupOfImages'].includes(fd.type))) {
70
+ // Create an instance of FileUploadingApi with the current state
71
+ const fileUploader = new fileUploadingApi_1.default(this.state);
72
+ // Process each element in formData[langCode] asynchronously
73
+ formData[langCode] = await Promise.all(formData[langCode].map(async (fd) => {
74
+ // Check if the type is one of the specified types
75
+ if (['file', 'image', 'groupOfImages'].includes(fd.type)) {
76
+ // If fileQuery does not exist, we create it and assign it to an object with the following properties:
77
+ if (!fd.fileQuery) {
78
+ const fileQuery = {
79
+ type: 'page',
80
+ entity: 'editor',
81
+ // Generate a random 4-digit ID
82
+ id: Number(Math.floor(Math.random() * 10000).toString().padStart(4, '0')),
83
+ };
84
+ fd.fileQuery = fileQuery;
85
+ }
86
+ // Convert fd.value to an array if it is a FileList, otherwise use it directly
87
+ const filesArray = typeof FileList !== 'undefined' && fd.value instanceof FileList
88
+ ? Array.from(fd.value)
89
+ : fd.value;
90
+ // If filesArray is an array, upload each file asynchronously
91
+ if (Array.isArray(filesArray)) {
92
+ const uploadPromises = filesArray.map((file) => fileUploader.upload(file, fd.fileQuery).catch((e) => e));
93
+ fd.value = (await Promise.all(uploadPromises)).flat();
94
+ }
95
+ // If fd.value is a single File or Blob, upload it
96
+ else if (fd.value instanceof File || fd.value instanceof Blob) {
97
+ fd.value = await fileUploader
98
+ .upload(fd.value, fd.fileQuery)
99
+ .catch((e) => e); // Catch any errors during upload
100
+ }
101
+ // Remove the 'fileQuery' property from the object after processing
102
+ delete fd.fileQuery;
103
+ }
104
+ // Return the processed form data element
105
+ return fd;
106
+ }));
107
+ }
57
108
  body.formData = formData;
58
109
  const result = await this._fetchPost(``, body);
59
110
  return this._dataPostProcess(result);
@@ -28,6 +28,7 @@ interface IFormDataEntity {
28
28
  time: Date | string;
29
29
  formData: IFormsPost;
30
30
  attributeSetIdentifier?: string;
31
+ actionMessage?: string;
31
32
  }
32
33
  /**
33
34
  * Represents a form data.
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IGeneralTypes, IGeneralTypesEntity } from './generalTypesInterfaces';
5
5
  /**
6
6
  * Controllers for working with types
7
+ * @handle /api/content/general-types
7
8
  */
8
9
  export default class GeneralTypesApi extends AsyncModules implements IGeneralTypes {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with types
9
+ * @handle /api/content/general-types
9
10
  */
10
11
  class GeneralTypesApi extends asyncModules_1.default {
11
12
  constructor(state) {
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const wsApi_1 = __importDefault(require("./web-socket/wsApi"));
47
47
  * @returns {IDefineApi} - List of methods set.
48
48
  */
49
49
  function defineOneEntry(url, config) {
50
- const stateModule = new stateModule_1.default(url, config);
50
+ const stateModule = new stateModule_1.default(url.endsWith('/') ? url.slice(0, -1) : url, config);
51
51
  const Admins = new adminsApi_1.default(stateModule);
52
52
  const AttributesSets = new attributeSetsApi_1.default(stateModule);
53
53
  const AuthProvider = new authProviderApi_1.default(stateModule);
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { ICollection, ICollectionFormObject, ICollectionResponce, ICollectionRow, ICollectionsApi } from './integrationCollectionsInterfaces';
5
5
  /**
6
6
  * Controllers for working with attributes.
7
+ * @handle /api/content/integration-collections
7
8
  */
8
9
  export default class IntegrationCollectionsApi extends AsyncModules implements ICollectionsApi {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with attributes.
10
+ * @handle /api/content/integration-collections
10
11
  */
11
12
  class IntegrationCollectionsApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { ILocalEntity, ILocales } from './localesInterfaces';
5
5
  /**
6
6
  * Controllers for working with localizations (content language)
7
+ * @handle /api/content/locales
7
8
  */
8
9
  export default class LocalesApi extends AsyncModules implements ILocales {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with localizations (content language)
9
+ * @handle /api/content/locales
9
10
  */
10
11
  class LocalesApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IMenus, IMenusEntity } from './menusInterfaces';
5
5
  /**
6
6
  * Controllers for working with menu objects
7
+ * @handle /api/content/menus
7
8
  */
8
9
  export default class MenusApi extends AsyncModules implements IMenus {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with menu objects
9
+ * @handle /api/content/menus
9
10
  */
10
11
  class MenusApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IBaseOrdersEntity, IOrderByMarkerEntity, IOrderData, IOrdersApi, IOrdersByMarkerEntity, IOrdersEntity } from './ordersInterfaces';
5
5
  /**
6
6
  * Controllers for working with orders
7
+ * @handle /api/content/orders-storage
7
8
  */
8
9
  export default class OrdersApi extends AsyncModules implements IOrdersApi {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with orders
10
+ * @handle /api/content/orders-storage
10
11
  */
11
12
  class OrdersApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IPageApi, IPageConfig, IPagesEntity, IPositionBlock, IPositionForm } from './pagesInterfaces';
5
5
  /**
6
6
  * Controllers for working with page objects, including catalog pages
7
+ * @handle /api/content/pages
7
8
  */
8
9
  export default class PageApi extends AsyncModules implements IPageApi {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with page objects, including catalog pages
10
+ * @handle /api/content/pages
10
11
  */
11
12
  class PageApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IAccountsEntity, IConnectedEntity, ICreateSessionEntity, IPaymentsApi, ISessionEntity, ISessionsEntity } from './paymentsInterfaces';
5
5
  /**
6
6
  * Controllers for working with payments
7
+ * @handle /api/content/payments
7
8
  */
8
9
  export default class PaymentsApi extends AsyncModules implements IPaymentsApi {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with payments
9
+ * @handle /api/content/payments
9
10
  */
10
11
  class PaymentsApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IProductStatusEntity, IProductStatuses } from './productStatusesInterfaces';
5
5
  /**
6
6
  * Controllers for working with product statuses
7
+ * @handle /api/content/product-statuses
7
8
  */
8
9
  export default class ProductStatusesApi extends AsyncModules implements IProductStatuses {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with product statuses
9
+ * @handle /api/content/product-statuses
9
10
  */
10
11
  class ProductStatusesApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IFilterParams, IProductApi, IProductBlock, IProductEntity, IProductsEntity, IProductsInfo, IProductsQuery, IProductsResponse } from './productsInterfaces';
5
5
  /**
6
6
  * Controllers for working with product pages
7
+ * @handle /api/content/products
7
8
  */
8
9
  export default class ProductApi extends AsyncModules implements IProductApi {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  // import { IProductInfo } from './productsInterfaces';
8
8
  /**
9
9
  * Controllers for working with product pages
10
+ * @handle /api/content/products
10
11
  */
11
12
  class ProductApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { ISystem } from './systemInterfaces';
5
5
  /**
6
6
  * Controllers for working with system - system
7
+ * @handle /api/content/system
7
8
  */
8
9
  export default class SystemApi extends AsyncModules implements ISystem {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with system - system
10
+ * @handle /api/content/system
10
11
  */
11
12
  class SystemApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError, Types } from '../base/utils';
4
4
  import type { ITemplateEntity, ITemplatesApi } from './templatesInterfaces';
5
5
  /**
6
6
  * Controllers for working with template objects
7
+ * @handle /api/content/templates
7
8
  */
8
9
  export default class TemplatesPreviewApi extends AsyncModules implements ITemplatesApi {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with template objects
10
+ * @handle /api/content/templates
10
11
  */
11
12
  class TemplatesPreviewApi extends asyncModules_1.default {
12
13
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { ITemplatesPreview, ITemplatesPreviewEntity } from './templatesPreviewInterfaces';
5
5
  /**
6
6
  * Controllers for working with template objects for preview
7
+ * @handle /api/content/template-previews
7
8
  */
8
9
  export default class TemplatePreviewsApi extends AsyncModules implements ITemplatesPreview {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with template objects for preview
9
+ * @handle /api/content/template-previews
9
10
  */
10
11
  class TemplatePreviewsApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type { IError } from '../base/utils';
4
4
  import type { IUserBody, IUserEntity, IUsers } from './usersInterfaces';
5
5
  /**
6
6
  * Controllers for working with users
7
+ * @handle /api/content/users
7
8
  */
8
9
  export default class UsersApi extends AsyncModules implements IUsers {
9
10
  protected state: StateModule;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
7
7
  /**
8
8
  * Controllers for working with users
9
+ * @handle /api/content/users
9
10
  */
10
11
  class UsersApi extends asyncModules_1.default {
11
12
  constructor(state) {
@@ -4,6 +4,7 @@ import type StateModule from '../base/stateModule';
4
4
  import type { IWS } from './wsInterfaces';
5
5
  /**
6
6
  * Controllers for working with users
7
+ * @handle /api/content/ws
7
8
  */
8
9
  export default class WsApi extends AsyncModules implements IWS {
9
10
  protected state: StateModule;
@@ -7,6 +7,7 @@ const socket_io_client_1 = require("socket.io-client");
7
7
  const asyncModules_1 = __importDefault(require("../base/asyncModules"));
8
8
  /**
9
9
  * Controllers for working with users
10
+ * @handle /api/content/ws
10
11
  */
11
12
  class WsApi extends asyncModules_1.default {
12
13
  constructor(state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.120",
3
+ "version": "1.0.121",
4
4
  "description": "OneEntry NPM package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -43,22 +43,21 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@jest/globals": "^29.7.0",
46
- "@microsoft/tsdoc": "^0.15.1",
47
46
  "@types/eslint-config-prettier": "^6.11.3",
48
47
  "@types/jest": "^29.5.14",
49
- "@types/node": "^22.13.11",
50
- "@typescript-eslint/eslint-plugin": "^8.24.1",
51
- "@typescript-eslint/parser": "^8.24.1",
48
+ "@types/node": "^22.15.17",
49
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
50
+ "@typescript-eslint/parser": "^8.32.1",
52
51
  "eslint": "^8.57.1",
53
- "eslint-config-prettier": "^10.1.1",
52
+ "eslint-config-prettier": "^10.1.5",
54
53
  "eslint-plugin-import": "^2.31.0",
55
54
  "eslint-plugin-jest": "^28.11.0",
56
- "eslint-plugin-prettier": "^5.2.3",
55
+ "eslint-plugin-prettier": "^5.4.0",
57
56
  "eslint-plugin-simple-import-sort": "^12.1.1",
58
57
  "jest": "^29.7.0",
59
58
  "npm-run-all": "^4.1.5",
60
59
  "prettier": "^3.5.3",
61
- "ts-jest": "^29.2.6",
62
- "typescript": "^5.7.3"
60
+ "ts-jest": "^29.3.2",
61
+ "typescript": "^5.8.3"
63
62
  }
64
63
  }