@stackables/bridge-graphql 1.0.2 → 1.0.3

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 (54) hide show
  1. package/build/bridge-transform.d.ts.map +1 -0
  2. package/build/index.d.ts.map +1 -0
  3. package/package.json +3 -3
  4. package/build/bridge-core/src/ExecutionTree.d.ts +0 -270
  5. package/build/bridge-core/src/ExecutionTree.d.ts.map +0 -1
  6. package/build/bridge-core/src/ExecutionTree.js +0 -1670
  7. package/build/bridge-core/src/execute-bridge.d.ts +0 -69
  8. package/build/bridge-core/src/execute-bridge.d.ts.map +0 -1
  9. package/build/bridge-core/src/execute-bridge.js +0 -52
  10. package/build/bridge-core/src/index.d.ts +0 -18
  11. package/build/bridge-core/src/index.d.ts.map +0 -1
  12. package/build/bridge-core/src/index.js +0 -20
  13. package/build/bridge-core/src/merge-documents.d.ts +0 -25
  14. package/build/bridge-core/src/merge-documents.d.ts.map +0 -1
  15. package/build/bridge-core/src/merge-documents.js +0 -91
  16. package/build/bridge-core/src/tools/index.d.ts +0 -2
  17. package/build/bridge-core/src/tools/index.d.ts.map +0 -1
  18. package/build/bridge-core/src/tools/index.js +0 -1
  19. package/build/bridge-core/src/tools/internal.d.ts +0 -71
  20. package/build/bridge-core/src/tools/internal.d.ts.map +0 -1
  21. package/build/bridge-core/src/tools/internal.js +0 -59
  22. package/build/bridge-core/src/types.d.ts +0 -349
  23. package/build/bridge-core/src/types.d.ts.map +0 -1
  24. package/build/bridge-core/src/types.js +0 -3
  25. package/build/bridge-core/src/utils.d.ts +0 -9
  26. package/build/bridge-core/src/utils.d.ts.map +0 -1
  27. package/build/bridge-core/src/utils.js +0 -23
  28. package/build/bridge-core/src/version-check.d.ts +0 -64
  29. package/build/bridge-core/src/version-check.d.ts.map +0 -1
  30. package/build/bridge-core/src/version-check.js +0 -205
  31. package/build/bridge-graphql/src/bridge-transform.d.ts.map +0 -1
  32. package/build/bridge-graphql/src/index.d.ts.map +0 -1
  33. package/build/bridge-stdlib/src/index.d.ts +0 -34
  34. package/build/bridge-stdlib/src/index.d.ts.map +0 -1
  35. package/build/bridge-stdlib/src/index.js +0 -40
  36. package/build/bridge-stdlib/src/tools/arrays.d.ts +0 -28
  37. package/build/bridge-stdlib/src/tools/arrays.d.ts.map +0 -1
  38. package/build/bridge-stdlib/src/tools/arrays.js +0 -50
  39. package/build/bridge-stdlib/src/tools/audit.d.ts +0 -36
  40. package/build/bridge-stdlib/src/tools/audit.d.ts.map +0 -1
  41. package/build/bridge-stdlib/src/tools/audit.js +0 -39
  42. package/build/bridge-stdlib/src/tools/http-call.d.ts +0 -35
  43. package/build/bridge-stdlib/src/tools/http-call.d.ts.map +0 -1
  44. package/build/bridge-stdlib/src/tools/http-call.js +0 -118
  45. package/build/bridge-stdlib/src/tools/strings.d.ts +0 -13
  46. package/build/bridge-stdlib/src/tools/strings.d.ts.map +0 -1
  47. package/build/bridge-stdlib/src/tools/strings.js +0 -12
  48. package/build/bridge-types/src/index.d.ts +0 -63
  49. package/build/bridge-types/src/index.d.ts.map +0 -1
  50. package/build/bridge-types/src/index.js +0 -8
  51. /package/build/{bridge-graphql/src/bridge-transform.d.ts → bridge-transform.d.ts} +0 -0
  52. /package/build/{bridge-graphql/src/bridge-transform.js → bridge-transform.js} +0 -0
  53. /package/build/{bridge-graphql/src/index.d.ts → index.d.ts} +0 -0
  54. /package/build/{bridge-graphql/src/index.js → index.js} +0 -0
