@openneuro/server 4.1.1 → 4.2.2
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 +6 -6
- package/src/graphql/resolvers/__tests__/dataset.spec.js +29 -0
- package/src/graphql/resolvers/__tests__/snapshots.spec.js +31 -1
- package/src/graphql/resolvers/snapshots.js +25 -17
- package/src/routes.js +0 -15
- package/src/handlers/feature-flags.js +0 -12
- package/yarn-error.log +0 -24423
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
},
|
|
17
17
|
"author": "Squishymedia",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@apollo/client": "3.
|
|
20
|
-
"@elastic/elasticsearch": "
|
|
19
|
+
"@apollo/client": "3.4.17",
|
|
20
|
+
"@elastic/elasticsearch": "7.15.0",
|
|
21
21
|
"@passport-next/passport-google-oauth2": "^1.0.0",
|
|
22
22
|
"@sentry/node": "^4.5.3",
|
|
23
|
-
"apollo-server": "2.
|
|
23
|
+
"apollo-server": "2.25.3",
|
|
24
24
|
"apollo-server-cache-redis": "1.4.0",
|
|
25
|
-
"apollo-server-express": "2.
|
|
25
|
+
"apollo-server-express": "2.25.3",
|
|
26
26
|
"async": "^2.4.1",
|
|
27
27
|
"base64url": "^3.0.0",
|
|
28
28
|
"body-parser": "^1.18.2",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "01f040e1d24d05b35ee769fd41593a9d2ebd6346"
|
|
108
108
|
}
|
|
@@ -114,6 +114,35 @@ describe('dataset resolvers', () => {
|
|
|
114
114
|
expect(sorted[1].id).toBe('ds002680:1.1.0')
|
|
115
115
|
expect(sorted[2].id).toBe('ds002680:1.2.0')
|
|
116
116
|
})
|
|
117
|
+
it('sorts 000002 (legacy snapshots) before 1.0.1 (current format)', () => {
|
|
118
|
+
const testSnapshots = [
|
|
119
|
+
{
|
|
120
|
+
id: 'ds000247:00002',
|
|
121
|
+
created: '2018-07-18T02:27:39.000Z',
|
|
122
|
+
tag: '00002',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'ds000247:00001',
|
|
126
|
+
created: '2018-07-18T02:35:37.000Z',
|
|
127
|
+
tag: '00001',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'ds000247:1.0.0',
|
|
131
|
+
created: '2021-07-05T15:58:18.000Z',
|
|
132
|
+
tag: '1.0.0',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: 'ds000247:1.0.1',
|
|
136
|
+
created: '2021-08-25T23:37:53.000Z',
|
|
137
|
+
tag: '1.0.1',
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
const sorted = testSnapshots.sort(ds.snapshotCreationComparison)
|
|
141
|
+
expect(sorted[0].id).toBe('ds000247:00002')
|
|
142
|
+
expect(sorted[1].id).toBe('ds000247:00001')
|
|
143
|
+
expect(sorted[2].id).toBe('ds000247:1.0.0')
|
|
144
|
+
expect(sorted[3].id).toBe('ds000247:1.0.1')
|
|
145
|
+
})
|
|
117
146
|
})
|
|
118
147
|
describe('deleteFiles', () => {
|
|
119
148
|
beforeEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
jest.mock('../../../config')
|
|
2
|
-
import { matchKnownObjects } from '../snapshots.js'
|
|
2
|
+
import { matchKnownObjects, filterLatestSnapshot } from '../snapshots.js'
|
|
3
3
|
|
|
4
4
|
describe('snapshot resolvers', () => {
|
|
5
5
|
describe('matchKnownObjects()', () => {
|
|
@@ -23,4 +23,34 @@ describe('snapshot resolvers', () => {
|
|
|
23
23
|
])
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
|
+
describe('filterLatestSnapshot()', () => {
|
|
27
|
+
it('returns the latest snapshot', () => {
|
|
28
|
+
const testSnapshots = [
|
|
29
|
+
{
|
|
30
|
+
id: 'ds000247:00002',
|
|
31
|
+
created: '2018-07-18T02:27:39.000Z',
|
|
32
|
+
tag: '00002',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'ds000247:00001',
|
|
36
|
+
created: '2018-07-18T02:35:37.000Z',
|
|
37
|
+
tag: '00001',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'ds000247:1.0.0',
|
|
41
|
+
created: '2021-07-05T15:58:18.000Z',
|
|
42
|
+
tag: '1.0.0',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'ds000247:1.0.1',
|
|
46
|
+
created: '2021-08-25T23:37:53.000Z',
|
|
47
|
+
tag: '1.0.1',
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
expect(filterLatestSnapshot(testSnapshots)).toBe('1.0.1')
|
|
51
|
+
})
|
|
52
|
+
it('returns null with no snapshots', () => {
|
|
53
|
+
expect(filterLatestSnapshot([])).toBeNull()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
26
56
|
})
|
|
@@ -176,23 +176,31 @@ export const participantCount = (obj, { modality }) => {
|
|
|
176
176
|
})
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
179
|
+
/**
|
|
180
|
+
* Select the most recent snapshot from an array of snapshots
|
|
181
|
+
* @param {*} snapshots Array of snapshot objects from datalad.getSnapshots
|
|
182
|
+
*/
|
|
183
|
+
export const filterLatestSnapshot = snapshots => {
|
|
184
|
+
if (snapshots.length) {
|
|
185
|
+
const sortedSnapshots = Array.prototype.sort.call(
|
|
186
|
+
snapshots,
|
|
187
|
+
snapshotCreationComparison,
|
|
188
|
+
)
|
|
189
|
+
return sortedSnapshots[sortedSnapshots.length - 1].tag
|
|
190
|
+
} else {
|
|
191
|
+
return null
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const latestSnapshot = async (obj, _, context) => {
|
|
196
|
+
const snapshots = await datalad.getSnapshots(obj.id)
|
|
197
|
+
const snapshotTag = filterLatestSnapshot(snapshots)
|
|
198
|
+
if (snapshotTag) {
|
|
199
|
+
return await snapshot(obj, { datasetId: obj.id, tag: snapshotTag }, context)
|
|
200
|
+
} else {
|
|
201
|
+
// In the case where there are no real snapshots, return HEAD as a snapshot
|
|
202
|
+
return await snapshot(obj, { datasetId: obj.id, tag: 'HEAD' }, context)
|
|
203
|
+
}
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
/**
|
package/src/routes.js
CHANGED
|
@@ -6,10 +6,6 @@ import * as datalad from './handlers/datalad'
|
|
|
6
6
|
import * as comments from './handlers/comments'
|
|
7
7
|
import { clientConfig } from './handlers/config.js'
|
|
8
8
|
import * as subscriptions from './handlers/subscriptions'
|
|
9
|
-
import {
|
|
10
|
-
setFlagRedesign2021,
|
|
11
|
-
unsetFlagRedesign2021,
|
|
12
|
-
} from './handlers/feature-flags'
|
|
13
9
|
import verifyUser from './libs/authentication/verifyUser.js'
|
|
14
10
|
import * as google from './libs/authentication/google.js'
|
|
15
11
|
import * as orcid from './libs/authentication/orcid.js'
|
|
@@ -169,17 +165,6 @@ const routes = [
|
|
|
169
165
|
url: '/sitemap',
|
|
170
166
|
handler: sitemapHandler,
|
|
171
167
|
},
|
|
172
|
-
// feature flag setters and unsetters
|
|
173
|
-
{
|
|
174
|
-
method: 'get',
|
|
175
|
-
url: '/feature/redesign-2021/enable',
|
|
176
|
-
handler: unsetFlagRedesign2021,
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
method: 'get',
|
|
180
|
-
url: '/feature/redesign-2021/disable',
|
|
181
|
-
handler: setFlagRedesign2021,
|
|
182
|
-
},
|
|
183
168
|
]
|
|
184
169
|
|
|
185
170
|
// initialize routes -------------------------------
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const feature = {
|
|
2
|
-
REDESIGN_2021: 'redesign-classic',
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export const setFlagRedesign2021 = (req, res) => {
|
|
6
|
-
res.cookie(feature.REDESIGN_2021, true).redirect('/')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const unsetFlagRedesign2021 = (req, res) => {
|
|
10
|
-
res.clearCookie(feature.REDESIGN_2021)
|
|
11
|
-
res.redirect('/')
|
|
12
|
-
}
|