@openneuro/app 4.15.2-alpha.9 → 4.15.2-demo.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.
@@ -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,7 +32,7 @@ class Issues extends React.Component {
32
32
  )
33
33
 
34
34
  // issue sub-errors
35
- const subErrors = issue.files.map((error, index2) => {
35
+ const subErrors = Array.from(issue.files).map((error, index2) => {
36
36
  return error ? (
37
37
  <Issue
38
38
  type={this.props.issueType}
@@ -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
  }
@@ -1,22 +1,25 @@
1
1
  /* eslint-env worker */
2
- import validate from 'bids-validator'
2
+ import { validate, fileListToTree } from '../utils/schema-validator.js'
3
3
  import { BIDSValidatorIssues } from './worker-interface'
4
4
 
5
- const asyncValidateBIDS = (files, options): Promise<BIDSValidatorIssues> =>
6
- new Promise(resolve => {
7
- validate.BIDS(files, options, (issues, summary) =>
8
- resolve({ issues, summary }),
9
- )
10
- })
11
-
12
5
  export async function runValidator(
13
6
  files,
14
7
  options,
15
8
  cb,
16
9
  ): Promise<BIDSValidatorIssues> {
17
10
  let error, output: BIDSValidatorIssues
11
+ output = { issues: { errors: [], warnings: [] }, summary: {} }
18
12
  try {
19
- output = await asyncValidateBIDS(files, options)
13
+ const tree = await fileListToTree(files)
14
+ const result = await validate(tree, { json: true })
15
+ const issues = Array.from(result.issues, ([key, value]) => value)
16
+ console.log(issues)
17
+ output.issues.warnings = issues.filter(
18
+ issue => issue.severity === 'warning',
19
+ )
20
+ output.issues.errors = issues.filter(issue => issue.severity === 'error')
21
+ output.summary = result.summary
22
+ console.log(output)
20
23
  } catch (err) {
21
24
  error = err
22
25
  }
@@ -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,