@skmtc/core 0.0.295 → 0.0.297
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 +27 -54
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +103 -139
- package/esm/context/GenerateContext.d.ts +6 -4
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +84 -6
- package/esm/context/ParseContext.d.ts +11 -11
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +51 -5
- package/esm/context/RenderContext.d.ts +7 -19
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +55 -85
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/context/ResultsHandler.js +2 -6
- package/esm/context/StackTrail.d.ts +10 -0
- package/esm/context/StackTrail.d.ts.map +1 -0
- package/esm/context/StackTrail.js +68 -0
- package/esm/context/types.d.ts +13 -1
- package/esm/context/types.d.ts.map +1 -1
- package/esm/generate/generate.d.ts +6 -3
- package/esm/generate/generate.d.ts.map +1 -1
- package/esm/generate/generate.js +18 -45
- package/esm/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +0 -1
- package/esm/oas/operation/Operation.d.ts +1 -1
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +1 -1
- package/esm/server/createServer.d.ts.map +1 -1
- package/esm/server/createServer.js +12 -13
- package/esm/types/Manifest.d.ts +11 -43
- package/esm/types/Manifest.d.ts.map +1 -1
- package/esm/types/Manifest.js +1 -5
- package/package.json +1 -1
- package/script/context/CoreContext.d.ts +27 -54
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +103 -139
- package/script/context/GenerateContext.d.ts +6 -4
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +106 -5
- package/script/context/ParseContext.d.ts +11 -11
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +76 -6
- package/script/context/RenderContext.d.ts +7 -19
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +55 -85
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/context/ResultsHandler.js +2 -6
- package/script/context/StackTrail.d.ts +10 -0
- package/script/context/StackTrail.d.ts.map +1 -0
- package/script/context/StackTrail.js +72 -0
- package/script/context/types.d.ts +13 -1
- package/script/context/types.d.ts.map +1 -1
- package/script/generate/generate.d.ts +6 -3
- package/script/generate/generate.d.ts.map +1 -1
- package/script/generate/generate.js +19 -47
- package/script/mod.d.ts +0 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +0 -1
- package/script/oas/operation/Operation.d.ts +1 -1
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +1 -1
- package/script/server/createServer.d.ts.map +1 -1
- package/script/server/createServer.js +11 -12
- package/script/types/Manifest.d.ts +11 -43
- package/script/types/Manifest.d.ts.map +1 -1
- package/script/types/Manifest.js +1 -5
- package/esm/generate/generateModels.d.ts +0 -3
- package/esm/generate/generateModels.d.ts.map +0 -1
- package/esm/generate/generateModels.js +0 -44
- package/esm/generate/generateOperations.d.ts +0 -3
- package/esm/generate/generateOperations.d.ts.map +0 -1
- package/esm/generate/generateOperations.js +0 -53
- package/esm/parse/parse.d.ts +0 -4
- package/esm/parse/parse.d.ts.map +0 -1
- package/esm/parse/parse.js +0 -16
- package/script/generate/generateModels.d.ts +0 -3
- package/script/generate/generateModels.d.ts.map +0 -1
- package/script/generate/generateModels.js +0 -71
- package/script/generate/generateOperations.d.ts +0 -3
- package/script/generate/generateOperations.d.ts.map +0 -1
- package/script/generate/generateOperations.js +0 -80
- package/script/parse/parse.d.ts +0 -4
- package/script/parse/parse.d.ts.map +0 -1
- package/script/parse/parse.js +0 -20
|
@@ -30,9 +30,7 @@ const ts_pattern_1 = require("ts-pattern");
|
|
|
30
30
|
const zod_1 = require("zod");
|
|
31
31
|
const Settings_js_1 = require("../types/Settings.js");
|
|
32
32
|
const generate_js_1 = require("../generate/generate.js");
|
|
33
|
-
const ParseContext_js_1 = require("../context/ParseContext.js");
|
|
34
33
|
const CoreContext_js_1 = require("../context/CoreContext.js");
|
|
35
|
-
const parse_js_1 = require("../parse/parse.js");
|
|
36
34
|
const postSettingsBody = zod_1.z.object({
|
|
37
35
|
schema: zod_1.z.string(),
|
|
38
36
|
clientSettings: Settings_js_1.clientSettings.optional()
|
|
@@ -52,7 +50,7 @@ const createServer = (generators) => {
|
|
|
52
50
|
return Sentry.startSpan({ name: 'Generate' }, () => {
|
|
53
51
|
const generatorsMap = Object.fromEntries(generators.map(generator => [generator.id, generator]));
|
|
54
52
|
const { traceId, spanId } = span.spanContext();
|
|
55
|
-
|
|
53
|
+
const { artifacts, manifest, renderDependencies } = (0, generate_js_1.generate)({
|
|
56
54
|
traceId,
|
|
57
55
|
spanId,
|
|
58
56
|
startAt,
|
|
@@ -61,6 +59,7 @@ const createServer = (generators) => {
|
|
|
61
59
|
settings: clientSettings,
|
|
62
60
|
generatorsMap
|
|
63
61
|
});
|
|
62
|
+
return { artifacts, manifest, renderDependencies };
|
|
64
63
|
});
|
|
65
64
|
});
|
|
66
65
|
return c.json(result);
|
|
@@ -69,10 +68,13 @@ const createServer = (generators) => {
|
|
|
69
68
|
return Sentry.startSpan({ name: 'GET /generators' }, () => c.json({ generators }));
|
|
70
69
|
});
|
|
71
70
|
app.post('/settings', async (c) => {
|
|
72
|
-
return await Sentry.startSpan({ name: 'POST /settings' }, async () => {
|
|
71
|
+
return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
|
|
73
72
|
const body = await c.req.json();
|
|
74
73
|
const { clientSettings } = postSettingsBody.parse(body);
|
|
75
|
-
const oasDocument =
|
|
74
|
+
const oasDocument = toOasDocument({
|
|
75
|
+
schema: body.schema,
|
|
76
|
+
spanId: span.spanContext().spanId
|
|
77
|
+
});
|
|
76
78
|
const out = generators.map(generator => {
|
|
77
79
|
const generatorSettings = clientSettings?.generators?.find(({ id }) => id === generator.id);
|
|
78
80
|
const generatorType = generator.type;
|
|
@@ -128,13 +130,10 @@ const toOperations = ({ generator, oasDocument, operationsSettings }) => {
|
|
|
128
130
|
return acc;
|
|
129
131
|
}, {});
|
|
130
132
|
};
|
|
131
|
-
const toOasDocument = ({ schema,
|
|
132
|
-
const parsedDocument = (0, generate_js_1.parseSchema)(schema);
|
|
133
|
-
const parseContext = new ParseContext_js_1.ParseContext({ parsedDocument });
|
|
133
|
+
const toOasDocument = ({ schema, spanId }) => {
|
|
134
134
|
const context = new CoreContext_js_1.CoreContext({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
spanId
|
|
135
|
+
spanId,
|
|
136
|
+
schema
|
|
138
137
|
});
|
|
139
|
-
return
|
|
138
|
+
return context.parse();
|
|
140
139
|
};
|
|
@@ -15,17 +15,17 @@ export declare const manifestEntry: z.ZodObject<{
|
|
|
15
15
|
generatorKeys: z.ZodArray<z.ZodEffects<z.ZodString, GeneratorKey, string>, "many">;
|
|
16
16
|
destinationPath: z.ZodString;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
destinationPath: string;
|
|
19
18
|
numberOfLines: number;
|
|
20
19
|
numberOfCharacters: number;
|
|
21
20
|
hash: string;
|
|
22
21
|
generatorKeys: GeneratorKey[];
|
|
23
|
-
}, {
|
|
24
22
|
destinationPath: string;
|
|
23
|
+
}, {
|
|
25
24
|
numberOfLines: number;
|
|
26
25
|
numberOfCharacters: number;
|
|
27
26
|
hash: string;
|
|
28
27
|
generatorKeys: string[];
|
|
28
|
+
destinationPath: string;
|
|
29
29
|
}>;
|
|
30
30
|
export type SuccessWarningError = 'success' | 'warning' | 'error';
|
|
31
31
|
export type WarningError = 'warning' | 'error';
|
|
@@ -37,19 +37,7 @@ export type Results = {
|
|
|
37
37
|
generate: Record<OperationGeneratorKey | ModelGeneratorKey, SuccessWarningError>;
|
|
38
38
|
render: SuccessWarningError;
|
|
39
39
|
};
|
|
40
|
-
export declare const results: z.
|
|
41
|
-
parse: z.ZodEnum<["success", "warning", "error"]>;
|
|
42
|
-
generate: z.ZodRecord<z.ZodString, z.ZodEnum<["success", "warning", "error"]>>;
|
|
43
|
-
render: z.ZodEnum<["success", "warning", "error"]>;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
parse: "success" | "warning" | "error";
|
|
46
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
47
|
-
render: "success" | "warning" | "error";
|
|
48
|
-
}, {
|
|
49
|
-
parse: "success" | "warning" | "error";
|
|
50
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
51
|
-
render: "success" | "warning" | "error";
|
|
52
|
-
}>;
|
|
40
|
+
export declare const results: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEnum<["success", "warning", "error"]>, z.ZodUndefined]>>;
|
|
53
41
|
export declare const phaseResults: z.ZodObject<{
|
|
54
42
|
parseResult: z.ZodEnum<["success", "warning", "error"]>;
|
|
55
43
|
generateResult: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodEnum<["success", "warning", "error"]>>>;
|
|
@@ -70,7 +58,7 @@ export type ManifestContent = {
|
|
|
70
58
|
region?: string;
|
|
71
59
|
files: Record<string, ManifestEntry>;
|
|
72
60
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
73
|
-
results:
|
|
61
|
+
results: Record<string, SuccessWarningError | undefined>;
|
|
74
62
|
startAt: number;
|
|
75
63
|
endAt: number;
|
|
76
64
|
};
|
|
@@ -86,32 +74,20 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
86
74
|
generatorKeys: z.ZodArray<z.ZodEffects<z.ZodString, GeneratorKey, string>, "many">;
|
|
87
75
|
destinationPath: z.ZodString;
|
|
88
76
|
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
destinationPath: string;
|
|
90
77
|
numberOfLines: number;
|
|
91
78
|
numberOfCharacters: number;
|
|
92
79
|
hash: string;
|
|
93
80
|
generatorKeys: GeneratorKey[];
|
|
94
|
-
}, {
|
|
95
81
|
destinationPath: string;
|
|
82
|
+
}, {
|
|
96
83
|
numberOfLines: number;
|
|
97
84
|
numberOfCharacters: number;
|
|
98
85
|
hash: string;
|
|
99
86
|
generatorKeys: string[];
|
|
87
|
+
destinationPath: string;
|
|
100
88
|
}>>;
|
|
101
89
|
pinnable: z.ZodRecord<z.ZodEffects<z.ZodString, GeneratorKey, string>, z.ZodString>;
|
|
102
|
-
results: z.
|
|
103
|
-
parse: z.ZodEnum<["success", "warning", "error"]>;
|
|
104
|
-
generate: z.ZodRecord<z.ZodString, z.ZodEnum<["success", "warning", "error"]>>;
|
|
105
|
-
render: z.ZodEnum<["success", "warning", "error"]>;
|
|
106
|
-
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
parse: "success" | "warning" | "error";
|
|
108
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
109
|
-
render: "success" | "warning" | "error";
|
|
110
|
-
}, {
|
|
111
|
-
parse: "success" | "warning" | "error";
|
|
112
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
113
|
-
render: "success" | "warning" | "error";
|
|
114
|
-
}>;
|
|
90
|
+
results: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEnum<["success", "warning", "error"]>, z.ZodUndefined]>>;
|
|
115
91
|
startAt: z.ZodNumber;
|
|
116
92
|
endAt: z.ZodNumber;
|
|
117
93
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -119,18 +95,14 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
119
95
|
traceId: string;
|
|
120
96
|
spanId: string;
|
|
121
97
|
files: Record<string, {
|
|
122
|
-
destinationPath: string;
|
|
123
98
|
numberOfLines: number;
|
|
124
99
|
numberOfCharacters: number;
|
|
125
100
|
hash: string;
|
|
126
101
|
generatorKeys: GeneratorKey[];
|
|
102
|
+
destinationPath: string;
|
|
127
103
|
}>;
|
|
128
104
|
pinnable: Partial<Record<GeneratorKey, string>>;
|
|
129
|
-
results:
|
|
130
|
-
parse: "success" | "warning" | "error";
|
|
131
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
132
|
-
render: "success" | "warning" | "error";
|
|
133
|
-
};
|
|
105
|
+
results: Record<string, "success" | "warning" | "error" | undefined>;
|
|
134
106
|
startAt: number;
|
|
135
107
|
endAt: number;
|
|
136
108
|
region?: string | undefined;
|
|
@@ -139,18 +111,14 @@ export declare const manifestContent: z.ZodObject<{
|
|
|
139
111
|
traceId: string;
|
|
140
112
|
spanId: string;
|
|
141
113
|
files: Record<string, {
|
|
142
|
-
destinationPath: string;
|
|
143
114
|
numberOfLines: number;
|
|
144
115
|
numberOfCharacters: number;
|
|
145
116
|
hash: string;
|
|
146
117
|
generatorKeys: string[];
|
|
118
|
+
destinationPath: string;
|
|
147
119
|
}>;
|
|
148
120
|
pinnable: Record<string, string>;
|
|
149
|
-
results:
|
|
150
|
-
parse: "success" | "warning" | "error";
|
|
151
|
-
generate: Record<string, "success" | "warning" | "error">;
|
|
152
|
-
render: "success" | "warning" | "error";
|
|
153
|
-
};
|
|
121
|
+
results: Record<string, "success" | "warning" | "error" | undefined>;
|
|
154
122
|
startAt: number;
|
|
155
123
|
endAt: number;
|
|
156
124
|
region?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/types/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAMxB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAEjE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C,eAAO,MAAM,mBAAmB,4CAA0C,CAAA;AAE1E,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAEhF,eAAO,MAAM,cAAc,gGAA0C,CAAA;AAErE,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,mBAAmB,CAAA;IAC1B,QAAQ,EAAE,MAAM,CACd,qBAAqB,GAAG,iBAAiB,EACzC,mBAAmB,CACpB,CAAA;IACD,MAAM,EAAE,mBAAmB,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"Manifest.d.ts","sourceRoot":"","sources":["../../src/types/Manifest.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,MAAM,CAAA;IACrB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAMxB,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;AAEjE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAE9C,eAAO,MAAM,mBAAmB,4CAA0C,CAAA;AAE1E,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAEhF,eAAO,MAAM,cAAc,gGAA0C,CAAA;AAErE,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,mBAAmB,CAAA;IAC1B,QAAQ,EAAE,MAAM,CACd,qBAAqB,GAAG,iBAAiB,EACzC,mBAAmB,CACpB,CAAA;IACD,MAAM,EAAE,mBAAmB,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,OAAO,oGAA0D,CAAA;AAE9E,eAAO,MAAM,YAAY;;;;;;;;;;;;EAIvB,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IACpC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAA;IACxD,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU1B,CAAA"}
|
package/script/types/Manifest.js
CHANGED
|
@@ -13,11 +13,7 @@ exports.manifestEntry = zod_1.z.object({
|
|
|
13
13
|
});
|
|
14
14
|
exports.successWarningError = zod_1.z.enum(['success', 'warning', 'error']);
|
|
15
15
|
exports.generateResult = zod_1.z.record(zod_1.z.record(exports.successWarningError));
|
|
16
|
-
exports.results = zod_1.z.
|
|
17
|
-
parse: exports.successWarningError,
|
|
18
|
-
generate: zod_1.z.record(exports.successWarningError),
|
|
19
|
-
render: exports.successWarningError
|
|
20
|
-
});
|
|
16
|
+
exports.results = zod_1.z.record(zod_1.z.union([exports.successWarningError, zod_1.z.undefined()]));
|
|
21
17
|
exports.phaseResults = zod_1.z.object({
|
|
22
18
|
parseResult: exports.successWarningError,
|
|
23
19
|
generateResult: exports.generateResult,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateModels.d.ts","sourceRoot":"","sources":["../../src/generate/generateModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAK5D,eAAO,MAAM,cAAc,YAAa,WAAW,SAkDlD,CAAA"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { toModelGeneratorKey } from '../types/GeneratorKeys.js';
|
|
2
|
-
import * as Sentry from '@sentry/deno';
|
|
3
|
-
export const generateModels = (context) => {
|
|
4
|
-
const { schemaModel, generatorsMap } = context;
|
|
5
|
-
Object.values(generatorsMap)
|
|
6
|
-
.filter(generator => generator.type === 'model')
|
|
7
|
-
.forEach(generator => {
|
|
8
|
-
const generatorInstance = new generator(context);
|
|
9
|
-
const refNames = Object.keys(schemaModel.components?.schemas ?? {});
|
|
10
|
-
refNames.forEach(rn => {
|
|
11
|
-
const refName = rn;
|
|
12
|
-
const generatorKey = toModelGeneratorKey({
|
|
13
|
-
refName,
|
|
14
|
-
generatorId: generator.id
|
|
15
|
-
});
|
|
16
|
-
context.setCurrentLocation(generatorKey);
|
|
17
|
-
Sentry.addBreadcrumb({
|
|
18
|
-
level: 'info',
|
|
19
|
-
message: `Transforming model`,
|
|
20
|
-
data: {
|
|
21
|
-
generatorId: generator.id,
|
|
22
|
-
method: refName
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
try {
|
|
26
|
-
generatorInstance.transformModel(refName);
|
|
27
|
-
context.captureResult({
|
|
28
|
-
phase: 'generate',
|
|
29
|
-
generatorKey,
|
|
30
|
-
result: 'success'
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
context.logger.error(error);
|
|
35
|
-
context.captureResult({
|
|
36
|
-
phase: 'generate',
|
|
37
|
-
generatorKey,
|
|
38
|
-
result: 'error'
|
|
39
|
-
});
|
|
40
|
-
Sentry.captureException(error);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateOperations.d.ts","sourceRoot":"","sources":["../../src/generate/generateOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAI5D,eAAO,MAAM,kBAAkB,YAAa,WAAW,SA0DtD,CAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/deno';
|
|
2
|
-
import { toOperationGeneratorKey } from '../types/GeneratorKeys.js';
|
|
3
|
-
export const generateOperations = (context) => {
|
|
4
|
-
const { schemaModel, generatorsMap } = context;
|
|
5
|
-
Object.values(generatorsMap)
|
|
6
|
-
.filter(generator => generator.type === 'operation')
|
|
7
|
-
.forEach(generator => {
|
|
8
|
-
const generatorInstance = new generator(context);
|
|
9
|
-
schemaModel.operations.forEach(operation => {
|
|
10
|
-
// TODO If we make OasOperation generic, for example by
|
|
11
|
-
// adding a `method` type, we could make isSupported
|
|
12
|
-
// a type guard which could help us narrow down the
|
|
13
|
-
// exact operation type that a generator receives.
|
|
14
|
-
// This would allow us to remove some type checks
|
|
15
|
-
// in the generator implementations
|
|
16
|
-
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
17
|
-
if (!generator.isSupported(operation)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const generatorKey = toOperationGeneratorKey({
|
|
21
|
-
generatorId: generator.id,
|
|
22
|
-
operation
|
|
23
|
-
});
|
|
24
|
-
context.setCurrentLocation(generatorKey);
|
|
25
|
-
Sentry.addBreadcrumb({
|
|
26
|
-
level: 'info',
|
|
27
|
-
message: `Transforming operation`,
|
|
28
|
-
data: {
|
|
29
|
-
generatorId: generator.id,
|
|
30
|
-
method: operation.method,
|
|
31
|
-
path: operation.path
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
generatorInstance.transformOperation(operation);
|
|
36
|
-
context.captureResult({
|
|
37
|
-
phase: 'generate',
|
|
38
|
-
generatorKey,
|
|
39
|
-
result: 'success'
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
context.logger.error(error);
|
|
44
|
-
context.captureResult({
|
|
45
|
-
phase: 'generate',
|
|
46
|
-
generatorKey,
|
|
47
|
-
result: 'error'
|
|
48
|
-
});
|
|
49
|
-
Sentry.captureException(error);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
package/esm/parse/parse.d.ts
DELETED
package/esm/parse/parse.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse/parse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,WAgBjD,CAAA"}
|
package/esm/parse/parse.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { toDocumentV3 } from '../oas/document/toDocumentV3.js';
|
|
2
|
-
import { Trail } from '../context/Trail.js';
|
|
3
|
-
export const oasToSkmtc = (context) => {
|
|
4
|
-
const { parsedDocument } = context;
|
|
5
|
-
const trail = new Trail({
|
|
6
|
-
document: parsedDocument
|
|
7
|
-
});
|
|
8
|
-
if (!parsedDocument.openapi.startsWith('3.0.')) {
|
|
9
|
-
throw new Error('Only OpenAPI v3 is supported');
|
|
10
|
-
}
|
|
11
|
-
return toDocumentV3({
|
|
12
|
-
document: parsedDocument,
|
|
13
|
-
trail,
|
|
14
|
-
context
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateModels.d.ts","sourceRoot":"","sources":["../../src/generate/generateModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAK5D,eAAO,MAAM,cAAc,YAAa,WAAW,SAkDlD,CAAA"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateModels = void 0;
|
|
27
|
-
const GeneratorKeys_js_1 = require("../types/GeneratorKeys.js");
|
|
28
|
-
const Sentry = __importStar(require("@sentry/deno"));
|
|
29
|
-
const generateModels = (context) => {
|
|
30
|
-
const { schemaModel, generatorsMap } = context;
|
|
31
|
-
Object.values(generatorsMap)
|
|
32
|
-
.filter(generator => generator.type === 'model')
|
|
33
|
-
.forEach(generator => {
|
|
34
|
-
const generatorInstance = new generator(context);
|
|
35
|
-
const refNames = Object.keys(schemaModel.components?.schemas ?? {});
|
|
36
|
-
refNames.forEach(rn => {
|
|
37
|
-
const refName = rn;
|
|
38
|
-
const generatorKey = (0, GeneratorKeys_js_1.toModelGeneratorKey)({
|
|
39
|
-
refName,
|
|
40
|
-
generatorId: generator.id
|
|
41
|
-
});
|
|
42
|
-
context.setCurrentLocation(generatorKey);
|
|
43
|
-
Sentry.addBreadcrumb({
|
|
44
|
-
level: 'info',
|
|
45
|
-
message: `Transforming model`,
|
|
46
|
-
data: {
|
|
47
|
-
generatorId: generator.id,
|
|
48
|
-
method: refName
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
try {
|
|
52
|
-
generatorInstance.transformModel(refName);
|
|
53
|
-
context.captureResult({
|
|
54
|
-
phase: 'generate',
|
|
55
|
-
generatorKey,
|
|
56
|
-
result: 'success'
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
context.logger.error(error);
|
|
61
|
-
context.captureResult({
|
|
62
|
-
phase: 'generate',
|
|
63
|
-
generatorKey,
|
|
64
|
-
result: 'error'
|
|
65
|
-
});
|
|
66
|
-
Sentry.captureException(error);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
exports.generateModels = generateModels;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateOperations.d.ts","sourceRoot":"","sources":["../../src/generate/generateOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAI5D,eAAO,MAAM,kBAAkB,YAAa,WAAW,SA0DtD,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateOperations = void 0;
|
|
27
|
-
const Sentry = __importStar(require("@sentry/deno"));
|
|
28
|
-
const GeneratorKeys_js_1 = require("../types/GeneratorKeys.js");
|
|
29
|
-
const generateOperations = (context) => {
|
|
30
|
-
const { schemaModel, generatorsMap } = context;
|
|
31
|
-
Object.values(generatorsMap)
|
|
32
|
-
.filter(generator => generator.type === 'operation')
|
|
33
|
-
.forEach(generator => {
|
|
34
|
-
const generatorInstance = new generator(context);
|
|
35
|
-
schemaModel.operations.forEach(operation => {
|
|
36
|
-
// TODO If we make OasOperation generic, for example by
|
|
37
|
-
// adding a `method` type, we could make isSupported
|
|
38
|
-
// a type guard which could help us narrow down the
|
|
39
|
-
// exact operation type that a generator receives.
|
|
40
|
-
// This would allow us to remove some type checks
|
|
41
|
-
// in the generator implementations
|
|
42
|
-
// https://linear.app/skmtc/issue/SKM-32/generic-models-operations
|
|
43
|
-
if (!generator.isSupported(operation)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const generatorKey = (0, GeneratorKeys_js_1.toOperationGeneratorKey)({
|
|
47
|
-
generatorId: generator.id,
|
|
48
|
-
operation
|
|
49
|
-
});
|
|
50
|
-
context.setCurrentLocation(generatorKey);
|
|
51
|
-
Sentry.addBreadcrumb({
|
|
52
|
-
level: 'info',
|
|
53
|
-
message: `Transforming operation`,
|
|
54
|
-
data: {
|
|
55
|
-
generatorId: generator.id,
|
|
56
|
-
method: operation.method,
|
|
57
|
-
path: operation.path
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
try {
|
|
61
|
-
generatorInstance.transformOperation(operation);
|
|
62
|
-
context.captureResult({
|
|
63
|
-
phase: 'generate',
|
|
64
|
-
generatorKey,
|
|
65
|
-
result: 'success'
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
context.logger.error(error);
|
|
70
|
-
context.captureResult({
|
|
71
|
-
phase: 'generate',
|
|
72
|
-
generatorKey,
|
|
73
|
-
result: 'error'
|
|
74
|
-
});
|
|
75
|
-
Sentry.captureException(error);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
exports.generateOperations = generateOperations;
|
package/script/parse/parse.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse/parse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAE5D,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,WAgBjD,CAAA"}
|
package/script/parse/parse.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.oasToSkmtc = void 0;
|
|
4
|
-
const toDocumentV3_js_1 = require("../oas/document/toDocumentV3.js");
|
|
5
|
-
const Trail_js_1 = require("../context/Trail.js");
|
|
6
|
-
const oasToSkmtc = (context) => {
|
|
7
|
-
const { parsedDocument } = context;
|
|
8
|
-
const trail = new Trail_js_1.Trail({
|
|
9
|
-
document: parsedDocument
|
|
10
|
-
});
|
|
11
|
-
if (!parsedDocument.openapi.startsWith('3.0.')) {
|
|
12
|
-
throw new Error('Only OpenAPI v3 is supported');
|
|
13
|
-
}
|
|
14
|
-
return (0, toDocumentV3_js_1.toDocumentV3)({
|
|
15
|
-
document: parsedDocument,
|
|
16
|
-
trail,
|
|
17
|
-
context
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
exports.oasToSkmtc = oasToSkmtc;
|