From 43ae6ef53f289768f1f89cae851db5ee2814eccc Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Thu, 2 Jul 2026 09:21:55 -0400 Subject: [PATCH] eng-1863 Relation cross-app contract --- packages/database/src/crossAppContracts.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/database/src/crossAppContracts.ts b/packages/database/src/crossAppContracts.ts index 63084917b..f64048453 100644 --- a/packages/database/src/crossAppContracts.ts +++ b/packages/database/src/crossAppContracts.ts @@ -25,6 +25,20 @@ export type CrossAppSchemaBase = CrossAppBase & { metadata?: Json; }; +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 = CrossAppSchemaBase & { label: string; @@ -76,3 +90,10 @@ export type CrossAppNode = CrossAppBase & { full: InlineCrossAppTypedContent; }; }; + +// A relation instance +export type CrossAppRelation = CrossAppBase & { + relationType: Ref; + source: LocalOrRemoteRef; + destination: LocalOrRemoteRef; +};