UNPKG

@nosana/schema-validator

Version:
1 lines 2.69 kB
!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:{global:{type:"object",nullable:!1,properties:{trigger:{type:"object",nullable:!0,properties:{branch:{type:["array","string"],items:{type:"string"},nullable:!0,uniqueItems:!0}}},secrets:{type:"array",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},secrets:{type:"array",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},resources:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!0}}}},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!0}}}},commands:{type:"array",nullable:!1,additionalItems:!1,items:{anyOf:[{type:"string",nullable:!1},{type:"object",nullable:!1,properties:{cmd:{type:"string",nullable:!1},working_dir:{type:"string",nullable:!0},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:!0}}}},artifacts:{type:"array",nullable:!0,items:{type:"object",nullable:!0,properties:{name:{type:"string",nullable:!1},path:{type:"string",nullable:!1}}}}}}]}}}}}},required:["global","jobs"],additionalProperties:!1},a=new l({allErrors:!0,verbose:!0,allowUnionTypes:!0,strict:!1}),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)))}));