Repository navigation
ENG-1986 Refactor Obsidian sync to use the new cross-app schemas (5/6) #1634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,14 +26,16 @@ export type CrossAppNodeSchema = CrossAppSchemaBase & { | |
| template?: string; | ||
| templateTitle?: string; | ||
| format?: string; | ||
| color?: string; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| slotDefinitions?: Record<string, LocalId | undefined>; | ||
| }; | ||
|
|
||
| // A relation type schema | ||
| export type CrossAppRelationTypeSchema = CrossAppSchemaBase & { | ||
| label: string; | ||
| complement: string; | ||
| // should we add colour? format? | ||
| color?: string; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| // should we add format? | ||
| }; | ||
|
|
||
| // A relation triple schema | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,7 @@ export const crossAppNodeSchemaToDbConcept = ( | |
| template: node.templateTitle, | ||
| template_content: node.template, | ||
| format: node.format, | ||
| color: node.color, | ||
| roles: slots.length > 0 ? slots : undefined, | ||
| }); | ||
| const referenceContent = slots.length ? node.slotDefinitions : undefined; | ||
|
|
@@ -141,11 +142,12 @@ export const crossAppRelationTypeSchemaToDbConcept = ( | |
| name: node.label, | ||
| author_local_id: node.authorId, | ||
| is_schema: true, | ||
| literal_content: { | ||
| literal_content: filterUndefined({ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| roles: ["source", "destination"], | ||
| label: node.label, | ||
| complement: node.complement, | ||
| }, | ||
| color: node.color, | ||
| }), | ||
| created: node.createdAt?.toISOString(), | ||
| last_modified: node.modifiedAt?.toISOString(), | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,7 +168,7 @@ export const dbNodeSchemaToCrossApp = ({ | |
| string, | ||
| number | ||
| >; | ||
| const { template, template_content, roles, format, ...other } = | ||
| const { template, template_content, roles, format, color, ...other } = | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Destructuring |
||
| schema.literal_content as Record<string, Json>; | ||
| const authorId = accountMap[schema.author_id || 0]; | ||
| if (authorId === undefined) throw new Error("Missing author"); | ||
|
|
@@ -195,6 +195,7 @@ export const dbNodeSchemaToCrossApp = ({ | |
| template: template_content as string | undefined, | ||
| templateTitle: template as string | undefined, | ||
| format: format as string | undefined, | ||
| color: color as string | undefined, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reads only the top-level key. Obsidian rows published before #1633 keep their color in |
||
| authorId, | ||
| slotDefinitions, | ||
| }; | ||
|
|
@@ -409,7 +410,7 @@ export const dbRelationTypeSchemaToCrossApp = ( | |
| accountMap: Record<number, string>, | ||
| ): CrossAppRelationTypeSchema => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| const { roles, label, complement, ...other } = | ||
| const { roles, label, complement, color, ...other } = | ||
| schema.literal_content as Record<string, Json>; | ||
| const authorId = accountMap[schema.author_id || 0]; | ||
| if (authorId === undefined) throw new Error("Missing author"); | ||
|
|
@@ -428,6 +429,7 @@ export const dbRelationTypeSchemaToCrossApp = ( | |
| metadata: other, | ||
| label: label as string, | ||
| complement: complement as string, | ||
| color: color as string | undefined, | ||
| authorId, | ||
| }; | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coloris now a CrossApp field, so it is no longer residual.source_datais whatmetadatastill carries for Obsidian rows.