Skip to content

Commit

Permalink
move AjvPack class to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Nov 29, 2020
1 parent c4251d3 commit 662bb1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions lib/standalone/index.ts → lib/standalone.ts
@@ -1,14 +1,12 @@
import type Ajv from "../ajv"
import type {AnyValidateFunction, SourceCode} from "../types"
import type {ScopeValueSets, ValueScopeName} from "../compile/codegen/scope"
import {_, _Code, Code, getProperty} from "../compile/codegen/code"
import {SchemaEnv} from "../compile"

type HashMap<T> = {[K in string]?: T}
import type AjvCore from "./core"
import type {AnyValidateFunction, SourceCode} from "./types"
import type {ScopeValueSets, ValueScopeName} from "./compile/codegen/scope"
import type {SchemaEnv} from "./compile"
import {_, _Code, Code, getProperty} from "./compile/codegen/code"

export default function standaloneCode(
ajv: Ajv,
refsOrFunc?: HashMap<string> | AnyValidateFunction
ajv: AjvCore,
refsOrFunc?: {[K in string]?: string} | AnyValidateFunction
): string {
if (!ajv.opts.code.source) {
throw new Error("moduleCode: ajv instance must have code.source option")
Expand All @@ -35,7 +33,7 @@ export default function standaloneCode(
}

function multiExportsCode<T extends SchemaEnv | string>(
schemas: HashMap<T>,
schemas: {[K in string]?: T},
getValidateFunc: (schOrId: T) => AnyValidateFunction | undefined
): string {
const usedValues: ScopeValueSets = {}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -64,7 +64,6 @@
"dependencies": {
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^0.5.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.2.2"
},
"devDependencies": {
Expand Down Expand Up @@ -94,6 +93,7 @@
"mocha": "^8.0.1",
"nyc": "^15.0.0",
"prettier": "^2.0.5",
"require-from-string": "^2.0.2",
"terser": "^5.2.1",
"ts-node": "^9.0.0",
"tsify": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion spec/ajv_instances.ts
@@ -1,6 +1,6 @@
import type AjvCore from "../dist/core"
import type {Options} from ".."
import AjvPack from "../dist/standalone/instance"
import AjvPack from "./ajv_pack"

export default function getAjvInstances(
_Ajv: typeof AjvCore,
Expand Down
4 changes: 2 additions & 2 deletions lib/standalone/instance.ts → spec/ajv_pack.ts
@@ -1,5 +1,5 @@
import Ajv, {AnySchema, AnyValidateFunction, ErrorObject} from "../core"
import standaloneCode from "."
import Ajv, {AnySchema, AnyValidateFunction, ErrorObject} from "../dist/core"
import standaloneCode from "../dist/standalone"
import requireFromString = require("require-from-string")

export default class AjvPack {
Expand Down

0 comments on commit 662bb1a

Please sign in to comment.