@conduit-client/generator-ts 3.17.3 → 3.19.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NamedService, type ServiceDescriptor } from '@conduit-client/utils';
|
|
2
2
|
import { Code } from './code';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ImportableReference } from './code';
|
|
4
4
|
/**
|
|
5
5
|
* Service that builds TypeScript source files.
|
|
6
6
|
*/
|
|
@@ -68,13 +68,8 @@ export declare class File {
|
|
|
68
68
|
*/
|
|
69
69
|
pushTo(block: Symbol, ...chunks: any[]): this;
|
|
70
70
|
private reExports;
|
|
71
|
-
/** Registers a
|
|
72
|
-
reExport(ref:
|
|
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 & {
|
|
71
|
+
/** Registers a re-export: `export { symbol [as alias] } from "…";` or `export type { … }` depending on `ref.isType`. */
|
|
72
|
+
reExport(ref: ImportableReference & {
|
|
78
73
|
filename: string;
|
|
79
74
|
exportedSymbol: string;
|
|
80
75
|
}, alias?: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Code, type NamedFileService } from '../files';
|
|
1
|
+
import { Code, type ImportableReference, type NamedFileService } from '../files';
|
|
2
2
|
import { type NamedTypeDefinitionService } from '../types';
|
|
3
3
|
import { ImperativeAdapterBindingGenerator } from './imperative-binding-generator';
|
|
4
4
|
import { ImperativeAdapterLegacyBindingGenerator } from './imperative-legacy-binding-generator';
|
|
@@ -7,15 +7,34 @@ 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';
|
|
11
10
|
import type { ICommandModel, ServiceDependency } from '../model/base-command-model';
|
|
12
11
|
import type { NamedTypeRegistryGeneratorService, TypeRegistryGenerator } from '../normalization/type-registry-generator';
|
|
13
12
|
import type { NamedGraphQLTypeRegistryGeneratorService } from '../normalization/graphql-type-registry-generator';
|
|
14
13
|
import type { Binding, NamedAPIService } from '@conduit-client/model/v1';
|
|
14
|
+
type FileExportRef = ImportableReference & {
|
|
15
|
+
filename: string;
|
|
16
|
+
exportedSymbol: string;
|
|
17
|
+
};
|
|
18
|
+
type TypeRegistryRefs = {
|
|
19
|
+
typeRegistryRef?: FileExportRef;
|
|
20
|
+
graphqlTypeRegistryRef?: FileExportRef;
|
|
21
|
+
};
|
|
15
22
|
export type IBindingsGenerator = {
|
|
16
23
|
build(): void;
|
|
17
24
|
};
|
|
18
25
|
export declare function defaultAdapterBindingsGeneratorFactory(services: NamedTypeDefinitionService, model: ICommandModel, binding: Binding): ImperativeAdapterBindingGenerator | ImperativeAdapterLegacyBindingGenerator | WireAdapterBindingGenerator | GraphQLImperativeAdapterBindingGenerator | GraphQLImperativeAdapterLegacyBindingGenerator | GraphQLWireAdapterBindingGenerator | GraphQLMutationAdapterBindingGenerator;
|
|
26
|
+
/**
|
|
27
|
+
* Controls which generated file a re-export is routed to.
|
|
28
|
+
*
|
|
29
|
+
* - `PUBLIC` — consumer-facing types surfaced through `bindings-public-types.ts`
|
|
30
|
+
* (wildcard-forwarded by both `bindings-core.ts` and `bindings.ts`).
|
|
31
|
+
* - `CUSTOM` — extension-author internals surfaced only through `bindings-core.ts`
|
|
32
|
+
* (e.g. command factories, type registries, repositories).
|
|
33
|
+
*/
|
|
34
|
+
export declare const enum ExportVisibility {
|
|
35
|
+
PUBLIC = "public",
|
|
36
|
+
CUSTOM = "custom"
|
|
37
|
+
}
|
|
19
38
|
/**
|
|
20
39
|
* Class responsible for generating binding files based on command models and service dependencies.
|
|
21
40
|
*
|
|
@@ -33,6 +52,7 @@ export declare class BindingsGenerator {
|
|
|
33
52
|
protected commandModels: ICommandModel[];
|
|
34
53
|
protected adapterBindingsGeneratorFactory: typeof defaultAdapterBindingsGeneratorFactory;
|
|
35
54
|
constructor(services: NamedAPIService & NamedFileService & NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedGraphQLTypeRegistryGeneratorService, commandModels: ICommandModel[], adapterBindingsGeneratorFactory?: typeof defaultAdapterBindingsGeneratorFactory);
|
|
55
|
+
private exportTargets;
|
|
36
56
|
protected adapterDeclarationSymbol: symbol;
|
|
37
57
|
protected bindingsServicesDeclarationSymbol: symbol;
|
|
38
58
|
protected serviceRequirementsSymbol: symbol;
|
|
@@ -46,6 +66,10 @@ export declare class BindingsGenerator {
|
|
|
46
66
|
protected returnStatementSymbol: symbol;
|
|
47
67
|
protected wrapperDeclarationsSymbol: symbol;
|
|
48
68
|
protected wrapperAssignmentsSymbol: symbol;
|
|
69
|
+
private fileFor;
|
|
70
|
+
protected emitReExport(visibility: ExportVisibility, ref: FileExportRef, alias?: string): void;
|
|
71
|
+
protected emitReExportTypeAll(visibility: ExportVisibility, targetFilename: string): void;
|
|
72
|
+
protected emitTypeDeclaration(visibility: ExportVisibility, ...statements: Code[]): void;
|
|
49
73
|
/**
|
|
50
74
|
* Template for generating the binding structure in the output file.
|
|
51
75
|
* Includes placeholders for adapter declarations, service requirements, and adapter invocations.
|
|
@@ -67,42 +91,25 @@ export declare class BindingsGenerator {
|
|
|
67
91
|
*/
|
|
68
92
|
build(): void;
|
|
69
93
|
/**
|
|
70
|
-
* Emits re-export statements
|
|
71
|
-
*
|
|
94
|
+
* Emits re-export statements routed by {@link ExportVisibility}. Each sub-method
|
|
95
|
+
* declares its own visibility level; the routing helpers map that to the
|
|
96
|
+
* correct output file.
|
|
72
97
|
*/
|
|
73
|
-
protected buildReExports(
|
|
74
|
-
typeRegistryRef?: ImportableValueReference & {
|
|
75
|
-
filename: string;
|
|
76
|
-
exportedSymbol: string;
|
|
77
|
-
};
|
|
78
|
-
graphqlTypeRegistryRef?: ImportableValueReference & {
|
|
79
|
-
filename: string;
|
|
80
|
-
exportedSymbol: string;
|
|
81
|
-
};
|
|
82
|
-
}): void;
|
|
98
|
+
protected buildReExports(refs: TypeRegistryRefs): void;
|
|
83
99
|
/**
|
|
84
|
-
* Re-exports per-command symbols
|
|
85
|
-
*
|
|
86
|
-
*
|
|
100
|
+
* Re-exports per-command symbols. Value exports (`buildCommandClass`, `CONFIG_SCHEMA`)
|
|
101
|
+
* go to bindings-core for extension authors. The `Config` type alias goes to the
|
|
102
|
+
* public types barrel for standard consumers.
|
|
87
103
|
*
|
|
88
104
|
* The CONFIG_SCHEMA alias uses a simple uppercase of the commandName (e.g. `getItemsByIds`
|
|
89
105
|
* becomes `GETITEMSBYIDS_CONFIG_SCHEMA`) to avoid ambiguity from word-boundary heuristics.
|
|
90
106
|
*/
|
|
91
|
-
protected buildCommandReExports(
|
|
107
|
+
protected buildCommandReExports(): void;
|
|
92
108
|
/**
|
|
93
109
|
* Re-exports the `TypeRegistry` (REST) and/or `GraphQLTypeRegistry` (GraphQL) classes
|
|
94
110
|
* so custom bindings can construct or extend them.
|
|
95
111
|
*/
|
|
96
|
-
protected buildTypeRegistryReExports(
|
|
97
|
-
typeRegistryRef?: ImportableValueReference & {
|
|
98
|
-
filename: string;
|
|
99
|
-
exportedSymbol: string;
|
|
100
|
-
};
|
|
101
|
-
graphqlTypeRegistryRef?: ImportableValueReference & {
|
|
102
|
-
filename: string;
|
|
103
|
-
exportedSymbol: string;
|
|
104
|
-
};
|
|
105
|
-
}): void;
|
|
112
|
+
protected buildTypeRegistryReExports(refs: TypeRegistryRefs): void;
|
|
106
113
|
/**
|
|
107
114
|
* Re-exports individual generated type repository classes (e.g. `RecordRepresentationRepository`)
|
|
108
115
|
* so custom bindings can extend or reference them without importing from internal paths.
|
|
@@ -110,21 +117,29 @@ export declare class BindingsGenerator {
|
|
|
110
117
|
* If both REST and GraphQL registries produce a repository with the same exported symbol,
|
|
111
118
|
* the GraphQL version is aliased with a `GraphQL_` prefix to avoid collisions.
|
|
112
119
|
*/
|
|
113
|
-
protected buildTypeRepositoryReExports(
|
|
120
|
+
protected buildTypeRepositoryReExports(): void;
|
|
114
121
|
/**
|
|
115
|
-
* Re-exports all generated entity types
|
|
116
|
-
*
|
|
122
|
+
* Re-exports all generated entity types (e.g. `Pet`, `Order`) into the
|
|
123
|
+
* public types barrel so both standard consumers and extension authors
|
|
124
|
+
* can reference domain models without importing from internal paths.
|
|
117
125
|
*
|
|
118
126
|
* The barrel `types/index.ts` is built incrementally by TypeDefinitionService
|
|
119
|
-
* as types are generated
|
|
120
|
-
*
|
|
127
|
+
* as types are generated. GraphQL-only specs produce no REST types so the
|
|
128
|
+
* barrel is never created.
|
|
129
|
+
*/
|
|
130
|
+
protected buildEntityTypeReExports(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Emits `WireAdapterResult` and per-wire-adapter result type aliases
|
|
133
|
+
* (e.g. `GetPetResult = WireAdapterResult<Pet>`) into the public types barrel
|
|
134
|
+
* when wire bindings are present.
|
|
121
135
|
*/
|
|
122
|
-
protected
|
|
136
|
+
protected buildWireAdapterResultExports(): void;
|
|
123
137
|
buildTypeInvalidation(typesWithNormalization: TypeRegistryGenerator['invalidatableTypes']): {
|
|
124
138
|
definitions: Code[];
|
|
125
139
|
declarations: Code[];
|
|
126
140
|
};
|
|
127
141
|
protected buildRequirements(): Code;
|
|
142
|
+
private hasBinding;
|
|
128
143
|
protected get hasRESTNormalization(): boolean;
|
|
129
144
|
protected get hasGraphQL(): boolean;
|
|
130
145
|
protected get hasWireBindings(): boolean;
|
|
@@ -138,3 +153,4 @@ export declare class BindingsGenerator {
|
|
|
138
153
|
protected get hasGraphQLMutationBindings(): boolean;
|
|
139
154
|
protected get hasGraphQLWireBindings(): boolean;
|
|
140
155
|
}
|
|
156
|
+
export {};
|
|
@@ -10,6 +10,7 @@ export type TypeDefinitionForOptions = {
|
|
|
10
10
|
export type ITypeDefinitionService = {
|
|
11
11
|
build(type: Type | undefined): Code;
|
|
12
12
|
readonly hasTypes: boolean;
|
|
13
|
+
readonly registeredTypes: ReadonlyMap<string, ImportableReference>;
|
|
13
14
|
};
|
|
14
15
|
export type NamedTypeDefinitionService = NamedService<'typeDefinition', ITypeDefinitionService>;
|
|
15
16
|
export declare class TypeDefinitionService implements ITypeDefinitionService {
|
|
@@ -18,6 +19,7 @@ export declare class TypeDefinitionService implements ITypeDefinitionService {
|
|
|
18
19
|
constructor(services: NamedAPIService & NamedFileService, fileFor?: (typename: string) => string);
|
|
19
20
|
cache: Map<string, ImportableReference>;
|
|
20
21
|
get hasTypes(): boolean;
|
|
22
|
+
get registeredTypes(): ReadonlyMap<string, ImportableReference>;
|
|
21
23
|
build(type: Type | undefined, useReferences?: boolean): Code;
|
|
22
24
|
buildTypeCode(t: Type, options: TypeDefinitionForOptions): Code;
|
|
23
25
|
buildReferenceCode(refType: RefType, options: TypeDefinitionForOptions): Code;
|
package/dist/v1/index.js
CHANGED
|
@@ -305,13 +305,9 @@ const _File = class _File {
|
|
|
305
305
|
code2.push(...chunks);
|
|
306
306
|
return this;
|
|
307
307
|
}
|
|
308
|
-
/** Registers a
|
|
308
|
+
/** Registers a re-export: `export { symbol [as alias] } from "…";` or `export type { … }` depending on `ref.isType`. */
|
|
309
309
|
reExport(ref, alias) {
|
|
310
|
-
this.reExports.add(ref.filename, ref.exportedSymbol, alias,
|
|
311
|
-
}
|
|
312
|
-
/** Registers a type re-export: `export type { symbol [as alias] } from "…";` */
|
|
313
|
-
reExportType(ref, alias) {
|
|
314
|
-
this.reExports.add(ref.filename, ref.exportedSymbol, alias, true);
|
|
310
|
+
this.reExports.add(ref.filename, ref.exportedSymbol, alias, ref.isType);
|
|
315
311
|
}
|
|
316
312
|
/** Registers a wildcard type re-export: `export type * from "…";` */
|
|
317
313
|
reExportTypeAll(targetFilename) {
|
|
@@ -459,6 +455,9 @@ class TypeDefinitionService {
|
|
|
459
455
|
get hasTypes() {
|
|
460
456
|
return this.cache.size > 0;
|
|
461
457
|
}
|
|
458
|
+
get registeredTypes() {
|
|
459
|
+
return this.cache;
|
|
460
|
+
}
|
|
462
461
|
build(type, useReferences = true) {
|
|
463
462
|
return type ? this.buildTypeCode(type, {
|
|
464
463
|
referenceFor: (t) => {
|
|
@@ -3161,7 +3160,7 @@ const WIRE_ADAPTER_CONSTRUCTOR$1 = {
|
|
|
3161
3160
|
exportedSymbol: "WireAdapterConstructor",
|
|
3162
3161
|
isType: true
|
|
3163
3162
|
};
|
|
3164
|
-
const WIRE_ADAPTER_RESULT = {
|
|
3163
|
+
const WIRE_ADAPTER_RESULT$1 = {
|
|
3165
3164
|
module: "@conduit-client/service-bindings-lwc/v1",
|
|
3166
3165
|
exportedSymbol: "WireAdapterResult",
|
|
3167
3166
|
isType: true
|
|
@@ -3195,7 +3194,7 @@ class WireAdapterBindingGenerator {
|
|
|
3195
3194
|
);
|
|
3196
3195
|
}
|
|
3197
3196
|
buildDeclaration() {
|
|
3198
|
-
return code`let ${this.binding.identifier}:${WIRE_ADAPTER_CONSTRUCTOR$1}<${this.commandConfigTypeImport}, ${WIRE_ADAPTER_RESULT}<${this.responseTypeCode}>, {}>;`;
|
|
3197
|
+
return code`let ${this.binding.identifier}:${WIRE_ADAPTER_CONSTRUCTOR$1}<${this.commandConfigTypeImport}, ${WIRE_ADAPTER_RESULT$1}<${this.responseTypeCode}>, {}>;`;
|
|
3199
3198
|
}
|
|
3200
3199
|
get localCommandConstructorName() {
|
|
3201
3200
|
return `${this.binding.identifier}_ctor`;
|
|
@@ -3484,6 +3483,11 @@ const NAMED_FETCH_NETWORK_COMMAND_SERVICE$1 = {
|
|
|
3484
3483
|
exportedSymbol: "NamedFetchNetworkCommandService",
|
|
3485
3484
|
isType: true
|
|
3486
3485
|
};
|
|
3486
|
+
const WIRE_ADAPTER_RESULT = {
|
|
3487
|
+
module: "@conduit-client/service-bindings-lwc/v1",
|
|
3488
|
+
exportedSymbol: "WireAdapterResult",
|
|
3489
|
+
isType: true
|
|
3490
|
+
};
|
|
3487
3491
|
const LWC_BINDINGS_SERVICE_DESCRIPTOR = {
|
|
3488
3492
|
module: "@conduit-client/service-bindings-lwc/v1",
|
|
3489
3493
|
exportedSymbol: "LWCWireBindingsServiceDescriptor",
|
|
@@ -3604,6 +3608,7 @@ class BindingsGenerator {
|
|
|
3604
3608
|
this.services = services;
|
|
3605
3609
|
this.commandModels = commandModels;
|
|
3606
3610
|
this.adapterBindingsGeneratorFactory = adapterBindingsGeneratorFactory;
|
|
3611
|
+
this.exportTargets = /* @__PURE__ */ new Map();
|
|
3607
3612
|
this.adapterDeclarationSymbol = Symbol.for("adapterDeclarations");
|
|
3608
3613
|
this.bindingsServicesDeclarationSymbol = Symbol.for("bindingsServicesDeclaration");
|
|
3609
3614
|
this.serviceRequirementsSymbol = Symbol.for("serviceRequirements");
|
|
@@ -3620,6 +3625,27 @@ class BindingsGenerator {
|
|
|
3620
3625
|
this.wrapperDeclarationsSymbol = Symbol.for("wrapperDeclarations");
|
|
3621
3626
|
this.wrapperAssignmentsSymbol = Symbol.for("wrapperAssignments");
|
|
3622
3627
|
}
|
|
3628
|
+
fileFor(visibility) {
|
|
3629
|
+
const file = this.exportTargets.get(visibility);
|
|
3630
|
+
if (!file) {
|
|
3631
|
+
throw new Error(
|
|
3632
|
+
`No export target registered for visibility "${visibility}". Call build() before emitting re-exports.`
|
|
3633
|
+
);
|
|
3634
|
+
}
|
|
3635
|
+
return file;
|
|
3636
|
+
}
|
|
3637
|
+
emitReExport(visibility, ref, alias) {
|
|
3638
|
+
this.fileFor(visibility).reExport(ref, alias);
|
|
3639
|
+
}
|
|
3640
|
+
emitReExportTypeAll(visibility, targetFilename) {
|
|
3641
|
+
this.fileFor(visibility).reExportTypeAll(targetFilename);
|
|
3642
|
+
}
|
|
3643
|
+
emitTypeDeclaration(visibility, ...statements) {
|
|
3644
|
+
const file = this.fileFor(visibility);
|
|
3645
|
+
for (const stmt of statements) {
|
|
3646
|
+
file.push(stmt);
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3623
3649
|
/**
|
|
3624
3650
|
* Template for generating the binding structure in the output file.
|
|
3625
3651
|
* Includes placeholders for adapter declarations, service requirements, and adapter invocations.
|
|
@@ -3792,11 +3818,15 @@ class BindingsGenerator {
|
|
|
3792
3818
|
* This method coordinates with individual binding generators to compile the necessary elements into a single file.
|
|
3793
3819
|
*/
|
|
3794
3820
|
build() {
|
|
3821
|
+
const publicTypesFilename = "artifacts/bindings-public-types.ts";
|
|
3822
|
+
const publicTypesFile = this.services.file.build(publicTypesFilename);
|
|
3795
3823
|
const coreFilename = "artifacts/bindings-core.ts";
|
|
3796
3824
|
const coreFile = this.services.file.build(coreFilename);
|
|
3797
3825
|
coreFile.template = this.coreTemplate;
|
|
3798
3826
|
const wrapperFilename = "artifacts/bindings.ts";
|
|
3799
3827
|
const wrapperFile = this.services.file.build(wrapperFilename);
|
|
3828
|
+
this.exportTargets.set("public", publicTypesFile);
|
|
3829
|
+
this.exportTargets.set("custom", coreFile);
|
|
3800
3830
|
wrapperFile.template = this.wrapperTemplate;
|
|
3801
3831
|
const CUSTOM_TYPE_REGISTRY_PARAM = "customTypeRegistry";
|
|
3802
3832
|
const CUSTOM_GRAPHQL_TYPE_REGISTRY_PARAM = "customGraphqlTypeRegistry";
|
|
@@ -3925,27 +3955,31 @@ class BindingsGenerator {
|
|
|
3925
3955
|
"\n"
|
|
3926
3956
|
)
|
|
3927
3957
|
);
|
|
3928
|
-
this.buildReExports(
|
|
3958
|
+
this.buildReExports({ typeRegistryRef, graphqlTypeRegistryRef });
|
|
3959
|
+
coreFile.reExportTypeAll(publicTypesFilename);
|
|
3960
|
+
wrapperFile.reExportTypeAll(publicTypesFilename);
|
|
3929
3961
|
}
|
|
3930
3962
|
/**
|
|
3931
|
-
* Emits re-export statements
|
|
3932
|
-
*
|
|
3963
|
+
* Emits re-export statements routed by {@link ExportVisibility}. Each sub-method
|
|
3964
|
+
* declares its own visibility level; the routing helpers map that to the
|
|
3965
|
+
* correct output file.
|
|
3933
3966
|
*/
|
|
3934
|
-
buildReExports(
|
|
3935
|
-
this.buildCommandReExports(
|
|
3936
|
-
this.buildTypeRegistryReExports(
|
|
3937
|
-
this.buildTypeRepositoryReExports(
|
|
3938
|
-
this.buildEntityTypeReExports(
|
|
3967
|
+
buildReExports(refs) {
|
|
3968
|
+
this.buildCommandReExports();
|
|
3969
|
+
this.buildTypeRegistryReExports(refs);
|
|
3970
|
+
this.buildTypeRepositoryReExports();
|
|
3971
|
+
this.buildEntityTypeReExports();
|
|
3972
|
+
this.buildWireAdapterResultExports();
|
|
3939
3973
|
}
|
|
3940
3974
|
/**
|
|
3941
|
-
* Re-exports per-command symbols
|
|
3942
|
-
*
|
|
3943
|
-
*
|
|
3975
|
+
* Re-exports per-command symbols. Value exports (`buildCommandClass`, `CONFIG_SCHEMA`)
|
|
3976
|
+
* go to bindings-core for extension authors. The `Config` type alias goes to the
|
|
3977
|
+
* public types barrel for standard consumers.
|
|
3944
3978
|
*
|
|
3945
3979
|
* The CONFIG_SCHEMA alias uses a simple uppercase of the commandName (e.g. `getItemsByIds`
|
|
3946
3980
|
* becomes `GETITEMSBYIDS_CONFIG_SCHEMA`) to avoid ambiguity from word-boundary heuristics.
|
|
3947
3981
|
*/
|
|
3948
|
-
buildCommandReExports(
|
|
3982
|
+
buildCommandReExports() {
|
|
3949
3983
|
for (const model of this.commandModels) {
|
|
3950
3984
|
const capitalized = capitalizeFirst(model.commandName);
|
|
3951
3985
|
const upper = model.commandName.toUpperCase();
|
|
@@ -3964,21 +3998,21 @@ class BindingsGenerator {
|
|
|
3964
3998
|
exportedSymbol: "Config",
|
|
3965
3999
|
isType: true
|
|
3966
4000
|
};
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
4001
|
+
this.emitReExport("custom", buildRef, `build${capitalized}CommandClass`);
|
|
4002
|
+
this.emitReExport("custom", schemaRef, `${upper}_CONFIG_SCHEMA`);
|
|
4003
|
+
this.emitReExport("public", configRef, `${capitalized}Config`);
|
|
3970
4004
|
}
|
|
3971
4005
|
}
|
|
3972
4006
|
/**
|
|
3973
4007
|
* Re-exports the `TypeRegistry` (REST) and/or `GraphQLTypeRegistry` (GraphQL) classes
|
|
3974
4008
|
* so custom bindings can construct or extend them.
|
|
3975
4009
|
*/
|
|
3976
|
-
buildTypeRegistryReExports(
|
|
4010
|
+
buildTypeRegistryReExports(refs) {
|
|
3977
4011
|
if (refs.typeRegistryRef) {
|
|
3978
|
-
|
|
4012
|
+
this.emitReExport("custom", refs.typeRegistryRef);
|
|
3979
4013
|
}
|
|
3980
4014
|
if (refs.graphqlTypeRegistryRef) {
|
|
3981
|
-
|
|
4015
|
+
this.emitReExport("custom", refs.graphqlTypeRegistryRef);
|
|
3982
4016
|
}
|
|
3983
4017
|
}
|
|
3984
4018
|
/**
|
|
@@ -3988,7 +4022,7 @@ class BindingsGenerator {
|
|
|
3988
4022
|
* If both REST and GraphQL registries produce a repository with the same exported symbol,
|
|
3989
4023
|
* the GraphQL version is aliased with a `GraphQL_` prefix to avoid collisions.
|
|
3990
4024
|
*/
|
|
3991
|
-
buildTypeRepositoryReExports(
|
|
4025
|
+
buildTypeRepositoryReExports() {
|
|
3992
4026
|
const restRepos = this.hasRESTNormalization ? [...this.services.typeRegistryGenerator.registeredTypes.values()] : [];
|
|
3993
4027
|
const graphqlRepos = this.hasGraphQL ? [...this.services.graphqlTypeRegistryGenerator.registeredTypes.values()] : [];
|
|
3994
4028
|
const restNames = new Set(restRepos.map((r) => r.typeClassRef.exportedSymbol));
|
|
@@ -3996,28 +4030,55 @@ class BindingsGenerator {
|
|
|
3996
4030
|
const conflicts = new Set([...restNames].filter((n) => graphqlNames.has(n)));
|
|
3997
4031
|
for (const { typeClassRef } of restRepos) {
|
|
3998
4032
|
if (!("filename" in typeClassRef) || !typeClassRef.exportedSymbol) continue;
|
|
3999
|
-
|
|
4033
|
+
this.emitReExport("custom", typeClassRef);
|
|
4000
4034
|
}
|
|
4001
4035
|
for (const { typeClassRef } of graphqlRepos) {
|
|
4002
4036
|
if (!("filename" in typeClassRef) || !typeClassRef.exportedSymbol) continue;
|
|
4003
4037
|
const alias = conflicts.has(typeClassRef.exportedSymbol) ? `GraphQL_${typeClassRef.exportedSymbol}` : void 0;
|
|
4004
|
-
|
|
4005
|
-
typeClassRef,
|
|
4006
|
-
alias
|
|
4007
|
-
);
|
|
4038
|
+
this.emitReExport("custom", typeClassRef, alias);
|
|
4008
4039
|
}
|
|
4009
4040
|
}
|
|
4010
4041
|
/**
|
|
4011
|
-
* Re-exports all generated entity types
|
|
4012
|
-
*
|
|
4042
|
+
* Re-exports all generated entity types (e.g. `Pet`, `Order`) into the
|
|
4043
|
+
* public types barrel so both standard consumers and extension authors
|
|
4044
|
+
* can reference domain models without importing from internal paths.
|
|
4013
4045
|
*
|
|
4014
4046
|
* The barrel `types/index.ts` is built incrementally by TypeDefinitionService
|
|
4015
|
-
* as types are generated
|
|
4016
|
-
*
|
|
4047
|
+
* as types are generated. GraphQL-only specs produce no REST types so the
|
|
4048
|
+
* barrel is never created.
|
|
4017
4049
|
*/
|
|
4018
|
-
buildEntityTypeReExports(
|
|
4019
|
-
|
|
4020
|
-
|
|
4050
|
+
buildEntityTypeReExports() {
|
|
4051
|
+
for (const ref of this.services.typeDefinition.registeredTypes.values()) {
|
|
4052
|
+
if ("filename" in ref && ref.exportedSymbol) {
|
|
4053
|
+
this.emitReExport("public", ref);
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
/**
|
|
4058
|
+
* Emits `WireAdapterResult` and per-wire-adapter result type aliases
|
|
4059
|
+
* (e.g. `GetPetResult = WireAdapterResult<Pet>`) into the public types barrel
|
|
4060
|
+
* when wire bindings are present.
|
|
4061
|
+
*/
|
|
4062
|
+
buildWireAdapterResultExports() {
|
|
4063
|
+
var _a;
|
|
4064
|
+
if (!this.hasWireBindings && !this.hasGraphQLWireBindings) {
|
|
4065
|
+
return;
|
|
4066
|
+
}
|
|
4067
|
+
this.emitTypeDeclaration(
|
|
4068
|
+
"public",
|
|
4069
|
+
code`export type {${WIRE_ADAPTER_RESULT}};`
|
|
4070
|
+
);
|
|
4071
|
+
for (const model of this.commandModels) {
|
|
4072
|
+
for (const binding of model.bindings) {
|
|
4073
|
+
if (binding.type !== "wire") continue;
|
|
4074
|
+
const responseSchema = (_a = model.responseType) == null ? void 0 : _a.default["application/json"];
|
|
4075
|
+
const responseTypeCode = this.services.typeDefinition.build(responseSchema);
|
|
4076
|
+
const aliasName = `${capitalizeFirst(binding.identifier)}Result`;
|
|
4077
|
+
this.emitTypeDeclaration(
|
|
4078
|
+
"public",
|
|
4079
|
+
code`export type ${aliasName} = ${WIRE_ADAPTER_RESULT}<${responseTypeCode}>;`
|
|
4080
|
+
);
|
|
4081
|
+
}
|
|
4021
4082
|
}
|
|
4022
4083
|
}
|
|
4023
4084
|
buildTypeInvalidation(typesWithNormalization) {
|
|
@@ -4129,6 +4190,9 @@ class BindingsGenerator {
|
|
|
4129
4190
|
","
|
|
4130
4191
|
)}}`;
|
|
4131
4192
|
}
|
|
4193
|
+
hasBinding(pred) {
|
|
4194
|
+
return this.commandModels.some((m) => m.bindings.some((b) => pred(m, b)));
|
|
4195
|
+
}
|
|
4132
4196
|
get hasRESTNormalization() {
|
|
4133
4197
|
return this.commandModels.some((model) => {
|
|
4134
4198
|
return model.cacheStrategy.type === "normalized" && model.operationType !== "graphql";
|
|
@@ -4138,70 +4202,40 @@ class BindingsGenerator {
|
|
|
4138
4202
|
return this.commandModels.some((model) => model.operationType === "graphql");
|
|
4139
4203
|
}
|
|
4140
4204
|
get hasWireBindings() {
|
|
4141
|
-
return this.
|
|
4142
|
-
(model) => model.bindings.some((binding) => binding.type === "wire")
|
|
4143
|
-
);
|
|
4205
|
+
return this.hasBinding((_m, b) => b.type === "wire");
|
|
4144
4206
|
}
|
|
4145
4207
|
get hasImperativeBindings() {
|
|
4146
|
-
return this.
|
|
4147
|
-
(model) => model.bindings.some(
|
|
4148
|
-
(binding) => binding.type === "imperative" || binding.type === "mutation"
|
|
4149
|
-
)
|
|
4150
|
-
);
|
|
4208
|
+
return this.hasBinding((_m, b) => b.type === "imperative" || b.type === "mutation");
|
|
4151
4209
|
}
|
|
4152
4210
|
get hasDefaultImperativeBindings() {
|
|
4153
|
-
return this.
|
|
4154
|
-
(
|
|
4155
|
-
(binding) => binding.type === "imperative" && model.operationType !== "query" && model.operationType !== "graphql"
|
|
4156
|
-
)
|
|
4211
|
+
return this.hasBinding(
|
|
4212
|
+
(m, b) => b.type === "imperative" && m.operationType !== "query" && m.operationType !== "graphql"
|
|
4157
4213
|
);
|
|
4158
4214
|
}
|
|
4159
4215
|
get hasQueryImperativeBindings() {
|
|
4160
|
-
return this.
|
|
4161
|
-
(model) => model.bindings.some(
|
|
4162
|
-
(binding) => binding.type === "imperative" && model.operationType === "query"
|
|
4163
|
-
)
|
|
4164
|
-
);
|
|
4216
|
+
return this.hasBinding((m, b) => b.type === "imperative" && m.operationType === "query");
|
|
4165
4217
|
}
|
|
4166
4218
|
get hasSubscribableImperativeBindings() {
|
|
4167
|
-
return this.
|
|
4168
|
-
(
|
|
4169
|
-
(binding) => binding.type === "imperative" && model.operationType === "query" && model.cacheStrategy.type !== "none"
|
|
4170
|
-
)
|
|
4219
|
+
return this.hasBinding(
|
|
4220
|
+
(m, b) => b.type === "imperative" && m.operationType === "query" && m.cacheStrategy.type !== "none"
|
|
4171
4221
|
);
|
|
4172
4222
|
}
|
|
4173
4223
|
get hasLegacyImperativeBindings() {
|
|
4174
|
-
return this.
|
|
4175
|
-
(model) => model.bindings.some((binding) => binding.type === "imperative-legacy")
|
|
4176
|
-
);
|
|
4224
|
+
return this.hasBinding((_m, b) => b.type === "imperative-legacy");
|
|
4177
4225
|
}
|
|
4178
4226
|
get hasGraphQLImperativeBindings() {
|
|
4179
|
-
return this.
|
|
4180
|
-
(model) => model.bindings.some(
|
|
4181
|
-
(binding) => binding.type === "imperative" && model.operationType === "graphql"
|
|
4182
|
-
)
|
|
4183
|
-
);
|
|
4227
|
+
return this.hasBinding((m, b) => b.type === "imperative" && m.operationType === "graphql");
|
|
4184
4228
|
}
|
|
4185
4229
|
get hasGraphQLLegacyImperativeBindings() {
|
|
4186
|
-
return this.
|
|
4187
|
-
(
|
|
4188
|
-
(binding) => binding.type === "imperative-legacy" && model.operationType === "graphql"
|
|
4189
|
-
)
|
|
4230
|
+
return this.hasBinding(
|
|
4231
|
+
(m, b) => b.type === "imperative-legacy" && m.operationType === "graphql"
|
|
4190
4232
|
);
|
|
4191
4233
|
}
|
|
4192
4234
|
get hasGraphQLMutationBindings() {
|
|
4193
|
-
return this.
|
|
4194
|
-
(model) => model.bindings.some(
|
|
4195
|
-
(binding) => binding.type === "mutation" && model.operationType === "graphql"
|
|
4196
|
-
)
|
|
4197
|
-
);
|
|
4235
|
+
return this.hasBinding((m, b) => b.type === "mutation" && m.operationType === "graphql");
|
|
4198
4236
|
}
|
|
4199
4237
|
get hasGraphQLWireBindings() {
|
|
4200
|
-
return this.
|
|
4201
|
-
(model) => model.bindings.some(
|
|
4202
|
-
(binding) => binding.type === "wire" && model.operationType === "graphql"
|
|
4203
|
-
)
|
|
4204
|
-
);
|
|
4238
|
+
return this.hasBinding((m, b) => b.type === "wire" && m.operationType === "graphql");
|
|
4205
4239
|
}
|
|
4206
4240
|
}
|
|
4207
4241
|
function getParameterMembers(...records) {
|