@nosana/schema-validator
Advanced tools
Comparing version 0.1.2 to 0.1.8
import { NosPipelineSchema } from "./schema"; | ||
import { parse } from 'yaml'; | ||
import { parse, stringify } from 'yaml'; | ||
export declare const validateJson: (schema: any) => { | ||
@@ -19,2 +19,2 @@ errors?: import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | null | undefined; | ||
}; | ||
export { NosPipelineSchema, parse as parseYaml }; | ||
export { NosPipelineSchema, parse as parseYaml, stringify as stringifyYaml }; |
import AJV from "ajv"; | ||
import { NosPipelineSchema } from "./schema.js"; | ||
import { parse } from 'yaml'; | ||
import { parse, stringify } from 'yaml'; | ||
const ajv = new AJV({ | ||
@@ -16,3 +16,3 @@ allErrors: true, | ||
export const validateYaml = (yaml) => validateJson(JSON.stringify(parse(yaml))); | ||
export { NosPipelineSchema, parse as parseYaml }; | ||
export { NosPipelineSchema, parse as parseYaml, stringify as stringifyYaml }; | ||
//# sourceMappingURL=index.js.map |
@@ -129,14 +129,4 @@ (function (global, factory) { | ||
items: { | ||
type: "object", | ||
nullable: true, | ||
properties: { | ||
name: { | ||
type: "string", | ||
nullable: false | ||
}, | ||
path: { | ||
type: "string", | ||
nullable: false | ||
} | ||
} | ||
type: "string", | ||
nullable: true | ||
} | ||
@@ -238,2 +228,6 @@ }, | ||
}); | ||
Object.defineProperty(exports, 'stringifyYaml', { | ||
enumerable: true, | ||
get: function () { return yaml.stringify; } | ||
}); | ||
exports.NosPipelineSchema = NosPipelineSchema; | ||
@@ -240,0 +234,0 @@ exports.validateJson = validateJson; |
@@ -1,1 +0,1 @@ | ||
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("ajv"),require("yaml")):"function"==typeof define&&define.amd?define(["exports","ajv","yaml"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).validate_schema={},e.AJV,e.yaml)}(this,(function(e,l,t){"use strict";const n={type:"object",properties:{nosana:{type:"object",nullable:!1,properties:{description:{type:"string",nullable:!1,minLength:3,maxLength:255}}},global:{type:"object",nullable:!1,properties:{image:{type:"string",nullable:!0,minLength:1,maxLength:4096},trigger:{type:"object",nullable:!0,properties:{branch:{type:["array","string"],items:{type:"string"},nullable:!0,uniqueItems:!0}}},environment:{anyOf:[{type:"object",nullable:!0,additionalProperties:{type:"string"}},{type:"object",nullable:!0,properties:{type:{type:"string",nullable:!1},endpoint:{type:"string",nullable:!1},value:{type:"string",nullable:!1}}}]},allow_failure:{type:"boolean",nullable:!0}}},jobs:{type:"array",nullable:!1,items:{type:"object",nullable:!1,properties:{name:{type:"string",nullable:!1},image:{type:"string",nullable:!0,minLength:1,maxLength:4096},environment:{anyOf:[{type:"object",nullable:!0,additionalProperties:{type:"string"}},{type:"object",nullable:!0,properties:{type:{type:"string",nullable:!1},endpoint:{type:"string",nullable:!1},value:{type:"string",nullable:!1}}}]},allow_failure:{type:"boolean",nullable:!0},resources:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}},commands:{type:"array",nullable:!1,items:{anyOf:[{type:"string",nullable:!1},{type:"object",properties:{cmd:{type:"string",nullable:!1},working_dir:{type:"string",nullable:!0},allow_failure:{type:"boolean",nullable:!0},resources:{type:"string",nullable:!0},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}}}}]}}}}}},required:["nosana","global","jobs"],additionalProperties:!1},a=new l({allErrors:!0,verbose:!0,allowUnionTypes:!0}),r=e=>{const l=JSON.parse(e),t=a.compile(n);return{valid:t(l),...t}};Object.defineProperty(e,"parseYaml",{enumerable:!0,get:function(){return t.parse}}),e.NosPipelineSchema=n,e.validateJson=r,e.validateYaml=e=>r(JSON.stringify(t.parse(e)))})); | ||
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?l(exports,require("ajv"),require("yaml")):"function"==typeof define&&define.amd?define(["exports","ajv","yaml"],l):l((e="undefined"!=typeof globalThis?globalThis:e||self).validate_schema={},e.AJV,e.yaml)}(this,(function(e,l,t){"use strict";const n={type:"object",properties:{nosana:{type:"object",nullable:!1,properties:{description:{type:"string",nullable:!1,minLength:3,maxLength:255}}},global:{type:"object",nullable:!1,properties:{image:{type:"string",nullable:!0,minLength:1,maxLength:4096},trigger:{type:"object",nullable:!0,properties:{branch:{type:["array","string"],items:{type:"string"},nullable:!0,uniqueItems:!0}}},environment:{anyOf:[{type:"object",nullable:!0,additionalProperties:{type:"string"}},{type:"object",nullable:!0,properties:{type:{type:"string",nullable:!1},endpoint:{type:"string",nullable:!1},value:{type:"string",nullable:!1}}}]},allow_failure:{type:"boolean",nullable:!0}}},jobs:{type:"array",nullable:!1,items:{type:"object",nullable:!1,properties:{name:{type:"string",nullable:!1},image:{type:"string",nullable:!0,minLength:1,maxLength:4096},environment:{anyOf:[{type:"object",nullable:!0,additionalProperties:{type:"string"}},{type:"object",nullable:!0,properties:{type:{type:"string",nullable:!1},endpoint:{type:"string",nullable:!1},value:{type:"string",nullable:!1}}}]},allow_failure:{type:"boolean",nullable:!0},resources:{type:"array",nullable:!0,items:{type:"string",nullable:!0}},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}},commands:{type:"array",nullable:!1,items:{anyOf:[{type:"string",nullable:!1},{type:"object",properties:{cmd:{type:"string",nullable:!1},working_dir:{type:"string",nullable:!0},allow_failure:{type:"boolean",nullable:!0},resources:{type:"string",nullable:!0},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}}}}]}}}}}},required:["nosana","global","jobs"],additionalProperties:!1},a=new l({allErrors:!0,verbose:!0,allowUnionTypes:!0}),r=e=>{const l=JSON.parse(e),t=a.compile(n);return{valid:t(l),...t}};Object.defineProperty(e,"parseYaml",{enumerable:!0,get:function(){return t.parse}}),Object.defineProperty(e,"stringifyYaml",{enumerable:!0,get:function(){return t.stringify}}),e.NosPipelineSchema=n,e.validateJson=r,e.validateYaml=e=>r(JSON.stringify(t.parse(e)))})); |
@@ -123,14 +123,4 @@ export const NosPipelineSchema = { | ||
items: { | ||
type: "object", | ||
nullable: true, | ||
properties: { | ||
name: { | ||
type: "string", | ||
nullable: false | ||
}, | ||
path: { | ||
type: "string", | ||
nullable: false | ||
} | ||
} | ||
type: "string", | ||
nullable: true | ||
} | ||
@@ -137,0 +127,0 @@ }, |
@@ -24,3 +24,3 @@ { | ||
"description": "To install dependencies:", | ||
"version": "0.1.2", | ||
"version": "0.1.8", | ||
"main": "dist/index.min.mjs", | ||
@@ -27,0 +27,0 @@ "module": "dist/index.min.mjs", |
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
43340
696