From 9e5a0adb98eba656d4fcc0b34d04cb7658b84051 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Mon, 21 Oct 2024 11:35:10 -0400 Subject: [PATCH] refactor: schema standard types --- src/entrypoints/_Scalars.ts | 2 +- .../generator-helpers/standardScalarTypes.ts | 2 +- src/entrypoints/utilities-for-generated.ts | 2 +- .../tests/fixture/graffle.config.ts | 2 +- .../tests/fixture/graffle/modules/Scalar.ts | 2 +- .../tests/fixture/graffle/modules/Schema.ts | 4 +-- src/generator/generators/Schema.ts | 2 +- src/layers/3_InferResult/Object.ts | 2 +- src/layers/3_InferResult/root.ts | 2 +- src/types/Schema/StandardTypes/_.ts | 2 ++ src/types/Schema/StandardTypes/__.ts | 1 + .../{typeTypes.ts => StandardTypes/object.ts} | 12 ++++----- .../scalar.ts} | 19 ++++++++++++-- src/types/Schema/_.ts | 26 +++++++++---------- src/types/Schema/__.ts | 22 ++++++++-------- src/types/Schema/directives/Include.ts | 2 +- src/types/Schema/directives/Skip.ts | 2 +- src/types/Schema/helpers.ts | 6 ++--- src/types/Schema/{types => nodes}/Args.ts | 0 src/types/Schema/{types => nodes}/Enum.ts | 0 .../Schema/{types => nodes}/InputField.ts | 0 .../Schema/{types => nodes}/InputObject.ts | 0 .../Schema/{types => nodes}/Interface.ts | 0 src/types/Schema/{types => nodes}/List.ts | 0 src/types/Schema/{types => nodes}/Nullable.ts | 0 .../Schema/{types => nodes}/OutputField.ts | 0 .../Schema/{types => nodes}/OutputObject.ts | 0 .../Schema/{types => nodes}/Scalar/Scalar.ts | 0 src/types/Schema/nodes/Scalar/_.ts | 4 +++ .../Schema/{types => nodes}/Scalar/codec.ts | 0 .../Schema/{types => nodes}/Scalar/create.ts | 0 .../Schema/{types => nodes}/Scalar/helpers.ts | 2 +- .../Scalar => nodes}/ScalarCodecless.ts | 0 src/types/Schema/{types => nodes}/Union.ts | 0 .../Schema/{types => nodes}/__typename.ts | 0 src/types/Schema/typeGroups.ts | 16 ++++++------ .../types/Scalar/JavaScriptScalarCodecs.ts | 16 ------------ src/types/Schema/types/Scalar/_.ts | 5 ---- tests/_/schemas/generate.ts | 2 +- .../kitchen-sink/graffle/modules/Scalar.ts | 2 +- .../kitchen-sink/graffle/modules/Schema.ts | 4 +-- .../mutation-only/graffle/modules/Scalar.ts | 2 +- .../mutation-only/graffle/modules/Schema.ts | 2 +- .../schemas/pokemon/graffle/modules/Scalar.ts | 2 +- .../schemas/pokemon/graffle/modules/Schema.ts | 4 +-- .../query-only/graffle/modules/Scalar.ts | 2 +- .../query-only/graffle/modules/Schema.ts | 2 +- 47 files changed, 89 insertions(+), 88 deletions(-) create mode 100644 src/types/Schema/StandardTypes/_.ts create mode 100644 src/types/Schema/StandardTypes/__.ts rename src/types/Schema/{typeTypes.ts => StandardTypes/object.ts} (55%) rename src/types/Schema/{types/Scalar/standardScalarTypes.ts => StandardTypes/scalar.ts} (51%) rename src/types/Schema/{types => nodes}/Args.ts (100%) rename src/types/Schema/{types => nodes}/Enum.ts (100%) rename src/types/Schema/{types => nodes}/InputField.ts (100%) rename src/types/Schema/{types => nodes}/InputObject.ts (100%) rename src/types/Schema/{types => nodes}/Interface.ts (100%) rename src/types/Schema/{types => nodes}/List.ts (100%) rename src/types/Schema/{types => nodes}/Nullable.ts (100%) rename src/types/Schema/{types => nodes}/OutputField.ts (100%) rename src/types/Schema/{types => nodes}/OutputObject.ts (100%) rename src/types/Schema/{types => nodes}/Scalar/Scalar.ts (100%) create mode 100644 src/types/Schema/nodes/Scalar/_.ts rename src/types/Schema/{types => nodes}/Scalar/codec.ts (100%) rename src/types/Schema/{types => nodes}/Scalar/create.ts (100%) rename src/types/Schema/{types => nodes}/Scalar/helpers.ts (96%) rename src/types/Schema/{types/Scalar => nodes}/ScalarCodecless.ts (100%) rename src/types/Schema/{types => nodes}/Union.ts (100%) rename src/types/Schema/{types => nodes}/__typename.ts (100%) delete mode 100644 src/types/Schema/types/Scalar/JavaScriptScalarCodecs.ts delete mode 100644 src/types/Schema/types/Scalar/_.ts diff --git a/src/entrypoints/_Scalars.ts b/src/entrypoints/_Scalars.ts index 48c084e8f..66dae546f 100644 --- a/src/entrypoints/_Scalars.ts +++ b/src/entrypoints/_Scalars.ts @@ -1 +1 @@ -export { create } from '../types/Schema/types/Scalar/_.js' +export { create } from '../types/Schema/nodes/Scalar/_.js' diff --git a/src/entrypoints/generator-helpers/standardScalarTypes.ts b/src/entrypoints/generator-helpers/standardScalarTypes.ts index 2107179ba..2b2d59a74 100644 --- a/src/entrypoints/generator-helpers/standardScalarTypes.ts +++ b/src/entrypoints/generator-helpers/standardScalarTypes.ts @@ -1 +1 @@ -export * from '../../types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../types/Schema/StandardTypes/scalar.js' diff --git a/src/entrypoints/utilities-for-generated.ts b/src/entrypoints/utilities-for-generated.ts index 09c9fb5ea..225c1d60a 100644 --- a/src/entrypoints/utilities-for-generated.ts +++ b/src/entrypoints/utilities-for-generated.ts @@ -12,5 +12,5 @@ export { type Exact, type ExactNonEmpty, type UnionExpanded } from '../lib/prelu export { TypeFunction } from '../lib/type-function/__.js' export { type GlobalRegistry } from '../types/GlobalRegistry/GlobalRegistry.js' export { Schema } from '../types/Schema/__.js' -export * from '../types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../types/Schema/StandardTypes/scalar.js' export { type SchemaDrivenDataMap } from '../types/SchemaDrivenDataMap/__.js' diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts index b8b1a83bb..5c90a6799 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle.config.ts @@ -12,7 +12,7 @@ export default Generator libraryPaths: { client: `../../../../entrypoints/client.ts`, schema: `../../../../entrypoints/schema.ts`, - scalars: `../../../../types/Schema/types/Scalar/standardScalarTypes.ts`, + scalars: `../../../../types/Schema/StandardTypes/scalar.ts`, utilitiesForGenerated: `../../../../entrypoints/utilities-for-generated.ts`, }, }) diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts index bc20fd6cb..0f3cd671c 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Scalar.ts @@ -1,6 +1,6 @@ import type * as $$Utilities from '../../../../../../entrypoints/utilities-for-generated.js' -export * from '../../../../../../types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../../../../../types/Schema/StandardTypes/scalar.js' // // diff --git a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts index 11c71e399..4a1ff7f26 100644 --- a/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts +++ b/src/extensions/SchemaErrors/tests/fixture/graffle/modules/Schema.ts @@ -20,12 +20,12 @@ export namespace Schema { // // - export type Mutation = $.ObjectMutation<{ + export type Mutation = $.StandardTypes.Mutation<{ id: $.Field<'id', $.Nullable<$Scalar.ID>, null> idNonNull: $.Field<'idNonNull', $Scalar.ID, null> }> - export type Query = $.ObjectQuery<{ + export type Query = $.StandardTypes.Query<{ InputObjectNested: $.Field< 'InputObjectNested', $.Nullable<$Scalar.ID>, diff --git a/src/generator/generators/Schema.ts b/src/generator/generators/Schema.ts index 0514173b4..6ff2b7400 100644 --- a/src/generator/generators/Schema.ts +++ b/src/generator/generators/Schema.ts @@ -240,7 +240,7 @@ const concreteRenderers = defineConcreteRenderers({ GraphQLObjectType: (config, node) => { const maybeRootTypeName = (Grafaid.Schema.RootTypeName as Record)[node.name] const type = maybeRootTypeName - ? `$.Object${maybeRootTypeName}<${renderOutputFields(config, node)}>` + ? `$.StandardTypes.${maybeRootTypeName}<${renderOutputFields(config, node)}>` : `$.OutputObject<${Code.string(node.name)}, ${renderOutputFields(config, node)}>` const doc = getDocumentation(config, node) const source = Code.export$(Code.type(node.name, type)) diff --git a/src/layers/3_InferResult/Object.ts b/src/layers/3_InferResult/Object.ts index 928f19b83..d038426ca 100644 --- a/src/layers/3_InferResult/Object.ts +++ b/src/layers/3_InferResult/Object.ts @@ -29,7 +29,7 @@ type SelectionNonSelectAlias<$SelectionSet , $Schema extends Schema, $SchemaNode // dprint-ignore export namespace Errors { - export type UnknownFieldName<$FieldName extends string, $Object extends Schema.RootType | Schema.OutputObject> = + export type UnknownFieldName<$FieldName extends string, $Object extends Schema.StandardTypes.RootType | Schema.OutputObject> = TSErrorDescriptive<'Object', `field "${$FieldName}" does not exist on object "${$Object['fields']['__typename']['type']['type']}"`> } diff --git a/src/layers/3_InferResult/root.ts b/src/layers/3_InferResult/root.ts index 16cc3af50..ee20cc94c 100644 --- a/src/layers/3_InferResult/root.ts +++ b/src/layers/3_InferResult/root.ts @@ -6,7 +6,7 @@ import type { Object } from './Object.js' export type RootViaObject< $SelectionSet, $Schema extends Schema, - $RootType extends Schema.RootType, + $RootType extends Schema.StandardTypes.RootType, > = Root< $SelectionSet, $Schema, diff --git a/src/types/Schema/StandardTypes/_.ts b/src/types/Schema/StandardTypes/_.ts new file mode 100644 index 000000000..3e47c5405 --- /dev/null +++ b/src/types/Schema/StandardTypes/_.ts @@ -0,0 +1,2 @@ +export * from './object.js' +export * from './scalar.js' diff --git a/src/types/Schema/StandardTypes/__.ts b/src/types/Schema/StandardTypes/__.ts new file mode 100644 index 000000000..0438380d0 --- /dev/null +++ b/src/types/Schema/StandardTypes/__.ts @@ -0,0 +1 @@ +export * as StandardTypes from './_.js' diff --git a/src/types/Schema/typeTypes.ts b/src/types/Schema/StandardTypes/object.ts similarity index 55% rename from src/types/Schema/typeTypes.ts rename to src/types/Schema/StandardTypes/object.ts index 47dde29b6..b8311bf9f 100644 --- a/src/types/Schema/typeTypes.ts +++ b/src/types/Schema/StandardTypes/object.ts @@ -1,16 +1,16 @@ -import type { Grafaid } from '../../lib/grafaid/__.js' -import type { OutputObject, SomeFields } from './_.js' +import type { Grafaid } from '../../../lib/grafaid/__.js' +import type { OutputObject, SomeFields } from '../_.js' -export interface ObjectQuery< +export interface Query< $Fields extends SomeFields = SomeFields, > extends OutputObject {} -export interface ObjectMutation< +export interface Mutation< $Fields extends SomeFields = SomeFields, > extends OutputObject {} -export interface ObjectSubscription< +export interface Subscription< $Fields extends SomeFields = SomeFields, > extends OutputObject {} -export type RootType = ObjectQuery | ObjectMutation | ObjectSubscription +export type RootType = Query | Mutation | Subscription diff --git a/src/types/Schema/types/Scalar/standardScalarTypes.ts b/src/types/Schema/StandardTypes/scalar.ts similarity index 51% rename from src/types/Schema/types/Scalar/standardScalarTypes.ts rename to src/types/Schema/StandardTypes/scalar.ts index 7558cbe76..8517a64cb 100644 --- a/src/types/Schema/types/Scalar/standardScalarTypes.ts +++ b/src/types/Schema/StandardTypes/scalar.ts @@ -1,5 +1,20 @@ -import { create } from './create.js' -import { JavaScriptScalarCodecs } from './JavaScriptScalarCodecs.js' +import { createCodec } from '../nodes/Scalar/codec.js' +import { create } from '../nodes/Scalar/create.js' + +export const JavaScriptScalarCodecs = { + String: createCodec({ + encode: (value: string) => value, + decode: (value: string) => value, + }), + Number: createCodec({ + encode: (value: number) => value, + decode: (value: number) => value, + }), + Boolean: createCodec({ + encode: (value: boolean) => value, + decode: (value: boolean) => value, + }), +} export const String = create(`String`, JavaScriptScalarCodecs.String) diff --git a/src/types/Schema/_.ts b/src/types/Schema/_.ts index 1640bef4a..4c3b35acd 100644 --- a/src/types/Schema/_.ts +++ b/src/types/Schema/_.ts @@ -1,17 +1,17 @@ export * as Directives from './Directive.js' export * from './helpers.js' export * from './Named/__.js' +export * from './nodes/__typename.js' +export * from './nodes/Args.js' +export * from './nodes/Enum.js' +export * from './nodes/InputField.js' +export * from './nodes/InputObject.js' +export * from './nodes/Interface.js' +export * from './nodes/List.js' +export * from './nodes/Nullable.js' +export * from './nodes/OutputField.js' +export { type OutputObject } from './nodes/OutputObject.js' +export * from './nodes/Scalar/Scalar.js' +export * from './nodes/Union.js' +export * from './StandardTypes/__.js' export * from './typeGroups.js' -export * from './types/__typename.js' -export * from './types/Args.js' -export * from './types/Enum.js' -export * from './types/InputField.js' -export * from './types/InputObject.js' -export * from './types/Interface.js' -export * from './types/List.js' -export * from './types/Nullable.js' -export * from './types/OutputField.js' -export { type OutputObject } from './types/OutputObject.js' -export * from './types/Scalar/Scalar.js' -export * from './types/Union.js' -export * from './typeTypes.js' diff --git a/src/types/Schema/__.ts b/src/types/Schema/__.ts index c5da239d9..c18135680 100644 --- a/src/types/Schema/__.ts +++ b/src/types/Schema/__.ts @@ -1,12 +1,12 @@ export * as Schema from './_.js' import type { GlobalRegistry } from '../GlobalRegistry/GlobalRegistry.js' -import type { Enum } from './types/Enum.js' -import type { Interface } from './types/Interface.js' -import type { OutputObject } from './types/OutputObject.js' -import type { Scalar } from './types/Scalar/Scalar.js' -import type { Union } from './types/Union.js' -import type { ObjectMutation, ObjectQuery, ObjectSubscription, RootType } from './typeTypes.js' +import type { Enum } from './nodes/Enum.js' +import type { Interface } from './nodes/Interface.js' +import type { OutputObject } from './nodes/OutputObject.js' +import type { Scalar } from './nodes/Scalar/Scalar.js' +import type { Union } from './nodes/Union.js' +import type { Mutation, Query, RootType, Subscription } from './StandardTypes/object.js' /** * A generic schema type. Any particular schema will be a subtype of this, with @@ -20,15 +20,15 @@ export interface Schema< RootTypesPresent: ('Query' | 'Mutation' | 'Subscription')[] RootUnion: RootType Root: { - Query: null | ObjectQuery - Mutation: null | ObjectMutation - Subscription: null | ObjectSubscription + Query: null | Query + Mutation: null | Mutation + Subscription: null | Subscription } allTypes: Record< string, | Enum - | ObjectQuery - | ObjectMutation + | Query + | Mutation | OutputObject | Union | Interface diff --git a/src/types/Schema/directives/Include.ts b/src/types/Schema/directives/Include.ts index 2b4205bd3..05585cb34 100644 --- a/src/types/Schema/directives/Include.ts +++ b/src/types/Schema/directives/Include.ts @@ -1,5 +1,5 @@ import type { Directive } from '../Directive.js' -import { Scalar } from '../types/Scalar/Scalar.js' +import { Scalar } from '../nodes/Scalar/Scalar.js' export const IncludeDirective: Directive = { name: `include`, diff --git a/src/types/Schema/directives/Skip.ts b/src/types/Schema/directives/Skip.ts index c3c4926bc..a40bcc397 100644 --- a/src/types/Schema/directives/Skip.ts +++ b/src/types/Schema/directives/Skip.ts @@ -1,5 +1,5 @@ import type { Directive } from '../Directive.js' -import { Scalar } from '../types/Scalar/Scalar.js' +import { Scalar } from '../nodes/Scalar/Scalar.js' export const SkipDirective: Directive = { name: `skip`, diff --git a/src/types/Schema/helpers.ts b/src/types/Schema/helpers.ts index 4a9a0e345..b06fa1bfe 100644 --- a/src/types/Schema/helpers.ts +++ b/src/types/Schema/helpers.ts @@ -1,8 +1,8 @@ import type { TSErrorDescriptive } from '../../lib/ts-error.js' +import type { __typename } from './nodes/__typename.js' +import type { List } from './nodes/List.js' +import type { Nullable } from './nodes/Nullable.js' import type { NamedTypes } from './typeGroups.js' -import type { __typename } from './types/__typename.js' -import type { List } from './types/List.js' -import type { Nullable } from './types/Nullable.js' // todo extends any because of infinite depth issue in generated schema types // dprint-ignore diff --git a/src/types/Schema/types/Args.ts b/src/types/Schema/nodes/Args.ts similarity index 100% rename from src/types/Schema/types/Args.ts rename to src/types/Schema/nodes/Args.ts diff --git a/src/types/Schema/types/Enum.ts b/src/types/Schema/nodes/Enum.ts similarity index 100% rename from src/types/Schema/types/Enum.ts rename to src/types/Schema/nodes/Enum.ts diff --git a/src/types/Schema/types/InputField.ts b/src/types/Schema/nodes/InputField.ts similarity index 100% rename from src/types/Schema/types/InputField.ts rename to src/types/Schema/nodes/InputField.ts diff --git a/src/types/Schema/types/InputObject.ts b/src/types/Schema/nodes/InputObject.ts similarity index 100% rename from src/types/Schema/types/InputObject.ts rename to src/types/Schema/nodes/InputObject.ts diff --git a/src/types/Schema/types/Interface.ts b/src/types/Schema/nodes/Interface.ts similarity index 100% rename from src/types/Schema/types/Interface.ts rename to src/types/Schema/nodes/Interface.ts diff --git a/src/types/Schema/types/List.ts b/src/types/Schema/nodes/List.ts similarity index 100% rename from src/types/Schema/types/List.ts rename to src/types/Schema/nodes/List.ts diff --git a/src/types/Schema/types/Nullable.ts b/src/types/Schema/nodes/Nullable.ts similarity index 100% rename from src/types/Schema/types/Nullable.ts rename to src/types/Schema/nodes/Nullable.ts diff --git a/src/types/Schema/types/OutputField.ts b/src/types/Schema/nodes/OutputField.ts similarity index 100% rename from src/types/Schema/types/OutputField.ts rename to src/types/Schema/nodes/OutputField.ts diff --git a/src/types/Schema/types/OutputObject.ts b/src/types/Schema/nodes/OutputObject.ts similarity index 100% rename from src/types/Schema/types/OutputObject.ts rename to src/types/Schema/nodes/OutputObject.ts diff --git a/src/types/Schema/types/Scalar/Scalar.ts b/src/types/Schema/nodes/Scalar/Scalar.ts similarity index 100% rename from src/types/Schema/types/Scalar/Scalar.ts rename to src/types/Schema/nodes/Scalar/Scalar.ts diff --git a/src/types/Schema/nodes/Scalar/_.ts b/src/types/Schema/nodes/Scalar/_.ts new file mode 100644 index 000000000..ca9a99e3e --- /dev/null +++ b/src/types/Schema/nodes/Scalar/_.ts @@ -0,0 +1,4 @@ +export * from '../../StandardTypes/scalar.js' +export * from '../ScalarCodecless.js' +export * from './create.js' +export * from './helpers.js' diff --git a/src/types/Schema/types/Scalar/codec.ts b/src/types/Schema/nodes/Scalar/codec.ts similarity index 100% rename from src/types/Schema/types/Scalar/codec.ts rename to src/types/Schema/nodes/Scalar/codec.ts diff --git a/src/types/Schema/types/Scalar/create.ts b/src/types/Schema/nodes/Scalar/create.ts similarity index 100% rename from src/types/Schema/types/Scalar/create.ts rename to src/types/Schema/nodes/Scalar/create.ts diff --git a/src/types/Schema/types/Scalar/helpers.ts b/src/types/Schema/nodes/Scalar/helpers.ts similarity index 96% rename from src/types/Schema/types/Scalar/helpers.ts rename to src/types/Schema/nodes/Scalar/helpers.ts index 91378ddae..40a4c694a 100644 --- a/src/types/Schema/types/Scalar/helpers.ts +++ b/src/types/Schema/nodes/Scalar/helpers.ts @@ -1,6 +1,6 @@ +import { String } from '../../StandardTypes/scalar.js' import type { Mapper } from './codec.js' import type { Scalar } from './Scalar.js' -import { String } from './standardScalarTypes.js' export type GetEncoded<$Scalar> = $Scalar extends Scalar ? $Encoded : never diff --git a/src/types/Schema/types/Scalar/ScalarCodecless.ts b/src/types/Schema/nodes/ScalarCodecless.ts similarity index 100% rename from src/types/Schema/types/Scalar/ScalarCodecless.ts rename to src/types/Schema/nodes/ScalarCodecless.ts diff --git a/src/types/Schema/types/Union.ts b/src/types/Schema/nodes/Union.ts similarity index 100% rename from src/types/Schema/types/Union.ts rename to src/types/Schema/nodes/Union.ts diff --git a/src/types/Schema/types/__typename.ts b/src/types/Schema/nodes/__typename.ts similarity index 100% rename from src/types/Schema/types/__typename.ts rename to src/types/Schema/nodes/__typename.ts diff --git a/src/types/Schema/typeGroups.ts b/src/types/Schema/typeGroups.ts index 8c38cce02..8062104df 100644 --- a/src/types/Schema/typeGroups.ts +++ b/src/types/Schema/typeGroups.ts @@ -1,12 +1,12 @@ import type { InputObject } from './_.js' -import type { __typename } from './types/__typename.js' -import type { Enum } from './types/Enum.js' -import type { Interface } from './types/Interface.js' -import type { List } from './types/List.js' -import type { Nullable } from './types/Nullable.js' -import type { OutputObject } from './types/OutputObject.js' -import type { Scalar } from './types/Scalar/Scalar.js' -import type { Union } from './types/Union.js' +import type { __typename } from './nodes/__typename.js' +import type { Enum } from './nodes/Enum.js' +import type { Interface } from './nodes/Interface.js' +import type { List } from './nodes/List.js' +import type { Nullable } from './nodes/Nullable.js' +import type { OutputObject } from './nodes/OutputObject.js' +import type { Scalar } from './nodes/Scalar/Scalar.js' +import type { Union } from './nodes/Union.js' export type NamedTypes = NamedInputTypes | NamedOutputTypes diff --git a/src/types/Schema/types/Scalar/JavaScriptScalarCodecs.ts b/src/types/Schema/types/Scalar/JavaScriptScalarCodecs.ts deleted file mode 100644 index 8ca3bfc68..000000000 --- a/src/types/Schema/types/Scalar/JavaScriptScalarCodecs.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { createCodec } from './codec.js' - -export const JavaScriptScalarCodecs = { - String: createCodec({ - encode: (value: string) => value, - decode: (value: string) => value, - }), - Number: createCodec({ - encode: (value: number) => value, - decode: (value: number) => value, - }), - Boolean: createCodec({ - encode: (value: boolean) => value, - decode: (value: boolean) => value, - }), -} diff --git a/src/types/Schema/types/Scalar/_.ts b/src/types/Schema/types/Scalar/_.ts deleted file mode 100644 index 5d5f789a7..000000000 --- a/src/types/Schema/types/Scalar/_.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './create.js' -export * from './helpers.js' -export * from './JavaScriptScalarCodecs.js' -export * from './ScalarCodecless.js' -export * from './standardScalarTypes.js' diff --git a/tests/_/schemas/generate.ts b/tests/_/schemas/generate.ts index 50dddaac9..96874cf2a 100644 --- a/tests/_/schemas/generate.ts +++ b/tests/_/schemas/generate.ts @@ -25,7 +25,7 @@ const generate = async ( libraryPaths: { client: `../../../src/entrypoints/client.ts`, schema: `../../../src/entrypoints/schema.ts`, - scalars: `../../../src/types/Schema/types/Scalar/standardScalarTypes.ts`, + scalars: `../../../src/types/Schema/StandardTypes/scalar.ts`, utilitiesForGenerated: `../../../src/entrypoints/utilities-for-generated.ts`, }, ...input.input, diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts index 22222541d..a2a35c315 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Scalar.ts @@ -1,6 +1,6 @@ import type * as $$Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -export * from '../../../../../../src/types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../../../../../src/types/Schema/StandardTypes/scalar.js' // // diff --git a/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts index cfb0e4f22..489914d2c 100644 --- a/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts +++ b/tests/_/schemas/kitchen-sink/graffle/modules/Schema.ts @@ -20,12 +20,12 @@ export namespace Schema { // // - export type Mutation = $.ObjectMutation<{ + export type Mutation = $.StandardTypes.Mutation<{ id: $.Field<'id', $.Nullable<$Scalar.ID>, null> idNonNull: $.Field<'idNonNull', $Scalar.ID, null> }> - export type Query = $.ObjectQuery<{ + export type Query = $.StandardTypes.Query<{ InputObjectNested: $.Field< 'InputObjectNested', $.Nullable<$Scalar.ID>, diff --git a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts index 16a4866b5..dc2e4caf1 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Scalar.ts @@ -1,3 +1,3 @@ import type * as $$Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -export * from '../../../../../../src/types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../../../../../src/types/Schema/StandardTypes/scalar.js' diff --git a/tests/_/schemas/mutation-only/graffle/modules/Schema.ts b/tests/_/schemas/mutation-only/graffle/modules/Schema.ts index 018f90b11..b8a8f3f0f 100644 --- a/tests/_/schemas/mutation-only/graffle/modules/Schema.ts +++ b/tests/_/schemas/mutation-only/graffle/modules/Schema.ts @@ -20,7 +20,7 @@ export namespace Schema { // // - export type Mutation = $.ObjectMutation<{ + export type Mutation = $.StandardTypes.Mutation<{ id: $.Field<'id', $.Nullable<$Scalar.ID>, null> idNonNull: $.Field<'idNonNull', $Scalar.ID, null> }> diff --git a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts index 16a4866b5..dc2e4caf1 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Scalar.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Scalar.ts @@ -1,3 +1,3 @@ import type * as $$Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -export * from '../../../../../../src/types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../../../../../src/types/Schema/StandardTypes/scalar.js' diff --git a/tests/_/schemas/pokemon/graffle/modules/Schema.ts b/tests/_/schemas/pokemon/graffle/modules/Schema.ts index 4d96dc146..4dd97e4bf 100644 --- a/tests/_/schemas/pokemon/graffle/modules/Schema.ts +++ b/tests/_/schemas/pokemon/graffle/modules/Schema.ts @@ -20,7 +20,7 @@ export namespace Schema { // // - export type Mutation = $.ObjectMutation<{ + export type Mutation = $.StandardTypes.Mutation<{ addPokemon: $.Field< 'addPokemon', $.Nullable, @@ -34,7 +34,7 @@ export namespace Schema { > }> - export type Query = $.ObjectQuery<{ + export type Query = $.StandardTypes.Query<{ battles: $.Field<'battles', $.List, null> beings: $.Field<'beings', $.List, null> pokemon: $.Field<'pokemon', $.Nullable<$.List>, null> diff --git a/tests/_/schemas/query-only/graffle/modules/Scalar.ts b/tests/_/schemas/query-only/graffle/modules/Scalar.ts index 16a4866b5..dc2e4caf1 100644 --- a/tests/_/schemas/query-only/graffle/modules/Scalar.ts +++ b/tests/_/schemas/query-only/graffle/modules/Scalar.ts @@ -1,3 +1,3 @@ import type * as $$Utilities from '../../../../../../src/entrypoints/utilities-for-generated.js' -export * from '../../../../../../src/types/Schema/types/Scalar/standardScalarTypes.js' +export * from '../../../../../../src/types/Schema/StandardTypes/scalar.js' diff --git a/tests/_/schemas/query-only/graffle/modules/Schema.ts b/tests/_/schemas/query-only/graffle/modules/Schema.ts index 181727f14..2cfff9e4c 100644 --- a/tests/_/schemas/query-only/graffle/modules/Schema.ts +++ b/tests/_/schemas/query-only/graffle/modules/Schema.ts @@ -20,7 +20,7 @@ export namespace Schema { // // - export type Query = $.ObjectQuery<{ + export type Query = $.StandardTypes.Query<{ id: $.Field<'id', $.Nullable<$Scalar.ID>, null> idNonNull: $.Field<'idNonNull', $Scalar.ID, null> }>