@openneuro/server 4.20.0-alpha.1 → 4.20.0-alpha.4

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.20.0-alpha.1",
3
+ "version": "4.20.0-alpha.4",
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": "7.15.0",
22
22
  "@graphql-tools/schema": "^10.0.0",
23
23
  "@keyv/redis": "^2.7.0",
24
- "@openneuro/search": "^4.20.0-alpha.1",
24
+ "@openneuro/search": "^4.20.0-alpha.4",
25
25
  "@passport-next/passport-google-oauth2": "^1.0.0",
26
26
  "@sentry/node": "^4.5.3",
27
27
  "base64url": "^3.0.0",
@@ -80,14 +80,13 @@
80
80
  "core-js": "^3.10.1",
81
81
  "ioredis-mock": "^8.8.1",
82
82
  "nodemon": "^2.0.7",
83
- "supertest": "^3.0.0",
84
83
  "ts-node-dev": "1.1.6",
85
84
  "tsc-watch": "^4.2.9",
86
- "vitest": "0.33.0",
87
- "vitest-fetch-mock": "^0.2.1"
85
+ "vitest": "0.34.4",
86
+ "vitest-fetch-mock": "0.2.2"
88
87
  },
89
88
  "publishConfig": {
90
89
  "access": "public"
91
90
  },
92
- "gitHead": "60ca7376fddf72b9516b582ee46c585ef526a39f"
91
+ "gitHead": "b658c22b75a090a38bdfc3aab081304f5d43c9c8"
93
92
  }
@@ -0,0 +1,6 @@
1
+ import { description } from './description.js'
2
+
3
+ export async function datasetType(dsOrSnapshot): Promise<'schema' | 'legacy'> {
4
+ const dsDescription = await description(dsOrSnapshot)
5
+ return dsDescription.DatasetType === 'derivative' ? 'schema' : 'legacy'
6
+ }
@@ -1,13 +1,19 @@
1
1
  import Issue from '../../models/issue'
2
+ import { datasetType } from './datasetType'
2
3
  import { revalidate } from './validation.js'
3
4
 
4
5
  /**
5
6
  * Issues resolver
6
7
  */
