From 322971e67c25586f9879d158d56c64444fc443a0 Mon Sep 17 00:00:00 2001 From: Thiren Bunsee Date: Thu, 12 Sep 2024 13:31:05 +0200 Subject: [PATCH 1/5] chore(deps): updated npm dependencies, mainly json-magic --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 7411bcd..c796b3a 100644 --- a/package.json +++ b/package.json @@ -42,26 +42,26 @@ "node": ">=12.0.0" }, "dependencies": { - "@synatic/json-magic": "^1.0.0", + "@synatic/json-magic": "^1.1.0", "@synatic/type-magic": "^1.0.0", "ajv": "6.12.6", "ajv-keywords": "3.5.2", "bson-objectid": "2.0.4", - "check-types": "11.2.2", + "check-types": "11.2.3", "clone-deep": "4.0.1", - "cron-parser": "4.8.1", + "cron-parser": "4.9.0", "jsonpath-plus": "7.2.0", - "moment": "2.29.4", - "moment-timezone": "0.5.43", - "underscore": "1.13.6", + "moment": "2.30.1", + "moment-timezone": "0.5.45", + "underscore": "1.13.7", "underscore.string": "3.3.6" }, "devDependencies": { "eslint": "^8.17.0", "eslint-config-google": "^0.14.0", - "eslint-config-prettier": "^8.5.0", - "mocha": "^10.0.0", - "nyc": "^15.1.0", - "prettier": "^2.6.2" + "eslint-config-prettier": "^9.1.0", + "mocha": "^10.7.3", + "nyc": "^17.0.0", + "prettier": "^3.3.2" } } From 5f457a1a79333156e0455f75f9c28efa55763896 Mon Sep 17 00:00:00 2001 From: Thiren Bunsee Date: Thu, 12 Sep 2024 13:31:37 +0200 Subject: [PATCH 2/5] test: added a test --- test/test.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 70dffd6..a586501 100644 --- a/test/test.js +++ b/test/test.js @@ -332,7 +332,7 @@ describe('Schema Magic', function () { required: false, }, ]; - console.log(newOutput); + assert.deepEqual(SchemaMagic.flattenSchema(schema), output, 'Invalid flatten'); }); }); @@ -398,7 +398,14 @@ describe('Schema Magic', function () { describe('JSON Generate', function () { it('generate a simple schema', function () { assert.deepEqual(SchemaMagic.generateSchemaFromJSON(null), {type: 'null'}, 'Invalid schema generate'); - assert.deepEqual(SchemaMagic.generateSchemaFromJSON('abc'), {type: 'string', stringLength: 3}, 'Invalid schema generate'); + assert.deepEqual( + SchemaMagic.generateSchemaFromJSON('abc'), + { + type: 'string', + stringLength: 3, + }, + 'Invalid schema generate' + ); assert.deepEqual(SchemaMagic.generateSchemaFromJSON(1), {type: 'integer'}, 'Invalid schema generate'); assert.deepEqual( SchemaMagic.generateSchemaFromJSON(new Date()), @@ -646,6 +653,14 @@ describe('Schema Magic', function () { assert.deepEqual(SchemaMagic.mergeSchemas(schemas), result, 'Invalid schema merge'); }); + it('should merge a simple schema with date-time fields', function () { + const schemas = [{type: 'string', format: 'date-time'}, {type: 'string'}]; + + const result = {type: 'string', format: 'date-time'}; + + assert.deepEqual(SchemaMagic.mergeSchemas(schemas), result, 'Invalid schema merge'); + }); + it('should merge equal', function () { const schemas = [ { From 4a0ec6ab30599c6c4b265697b6e29d1f34a388c9 Mon Sep 17 00:00:00 2001 From: Thiren Bunsee Date: Thu, 12 Sep 2024 13:31:43 +0200 Subject: [PATCH 3/5] 1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c796b3a..3b42660 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@synatic/schema-magic", - "version": "1.2.2", + "version": "1.3.0", "description": "JSON Schema Utilities", "main": "index.js", "files": [ From af4573b86dd3e2cb45106244090e51238dfc565e Mon Sep 17 00:00:00 2001 From: Thiren Bunsee Date: Thu, 12 Sep 2024 13:33:38 +0200 Subject: [PATCH 4/5] test: removed unused variable --- test/test.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/test/test.js b/test/test.js index a586501..5b08eb0 100644 --- a/test/test.js +++ b/test/test.js @@ -300,38 +300,6 @@ describe('Schema Magic', function () { required: false, }, ]; - const newOutput = [ - { - path: 'val1', - type: 'integer', - format: undefined, - isArray: false, - required: false, - }, - { - path: 'val2', - type: 'array', - format: undefined, - isArray: true, - required: false, - }, - { - path: 'val2.n.a', - type: 'number', - format: undefined, - isArray: false, - inArray: true, - required: false, - }, - { - path: 'val2.n.b', - type: 'string', - format: 'date-time', - isArray: false, - inArray: true, - required: false, - }, - ]; assert.deepEqual(SchemaMagic.flattenSchema(schema), output, 'Invalid flatten'); }); From a9190a0fb31af342699585bbde4f8861e2789779 Mon Sep 17 00:00:00 2001 From: Thiren Bunsee Date: Thu, 12 Sep 2024 13:35:50 +0200 Subject: [PATCH 5/5] ci: optimised the CI pipeline and updated dependencies --- .github/workflows/ci-build.yml | 16 ++++++---------- .github/workflows/ci-codeql-analysis.yml | 4 ---- .github/workflows/ci-npm-publish.yml | 12 ++++++------ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 9c4a6b4..e11fc98 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -2,10 +2,6 @@ name: "Build" on: push: - branches: [master, develop] - pull_request: - # The branches below must be a subset of the branches above - branches: [master, develop] workflow_dispatch: inputs: reason: @@ -22,10 +18,10 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 registry-url: https://registry.npmjs.org/ # Skip post-install scripts here, as a malicious # script could steal NODE_AUTH_TOKEN. @@ -44,10 +40,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 registry-url: https://registry.npmjs.org/ # Skip post-install scripts here, as a malicious # script could steal NODE_AUTH_TOKEN. diff --git a/.github/workflows/ci-codeql-analysis.yml b/.github/workflows/ci-codeql-analysis.yml index ddec1c8..ce79a57 100644 --- a/.github/workflows/ci-codeql-analysis.yml +++ b/.github/workflows/ci-codeql-analysis.yml @@ -2,10 +2,6 @@ name: "CodeQL Analysis" on: push: - branches: [master, develop] - pull_request: - # The branches below must be a subset of the branches above - branches: [master, develop] workflow_dispatch: inputs: reason: diff --git a/.github/workflows/ci-npm-publish.yml b/.github/workflows/ci-npm-publish.yml index 28533bf..02e92e2 100644 --- a/.github/workflows/ci-npm-publish.yml +++ b/.github/workflows/ci-npm-publish.yml @@ -11,10 +11,10 @@ jobs: timeout-minutes: 5 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 20 registry-url: https://registry.npmjs.org/ # Skip post-install scripts here, as a malicious # script could steal NODE_AUTH_TOKEN. @@ -28,10 +28,10 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 20 registry-url: https://registry.npmjs.org/ # Skip post-install scripts here, as a malicious # script could steal NODE_AUTH_TOKEN.