@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,229 @@
1
+ /**
2
+ * @leaven-graphql/nestjs - Type definitions
3
+ *
4
+ * Copyright 2026 Pegasus Heavy Industries LLC
5
+ * Licensed under the Apache License, Version 2.0
6
+ */
7
+ import type { Type } from '@nestjs/common';
8
+ import type { ModuleMetadata } from '@nestjs/common/interfaces';
9
+ import type { GraphQLSchema, DocumentNode } from 'graphql';
10
+ import type { DocumentCacheConfig } from '@leaven-graphql/core';
11
+ /**
12
+ * Configuration options for the Leaven GraphQL module
13
+ */
14
+ export interface LeavenModuleOptions {
15
+ /**
16
+ * Path for the GraphQL endpoint
17
+ * @default '/graphql'
18
+ */
19
+ path?: string;
20
+ /**
21
+ * Pre-built GraphQL schema (schema-first approach)
22
+ */
23
+ schema?: GraphQLSchema;
24
+ /**
25
+ * Type definitions for schema-first approach
26
+ */
27
+ typeDefs?: string | DocumentNode | Array<string | DocumentNode>;
28
+ /**
29
+ * Resolvers for schema-first approach
30
+ */
31
+ resolvers?: Record<string, unknown> | Array<Record<string, unknown>>;
32
+ /**
33
+ * Enable auto-schema generation (code-first approach)
34
+ * @default true
35
+ */
36
+ autoSchemaFile?: boolean | string;
37
+ /**
38
+ * Sort schema alphabetically
39
+ * @default false
40
+ */
41
+ sortSchema?: boolean;
42
+ /**
43
+ * Build schema options for code-first
44
+ */
45
+ buildSchemaOptions?: BuildSchemaOptions;
46
+ /**
47
+ * Enable GraphQL Playground
48
+ * @default true in development
49
+ */
50
+ playground?: boolean;
51
+ /**
52
+ * Enable introspection
53
+ * @default true in development
54
+ */
55
+ introspection?: boolean;
56
+ /**
57
+ * Document cache configuration
58
+ */
59
+ cache?: DocumentCacheConfig | boolean;
60
+ /**
61
+ * Maximum query complexity allowed
62
+ */
63
+ maxComplexity?: number;
64
+ /**
65
+ * Maximum query depth allowed
66
+ */
67
+ maxDepth?: number;
68
+ /**
69
+ * Enable execution metrics
70
+ * @default false
71
+ */
72
+ metrics?: boolean;
73
+ /**
74
+ * Enable debug mode
75
+ * @default false
76
+ */
77
+ debug?: boolean;
78
+ /**
79
+ * Context factory function
80
+ */
81
+ context?: ContextFactory;
82
+ /**
83
+ * Format error function
84
+ */
85
+ formatError?: FormatErrorFn;
86
+ /**
87
+ * Plugins to use
88
+ */
89
+ plugins?: LeavenPlugin[];
90
+ /**
91
+ * Enable CORS
92
+ */
93
+ cors?: boolean | CorsOptions;
94
+ /**
95
+ * Include stack traces in errors (development only)
96
+ * @default false
97
+ */
98
+ includeStacktraceInErrorResponses?: boolean;
99
+ }
100
+ /**
101
+ * Options for async module configuration
102
+ */
103
+ export interface LeavenModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
104
+ /**
105
+ * Existing provider to use
106
+ */
107
+ useExisting?: Type<LeavenOptionsFactory>;
108
+ /**
109
+ * Class to instantiate
110
+ */
111
+ useClass?: Type<LeavenOptionsFactory>;
112
+ /**
113
+ * Factory function
114
+ */
115
+ useFactory?: (...args: unknown[]) => Promise<LeavenModuleOptions> | LeavenModuleOptions;
116
+ /**
117
+ * Injection tokens for factory
118
+ */
119
+ inject?: unknown[];
120
+ }
121
+ /**
122
+ * Factory interface for creating Leaven options
123
+ */
124
+ export interface LeavenOptionsFactory {
125
+ createLeavenOptions(): Promise<LeavenModuleOptions> | LeavenModuleOptions;
126
+ }
127
+ /**
128
+ * Build schema options for code-first approach
129
+ */
130
+ export interface BuildSchemaOptions {
131
+ /**
132
+ * Date scalar mode
133
+ */
134
+ dateScalarMode?: 'isoDate' | 'timestamp';
135
+ /**
136
+ * Number scalar mode
137
+ */
138
+ numberScalarMode?: 'integer' | 'float';
139
+ /**
140
+ * Skip check for resolvers
141
+ */
142
+ skipCheck?: boolean;
143
+ /**
144
+ * Orphaned types to include
145
+ */
146
+ orphanedTypes?: Type[];
147
+ /**
148
+ * Directives to include
149
+ */
150
+ directives?: DirectiveDefinition[];
151
+ }
152
+ /**
153
+ * Directive definition
154
+ */
155
+ export interface DirectiveDefinition {
156
+ name: string;
157
+ locations: string[];
158
+ args?: Record<string, unknown>;
159
+ }
160
+ /**
161
+ * Context factory function type
162
+ */
163
+ export type ContextFactory<TContext = Record<string, unknown>> = (request: Request, response: Response) => TContext | Promise<TContext>;
164
+ /**
165
+ * Error formatting function
166
+ */
167
+ export type FormatErrorFn = (error: GraphQLFormattedError) => GraphQLFormattedError;
168
+ /**
169
+ * GraphQL formatted error
170
+ */
171
+ export interface GraphQLFormattedError {
172
+ message: string;
173
+ locations?: Array<{
174
+ line: number;
175
+ column: number;
176
+ }>;
177
+ path?: Array<string | number>;
178
+ extensions?: Record<string, unknown>;
179
+ }
180
+ /**
181
+ * Plugin interface
182
+ */
183
+ export interface LeavenPlugin {
184
+ name: string;
185
+ onInit?: () => void | Promise<void>;
186
+ onRequest?: (context: PluginContext) => void | Promise<void>;
187
+ onResponse?: (context: PluginContext, response: unknown) => void | Promise<void>;
188
+ onError?: (context: PluginContext, error: Error) => void | Promise<void>;
189
+ }
190
+ /**
191
+ * Plugin context
192
+ */
193
+ export interface PluginContext {
194
+ request: Request;
195
+ response?: Response;
196
+ schema: GraphQLSchema;
197
+ document?: DocumentNode;
198
+ operationName?: string;
199
+ variables?: Record<string, unknown>;
200
+ }
201
+ /**
202
+ * CORS options
203
+ */
204
+ export interface CorsOptions {
205
+ origin?: string | string[] | boolean;
206
+ methods?: string | string[];
207
+ allowedHeaders?: string | string[];
208
+ exposedHeaders?: string | string[];
209
+ credentials?: boolean;
210
+ maxAge?: number;
211
+ }
212
+ /**
213
+ * Request context passed to resolvers
214
+ */
215
+ export interface GqlContext<TRequest = Request, TResponse = Response> {
216
+ req: TRequest;
217
+ res: TResponse;
218
+ [key: string]: unknown;
219
+ }
220
+ /**
221
+ * Execution context for GraphQL operations
222
+ */
223
+ export interface GqlExecutionContext {
224
+ getContext<T = GqlContext>(): T;
225
+ getRoot<T = unknown>(): T;
226
+ getArgs<T = Record<string, unknown>>(): T;
227
+ getInfo<T = unknown>(): T;
228
+ }
229
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;IAEhE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAErE;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAElC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,KAAK,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;IAEtC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM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1.0",
4
+ "description": "NestJS integration for Leaven GraphQL",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "dependencies": {
19
+ "@leaven-graphql/core": "0.1.0",
20
+ "@leaven-graphql/context": "0.1.0",
21
+ "@leaven-graphql/errors": "0.1.0"
22
+ },
23
+ "peerDependencies": {
24
+ "@nestjs/common": ">=10.0.0",
25
+ "@nestjs/core": ">=10.0.0",
26
+ "@nestjs/graphql": ">=12.0.0",
27
+ "graphql": "^16.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@nestjs/common": "^11.0.20",
31
+ "@nestjs/core": "^11.0.20",
32
+ "@nestjs/graphql": "^13.0.6",
33
+ "@nestjs/testing": "^11.0.20",
34
+ "graphql": "^16.12.0",
35
+ "reflect-metadata": "^0.2.2",
36
+ "rxjs": "^7.8.2",
37
+ "typescript": "^5.9.3"
38
+ },
39
+ "keywords": [
40
+ "nestjs",
41
+ "graphql",
42
+ "leaven",
43
+ "bun",
44
+ "api"
45
+ ],
46
+ "license": "Apache-2.0",
47
+ "author": "Pegasus Heavy Industries LLC",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/PegasusHeavyIndustries/leaven.git",
51
+ "directory": "packages/nestjs"
52
+ },
53
+ "scripts": {
54
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun --external @nestjs/* --external reflect-metadata --external rxjs --external graphql --external class-transformer --external class-validator --external @leaven-graphql/* && tsc -p tsconfig.build.json",
55
+ "clean": "rm -rf dist",
56
+ "test": "bun test",
57
+ "typecheck": "tsc --noEmit"
58
+ }
59
+ }