$
This commit is contained in:
9
node_modules/ajv-formats/dist/formats.d.ts
generated
vendored
Normal file
9
node_modules/ajv-formats/dist/formats.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Format } from "ajv";
|
||||
export declare type FormatMode = "fast" | "full";
|
||||
export declare type FormatName = "date" | "time" | "date-time" | "duration" | "uri" | "uri-reference" | "uri-template" | "url" | "email" | "hostname" | "ipv4" | "ipv6" | "regex" | "uuid" | "json-pointer" | "json-pointer-uri-fragment" | "relative-json-pointer" | "byte" | "int32" | "int64" | "float" | "double" | "password" | "binary";
|
||||
export declare type DefinedFormats = {
|
||||
[key in FormatName]: Format;
|
||||
};
|
||||
export declare const fullFormats: DefinedFormats;
|
||||
export declare const fastFormats: DefinedFormats;
|
||||
export declare const formatNames: FormatName[];
|
173
node_modules/ajv-formats/dist/formats.js
generated
vendored
Normal file
173
node_modules/ajv-formats/dist/formats.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/ajv-formats/dist/formats.js.map
generated
vendored
Normal file
1
node_modules/ajv-formats/dist/formats.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/ajv-formats/dist/index.d.ts
generated
vendored
Normal file
15
node_modules/ajv-formats/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { FormatMode, FormatName } from "./formats";
|
||||
import type { Plugin, Format } from "ajv";
|
||||
export { FormatMode, FormatName } from "./formats";
|
||||
export { LimitFormatError } from "./limit";
|
||||
export interface FormatOptions {
|
||||
mode?: FormatMode;
|
||||
formats?: FormatName[];
|
||||
keywords?: boolean;
|
||||
}
|
||||
export declare type FormatsPluginOptions = FormatName[] | FormatOptions;
|
||||
export interface FormatsPlugin extends Plugin<FormatsPluginOptions> {
|
||||
get: (format: FormatName, mode?: FormatMode) => Format;
|
||||
}
|
||||
declare const formatsPlugin: FormatsPlugin;
|
||||
export default formatsPlugin;
|
37
node_modules/ajv-formats/dist/index.js
generated
vendored
Normal file
37
node_modules/ajv-formats/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const formats_1 = require("./formats");
|
||||
const limit_1 = require("./limit");
|
||||
const codegen_1 = require("ajv/dist/compile/codegen");
|
||||
const fullName = new codegen_1.Name("fullFormats");
|
||||
const fastName = new codegen_1.Name("fastFormats");
|
||||
const formatsPlugin = (ajv, opts = { keywords: true }) => {
|
||||
if (Array.isArray(opts)) {
|
||||
addFormats(ajv, opts, formats_1.fullFormats, fullName);
|
||||
return ajv;
|
||||
}
|
||||
const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
|
||||
const list = opts.formats || formats_1.formatNames;
|
||||
addFormats(ajv, list, formats, exportName);
|
||||
if (opts.keywords)
|
||||
limit_1.default(ajv);
|
||||
return ajv;
|
||||
};
|
||||
formatsPlugin.get = (name, mode = "full") => {
|
||||
const formats = mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats;
|
||||
const f = formats[name];
|
||||
if (!f)
|
||||
throw new Error(`Unknown format "${name}"`);
|
||||
return f;
|
||||
};
|
||||
function addFormats(ajv, list, fs, exportName) {
|
||||
var _a;
|
||||
var _b;
|
||||
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : (_b.formats = codegen_1._ `require("ajv-formats/dist/formats").${exportName}`);
|
||||
for (const f of list)
|
||||
ajv.addFormat(f, fs[f]);
|
||||
}
|
||||
module.exports = exports = formatsPlugin;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = formatsPlugin;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/ajv-formats/dist/index.js.map
generated
vendored
Normal file
1
node_modules/ajv-formats/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
10
node_modules/ajv-formats/dist/limit.d.ts
generated
vendored
Normal file
10
node_modules/ajv-formats/dist/limit.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { Plugin, CodeKeywordDefinition, ErrorObject } from "ajv";
|
||||
declare type Kwd = "formatMaximum" | "formatMinimum" | "formatExclusiveMaximum" | "formatExclusiveMinimum";
|
||||
declare type Comparison = "<=" | ">=" | "<" | ">";
|
||||
export declare type LimitFormatError = ErrorObject<Kwd, {
|
||||
limit: string;
|
||||
comparison: Comparison;
|
||||
}>;
|
||||
export declare const formatLimitDefinition: CodeKeywordDefinition;
|
||||
declare const formatLimitPlugin: Plugin<undefined>;
|
||||
export default formatLimitPlugin;
|
69
node_modules/ajv-formats/dist/limit.js
generated
vendored
Normal file
69
node_modules/ajv-formats/dist/limit.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.formatLimitDefinition = void 0;
|
||||
const ajv_1 = require("ajv");
|
||||
const codegen_1 = require("ajv/dist/compile/codegen");
|
||||
const ops = codegen_1.operators;
|
||||
const KWDs = {
|
||||
formatMaximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT },
|
||||
formatMinimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT },
|
||||
formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
||||
formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE },
|
||||
};
|
||||
const error = {
|
||||
message: ({ keyword, schemaCode }) => codegen_1.str `should be ${KWDs[keyword].okStr} ${schemaCode}`,
|
||||
params: ({ keyword, schemaCode }) => codegen_1._ `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`,
|
||||
};
|
||||
exports.formatLimitDefinition = {
|
||||
keyword: Object.keys(KWDs),
|
||||
type: "string",
|
||||
schemaType: "string",
|
||||
$data: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const { gen, data, schemaCode, keyword, it } = cxt;
|
||||
const { opts, self } = it;
|
||||
if (!opts.validateFormats)
|
||||
return;
|
||||
const fCxt = new ajv_1.KeywordCxt(it, self.RULES.all.format.definition, "format");
|
||||
if (fCxt.$data)
|
||||
validate$DataFormat();
|
||||
else
|
||||
validateFormat();
|
||||
function validate$DataFormat() {
|
||||
const fmts = gen.scopeValue("formats", {
|
||||
ref: self.formats,
|
||||
code: opts.code.formats,
|
||||
});
|
||||
const fmt = gen.const("fmt", codegen_1._ `${fmts}[${fCxt.schemaCode}]`);
|
||||
cxt.fail$data(codegen_1.or(codegen_1._ `typeof ${fmt} != "object"`, codegen_1._ `${fmt} instanceof RegExp`, codegen_1._ `typeof ${fmt}.compare != "function"`, compareCode(fmt)));
|
||||
}
|
||||
function validateFormat() {
|
||||
const format = fCxt.schema;
|
||||
const fmtDef = self.formats[format];
|
||||
if (!fmtDef || fmtDef === true)
|
||||
return;
|
||||
if (typeof fmtDef != "object" ||
|
||||
fmtDef instanceof RegExp ||
|
||||
typeof fmtDef.compare != "function") {
|
||||
throw new Error(`"${keyword}": format "${format}" does not define "compare" function`);
|
||||
}
|
||||
const fmt = gen.scopeValue("formats", {
|
||||
key: format,
|
||||
ref: fmtDef,
|
||||
code: opts.code.formats ? codegen_1._ `${opts.code.formats}${codegen_1.getProperty(format)}` : undefined,
|
||||
});
|
||||
cxt.fail$data(compareCode(fmt));
|
||||
}
|
||||
function compareCode(fmt) {
|
||||
return codegen_1._ `${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
|
||||
}
|
||||
},
|
||||
dependencies: ["format"],
|
||||
};
|
||||
const formatLimitPlugin = (ajv) => {
|
||||
ajv.addKeyword(exports.formatLimitDefinition);
|
||||
return ajv;
|
||||
};
|
||||
exports.default = formatLimitPlugin;
|
||||
//# sourceMappingURL=limit.js.map
|
1
node_modules/ajv-formats/dist/limit.js.map
generated
vendored
Normal file
1
node_modules/ajv-formats/dist/limit.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user