nitro-graphql 2.0.0-beta.4 → 2.0.0-beta.41

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.
Files changed (168) hide show
  1. package/README.md +438 -27
  2. package/dist/cli/commands/generate.d.mts +26 -0
  3. package/dist/cli/commands/generate.mjs +196 -0
  4. package/dist/cli/commands/index.d.mts +4 -0
  5. package/dist/cli/commands/index.mjs +5 -0
  6. package/dist/cli/commands/init.d.mts +46 -0
  7. package/dist/cli/commands/init.mjs +195 -0
  8. package/dist/cli/commands/validate.d.mts +10 -0
  9. package/dist/cli/commands/validate.mjs +69 -0
  10. package/dist/cli/completions.d.mts +7 -0
  11. package/dist/cli/completions.mjs +34 -0
  12. package/dist/cli/config.d.mts +75 -0
  13. package/dist/cli/config.mjs +20 -0
  14. package/dist/cli/index.d.mts +24 -0
  15. package/dist/cli/index.mjs +253 -0
  16. package/dist/config.d.mts +2 -0
  17. package/dist/config.mjs +3 -0
  18. package/dist/core/codegen/client.d.mts +23 -0
  19. package/dist/core/codegen/client.mjs +150 -0
  20. package/dist/core/codegen/document-loader.d.mts +10 -0
  21. package/dist/core/codegen/document-loader.mjs +18 -0
  22. package/dist/core/codegen/index.d.mts +8 -0
  23. package/dist/core/codegen/index.mjs +9 -0
  24. package/dist/core/codegen/plugin.d.mts +20 -0
  25. package/dist/core/codegen/plugin.mjs +30 -0
  26. package/dist/core/codegen/runtime.d.mts +20 -0
  27. package/dist/core/codegen/runtime.mjs +60 -0
  28. package/dist/core/codegen/schema-loader.d.mts +28 -0
  29. package/dist/core/codegen/schema-loader.mjs +128 -0
  30. package/dist/core/codegen/server.d.mts +28 -0
  31. package/dist/core/codegen/server.mjs +143 -0
  32. package/dist/core/codegen/validation.d.mts +13 -0
  33. package/dist/core/codegen/validation.mjs +96 -0
  34. package/dist/core/config.d.mts +50 -0
  35. package/dist/core/config.mjs +82 -0
  36. package/dist/core/constants.d.mts +188 -0
  37. package/dist/core/constants.mjs +210 -0
  38. package/dist/core/index.d.mts +33 -0
  39. package/dist/core/index.mjs +27 -0
  40. package/dist/core/manifest.d.mts +46 -0
  41. package/dist/core/manifest.mjs +76 -0
  42. package/dist/core/scanning/ast-scanner.d.mts +28 -0
  43. package/dist/core/scanning/ast-scanner.mjs +122 -0
  44. package/dist/core/scanning/common.d.mts +37 -0
  45. package/dist/core/scanning/common.mjs +60 -0
  46. package/dist/core/scanning/directives.d.mts +10 -0
  47. package/dist/core/scanning/directives.mjs +29 -0
  48. package/dist/core/scanning/documents.d.mts +21 -0
  49. package/dist/core/scanning/documents.mjs +43 -0
  50. package/dist/core/scanning/index.d.mts +7 -0
  51. package/dist/core/scanning/index.mjs +8 -0
  52. package/dist/core/scanning/resolvers.d.mts +15 -0
  53. package/dist/core/scanning/resolvers.mjs +59 -0
  54. package/dist/core/scanning/schemas.d.mts +14 -0
  55. package/dist/core/scanning/schemas.mjs +64 -0
  56. package/dist/core/schema/builder.d.mts +53 -0
  57. package/dist/core/schema/builder.mjs +70 -0
  58. package/dist/core/schema/federation.d.mts +34 -0
  59. package/dist/core/schema/federation.mjs +40 -0
  60. package/dist/core/schema/index.d.mts +3 -0
  61. package/dist/core/schema/index.mjs +4 -0
  62. package/dist/core/types/adapter.d.mts +58 -0
  63. package/dist/core/types/codegen.d.mts +133 -0
  64. package/dist/core/types/config.d.mts +210 -0
  65. package/dist/core/types/config.mjs +1 -0
  66. package/dist/{utils/define.d.ts → core/types/define.d.mts} +3 -30
  67. package/dist/core/types/define.mjs +1 -0
  68. package/dist/core/types/index.d.mts +5 -0
  69. package/dist/core/types/index.mjs +1 -0
  70. package/dist/core/types/scanning.d.mts +69 -0
  71. package/dist/core/types/scanning.mjs +1 -0
  72. package/dist/{utils/directive-parser.d.ts → core/utils/directive-parser.d.mts} +21 -4
  73. package/dist/{utils/directive-parser.js → core/utils/directive-parser.mjs} +25 -34
  74. package/dist/core/utils/errors.d.mts +77 -0
  75. package/dist/core/utils/errors.mjs +93 -0
  76. package/dist/core/utils/file-io.d.mts +24 -0
  77. package/dist/core/utils/file-io.mjs +47 -0
  78. package/dist/core/utils/imports.d.mts +15 -0
  79. package/dist/core/utils/imports.mjs +25 -0
  80. package/dist/core/utils/index.d.mts +7 -0
  81. package/dist/core/utils/index.mjs +8 -0
  82. package/dist/core/utils/logger.d.mts +19 -0
  83. package/dist/core/utils/logger.mjs +38 -0
  84. package/dist/core/utils/ofetch-templates.d.mts +30 -0
  85. package/dist/core/utils/ofetch-templates.mjs +135 -0
  86. package/dist/core/validation/external-services.d.mts +11 -0
  87. package/dist/core/validation/external-services.mjs +34 -0
  88. package/dist/core/validation/index.d.mts +2 -0
  89. package/dist/core/validation/index.mjs +3 -0
  90. package/dist/define.d.mts +294 -0
  91. package/dist/define.mjs +323 -0
  92. package/dist/index.d.mts +6 -0
  93. package/dist/index.mjs +6 -0
  94. package/dist/nitro/adapter.d.mts +30 -0
  95. package/dist/nitro/adapter.mjs +97 -0
  96. package/dist/{utils/apollo.d.ts → nitro/apollo.d.mts} +3 -3
  97. package/dist/nitro/apollo.mjs +59 -0
  98. package/dist/nitro/codegen.d.mts +19 -0
  99. package/dist/nitro/codegen.mjs +141 -0
  100. package/dist/nitro/config.d.mts +51 -0
  101. package/dist/nitro/config.mjs +57 -0
  102. package/dist/nitro/index.d.mts +46 -0
  103. package/dist/nitro/index.mjs +65 -0
  104. package/dist/nitro/paths.d.mts +54 -0
  105. package/dist/nitro/paths.mjs +92 -0
  106. package/dist/nitro/rollup.d.mts +6 -0
  107. package/dist/nitro/rollup.mjs +95 -0
  108. package/dist/nitro/routes/apollo-server.d.mts +6 -0
  109. package/dist/nitro/routes/apollo-server.mjs +71 -0
  110. package/dist/nitro/routes/debug-template.d.mts +15 -0
  111. package/dist/nitro/routes/debug-template.mjs +385 -0
  112. package/dist/nitro/routes/debug.d.mts +55 -0
  113. package/dist/nitro/routes/debug.mjs +102 -0
  114. package/dist/nitro/routes/graphql-yoga.d.mts +6 -0
  115. package/dist/nitro/routes/graphql-yoga.mjs +62 -0
  116. package/dist/nitro/routes/health.d.mts +10 -0
  117. package/dist/{routes/health.js → nitro/routes/health.mjs} +4 -3
  118. package/dist/nitro/setup/extend-loader.d.mts +19 -0
  119. package/dist/nitro/setup/extend-loader.mjs +129 -0
  120. package/dist/nitro/setup/file-watcher.d.mts +16 -0
  121. package/dist/nitro/setup/file-watcher.mjs +98 -0
  122. package/dist/nitro/setup/logging.d.mts +17 -0
  123. package/dist/nitro/setup/logging.mjs +66 -0
  124. package/dist/nitro/setup/rollup-integration.d.mts +16 -0
  125. package/dist/nitro/setup/rollup-integration.mjs +90 -0
  126. package/dist/nitro/setup/routes.d.mts +10 -0
  127. package/dist/nitro/setup/routes.mjs +35 -0
  128. package/dist/nitro/setup/ts-config.d.mts +11 -0
  129. package/dist/nitro/setup/ts-config.mjs +69 -0
  130. package/dist/nitro/setup.d.mts +12 -0
  131. package/dist/nitro/setup.mjs +234 -0
  132. package/dist/nitro/types.d.mts +374 -0
  133. package/dist/nitro/types.mjs +1 -0
  134. package/dist/nitro/virtual/generators.d.mts +31 -0
  135. package/dist/nitro/virtual/generators.mjs +113 -0
  136. package/dist/nitro/virtual/stubs.d.mts +20 -0
  137. package/dist/nitro/virtual/stubs.mjs +31 -0
  138. package/dist/{ecosystem/nuxt.d.ts → nuxt.d.mts} +1 -1
  139. package/dist/nuxt.mjs +109 -0
  140. package/dist/{graphql/server.d.ts → stubs/index.d.mts} +5 -1
  141. package/dist/stubs/index.mjs +1 -0
  142. package/package.json +102 -77
  143. package/dist/ecosystem/nuxt.js +0 -67
  144. package/dist/graphql/index.d.ts +0 -5
  145. package/dist/index.d.ts +0 -8
  146. package/dist/index.js +0 -264
  147. package/dist/rollup.js +0 -119
  148. package/dist/routes/apollo-server.d.ts +0 -6
  149. package/dist/routes/apollo-server.js +0 -89
  150. package/dist/routes/graphql-yoga.d.ts +0 -6
  151. package/dist/routes/graphql-yoga.js +0 -91
  152. package/dist/routes/health.d.ts +0 -6
  153. package/dist/types/index.d.ts +0 -128
  154. package/dist/types/standard-schema.d.ts +0 -59
  155. package/dist/utils/apollo.js +0 -61
  156. package/dist/utils/client-codegen.d.ts +0 -38
  157. package/dist/utils/client-codegen.js +0 -290
  158. package/dist/utils/define.js +0 -57
  159. package/dist/utils/index.d.ts +0 -39
  160. package/dist/utils/index.js +0 -250
  161. package/dist/utils/server-codegen.d.ts +0 -7
  162. package/dist/utils/server-codegen.js +0 -136
  163. package/dist/utils/type-generation.d.ts +0 -7
  164. package/dist/utils/type-generation.js +0 -287
  165. package/dist/vite.d.ts +0 -25
  166. package/dist/vite.js +0 -40
  167. /package/dist/{graphql/index.js → core/types/adapter.mjs} +0 -0
  168. /package/dist/{graphql/server.js → core/types/codegen.mjs} +0 -0
