fix(custom-types): Make schema optional (#866)

* fix(custom-types): Make schema optional

The schema is optional in practice for custom types (as seen in the TS types above), and not always included in exports.

* add nullable

* fix

---------

Co-authored-by: Guy Ben-Aharon <baguy3@gmail.com>
This commit is contained in:
Aaron Dewes
2025-08-27 11:48:14 +02:00
committed by GitHub
parent 66b086378c
commit 60c5675cbf
2 changed files with 10 additions and 9 deletions

View File

@@ -15,12 +15,12 @@ export interface DBCustomTypeField {
export interface DBCustomType { export interface DBCustomType {
id: string; id: string;
schema?: string; schema?: string | null;
name: string; name: string;
kind: DBCustomTypeKind; kind: DBCustomTypeKind;
values?: string[]; // For enum types values?: string[] | null; // For enum types
fields?: DBCustomTypeField[]; // For composite types fields?: DBCustomTypeField[] | null; // For composite types
order?: number; order?: number | null;
} }
export const dbCustomTypeFieldSchema = z.object({ export const dbCustomTypeFieldSchema = z.object({
@@ -30,11 +30,12 @@ export const dbCustomTypeFieldSchema = z.object({
export const dbCustomTypeSchema: z.ZodType<DBCustomType> = z.object({ export const dbCustomTypeSchema: z.ZodType<DBCustomType> = z.object({
id: z.string(), id: z.string(),
schema: z.string(), schema: z.string().or(z.null()).optional(),
name: z.string(), name: z.string(),
kind: z.nativeEnum(DBCustomTypeKind), kind: z.nativeEnum(DBCustomTypeKind),
values: z.array(z.string()).optional(), values: z.array(z.string()).or(z.null()).optional(),
fields: z.array(dbCustomTypeFieldSchema).optional(), fields: z.array(dbCustomTypeFieldSchema).or(z.null()).optional(),
order: z.number().or(z.null()).optional(),
}); });
export const createCustomTypesFromMetadata = ({ export const createCustomTypesFromMetadata = ({

View File

@@ -128,8 +128,8 @@ export const CustomTypeList: React.FC<CustomTypeProps> = ({ customTypes }) => {
// if both have order, sort by order // if both have order, sort by order
if ( if (
customType1.order !== undefined && customType1.order != null &&
customType2.order !== undefined customType2.order != null
) { ) {
return ( return (
customType1.order - customType2.order customType1.order - customType2.order