@opencloning/opencloningdb 1.8.2 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/package.json +4 -4
- package/src/GetSequenceFileAndDatabaseIdComponent.cy.jsx +2 -0
- package/src/SequenceSelect.cy.jsx +31 -1
- package/src/SequenceSelect.jsx +15 -9
- package/src/common.js +16 -2
- package/src/common.test.js +8 -7
- package/src/endpoints.js +28 -21
- package/src/endpoints.test.js +17 -0
- package/src/index.js +1 -1
- package/src/testUtils.test.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# @opencloning/opencloningdb
|
|
2
2
|
|
|
3
|
+
## 1.8.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#778](https://github.com/OpenCloning/OpenCloning_frontend/pull/778) [`fe1d81c`](https://github.com/OpenCloning/OpenCloning_frontend/commit/fe1d81c6f4b85f6317a2a9e46cc68c571c79c394) Thanks [@manulera](https://github.com/manulera)! - Only send the auth token to the backend, and rename the http client APIs.
|
|
8
|
+
|
|
9
|
+
- `@opencloning/utils`: `@opencloning/utils/httpClients` exports `getBackendHttpClient(backendUrl, { authenticated })`, a client that can only reach the backend (`allowAbsoluteUrls: false`) and is the only one carrying the auth token, and `getExternalHttpClient()` for whitelisted external urls. Replaces `@opencloning/utils/getHttpClient` (`getHttpClient`, `getAuthenticatedHttpClient`). `attachAuthInterceptors` refuses clients that could send the token elsewhere.
|
|
10
|
+
- `@opencloning/ui` (breaking): `useHttpClient` is renamed `useBackendHttpClient` and takes urls relative to `backendUrl`; `useBackendRoute` is removed; `useBackendAPI` is renamed `useSourceRequest` and `sendPostRequest` is renamed `sendSourceRequest`.
|
|
11
|
+
- `@opencloning/opencloningdb`, `@opencloning/opencloning-elabftw`: clients can no longer be pointed at other hosts.
|
|
12
|
+
|
|
13
|
+
- [#778](https://github.com/OpenCloning/OpenCloning_frontend/pull/778) [`fe1d81c`](https://github.com/OpenCloning/OpenCloning_frontend/commit/fe1d81c6f4b85f6317a2a9e46cc68c571c79c394) Thanks [@manulera](https://github.com/manulera)! - Encode values interpolated into request URL paths to prevent client-side path traversal. A sample UID such as `../workspaces/1/users/5` could make a user's own request hit a different endpoint, e.g. "delete UID" removing a workspace member.
|
|
14
|
+
|
|
15
|
+
- `@opencloning/utils`: new `encodePathSegment` (`@opencloning/utils/urlUtils`), which applies `encodeURIComponent` and rejects `.` and `..`.
|
|
16
|
+
- `@opencloning/opencloningdb`: all path parameters in `endpoints.js` are encoded.
|
|
17
|
+
- `@opencloning/opencloning-elabftw`: eLabFTW item and upload paths are encoded.
|
|
18
|
+
- `@opencloning/ui`: the `example`, `key` and `template` URL parameters are encoded when loading examples and templates.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`fe1d81c`](https://github.com/OpenCloning/OpenCloning_frontend/commit/fe1d81c6f4b85f6317a2a9e46cc68c571c79c394), [`fe1d81c`](https://github.com/OpenCloning/OpenCloning_frontend/commit/fe1d81c6f4b85f6317a2a9e46cc68c571c79c394), [`fe1d81c`](https://github.com/OpenCloning/OpenCloning_frontend/commit/fe1d81c6f4b85f6317a2a9e46cc68c571c79c394)]:
|
|
21
|
+
- @opencloning/utils@2.0.0
|
|
22
|
+
- @opencloning/ui@2.0.0
|
|
23
|
+
|
|
24
|
+
## 1.8.7
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`f7f376e`](https://github.com/OpenCloning/OpenCloning_frontend/commit/f7f376ee351d9b2da52413700836dc55ba54b5ea)]:
|
|
29
|
+
- @opencloning/ui@1.10.0
|
|
30
|
+
- @opencloning/utils@1.10.0
|
|
31
|
+
|
|
32
|
+
## 1.8.6
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#771](https://github.com/OpenCloning/OpenCloning_frontend/pull/771) [`73363e7`](https://github.com/OpenCloning/OpenCloning_frontend/commit/73363e7a7f7e494e20a54bd87e5dba97f8a9197e) Thanks [@manulera](https://github.com/manulera)! - Keep OIDC sessions signed in by requesting a token on each API call instead of reusing a stored JWT
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [[`73363e7`](https://github.com/OpenCloning/OpenCloning_frontend/commit/73363e7a7f7e494e20a54bd87e5dba97f8a9197e)]:
|
|
39
|
+
- @opencloning/utils@1.9.5
|
|
40
|
+
- @opencloning/ui@1.9.5
|
|
41
|
+
|
|
42
|
+
## 1.8.5
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies []:
|
|
47
|
+
- @opencloning/ui@1.9.4
|
|
48
|
+
- @opencloning/utils@1.9.4
|
|
49
|
+
|
|
50
|
+
## 1.8.4
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#741](https://github.com/OpenCloning/OpenCloning_frontend/pull/741) [`c65f24a`](https://github.com/OpenCloning/OpenCloning_frontend/commit/c65f24ae853b45005e9a7f429236b8b8d7ea84fa) Thanks [@manulera](https://github.com/manulera)! - Add workspace functionality to add and remove users by owners
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [[`df69a1b`](https://github.com/OpenCloning/OpenCloning_frontend/commit/df69a1bfb3b3128e93d89eef48a29f81a54ebb82)]:
|
|
57
|
+
- @opencloning/utils@1.9.3
|
|
58
|
+
- @opencloning/ui@1.9.3
|
|
59
|
+
|
|
60
|
+
## 1.8.3
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- [#732](https://github.com/OpenCloning/OpenCloning_frontend/pull/732) [`cb5ddf4`](https://github.com/OpenCloning/OpenCloning_frontend/commit/cb5ddf4502a288357f8f853242fb35e5ad2a2207) Thanks [@manulera](https://github.com/manulera)! - Create lines from button in list, enables reference strain + transformation + mating
|
|
65
|
+
|
|
66
|
+
- [#732](https://github.com/OpenCloning/OpenCloning_frontend/pull/732) [`cb5ddf4`](https://github.com/OpenCloning/OpenCloning_frontend/commit/cb5ddf4502a288357f8f853242fb35e5ad2a2207) Thanks [@manulera](https://github.com/manulera)! - Auto-select new tag when creating it
|
|
67
|
+
|
|
68
|
+
- [#737](https://github.com/OpenCloning/OpenCloning_frontend/pull/737) [`b40f86f`](https://github.com/OpenCloning/OpenCloning_frontend/commit/b40f86fc3219d6016d8d5c8390b171affc8987f8) Thanks [@manulera](https://github.com/manulera)! - Add button for bulk-download to text files
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [[`06bb1a5`](https://github.com/OpenCloning/OpenCloning_frontend/commit/06bb1a513519f598e9ec3b5eec73544e2ed3958e), [`bc045f9`](https://github.com/OpenCloning/OpenCloning_frontend/commit/bc045f9e74b4d5b84250dcb5a77b93de99e4d684)]:
|
|
71
|
+
- @opencloning/ui@1.9.2
|
|
72
|
+
- @opencloning/utils@1.9.2
|
|
73
|
+
|
|
3
74
|
## 1.8.2
|
|
4
75
|
|
|
5
76
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"license": "MIT",
|
|
3
3
|
"name": "@opencloning/opencloningdb",
|
|
4
|
-
"version": "1.8.
|
|
4
|
+
"version": "1.8.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@mui/icons-material": "^5.18.0",
|
|
17
17
|
"@mui/material": "^5.18.0",
|
|
18
|
-
"@opencloning/ui": "
|
|
19
|
-
"@opencloning/utils": "
|
|
20
|
-
"axios": "^1.
|
|
18
|
+
"@opencloning/ui": "2.0.0",
|
|
19
|
+
"@opencloning/utils": "2.0.0",
|
|
20
|
+
"axios": "^1.20.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^18.3.1",
|
|
@@ -29,6 +29,7 @@ describe('<GetSequenceFileAndDatabaseIdComponent />', () => {
|
|
|
29
29
|
cy.setupOpenCloningDBTestAuth();
|
|
30
30
|
|
|
31
31
|
cy.interceptOpenCloningDBStub('get_sequences_search_by_name', { alias: 'getSequences' });
|
|
32
|
+
cy.interceptOpenCloningDBStub('get_sequences_search_by_name_uid_query', { alias: 'getSequencesByNameUidQuery' });
|
|
32
33
|
cy.interceptOpenCloningDBStub('get_text_file_sequence', { alias: 'getSequenceFile' });
|
|
33
34
|
|
|
34
35
|
cy.mount(
|
|
@@ -57,6 +58,7 @@ describe('<GetSequenceFileAndDatabaseIdComponent />', () => {
|
|
|
57
58
|
|
|
58
59
|
cy.setupOpenCloningDBTestAuth();
|
|
59
60
|
cy.interceptOpenCloningDBStub('get_sequences_search_by_name', { alias: 'getSequences' });
|
|
61
|
+
cy.interceptOpenCloningDBStub('get_sequences_search_by_name_uid_query', { alias: 'getSequencesByNameUidQuery' });
|
|
60
62
|
|
|
61
63
|
cy.getStub('get_text_file_sequence').then((textFileSequenceStub) => {
|
|
62
64
|
let callCount = 0;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import endpoints from './endpoints';
|
|
2
3
|
import SequenceSelect from './SequenceSelect';
|
|
3
4
|
import { clickMultiSelectOption } from '../../../cypress/e2e/common_functions';
|
|
4
5
|
|
|
5
6
|
const SEQUENCE_NAME = 'ase1_CDS_PCR';
|
|
7
|
+
const SEQUENCE_UID = 'example_sequencing-sample';
|
|
6
8
|
|
|
7
9
|
describe('<SequenceSelect />', () => {
|
|
8
|
-
it('searches for a sequence and shows results', () => {
|
|
10
|
+
it('searches for a sequence by name and shows results', () => {
|
|
9
11
|
cy.setupOpenCloningDBTestAuth();
|
|
10
12
|
const onChangeSpy = cy.spy().as('onChangeSpy');
|
|
11
13
|
|
|
12
14
|
cy.interceptOpenCloningDBStub('get_sequences_search_by_name', { alias: 'getSequences' });
|
|
15
|
+
cy.interceptOpenCloningDBStub('get_sequences_search_by_name_uid_query', { alias: 'getSequencesByUid' });
|
|
13
16
|
|
|
14
17
|
cy.mount(
|
|
15
18
|
<SequenceSelect label="Sequence" onChange={onChangeSpy} multiple={false} />
|
|
@@ -29,4 +32,31 @@ describe('<SequenceSelect />', () => {
|
|
|
29
32
|
|
|
30
33
|
cy.get('input').should('have.value', SEQUENCE_NAME);
|
|
31
34
|
});
|
|
35
|
+
it('searches for a sequence by uid and shows results', () => {
|
|
36
|
+
cy.setupOpenCloningDBTestAuth();
|
|
37
|
+
const onChangeSpy = cy.spy().as('onChangeSpy');
|
|
38
|
+
|
|
39
|
+
cy.interceptOpenCloningDBStub('get_sequences_search_by_uid', { alias: 'getSequencesByUid' });
|
|
40
|
+
cy.interceptOpenCloningDBStub('get_sequences_search_by_uid_name_query', { alias: 'getSequencesByName' });
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
cy.mount(
|
|
44
|
+
<SequenceSelect label="Sequence" onChange={onChangeSpy} multiple={false} />
|
|
45
|
+
);
|
|
46
|
+
cy.get('input').click();
|
|
47
|
+
cy.contains('Type at least').should('exist');
|
|
48
|
+
cy.get('input').type(SEQUENCE_UID);
|
|
49
|
+
cy.get('.MuiAutocomplete-listbox li', { timeout: 10000 }).should('have.length.greaterThan', 0);
|
|
50
|
+
|
|
51
|
+
// We need to incercept, because it will submit the value of combined name + uid which is not in a stub
|
|
52
|
+
cy.intercept('GET', Cypress.getDbURL(endpoints.sequences, '*'), { statusCode: 200, body: { items: [] } }).as('getSequences2');
|
|
53
|
+
clickMultiSelectOption('Sequence', SEQUENCE_UID, 'div');
|
|
54
|
+
|
|
55
|
+
cy.getStub('get_sequences_search_by_uid').then((stub) => {
|
|
56
|
+
const stubSequence = stub.response.body.items.find((sequence) => sequence.sample_uids.includes(SEQUENCE_UID));
|
|
57
|
+
expect(stubSequence).to.exist;
|
|
58
|
+
cy.get('@onChangeSpy').should('have.been.calledWith', stubSequence);
|
|
59
|
+
cy.get('input').should('have.value', `${stubSequence.name} (${SEQUENCE_UID})`);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
32
62
|
});
|
package/src/SequenceSelect.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { QuerySelect, useDebouncedSearchQuery } from '@opencloning/ui';
|
|
3
|
-
import { openCloningDBHttpClient } from './common';
|
|
3
|
+
import { formatSequenceName, openCloningDBHttpClient } from './common';
|
|
4
4
|
import endpoints from './endpoints';
|
|
5
5
|
|
|
6
6
|
const messages = {
|
|
@@ -8,19 +8,25 @@ const messages = {
|
|
|
8
8
|
errorMessage: 'Could not retrieve sequences from OpenCloningDB',
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
const getGetQuery = (sequenceTypes) => {
|
|
12
|
-
return (
|
|
13
|
-
queryKey: ['sequences', { sequence_types: sequenceTypes,
|
|
13
|
+
return (query) => ({
|
|
14
|
+
queryKey: ['sequences', { sequence_types: sequenceTypes, query }],
|
|
14
15
|
queryFn: async () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const results = await Promise.all([
|
|
17
|
+
openCloningDBHttpClient.get(endpoints.sequences, {
|
|
18
|
+
params: { sequence_types: sequenceTypes, uid: query },
|
|
19
|
+
}),
|
|
20
|
+
openCloningDBHttpClient.get(endpoints.sequences, {
|
|
21
|
+
params: { sequence_types: sequenceTypes, name: query },
|
|
22
|
+
}),
|
|
23
|
+
]);
|
|
24
|
+
return [...results[0].data.items, ...results[1].data.items];
|
|
19
25
|
},
|
|
20
26
|
})};
|
|
21
27
|
|
|
22
28
|
function SequenceSelect({ value, onChange, label, multiple = true, sequenceTypes = undefined, ...rest }) {
|
|
23
|
-
const { query, autocompleteProps, clearInput } = useDebouncedSearchQuery(getGetQuery(sequenceTypes));
|
|
29
|
+
const { query, autocompleteProps, clearInput } = useDebouncedSearchQuery(getGetQuery(sequenceTypes), {minChars: 1});
|
|
24
30
|
|
|
25
31
|
return (
|
|
26
32
|
<QuerySelect
|
|
@@ -29,7 +35,7 @@ function SequenceSelect({ value, onChange, label, multiple = true, sequenceTypes
|
|
|
29
35
|
loadingMessage={messages.loadingMessage}
|
|
30
36
|
errorMessage={messages.errorMessage}
|
|
31
37
|
multiple={multiple}
|
|
32
|
-
getOptionLabel={
|
|
38
|
+
getOptionLabel={formatSequenceName}
|
|
33
39
|
getOptionKey={(seq) => seq.id}
|
|
34
40
|
value={value}
|
|
35
41
|
onChange={onChange}
|
package/src/common.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { attachAuthInterceptors, setHttpClientUnauthorizedHandler } from '@opencloning/utils/httpClientAuth';
|
|
2
|
+
import { attachAuthInterceptors, setHttpClientTokenGetter, setHttpClientUnauthorizedHandler } from '@opencloning/utils/httpClientAuth';
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const baseUrl = `${import.meta.env?.VITE_OPENCLONING_DB_BACKEND || 'http://localhost:8000'}/db`;
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export {
|
|
8
|
+
setHttpClientTokenGetter,
|
|
9
|
+
setHttpClientUnauthorizedHandler as setUnauthorizedHandler,
|
|
10
|
+
};
|
|
8
11
|
|
|
9
12
|
export function setWorkspaceHeader(id) {
|
|
10
13
|
openCloningDBHttpClient.defaults.headers.common['X-Workspace-Id'] = id;
|
|
@@ -16,6 +19,8 @@ export function clearWorkspaceHeader() {
|
|
|
16
19
|
|
|
17
20
|
export const openCloningDBHttpClient = axios.create({
|
|
18
21
|
baseURL: baseUrl,
|
|
22
|
+
// Every url is appended to baseURL, so requests (and the auth token) only reach the backend
|
|
23
|
+
allowAbsoluteUrls: false,
|
|
19
24
|
paramsSerializer: (params) => {
|
|
20
25
|
const searchParams = new URLSearchParams();
|
|
21
26
|
|
|
@@ -40,3 +45,12 @@ export const openCloningDBHttpClient = axios.create({
|
|
|
40
45
|
});
|
|
41
46
|
|
|
42
47
|
attachAuthInterceptors(openCloningDBHttpClient);
|
|
48
|
+
|
|
49
|
+
export function formatSequenceName({ id, name, sample_uids: sampleUids }) {
|
|
50
|
+
if (!name) return `Sequence ${id}`;
|
|
51
|
+
let out = name;
|
|
52
|
+
if (sampleUids && sampleUids.length > 0) {
|
|
53
|
+
out += ` (${sampleUids.join(', ')})`;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
package/src/common.test.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
baseUrl,
|
|
5
5
|
clearWorkspaceHeader,
|
|
6
6
|
openCloningDBHttpClient,
|
|
7
|
+
setHttpClientTokenGetter,
|
|
7
8
|
setUnauthorizedHandler,
|
|
8
9
|
setWorkspaceHeader,
|
|
9
10
|
} from './common';
|
|
@@ -13,15 +14,15 @@ const responseFulfilled = openCloningDBHttpClient.interceptors.response.handlers
|
|
|
13
14
|
const responseRejected = openCloningDBHttpClient.interceptors.response.handlers[0].rejected;
|
|
14
15
|
|
|
15
16
|
beforeEach(() => {
|
|
16
|
-
localStorage.clear();
|
|
17
17
|
clearWorkspaceHeader();
|
|
18
18
|
setUnauthorizedHandler(null);
|
|
19
|
+
setHttpClientTokenGetter(null);
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
afterEach(() => {
|
|
22
|
-
localStorage.clear();
|
|
23
23
|
clearWorkspaceHeader();
|
|
24
24
|
setUnauthorizedHandler(null);
|
|
25
|
+
setHttpClientTokenGetter(null);
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
describe('common', () => {
|
|
@@ -55,20 +56,20 @@ describe('common', () => {
|
|
|
55
56
|
expect(openCloningDBHttpClient.defaults.paramsSerializer()).toBe('');
|
|
56
57
|
});
|
|
57
58
|
|
|
58
|
-
it('adds the bearer token
|
|
59
|
-
|
|
59
|
+
it('adds the bearer token from the registered token getter', async () => {
|
|
60
|
+
setHttpClientTokenGetter(() => '__TEST_TOKEN__');
|
|
60
61
|
const config = { headers: {} };
|
|
61
62
|
|
|
62
|
-
const result = requestFulfilled(config);
|
|
63
|
+
const result = await requestFulfilled(config);
|
|
63
64
|
|
|
64
65
|
expect(result).toBe(config);
|
|
65
66
|
expect(config.headers.Authorization).toBe('Bearer __TEST_TOKEN__');
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
it('leaves request headers unchanged when
|
|
69
|
+
it('leaves request headers unchanged when no token getter is set', async () => {
|
|
69
70
|
const config = { headers: {} };
|
|
70
71
|
|
|
71
|
-
const result = requestFulfilled(config);
|
|
72
|
+
const result = await requestFulfilled(config);
|
|
72
73
|
|
|
73
74
|
expect(result).toBe(config);
|
|
74
75
|
expect(config.headers.Authorization).toBeUndefined();
|
package/src/endpoints.js
CHANGED
|
@@ -1,52 +1,59 @@
|
|
|
1
|
+
import { encodePathSegment as e } from '@opencloning/utils/urlUtils';
|
|
2
|
+
|
|
3
|
+
// Every interpolated value is encoded to prevent client-side path traversal
|
|
4
|
+
// (e.g. a sample uid like "../workspaces/1/users/5").
|
|
1
5
|
const endpoints = {
|
|
2
6
|
sequences: '/sequences',
|
|
3
|
-
sequence: (id) => `/sequences/${id}`,
|
|
4
|
-
sequenceTextFile: (id) => `/sequences/${id}/text_file_sequence`,
|
|
5
|
-
sequenceChangeAnnotation: (id) => `/sequences/${id}/change_annotation`,
|
|
6
|
-
sequenceCloningStrategy: (id) => `/sequences/${id}/cloning_strategy`,
|
|
7
|
-
sequenceChildren: (id) => `/sequences/${id}/children`,
|
|
8
|
-
sequenceLines: (id) => `/sequences/${id}/lines`,
|
|
9
|
-
sequenceChangeCircularity: (id) => `/sequences/${id}/change_circularity`,
|
|
10
|
-
sequencePrimers: (id) => `/sequences/${id}/primers`,
|
|
11
|
-
sequenceSequencingFiles: (id) => `/sequences/${id}/sequencing_files`,
|
|
7
|
+
sequence: (id) => `/sequences/${e(id)}`,
|
|
8
|
+
sequenceTextFile: (id) => `/sequences/${e(id)}/text_file_sequence`,
|
|
9
|
+
sequenceChangeAnnotation: (id) => `/sequences/${e(id)}/change_annotation`,
|
|
10
|
+
sequenceCloningStrategy: (id) => `/sequences/${e(id)}/cloning_strategy`,
|
|
11
|
+
sequenceChildren: (id) => `/sequences/${e(id)}/children`,
|
|
12
|
+
sequenceLines: (id) => `/sequences/${e(id)}/lines`,
|
|
13
|
+
sequenceChangeCircularity: (id) => `/sequences/${e(id)}/change_circularity`,
|
|
14
|
+
sequencePrimers: (id) => `/sequences/${e(id)}/primers`,
|
|
15
|
+
sequenceSequencingFiles: (id) => `/sequences/${e(id)}/sequencing_files`,
|
|
12
16
|
sequenceSearch: '/sequences/search',
|
|
13
17
|
sequencesValidateUpload: '/sequences/validate-upload',
|
|
14
18
|
sequencesBulk: '/sequences/bulk',
|
|
15
19
|
sequencesCloningStrategyBulkValidate: '/sequences/cloning_strategy/bulk/validate',
|
|
16
20
|
sequencesCloningStrategyBulk: '/sequences/cloning_strategy/bulk',
|
|
17
|
-
sequencingFileDownload: (id) => `/sequencing_files/${id}/download`,
|
|
18
|
-
sequenceSequencingFileDelete: (sequenceId, fileId) => `/sequences/${sequenceId}/sequencing_files/${fileId}`,
|
|
21
|
+
sequencingFileDownload: (id) => `/sequencing_files/${e(id)}/download`,
|
|
22
|
+
sequenceSequencingFileDelete: (sequenceId, fileId) => `/sequences/${e(sequenceId)}/sequencing_files/${e(fileId)}`,
|
|
19
23
|
postSequence: '/sequences',
|
|
20
24
|
primers: '/primers',
|
|
21
25
|
primersValidateUpload: '/primers/validate-upload',
|
|
22
26
|
primersBulk: '/primers/bulk',
|
|
23
|
-
primer: (id) => `/primers/${id}`,
|
|
24
|
-
primerTemplateSequences: (id) => `/primers/${id}/sequences`,
|
|
27
|
+
primer: (id) => `/primers/${e(id)}`,
|
|
28
|
+
primerTemplateSequences: (id) => `/primers/${e(id)}/sequences`,
|
|
25
29
|
postPrimer: '/primers',
|
|
26
30
|
lines: '/lines',
|
|
27
|
-
line: (id) => `/lines/${id}`,
|
|
28
|
-
lineChildren: (id) => `/lines/${id}/children`,
|
|
29
|
-
lineTags: (id) => `/lines/${id}/tags`,
|
|
30
|
-
inputEntityTags: (id) => `/input_entities/${id}/tags`,
|
|
31
|
+
line: (id) => `/lines/${e(id)}`,
|
|
32
|
+
lineChildren: (id) => `/lines/${e(id)}/children`,
|
|
33
|
+
lineTags: (id) => `/lines/${e(id)}/tags`,
|
|
34
|
+
inputEntityTags: (id) => `/input_entities/${e(id)}/tags`,
|
|
31
35
|
postLine: '/lines',
|
|
32
36
|
linesValidateUpload: '/lines/validate-upload',
|
|
33
37
|
linesBulk: '/lines/bulk',
|
|
34
38
|
tags: '/tags',
|
|
35
39
|
tagPost: '/tags',
|
|
36
|
-
tagUnlinkLine: (lineId, tagId) => `/lines/${lineId}/tags/${tagId}`,
|
|
37
|
-
tagUnlinkInputEntity: (inputEntityId, tagId) => `/input_entities/${inputEntityId}/tags/${tagId}`,
|
|
40
|
+
tagUnlinkLine: (lineId, tagId) => `/lines/${e(lineId)}/tags/${e(tagId)}`,
|
|
41
|
+
tagUnlinkInputEntity: (inputEntityId, tagId) => `/input_entities/${e(inputEntityId)}/tags/${e(tagId)}`,
|
|
38
42
|
sequenceSamples: '/sequence_samples',
|
|
39
43
|
postSequenceSample: '/sequence_samples',
|
|
40
|
-
sequenceSample: (uid) => `/sequence_samples/${uid}`,
|
|
44
|
+
sequenceSample: (uid) => `/sequence_samples/${e(uid)}`,
|
|
41
45
|
authToken: '/auth/token',
|
|
42
46
|
authRegister: '/auth/register',
|
|
43
47
|
authMe: '/auth/me',
|
|
44
48
|
workspaces: '/workspaces',
|
|
45
49
|
postWorkspace: '/workspaces',
|
|
46
|
-
workspace: (id) => `/workspaces/${id}`,
|
|
50
|
+
workspace: (id) => `/workspaces/${e(id)}`,
|
|
51
|
+
workspaceUsers: (id) => `/workspaces/${e(id)}/users`,
|
|
52
|
+
workspaceUser: (workspaceId, userId) => `/workspaces/${e(workspaceId)}/users/${e(userId)}`,
|
|
47
53
|
templateSequences: '/template_sequences',
|
|
48
54
|
templateSequencesValidateUpload: '/template_sequences/validate-upload',
|
|
49
55
|
templateSequencesBulk: '/template_sequences/bulk',
|
|
56
|
+
export: '/export',
|
|
50
57
|
};
|
|
51
58
|
|
|
52
59
|
export default endpoints;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import endpoints from './endpoints';
|
|
4
|
+
|
|
5
|
+
describe('endpoints', () => {
|
|
6
|
+
it('encodes path parameters so they cannot change the request path', () => {
|
|
7
|
+
expect(endpoints.sequenceSample('../workspaces/1/users/5')).toBe('/sequence_samples/..%2Fworkspaces%2F1%2Fusers%2F5');
|
|
8
|
+
expect(endpoints.primer('1/../../workspaces/2')).toBe('/primers/1%2F..%2F..%2Fworkspaces%2F2');
|
|
9
|
+
expect(() => endpoints.sequenceSample('..')).toThrow();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('keeps normal ids unchanged', () => {
|
|
13
|
+
expect(endpoints.sequence(12)).toBe('/sequences/12');
|
|
14
|
+
expect(endpoints.sequenceSequencingFileDelete(3, 4)).toBe('/sequences/3/sequencing_files/4');
|
|
15
|
+
expect(endpoints.sequenceSample('ML-7_a')).toBe('/sequence_samples/ML-7_a');
|
|
16
|
+
});
|
|
17
|
+
});
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as OpenCloningDBInterface } from './OpenCloningDBInterface.js';
|
|
2
|
-
export { openCloningDBHttpClient, setUnauthorizedHandler, setWorkspaceHeader, clearWorkspaceHeader, baseUrl } from './common.js';
|
|
2
|
+
export { openCloningDBHttpClient, setUnauthorizedHandler, setHttpClientTokenGetter, setWorkspaceHeader, clearWorkspaceHeader, baseUrl, formatSequenceName } from './common.js';
|
|
3
3
|
export { default as endpoints } from './endpoints.js';
|
|
4
4
|
export { default as SequenceSelect } from './SequenceSelect.jsx';
|
package/src/testUtils.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { http, HttpResponse } from 'msw';
|
|
3
3
|
import { describe, expect, it } from 'vitest';
|
|
4
|
-
import { baseUrl } from './common';
|
|
4
|
+
import { baseUrl, setHttpClientTokenGetter } from './common';
|
|
5
5
|
|
|
6
6
|
const STUB_FOLDER = `${__dirname}/../../../OpenCloning_backend/stubs/db`;
|
|
7
7
|
|
|
@@ -75,11 +75,11 @@ export function addStubToServer(server, stub) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export function setupToken() {
|
|
78
|
-
|
|
78
|
+
setHttpClientTokenGetter(() => '__TEST_TOKEN__');
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function clearToken() {
|
|
82
|
-
|
|
82
|
+
setHttpClientTokenGetter(null);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
describe('test utility module', () => {
|