Skip to content

Commit 2a4c2d2

Browse files
committed
Merge branch 'dev/1.27' of https://github.com/weaviate/typescript-client into 1.27/multi-vector-search
2 parents de854b8 + 8ed6c24 commit 2a4c2d2

File tree

7 files changed

+65
-11
lines changed

7 files changed

+65
-11
lines changed

src/collections/config/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ export type MultiTenancyConfig = {
4040
enabled: boolean;
4141
};
4242

43+
export type ReplicationDeletionStrategy = 'DeleteOnConflict' | 'NoAutomatedResolution';
44+
4345
export type ReplicationConfig = {
4446
asyncEnabled: boolean;
47+
deletionStrategy: ReplicationDeletionStrategy;
4548
factor: number;
4649
};
4750

src/collections/config/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class ConfigMapping {
265265
return {
266266
factor: v.factor,
267267
asyncEnabled: v.asyncEnabled ? v.asyncEnabled : false,
268+
deletionStrategy: v.deletionStrategy ? v.deletionStrategy : 'NoAutomatedResolution',
268269
};
269270
}
270271
static sharding(v?: WeaviateShardingConfig): ShardingConfig {

src/collections/configure/index.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
InvertedIndexConfigUpdate,
44
MultiTenancyConfigCreate,
55
ReplicationConfigCreate,
6+
ReplicationConfigUpdate,
7+
ReplicationDeletionStrategy,
68
ShardingConfigCreate,
79
VectorConfigUpdate,
810
VectorIndexType,
@@ -131,10 +133,19 @@ const configure = {
131133
* See [the docs](https://weaviate.io/developers/weaviate/concepts/replication-architecture#replication-vs-sharding) for more details.
132134
*
133135
* @param {boolean} [options.asyncEnabled] Whether asynchronous replication is enabled. Default is false.
136+
* @param {ReplicationDeletionStrategy} [options.deletionStrategy] The deletion strategy when replication conflicts are detected between deletes and reads.
134137
* @param {number} [options.factor] The replication factor. Default is 1.
135138
*/
136-
replication: (options: { asyncEnabled?: boolean; factor?: number }): ReplicationConfigCreate => {
137-
return { asyncEnabled: options.asyncEnabled, factor: options.factor };
139+
replication: (options: {
140+
asyncEnabled?: boolean;
141+
deletionStrategy?: ReplicationDeletionStrategy;
142+
factor?: number;
143+
}): ReplicationConfigCreate => {
144+
return {
145+
asyncEnabled: options.asyncEnabled,
146+
deletionStrategy: options.deletionStrategy,
147+
factor: options.factor,
148+
};
138149
},
139150
/**
140151
* Create a `ShardingConfigCreate` object to be used when defining the sharding configuration of your collection.
@@ -217,10 +228,19 @@ const reconfigure = {
217228
* See [the docs](https://weaviate.io/developers/weaviate/concepts/replication-architecture#replication-vs-sharding) for more details.
218229
*
219230
* @param {boolean} [options.asyncEnabled] Whether asynchronous replication is enabled.
231+
* @param {ReplicationDeletionStrategy} [options.deletionStrategy] The deletion strategy when replication conflicts are detected between deletes and reads.
220232
* @param {number} [options.factor] The replication factor.
221233
*/
222-
replication: (options: { asyncEnabled?: boolean; factor?: number }): ReplicationConfigCreate => {
223-
return { asyncEnabled: options.asyncEnabled, factor: options.factor };
234+
replication: (options: {
235+
asyncEnabled?: boolean;
236+
deletionStrategy?: ReplicationDeletionStrategy;
237+
factor?: number;
238+
}): ReplicationConfigUpdate => {
239+
return {
240+
asyncEnabled: options.asyncEnabled,
241+
deletionStrategy: options.deletionStrategy,
242+
factor: options.factor,
243+
};
224244
},
225245
};
226246

src/collections/configure/types/base.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import { WeaviateNestedProperty, WeaviateProperty } from '../../../openapi/types.js';
2-
import { InvertedIndexConfig, MultiTenancyConfig, ReplicationConfig } from '../../config/types/index.js';
2+
import {
3+
InvertedIndexConfig,
4+
MultiTenancyConfig,
5+
ReplicationConfig,
6+
ReplicationDeletionStrategy,
7+
} from '../../config/types/index.js';
38
import { DataType } from '../../types/index.js';
49
import { NonRefKeys, RefKeys } from '../../types/internal.js';
510

6-
export type RecursivePartial<T> = {
7-
[P in keyof T]?: RecursivePartial<T[P]>;
8-
};
11+
export type RecursivePartial<T> = T extends object
12+
? {
13+
[P in keyof T]?: RecursivePartial<T[P]>;
14+
}
15+
: T;
916

1017
export type InvertedIndexConfigCreate = RecursivePartial<InvertedIndexConfig>;
1118

@@ -133,6 +140,7 @@ export type ReplicationConfigCreate = RecursivePartial<ReplicationConfig>;
133140

134141
export type ReplicationConfigUpdate = {
135142
asyncEnabled?: boolean;
143+
deletionStrategy?: ReplicationDeletionStrategy;
136144
factor?: number;
137145
};
138146

src/collections/configure/unit.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ import {
1414
ModuleConfig,
1515
VectorConfigCreate,
1616
} from '../types/index.js';
17-
import { configure } from './index.js';
17+
import { configure, reconfigure } from './index.js';
1818
import {
1919
InvertedIndexConfigCreate,
2020
MultiTenancyConfigCreate,
2121
ReplicationConfigCreate,
22+
ReplicationConfigUpdate,
2223
ShardingConfigCreate,
2324
VectorIndexConfigFlatCreate,
2425
VectorIndexConfigHNSWCreate,
2526
} from './types/index.js';
2627

27-
describe('Unit testing of the configure factory class', () => {
28+
describe('Unit testing of the configure & reconfigure factory classes', () => {
2829
it('should create the correct InvertedIndexConfig type with all values', () => {
2930
const config = configure.invertedIndex({
3031
bm25b: 0.5,
@@ -76,13 +77,28 @@ describe('Unit testing of the configure factory class', () => {
7677
});
7778
});
7879

79-
it('should create the correct ReplicationConfig type with all values', () => {
80+
it('should create the correct ReplicationConfigCreate type with all values', () => {
8081
const config = configure.replication({
8182
asyncEnabled: true,
83+
deletionStrategy: 'DeleteOnConflict',
8284
factor: 2,
8385
});
8486
expect(config).toEqual<ReplicationConfigCreate>({
8587
asyncEnabled: true,
88+
deletionStrategy: 'DeleteOnConflict',
89+
factor: 2,
90+
});
91+
});
92+
93+
it('should create the correct ReplicationConfigUpdate type with all values', () => {
94+
const config = reconfigure.replication({
95+
asyncEnabled: true,
96+
deletionStrategy: 'DeleteOnConflict',
97+
factor: 2,
98+
});
99+
expect(config).toEqual<ReplicationConfigUpdate>({
100+
asyncEnabled: true,
101+
deletionStrategy: 'DeleteOnConflict',
86102
factor: 2,
87103
});
88104
});

src/collections/integration.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
PQConfig,
77
PhoneNumber,
88
PropertyConfig,
9+
ReplicationDeletionStrategy,
910
Text2VecContextionaryConfig,
1011
Text2VecOpenAIConfig,
1112
VectorIndexConfigHNSW,
@@ -578,6 +579,10 @@ describe('Testing of the collections.create method', () => {
578579

579580
expect(response.multiTenancy.enabled).toEqual(true);
580581

582+
expect(response.replication.asyncEnabled).toEqual(false);
583+
expect(response.replication.deletionStrategy).toEqual<ReplicationDeletionStrategy>(
584+
'NoAutomatedResolution'
585+
);
581586
expect(response.replication.factor).toEqual(2);
582587

583588
const indexConfig = response.vectorizers.default.indexConfig as VectorIndexConfigHNSW;

src/collections/journey.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ describe('Journey testing of the client using a WCD cluster', () => {
145145
references: [],
146146
replication: {
147147
asyncEnabled: false,
148+
deletionStrategy: 'NoAutomatedResolution',
148149
factor: 1,
149150
},
150151
reranker: {

0 commit comments

Comments
 (0)