@ucdjs/pipelines-graph 0.0.1-beta.7 → 0.0.1-beta.8
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 +23 -3
- package/dist/index.d.mts +3 -7
- package/dist/index.mjs +15 -21
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
[![npm version][npm-version-src]][npm-version-href]
|
|
4
4
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
-
[![codecov][codecov-src]][codecov-href]
|
|
6
5
|
|
|
7
6
|
> [!IMPORTANT]
|
|
8
7
|
> This is an internal package. It may change without warning and is not subject to semantic versioning. Use at your own risk.
|
|
@@ -15,6 +14,29 @@ A collection of core pipeline functionalities for the UCD project.
|
|
|
15
14
|
npm install @ucdjs/pipelines-graph
|
|
16
15
|
```
|
|
17
16
|
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
This package keeps graph construction and graph inspection separate from pipeline definition loading and execution.
|
|
20
|
+
Use it when you already have a pipeline definition or execution graph and need a stable graph-shaped view for tooling, visualization, or debugging.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { buildDAG } from "@ucdjs/pipelines-core";
|
|
24
|
+
import { buildRouteGraph, toVisualTree } from "@ucdjs/pipelines-graph";
|
|
25
|
+
|
|
26
|
+
const dag = buildDAG(pipeline.routes);
|
|
27
|
+
const graph = buildRouteGraph(pipeline, dag);
|
|
28
|
+
|
|
29
|
+
console.log(toVisualTree(graph));
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Example output:
|
|
33
|
+
|
|
34
|
+
```txt
|
|
35
|
+
└─ route:static:emoji
|
|
36
|
+
├─ route:static:groups
|
|
37
|
+
└─ route:static:summary
|
|
38
|
+
```
|
|
39
|
+
|
|
18
40
|
## 📄 License
|
|
19
41
|
|
|
20
42
|
Published under [MIT License](./LICENSE).
|
|
@@ -23,5 +45,3 @@ Published under [MIT License](./LICENSE).
|
|
|
23
45
|
[npm-version-href]: https://npmjs.com/package/@ucdjs/pipelines-graph
|
|
24
46
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@ucdjs/pipelines-graph?style=flat&colorA=18181B&colorB=4169E1
|
|
25
47
|
[npm-downloads-href]: https://npmjs.com/package/@ucdjs/pipelines-graph
|
|
26
|
-
[codecov-src]: https://img.shields.io/codecov/c/gh/ucdjs/ucd?style=flat&colorA=18181B&colorB=4169E1
|
|
27
|
-
[codecov-href]: https://codecov.io/gh/ucdjs/ucd
|
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { DAG, FileContext, PipelineDefinition, PipelineGraph, PipelineGraphEdge } from "@ucdjs/pipelines-core";
|
|
2
2
|
|
|
3
3
|
//#region src/builder.d.ts
|
|
4
|
-
interface GraphBuilderOptions {
|
|
5
|
-
includeArtifacts?: boolean;
|
|
6
|
-
}
|
|
7
4
|
declare class PipelineGraphBuilder {
|
|
8
5
|
#private;
|
|
9
6
|
addSourceNode(version: string): string;
|
|
10
7
|
addFileNode(file: FileContext): string;
|
|
11
8
|
addRouteNode(routeId: string, version: string): string;
|
|
12
|
-
|
|
13
|
-
addOutputNode(outputIndex: number, version: string, property?: string): string;
|
|
9
|
+
addOutputNode(outputIndex: number, version: string, property?: string, outputId?: string, locator?: string): string;
|
|
14
10
|
addEdge(from: string, to: string, type: PipelineGraphEdge["type"]): void;
|
|
15
11
|
build(): PipelineGraph;
|
|
16
12
|
clear(): void;
|
|
@@ -21,7 +17,7 @@ declare function createPipelineGraphBuilder(): PipelineGraphBuilder;
|
|
|
21
17
|
/**
|
|
22
18
|
* Build a pipeline graph from a pipeline definition and its DAG.
|
|
23
19
|
* @param {PipelineDefinition} pipeline The pipeline definition to build the graph from.
|
|
24
|
-
* @param {DAG} dag The DAG representing the dependencies between routes
|
|
20
|
+
* @param {DAG} dag The DAG representing the dependencies between routes in the pipeline.
|
|
25
21
|
* @returns {PipelineGraph} The constructed pipeline graph.
|
|
26
22
|
*/
|
|
27
23
|
declare function buildRouteGraph(pipeline: PipelineDefinition, dag: DAG): PipelineGraph;
|
|
@@ -47,4 +43,4 @@ declare function find(graph: PipelineGraph, nodeId: string): PipelineGraph["node
|
|
|
47
43
|
*/
|
|
48
44
|
declare function findEdges(graph: PipelineGraph, from: string, to: string): PipelineGraph["edges"];
|
|
49
45
|
//#endregion
|
|
50
|
-
export {
|
|
46
|
+
export { PipelineGraphBuilder, buildRouteGraph, createPipelineGraphBuilder, find, findEdges, toVisualTree };
|
package/dist/index.mjs
CHANGED
|
@@ -30,22 +30,22 @@ var PipelineGraphBuilder = class {
|
|
|
30
30
|
});
|
|
31
31
|
return id;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
const id = `
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
addOutputNode(outputIndex, version, property, outputId, locator) {
|
|
34
|
+
const id = `output:${version}:${outputId || locator ? `${outputId ?? "default"}:${locator ?? "unknown"}` : `${outputIndex}`}`;
|
|
35
|
+
const existing = this.#nodes.get(id);
|
|
36
|
+
if (existing?.type === "output") this.#nodes.set(id, {
|
|
37
|
+
...existing,
|
|
38
|
+
property: existing.property ?? property,
|
|
39
|
+
outputId: existing.outputId ?? outputId,
|
|
40
|
+
locator: existing.locator ?? locator
|
|
39
41
|
});
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
addOutputNode(outputIndex, version, property) {
|
|
43
|
-
const id = `output:${version}:${outputIndex}`;
|
|
44
|
-
if (!this.#nodes.has(id)) this.#nodes.set(id, {
|
|
42
|
+
else if (!existing) this.#nodes.set(id, {
|
|
45
43
|
id,
|
|
46
44
|
type: "output",
|
|
47
45
|
outputIndex,
|
|
48
|
-
property
|
|
46
|
+
property,
|
|
47
|
+
outputId,
|
|
48
|
+
locator
|
|
49
49
|
});
|
|
50
50
|
return id;
|
|
51
51
|
}
|
|
@@ -61,7 +61,7 @@ var PipelineGraphBuilder = class {
|
|
|
61
61
|
}
|
|
62
62
|
build() {
|
|
63
63
|
return {
|
|
64
|
-
nodes:
|
|
64
|
+
nodes: [...this.#nodes.values()],
|
|
65
65
|
edges: [...this.#edges]
|
|
66
66
|
};
|
|
67
67
|
}
|
|
@@ -74,13 +74,12 @@ var PipelineGraphBuilder = class {
|
|
|
74
74
|
function createPipelineGraphBuilder() {
|
|
75
75
|
return new PipelineGraphBuilder();
|
|
76
76
|
}
|
|
77
|
-
|
|
78
77
|
//#endregion
|
|
79
78
|
//#region src/graph-utils.ts
|
|
80
79
|
/**
|
|
81
80
|
* Build a pipeline graph from a pipeline definition and its DAG.
|
|
82
81
|
* @param {PipelineDefinition} pipeline The pipeline definition to build the graph from.
|
|
83
|
-
* @param {DAG} dag The DAG representing the dependencies between routes
|
|
82
|
+
* @param {DAG} dag The DAG representing the dependencies between routes in the pipeline.
|
|
84
83
|
* @returns {PipelineGraph} The constructed pipeline graph.
|
|
85
84
|
*/
|
|
86
85
|
function buildRouteGraph(pipeline, dag) {
|
|
@@ -93,10 +92,6 @@ function buildRouteGraph(pipeline, dag) {
|
|
|
93
92
|
const depNodeId = builder.addRouteNode(depId, "static");
|
|
94
93
|
builder.addEdge(depNodeId, currentRouteId, "provides");
|
|
95
94
|
}
|
|
96
|
-
for (const artifactId of routeNode.emittedArtifacts) {
|
|
97
|
-
const artifactNodeId = builder.addArtifactNode(artifactId, "static");
|
|
98
|
-
builder.addEdge(currentRouteId, artifactNodeId, "resolved");
|
|
99
|
-
}
|
|
100
95
|
}
|
|
101
96
|
return builder.build();
|
|
102
97
|
}
|
|
@@ -164,6 +159,5 @@ function find(graph, nodeId) {
|
|
|
164
159
|
function findEdges(graph, from, to) {
|
|
165
160
|
return graph.edges.filter((edge) => edge.from === from && edge.to === to);
|
|
166
161
|
}
|
|
167
|
-
|
|
168
162
|
//#endregion
|
|
169
|
-
export { PipelineGraphBuilder, buildRouteGraph, createPipelineGraphBuilder, find, findEdges, toVisualTree };
|
|
163
|
+
export { PipelineGraphBuilder, buildRouteGraph, createPipelineGraphBuilder, find, findEdges, toVisualTree };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ucdjs/pipelines-graph",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Lucas Nørgård",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"node": ">=24.13"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ucdjs/pipelines-core": "0.0.1-beta.
|
|
32
|
+
"@ucdjs/pipelines-core": "0.0.1-beta.8"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@luxass/eslint-config": "7.
|
|
36
|
-
"eslint": "10.0
|
|
37
|
-
"publint": "0.3.
|
|
38
|
-
"tsdown": "0.
|
|
39
|
-
"typescript": "
|
|
35
|
+
"@luxass/eslint-config": "7.4.1",
|
|
36
|
+
"eslint": "10.1.0",
|
|
37
|
+
"publint": "0.3.18",
|
|
38
|
+
"tsdown": "0.21.4",
|
|
39
|
+
"typescript": "6.0.2",
|
|
40
40
|
"@ucdjs-tooling/tsdown-config": "1.0.0",
|
|
41
41
|
"@ucdjs-tooling/tsconfig": "1.0.0"
|
|
42
42
|
},
|