Skip to content

Commit e6c1a85

Browse files
authored
refactor: classified the store (#44)
1 parent 0674443 commit e6c1a85

File tree

21 files changed

+137
-143
lines changed

21 files changed

+137
-143
lines changed

src/internal/OpenApiTools/Extractor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CodeGenerator, OpenApi } from "../../types";
22
import * as ConverterContext from "./ConverterContext";
3-
import { Store } from "./store";
3+
import type { Store } from "./store";
44

55
const extractPickedParameter = (parameter: OpenApi.Parameter): CodeGenerator.PickedParameter => {
66
return {
@@ -56,7 +56,7 @@ const hasQueryParameters = (parameters?: OpenApi.Parameter[]): boolean => {
5656
};
5757

5858
export const generateCodeGeneratorParamsArray = (
59-
store: Store.Type,
59+
store: Store,
6060
converterContext: ConverterContext.Types,
6161
allowOperationIds: string[] | undefined,
6262
): CodeGenerator.Params[] => {

src/internal/OpenApiTools/Parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as TypeNodeContext from "./TypeNodeContext";
1616
export class Parser {
1717
private currentPoint: string;
1818
private convertContext: ConvertContext.Types;
19-
private store: Store.Type;
19+
private store: Store;
2020
private factory: TypeScriptCodeGenerator.Factory.Type;
2121
constructor(
2222
private entryPoint: string,
@@ -26,7 +26,7 @@ export class Parser {
2626
this.currentPoint = entryPoint;
2727
this.convertContext = ConvertContext.create();
2828
this.factory = TypeScriptCodeGenerator.Factory.create();
29-
this.store = Store.create(this.factory, noReferenceOpenApiSchema);
29+
this.store = new Store(this.factory, noReferenceOpenApiSchema);
3030
this.initialize();
3131
}
3232

src/internal/OpenApiTools/TypeNodeContext.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ts from "typescript";
55
import { DevelopmentError } from "../Exception";
66
import * as TypeScriptCodeGenerator from "../TsGenerator";
77
import * as ConverterContext from "./ConverterContext";
8-
import { Store } from "./store";
8+
import type { Store } from "./store";
99
import * as ToTypeNode from "./toTypeNode";
1010

1111
export interface ReferencePathSet {
@@ -25,7 +25,7 @@ const generatePath = (entryPoint: string, currentPoint: string, referencePath: s
2525
};
2626
};
2727

28-
const calculateReferencePath = (store: Store.Type, base: string, pathArray: string[]): ToTypeNode.ResolveReferencePath => {
28+
const calculateReferencePath = (store: Store, base: string, pathArray: string[]): ToTypeNode.ResolveReferencePath => {
2929
let names: string[] = [];
3030
let unresolvedPaths: string[] = [];
3131
pathArray.reduce((previous, lastPath, index) => {
@@ -75,7 +75,7 @@ const calculateReferencePath = (store: Store.Type, base: string, pathArray: stri
7575

7676
export const create = (
7777
entryPoint: string,
78-
store: Store.Type,
78+
store: Store,
7979
factory: TypeScriptCodeGenerator.Factory.Type,
8080
converterContext: ConverterContext.Types,
8181
): ToTypeNode.Context => {

src/internal/OpenApiTools/components/Headers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Factory } from "../../TsGenerator";
44
import * as ConverterContext from "../ConverterContext";
55
import * as Guard from "../Guard";
66
import * as Name from "../Name";
7-
import { Store } from "../store";
7+
import type { Store } from "../store";
88
import * as ToTypeNode from "../toTypeNode";
99
import * as Header from "./Header";
1010
import * as Reference from "./Reference";
@@ -13,7 +13,7 @@ import * as Schema from "./Schema";
1313
export const generateNamespace = (
1414
entryPoint: string,
1515
currentPoint: string,
16-
store: Store.Type,
16+
store: Store,
1717
factory: Factory.Type,
1818
headers: Record<string, OpenApi.Header | OpenApi.Reference>,
1919
context: ToTypeNode.Context,

src/internal/OpenApiTools/components/Operation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Factory } from "../../TsGenerator";
88
import * as ConverterContext from "../ConverterContext";
99
import * as Guard from "../Guard";
1010
import * as Name from "../Name";
11-
import { Store } from "../store";
11+
import type { Store } from "../store";
1212
import * as ToTypeNode from "../toTypeNode";
1313
import * as ExternalDocumentation from "./ExternalDocumentation";
1414
import * as Parameter from "./Parameter";
@@ -35,7 +35,7 @@ const generateComment = (operation: OpenApi.Operation): string => {
3535
export const generateNamespace = (
3636
entryPoint: string,
3737
currentPoint: string,
38-
store: Store.Type,
38+
store: Store,
3939
factory: Factory.Type,
4040
parentPath: string,
4141
name: string,
@@ -131,7 +131,7 @@ export const generateNamespace = (
131131
export const generateStatements = (
132132
entryPoint: string,
133133
currentPoint: string,
134-
store: Store.Type,
134+
store: Store,
135135
factory: Factory.Type,
136136
requestUri: string,
137137
httpMethod: string, // PUT POST PATCH

src/internal/OpenApiTools/components/Parameter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { OpenApi } from "../../../types";
44
import { Factory } from "../../TsGenerator";
55
import * as ConverterContext from "../ConverterContext";
66
import * as Guard from "../Guard";
7-
import { Store } from "../store";
7+
import type { Store } from "../store";
88
import * as ToTypeNode from "../toTypeNode";
99
import * as Reference from "./Reference";
1010

@@ -39,7 +39,7 @@ export const generateTypeAlias = (
3939
export const generatePropertySignature = (
4040
entryPoint: string,
4141
currentPoint: string,
42-
store: Store.Type,
42+
store: Store,
4343
factory: Factory.Type,
4444
parameter: OpenApi.Parameter | OpenApi.Reference,
4545
context: ToTypeNode.Context,
@@ -86,7 +86,7 @@ export const generatePropertySignature = (
8686
export const generatePropertySignatures = (
8787
entryPoint: string,
8888
currentPoint: string,
89-
store: Store.Type,
89+
store: Store,
9090
factory: Factory.Type,
9191
parameters: (OpenApi.Parameter | OpenApi.Reference)[],
9292
context: ToTypeNode.Context,
@@ -100,7 +100,7 @@ export const generatePropertySignatures = (
100100
export const generateInterface = (
101101
entryPoint: string,
102102
currentPoint: string,
103-
store: Store.Type,
103+
store: Store,
104104
factory: Factory.Type,
105105
name: string,
106106
parameters: [OpenApi.Parameter | OpenApi.Reference],
@@ -120,7 +120,7 @@ export const generateInterface = (
120120
export const generateAliasInterface = (
121121
entryPoint: string,
122122
currentPoint: string,
123-
store: Store.Type,
123+
store: Store,
124124
factory: Factory.Type,
125125
name: string,
126126
parameters: (OpenApi.Parameter | OpenApi.Reference)[],

src/internal/OpenApiTools/components/Parameters.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Factory } from "../../TsGenerator";
44
import * as ConverterContext from "../ConverterContext";
55
import * as Guard from "../Guard";
66
import * as Name from "../Name";
7-
import { Store } from "../store";
7+
import type { Store } from "../store";
88
import * as ToTypeNode from "../toTypeNode";
99
import * as Paramter from "./Parameter";
1010
import * as Reference from "./Reference";
@@ -13,7 +13,7 @@ import * as Schema from "./Schema";
1313
export const generateNamespace = (
1414
entryPoint: string,
1515
currentPoint: string,
16-
store: Store.Type,
16+
store: Store,
1717
factory: Factory.Type,
1818
parameters: Record<string, OpenApi.Parameter | OpenApi.Reference>,
1919
context: ToTypeNode.Context,
@@ -71,7 +71,7 @@ export const generateNamespace = (
7171
export const generateNamespaceWithList = (
7272
entryPoint: string,
7373
currentPoint: string,
74-
store: Store.Type,
74+
store: Store,
7575
factory: Factory.Type,
7676
parameters: (OpenApi.Parameter | OpenApi.Reference)[],
7777
context: ToTypeNode.Context,

src/internal/OpenApiTools/components/PathItem.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ts from "typescript";
33
import type { OpenApi } from "../../../types";
44
import { Factory } from "../../TsGenerator";
55
import * as ConverterContext from "../ConverterContext";
6-
import { Store } from "../store";
6+
import type { Store } from "../store";
77
import * as ToTypeNode from "../toTypeNode";
88
import * as Operation from "./Operation";
99
import * as Parameters from "./Parameters";
@@ -12,7 +12,7 @@ import * as Servers from "./Servers";
1212
export const generateNamespace = (
1313
entryPoint: string,
1414
currentPoint: string,
15-
store: Store.Type,
15+
store: Store,
1616
factory: Factory.Type,
1717
parentPath: string,
1818
name: string,
@@ -60,7 +60,7 @@ export const generateNamespace = (
6060
export const generateStatements = (
6161
entryPoint: string,
6262
currentPoint: string,
63-
store: Store.Type,
63+
store: Store,
6464
factory: Factory.Type,
6565
requestUri: string,
6666
pathItem: OpenApi.PathItem,

src/internal/OpenApiTools/components/PathItems.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Factory } from "../../TsGenerator";
44
import * as ConverterContext from "../ConverterContext";
55
import * as Guard from "../Guard";
66
import * as Name from "../Name";
7-
import { Store } from "../store";
7+
import type { Store } from "../store";
88
import * as ToTypeNode from "../toTypeNode";
99
import * as PathItem from "./PathItem";
1010
import * as Reference from "./Reference";
@@ -13,7 +13,7 @@ import * as Reference from "./Reference";
1313
export const generateNamespace = (
1414
entryPoint: string,
1515
currentPoint: string,
16-
store: Store.Type,
16+
store: Store,
1717
factory: Factory.Type,
1818
pathItems: Record<string, OpenApi.PathItem | OpenApi.Reference>,
1919
context: ToTypeNode.Context,

src/internal/OpenApiTools/components/RequestBodies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { Factory } from "../../TsGenerator";
55
import * as ConverterContext from "../ConverterContext";
66
import * as Guard from "../Guard";
77
import * as Name from "../Name";
8-
import { Store } from "../store";
8+
import type { Store } from "../store";
99
import * as ToTypeNode from "../toTypeNode";
1010
import * as Reference from "./Reference";
1111
import * as RequestBody from "./RequestBody";
1212

1313
export const generateNamespace = (
1414
entryPoint: string,
1515
currentPoint: string,
16-
store: Store.Type,
16+
store: Store,
1717
factory: Factory.Type,
1818
requestBodies: Record<string, OpenApi.RequestBody | OpenApi.Reference>,
1919
context: ToTypeNode.Context,

0 commit comments

Comments
 (0)