nitro-graphql 2.0.0-beta.7 → 2.0.0-beta.72

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 (242) hide show
  1. package/README.md +31 -1196
  2. package/dist/cli/adapter.d.mts +13 -0
  3. package/dist/cli/adapter.mjs +67 -0
  4. package/dist/cli/commands/build.d.mts +21 -0
  5. package/dist/cli/commands/build.mjs +50 -0
  6. package/dist/cli/commands/dev.d.mts +40 -0
  7. package/dist/cli/commands/dev.mjs +74 -0
  8. package/dist/cli/commands/generate.d.mts +25 -0
  9. package/dist/cli/commands/generate.mjs +198 -0
  10. package/dist/cli/commands/index.d.mts +5 -0
  11. package/dist/cli/commands/index.mjs +5 -0
  12. package/dist/cli/commands/init.d.mts +45 -0
  13. package/dist/cli/commands/init.mjs +195 -0
  14. package/dist/cli/commands/validate.d.mts +9 -0
  15. package/dist/cli/commands/validate.mjs +65 -0
  16. package/dist/cli/completions.d.mts +6 -0
  17. package/dist/cli/completions.mjs +32 -0
  18. package/dist/cli/config.d.mts +18 -0
  19. package/dist/cli/config.mjs +19 -0
  20. package/dist/cli/index.d.mts +26 -0
  21. package/dist/cli/index.mjs +315 -0
  22. package/dist/cli/server/debug-handler.d.mts +9 -0
  23. package/dist/cli/server/debug-handler.mjs +68 -0
  24. package/dist/cli/server/dev-server.d.mts +29 -0
  25. package/dist/cli/server/dev-server.mjs +62 -0
  26. package/dist/cli/server/graphql-handler.d.mts +21 -0
  27. package/dist/cli/server/graphql-handler.mjs +43 -0
  28. package/dist/cli/server/health-handler.d.mts +12 -0
  29. package/dist/cli/server/health-handler.mjs +29 -0
  30. package/dist/cli/server/loader.d.mts +33 -0
  31. package/dist/cli/server/loader.mjs +144 -0
  32. package/dist/cli/server/sandbox-handler.d.mts +12 -0
  33. package/dist/cli/server/sandbox-handler.mjs +17 -0
  34. package/dist/cli/server/watcher.d.mts +20 -0
  35. package/dist/cli/server/watcher.mjs +64 -0
  36. package/dist/cli/server/ws-handler.d.mts +28 -0
  37. package/dist/cli/server/ws-handler.mjs +48 -0
  38. package/dist/config.d.mts +2 -0
  39. package/dist/config.mjs +2 -0
  40. package/dist/core/codegen/client.d.mts +42 -0
  41. package/dist/core/codegen/client.mjs +551 -0
  42. package/dist/core/codegen/document-loader.d.mts +9 -0
  43. package/dist/core/codegen/document-loader.mjs +16 -0
  44. package/dist/core/codegen/index.d.mts +8 -0
  45. package/dist/core/codegen/index.mjs +8 -0
  46. package/dist/core/codegen/plugin.d.mts +19 -0
  47. package/dist/core/codegen/plugin.mjs +29 -0
  48. package/dist/core/codegen/runtime.d.mts +17 -0
  49. package/dist/core/codegen/runtime.mjs +61 -0
  50. package/dist/core/codegen/schema-loader.d.mts +27 -0
  51. package/dist/core/codegen/schema-loader.mjs +126 -0
  52. package/dist/core/codegen/server.d.mts +27 -0
  53. package/dist/core/codegen/server.mjs +142 -0
  54. package/dist/core/codegen/validation.d.mts +17 -0
  55. package/dist/core/codegen/validation.mjs +33 -0
  56. package/dist/core/config.d.mts +45 -0
  57. package/dist/core/config.mjs +76 -0
  58. package/dist/core/constants.d.mts +188 -0
  59. package/dist/core/constants.mjs +208 -0
  60. package/dist/core/debug/index.d.mts +2 -0
  61. package/dist/core/debug/index.mjs +2 -0
  62. package/dist/core/debug/template.d.mts +52 -0
  63. package/dist/core/debug/template.mjs +384 -0
  64. package/dist/core/extend/index.d.mts +2 -0
  65. package/dist/core/extend/index.mjs +2 -0
  66. package/dist/core/extend/loader.d.mts +40 -0
  67. package/dist/core/extend/loader.mjs +196 -0
  68. package/dist/core/index.d.mts +33 -0
  69. package/dist/core/index.mjs +28 -0
  70. package/dist/core/manifest.d.mts +56 -0
  71. package/dist/core/manifest.mjs +100 -0
  72. package/dist/core/pubsub/index.d.mts +109 -0
  73. package/dist/core/pubsub/index.mjs +146 -0
  74. package/dist/core/scanning/ast-scanner.d.mts +27 -0
  75. package/dist/core/scanning/ast-scanner.mjs +114 -0
  76. package/dist/core/scanning/common.d.mts +25 -0
  77. package/dist/core/scanning/common.mjs +57 -0
  78. package/dist/core/scanning/directives.d.mts +13 -0
  79. package/dist/core/scanning/directives.mjs +28 -0
  80. package/dist/core/scanning/documents.d.mts +20 -0
  81. package/dist/core/scanning/documents.mjs +36 -0
  82. package/dist/core/scanning/index.d.mts +7 -0
  83. package/dist/core/scanning/index.mjs +7 -0
  84. package/dist/core/scanning/resolvers.d.mts +14 -0
  85. package/dist/core/scanning/resolvers.mjs +58 -0
  86. package/dist/core/scanning/schemas.d.mts +13 -0
  87. package/dist/core/scanning/schemas.mjs +50 -0
  88. package/dist/core/schema/builder.d.mts +59 -0
  89. package/dist/core/schema/builder.mjs +76 -0
  90. package/dist/core/schema/federation.d.mts +33 -0
  91. package/dist/core/schema/federation.mjs +38 -0
  92. package/dist/core/schema/index.d.mts +3 -0
  93. package/dist/core/schema/index.mjs +3 -0
  94. package/dist/core/server/index.d.mts +4 -0
  95. package/dist/core/server/index.mjs +3 -0
  96. package/dist/core/server/sandbox.d.mts +18 -0
  97. package/dist/core/server/sandbox.mjs +38 -0
  98. package/dist/core/server/types.d.mts +54 -0
  99. package/dist/core/server/types.mjs +1 -0
  100. package/dist/core/server/yoga.d.mts +42 -0
  101. package/dist/core/server/yoga.mjs +87 -0
  102. package/dist/core/types/adapter.d.mts +55 -0
  103. package/dist/core/types/adapter.mjs +1 -0
  104. package/dist/core/types/codegen.d.mts +136 -0
  105. package/dist/core/types/codegen.mjs +1 -0
  106. package/dist/core/types/config.d.mts +188 -0
  107. package/dist/core/types/config.mjs +1 -0
  108. package/dist/{utils/define.d.ts → core/types/define.d.mts} +2 -30
  109. package/dist/core/types/define.mjs +1 -0
  110. package/dist/core/types/index.d.mts +5 -0
  111. package/dist/core/types/index.mjs +1 -0
  112. package/dist/core/types/scanning.d.mts +64 -0
  113. package/dist/core/types/scanning.mjs +1 -0
  114. package/dist/{utils/directive-parser.d.ts → core/utils/directive-parser.d.mts} +18 -4
  115. package/dist/{utils/directive-parser.js → core/utils/directive-parser.mjs} +29 -36
  116. package/dist/core/utils/errors.d.mts +77 -0
  117. package/dist/core/utils/errors.mjs +91 -0
  118. package/dist/core/utils/file-io.d.mts +24 -0
  119. package/dist/core/utils/file-io.mjs +45 -0
  120. package/dist/core/utils/imports.d.mts +15 -0
  121. package/dist/core/utils/imports.mjs +24 -0
  122. package/dist/core/utils/index.d.mts +7 -0
  123. package/dist/core/utils/index.mjs +7 -0
  124. package/dist/core/utils/logger.d.mts +18 -0
  125. package/dist/core/utils/logger.mjs +36 -0
  126. package/dist/core/utils/ofetch-templates.d.mts +30 -0
  127. package/dist/core/utils/ofetch-templates.mjs +134 -0
  128. package/dist/core/utils/runtime.d.mts +74 -0
  129. package/dist/core/utils/runtime.mjs +109 -0
  130. package/dist/core/utils/subscribe-templates.d.mts +8 -0
  131. package/dist/core/utils/subscribe-templates.mjs +58 -0
  132. package/dist/core/validation/external-services.d.mts +11 -0
  133. package/dist/core/validation/external-services.mjs +33 -0
  134. package/dist/core/validation/index.d.mts +2 -0
  135. package/dist/core/validation/index.mjs +2 -0
  136. package/dist/core/watcher/index.d.mts +107 -0
  137. package/dist/core/watcher/index.mjs +140 -0
  138. package/dist/define.d.mts +294 -0
  139. package/dist/define.mjs +323 -0
  140. package/dist/index.d.mts +6 -0
  141. package/dist/index.mjs +5 -0
  142. package/dist/nitro/adapter.d.mts +28 -0
  143. package/dist/nitro/adapter.mjs +90 -0
  144. package/dist/{utils/apollo.d.ts → nitro/apollo.d.mts} +3 -3
  145. package/dist/nitro/apollo.mjs +57 -0
  146. package/dist/nitro/codegen.d.mts +18 -0
  147. package/dist/nitro/codegen.mjs +171 -0
  148. package/dist/nitro/config.d.mts +50 -0
  149. package/dist/nitro/config.mjs +55 -0
  150. package/dist/nitro/index.d.mts +45 -0
  151. package/dist/nitro/index.mjs +63 -0
  152. package/dist/{utils/path-resolver.d.ts → nitro/paths.d.mts} +8 -25
  153. package/dist/nitro/paths.mjs +97 -0
  154. package/dist/nitro/rollup.d.mts +6 -0
  155. package/dist/nitro/rollup.mjs +52 -0
  156. package/dist/nitro/routes/apollo-sandbox-script.d.mts +6 -0
  157. package/dist/nitro/routes/apollo-sandbox-script.mjs +12 -0
  158. package/dist/nitro/routes/apollo-server-ws.d.mts +15 -0
  159. package/dist/nitro/routes/apollo-server-ws.mjs +50 -0
  160. package/dist/nitro/routes/apollo-server.d.mts +6 -0
  161. package/dist/nitro/routes/apollo-server.mjs +69 -0
  162. package/dist/{routes/debug.d.ts → nitro/routes/debug.d.mts} +12 -19
  163. package/dist/nitro/routes/debug.mjs +98 -0
  164. package/dist/nitro/routes/graphql-yoga-ws.d.mts +12 -0
  165. package/dist/nitro/routes/graphql-yoga-ws.mjs +50 -0
  166. package/dist/nitro/routes/graphql-yoga.d.mts +12 -0
  167. package/dist/nitro/routes/graphql-yoga.mjs +39 -0
  168. package/dist/nitro/routes/health.d.mts +10 -0
  169. package/dist/{routes/health.js → nitro/routes/health.mjs} +5 -6
  170. package/dist/nitro/setup/extend-loader.d.mts +16 -0
  171. package/dist/nitro/setup/extend-loader.mjs +80 -0
  172. package/dist/nitro/setup/file-watcher.d.mts +18 -0
  173. package/dist/nitro/setup/file-watcher.mjs +62 -0
  174. package/dist/nitro/setup/logging.d.mts +16 -0
  175. package/dist/nitro/setup/logging.mjs +64 -0
  176. package/dist/nitro/setup/rollup-integration.d.mts +24 -0
  177. package/dist/nitro/setup/rollup-integration.mjs +64 -0
  178. package/dist/nitro/setup/routes.d.mts +13 -0
  179. package/dist/nitro/setup/routes.mjs +69 -0
  180. package/dist/nitro/setup/scanner.d.mts +59 -0
  181. package/dist/nitro/setup/scanner.mjs +118 -0
  182. package/dist/nitro/setup/ts-config.d.mts +10 -0
  183. package/dist/nitro/setup/ts-config.mjs +67 -0
  184. package/dist/nitro/setup.d.mts +11 -0
  185. package/dist/nitro/setup.mjs +189 -0
  186. package/dist/nitro/types.d.mts +549 -0
  187. package/dist/nitro/types.mjs +1 -0
  188. package/dist/nitro/virtual/generators.d.mts +38 -0
  189. package/dist/nitro/virtual/generators.mjs +190 -0
  190. package/dist/nitro/virtual/stubs.d.mts +21 -0
  191. package/dist/nitro/virtual/stubs.mjs +31 -0
  192. package/dist/{ecosystem/nuxt.d.ts → nuxt.d.mts} +1 -1
  193. package/dist/nuxt.mjs +111 -0
  194. package/dist/{graphql/server.d.ts → stubs/index.d.mts} +5 -1
  195. package/dist/stubs/index.mjs +1 -0
  196. package/dist/subscribe/index.d.mts +78 -0
  197. package/dist/subscribe/index.mjs +205 -0
  198. package/native/index.d.ts +20 -0
  199. package/native/index.js +585 -0
  200. package/package.json +202 -112
  201. package/dist/ecosystem/nuxt.js +0 -67
  202. package/dist/graphql/index.d.ts +0 -5
  203. package/dist/graphql/index.js +0 -1
  204. package/dist/graphql/server.js +0 -1
  205. package/dist/index.d.ts +0 -8
  206. package/dist/index.js +0 -318
  207. package/dist/rollup.js +0 -277
  208. package/dist/routes/apollo-server.d.ts +0 -6
  209. package/dist/routes/apollo-server.js +0 -89
  210. package/dist/routes/debug.js +0 -449
  211. package/dist/routes/graphql-yoga.d.ts +0 -6
  212. package/dist/routes/graphql-yoga.js +0 -91
  213. package/dist/routes/health.d.ts +0 -10
  214. package/dist/types/index.d.ts +0 -246
  215. package/dist/types/standard-schema.d.ts +0 -59
  216. package/dist/utils/apollo.js +0 -61
  217. package/dist/utils/client-codegen.d.ts +0 -38
  218. package/dist/utils/client-codegen.js +0 -290
  219. package/dist/utils/define.js +0 -57
  220. package/dist/utils/file-generator.d.ts +0 -37
  221. package/dist/utils/file-generator.js +0 -72
  222. package/dist/utils/index.d.ts +0 -39
  223. package/dist/utils/index.js +0 -278
  224. package/dist/utils/path-resolver.js +0 -127
  225. package/dist/utils/server-codegen.d.ts +0 -7
  226. package/dist/utils/server-codegen.js +0 -136
  227. package/dist/utils/type-generation.d.ts +0 -7
  228. package/dist/utils/type-generation.js +0 -360
  229. package/dist/virtual/debug-info.d.ts +0 -9
  230. package/dist/virtual/debug-info.js +0 -26
  231. package/dist/virtual/graphql-config.d.ts +0 -9
  232. package/dist/virtual/graphql-config.js +0 -10
  233. package/dist/virtual/module-config.d.ts +0 -9
  234. package/dist/virtual/module-config.js +0 -10
  235. package/dist/virtual/server-directives.d.ts +0 -11
  236. package/dist/virtual/server-directives.js +0 -10
  237. package/dist/virtual/server-resolvers.d.ts +0 -11
  238. package/dist/virtual/server-resolvers.js +0 -10
  239. package/dist/virtual/server-schemas.d.ts +0 -11
  240. package/dist/virtual/server-schemas.js +0 -10
  241. package/dist/vite.d.ts +0 -25
  242. package/dist/vite.js +0 -40
