Skip to content

Commit 36e5459

Browse files
committed
API specification for graph exploration.
1 parent d367c22 commit 36e5459

4 files changed

Lines changed: 352 additions & 1 deletion

File tree

packages/marble-api/openapis/marblecore-api.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ paths:
471471
/analytics/available-filters:
472472
$ref: ./marblecore-api/analytics.yml#/~1analytics~1available-filters
473473

474-
# SCORING
474+
# SCORING
475475

476476
/scoring/settings:
477477
$ref: ./marblecore-api/scoring.yml#/~1scoring~1settings
@@ -492,6 +492,15 @@ paths:
492492
/scoring/distribution/{recordType}:
493493
$ref: ./marblecore-api/scoring.yml#/~1scoring~1distribution~1{recordType}
494494

495+
# GRAPH EXPLORATION
496+
497+
/graph/relations:
498+
$ref: ./marblecore-api/graph.yml#/~1graph~1relations
499+
/graph/relations/{relationId}:
500+
$ref: ./marblecore-api/graph.yml#/~1graph~1relations~1{relationId}
501+
/graph/{recordType}/{recordId}:
502+
$ref: ./marblecore-api/graph.yml#/~1graph~1{recordType}~1{recordId}
503+
495504
components:
496505
securitySchemes:
497506
$ref: marblecore-api/_common.yml#/securitySchemes

packages/marble-api/openapis/marblecore-api/_schemas.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,3 +647,18 @@ UpdateScoringRuleset:
647647
$ref: scoring.yml#/components/schemas/UpdateScoringRuleset
648648
ScoringScore:
649649
$ref: scoring.yml#/components/schemas/ScoringScore
650+
651+
# GRAPH EXPLORATION
652+
653+
GraphRelation:
654+
$ref: graph.yml#/components/schemas/GraphRelation
655+
CreateGraphRelation:
656+
$ref: graph.yml#/components/schemas/CreateGraphRelation
657+
Graph:
658+
$ref: graph.yml#/components/schemas/Graph
659+
GraphNodeRef:
660+
$ref: graph.yml#/components/schemas/GraphNodeRef
661+
GraphNode:
662+
$ref: graph.yml#/components/schemas/GraphNode
663+
GraphEdge:
664+
$ref: graph.yml#/components/schemas/GraphEdge
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/graph/relations:
2+
get:
3+
tags:
4+
- Graph exploration
5+
summary: List same-field relations configurations
6+
operationId: listGraphRelations
7+
security:
8+
- bearerAuth: []
9+
responses:
10+
"200":
11+
description: List of same-field relation configurations
12+
content:
13+
application/json:
14+
schema:
15+
$ref: "#/components/schemas/GraphRelation"
16+
"401":
17+
$ref: "components.yml#/responses/401"
18+
"403":
19+
$ref: "components.yml#/responses/403"
20+
21+
post:
22+
tags:
23+
- Graph exploration
24+
summary: Create a same-field relation configuration
25+
operationId: createGraphRelation
26+
security:
27+
- bearerAuth: []
28+
requestBody:
29+
description: Graph relation
30+
content:
31+
application/json:
32+
schema:
33+
$ref: '#/components/schemas/CreateGraphRelation'
34+
required: true
35+
responses:
36+
"201":
37+
description: Configuration created
38+
content:
39+
application/json:
40+
schema:
41+
$ref: "#/components/schemas/GraphRelation"
42+
"401":
43+
$ref: "components.yml#/responses/401"
44+
"403":
45+
$ref: "components.yml#/responses/403"
46+
47+
/graph/relations/{relationId}:
48+
delete:
49+
tags:
50+
- Graph exploration
51+
summary: Delete a same-field relation configuration
52+
operationId: deleteGraphRelation
53+
security:
54+
- bearerAuth: []
55+
parameters:
56+
- name: relationId
57+
description: ID of the configuration
58+
in: path
59+
required: true
60+
schema:
61+
type: string
62+
format: uuid
63+
responses:
64+
"204":
65+
description: Configuration was deleted
66+
"401":
67+
$ref: "components.yml#/responses/401"
68+
"403":
69+
$ref: "components.yml#/responses/403"
70+
71+
/graph/{recordType}/{recordId}:
72+
get:
73+
tags:
74+
- Graph exploration
75+
summary: Generate the relationship graph from a starting record
76+
operationId: generateRelationshipGraph
77+
security:
78+
- bearerAuth: []
79+
parameters:
80+
- name: recordType
81+
description: Record table name
82+
in: path
83+
required: true
84+
schema:
85+
type: string
86+
- name: recordId
87+
description: Record ID
88+
in: path
89+
required: true
90+
schema:
91+
type: string
92+
responses:
93+
"200":
94+
description: Relationship graph
95+
content:
96+
application/json:
97+
schema:
98+
$ref: "#/components/schemas/Graph"
99+
"401":
100+
$ref: "components.yml#/responses/401"
101+
"403":
102+
$ref: "components.yml#/responses/403"
103+
104+
components:
105+
schemas:
106+
GraphRelation:
107+
type: object
108+
required:
109+
- id
110+
- label
111+
- left_type
112+
- left_field
113+
- right_type
114+
- right_field
115+
- created_at
116+
properties:
117+
id:
118+
type: string
119+
format: uuid
120+
label:
121+
type: string
122+
left_type:
123+
type: string
124+
left_field:
125+
type: string
126+
right_type:
127+
type: string
128+
right_field:
129+
type: string
130+
created_at:
131+
type: string
132+
format: date-time
133+
134+
CreateGraphRelation:
135+
type: object
136+
required:
137+
- label
138+
- left_type
139+
- left_field
140+
- right_typeÀ
141+
- right_field
142+
properties:
143+
label:
144+
type: string
145+
left_type:
146+
type: string
147+
left_field:
148+
type: string
149+
right_type:
150+
type: string
151+
right_field:
152+
type: string
153+
154+
Graph:
155+
type: object
156+
required:
157+
- start
158+
- nodes
159+
- edges
160+
properties:
161+
start:
162+
$ref: "#/components/schemas/GraphNodeRef"
163+
nodes:
164+
type: array
165+
items:
166+
$ref: "#/components/schemas/GraphNode"
167+
edges:
168+
type: array
169+
items:
170+
$ref: "#/components/schemas/GraphEdge"
171+
172+
GraphNodeRef:
173+
type: object
174+
required: [type, id]
175+
properties:
176+
type:
177+
type: string
178+
id:
179+
type: string
180+
181+
GraphNode:
182+
allOf:
183+
- $ref: "#/components/schemas/GraphNodeRef"
184+
- type: object
185+
properties:
186+
type:
187+
type: string
188+
id:
189+
type: string
190+
connector:
191+
type: boolean
192+
connector_kind:
193+
type: string
194+
enum: [match, link]
195+
hypernode_count:
196+
type: integer
197+
198+
GraphEdge:
199+
type: object
200+
required:
201+
- kind
202+
- label
203+
- from
204+
- to
205+
properties:
206+
kind:
207+
type: string
208+
label:
209+
type: string
210+
from:
211+
$ref: "#/components/schemas/GraphNodeRef"
212+
to:
213+
$ref: "#/components/schemas/GraphNodeRef"
214+
field:
215+
type: string
216+
value:
217+
type: string

