@acorex/connectivity 20.0.0 → 20.0.2

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.
@@ -15,7 +15,7 @@ import { RootConfig as RootConfig$6, AXMDeviceSessionsServiceImpl, AXMSessionSta
15
15
  import { of, delay, firstValueFrom } from 'rxjs';
16
16
  import { AXMPermissionsKeys, AXMFormTemplateTypes, RootConfig as RootConfig$3 } from '@acorex/modules/form-template-management';
17
17
  import { RootConfig } from '@acorex/modules/conversation';
18
- import { AXPBarChartWidget, AXPStickyNoteWidget, AXPDonutChartWidget, AXPGaugeChartWidget, AXPLineChartWidget, AXPTaskListWidget, RootConfig as RootConfig$1 } from '@acorex/modules/dashboard-management';
18
+ import { AXPBarChartWidget, AXPAnalogClockWidget, AXPMinimalWeatherWidget, AXPAdvancedWeatherWidget, AXPStickyNoteWidget, AXPDonutChartWidget, AXPGaugeChartWidget, AXPLineChartWidget, AXPTaskListWidget, RootConfig as RootConfig$1 } from '@acorex/modules/dashboard-management';
19
19
  import { RootConfig as RootConfig$4 } from '@acorex/modules/issue-management';
20
20
  import { RootConfig as RootConfig$5 } from '@acorex/modules/log-management';
21
21
  import { AXMOrganizationNodeType, RootConfig as RootConfig$8 } from '@acorex/modules/organization-management';
@@ -1005,52 +1005,127 @@ function generateBarChartWidget() {
1005
1005
  // Generate analog clock widget
1006
1006
  function generateAnalogClockWidget() {
1007
1007
  const uniqueId = AXPDataGenerator.uuid();
1008
+ // Define timezone options that match AXPTimeZone interface
1009
+ const timezoneOptions = [
1010
+ { code: 'UTC-12', title: 'UTC-12 (Baker Island Time)', offset: '-12:00', iana: 'Etc/GMT+12', abbr: 'BIT' },
1011
+ { code: 'UTC-11', title: 'UTC-11 (Niue Time)', offset: '-11:00', iana: 'Etc/GMT+11', abbr: 'NIU' },
1012
+ {
1013
+ code: 'UTC-10',
1014
+ title: 'UTC-10 (Hawaii-Aleutian Standard Time)',
1015
+ offset: '-10:00',
1016
+ iana: 'Pacific/Honolulu',
1017
+ abbr: 'HNL',
1018
+ },
1019
+ {
1020
+ code: 'UTC-9:30',
1021
+ title: 'UTC-9:30 (Marquesas Islands Time)',
1022
+ offset: '-09:30',
1023
+ iana: 'Pacific/Marquesas',
1024
+ abbr: 'MQS',
1025
+ },
1026
+ { code: 'UTC-9', title: 'UTC-9 (Alaska Standard Time)', offset: '-09:00', iana: 'America/Anchorage', abbr: 'ANC' },
1027
+ {
1028
+ code: 'UTC-8',
1029
+ title: 'UTC-8 (Pacific Standard Time)',
1030
+ offset: '-08:00',
1031
+ iana: 'America/Los_Angeles',
1032
+ abbr: 'LAX',
1033
+ },
1034
+ ];
1035
+ // Additional timezone options for "others" array
1036
+ const otherTimezoneOptions = [
1037
+ { code: 'UTC-12', title: 'UTC-12 (Baker Island Time)', offset: '-12:00', iana: 'Etc/GMT+12', abbr: 'BIT' },
1038
+ { code: 'UTC-11', title: 'UTC-11 (Niue Time)', offset: '-11:00', iana: 'Etc/GMT+11', abbr: 'NIU' },
1039
+ {
1040
+ code: 'UTC-10',
1041
+ title: 'UTC-10 (Hawaii-Aleutian Standard Time)',
1042
+ offset: '-10:00',
1043
+ iana: 'Pacific/Honolulu',
1044
+ abbr: 'HNL',
1045
+ },
1046
+ {
1047
+ code: 'UTC-9:30',
1048
+ title: 'UTC-9:30 (Marquesas Islands Time)',
1049
+ offset: '-09:30',
1050
+ iana: 'Pacific/Marquesas',
1051
+ abbr: 'MQS',
1052
+ },
1053
+ { code: 'UTC-9', title: 'UTC-9 (Alaska Standard Time)', offset: '-09:00', iana: 'America/Anchorage', abbr: 'ANC' },
1054
+ {
1055
+ code: 'UTC-8',
1056
+ title: 'UTC-8 (Pacific Standard Time)',
1057
+ offset: '-08:00',
1058
+ iana: 'America/Los_Angeles',
1059
+ abbr: 'LAX',
1060
+ },
1061
+ ];
1062
+ // Randomly select a primary timezone
1063
+ const primaryTimezone = AXPDataGenerator.pick(timezoneOptions);
1064
+ // Randomly decide how many additional timezones to show (0-3)
1065
+ const otherTimezones = AXPDataGenerator.pick([
1066
+ [],
1067
+ [AXPDataGenerator.pick(otherTimezoneOptions)],
1068
+ [AXPDataGenerator.pick(otherTimezoneOptions), AXPDataGenerator.pick(otherTimezoneOptions)],
1069
+ ]);
1008
1070
  return {
1009
1071
  config: {
1010
1072
  id: AXPDataGenerator.uuid(),
1011
- width: 2,
1012
- height: 3,
1013
- minWidth: 2,
1014
- minHeight: 2,
1015
- maxWidth: 4,
1016
- maxHeight: 4,
1073
+ ...AXPAnalogClockWidget?.meta?.['dimensions'],
1017
1074
  },
1018
1075
  node: {
1019
1076
  name: `analog-clock-${uniqueId}`,
1020
1077
  path: `analog-clock-${uniqueId}`,
1021
1078
  type: 'analog-clock',
1022
1079
  options: {
1023
- timezone: {
1024
- code: AXPDataGenerator.pick(['UTC', 'America/New_York', 'Europe/London', 'Asia/Tokyo', 'Australia/Sydney']),
1025
- title: AXPDataGenerator.pick([
1026
- 'UTC',
1027
- 'Eastern Time',
1028
- 'Greenwich Mean Time',
1029
- 'Japan Standard Time',
1030
- 'Australian Eastern Time',
1031
- ]),
1032
- iana: AXPDataGenerator.pick(['UTC', 'America/New_York', 'Europe/London', 'Asia/Tokyo', 'Australia/Sydney']),
1033
- abbr: AXPDataGenerator.pick(['UTC', 'EST', 'GMT', 'JST', 'AEST']),
1034
- },
1035
- others: AXPDataGenerator.pick([
1036
- [],
1037
- [
1038
- {
1039
- code: 'America/Los_Angeles',
1040
- title: 'Pacific Time',
1041
- iana: 'America/Los_Angeles',
1042
- abbr: 'PST',
1043
- },
1044
- ],
1045
- [
1046
- {
1047
- code: 'Europe/Paris',
1048
- title: 'Central European Time',
1049
- iana: 'Europe/Paris',
1050
- abbr: 'CET',
1051
- },
1052
- ],
1053
- ]),
1080
+ timezone: primaryTimezone,
1081
+ others: otherTimezones,
1082
+ },
1083
+ },
1084
+ };
1085
+ }
1086
+ // Generate analog clock widget
1087
+ function generateAnalogClockWidget2() {
1088
+ const uniqueId = AXPDataGenerator.uuid();
1089
+ // Define timezone options that match AXPTimeZone interface
1090
+ const timezoneOptions = [
1091
+ { code: 'UTC-12', title: 'UTC-12 (Baker Island Time)', offset: '-12:00', iana: 'Etc/GMT+12', abbr: 'BIT' },
1092
+ { code: 'UTC-11', title: 'UTC-11 (Niue Time)', offset: '-11:00', iana: 'Etc/GMT+11', abbr: 'NIU' },
1093
+ {
1094
+ code: 'UTC-10',
1095
+ title: 'UTC-10 (Hawaii-Aleutian Standard Time)',
1096
+ offset: '-10:00',
1097
+ iana: 'Pacific/Honolulu',
1098
+ abbr: 'HNL',
1099
+ },
1100
+ {
1101
+ code: 'UTC-9:30',
1102
+ title: 'UTC-9:30 (Marquesas Islands Time)',
1103
+ offset: '-09:30',
1104
+ iana: 'Pacific/Marquesas',
1105
+ abbr: 'MQS',
1106
+ },
1107
+ { code: 'UTC-9', title: 'UTC-9 (Alaska Standard Time)', offset: '-09:00', iana: 'America/Anchorage', abbr: 'ANC' },
1108
+ {
1109
+ code: 'UTC-8',
1110
+ title: 'UTC-8 (Pacific Standard Time)',
1111
+ offset: '-08:00',
1112
+ iana: 'America/Los_Angeles',
1113
+ abbr: 'LAX',
1114
+ },
1115
+ ];
1116
+ // Randomly select a primary timezone
1117
+ const primaryTimezone = AXPDataGenerator.pick(timezoneOptions);
1118
+ return {
1119
+ config: {
1120
+ id: AXPDataGenerator.uuid(),
1121
+ ...AXPAnalogClockWidget?.meta?.['dimensions'],
1122
+ },
1123
+ node: {
1124
+ name: `analog-clock-${uniqueId}`,
1125
+ path: `analog-clock-${uniqueId}`,
1126
+ type: 'analog-clock',
1127
+ options: {
1128
+ timezone: primaryTimezone,
1054
1129
  },
1055
1130
  },
1056
1131
  };
@@ -1061,12 +1136,7 @@ function generateMinimalWeatherWidget() {
1061
1136
  return {
1062
1137
  config: {
1063
1138
  id: AXPDataGenerator.uuid(),
1064
- width: 2,
1065
- height: 2,
1066
- minWidth: 1,
1067
- minHeight: 2,
1068
- maxWidth: 4,
1069
- maxHeight: 5,
1139
+ ...AXPMinimalWeatherWidget?.meta?.['dimensions'],
1070
1140
  },
1071
1141
  node: {
1072
1142
  name: `minimal-weather-${uniqueId}`,
@@ -1085,12 +1155,7 @@ function generateAdvancedWeatherWidget() {
1085
1155
  return {
1086
1156
  config: {
1087
1157
  id: AXPDataGenerator.uuid(),
1088
- width: 3,
1089
- height: 5,
1090
- minWidth: 3,
1091
- minHeight: 5,
1092
- maxWidth: 5,
1093
- maxHeight: 7,
1158
+ ...AXPAdvancedWeatherWidget?.meta?.['dimensions'],
1094
1159
  },
1095
1160
  node: {
1096
1161
  name: `advanced-weather-${uniqueId}`,
@@ -1582,6 +1647,7 @@ function generateChartsDashboard(user) {
1582
1647
  function generateUtilityDashboard() {
1583
1648
  const utilityWidgets = [
1584
1649
  generateAnalogClockWidget(),
1650
+ generateAnalogClockWidget2(),
1585
1651
  generateMinimalWeatherWidget(),
1586
1652
  generateAdvancedWeatherWidget(),
1587
1653
  generateStickyNoteWidget(),
@@ -6441,16 +6507,53 @@ class AXCLockService {
6441
6507
  this.className = 'locks';
6442
6508
  //#endregion
6443
6509
  this.entityName = this.className;
6510
+ //#region ---- Cache Configuration & Management ----
6511
+ /**
6512
+ * Cache Time-To-Live in milliseconds. Default is 5 seconds but can be overridden
6513
+ * at runtime using {@link setCacheDuration}.
6514
+ */
6515
+ this.cacheTTL = 5000;
6516
+ /** In-memory cache for lock information. */
6517
+ this.cacheMap = new Map();
6444
6518
  // Initialise a dedicated Dexie database for lock management to avoid any
6445
6519
  // dependency on the generic AXPEntityStorageService. Using a separate
6446
6520
  // database name ensures we don't conflict with the existing entity-store
6447
6521
  // schema while keeping things lightweight.
6448
6522
  this.db = new Dexie('ACoreXPlatformLocks');
6449
6523
  this.db.version(1).stores({ [this.className]: 'id, refId, refType, type' });
6524
+ // Start cache invalidation timer with the default TTL.
6525
+ this.startCacheTimer();
6450
6526
  }
6451
6527
  get lockTable() {
6452
6528
  return this.db[this.className];
6453
6529
  }
6530
+ /**
6531
+ * Generates a unique cache key based on the lock request parameters.
6532
+ */
6533
+ getCacheKey(req) {
6534
+ return `${req.refId}|${req.refType}|${req.type ?? ''}`;
6535
+ }
6536
+ /**
6537
+ * Starts or restarts the interval that clears the cache.
6538
+ */
6539
+ startCacheTimer() {
6540
+ if (this.cacheTimer) {
6541
+ clearInterval(this.cacheTimer);
6542
+ }
6543
+ this.cacheTimer = setInterval(() => this.cacheMap.clear(), this.cacheTTL);
6544
+ }
6545
+ /**
6546
+ * Allows consumers to change the cache duration (in milliseconds) at runtime.
6547
+ * The new duration is applied immediately.
6548
+ */
6549
+ setCacheDuration(ms) {
6550
+ if (ms <= 0) {
6551
+ throw new Error('Cache duration must be greater than zero.');
6552
+ }
6553
+ this.cacheTTL = ms;
6554
+ this.startCacheTimer();
6555
+ }
6556
+ //#endregion
6454
6557
  lock(request) {
6455
6558
  //TODO locked by get info and save
6456
6559
  const entity = {
@@ -6462,24 +6565,42 @@ class AXCLockService {
6462
6565
  title: '',
6463
6566
  },
6464
6567
  };
6465
- return this.lockTable.add(entity).then(() => entity);
6568
+ return this.lockTable.add(entity).then(() => {
6569
+ // Invalidate cache because underlying data has changed.
6570
+ this.cacheMap.clear();
6571
+ return entity;
6572
+ });
6466
6573
  }
6467
6574
  async unlock(request) {
6468
6575
  const items = await this.getItems(request);
6469
6576
  if (items.length > 0) {
6470
6577
  //TODO may be don't have id and multi primary key like this!!!!!
6471
6578
  await this.lockTable.delete(items[0].id);
6579
+ // Invalidate cache since data has changed.
6580
+ this.cacheMap.clear();
6472
6581
  }
6473
6582
  else {
6474
6583
  throw new Error('not found');
6475
6584
  }
6476
6585
  }
6477
6586
  async check(request) {
6478
- return (await this.getItems(request)).length > 0;
6587
+ try {
6588
+ await this.getInfo(request);
6589
+ return true;
6590
+ }
6591
+ catch {
6592
+ return false;
6593
+ }
6479
6594
  }
6480
6595
  async getInfo(request) {
6596
+ const key = this.getCacheKey(request);
6597
+ const cached = this.cacheMap.get(key);
6598
+ if (cached) {
6599
+ return cached;
6600
+ }
6481
6601
  const items = await this.getItems(request);
6482
6602
  if (items.length > 0) {
6603
+ this.cacheMap.set(key, items[0]);
6483
6604
  return items[0];
6484
6605
  }
6485
6606
  else {