@xh/hoist 83.0.1 → 83.1.0

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 (42) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/build/types/cmp/error/ErrorBoundary.d.ts +2 -0
  3. package/build/types/cmp/error/ErrorBoundaryModel.d.ts +12 -0
  4. package/build/types/cmp/filter/FilterChooserModel.d.ts +18 -0
  5. package/build/types/cmp/form/Form.d.ts +4 -4
  6. package/build/types/cmp/form/formfieldset/FormFieldSetModel.d.ts +9 -0
  7. package/build/types/cmp/grouping/GroupingChooserModel.d.ts +16 -0
  8. package/build/types/cmp/pinpad/PinPadModel.d.ts +8 -0
  9. package/build/types/cmp/treemap/SplitTreeMapModel.d.ts +10 -10
  10. package/build/types/cmp/treemap/TreeMapModel.d.ts +19 -20
  11. package/build/types/core/HoistComponent.d.ts +20 -22
  12. package/build/types/core/load/LoadSpec.d.ts +19 -19
  13. package/build/types/data/impl/RecordSet.d.ts +2 -2
  14. package/build/types/desktop/cmp/input/DateInput.d.ts +1 -1
  15. package/build/types/desktop/cmp/leftrightchooser/LeftRightChooserModel.d.ts +1 -1
  16. package/build/types/svc/AutoRefreshService.d.ts +1 -1
  17. package/build/types/svc/ChangelogService.d.ts +2 -3
  18. package/build/types/svc/FetchService.d.ts +19 -17
  19. package/cmp/error/ErrorBoundary.ts +2 -0
  20. package/cmp/error/ErrorBoundaryModel.ts +12 -0
  21. package/cmp/filter/FilterChooserModel.ts +18 -0
  22. package/cmp/form/Form.ts +4 -4
  23. package/cmp/form/formfieldset/FormFieldSetModel.ts +9 -0
  24. package/cmp/grouping/GroupingChooserModel.ts +16 -0
  25. package/cmp/pinpad/PinPadModel.ts +8 -0
  26. package/cmp/treemap/SplitTreeMapModel.ts +10 -10
  27. package/cmp/treemap/TreeMapModel.ts +19 -20
  28. package/core/HoistComponent.ts +20 -22
  29. package/core/load/LoadSpec.ts +19 -20
  30. package/data/impl/RecordSet.ts +3 -3
  31. package/desktop/cmp/input/DateInput.ts +1 -1
  32. package/desktop/cmp/leftrightchooser/LeftRightChooserModel.ts +1 -1
  33. package/mcp/cli/ts.ts +9 -2
  34. package/mcp/data/ts-registry.ts +116 -12
  35. package/mcp/formatters/typescript.ts +50 -4
  36. package/mcp/tools/typescript.ts +9 -2
  37. package/package.json +2 -2
  38. package/svc/AutoRefreshService.ts +1 -1
  39. package/svc/ChangelogService.ts +2 -3
  40. package/svc/EnvironmentService.ts +7 -5
  41. package/svc/FetchService.ts +20 -18
  42. package/svc/WebSocketService.ts +1 -1
@@ -25,32 +25,34 @@ import ShortUniqueId from 'short-unique-id';
25
25
 
26
26
  const defaultIdGenerator = new ShortUniqueId({length: 16});
27
27
 
28
+ export interface FetchServiceDefaults {
29
+ autoGenCorrelationIds?: boolean | ((opts: FetchOptions) => boolean);
30
+ correlationIdHeaderKey?: string;
31
+ genCorrelationId?: () => string;
32
+ }
33
+
28
34
  /**
29
35
  * Service for making managed HTTP requests, both to the app's own Hoist server and to remote APIs.
30
36
  *
31
- * Wrapper around the standard Fetch API with some enhancements to streamline the process for
32
- * the most common use-cases. The Fetch API will be called with CORS enabled, credentials
33
- * included, and redirects followed.
37
+ * Typically accessed via `XH.fetchService` or the convenience methods on XH `XH.fetch()`,
38
+ * `XH.fetchJson()`, `XH.postJson()`, `XH.putJson()`, `XH.deleteJson()` which delegate here.
34
39
  *
35
- * Set {@link FetchService.defaults.autoGenCorrelationIds} to enable auto-generation of Correlation IDs
36
- * for requests issued by this service. Best configured in the app's `Bootstrap` module to ensure
37
- * coverage of early hoist core init requests. Can also be set on a per-request basis via
38
- * {@link FetchOptions.correlationId}.
40
+ * Wraps the standard Fetch API with CORS enabled, credentials included, and redirects followed.
41
+ * Provides JSON convenience methods (`fetchJson`, `postJson`, `putJson`, `patchJson`,
42
+ * `deleteJson`, `getJson`) that handle serialization and content-type headers automatically.
39
43
  *
40
- * Custom headers can be set on a request via {@link FetchOptions.headers}. Default headers for all
41
- * requests can be set / customized using {@link addDefaultHeaders}.
44
+ * Key features:
45
+ * - Configurable timeouts (default 30s) via {@link FetchOptions.timeout}
46
+ * - Auto-abort of duplicate in-flight requests via {@link FetchOptions.autoAbortKey}
47
+ * - Optional correlation IDs for request tracking (see `defaults.autoGenCorrelationIds`)
48
+ * - Request/response interceptors via {@link addInterceptor}
49
+ * - Default headers for all requests via {@link addDefaultHeaders}
50
+ * - Rich exception handling with HTTP status, server messages, and trace IDs
42
51
  *
43
- * Also see the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API Docs}.
52
+ * All convenience methods accept the same {@link FetchOptions} as the main `fetch()` entry point.
44
53
  *
45
- * Note that the convenience methods `fetchJson`, `postJson`, `putJson` all accept the same options
46
- * as the main entry point `fetch`, as they delegate to fetch after setting additional defaults.
54
+ * @see FetchOptions
47
55
  */
48
- export interface FetchServiceDefaults {
49
- autoGenCorrelationIds?: boolean | ((opts: FetchOptions) => boolean);
50
- correlationIdHeaderKey?: string;
51
- genCorrelationId?: () => string;
52
- }
53
-
54
56
  export class FetchService extends HoistService {
55
57
  static instance: FetchService;
56
58
 
@@ -345,7 +345,7 @@ export class WebSocketService extends HoistService {
345
345
  private buildWebSocketUrl() {
346
346
  const protocol = window.location.protocol == 'https:' ? 'wss:' : 'ws:',
347
347
  endpoint = `xhWebSocket?${this.METADATA_FOR_HANDSHAKE.map(key => `${key}=${XH[key]}`).join('&')}`;
348
- return XH.isDevelopmentMode
348
+ return XH.baseUrl.includes('//')
349
349
  ? `${protocol}//${XH.baseUrl.split('//')[1]}${endpoint}`
350
350
  : `${protocol}//${window.location.host}${XH.baseUrl}${endpoint}`;
351
351
  }