@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.
Files changed (265) hide show
  1. package/esm/mod.d.ts +0 -1
  2. package/esm/mod.d.ts.map +1 -1
  3. package/esm/mod.js +0 -1
  4. package/esm/oas/array/Array.d.ts +3 -0
  5. package/esm/oas/array/Array.d.ts.map +1 -1
  6. package/esm/oas/array/Array.js +8 -0
  7. package/esm/oas/array/toArray.d.ts.map +1 -1
  8. package/esm/oas/array/toArray.js +6 -5
  9. package/esm/oas/boolean/Boolean.d.ts +3 -0
  10. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  11. package/esm/oas/boolean/Boolean.js +8 -0
  12. package/esm/oas/boolean/toBoolean.d.ts.map +1 -1
  13. package/esm/oas/boolean/toBoolean.js +6 -5
  14. package/esm/oas/components/Components.d.ts +4 -1
  15. package/esm/oas/components/Components.d.ts.map +1 -1
  16. package/esm/oas/components/Components.js +4 -0
  17. package/esm/oas/components/toComponentsV3.d.ts.map +1 -1
  18. package/esm/oas/components/toComponentsV3.js +4 -2
  19. package/esm/oas/contact/Contact.d.ts +15 -0
  20. package/esm/oas/contact/Contact.d.ts.map +1 -0
  21. package/esm/oas/contact/Contact.js +38 -0
  22. package/esm/oas/contact/toContactV3.d.ts +5 -0
  23. package/esm/oas/contact/toContactV3.d.ts.map +1 -0
  24. package/esm/oas/contact/toContactV3.js +15 -0
  25. package/esm/oas/document/Document.d.ts +3 -0
  26. package/esm/oas/document/Document.d.ts.map +1 -1
  27. package/esm/oas/document/Document.js +7 -0
  28. package/esm/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
  29. package/esm/oas/document/toDocumentFieldsV3.js +7 -2
  30. package/esm/oas/example/Example.d.ts +3 -0
  31. package/esm/oas/example/Example.d.ts.map +1 -1
  32. package/esm/oas/example/Example.js +4 -0
  33. package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
  34. package/esm/oas/example/toExamplesV3.js +6 -5
  35. package/esm/oas/header/Header.d.ts +3 -0
  36. package/esm/oas/header/Header.d.ts.map +1 -1
  37. package/esm/oas/header/Header.js +4 -0
  38. package/esm/oas/header/toHeadersV3.d.ts.map +1 -1
  39. package/esm/oas/header/toHeadersV3.js +4 -2
  40. package/esm/oas/info/Info.d.ts +9 -6
  41. package/esm/oas/info/Info.d.ts.map +1 -1
  42. package/esm/oas/info/Info.js +4 -0
  43. package/esm/oas/info/toInfoV3.d.ts.map +1 -1
  44. package/esm/oas/info/toInfoV3.js +13 -16
  45. package/esm/oas/integer/Integer.d.ts +3 -0
  46. package/esm/oas/integer/Integer.d.ts.map +1 -1
  47. package/esm/oas/integer/Integer.js +8 -0
  48. package/esm/oas/integer/toInteger.d.ts.map +1 -1
  49. package/esm/oas/integer/toInteger.js +6 -5
  50. package/esm/oas/intersection/Intersection.d.ts +2 -0
  51. package/esm/oas/intersection/Intersection.d.ts.map +1 -1
  52. package/esm/oas/intersection/Intersection.js +3 -0
  53. package/esm/oas/intersection/toIntersection.d.ts.map +1 -1
  54. package/esm/oas/intersection/toIntersection.js +6 -5
  55. package/esm/oas/license/License.d.ts +13 -0
  56. package/esm/oas/license/License.d.ts.map +1 -0
  57. package/esm/oas/license/License.js +31 -0
  58. package/esm/oas/license/toLicenseV3.d.ts +5 -0
  59. package/esm/oas/license/toLicenseV3.d.ts.map +1 -0
  60. package/esm/oas/license/toLicenseV3.js +14 -0
  61. package/esm/oas/mediaType/MediaType.d.ts +2 -0
  62. package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
  63. package/esm/oas/mediaType/MediaType.js +7 -0
  64. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  65. package/esm/oas/mediaType/toMediaTypeItemV3.js +4 -2
  66. package/esm/oas/number/Number.d.ts +3 -0
  67. package/esm/oas/number/Number.d.ts.map +1 -1
  68. package/esm/oas/number/Number.js +8 -0
  69. package/esm/oas/number/toNumber.d.ts.map +1 -1
  70. package/esm/oas/number/toNumber.js +6 -5
  71. package/esm/oas/object/Object.d.ts +3 -0
  72. package/esm/oas/object/Object.d.ts.map +1 -1
  73. package/esm/oas/object/Object.js +12 -2
  74. package/esm/oas/object/toObject.d.ts.map +1 -1
  75. package/esm/oas/object/toObject.js +4 -2
  76. package/esm/oas/operation/Operation.d.ts +2 -0
  77. package/esm/oas/operation/Operation.d.ts.map +1 -1
  78. package/esm/oas/operation/Operation.js +7 -0
  79. package/esm/oas/operation/toOperationsV3.d.ts.map +1 -1
  80. package/esm/oas/operation/toOperationsV3.js +4 -2
  81. package/esm/oas/parameter/Parameter.d.ts +2 -0
  82. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  83. package/esm/oas/parameter/Parameter.js +7 -0
  84. package/esm/oas/parameter/toParameterV3.d.ts.map +1 -1
  85. package/esm/oas/parameter/toParameterV3.js +4 -2
  86. package/esm/oas/pathItem/PathItem.d.ts +2 -0
  87. package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
  88. package/esm/oas/pathItem/PathItem.js +7 -0
  89. package/esm/oas/pathItem/toPathItemV3.d.ts.map +1 -1
  90. package/esm/oas/pathItem/toPathItemV3.js +4 -2
  91. package/esm/oas/requestBody/RequestBody.d.ts +2 -0
  92. package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
  93. package/esm/oas/requestBody/RequestBody.js +7 -0
  94. package/esm/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
  95. package/esm/oas/requestBody/toRequestBodiesV3.js +4 -2
  96. package/esm/oas/response/Response.d.ts +3 -1
  97. package/esm/oas/response/Response.d.ts.map +1 -1
  98. package/esm/oas/response/Response.js +8 -1
  99. package/esm/oas/response/toResponseV3.d.ts.map +1 -1
  100. package/esm/oas/response/toResponseV3.js +4 -2
  101. package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +8 -0
  102. package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -0
  103. package/esm/oas/specificationExtensions/toSpecificationExtensionsV3.js +18 -0
  104. package/esm/oas/string/String.d.ts +3 -0
  105. package/esm/oas/string/String.d.ts.map +1 -1
  106. package/esm/oas/string/String.js +8 -0
  107. package/esm/oas/string/toString.d.ts.map +1 -1
  108. package/esm/oas/string/toString.js +6 -5
  109. package/esm/oas/tag/Tag.d.ts +3 -0
  110. package/esm/oas/tag/Tag.d.ts.map +1 -1
  111. package/esm/oas/tag/Tag.js +4 -0
  112. package/esm/oas/tag/toTagsV3.d.ts.map +1 -1
  113. package/esm/oas/tag/toTagsV3.js +4 -2
  114. package/esm/oas/union/Union.d.ts +3 -0
  115. package/esm/oas/union/Union.d.ts.map +1 -1
  116. package/esm/oas/union/Union.js +8 -0
  117. package/esm/oas/union/toUnion.d.ts.map +1 -1
  118. package/esm/oas/union/toUnion.js +6 -5
  119. package/esm/oas/unknown/Unknown.d.ts +3 -0
  120. package/esm/oas/unknown/Unknown.d.ts.map +1 -1
  121. package/esm/oas/unknown/Unknown.js +8 -0
  122. package/esm/oas/unknown/toUnknown.d.ts.map +1 -1
  123. package/esm/oas/unknown/toUnknown.js +6 -5
  124. package/package.json +1 -2
  125. package/script/mod.d.ts +0 -1
  126. package/script/mod.d.ts.map +1 -1
  127. package/script/mod.js +0 -1
  128. package/script/oas/array/Array.d.ts +3 -0
  129. package/script/oas/array/Array.d.ts.map +1 -1
  130. package/script/oas/array/Array.js +8 -0
  131. package/script/oas/array/toArray.d.ts.map +1 -1
  132. package/script/oas/array/toArray.js +6 -5
  133. package/script/oas/boolean/Boolean.d.ts +3 -0
  134. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  135. package/script/oas/boolean/Boolean.js +8 -0
  136. package/script/oas/boolean/toBoolean.d.ts.map +1 -1
  137. package/script/oas/boolean/toBoolean.js +6 -5
  138. package/script/oas/components/Components.d.ts +4 -1
  139. package/script/oas/components/Components.d.ts.map +1 -1
  140. package/script/oas/components/Components.js +4 -0
  141. package/script/oas/components/toComponentsV3.d.ts.map +1 -1
  142. package/script/oas/components/toComponentsV3.js +4 -2
  143. package/script/oas/contact/Contact.d.ts +15 -0
  144. package/script/oas/contact/Contact.d.ts.map +1 -0
  145. package/script/oas/contact/Contact.js +42 -0
  146. package/script/oas/contact/toContactV3.d.ts +5 -0
  147. package/script/oas/contact/toContactV3.d.ts.map +1 -0
  148. package/script/oas/contact/toContactV3.js +19 -0
  149. package/script/oas/document/Document.d.ts +3 -0
  150. package/script/oas/document/Document.d.ts.map +1 -1
  151. package/script/oas/document/Document.js +7 -0
  152. package/script/oas/document/toDocumentFieldsV3.d.ts.map +1 -1
  153. package/script/oas/document/toDocumentFieldsV3.js +7 -2
  154. package/script/oas/example/Example.d.ts +3 -0
  155. package/script/oas/example/Example.d.ts.map +1 -1
  156. package/script/oas/example/Example.js +4 -0
  157. package/script/oas/example/toExamplesV3.d.ts.map +1 -1
  158. package/script/oas/example/toExamplesV3.js +6 -5
  159. package/script/oas/header/Header.d.ts +3 -0
  160. package/script/oas/header/Header.d.ts.map +1 -1
  161. package/script/oas/header/Header.js +4 -0
  162. package/script/oas/header/toHeadersV3.d.ts.map +1 -1
  163. package/script/oas/header/toHeadersV3.js +4 -2
  164. package/script/oas/info/Info.d.ts +9 -6
  165. package/script/oas/info/Info.d.ts.map +1 -1
  166. package/script/oas/info/Info.js +4 -0
  167. package/script/oas/info/toInfoV3.d.ts.map +1 -1
  168. package/script/oas/info/toInfoV3.js +13 -16
  169. package/script/oas/integer/Integer.d.ts +3 -0
  170. package/script/oas/integer/Integer.d.ts.map +1 -1
  171. package/script/oas/integer/Integer.js +8 -0
  172. package/script/oas/integer/toInteger.d.ts.map +1 -1
  173. package/script/oas/integer/toInteger.js +6 -5
  174. package/script/oas/intersection/Intersection.d.ts +2 -0
  175. package/script/oas/intersection/Intersection.d.ts.map +1 -1
  176. package/script/oas/intersection/Intersection.js +3 -0
  177. package/script/oas/intersection/toIntersection.d.ts.map +1 -1
  178. package/script/oas/intersection/toIntersection.js +6 -5
  179. package/script/oas/license/License.d.ts +13 -0
  180. package/script/oas/license/License.d.ts.map +1 -0
  181. package/script/oas/license/License.js +35 -0
  182. package/script/oas/license/toLicenseV3.d.ts +5 -0
  183. package/script/oas/license/toLicenseV3.d.ts.map +1 -0
  184. package/script/oas/license/toLicenseV3.js +18 -0
  185. package/script/oas/mediaType/MediaType.d.ts +2 -0
  186. package/script/oas/mediaType/MediaType.d.ts.map +1 -1
  187. package/script/oas/mediaType/MediaType.js +7 -0
  188. package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  189. package/script/oas/mediaType/toMediaTypeItemV3.js +4 -2
  190. package/script/oas/number/Number.d.ts +3 -0
  191. package/script/oas/number/Number.d.ts.map +1 -1
  192. package/script/oas/number/Number.js +8 -0
  193. package/script/oas/number/toNumber.d.ts.map +1 -1
  194. package/script/oas/number/toNumber.js +6 -5
  195. package/script/oas/object/Object.d.ts +3 -0
  196. package/script/oas/object/Object.d.ts.map +1 -1
  197. package/script/oas/object/Object.js +12 -2
  198. package/script/oas/object/toObject.d.ts.map +1 -1
  199. package/script/oas/object/toObject.js +4 -2
  200. package/script/oas/operation/Operation.d.ts +2 -0
  201. package/script/oas/operation/Operation.d.ts.map +1 -1
  202. package/script/oas/operation/Operation.js +7 -0
  203. package/script/oas/operation/toOperationsV3.d.ts.map +1 -1
  204. package/script/oas/operation/toOperationsV3.js +4 -2
  205. package/script/oas/parameter/Parameter.d.ts +2 -0
  206. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  207. package/script/oas/parameter/Parameter.js +7 -0
  208. package/script/oas/parameter/toParameterV3.d.ts.map +1 -1
  209. package/script/oas/parameter/toParameterV3.js +4 -2
  210. package/script/oas/pathItem/PathItem.d.ts +2 -0
  211. package/script/oas/pathItem/PathItem.d.ts.map +1 -1
  212. package/script/oas/pathItem/PathItem.js +7 -0
  213. package/script/oas/pathItem/toPathItemV3.d.ts.map +1 -1
  214. package/script/oas/pathItem/toPathItemV3.js +4 -2
  215. package/script/oas/requestBody/RequestBody.d.ts +2 -0
  216. package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
  217. package/script/oas/requestBody/RequestBody.js +7 -0
  218. package/script/oas/requestBody/toRequestBodiesV3.d.ts.map +1 -1
  219. package/script/oas/requestBody/toRequestBodiesV3.js +4 -2
  220. package/script/oas/response/Response.d.ts +3 -1
  221. package/script/oas/response/Response.d.ts.map +1 -1
  222. package/script/oas/response/Response.js +8 -1
  223. package/script/oas/response/toResponseV3.d.ts.map +1 -1
  224. package/script/oas/response/toResponseV3.js +4 -2
  225. package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts +8 -0
  226. package/script/oas/specificationExtensions/toSpecificationExtensionsV3.d.ts.map +1 -0
  227. package/script/oas/specificationExtensions/toSpecificationExtensionsV3.js +22 -0
  228. package/script/oas/string/String.d.ts +3 -0
  229. package/script/oas/string/String.d.ts.map +1 -1
  230. package/script/oas/string/String.js +8 -0
  231. package/script/oas/string/toString.d.ts.map +1 -1
  232. package/script/oas/string/toString.js +6 -5
  233. package/script/oas/tag/Tag.d.ts +3 -0
  234. package/script/oas/tag/Tag.d.ts.map +1 -1
  235. package/script/oas/tag/Tag.js +4 -0
  236. package/script/oas/tag/toTagsV3.d.ts.map +1 -1
  237. package/script/oas/tag/toTagsV3.js +4 -2
  238. package/script/oas/union/Union.d.ts +3 -0
  239. package/script/oas/union/Union.d.ts.map +1 -1
  240. package/script/oas/union/Union.js +8 -0
  241. package/script/oas/union/toUnion.d.ts.map +1 -1
  242. package/script/oas/union/toUnion.js +6 -5
  243. package/script/oas/unknown/Unknown.d.ts +3 -0
  244. package/script/oas/unknown/Unknown.d.ts.map +1 -1
  245. package/script/oas/unknown/Unknown.js +8 -0
  246. package/script/oas/unknown/toUnknown.d.ts.map +1 -1
  247. package/script/oas/unknown/toUnknown.js +6 -5
  248. package/esm/oas/contact/contact-types.d.ts +0 -9
  249. package/esm/oas/contact/contact-types.d.ts.map +0 -1
  250. package/esm/oas/contact/contact-types.js +0 -7
  251. package/esm/oas/license/license-types.d.ts +0 -9
  252. package/esm/oas/license/license-types.d.ts.map +0 -1
  253. package/esm/oas/license/license-types.js +0 -7
  254. package/esm/server/createServer.d.ts +0 -5
  255. package/esm/server/createServer.d.ts.map +0 -1
  256. package/esm/server/createServer.js +0 -112
  257. package/script/oas/contact/contact-types.d.ts +0 -9
  258. package/script/oas/contact/contact-types.d.ts.map +0 -1
  259. package/script/oas/contact/contact-types.js +0 -10
  260. package/script/oas/license/license-types.d.ts +0 -9
  261. package/script/oas/license/license-types.d.ts.map +0 -1
  262. package/script/oas/license/license-types.js +0 -10
  263. package/script/server/createServer.d.ts +0 -5
  264. package/script/server/createServer.d.ts.map +0 -1
  265. package/script/server/createServer.js +0 -139
