@openneuro/server 4.4.6 → 4.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openneuro/server",
3
- "version": "4.4.6",
3
+ "version": "4.4.7",
4
4
  "description": "Core service for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "src/server.js",
@@ -47,7 +47,7 @@
47
47
  "jsonwebtoken": "^8.3.0",
48
48
  "mime-types": "^2.1.19",
49
49
  "moment": "^2.14.1",
50
- "mongoose": "5.12.3",
50
+ "mongoose": "6.2.0",
51
51
  "morgan": "^1.6.1",
52
52
  "node-fetch": "^2.6.0",
53
53
  "node-mailjet": "^3.3.5",
@@ -104,5 +104,5 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
107
- "gitHead": "b60d0579c126f2934990f9c1fc2144223be35a5d"
107
+ "gitHead": "4373b377ffa4f0bcd71a7abaf07235c262f6cdb2"
108
108
  }
@@ -16,7 +16,7 @@ describe('dataset model operations', () => {
16
16
  // Setup a default sequence value to return for each test
17
17
  mockingoose.Counter.toReturn(
18
18
  { _id: 'dataset', sequence_value: 1 },
19
- 'findOneAndUpdate',
19
+ 'findOne',
20
20
  )
21
21
  })
22
22
  it('resolves to dataset id string', async done => {
@@ -28,7 +28,7 @@ describe('snapshot model operations', () => {
28
28
  // Setup a default sequence value to return for each test
29
29
  mockingoose.Counter.toReturn(
30
30
  { _id: 'dataset', sequence_value: 1 },
31
- 'findOneAndUpdate',
31
+ 'findOne',
32
32
  )
33
33
  })
34
34
  it('posts to the DataLad /datasets/{dsId}/snapshots/{snapshot} endpoint', async done => {
@@ -12,7 +12,7 @@ describe('dataset resolvers', () => {
12
12
  mockingoose.resetAll()
13
13
  mockingoose.Counter.toReturn(
14
14
  { _id: 'dataset', sequence_value: 1 },
15
- 'findOneAndUpdate',
15
+ 'findOne',
16
16
  )
17
17
  })
18
18
  describe('createDataset()', () => {
@@ -287,13 +287,24 @@ export const starred = (obj, _, { user }) =>
287
287
  /**
288
288
  * Is this dataset available on brainlife?
289
289
  */
290
- export const onBrainlife = async dataset => {
290
+ export const onBrainlife = async datasetOrSnapshot => {
291
291
  try {
292
- const url = `https://brainlife.io/api/warehouse/datalad/datasets?find={"path":{"$regex":"${dataset.id}$"}}`
292
+ const find = {
293
+ removed: false,
294
+ }
295
+ if (datasetOrSnapshot.tag) {
296
+ find.path = { $regex: '^OpenNeuro/' + datasetOrSnapshot.id.split(':')[0] }
297
+ find.version = datasetOrSnapshot.tag
298
+ } else {
299
+ find.path = { $regex: '^OpenNeuro/' + datasetOrSnapshot.id }
300
+ }
301
+ const url = `https://brainlife.io/api/warehouse/datalad/datasets?find=${JSON.stringify(
302
+ find,
303
+ )}`
293
304
  const res = await fetch(url)
294
305
  const body = await res.json()
295
306
  if (Array.isArray(body) && body.length) {
296
- return body[0].path === `OpenNeuroDatasets/${dataset.id}`
307
+ return true
297
308
  } else {
298
309
  return false
299
310
  }
@@ -1,5 +1,10 @@
1
1
  import * as datalad from '../../datalad/snapshots.js'
2
- import { dataset, analytics, snapshotCreationComparison } from './dataset.js'
2
+ import {
3
+ dataset,
4
+ analytics,
5
+ snapshotCreationComparison,
6
+ onBrainlife,
7
+ } from './dataset.js'
3
8
  import { checkDatasetRead, checkDatasetWrite } from '../permissions.js'
4
9
  import { readme } from './readme.js'
5
10
  import { description } from './description.js'
@@ -32,6 +37,7 @@ export const snapshot = (obj, { datasetId, tag }, context) => {
32
37
  .then(filterRemovedAnnexObjects(datasetId, context.userInfo)),
33
38
  deprecated: () => deprecated({ datasetId, tag }),
34
39
  related: () => related(datasetId),
40
+ onBrainlife,
35
41
  }))
36
42
  },
37
43
  )
@@ -459,6 +459,8 @@ export const typeDefs = `
459
459
  deprecated: DeprecatedSnapshot
460
460
  # Related DOI references
461
461
  related: [RelatedObject]
462
+ # Is the snapshot available for analysis on Brainlife?
463
+ onBrainlife: Boolean @cacheControl(maxAge: 10080, scope: PUBLIC)
462
464
  }
463
465
 
464
466
  # RelatedObject nature of relationship
@@ -36,11 +36,12 @@ export const mailjetFormat = (email: Record<string, string>) => ({
36
36
  * @param email Nodemailer style email record
37
37
  */
38
38
  export const send = (email: Record<string, string>): Promise<Response> => {
39
- // Mailjet is not configured, instead log emails
40
- if (!perform_api_call) {
39
+ if (perform_api_call) {
40
+ return transport
41
+ .post('send', { version: 'v3.1', perform_api_call })
42
+ .request(mailjetFormat(email))
43
+ } else {
44
+ // Mailjet is not configured, instead log emails
41
45
  console.dir(email)
42
46
  }
43
- return transport
44
- .post('send', { version: 'v3.1', perform_api_call })
45
- .request(mailjetFormat(email))
46
47
  }
@@ -30,7 +30,7 @@ describe('IngestDataset model', () => {
30
30
  notified: false,
31
31
  })
32
32
  goodUrlModel.validate(result => {
33
- expect(result).toBe(null)
33
+ expect(result).toBe(undefined)
34
34
  done()
35
35
  })
36
36
  })
@@ -2,6 +2,7 @@ import mongoose, { Document } from 'mongoose'
2
2
  const { Schema, model } = mongoose
3
3
 
4
4
  export interface CommentDocument extends Document {
5
+ _id: string
5
6
  createDate: Date
6
7
  datasetId: string
7
8
  datasetLabel: string
package/src/server.js CHANGED
@@ -23,12 +23,8 @@ const redisConnectionSetup = async () => {
23
23
  }
24
24
 
25
25
  mongoose.connect(config.mongo.url, {
26
- useNewUrlParser: true,
27
26
  dbName: config.mongo.dbName,
28
27
  connectTimeoutMS: config.mongo.connectTimeoutMS,
29
- useFindAndModify: false,
30
- useUnifiedTopology: true,
31
- useCreateIndex: true,
32
28
  })
33
29
 
34
30
  redisConnectionSetup().then(() => {