@acorex/connectivity 20.0.22 → 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, AXPRegionalService, AXPFileStorageService, 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';
@@ -23,7 +23,6 @@ import { filter, throttleTime, take, of, delay, firstValueFrom } from 'rxjs';
23
23
  import { AXMPermissionsKeys as AXMPermissionsKeys$1, RootConfig as RootConfig$e } from '@acorex/modules/issue-management';
24
24
  import { RootConfig as RootConfig$7, AXMMetaDataDefinitionCategoryServiceImpl, AXMMetaDataDefinitionService, AXMMetaDataDefinitionCategoryService } from '@acorex/modules/platform-management';
25
25
  import { AXFileService } from '@acorex/core/file';
26
- import { AXTranslationService } from '@acorex/core/translation';
27
26
  import { RootConfig as RootConfig$8 } from '@acorex/modules/text-template-management';
28
27
  import { RootConfig as RootConfig$9 } from '@acorex/modules/scheduler-job-management';
29
28
  import { APPLICATION_SOURCE_NAME, MODULE_SOURCE_NAME, ENTITY_SOURCE_NAME, FEATURE_SOURCE_NAME, PERMISSION_SOURCE_NAME, PROPERTY_SOURCE_NAME, AXPModuleDesignerService } from '@acorex/modules/application-management';
@@ -31,6 +30,7 @@ import { RootConfig as RootConfig$b } from '@acorex/modules/training-management'
31
30
  import { RootConfig as RootConfig$c } from '@acorex/modules/project-management';
32
31
  import { RootConfig as RootConfig$d, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMFolderService, AXMDocumentService } from '@acorex/modules/document-management';
33
32
  import { RootConfig as RootConfig$f } from '@acorex/modules/log-management';
33
+ import { AXTranslationService } from '@acorex/core/translation';
34
34
  import { RootConfig as RootConfig$g } from '@acorex/modules/calendar-management';
35
35
  import { RootConfig as RootConfig$h } from '@acorex/modules/data-management';
36
36
  import { convertArrayToDataSource } from '@acorex/cdk/common';
@@ -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,22 +186,54 @@ 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
- async initial(entityName, collection) {
199
- const exists = await this.table('entity-store').where({ entityName }).count();
198
+ //#region ---- Initialization Methods ----
199
+ /**
200
+ * Seed the storage with the provided collection only if it has not been
201
+ * inserted before.
202
+ *
203
+ * Rather than relying on the total record count, we inspect whether the first
204
+ * item of the incoming collection (identified by its `id`) already exists in
205
+ * the table for the given `entityName`. If it exists, the data has already
206
+ * been seeded and no action is taken; otherwise, the entire collection is
207
+ * bulk-inserted.
208
+ */
209
+ async initial(entityName, collection, options = { mergeType: 'merge', uniqueKeys: ['name'] }) {
210
+ if (!collection?.length) {
211
+ return collection;
212
+ }
213
+ const uniqueKeys = options.uniqueKeys;
214
+ let exists = 0;
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]));
219
+ if (existingRecord) {
220
+ exists = 1;
221
+ break;
222
+ }
223
+ }
224
+ }
200
225
  if (exists === 0) {
201
- await this.table('entity-store').bulkAdd(collection.map((item) => ({ ...item, entityName })));
226
+ if (options?.mergeType === 'merge') {
227
+ await this.table('entity-store').bulkAdd(collection.map((item) => ({ ...item, entityName })));
228
+ }
229
+ else {
230
+ await this.table('entity-store').where({ entityName }).delete();
231
+ await this.table('entity-store').bulkAdd(collection.map((item) => ({ ...item, entityName })));
232
+ }
202
233
  }
203
234
  return collection;
204
235
  }
236
+ //#endregion
205
237
  async getOne(entityName, id) {
206
238
  return await this.table('entity-store').where({ entityName, id: id }).first();
207
239
  }
@@ -6596,100 +6628,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
6596
6628
  type: Injectable
