adapt-authoring-jsonschema 1.4.6 → 1.5.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.
@@ -1,32 +1,17 @@
1
1
  name: Release
2
+
2
3
  on:
3
4
  push:
4
5
  branches:
5
6
  - master
6
7
 
8
+ permissions:
9
+ contents: write
10
+ issues: write
11
+ pull-requests: write
12
+ id-token: write
13
+ packages: write
14
+
7
15
  jobs:
8
16
  release:
9
- name: Release
10
- runs-on: ubuntu-latest
11
- permissions:
12
- contents: write # to be able to publish a GitHub release
13
- issues: write # to be able to comment on released issues
14
- pull-requests: write # to be able to comment on released pull requests
15
- id-token: write # to enable use of OIDC for trusted publishing and npm provenance
16
- steps:
17
- - name: Checkout
18
- uses: actions/checkout@v3
19
- with:
20
- fetch-depth: 0
21
- - name: Setup Node.js
22
- uses: actions/setup-node@v3
23
- with:
24
- node-version: 'lts/*'
25
- - name: Update npm
26
- run: npm install -g npm@latest
27
- - name: Install dependencies
28
- run: npm install
29
- - name: Release
30
- env:
31
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
- run: npx semantic-release
17
+ uses: adaptlearning/semantic-release-config/.github/workflows/release.yml@master
@@ -1,9 +1,4 @@
1
1
  export default class SchemasReference {
2
- constructor (appData, config, dir, utils) {
3
- this.appData = appData
4
- this.utils = utils
5
- }
6
-
7
2
  async run () {
8
3
  this.schemas = await this.loadSchemas()
9
4
  this.manualFile = 'schemas-reference.md'
@@ -12,7 +7,7 @@ export default class SchemasReference {
12
7
  }
13
8
 
14
9
  async loadSchemas () {
15
- const { schemas, raw } = this.appData.schemas
10
+ const { schemas, raw } = this.app.schemas
16
11
  return Object.keys(schemas)
17
12
  .sort((a, b) => a.localeCompare(b))
18
13
  .reduce((m, s) => Object.assign(m, { [s]: raw[s] }), {})
@@ -33,7 +33,7 @@ class JsonSchemaModule extends AbstractModule {
33
33
  this._library.on('schemaExtended', (base, ext) => this.log('verbose', 'EXTEND_SCHEMA', base, ext))
34
34
  this._library.on('reset', () => this.log('debug', 'RESET_SCHEMAS'))
35
35
 
36
- await this._library.init()
36
+ this._library.init()
37
37
 
38
38
  this._library.addKeyword({
39
39
  keyword: 'isDirectory',
@@ -122,8 +122,8 @@ class JsonSchemaModule extends AbstractModule {
122
122
  /**
123
123
  * Empties the schema registry (with the exception of the base schema)
124
124
  */
125
- async resetSchemaRegistry () {
126
- await this._library.resetSchemaRegistry()
125
+ resetSchemaRegistry () {
126
+ this._library.resetSchemaRegistry()
127
127
  }
128
128
 
129
129
  /**
@@ -152,14 +152,17 @@ class JsonSchemaModule extends AbstractModule {
152
152
  * @return {Promise}
153
153
  */
154
154
  async registerSchemas (options = {}) {
155
- await this.resetSchemaRegistry()
155
+ this.resetSchemaRegistry()
156
156
  await Promise.all(Object.values(this.app.dependencies).map(async d => {
157
157
  if (d.name === this.name) return
158
158
  const files = await glob('schema/*.schema.json', { cwd: d.rootDir, absolute: true })
159
- const results = await Promise.allSettled(files.map(f => this.registerSchema(f)))
160
- results
161
- .filter(r => r.status === 'rejected')
162
- .forEach(r => this.log('warn', r.reason))
159
+ for (const f of files) {
160
+ try {
161
+ this.registerSchema(f)
162
+ } catch (e) {
163
+ this.log('warn', e)
164
+ }
165
+ }
163
166
  }))
164
167
  await this.registerSchemasHook.invoke()
165
168
  if (options.quiet !== true) this.logSchemas()
@@ -170,11 +173,11 @@ class JsonSchemaModule extends AbstractModule {
170
173
  * @param {String} filePath Path to the schema file
171
174
  * @param {Object} options Extra options
172
175
  * @param {Boolean} options.replace Replace existing schema with same name
173
- * @return {Promise<Schema>}
176
+ * @return {Schema}
174
177
  */
175
- async registerSchema (filePath, options = {}) {
178
+ registerSchema (filePath, options = {}) {
176
179
  try {
177
- return await this._library.registerSchema(filePath, options)
180
+ return this._library.registerSchema(filePath, options)
178
181
  } catch (e) {
179
182
  // Convert library errors to app errors
180
183
  if (e instanceof SchemaError) {
@@ -199,7 +202,7 @@ class JsonSchemaModule extends AbstractModule {
199
202
  * Creates a new Schema instance
200
203
  * @param {String} filePath Path to the schema file
201
204
  * @param {Object} options Options passed to Schema constructor
202
- * @returns {Promise<Schema>}
205
+ * @returns {Schema}
203
206
  */
204
207
  createSchema (filePath, options = {}) {
205
208
  return this._library.createSchema(filePath, {
@@ -228,10 +231,10 @@ class JsonSchemaModule extends AbstractModule {
228
231
  async getSchema (schemaName, options = {}) {
229
232
  await this._schemasRegistered
230
233
  try {
231
- return await this._library.getSchema(schemaName, options)
234
+ return this._library.getSchema(schemaName, options)
232
235
  } catch (e) {
233
236
  if (e instanceof SchemaError && e.code === 'MISSING_SCHEMA') {
234
- throw this.app.errors.MISSING_SCHEMA.setData({ schemaName })
237
+ throw this.app.errors.MISSING_SCHEMA.setData({ schemaName: e.data?.schemaName ?? schemaName })
235
238
  }
236
239
  throw e
237
240
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-jsonschema",
3
- "version": "1.4.6",
3
+ "version": "1.5.1",
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",
@@ -15,35 +15,17 @@
15
15
  "repository": "github:adapt-security/adapt-authoring-jsonschema",
16
16
  "dependencies": {
17
17
  "adapt-authoring-core": "^2.0.0",
18
- "adapt-schemas": "^2.0.0"
18
+ "adapt-schemas": "^3.1.0"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "adapt-authoring-config": "^1.1.4",
22
22
  "adapt-authoring-errors": "^1.1.2"
23
23
  },
24
24
  "devDependencies": {
25
- "@semantic-release/git": "^10.0.1",
26
- "conventional-changelog-eslint": "^6.0.0",
27
- "semantic-release": "^25.0.2",
25
+ "@adaptlearning/semantic-release-config": "^1.0.0",
28
26
  "standard": "^17.1.0"
29
27
  },
30
28
  "release": {
31
- "plugins": [
32
- [
33
- "@semantic-release/commit-analyzer",
34
- {
35
- "preset": "eslint"
36
- }
37
- ],
38
- [
39
- "@semantic-release/release-notes-generator",
40
- {
41
- "preset": "eslint"
42
- }
43
- ],
44
- "@semantic-release/npm",
45
- "@semantic-release/github",
46
- "@semantic-release/git"
47
- ]
29
+ "extends": "@adaptlearning/semantic-release-config"
48
30
  }
49
31
  }
@@ -85,9 +85,9 @@ describe('JsonSchemaModule', () => {
85
85
  })
86
86
 
87
87
  describe('#resetSchemaRegistry()', () => {
88
- it('should call the library resetSchemaRegistry', async () => {
88
+ it('should call the library resetSchemaRegistry', () => {
89
89
  const { instance, mockSchemas } = createInstance()
90
- await instance.resetSchemaRegistry()
90
+ instance.resetSchemaRegistry()
91
91
  assert.equal(mockSchemas.resetSchemaRegistry.mock.calls.length, 1)
92
92
  })
93
93
  })