@conduit-client/generator-ts 3.16.0 → 3.17.1

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.
@@ -1,5 +1,6 @@
1
1
  import { type NamedService, type ServiceDescriptor } from '@conduit-client/utils';
2
2
  import { Code } from './code';
3
+ import type { ImportableTypeReference, ImportableValueReference } from './code';
3
4
  /**
4
5
  * Service that builds TypeScript source files.
5
6
  */
@@ -66,6 +67,19 @@ export declare class File {
66
67
  * @returns this
67
68
  */
68
69
  pushTo(block: Symbol, ...chunks: any[]): this;
70
+ private reExports;
71
+ /** Registers a value re-export: `export { symbol [as alias] } from "…";` */
72
+ reExport(ref: ImportableValueReference & {
73
+ filename: string;
74
+ exportedSymbol: string;
75
+ }, alias?: string): void;
76
+ /** Registers a type re-export: `export type { symbol [as alias] } from "…";` */
77
+ reExportType(ref: ImportableTypeReference & {
78
+ filename: string;
79
+ exportedSymbol: string;
80
+ }, alias?: string): void;
81
+ /** Registers a wildcard type re-export: `export type * from "…";` */
82
+ reExportTypeAll(targetFilename: string): void;
69
83
  /**
70
84
  * Returns the code for this File, with ImportableReferences resolved.
71
85
  *
@@ -96,6 +96,11 @@ export declare abstract class CommandGenerator {
96
96
  * Override (e.g. GraphQL) when the constructor has a fixed param list with no rest.
97
97
  */
98
98
  protected getBuildCommandClassConstructorParams(): Code;
99
+ /**
100
+ * Additional generic type args for the Generated declare class that surface
101
+ * public constructor fields (config, typeRegistry, etc.) on InstanceType<>.
102
+ */
103
+ protected getBuildCommandClassConstructorFieldGenerics(): Code;
99
104
  protected buildCommandTypeGenerics(): Code;
100
105
  protected buildExtraServices(): Code | undefined;
101
106
  protected generateAfterRequestHooks(): Code;
@@ -7,6 +7,7 @@ import { WireAdapterBindingGenerator } from './wire-binding-generator';
7
7
  import { GraphQLImperativeAdapterBindingGenerator } from './graphql-imperative-binding-generator';
8
8
  import { GraphQLWireAdapterBindingGenerator } from './graphql-wire-binding-generator';
9
9
  import { GraphQLMutationAdapterBindingGenerator } from './graphql-mutation-binding-generator';
10
+ import type { File, ImportableValueReference } from '../files';
10
11
  import type { ICommandModel, ServiceDependency } from '../model/base-command-model';
11
12
  import type { NamedTypeRegistryGeneratorService, TypeRegistryGenerator } from '../normalization/type-registry-generator';
12
13
  import type { NamedGraphQLTypeRegistryGeneratorService } from '../normalization/graphql-type-registry-generator';
@@ -41,7 +42,10 @@ export declare class BindingsGenerator {
41
42
  protected typeInvalidationDefinitionSymbol: symbol;
42
43
  protected rootTypesInstantiationSymbol: symbol;
43
44
  protected exportsTypeMembersSymbol: symbol;
44
- protected exportsAssignmentsSymbol: symbol;
45
+ protected initGeneratedBindingsExtraParamsSymbol: symbol;
46
+ protected returnStatementSymbol: symbol;
47
+ protected wrapperDeclarationsSymbol: symbol;
48
+ protected wrapperAssignmentsSymbol: symbol;
45
49
  /**
46
50
  * Template for generating the binding structure in the output file.
47
51
  * Includes placeholders for adapter declarations, service requirements, and adapter invocations.
@@ -55,13 +59,67 @@ export declare class BindingsGenerator {
55
59
  * @returns {Code[]} An array of code blocks forming the template for the binding output file.
56
60
  */
57
61
  get coreTemplate(): (symbol | Code)[];
58
- get wrapperTemplate(): Code[];
62
+ get wrapperTemplate(): (symbol | Code)[];
59
63
  protected get serviceDependencies(): ServiceDependency[];
60
64
  /**
61
65
  * Builds the binding file, generating declarations, requirements, and invocations for each command model.
62
66
  * This method coordinates with individual binding generators to compile the necessary elements into a single file.
63
67
  */
64
68
  build(): void;
69
+ /**
70
+ * Emits re-export statements from bindings-core so that custom bindings modules
71
+ * can import generated internals from a single stable entry point.
72
+ */
73
+ protected buildReExports(coreFile: File, refs: {
74
+ typeRegistryRef?: ImportableValueReference & {
75
+ filename: string;
76
+ exportedSymbol: string;
77
+ };
78
+ graphqlTypeRegistryRef?: ImportableValueReference & {
79
+ filename: string;
80
+ exportedSymbol: string;
81
+ };
82
+ }): void;
83
+ /**
84
+ * Re-exports per-command symbols: `buildCommandClass` (aliased to `build<Capitalized>CommandClass`),
85
+ * `CONFIG_SCHEMA` (aliased to `<UPPER>_CONFIG_SCHEMA`), and the `Config` type
86
+ * (aliased to `<Capitalized>Config`).
87
+ *
88
+ * The CONFIG_SCHEMA alias uses a simple uppercase of the commandName (e.g. `getItemsByIds`
89
+ * becomes `GETITEMSBYIDS_CONFIG_SCHEMA`) to avoid ambiguity from word-boundary heuristics.
90
+ */
91
+ protected buildCommandReExports(coreFile: File): void;
92
+ /**
93
+ * Re-exports the `TypeRegistry` (REST) and/or `GraphQLTypeRegistry` (GraphQL) classes
94
+ * so custom bindings can construct or extend them.
95
+ */
96
+ protected buildTypeRegistryReExports(coreFile: File, refs: {
97
+ typeRegistryRef?: ImportableValueReference & {
98
+ filename: string;
99
+ exportedSymbol: string;
100
+ };
101
+ graphqlTypeRegistryRef?: ImportableValueReference & {
102
+ filename: string;
103
+ exportedSymbol: string;
104
+ };
105
+ }): void;
106
+ /**
107
+ * Re-exports individual generated type repository classes (e.g. `RecordRepresentationRepository`)
108
+ * so custom bindings can extend or reference them without importing from internal paths.
109
+ *
110
+ * If both REST and GraphQL registries produce a repository with the same exported symbol,
111
+ * the GraphQL version is aliased with a `GraphQL_` prefix to avoid collisions.
112
+ */
113
+ protected buildTypeRepositoryReExports(coreFile: File): void;
114
+ /**
115
+ * Re-exports all generated entity types so custom bindings can reference
116
+ * domain models (e.g. `api_Item`) without importing from internal paths.
117
+ *
118
+ * The barrel `types/index.ts` is built incrementally by TypeDefinitionService
119
+ * as types are generated; we just re-export it from bindings-core.
120
+ * GraphQL-only specs produce no REST types so the barrel is never created.
121
+ */
122
+ protected buildEntityTypeReExports(coreFile: File): void;
65
123
  buildTypeInvalidation(typesWithNormalization: TypeRegistryGenerator['invalidatableTypes']): {
66
124
  definitions: Code[];
67
125
  declarations: Code[];
@@ -4,7 +4,7 @@ import type { NamedFileService, File, ImportableValueReference, ImportableRefere
4
4
  import type { NamedService } from '@conduit-client/utils';
5
5
  import type { GraphQLSchemaModel } from '../model/graphql-schema-model';
6
6
  import type { GraphQLObjectType } from './graphql-type-generator';
7
- type GraphQLTypeRepositoryReference = {
7
+ export type GraphQLTypeRepositoryReference = {
8
8
  propertyName: string;
9
9
  typeClassRef: ImportableValueReference;
10
10
  typeName: string;
@@ -16,6 +16,7 @@ type Options = {
16
16
  export type IGraphQLTypeRegistryGeneratorService = {
17
17
  build(): ImportableValueReference;
18
18
  buildGraphQLType(options: Options): GraphQLTypeRepositoryReference;
19
+ readonly registeredTypes: ReadonlyMap<string, GraphQLTypeRepositoryReference>;
19
20
  };
20
21
  export type NamedGraphQLTypeRegistryGeneratorService<Name extends string = 'graphqlTypeRegistryGenerator'> = NamedService<Name, IGraphQLTypeRegistryGeneratorService>;
21
22
  export declare const NAMED_CACHE_CONTROLLER_SERVICE: ImportableReference;
@@ -35,6 +36,7 @@ export declare class GraphQLTypeRegistryGenerator implements IGraphQLTypeRegistr
35
36
  protected typeInstantiationsSymbol: symbol;
36
37
  protected typeGettersSymbol: symbol;
37
38
  cache: Map<string, GraphQLTypeRepositoryReference>;
39
+ get registeredTypes(): ReadonlyMap<string, GraphQLTypeRepositoryReference>;
38
40
  private get file();
39
41
  private buildFile;
40
42
  get template(): (symbol | import("..").Code)[];
@@ -6,7 +6,7 @@ import type { INormalizedTypeGenerator } from './normalized-type-generator';
6
6
  import type { NamedService } from '@conduit-client/utils';
7
7
  import type { File, ImportableValueReference, NamedFileService } from '../files';
8
8
  import type { NamedNormalizeGeneratorService } from './normalize-code-gen/normalize-generator-service';
9
- type TypeRepositoryReference = {
9
+ export type TypeRepositoryReference = {
10
10
  propertyName: string;
11
11
  typeClassRef: ImportableValueReference;
12
12
  };
@@ -20,6 +20,7 @@ export type ITypeRegistryGeneratorService = {
20
20
  build(): ImportableValueReference;
21
21
  buildType(type: Type, options: Options): TypeRepositoryReference;
22
22
  invalidatableTypes: TypeRepositoryReference[];
23
+ readonly registeredTypes: ReadonlyMap<string, TypeRepositoryReference>;
23
24
  };
24
25
  export type NamedTypeRegistryGeneratorService<Name extends string = 'typeRegistryGenerator'> = NamedService<Name, ITypeRegistryGeneratorService>;
25
26
  /**
@@ -40,6 +41,7 @@ export declare class TypeRegistryGenerator implements ITypeRegistryGeneratorServ
40
41
  * after all operations precessing is complete.
41
42
  */
42
43
  invalidatableTypes: TypeRepositoryReference[];
44
+ get registeredTypes(): ReadonlyMap<string, TypeRepositoryReference>;
43
45
  private get file();
44
46
  private buildFile;
45
47
  get template(): (symbol | Code)[];
@@ -9,6 +9,7 @@ export type TypeDefinitionForOptions = {
9
9
  };
10
10
  export type ITypeDefinitionService = {
11
11
  build(type: Type | undefined): Code;
12
+ readonly hasTypes: boolean;
12
13
  };
13
14
  export type NamedTypeDefinitionService = NamedService<'typeDefinition', ITypeDefinitionService>;
14
15
  export declare class TypeDefinitionService implements ITypeDefinitionService {
@@ -16,6 +17,7 @@ export declare class TypeDefinitionService implements ITypeDefinitionService {
16
17
  private fileFor;
17
18
  constructor(services: NamedAPIService & NamedFileService, fileFor?: (typename: string) => string);
18
19
  cache: Map<string, ImportableReference>;
20
+ get hasTypes(): boolean;
19
21
  build(type: Type | undefined, useReferences?: boolean): Code;
20
22
  buildTypeCode(t: Type, options: TypeDefinitionForOptions): Code;
21
23
  buildReferenceCode(refType: RefType, options: TypeDefinitionForOptions): Code;
@@ -32,4 +34,6 @@ export declare function typeDefinitions(services: NamedAPIService & NamedFileSer
32
34
  fileFor?: (typename: string) => string;
33
35
  }): TypeDefinitionService;
34
36
  export declare const FILE_PER_TYPE: (typename: string) => string;
37
+ export declare const TYPES_SINGLE_FILE_PATH = "types/types.ts";
35
38
  export declare const SINGLE_FILE: (_: string) => string;
39
+ export declare const TYPES_INDEX_PATH = "types/index.ts";