Skip to content

Commit

Permalink
fix(ajv): don't re-export types from Ajv 6 that are gone in later ver…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
grantila committed Feb 14, 2022
1 parent 2bb692f commit 75ab2bf
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 2 deletions.
93 changes: 93 additions & 0 deletions lib/ajv-types.ts
@@ -0,0 +1,93 @@
// These are taken from Ajv 6. They're gone in 8, but seems compatible, so to
// not depend on the _types_ from 6 when perhaps using later versions, they're
// copy-pasted here.


export interface TypeParams {
type: string;
}


export type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
DependenciesParams | FormatParams | ComparisonParams |
MultipleOfParams | PatternParams | RequiredParams |
TypeParams | UniqueItemsParams | CustomParams |
PatternRequiredParams | PropertyNamesParams |
IfParams | SwitchParams | NoParams | EnumParams;

export interface RefParams {
ref: string;
}

export interface LimitParams {
limit: number;
}

export interface AdditionalPropertiesParams {
additionalProperty: string;
}

export interface DependenciesParams {
property: string;
missingProperty: string;
depsCount: number;
deps: string;
}

export interface FormatParams {
format: string
}

export interface ComparisonParams {
comparison: string;
limit: number | string;
exclusive: boolean;
}

export interface MultipleOfParams {
multipleOf: number;
}

export interface PatternParams {
pattern: string;
}

export interface RequiredParams {
missingProperty: string;
}

export interface TypeParams {
type: string;
}

export interface UniqueItemsParams {
i: number;
j: number;
}

export interface CustomParams {
keyword: string;
}

export interface PatternRequiredParams {
missingPattern: string;
}

export interface PropertyNamesParams {
propertyName: string;
}

export interface IfParams {
failingKeyword: string;
}

export interface SwitchParams {
caseIndex: number;
}

export interface NoParams { }

export interface EnumParams {
allowedValues: Array<any>;
}

2 changes: 1 addition & 1 deletion lib/prettification.ts
@@ -1,4 +1,4 @@
import { ValidateFunction } from "ajv"
import type { ValidateFunction } from "ajv"
import { getAstByObject } from "jsonpos"

import {
Expand Down
3 changes: 2 additions & 1 deletion lib/types.ts
@@ -1,9 +1,10 @@
import type { ErrorObject, ErrorParameters, TypeParams } from "ajv"
import type { ErrorObject } from "ajv"
import type { ParsedJson } from "jsonpos"

import type { DataPath } from "./data-path.js"
import type { StyleManager } from "./style/interface.js"
import type { PrintCode } from "./code/types.js"
import type { ErrorParameters, TypeParams } from "./ajv-types.js"


export interface ErrorContext
Expand Down

0 comments on commit 75ab2bf

Please sign in to comment.