@openneuro/server 4.18.1 → 4.19.0-alpha.1

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.18.1",
3
+ "version": "4.19.0-alpha.1",
4
4
  "description": "Core service for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "src/server.js",
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@apollo/client": "3.7.2",
19
19
  "@elastic/elasticsearch": "7.15.0",
20
- "@openneuro/search": "^4.18.1",
20
+ "@openneuro/search": "^4.19.0-alpha.1",
21
21
  "@passport-next/passport-google-oauth2": "^1.0.0",
22
22
  "@sentry/node": "^4.5.3",
23
23
  "apollo-server": "2.25.4",
@@ -92,5 +92,5 @@
92
92
  "publishConfig": {
93
93
  "access": "public"
94
94
  },
95
- "gitHead": "fbd8afe9033abf11e39e17968b3e9f60261a9c01"
95
+ "gitHead": "42250552695e01915a37f3d00fe6c3476d1661c0"
96
96
  }
@@ -1,12 +1,48 @@
1
+ import Snapshot from '../../models/snapshot'
1
2
  import MetadataModel from '../../models/metadata'
3
+ import { latestSnapshot } from './snapshots'
4
+ import { permissions } from './permissions'
2
5
 
3
6
  /**
4
7
  * Summary resolver
8
+ *
9
+ * User modified fields are queried from the Metadata model and dynamic metadata is updated from the latest snapshot
5
10
  */
6
- export const metadata = dataset => {
7
- return MetadataModel.findOne({
11
+ export const metadata = async (dataset, _, context) => {
12
+ const record = await MetadataModel.findOne({
8
13
  datasetId: dataset.id,
14
+ }).lean()
15
+ // Replace dynamic fields with latest available
16
+ const snapshot = await latestSnapshot(dataset, null, context)
17
+ const description = await snapshot.description()
18
+ const summary = await snapshot.summary()
19
+ // Find the users with admin access
20
+ // TODO - This could be a user object that is resolved with the full type instead of just email
21
+ // Email matches the existing records however and the user object would require other changes
22
+ const adminUsers = []
23
+ const { userPermissions } = await permissions(dataset)
24
+ for (const user of userPermissions) {
25
+ adminUsers.push((await user.user).email)
26
+ }
27
+ const firstSnapshot = await Snapshot.find({ datasetId: dataset.id }).sort({
28
+ created: 1,
9
29
  })
30
+ const firstSnapshotCreatedAt = firstSnapshot.length
31
+ ? firstSnapshot[0].created
32
+ : null
33
+ return {
34
+ ...record,
35
+ datasetId: dataset.id,
36
+ datasetName: description.Name,
37
+ tasksCompleted: summary.tasks,
38
+ seniorAuthor: description.Authors[0],
39
+ adminUsers,
40
+ firstSnapshotCreatedAt,
41
+ latestSnapshotCreatedAt: snapshot.created,
42
+ subjectAges: summary.subjectMetadata.map(s => s.age),
43
+ modalities: summary.modalities,
44
+ dataProcessed: summary.dataProcessed,
45
+ }
10
46
  }
11
47
 
12
48
  /**
@@ -415,6 +415,25 @@ export const typeDefs = `
415
415
  message: String
416
416
  # Associated commit references (tags or branches)
417
417
  references: String
418
+ # File changes in this commit
419
+ files: [DiffFiles]
420
+ # Files changed
421
+ filesChanged: Int
422
+ # Total number of insertions
423
+ insertions: Int
424
+ # Total number of deletions
425
+ deletions: Int
426
+ }
427
+
428
+ type DiffFiles {
429
+ # Status string (A = added, M = modified, D = deleted)
430
+ status: String
431
+ mode: Int
432
+ # Previous path
433
+ old: String
434
+ # New path
435
+ new: String
436
+ binary: Boolean
418
437
  }
419
438
 
420
439
  # Ephemeral draft or working tree for a dataset
@@ -3,6 +3,7 @@ import mongoose, { Document } from 'mongoose'
3
3
  const { Schema, model } = mongoose
4
4
 
5
5
  export interface MetadataDocument extends Document {
6
+ datasetId: string
6
7
  datasetName: string
7
8
  datasetUrl: string
8
9
  dataProcessed: boolean
@@ -10,7 +11,6 @@ export interface MetadataDocument extends Document {
10
11
  latestSnapshotCreatedAt: Date
11
12
  ages: number[]
12
13
  modalities: string[]
13
- datasetId: string
14
14
  adminUsers: string[]
15
15
  dxStatus: string
16
16
  tasksCompleted: string[]
@@ -29,6 +29,7 @@ export interface MetadataDocument extends Document {
29
29
  }
30
30
 
31
31
  const metadataSchema = new Schema({
32
+ datasetId: { type: String, default: uuid.v4 }, // OpenNeuro id
32
33
  datasetName: String,
33
34
  datasetUrl: String, // @id type
34
35
  dataProcessed: Boolean, // 'true' | 'false' | 'user input string'
@@ -36,7 +37,6 @@ const metadataSchema = new Schema({
36
37
  latestSnapshotCreatedAt: Date,
37
38
  ages: [Number],
38
39
  modalities: [String],
39
- datasetId: { type: String, default: uuid.v4 }, // OpenNeuro id
40
40
  adminUsers: [String], // email type (@id type?)
41
41
  dxStatus: String,
42
42
  tasksCompleted: [String],