@@ -0,0 +1,40 @@
1
+ import { LOG_TAG } from "../constants.mjs";
2
+ import { consola as consola$1 } from "consola";
3
+
4
+ //#region src/core/schema/federation.ts
5
+ const logger = consola$1.withTag(LOG_TAG);
6
+ /**
7
+ * Cached result: function if available, false if not available, null if not checked yet
8
+ */
9
+ let buildSubgraphSchemaCache = null;
10
+ /**
11
+ * Dynamically load @apollo/subgraph for federation support.
12
+ * Returns the buildSubgraphSchema function if available, or false if the package is not installed.
13
+ * Result is cached for subsequent calls.
14
+ */
15
+ async function loadFederationSupport() {
16
+ if (buildSubgraphSchemaCache !== null) return buildSubgraphSchemaCache;
17
+ try {
18
+ buildSubgraphSchemaCache = (await import("@apollo/subgraph")).buildSubgraphSchema;
19
+ } catch {
20
+ buildSubgraphSchemaCache = false;
21
+ }
22
+ return buildSubgraphSchemaCache;
23
+ }
24
+ /**
25
+ * Log a warning when federation is enabled but @apollo/subgraph is not available.
26
+ * Uses consola logger instead of console.warn for consistent logging.
27
+ */
28
+ function warnFederationUnavailable() {
29
+ logger.warn("Federation enabled but @apollo/subgraph not available, falling back to regular schema");
30
+ }
31
+ /**
32
+ * Reset the federation support cache.
33
+ * Useful for testing or when the module needs to be reloaded.
34
+ */
35
+ function resetFederationCache() {
36
+ buildSubgraphSchemaCache = null;
37
+ }
38
+
39
+ //#endregion
40
+ export { loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -0,0 +1,3 @@
1
+ import { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
2
+ import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
3
+ export { CreateMergedSchemaOptions, DirectiveWrapper, ModuleConfig, ResolverDefinition, SchemaDefinition, buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -0,0 +1,4 @@
1
+ import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./federation.mjs";
2
+ import { buildGraphQLSchema, createMergedSchema } from "./builder.mjs";
3
+
4
+ export { buildGraphQLSchema, createMergedSchema, loadFederationSupport, resetFederationCache, warnFederationUnavailable };
@@ -0,0 +1,58 @@
1
+ import { CoreConfig, CoreContext, CoreLogger } from "./config.mjs";
2
+ import { ScanContext, ScanResult, ScannedResolver } from "./scanning.mjs";
3
+ import "./index.mjs";
4
+
5
+ //#region src/core/types/adapter.d.ts
6
+
7
+ /**
8
+ * Framework adapter interface
9
+ * Adapters convert framework-specific types to core types
10
+ */
11
+ interface FrameworkAdapter<TFramework = unknown> {
12
+ /** Adapter name for logging */
13
+ readonly name: string;
14
+ /** Create core config from framework instance */
15
+ createCoreConfig: (framework: TFramework) => CoreConfig;
16
+ /** Create core context from framework instance */
17
+ createCoreContext: (framework: TFramework) => CoreContext;
18
+ /** Create scan context from framework instance */
19
+ createScanContext: (framework: TFramework) => ScanContext;
20
+ /** Get framework logger adapted to CoreLogger interface */
21
+ getLogger: (framework: TFramework) => CoreLogger;
22
+ }
23
+ /**
24
+ * Scan adapter interface
25
+ * Provides high-level scanning operations using the framework adapter
26
+ */
27
+ interface ScanAdapter<TFramework = unknown> {
28
+ /** Scan for GraphQL schema files */
29
+ scanSchemas: (framework: TFramework) => Promise<ScanResult<string>>;
30
+ /** Scan for GraphQL files (schemas + operations) */
31
+ scanGraphql: (framework: TFramework) => Promise<ScanResult<string>>;
32
+ /** Scan for resolver files */
33
+ scanResolvers: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
34
+ /** Scan for directive files */
35
+ scanDirectives: (framework: TFramework) => Promise<ScanResult<ScannedResolver>>;
36
+ /** Scan for client documents */
37
+ scanDocuments: (framework: TFramework) => Promise<ScanResult<string>>;
38
+ }
39
+ /**
40
+ * Codegen adapter interface
41
+ * Provides high-level codegen operations using the framework adapter
42
+ */
43
+ interface CodegenAdapter<TFramework = unknown> {
44
+ /** Generate server types */
45
+ generateServerTypes: (framework: TFramework, options?: {
46
+ silent?: boolean;
47
+ }) => Promise<void>;
48
+ /** Generate client types */
49
+ generateClientTypes: (framework: TFramework, options?: {
50
+ silent?: boolean;
51
+ }) => Promise<void>;
52
+ }
53
+ /**
54
+ * Combined full adapter interface
55
+ */
56
+ interface FullFrameworkAdapter<TFramework = unknown> extends FrameworkAdapter<TFramework>, ScanAdapter<TFramework>, CodegenAdapter<TFramework> {}
57
+ //#endregion
58
+ export { CodegenAdapter, FrameworkAdapter, FullFrameworkAdapter, ScanAdapter };
@@ -0,0 +1,133 @@
1
+ import { Source } from "@graphql-tools/utils";
2
+ import { GraphQLSchema } from "graphql";
3
+
4
+ //#region src/core/types/codegen.d.ts
5
+
6
+ /**
7
+ * Scalar type mapping (can be string or input/output object)
8
+ */
9
+ type ScalarType = string | {
10
+ input: string;
11
+ output: string;
12
+ };
13
+ /**
14
+ * Server codegen configuration
15
+ */
16
+ interface ServerCodegenConfig {
17
+ scalars?: Record<string, ScalarType>;
18
+ defaultScalarType?: string;
19
+ defaultMapper?: string;
20
+ contextType?: string;
21
+ maybeValue?: string;
22
+ inputMaybeValue?: string;
23
+ declarationKind?: string;
24
+ enumsAsTypes?: boolean;
25
+ federation?: boolean;
26
+ [key: string]: unknown;
27
+ }
28
+ /**
29
+ * Client codegen configuration
30
+ */
31
+ interface ClientCodegenConfig {
32
+ emitLegacyCommonJSImports?: boolean;
33
+ useTypeImports?: boolean;
34
+ enumsAsTypes?: boolean;
35
+ strictScalars?: boolean;
36
+ maybeValue?: string;
37
+ inputMaybeValue?: string;
38
+ documentMode?: string;
39
+ pureMagicComment?: boolean;
40
+ dedupeOperationSuffix?: boolean;
41
+ rawRequest?: boolean;
42
+ scalars?: Record<string, ScalarType>;
43
+ typedDocumentNode?: boolean;
44
+ [key: string]: unknown;
45
+ }
46
+ /**
47
+ * SDK codegen configuration
48
+ */
49
+ interface SdkCodegenConfig extends ClientCodegenConfig {
50
+ [key: string]: unknown;
51
+ }
52
+ /**
53
+ * Input for server type generation
54
+ */
55
+ interface ServerCodegenInput {
56
+ /** GraphQL framework name */
57
+ framework: string;
58
+ /** Parsed GraphQL schema */
59
+ schema: GraphQLSchema;
60
+ /** Server codegen configuration */
61
+ config?: ServerCodegenConfig;
62
+ /** Whether federation is enabled */
63
+ federationEnabled?: boolean;
64
+ /** Output filename (optional) */
65
+ outputPath?: string;
66
+ }
67
+ /**
68
+ * Result of server type generation
69
+ */
70
+ interface ServerCodegenResult {
71
+ /** Generated TypeScript types content */
72
+ types: string;
73
+ /** Printed GraphQL schema */
74
+ schemaString: string;
75
+ }
76
+ /**
77
+ * Input for client type generation
78
+ */
79
+ interface ClientCodegenInput {
80
+ /** Parsed GraphQL schema */
81
+ schema: GraphQLSchema;
82
+ /** Loaded GraphQL documents */
83
+ documents: Source[];
84
+ /** Client codegen configuration */
85
+ config?: ClientCodegenConfig;
86
+ /** SDK codegen configuration */
87
+ sdkConfig?: SdkCodegenConfig;
88
+ /** Output filename (optional) */
89
+ outputPath?: string;
90
+ /** Service name for external services */
91
+ serviceName?: string;
92
+ /** Virtual types import path */
93
+ virtualTypesPath?: string;
94
+ /** Generation options */
95
+ options?: {
96
+ silent?: boolean;
97
+ isInitial?: boolean;
98
+ };
99
+ }
100
+ /**
101
+ * Result of client type generation
102
+ */
103
+ interface ClientCodegenResult {
104
+ /** Generated TypeScript types content */
105
+ types: string;
106
+ /** Generated SDK content */
107
+ sdk: string;
108
+ }
109
+ /**
110
+ * External service configuration for codegen
111
+ */
112
+ interface ExternalServiceCodegenConfig {
113
+ name: string;
114
+ schema: string | string[];
115
+ endpoint: string;
116
+ headers?: Record<string, string> | (() => Record<string, string>);
117
+ documents?: string[];
118
+ downloadSchema?: boolean | 'once' | 'always' | 'manual';
119
+ downloadPath?: string;
120
+ codegen?: {
121
+ client?: ClientCodegenConfig;
122
+ clientSDK?: SdkCodegenConfig;
123
+ };
124
+ }
125
+ /**
126
+ * Schema loading options
127
+ */
128
+ interface SchemaLoadOptions {
129
+ headers?: Record<string, string>;
130
+ loaders?: unknown[];
131
+ }
132
+ //#endregion
133
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
@@ -0,0 +1,210 @@
1
+ import { GraphQLFramework } from "../constants.mjs";
2
+
3
+ //#region src/core/types/config.d.ts
4
+
5
+ /**
6
+ * Core logger interface
7
+ * Abstracts logging functionality for framework independence
8
+ */
9
+ interface CoreLogger {
10
+ info: (message: string, ...args: unknown[]) => void;
11
+ warn: (message: string, ...args: unknown[]) => void;
12
+ error: (message: string, ...args: unknown[]) => void;
13
+ success: (message: string, ...args: unknown[]) => void;
14
+ debug: (message: string, ...args: unknown[]) => void;
15
+ }
16
+ /**
17
+ * GraphQL codegen configuration
18
+ */
19
+ interface CoreCodegenConfig {
20
+ /** Server-side codegen options */
21
+ server?: Record<string, unknown>;
22
+ /** Client-side codegen options */
23
+ client?: Record<string, unknown>;
24
+ /** Client SDK codegen options */
25
+ clientSDK?: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Security configuration options
29
+ */
30
+ interface CoreSecurityConfig {
31
+ /** Enable/disable GraphQL introspection */
32
+ introspection?: boolean;
33
+ /** Enable/disable GraphQL playground */
34
+ playground?: boolean;
35
+ /** Enable/disable error masking in responses */
36
+ maskErrors?: boolean;
37
+ /** Disable field suggestions in error messages */
38
+ disableSuggestions?: boolean;
39
+ }
40
+ /**
41
+ * External GraphQL service configuration
42
+ */
43
+ interface CoreExternalService {
44
+ /** Unique service name */
45
+ name: string;
46
+ /** GraphQL schema URL or file path */
47
+ schema: string;
48
+ /** GraphQL endpoint URL */
49
+ endpoint: string;
50
+ /** Headers for schema introspection */
51
+ headers?: Record<string, string> | (() => Record<string, string>);
52
+ /** Document patterns for this service */
53
+ documents?: string[];
54
+ /** Service-specific path overrides */
55
+ paths?: {
56
+ sdk?: string;
57
+ types?: string;
58
+ ofetch?: string;
59
+ };
60
+ }
61
+ /**
62
+ * Apollo Federation configuration
63
+ */
64
+ interface CoreFederationConfig {
65
+ /** Enable federation support */
66
+ enabled?: boolean;
67
+ /** Service name for federation */
68
+ serviceName?: string;
69
+ }
70
+ /**
71
+ * Path configuration with placeholders
72
+ */
73
+ interface CorePathsConfig {
74
+ /** Server GraphQL directory (default: 'server/graphql') */
75
+ serverDir?: string;
76
+ /** Client GraphQL directory (default: 'app/graphql' or 'graphql') */
77
+ clientDir?: string;
78
+ /** Types output directory (default: '{buildDir}/types') */
79
+ typesDir?: string;
80
+ }
81
+ /**
82
+ * Scaffold file generation configuration
83
+ */
84
+ interface CoreScaffoldConfig {
85
+ /** Master switch for all scaffold files */
86
+ enabled?: boolean;
87
+ /** Generate graphql.config.ts */
88
+ graphqlConfig?: boolean | string;
89
+ /** Generate server schema.ts */
90
+ serverSchema?: boolean | string;
91
+ /** Generate server config.ts */
92
+ serverConfig?: boolean | string;
93
+ /** Generate server context.d.ts */
94
+ serverContext?: boolean | string;
95
+ }
96
+ /**
97
+ * Type generation configuration
98
+ */
99
+ interface CoreTypesConfig {
100
+ /** Master switch for type generation */
101
+ enabled?: boolean;
102
+ /** Server types output path */
103
+ server?: boolean | string;
104
+ /** Client types output path */
105
+ client?: boolean | string;
106
+ /** External service types output path */
107
+ external?: boolean | string;
108
+ }
109
+ /**
110
+ * SDK generation configuration
111
+ */
112
+ interface CoreSdkConfig {
113
+ /** Master switch for SDK generation */
114
+ enabled?: boolean;
115
+ /** Main SDK output path */
116
+ main?: boolean | string;
117
+ /** External service SDK output path */
118
+ external?: boolean | string;
119
+ }
120
+ /**
121
+ * Client utilities configuration
122
+ */
123
+ interface CoreClientUtilsConfig {
124
+ /** Master switch for client utilities */
125
+ enabled?: boolean;
126
+ /** Index file output path */
127
+ index?: boolean | string;
128
+ /** Ofetch client output path */
129
+ ofetch?: boolean | string;
130
+ }
131
+ /**
132
+ * Core GraphQL options
133
+ * Framework-agnostic GraphQL configuration
134
+ */
135
+ interface CoreGraphQLOptions {
136
+ /** GraphQL framework to use */
137
+ framework?: GraphQLFramework;
138
+ /** GraphQL endpoint path */
139
+ endpoint?: string;
140
+ /** Codegen configuration */
141
+ codegen?: CoreCodegenConfig;
142
+ /** Security configuration */
143
+ security?: CoreSecurityConfig;
144
+ /** External GraphQL services */
145
+ externalServices?: CoreExternalService[];
146
+ /** Apollo Federation configuration */
147
+ federation?: CoreFederationConfig;
148
+ /** Path configuration */
149
+ paths?: CorePathsConfig;
150
+ /** Scaffold file configuration */
151
+ scaffold?: false | CoreScaffoldConfig;
152
+ /** Type generation configuration */
153
+ types?: false | CoreTypesConfig;
154
+ /** SDK generation configuration */
155
+ sdk?: false | CoreSdkConfig;
156
+ /** Client utilities configuration */
157
+ clientUtils?: false | CoreClientUtilsConfig;
158
+ }
159
+ /**
160
+ * Core configuration
161
+ * Main configuration interface that replaces Nitro-specific options
162
+ */
163
+ interface CoreConfig {
164
+ /** Root directory of the project */
165
+ rootDir: string;
166
+ /** Build output directory */
167
+ buildDir: string;
168
+ /** Server GraphQL directory */
169
+ serverDir: string;
170
+ /** Client GraphQL directory */
171
+ clientDir: string;
172
+ /** Types output directory */
173
+ typesDir: string;
174
+ /** GraphQL framework to use */
175
+ framework: GraphQLFramework;
176
+ /** Whether running in Nuxt context */
177
+ isNuxt: boolean;
178
+ /** Whether running in development mode */
179
+ isDev: boolean;
180
+ /** GraphQL options */
181
+ graphqlOptions: CoreGraphQLOptions;
182
+ /** Logger instance */
183
+ logger: CoreLogger;
184
+ /** Patterns to ignore during scanning */
185
+ ignorePatterns: string[];
186
+ /** Layer server directories (Nuxt) */
187
+ layerServerDirs?: string[];
188
+ /** Layer app directories (Nuxt) */
189
+ layerAppDirs?: string[];
190
+ }
191
+ /**
192
+ * Core context for runtime operations
193
+ * Holds resolved configuration and state
194
+ */
195
+ interface CoreContext {
196
+ /** Resolved configuration */
197
+ config: CoreConfig;
198
+ /** GraphQL build directory */
199
+ graphqlBuildDir: string;
200
+ /** Watch directories for file watching */
201
+ watchDirs: string[];
202
+ /** Relative directory paths */
203
+ dir: {
204
+ build: string;
205
+ client: string;
206
+ server: string;
207
+ };
208
+ }
209
+ //#endregion
210
+ export { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,23 +1,8 @@
1
1
  import { GraphQLSchema } from "graphql";
2
- import { ApolloServerOptions } from "@apollo/server";
3
- import { H3Event } from "h3";
4
- import { YogaServerOptions } from "graphql-yoga";
5
- import { NPMConfig, Resolvers, ResolversTypes } from "#graphql/server";
6
- import { StandardSchemaV1 } from "nitro-graphql";
7
2
 
8
- //#region src/utils/define.d.ts
3
+ //#region src/core/types/define.d.ts
4
+
9
5
  type Flatten<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;
10
- declare function defineSchema<T extends Partial<Record<keyof ResolversTypes, StandardSchemaV1>>>(config: T): Flatten<T>;
11
- declare function defineResolver(resolvers: Resolvers): Resolvers;
12
- type ResolverQuery = Resolvers extends {
13
- Query: infer Q;
14
- } ? Q : never;
15
- declare function defineQuery(resolvers?: Resolvers['Query']): Resolvers;
16
- declare function defineMutation(resolvers?: Resolvers['Mutation']): Resolvers;
17
- declare function defineSubscription(resolvers?: Resolvers['Subscription']): Resolvers;
18
- declare function defineType(resolvers: Resolvers): Resolvers;
19
- type DefineServerConfig<T extends NPMConfig = NPMConfig> = T['framework'] extends 'graphql-yoga' ? Partial<YogaServerOptions<H3Event, Partial<H3Event>>> : T['framework'] extends 'apollo-server' ? Partial<ApolloServerOptions<H3Event>> : Partial<YogaServerOptions<H3Event, Partial<H3Event>>> | Partial<ApolloServerOptions<H3Event>>;
20
- declare function defineGraphQLConfig<T extends NPMConfig = NPMConfig>(config: Partial<DefineServerConfig<T>>): Partial<DefineServerConfig<T>>;
21
6
  type DirectiveLocationName = 'QUERY' | 'MUTATION' | 'SUBSCRIPTION' | 'FIELD' | 'FRAGMENT_DEFINITION' | 'FRAGMENT_SPREAD' | 'INLINE_FRAGMENT' | 'VARIABLE_DEFINITION' | 'SCHEMA' | 'SCALAR' | 'OBJECT' | 'FIELD_DEFINITION' | 'ARGUMENT_DEFINITION' | 'INTERFACE' | 'UNION' | 'ENUM' | 'ENUM_VALUE' | 'INPUT_OBJECT' | 'INPUT_FIELD_DEFINITION';
22
7
  type GraphQLScalarType = 'String' | 'Int' | 'Float' | 'Boolean' | 'ID' | 'JSON' | 'DateTime';
23
8
  type GraphQLBaseType = GraphQLScalarType | (string & {});
@@ -56,17 +41,5 @@ interface DefineDirectiveConfig {
56
41
  isRepeatable?: boolean;
57
42
  transformer?: (schema: GraphQLSchema) => GraphQLSchema;
58
43
  }
59
- /**
60
- * Helper function to create directive arguments with proper type inference
61
- * @example
62
- * args: {
63
- * myArg: arg('String!', { defaultValue: 'hello' })
64
- * }
65
- */
66
- declare function arg<T extends GraphQLArgumentType>(type: T, options?: {
67
- defaultValue?: any;
68
- description?: string;
69
- }): DirectiveArgument<T>;
70
- declare function defineDirective(config: DefineDirectiveConfig): DirectiveDefinition;
71
44
  //#endregion
72
- export { DefineDirectiveConfig, DefineServerConfig, DirectiveArgument, DirectiveDefinition, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverQuery, arg, defineDirective, defineGraphQLConfig, defineMutation, defineQuery, defineResolver, defineSchema, defineSubscription, defineType };
45
+ export { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,5 @@
1
+ import { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, ExternalServiceCodegenConfig, ScalarType, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult } from "./codegen.mjs";
2
+ import { CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig } from "./config.mjs";
3
+ import { DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType } from "./define.mjs";
4
+ import { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver } from "./scanning.mjs";
5
+ export { ClientCodegenConfig, ClientCodegenInput, ClientCodegenResult, CoreClientUtilsConfig, CoreCodegenConfig, CoreConfig, CoreContext, CoreExternalService, CoreFederationConfig, CoreGraphQLOptions, CoreLogger, CorePathsConfig, CoreScaffoldConfig, CoreSdkConfig, CoreSecurityConfig, CoreTypesConfig, DefineDirectiveConfig, DirectiveArgument, DirectiveDefinition, ExternalServiceCodegenConfig, Flatten, GraphQLArgumentType, GraphQLBaseType, GraphQLScalarType, ResolverImport, ScalarType, ScanContext, ScanResult, ScannedFile, ScannedResolver, SchemaLoadOptions, SdkCodegenConfig, ServerCodegenConfig, ServerCodegenInput, ServerCodegenResult };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,69 @@
1
+ import { CoreLogger } from "./config.mjs";
2
+
3
+ //#region src/core/types/scanning.d.ts
4
+
5
+ /**
6
+ * Scan context for file scanning operations
7
+ * Provides all necessary information for scanning without framework dependencies
8
+ */
9
+ interface ScanContext {
10
+ /** Root directory of the project */
11
+ rootDir: string;
12
+ /** Server GraphQL directory */
13
+ serverDir: string;
14
+ /** Client GraphQL directory */
15
+ clientDir: string;
16
+ /** Patterns to ignore during scanning */
17
+ ignorePatterns: string[];
18
+ /** Whether running in development mode */
19
+ isDev: boolean;
20
+ /** Logger instance */
21
+ logger: CoreLogger;
22
+ /** Layer server directories (Nuxt layers) */
23
+ layerServerDirs?: string[];
24
+ /** Layer app directories (Nuxt layers) */
25
+ layerAppDirs?: string[];
26
+ }
27
+ /**
28
+ * Generic scan result wrapper
29
+ * Provides consistent result structure with warnings and errors
30
+ */
31
+ interface ScanResult<T> {
32
+ /** Scanned items */
33
+ items: T[];
34
+ /** Non-fatal warnings encountered during scanning */
35
+ warnings: string[];
36
+ /** Errors encountered during scanning */
37
+ errors: string[];
38
+ }
39
+ /**
40
+ * File information from scanning
41
+ */
42
+ interface ScannedFile {
43
+ /** Relative path from scan directory */
44
+ path: string;
45
+ /** Absolute file path */
46
+ fullPath: string;
47
+ }
48
+ /**
49
+ * Resolver import information
50
+ */
51
+ interface ResolverImport {
52
+ /** Export name */
53
+ name: string;
54
+ /** Resolver type (query, mutation, resolver, type, subscription, directive) */
55
+ type: 'query' | 'mutation' | 'resolver' | 'type' | 'subscription' | 'directive';
56
+ /** Aliased import name */
57
+ as: string;
58
+ }
59
+ /**
60
+ * Scanned resolver information
61
+ */
62
+ interface ScannedResolver {
63
+ /** File specifier (path) */
64
+ specifier: string;
65
+ /** Exports from this file */
66
+ imports: ResolverImport[];
67
+ }
68
+ //#endregion
69
+ export { ResolverImport, ScanContext, ScanResult, ScannedFile, ScannedResolver };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,4 +1,8 @@
1
- //#region src/utils/directive-parser.d.ts
1
+ //#region src/core/utils/directive-parser.d.ts
2
+ /**
3
+ * Directive parser utilities
4
+ * AST-based parsing for GraphQL directive definitions
5
+ */
2
6
  interface ParsedDirective {
3
7
  name: string;
4
8
  locations: string[];
@@ -69,12 +73,25 @@ declare class DirectiveParser {
69
73
  */
70
74
  declare function generateDirectiveSchema(directive: ParsedDirective): string;
71
75
  /**
72
- * Generate directive schemas file from scanned directives
76
+ * Directive file reference
77
+ * Can be either { fullPath } or { specifier } (for GenImport compatibility)
73
78
  */
74
- declare function generateDirectiveSchemas(nitro: any, directives: any[]): Promise<void>;
79
+ type DirectiveFileRef = {
80
+ fullPath: string;
81
+ } | {
82
+ specifier: string;
83
+ };
75
84
  /**
76
85
  * Singleton instance for reuse
77
86
  */
78
87
  declare const directiveParser: DirectiveParser;
88
+ /**
89
+ * Generate GraphQL schemas from an array of parsed directives
90
+ */
91
+ declare function generateDirectiveSchemas(nitro: {
92
+ graphql: {
93
+ buildDir: string;
94
+ };
95
+ }, directives: DirectiveFileRef[]): Promise<string | null>;
79
96
  //#endregion
80
- export { DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas };
97
+ export { DirectiveFileRef, DirectiveParser, ParsedDirective, directiveParser, generateDirectiveSchema, generateDirectiveSchemas };