@@ -0,0 +1,28 @@
1
+ import { BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, SERVICE_DEFAULT } from "./constants.mjs";
2
+ import { GENERATED_FILE_HEADER, pluginContent } from "./codegen/plugin.mjs";
3
+ import { loadGraphQLDocuments } from "./codegen/document-loader.mjs";
4
+ import { ensureDir, readFileSafe, writeFile, writeFileIfChanged } from "./utils/file-io.mjs";
5
+ import { downloadAndSaveSchema, graphQLLoadSchemaSync, loadExternalSchema } from "./codegen/schema-loader.mjs";
6
+ import { DEFAULT_CLIENT_CODEGEN_CONFIG, extractSubscriptions, generateClientTypesCore, generateExternalClientTypesCore, generateSubscriptionBuilder } from "./codegen/client.mjs";
7
+ import { generateResolverModule, generateRuntimeIndex, generateSchemaModule } from "./codegen/runtime.mjs";
8
+ import { DEFAULT_SERVER_CODEGEN_CONFIG, generateServerTypesCore, generateTypes } from "./codegen/server.mjs";
9
+ import { validateNoDuplicateTypes, validateSchemaFiles } from "./codegen/validation.mjs";
10
+ import { createLogger, createSilentLogger, defaultLogger } from "./utils/logger.mjs";
11
+ import { createCoreConfig, createCoreContext, createScanContext, mergeGraphQLOptions } from "./config.mjs";
12
+ import { isLocalPath, loadPackageConfig, resolvePackageFiles } from "./manifest.mjs";
13
+ import { deduplicateFiles, extractPaths, filterByExtension, scanDirectory } from "./scanning/common.mjs";
14
+ import { parseSingleFile, scanWithAST } from "./scanning/ast-scanner.mjs";
15
+ import { parseDirectiveCall, scanDirectivesCore } from "./scanning/directives.mjs";
16
+ import { scanDocumentsCore } from "./scanning/documents.mjs";
17
+ import { parseResolverCall, scanResolversCore } from "./scanning/resolvers.mjs";
18
+ import { scanGraphqlCore, scanSchemasCore } from "./scanning/schemas.mjs";
19
+ import { loadFederationSupport, resetFederationCache, warnFederationUnavailable } from "./schema/federation.mjs";
20
+ import { BASE_SCHEMA, buildGraphQLSchema, createMergedSchema, parse, subscribe, validate } from "./schema/builder.mjs";
21
+ import { APOLLO_SANDBOX_CDN, createSandboxResponse, fetchSandboxScript } from "./server/sandbox.mjs";
22
+ import { BASE_SCHEMA as BASE_SCHEMA$1, apolloSandboxHtml, createYogaServer } from "./server/yoga.mjs";
23
+ import { DirectiveParser, directiveParser, generateDirectiveSchema, generateDirectiveSchemas } from "./utils/directive-parser.mjs";
24
+ import { createDefaultMaskError } from "./utils/errors.mjs";
25
+ import { getImportId, relativeWithDot } from "./utils/imports.mjs";
26
+ import { generateOfetchTemplate } from "./utils/ofetch-templates.mjs";
27
+ import { validateExternalServices } from "./validation/external-services.mjs";
28
+ export { APOLLO_SANDBOX_CDN, BASE_SCHEMA, BUILTIN_SCALARS, CHUNK_NAME_RESOLVERS, CHUNK_NAME_SCHEMAS, CHUNK_PATH_GRAPHQL, CHUNK_PATH_UNKNOWN, CODEGEN_EXTERNALS, DEFAULT_CLIENT_CODEGEN_CONFIG, DEFAULT_CLIENT_TYPES_PATH, DEFAULT_GRAPHQL_SCALARS, DEFAULT_SERVER_CODEGEN_CONFIG, DEFAULT_SERVER_TYPES_PATH, DEFINE_DIRECTIVE, DEFINE_FIELD, DEFINE_FUNCTIONS, DEFINE_GRAPHQL_CONFIG, DEFINE_MUTATION, DEFINE_QUERY, DEFINE_RESOLVER, DEFINE_SCHEMA, DEFINE_SUBSCRIPTION, DIRECTIVE_EXTENSIONS, DIRECTIVE_GLOB_PATTERN, DIR_APP_GRAPHQL, DIR_BUILD_NITRO, DIR_BUILD_NUXT, DIR_CLIENT_GRAPHQL, DIR_EXTERNAL, DIR_ROUTES_GRAPHQL, DIR_SERVER_GRAPHQL, DIR_SERVER_GRAPHQL_WIN, DirectiveParser, ENDPOINT_DEBUG, ENDPOINT_GRAPHQL, ENDPOINT_HEALTH, FEDERATION_EXTERNALS, FILE_CLIENT_TYPES, FILE_CONFIG_TS, FILE_CONTEXT_DTS, FILE_CONTEXT_TS, FILE_DIRECTIVES_GRAPHQL, FILE_GRAPHQL_CONFIG, FILE_GRAPHQL_DTS, FILE_INDEX_TS, FILE_OFETCH_TS, FILE_SCHEMA_GRAPHQL, FILE_SCHEMA_TS, FILE_SDK_TS, FILE_SERVER_TYPES, FRAMEWORK_NITRO, FRAMEWORK_NUXT, FRAMEWORK_STANDALONE, GENERATED_FILE_HEADER, GLOB_SCAN_PATTERN, GRAPHQL_EXTENSIONS, GRAPHQL_FRAMEWORK_APOLLO, GRAPHQL_FRAMEWORK_YOGA, GRAPHQL_GLOB_PATTERN, GRAPHQL_HTTP_METHODS, HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_INTERNAL_ERROR, LOG_TAG, PATTERN_CLIENT_EXTERNAL_TYPES, PLACEHOLDER_BUILD_DIR, PLACEHOLDER_CLIENT_DIR, PLACEHOLDER_FRAMEWORK, PLACEHOLDER_ROOT_DIR, PLACEHOLDER_SERVER_DIR, PLACEHOLDER_SERVICE_NAME, PLACEHOLDER_TYPES_DIR, RESOLVER_EXTENSIONS, RESOLVER_GLOB_PATTERN, RESOLVER_TYPE_DIRECTIVE, RESOLVER_TYPE_MUTATION, RESOLVER_TYPE_QUERY, RESOLVER_TYPE_RESOLVER, RESOLVER_TYPE_SUBSCRIPTION, RESOLVER_TYPE_TYPE, SERVICE_DEFAULT, BASE_SCHEMA$1 as YOGA_BASE_SCHEMA, apolloSandboxHtml, buildGraphQLSchema, createCoreConfig, createCoreContext, createDefaultMaskError, createLogger, createMergedSchema, createSandboxResponse, createScanContext, createSilentLogger, createYogaServer, deduplicateFiles, defaultLogger, directiveParser, downloadAndSaveSchema, ensureDir, extractPaths, extractSubscriptions, fetchSandboxScript, filterByExtension, generateClientTypesCore, generateDirectiveSchema, generateDirectiveSchemas, generateExternalClientTypesCore, generateOfetchTemplate, generateResolverModule, generateRuntimeIndex, generateSchemaModule, generateServerTypesCore, generateSubscriptionBuilder, generateTypes, getImportId, graphQLLoadSchemaSync, isLocalPath, loadExternalSchema, loadFederationSupport, loadGraphQLDocuments, loadPackageConfig, mergeGraphQLOptions, parse, parseDirectiveCall, parseResolverCall, parseSingleFile, pluginContent, readFileSafe, relativeWithDot, resetFederationCache, resolvePackageFiles, scanDirectivesCore, scanDirectory, scanDocumentsCore, scanGraphqlCore, scanResolversCore, scanSchemasCore, scanWithAST, subscribe, validate, validateExternalServices, validateNoDuplicateTypes, validateSchemaFiles, warnFederationUnavailable, writeFile, writeFileIfChanged };
@@ -0,0 +1,56 @@
1
+ //#region src/core/manifest.d.ts
2
+ /**
3
+ * Package Config Loader
4
+ * Loads package configuration for extend functionality
5
+ */
6
+ /**
7
+ * Package config structure (subset of CLIConfig)
8
+ */
9
+ interface PackageConfig {
10
+ serverDir?: string;
11
+ clientDir?: string;
12
+ }
13
+ /**
14
+ * Resolved package with config and base directory
15
+ */
16
+ interface ResolvedPackage {
17
+ config: PackageConfig;
18
+ baseDir: string;
19
+ }
20
+ /**
21
+ * Resolved extend paths
22
+ */
23
+ interface ResolvedExtend {
24
+ schemas: string[];
25
+ resolvers: string[];
26
+ directives: string[];
27
+ documents: string[];
28
+ serverDir: string;
29
+ clientDir?: string;
30
+ /** Path to config.ts if it exists */
31
+ configPath?: string;
32
+ /** Path to schema.ts if it exists */
33
+ schemaPath?: string;
34
+ }
35
+ /**
36
+ * Check if source is a local path (relative or absolute)
37
+ */
38
+ declare function isLocalPath(source: string): boolean;
39
+ /**
40
+ * Load config from package or local directory
41
+ * Uses c12 for proper config loading with TypeScript support
42
+ *
43
+ * @param source - Package name or local path (./path, ../path, /absolute/path)
44
+ * @param rootDir - Root directory for resolution
45
+ * @returns Resolved package with config and base directory, or null if not found
46
+ */
47
+ declare function loadPackageConfig(source: string, rootDir: string): Promise<ResolvedPackage | null>;
48
+ /**
49
+ * Scan package's serverDir and resolve all GraphQL files
50
+ *
51
+ * @param pkg - Resolved package with config
52
+ * @returns Resolved file paths
53
+ */
54
+ declare function resolvePackageFiles(pkg: ResolvedPackage): Promise<ResolvedExtend>;
55
+ //#endregion
56
+ export { PackageConfig, ResolvedExtend, ResolvedPackage, isLocalPath, loadPackageConfig, resolvePackageFiles };
@@ -0,0 +1,100 @@
1
+ import { DIRECTIVE_EXTENSIONS, GRAPHQL_EXTENSIONS, RESOLVER_EXTENSIONS } from "./constants.mjs";
2
+ import { dirname, isAbsolute, resolve } from "pathe";
3
+ import { existsSync } from "node:fs";
4
+ import { loadConfig } from "c12";
5
+ import { resolvePath } from "mlly";
6
+ import { glob } from "tinyglobby";
7
+ //#region src/core/manifest.ts
8
+ /**
9
+ * Package Config Loader
10
+ * Loads package configuration for extend functionality
11
+ */
12
+ /**
13
+ * Check if source is a local path (relative or absolute)
14
+ */
15
+ function isLocalPath(source) {
16
+ return source.startsWith(".") || isAbsolute(source);
17
+ }
18
+ /**
19
+ * Load config from package or local directory
20
+ * Uses c12 for proper config loading with TypeScript support
21
+ *
22
+ * @param source - Package name or local path (./path, ../path, /absolute/path)
23
+ * @param rootDir - Root directory for resolution
24
+ * @returns Resolved package with config and base directory, or null if not found
25
+ */
26
+ async function loadPackageConfig(source, rootDir) {
27
+ try {
28
+ let pkgDir;
29
+ if (isLocalPath(source)) {
30
+ pkgDir = resolve(rootDir, source);
31
+ if (!existsSync(pkgDir)) return null;
32
+ } else pkgDir = dirname(await resolvePath(`${source}/package.json`, {
33
+ url: rootDir,
34
+ extensions: [".json"]
35
+ }));
36
+ const { config } = await loadConfig({
37
+ name: "nitro-graphql",
38
+ cwd: pkgDir,
39
+ defaultConfig: { serverDir: "server/graphql" }
40
+ });
41
+ const resolvedConfig = {
42
+ serverDir: config?.serverDir || "server/graphql",
43
+ clientDir: config?.clientDir
44
+ };
45
+ if (!existsSync(resolve(pkgDir, resolvedConfig.serverDir))) return null;
46
+ return {
47
+ config: resolvedConfig,
48
+ baseDir: pkgDir
49
+ };
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+ /**
55
+ * Scan package's serverDir and resolve all GraphQL files
56
+ *
57
+ * @param pkg - Resolved package with config
58
+ * @returns Resolved file paths
59
+ */
60
+ async function resolvePackageFiles(pkg) {
61
+ const serverDir = resolve(pkg.baseDir, pkg.config.serverDir || "server/graphql");
62
+ const clientDir = pkg.config.clientDir ? resolve(pkg.baseDir, pkg.config.clientDir) : void 0;
63
+ const schemaPattern = `**/*{${GRAPHQL_EXTENSIONS.join(",")}}`;
64
+ const resolverPattern = `**/*{${RESOLVER_EXTENSIONS.join(",")}}`;
65
+ const directivePattern = `**/*{${DIRECTIVE_EXTENSIONS.join(",")}}`;
66
+ const scanPromises = [
67
+ glob(schemaPattern, {
68
+ cwd: serverDir,
69
+ absolute: true
70
+ }),
71
+ glob(resolverPattern, {
72
+ cwd: serverDir,
73
+ absolute: true
74
+ }),
75
+ glob(directivePattern, {
76
+ cwd: serverDir,
77
+ absolute: true
78
+ })
79
+ ];
80
+ if (clientDir && existsSync(clientDir)) scanPromises.push(glob(schemaPattern, {
81
+ cwd: clientDir,
82
+ absolute: true
83
+ }));
84
+ else scanPromises.push(Promise.resolve([]));
85
+ const [schemas = [], resolvers = [], directives = [], documents = []] = await Promise.all(scanPromises);
86
+ const configPath = resolve(serverDir, "config.ts");
87
+ const schemaPath = resolve(serverDir, "schema.ts");
88
+ return {
89
+ schemas: schemas.sort((a, b) => a.localeCompare(b)),
90
+ resolvers: resolvers.sort((a, b) => a.localeCompare(b)),
91
+ directives: directives.sort((a, b) => a.localeCompare(b)),
92
+ documents: documents.sort((a, b) => a.localeCompare(b)),
93
+ serverDir,
94
+ clientDir,
95
+ configPath: existsSync(configPath) ? configPath : void 0,
96
+ schemaPath: existsSync(schemaPath) ? schemaPath : void 0
97
+ };
98
+ }
99
+ //#endregion
100
+ export { isLocalPath, loadPackageConfig, resolvePackageFiles };
@@ -0,0 +1,109 @@
1
+ //#region src/core/pubsub/index.d.ts
2
+ /**
3
+ * Built-in PubSub implementation for GraphQL Subscriptions
4
+ * Simple EventEmitter-based implementation for single-instance deployments
5
+ *
6
+ * For multi-instance deployments, use external PubSub solutions like:
7
+ * - Redis (with ioredis)
8
+ * - Kafka
9
+ * - RabbitMQ
10
+ * - Cloud Pub/Sub services
11
+ */
12
+ /**
13
+ * Generic PubSub engine interface
14
+ * Compatible with various PubSub implementations
15
+ */
16
+ interface PubSubEngine<Topics extends Record<string, unknown> = Record<string, unknown>> {
17
+ /**
18
+ * Publish an event to a topic
19
+ * @param topic - Topic name to publish to
20
+ * @param payload - Event payload
21
+ */
22
+ publish: <K extends keyof Topics>(topic: K, payload: Topics[K]) => Promise<void>;
23
+ /**
24
+ * Subscribe to a topic
25
+ * @param topic - Topic name to subscribe to
26
+ * @returns AsyncIterable that yields events
27
+ */
28
+ subscribe: <K extends keyof Topics>(topic: K) => AsyncIterable<Topics[K]>;
29
+ }
30
+ /**
31
+ * Type alias for typed PubSub instances
32
+ */
33
+ type TypedPubSub<Topics extends Record<string, unknown>> = PubSubEngine<Topics>;
34
+ /**
35
+ * Create a simple in-memory PubSub instance
36
+ *
37
+ * This implementation uses EventEmitter for lightweight pub/sub functionality.
38
+ * Suitable for:
39
+ * - Development environments
40
+ * - Single-instance production deployments
41
+ * - Testing
42
+ *
43
+ * NOT suitable for:
44
+ * - Multi-instance/clustered deployments (events won't propagate across instances)
45
+ * - High-throughput scenarios (consider Redis-based PubSub)
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Define your topic types
50
+ * interface MyTopics {
51
+ * 'user:created': { id: string; name: string }
52
+ * 'message:sent': { channelId: string; content: string }
53
+ * }
54
+ *
55
+ * // Create typed PubSub instance
56
+ * const pubsub = createPubSub<MyTopics>()
57
+ *
58
+ * // Publish events
59
+ * await pubsub.publish('user:created', { id: '123', name: 'John' })
60
+ *
61
+ * // Subscribe to events (in a resolver)
62
+ * export const userSubscriptions = defineSubscription({
63
+ * userCreated: {
64
+ * subscribe: async function* () {
65
+ * yield* pubsub.subscribe('user:created')
66
+ * }
67
+ * }
68
+ * })
69
+ * ```
70
+ */
71
+ declare function createPubSub<Topics extends Record<string, unknown> = Record<string, unknown>>(): PubSubEngine<Topics>;
72
+ /**
73
+ * Filter subscription events based on a predicate
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * export const chatSubscriptions = defineSubscription({
78
+ * messageAdded: {
79
+ * subscribe: async function* (_, { channelId }) {
80
+ * yield* withFilter(
81
+ * pubsub.subscribe('message:added'),
82
+ * (message) => message.channelId === channelId
83
+ * )
84
+ * }
85
+ * }
86
+ * })
87
+ * ```
88
+ */
89
+ declare function withFilter<T>(asyncIterable: AsyncIterable<T>, filter: (value: T) => boolean | Promise<boolean>): AsyncIterable<T>;
90
+ /**
91
+ * Map subscription events to a different shape
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * export const chatSubscriptions = defineSubscription({
96
+ * messageAdded: {
97
+ * subscribe: async function* () {
98
+ * yield* mapAsyncIterator(
99
+ * pubsub.subscribe('message:added'),
100
+ * (event) => ({ messageAdded: event.message })
101
+ * )
102
+ * }
103
+ * }
104
+ * })
105
+ * ```
106
+ */
107
+ declare function mapAsyncIterator<T, U>(asyncIterable: AsyncIterable<T>, mapper: (value: T) => U | Promise<U>): AsyncIterable<U>;
108
+ //#endregion
109
+ export { PubSubEngine, TypedPubSub, createPubSub, mapAsyncIterator, withFilter };
@@ -0,0 +1,146 @@
1
+ import { EventEmitter } from "node:events";
2
+ //#region src/core/pubsub/index.ts
3
+ /**
4
+ * Built-in PubSub implementation for GraphQL Subscriptions
5
+ * Simple EventEmitter-based implementation for single-instance deployments
6
+ *
7
+ * For multi-instance deployments, use external PubSub solutions like:
8
+ * - Redis (with ioredis)
9
+ * - Kafka
10
+ * - RabbitMQ
11
+ * - Cloud Pub/Sub services
12
+ */
13
+ /**
14
+ * Create a simple in-memory PubSub instance
15
+ *
16
+ * This implementation uses EventEmitter for lightweight pub/sub functionality.
17
+ * Suitable for:
18
+ * - Development environments
19
+ * - Single-instance production deployments
20
+ * - Testing
21
+ *
22
+ * NOT suitable for:
23
+ * - Multi-instance/clustered deployments (events won't propagate across instances)
24
+ * - High-throughput scenarios (consider Redis-based PubSub)
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * // Define your topic types
29
+ * interface MyTopics {
30
+ * 'user:created': { id: string; name: string }
31
+ * 'message:sent': { channelId: string; content: string }
32
+ * }
33
+ *
34
+ * // Create typed PubSub instance
35
+ * const pubsub = createPubSub<MyTopics>()
36
+ *
37
+ * // Publish events
38
+ * await pubsub.publish('user:created', { id: '123', name: 'John' })
39
+ *
40
+ * // Subscribe to events (in a resolver)
41
+ * export const userSubscriptions = defineSubscription({
42
+ * userCreated: {
43
+ * subscribe: async function* () {
44
+ * yield* pubsub.subscribe('user:created')
45
+ * }
46
+ * }
47
+ * })
48
+ * ```
49
+ */
50
+ function createPubSub() {
51
+ const emitter = new EventEmitter();
52
+ emitter.setMaxListeners(0);
53
+ return {
54
+ async publish(topic, payload) {
55
+ emitter.emit(String(topic), payload);
56
+ },
57
+ subscribe(topic) {
58
+ const topicStr = String(topic);
59
+ return { [Symbol.asyncIterator]() {
60
+ const queue = [];
61
+ let resolve = null;
62
+ let done = false;
63
+ const listener = (payload) => {
64
+ if (resolve) {
65
+ resolve({
66
+ value: payload,
67
+ done: false
68
+ });
69
+ resolve = null;
70
+ } else queue.push(payload);
71
+ };
72
+ emitter.on(topicStr, listener);
73
+ return {
74
+ next() {
75
+ if (done) return Promise.resolve({
76
+ value: void 0,
77
+ done: true
78
+ });
79
+ if (queue.length > 0) return Promise.resolve({
80
+ value: queue.shift(),
81
+ done: false
82
+ });
83
+ return new Promise((r) => {
84
+ resolve = r;
85
+ });
86
+ },
87
+ return() {
88
+ done = true;
89
+ emitter.off(topicStr, listener);
90
+ return Promise.resolve({
91
+ value: void 0,
92
+ done: true
93
+ });
94
+ },
95
+ throw(error) {
96
+ done = true;
97
+ emitter.off(topicStr, listener);
98
+ return Promise.reject(error);
99
+ }
100
+ };
101
+ } };
102
+ }
103
+ };
104
+ }
105
+ /**
106
+ * Filter subscription events based on a predicate
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * export const chatSubscriptions = defineSubscription({
111
+ * messageAdded: {
112
+ * subscribe: async function* (_, { channelId }) {
113
+ * yield* withFilter(
114
+ * pubsub.subscribe('message:added'),
115
+ * (message) => message.channelId === channelId
116
+ * )
117
+ * }
118
+ * }
119
+ * })
120
+ * ```
121
+ */
122
+ async function* withFilter(asyncIterable, filter) {
123
+ for await (const value of asyncIterable) if (await filter(value)) yield value;
124
+ }
125
+ /**
126
+ * Map subscription events to a different shape
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * export const chatSubscriptions = defineSubscription({
131
+ * messageAdded: {
132
+ * subscribe: async function* () {
133
+ * yield* mapAsyncIterator(
134
+ * pubsub.subscribe('message:added'),
135
+ * (event) => ({ messageAdded: event.message })
136
+ * )
137
+ * }
138
+ * }
139
+ * })
140
+ * ```
141
+ */
142
+ async function* mapAsyncIterator(asyncIterable, mapper) {
143
+ for await (const value of asyncIterable) yield await mapper(value);
144
+ }
145
+ //#endregion
146
+ export { createPubSub, mapAsyncIterator, withFilter };
@@ -0,0 +1,27 @@
1
+ import { ResolverImport, ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
2
+
3
+ //#region src/core/scanning/ast-scanner.d.ts
4
+ /**
5
+ * Configuration for AST-based scanning
6
+ */
7
+ interface ASTScanConfig {
8
+ /** Glob pattern for files to scan */
9
+ pattern: string;
10
+ /** Parse a function call and return import info, or null if not a valid export */
11
+ parseCall: (calleeName: string, exportName: string, filePath: string) => ResolverImport | null;
12
+ /** Whether to emit warnings for common issues (default: true for resolvers) */
13
+ emitWarnings?: boolean;
14
+ /** Valid function names for warning messages */
15
+ validFunctions?: readonly string[];
16
+ }
17
+ /**
18
+ * Scan files matching a pattern and parse their exports using AST
19
+ */
20
+ declare function scanWithAST(ctx: ScanContext, config: ASTScanConfig): Promise<ScanResult<ScannedResolver>>;
21
+ /**
22
+ * Parse a single file and extract exports using AST
23
+ * Used for manifest resolver files
24
+ */
25
+ declare function parseSingleFile(filePath: string, parseCall: (calleeName: string, exportName: string, filePath: string) => ResolverImport | null): Promise<ScannedResolver | null>;
26
+ //#endregion
27
+ export { ASTScanConfig, parseSingleFile, scanWithAST };
@@ -0,0 +1,114 @@
1
+ import { scanDirectory } from "./common.mjs";
2
+ import { readFile } from "node:fs/promises";
3
+ import { basename, relative } from "pathe";
4
+ import { parseSync } from "oxc-parser";
5
+ //#region src/core/scanning/ast-scanner.ts
6
+ /**
7
+ * Scan files matching a pattern and parse their exports using AST
8
+ */
9
+ async function scanWithAST(ctx, config) {
10
+ const warnings = [];
11
+ const errors = [];
12
+ try {
13
+ const serverDirRelative = relative(ctx.rootDir, ctx.serverDir);
14
+ const files = await scanDirectory(ctx, ctx.rootDir, serverDirRelative, config.pattern);
15
+ const results = [];
16
+ for (const file of files) try {
17
+ const fileContent = await readFile(file.fullPath, "utf-8");
18
+ const parsed = parseSync(file.fullPath, fileContent);
19
+ if (parsed.errors && parsed.errors.length > 0) {
20
+ if (ctx.isDev) {
21
+ const fileName = basename(file.fullPath);
22
+ const firstError = parsed.errors[0];
23
+ const location = firstError?.labels?.[0];
24
+ const lineInfo = location ? `:${location.start}` : "";
25
+ const message = firstError?.message.split(",")[0] || "Syntax error";
26
+ errors.push(`${fileName}${lineInfo} - ${message}`);
27
+ }
28
+ continue;
29
+ }
30
+ const result = parseExports(file.fullPath, parsed.program, config);
31
+ if (ctx.isDev && config.emitWarnings && result.warnings.length > 0) {
32
+ const relPath = relative(ctx.rootDir, file.fullPath);
33
+ for (const warning of result.warnings) warnings.push(`${relPath}: ${warning}`);
34
+ }
35
+ if (result.resolver.imports.length > 0) results.push(result.resolver);
36
+ } catch (error) {
37
+ const relPath = relative(ctx.rootDir, file.fullPath);
38
+ errors.push(`Failed to parse file ${relPath}: ${error}`);
39
+ }
40
+ return {
41
+ items: results,
42
+ warnings,
43
+ errors
44
+ };
45
+ } catch (error) {
46
+ errors.push(`Scanning error: ${error}`);
47
+ return {
48
+ items: [],
49
+ warnings,
50
+ errors
51
+ };
52
+ }
53
+ }
54
+ /**
55
+ * Parse a single file and extract exports using AST
56
+ * Used for manifest resolver files
57
+ */
58
+ async function parseSingleFile(filePath, parseCall) {
59
+ try {
60
+ const parsed = parseSync(filePath, await readFile(filePath, "utf-8"));
61
+ if (parsed.errors && parsed.errors.length > 0) return null;
62
+ const result = parseExports(filePath, parsed.program, {
63
+ pattern: "",
64
+ parseCall,
65
+ emitWarnings: false
66
+ });
67
+ if (result.resolver.imports.length > 0) return result.resolver;
68
+ return null;
69
+ } catch {
70
+ return null;
71
+ }
72
+ }
73
+ /**
74
+ * Parse exports from AST program
75
+ */
76
+ function parseExports(filePath, program, config) {
77
+ const warnings = [];
78
+ const resolver = {
79
+ specifier: filePath,
80
+ imports: []
81
+ };
82
+ let hasDefaultExport = false;
83
+ let hasNamedExport = false;
84
+ const namedExports = [];
85
+ for (const node of program.body) {
86
+ if (node.type === "ExportDefaultDeclaration") hasDefaultExport = true;
87
+ if (node.type === "ExportNamedDeclaration" && node.declaration && node.declaration.type === "VariableDeclaration") {
88
+ for (const decl of node.declaration.declarations) if (decl.type === "VariableDeclarator" && decl.init && decl.id.type === "Identifier") {
89
+ hasNamedExport = true;
90
+ namedExports.push(decl.id.name);
91
+ if (decl.init && decl.init.type === "CallExpression") {
92
+ if (decl.init.callee.type === "Identifier") {
93
+ const imp = config.parseCall(decl.init.callee.name, decl.id.name, filePath);
94
+ if (imp) resolver.imports.push(imp);
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ if (config.emitWarnings) {
101
+ if (hasDefaultExport && !hasNamedExport) warnings.push("Using default export instead of named export. Must use named exports like \"export const myResolver = defineQuery(...)\". Default exports are not detected.");
102
+ if (resolver.imports.length === 0 && hasNamedExport) {
103
+ const validFunctions = config.validFunctions?.join(", ") || "define* functions";
104
+ warnings.push(`File has named exports [${namedExports.join(", ")}] but none use the required define functions (${validFunctions}). Exports will not be registered.`);
105
+ }
106
+ if (!hasDefaultExport && !hasNamedExport) warnings.push("No exports found. Files must export using define* functions.");
107
+ }
108
+ return {
109
+ resolver,
110
+ warnings
111
+ };
112
+ }
113
+ //#endregion
114
+ export { parseSingleFile, scanWithAST };
@@ -0,0 +1,25 @@
1
+ import { ScanContext, ScannedFile } from "../types/scanning.mjs";
2
+
3
+ //#region src/core/scanning/common.d.ts
4
+ /**
5
+ * Scan a directory for files matching a glob pattern
6
+ */
7
+ declare function scanDirectory(ctx: ScanContext, baseDir: string, subDir: string, globPattern?: string): Promise<ScannedFile[]>;
8
+ /**
9
+ * Deduplicate files by fullPath
10
+ */
11
+ declare function deduplicateFiles<T extends {
12
+ fullPath: string;
13
+ }>(files: T[]): T[];
14
+ /**
15
+ * Filter files by extension
16
+ */
17
+ declare function filterByExtension<T extends {
18
+ fullPath: string;
19
+ }>(files: T[], extensions: readonly string[]): T[];
20
+ /**
21
+ * Extract file paths from scanned files
22
+ */
23
+ declare function extractPaths(files: ScannedFile[]): string[];
24
+ //#endregion
25
+ export { deduplicateFiles, extractPaths, filterByExtension, scanDirectory };
@@ -0,0 +1,57 @@
1
+ import { GLOB_SCAN_PATTERN } from "../constants.mjs";
2
+ import { join, relative } from "pathe";
3
+ import { glob } from "tinyglobby";
4
+ //#region src/core/scanning/common.ts
5
+ const DEFAULT_IGNORE_PATTERNS = [
6
+ "**/node_modules/**",
7
+ "**/.git/**",
8
+ "**/.output/**",
9
+ "**/.nitro/**",
10
+ "**/.nuxt/**",
11
+ "**/.graphql/**"
12
+ ];
13
+ /**
14
+ * Scan a directory for files matching a glob pattern
15
+ */
16
+ async function scanDirectory(ctx, baseDir, subDir, globPattern = GLOB_SCAN_PATTERN) {
17
+ return (await glob(join(subDir, globPattern), {
18
+ cwd: baseDir,
19
+ dot: true,
20
+ ignore: [...DEFAULT_IGNORE_PATTERNS, ...ctx.ignorePatterns],
21
+ absolute: true
22
+ }).catch((error) => {
23
+ if (error?.code === "ENOTDIR") {
24
+ ctx.logger.warn(`Ignoring \`${join(baseDir, subDir)}\`. It must be a directory.`);
25
+ return [];
26
+ }
27
+ throw error;
28
+ })).map((fullPath) => ({
29
+ fullPath,
30
+ path: relative(join(baseDir, subDir), fullPath)
31
+ })).sort((a, b) => a.path.localeCompare(b.path));
32
+ }
33
+ /**
34
+ * Deduplicate files by fullPath
35
+ */
36
+ function deduplicateFiles(files) {
37
+ const seenPaths = /* @__PURE__ */ new Set();
38
+ return files.filter((file) => {
39
+ if (seenPaths.has(file.fullPath)) return false;
40
+ seenPaths.add(file.fullPath);
41
+ return true;
42
+ });
43
+ }
44
+ /**
45
+ * Filter files by extension
46
+ */
47
+ function filterByExtension(files, extensions) {
48
+ return files.filter((file) => extensions.some((ext) => file.fullPath.endsWith(ext)));
49
+ }
50
+ /**
51
+ * Extract file paths from scanned files
52
+ */
53
+ function extractPaths(files) {
54
+ return files.map((f) => f.fullPath);
55
+ }
56
+ //#endregion
57
+ export { deduplicateFiles, extractPaths, filterByExtension, scanDirectory };
@@ -0,0 +1,13 @@
1
+ import { ResolverImport, ScanContext, ScanResult, ScannedResolver } from "../types/scanning.mjs";
2
+
3
+ //#region src/core/scanning/directives.d.ts
4
+ /**
5
+ * Parse a defineDirective call and return the import info
6
+ */
7
+ declare function parseDirectiveCall(calleeName: string, exportName: string, filePath: string): ResolverImport | null;
8
+ /**
9
+ * Scan for directive files (.directive.ts/.js)
10
+ */
11
+ declare function scanDirectivesCore(ctx: ScanContext): Promise<ScanResult<ScannedResolver>>;
12
+ //#endregion
13
+ export { parseDirectiveCall, scanDirectivesCore };