Skip to content

Commit 0bec64e

Browse files
committed
Update swagger stubs and impl accordingly
1 parent 1da8950 commit 0bec64e

File tree

6 files changed

+142
-30
lines changed

6 files changed

+142
-30
lines changed

src/collections/data/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,18 @@ const data = <T>(
190190
? (Serialize.restProperties(object.properties, object.references) as T)
191191
: undefined,
192192
};
193+
// as any required below because server uses swagger object as interface{} in Go to perform type switching
194+
// actual types are []number and [][]number but unions don't work in go-swagger
193195
if (Array.isArray(object.vectors)) {
194196
const requiresNamedVectorsInsertFix = await dbVersionSupport.requiresNamedVectorsInsertFix();
195197
if (requiresNamedVectorsInsertFix.supports) {
196198
obj.vector = object.vectors;
197-
obj.vectors = { default: object.vectors };
199+
obj.vectors = { default: object.vectors as any };
198200
} else {
199201
obj.vector = object.vectors;
200202
}
201203
} else if (object.vectors) {
202-
obj.vectors = object.vectors;
204+
obj.vectors = object.vectors as any;
203205
}
204206
return obj;
205207
};

src/data/creator.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ export default class Creator extends CommandBase {
6161
}
6262
};
6363

64+
// as any required below because server uses swagger object as interface{} in Go to perform type switching
65+
// actual types are []number and [][]number but unions don't work in go-swagger
6466
payload = (): WeaviateObject => ({
6567
tenant: this.tenant,
6668
vector: this.vector,
6769
properties: this.properties,
6870
class: this.className,
6971
id: this.id,
70-
vectors: this.vectors,
72+
vectors: this.vectors as any,
7173
});
7274

