[6a3a178] | 1 | import type {AnySchemaObject} from "./types"
|
---|
| 2 | import AjvCore, {Options} from "./core"
|
---|
| 3 |
|
---|
| 4 | import draft7Vocabularies from "./vocabularies/draft7"
|
---|
| 5 | import dynamicVocabulary from "./vocabularies/dynamic"
|
---|
| 6 | import nextVocabulary from "./vocabularies/next"
|
---|
| 7 | import unevaluatedVocabulary from "./vocabularies/unevaluated"
|
---|
| 8 | import discriminator from "./vocabularies/discriminator"
|
---|
| 9 | import addMetaSchema2019 from "./refs/json-schema-2019-09"
|
---|
| 10 |
|
---|
| 11 | const META_SCHEMA_ID = "https://json-schema.org/draft/2019-09/schema"
|
---|
| 12 |
|
---|
| 13 | class Ajv2019 extends AjvCore {
|
---|
| 14 | constructor(opts: Options = {}) {
|
---|
| 15 | super({
|
---|
| 16 | ...opts,
|
---|
| 17 | dynamicRef: true,
|
---|
| 18 | next: true,
|
---|
| 19 | unevaluated: true,
|
---|
| 20 | })
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | _addVocabularies(): void {
|
---|
| 24 | super._addVocabularies()
|
---|
| 25 | this.addVocabulary(dynamicVocabulary)
|
---|
| 26 | draft7Vocabularies.forEach((v) => this.addVocabulary(v))
|
---|
| 27 | this.addVocabulary(nextVocabulary)
|
---|
| 28 | this.addVocabulary(unevaluatedVocabulary)
|
---|
| 29 | if (this.opts.discriminator) this.addKeyword(discriminator)
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | _addDefaultMetaSchema(): void {
|
---|
| 33 | super._addDefaultMetaSchema()
|
---|
| 34 | const {$data, meta} = this.opts
|
---|
| 35 | if (!meta) return
|
---|
| 36 | addMetaSchema2019.call(this, $data)
|
---|
| 37 | this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | defaultMeta(): string | AnySchemaObject | undefined {
|
---|
| 41 | return (this.opts.defaultMeta =
|
---|
| 42 | super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined))
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | module.exports = exports = Ajv2019
|
---|
| 47 | Object.defineProperty(exports, "__esModule", {value: true})
|
---|
| 48 |
|
---|
| 49 | export default Ajv2019
|
---|
| 50 |
|
---|
| 51 | export {
|
---|
| 52 | Format,
|
---|
| 53 | FormatDefinition,
|
---|
| 54 | AsyncFormatDefinition,
|
---|
| 55 | KeywordDefinition,
|
---|
| 56 | KeywordErrorDefinition,
|
---|
| 57 | CodeKeywordDefinition,
|
---|
| 58 | MacroKeywordDefinition,
|
---|
| 59 | FuncKeywordDefinition,
|
---|
| 60 | Vocabulary,
|
---|
| 61 | Schema,
|
---|
| 62 | SchemaObject,
|
---|
| 63 | AnySchemaObject,
|
---|
| 64 | AsyncSchema,
|
---|
| 65 | AnySchema,
|
---|
| 66 | ValidateFunction,
|
---|
| 67 | AsyncValidateFunction,
|
---|
| 68 | ErrorObject,
|
---|
| 69 | ErrorNoParams,
|
---|
| 70 | } from "./types"
|
---|
| 71 |
|
---|
| 72 | export {Plugin, Options, CodeOptions, InstanceOptions, Logger, ErrorsTextOptions} from "./core"
|
---|
| 73 | export {SchemaCxt, SchemaObjCxt} from "./compile"
|
---|
| 74 | export {KeywordCxt} from "./compile/validate"
|
---|
| 75 | export {DefinedError} from "./vocabularies/errors"
|
---|
| 76 | export {JSONType} from "./compile/rules"
|
---|
| 77 | export {JSONSchemaType} from "./types/json-schema"
|
---|
| 78 | export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen"
|
---|