@nxgt/graphql-validation 0.2.1 → 0.3.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 +64 -5
- package/dist/builder/check-constraints.d.ts +6 -1
- package/dist/builder/check-constraints.d.ts.map +1 -1
- package/dist/builder/input-code.d.ts +14 -1
- package/dist/builder/input-code.d.ts.map +1 -1
- package/dist/builder/input-schema.d.ts +3 -1
- package/dist/builder/input-schema.d.ts.map +1 -1
- package/dist/builder/leaf.d.ts +2 -2
- package/dist/builder/leaf.d.ts.map +1 -1
- package/dist/chunks/index-twevz7yc.js +527 -0
- package/dist/chunks/index-twevz7yc.js.map +26 -0
- package/dist/chunks/{index-rbxe5m3y.js → index-xcaf9kes.js} +24 -97
- package/dist/chunks/index-xcaf9kes.js.map +27 -0
- package/dist/cli.js +1 -1
- package/dist/codegen.d.ts +1 -0
- package/dist/codegen.d.ts.map +1 -1
- package/dist/codegen.js +19 -9
- package/dist/codegen.js.map +3 -3
- package/dist/formats/byte.d.ts +1 -1
- package/dist/formats/byte.d.ts.map +1 -1
- package/dist/formats/date-time.d.ts +1 -1
- package/dist/formats/date-time.d.ts.map +1 -1
- package/dist/formats/date.d.ts +1 -1
- package/dist/formats/date.d.ts.map +1 -1
- package/dist/formats/email.d.ts +1 -1
- package/dist/formats/email.d.ts.map +1 -1
- package/dist/formats/format.d.ts +17 -3
- package/dist/formats/format.d.ts.map +1 -1
- package/dist/formats/index.d.ts +6 -8
- package/dist/formats/index.d.ts.map +1 -1
- package/dist/formats/ipv4.d.ts +1 -1
- package/dist/formats/ipv4.d.ts.map +1 -1
- package/dist/formats/ipv6.d.ts +1 -1
- package/dist/formats/ipv6.d.ts.map +1 -1
- package/dist/formats/marked.d.ts +42 -0
- package/dist/formats/marked.d.ts.map +1 -0
- package/dist/formats/registry.d.ts +50 -0
- package/dist/formats/registry.d.ts.map +1 -0
- package/dist/formats/uri.d.ts +1 -1
- package/dist/formats/uri.d.ts.map +1 -1
- package/dist/formats/uuid.d.ts +1 -1
- package/dist/formats/uuid.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +3 -3
- package/dist/rules/format.d.ts.map +1 -1
- package/dist/rules/index.d.ts +8 -3
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/rule.d.ts +19 -2
- package/dist/rules/rule.d.ts.map +1 -1
- package/dist/with-validation.d.ts +17 -1
- package/dist/with-validation.d.ts.map +1 -1
- package/docs/README.md +1 -1
- package/docs/guide/constraints.md +149 -4
- package/docs/guide/errors.md +4 -1
- package/docs/roadmap.md +19 -15
- package/docs/troubleshooting.md +157 -4
- package/package.json +2 -2
- package/dist/chunks/index-rbxe5m3y.js.map +0 -37
- package/dist/chunks/index-s1kkmg35.js +0 -266
- package/dist/chunks/index-s1kkmg35.js.map +0 -14
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Peers, all **required**:
|
|
|
19
19
|
| --- | --- |
|
|
20
20
|
| `graphql` | `^16.11.0 \|\| ^17.0.0` |
|
|
21
21
|
| `zod` | `>=4.6.5 <5` |
|
|
22
|
-
| `typescript` | `^6.0.3` |
|
|
22
|
+
| `typescript` | `^6.0.3 \|\| ^7.0.0` |
|
|
23
23
|
|
|
24
24
|
Your `tsconfig.json` needs:
|
|
25
25
|
|
|
@@ -83,6 +83,63 @@ request. The resolver receives the parsed arguments.
|
|
|
83
83
|
Every argument, its rule and its Zod equivalent, and the formats, are in
|
|
84
84
|
[Constraints](docs/guide/constraints.md).
|
|
85
85
|
|
|
86
|
+
### Your own formats
|
|
87
|
+
|
|
88
|
+
Name a format of your own in `@constraint(format: "...")`: write each as a Zod
|
|
89
|
+
string schema in one module, and hand the record to `withValidation`.
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// formats.ts
|
|
93
|
+
import { z } from 'zod';
|
|
94
|
+
|
|
95
|
+
export const formatSchemas = {
|
|
96
|
+
siret: z.string().regex(/^\d{14}$/, 'Invalid SIRET: write its 14 digits'),
|
|
97
|
+
'work-email': z.email().endsWith('@example.com', 'Use your work address'),
|
|
98
|
+
};
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { makeExecutableSchema } from '@graphql-tools/schema';
|
|
103
|
+
import { constraintTypeDefs, withValidation } from '@nxgt/graphql-validation';
|
|
104
|
+
import { formatSchemas } from './formats';
|
|
105
|
+
|
|
106
|
+
const typeDefs = [
|
|
107
|
+
constraintTypeDefs,
|
|
108
|
+
/* GraphQL */ `
|
|
109
|
+
input Company {
|
|
110
|
+
siret: String! @constraint(format: "siret")
|
|
111
|
+
contact: String @constraint(format: "work-email", maxLength: 64)
|
|
112
|
+
}
|
|
113
|
+
type Mutation { register(input: Company!): Boolean }
|
|
114
|
+
`,
|
|
115
|
+
];
|
|
116
|
+
const resolvers = { Mutation: { register: () => true } };
|
|
117
|
+
|
|
118
|
+
export const schema = withValidation(
|
|
119
|
+
makeExecutableSchema({ typeDefs, resolvers }),
|
|
120
|
+
{ formats: formatSchemas },
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
A format is `z.string()` or a string format (`z.email()`, …), narrowed as you
|
|
125
|
+
like (`.regex()`, `.refine()`) but never transformed nor rewritten (no
|
|
126
|
+
`.transform()`, `.trim()`, `.toLowerCase()`, `z.url()`, which trims,
|
|
127
|
+
`z.coerce.string()`, …): the resolver receives what the client sent. The one
|
|
128
|
+
exception is the built-in `uri`, `z.url()`, which trims surrounding white
|
|
129
|
+
space (see [Formats](docs/guide/constraints.md#formats)). The other rules
|
|
130
|
+
narrow your format as they narrow a built-in one. Its messages are yours: a
|
|
131
|
+
refusal reads as your schema writes it, and its issue carries
|
|
132
|
+
`constraint: "format"`. A name is lowercase letters, digits and hyphens; a
|
|
133
|
+
built-in name (`email`, …) is a type error and refused at startup, and so is
|
|
134
|
+
a schema that rewrites the value (a custom `.check()` that does fails the
|
|
135
|
+
request, naming the format). An async check (`.refine(async …)`) works in a
|
|
136
|
+
request, and runs once per value. Your format runs through Zod's public API
|
|
137
|
+
only (`safeParseAsync`, `check`, `refine`, `catch`), so a Zod 4 release that
|
|
138
|
+
changes Zod's internals does not break it. Call `withValidation` once, with every
|
|
139
|
+
format: a second call with the same record wraps nothing; with other
|
|
140
|
+
formats, or none, it throws. Without `formats`, nothing changes. Details in
|
|
141
|
+
[Constraints](docs/guide/constraints.md#your-own-formats).
|
|
142
|
+
|
|
86
143
|
### Read the error
|
|
87
144
|
|
|
88
145
|
```json
|
|
@@ -171,12 +228,13 @@ the directive declared is this package's. Both at once throw
|
|
|
171
228
|
| Export | Is |
|
|
172
229
|
| --- | --- |
|
|
173
230
|
| `constraintTypeDefs` | the SDL of `@constraint`, to add to `typeDefs` |
|
|
174
|
-
| `withValidation(schema)` | checks every `@constraint` of a schema before its resolvers run |
|
|
231
|
+
| `withValidation(schema, options?)` | checks every `@constraint` of a schema before its resolvers run; `options.formats` adds your own formats |
|
|
175
232
|
| `validated(schema \| shape, resolver)` | a resolver whose arguments a Zod schema checks |
|
|
176
233
|
| `badUserInput(where, zodError)` | builds the error above, for code that validates by hand |
|
|
177
234
|
| `ValidationIssue`, `BadUserInputExtensions` | the types of `extensions.issues` and `extensions` |
|
|
178
235
|
| `ConstraintArgument` | the type of `issues[].constraint`: `'minLength' \| 'format' \| ...` |
|
|
179
236
|
| `ArgsSchema`, `SchemaOf` | the types `validated` accepts |
|
|
237
|
+
| `WithValidationOptions`, `FormatSchemas`, `OwnFormats`, `StringSchema`, `FormatName` | the types of `withValidation`'s options: a record of string schemas, with no built-in format name (`FormatName`) |
|
|
180
238
|
|
|
181
239
|
`@nxgt/graphql-validation/codegen` is for a code generator, such as
|
|
182
240
|
[`@nxgt/graphql-codegen-zod`](https://www.npmjs.com/package/@nxgt/graphql-codegen-zod): it writes the schemas `withValidation` builds as source, and
|
|
@@ -184,9 +242,10 @@ refuses the schemas `withValidation` refuses. A server does not need it.
|
|
|
184
242
|
|
|
185
243
|
| Export | Is |
|
|
186
244
|
| --- | --- |
|
|
187
|
-
| `checkConstraints(schema, onArgs?)` | runs every startup check of `withValidation` without wrapping anything; returns the `@constraint` directive, or `undefined` when the schema declares none |
|
|
245
|
+
| `checkConstraints(schema, onArgs?, formats?)` | runs every startup check of `withValidation` without wrapping anything; returns the `@constraint` directive, or `undefined` when the schema declares none. `formats` is the record `withValidation` takes, checked the same way |
|
|
188
246
|
| `constraintsOn(directive, node)` | the `Constraint`s written on an argument or input field (`arg.astNode`), `format` first |
|
|
189
|
-
| `inputCode(type, constraints, where, named, options?)` | the schema of that argument or field as source, `z` a free identifier: built-in scalars and lists written in full, nullable types `.nullish()`; every other named type (enum, input object, custom scalar) is what `named(type)` returns. A constraint that cannot apply throws the startup message, naming `where`. `options` (`InputCodeOptions`): `list({ type, code, single })` returns each list's source, given `code` (the array with every rule) and `single` (the list's named type, non-null, without rules), e.g. to take a single value as graphql does: `single`, wrapped, piped into `code` |
|
|
247
|
+
| `inputCode(type, constraints, where, named, options?, formats?)` | the schema of that argument or field as source, `z` a free identifier: built-in scalars and lists written in full, nullable types `.nullish()`; every other named type (enum, input object, custom scalar) is what `named(type)` returns. A constraint that cannot apply throws the startup message, naming `where`. `options` (`InputCodeOptions`): `list({ type, code, single })` returns each list's source, given `code` (the array with every rule) and `single` (the list's named type, non-null, without rules), e.g. to take a single value as graphql does: `single`, wrapped, piped into `code`. `format(name)` returns the source of one of your formats, since only the generator knows where your record is imported from: a reference to your schema, which the other rules narrow (`formatSchemas.siret.max(14)`); built-in formats never reach it. `formats`: the record `withValidation` takes, checked the same way, so its names are known; a field using one of them without the `format` option throws `@constraint(format: "<name>") is one of the application's formats: its source is the code generator's to write, through inputCode's format option.` |
|
|
248
|
+
| `FormatSchemas` | the type of that record |
|
|
190
249
|
| `Constraint` | `{ rule, value }`, one `@constraint` argument. Of `rule`, read `argument` (`'minItems'`, `'format'`, …), `target` (`'list'` for `minItems`/`maxItems`, else what the rule narrows) and `base` (`true` for `format`, which picks the schema the others narrow); the rest is internal |
|
|
191
250
|
|
|
192
251
|
```ts
|
|
@@ -233,4 +292,4 @@ Every startup error and its fix is in [Troubleshooting](docs/troubleshooting.md)
|
|
|
233
292
|
- [Documentation index](docs/README.md)
|
|
234
293
|
- Guides: [Constraints](docs/guide/constraints.md), [Errors](docs/guide/errors.md)
|
|
235
294
|
- [Troubleshooting](docs/troubleshooting.md)
|
|
236
|
-
- [Roadmap](docs/roadmap.md):
|
|
295
|
+
- [Roadmap](docs/roadmap.md): your own formats in the Zod codegen plugin, schemas that read the context
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type GraphQLDirective, type GraphQLField, type GraphQLObjectType, type GraphQLSchema } from 'graphql';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
|
+
import { type FormatSchemas } from '../formats/registry.js';
|
|
3
4
|
/**
|
|
4
5
|
* Runs every check `withValidation` makes at startup, so a code generator
|
|
5
6
|
* refuses the same schemas: the declaration is `constraintTypeDefs`', every
|
|
@@ -8,8 +9,12 @@ import type { z } from 'zod';
|
|
|
8
9
|
* default value breaks its own. `onArgs` receives each object field's
|
|
9
10
|
* arguments schema, for a field with something to check.
|
|
10
11
|
*
|
|
12
|
+
* `formats` are the application's own, which `@constraint(format: "...")`
|
|
13
|
+
* may name beside the built-in ones; they are checked first (name, no
|
|
14
|
+
* built-in replaced, a Zod string schema each).
|
|
15
|
+
*
|
|
11
16
|
* Returns the `@constraint` directive, or `undefined` when the schema
|
|
12
17
|
* declares none (and so carries no constraint).
|
|
13
18
|
*/
|
|
14
|
-
export declare function checkConstraints(schema: GraphQLSchema, onArgs?: (type: GraphQLObjectType, field: GraphQLField<unknown, unknown>, args: z.ZodType) => void): GraphQLDirective | undefined;
|
|
19
|
+
export declare function checkConstraints(schema: GraphQLSchema, onArgs?: (type: GraphQLObjectType, field: GraphQLField<unknown, unknown>, args: z.ZodType) => void, formats?: FormatSchemas): GraphQLDirective | undefined;
|
|
15
20
|
//# sourceMappingURL=check-constraints.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-constraints.d.ts","sourceRoot":"","sources":["../../src/builder/check-constraints.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"check-constraints.d.ts","sourceRoot":"","sources":["../../src/builder/check-constraints.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAGlB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EAAE,KAAK,aAAa,EAAc,MAAM,qBAAqB,CAAC;AAKrE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,CACR,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EACrC,IAAI,EAAE,CAAC,CAAC,OAAO,KACX,IAAI,EACT,OAAO,CAAC,EAAE,aAAa,GACrB,gBAAgB,GAAG,SAAS,CAyB9B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GraphQLInputType, type GraphQLList, type GraphQLNamedInputType } from 'graphql';
|
|
2
|
+
import { type FormatSchemas } from '../formats/registry.js';
|
|
2
3
|
import type { Constraint } from './constraints.js';
|
|
3
4
|
/**
|
|
4
5
|
* The source of the schema of one argument or input field: what
|
|
@@ -10,8 +11,12 @@ import type { Constraint } from './constraints.js';
|
|
|
10
11
|
* object's or an enum's schema by name, a custom scalar's from a mapping.
|
|
11
12
|
* The built-in scalars are written here, with their constraints. A
|
|
12
13
|
* constraint that cannot apply fails as it does at startup.
|
|
14
|
+
*
|
|
15
|
+
* `formats` are the application's own, as `withValidation` takes them: a
|
|
16
|
+
* name among them is a known format, which a built-in one is not. Their
|
|
17
|
+
* source is `options.format`'s to write.
|
|
13
18
|
*/
|
|
14
|
-
export declare function inputCode(type: GraphQLInputType, constraints: readonly Constraint[], where: string, named: (type: GraphQLNamedInputType) => string, options?: InputCodeOptions): string;
|
|
19
|
+
export declare function inputCode(type: GraphQLInputType, constraints: readonly Constraint[], where: string, named: (type: GraphQLNamedInputType) => string, options?: InputCodeOptions, formats?: FormatSchemas): string;
|
|
15
20
|
/** How `inputCode` writes what a generator may want written otherwise. */
|
|
16
21
|
export interface InputCodeOptions {
|
|
17
22
|
/**
|
|
@@ -25,5 +30,13 @@ export interface InputCodeOptions {
|
|
|
25
30
|
readonly code: string;
|
|
26
31
|
readonly single: string;
|
|
27
32
|
}) => string;
|
|
33
|
+
/**
|
|
34
|
+
* The source of one of the application's formats, given its name (a key
|
|
35
|
+
* of the `formats` record): a reference to the application's own schema,
|
|
36
|
+
* which the rules after `format` narrow (`formatSchemas.slug.max(40)`).
|
|
37
|
+
* A built-in format is written inline and never reaches it. Without it,
|
|
38
|
+
* a field using one of the application's formats throws.
|
|
39
|
+
*/
|
|
40
|
+
readonly format?: (name: string) => string;
|
|
28
41
|
}
|
|
29
42
|
//# sourceMappingURL=input-code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-code.d.ts","sourceRoot":"","sources":["../../src/builder/input-code.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAK1B,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"input-code.d.ts","sourceRoot":"","sources":["../../src/builder/input-code.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAK1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAEN,KAAK,aAAa,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,MAAM,EAC9C,OAAO,GAAE,gBAAqB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACrB,MAAM,CAQR;AAED,0EAA0E;AAC1E,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE;QACtB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACxB,KAAK,MAAM,CAAC;IACb;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type GraphQLArgument, type GraphQLDirective, type GraphQLInputField, type GraphQLInputType, type GraphQLSchema } from 'graphql';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { type FormatRegistry } from '../formats/registry.js';
|
|
3
4
|
/**
|
|
4
5
|
* Builds the schemas of the arguments and input fields of one GraphQL
|
|
5
6
|
* schema, once each: an input type is walked a single time however many
|
|
@@ -9,7 +10,8 @@ import { z } from 'zod';
|
|
|
9
10
|
export declare class InputSchemas {
|
|
10
11
|
#private;
|
|
11
12
|
readonly directive: GraphQLDirective | undefined;
|
|
12
|
-
|
|
13
|
+
/** `formats`: the built-in ones by default, the application's added. */
|
|
14
|
+
constructor(schema: GraphQLSchema, formats?: FormatRegistry);
|
|
13
15
|
/** Whether a value of this type can break a constraint anywhere inside. */
|
|
14
16
|
isConstrained(type: GraphQLInputType): boolean;
|
|
15
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-schema.d.ts","sourceRoot":"","sources":["../../src/builder/input-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAMlB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"input-schema.d.ts","sourceRoot":"","sources":["../../src/builder/input-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAEtB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAMlB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAMtE;;;;;GAKG;AACH,qBAAa,YAAY;;IACxB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAYjD,wEAAwE;gBAC5D,MAAM,EAAE,aAAa,EAAE,OAAO,GAAE,cAA6B;IAyBzE,2EAA2E;IAC3E,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO;IAK9C;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAMrC,gEAAgE;IAChE,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,GAAG,OAAO;IAO/D,8EAA8E;IAC9E,EAAE,CAAC,KAAK,EAAE,eAAe,GAAG,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO;IAYxE;;;;OAIG;IACH,aAAa,IAAI,IAAI;CA+ErB"}
|
package/dist/builder/leaf.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type GraphQLLeafType } from 'graphql';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import type { Target } from '../rules/rule.js';
|
|
3
|
+
import type { RuleContext, Target } from '../rules/rule.js';
|
|
4
4
|
import type { Constraint } from './constraints.js';
|
|
5
5
|
/**
|
|
6
6
|
* Fails unless every constraint applies to a value of `type`: `minLength` on
|
|
@@ -16,7 +16,7 @@ export declare function assertObjectTargets(typeName: string, constraints: reado
|
|
|
16
16
|
* without any is left as graphql parsed it. A constraint that cannot apply
|
|
17
17
|
* fails here, at startup.
|
|
18
18
|
*/
|
|
19
|
-
export declare function leafSchema(type: GraphQLLeafType, constraints: readonly Constraint[], where: string): z.ZodType;
|
|
19
|
+
export declare function leafSchema(type: GraphQLLeafType, constraints: readonly Constraint[], where: string, context: RuleContext): z.ZodType;
|
|
20
20
|
/** The source of a built-in scalar's schema, before its constraints. */
|
|
21
21
|
export declare function baseCode(type: GraphQLLeafType): string | undefined;
|
|
22
22
|
/** What a rule's target reads as in an error. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leaf.d.ts","sourceRoot":"","sources":["../../src/builder/leaf.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,eAAe,EAEpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"leaf.d.ts","sourceRoot":"","sources":["../../src/builder/leaf.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,eAAe,EAEpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAehD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,MAAM,GACX,IAAI,CAMN;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,MAAM,GACX,IAAI,CAIN;AAYD;;;;GAIG;AACH,wBAAgB,UAAU,CACzB,IAAI,EAAE,eAAe,EACrB,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,GAClB,CAAC,CAAC,OAAO,CAmBX;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAMlE;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIrD"}
|