adapt-authoring-jsonschema 1.5.0 → 1.6.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.
@@ -10,7 +10,8 @@ permissions:
10
10
  issues: write
11
11
  pull-requests: write
12
12
  id-token: write
13
+ packages: write
13
14
 
14
15
  jobs:
15
16
  release:
16
- uses: adaptlearning/semantic-release-config/.github/workflows/release.yml@master
17
+ uses: adaptlearning/semantic-release-config/.github/workflows/release.yml@master
@@ -1,6 +1,5 @@
1
1
  import { AbstractModule, App, Hook } from 'adapt-authoring-core'
2
2
  import { glob } from 'glob'
3
- import path from 'path'
4
3
  import { Schemas, SchemaError, XSSDefaults } from 'adapt-schemas'
5
4
 
6
5
  /**
@@ -41,19 +40,9 @@ class JsonSchemaModule extends AbstractModule {
41
40
  modifying: true,
42
41
  schemaType: 'boolean',
43
42
  compile: function () {
44
- const doReplace = value => {
45
- const app = App.instance
46
- return [
47
- ['$ROOT', app.rootDir],
48
- ['$DATA', app.getConfig('dataDir')],
49
- ['$TEMP', app.getConfig('tempDir')]
50
- ].reduce((m, [k, v]) => {
51
- return m.startsWith(k) ? path.resolve(v, m.replace(k, '').slice(1)) : m
52
- }, value)
53
- }
54
43
  return (value, { parentData, parentDataProperty }) => {
55
44
  try {
56
- parentData[parentDataProperty] = doReplace(value)
45
+ parentData[parentDataProperty] = App.instance.config.resolveDirectory(value)
57
46
  } catch (e) {}
58
47
  return true
59
48
  }
@@ -61,7 +50,6 @@ class JsonSchemaModule extends AbstractModule {
61
50
  })
62
51
 
63
52
  this._schemasRegistered = this.onReady()
64
- .then(() => this.app.waitForModule('config', 'errors'))
65
53
  .then(() => {
66
54
  // Update library options from config
67
55
  this._library.options.enableCache = this.getConfig('enableCache')
@@ -234,7 +222,7 @@ class JsonSchemaModule extends AbstractModule {
234
222
  return this._library.getSchema(schemaName, options)
235
223
  } catch (e) {
236
224
  if (e instanceof SchemaError && e.code === 'MISSING_SCHEMA') {
237
- throw this.app.errors.MISSING_SCHEMA.setData({ schemaName })
225
+ throw this.app.errors.MISSING_SCHEMA.setData({ schemaName: e.data?.schemaName ?? schemaName })
238
226
  }
239
227
  throw e
240
228
  }
@@ -245,8 +233,8 @@ class JsonSchemaModule extends AbstractModule {
245
233
  */
246
234
  logSchemas () {
247
235
  this.log('debug', 'SCHEMAS', Object.keys(this.schemas))
248
- this.log('debug', 'SCHEMA_EXTENSIONS', Object.entries(this.schemas).reduce((m, [k, v]) => {
249
- if (v.extensions.length) m[k] = v.extensions
236
+ this.log('debug', 'SCHEMA_EXTENSIONS', Object.entries(this.schemaExtensions).reduce((m, [k, v]) => {
237
+ if (v?.length) m[k] = v
250
238
  return m
251
239
  }, {}))
252
240
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-jsonschema",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Module to add support for the JSON schema specification",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-jsonschema",
6
6
  "license": "GPL-3.0",
@@ -14,13 +14,9 @@
14
14
  },
15
15
  "repository": "github:adapt-security/adapt-authoring-jsonschema",
16
16
  "dependencies": {
17
- "adapt-authoring-core": "^2.0.0",
17
+ "adapt-authoring-core": "^3.0.0",
18
18
  "adapt-schemas": "^3.1.0"
19
19
  },
20
- "peerDependencies": {
21
- "adapt-authoring-config": "^1.1.4",
22
- "adapt-authoring-errors": "^1.1.2"
23
- },
24
20
  "devDependencies": {
25
21
  "@adaptlearning/semantic-release-config": "^1.0.0",
26
22
  "standard": "^17.1.0"