@m1212e/rumble 0.24.2 → 0.25.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.
- package/out/client.cjs +54 -50
- package/out/client.cjs.map +1 -1
- package/out/client.d.cts.map +1 -1
- package/out/client.d.mts.map +1 -1
- package/out/client.mjs +54 -50
- package/out/client.mjs.map +1 -1
- package/out/index.cjs +803 -473
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +272 -284
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +268 -280
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +808 -478
- package/out/index.mjs.map +1 -1
- package/package.json +9 -8
package/out/index.d.cts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { GraphQLError, GraphQLSchema } from "graphql";
|
|
2
|
-
import { Table } from "drizzle-orm";
|
|
2
|
+
import { SQL, Table } from "drizzle-orm";
|
|
3
3
|
import { MySqlAsyncDatabase } from "drizzle-orm/mysql-core";
|
|
4
4
|
import { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
5
5
|
import { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
|
|
6
|
+
import { Tracer } from "@opentelemetry/api";
|
|
7
|
+
import SchemaBuilder from "@pothos/core";
|
|
8
|
+
import { TracingWrapperOptions } from "@pothos/tracing-opentelemetry";
|
|
9
|
+
import { YogaServerOptions, createPubSub } from "graphql-yoga";
|
|
6
10
|
import { IncomingMessage, RequestListener, ServerResponse } from "node:http";
|
|
7
11
|
import { Http2ServerRequest, Http2ServerResponse } from "node:http2";
|
|
8
12
|
import { Socket } from "node:net";
|
|
@@ -10,10 +14,6 @@ import "@whatwg-node/fetch";
|
|
|
10
14
|
import { EnvelopArmorPlugin } from "@escape.tech/graphql-armor";
|
|
11
15
|
import { useSofa } from "@m1212e/sofa-api";
|
|
12
16
|
import { ServerOptions } from "graphql-ws";
|
|
13
|
-
import { YogaServerOptions, createPubSub } from "graphql-yoga";
|
|
14
|
-
import { Tracer } from "@opentelemetry/api";
|
|
15
|
-
import SchemaBuilder from "@pothos/core";
|
|
16
|
-
import { TracingWrapperOptions } from "@pothos/tracing-opentelemetry";
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region lib/helpers/asserts.d.ts
|
|
19
19
|
/**
|
|
@@ -170,6 +170,25 @@ type DrizzleQueryFunctionInput<DB extends DrizzleInstance, QueryField extends ke
|
|
|
170
170
|
*/
|
|
171
171
|
type DrizzleTableValueType<DB extends DrizzleInstance, QueryField extends keyof DrizzleQueryFunction<DB>> = NonNullable<Awaited<ReturnType<DrizzleQueryFunction<DB>[QueryField]["findFirst"]>>>;
|
|
172
172
|
//#endregion
|
|
173
|
+
//#region lib/abilityBuilder/queryFilter.d.ts
|
|
174
|
+
/**
|
|
175
|
+
* Static, non changing query filter input type for a specific table
|
|
176
|
+
*/
|
|
177
|
+
type StaticQueryFilter<DB extends DrizzleInstance, Table extends keyof DrizzleQueryFunction<DB>, Filter extends DrizzleQueryFunctionInput<DB, Table>> = Filter;
|
|
178
|
+
/**
|
|
179
|
+
* Dynamic, context based query filter input type for a specific table
|
|
180
|
+
*/
|
|
181
|
+
type DynamicQueryFilter<DB extends DrizzleInstance, Table extends keyof DrizzleQueryFunction<DB>, Filter extends DrizzleQueryFunctionInput<DB, Table>, Context> = (context: Context) => StaticQueryFilter<DB, Table, Filter> | undefined | "allow" | Promise<StaticQueryFilter<DB, Table, Filter> | undefined | "allow">;
|
|
182
|
+
/**
|
|
183
|
+
* Combined query filter type for a specific table. May be static or dynamic.
|
|
184
|
+
*/
|
|
185
|
+
type QueryFilter<DB extends DrizzleInstance, Table extends keyof DrizzleQueryFunction<DB>, Filter extends DrizzleQueryFunctionInput<DB, Table>, Context> = StaticQueryFilter<DB, Table, Filter> | DynamicQueryFilter<DB, Table, Filter, Context>;
|
|
186
|
+
/**
|
|
187
|
+
* The query filters registered per action. "unrestricted" when a bare allow()
|
|
188
|
+
* granted the action without conditions.
|
|
189
|
+
*/
|
|
190
|
+
type QueryFilterRegistry<UserContext extends Record<string, any>, DB extends DrizzleInstance, Action extends string, TableName extends keyof DrizzleQueryFunction<DB>> = Map<Action, QueryFilter<DB, TableName, DrizzleQueryFunctionInput<DB, TableName>, UserContext>[] | "unrestricted">;
|
|
191
|
+
//#endregion
|
|
173
192
|
//#region lib/runtimeFiltersPlugin/filterTypes.d.ts
|
|
174
193
|
type Prefetch<Context, ReturnType> = (params: {
|
|
175
194
|
context: Context;
|
|
@@ -184,6 +203,240 @@ type FilterPrefetchCombo<Context, FilteredEntityType, PrefetchReturnType = never
|
|
|
184
203
|
prefetch?: Prefetch<Context, PrefetchReturnType>;
|
|
185
204
|
};
|
|
186
205
|
//#endregion
|
|
206
|
+
//#region lib/types/rumbleInput.d.ts
|
|
207
|
+
interface RumbleLogger {
|
|
208
|
+
info(obj: Record<string, unknown>, msg: string): void;
|
|
209
|
+
warn(obj: Record<string, unknown>, msg: string): void;
|
|
210
|
+
error(obj: Record<string, unknown>, msg: string): void;
|
|
211
|
+
debug(obj: Record<string, unknown>, msg: string): void;
|
|
212
|
+
child(bindings: Record<string, unknown>): RumbleLogger;
|
|
213
|
+
}
|
|
214
|
+
type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder>[0], "smartSubscriptions" | "drizzle" | "validation">;
|
|
215
|
+
type RumbleInput<UserContext extends Record<string, any>, DB extends DrizzleInstance, RequestEvent extends Record<string, any>, Action extends string, PothosConfig extends CustomRumblePothosConfig, Schema extends Record<string, any> = Record<string, any>> = {
|
|
216
|
+
/**
|
|
217
|
+
* Your drizzle database instance
|
|
218
|
+
*/
|
|
219
|
+
db: DB;
|
|
220
|
+
/**
|
|
221
|
+
* The drizzle schema object (the same one passed to `defineRelations`).
|
|
222
|
+
*/
|
|
223
|
+
schema: Schema;
|
|
224
|
+
/**
|
|
225
|
+
* A function for providing context for each request based on the incoming HTTP Request.
|
|
226
|
+
* The type of the parameter equals the HTTPRequest type of your chosen server.
|
|
227
|
+
*/
|
|
228
|
+
context?: ((event: RequestEvent) => Promise<UserContext> | UserContext) | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* The actions that are available
|
|
231
|
+
*/
|
|
232
|
+
actions?: Action[];
|
|
233
|
+
/**
|
|
234
|
+
* Customization for subscriptions. See https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#distributed-pubsub-for-production
|
|
235
|
+
*/
|
|
236
|
+
subscriptions?: Parameters<typeof createPubSub>;
|
|
237
|
+
/**
|
|
238
|
+
* Options passed along to the pothos schema builder.
|
|
239
|
+
*/
|
|
240
|
+
pothosConfig?: PothosConfig;
|
|
241
|
+
/**
|
|
242
|
+
* Limits the returned amount when querying lists. Set to null to disable.
|
|
243
|
+
* @default 100
|
|
244
|
+
*/
|
|
245
|
+
defaultLimit?: number | undefined | null;
|
|
246
|
+
/**
|
|
247
|
+
* rumble supports fuzzy search for the query helpers. This enables the users of your API to search for entities via fuzzy search inputs.
|
|
248
|
+
* This currently only is supported by postgres databases and will fail if enabled on other dialects.
|
|
249
|
+
*
|
|
250
|
+
* Please note that this will install the pg_trgm extension on startup if your database does not have it already installed.
|
|
251
|
+
* https://www.postgresql.org/docs/current/pgtrgm.html
|
|
252
|
+
*/
|
|
253
|
+
search?: {
|
|
254
|
+
/**
|
|
255
|
+
* Whether search is enabled
|
|
256
|
+
*/
|
|
257
|
+
enabled?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* The cuttoff factor to reduce the amount of returned results.
|
|
260
|
+
* Defaults to 0.3. Lower values will return more results.
|
|
261
|
+
*/
|
|
262
|
+
threshold?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Will perform a local
|
|
265
|
+
* SET cpu_operator_cost = x;
|
|
266
|
+
* for search queries. This can help to make the planner
|
|
267
|
+
* use a potential index scan instead of a sequential scan.
|
|
268
|
+
* This will not affect queries that are not using the search feature.
|
|
269
|
+
*/
|
|
270
|
+
cpu_operator_cost?: number;
|
|
271
|
+
} | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* rumble can set up otel tracing if you want to. This will provide details of execution time and outcome to the provided tracer. See https://pothos-graphql.dev/docs/plugins/tracing#install for more information.
|
|
274
|
+
*
|
|
275
|
+
* The emitted spans and attributes are identical for every transport, so an
|
|
276
|
+
* operation served via GraphQL, the SOFA REST adapter or WebSockets produces
|
|
277
|
+
* the same trace shape (see `rumble.transport` to tell them apart).
|
|
278
|
+
*/
|
|
279
|
+
otel?: {
|
|
280
|
+
/**
|
|
281
|
+
* Whether otel tracing should be enabled. This will create a tracer if none is provided.
|
|
282
|
+
*/
|
|
283
|
+
enabled?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* The tracer to use. If enabled is true and no tracer is provided, a tracer will be created.
|
|
286
|
+
*/
|
|
287
|
+
tracer?: Tracer;
|
|
288
|
+
/**
|
|
289
|
+
* You can pass options to the tracing wrapper
|
|
290
|
+
*/
|
|
291
|
+
options?: TracingWrapperOptions<unknown>;
|
|
292
|
+
/**
|
|
293
|
+
* Whether the operation source is attached to operation spans as
|
|
294
|
+
* `graphql.document`.
|
|
295
|
+
*
|
|
296
|
+
* Keep in mind that a document can carry inline argument literals, so this
|
|
297
|
+
* may contain user data.
|
|
298
|
+
* @default true
|
|
299
|
+
*/
|
|
300
|
+
includeDocument?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Whether the incoming operation variables are attached to operation spans
|
|
303
|
+
* as `graphql.variables.<name>` attributes.
|
|
304
|
+
*
|
|
305
|
+
* Variables regularly carry personal data, so you can turn this off
|
|
306
|
+
* entirely (`false`) or pass a function to redact or drop single entries
|
|
307
|
+
* before they leave the process.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```ts
|
|
311
|
+
* otel: {
|
|
312
|
+
* enabled: true,
|
|
313
|
+
* includeVariables: ({ password, ...rest }) => rest,
|
|
314
|
+
* }
|
|
315
|
+
* ```
|
|
316
|
+
* @default true
|
|
317
|
+
*/
|
|
318
|
+
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Structured logging for rumble internals. Pass a pino (or compatible) logger instance.
|
|
322
|
+
* When enabled, rumble emits structured log entries for GraphQL operations, ability checks,
|
|
323
|
+
* and runtime filter applications — queryable by level and field in Loki or similar.
|
|
324
|
+
*/
|
|
325
|
+
logger?: {
|
|
326
|
+
/**
|
|
327
|
+
* Whether structured logging should be enabled.
|
|
328
|
+
*/
|
|
329
|
+
enabled?: boolean;
|
|
330
|
+
/**
|
|
331
|
+
* The logger instance to use. Must satisfy the RumbleLogger interface (pino satisfies this).
|
|
332
|
+
*/
|
|
333
|
+
logger: RumbleLogger;
|
|
334
|
+
/**
|
|
335
|
+
* When both logger and otel are enabled, inject `trace_id`, `span_id` and `trace_flags`
|
|
336
|
+
* fields into every log entry emitted during a GraphQL operation. Useful for correlating
|
|
337
|
+
* log lines with traces in backends like Jaeger or Grafana Tempo.
|
|
338
|
+
* @default true
|
|
339
|
+
*/
|
|
340
|
+
injectTraceId?: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Whether the incoming operation variables are attached to the operation
|
|
343
|
+
* start log entry as a `graphql.variables` object.
|
|
344
|
+
*
|
|
345
|
+
* Variables regularly carry personal data, so you can turn this off
|
|
346
|
+
* entirely (`false`) or pass a function to redact or drop single entries
|
|
347
|
+
* before they are logged.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* logger: {
|
|
352
|
+
* enabled: true,
|
|
353
|
+
* logger: pino(),
|
|
354
|
+
* includeVariables: ({ password, ...rest }) => rest,
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
* @default true
|
|
358
|
+
*/
|
|
359
|
+
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
360
|
+
};
|
|
361
|
+
/**
|
|
362
|
+
* Configures `@pothos/plugin-validation`, which rumble installs by default to power
|
|
363
|
+
* `Address`/`AddressInput`'s country-aware validation (see `implementDefaultAddressTypes`).
|
|
364
|
+
*/
|
|
365
|
+
validation?: NonNullable<ConstructorParameters<typeof SchemaBuilder>[0]>["validation"];
|
|
366
|
+
};
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region lib/abilityBuilder/columnMask.d.ts
|
|
369
|
+
type MaskColumnsInput<DB extends DrizzleInstance, Action extends string> = {
|
|
370
|
+
table: TableRelationNames<DB>;
|
|
371
|
+
action: Action;
|
|
372
|
+
abilities: Record<string, any>;
|
|
373
|
+
entities: unknown[];
|
|
374
|
+
};
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region lib/abilityBuilder/filterResponse.d.ts
|
|
377
|
+
type FindFirstConfig<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = NonNullable<Parameters<DB["query"][TableName]["findFirst"]>[0]>;
|
|
378
|
+
type FindManyConfig<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = NonNullable<Parameters<DB["query"][TableName]["findMany"]>[0]>;
|
|
379
|
+
/**
|
|
380
|
+
* The query filters of an ability, as handed out by
|
|
381
|
+
* `abilities.<table>.filter(...)`.
|
|
382
|
+
*
|
|
383
|
+
* `columns` and `extras` are set at runtime but left out of the types on
|
|
384
|
+
* purpose: a visible, loosely typed extras makes drizzle infer `{}` as the row
|
|
385
|
+
* type of findFirst/findMany, and the column flag is an internal detail anyway.
|
|
386
|
+
*/
|
|
387
|
+
type AbilityFilter<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = {
|
|
388
|
+
/**
|
|
389
|
+
* Query filters for the drizzle query API.
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* author: t.relation("author", {
|
|
393
|
+
* query: async (_args, ctx) => (await ctx.abilities.users.filter("read")).query.single,
|
|
394
|
+
* }),
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
query: {
|
|
398
|
+
/**
|
|
399
|
+
* For find first calls
|
|
400
|
+
*/
|
|
401
|
+
single: Pick<FindFirstConfig<DB, TableName>, "where">;
|
|
402
|
+
/**
|
|
403
|
+
* For find many calls
|
|
404
|
+
*/
|
|
405
|
+
many: Pick<FindManyConfig<DB, TableName>, "where" | "limit">;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* Query filters for the drizzle SQL API as used in e.g. updates.
|
|
409
|
+
* @example
|
|
410
|
+
*
|
|
411
|
+
* ```ts
|
|
412
|
+
* await db
|
|
413
|
+
* .update(schema.users)
|
|
414
|
+
* .set({
|
|
415
|
+
* name: args.newName,
|
|
416
|
+
* })
|
|
417
|
+
* .where(
|
|
418
|
+
* and(
|
|
419
|
+
* eq(schema.users.id, args.userId),
|
|
420
|
+
* (await ctx.abilities.users.filter("update")).sql.where,
|
|
421
|
+
* ),
|
|
422
|
+
* );
|
|
423
|
+
* ```
|
|
424
|
+
*
|
|
425
|
+
*/
|
|
426
|
+
sql: {
|
|
427
|
+
readonly where: SQL | undefined;
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* What `abilities.<table>.filter(...)` resolves to.
|
|
432
|
+
*/
|
|
433
|
+
type AbilityFilterResponse<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = AbilityFilter<DB, TableName> & {
|
|
434
|
+
/**
|
|
435
|
+
* Merges the current query filters with the provided filters for this call only
|
|
436
|
+
*/
|
|
437
|
+
merge: (filters: NonNullable<DrizzleQueryFunctionInput<DB, TableName>>) => AbilityFilter<DB, TableName>;
|
|
438
|
+
};
|
|
439
|
+
//#endregion
|
|
187
440
|
//#region lib/scalars/address.d.ts
|
|
188
441
|
/**
|
|
189
442
|
* The shape of a postal address, modeled after the OIDC `address` claim
|
|
@@ -4401,168 +4654,6 @@ type RouteWithTypesOpts<TServerContext, TMethod extends HTTPMethod, TPath extend
|
|
|
4401
4654
|
};
|
|
4402
4655
|
type ExtractPathParamsWithPattern<TPath extends string> = Pipe<TPath, [Strings.Split<'/'>, Tuples.Filter<Strings.StartsWith<':'>>, Tuples.Map<Strings.Trim<':'>>, Tuples.ToUnion]>;
|
|
4403
4656
|
//#endregion
|
|
4404
|
-
//#region lib/types/rumbleInput.d.ts
|
|
4405
|
-
interface RumbleLogger {
|
|
4406
|
-
info(obj: Record<string, unknown>, msg: string): void;
|
|
4407
|
-
warn(obj: Record<string, unknown>, msg: string): void;
|
|
4408
|
-
error(obj: Record<string, unknown>, msg: string): void;
|
|
4409
|
-
debug(obj: Record<string, unknown>, msg: string): void;
|
|
4410
|
-
child(bindings: Record<string, unknown>): RumbleLogger;
|
|
4411
|
-
}
|
|
4412
|
-
type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder>[0], "smartSubscriptions" | "drizzle" | "validation">;
|
|
4413
|
-
type RumbleInput<UserContext extends Record<string, any>, DB extends DrizzleInstance, RequestEvent extends Record<string, any>, Action extends string, PothosConfig extends CustomRumblePothosConfig, Schema extends Record<string, any> = Record<string, any>> = {
|
|
4414
|
-
/**
|
|
4415
|
-
* Your drizzle database instance
|
|
4416
|
-
*/
|
|
4417
|
-
db: DB;
|
|
4418
|
-
/**
|
|
4419
|
-
* The drizzle schema object (the same one passed to `defineRelations`).
|
|
4420
|
-
*/
|
|
4421
|
-
schema: Schema;
|
|
4422
|
-
/**
|
|
4423
|
-
* A function for providing context for each request based on the incoming HTTP Request.
|
|
4424
|
-
* The type of the parameter equals the HTTPRequest type of your chosen server.
|
|
4425
|
-
*/
|
|
4426
|
-
context?: ((event: RequestEvent) => Promise<UserContext> | UserContext) | undefined;
|
|
4427
|
-
/**
|
|
4428
|
-
* The actions that are available
|
|
4429
|
-
*/
|
|
4430
|
-
actions?: Action[];
|
|
4431
|
-
/**
|
|
4432
|
-
* Customization for subscriptions. See https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#distributed-pubsub-for-production
|
|
4433
|
-
*/
|
|
4434
|
-
subscriptions?: Parameters<typeof createPubSub>;
|
|
4435
|
-
/**
|
|
4436
|
-
* Options passed along to the pothos schema builder.
|
|
4437
|
-
*/
|
|
4438
|
-
pothosConfig?: PothosConfig;
|
|
4439
|
-
/**
|
|
4440
|
-
* Limits the returned amount when querying lists. Set to null to disable.
|
|
4441
|
-
* @default 100
|
|
4442
|
-
*/
|
|
4443
|
-
defaultLimit?: number | undefined | null;
|
|
4444
|
-
/**
|
|
4445
|
-
* rumble supports fuzzy search for the query helpers. This enables the users of your API to search for entities via fuzzy search inputs.
|
|
4446
|
-
* This currently only is supported by postgres databases and will fail if enabled on other dialects.
|
|
4447
|
-
*
|
|
4448
|
-
* Please note that this will install the pg_trgm extension on startup if your database does not have it already installed.
|
|
4449
|
-
* https://www.postgresql.org/docs/current/pgtrgm.html
|
|
4450
|
-
*/
|
|
4451
|
-
search?: {
|
|
4452
|
-
/**
|
|
4453
|
-
* Whether search is enabled
|
|
4454
|
-
*/
|
|
4455
|
-
enabled?: boolean;
|
|
4456
|
-
/**
|
|
4457
|
-
* The cuttoff factor to reduce the amount of returned results.
|
|
4458
|
-
* Defaults to 0.3. Lower values will return more results.
|
|
4459
|
-
*/
|
|
4460
|
-
threshold?: number;
|
|
4461
|
-
/**
|
|
4462
|
-
* Will perform a local
|
|
4463
|
-
* SET cpu_operator_cost = x;
|
|
4464
|
-
* for search queries. This can help to make the planner
|
|
4465
|
-
* use a potential index scan instead of a sequential scan.
|
|
4466
|
-
* This will not affect queries that are not using the search feature.
|
|
4467
|
-
*/
|
|
4468
|
-
cpu_operator_cost?: number;
|
|
4469
|
-
} | undefined;
|
|
4470
|
-
/**
|
|
4471
|
-
* rumble can set up otel tracing if you want to. This will provide details of execution time and outcome to the provided tracer. See https://pothos-graphql.dev/docs/plugins/tracing#install for more information.
|
|
4472
|
-
*
|
|
4473
|
-
* The emitted spans and attributes are identical for every transport, so an
|
|
4474
|
-
* operation served via GraphQL, the SOFA REST adapter or WebSockets produces
|
|
4475
|
-
* the same trace shape (see `rumble.transport` to tell them apart).
|
|
4476
|
-
*/
|
|
4477
|
-
otel?: {
|
|
4478
|
-
/**
|
|
4479
|
-
* Whether otel tracing should be enabled. This will create a tracer if none is provided.
|
|
4480
|
-
*/
|
|
4481
|
-
enabled?: boolean;
|
|
4482
|
-
/**
|
|
4483
|
-
* The tracer to use. If enabled is true and no tracer is provided, a tracer will be created.
|
|
4484
|
-
*/
|
|
4485
|
-
tracer?: Tracer;
|
|
4486
|
-
/**
|
|
4487
|
-
* You can pass options to the tracing wrapper
|
|
4488
|
-
*/
|
|
4489
|
-
options?: TracingWrapperOptions<unknown>;
|
|
4490
|
-
/**
|
|
4491
|
-
* Whether the operation source is attached to operation spans as
|
|
4492
|
-
* `graphql.document`.
|
|
4493
|
-
*
|
|
4494
|
-
* Keep in mind that a document can carry inline argument literals, so this
|
|
4495
|
-
* may contain user data.
|
|
4496
|
-
* @default true
|
|
4497
|
-
*/
|
|
4498
|
-
includeDocument?: boolean;
|
|
4499
|
-
/**
|
|
4500
|
-
* Whether the incoming operation variables are attached to operation spans
|
|
4501
|
-
* as `graphql.variables.<name>` attributes.
|
|
4502
|
-
*
|
|
4503
|
-
* Variables regularly carry personal data, so you can turn this off
|
|
4504
|
-
* entirely (`false`) or pass a function to redact or drop single entries
|
|
4505
|
-
* before they leave the process.
|
|
4506
|
-
*
|
|
4507
|
-
* @example
|
|
4508
|
-
* ```ts
|
|
4509
|
-
* otel: {
|
|
4510
|
-
* enabled: true,
|
|
4511
|
-
* includeVariables: ({ password, ...rest }) => rest,
|
|
4512
|
-
* }
|
|
4513
|
-
* ```
|
|
4514
|
-
* @default true
|
|
4515
|
-
*/
|
|
4516
|
-
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
4517
|
-
};
|
|
4518
|
-
/**
|
|
4519
|
-
* Structured logging for rumble internals. Pass a pino (or compatible) logger instance.
|
|
4520
|
-
* When enabled, rumble emits structured log entries for GraphQL operations, ability checks,
|
|
4521
|
-
* and runtime filter applications — queryable by level and field in Loki or similar.
|
|
4522
|
-
*/
|
|
4523
|
-
logger?: {
|
|
4524
|
-
/**
|
|
4525
|
-
* Whether structured logging should be enabled.
|
|
4526
|
-
*/
|
|
4527
|
-
enabled?: boolean;
|
|
4528
|
-
/**
|
|
4529
|
-
* The logger instance to use. Must satisfy the RumbleLogger interface (pino satisfies this).
|
|
4530
|
-
*/
|
|
4531
|
-
logger: RumbleLogger;
|
|
4532
|
-
/**
|
|
4533
|
-
* When both logger and otel are enabled, inject `trace_id`, `span_id` and `trace_flags`
|
|
4534
|
-
* fields into every log entry emitted during a GraphQL operation. Useful for correlating
|
|
4535
|
-
* log lines with traces in backends like Jaeger or Grafana Tempo.
|
|
4536
|
-
* @default true
|
|
4537
|
-
*/
|
|
4538
|
-
injectTraceId?: boolean;
|
|
4539
|
-
/**
|
|
4540
|
-
* Whether the incoming operation variables are attached to the operation
|
|
4541
|
-
* start log entry as a `graphql.variables` object.
|
|
4542
|
-
*
|
|
4543
|
-
* Variables regularly carry personal data, so you can turn this off
|
|
4544
|
-
* entirely (`false`) or pass a function to redact or drop single entries
|
|
4545
|
-
* before they are logged.
|
|
4546
|
-
*
|
|
4547
|
-
* @example
|
|
4548
|
-
* ```ts
|
|
4549
|
-
* logger: {
|
|
4550
|
-
* enabled: true,
|
|
4551
|
-
* logger: pino(),
|
|
4552
|
-
* includeVariables: ({ password, ...rest }) => rest,
|
|
4553
|
-
* }
|
|
4554
|
-
* ```
|
|
4555
|
-
* @default true
|
|
4556
|
-
*/
|
|
4557
|
-
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
4558
|
-
};
|
|
4559
|
-
/**
|
|
4560
|
-
* Configures `@pothos/plugin-validation`, which rumble installs by default to power
|
|
4561
|
-
* `Address`/`AddressInput`'s country-aware validation (see `implementDefaultAddressTypes`).
|
|
4562
|
-
*/
|
|
4563
|
-
validation?: NonNullable<ConstructorParameters<typeof SchemaBuilder>[0]>["validation"];
|
|
4564
|
-
};
|
|
4565
|
-
//#endregion
|
|
4566
4657
|
//#region lib/rumble.d.ts
|
|
4567
4658
|
export declare const rumble: <UserContext extends Record<string, any>, DB extends DrizzleInstance, RequestEvent extends Record<string, any>, PothosConfig extends CustomRumblePothosConfig, Schema extends Record<string, any>, Action extends string = "delete" | "read" | "update">(rumbleInput: RumbleInput<UserContext, DB, RequestEvent, Action, PothosConfig> & {
|
|
4568
4659
|
schema: Schema;
|
|
@@ -4585,44 +4676,31 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4585
4676
|
*/
|
|
4586
4677
|
abilityBuilder: { [key in TableRelationNames<DB>]: {
|
|
4587
4678
|
allow: (action: Action | Action[]) => {
|
|
4588
|
-
when: (queryFilter:
|
|
4679
|
+
when: (queryFilter: QueryFilter<DB, key, DrizzleQueryFunctionInput<DB, key>, UserContext>) => void;
|
|
4589
4680
|
};
|
|
4590
4681
|
filter: (action: Action | Action[]) => {
|
|
4682
|
+
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>, never>) => void;
|
|
4591
4683
|
prefetch: <PrefetchReturnType>(prefetch: Prefetch<UserContext, PrefetchReturnType>) => {
|
|
4592
4684
|
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>, PrefetchReturnType>) => void;
|
|
4593
4685
|
};
|
|
4594
|
-
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>>) => void;
|
|
4595
4686
|
};
|
|
4596
4687
|
_: {
|
|
4597
4688
|
runtimeFilters: Map<Action, FilterPrefetchCombo<UserContext, any, any>[]>;
|
|
4598
|
-
queryFilters:
|
|
4689
|
+
queryFilters: QueryFilterRegistry<UserContext, DB, Action, key>;
|
|
4599
4690
|
};
|
|
4600
4691
|
}; } & {
|
|
4601
4692
|
_: {
|
|
4693
|
+
maskColumns: (input: MaskColumnsInput<DB, Action>) => void | Promise<void>;
|
|
4694
|
+
maskedActions: (abilities: object, table: TableRelationNames<DB>) => Set<Action>;
|
|
4695
|
+
primaryKeyHidden: (abilities: object, row: object) => boolean;
|
|
4696
|
+
registerReadAction(table: TableRelationNames<DB>, action: Action): void;
|
|
4697
|
+
readActionOf(table: TableRelationNames<DB>): Action;
|
|
4602
4698
|
registeredFilters({ action, table }: {
|
|
4603
4699
|
table: TableRelationNames<DB>;
|
|
4604
4700
|
action: Action;
|
|
4605
4701
|
}): Filter<UserContext, DrizzleTableValueType<DB, TableRelationNames<DB>>>[];
|
|
4606
4702
|
build(): (ctx: UserContext) => { [key in TableRelationNames<DB>]: {
|
|
4607
|
-
filter: (action: Action) => Promise<
|
|
4608
|
-
query: {
|
|
4609
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4610
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4611
|
-
};
|
|
4612
|
-
sql: {
|
|
4613
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4614
|
-
};
|
|
4615
|
-
} & {
|
|
4616
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
4617
|
-
query: {
|
|
4618
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4619
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4620
|
-
};
|
|
4621
|
-
sql: {
|
|
4622
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4623
|
-
};
|
|
4624
|
-
};
|
|
4625
|
-
}>;
|
|
4703
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4626
4704
|
}; };
|
|
4627
4705
|
};
|
|
4628
4706
|
};
|
|
@@ -4632,25 +4710,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4632
4710
|
schemaBuilder: PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4633
4711
|
Context: Awaited<UserContext & {
|
|
4634
4712
|
abilities: { [key in TableRelationNames<DB>]: {
|
|
4635
|
-
filter: (action: Action) => Promise<
|
|
4636
|
-
query: {
|
|
4637
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4638
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4639
|
-
};
|
|
4640
|
-
sql: {
|
|
4641
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4642
|
-
};
|
|
4643
|
-
} & {
|
|
4644
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
4645
|
-
query: {
|
|
4646
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4647
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4648
|
-
};
|
|
4649
|
-
sql: {
|
|
4650
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4651
|
-
};
|
|
4652
|
-
};
|
|
4653
|
-
}>;
|
|
4713
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4654
4714
|
}; };
|
|
4655
4715
|
}>;
|
|
4656
4716
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4790,25 +4850,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4790
4850
|
adjust?: ((t: import("@pothos/plugin-drizzle").DrizzleObjectFieldBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4791
4851
|
Context: Awaited<UserContext & {
|
|
4792
4852
|
abilities: { [key in TableRelationNames<DB>]: {
|
|
4793
|
-
filter: (action: Action) => Promise<
|
|
4794
|
-
query: {
|
|
4795
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4796
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4797
|
-
};
|
|
4798
|
-
sql: {
|
|
4799
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4800
|
-
};
|
|
4801
|
-
} & {
|
|
4802
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
4803
|
-
query: {
|
|
4804
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4805
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4806
|
-
};
|
|
4807
|
-
sql: {
|
|
4808
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4809
|
-
};
|
|
4810
|
-
};
|
|
4811
|
-
}>;
|
|
4853
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4812
4854
|
}; };
|
|
4813
4855
|
}>;
|
|
4814
4856
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4887,25 +4929,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4887
4929
|
}) => import("@pothos/plugin-drizzle").DrizzleObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4888
4930
|
Context: Awaited<UserContext & {
|
|
4889
4931
|
abilities: { [key in TableRelationNames<DB>]: {
|
|
4890
|
-
filter: (action: Action) => Promise<
|
|
4891
|
-
query: {
|
|
4892
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4893
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4894
|
-
};
|
|
4895
|
-
sql: {
|
|
4896
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4897
|
-
};
|
|
4898
|
-
} & {
|
|
4899
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
4900
|
-
query: {
|
|
4901
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
4902
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
4903
|
-
};
|
|
4904
|
-
sql: {
|
|
4905
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
4906
|
-
};
|
|
4907
|
-
};
|
|
4908
|
-
}>;
|
|
4932
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4909
4933
|
}; };
|
|
4910
4934
|
}>;
|
|
4911
4935
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4995,25 +5019,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4995
5019
|
})) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4996
5020
|
Context: Awaited<UserContext & {
|
|
4997
5021
|
abilities: { [key in TableRelationNames<DB>]: {
|
|
4998
|
-
filter: (action: Action) => Promise<
|
|
4999
|
-
query: {
|
|
5000
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
5001
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
5002
|
-
};
|
|
5003
|
-
sql: {
|
|
5004
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
5005
|
-
};
|
|
5006
|
-
} & {
|
|
5007
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
5008
|
-
query: {
|
|
5009
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
5010
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
5011
|
-
};
|
|
5012
|
-
sql: {
|
|
5013
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
5014
|
-
};
|
|
5015
|
-
};
|
|
5016
|
-
}>;
|
|
5022
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
5017
5023
|
}; };
|
|
5018
5024
|
}>;
|
|
5019
5025
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -5133,25 +5139,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
5133
5139
|
})) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
5134
5140
|
Context: Awaited<UserContext & {
|
|
5135
5141
|
abilities: { [key in TableRelationNames<DB>]: {
|
|
5136
|
-
filter: (action: Action) => Promise<
|
|
5137
|
-
query: {
|
|
5138
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
5139
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
5140
|
-
};
|
|
5141
|
-
sql: {
|
|
5142
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
5143
|
-
};
|
|
5144
|
-
} & {
|
|
5145
|
-
merge: (p: NonNullable<DrizzleQueryFunctionInput<DB, key>>) => {
|
|
5146
|
-
query: {
|
|
5147
|
-
single: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findFirst"]>[0]>>, "where">;
|
|
5148
|
-
many: Pick<NonNullable<NonNullable<Parameters<DB["query"][key]["findMany"]>[0]>>, "limit" | "where">;
|
|
5149
|
-
};
|
|
5150
|
-
sql: {
|
|
5151
|
-
readonly where: import("drizzle-orm").SQL<unknown> | undefined;
|
|
5152
|
-
};
|
|
5153
|
-
};
|
|
5154
|
-
}>;
|
|
5142
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
5155
5143
|
}; };
|
|
5156
5144
|
}>;
|
|
5157
5145
|
DrizzleRelations: DB["_"]["relations"];
|