@cerbos/orm-prisma 3.0.1 → 3.1.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 (35) hide show
  1. package/README.md +2 -2
  2. package/lib/index.js +54 -1
  3. package/lib/index.js.map +1 -1
  4. package/package.json +17 -12
  5. package/src/generated/prisma/browser.ts +59 -0
  6. package/src/generated/prisma/client.ts +79 -0
  7. package/src/generated/prisma/commonInputTypes.ts +248 -0
  8. package/src/generated/prisma/enums.ts +15 -0
  9. package/src/generated/prisma/internal/class.ts +262 -0
  10. package/src/generated/prisma/internal/prismaNamespace.ts +1333 -0
  11. package/src/generated/prisma/internal/prismaNamespaceBrowser.ts +168 -0
  12. package/src/generated/prisma/models/Category.ts +1407 -0
  13. package/src/generated/prisma/models/Label.ts +1271 -0
  14. package/src/generated/prisma/models/NestedResource.ts +1557 -0
  15. package/src/generated/prisma/models/NextLevelNestedResource.ts +1332 -0
  16. package/src/generated/prisma/models/Resource.ts +2131 -0
  17. package/src/generated/prisma/models/SubCategory.ts +1407 -0
  18. package/src/generated/prisma/models/Tag.ts +1271 -0
  19. package/src/generated/prisma/models/User.ts +1498 -0
  20. package/src/generated/prisma/models.ts +19 -0
  21. package/src/generated/prisma-v6/client.d.ts +1 -0
  22. package/src/generated/prisma-v6/default.d.ts +1 -0
  23. package/src/generated/prisma-v6/edge.d.ts +1 -0
  24. package/src/generated/prisma-v6/index.d.ts +13639 -0
  25. package/src/generated/prisma-v6/runtime/index-browser.d.ts +370 -0
  26. package/src/generated/prisma-v6/runtime/library.d.ts +3982 -0
  27. package/src/generated/prisma-v6/wasm.d.ts +1 -0
  28. package/src/index.test.ts +702 -2
  29. package/src/index.ts +79 -1
  30. package/src/test-setup.v6.ts +5 -0
  31. package/src/test-setup.v7.ts +7 -0
  32. package/lib/index.test.d.ts +0 -2
  33. package/lib/index.test.d.ts.map +0 -1
  34. package/lib/index.test.js +0 -4093
  35. package/lib/index.test.js.map +0 -1
