oneentry 1.0.116 → 1.0.117

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.
@@ -16,7 +16,7 @@ import type { IError, ILocalizeInfo } from '../base/utils';
16
16
  interface IAuthProvider {
17
17
  signUp(marker: string, data: ISignUpData, langCode?: string): Promise<ISignUpEntity | IError>;
18
18
  generateCode(marker: string, userIdentifier: string, eventIdentifier: string): Promise<void | IError>;
19
- checkCode(marker: string, userIdentifier: string, code: string, eventIdentifier: string): Promise<boolean | IError>;
19
+ checkCode(marker: string, userIdentifier: string, eventIdentifier: string, code: string): Promise<boolean | IError>;
20
20
  activateUser(marker: string, userIdentifier: string, code: string): Promise<boolean | IError>;
21
21
  auth(marker: string, data: IAuthPostBody): Promise<IAuthEntity | IError>;
22
22
  refresh(marker: string, token: string): Promise<IAuthEntity | IError>;
@@ -43,7 +43,7 @@ export default abstract class SyncModules {
43
43
  */
44
44
  protected _clearArray(data: Record<string, any>): any;
45
45
  /**
46
- * sortAttributes
46
+ * Sort attributes by its positions
47
47
  *
48
48
  * @param data
49
49
  * @returns
@@ -58,7 +58,7 @@ export default abstract class SyncModules {
58
58
  * @param days
59
59
  * @returns
60
60
  */
61
- protected _addDays(date: string | number | Date, days: number): Date;
61
+ protected _addDays(date: Date, days: number): Date;
62
62
  /**
63
63
  * Function to generate intervals for a specific date
64
64
  *
@@ -66,18 +66,18 @@ export default abstract class SyncModules {
66
66
  * @param schedule
67
67
  * @param utcIntervals
68
68
  */
69
- protected _generateIntervalsForDate(date: string | number | Date, schedule: {
70
- inEveryWeek: any;
69
+ protected _generateIntervalsForDate(date: Date, schedule: {
70
+ inEveryWeek: boolean;
71
71
  times: any[];
72
- inEveryMonth: any;
73
- }, utcIntervals: any[][]): void;
72
+ inEveryMonth: boolean;
73
+ }, utcIntervals: Set<Array<string>>): void;
74
74
  /**
75
75
  * Add TimeIntervals to schedules
76
76
  *
77
77
  * @param schedules
78
78
  * @returns schedules with timeIntervals
79
79
  */
80
- protected _addTimeIntervalsToSchedules(schedules: any[]): any[];
80
+ _addTimeIntervalsToSchedules(schedules: any[]): any[];
81
81
  /**
82
82
  * normalizeAttr
83
83
  *
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  class SyncModules {
4
4
  constructor(state) {
5
5
  /**
6
- * sortAttributes
6
+ * Sort attributes by its positions
7
7
  *
8
8
  * @param data
9
9
  * @returns
@@ -143,40 +143,85 @@ class SyncModules {
143
143
  * @param utcIntervals
144
144
  */
145
145
  _generateIntervalsForDate(date, schedule, utcIntervals) {
146
- // Generate intervals based on weekly repetition
147
- if (schedule.inEveryWeek) {
148
- for (let week = 0; week < 4; week++) {
146
+ // inEveryWeek
147
+ if (schedule.inEveryWeek && !schedule.inEveryMonth) {
148
+ let currentDate = new Date(date);
149
+ // Вычисляем последний день текущего месяца
150
+ const endOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
151
+ while (currentDate <= endOfMonth) {
149
152
  schedule.times.forEach((timeRange) => {
150
153
  const [startTime, endTime] = timeRange;
151
- const intervalStart = this._addDays(date, week * 7);
154
+ const intervalStart = new Date(currentDate);
152
155
  intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
153
- const intervalEnd = this._addDays(date, week * 7);
156
+ const intervalEnd = new Date(currentDate);
154
157
  intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
155
- utcIntervals.push([
158
+ // Добавляем строку JSON в Set для уникальности
159
+ utcIntervals.add([
156
160
  intervalStart.toISOString(),
157
161
  intervalEnd.toISOString(),
158
162
  ]);
159
163
  });
164
+ currentDate = this._addDays(currentDate, 7); // Переходим к следующей неделе
160
165
  }
161
166
  }
162
- // Generate intervals based on monthly repetition
163
- if (schedule.inEveryMonth) {
164
- for (let month = 0; month < 12; month++) {
167
+ // inEveryMonth
168
+ if (schedule.inEveryMonth && !schedule.inEveryWeek) {
169
+ const startDate = new Date(date); // Начальная дата
170
+ const targetDayOfMonth = startDate.getUTCDate(); // Определяем день месяца начальной даты
171
+ const numberOfMonths = 12; // Количество месяцев, на которые нужно повторить
172
+ for (let i = 0; i < numberOfMonths; i++) {
173
+ const currentDate = new Date(startDate);
174
+ currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
175
+ // Попробуем установить текущую дату на целевой день месяца
176
+ currentDate.setUTCDate(targetDayOfMonth);
177
+ // Проверяем, не вышли ли мы за пределы месяца
178
+ if (currentDate.getUTCMonth() !== (startDate.getUTCMonth() + i) % 12) {
179
+ continue; // Если вышли, пропускаем этот месяц
180
+ }
165
181
  schedule.times.forEach((timeRange) => {
166
182
  const [startTime, endTime] = timeRange;
167
- const intervalStart = new Date(date);
168
- intervalStart.setUTCMonth(intervalStart.getUTCMonth() + month);
183
+ const intervalStart = new Date(currentDate);
169
184
  intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
170
- const intervalEnd = new Date(date);
171
- intervalEnd.setUTCMonth(intervalEnd.getUTCMonth() + month);
185
+ const intervalEnd = new Date(currentDate);
172
186
  intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
173
- utcIntervals.push([
187
+ utcIntervals.add([
174
188
  intervalStart.toISOString(),
175
189
  intervalEnd.toISOString(),
176
190
  ]);
177
191
  });
178
192
  }
179
193
  }
194
+ // inEveryMonth && inEveryWeek
195
+ if (schedule.inEveryMonth && schedule.inEveryWeek) {
196
+ const startDate = new Date(date); // Начальная дата
197
+ const targetDayOfWeek = startDate.getUTCDay(); // Определяем день недели начальной даты
198
+ const numberOfMonths = 12; // Количество месяцев, на которые нужно повторить
199
+ for (let i = 0; i < numberOfMonths; i++) {
200
+ const currentDate = new Date(startDate);
201
+ currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
202
+ currentDate.setUTCDate(1); // Устанавливаем на первый день месяца
203
+ // Находим первый целевой день недели в текущем месяце
204
+ const daysUntilTargetDay = (targetDayOfWeek - currentDate.getUTCDay() + 7) % 7;
205
+ currentDate.setUTCDate(currentDate.getUTCDate() + daysUntilTargetDay);
206
+ // Проходим по всем целевым дням недели в текущем месяце
207
+ while (currentDate.getUTCMonth() ===
208
+ (startDate.getUTCMonth() + i) % 12) {
209
+ schedule.times.forEach((timeRange) => {
210
+ const [startTime, endTime] = timeRange;
211
+ const intervalStart = new Date(currentDate);
212
+ intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
213
+ const intervalEnd = new Date(currentDate);
214
+ intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
215
+ utcIntervals.add([
216
+ intervalStart.toISOString(),
217
+ intervalEnd.toISOString(),
218
+ ]);
219
+ });
220
+ // Переходим к следующей неделе (следующему такому же дню недели)
221
+ currentDate.setUTCDate(currentDate.getUTCDate() + 7);
222
+ }
223
+ }
224
+ }
180
225
  }
181
226
  /**
182
227
  * Add TimeIntervals to schedules
@@ -187,23 +232,19 @@ class SyncModules {
187
232
  _addTimeIntervalsToSchedules(schedules) {
188
233
  schedules.forEach((scheduleGroup) => {
189
234
  scheduleGroup.values.forEach((schedule) => {
190
- const utcIntervals = [];
235
+ const utcIntervals = new Set();
191
236
  const startDate = new Date(schedule.dates[0]);
192
237
  const endDate = new Date(schedule.dates[1]);
193
- // Check if the dates are the same
194
238
  const isSameDay = startDate.toISOString() === endDate.toISOString();
195
- // If the dates are the same, process only the first date
196
239
  if (isSameDay) {
197
240
  this._generateIntervalsForDate(startDate, schedule, utcIntervals);
198
241
  }
199
242
  else {
200
- // Otherwise, process each day in the range
201
243
  for (let currentDate = new Date(startDate); currentDate <= endDate; currentDate = this._addDays(currentDate, 1)) {
202
244
  this._generateIntervalsForDate(currentDate, schedule, utcIntervals);
203
245
  }
204
246
  }
205
- // Add calculated intervals to the new field timeIntervals
206
- schedule.timeIntervals = utcIntervals;
247
+ schedule.timeIntervals = Array.from(utcIntervals).sort();
207
248
  });
208
249
  });
209
250
  return schedules;
@@ -225,7 +266,8 @@ class SyncModules {
225
266
  // add timeIntervals
226
267
  if (data.attributeValues[attr].type === 'timeInterval') {
227
268
  const schedules = data.attributeValues[attr].value;
228
- if (typeof schedules === 'object' && schedules.length > 0) {
269
+ // console.log(JSON.stringify(schedules));
270
+ if (Array.isArray(schedules) && schedules.length > 0) {
229
271
  const result = this._addTimeIntervalsToSchedules(schedules);
230
272
  data.attributeValues[attr].value = result;
231
273
  }
@@ -69,6 +69,8 @@ interface IAttributes {
69
69
  type: string;
70
70
  settings?: Record<string, any>;
71
71
  validators: Record<string, any>;
72
+ additionalFields?: any;
73
+ [key: string]: any;
72
74
  }
73
75
  interface ILocalizeInfos {
74
76
  [key: string]: ILocalizeInfo;
@@ -16,12 +16,13 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
16
16
  * @param {File} [data] File objects. Get data as File from your unput as e.target.files[0]
17
17
  *
18
18
  * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
19
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example : "page"
20
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
21
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
22
- * @param {number} [fileQuery.width] - Optional width parameter. Example : 0
23
- * @param {number} [fileQuery.height] - Optional height parameter. Example : 0
24
- * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example : true
19
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page"
20
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor"
21
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787
22
+ * @param {number} [fileQuery.width] - Optional width parameter. Example: 0
23
+ * @param {number} [fileQuery.height] - Optional height parameter. Example: 0
24
+ * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true
25
+ * @param {boolean} [fileQuery.template] - preview template identifier. Example: 1
25
26
  *
26
27
  * @returns Uploads a file to an Amazon S3-compatible cloud file storage
27
28
  */
@@ -32,9 +33,10 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
32
33
  * @param {string} [filename] File name. Example "file.png"
33
34
  *
34
35
  * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
35
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example : "page"
36
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
37
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
36
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page"
37
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor"
38
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787
39
+ * @param {number} [fileQuery.template] - preview template identifier. Example: 1
38
40
  *
39
41
  * @returns Deletes a file from the cloud file storage
40
42
  */
@@ -47,8 +49,9 @@ export default class FileUploadingApi extends AsyncModules implements IFileUploa
47
49
  * @param {string} [type] - Type, determines the folder name in the storage
48
50
  * @param {string} [entity] - entity name, from which the file is uploaded, determines the folder name in the storage
49
51
  * @param {string} [filename] - Filename. Example "file.png"
52
+ * @param {string} [template] - preview template identifier. Example 1
50
53
  *
51
54
  * @returns Return file as File object
52
55
  */
53
- getFile(id: number, type: string, entity: string, filename?: string): Promise<Blob | IError>;
56
+ getFile(id: number, type: string, entity: string, filename?: string, template?: string): Promise<Blob | IError>;
54
57
  }
@@ -28,12 +28,13 @@ class FileUploadingApi extends asyncModules_1.default {
28
28
  * @param {File} [data] File objects. Get data as File from your unput as e.target.files[0]
29
29
  *
30
30
  * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
31
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example : "page"
32
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
33
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
34
- * @param {number} [fileQuery.width] - Optional width parameter. Example : 0
35
- * @param {number} [fileQuery.height] - Optional height parameter. Example : 0
36
- * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example : true
31
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page"
32
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor"
33
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787
34
+ * @param {number} [fileQuery.width] - Optional width parameter. Example: 0
35
+ * @param {number} [fileQuery.height] - Optional height parameter. Example: 0
36
+ * @param {boolean} [fileQuery.compress] - Optional flag of optimization (compression) for images. Example: true
37
+ * @param {boolean} [fileQuery.template] - preview template identifier. Example: 1
37
38
  *
38
39
  * @returns Uploads a file to an Amazon S3-compatible cloud file storage
39
40
  */
@@ -50,9 +51,10 @@ class FileUploadingApi extends asyncModules_1.default {
50
51
  * @param {string} [filename] File name. Example "file.png"
51
52
  *
52
53
  * @param {IUploadingQuery} [fileQuery] - Optional set query parameters.
53
- * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example : "page"
54
- * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example : "editor"
55
- * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example : 3787
54
+ * @param {string} [fileQuery.type] - Type, determines the folder name in the storage. Example: "page"
55
+ * @param {string} [fileQuery.entity] - Entity name from which the file is uploaded, determines the folder name in the storage. Example: "editor"
56
+ * @param {number} [fileQuery.id] - Identifier of the object from which the file is uploaded, determines the folder name in the storage. Example: 3787
57
+ * @param {number} [fileQuery.template] - preview template identifier. Example: 1
56
58
  *
57
59
  * @returns Deletes a file from the cloud file storage
58
60
  */
@@ -69,11 +71,12 @@ class FileUploadingApi extends asyncModules_1.default {
69
71
  * @param {string} [type] - Type, determines the folder name in the storage
70
72
  * @param {string} [entity] - entity name, from which the file is uploaded, determines the folder name in the storage
71
73
  * @param {string} [filename] - Filename. Example "file.png"
74
+ * @param {string} [template] - preview template identifier. Example 1
72
75
  *
73
76
  * @returns Return file as File object
74
77
  */
75
- async getFile(id, type, entity, filename) {
76
- const response = await fetch(this._getFullPath(`?id=${id}&type=${type}&entity=${entity}${filename ? `&filename=${filename}` : ''}`), {
78
+ async getFile(id, type, entity, filename, template) {
79
+ const response = await fetch(this._getFullPath(`?id=${id}&type=${type}&entity=${entity}${filename ? `&filename=${filename}` : ''}${template ? `&template=${template}` : ''}`), {
77
80
  method: 'GET',
78
81
  headers: {
79
82
  'Content-Type': 'application/json',
@@ -40,6 +40,8 @@ export default class IntegrationCollectionsApi extends AsyncModules implements I
40
40
  *
41
41
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
42
42
  * @param {number} [userQuery.offset] - Optional parameter for pagination, default is 30
43
+ * @param {number} [userQuery.entityType] - Entity type. Example: 1
44
+ * @param {number} [userQuery.entityId] - Entity identifier. Example: orders
43
45
  *
44
46
  * @returns Returns object ItemsWithTotal, where items is an array of requested objects
45
47
  */
@@ -56,6 +56,8 @@ class IntegrationCollectionsApi extends asyncModules_1.default {
56
56
  *
57
57
  * @param {number} [userQuery.limit] - Optional parameter for pagination, default is 0
58
58
  * @param {number} [userQuery.offset] - Optional parameter for pagination, default is 30
59
+ * @param {number} [userQuery.entityType] - Entity type. Example: 1
60
+ * @param {number} [userQuery.entityId] - Entity identifier. Example: orders
59
61
  *
60
62
  * @returns Returns object ItemsWithTotal, where items is an array of requested objects
61
63
  */
@@ -21,8 +21,8 @@ interface IMenus {
21
21
  */
22
22
  interface IMenusPages {
23
23
  children?: Array<IMenusPages> | IMenusPages;
24
- id: number;
25
- pageUrl: string;
24
+ id: number | null;
25
+ pageUrl: string | null;
26
26
  localizeInfos: ILocalizeInfo;
27
27
  attributeValues: any;
28
28
  position: number;
@@ -90,8 +90,8 @@ interface IBaseOrdersEntity {
90
90
  paymentAccountIdentifier: string;
91
91
  formData: Array<IOrdersFormData>;
92
92
  products: Array<IOrderProductData>;
93
- createdDate: string;
94
- totalSum: string;
93
+ createdDate?: string;
94
+ totalSum: number;
95
95
  currency: string;
96
96
  id: number;
97
97
  statusIdentifier?: string;
@@ -115,5 +115,6 @@ interface IAccountsEntity {
115
115
  localizeInfos: Record<string, any>;
116
116
  type: 'stripe' | 'custom';
117
117
  isVisible: boolean;
118
+ isUsed: boolean;
118
119
  }
119
120
  export type { IAccountsEntity, IConnectedEntity, ICreateSessionEntity, IIntent, IPaymentsApi, ISessionEntity, ISessionItem, ISessionsEntity, };
@@ -100,9 +100,9 @@ interface IProductsEntity {
100
100
  localizeInfos: Record<string, any>;
101
101
  isVisible: boolean;
102
102
  statusIdentifier: string | null;
103
- attributeSetIdentifier: string;
103
+ attributeSetIdentifier: string | null;
104
104
  isSync: number | boolean;
105
- price: number;
105
+ price: number | null;
106
106
  templateIdentifier: string | null;
107
107
  shortDescTemplateIdentifier: string | null;
108
108
  statusLocalizeInfos: Record<string, any>;
@@ -171,8 +171,8 @@ interface IProductBlock {
171
171
  productConfig: {
172
172
  quantity: string | number;
173
173
  countElementsPerRow: string | number;
174
- sortType?: string;
175
- sortOrder?: string;
174
+ sortType?: string | number;
175
+ sortOrder?: string | number;
176
176
  };
177
177
  similarProductRules: Array<{
178
178
  property: string;
@@ -29,7 +29,7 @@ interface ITemplatesPreviewEntity {
29
29
  version: number;
30
30
  identifier: string;
31
31
  attributeValues: AttributeType;
32
- attributeSetIdentifier: string | null;
32
+ attributeSetIdentifier?: string | null;
33
33
  proportion: {
34
34
  horizontal: IProportion | null;
35
35
  vertical: IProportion | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oneentry",
3
- "version": "1.0.116",
3
+ "version": "1.0.117",
4
4
  "description": "OneEntry NPM package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",