prisma-flare 1.0.0
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/dist/cli/db-create.cjs +240 -0
- package/dist/cli/db-create.d.cts +1 -0
- package/dist/cli/db-create.d.ts +1 -0
- package/dist/cli/db-create.js +217 -0
- package/dist/cli/db-drop.cjs +263 -0
- package/dist/cli/db-drop.d.cts +1 -0
- package/dist/cli/db-drop.d.ts +1 -0
- package/dist/cli/db-drop.js +240 -0
- package/dist/cli/db-migrate.cjs +318 -0
- package/dist/cli/db-migrate.d.cts +1 -0
- package/dist/cli/db-migrate.d.ts +1 -0
- package/dist/cli/db-migrate.js +295 -0
- package/dist/cli/db-reset.cjs +110 -0
- package/dist/cli/db-reset.d.cts +1 -0
- package/dist/cli/db-reset.d.ts +1 -0
- package/dist/cli/db-reset.js +87 -0
- package/dist/cli/db-seed.cjs +87 -0
- package/dist/cli/db-seed.d.cts +1 -0
- package/dist/cli/db-seed.d.ts +1 -0
- package/dist/cli/db-seed.js +64 -0
- package/dist/cli/index.cjs +352 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +328 -0
- package/dist/core/flareBuilder.cjs +681 -0
- package/dist/core/flareBuilder.d.cts +402 -0
- package/dist/core/flareBuilder.d.ts +402 -0
- package/dist/core/flareBuilder.js +658 -0
- package/dist/core/hooks.cjs +243 -0
- package/dist/core/hooks.d.cts +13 -0
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/hooks.js +209 -0
- package/dist/generated.cjs +31 -0
- package/dist/generated.d.cts +4 -0
- package/dist/generated.d.ts +4 -0
- package/dist/generated.js +6 -0
- package/dist/index.cjs +1315 -0
- package/dist/index.d.cts +237 -0
- package/dist/index.d.ts +237 -0
- package/dist/index.js +1261 -0
- package/dist/prisma.types-nGNe1CG8.d.cts +201 -0
- package/dist/prisma.types-nGNe1CG8.d.ts +201 -0
- package/license.md +21 -0
- package/package.json +115 -0
- package/readme.md +957 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract model names from PrismaClient
|
|
5
|
+
* Note: $use was removed in Prisma 7, but we keep it here for backwards compatibility
|
|
6
|
+
*/
|
|
7
|
+
type RawPrismaClientKeys = Exclude<Extract<keyof PrismaClient, string>, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use' | '$extends' | '$executeRaw' | '$executeRawUnsafe' | '$queryRaw' | '$queryRawUnsafe'>;
|
|
8
|
+
/**
|
|
9
|
+
* Extract model names from PrismaClient (lowercase only, matching Prisma client delegates)
|
|
10
|
+
*/
|
|
11
|
+
type ModelName = [RawPrismaClientKeys] extends [never] ? string : RawPrismaClientKeys;
|
|
12
|
+
/**
|
|
13
|
+
* Extract the delegate type for a given model
|
|
14
|
+
*/
|
|
15
|
+
type ModelDelegate<T extends ModelName> = Uncapitalize<T> extends keyof PrismaClient ? PrismaClient[Uncapitalize<T>] : any;
|
|
16
|
+
/**
|
|
17
|
+
* Get the proper Prisma args type for a model operation
|
|
18
|
+
*/
|
|
19
|
+
type PrismaArgs<T extends ModelName, A extends keyof ModelDelegate<T>> = ModelDelegate<T>[A] extends (args: infer Args) => any ? Args : ModelDelegate<T>[A] extends (args?: infer Args) => any ? Args : never;
|
|
20
|
+
/**
|
|
21
|
+
* Extract the record type for a given model
|
|
22
|
+
*/
|
|
23
|
+
type RecordType<T extends ModelName> = NonNullable<Awaited<ReturnType<ModelDelegate<T>['findFirst']>>>;
|
|
24
|
+
/**
|
|
25
|
+
* Extract FindMany args type for a given model
|
|
26
|
+
*/
|
|
27
|
+
type FindManyArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'findMany'>>;
|
|
28
|
+
/**
|
|
29
|
+
* Extract FindFirst args type for a given model
|
|
30
|
+
*/
|
|
31
|
+
type FindFirstArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'findFirst'>>;
|
|
32
|
+
/**
|
|
33
|
+
* Helper to make where clause optional
|
|
34
|
+
*/
|
|
35
|
+
type OptionalWhere<T> = T extends {
|
|
36
|
+
where: any;
|
|
37
|
+
} ? Omit<T, 'where'> & {
|
|
38
|
+
where?: T['where'];
|
|
39
|
+
} : T;
|
|
40
|
+
/**
|
|
41
|
+
* Extract Create args type for a given model
|
|
42
|
+
*/
|
|
43
|
+
type CreateArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'create'>>;
|
|
44
|
+
/**
|
|
45
|
+
* Extract Create data type for a given model
|
|
46
|
+
*/
|
|
47
|
+
type CreateData<T extends ModelName> = NonNullable<PrismaArgs<T, 'create'>> extends {
|
|
48
|
+
data: infer D;
|
|
49
|
+
} ? D : never;
|
|
50
|
+
/**
|
|
51
|
+
* Extract CreateMany args type for a given model
|
|
52
|
+
*/
|
|
53
|
+
type CreateManyArgs<T extends ModelName> = 'createMany' extends keyof ModelDelegate<T> ? NonNullable<PrismaArgs<T, 'createMany'>> : never;
|
|
54
|
+
/**
|
|
55
|
+
* Extract CreateMany data type for a given model
|
|
56
|
+
*/
|
|
57
|
+
type CreateManyData<T extends ModelName> = 'createMany' extends keyof ModelDelegate<T> ? NonNullable<PrismaArgs<T, 'createMany'>> extends {
|
|
58
|
+
data: infer D;
|
|
59
|
+
} ? D : never : never;
|
|
60
|
+
/**
|
|
61
|
+
* Extract Update args type for a given model
|
|
62
|
+
*/
|
|
63
|
+
type UpdateArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'update'>>>;
|
|
64
|
+
/**
|
|
65
|
+
* Extract Update data type for a given model
|
|
66
|
+
*/
|
|
67
|
+
type UpdateData<T extends ModelName> = NonNullable<PrismaArgs<T, 'update'>> extends {
|
|
68
|
+
data: infer D;
|
|
69
|
+
} ? D : never;
|
|
70
|
+
/**
|
|
71
|
+
* Extract UpdateMany data type for a given model
|
|
72
|
+
*/
|
|
73
|
+
type UpdateManyData<T extends ModelName> = NonNullable<PrismaArgs<T, 'updateMany'>> extends {
|
|
74
|
+
data: infer D;
|
|
75
|
+
} ? D : never;
|
|
76
|
+
/**
|
|
77
|
+
* Extract Delete args type for a given model
|
|
78
|
+
*/
|
|
79
|
+
type DeleteArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'delete'>>>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract DeleteMany args type for a given model
|
|
82
|
+
*/
|
|
83
|
+
type DeleteManyArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'deleteMany'>>;
|
|
84
|
+
/**
|
|
85
|
+
* Extract Upsert args type for a given model
|
|
86
|
+
*/
|
|
87
|
+
type UpsertArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'upsert'>>>;
|
|
88
|
+
/**
|
|
89
|
+
* Extract Where input type
|
|
90
|
+
*/
|
|
91
|
+
type WhereInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
92
|
+
where?: infer W;
|
|
93
|
+
} ? W : never;
|
|
94
|
+
/**
|
|
95
|
+
* Extract OrderBy input type
|
|
96
|
+
*/
|
|
97
|
+
type OrderByInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
98
|
+
orderBy?: infer O;
|
|
99
|
+
} ? O : never;
|
|
100
|
+
/**
|
|
101
|
+
* Extract Select input type
|
|
102
|
+
*/
|
|
103
|
+
type SelectInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
104
|
+
select?: infer S;
|
|
105
|
+
} ? S : never;
|
|
106
|
+
/**
|
|
107
|
+
* Extract Include input type
|
|
108
|
+
*/
|
|
109
|
+
type IncludeInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
110
|
+
include?: infer I;
|
|
111
|
+
} ? I : never;
|
|
112
|
+
type IncludeMap<T extends ModelName> = string extends T ? any : NonNullable<IncludeInput<T>>;
|
|
113
|
+
type IncludeKey<T extends ModelName> = string extends T ? string : (keyof IncludeMap<T> & string);
|
|
114
|
+
/**
|
|
115
|
+
* Extract Distinct input type
|
|
116
|
+
*/
|
|
117
|
+
type DistinctInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
118
|
+
distinct?: infer D;
|
|
119
|
+
} ? D : never;
|
|
120
|
+
/**
|
|
121
|
+
* Extract GroupBy args type
|
|
122
|
+
*/
|
|
123
|
+
type GroupByArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'groupBy'>>;
|
|
124
|
+
/**
|
|
125
|
+
* Extract GroupBy input type
|
|
126
|
+
*/
|
|
127
|
+
type GroupByInput<T extends ModelName> = GroupByArgs<T> extends {
|
|
128
|
+
by: infer B;
|
|
129
|
+
} ? B : never;
|
|
130
|
+
/**
|
|
131
|
+
* Extract Having input type
|
|
132
|
+
*/
|
|
133
|
+
type HavingInput<T extends ModelName> = GroupByArgs<T> extends {
|
|
134
|
+
having?: infer H;
|
|
135
|
+
} ? H : never;
|
|
136
|
+
/**
|
|
137
|
+
* Extract Aggregate args type
|
|
138
|
+
*/
|
|
139
|
+
type AggregateArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'aggregate'>>;
|
|
140
|
+
type SumFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
141
|
+
_sum?: infer S;
|
|
142
|
+
} ? keyof S : string;
|
|
143
|
+
type AvgFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
144
|
+
_avg?: infer A;
|
|
145
|
+
} ? keyof A : string;
|
|
146
|
+
type MinFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
147
|
+
_min?: infer M;
|
|
148
|
+
} ? keyof M : string;
|
|
149
|
+
type MaxFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
150
|
+
_max?: infer M;
|
|
151
|
+
} ? keyof M : string;
|
|
152
|
+
/**
|
|
153
|
+
* Hook timing - before or after operation
|
|
154
|
+
*/
|
|
155
|
+
type HookTiming = 'before' | 'after';
|
|
156
|
+
/**
|
|
157
|
+
* Prisma operation types
|
|
158
|
+
*/
|
|
159
|
+
type PrismaOperation = 'create' | 'update' | 'updateMany' | 'delete' | 'deleteMany' | 'upsert' | 'findFirst' | 'findMany' | 'findUnique';
|
|
160
|
+
/**
|
|
161
|
+
* Callback function for before hooks
|
|
162
|
+
*/
|
|
163
|
+
type BeforeHookCallback<_T extends ModelName = ModelName> = (args: any, prisma: PrismaClient) => Promise<void> | void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback function for after hooks
|
|
166
|
+
*/
|
|
167
|
+
type AfterHookCallback<_T extends ModelName = ModelName> = (args: any, result: any, prisma: PrismaClient) => Promise<void> | void;
|
|
168
|
+
/**
|
|
169
|
+
* Callback function for column change hooks
|
|
170
|
+
*/
|
|
171
|
+
type ColumnChangeCallback<T extends ModelName = ModelName> = (oldValue: any, newValue: any, record: NonNullable<RecordType<T>>, prisma: PrismaClient) => Promise<void> | void;
|
|
172
|
+
/**
|
|
173
|
+
* Query builder aggregation result types
|
|
174
|
+
*/
|
|
175
|
+
interface AggregateResult {
|
|
176
|
+
_sum: Record<string, number | null>;
|
|
177
|
+
_avg: Record<string, number | null>;
|
|
178
|
+
_min: Record<string, any>;
|
|
179
|
+
_max: Record<string, any>;
|
|
180
|
+
_count: Record<string, number>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Generic query arguments
|
|
184
|
+
*/
|
|
185
|
+
type QueryArgs = Record<string, any>;
|
|
186
|
+
/**
|
|
187
|
+
* Paginated result interface
|
|
188
|
+
*/
|
|
189
|
+
interface PaginatedResult<T> {
|
|
190
|
+
data: T[];
|
|
191
|
+
meta: {
|
|
192
|
+
total: number;
|
|
193
|
+
lastPage: number;
|
|
194
|
+
currentPage: number;
|
|
195
|
+
perPage: number;
|
|
196
|
+
prev: number | null;
|
|
197
|
+
next: number | null;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export type { AvgFields as A, BeforeHookCallback as B, CreateData as C, DistinctInput as D, FindManyArgs as F, GroupByInput as G, HavingInput as H, IncludeKey as I, ModelName as M, OrderByInput as O, PaginatedResult as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ModelDelegate as a, CreateManyData as b, DeleteArgs as c, DeleteManyArgs as d, UpdateManyData as e, UpsertArgs as f, SumFields as g, MinFields as h, MaxFields as i, AfterHookCallback as j, ColumnChangeCallback as k, PrismaOperation as l, HookTiming as m, FindFirstArgs as n, CreateArgs as o, CreateManyArgs as p, UpdateArgs as q, AggregateResult as r };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extract model names from PrismaClient
|
|
5
|
+
* Note: $use was removed in Prisma 7, but we keep it here for backwards compatibility
|
|
6
|
+
*/
|
|
7
|
+
type RawPrismaClientKeys = Exclude<Extract<keyof PrismaClient, string>, '$connect' | '$disconnect' | '$on' | '$transaction' | '$use' | '$extends' | '$executeRaw' | '$executeRawUnsafe' | '$queryRaw' | '$queryRawUnsafe'>;
|
|
8
|
+
/**
|
|
9
|
+
* Extract model names from PrismaClient (lowercase only, matching Prisma client delegates)
|
|
10
|
+
*/
|
|
11
|
+
type ModelName = [RawPrismaClientKeys] extends [never] ? string : RawPrismaClientKeys;
|
|
12
|
+
/**
|
|
13
|
+
* Extract the delegate type for a given model
|
|
14
|
+
*/
|
|
15
|
+
type ModelDelegate<T extends ModelName> = Uncapitalize<T> extends keyof PrismaClient ? PrismaClient[Uncapitalize<T>] : any;
|
|
16
|
+
/**
|
|
17
|
+
* Get the proper Prisma args type for a model operation
|
|
18
|
+
*/
|
|
19
|
+
type PrismaArgs<T extends ModelName, A extends keyof ModelDelegate<T>> = ModelDelegate<T>[A] extends (args: infer Args) => any ? Args : ModelDelegate<T>[A] extends (args?: infer Args) => any ? Args : never;
|
|
20
|
+
/**
|
|
21
|
+
* Extract the record type for a given model
|
|
22
|
+
*/
|
|
23
|
+
type RecordType<T extends ModelName> = NonNullable<Awaited<ReturnType<ModelDelegate<T>['findFirst']>>>;
|
|
24
|
+
/**
|
|
25
|
+
* Extract FindMany args type for a given model
|
|
26
|
+
*/
|
|
27
|
+
type FindManyArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'findMany'>>;
|
|
28
|
+
/**
|
|
29
|
+
* Extract FindFirst args type for a given model
|
|
30
|
+
*/
|
|
31
|
+
type FindFirstArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'findFirst'>>;
|
|
32
|
+
/**
|
|
33
|
+
* Helper to make where clause optional
|
|
34
|
+
*/
|
|
35
|
+
type OptionalWhere<T> = T extends {
|
|
36
|
+
where: any;
|
|
37
|
+
} ? Omit<T, 'where'> & {
|
|
38
|
+
where?: T['where'];
|
|
39
|
+
} : T;
|
|
40
|
+
/**
|
|
41
|
+
* Extract Create args type for a given model
|
|
42
|
+
*/
|
|
43
|
+
type CreateArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'create'>>;
|
|
44
|
+
/**
|
|
45
|
+
* Extract Create data type for a given model
|
|
46
|
+
*/
|
|
47
|
+
type CreateData<T extends ModelName> = NonNullable<PrismaArgs<T, 'create'>> extends {
|
|
48
|
+
data: infer D;
|
|
49
|
+
} ? D : never;
|
|
50
|
+
/**
|
|
51
|
+
* Extract CreateMany args type for a given model
|
|
52
|
+
*/
|
|
53
|
+
type CreateManyArgs<T extends ModelName> = 'createMany' extends keyof ModelDelegate<T> ? NonNullable<PrismaArgs<T, 'createMany'>> : never;
|
|
54
|
+
/**
|
|
55
|
+
* Extract CreateMany data type for a given model
|
|
56
|
+
*/
|
|
57
|
+
type CreateManyData<T extends ModelName> = 'createMany' extends keyof ModelDelegate<T> ? NonNullable<PrismaArgs<T, 'createMany'>> extends {
|
|
58
|
+
data: infer D;
|
|
59
|
+
} ? D : never : never;
|
|
60
|
+
/**
|
|
61
|
+
* Extract Update args type for a given model
|
|
62
|
+
*/
|
|
63
|
+
type UpdateArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'update'>>>;
|
|
64
|
+
/**
|
|
65
|
+
* Extract Update data type for a given model
|
|
66
|
+
*/
|
|
67
|
+
type UpdateData<T extends ModelName> = NonNullable<PrismaArgs<T, 'update'>> extends {
|
|
68
|
+
data: infer D;
|
|
69
|
+
} ? D : never;
|
|
70
|
+
/**
|
|
71
|
+
* Extract UpdateMany data type for a given model
|
|
72
|
+
*/
|
|
73
|
+
type UpdateManyData<T extends ModelName> = NonNullable<PrismaArgs<T, 'updateMany'>> extends {
|
|
74
|
+
data: infer D;
|
|
75
|
+
} ? D : never;
|
|
76
|
+
/**
|
|
77
|
+
* Extract Delete args type for a given model
|
|
78
|
+
*/
|
|
79
|
+
type DeleteArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'delete'>>>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract DeleteMany args type for a given model
|
|
82
|
+
*/
|
|
83
|
+
type DeleteManyArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'deleteMany'>>;
|
|
84
|
+
/**
|
|
85
|
+
* Extract Upsert args type for a given model
|
|
86
|
+
*/
|
|
87
|
+
type UpsertArgs<T extends ModelName> = OptionalWhere<NonNullable<PrismaArgs<T, 'upsert'>>>;
|
|
88
|
+
/**
|
|
89
|
+
* Extract Where input type
|
|
90
|
+
*/
|
|
91
|
+
type WhereInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
92
|
+
where?: infer W;
|
|
93
|
+
} ? W : never;
|
|
94
|
+
/**
|
|
95
|
+
* Extract OrderBy input type
|
|
96
|
+
*/
|
|
97
|
+
type OrderByInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
98
|
+
orderBy?: infer O;
|
|
99
|
+
} ? O : never;
|
|
100
|
+
/**
|
|
101
|
+
* Extract Select input type
|
|
102
|
+
*/
|
|
103
|
+
type SelectInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
104
|
+
select?: infer S;
|
|
105
|
+
} ? S : never;
|
|
106
|
+
/**
|
|
107
|
+
* Extract Include input type
|
|
108
|
+
*/
|
|
109
|
+
type IncludeInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
110
|
+
include?: infer I;
|
|
111
|
+
} ? I : never;
|
|
112
|
+
type IncludeMap<T extends ModelName> = string extends T ? any : NonNullable<IncludeInput<T>>;
|
|
113
|
+
type IncludeKey<T extends ModelName> = string extends T ? string : (keyof IncludeMap<T> & string);
|
|
114
|
+
/**
|
|
115
|
+
* Extract Distinct input type
|
|
116
|
+
*/
|
|
117
|
+
type DistinctInput<T extends ModelName> = FindManyArgs<T> extends {
|
|
118
|
+
distinct?: infer D;
|
|
119
|
+
} ? D : never;
|
|
120
|
+
/**
|
|
121
|
+
* Extract GroupBy args type
|
|
122
|
+
*/
|
|
123
|
+
type GroupByArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'groupBy'>>;
|
|
124
|
+
/**
|
|
125
|
+
* Extract GroupBy input type
|
|
126
|
+
*/
|
|
127
|
+
type GroupByInput<T extends ModelName> = GroupByArgs<T> extends {
|
|
128
|
+
by: infer B;
|
|
129
|
+
} ? B : never;
|
|
130
|
+
/**
|
|
131
|
+
* Extract Having input type
|
|
132
|
+
*/
|
|
133
|
+
type HavingInput<T extends ModelName> = GroupByArgs<T> extends {
|
|
134
|
+
having?: infer H;
|
|
135
|
+
} ? H : never;
|
|
136
|
+
/**
|
|
137
|
+
* Extract Aggregate args type
|
|
138
|
+
*/
|
|
139
|
+
type AggregateArgs<T extends ModelName> = NonNullable<PrismaArgs<T, 'aggregate'>>;
|
|
140
|
+
type SumFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
141
|
+
_sum?: infer S;
|
|
142
|
+
} ? keyof S : string;
|
|
143
|
+
type AvgFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
144
|
+
_avg?: infer A;
|
|
145
|
+
} ? keyof A : string;
|
|
146
|
+
type MinFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
147
|
+
_min?: infer M;
|
|
148
|
+
} ? keyof M : string;
|
|
149
|
+
type MaxFields<T extends ModelName> = AggregateArgs<T> extends {
|
|
150
|
+
_max?: infer M;
|
|
151
|
+
} ? keyof M : string;
|
|
152
|
+
/**
|
|
153
|
+
* Hook timing - before or after operation
|
|
154
|
+
*/
|
|
155
|
+
type HookTiming = 'before' | 'after';
|
|
156
|
+
/**
|
|
157
|
+
* Prisma operation types
|
|
158
|
+
*/
|
|
159
|
+
type PrismaOperation = 'create' | 'update' | 'updateMany' | 'delete' | 'deleteMany' | 'upsert' | 'findFirst' | 'findMany' | 'findUnique';
|
|
160
|
+
/**
|
|
161
|
+
* Callback function for before hooks
|
|
162
|
+
*/
|
|
163
|
+
type BeforeHookCallback<_T extends ModelName = ModelName> = (args: any, prisma: PrismaClient) => Promise<void> | void;
|
|
164
|
+
/**
|
|
165
|
+
* Callback function for after hooks
|
|
166
|
+
*/
|
|
167
|
+
type AfterHookCallback<_T extends ModelName = ModelName> = (args: any, result: any, prisma: PrismaClient) => Promise<void> | void;
|
|
168
|
+
/**
|
|
169
|
+
* Callback function for column change hooks
|
|
170
|
+
*/
|
|
171
|
+
type ColumnChangeCallback<T extends ModelName = ModelName> = (oldValue: any, newValue: any, record: NonNullable<RecordType<T>>, prisma: PrismaClient) => Promise<void> | void;
|
|
172
|
+
/**
|
|
173
|
+
* Query builder aggregation result types
|
|
174
|
+
*/
|
|
175
|
+
interface AggregateResult {
|
|
176
|
+
_sum: Record<string, number | null>;
|
|
177
|
+
_avg: Record<string, number | null>;
|
|
178
|
+
_min: Record<string, any>;
|
|
179
|
+
_max: Record<string, any>;
|
|
180
|
+
_count: Record<string, number>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Generic query arguments
|
|
184
|
+
*/
|
|
185
|
+
type QueryArgs = Record<string, any>;
|
|
186
|
+
/**
|
|
187
|
+
* Paginated result interface
|
|
188
|
+
*/
|
|
189
|
+
interface PaginatedResult<T> {
|
|
190
|
+
data: T[];
|
|
191
|
+
meta: {
|
|
192
|
+
total: number;
|
|
193
|
+
lastPage: number;
|
|
194
|
+
currentPage: number;
|
|
195
|
+
perPage: number;
|
|
196
|
+
prev: number | null;
|
|
197
|
+
next: number | null;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export type { AvgFields as A, BeforeHookCallback as B, CreateData as C, DistinctInput as D, FindManyArgs as F, GroupByInput as G, HavingInput as H, IncludeKey as I, ModelName as M, OrderByInput as O, PaginatedResult as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ModelDelegate as a, CreateManyData as b, DeleteArgs as c, DeleteManyArgs as d, UpdateManyData as e, UpsertArgs as f, SumFields as g, MinFields as h, MaxFields as i, AfterHookCallback as j, ColumnChangeCallback as k, PrismaOperation as l, HookTiming as m, FindFirstArgs as n, CreateArgs as o, CreateManyArgs as p, UpdateArgs as q, AggregateResult as r };
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fabrizio Spadaro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prisma-flare",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Prisma utilities package with callback system and query builder for chained operations",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"dev": "tsup --watch",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"lint": "eslint src --ext .ts",
|
|
15
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
16
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
17
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
18
|
+
"test": "tsx scripts/setup-test-project.ts && cd tests/test-project && npm test",
|
|
19
|
+
"test:e2e": "npm run test",
|
|
20
|
+
"test:all": "npm run test",
|
|
21
|
+
"test:watch": "vitest -c vitest.integration.config.ts",
|
|
22
|
+
"test:ui": "vitest --ui",
|
|
23
|
+
"test:coverage": "vitest run --coverage",
|
|
24
|
+
"create": "tsx src/cli/db-create.ts",
|
|
25
|
+
"drop": "tsx src/cli/db-drop.ts",
|
|
26
|
+
"migrate": "tsx src/cli/db-migrate.ts",
|
|
27
|
+
"reset": "tsx src/cli/db-reset.ts",
|
|
28
|
+
"seed": "tsx src/cli/db-seed.ts"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"prisma",
|
|
32
|
+
"orm",
|
|
33
|
+
"utilities",
|
|
34
|
+
"callbacks",
|
|
35
|
+
"query-builder",
|
|
36
|
+
"middleware",
|
|
37
|
+
"hooks",
|
|
38
|
+
"typescript"
|
|
39
|
+
],
|
|
40
|
+
"author": "Fabrizio Spadaro",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"bin": {
|
|
43
|
+
"prisma-flare": "./dist/cli/index.js"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@prisma/client": ">=5.18.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependenciesMeta": {
|
|
49
|
+
"@prisma/client": {
|
|
50
|
+
"optional": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"pg": "^8.16.3",
|
|
55
|
+
"pluralize": "^8.0.0",
|
|
56
|
+
"dotenv": "^17.2.3"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@prisma/client": "^5.18.0",
|
|
60
|
+
"prisma": "^5.18.0",
|
|
61
|
+
"@types/node": "^20.19.25",
|
|
62
|
+
"@types/pg": "^8.15.6",
|
|
63
|
+
"@types/pluralize": "^0.0.33",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
65
|
+
"@typescript-eslint/parser": "^8.49.0",
|
|
66
|
+
"@vitest/ui": "^4.0.15",
|
|
67
|
+
"eslint": "^9.39.1",
|
|
68
|
+
"eslint-config-prettier": "^10.1.8",
|
|
69
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
70
|
+
"prettier": "^3.7.4",
|
|
71
|
+
"tsup": "^8.5.1",
|
|
72
|
+
"tsx": "^4.21.0",
|
|
73
|
+
"typescript": "^5.9.3",
|
|
74
|
+
"vitest": "^4.0.15"
|
|
75
|
+
},
|
|
76
|
+
"exports": {
|
|
77
|
+
".": {
|
|
78
|
+
"types": "./dist/index.d.ts",
|
|
79
|
+
"import": "./dist/index.js",
|
|
80
|
+
"require": "./dist/index.cjs"
|
|
81
|
+
},
|
|
82
|
+
"./generated": {
|
|
83
|
+
"types": "./dist/generated.d.ts",
|
|
84
|
+
"import": "./dist/generated.js",
|
|
85
|
+
"require": "./dist/generated.cjs"
|
|
86
|
+
},
|
|
87
|
+
"./flareBuilder": {
|
|
88
|
+
"types": "./dist/core/flareBuilder.d.ts",
|
|
89
|
+
"import": "./dist/core/flareBuilder.js",
|
|
90
|
+
"require": "./dist/core/flareBuilder.cjs"
|
|
91
|
+
},
|
|
92
|
+
"./hooks": {
|
|
93
|
+
"types": "./dist/core/hooks.d.ts",
|
|
94
|
+
"import": "./dist/core/hooks.js",
|
|
95
|
+
"require": "./dist/core/hooks.cjs"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"typesVersions": {
|
|
99
|
+
"*": {
|
|
100
|
+
"generated": [
|
|
101
|
+
"./dist/generated.d.ts"
|
|
102
|
+
],
|
|
103
|
+
"flareBuilder": [
|
|
104
|
+
"./dist/core/flareBuilder.d.ts"
|
|
105
|
+
],
|
|
106
|
+
"hooks": [
|
|
107
|
+
"./dist/core/hooks.d.ts"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"files": [
|
|
112
|
+
"dist",
|
|
113
|
+
"README.md"
|
|
114
|
+
]
|
|
115
|
+
}
|