-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/better-json-schemas-developer-experience' into dev…
…elop
- Loading branch information
Showing
96 changed files
with
398 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ skills/**/memory/*.json | |
core/data/models/*.nlp | ||
package.json.backup | ||
.python-version | ||
schemas/**/*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../schemas/voice-config-schemas/watson-stt.json", | ||
"apikey": "", | ||
"url": "https://stream.watsonplatform.net/speech-to-text/api" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../schemas/voice-config-schemas/watson-tts.json", | ||
"apikey": "", | ||
"url": "https://stream.watsonplatform.net/text-to-speech/api" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../schemas/global-data/global-answers.json", | ||
"answers": { | ||
"success": {}, | ||
"errors": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../../schemas/global-data/global-entity.json", | ||
"options": { | ||
"red": { | ||
"synonyms": ["red"], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../../schemas/global-data/global-entity.json", | ||
"options": { | ||
"LOW": { | ||
"synonyms": ["low"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"$schema": "../../../schemas/global-data/global-answers.json", | ||
"answers": { | ||
"success": {}, | ||
"errors": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
|
||
import { LogHelper } from '@/helpers/log-helper' | ||
import { | ||
domainSchemaObject, | ||
skillSchemaObject, | ||
skillConfigSchemaObject | ||
} from '@/schemas/skill-schemas' | ||
import { | ||
globalEntitySchemaObject, | ||
globalResolverSchemaObject, | ||
globalAnswersSchemaObject | ||
} from '@/schemas/global-data-schemas' | ||
import { | ||
amazonVoiceConfiguration, | ||
googleCloudVoiceConfiguration, | ||
watsonVoiceConfiguration | ||
} from '@/schemas/voice-config-schemas' | ||
|
||
/** | ||
* Generate JSON schemas | ||
* @param {string} categoryName | ||
* @param {Map<string, Object>} schemas | ||
*/ | ||
export const generateSchemas = async (categoryName, schemas) => { | ||
const categorySchemasPath = path.join(process.cwd(), 'schemas', categoryName) | ||
await fs.promises.mkdir(categorySchemasPath, { recursive: true }) | ||
for (const [schemaName, schemaObject] of schemas.entries()) { | ||
const schemaPath = path.join(categorySchemasPath, `${schemaName}.json`) | ||
await fs.promises.writeFile( | ||
schemaPath, | ||
JSON.stringify( | ||
{ | ||
$schema: 'https://json-schema.org/draft-07/schema', | ||
...schemaObject | ||
}, | ||
null, | ||
2 | ||
) | ||
) | ||
} | ||
} | ||
|
||
export default async () => { | ||
LogHelper.info('Generating the JSON schemas...') | ||
await Promise.all([ | ||
generateSchemas( | ||
'global-data', | ||
new Map([ | ||
['global-entity', globalEntitySchemaObject], | ||
['global-resolver', globalResolverSchemaObject], | ||
['global-answers', globalAnswersSchemaObject] | ||
]) | ||
), | ||
generateSchemas( | ||
'skill-schemas', | ||
new Map([ | ||
['domain', domainSchemaObject], | ||
['skill', skillSchemaObject], | ||
['skill-config', skillConfigSchemaObject] | ||
]) | ||
), | ||
generateSchemas( | ||
'voice-config-schemas', | ||
new Map([ | ||
['amazon', amazonVoiceConfiguration], | ||
[ | ||
'google-cloud', | ||
googleCloudVoiceConfiguration | ||
], | ||
['watson-stt', watsonVoiceConfiguration], | ||
['watson-tts', watsonVoiceConfiguration] | ||
]) | ||
) | ||
]) | ||
LogHelper.success('JSON schemas generated') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { LogHelper } from '@/helpers/log-helper' | ||
|
||
import generateJsonSchemas from './generate-json-schemas' | ||
|
||
/** | ||
* Execute the generating JSON schemas script | ||
*/ | ||
;(async () => { | ||
try { | ||
await generateJsonSchemas() | ||
} catch (error) { | ||
LogHelper.error(`Failed to generate the json schemas: ${error}`) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.