From decbf8deec433952eb9c0a1db8169b7e648f1444 Mon Sep 17 00:00:00 2001 From: to1source <31663067+to1source@users.noreply.github.com> Date: Thu, 28 Apr 2022 11:54:42 +0800 Subject: [PATCH 1/2] install deps --- packages/ast/pnpm-lock.yaml | 2 +- packages/config-validator/pnpm-lock.yaml | 6 +++--- packages/contract/pnpm-lock.yaml | 6 +++--- packages/errors/pnpm-lock.yaml | 2 +- packages/utils/pnpm-lock.yaml | 4 ++-- packages/validator-core/pnpm-lock.yaml | 4 ++-- packages/validator/pnpm-lock.yaml | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/ast/pnpm-lock.yaml b/packages/ast/pnpm-lock.yaml index 254693b..1fad9ff 100644 --- a/packages/ast/pnpm-lock.yaml +++ b/packages/ast/pnpm-lock.yaml @@ -2,7 +2,7 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/constants': workspace:^0.5.1 + '@jsonql/constants': workspace:^0.5.10 '@types/node': ^17.0.23 '@typescript-eslint/eslint-plugin': ^5.17.0 '@typescript-eslint/parser': ^5.17.0 diff --git a/packages/config-validator/pnpm-lock.yaml b/packages/config-validator/pnpm-lock.yaml index 605a9bd..39e0237 100644 --- a/packages/config-validator/pnpm-lock.yaml +++ b/packages/config-validator/pnpm-lock.yaml @@ -2,10 +2,10 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/constants': workspace:^0.5.9 + '@jsonql/constants': workspace:^0.5.10 '@jsonql/errors': workspace:^0.6.0 - '@jsonql/utils': workspace:^0.3.3 - '@jsonql/validator-core': workspace:^0.1.0 + '@jsonql/utils': workspace:^0.4.0 + '@jsonql/validator-core': workspace:^0.1.2 '@types/node': ^17.0.23 '@typescript-eslint/eslint-plugin': ^5.17.0 '@typescript-eslint/parser': ^5.17.0 diff --git a/packages/contract/pnpm-lock.yaml b/packages/contract/pnpm-lock.yaml index 7ce6db4..aaafbf3 100644 --- a/packages/contract/pnpm-lock.yaml +++ b/packages/contract/pnpm-lock.yaml @@ -2,9 +2,9 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/constants': workspace:^0.5.1 - '@jsonql/errors': workspace:^0.5.1 - '@jsonql/utils': workspace:^0.3.0 + '@jsonql/constants': workspace:^0.5.10 + '@jsonql/errors': workspace:^0.6.0 + '@jsonql/utils': workspace:^0.4.0 '@swc/cli': ^0.1.57 '@swc/core': ^1.2.165 '@types/node': ^17.0.23 diff --git a/packages/errors/pnpm-lock.yaml b/packages/errors/pnpm-lock.yaml index d23a595..8685cc6 100644 --- a/packages/errors/pnpm-lock.yaml +++ b/packages/errors/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: 5.3 specifiers: - '@jsonql/constants': workspace:^0.2.0 + '@jsonql/constants': workspace:^0.5.10 '@types/koa': ^2.13.4 '@types/koa-bodyparser': ^4.3.7 koa: ^2.13.4 diff --git a/packages/utils/pnpm-lock.yaml b/packages/utils/pnpm-lock.yaml index 7c930f8..3d98c97 100644 --- a/packages/utils/pnpm-lock.yaml +++ b/packages/utils/pnpm-lock.yaml @@ -2,8 +2,8 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/constants': workspace:^0.4.0 - '@jsonql/errors': workspace:^0.5.0 + '@jsonql/constants': workspace:^0.5.10 + '@jsonql/errors': workspace:^0.6.0 '@types/koa': ^2.13.4 '@types/lodash-es': ^4.17.6 '@types/node': ^17.0.23 diff --git a/packages/validator-core/pnpm-lock.yaml b/packages/validator-core/pnpm-lock.yaml index d74e5f2..0521151 100644 --- a/packages/validator-core/pnpm-lock.yaml +++ b/packages/validator-core/pnpm-lock.yaml @@ -2,8 +2,8 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/constants': workspace:^0.5.9 - '@jsonql/utils': workspace:^0.3.3 + '@jsonql/constants': workspace:^0.5.10 + '@jsonql/utils': workspace:^0.4.0 '@types/node': ^17.0.23 '@typescript-eslint/eslint-plugin': ^5.17.0 '@typescript-eslint/parser': ^5.17.0 diff --git a/packages/validator/pnpm-lock.yaml b/packages/validator/pnpm-lock.yaml index 790853f..fd1c850 100644 --- a/packages/validator/pnpm-lock.yaml +++ b/packages/validator/pnpm-lock.yaml @@ -2,11 +2,11 @@ lockfileVersion: 5.3 specifiers: '@ava/typescript': ^3.0.1 - '@jsonql/ast': workspace:^0.4.1 - '@jsonql/constants': workspace:^0.5.9 + '@jsonql/ast': workspace:^0.5.0 + '@jsonql/constants': workspace:^0.5.10 '@jsonql/errors': workspace:^0.6.0 - '@jsonql/utils': workspace:^0.3.3 - '@jsonql/validator-core': workspace:^0.1.1 + '@jsonql/utils': workspace:^0.4.0 + '@jsonql/validator-core': workspace:^0.1.2 '@types/node': ^17.0.23 '@typescript-eslint/eslint-plugin': ^5.17.0 '@typescript-eslint/parser': ^5.17.0 -- Gitee From 7b00cc5f97783e066abb8a5eab8b3d2484d66ff9 Mon Sep 17 00:00:00 2001 From: to1source <31663067+to1source@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:08:01 +0800 Subject: [PATCH 2/2] just moving some code around and did nothing --- packages/validator/src/class/fn.ts | 44 ++++++++++---------- packages/validator/tests/class-units.test.ts | 4 +- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/packages/validator/src/class/fn.ts b/packages/validator/src/class/fn.ts index 934a1f6..98ed152 100644 --- a/packages/validator/src/class/fn.ts +++ b/packages/validator/src/class/fn.ts @@ -53,29 +53,6 @@ export function createAutomaticRules( }) } -/* create a generic wrapper method to manage the error */ -async function validateFnWrapper( - fn: JsonqlValidateFn, - args: Array, - name?: string, - errDetail?: Array -) { - - return Reflect.apply(fn, null, args) - .then((result: boolean) => { - - console.log(name, args, errDetail) - - if (!result) { - throw new JsonqlValidationError(name, errDetail) - } - return result - }) - .catch(err => { - console.log('ERROR?', err) - }) -} - /** when this get put in the execution queue we also provide the index (argument position) @@ -113,6 +90,27 @@ function getValidateRules(ast: any): JsonqlValidateFn { throw new Error(`Unable to determine type from ast map to create validator!`) } +/* create a generic wrapper method to manage the error */ +async function validateFnWrapper( + fn: JsonqlValidateFn, + args: Array, + name?: string, + errDetail?: Array +) { + + return Reflect.apply(fn, null, args) + .then((result: boolean) => { + if (!result) { + console.log(name, args, errDetail) + throw new JsonqlValidationError(name, errDetail) + } + return result + }) + .catch(err => { + console.log('ERROR?', err) + }) +} + /** extract the default value if there is none */ export function getOptionalValue(arg: any, param: any) { if (arg !== undefined) { diff --git a/packages/validator/tests/class-units.test.ts b/packages/validator/tests/class-units.test.ts index 3d41907..e2c3534 100644 --- a/packages/validator/tests/class-units.test.ts +++ b/packages/validator/tests/class-units.test.ts @@ -76,8 +76,8 @@ test.only(`It should able validate`, async t => { return validator.validate(values) .then(result => { - console.log('result') - showDeep(result) + //console.log('result') + //showDeep(result) }) .catch(err => { console.log('err') -- Gitee