@h-rig/core 0.0.6-alpha.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/README.md +9 -0
- package/dist/src/define-config.js +24 -0
- package/dist/src/define-plugin.js +50 -0
- package/dist/src/engineReadModelReducer.js +1780 -0
- package/dist/src/index.js +2616 -0
- package/dist/src/load-config.js +49 -0
- package/dist/src/plugin-host.js +158 -0
- package/dist/src/plugin-runtime.js +1 -0
- package/dist/src/rig-init-builder.js +57 -0
- package/dist/src/rigSelectors.js +293 -0
- package/dist/src/taskGraph.js +64 -0
- package/dist/src/taskGraphCodes.js +26 -0
- package/dist/src/taskGraphLayout.js +374 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/define-config.ts
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { RigConfig } from "@rig/contracts";
|
|
5
|
+
function defineConfig(cfg) {
|
|
6
|
+
const runtimeByName = new Map;
|
|
7
|
+
const plugins = cfg.plugins ?? [];
|
|
8
|
+
for (const plugin of plugins) {
|
|
9
|
+
if (plugin?.__runtime) {
|
|
10
|
+
runtimeByName.set(plugin.name, plugin.__runtime);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const decoded = Schema.decodeUnknownSync(RigConfig)(cfg);
|
|
14
|
+
const decodedPlugins = decoded.plugins.map((p) => {
|
|
15
|
+
const runtime = runtimeByName.get(p.name);
|
|
16
|
+
if (!runtime)
|
|
17
|
+
return p;
|
|
18
|
+
return { ...p, __runtime: runtime };
|
|
19
|
+
});
|
|
20
|
+
return { ...decoded, plugins: decodedPlugins };
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
defineConfig
|
|
24
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/define-plugin.ts
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { RigPlugin } from "@rig/contracts";
|
|
5
|
+
function definePlugin(meta, runtime) {
|
|
6
|
+
const validated = Schema.decodeUnknownSync(RigPlugin)(meta);
|
|
7
|
+
if (!runtime) {
|
|
8
|
+
return validated;
|
|
9
|
+
}
|
|
10
|
+
const declaredValidators = new Map((validated.contributes?.validators ?? []).map((v) => [v.id, v]));
|
|
11
|
+
const runtimeValidators = new Map((runtime.validators ?? []).map((v) => [v.id, v]));
|
|
12
|
+
for (const v of runtimeValidators.values()) {
|
|
13
|
+
const metadata = declaredValidators.get(v.id);
|
|
14
|
+
if (!metadata) {
|
|
15
|
+
throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" has no matching metadata entry in contributes.validators`);
|
|
16
|
+
}
|
|
17
|
+
if (metadata.category !== v.category) {
|
|
18
|
+
throw new Error(`definePlugin(${validated.name}): executable validator "${v.id}" category "${v.category}" does not match metadata category "${metadata.category}"`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (runtime.validators) {
|
|
22
|
+
for (const v of declaredValidators.values()) {
|
|
23
|
+
if (!runtimeValidators.has(v.id)) {
|
|
24
|
+
throw new Error(`definePlugin(${validated.name}): validator metadata "${v.id}" has no runtime implementation`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const declaredSources = new Map((validated.contributes?.taskSources ?? []).map((s) => [s.id, s]));
|
|
29
|
+
const runtimeSources = new Map((runtime.taskSources ?? []).map((s) => [s.id, s]));
|
|
30
|
+
for (const s of runtimeSources.values()) {
|
|
31
|
+
const metadata = declaredSources.get(s.id);
|
|
32
|
+
if (!metadata) {
|
|
33
|
+
throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" has no matching metadata entry in contributes.taskSources`);
|
|
34
|
+
}
|
|
35
|
+
if (metadata.kind !== s.kind) {
|
|
36
|
+
throw new Error(`definePlugin(${validated.name}): executable task source "${s.id}" kind "${s.kind}" does not match metadata kind "${metadata.kind}"`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (runtime.taskSources) {
|
|
40
|
+
for (const s of declaredSources.values()) {
|
|
41
|
+
if (!runtimeSources.has(s.id)) {
|
|
42
|
+
throw new Error(`definePlugin(${validated.name}): task source metadata "${s.id}" has no runtime implementation`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { ...validated, __runtime: runtime };
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
definePlugin
|
|
50
|
+
};
|