Skip to content

Commit

Permalink
feat: drop deprecated, add new type
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Feb 7, 2022
1 parent 45b64b2 commit 4917680
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 71 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@commitlint/config-conventional": "^16.0.0",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.15",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"@typescript-eslint/eslint-plugin": "^5.11.0",
"@typescript-eslint/parser": "^5.11.0",
"cross-env": "^7.0.3",
"eslint": "^8.8.0",
"eslint-plugin-unused-imports": "^2.0.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/input/src/Type/JSONString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ export const JSONString = new ScalarType<any>({
name: "JSON",
validate(payload) {
this.assert(isString(payload), "Wrong payload", payload);

return JSON.parse(payload);
try {
return JSON.parse(payload);
} catch (error) {
this.assert(false, "Wrong JSON", payload);
}
},
});
9 changes: 0 additions & 9 deletions packages/input/src/Type/ObjectType.ts

This file was deleted.

11 changes: 11 additions & 0 deletions packages/input/src/Type/RecordType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {isObject} from "@bunt/util";
import {ScalarType} from "./ScalarType";

export const RecordType = new ScalarType<Record<string, any>>({
name: "RecordType",
validate(payload) {
this.assert(isObject(payload), "Wrong payload", payload);

return payload;
},
});
2 changes: 1 addition & 1 deletion packages/input/src/Type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export * from "./List";
export * from "./Nullable";
export * from "./NonNull";
export * from "./Fields";
export * from "./ObjectType";
export * from "./Text";
export * from "./Varchar";
export * from "./Union";
export * from "./Bool";
export * from "./UUID";
export * from "./JSONString";
export * from "./RecordType";
export * from "./Enum";
12 changes: 12 additions & 0 deletions packages/input/test/src/Main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
validate,
Varchar,
} from "../../src";
import {RecordType} from "../../src/Type/RecordType";
import {ITestDescription, ITestHobby, ITestType} from "./interfaces";
import {TestEnum, TestEnumType} from "./Type/TestEnum";

Expand Down Expand Up @@ -130,4 +131,15 @@ describe("Test Input", () => {
.resolves
.toEqual({foo: 1, bar: 2});
});

test("RecordType", async () => {
const plainObject = {foo: 1, bar: 2};
await expect(validate(RecordType, plainObject))
.resolves
.toEqual(plainObject);

await expect(validate(RecordType, null))
.rejects
.toThrow();
});
});
4 changes: 2 additions & 2 deletions packages/queue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"dependencies": {
"@bunt/unit": "^0.21.11",
"@bunt/util": "^0.21.10",
"@types/ioredis": "^4.28.7",
"ioredis": "^4.28.4"
"@types/ioredis": "^4.28.8",
"ioredis": "^4.28.5"
},
"license": "MIT"
}
110 changes: 55 additions & 55 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1641,10 +1641,10 @@
dependencies:
"@types/node" "*"

"@types/ioredis@^4.28.7":
version "4.28.7"
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.7.tgz#ee79987ef80597ba8c17cfbf9345859ff9233c2d"
integrity sha512-jnSGCD2/TPk02j6v6CGqaCEl0LbmLgK6jUuk/AFaSNUBV+SCHiG7E7fnwJreN6hw9GqtLAFkJs4zFbkJrz11mQ==
"@types/ioredis@^4.28.8":
version "4.28.8"
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.8.tgz#a181d6eb70e402a6db670fe54b9c5bb66c0fac17"
integrity sha512-mULOyO2smtvkE1zmzRRA4P0+1UjEqusi014kXOL1q3CY0RgqkR5/wKvv+vAJbPw2Q66wPyylKeevUy+m/FaRMg==
dependencies:
"@types/node" "*"

Expand Down Expand Up @@ -1748,84 +1748,84 @@
dependencies:
"@types/yargs-parser" "*"

