@jxsuite/server 4.4.5 → 4.5.1

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.
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { JsonValue } from "@jxsuite/schema/types";
2
+
1
3
  export interface BuildEntry {
2
4
  entrypoints: string[];
3
5
  outdir: string;
@@ -16,11 +18,12 @@ export interface ClassJsonField {
16
18
  access?: string;
17
19
  scope?: string;
18
20
  identifier?: string;
19
- initializer?: unknown;
20
- default?: unknown;
21
- type?: Record<string, unknown>;
21
+ initializer?: JsonValue;
22
+ default?: JsonValue;
23
+ /** A JSON Schema fragment; only an object (or array) form is merged into the studio schema. */
24
+ type?: JsonValue;
22
25
  description?: string;
23
- examples?: unknown[];
26
+ examples?: JsonValue[];
24
27
  }
25
28
 
26
29
  export interface ClassJsonMethod {
@@ -31,21 +34,28 @@ export interface ClassJsonMethod {
31
34
  getter?: { body: string };
32
35
  setter?: { parameters?: ClassJsonParam[]; body: string };
33
36
  parameters?: ClassJsonParam[];
34
- returns?: Record<string, unknown>;
37
+ returns?: JsonValue;
38
+ /** Where a format-extension capability method may run (`compiler`, `server`, `client`). */
39
+ timing?: string[];
35
40
  }
36
41
 
37
42
  export interface ClassJsonParameterDef {
38
43
  identifier?: string;
39
- type?: Record<string, unknown>;
44
+ /** A JSON Schema fragment; only an object (or array) form is merged into the studio schema. */
45
+ type?: JsonValue;
40
46
  format?: string;
41
47
  description?: string;
42
- examples?: unknown[];
48
+ examples?: JsonValue[];
43
49
  }
44
50
 
45
51
  export interface ClassJsonDef {
46
52
  title?: string;
47
53
  description?: string;
48
54
  $implementation?: string;
55
+ /** A format extension's format block, surfaced to the studio verbatim. */
56
+ format?: JsonValue;
57
+ /** Studio presentation hints, surfaced verbatim. */
58
+ $studio?: JsonValue;
49
59
  extends?: { $ref?: string };
50
60
  $defs?: {
51
61
  fields?: Record<string, ClassJsonField>;
package/src/watch.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /** Watch.js — File watcher + SSE live reload */
2
2
 
3
- import { watch as chokidarWatch } from "chokidar";
3
+ import { watch } from "chokidar";
4
4
  import { relative } from "node:path";
5
+ import { errorMessage } from "@jxsuite/schema/parse";
5
6
  import { rebuild } from "./build.ts";
6
7
  import { coalesceFsEvents, toFsEvent } from "./refactor/fs-events.ts";
7
8
  import { createWatchIgnore } from "./watch-policy.ts";
@@ -109,7 +110,7 @@ export function createWatcher(
109
110
  let fsTimer: ReturnType<typeof setTimeout> | null = null;
110
111
  let fsBuffer: FsEventPayload[] = [];
111
112
  const fsDebounceMs = 40;
112
- const watcher = chokidarWatch(root, {
113
+ const watcher = watch(root, {
113
114
  awaitWriteFinish: {
114
115
  pollInterval: 10,
115
116
  stabilityThreshold: debounceMs,
@@ -152,7 +153,7 @@ export function createWatcher(
152
153
  try {
153
154
  await preReload(filename);
154
155
  } catch (error) {
155
- console.error(`[watch] preReload failed: ${(error as Error).message}`);
156
+ console.error(`[watch] preReload failed: ${errorMessage(error)}`);
156
157
  }
157
158
  }
158
159
  if (builds.length > 0) {
@@ -174,11 +175,12 @@ export function createWatcher(
174
175
 
175
176
  // Gracefully handle watch errors (e.g. EINVAL on transient Bun test dirs).
176
177
  watcher.on("error", (err) => {
177
- const error = err as Error;
178
- if (error.message?.includes("EINVAL")) {
178
+ // Chokidar forwards the fs watcher's own errors, which are Error instances carrying a message.
179
+ const message = err instanceof Error ? err.message : undefined;
180
+ if (message?.includes("EINVAL")) {
179
181
  return;
180
182
  }
181
- console.error("[watch] chokidar error:", error.message ?? error);
183
+ console.error("[watch] chokidar error:", message ?? err);
182
184
  });
183
185
 
184
186
  return { broadcast, broadcastEvent, handleSSE, watcher };