@stoplight/spectral-core
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -5,3 +5,3 @@ "use strict"; | ||
const types_1 = require("@stoplight/types"); | ||
exports.SPECTRAL_PKG_VERSION = '1.2.1'; | ||
exports.SPECTRAL_PKG_VERSION = '1.3.0'; | ||
exports.DEFAULT_PARSER_OPTIONS = Object.freeze({ | ||
@@ -8,0 +8,0 @@ incompatibleValues: types_1.DiagnosticSeverity.Error, |
@@ -48,4 +48,5 @@ "use strict"; | ||
exports.RulesetFunctionValidationError = RulesetFunctionValidationError; | ||
const DEFAULT_OPTIONS_VALIDATOR = (o) => o === null; | ||
function createRulesetFunction({ input, errorOnInvalidInput = false, options, }, fn) { | ||
const validateOptions = options === null ? (o) => o === null : ajv.compile(options); | ||
const validateOptions = options === null ? DEFAULT_OPTIONS_VALIDATOR : ajv.compile(options); | ||
const validateInput = input !== null ? ajv.compile(input) : input; | ||
@@ -88,2 +89,9 @@ const wrappedFn = function (input, options, ...args) { | ||
}; | ||
Reflect.defineProperty(wrappedFn, 'schemas', { | ||
enumerable: false, | ||
value: { | ||
input, | ||
options, | ||
}, | ||
}); | ||
return wrappedFn; | ||
@@ -90,0 +98,0 @@ } |
@@ -1,5 +0,6 @@ | ||
import { JsonPath } from '@stoplight/types'; | ||
import type { JsonPath } from '@stoplight/types'; | ||
import type { IDocumentInventory } from '../documentInventory'; | ||
import type { IRule } from '../ruleset/rule/rule'; | ||
import type { IDocument } from '../document'; | ||
import type { JSONSchema7 } from 'json-schema'; | ||
export declare type RulesetFunction<I extends unknown = unknown, O extends unknown = unknown> = (input: I, options: O, context: RulesetFunctionContext) => void | IFunctionResult[] | Promise<void | IFunctionResult[]>; | ||
@@ -15,2 +16,6 @@ export declare type RulesetFunctionContext = { | ||
validator<O = unknown>(options: unknown): asserts options is O; | ||
readonly schemas: Readonly<{ | ||
input: Readonly<JSONSchema7> | null; | ||
options: Readonly<JSONSchema7> | null; | ||
}>; | ||
}; | ||
@@ -17,0 +22,0 @@ export interface IFunctionResult { |
{ | ||
"name": "@stoplight/spectral-core", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"main": "dist/index.js", | ||
@@ -30,3 +30,3 @@ "types": "dist/index.d.ts", | ||
"@stoplight/spectral-parsers": "^1.0.0", | ||
"@stoplight/spectral-ref-resolver": "*", | ||
"@stoplight/spectral-ref-resolver": "^1.0.0", | ||
"@stoplight/spectral-runtime": "^1.0.0", | ||
@@ -33,0 +33,0 @@ "@stoplight/types": "12.3.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
157356
2404
1