@api3/airnode-validator
Advanced tools
Comparing version 0.3.1 to 0.4.0
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var yargs_1 = __importDefault(require("yargs")); | ||
var helpers_1 = require("yargs/helpers"); | ||
var utils = __importStar(require("./utils")); | ||
var convertor_1 = require("../convertor"); | ||
@@ -99,14 +53,3 @@ var args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) | ||
} | ||
var messages = []; | ||
var _b = __read(args.from.toLowerCase().split('@'), 2), from = _b[0], fromVersion = _b[1]; | ||
var _c = __read(args.to.toLowerCase().split('@'), 2), to = _c[0], toVersion = _c[1]; | ||
var templatePath = utils.getConversionPath(from, to, messages, fromVersion, toVersion); | ||
if (templatePath) { | ||
var res = (0, convertor_1.convert)(args.specification, templatePath, args.secrets); | ||
(_a = res.messages).push.apply(_a, __spreadArray([], __read(messages), false)); | ||
console.log(JSON.stringify(args['specs-only'] ? res.output : res, null, 2)); | ||
} | ||
else { | ||
console.log(JSON.stringify(messages, null, 2)); | ||
} | ||
console.log(JSON.stringify((0, convertor_1.convertWithTemplate)(args.specification, args.from, args.to, args.secrets), null, 2)); | ||
//# sourceMappingURL=convertCmd.js.map |
@@ -27,3 +27,4 @@ import { Log } from '../types'; | ||
export declare function parseEnv(envPath: string, messages: Log[]): Record<string, string | undefined> | undefined; | ||
export declare function interpolate(specs: object, env: Record<string, string | undefined>, messages: Log[]): object | undefined; | ||
export declare function interpolate(specs: unknown, env: Record<string, string | undefined>, messages: Log[]): object | undefined; | ||
export declare function readJson(filePath: string, messages: Log[]): object | undefined; | ||
export declare function parseTemplateName(templateName: string, messages: Log[]): [name: string, version?: string] | undefined; |
@@ -52,3 +52,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readJson = exports.interpolate = exports.parseEnv = exports.getConversionPath = exports.getPath = exports.conversions = exports.templateVersions = void 0; | ||
exports.parseTemplateName = exports.readJson = exports.interpolate = exports.parseEnv = exports.getConversionPath = exports.getPath = exports.conversions = exports.templateVersions = void 0; | ||
var fs = __importStar(require("fs")); | ||
@@ -58,2 +58,3 @@ var path = __importStar(require("path")); | ||
var dotenv_1 = __importDefault(require("dotenv")); | ||
var types_1 = require("../types"); | ||
var logger = __importStar(require("../utils/logger")); | ||
@@ -277,2 +278,15 @@ var messages_1 = require("../utils/messages"); | ||
exports.readJson = readJson; | ||
function parseTemplateName(templateName, messages) { | ||
var _a = __read(templateName.split('@'), 2), name = _a[0], version = _a[1]; | ||
if (!types_1.templates[name.toLowerCase()]) { | ||
messages.push(logger.error("".concat(name, " is not a valid template name"))); | ||
return undefined; | ||
} | ||
if (version && !version.match(globals_1.regexList.templateVersion)) { | ||
messages.push(logger.error("".concat(version, " is not a valid version"))); | ||
return undefined; | ||
} | ||
return [types_1.templates[name.toLowerCase()], version]; | ||
} | ||
exports.parseTemplateName = parseTemplateName; | ||
//# sourceMappingURL=utils.js.map |
@@ -21,31 +21,5 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _a, _b; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -55,5 +29,3 @@ var yargs_1 = __importDefault(require("yargs")); | ||
var utils = __importStar(require("./utils")); | ||
var logger = __importStar(require("../utils/logger")); | ||
var validator_1 = require("../validator"); | ||
var types_1 = require("../types"); | ||
var messages = []; | ||
@@ -79,20 +51,10 @@ var args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) | ||
.parseSync(); | ||
var templatePath, version; | ||
// eslint-disable-next-line prefer-const | ||
_a = __read(args.template.split('@'), 2), templatePath = _a[0], version = _a[1]; | ||
if (types_1.templates[templatePath.toLowerCase()]) { | ||
templatePath = utils.getPath(types_1.templates[templatePath.toLowerCase()], messages, version); | ||
} | ||
else if (version) { | ||
messages.push(logger.warn('Version argument will be ignored when validating provided template file')); | ||
} | ||
var res; | ||
if (templatePath) { | ||
res = (0, validator_1.validate)(args.specification, templatePath, args.secrets); | ||
(_b = res.messages).push.apply(_b, __spreadArray([], __read(messages), false)); | ||
if (utils.parseTemplateName(args.template, messages)) { | ||
res = (0, validator_1.validateWithTemplate)(args.specification, args.template, args.secrets); | ||
} | ||
else { | ||
res = messages; | ||
res = (0, validator_1.validate)(args.specification, args.template, args.secrets); | ||
} | ||
console.log(JSON.stringify(res, null, 2)); | ||
//# sourceMappingURL=validateCmd.js.map |
import { Result } from './types'; | ||
/** | ||
* Converts a specification according to the template | ||
* @param specsPath - specification file to convert, root must be an object (not an array) | ||
* @param specsPath - specification file to convert | ||
* @param templatePath - template json file | ||
@@ -11,4 +11,12 @@ * @param interpolatePath - path to env file that will be interpolated with specification file | ||
/** | ||
* Converts a specification from provided format to specified format | ||
* @param specsPath specification file to convert | ||
* @param fromTemplateName format name of specification file | ||
* @param toTemplateName name of format to which the specification will be converted to | ||
* @param interpolatePath path to env file that will be interpolated with specification file | ||
*/ | ||
export declare function convertWithTemplate(specsPath: string | undefined, fromTemplateName: string | undefined, toTemplateName: string | undefined, interpolatePath?: string): Result; | ||
/** | ||
* Converts specification from provided string and converts it into format the template specifies | ||
* @param specs - specification to convert, root must be an object (not an array) | ||
* @param specs - specification to convert | ||
* @param template - template json | ||
@@ -19,2 +27,2 @@ * @param interpolate - list of env variables that will be interpolated with specification | ||
*/ | ||
export declare function convertJson(specs: object, template: object, interpolate?: Record<string, string | undefined>, templatePath?: string): Result; | ||
export declare function convertJson(specs: object, template: object, templatePath?: string, interpolate?: Record<string, string | undefined>): Result; |
@@ -21,4 +21,24 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertJson = exports.convert = void 0; | ||
exports.convertJson = exports.convertWithTemplate = exports.convert = void 0; | ||
var path_1 = __importDefault(require("path")); | ||
var logger = __importStar(require("./utils/logger")); | ||
@@ -29,3 +49,3 @@ var processor_1 = require("./processor"); | ||
* Converts a specification according to the template | ||
* @param specsPath - specification file to convert, root must be an object (not an array) | ||
* @param specsPath - specification file to convert | ||
* @param templatePath - template json file | ||
@@ -53,9 +73,35 @@ * @param interpolatePath - path to env file that will be interpolated with specification file | ||
} | ||
var split = templatePath.split('/'); | ||
return convertJson(specs, template, env, split.slice(0, split.length - 1).join('/') + '/'); | ||
var split = templatePath.split(path_1.default.sep); | ||
return convertJson(specs, template, split.slice(0, split.length - 1).join(path_1.default.sep) + path_1.default.sep, env); | ||
} | ||
exports.convert = convert; | ||
/** | ||
* Converts a specification from provided format to specified format | ||
* @param specsPath specification file to convert | ||
* @param fromTemplateName format name of specification file | ||
* @param toTemplateName name of format to which the specification will be converted to | ||
* @param interpolatePath path to env file that will be interpolated with specification file | ||
*/ | ||
function convertWithTemplate(specsPath, fromTemplateName, toTemplateName, interpolatePath) { | ||
var _a, _b; | ||
if (!fromTemplateName) { | ||
return { valid: false, messages: [logger.error('Valid from template name must be provided')] }; | ||
} | ||
if (!toTemplateName) { | ||
return { valid: false, messages: [logger.error('Valid from template name must be provided')] }; | ||
} | ||
var messages = []; | ||
var fromVersion, toVersion; | ||
_a = __read(fromTemplateName.split('@'), 2), fromTemplateName = _a[0], fromVersion = _a[1]; | ||
_b = __read(toTemplateName.split('@'), 2), toTemplateName = _b[0], toVersion = _b[1]; | ||
var templatePath = utils.getConversionPath(fromTemplateName, toTemplateName, messages, fromVersion, toVersion); | ||
if (!templatePath) { | ||
return { valid: false, messages: messages }; | ||
} | ||
return convert(specsPath, templatePath, interpolatePath); | ||
} | ||
exports.convertWithTemplate = convertWithTemplate; | ||
/** | ||
* Converts specification from provided string and converts it into format the template specifies | ||
* @param specs - specification to convert, root must be an object (not an array) | ||
* @param specs - specification to convert | ||
* @param template - template json | ||
@@ -66,3 +112,3 @@ * @param interpolate - list of env variables that will be interpolated with specification | ||
*/ | ||
function convertJson(specs, template, interpolate, templatePath) { | ||
function convertJson(specs, template, templatePath, interpolate) { | ||
if (templatePath === void 0) { templatePath = ''; } | ||
@@ -69,0 +115,0 @@ var nonRedundant = {}, output = {}, messages = []; |
@@ -10,2 +10,3 @@ export declare const regexList: { | ||
regexTokens: RegExp; | ||
templateVersion: RegExp; | ||
}; | ||
@@ -12,0 +13,0 @@ export declare const keywords: { |
@@ -12,3 +12,4 @@ "use strict"; | ||
patchVersion: /(?<=([0-9]+\.[0-9]+))\.[0-9]+$/g, | ||
regexTokens: /[\.\\\[\]\(\)]/g, // characters used in regular expressions and should be escaped before creating regex | ||
regexTokens: /[\.\\\[\]\(\)]/g, | ||
templateVersion: /^[0-9]+\.[0-9]+(\.[0-9]+)?$/, // format of validator template versions | ||
}; | ||
@@ -15,0 +16,0 @@ exports.keywords = { |
@@ -28,3 +28,3 @@ import { Log, Roots } from '../types'; | ||
*/ | ||
export declare function recursiveSubstitute(specs: any, substitute: (value: string) => string, ignoredKeys?: string[]): any; | ||
export declare function recursiveSubstitute(specs: any, substitute: (value: string, key?: string) => string, ignoredKeys?: string[]): any; | ||
/** | ||
@@ -31,0 +31,0 @@ * Checks if any extra fields are present |
@@ -79,9 +79,10 @@ "use strict"; | ||
function replaceConditionalMatch(match, template) { | ||
if (typeof match === 'string') { | ||
match = match.replace(globals_1.regexList.regexTokens, '\\$&'); | ||
} | ||
else { | ||
if (typeof match !== 'string') { | ||
match = match.toString(); | ||
} | ||
var substitute = function (toReplace) { | ||
var escapedMatch = match.replace(globals_1.regexList.regexTokens, '\\$&'); | ||
var substitute = function (toReplace, key) { | ||
if (key === globals_1.keywords.regexp || key === globals_1.keywords.keyRegexp) { | ||
return toReplace.replace(new RegExp(globals_1.keywords.match, 'g'), escapedMatch); | ||
} | ||
return toReplace.replace(new RegExp(globals_1.keywords.match, 'g'), match); | ||
@@ -99,3 +100,3 @@ }; | ||
function replacePathsWithValues(specs, rootSpecs, template) { | ||
var substitute = function (toReplace) { | ||
var substitute = function (toReplace, key) { | ||
var e_1, _a; | ||
@@ -123,2 +124,5 @@ var matches = toReplace.match(globals_1.regexList.parameterValuePath); | ||
if (value) { | ||
if (key === globals_1.keywords.regexp || key === globals_1.keywords.keyRegexp) { | ||
value = value.replace(globals_1.regexList.regexTokens, '\\$&'); | ||
} | ||
toReplace = toReplace.replace("[".concat(pathStr, "]"), value); | ||
@@ -146,3 +150,3 @@ } | ||
function replaceParamIndexWithName(specs, paramPath) { | ||
var substitute = function (toReplace) { | ||
var substitute = function (toReplace, key) { | ||
var e_2, _a; | ||
@@ -153,3 +157,9 @@ try { | ||
var index = parseInt(match.match('[0-9]+')[0]); | ||
toReplace = toReplace.replace(new RegExp("\\{\\{".concat(index, "\\}\\}"), 'g'), paramPath[index]); | ||
if (!paramPath[index]) { | ||
continue; | ||
} | ||
var value = key === globals_1.keywords.regexp || key === globals_1.keywords.keyRegexp | ||
? paramPath[index].replace(globals_1.regexList.regexTokens, '\\$&') | ||
: paramPath[index]; | ||
toReplace = toReplace.replace(new RegExp("\\{\\{".concat(index, "\\}\\}"), 'g'), value); | ||
} | ||
@@ -190,3 +200,3 @@ } | ||
if (typeof specs[key] === 'string') { | ||
return __assign(__assign({}, acc), (_a = {}, _a[newKey] = substitute(specs[key]), _a)); | ||
return __assign(__assign({}, acc), (_a = {}, _a[newKey] = substitute(specs[key], key), _a)); | ||
} | ||
@@ -193,0 +203,0 @@ var newValue = recursiveSubstitute(specs[key], substitute, ignoredKeys); |
@@ -8,4 +8,5 @@ import { Result } from './types'; | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - if the validator should run the validation | ||
*/ | ||
export declare function validateJsonWithTemplate(specs: object, templateName: string | undefined, interpolate?: Record<string, string | undefined>, returnJson?: boolean): Result; | ||
export declare function validateJsonWithTemplate(specs: object, templateName: string | undefined, shouldValidate: boolean, interpolate?: Record<string, string | undefined>, returnJson?: boolean): Result; | ||
/** | ||
@@ -25,5 +26,6 @@ * Validates specification on provided path with known template | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - should the config be validated | ||
* @returns array of error and warning messages | ||
*/ | ||
export declare function validate(specsPath: string | undefined, templatePath: string | undefined, interpolatePath?: string, returnJson?: boolean): Result; | ||
export declare function validate(specsPath: string | undefined, templatePath: string | undefined, interpolatePath?: string, returnJson?: boolean, shouldValidate?: boolean): Result; | ||
/** | ||
@@ -36,4 +38,5 @@ * Validates specification from provided string according to string containing template structure | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - should the config be validated | ||
* @returns array of error and warning messages | ||
*/ | ||
export declare function validateJson(specs: object, template: object, templatePath?: string, interpolate?: Record<string, string | undefined>, returnJson?: boolean): Result; | ||
export declare function validateJson(specs: object, template: object, templatePath?: string, interpolate?: Record<string, string | undefined>, returnJson?: boolean, shouldValidate?: boolean): Result; |
@@ -21,2 +21,18 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -29,3 +45,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var logger = __importStar(require("./utils/logger")); | ||
var types_1 = require("./types"); | ||
var processor_1 = require("./processor"); | ||
@@ -40,4 +55,6 @@ var utils = __importStar(require("./commands/utils")); | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - if the validator should run the validation | ||
*/ | ||
function validateJsonWithTemplate(specs, templateName, interpolate, returnJson) { | ||
function validateJsonWithTemplate(specs, templateName, shouldValidate, interpolate, returnJson) { | ||
var _a; | ||
if (returnJson === void 0) { returnJson = false; } | ||
@@ -47,4 +64,9 @@ if (!templateName) { | ||
} | ||
var messages = []; | ||
var templatePath = utils.getPath(types_1.templates[templateName.toLowerCase()], messages); | ||
var messages = [], parsed = utils.parseTemplateName(templateName, messages); | ||
var version; | ||
if (!parsed) { | ||
return { valid: false, messages: messages }; | ||
} | ||
_a = __read(parsed, 2), templateName = _a[0], version = _a[1]; | ||
var templatePath = utils.getPath(templateName, messages, version); | ||
if (messages.length || !templatePath) { | ||
@@ -57,4 +79,4 @@ return { valid: false, messages: messages }; | ||
} | ||
var split = templatePath.split('/'); | ||
return validateJson(specs, template, split.slice(0, split.length - 1).join('/') + '/', interpolate, returnJson); | ||
var split = templatePath.split(path_1.default.sep); | ||
return validateJson(specs, template, split.slice(0, split.length - 1).join(path_1.default.sep) + path_1.default.sep, interpolate, returnJson, shouldValidate); | ||
} | ||
@@ -84,3 +106,3 @@ exports.validateJsonWithTemplate = validateJsonWithTemplate; | ||
} | ||
return validateJsonWithTemplate(specs, templateName, env, returnJson); | ||
return validateJsonWithTemplate(specs, templateName, true, env, returnJson); | ||
} | ||
@@ -94,6 +116,8 @@ exports.validateWithTemplate = validateWithTemplate; | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - should the config be validated | ||
* @returns array of error and warning messages | ||
*/ | ||
function validate(specsPath, templatePath, interpolatePath, returnJson) { | ||
function validate(specsPath, templatePath, interpolatePath, returnJson, shouldValidate) { | ||
if (returnJson === void 0) { returnJson = false; } | ||
if (shouldValidate === void 0) { shouldValidate = true; } | ||
if (!specsPath || !templatePath) { | ||
@@ -115,4 +139,4 @@ return { valid: false, messages: [logger.error('Specification and template file must be provided')] }; | ||
} | ||
var split = templatePath.split('/'); | ||
return validateJson(specs, template, split.slice(0, split.length - 1).join('/') + '/', env, returnJson); | ||
var split = templatePath.split(path_1.default.sep); | ||
return validateJson(specs, template, split.slice(0, split.length - 1).join(path_1.default.sep) + path_1.default.sep, env, returnJson, shouldValidate); | ||
} | ||
@@ -127,7 +151,9 @@ exports.validate = validate; | ||
* @param returnJson - parsed JSON specification will be returned | ||
* @param shouldValidate - should the config be validated | ||
* @returns array of error and warning messages | ||
*/ | ||
function validateJson(specs, template, templatePath, interpolate, returnJson) { | ||
function validateJson(specs, template, templatePath, interpolate, returnJson, shouldValidate) { | ||
if (templatePath === void 0) { templatePath = ''; } | ||
if (returnJson === void 0) { returnJson = false; } | ||
if (shouldValidate === void 0) { shouldValidate = true; } | ||
var messages = []; | ||
@@ -141,2 +167,9 @@ var interpolated = specs; | ||
var nonRedundant = template[globals_1.keywords.arrayItem] ? [] : {}; | ||
if (!shouldValidate) { | ||
return { | ||
valid: true, | ||
messages: [], | ||
specs: returnJson ? interpolated : undefined, | ||
}; | ||
} | ||
var result = (0, processor_1.processSpecs)(interpolated, template, [], nonRedundant, { | ||
@@ -143,0 +176,0 @@ specs: interpolated, |
@@ -52,2 +52,3 @@ "use strict"; | ||
var fs_1 = __importDefault(require("fs")); | ||
var path_1 = __importDefault(require("path")); | ||
var logger = __importStar(require("../utils/logger")); | ||
@@ -75,5 +76,5 @@ var processor_1 = require("../processor"); | ||
var roots = { specs: specs, nonRedundantParams: globals_1.keywords.arrayItem in template ? [] : {}, output: {} }; | ||
var split = nestedTemplatePath.split('/'); | ||
nestedTemplatePath = split.slice(0, split.length - 1).join('/'); | ||
var result = (0, processor_1.processSpecs)(specs, template, [], roots.nonRedundantParams, roots, "".concat(templatePath).concat(nestedTemplatePath).concat(nestedTemplatePath ? '/' : ''), __spreadArray(__spreadArray([], __read(paramPathPrefix), false), __read(paramPath), false)); | ||
var split = nestedTemplatePath.split(path_1.default.sep); | ||
nestedTemplatePath = split.slice(0, split.length - 1).join(path_1.default.sep); | ||
var result = (0, processor_1.processSpecs)(specs, template, [], roots.nonRedundantParams, roots, "".concat(templatePath).concat(nestedTemplatePath).concat(nestedTemplatePath ? path_1.default.sep : ''), __spreadArray(__spreadArray([], __read(paramPathPrefix), false), __read(paramPath), false)); | ||
return result.messages; | ||
@@ -80,0 +81,0 @@ } |
{ | ||
"ois": { | ||
"__arrayItem": { | ||
"__template": "ois.json", | ||
"__template": "../1.0/ois.json", | ||
"apiSpecifications": { | ||
@@ -87,4 +87,3 @@ "components": { | ||
"__catch": { | ||
"__level": "warning", | ||
"__message": "__fullPath: nodeVersion should be set to 0.2.*" | ||
"__level": "warning" | ||
} | ||
@@ -102,3 +101,3 @@ }, | ||
"stage": { | ||
"__regexp": "^[a-zA-Z0-9-_]{1,16}$", | ||
"__regexp": "^[a-z0-9-_]{1,16}$", | ||
"__catch": { | ||
@@ -105,0 +104,0 @@ "__message": "__fullPath can contain only alphanumeric characters, '-' or '_' and cannot be longer than 16 characters" |
{ | ||
"ois": { | ||
"__arrayItem": { | ||
"__template": "ois.json", | ||
"__template": "../1.0/ois.json", | ||
"apiSpecifications": { | ||
@@ -176,3 +176,3 @@ "components": { | ||
"stage": { | ||
"__regexp": "^[a-zA-Z0-9-_]{1,16}$", | ||
"__regexp": "^[a-z0-9-_]{1,16}$", | ||
"__catch": { | ||
@@ -179,0 +179,0 @@ "__message": "__fullPath can contain only alphanumeric characters, '-' or '_' and cannot be longer than 16 characters" |
{ | ||
"ois": { | ||
"__arrayItem": { | ||
"__template": "ois.json" | ||
"__template": "../1.0/ois.json" | ||
} | ||
@@ -6,0 +6,0 @@ }, |
{ | ||
"name": "@api3/airnode-validator", | ||
"license": "MIT", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "./dist/src/index.js", |
@@ -10,9 +10,27 @@ # `@api3/airnode-validator` | ||
General usage of validator and convertor is described in the | ||
[API3 Documentation](https://docs.api3.org/airnode/latest/reference/packages/validator.html). For debugging purposes it | ||
might be useful to run the validator with path to template file instead of providing the format name: | ||
[API3 Documentation](https://docs.api3.org/airnode/latest/reference/packages/validator.html). | ||
## Build Manually | ||
You can clone and build the Airnode monorepo then run the validator as a yarn script from inside the | ||
`packages/airnode-validator` directory. | ||
```sh | ||
# execute the validator | ||
yarn run cli:validator --template="config" --specs="exampleSpecs/config.json" | ||
# validator output | ||
{ | ||
"valid": true, | ||
"messages": [] | ||
} | ||
``` | ||
For debugging purposes it might be useful to run the validator with path to template file instead of providing the | ||
format name: | ||
```sh | ||
yarn run cli:validator --template="templates/0.2/config.json" --specs="myProject/config/config.json" | ||
# OR | ||
yarn run cli:convertor --template="conversions/oas@3.0------ois@0.2.json" --specs="myProject/config/oas.json" | ||
yarn run cli:convertor --template="conversions/oas@3.0------ois@1.0.json" --specs="myProject/config/oas.json" | ||
``` | ||
@@ -36,3 +54,3 @@ | ||
## Documentation | ||
## Other Documentation | ||
@@ -39,0 +57,0 @@ Source documentation markdown files are located in `docs/src/` directory. All template related examples are located in |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59
242490
85
4879