Skip to content

Commit d54f0c7

Browse files
authored
ENG-1984 Define cross-app schema contracts (#1193)
1 parent 2ad7f73 commit d54f0c7

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

packages/database/src/crossAppContracts.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ContentType } from "@repo/content-model";
2-
import { Enums } from "./dbTypes";
2+
import { Enums, type Json } from "./dbTypes";
33

44
export type LocalRef = {
55
// This localId is expected to be unique within the current space
@@ -21,6 +21,42 @@ export type CrossAppBase = LocalRef & {
2121
author: Ref;
2222
};
2323

24+
export type CrossAppSchemaBase = CrossAppBase & {
25+
metadata?: Json;
26+
};
27+
28+
// A node schema
29+
export type CrossAppNodeSchema = CrossAppSchemaBase & {
30+
label: string;
31+
template?: string;
32+
templateTitle?: string;
33+
};
34+
35+
// A relation type schema
36+
export type CrossAppRelationTypeSchema = CrossAppSchemaBase & {
37+
label: string;
38+
complement: string;
39+
// should we add colour? format?
40+
};
41+
42+
// A relation triple schema
43+
export type CrossAppRelationTripleSchema = CrossAppSchemaBase &
44+
(
45+
| {
46+
label: string;
47+
complement: string;
48+
relation?: never;
49+
}
50+
| {
51+
relation: Ref;
52+
label?: never;
53+
complement?: never;
54+
}
55+
) & {
56+
sourceType: Ref;
57+
destinationType: Ref;
58+
};
59+
2460
// An inline vector semantic embedding
2561
export type CrossAppEmbedding = {
2662
value: number[];

0 commit comments

Comments
 (0)