@openneuro/server 3.36.6-alpha.0 → 3.36.6-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": "3.36.6-alpha.0",
3
+ "version": "3.36.6-alpha.4",
4
4
  "description": "Core service for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "src/server.js",
@@ -61,6 +61,7 @@
61
61
  "react-dom": "^17.0.1",
62
62
  "redlock": "^4.0.0",
63
63
  "request": "^2.83.0",
64
+ "semver": "^5.5.0",
64
65
  "sitemap": "^2.1.0",
65
66
  "subscriptions-transport-ws": "0.9.18",
66
67
  "superagent": "^3.8.2",
@@ -81,6 +82,7 @@
81
82
  "@types/ioredis": "^4.17.1",
82
83
  "@types/jest": "^26.0.23",
83
84
  "@types/nodemailer": "^6.4.1",
85
+ "@types/semver": "^5",
84
86
  "apollo-link-schema": "^1.2.5",
85
87
  "babel-eslint": "^10.1.0",
86
88
  "core-js": "^3.10.1",
@@ -102,5 +104,5 @@
102
104
  "publishConfig": {
103
105
  "access": "public"
104
106
  },
105
- "gitHead": "bf1e240880aec72270e1bb31648d07045dca3d56"
107
+ "gitHead": "3bb8cca2661acc0375c29c2f3cf32eedc53ed8ed"
106
108
  }
@@ -27,16 +27,20 @@ describe('dataset resolvers', () => {
27
27
  })
28
28
  })
29
29
  describe('snapshotCreationComparison()', () => {
30
- it('sorts array of objects by the "created" property', () => {
30
+ it('sorts array of objects by the "created" and "tag" properties', () => {
31
31
  const testArray = [
32
- { id: 2, created: new Date('2018-11-20T00:05:43.473Z') },
33
- { id: 1, created: new Date('2018-11-19T00:05:43.473Z') },
34
- { id: 3, created: new Date('2018-11-23T00:05:43.473Z') },
32
+ { id: 2, created: new Date('2018-11-20T00:05:43.473Z'), tag: '1.0.0' },
33
+ { id: 1, created: new Date('2018-11-19T00:05:43.473Z'), tag: '1.0.1' },
34
+ { id: 3, created: new Date('2018-11-23T00:05:43.473Z'), tag: '1.0.2' },
35
+ { id: 5, created: new Date('2018-11-23T00:05:43.473Z'), tag: '1.0.10' },
36
+ { id: 4, created: new Date('2018-11-23T00:05:43.473Z'), tag: '1.0.3' },
35
37
  ]
36
38
  const sorted = testArray.sort(ds.snapshotCreationComparison)
37
39
  expect(sorted[0].id).toBe(1)
38
40
  expect(sorted[1].id).toBe(2)
39
41
  expect(sorted[2].id).toBe(3)
42
+ expect(sorted[3].id).toBe(4)
43
+ expect(sorted[4].id).toBe(5)
40
44
  })
41
45
  it('sorts array of objects by the "created" property as strings', () => {
42
46
  const testArray = [
@@ -60,18 +64,16 @@ describe('dataset resolvers', () => {
60
64
  mockingoose.Dataset.toReturn(true, 'count')
61
65
  // capture and check datalad delete request
62
66
  request.del = url => ({
63
- set: (header1, headerValue1) => ({
67
+ set: (header1, headerValue1) => ({
64
68
  set: () => ({
65
- send: ({ filenames}) => {
66
- expect(url).toEqual(
67
- 'http://datalad-0/datasets/ds999999/files',
68
- )
69
+ send: ({ filenames }) => {
70
+ expect(url).toEqual('http://datalad-0/datasets/ds999999/files')
69
71
  expect(filenames).toEqual([':sub-99'])
70
72
  expect(header1).toEqual('Cookie')
71
73
  expect(headerValue1).toMatch(/^accessToken=/)
72
- }
73
- }),
74
+ },
74
75
  }),
76
+ }),
75
77
  })
76
78
 
77
79
  ds.deleteFiles(
@@ -23,6 +23,7 @@ import { UpdatedFile } from '../utils/file.js'
23
23
  import { getDatasetWorker } from '../../libs/datalad-service.js'
24
24
  import { getDraftHead } from '../../datalad/dataset.js'
25
25
  import { getFileName } from '../../datalad/files.js'
26
+ import semver from 'semver'
26
27
 
27
28
  export const dataset = async (obj, { id }, { user, userInfo }) => {
28
29
  await checkDatasetRead(id, user, userInfo)
@@ -41,8 +42,14 @@ export const datasets = (parent, args, { user, userInfo }) => {
41
42
  }
42
43
  }
43
44
 
44
- export const snapshotCreationComparison = ({ created: a }, { created: b }) => {
45
- return new Date(a).getTime() - new Date(b).getTime()
45
+ export const snapshotCreationComparison = (
46
+ { created: a, tag: a_tag },
47
+ { created: b, tag: b_tag },
48
+ ) => {
49
+ return (
50
+ new Date(a).getTime() - new Date(b).getTime() ||
51
+ semver.compare(a_tag, b_tag)
52
+ )
46
53
  }
47
54
 
48
55
  /**