@conduit-client/generator-ts 5.67.0-dev1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/index.js +6 -0
- package/dist/main/index.js.map +1 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/v1/__tests__/api-module-generator-service.spec.d.ts +1 -0
- package/dist/types/v1/__tests__/test-utils/additional-properties-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/all-of-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/any-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/array-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/base-api.d.ts +9 -0
- package/dist/types/v1/__tests__/test-utils/datetime-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/discriminator-api.d.ts +9 -0
- package/dist/types/v1/__tests__/test-utils/enum-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/index.d.ts +31 -0
- package/dist/types/v1/__tests__/test-utils/object-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/oneof-api.d.ts +8 -0
- package/dist/types/v1/__tests__/test-utils/scalar-api.d.ts +9 -0
- package/dist/types/v1/__tests__/utils.spec.d.ts +1 -0
- package/dist/types/v1/api-module-generator-service.d.ts +18 -0
- package/dist/types/v1/files/__tests__/code.spec.d.ts +1 -0
- package/dist/types/v1/files/__tests__/file.spec.d.ts +1 -0
- package/dist/types/v1/files/__tests__/write-files.spec.d.ts +1 -0
- package/dist/types/v1/files/code.d.ts +86 -0
- package/dist/types/v1/files/file.d.ts +79 -0
- package/dist/types/v1/files/index.d.ts +3 -0
- package/dist/types/v1/files/write-files.d.ts +12 -0
- package/dist/types/v1/generators/__tests__/api-family-module-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/aura-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/aura-graphql-normalized-cache-control-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/aura-normalized-cache-control-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/aura-resource-cache-control-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/base-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/bindings-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/built-test-model.d.ts +10 -0
- package/dist/types/v1/generators/__tests__/cache-control-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/command-config-builder.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/http-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/http-normalized-cache-control-command-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/imperative-binding-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/imperative-legacy-binding-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/normalized-cache-control-generator-mixin.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/utils.spec.d.ts +1 -0
- package/dist/types/v1/generators/__tests__/wire-binding-generator.spec.d.ts +1 -0
- package/dist/types/v1/generators/api-family-module-generator.d.ts +54 -0
- package/dist/types/v1/generators/aura-command-generator.d.ts +46 -0
- package/dist/types/v1/generators/aura-graphql-normalized-cache-control-command-generator.d.ts +1 -0
- package/dist/types/v1/generators/aura-normalized-cache-control-command-generator.d.ts +1 -0
- package/dist/types/v1/generators/aura-resource-cache-control-command-generator.d.ts +39 -0
- package/dist/types/v1/generators/base-command-generator.d.ts +88 -0
- package/dist/types/v1/generators/bindings-generator.d.ts +69 -0
- package/dist/types/v1/generators/cache-control-generator.d.ts +2 -0
- package/dist/types/v1/generators/command-config-builder.d.ts +28 -0
- package/dist/types/v1/generators/graphql-imperative-binding-generator.d.ts +23 -0
- package/dist/types/v1/generators/graphql-imperative-legacy-binding-generator.d.ts +18 -0
- package/dist/types/v1/generators/graphql-mutation-binding-generator.d.ts +21 -0
- package/dist/types/v1/generators/graphql-normalized-cache-control-generator-mixin.d.ts +13 -0
- package/dist/types/v1/generators/graphql-root-variable-names.d.ts +2 -0
- package/dist/types/v1/generators/graphql-wire-binding-generator.d.ts +18 -0
- package/dist/types/v1/generators/http-command-generator.d.ts +67 -0
- package/dist/types/v1/generators/http-graphql-normalized-cache-control-command-generator.d.ts +1 -0
- package/dist/types/v1/generators/http-normalized-cache-control-command-generator.d.ts +1 -0
- package/dist/types/v1/generators/imperative-binding-generator.d.ts +24 -0
- package/dist/types/v1/generators/imperative-legacy-binding-generator.d.ts +18 -0
- package/dist/types/v1/generators/index.d.ts +9 -0
- package/dist/types/v1/generators/normalized-cache-control-generator-mixin.d.ts +15 -0
- package/dist/types/v1/generators/utils.d.ts +17 -0
- package/dist/types/v1/generators/wire-binding-generator.d.ts +19 -0
- package/dist/types/v1/index.d.ts +4 -0
- package/dist/types/v1/model/__tests__/aura-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/aura-graphql-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/aura-normalized-caching-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/aura-resource-caching-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/base-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/graphql-schema-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/graphql-utils.d.ts +17 -0
- package/dist/types/v1/model/__tests__/http-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/__tests__/http-normalized-caching-command-model.spec.d.ts +1 -0
- package/dist/types/v1/model/aura-command-model.d.ts +34 -0
- package/dist/types/v1/model/aura-graphql-command-model.d.ts +10 -0
- package/dist/types/v1/model/aura-normalized-caching-command-model.d.ts +8 -0
- package/dist/types/v1/model/aura-resource-caching-command-model.d.ts +13 -0
- package/dist/types/v1/model/base-command-model.d.ts +186 -0
- package/dist/types/v1/model/graphql-command-model-interface.d.ts +12 -0
- package/dist/types/v1/model/graphql-schema-model.d.ts +104 -0
- package/dist/types/v1/model/http-command-model.d.ts +32 -0
- package/dist/types/v1/model/http-graphql-command-model.d.ts +16 -0
- package/dist/types/v1/model/http-normalized-caching-command-model.d.ts +14 -0
- package/dist/types/v1/normalization/__tests__/graphql-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/graphql-type-registry-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/identifiable-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/integration.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/normalized-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/type-registry-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/unidentifiable-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/__tests__/utils.d.ts +3 -0
- package/dist/types/v1/normalization/graphql/__tests__/cursor-connection-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/graphql/__tests__/identifiable-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/graphql/__tests__/interface-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/graphql/__tests__/unidentifiable-type-generator.spec.d.ts +1 -0
- package/dist/types/v1/normalization/graphql/base-type-generator.d.ts +76 -0
- package/dist/types/v1/normalization/graphql/cursor-connection-type-generator.d.ts +17 -0
- package/dist/types/v1/normalization/graphql/document-root-type-generator.d.ts +13 -0
- package/dist/types/v1/normalization/graphql/identifiable-type-generator.d.ts +13 -0
- package/dist/types/v1/normalization/graphql/interface-type-generator.d.ts +10 -0
- package/dist/types/v1/normalization/graphql/unidentifiable-type-generator.d.ts +13 -0
- package/dist/types/v1/normalization/graphql/union-type-generator.d.ts +10 -0
- package/dist/types/v1/normalization/graphql-type-generator.d.ts +47 -0
- package/dist/types/v1/normalization/graphql-type-registry-generator.d.ts +59 -0
- package/dist/types/v1/normalization/identifiable-type-generator.d.ts +19 -0
- package/dist/types/v1/normalization/index.d.ts +28 -0
- package/dist/types/v1/normalization/normalize-code-gen/__tests__/normalize-generator-service.spec.d.ts +1 -0
- package/dist/types/v1/normalization/normalize-code-gen/__tests__/utils.d.ts +15 -0
- package/dist/types/v1/normalization/normalize-code-gen/normalize-generator-service.d.ts +65 -0
- package/dist/types/v1/normalization/normalized-type-generator.d.ts +52 -0
- package/dist/types/v1/normalization/type-registry-generator.d.ts +68 -0
- package/dist/types/v1/normalization/unidentifiable-type-generator.d.ts +17 -0
- package/dist/types/v1/normalization/utils.d.ts +23 -0
- package/dist/types/v1/types/__tests__/json-schema-declarations.spec.d.ts +1 -0
- package/dist/types/v1/types/__tests__/json-schema.spec.d.ts +3 -0
- package/dist/types/v1/types/__tests__/normalized-type-definition.spec.d.ts +1 -0
- package/dist/types/v1/types/__tests__/resolve-all-of-type.spec.d.ts +1 -0
- package/dist/types/v1/types/__tests__/type-definition.spec.d.ts +1 -0
- package/dist/types/v1/types/index.d.ts +4 -0
- package/dist/types/v1/types/json-schema-declarations.d.ts +29 -0
- package/dist/types/v1/types/json-schema.d.ts +15 -0
- package/dist/types/v1/types/normalized-type-definition.d.ts +25 -0
- package/dist/types/v1/types/resolve-all-of-type.d.ts +16 -0
- package/dist/types/v1/types/type-definition.d.ts +35 -0
- package/dist/types/v1/utils.d.ts +30 -0
- package/dist/v1/index.js +11074 -0
- package/dist/v1/index.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { GraphQLTypeGenerator } from './graphql-type-generator';
|
|
2
|
+
import type { NamedFileService, File, ImportableValueReference, ImportableReference } from '../files';
|
|
3
|
+
import type { NamedService } from '@conduit-client/utils';
|
|
4
|
+
import type { GraphQLSchemaModel } from '../model/graphql-schema-model';
|
|
5
|
+
import type { GraphQLObjectType } from './graphql-type-generator';
|
|
6
|
+
import { NamedAPIService } from '@conduit-client/model/v1';
|
|
7
|
+
type GraphQLTypeRepositoryReference = {
|
|
8
|
+
propertyName: string;
|
|
9
|
+
typeClassRef: ImportableValueReference;
|
|
10
|
+
typeName: string;
|
|
11
|
+
};
|
|
12
|
+
type Options = {
|
|
13
|
+
type: GraphQLObjectType;
|
|
14
|
+
schemaModel: GraphQLSchemaModel;
|
|
15
|
+
};
|
|
16
|
+
export type IGraphQLTypeRegistryGeneratorService = {
|
|
17
|
+
build(): ImportableValueReference;
|
|
18
|
+
buildGraphQLType(options: Options): GraphQLTypeRepositoryReference;
|
|
19
|
+
};
|
|
20
|
+
export type NamedGraphQLTypeRegistryGeneratorService<Name extends string = 'graphqlTypeRegistryGenerator'> = NamedService<Name, IGraphQLTypeRegistryGeneratorService>;
|
|
21
|
+
export declare const NAMED_CACHE_CONTROLLER_SERVICE: ImportableReference;
|
|
22
|
+
export declare const NAMED_PUB_SUB_SERVICE: ImportableReference;
|
|
23
|
+
export declare const TYPE_SERVICES: import("..").Code;
|
|
24
|
+
/**
|
|
25
|
+
* A class for building the GraphQL type registry for a given module
|
|
26
|
+
*/
|
|
27
|
+
export declare class GraphQLTypeRegistryGenerator implements IGraphQLTypeRegistryGeneratorService {
|
|
28
|
+
protected services: NamedFileService & NamedAPIService;
|
|
29
|
+
protected filename: string;
|
|
30
|
+
protected graphqlTypeGenerator: GraphQLTypeGenerator;
|
|
31
|
+
constructor(services: NamedFileService & NamedAPIService, filename?: string);
|
|
32
|
+
setGraphQLTypeGenerator(generator: GraphQLTypeGenerator): void;
|
|
33
|
+
_file: File | undefined;
|
|
34
|
+
protected typeDeclarationsSymbol: symbol;
|
|
35
|
+
protected typeInstantiationsSymbol: symbol;
|
|
36
|
+
protected typeGettersSymbol: symbol;
|
|
37
|
+
cache: Map<string, GraphQLTypeRepositoryReference>;
|
|
38
|
+
private get file();
|
|
39
|
+
private buildFile;
|
|
40
|
+
get template(): (symbol | import("..").Code)[];
|
|
41
|
+
/**
|
|
42
|
+
* A method for building the base GraphQL type registry code, without any classes populated
|
|
43
|
+
*/
|
|
44
|
+
build(): {
|
|
45
|
+
readonly filename: string;
|
|
46
|
+
readonly exportedSymbol: "GraphQLTypeRegistry";
|
|
47
|
+
readonly isType: false;
|
|
48
|
+
};
|
|
49
|
+
get namespace(): string;
|
|
50
|
+
/**
|
|
51
|
+
* A method for building/adding a specific GraphQL type to the registry
|
|
52
|
+
*/
|
|
53
|
+
buildGraphQLType(options: Options): GraphQLTypeRepositoryReference;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates a GraphQLTypeRegistryGeneratorService.
|
|
57
|
+
*/
|
|
58
|
+
export declare function graphqlTypeRegistryGeneratorService(services: NamedFileService & NamedAPIService, graphqlTypeGenerator?: GraphQLTypeGenerator): IGraphQLTypeRegistryGeneratorService;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Code } from '../files';
|
|
2
|
+
import type { IdentifiableType, Type } from '@conduit-client/model/v1';
|
|
3
|
+
import type { NamedNormalizedTypeDefinitionService, NamedTypeDefinitionService } from '../types';
|
|
4
|
+
import type { NamedTypeRegistryGeneratorService } from './type-registry-generator';
|
|
5
|
+
import { NamedNormalizeGeneratorService } from './normalize-code-gen/normalize-generator-service';
|
|
6
|
+
/**
|
|
7
|
+
* Generates the normalizer class for an identifiable type
|
|
8
|
+
* @param services The services required for this function. TypeDefinitionService is used to generate utility types.
|
|
9
|
+
* TypeRegistryGeneratorService is used to build references to child types
|
|
10
|
+
* @param type The type to generate the normalizer for
|
|
11
|
+
* @param options Options for generating the type, including the type name, namespace, and an optional key param override
|
|
12
|
+
* @returns Class name and code for the build type class
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateIdentifiableType(services: NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedNormalizeGeneratorService & NamedNormalizedTypeDefinitionService, type: IdentifiableType, options: {
|
|
15
|
+
className: string;
|
|
16
|
+
namespace: string;
|
|
17
|
+
name: string;
|
|
18
|
+
keyParamType?: Type;
|
|
19
|
+
}): Code;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from './normalized-type-generator';
|
|
2
|
+
export * from './type-registry-generator';
|
|
3
|
+
export * from './normalize-code-gen/normalize-generator-service';
|
|
4
|
+
export { GraphQLTypeGenerator } from './graphql-type-generator';
|
|
5
|
+
export type { GraphQLObjectType, IGraphQLTypeGenerator } from './graphql-type-generator';
|
|
6
|
+
export { GraphQLTypeRegistryGenerator, graphqlTypeRegistryGeneratorService, } from './graphql-type-registry-generator';
|
|
7
|
+
export type { IGraphQLTypeRegistryGeneratorService, NamedGraphQLTypeRegistryGeneratorService, } from './graphql-type-registry-generator';
|
|
8
|
+
export { IdentifiableGraphQLTypeGenerator } from './graphql/identifiable-type-generator';
|
|
9
|
+
export type { IdentifiableGraphQLObjectType } from './graphql/identifiable-type-generator';
|
|
10
|
+
export { UnidentifiableGraphQLTypeGenerator } from './graphql/unidentifiable-type-generator';
|
|
11
|
+
export type { UnidentifiableGraphQLObjectType } from './graphql/unidentifiable-type-generator';
|
|
12
|
+
export { CursorConnectionGraphQLTypeGenerator } from './graphql/cursor-connection-type-generator';
|
|
13
|
+
export type { CursorConnectionGraphQLObjectType } from './graphql/cursor-connection-type-generator';
|
|
14
|
+
export { InterfaceGraphQLTypeGenerator } from './graphql/interface-type-generator';
|
|
15
|
+
export type { InterfaceGraphQLObjectType } from './graphql/interface-type-generator';
|
|
16
|
+
export { UnionGraphQLTypeGenerator } from './graphql/union-type-generator';
|
|
17
|
+
export type { UnionGraphQLObjectType } from './graphql/union-type-generator';
|
|
18
|
+
export { BaseGraphQLTypeGenerator } from './graphql/base-type-generator';
|
|
19
|
+
export type { GenerationOptions } from './graphql/base-type-generator';
|
|
20
|
+
export { generateIdentifiableGraphQLType } from './graphql/identifiable-type-generator';
|
|
21
|
+
export { generateUnidentifiableGraphQLType } from './graphql/unidentifiable-type-generator';
|
|
22
|
+
export { generateCursorConnectionGraphQLType } from './graphql/cursor-connection-type-generator';
|
|
23
|
+
export { generateInterfaceGraphQLType } from './graphql/interface-type-generator';
|
|
24
|
+
export { generateUnionGraphQLType } from './graphql/union-type-generator';
|
|
25
|
+
export { TypeRegistryGenerator } from './type-registry-generator';
|
|
26
|
+
export type { ITypeRegistryGeneratorService } from './type-registry-generator';
|
|
27
|
+
export { NormalizedTypeGenerator } from './normalized-type-generator';
|
|
28
|
+
export type { INormalizedTypeGenerator } from './normalized-type-generator';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseTypeRegistry, Type } from '@conduit-client/model/v1';
|
|
2
|
+
import { NormalizeGeneratorService } from '../../normalize-code-gen/normalize-generator-service';
|
|
3
|
+
export declare const baseOptions: {
|
|
4
|
+
namespace: string;
|
|
5
|
+
typeRegistryRef: import("../../..").Code;
|
|
6
|
+
cacheRef: import("../../..").Code;
|
|
7
|
+
denormalizeDataRef: import("../../..").Code;
|
|
8
|
+
normalizeDataRef: import("../../..").Code;
|
|
9
|
+
errorsRef: import("../../..").Code;
|
|
10
|
+
existingNormalizedDataRef: import("../../..").Code;
|
|
11
|
+
};
|
|
12
|
+
export declare function setupNormalizeGenerator(): {
|
|
13
|
+
generator: NormalizeGeneratorService;
|
|
14
|
+
typeRegistry: BaseTypeRegistry<Type>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type NamedService } from '@conduit-client/utils';
|
|
2
|
+
import { Code } from '../../files';
|
|
3
|
+
import { type ObjectType, type Type } from '@conduit-client/model/v1';
|
|
4
|
+
import type { DiscriminatedObjectType, NamedAPIService, OneOf } from '@conduit-client/model/v1';
|
|
5
|
+
import { NamedTypeRegistryGeneratorService } from '../type-registry-generator';
|
|
6
|
+
import { NamedJSONSchemaDeclarationService, NamedNormalizedTypeDefinitionService, NamedTypeDefinitionService } from '../../types';
|
|
7
|
+
/**
|
|
8
|
+
* The input options for the normalize generator service. Includes all the
|
|
9
|
+
* data and code references required to build an implementation of normalize & denormalize method bodies
|
|
10
|
+
*/
|
|
11
|
+
type Options = {
|
|
12
|
+
namespace: string;
|
|
13
|
+
typeRegistryRef: Code;
|
|
14
|
+
cacheRef: Code;
|
|
15
|
+
denormalizeDataRef: Code;
|
|
16
|
+
normalizeDataRef: Code;
|
|
17
|
+
existingNormalizedDataRef: Code;
|
|
18
|
+
errorsRef: Code;
|
|
19
|
+
useReferences?: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The result type of the normalize generator service
|
|
23
|
+
*/
|
|
24
|
+
type NormalizationCode = {
|
|
25
|
+
normalize: Code;
|
|
26
|
+
denormalize: Code;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* An interface for a service that builds the normalization and denormalization code
|
|
30
|
+
* for a given type, given a set of code references for required variables, e.g.
|
|
31
|
+
* a type registry, the data to normalized/denormalize, etc.
|
|
32
|
+
*/
|
|
33
|
+
export type INormalizeGeneratorService = {
|
|
34
|
+
build(type: Type, options: Options): NormalizationCode;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The named service definition for the normalize generator
|
|
38
|
+
*/
|
|
39
|
+
export type NamedNormalizeGeneratorService = NamedService<'normalizeGenerator', INormalizeGeneratorService>;
|
|
40
|
+
/**
|
|
41
|
+
* The implementation of the normalize generator service.
|
|
42
|
+
*/
|
|
43
|
+
export declare class NormalizeGeneratorService implements INormalizeGeneratorService {
|
|
44
|
+
protected services: NamedAPIService & NamedTypeRegistryGeneratorService & NamedTypeDefinitionService & NamedNormalizedTypeDefinitionService & NamedJSONSchemaDeclarationService;
|
|
45
|
+
constructor(services: NamedAPIService & NamedTypeRegistryGeneratorService & NamedTypeDefinitionService & NamedNormalizedTypeDefinitionService & NamedJSONSchemaDeclarationService);
|
|
46
|
+
/**
|
|
47
|
+
* The public interface method for the normalize generator service, used
|
|
48
|
+
* to build the body of denormalize/normalize methods.
|
|
49
|
+
* @param type The type to generate normalization/denormalization code for
|
|
50
|
+
* @param options The set of required input options to generate the code
|
|
51
|
+
* @returns The normalize and denormalize code
|
|
52
|
+
*/
|
|
53
|
+
build(type: Type, options: Options): NormalizationCode;
|
|
54
|
+
buildNormalizeCode(type: Type, options: Options): NormalizationCode | undefined;
|
|
55
|
+
buildObjectCode(t: ObjectType, options: Options): NormalizationCode | undefined;
|
|
56
|
+
buildPropCodes(t: ObjectType, options: Options): NormalizationCode[];
|
|
57
|
+
buildAdditionalPropsCode(t: ObjectType, hasExplicitPropertiesDefined: boolean, options: Options): NormalizationCode | undefined;
|
|
58
|
+
buildOneOfCode(type: OneOf, options: Options): NormalizationCode | undefined;
|
|
59
|
+
buildDiscriminatedObjectCode(t: DiscriminatedObjectType, options: Options): {
|
|
60
|
+
normalize: Code;
|
|
61
|
+
denormalize: Code;
|
|
62
|
+
} | undefined;
|
|
63
|
+
}
|
|
64
|
+
export declare function normalizeGenerator(services: NamedTypeDefinitionService & NamedAPIService & NamedTypeRegistryGeneratorService & NamedJSONSchemaDeclarationService & NamedNormalizedTypeDefinitionService): NormalizeGeneratorService;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ImportableValueReference, NamedFileService } from '../files';
|
|
2
|
+
import { type Type } from '@conduit-client/model/v1';
|
|
3
|
+
import type { NamedNormalizedTypeDefinitionService, NamedTypeDefinitionService } from '../types';
|
|
4
|
+
import type { NamedTypeRegistryGeneratorService } from './type-registry-generator';
|
|
5
|
+
import { NamedNormalizeGeneratorService } from './normalize-code-gen/normalize-generator-service';
|
|
6
|
+
export type INormalizedTypeGenerator = {
|
|
7
|
+
build(options: {
|
|
8
|
+
namespace: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: Type;
|
|
11
|
+
keyParamType?: Type;
|
|
12
|
+
}): ImportableValueReference;
|
|
13
|
+
buildRef(options: {
|
|
14
|
+
namespace: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: Type;
|
|
17
|
+
keyParamType?: Type;
|
|
18
|
+
}): ImportableValueReference;
|
|
19
|
+
};
|
|
20
|
+
type Options = {
|
|
21
|
+
namespace: string;
|
|
22
|
+
name: string;
|
|
23
|
+
type: Type;
|
|
24
|
+
keyParamsType?: Type;
|
|
25
|
+
};
|
|
26
|
+
export declare const FILE_PER_NORMALIZED_TYPE: (typename: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* A class for building normalized type class implementations
|
|
29
|
+
*/
|
|
30
|
+
export declare class NormalizedTypeGenerator implements INormalizedTypeGenerator {
|
|
31
|
+
protected services: NamedFileService & NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedNormalizeGeneratorService & NamedNormalizedTypeDefinitionService;
|
|
32
|
+
private fileFor;
|
|
33
|
+
private generateType;
|
|
34
|
+
constructor(services: NamedFileService & NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedNormalizeGeneratorService & NamedNormalizedTypeDefinitionService, fileFor?: (typename: string) => string, generateType?: typeof defaultGenerateType);
|
|
35
|
+
cache: Map<string, ImportableValueReference>;
|
|
36
|
+
protected typeBuildersSymbol: symbol;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param options The options for building the type normalizer, inclduing the namespace, the name, the type, and key param overrides
|
|
40
|
+
* @returns An importable reference for the type class
|
|
41
|
+
*/
|
|
42
|
+
build(options: Options): ImportableValueReference;
|
|
43
|
+
buildRef(options: Options): {
|
|
44
|
+
readonly filename: string;
|
|
45
|
+
readonly exportedSymbol: string;
|
|
46
|
+
readonly isType: false;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
declare function defaultGenerateType(services: NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedNormalizeGeneratorService & NamedNormalizedTypeDefinitionService, type: Type, options: Options & {
|
|
50
|
+
className: string;
|
|
51
|
+
}): import("..").Code;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Code } from '../files';
|
|
2
|
+
import type { NamedJSONSchemaDeclarationService, NamedNormalizedTypeDefinitionService, NamedTypeDefinitionService } from '../types';
|
|
3
|
+
import type { INormalizedTypeGenerator } from './normalized-type-generator';
|
|
4
|
+
import type { NamedService } from '@conduit-client/utils';
|
|
5
|
+
import type { File, ImportableValueReference, NamedFileService } from '../files';
|
|
6
|
+
import { NamedAPIService, type Type } from '@conduit-client/model/v1';
|
|
7
|
+
import { NamedNormalizeGeneratorService } from './normalize-code-gen/normalize-generator-service';
|
|
8
|
+
type TypeRepositoryReference = {
|
|
9
|
+
propertyName: string;
|
|
10
|
+
typeClassRef: ImportableValueReference;
|
|
11
|
+
};
|
|
12
|
+
type Options = {
|
|
13
|
+
name: string;
|
|
14
|
+
namespace: string;
|
|
15
|
+
keyParamType?: Type;
|
|
16
|
+
isInvalidatable?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ITypeRegistryGeneratorService = {
|
|
19
|
+
build(): ImportableValueReference;
|
|
20
|
+
buildType(type: Type, options: Options): TypeRepositoryReference;
|
|
21
|
+
invalidatableTypes: TypeRepositoryReference[];
|
|
22
|
+
};
|
|
23
|
+
export type NamedTypeRegistryGeneratorService<Name extends string = 'typeRegistryGenerator'> = NamedService<Name, ITypeRegistryGeneratorService>;
|
|
24
|
+
/**
|
|
25
|
+
* A class for building the type registry for a given module
|
|
26
|
+
*/
|
|
27
|
+
export declare class TypeRegistryGenerator implements ITypeRegistryGeneratorService {
|
|
28
|
+
protected services: NamedFileService & NamedTypeDefinitionService & NamedNormalizedTypeDefinitionService;
|
|
29
|
+
protected typeGenerator: INormalizedTypeGenerator;
|
|
30
|
+
protected filename: string;
|
|
31
|
+
constructor(services: NamedFileService & NamedTypeDefinitionService & NamedNormalizedTypeDefinitionService, typeGenerator: INormalizedTypeGenerator, filename?: string);
|
|
32
|
+
_file: File | undefined;
|
|
33
|
+
protected typeDeclarationsSymbol: symbol;
|
|
34
|
+
protected typeInstantiationsSymbol: symbol;
|
|
35
|
+
protected typeGettersSymbol: symbol;
|
|
36
|
+
cache: Map<string, TypeRepositoryReference>;
|
|
37
|
+
/**
|
|
38
|
+
* Note: Use with caution, it is only guaranteed to have the types with normalization
|
|
39
|
+
* after all operations precessing is complete.
|
|
40
|
+
*/
|
|
41
|
+
invalidatableTypes: TypeRepositoryReference[];
|
|
42
|
+
private get file();
|
|
43
|
+
private buildFile;
|
|
44
|
+
get template(): (symbol | Code)[];
|
|
45
|
+
/**
|
|
46
|
+
* A method for building the base type registry code, without any classes populated
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
build(): {
|
|
50
|
+
readonly filename: string;
|
|
51
|
+
readonly exportedSymbol: "TypeRegistry";
|
|
52
|
+
readonly isType: false;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A method for building/adding a specific type to the registry
|
|
56
|
+
* @param type The type to add to the registry
|
|
57
|
+
* @param options Options including namespace, name, and key overrides
|
|
58
|
+
* @returns The name of the method on the registry used to build the type, and an importable reference to the type class
|
|
59
|
+
*/
|
|
60
|
+
buildType(type: Type, options: Options): TypeRepositoryReference;
|
|
61
|
+
}
|
|
62
|
+
export declare const TYPE_REGISTRY_FILE = "normalization/type-registry.ts";
|
|
63
|
+
/**
|
|
64
|
+
* Creates a TypeRegistryGeneratorService.
|
|
65
|
+
*
|
|
66
|
+
**/
|
|
67
|
+
export declare function typeRegistryGeneratorService(services: NamedAPIService & NamedFileService & NamedTypeDefinitionService & NamedNormalizedTypeDefinitionService & NamedJSONSchemaDeclarationService & Partial<NamedNormalizeGeneratorService>, typeGenerator?: INormalizedTypeGenerator): ITypeRegistryGeneratorService;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UnidentifiableType } from '@conduit-client/model/v1';
|
|
2
|
+
import type { NamedNormalizedTypeDefinitionService, NamedTypeDefinitionService } from '../types';
|
|
3
|
+
import type { NamedTypeRegistryGeneratorService } from './type-registry-generator';
|
|
4
|
+
import { NamedNormalizeGeneratorService } from './normalize-code-gen/normalize-generator-service';
|
|
5
|
+
/**
|
|
6
|
+
* Generates the normalizer class for an unidentifiable type
|
|
7
|
+
* @param services The services required for this function. TypeDefinitionService is used to generate utility types.
|
|
8
|
+
* TypeRegistryGeneratorService is used to build references to child types
|
|
9
|
+
* @param type The type to generate the normalizer for
|
|
10
|
+
* @param options Options for generating the type, including the type name and namespace
|
|
11
|
+
* @returns Class name and code for the build type class
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateUnidentifiableType(services: NamedTypeDefinitionService & NamedTypeRegistryGeneratorService & NamedNormalizeGeneratorService & NamedNormalizedTypeDefinitionService, type: UnidentifiableType, options: {
|
|
14
|
+
namespace: string;
|
|
15
|
+
name: string;
|
|
16
|
+
className: string;
|
|
17
|
+
}): import("..").Code;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ImportableReference } from '../files';
|
|
2
|
+
export declare const CACHE: ImportableReference;
|
|
3
|
+
export declare const READONLY_CACHE: ImportableReference;
|
|
4
|
+
export declare const NORMALIZED_LINK: ImportableReference;
|
|
5
|
+
export declare const READ_ERRORS: ImportableReference;
|
|
6
|
+
export declare const WRITE_ERRORS: ImportableReference;
|
|
7
|
+
export declare const READ_INPUT: ImportableReference;
|
|
8
|
+
export declare const WRITE_INPUT: ImportableReference;
|
|
9
|
+
export declare const NORMALIZE_DATA_INPUT: ImportableReference;
|
|
10
|
+
export declare const DENORMALIZE_DATA_INPUT: ImportableReference;
|
|
11
|
+
export declare const EXTRACT_READ_WRITE_DATA: ImportableReference;
|
|
12
|
+
export declare const BUILD_READ_WRITE_RESULT: ImportableReference;
|
|
13
|
+
export declare const OK: ImportableReference;
|
|
14
|
+
export declare const RESULT: ImportableReference;
|
|
15
|
+
export declare const READ_RESULT: ImportableReference;
|
|
16
|
+
export declare const WRITE_RESULT: ImportableReference;
|
|
17
|
+
export declare const DEEP_EQUALS: ImportableReference;
|
|
18
|
+
export declare const NAMED_CACHE_CONTROLLER_SERVICE: ImportableReference;
|
|
19
|
+
export declare const NAMED_PUB_SUB_SERVICE: ImportableReference;
|
|
20
|
+
export declare const TYPE_SERVICES: import("..").Code;
|
|
21
|
+
export declare const NORMALIZE_UNION_REPRESENTATION: ImportableReference;
|
|
22
|
+
export declare const DENORMALIZE_UNION_REPRESENTATION: ImportableReference;
|
|
23
|
+
export declare const VALIDATE_JSON_SCHEMA: ImportableReference;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type NamedService } from '@conduit-client/utils';
|
|
2
|
+
import type { Type } from '@conduit-client/model/v1';
|
|
3
|
+
import type { APIService } from '@conduit-client/model/v1';
|
|
4
|
+
import type { Code, FileService } from '../files';
|
|
5
|
+
/**
|
|
6
|
+
* A JsonSchemaDeclarationService constructs & tracks JSONSchema definitions for types.
|
|
7
|
+
*/
|
|
8
|
+
export type JsonSchemaDeclarationService = {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a JSONSchema for a specified Type.
|
|
11
|
+
*
|
|
12
|
+
* @param type type to build JSON Schema for. The specified type can be a type in the TypeRegistry
|
|
13
|
+
* associated with this service, contain references to a type in the TypeRegistry, or be a standalone
|
|
14
|
+
* type with no connection to the TypeRegistry.
|
|
15
|
+
* @returns Code containing a TypeScript expression of the JSON schema for the type, eg "{type:'string'}"
|
|
16
|
+
* or "{type:'object',properties:{foo:{$ref:'#/$defs/bar'}},...<ImportableReference>}". The Code will contain
|
|
17
|
+
* ImportableReferences if the input type references any Types in the service's TypeRegistry.
|
|
18
|
+
*/
|
|
19
|
+
build(type: Type): Code;
|
|
20
|
+
};
|
|
21
|
+
export type NamedJSONSchemaDeclarationService<Name extends string = 'jsonSchema'> = NamedService<Name, JsonSchemaDeclarationService>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a JsonSchemaDeclarationService.
|
|
24
|
+
*
|
|
25
|
+
**/
|
|
26
|
+
export declare function jsonSchemaDeclarationService(services: {
|
|
27
|
+
api: APIService;
|
|
28
|
+
file: FileService;
|
|
29
|
+
}): JsonSchemaDeclarationService;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Type } from '@conduit-client/model/v1';
|
|
2
|
+
import type { JSONSchema, RefType } from '@conduit-client/jsonschema-validate';
|
|
3
|
+
type JsonSchemaForOptions = {
|
|
4
|
+
referenceFor?: (t: Type) => RefType | undefined;
|
|
5
|
+
useReferences?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Returns the JSON schema for a specified type.
|
|
9
|
+
*
|
|
10
|
+
* @param type the type
|
|
11
|
+
* @param options Options
|
|
12
|
+
* @returns JSON schema for type
|
|
13
|
+
*/
|
|
14
|
+
export declare function jsonSchemaFor(type: Type, options?: JsonSchemaForOptions): JSONSchema;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Type } from '@conduit-client/model/v1';
|
|
2
|
+
import { Code } from '../files';
|
|
3
|
+
import { TypeDefinitionForOptions, TypeDefinitionService } from './type-definition';
|
|
4
|
+
import { type NamedService } from '@conduit-client/utils';
|
|
5
|
+
import type { AllOfType, DiscriminatedObjectType, NamedAPIService, OneOf } from '@conduit-client/model/v1';
|
|
6
|
+
import type { NamedFileService } from '../files';
|
|
7
|
+
export type INormalizedTypeDefinitionService = {
|
|
8
|
+
buildReference(type: Type): Code;
|
|
9
|
+
buildRepresentation(type: Type): Code;
|
|
10
|
+
};
|
|
11
|
+
export declare const SINGLE_FILE_NORMALIZED: (_: string) => string;
|
|
12
|
+
export declare class NormalizedTypeDefinitionService extends TypeDefinitionService implements INormalizedTypeDefinitionService {
|
|
13
|
+
constructor(services: NamedAPIService & NamedFileService, fileFor?: (typename: string) => string);
|
|
14
|
+
buildReference(t: Type): Code;
|
|
15
|
+
buildRepresentation(t: Type): Code;
|
|
16
|
+
build(type: Type | undefined, useReferences?: boolean): Code;
|
|
17
|
+
buildAllOfCode(allOfType: AllOfType, options: TypeDefinitionForOptions): Code;
|
|
18
|
+
buildOneOfCode(t: OneOf, options: TypeDefinitionForOptions): Code;
|
|
19
|
+
buildDiscriminatedObjectCode(t: DiscriminatedObjectType, options: TypeDefinitionForOptions): Code;
|
|
20
|
+
getExportedSymbol(typename: string): string;
|
|
21
|
+
}
|
|
22
|
+
export type NamedNormalizedTypeDefinitionService = NamedService<'normalizedTypeDefinition', INormalizedTypeDefinitionService>;
|
|
23
|
+
export declare function normalizedTypeDefinitions(services: NamedAPIService & NamedFileService, options?: {
|
|
24
|
+
fileFor?: (typename: string) => string;
|
|
25
|
+
}): NormalizedTypeDefinitionService;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AllOfType, Type } from '@conduit-client/model/v1';
|
|
2
|
+
import { Result } from '@conduit-client/utils';
|
|
3
|
+
/**
|
|
4
|
+
* This function is intended to collapse an allOf type into it's concrete type
|
|
5
|
+
* This is allows code generation to operate on a single, canonical type definition
|
|
6
|
+
* that has had any composition resolved. This process occurs by recursively applying
|
|
7
|
+
* intersection between all the members of the allof. If at any point an intersection
|
|
8
|
+
* results in an "impossible" type, e.g. string & number, an error is thrown.
|
|
9
|
+
*
|
|
10
|
+
* Please reference the OpenAPI spec to see the intention of composed allOfs:
|
|
11
|
+
* https://spec.openapis.org/oas/v3.1.0.html#composition-and-inheritance-polymorphism
|
|
12
|
+
* @param type The all of type to resolve
|
|
13
|
+
* @returns a resolved type
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveAllOfType(type: AllOfType): Type;
|
|
16
|
+
export declare function intersectTypes(a: Type, b: Type): Result<Type, Error>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type NamedService } from '@conduit-client/utils';
|
|
2
|
+
import { Code } from '../files';
|
|
3
|
+
import type { ImportableReference, NamedFileService } from '../files';
|
|
4
|
+
import type { DiscriminatedObjectType, ObjectType, Type, RefType, AllOfType, OneOf } from '@conduit-client/model/v1';
|
|
5
|
+
import type { NamedAPIService } from '@conduit-client/model/v1';
|
|
6
|
+
export type TypeDefinitionForOptions = {
|
|
7
|
+
referenceFor?: (t: Type) => ImportableReference | undefined;
|
|
8
|
+
useReferences?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type ITypeDefinitionService = {
|
|
11
|
+
build(type: Type | undefined): Code;
|
|
12
|
+
};
|
|
13
|
+
export type NamedTypeDefinitionService = NamedService<'typeDefinition', ITypeDefinitionService>;
|
|
14
|
+
export declare class TypeDefinitionService implements ITypeDefinitionService {
|
|
15
|
+
protected services: NamedAPIService & NamedFileService;
|
|
16
|
+
private fileFor;
|
|
17
|
+
constructor(services: NamedAPIService & NamedFileService, fileFor?: (typename: string) => string);
|
|
18
|
+
cache: Map<string, ImportableReference>;
|
|
19
|
+
build(type: Type | undefined, useReferences?: boolean): Code;
|
|
20
|
+
buildTypeCode(t: Type, options: TypeDefinitionForOptions): Code;
|
|
21
|
+
buildReferenceCode(refType: RefType, options: TypeDefinitionForOptions): Code;
|
|
22
|
+
buildObjectCode(t: ObjectType, options: TypeDefinitionForOptions): Code;
|
|
23
|
+
buildDiscriminatedObjectCode(t: DiscriminatedObjectType, options: TypeDefinitionForOptions): Code;
|
|
24
|
+
buildObjectProperties(t: ObjectType, options: TypeDefinitionForOptions): Code[];
|
|
25
|
+
buildAdditionalProperties(t: ObjectType, options: TypeDefinitionForOptions): Code[];
|
|
26
|
+
buildAllOfCode(t: AllOfType, options: TypeDefinitionForOptions): Code;
|
|
27
|
+
buildOneOfCode(t: OneOf, options: TypeDefinitionForOptions): Code;
|
|
28
|
+
getExportedSymbol(typename: string): string;
|
|
29
|
+
buildTypeDeclaration(typename: string): ImportableReference;
|
|
30
|
+
}
|
|
31
|
+
export declare function typeDefinitions(services: NamedAPIService & NamedFileService, options?: {
|
|
32
|
+
fileFor?: (typename: string) => string;
|
|
33
|
+
}): TypeDefinitionService;
|
|
34
|
+
export declare const FILE_PER_TYPE: (typename: string) => string;
|
|
35
|
+
export declare const SINGLE_FILE: (_: string) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Parameter, Type, TypeOfParameter } from '@conduit-client/model/v1';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a set of parameter specification from Record<string, Parameter> to a list of named parameters info.
|
|
4
|
+
* Performs dupe parameters detection.
|
|
5
|
+
*
|
|
6
|
+
* @param records the parameter specifications to convert
|
|
7
|
+
* @returns a list of parameters info
|
|
8
|
+
*/
|
|
9
|
+
export declare function getParameterMembers<T extends Type = TypeOfParameter<Parameter>>(...records: Record<string, Parameter<T>>[]): {
|
|
10
|
+
name: string;
|
|
11
|
+
type: T;
|
|
12
|
+
required: boolean;
|
|
13
|
+
explode?: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const getQueryParameterMembers: (...records: Record<string, Parameter<import("@conduit-client/model/v1").ScalarType | ({
|
|
16
|
+
type: "array";
|
|
17
|
+
items: Type;
|
|
18
|
+
} & import("@conduit-client/model/v1").BaseType & {
|
|
19
|
+
items?: import("@conduit-client/model/v1").ScalarType;
|
|
20
|
+
})>>[]) => {
|
|
21
|
+
name: string;
|
|
22
|
+
type: import("@conduit-client/model/v1").ScalarType | ({
|
|
23
|
+
type: "array";
|
|
24
|
+
items: Type;
|
|
25
|
+
} & import("@conduit-client/model/v1").BaseType & {
|
|
26
|
+
items?: import("@conduit-client/model/v1").ScalarType;
|
|
27
|
+
});
|
|
28
|
+
required: boolean;
|
|
29
|
+
explode?: boolean;
|
|
30
|
+
}[];
|