From f45a084a8cc7657a6de9598c27fe2c76b303502b Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 19 Oct 2024 09:40:16 -0400 Subject: [PATCH 1/4] refactor(generator): raise to external pos --- src/entrypoints/_Generator.ts | 4 ++-- src/entrypoints/extensionkit.ts | 2 +- src/entrypoints/utilities-for-generated.ts | 4 ++-- .../CustomScalars/schemaDrivenDataMap/generator.ts | 10 +++++----- src/extensions/SchemaErrors/generator.ts | 2 +- src/extensions/SchemaErrors/global.ts | 2 +- src/{layers/4_generator => generator}/_.ts | 0 src/{layers/4_generator => generator}/__.ts | 0 src/{ => generator}/cli/generate.ts | 6 +++--- .../config/__snapshots__/config.test.ts.snap | 0 .../config/config.test.ts | 2 +- .../4_generator => generator}/config/config.ts | 14 +++++++------- .../4_generator => generator}/config/defaults.ts | 0 .../4_generator => generator}/config/input.ts | 2 +- .../4_generator => generator}/configFile/_.ts | 0 .../configFile/builder.ts | 0 .../4_generator => generator}/configFile/loader.ts | 8 ++++---- .../4_generator => generator}/extension/create.ts | 0 .../4_generator => generator}/extension/types.ts | 4 ++-- .../generator/__snapshots__/generate.test.ts.snap | 0 .../generator/generate.test.ts | 0 .../generator/generate.ts | 2 +- .../4_generator => generator}/generators/Client.ts | 2 +- .../4_generator => generator}/generators/Data.ts | 0 .../generators/MethodsDocument.ts | 0 .../generators/MethodsRoot.ts | 2 +- .../generators/MethodsSelect.ts | 2 +- .../4_generator => generator}/generators/Scalar.ts | 2 +- .../4_generator => generator}/generators/Schema.ts | 12 ++++++------ .../4_generator => generator}/generators/Select.ts | 0 .../generators/SelectionSets.test-d.ts | 2 +- .../generators/SelectionSets.ts | 10 +++++----- .../4_generator => generator}/generators/_.ts | 2 +- .../4_generator => generator}/generators/__.ts | 2 +- .../4_generator => generator}/generators/global.ts | 2 +- .../helpers/identifiers.ts | 0 .../helpers/moduleGenerator.ts | 0 .../helpers/moduleGeneratorRunner.ts | 0 .../4_generator => generator}/helpers/render.ts | 8 ++++---- src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts | 2 +- src/layers/3_InferResult/Alias.ts | 2 +- src/layers/3_InferResult/Field.ts | 2 +- src/layers/3_InferResult/InlineFragment.ts | 2 +- src/layers/3_InferResult/Interface.ts | 2 +- src/layers/3_InferResult/Object.ts | 2 +- src/layers/3_InferResult/ScalarsWildcard.ts | 2 +- src/layers/3_InferResult/Union.ts | 2 +- src/layers/3_InferResult/root.ts | 2 +- src/layers/5_select/select.ts | 2 +- src/layers/6_client/Settings/Config.ts | 2 +- src/layers/6_client/Settings/Input.ts | 2 +- src/layers/6_client/Settings/InputToConfig.ts | 2 +- .../inputIncrementable/inputIncrementable.ts | 2 +- src/layers/6_client/extension/extension.ts | 2 +- src/layers/6_client/handleOutput.ts | 2 +- src/layers/6_client/prefilled.ts | 2 +- src/layers/6_client/requestMethods/document.ts | 2 +- .../6_client/requestMethods/requestMethods.ts | 2 +- src/layers/{4_generator => }/GlobalRegistry.ts | 10 +++++----- tests/_/schemas/generate.ts | 2 +- .../schemas/kitchen-sink/graffle/modules/Schema.ts | 12 ++++++++++++ 61 files changed, 91 insertions(+), 79 deletions(-) rename src/{layers/4_generator => generator}/_.ts (100%) rename src/{layers/4_generator => generator}/__.ts (100%) rename src/{ => generator}/cli/generate.ts (96%) rename src/{layers/4_generator => generator}/config/__snapshots__/config.test.ts.snap (100%) rename src/{layers/4_generator => generator}/config/config.test.ts (96%) rename src/{layers/4_generator => generator}/config/config.ts (94%) rename src/{layers/4_generator => generator}/config/defaults.ts (100%) rename src/{layers/4_generator => generator}/config/input.ts (98%) rename src/{layers/4_generator => generator}/configFile/_.ts (100%) rename src/{layers/4_generator => generator}/configFile/builder.ts (100%) rename src/{layers/4_generator => generator}/configFile/loader.ts (91%) rename src/{layers/4_generator => generator}/extension/create.ts (100%) rename src/{layers/4_generator => generator}/extension/types.ts (86%) rename src/{layers/4_generator => generator}/generator/__snapshots__/generate.test.ts.snap (100%) rename src/{layers/4_generator => generator}/generator/generate.test.ts (100%) rename src/{layers/4_generator => generator}/generator/generate.ts (95%) rename src/{layers/4_generator => generator}/generators/Client.ts (84%) rename src/{layers/4_generator => generator}/generators/Data.ts (100%) rename src/{layers/4_generator => generator}/generators/MethodsDocument.ts (100%) rename src/{layers/4_generator => generator}/generators/MethodsRoot.ts (98%) rename src/{layers/4_generator => generator}/generators/MethodsSelect.ts (97%) rename src/{layers/4_generator => generator}/generators/Scalar.ts (98%) rename src/{layers/4_generator => generator}/generators/Schema.ts (97%) rename src/{layers/4_generator => generator}/generators/Select.ts (100%) rename src/{layers/4_generator => generator}/generators/SelectionSets.test-d.ts (98%) rename src/{layers/4_generator => generator}/generators/SelectionSets.ts (98%) rename src/{layers/4_generator => generator}/generators/_.ts (90%) rename src/{layers/4_generator => generator}/generators/__.ts (90%) rename src/{layers/4_generator => generator}/generators/global.ts (98%) rename src/{layers/4_generator => generator}/helpers/identifiers.ts (100%) rename src/{layers/4_generator => generator}/helpers/moduleGenerator.ts (100%) rename src/{layers/4_generator => generator}/helpers/moduleGeneratorRunner.ts (100%) rename src/{layers/4_generator => generator}/helpers/render.ts (95%) rename src/layers/{4_generator => }/GlobalRegistry.ts (89%) diff --git a/src/entrypoints/_Generator.ts b/src/entrypoints/_Generator.ts index 1d1e8c46e..701509565 100644 --- a/src/entrypoints/_Generator.ts +++ b/src/entrypoints/_Generator.ts @@ -1,2 +1,2 @@ -export { generate } from '../layers/4_generator/_.js' -export { create } from '../layers/4_generator/configFile/builder.js' +export { generate } from '../generator/_.js' +export { create } from '../generator/configFile/builder.js' diff --git a/src/entrypoints/extensionkit.ts b/src/entrypoints/extensionkit.ts index 9ca6c4523..958c59b3f 100644 --- a/src/entrypoints/extensionkit.ts +++ b/src/entrypoints/extensionkit.ts @@ -1,2 +1,2 @@ -export { createExtension as createGeneratorExtension } from '../layers/4_generator/extension/create.js' +export { createExtension as createGeneratorExtension } from '../generator/extension/create.js' export { createExtension } from '../layers/6_client/extension/extension.js' diff --git a/src/entrypoints/utilities-for-generated.ts b/src/entrypoints/utilities-for-generated.ts index 27492d485..7741fc889 100644 --- a/src/entrypoints/utilities-for-generated.ts +++ b/src/entrypoints/utilities-for-generated.ts @@ -1,8 +1,7 @@ export { type Simplify } from 'type-fest' export { type SchemaDrivenDataMap } from '../extensions/CustomScalars/schemaDrivenDataMap/__.js' +export { type Schema as SchemaIndexBase } from '../generator/generators/Schema.js' export * from '../layers/2_Select/__.js' -export { type Schema as SchemaIndexBase } from '../layers/4_generator/generators/Schema.js' -export { type GlobalRegistry } from '../layers/4_generator/GlobalRegistry.js' export type { ConfigGetOutputError, HandleOutput, @@ -10,5 +9,6 @@ export type { } from '../layers/6_client/handleOutput.js' export { type DocumentRunner } from '../layers/6_client/requestMethods/document.js' export type { Config } from '../layers/6_client/Settings/Config.js' +export { type GlobalRegistry } from '../layers/GlobalRegistry.js' export { type Exact, type ExactNonEmpty, type UnionExpanded } from '../lib/prelude.js' export { TypeFunction } from '../lib/type-function/__.js' diff --git a/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts b/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts index abd4135b1..6a4bd7f27 100644 --- a/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts +++ b/src/extensions/CustomScalars/schemaDrivenDataMap/generator.ts @@ -1,8 +1,8 @@ -import type { Config } from '../../../layers/4_generator/config/config.js' -import { ModuleGeneratorScalar } from '../../../layers/4_generator/generators/Scalar.js' -import { createModuleGenerator } from '../../../layers/4_generator/helpers/moduleGenerator.js' -import { createCodeGenerator } from '../../../layers/4_generator/helpers/moduleGeneratorRunner.js' -import { title1 } from '../../../layers/4_generator/helpers/render.js' +import type { Config } from '../../../generator/config/config.js' +import { ModuleGeneratorScalar } from '../../../generator/generators/Scalar.js' +import { createModuleGenerator } from '../../../generator/helpers/moduleGenerator.js' +import { createCodeGenerator } from '../../../generator/helpers/moduleGeneratorRunner.js' +import { title1 } from '../../../generator/helpers/render.js' import { Code } from '../../../lib/Code.js' import { Grafaid } from '../../../lib/grafaid/__.js' import { entries } from '../../../lib/prelude.js' diff --git a/src/extensions/SchemaErrors/generator.ts b/src/extensions/SchemaErrors/generator.ts index 517a86a7e..7b152db05 100644 --- a/src/extensions/SchemaErrors/generator.ts +++ b/src/extensions/SchemaErrors/generator.ts @@ -1,5 +1,5 @@ import { createGeneratorExtension } from '../../entrypoints/extensionkit.js' -import type { Config as GeneratorConfig } from '../../layers/4_generator/config/config.js' +import type { Config as GeneratorConfig } from '../../generator/config/config.js' import { Code } from '../../lib/Code.js' import { ConfigManager } from '../../lib/config-manager/__.js' import { Grafaid } from '../../lib/grafaid/__.js' diff --git a/src/extensions/SchemaErrors/global.ts b/src/extensions/SchemaErrors/global.ts index e2f3c2d3a..5037a0609 100644 --- a/src/extensions/SchemaErrors/global.ts +++ b/src/extensions/SchemaErrors/global.ts @@ -1,4 +1,4 @@ -import type { GlobalRegistry } from '../../layers/4_generator/GlobalRegistry.js' +import type { GlobalRegistry } from '../../layers/GlobalRegistry.js' declare global { namespace GraffleGlobal { diff --git a/src/layers/4_generator/_.ts b/src/generator/_.ts similarity index 100% rename from src/layers/4_generator/_.ts rename to src/generator/_.ts diff --git a/src/layers/4_generator/__.ts b/src/generator/__.ts similarity index 100% rename from src/layers/4_generator/__.ts rename to src/generator/__.ts diff --git a/src/cli/generate.ts b/src/generator/cli/generate.ts similarity index 96% rename from src/cli/generate.ts rename to src/generator/cli/generate.ts index f5cc581fc..58e9a96b0 100755 --- a/src/cli/generate.ts +++ b/src/generator/cli/generate.ts @@ -3,9 +3,9 @@ import { Command } from '@molt/command' import * as Path from 'node:path' import { z } from 'zod' -import { Generator } from '../layers/4_generator/__.js' -import { toAbsolutePath } from '../lib/fs.js' -import { isError, urlParseSafe } from '../lib/prelude.js' +import { toAbsolutePath } from '../../lib/fs.js' +import { isError, urlParseSafe } from '../../lib/prelude.js' +import { Generator } from '../__.js' const args = Command.create().description(`Generate a type safe GraphQL client.`) .parameter( diff --git a/src/layers/4_generator/config/__snapshots__/config.test.ts.snap b/src/generator/config/__snapshots__/config.test.ts.snap similarity index 100% rename from src/layers/4_generator/config/__snapshots__/config.test.ts.snap rename to src/generator/config/__snapshots__/config.test.ts.snap diff --git a/src/layers/4_generator/config/config.test.ts b/src/generator/config/config.test.ts similarity index 96% rename from src/layers/4_generator/config/config.test.ts rename to src/generator/config/config.test.ts index dea1b0564..bd75a5c32 100644 --- a/src/layers/4_generator/config/config.test.ts +++ b/src/generator/config/config.test.ts @@ -1,5 +1,5 @@ import { expect } from 'vitest' -import { test } from '../../../../tests/_/helpers.js' +import { test } from '../../../tests/_/helpers.js' import { createConfig } from './config.js' test(`can load schema from custom path`, async () => { diff --git a/src/layers/4_generator/config/config.ts b/src/generator/config/config.ts similarity index 94% rename from src/layers/4_generator/config/config.ts rename to src/generator/config/config.ts index 0f60dddcb..afe4d07e1 100644 --- a/src/layers/4_generator/config/config.ts +++ b/src/generator/config/config.ts @@ -1,16 +1,16 @@ import fs from 'node:fs/promises' import * as Path from 'node:path' -import { Graffle } from '../../../entrypoints/__Graffle.js' -import { Introspection } from '../../../entrypoints/extensions.js' -import { ConfigManager } from '../../../lib/config-manager/__.js' -import { fileExists, isPathToADirectory, toAbsolutePath, toFilePath } from '../../../lib/fs.js' -import { Grafaid } from '../../../lib/grafaid/__.js' -import { isString } from '../../../lib/prelude.js' +import { Graffle } from '../../entrypoints/__Graffle.js' +import { Introspection } from '../../entrypoints/extensions.js' +import { ConfigManager } from '../../lib/config-manager/__.js' +import { fileExists, isPathToADirectory, toAbsolutePath, toFilePath } from '../../lib/fs.js' +import { Grafaid } from '../../lib/grafaid/__.js' +import { isString } from '../../lib/prelude.js' import { type Formatter, getTypescriptFormatterOrPassthrough, passthroughFormatter, -} from '../../../lib/typescript-formatter.js' +} from '../../lib/typescript-formatter.js' import type { Extension } from '../extension/types.js' import { defaultLibraryPaths } from './defaults.js' import { defaultName } from './defaults.js' diff --git a/src/layers/4_generator/config/defaults.ts b/src/generator/config/defaults.ts similarity index 100% rename from src/layers/4_generator/config/defaults.ts rename to src/generator/config/defaults.ts diff --git a/src/layers/4_generator/config/input.ts b/src/generator/config/input.ts similarity index 98% rename from src/layers/4_generator/config/input.ts rename to src/generator/config/input.ts index 8481ef366..a57803416 100644 --- a/src/layers/4_generator/config/input.ts +++ b/src/generator/config/input.ts @@ -1,4 +1,4 @@ -import type { Grafaid } from '../../../lib/grafaid/__.js' +import type { Grafaid } from '../../lib/grafaid/__.js' import type { Extension } from '../extension/types.js' export interface InputLint { diff --git a/src/layers/4_generator/configFile/_.ts b/src/generator/configFile/_.ts similarity index 100% rename from src/layers/4_generator/configFile/_.ts rename to src/generator/configFile/_.ts diff --git a/src/layers/4_generator/configFile/builder.ts b/src/generator/configFile/builder.ts similarity index 100% rename from src/layers/4_generator/configFile/builder.ts rename to src/generator/configFile/builder.ts diff --git a/src/layers/4_generator/configFile/loader.ts b/src/generator/configFile/loader.ts similarity index 91% rename from src/layers/4_generator/configFile/loader.ts rename to src/generator/configFile/loader.ts index 7db1def0b..52328bdbe 100644 --- a/src/layers/4_generator/configFile/loader.ts +++ b/src/generator/configFile/loader.ts @@ -1,8 +1,8 @@ import * as Path from 'node:path' -import { Errors } from '../../../lib/errors/__.js' -import { isPathToADirectory, toAbsolutePath } from '../../../lib/fs.js' -import { importFirst } from '../../../lib/import-first.js' -import { isError } from '../../../lib/prelude.js' +import { Errors } from '../../lib/errors/__.js' +import { isPathToADirectory, toAbsolutePath } from '../../lib/fs.js' +import { importFirst } from '../../lib/import-first.js' +import { isError } from '../../lib/prelude.js' import { type Builder, isBuilder } from './builder.js' interface Config { diff --git a/src/layers/4_generator/extension/create.ts b/src/generator/extension/create.ts similarity index 100% rename from src/layers/4_generator/extension/create.ts rename to src/generator/extension/create.ts diff --git a/src/layers/4_generator/extension/types.ts b/src/generator/extension/types.ts similarity index 86% rename from src/layers/4_generator/extension/types.ts rename to src/generator/extension/types.ts index 94b107d5a..efcfe2314 100644 --- a/src/layers/4_generator/extension/types.ts +++ b/src/generator/extension/types.ts @@ -1,5 +1,5 @@ -import type { Code } from '../../../lib/Code.js' -import type { Grafaid } from '../../../lib/grafaid/__.js' +import type { Code } from '../../lib/Code.js' +import type { Grafaid } from '../../lib/grafaid/__.js' import type { Config } from '../config/config.js' export interface Extension { diff --git a/src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap b/src/generator/generator/__snapshots__/generate.test.ts.snap similarity index 100% rename from src/layers/4_generator/generator/__snapshots__/generate.test.ts.snap rename to src/generator/generator/__snapshots__/generate.test.ts.snap diff --git a/src/layers/4_generator/generator/generate.test.ts b/src/generator/generator/generate.test.ts similarity index 100% rename from src/layers/4_generator/generator/generate.test.ts rename to src/generator/generator/generate.test.ts diff --git a/src/layers/4_generator/generator/generate.ts b/src/generator/generator/generate.ts similarity index 95% rename from src/layers/4_generator/generator/generate.ts rename to src/generator/generator/generate.ts index 00f9eb664..3e259fcae 100644 --- a/src/layers/4_generator/generator/generate.ts +++ b/src/generator/generator/generate.ts @@ -1,5 +1,5 @@ import fs from 'node:fs/promises' -import { ModuleGeneratorSchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' +import { ModuleGeneratorSchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' import { createConfig } from '../config/config.js' import type { Input } from '../config/input.js' import { ModuleGenerator_ } from '../generators/_.js' diff --git a/src/layers/4_generator/generators/Client.ts b/src/generator/generators/Client.ts similarity index 84% rename from src/layers/4_generator/generators/Client.ts rename to src/generator/generators/Client.ts index 386f35d8f..1e4343859 100644 --- a/src/layers/4_generator/generators/Client.ts +++ b/src/generator/generators/Client.ts @@ -1,4 +1,4 @@ -import { ModuleGeneratorSchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' +import { ModuleGeneratorSchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGeneratorData } from './Data.js' diff --git a/src/layers/4_generator/generators/Data.ts b/src/generator/generators/Data.ts similarity index 100% rename from src/layers/4_generator/generators/Data.ts rename to src/generator/generators/Data.ts diff --git a/src/layers/4_generator/generators/MethodsDocument.ts b/src/generator/generators/MethodsDocument.ts similarity index 100% rename from src/layers/4_generator/generators/MethodsDocument.ts rename to src/generator/generators/MethodsDocument.ts diff --git a/src/layers/4_generator/generators/MethodsRoot.ts b/src/generator/generators/MethodsRoot.ts similarity index 98% rename from src/layers/4_generator/generators/MethodsRoot.ts rename to src/generator/generators/MethodsRoot.ts index 8a9326b70..115ec20cd 100644 --- a/src/layers/4_generator/generators/MethodsRoot.ts +++ b/src/generator/generators/MethodsRoot.ts @@ -1,5 +1,5 @@ // todo remove use of Utils.Aug when schema errors not in use -import { Grafaid } from '../../../lib/grafaid/__.js' +import { Grafaid } from '../../lib/grafaid/__.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { createCodeGenerator } from '../helpers/moduleGeneratorRunner.js' import { renderDocumentation, renderName } from '../helpers/render.js' diff --git a/src/layers/4_generator/generators/MethodsSelect.ts b/src/generator/generators/MethodsSelect.ts similarity index 97% rename from src/layers/4_generator/generators/MethodsSelect.ts rename to src/generator/generators/MethodsSelect.ts index 1ab885bc3..c133990ac 100644 --- a/src/layers/4_generator/generators/MethodsSelect.ts +++ b/src/generator/generators/MethodsSelect.ts @@ -1,5 +1,5 @@ // todo jsdoc -import { Grafaid } from '../../../lib/grafaid/__.js' +import { Grafaid } from '../../lib/grafaid/__.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { renderName, title1 } from '../helpers/render.js' import { ModuleGeneratorSelectionSets } from './SelectionSets.js' diff --git a/src/layers/4_generator/generators/Scalar.ts b/src/generator/generators/Scalar.ts similarity index 98% rename from src/layers/4_generator/generators/Scalar.ts rename to src/generator/generators/Scalar.ts index 3d849430c..e619d99f6 100644 --- a/src/layers/4_generator/generators/Scalar.ts +++ b/src/generator/generators/Scalar.ts @@ -1,4 +1,4 @@ -import { Grafaid } from '../../../lib/grafaid/__.js' +import { Grafaid } from '../../lib/grafaid/__.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { typeTitle2 } from '../helpers/render.js' diff --git a/src/layers/4_generator/generators/Schema.ts b/src/generator/generators/Schema.ts similarity index 97% rename from src/layers/4_generator/generators/Schema.ts rename to src/generator/generators/Schema.ts index 9f7fbd420..20fb8538c 100644 --- a/src/layers/4_generator/generators/Schema.ts +++ b/src/generator/generators/Schema.ts @@ -1,10 +1,10 @@ -import type { SchemaDrivenDataMap } from '../../../entrypoints/utilities-for-generated.js' -import { Code } from '../../../lib/Code.js' -import { Grafaid } from '../../../lib/grafaid/__.js' -import { entries, isObjectEmpty, values } from '../../../lib/prelude.js' -import type { SchemaKit } from '../../1_Schema/__.js' +import type { SchemaDrivenDataMap } from '../../entrypoints/utilities-for-generated.js' +import type { SchemaKit } from '../../layers/1_Schema/__.js' +import type { GlobalRegistry } from '../../layers/GlobalRegistry.js' +import { Code } from '../../lib/Code.js' +import { Grafaid } from '../../lib/grafaid/__.js' +import { entries, isObjectEmpty, values } from '../../lib/prelude.js' import type { Config } from '../config/config.js' -import type { GlobalRegistry } from '../GlobalRegistry.js' import { identifiers } from '../helpers/identifiers.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { createCodeGenerator } from '../helpers/moduleGeneratorRunner.js' diff --git a/src/layers/4_generator/generators/Select.ts b/src/generator/generators/Select.ts similarity index 100% rename from src/layers/4_generator/generators/Select.ts rename to src/generator/generators/Select.ts diff --git a/src/layers/4_generator/generators/SelectionSets.test-d.ts b/src/generator/generators/SelectionSets.test-d.ts similarity index 98% rename from src/layers/4_generator/generators/SelectionSets.test-d.ts rename to src/generator/generators/SelectionSets.test-d.ts index e2eb9c892..015997fe4 100644 --- a/src/layers/4_generator/generators/SelectionSets.test-d.ts +++ b/src/generator/generators/SelectionSets.test-d.ts @@ -1,5 +1,5 @@ import { assertType, test } from 'vitest' -import type * as SelectionSets from '../../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js' +import type * as SelectionSets from '../../../tests/_/schemas/kitchen-sink/graffle/modules/SelectionSets.js' type Q = SelectionSets.Query diff --git a/src/layers/4_generator/generators/SelectionSets.ts b/src/generator/generators/SelectionSets.ts similarity index 98% rename from src/layers/4_generator/generators/SelectionSets.ts rename to src/generator/generators/SelectionSets.ts index 1858cfd8b..553db22f6 100644 --- a/src/layers/4_generator/generators/SelectionSets.ts +++ b/src/generator/generators/SelectionSets.ts @@ -1,11 +1,11 @@ // todo: generate in JSDoc how the feature maps to GQL syntax. // todo: on union fields, JSDoc that mentions the syntax `on*` -import { Code } from '../../../lib/Code.js' -import { Grafaid } from '../../../lib/grafaid/__.js' -import { analyzeArgsNullability } from '../../../lib/grafaid/schema/args.js' -import { RootTypeName } from '../../../lib/grafaid/schema/schema.js' -import { Select } from '../../2_Select/__.js' +import { Select } from '../../layers/2_Select/__.js' +import { Code } from '../../lib/Code.js' +import { Grafaid } from '../../lib/grafaid/__.js' +import { analyzeArgsNullability } from '../../lib/grafaid/schema/args.js' +import { RootTypeName } from '../../lib/grafaid/schema/schema.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { createCodeGenerator } from '../helpers/moduleGeneratorRunner.js' import { getDocumentation, renderDocumentation, renderName, title1, typeTitle2SelectionSet } from '../helpers/render.js' diff --git a/src/layers/4_generator/generators/_.ts b/src/generator/generators/_.ts similarity index 90% rename from src/layers/4_generator/generators/_.ts rename to src/generator/generators/_.ts index 3eb69e467..26bb1d46c 100644 --- a/src/layers/4_generator/generators/_.ts +++ b/src/generator/generators/_.ts @@ -1,4 +1,4 @@ -import { ModuleGeneratorSchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' +import { ModuleGeneratorSchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/generator.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGeneratorClient } from './Client.js' import { ModuleGeneratorSelect } from './Select.js' diff --git a/src/layers/4_generator/generators/__.ts b/src/generator/generators/__.ts similarity index 90% rename from src/layers/4_generator/generators/__.ts rename to src/generator/generators/__.ts index 819c1bb48..0f9d13f95 100644 --- a/src/layers/4_generator/generators/__.ts +++ b/src/generator/generators/__.ts @@ -1,4 +1,4 @@ -import { capitalizeFirstLetter } from '../../../lib/prelude.js' +import { capitalizeFirstLetter } from '../../lib/prelude.js' import { defaultName } from '../config/defaults.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGenerator_ } from './_.js' diff --git a/src/layers/4_generator/generators/global.ts b/src/generator/generators/global.ts similarity index 98% rename from src/layers/4_generator/generators/global.ts rename to src/generator/generators/global.ts index ac658b732..67ce85bc8 100644 --- a/src/layers/4_generator/generators/global.ts +++ b/src/generator/generators/global.ts @@ -1,4 +1,4 @@ -import { Code } from '../../../lib/Code.js' +import { Code } from '../../lib/Code.js' import { identifiers } from '../helpers/identifiers.js' import { createModuleGenerator } from '../helpers/moduleGenerator.js' import { ModuleGeneratorData } from './Data.js' diff --git a/src/layers/4_generator/helpers/identifiers.ts b/src/generator/helpers/identifiers.ts similarity index 100% rename from src/layers/4_generator/helpers/identifiers.ts rename to src/generator/helpers/identifiers.ts diff --git a/src/layers/4_generator/helpers/moduleGenerator.ts b/src/generator/helpers/moduleGenerator.ts similarity index 100% rename from src/layers/4_generator/helpers/moduleGenerator.ts rename to src/generator/helpers/moduleGenerator.ts diff --git a/src/layers/4_generator/helpers/moduleGeneratorRunner.ts b/src/generator/helpers/moduleGeneratorRunner.ts similarity index 100% rename from src/layers/4_generator/helpers/moduleGeneratorRunner.ts rename to src/generator/helpers/moduleGeneratorRunner.ts diff --git a/src/layers/4_generator/helpers/render.ts b/src/generator/helpers/render.ts similarity index 95% rename from src/layers/4_generator/helpers/render.ts rename to src/generator/helpers/render.ts index 34df74c84..d79bc1dc4 100644 --- a/src/layers/4_generator/helpers/render.ts +++ b/src/generator/helpers/render.ts @@ -1,7 +1,7 @@ -import { Code } from '../../../lib/Code.js' -import { Grafaid } from '../../../lib/grafaid/__.js' -import { getNodeDisplayName } from '../../../lib/grafaid/graphql.js' -import { borderThickFullWidth, borderThinFullWidth, centerTo } from '../../../lib/text.js' +import { Code } from '../../lib/Code.js' +import { Grafaid } from '../../lib/grafaid/__.js' +import { getNodeDisplayName } from '../../lib/grafaid/graphql.js' +import { borderThickFullWidth, borderThinFullWidth, centerTo } from '../../lib/text.js' import type { Config } from '../config/config.js' export const title1 = (title: string, subTitle?: string) => { diff --git a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts index 2be0edff5..b3162b0c8 100644 --- a/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts +++ b/src/layers/1_Schema/Hybrid/types/Scalar/Scalar.ts @@ -1,4 +1,4 @@ -import type { GlobalRegistry } from '../../../../4_generator/GlobalRegistry.js' +import type { GlobalRegistry } from '../../../../GlobalRegistry.js' import type { Codec, Mapper } from './codec.js' import { JavaScriptScalarCodecs } from './nativeScalarCodecs.js' diff --git a/src/layers/3_InferResult/Alias.ts b/src/layers/3_InferResult/Alias.ts index aadcb5b79..c637e0fa8 100644 --- a/src/layers/3_InferResult/Alias.ts +++ b/src/layers/3_InferResult/Alias.ts @@ -1,7 +1,7 @@ +import type { Schema } from '../../generator/generators/Schema.js' import type { mergeObjectArray, ValuesOrEmptyObject } from '../../lib/prelude.js' import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Field } from './Field.js' // dprint-ignore diff --git a/src/layers/3_InferResult/Field.ts b/src/layers/3_InferResult/Field.ts index 69ec00d14..619e3134d 100644 --- a/src/layers/3_InferResult/Field.ts +++ b/src/layers/3_InferResult/Field.ts @@ -1,8 +1,8 @@ import type { Simplify } from 'type-fest' +import type { Schema } from '../../generator/generators/Schema.js' import type { TSErrorDescriptive } from '../../lib/ts-error.js' import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Interface } from './Interface.js' import type { Object } from './Object.js' import type { Union } from './Union.js' diff --git a/src/layers/3_InferResult/InlineFragment.ts b/src/layers/3_InferResult/InlineFragment.ts index 56647e38e..957b81955 100644 --- a/src/layers/3_InferResult/InlineFragment.ts +++ b/src/layers/3_InferResult/InlineFragment.ts @@ -1,7 +1,7 @@ +import type { Schema } from '../../generator/generators/Schema.js' import { type GetKeyOr } from '../../lib/prelude.js' import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Object } from './Object.js' // dprint-ignore diff --git a/src/layers/3_InferResult/Interface.ts b/src/layers/3_InferResult/Interface.ts index 36a4c9c91..85d6695ef 100644 --- a/src/layers/3_InferResult/Interface.ts +++ b/src/layers/3_InferResult/Interface.ts @@ -1,5 +1,5 @@ +import type { Schema } from '../../generator/generators/Schema.js' import type { SchemaKit } from '../1_Schema/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { InlineFragmentTypeConditional } from './InlineFragment.js' // dprint-ignore diff --git a/src/layers/3_InferResult/Object.ts b/src/layers/3_InferResult/Object.ts index 20f25270e..203f4aee0 100644 --- a/src/layers/3_InferResult/Object.ts +++ b/src/layers/3_InferResult/Object.ts @@ -1,9 +1,9 @@ import type { Simplify } from 'type-fest' +import type { Schema } from '../../generator/generators/Schema.js' import { type StringKeyof } from '../../lib/prelude.js' import type { TSErrorDescriptive } from '../../lib/ts-error.js' import type { SchemaKit } from '../1_Schema/__.js' import type { Select } from '../2_Select/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Alias } from './Alias.js' import type { Field } from './Field.js' import type { ScalarsWildcard } from './ScalarsWildcard.js' diff --git a/src/layers/3_InferResult/ScalarsWildcard.ts b/src/layers/3_InferResult/ScalarsWildcard.ts index e78f25ede..e78e0d8d4 100644 --- a/src/layers/3_InferResult/ScalarsWildcard.ts +++ b/src/layers/3_InferResult/ScalarsWildcard.ts @@ -1,5 +1,5 @@ +import type { Schema } from '../../generator/generators/Schema.js' import type { SchemaKit } from '../1_Schema/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Field } from './Field.js' export type ScalarsWildcard< diff --git a/src/layers/3_InferResult/Union.ts b/src/layers/3_InferResult/Union.ts index 383a6e8fb..fd6ca2b98 100644 --- a/src/layers/3_InferResult/Union.ts +++ b/src/layers/3_InferResult/Union.ts @@ -1,5 +1,5 @@ +import type { Schema } from '../../generator/generators/Schema.js' import type { SchemaKit } from '../1_Schema/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { InlineFragmentTypeConditional } from './InlineFragment.js' // dprint-ignore diff --git a/src/layers/3_InferResult/root.ts b/src/layers/3_InferResult/root.ts index 69bc6ddcc..1cc7ffd28 100644 --- a/src/layers/3_InferResult/root.ts +++ b/src/layers/3_InferResult/root.ts @@ -1,6 +1,6 @@ +import type { Schema } from '../../generator/generators/Schema.js' import { type ExcludeNull } from '../../lib/prelude.js' import type { SchemaKit } from '../1_Schema/__.js' -import type { Schema } from '../4_generator/generators/Schema.js' import type { Object } from './Object.js' export type RootViaObject< diff --git a/src/layers/5_select/select.ts b/src/layers/5_select/select.ts index 8c85e6996..eb62ce8fe 100644 --- a/src/layers/5_select/select.ts +++ b/src/layers/5_select/select.ts @@ -1,5 +1,5 @@ import { identityProxy } from '../../lib/prelude.js' -import type { GlobalRegistry } from '../4_generator/GlobalRegistry.js' +import type { GlobalRegistry } from '../GlobalRegistry.js' // dprint-ignore type Create = <$Name extends GlobalRegistry.ClientNames>(name: $Name) => diff --git a/src/layers/6_client/Settings/Config.ts b/src/layers/6_client/Settings/Config.ts index 08b43a68b..4aa95d474 100644 --- a/src/layers/6_client/Settings/Config.ts +++ b/src/layers/6_client/Settings/Config.ts @@ -1,8 +1,8 @@ import type { GraphQLSchema } from 'graphql' import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { RequireProperties } from '../../../lib/prelude.js' -import type { GlobalRegistry } from '../../4_generator/GlobalRegistry.js' import type { TransportHttp, TransportMemory } from '../../5_request/types.js' +import type { GlobalRegistry } from '../../GlobalRegistry.js' import type { Extension } from '../extension/extension.js' import type { TransportHttpInput } from '../transportHttp/request.js' import type { InputStatic } from './Input.js' diff --git a/src/layers/6_client/Settings/Input.ts b/src/layers/6_client/Settings/Input.ts index 067d80f18..287c5ee68 100644 --- a/src/layers/6_client/Settings/Input.ts +++ b/src/layers/6_client/Settings/Input.ts @@ -1,6 +1,6 @@ import type { GraphQLSchema } from 'graphql' import type { SchemaDrivenDataMap } from '../../../extensions/CustomScalars/schemaDrivenDataMap/__.js' -import type { GlobalRegistry } from '../../4_generator/GlobalRegistry.js' +import type { GlobalRegistry } from '../../GlobalRegistry.js' import type { WithInput } from './inputIncrementable/inputIncrementable.js' export type URLInput = URL | string diff --git a/src/layers/6_client/Settings/InputToConfig.ts b/src/layers/6_client/Settings/InputToConfig.ts index a7ffaee39..a972c6469 100644 --- a/src/layers/6_client/Settings/InputToConfig.ts +++ b/src/layers/6_client/Settings/InputToConfig.ts @@ -1,7 +1,7 @@ import type { IsUnknown } from 'type-fest' import type { ConfigManager } from '../../../lib/config-manager/__.js' -import type { GlobalRegistry } from '../../4_generator/GlobalRegistry.js' import { Transport } from '../../5_request/types.js' +import type { GlobalRegistry } from '../../GlobalRegistry.js' import { defaultMethodMode } from '../transportHttp/request.js' import { outputConfigDefault, type TransportConfigHttp, type TransportConfigMemory } from './Config.js' import type { InputOutputEnvelopeLonghand, InputStatic, URLInput } from './Input.js' diff --git a/src/layers/6_client/Settings/inputIncrementable/inputIncrementable.ts b/src/layers/6_client/Settings/inputIncrementable/inputIncrementable.ts index af4e5872a..a3460a294 100644 --- a/src/layers/6_client/Settings/inputIncrementable/inputIncrementable.ts +++ b/src/layers/6_client/Settings/inputIncrementable/inputIncrementable.ts @@ -1,5 +1,5 @@ -import type { GlobalRegistry } from '../../../4_generator/GlobalRegistry.js' import type { Transport, TransportMemory } from '../../../5_request/types.js' +import type { GlobalRegistry } from '../../../GlobalRegistry.js' import type { TransportHttpInput } from '../../transportHttp/request.js' import type { Config } from '../Config.js' import type { NormalizeInput } from '../InputToConfig.js' diff --git a/src/layers/6_client/extension/extension.ts b/src/layers/6_client/extension/extension.ts index 4c866db39..a6ff77cc9 100644 --- a/src/layers/6_client/extension/extension.ts +++ b/src/layers/6_client/extension/extension.ts @@ -4,8 +4,8 @@ import type { AssertConstraint } from '../../../lib/prelude.js' import type { TypeFunction } from '../../../lib/type-function/__.js' import type { Fn } from '../../../lib/type-function/TypeFunction.js' import type { Select } from '../../2_Select/__.js' -import type { GlobalRegistry } from '../../4_generator/GlobalRegistry.js' import type { RequestCore } from '../../5_request/__.js' +import type { GlobalRegistry } from '../../GlobalRegistry.js' import type { Client } from '../client.js' import type { GraffleExecutionResultEnvelope } from '../handleOutput.js' import type { Config } from '../Settings/Config.js' diff --git a/src/layers/6_client/handleOutput.ts b/src/layers/6_client/handleOutput.ts index daf16eb93..556ec5fae 100644 --- a/src/layers/6_client/handleOutput.ts +++ b/src/layers/6_client/handleOutput.ts @@ -9,8 +9,8 @@ import { type GetOrNever, type Values, } from '../../lib/prelude.js' -import type { GlobalRegistry } from '../4_generator/GlobalRegistry.js' import type { TransportHttp } from '../5_request/types.js' +import type { GlobalRegistry } from '../GlobalRegistry.js' import type { RunTypeHookOnRequestResult } from './extension/extension.js' import type { State } from './fluent.js' import { diff --git a/src/layers/6_client/prefilled.ts b/src/layers/6_client/prefilled.ts index 17f028b55..41d7e1758 100644 --- a/src/layers/6_client/prefilled.ts +++ b/src/layers/6_client/prefilled.ts @@ -1,7 +1,7 @@ import type { HasRequiredKeys } from 'type-fest' import type { SchemaDrivenDataMap } from '../../extensions/CustomScalars/schemaDrivenDataMap/__.js' import type { Exact } from '../../lib/prelude.js' -import type { GlobalRegistry } from '../4_generator/GlobalRegistry.js' +import type { GlobalRegistry } from '../GlobalRegistry.js' import { type Client, create } from './client.js' import type { InputBase } from './Settings/Input.js' import type { NormalizeInput } from './Settings/InputToConfig.js' diff --git a/src/layers/6_client/requestMethods/document.ts b/src/layers/6_client/requestMethods/document.ts index 588c366f3..99c058426 100644 --- a/src/layers/6_client/requestMethods/document.ts +++ b/src/layers/6_client/requestMethods/document.ts @@ -1,8 +1,8 @@ import type { UnionToTuple } from 'type-fest' +import type { Schema } from '../../../generator/generators/Schema.js' import type { IsTupleMultiple } from '../../../lib/prelude.js' import type { Select } from '../../2_Select/__.js' import type { InferResult } from '../../3_InferResult/__.js' -import type { Schema } from '../../4_generator/generators/Schema.js' import { type HandleOutput } from '../handleOutput.js' import type { Config } from '../Settings/Config.js' diff --git a/src/layers/6_client/requestMethods/requestMethods.ts b/src/layers/6_client/requestMethods/requestMethods.ts index 3a4f2e81c..d547d8357 100644 --- a/src/layers/6_client/requestMethods/requestMethods.ts +++ b/src/layers/6_client/requestMethods/requestMethods.ts @@ -3,8 +3,8 @@ import type { Fluent } from '../../../lib/fluent/__.js' import type { Grafaid } from '../../../lib/grafaid/__.js' import { isSymbol } from '../../../lib/prelude.js' import { Select } from '../../2_Select/__.js' -import type { GlobalRegistry } from '../../4_generator/GlobalRegistry.js' import { RequestCore } from '../../5_request/__.js' +import type { GlobalRegistry } from '../../GlobalRegistry.js' import { type ClientContext, defineTerminus, type State } from '../fluent.js' import { handleOutput } from '../handleOutput.js' import type { Config } from '../Settings/Config.js' diff --git a/src/layers/4_generator/GlobalRegistry.ts b/src/layers/GlobalRegistry.ts similarity index 89% rename from src/layers/4_generator/GlobalRegistry.ts rename to src/layers/GlobalRegistry.ts index daab2309a..de26c189d 100644 --- a/src/layers/4_generator/GlobalRegistry.ts +++ b/src/layers/GlobalRegistry.ts @@ -1,9 +1,9 @@ import type { IsNever } from 'type-fest' -import type { TypeFunction } from '../../entrypoints/utilities-for-generated.js' -import type { ConfigManager } from '../../lib/config-manager/__.js' -import type { Values } from '../../lib/prelude.js' -import type { TSErrorDescriptive } from '../../lib/ts-error.js' -import type { Schema } from './generators/Schema.js' +import type { TypeFunction } from '../entrypoints/utilities-for-generated.js' +import type { Schema } from '../generator/generators/Schema.js' +import type { ConfigManager } from '../lib/config-manager/__.js' +import type { Values } from '../lib/prelude.js' +import type { TSErrorDescriptive } from '../lib/ts-error.js' declare global { export namespace GraffleGlobal { diff --git a/tests/_/schemas/generate.ts b/tests/_/schemas/generate.ts index 8b7a348a0..64e212814 100644 --- a/tests/_/schemas/generate.ts +++ b/tests/_/schemas/generate.ts @@ -1,5 +1,5 @@ import { join } from 'node:path' -import { Generator } from '../../../src/layers/4_generator/__.js' +import { Generator } from '../../../src/generator/__.js' import { Grafaid } from '../../../src/lib/grafaid/__.js' const generate = async ( diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts index cfaee08dd..9d91c8703 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts @@ -306,6 +306,18 @@ export namespace Schema { // // + // todo generate code like this: + export interface DateInterface2 extends $.Interface { + name: 'DateInterface1' + implementors: [DateObject1] + fields: { + date1: { + inlineType: [0] + namedType: $Scalar.Date + } + } + } + export type DateInterface1 = $.Interface<'DateInterface1', { date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> }, [DateObject1]> From d2f1f7c41087ce4b00c6f14867126a74cc854374 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 19 Oct 2024 09:45:44 -0400 Subject: [PATCH 2/4] test --- .../generator/__snapshots__/generate.test.ts.snap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/generator/generator/__snapshots__/generate.test.ts.snap b/src/generator/generator/__snapshots__/generate.test.ts.snap index 5660edf11..f47b8d54c 100644 --- a/src/generator/generator/__snapshots__/generate.test.ts.snap +++ b/src/generator/generator/__snapshots__/generate.test.ts.snap @@ -1220,6 +1220,18 @@ export namespace Schema { // // + // todo generate code like this: + export interface DateInterface2 extends $.Interface { + name: 'DateInterface1' + implementors: [DateObject1] + fields: { + date1: { + inlineType: [0] + namedType: $Scalar.Date + } + } + } + export type DateInterface1 = $.Interface<'DateInterface1', { date1: $.Field<'date1', $.Output.Nullable<$Scalar.Date>, null> }, [DateObject1]> From 22c2054c1f0c33b127920d368cc32d82f0428503 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 19 Oct 2024 09:47:34 -0400 Subject: [PATCH 3/4] fix bin path --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c4fbbeb28..962dc1a27 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "packageManager": "pnpm@9.12.2", "type": "module", "bin": { - "graffle": "./build/cli/generate.js" + "graffle": "./build/generator/cli/generate.js" }, "exports": { ".": { From aa656283106fbd97a3b39d77258c94d6743f902a Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Sat, 19 Oct 2024 09:48:49 -0400 Subject: [PATCH 4/4] chmod path --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 962dc1a27..831bd41db 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "check:publint": "publint run --strict", "prepublishOnly": "pnpm build", "build:docs": "doctoc README.md --notitle && dprint fmt README.md", - "build": "pnpm clean && pnpm tsc --project tsconfig.build.json && chmod +x ./build/cli/generate.js", + "build": "pnpm clean && pnpm tsc --project tsconfig.build.json && chmod +x ./build/generator/cli/generate.js", "clean": "tsc --build --clean && rm -rf build", "test:unit": "vitest --exclude tests/examples", "test:examples": "vitest --config vitest.examples.config.ts --dir tests/examples",