1 | import { DMMFClass } from './dmmf';
|
2 | import { DMMF } from './dmmf-types';
|
3 | import { ArgError, FieldError, InvalidArgError, InvalidFieldError } from './error-types';
|
4 | import { MissingItem } from './utils/printJsonErrors';
|
5 | export declare class Document {
|
6 | readonly type: 'query' | 'mutation';
|
7 | readonly children: Field[];
|
8 | constructor(type: 'query' | 'mutation', children: Field[]);
|
9 | toString(): string;
|
10 | validate(select?: any, isTopLevelQuery?: boolean, originalMethod?: string, errorFormat?: 'pretty' | 'minimal' | 'colorless', validationCallsite?: any): void;
|
11 | protected printFieldError: ({ error, path }: FieldError, missingItems: MissingItem[], minimal: boolean) => string;
|
12 | protected printArgError: ({ error, path }: ArgError, hasMissingItems: boolean, minimal: boolean) => string;
|
13 | /**
|
14 | * As we're allowing both single objects and array of objects for list inputs, we need to remove incorrect
|
15 | * zero indexes from the path
|
16 | * @param inputPath e.g. ['where', 'AND', 0, 'id']
|
17 | * @param select select object
|
18 | */
|
19 | private normalizePath;
|
20 | }
|
21 | export declare class PrismaClientValidationError extends Error {
|
22 | }
|
23 | export interface FieldArgs {
|
24 | name: string;
|
25 | schemaField?: DMMF.SchemaField;
|
26 | args?: Args;
|
27 | children?: Field[];
|
28 | error?: InvalidFieldError;
|
29 | }
|
30 | export declare class Field {
|
31 | readonly name: string;
|
32 | readonly args?: Args;
|
33 | readonly children?: Field[];
|
34 | readonly error?: InvalidFieldError;
|
35 | readonly hasInvalidChild: boolean;
|
36 | readonly hasInvalidArg: boolean;
|
37 | readonly schemaField?: DMMF.SchemaField;
|
38 | constructor({ name, args, children, error, schemaField }: FieldArgs);
|
39 | toString(): string;
|
40 | collectErrors(prefix?: string): {
|
41 | fieldErrors: FieldError[];
|
42 | argErrors: ArgError[];
|
43 | };
|
44 | }
|
45 | export declare class Args {
|
46 | args: Arg[];
|
47 | readonly hasInvalidArg: boolean;
|
48 | constructor(args?: Arg[]);
|
49 | toString(): string;
|
50 | collectErrors(): ArgError[];
|
51 | }
|
52 | interface ArgOptions {
|
53 | key: string;
|
54 | value: ArgValue;
|
55 | argType?: DMMF.ArgType;
|
56 | isEnum?: boolean;
|
57 | error?: InvalidArgError;
|
58 | schemaArg?: DMMF.SchemaArg;
|
59 | }
|
60 | export declare class Arg {
|
61 | readonly key: string;
|
62 | value: ArgValue;
|
63 | readonly error?: InvalidArgError;
|
64 | readonly hasError: boolean;
|
65 | readonly isEnum: boolean;
|
66 | readonly schemaArg?: DMMF.SchemaArg;
|
67 | readonly argType?: DMMF.ArgType;
|
68 | readonly isNullable: boolean;
|
69 | constructor({ key, value, argType, isEnum, error, schemaArg, }: ArgOptions);
|
70 | _toString(value: ArgValue, key: string): string | undefined;
|
71 | toString(): string;
|
72 | collectErrors(): ArgError[];
|
73 | }
|
74 | export declare type ArgValue = string | boolean | number | undefined | Args | string[] | boolean[] | number[] | Args[] | null;
|
75 | export interface DocumentInput {
|
76 | dmmf: DMMFClass;
|
77 | rootTypeName: 'query' | 'mutation';
|
78 | rootField: string;
|
79 | select?: any;
|
80 | }
|
81 | export declare function makeDocument({ dmmf, rootTypeName, rootField, select, }: DocumentInput): Document;
|
82 | export declare function transformDocument(document: Document): Document;
|
83 | export declare function selectionToFields(dmmf: DMMFClass, selection: any, schemaField: DMMF.SchemaField, path: string[]): Field[];
|
84 | export declare function isInputArgType(argType: DMMF.ArgType): argType is DMMF.InputType;
|
85 | export interface UnpackOptions {
|
86 | document: Document;
|
87 | path: string[];
|
88 | data: any;
|
89 | }
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | export declare function unpack({ document, path, data }: UnpackOptions): any;
|
95 | export interface MapDatesOptions {
|
96 | field: Field;
|
97 | data: any;
|
98 | }
|
99 | export declare function mapDates({ field, data }: MapDatesOptions): any;
|
100 | export declare function mapJson({ field, data }: MapDatesOptions): any;
|
101 | export declare function getField(document: Document, path: string[]): Field;
|
102 | export {};
|