@genroc/eval-node 0.0.0-edge.e7344b7 → 0.0.0-edge.e8b5b331

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/dist/import.js CHANGED
@@ -90,15 +90,17 @@ function objectType(s, used) {
90
90
  const doc = typeof sub.description === "string"
91
91
  ? ` /** ${sub.description} */\n`
92
92
  : "";
93
- lines.push(`${doc} ${propKey(key)}${required.has(key) ? "" : "?"}: ${tsType(sub, used)};`);
93
+ lines.push(`${doc} ${propKey(key)}${required.has(key) ? "" : "?"}: ${nest(tsType(sub, used))};`);
94
94
  }
95
95
  if (s.additionalProperties && typeof s.additionalProperties === "object") {
96
- lines.push(` [key: string]: ${tsType(s.additionalProperties, used)};`);
96
+ lines.push(` [key: string]: ${nest(tsType(s.additionalProperties, used))};`);
97
97
  }
98
98
  if (lines.length === 0)
99
99
  return "Record<string, unknown>";
100
100
  return `{\n${lines.join("\n")}\n}`;
101
101
  }
102
+ /** Every line but the first, which is already placed by the property that opens it. */
103
+ const nest = (t) => t.replace(/\n/g, "\n ");
102
104
  function union(parts) {
103
105
  const seen = [...new Set(parts)];
104
106
  return seen.length === 0 ? "unknown" : seen.join(" | ");
@@ -106,13 +108,6 @@ function union(parts) {
106
108
  const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
107
109
  const propKey = (k) => (IDENT.test(k) ? k : JSON.stringify(k));
108
110
  const identifier = (n) => IDENT.test(n) ? n : `Def_${n.replace(/[^A-Za-z0-9_$]/g, "_")}`;
109
- function deref(s, defs) {
110
- let cur = s;
111
- for (let i = 0; cur && typeof cur.$ref === "string" && i < 16; i++) {
112
- cur = defs[cur.$ref.replace(/^#\/\$defs\//, "")];
113
- }
114
- return cur;
115
- }
116
111
  /** Emits one named type per reachable $def rather than inlining: a task output may
117
112
  * reference itself (specs/recursive-type-inference.md) and inlining would not terminate. */
118
113
  function declarations(at) {
package/dist/worker.js CHANGED
@@ -62,15 +62,15 @@ async function fetchObject(ref) {
62
62
  /** Put each listed value back where its path says it belongs. Paths are arrays of keys, so this
63
63
  * needs no parser: the whole reason they are not JSON Pointer strings. */
64
64
  async function resolveObjects(job) {
65
- let input = job.input;
65
+ let input = job.external_input;
66
66
  for (const e of job.objects ?? []) {
67
67
  const value = await fetchObject(e.ref);
68
68
  if (e.path.length === 0) {
69
69
  input = value;
70
70
  continue;
71
71
  }
72
- // The path is rooted at the entry and starts with "input", which is the value being rebuilt.
73
- const rest = e.path[0] === "input" ? e.path.slice(1) : e.path;
72
+ // The path is rooted at the entry and starts with "external_input", the value being rebuilt.
73
+ const rest = e.path[0] === "external_input" ? e.path.slice(1) : e.path;
74
74
  if (rest.length === 0) {
75
75
  input = value;
76
76
  continue;
package/import.ts CHANGED
@@ -137,16 +137,21 @@ function objectType(s: Schema, used: Set<string>): string {
137
137
  ? ` /** ${sub.description} */\n`
138
138
  : "";
139
139
  lines.push(
140
- `${doc} ${propKey(key)}${required.has(key) ? "" : "?"}: ${tsType(sub, used)};`,
140
+ `${doc} ${propKey(key)}${required.has(key) ? "" : "?"}: ${nest(tsType(sub, used))};`,
141
141
  );
142
142
  }
143
143
  if (s.additionalProperties && typeof s.additionalProperties === "object") {
144
- lines.push(` [key: string]: ${tsType(s.additionalProperties, used)};`);
144
+ lines.push(
145
+ ` [key: string]: ${nest(tsType(s.additionalProperties, used))};`,
146
+ );
145
147
  }
146
148
  if (lines.length === 0) return "Record<string, unknown>";
147
149
  return `{\n${lines.join("\n")}\n}`;
148
150
  }
149
151
 
152
+ /** Every line but the first, which is already placed by the property that opens it. */
153
+ const nest = (t: string) => t.replace(/\n/g, "\n ");
154
+
150
155
  function union(parts: string[]): string {
151
156
  const seen = [...new Set(parts)];
152
157
  return seen.length === 0 ? "unknown" : seen.join(" | ");
@@ -157,17 +162,6 @@ const propKey = (k: string) => (IDENT.test(k) ? k : JSON.stringify(k));
157
162
  const identifier = (n: string) =>
158
163
  IDENT.test(n) ? n : `Def_${n.replace(/[^A-Za-z0-9_$]/g, "_")}`;
159
164
 
160
- function deref(
161
- s: Schema | undefined,
162
- defs: Record<string, Schema>,
163
- ): Schema | undefined {
164
- let cur = s;
165
- for (let i = 0; cur && typeof cur.$ref === "string" && i < 16; i++) {
166
- cur = defs[cur.$ref.replace(/^#\/\$defs\//, "")];
167
- }
168
- return cur;
169
- }
170
-
171
165
  /** Emits one named type per reachable $def rather than inlining: a task output may
172
166
  * reference itself (specs/recursive-type-inference.md) and inlining would not terminate. */
173
167
  function declarations(at: Located): string {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genroc/eval-node",
3
- "version": "0.0.0-edge.e7344b7",
3
+ "version": "0.0.0-edge.e8b5b331",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
package/worker.ts CHANGED
@@ -43,8 +43,8 @@ type ObjectEntry = { path: (string | number)[]; ref: string; size: number };
43
43
  type QueueTask = {
44
44
  token: string;
45
45
  process: string;
46
- task_id: string;
47
- input: unknown;
46
+ task: string;
47
+ external_input: unknown;
48
48
  objects?: ObjectEntry[];
49
49
  raises?: Record<string, unknown>;
50
50
  };
@@ -76,15 +76,15 @@ async function fetchObject(ref: string): Promise<unknown> {
76
76
  /** Put each listed value back where its path says it belongs. Paths are arrays of keys, so this
77
77
  * needs no parser: the whole reason they are not JSON Pointer strings. */
78
78
  async function resolveObjects(job: QueueTask): Promise<unknown> {
79
- let input: any = job.input;
79
+ let input: any = job.external_input;
80
80
  for (const e of job.objects ?? []) {
81
81
  const value = await fetchObject(e.ref);
82
82
  if (e.path.length === 0) {
83
83
  input = value;
84
84
  continue;
85
85
  }
86
- // The path is rooted at the entry and starts with "input", which is the value being rebuilt.
87
- const rest = e.path[0] === "input" ? e.path.slice(1) : e.path;
86
+ // The path is rooted at the entry and starts with "external_input", the value being rebuilt.
87
+ const rest = e.path[0] === "external_input" ? e.path.slice(1) : e.path;
88
88
  if (rest.length === 0) {
89
89
  input = value;
90
90
  continue;