@automatons/parser 0.0.2

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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/converters/allOf.d.ts +4 -0
  4. package/converters/allOf.d.ts.map +1 -0
  5. package/converters/allOf.js +10 -0
  6. package/converters/allOf.js.map +1 -0
  7. package/converters/array.d.ts +4 -0
  8. package/converters/array.d.ts.map +1 -0
  9. package/converters/array.js +13 -0
  10. package/converters/array.js.map +1 -0
  11. package/converters/boolean.d.ts +4 -0
  12. package/converters/boolean.d.ts.map +1 -0
  13. package/converters/boolean.js +9 -0
  14. package/converters/boolean.js.map +1 -0
  15. package/converters/map.d.ts +7 -0
  16. package/converters/map.d.ts.map +1 -0
  17. package/converters/map.js +5 -0
  18. package/converters/map.js.map +1 -0
  19. package/converters/model.d.ts +3 -0
  20. package/converters/model.d.ts.map +1 -0
  21. package/converters/model.js +11 -0
  22. package/converters/model.js.map +1 -0
  23. package/converters/number.d.ts +4 -0
  24. package/converters/number.d.ts.map +1 -0
  25. package/converters/number.js +11 -0
  26. package/converters/number.js.map +1 -0
  27. package/converters/object.d.ts +4 -0
  28. package/converters/object.d.ts.map +1 -0
  29. package/converters/object.js +10 -0
  30. package/converters/object.js.map +1 -0
  31. package/converters/oneOf.d.ts +4 -0
  32. package/converters/oneOf.d.ts.map +1 -0
  33. package/converters/oneOf.js +10 -0
  34. package/converters/oneOf.js.map +1 -0
  35. package/converters/schema.d.ts +4 -0
  36. package/converters/schema.d.ts.map +1 -0
  37. package/converters/schema.js +13 -0
  38. package/converters/schema.js.map +1 -0
  39. package/converters/schemaModel.d.ts +4 -0
  40. package/converters/schemaModel.d.ts.map +1 -0
  41. package/converters/schemaModel.js +11 -0
  42. package/converters/schemaModel.js.map +1 -0
  43. package/converters/security.d.ts +4 -0
  44. package/converters/security.d.ts.map +1 -0
  45. package/converters/security.js +18 -0
  46. package/converters/security.js.map +1 -0
  47. package/converters/server.d.ts +4 -0
  48. package/converters/server.d.ts.map +1 -0
  49. package/converters/server.js +11 -0
  50. package/converters/server.js.map +1 -0
  51. package/converters/string.d.ts +4 -0
  52. package/converters/string.d.ts.map +1 -0
  53. package/converters/string.js +11 -0
  54. package/converters/string.js.map +1 -0
  55. package/extractors/index.d.ts +4 -0
  56. package/extractors/index.d.ts.map +1 -0
  57. package/extractors/index.js +16 -0
  58. package/extractors/index.js.map +1 -0
  59. package/extractors/model/allOf.d.ts +4 -0
  60. package/extractors/model/allOf.d.ts.map +1 -0
  61. package/extractors/model/allOf.js +11 -0
  62. package/extractors/model/allOf.js.map +1 -0
  63. package/extractors/model/array.d.ts +4 -0
  64. package/extractors/model/array.d.ts.map +1 -0
  65. package/extractors/model/array.js +15 -0
  66. package/extractors/model/array.js.map +1 -0
  67. package/extractors/model/index.d.ts +4 -0
  68. package/extractors/model/index.d.ts.map +1 -0
  69. package/extractors/model/index.js +41 -0
  70. package/extractors/model/index.js.map +1 -0
  71. package/extractors/model/object.d.ts +4 -0
  72. package/extractors/model/object.d.ts.map +1 -0
  73. package/extractors/model/object.js +22 -0
  74. package/extractors/model/object.js.map +1 -0
  75. package/extractors/model/of.d.ts +8 -0
  76. package/extractors/model/of.d.ts.map +1 -0
  77. package/extractors/model/of.js +14 -0
  78. package/extractors/model/of.js.map +1 -0
  79. package/extractors/model/oneOf.d.ts +6 -0
  80. package/extractors/model/oneOf.d.ts.map +1 -0
  81. package/extractors/model/oneOf.js +11 -0
  82. package/extractors/model/oneOf.js.map +1 -0
  83. package/extractors/model/ref.d.ts +4 -0
  84. package/extractors/model/ref.d.ts.map +1 -0
  85. package/extractors/model/ref.js +13 -0
  86. package/extractors/model/ref.js.map +1 -0
  87. package/extractors/model/type.d.ts +6 -0
  88. package/extractors/model/type.d.ts.map +1 -0
  89. package/extractors/model/type.js +3 -0
  90. package/extractors/model/type.js.map +1 -0
  91. package/extractors/path/index.d.ts +8 -0
  92. package/extractors/path/index.d.ts.map +1 -0
  93. package/extractors/path/index.js +17 -0
  94. package/extractors/path/index.js.map +1 -0
  95. package/extractors/path/mediaType.d.ts +3 -0
  96. package/extractors/path/mediaType.d.ts.map +1 -0
  97. package/extractors/path/mediaType.js +10 -0
  98. package/extractors/path/mediaType.js.map +1 -0
  99. package/extractors/path/method.d.ts +4 -0
  100. package/extractors/path/method.d.ts.map +1 -0
  101. package/extractors/path/method.js +75 -0
  102. package/extractors/path/method.js.map +1 -0
  103. package/extractors/path/parameter.d.ts +4 -0
  104. package/extractors/path/parameter.d.ts.map +1 -0
  105. package/extractors/path/parameter.js +83 -0
  106. package/extractors/path/parameter.js.map +1 -0
  107. package/extractors/path/requestBody.d.ts +8 -0
  108. package/extractors/path/requestBody.d.ts.map +1 -0
  109. package/extractors/path/requestBody.js +34 -0
  110. package/extractors/path/requestBody.js.map +1 -0
  111. package/extractors/path/response.d.ts +5 -0
  112. package/extractors/path/response.d.ts.map +1 -0
  113. package/extractors/path/response.js +19 -0
  114. package/extractors/path/response.js.map +1 -0
  115. package/extractors/path/security.d.ts +4 -0
  116. package/extractors/path/security.d.ts.map +1 -0
  117. package/extractors/path/security.js +10 -0
  118. package/extractors/path/security.js.map +1 -0
  119. package/extractors/path/status.d.ts +3 -0
  120. package/extractors/path/status.d.ts.map +1 -0
  121. package/extractors/path/status.js +11 -0
  122. package/extractors/path/status.js.map +1 -0
  123. package/extractors/path/type.d.ts +20 -0
  124. package/extractors/path/type.d.ts.map +1 -0
  125. package/extractors/path/type.js +3 -0
  126. package/extractors/path/type.js.map +1 -0
  127. package/extractors/schema/allOf.d.ts +7 -0
  128. package/extractors/schema/allOf.d.ts.map +1 -0
  129. package/extractors/schema/allOf.js +16 -0
  130. package/extractors/schema/allOf.js.map +1 -0
  131. package/extractors/schema/array.d.ts +12 -0
  132. package/extractors/schema/array.d.ts.map +1 -0
  133. package/extractors/schema/array.js +30 -0
  134. package/extractors/schema/array.js.map +1 -0
  135. package/extractors/schema/boolean.d.ts +11 -0
  136. package/extractors/schema/boolean.d.ts.map +1 -0
  137. package/extractors/schema/boolean.js +15 -0
  138. package/extractors/schema/boolean.js.map +1 -0
  139. package/extractors/schema/index.d.ts +9 -0
  140. package/extractors/schema/index.d.ts.map +1 -0
  141. package/extractors/schema/index.js +40 -0
  142. package/extractors/schema/index.js.map +1 -0
  143. package/extractors/schema/number.d.ts +11 -0
  144. package/extractors/schema/number.d.ts.map +1 -0
  145. package/extractors/schema/number.js +15 -0
  146. package/extractors/schema/number.js.map +1 -0
  147. package/extractors/schema/object.d.ts +7 -0
  148. package/extractors/schema/object.d.ts.map +1 -0
  149. package/extractors/schema/object.js +16 -0
  150. package/extractors/schema/object.js.map +1 -0
  151. package/extractors/schema/oneOf.d.ts +7 -0
  152. package/extractors/schema/oneOf.d.ts.map +1 -0
  153. package/extractors/schema/oneOf.js +16 -0
  154. package/extractors/schema/oneOf.js.map +1 -0
  155. package/extractors/schema/ref.d.ts +7 -0
  156. package/extractors/schema/ref.d.ts.map +1 -0
  157. package/extractors/schema/ref.js +16 -0
  158. package/extractors/schema/ref.js.map +1 -0
  159. package/extractors/schema/string.d.ts +11 -0
  160. package/extractors/schema/string.d.ts.map +1 -0
  161. package/extractors/schema/string.js +15 -0
  162. package/extractors/schema/string.js.map +1 -0
  163. package/index.d.ts +3 -0
  164. package/index.d.ts.map +1 -0
  165. package/index.js +15 -0
  166. package/index.js.map +1 -0
  167. package/package.json +55 -0
  168. package/parser.d.ts +8 -0
  169. package/parser.d.ts.map +1 -0
  170. package/parser.js +15 -0
  171. package/parser.js.map +1 -0
  172. package/parsers/api.d.ts +7 -0
  173. package/parsers/api.d.ts.map +1 -0
  174. package/parsers/api.js +29 -0
  175. package/parsers/api.js.map +1 -0
  176. package/parsers/model.d.ts +4 -0
  177. package/parsers/model.d.ts.map +1 -0
  178. package/parsers/model.js +11 -0
  179. package/parsers/model.js.map +1 -0
  180. package/types/api.d.ts +105 -0
  181. package/types/api.d.ts.map +1 -0
  182. package/types/api.js +3 -0
  183. package/types/api.js.map +1 -0
  184. package/types/index.d.ts +3 -0
  185. package/types/index.d.ts.map +1 -0
  186. package/types/index.js +15 -0
  187. package/types/index.js.map +1 -0
  188. package/types/model.d.ts +94 -0
  189. package/types/model.d.ts.map +1 -0
  190. package/types/model.js +3 -0
  191. package/types/model.js.map +1 -0
  192. package/utils/method.d.ts +4 -0
  193. package/utils/method.d.ts.map +1 -0
  194. package/utils/method.js +5 -0
  195. package/utils/method.js.map +1 -0
  196. package/utils/omitCopy.d.ts +2 -0
  197. package/utils/omitCopy.d.ts.map +1 -0
  198. package/utils/omitCopy.js +6 -0
  199. package/utils/omitCopy.js.map +1 -0
  200. package/utils/overwrite.d.ts +2 -0
  201. package/utils/overwrite.d.ts.map +1 -0
  202. package/utils/overwrite.js +5 -0
  203. package/utils/overwrite.js.map +1 -0
  204. package/utils/sort.d.ts +6 -0
  205. package/utils/sort.d.ts.map +1 -0
  206. package/utils/sort.js +5 -0
  207. package/utils/sort.js.map +1 -0
  208. package/utils/uniq.d.ts +2 -0
  209. package/utils/uniq.d.ts.map +1 -0
  210. package/utils/uniq.js +5 -0
  211. package/utils/uniq.js.map +1 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractArraySchema = void 0;
