Skip to content

Commit 61c1d49

Browse files
committed
Merge branch 'main' of https://github.com/weaviate/typescript-client into 1.30/support-for-runtime-generate
2 parents 5eb09da + e30bd50 commit 61c1d49

File tree

7 files changed

+264
-77
lines changed

7 files changed

+264
-77
lines changed

.github/workflows/main.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
npm run format:check
3131
npm run docs
3232
33-
tests:
33+
tests-without-auth:
3434
needs: checks
3535
runs-on: ubuntu-latest
3636
strategy:
@@ -49,6 +49,37 @@ jobs:
4949
]
5050
steps:
5151
- uses: actions/checkout@v3
52+
- uses: actions/setup-node@v3
53+
with:
54+
node-version: ${{ matrix.versions.node }}
55+
- name: Login to Docker Hub
56+
if: ${{ !github.event.pull_request.head.repo.fork && github.triggering_actor != 'dependabot[bot]' }}
57+
uses: docker/login-action@v3
58+
with:
59+
username: ${{secrets.DOCKER_USERNAME}}
60+
password: ${{secrets.DOCKER_PASSWORD}}
61+
- name: "Install dependencies"
62+
run: |
63+
npm ci
64+
ci/run_dependencies.sh ${{ matrix.versions.weaviate }}
65+
- name: "Run tests without authentication tests"
66+
run: WEAVIATE_VERSION=${{ matrix.versions.weaviate }} npm test
67+
- name: "Transpile the package"
68+
run: npm run build
69+
- name: "Stop Weaviate"
70+
run: ci/stop_dependencies.sh ${{ matrix.versions.weaviate }}
71+
72+
tests-with-auth:
73+
needs: checks
74+
runs-on: ubuntu-latest
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
versions: [
79+
{ node: "22.x", weaviate: $WEAVIATE_129}
80+
]
81+
steps:
82+
- uses: actions/checkout@v3
5283
- uses: actions/setup-node@v3
5384
with:
5485
node-version: ${{ matrix.versions.node }}
@@ -70,16 +101,11 @@ jobs:
70101
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
71102
OKTA_CLIENT_SECRET: ${{ secrets.OKTA_CLIENT_SECRET }}
72103
run: WEAVIATE_VERSION=${{ matrix.versions.weaviate }} npm test
73-
- name: "Run tests without authentication tests (for forks)"
74-
if: ${{ github.event.pull_request.head.repo.fork }}
75-
run: WEAVIATE_VERSION=${{ matrix.versions.weaviate }} npm test
76-
- name: "Transpile the package"
77-
run: npm run build
78104
- name: "Stop Weaviate"
79105
run: ci/stop_dependencies.sh ${{ matrix.versions.weaviate }}
80106

81107
publish:
82-
needs: tests
108+
needs: [tests-with-auth, tests-without-auth]
83109
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
84110
runs-on: ubuntu-latest
85111
permissions:

src/openapi/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export interface paths {
231231
}
232232

