@venn-lang/runtime 0.1.0
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/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/index.d.ts +453 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3314 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
- package/src/check/check-calls.ts +82 -0
- package/src/check/check-deco-body.ts +77 -0
- package/src/check/check-document.ts +106 -0
- package/src/check/check-env.ts +96 -0
- package/src/check/check-fragment-call.ts +27 -0
- package/src/check/check-imports.ts +82 -0
- package/src/check/check-interpolation.ts +58 -0
- package/src/check/check-options.ts +18 -0
- package/src/check/check-uncalled.ts +42 -0
- package/src/check/check.types.ts +30 -0
- package/src/check/index.ts +4 -0
- package/src/context/action-context.ts +20 -0
- package/src/context/index.ts +1 -0
- package/src/decorators/builtin-decorators.ts +87 -0
- package/src/decorators/create-decorator-source.ts +25 -0
- package/src/decorators/index.ts +2 -0
- package/src/emit/create-emitter.ts +16 -0
- package/src/emit/emitter.types.ts +6 -0
- package/src/emit/index.ts +3 -0
- package/src/emit/run-id.ts +11 -0
- package/src/eventsink/event-sink.port.ts +13 -0
- package/src/eventsink/event-sink.types.ts +11 -0
- package/src/eventsink/index.ts +4 -0
- package/src/eventsink/memory-sink.ts +17 -0
- package/src/eventsink/ndjson-sink.ts +14 -0
- package/src/index.ts +14 -0
- package/src/ports/create-port-resolver.ts +39 -0
- package/src/ports/index.ts +2 -0
- package/src/ports/port-resolver.types.ts +12 -0
- package/src/registry/build-registry.ts +76 -0
- package/src/registry/index.ts +2 -0
- package/src/registry/registry.types.ts +24 -0
- package/src/run/create-runner.ts +103 -0
- package/src/run/index.ts +4 -0
- package/src/run/resolve-imports.ts +166 -0
- package/src/run/runner.types.ts +67 -0
- package/src/scheduler/absorb-exit.ts +19 -0
- package/src/scheduler/aliases.ts +44 -0
- package/src/scheduler/annotations.ts +48 -0
- package/src/scheduler/base-scope.ts +25 -0
- package/src/scheduler/bind-globals.ts +55 -0
- package/src/scheduler/bind-imports.ts +130 -0
- package/src/scheduler/bind-namespaces.ts +61 -0
- package/src/scheduler/bind-prelude.ts +11 -0
- package/src/scheduler/block-plan.ts +66 -0
- package/src/scheduler/branch-engine.ts +13 -0
- package/src/scheduler/call-params.ts +140 -0
- package/src/scheduler/cleanup.types.ts +18 -0
- package/src/scheduler/collect.ts +60 -0
- package/src/scheduler/concurrency.ts +16 -0
- package/src/scheduler/create-cleanup-list.ts +17 -0
- package/src/scheduler/declared-arity.ts +13 -0
- package/src/scheduler/engine.types.ts +50 -0
- package/src/scheduler/filter.ts +5 -0
- package/src/scheduler/filter.types.ts +9 -0
- package/src/scheduler/flaky.ts +32 -0
- package/src/scheduler/flaky.types.ts +7 -0
- package/src/scheduler/index.ts +16 -0
- package/src/scheduler/invocation.ts +103 -0
- package/src/scheduler/local-call.ts +28 -0
- package/src/scheduler/node-span.ts +29 -0
- package/src/scheduler/opts-text.ts +10 -0
- package/src/scheduler/opts.ts +14 -0
- package/src/scheduler/pending.types.ts +9 -0
- package/src/scheduler/run-action.ts +163 -0
- package/src/scheduler/run-around.ts +23 -0
- package/src/scheduler/run-attempts.ts +105 -0
- package/src/scheduler/run-bindings.ts +67 -0
- package/src/scheduler/run-block.ts +65 -0
- package/src/scheduler/run-document.ts +181 -0
- package/src/scheduler/run-expect.ts +48 -0
- package/src/scheduler/run-flow.ts +69 -0
- package/src/scheduler/run-foreach.ts +148 -0
- package/src/scheduler/run-group.ts +9 -0
- package/src/scheduler/run-if.ts +21 -0
- package/src/scheduler/run-lifecycle.ts +86 -0
- package/src/scheduler/run-matcher.ts +99 -0
- package/src/scheduler/run-parallel.ts +68 -0
- package/src/scheduler/run-prologue.ts +59 -0
- package/src/scheduler/run-race.ts +20 -0
- package/src/scheduler/run-repeat.ts +54 -0
- package/src/scheduler/run-run.ts +41 -0
- package/src/scheduler/run-script.ts +48 -0
- package/src/scheduler/run-statements.ts +107 -0
- package/src/scheduler/run-step.ts +76 -0
- package/src/scheduler/run-try.ts +34 -0
- package/src/scheduler/run-while.ts +50 -0
- package/src/scheduler/script-lifecycle.ts +47 -0
- package/src/scheduler/settled.ts +20 -0
- package/src/scheduler/signals.ts +33 -0
- package/src/scheduler/target.ts +30 -0
- package/src/scheduler/unknown-option.ts +87 -0
- package/src/scope/create-scope.ts +67 -0
- package/src/scope/index.ts +2 -0
- package/src/scope/scope.types.ts +12 -0
- package/src/types/create-type-catalog.ts +70 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type FnType, prune, specToType, type Type, type TypeCatalog } from "@venn-lang/core";
|
|
2
|
+
import type { PluginDefinition } from "@venn-lang/sdk";
|
|
3
|
+
import type { TypeSpec } from "@venn-lang/types";
|
|
4
|
+
|
|
5
|
+
/** The published specs, indexed by the name a flow would write. */
|
|
6
|
+
interface Published {
|
|
7
|
+
types: Map<string, TypeSpec>;
|
|
8
|
+
signatures: Map<string, TypeSpec>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Turn what the loaded plugins publish into what the checker can ask.
|
|
13
|
+
*
|
|
14
|
+
* This is the seam the core deliberately does not cross: `@venn-lang/core` knows
|
|
15
|
+
* nothing about plugins and gets told. Names are qualified here, once: a plugin
|
|
16
|
+
* says `Request` and a flow writes `http.Request`.
|
|
17
|
+
*
|
|
18
|
+
* @param plugins The plugins loaded for this run.
|
|
19
|
+
* @returns A catalog answering a type name or an action's signature.
|
|
20
|
+
*/
|
|
21
|
+
export function createTypeCatalog(plugins: readonly PluginDefinition[]): TypeCatalog {
|
|
22
|
+
const published: Published = { types: new Map(), signatures: new Map() };
|
|
23
|
+
for (const plugin of plugins) collect(plugin, published);
|
|
24
|
+
const reader = createReader(published);
|
|
25
|
+
return {
|
|
26
|
+
typeOf: (name) => reader.read(published.types, name),
|
|
27
|
+
signatureOf: (target) => asFn(reader.read(published.signatures, target)),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function collect(plugin: PluginDefinition, into: Published): void {
|
|
32
|
+
for (const [name, spec] of Object.entries(plugin.typeDefs ?? {})) {
|
|
33
|
+
into.types.set(`${plugin.namespace}.${name}`, spec);
|
|
34
|
+
}
|
|
35
|
+
for (const action of plugin.actions ?? []) {
|
|
36
|
+
const key = `${plugin.namespace}.${action.name}`;
|
|
37
|
+
if (action.signature) into.signatures.set(key, action.signature);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Read a published spec once and keep the result.
|
|
43
|
+
*
|
|
44
|
+
* The same `http.Request` has to be the same object every time it is asked for:
|
|
45
|
+
* inference writes into what it is handed, and two copies would drift apart in
|
|
46
|
+
* the middle of a file. `open` guards a type that refers to itself, so the
|
|
47
|
+
* second visit answers "unknown" rather than recurring forever.
|
|
48
|
+
*/
|
|
49
|
+
function createReader(published: Published) {
|
|
50
|
+
const cache = new Map<string, Type>();
|
|
51
|
+
const open = new Set<string>();
|
|
52
|
+
const read = (from: Map<string, TypeSpec>, name: string): Type | undefined => {
|
|
53
|
+
const cached = cache.get(name);
|
|
54
|
+
if (cached) return cached;
|
|
55
|
+
const spec = from.get(name);
|
|
56
|
+
if (!spec || open.has(name)) return undefined;
|
|
57
|
+
open.add(name);
|
|
58
|
+
const type = specToType(spec, (ref) => read(published.types, ref));
|
|
59
|
+
open.delete(name);
|
|
60
|
+
cache.set(name, type);
|
|
61
|
+
return type;
|
|
62
|
+
};
|
|
63
|
+
return { read };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function asFn(type: Type | undefined): FnType | undefined {
|
|
67
|
+
if (!type) return undefined;
|
|
68
|
+
const pruned = prune(type);
|
|
69
|
+
return pruned.kind === "fn" ? pruned : undefined;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTypeCatalog } from "./create-type-catalog.js";
|