@@ -1,349 +0,0 @@
1
- /**
2
- * Structured node reference — identifies a specific data point in the execution graph.
3
- *
4
- * Every wire has a "from" and "to", each described by a NodeRef.
5
- * The trunk (module + type + field + instance) identifies the node,
6
- * while path drills into its data.
7
- */
8
- export type NodeRef = {
9
- /** Module identifier: "hereapi", "sendgrid", "zillow", or SELF_MODULE */
10
- module: string;
11
- /** GraphQL type ("Query" | "Mutation") or "Tools" for tool functions */
12
- type: string;
13
- /** Field or function name: "geocode", "search", "centsToUsd" */
14
- field: string;
15
- /** Instance number for tool calls (1, 2, ...) */
16
- instance?: number;
17
- /** References the current array element in a shadow tree (for per-element mapping) */
18
- element?: boolean;
19
- /** Path into the data: ["items", "0", "position", "lat"] */
20
- path: string[];
21
- /** True when the first `?.` is right after the root (e.g., `api?.data`) */
22
- rootSafe?: boolean;
23
- /** Per-segment safety flags (same length as `path`); true = `?.` before that segment */
24
- pathSafe?: boolean[];
25
- };
26
- /**
27
- * A wire connects a data source (from) to a data sink (to).
28
- * Execution is pull-based: when "to" is demanded, "from" is resolved.
29
- *
30
- * Constant wires (`=`) set a fixed value on the target.
31
- * Pull wires (`<-`) resolve the source at runtime.
32
- * Pipe wires (`pipe: true`) are generated by the `<- h1:h2:source` shorthand
33
- * and route data through declared tool handles; the serializer collapses them
34
- * back to pipe notation.
35
- */
36
- export type Wire = {
37
- from: NodeRef;
38
- to: NodeRef;
39
- pipe?: true;
40
- safe?: true;
41
- falsyFallbackRefs?: NodeRef[];
42
- falsyFallback?: string;
43
- falsyControl?: ControlFlowInstruction;
44
- nullishFallback?: string;
45
- nullishFallbackRef?: NodeRef;
46
- nullishControl?: ControlFlowInstruction;
47
- catchFallback?: string;
48
- catchFallbackRef?: NodeRef;
49
- catchControl?: ControlFlowInstruction;
50
- } | {
51
- value: string;
52
- to: NodeRef;
53
- } | {
54
- cond: NodeRef;
55
- thenRef?: NodeRef;
56
- thenValue?: string;
57
- elseRef?: NodeRef;
58
- elseValue?: string;
59
- to: NodeRef;
60
- falsyFallbackRefs?: NodeRef[];
61
- falsyFallback?: string;
62
- falsyControl?: ControlFlowInstruction;
63
- nullishFallback?: string;
64
- nullishFallbackRef?: NodeRef;
65
- nullishControl?: ControlFlowInstruction;
66
- catchFallback?: string;
67
- catchFallbackRef?: NodeRef;
68
- catchControl?: ControlFlowInstruction;
69
- } | {
70
- /** Short-circuit logical AND: evaluate left first, only evaluate right if left is truthy */
71
- condAnd: {
72
- leftRef: NodeRef;
73
- rightRef?: NodeRef;
74
- rightValue?: string;
75
- safe?: true;
76
- rightSafe?: true;
77
- };
78
- to: NodeRef;
79
- falsyFallbackRefs?: NodeRef[];
80
- falsyFallback?: string;
81
- falsyControl?: ControlFlowInstruction;
82
- nullishFallback?: string;
83
- nullishFallbackRef?: NodeRef;
84
- nullishControl?: ControlFlowInstruction;
85
- catchFallback?: string;
86
- catchFallbackRef?: NodeRef;
87
- catchControl?: ControlFlowInstruction;
88
- } | {
89
- /** Short-circuit logical OR: evaluate left first, only evaluate right if left is falsy */
90
- condOr: {
91
- leftRef: NodeRef;
92
- rightRef?: NodeRef;
93
- rightValue?: string;
94
- safe?: true;
95
- rightSafe?: true;
96
- };
97
- to: NodeRef;
98
- falsyFallbackRefs?: NodeRef[];
99
- falsyFallback?: string;
100
- falsyControl?: ControlFlowInstruction;
101
- nullishFallback?: string;
102
- nullishFallbackRef?: NodeRef;
103
- nullishControl?: ControlFlowInstruction;
104
- catchFallback?: string;
105
- catchFallbackRef?: NodeRef;
106
- catchControl?: ControlFlowInstruction;
107
- };
108
- /**
109
- * Bridge definition — wires one GraphQL field to its data sources.
110
- */
111
- export type Bridge = {
112
- kind: "bridge";
113
- /** GraphQL type: "Query" | "Mutation" */
114
- type: string;
115
- /** GraphQL field name */
116
- field: string;
117
- /** Declared data sources and their wire handles */
118
- handles: HandleBinding[];
119
- /** Connection wires */
120
- wires: Wire[];
121
- /**
122
- * When set, this bridge was declared with the passthrough shorthand:
123
- * `bridge Type.field with <name>`. The value is the define/tool name.
124
- */
125
- passthrough?: string;
126
- /** Handles to eagerly evaluate (e.g. side-effect tools).
127
- * Critical by default — a forced handle that throws aborts the bridge.
128
- * Add `catchError: true` (written as `force <handle> ?? null`) to
129
- * swallow the error for fire-and-forget side-effects. */
130
- forces?: Array<{
131
- handle: string;
132
- module: string;
133
- type: string;
134
- field: string;
135
- instance?: number;
136
- /** When true, errors from this forced handle are silently caught (`?? null`). */
137
- catchError?: true;
138
- }>;
139
- arrayIterators?: Record<string, string>;
140
- pipeHandles?: Array<{
141
- key: string;
142
- handle: string;
143
- baseTrunk: {
144
- module: string;
145
- type: string;
146
- field: string;
147
- instance?: number;
148
- };
149
- }>;
150
- };
151
- /**
152
- * A handle binding — declares a named data source available in a bridge.
153
- *
154
- * Every wire reference in the bridge body must trace back to one of these.
155
- */
156
- export type HandleBinding = {
157
- handle: string;
158
- kind: "tool";
159
- name: string;
160
- version?: string;
161
- } | {
162
- handle: string;
163
- kind: "input";
164
- } | {
165
- handle: string;
166
- kind: "output";
167
- } | {
168
- handle: string;
169
- kind: "context";
170
- } | {
171
- handle: string;
172
- kind: "const";
173
- } | {
174
- handle: string;
175
- kind: "define";
176
- name: string;
177
- };
178
- /** Internal module identifier for the bridge's own trunk (input args + output fields) */
179
- export declare const SELF_MODULE = "_";
180
- /**
181
- * Tool definition — a declared tool with wires, dependencies, and optional inheritance.
182
- *
183
- * Tool blocks define reusable, composable API call configurations:
184
- * tool hereapi httpCall — root tool with function name
185
- * tool hereapi.geocode extends hereapi — child inherits parent wires
186
- *
187
- * The engine resolves extends chains, merges wires, and calls the
188
- * registered tool function with the fully-built input object.
189
- */
190
- export type ToolDef = {
191
- kind: "tool";
192
- /** Tool name: "hereapi", "sendgrid.send", "authService" */
193
- name: string;
194
- /** Function name — looked up in the tools map. Omitted when extends is used. */
195
- fn?: string;
196
- /** Parent tool name — inherits fn, deps, and wires */
197
- extends?: string;
198
- /** Dependencies declared via `with` inside the tool block */
199
- deps: ToolDep[];
200
- /** Wires: constants (`=`) and pulls (`<-`) defining the tool's input */
201
- wires: ToolWire[];
202
- };
203
- /**
204
- * A dependency declared inside a tool block.
205
- *
206
- * with context — brings the full GraphQL context into scope
207
- * with authService as auth — brings another tool's output into scope
208
- */
209
- export type ToolDep = {
210
- kind: "context";
211
- handle: string;
212
- } | {
213
- kind: "tool";
214
- handle: string;
215
- tool: string;
216
- version?: string;
217
- } | {
218
- kind: "const";
219
- handle: string;
220
- };
221
- /**
222
- * A wire in a tool block — either a constant value, a pull from a dependency,
223
- * or an error fallback.
224
- *
225
- * Examples:
226
- * baseUrl = "https://api.sendgrid.com/v3" → constant
227
- * method = POST → constant (unquoted)
228
- * headers.Authorization <- ctx.sendgrid.token → pull from context
229
- * headers.Authorization <- auth.access_token → pull from tool dep
230
- * on error = { "lat": 0, "lon": 0 } → constant fallback
231
- * on error <- ctx.fallbacks.geo → pull fallback from context
232
- */
233
- export type ToolWire = {
234
- target: string;
235
- kind: "constant";
236
- value: string;
237
- } | {
238
- target: string;
239
- kind: "pull";
240
- source: string;
241
- } | {
242
- kind: "onError";
243
- value: string;
244
- } | {
245
- kind: "onError";
246
- source: string;
247
- };
248
- /**
249
- * Context passed to every tool function as the second argument.
250
- *
251
- * Provides access to engine services (logger, etc.) without polluting the
252
- * input object. Tools that don't need it simply ignore the second arg.
253
- */
254
- export type { ToolContext, ToolCallFn, ToolMap, CacheStore, } from "@stackables/bridge-types";
255
- /**
256
- * Explicit control flow instruction — used on the right side of fallback
257
- * gates (`||`, `??`, `catch`) to influence execution.
258
- *
259
- * - `throw` — raises a standard Error with the given message
260
- * - `panic` — raises a BridgePanicError that bypasses all error boundaries
261
- * - `continue` — skips the current array element (sentinel value)
262
- * - `break` — halts array iteration (sentinel value)
263
- */
264
- export type ControlFlowInstruction = {
265
- kind: "throw";
266
- message: string;
267
- } | {
268
- kind: "panic";
269
- message: string;
270
- } | {
271
- kind: "continue";
272
- } | {
273
- kind: "break";
274
- };
275
- /**
276
- * Named constant definition — a reusable value defined in the bridge file.
277
- *
278
- * Constants are available in bridge blocks via `with const as c` and in tool
279
- * blocks via `with const`. The engine collects all ConstDef instructions into
280
- * a single namespace object keyed by name.
281
- *
282
- * Examples:
283
- * const fallbackGeo = { "lat": 0, "lon": 0 }
284
- * const defaultCurrency = "EUR"
285
- */
286
- export type ConstDef = {
287
- kind: "const";
288
- /** Constant name — used as the key in the const namespace */
289
- name: string;
290
- /** Raw JSON string — parsed at runtime when accessed */
291
- value: string;
292
- };
293
- /**
294
- * Version declaration — records the bridge file's declared language version.
295
- *
296
- * Emitted by the parser as the first instruction. Used at runtime to verify
297
- * that the standard library satisfies the bridge's minimum version requirement.
298
- *
299
- * Example: `version 1.5` → `{ kind: "version", version: "1.5" }`
300
- */
301
- export type VersionDecl = {
302
- kind: "version";
303
- /** Declared version string, e.g. "1.5" */
304
- version: string;
305
- };
306
- /** Union of all instruction types (excludes VersionDecl — version lives on BridgeDocument) */
307
- export type Instruction = Bridge | ToolDef | ConstDef | DefineDef;
308
- /**
309
- * Parsed bridge document — the structured output of the compiler.
310
- *
311
- * Wraps the instruction array with document-level metadata (version) and
312
- * provides a natural home for future pre-computed optimisations.
313
- */
314
- export interface BridgeDocument {
315
- /** Declared language version (from `version X.Y` header). */
316
- version?: string;
317
- /** All instructions: bridge, tool, const, and define blocks. */
318
- instructions: Instruction[];
319
- }
320
- /**
321
- * Define block — a reusable named subgraph (pipeline / macro).
322
- *
323
- * At parse time a define is stored as a template. When a bridge declares
324
- * `with <define> as <handle>`, the define's handles and wires are inlined
325
- * into the bridge with namespaced identifiers for isolation.
326
- *
327
- * Example:
328
- * define secureProfile {
329
- * with userApi as api
330
- * with input as i
331
- * with output as o
332
- * api.id <- i.userId
333
- * o.name <- api.login
334
- * }
335
- */
336
- export type DefineDef = {
337
- kind: "define";
338
- /** Define name — referenced in bridge `with` declarations */
339
- name: string;
340
- /** Declared handles (tools, input, output, etc.) */
341
- handles: HandleBinding[];
342
- /** Connection wires (same format as Bridge wires) */
343
- wires: Wire[];
344
- /** Array iterators (same as Bridge) */
345
- arrayIterators?: Record<string, string>;
346
- /** Pipe fork registry (same as Bridge) */
347
- pipeHandles?: Bridge["pipeHandles"];
348
- };
349
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE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;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qDAAqD;IACrD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;CACrC,CAAC"}
@@ -1,3 +0,0 @@
1
- /** Internal module identifier for the bridge's own trunk (input args + output fields) */
2
- export const SELF_MODULE = "_";
3
- /* c8 ignore stop */
@@ -1,9 +0,0 @@
1
- /**
2
- * Shared utilities for the Bridge runtime.
3
- */
4
- /**
5
- * Split a dotted path string into path segments, expanding array indices.
6
- * e.g. "items[0].name" → ["items", "0", "name"]
7
- */
8
- export declare function parsePath(text: string): string[];
9
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAchD"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Shared utilities for the Bridge runtime.
3
- */
4
- /**
5
- * Split a dotted path string into path segments, expanding array indices.
6
- * e.g. "items[0].name" → ["items", "0", "name"]
7
- */
8
- export function parsePath(text) {
9
- const parts = [];
10
- for (const segment of text.split(".")) {
11
- const match = segment.match(/^([^[]+)(?:\[(\d*)\])?$/);
12
- if (match) {
13
- parts.push(match[1]);
14
- if (match[2] !== undefined && match[2] !== "") {
15
- parts.push(match[2]);
16
- }
17
- }
18
- else {
19
- parts.push(segment);
20
- }
21
- }
22
- return parts;
23
- }
@@ -1,64 +0,0 @@
1
- import type { BridgeDocument, Instruction, ToolMap } from "./types.ts";
2
- /**
3
- * Extract the declared bridge version from a document.
4
- * Returns `undefined` if no version was declared.
5
- */
6
- export declare function getBridgeVersion(doc: BridgeDocument): string | undefined;
7
- /**
8
- * Verify that the standard library satisfies the bridge file's declared version.
9
- *
10
- * The bridge `version X.Y` header acts as a minimum-version constraint:
11
- * - Same major → compatible (only major bumps introduce breaking changes)
12
- * - Bridge minor ≤ std minor → OK (std is same or newer)
13
- * - Bridge minor > std minor → ERROR (bridge needs features not in this std)
14
- * - Different major → ERROR (user must provide a compatible std explicitly)
15
- *
16
- * @throws Error with an actionable message when the std is incompatible.
17
- */
18
- export declare function checkStdVersion(version: string | undefined, stdVersion: string): void;
19
- /**
20
- * Resolve the standard library namespace and version to use.
21
- *
22
- * Checks the bundled std first. When the bridge file targets a different
23
- * major version (e.g. `version 1.5` vs bundled `2.0.0`), scans the
24
- * user-provided tools map for a versioned namespace key like `"std@1.5"`.
25
- *
26
- * @returns The resolved std namespace and its version string.
27
- * @throws Error with an actionable message when no compatible std is found.
28
- */
29
- export declare function resolveStd(version: string | undefined, bundledStd: ToolMap, bundledStdVersion: string, userTools?: ToolMap): {
30
- namespace: ToolMap;
31
- version: string;
32
- };
33
- /**
34
- * Collect every tool reference that carries an `@version` tag from handles
35
- * (bridge/define blocks) and deps (tool blocks).
36
- */
37
- export declare function collectVersionedHandles(instructions: Instruction[]): Array<{
38
- name: string;
39
- version: string;
40
- }>;
41
- /**
42
- * Check whether a versioned dotted tool name can be resolved.
43
- *
44
- * In addition to the standard checks (namespace traversal, flat key),
45
- * this also checks **versioned namespace keys** in the tool map:
46
- * - `"std.str.toLowerCase@999.1"` as a flat key
47
- * - `"std.str@999.1"` as a namespace key containing `toLowerCase`
48
- * - `"std@999.1"` as a namespace key, traversing to `str.toLowerCase`
49
- */
50
- export declare function hasVersionedToolFn(toolFns: ToolMap, name: string, version: string): boolean;
51
- /**
52
- * Validate that all versioned tool handles can be satisfied at runtime.
53
- *
54
- * For each handle with `@version`:
55
- * 1. A versioned key or versioned namespace in the tool map → satisfied
56
- * 2. A `std.*` tool whose STD_VERSION ≥ the requested version → satisfied
57
- * 3. Otherwise → throws with an actionable error message
58
- *
59
- * Call this **before** constructing the ExecutionTree to fail early.
60
- *
61
- * @throws Error when a versioned tool cannot be satisfied.
62
- */
63
- export declare function checkHandleVersions(instructions: Instruction[], toolFns: ToolMap, stdVersion: string): void;
64
- //# sourceMappingURL=version-check.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version-check.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/version-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EAEd,WAAW,EAEX,OAAO,EACR,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAExE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,UAAU,EAAE,MAAM,GACjB,IAAI,CAuBN;AAID;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,UAAU,EAAE,OAAO,EACnB,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,OAAY,GACtB;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA4CzC;AAID;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,WAAW,EAAE,GAC1B,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAmB1C;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CA8BT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,WAAW,EAAE,EAC3B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,IAAI,CA6BN"}
@@ -1,205 +0,0 @@
1
- /**
2
- * Extract the declared bridge version from a document.
3
- * Returns `undefined` if no version was declared.
4
- */
5
- export function getBridgeVersion(doc) {
6
- return doc.version;
7
- }
8
- /**
9
- * Verify that the standard library satisfies the bridge file's declared version.
10
- *
11
- * The bridge `version X.Y` header acts as a minimum-version constraint:
12
- * - Same major → compatible (only major bumps introduce breaking changes)
13
- * - Bridge minor ≤ std minor → OK (std is same or newer)
14
- * - Bridge minor > std minor → ERROR (bridge needs features not in this std)
15
- * - Different major → ERROR (user must provide a compatible std explicitly)
16
- *
17
- * @throws Error with an actionable message when the std is incompatible.
18
- */
19
- export function checkStdVersion(version, stdVersion) {
20
- if (!version)
21
- return; // no version declared — nothing to check
22
- const bParts = version.split(".").map(Number);
23
- const sParts = stdVersion.split(".").map(Number);
24
- const [bMajor = 0, bMinor = 0] = bParts;
25
- const [sMajor = 0, sMinor = 0] = sParts;
26
- if (bMajor !== sMajor) {
27
- throw new Error(`Bridge version ${version} requires a ${bMajor}.x standard library, ` +
28
- `but the provided std is ${stdVersion} (major version ${sMajor}). ` +
29
- `Provide a compatible std as "std@${version}" in the tools map.`);
30
- }
31
- if (bMinor > sMinor) {
32
- throw new Error(`Bridge version ${version} requires standard library ≥ ${bMajor}.${bMinor}, ` +
33
- `but the installed @stackables/bridge-stdlib is ${stdVersion}. ` +
34
- `Update @stackables/bridge-stdlib to ${bMajor}.${bMinor}.0 or later.`);
35
- }
36
- }
37
- // ── Std resolution from tools map ───────────────────────────────────────────
38
- /**
39
- * Resolve the standard library namespace and version to use.
40
- *
41
- * Checks the bundled std first. When the bridge file targets a different
42
- * major version (e.g. `version 1.5` vs bundled `2.0.0`), scans the
43
- * user-provided tools map for a versioned namespace key like `"std@1.5"`.
44
- *
45
- * @returns The resolved std namespace and its version string.
46
- * @throws Error with an actionable message when no compatible std is found.
47
- */
48
- export function resolveStd(version, bundledStd, bundledStdVersion, userTools = {}) {
49
- if (!version) {
50
- return { namespace: bundledStd, version: bundledStdVersion };
51
- }
52
- const [bMajor = 0, bMinor = 0] = version.split(".").map(Number);
53
- const [sMajor = 0, sMinor = 0] = bundledStdVersion.split(".").map(Number);
54
- // Bundled std satisfies the bridge version
55
- if (bMajor === sMajor && sMinor >= bMinor) {
56
- return { namespace: bundledStd, version: bundledStdVersion };
57
- }
58
- // Scan tools for a versioned std namespace key (e.g. "std@1.5")
59
- for (const key of Object.keys(userTools)) {
60
- const match = key.match(/^std@(.+)$/);
61
- if (match) {
62
- const ver = match[1];
63
- const parts = ver.split(".").map(Number);
64
- const [vMajor = 0, vMinor = 0] = parts;
65
- if (vMajor === bMajor && vMinor >= bMinor) {
66
- const ns = userTools[key];
67
- if (ns != null && typeof ns === "object" && !Array.isArray(ns)) {
68
- const fullVersion = parts.length <= 2 ? `${ver}.0` : ver;
69
- return { namespace: ns, version: fullVersion };
70
- }
71
- }
72
- }
73
- }
74
- // No compatible std found — produce actionable error
75
- if (bMajor !== sMajor) {
76
- throw new Error(`Bridge version ${version} requires a ${bMajor}.x standard library, ` +
77
- `but the bundled std is ${bundledStdVersion} (major version ${sMajor}). ` +
78
- `Provide a compatible std as "std@${version}" in the tools map.`);
79
- }
80
- throw new Error(`Bridge version ${version} requires standard library ≥ ${bMajor}.${bMinor}, ` +
81
- `but the installed @stackables/bridge-stdlib is ${bundledStdVersion}. ` +
82
- `Update @stackables/bridge-stdlib to ${bMajor}.${bMinor}.0 or later.`);
83
- }
84
- // ── Versioned handle validation ─────────────────────────────────────────────
85
- /**
86
- * Collect every tool reference that carries an `@version` tag from handles
87
- * (bridge/define blocks) and deps (tool blocks).
88
- */
89
- export function collectVersionedHandles(instructions) {
90
- const result = [];
91
- for (const inst of instructions) {
92
- if (inst.kind === "bridge" || inst.kind === "define") {
93
- for (const h of inst.handles) {
94
- if (h.kind === "tool" && h.version) {
95
- result.push({ name: h.name, version: h.version });
96
- }
97
- }
98
- }
99
- if (inst.kind === "tool") {
100
- for (const dep of inst.deps) {
101
- if (dep.kind === "tool" && dep.version) {
102
- result.push({ name: dep.tool, version: dep.version });
103
- }
104
- }
105
- }
106
- }
107
- return result;
108
- }
109
- /**
110
- * Check whether a dotted tool name resolves to a function in the tool map.
111
- * Supports both namespace traversal (std.str.toUpperCase) and flat keys.
112
- */
113
- function hasToolFn(toolFns, name) {
114
- if (name.includes(".")) {
115
- const parts = name.split(".");
116
- let current = toolFns;
117
- for (const part of parts) {
118
- if (current == null || typeof current !== "object") {
119
- current = undefined;
120
- break;
121
- }
122
- current = current[part];
123
- }
124
- if (typeof current === "function")
125
- return true;
126
- // flat key fallback
127
- return typeof toolFns[name] === "function";
128
- }
129
- return typeof toolFns[name] === "function";
130
- }
131
- /**
132
- * Check whether a versioned dotted tool name can be resolved.
133
- *
134
- * In addition to the standard checks (namespace traversal, flat key),
135
- * this also checks **versioned namespace keys** in the tool map:
136
- * - `"std.str.toLowerCase@999.1"` as a flat key
137
- * - `"std.str@999.1"` as a namespace key containing `toLowerCase`
138
- * - `"std@999.1"` as a namespace key, traversing to `str.toLowerCase`
139
- */
140
- export function hasVersionedToolFn(toolFns, name, version) {
141
- const versionedKey = `${name}@${version}`;
142
- // 1. Flat key or direct namespace traversal
143
- if (hasToolFn(toolFns, versionedKey))
144
- return true;
145
- // 2. Versioned namespace key lookup
146
- // For "std.str.toLowerCase" @ "999.1", try:
147
- // toolFns["std.str@999.1"]?.toLowerCase
148
- // toolFns["std@999.1"]?.str?.toLowerCase
149
- if (name.includes(".")) {
150
- const parts = name.split(".");
151
- for (let i = parts.length - 1; i >= 1; i--) {
152
- const nsKey = parts.slice(0, i).join(".") + "@" + version;
153
- const remainder = parts.slice(i);
154
- let ns = toolFns[nsKey];
155
- if (ns != null && typeof ns === "object") {
156
- for (const part of remainder) {
157
- if (ns == null || typeof ns !== "object") {
158
- ns = undefined;
159
- break;
160
- }
161
- ns = ns[part];
162
- }
163
- if (typeof ns === "function")
164
- return true;
165
- }
166
- }
167
- }
168
- return false;
169
- }
170
- /**
171
- * Validate that all versioned tool handles can be satisfied at runtime.
172
- *
173
- * For each handle with `@version`:
174
- * 1. A versioned key or versioned namespace in the tool map → satisfied
175
- * 2. A `std.*` tool whose STD_VERSION ≥ the requested version → satisfied
176
- * 3. Otherwise → throws with an actionable error message
177
- *
178
- * Call this **before** constructing the ExecutionTree to fail early.
179
- *
180
- * @throws Error when a versioned tool cannot be satisfied.
181
- */
182
- export function checkHandleVersions(instructions, toolFns, stdVersion) {
183
- const versioned = collectVersionedHandles(instructions);
184
- for (const { name, version } of versioned) {
185
- // 1. Flat key, namespace traversal, or versioned namespace key
186
- if (hasVersionedToolFn(toolFns, name, version))
187
- continue;
188
- // 2. For std.* tools, check if the active std satisfies the version
189
- if (name.startsWith("std.")) {
190
- const sParts = stdVersion.split(".").map(Number);
191
- const vParts = version.split(".").map(Number);
192
- const [sMajor = 0, sMinor = 0] = sParts;
193
- const [vMajor = 0, vMinor = 0] = vParts;
194
- if (sMajor === vMajor && sMinor >= vMinor)
195
- continue;
196
- throw new Error(`Tool "${name}@${version}" requires standard library ≥ ${vMajor}.${vMinor}, ` +
197
- `but the installed @stackables/bridge-stdlib is ${stdVersion}. ` +
198
- `Either update the stdlib or provide the tool as ` +
199
- `"${name}@${version}" in the tools map.`);
200
- }
201
- // 3. Non-std tool — must be provided with a versioned key or namespace
202
- throw new Error(`Tool "${name}@${version}" is not available. ` +
203
- `Provide it as "${name}@${version}" in the tools map.`);
204
- }
205
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge-transform.d.ts","sourceRoot":"","sources":["../../../src/bridge-transform.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAInB,MAAM,SAAS,CAAC;AACjB,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvE,YAAY,EAAE,MAAM,EAAE,CAAC;AAUvB,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;qEACiE;IACjE,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtD;;;6DAGyD;IACzD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qFAAqF;AACrF,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,cAAc,CAAC,CAAC;AAEvC,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa,CAuJf;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,GAAG,GAAG,SAAS,EAAE,CAEzD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB;wBAER;QAAE,IAAI,EAAE;YAAE,YAAY,EAAE,GAAG,CAAA;SAAE,CAAA;KAAE;8CAK5C;YACD,MAAM,EAAE,GAAG,CAAC;YACZ,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;SAC7B;;EAeR"}