@stackables/bridge-compiler 1.0.0 → 1.0.2

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 (73) hide show
  1. package/build/bridge-compiler/src/bridge-format.d.ts.map +1 -0
  2. package/build/{bridge-lint.d.ts.map → bridge-compiler/src/bridge-lint.d.ts.map} +1 -1
  3. package/build/bridge-compiler/src/index.d.ts.map +1 -0
  4. package/build/bridge-compiler/src/language-service.d.ts.map +1 -0
  5. package/build/bridge-compiler/src/parser/index.d.ts.map +1 -0
  6. package/build/bridge-compiler/src/parser/lexer.d.ts.map +1 -0
  7. package/build/bridge-compiler/src/parser/parser.d.ts.map +1 -0
  8. package/build/bridge-core/src/ExecutionTree.d.ts +270 -0
  9. package/build/bridge-core/src/ExecutionTree.d.ts.map +1 -0
  10. package/build/bridge-core/src/ExecutionTree.js +1670 -0
  11. package/build/bridge-core/src/execute-bridge.d.ts +69 -0
  12. package/build/bridge-core/src/execute-bridge.d.ts.map +1 -0
  13. package/build/bridge-core/src/execute-bridge.js +52 -0
  14. package/build/bridge-core/src/index.d.ts +18 -0
  15. package/build/bridge-core/src/index.d.ts.map +1 -0
  16. package/build/bridge-core/src/index.js +20 -0
  17. package/build/bridge-core/src/merge-documents.d.ts +25 -0
  18. package/build/bridge-core/src/merge-documents.d.ts.map +1 -0
  19. package/build/bridge-core/src/merge-documents.js +91 -0
  20. package/build/bridge-core/src/tools/index.d.ts +2 -0
  21. package/build/bridge-core/src/tools/index.d.ts.map +1 -0
  22. package/build/bridge-core/src/tools/index.js +1 -0
  23. package/build/bridge-core/src/tools/internal.d.ts +71 -0
  24. package/build/bridge-core/src/tools/internal.d.ts.map +1 -0
  25. package/build/bridge-core/src/tools/internal.js +59 -0
  26. package/build/bridge-core/src/types.d.ts +349 -0
  27. package/build/bridge-core/src/types.d.ts.map +1 -0
  28. package/build/bridge-core/src/types.js +3 -0
  29. package/build/bridge-core/src/utils.d.ts +9 -0
  30. package/build/bridge-core/src/utils.d.ts.map +1 -0
  31. package/build/bridge-core/src/utils.js +23 -0
  32. package/build/bridge-core/src/version-check.d.ts +64 -0
  33. package/build/bridge-core/src/version-check.d.ts.map +1 -0
  34. package/build/bridge-core/src/version-check.js +205 -0
  35. package/build/bridge-stdlib/src/index.d.ts +34 -0
  36. package/build/bridge-stdlib/src/index.d.ts.map +1 -0
  37. package/build/bridge-stdlib/src/index.js +40 -0
  38. package/build/bridge-stdlib/src/tools/arrays.d.ts +28 -0
  39. package/build/bridge-stdlib/src/tools/arrays.d.ts.map +1 -0
  40. package/build/bridge-stdlib/src/tools/arrays.js +50 -0
  41. package/build/bridge-stdlib/src/tools/audit.d.ts +36 -0
  42. package/build/bridge-stdlib/src/tools/audit.d.ts.map +1 -0
  43. package/build/bridge-stdlib/src/tools/audit.js +39 -0
  44. package/build/bridge-stdlib/src/tools/http-call.d.ts +35 -0
  45. package/build/bridge-stdlib/src/tools/http-call.d.ts.map +1 -0
  46. package/build/bridge-stdlib/src/tools/http-call.js +118 -0
  47. package/build/bridge-stdlib/src/tools/strings.d.ts +13 -0
  48. package/build/bridge-stdlib/src/tools/strings.d.ts.map +1 -0
  49. package/build/bridge-stdlib/src/tools/strings.js +12 -0
  50. package/build/bridge-types/src/index.d.ts +63 -0
  51. package/build/bridge-types/src/index.d.ts.map +1 -0
  52. package/build/bridge-types/src/index.js +8 -0
  53. package/package.json +2 -2
  54. package/build/bridge-format.d.ts.map +0 -1
  55. package/build/index.d.ts.map +0 -1
  56. package/build/language-service.d.ts.map +0 -1
  57. package/build/parser/index.d.ts.map +0 -1
  58. package/build/parser/lexer.d.ts.map +0 -1
  59. package/build/parser/parser.d.ts.map +0 -1
  60. /package/build/{bridge-format.d.ts → bridge-compiler/src/bridge-format.d.ts} +0 -0
  61. /package/build/{bridge-format.js → bridge-compiler/src/bridge-format.js} +0 -0
  62. /package/build/{bridge-lint.d.ts → bridge-compiler/src/bridge-lint.d.ts} +0 -0
  63. /package/build/{bridge-lint.js → bridge-compiler/src/bridge-lint.js} +0 -0
  64. /package/build/{index.d.ts → bridge-compiler/src/index.d.ts} +0 -0
  65. /package/build/{index.js → bridge-compiler/src/index.js} +0 -0
  66. /package/build/{language-service.d.ts → bridge-compiler/src/language-service.d.ts} +0 -0
  67. /package/build/{language-service.js → bridge-compiler/src/language-service.js} +0 -0
  68. /package/build/{parser → bridge-compiler/src/parser}/index.d.ts +0 -0
  69. /package/build/{parser → bridge-compiler/src/parser}/index.js +0 -0
  70. /package/build/{parser → bridge-compiler/src/parser}/lexer.d.ts +0 -0
  71. /package/build/{parser → bridge-compiler/src/parser}/lexer.js +0 -0
  72. /package/build/{parser → bridge-compiler/src/parser}/parser.d.ts +0 -0
  73. /package/build/{parser → bridge-compiler/src/parser}/parser.js +0 -0
