@skmtc/core 0.0.553 → 0.0.554
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 +6 -6
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +9 -14
- package/esm/context/ParseContext.d.ts +6 -9
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +10 -55
- package/esm/context/types.d.ts +2 -0
- package/esm/context/types.d.ts.map +1 -1
- package/esm/run/transform.d.ts +4 -3
- package/esm/run/transform.d.ts.map +1 -1
- package/esm/run/transform.js +3 -3
- package/package.json +1 -5
- package/script/context/CoreContext.d.ts +6 -6
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +9 -14
- package/script/context/ParseContext.d.ts +6 -9
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +12 -61
- package/script/context/types.d.ts +2 -0
- package/script/context/types.d.ts.map +1 -1
- package/script/run/transform.d.ts +4 -3
- package/script/run/transform.d.ts.map +1 -1
- package/script/run/transform.js +3 -3
|
@@ -9,6 +9,7 @@ import * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
|
9
9
|
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
10
10
|
import type { GeneratorType, GeneratorsMap } from '../types/GeneratorType.js';
|
|
11
11
|
import type { Preview } from '../types/Preview.js';
|
|
12
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
12
13
|
export type ParsePhase = {
|
|
13
14
|
type: 'parse';
|
|
14
15
|
context: ParseContext;
|
|
@@ -27,7 +28,7 @@ type CoreContextArgs = {
|
|
|
27
28
|
logsPath?: string;
|
|
28
29
|
};
|
|
29
30
|
type TransformArgs = {
|
|
30
|
-
|
|
31
|
+
documentObject: OpenAPIV3.Document;
|
|
31
32
|
settings: ClientSettings | undefined;
|
|
32
33
|
toGeneratorsMap: <EnrichmentType>() => GeneratorsMap<GeneratorType<EnrichmentType>, EnrichmentType>;
|
|
33
34
|
prettier?: PrettierConfigType;
|
|
@@ -36,18 +37,17 @@ export declare class CoreContext {
|
|
|
36
37
|
#private;
|
|
37
38
|
logger: log.Logger;
|
|
38
39
|
constructor({ spanId, logsPath }: CoreContextArgs);
|
|
39
|
-
parse(
|
|
40
|
+
parse(documentObject: OpenAPIV3.Document): {
|
|
40
41
|
oasDocument: OasDocument;
|
|
41
42
|
extensions: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
transform({ schema, settings, toGeneratorsMap, prettier }: TransformArgs): Promise<{
|
|
43
|
+
};
|
|
44
|
+
transform({ documentObject, settings, toGeneratorsMap, prettier }: TransformArgs): {
|
|
45
45
|
results: import("../types/Results.js").ResultsItem;
|
|
46
46
|
files: Record<string, import("../types/Manifest.js").ManifestEntry>;
|
|
47
47
|
previews: Record<string, Record<string, Preview>>;
|
|
48
48
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
49
49
|
artifacts: Record<string, string>;
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
51
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
52
52
|
captureCurrentResult(result: ResultType): void;
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,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(), "f");
|
|
37
37
|
this.logger = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupLogger).call(this, { spanId, logsPath });
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this,
|
|
41
|
-
const oasDocument =
|
|
39
|
+
parse(documentObject) {
|
|
40
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, documentObject), "f");
|
|
41
|
+
const oasDocument = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
42
42
|
const extensions = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.extentions;
|
|
43
43
|
return {
|
|
44
44
|
oasDocument,
|
|
45
45
|
extensions
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, schema), "f");
|
|
50
|
-
await __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
51
|
-
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.oas30Document;
|
|
52
|
-
}
|
|
53
|
-
async transform({ schema, settings, toGeneratorsMap, prettier }) {
|
|
48
|
+
transform({ documentObject, settings, toGeneratorsMap, prettier }) {
|
|
54
49
|
// Temp workaround to extract generator keys during
|
|
55
50
|
// 'render' by invoking a callback passed during 'generate'
|
|
56
51
|
try {
|
|
@@ -59,9 +54,9 @@ export class CoreContext {
|
|
|
59
54
|
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.addGeneratorKey({ generatorKey });
|
|
60
55
|
}
|
|
61
56
|
};
|
|
62
|
-
const oasDocument =
|
|
63
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this,
|
|
64
|
-
return
|
|
57
|
+
const oasDocument = this.trace('parse', () => {
|
|
58
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, documentObject), "f");
|
|
59
|
+
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
65
60
|
});
|
|
66
61
|
const { files, previews } = this.trace('generate', () => {
|
|
67
62
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
@@ -153,9 +148,9 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
153
148
|
}
|
|
154
149
|
});
|
|
155
150
|
return log.getLogger(spanId);
|
|
156
|
-
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(
|
|
151
|
+
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(documentObject) {
|
|
157
152
|
const parseContext = new ParseContext({
|
|
158
|
-
|
|
153
|
+
documentObject,
|
|
159
154
|
logger: this.logger,
|
|
160
155
|
stackTrail: __classPrivateFieldGet(this, _CoreContext_stackTrail, "f")
|
|
161
156
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import { OasDocument } from '../oas/document/Document.js';
|
|
3
3
|
import type * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
4
4
|
import type { StackTrail } from './StackTrail.js';
|
|
5
5
|
type ConstructorArgs = {
|
|
6
|
-
|
|
6
|
+
documentObject: OpenAPIV3.Document;
|
|
7
7
|
logger: log.Logger;
|
|
8
8
|
stackTrail: StackTrail;
|
|
9
9
|
};
|
|
@@ -17,20 +17,17 @@ type RegisterExtensionArgs = {
|
|
|
17
17
|
extensionFields: Record<string, unknown>;
|
|
18
18
|
};
|
|
19
19
|
export declare class ParseContext {
|
|
20
|
-
|
|
21
|
-
schema: string;
|
|
20
|
+
documentObject: OpenAPIV3.Document;
|
|
22
21
|
logger: log.Logger;
|
|
23
22
|
oasDocument: OasDocument;
|
|
24
23
|
stackTrail: StackTrail;
|
|
25
24
|
extentions: Record<string, unknown>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
parse(): Promise<OasDocument>;
|
|
25
|
+
constructor({ documentObject, logger, stackTrail }: ConstructorArgs);
|
|
26
|
+
parse(): OasDocument;
|
|
29
27
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
30
28
|
registerExtension({ extensionFields, stackTrail, type }: RegisterExtensionArgs): void;
|
|
31
29
|
logSkippedFields(skipped: Record<string, unknown>): void;
|
|
32
30
|
}
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const toV3Document: (schema: OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document) => Promise<OpenAPIV3.Document>;
|
|
31
|
+
export declare const parseSchema: (schema: string) => OpenAPIV3.Document<{}>;
|
|
35
32
|
export {};
|
|
36
33
|
//# sourceMappingURL=ParseContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGjD,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAED,qBAAa,YAAY;IACvB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBAEvB,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,eAAe;IAQnE,KAAK;IASL,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,iBAAiB,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,qBAAqB,GAAG,IAAI;IAIrF,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlD;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,2BAMzC,CAAA"}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var _ParseContext_instances, _ParseContext_parseDocument;
|
|
7
1
|
import { setWith } from 'lodash-es';
|
|
8
2
|
import { parse as parseYaml } from '../deps/jsr.io/@std/yaml/0.215.0/mod.js';
|
|
9
3
|
import { toDocumentFieldsV3 } from '../oas/document/toDocumentFieldsV3.js';
|
|
10
4
|
import { OasDocument } from '../oas/document/Document.js';
|
|
11
5
|
import { tracer } from '../helpers/tracer.js';
|
|
12
|
-
import { Converter as ThreeOneToThreeZeroConverter } from '@apiture/openapi-down-convert';
|
|
13
|
-
import { match, P } from 'ts-pattern';
|
|
14
|
-
import converter from 'swagger2openapi';
|
|
15
6
|
export class ParseContext {
|
|
16
|
-
constructor({
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(this, "schema", {
|
|
7
|
+
constructor({ documentObject, logger, stackTrail }) {
|
|
8
|
+
Object.defineProperty(this, "documentObject", {
|
|
19
9
|
enumerable: true,
|
|
20
10
|
configurable: true,
|
|
21
11
|
writable: true,
|
|
@@ -45,24 +35,18 @@ export class ParseContext {
|
|
|
45
35
|
writable: true,
|
|
46
36
|
value: void 0
|
|
47
37
|
});
|
|
48
|
-
|
|
49
|
-
enumerable: true,
|
|
50
|
-
configurable: true,
|
|
51
|
-
writable: true,
|
|
52
|
-
value: void 0
|
|
53
|
-
});
|
|
54
|
-
this.schema = schema;
|
|
38
|
+
this.documentObject = documentObject;
|
|
55
39
|
this.logger = logger;
|
|
56
40
|
this.stackTrail = stackTrail;
|
|
57
41
|
this.extentions = {};
|
|
58
42
|
this.oasDocument = new OasDocument();
|
|
59
|
-
this.oas30Document = null;
|
|
60
43
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
44
|
+
parse() {
|
|
45
|
+
this.oasDocument.fields = toDocumentFieldsV3({
|
|
46
|
+
documentObject: this.documentObject,
|
|
47
|
+
context: this
|
|
48
|
+
});
|
|
49
|
+
return this.oasDocument;
|
|
66
50
|
}
|
|
67
51
|
trace(token, fn) {
|
|
68
52
|
return tracer(this.stackTrail, token, fn);
|
|
@@ -80,15 +64,7 @@ export class ParseContext {
|
|
|
80
64
|
});
|
|
81
65
|
}
|
|
82
66
|
}
|
|
83
|
-
|
|
84
|
-
const fields = toDocumentFieldsV3({
|
|
85
|
-
documentObject,
|
|
86
|
-
context: this
|
|
87
|
-
});
|
|
88
|
-
this.oasDocument.fields = fields;
|
|
89
|
-
return this.oasDocument;
|
|
90
|
-
};
|
|
91
|
-
export const stringToSchema = (schema) => {
|
|
67
|
+
export const parseSchema = (schema) => {
|
|
92
68
|
if (schema.trimStart().startsWith('{')) {
|
|
93
69
|
return JSON.parse(schema);
|
|
94
70
|
}
|
|
@@ -96,24 +72,3 @@ export const stringToSchema = (schema) => {
|
|
|
96
72
|
return parseYaml(schema);
|
|
97
73
|
}
|
|
98
74
|
};
|
|
99
|
-
export const toV3Document = async (schema) => {
|
|
100
|
-
return await match(schema)
|
|
101
|
-
.with({ openapi: P.string.startsWith('3.0.') }, doc => doc)
|
|
102
|
-
.with({ openapi: P.string.startsWith('3.1.') }, doc => {
|
|
103
|
-
const options = {
|
|
104
|
-
verbose: false,
|
|
105
|
-
deleteExampleWithId: false,
|
|
106
|
-
allOfTransform: true
|
|
107
|
-
};
|
|
108
|
-
const converter = new ThreeOneToThreeZeroConverter(doc, options);
|
|
109
|
-
return converter.convert();
|
|
110
|
-
})
|
|
111
|
-
.with({ swagger: '2.0.0' }, async (doc) => {
|
|
112
|
-
const parsed = await converter.convertObj(doc, {});
|
|
113
|
-
return parsed;
|
|
114
|
-
})
|
|
115
|
-
.otherwise(() => {
|
|
116
|
-
console.log('Unrecognized OpenAPI version', JSON.stringify(schema, null, 2).substring(0, 1000));
|
|
117
|
-
throw new Error('Unrecognized OpenAPI version');
|
|
118
|
-
});
|
|
119
|
-
};
|
package/esm/context/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
|
2
2
|
import type { ManifestEntry } from '../types/Manifest.js';
|
|
3
3
|
import type { Preview } from '../types/Preview.js';
|
|
4
4
|
import type { ResultType } from '../types/Results.js';
|
|
5
|
+
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
5
6
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
6
7
|
export type GetFileOptions = {
|
|
7
8
|
throwIfNotFound?: boolean;
|
|
@@ -21,4 +22,5 @@ export type RenderResult = {
|
|
|
21
22
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
22
23
|
results: Record<string, ResultType>;
|
|
23
24
|
};
|
|
25
|
+
export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
24
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAEtE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;CAChD,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACjD,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA"}
|
package/esm/run/transform.d.ts
CHANGED
|
@@ -2,19 +2,20 @@ import type { ClientSettings } from '../types/Settings.js';
|
|
|
2
2
|
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
3
3
|
import type { ManifestContent } from '../types/Manifest.js';
|
|
4
4
|
import type { GeneratorsMap, GeneratorType } from '../types/GeneratorType.js';
|
|
5
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
5
6
|
type TransformArgs = {
|
|
6
7
|
traceId: string;
|
|
7
8
|
spanId: string;
|
|
8
|
-
|
|
9
|
+
documentObject: OpenAPIV3.Document;
|
|
9
10
|
settings: ClientSettings | undefined;
|
|
10
11
|
prettier?: PrettierConfigType;
|
|
11
12
|
logsPath?: string;
|
|
12
13
|
toGeneratorsMap: <EnrichmentType>() => GeneratorsMap<GeneratorType<EnrichmentType>, EnrichmentType>;
|
|
13
14
|
startAt: number;
|
|
14
15
|
};
|
|
15
|
-
export declare const transform: ({ traceId, spanId,
|
|
16
|
+
export declare const transform: ({ traceId, spanId, documentObject, settings, prettier, toGeneratorsMap, logsPath, startAt }: TransformArgs) => {
|
|
16
17
|
artifacts: Record<string, string>;
|
|
17
18
|
manifest: ManifestContent;
|
|
18
|
-
}
|
|
19
|
+
};
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/run/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/run/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,CAAC,cAAc,OAAO,aAAa,CAClD,aAAa,CAAC,cAAc,CAAC,EAC7B,cAAc,CACf,CAAA;IACD,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,SAAS,gGASnB,aAAa;;;CAwBf,CAAA"}
|
package/esm/run/transform.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
2
|
import { CoreContext } from '../context/CoreContext.js';
|
|
3
|
-
export const transform =
|
|
3
|
+
export const transform = ({ traceId, spanId, documentObject, settings, prettier, toGeneratorsMap, logsPath, startAt }) => {
|
|
4
4
|
const context = new CoreContext({ spanId, logsPath });
|
|
5
|
-
const { artifacts, files, previews, pinnable, results } =
|
|
5
|
+
const { artifacts, files, previews, pinnable, results } = context.transform({
|
|
6
6
|
settings,
|
|
7
7
|
toGeneratorsMap,
|
|
8
8
|
prettier,
|
|
9
|
-
|
|
9
|
+
documentObject
|
|
10
10
|
});
|
|
11
11
|
const manifest = {
|
|
12
12
|
files,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skmtc/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.554",
|
|
4
4
|
"main": "./script/mod.js",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"test": "exit 0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@apiture/openapi-down-convert": "0.14.0",
|
|
61
60
|
"@babel/helper-validator-identifier": "7.22.20",
|
|
62
61
|
"@deno/shim-deno": "~0.18.0",
|
|
63
62
|
"@google/generative-ai": "^0.21.0",
|
|
@@ -65,10 +64,7 @@
|
|
|
65
64
|
"@sentry/deno": "8.47.0",
|
|
66
65
|
"@types/babel__helper-validator-identifier": "7.15.2",
|
|
67
66
|
"@types/lodash-es": "4.17.12",
|
|
68
|
-
"@types/swagger2openapi": "7.0.4",
|
|
69
67
|
"lodash-es": "4.17.21",
|
|
70
|
-
"openapi-types": "12.1.3",
|
|
71
|
-
"swagger2openapi": "7.0.8",
|
|
72
68
|
"tiny-invariant": "1.3.3",
|
|
73
69
|
"ts-pattern": "5.6.0",
|
|
74
70
|
"zod": "3.24.1",
|
|
@@ -9,6 +9,7 @@ import * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
|
9
9
|
import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
10
10
|
import type { GeneratorType, GeneratorsMap } from '../types/GeneratorType.js';
|
|
11
11
|
import type { Preview } from '../types/Preview.js';
|
|
12
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
12
13
|
export type ParsePhase = {
|
|
13
14
|
type: 'parse';
|
|
14
15
|
context: ParseContext;
|
|
@@ -27,7 +28,7 @@ type CoreContextArgs = {
|
|
|
27
28
|
logsPath?: string;
|
|
28
29
|
};
|
|
29
30
|
type TransformArgs = {
|
|
30
|
-
|
|
31
|
+
documentObject: OpenAPIV3.Document;
|
|
31
32
|
settings: ClientSettings | undefined;
|
|
32
33
|
toGeneratorsMap: <EnrichmentType>() => GeneratorsMap<GeneratorType<EnrichmentType>, EnrichmentType>;
|
|
33
34
|
prettier?: PrettierConfigType;
|
|
@@ -36,18 +37,17 @@ export declare class CoreContext {
|
|
|
36
37
|
#private;
|
|
37
38
|
logger: log.Logger;
|
|
38
39
|
constructor({ spanId, logsPath }: CoreContextArgs);
|
|
39
|
-
parse(
|
|
40
|
+
parse(documentObject: OpenAPIV3.Document): {
|
|
40
41
|
oasDocument: OasDocument;
|
|
41
42
|
extensions: Record<string, unknown>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
transform({ schema, settings, toGeneratorsMap, prettier }: TransformArgs): Promise<{
|
|
43
|
+
};
|
|
44
|
+
transform({ documentObject, settings, toGeneratorsMap, prettier }: TransformArgs): {
|
|
45
45
|
results: import("../types/Results.js").ResultsItem;
|
|
46
46
|
files: Record<string, import("../types/Manifest.js").ManifestEntry>;
|
|
47
47
|
previews: Record<string, Record<string, Preview>>;
|
|
48
48
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
49
49
|
artifacts: Record<string, string>;
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
51
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
52
52
|
captureCurrentResult(result: ResultType): void;
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAM7D,OAAO,KAAK,EAAE,aAAa,EAAE,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,GAAG;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAUD,KAAK,aAAa,GAAG;IACnB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,eAAe,EAAE,CAAC,cAAc,OAAO,aAAa,CAClD,aAAa,CAAC,cAAc,CAAC,EAC7B,cAAc,CACf,CAAA;IACD,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B,CAAA;AAOD,qBAAa,WAAW;;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;gBAKN,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,eAAe;IAiDjD,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,QAAQ;;;;IAaxC,SAAS,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,EAAE,aAAa;;;;;;;IAsEhF,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAiClD,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAwB/C;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,GAAG,CAAC,SAAS,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAQnF"}
|
|
@@ -63,21 +63,16 @@ class CoreContext {
|
|
|
63
63
|
__classPrivateFieldSet(this, _CoreContext_results, new ResultsLog_js_1.ResultsLog(), "f");
|
|
64
64
|
this.logger = __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupLogger).call(this, { spanId, logsPath });
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this,
|
|
68
|
-
const oasDocument =
|
|
66
|
+
parse(documentObject) {
|
|
67
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, documentObject), "f");
|
|
68
|
+
const oasDocument = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
69
69
|
const extensions = __classPrivateFieldGet(this, _CoreContext_phase, "f").context.extentions;
|
|
70
70
|
return {
|
|
71
71
|
oasDocument,
|
|
72
72
|
extensions
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, schema), "f");
|
|
77
|
-
await __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
78
|
-
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.oas30Document;
|
|
79
|
-
}
|
|
80
|
-
async transform({ schema, settings, toGeneratorsMap, prettier }) {
|
|
75
|
+
transform({ documentObject, settings, toGeneratorsMap, prettier }) {
|
|
81
76
|
// Temp workaround to extract generator keys during
|
|
82
77
|
// 'render' by invoking a callback passed during 'generate'
|
|
83
78
|
try {
|
|
@@ -86,9 +81,9 @@ class CoreContext {
|
|
|
86
81
|
__classPrivateFieldGet(this, _CoreContext_phase, "f").context.addGeneratorKey({ generatorKey });
|
|
87
82
|
}
|
|
88
83
|
};
|
|
89
|
-
const oasDocument =
|
|
90
|
-
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this,
|
|
91
|
-
return
|
|
84
|
+
const oasDocument = this.trace('parse', () => {
|
|
85
|
+
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupParsePhase).call(this, documentObject), "f");
|
|
86
|
+
return __classPrivateFieldGet(this, _CoreContext_phase, "f").context.parse();
|
|
92
87
|
});
|
|
93
88
|
const { files, previews } = this.trace('generate', () => {
|
|
94
89
|
__classPrivateFieldSet(this, _CoreContext_phase, __classPrivateFieldGet(this, _CoreContext_instances, "m", _CoreContext_setupGeneratePhase).call(this, {
|
|
@@ -181,9 +176,9 @@ _CoreContext_phase = new WeakMap(), _CoreContext_results = new WeakMap(), _CoreC
|
|
|
181
176
|
}
|
|
182
177
|
});
|
|
183
178
|
return log.getLogger(spanId);
|
|
184
|
-
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(
|
|
179
|
+
}, _CoreContext_setupParsePhase = function _CoreContext_setupParsePhase(documentObject) {
|
|
185
180
|
const parseContext = new ParseContext_js_1.ParseContext({
|
|
186
|
-
|
|
181
|
+
documentObject,
|
|
187
182
|
logger: this.logger,
|
|
188
183
|
stackTrail: __classPrivateFieldGet(this, _CoreContext_stackTrail, "f")
|
|
189
184
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import { OasDocument } from '../oas/document/Document.js';
|
|
3
3
|
import type * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
4
4
|
import type { StackTrail } from './StackTrail.js';
|
|
5
5
|
type ConstructorArgs = {
|
|
6
|
-
|
|
6
|
+
documentObject: OpenAPIV3.Document;
|
|
7
7
|
logger: log.Logger;
|
|
8
8
|
stackTrail: StackTrail;
|
|
9
9
|
};
|
|
@@ -17,20 +17,17 @@ type RegisterExtensionArgs = {
|
|
|
17
17
|
extensionFields: Record<string, unknown>;
|
|
18
18
|
};
|
|
19
19
|
export declare class ParseContext {
|
|
20
|
-
|
|
21
|
-
schema: string;
|
|
20
|
+
documentObject: OpenAPIV3.Document;
|
|
22
21
|
logger: log.Logger;
|
|
23
22
|
oasDocument: OasDocument;
|
|
24
23
|
stackTrail: StackTrail;
|
|
25
24
|
extentions: Record<string, unknown>;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
parse(): Promise<OasDocument>;
|
|
25
|
+
constructor({ documentObject, logger, stackTrail }: ConstructorArgs);
|
|
26
|
+
parse(): OasDocument;
|
|
29
27
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
30
28
|
registerExtension({ extensionFields, stackTrail, type }: RegisterExtensionArgs): void;
|
|
31
29
|
logSkippedFields(skipped: Record<string, unknown>): void;
|
|
32
30
|
}
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const toV3Document: (schema: OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document) => Promise<OpenAPIV3.Document>;
|
|
31
|
+
export declare const parseSchema: (schema: string) => OpenAPIV3.Document<{}>;
|
|
35
32
|
export {};
|
|
36
33
|
//# sourceMappingURL=ParseContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGjD,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAED,qBAAa,YAAY;IACvB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;gBAEvB,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,eAAe;IAQnE,KAAK;IASL,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD,iBAAiB,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,qBAAqB,GAAG,IAAI;IAIrF,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlD;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,2BAMzC,CAAA"}
|
|
@@ -1,27 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
-
};
|
|
10
|
-
var _ParseContext_instances, _ParseContext_parseDocument;
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
3
|
+
exports.parseSchema = exports.ParseContext = void 0;
|
|
13
4
|
const lodash_es_1 = require("lodash-es");
|
|
14
5
|
const mod_js_1 = require("../deps/jsr.io/@std/yaml/0.215.0/mod.js");
|
|
15
6
|
const toDocumentFieldsV3_js_1 = require("../oas/document/toDocumentFieldsV3.js");
|
|
16
7
|
const Document_js_1 = require("../oas/document/Document.js");
|
|
17
8
|
const tracer_js_1 = require("../helpers/tracer.js");
|
|
18
|
-
const openapi_down_convert_1 = require("@apiture/openapi-down-convert");
|
|
19
|
-
const ts_pattern_1 = require("ts-pattern");
|
|
20
|
-
const swagger2openapi_1 = __importDefault(require("swagger2openapi"));
|
|
21
9
|
class ParseContext {
|
|
22
|
-
constructor({
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(this, "schema", {
|
|
10
|
+
constructor({ documentObject, logger, stackTrail }) {
|
|
11
|
+
Object.defineProperty(this, "documentObject", {
|
|
25
12
|
enumerable: true,
|
|
26
13
|
configurable: true,
|
|
27
14
|
writable: true,
|
|
@@ -51,24 +38,18 @@ class ParseContext {
|
|
|
51
38
|
writable: true,
|
|
52
39
|
value: void 0
|
|
53
40
|
});
|
|
54
|
-
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true,
|
|
58
|
-
value: void 0
|
|
59
|
-
});
|
|
60
|
-
this.schema = schema;
|
|
41
|
+
this.documentObject = documentObject;
|
|
61
42
|
this.logger = logger;
|
|
62
43
|
this.stackTrail = stackTrail;
|
|
63
44
|
this.extentions = {};
|
|
64
45
|
this.oasDocument = new Document_js_1.OasDocument();
|
|
65
|
-
this.oas30Document = null;
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
47
|
+
parse() {
|
|
48
|
+
this.oasDocument.fields = (0, toDocumentFieldsV3_js_1.toDocumentFieldsV3)({
|
|
49
|
+
documentObject: this.documentObject,
|
|
50
|
+
context: this
|
|
51
|
+
});
|
|
52
|
+
return this.oasDocument;
|
|
72
53
|
}
|
|
73
54
|
trace(token, fn) {
|
|
74
55
|
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn);
|
|
@@ -87,15 +68,7 @@ class ParseContext {
|
|
|
87
68
|
}
|
|
88
69
|
}
|
|
89
70
|
exports.ParseContext = ParseContext;
|
|
90
|
-
|
|
91
|
-
const fields = (0, toDocumentFieldsV3_js_1.toDocumentFieldsV3)({
|
|
92
|
-
documentObject,
|
|
93
|
-
context: this
|
|
94
|
-
});
|
|
95
|
-
this.oasDocument.fields = fields;
|
|
96
|
-
return this.oasDocument;
|
|
97
|
-
};
|
|
98
|
-
const stringToSchema = (schema) => {
|
|
71
|
+
const parseSchema = (schema) => {
|
|
99
72
|
if (schema.trimStart().startsWith('{')) {
|
|
100
73
|
return JSON.parse(schema);
|
|
101
74
|
}
|
|
@@ -103,26 +76,4 @@ const stringToSchema = (schema) => {
|
|
|
103
76
|
return (0, mod_js_1.parse)(schema);
|
|
104
77
|
}
|
|
105
78
|
};
|
|
106
|
-
exports.
|
|
107
|
-
const toV3Document = async (schema) => {
|
|
108
|
-
return await (0, ts_pattern_1.match)(schema)
|
|
109
|
-
.with({ openapi: ts_pattern_1.P.string.startsWith('3.0.') }, doc => doc)
|
|
110
|
-
.with({ openapi: ts_pattern_1.P.string.startsWith('3.1.') }, doc => {
|
|
111
|
-
const options = {
|
|
112
|
-
verbose: false,
|
|
113
|
-
deleteExampleWithId: false,
|
|
114
|
-
allOfTransform: true
|
|
115
|
-
};
|
|
116
|
-
const converter = new openapi_down_convert_1.Converter(doc, options);
|
|
117
|
-
return converter.convert();
|
|
118
|
-
})
|
|
119
|
-
.with({ swagger: '2.0.0' }, async (doc) => {
|
|
120
|
-
const parsed = await swagger2openapi_1.default.convertObj(doc, {});
|
|
121
|
-
return parsed;
|
|
122
|
-
})
|
|
123
|
-
.otherwise(() => {
|
|
124
|
-
console.log('Unrecognized OpenAPI version', JSON.stringify(schema, null, 2).substring(0, 1000));
|
|
125
|
-
throw new Error('Unrecognized OpenAPI version');
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
exports.toV3Document = toV3Document;
|
|
79
|
+
exports.parseSchema = parseSchema;
|
|
@@ -2,6 +2,7 @@ import type { GeneratorKey } from '../types/GeneratorKeys.js';
|
|
|
2
2
|
import type { ManifestEntry } from '../types/Manifest.js';
|
|
3
3
|
import type { Preview } from '../types/Preview.js';
|
|
4
4
|
import type { ResultType } from '../types/Results.js';
|
|
5
|
+
import type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
5
6
|
export type PhaseType = 'parse' | 'generate' | 'render';
|
|
6
7
|
export type GetFileOptions = {
|
|
7
8
|
throwIfNotFound?: boolean;
|
|
@@ -21,4 +22,5 @@ export type RenderResult = {
|
|
|
21
22
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
22
23
|
results: Record<string, ResultType>;
|
|
23
24
|
};
|
|
25
|
+
export type AnyOasDocument = OpenAPIV2.Document | OpenAPIV3.Document | OpenAPIV3_1.Document;
|
|
24
26
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/context/types.ts"],"names":[],"mappings":"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C,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAA"}
|
|
@@ -2,19 +2,20 @@ import type { ClientSettings } from '../types/Settings.js';
|
|
|
2
2
|
import type { PrettierConfigType } from '../types/prettierConfig.js';
|
|
3
3
|
import type { ManifestContent } from '../types/Manifest.js';
|
|
4
4
|
import type { GeneratorsMap, GeneratorType } from '../types/GeneratorType.js';
|
|
5
|
+
import type { OpenAPIV3 } from 'openapi-types';
|
|
5
6
|
type TransformArgs = {
|
|
6
7
|
traceId: string;
|
|
7
8
|
spanId: string;
|
|
8
|
-
|
|
9
|
+
documentObject: OpenAPIV3.Document;
|
|
9
10
|
settings: ClientSettings | undefined;
|
|
10
11
|
prettier?: PrettierConfigType;
|
|
11
12
|
logsPath?: string;
|
|
12
13
|
toGeneratorsMap: <EnrichmentType>() => GeneratorsMap<GeneratorType<EnrichmentType>, EnrichmentType>;
|
|
13
14
|
startAt: number;
|
|
14
15
|
};
|
|
15
|
-
export declare const transform: ({ traceId, spanId,
|
|
16
|
+
export declare const transform: ({ traceId, spanId, documentObject, settings, prettier, toGeneratorsMap, logsPath, startAt }: TransformArgs) => {
|
|
16
17
|
artifacts: Record<string, string>;
|
|
17
18
|
manifest: ManifestContent;
|
|
18
|
-
}
|
|
19
|
+
};
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/run/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/run/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,CAAC,cAAc,OAAO,aAAa,CAClD,aAAa,CAAC,cAAc,CAAC,EAC7B,cAAc,CACf,CAAA;IACD,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,SAAS,gGASnB,aAAa;;;CAwBf,CAAA"}
|
package/script/run/transform.js
CHANGED
|
@@ -26,13 +26,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.transform = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
28
|
const CoreContext_js_1 = require("../context/CoreContext.js");
|
|
29
|
-
const transform =
|
|
29
|
+
const transform = ({ traceId, spanId, documentObject, settings, prettier, toGeneratorsMap, logsPath, startAt }) => {
|
|
30
30
|
const context = new CoreContext_js_1.CoreContext({ spanId, logsPath });
|
|
31
|
-
const { artifacts, files, previews, pinnable, results } =
|
|
31
|
+
const { artifacts, files, previews, pinnable, results } = context.transform({
|
|
32
32
|
settings,
|
|
33
33
|
toGeneratorsMap,
|
|
34
34
|
prettier,
|
|
35
|
-
|
|
35
|
+
documentObject
|
|
36
36
|
});
|
|
37
37
|
const manifest = {
|
|
38
38
|
files,
|