Skip to content

Commit ab64936

Browse files
committed
eng-1863 Relation cross-app contract
1 parent d54f0c7 commit ab64936

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

packages/database/src/crossAppContracts.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ type DbRef = {
1414
// Generalized reference
1515
export type Ref = LocalRef | DbRef;
1616

17+
type SpaceRef = DbRef | { url: string; sourceApp: Enums<"Platform"> };
18+
19+
// A potentially cross-space reference
20+
export type LocalOrRemoteRef =
21+
| LocalRef
22+
| {
23+
localId: string;
24+
// infer space from context if absent.
25+
space?: SpaceRef;
26+
}
27+
| {
28+
// A string that contains combined space and localId
29+
rid: string;
30+
};
31+
1732
// Common attributes for most types
1833
export type CrossAppBase = LocalRef & {
1934
createdAt: Date;
@@ -85,3 +100,10 @@ export type CrossAppNode = CrossAppBase & {
85100
full: InlineCrossAppTypedContent;
86101
};
87102
};
103+
104+
// A relation instance
105+
export type CrossAppRelation = CrossAppBase & {
106+
relationType: Ref;
107+
source: LocalOrRemoteRef;
108+
destination: LocalOrRemoteRef;
109+
};

0 commit comments

Comments
 (0)