@@ -0,0 +1,69 @@
1
+ import type { Logger, ToolTrace, TraceLevel } from "./ExecutionTree.ts";
2
+ import type { BridgeDocument, ToolMap } from "./types.ts";
3
+ export type ExecuteBridgeOptions = {
4
+ /** Parsed bridge document (from `parseBridge` or `parseBridgeDiagnostics`). */
5
+ document: BridgeDocument;
6
+ /**
7
+ * Which bridge to execute, as `"Type.field"`.
8
+ * Mirrors the `bridge Type.field { ... }` declaration.
9
+ * Example: `"Query.searchTrains"` or `"Mutation.sendEmail"`.
10
+ */
11
+ operation: string;
12
+ /** Input arguments — equivalent to GraphQL field arguments. */
13
+ input?: Record<string, unknown>;
14
+ /**
15
+ * Tool functions available to the engine.
16
+ *
17
+ * Supports namespaced nesting: `{ myNamespace: { myTool } }`.
18
+ * The built-in `std` namespace is always included; user tools are
19
+ * merged on top (shallow).
20
+ *
21
+ * To provide a specific version of std (e.g. when the bridge file
22
+ * targets an older major), use a versioned namespace key:
23
+ * ```ts
24
+ * tools: { "std@1.5": oldStdNamespace }
25
+ * ```
26
+ */
27
+ tools?: ToolMap;
28
+ /** Context available via `with context as ctx` inside the bridge. */
29
+ context?: Record<string, unknown>;
30
+ /**
31
+ * Enable tool-call tracing.
32
+ * - `"off"` (default) — no collection, zero overhead
33
+ * - `"basic"` — tool, fn, timing, errors; no input/output
34
+ * - `"full"` — everything including input and output
35
+ */
36
+ trace?: TraceLevel;
37
+ /** Structured logger for engine events. */
38
+ logger?: Logger;
39
+ /** External abort signal — cancels execution when triggered. */
40
+ signal?: AbortSignal;
41
+ };
42
+ export type ExecuteBridgeResult<T = unknown> = {
43
+ data: T;
44
+ traces: ToolTrace[];
45
+ };
46
+ /**
47
+ * Execute a bridge operation without GraphQL.
48
+ *
49
+ * Runs a bridge file's data-wiring logic standalone — no schema, no server,
50
+ * no HTTP layer required. Useful for CLI tools, background jobs, tests, and
51
+ * any context where you want Bridge's declarative data-fetching outside of
52
+ * a GraphQL server.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { parseBridge, executeBridge } from "@stackables/bridge";
57
+ * import { readFileSync } from "node:fs";
58
+ *
59
+ * const document = parseBridge(readFileSync("my.bridge", "utf8"));
60
+ * const { data } = await executeBridge({
61
+ * document,
62
+ * operation: "Query.myField",
63
+ * input: { city: "Berlin" },
64
+ * });
65
+ * console.log(data);
66
+ * ```
67
+ */
68
+ export declare function executeBridge<T = unknown>(options: ExecuteBridgeOptions): Promise<ExecuteBridgeResult<T>>;
69
+ //# sourceMappingURL=execute-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-bridge.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/execute-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,+EAA+E;IAC/E,QAAQ,EAAE,cAAc,CAAC;IACzB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC7C,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,CAAC,GAAG,OAAO,EAC7C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAyCjC"}
@@ -0,0 +1,52 @@
1
+ import { ExecutionTree, TraceCollector } from "./ExecutionTree.js";
2
+ import { SELF_MODULE } from "./types.js";
3
+ import { std as bundledStd, STD_VERSION as BUNDLED_STD_VERSION, } from "@stackables/bridge-stdlib";
4
+ import { resolveStd, checkHandleVersions } from "./version-check.js";
5
+ /**
6
+ * Execute a bridge operation without GraphQL.
7
+ *
8
+ * Runs a bridge file's data-wiring logic standalone — no schema, no server,
9
+ * no HTTP layer required. Useful for CLI tools, background jobs, tests, and
10
+ * any context where you want Bridge's declarative data-fetching outside of
11
+ * a GraphQL server.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { parseBridge, executeBridge } from "@stackables/bridge";
16
+ * import { readFileSync } from "node:fs";
17
+ *
18
+ * const document = parseBridge(readFileSync("my.bridge", "utf8"));
19
+ * const { data } = await executeBridge({
20
+ * document,
21
+ * operation: "Query.myField",
22
+ * input: { city: "Berlin" },
23
+ * });
24
+ * console.log(data);
25
+ * ```
26
+ */
27
+ export async function executeBridge(options) {
28
+ const { document: doc, operation, input = {}, context = {} } = options;
29
+ const parts = operation.split(".");
30
+ if (parts.length !== 2 || !parts[0] || !parts[1]) {
31
+ throw new Error(`Invalid operation "${operation}" — expected "Type.field" (e.g. "Query.myField")`);
32
+ }
33
+ const [type, field] = parts;
34
+ const trunk = { module: SELF_MODULE, type, field };
35
+ const userTools = options.tools ?? {};
36
+ // Resolve which std to use: bundled, or a versioned namespace from tools
37
+ const { namespace: activeStd, version: activeStdVersion } = resolveStd(doc.version, bundledStd, BUNDLED_STD_VERSION, userTools);
38
+ const allTools = { std: activeStd, ...userTools };
39
+ // Verify all @version-tagged handles can be satisfied
40
+ checkHandleVersions(doc.instructions, allTools, activeStdVersion);
41
+ const tree = new ExecutionTree(trunk, doc, allTools, context);
42
+ if (options.logger)
43
+ tree.logger = options.logger;
44
+ if (options.signal)
45
+ tree.signal = options.signal;
46
+ const traceLevel = options.trace ?? "off";
47
+ if (traceLevel !== "off") {
48
+ tree.tracer = new TraceCollector(traceLevel);
49
+ }
50
+ const data = await tree.run(input);
51
+ return { data: data, traces: tree.getTraces() };
52
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @stackables/bridge-core — The Bridge runtime engine.
3
+ *
4
+ * Contains the execution engine, type system, internal tools (math, logic,
5
+ * string concat), and utilities. Given pre-parsed `Instruction[]` (JSON AST),
6
+ * you can execute a bridge without pulling in the parser (Chevrotain) or
7
+ * GraphQL dependencies.
8
+ */
9
+ export { executeBridge } from "./execute-bridge.ts";
10
+ export type { ExecuteBridgeOptions, ExecuteBridgeResult, } from "./execute-bridge.ts";
11
+ export { checkStdVersion, checkHandleVersions, collectVersionedHandles, getBridgeVersion, hasVersionedToolFn, resolveStd, } from "./version-check.ts";
12
+ export { mergeBridgeDocuments } from "./merge-documents.ts";
13
+ export { ExecutionTree, TraceCollector, BridgeAbortError, BridgePanicError, MAX_EXECUTION_DEPTH, } from "./ExecutionTree.ts";
14
+ export type { Logger, ToolTrace, TraceLevel } from "./ExecutionTree.ts";
15
+ export { SELF_MODULE } from "./types.ts";
16
+ export type { Bridge, BridgeDocument, CacheStore, ConstDef, ControlFlowInstruction, DefineDef, HandleBinding, Instruction, NodeRef, ToolCallFn, ToolContext, ToolDef, ToolDep, ToolMap, ToolWire, VersionDecl, Wire, } from "./types.ts";
17
+ export { parsePath } from "./utils.ts";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI5D,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIxE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EACV,MAAM,EACN,cAAc,EACd,UAAU,EACV,QAAQ,EACR,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,WAAW,EACX,IAAI,GACL,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @stackables/bridge-core — The Bridge runtime engine.
3
+ *
4
+ * Contains the execution engine, type system, internal tools (math, logic,
5
+ * string concat), and utilities. Given pre-parsed `Instruction[]` (JSON AST),
6
+ * you can execute a bridge without pulling in the parser (Chevrotain) or
7
+ * GraphQL dependencies.
8
+ */
9
+ // ── Runtime engine ──────────────────────────────────────────────────────────
10
+ export { executeBridge } from "./execute-bridge.js";
11
+ // ── Version check ───────────────────────────────────────────────────────────
12
+ export { checkStdVersion, checkHandleVersions, collectVersionedHandles, getBridgeVersion, hasVersionedToolFn, resolveStd, } from "./version-check.js";
13
+ // ── Document utilities ──────────────────────────────────────────────────────
14
+ export { mergeBridgeDocuments } from "./merge-documents.js";
15
+ // ── Execution tree (advanced) ───────────────────────────────────────────────
16
+ export { ExecutionTree, TraceCollector, BridgeAbortError, BridgePanicError, MAX_EXECUTION_DEPTH, } from "./ExecutionTree.js";
17
+ // ── Types ───────────────────────────────────────────────────────────────────
18
+ export { SELF_MODULE } from "./types.js";
19
+ // ── Utilities ───────────────────────────────────────────────────────────────
20
+ export { parsePath } from "./utils.js";
@@ -0,0 +1,25 @@
1
+ import type { BridgeDocument } from "./types.ts";
2
+ /**
3
+ * Merge multiple `BridgeDocument`s into one.
4
+ *
5
+ * Instructions are concatenated in order. For the version field, the
6
+ * **highest** declared version wins — this preserves the strictest
7
+ * compatibility requirement across all source documents. Documents
8
+ * without a version are silently skipped during version resolution.
9
+ *
10
+ * Top-level names (bridges, tools, constants, defines) must be globally
11
+ * unique across all merged documents. Duplicates cause an immediate error
12
+ * rather than silently shadowing one another.
13
+ *
14
+ * @throws Error when documents declare different **major** versions
15
+ * (e.g. merging a `1.x` and `2.x` document is not allowed).
16
+ * @throws Error when documents define duplicate top-level names.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const merged = mergeBridgeDocuments(weatherDoc, quotesDoc, authDoc);
21
+ * const schema = bridgeTransform(baseSchema, merged, { tools });
22
+ * ```
23
+ */
24
+ export declare function mergeBridgeDocuments(...docs: BridgeDocument[]): BridgeDocument;
25
+ //# sourceMappingURL=merge-documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-documents.d.ts","sourceRoot":"","sources":["../../../../bridge-core/src/merge-documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,YAAY,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,IAAI,EAAE,cAAc,EAAE,GACxB,cAAc,CA8BhB"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Merge multiple `BridgeDocument`s into one.
3
+ *
4
+ * Instructions are concatenated in order. For the version field, the
5
+ * **highest** declared version wins — this preserves the strictest
6
+ * compatibility requirement across all source documents. Documents
7
+ * without a version are silently skipped during version resolution.
8
+ *
9
+ * Top-level names (bridges, tools, constants, defines) must be globally
10
+ * unique across all merged documents. Duplicates cause an immediate error
11
+ * rather than silently shadowing one another.
12
+ *
13
+ * @throws Error when documents declare different **major** versions
14
+ * (e.g. merging a `1.x` and `2.x` document is not allowed).
15
+ * @throws Error when documents define duplicate top-level names.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const merged = mergeBridgeDocuments(weatherDoc, quotesDoc, authDoc);
20
+ * const schema = bridgeTransform(baseSchema, merged, { tools });
21
+ * ```
22
+ */
23
+ export function mergeBridgeDocuments(...docs) {
24
+ if (docs.length === 0) {
25
+ return { instructions: [] };
26
+ }
27
+ if (docs.length === 1) {
28
+ return docs[0];
29
+ }
30
+ const version = resolveVersion(docs);
31
+ const instructions = [];
32
+ // Track global namespaces to prevent collisions across merged files
33
+ const seenDefs = new Set();
34
+ for (const doc of docs) {
35
+ for (const inst of doc.instructions) {
36
+ const key = instructionKey(inst);
37
+ if (key) {
38
+ if (seenDefs.has(key)) {
39
+ throw new Error(`Merge conflict: duplicate ${key.replace(":", " '")}' across bridge documents.`);
40
+ }
41
+ seenDefs.add(key);
42
+ }
43
+ instructions.push(inst);
44
+ }
45
+ }
46
+ return { version, instructions };
47
+ }
48
+ // ── Internal ────────────────────────────────────────────────────────────────
49
+ /** Unique key for a top-level instruction, used for collision detection. */
50
+ function instructionKey(inst) {
51
+ switch (inst.kind) {
52
+ case "const":
53
+ return `const:${inst.name}`;
54
+ case "tool":
55
+ return `tool:${inst.name}`;
56
+ case "define":
57
+ return `define:${inst.name}`;
58
+ case "bridge":
59
+ return `bridge:${inst.type}.${inst.field}`;
60
+ }
61
+ }
62
+ /**
63
+ * Pick the highest declared version, ensuring all documents share the same
64
+ * major. Returns `undefined` when no document declares a version.
65
+ */
66
+ function resolveVersion(docs) {
67
+ let best;
68
+ let bestMajor = -1;
69
+ let bestMinor = -1;
70
+ let bestPatch = -1;
71
+ for (const doc of docs) {
72
+ if (!doc.version)
73
+ continue;
74
+ const parts = doc.version.split(".").map(Number);
75
+ const [major = 0, minor = 0, patch = 0] = parts;
76
+ if (best !== undefined && major !== bestMajor) {
77
+ throw new Error(`Cannot merge bridge documents with different major versions: ` +
78
+ `${best} vs ${doc.version}. ` +
79
+ `Split them into separate bridgeTransform calls instead.`);
80
+ }
81
+ if (major > bestMajor ||
82
+ (major === bestMajor && minor > bestMinor) ||
83
+ (major === bestMajor && minor === bestMinor && patch > bestPatch)) {
84
+ best = doc.version;
85
+ bestMajor = major;
86
+ bestMinor = minor;
87
+ bestPatch = patch;
88
+ }
89
+ }
90
+ return best;
91
+ }
@@ -0,0 +1,2 @@
1
+ export * as internal from "./internal.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../bridge-core/src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export * as internal from "./internal.js";
@@ -0,0 +1,71 @@
1
+ /** Add two numbers. Returns `a + b`. */
2
+ export declare function add(opts: {
3
+ a: number;
4
+ b: number;
5
+ }): number;
6
+ /** Subtract two numbers. Returns `a - b`. */
7
+ export declare function subtract(opts: {
8
+ a: number;
9
+ b: number;
10
+ }): number;
11
+ /** Multiply two numbers. Returns `a * b`. */
12
+ export declare function multiply(opts: {
13
+ a: number;
14
+ b: number;
15
+ }): number;
16
+ /** Divide two numbers. Returns `a / b`. */
17
+ export declare function divide(opts: {
18
+ a: number;
19
+ b: number;
20
+ }): number;
21
+ /** Strict equality. Returns `true` if `a === b`, `false` otherwise. */
22
+ export declare function eq(opts: {
23
+ a: any;
24
+ b: any;
25
+ }): boolean;
26
+ /** Strict inequality. Returns `true` if `a !== b`, `false` otherwise. */
27
+ export declare function neq(opts: {
28
+ a: any;
29
+ b: any;
30
+ }): boolean;
31
+ /** Greater than. Returns `true` if `a > b`, `false` otherwise. */
32
+ export declare function gt(opts: {
33
+ a: number;
34
+ b: number;
35
+ }): boolean;
36
+ /** Greater than or equal. Returns `true` if `a >= b`, `false` otherwise. */
37
+ export declare function gte(opts: {
38
+ a: number;
39
+ b: number;
40
+ }): boolean;
41
+ /** Less than. Returns `true` if `a < b`, `false` otherwise. */
42
+ export declare function lt(opts: {
43
+ a: number;
44
+ b: number;
45
+ }): boolean;
46
+ /** Less than or equal. Returns `true` if `a <= b`, `false` otherwise. */
47
+ export declare function lte(opts: {
48
+ a: number;
49
+ b: number;
50
+ }): boolean;
51
+ /** Logical NOT. Returns `true` if `a` is falsy. */
52
+ export declare function not(opts: {
53
+ a: any;
54
+ }): boolean;
55
+ /** Logical AND. Returns `true` if both `a` and `b` are truthy. */
56
+ export declare function and(opts: {
57
+ a: any;
58
+ b: any;
59
+ }): boolean;
60
+ /** Logical OR. Returns `true` if either `a` or `b` is truthy. */
61
+ export declare function or(opts: {
62
+ a: any;
63
+ b: any;
64
+ }): boolean;
65
+ /** String concatenation. Joins all parts into a single string. */
66
+ export declare function concat(opts: {
67
+ parts: unknown[];
68
+ }): {
69
+ value: string;
70
+ };
71
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../bridge-core/src/tools/internal.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE1D;AACD,6CAA6C;AAC7C,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE/D;AACD,6CAA6C;AAC7C,wBAAgB,QAAQ,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE/D;AACD,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE7D;AACD,uEAAuE;AACvE,wBAAgB,EAAE,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAEpD;AACD,yEAAyE;AACzE,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAErD;AACD,kEAAkE;AAClE,wBAAgB,EAAE,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE1D;AACD,4EAA4E;AAC5E,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE3D;AACD,+DAA+D;AAC/D,wBAAgB,EAAE,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE1D;AACD,yEAAyE;AACzE,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAE3D;AACD,mDAAmD;AACnD,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAE7C;AACD,kEAAkE;AAClE,wBAAgB,GAAG,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAErD;AACD,iEAAiE;AACjE,wBAAgB,EAAE,CAAC,IAAI,EAAE;IAAE,CAAC,EAAE,GAAG,CAAC;IAAC,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAEpD;AACD,kEAAkE;AAClE,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAKpE"}
@@ -0,0 +1,59 @@
1
+ /** Add two numbers. Returns `a + b`. */
2
+ export function add(opts) {
3
+ return Number(opts.a) + Number(opts.b);
4
+ }
5
+ /** Subtract two numbers. Returns `a - b`. */
6
+ export function subtract(opts) {
7
+ return Number(opts.a) - Number(opts.b);
8
+ }
9
+ /** Multiply two numbers. Returns `a * b`. */
10
+ export function multiply(opts) {
11
+ return Number(opts.a) * Number(opts.b);
12
+ }
13
+ /** Divide two numbers. Returns `a / b`. */
14
+ export function divide(opts) {
15
+ return Number(opts.a) / Number(opts.b);
16
+ }
17
+ /** Strict equality. Returns `true` if `a === b`, `false` otherwise. */
18
+ export function eq(opts) {
19
+ return opts.a === opts.b;
20
+ }
21
+ /** Strict inequality. Returns `true` if `a !== b`, `false` otherwise. */
22
+ export function neq(opts) {
23
+ return opts.a !== opts.b;
24
+ }
25
+ /** Greater than. Returns `true` if `a > b`, `false` otherwise. */
26
+ export function gt(opts) {
27
+ return Number(opts.a) > Number(opts.b);
28
+ }
29
+ /** Greater than or equal. Returns `true` if `a >= b`, `false` otherwise. */
30
+ export function gte(opts) {
31
+ return Number(opts.a) >= Number(opts.b);
32
+ }
33
+ /** Less than. Returns `true` if `a < b`, `false` otherwise. */
34
+ export function lt(opts) {
35
+ return Number(opts.a) < Number(opts.b);
36
+ }
37
+ /** Less than or equal. Returns `true` if `a <= b`, `false` otherwise. */
38
+ export function lte(opts) {
39
+ return Number(opts.a) <= Number(opts.b);
40
+ }
41
+ /** Logical NOT. Returns `true` if `a` is falsy. */
42
+ export function not(opts) {
43
+ return !opts.a;
44
+ }
45
+ /** Logical AND. Returns `true` if both `a` and `b` are truthy. */
46
+ export function and(opts) {
47
+ return Boolean(opts.a) && Boolean(opts.b);
48
+ }
49
+ /** Logical OR. Returns `true` if either `a` or `b` is truthy. */
50
+ export function or(opts) {
51
+ return Boolean(opts.a) || Boolean(opts.b);
52
+ }
53
+ /** String concatenation. Joins all parts into a single string. */
54
+ export function concat(opts) {
55
+ const result = (opts.parts ?? [])
56
+ .map((v) => (v == null ? "" : String(v)))
57
+ .join("");
58
+ return { value: result };
59
+ }