@nxgt/graphql-validation 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -1
- package/dist/bad-user-input.d.ts +1 -1
- package/dist/builder/args-schema.d.ts +1 -1
- package/dist/builder/check-constraints.d.ts +15 -0
- package/dist/builder/check-constraints.d.ts.map +1 -0
- package/dist/builder/constraints.d.ts +1 -1
- package/dist/builder/input-code.d.ts +29 -0
- package/dist/builder/input-code.d.ts.map +1 -0
- package/dist/builder/input-schema.d.ts.map +1 -1
- package/dist/builder/leaf.d.ts +14 -4
- package/dist/builder/leaf.d.ts.map +1 -1
- package/dist/chunks/{index-n3hypgpf.js → index-rbxe5m3y.js} +7 -3
- package/dist/chunks/{index-n3hypgpf.js.map → index-rbxe5m3y.js.map} +3 -3
- package/dist/chunks/index-s1kkmg35.js +266 -0
- package/dist/chunks/index-s1kkmg35.js.map +14 -0
- package/dist/cli.js +1 -1
- package/dist/codegen.d.ts +4 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +56 -0
- package/dist/codegen.js.map +10 -0
- package/dist/formats/all.d.ts +8 -8
- package/dist/formats/byte.d.ts +1 -1
- package/dist/formats/date-time.d.ts +1 -1
- package/dist/formats/date.d.ts +1 -1
- package/dist/formats/email.d.ts +1 -1
- package/dist/formats/index.d.ts +2 -2
- package/dist/formats/ipv4.d.ts +1 -1
- package/dist/formats/ipv6.d.ts +1 -1
- package/dist/formats/uri.d.ts +1 -1
- package/dist/formats/uuid.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +12 -243
- package/dist/index.js.map +4 -8
- package/dist/rules/all.d.ts +15 -15
- package/dist/rules/contains.d.ts +1 -1
- package/dist/rules/ends-with.d.ts +1 -1
- package/dist/rules/exclusive-max.d.ts +1 -1
- package/dist/rules/exclusive-min.d.ts +1 -1
- package/dist/rules/format.d.ts +1 -1
- package/dist/rules/index.d.ts +3 -1
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/max-items.d.ts +1 -1
- package/dist/rules/max-length.d.ts +1 -1
- package/dist/rules/max.d.ts +1 -1
- package/dist/rules/min-items.d.ts +1 -1
- package/dist/rules/min-length.d.ts +1 -1
- package/dist/rules/min.d.ts +1 -1
- package/dist/rules/multiple-of.d.ts +1 -1
- package/dist/rules/not-contains.d.ts +1 -1
- package/dist/rules/pattern.d.ts +1 -1
- package/dist/rules/rule.d.ts +1 -1
- package/dist/rules/starts-with.d.ts +1 -1
- package/dist/with-validation.d.ts.map +1 -1
- package/docs/guide/constraints.md +1 -1
- package/docs/roadmap.md +6 -3
- package/docs/troubleshooting.md +14 -2
- package/package.json +7 -1
package/dist/rules/max.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const maxRule: import("./rule").Rule<"max", "Float", "number">;
|
|
1
|
+
export declare const maxRule: import("./rule.js").Rule<"max", "Float", "number">;
|
|
2
2
|
//# sourceMappingURL=max.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const minItemsRule: import("./rule").Rule<"minItems", "Int", "list">;
|
|
1
|
+
export declare const minItemsRule: import("./rule.js").Rule<"minItems", "Int", "list">;
|
|
2
2
|
//# sourceMappingURL=min-items.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const minLengthRule: import("./rule").Rule<"minLength", "Int", "string">;
|
|
1
|
+
export declare const minLengthRule: import("./rule.js").Rule<"minLength", "Int", "string">;
|
|
2
2
|
//# sourceMappingURL=min-length.d.ts.map
|
package/dist/rules/min.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const minRule: import("./rule").Rule<"min", "Float", "number">;
|
|
1
|
+
export declare const minRule: import("./rule.js").Rule<"min", "Float", "number">;
|
|
2
2
|
//# sourceMappingURL=min.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const multipleOfRule: import("./rule").Rule<"multipleOf", "Float", "number">;
|
|
1
|
+
export declare const multipleOfRule: import("./rule.js").Rule<"multipleOf", "Float", "number">;
|
|
2
2
|
//# sourceMappingURL=multiple-of.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const notContainsRule: import("./rule").Rule<"notContains", "String", "string">;
|
|
1
|
+
export declare const notContainsRule: import("./rule.js").Rule<"notContains", "String", "string">;
|
|
2
2
|
//# sourceMappingURL=not-contains.d.ts.map
|
package/dist/rules/pattern.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const patternRule: import("./rule").Rule<"pattern", "String", "string">;
|
|
1
|
+
export declare const patternRule: import("./rule.js").Rule<"pattern", "String", "string">;
|
|
2
2
|
//# sourceMappingURL=pattern.d.ts.map
|
package/dist/rules/rule.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const startsWithRule: import("./rule").Rule<"startsWith", "String", "string">;
|
|
1
|
+
export declare const startsWithRule: import("./rule.js").Rule<"startsWith", "String", "string">;
|
|
2
2
|
//# sourceMappingURL=starts-with.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-validation.d.ts","sourceRoot":"","sources":["../src/with-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"with-validation.d.ts","sourceRoot":"","sources":["../src/with-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,aAAa,EAClB,MAAM,SAAS,CAAC;AAiDjB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAWpE"}
|
|
@@ -237,7 +237,7 @@ and list `generated/graphql/constraint.graphqls` in `graphql.config.yml` in plac
|
|
|
237
237
|
`--out <file>` writes `<file>`, creating the folder, and without it the SDL goes
|
|
238
238
|
to stdout (`--help` or `-h`, anywhere on the line, lists the flags). It exits 0 when done, 1 when the file
|
|
239
239
|
cannot be written (`typedefs failed: <message>` on stderr), and 2 on a usage
|
|
240
|
-
error (`Unknown command "<x>".`, `Unexpected arguments: …`, or
|
|
240
|
+
error (`Unknown command "<x>".`, `Unexpected arguments: …`, or `No command.`). Regenerate the file after upgrading the
|
|
241
241
|
package.
|
|
242
242
|
|
|
243
243
|
The schema must declare `@constraint` once. Pick one source for the server:
|
package/docs/roadmap.md
CHANGED
|
@@ -19,12 +19,15 @@ What `@nxgt/graphql-validation` is heading for, phrased as what you get.
|
|
|
19
19
|
|
|
20
20
|
## Next
|
|
21
21
|
|
|
22
|
-
- **A Zod codegen plugin** that writes the same schemas as source, from the
|
|
23
|
-
same rules, so the types your resolvers receive come from your SDL.
|
|
24
22
|
- **Your own formats**, named in `@constraint(format: "...")`.
|
|
25
23
|
- **Schemas that read the context**, `(args, context) => schema`, for checks
|
|
26
24
|
that need the request (uniqueness in a database, permissions).
|
|
27
25
|
|
|
28
26
|
## Shipped
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
- **Declarations resolve under `nodenext`** — 0.2.1. `moduleResolution`
|
|
29
|
+
`nodenext` and `node16` find every export, as `bundler` does.
|
|
30
|
+
- **A Zod codegen plugin**, [`@nxgt/graphql-codegen-zod`](https://www.npmjs.com/package/@nxgt/graphql-codegen-zod):
|
|
31
|
+
it writes the same schemas as source, from the same rules, so the types your
|
|
32
|
+
resolvers receive and the variables a client sends come from your SDL. This
|
|
33
|
+
package gains `@nxgt/graphql-validation/codegen` for it.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -16,13 +16,25 @@ is the one a client sees.
|
|
|
16
16
|
|
|
17
17
|
**When:** type-checking an import of the package.
|
|
18
18
|
**Why:** the package is ESM with an `exports` map, which `moduleResolution`
|
|
19
|
-
`node`/`node10` ignores
|
|
20
|
-
**Fix:**
|
|
19
|
+
`node`/`node10` ignores.
|
|
20
|
+
**Fix:** use `bundler`, or `nodenext` / `node16` (from 0.2.1).
|
|
21
21
|
|
|
22
22
|
```jsonc
|
|
23
23
|
{ "compilerOptions": { "moduleResolution": "bundler" } }
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### `TS2305: Module '"@nxgt/graphql-validation"' has no exported member 'constraintTypeDefs'`
|
|
27
|
+
|
|
28
|
+
**When:** type-checking an import of the package under `moduleResolution`
|
|
29
|
+
`nodenext` or `node16`, with a version before 0.2.1.
|
|
30
|
+
**Why:** the declarations of those versions imported each other without an
|
|
31
|
+
extension, which `nodenext` does not resolve, so no export was found.
|
|
32
|
+
**Fix:** upgrade, or use `bundler` until you can.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun add @nxgt/graphql-validation@latest
|
|
36
|
+
```
|
|
37
|
+
|
|
26
38
|
## Startup
|
|
27
39
|
|
|
28
40
|
### `@constraint(minLength) on Query.check(age:) needs a String or an ID, not Int.`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxgt/graphql-validation",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Validate GraphQL arguments and input fields with @constraint directives, checked by Zod schemas, for graphql 16 and 17",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
"import": "./dist/index.js",
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./codegen": {
|
|
27
|
+
"types": "./dist/codegen.d.ts",
|
|
28
|
+
"import": "./dist/codegen.js",
|
|
29
|
+
"default": "./dist/codegen.js"
|
|
30
|
+
},
|
|
26
31
|
"./package.json": "./package.json"
|
|
27
32
|
},
|
|
28
33
|
"keywords": [
|
|
@@ -52,6 +57,7 @@
|
|
|
52
57
|
"nxgt": {
|
|
53
58
|
"entrypoints": [
|
|
54
59
|
"src/index.ts",
|
|
60
|
+
"src/codegen.ts",
|
|
55
61
|
"src/cli.ts"
|
|
56
62
|
]
|
|
57
63
|
},
|