Skip to content

Commit

Permalink
Update schema to draft7. definitions to defs (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Silvia Chen <[email protected]>
  • Loading branch information
silviac98 and Silvia Chen authored Jan 30, 2025
1 parent 688efe7 commit a063109
Show file tree
Hide file tree
Showing 14 changed files with 481 additions and 477 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"watch": "tsc -b -w",
"test-watch": " NODE_OPTIONS=--experimental-vm-modules jest --watch",
"test": "jest --collectCoverage",
"bundle-schema": "node ./scripts/transform.js"
"bundle-schema": "node ./scripts/transform.js && prettier src/json-schema/bundled.json --write"
},
"devDependencies": {
"@apidevtools/json-schema-ref-parser": "^11.7.3",
Expand Down
32 changes: 15 additions & 17 deletions scripts/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
* SPDX-License-Identifier: MIT
*/

const $RefParser = require('@apidevtools/json-schema-ref-parser');
const path = require('path');
const fs = require('fs');
const util = require('util');
const $RefParser = require('@apidevtools/json-schema-ref-parser')
const path = require('path')
const fs = require('fs')
const util = require('util')

const writeFile = util.promisify(fs.writeFile);
const writeFile = util.promisify(fs.writeFile)

const SCHEMA_PATH = '../src/json-schema/';
const BUNDLED_FILE_NAME = 'bundled.json';
const SCHEMA_PATH = '../src/json-schema/'
const BUNDLED_FILE_NAME = 'bundled.json'

async function parseSchema() {
try {
const bundled = await $RefParser.bundle(path.resolve(__dirname, SCHEMA_PATH, 'partial/base.json'))
const bundledJSON = JSON.stringify(bundled, null, 2)

try {
const bundled = await $RefParser.bundle(path.resolve(__dirname, SCHEMA_PATH, 'partial/base.json'));
const bundledJSON = JSON.stringify(bundled, null, '\t');

writeFile(path.resolve(__dirname, SCHEMA_PATH, BUNDLED_FILE_NAME), bundledJSON);
}
catch (err) {
console.log(err);
}
writeFile(path.resolve(__dirname, SCHEMA_PATH, BUNDLED_FILE_NAME), bundledJSON)
} catch (err) {
console.log(err)
}
}

parseSchema();
parseSchema()
8 changes: 6 additions & 2 deletions src/json-schema/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@
"arn:aws:states:::sqs:sendMessage.waitForTaskToken",
"arn:aws:states:::states:startExecution",
"arn:aws:states:::states:startExecution.sync",
"arn:aws:states:::states:startExecution.waitForTaskToken"
"arn:aws:states:::states:startExecution.waitForTaskToken",
"arn:aws:states:::http:invoke"
]
},
"Parameters": {
Expand Down Expand Up @@ -2054,6 +2055,7 @@
"properties": {
"ReaderConfig": {
"type": "object",
"$id": "mapState/ReaderConfig",
"description": "A JSON object that specifies where to read the items instead of from the effective input.",
"properties": {
"InputType": {
Expand Down Expand Up @@ -2193,6 +2195,7 @@
},
"ResultWriter": {
"type": "object",
"$id": "mapState/ResultWriter",
"description": "A JSON object that specifies where to write the results instead of to the Map state's result.",
"properties": {
"Resource": {
Expand Down Expand Up @@ -2363,5 +2366,6 @@
"enum": ["JSONata", "JSONPath"]
}
},
"required": ["States", "StartAt"]
"required": ["States", "StartAt"],
"$defs": {}
}
11 changes: 6 additions & 5 deletions src/json-schema/partial/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"enum": ["1.0"]
},
"Comment": {
"$ref": "common.json#/definitions/comment"
"$ref": "common.json#/$defs/comment"
},
"TimeoutSeconds": {
"$ref": "common.json#/definitions/seconds",
"$ref": "common.json#/$defs/seconds",
"description": "The maximum number of seconds an execution of the state machine can run. If it runs longer than the specified time, the execution fails with a States.Timeout error."
},
"StartAt": {
Expand All @@ -19,11 +19,12 @@
"minLength": 1
},
"States": {
"$ref": "states.json#/definitions/states"
"$ref": "states.json#/$defs/states"
},
"QueryLanguage": {
"$ref": "common.json#/definitions/queryLanguage"
"$ref": "common.json#/$defs/queryLanguage"
}
},
"required": ["States", "StartAt"]
"required": ["States", "StartAt"],
"$defs": {}
}
Loading

0 comments on commit a063109

Please sign in to comment.