@leaven-graphql/nestjs 0.1.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.
@@ -0,0 +1,205 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - Decorators
3
+ *
4
+ * Copyright 2026 Pegasus Heavy Industries LLC
5
+ * Licensed under the Apache License, Version 2.0
6
+ */
7
+ /**
8
+ * Metadata key for resolver complexity
9
+ */
10
+ export declare const COMPLEXITY_KEY = "leaven:complexity";
11
+ /**
12
+ * Metadata key for field deprecation
13
+ */
14
+ export declare const DEPRECATED_KEY = "leaven:deprecated";
15
+ /**
16
+ * Metadata key for field description
17
+ */
18
+ export declare const DESCRIPTION_KEY = "leaven:description";
19
+ /**
20
+ * Metadata key for caching
21
+ */
22
+ export declare const CACHE_KEY = "leaven:cache";
23
+ /**
24
+ * Metadata key for subscription filter
25
+ */
26
+ export declare const SUBSCRIPTION_FILTER_KEY = "leaven:subscription:filter";
27
+ /**
28
+ * Inject the GraphQL context
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * @Query(() => User)
33
+ * async me(@Context() ctx: GqlContext) {
34
+ * return ctx.req.user;
35
+ * }
36
+ * ```
37
+ */
38
+ export declare const Context: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
39
+ /**
40
+ * Inject the GraphQL info object
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * @Query(() => [Post])
45
+ * async posts(@Info() info: GraphQLResolveInfo) {
46
+ * // Access field selection, etc.
47
+ * }
48
+ * ```
49
+ */
50
+ export declare const Info: (...dataOrPipes: unknown[]) => ParameterDecorator;
51
+ /**
52
+ * Inject the root/parent value
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * @ResolveField(() => String)
57
+ * async fullName(@Root() user: User) {
58
+ * return `${user.firstName} ${user.lastName}`;
59
+ * }
60
+ * ```
61
+ */
62
+ export declare const Root: (...dataOrPipes: unknown[]) => ParameterDecorator;
63
+ /**
64
+ * Alias for Root decorator
65
+ */
66
+ export declare const Parent: (...dataOrPipes: unknown[]) => ParameterDecorator;
67
+ /**
68
+ * Inject resolver arguments
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * @Query(() => User)
73
+ * async user(@Args('id') id: string) {
74
+ * return this.userService.findById(id);
75
+ * }
76
+ * ```
77
+ */
78
+ export declare const Args: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
79
+ /**
80
+ * Set complexity for a resolver
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * @Query(() => [Post])
85
+ * @Complexity(10)
86
+ * async posts() {
87
+ * return this.postService.findAll();
88
+ * }
89
+ * ```
90
+ */
91
+ export declare function Complexity(value: number | ComplexityEstimator): MethodDecorator;
92
+ /**
93
+ * Complexity estimator function type
94
+ */
95
+ export type ComplexityEstimator = (options: ComplexityEstimatorArgs) => number;
96
+ /**
97
+ * Arguments for complexity estimator
98
+ */
99
+ export interface ComplexityEstimatorArgs {
100
+ field: unknown;
101
+ args: Record<string, unknown>;
102
+ childComplexity: number;
103
+ }
104
+ /**
105
+ * Mark a field as deprecated
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * @Query(() => String)
110
+ * @Deprecated('Use newField instead')
111
+ * async oldField() {
112
+ * return 'deprecated';
113
+ * }
114
+ * ```
115
+ */
116
+ export declare function Deprecated(reason: string): MethodDecorator;
117
+ /**
118
+ * Add description to a field
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * @Query(() => User)
123
+ * @Description('Fetch the currently authenticated user')
124
+ * async me() {
125
+ * return this.authService.getCurrentUser();
126
+ * }
127
+ * ```
128
+ */
129
+ export declare function Description(text: string): MethodDecorator;
130
+ /**
131
+ * Enable caching for a resolver
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * @Query(() => Settings)
136
+ * @CacheHint({ maxAge: 3600 })
137
+ * async settings() {
138
+ * return this.settingsService.getAll();
139
+ * }
140
+ * ```
141
+ */
142
+ export declare function CacheHint(options: CacheHintOptions): MethodDecorator;
143
+ /**
144
+ * Cache hint options
145
+ */
146
+ export interface CacheHintOptions {
147
+ /**
148
+ * Maximum age in seconds
149
+ */
150
+ maxAge?: number;
151
+ /**
152
+ * Cache scope
153
+ */
154
+ scope?: 'PUBLIC' | 'PRIVATE';
155
+ }
156
+ /**
157
+ * Add filter to subscription
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * @Subscription(() => Comment)
162
+ * @SubscriptionFilter((payload, variables) => payload.postId === variables.postId)
163
+ * commentAdded() {
164
+ * return pubSub.asyncIterator('COMMENT_ADDED');
165
+ * }
166
+ * ```
167
+ */
168
+ export declare function SubscriptionFilter(filter: (payload: unknown, variables: unknown, context: unknown) => boolean | Promise<boolean>): MethodDecorator;
169
+ /**
170
+ * Compose multiple decorators
171
+ *
172
+ * @example
173
+ * ```typescript
174
+ * @Query(() => [Post])
175
+ * @PublicQuery() // combines Complexity, Description, and CacheHint
176
+ * async publicPosts() {
177
+ * return this.postService.findPublic();
178
+ * }
179
+ *
180
+ * function PublicQuery() {
181
+ * return Decorators(
182
+ * Complexity(5),
183
+ * Description('Fetch public posts'),
184
+ * CacheHint({ maxAge: 60, scope: 'PUBLIC' })
185
+ * );
186
+ * }
187
+ * ```
188
+ */
189
+ export declare function Decorators(...decorators: MethodDecorator[]): MethodDecorator;
190
+ /**
191
+ * Create a custom context decorator
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * export const CurrentUser = createContextDecorator<User>('user');
196
+ *
197
+ * // Usage:
198
+ * @Query(() => Profile)
199
+ * async profile(@CurrentUser() user: User) {
200
+ * return this.profileService.getByUserId(user.id);
201
+ * }
202
+ * ```
203
+ */
204
+ export declare function createContextDecorator<T>(key: string): () => ParameterDecorator;
205
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"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e,CAEpE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC7F,eAAe,CAEjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,GAAG,UAAU,EAAE,eAAe,EAAE,GAAG,eAAe,CAE5E;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,kBAAkB,CAM/E"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - Leaven Driver for NestJS GraphQL
3
+ *
4
+ * Copyright 2026 Pegasus Heavy Industries LLC
5
+ * Licensed under the Apache License, Version 2.0
6
+ */
7
+ import { type OnModuleInit, type OnModuleDestroy } from '@nestjs/common';
8
+ import type { GraphQLSchema, DocumentNode } from 'graphql';
9
+ import { LeavenExecutor } from '@leaven-graphql/core';
10
+ import type { LeavenModuleOptions, GqlContext, GraphQLFormattedError } from './types';
11
+ /**
12
+ * Request handler result
13
+ */
14
+ export interface HandlerResult {
15
+ data?: Record<string, unknown> | null;
16
+ errors?: readonly GraphQLFormattedError[];
17
+ extensions?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Leaven Driver for NestJS GraphQL
21
+ *
22
+ * This driver integrates Leaven's high-performance GraphQL execution
23
+ * with NestJS's dependency injection and module system.
24
+ */
25
+ export declare class LeavenDriver implements OnModuleInit, OnModuleDestroy {
26
+ private executor;
27
+ private schema;
28
+ private readonly options;
29
+ constructor(options: LeavenModuleOptions);
30
+ /**
31
+ * Initialize the driver with a schema
32
+ */
33
+ onModuleInit(): Promise<void>;
34
+ /**
35
+ * Cleanup resources on module destroy
36
+ */
37
+ onModuleDestroy(): Promise<void>;
38
+ /**
39
+ * Set the GraphQL schema
40
+ */
41
+ setSchema(schema: GraphQLSchema): void;
42
+ /**
43
+ * Get the current schema
44
+ */
45
+ getSchema(): GraphQLSchema | null;
46
+ /**
47
+ * Get the executor instance
48
+ */
49
+ getExecutor(): LeavenExecutor | null;
50
+ /**
51
+ * Initialize the Leaven executor
52
+ */
53
+ private initializeExecutor;
54
+ /**
55
+ * Execute a GraphQL request
56
+ */
57
+ execute<TData = Record<string, unknown>>(query: string | DocumentNode, variables?: Record<string, unknown>, context?: GqlContext, operationName?: string): Promise<HandlerResult>;
58
+ /**
59
+ * Handle an HTTP request
60
+ */
61
+ handleRequest(request: Request, response: Response): Promise<HandlerResult>;
62
+ /**
63
+ * Parse the request body
64
+ */
65
+ private parseRequestBody;
66
+ /**
67
+ * Create context for the request
68
+ */
69
+ private createContext;
70
+ /**
71
+ * Convert DocumentNode to string
72
+ */
73
+ private documentToString;
74
+ /**
75
+ * Check if playground should be enabled
76
+ */
77
+ isPlaygroundEnabled(): boolean;
78
+ /**
79
+ * Check if introspection should be enabled
80
+ */
81
+ isIntrospectionEnabled(): boolean;
82
+ /**
83
+ * Get the GraphQL path
84
+ */
85
+ getPath(): string;
86
+ /**
87
+ * Get cache statistics
88
+ */
89
+ getCacheStats(): ReturnType<LeavenExecutor['getCacheStats']> | null;
90
+ /**
91
+ * Clear all caches
92
+ */
93
+ clearCaches(): void;
94
+ }
95
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../src/driver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,KAA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AAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC;IAYzB;;OAEG;YACW,gBAAgB;IAiC9B;;OAEG;YACW,aAAa;IAiB3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;IACI,mBAAmB,IAAI,OAAO;IAOrC;;OAEG;IACI,sBAAsB,IAAI,OAAO;IAOxC;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,aAAa,IAAI,UAAU,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,GAAG,IAAI;IAI1E;;OAEG;IACI,WAAW,IAAI,IAAI;CAG3B"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - GraphQL Execution Context
3
+ *
4
+ * Provides a helper class for accessing GraphQL-specific context in guards,
5
+ * interceptors, and other NestJS constructs.
6
+ *
7
+ * Copyright 2026 Pegasus Heavy Industries LLC
8
+ * Licensed under the Apache License, Version 2.0
9
+ */
10
+ import type { ExecutionContext, ArgumentsHost } from '@nestjs/common';
11
+ import type { GraphQLResolveInfo } from 'graphql';
12
+ import type { GqlContext } from './types';
13
+ /**
14
+ * GraphQL execution context helper
15
+ *
16
+ * Provides easy access to GraphQL resolver arguments from NestJS execution context.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * @Injectable()
21
+ * export class AuthGuard implements CanActivate {
22
+ * canActivate(context: ExecutionContext): boolean {
23
+ * const gqlContext = GqlExecutionContext.create(context);
24
+ * const ctx = gqlContext.getContext();
25
+ * const args = gqlContext.getArgs();
26
+ * const info = gqlContext.getInfo();
27
+ *
28
+ * return !!ctx.user;
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export declare class GqlExecutionContext {
34
+ private readonly host;
35
+ private readonly args;
36
+ private constructor();
37
+ /**
38
+ * Create a GqlExecutionContext from an ExecutionContext
39
+ */
40
+ static create(context: ExecutionContext): GqlExecutionContext;
41
+ /**
42
+ * Get the GraphQL context object
43
+ *
44
+ * The context is the third argument in GraphQL resolvers:
45
+ * (root, args, context, info)
46
+ */
47
+ getContext<T = GqlContext>(): T;
48
+ /**
49
+ * Get the root/parent value
50
+ *
51
+ * The root is the first argument in GraphQL resolvers:
52
+ * (root, args, context, info)
53
+ */
54
+ getRoot<T = unknown>(): T;
55
+ /**
56
+ * Get the resolver arguments
57
+ *
58
+ * The args is the second argument in GraphQL resolvers:
59
+ * (root, args, context, info)
60
+ */
61
+ getArgs<T = Record<string, unknown>>(): T;
62
+ /**
63
+ * Get the GraphQL resolve info
64
+ *
65
+ * The info is the fourth argument in GraphQL resolvers:
66
+ * (root, args, context, info)
67
+ */
68
+ getInfo<T = GraphQLResolveInfo>(): T;
69
+ /**
70
+ * Get a specific argument by name
71
+ */
72
+ getArg<T = unknown>(name: string): T | undefined;
73
+ /**
74
+ * Get a specific context property by name
75
+ */
76
+ getContextProperty<T = unknown>(name: string): T | undefined;
77
+ /**
78
+ * Get the underlying ArgumentsHost
79
+ */
80
+ getHost(): ArgumentsHost;
81
+ /**
82
+ * Get the type of the execution context
83
+ * For GraphQL resolvers, this typically returns 'graphql'
84
+ */
85
+ getType(): string;
86
+ /**
87
+ * Check if this is a GraphQL context
88
+ */
89
+ isGraphQL(): boolean;
90
+ /**
91
+ * Get the handler (method) being executed
92
+ */
93
+ getHandler(): Function | undefined;
94
+ /**
95
+ * Get the class containing the handler
96
+ */
97
+ getClass(): Function | undefined;
98
+ /**
99
+ * Get the field name being resolved
100
+ */
101
+ getFieldName(): string | undefined;
102
+ /**
103
+ * Get the parent type name
104
+ */
105
+ getParentTypeName(): string | undefined;
106
+ /**
107
+ * Get the return type name
108
+ */
109
+ getReturnTypeName(): string | undefined;
110
+ /**
111
+ * Get the operation name from the query
112
+ */
113
+ getOperationName(): string | undefined;
114
+ /**
115
+ * Get the operation type (query, mutation, subscription)
116
+ */
117
+ getOperationType(): 'query' | 'mutation' | 'subscription' | undefined;
118
+ /**
119
+ * Get the variable values from the operation
120
+ */
121
+ getVariables<T = Record<string, unknown>>(): T;
122
+ /**
123
+ * Get the path to the current field
124
+ */
125
+ getPath(): string[];
126
+ /**
127
+ * Get the requested fields (first level)
128
+ */
129
+ getSelectedFields(): string[];
130
+ }
131
+ /**
132
+ * Helper function to extract GraphQL context from execution context
133
+ */
134
+ export declare function getGqlContext<T = GqlContext>(context: ExecutionContext): T;
135
+ /**
136
+ * Helper function to extract GraphQL args from execution context
137
+ */
138
+ export declare function getGqlArgs<T = Record<string, unknown>>(context: ExecutionContext): T;
139
+ /**
140
+ * Helper function to extract GraphQL info from execution context
141
+ */
142
+ export declare function getGqlInfo<T = GraphQLResolveInfo>(context: ExecutionContext): T;
143
+ /**
144
+ * Helper function to extract GraphQL root from execution context
145
+ */
146
+ export declare function getGqlRoot<T = unknown>(context: ExecutionContext): T;
147
+ //# sourceMappingURL=execution-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-context.d.ts","sourceRoot":"","sources":["../src/execution-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,mBAAmB;IAGV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IAEjC,OAAO;IAIP;;OAEG;WACW,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB;IAIpE;;;;;OAKG;IACI,UAAU,CAAC,CAAC,GAAG,UAAU,KAAK,CAAC;IAItC;;;;;OAKG;IACI,OAAO,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC;IAIhC;;;;;OAKG;IACI,OAAO,CAAC,CAAC,GAAG,MAAM,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EG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,kBAAkB,EAAE,OAAO,EAAE,gBAAgB,GAAG,CAAC,CAE/E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,CAAC,CAEpE"}
@@ -0,0 +1,183 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - Guards
3
+ *
4
+ * Copyright 2026 Pegasus Heavy Industries LLC
5
+ * Licensed under the Apache License, Version 2.0
6
+ */
7
+ import { type CanActivate, type ExecutionContext } from '@nestjs/common';
8
+ import { Reflector } from '@nestjs/core';
9
+ import type { GqlContext } from './types';
10
+ /**
11
+ * Metadata key for public resolvers
12
+ */
13
+ export declare const IS_PUBLIC_KEY = "leaven:isPublic";
14
+ /**
15
+ * Metadata key for required roles
16
+ */
17
+ export declare const ROLES_KEY = "leaven:roles";
18
+ /**
19
+ * Metadata key for required permissions
20
+ */
21
+ export declare const PERMISSIONS_KEY = "leaven:permissions";
22
+ /**
23
+ * Mark a resolver as public (no authentication required)
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * @Query(() => String)
28
+ * @Public()
29
+ * async publicInfo() {
30
+ * return 'This is public';
31
+ * }
32
+ * ```
33
+ */
34
+ export declare const Public: () => ClassDecorator & MethodDecorator;
35
+ /**
36
+ * Require specific roles
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * @Query(() => [User])
41
+ * @Roles('admin', 'moderator')
42
+ * async users() {
43
+ * return this.userService.findAll();
44
+ * }
45
+ * ```
46
+ */
47
+ export declare const Roles: (...roles: string[]) => ClassDecorator & MethodDecorator;
48
+ /**
49
+ * Require specific permissions
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * @Mutation(() => User)
54
+ * @Permissions('user:write', 'user:delete')
55
+ * async deleteUser(@Args('id') id: string) {
56
+ * return this.userService.delete(id);
57
+ * }
58
+ * ```
59
+ */
60
+ export declare const Permissions: (...permissions: string[]) => ClassDecorator & MethodDecorator;
61
+ /**
62
+ * Authentication guard for GraphQL resolvers
63
+ *
64
+ * Ensures the user is authenticated before accessing protected resolvers.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * @UseGuards(AuthGuard)
69
+ * @Resolver(() => User)
70
+ * export class UserResolver {
71
+ * // All resolvers in this class require authentication
72
+ * }
73
+ * ```
74
+ */
75
+ export declare class AuthGuard implements CanActivate {
76
+ private readonly reflector;
77
+ constructor(reflector: Reflector);
78
+ canActivate(context: ExecutionContext): boolean;
79
+ /**
80
+ * Get GraphQL context from execution context
81
+ */
82
+ protected getGqlContext(context: ExecutionContext): GqlContext;
83
+ /**
84
+ * Extract user from context
85
+ * Override this method to customize user extraction
86
+ */
87
+ protected extractUser(context: GqlContext): unknown;
88
+ }
89
+ /**
90
+ * Role-based access guard
91
+ *
92
+ * Ensures the user has the required roles.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * @UseGuards(AuthGuard, RolesGuard)
97
+ * @Roles('admin')
98
+ * @Resolver(() => Admin)
99
+ * export class AdminResolver {
100
+ * // Only admins can access these resolvers
101
+ * }
102
+ * ```
103
+ */
104
+ export declare class RolesGuard implements CanActivate {
105
+ private readonly reflector;
106
+ constructor(reflector: Reflector);
107
+ canActivate(context: ExecutionContext): boolean;
108
+ /**
109
+ * Get GraphQL context from execution context
110
+ */
111
+ protected getGqlContext(context: ExecutionContext): GqlContext;
112
+ /**
113
+ * Extract user from context
114
+ */
115
+ protected extractUser(context: GqlContext): unknown;
116
+ /**
117
+ * Extract roles from user
118
+ * Override this method to customize role extraction
119
+ */
120
+ protected extractRoles(user: unknown): string[];
121
+ }
122
+ /**
123
+ * Permission-based access guard
124
+ *
125
+ * Ensures the user has the required permissions.
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * @UseGuards(AuthGuard, PermissionsGuard)
130
+ * @Permissions('posts:read', 'posts:write')
131
+ * @Resolver(() => Post)
132
+ * export class PostResolver {
133
+ * // Users need posts:read and posts:write permissions
134
+ * }
135
+ * ```
136
+ */
137
+ export declare class PermissionsGuard implements CanActivate {
138
+ private readonly reflector;
139
+ constructor(reflector: Reflector);
140
+ canActivate(context: ExecutionContext): boolean;
141
+ /**
142
+ * Get GraphQL context from execution context
143
+ */
144
+ protected getGqlContext(context: ExecutionContext): GqlContext;
145
+ /**
146
+ * Extract user from context
147
+ */
148
+ protected extractUser(context: GqlContext): unknown;
149
+ /**
150
+ * Extract permissions from user
151
+ * Override this method to customize permission extraction
152
+ */
153
+ protected extractPermissions(user: unknown): string[];
154
+ }
155
+ /**
156
+ * Complexity limit guard
157
+ *
158
+ * Prevents queries that exceed complexity limits.
159
+ */
160
+ export declare class ComplexityGuard implements CanActivate {
161
+ private readonly maxComplexity;
162
+ constructor(maxComplexity: number);
163
+ canActivate(context: ExecutionContext): boolean;
164
+ /**
165
+ * Get GraphQL context from execution context
166
+ */
167
+ private getGqlContext;
168
+ }
169
+ /**
170
+ * Depth limit guard
171
+ *
172
+ * Prevents queries that exceed depth limits.
173
+ */
174
+ export declare class DepthGuard implements CanActivate {
175
+ private readonly maxDepth;
176
+ constructor(maxDepth: number);
177
+ canActivate(context: ExecutionContext): boolean;
178
+ /**
179
+ * Get GraphQL context from execution context
180
+ */
181
+ private getGqlContext;
182
+ }
183
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAKtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,eAAe,uB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EG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,UAAU;IAK9D;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IAQnD;;;OAGG;IACH,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE;CActD;AAED;;;;GAIG;AACH,qBACa,eAAgB,YAAW,WAAW;IAEd,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAAb,aAAa,EAAE,MAAM;IAGlE,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAatD;;OAEG;IACH,OAAO,CAAC,aAAa;CAItB;AAED;;;;GAIG;AACH,qBACa,UAAW,YAAW,WAAW;IAEd,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAGxD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAatD;;OAEG;IACH,OAAO,CAAC,aAAa;CAItB"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - NestJS integration for Leaven GraphQL
3
+ *
4
+ * This package provides seamless integration between NestJS and Leaven,
5
+ * allowing you to use Leaven's high-performance GraphQL execution engine
6
+ * within your NestJS applications.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { Module } from '@nestjs/common';
11
+ * import { LeavenModule } from '@leaven-graphql/nestjs';
12
+ *
13
+ * @Module({
14
+ * imports: [
15
+ * LeavenModule.forRoot({
16
+ * playground: true,
17
+ * introspection: true,
18
+ * }),
19
+ * ],
20
+ * })
21
+ * export class AppModule {}
22
+ * ```
23
+ *
24
+ * Copyright 2026 Pegasus Heavy Industries LLC
25
+ * Licensed under the Apache License, Version 2.0
26
+ */
27
+ export { LeavenModule, LEAVEN_MODULE_OPTIONS, LEAVEN_DRIVER } from './module';
28
+ export { LeavenDriver, type HandlerResult } from './driver';
29
+ export type { LeavenModuleOptions, LeavenModuleAsyncOptions, LeavenOptionsFactory, BuildSchemaOptions, DirectiveDefinition, ContextFactory, FormatErrorFn, GraphQLFormattedError, LeavenPlugin, PluginContext, CorsOptions, GqlContext, GqlExecutionContext as GqlExecutionContextInterface, } from './types';
30
+ export { Context, Info, Root, Parent, Args, Complexity, Deprecated, Description, CacheHint, SubscriptionFilter, Decorators, createContextDecorator, COMPLEXITY_KEY, DEPRECATED_KEY, DESCRIPTION_KEY, CACHE_KEY, SUBSCRIPTION_FILTER_KEY, type ComplexityEstimator, type ComplexityEstimatorArgs, type CacheHintOptions, } from './decorators';
31
+ export { AuthGuard, RolesGuard, PermissionsGuard, ComplexityGuard, DepthGuard, Public, Roles, Permissions, IS_PUBLIC_KEY, ROLES_KEY, PERMISSIONS_KEY, } from './guards';
32
+ export { LoggingInterceptor, ErrorFormattingInterceptor, ComplexityInterceptor, CachingInterceptor, MetricsInterceptor, type OperationMetrics, type MetricsSummary, } from './interceptors';
33
+ export { GraphQLMiddleware, createGraphQLMiddleware } from './middleware';
34
+ export { GqlExecutionContext, getGqlContext, getGqlArgs, getGqlInfo, getGqlRoot, } from './execution-context';
35
+ export { SchemaBuilderService, generateSchemaFile, getResolverMetadata, registerResolverMetadata, clearResolverMetadata, type SchemaSource, type SchemaFileOptions, type ResolverMetadata, } from './schema-builder';
36
+ export { SubscriptionManager, Subscription, InjectPubSub, type SubscriptionConfig, type SubscriptionContext, type SubscribeMessage, type CompleteMessage, type ExecutionArgs, } from './subscriptions';
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9E,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAG5D,YAAY,EACV,mBAAmB,EACn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