diff --git a/src/collections/configure/types/base.ts b/src/collections/configure/types/base.ts index a2934ca1..d279ab96 100644 --- a/src/collections/configure/types/base.ts +++ b/src/collections/configure/types/base.ts @@ -36,17 +36,32 @@ export type MultiTenancyConfigUpdate = { autoTenantCreation?: boolean; }; +export type ObjectDataType = 'object' | 'object[]'; + +export type PrimitiveDataType = Exclude; + +export type NestedDataTypeConfig = + | { + dataType: ObjectDataType; + /** only for object types */ + nestedProperties?: NestedPropertyConfigCreate[]; + } + | { + dataType: PrimitiveDataType; + /** If not an object, or an array of objecs, this field should never be assigned. */ + nestedProperties?: never; + }; + export type NestedPropertyCreate = T extends undefined ? { name: string; dataType: DataType; description?: string; - nestedProperties?: NestedPropertyConfigCreate[]; indexInverted?: boolean; indexFilterable?: boolean; indexSearchable?: boolean; tokenization?: WeaviateNestedProperty['tokenization']; - } + } & NestedDataTypeConfig : { [K in NonRefKeys]: RequiresNested> extends true ? { @@ -92,9 +107,7 @@ export type NestedPropertyConfigCreateBase = { export type PropertyConfigCreate = T extends undefined ? { name: string; - dataType: DataType; description?: string; - nestedProperties?: NestedPropertyConfigCreate[]; indexInverted?: boolean; indexFilterable?: boolean; indexRangeFilters?: boolean; @@ -102,7 +115,7 @@ export type PropertyConfigCreate = T extends undefined tokenization?: WeaviateProperty['tokenization']; skipVectorization?: boolean; vectorizePropertyName?: boolean; - } + } & NestedDataTypeConfig : { [K in NonRefKeys]: RequiresNested> extends true ? {