oneentry 1.0.138 → 1.0.140

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/README.md +16 -1
  2. package/configure.js +40 -21
  3. package/package.json +15 -12
  4. package/dist/admins/adminsApi.d.ts +0 -50
  5. package/dist/admins/adminsApi.js +0 -65
  6. package/dist/admins/adminsInterfaces.d.ts +0 -99
  7. package/dist/admins/adminsInterfaces.js +0 -2
  8. package/dist/admins/adminsSchemas.d.ts +0 -30
  9. package/dist/admins/adminsSchemas.js +0 -27
  10. package/dist/attribute-sets/attributeSetsApi.d.ts +0 -63
  11. package/dist/attribute-sets/attributeSetsApi.js +0 -98
  12. package/dist/attribute-sets/attributeSetsInterfaces.d.ts +0 -187
  13. package/dist/attribute-sets/attributeSetsInterfaces.js +0 -2
  14. package/dist/attribute-sets/attributeSetsSchemas.d.ts +0 -90
  15. package/dist/attribute-sets/attributeSetsSchemas.js +0 -74
  16. package/dist/auth-provider/authProviderApi.d.ts +0 -249
  17. package/dist/auth-provider/authProviderApi.js +0 -351
  18. package/dist/auth-provider/authProviderSchemas.d.ts +0 -137
  19. package/dist/auth-provider/authProviderSchemas.js +0 -85
  20. package/dist/auth-provider/authProvidersInterfaces.d.ts +0 -417
  21. package/dist/auth-provider/authProvidersInterfaces.js +0 -2
  22. package/dist/base/asyncModules.d.ts +0 -80
  23. package/dist/base/asyncModules.js +0 -440
  24. package/dist/base/result.d.ts +0 -39
  25. package/dist/base/result.js +0 -154
  26. package/dist/base/stateModule.d.ts +0 -41
  27. package/dist/base/stateModule.js +0 -128
  28. package/dist/base/syncModules.d.ts +0 -148
  29. package/dist/base/syncModules.js +0 -530
  30. package/dist/base/utils.d.ts +0 -197
  31. package/dist/base/utils.js +0 -2
  32. package/dist/base/validation.d.ts +0 -118
  33. package/dist/base/validation.js +0 -132
  34. package/dist/blocks/blocksApi.d.ts +0 -74
  35. package/dist/blocks/blocksApi.js +0 -184
  36. package/dist/blocks/blocksInterfaces.d.ts +0 -173
  37. package/dist/blocks/blocksInterfaces.js +0 -2
  38. package/dist/blocks/blocksSchemas.d.ts +0 -187
  39. package/dist/blocks/blocksSchemas.js +0 -43
  40. package/dist/events/eventsApi.d.ts +0 -60
  41. package/dist/events/eventsApi.js +0 -97
  42. package/dist/events/eventsInterfaces.d.ts +0 -87
  43. package/dist/events/eventsInterfaces.js +0 -2
  44. package/dist/file-uploading/fileUploadingApi.d.ts +0 -88
  45. package/dist/file-uploading/fileUploadingApi.js +0 -132
  46. package/dist/file-uploading/fileUploadingInterfaces.d.ts +0 -117
  47. package/dist/file-uploading/fileUploadingInterfaces.js +0 -2
  48. package/dist/file-uploading/fileUploadingSchemas.d.ts +0 -22
  49. package/dist/file-uploading/fileUploadingSchemas.js +0 -21
  50. package/dist/forms/formsApi.d.ts +0 -42
  51. package/dist/forms/formsApi.js +0 -57
  52. package/dist/forms/formsInterfaces.d.ts +0 -132
  53. package/dist/forms/formsInterfaces.js +0 -2
  54. package/dist/forms/formsSchemas.d.ts +0 -65
  55. package/dist/forms/formsSchemas.js +0 -36
  56. package/dist/forms-data/formsDataApi.d.ts +0 -106
  57. package/dist/forms-data/formsDataApi.js +0 -189
  58. package/dist/forms-data/formsDataInterfaces.d.ts +0 -525
  59. package/dist/forms-data/formsDataInterfaces.js +0 -2
  60. package/dist/forms-data/formsDataSchemas.d.ts +0 -115
  61. package/dist/forms-data/formsDataSchemas.js +0 -86
  62. package/dist/general-types/generalTypesApi.d.ts +0 -28
  63. package/dist/general-types/generalTypesApi.js +0 -38
  64. package/dist/general-types/generalTypesInterfaces.d.ts +0 -30
  65. package/dist/general-types/generalTypesInterfaces.js +0 -2
  66. package/dist/general-types/generalTypesSchemas.d.ts +0 -50
  67. package/dist/general-types/generalTypesSchemas.js +0 -35
  68. package/dist/index.d.ts +0 -94
  69. package/dist/index.js +0 -97
  70. package/dist/integration-collections/integrationCollectionsApi.d.ts +0 -173
  71. package/dist/integration-collections/integrationCollectionsApi.js +0 -220
  72. package/dist/integration-collections/integrationCollectionsInterfaces.d.ts +0 -313
  73. package/dist/integration-collections/integrationCollectionsInterfaces.js +0 -2
  74. package/dist/integration-collections/integrationCollectionsSchemas.d.ts +0 -84
  75. package/dist/integration-collections/integrationCollectionsSchemas.js +0 -63
  76. package/dist/locales/localesApi.d.ts +0 -27
  77. package/dist/locales/localesApi.js +0 -37
  78. package/dist/locales/localesInterfaces.d.ts +0 -41
  79. package/dist/locales/localesInterfaces.js +0 -2
  80. package/dist/locales/localesSchemas.d.ts +0 -32
  81. package/dist/locales/localesSchemas.js +0 -26
  82. package/dist/menus/menusApi.d.ts +0 -29
  83. package/dist/menus/menusApi.js +0 -39
  84. package/dist/menus/menusInterfaces.d.ts +0 -88
  85. package/dist/menus/menusInterfaces.js +0 -4
  86. package/dist/menus/menusSchemas.d.ts +0 -16
  87. package/dist/menus/menusSchemas.js +0 -28
  88. package/dist/orders/ordersApi.d.ts +0 -126
  89. package/dist/orders/ordersApi.js +0 -169
  90. package/dist/orders/ordersInterfaces.d.ts +0 -427
  91. package/dist/orders/ordersInterfaces.js +0 -2
  92. package/dist/orders/ordersSchemas.d.ts +0 -158
  93. package/dist/orders/ordersSchemas.js +0 -120
  94. package/dist/pages/pagesApi.d.ts +0 -151
  95. package/dist/pages/pagesApi.js +0 -390
  96. package/dist/pages/pagesInterfaces.d.ts +0 -292
  97. package/dist/pages/pagesInterfaces.js +0 -2
  98. package/dist/pages/pagesSchemas.d.ts +0 -85
  99. package/dist/pages/pagesSchemas.js +0 -46
  100. package/dist/payments/paymentsApi.d.ts +0 -82
  101. package/dist/payments/paymentsApi.js +0 -121
  102. package/dist/payments/paymentsInterfaces.d.ts +0 -206
  103. package/dist/payments/paymentsInterfaces.js +0 -2
  104. package/dist/payments/paymentsSchemas.d.ts +0 -137
  105. package/dist/payments/paymentsSchemas.js +0 -78
  106. package/dist/product-statuses/productStatusesApi.d.ts +0 -47
  107. package/dist/product-statuses/productStatusesApi.js +0 -70
  108. package/dist/product-statuses/productStatusesInterfaces.d.ts +0 -66
  109. package/dist/product-statuses/productStatusesInterfaces.js +0 -2
  110. package/dist/product-statuses/productStatusesSchemas.d.ts +0 -34
  111. package/dist/product-statuses/productStatusesSchemas.js +0 -30
  112. package/dist/products/productsApi.d.ts +0 -365
  113. package/dist/products/productsApi.js +0 -464
  114. package/dist/products/productsInterfaces.d.ts +0 -583
  115. package/dist/products/productsInterfaces.js +0 -2
  116. package/dist/products/productsSchemas.d.ts +0 -212
  117. package/dist/products/productsSchemas.js +0 -85
  118. package/dist/system/systemApi.d.ts +0 -65
  119. package/dist/system/systemApi.js +0 -82
  120. package/dist/system/systemInterfaces.d.ts +0 -23
  121. package/dist/system/systemInterfaces.js +0 -2
  122. package/dist/templates/templatesApi.d.ts +0 -49
  123. package/dist/templates/templatesApi.js +0 -75
  124. package/dist/templates/templatesInterfaces.d.ts +0 -70
  125. package/dist/templates/templatesInterfaces.js +0 -2
  126. package/dist/templates/templatesSchemas.d.ts +0 -48
  127. package/dist/templates/templatesSchemas.js +0 -31
  128. package/dist/templates-preview/templatesPreviewApi.d.ts +0 -38
  129. package/dist/templates-preview/templatesPreviewApi.js +0 -53
  130. package/dist/templates-preview/templatesPreviewInterfaces.d.ts +0 -121
  131. package/dist/templates-preview/templatesPreviewInterfaces.js +0 -2
  132. package/dist/templates-preview/templatesPreviewSchemas.d.ts +0 -83
  133. package/dist/templates-preview/templatesPreviewSchemas.js +0 -48
  134. package/dist/users/usersApi.d.ts +0 -143
  135. package/dist/users/usersApi.js +0 -174
  136. package/dist/users/usersInterfaces.d.ts +0 -235
  137. package/dist/users/usersInterfaces.js +0 -2
  138. package/dist/users/usersSchemas.d.ts +0 -38
  139. package/dist/users/usersSchemas.js +0 -28
  140. package/dist/web-socket/wsApi.d.ts +0 -25
  141. package/dist/web-socket/wsApi.js +0 -45
  142. package/dist/web-socket/wsInterfaces.d.ts +0 -17
  143. package/dist/web-socket/wsInterfaces.js +0 -2
