@openneuro/server 5.0.0 → 5.1.0

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.
Files changed (98) hide show
  1. package/package.json +8 -5
  2. package/src/app.ts +2 -4
  3. package/src/cache/__tests__/tree.spec.ts +2 -0
  4. package/src/cache/tree.ts +4 -0
  5. package/src/cache/types.ts +1 -0
  6. package/src/datalad/__tests__/contributors.spec.ts +1 -1
  7. package/src/datalad/__tests__/dataRetentionNotifications.spec.ts +11 -11
  8. package/src/datalad/__tests__/files.spec.ts +31 -1
  9. package/src/datalad/__tests__/snapshots.spec.ts +4 -4
  10. package/src/datalad/contributors.ts +2 -2
  11. package/src/datalad/dataRetentionNotifications.ts +5 -5
  12. package/src/datalad/dataset.ts +9 -5
  13. package/src/datalad/description.ts +2 -2
  14. package/src/datalad/draft.ts +8 -3
  15. package/src/datalad/files.ts +71 -12
  16. package/src/datalad/readme.ts +2 -2
  17. package/src/datalad/snapshots.ts +19 -14
  18. package/src/elasticsearch/elastic-client.ts +11 -6
  19. package/src/elasticsearch/reindex-dataset.ts +8 -4
  20. package/src/graphql/__tests__/comment.spec.ts +3 -2
  21. package/src/graphql/__tests__/schema.spec.ts +28 -0
  22. package/src/graphql/builder.ts +42 -0
  23. package/src/graphql/resolvers/__tests__/dataset.spec.ts +6 -119
  24. package/src/graphql/resolvers/__tests__/importRemoteDataset.spec.ts +2 -1
  25. package/src/graphql/resolvers/__tests__/permssions.spec.ts +3 -2
  26. package/src/graphql/resolvers/__tests__/user.spec.ts +39 -11
  27. package/src/graphql/resolvers/brainInitiative.ts +4 -3
  28. package/src/graphql/resolvers/cache.ts +7 -6
  29. package/src/graphql/resolvers/comment.ts +35 -19
  30. package/src/graphql/resolvers/dataset-search.ts +7 -6
  31. package/src/graphql/resolvers/dataset.ts +77 -45
  32. package/src/graphql/resolvers/datasetEvents.ts +18 -16
  33. package/src/graphql/resolvers/description.ts +2 -1
  34. package/src/graphql/resolvers/draft.ts +14 -3
  35. package/src/graphql/resolvers/fileCheck.ts +5 -4
  36. package/src/graphql/resolvers/flaggedFiles.ts +2 -1
  37. package/src/graphql/resolvers/follow.ts +2 -1
  38. package/src/graphql/resolvers/git.ts +2 -1
  39. package/src/graphql/resolvers/gitEvents.ts +2 -1
  40. package/src/graphql/resolvers/history.ts +3 -1
  41. package/src/graphql/resolvers/holdDeletion.ts +1 -1
  42. package/src/graphql/resolvers/importRemoteDataset.ts +3 -2
  43. package/src/graphql/resolvers/issues.ts +2 -1
  44. package/src/graphql/resolvers/metadata.ts +3 -2
  45. package/src/graphql/resolvers/permissions.ts +26 -6
  46. package/src/graphql/resolvers/publish.ts +2 -1
  47. package/src/graphql/resolvers/readme.ts +2 -1
  48. package/src/graphql/resolvers/reexporter.ts +2 -1
  49. package/src/graphql/resolvers/relation.ts +3 -2
  50. package/src/graphql/resolvers/reset.ts +2 -1
  51. package/src/graphql/resolvers/reviewer.ts +14 -6
  52. package/src/graphql/resolvers/snapshots.ts +42 -10
  53. package/src/graphql/resolvers/stars.ts +2 -1
  54. package/src/graphql/resolvers/upload.ts +3 -2
  55. package/src/graphql/resolvers/user.ts +44 -32
  56. package/src/graphql/resolvers/validation.ts +6 -5
  57. package/src/graphql/resolvers/worker.ts +2 -1
  58. package/src/graphql/schema/analytics.ts +12 -0
  59. package/src/graphql/schema/comment.ts +30 -0
  60. package/src/graphql/schema/dataset-events.ts +91 -0
  61. package/src/graphql/schema/dataset-search.ts +32 -0
  62. package/src/graphql/schema/dataset.ts +167 -0
  63. package/src/graphql/schema/description.ts +44 -0
  64. package/src/graphql/schema/draft.ts +80 -0
  65. package/src/graphql/schema/enums.ts +55 -0
  66. package/src/graphql/schema/files.ts +44 -0
  67. package/src/graphql/schema/inputs.ts +231 -0
  68. package/src/graphql/schema/metadata.ts +86 -0
  69. package/src/graphql/schema/misc.ts +154 -0
  70. package/src/graphql/schema/mutation.ts +549 -0
  71. package/src/graphql/schema/pagination.ts +12 -0
  72. package/src/graphql/schema/permissions.ts +21 -0
  73. package/src/graphql/schema/query.ts +119 -0
  74. package/src/graphql/schema/refs.ts +23 -0
  75. package/src/graphql/schema/reviewer.ts +11 -0
  76. package/src/graphql/schema/scalars.ts +9 -0
  77. package/src/graphql/schema/snapshot.ts +111 -0
  78. package/src/graphql/schema/upload.ts +13 -0
  79. package/src/graphql/schema/user.ts +61 -0
  80. package/src/graphql/schema/validation.ts +70 -0
  81. package/src/graphql/schema/worker.ts +16 -0
  82. package/src/graphql/schema.ts +29 -1114
  83. package/src/handlers/subscriptions.ts +1 -1
  84. package/src/libs/apikey.ts +1 -1
  85. package/src/libs/authentication/crypto.ts +14 -9
  86. package/src/libs/notifications.ts +1 -1
  87. package/src/libs/presign.ts +32 -20
  88. package/src/libs/redis.ts +12 -2
  89. package/src/models/comment.ts +2 -4
  90. package/src/models/counter.ts +2 -2
  91. package/src/models/ingestDataset.ts +1 -2
  92. package/src/models/notification.ts +0 -2
  93. package/src/models/subscription.ts +0 -1
  94. package/src/models/user.ts +1 -2
  95. package/src/models/userMigration.ts +1 -1
  96. package/src/models/userNotificationStatus.ts +0 -1
  97. package/src/utils/__tests__/snapshots.spec.ts +120 -0
  98. package/src/utils/snapshots.ts +12 -0
