@m1212e/rumble 0.24.2 → 0.25.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.
- 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 +835 -490
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts +303 -284
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts +300 -281
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +838 -496
- 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,7 @@ 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 {
|
|
14
|
-
import { Tracer } from "@opentelemetry/api";
|
|
15
|
-
import SchemaBuilder from "@pothos/core";
|
|
16
|
-
import { TracingWrapperOptions } from "@pothos/tracing-opentelemetry";
|
|
17
|
+
import { PhoneNumber } from "libphonenumber-js";
|
|
17
18
|
//#endregion
|
|
18
19
|
//#region lib/helpers/asserts.d.ts
|
|
19
20
|
/**
|
|
@@ -170,6 +171,25 @@ type DrizzleQueryFunctionInput<DB extends DrizzleInstance, QueryField extends ke
|
|
|
170
171
|
*/
|
|
171
172
|
type DrizzleTableValueType<DB extends DrizzleInstance, QueryField extends keyof DrizzleQueryFunction<DB>> = NonNullable<Awaited<ReturnType<DrizzleQueryFunction<DB>[QueryField]["findFirst"]>>>;
|
|
172
173
|
//#endregion
|
|
174
|
+
//#region lib/abilityBuilder/queryFilter.d.ts
|
|
175
|
+
/**
|
|
176
|
+
* Static, non changing query filter input type for a specific table
|
|
177
|
+
*/
|
|
178
|
+
type StaticQueryFilter<DB extends DrizzleInstance, Table extends keyof DrizzleQueryFunction<DB>, Filter extends DrizzleQueryFunctionInput<DB, Table>> = Filter;
|
|
179
|
+
/**
|
|
180
|
+
* Dynamic, context based query filter input type for a specific table
|
|
181
|
+
*/
|
|
182
|
+
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">;
|
|
183
|
+
/**
|
|
184
|
+
* Combined query filter type for a specific table. May be static or dynamic.
|
|
185
|
+
*/
|
|
186
|
+
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>;
|
|
187
|
+
/**
|
|
188
|
+
* The query filters registered per action. "unrestricted" when a bare allow()
|
|
189
|
+
* granted the action without conditions.
|
|
190
|
+
*/
|
|
191
|
+
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">;
|
|
192
|
+
//#endregion
|
|
173
193
|
//#region lib/runtimeFiltersPlugin/filterTypes.d.ts
|
|
174
194
|
type Prefetch<Context, ReturnType> = (params: {
|
|
175
195
|
context: Context;
|
|
@@ -184,6 +204,240 @@ type FilterPrefetchCombo<Context, FilteredEntityType, PrefetchReturnType = never
|
|
|
184
204
|
prefetch?: Prefetch<Context, PrefetchReturnType>;
|
|
185
205
|
};
|
|
186
206
|
//#endregion
|
|
207
|
+
//#region lib/types/rumbleInput.d.ts
|
|
208
|
+
interface RumbleLogger {
|
|
209
|
+
info(obj: Record<string, unknown>, msg: string): void;
|
|
210
|
+
warn(obj: Record<string, unknown>, msg: string): void;
|
|
211
|
+
error(obj: Record<string, unknown>, msg: string): void;
|
|
212
|
+
debug(obj: Record<string, unknown>, msg: string): void;
|
|
213
|
+
child(bindings: Record<string, unknown>): RumbleLogger;
|
|
214
|
+
}
|
|
215
|
+
type CustomRumblePothosConfig = Omit<ConstructorParameters<typeof SchemaBuilder>[0], "smartSubscriptions" | "drizzle" | "validation">;
|
|
216
|
+
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>> = {
|
|
217
|
+
/**
|
|
218
|
+
* Your drizzle database instance
|
|
219
|
+
*/
|
|
220
|
+
db: DB;
|
|
221
|
+
/**
|
|
222
|
+
* The drizzle schema object (the same one passed to `defineRelations`).
|
|
223
|
+
*/
|
|
224
|
+
schema: Schema;
|
|
225
|
+
/**
|
|
226
|
+
* A function for providing context for each request based on the incoming HTTP Request.
|
|
227
|
+
* The type of the parameter equals the HTTPRequest type of your chosen server.
|
|
228
|
+
*/
|
|
229
|
+
context?: ((event: RequestEvent) => Promise<UserContext> | UserContext) | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* The actions that are available
|
|
232
|
+
*/
|
|
233
|
+
actions?: Action[];
|
|
234
|
+
/**
|
|
235
|
+
* Customization for subscriptions. See https://the-guild.dev/graphql/yoga-server/docs/features/subscriptions#distributed-pubsub-for-production
|
|
236
|
+
*/
|
|
237
|
+
subscriptions?: Parameters<typeof createPubSub>;
|
|
238
|
+
/**
|
|
239
|
+
* Options passed along to the pothos schema builder.
|
|
240
|
+
*/
|
|
241
|
+
pothosConfig?: PothosConfig;
|
|
242
|
+
/**
|
|
243
|
+
* Limits the returned amount when querying lists. Set to null to disable.
|
|
244
|
+
* @default 100
|
|
245
|
+
*/
|
|
246
|
+
defaultLimit?: number | undefined | null;
|
|
247
|
+
/**
|
|
248
|
+
* rumble supports fuzzy search for the query helpers. This enables the users of your API to search for entities via fuzzy search inputs.
|
|
249
|
+
* This currently only is supported by postgres databases and will fail if enabled on other dialects.
|
|
250
|
+
*
|
|
251
|
+
* Please note that this will install the pg_trgm extension on startup if your database does not have it already installed.
|
|
252
|
+
* https://www.postgresql.org/docs/current/pgtrgm.html
|
|
253
|
+
*/
|
|
254
|
+
search?: {
|
|
255
|
+
/**
|
|
256
|
+
* Whether search is enabled
|
|
257
|
+
*/
|
|
258
|
+
enabled?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* The cuttoff factor to reduce the amount of returned results.
|
|
261
|
+
* Defaults to 0.3. Lower values will return more results.
|
|
262
|
+
*/
|
|
263
|
+
threshold?: number;
|
|
264
|
+
/**
|
|
265
|
+
* Will perform a local
|
|
266
|
+
* SET cpu_operator_cost = x;
|
|
267
|
+
* for search queries. This can help to make the planner
|
|
268
|
+
* use a potential index scan instead of a sequential scan.
|
|
269
|
+
* This will not affect queries that are not using the search feature.
|
|
270
|
+
*/
|
|
271
|
+
cpu_operator_cost?: number;
|
|
272
|
+
} | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* 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.
|
|
275
|
+
*
|
|
276
|
+
* The emitted spans and attributes are identical for every transport, so an
|
|
277
|
+
* operation served via GraphQL, the SOFA REST adapter or WebSockets produces
|
|
278
|
+
* the same trace shape (see `rumble.transport` to tell them apart).
|
|
279
|
+
*/
|
|
280
|
+
otel?: {
|
|
281
|
+
/**
|
|
282
|
+
* Whether otel tracing should be enabled. This will create a tracer if none is provided.
|
|
283
|
+
*/
|
|
284
|
+
enabled?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* The tracer to use. If enabled is true and no tracer is provided, a tracer will be created.
|
|
287
|
+
*/
|
|
288
|
+
tracer?: Tracer;
|
|
289
|
+
/**
|
|
290
|
+
* You can pass options to the tracing wrapper
|
|
291
|
+
*/
|
|
292
|
+
options?: TracingWrapperOptions<unknown>;
|
|
293
|
+
/**
|
|
294
|
+
* Whether the operation source is attached to operation spans as
|
|
295
|
+
* `graphql.document`.
|
|
296
|
+
*
|
|
297
|
+
* Keep in mind that a document can carry inline argument literals, so this
|
|
298
|
+
* may contain user data.
|
|
299
|
+
* @default true
|
|
300
|
+
*/
|
|
301
|
+
includeDocument?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Whether the incoming operation variables are attached to operation spans
|
|
304
|
+
* as `graphql.variables.<name>` attributes.
|
|
305
|
+
*
|
|
306
|
+
* Variables regularly carry personal data, so you can turn this off
|
|
307
|
+
* entirely (`false`) or pass a function to redact or drop single entries
|
|
308
|
+
* before they leave the process.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* otel: {
|
|
313
|
+
* enabled: true,
|
|
314
|
+
* includeVariables: ({ password, ...rest }) => rest,
|
|
315
|
+
* }
|
|
316
|
+
* ```
|
|
317
|
+
* @default true
|
|
318
|
+
*/
|
|
319
|
+
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Structured logging for rumble internals. Pass a pino (or compatible) logger instance.
|
|
323
|
+
* When enabled, rumble emits structured log entries for GraphQL operations, ability checks,
|
|
324
|
+
* and runtime filter applications — queryable by level and field in Loki or similar.
|
|
325
|
+
*/
|
|
326
|
+
logger?: {
|
|
327
|
+
/**
|
|
328
|
+
* Whether structured logging should be enabled.
|
|
329
|
+
*/
|
|
330
|
+
enabled?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* The logger instance to use. Must satisfy the RumbleLogger interface (pino satisfies this).
|
|
333
|
+
*/
|
|
334
|
+
logger: RumbleLogger;
|
|
335
|
+
/**
|
|
336
|
+
* When both logger and otel are enabled, inject `trace_id`, `span_id` and `trace_flags`
|
|
337
|
+
* fields into every log entry emitted during a GraphQL operation. Useful for correlating
|
|
338
|
+
* log lines with traces in backends like Jaeger or Grafana Tempo.
|
|
339
|
+
* @default true
|
|
340
|
+
*/
|
|
341
|
+
injectTraceId?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Whether the incoming operation variables are attached to the operation
|
|
344
|
+
* start log entry as a `graphql.variables` object.
|
|
345
|
+
*
|
|
346
|
+
* Variables regularly carry personal data, so you can turn this off
|
|
347
|
+
* entirely (`false`) or pass a function to redact or drop single entries
|
|
348
|
+
* before they are logged.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* logger: {
|
|
353
|
+
* enabled: true,
|
|
354
|
+
* logger: pino(),
|
|
355
|
+
* includeVariables: ({ password, ...rest }) => rest,
|
|
356
|
+
* }
|
|
357
|
+
* ```
|
|
358
|
+
* @default true
|
|
359
|
+
*/
|
|
360
|
+
includeVariables?: boolean | ((variables: Record<string, unknown>) => Record<string, unknown> | undefined);
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Configures `@pothos/plugin-validation`, which rumble installs by default to power
|
|
364
|
+
* `Address`/`AddressInput`'s country-aware validation (see `implementDefaultAddressTypes`).
|
|
365
|
+
*/
|
|
366
|
+
validation?: NonNullable<ConstructorParameters<typeof SchemaBuilder>[0]>["validation"];
|
|
367
|
+
};
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region lib/abilityBuilder/columnMask.d.ts
|
|
370
|
+
type MaskColumnsInput<DB extends DrizzleInstance, Action extends string> = {
|
|
371
|
+
table: TableRelationNames<DB>;
|
|
372
|
+
action: Action;
|
|
373
|
+
abilities: Record<string, any>;
|
|
374
|
+
entities: unknown[];
|
|
375
|
+
};
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region lib/abilityBuilder/filterResponse.d.ts
|
|
378
|
+
type FindFirstConfig<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = NonNullable<Parameters<DB["query"][TableName]["findFirst"]>[0]>;
|
|
379
|
+
type FindManyConfig<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = NonNullable<Parameters<DB["query"][TableName]["findMany"]>[0]>;
|
|
380
|
+
/**
|
|
381
|
+
* The query filters of an ability, as handed out by
|
|
382
|
+
* `abilities.<table>.filter(...)`.
|
|
383
|
+
*
|
|
384
|
+
* `columns` and `extras` are set at runtime but left out of the types on
|
|
385
|
+
* purpose: a visible, loosely typed extras makes drizzle infer `{}` as the row
|
|
386
|
+
* type of findFirst/findMany, and the column flag is an internal detail anyway.
|
|
387
|
+
*/
|
|
388
|
+
type AbilityFilter<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = {
|
|
389
|
+
/**
|
|
390
|
+
* Query filters for the drizzle query API.
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* author: t.relation("author", {
|
|
394
|
+
* query: async (_args, ctx) => (await ctx.abilities.users.filter("read")).query.single,
|
|
395
|
+
* }),
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
query: {
|
|
399
|
+
/**
|
|
400
|
+
* For find first calls
|
|
401
|
+
*/
|
|
402
|
+
single: Pick<FindFirstConfig<DB, TableName>, "where">;
|
|
403
|
+
/**
|
|
404
|
+
* For find many calls
|
|
405
|
+
*/
|
|
406
|
+
many: Pick<FindManyConfig<DB, TableName>, "where" | "limit">;
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Query filters for the drizzle SQL API as used in e.g. updates.
|
|
410
|
+
* @example
|
|
411
|
+
*
|
|
412
|
+
* ```ts
|
|
413
|
+
* await db
|
|
414
|
+
* .update(schema.users)
|
|
415
|
+
* .set({
|
|
416
|
+
* name: args.newName,
|
|
417
|
+
* })
|
|
418
|
+
* .where(
|
|
419
|
+
* and(
|
|
420
|
+
* eq(schema.users.id, args.userId),
|
|
421
|
+
* (await ctx.abilities.users.filter("update")).sql.where,
|
|
422
|
+
* ),
|
|
423
|
+
* );
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
*/
|
|
427
|
+
sql: {
|
|
428
|
+
readonly where: SQL | undefined;
|
|
429
|
+
};
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* What `abilities.<table>.filter(...)` resolves to.
|
|
433
|
+
*/
|
|
434
|
+
type AbilityFilterResponse<DB extends DrizzleInstance, TableName extends TableRelationNames<DB>> = AbilityFilter<DB, TableName> & {
|
|
435
|
+
/**
|
|
436
|
+
* Merges the current query filters with the provided filters for this call only
|
|
437
|
+
*/
|
|
438
|
+
merge: (filters: NonNullable<DrizzleQueryFunctionInput<DB, TableName>>) => AbilityFilter<DB, TableName>;
|
|
439
|
+
};
|
|
440
|
+
//#endregion
|
|
187
441
|
//#region lib/scalars/address.d.ts
|
|
188
442
|
/**
|
|
189
443
|
* The shape of a postal address, modeled after the OIDC `address` claim
|
|
@@ -4401,168 +4655,6 @@ type RouteWithTypesOpts<TServerContext, TMethod extends HTTPMethod, TPath extend
|
|
|
4401
4655
|
};
|
|
4402
4656
|
type ExtractPathParamsWithPattern<TPath extends string> = Pipe<TPath, [Strings.Split<'/'>, Tuples.Filter<Strings.StartsWith<':'>>, Tuples.Map<Strings.Trim<':'>>, Tuples.ToUnion]>;
|
|
4403
4657
|
//#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
4658
|
//#region lib/rumble.d.ts
|
|
4567
4659
|
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
4660
|
schema: Schema;
|
|
@@ -4585,44 +4677,31 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4585
4677
|
*/
|
|
4586
4678
|
abilityBuilder: { [key in TableRelationNames<DB>]: {
|
|
4587
4679
|
allow: (action: Action | Action[]) => {
|
|
4588
|
-
when: (queryFilter:
|
|
4680
|
+
when: (queryFilter: QueryFilter<DB, key, DrizzleQueryFunctionInput<DB, key>, UserContext>) => void;
|
|
4589
4681
|
};
|
|
4590
4682
|
filter: (action: Action | Action[]) => {
|
|
4683
|
+
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>, never>) => void;
|
|
4591
4684
|
prefetch: <PrefetchReturnType>(prefetch: Prefetch<UserContext, PrefetchReturnType>) => {
|
|
4592
4685
|
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>, PrefetchReturnType>) => void;
|
|
4593
4686
|
};
|
|
4594
|
-
by: (explicitFilter: Filter<UserContext, DrizzleTableValueType<DB, key>>) => void;
|
|
4595
4687
|
};
|
|
4596
4688
|
_: {
|
|
4597
4689
|
runtimeFilters: Map<Action, FilterPrefetchCombo<UserContext, any, any>[]>;
|
|
4598
|
-
queryFilters:
|
|
4690
|
+
queryFilters: QueryFilterRegistry<UserContext, DB, Action, key>;
|
|
4599
4691
|
};
|
|
4600
4692
|
}; } & {
|
|
4601
4693
|
_: {
|
|
4694
|
+
maskColumns: (input: MaskColumnsInput<DB, Action>) => void | Promise<void>;
|
|
4695
|
+
maskedActions: (abilities: object, table: TableRelationNames<DB>) => Set<Action>;
|
|
4696
|
+
primaryKeyHidden: (abilities: object, row: object) => boolean;
|
|
4697
|
+
registerReadAction(table: TableRelationNames<DB>, action: Action): void;
|
|
4698
|
+
readActionOf(table: TableRelationNames<DB>): Action;
|
|
4602
4699
|
registeredFilters({ action, table }: {
|
|
4603
4700
|
table: TableRelationNames<DB>;
|
|
4604
4701
|
action: Action;
|
|
4605
4702
|
}): Filter<UserContext, DrizzleTableValueType<DB, TableRelationNames<DB>>>[];
|
|
4606
4703
|
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
|
-
}>;
|
|
4704
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4626
4705
|
}; };
|
|
4627
4706
|
};
|
|
4628
4707
|
};
|
|
@@ -4632,25 +4711,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4632
4711
|
schemaBuilder: PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4633
4712
|
Context: Awaited<UserContext & {
|
|
4634
4713
|
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
|
-
}>;
|
|
4714
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4654
4715
|
}; };
|
|
4655
4716
|
}>;
|
|
4656
4717
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4790,25 +4851,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4790
4851
|
adjust?: ((t: import("@pothos/plugin-drizzle").DrizzleObjectFieldBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4791
4852
|
Context: Awaited<UserContext & {
|
|
4792
4853
|
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
|
-
}>;
|
|
4854
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4812
4855
|
}; };
|
|
4813
4856
|
}>;
|
|
4814
4857
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4887,25 +4930,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4887
4930
|
}) => import("@pothos/plugin-drizzle").DrizzleObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4888
4931
|
Context: Awaited<UserContext & {
|
|
4889
4932
|
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
|
-
}>;
|
|
4933
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
4909
4934
|
}; };
|
|
4910
4935
|
}>;
|
|
4911
4936
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -4995,25 +5020,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
4995
5020
|
})) => PothosSchemaTypes.InputObjectRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
4996
5021
|
Context: Awaited<UserContext & {
|
|
4997
5022
|
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
|
-
}>;
|
|
5023
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
5017
5024
|
}; };
|
|
5018
5025
|
}>;
|
|
5019
5026
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -5133,25 +5140,7 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
5133
5140
|
})) => PothosSchemaTypes.EnumRef<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
5134
5141
|
Context: Awaited<UserContext & {
|
|
5135
5142
|
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
|
-
}>;
|
|
5143
|
+
filter: (action: Action) => Promise<AbilityFilterResponse<DB, key>>;
|
|
5155
5144
|
}; };
|
|
5156
5145
|
}>;
|
|
5157
5146
|
DrizzleRelations: DB["_"]["relations"];
|
|
@@ -5244,6 +5233,36 @@ export declare const rumble: <UserContext extends Record<string, any>, DB extend
|
|
|
5244
5233
|
buildSchema: () => GraphQLSchema;
|
|
5245
5234
|
};
|
|
5246
5235
|
//#endregion
|
|
5236
|
+
//#region lib/scalars/emailAddress.d.ts
|
|
5237
|
+
/**
|
|
5238
|
+
* Validates an email address using graphql-scalars' own format check, then lowercases it, exactly
|
|
5239
|
+
* as the `EmailAddress` scalar does. Exported for values that do not arrive as GraphQL input,
|
|
5240
|
+
* such as OIDC claims.
|
|
5241
|
+
*
|
|
5242
|
+
* @throws RumbleErrorSafe if the value is not a valid email address
|
|
5243
|
+
*/
|
|
5244
|
+
export declare const normalizeEmailAddress: (value: unknown) => string;
|
|
5245
|
+
//#endregion
|
|
5246
|
+
//#region lib/scalars/personName.d.ts
|
|
5247
|
+
/**
|
|
5248
|
+
* Normalizes and validates a person's name, exactly as the `PersonName` scalar does. Exported
|
|
5249
|
+
* for values that do not arrive as GraphQL input, such as OIDC claims.
|
|
5250
|
+
*
|
|
5251
|
+
* @throws RumbleErrorSafe if the value is not a valid name
|
|
5252
|
+
*/
|
|
5253
|
+
export declare const normalizePersonName: (value: unknown) => string;
|
|
5254
|
+
//#endregion
|
|
5255
|
+
//#region lib/scalars/phoneNumber.d.ts
|
|
5256
|
+
/**
|
|
5257
|
+
* Parses and validates a phone number using libphonenumber-js (Google's phone number metadata),
|
|
5258
|
+
* which checks real per-country validity (length, area code plausibility, ...) rather than just
|
|
5259
|
+
* the E.164 shape. This is what the `PhoneNumber` scalar does with its input; exported for values
|
|
5260
|
+
* that do not arrive as GraphQL input. `.number` of the result is the E.164 form.
|
|
5261
|
+
*
|
|
5262
|
+
* @throws RumbleErrorSafe if the value is not a valid phone number
|
|
5263
|
+
*/
|
|
5264
|
+
export declare const parsePhoneNumber: (value: unknown) => PhoneNumber;
|
|
5265
|
+
//#endregion
|
|
5247
5266
|
//#region lib/types/rumbleError.d.ts
|
|
5248
5267
|
/**
|
|
5249
5268
|
* An error that gets raised by rumble whenever something does not go according to plan.
|