Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions apps/roam/src/components/settings/utils/zodSchema.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,84 @@ const globalSettings: GlobalSettings = {
},
],
},
Relations: [
{
id: "relation-uid-1",
label: "Informs",
source: "_EVD-node",
destination: "_QUE-node",
complement: "Informed By",
ifConditions: [
{
triples: [
["Page", "is a", "source"],
["Block", "references", "Page"],
["Block", "is in page", "ParentPage"],
["ParentPage", "is a", "destination"],
],
nodePositions: {
source: "200 50",
destination: "200 350",
},
},
],
},
{
id: "relation-uid-2",
label: "Supports",
source: "_EVD-node",
destination: "_CLM-node",
complement: "Supported By",
ifConditions: [
{
triples: [
["Page", "is a", "source"],
["Block", "references", "Page"],
["SBlock", "references", "SPage"],
["SPage", "has title", "SupportedBy"],
["SBlock", "has child", "Block"],
["PBlock", "references", "ParentPage"],
["PBlock", "has child", "SBlock"],
["ParentPage", "is a", "destination"],
],
nodePositions: {
"0": "250 325",
"1": "100 325",
"2": "100 200",
"3": "250 200",
"4": "400 200",
"5": "100 75",
"6": "250 75",
source: "400 325",
destination: "400 75",
},
},
{
triples: [
["Page", "is a", "destination"],
["Block", "references", "Page"],
["SBlock", "references", "SPage"],
["SPage", "has title", "Supports"],
["SBlock", "has child", "Block"],
["PBlock", "references", "ParentPage"],
["PBlock", "has child", "SBlock"],
["ParentPage", "is a", "source"],
],
nodePositions: {
"7": "250 325",
"8": "100 325",
"9": "100 200",
"10": "250 200",
"11": "400 200",
"12": "100 75",
"13": "250 75",
source: "400 75",
destination: "400 325",
},
},
],
},
],
};

const defaultGlobalSettings: GlobalSettings = {
Expand All @@ -204,6 +282,7 @@ const defaultGlobalSettings: GlobalSettings = {
"Include Parent And Child Blocks": false,
"Page Groups": [],
},
Relations: [],
};

const personalSection: PersonalSection = {
Expand Down
20 changes: 20 additions & 0 deletions apps/roam/src/components/settings/utils/zodSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ export const DiscourseNodeSchema = z.object({
.transform((val) => val ?? "user"),
});

export const TripleSchema = z.tuple([z.string(), z.string(), z.string()]);

export const RelationConditionSchema = z.object({
triples: z.array(TripleSchema).default([]),
nodePositions: z.record(z.string(), z.string()).default({}),
});

export const DiscourseRelationSchema = z.object({
id: z.string(),
label: z.string(),
source: z.string(),
destination: z.string(),
complement: z.string().default(""),
ifConditions: z.array(RelationConditionSchema).default([]),
});

export const FeatureFlagsSchema = z.object({
"Enable Left Sidebar": z.boolean().default(false),
"Suggestive Mode Enabled": z.boolean().default(false),
Expand Down Expand Up @@ -179,6 +195,7 @@ export const GlobalSettingsSchema = z.object({
"Left Sidebar": LeftSidebarGlobalSettingsSchema.default({}),
Export: ExportSettingsSchema.default({}),
"Suggestive Mode": SuggestiveModeGlobalSettingsSchema.default({}),
Relations: z.array(DiscourseRelationSchema).default([]),
});

export const PersonalSectionSchema = z.object({
Expand Down Expand Up @@ -242,6 +259,9 @@ export const GithubSettingsSchema = z.object({
export type CanvasSettings = z.infer<typeof CanvasSettingsSchema>;
export type SuggestiveRules = z.infer<typeof SuggestiveRulesSchema>;
export type DiscourseNodeSettings = z.infer<typeof DiscourseNodeSchema>;
export type Triple = z.infer<typeof TripleSchema>;
export type RelationCondition = z.infer<typeof RelationConditionSchema>;
export type DiscourseRelationSettings = z.infer<typeof DiscourseRelationSchema>;
export type FeatureFlags = z.infer<typeof FeatureFlagsSchema>;
export type ExportSettings = z.infer<typeof ExportSettingsSchema>;
export type PageGroup = z.infer<typeof PageGroupSchema>;
Expand Down