Skip to content

Commit 4a6d063

Browse files
committed
Bind GraphService to Wails frontend
Register the resource GraphService as a Wails service, exposing GetRelated, GetRelationshipChain, and GetDependencyTree to the UI.
1 parent dd6cd05 commit 4a6d063

5 files changed

Lines changed: 231 additions & 0 deletions

File tree

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func main() {
155155

156156
// Setup the plugin systems
157157
resourceController := resource.NewController(log, settingsProvider, stateDir.PluginStore)
158+
graphService := resource.NewGraphService(resourceController.Graph())
158159

159160
settingsController := settings.NewController(log, settingsProvider, settingsStore)
160161

@@ -256,6 +257,7 @@ func main() {
256257
services := []application.Service{
257258
// 1. Controllers — need ctx before plugin loading
258259
application.NewService(&resource.ServiceWrapper{Ctrl: resourceController}),
260+
application.NewService(graphService),
259261
application.NewService(&settings.ServiceWrapper{Ctrl: settingsController}),
260262
application.NewService(&exec.ServiceWrapper{Ctrl: execController}),
261263
application.NewService(&networker.ServiceWrapper{Ctrl: networkerController}),
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
2+
// This file is automatically generated. DO NOT EDIT
3+
4+
export {
5+
DependencyNode,
6+
DependencyTree,
7+
GraphEdge,
8+
GraphNode
9+
} from "./models.js";
10+
11+
export type {
12+
RelationshipType
13+
} from "./models.js";
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
2+
// This file is automatically generated. DO NOT EDIT
3+
4+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5+
// @ts-ignore: Unused imports
6+
import { Create as $Create } from "@wailsio/runtime";
7+
8+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
9+
// @ts-ignore: Unused imports
10+
import * as resource$0 from "../../../../../../plugin-sdk/pkg/v1/resource/models.js";
11+
12+
export class DependencyNode {
13+
"edge": GraphEdge;
14+
"children": DependencyNode[];
15+
16+
/** Creates a new DependencyNode instance. */
17+
constructor($$source: Partial<DependencyNode> = {}) {
18+
if (!("edge" in $$source)) {
19+
this["edge"] = (new GraphEdge());
20+
}
21+
if (!("children" in $$source)) {
22+
this["children"] = [];
23+
}
24+
25+
Object.assign(this, $$source);
26+
}
27+
28+
/**
29+
* Creates a new DependencyNode instance from a string or object.
30+
*/
31+
static createFrom($$source: any = {}): DependencyNode {
32+
const $$createField0_0 = $$createType0;
33+
const $$createField1_0 = $$createType2;
34+
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
35+
if ("edge" in $$parsedSource) {
36+
$$parsedSource["edge"] = $$createField0_0($$parsedSource["edge"]);
37+
}
38+
if ("children" in $$parsedSource) {
39+
$$parsedSource["children"] = $$createField1_0($$parsedSource["children"]);
40+
}
41+
return new DependencyNode($$parsedSource as Partial<DependencyNode>);
42+
}
43+
}
44+
45+
export class DependencyTree {
46+
"root": GraphNode;
47+
"children": DependencyNode[];
48+
49+
/** Creates a new DependencyTree instance. */
50+
constructor($$source: Partial<DependencyTree> = {}) {
51+
if (!("root" in $$source)) {
52+
this["root"] = (new GraphNode());
53+
}
54+
if (!("children" in $$source)) {
55+
this["children"] = [];
56+
}
57+
58+
Object.assign(this, $$source);
59+
}
60+
61+
/**
62+
* Creates a new DependencyTree instance from a string or object.
63+
*/
64+
static createFrom($$source: any = {}): DependencyTree {
65+
const $$createField0_0 = $$createType3;
66+
const $$createField1_0 = $$createType2;
67+
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
68+
if ("root" in $$parsedSource) {
69+
$$parsedSource["root"] = $$createField0_0($$parsedSource["root"]);
70+
}
71+
if ("children" in $$parsedSource) {
72+
$$parsedSource["children"] = $$createField1_0($$parsedSource["children"]);
73+
}
74+
return new DependencyTree($$parsedSource as Partial<DependencyTree>);
75+
}
76+
}
77+
78+
export class GraphEdge {
79+
"source": GraphNode;
80+
"target": GraphNode;
81+
"type": RelationshipType;
82+
"label": string;
83+
84+
/** Creates a new GraphEdge instance. */
85+
constructor($$source: Partial<GraphEdge> = {}) {
86+
if (!("source" in $$source)) {
87+
this["source"] = (new GraphNode());
88+
}
89+
if (!("target" in $$source)) {
90+
this["target"] = (new GraphNode());
91+
}
92+
if (!("type" in $$source)) {
93+
this["type"] = resource$0.RelationshipType.$zero;
94+
}
95+
if (!("label" in $$source)) {
96+
this["label"] = "";
97+
}
98+
99+
Object.assign(this, $$source);
100+
}
101+
102+
/**
103+
* Creates a new GraphEdge instance from a string or object.
104+
*/
105+
static createFrom($$source: any = {}): GraphEdge {
106+
const $$createField0_0 = $$createType3;
107+
const $$createField1_0 = $$createType3;
108+
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
109+
if ("source" in $$parsedSource) {
110+
$$parsedSource["source"] = $$createField0_0($$parsedSource["source"]);
111+
}
112+
if ("target" in $$parsedSource) {
113+
$$parsedSource["target"] = $$createField1_0($$parsedSource["target"]);
114+
}
115+
return new GraphEdge($$parsedSource as Partial<GraphEdge>);
116+
}
117+
}
118+
119+
/**
120+
* GraphNode identifies a specific resource instance in the graph.
121+
*/
122+
export class GraphNode {
123+
"pluginId": string;
124+
"connectionId": string;
125+
"resourceKey": string;
126+
"id": string;
127+
"namespace"?: string;
128+
129+
/** Creates a new GraphNode instance. */
130+
constructor($$source: Partial<GraphNode> = {}) {
131+
if (!("pluginId" in $$source)) {
132+
this["pluginId"] = "";
133+
}
134+
if (!("connectionId" in $$source)) {
135+
this["connectionId"] = "";
136+
}
137+
if (!("resourceKey" in $$source)) {
138+
this["resourceKey"] = "";
139+
}
140+
if (!("id" in $$source)) {
141+
this["id"] = "";
142+
}
143+
144+
Object.assign(this, $$source);
145+
}
146+
147+
/**
148+
* Creates a new GraphNode instance from a string or object.
149+
*/
150+
static createFrom($$source: any = {}): GraphNode {
151+
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
152+
return new GraphNode($$parsedSource as Partial<GraphNode>);
153+
}
154+
}
155+
156+
/**
157+
* RelationshipType re-exports from SDK for convenience.
158+
*/
159+
export type RelationshipType = resource$0.RelationshipType;
160+
161+
// Private type creation functions
162+
const $$createType0 = GraphEdge.createFrom;
163+
const $$createType1 = DependencyNode.createFrom;
164+
const $$createType2 = $Create.Array($$createType1);
165+
const $$createType3 = GraphNode.createFrom;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
2+
// This file is automatically generated. DO NOT EDIT
3+
4+
/**
5+
* GraphService exposes graph query methods to the frontend via Wails binding.
6+
* @module
7+
*/
8+
9+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
10+
// @ts-ignore: Unused imports
11+
import { Call as $Call, CancellablePromise as $CancellablePromise, Create as $Create } from "@wailsio/runtime";
12+
13+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
14+
// @ts-ignore: Unused imports
15+
import * as graph$0 from "./graph/models.js";
16+
17+
/**
18+
* GetDependencyTree follows all outgoing edges recursively.
19+
*/
20+
export function GetDependencyTree(pluginID: string, connectionID: string, resourceKey: string, $namespace: string, id: string, maxDepth: number): $CancellablePromise<graph$0.DependencyTree | null> {
21+
return $Call.ByID(3749557463, pluginID, connectionID, resourceKey, $namespace, id, maxDepth).then(($result: any) => {
22+
return $$createType1($result);
23+
});
24+
}
25+
26+
/**
27+
* GetRelated returns edges connected to the given node.
28+
*/
29+
export function GetRelated(pluginID: string, connectionID: string, resourceKey: string, $namespace: string, id: string, direction: string, relType: string | null): $CancellablePromise<graph$0.GraphEdge[]> {
30+
return $Call.ByID(3912521777, pluginID, connectionID, resourceKey, $namespace, id, direction, relType).then(($result: any) => {
31+
return $$createType3($result);
32+
});
33+
}
34+
35+
/**
36+
* GetRelationshipChain follows edges of a specific type up to maxDepth hops.
37+
*/
38+
export function GetRelationshipChain(pluginID: string, connectionID: string, resourceKey: string, $namespace: string, id: string, relType: string, maxDepth: number): $CancellablePromise<graph$0.GraphEdge[][]> {
39+
return $Call.ByID(1916045973, pluginID, connectionID, resourceKey, $namespace, id, relType, maxDepth).then(($result: any) => {
40+
return $$createType4($result);
41+
});
42+
}
43+
44+
// Private type creation functions
45+
const $$createType0 = graph$0.DependencyTree.createFrom;
46+
const $$createType1 = $Create.Nullable($$createType0);
47+
const $$createType2 = graph$0.GraphEdge.createFrom;
48+
const $$createType3 = $Create.Array($$createType2);
49+
const $$createType4 = $Create.Array($$createType3);

packages/omniviewdev-runtime/src/bindings/github.com/omniviewdev/omniview/backend/pkg/plugin/resource/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
22
// This file is automatically generated. DO NOT EDIT
33

4+
import * as GraphService from "./graphservice.js";
45
import * as ServiceWrapper from "./servicewrapper.js";
56
export {
7+
GraphService,
68
ServiceWrapper
79
};
810

0 commit comments

Comments
 (0)