suparisma 1.0.0 → 1.0.2

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.
@@ -1,394 +0,0 @@
1
- // THIS FILE IS AUTO-GENERATED - DO NOT EDIT DIRECTLY
2
- // Edit the generator script instead
3
-
4
- import type { Thing } from '@prisma/client';
5
- import type { ModelResult, SuparismaOptions, SearchQuery, SearchState } from '../utils/core';
6
-
7
- /**
8
- * Extended Thing type that includes relation fields.
9
- * This represents the complete shape of Thing records returned from the database.
10
- */
11
- export interface ThingWithRelations {
12
- id: string;
13
- name?: string;
14
- someEnum: string;
15
- someNumber?: number;
16
- createdAt: string;
17
- updatedAt: string;
18
- }
19
-
20
- /**
21
- * Input type for creating a new Thing record.
22
- * Fields with default values are optional and will be filled automatically if not provided.
23
- *
24
- * @example
25
- * // Create a minimal thing
26
- * thing.create({
27
- * // Required fields only
28
-
29
- * });
30
- *
31
- * @example
32
- * // Create with optional fields
33
- * thing.create({
34
- * // All fields including optional ones
35
- * id?: string,
36
- * name?: string,
37
- * someEnum?: string,
38
- * });
39
- */
40
- export interface ThingCreateInput {
41
- id?: string;
42
- name?: string;
43
- someEnum?: string;
44
- someNumber?: number;
45
- }
46
-
47
- /**
48
- * Input type for updating an existing Thing record.
49
- * All fields are optional since you only need to specify the fields you want to change.
50
- *
51
- * @example
52
- * // Update a thing's fields
53
- * thing.update({
54
- * where: { id: "123" },
55
- * data: {
56
- * id?: string,
57
- * name?: string,
58
- * }
59
- * });
60
- */
61
- export type ThingUpdateInput = Partial<ThingCreateInput>;
62
-
63
- /**
64
- * Filter type for querying Thing records.
65
- * You can filter by any field in the model using equality or advanced filter operators.
66
- *
67
- * @example
68
- * // Basic filtering
69
- * thing.findMany({
70
- * where: {
71
- * id: "value",
72
- * name?: "value"
73
- * }
74
- * });
75
- *
76
- * @example
77
- * // Advanced filtering
78
- * thing.findMany({
79
- * where: {
80
- * // Use advanced operators
81
- * id: { contains: "partial" }
82
- * }
83
- * });
84
- */
85
- export type ThingWhereInput = Partial<ThingWithRelations>;
86
-
87
- /**
88
- * Unique identifier for finding a specific Thing record.
89
- * Usually uses the ID field but can be any field marked as @unique in the schema.
90
- *
91
- * @example
92
- * // Find by ID
93
- * thing.findUnique({ id: "123" });
94
- *
95
- * @example
96
- * // Delete by ID
97
- * thing.delete({ id: "123" });
98
- */
99
- export type ThingWhereUniqueInput = {
100
- id: string;
101
- };
102
-
103
- /**
104
- * Sort options for Thing queries.
105
- * Specify the field to sort by and the direction ('asc' or 'desc').
106
- *
107
- * @example
108
- * // Sort by creation date, newest first
109
- * thing.findMany({
110
- * orderBy: { created_at: 'desc' }
111
- * });
112
- *
113
- * @example
114
- * // Sort alphabetically
115
- * thing.findMany({
116
- * orderBy: { name: 'asc' }
117
- * });
118
- */
119
- export type ThingOrderByInput = {
120
- [key in keyof ThingWithRelations]?: 'asc' | 'desc';
121
- };
122
-
123
- /**
124
- * Result type for operations that return a single Thing record.
125
- */
126
- export type ThingSingleResult = ModelResult<ThingWithRelations>;
127
-
128
- /**
129
- * Result type for operations that return multiple Thing records.
130
- */
131
- export type ThingManyResult = ModelResult<ThingWithRelations[]>;
132
-
133
- /**
134
- * Configuration options for the Thing hook.
135
- */
136
- export type UseThingOptions = SuparismaOptions<ThingWhereInput, ThingOrderByInput>;
137
-
138
- /**
139
- * The complete API for interacting with Thing records.
140
- * This interface defines all available operations and state properties.
141
- */
142
- export interface ThingHookApi {
143
- /**
144
- * Current array of Thing records.
145
- * This is automatically updated when:
146
- * - The initial data is loaded
147
- * - Mutations are performed (create, update, delete)
148
- * - Real-time updates are received from other clients
149
- * - The refresh method is called
150
- *
151
- * @example
152
- * // Render a list of thing records
153
- * const { data } = thing;
154
- * return (
155
- * <ul>
156
- * {data.map(item => (
157
- * <li key={item.id}>{item.name}</li>
158
- * ))}
159
- * </ul>
160
- * );
161
- */
162
- data: ThingWithRelations[];
163
-
164
- /**
165
- * Error object if the last operation failed, null otherwise.
166
- *
167
- * @example
168
- * // Handle potential errors
169
- * const { error } = thing;
170
- * if (error) {
171
- * return <div>Error: {error.message}</div>;
172
- * }
173
- */
174
- error: Error | null;
175
-
176
- /**
177
- * Boolean indicating if an operation is in progress.
178
- *
179
- * @example
180
- * // Show loading state
181
- * const { loading } = thing;
182
- * if (loading) {
183
- * return <div>Loading...</div>;
184
- * }
185
- */
186
- loading: boolean;
187
-
188
- /**
189
- * The current count of records matching the filter criteria.
190
- * This automatically updates with the data, including realtime updates.
191
- * It always reflects the current length of the data array, respecting any filters.
192
- *
193
- * @example
194
- * // Display the count in the UI
195
- * const { count } = thing;
196
- * return <div>Total records: {count}</div>;
197
- */
198
- count: number;
199
-
200
-
201
-
202
- /**
203
- * Find a single Thing record by its unique identifier.
204
- *
205
- * @param where - The unique identifier to find the record by
206
- * @returns A promise with the found record or error
207
- *
208
- * @example
209
- * // Find thing by ID
210
- * const result = await thing.findUnique({ id: "123" });
211
- * if (result.data) {
212
- * console.log("Found thing:", result.data);
213
- * }
214
- */
215
- findUnique: (where: ThingWhereUniqueInput) => ThingSingleResult;
216
-
217
- /**
218
- * Find multiple Thing records matching the filter criteria.
219
- * Supports filtering, sorting, and pagination.
220
- *
221
- * @param params - Optional query parameters
222
- * @returns A promise with the matching records or error
223
- *
224
- * @example
225
- * // Get all thing records
226
- * const result = await thing.findMany();
227
- *
228
- * @example
229
- * // Filter and sort records
230
- * const result = await thing.findMany({
231
- * where: { active: true },
232
- * orderBy: { created_at: 'desc' },
233
- * take: 10,
234
- * skip: 0
235
- * });
236
- */
237
- findMany: (params?: {
238
- where?: ThingWhereInput;
239
- orderBy?: ThingOrderByInput;
240
- take?: number;
241
- skip?: number;
242
- }) => ThingManyResult;
243
-
244
- /**
245
- * Find the first Thing record matching the filter criteria.
246
- *
247
- * @param params - Optional query parameters
248
- * @returns A promise with the first matching record or error
249
- *
250
- * @example
251
- * // Find the first active thing
252
- * const result = await thing.findFirst({
253
- * where: { active: true }
254
- * });
255
- *
256
- * @example
257
- * // Find the oldest thing
258
- * const result = await thing.findFirst({
259
- * orderBy: { created_at: 'asc' }
260
- * });
261
- */
262
- findFirst: (params?: {
263
- where?: ThingWhereInput;
264
- orderBy?: ThingOrderByInput;
265
- }) => ThingSingleResult;
266
-
267
- /**
268
- * Create a new Thing record.
269
- * Fields with default values are optional and will use their defaults if not provided.
270
- *
271
- * @param data - The data for the new record
272
- * @returns A promise with the created record or error
273
- *
274
- * @example
275
- * // Create a new thing
276
- * const result = await thing.create({
277
-
278
- * });
279
- *
280
- * @example
281
- * // Create with custom ID (overriding default)
282
- * const result = await thing.create({
283
- * id: "custom-id",
284
-
285
- * });
286
- */
287
- create: (data: ThingCreateInput) => ThingSingleResult;
288
-
289
- /**
290
- * Update an existing Thing record.
291
- *
292
- * @param params - Object with the record identifier and fields to update
293
- * @returns A promise with the updated record or error
294
- *
295
- * @example
296
- * // Update a thing's fields
297
- * const result = await thing.update({
298
- * where: { id: "123" },
299
- * data: {
300
- * id?: "updated value",
301
- * name?: "updated value"
302
- * }
303
- * });
304
- */
305
- update: (params: {
306
- where: ThingWhereUniqueInput;
307
- data: ThingUpdateInput;
308
- }) => ThingSingleResult;
309
-
310
- /**
311
- * Delete a Thing record by its unique identifier.
312
- *
313
- * @param where - The unique identifier of the record to delete
314
- * @returns A promise with the deleted record or error
315
- *
316
- * @example
317
- * // Delete a thing by ID
318
- * const result = await thing.delete({ id: "123" });
319
- * if (result.data) {
320
- * console.log("Deleted thing:", result.data);
321
- * }
322
- */
323
- delete: (where: ThingWhereUniqueInput) => ThingSingleResult;
324
-
325
- /**
326
- * Delete multiple Thing records matching the filter criteria.
327
- *
328
- * @param params - Optional filter parameters
329
- * @returns A promise with the count of deleted records or error
330
- *
331
- * @example
332
- * // Delete all inactive thing records
333
- * const result = await thing.deleteMany({
334
- * where: { active: false }
335
- * });
336
- * console.log(`Deleted ${result.count} records`);
337
- *
338
- * @example
339
- * // Delete all thing records (use with caution!)
340
- * const result = await thing.deleteMany();
341
- */
342
- deleteMany: (params?: {
343
- where?: ThingWhereInput;
344
- }) => Promise<{ count: number; error: Error | null }>;
345
-
346
- /**
347
- * Create a record if it doesn't exist, or update it if it does.
348
- *
349
- * @param params - Object with the identifier, update data, and create data
350
- * @returns A promise with the created or updated record or error
351
- *
352
- * @example
353
- * // Upsert a thing by ID
354
- * const result = await thing.upsert({
355
- * where: { id: "123" },
356
- * update: { name: "Updated Name" },
357
- * create: {
358
- * id: "123",
359
- * name: "New Name"
360
-
361
- * }
362
- * });
363
- */
364
- upsert: (params: {
365
- where: ThingWhereUniqueInput;
366
- update: ThingUpdateInput;
367
- create: ThingCreateInput;
368
- }) => ThingSingleResult;
369
-
370
- /**
371
- * Manually refresh the data with current filter settings.
372
- * Useful after external operations or when realtime is disabled.
373
- *
374
- * @param params - Optional override parameters for this specific refresh
375
- * @returns A promise with the refreshed data or error
376
- *
377
- * @example
378
- * // Refresh with current filter settings
379
- * await thing.refresh();
380
- *
381
- * @example
382
- * // Refresh with different filters for this call only
383
- * await thing.refresh({
384
- * where: { active: true },
385
- * orderBy: { name: 'asc' }
386
- * });
387
- */
388
- refresh: (params?: {
389
- where?: ThingWhereInput;
390
- orderBy?: ThingOrderByInput;
391
- take?: number;
392
- skip?: number;
393
- }) => ThingManyResult;
394
- }