"@typescript-eslint/eslint-plugin@^5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.10.2.tgz#f8c1d59fc37bd6d9d11c97267fdfe722c4777152"
integrity sha512-4W/9lLuE+v27O/oe7hXJKjNtBLnZE8tQAFpapdxwSVHqtmIoPB1gph3+ahNwVuNL37BX7YQHyGF9Xv6XCnIX2Q==
"@typescript-eslint/eslint-plugin@^5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.11.0.tgz#3b866371d8d75c70f9b81535e7f7d3aa26527c7a"
integrity sha512-HJh33bgzXe6jGRocOj4FmefD7hRY4itgjzOrSs3JPrTNXsX7j5+nQPciAUj/1nZtwo2kAc3C75jZO+T23gzSGw==
dependencies:
"@typescript-eslint/scope-manager" "5.10.2"
"@typescript-eslint/type-utils" "5.10.2"
"@typescript-eslint/utils" "5.10.2"
"@typescript-eslint/scope-manager" "5.11.0"
"@typescript-eslint/type-utils" "5.11.0"
"@typescript-eslint/utils" "5.11.0"
debug "^4.3.2"
functional-red-black-tree "^1.0.1"
ignore "^5.1.8"
regexpp "^3.2.0"
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/parser@^5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.10.2.tgz#b6076d27cc5499ce3f2c625f5ccde946ecb7db9a"
integrity sha512-JaNYGkaQVhP6HNF+lkdOr2cAs2wdSZBoalE22uYWq8IEv/OVH0RksSGydk+sW8cLoSeYmC+OHvRyv2i4AQ7Czg==
"@typescript-eslint/parser@^5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.11.0.tgz#b4fcaf65513f9b34bdcbffdda055724a5efb7e04"
integrity sha512-x0DCjetHZYBRovJdr3U0zG9OOdNXUaFLJ82ehr1AlkArljJuwEsgnud+Q7umlGDFLFrs8tU8ybQDFocp/eX8mQ==
dependencies:
"@typescript-eslint/scope-manager" "5.10.2"
"@typescript-eslint/types" "5.10.2"
"@typescript-eslint/typescript-estree" "5.10.2"
"@typescript-eslint/scope-manager" "5.11.0"
"@typescript-eslint/types" "5.11.0"
"@typescript-eslint/typescript-estree" "5.11.0"
debug "^4.3.2"

"@typescript-eslint/scope-manager@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.10.2.tgz#92c0bc935ec00f3d8638cdffb3d0e70c9b879639"
integrity sha512-39Tm6f4RoZoVUWBYr3ekS75TYgpr5Y+X0xLZxXqcZNDWZdJdYbKd3q2IR4V9y5NxxiPu/jxJ8XP7EgHiEQtFnw==
"@typescript-eslint/scope-manager@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.11.0.tgz#f5aef83ff253f457ecbee5f46f762298f0101e4b"
integrity sha512-z+K4LlahDFVMww20t/0zcA7gq/NgOawaLuxgqGRVKS0PiZlCTIUtX0EJbC0BK1JtR4CelmkPK67zuCgpdlF4EA==
dependencies:
"@typescript-eslint/types" "5.10.2"
"@typescript-eslint/visitor-keys" "5.10.2"
"@typescript-eslint/types" "5.11.0"
"@typescript-eslint/visitor-keys" "5.11.0"

"@typescript-eslint/type-utils@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.10.2.tgz#ad5acdf98a7d2ab030bea81f17da457519101ceb"
integrity sha512-uRKSvw/Ccs5FYEoXW04Z5VfzF2iiZcx8Fu7DGIB7RHozuP0VbKNzP1KfZkHBTM75pCpsWxIthEH1B33dmGBKHw==
"@typescript-eslint/type-utils@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.11.0.tgz#58be0ba73d1f6ef8983d79f7f0bc2209b253fefe"
integrity sha512-wDqdsYO6ofLaD4DsGZ0jGwxp4HrzD2YKulpEZXmgN3xo4BHJwf7kq49JTRpV0Gx6bxkSUmc9s0EIK1xPbFFpIA==
dependencies:
"@typescript-eslint/utils" "5.10.2"
"@typescript-eslint/utils" "5.11.0"
debug "^4.3.2"
tsutils "^3.21.0"

"@typescript-eslint/types@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.10.2.tgz#604d15d795c4601fffba6ecb4587ff9fdec68ce8"
integrity sha512-Qfp0qk/5j2Rz3p3/WhWgu4S1JtMcPgFLnmAKAW061uXxKSa7VWKZsDXVaMXh2N60CX9h6YLaBoy9PJAfCOjk3w==
"@typescript-eslint/types@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.11.0.tgz#ba345818a2540fdf2755c804dc2158517ab61188"
integrity sha512-cxgBFGSRCoBEhvSVLkKw39+kMzUKHlJGVwwMbPcTZX3qEhuXhrjwaZXWMxVfxDgyMm+b5Q5b29Llo2yow8Y7xQ==

