@openneuro/server 4.5.1 → 4.6.0-alpha.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0-alpha.0",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@apollo/client": "3.4.17",
|
|
20
20
|
"@elastic/elasticsearch": "7.15.0",
|
|
21
|
+
"@openneuro/search": "^4.6.0-alpha.0",
|
|
21
22
|
"@passport-next/passport-google-oauth2": "^1.0.0",
|
|
22
23
|
"@sentry/node": "^4.5.3",
|
|
23
24
|
"apollo-server": "2.25.3",
|
|
@@ -104,5 +105,5 @@
|
|
|
104
105
|
"publishConfig": {
|
|
105
106
|
"access": "public"
|
|
106
107
|
},
|
|
107
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "ce2db27f750c2614e9cf2f0461add04ca8c3cb48"
|
|
108
109
|
}
|
package/src/datalad/snapshots.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Get snapshots from datalad-service tags
|
|
3
3
|
*/
|
|
4
4
|
import request from 'superagent'
|
|
5
|
+
import { reindexDataset } from '../elasticsearch/reindex-dataset'
|
|
5
6
|
import { redis, redlock } from '../libs/redis'
|
|
6
7
|
import CacheItem, { CacheType } from '../cache/item'
|
|
7
8
|
import config from '../config.js'
|
|
@@ -169,15 +170,17 @@ export const createSnapshot = async (
|
|
|
169
170
|
updateDatasetName(datasetId),
|
|
170
171
|
])
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
await reindexDataset(datasetId)
|
|
174
|
+
|
|
173
175
|
announceNewSnapshot(snapshot, datasetId, user)
|
|
174
176
|
return snapshot
|
|
175
177
|
} catch (err) {
|
|
176
178
|
// delete the keys if any step fails
|
|
177
179
|
// this avoids inconsistent cache state after failures
|
|
178
180
|
snapshotCache.drop()
|
|
179
|
-
snapshotLock.unlock()
|
|
180
181
|
return err
|
|
182
|
+
} finally {
|
|
183
|
+
snapshotLock.unlock()
|
|
181
184
|
}
|
|
182
185
|
}
|
|
183
186
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { indexDataset, queryForIndex, indexingToken } from '@openneuro/search'
|
|
2
|
+
import { elasticClient } from './elastic-client'
|
|
3
|
+
import {
|
|
4
|
+
from,
|
|
5
|
+
ApolloClient,
|
|
6
|
+
InMemoryCache,
|
|
7
|
+
NormalizedCacheObject,
|
|
8
|
+
} from '@apollo/client'
|
|
9
|
+
import { setContext } from '@apollo/client/link/context'
|
|
10
|
+
import { HttpLink } from '@apollo/client/link/http'
|
|
11
|
+
import fetch from 'node-fetch'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Setup SchemaLink based client for querying
|
|
15
|
+
*/
|
|
16
|
+
export const schemaLinkClient = (): ApolloClient<NormalizedCacheObject> => {
|
|
17
|
+
const accessToken = indexingToken()
|
|
18
|
+
const authLink = setContext((_, { headers }) => {
|
|
19
|
+
return {
|
|
20
|
+
headers: {
|
|
21
|
+
...headers,
|
|
22
|
+
Cookie: `accessToken=${accessToken}`,
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
const httpLink = new HttpLink({
|
|
27
|
+
uri: process.env.GRAPHQL_URI,
|
|
28
|
+
fetch,
|
|
29
|
+
})
|
|
30
|
+
return new ApolloClient({
|
|
31
|
+
link: from([authLink, httpLink]),
|
|
32
|
+
cache: new InMemoryCache(),
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const client = schemaLinkClient()
|
|
37
|
+
|
|
38
|
+
export const reindexDataset = async (datasetId: string): Promise<void> => {
|
|
39
|
+
const datasetIndexQueryResult = await queryForIndex(client, datasetId)
|
|
40
|
+
await indexDataset(elasticClient, datasetIndexQueryResult.data.dataset)
|
|
41
|
+
}
|
package/tsconfig.json
CHANGED
package/jestsetup.js
DELETED
|
File without changes
|