@openneuro/server 4.47.7 → 5.0.0-alpha.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 (45) hide show
  1. package/package.json +10 -7
  2. package/src/app.ts +1 -1
  3. package/src/cache/__tests__/tree.spec.ts +212 -0
  4. package/src/cache/tree.ts +148 -0
  5. package/src/datalad/__tests__/dataRetentionNotifications.spec.ts +11 -0
  6. package/src/datalad/__tests__/files.spec.ts +249 -0
  7. package/src/datalad/dataRetentionNotifications.ts +5 -0
  8. package/src/datalad/dataset.ts +29 -1
  9. package/src/datalad/files.ts +362 -39
  10. package/src/datalad/snapshots.ts +29 -54
  11. package/src/graphql/resolvers/__tests__/response-status.spec.ts +42 -0
  12. package/src/graphql/resolvers/build-search-query.ts +391 -0
  13. package/src/graphql/resolvers/cache.ts +5 -1
  14. package/src/graphql/resolvers/dataset-search.ts +40 -23
  15. package/src/graphql/resolvers/datasetEvents.ts +48 -78
  16. package/src/graphql/resolvers/draft.ts +5 -2
  17. package/src/graphql/resolvers/holdDeletion.ts +21 -0
  18. package/src/graphql/resolvers/index.ts +6 -0
  19. package/src/graphql/resolvers/mutation.ts +2 -0
  20. package/src/graphql/resolvers/response-status.ts +43 -0
  21. package/src/graphql/resolvers/snapshots.ts +9 -18
  22. package/src/graphql/resolvers/summary.ts +17 -0
  23. package/src/graphql/schema.ts +54 -14
  24. package/src/handlers/datalad.ts +4 -0
  25. package/src/handlers/doi.ts +32 -36
  26. package/src/libs/doi/__tests__/doi.spec.ts +50 -12
  27. package/src/libs/doi/__tests__/validate.spec.ts +110 -0
  28. package/src/libs/doi/index.ts +108 -71
  29. package/src/libs/doi/metadata.ts +101 -0
  30. package/src/libs/doi/validate.ts +59 -0
  31. package/src/libs/presign.ts +137 -0
  32. package/src/models/dataset.ts +2 -0
  33. package/src/models/doi.ts +7 -0
  34. package/src/queues/producer-methods.ts +9 -5
  35. package/src/queues/queue-schedule.ts +1 -1
  36. package/src/queues/queues.ts +2 -2
  37. package/src/routes.ts +10 -2
  38. package/src/types/datacite/LICENSE +37 -0
  39. package/src/types/datacite/README.md +3 -0
  40. package/src/types/datacite/datacite-v4.5.json +643 -0
  41. package/src/types/datacite/datacite-v4.5.ts +281 -0
  42. package/src/types/datacite.ts +53 -63
  43. package/src/utils/datacite-mapper.ts +7 -3
  44. package/src/utils/datacite-utils.ts +12 -15
  45. package/src/libs/doi/__tests__/__snapshots__/doi.spec.ts.snap +0 -17
package/src/models/doi.ts CHANGED
@@ -1,17 +1,24 @@
1
1
  import mongoose from "mongoose"
2
2
  import type { Document } from "mongoose"
3
+ import type { DoiState } from "../types/datacite"
3
4
  const { Schema, model } = mongoose
4
5
 
5
6
  export interface DoiDocument extends Document {
6
7
  datasetId: string
7
8
  snapshotId: string
8
9
  doi: string
10
+ state: DoiState
9
11
  }
10
12
 
11
13
  const doiSchema = new Schema({
12
14
  datasetId: String,
13
15
  snapshotId: String,
14
16
  doi: String,
17
+ state: {
18
+ type: String,
19
+ enum: ["draft", "registered", "findable"],
20
+ default: "draft",
21
+ },
15
22
  })
16
23
 
17
24
  const Doi = model<DoiDocument>("Doi", doiSchema)
