@leaven-graphql/nestjs 0.1.0 → 0.2.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/LICENSE +1 -1
- package/README.md +408 -23
- package/dist/decorators.d.ts +92 -3
- package/dist/decorators.d.ts.map +1 -1
- package/dist/driver.d.ts +107 -8
- package/dist/driver.d.ts.map +1 -1
- package/dist/execution-context.d.ts +46 -2
- package/dist/execution-context.d.ts.map +1 -1
- package/dist/graphql-driver.d.ts +180 -0
- package/dist/graphql-driver.d.ts.map +1 -0
- package/dist/guards.d.ts +57 -11
- package/dist/guards.d.ts.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1577 -792
- package/dist/interceptors.d.ts +41 -5
- package/dist/interceptors.d.ts.map +1 -1
- package/dist/middleware.d.ts +100 -4
- package/dist/middleware.d.ts.map +1 -1
- package/dist/module.d.ts +77 -12
- package/dist/module.d.ts.map +1 -1
- package/dist/schema-builder.d.ts +39 -10
- package/dist/schema-builder.d.ts.map +1 -1
- package/dist/subscriptions.d.ts +346 -22
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/types.d.ts +188 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -12
package/dist/guards.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @leaven-graphql/nestjs - Guards
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2026
|
|
4
|
+
* Copyright 2026 Joseph Quinn
|
|
5
5
|
* Licensed under the Apache License, Version 2.0
|
|
6
6
|
*/
|
|
7
7
|
import { type CanActivate, type ExecutionContext } from '@nestjs/common';
|
|
@@ -19,6 +19,26 @@ export declare const ROLES_KEY = "leaven:roles";
|
|
|
19
19
|
* Metadata key for required permissions
|
|
20
20
|
*/
|
|
21
21
|
export declare const PERMISSIONS_KEY = "leaven:permissions";
|
|
22
|
+
/**
|
|
23
|
+
* Injection token under which the module must provide the maximum allowed
|
|
24
|
+
* query complexity (see `LeavenModuleOptions.maxComplexity`) for
|
|
25
|
+
* `ComplexityGuard`.
|
|
26
|
+
*
|
|
27
|
+
* Overriding this provider with a finite limit while leaving
|
|
28
|
+
* `LeavenModuleOptions.maxComplexity` unset rejects every request: the driver
|
|
29
|
+
* measures complexity only when the *option* is set, and the guard fails
|
|
30
|
+
* closed on an unmeasured request. Set the option too.
|
|
31
|
+
*/
|
|
32
|
+
export declare const LEAVEN_MAX_COMPLEXITY = "LEAVEN_MAX_COMPLEXITY";
|
|
33
|
+
/**
|
|
34
|
+
* Injection token under which the module must provide the maximum allowed
|
|
35
|
+
* query depth (see `LeavenModuleOptions.maxDepth`) for `DepthGuard`.
|
|
36
|
+
*
|
|
37
|
+
* As with {@link LEAVEN_MAX_COMPLEXITY}, a finite override is only meaningful
|
|
38
|
+
* alongside `LeavenModuleOptions.maxDepth`, which is what makes the driver
|
|
39
|
+
* measure each request's depth.
|
|
40
|
+
*/
|
|
41
|
+
export declare const LEAVEN_MAX_DEPTH = "LEAVEN_MAX_DEPTH";
|
|
22
42
|
/**
|
|
23
43
|
* Mark a resolver as public (no authentication required)
|
|
24
44
|
*
|
|
@@ -78,6 +98,9 @@ export declare class AuthGuard implements CanActivate {
|
|
|
78
98
|
canActivate(context: ExecutionContext): boolean;
|
|
79
99
|
/**
|
|
80
100
|
* Get GraphQL context from execution context
|
|
101
|
+
*
|
|
102
|
+
* Delegates to the shared `execution-context` helper, which owns the
|
|
103
|
+
* positional assumption (`GQL_RESOLVER_ARGS`) about resolver arguments.
|
|
81
104
|
*/
|
|
82
105
|
protected getGqlContext(context: ExecutionContext): GqlContext;
|
|
83
106
|
/**
|
|
@@ -107,6 +130,9 @@ export declare class RolesGuard implements CanActivate {
|
|
|
107
130
|
canActivate(context: ExecutionContext): boolean;
|
|
108
131
|
/**
|
|
109
132
|
* Get GraphQL context from execution context
|
|
133
|
+
*
|
|
134
|
+
* Delegates to the shared `execution-context` helper, which owns the
|
|
135
|
+
* positional assumption (`GQL_RESOLVER_ARGS`) about resolver arguments.
|
|
110
136
|
*/
|
|
111
137
|
protected getGqlContext(context: ExecutionContext): GqlContext;
|
|
112
138
|
/**
|
|
@@ -140,6 +166,9 @@ export declare class PermissionsGuard implements CanActivate {
|
|
|
140
166
|
canActivate(context: ExecutionContext): boolean;
|
|
141
167
|
/**
|
|
142
168
|
* Get GraphQL context from execution context
|
|
169
|
+
*
|
|
170
|
+
* Delegates to the shared `execution-context` helper, which owns the
|
|
171
|
+
* positional assumption (`GQL_RESOLVER_ARGS`) about resolver arguments.
|
|
143
172
|
*/
|
|
144
173
|
protected getGqlContext(context: ExecutionContext): GqlContext;
|
|
145
174
|
/**
|
|
@@ -155,29 +184,46 @@ export declare class PermissionsGuard implements CanActivate {
|
|
|
155
184
|
/**
|
|
156
185
|
* Complexity limit guard
|
|
157
186
|
*
|
|
158
|
-
* Prevents queries that exceed complexity limits.
|
|
187
|
+
* Prevents queries that exceed complexity limits. `LeavenDriver` computes
|
|
188
|
+
* each request's complexity before execution and records it on the request
|
|
189
|
+
* context as `_queryComplexity`; this guard rejects the request when that
|
|
190
|
+
* value exceeds the limit provided via the `LEAVEN_MAX_COMPLEXITY`
|
|
191
|
+
* injection token.
|
|
192
|
+
*
|
|
193
|
+
* Whenever a finite limit is configured the guard fails **closed**: a request
|
|
194
|
+
* whose complexity is missing or non-numeric — analysis never ran, or it
|
|
195
|
+
* failed — is rejected rather than allowed through unmeasured.
|
|
196
|
+
*
|
|
197
|
+
* With no limit configured the module supplies the `Infinity` sentinel. There
|
|
198
|
+
* is then nothing to enforce, and the driver does not compute
|
|
199
|
+
* `_queryComplexity` at all, so the guard admits every request instead of
|
|
200
|
+
* rejecting them all for a measurement nobody asked for.
|
|
159
201
|
*/
|
|
160
202
|
export declare class ComplexityGuard implements CanActivate {
|
|
161
203
|
private readonly maxComplexity;
|
|
162
204
|
constructor(maxComplexity: number);
|
|
163
205
|
canActivate(context: ExecutionContext): boolean;
|
|
164
|
-
/**
|
|
165
|
-
* Get GraphQL context from execution context
|
|
166
|
-
*/
|
|
167
|
-
private getGqlContext;
|
|
168
206
|
}
|
|
169
207
|
/**
|
|
170
208
|
* Depth limit guard
|
|
171
209
|
*
|
|
172
|
-
* Prevents queries that exceed depth limits.
|
|
210
|
+
* Prevents queries that exceed depth limits. `LeavenDriver` computes each
|
|
211
|
+
* request's depth before execution and records it on the request context as
|
|
212
|
+
* `_queryDepth`; this guard rejects the request when that value exceeds the
|
|
213
|
+
* limit provided via the `LEAVEN_MAX_DEPTH` injection token.
|
|
214
|
+
*
|
|
215
|
+
* Whenever a finite limit is configured the guard fails **closed**: a request
|
|
216
|
+
* whose depth is missing or non-numeric — analysis never ran, or it failed —
|
|
217
|
+
* is rejected rather than allowed through unmeasured.
|
|
218
|
+
*
|
|
219
|
+
* With no limit configured the module supplies the `Infinity` sentinel. There
|
|
220
|
+
* is then nothing to enforce, and the driver does not compute `_queryDepth` at
|
|
221
|
+
* all, so the guard admits every request instead of rejecting them all for a
|
|
222
|
+
* measurement nobody asked for.
|
|
173
223
|
*/
|
|
174
224
|
export declare class DepthGuard implements CanActivate {
|
|
175
225
|
private readonly maxDepth;
|
|
176
226
|
constructor(maxDepth: number);
|
|
177
227
|
canActivate(context: ExecutionContext): boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Get GraphQL context from execution context
|
|
180
|
-
*/
|
|
181
|
-
private getGqlContext;
|
|
182
228
|
}
|
|
183
229
|
//# sourceMappingURL=guards.d.ts.map
|
package/dist/guards.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"gu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|
-
* Copyright 2026
|
|
24
|
+
* Copyright 2026 Joseph Quinn
|
|
25
25
|
* Licensed under the Apache License, Version 2.0
|
|
26
26
|
*/
|
|
27
|
-
export { LeavenModule, LEAVEN_MODULE_OPTIONS, LEAVEN_DRIVER } from './module';
|
|
27
|
+
export { LeavenModule, LEAVEN_MODULE_OPTIONS, LEAVEN_DRIVER, LEAVEN_PUBSUB } from './module';
|
|
28
28
|
export { LeavenDriver, type HandlerResult } from './driver';
|
|
29
|
-
export
|
|
29
|
+
export { LeavenGraphQLDriver, type LeavenDriverConfig } from './graphql-driver';
|
|
30
|
+
export type { LeavenModuleOptions, LeavenModuleAsyncOptions, LeavenModuleFactoryAsyncOptions, LeavenModuleClassAsyncOptions, LeavenModuleExistingAsyncOptions, LeavenOptionsFactory, BuildSchemaOptions, DirectiveDefinition, ContextFactory, FormatErrorFn, GraphQLFormattedError,
|
|
31
|
+
/** @deprecated Has no effect; removal target 0.3.0. */
|
|
32
|
+
LeavenPlugin,
|
|
33
|
+
/** @deprecated Has no effect; removal target 0.3.0. */
|
|
34
|
+
PluginContext, CorsOptions, GqlContext, GqlExecutionContext as GqlExecutionContextInterface, } from './types';
|
|
30
35
|
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';
|
|
36
|
+
export { AuthGuard, RolesGuard, PermissionsGuard, ComplexityGuard, DepthGuard, Public, Roles, Permissions, IS_PUBLIC_KEY, ROLES_KEY, PERMISSIONS_KEY, LEAVEN_MAX_COMPLEXITY, LEAVEN_MAX_DEPTH, } from './guards';
|
|
32
37
|
export { LoggingInterceptor, ErrorFormattingInterceptor, ComplexityInterceptor, CachingInterceptor, MetricsInterceptor, type OperationMetrics, type MetricsSummary, } from './interceptors';
|
|
33
38
|
export { GraphQLMiddleware, createGraphQLMiddleware } from './middleware';
|
|
34
39
|
export { GqlExecutionContext, getGqlContext, getGqlArgs, getGqlInfo, getGqlRoot, } from './execution-context';
|
|
35
40
|
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';
|
|
41
|
+
export { SubscriptionManager, Subscription, InjectPubSub, type SubscriptionConfig, type SubscriptionContext, type SubscriptionSocket, type BunWebSocketConfig, type SubscribeMessage, type CompleteMessage, type ExecutionArgs, } from './subscriptions';
|
|
37
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
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,aAAa,EAAE,MAAM,UAAU,CAAC;AAG7F,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAI5D,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,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