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