@stackables/bridge-core 1.0.1 → 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.
- package/build/{bridge-core/src/ExecutionTree.d.ts → ExecutionTree.d.ts} +59 -2
- package/build/ExecutionTree.d.ts.map +1 -0
- package/build/{bridge-core/src/ExecutionTree.js → ExecutionTree.js} +492 -145
- package/build/execute-bridge.d.ts.map +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/merge-documents.d.ts.map +1 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/internal.d.ts.map +1 -0
- package/build/{bridge-core/src/types.d.ts → types.d.ts} +1 -1
- package/build/types.d.ts.map +1 -0
- package/build/utils.d.ts.map +1 -0
- package/build/version-check.d.ts.map +1 -0
- package/package.json +3 -3
- package/build/bridge-core/src/ExecutionTree.d.ts.map +0 -1
- package/build/bridge-core/src/execute-bridge.d.ts.map +0 -1
- package/build/bridge-core/src/index.d.ts.map +0 -1
- package/build/bridge-core/src/merge-documents.d.ts.map +0 -1
- package/build/bridge-core/src/tools/index.d.ts.map +0 -1
- package/build/bridge-core/src/tools/internal.d.ts.map +0 -1
- package/build/bridge-core/src/types.d.ts.map +0 -1
- package/build/bridge-core/src/utils.d.ts.map +0 -1
- package/build/bridge-core/src/version-check.d.ts.map +0 -1
- package/build/bridge-stdlib/src/index.d.ts +0 -34
- package/build/bridge-stdlib/src/index.d.ts.map +0 -1
- package/build/bridge-stdlib/src/index.js +0 -40
- package/build/bridge-stdlib/src/tools/arrays.d.ts +0 -28
- package/build/bridge-stdlib/src/tools/arrays.d.ts.map +0 -1
- package/build/bridge-stdlib/src/tools/arrays.js +0 -50
- package/build/bridge-stdlib/src/tools/audit.d.ts +0 -36
- package/build/bridge-stdlib/src/tools/audit.d.ts.map +0 -1
- package/build/bridge-stdlib/src/tools/audit.js +0 -39
- package/build/bridge-stdlib/src/tools/http-call.d.ts +0 -35
- package/build/bridge-stdlib/src/tools/http-call.d.ts.map +0 -1
- package/build/bridge-stdlib/src/tools/http-call.js +0 -118
- package/build/bridge-stdlib/src/tools/strings.d.ts +0 -13
- package/build/bridge-stdlib/src/tools/strings.d.ts.map +0 -1
- package/build/bridge-stdlib/src/tools/strings.js +0 -12
- package/build/bridge-types/src/index.d.ts +0 -63
- package/build/bridge-types/src/index.d.ts.map +0 -1
- package/build/bridge-types/src/index.js +0 -8
- /package/build/{bridge-core/src/execute-bridge.d.ts → execute-bridge.d.ts} +0 -0
- /package/build/{bridge-core/src/execute-bridge.js → execute-bridge.js} +0 -0
- /package/build/{bridge-core/src/index.d.ts → index.d.ts} +0 -0
- /package/build/{bridge-core/src/index.js → index.js} +0 -0
- /package/build/{bridge-core/src/merge-documents.d.ts → merge-documents.d.ts} +0 -0
- /package/build/{bridge-core/src/merge-documents.js → merge-documents.js} +0 -0
- /package/build/{bridge-core/src/tools → tools}/index.d.ts +0 -0
- /package/build/{bridge-core/src/tools → tools}/index.js +0 -0
- /package/build/{bridge-core/src/tools → tools}/internal.d.ts +0 -0
- /package/build/{bridge-core/src/tools → tools}/internal.js +0 -0
- /package/build/{bridge-core/src/types.js → types.js} +0 -0
- /package/build/{bridge-core/src/utils.d.ts → utils.d.ts} +0 -0
- /package/build/{bridge-core/src/utils.js → utils.js} +0 -0
- /package/build/{bridge-core/src/version-check.d.ts → version-check.d.ts} +0 -0
- /package/build/{bridge-core/src/version-check.js → version-check.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Bridge, BridgeDocument, ToolMap } from "./types.ts";
|
|
1
|
+
import type { Bridge, BridgeDocument, ToolMap, Wire } from "./types.ts";
|
|
2
2
|
/** Fatal panic error — bypasses all error boundaries (`?.` and `catch`). */
|
|
3
3
|
export declare class BridgePanicError extends Error {
|
|
4
4
|
constructor(message: string);
|
|
@@ -32,6 +32,13 @@ type Trunk = {
|
|
|
32
32
|
field: string;
|
|
33
33
|
instance?: number;
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* A value that may already be resolved (synchronous) or still pending (asynchronous).
|
|
37
|
+
* Using this instead of always returning `Promise<T>` lets callers skip
|
|
38
|
+
* microtask scheduling when the value is immediately available.
|
|
39
|
+
* See docs/performance.md (#10).
|
|
40
|
+
*/
|
|
41
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
35
42
|
/** Trace verbosity level.
|
|
36
43
|
* - `"off"` (default) — no collection, zero overhead
|
|
37
44
|
* - `"basic"` — tool, fn, timing, errors; no input/output
|
|
@@ -101,6 +108,8 @@ export declare class ExecutionTree {
|
|
|
101
108
|
private toolFns?;
|
|
102
109
|
/** Shadow-tree nesting depth (0 for root). */
|
|
103
110
|
private depth;
|
|
111
|
+
/** Pre-computed `trunkKey({ ...this.trunk, element: true })`. See docs/performance.md (#4). */
|
|
112
|
+
private elementTrunkKey;
|
|
104
113
|
constructor(trunk: Trunk, document: BridgeDocument, toolFns?: ToolMap, context?: Record<string, any> | undefined, parent?: ExecutionTree | undefined);
|
|
105
114
|
/** Derive tool name from a trunk */
|
|
106
115
|
private getToolName;
|
|
@@ -115,7 +124,20 @@ export declare class ExecutionTree {
|
|
|
115
124
|
private resolveToolSource;
|
|
116
125
|
/** Call a tool dependency (cached per request) */
|
|
117
126
|
private resolveToolDep;
|
|
118
|
-
schedule(target: Trunk, pullChain?: Set<string>): any
|
|
127
|
+
schedule(target: Trunk, pullChain?: Set<string>): MaybePromise<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Assemble input from resolved wire values and either invoke a direct tool
|
|
130
|
+
* function or return the data for pass-through targets (local/define/logic).
|
|
131
|
+
* Returns synchronously when the tool function (if any) returns sync.
|
|
132
|
+
* See docs/performance.md (#12).
|
|
133
|
+
*/
|
|
134
|
+
private scheduleFinish;
|
|
135
|
+
/**
|
|
136
|
+
* Full async schedule path for targets backed by a ToolDef.
|
|
137
|
+
* Resolves tool wires, bridge wires, and invokes the tool function
|
|
138
|
+
* with error recovery support.
|
|
139
|
+
*/
|
|
140
|
+
private scheduleToolDef;
|
|
119
141
|
/**
|
|
120
142
|
* Invoke a tool function, recording both an OpenTelemetry span and (when
|
|
121
143
|
* tracing is enabled) a ToolTrace entry. All three tool-call sites in the
|
|
@@ -125,6 +147,16 @@ export declare class ExecutionTree {
|
|
|
125
147
|
shadow(): ExecutionTree;
|
|
126
148
|
/** Returns collected traces (empty array when tracing is disabled). */
|
|
127
149
|
getTraces(): ToolTrace[];
|
|
150
|
+
/**
|
|
151
|
+
* Traverse `ref.path` on an already-resolved value, respecting null guards.
|
|
152
|
+
* Extracted from `pullSingle` so the sync and async paths can share logic.
|
|
153
|
+
*/
|
|
154
|
+
private applyPath;
|
|
155
|
+
/**
|
|
156
|
+
* Pull a single value. Returns synchronously when already in state;
|
|
157
|
+
* returns a Promise only when the value is a pending tool call.
|
|
158
|
+
* See docs/performance.md (#10).
|
|
159
|
+
*/
|
|
128
160
|
private pullSingle;
|
|
129
161
|
push(args: Record<string, any>): void;
|
|
130
162
|
/** Store the aggregated promise for critical forced handles so
|
|
@@ -163,7 +195,16 @@ export declare class ExecutionTree {
|
|
|
163
195
|
* After layers 1–2b, the overdefinition boundary (`!= null`) decides whether
|
|
164
196
|
* to return or continue to the next wire.
|
|
165
197
|
*/
|
|
198
|
+
/**
|
|
199
|
+
* Resolve wires, returning synchronously when the hot path allows it.
|
|
200
|
+
*
|
|
201
|
+
* Fast path: single `from` wire with no fallback/catch modifiers, which is
|
|
202
|
+
* the common case for element field wires like `.id <- it.id`. Delegates to
|
|
203
|
+
* `resolveWiresAsync` for anything more complex.
|
|
204
|
+
* See docs/performance.md (#10).
|
|
205
|
+
*/
|
|
166
206
|
private resolveWires;
|
|
207
|
+
private resolveWiresAsync;
|
|
167
208
|
/**
|
|
168
209
|
* Resolve an output field by path for use outside of a GraphQL resolver.
|
|
169
210
|
*
|
|
@@ -179,6 +220,22 @@ export declare class ExecutionTree {
|
|
|
179
220
|
* in a shadow tree (mirrors `response()` array handling).
|
|
180
221
|
*/
|
|
181
222
|
pullOutputField(path: string[], array?: boolean): Promise<unknown>;
|
|
223
|
+
/**
|
|
224
|
+
* Resolve pre-grouped wires on this shadow tree without re-filtering.
|
|
225
|
+
* Called by the parent's `materializeShadows` to skip per-element wire
|
|
226
|
+
* filtering. Returns synchronously when the wire resolves sync (hot path).
|
|
227
|
+
* See docs/performance.md (#8, #10).
|
|
228
|
+
*/
|
|
229
|
+
resolvePreGrouped(wires: Wire[]): MaybePromise<unknown>;
|
|
230
|
+
/**
|
|
231
|
+
* Materialise all output wires into a plain JS object.
|
|
232
|
+
*
|
|
233
|
+
* Used by the GraphQL adapter when a bridge field returns a scalar type
|
|
234
|
+
* (e.g. `JSON`, `JSONObject`). In that case GraphQL won't call sub-field
|
|
235
|
+
* resolvers, so we need to eagerly resolve every output wire and assemble
|
|
236
|
+
* the result ourselves — the same logic `run()` uses for object output.
|
|
237
|
+
*/
|
|
238
|
+
collectOutput(): Promise<unknown>;
|
|
182
239
|
/**
|
|
183
240
|
* Execute the bridge end-to-end without GraphQL.
|
|
184
241
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecutionTree.d.ts","sourceRoot":"","sources":["../src/ExecutionTree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EAMd,OAAO,EACP,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,4EAA4E;AAC5E,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,2EAA2E;AAC3E,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,SAAyC;CAI7D;AAOD,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AA0CtC;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACjC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE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