@openneuro/server 4.44.5 → 4.44.7
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 +3 -3
- package/src/datalad/analytics.ts +0 -6
- package/src/datalad/dataset.ts +2 -25
- package/src/datalad/snapshots.ts +19 -7
- package/src/graphql/resolvers/dataset.ts +2 -1
- package/src/graphql/resolvers/datasetType.ts +4 -2
- package/src/graphql/resolvers/snapshots.ts +2 -2
- package/src/sentry.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/server",
|
|
3
|
-
"version": "4.44.
|
|
3
|
+
"version": "4.44.7",
|
|
4
4
|
"description": "Core service for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@elastic/elasticsearch": "8.13.1",
|
|
22
22
|
"@graphql-tools/schema": "^10.0.0",
|
|
23
23
|
"@keyv/redis": "^4.5.0",
|
|
24
|
-
"@openneuro/search": "^4.44.
|
|
24
|
+
"@openneuro/search": "^4.44.7",
|
|
25
25
|
"@sentry/node": "^10.37.0",
|
|
26
26
|
"@sentry/profiling-node": "^10.37.0",
|
|
27
27
|
"base64url": "^3.0.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "83fbb6f05dfcb66981ca52e3c2f8bda1c88380b8"
|
|
93
93
|
}
|
package/src/datalad/analytics.ts
CHANGED
|
@@ -17,9 +17,6 @@ export const trackAnalytics = async (datasetId, tag, type) => {
|
|
|
17
17
|
views: 1,
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
{
|
|
21
|
-
upsert: true,
|
|
22
|
-
},
|
|
23
20
|
).exec()
|
|
24
21
|
} else if (type === "downloads") {
|
|
25
22
|
return Dataset.updateOne(
|
|
@@ -31,9 +28,6 @@ export const trackAnalytics = async (datasetId, tag, type) => {
|
|
|
31
28
|
downloads: 1,
|
|
32
29
|
},
|
|
33
30
|
},
|
|
34
|
-
{
|
|
35
|
-
upsert: true,
|
|
36
|
-
},
|
|
37
31
|
).exec()
|
|
38
32
|
}
|
|
39
33
|
}
|
package/src/datalad/dataset.ts
CHANGED
|
@@ -14,7 +14,7 @@ import * as subscriptions from "../handlers/subscriptions"
|
|
|
14
14
|
import { generateDataladCookie } from "../libs/authentication/jwt"
|
|
15
15
|
import { redis } from "../libs/redis"
|
|
16
16
|
import CacheItem, { CacheType } from "../cache/item"
|
|
17
|
-
import { updateDatasetRevision } from "./draft"
|
|
17
|
+
import { getDraftRevision, updateDatasetRevision } from "./draft"
|
|
18
18
|
import { encodeFilePath, filesUrl, fileUrl, getFileName } from "./files"
|
|
19
19
|
import { getAccessionNumber } from "../libs/dataset"
|
|
20
20
|
import Dataset from "../models/dataset"
|
|
@@ -80,28 +80,6 @@ export const createDataset = async (
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
interface WorkerDraftFields {
|
|
84
|
-
// Commit id hash
|
|
85
|
-
ref: string
|
|
86
|
-
// Commit tree ref
|
|
87
|
-
tree: string
|
|
88
|
-
// Commit message
|
|
89
|
-
message: string
|
|
90
|
-
// Commit author time
|
|
91
|
-
modified: string
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Return the latest commit
|
|
96
|
-
* @param {string} id Dataset accession number
|
|
97
|
-
*/
|
|
98
|
-
export const getDraftHead = async (id): Promise<WorkerDraftFields> => {
|
|
99
|
-
const draftRes = await request
|
|
100
|
-
.get(`${getDatasetWorker(id)}/datasets/${id}/draft`)
|
|
101
|
-
.set("Accept", "application/json")
|
|
102
|
-
return draftRes.body
|
|
103
|
-
}
|
|
104
|
-
|
|
105
83
|
/**
|
|
106
84
|
* Fetch dataset document and related fields
|
|
107
85
|
*/
|
|
@@ -109,7 +87,7 @@ export const getDataset = async (id) => {
|
|
|
109
87
|
const dataset = await Dataset.findOne({ id }).lean()
|
|
110
88
|
return {
|
|
111
89
|
...dataset,
|
|
112
|
-
revision: (
|
|
90
|
+
revision: getDraftRevision(id),
|
|
113
91
|
}
|
|
114
92
|
}
|
|
115
93
|
|
|
@@ -525,7 +503,6 @@ export async function updatePublic(datasetId, publicFlag, user) {
|
|
|
525
503
|
await Dataset.updateOne(
|
|
526
504
|
{ id: datasetId },
|
|
527
505
|
{ public: publicFlag, publishDate: new Date() },
|
|
528
|
-
{ upsert: true },
|
|
529
506
|
).exec()
|
|
530
507
|
await updateEvent(event)
|
|
531
508
|
}
|
package/src/datalad/snapshots.ts
CHANGED
|
@@ -103,13 +103,16 @@ const postSnapshot = async (
|
|
|
103
103
|
export const getSnapshots = async (datasetId): Promise<SnapshotDocument[]> => {
|
|
104
104
|
const dataset = await Dataset.findOne({ id: datasetId })
|
|
105
105
|
if (!dataset) return null
|
|
106
|
-
const
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
const cache = new CacheItem(redis, CacheType.snapshot, [datasetId], 432000)
|
|
107
|
+
return cache.get(() => {
|
|
108
|
+
const url = `${getDatasetWorker(datasetId)}/datasets/${datasetId}/snapshots`
|
|
109
|
+
return request
|
|
110
|
+
.get(url)
|
|
111
|
+
.set("Accept", "application/json")
|
|
112
|
+
.then(({ body: { snapshots } }) => {
|
|
113
|
+
return snapshots.sort(snapshotCreationComparison)
|
|
114
|
+
})
|
|
115
|
+
})
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
const announceNewSnapshot = async (snapshot, datasetId, user) => {
|
|
@@ -175,6 +178,11 @@ export const createSnapshot = async (
|
|
|
175
178
|
updateDatasetName(datasetId),
|
|
176
179
|
])
|
|
177
180
|
|
|
181
|
+
const snapshotListCache = new CacheItem(redis, CacheType.snapshot, [
|
|
182
|
+
datasetId,
|
|
183
|
+
])
|
|
184
|
+
await snapshotListCache.drop()
|
|
185
|
+
|
|
178
186
|
// Version is created here and event is updated
|
|
179
187
|
await updateEvent(event)
|
|
180
188
|
|
|
@@ -205,6 +213,10 @@ export const deleteSnapshot = (datasetId, tag) => {
|
|
|
205
213
|
tag,
|
|
206
214
|
])
|
|
207
215
|
await snapshotCache.drop()
|
|
216
|
+
const snapshotListCache = new CacheItem(redis, CacheType.snapshot, [
|
|
217
|
+
datasetId,
|
|
218
|
+
])
|
|
219
|
+
await snapshotListCache.drop()
|
|
208
220
|
return body
|
|
209
221
|
})
|
|
210
222
|
}
|
|
@@ -24,6 +24,7 @@ import { derivatives } from "./derivatives"
|
|
|
24
24
|
import { promiseTimeout } from "../../utils/promiseTimeout"
|
|
25
25
|
import { datasetEvents } from "./datasetEvents"
|
|
26
26
|
import semver from "semver"
|
|
27
|
+
import { getDraftInfo } from "../../datalad/draft"
|
|
27
28
|
|
|
28
29
|
export const dataset = async (obj, { id }, { user, userInfo }) => {
|
|
29
30
|
await checkDatasetRead(id, user, userInfo)
|
|
@@ -280,7 +281,7 @@ const worker = (obj) => getDatasetWorker(obj.id)
|
|
|
280
281
|
const Dataset = {
|
|
281
282
|
uploader: (ds, _, context) => user(ds, { id: ds.uploader }, context),
|
|
282
283
|
draft: async (obj) => {
|
|
283
|
-
const draftHead = await
|
|
284
|
+
const draftHead = await getDraftInfo(obj.id)
|
|
284
285
|
return {
|
|
285
286
|
id: obj.id,
|
|
286
287
|
revision: draftHead.ref,
|
|
@@ -5,8 +5,10 @@ import { description } from "./description.js"
|
|
|
5
5
|
* Return "schema" or "legacy" depending on the validator preferred for a dataset
|
|
6
6
|
*/
|
|
7
7
|
export async function datasetType(dsOrSnapshot): Promise<"schema" | "legacy"> {
|
|
8
|
-
const ds =
|
|
9
|
-
|
|
8
|
+
const ds = await Dataset.findOne({
|
|
9
|
+
id: dsOrSnapshot.datasetId || dsOrSnapshot.id,
|
|
10
|
+
}).lean()
|
|
11
|
+
if (ds && ds.schemaValidator) {
|
|
10
12
|
return "schema"
|
|
11
13
|
} else {
|
|
12
14
|
const dsDescription = await description(dsOrSnapshot)
|
|
@@ -14,11 +14,11 @@ import DeprecatedSnapshot from "../../models/deprecatedSnapshot"
|
|
|
14
14
|
import { redis } from "../../libs/redis"
|
|
15
15
|
import CacheItem, { CacheType } from "../../cache/item"
|
|
16
16
|
import { normalizeDOI } from "../../libs/doi/normalize"
|
|
17
|
-
import { getDraftHead } from "../../datalad/dataset"
|
|
18
17
|
import { downloadFiles } from "../../datalad/snapshots"
|
|
19
18
|
import { snapshotValidation } from "./validation"
|
|
20
19
|
import { advancedDatasetSearchConnection } from "./dataset-search"
|
|
21
20
|
import { contributors } from "../../datalad/contributors"
|
|
21
|
+
import { getDraftInfo } from "../../datalad/draft"
|
|
22
22
|
|
|
23
23
|
export const snapshots = (obj) => {
|
|
24
24
|
return datalad.getSnapshots(obj.id)
|
|
@@ -279,7 +279,7 @@ export const latestSnapshot = async (obj, _, context) => {
|
|
|
279
279
|
// In the case where there are no real snapshots, return most recent commit as snapshot
|
|
280
280
|
return await snapshot(
|
|
281
281
|
obj,
|
|
282
|
-
{ datasetId: obj.id, tag: (await
|
|
282
|
+
{ datasetId: obj.id, tag: (await getDraftInfo(obj.id)).ref },
|
|
283
283
|
context,
|
|
284
284
|
)
|
|
285
285
|
}
|
package/src/sentry.ts
CHANGED
|
@@ -4,7 +4,8 @@ import config from "./config"
|
|
|
4
4
|
import { version } from "./lerna.json"
|
|
5
5
|
|
|
6
6
|
Sentry.init({
|
|
7
|
-
dsn:
|
|
7
|
+
dsn:
|
|
8
|
+
"https://baebfdeb279ddb0c39c876feefd464c8@o4507748938350592.ingest.us.sentry.io/4507750879461376",
|
|
8
9
|
environment: config.sentry.ENVIRONMENT,
|
|
9
10
|
integrations: [
|
|
10
11
|
nodeProfilingIntegration(),
|