@nxgt/graphql-validation 0.2.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 CHANGED
@@ -26,7 +26,7 @@ Your `tsconfig.json` needs:
26
26
  ```jsonc
27
27
  {
28
28
  "compilerOptions": {
29
- "moduleResolution": "bundler" // `nodenext` is not supported
29
+ "moduleResolution": "bundler" // or "nodenext" / "node16", from 0.2.1; "node" / "node10" ignore `exports`
30
30
  }
31
31
  }
32
32
  ```
@@ -1,6 +1,6 @@
1
1
  import { GraphQLError } from 'graphql';
2
2
  import type { z } from 'zod';
3
- import type { ConstraintArgument } from './rules';
3
+ import type { ConstraintArgument } from './rules/index.js';
4
4
  /** One reason an input was refused, at its path inside the arguments. */
5
5
  export interface ValidationIssue {
6
6
  /** `['input', 'address', 'zip']`: the argument, then the input fields. */
@@ -1,6 +1,6 @@
1
1
  import type { GraphQLField, GraphQLObjectType } from 'graphql';
2
2
  import { z } from 'zod';
3
- import type { InputSchemas } from './input-schema';
3
+ import type { InputSchemas } from './input-schema.js';
4
4
  /**
5
5
  * The schema of a field's arguments, or `undefined` when none of them can
6
6
  * break a constraint, so a field with nothing to check is left untouched.
@@ -1,5 +1,5 @@
1
1
  import { type DirectiveNode, type GraphQLDirective } from 'graphql';
2
- import { type RegisteredRule } from '../rules';
2
+ import { type RegisteredRule } from '../rules/index.js';
3
3
  /** One `@constraint` argument written on an argument or an input field. */
4
4
  export interface Constraint {
5
5
  readonly rule: RegisteredRule;
@@ -1,5 +1,5 @@
1
1
  import { type GraphQLInputType, type GraphQLList, type GraphQLNamedInputType } from 'graphql';
2
- import type { Constraint } from './constraints';
2
+ import type { Constraint } from './constraints.js';
3
3
  /**
4
4
  * The source of the schema of one argument or input field: what
5
5
  * `InputSchemas` builds at startup, written for a code generator. The
@@ -1,7 +1,7 @@
1
1
  import { type GraphQLLeafType } from 'graphql';
2
2
  import { z } from 'zod';
3
- import type { Target } from '../rules/rule';
4
- import type { Constraint } from './constraints';
3
+ import type { Target } from '../rules/rule.js';
4
+ import type { Constraint } from './constraints.js';
5
5
  /**
6
6
  * Fails unless every constraint applies to a value of `type`: `minLength` on
7
7
  * an `Int`, anything on a custom scalar or an enum, fails, naming `where`.
package/dist/codegen.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { checkConstraints } from './builder/check-constraints';
2
- export { type Constraint, constraintsOn } from './builder/constraints';
3
- export { type InputCodeOptions, inputCode } from './builder/input-code';
1
+ export { checkConstraints } from './builder/check-constraints.js';
2
+ export { type Constraint, constraintsOn } from './builder/constraints.js';
3
+ export { type InputCodeOptions, inputCode } from './builder/input-code.js';
4
4
  //# sourceMappingURL=codegen.d.ts.map
@@ -1,9 +1,9 @@
1
- export * from './byte';
2
- export * from './date';
3
- export * from './date-time';
4
- export * from './email';
5
- export * from './ipv4';
6
- export * from './ipv6';
7
- export * from './uri';
8
- export * from './uuid';
1
+ export * from './byte.js';
2
+ export * from './date.js';
3
+ export * from './date-time.js';
4
+ export * from './email.js';
5
+ export * from './ipv4.js';
6
+ export * from './ipv6.js';
7
+ export * from './uri.js';
8
+ export * from './uuid.js';
9
9
  //# sourceMappingURL=all.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const byteFormat: import("./format").Format<"byte">;
1
+ export declare const byteFormat: import("./format.js").Format<"byte">;
2
2
  //# sourceMappingURL=byte.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const dateTimeFormat: import("./format").Format<"date-time">;
1
+ export declare const dateTimeFormat: import("./format.js").Format<"date-time">;
2
2
  //# sourceMappingURL=date-time.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const dateFormat: import("./format").Format<"date">;
1
+ export declare const dateFormat: import("./format.js").Format<"date">;
2
2
  //# sourceMappingURL=date.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const emailFormat: import("./format").Format<"email">;
1
+ export declare const emailFormat: import("./format.js").Format<"email">;
2
2
  //# sourceMappingURL=email.d.ts.map
@@ -1,5 +1,5 @@
1
- import * as all from './all';
2
- import type { Format } from './format';
1
+ import * as all from './all.js';
2
+ import type { Format } from './format.js';
3
3
  /**
4
4
  * Every format, keyed by the value `@constraint(format: "...")` takes.
5
5
  * Derived from what `./all` exports, so a new format is one file and one
@@ -1,2 +1,2 @@
1
- export declare const ipv4Format: import("./format").Format<"ipv4">;
1
+ export declare const ipv4Format: import("./format.js").Format<"ipv4">;
2
2
  //# sourceMappingURL=ipv4.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const ipv6Format: import("./format").Format<"ipv6">;
1
+ export declare const ipv6Format: import("./format.js").Format<"ipv6">;
2
2
  //# sourceMappingURL=ipv6.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const uriFormat: import("./format").Format<"uri">;
1
+ export declare const uriFormat: import("./format.js").Format<"uri">;
2
2
  //# sourceMappingURL=uri.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const uuidFormat: import("./format").Format<"uuid">;
1
+ export declare const uuidFormat: import("./format.js").Format<"uuid">;
2
2
  //# sourceMappingURL=uuid.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { type BadUserInputExtensions, badUserInput, type ValidationIssue, } from './bad-user-input';
2
- export { constraintTypeDefs } from './constraint-directive';
3
- export type { ConstraintArgument } from './rules';
4
- export { type ArgsSchema, type SchemaOf, validated } from './validated';
5
- export { withValidation } from './with-validation';
1
+ export { type BadUserInputExtensions, badUserInput, type ValidationIssue, } from './bad-user-input.js';
2
+ export { constraintTypeDefs } from './constraint-directive.js';
3
+ export type { ConstraintArgument } from './rules/index.js';
4
+ export { type ArgsSchema, type SchemaOf, validated } from './validated.js';
5
+ export { withValidation } from './with-validation.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,16 +1,16 @@
1
- export * from './contains';
2
- export * from './ends-with';
3
- export * from './exclusive-max';
4
- export * from './exclusive-min';
5
- export * from './format';
6
- export * from './max';
7
- export * from './max-items';
8
- export * from './max-length';
9
- export * from './min';
10
- export * from './min-items';
11
- export * from './min-length';
12
- export * from './multiple-of';
13
- export * from './not-contains';
14
- export * from './pattern';
15
- export * from './starts-with';
1
+ export * from './contains.js';
2
+ export * from './ends-with.js';
3
+ export * from './exclusive-max.js';
4
+ export * from './exclusive-min.js';
5
+ export * from './format.js';
6
+ export * from './max.js';
7
+ export * from './max-items.js';
8
+ export * from './max-length.js';
9
+ export * from './min.js';
10
+ export * from './min-items.js';
11
+ export * from './min-length.js';
12
+ export * from './multiple-of.js';
13
+ export * from './not-contains.js';
14
+ export * from './pattern.js';
15
+ export * from './starts-with.js';
16
16
  //# sourceMappingURL=all.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const containsRule: import("./rule").Rule<"contains", "String", "string">;
1
+ export declare const containsRule: import("./rule.js").Rule<"contains", "String", "string">;
2
2
  //# sourceMappingURL=contains.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const endsWithRule: import("./rule").Rule<"endsWith", "String", "string">;
1
+ export declare const endsWithRule: import("./rule.js").Rule<"endsWith", "String", "string">;
2
2
  //# sourceMappingURL=ends-with.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const exclusiveMaxRule: import("./rule").Rule<"exclusiveMax", "Float", "number">;
1
+ export declare const exclusiveMaxRule: import("./rule.js").Rule<"exclusiveMax", "Float", "number">;
2
2
  //# sourceMappingURL=exclusive-max.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const exclusiveMinRule: import("./rule").Rule<"exclusiveMin", "Float", "number">;
1
+ export declare const exclusiveMinRule: import("./rule.js").Rule<"exclusiveMin", "Float", "number">;
2
2
  //# sourceMappingURL=exclusive-min.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const formatRule: import("./rule").Rule<"format", "String", "string">;
1
+ export declare const formatRule: import("./rule.js").Rule<"format", "String", "string">;
2
2
  //# sourceMappingURL=format.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod';
2
- import * as all from './all';
2
+ import * as all from './all.js';
3
3
  /**
4
4
  * One of the rules, as its own type: a builder narrows it on `target`, so a
5
5
  * number schema never reaches a string rule.
@@ -1,2 +1,2 @@
1
- export declare const maxItemsRule: import("./rule").Rule<"maxItems", "Int", "list">;
1
+ export declare const maxItemsRule: import("./rule.js").Rule<"maxItems", "Int", "list">;
2
2
  //# sourceMappingURL=max-items.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const maxLengthRule: import("./rule").Rule<"maxLength", "Int", "string">;
1
+ export declare const maxLengthRule: import("./rule.js").Rule<"maxLength", "Int", "string">;
2
2
  //# sourceMappingURL=max-length.d.ts.map
@@ -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
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod';
2
- import type { StringSchema } from '../formats/format';
2
+ import type { StringSchema } from '../formats/format.js';
3
3
  /** The schema each kind of rule narrows. */
4
4
  export interface Targets {
5
5
  string: StringSchema;
@@ -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
package/docs/roadmap.md CHANGED
@@ -25,6 +25,8 @@ What `@nxgt/graphql-validation` is heading for, phrased as what you get.
25
25
 
26
26
  ## Shipped
27
27
 
28
+ - **Declarations resolve under `nodenext`** — 0.2.1. `moduleResolution`
29
+ `nodenext` and `node16` find every export, as `bundler` does.
28
30
  - **A Zod codegen plugin**, [`@nxgt/graphql-codegen-zod`](https://www.npmjs.com/package/@nxgt/graphql-codegen-zod):
29
31
  it writes the same schemas as source, from the same rules, so the types your
30
32
  resolvers receive and the variables a client sends come from your SDL. This
@@ -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, and `nodenext` is not supported.
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.2.0",
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",