Skip to content

ENG-1983 Define intermediate schemas for node, relations and schemas#1183

Draft
maparent wants to merge 2 commits into
mainfrom
eng-1983-define-intermediate-schemas-for-node-relations-and-schemas
Draft

ENG-1983 Define intermediate schemas for node, relations and schemas#1183
maparent wants to merge 2 commits into
mainfrom
eng-1983-define-intermediate-schemas-for-node-relations-and-schemas

Conversation

@maparent

@maparent maparent commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

@linear-code

linear-code Bot commented Jul 2, 2026

Copy link
Copy Markdown

ENG-1983

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
discourse-graph Ready Ready Preview, Comment Jul 10, 2026 1:41pm

Request Review

@supabase

supabase Bot commented Jul 2, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project zytfjzqyijgagqxrzbmz because there are no changes detected in packages/database/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 3badfb0 to 4bbf2f8 Compare July 2, 2026 13:49
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 4bbf2f8 to a8bc33d Compare July 2, 2026 15:07
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from a8bc33d to 47202b7 Compare July 2, 2026 15:30
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 47202b7 to 66ebc78 Compare July 2, 2026 15:55
@@ -0,0 +1,92 @@
import type { ContentType } from "@repo/content-model";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maparent
Let's only export types that are being used elsewhere. This adds positive signal and really helps navigate and grok the file.

When we export types that are not used, it adds a false positive and makes it harder to understand intent.

@sid597 sid597 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and suggestions, I read CrossApp... so many time that now I am confused what it even means lol

Comment thread packages/database/src/crossAppNodeContract.example.ts
sourceApp: "Roam",
url: ROAM_SOURCE_SPACE_ID,
},
local_id: ROAM_SOURCE_NODE_ID,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snake case -> camelCase

What do you think about naming, like appending source vs direct e.g

  • sourceLocalId, vs localId
  • space.sourceApp vs space.app

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tended to remove source here, because everything was named sourceSomething, and it did not seem to add specific information (as you were remarking about CrossApp!) Maybe I missed something? Fully negotiable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to camelCase for TypeScript-facing contract fields

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Did the rename in the type and forgot to update the example.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for source: With the same reasoning as account, happy to reintroduce it where it fits database names. It was quite broad in the original file, but that argument does not hold anymore. Would you prefer that?

| {
localId: string;
// infer space from context if absent.
space?: SpaceRef;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for future? Can space be absent in Obsidian <-> roam sync?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the case where we have a reference to a node in another space. It currently happens in Obsidian; the source or destination of a relation may be an imported node, in which case we give the reference to the original node (imported nodes are not materialized again.)
But yes, it can be absent and inferred from context in most cases.

@mdroidian mdroidian Jul 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that localId/space can be used for more use cases? If not, then having it in a union this high up will just complicate things by making the downstream types just more complex for a single use case.

Comment thread packages/database/src/crossAppContracts.ts Outdated
value: string;
localId?: string;
embedding?: CrossAppEmbedding;
author: CrossAppAccount | Ref;

@mdroidian mdroidian Jul 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would author use Ref (specifically LocalRef)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows a minimal reference to the author, i.e. enough for a reference, not enough for an upsert. I did not check how we currently include authors in the sync, but I think it's closer to Ref usage than to an InlineAccount. Reusing the Ref type is a bit of overloading here, maybe we should define a separate AccountRef. But it would end up having exactly the same parameters.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m still unclear on when author would actually use Ref, specifically LocalRef. Could you give a real world example?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In convertRoamNodeToFullContent, we use author_local_id which would be the equivalent of a LocalRef.

Comment thread packages/database/src/crossAppContracts.ts Outdated
Comment thread packages/database/src/crossAppContracts.ts Outdated
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 66ebc78 to 38f9ba0 Compare July 4, 2026 13:33
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch 2 times, most recently from 885ec68 to 80f3533 Compare July 4, 2026 13:41
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 80f3533 to e4a3d61 Compare July 4, 2026 13:51
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from e4a3d61 to 1e9e344 Compare July 4, 2026 17:19
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 1e9e344 to a335e7d Compare July 4, 2026 19:17
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from a335e7d to 768923b Compare July 4, 2026 21:49
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 768923b to c20936a Compare July 4, 2026 22:19
@maparent

maparent commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

Decision: Will be split in sub-tasks.

@maparent maparent marked this pull request as draft July 5, 2026 22:17
@maparent maparent removed request for mdroidian and sid597 July 5, 2026 22:17
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from fc84691 to 442535f Compare July 6, 2026 02:20
@maparent maparent changed the base branch from main to eng-1987-align-cross-app-node-content-contract-with-database-schema July 6, 2026 02:21
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 442535f to b42b68f Compare July 6, 2026 02:29
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from b42b68f to 729236e Compare July 6, 2026 02:39
Base automatically changed from eng-1987-align-cross-app-node-content-contract-with-database-schema to main July 6, 2026 11:53
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 729236e to c9117a2 Compare July 6, 2026 15:22
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from c9117a2 to d3a1f85 Compare July 6, 2026 19:25
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from d3a1f85 to e54938d Compare July 8, 2026 13:51
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from e54938d to a787c0b Compare July 9, 2026 18:16
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from a787c0b to 8394ac5 Compare July 9, 2026 18:29
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 8394ac5 to 859d547 Compare July 9, 2026 18:34
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from 859d547 to fab6a5f Compare July 10, 2026 13:14
@maparent maparent force-pushed the eng-1983-define-intermediate-schemas-for-node-relations-and-schemas branch from fab6a5f to f2f5ee7 Compare July 10, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants