@xh/hoist 68.0.0-SNAPSHOT.1726237236739 → 68.0.0-SNAPSHOT.1726599173889

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 (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/admin/columns/Tracking.ts +1 -2
  3. package/admin/tabs/cluster/BaseInstanceModel.ts +21 -6
  4. package/admin/tabs/cluster/ClusterTab.ts +40 -15
  5. package/admin/tabs/cluster/ClusterTabModel.ts +21 -21
  6. package/admin/tabs/cluster/connpool/ConnPoolMonitorPanel.ts +2 -1
  7. package/admin/tabs/cluster/environment/ServerEnvPanel.ts +2 -1
  8. package/admin/tabs/cluster/hzobject/HzObjectPanel.ts +2 -1
  9. package/admin/tabs/cluster/logs/LogDisplayModel.ts +18 -24
  10. package/admin/tabs/cluster/logs/LogViewer.ts +2 -2
  11. package/admin/tabs/cluster/logs/LogViewerModel.ts +0 -3
  12. package/admin/tabs/cluster/memory/MemoryMonitorPanel.ts +2 -1
  13. package/admin/tabs/cluster/services/DetailsModel.ts +0 -8
  14. package/admin/tabs/cluster/services/ServicePanel.ts +2 -1
  15. package/admin/tabs/cluster/websocket/WebSocketModel.ts +1 -7
  16. package/admin/tabs/general/alertBanner/AlertBannerModel.ts +23 -24
  17. package/admin/tabs/general/alertBanner/AlertBannerPanel.ts +3 -5
  18. package/build/types/admin/tabs/cluster/BaseInstanceModel.d.ts +4 -1
  19. package/build/types/admin/tabs/cluster/ClusterTab.d.ts +2 -0
  20. package/build/types/admin/tabs/cluster/ClusterTabModel.d.ts +3 -2
  21. package/build/types/admin/tabs/cluster/logs/LogViewerModel.d.ts +0 -2
  22. package/build/types/admin/tabs/cluster/services/DetailsModel.d.ts +0 -1
  23. package/build/types/admin/tabs/cluster/websocket/WebSocketModel.d.ts +0 -2
  24. package/build/types/admin/tabs/general/alertBanner/AlertBannerModel.d.ts +3 -3
  25. package/build/types/admin/tabs/general/config/ConfigPanelModel.d.ts +1 -1
  26. package/build/types/admin/tabs/userData/jsonblob/JsonBlobModel.d.ts +1 -1
  27. package/build/types/admin/tabs/userData/prefs/editor/PrefEditorModel.d.ts +1 -1
  28. package/build/types/admin/tabs/userData/users/UserModel.d.ts +1 -1
  29. package/build/types/desktop/cmp/rest/RestGridModel.d.ts +2 -2
  30. package/build/types/desktop/cmp/rest/impl/RestFormModel.d.ts +1 -1
  31. package/build/types/promise/Promise.d.ts +5 -5
  32. package/build/types/svc/AlertBannerService.d.ts +3 -7
  33. package/build/types/svc/EnvironmentService.d.ts +6 -2
  34. package/build/types/svc/IdentityService.d.ts +1 -1
  35. package/core/exception/ExceptionHandler.ts +1 -1
  36. package/package.json +1 -1
  37. package/promise/Promise.ts +11 -12
  38. package/svc/AlertBannerService.ts +6 -30
  39. package/svc/EnvironmentService.ts +29 -21
  40. package/tsconfig.tsbuildinfo +1 -1
@@ -2,7 +2,7 @@ import { FormModel } from '@xh/hoist/cmp/form';
2
2
  import { HoistModel, Intent, LoadSpec, PlainObject } from '@xh/hoist/core';
3
3
  import { AlertBannerSpec } from '@xh/hoist/svc';
4
4
  export declare class AlertBannerModel extends HoistModel {
5
- savedValue: any;
5
+ savedValue: AlertBannerSpec;
6
6
  savedPresets: PlainObject[];
7
7
  formModel: FormModel;
8
8
  bannerModel: any;
@@ -10,7 +10,7 @@ export declare class AlertBannerModel extends HoistModel {
10
10
  get iconOptions(): string[];
11
11
  constructor();
12
12
  doLoadAsync(loadSpec: LoadSpec): Promise<void>;
13
- saveAsync(): Promise<any>;
13
+ saveAsync(): Promise<void>;
14
14
  resetForm(): void;
15
15
  loadPreset(preset: PlainObject): void;
16
16
  addPreset(): void;
@@ -19,7 +19,7 @@ export declare class AlertBannerModel extends HoistModel {
19
19
  get shouldDisableAddPreset(): boolean;
20
20
  loadPresetsAsync(): Promise<void>;
21
21
  savePresetsAsync(): Promise<void>;
22
- saveBannerSpecAsync(spec: AlertBannerSpec): Promise<void>;
23
22
  private syncPreview;
24
23
  private saveInternalAsync;
24
+ private saveBannerSpecAsync;
25
25
  }
@@ -10,7 +10,7 @@ export declare class ConfigPanelModel extends HoistModel {
10
10
  gridModel: RestGridModel;
11
11
  differModel: DifferModel;
12
12
  constructor();
13
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
13
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
14
14
  openDiffer(): void;
15
15
  closeDiffer(): void;
16
16
  private valueRenderer;
@@ -8,7 +8,7 @@ export declare class JsonBlobModel extends HoistModel {
8
8
  gridModel: RestGridModel;
9
9
  differModel: DifferModel;
10
10
  constructor();
11
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
11
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
12
12
  openDiffer(): void;
13
13
  closeDiffer(): void;
14
14
  }
@@ -10,7 +10,7 @@ export declare class PrefEditorModel extends HoistModel {
10
10
  gridModel: RestGridModel;
11
11
  differModel: DifferModel;
12
12
  constructor();
13
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
13
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
14
14
  openDiffer(): void;
15
15
  closeDiffer(): void;
16
16
  }
@@ -8,5 +8,5 @@ export declare class UserModel extends HoistModel {
8
8
  withRolesOnly: boolean;
9
9
  gridModel: GridModel;
10
10
  constructor();
11
- doLoadAsync(loadSpec: LoadSpec): Promise<any>;
11
+ doLoadAsync(loadSpec: LoadSpec): Promise<void>;
12
12
  }
@@ -90,8 +90,8 @@ export declare class RestGridModel extends HoistModel {
90
90
  loadData(rawData: PlainObject[], rawSummaryData?: PlainObject): void;
91
91
  addRecord(): void;
92
92
  cloneRecord(record: StoreRecord): void;
93
- deleteRecordAsync(record: StoreRecord): Promise<any>;
94
- bulkDeleteRecordsAsync(records: StoreRecord[]): Promise<any>;
93
+ deleteRecordAsync(record: StoreRecord): Promise<void>;
94
+ bulkDeleteRecordsAsync(records: StoreRecord[]): Promise<void>;
95
95
  editRecord(record: StoreRecord): void;
96
96
  viewRecord(record: StoreRecord): void;
97
97
  confirmDeleteRecords(): void;
@@ -34,7 +34,7 @@ export declare class RestFormModel extends HoistModel {
34
34
  openEdit(rec: any): void;
35
35
  openClone(data: any): void;
36
36
  openView(rec: any): void;
37
- validateAndSaveAsync(): Promise<any>;
37
+ validateAndSaveAsync(): Promise<void>;
38
38
  private initForm;
39
39
  private saveRecordAsync;
40
40
  fieldModelConfig(editor: RestGridEditor): {
@@ -1,4 +1,4 @@
1
- import { Thunkable, ExceptionHandlerOptions, TaskObserver, TrackOptions } from '@xh/hoist/core';
1
+ import { Thunkable, ExceptionHandlerOptions, TaskObserver, TrackOptions, Some, Awaitable } from '@xh/hoist/core';
2
2
  /**
3
3
  * Enhancements to the Global Promise object.
4
4
  * Merged in to definition here and implemented on the prototype below.
@@ -9,7 +9,7 @@ declare global {
9
9
  * Version of `then()` that wraps the callback in a MobX action, for use in a Promise chain
10
10
  * that modifies MobX observables.
11
11
  */
12
- thenAction(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any): Promise<any>;
12
+ thenAction<TResult>(onFulfilled: (value: T) => Awaitable<TResult>): Promise<TResult>;
13
13
  /**
14
14
  * Version of `catch()` that will only catch certain exceptions.
15
15
  *
@@ -18,16 +18,16 @@ declare global {
18
18
  * selector will be handled by this method.
19
19
  * @param fn - catch handler
20
20
  */
21
- catchWhen(selector: ((e: any) => boolean) | string | string[], fn?: (reason: any) => any): Promise<any>;
21
+ catchWhen<TResult = undefined>(selector: ((e: any) => boolean) | Some<string>, fn?: (reason: any) => Awaitable<TResult>): Promise<T | TResult>;
22
22
  /**
23
23
  * Version of `catch()` that passes the error onto Hoist's default exception handler for
24
24
  * convention-driven logging and alerting. Typically called last in a Promise chain.
25
25
  */
26
- catchDefault(options?: ExceptionHandlerOptions): Promise<any>;
26
+ catchDefault(options?: ExceptionHandlerOptions): Promise<T | undefined>;
27
27
  /**
28
28
  * Version of `catchDefault()` that will only catch certain exceptions.
29
29
  */
30
- catchDefaultWhen(selector: ((e: any) => boolean) | string | string[], options: ExceptionHandlerOptions): Promise<any>;
30
+ catchDefaultWhen(selector: ((e: any) => boolean) | Some<string>, options: ExceptionHandlerOptions): Promise<T | undefined>;
31
31
  /**
32
32
  * Wait on a potentially async function before passing on the original value.
33
33
  * Useful when we want to block and do something on the promise chain, but do not want to
@@ -2,18 +2,14 @@ import { BannerSpec, HoistService, Intent } from '@xh/hoist/core';
2
2
  /**
3
3
  * Service to display an app-wide alert banner, as configured via the Hoist Admin console.
4
4
  *
5
- * For this service to be active, a client-visible `xhAlertBannerConfig` config must be specified
6
- * as `{enabled:true, interval: x}`, where `x` sets this service's polling frequency in seconds.
5
+ * Note that the client is provided with updated banner data from the server via
6
+ * EnvironmentService, and its regular polling. See 'xhEnvPollConfig' for more information.
7
7
  */
8
8
  export declare class AlertBannerService extends HoistService {
9
9
  xhImpl: boolean;
10
10
  static instance: AlertBannerService;
11
- private timer;
12
- get interval(): number;
13
- get enabled(): boolean;
14
11
  get lastDismissed(): number;
15
- initAsync(): Promise<void>;
16
- checkForBannerAsync(): Promise<void>;
12
+ updateBanner(spec: AlertBannerSpec): Promise<void>;
17
13
  genBannerSpec(message: string, intent: Intent, iconName: string, enableClose: boolean): BannerSpec;
18
14
  private onClose;
19
15
  private isTargetedApp;
@@ -1,7 +1,7 @@
1
1
  import { HoistService } from '@xh/hoist/core';
2
2
  /**
3
3
  * Load and report on the client and server environment, including software versions, timezones, and
4
- * and other technical information.
4
+ * other technical information.
5
5
  */
6
6
  export declare class EnvironmentService extends HoistService {
7
7
  static instance: EnvironmentService;
@@ -30,9 +30,13 @@ export declare class EnvironmentService extends HoistService {
30
30
  isTest(): boolean;
31
31
  isMinHoistCoreVersion(version: string): boolean;
32
32
  isMaxHoistCoreVersion(version: string): boolean;
33
+ /**
34
+ * Update critical environment information from server.
35
+ * @internal - not for app use. Called by `pollTimer` and as needed by Hoist code.
36
+ */
37
+ pollServerAsync(): Promise<void>;
33
38
  constructor();
34
39
  private startPolling;
35
- private pollServerAsync;
36
40
  private setServerInfo;
37
41
  private get pollIntervalMs();
38
42
  }
@@ -54,7 +54,7 @@ export declare class IdentityService extends HoistService {
54
54
  */
55
55
  impersonateAsync(username: string): Promise<void>;
56
56
  /** Exit any active impersonation, reloading the app to resume accessing it as yourself. */
57
- endImpersonateAsync(): Promise<any>;
57
+ endImpersonateAsync(): Promise<void>;
58
58
  private createUser;
59
59
  private hasGate;
60
60
  private canUserImpersonate;
@@ -127,7 +127,7 @@ export class ExceptionHandler {
127
127
  ),
128
128
  actionButtonProps: {
129
129
  icon: Icon.search(),
130
- onClick: () => exceptionDialogModel.show(e, opts)
130
+ onClick: () => exceptionDialogModel.showDetails(e, opts)
131
131
  },
132
132
  intent: showAsError ? 'danger' : 'primary',
133
133
  ...ExceptionHandler.TOAST_PROPS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist",
3
- "version": "68.0.0-SNAPSHOT.1726237236739",
3
+ "version": "68.0.0-SNAPSHOT.1726599173889",
4
4
  "description": "Hoist add-on for building and deploying React Applications.",
5
5
  "repository": "github:xh/hoist-react",
6
6
  "homepage": "https://xh.io",
@@ -10,7 +10,9 @@ import {
10
10
  ExceptionHandlerOptions,
11
11
  TaskObserver,
12
12
  TrackOptions,
13
- XH
13
+ XH,
14
+ Some,
15
+ Awaitable
14
16
  } from '@xh/hoist/core';
15
17
  import {action} from '@xh/hoist/mobx';
16
18
  import {olderThan, SECONDS} from '@xh/hoist/utils/datetime';
@@ -26,10 +28,7 @@ declare global {
26
28
  * Version of `then()` that wraps the callback in a MobX action, for use in a Promise chain
27
29
  * that modifies MobX observables.
28
30
  */
29
- thenAction(
30
- onFulfilled?: (value: T) => any,
31
- onRejected?: (reason: any) => any
32
- ): Promise<any>;
31
+ thenAction<TResult>(onFulfilled: (value: T) => Awaitable<TResult>): Promise<TResult>;
33
32
 
34
33
  /**
35
34
  * Version of `catch()` that will only catch certain exceptions.
@@ -39,24 +38,24 @@ declare global {
39
38
  * selector will be handled by this method.
40
39
  * @param fn - catch handler
41
40
  */
42
- catchWhen(
43
- selector: ((e: any) => boolean) | string | string[],
44
- fn?: (reason: any) => any
45
- ): Promise<any>;
41
+ catchWhen<TResult = undefined>(
42
+ selector: ((e: any) => boolean) | Some<string>,
43
+ fn?: (reason: any) => Awaitable<TResult>
44
+ ): Promise<T | TResult>;
46
45
 
47
46
  /**
48
47
  * Version of `catch()` that passes the error onto Hoist's default exception handler for
49
48
  * convention-driven logging and alerting. Typically called last in a Promise chain.
50
49
  */
51
- catchDefault(options?: ExceptionHandlerOptions): Promise<any>;
50
+ catchDefault(options?: ExceptionHandlerOptions): Promise<T | undefined>;
52
51
 
53
52
  /**
54
53
  * Version of `catchDefault()` that will only catch certain exceptions.
55
54
  */
56
55
  catchDefaultWhen(
57
- selector: ((e: any) => boolean) | string | string[],
56
+ selector: ((e: any) => boolean) | Some<string>,
58
57
  options: ExceptionHandlerOptions
59
- ): Promise<any>;
58
+ ): Promise<T | undefined>;
60
59
 
61
60
  /**
62
61
  * Wait on a potentially async function before passing on the original value.
@@ -6,52 +6,28 @@
6
6
  */
7
7
  import {BannerModel} from '@xh/hoist/appcontainer/BannerModel';
8
8
  import {markdown} from '@xh/hoist/cmp/markdown';
9
- import {BannerSpec, HoistService, Intent, managed, XH} from '@xh/hoist/core';
9
+ import {BannerSpec, HoistService, Intent, XH} from '@xh/hoist/core';
10
10
  import {Icon} from '@xh/hoist/icon';
11
- import {Timer} from '@xh/hoist/utils/async';
12
- import {SECONDS} from '@xh/hoist/utils/datetime';
13
11
  import {compact, isEmpty, map, trim} from 'lodash';
14
12
 
15
13
  /**
16
14
  * Service to display an app-wide alert banner, as configured via the Hoist Admin console.
17
15
  *
18
- * For this service to be active, a client-visible `xhAlertBannerConfig` config must be specified
19
- * as `{enabled:true, interval: x}`, where `x` sets this service's polling frequency in seconds.
16
+ * Note that the client is provided with updated banner data from the server via
17
+ * EnvironmentService, and its regular polling. See 'xhEnvPollConfig' for more information.
20
18
  */
21
19
  export class AlertBannerService extends HoistService {
22
20
  override xhImpl = true;
23
21
 
24
22
  static instance: AlertBannerService;
25
23
 
26
- @managed
27
- private timer: Timer;
28
-
29
- get interval(): number {
30
- const conf = XH.getConf('xhAlertBannerConfig', {});
31
- return conf.enabled && conf.interval ? conf.interval * SECONDS : -1;
32
- }
33
-
34
- get enabled(): boolean {
35
- return this.interval > 0;
36
- }
37
-
38
24
  get lastDismissed(): number {
39
25
  return XH.localStorageService.get('xhAlertBanner.lastDismissed');
40
26
  }
41
27
 
42
- override async initAsync() {
43
- this.timer = Timer.create({
44
- runFn: () => this.checkForBannerAsync(),
45
- interval: this.interval
46
- });
47
- }
48
-
49
- async checkForBannerAsync() {
50
- if (!this.enabled) return;
51
-
52
- const data: AlertBannerSpec = await XH.fetchJson({url: 'xh/alertBanner'}),
53
- {active, expires, publishDate, message, intent, iconName, enableClose, clientApps} =
54
- data,
28
+ async updateBanner(spec: AlertBannerSpec) {
29
+ const {active, expires, publishDate, message, intent, iconName, enableClose, clientApps} =
30
+ spec,
55
31
  {lastDismissed, onClose} = this;
56
32
 
57
33
  if (
@@ -18,7 +18,7 @@ import {version as reactVersion} from 'react';
18
18
 
19
19
  /**
20
20
  * Load and report on the client and server environment, including software versions, timezones, and
21
- * and other technical information.
21
+ * other technical information.
22
22
  */
23
23
  export class EnvironmentService extends HoistService {
24
24
  static instance: EnvironmentService;
@@ -49,7 +49,7 @@ export class EnvironmentService extends HoistService {
49
49
  private pollTimer: Timer;
50
50
 
51
51
  override async initAsync() {
52
- const {pollConfig, instanceName, ...serverEnv} = await XH.fetchJson({
52
+ const {pollConfig, instanceName, alertBanner, ...serverEnv} = await XH.fetchJson({
53
53
  url: 'xh/environment'
54
54
  }),
55
55
  clientTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'Unknown',
@@ -81,7 +81,10 @@ export class EnvironmentService extends HoistService {
81
81
  this.pollConfig = pollConfig;
82
82
  this.addReaction({
83
83
  when: () => XH.appIsRunning,
84
- run: this.startPolling
84
+ run: () => {
85
+ XH.alertBannerService.updateBanner(alertBanner);
86
+ this.startPolling();
87
+ }
85
88
  });
86
89
  }
87
90
 
@@ -109,23 +112,11 @@ export class EnvironmentService extends HoistService {
109
112
  return checkMaxVersion(this.get('hoistCoreVersion'), version);
110
113
  }
111
114
 
112
- //------------------------------
113
- // Implementation
114
- //------------------------------
115
- constructor() {
116
- super();
117
- makeObservable(this);
118
- }
119
-
120
- private startPolling() {
121
- this.pollTimer = Timer.create({
122
- runFn: () => this.pollServerAsync(),
123
- interval: this.pollIntervalMs,
124
- delay: true
125
- });
126
- }
127
-
128
- private async pollServerAsync() {
115
+ /**
116
+ * Update critical environment information from server.
117
+ * @internal - not for app use. Called by `pollTimer` and as needed by Hoist code.
118
+ */
119
+ async pollServerAsync() {
129
120
  let data;
130
121
  try {
131
122
  data = await XH.fetchJson({url: 'xh/environmentPoll'});
@@ -135,10 +126,11 @@ export class EnvironmentService extends HoistService {
135
126
  }
136
127
 
137
128
  // Update config/interval, and server info
138
- const {pollConfig, instanceName, appVersion, appBuild} = data;
129
+ const {pollConfig, instanceName, alertBanner, appVersion, appBuild} = data;
139
130
  this.pollConfig = pollConfig;
140
131
  this.pollTimer.setInterval(this.pollIntervalMs);
141
132
  this.setServerInfo(instanceName, appVersion, appBuild);
133
+ XH.alertBannerService.updateBanner(alertBanner);
142
134
 
143
135
  // Handle version change
144
136
  if (appVersion != XH.getEnv('appVersion') || appBuild != XH.getEnv('appBuild')) {
@@ -163,6 +155,22 @@ export class EnvironmentService extends HoistService {
163
155
  }
164
156
  }
165
157
 
158
+ //------------------------------
159
+ // Implementation
160
+ //------------------------------
161
+ constructor() {
162
+ super();
163
+ makeObservable(this);
164
+ }
165
+
166
+ private startPolling() {
167
+ this.pollTimer = Timer.create({
168
+ runFn: () => this.pollServerAsync(),
169
+ interval: this.pollIntervalMs,
170
+ delay: true
171
+ });
172
+ }
173
+
166
174
  @action
167
175
  private setServerInfo(serverInstance: string, serverVersion: string, serverBuild: string) {
168
176
  this.serverInstance = serverInstance;