233233
export interface definitions {
234-
UserInfo: {
234+
UserOwnInfo: {
235235
/** @description The groups associated to the user */
236236
groups?: string[];
237237
roles?: definitions['Role'][];
@@ -1615,7 +1615,7 @@ export interface operations {
16151615
responses: {
16161616
/** Info about the user */
16171617
200: {
1618-
schema: definitions['UserInfo'];
1618+
schema: definitions['UserOwnInfo'];
16191619
};
16201620
/** Unauthorized or invalid credentials. */
16211621
401: unknown;

src/openapi/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type WeaviateMultiTenancyConfig = WeaviateClass['multiTenancyConfig'];
5454
export type WeaviateReplicationConfig = WeaviateClass['replicationConfig'];
5555
export type WeaviateShardingConfig = WeaviateClass['shardingConfig'];
5656
export type WeaviateShardStatus = definitions['ShardStatusGetResponse'];
57-
export type WeaviateUser = definitions['UserInfo'];
57+
export type WeaviateUser = definitions['UserOwnInfo'];
5858
export type WeaviateVectorIndexConfig = WeaviateClass['vectorIndexConfig'];
5959
export type WeaviateVectorsConfig = WeaviateClass['vectorConfig'];
6060
export type WeaviateVectorConfig = definitions['VectorConfig'];

src/roles/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
PermissionsInput,
1111
Role,
1212
RolesPermission,
13+
TenantsPermission,
1314
UsersPermission,
1415
} from './types.js';
1516
import { Map } from './util.js';
@@ -207,6 +208,23 @@ export const permissions = {
207208
return out;
208209
});
209210
},
211+
tenants: (args: {
212+
collection: string | string[];
213+
create?: boolean;
214+
read?: boolean;
215+
update?: boolean;
216+
delete?: boolean;
217+
}): TenantsPermission[] => {
218+
const collections = Array.isArray(args.collection) ? args.collection : [args.collection];
219+
return collections.flatMap((collection) => {
220+
const out: TenantsPermission = { collection, actions: [] };
221+
if (args.create) out.actions.push('create_tenants');
222+
if (args.read) out.actions.push('read_tenants');
223+
if (args.update) out.actions.push('update_tenants');
224+
if (args.delete) out.actions.push('delete_tenants');
225+
return out;
226+
});
227+
},
210228
users: (args: {
211229
user: string | string[];
212230
assign_and_revoke?: boolean;

src/roles/integration.test.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ only('Integration testing of the roles namespace', () => {
5858
dataPermissions: [],
5959
nodesPermissions: [],
6060
rolesPermissions: [],
61+
tenantsPermissions: [],
6162
usersPermissions: [],
6263
},
6364
},
@@ -72,6 +73,7 @@ only('Integration testing of the roles namespace', () => {
7273
dataPermissions: [],
7374
nodesPermissions: [],
7475
rolesPermissions: [],
76+
tenantsPermissions: [],
7577
usersPermissions: [],
7678
},
7779
},
@@ -97,6 +99,7 @@ only('Integration testing of the roles namespace', () => {
9799
dataPermissions: [],
98100
nodesPermissions: [],
99101
rolesPermissions: [],
102+
tenantsPermissions: [],
100103
usersPermissions: [],
101104
},
102105
},
@@ -122,6 +125,7 @@ only('Integration testing of the roles namespace', () => {
122125
],
123126
nodesPermissions: [],
124127
rolesPermissions: [],
128+
tenantsPermissions: [],
125129
usersPermissions: [],
126130
},
127131
},
@@ -141,6 +145,7 @@ only('Integration testing of the roles namespace', () => {
141145
{ collection: 'Some-collection', verbosity: 'verbose', actions: ['read_nodes'] },
142146
],
143147
rolesPermissions: [],
148+
tenantsPermissions: [],
144149
usersPermissions: [],
145150
},
146151
},
@@ -157,6 +162,7 @@ only('Integration testing of the roles namespace', () => {
157162
dataPermissions: [],
158163
nodesPermissions: [{ collection: '*', verbosity: 'minimal', actions: ['read_nodes'] }],
159164
rolesPermissions: [],
165+
tenantsPermissions: [],
160166
usersPermissions: [],
161167
},
162168
},
@@ -179,6 +185,33 @@ only('Integration testing of the roles namespace', () => {
179185
rolesPermissions: [
180186
{ role: 'some-role', actions: ['create_roles', 'read_roles', 'update_roles', 'delete_roles'] },
181187
],
188+
tenantsPermissions: [],
189+
usersPermissions: [],
190+
},
191+
},
192+
{
193+
roleName: 'tenants',
194+
permissions: weaviate.permissions.tenants({
195+
collection: 'some-collection',
196+
create: true,
197+
read: true,
198+
update: true,
199+
delete: true,
200+
}),
201+
expected: {
202+
name: 'tenants',
203+
backupsPermissions: [],
204+
clusterPermissions: [],
205+
collectionsPermissions: [],
206+
dataPermissions: [],
207+
nodesPermissions: [],
208+
rolesPermissions: [],
209+
tenantsPermissions: [
210+
{
211+
collection: 'Some-collection',
212+
actions: ['create_tenants', 'read_tenants', 'update_tenants', 'delete_tenants'],
213+
},
214+
],
182215
usersPermissions: [],
183216
},
184217
},
@@ -197,6 +230,7 @@ only('Integration testing of the roles namespace', () => {
197230
dataPermissions: [],
198231
nodesPermissions: [],
199232
rolesPermissions: [],
233+
tenantsPermissions: [],
200234
usersPermissions: [{ users: 'some-user', actions: ['assign_and_revoke_users', 'read_users'] }],
201235
},
202236
},
@@ -218,9 +252,17 @@ only('Integration testing of the roles namespace', () => {
218252

219253
afterAll(() =>
220254
Promise.all(
221-
['backups', 'cluster', 'collections', 'data', 'nodes-verbose', 'nodes-minimal', 'roles', 'users'].map(
222-
(n) => client.roles.delete(n)
223-
)
255+
[
256+
'backups',
257+
'cluster',
258+
'collections',
259+
'data',
260+
'nodes-verbose',
261+
'nodes-minimal',
262+
'roles',
263+
'tenants',
264+
'users',
265+
].map((n) => client.roles.delete(n))
224266
)
225267
);
226268
});

src/roles/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export type DataAction = Extract<
1616
>;
1717
export type NodesAction = Extract<Action, 'read_nodes'>;
1818
export type RolesAction = Extract<Action, 'create_roles' | 'read_roles' | 'update_roles' | 'delete_roles'>;
19+
export type TenantsAction = Extract<
20+
Action,
21+
'create_tenants' | 'delete_tenants' | 'read_tenants' | 'update_tenants'
22+
>;
1923
export type UsersAction = Extract<Action, 'read_users' | 'assign_and_revoke_users'>;
2024

2125
export type BackupsPermission = {
@@ -48,6 +52,11 @@ export type RolesPermission = {
4852
actions: RolesAction[];
4953
};
5054

55+
export type TenantsPermission = {
56+
collection: string;
57+
actions: TenantsAction[];
58+
};
59+
5160
export type UsersPermission = {
5261
users: string;
5362
actions: UsersAction[];
@@ -61,6 +70,7 @@ export type Role = {
6170
dataPermissions: DataPermission[];
6271
nodesPermissions: NodesPermission[];
6372
rolesPermissions: RolesPermission[];
73+
tenantsPermissions: TenantsPermission[];
6474
usersPermissions: UsersPermission[];
6575
};
6676

@@ -71,6 +81,7 @@ export type Permission =
7181
| DataPermission
7282
| NodesPermission
7383
| RolesPermission
84+
| TenantsPermission
7485
| UsersPermission;
7586

7687
export type PermissionsInput = Permission | Permission[] | Permission[][] | (Permission | Permission[])[];

0 commit comments

Comments
 (0)