6597
6629
  }], ctorParameters: () => [] });
6598
6630
 
6599
- class AXCRegionalServiceImpl extends AXPRegionalService {
6600
- constructor() {
6601
- super(...arguments);
6602
- this.languageService = inject(AXTranslationService);
6603
- }
6604
- async getCountries() {
6605
- const lang = await firstValueFrom(this.languageService.langChanges$);
6606
- const { countries } = await import('./acorex-connectivity-mock-countries-DHRrtbwM.mjs');
6607
- return countries.map((country) => {
6608
- if (lang == country.regional) {
6609
- return {
6610
- ...country,
6611
- title: country.native,
6612
- };
6613
- }
6614
- else {
6615
- return country;
6616
- }
6617
- });
6618
- }
6619
- async getProvinces(countryId) {
6620
- const lang = await firstValueFrom(this.languageService.langChanges$);
6621
- const country = await this.getCountries();
6622
- const data = country
6623
- .filter((c) => !countryId || c.code === countryId)
6624
- .flatMap((c) => c.provinces?.map((province) => {
6625
- if (lang == c.regional) {
6626
- return {
6627
- ...province,
6628
- title: province.native,
6629
- };
6630
- }
6631
- else {
6632
- return province;
6633
- }
6634
- }) ?? []);
6635
- return data;
6636
- }
6637
- async getCities(filter = {}) {
6638
- const { countryId, provinceId } = filter;
6639
- const countries = await this.getCountries();
6640
- const lang = await firstValueFrom(this.languageService.langChanges$);
6641
- const filteredCountries = countryId ? countries.filter((c) => c.code === countryId) : countries;
6642
- const provinces = filteredCountries.flatMap((c) => c.provinces ?? []);
6643
- const filteredProvinces = provinceId ? provinces.filter((p) => p.code === provinceId) : provinces;
6644
- filteredProvinces.forEach((province) => {
6645
- province.cities = province.cities?.map((city) => {
6646
- const country = countries.find((c) => c.provinces?.some((p) => p.code === province.code));
6647
- if (country && lang == country.regional) {
6648
- return {
6649
- ...city,
6650
- title: city.native,
6651
- };
6652
- }
6653
- else {
6654
- return city;
6655
- }
6656
- });
6657
- });
6658
- return filteredProvinces.flatMap((p) => p.cities ?? []);
6659
- }
6660
- async getCurrencies() {
6661
- const { currencies } = await import('./acorex-connectivity-mock-currencies-B-x3Mxql.mjs');
6662
- return currencies;
6663
- }
6664
- async getLocaleProfiles() {
6665
- const { profiles } = await import('./acorex-connectivity-mock-profiles-MJ9xFTtp.mjs');
6666
- return profiles.filter((c) => ['en-US', 'fa-IR'].some((e) => e == c.localeInfo.code));
6667
- }
6668
- async getLanguages() {
6669
- return (await this.getLocaleProfiles()).map((c) => ({ code: c.localeInfo.code, title: c.title }));
6670
- }
6671
- async getAvailableLanguages() {
6672
- return (await this.getLanguages()).filter((c) => ['fa-IR', 'en-US'].some((e) => e == c.code));
6673
- }
6674
- async getTimeZones() {
6675
- const { timeZones } = await import('./acorex-connectivity-mock-timezones-CnNQ6EXw.mjs');
6676
- return timeZones;
6677
- }
6678
- async getBrowserTimeZoneCode() {
6679
- const { timeZones } = await import('./acorex-connectivity-mock-timezones-CnNQ6EXw.mjs');
6680
- const now = new Date();
6681
- // Calculate offset in hours and minutes
6682
- const offsetMinutes = now.getTimezoneOffset();
6683
- const offsetHours = Math.floor(-offsetMinutes / 60);
6684
- const offsetRemainder = Math.abs(offsetMinutes % 60);
6685
- // Format the offset properly
6686
- const formattedOffset = `UTC${offsetHours >= 0 ? '+' : ''}${offsetHours}${offsetRemainder ? `:${offsetRemainder.toString().padStart(2, '0')}` : ''}`;
6687
- // Find matching time zone
6688
- const matchedZone = timeZones.find((zone) => zone.code === formattedOffset);
6689
- return matchedZone ? matchedZone.code : 'UTC';
6690
- }
6691
- }
6692
-
6693
6631
  class AXCPlatformManagementMockModule {
6694
6632
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCPlatformManagementMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
6695
6633
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.7", ngImport: i0, type: AXCPlatformManagementMockModule }); }
@@ -6722,10 +6660,6 @@ class AXCPlatformManagementMockModule {
6722
6660
  provide: AXPFileStorageService,
6723
6661
  useClass: AXCFileStorageService,
6724
6662
  },
6725
- {
6726
- provide: AXPRegionalService,
6727
- useClass: AXCRegionalServiceImpl,
6728
- },
6729
6663
  ] }); }
