nitro-graphql 2.0.0-beta.36 → 2.0.0-beta.38
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/dist/cli/commands/generate.d.mts +26 -0
- package/dist/cli/commands/generate.mjs +196 -0
- package/dist/cli/commands/index.d.mts +4 -0
- package/dist/cli/commands/index.mjs +5 -0
- package/dist/cli/commands/init.d.mts +12 -0
- package/dist/cli/commands/init.mjs +100 -0
- package/dist/cli/commands/validate.d.mts +10 -0
- package/dist/cli/commands/validate.mjs +69 -0
- package/dist/cli/config.d.mts +75 -0
- package/dist/cli/config.mjs +20 -0
- package/dist/cli/index.d.mts +24 -0
- package/dist/cli/index.mjs +219 -0
- package/dist/core/codegen/client.d.mts +23 -0
- package/dist/core/codegen/client.mjs +150 -0
- package/dist/core/codegen/document-loader.d.mts +10 -0
- package/dist/core/codegen/document-loader.mjs +18 -0
- package/dist/core/codegen/index.d.mts +8 -0
- package/dist/core/codegen/index.mjs +9 -0
- package/dist/{utils/codegen-plugin.d.mts → core/codegen/plugin.d.mts} +2 -2
- package/dist/{utils/codegen-plugin.mjs → core/codegen/plugin.mjs} +1 -1
- package/dist/core/codegen/runtime.d.mts +20 -0
- package/dist/core/codegen/runtime.mjs +60 -0
- package/dist/core/codegen/schema-loader.d.mts +28 -0
- package/dist/core/codegen/schema-loader.mjs +128 -0
- package/dist/core/codegen/server.d.mts +28 -0
- package/dist/core/codegen/server.mjs +143 -0
- package/dist/{codegen → core/codegen}/validation.d.mts +1 -1
- package/dist/{codegen → core/codegen}/validation.mjs +1 -1
- package/dist/core/config.d.mts +50 -0
- package/dist/core/config.mjs +82 -0
- package/dist/core/constants.d.mts +188 -0
- package/dist/core/constants.mjs +210 -0
- package/dist/core/index.d.mts +32 -0
- package/dist/core/index.mjs +26 -0
- package/dist/core/scanning/ast-scanner.d.mts +23 -0
- package/dist/core/scanning/ast-scanner.mjs +103 -0
- package/dist/core/scanning/common.d.mts +37 -0
- package/dist/core/scanning/common.mjs +60 -0
- package/dist/core/scanning/directives.d.mts +10 -0
- package/dist/core/scanning/directives.mjs +29 -0
- package/dist/core/scanning/documents.d.mts +21 -0
- package/dist/core/scanning/documents.mjs +43 -0
- package/dist/core/scanning/index.d.mts +7 -0
- package/dist/core/scanning/index.mjs +8 -0
- package/dist/core/scanning/resolvers.d.mts +10 -0
- package/dist/core/scanning/resolvers.mjs +58 -0
- package/dist/core/scanning/schemas.d.mts +14 -0
- package/dist/core/scanning/schemas.mjs +64 -0
- package/dist/{utils/schema-builder.d.mts → core/schema/builder.d.mts} +7 -2
- package/dist/{utils/schema-builder.mjs → core/schema/builder.mjs} +22 -3
- package/dist/{utils → core/schema}/federation.d.mts +10 -5
- package/dist/{utils → core/schema}/federation.mjs +1 -1
- package/dist/core/schema/index.d.mts +3 -0
- package/dist/core/schema/index.mjs +4 -0
- package/dist/core/types/adapter.d.mts +58 -0
- package/dist/core/types/codegen.d.mts +133 -0
- package/dist/core/types/config.d.mts +212 -0
- package/dist/{types → core/types}/define.d.mts +3 -7
- package/dist/core/types/index.d.mts +5 -0
- package/dist/core/types/scanning.d.mts +69 -0
- package/dist/core/types/scanning.mjs +1 -0
- package/dist/{utils → core/utils}/directive-parser.d.mts +21 -5
- package/dist/{utils → core/utils}/directive-parser.mjs +25 -36
- package/dist/{utils → core/utils}/errors.d.mts +8 -4
- package/dist/{utils → core/utils}/errors.mjs +8 -4
- package/dist/core/utils/file-io.d.mts +24 -0
- package/dist/core/utils/file-io.mjs +47 -0
- package/dist/{utils → core/utils}/imports.d.mts +1 -1
- package/dist/{utils → core/utils}/imports.mjs +1 -1
- package/dist/core/utils/index.d.mts +7 -0
- package/dist/core/utils/index.mjs +8 -0
- package/dist/core/utils/logger.d.mts +19 -0
- package/dist/core/utils/logger.mjs +38 -0
- package/dist/{utils → core/utils}/ofetch-templates.d.mts +1 -1
- package/dist/{utils → core/utils}/ofetch-templates.mjs +1 -1
- package/dist/core/validation/external-services.d.mts +11 -0
- package/dist/{utils/validation.mjs → core/validation/external-services.mjs} +3 -3
- package/dist/core/validation/index.d.mts +2 -0
- package/dist/core/validation/index.mjs +3 -0
- package/dist/define.d.mts +1 -3
- package/dist/index.d.mts +6 -43
- package/dist/index.mjs +5 -62
- package/dist/nitro/adapter.d.mts +30 -0
- package/dist/nitro/adapter.mjs +97 -0
- package/dist/{utils → nitro}/apollo.d.mts +1 -1
- package/dist/{utils → nitro}/apollo.mjs +1 -1
- package/dist/nitro/codegen.d.mts +19 -0
- package/dist/nitro/codegen.mjs +141 -0
- package/dist/nitro/config.d.mts +52 -0
- package/dist/nitro/config.mjs +58 -0
- package/dist/nitro/index.d.mts +46 -0
- package/dist/nitro/index.mjs +65 -0
- package/dist/{utils/path-resolver.d.mts → nitro/paths.d.mts} +3 -19
- package/dist/{utils/path-resolver.mjs → nitro/paths.mjs} +2 -36
- package/dist/{rollup.d.mts → nitro/rollup.d.mts} +1 -1
- package/dist/{rollup.mjs → nitro/rollup.mjs} +11 -23
- package/dist/{routes → nitro/routes}/apollo-server.d.mts +1 -1
- package/dist/nitro/routes/apollo-server.mjs +71 -0
- package/dist/{routes → nitro/routes}/debug-template.d.mts +1 -1
- package/dist/{routes → nitro/routes}/debug-template.mjs +1 -1
- package/dist/{routes → nitro/routes}/debug.d.mts +10 -16
- package/dist/{routes → nitro/routes}/debug.mjs +2 -2
- package/dist/nitro/routes/graphql-yoga.d.mts +6 -0
- package/dist/{routes → nitro/routes}/graphql-yoga.mjs +21 -10
- package/dist/nitro/routes/health.d.mts +10 -0
- package/dist/{routes → nitro/routes}/health.mjs +1 -1
- package/dist/nitro/setup/file-watcher.d.mts +16 -0
- package/dist/{setup → nitro/setup}/file-watcher.mjs +14 -18
- package/dist/nitro/setup/logging.d.mts +17 -0
- package/dist/nitro/setup/logging.mjs +66 -0
- package/dist/nitro/setup/rollup-integration.d.mts +16 -0
- package/dist/{setup → nitro/setup}/rollup-integration.mjs +2 -2
- package/dist/nitro/setup/routes.d.mts +10 -0
- package/dist/nitro/setup/routes.mjs +35 -0
- package/dist/nitro/setup/ts-config.d.mts +11 -0
- package/dist/{setup → nitro/setup}/ts-config.mjs +3 -3
- package/dist/{setup.d.mts → nitro/setup.d.mts} +3 -2
- package/dist/{setup.mjs → nitro/setup.mjs} +73 -62
- package/dist/nitro/types.d.mts +378 -0
- package/dist/nitro/types.mjs +1 -0
- package/dist/nitro/virtual/generators.d.mts +31 -0
- package/dist/nitro/virtual/generators.mjs +193 -0
- package/dist/nitro/virtual/stubs.d.mts +20 -0
- package/dist/nitro/virtual/stubs.mjs +31 -0
- package/dist/{ecosystem/nuxt.d.mts → nuxt.d.mts} +1 -1
- package/dist/{ecosystem/nuxt.mjs → nuxt.mjs} +2 -2
- package/dist/{graphql/server.d.mts → stubs/index.d.mts} +5 -1
- package/dist/stubs/index.mjs +1 -0
- package/package.json +45 -43
- package/dist/codegen/client-types.d.mts +0 -13
- package/dist/codegen/client-types.mjs +0 -131
- package/dist/codegen/external-types.d.mts +0 -12
- package/dist/codegen/external-types.mjs +0 -88
- package/dist/codegen/index.d.mts +0 -18
- package/dist/codegen/index.mjs +0 -24
- package/dist/codegen/server-types.d.mts +0 -13
- package/dist/codegen/server-types.mjs +0 -64
- package/dist/config/defaults.mjs +0 -36
- package/dist/constants/scalars.mjs +0 -27
- package/dist/constants.mjs +0 -106
- package/dist/graphql/index.d.mts +0 -5
- package/dist/routes/apollo-server.mjs +0 -45
- package/dist/routes/graphql-yoga.d.mts +0 -6
- package/dist/routes/health.d.mts +0 -10
- package/dist/setup/graphql-scanner.mjs +0 -25
- package/dist/setup/scaffold-generator.mjs +0 -109
- package/dist/types/index.d.mts +0 -246
- package/dist/types/standard-schema.d.mts +0 -59
- package/dist/utils/client-codegen.d.mts +0 -41
- package/dist/utils/client-codegen.mjs +0 -267
- package/dist/utils/file-generator.d.mts +0 -37
- package/dist/utils/file-generator.mjs +0 -72
- package/dist/utils/file-writer.d.mts +0 -35
- package/dist/utils/file-writer.mjs +0 -32
- package/dist/utils/index.d.mts +0 -13
- package/dist/utils/index.mjs +0 -13
- package/dist/utils/layers.d.mts +0 -22
- package/dist/utils/layers.mjs +0 -28
- package/dist/utils/scanning/common.d.mts +0 -23
- package/dist/utils/scanning/common.mjs +0 -39
- package/dist/utils/scanning/directives.d.mts +0 -11
- package/dist/utils/scanning/directives.mjs +0 -43
- package/dist/utils/scanning/documents.d.mts +0 -15
- package/dist/utils/scanning/documents.mjs +0 -46
- package/dist/utils/scanning/index.d.mts +0 -6
- package/dist/utils/scanning/index.mjs +0 -7
- package/dist/utils/scanning/resolvers.d.mts +0 -11
- package/dist/utils/scanning/resolvers.mjs +0 -100
- package/dist/utils/scanning/schemas.d.mts +0 -15
- package/dist/utils/scanning/schemas.mjs +0 -29
- package/dist/utils/server-codegen.d.mts +0 -7
- package/dist/utils/server-codegen.mjs +0 -113
- package/dist/utils/type-generation.d.mts +0 -6
- package/dist/utils/type-generation.mjs +0 -7
- package/dist/utils/validation.d.mts +0 -11
- package/dist/virtual/debug-info.d.mts +0 -9
- package/dist/virtual/debug-info.mjs +0 -26
- package/dist/virtual/generators/config.d.mts +0 -22
- package/dist/virtual/generators/config.mjs +0 -36
- package/dist/virtual/generators/debug.d.mts +0 -14
- package/dist/virtual/generators/debug.mjs +0 -53
- package/dist/virtual/generators/directives.d.mts +0 -14
- package/dist/virtual/generators/directives.mjs +0 -52
- package/dist/virtual/generators/index.d.mts +0 -6
- package/dist/virtual/generators/index.mjs +0 -7
- package/dist/virtual/generators/resolvers.d.mts +0 -14
- package/dist/virtual/generators/resolvers.mjs +0 -55
- package/dist/virtual/generators/schemas.d.mts +0 -14
- package/dist/virtual/generators/schemas.mjs +0 -43
- package/dist/virtual/graphql-config.d.mts +0 -9
- package/dist/virtual/graphql-config.mjs +0 -10
- package/dist/virtual/module-config.d.mts +0 -9
- package/dist/virtual/module-config.mjs +0 -10
- package/dist/virtual/server-directives.d.mts +0 -11
- package/dist/virtual/server-directives.mjs +0 -10
- package/dist/virtual/server-resolvers.d.mts +0 -11
- package/dist/virtual/server-resolvers.mjs +0 -10
- package/dist/virtual/server-schemas.d.mts +0 -11
- package/dist/virtual/server-schemas.mjs +0 -10
- /package/dist/{graphql/index.mjs → core/types/adapter.mjs} +0 -0
- /package/dist/{graphql/server.mjs → core/types/codegen.mjs} +0 -0
- /package/dist/{types/define.mjs → core/types/config.mjs} +0 -0
- /package/dist/{types/index.mjs → core/types/define.mjs} +0 -0
- /package/dist/{types/standard-schema.mjs → core/types/index.mjs} +0 -0
package/dist/types/index.d.mts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from "./standard-schema.mjs";
|
|
2
|
-
import { TypeScriptPluginConfig } from "@graphql-codegen/typescript";
|
|
3
|
-
import { plugin as plugin$1 } from "@graphql-codegen/typescript-generic-sdk";
|
|
4
|
-
import { TypeScriptDocumentsPluginConfig } from "@graphql-codegen/typescript-operations";
|
|
5
|
-
import { IResolvers } from "@graphql-tools/utils";
|
|
6
|
-
import { TypeScriptResolversPluginConfig } from "@graphql-codegen/typescript-resolvers";
|
|
7
|
-
import { ESMCodeGenOptions } from "knitwork";
|
|
8
|
-
|
|
9
|
-
//#region src/types/index.d.ts
|
|
10
|
-
type CodegenServerConfig = TypeScriptPluginConfig & TypeScriptResolversPluginConfig;
|
|
11
|
-
type DocumentModeConfig = Pick<Parameters<typeof plugin$1>[2], 'documentMode'>;
|
|
12
|
-
type DocumentModeEnum = NonNullable<DocumentModeConfig['documentMode']>;
|
|
13
|
-
type DocumentModeType = `${DocumentModeEnum}`;
|
|
14
|
-
type GenericSdkConfig = Omit<Parameters<typeof plugin$1>[2], 'documentMode'> & {
|
|
15
|
-
documentMode?: DocumentModeType;
|
|
16
|
-
};
|
|
17
|
-
type CodegenClientConfig = TypeScriptPluginConfig & TypeScriptDocumentsPluginConfig & {
|
|
18
|
-
endpoint?: string;
|
|
19
|
-
};
|
|
20
|
-
interface IESMImport {
|
|
21
|
-
name: string;
|
|
22
|
-
as?: string;
|
|
23
|
-
type: 'resolver' | 'query' | 'mutation' | 'type' | 'subscription' | 'directive';
|
|
24
|
-
}
|
|
25
|
-
interface GenImport {
|
|
26
|
-
specifier: string;
|
|
27
|
-
imports: IESMImport[];
|
|
28
|
-
options?: ESMCodeGenOptions;
|
|
29
|
-
}
|
|
30
|
-
declare module 'nitro/types' {
|
|
31
|
-
interface Nitro {
|
|
32
|
-
scanSchemas: string[];
|
|
33
|
-
scanDocuments: string[];
|
|
34
|
-
scanResolvers: GenImport[];
|
|
35
|
-
scanDirectives: GenImport[];
|
|
36
|
-
graphql: {
|
|
37
|
-
buildDir: string;
|
|
38
|
-
watchDirs: string[];
|
|
39
|
-
clientDir: string;
|
|
40
|
-
serverDir: string;
|
|
41
|
-
dir: {
|
|
42
|
-
build: string;
|
|
43
|
-
client: string;
|
|
44
|
-
server: string;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
declare module 'nitro/types' {
|
|
50
|
-
interface NitroOptions {
|
|
51
|
-
graphql?: NitroGraphQLOptions;
|
|
52
|
-
}
|
|
53
|
-
interface NitroRuntimeConfig {
|
|
54
|
-
graphql?: NitroGraphQLOptions;
|
|
55
|
-
}
|
|
56
|
-
interface NitroConfig {
|
|
57
|
-
graphql?: NitroGraphQLOptions;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Service-specific path overrides for external GraphQL services
|
|
62
|
-
* These paths override global config for this specific service
|
|
63
|
-
*/
|
|
64
|
-
interface ExternalServicePaths {
|
|
65
|
-
/** SDK file path (overrides global sdk.external config) */
|
|
66
|
-
sdk?: FileGenerationConfig;
|
|
67
|
-
/** Type definitions file path (overrides global types.external config) */
|
|
68
|
-
types?: FileGenerationConfig;
|
|
69
|
-
/** ofetch client wrapper path (overrides global clientUtils.ofetch config) */
|
|
70
|
-
ofetch?: FileGenerationConfig;
|
|
71
|
-
}
|
|
72
|
-
interface ExternalGraphQLService {
|
|
73
|
-
/** Unique name for this service (used for file naming and type generation) */
|
|
74
|
-
name: string;
|
|
75
|
-
/** Schema source - can be URL(s) for remote schemas or file path(s) for local schemas */
|
|
76
|
-
schema: string | string[];
|
|
77
|
-
/** GraphQL endpoint for this service */
|
|
78
|
-
endpoint: string;
|
|
79
|
-
/** Optional headers for schema introspection and client requests */
|
|
80
|
-
headers?: Record<string, string> | (() => Record<string, string>);
|
|
81
|
-
/** Optional: specific document patterns for this service */
|
|
82
|
-
documents?: string[];
|
|
83
|
-
/**
|
|
84
|
-
* Optional: Download and cache schema locally for offline usage
|
|
85
|
-
* - true or 'once': Download if file doesn't exist, then use cached version (offline-friendly)
|
|
86
|
-
* - 'always': Check for updates on every build (current behavior)
|
|
87
|
-
* - 'manual': Never download automatically, user manages schema files manually
|
|
88
|
-
* - false: Disable schema downloading
|
|
89
|
-
*/
|
|
90
|
-
downloadSchema?: boolean | 'once' | 'always' | 'manual';
|
|
91
|
-
/** Optional: Custom path to save downloaded schema (default: .nitro/graphql/schemas/[serviceName].graphql) */
|
|
92
|
-
downloadPath?: string;
|
|
93
|
-
/** Optional: service-specific codegen configuration */
|
|
94
|
-
codegen?: {
|
|
95
|
-
client?: CodegenClientConfig;
|
|
96
|
-
clientSDK?: GenericSdkConfig;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Optional: Service-specific path overrides
|
|
100
|
-
* These paths take precedence over global config (sdk, types, clientUtils)
|
|
101
|
-
* Supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework}, {typesDir}, {clientGraphql}
|
|
102
|
-
*/
|
|
103
|
-
paths?: ExternalServicePaths;
|
|
104
|
-
}
|
|
105
|
-
interface FederationConfig {
|
|
106
|
-
/** Enable Apollo Federation subgraph support */
|
|
107
|
-
enabled: boolean;
|
|
108
|
-
/** Service name for federation (used in subgraph config) */
|
|
109
|
-
serviceName?: string;
|
|
110
|
-
/** Service version for federation */
|
|
111
|
-
serviceVersion?: string;
|
|
112
|
-
/** Service URL for federation gateway */
|
|
113
|
-
serviceUrl?: string;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* File generation control:
|
|
117
|
-
* - false: Do not generate this file
|
|
118
|
-
* - true: Generate at default location
|
|
119
|
-
* - string: Generate at custom path (supports placeholders: {serviceName}, {buildDir}, {rootDir}, {framework})
|
|
120
|
-
*/
|
|
121
|
-
type FileGenerationConfig = boolean | string;
|
|
122
|
-
/**
|
|
123
|
-
* Scaffold files configuration
|
|
124
|
-
* Control auto-generation of scaffold/boilerplate files
|
|
125
|
-
*/
|
|
126
|
-
interface ScaffoldConfig {
|
|
127
|
-
/** Enable/disable all scaffold files */
|
|
128
|
-
enabled?: boolean;
|
|
129
|
-
/** graphql.config.ts - GraphQL Config file for IDE tooling */
|
|
130
|
-
graphqlConfig?: FileGenerationConfig;
|
|
131
|
-
/** server/graphql/schema.ts - Schema definition file */
|
|
132
|
-
serverSchema?: FileGenerationConfig;
|
|
133
|
-
/** server/graphql/config.ts - GraphQL server configuration */
|
|
134
|
-
serverConfig?: FileGenerationConfig;
|
|
135
|
-
/** server/graphql/context.ts - H3 context augmentation */
|
|
136
|
-
serverContext?: FileGenerationConfig;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Client utilities configuration
|
|
140
|
-
* Control auto-generation of client-side utility files (Nuxt only)
|
|
141
|
-
*/
|
|
142
|
-
interface ClientUtilsConfig {
|
|
143
|
-
/** Enable/disable all client utilities */
|
|
144
|
-
enabled?: boolean;
|
|
145
|
-
/** app/graphql/index.ts - Main exports file */
|
|
146
|
-
index?: FileGenerationConfig;
|
|
147
|
-
/** app/graphql/{serviceName}/ofetch.ts - ofetch client wrapper */
|
|
148
|
-
ofetch?: FileGenerationConfig;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* SDK files configuration
|
|
152
|
-
* Control auto-generation of GraphQL SDK files
|
|
153
|
-
*/
|
|
154
|
-
interface SdkConfig {
|
|
155
|
-
/** Enable/disable all SDK files */
|
|
156
|
-
enabled?: boolean;
|
|
157
|
-
/** app/graphql/default/sdk.ts - Main service SDK */
|
|
158
|
-
main?: FileGenerationConfig;
|
|
159
|
-
/** app/graphql/{serviceName}/sdk.ts - External service SDKs */
|
|
160
|
-
external?: FileGenerationConfig;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Type files configuration
|
|
164
|
-
* Control auto-generation of TypeScript type definition files
|
|
165
|
-
*/
|
|
166
|
-
interface TypesConfig {
|
|
167
|
-
/** Enable/disable all type files */
|
|
168
|
-
enabled?: boolean;
|
|
169
|
-
/** .nitro/types/nitro-graphql-server.d.ts - Server-side types */
|
|
170
|
-
server?: FileGenerationConfig;
|
|
171
|
-
/** .nitro/types/nitro-graphql-client.d.ts - Client-side types */
|
|
172
|
-
client?: FileGenerationConfig;
|
|
173
|
-
/** .nitro/types/nitro-graphql-client-{serviceName}.d.ts - External service types */
|
|
174
|
-
external?: FileGenerationConfig;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Global path overrides
|
|
178
|
-
* Set base directories for file generation
|
|
179
|
-
*/
|
|
180
|
-
interface PathsConfig {
|
|
181
|
-
/** Server GraphQL directory (default: 'server/graphql') */
|
|
182
|
-
serverGraphql?: string;
|
|
183
|
-
/** Client GraphQL directory (default: 'app/graphql' for Nuxt, 'graphql' for Nitro) */
|
|
184
|
-
clientGraphql?: string;
|
|
185
|
-
/** Build directory (default: '.nitro' or '.nuxt') */
|
|
186
|
-
buildDir?: string;
|
|
187
|
-
/** Types directory (default: '{buildDir}/types') */
|
|
188
|
-
typesDir?: string;
|
|
189
|
-
}
|
|
190
|
-
interface NitroGraphQLOptions {
|
|
191
|
-
framework?: 'graphql-yoga' | 'apollo-server';
|
|
192
|
-
endpoint?: {
|
|
193
|
-
graphql?: string;
|
|
194
|
-
healthCheck?: string;
|
|
195
|
-
};
|
|
196
|
-
playground?: boolean;
|
|
197
|
-
typedefs?: string[];
|
|
198
|
-
resolvers?: Array<IResolvers<any, any>>;
|
|
199
|
-
loader?: {
|
|
200
|
-
include?: RegExp;
|
|
201
|
-
exclude?: RegExp;
|
|
202
|
-
validate?: boolean;
|
|
203
|
-
};
|
|
204
|
-
codegen?: {
|
|
205
|
-
server?: CodegenServerConfig;
|
|
206
|
-
client?: CodegenClientConfig;
|
|
207
|
-
clientSDK?: GenericSdkConfig;
|
|
208
|
-
};
|
|
209
|
-
/** External GraphQL services to generate types and SDKs for */
|
|
210
|
-
externalServices?: ExternalGraphQLService[];
|
|
211
|
-
/** Apollo Federation configuration */
|
|
212
|
-
federation?: FederationConfig;
|
|
213
|
-
/** Server GraphQL directory path */
|
|
214
|
-
serverDir?: string;
|
|
215
|
-
/** Layer directories (populated by Nuxt module) */
|
|
216
|
-
layerDirectories?: string[];
|
|
217
|
-
layerServerDirs?: string[];
|
|
218
|
-
layerAppDirs?: string[];
|
|
219
|
-
/**
|
|
220
|
-
* Scaffold files configuration
|
|
221
|
-
* Set to false to disable all scaffold file generation (library mode)
|
|
222
|
-
*/
|
|
223
|
-
scaffold?: false | ScaffoldConfig;
|
|
224
|
-
/**
|
|
225
|
-
* Client utilities configuration
|
|
226
|
-
* Set to false to disable all client utility generation
|
|
227
|
-
*/
|
|
228
|
-
clientUtils?: false | ClientUtilsConfig;
|
|
229
|
-
/**
|
|
230
|
-
* SDK files configuration
|
|
231
|
-
* Set to false to disable all SDK generation
|
|
232
|
-
*/
|
|
233
|
-
sdk?: false | SdkConfig;
|
|
234
|
-
/**
|
|
235
|
-
* Type files configuration
|
|
236
|
-
* Set to false to disable all type generation
|
|
237
|
-
*/
|
|
238
|
-
types?: false | TypesConfig;
|
|
239
|
-
/**
|
|
240
|
-
* Global path overrides
|
|
241
|
-
* Customize base directories for file generation
|
|
242
|
-
*/
|
|
243
|
-
paths?: PathsConfig;
|
|
244
|
-
}
|
|
245
|
-
//#endregion
|
|
246
|
-
export { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, StandardSchemaV1, TypesConfig };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
//#region src/types/standard-schema.d.ts
|
|
2
|
-
/** The Standard Schema interface. */
|
|
3
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
4
|
-
/** The Standard Schema properties. */
|
|
5
|
-
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
6
|
-
}
|
|
7
|
-
declare namespace StandardSchemaV1 {
|
|
8
|
-
/** The Standard Schema properties interface. */
|
|
9
|
-
export interface Props<Input = unknown, Output = Input> {
|
|
10
|
-
/** The version number of the standard. */
|
|
11
|
-
readonly version: 1;
|
|
12
|
-
/** The vendor name of the schema library. */
|
|
13
|
-
readonly vendor: string;
|
|
14
|
-
/** Validates unknown input values. */
|
|
15
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
16
|
-
/** Inferred types associated with the schema. */
|
|
17
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
18
|
-
}
|
|
19
|
-
/** The result interface of the validate function. */
|
|
20
|
-
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
21
|
-
/** The result interface if validation succeeds. */
|
|
22
|
-
export interface SuccessResult<Output> {
|
|
23
|
-
/** The typed output value. */
|
|
24
|
-
readonly value: Output;
|
|
25
|
-
/** The non-existent issues. */
|
|
26
|
-
readonly issues?: undefined;
|
|
27
|
-
}
|
|
28
|
-
/** The result interface if validation fails. */
|
|
29
|
-
export interface FailureResult {
|
|
30
|
-
/** The issues of failed validation. */
|
|
31
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
32
|
-
}
|
|
33
|
-
/** The issue interface of the failure output. */
|
|
34
|
-
export interface Issue {
|
|
35
|
-
/** The error message of the issue. */
|
|
36
|
-
readonly message: string;
|
|
37
|
-
/** The path of the issue, if any. */
|
|
38
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
39
|
-
}
|
|
40
|
-
/** The path segment interface of the issue. */
|
|
41
|
-
export interface PathSegment {
|
|
42
|
-
/** The key representing a path segment. */
|
|
43
|
-
readonly key: PropertyKey;
|
|
44
|
-
}
|
|
45
|
-
/** The Standard Schema types interface. */
|
|
46
|
-
export interface Types<Input = unknown, Output = Input> {
|
|
47
|
-
/** The input type of the schema. */
|
|
48
|
-
readonly input: Input;
|
|
49
|
-
/** The output type of the schema. */
|
|
50
|
-
readonly output: Output;
|
|
51
|
-
}
|
|
52
|
-
/** Infers the input type of a Standard Schema. */
|
|
53
|
-
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
54
|
-
/** Infers the output type of a Standard Schema. */
|
|
55
|
-
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
56
|
-
export {};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { StandardSchemaV1 };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { CodegenClientConfig, ExternalGraphQLService, GenericSdkConfig } from "../types/index.mjs";
|
|
2
|
-
import { GraphQLSchema } from "graphql";
|
|
3
|
-
import { LoadSchemaOptions, UnnormalizedTypeDefPointer } from "@graphql-tools/load";
|
|
4
|
-
import { Source } from "@graphql-tools/utils";
|
|
5
|
-
|
|
6
|
-
//#region src/utils/client-codegen.d.ts
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Type definition pointer for GraphQL schemas
|
|
10
|
-
*/
|
|
11
|
-
type GraphQLTypeDefPointer = UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[];
|
|
12
|
-
/**
|
|
13
|
-
* Options for loading GraphQL schemas
|
|
14
|
-
*/
|
|
15
|
-
type GraphQLLoadSchemaOptions = Partial<LoadSchemaOptions>;
|
|
16
|
-
declare function graphQLLoadSchemaSync(schemaPointers: GraphQLTypeDefPointer, data?: GraphQLLoadSchemaOptions): Promise<GraphQLSchema | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* Load schema from external GraphQL service
|
|
19
|
-
*/
|
|
20
|
-
declare function loadExternalSchema(service: ExternalGraphQLService, buildDir?: string): Promise<GraphQLSchema | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* Download and save schema from external service
|
|
23
|
-
*/
|
|
24
|
-
declare function downloadAndSaveSchema(service: ExternalGraphQLService, buildDir: string): Promise<string | undefined>;
|
|
25
|
-
declare function loadGraphQLDocuments(patterns: string | string[]): Promise<Source[]>;
|
|
26
|
-
declare function generateClientTypes(schema: GraphQLSchema, docs: Source[], config?: CodegenClientConfig, sdkConfig?: GenericSdkConfig, outputPath?: string, serviceName?: string, virtualTypesPath?: string, options?: {
|
|
27
|
-
silent?: boolean;
|
|
28
|
-
isInitial?: boolean;
|
|
29
|
-
}): Promise<false | {
|
|
30
|
-
types: string;
|
|
31
|
-
sdk: string;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Generate client types for external GraphQL service
|
|
35
|
-
*/
|
|
36
|
-
declare function generateExternalClientTypes(service: ExternalGraphQLService, schema: GraphQLSchema, docs: Source[], virtualTypesPath?: string): Promise<{
|
|
37
|
-
types: string;
|
|
38
|
-
sdk: string;
|
|
39
|
-
} | false>;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { GraphQLLoadSchemaOptions, GraphQLTypeDefPointer, downloadAndSaveSchema, generateClientTypes, generateExternalClientTypes, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments };
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_GRAPHQL_SCALARS } from "../constants/scalars.mjs";
|
|
2
|
-
import { pluginContent } from "./codegen-plugin.mjs";
|
|
3
|
-
import { defu as defu$1 } from "defu";
|
|
4
|
-
import { consola as consola$1 } from "consola";
|
|
5
|
-
import { dirname, resolve } from "pathe";
|
|
6
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
-
import { parse } from "graphql";
|
|
8
|
-
import { createHash } from "node:crypto";
|
|
9
|
-
import { codegen } from "@graphql-codegen/core";
|
|
10
|
-
import { preset } from "@graphql-codegen/import-types-preset";
|
|
11
|
-
import { plugin } from "@graphql-codegen/typescript";
|
|
12
|
-
import { plugin as plugin$1 } from "@graphql-codegen/typescript-generic-sdk";
|
|
13
|
-
import { plugin as plugin$2 } from "@graphql-codegen/typescript-operations";
|
|
14
|
-
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader";
|
|
15
|
-
import { loadDocuments, loadSchemaSync } from "@graphql-tools/load";
|
|
16
|
-
import { UrlLoader } from "@graphql-tools/url-loader";
|
|
17
|
-
import { printSchemaWithDirectives } from "@graphql-tools/utils";
|
|
18
|
-
|
|
19
|
-
//#region src/utils/client-codegen.ts
|
|
20
|
-
async function graphQLLoadSchemaSync(schemaPointers, data = {}) {
|
|
21
|
-
const filteredPointers = [...Array.isArray(schemaPointers) ? schemaPointers : [schemaPointers], "!**/vfs/**"];
|
|
22
|
-
let result;
|
|
23
|
-
try {
|
|
24
|
-
result = loadSchemaSync(filteredPointers, {
|
|
25
|
-
...data,
|
|
26
|
-
loaders: [
|
|
27
|
-
new GraphQLFileLoader(),
|
|
28
|
-
new UrlLoader(),
|
|
29
|
-
...data.loaders || []
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
} catch (e) {
|
|
33
|
-
if ((e.message || "").includes("Unable to find any GraphQL type definitions for the following pointers:")) consola$1.info("No server GraphQL files found. If you need server-side GraphQL, add .graphql files to your server directory.");
|
|
34
|
-
else throw e;
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Load schema from external GraphQL service
|
|
40
|
-
*/
|
|
41
|
-
async function loadExternalSchema(service, buildDir) {
|
|
42
|
-
try {
|
|
43
|
-
const headers = typeof service.headers === "function" ? service.headers() : service.headers || {};
|
|
44
|
-
const schemas = Array.isArray(service.schema) ? service.schema : [service.schema];
|
|
45
|
-
if (service.downloadSchema && buildDir) {
|
|
46
|
-
const defaultPath = resolve(buildDir, "graphql", "schemas", `${service.name}.graphql`);
|
|
47
|
-
const schemaFilePath = service.downloadPath ? resolve(service.downloadPath) : defaultPath;
|
|
48
|
-
if (existsSync(schemaFilePath)) try {
|
|
49
|
-
return loadSchemaSync([schemaFilePath], { loaders: [new GraphQLFileLoader()] });
|
|
50
|
-
} catch {
|
|
51
|
-
consola$1.warn(`[graphql:${service.name}] Cached schema invalid, loading from source`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const hasUrls = schemas.some((schema) => isUrl(schema));
|
|
55
|
-
const hasLocalFiles = schemas.some((schema) => !isUrl(schema));
|
|
56
|
-
const loaders = [];
|
|
57
|
-
if (hasLocalFiles) loaders.push(new GraphQLFileLoader());
|
|
58
|
-
if (hasUrls) loaders.push(new UrlLoader());
|
|
59
|
-
if (loaders.length === 0) throw new Error("No appropriate loaders found for schema sources");
|
|
60
|
-
return loadSchemaSync(schemas, {
|
|
61
|
-
loaders,
|
|
62
|
-
...Object.keys(headers).length > 0 && { headers }
|
|
63
|
-
});
|
|
64
|
-
} catch (error) {
|
|
65
|
-
consola$1.error(`[graphql:${service.name}] Failed to load external schema:`, error);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Check if a path is a URL (http/https)
|
|
71
|
-
*/
|
|
72
|
-
function isUrl(path) {
|
|
73
|
-
return path.startsWith("http://") || path.startsWith("https://");
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Download and save schema from external service
|
|
77
|
-
*/
|
|
78
|
-
async function downloadAndSaveSchema(service, buildDir) {
|
|
79
|
-
const downloadMode = service.downloadSchema;
|
|
80
|
-
if (!downloadMode || downloadMode === "manual") return;
|
|
81
|
-
const defaultPath = resolve(buildDir, "graphql", "schemas", `${service.name}.graphql`);
|
|
82
|
-
const schemaFilePath = service.downloadPath ? resolve(service.downloadPath) : defaultPath;
|
|
83
|
-
try {
|
|
84
|
-
const headers = typeof service.headers === "function" ? service.headers() : service.headers || {};
|
|
85
|
-
const schemas = Array.isArray(service.schema) ? service.schema : [service.schema];
|
|
86
|
-
const hasUrlSchemas = schemas.some((schema) => isUrl(schema));
|
|
87
|
-
const hasLocalSchemas = schemas.some((schema) => !isUrl(schema));
|
|
88
|
-
let shouldDownload = false;
|
|
89
|
-
const fileExists = existsSync(schemaFilePath);
|
|
90
|
-
if (downloadMode === "always") {
|
|
91
|
-
shouldDownload = true;
|
|
92
|
-
if (fileExists && hasUrlSchemas) try {
|
|
93
|
-
const remoteSchemaString = printSchemaWithDirectives(loadSchemaSync(schemas.filter(isUrl), {
|
|
94
|
-
loaders: [new UrlLoader()],
|
|
95
|
-
...Object.keys(headers).length > 0 && { headers }
|
|
96
|
-
}));
|
|
97
|
-
const remoteHash = createHash("md5").update(remoteSchemaString).digest("hex");
|
|
98
|
-
const localSchemaString = readFileSync(schemaFilePath, "utf-8");
|
|
99
|
-
if (remoteHash === createHash("md5").update(localSchemaString).digest("hex")) {
|
|
100
|
-
shouldDownload = false;
|
|
101
|
-
consola$1.info(`[graphql:${service.name}] Schema is up-to-date, using cached version`);
|
|
102
|
-
}
|
|
103
|
-
} catch {
|
|
104
|
-
consola$1.warn(`[graphql:${service.name}] Unable to compare with remote schema, updating local cache`);
|
|
105
|
-
shouldDownload = true;
|
|
106
|
-
}
|
|
107
|
-
else if (fileExists && hasLocalSchemas) {
|
|
108
|
-
const localFiles = schemas.filter((schema) => !isUrl(schema));
|
|
109
|
-
let sourceIsNewer = false;
|
|
110
|
-
for (const localFile of localFiles) if (existsSync(localFile)) {
|
|
111
|
-
const { statSync } = await import("node:fs");
|
|
112
|
-
const sourceStats = statSync(localFile);
|
|
113
|
-
const cachedStats = statSync(schemaFilePath);
|
|
114
|
-
if (sourceStats.mtime > cachedStats.mtime) {
|
|
115
|
-
sourceIsNewer = true;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (!sourceIsNewer) shouldDownload = false;
|
|
120
|
-
}
|
|
121
|
-
} else if (downloadMode === true || downloadMode === "once") shouldDownload = !fileExists;
|
|
122
|
-
if (shouldDownload) {
|
|
123
|
-
if (hasUrlSchemas && hasLocalSchemas) {
|
|
124
|
-
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, {
|
|
125
|
-
loaders: [new GraphQLFileLoader(), new UrlLoader()],
|
|
126
|
-
...Object.keys(headers).length > 0 && { headers }
|
|
127
|
-
}));
|
|
128
|
-
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
129
|
-
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
130
|
-
} else if (hasUrlSchemas) {
|
|
131
|
-
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, {
|
|
132
|
-
loaders: [new UrlLoader()],
|
|
133
|
-
...Object.keys(headers).length > 0 && { headers }
|
|
134
|
-
}));
|
|
135
|
-
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
136
|
-
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
137
|
-
} else if (hasLocalSchemas) {
|
|
138
|
-
const schemaString = printSchemaWithDirectives(loadSchemaSync(schemas, { loaders: [new GraphQLFileLoader()] }));
|
|
139
|
-
mkdirSync(dirname(schemaFilePath), { recursive: true });
|
|
140
|
-
writeFileSync(schemaFilePath, schemaString, "utf-8");
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return schemaFilePath;
|
|
144
|
-
} catch (error) {
|
|
145
|
-
consola$1.error(`[graphql:${service.name}] Failed to download/copy schema:`, error);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async function loadGraphQLDocuments(patterns) {
|
|
150
|
-
try {
|
|
151
|
-
return await loadDocuments(patterns, { loaders: [new GraphQLFileLoader()] });
|
|
152
|
-
} catch (e) {
|
|
153
|
-
if ((e.message || "").includes("Unable to find any GraphQL type definitions for the following pointers:")) return [];
|
|
154
|
-
else throw e;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
async function generateClientTypes(schema, docs, config = {}, sdkConfig = {}, outputPath, serviceName, virtualTypesPath, options = {}) {
|
|
158
|
-
if (docs.length === 0 && !serviceName) {
|
|
159
|
-
if (!options.silent && options.isInitial) consola$1.info("No client GraphQL files found. Skipping client type generation.");
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
const serviceLabel = serviceName ? `:${serviceName}` : "";
|
|
163
|
-
const mergedConfig = defu$1({
|
|
164
|
-
emitLegacyCommonJSImports: false,
|
|
165
|
-
useTypeImports: true,
|
|
166
|
-
enumsAsTypes: true,
|
|
167
|
-
strictScalars: true,
|
|
168
|
-
maybeValue: "T | null | undefined",
|
|
169
|
-
inputMaybeValue: "T | undefined",
|
|
170
|
-
documentMode: "string",
|
|
171
|
-
pureMagicComment: true,
|
|
172
|
-
dedupeOperationSuffix: true,
|
|
173
|
-
rawRequest: true,
|
|
174
|
-
scalars: DEFAULT_GRAPHQL_SCALARS
|
|
175
|
-
}, config);
|
|
176
|
-
const mergedSdkConfig = defu$1(mergedConfig, sdkConfig);
|
|
177
|
-
try {
|
|
178
|
-
if (docs.length === 0) return {
|
|
179
|
-
types: await codegen({
|
|
180
|
-
filename: outputPath || "client-types.generated.ts",
|
|
181
|
-
schema: parse(printSchemaWithDirectives(schema)),
|
|
182
|
-
documents: [],
|
|
183
|
-
config: mergedConfig,
|
|
184
|
-
plugins: [{ pluginContent: {} }, { typescript: {} }],
|
|
185
|
-
pluginMap: {
|
|
186
|
-
pluginContent: { plugin: pluginContent },
|
|
187
|
-
typescript: { plugin }
|
|
188
|
-
}
|
|
189
|
-
}),
|
|
190
|
-
sdk: `// THIS FILE IS GENERATED, DO NOT EDIT!
|
|
191
|
-
/* eslint-disable eslint-comments/no-unlimited-disable */
|
|
192
|
-
/* tslint:disable */
|
|
193
|
-
/* eslint-disable */
|
|
194
|
-
/* prettier-ignore */
|
|
195
|
-
|
|
196
|
-
import type { GraphQLResolveInfo } from 'graphql'
|
|
197
|
-
export type RequireFields<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> }
|
|
198
|
-
|
|
199
|
-
export interface Requester<C = {}, E = unknown> {
|
|
200
|
-
<R, V>(doc: string, vars?: V, options?: C): Promise<R> | AsyncIterable<R>
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export type Sdk = {
|
|
204
|
-
request: <R, V = Record<string, any>>(document: string, variables?: V) => Promise<R>
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function getSdk(requester: Requester): Sdk {
|
|
208
|
-
return {
|
|
209
|
-
request: <R, V = Record<string, any>>(document: string, variables?: V): Promise<R> => {
|
|
210
|
-
return requester<R, V>(document, variables)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
`
|
|
215
|
-
};
|
|
216
|
-
const output = await codegen({
|
|
217
|
-
filename: outputPath || "client-types.generated.ts",
|
|
218
|
-
schema: parse(printSchemaWithDirectives(schema)),
|
|
219
|
-
documents: [...docs],
|
|
220
|
-
config: mergedConfig,
|
|
221
|
-
plugins: [
|
|
222
|
-
{ pluginContent: {} },
|
|
223
|
-
{ typescript: {} },
|
|
224
|
-
{ typescriptOperations: {} }
|
|
225
|
-
],
|
|
226
|
-
pluginMap: {
|
|
227
|
-
pluginContent: { plugin: pluginContent },
|
|
228
|
-
typescript: { plugin },
|
|
229
|
-
typescriptOperations: { plugin: plugin$2 }
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
const typesPath = virtualTypesPath || (serviceName ? `#graphql/client/${serviceName}` : "#graphql/client");
|
|
233
|
-
const sdkOutput = await preset.buildGeneratesSection({
|
|
234
|
-
baseOutputDir: outputPath || "client-types.generated.ts",
|
|
235
|
-
schema: parse(printSchemaWithDirectives(schema)),
|
|
236
|
-
documents: [...docs],
|
|
237
|
-
config: mergedSdkConfig,
|
|
238
|
-
presetConfig: { typesPath },
|
|
239
|
-
plugins: [{ pluginContent: {} }, { typescriptGenericSdk: {} }],
|
|
240
|
-
pluginMap: {
|
|
241
|
-
pluginContent: { plugin: pluginContent },
|
|
242
|
-
typescriptGenericSdk: { plugin: plugin$1 }
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
return {
|
|
246
|
-
types: output,
|
|
247
|
-
sdk: (await Promise.all(sdkOutput.map(async (config$1) => {
|
|
248
|
-
return {
|
|
249
|
-
file: config$1.filename,
|
|
250
|
-
content: await codegen(config$1)
|
|
251
|
-
};
|
|
252
|
-
})))[0]?.content || ""
|
|
253
|
-
};
|
|
254
|
-
} catch (error) {
|
|
255
|
-
consola$1.warn(`[graphql${serviceLabel}] Client type generation failed:`, error);
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Generate client types for external GraphQL service
|
|
261
|
-
*/
|
|
262
|
-
async function generateExternalClientTypes(service, schema, docs, virtualTypesPath) {
|
|
263
|
-
return generateClientTypes(schema, docs, service.codegen?.client || {}, service.codegen?.clientSDK || {}, void 0, service.name, virtualTypesPath);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
267
|
-
export { downloadAndSaveSchema, generateClientTypes, generateExternalClientTypes, graphQLLoadSchemaSync, loadExternalSchema, loadGraphQLDocuments };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Nitro } from "nitro/types";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/file-generator.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Safely write a file to disk, creating parent directories if needed
|
|
7
|
-
*/
|
|
8
|
-
declare function writeFile(filePath: string, content: string, description?: string): void;
|
|
9
|
-
/**
|
|
10
|
-
* Write a file only if it doesn't already exist
|
|
11
|
-
* Returns true if file was created, false if it already existed
|
|
12
|
-
*/
|
|
13
|
-
declare function writeFileIfNotExists(filePath: string, content: string, description?: string): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Write a file and always overwrite (used for generated files like SDK)
|
|
16
|
-
* This is for files that are auto-generated and should be updated on every build
|
|
17
|
-
*/
|
|
18
|
-
declare function writeGeneratedFile(filePath: string, content: string, description?: string): void;
|
|
19
|
-
/**
|
|
20
|
-
* Check if a path is configured and should be generated
|
|
21
|
-
* Returns the resolved path if should generate, null otherwise
|
|
22
|
-
*/
|
|
23
|
-
declare function getGenerationPath(resolvedPath: string | null, description?: string): string | null;
|
|
24
|
-
/**
|
|
25
|
-
* Log skipped file generation (helpful for debugging library mode)
|
|
26
|
-
*/
|
|
27
|
-
declare function logSkipped(fileName: string, reason?: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* Log generated file path
|
|
30
|
-
*/
|
|
31
|
-
declare function logGenerated(fileName: string, path: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* Validate that a Nitro instance has the required GraphQL configuration
|
|
34
|
-
*/
|
|
35
|
-
declare function validateGraphQLConfig(nitro: Nitro): boolean;
|
|
36
|
-
//#endregion
|
|
37
|
-
export { getGenerationPath, logGenerated, logSkipped, validateGraphQLConfig, writeFile, writeFileIfNotExists, writeGeneratedFile };
|