Skip to content

Commit 3c36ee7

Browse files
committed
API specification for graph exploration.
1 parent d367c22 commit 3c36ee7

4 files changed

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