"@typescript-eslint/typescript-estree@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.10.2.tgz#810906056cd3ddcb35aa333fdbbef3713b0fe4a7"
integrity sha512-WHHw6a9vvZls6JkTgGljwCsMkv8wu8XU8WaYKeYhxhWXH/atZeiMW6uDFPLZOvzNOGmuSMvHtZKd6AuC8PrwKQ==
"@typescript-eslint/typescript-estree@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.11.0.tgz#53f9e09b88368191e52020af77c312a4777ffa43"
integrity sha512-yVH9hKIv3ZN3lw8m/Jy5I4oXO4ZBMqijcXCdA4mY8ull6TPTAoQnKKrcZ0HDXg7Bsl0Unwwx7jcXMuNZc0m4lg==
dependencies:
"@typescript-eslint/types" "5.10.2"
"@typescript-eslint/visitor-keys" "5.10.2"
"@typescript-eslint/types" "5.11.0"
"@typescript-eslint/visitor-keys" "5.11.0"
debug "^4.3.2"
globby "^11.0.4"
is-glob "^4.0.3"
semver "^7.3.5"
tsutils "^3.21.0"

"@typescript-eslint/utils@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.10.2.tgz#1fcd37547c32c648ab11aea7173ec30060ee87a8"
integrity sha512-vuJaBeig1NnBRkf7q9tgMLREiYD7zsMrsN1DA3wcoMDvr3BTFiIpKjGiYZoKPllfEwN7spUjv7ZqD+JhbVjEPg==
"@typescript-eslint/utils@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.11.0.tgz#d91548ef180d74c95d417950336d9260fdbe1dc5"
integrity sha512-g2I480tFE1iYRDyMhxPAtLQ9HAn0jjBtipgTCZmd9I9s11OV8CTsG+YfFciuNDcHqm4csbAgC2aVZCHzLxMSUw==
dependencies:
"@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.10.2"
"@typescript-eslint/types" "5.10.2"
"@typescript-eslint/typescript-estree" "5.10.2"
"@typescript-eslint/scope-manager" "5.11.0"
"@typescript-eslint/types" "5.11.0"
"@typescript-eslint/typescript-estree" "5.11.0"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/visitor-keys@5.10.2":
version "5.10.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.10.2.tgz#fdbf272d8e61c045d865bd6c8b41bea73d222f3d"
integrity sha512-zHIhYGGGrFJvvyfwHk5M08C5B5K4bewkm+rrvNTKk1/S15YHR+SA/QUF8ZWscXSfEaB8Nn2puZj+iHcoxVOD/Q==
"@typescript-eslint/visitor-keys@5.11.0":
version "5.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.11.0.tgz#888542381f1a2ac745b06d110c83c0b261487ebb"
integrity sha512-E8w/vJReMGuloGxJDkpPlGwhxocxOpSVgSvjiLO5IxZPmxZF30weOeJYyPSEACwM+X4NziYS9q+WkN/2DHYQwA==
dependencies:
"@typescript-eslint/types" "5.10.2"
"@typescript-eslint/types" "5.11.0"
eslint-visitor-keys "^3.0.0"

"@zxing/[email protected]":
Expand Down Expand Up @@ -4049,10 +4049,10 @@ internal-slot@^1.0.3:
has "^1.0.3"
side-channel "^1.0.4"

ioredis@^4.28.4:
version "4.28.4"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.4.tgz#de62dee96159a97b37f75d91318f2c6dbfe63c15"
integrity sha512-KmG3FDd1pKZcWQ7/fIbwzvpkZ50NwRJ3RBK9dpetJrNfC+sxhK6TzaVkExvh9AiF+rAVSUmvqfHyQp5U418aDw==
ioredis@^4.28.5:
version "4.28.5"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
dependencies:
cluster-key-slot "^1.1.0"
debug "^4.3.1"
Expand Down

0 comments on commit 4917680

Please sign in to comment.