somod-schema
Version:
Schema to validate yaml files in somod modules
124 lines (123 loc) • 5.28 kB
JavaScript
import { somodAjvCompile, somodAnd, somodEquals, somodFunctions, somodIf, somodJsonParse, somodJsonStringify, somodKey, somodOr, somodParameter } from "../common/keywords";
import { arrayLike, booleanLike, numberLike, samAnd, samBase64, samBoolean, samCidr, samEquals, samFindInMap, samGetAZs, samIf, samJoin, samNot, samNumber, samOr, samRef, samSelect, samSplit, samString, samSub, stringLike } from "./components/expression";
import { somodAccess, somodCreateIf, somodDependsOn, somodExtend, somodModuleName, somodModuleNamePattern, somodOutput, somodRef, somodResourceLogicalIdPattern, somodResourceName } from "./components/keywords";
import { allResource } from "./resources/all";
import { customResource } from "./resources/custom";
import { functionEventSource, functionResource, functionTypes, functionApiEvent, functionHttpApiEvent, functionEvent } from "./resources/function";
import { functionLayerResource } from "./resources/functionLayer";
import { functionMiddlewareResource } from "./resources/functionMiddleware";
var serverlessTemplate = {
$schema: "http://json-schema.org/draft-07/schema",
$id: "https://somod.json-schema.sodaru.com/serverless-template/index.json",
title: "JSON Schema for Serverless Template in SOMOD",
definitions: {
somodAjvCompile: somodAjvCompile,
somodAnd: somodAnd,
somodEquals: somodEquals,
somodFunctions: somodFunctions,
somodIf: somodIf,
somodJsonParse: somodJsonParse,
somodJsonStringify: somodJsonStringify,
somodKey: somodKey,
somodOr: somodOr,
somodParameter: somodParameter,
arrayLike: arrayLike,
booleanLike: booleanLike,
numberLike: numberLike,
samAnd: samAnd,
samBase64: samBase64,
samBoolean: samBoolean,
samCidr: samCidr,
samEquals: samEquals,
samFindInMap: samFindInMap,
samGetAZs: samGetAZs,
samIf: samIf,
samJoin: samJoin,
samNot: samNot,
samNumber: samNumber,
samOr: samOr,
samRef: samRef,
samSelect: samSelect,
samSplit: samSplit,
samString: samString,
samSub: samSub,
stringLike: stringLike,
somodAccess: somodAccess,
somodCreateIf: somodCreateIf,
somodDependsOn: somodDependsOn,
somodExtend: somodExtend,
somodModuleName: somodModuleName,
somodModuleNamePattern: somodModuleNamePattern,
somodOutput: somodOutput,
somodRef: somodRef,
somodResourceLogicalIdPattern: somodResourceLogicalIdPattern,
somodResourceName: somodResourceName,
allResource: allResource,
customResource: customResource,
functionTypes: functionTypes,
functionApiEvent: functionApiEvent,
functionHttpApiEvent: functionHttpApiEvent,
functionEvent: functionEvent,
functionEventSource: functionEventSource,
functionResource: functionResource,
functionLayerResource: functionLayerResource,
functionMiddlewareResource: functionMiddlewareResource
},
type: "object",
required: ["Resources"],
properties: {
Resources: {
type: "object",
additionalProperties: {
allOf: [
{ $ref: "#/definitions/allResource" },
{
if: {
type: "object",
properties: {
Type: {
enum: [
"AWS::Serverless::Function",
"AWS::Serverless::LayerVersion",
"SOMOD::Serverless::FunctionMiddleware"
]
}
}
},
then: {
oneOf: [
{ $ref: "#/definitions/functionResource" },
{ $ref: "#/definitions/functionLayerResource" },
{ $ref: "#/definitions/functionMiddlewareResource" }
]
}
},
{
if: {
type: "object",
properties: {
Type: {
type: "string",
pattern: "^Custom::[A-Z][a-zA-Z0-9]{0,63}$"
}
}
},
then: { $ref: "#/definitions/customResource" }
}
]
},
propertyNames: { type: "string", pattern: "^[a-zA-Z0-9]{1,64}$" }
},
Outputs: {
type: "object",
additionalProperties: {
$ref: "#/definitions/stringLike"
},
propertyNames: {
$ref: "#/definitions/somodParameter/properties/SOMOD::Parameter"
}
}
},
additionalProperties: false
};
export default serverlessTemplate;