@pkgverse/prismock 2.0.0-beta.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/LICENSE +21 -0
- package/README.md +277 -0
- package/dist/index.cjs +5337 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +5289 -0
- package/dist/lib/client.d.ts +19 -0
- package/dist/lib/delegate.d.ts +42 -0
- package/dist/lib/extensions/index.d.ts +8 -0
- package/dist/lib/extensions/model.d.ts +5 -0
- package/dist/lib/extensions/query.d.ts +4 -0
- package/dist/lib/extensions/result.d.ts +3 -0
- package/dist/lib/helpers.d.ts +11 -0
- package/dist/lib/operations/aggregate.d.ts +11 -0
- package/dist/lib/operations/create.d.ts +34 -0
- package/dist/lib/operations/delete.d.ts +13 -0
- package/dist/lib/operations/find/find.d.ts +155 -0
- package/dist/lib/operations/find/index.d.ts +1 -0
- package/dist/lib/operations/find/match.d.ts +4 -0
- package/dist/lib/operations/groupBy/groupBy.d.ts +10 -0
- package/dist/lib/operations/groupBy/index.d.ts +1 -0
- package/dist/lib/operations/index.d.ts +6 -0
- package/dist/lib/operations/update.d.ts +14 -0
- package/dist/lib/prismock.d.ts +290 -0
- package/dist/lib/types/Aggregate.d.ts +9 -0
- package/dist/lib/types/Create.d.ts +16 -0
- package/dist/lib/types/Find.d.ts +35 -0
- package/dist/lib/types/GroupBy.d.ts +42 -0
- package/dist/lib/types/Upsert.d.ts +9 -0
- package/dist/lib/types/index.d.ts +5 -0
- package/package.json +112 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
2
|
+
import * as runtime from '@prisma/client/runtime/library';
|
|
3
|
+
import { Delegate } from './delegate';
|
|
4
|
+
import { Data } from './prismock';
|
|
5
|
+
type GetData = () => Data;
|
|
6
|
+
type SetData = (data: Data) => void;
|
|
7
|
+
interface PrismockData {
|
|
8
|
+
getData: GetData;
|
|
9
|
+
setData: SetData;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
}
|
|
12
|
+
export type PrismockClientType<T = PrismaClient> = T & PrismockData;
|
|
13
|
+
export declare function generateClient<T = PrismaClient>(delegates: Record<string, Delegate>, getData: GetData, setData: SetData): PrismockClientType<T>;
|
|
14
|
+
type PrismaModule = {
|
|
15
|
+
dmmf: runtime.BaseDMMF;
|
|
16
|
+
};
|
|
17
|
+
export declare function createPrismock(instance: PrismaModule): typeof PrismaClient & PrismockData;
|
|
18
|
+
export declare const PrismockClient: typeof PrismaClient & PrismockData;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
+
import { CreateArgs, CreateManyArgs, FindArgs, GroupByArgs, UpsertArgs } from './types';
|
|
3
|
+
import { DeleteArgs, UpdateArgs } from './operations';
|
|
4
|
+
import { Data, Delegates, Properties } from './prismock';
|
|
5
|
+
export type Item = Record<string, unknown>;
|
|
6
|
+
export type Delegate = {
|
|
7
|
+
create: (args: CreateArgs) => Promise<Item>;
|
|
8
|
+
createMany: (args: CreateManyArgs) => Promise<{
|
|
9
|
+
count: number;
|
|
10
|
+
}>;
|
|
11
|
+
delete: (args: DeleteArgs) => Promise<Item | null>;
|
|
12
|
+
deleteMany: (args: DeleteArgs) => Promise<{
|
|
13
|
+
count: number;
|
|
14
|
+
}>;
|
|
15
|
+
update: (args: UpdateArgs) => Promise<Item | null>;
|
|
16
|
+
updateMany: (args: UpdateArgs) => Promise<{
|
|
17
|
+
count: number;
|
|
18
|
+
}>;
|
|
19
|
+
upsert: (args: UpsertArgs) => Promise<Item>;
|
|
20
|
+
findMany: (args?: FindArgs) => Promise<Item[]>;
|
|
21
|
+
findUnique: (args: FindArgs) => Promise<Item>;
|
|
22
|
+
findFirst: (args: FindArgs) => Promise<Item>;
|
|
23
|
+
findUniqueOrThrow: (args: FindArgs) => Promise<Item>;
|
|
24
|
+
findFirstOrThrow: (args: FindArgs) => Promise<Item>;
|
|
25
|
+
groupBy: (args: GroupByArgs) => Promise<any[]>;
|
|
26
|
+
count: (args: FindArgs) => Promise<number>;
|
|
27
|
+
model: DMMF.Model;
|
|
28
|
+
getProperties: () => DelegateProperties;
|
|
29
|
+
getItems: () => Item[];
|
|
30
|
+
onChange: (items: Item[]) => void;
|
|
31
|
+
};
|
|
32
|
+
export type DelegateProperties = {
|
|
33
|
+
increment: Record<string, number>;
|
|
34
|
+
};
|
|
35
|
+
export type DelegateContext = {
|
|
36
|
+
models: DMMF.Model[];
|
|
37
|
+
model: DMMF.Model;
|
|
38
|
+
name: string;
|
|
39
|
+
data: Data;
|
|
40
|
+
properties: Record<string, DelegateProperties>;
|
|
41
|
+
};
|
|
42
|
+
export declare function generateDelegate(model: DMMF.Model, data: Data, name: string, properties: Properties, delegates: Delegates, onChange: (items: Item[]) => void): Delegate;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Prisma, PrismaClient } from '@prisma/client';
|
|
2
|
+
import { applyModelExtensions } from './model';
|
|
3
|
+
import { applyQueryExtensions } from './query';
|
|
4
|
+
import { applyResultExtensions } from './result';
|
|
5
|
+
import type { ExtendsHook, DefaultArgs } from '@prisma/client/runtime/library';
|
|
6
|
+
export { applyModelExtensions, applyQueryExtensions, applyResultExtensions };
|
|
7
|
+
export type ExtensionsDefinition = Parameters<ExtendsHook<"define", Prisma.TypeMapCb, DefaultArgs>>[0];
|
|
8
|
+
export declare function applyExtensions(client: PrismaClient, extensions: ExtensionsDefinition): PrismaClient<Prisma.PrismaClientOptions, never, DefaultArgs>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Prisma, PrismaClient } from '@prisma/client';
|
|
2
|
+
import type { DefaultArgs, ExtendsHook } from '@prisma/client/runtime/library';
|
|
3
|
+
type ExtensionsDefinition = Parameters<ExtendsHook<'define', Prisma.TypeMapCb, DefaultArgs>>[0];
|
|
4
|
+
export declare function applyModelExtensions(client: PrismaClient, extensions: ExtensionsDefinition): PrismaClient;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Prisma } from "@prisma/client";
|
|
2
|
+
import type { ExtendsHook, DefaultArgs } from "@prisma/client/runtime/library";
|
|
3
|
+
import type { PrismaClient } from "@prisma/client";
|
|
4
|
+
export declare function applyQueryExtensions(client: PrismaClient, extensions: Parameters<ExtendsHook<"define", Prisma.TypeMapCb, DefaultArgs>>[0]): PrismaClient;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Prisma, PrismaClient } from "@prisma/client";
|
|
2
|
+
import { type DefaultArgs, type ExtendsHook } from "@prisma/client/runtime/library";
|
|
3
|
+
export declare function applyResultExtensions(client: PrismaClient, extensions: Parameters<ExtendsHook<"define", Prisma.TypeMapCb, DefaultArgs>>[0]): PrismaClient;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Item } from './delegate';
|
|
2
|
+
export declare function camelize(str: string): string;
|
|
3
|
+
export declare function shallowCompare(a: Item, b: Item): boolean;
|
|
4
|
+
export declare function pick(obj: Record<string, unknown>, keys: string[]): {};
|
|
5
|
+
export declare function omit(obj: Record<string, unknown>, keys: string[]): {};
|
|
6
|
+
export declare function uuid(): string;
|
|
7
|
+
export declare function removeUndefined(o?: Record<string, unknown>): Item | undefined;
|
|
8
|
+
export declare function pipe<T>(...functions: Array<(arg: T) => T>): (value: T) => T;
|
|
9
|
+
export declare function compose<T>(...functions: Array<(arg: T) => T>): (value: T) => T;
|
|
10
|
+
export declare function unique<T>(value: T[]): T[];
|
|
11
|
+
export declare function ensureArray<T>(value: T | T[]): T[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Item } from '../delegate';
|
|
2
|
+
import { AggregateArgs } from '../types';
|
|
3
|
+
type AggregateResult = {
|
|
4
|
+
_avg?: Record<string, number>;
|
|
5
|
+
_count?: number | Record<string, number>;
|
|
6
|
+
_max?: Record<string, number>;
|
|
7
|
+
_min?: Record<string, number>;
|
|
8
|
+
_sum?: Record<string, number>;
|
|
9
|
+
};
|
|
10
|
+
export declare function aggregate(args: AggregateArgs, items: Item[]): AggregateResult;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
+
import { Delegate, DelegateProperties, Item } from '../delegate';
|
|
3
|
+
import { Delegates } from '../prismock';
|
|
4
|
+
import { CreateArgs } from '../types';
|
|
5
|
+
export declare const isAutoIncrement: (field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
6
|
+
kind: DMMF.FieldKind;
|
|
7
|
+
name: string;
|
|
8
|
+
isRequired: boolean;
|
|
9
|
+
isList: boolean;
|
|
10
|
+
isUnique: boolean;
|
|
11
|
+
isId: boolean;
|
|
12
|
+
isReadOnly: boolean;
|
|
13
|
+
isGenerated?: boolean | undefined;
|
|
14
|
+
isUpdatedAt?: boolean | undefined;
|
|
15
|
+
type: string;
|
|
16
|
+
dbName?: string | null | undefined;
|
|
17
|
+
hasDefaultValue: boolean;
|
|
18
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
19
|
+
name: string;
|
|
20
|
+
args: any[];
|
|
21
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
22
|
+
relationFromFields?: string[] | undefined;
|
|
23
|
+
relationToFields?: string[] | undefined;
|
|
24
|
+
relationOnDelete?: string | undefined;
|
|
25
|
+
relationName?: string | undefined;
|
|
26
|
+
documentation?: string | undefined;
|
|
27
|
+
}>) => boolean;
|
|
28
|
+
export declare function calculateDefaultFieldValue(field: DMMF.Field, properties: DelegateProperties): unknown;
|
|
29
|
+
export declare function createDefaultValues(fields: DMMF.Field[], properties: DelegateProperties): Record<string, unknown>;
|
|
30
|
+
export declare function connectOrCreate(delegate: Delegate, delegates: Delegates): (item: Item) => Item;
|
|
31
|
+
export declare function nestedCreate(current: Delegate, delegates: Delegates): (item: Item) => {
|
|
32
|
+
[x: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
export declare function create(item: Item, options: Omit<CreateArgs, 'data'>, delegate: Delegate, delegates: Delegates, onChange: (items: Item[]) => void): Item;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Delegates } from '../prismock';
|
|
2
|
+
import { Item, Delegate } from '../delegate';
|
|
3
|
+
import { FindWhereArgs, SelectArgs } from '../types';
|
|
4
|
+
export type DeleteArgs = {
|
|
5
|
+
select?: SelectArgs | null;
|
|
6
|
+
include?: Record<string, boolean> | null;
|
|
7
|
+
where?: FindWhereArgs;
|
|
8
|
+
};
|
|
9
|
+
export type DeletionMap = {
|
|
10
|
+
toDelete: Item[];
|
|
11
|
+
withoutDeleted: Item[];
|
|
12
|
+
};
|
|
13
|
+
export declare function deleteMany(args: DeleteArgs, current: Delegate, delegates: Delegates, onChange: (items: Item[]) => void): Item[];
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
2
|
+
import { FindArgs, GroupByFieldArg, Order, OrderedValue } from '../../types';
|
|
3
|
+
import { Delegate, DelegateProperties, Item } from '../../delegate';
|
|
4
|
+
import { Delegates } from '../../prismock';
|
|
5
|
+
export declare function findNextIncrement(properties: DelegateProperties, fieldName: string): number;
|
|
6
|
+
export declare function findOne(args: FindArgs, current: Delegate, delegates: Delegates): Item | null;
|
|
7
|
+
export declare function where(whereArgs: FindArgs['where'], current: Delegate, delegates: Delegates): (item: Record<string, unknown>) => boolean;
|
|
8
|
+
export declare function calculateOrder(a: Item, b: Item, orderedProperties: Record<string, OrderedValue>, current: Delegate, delegates: Delegates): number;
|
|
9
|
+
export declare function calculateRelationOrder(a: Item, b: Item, orderedProperty: string, sortOrder: Order, current: Delegate, delegates: Delegates): number;
|
|
10
|
+
export declare function order(args: FindArgs, delegate: Delegate, delegates: Delegates): (items: Item[]) => Item[];
|
|
11
|
+
export declare function paginate(skip?: number, take?: number): (items: Item[]) => Item[];
|
|
12
|
+
export declare function includes(args: FindArgs, current: Delegate, delegates: Delegates): (item: Item) => Item;
|
|
13
|
+
export declare function select(selectArgs: FindArgs['select']): (item: Item) => Item;
|
|
14
|
+
export declare const getJoinField: (field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
15
|
+
kind: DMMF.FieldKind;
|
|
16
|
+
name: string;
|
|
17
|
+
isRequired: boolean;
|
|
18
|
+
isList: boolean;
|
|
19
|
+
isUnique: boolean;
|
|
20
|
+
isId: boolean;
|
|
21
|
+
isReadOnly: boolean;
|
|
22
|
+
isGenerated?: boolean | undefined;
|
|
23
|
+
isUpdatedAt?: boolean | undefined;
|
|
24
|
+
type: string;
|
|
25
|
+
dbName?: string | null | undefined;
|
|
26
|
+
hasDefaultValue: boolean;
|
|
27
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
28
|
+
name: string;
|
|
29
|
+
args: any[];
|
|
30
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
31
|
+
relationFromFields?: string[] | undefined;
|
|
32
|
+
relationToFields?: string[] | undefined;
|
|
33
|
+
relationOnDelete?: string | undefined;
|
|
34
|
+
relationName?: string | undefined;
|
|
35
|
+
documentation?: string | undefined;
|
|
36
|
+
}>, delegates: Delegates) => import("@prisma/generator-helper").ReadonlyDeep<import("@prisma/generator-helper").ReadonlyDeep<{
|
|
37
|
+
kind: DMMF.FieldKind;
|
|
38
|
+
name: string;
|
|
39
|
+
isRequired: boolean;
|
|
40
|
+
isList: boolean;
|
|
41
|
+
isUnique: boolean;
|
|
42
|
+
isId: boolean;
|
|
43
|
+
isReadOnly: boolean;
|
|
44
|
+
isGenerated?: boolean | undefined;
|
|
45
|
+
isUpdatedAt?: boolean | undefined;
|
|
46
|
+
type: string;
|
|
47
|
+
dbName?: string | null | undefined;
|
|
48
|
+
hasDefaultValue: boolean;
|
|
49
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
50
|
+
name: string;
|
|
51
|
+
args: any[];
|
|
52
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
53
|
+
relationFromFields?: string[] | undefined;
|
|
54
|
+
relationToFields?: string[] | undefined;
|
|
55
|
+
relationOnDelete?: string | undefined;
|
|
56
|
+
relationName?: string | undefined;
|
|
57
|
+
documentation?: string | undefined;
|
|
58
|
+
}>> | undefined;
|
|
59
|
+
export declare const getDelegateFromField: (field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
60
|
+
kind: DMMF.FieldKind;
|
|
61
|
+
name: string;
|
|
62
|
+
isRequired: boolean;
|
|
63
|
+
isList: boolean;
|
|
64
|
+
isUnique: boolean;
|
|
65
|
+
isId: boolean;
|
|
66
|
+
isReadOnly: boolean;
|
|
67
|
+
isGenerated?: boolean | undefined;
|
|
68
|
+
isUpdatedAt?: boolean | undefined;
|
|
69
|
+
type: string;
|
|
70
|
+
dbName?: string | null | undefined;
|
|
71
|
+
hasDefaultValue: boolean;
|
|
72
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
73
|
+
name: string;
|
|
74
|
+
args: any[];
|
|
75
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
76
|
+
relationFromFields?: string[] | undefined;
|
|
77
|
+
relationToFields?: string[] | undefined;
|
|
78
|
+
relationOnDelete?: string | undefined;
|
|
79
|
+
relationName?: string | undefined;
|
|
80
|
+
documentation?: string | undefined;
|
|
81
|
+
}>, delegates: Delegates) => Delegate;
|
|
82
|
+
export declare const getFieldRelationshipWhere: (item: Item, field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
83
|
+
kind: DMMF.FieldKind;
|
|
84
|
+
name: string;
|
|
85
|
+
isRequired: boolean;
|
|
86
|
+
isList: boolean;
|
|
87
|
+
isUnique: boolean;
|
|
88
|
+
isId: boolean;
|
|
89
|
+
isReadOnly: boolean;
|
|
90
|
+
isGenerated?: boolean | undefined;
|
|
91
|
+
isUpdatedAt?: boolean | undefined;
|
|
92
|
+
type: string;
|
|
93
|
+
dbName?: string | null | undefined;
|
|
94
|
+
hasDefaultValue: boolean;
|
|
95
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
96
|
+
name: string;
|
|
97
|
+
args: any[];
|
|
98
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
99
|
+
relationFromFields?: string[] | undefined;
|
|
100
|
+
relationToFields?: string[] | undefined;
|
|
101
|
+
relationOnDelete?: string | undefined;
|
|
102
|
+
relationName?: string | undefined;
|
|
103
|
+
documentation?: string | undefined;
|
|
104
|
+
}>, delegates: Delegates) => Record<string, GroupByFieldArg>;
|
|
105
|
+
export declare const getFieldFromRelationshipWhere: (item: Item, field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
106
|
+
kind: DMMF.FieldKind;
|
|
107
|
+
name: string;
|
|
108
|
+
isRequired: boolean;
|
|
109
|
+
isList: boolean;
|
|
110
|
+
isUnique: boolean;
|
|
111
|
+
isId: boolean;
|
|
112
|
+
isReadOnly: boolean;
|
|
113
|
+
isGenerated?: boolean | undefined;
|
|
114
|
+
isUpdatedAt?: boolean | undefined;
|
|
115
|
+
type: string;
|
|
116
|
+
dbName?: string | null | undefined;
|
|
117
|
+
hasDefaultValue: boolean;
|
|
118
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
119
|
+
name: string;
|
|
120
|
+
args: any[];
|
|
121
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
122
|
+
relationFromFields?: string[] | undefined;
|
|
123
|
+
relationToFields?: string[] | undefined;
|
|
124
|
+
relationOnDelete?: string | undefined;
|
|
125
|
+
relationName?: string | undefined;
|
|
126
|
+
documentation?: string | undefined;
|
|
127
|
+
}>) => {
|
|
128
|
+
[x: string]: GroupByFieldArg;
|
|
129
|
+
};
|
|
130
|
+
export declare const getFieldToRelationshipWhere: (item: Item, field: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
131
|
+
kind: DMMF.FieldKind;
|
|
132
|
+
name: string;
|
|
133
|
+
isRequired: boolean;
|
|
134
|
+
isList: boolean;
|
|
135
|
+
isUnique: boolean;
|
|
136
|
+
isId: boolean;
|
|
137
|
+
isReadOnly: boolean;
|
|
138
|
+
isGenerated?: boolean | undefined;
|
|
139
|
+
isUpdatedAt?: boolean | undefined;
|
|
140
|
+
type: string;
|
|
141
|
+
dbName?: string | null | undefined;
|
|
142
|
+
hasDefaultValue: boolean;
|
|
143
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
144
|
+
name: string;
|
|
145
|
+
args: any[];
|
|
146
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
147
|
+
relationFromFields?: string[] | undefined;
|
|
148
|
+
relationToFields?: string[] | undefined;
|
|
149
|
+
relationOnDelete?: string | undefined;
|
|
150
|
+
relationName?: string | undefined;
|
|
151
|
+
documentation?: string | undefined;
|
|
152
|
+
}>) => {
|
|
153
|
+
[x: string]: GroupByFieldArg;
|
|
154
|
+
};
|
|
155
|
+
export declare function findMany(args: FindArgs, current: Delegate, delegates: Delegates): Item[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './find';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Delegate } from '../../delegate';
|
|
2
|
+
import { Delegates } from '../../prismock';
|
|
3
|
+
import { GroupByArgs } from '../../types';
|
|
4
|
+
export declare function groupBy(args: GroupByArgs, current: Delegate, delegates: Delegates): {
|
|
5
|
+
_avg?: Record<string, number> | undefined;
|
|
6
|
+
_count?: number | Record<string, number> | undefined;
|
|
7
|
+
_max?: Record<string, number> | undefined;
|
|
8
|
+
_min?: Record<string, number> | undefined;
|
|
9
|
+
_sum?: Record<string, number> | undefined;
|
|
10
|
+
}[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './groupBy';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Delegate, Item } from '../delegate';
|
|
2
|
+
import { Delegates } from '../prismock';
|
|
3
|
+
import { FindWhereArgs, SelectArgs } from '../types';
|
|
4
|
+
export type UpdateArgs = {
|
|
5
|
+
select?: SelectArgs | null;
|
|
6
|
+
include?: Record<string, boolean> | null;
|
|
7
|
+
data: Item;
|
|
8
|
+
where: FindWhereArgs;
|
|
9
|
+
};
|
|
10
|
+
export type UpdateMap = {
|
|
11
|
+
toUpdate: Item[];
|
|
12
|
+
updated: Item[];
|
|
13
|
+
};
|
|
14
|
+
export declare function updateMany(args: UpdateArgs, current: Delegate, delegates: Delegates, onChange: (items: Item[]) => void): Item[];
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
import { DMMF } from '@prisma/generator-helper';
|
|
3
|
+
import { Generator } from '@prisma/internals/dist/Generator';
|
|
4
|
+
import { Delegate, DelegateProperties, Item } from './delegate';
|
|
5
|
+
import { PrismockClientType } from './client';
|
|
6
|
+
type Options = {
|
|
7
|
+
schemaPath?: string;
|
|
8
|
+
};
|
|
9
|
+
type OptionsSync = {
|
|
10
|
+
models: DMMF.Model[];
|
|
11
|
+
};
|
|
12
|
+
export type Data = Record<string, Item[]>;
|
|
13
|
+
export type Properties = Record<string, DelegateProperties>;
|
|
14
|
+
export type Delegates = Record<string, Delegate>;
|
|
15
|
+
export declare function generateDMMF(schemaPath?: string): Promise<import("@prisma/generator-helper").ReadonlyDeep<{
|
|
16
|
+
datamodel: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
17
|
+
models: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
18
|
+
name: string;
|
|
19
|
+
dbName: string | null;
|
|
20
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
21
|
+
kind: DMMF.FieldKind;
|
|
22
|
+
name: string;
|
|
23
|
+
isRequired: boolean;
|
|
24
|
+
isList: boolean;
|
|
25
|
+
isUnique: boolean;
|
|
26
|
+
isId: boolean;
|
|
27
|
+
isReadOnly: boolean;
|
|
28
|
+
isGenerated?: boolean | undefined;
|
|
29
|
+
isUpdatedAt?: boolean | undefined;
|
|
30
|
+
type: string;
|
|
31
|
+
dbName?: string | null | undefined;
|
|
32
|
+
hasDefaultValue: boolean;
|
|
33
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
34
|
+
name: string;
|
|
35
|
+
args: any[];
|
|
36
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
37
|
+
relationFromFields?: string[] | undefined;
|
|
38
|
+
relationToFields?: string[] | undefined;
|
|
39
|
+
relationOnDelete?: string | undefined;
|
|
40
|
+
relationName?: string | undefined;
|
|
41
|
+
documentation?: string | undefined;
|
|
42
|
+
}>[];
|
|
43
|
+
uniqueFields: string[][];
|
|
44
|
+
uniqueIndexes: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
45
|
+
name: string;
|
|
46
|
+
fields: string[];
|
|
47
|
+
}>[];
|
|
48
|
+
documentation?: string | undefined;
|
|
49
|
+
primaryKey: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
50
|
+
name: string | null;
|
|
51
|
+
fields: string[];
|
|
52
|
+
}> | null;
|
|
53
|
+
isGenerated?: boolean | undefined;
|
|
54
|
+
}>[];
|
|
55
|
+
enums: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
56
|
+
name: string;
|
|
57
|
+
values: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
58
|
+
name: string;
|
|
59
|
+
dbName: string | null;
|
|
60
|
+
}>[];
|
|
61
|
+
dbName?: string | null | undefined;
|
|
62
|
+
documentation?: string | undefined;
|
|
63
|
+
}>[];
|
|
64
|
+
types: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
65
|
+
name: string;
|
|
66
|
+
dbName: string | null;
|
|
67
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
68
|
+
kind: DMMF.FieldKind;
|
|
69
|
+
name: string;
|
|
70
|
+
isRequired: boolean;
|
|
71
|
+
isList: boolean;
|
|
72
|
+
isUnique: boolean;
|
|
73
|
+
isId: boolean;
|
|
74
|
+
isReadOnly: boolean;
|
|
75
|
+
isGenerated?: boolean | undefined;
|
|
76
|
+
isUpdatedAt?: boolean | undefined;
|
|
77
|
+
type: string;
|
|
78
|
+
dbName?: string | null | undefined;
|
|
79
|
+
hasDefaultValue: boolean;
|
|
80
|
+
default?: DMMF.FieldDefaultScalar[] | import("@prisma/generator-helper").ReadonlyDeep<{
|
|
81
|
+
name: string;
|
|
82
|
+
args: any[];
|
|
83
|
+
}> | DMMF.FieldDefaultScalar | undefined;
|
|
84
|
+
relationFromFields?: string[] | undefined;
|
|
85
|
+
relationToFields?: string[] | undefined;
|
|
86
|
+
relationOnDelete?: string | undefined;
|
|
87
|
+
relationName?: string | undefined;
|
|
88
|
+
documentation?: string | undefined;
|
|
89
|
+
}>[];
|
|
90
|
+
uniqueFields: string[][];
|
|
91
|
+
uniqueIndexes: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
92
|
+
name: string;
|
|
93
|
+
fields: string[];
|
|
94
|
+
}>[];
|
|
95
|
+
documentation?: string | undefined;
|
|
96
|
+
primaryKey: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
97
|
+
name: string | null;
|
|
98
|
+
fields: string[];
|
|
99
|
+
}> | null;
|
|
100
|
+
isGenerated?: boolean | undefined;
|
|
101
|
+
}>[];
|
|
102
|
+
indexes: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
103
|
+
model: string;
|
|
104
|
+
type: DMMF.IndexType;
|
|
105
|
+
isDefinedOnField: boolean;
|
|
106
|
+
name?: string | undefined;
|
|
107
|
+
dbName?: string | undefined;
|
|
108
|
+
algorithm?: string | undefined;
|
|
109
|
+
clustered?: boolean | undefined;
|
|
110
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
111
|
+
name: string;
|
|
112
|
+
sortOrder?: DMMF.SortOrder | undefined;
|
|
113
|
+
length?: number | undefined;
|
|
114
|
+
operatorClass?: string | undefined;
|
|
115
|
+
}>[];
|
|
116
|
+
}>[];
|
|
117
|
+
}>;
|
|
118
|
+
schema: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
119
|
+
rootQueryType?: string | undefined;
|
|
120
|
+
rootMutationType?: string | undefined;
|
|
121
|
+
inputObjectTypes: {
|
|
122
|
+
model?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
123
|
+
name: string;
|
|
124
|
+
constraints: {
|
|
125
|
+
maxNumFields: number | null;
|
|
126
|
+
minNumFields: number | null;
|
|
127
|
+
fields?: string[] | undefined;
|
|
128
|
+
};
|
|
129
|
+
meta?: {
|
|
130
|
+
source?: string | undefined;
|
|
131
|
+
} | undefined;
|
|
132
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
133
|
+
name: string;
|
|
134
|
+
comment?: string | undefined;
|
|
135
|
+
isNullable: boolean;
|
|
136
|
+
isRequired: boolean;
|
|
137
|
+
inputTypes: DMMF.InputTypeRef[];
|
|
138
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
139
|
+
sinceVersion: string;
|
|
140
|
+
reason: string;
|
|
141
|
+
plannedRemovalVersion?: string | undefined;
|
|
142
|
+
}> | undefined;
|
|
143
|
+
}>[];
|
|
144
|
+
}>[] | undefined;
|
|
145
|
+
prisma: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
146
|
+
name: string;
|
|
147
|
+
constraints: {
|
|
148
|
+
maxNumFields: number | null;
|
|
149
|
+
minNumFields: number | null;
|
|
150
|
+
fields?: string[] | undefined;
|
|
151
|
+
};
|
|
152
|
+
meta?: {
|
|
153
|
+
source?: string | undefined;
|
|
154
|
+
} | undefined;
|
|
155
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
156
|
+
name: string;
|
|
157
|
+
comment?: string | undefined;
|
|
158
|
+
isNullable: boolean;
|
|
159
|
+
isRequired: boolean;
|
|
160
|
+
inputTypes: DMMF.InputTypeRef[];
|
|
161
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
162
|
+
sinceVersion: string;
|
|
163
|
+
reason: string;
|
|
164
|
+
plannedRemovalVersion?: string | undefined;
|
|
165
|
+
}> | undefined;
|
|
166
|
+
}>[];
|
|
167
|
+
}>[];
|
|
168
|
+
};
|
|
169
|
+
outputObjectTypes: {
|
|
170
|
+
model: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
171
|
+
name: string;
|
|
172
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
173
|
+
name: string;
|
|
174
|
+
isNullable?: boolean | undefined;
|
|
175
|
+
outputType: DMMF.OutputTypeRef;
|
|
176
|
+
args: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
177
|
+
name: string;
|
|
178
|
+
comment?: string | undefined;
|
|
179
|
+
isNullable: boolean;
|
|
180
|
+
isRequired: boolean;
|
|
181
|
+
inputTypes: DMMF.InputTypeRef[];
|
|
182
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
183
|
+
sinceVersion: string;
|
|
184
|
+
reason: string;
|
|
185
|
+
plannedRemovalVersion?: string | undefined;
|
|
186
|
+
}> | undefined;
|
|
187
|
+
}>[];
|
|
188
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
189
|
+
sinceVersion: string;
|
|
190
|
+
reason: string;
|
|
191
|
+
plannedRemovalVersion?: string | undefined;
|
|
192
|
+
}> | undefined;
|
|
193
|
+
documentation?: string | undefined;
|
|
194
|
+
}>[];
|
|
195
|
+
}>[];
|
|
196
|
+
prisma: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
197
|
+
name: string;
|
|
198
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
199
|
+
name: string;
|
|
200
|
+
isNullable?: boolean | undefined;
|
|
201
|
+
outputType: DMMF.OutputTypeRef;
|
|
202
|
+
args: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
203
|
+
name: string;
|
|
204
|
+
comment?: string | undefined;
|
|
205
|
+
isNullable: boolean;
|
|
206
|
+
isRequired: boolean;
|
|
207
|
+
inputTypes: DMMF.InputTypeRef[];
|
|
208
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
209
|
+
sinceVersion: string;
|
|
210
|
+
reason: string;
|
|
211
|
+
plannedRemovalVersion?: string | undefined;
|
|
212
|
+
}> | undefined;
|
|
213
|
+
}>[];
|
|
214
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
215
|
+
sinceVersion: string;
|
|
216
|
+
reason: string;
|
|
217
|
+
plannedRemovalVersion?: string | undefined;
|
|
218
|
+
}> | undefined;
|
|
219
|
+
documentation?: string | undefined;
|
|
220
|
+
}>[];
|
|
221
|
+
}>[];
|
|
222
|
+
};
|
|
223
|
+
enumTypes: {
|
|
224
|
+
model?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
225
|
+
name: string;
|
|
226
|
+
values: string[];
|
|
227
|
+
}>[] | undefined;
|
|
228
|
+
prisma: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
229
|
+
name: string;
|
|
230
|
+
values: string[];
|
|
231
|
+
}>[];
|
|
232
|
+
};
|
|
233
|
+
fieldRefTypes: {
|
|
234
|
+
prisma?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
235
|
+
name: string;
|
|
236
|
+
allowTypes: DMMF.FieldRefAllowType[];
|
|
237
|
+
fields: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
238
|
+
name: string;
|
|
239
|
+
comment?: string | undefined;
|
|
240
|
+
isNullable: boolean;
|
|
241
|
+
isRequired: boolean;
|
|
242
|
+
inputTypes: DMMF.InputTypeRef[];
|
|
243
|
+
deprecation?: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
244
|
+
sinceVersion: string;
|
|
245
|
+
reason: string;
|
|
246
|
+
plannedRemovalVersion?: string | undefined;
|
|
247
|
+
}> | undefined;
|
|
248
|
+
}>[];
|
|
249
|
+
}>[] | undefined;
|
|
250
|
+
};
|
|
251
|
+
}>;
|
|
252
|
+
mappings: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
253
|
+
modelOperations: import("@prisma/generator-helper").ReadonlyDeep<{
|
|
254
|
+
model: string;
|
|
255
|
+
plural: string;
|
|
256
|
+
findUnique?: string | null | undefined;
|
|
257
|
+
findUniqueOrThrow?: string | null | undefined;
|
|
258
|
+
findFirst?: string | null | undefined;
|
|
259
|
+
findFirstOrThrow?: string | null | undefined;
|
|
260
|
+
findMany?: string | null | undefined;
|
|
261
|
+
create?: string | null | undefined;
|
|
262
|
+
createMany?: string | null | undefined;
|
|
263
|
+
createManyAndReturn?: string | null | undefined;
|
|
264
|
+
update?: string | null | undefined;
|
|
265
|
+
updateMany?: string | null | undefined;
|
|
266
|
+
upsert?: string | null | undefined;
|
|
267
|
+
delete?: string | null | undefined;
|
|
268
|
+
deleteMany?: string | null | undefined;
|
|
269
|
+
aggregate?: string | null | undefined;
|
|
270
|
+
groupBy?: string | null | undefined;
|
|
271
|
+
count?: string | null | undefined;
|
|
272
|
+
findRaw?: string | null | undefined;
|
|
273
|
+
aggregateRaw?: string | null | undefined;
|
|
274
|
+
}>[];
|
|
275
|
+
otherOperations: {
|
|
276
|
+
read: string[];
|
|
277
|
+
write: string[];
|
|
278
|
+
};
|
|
279
|
+
}>;
|
|
280
|
+
}>>;
|
|
281
|
+
export declare function fetchGenerator(schemaPath?: string): Promise<Generator>;
|
|
282
|
+
export declare function getProvider(generator: Generator): import("@prisma/generator-helper").ActiveConnectorType | undefined;
|
|
283
|
+
export declare function generatePrismock<T = PrismaClient>(options?: Options): Promise<PrismockClientType<T>>;
|
|
284
|
+
export declare function generatePrismockSync<T = PrismockClientType>(options: OptionsSync): PrismockClientType<T>;
|
|
285
|
+
export declare function generateDelegates(options: OptionsSync): {
|
|
286
|
+
delegates: Delegates;
|
|
287
|
+
getData: () => Data;
|
|
288
|
+
setData: (d: Data) => void;
|
|
289
|
+
};
|
|
290
|
+
export {};
|