nitro-graphql 2.0.0-beta.4 → 2.0.0-beta.6
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/README.md +785 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +80 -26
- package/dist/rollup.js +155 -28
- package/dist/routes/debug.d.ts +15 -0
- package/dist/routes/debug.js +449 -0
- package/dist/types/index.d.ts +119 -1
- package/dist/types/standard-schema.d.ts +2 -2
- package/dist/utils/file-generator.d.ts +37 -0
- package/dist/utils/file-generator.js +72 -0
- package/dist/utils/index.js +62 -34
- package/dist/utils/path-resolver.d.ts +70 -0
- package/dist/utils/path-resolver.js +127 -0
- package/dist/utils/type-generation.js +111 -38
- package/package.json +9 -5
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { moduleConfig } from "#nitro-internal-virtual/module-config";
|
|
2
|
+
import { directives } from "#nitro-internal-virtual/server-directives";
|
|
3
|
+
import { resolvers } from "#nitro-internal-virtual/server-resolvers";
|
|
4
|
+
import { schemas } from "#nitro-internal-virtual/server-schemas";
|
|
5
|
+
import { defineEventHandler, getQuery, setResponseHeader } from "h3";
|
|
6
|
+
import { debugInfo } from "#nitro-internal-virtual/debug-info";
|
|
7
|
+
|
|
8
|
+
//#region src/routes/debug.ts
|
|
9
|
+
/**
|
|
10
|
+
* Debug endpoint for inspecting virtual modules and GraphQL setup
|
|
11
|
+
* Only available in development mode
|
|
12
|
+
*
|
|
13
|
+
* Routes:
|
|
14
|
+
* - /_nitro/graphql/debug - HTML dashboard
|
|
15
|
+
* - /_nitro/graphql/debug?format=json - JSON API
|
|
16
|
+
*/
|
|
17
|
+
var debug_default = defineEventHandler(async (event) => {
|
|
18
|
+
if (!debugInfo.isDev) {
|
|
19
|
+
setResponseHeader(event, "Content-Type", "text/plain");
|
|
20
|
+
return "Debug endpoint is only available in development mode";
|
|
21
|
+
}
|
|
22
|
+
const format = getQuery(event).format || "html";
|
|
23
|
+
const processedResolverFiles = debugInfo.scanned.resolverFiles.map((r) => {
|
|
24
|
+
const parts = r.specifier.split("/");
|
|
25
|
+
return {
|
|
26
|
+
file: parts[parts.length - 1],
|
|
27
|
+
fullPath: r.specifier,
|
|
28
|
+
exports: r.imports.map((i) => ({
|
|
29
|
+
name: i.name,
|
|
30
|
+
type: i.type,
|
|
31
|
+
as: i.as
|
|
32
|
+
}))
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const processedDirectiveFiles = debugInfo.scanned.directiveFiles.map((d) => {
|
|
36
|
+
const parts = d.specifier.split("/");
|
|
37
|
+
return {
|
|
38
|
+
file: parts[parts.length - 1],
|
|
39
|
+
fullPath: d.specifier,
|
|
40
|
+
exports: d.imports.map((i) => ({
|
|
41
|
+
name: i.name,
|
|
42
|
+
type: i.type,
|
|
43
|
+
as: i.as
|
|
44
|
+
}))
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const fullDebugInfo = {
|
|
48
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
49
|
+
environment: {
|
|
50
|
+
dev: debugInfo.isDev,
|
|
51
|
+
framework: debugInfo.framework
|
|
52
|
+
},
|
|
53
|
+
graphql: {
|
|
54
|
+
framework: debugInfo.graphqlFramework,
|
|
55
|
+
federation: debugInfo.federation
|
|
56
|
+
},
|
|
57
|
+
scanned: {
|
|
58
|
+
schemas: debugInfo.scanned.schemas,
|
|
59
|
+
schemaFiles: debugInfo.scanned.schemaFiles.map((s) => {
|
|
60
|
+
return s.split("/").slice(-3).join("/");
|
|
61
|
+
}),
|
|
62
|
+
resolvers: debugInfo.scanned.resolvers,
|
|
63
|
+
resolverFiles: processedResolverFiles,
|
|
64
|
+
directives: debugInfo.scanned.directives,
|
|
65
|
+
directiveFiles: processedDirectiveFiles,
|
|
66
|
+
documents: debugInfo.scanned.documents,
|
|
67
|
+
documentFiles: debugInfo.scanned.documentFiles.map((d) => {
|
|
68
|
+
return d.split("/").slice(-3).join("/");
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
runtime: {
|
|
72
|
+
loadedResolvers: resolvers.length,
|
|
73
|
+
loadedSchemas: schemas.length,
|
|
74
|
+
loadedDirectives: directives.length
|
|
75
|
+
},
|
|
76
|
+
virtualModules: debugInfo.virtualModules || {},
|
|
77
|
+
virtualModuleSamples: {
|
|
78
|
+
"server-resolvers": {
|
|
79
|
+
resolverCount: resolvers.length,
|
|
80
|
+
sample: resolvers.slice(0, 3).map((r) => ({
|
|
81
|
+
hasResolver: !!r.resolver,
|
|
82
|
+
resolverKeys: r.resolver ? Object.keys(r.resolver) : []
|
|
83
|
+
}))
|
|
84
|
+
},
|
|
85
|
+
"server-schemas": {
|
|
86
|
+
schemaCount: schemas.length,
|
|
87
|
+
sample: schemas.slice(0, 2).map((s) => ({
|
|
88
|
+
defLength: s.def?.length || 0,
|
|
89
|
+
defPreview: s.def?.substring(0, 100) || "Empty"
|
|
90
|
+
}))
|
|
91
|
+
},
|
|
92
|
+
"server-directives": { directiveCount: directives.length },
|
|
93
|
+
"module-config": moduleConfig
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (format === "json") {
|
|
97
|
+
setResponseHeader(event, "Content-Type", "application/json");
|
|
98
|
+
return fullDebugInfo;
|
|
99
|
+
}
|
|
100
|
+
setResponseHeader(event, "Content-Type", "text/html");
|
|
101
|
+
return generateHtmlDashboard(fullDebugInfo);
|
|
102
|
+
});
|
|
103
|
+
function generateHtmlDashboard(debugInfo$1) {
|
|
104
|
+
return `<!DOCTYPE html>
|
|
105
|
+
<html lang="en">
|
|
106
|
+
<head>
|
|
107
|
+
<meta charset="UTF-8">
|
|
108
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
109
|
+
<title>Nitro GraphQL Debug Dashboard</title>
|
|
110
|
+
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"><\/script>
|
|
111
|
+
<style>
|
|
112
|
+
@keyframes fadeIn {
|
|
113
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
114
|
+
to { opacity: 1; transform: translateY(0); }
|
|
115
|
+
}
|
|
116
|
+
.animate-fade-in {
|
|
117
|
+
animation: fadeIn 0.3s ease-out;
|
|
118
|
+
}
|
|
119
|
+
/* Custom Scrollbar */
|
|
120
|
+
::-webkit-scrollbar {
|
|
121
|
+
width: 8px;
|
|
122
|
+
height: 8px;
|
|
123
|
+
}
|
|
124
|
+
::-webkit-scrollbar-track {
|
|
125
|
+
background: #0f172a;
|
|
126
|
+
border-radius: 4px;
|
|
127
|
+
}
|
|
128
|
+
::-webkit-scrollbar-thumb {
|
|
129
|
+
background: #334155;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
}
|
|
132
|
+
::-webkit-scrollbar-thumb:hover {
|
|
133
|
+
background: #475569;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
136
|
+
</head>
|
|
137
|
+
<body class="bg-slate-950 text-slate-200 min-h-screen">
|
|
138
|
+
<div class="container mx-auto max-w-7xl p-6 space-y-6 animate-fade-in">
|
|
139
|
+
<!-- Header -->
|
|
140
|
+
<div class="mb-8 border-b border-slate-800 pb-6">
|
|
141
|
+
<div class="flex items-center gap-3 mb-2">
|
|
142
|
+
<svg class="w-10 h-10" viewBox="0 0 400 400" fill="none">
|
|
143
|
+
<path d="M57.468 302.66l-14.376-8.3 160.15-277.38 14.376 8.3z" fill="#E535AB"/>
|
|
144
|
+
<path d="M39.8 272.2h320.3v16.6H39.8z" fill="#E535AB"/>
|
|
145
|
+
<path d="M206.348 374.026l-160.21-92.5 8.3-14.376 160.21 92.5z" fill="#E535AB"/>
|
|
146
|
+
<path d="M345.522 132.947l-160.21-92.5 8.3-14.376 160.21 92.5z" fill="#E535AB"/>
|
|
147
|
+
<path d="M54.482 132.883l-8.3-14.375 160.21-92.5 8.3 14.376z" fill="#E535AB"/>
|
|
148
|
+
<path d="M342.568 302.663l-160.15-277.38 14.376-8.3 160.15 277.38z" fill="#E535AB"/>
|
|
149
|
+
<path d="M52.5 107.5h16.6v185H52.5z" fill="#E535AB"/>
|
|
150
|
+
<path d="M330.9 107.5h16.6v185h-16.6z" fill="#E535AB"/>
|
|
151
|
+
<path d="M203.522 367l-7.25-12.558 139.34-80.45 7.25 12.557z" fill="#E535AB"/>
|
|
152
|
+
<path d="M369.5 297.9c-9.6 16.7-31 22.4-47.7 12.8-16.7-9.6-22.4-31-12.8-47.7 9.6-16.7 31-22.4 47.7-12.8 16.8 9.7 22.5 31 12.8 47.7M90.9 137c-9.6 16.7-31 22.4-47.7 12.8-16.7-9.6-22.4-31-12.8-47.7 9.6-16.7 31-22.4 47.7-12.8 16.7 9.7 22.4 31 12.8 47.7M30.5 297.9c-9.6-16.7-3.9-38 12.8-47.7 16.7-9.6 38-3.9 47.7 12.8 9.6 16.7 3.9 38-12.8 47.7-16.8 9.6-38.1 3.9-47.7-12.8M309.1 137c-9.6-16.7-3.9-38 12.8-47.7 16.7-9.6 38-3.9 47.7 12.8 9.6 16.7 3.9 38-12.8 47.7-16.7 9.6-38.1 3.9-47.7-12.8M200 395.8c-19.3 0-34.9-15.6-34.9-34.9 0-19.3 15.6-34.9 34.9-34.9 19.3 0 34.9 15.6 34.9 34.9 0 19.2-15.6 34.9-34.9 34.9M200 74c-19.3 0-34.9-15.6-34.9-34.9 0-19.3 15.6-34.9 34.9-34.9 19.3 0 34.9 15.6 34.9 34.9 0 19.3-15.6 34.9-34.9 34.9" fill="#E535AB"/>
|
|
153
|
+
</svg>
|
|
154
|
+
<div>
|
|
155
|
+
<h1 class="text-3xl font-bold text-slate-100">
|
|
156
|
+
Nitro GraphQL Debug
|
|
157
|
+
</h1>
|
|
158
|
+
<p class="text-sm text-slate-500">Development Diagnostics Dashboard</p>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<!-- Top Stats Grid -->
|
|
164
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
165
|
+
<!-- Environment Card -->
|
|
166
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
167
|
+
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
168
|
+
<span class="text-[#E535AB]">●</span> Environment
|
|
169
|
+
</h2>
|
|
170
|
+
<div class="space-y-3">
|
|
171
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
172
|
+
<span class="text-slate-400 text-sm">Mode</span>
|
|
173
|
+
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.environment.dev ? "Development" : "Production"}</span>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
176
|
+
<span class="text-slate-400 text-sm">Framework</span>
|
|
177
|
+
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.environment.framework}</span>
|
|
178
|
+
</div>
|
|
179
|
+
<div class="flex justify-between items-center py-2">
|
|
180
|
+
<span class="text-slate-400 text-sm">GraphQL Server</span>
|
|
181
|
+
<span class="text-slate-200 font-medium text-sm">${debugInfo$1.graphql.framework || "Not configured"}</span>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<!-- Scanned Files Card -->
|
|
187
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
188
|
+
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
189
|
+
<span class="text-[#E535AB]">●</span> Scanned Files
|
|
190
|
+
</h2>
|
|
191
|
+
<div class="space-y-3">
|
|
192
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
193
|
+
<span class="text-slate-400 text-sm">Schemas</span>
|
|
194
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.schemas}</span>
|
|
195
|
+
</div>
|
|
196
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
197
|
+
<span class="text-slate-400 text-sm">Resolvers</span>
|
|
198
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.resolvers}</span>
|
|
199
|
+
</div>
|
|
200
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
201
|
+
<span class="text-slate-400 text-sm">Directives</span>
|
|
202
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.directives}</span>
|
|
203
|
+
</div>
|
|
204
|
+
<div class="flex justify-between items-center py-2">
|
|
205
|
+
<span class="text-slate-400 text-sm">Documents</span>
|
|
206
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.scanned.documents}</span>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<!-- Runtime Info Card -->
|
|
212
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
213
|
+
<h2 class="text-lg font-semibold mb-4 text-slate-200 flex items-center gap-2">
|
|
214
|
+
<span class="text-[#E535AB]">●</span> Runtime Loaded
|
|
215
|
+
</h2>
|
|
216
|
+
<div class="space-y-3">
|
|
217
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
218
|
+
<span class="text-slate-400 text-sm">Resolvers</span>
|
|
219
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedResolvers}</span>
|
|
220
|
+
</div>
|
|
221
|
+
<div class="flex justify-between items-center py-2 border-b border-slate-800/50">
|
|
222
|
+
<span class="text-slate-400 text-sm">Schemas</span>
|
|
223
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedSchemas}</span>
|
|
224
|
+
</div>
|
|
225
|
+
<div class="flex justify-between items-center py-2">
|
|
226
|
+
<span class="text-slate-400 text-sm">Directives</span>
|
|
227
|
+
<span class="text-[#E535AB] font-semibold text-sm">${debugInfo$1.runtime.loadedDirectives}</span>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<!-- Resolver Exports -->
|
|
234
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6">
|
|
235
|
+
<div class="flex justify-between items-center mb-4">
|
|
236
|
+
<h2 class="text-xl font-semibold text-slate-200 flex items-center gap-2">
|
|
237
|
+
<span class="text-[#E535AB]">●</span> Resolver Exports
|
|
238
|
+
</h2>
|
|
239
|
+
${debugInfo$1.scanned.resolverFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.resolverFiles.length} files</span>` : ""}
|
|
240
|
+
</div>
|
|
241
|
+
${debugInfo$1.scanned.resolverFiles.length > 0 ? `
|
|
242
|
+
<div class="max-h-96 overflow-y-auto space-y-2 pr-2">
|
|
243
|
+
${debugInfo$1.scanned.resolverFiles.map((r) => {
|
|
244
|
+
const totalExports = r.exports.length;
|
|
245
|
+
return `
|
|
246
|
+
<div class="border border-slate-700/50 rounded-lg p-4 hover:border-[#E535AB]/20 hover:bg-slate-800/30 transition-all">
|
|
247
|
+
<div class="flex justify-between items-center mb-3">
|
|
248
|
+
<span class="text-slate-300 font-mono text-xs truncate pr-2">${r.file}</span>
|
|
249
|
+
<span class="bg-slate-800/80 px-2.5 py-0.5 rounded text-[#E535AB] text-[10px] font-semibold whitespace-nowrap">
|
|
250
|
+
${totalExports} export${totalExports !== 1 ? "s" : ""}
|
|
251
|
+
</span>
|
|
252
|
+
</div>
|
|
253
|
+
<div class="flex flex-wrap gap-1.5">
|
|
254
|
+
${r.exports.map((e) => {
|
|
255
|
+
const typeConfig = {
|
|
256
|
+
query: {
|
|
257
|
+
bg: "bg-blue-500/10",
|
|
258
|
+
text: "text-blue-400",
|
|
259
|
+
border: "border-blue-500/30",
|
|
260
|
+
symbol: "◆",
|
|
261
|
+
label: "query"
|
|
262
|
+
},
|
|
263
|
+
mutation: {
|
|
264
|
+
bg: "bg-[#E535AB]/10",
|
|
265
|
+
text: "text-[#E535AB]",
|
|
266
|
+
border: "border-[#E535AB]/30",
|
|
267
|
+
symbol: "●",
|
|
268
|
+
label: "mutation"
|
|
269
|
+
},
|
|
270
|
+
type: {
|
|
271
|
+
bg: "bg-purple-500/10",
|
|
272
|
+
text: "text-purple-400",
|
|
273
|
+
border: "border-purple-500/30",
|
|
274
|
+
symbol: "▲",
|
|
275
|
+
label: "type"
|
|
276
|
+
},
|
|
277
|
+
directive: {
|
|
278
|
+
bg: "bg-amber-500/10",
|
|
279
|
+
text: "text-amber-400",
|
|
280
|
+
border: "border-amber-500/30",
|
|
281
|
+
symbol: "@",
|
|
282
|
+
label: "directive"
|
|
283
|
+
},
|
|
284
|
+
resolver: {
|
|
285
|
+
bg: "bg-emerald-500/10",
|
|
286
|
+
text: "text-emerald-400",
|
|
287
|
+
border: "border-emerald-500/30",
|
|
288
|
+
symbol: "◉",
|
|
289
|
+
label: "resolver"
|
|
290
|
+
},
|
|
291
|
+
subscription: {
|
|
292
|
+
bg: "bg-teal-500/10",
|
|
293
|
+
text: "text-teal-400",
|
|
294
|
+
border: "border-teal-500/30",
|
|
295
|
+
symbol: "↻",
|
|
296
|
+
label: "subscription"
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const config = typeConfig[e.type] || typeConfig.resolver;
|
|
300
|
+
return `<span class="px-2.5 py-1 rounded border text-[11px] font-mono ${config.bg} ${config.text} ${config.border} hover:scale-105 transition-transform inline-flex items-center gap-1.5">
|
|
301
|
+
<span class="font-bold">${config.symbol}</span>
|
|
302
|
+
<span class="font-medium">${e.name}</span>
|
|
303
|
+
<span class="opacity-60 text-[9px] uppercase tracking-wide">${config.label}</span>
|
|
304
|
+
</span>`;
|
|
305
|
+
}).join("")}
|
|
306
|
+
</div>
|
|
307
|
+
</div>
|
|
308
|
+
`;
|
|
309
|
+
}).join("")}
|
|
310
|
+
</div>
|
|
311
|
+
` : "<p class=\"text-slate-500 text-sm\">No resolvers found</p>"}
|
|
312
|
+
</div>
|
|
313
|
+
|
|
314
|
+
<!-- Generated Virtual Modules -->
|
|
315
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6">
|
|
316
|
+
<div class="flex justify-between items-center mb-4">
|
|
317
|
+
<h2 class="text-xl font-semibold text-slate-200 flex items-center gap-2">
|
|
318
|
+
<span class="text-[#E535AB]">●</span> Generated Virtual Modules
|
|
319
|
+
</h2>
|
|
320
|
+
<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">
|
|
321
|
+
${Object.keys(debugInfo$1.virtualModules).length} modules
|
|
322
|
+
</span>
|
|
323
|
+
</div>
|
|
324
|
+
<div class="space-y-3">
|
|
325
|
+
${Object.entries(debugInfo$1.virtualModules).map(([moduleName, codeContent]) => {
|
|
326
|
+
const code = String(codeContent);
|
|
327
|
+
const moduleColors = {
|
|
328
|
+
"server-schemas": {
|
|
329
|
+
bg: "bg-blue-500/5",
|
|
330
|
+
border: "border-blue-500/20",
|
|
331
|
+
text: "text-blue-400"
|
|
332
|
+
},
|
|
333
|
+
"server-resolvers": {
|
|
334
|
+
bg: "bg-[#E535AB]/5",
|
|
335
|
+
border: "border-[#E535AB]/20",
|
|
336
|
+
text: "text-[#E535AB]"
|
|
337
|
+
},
|
|
338
|
+
"server-directives": {
|
|
339
|
+
bg: "bg-amber-500/5",
|
|
340
|
+
border: "border-amber-500/20",
|
|
341
|
+
text: "text-amber-400"
|
|
342
|
+
},
|
|
343
|
+
"module-config": {
|
|
344
|
+
bg: "bg-purple-500/5",
|
|
345
|
+
border: "border-purple-500/20",
|
|
346
|
+
text: "text-purple-400"
|
|
347
|
+
},
|
|
348
|
+
"graphql-config": {
|
|
349
|
+
bg: "bg-emerald-500/5",
|
|
350
|
+
border: "border-emerald-500/20",
|
|
351
|
+
text: "text-emerald-400"
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const colorConfig = moduleColors[moduleName] || moduleColors["module-config"];
|
|
355
|
+
const lineCount = code.split("\\n").length;
|
|
356
|
+
const byteSize = new TextEncoder().encode(code).length;
|
|
357
|
+
return `
|
|
358
|
+
<details class="border ${colorConfig.border} ${colorConfig.bg} rounded-lg overflow-hidden group">
|
|
359
|
+
<summary class="cursor-pointer p-4 hover:bg-slate-800/30 transition-all flex justify-between items-center">
|
|
360
|
+
<div class="flex items-center gap-3">
|
|
361
|
+
<span class="${colorConfig.text} text-lg">▸</span>
|
|
362
|
+
<div>
|
|
363
|
+
<span class="font-mono text-sm ${colorConfig.text} font-semibold">#nitro-internal-virtual/${moduleName}</span>
|
|
364
|
+
<div class="text-[10px] text-slate-500 mt-0.5">
|
|
365
|
+
${lineCount} lines · ${(byteSize / 1024).toFixed(2)} KB
|
|
366
|
+
</div>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
<button
|
|
370
|
+
onclick="event.stopPropagation(); navigator.clipboard.writeText(this.getAttribute('data-code')); this.textContent = '✓ Copied!'; setTimeout(() => this.textContent = 'Copy', 1000)"
|
|
371
|
+
data-code="${escapeHtml(code).replace(/"/g, """)}"
|
|
372
|
+
class="text-xs px-3 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded border border-slate-600/50 transition-colors"
|
|
373
|
+
>
|
|
374
|
+
Copy
|
|
375
|
+
</button>
|
|
376
|
+
</summary>
|
|
377
|
+
<div class="border-t ${colorConfig.border}">
|
|
378
|
+
<div class="bg-slate-950/80 p-4 max-h-96 overflow-auto">
|
|
379
|
+
<pre class="text-xs font-mono text-slate-300 leading-relaxed"><code>${escapeHtml(code)}</code></pre>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
</details>
|
|
383
|
+
`;
|
|
384
|
+
}).join("")}
|
|
385
|
+
</div>
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
<!-- Files Grid -->
|
|
389
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
390
|
+
<!-- Schema Files -->
|
|
391
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
392
|
+
<div class="flex justify-between items-center mb-4">
|
|
393
|
+
<h2 class="text-lg font-semibold text-slate-200 flex items-center gap-2">
|
|
394
|
+
<span class="text-[#E535AB]">●</span> Schema Files
|
|
395
|
+
</h2>
|
|
396
|
+
${debugInfo$1.scanned.schemaFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.schemaFiles.length} file${debugInfo$1.scanned.schemaFiles.length !== 1 ? "s" : ""}</span>` : ""}
|
|
397
|
+
</div>
|
|
398
|
+
<ul class="space-y-2 max-h-64 overflow-y-auto pr-2">
|
|
399
|
+
${debugInfo$1.scanned.schemaFiles.length > 0 ? debugInfo$1.scanned.schemaFiles.map((f) => `<li class="text-slate-400 font-mono text-xs flex items-start gap-2 py-1.5 px-2 rounded hover:bg-slate-800/50 transition-colors group">
|
|
400
|
+
<span class="text-[#E535AB] text-[10px] mt-0.5 group-hover:scale-110 transition-transform">▸</span>
|
|
401
|
+
<span class="truncate group-hover:text-slate-300">${f}</span>
|
|
402
|
+
</li>`).join("") : "<li class=\"text-slate-500 text-sm\">No schemas found</li>"}
|
|
403
|
+
</ul>
|
|
404
|
+
</div>
|
|
405
|
+
|
|
406
|
+
<!-- Document Files -->
|
|
407
|
+
<div class="bg-slate-900/50 border border-slate-700/50 rounded-lg p-6 hover:border-[#E535AB]/30 transition-all">
|
|
408
|
+
<div class="flex justify-between items-center mb-4">
|
|
409
|
+
<h2 class="text-lg font-semibold text-slate-200 flex items-center gap-2">
|
|
410
|
+
<span class="text-[#E535AB]">●</span> Document Files
|
|
411
|
+
</h2>
|
|
412
|
+
${debugInfo$1.scanned.documentFiles.length > 0 ? `<span class="text-xs text-slate-500 bg-slate-800/50 px-2 py-1 rounded">${debugInfo$1.scanned.documentFiles.length} file${debugInfo$1.scanned.documentFiles.length !== 1 ? "s" : ""}</span>` : ""}
|
|
413
|
+
</div>
|
|
414
|
+
<ul class="space-y-2 max-h-64 overflow-y-auto pr-2">
|
|
415
|
+
${debugInfo$1.scanned.documentFiles.length > 0 ? debugInfo$1.scanned.documentFiles.map((f) => `<li class="text-slate-400 font-mono text-xs flex items-start gap-2 py-1.5 px-2 rounded hover:bg-slate-800/50 transition-colors group">
|
|
416
|
+
<span class="text-[#E535AB] text-[10px] mt-0.5 group-hover:scale-110 transition-transform">▸</span>
|
|
417
|
+
<span class="truncate group-hover:text-slate-300">${f}</span>
|
|
418
|
+
</li>`).join("") : "<li class=\"text-slate-500 text-sm\">No documents found</li>"}
|
|
419
|
+
</ul>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
|
|
423
|
+
<!-- Reload Button -->
|
|
424
|
+
<button
|
|
425
|
+
onclick="location.reload()"
|
|
426
|
+
class="fixed bottom-8 right-8 bg-[#E535AB] hover:bg-[#d12a99] text-white font-semibold px-6 py-3 rounded-lg shadow-lg hover:shadow-xl hover:shadow-[#E535AB]/20 transform hover:-translate-y-1 transition-all duration-200 flex items-center gap-2 border border-[#E535AB]/20"
|
|
427
|
+
>
|
|
428
|
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
|
429
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
|
430
|
+
</svg>
|
|
431
|
+
Reload
|
|
432
|
+
</button>
|
|
433
|
+
</div>
|
|
434
|
+
</body>
|
|
435
|
+
</html>`;
|
|
436
|
+
}
|
|
437
|
+
function escapeHtml(text) {
|
|
438
|
+
const map = {
|
|
439
|
+
"&": "&",
|
|
440
|
+
"<": "<",
|
|
441
|
+
">": ">",
|
|
442
|
+
"\"": """,
|
|
443
|
+
"'": "'"
|
|
444
|
+
};
|
|
445
|
+
return text.replace(/[&<>"']/g, (m) => map[m] || m);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
export { debug_default as default };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ declare module 'nitro/types' {
|
|
|
57
57
|
graphql?: NitroGraphQLOptions;
|
|
58
58
|
}
|
|
59
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
|
+
}
|
|
60
72
|
interface ExternalGraphQLService {
|
|
61
73
|
/** Unique name for this service (used for file naming and type generation) */
|
|
62
74
|
name: string;
|
|
@@ -83,6 +95,12 @@ interface ExternalGraphQLService {
|
|
|
83
95
|
client?: CodegenClientConfig;
|
|
84
96
|
clientSDK?: GenericSdkConfig;
|
|
85
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;
|
|
86
104
|
}
|
|
87
105
|
interface FederationConfig {
|
|
88
106
|
/** Enable Apollo Federation subgraph support */
|
|
@@ -94,6 +112,81 @@ interface FederationConfig {
|
|
|
94
112
|
/** Service URL for federation gateway */
|
|
95
113
|
serviceUrl?: string;
|
|
96
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
|
+
}
|
|
97
190
|
interface NitroGraphQLOptions {
|
|
98
191
|
framework: 'graphql-yoga' | 'apollo-server';
|
|
99
192
|
endpoint?: {
|
|
@@ -123,6 +216,31 @@ interface NitroGraphQLOptions {
|
|
|
123
216
|
layerDirectories?: string[];
|
|
124
217
|
layerServerDirs?: string[];
|
|
125
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;
|
|
126
244
|
}
|
|
127
245
|
//#endregion
|
|
128
|
-
export { CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, FederationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions };
|
|
246
|
+
export { ClientUtilsConfig, CodegenClientConfig, CodegenServerConfig, ExternalGraphQLService, ExternalServicePaths, FederationConfig, FileGenerationConfig, GenImport, GenericSdkConfig, NitroGraphQLOptions, PathsConfig, ScaffoldConfig, SdkConfig, TypesConfig };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//#region src/types/standard-schema.d.ts
|
|
2
2
|
/** The Standard Schema interface. */
|
|
3
|
-
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
|
+
interface StandardSchemaV1<Input$1 = unknown, Output$1 = Input$1> {
|
|
4
4
|
/** The Standard Schema properties. */
|
|
5
|
-
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
5
|
+
readonly '~standard': StandardSchemaV1.Props<Input$1, Output$1>;
|
|
6
6
|
}
|
|
7
7
|
declare namespace StandardSchemaV1 {
|
|
8
8
|
/** The Standard Schema properties interface. */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Nitro } from "nitropack/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 };
|