Skip to content

Commit

Permalink
Merge pull request #87 from synatic/develop
Browse files Browse the repository at this point in the history
1.3.0 - updated json-magic and other npm packages
  • Loading branch information
thiren authored Sep 12, 2024
2 parents 19db909 + a9190a0 commit 15711a5
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 65 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/ci-codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci-npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synatic/schema-magic",
"version": "1.2.2",
"version": "1.3.0",
"description": "JSON Schema Utilities",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -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"
}
}
51 changes: 17 additions & 34 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,39 +300,7 @@ 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,
},
];
console.log(newOutput);

assert.deepEqual(SchemaMagic.flattenSchema(schema), output, 'Invalid flatten');
});
});
Expand Down Expand Up @@ -398,7 +366,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()),
Expand Down Expand Up @@ -646,6 +621,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 = [
{
Expand Down

0 comments on commit 15711a5

Please sign in to comment.