6730
6664
  }
6731
6665
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCPlatformManagementMockModule, decorators: [{
@@ -6763,10 +6697,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
6763
6697
  provide: AXPFileStorageService,
6764
6698
  useClass: AXCFileStorageService,
6765
6699
  },
6766
- {
6767
- provide: AXPRegionalService,
6768
- useClass: AXCRegionalServiceImpl,
6769
- },
6770
6700
  ],
6771
6701
  }]
6772
6702
  }] });
@@ -8537,6 +8467,7 @@ const DOCUMENT_TYPES = [
8537
8467
  title: 'Risk Assessment Report',
8538
8468
  maxSize: 5000,
8539
8469
  isEncrypted: false,
8470
+ enableVersioning: true,
8540
8471
  isMultiple: true,
8541
8472
  meta: [
8542
8473
  {
@@ -8580,6 +8511,7 @@ const DOCUMENT_TYPES = [
8580
8511
  title: 'Upload File',
8581
8512
  maxSize: 50000,
8582
8513
  isEncrypted: false,
8514
+ enableVersioning: false,
8583
8515
  isMultiple: false,
8584
8516
  meta: [],
8585
8517
  type: {
@@ -9845,6 +9777,100 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
9845
9777
  type: Injectable
9846
9778
  }], ctorParameters: () => [] });
9847
9779
 
9780
+ class AXCRegionalServiceImpl extends AXPRegionalService {
9781
+ constructor() {
9782
+ super(...arguments);
9783
+ this.languageService = inject(AXTranslationService);
9784
+ }
9785
+ async getCountries() {
9786
+ const lang = await firstValueFrom(this.languageService.langChanges$);
9787
+ const { countries } = await import('./acorex-connectivity-mock-countries-DHRrtbwM.mjs');
9788
+ return countries.map((country) => {
9789
+ if (lang == country.regional) {
9790
+ return {
9791
+ ...country,
9792
+ title: country.native,
9793
+ };
9794
+ }
9795
+ else {
9796
+ return country;
9797
+ }
9798
+ });
9799
+ }
9800
+ async getProvinces(countryId) {
9801
+ const lang = await firstValueFrom(this.languageService.langChanges$);
9802
+ const country = await this.getCountries();
9803
+ const data = country
9804
+ .filter((c) => !countryId || c.code === countryId)
9805
+ .flatMap((c) => c.provinces?.map((province) => {
9806
+ if (lang == c.regional) {
9807
+ return {
9808
+ ...province,
9809
+ title: province.native,
9810
+ };
9811
+ }
9812
+ else {
9813
+ return province;
9814
+ }
9815
+ }) ?? []);
9816
+ return data;
9817
+ }
9818
+ async getCities(filter = {}) {
9819
+ const { countryId, provinceId } = filter;
9820
+ const countries = await this.getCountries();
9821
+ const lang = await firstValueFrom(this.languageService.langChanges$);
9822
+ const filteredCountries = countryId ? countries.filter((c) => c.code === countryId) : countries;
9823
+ const provinces = filteredCountries.flatMap((c) => c.provinces ?? []);
9824
+ const filteredProvinces = provinceId ? provinces.filter((p) => p.code === provinceId) : provinces;
9825
+ filteredProvinces.forEach((province) => {
9826
+ province.cities = province.cities?.map((city) => {
9827
+ const country = countries.find((c) => c.provinces?.some((p) => p.code === province.code));
9828
+ if (country && lang == country.regional) {
9829
+ return {
9830
+ ...city,
9831
+ title: city.native,
9832
+ };
9833
+ }
9834
+ else {
9835
+ return city;
9836
+ }
9837
+ });
9838
+ });
9839
+ return filteredProvinces.flatMap((p) => p.cities ?? []);
9840
+ }
9841
+ async getCurrencies() {
9842
+ const { currencies } = await import('./acorex-connectivity-mock-currencies-B-x3Mxql.mjs');
9843
+ return currencies;
9844
+ }
9845
+ async getLocaleProfiles() {
9846
+ const { profiles } = await import('./acorex-connectivity-mock-profiles-MJ9xFTtp.mjs');
9847
+ return profiles.filter((c) => ['en-US', 'fa-IR'].some((e) => e == c.localeInfo.code));
9848
+ }
9849
+ async getLanguages() {
9850
+ return (await this.getLocaleProfiles()).map((c) => ({ code: c.localeInfo.code, title: c.title }));
9851
+ }
9852
+ async getAvailableLanguages() {
9853
+ return (await this.getLanguages()).filter((c) => ['fa-IR', 'en-US'].some((e) => e == c.code));
9854
+ }
9855
+ async getTimeZones() {
9856
+ const { timeZones } = await import('./acorex-connectivity-mock-timezones-CnNQ6EXw.mjs');
9857
+ return timeZones;
9858
+ }
9859
+ async getBrowserTimeZoneCode() {
9860
+ const { timeZones } = await import('./acorex-connectivity-mock-timezones-CnNQ6EXw.mjs');
9861
+ const now = new Date();
9862
+ // Calculate offset in hours and minutes
9863
+ const offsetMinutes = now.getTimezoneOffset();
9864
+ const offsetHours = Math.floor(-offsetMinutes / 60);
9865
+ const offsetRemainder = Math.abs(offsetMinutes % 60);
9866
+ // Format the offset properly
9867
+ const formattedOffset = `UTC${offsetHours >= 0 ? '+' : ''}${offsetHours}${offsetRemainder ? `:${offsetRemainder.toString().padStart(2, '0')}` : ''}`;
9868
+ // Find matching time zone
9869
+ const matchedZone = timeZones.find((zone) => zone.code === formattedOffset);
9870
+ return matchedZone ? matchedZone.code : 'UTC';
9871
+ }
9872
+ }
9873
+
9848
9874
  class AXCCommonMockModule {
9849
9875
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCCommonMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
9850
9876
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.7", ngImport: i0, type: AXCCommonMockModule }); }
@@ -9863,6 +9889,10 @@ class AXCCommonMockModule {
9863
9889
  provide: AXPLockService,
9864
9890
  useClass: AXCLockService,
9865
9891
  },
9892
+ {
9893
+ provide: AXPRegionalService,
9894
+ useClass: AXCRegionalServiceImpl
9895
+ }
9866
9896
  ] }); }
9867
9897
  }
9868
9898
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCCommonMockModule, decorators: [{
@@ -9886,6 +9916,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
9886
9916
  provide: AXPLockService,
9887
9917
  useClass: AXCLockService,
9888
9918
  },
9919
+ {
9920
+ provide: AXPRegionalService,
9921
+ useClass: AXCRegionalServiceImpl
9922
+ }
9889
9923
  ],
9890
9924
  }]
9891
9925
  }] });