@acorex/connectivity 20.0.23 → 20.0.25

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.
@@ -2,12 +2,12 @@ import * as i1 from '@acorex/platform/core';
2
2
  import { AXPSystemActionType, extractTextFromHtml, AXPDataGenerator, applySortArray, applyFilterArray, AXPActivityLogProvider, AXP_ACTIVITY_LOG_PROVIDER } from '@acorex/platform/core';
3
3
  import Dexie from 'dexie';
4
4
  import { transform, isEqual } from 'lodash';
5
- import { AXPEntityDefinitionRegistryService, AXPEntityStorageService, AXP_DATA_SEEDER_TOKEN, AXPDataSeederService } from '@acorex/platform/layout/entity';
6
5
  import * as i2 from '@acorex/platform/auth';
7
6
  import { AXPSessionService, AXP_APPLICATION_LOADER, AXP_FEATURE_LOADER, AXP_PERMISSION_LOADER, AXP_TENANT_LOADER, AXPAuthModule } from '@acorex/platform/auth';
7
+ import { AXPLockService, AXPFileStorageStatus, AXPFileStorageService, AXPRegionalService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
8
+ import { AXPEntityDefinitionRegistryService, AXPEntityStorageService, AXP_DATA_SEEDER_TOKEN, AXPDataSeederService } from '@acorex/platform/layout/entity';
8
9
  import * as i0 from '@angular/core';
9
10
  import { inject, Injectable, NgModule } from '@angular/core';
10
- import { AXPLockService, AXPFileStorageStatus, AXPFileStorageService, AXPRegionalService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
11
11
  import { AXSafePipe } from '@acorex/core/pipes';
12
12
  import { RootConfig, AXMUsersEntityService, AXMSessionStatusTypes, AXMDeviceSessionsServiceImpl, AXMDeviceSessionsService } from '@acorex/modules/security-management';
13
13
  import { AXMFormTemplateTypes, RootConfig as RootConfig$1, AXMFormTemplateManagementCategoryEntityServiceImpl, AXMFormTemplateManagementCategoryEntityService, AXMPermissionsKeys } from '@acorex/modules/form-template-management';
@@ -59,31 +59,31 @@ class AXPDexieEntityStorageService extends Dexie {
59
59
  const hasId = newArray.length > 0 && typeof newArray[0] === 'object' && newArray[0] !== null && 'id' in newArray[0];
60
60
  if (hasId) {
61
61
  // Compare by id for objects with id
62
- const added = newArray.filter(item => !oldArray.some(oldItem => oldItem.id === item.id));
63
- const removed = oldArray.filter(item => !newArray.some(newItem => newItem.id === item.id));
62
+ const added = newArray.filter((item) => !oldArray.some((oldItem) => oldItem.id === item.id));
63
+ const removed = oldArray.filter((item) => !newArray.some((newItem) => newItem.id === item.id));
64
64
  result[key] = {
65
65
  oldValue: oldObj[key],
66
66
  newValue: value,
67
67
  added,
68
- removed
68
+ removed,
69
69
  };
70
70
  }
71
71
  else {
72
72
  // For primitive arrays or objects without id, use deep comparison
73
- const added = newArray.filter(item => !oldArray.some(oldItem => isEqual(item, oldItem)));
74
- const removed = oldArray.filter(item => !newArray.some(newItem => isEqual(item, newItem)));
73
+ const added = newArray.filter((item) => !oldArray.some((oldItem) => isEqual(item, oldItem)));
74
+ const removed = oldArray.filter((item) => !newArray.some((newItem) => isEqual(item, newItem)));
75
75
  result[key] = {
76
76
  oldValue: oldObj[key],
77
77
  newValue: value,
78
78
  added,
79
- removed
79
+ removed,
80
80
  };
81
81
  }
82
82
  }
83
83
  else {
84
84
  result[key] = {
85
85
  oldValue: oldObj[key],
86
- newValue: value
86
+ newValue: value,
87
87
  };
88
88
  }
89
89
  }
@@ -111,7 +111,7 @@ class AXPDexieEntityStorageService extends Dexie {
111
111
  let transformedChanges = {};
112
112
  if (changeType === 'update' && changes && entityConfig) {
113
113
  for (const [key, value] of Object.entries(changes)) {
114
- const property = entityConfig.properties.find(p => p.name === key);
114
+ const property = entityConfig.properties.find((p) => p.name === key);
115
115
  if (property && property.schema.interface) {
116
116
  const widgetType = property.schema.interface.type;
117
117
  // Handle different widget types
@@ -120,13 +120,13 @@ class AXPDexieEntityStorageService extends Dexie {
120
120
  if (value.added?.length) {
121
121
  actions.push({
122
122
  type: AXPSystemActionType.Upload,
123
- description: `"${value.added?.map(item => item.name).join(', ')}"`
123
+ description: `"${value.added?.map((item) => item.name).join(', ')}"`,
124
124
  });
125
125
  }
126
126
  if (value.removed?.length) {
127
127
  actions.push({
128
128
  type: AXPSystemActionType.Delete,
129
- description: `"${value.removed?.map(item => item.name).join(', ')}"`
129
+ description: `"${value.removed?.map((item) => item.name).join(', ')}"`,
130
130
  });
131
131
  }
132
132
  transformedChanges[key] = {
@@ -139,7 +139,7 @@ class AXPDexieEntityStorageService extends Dexie {
139
139
  const safeValue = extractTextFromHtml(value.newValue);
140
140
  actions.push({
141
141
  type: AXPSystemActionType.Update,
142
- description: `${property.title} to "${safeValue.length > 100 ? safeValue.slice(0, 30) + '...' : safeValue}"`
142
+ description: `${property.title} to "${safeValue.length > 100 ? safeValue.slice(0, 30) + '...' : safeValue}"`,
143
143
  });
144
144
  transformedChanges[key] = {
145
145
  ...value,
@@ -149,7 +149,7 @@ class AXPDexieEntityStorageService extends Dexie {
149
149
  case 'text-editor':
150
150
  actions.push({
151
151
  type: AXPSystemActionType.Update,
152
- description: `${property.title} to "${value.newValue.length > 100 ? value.newValue.slice(0, 30) + '...' : value.newValue}"`
152
+ description: `${property.title} to "${value.newValue.length > 100 ? value.newValue.slice(0, 30) + '...' : value.newValue}"`,
153
153
  });
154
154
  transformedChanges[key] = {
155
155
  ...value,
@@ -160,7 +160,7 @@ class AXPDexieEntityStorageService extends Dexie {
160
160
  //TODO @ a.b not working
161
161
  actions.push({
162
162
  type: AXPSystemActionType.Update,
163
- description: `${property.title}`
163
+ description: `${property.title}`,
164
164
  });
165
165
  transformedChanges[key] = {
166
166
  ...value,
@@ -186,13 +186,13 @@ class AXPDexieEntityStorageService extends Dexie {
186
186
  },
187
187
  changeType: changeType,
188
188
  changes: actions,
189
- data: { ...entity }
189
+ data: { ...entity },
190
190
  };
191
191
  // Add history record
192
192
  await this.table('entity-store').add({
193
193
  ...data,
194
194
  entityName: historyEntityName,
195
- isCurrent: true
195
+ isCurrent: true,
196
196
  });
197
197
  }
198
198
  //#region ---- Initialization Methods ----
@@ -207,23 +207,18 @@ class AXPDexieEntityStorageService extends Dexie {
207
207
  * bulk-inserted.
208
208
  */
209
209
  async initial(entityName, collection, options = { mergeType: 'merge', uniqueKeys: ['name'] }) {
210
- // Return early when collection is empty
211
210
  if (!collection?.length) {
212
211
  return collection;
213
212
  }
214
- // Build existence check based on provided unique keys rather than hard-coded `id`
215
- const firstItem = collection[0];
216
213
  const uniqueKeys = options.uniqueKeys;
217
214
  let exists = 0;
218
- if (await this.table('entity-store').where({ entityName }).count() > 0) {
219
- for (const key of uniqueKeys) {
220
- const existingRecord = await this.table('entity-store')
221
- .where({ entityName })
222
- .filter((rec) => rec[key] === firstItem[key])
223
- .first();
215
+ if ((await this.table('entity-store').where({ entityName }).count()) > 0) {
216
+ const allRecords = await this.table('entity-store').where({ entityName }).toArray();
217
+ for (const item of collection) {
218
+ const existingRecord = allRecords.find((rec) => uniqueKeys.every((key) => rec[key] === item[key]));
224
219
  if (existingRecord) {
225
220
  exists = 1;
226
- break; // Stop iterating once a match is found
221
+ break;
227
222
  }
228
223
  }
229
224
  }