diff --git a/packages/database/src/crossAppContracts.ts b/packages/database/src/crossAppContracts.ts index 27c78b00f..4188b1698 100644 --- a/packages/database/src/crossAppContracts.ts +++ b/packages/database/src/crossAppContracts.ts @@ -21,6 +21,20 @@ type CrossAppBase = LocalRef & { author: Ref; }; +type SpaceRef = DbRef | { url: string; sourceApp: Enums<"Platform"> }; + +export type LocalOrRemoteRef = + | LocalRef + | { + localId: string; + // infer space from context if absent. + space?: SpaceRef; + } + | { + // A string that contains combined space and localId + rid: string; + }; + // A node schema export type CrossAppNodeSchema = CrossAppBase & { label: string; @@ -72,3 +86,10 @@ export type CrossAppNode = CrossAppBase & { full: InlineCrossAppTypedContent; }; }; + +// A relation instance +export type CrossAppRelation = CrossAppBase & { + relationType: Ref; + source: LocalOrRemoteRef; + destination: LocalOrRemoteRef; +};