4
+ const change_case_1 = require("change-case");
5
+ const schemaModel_1 = require("../../converters/schemaModel");
6
+ const model_1 = require("../../converters/model");
7
+ const array_1 = require("../../converters/array");
8
+ const index_1 = require("./index");
9
+ exports.extractArraySchema = async (title, schema, context) => {
10
+ const models = [];
11
+ const imports = [];
12
+ let itemSchema = undefined;
13
+ if (schema.items) {
14
+ const { schema: shm, models: itemModels, imports: itemImports } = await index_1.extractSchema(change_case_1.pascalCase([title, 'Item'].join(' ')), schema.items, context);
15
+ itemSchema = shm;
16
+ models.push(...itemModels);
17
+ imports.push(...(itemImports ?? []));
18
+ }
19
+ if (schema.title) {
20
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
21
+ const model = model_1.convertModel(title, array_1.convertArray(schema, itemSchema));
22
+ return { schema: modelSchema, models: [model, ...models], imports: [...models] };
23
+ }
24
+ return {
25
+ schema: array_1.convertArray(schema, itemSchema),
26
+ models: models,
27
+ imports,
28
+ };
29
+ };
30
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/extractors/schema/array.ts"],"names":[],"mappings":";;;AAEA,6CAAuC;AACvC,8DAAgE;AAChE,kDAAoD;AACpD,kDAAoD;AACpD,mCAAsC;AAEzB,QAAA,kBAAkB,GAAG,KAAK,EAAE,KAAa,EAAE,MAA0B,EAAE,OAAyB,EAAE,EAAE;IAC/G,MAAM,MAAM,GAAY,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAY,EAAE,CAAC;IAC5B,IAAI,UAAU,GAAG,SAAS,CAAC;IAC3B,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,EAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAC,GAC3D,MAAM,qBAAa,CAAC,wBAAU,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACpF,UAAU,GAAG,GAAG,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QAC3B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC;KACtC;IACD,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,oBAAY,CAAC,KAAK,EAAE,oBAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;QACpE,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,EAAC,CAAC;KAChF;IACD,OAAO;QACL,MAAM,EAAE,oBAAY,CAAC,MAAM,EAAE,UAAU,CAAC;QACxC,MAAM,EAAE,MAAM;QACd,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { OpenapiSchemaBoolean } from '@automatons/tools';
2
+ export declare const extractBooleanSchema: (title: string, schema: OpenapiSchemaBoolean) => {
3
+ schema: import("../..").ModelSchema;
4
+ models: import("../..").Model[];
5
+ imports: import("../..").Model[];
6
+ } | {
7
+ schema: import("../..").BooleanSchema;
8
+ models: never[];
9
+ imports?: undefined;
10
+ };
11
+ //# sourceMappingURL=boolean.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAKvD,eAAO,MAAM,oBAAoB,UAAW,MAAM,UAAU,oBAAoB;;;;;;;;CAO/E,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractBooleanSchema = void 0;
4
+ const schemaModel_1 = require("../../converters/schemaModel");
5
+ const model_1 = require("../../converters/model");
6
+ const boolean_1 = require("../../converters/boolean");
7
+ exports.extractBooleanSchema = (title, schema) => {
8
+ if (schema.title) {
9
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
10
+ const models = [model_1.convertModel(title, boolean_1.convertBoolean(schema))];
11
+ return { schema: modelSchema, models, imports: models };
12
+ }
13
+ return { schema: boolean_1.convertBoolean(schema), models: [] };
14
+ };
15
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/extractors/schema/boolean.ts"],"names":[],"mappings":";;;AACA,8DAAgE;AAChE,kDAAoD;AACpD,sDAAwD;AAE3C,QAAA,oBAAoB,GAAG,CAAC,KAAa,EAAE,MAA4B,EAAE,EAAE;IAClF,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,CAAC,oBAAY,CAAC,KAAK,EAAE,wBAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC7D,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;KACvD;IACD,OAAO,EAAC,MAAM,EAAE,wBAAc,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAC,CAAC;AACtD,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AutomatonContext, OpenapiSchema } from '@automatons/tools';
2
+ import { Model, Schema } from '../../types';
3
+ export declare type ExtractSchemaResult = {
4
+ schema: Schema;
5
+ models: Model[];
6
+ imports?: Model[];
7
+ };
8
+ export declare const extractSchema: (title: string, schema: OpenapiSchema, context: AutomatonContext) => Promise<ExtractSchemaResult>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAShB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,aAAa,CAAC;AAU1C,oBAAY,mBAAmB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC;AAEzF,eAAO,MAAM,aAAa,UAAiB,MAAM,UAAU,aAAa,WAC7D,gBAAgB,KAAG,OAAO,CAAC,mBAAmB,CAmBxD,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractSchema = void 0;
4
+ const tools_1 = require("@automatons/tools");
5
+ const number_1 = require("./number");
6
+ const array_1 = require("./array");
7
+ const object_1 = require("./object");
8
+ const allOf_1 = require("./allOf");
9
+ const oneOf_1 = require("./oneOf");
10
+ const ref_1 = require("./ref");
11
+ const string_1 = require("./string");
12
+ const boolean_1 = require("./boolean");
13
+ exports.extractSchema = async (title, schema, context) => {
14
+ if (tools_1.isSchemaString(schema)) {
15
+ return string_1.extractStringSchema(title, schema);
16
+ }
17
+ else if (tools_1.isSchemaNumber(schema) || tools_1.isSchemaInteger(schema)) {
18
+ return number_1.extractNumberSchema(title, schema);
19
+ }
20
+ else if (tools_1.isSchemaBoolean(schema)) {
21
+ return boolean_1.extractBooleanSchema(title, schema);
22
+ }
23
+ else if (tools_1.isSchemaArray(schema)) {
24
+ return array_1.extractArraySchema(title, schema, context);
25
+ }
26
+ else if (tools_1.isSchemaObject(schema)) {
27
+ return object_1.extractObjectSchema(title, schema, context);
28
+ }
29
+ else if (tools_1.isSchemaAllOf(schema)) {
30
+ return allOf_1.extractAllOfSchema(title, schema, context);
31
+ }
32
+ else if (tools_1.isSchemaOneOf(schema)) {
33
+ return oneOf_1.extractOneOfSchema(title, schema, context);
34
+ }
35
+ else if (tools_1.isSchemaRef(schema)) {
36
+ return ref_1.extractRefSchema(title, schema);
37
+ }
38
+ throw new Error(`Unknown type\n${JSON.stringify(schema, undefined, 2)}`);
39
+ };
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extractors/schema/index.ts"],"names":[],"mappings":";;;AAAA,6CAW2B;AAE3B,qCAA6C;AAC7C,mCAA2C;AAC3C,qCAA6C;AAC7C,mCAA2C;AAC3C,mCAA2C;A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SchemaInteger, OpenapiSchemaNumber } from '@automatons/tools';
2
+ export declare const extractNumberSchema: (title: string, schema: OpenapiSchemaNumber | OpenapiSchemaInteger) => {
3
+ schema: import("../..").ModelSchema;
4
+ models: import("../..").Model[];
5
+ imports: import("../..").Model[];
6
+ } | {
7
+ schema: import("../..").NumberSchema;
8
+ models: never[];
9
+ imports?: undefined;
10
+ };
11
+ //# sourceMappingURL=number.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAK5E,eAAO,MAAM,mBAAmB,UAAW,MAAM,UAAU,mBAAmB,GAAG,oBAAoB;;;;;;;;CAOpG,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractNumberSchema = void 0;
4
+ const schemaModel_1 = require("../../converters/schemaModel");
5
+ const model_1 = require("../../converters/model");
6
+ const number_1 = require("../../converters/number");
7
+ exports.extractNumberSchema = (title, schema) => {
8
+ if (schema.title) {
9
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
10
+ const models = [model_1.convertModel(title, number_1.convertNumber(schema))];
11
+ return { schema: modelSchema, models, imports: models };
12
+ }
13
+ return { schema: number_1.convertNumber(schema), models: [] };
14
+ };
15
+ //# sourceMappingURL=number.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src/extractors/schema/number.ts"],"names":[],"mappings":";;;AACA,8DAAgE;AAChE,kDAAoD;AACpD,oDAAsD;AAEzC,QAAA,mBAAmB,GAAG,CAAC,KAAa,EAAE,MAAkD,EAAE,EAAE;IACvG,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,CAAC,oBAAY,CAAC,KAAK,EAAE,sBAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5D,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;KACvD;IACD,OAAO,EAAC,MAAM,EAAE,sBAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAC,CAAC;AACrD,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AutomatonContext, OpenapiSchemaObject } from '@automatons/tools';
2
+ export declare const extractObjectSchema: (title: string, schema: OpenapiSchemaObject, context: AutomatonContext) => Promise<{
3
+ schema: import("../..").ModelSchema;
4
+ models: import("../..").Model[];
5
+ imports: import("../..").Model[];
6
+ }>;
7
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAKxE,eAAO,MAAM,mBAAmB,UAAiB,MAAM,UAAU,mBAAmB,WAAW,gBAAgB;;;;EAQ9G,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractObjectSchema = void 0;
4
+ const schemaModel_1 = require("../../converters/schemaModel");
5
+ const model_1 = require("../model");
6
+ const model_2 = require("../../converters/model");
7
+ exports.extractObjectSchema = async (title, schema, context) => {
8
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
9
+ const { model, insides } = await model_1.extractModel(title, schema, context);
10
+ return {
11
+ schema: modelSchema,
12
+ models: [model, ...insides],
13
+ imports: [model_2.convertModel(title, modelSchema)],
14
+ };
15
+ };
16
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/extractors/schema/object.ts"],"names":[],"mappings":";;;AACA,8DAAgE;AAChE,oCAAsC;AACtC,kDAAoD;AAEvC,QAAA,mBAAmB,GAAG,KAAK,EAAE,KAAa,EAAE,MAA2B,EAAE,OAAyB,EAAE,EAAE;IACjH,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAG,MAAM,oBAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC;QAC3B,OAAO,EAAE,CAAC,oBAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { AutomatonContext, OpenapiSchemaOneOf } from '@automatons/tools';
2
+ export declare const extractOneOfSchema: (title: string, schema: OpenapiSchemaOneOf, context: AutomatonContext) => Promise<{
3
+ schema: import("../..").ModelSchema;
4
+ models: import("../..").Model[];
5
+ imports: import("../..").Model[];
6
+ }>;
7
+ //# sourceMappingURL=oneOf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneOf.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/oneOf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAKvE,eAAO,MAAM,kBAAkB,UAAiB,MAAM,UAAU,kBAAkB,WAAW,gBAAgB;;;;EAQ5G,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractOneOfSchema = void 0;
4
+ const schemaModel_1 = require("../../converters/schemaModel");
5
+ const model_1 = require("../model");
6
+ const model_2 = require("../../converters/model");
7
+ exports.extractOneOfSchema = async (title, schema, context) => {
8
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
9
+ const { model, insides } = await model_1.extractModel(title, schema, context);
10
+ return {
11
+ schema: modelSchema,
12
+ models: [model, ...insides],
13
+ imports: [model_2.convertModel(title, modelSchema)],
14
+ };
15
+ };
16
+ //# sourceMappingURL=oneOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oneOf.js","sourceRoot":"","sources":["../../../src/extractors/schema/oneOf.ts"],"names":[],"mappings":";;;AACA,8DAAgE;AAChE,oCAAsC;AACtC,kDAAoD;AAEvC,QAAA,kBAAkB,GAAG,KAAK,EAAE,KAAa,EAAE,MAA0B,EAAE,OAAyB,EAAE,EAAE;IAC/G,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAG,MAAM,oBAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC;QAC3B,OAAO,EAAE,CAAC,oBAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { OpenapiSchemaReference } from '@automatons/tools';
2
+ export declare const extractRefSchema: (title: string, schema: OpenapiSchemaReference) => {
3
+ schema: import("../..").ModelSchema;
4
+ models: never[];
5
+ imports: import("../..").Model[];
6
+ };
7
+ //# sourceMappingURL=ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAiB,MAAM,mBAAmB,CAAC;AAIzE,eAAO,MAAM,gBAAgB,UAAW,MAAM,UAAU,sBAAsB;;;;CAQ7E,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractRefSchema = void 0;
4
+ const tools_1 = require("@automatons/tools");
5
+ const schemaModel_1 = require("../../converters/schemaModel");
6
+ const model_1 = require("../../converters/model");
7
+ exports.extractRefSchema = (title, schema) => {
8
+ const name = tools_1.referenceTitle(schema) ?? title;
9
+ const modelSchema = schemaModel_1.convertSchemaModel(name, schema);
10
+ return {
11
+ schema: modelSchema,
12
+ models: [],
13
+ imports: [model_1.convertModel(name, modelSchema)],
14
+ };
15
+ };
16
+ //# sourceMappingURL=ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.js","sourceRoot":"","sources":["../../../src/extractors/schema/ref.ts"],"names":[],"mappings":";;;AAAA,6CAAyE;AACzE,8DAAgE;AAChE,kDAAoD;AAEvC,QAAA,gBAAgB,GAAG,CAAC,KAAa,EAAE,MAA8B,EAAE,EAAE;IAChF,MAAM,IAAI,GAAG,sBAAc,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;IAC7C,MAAM,WAAW,GAAG,gCAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,CAAC,oBAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { OpenapiSchemaString } from '@automatons/tools';
2
+ export declare const extractStringSchema: (title: string, schema: OpenapiSchemaString) => {
3
+ schema: import("../..").ModelSchema;
4
+ models: import("../..").Model[];
5
+ imports: import("../..").Model[];
6
+ } | {
7
+ schema: import("../..").StringSchema;
8
+ models: never[];
9
+ imports?: undefined;
10
+ };
11
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/extractors/schema/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,mBAAmB,UAAW,MAAM,UAAU,mBAAmB;;;;;;;;CAO7E,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractStringSchema = void 0;
4
+ const schemaModel_1 = require("../../converters/schemaModel");
5
+ const model_1 = require("../../converters/model");
6
+ const string_1 = require("../../converters/string");
7
+ exports.extractStringSchema = (title, schema) => {
8
+ if (schema.title) {
9
+ const modelSchema = schemaModel_1.convertSchemaModel(title, schema);
10
+ const models = [model_1.convertModel(title, string_1.convertString(schema))];
11
+ return { schema: modelSchema, models, imports: models };
12
+ }
13
+ return { schema: string_1.convertString(schema), models: [] };
14
+ };
15
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/extractors/schema/string.ts"],"names":[],"mappings":";;;AACA,8DAAgE;AAChE,kDAAoD;AACpD,oDAAsD;AAEzC,QAAA,mBAAmB,GAAG,CAAC,KAAa,EAAE,MAA2B,EAAE,EAAE;IAChF,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,MAAM,WAAW,GAAG,gCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,CAAC,oBAAY,CAAC,KAAK,EAAE,sBAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5D,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;KACvD;IACD,OAAO,EAAC,MAAM,EAAE,sBAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAC,CAAC;AACrD,CAAC,CAAC"}
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './parser';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./parser"), exports);
14
+ __exportStar(require("./types"), exports);
15
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAyB;AACzB,0CAAwB"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@automatons/parser",
3
+ "version": "0.0.2",
4
+ "repository": "git@github.com:openapi-automatons/parser.git",
5
+ "author": "tanmen <yt.prog@gmail.com>",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "openapi",
9
+ "openapi-automatons",
10
+ "automatons"
11
+ ],
12
+ "main": "index.js",
13
+ "scripts": {
14
+ "prebuild": "depcheck && node scripts/prebuild.js",
15
+ "build": "tsc && cp package.json README.md LICENSE dist",
16
+ "postinstall": "husky install && typesync && yarn check --integrity || yarn install --ignore-scripts && yarn-deduplicate",
17
+ "lint": "eslint src --ext .ts,.tsx",
18
+ "test": "jest"
19
+ },
20
+ "dependencies": {
21
+ "@automatons/tools": "^1.0.9",
22
+ "change-case": "^4.1.1",
23
+ "deep-equal": "^2.0.3",
24
+ "fs-extra": "^10.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@commitlint/cli": "^14.1.0",
28
+ "@commitlint/config-conventional": "^14.1.0",
29
+ "@semantic-release/changelog": "^6.0.1",
30
+ "@semantic-release/git": "^10.0.1",
31
+ "@semantic-release/npm": "^8.0.3",
32
+ "@types/deep-equal": "^1.0.1",
33
+ "@types/eslint": "^7.28.2",
34
+ "@types/fs-extra": "^9.0.1",
35
+ "@types/jest": "^25.2.1",
36
+ "@types/node": "^13.13.0",
37
+ "@types/semantic-release": "^17.2.3",
38
+ "@typescript-eslint/eslint-plugin": "^5.3.1",
39
+ "@typescript-eslint/parser": "^5.3.1",
40
+ "depcheck": "^1.4.2",
41
+ "eslint": "^8.2.0",
42
+ "eslint-config-google": "^0.14.0",
43
+ "husky": "^7.0.4",
44
+ "jest": "^26.0.1",
45
+ "lint-staged": "^12.0.2",
46
+ "semantic-release": "^18.0.0",
47
+ "ts-jest": "^26.0.0",
48
+ "typescript": "^3.9.3",
49
+ "typesync": "^0.8.0",
50
+ "yarn-deduplicate": "^3.1.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ }
55
+ }
package/parser.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { AutomatonSettings, Openapi } from '@automatons/tools';
2
+ import { Api, Model, Security } from './types';
3
+ export declare const parser: (openapi: Openapi, settings: AutomatonSettings) => Promise<{
4
+ models: Model[];
5
+ apis: Api[];
6
+ securities: Security[];
7
+ }>;
8
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,MAAM,YACD,OAAO,YAAY,iBAAiB;YAChC,KAAK,EAAE;UAAQ,GAAG,EAAE;gBAAc,QAAQ,EAAE;EAO/D,CAAC"}
package/parser.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parser = void 0;
4
+ const security_1 = require("./converters/security");
5
+ const api_1 = require("./parsers/api");
6
+ const model_1 = require("./parsers/model");
7
+ exports.parser = async (openapi, settings) => {
8
+ const { apis, models } = await api_1.parseApi({ openapi, settings });
9
+ models.push(...await model_1.parseModel({ openapi, settings }));
10
+ const securities = Object.entries(openapi.components?.securitySchemes ?? {})
11
+ .map(([key, schema]) => security_1.convertSecurity(key, schema, []))
12
+ .filter((value) => value !== undefined);
13
+ return { models, apis, securities };
14
+ };
15
+ //# sourceMappingURL=parser.js.map
package/parser.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;;AACA,oDAAsD;AACtD,uCAAuC;AACvC,2CAA2C;AAG9B,QAAA,MAAM,GACjB,KAAK,EAAE,OAAgB,EAAE,QAA2B,EACgB,EAAE;IACpE,MAAM,EAAC,IAAI,EAAE,MAAM,EAAC,GAAG,MAAM,cAAQ,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,kBAAU,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,eAAe,IAAI,EAAE,CAAC;SACzE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,0BAAe,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;SACxD,MAAM,CAAW,CAAC,KAAK,EAAqB,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACvE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAC,CAAC;AACpC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Api, Model } from '../types';
2
+ import { AutomatonContext } from '@automatons/tools';
3
+ export declare const parseApi: ({ openapi, settings }: AutomatonContext) => Promise<{
4
+ apis: Api[];
5
+ models: Model[];
6
+ }>;
7
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/parsers/api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAO,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAGnD,eAAO,MAAM,QAAQ,0BAA+B,gBAAgB,KAAG,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAa9G,CAAC"}
package/parsers/api.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseApi = void 0;
4
+ const change_case_1 = require("change-case");
5
+ const map_1 = require("../converters/map");
6
+ const extractors_1 = require("../extractors");
7
+ const uniq_1 = require("../utils/uniq");
8
+ const overwrite_1 = require("../utils/overwrite");
9
+ exports.parseApi = async ({ openapi, settings }) => {
10
+ const paths = (await Promise.all(map_1.convertMap(openapi.paths)
11
+ .map(({ key, schema }) => extractors_1.extractPath(schema, { path: key, openapi, settings })))).flat();
12
+ return {
13
+ apis: paths
14
+ .reduce((apis, path) => path.tags.reduce((_apis, tag) => {
15
+ const title = change_case_1.pascalCase([tag, 'Api'].join(' '));
16
+ const api = _apis.find((api) => api.title === title);
17
+ return overwrite_1.overwrite(_apis, createApi(title, path.path, path.imports, api), (item) => item.title !== title);
18
+ }, apis), []),
19
+ models: paths.reduce((models, cur) => uniq_1.uniq([...models, ...cur.models], 'title'), []),
20
+ };
21
+ };
22
+ const createApi = (title, path, imports, base) => ({
23
+ title: change_case_1.pascalCase(title),
24
+ filename: change_case_1.camelCase(title),
25
+ imports: uniq_1.uniq([...base?.imports ?? [], ...imports], 'title'),
26
+ servers: uniq_1.uniq([...base?.servers ?? [], ...path.servers], 'name'),
27
+ paths: [...base?.paths ?? [], path],
28
+ });
29
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/parsers/api.ts"],"names":[],"mappings":";;;AAAA,6CAAkD;AAClD,2CAA6C;AAC7C,8CAA0C;AAE1C,wCAAmC;AAEnC,kDAA6C;AAEhC,QAAA,QAAQ,GAAG,KAAK,EAAE,EAAC,OAAO,EAAE,QAAQ,EAAmB,EAA6C,EAAE;IACjH,MAAM,KAAK,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAU,CAAC,OAAO,CAAC,KAAK,CAAC;SACvD,GAAG,CAAC,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,wBAAW,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxF,OAAO;QACL,IAAI,EAAE,KAAK;aACR,MAAM,CAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACrC,MAAM,KAAK,GAAG,wBAAU,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACjD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;YACrD,OAAO,qBAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;QAC1G,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAU,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,WAAI,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;KAC9F,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,IAAU,EAAE,OAAgB,EAAE,IAAU,EAAE,EAAE,CAAC,CAAC;IAC9E,KAAK,EAAE,wBAAU,CAAC,KAAK,CAAC;IACxB,QAAQ,EAAE,uBAAS,CAAC,KAAK,CAAC;IAC1B,OAAO,EAAE,WAAI,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC;IAC5D,OAAO,EAAE,WAAI,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAChE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,IAAI,EAAE,EAAE,IAAI,CAAC;CACpC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Model } from '../types';
2
+ import { AutomatonContext } from '@automatons/tools';
3
+ export declare const parseModel: (context: AutomatonContext) => Promise<Model[]>;
4
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/parsers/model.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,eAAO,MAAM,UAAU,YAAmB,gBAAgB,KAAG,OAAO,CAAC,KAAK,EAAE,CAKhE,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseModel = void 0;
4
+ const change_case_1 = require("change-case");
5
+ const map_1 = require("../converters/map");
6
+ const model_1 = require("../extractors/model");
7
+ exports.parseModel = async (context) => (await Promise.all(map_1.convertMap(context.openapi.components?.schemas)
8
+ .map(({ key, schema }) => ({ title: change_case_1.pascalCase(key), schema }))
9
+ .map(async ({ title, schema }) => Object.values(await model_1.extractModel(title, schema, context)))))
10
+ .flat(2);
11
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/parsers/model.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,2CAA6C;AAC7C,+CAAiD;AAIpC,QAAA,UAAU,GAAG,KAAK,EAAE,OAAyB,EAAoB,EAAE,CAC9E,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAU,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC;KAC/D,GAAG,CAAC,CAAC,EAAC,GAAG,EAAE,MAAM,EAAC,EAAE,EAAE,CACrB,CAAC,EAAC,KAAK,EAAE,wBAAU,CAAC,GAAG,CAAC,EAAE,MAAM,EAAC,CAAC,CAAC;KACpC,GAAG,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,oBAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3F,IAAI,CAAC,CAAC,CAAC,CAAC"}
package/types/api.d.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { Model, Schema } from './model';
2
+ export interface Api {
3
+ title: string;
4
+ filename: string;
5
+ servers: Server[];
6
+ imports: Model[];
7
+ paths: Path[];
8
+ }
9
+ export declare type Path = ReceivePath | AffectPath;
10
+ export declare type ReceiveMethod = 'get' | 'head' | 'delete' | 'options' | 'trace';
11
+ export declare type ReceivePath = {
12
+ name: string;
13
+ method: ReceiveMethod;
14
+ path: string;
15
+ servers: Server[];
16
+ parameters?: PathParameter[];
17
+ queries?: QueryParameter[];
18
+ headers?: HeaderParameter[];
19
+ cookies?: CookieParameter[];
20
+ schema?: Schema;
21
+ securities?: Security[];
22
+ };
23
+ export declare type AffectMethod = 'post' | 'put' | 'patch';
24
+ export declare type AffectPath = {
25
+ name: string;
26
+ method: AffectMethod;
27
+ path: string;
28
+ servers: Server[];
29
+ forms?: Form[];
30
+ parameters?: PathParameter[];
31
+ queries?: QueryParameter[];
32
+ headers?: HeaderParameter[];
33
+ cookies?: CookieParameter[];
34
+ schema?: Schema;
35
+ securities?: Security[];
36
+ };
37
+ export declare type Form = {
38
+ types: string[];
39
+ required?: boolean;
40
+ schema: Schema;
41
+ };
42
+ export declare type Server = {
43
+ name: string;
44
+ url: string;
45
+ values?: ServerValue[];
46
+ };
47
+ export declare type ServerValue = {
48
+ name: string;
49
+ defaultValue: string;
50
+ enums: string[];
51
+ };
52
+ export declare type PathParameter = {
53
+ name: string;
54
+ schema: Schema;
55
+ style: 'simple' | 'label' | 'matrix';
56
+ explode?: boolean;
57
+ };
58
+ export declare type QueryParameter = {
59
+ name: string;
60
+ schema: Schema;
61
+ style: 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
62
+ required?: boolean;
63
+ explode?: boolean;
64
+ };
65
+ export declare type HeaderParameter = {
66
+ name: string;
67
+ schema: Schema;
68
+ style: 'simple';
69
+ required?: boolean;
70
+ explode?: boolean;
71
+ };
72
+ export declare type CookieParameter = {
73
+ name: string;
74
+ schema: Schema;
75
+ style: 'form';
76
+ required?: boolean;
77
+ explode?: boolean;
78
+ };
79
+ export declare type Security = ApiKeySecurity | HttpSecurity | Oauth2Security | OpenIdConnectSecurity;
80
+ export declare type ApiKeySecurity = {
81
+ name: string;
82
+ type: 'apiKey';
83
+ key: string;
84
+ in: 'query' | 'header' | 'cookie';
85
+ description?: string;
86
+ };
87
+ export declare type HttpSecurity = {
88
+ name: string;
89
+ type: 'http';
90
+ scheme: 'basic' | 'bearer';
91
+ description?: string;
92
+ };
93
+ export declare type Oauth2Security = {
94
+ name: string;
95
+ type: 'oauth2';
96
+ scopes: string[];
97
+ description?: string;
98
+ };
99
+ export declare type OpenIdConnectSecurity = {
100
+ name: string;
101
+ type: 'openIdConnect';
102
+ scopes: string[];
103
+ description?: string;
104
+ };
105
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/types/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAA;CACd;AAED,oBAAY,IAAI,GAAG,WAAW,GAAG,UAAU,CAAC;AAE5C,oBAAY,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5E,oBAAY,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,eA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