@skmtc/core 0.0.370 → 0.0.373
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/mod.d.ts +0 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +0 -1
- package/esm/oas/array/Array.d.ts +3 -0
- package/esm/oas/array/Array.d.ts.map +1 -1
- package/esm/oas/array/Array.js +8 -0
- package/esm/oas/array/toArray.d.ts.map +1 -1
- package/esm/oas/array/toArray.js +6 -5
- package/esm/oas/boolean/Boolean.d.ts +3 -0
- package/esm/oas/boolean/Boolean.d.ts.map +1 -1
- package/esm/oas/boolean/Boolean.js +8 -0
- package/esm/oas/boolean/toBoolean.d.ts.map +1 -1
- package/esm/oas/boolean/toBoolean.js +6 -5
- package/esm/oas/components/Components.d.ts +4 -1
- package/esm/oas/components/Components.d.ts.map +1 -1
- package/esm/oas/components/Components.js +4 -0
- package/esm/oas/components/toComponentsV3.d.ts.map +1 -1
- package/esm/oas/components/toComponentsV3.js +4 -2
- package/esm/oas/contact/Contact.d.ts +15 -0
- package/esm/oas/contact/Contact.d.ts.map +1 -0
- package/esm/oas/contact/Contact.js +38 -0
- package/esm/oas/contact/toContactV3.d.ts +5 -0
- package/esm/oas/contact/toContactV3.d.ts.map +1 -0
- package/esm/oas/contact/toContactV3.js +15 -0
- package/esm/oas/document/Document.d.ts +3 -0
- package/esm/oas/document/Document.d.ts.map +1 -1
- package/esm/oas/document/Document.js +7 -0
- package/esm/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
- package/esm/oas/document/toDocumentFieldsV3.js +7 -2
- package/esm/oas/example/Example.d.ts +3 -0
- package/esm/oas/example/Example.d.ts.map +1 -1
- package/esm/oas/example/Example.js +4 -0
- package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
- package/esm/oas/example/toExamplesV3.js +6 -5
- package/esm/oas/header/Header.d.ts +3 -0
- package/esm/oas/header/Header.d.ts.map +1 -1
- package/esm/oas/header/Header.js +4 -0
- package/esm/oas/header/toHeadersV3.d.ts.map +1 -1
- package/esm/oas/header/toHeadersV3.js +4 -2
- package/esm/oas/info/Info.d.ts +9 -6
- package/esm/oas/info/Info.d.ts.map +1 -1
- package/esm/oas/info/Info.js +4 -0
- package/esm/oas/info/toInfoV3.d.ts.map +1 -1
- package/esm/oas/info/toInfoV3.js +13 -16
- package/esm/oas/integer/Integer.d.ts +3 -0
- package/esm/oas/integer/Integer.d.ts.map +1 -1
- package/esm/oas/integer/Integer.js +8 -0
- package/esm/oas/integer/toInteger.d.ts.map +1 -1
- package/esm/oas/integer/toInteger.js +6 -5
- package/esm/oas/intersection/Intersection.d.ts +2 -0
- package/esm/oas/intersection/Intersection.d.ts.map +1 -1
- package/esm/oas/intersection/Intersection.js +3 -0
- package/esm/oas/intersection/toIntersection.d.ts.map +1 -1
- package/esm/oas/intersection/toIntersection.js +6 -5
- package/esm/oas/license/License.d.ts +13 -0
- package/esm/oas/license/License.d.ts.map +1 -0
- package/esm/oas/license/License.js +31 -0
- package/esm/oas/license/toLicenseV3.d.ts +5 -0
- package/esm/oas/license/toLicenseV3.d.ts.map +1 -0
- package/esm/oas/license/toLicenseV3.js +14 -0
- package/esm/oas/mediaType/MediaType.d.ts +2 -0
- package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
- package/esm/oas/mediaType/MediaType.js +7 -0
- package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/esm/oas/mediaType/toMediaTypeItemV3.js +4 -2
- package/esm/oas/number/Number.d.ts +3 -0
- package/esm/oas/number/Number.d.ts.map +1 -1
- package/esm/oas/number/Number.js +8 -0
- package/esm/oas/number/toNumber.d.ts.map +1 -1
- package/esm/oas/number/toNumber.js +6 -5
- package/esm/oas/object/Object.d.ts +3 -0
- package/esm/oas/object/Object.d.ts.map +1 -1
- package/esm/oas/object/Object.js +12 -2
- package/esm/oas/object/toObject.d.ts.map +1 -1
- package/esm/oas/object/toObject.js +4 -2
- package/esm/oas/operation/Operation.d.ts +2 -0
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +7 -0
- package/esm/oas/operation/toOperationsV3.d.ts.map +1 -1
- package/esm/oas/operation/toOperationsV3.js +4 -2
- package/esm/oas/parameter/Parameter.d.ts +2 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +7 -0
- package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/esm/oas/parameter/toParameterV3.js +4 -2
- package/esm/oas/pathItem/PathItem.d.ts +2 -0
- package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
- package/esm/oas/pathItem/PathItem.js +7 -0
- package/esm/oas/pathItem/toPathItemV3.d.ts.map +1 -1
- package/esm/oas/pathItem/toPathItemV3.js +4 -2
- package/esm/oas/requestBody/RequestBody.d.ts +2 -0
- package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
- package/esm/oas/requestBody/RequestBody.js +7 -0
- package/esm/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
- package/esm/oas/requestBody/toRequestBodiesV3.js +4 -2
- package/esm/oas/response/Response.d.ts +3 -1
- package/esm/oas/response/Response.d.ts.map +1 -1
- package/esm/oas/response/Response.js +8 -1
- package/esm/oas/response/toResponseV3.d.ts.map +1 -1
- package/esm/oas/response/toResponseV3.js +4 -2
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +8 -0
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -0
- package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.js +18 -0
- package/esm/oas/string/String.d.ts +3 -0
- package/esm/oas/string/String.d.ts.map +1 -1
- package/esm/oas/string/String.js +8 -0
- package/esm/oas/string/toString.d.ts.map +1 -1
- package/esm/oas/string/toString.js +6 -5
- package/esm/oas/tag/Tag.d.ts +3 -0
- package/esm/oas/tag/Tag.d.ts.map +1 -1
- package/esm/oas/tag/Tag.js +4 -0
- package/esm/oas/tag/toTagsV3.d.ts.map +1 -1
- package/esm/oas/tag/toTagsV3.js +4 -2
- package/esm/oas/union/Union.d.ts +3 -0
- package/esm/oas/union/Union.d.ts.map +1 -1
- package/esm/oas/union/Union.js +8 -0
- package/esm/oas/union/toUnion.d.ts.map +1 -1
- package/esm/oas/union/toUnion.js +6 -5
- package/esm/oas/unknown/Unknown.d.ts +3 -0
- package/esm/oas/unknown/Unknown.d.ts.map +1 -1
- package/esm/oas/unknown/Unknown.js +8 -0
- package/esm/oas/unknown/toUnknown.d.ts.map +1 -1
- package/esm/oas/unknown/toUnknown.js +6 -5
- package/package.json +1 -2
- package/script/mod.d.ts +0 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +0 -1
- package/script/oas/array/Array.d.ts +3 -0
- package/script/oas/array/Array.d.ts.map +1 -1
- package/script/oas/array/Array.js +8 -0
- package/script/oas/array/toArray.d.ts.map +1 -1
- package/script/oas/array/toArray.js +6 -5
- package/script/oas/boolean/Boolean.d.ts +3 -0
- package/script/oas/boolean/Boolean.d.ts.map +1 -1
- package/script/oas/boolean/Boolean.js +8 -0
- package/script/oas/boolean/toBoolean.d.ts.map +1 -1
- package/script/oas/boolean/toBoolean.js +6 -5
- package/script/oas/components/Components.d.ts +4 -1
- package/script/oas/components/Components.d.ts.map +1 -1
- package/script/oas/components/Components.js +4 -0
- package/script/oas/components/toComponentsV3.d.ts.map +1 -1
- package/script/oas/components/toComponentsV3.js +4 -2
- package/script/oas/contact/Contact.d.ts +15 -0
- package/script/oas/contact/Contact.d.ts.map +1 -0
- package/script/oas/contact/Contact.js +42 -0
- package/script/oas/contact/toContactV3.d.ts +5 -0
- package/script/oas/contact/toContactV3.d.ts.map +1 -0
- package/script/oas/contact/toContactV3.js +19 -0
- package/script/oas/document/Document.d.ts +3 -0
- package/script/oas/document/Document.d.ts.map +1 -1
- package/script/oas/document/Document.js +7 -0
- package/script/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
- package/script/oas/document/toDocumentFieldsV3.js +7 -2
- package/script/oas/example/Example.d.ts +3 -0
- package/script/oas/example/Example.d.ts.map +1 -1
- package/script/oas/example/Example.js +4 -0
- package/script/oas/example/toExamplesV3.d.ts.map +1 -1
- package/script/oas/example/toExamplesV3.js +6 -5
- package/script/oas/header/Header.d.ts +3 -0
- package/script/oas/header/Header.d.ts.map +1 -1
- package/script/oas/header/Header.js +4 -0
- package/script/oas/header/toHeadersV3.d.ts.map +1 -1
- package/script/oas/header/toHeadersV3.js +4 -2
- package/script/oas/info/Info.d.ts +9 -6
- package/script/oas/info/Info.d.ts.map +1 -1
- package/script/oas/info/Info.js +4 -0
- package/script/oas/info/toInfoV3.d.ts.map +1 -1
- package/script/oas/info/toInfoV3.js +13 -16
- package/script/oas/integer/Integer.d.ts +3 -0
- package/script/oas/integer/Integer.d.ts.map +1 -1
- package/script/oas/integer/Integer.js +8 -0
- package/script/oas/integer/toInteger.d.ts.map +1 -1
- package/script/oas/integer/toInteger.js +6 -5
- package/script/oas/intersection/Intersection.d.ts +2 -0
- package/script/oas/intersection/Intersection.d.ts.map +1 -1
- package/script/oas/intersection/Intersection.js +3 -0
- package/script/oas/intersection/toIntersection.d.ts.map +1 -1
- package/script/oas/intersection/toIntersection.js +6 -5
- package/script/oas/license/License.d.ts +13 -0
- package/script/oas/license/License.d.ts.map +1 -0
- package/script/oas/license/License.js +35 -0
- package/script/oas/license/toLicenseV3.d.ts +5 -0
- package/script/oas/license/toLicenseV3.d.ts.map +1 -0
- package/script/oas/license/toLicenseV3.js +18 -0
- package/script/oas/mediaType/MediaType.d.ts +2 -0
- package/script/oas/mediaType/MediaType.d.ts.map +1 -1
- package/script/oas/mediaType/MediaType.js +7 -0
- package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
- package/script/oas/mediaType/toMediaTypeItemV3.js +4 -2
- package/script/oas/number/Number.d.ts +3 -0
- package/script/oas/number/Number.d.ts.map +1 -1
- package/script/oas/number/Number.js +8 -0
- package/script/oas/number/toNumber.d.ts.map +1 -1
- package/script/oas/number/toNumber.js +6 -5
- package/script/oas/object/Object.d.ts +3 -0
- package/script/oas/object/Object.d.ts.map +1 -1
- package/script/oas/object/Object.js +12 -2
- package/script/oas/object/toObject.d.ts.map +1 -1
- package/script/oas/object/toObject.js +4 -2
- package/script/oas/operation/Operation.d.ts +2 -0
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +7 -0
- package/script/oas/operation/toOperationsV3.d.ts.map +1 -1
- package/script/oas/operation/toOperationsV3.js +4 -2
- package/script/oas/parameter/Parameter.d.ts +2 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +7 -0
- package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
- package/script/oas/parameter/toParameterV3.js +4 -2
- package/script/oas/pathItem/PathItem.d.ts +2 -0
- package/script/oas/pathItem/PathItem.d.ts.map +1 -1
- package/script/oas/pathItem/PathItem.js +7 -0
- package/script/oas/pathItem/toPathItemV3.d.ts.map +1 -1
- package/script/oas/pathItem/toPathItemV3.js +4 -2
- package/script/oas/requestBody/RequestBody.d.ts +2 -0
- package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
- package/script/oas/requestBody/RequestBody.js +7 -0
- package/script/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
- package/script/oas/requestBody/toRequestBodiesV3.js +4 -2
- package/script/oas/response/Response.d.ts +3 -1
- package/script/oas/response/Response.d.ts.map +1 -1
- package/script/oas/response/Response.js +8 -1
- package/script/oas/response/toResponseV3.d.ts.map +1 -1
- package/script/oas/response/toResponseV3.js +4 -2
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +8 -0
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -0
- package/script/oas/specificationExtensions/toSpecificationExtensionsV3.js +22 -0
- package/script/oas/string/String.d.ts +3 -0
- package/script/oas/string/String.d.ts.map +1 -1
- package/script/oas/string/String.js +8 -0
- package/script/oas/string/toString.d.ts.map +1 -1
- package/script/oas/string/toString.js +6 -5
- package/script/oas/tag/Tag.d.ts +3 -0
- package/script/oas/tag/Tag.d.ts.map +1 -1
- package/script/oas/tag/Tag.js +4 -0
- package/script/oas/tag/toTagsV3.d.ts.map +1 -1
- package/script/oas/tag/toTagsV3.js +4 -2
- package/script/oas/union/Union.d.ts +3 -0
- package/script/oas/union/Union.d.ts.map +1 -1
- package/script/oas/union/Union.js +8 -0
- package/script/oas/union/toUnion.d.ts.map +1 -1
- package/script/oas/union/toUnion.js +6 -5
- package/script/oas/unknown/Unknown.d.ts +3 -0
- package/script/oas/unknown/Unknown.d.ts.map +1 -1
- package/script/oas/unknown/Unknown.js +8 -0
- package/script/oas/unknown/toUnknown.d.ts.map +1 -1
- package/script/oas/unknown/toUnknown.js +6 -5
- package/esm/oas/contact/contact-types.d.ts +0 -9
- package/esm/oas/contact/contact-types.d.ts.map +0 -1
- package/esm/oas/contact/contact-types.js +0 -7
- package/esm/oas/license/license-types.d.ts +0 -9
- package/esm/oas/license/license-types.d.ts.map +0 -1
- package/esm/oas/license/license-types.js +0 -7
- package/esm/server/createServer.d.ts +0 -5
- package/esm/server/createServer.d.ts.map +0 -1
- package/esm/server/createServer.js +0 -112
- package/script/oas/contact/contact-types.d.ts +0 -9
- package/script/oas/contact/contact-types.d.ts.map +0 -1
- package/script/oas/contact/contact-types.js +0 -10
- package/script/oas/license/license-types.d.ts +0 -9
- package/script/oas/license/license-types.d.ts.map +0 -1
- package/script/oas/license/license-types.js +0 -10
- package/script/server/createServer.d.ts +0 -5
- package/script/server/createServer.d.ts.map +0 -1
- package/script/server/createServer.js +0 -139
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"license-types.d.ts","sourceRoot":"","sources":["../../../src/oas/license/license-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAKnD,CAAA"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import type { OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
3
|
-
import type { ModelGateway } from '../dsl/model/ModelInsertable.js';
|
|
4
|
-
export declare const createServer: (generators: (OperationGateway | ModelGateway)[]) => Hono;
|
|
5
|
-
//# sourceMappingURL=createServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IA0GF,CAAA"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import * as Sentry from '@sentry/deno';
|
|
2
|
-
import { Hono } from 'hono';
|
|
3
|
-
import { match } from 'ts-pattern';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { clientSettings as settingsSchema } from '../types/Settings.js';
|
|
6
|
-
import { transform } from '../transform/transform.js';
|
|
7
|
-
import { CoreContext } from '../context/CoreContext.js';
|
|
8
|
-
const postSettingsBody = z.object({
|
|
9
|
-
defaultSelected: z.boolean().optional(),
|
|
10
|
-
schema: z.string(),
|
|
11
|
-
clientSettings: settingsSchema.optional()
|
|
12
|
-
});
|
|
13
|
-
const postGenerateBody = z.object({
|
|
14
|
-
schema: z.string(),
|
|
15
|
-
clientSettings: settingsSchema.optional(),
|
|
16
|
-
prettier: z.record(z.unknown()).optional()
|
|
17
|
-
});
|
|
18
|
-
export const createServer = (generators) => {
|
|
19
|
-
const app = new Hono();
|
|
20
|
-
app.post('/artifacts', async (c) => {
|
|
21
|
-
const startAt = Date.now();
|
|
22
|
-
const result = await Sentry.startSpan({ name: 'POST /artifacts' }, async (span) => {
|
|
23
|
-
const body = await Sentry.startSpan({ name: 'Parse JSON' }, () => c.req.json());
|
|
24
|
-
const { schema, clientSettings, prettier } = await Sentry.startSpan({ name: 'Validate request content' }, () => postGenerateBody.parseAsync(body));
|
|
25
|
-
return Sentry.startSpan({ name: 'Generate' }, () => {
|
|
26
|
-
const generatorsMap = Object.fromEntries(generators.map(generator => [generator.id, generator]));
|
|
27
|
-
const { traceId, spanId } = span.spanContext();
|
|
28
|
-
const { artifacts, manifest } = transform({
|
|
29
|
-
traceId,
|
|
30
|
-
spanId,
|
|
31
|
-
startAt,
|
|
32
|
-
schema,
|
|
33
|
-
prettier,
|
|
34
|
-
settings: clientSettings,
|
|
35
|
-
generatorsMap
|
|
36
|
-
});
|
|
37
|
-
return { artifacts, manifest };
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
return c.json(result);
|
|
41
|
-
});
|
|
42
|
-
app.get('/generators', c => {
|
|
43
|
-
return Sentry.startSpan({ name: 'GET /generators' }, () => c.json({ generators }));
|
|
44
|
-
});
|
|
45
|
-
app.post('/settings', async (c) => {
|
|
46
|
-
return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
|
|
47
|
-
const body = await c.req.json();
|
|
48
|
-
const { clientSettings, defaultSelected = false } = postSettingsBody.parse(body);
|
|
49
|
-
const oasDocument = toOasDocument({
|
|
50
|
-
schema: body.schema,
|
|
51
|
-
spanId: span.spanContext().spanId
|
|
52
|
-
});
|
|
53
|
-
const out = generators.map(generator => {
|
|
54
|
-
const generatorSettings = clientSettings?.generators.find(({ id }) => id === generator.id);
|
|
55
|
-
const generatorType = generator.type;
|
|
56
|
-
return match(generatorType)
|
|
57
|
-
.with('operation', () => ({
|
|
58
|
-
...generatorSettings,
|
|
59
|
-
id: generator.id,
|
|
60
|
-
operations: toOperations({
|
|
61
|
-
generator: generator,
|
|
62
|
-
oasDocument,
|
|
63
|
-
defaultSelected,
|
|
64
|
-
operationsSettings: generatorSettings && 'operations' in generatorSettings
|
|
65
|
-
? generatorSettings.operations
|
|
66
|
-
: undefined
|
|
67
|
-
})
|
|
68
|
-
}))
|
|
69
|
-
.with('model', () => ({
|
|
70
|
-
...generatorSettings,
|
|
71
|
-
id: generator.id,
|
|
72
|
-
models: toModels({
|
|
73
|
-
oasDocument,
|
|
74
|
-
defaultSelected,
|
|
75
|
-
modelsSettings: generatorSettings && 'models' in generatorSettings
|
|
76
|
-
? generatorSettings.models
|
|
77
|
-
: undefined
|
|
78
|
-
})
|
|
79
|
-
}))
|
|
80
|
-
.otherwise(matched => {
|
|
81
|
-
throw new Error(`Invalid generator type: '${matched}' for ${generator.id}`);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
return c.json({ generators: out });
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
return app;
|
|
88
|
-
};
|
|
89
|
-
const toModels = ({ defaultSelected, oasDocument, modelsSettings }) => {
|
|
90
|
-
return Object.fromEntries(Object.keys(oasDocument.components?.schemas ?? {}).map(refName => [
|
|
91
|
-
refName,
|
|
92
|
-
modelsSettings?.[refName]
|
|
93
|
-
? modelsSettings?.[refName]
|
|
94
|
-
: { selected: defaultSelected }
|
|
95
|
-
]));
|
|
96
|
-
};
|
|
97
|
-
const toOperations = ({ generator, oasDocument, operationsSettings, defaultSelected }) => {
|
|
98
|
-
return Object.values(oasDocument.operations)
|
|
99
|
-
.filter(operation => generator.isSupported(operation))
|
|
100
|
-
.reduce((acc, operation) => {
|
|
101
|
-
const { path, method } = operation;
|
|
102
|
-
acc[path] = acc[path] ?? {};
|
|
103
|
-
acc[path][method] = operationsSettings?.[path]?.[method]
|
|
104
|
-
? operationsSettings?.[path]?.[method]
|
|
105
|
-
: { selected: defaultSelected };
|
|
106
|
-
return acc;
|
|
107
|
-
}, {});
|
|
108
|
-
};
|
|
109
|
-
const toOasDocument = ({ schema, spanId }) => {
|
|
110
|
-
const context = new CoreContext({ spanId });
|
|
111
|
-
return context.parse(schema);
|
|
112
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contact-types.d.ts","sourceRoot":"","sources":["../../../src/oas/contact/contact-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAKnD,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.oasContactData = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
exports.oasContactData = zod_1.z.object({
|
|
6
|
-
oasType: zod_1.z.literal('contact'),
|
|
7
|
-
name: zod_1.z.string().optional(),
|
|
8
|
-
url: zod_1.z.string().optional(),
|
|
9
|
-
email: zod_1.z.string().email().optional()
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"license-types.d.ts","sourceRoot":"","sources":["../../../src/oas/license/license-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAKnD,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.oasLicenseData = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
exports.oasLicenseData = zod_1.z.object({
|
|
6
|
-
oasType: zod_1.z.literal('license'),
|
|
7
|
-
name: zod_1.z.string(),
|
|
8
|
-
url: zod_1.z.string().optional(),
|
|
9
|
-
identifier: zod_1.z.string().optional()
|
|
10
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import type { OperationGateway } from '../dsl/operation/OperationInsertable.js';
|
|
3
|
-
import type { ModelGateway } from '../dsl/model/ModelInsertable.js';
|
|
4
|
-
export declare const createServer: (generators: (OperationGateway | ModelGateway)[]) => Hono;
|
|
5
|
-
//# sourceMappingURL=createServer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IA0GF,CAAA"}
|
|
@@ -1,139 +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.createServer = void 0;
|
|
27
|
-
const Sentry = __importStar(require("@sentry/deno"));
|
|
28
|
-
const hono_1 = require("hono");
|
|
29
|
-
const ts_pattern_1 = require("ts-pattern");
|
|
30
|
-
const zod_1 = require("zod");
|
|
31
|
-
const Settings_js_1 = require("../types/Settings.js");
|
|
32
|
-
const transform_js_1 = require("../transform/transform.js");
|
|
33
|
-
const CoreContext_js_1 = require("../context/CoreContext.js");
|
|
34
|
-
const postSettingsBody = zod_1.z.object({
|
|
35
|
-
defaultSelected: zod_1.z.boolean().optional(),
|
|
36
|
-
schema: zod_1.z.string(),
|
|
37
|
-
clientSettings: Settings_js_1.clientSettings.optional()
|
|
38
|
-
});
|
|
39
|
-
const postGenerateBody = zod_1.z.object({
|
|
40
|
-
schema: zod_1.z.string(),
|
|
41
|
-
clientSettings: Settings_js_1.clientSettings.optional(),
|
|
42
|
-
prettier: zod_1.z.record(zod_1.z.unknown()).optional()
|
|
43
|
-
});
|
|
44
|
-
const createServer = (generators) => {
|
|
45
|
-
const app = new hono_1.Hono();
|
|
46
|
-
app.post('/artifacts', async (c) => {
|
|
47
|
-
const startAt = Date.now();
|
|
48
|
-
const result = await Sentry.startSpan({ name: 'POST /artifacts' }, async (span) => {
|
|
49
|
-
const body = await Sentry.startSpan({ name: 'Parse JSON' }, () => c.req.json());
|
|
50
|
-
const { schema, clientSettings, prettier } = await Sentry.startSpan({ name: 'Validate request content' }, () => postGenerateBody.parseAsync(body));
|
|
51
|
-
return Sentry.startSpan({ name: 'Generate' }, () => {
|
|
52
|
-
const generatorsMap = Object.fromEntries(generators.map(generator => [generator.id, generator]));
|
|
53
|
-
const { traceId, spanId } = span.spanContext();
|
|
54
|
-
const { artifacts, manifest } = (0, transform_js_1.transform)({
|
|
55
|
-
traceId,
|
|
56
|
-
spanId,
|
|
57
|
-
startAt,
|
|
58
|
-
schema,
|
|
59
|
-
prettier,
|
|
60
|
-
settings: clientSettings,
|
|
61
|
-
generatorsMap
|
|
62
|
-
});
|
|
63
|
-
return { artifacts, manifest };
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
return c.json(result);
|
|
67
|
-
});
|
|
68
|
-
app.get('/generators', c => {
|
|
69
|
-
return Sentry.startSpan({ name: 'GET /generators' }, () => c.json({ generators }));
|
|
70
|
-
});
|
|
71
|
-
app.post('/settings', async (c) => {
|
|
72
|
-
return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
|
|
73
|
-
const body = await c.req.json();
|
|
74
|
-
const { clientSettings, defaultSelected = false } = postSettingsBody.parse(body);
|
|
75
|
-
const oasDocument = toOasDocument({
|
|
76
|
-
schema: body.schema,
|
|
77
|
-
spanId: span.spanContext().spanId
|
|
78
|
-
});
|
|
79
|
-
const out = generators.map(generator => {
|
|
80
|
-
const generatorSettings = clientSettings?.generators.find(({ id }) => id === generator.id);
|
|
81
|
-
const generatorType = generator.type;
|
|
82
|
-
return (0, ts_pattern_1.match)(generatorType)
|
|
83
|
-
.with('operation', () => ({
|
|
84
|
-
...generatorSettings,
|
|
85
|
-
id: generator.id,
|
|
86
|
-
operations: toOperations({
|
|
87
|
-
generator: generator,
|
|
88
|
-
oasDocument,
|
|
89
|
-
defaultSelected,
|
|
90
|
-
operationsSettings: generatorSettings && 'operations' in generatorSettings
|
|
91
|
-
? generatorSettings.operations
|
|
92
|
-
: undefined
|
|
93
|
-
})
|
|
94
|
-
}))
|
|
95
|
-
.with('model', () => ({
|
|
96
|
-
...generatorSettings,
|
|
97
|
-
id: generator.id,
|
|
98
|
-
models: toModels({
|
|
99
|
-
oasDocument,
|
|
100
|
-
defaultSelected,
|
|
101
|
-
modelsSettings: generatorSettings && 'models' in generatorSettings
|
|
102
|
-
? generatorSettings.models
|
|
103
|
-
: undefined
|
|
104
|
-
})
|
|
105
|
-
}))
|
|
106
|
-
.otherwise(matched => {
|
|
107
|
-
throw new Error(`Invalid generator type: '${matched}' for ${generator.id}`);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
return c.json({ generators: out });
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
return app;
|
|
114
|
-
};
|
|
115
|
-
exports.createServer = createServer;
|
|
116
|
-
const toModels = ({ defaultSelected, oasDocument, modelsSettings }) => {
|
|
117
|
-
return Object.fromEntries(Object.keys(oasDocument.components?.schemas ?? {}).map(refName => [
|
|
118
|
-
refName,
|
|
119
|
-
modelsSettings?.[refName]
|
|
120
|
-
? modelsSettings?.[refName]
|
|
121
|
-
: { selected: defaultSelected }
|
|
122
|
-
]));
|
|
123
|
-
};
|
|
124
|
-
const toOperations = ({ generator, oasDocument, operationsSettings, defaultSelected }) => {
|
|
125
|
-
return Object.values(oasDocument.operations)
|
|
126
|
-
.filter(operation => generator.isSupported(operation))
|
|
127
|
-
.reduce((acc, operation) => {
|
|
128
|
-
const { path, method } = operation;
|
|
129
|
-
acc[path] = acc[path] ?? {};
|
|
130
|
-
acc[path][method] = operationsSettings?.[path]?.[method]
|
|
131
|
-
? operationsSettings?.[path]?.[method]
|
|
132
|
-
: { selected: defaultSelected };
|
|
133
|
-
return acc;
|
|
134
|
-
}, {});
|
|
135
|
-
};
|
|
136
|
-
const toOasDocument = ({ schema, spanId }) => {
|
|
137
|
-
const context = new CoreContext_js_1.CoreContext({ spanId });
|
|
138
|
-
return context.parse(schema);
|
|
139
|
-
};
|