Skip to content

Commit 6971bec

Browse files
authored
address review (#719)
1 parent 319d5e1 commit 6971bec

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

apps/roam/src/components/settings/utils/zodSchema.example.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,84 @@ const globalSettings: GlobalSettings = {
178178
},
179179
],
180180
},
181+
Relations: [
182+
{
183+
id: "relation-uid-1",
184+
label: "Informs",
185+
source: "_EVD-node",
186+
destination: "_QUE-node",
187+
complement: "Informed By",
188+
ifConditions: [
189+
{
190+
triples: [
191+
["Page", "is a", "source"],
192+
["Block", "references", "Page"],
193+
["Block", "is in page", "ParentPage"],
194+
["ParentPage", "is a", "destination"],
195+
],
196+
nodePositions: {
197+
source: "200 50",
198+
destination: "200 350",
199+
},
200+
},
201+
],
202+
},
203+
{
204+
id: "relation-uid-2",
205+
label: "Supports",
206+
source: "_EVD-node",
207+
destination: "_CLM-node",
208+
complement: "Supported By",
209+
ifConditions: [
210+
{
211+
triples: [
212+
["Page", "is a", "source"],
213+
["Block", "references", "Page"],
214+
["SBlock", "references", "SPage"],
215+
["SPage", "has title", "SupportedBy"],
216+
["SBlock", "has child", "Block"],
217+
["PBlock", "references", "ParentPage"],
218+
["PBlock", "has child", "SBlock"],
219+
["ParentPage", "is a", "destination"],
220+
],
221+
nodePositions: {
222+
"0": "250 325",
223+
"1": "100 325",
224+
"2": "100 200",
225+
"3": "250 200",
226+
"4": "400 200",
227+
"5": "100 75",
228+
"6": "250 75",
229+
source: "400 325",
230+
destination: "400 75",
231+
},
232+
},
233+
{
234+
triples: [
235+
["Page", "is a", "destination"],
236+
["Block", "references", "Page"],
237+
["SBlock", "references", "SPage"],
238+
["SPage", "has title", "Supports"],
239+
["SBlock", "has child", "Block"],
240+
["PBlock", "references", "ParentPage"],
241+
["PBlock", "has child", "SBlock"],
242+
["ParentPage", "is a", "source"],
243+
],
244+
nodePositions: {
245+
"7": "250 325",
246+
"8": "100 325",
247+
"9": "100 200",
248+
"10": "250 200",
249+
"11": "400 200",
250+
"12": "100 75",
251+
"13": "250 75",
252+
source: "400 75",
253+
destination: "400 325",
254+
},
255+
},
256+
],
257+
},
258+
],
181259
};
182260

183261
const defaultGlobalSettings: GlobalSettings = {
@@ -204,6 +282,7 @@ const defaultGlobalSettings: GlobalSettings = {
204282
"Include Parent And Child Blocks": false,
205283
"Page Groups": [],
206284
},
285+
Relations: [],
207286
};
208287

209288
const personalSection: PersonalSection = {

apps/roam/src/components/settings/utils/zodSchema.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,22 @@ export const DiscourseNodeSchema = z.object({
136136
.transform((val) => val ?? "user"),
137137
});
138138

139+
export const TripleSchema = z.tuple([z.string(), z.string(), z.string()]);
140+
141+
export const RelationConditionSchema = z.object({
142+
triples: z.array(TripleSchema).default([]),
143+
nodePositions: z.record(z.string(), z.string()).default({}),
144+
});
145+
146+
export const DiscourseRelationSchema = z.object({
147+
id: z.string(),
148+
label: z.string(),
149+
source: z.string(),
150+
destination: z.string(),
151+
complement: z.string().default(""),
152+
ifConditions: z.array(RelationConditionSchema).default([]),
153+
});
154+
139155
export const FeatureFlagsSchema = z.object({
140156
"Enable Left Sidebar": z.boolean().default(false),
141157
"Suggestive Mode Enabled": z.boolean().default(false),
@@ -179,6 +195,7 @@ export const GlobalSettingsSchema = z.object({
179195
"Left Sidebar": LeftSidebarGlobalSettingsSchema.default({}),
180196
Export: ExportSettingsSchema.default({}),
181197
"Suggestive Mode": SuggestiveModeGlobalSettingsSchema.default({}),
198+
Relations: z.array(DiscourseRelationSchema).default([]),
182199
});
183200

184201
export const PersonalSectionSchema = z.object({
@@ -242,6 +259,9 @@ export const GithubSettingsSchema = z.object({
242259
export type CanvasSettings = z.infer<typeof CanvasSettingsSchema>;
243260
export type SuggestiveRules = z.infer<typeof SuggestiveRulesSchema>;
244261
export type DiscourseNodeSettings = z.infer<typeof DiscourseNodeSchema>;
262+
export type Triple = z.infer<typeof TripleSchema>;
263+
export type RelationCondition = z.infer<typeof RelationConditionSchema>;
264+
export type DiscourseRelationSettings = z.infer<typeof DiscourseRelationSchema>;
245265
export type FeatureFlags = z.infer<typeof FeatureFlagsSchema>;
246266
export type ExportSettings = z.infer<typeof ExportSettingsSchema>;
247267
export type PageGroup = z.infer<typeof PageGroupSchema>;

0 commit comments

Comments
 (0)