@openneuro/app 4.17.2 → 4.18.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.
@@ -20,7 +20,7 @@ class Issue extends React.Component {
20
20
  if (error.character) {
21
21
  errLocation += 'Character: ' + error.character + ''
22
22
  }
23
- if (errLocation == '' && error.evidence) {
23
+ if (errLocation === '' && error.evidence) {
24
24
  errLocation = 'Evidence: '
25
25
  }
26
26
  if (errLocation) {
@@ -11,7 +11,7 @@ class Issues extends React.Component {
11
11
  render() {
12
12
  const issueFiles = this.props.issues
13
13
  const issues = issueFiles.map((issue, index) => {
14
- let totalFiles = issue.files.length
14
+ let totalFiles = issue.files.length || issue.files.size
15
15
  if (issue.additionalFileCount) {
16
16
  totalFiles += issue.additionalFileCount
17
17
  }
@@ -32,16 +32,32 @@ class Issues extends React.Component {
32
32
  )
33
33
 
34
34
  // issue sub-errors
35
- const subErrors = issue.files.map((error, index2) => {
36
- return error ? (
37
- <Issue
38
- type={this.props.issueType}
39
- file={issue.file}
40
- error={error}
41
- index={index2}
42
- key={index2}
43
- />
44
- ) : null
35
+ const subErrors = Array.from(issue.files).map((error, index2) => {
36
+ // Schema validator returns multiple files here
37
+ // map those to the old sub-issue model to display them
38
+ if (error?.length) {
39
+ return error.filter(Boolean).map((i, index3) => {
40
+ return (
41
+ <Issue
42
+ type={this.props.issueType}
43
+ file={i.file}
44
+ error={i}
45
+ index={index3}
46
+ key={index3}
47
+ />
48
+ )
49
+ })
50
+ } else {
51
+ return error ? (
52
+ <Issue
53
+ type={this.props.issueType}
54
+ file={issue.file}
55
+ error={error}
56
+ index={index2}
57
+ key={index2}
58
+ />
59
+ ) : null
60
+ }
45
61
  })
46
62
 
47
63
  if (issue.additionalFileCount > 0) {
@@ -78,7 +78,7 @@ class ValidationResults extends React.Component {
78
78
  _countFiles(issues) {
79
79
  let numFiles = 0
80
80
  for (const issue of issues) {
81
- numFiles += issue.files.length
81
+ numFiles += Array.from(issue.files).length
82
82
  if (issue.additionalFileCount) {
83
83
  numFiles += issue.additionalFileCount
84
84
  }
@@ -0,0 +1,13 @@
1
+ import { runValidator } from './schema.worker' // eslint-disable-line import/no-unresolved
2
+ import { BIDSValidatorIssues } from './worker-interface'
3
+
4
+ function init(files, options): Promise<BIDSValidatorIssues> {
5
+ return new Promise((resolve, reject) => {
6
+ void runValidator(files, options, ({ error, output }) => {
7
+ if (error) reject(error)
8
+ else resolve(output)
9
+ })
10
+ })
11
+ }
12
+
13
+ export default init
@@ -0,0 +1,29 @@
1
+ /* eslint-env worker */
2
+ import { validate, fileListToTree } from '../utils/schema-validator.js'
3
+ import { BIDSValidatorIssues } from './worker-interface'
4
+
5
+ export async function runValidator(
6
+ files,
7
+ options,
8
+ cb,
9
+ ): Promise<BIDSValidatorIssues> {
10
+ let error
11
+ const output = {
12
+ issues: { errors: [], warnings: [] },
13
+ summary: {},
14
+ } as BIDSValidatorIssues
15
+ try {
16
+ const tree = await fileListToTree(files)
17
+ const result = await validate(tree, { json: true })
18
+ const issues = Array.from(result.issues, ([key, value]) => value)
19
+ output.issues.warnings = issues.filter(
20
+ issue => issue.severity === 'warning',
21
+ )
22
+ output.issues.errors = issues.filter(issue => issue.severity === 'error')
23
+ output.summary = result.summary
24
+ } catch (err) {
25
+ error = err
26
+ }
27
+ cb({ error, output })
28
+ return output
29
+ }
@@ -1,5 +1,8 @@
1
1
  // Shared interface for BIDSValidatorIssues shared without cross import for validate and validate.worker
2
2
  export interface BIDSValidatorIssues {
3
- issues: Record<string, unknown>[]
3
+ issues: {
4
+ errors: Record<string, unknown>[]
5
+ warnings: Record<string, unknown>[]
6
+ }
4
7
  summary: Record<string, unknown>
5
8
  }
package/vite.config.js CHANGED
@@ -7,6 +7,7 @@ export default defineConfig({
7
7
  server: {
8
8
  port: 80,
9
9
  host: '0.0.0.0',
10
+ cors: true,
10
11
  },
11
12
  build: {
12
13
  sourcemap: true,