packages/marble-api/src/generated/marblecore-api.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,46 @@ export type ScoringScore = {
21432143
ruleset_id?: string;
21442144
evaluations?: NodeEvaluationDto[];
21452145
};
2146+
export type GraphRelation = {
2147+
id: string;
2148+
label: string;
2149+
left_type: string;
2150+
left_field: string;
2151+
right_type: string;
2152+
right_field: string;
2153+
created_at: string;
2154+
};
2155+
export type CreateGraphRelation = {
2156+
label: string;
2157+
left_type: string;
2158+
left_field: string;
2159+
right_type?: string;
2160+
right_field: string;
2161+
};
2162+
export type GraphNodeRef = {
2163+
"type": string;
2164+
id: string;
2165+
};
2166+
export type GraphNode = GraphNodeRef & {
2167+
"type"?: string;
2168+
id?: string;
2169+
connector?: boolean;
2170+
connector_kind?: "match" | "link";
2171+
hypernode_count?: number;
2172+
};
2173+
export type GraphEdge = {
2174+
kind: string;
2175+
label: string;
2176+
"from": GraphNodeRef;
2177+
to: GraphNodeRef;
2178+
field?: string;
2179+
value?: string;
2180+
};
2181+
export type Graph = {
2182+
start: GraphNodeRef;
2183+
nodes: GraphNode[];
2184+
edges: GraphEdge[];
2185+
};
21462186
/**
21472187
* Get searchable tables
21482188
*/
@@ -7227,3 +7267,73 @@ export function getScoreDistribution(recordType: string, opts?: Oazapfts.Request
72277267
...opts
72287268
}));
72297269
}
7270+
/**
7271+
* List same-field relations configurations
7272+
*/
7273+
export function listGraphRelations(opts?: Oazapfts.RequestOpts) {
7274+
return oazapfts.ok(oazapfts.fetchJson<{
7275+
status: 200;
7276+
data: GraphRelation;
7277+
} | {
7278+
status: 401;
7279+
data: string;
7280+
} | {
7281+
status: 403;
7282+
data: string;
7283+
}>("/graph/relations", {
7284+
...opts
7285+
}));
7286+
}
7287+
/**
7288+
* Create a same-field relation configuration
7289+
*/
7290+
export function createGraphRelation(createGraphRelation: CreateGraphRelation, opts?: Oazapfts.RequestOpts) {
7291+
return oazapfts.ok(oazapfts.fetchJson<{
7292+
status: 201;
7293+
data: GraphRelation;
7294+
} | {
7295+
status: 401;
7296+
data: string;
7297+
} | {
7298+
status: 403;
7299+
data: string;
7300+
}>("/graph/relations", oazapfts.json({
7301+
...opts,
7302+
method: "POST",
7303+
body: createGraphRelation
7304+
})));
7305+
}
7306+
/**
7307+
* Delete a same-field relation configuration
7308+
*/
7309+
export function deleteGraphRelation(relationId: string, opts?: Oazapfts.RequestOpts) {
7310+
return oazapfts.ok(oazapfts.fetchJson<{
7311+
status: 204;
7312+
} | {
7313+
status: 401;
7314+
data: string;
7315+
} | {
7316+
status: 403;
7317+
data: string;
7318+
}>(`/graph/relations/${encodeURIComponent(relationId)}`, {
7319+
...opts,
7320+
method: "DELETE"
7321+
}));
7322+
}
7323+
/**
7324+
* Generate the relationship graph from a starting record
7325+
*/
7326+
export function generateRelationshipGraph(opts?: Oazapfts.RequestOpts) {
7327+
return oazapfts.ok(oazapfts.fetchJson<{
7328+
status: 200;
7329+
data: Graph;
7330+
} | {
7331+
status: 401;
7332+
data: string;
7333+
} | {
7334+
status: 403;
7335+
data: string;
7336+
}>(`/graph/${encodeURIComponent(recordType)}/${encodeURIComponent(recordId)}`, {
7337+
...opts
7338+
}));
7339+
}

0 commit comments

Comments
 (0)