@@ -1,7 +0,0 @@
1
- import { z } from 'zod';
2
- export const oasContactData = z.object({
3
- oasType: z.literal('contact'),
4
- name: z.string().optional(),
5
- url: z.string().optional(),
6
- email: z.string().email().optional()
7
- });
@@ -1,9 +0,0 @@
1
- import { z } from 'zod';
2
- export type OasLicenseData = {
3
- oasType: 'license';
4
- name: string;
5
- url?: string;
6
- identifier?: string;
7
- };
8
- export declare const oasLicenseData: z.ZodType<OasLicenseData>;
9
- //# sourceMappingURL=license-types.d.ts.map
@@ -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,7 +0,0 @@
1
- import { z } from 'zod';
2
- export const oasLicenseData = z.object({
3
- oasType: z.literal('license'),
4
- name: z.string(),
5
- url: z.string().optional(),
6
- identifier: z.string().optional()
7
- });
@@ -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,9 +0,0 @@
1
- import { z } from 'zod';
2
- export type OasContactData = {
3
- oasType: 'contact';
4
- name?: string;
5
- url?: string;
6
- email?: string;
7
- };
8
- export declare const oasContactData: z.ZodType<OasContactData>;
9
- //# sourceMappingURL=contact-types.d.ts.map
@@ -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,9 +0,0 @@
1
- import { z } from 'zod';
2
- export type OasLicenseData = {
3
- oasType: 'license';
4
- name: string;
5
- url?: string;
6
- identifier?: string;
7
- };
8
- export declare const oasLicenseData: z.ZodType<OasLicenseData>;
9
- //# sourceMappingURL=license-types.d.ts.map
@@ -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
- };