7
- export const issues = (dataset, _, { userInfo }) => {
8
+ export const issues = async (dataset, _, { userInfo }) => {
8
9
  return Issue.findOne({
9
10
  id: dataset.revision,
10
11
  datasetId: dataset.id,
12
+ // Match if we have no validatorMetadata or the correct 'legacy' / 'schema' value if we do
13
+ $or: [
14
+ { 'validatorMetadata.validator': await datasetType(dataset) },
15
+ { validatorMetadata: { $exists: false } },
16
+ ],
11
17
  })
12
18
  .exec()
13
19
  .then(data => {
@@ -26,11 +32,16 @@ export const issues = (dataset, _, { userInfo }) => {
26
32
  /**
27
33
  * Snapshot issues resolver
28
34
  */
29
- export const snapshotIssues = snapshot => {
35
+ export const snapshotIssues = async snapshot => {
30
36
  const datasetId = snapshot.id.split(':')[0]
31
37
  return Issue.findOne({
32
38
  id: snapshot.hexsha,
33
39
  datasetId,
40
+ // Match if we have no validatorMetadata or the correct 'legacy' / 'schema' value if we do
41
+ $or: [
42
+ { 'validatorMetadata.validator': await datasetType(snapshot) },
43
+ { validatorMetadata: { $exists: false } },
44
+ ],
34
45
  })
35
46
  .exec()
36
47
  .then(data => (data ? data.issues : null))
@@ -1,4 +1,5 @@
1
1
  import Summary, { SummaryDocument } from '../../models/summary'
2
+ import { datasetType } from './datasetType'
2
3
 
3
4
  /**
4
5
  * Summary resolver
@@ -8,6 +9,11 @@ export async function summary(dataset): Promise<Partial<SummaryDocument>> {
8
9
  await Summary.findOne({
9
10
  id: dataset.revision,
10
11
  datasetId: dataset.id,
12
+ // Match if we have no validatorMetadata or the correct 'legacy' / 'schema' value if we do
13
+ $or: [
14
+ { 'validatorMetadata.validator': await datasetType(dataset) },
15
+ { validatorMetadata: { $exists: false } },
16
+ ],
11
17
  }).exec()
12
18
  )?.toObject()
13
19
  if (datasetSummary) {
@@ -27,7 +33,11 @@ export async function summary(dataset): Promise<Partial<SummaryDocument>> {
27
33
  */
28
34
  export const updateSummary = (obj, args) => {
29
35
  return Summary.updateOne(
30
- { id: args.summary.id, datasetId: args.summary.datasetId },
36
+ {
37
+ id: args.summary.id,
38
+ datasetId: args.summary.datasetId,
39
+ validatorMetadata: args.summary.validatorMetadata,
40
+ },
31
41
  args.summary,
32
42
  {
33
43
  upsert: true,
@@ -12,7 +12,11 @@ import { redlock } from '../../libs/redis.js'
12
12
  */
13
13
  export const updateValidation = (obj, args) => {
14
14
  return Issue.updateOne(
15
- { id: args.validation.id, datasetId: args.validation.datasetId },
15
+ {
16
+ id: args.validation.id,
17
+ datasetId: args.validation.datasetId,
18
+ validatorMetadata: args.validation.validatorMetadata,
19
+ },
16
20
  args.validation,
17
21
  {
18
22
  upsert: true,
@@ -219,6 +219,14 @@ export const typeDefs = `
219
219
  TracerRadionuclide: [String]
220
220
  }
221
221
 
222
+ # BIDS Validator metadata
223
+ input ValidatorMetadata {
224
+ # Unique string identifying the type of BIDS validator software
225
+ validator: String
226
+ # Semantic versioning string for the version of the validation software
227
+ version: String
228
+ }
229
+
222
230
  input SummaryInput {
223
231
  id: ID! # Git reference for this summary
224
232
  datasetId: ID!
@@ -233,6 +241,10 @@ export const typeDefs = `
233
241
  totalFiles: Int!
234
242
  dataProcessed: Boolean
235
243
  pet: SummaryPetInput
244
+ # Metadata for validation software used
245
+ validatorMetadata: ValidatorMetadata
246
+ # BIDS Specification schema version
247
+ schemaVersion: String
236
248
  }
237
249
 
238
250
  input SubjectMetadataInput {
@@ -246,6 +258,7 @@ export const typeDefs = `
246
258
  id: ID! # Git reference for this validation
247
259
  datasetId: ID!
248
260
  issues: [ValidationIssueInput]!
261
+ validatorMetadata: ValidatorMetadata
249
262
  }
250
263
 
251
264
  # Dataset Metadata
@@ -598,6 +611,8 @@ export const typeDefs = `
598
611
  totalFiles: Int!
599
612
  dataProcessed: Boolean
600
613
  pet: SummaryPetFields
614
+ # BIDS Specification schema version
615
+ schemaVersion: String
601
616
  }
602
617
 
603
618
  type SummaryPetFields {
@@ -645,7 +660,7 @@ export const typeDefs = `
645
660
  type ValidationIssue {
646
661
  severity: Severity!
647
662
  key: String!
648
- code: Int!
663
+ code: Int
649
664
  reason: String!
650
665
  files: [ValidationIssueFile]
651
666
  additionalFileCount: Int
@@ -655,7 +670,7 @@ export const typeDefs = `
655
670
  input ValidationIssueInput {
656
671
  severity: Severity!
657
672
  key: String!
658
- code: Int!
673
+ code: Int
659
674
  reason: String!
660
675
  files: [ValidationIssueFileInput]
661
676
  additionalFileCount: Int
@@ -663,8 +678,10 @@ export const typeDefs = `
663
678
  }
664
679
 
665
680
  type ValidationIssueFile {
681
+ name: String
682
+ path: String
666
683
  key: String!
667
- code: Int!
684
+ code: Int
668
685
  file: ValidationIssueFileDetail
669
686
  evidence: String
670
687
  line: Int
@@ -675,15 +692,19 @@ export const typeDefs = `
675
692
  }
676
693
 
677
694
  input ValidationIssueFileInput {
678
- key: String!
679
- code: Int!
695
+ name: String
696
+ path: String
697
+ key: String
698
+ code: Int
680
699
  file: ValidationIssueFileDetailInput
681
700
  evidence: String
682
701
  line: Int
683
702
  character: Int
684
- severity: Severity!
703
+ severity: Severity
685
704
  reason: String
686
705
  helpUrl: String
706
+ # Temporary field for compatibility (remove after bids-validator@1.13.0)
707
+ _datasetAbsPath: String
687
708
  }
688
709
 
689
710
  type ValidationIssueFileDetail {
@@ -5,12 +5,20 @@ export interface IssueDocument extends Document {
5
5
  id: string
6
6
  datasetId: string
7
7
  issues: object
8
+ validatorMetadata: {
9
+ validator: string
10
+ version: string
11
+ }
8
12
  }
9
13
 
10
14
  const issueSchema = new Schema({
11
15
  id: { type: String, required: true },
12
16
  datasetId: { type: String, required: true },
13
17
  issues: Object,
18
+ validatorMetadata: {
19
+ validator: String,
20
+ version: String,
21
+ },
14
22
  })
15
23
 
16
24
  const Issue = model<IssueDocument>('Issue', issueSchema)
@@ -24,6 +24,10 @@ export interface SummaryDocument extends Document {
24
24
  size: number
25
25
  dataProcessed: boolean
26
26
  pet: SummaryPetField
27
+ validatorMetadata: {
28
+ validator: string
29
+ version: string
30
+ }
27
31
  }
28
32
 
29
33
  const summarySchema = new Schema({
@@ -47,6 +51,10 @@ const summarySchema = new Schema({
47
51
  TracerName: [String],
48
52
  TracerRadionuclide: [String],
49
53
  },
54
+ validatorMetadata: {
55
+ validator: String,
56
+ version: String,
57
+ },
50
58
  })
51
59
 
52
60
  summarySchema.index({ id: 1 })