@@ -0,0 +1,262 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!! */
3
+ /* eslint-disable */
4
+ // biome-ignore-all lint: generated file
5
+ // @ts-nocheck
6
+ /*
7
+ * WARNING: This is an internal file that is subject to change!
8
+ *
9
+ * 🛑 Under no circumstances should you import this file directly! 🛑
10
+ *
11
+ * Please import the `PrismaClient` class from the `client.ts` file instead.
12
+ */
13
+
14
+ import * as runtime from "@prisma/client/runtime/client"
15
+ import type * as Prisma from "./prismaNamespace.js"
16
+
17
+
18
+ const config: runtime.GetPrismaClientConfig = {
19
+ "previewFeatures": [],
20
+ "clientVersion": "7.3.0",
21
+ "engineVersion": "9d6ad21cbbceab97458517b147a6a09ff43aa735",
22
+ "activeProvider": "sqlite",
23
+ "inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client\" // or `prisma-client-js`\n output = \"../src/generated/prisma\"\n engineType = \"client\" // enable Prisma ORM without Rust\n moduleFormat = \"cjs\"\n}\n\ndatasource db {\n provider = \"sqlite\"\n}\n\nmodel Resource {\n id String @id @default(cuid())\n aString String\n aNumber Int\n aBool Boolean\n ownedBy User[]\n createdBy User @relation(fields: [creatorId], references: [id], name: \"creator\")\n creatorId String\n nested NestedResource @relation(fields: [nestedResourceId], references: [id])\n nestedResourceId String\n tags Tag[] // Add many-to-many relationship\n aOptionalString String?\n categories Category[] // Add categories relation\n}\n\nmodel User {\n id String @id @default(cuid())\n aString String\n aNumber Int\n aBool Boolean\n resources Resource[]\n createdResources Resource[] @relation(name: \"creator\")\n}\n\nmodel NestedResource {\n id String @id @default(cuid())\n aString String\n aNumber Int\n aBool Boolean\n aOptionalString String?\n\n Resource Resource[]\n nextlevel NextLevelNestedResource @relation(fields: [nextLevelNestedResourceId], references: [id])\n nextLevelNestedResourceId String\n}\n\nmodel NextLevelNestedResource {\n id String @id @default(cuid())\n aString String\n aNumber Int\n aBool Boolean\n NestedResource NestedResource[]\n}\n\nmodel Tag {\n id String @id @default(cuid())\n name String @unique\n resources Resource[]\n}\n\n// Add new models for nested many-to-many relations\nmodel Category {\n id String @id @default(cuid())\n name String @unique\n resources Resource[]\n subCategories SubCategory[]\n}\n\nmodel SubCategory {\n id String @id @default(cuid())\n name String @unique\n categories Category[]\n labels Label[]\n}\n\nmodel Label {\n id String @id @default(cuid())\n name String @unique\n subCategories SubCategory[]\n}\n",
24
+ "runtimeDataModel": {
25
+ "models": {},
26
+ "enums": {},
27
+ "types": {}
28
+ }
29
+ }
30
+
31
+ config.runtimeDataModel = JSON.parse("{\"models\":{\"Resource\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aNumber\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"aBool\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"ownedBy\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"ResourceToUser\"},{\"name\":\"createdBy\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"creator\"},{\"name\":\"creatorId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"nested\",\"kind\":\"object\",\"type\":\"NestedResource\",\"relationName\":\"NestedResourceToResource\"},{\"name\":\"nestedResourceId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"tags\",\"kind\":\"object\",\"type\":\"Tag\",\"relationName\":\"ResourceToTag\"},{\"name\":\"aOptionalString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"categories\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"CategoryToResource\"}],\"dbName\":null},\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aNumber\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"aBool\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"resources\",\"kind\":\"object\",\"type\":\"Resource\",\"relationName\":\"ResourceToUser\"},{\"name\":\"createdResources\",\"kind\":\"object\",\"type\":\"Resource\",\"relationName\":\"creator\"}],\"dbName\":null},\"NestedResource\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aNumber\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"aBool\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"aOptionalString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"Resource\",\"kind\":\"object\",\"type\":\"Resource\",\"relationName\":\"NestedResourceToResource\"},{\"name\":\"nextlevel\",\"kind\":\"object\",\"type\":\"NextLevelNestedResource\",\"relationName\":\"NestedResourceToNextLevelNestedResource\"},{\"name\":\"nextLevelNestedResourceId\",\"kind\":\"scalar\",\"type\":\"String\"}],\"dbName\":null},\"NextLevelNestedResource\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aString\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"aNumber\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"aBool\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"NestedResource\",\"kind\":\"object\",\"type\":\"NestedResource\",\"relationName\":\"NestedResourceToNextLevelNestedResource\"}],\"dbName\":null},\"Tag\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"resources\",\"kind\":\"object\",\"type\":\"Resource\",\"relationName\":\"ResourceToTag\"}],\"dbName\":null},\"Category\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"resources\",\"kind\":\"object\",\"type\":\"Resource\",\"relationName\":\"CategoryToResource\"},{\"name\":\"subCategories\",\"kind\":\"object\",\"type\":\"SubCategory\",\"relationName\":\"CategoryToSubCategory\"}],\"dbName\":null},\"SubCategory\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"categories\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"CategoryToSubCategory\"},{\"name\":\"labels\",\"kind\":\"object\",\"type\":\"Label\",\"relationName\":\"LabelToSubCategory\"}],\"dbName\":null},\"Label\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"subCategories\",\"kind\":\"object\",\"type\":\"SubCategory\",\"relationName\":\"LabelToSubCategory\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}")
32
+
33
+ async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
34
+ const { Buffer } = await import('node:buffer')
35
+ const wasmArray = Buffer.from(wasmBase64, 'base64')
36
+ return new WebAssembly.Module(wasmArray)
37
+ }
38
+
39
+ config.compilerWasm = {
40
+ getRuntime: async () => await import("@prisma/client/runtime/query_compiler_fast_bg.sqlite.js"),
41
+
42
+ getQueryCompilerWasmModule: async () => {
43
+ const { wasm } = await import("@prisma/client/runtime/query_compiler_fast_bg.sqlite.wasm-base64.js")
44
+ return await decodeBase64AsWasm(wasm)
45
+ },
46
+
47
+ importName: "./query_compiler_fast_bg.js"
48
+ }
49
+
50
+
51
+
52
+ export type LogOptions<ClientOptions extends Prisma.PrismaClientOptions> =
53
+ 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never
54
+
55
+ export interface PrismaClientConstructor {
56
+ /**
57
+ * ## Prisma Client
58
+ *
59
+ * Type-safe database client for TypeScript
60
+ * @example
61
+ * ```
62
+ * const prisma = new PrismaClient()
63
+ * // Fetch zero or more Resources
64
+ * const resources = await prisma.resource.findMany()
65
+ * ```
66
+ *
67
+ * Read more in our [docs](https://pris.ly/d/client).
68
+ */
69
+
70
+ new <
71
+ Options extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
72
+ LogOpts extends LogOptions<Options> = LogOptions<Options>,
73
+ OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'],
74
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
75
+ >(options: Prisma.Subset<Options, Prisma.PrismaClientOptions> ): PrismaClient<LogOpts, OmitOpts, ExtArgs>
76
+ }
77
+
78
+ /**
79
+ * ## Prisma Client
80
+ *
81
+ * Type-safe database client for TypeScript
82
+ * @example
83
+ * ```
84
+ * const prisma = new PrismaClient()
85
+ * // Fetch zero or more Resources
86
+ * const resources = await prisma.resource.findMany()
87
+ * ```
88
+ *
89
+ * Read more in our [docs](https://pris.ly/d/client).
90
+ */
91
+
92
+ export interface PrismaClient<
93
+ in LogOpts extends Prisma.LogLevel = never,
94
+ in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = undefined,
95
+ in out ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
96
+ > {
97
+ [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
98
+
99
+ $on<V extends LogOpts>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;
100
+
101
+ /**
102
+ * Connect with the database
103
+ */
104
+ $connect(): runtime.Types.Utils.JsPromise<void>;
105
+
106
+ /**
107
+ * Disconnect from the database
108
+ */
109
+ $disconnect(): runtime.Types.Utils.JsPromise<void>;
110
+
111
+ /**
112
+ * Executes a prepared raw query and returns the number of affected rows.
113
+ * @example
114
+ * ```
115
+ * const result = await prisma.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};`
116
+ * ```
117
+ *
118
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
119
+ */
120
+ $executeRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<number>;
121
+
122
+ /**
123
+ * Executes a raw query and returns the number of affected rows.
124
+ * Susceptible to SQL injections, see documentation.
125
+ * @example
126
+ * ```
127
+ * const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
128
+ * ```
129
+ *
130
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
131
+ */
132
+ $executeRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<number>;
133
+
134
+ /**
135
+ * Performs a prepared raw query and returns the `SELECT` data.
136
+ * @example
137
+ * ```
138
+ * const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};`
139
+ * ```
140
+ *
141
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
142
+ */
143
+ $queryRaw<T = unknown>(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise<T>;
144
+
145
+ /**
146
+ * Performs a raw query and returns the `SELECT` data.
147
+ * Susceptible to SQL injections, see documentation.
148
+ * @example
149
+ * ```
150
+ * const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
151
+ * ```
152
+ *
153
+ * Read more in our [docs](https://pris.ly/d/raw-queries).
154
+ */
155
+ $queryRawUnsafe<T = unknown>(query: string, ...values: any[]): Prisma.PrismaPromise<T>;
156
+
157
+
158
+ /**
159
+ * Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
160
+ * @example
161
+ * ```
162
+ * const [george, bob, alice] = await prisma.$transaction([
163
+ * prisma.user.create({ data: { name: 'George' } }),
164
+ * prisma.user.create({ data: { name: 'Bob' } }),
165
+ * prisma.user.create({ data: { name: 'Alice' } }),
166
+ * ])
167
+ * ```
168
+ *
169
+ * Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
170
+ */
171
+ $transaction<P extends Prisma.PrismaPromise<any>[]>(arg: [...P], options?: { isolationLevel?: Prisma.TransactionIsolationLevel }): runtime.Types.Utils.JsPromise<runtime.Types.Utils.UnwrapTuple<P>>
172
+
173
+ $transaction<R>(fn: (prisma: Omit<PrismaClient, runtime.ITXClientDenyList>) => runtime.Types.Utils.JsPromise<R>, options?: { maxWait?: number, timeout?: number, isolationLevel?: Prisma.TransactionIsolationLevel }): runtime.Types.Utils.JsPromise<R>
174
+
175
+ $extends: runtime.Types.Extensions.ExtendsHook<"extends", Prisma.TypeMapCb<OmitOpts>, ExtArgs, runtime.Types.Utils.Call<Prisma.TypeMapCb<OmitOpts>, {
176
+ extArgs: ExtArgs
177
+ }>>
178
+
179
+ /**
180
+ * `prisma.resource`: Exposes CRUD operations for the **Resource** model.
181
+ * Example usage:
182
+ * ```ts
183
+ * // Fetch zero or more Resources
184
+ * const resources = await prisma.resource.findMany()
185
+ * ```
186
+ */
187
+ get resource(): Prisma.ResourceDelegate<ExtArgs, { omit: OmitOpts }>;
188
+
189
+ /**
190
+ * `prisma.user`: Exposes CRUD operations for the **User** model.
191
+ * Example usage:
192
+ * ```ts
193
+ * // Fetch zero or more Users
194
+ * const users = await prisma.user.findMany()
195
+ * ```
196
+ */
197
+ get user(): Prisma.UserDelegate<ExtArgs, { omit: OmitOpts }>;
198
+
199
+ /**
200
+ * `prisma.nestedResource`: Exposes CRUD operations for the **NestedResource** model.
201
+ * Example usage:
202
+ * ```ts
203
+ * // Fetch zero or more NestedResources
204
+ * const nestedResources = await prisma.nestedResource.findMany()
205
+ * ```
206
+ */
207
+ get nestedResource(): Prisma.NestedResourceDelegate<ExtArgs, { omit: OmitOpts }>;
208
+
209
+ /**
210
+ * `prisma.nextLevelNestedResource`: Exposes CRUD operations for the **NextLevelNestedResource** model.
211
+ * Example usage:
212
+ * ```ts
213
+ * // Fetch zero or more NextLevelNestedResources
214
+ * const nextLevelNestedResources = await prisma.nextLevelNestedResource.findMany()
215
+ * ```
216
+ */
217
+ get nextLevelNestedResource(): Prisma.NextLevelNestedResourceDelegate<ExtArgs, { omit: OmitOpts }>;
218
+
219
+ /**
220
+ * `prisma.tag`: Exposes CRUD operations for the **Tag** model.
221
+ * Example usage:
222
+ * ```ts
223
+ * // Fetch zero or more Tags
224
+ * const tags = await prisma.tag.findMany()
225
+ * ```
226
+ */
227
+ get tag(): Prisma.TagDelegate<ExtArgs, { omit: OmitOpts }>;
228
+
229
+ /**
230
+ * `prisma.category`: Exposes CRUD operations for the **Category** model.
231
+ * Example usage:
232
+ * ```ts
233
+ * // Fetch zero or more Categories
234
+ * const categories = await prisma.category.findMany()
235
+ * ```
236
+ */
237
+ get category(): Prisma.CategoryDelegate<ExtArgs, { omit: OmitOpts }>;
238
+
239
+ /**
240
+ * `prisma.subCategory`: Exposes CRUD operations for the **SubCategory** model.
241
+ * Example usage:
242
+ * ```ts
243
+ * // Fetch zero or more SubCategories
244
+ * const subCategories = await prisma.subCategory.findMany()
245
+ * ```
246
+ */
247
+ get subCategory(): Prisma.SubCategoryDelegate<ExtArgs, { omit: OmitOpts }>;
248
+
249
+ /**
250
+ * `prisma.label`: Exposes CRUD operations for the **Label** model.
251
+ * Example usage:
252
+ * ```ts
253
+ * // Fetch zero or more Labels
254
+ * const labels = await prisma.label.findMany()
255
+ * ```
256
+ */
257
+ get label(): Prisma.LabelDelegate<ExtArgs, { omit: OmitOpts }>;
258
+ }
259
+
260
+ export function getPrismaClientClass(): PrismaClientConstructor {
261
+ return runtime.getPrismaClient(config) as unknown as PrismaClientConstructor
262
+ }