mirror of
https://github.com/jambonz/verb-specifications.git
synced 2026-03-26 13:59:02 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32f63759db | ||
|
|
825130348b | ||
|
|
f99b94a405 | ||
|
|
6c40dda566 | ||
|
|
899f55a272 | ||
|
|
22a6b30aa3 | ||
|
|
430a702752 | ||
|
|
8dbbe13c5f |
4
index.js
4
index.js
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
...require('./jambonz-app-json-validation'),
|
||||
specs: require('./specs')
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const assert = require('assert');
|
||||
const debug = require('debug')('jambonz:app-json-validation');
|
||||
const _specData = require('./specs');
|
||||
const specs = new Map();
|
||||
for (const key in _specData) { specs.set(key, _specData[key]); }
|
||||
@@ -30,7 +31,7 @@ function normalizeJambones(logger, obj) {
|
||||
throw new Error('malformed jambonz payload: missing verb property');
|
||||
}
|
||||
}
|
||||
logger.debug({ document }, `normalizeJambones: returning document with ${document.length} tasks`);
|
||||
debug({ document }, `normalizeJambones: returning document with ${document.length} tasks`);
|
||||
return document;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ function validate(logger, obj) {
|
||||
}
|
||||
|
||||
function validateVerb(name, data, logger) {
|
||||
logger.debug(`validating ${name} with data ${JSON.stringify(data)}`);
|
||||
debug(`validating ${name} with data ${JSON.stringify(data)}`);
|
||||
// validate the instruction is supported
|
||||
if (!specs.has(name)) throw new Error(`invalid instruction: ${name}`);
|
||||
|
||||
@@ -55,7 +56,7 @@ function validateVerb(name, data, logger) {
|
||||
if (dKey in specData.properties) {
|
||||
const dVal = data[dKey];
|
||||
const dSpec = specData.properties[dKey];
|
||||
logger.debug(`Task:validate validating property ${dKey} with value ${JSON.stringify(dVal)}`);
|
||||
debug(`Task:validate validating property ${dKey} with value ${JSON.stringify(dVal)}`);
|
||||
|
||||
if (typeof dSpec === 'string' && dSpec === 'array') {
|
||||
if (!Array.isArray(dVal)) throw new Error(`${name}: property ${dKey} is not an array`);
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -1,14 +1,15 @@
|
||||
{
|
||||
"name": "verb-specifications",
|
||||
"version": "0.0.2",
|
||||
"name": "@jambonz/verb-specifications",
|
||||
"version": "0.0.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "verb-specifications",
|
||||
"version": "0.0.2",
|
||||
"name": "@jambonz/verb-specifications",
|
||||
"version": "0.0.7",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
"pino": "^8.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -435,7 +436,6 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
@@ -1671,8 +1671,7 @@
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/natural-compare": {
|
||||
"version": "1.4.0",
|
||||
@@ -2771,7 +2770,6 @@
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
@@ -3671,8 +3669,7 @@
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"natural-compare": {
|
||||
"version": "1.4.0",
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"name": "verb-specifications",
|
||||
"version": "0.0.2",
|
||||
"name": "@jambonz/verb-specifications",
|
||||
"version": "0.0.8",
|
||||
"description": "Jambonz Verb Specification Utilities",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node test/",
|
||||
"jslint": "eslint index.js"
|
||||
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,6 +23,7 @@
|
||||
"tape": "^5.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
"pino": "^8.8.0"
|
||||
}
|
||||
}
|
||||
|
||||
65
specs.json
65
specs.json
@@ -465,10 +465,7 @@
|
||||
},
|
||||
"synthesizer": {
|
||||
"properties": {
|
||||
"vendor": {
|
||||
"type": "string",
|
||||
"enum": ["google", "aws", "polly", "microsoft", "nuance", "ibm", "default"]
|
||||
},
|
||||
"vendor": "string",
|
||||
"language": "string",
|
||||
"voice": "string",
|
||||
"engine": {
|
||||
@@ -487,10 +484,8 @@
|
||||
"recognizer": {
|
||||
"properties": {
|
||||
"vendor": {
|
||||
"type": "string",
|
||||
"enum": ["google", "aws", "microsoft", "nuance", "deepgram", "ibm", "default"]
|
||||
},
|
||||
"language": "string",
|
||||
"vendor": "string",
|
||||
"language": "string",
|
||||
"vad": "#vad",
|
||||
"hints": "array",
|
||||
"hintsBoost": "number",
|
||||
@@ -555,12 +550,37 @@
|
||||
"asrTimeout": "number",
|
||||
"nuanceOptions": "#nuanceOptions",
|
||||
"deepgramOptions": "#deepgramOptions",
|
||||
"ibmOptions": "#ibmOptions"
|
||||
"ibmOptions": "#ibmOptions",
|
||||
"nvidiaOptions": "#nvidiaOptions",
|
||||
"sonioxOptions": "#sonioxOptions",
|
||||
"customOptions": "#customOptions"
|
||||
},
|
||||
"required": [
|
||||
"vendor"
|
||||
]
|
||||
},
|
||||
"customOptions": {
|
||||
"properties": {
|
||||
"authToken": "string",
|
||||
"uri": "string",
|
||||
"options": "object"
|
||||
},
|
||||
"required": [
|
||||
]
|
||||
},
|
||||
"nvidiaOptions": {
|
||||
"properties": {
|
||||
"rivaUri": "string",
|
||||
"maxAlternatives": "number",
|
||||
"profanityFilter": "boolean",
|
||||
"punctuation": "boolean",
|
||||
"wordTimeOffsets": "boolean",
|
||||
"verbatimTranscripts": "boolean",
|
||||
"customConfiguration": "object"
|
||||
},
|
||||
"required": [
|
||||
]
|
||||
},
|
||||
"ibmOptions": {
|
||||
"properties": {
|
||||
"sttApiKey": "string",
|
||||
@@ -628,6 +648,31 @@
|
||||
"tag": "string"
|
||||
}
|
||||
},
|
||||
"sonioxOptions": {
|
||||
"properties": {
|
||||
"apiKey": "string",
|
||||
"model": "string",
|
||||
"endpointDetection": "boolean",
|
||||
"profanityFilter": "boolean",
|
||||
"speechContext": "string",
|
||||
"clientRequestReference": "string",
|
||||
"storage": "#sonioxStorage"
|
||||
},
|
||||
"required": [
|
||||
]
|
||||
},
|
||||
"sonioxStorage": {
|
||||
"properties": {
|
||||
"id": "string",
|
||||
"title": "string",
|
||||
"disableStoreAudio": "boolean",
|
||||
"disableStoreTranscript": "boolean",
|
||||
"disableSearch": "boolean",
|
||||
"metadata": "object"
|
||||
},
|
||||
"required": [
|
||||
]
|
||||
},
|
||||
"nuanceOptions": {
|
||||
"properties": {
|
||||
"clientId": "string",
|
||||
@@ -774,4 +819,4 @@
|
||||
"greetingCompletionTimeoutMs": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('tape');
|
||||
const logger = require('pino')({level: process.env.JAMBONES_LOGLEVEL || 'error'});
|
||||
const { validate } = require('../jambonz-app-json-validation');
|
||||
const { validate } = require('..');
|
||||
|
||||
test("validate correct verbs", async (t) => {
|
||||
|
||||
@@ -231,7 +231,7 @@ test("validate correct verbs", async (t) => {
|
||||
"verb": "transcribe",
|
||||
"transcriptionHook": "http://example.com/transcribe",
|
||||
"recognizer": {
|
||||
"vendor": "google",
|
||||
"vendor": "nvidia",
|
||||
"language" : "en-US",
|
||||
"interim": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user