@gqlkit-ts/cli 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-type-generator/auto-type-generator.d.ts +26 -4
- package/dist/auto-type-generator/auto-type-generator.d.ts.map +1 -1
- package/dist/auto-type-generator/auto-type-generator.js +846 -152
- package/dist/auto-type-generator/auto-type-generator.js.map +1 -1
- package/dist/auto-type-generator/index.d.ts +9 -2
- package/dist/auto-type-generator/index.d.ts.map +1 -1
- package/dist/auto-type-generator/index.js +3 -0
- package/dist/auto-type-generator/index.js.map +1 -1
- package/dist/auto-type-generator/inline-enum-collector.d.ts +39 -0
- package/dist/auto-type-generator/inline-enum-collector.d.ts.map +1 -0
- package/dist/auto-type-generator/inline-enum-collector.js +193 -0
- package/dist/auto-type-generator/inline-enum-collector.js.map +1 -0
- package/dist/auto-type-generator/inline-object-traverser.d.ts +20 -0
- package/dist/auto-type-generator/inline-object-traverser.d.ts.map +1 -0
- package/dist/auto-type-generator/inline-object-traverser.js +22 -0
- package/dist/auto-type-generator/inline-object-traverser.js.map +1 -0
- package/dist/auto-type-generator/inline-union-collector.d.ts +29 -0
- package/dist/auto-type-generator/inline-union-collector.d.ts.map +1 -0
- package/dist/auto-type-generator/inline-union-collector.js +216 -0
- package/dist/auto-type-generator/inline-union-collector.js.map +1 -0
- package/dist/auto-type-generator/inline-union-types.d.ts +29 -0
- package/dist/auto-type-generator/inline-union-types.d.ts.map +1 -0
- package/dist/auto-type-generator/inline-union-types.js +2 -0
- package/dist/auto-type-generator/inline-union-types.js.map +1 -0
- package/dist/auto-type-generator/inline-union-validator.d.ts +76 -0
- package/dist/auto-type-generator/inline-union-validator.d.ts.map +1 -0
- package/dist/auto-type-generator/inline-union-validator.js +329 -0
- package/dist/auto-type-generator/inline-union-validator.js.map +1 -0
- package/dist/auto-type-generator/naming-convention.d.ts +22 -1
- package/dist/auto-type-generator/naming-convention.d.ts.map +1 -1
- package/dist/auto-type-generator/naming-convention.js +24 -0
- package/dist/auto-type-generator/naming-convention.js.map +1 -1
- package/dist/auto-type-generator/resolve-type-generator.d.ts +20 -0
- package/dist/auto-type-generator/resolve-type-generator.d.ts.map +1 -0
- package/dist/auto-type-generator/resolve-type-generator.js +2 -0
- package/dist/auto-type-generator/resolve-type-generator.js.map +1 -0
- package/dist/auto-type-generator/resolver-field-iterator.d.ts +13 -0
- package/dist/auto-type-generator/resolver-field-iterator.d.ts.map +1 -0
- package/dist/auto-type-generator/resolver-field-iterator.js +22 -0
- package/dist/auto-type-generator/resolver-field-iterator.js.map +1 -0
- package/dist/auto-type-generator/typename-extractor.d.ts +26 -0
- package/dist/auto-type-generator/typename-extractor.d.ts.map +1 -0
- package/dist/auto-type-generator/typename-extractor.js +142 -0
- package/dist/auto-type-generator/typename-extractor.js.map +1 -0
- package/dist/auto-type-generator/typename-resolve-type-generator.d.ts +35 -0
- package/dist/auto-type-generator/typename-resolve-type-generator.d.ts.map +1 -0
- package/dist/auto-type-generator/typename-resolve-type-generator.js +177 -0
- package/dist/auto-type-generator/typename-resolve-type-generator.js.map +1 -0
- package/dist/auto-type-generator/typename-types.d.ts +43 -0
- package/dist/auto-type-generator/typename-types.d.ts.map +1 -0
- package/dist/auto-type-generator/typename-types.js +37 -0
- package/dist/auto-type-generator/typename-types.js.map +1 -0
- package/dist/auto-type-generator/typename-validator.d.ts +37 -0
- package/dist/auto-type-generator/typename-validator.d.ts.map +1 -0
- package/dist/auto-type-generator/typename-validator.js +206 -0
- package/dist/auto-type-generator/typename-validator.js.map +1 -0
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/docs.d.ts +51 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +154 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/gen-orchestrator/orchestrator.d.ts.map +1 -1
- package/dist/gen-orchestrator/orchestrator.js +119 -14
- package/dist/gen-orchestrator/orchestrator.js.map +1 -1
- package/dist/resolver-extractor/extract-resolvers.d.ts +28 -1
- package/dist/resolver-extractor/extract-resolvers.d.ts.map +1 -1
- package/dist/resolver-extractor/extractor/define-api-extractor.d.ts +16 -1
- package/dist/resolver-extractor/extractor/define-api-extractor.d.ts.map +1 -1
- package/dist/resolver-extractor/extractor/define-api-extractor.js +86 -309
- package/dist/resolver-extractor/extractor/define-api-extractor.js.map +1 -1
- package/dist/resolver-extractor/index.d.ts +0 -1
- package/dist/resolver-extractor/index.d.ts.map +1 -1
- package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts +1 -0
- package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts.map +1 -1
- package/dist/resolver-extractor/validator/abstract-resolver-validator.js +9 -5
- package/dist/resolver-extractor/validator/abstract-resolver-validator.js.map +1 -1
- package/dist/schema-generator/emitter/code-emitter.d.ts +10 -2
- package/dist/schema-generator/emitter/code-emitter.d.ts.map +1 -1
- package/dist/schema-generator/emitter/code-emitter.js +39 -4
- package/dist/schema-generator/emitter/code-emitter.js.map +1 -1
- package/dist/schema-generator/generate-schema.d.ts +1 -0
- package/dist/schema-generator/generate-schema.d.ts.map +1 -1
- package/dist/schema-generator/generate-schema.js +90 -4
- package/dist/schema-generator/generate-schema.js.map +1 -1
- package/dist/schema-generator/integrator/result-integrator.d.ts +34 -2
- package/dist/schema-generator/integrator/result-integrator.d.ts.map +1 -1
- package/dist/schema-generator/integrator/result-integrator.js +96 -1
- package/dist/schema-generator/integrator/result-integrator.js.map +1 -1
- package/dist/schema-generator/resolver-collector/resolver-collector.d.ts +2 -0
- package/dist/schema-generator/resolver-collector/resolver-collector.d.ts.map +1 -1
- package/dist/schema-generator/resolver-collector/resolver-collector.js +22 -0
- package/dist/schema-generator/resolver-collector/resolver-collector.js.map +1 -1
- package/dist/shared/constants.d.ts +0 -16
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +0 -19
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/directive-detector.d.ts.map +1 -1
- package/dist/shared/directive-detector.js +8 -15
- package/dist/shared/directive-detector.js.map +1 -1
- package/dist/shared/enum-prefix-detector.d.ts +63 -0
- package/dist/shared/enum-prefix-detector.d.ts.map +1 -0
- package/dist/shared/enum-prefix-detector.js +80 -0
- package/dist/shared/enum-prefix-detector.js.map +1 -0
- package/dist/shared/file-scanner.d.ts.map +1 -1
- package/dist/shared/file-scanner.js +5 -3
- package/dist/shared/file-scanner.js.map +1 -1
- package/dist/shared/ignore-fields-detector.d.ts +26 -0
- package/dist/shared/ignore-fields-detector.d.ts.map +1 -0
- package/dist/shared/ignore-fields-detector.js +83 -0
- package/dist/shared/ignore-fields-detector.js.map +1 -0
- package/dist/shared/ignore-fields-validator.d.ts +29 -0
- package/dist/shared/ignore-fields-validator.d.ts.map +1 -0
- package/dist/shared/ignore-fields-validator.js +43 -0
- package/dist/shared/ignore-fields-validator.js.map +1 -0
- package/dist/shared/index.d.ts +3 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -3
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/interface-detector.d.ts +3 -2
- package/dist/shared/interface-detector.d.ts.map +1 -1
- package/dist/shared/interface-detector.js +54 -11
- package/dist/shared/interface-detector.js.map +1 -1
- package/dist/shared/path-utils.d.ts +2 -0
- package/dist/shared/path-utils.d.ts.map +1 -0
- package/dist/shared/path-utils.js +4 -0
- package/dist/shared/path-utils.js.map +1 -0
- package/dist/shared/source-location.d.ts +5 -0
- package/dist/shared/source-location.d.ts.map +1 -1
- package/dist/shared/source-location.js +7 -0
- package/dist/shared/source-location.js.map +1 -1
- package/dist/shared/type-converter.d.ts.map +1 -1
- package/dist/shared/type-converter.js +11 -0
- package/dist/shared/type-converter.js.map +1 -1
- package/dist/shared/typescript-utils.d.ts +34 -7
- package/dist/shared/typescript-utils.d.ts.map +1 -1
- package/dist/shared/typescript-utils.js +72 -24
- package/dist/shared/typescript-utils.js.map +1 -1
- package/dist/type-extractor/collector/scalar-collector.d.ts.map +1 -1
- package/dist/type-extractor/collector/scalar-collector.js +4 -14
- package/dist/type-extractor/collector/scalar-collector.js.map +1 -1
- package/dist/type-extractor/converter/graphql-converter.d.ts.map +1 -1
- package/dist/type-extractor/converter/graphql-converter.js +57 -4
- package/dist/type-extractor/converter/graphql-converter.js.map +1 -1
- package/dist/type-extractor/extractor/field-type-resolver.d.ts +28 -0
- package/dist/type-extractor/extractor/field-type-resolver.d.ts.map +1 -0
- package/dist/type-extractor/extractor/field-type-resolver.js +433 -0
- package/dist/type-extractor/extractor/field-type-resolver.js.map +1 -0
- package/dist/type-extractor/extractor/type-extractor.d.ts +12 -3
- package/dist/type-extractor/extractor/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor/extractor/type-extractor.js +260 -229
- package/dist/type-extractor/extractor/type-extractor.js.map +1 -1
- package/dist/type-extractor/extractor/type-name-collector.d.ts +24 -0
- package/dist/type-extractor/extractor/type-name-collector.d.ts.map +1 -0
- package/dist/type-extractor/extractor/type-name-collector.js +102 -0
- package/dist/type-extractor/extractor/type-name-collector.js.map +1 -0
- package/dist/type-extractor/mapper/scalar-base-type-mapper.d.ts +89 -0
- package/dist/type-extractor/mapper/scalar-base-type-mapper.d.ts.map +1 -0
- package/dist/type-extractor/mapper/scalar-base-type-mapper.js +158 -0
- package/dist/type-extractor/mapper/scalar-base-type-mapper.js.map +1 -0
- package/dist/type-extractor/types/diagnostics.d.ts +1 -1
- package/dist/type-extractor/types/diagnostics.d.ts.map +1 -1
- package/dist/type-extractor/types/graphql.d.ts +2 -0
- package/dist/type-extractor/types/graphql.d.ts.map +1 -1
- package/dist/type-extractor/types/index.d.ts +2 -1
- package/dist/type-extractor/types/index.d.ts.map +1 -1
- package/dist/type-extractor/types/index.js +1 -1
- package/dist/type-extractor/types/index.js.map +1 -1
- package/dist/type-extractor/types/ts-type-reference-factory.d.ts +47 -0
- package/dist/type-extractor/types/ts-type-reference-factory.d.ts.map +1 -0
- package/dist/type-extractor/types/ts-type-reference-factory.js +75 -0
- package/dist/type-extractor/types/ts-type-reference-factory.js.map +1 -0
- package/dist/type-extractor/types/typescript.d.ts +25 -1
- package/dist/type-extractor/types/typescript.d.ts.map +1 -1
- package/dist/type-extractor/validator/type-validator.js +1 -1
- package/dist/type-extractor/validator/type-validator.js.map +1 -1
- package/docs/coding-agents.md +64 -0
- package/docs/configuration.md +6 -20
- package/docs/getting-started.md +15 -12
- package/docs/index.md +36 -21
- package/docs/integration/apollo.md +8 -40
- package/docs/integration/drizzle.md +187 -0
- package/docs/integration/prisma.md +196 -0
- package/docs/integration/yoga.md +8 -40
- package/docs/schema/abstract-resolvers.md +117 -0
- package/docs/schema/directives.md +5 -0
- package/docs/schema/documentation.md +5 -0
- package/docs/schema/enums.md +307 -0
- package/docs/schema/fields.md +66 -0
- package/docs/schema/index.md +21 -0
- package/docs/schema/inputs.md +117 -15
- package/docs/schema/interfaces.md +31 -1
- package/docs/schema/objects.md +42 -0
- package/docs/schema/queries-mutations.md +138 -22
- package/docs/schema/scalars.md +5 -0
- package/docs/schema/unions.md +208 -1
- package/docs/what-is-gqlkit.md +13 -8
- package/package.json +14 -5
- package/src/auto-type-generator/auto-type-generator.ts +1670 -0
- package/src/auto-type-generator/index.ts +63 -0
- package/src/auto-type-generator/inline-enum-collector.ts +338 -0
- package/src/auto-type-generator/inline-object-traverser.ts +49 -0
- package/src/auto-type-generator/inline-union-collector.ts +402 -0
- package/src/auto-type-generator/inline-union-types.ts +33 -0
- package/src/auto-type-generator/inline-union-validator.ts +482 -0
- package/src/auto-type-generator/name-collision-validator.ts +119 -0
- package/src/auto-type-generator/naming-convention.ts +163 -0
- package/src/auto-type-generator/resolve-type-generator.ts +21 -0
- package/src/auto-type-generator/resolver-field-iterator.ts +39 -0
- package/src/auto-type-generator/typename-extractor.ts +230 -0
- package/src/auto-type-generator/typename-resolve-type-generator.ts +281 -0
- package/src/auto-type-generator/typename-types.ts +66 -0
- package/src/auto-type-generator/typename-validator.ts +326 -0
- package/src/cli.ts +13 -0
- package/src/commands/docs.ts +211 -0
- package/src/commands/gen.ts +141 -0
- package/src/commands/main.ts +5 -0
- package/src/config/define-config.ts +28 -0
- package/src/config/index.ts +7 -0
- package/src/config/types.ts +144 -0
- package/src/config-loader/index.ts +14 -0
- package/src/config-loader/loader.ts +143 -0
- package/src/config-loader/validator.ts +672 -0
- package/src/gen-orchestrator/hook-executor/hook-executor.ts +117 -0
- package/src/gen-orchestrator/orchestrator.ts +798 -0
- package/src/gen-orchestrator/reporter/diagnostic-reporter.ts +44 -0
- package/src/gen-orchestrator/reporter/progress-reporter.ts +61 -0
- package/src/gen-orchestrator/writer/file-writer.ts +38 -0
- package/src/index.ts +2 -0
- package/src/resolver-extractor/extract-resolvers.ts +82 -0
- package/src/resolver-extractor/extractor/define-api-extractor.ts +740 -0
- package/src/resolver-extractor/index.ts +13 -0
- package/src/resolver-extractor/validator/abstract-resolver-validator.ts +259 -0
- package/src/schema-generator/builder/ast-builder.ts +706 -0
- package/src/schema-generator/emitter/code-emitter.ts +385 -0
- package/src/schema-generator/emitter/sdl-emitter.ts +13 -0
- package/src/schema-generator/generate-schema.ts +267 -0
- package/src/schema-generator/index.ts +19 -0
- package/src/schema-generator/integrator/result-integrator.ts +759 -0
- package/src/schema-generator/pruner/schema-pruner.ts +112 -0
- package/src/schema-generator/resolver-collector/resolver-collector.ts +157 -0
- package/src/shared/constants.ts +122 -0
- package/src/shared/default-value-detector.ts +172 -0
- package/src/shared/diagnostics.ts +35 -0
- package/src/shared/directive-definition-extractor.ts +564 -0
- package/src/shared/directive-detector.ts +556 -0
- package/src/shared/enum-prefix-detector.ts +99 -0
- package/src/shared/file-scanner.ts +170 -0
- package/src/shared/ignore-fields-detector.ts +109 -0
- package/src/shared/ignore-fields-validator.ts +66 -0
- package/src/shared/index.ts +34 -0
- package/src/shared/inline-object-extractor.ts +102 -0
- package/src/shared/inline-object-utils.ts +23 -0
- package/src/shared/interface-detector.ts +176 -0
- package/src/shared/interface-validator.ts +211 -0
- package/src/shared/metadata-detector.ts +443 -0
- package/src/shared/path-utils.ts +3 -0
- package/src/shared/program-factory.ts +51 -0
- package/src/shared/source-location.ts +38 -0
- package/src/shared/tsconfig-loader.ts +126 -0
- package/src/shared/tsdoc-parser.ts +155 -0
- package/src/shared/type-converter.ts +99 -0
- package/src/shared/typescript-utils.ts +246 -0
- package/src/type-extractor/collector/result-collector.ts +57 -0
- package/src/type-extractor/collector/scalar-collector.ts +254 -0
- package/src/type-extractor/converter/field-eligibility.ts +112 -0
- package/src/type-extractor/converter/graphql-converter.ts +483 -0
- package/src/type-extractor/extract-types.ts +1 -0
- package/src/type-extractor/extractor/field-type-resolver.ts +614 -0
- package/src/type-extractor/extractor/type-extractor.ts +1644 -0
- package/src/type-extractor/extractor/type-name-collector.ts +130 -0
- package/src/type-extractor/index.ts +20 -0
- package/src/type-extractor/mapper/scalar-base-type-mapper.ts +265 -0
- package/src/type-extractor/types/diagnostics.ts +109 -0
- package/src/type-extractor/types/graphql.ts +55 -0
- package/src/type-extractor/types/index.ts +37 -0
- package/src/type-extractor/types/ts-type-reference-factory.ts +150 -0
- package/src/type-extractor/types/typescript.ts +137 -0
- package/src/type-extractor/validator/type-validator.ts +77 -0
- package/dist/auto-type-generator/auto-type-generator.test.d.ts +0 -2
- package/dist/auto-type-generator/auto-type-generator.test.d.ts.map +0 -1
- package/dist/auto-type-generator/auto-type-generator.test.js +0 -613
- package/dist/auto-type-generator/auto-type-generator.test.js.map +0 -1
- package/dist/auto-type-generator/name-collision-validator.test.d.ts +0 -2
- package/dist/auto-type-generator/name-collision-validator.test.d.ts.map +0 -1
- package/dist/auto-type-generator/name-collision-validator.test.js +0 -358
- package/dist/auto-type-generator/name-collision-validator.test.js.map +0 -1
- package/dist/auto-type-generator/naming-convention.test.d.ts +0 -2
- package/dist/auto-type-generator/naming-convention.test.d.ts.map +0 -1
- package/dist/auto-type-generator/naming-convention.test.js +0 -132
- package/dist/auto-type-generator/naming-convention.test.js.map +0 -1
- package/dist/commands/gen.test.d.ts +0 -2
- package/dist/commands/gen.test.d.ts.map +0 -1
- package/dist/commands/gen.test.js +0 -226
- package/dist/commands/gen.test.js.map +0 -1
- package/dist/config-loader/loader.test.d.ts +0 -2
- package/dist/config-loader/loader.test.d.ts.map +0 -1
- package/dist/config-loader/loader.test.js +0 -123
- package/dist/config-loader/loader.test.js.map +0 -1
- package/dist/config-loader/validator.test.d.ts +0 -2
- package/dist/config-loader/validator.test.d.ts.map +0 -1
- package/dist/config-loader/validator.test.js +0 -846
- package/dist/config-loader/validator.test.js.map +0 -1
- package/dist/gen-orchestrator/golden.test.d.ts +0 -2
- package/dist/gen-orchestrator/golden.test.d.ts.map +0 -1
- package/dist/gen-orchestrator/golden.test.js +0 -102
- package/dist/gen-orchestrator/golden.test.js.map +0 -1
- package/dist/gen-orchestrator/hook-executor/hook-executor.test.d.ts +0 -2
- package/dist/gen-orchestrator/hook-executor/hook-executor.test.d.ts.map +0 -1
- package/dist/gen-orchestrator/hook-executor/hook-executor.test.js +0 -167
- package/dist/gen-orchestrator/hook-executor/hook-executor.test.js.map +0 -1
- package/dist/gen-orchestrator/reporter/progress-reporter.test.d.ts +0 -2
- package/dist/gen-orchestrator/reporter/progress-reporter.test.d.ts.map +0 -1
- package/dist/gen-orchestrator/reporter/progress-reporter.test.js +0 -74
- package/dist/gen-orchestrator/reporter/progress-reporter.test.js.map +0 -1
- package/dist/resolver-extractor/validator/only-validator.d.ts +0 -61
- package/dist/resolver-extractor/validator/only-validator.d.ts.map +0 -1
- package/dist/resolver-extractor/validator/only-validator.js +0 -76
- package/dist/resolver-extractor/validator/only-validator.js.map +0 -1
- package/dist/resolver-extractor/validator/only-validator.test.d.ts +0 -8
- package/dist/resolver-extractor/validator/only-validator.test.d.ts.map +0 -1
- package/dist/resolver-extractor/validator/only-validator.test.js +0 -352
- package/dist/resolver-extractor/validator/only-validator.test.js.map +0 -1
- package/dist/schema-generator/builder/ast-builder.test.d.ts +0 -2
- package/dist/schema-generator/builder/ast-builder.test.d.ts.map +0 -1
- package/dist/schema-generator/builder/ast-builder.test.js +0 -469
- package/dist/schema-generator/builder/ast-builder.test.js.map +0 -1
- package/dist/shared/file-scanner.test.d.ts +0 -2
- package/dist/shared/file-scanner.test.d.ts.map +0 -1
- package/dist/shared/file-scanner.test.js +0 -138
- package/dist/shared/file-scanner.test.js.map +0 -1
- package/dist/shared/interface-validator.test.d.ts +0 -2
- package/dist/shared/interface-validator.test.d.ts.map +0 -1
- package/dist/shared/interface-validator.test.js +0 -145
- package/dist/shared/interface-validator.test.js.map +0 -1
- package/dist/type-extractor/types/typescript.test.d.ts +0 -2
- package/dist/type-extractor/types/typescript.test.d.ts.map +0 -1
- package/dist/type-extractor/types/typescript.test.js +0 -287
- package/dist/type-extractor/types/typescript.test.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import {
|
|
3
|
+
isExported,
|
|
4
|
+
resolveOriginalSymbol,
|
|
5
|
+
} from "../../shared/typescript-utils.js";
|
|
6
|
+
|
|
7
|
+
export interface TypeNameCollectionResult {
|
|
8
|
+
readonly typeNames: ReadonlySet<string>;
|
|
9
|
+
readonly typeSymbols: ReadonlyMap<string, ts.Symbol>;
|
|
10
|
+
/**
|
|
11
|
+
* Maps underlying type symbols to their schema type names.
|
|
12
|
+
* For `type User = ExternalUser;`, maps ExternalUser's symbol to "User".
|
|
13
|
+
* This allows recognizing `ExternalUser` as `User` in field types.
|
|
14
|
+
*/
|
|
15
|
+
readonly underlyingSymbolToTypeName: ReadonlyMap<ts.Symbol, string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Collects all declared type names from exported type declarations.
|
|
20
|
+
*
|
|
21
|
+
* Used in Phase 1 of the 2-phase type extraction process to gather
|
|
22
|
+
* all schema-defined type names before processing field types.
|
|
23
|
+
*
|
|
24
|
+
* Handles:
|
|
25
|
+
* - Direct type declarations (type, interface, enum)
|
|
26
|
+
* - Named re-exports: `export type { Foo } from "..."`
|
|
27
|
+
* - Wildcard re-exports: `export type * from "..."`
|
|
28
|
+
*/
|
|
29
|
+
export function collectDeclaredTypeNames(
|
|
30
|
+
program: ts.Program,
|
|
31
|
+
sourceFiles: ReadonlyArray<string>,
|
|
32
|
+
): TypeNameCollectionResult {
|
|
33
|
+
const typeNames = new Set<string>();
|
|
34
|
+
const typeSymbols = new Map<string, ts.Symbol>();
|
|
35
|
+
const underlyingSymbolToTypeName = new Map<ts.Symbol, string>();
|
|
36
|
+
const checker = program.getTypeChecker();
|
|
37
|
+
|
|
38
|
+
for (const filePath of sourceFiles) {
|
|
39
|
+
const sourceFile = program.getSourceFile(filePath);
|
|
40
|
+
if (!sourceFile) continue;
|
|
41
|
+
|
|
42
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
43
|
+
// Direct type declarations
|
|
44
|
+
if (ts.isTypeAliasDeclaration(node) && isExported(node)) {
|
|
45
|
+
const name = node.name.getText(sourceFile);
|
|
46
|
+
typeNames.add(name);
|
|
47
|
+
const symbol = checker.getSymbolAtLocation(node.name);
|
|
48
|
+
if (symbol) {
|
|
49
|
+
typeSymbols.set(name, resolveOriginalSymbol(symbol, checker));
|
|
50
|
+
|
|
51
|
+
// For type aliases like `type User = ExternalUser;`,
|
|
52
|
+
// also track the underlying type's symbol
|
|
53
|
+
const type = checker.getTypeAtLocation(node.type);
|
|
54
|
+
if (type.symbol) {
|
|
55
|
+
const underlyingSymbol = resolveOriginalSymbol(
|
|
56
|
+
type.symbol,
|
|
57
|
+
checker,
|
|
58
|
+
);
|
|
59
|
+
underlyingSymbolToTypeName.set(underlyingSymbol, name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (ts.isInterfaceDeclaration(node) && isExported(node)) {
|
|
64
|
+
const name = node.name.getText(sourceFile);
|
|
65
|
+
typeNames.add(name);
|
|
66
|
+
const symbol = checker.getSymbolAtLocation(node.name);
|
|
67
|
+
if (symbol) {
|
|
68
|
+
typeSymbols.set(name, resolveOriginalSymbol(symbol, checker));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (ts.isEnumDeclaration(node) && isExported(node)) {
|
|
72
|
+
const name = node.name.getText(sourceFile);
|
|
73
|
+
typeNames.add(name);
|
|
74
|
+
const symbol = checker.getSymbolAtLocation(node.name);
|
|
75
|
+
if (symbol) {
|
|
76
|
+
typeSymbols.set(name, resolveOriginalSymbol(symbol, checker));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Re-exports: `export type { ... } from "..."` or `export type * from "..."`
|
|
81
|
+
if (ts.isExportDeclaration(node) && node.isTypeOnly) {
|
|
82
|
+
if (node.exportClause) {
|
|
83
|
+
// Named re-exports: `export type { Foo, Bar } from "..."`
|
|
84
|
+
if (ts.isNamedExports(node.exportClause)) {
|
|
85
|
+
for (const element of node.exportClause.elements) {
|
|
86
|
+
// Use the exported name (element.name), not the property name
|
|
87
|
+
const name = element.name.getText(sourceFile);
|
|
88
|
+
typeNames.add(name);
|
|
89
|
+
const symbol = checker.getSymbolAtLocation(element.name);
|
|
90
|
+
if (symbol) {
|
|
91
|
+
typeSymbols.set(name, resolveOriginalSymbol(symbol, checker));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else if (node.moduleSpecifier) {
|
|
96
|
+
// Wildcard re-exports: `export type * from "..."`
|
|
97
|
+
const moduleSymbol = checker.getSymbolAtLocation(
|
|
98
|
+
node.moduleSpecifier,
|
|
99
|
+
);
|
|
100
|
+
if (moduleSymbol) {
|
|
101
|
+
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
102
|
+
for (const exp of exports) {
|
|
103
|
+
const name = exp.getName();
|
|
104
|
+
// Check if the export is a type (not a value)
|
|
105
|
+
if (isTypeExport(exp)) {
|
|
106
|
+
typeNames.add(name);
|
|
107
|
+
typeSymbols.set(name, resolveOriginalSymbol(exp, checker));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return { typeNames, typeSymbols, underlyingSymbolToTypeName };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Checks if a symbol represents a type export (not a value export).
|
|
121
|
+
*/
|
|
122
|
+
function isTypeExport(symbol: ts.Symbol): boolean {
|
|
123
|
+
const flags = symbol.flags;
|
|
124
|
+
return (
|
|
125
|
+
(flags & ts.SymbolFlags.Type) !== 0 ||
|
|
126
|
+
(flags & ts.SymbolFlags.TypeAlias) !== 0 ||
|
|
127
|
+
(flags & ts.SymbolFlags.Interface) !== 0 ||
|
|
128
|
+
(flags & ts.SymbolFlags.Enum) !== 0
|
|
129
|
+
);
|
|
130
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
CollectedScalarType,
|
|
3
|
+
ConfigScalarMapping,
|
|
4
|
+
DescriptionSource,
|
|
5
|
+
ScalarMetadataInfo,
|
|
6
|
+
} from "./collector/scalar-collector.js";
|
|
7
|
+
|
|
8
|
+
export type { ExtractTypesResult } from "./extract-types.js";
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
Diagnostic,
|
|
12
|
+
DiagnosticCode,
|
|
13
|
+
Diagnostics,
|
|
14
|
+
ExtractedTypeInfo,
|
|
15
|
+
FieldInfo,
|
|
16
|
+
GraphQLFieldType,
|
|
17
|
+
GraphQLTypeInfo,
|
|
18
|
+
GraphQLTypeKind,
|
|
19
|
+
SourceLocation,
|
|
20
|
+
} from "./types/index.js";
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScalarBaseTypeMapper builds a mapping from base type symbols to scalar names.
|
|
3
|
+
*
|
|
4
|
+
* This enables automatic mapping of base types (e.g., Date) to their corresponding
|
|
5
|
+
* scalar types (e.g., DateTime) when used in field types.
|
|
6
|
+
*
|
|
7
|
+
* The mapper supports:
|
|
8
|
+
* - Input/output context-aware lookups
|
|
9
|
+
* - Conflict detection when multiple scalars share the same base type
|
|
10
|
+
* - Symbol-based comparison for accurate type matching
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import ts from "typescript";
|
|
14
|
+
import type { ScalarMetadataInfo } from "../collector/scalar-collector.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Information about a scalar mapping from base type to scalar name.
|
|
18
|
+
*/
|
|
19
|
+
export interface ScalarBaseTypeMapping {
|
|
20
|
+
/** GraphQL scalar name */
|
|
21
|
+
readonly scalarName: string;
|
|
22
|
+
/** Usage constraint from GqlScalar definition */
|
|
23
|
+
readonly only: "input" | "output" | null;
|
|
24
|
+
/** Source scalar type name for diagnostics */
|
|
25
|
+
readonly sourceTypeName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Result of a scalar mapping lookup.
|
|
30
|
+
*/
|
|
31
|
+
export interface ScalarMappingLookupResult {
|
|
32
|
+
readonly mapping: ScalarBaseTypeMapping | null;
|
|
33
|
+
readonly conflict: ScalarMappingConflict | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Information about a scalar mapping conflict.
|
|
38
|
+
*/
|
|
39
|
+
export interface ScalarMappingConflict {
|
|
40
|
+
readonly code: "AMBIGUOUS_SCALAR_BASE_TYPE";
|
|
41
|
+
readonly baseTypeSymbol: ts.Symbol;
|
|
42
|
+
readonly conflictingScalars: ReadonlyArray<{
|
|
43
|
+
readonly scalarName: string;
|
|
44
|
+
readonly only: "input" | "output" | null;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Context for scalar mapping: input (for args/input types) or output (for return types/object types).
|
|
50
|
+
*/
|
|
51
|
+
export type ScalarMappingContext = "input" | "output";
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Mapping table built from scalar definitions.
|
|
55
|
+
*/
|
|
56
|
+
export interface ScalarBaseTypeMappingTable {
|
|
57
|
+
/** Maps base type symbol to scalar mappings for input context */
|
|
58
|
+
readonly inputMappings: ReadonlyMap<ts.Symbol, ScalarBaseTypeMapping>;
|
|
59
|
+
/** Maps base type symbol to scalar mappings for output context */
|
|
60
|
+
readonly outputMappings: ReadonlyMap<ts.Symbol, ScalarBaseTypeMapping>;
|
|
61
|
+
/** Conflicts detected during table construction */
|
|
62
|
+
readonly conflicts: ReadonlyMap<ts.Symbol, ScalarMappingConflict>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parameters for building a scalar mapping table.
|
|
67
|
+
*/
|
|
68
|
+
export interface BuildScalarMappingTableParams {
|
|
69
|
+
readonly detectedScalars: ReadonlyArray<ScalarMetadataInfo>;
|
|
70
|
+
readonly checker: ts.TypeChecker;
|
|
71
|
+
readonly program: ts.Program;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Extract the base type symbol from a scalar type.
|
|
76
|
+
* For GqlScalar<"DateTime", Date>, this returns the symbol for Date.
|
|
77
|
+
*/
|
|
78
|
+
function extractBaseTypeSymbol(
|
|
79
|
+
scalarInfo: ScalarMetadataInfo,
|
|
80
|
+
checker: ts.TypeChecker,
|
|
81
|
+
program: ts.Program,
|
|
82
|
+
): ts.Symbol | null {
|
|
83
|
+
const sourceFile = program.getSourceFile(scalarInfo.sourceFile);
|
|
84
|
+
if (!sourceFile) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let foundSymbol: ts.Symbol | null = null;
|
|
89
|
+
|
|
90
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
91
|
+
if (ts.isTypeAliasDeclaration(node)) {
|
|
92
|
+
const name = node.name.getText(sourceFile);
|
|
93
|
+
if (name === scalarInfo.typeName) {
|
|
94
|
+
const symbol = checker.getSymbolAtLocation(node.name);
|
|
95
|
+
if (symbol) {
|
|
96
|
+
const type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
97
|
+
// GqlScalar is an intersection type: Base & { " $gqlkitScalar"?: ... }
|
|
98
|
+
// We need to extract the Base type from this intersection
|
|
99
|
+
if (type.isIntersection()) {
|
|
100
|
+
for (const member of type.types) {
|
|
101
|
+
// Skip the metadata object type
|
|
102
|
+
if (member.getProperty(" $gqlkitScalar")) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// This should be the base type
|
|
106
|
+
if (member.symbol) {
|
|
107
|
+
foundSymbol = member.symbol;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return foundSymbol;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Builds a scalar mapping table from detected scalars.
|
|
122
|
+
*
|
|
123
|
+
* This function:
|
|
124
|
+
* 1. Extracts base type symbols from each scalar definition
|
|
125
|
+
* 2. Groups mappings by input/output context based on the `only` constraint
|
|
126
|
+
* 3. Detects conflicts when multiple scalars share the same base type in a context
|
|
127
|
+
*/
|
|
128
|
+
export function buildScalarMappingTable(
|
|
129
|
+
params: BuildScalarMappingTableParams,
|
|
130
|
+
): ScalarBaseTypeMappingTable {
|
|
131
|
+
const { detectedScalars, checker, program } = params;
|
|
132
|
+
|
|
133
|
+
const inputMappings = new Map<ts.Symbol, ScalarBaseTypeMapping>();
|
|
134
|
+
const outputMappings = new Map<ts.Symbol, ScalarBaseTypeMapping>();
|
|
135
|
+
const conflicts = new Map<ts.Symbol, ScalarMappingConflict>();
|
|
136
|
+
|
|
137
|
+
// Track all scalars for each base type symbol to detect conflicts
|
|
138
|
+
const inputCandidates = new Map<
|
|
139
|
+
ts.Symbol,
|
|
140
|
+
Array<{
|
|
141
|
+
scalarName: string;
|
|
142
|
+
only: "input" | "output" | null;
|
|
143
|
+
typeName: string;
|
|
144
|
+
}>
|
|
145
|
+
>();
|
|
146
|
+
const outputCandidates = new Map<
|
|
147
|
+
ts.Symbol,
|
|
148
|
+
Array<{
|
|
149
|
+
scalarName: string;
|
|
150
|
+
only: "input" | "output" | null;
|
|
151
|
+
typeName: string;
|
|
152
|
+
}>
|
|
153
|
+
>();
|
|
154
|
+
|
|
155
|
+
for (const scalarInfo of detectedScalars) {
|
|
156
|
+
const baseTypeSymbol = extractBaseTypeSymbol(scalarInfo, checker, program);
|
|
157
|
+
if (!baseTypeSymbol) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const candidate = {
|
|
162
|
+
scalarName: scalarInfo.scalarName,
|
|
163
|
+
only: scalarInfo.only,
|
|
164
|
+
typeName: scalarInfo.typeName,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Register to input context if no constraint or input-only
|
|
168
|
+
if (scalarInfo.only === null || scalarInfo.only === "input") {
|
|
169
|
+
const existing = inputCandidates.get(baseTypeSymbol) ?? [];
|
|
170
|
+
existing.push(candidate);
|
|
171
|
+
inputCandidates.set(baseTypeSymbol, existing);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Register to output context if no constraint or output-only
|
|
175
|
+
if (scalarInfo.only === null || scalarInfo.only === "output") {
|
|
176
|
+
const existing = outputCandidates.get(baseTypeSymbol) ?? [];
|
|
177
|
+
existing.push(candidate);
|
|
178
|
+
outputCandidates.set(baseTypeSymbol, existing);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Process input mappings and detect conflicts
|
|
183
|
+
for (const [symbol, candidates] of inputCandidates) {
|
|
184
|
+
if (candidates.length === 1) {
|
|
185
|
+
const candidate = candidates[0]!;
|
|
186
|
+
inputMappings.set(symbol, {
|
|
187
|
+
scalarName: candidate.scalarName,
|
|
188
|
+
only: candidate.only,
|
|
189
|
+
sourceTypeName: candidate.typeName,
|
|
190
|
+
});
|
|
191
|
+
} else if (candidates.length > 1) {
|
|
192
|
+
conflicts.set(symbol, {
|
|
193
|
+
code: "AMBIGUOUS_SCALAR_BASE_TYPE",
|
|
194
|
+
baseTypeSymbol: symbol,
|
|
195
|
+
conflictingScalars: candidates.map((c) => ({
|
|
196
|
+
scalarName: c.scalarName,
|
|
197
|
+
only: c.only,
|
|
198
|
+
})),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Process output mappings and detect conflicts
|
|
204
|
+
for (const [symbol, candidates] of outputCandidates) {
|
|
205
|
+
if (candidates.length === 1) {
|
|
206
|
+
const candidate = candidates[0]!;
|
|
207
|
+
outputMappings.set(symbol, {
|
|
208
|
+
scalarName: candidate.scalarName,
|
|
209
|
+
only: candidate.only,
|
|
210
|
+
sourceTypeName: candidate.typeName,
|
|
211
|
+
});
|
|
212
|
+
} else if (candidates.length > 1) {
|
|
213
|
+
// Only add conflict if not already added from input context
|
|
214
|
+
if (!conflicts.has(symbol)) {
|
|
215
|
+
conflicts.set(symbol, {
|
|
216
|
+
code: "AMBIGUOUS_SCALAR_BASE_TYPE",
|
|
217
|
+
baseTypeSymbol: symbol,
|
|
218
|
+
conflictingScalars: candidates.map((c) => ({
|
|
219
|
+
scalarName: c.scalarName,
|
|
220
|
+
only: c.only,
|
|
221
|
+
})),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return {
|
|
228
|
+
inputMappings,
|
|
229
|
+
outputMappings,
|
|
230
|
+
conflicts,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Parameters for looking up a scalar mapping.
|
|
236
|
+
*/
|
|
237
|
+
export interface LookupScalarMappingParams {
|
|
238
|
+
readonly baseTypeSymbol: ts.Symbol;
|
|
239
|
+
readonly context: ScalarMappingContext;
|
|
240
|
+
readonly table: ScalarBaseTypeMappingTable;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Looks up a scalar mapping for a given base type symbol and context.
|
|
245
|
+
*
|
|
246
|
+
* @returns mapping if found, conflict if detected, or both null if no mapping exists
|
|
247
|
+
*/
|
|
248
|
+
export function lookupScalarMapping(
|
|
249
|
+
params: LookupScalarMappingParams,
|
|
250
|
+
): ScalarMappingLookupResult {
|
|
251
|
+
const { baseTypeSymbol, context, table } = params;
|
|
252
|
+
|
|
253
|
+
// Check for conflicts first
|
|
254
|
+
const conflict = table.conflicts.get(baseTypeSymbol);
|
|
255
|
+
if (conflict) {
|
|
256
|
+
return { mapping: null, conflict };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Look up mapping based on context
|
|
260
|
+
const mappings =
|
|
261
|
+
context === "input" ? table.inputMappings : table.outputMappings;
|
|
262
|
+
const mapping = mappings.get(baseTypeSymbol);
|
|
263
|
+
|
|
264
|
+
return { mapping: mapping ?? null, conflict: null };
|
|
265
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export interface SourceLocation {
|
|
2
|
+
readonly file: string;
|
|
3
|
+
readonly line: number;
|
|
4
|
+
readonly column: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type DiagnosticCode =
|
|
8
|
+
| "DIRECTORY_NOT_FOUND"
|
|
9
|
+
| "PARSE_ERROR"
|
|
10
|
+
| "UNSUPPORTED_SYNTAX"
|
|
11
|
+
| "RESERVED_TYPE_NAME"
|
|
12
|
+
| "UNRESOLVED_REFERENCE"
|
|
13
|
+
| "NAMING_CONVENTION_MISMATCH"
|
|
14
|
+
| "INVALID_RESOLVER_SIGNATURE"
|
|
15
|
+
| "UNSUPPORTED_RETURN_TYPE"
|
|
16
|
+
| "UNSUPPORTED_ARG_TYPE"
|
|
17
|
+
| "UNKNOWN_TARGET_TYPE"
|
|
18
|
+
| "PARENT_TYPE_MISMATCH"
|
|
19
|
+
| "MISSING_PARENT_TYPE"
|
|
20
|
+
| "UNSUPPORTED_ENUM_TYPE"
|
|
21
|
+
| "INVALID_ENUM_MEMBER"
|
|
22
|
+
| "INVALID_INPUT_TYPE"
|
|
23
|
+
| "UNKNOWN_ARGUMENT_TYPE"
|
|
24
|
+
| "OUTPUT_TYPE_IN_INPUT"
|
|
25
|
+
| "CIRCULAR_INPUT_REFERENCE"
|
|
26
|
+
| "UNKNOWN_BRANDED_SCALAR"
|
|
27
|
+
| "INVALID_SCALAR_IMPORT"
|
|
28
|
+
| "CONFLICTING_SCALAR_TYPE"
|
|
29
|
+
| "INVALID_DEFINE_CALL"
|
|
30
|
+
| "CONFIG_SYNTAX_ERROR"
|
|
31
|
+
| "CONFIG_MISSING_PROPERTY"
|
|
32
|
+
| "CONFIG_INVALID_TYPE"
|
|
33
|
+
| "CONFIG_INVALID_PATH"
|
|
34
|
+
| "CONFIG_BUILTIN_OVERRIDE"
|
|
35
|
+
| "CONFIG_DUPLICATE_MAPPING"
|
|
36
|
+
| "CONFIG_DUPLICATE_TYPE"
|
|
37
|
+
| "CONFIG_INVALID_OUTPUT_TYPE"
|
|
38
|
+
| "CONFIG_INVALID_OUTPUT_PATH"
|
|
39
|
+
| "CONFIG_INVALID_SOURCE_DIR"
|
|
40
|
+
| "CONFIG_INVALID_IGNORE_GLOBS"
|
|
41
|
+
| "CONFIG_INVALID_HOOK_TYPE"
|
|
42
|
+
| "CONFIG_INVALID_HOOK_COMMAND"
|
|
43
|
+
| "CONFIG_INVALID_ONLY_VALUE"
|
|
44
|
+
| "CUSTOM_SCALAR_TYPE_NOT_FOUND"
|
|
45
|
+
| "TSCONFIG_NOT_FOUND"
|
|
46
|
+
| "TSCONFIG_PARSE_ERROR"
|
|
47
|
+
| "TSCONFIG_INVALID"
|
|
48
|
+
| "ONEOF_FIELD_NAME_CONFLICT"
|
|
49
|
+
| "ONEOF_MULTIPLE_PROPERTIES"
|
|
50
|
+
| "ONEOF_EMPTY_OBJECT"
|
|
51
|
+
| "ONEOF_INVALID_FIELD_TYPE"
|
|
52
|
+
| "ONEOF_DUPLICATE_PROPERTY"
|
|
53
|
+
| "ONEOF_MIXED_MEMBERS"
|
|
54
|
+
| "ONEOF_NAMED_TYPE_UNION"
|
|
55
|
+
| "MULTIPLE_INPUT_TYPES"
|
|
56
|
+
| "MISSING_INPUT_TYPE"
|
|
57
|
+
| "MISSING_OUTPUT_TYPE"
|
|
58
|
+
| "EMPTY_DIRECTIVE_NAME"
|
|
59
|
+
| "UNRESOLVABLE_ARGUMENT"
|
|
60
|
+
| "UNRESOLVABLE_ARG_TYPE"
|
|
61
|
+
| "INVALID_LOCATION"
|
|
62
|
+
| "INVALID_DIRECTIVE_LOCATION"
|
|
63
|
+
| "UNSUPPORTED_DIRECTIVE_LOCATION"
|
|
64
|
+
| "UNDEFINED_DIRECTIVE"
|
|
65
|
+
| "INTERFACE_NOT_FOUND"
|
|
66
|
+
| "INTERFACE_NOT_INTERFACE"
|
|
67
|
+
| "INTERFACE_MISSING_FIELD"
|
|
68
|
+
| "INTERFACE_FIELD_TYPE_MISMATCH"
|
|
69
|
+
| "INTERFACE_CIRCULAR_REFERENCE"
|
|
70
|
+
| "UNRESOLVABLE_DEFAULT_VALUE"
|
|
71
|
+
| "AUTO_TYPE_NAME_COLLISION_USER"
|
|
72
|
+
| "AUTO_TYPE_NAME_COLLISION_AUTO"
|
|
73
|
+
| "MODULE_RESOLUTION_ERROR"
|
|
74
|
+
| "SKIPPED_FIELD"
|
|
75
|
+
| "SKIPPED_ENUM_VALUE"
|
|
76
|
+
| "INDEX_SIGNATURE_ONLY"
|
|
77
|
+
| "UNKNOWN_ABSTRACT_TYPE"
|
|
78
|
+
| "INVALID_ABSTRACT_TYPE_KIND"
|
|
79
|
+
| "INVALID_OBJECT_TYPE_KIND"
|
|
80
|
+
| "DUPLICATE_RESOLVE_TYPE"
|
|
81
|
+
| "DUPLICATE_IS_TYPE_OF"
|
|
82
|
+
| "MISSING_ABSTRACT_TYPE_RESOLVER"
|
|
83
|
+
| "DUPLICATE_ENUM_VALUE"
|
|
84
|
+
| "DUPLICATE_ENUM_VALUE_AFTER_CONVERSION"
|
|
85
|
+
| "INVALID_ENUM_MEMBER_NAME"
|
|
86
|
+
| "AMBIGUOUS_SCALAR_BASE_TYPE"
|
|
87
|
+
| "INLINE_UNION_PRIMITIVE_MEMBER"
|
|
88
|
+
| "INLINE_UNION_ENUM_MEMBER"
|
|
89
|
+
| "INLINE_UNION_UNRESOLVABLE_MEMBER"
|
|
90
|
+
| "MISSING_TYPENAME_PROPERTY"
|
|
91
|
+
| "INVALID_TYPENAME_TYPE"
|
|
92
|
+
| "OPTIONAL_TYPENAME_PROPERTY"
|
|
93
|
+
| "NULLABLE_TYPENAME_PROPERTY"
|
|
94
|
+
| "TYPENAME_FIELD_STRUCTURE_MISMATCH"
|
|
95
|
+
| "DUPLICATE_TYPENAME_VALUE"
|
|
96
|
+
| "IGNORE_FIELD_NOT_FOUND"
|
|
97
|
+
| "IGNORE_ALL_FIELDS";
|
|
98
|
+
|
|
99
|
+
export interface Diagnostic {
|
|
100
|
+
readonly code: DiagnosticCode;
|
|
101
|
+
readonly message: string;
|
|
102
|
+
readonly severity: "error" | "warning";
|
|
103
|
+
readonly location: SourceLocation | null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface Diagnostics {
|
|
107
|
+
readonly errors: ReadonlyArray<Diagnostic>;
|
|
108
|
+
readonly warnings: ReadonlyArray<Diagnostic>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DirectiveArgumentValue,
|
|
3
|
+
DirectiveInfo,
|
|
4
|
+
} from "../../shared/directive-detector.js";
|
|
5
|
+
import type { DeprecationInfo } from "../../shared/tsdoc-parser.js";
|
|
6
|
+
|
|
7
|
+
export type GraphQLTypeKind =
|
|
8
|
+
| "Object"
|
|
9
|
+
| "Interface"
|
|
10
|
+
| "Union"
|
|
11
|
+
| "Enum"
|
|
12
|
+
| "InputObject"
|
|
13
|
+
| "OneOfInputObject";
|
|
14
|
+
|
|
15
|
+
export interface GraphQLFieldType {
|
|
16
|
+
readonly typeName: string;
|
|
17
|
+
readonly nullable: boolean;
|
|
18
|
+
readonly list: boolean;
|
|
19
|
+
readonly listItemNullable: boolean | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FieldInfo {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly type: GraphQLFieldType;
|
|
25
|
+
readonly description: string | null;
|
|
26
|
+
readonly deprecated: DeprecationInfo | null;
|
|
27
|
+
readonly directives: ReadonlyArray<DirectiveInfo> | null;
|
|
28
|
+
readonly defaultValue: DirectiveArgumentValue | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface EnumValueInfo {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly originalValue: string;
|
|
34
|
+
/** Numeric value for numeric enums, null for string enums */
|
|
35
|
+
readonly numericValue: number | null;
|
|
36
|
+
readonly description: string | null;
|
|
37
|
+
readonly deprecated: DeprecationInfo | null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface GraphQLTypeInfo {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly kind: GraphQLTypeKind;
|
|
43
|
+
readonly fields: ReadonlyArray<FieldInfo> | null;
|
|
44
|
+
readonly unionMembers: ReadonlyArray<string> | null;
|
|
45
|
+
readonly enumValues: ReadonlyArray<EnumValueInfo> | null;
|
|
46
|
+
/** True if this enum uses numeric values */
|
|
47
|
+
readonly isNumericEnum: boolean;
|
|
48
|
+
/** True if this string enum needs value mapping (at least one value converted) */
|
|
49
|
+
readonly needsStringEnumMapping: boolean;
|
|
50
|
+
readonly implementedInterfaces: ReadonlyArray<string> | null;
|
|
51
|
+
readonly sourceFile: string;
|
|
52
|
+
readonly description: string | null;
|
|
53
|
+
readonly deprecated: DeprecationInfo | null;
|
|
54
|
+
readonly directives: ReadonlyArray<DirectiveInfo> | null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type { DeprecationInfo } from "../../shared/tsdoc-parser.js";
|
|
2
|
+
export type {
|
|
3
|
+
Diagnostic,
|
|
4
|
+
DiagnosticCode,
|
|
5
|
+
Diagnostics,
|
|
6
|
+
SourceLocation,
|
|
7
|
+
} from "./diagnostics.js";
|
|
8
|
+
export type {
|
|
9
|
+
EnumValueInfo,
|
|
10
|
+
FieldInfo,
|
|
11
|
+
GraphQLFieldType,
|
|
12
|
+
GraphQLTypeInfo,
|
|
13
|
+
GraphQLTypeKind,
|
|
14
|
+
} from "./graphql.js";
|
|
15
|
+
export {
|
|
16
|
+
createArrayType,
|
|
17
|
+
createInlineObjectType,
|
|
18
|
+
createLiteralType,
|
|
19
|
+
createPrimitiveType,
|
|
20
|
+
createReferenceType,
|
|
21
|
+
createScalarType,
|
|
22
|
+
createUnionType,
|
|
23
|
+
} from "./ts-type-reference-factory.js";
|
|
24
|
+
export type {
|
|
25
|
+
EnumMemberInfo,
|
|
26
|
+
ExtractedTypeInfo,
|
|
27
|
+
FieldDefinition,
|
|
28
|
+
InlineEnumMemberInfo,
|
|
29
|
+
InlineObjectMember,
|
|
30
|
+
InlineObjectProperty,
|
|
31
|
+
InlineObjectPropertyDef,
|
|
32
|
+
ScalarTypeInfo,
|
|
33
|
+
TSTypeReference,
|
|
34
|
+
TSTypeReferenceKind,
|
|
35
|
+
TypeKind,
|
|
36
|
+
TypeMetadata,
|
|
37
|
+
} from "./typescript.js";
|