Skip to content

Commit 5c535c3

Browse files
jordanhunt22Convex, Inc.
authored and
Convex, Inc.
committed
[Record Validators] Walk AST in dashboard (#29576)
Update `ValidatorJSON` to include records GitOrigin-RevId: babe572a55834bf1189e19b689e430ebdd897da7
1 parent 53ac964 commit 5c535c3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

npm-packages/convex/src/values/validators.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ export class VRecord<
458458
get json(): ValidatorJSON {
459459
return {
460460
type: this.kind,
461-
keys: this.key.json,
461+
// This cast is needed because TypeScript thinks the key type is too wide
462+
keys: this.key.json as RecordKeyValidatorJSON,
462463
values: {
463464
fieldType: this.value.json,
464465
optional: false,
@@ -630,6 +631,17 @@ export type ValidatorJSON =
630631
| { type: "literal"; value: JSONValue }
631632
| { type: "id"; tableName: string }
632633
| { type: "array"; value: ValidatorJSON }
633-
| { type: "record"; keys: ValidatorJSON; values: ObjectFieldType }
634+
| {
635+
type: "record";
636+
keys: RecordKeyValidatorJSON;
637+
values: RecordValueValidatorJSON;
638+
}
634639
| { type: "object"; value: Record<string, ObjectFieldType> }
635640
| { type: "union"; value: ValidatorJSON[] };
641+
642+
type RecordKeyValidatorJSON =
643+
| { type: "string" }
644+
| { type: "id"; tableName: string }
645+
| { type: "union"; value: RecordKeyValidatorJSON[] };
646+
647+
type RecordValueValidatorJSON = ObjectFieldType & { optional: false };

0 commit comments

Comments
 (0)