@@ -1,530 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // Using WeakMap to store unique instance IDs for each object instance
4
- const instanceIds = new WeakMap();
5
- // Counter to ensure even more uniqueness
6
- let instanceCounter = 0;
7
- /**
8
- * Abstract class representing synchronization modules.
9
- */
10
- class SyncModules {
11
- /**
12
- * Constructor to initialize state and URL.
13
- * @param {StateModule} state - StateModule instance.
14
- */
15
- constructor(state) {
16
- /**
17
- * Sorts attributes by their positions.
18
- * @param {any} data - The data containing attributes.
19
- * @returns {any} Sorted attributes.
20
- */
21
- this._sortAttributes = (data) => Object.fromEntries(Object.entries(data).sort(([, a], [, b]) => a.position - b.position));
22
- this.state = state;
23
- this._url = state.url;
24
- // Generate and store a unique instance ID using WeakMap
25
- if (!instanceIds.has(this)) {
26
- const timestampPart = Date.now().toString(36);
27
- const randomPart = Math.random().toString(36).substring(2, 15) +
28
- Math.random().toString(36).substring(2, 15);
29
- const counterPart = (++instanceCounter).toString(36);
30
- const instanceId = `${timestampPart}${randomPart}${counterPart}`;
31
- instanceIds.set(this, instanceId);
32
- }
33
- }
34
- /**
35
- * Constructs the full URL path by appending the given path to the base URL.
36
- * @param {string} path - The path to append to the base URL.
37
- * @returns {string} The full URL as a string.
38
- */
39
- _getFullPath(path) {
40
- return this._url + path;
41
- }
42
- /**
43
- * Converts query parameters into a query string.
44
- * @param {IProductsQuery | IUploadingQuery | any} query - The query object containing key-value pairs.
45
- * @returns {string} A string representation of the query parameters.
46
- */
47
- _queryParamsToString(query) {
48
- let result = '';
49
- for (const key in query) {
50
- if (query[key] !== null) {
51
- result += `${key}=${query[key]}&`;
52
- }
53
- }
54
- return result.slice(0, result.length - 1);
55
- }
56
- /**
57
- * Normalizes data based on language code.
58
- * @param {any} data - The data to normalize.
59
- * @param {string} langCode - The language code for normalization.
60
- * @returns {any} Normalized data.
61
- */
62
- _normalizeData(data, langCode = this.state.lang) {
63
- if (Array.isArray(data)) {
64
- return this._normalizeAttr(data.map((item) => this._normalizeData(item, langCode)));
65
- }
66
- else if (typeof data === 'object' && data) {
67
- const normalizeData = {};
68
- for (const key in data) {
69
- if (Array.isArray(data[key])) {
70
- normalizeData[key] = this._normalizeData(data[key], langCode);
71
- }
72
- else if (!data[key] || typeof data[key] !== 'object') {
73
- normalizeData[key] = data[key];
74
- }
75
- else if (langCode in data[key]) {
76
- normalizeData[key] = data[key][langCode];
77
- }
78
- else {
79
- normalizeData[key] = this._normalizeData(data[key], langCode);
80
- }
81
- }
82
- return this._normalizeAttr(normalizeData);
83
- }
84
- else {
85
- return data;
86
- }
87
- }
88
- /**
89
- * Normalizes the body of a POST request.
90
- * @param {any} body - The body to normalize.
91
- * @param {string} [langCode] - The language code for normalization.
92
- * @returns {any} Normalized body.
93
- */
94
- _normalizePostBody(body, langCode = this.state.lang) {
95
- const formData = {};
96
- formData[langCode] = Array.isArray(body.formData)
97
- ? body.formData
98
- : [body.formData];
99
- body.formData = formData;
100
- return body;
101
- }
102
- /**
103
- * Clears arrays within the data structure.
104
- * @param {Record<string, any>} data - The data to clear.
105
- * @returns {any} Cleared data.
106
- */
107
- _clearArray(data) {
108
- if (Array.isArray(data)) {
109
- return data.map((item) => this._clearArray(item));
110
- }
111
- else if (typeof data === 'object' && data) {
112
- const normalizeData = {};
113
- for (const key in data) {
114
- if (Array.isArray(data[key])) {
115
- normalizeData[key] = this._clearArray(data[key]);
116
- }
117
- else if (!data[key] || typeof data[key] !== 'object') {
118
- normalizeData[key] = data[key];
119
- }
120
- else if (key === 'attributeValues') {
121
- const attrs = data[key];
122
- for (const attr in attrs) {
123
- if (attrs[attr].type === 'image' &&
124
- attrs[attr].value.length === 1) {
125
- attrs[attr].value = attrs[attr].value[0];
126
- }
127
- }
128
- normalizeData[key] = data[key];
129
- }
130
- else {
131
- normalizeData[key] = this._clearArray(data[key]);
132
- }
133
- }
134
- return normalizeData;
135
- }
136
- else {
137
- return data;
138
- }
139
- }
140
- /**
141
- * Adds a specified number of days to a date.
142
- * @param {Date} date - The initial date.
143
- * @param {number} days - The number of days to add.
144
- * @returns {any} The new date with added days.
145
- */
146
- _addDays(date, days) {
147
- const result = new Date(date);
148
- result.setUTCDate(result.getUTCDate() + days);
149
- return result;
150
- }
151
- /**
152
- * Common logic for processing schedule dates (weekly, monthly, or both).
153
- * @param {Date} date - The date for which to process intervals.
154
- * @param {object} config - Configuration for schedule repetition.
155
- * @param {boolean} config.inEveryWeek - Whether to repeat weekly.
156
- * @param {boolean} config.inEveryMonth - Whether to repeat monthly.
157
- * @param {Function} processDate - Callback function to process each date.
158
- */
159
- _processScheduleDates(date, config, processDate) {
160
- // Handle weekly schedules
161
- if (config.inEveryWeek && !config.inEveryMonth) {
162
- let currentDate = new Date(date);
163
- // Calculate the last day of the current month
164
- const endOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
165
- while (currentDate <= endOfMonth) {
166
- processDate(currentDate);
167
- // Move to the next week
168
- currentDate = this._addDays(currentDate, 7);
169
- }
170
- }
171
- // Handle monthly schedules
172
- if (config.inEveryMonth && !config.inEveryWeek) {
173
- const startDate = new Date(date);
174
- const targetDayOfMonth = startDate.getUTCDate();
175
- const numberOfMonths = 12;
176
- for (let i = 0; i < numberOfMonths; i++) {
177
- const currentDate = new Date(startDate);
178
- currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
179
- // Try setting the current date to the target day of the month
180
- currentDate.setUTCDate(targetDayOfMonth);
181
- // Check if we have exceeded the month
182
- if (currentDate.getUTCMonth() !== (startDate.getUTCMonth() + i) % 12) {
183
- continue; // Skip this month if exceeded
184
- }
185
- processDate(currentDate);
186
- }
187
- }
188
- // Handle both weekly and monthly schedules
189
- if (config.inEveryMonth && config.inEveryWeek) {
190
- const startDate = new Date(date);
191
- const targetDayOfWeek = startDate.getUTCDay();
192
- const numberOfMonths = 12;
193
- for (let i = 0; i < numberOfMonths; i++) {
194
- const currentDate = new Date(startDate);
195
- currentDate.setUTCMonth(currentDate.getUTCMonth() + i);
196
- // Set to the first day of the month
197
- currentDate.setUTCDate(1);
198
- // Find the first target day of the week in the current month
199
- const daysUntilTargetDay = (targetDayOfWeek - currentDate.getUTCDay() + 7) % 7;
200
- currentDate.setUTCDate(currentDate.getUTCDate() + daysUntilTargetDay);
201
- // Iterate over all target days of the week in the current month
202
- while (currentDate.getUTCMonth() ===
203
- (startDate.getUTCMonth() + i) % 12) {
204
- processDate(currentDate);
205
- // Move to the next week (same day of the week)
206
- currentDate.setUTCDate(currentDate.getUTCDate() + 7);
207
- }
208
- }
209
- }
210
- }
211
- /**
212
- * Generates intervals for a specific date based on a schedule.
213
- * @param {Date} date - The date for which to generate intervals.
214
- * @param {object} schedule - The schedule defining the intervals.
215
- * @param {boolean} schedule.inEveryWeek - The number of weeks between intervals.
216
- * @param {any[]} schedule.times - The times for each interval.
217
- * @param {boolean} schedule.inEveryMonth - The month intervals for each interval.
218
- * @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
219
- */
220
- _generateIntervalsForDate(date, schedule, utcIntervals) {
221
- this._processScheduleDates(date, schedule, (currentDate) => {
222
- schedule.times.forEach((timeRange) => {
223
- const [startTime, endTime] = timeRange;
224
- const intervalStart = new Date(currentDate);
225
- intervalStart.setUTCHours(startTime.hours, startTime.minutes, 0, 0);
226
- const intervalEnd = new Date(currentDate);
227
- intervalEnd.setUTCHours(endTime.hours, endTime.minutes, 0, 0);
228
- utcIntervals.add([
229
- intervalStart.toISOString(),
230
- intervalEnd.toISOString(),
231
- ]);
232
- });
233
- });
234
- }
235
- /**
236
- * Adds time intervals to schedules.
237
- * @param {any[]} schedules - The schedules to process.
238
- * @returns {any} Schedules with added time intervals.
239
- */
240
- _addTimeIntervalsToSchedules(schedules) {
241
- schedules === null || schedules === void 0 ? void 0 : schedules.forEach((scheduleGroup) => {
242
- // Skip if scheduleGroup.values is not an array
243
- if (!scheduleGroup ||
244
- !scheduleGroup.values ||
245
- !Array.isArray(scheduleGroup.values)) {
246
- return;
247
- }
248
- scheduleGroup.values.forEach((schedule) => {
249
- const utcIntervals = new Set();
250
- const startDate = new Date(schedule.dates[0]);
251
- const endDate = new Date(schedule.dates[1]);
252
- const isSameDay = startDate.toISOString() === endDate.toISOString();
253
- if (isSameDay) {
254
- this._generateIntervalsForDate(startDate, schedule, utcIntervals);
255
- }
256
- else {
257
- for (let currentDate = new Date(startDate); currentDate <= endDate; currentDate = this._addDays(currentDate, 1)) {
258
- this._generateIntervalsForDate(currentDate, schedule, utcIntervals);
259
- }
260
- }
261
- schedule.timeIntervals = Array.from(utcIntervals).sort();
262
- });
263
- });
264
- return schedules;
265
- }
266
- /**
267
- * Generates intervals for a specific date for form schedules.
268
- * @param {Date} date - The date for which to generate intervals.
269
- * @param {object} interval - The interval configuration.
270
- * @param {boolean} interval.inEveryWeek - Indicates whether the schedule is weekly.
271
- * @param {boolean} interval.inEveryMonth - Indicates whether the schedule is monthly.
272
- * @param {any[]} timeIntervals - The time intervals to process.
273
- * @param {Set<Array<string>>} utcIntervals - A set to store unique intervals.
274
- */
275
- _generateIntervalsForFormDate(date, interval, timeIntervals, utcIntervals) {
276
- const generateTimeSlotsForDate = (currentDate) => {
277
- timeIntervals.forEach((timeInterval) => {
278
- let currentStart = timeInterval.start;
279
- const endTime = timeInterval.end;
280
- while (currentStart.hours < endTime.hours ||
281
- (currentStart.hours === endTime.hours &&
282
- currentStart.minutes < endTime.minutes)) {
283
- const intervalStart = new Date(currentDate);
284
- intervalStart.setUTCHours(currentStart.hours, currentStart.minutes, 0, 0);
285
- const nextMinutes = currentStart.minutes + timeInterval.period;
286
- const nextHours = currentStart.hours + Math.floor(nextMinutes / 60);
287
- const minutes = nextMinutes % 60;
288
- if (nextHours > endTime.hours ||
289
- (nextHours === endTime.hours && minutes > endTime.minutes)) {
290
- break;
291
- }
292
- const intervalEnd = new Date(currentDate);
293
- intervalEnd.setUTCHours(nextHours, minutes, 0, 0);
294
- utcIntervals.add([
295
- intervalStart.toISOString(),
296
- intervalEnd.toISOString(),
297
- ]);
298
- currentStart = { hours: nextHours, minutes };
299
- }
300
- });
301
- };
302
- this._processScheduleDates(date, interval, generateTimeSlotsForDate);
303
- }
304
- /**
305
- * Adds time intervals to form schedules (different structure).
306
- * @param {any[]} intervals - The intervals to process.
307
- * @returns {any} Intervals with added time intervals.
308
- */
309
- _addTimeIntervalsToFormSchedules(intervals) {
310
- intervals.forEach((interval) => {
311
- var _a, _b;
312
- if (!interval.intervals || !Array.isArray(interval.intervals)) {
313
- return;
314
- }
315
- const utcIntervals = new Set();
316
- const startDate = new Date(interval.range[0]);
317
- const endDate = new Date(interval.range[1]);
318
- const isSameDay = startDate.toISOString() === endDate.toISOString();
319
- const intervalConfig = {
320
- inEveryWeek: (_a = interval.inEveryWeek) !== null && _a !== void 0 ? _a : false,
321
- inEveryMonth: (_b = interval.inEveryMonth) !== null && _b !== void 0 ? _b : false,
322
- };
323
- if (isSameDay) {
324
- this._generateIntervalsForFormDate(startDate, intervalConfig, interval.intervals, utcIntervals);
325
- }
326
- else {
327
- for (let currentDate = new Date(startDate); currentDate <= endDate; currentDate = this._addDays(currentDate, 1)) {
328
- this._generateIntervalsForFormDate(currentDate, intervalConfig, interval.intervals, utcIntervals);
329
- }
330
- }
331
- interval.timeIntervals = Array.from(utcIntervals).sort();
332
- });
333
- return intervals;
334
- }
335
- /**
336
- * Transforms additionalFields from array to object keyed by marker.
337
- * Skipped when rawData is enabled in config.
338
- * @param {any} attr - The attribute object that may contain additionalFields.
339
- */
340
- _normalizeAdditionalFields(attr) {
341
- if (!this.state.rawData && Array.isArray(attr.additionalFields)) {
342
- attr.additionalFields = Object.fromEntries(attr.additionalFields.map((field) => [field.marker, field]));
343
- }
344
- }
345
- /**
346
- * Normalizes attributes within the data.
347
- * @param {any} data - The data to normalize.
348
- * @returns {any} Normalized attributes.
349
- */
350
- _normalizeAttr(data) {
351
- var _a;
352
- // For regular attributes collections - pages, products, etc.
353
- if ('attributeValues' in data) {
354
- for (const attr in data.attributeValues) {
355
- const d = data.attributeValues[attr];
356
- this._normalizeAdditionalFields(d);
357
- // normalize numbers
358
- if (d.type === 'integer' || d.type === 'float') {
359
- const numValue = Number(d.value);
360
- d.value = isNaN(numValue) ? null : numValue;
361
- }
362
- // add timeIntervals
363
- if (data.attributeValues[attr].type === 'timeInterval') {
364
- const schedules = data.attributeValues[attr].value;
365
- // console.log('Schedules: ', JSON.stringify(schedules));
366
- if (Array.isArray(schedules) && schedules.length > 0) {
367
- const result = this._addTimeIntervalsToSchedules(schedules);
368
- data.attributeValues[attr].value = result;
369
- }
370
- }
371
- }
372
- return {
373
- ...data,
374
- attributeValues: this._sortAttributes(data.attributeValues),
375
- };
376
- }
377
- // for forms attributes - forms attributes collections
378
- if ('attributes' in data) {
379
- const d = data.attributes;
380
- for (const attr in d) {
381
- this._normalizeAdditionalFields(d[attr]);
382
- // Normalize numbers
383
- // if (d[attr].type === 'integer' || d[attr].type === 'float') {
384
- // const numValue = Number(d[attr].value);
385
- // d[attr].value = isNaN(numValue) ? null : numValue;
386
- // }
387
- // Add time intervals
388
- if (d[attr].type === 'timeInterval') {
389
- const intervals = (_a = d[attr].localizeInfos) === null || _a === void 0 ? void 0 : _a.intervals;
390
- // console.log('Schedules:: ', JSON.stringify(intervals));
391
- if (intervals && Array.isArray(intervals) && intervals.length > 0) {
392
- const result = this._addTimeIntervalsToFormSchedules(intervals);
393
- d[attr].localizeInfos.intervals = result;
394
- }
395
- }
396
- }
397
- return data;
398
- }
399
- // For single attribute - for attribute sets
400
- if ('type' in data) {
401
- this._normalizeAdditionalFields(data);
402
- // Normalize numbers
403
- if (data.type === 'integer' || data.type === 'float') {
404
- const numValue = Number(data.value);
405
- data.value = isNaN(numValue) ? null : numValue;
406
- }
407
- // Add time intervals
408
- if (data.type === 'timeInterval') {
409
- const schedules = data.value;
410
- if (Array.isArray(schedules) && schedules.length > 0) {
411
- const result = this._addTimeIntervalsToSchedules(schedules);
412
- data.value = result;
413
- }
414
- }
415
- }
416
- return data;
417
- }
418
- /**
419
- * Processes data after fetching or receiving it.
420
- * @param {any} data - The data to process.
421
- * @param {any} [langCode] - The language code for processing.
422
- * @returns {any} Processed data.
423
- */
424
- _dataPostProcess(data, langCode = this.state.lang) {
425
- const normalize = this._normalizeData(data, langCode);
426
- const result = this._clearArray(normalize);
427
- return result;
428
- }
429
- /**
430
- * Sets the access token in the state.
431
- * @param {string} accessToken - The access token to set.
432
- * @returns {any} The instance of SyncModules for chaining.
433
- */
434
- setAccessToken(accessToken) {
435
- this.state.accessToken = accessToken;
436
- return this;
437
- }
438
- /**
439
- * Sets the refresh token in the state.
440
- * @param {string} refreshToken - The refresh token to set.
441
- * @returns {any} The instance of SyncModules for chaining.
442
- */
443
- setRefreshToken(refreshToken) {
444
- this.state.refreshToken = refreshToken;
445
- return this;
446
- }
447
- /**
448
- * Get deviceMetadata
449
- * @returns {string} - Returns an object containing device metadata.
450
- */
451
- _getDeviceMetadata() {
452
- // Check if we're in a browser environment
453
- if (typeof globalThis === 'undefined') {
454
- return '';
455
- }
456
- // Access navigator through globalThis.window object to avoid direct reference
457
- const win = globalThis.window;
458
- // Get the instance ID from the WeakMap
459
- const instanceId = instanceIds.get(this) ||
460
- Date.now().toString(36) +
461
- Math.random().toString(36).substring(2, 15) +
462
- Math.random().toString(36).substring(2, 15) +
463
- (++instanceCounter).toString(36);
464
- // Node.js environment - unique per-instance fingerprint (no shared process ID)
465
- if (!win) {
466
- return JSON.stringify({
467
- fingerprint: `UQ_${instanceId}`,
468
- deviceInfo: {
469
- os: 'Node.js',
470
- browser: `Node.js/${instanceId.substring(0, 10)}`,
471
- location: 'en-US',
472
- },
473
- });
474
- }
475
- const nav = win.navigator || {};
476
- const platform = nav.platform || 'Win32';
477
- const userAgent = nav.userAgent || 'Node.js/22';
478
- const language = nav.language || 'en-US';
479
- // Get screen information if available
480
- const screen = win.screen || {};
481
- const screenWidth = screen.width || 0;
482
- const screenHeight = screen.height || 0;
483
- const colorDepth = screen.colorDepth || 0;
484
- // Get timezone
485
- let timezone = 'UTC';
486
- try {
487
- timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
488
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
489
- }
490
- catch (e) {
491
- // Ignore error, fallback to UTC
492
- }
493
- // Detect private browsing mode
494
- let isPrivateBrowsing = false;
495
- try {
496
- // Simple localStorage test to detect private browsing
497
- if (win.localStorage) {
498
- const testKey = 'test_private_browsing';
499
- win.localStorage.setItem(testKey, '1');
500
- win.localStorage.removeItem(testKey);
501
- }
502
- else {
503
- isPrivateBrowsing = true; // If localStorage is not available, likely private browsing
504
- }
505
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
506
- }
507
- catch (e) {
508
- isPrivateBrowsing = true; // Error during localStorage access indicates private browsing
509
- }
510
- // Create a stable fingerprint string using stable device/browser characteristics
511
- const fingerprintString = `${platform}|${userAgent}|${language}|${screenWidth}|${screenHeight}|${colorDepth}|${timezone}|${isPrivateBrowsing ? 'private' : 'normal'}|${instanceId}`;
512
- // Simple but stable hash function
513
- let hash = 0;
514
- for (let i = 0; i < fingerprintString.length; i++) {
515
- const char = fingerprintString.charCodeAt(i);
516
- hash = (hash << 5) - hash + char;
517
- hash = hash & hash; // Convert to 32-bit integer
518
- }
519
- const deviceMetadata = {
520
- fingerprint: `UQ_${Math.abs(hash).toString(36)}_${instanceId.substring(0, 12)}`,
521
- deviceInfo: {
522
- os: platform.replace(/ /g, '_'),
523
- browser: userAgent.replace(/ /g, '_'),
524
- location: language,
525
- },
526
- };
527
- return JSON.stringify(deviceMetadata);
528
- }
529
- }
530
- exports.default = SyncModules;