Skip to content

Commit

Permalink
Merge pull request #231 from pacyL2K19/bugfix/#203-nested-properties
Browse files Browse the repository at this point in the history
Improve nestedProperties' type configuration
  • Loading branch information
tsmith023 authored Nov 21, 2024
2 parents a137e70 + 1bfedd7 commit acf2462
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/collections/configure/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,31 @@ export type MultiTenancyConfigUpdate = {
autoTenantCreation?: boolean;
};

export type ObjectDataType = 'object' | 'object[]';

export type PrimitiveDataType = Exclude<DataType, ObjectDataType>;

export type NestedDataTypeConfig<T> =
| {
dataType: ObjectDataType;
/** only for object types */
nestedProperties?: NestedPropertyConfigCreate<T, ObjectDataType>[];
}
| {
dataType: PrimitiveDataType;
/** If not an object, or an array of objecs, this field should never be assigned. */
nestedProperties?: never;
};

export type NestedPropertyCreate<T = undefined> = T extends undefined
? {
name: string;
dataType: DataType;
description?: string;
nestedProperties?: NestedPropertyConfigCreate<T, DataType>[];
indexInverted?: boolean;
indexFilterable?: boolean;
indexSearchable?: boolean;
tokenization?: WeaviateNestedProperty['tokenization'];
}
} & NestedDataTypeConfig<T>
: {
[K in NonRefKeys<T>]: RequiresNested<DataType<T[K]>> extends true
? {
Expand Down Expand Up @@ -92,17 +106,15 @@ export type NestedPropertyConfigCreateBase = {
export type PropertyConfigCreate<T> = T extends undefined
? {
name: string;
dataType: DataType;
description?: string;
nestedProperties?: NestedPropertyConfigCreate<T, DataType>[];
indexInverted?: boolean;
indexFilterable?: boolean;
indexRangeFilters?: boolean;
indexSearchable?: boolean;
tokenization?: WeaviateProperty['tokenization'];
skipVectorization?: boolean;
vectorizePropertyName?: boolean;
}
} & NestedDataTypeConfig<T>
: {
[K in NonRefKeys<T>]: RequiresNested<DataType<T[K]>> extends true
? {
Expand Down

0 comments on commit acf2462

Please sign in to comment.