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