@@ -1,1114 +1,29 @@
1
- import { schemaComposer } from "graphql-compose"
2
- import resolvers from "./resolvers"
3
- import {
4
- advancedDatasetSearch,
5
- datasetSearch,
6
- } from "./resolvers/dataset-search"
7
-
8
- export const typeDefs = `
9
- scalar Date
10
- scalar DateTime
11
- scalar Time
12
- scalar BigInt
13
-
14
- enum CacheControlScope {
15
- PUBLIC
16
- PRIVATE
17
- }
18
-
19
- directive @cacheControl(
20
- maxAge: Int
21
- scope: CacheControlScope
22
- ) on OBJECT | FIELD_DEFINITION
23
-
24
- enum SortOrdering {
25
- ascending
26
- descending
27
- }
28
-
29
- # Sorting order for users
30
- input UserSortInput {
31
- field: String!
32
- order: SortOrdering = ascending
33
- }
34
-
35
- # Sorting order for datasets
36
- input DatasetSort {
37
- # Dataset created time
38
- created: SortOrdering
39
- # Alphanumeric sort of dataset name
40
- name: SortOrdering
41
- # Alphanumeric sort of uploader name
42
- uploader: SortOrdering
43
- # Order by star count
44
- stars: SortOrdering
45
- # Order by download count
46
- downloads: SortOrdering
47
- # Order by dataset views
48
- views: SortOrdering
49
- # Order by count of dataset followers
50
- subscriptions: SortOrdering
51
- # Order by publish date
52
- publishDate: SortOrdering
53
- }
54
-
55
- # Dataset query filter flags
56
- input DatasetFilter {
57
- "Limit to datasets available publicly"
58
- public: Boolean
59
- "Return only datasets that are shared with the user"
60
- shared: Boolean
61
- "Return only datasets with an invalid Draft"
62
- invalid: Boolean
63
- "Return only datasets starred by the query user"
64
- starred: Boolean
65
- "Return all datasets, ignores any other constraints but not sorts"
66
- all: Boolean
67
- }
68
-
69
- type Query {
70
- # One dataset
71
- dataset(id: ID!): Dataset
72
- # Get all datasets
73
- datasets(
74
- "Limit results, default 25, max 100"
75
- first: Int = 25
76
- "Cursor key used to fetch later results"
77
- after: String
78
- "Cursor key used to fetch earlier results"
79
- before: String
80
- "Sorting fields"
81
- orderBy: DatasetSort = { created: ascending }
82
- "Filtering fields"
83
- filterBy: DatasetFilter = {}
84
- "Query user's datasets only - excludes public datasets from other filters"
85
- myDatasets: Boolean
86
- "Query datasets of a specific modality"
87
- modality: String
88
- ): DatasetConnection
89
- # Get one user
90
- user(id: ID!): User
91
- # Get a list of users
92
- users(
93
- orderBy: [UserSortInput!]
94
- isAdmin: Boolean
95
- isBlocked: Boolean
96
- search: String
97
- limit: Int
98
- offset: Int
99
- ): UserList!
100
- # Get the total number of dataset participants
101
- participantCount(modality: String): Int @cacheControl(maxAge: 3600, scope: PUBLIC)
102
- # Request one snapshot
103
- snapshot(datasetId: ID!, tag: String!): Snapshot
104
- # Get annexed files that have been flagged or removed.
105
- flaggedFiles(
106
- "Get files that have been flagged, default true."
107
- flagged: Boolean = true
108
- "Get files that have already been deleted, default false."
109
- deleted: Boolean = false
110
- ): [FlaggedFile]
111
- # All public dataset metadata
112
- publicMetadata: [Metadata] @cacheControl(maxAge: 86400, scope: PUBLIC)
113
- orcidConsent: Boolean
114
- }
115
-
116
- type Mutation {
117
- # Create a new dataset container and repository
118
- createDataset(affirmedDefaced: Boolean, affirmedConsent: Boolean): Dataset
119
- # Deletes a dataset and all associated snapshots
120
- deleteDataset(id: ID!, reason: String, redirect: String): Boolean
121
- # Tag the current draft
122
- createSnapshot(datasetId: ID!, tag: String!, changes: [String!]): Snapshot
123
- # Remove a tag from the dataset
124
- deleteSnapshot(datasetId: ID!, tag: String!): Boolean!
125
- # removes the annex object of the given file
126
- removeAnnexObject(datasetId: ID!, snapshot: String!, annexKey: String!, path: String, filename: String): Boolean
127
- # flags the given file
128
- flagAnnexObject(datasetId: ID!, snapshot: String!, filepath: String!, annexKey: String!): Boolean
129
- # Delete files or directories in a draft
130
- deleteFiles(datasetId: ID!, files: [DeleteFile]): Boolean
131
- # Add or remove the public flag from a dataset
132
- updatePublic(datasetId: ID!, publicFlag: Boolean!): Boolean!
133
- # Update a draft summary
134
- updateSummary(summary: SummaryInput!): Summary
135
- # Update a draft with validation results
136
- updateValidation(validation: ValidatorInput!): Boolean
137
- # Update a users's permissions on a dataset
138
- updatePermissions(datasetId: ID!, userEmail: String!, level: String!): DatasetPermissions
139
- # Update a users's permissions for a given ORCID
140
- updateOrcidPermissions(datasetId: ID!, userOrcid: String!, level: String!): DatasetPermissions
141
- # Remove a users's permissions on a dataset
142
- removePermissions(datasetId: ID!, userId: String!): Boolean
143
- # Remove a user
144
- removeUser(id: ID!): Boolean
145
- # Sets a users admin status
146
- setAdmin(id: ID!, admin: Boolean!): User
147
- # Sets a users admin status
148
- setBlocked(id: ID!, blocked: Boolean!): User
149
- # Mutation for updating user data
150
- updateUser(id: ID!, location: String, institution: String, links: [String], orcidConsent: Boolean): User
151
- # Tracks a view or download for a dataset
152
- trackAnalytics(datasetId: ID!, tag: String, type: AnalyticTypes): Boolean
153
- # Follow dataset
154
- followDataset(datasetId: ID!): FollowDatasetResponse
155
- # Star dataset
156
- starDataset(datasetId: ID!): StarDatasetResponse
157
- # Make a dataset public
158
- publishDataset(datasetId: ID!): Boolean
159
- # Update dataset_description.json scalar fields
160
- updateDescription(datasetId: ID!, field: String!, value: String!): Description
161
- # Update dataset_description.json list fields
162
- updateDescriptionList(datasetId: ID!, field: String!, value: [String!]): Description
163
- # Update dataset README file
164
- updateReadme(datasetId: ID!, value: String!): Boolean
165
- # Submits a new comment and returns the comment ID for replies
166
- addComment(datasetId: ID!, parentId: ID, comment: String!): ID
167
- # Edits an existing comment
168
- editComment(commentId: ID!, comment: String!): Boolean
169
- # Deletes an existing comment (deleteChildren defaults to false). Returns the ids of all deleted comments.
170
- deleteComment(commentId: ID!, deleteChildren: Boolean): [String]
171
- # Subscribes user to newsletter
172
- subscribeToNewsletter(email: String!): Boolean
173
- # Upserts dataset metadata
174
- addMetadata(datasetId: ID!, metadata: MetadataInput!): Metadata
175
- # Start an upload
176
- prepareUpload(datasetId: ID!, uploadId: ID!): UploadMetadata
177
- # Add files from a completed upload to the dataset draft
178
- finishUpload(uploadId: ID!): Boolean
179
- # Drop cached data for a dataset - requires site admin access
180
- cacheClear(datasetId: ID!): Boolean
181
- # Rerun fsck on a dataset if 30 minutes have passed since last request
182
- fsckDataset(datasetId: ID!): Boolean
183
- # Rerun the latest validator on a given commit
184
- revalidate(datasetId: ID!, ref: String!): Boolean
185
- # Request a temporary token for git access
186
- prepareRepoAccess(datasetId: ID!): RepoMetadata
187
- # Rerun remote exports
188
- reexportRemotes(datasetId: ID!): Boolean
189
- # Reset draft commit
190
- resetDraft(datasetId: ID!, ref: String!): Boolean
191
- # Flag snapshot as deprecated
192
- deprecateSnapshot(datasetId: ID!, tag: String!, reason: String!): Snapshot
193
- # Unflag snapshot as deprecated
194
- undoDeprecateSnapshot(datasetId: ID!, tag: String!): Snapshot
195
- # Create anonymous read only reviewer
196
- createReviewer(datasetId: ID!): DatasetReviewer
197
- # Remove reviewer
198
- deleteReviewer(datasetId: ID!, id: ID!): DatasetReviewer
199
- # Add a relationship to an external DOI
200
- createRelation(datasetId: ID!, doi: String!, relation: RelatedObjectRelation!, kind: RelatedObjectKind!, description: String): Dataset
201
- # Remove a relationship to an external DOI
202
- deleteRelation(datasetId: ID!, doi: String!): Dataset
203
- # Submit an import for a remote dataset, returns id if the URL is accepted for import
204
- importRemoteDataset(datasetId: ID!, url: String!): ID
205
- # Finish and notify import is done, returns true if successful
206
- finishImportRemoteDataset(id: ID!, success: Boolean!, message: String): Boolean
207
- # Create or update an admin note on a dataset
208
- saveAdminNote(id: ID, datasetId: ID!, note: String!): DatasetEvent
209
- # Create a git event log for dataset changes
210
- createGitEvent(datasetId: ID!, commit: String!, reference: String!): DatasetEvent
211
- # Request contributor status for a dataset
212
- createContributorRequestEvent(datasetId: ID!): DatasetEvent
213
- # Save contributor request response data
214
- processContributorRequest(
215
- datasetId: ID!
216
- targetUserId: ID!
217
- requestId: ID!
218
- resolutionStatus: ResponseStatusType!
219
- reason: String
220
- ): DatasetEvent
221
- # Create or update a fileCheck document
222
- updateFileCheck(
223
- datasetId: ID!
224
- hexsha: String!
225
- refs: [String!]!
226
- annexFsck: [AnnexFsckInput!]!
227
- remote: String
228
- ): FileCheck
229
- # Profile Event Status updates
230
- updateEventStatus(eventId: ID!, status: NotificationStatusType!): UserNotificationStatus
231
- updateContributors(
232
- datasetId: String!
233
- newContributors: [ContributorInput!]!
234
- ): UpdateContributorsPayload!
235
- createContributorCitationEvent(
236
- datasetId: ID!
237
- targetUserId: ID!
238
- contributorData: ContributorInput!
239
- ): DatasetEvent
240
- processContributorCitation(
241
- eventId: ID!
242
- status: ResponseStatusType!
243
- ): DatasetEvent
244
- # Hold or release automated deletion for a dataset
245
- holdDeletion(datasetId: ID!, hold: Boolean!): Boolean
246
- # Update worker task queue status
247
- updateWorkerTask(
248
- id: ID!,
249
- args: JSON,
250
- kwargs: JSON,
251
- taskName: String,
252
- worker: String,
253
- queuedAt: DateTime,
254
- startedAt: DateTime,
255
- finishedAt: DateTime,
256
- error: String,
257
- executionTime: Int,
258
- ): WorkerTask
259
- }
260
-
261
- # Anonymous dataset reviewer
262
- type DatasetReviewer {
263
- id: ID!
264
- # Dataset accession number
265
- datasetId: ID!
266
- # Expiration time
267
- expiration: DateTime
268
- # Login URL generated (only returned on creation)
269
- url: String!
270
- }
271
-
272
- # Sort options for advanced dataset search
273
- enum SearchSortOption {
274
- relevance
275
- newest
276
- oldest
277
- activity
278
- name_asc
279
- name_desc
280
- last_updated
281
- }
282
-
283
- # Search input for advanced dataset search
284
- input DatasetSearchInput {
285
- keywords: [String]
286
- modality: String
287
- ageRange: [Int]
288
- subjectCountRange: [Int]
289
- diagnosis: String
290
- tasks: [String]
291
- authors: [String]
292
- sex: String
293
- dateRange: String
294
- species: String
295
- studyStructure: String
296
- studyDomains: [String]
297
- bidsDatasetType: String
298
- brainInitiative: Boolean
299
- bodyParts: [String]
300
- scannerManufacturers: [String]
301
- scannerManufacturersModelNames: [String]
302
- tracerNames: [String]
303
- tracerRadionuclides: [String]
304
- sortBy: SearchSortOption
305
- "Filter datasets by a specific user's permissions"
306
- userId: String
307
- "Filter to only public datasets"
308
- publicOnly: Boolean
309
- }
310
-
311
- input DeleteFile {
312
- path: String!
313
- filename: String
314
- }
315
-
316
- input UploadFile {
317
- filename: String!
318
- size: BigInt!
319
- }
320
-
321
- input SummaryPetInput {
322
- BodyPart: [String]
323
- ScannerManufacturer: [String]
324
- ScannerManufacturersModelName: [String]
325
- TracerName: [String]
326
- TracerRadionuclide: [String]
327
- }
328
-
329
- # BIDS Validator metadata
330
- type ValidatorMetadata {
331
- # Unique string identifying the type of BIDS validator software
332
- validator: String
333
- # Semantic versioning string for the version of the validation software
334
- version: String
335
- }
336
-
337
- # BIDS Validator metadata
338
- input ValidatorMetadataInput {
339
- # Unique string identifying the type of BIDS validator software
340
- validator: String
341
- # Semantic versioning string for the version of the validation software
342
- version: String
343
- }
344
-
345
- input SummaryInput {
346
- id: ID! # Git reference for this summary
347
- datasetId: ID!
348
- modalities: [String]
349
- secondaryModalities: [String]
350
- dataTypes: [String]
351
- sessions: [String]
352
- subjects: [String]
353
- subjectMetadata: [SubjectMetadataInput]
354
- tasks: [String]
355
- size: BigInt!
356
- totalFiles: Int!
357
- dataProcessed: Boolean
358
- pet: SummaryPetInput
359
- # Metadata for validation software used
360
- validatorMetadata: ValidatorMetadataInput
361
- # BIDS Specification schema version
362
- schemaVersion: String
363
- }
364
-
365
- input SubjectMetadataInput {
366
- participantId: String!
367
- age: Float
368
- sex: String
369
- group: String
370
- }
371
-
372
- input ValidatorInput {
373
- id: ID! # Git reference for this validation
374
- datasetId: ID!
375
- issues: [ValidatorIssueInput]!
376
- codeMessages: [ValidatorCodeMessageInput]!
377
- validatorMetadata: ValidatorMetadataInput!
378
- }
379
-
380
- # Dataset Metadata
381
- input MetadataInput {
382
- datasetId: ID!
383
- datasetUrl: String
384
- datasetName: String
385
- firstSnapshotCreatedAt: DateTime
386
- latestSnapshotCreatedAt: DateTime
387
- dxStatus: String
388
- tasksCompleted: [String]
389
- trialCount: Int
390
- studyDesign: String
391
- studyDomain: String
392
- studyLongitudinal: String
393
- dataProcessed: Boolean
394
- species: String
395
- associatedPaperDOI: String
396
- openneuroPaperDOI: String
397
- seniorAuthor: String
398
- adminUsers: [String]
399
- ages: [Float]
400
- modalities: [String]
401
- grantFunderName: String
402
- grantIdentifier: String
403
- affirmedDefaced: Boolean
404
- affirmedConsent: Boolean
405
- }
406
-
407
- # Information for pagination in a connection.
408
- type PageInfo {
409
- # When paginating forwards, are there more items?
410
- hasNextPage: Boolean!
411
- # When paginating backwards, are there more items?
412
- hasPreviousPage: Boolean!
413
- # When paginating backwards, the cursor to continue.
414
- startCursor: String
415
- # When paginating forwards, the cursor to continue.
416
- endCursor: String
417
- # Total results
418
- count: Int
419
- }
420
-
421
- # OpenNeuro user records from all providers
422
- type User {
423
- id: ID
424
- provider: UserProvider
425
- avatar: String
426
- orcid: String
427
- created: DateTime!
428
- modified: DateTime
429
- lastSeen: DateTime
430
- email: String
431
- name: String
432
- admin: Boolean
433
- blocked: Boolean
434
- location: String
435
- institution: String
436
- github: String
437
- githubSynced: Date
438
- links: [String]
439
- notifications: [DatasetEvent!]
440
- orcidConsent: Boolean
441
- }
442
-
443
- type UserList {
444
- users: [User!]!
445
- totalCount: Int!
446
- }
447
-
448
- # Which provider a user login comes from
449
- enum UserProvider {
450
- google
451
- orcid
452
- }
453
-
454
- # Connection for a list of datasets
455
- type DatasetConnection {
456
- # A list of dataset edges
457
- edges: [DatasetEdge]
458
- # Pagination metadata
459
- pageInfo: PageInfo!
460
- }
461
-
462
- # One connected dataset
463
- type DatasetEdge {
464
- # Edge identifier
465
- id: String!
466
- # Connected dataset
467
- node: Dataset!
468
- # Pagination cursor
469
- cursor: String!
470
- }
471
-
472
- type DatasetId {
473
- datasetId: ID
474
- }
475
-
476
- # Client metadata needed to complete an upload
477
- type UploadMetadata {
478
- # Unique identifier for this upload
479
- id: ID!
480
- # Dataset associated with this upload
481
- datasetId: ID!
482
- # Is this a complete upload (do we allow a resume or not?)
483
- complete: Boolean!
484
- # Estimated size in bytes (this is just used for progress display and can be inaccurate)
485
- estimatedSize: BigInt
486
- # On the first request, this token is returned to allow uploads into this upload bucket
487
- token: String
488
- # An endpoint index used to identify the backend responsible for these files
489
- endpoint: Int
490
- }
491
-
492
- # Top level dataset, one draft and many snapshots
493
- type Dataset {
494
- id: ID!
495
- created: DateTime!
496
- uploader: User
497
- public: Boolean
498
- draft: Draft
499
- snapshots: [Snapshot]
500
- # Newest snapshot
501
- latestSnapshot: Snapshot!
502
- permissions: DatasetPermissions
503
- analytics: Analytic
504
- stars: [Star]
505
- followers: [Follower]
506
- # Canonical name, latest snapshot or draft if no snapshot or default if neither
507
- name: String
508
- # User comments on this dataset
509
- comments: [Comment]
510
- # Am I following this dataset?
511
- following: Boolean
512
- # Have I starred this dataset?
513
- starred: Boolean
514
- # When was this dataset first made public?
515
- publishDate: DateTime
516
- # Is the dataset available for analysis on Brainlife?
517
- onBrainlife: Boolean @cacheControl(maxAge: 10080, scope: PUBLIC)
518
- # Available derivatives of this dataset
519
- derivatives: [DatasetDerivatives] @cacheControl(maxAge: 3600, scope: PUBLIC)
520
- # Dataset Metadata
521
- metadata: Metadata
522
- # Return the version history for a dataset (git log)
523
- history: [DatasetCommit]
524
- # Worker assignment
525
- worker: String
526
- # Anonymous reviewers for this dataset
527
- reviewers: [DatasetReviewer]
528
- # Dataset belongs to Brain Initiative
529
- brainInitiative: Boolean
530
- # Log of events associated with this dataset
531
- events: [DatasetEvent]
532
- # Hold automated deletion for this dataset
533
- holdDeletion: Boolean
534
- }
535
-
536
- type DatasetDerivatives {
537
- # Remote reference to display
538
- name: String
539
- # Is this an OpenNeuro derivative?
540
- local: Boolean
541
- # S3-like URL if available
542
- s3Url: String
543
- # DataLad GitHub URL if available
544
- dataladUrl: String
545
- }
546
-
547
- type DatasetCommit {
548
- # Git commit hash
549
- id: ID!
550
- # Commit time
551
- date: DateTime
552
- # Author string
553
- authorName: String
554
- # Author email
555
- authorEmail: String
556
- # Commit message
557
- message: String
558
- # Associated commit references (tags or branches)
559
- references: String
560
- # File changes in this commit
561
- files: [DiffFiles]
562
- # Files changed
563
- filesChanged: Int
564
- # Total number of insertions
565
- insertions: Int
566
- # Total number of deletions
567
- deletions: Int
568
- }
569
-
570
- type DiffFiles {
571
- # Status string (A = added, M = modified, D = deleted)
572
- status: String
573
- mode: Int
574
- # Previous path
575
- old: String
576
- # New path
577
- new: String
578
- binary: Boolean
579
- }
580
-
581
- type ValidatorCodeMessage {
582
- code: String!
583
- message: String!
584
- }
585
-
586
- # BIDS Validator (schema) issues
587
- type ValidatorIssue {
588
- code: String!
589
- subCode: String
590
- location: String
591
- severity: Severity
592
- rule: String
593
- issueMessage: String
594
- affects: String
595
- line: Int
596
- }
597
-
598
- type DatasetValidation {
599
- # Hash of the data validated
600
- id: String
601
- datasetId: String
602
- # Issue objects returned by BIDS validator
603
- issues: [ValidatorIssue]
604
- codeMessages: [ValidatorCodeMessage]
605
- # Count of errors
606
- errors: Int
607
- # Count of warnings
608
- warnings: Int
609
- }
610
-
611
- # Ephemeral draft or working tree for a dataset
612
- type Draft {
613
- id: ID
614
- # Which dataset this draft is related to
615
- dataset: Dataset
616
- # Last edit timestamp
617
- modified: DateTime
618
- # Validator summary
619
- summary: Summary
620
- # Validator issues (legacy validator)
621
- issues: [ValidationIssue]
622
- # Validator issues status (legacy validator)
623
- issuesStatus: ValidationIssueStatus
624
- # Validator issues (schema validator)
625
- validation: DatasetValidation
626
- # Committed files in the working tree
627
- files(tree: String, recursive: Boolean): [DatasetFile]
628
- # dataset_description.json fields
629
- description: Description
630
- # Dataset README
631
- readme: String
632
- # Uploads in progress or recently completed
633
- uploads: [UploadMetadata]
634
- # Git commit hash
635
- head: String
636
- # Total size in bytes of this draft
637
- size: BigInt
638
- # File issues
639
- fileCheck: FileCheck
640
- # Contributors list from datacite.yml
641
- contributors: [Contributor]
642
- }
643
-
644
- # Tagged snapshot of a draft
645
- type Snapshot @cacheControl(maxAge: 3600, scope: PUBLIC) {
646
- # Snapshot ids are dataset:tag values
647
- id: ID!
648
- # Git tag of this snapshot
649
- tag: String!
650
- # The parent dataset for this snapshot
651
- dataset: Dataset!
652
- created: DateTime
653
- # bids-validator summary of this snapshot
654
- summary: Summary
655
- # Validator issues (legacy validator)
656
- issues: [ValidationIssue]
657
- # Validator issues status (legacy validator)
658
- issuesStatus: ValidationIssueStatus
659
- # Validator issues (schema validator)
660
- validation: DatasetValidation
661
- # Snapshot files
662
- files(tree: String, recursive: Boolean): [DatasetFile]
663
- # dataset_description.json fields
664
- description: Description
665
- # Snapshot usage and download statistics
666
- analytics: Analytic
667
- # Dataset README
668
- readme: String @cacheControl(maxAge: 31536000, scope: PUBLIC)
669
- # The git hash associated with this snapshot
670
- hexsha: String
671
- # Whether or not this snapshot has been deprecated (returns null if false)
672
- deprecated: DeprecatedSnapshot
673
- # Related DOI references
674
- related: [RelatedObject]
675
- # Is the snapshot available for analysis on Brainlife?
676
- onBrainlife: Boolean @cacheControl(maxAge: 10080, scope: PUBLIC)
677
- # Total size in bytes of this snapshot
678
- size: BigInt
679
- # Contributors list from datacite.yml
680
- contributors: [Contributor]
681
- }
682
-
683
- # RelatedObject nature of relationship
684
- enum RelatedObjectRelation {
685
- sameAs
686
- derivative
687
- source
688
- }
689
-
690
- # RelatedObject kind of target object
691
- enum RelatedObjectKind {
692
- Dataset
693
- Article
694
- }
695
-
696
- # DOI for an external object
697
- type RelatedObject {
698
- # DOI string in uri format
699
- id: ID!
700
- # The nature of the relationship
701
- relation: RelatedObjectRelation!
702
- # What kind of target object is it?
703
- kind: RelatedObjectKind!
704
- # Optional description
705
- description: String
706
- }
707
-
708
- # Set on snapshots that have been deprecated
709
- type DeprecatedSnapshot {
710
- # hexsha of deprecated snapshots
711
- id: ID!
712
- # ID of user who flagged snapshot as deprecated
713
- user: String
714
- # Reason for deprecating snapshot
715
- reason: String
716
- # Timestamp of snapshot deprecation
717
- timestamp: Date
718
- }
719
-
720
- # Contents of dataset_description.json
721
- type Description @cacheControl(maxAge: 30, scope: PUBLIC) {
722
- # Draft id for this description
723
- id: ID!
724
- # Name of the dataset
725
- Name: String!
726
- # The version of the BIDS standard that was used
727
- BIDSVersion: String!
728
- # License for distribution - see BIDS specification (https://bids.neuroimaging.io) appendix II for recommended values
729
- License: String
730
- # List of individuals who contributed to the creation/curation of the dataset
731
- Authors: [String]
732
- # PI or senior author of this dataset
733
- SeniorAuthor: String
734
- # Text acknowledging contributions of individuals or institutions beyond those listed in Authors or Funding.
735
- Acknowledgements: String
736
- # Instructions how researchers using this dataset should acknowledge the original authors. This field can also be used to define a publication that should be cited in publications that use the dataset.
737
- HowToAcknowledge: String
738
- # List of sources of funding (grant numbers)
739
- Funding: [String]
740
- # List of references to publication that contain information on the dataset, or links
741
- ReferencesAndLinks: [String]
742
- # The Document Object Identifier of the dataset (not the corresponding paper).
743
- DatasetDOI: String
744
- # The BIDS DatasetType field defined as "raw" or "derivative"
745
- DatasetType: String
746
- # List of ethics committee approvals of the research protocols and/or protocol identifiers.
747
- EthicsApprovals: [String]
748
- }
749
-
750
-
751
- # Defines the Contributor type in contributors.ts
752
- type Contributor {
753
- name: String!
754
- givenName: String
755
- familyName: String
756
- orcid: String
757
- contributorType: String!
758
- order: Int
759
- }
760
-
761
- # ContributorInput input type
762
- input ContributorInput {
763
- name: String
764
- givenName: String
765
- familyName: String
766
- orcid: String
767
- contributorType: String
768
- order: Int
769
- }
770
-
771
- type UpdateContributorsPayload {
772
- success: Boolean!
773
- dataset: Dataset
774
- }
775
-
776
-
777
- # User permissions on a dataset
778
- type Permission {
779
- datasetId: ID!
780
- userId: String!
781
- level: String!
782
- user: User
783
- }
784
-
785
- # Fundamentally an array of permissions tied to an id
786
- # for better cache control
787
- type DatasetPermissions {
788
- id: ID!
789
- userPermissions: [Permission]
790
- }
791
-
792
- # Authors of a dataset
793
- type Author {
794
- ORCID: String
795
- name: String
796
- }
797
-
798
- # Validator summary from bids-validator
799
- type Summary {
800
- id: ID!
801
- modalities: [String]
802
- primaryModality: String
803
- secondaryModalities: [String]
804
- sessions: [String]
805
- subjects: [String]
806
- subjectMetadata: [SubjectMetadata]
807
- tasks: [String]
808
- size: BigInt!
809
- totalFiles: Int!
810
- dataProcessed: Boolean
811
- pet: SummaryPetFields
812
- # BIDS Specification schema version
813
- schemaVersion: String
814
- # Validator metadata
815
- validatorMetadata: ValidatorMetadata
816
- }
817
-
818
- type SummaryPetFields {
819
- BodyPart: [String]
820
- ScannerManufacturer: [String]
821
- ScannerManufacturersModelName: [String]
822
- TracerName: [String]
823
- TracerRadionuclide: [String]
824
- }
825
-
826
- type SubjectMetadata {
827
- participantId: String!
828
- age: Float
829
- sex: String
830
- group: String
831
- }
832
-
833
- type FollowDatasetResponse {
834
- following: Boolean
835
- newFollower: Follower
836
- }
837
-
838
- # Dataset Followers
839
- type Follower {
840
- userId: String
841
- datasetId: String
842
- }
843
-
844
- type StarDatasetResponse {
845
- starred: Boolean
846
- newStar: Star
847
- }
848
-
849
- # Dataset Stars
850
- type Star @cacheControl(maxAge: 300, scope: PUBLIC) {
851
- userId: String
852
- datasetId: String
853
- }
854
-
855
- enum Severity {
856
- error
857
- warning
858
- }
859
-
860
- type ValidationIssue {
861
- severity: Severity!
862
- key: String!
863
- code: Int
864
- reason: String!
865
- files: [ValidationIssueFile]
866
- additionalFileCount: Int
867
- helpUrl: String
868
- }
869
-
870
- # Legacy validator count of errors and warnings
871
- type ValidationIssueStatus {
872
- errors: Int
873
- warnings: Int
874
- }
875
-
876
- input ValidatorIssueInput {
877
- code: String!
878
- subCode: String
879
- location: String
880
- severity: Severity
881
- rule: String
882
- issueMessage: String
883
- affects: String
884
- line: Int
885
- }
886
-
887
- input ValidatorCodeMessageInput {
888
- code: String!
889
- message: String!
890
- }
891
-
892
- type ValidationIssueFile {
893
- name: String
894
- path: String
895
- key: String!
896
- code: Int
897
- file: ValidationIssueFileDetail
898
- evidence: String
899
- line: Int
900
- character: Int
901
- severity: Severity!
902
- reason: String
903
- helpUrl: String
904
- }
905
-
906
- type ValidationIssueFileDetail {
907
- name: String
908
- path: String
909
- relativePath: String
910
- }
911
-
912
- # File metadata and link to contents
913
- type DatasetFile {
914
- id: ID!
915
- filename: String!
916
- size: BigInt
917
- annexed: Boolean
918
- urls: [String]
919
- # Return a flag if this is a directory which contains more files
920
- directory: Boolean
921
- }
922
-
923
- # Update to files
924
- type FilesUpdate {
925
- datasetId: String
926
- action: String
927
- payload: [DatasetFile]
928
- }
929
-
930
- # Analytics for a dataset
931
- type Analytic @cacheControl(maxAge: 300, scope: PUBLIC) {
932
- datasetId: ID!
933
- tag: String
934
- views: Int
935
- downloads: Int
936
- }
937
-
938
- type Comment {
939
- id: ID!
940
- # Comment draft.js body
941
- text: String!
942
- # User posting the comment
943
- user: User
944
- # Comment creation time
945
- createDate: DateTime!
946
- # Any comment this is a reply to
947
- parent: Comment
948
- # Any replies to this comment
949
- replies: [Comment]
950
- }
951
-
952
- # Types of analytics
953
- enum AnalyticTypes {
954
- downloads
955
- views
956
- }
957
-
958
- # Dataset Metadata
959
- type Metadata {
960
- datasetId: ID!
961
- datasetUrl: String
962
- datasetName: String
963
- firstSnapshotCreatedAt: DateTime
964
- latestSnapshotCreatedAt: DateTime
965
- dxStatus: String
966
- tasksCompleted: [String]
967
- trialCount: Int
968
- studyDesign: String
969
- studyDomain: String
970
- studyLongitudinal: String
971
- dataProcessed: Boolean
972
- species: String
973
- associatedPaperDOI: String
974
- openneuroPaperDOI: String
975
- seniorAuthor: String
976
- adminUsers: [String]
977
- ages: [Float]
978
- modalities: [String]
979
- grantFunderName: String
980
- grantIdentifier: String
981
- affirmedDefaced: Boolean
982
- affirmedConsent: Boolean
983
- }
984
-
985
- # Info needed to access git repositories directly
986
- type RepoMetadata {
987
- # Temporary token used for HTTPS authentication via git
988
- token: String
989
- # An endpoint index used to identify the backend responsible for these files
990
- endpoint: Int
991
- }
992
-
993
- # An annexed file that has been flagged for removal.
994
- type FlaggedFile {
995
- datasetId: String
996
- snapshot: String
997
- filepath: String
998
- annexKey: String
999
- removed: Boolean
1000
- remover: User
1001
- flagged: Boolean
1002
- flagger: User
1003
- createdAt: DateTime
1004
- }
1005
-
1006
- type DatasetEventDescription {
1007
- type: String
1008
- version: String
1009
- public: Boolean
1010
- target: User
1011
- targetUserId: ID
1012
- level: String
1013
- ref: String
1014
- message: String
1015
- requestId: ID
1016
- reason: String
1017
- datasetId: ID
1018
- resolutionStatus: ResponseStatusType
1019
- contributorData: Contributor
1020
- }
1021
-
1022
- # Dataset events
1023
- type DatasetEvent {
1024
- # Unique identifier for the event
1025
- id: ID
1026
- # Timestamp of the event
1027
- timestamp: DateTime
1028
- # User associated with the event
1029
- user: User
1030
- # Event description object
1031
- event: DatasetEventDescription
1032
- # True if the event succeeded
1033
- success: Boolean
1034
- # Notes associated with the event
1035
- note: String
1036
- # top-level datasetId field
1037
- datasetId: ID
1038
- # User's notification status event
1039
- notificationStatus: UserNotificationStatus
1040
- responseStatus: ResponseStatusType
1041
- hasBeenRespondedTo: Boolean
1042
- }
1043
-
1044
-
1045
- # Possible statuses for user notification/events
1046
- enum NotificationStatusType {
1047
- UNREAD
1048
- SAVED
1049
- ARCHIVED
1050
- }
1051
-
1052
- # Define the enum for responseStatus
1053
- enum ResponseStatusType {
1054
- PENDING
1055
- ACCEPTED
1056
- DENIED
1057
- }
1058
-
1059
- # User's notification status
1060
- type UserNotificationStatus {
1061
- status: NotificationStatusType!
1062
- }
1063
-
1064
-
1065
-
1066
- type FileCheck {
1067
- datasetId: String!
1068
- hexsha: String!
1069
- refs: [String!]!
1070
- annexFsck: [AnnexFsck!]
1071
- remote: String
1072
- }
1073
-
1074
- type AnnexFsck {
1075
- command: String
1076
- errorMessages: [String]
1077
- file: String
1078
- key: String
1079
- note: String
1080
- success: Boolean
1081
- }
1082
-
1083
- input AnnexFsckInput {
1084
- command: String
1085
- errorMessages: [String]
1086
- file: String
1087
- key: String
1088
- note: String
1089
- success: Boolean
1090
- dead: [String]
1091
- missing: [String]
1092
- untrusted: [String]
1093
- input: [String]
1094
- }
1095
-
1096
- type WorkerTask {
1097
- id: ID!
1098
- args: JSON
1099
- kwargs: JSON
1100
- taskName: String
1101
- worker: String
1102
- queuedAt: DateTime
1103
- startedAt: DateTime
1104
- finishedAt: DateTime
1105
- error: String
1106
- executionTime: Int
1107
- }
1108
- `
1109
-
1110
- schemaComposer.addTypeDefs(typeDefs)
1111
- schemaComposer.addResolveMethods(resolvers)
1112
- schemaComposer.Query.addFields(datasetSearch)
1113
- schemaComposer.Query.addFields(advancedDatasetSearch)
1114
- export default schemaComposer.buildSchema()
1
+ import { builder } from "./builder"
2
+
3
+ // Side-effect imports register types with the builder
4
+ import "./schema/scalars"
5
+ import "./schema/enums"
6
+ import "./schema/inputs"
7
+ import "./schema/refs"
8
+ import "./schema/pagination"
9
+ import "./schema/analytics"
10
+ import "./schema/description"
11
+ import "./schema/files"
12
+ import "./schema/validation"
13
+ import "./schema/metadata"
14
+ import "./schema/reviewer"
15
+ import "./schema/upload"
16
+ import "./schema/worker"
17
+ import "./schema/misc"
18
+ import "./schema/permissions"
19
+ import "./schema/user"
20
+ import "./schema/comment"
21
+ import "./schema/dataset-events"
22
+ import "./schema/draft"
23
+ import "./schema/snapshot"
24
+ import "./schema/dataset"
25
+ import "./schema/dataset-search"
26
+ import "./schema/query"
27
+ import "./schema/mutation"
28
+
29
+ export default builder.toSchema()