7375
validate = () => {

src/data/updater.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,15 @@ export default class Updater extends CommandBase {
6767
return this;
6868
};
6969

70+
// as any required below because server uses swagger object as interface{} in Go to perform type switching
71+
// actual types are []number and [][]number but unions don't work in go-swagger
7072
payload = (): WeaviateObject => ({
7173
tenant: this.tenant,
7274
properties: this.properties,
7375
class: this.className,
7476
id: this.id,
7577
vector: this.vector,
76-
vectors: this.vectors,
78+
vectors: this.vectors as any,
7779
});
7880

7981
validate = () => {

src/graphql/journey.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2378,7 +2378,7 @@ describe('named vectors test', () => {
23782378
.get()
23792379
.withClassName(className)
23802380
.withNearVector({
2381-
vector: res.vectors?.title as number[],
2381+
vector: res.vectors?.title as any,
23822382
targetVectors: ['title'],
23832383
})
23842384
.withFields('title')

src/openapi/schema.ts

Lines changed: 125 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export interface paths {
4040
};
4141
};
4242
};
43+
'/users/own-info': {
44+
get: operations['getOwnInfo'];
45+
};
4346
'/authz/roles': {
4447
get: operations['getRoles'];
4548
post: operations['createRole'];
@@ -64,13 +67,16 @@ export interface paths {
6467
get: operations['getRolesForUser'];
6568
};
6669
'/authz/users/{id}/assign': {
67-
post: operations['assignRole'];
70+
post: operations['assignRoleToUser'];
6871
};
6972
'/authz/users/{id}/revoke': {
70-
post: operations['revokeRole'];
73+
post: operations['revokeRoleFromUser'];
74+
};
75+
'/authz/groups/{id}/assign': {
76+
post: operations['assignRoleToGroup'];
7177
};
72-
'/authz/users/own-roles': {
73-
get: operations['getRolesForOwnUser'];
78+
'/authz/groups/{id}/revoke': {
79+
post: operations['revokeRoleFromGroup'];
7480
};
7581
'/objects': {
7682
/** Lists all Objects in reverse order of creation, owned by the user that belongs to the used token. */
@@ -225,6 +231,13 @@ export interface paths {
225231
}
226232

227233
export interface definitions {
234+
UserInfo: {
235+
/** @description The groups associated to the user */
236+
groups?: string[];
237+
roles?: definitions['Role'][];
238+
/** @description The username associated with the provided key */
239+
username: string;
240+
};
228241
Role: {
229242
/** @description role name */
230243
name: string;
@@ -272,13 +285,40 @@ export interface definitions {
272285
*/
273286
collection?: string;
274287
};
288+
/** @description resources applicable for user actions */
289+
users?: {
290+
/**
291+
* @description string or regex. if a specific name, if left empty it will be ALL or *
292+
* @default *
293+
*/
294+
users?: string;
295+
};
296+
/** @description resources applicable for tenant actions */
297+
tenants?: {
298+
/**
299+
* @description string or regex. if a specific collection name, if left empty it will be ALL or *
300+
* @default *
301+
*/
302+
collection?: string;
303+
/**
304+
* @description string or regex. if a specific tenant name, if left empty it will be ALL or *
305+
* @default *
306+
*/
307+
tenant?: string;
308+
};
275309
/** @description resources applicable for role actions */
276310
roles?: {
277311
/**
278312
* @description string or regex. if a specific role name, if left empty it will be ALL or *
279313
* @default *
280314
*/
281315
role?: string;
316+
/**
317+
* @description set the scope for the manage role permission
318+
* @default match
319+
* @enum {string}
320+
*/
321+
scope?: 'all' | 'match';
282322
};
283323
/** @description resources applicable for collection and/or tenant actions */
284324
collections?: {
@@ -287,11 +327,6 @@ export interface definitions {
287327
* @default *
288328
*/
289329
collection?: string;
290-
/**
291-
* @description string or regex. if a specific tenant name, if left empty it will be ALL or *
292-
* @default *
293-
*/
294-
tenant?: string;
295330
};
296331
/**
297332
* @description allowed actions in weaviate.
@@ -300,19 +335,22 @@ export interface definitions {
300335
action:
301336
| 'manage_backups'
302337
| 'read_cluster'
303-
| 'manage_data'
304338
| 'create_data'
305339
| 'read_data'
306340
| 'update_data'
307341
| 'delete_data'
308342
| 'read_nodes'
309343
| 'manage_roles'
310344
| 'read_roles'
311-
| 'manage_collections'
312345
| 'create_collections'
313346
| 'read_collections'
314347
| 'update_collections'
315-
| 'delete_collections';
348+
| 'delete_collections'
349+
| 'assign_and_revoke_users'
350+
| 'create_tenants'
351+
| 'read_tenants'
352+
| 'update_tenants'
353+
| 'delete_tenants';
316354
};
317355
/** @description list of roles */
318356
RolesListResponse: definitions['Role'][];
@@ -374,7 +412,7 @@ export interface definitions {
374412
/** @description A vector representation of the object in the Contextionary. If provided at object creation, this wil take precedence over any vectorizer setting. */
375413
C11yVector: number[];
376414
/** @description A vector representation of the object. If provided at object creation, this wil take precedence over any vectorizer setting. */
377-
Vector: number[];
415+
Vector: { [key: string]: unknown };
378416
/** @description A map of named vectors for multi-vector representations. */
379417
Vectors: { [key: string]: definitions['Vector'] };
380418
/** @description Receive question based on array of classes, properties and values. */
@@ -1504,12 +1542,6 @@ export interface definitions {
15041542
TenantResponse: definitions['Tenant'] & {
15051543
/** @description The list of nodes that owns that tenant data. */
15061544
belongsToNodes?: string[];
1507-
/**
1508-
* @description Experimental. The data version of the tenant is a monotonically increasing number starting from 0 which is incremented each time a tenant's data is offloaded to cloud storage.
1509-
* @default 0
1510-
* @example 3
1511-
*/
1512-
dataVersion?: number;
15131545
};
15141546
}
15151547

@@ -1576,6 +1608,20 @@ export interface operations {
15761608
503: unknown;
15771609
};
15781610
};
1611+
getOwnInfo: {
1612+
responses: {
1613+
/** Info about the user */
1614+
200: {
1615+
schema: definitions['UserInfo'];
1616+
};
1617+
/** Unauthorized or invalid credentials. */
1618+
401: unknown;
1619+
/** An error has occurred while trying to fulfill the request. Most likely the ErrorResponse will contain more information about the error. */
1620+
500: {
1621+
schema: definitions['ErrorResponse'];
1622+
};
1623+
};
1624+
};
15791625
getRoles: {
15801626
responses: {
15811627
/** Successful response. */
@@ -1860,7 +1906,7 @@ export interface operations {
18601906
};
18611907
};
18621908
};
1863-
assignRole: {
1909+
assignRoleToUser: {
18641910
parameters: {
18651911
path: {
18661912
/** user name */
@@ -1894,7 +1940,7 @@ export interface operations {
18941940
};
18951941
};
18961942
};
1897-
revokeRole: {
1943+
revokeRoleFromUser: {
18981944
parameters: {
18991945
path: {
19001946
/** user name */
@@ -1928,14 +1974,68 @@ export interface operations {
19281974
};
19291975
};
19301976
};
1931-
getRolesForOwnUser: {
1977+
assignRoleToGroup: {
1978+
parameters: {
1979+
path: {
1980+
/** group name */
1981+
id: string;
1982+
};
1983+
body: {
1984+
body: {
1985+
/** @description the roles that assigned to group */
1986+
roles?: string[];
1987+
};
1988+
};
1989+
};
1990+
responses: {
1991+
/** Role assigned successfully */
1992+
200: unknown;
1993+
/** Bad request */
1994+
400: {
1995+
schema: definitions['ErrorResponse'];
1996+
};
1997+
/** Unauthorized or invalid credentials. */
1998+
401: unknown;
1999+
/** Forbidden */
2000+
403: {
2001+
schema: definitions['ErrorResponse'];
2002+
};
2003+
/** role or group is not found. */
2004+
404: unknown;
2005+
/** An error has occurred while trying to fulfill the request. Most likely the ErrorResponse will contain more information about the error. */
2006+
500: {
2007+
schema: definitions['ErrorResponse'];
2008+
};
2009+
};
2010+
};
2011+
revokeRoleFromGroup: {
2012+
parameters: {
2013+
path: {
2014+
/** group name */
2015+
id: string;
2016+
};
2017+
body: {
2018+
body: {
2019+
/** @description the roles that revoked from group */
2020+
roles?: string[];
2021+
};
2022+
};
2023+
};
19322024
responses: {
1933-
/** Role assigned to own users */
1934-
200: {
1935-
schema: definitions['RolesListResponse'];
2025+
/** Role revoked successfully */
2026+
200: unknown;
2027+
/** Bad request */
2028+
400: {
2029+
schema: definitions['ErrorResponse'];
19362030
};
19372031
/** Unauthorized or invalid credentials. */
19382032
401: unknown;
2033+
/** Forbidden */
2034+
403: {
2035+
schema: definitions['ErrorResponse'];
2036+
};
2037+
/** role or group is not found. */
2038+
404: unknown;
19392039
/** An error has occurred while trying to fulfill the request. Most likely the ErrorResponse will contain more information about the error. */
19402040
500: {
19412041
schema: definitions['ErrorResponse'];

src/schema/journey.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,12 @@ async function newClassObject(className: string, client: WeaviateClient): Promis
732732
dynamicEfMin: 100,
733733
ef: -1,
734734
maxConnections: 64,
735+
multivector: (await isVer(client, 29, 0))
736+
? {
737+
aggregation: 'maxSim',
738+
enabled: false,
739+
}
740+
: undefined,
735741
pq: {
736742
bitCompression: false,
737743
centroids: 256,

0 commit comments

Comments
 (0)