@@ -25,14 +25,18 @@ export function queueIndexDataset(datasetId: string) {
25
25
  * Queue data retention check for a dataset
26
26
  * @param datasetId Dataset to check
27
27
  */
28
- export function queueDataRetentionCheck(datasetId: string) {
28
+ export async function queueDataRetentionCheck(
29
+ datasetId: string,
30
+ ): Promise<void> {
29
31
  try {
30
32
  const msg = new ProducibleMessage()
31
33
  msg.setQueue(OpenNeuroQueues.DATARETENTION).setBody({ datasetId })
32
- producer.produce(msg, (err) => {
33
- if (err) {
34
- Sentry.captureException(err)
35
- }
34
+ msg.setTTL(64800000) // 18 hours in ms to survive the consumer rate limits
35
+ await new Promise<void>((resolve, reject) => {
36
+ producer.produce(msg, (err) => {
37
+ if (err) reject(err)
38
+ else resolve()
39
+ })
36
40
  })
37
41
  } catch (err) {
38
42
  Sentry.captureException(err)
@@ -14,7 +14,7 @@ async function enqueueAllDatasetChecks(): Promise<void> {
14
14
  const cursor = Dataset.find({}, "id").cursor()
15
15
  for await (const dataset of cursor) {
16
16
  // Check data retention policy status and send notifications
17
- queueDataRetentionCheck(dataset.id)
17
+ await queueDataRetentionCheck(dataset.id)
18
18
  }
19
19
  }
20
20
 
@@ -55,6 +55,6 @@ export async function setupQueues(): Promise<void> {
55
55
  // Limit indexing queue to 8 runs per minute to avoid stacking indexing excessively
56
56
  await setRateLimit(OpenNeuroQueues.INDEXING, 8, 60000)
57
57
 
58
- // Rate limit data retention queue to 16 runs per minute
59
- await setRateLimit(OpenNeuroQueues.DATARETENTION, 16, 60000)
58
+ // Rate limit data retention queue to 60 runs per minute
59
+ await setRateLimit(OpenNeuroQueues.DATARETENTION, 60, 60000)
60
60
  }
package/src/routes.ts CHANGED
@@ -190,8 +190,16 @@ const routes = [
190
190
  // git redirect routes
191
191
  { method: "get", url: "/git/:datasetId", handler: datalad.gitRepo },
192
192
  { method: "post", url: "/git/:datasetId", handler: datalad.gitRepo },
193
- { method: "get", url: "/git/:datasetId/*", handler: datalad.gitRepo },
194
- { method: "post", url: "/git/:datasetId/*", handler: datalad.gitRepo },
193
+ {
194
+ method: "get",
195
+ url: "/git/:datasetId/*arguments",
196
+ handler: datalad.gitRepo,
197
+ },
198
+ {
199
+ method: "post",
200
+ url: "/git/:datasetId/*arguments",
201
+ handler: datalad.gitRepo,
202
+ },
195
203
  ]
196
204
 
197
205
  // initialize routes -------------------------------
@@ -0,0 +1,37 @@
1
+ DataCite is free software; you can redistribute it and/or modify
2
+ it under the terms of the Revised BSD License quoted below.
3
+
4
+ Copyright (C) 2015-2018 CERN.
5
+ Copyright (C) 2018 Center for Open Science.
6
+ Copyright (C) 2019-2024 Caltech.
7
+ Copyright (C) 2024 Institute of Biotechnology of the Czech Academy of Sciences.
8
+
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are
13
+ met:
14
+
15
+ * Redistributions of source code must retain the above copyright
16
+ notice, this list of conditions and the following disclaimer.
17
+
18
+ * Redistributions in binary form must reproduce the above copyright
19
+ notice, this list of conditions and the following disclaimer in the
20
+ documentation and/or other materials provided with the distribution.
21
+
22
+ * Neither the name of the copyright holder nor the names of its
23
+ contributors may be used to endorse or promote products derived from
24
+ this software without specific prior written permission.
25
+
26
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30
+ HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
33
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
35
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
36
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
37
+ DAMAGE.
@@ -0,0 +1,3 @@
1
+ Generate `datacite-v4.5.ts` with `npx json-schema-to-typescript datacite-v4.5.json`.
2
+
3
+ `datacite-v4.5.json` sourced from https://github.com/inveniosoftware/datacite/blob/5506d1347a070952d2c2b96c213f44c5fa46d0dd/datacite/schemas/datacite-v4.5.json