UNPKG

2.9 kBTypeScriptView Raw
1import { DMMF } from './dmmf-types';
2export interface ArgError {
3 path: string[];
4 error: InvalidArgError;
5}
6export interface FieldError {
7 path: string[];
8 error: InvalidFieldError;
9}
10export declare type InvalidFieldError = InvalidFieldNameError | InvalidFieldTypeError | EmptySelectError | NoTrueSelectError | IncludeAndSelectError | EmptyIncludeError;
11export interface InvalidFieldTypeError {
12 type: 'invalidFieldType';
13 modelName: string;
14 fieldName: string;
15 providedValue: any;
16}
17export interface InvalidFieldNameError {
18 type: 'invalidFieldName';
19 modelName: string;
20 didYouMean?: string | null;
21 providedName: string;
22 isInclude?: boolean;
23 isIncludeScalar?: boolean;
24 outputType: DMMF.OutputType;
25}
26export interface EmptySelectError {
27 type: 'emptySelect';
28 field: DMMF.SchemaField;
29}
30export interface EmptyIncludeError {
31 type: 'emptyInclude';
32 field: DMMF.SchemaField;
33}
34export interface NoTrueSelectError {
35 type: 'noTrueSelect';
36 field: DMMF.SchemaField;
37}
38export interface IncludeAndSelectError {
39 type: 'includeAndSelect';
40 field: DMMF.SchemaField;
41}
42export declare type JavaScriptPrimitiveType = 'number' | 'string' | 'boolean';
43export declare type InvalidArgError = InvalidArgNameError | MissingArgError | InvalidArgTypeError | AtLeastOneError | AtMostOneError | InvalidNullArgError;
44/**
45 * This error occurs if the user provides an arg name that doens't exist
46 */
47export interface InvalidArgNameError {
48 type: 'invalidName';
49 providedName: string;
50 providedValue: any;
51 didYouMeanArg?: string;
52 didYouMeanField?: string;
53 originalType: DMMF.ArgType;
54 possibilities?: DMMF.SchemaArgInputType[];
55 outputType?: DMMF.OutputType;
56}
57/**
58 * Opposite of InvalidArgNameError - if the user *doesn't* provide an arg that should be provided
59 * This error both happens with an implicit and explicit `undefined`
60 */
61export interface MissingArgError {
62 type: 'missingArg';
63 missingName: string;
64 missingType: DMMF.SchemaArgInputType[];
65 atLeastOne: boolean;
66 atMostOne: boolean;
67}
68/**
69 * If a user incorrectly provided null where she shouldn't have
70 */
71export interface InvalidNullArgError {
72 type: 'invalidNullArg';
73 name: string;
74 invalidType: DMMF.SchemaArgInputType[];
75 atLeastOne: boolean;
76 atMostOne: boolean;
77}
78export interface AtMostOneError {
79 type: 'atMostOne';
80 key: string;
81 inputType: DMMF.InputType;
82 providedKeys: string[];
83}
84export interface AtLeastOneError {
85 type: 'atLeastOne';
86 key: string;
87 inputType: DMMF.InputType;
88}
89/**
90 * If the scalar type of an arg is not matching what is required
91 */
92export interface InvalidArgTypeError {
93 type: 'invalidType';
94 argName: string;
95 requiredType: {
96 bestFittingType: DMMF.SchemaArgInputType;
97 inputType: DMMF.SchemaArgInputType[];
98 };
99 providedValue: any;
100}