@skmtc/core 0.0.263 → 0.0.265
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/esm/context/CoreContext.d.ts +9 -21
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +4 -4
- package/esm/context/GenerateContext.d.ts +14 -18
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +6 -6
- package/esm/dsl/ModelDriver.d.ts +10 -10
- package/esm/dsl/ModelDriver.d.ts.map +1 -1
- package/esm/dsl/ModelDriver.js +33 -21
- package/esm/dsl/{ModelCreator.d.ts → ModelInsertable.d.ts} +2 -14
- package/esm/dsl/ModelInsertable.d.ts.map +1 -0
- package/esm/dsl/OperationDriver.d.ts +10 -10
- package/esm/dsl/OperationDriver.d.ts.map +1 -1
- package/esm/dsl/OperationDriver.js +33 -22
- package/{script/dsl/OperationCreator.d.ts → esm/dsl/OperationInsertable.d.ts} +2 -2
- package/esm/dsl/OperationInsertable.d.ts.map +1 -0
- package/esm/dsl/base.d.ts +5 -5
- package/esm/dsl/base.d.ts.map +1 -1
- package/esm/dsl/base.js +3 -3
- package/esm/dsl/withConfig.d.ts +13 -13
- package/esm/dsl/withConfig.d.ts.map +1 -1
- package/esm/dsl/withConfig.js +2 -2
- package/esm/generate/generate.d.ts +2 -2
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/mod.d.ts +2 -4
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -4
- package/esm/server/createServer.d.ts +2 -2
- package/esm/server/createServer.d.ts.map +1 -1
- package/esm/types/GeneratedValue.d.ts +13 -0
- package/esm/types/GeneratedValue.d.ts.map +1 -1
- package/esm/types/GeneratorKeys.d.ts +1 -1
- package/esm/types/GeneratorKeys.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +9 -21
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +4 -4
- package/script/context/GenerateContext.d.ts +14 -18
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +6 -6
- package/script/dsl/ModelDriver.d.ts +10 -10
- package/script/dsl/ModelDriver.d.ts.map +1 -1
- package/script/dsl/ModelDriver.js +33 -21
- package/script/dsl/{ModelCreator.d.ts → ModelInsertable.d.ts} +2 -14
- package/script/dsl/ModelInsertable.d.ts.map +1 -0
- package/script/dsl/OperationDriver.d.ts +10 -10
- package/script/dsl/OperationDriver.d.ts.map +1 -1
- package/script/dsl/OperationDriver.js +33 -22
- package/{esm/dsl/OperationCreator.d.ts → script/dsl/OperationInsertable.d.ts} +2 -2
- package/script/dsl/OperationInsertable.d.ts.map +1 -0
- package/script/dsl/base.d.ts +5 -5
- package/script/dsl/base.d.ts.map +1 -1
- package/script/dsl/base.js +3 -3
- package/script/dsl/withConfig.d.ts +13 -13
- package/script/dsl/withConfig.d.ts.map +1 -1
- package/script/dsl/withConfig.js +5 -5
- package/script/generate/generate.d.ts +2 -2
- package/script/generate/generate.d.ts.map +1 -1
- package/script/mod.d.ts +2 -4
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +2 -4
- package/script/server/createServer.d.ts +2 -2
- package/script/server/createServer.d.ts.map +1 -1
- package/script/types/GeneratedValue.d.ts +13 -0
- package/script/types/GeneratedValue.d.ts.map +1 -1
- package/script/types/GeneratorKeys.d.ts +1 -1
- package/script/types/GeneratorKeys.d.ts.map +1 -1
- package/esm/dsl/ModelCreator.d.ts.map +0 -1
- package/esm/dsl/OperationCreator.d.ts.map +0 -1
- package/esm/helpers/verifyType.d.ts +0 -4
- package/esm/helpers/verifyType.d.ts.map +0 -1
- package/esm/helpers/verifyType.js +0 -12
- package/esm/types/GenerationType.d.ts +0 -16
- package/esm/types/GenerationType.d.ts.map +0 -1
- package/esm/types/GenerationType.js +0 -15
- package/esm/typescript/toOperationResponse.d.ts +0 -16
- package/esm/typescript/toOperationResponse.d.ts.map +0 -1
- package/esm/typescript/toOperationResponse.js +0 -17
- package/script/dsl/ModelCreator.d.ts.map +0 -1
- package/script/dsl/OperationCreator.d.ts.map +0 -1
- package/script/helpers/verifyType.d.ts +0 -4
- package/script/helpers/verifyType.d.ts.map +0 -1
- package/script/helpers/verifyType.js +0 -15
- package/script/types/GenerationType.d.ts +0 -16
- package/script/types/GenerationType.d.ts.map +0 -1
- package/script/types/GenerationType.js +0 -16
- package/script/typescript/toOperationResponse.d.ts +0 -16
- package/script/typescript/toOperationResponse.d.ts.map +0 -1
- package/script/typescript/toOperationResponse.js +0 -21
- /package/esm/dsl/{ModelCreator.js → ModelInsertable.js} +0 -0
- /package/esm/dsl/{OperationCreator.js → OperationInsertable.js} +0 -0
- /package/script/dsl/{ModelCreator.js → ModelInsertable.js} +0 -0
- /package/script/dsl/{OperationCreator.js → OperationInsertable.js} +0 -0
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import type { ParseContext } from './ParseContext.js';
|
|
2
1
|
import { GenerateContext } from './GenerateContext.js';
|
|
3
|
-
import type { AddRenderDependencyArgs, GetModelSettingsArgs, GetOperationSettingsArgs, PickArgs, RegisterArgs,
|
|
4
|
-
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
5
|
-
import type { OasDocument } from '../oas/document/Document.js';
|
|
2
|
+
import type { AddRenderDependencyArgs, GetModelSettingsArgs, GetOperationSettingsArgs, PickArgs, RegisterArgs, InsertReturn, InsertArgs } from './GenerateContext.js';
|
|
6
3
|
import { RenderContext, type FilesRenderResult } from './RenderContext.js';
|
|
7
4
|
import type { AddGeneratorKeyArgs, FileContents, RenderDependencies, RenderOptions } from './types.js';
|
|
5
|
+
import type { ParseContext } from './ParseContext.js';
|
|
6
|
+
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
7
|
+
import type { OasDocument } from '../oas/document/Document.js';
|
|
8
8
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
9
9
|
import type { BaseSettings, ClientSettings } from '../types/Settings.js';
|
|
10
10
|
import type { Definition } from '../dsl/Definition.js';
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
11
|
+
import type { OperationGenerator } from '../dsl/OperationInsertable.js';
|
|
12
|
+
import type { ModelGenerator } from '../dsl/ModelInsertable.js';
|
|
13
13
|
import type { GeneratedValue } from '../types/GeneratedValue.js';
|
|
14
14
|
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
15
15
|
import type { OasRef } from '../oas/ref/Ref.js';
|
|
16
|
-
import type {
|
|
17
|
-
import type { GenerationType } from '../types/GenerationType.js';
|
|
16
|
+
import type { GenerationType } from '../types/GeneratedValue.js';
|
|
18
17
|
import type { RefName } from '../types/RefName.js';
|
|
19
|
-
type TransformArgs<V extends GeneratedValue> = {
|
|
20
|
-
creator: OperationCreator<V>;
|
|
21
|
-
operation: OasOperation;
|
|
22
|
-
generation?: GenerationType;
|
|
23
|
-
destinationPath?: string;
|
|
24
|
-
} | {
|
|
25
|
-
creator: ModelCreator<V>;
|
|
26
|
-
refName: RefName;
|
|
27
|
-
generation?: GenerationType;
|
|
28
|
-
destinationPath?: string;
|
|
29
|
-
};
|
|
30
18
|
type SharedContext = {
|
|
31
19
|
type: 'parse';
|
|
32
20
|
context: ParseContext;
|
|
@@ -63,11 +51,11 @@ export declare class CoreContext {
|
|
|
63
51
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
64
52
|
addRenderDependency(args: AddRenderDependencyArgs): void;
|
|
65
53
|
getFile(filePath: string): FileContents;
|
|
66
|
-
|
|
54
|
+
findDefinition(args: PickArgs): Definition<GeneratedValue> | undefined;
|
|
67
55
|
render(options: RenderOptions): FilesRenderResult;
|
|
68
56
|
addFile(normalisedPath: string): FileContents;
|
|
69
57
|
getOperationBaseSettings(args: GetOperationSettingsArgs): BaseSettings;
|
|
70
|
-
|
|
58
|
+
insert<V extends GeneratedValue, T extends GenerationType>(args: InsertArgs<V, T>): InsertReturn<V, T>;
|
|
71
59
|
getModelBaseSettings(args: GetModelSettingsArgs): BaseSettings;
|
|
72
60
|
get files(): Map<string, FileContents>;
|
|
73
61
|
get renderDependencies(): RenderDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CoreContext.d.ts","sourceRoot":"","sources":["../../src/context/CoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC1E,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACd,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,E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97
97
|
.exhaustive();
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
findDefinition(args) {
|
|
100
100
|
return match(this.phase)
|
|
101
|
-
.with({ type: 'generate' }, ({ context }) => context.
|
|
101
|
+
.with({ type: 'generate' }, ({ context }) => context.findDefinition(args))
|
|
102
102
|
.with({ type: 'parse' }, () => {
|
|
103
103
|
throw new Error(`Cannot pick during parse phase`);
|
|
104
104
|
})
|
|
@@ -142,10 +142,10 @@ export class CoreContext {
|
|
|
142
142
|
})
|
|
143
143
|
.exhaustive();
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
insert(args) {
|
|
146
146
|
return match(this.phase)
|
|
147
147
|
.with({ type: 'generate' }, ({ context }) => {
|
|
148
|
-
return context.
|
|
148
|
+
return context.insert({ ...args, coreContext: this });
|
|
149
149
|
})
|
|
150
150
|
.with({ type: 'parse' }, () => {
|
|
151
151
|
throw new Error(`Cannot run 'transform' during parse phase`);
|
|
@@ -6,12 +6,11 @@ import type { OasRef } from '../oas/ref/Ref.js';
|
|
|
6
6
|
import type { FileContents, GetFileOptions, RenderDependencies } from './types.js';
|
|
7
7
|
import type { BaseSettings, ClientSettings } from '../types/Settings.js';
|
|
8
8
|
import type { Method } from '../types/Method.js';
|
|
9
|
-
import type {
|
|
9
|
+
import type { OperationInsertable, OperationGenerator } from '../dsl/OperationInsertable.js';
|
|
10
10
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
11
11
|
import type { CoreContext } from './CoreContext.js';
|
|
12
|
-
import type {
|
|
13
|
-
import type { GenerationType } from '../types/
|
|
14
|
-
import type { GeneratedValue } from '../types/GeneratedValue.js';
|
|
12
|
+
import type { ModelInsertable, ModelGenerator } from '../dsl/ModelInsertable.js';
|
|
13
|
+
import type { GenerationType, GeneratedDefintion, GeneratedValue } from '../types/GeneratedValue.js';
|
|
15
14
|
import type { ContentSettings } from '../dsl/ContentSettings.js';
|
|
16
15
|
import type { RefName } from '../types/RefName.js';
|
|
17
16
|
type ConstructorArgs = {
|
|
@@ -43,22 +42,20 @@ export type GetModelSettingsArgs = {
|
|
|
43
42
|
generatorId: string;
|
|
44
43
|
refName: RefName;
|
|
45
44
|
};
|
|
46
|
-
export type
|
|
47
|
-
|
|
48
|
-
creator: OperationCreator<V>;
|
|
45
|
+
export type InsertArgs<V extends GeneratedValue, T extends GenerationType> = {
|
|
46
|
+
insertable: OperationInsertable<V>;
|
|
49
47
|
operation: OasOperation;
|
|
50
|
-
generation?:
|
|
48
|
+
generation?: T;
|
|
51
49
|
destinationPath?: string;
|
|
52
50
|
} | {
|
|
53
|
-
|
|
54
|
-
creator: ModelCreator<V>;
|
|
51
|
+
insertable: ModelInsertable<V>;
|
|
55
52
|
refName: RefName;
|
|
56
|
-
generation?:
|
|
53
|
+
generation?: T;
|
|
57
54
|
destinationPath?: string;
|
|
58
55
|
};
|
|
59
|
-
export type
|
|
56
|
+
export type InsertReturn<V extends GeneratedValue, T extends GenerationType> = {
|
|
60
57
|
settings: ContentSettings;
|
|
61
|
-
definition:
|
|
58
|
+
definition: GeneratedDefintion<V, T>;
|
|
62
59
|
};
|
|
63
60
|
export declare class GenerateContext {
|
|
64
61
|
files: Map<string, FileContents>;
|
|
@@ -70,17 +67,16 @@ export declare class GenerateContext {
|
|
|
70
67
|
constructor({ schemaModel, generatorsMap, settings }: ConstructorArgs);
|
|
71
68
|
getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
|
|
72
69
|
register({ imports, packageDependencies, definitions, destinationPath }: RegisterArgs): void;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
70
|
+
insert<V extends GeneratedValue, T extends GenerationType>({ coreContext, generation, destinationPath, ...rest }: InsertArgs<V, T> & {
|
|
71
|
+
coreContext: CoreContext;
|
|
72
|
+
}): InsertReturn<V, T>;
|
|
77
73
|
getOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
|
|
78
74
|
getModelBaseSettings({ generatorId, refName }: GetModelSettingsArgs): BaseSettings;
|
|
79
75
|
addFile(normalisedPath: string): FileContents;
|
|
80
76
|
resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
|
|
81
77
|
addRenderDependency({ generatorId, dependencies, operation }: AddRenderDependencyArgs): void;
|
|
82
78
|
/** Produce external instance and return its name */
|
|
83
|
-
|
|
79
|
+
findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
|
|
84
80
|
}
|
|
85
81
|
export {};
|
|
86
82
|
//# sourceMappingURL=GenerateContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,kBAAkB,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EA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E,WAAW,CAAA;IACxB,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAAC,CAAA;gBAEtD,EAAE,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,EAAE,eAAe;IASrE,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,EAAE,eAAuB,EAAE,GAAE,cAAmB,GAC/C,YAAY;IAgBf,QAAQ,CAAC,EACP,OAAY,EACZ,mBAAwB,EACxB,WAAW,EACX,eAAe,EAChB,EAAE,YAAY;IA6Bf,MAAM,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,EAAE,EACzD,WAAW,EACX,UAAU,EACV,eAAe,EACf,GAAG,IAAI,EACR,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IA4BvE,wBAAwB,CAAC,EACvB,WAAW,EACX,IAAI,EACJ,MAAM,EACP,EAAE,wBAAwB;IAwB3B,oBAAoB,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,oBAAoB;IAwBnE,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY;IAgB7C,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAWpE,mBAAmB,CAAC,EAClB,WAAW,EACX,YAAY,EACZ,SAAS,EACV,EAAE,uBAAuB;IAc1B,oDAAoD;IACpD,cAAc,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS;CAGvE"}
|
|
@@ -82,12 +82,12 @@ export class GenerateContext {
|
|
|
82
82
|
currentFile.definitions.set(`${definition.identifier}`, definition);
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
insert({ coreContext, generation, destinationPath, ...rest }) {
|
|
86
86
|
if ('operation' in rest) {
|
|
87
|
-
const {
|
|
87
|
+
const { insertable, operation } = rest;
|
|
88
88
|
const { settings, definition } = new OperationDriver({
|
|
89
89
|
context: coreContext,
|
|
90
|
-
|
|
90
|
+
insertable,
|
|
91
91
|
operation,
|
|
92
92
|
generation,
|
|
93
93
|
destinationPath
|
|
@@ -95,10 +95,10 @@ export class GenerateContext {
|
|
|
95
95
|
return { settings, definition };
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
|
-
const {
|
|
98
|
+
const { insertable, refName } = rest;
|
|
99
99
|
const { settings, definition } = new ModelDriver({
|
|
100
100
|
context: coreContext,
|
|
101
|
-
|
|
101
|
+
insertable,
|
|
102
102
|
refName,
|
|
103
103
|
generation,
|
|
104
104
|
destinationPath
|
|
@@ -167,7 +167,7 @@ export class GenerateContext {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
/** Produce external instance and return its name */
|
|
170
|
-
|
|
170
|
+
findDefinition({ name, exportPath }) {
|
|
171
171
|
return this.getFile(exportPath).definitions.get(name);
|
|
172
172
|
}
|
|
173
173
|
}
|
package/esm/dsl/ModelDriver.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModelInsertable } from './ModelInsertable.js';
|
|
2
2
|
import type { CoreContext } from '../context/CoreContext.js';
|
|
3
3
|
import { ContentSettings } from './ContentSettings.js';
|
|
4
|
-
import {
|
|
5
|
-
import type { GenerationType } from '../types/GenerationType.js';
|
|
4
|
+
import type { GeneratedDefintion, GenerationType } from '../types/GeneratedValue.js';
|
|
6
5
|
import type { GeneratedValue } from '../types/GeneratedValue.js';
|
|
7
6
|
import type { RefName } from '../types/RefName.js';
|
|
8
|
-
type CreateModelArgs<V extends GeneratedValue> = {
|
|
7
|
+
type CreateModelArgs<V extends GeneratedValue, T extends GenerationType> = {
|
|
9
8
|
context: CoreContext;
|
|
10
|
-
|
|
9
|
+
insertable: ModelInsertable<V>;
|
|
11
10
|
refName: RefName;
|
|
12
|
-
generation?:
|
|
11
|
+
generation?: T;
|
|
13
12
|
destinationPath?: string;
|
|
14
13
|
};
|
|
15
|
-
export declare class ModelDriver<V extends GeneratedValue> {
|
|
14
|
+
export declare class ModelDriver<V extends GeneratedValue, T extends GenerationType> {
|
|
16
15
|
context: CoreContext;
|
|
17
|
-
|
|
16
|
+
insertable: ModelInsertable<V>;
|
|
18
17
|
refName: RefName;
|
|
19
18
|
settings: ContentSettings;
|
|
20
19
|
destinationPath?: string;
|
|
21
|
-
definition:
|
|
22
|
-
constructor({ context,
|
|
20
|
+
definition: GeneratedDefintion<V, T>;
|
|
21
|
+
constructor({ context, insertable, refName, generation, destinationPath }: CreateModelArgs<V, T>);
|
|
23
22
|
get value(): V;
|
|
24
23
|
get name(): string;
|
|
25
24
|
get exportPath(): string;
|
|
26
25
|
private apply;
|
|
27
26
|
private getDefinition;
|
|
28
27
|
private buildModelSettings;
|
|
28
|
+
private affirmDefinition;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
31
31
|
//# sourceMappingURL=ModelDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelDriver.d.ts","sourceRoot":"","sources":["../../src/dsl/ModelDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ModelDriver.d.ts","sourceRoot":"","sources":["../../src/dsl/ModelDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAKtD,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,IAAI;IACzE,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAgBD,qBAAa,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc;IACzE,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBACxB,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,UAAU,EACV,eAAe,EAChB,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAaxB,IAAI,KAAK,IAAI,CAAC,CAQb;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,OAAO,CAAC,KAAK;IAyBb,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,gBAAgB;CAoBzB"}
|
package/esm/dsl/ModelDriver.js
CHANGED
|
@@ -3,16 +3,16 @@ import { normalize } from '../deps/jsr.io/@std/path/1.0.0/mod.js';
|
|
|
3
3
|
import { Definition } from './Definition.js';
|
|
4
4
|
import { Identifier } from './Identifier.js';
|
|
5
5
|
import { match } from 'ts-pattern';
|
|
6
|
-
import {
|
|
6
|
+
import { toModelGeneratorKey } from '../types/GeneratorKeys.js';
|
|
7
7
|
export class ModelDriver {
|
|
8
|
-
constructor({ context,
|
|
8
|
+
constructor({ context, insertable, refName, generation, destinationPath }) {
|
|
9
9
|
Object.defineProperty(this, "context", {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
configurable: true,
|
|
12
12
|
writable: true,
|
|
13
13
|
value: void 0
|
|
14
14
|
});
|
|
15
|
-
Object.defineProperty(this, "
|
|
15
|
+
Object.defineProperty(this, "insertable", {
|
|
16
16
|
enumerable: true,
|
|
17
17
|
configurable: true,
|
|
18
18
|
writable: true,
|
|
@@ -43,18 +43,18 @@ export class ModelDriver {
|
|
|
43
43
|
value: void 0
|
|
44
44
|
});
|
|
45
45
|
this.context = context;
|
|
46
|
-
this.
|
|
46
|
+
this.insertable = insertable;
|
|
47
47
|
this.refName = refName;
|
|
48
48
|
this.destinationPath = destinationPath;
|
|
49
|
-
this.settings = this.buildModelSettings({ refName,
|
|
49
|
+
this.settings = this.buildModelSettings({ refName, insertable });
|
|
50
50
|
this.definition = this.apply({
|
|
51
|
-
|
|
51
|
+
generation,
|
|
52
52
|
destinationPath
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
get value() {
|
|
56
56
|
if (!this.definition) {
|
|
57
|
-
throw new Error(`${this.
|
|
57
|
+
throw new Error(`${this.insertable.id} ${this.refName}: definition is undefined`);
|
|
58
58
|
}
|
|
59
59
|
return this.definition.value;
|
|
60
60
|
}
|
|
@@ -64,10 +64,10 @@ export class ModelDriver {
|
|
|
64
64
|
get exportPath() {
|
|
65
65
|
return this.settings.exportPath;
|
|
66
66
|
}
|
|
67
|
-
apply({
|
|
67
|
+
apply({ generation, destinationPath } = {}) {
|
|
68
68
|
const { name, exportPath, selected, importFrom } = this.settings;
|
|
69
|
-
if (!selected &&
|
|
70
|
-
return;
|
|
69
|
+
if (!selected && generation !== 'force') {
|
|
70
|
+
return undefined;
|
|
71
71
|
}
|
|
72
72
|
const definition = this.getDefinition({ name, exportPath });
|
|
73
73
|
if (destinationPath &&
|
|
@@ -80,12 +80,11 @@ export class ModelDriver {
|
|
|
80
80
|
return definition;
|
|
81
81
|
}
|
|
82
82
|
getDefinition({ name, exportPath }) {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
return existing;
|
|
83
|
+
const cachedDefinition = this.context.findDefinition({ name, exportPath });
|
|
84
|
+
if (this.affirmDefinition(cachedDefinition)) {
|
|
85
|
+
return cachedDefinition;
|
|
87
86
|
}
|
|
88
|
-
const value = new this.
|
|
87
|
+
const value = new this.insertable({
|
|
89
88
|
refName: this.refName,
|
|
90
89
|
context: this.context,
|
|
91
90
|
settings: this.settings,
|
|
@@ -98,7 +97,7 @@ export class ModelDriver {
|
|
|
98
97
|
typeof value.tsType === 'string'
|
|
99
98
|
? value.tsType
|
|
100
99
|
: undefined;
|
|
101
|
-
const identifier = match(this.
|
|
100
|
+
const identifier = match(this.insertable.entityType.type)
|
|
102
101
|
.with('value', () => Identifier.createValue({ name, tsType }))
|
|
103
102
|
.with('type', () => Identifier.createType(name))
|
|
104
103
|
.exhaustive();
|
|
@@ -113,17 +112,30 @@ export class ModelDriver {
|
|
|
113
112
|
});
|
|
114
113
|
return definition;
|
|
115
114
|
}
|
|
116
|
-
buildModelSettings({ refName,
|
|
115
|
+
buildModelSettings({ refName, insertable }) {
|
|
117
116
|
const baseSettings = this.context.getModelBaseSettings({
|
|
118
|
-
generatorId:
|
|
117
|
+
generatorId: insertable.id,
|
|
119
118
|
refName
|
|
120
119
|
});
|
|
121
|
-
const e =
|
|
120
|
+
const e = insertable.toExportPath({ refName, baseSettings });
|
|
122
121
|
return new ContentSettings({
|
|
123
|
-
name:
|
|
124
|
-
selected:
|
|
122
|
+
name: insertable.toName({ refName, baseSettings }),
|
|
123
|
+
selected: insertable.isSelected({ refName, baseSettings }),
|
|
125
124
|
exportPath: e,
|
|
126
125
|
importFrom: baseSettings.importFrom ?? e
|
|
127
126
|
});
|
|
128
127
|
}
|
|
128
|
+
affirmDefinition(definition) {
|
|
129
|
+
if (!definition) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const currentKey = toModelGeneratorKey({
|
|
133
|
+
generatorId: this.insertable.id,
|
|
134
|
+
refName: this.refName
|
|
135
|
+
});
|
|
136
|
+
if (currentKey === definition.generatorKey) {
|
|
137
|
+
throw new Error(`Registered definition mismatch: cached key '${definition.generatorKey}' does not match new key ${currentKey}`);
|
|
138
|
+
}
|
|
139
|
+
return definition.value instanceof this.insertable;
|
|
140
|
+
}
|
|
129
141
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { CoreContext } from '../context/CoreContext.js';
|
|
2
|
-
import type { OasSchema } from '../oas/schema/Schema.js';
|
|
3
2
|
import type { EntityType } from './EntityType.js';
|
|
4
|
-
import type { OasRef } from '../oas/ref/Ref.js';
|
|
5
|
-
import type { CustomValue } from '../types/CustomValue.js';
|
|
6
|
-
import type { OasVoid } from '../oas/void/Void.js';
|
|
7
3
|
import type { ContentSettings } from './ContentSettings.js';
|
|
8
4
|
import type { BaseSettings } from '../types/Settings.js';
|
|
9
5
|
import type { RefName } from '../types/RefName.js';
|
|
@@ -28,7 +24,7 @@ export type ModelGenerator = {
|
|
|
28
24
|
type: 'model';
|
|
29
25
|
pinnable?: boolean;
|
|
30
26
|
};
|
|
31
|
-
export type
|
|
27
|
+
export type ModelInsertable<V> = {
|
|
32
28
|
prototype: V;
|
|
33
29
|
} & {
|
|
34
30
|
new (args: {
|
|
@@ -43,12 +39,4 @@ export type ModelCreator<V> = {
|
|
|
43
39
|
toExportPath: ({ refName, baseSettings }: ToModelExportPathArgs) => string;
|
|
44
40
|
isSelected: ({ refName, baseSettings }: IsModelSelectedArgs) => boolean;
|
|
45
41
|
} & Function;
|
|
46
|
-
|
|
47
|
-
context: CoreContext;
|
|
48
|
-
destinationPath: string;
|
|
49
|
-
schema: OasSchema | OasRef<'schema'> | OasVoid | CustomValue;
|
|
50
|
-
};
|
|
51
|
-
export type TypeSystemCreator<V> = {
|
|
52
|
-
create: (args: TypeSystemCreatorFnArgs) => V;
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=ModelCreator.d.ts.map
|
|
42
|
+
//# sourceMappingURL=ModelInsertable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelInsertable.d.ts","sourceRoot":"","sources":["../../src/dsl/ModelInsertable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC3C,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,OAAO,EAAE,WAAW,GAAG,kBAAkB,CAAA;IAC9C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,GAAG;IAClD,KAAK,IAAI,EAAE;QACT,OAAO,EAAE,WAAW,CAAA;QACpB,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,eAAe,CAAA;QACzB,eAAe,EAAE,MAAM,CAAA;KACxB,GAAG,CAAC,CAAA;IACL,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,eAAe,KAAK,MAAM,CAAA;IAC9D,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,qBAAqB,KAAK,MAAM,CAAA;IAC1E,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,mBAAmB,KAAK,OAAO,CAAA;CAExE,GAAG,QAAQ,CAAA"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OperationInsertable } from './OperationInsertable.js';
|
|
2
2
|
import type { CoreContext } from '../context/CoreContext.js';
|
|
3
3
|
import type { OasOperation } from '../oas/operation/Operation.js';
|
|
4
4
|
import { ContentSettings } from './ContentSettings.js';
|
|
5
|
-
import {
|
|
6
|
-
import type { GenerationType } from '../types/GenerationType.js';
|
|
5
|
+
import type { GeneratedDefintion, GenerationType } from '../types/GeneratedValue.js';
|
|
7
6
|
import type { GeneratedValue } from '../types/GeneratedValue.js';
|
|
8
|
-
type CreateOperationArgs<V extends GeneratedValue> = {
|
|
7
|
+
type CreateOperationArgs<V extends GeneratedValue, T extends GenerationType> = {
|
|
9
8
|
context: CoreContext;
|
|
10
|
-
|
|
9
|
+
insertable: OperationInsertable<V>;
|
|
11
10
|
operation: OasOperation;
|
|
12
|
-
generation?:
|
|
11
|
+
generation?: T;
|
|
13
12
|
destinationPath?: string;
|
|
14
13
|
};
|
|
15
|
-
export declare class OperationDriver<V extends GeneratedValue> {
|
|
14
|
+
export declare class OperationDriver<V extends GeneratedValue, T extends GenerationType> {
|
|
16
15
|
context: CoreContext;
|
|
17
|
-
|
|
16
|
+
insertable: OperationInsertable<V>;
|
|
18
17
|
operation: OasOperation;
|
|
19
18
|
settings: ContentSettings;
|
|
20
19
|
destinationPath?: string;
|
|
21
|
-
definition:
|
|
22
|
-
constructor({ context,
|
|
20
|
+
definition: GeneratedDefintion<V, T>;
|
|
21
|
+
constructor({ context, insertable, operation, generation, destinationPath }: CreateOperationArgs<V, T>);
|
|
23
22
|
get value(): V;
|
|
24
23
|
get name(): string;
|
|
25
24
|
get exportPath(): string;
|
|
26
25
|
private apply;
|
|
27
26
|
private getDefinition;
|
|
28
27
|
private buildOperationSettings;
|
|
28
|
+
private affirmDefinition;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
31
31
|
//# sourceMappingURL=OperationDriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationDriver.d.ts","sourceRoot":"","sources":["../../src/dsl/OperationDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"OperationDriver.d.ts","sourceRoot":"","sources":["../../src/dsl/OperationDriver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAItD,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAIhE,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,SAAS,cAAc,IAAI;IAC7E,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAClC,SAAS,EAAE,YAAY,CAAA;IACvB,UAAU,CAAC,EAAE,CAAC,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAiBD,qBAAa,eAAe,CAC1B,CAAC,SAAS,cAAc,EACxB,CAAC,SAAS,cAAc;IAExB,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAClC,SAAS,EAAE,YAAY,CAAA;IACvB,QAAQ,EAAE,eAAe,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBAExB,EACV,OAAO,EACP,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EAChB,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC;IAiB5B,IAAI,KAAK,IAAI,CAAC,CAQb;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,OAAO,CAAC,KAAK;IAyBb,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,gBAAgB;CAoBzB"}
|
|
@@ -2,17 +2,17 @@ import { ContentSettings } from './ContentSettings.js';
|
|
|
2
2
|
import { normalize } from '../deps/jsr.io/@std/path/1.0.0/mod.js';
|
|
3
3
|
import { Definition } from './Definition.js';
|
|
4
4
|
import { Identifier } from './Identifier.js';
|
|
5
|
-
import { verifyType } from '../helpers/verifyType.js';
|
|
6
5
|
import { match } from 'ts-pattern';
|
|
6
|
+
import { toOperationGeneratorKey } from '../types/GeneratorKeys.js';
|
|
7
7
|
export class OperationDriver {
|
|
8
|
-
constructor({ context,
|
|
8
|
+
constructor({ context, insertable, operation, generation, destinationPath }) {
|
|
9
9
|
Object.defineProperty(this, "context", {
|
|
10
10
|
enumerable: true,
|
|
11
11
|
configurable: true,
|
|
12
12
|
writable: true,
|
|
13
13
|
value: void 0
|
|
14
14
|
});
|
|
15
|
-
Object.defineProperty(this, "
|
|
15
|
+
Object.defineProperty(this, "insertable", {
|
|
16
16
|
enumerable: true,
|
|
17
17
|
configurable: true,
|
|
18
18
|
writable: true,
|
|
@@ -43,21 +43,21 @@ export class OperationDriver {
|
|
|
43
43
|
value: void 0
|
|
44
44
|
});
|
|
45
45
|
this.context = context;
|
|
46
|
-
this.
|
|
46
|
+
this.insertable = insertable;
|
|
47
47
|
this.operation = operation;
|
|
48
48
|
this.destinationPath = destinationPath;
|
|
49
49
|
this.settings = this.buildOperationSettings({
|
|
50
50
|
operation,
|
|
51
|
-
|
|
51
|
+
insertable
|
|
52
52
|
});
|
|
53
53
|
this.definition = this.apply({
|
|
54
|
-
|
|
54
|
+
generation,
|
|
55
55
|
destinationPath
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
get value() {
|
|
59
59
|
if (!this.definition) {
|
|
60
|
-
throw new Error(`${this.
|
|
60
|
+
throw new Error(`${this.insertable.id} ${this.operation.path} ${this.operation.method}: definition is undefined`);
|
|
61
61
|
}
|
|
62
62
|
return this.definition.value;
|
|
63
63
|
}
|
|
@@ -67,10 +67,10 @@ export class OperationDriver {
|
|
|
67
67
|
get exportPath() {
|
|
68
68
|
return this.settings.exportPath;
|
|
69
69
|
}
|
|
70
|
-
apply({
|
|
70
|
+
apply({ generation, destinationPath } = {}) {
|
|
71
71
|
const { name, exportPath, selected, importFrom } = this.settings;
|
|
72
|
-
if (!selected &&
|
|
73
|
-
return;
|
|
72
|
+
if (!selected && generation !== 'force') {
|
|
73
|
+
return undefined;
|
|
74
74
|
}
|
|
75
75
|
const definition = this.getDefinition({ name, exportPath });
|
|
76
76
|
if (destinationPath &&
|
|
@@ -83,13 +83,11 @@ export class OperationDriver {
|
|
|
83
83
|
return definition;
|
|
84
84
|
}
|
|
85
85
|
getDefinition({ name, exportPath }) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
verifyType(existing.value, this.creator);
|
|
90
|
-
return existing;
|
|
86
|
+
const cachedDefinition = this.context.findDefinition({ name, exportPath });
|
|
87
|
+
if (this.affirmDefinition(cachedDefinition)) {
|
|
88
|
+
return cachedDefinition;
|
|
91
89
|
}
|
|
92
|
-
const value = new this.
|
|
90
|
+
const value = new this.insertable({
|
|
93
91
|
context: this.context,
|
|
94
92
|
operation: this.operation,
|
|
95
93
|
settings: this.settings
|
|
@@ -98,7 +96,7 @@ export class OperationDriver {
|
|
|
98
96
|
const tsType = 'tsType' in value && typeof value.tsType === 'string'
|
|
99
97
|
? value.tsType
|
|
100
98
|
: undefined;
|
|
101
|
-
const identifier = match(this.
|
|
99
|
+
const identifier = match(this.insertable.entityType.type)
|
|
102
100
|
.with('value', () => Identifier.createValue({ name, tsType }))
|
|
103
101
|
.with('type', () => Identifier.createType(name))
|
|
104
102
|
.exhaustive();
|
|
@@ -113,18 +111,31 @@ export class OperationDriver {
|
|
|
113
111
|
});
|
|
114
112
|
return definition;
|
|
115
113
|
}
|
|
116
|
-
buildOperationSettings({ operation,
|
|
114
|
+
buildOperationSettings({ operation, insertable }) {
|
|
117
115
|
const baseSettings = this.context.getOperationBaseSettings({
|
|
118
|
-
generatorId:
|
|
116
|
+
generatorId: insertable.id,
|
|
119
117
|
path: operation.path,
|
|
120
118
|
method: operation.method
|
|
121
119
|
});
|
|
122
|
-
const e =
|
|
120
|
+
const e = insertable.toExportPath({ operation, baseSettings });
|
|
123
121
|
return new ContentSettings({
|
|
124
|
-
name:
|
|
125
|
-
selected:
|
|
122
|
+
name: insertable.toName({ operation, baseSettings }),
|
|
123
|
+
selected: insertable.isSelected({ operation, baseSettings }),
|
|
126
124
|
exportPath: e,
|
|
127
125
|
importFrom: baseSettings.importFrom ?? e
|
|
128
126
|
});
|
|
129
127
|
}
|
|
128
|
+
affirmDefinition(definition) {
|
|
129
|
+
if (!definition) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const currentKey = toOperationGeneratorKey({
|
|
133
|
+
generatorId: this.insertable.id,
|
|
134
|
+
operation: this.operation
|
|
135
|
+
});
|
|
136
|
+
if (currentKey === definition.generatorKey) {
|
|
137
|
+
throw new Error(`Registered definition mismatch: cached key '${definition.generatorKey}' does not match new key ${currentKey}`);
|
|
138
|
+
}
|
|
139
|
+
return definition.value instanceof this.insertable;
|
|
140
|
+
}
|
|
130
141
|
}
|
|
@@ -30,7 +30,7 @@ export type OperationGenerator = {
|
|
|
30
30
|
pinnable?: boolean;
|
|
31
31
|
isSupported?: (operation: OasOperation) => boolean;
|
|
32
32
|
};
|
|
33
|
-
export type
|
|
33
|
+
export type OperationInsertable<V> = {
|
|
34
34
|
prototype: V;
|
|
35
35
|
} & {
|
|
36
36
|
id: string;
|
|
@@ -41,4 +41,4 @@ export type OperationCreator<V> = {
|
|
|
41
41
|
isSelected: ({ operation, baseSettings }: IsOperationSelectedArgs) => boolean;
|
|
42
42
|
} & Function;
|
|
43
43
|
export {};
|
|
44
|
-
//# sourceMappingURL=
|
|
44
|
+
//# sourceMappingURL=OperationInsertable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationInsertable.d.ts","sourceRoot":"","sources":["../../src/dsl/OperationInsertable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,WAAW,CAAA;IACpB,QAAQ,EAAE,eAAe,CAAA;IACzB,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,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