react-query-lightbase-codegen 1.0.1 → 1.0.4

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 (41) hide show
  1. package/{lib/typescript → dist}/convertSwaggerFile.d.ts +0 -0
  2. package/{lib/src → dist}/convertSwaggerFile.js +7 -10
  3. package/dist/convertSwaggerFile.js.map +1 -0
  4. package/{lib/typescript → dist}/generateHooks.d.ts +0 -0
  5. package/dist/generateHooks.js +395 -0
  6. package/dist/generateHooks.js.map +1 -0
  7. package/{lib/typescript → dist}/generateImports.d.ts +0 -0
  8. package/dist/generateImports.js +28 -0
  9. package/dist/generateImports.js.map +1 -0
  10. package/{lib/typescript → dist}/generateSchemas.d.ts +0 -0
  11. package/dist/generateSchemas.js +97 -0
  12. package/dist/generateSchemas.js.map +1 -0
  13. package/{lib/typescript → dist}/importSpecs.d.ts +0 -0
  14. package/dist/importSpecs.js +81 -0
  15. package/dist/importSpecs.js.map +1 -0
  16. package/{lib/typescript → dist}/index.d.ts +0 -0
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -0
  19. package/{lib/typescript → dist}/utils.d.ts +0 -0
  20. package/{lib/src → dist}/utils.js +38 -53
  21. package/dist/utils.js.map +1 -0
  22. package/package.json +9 -27
  23. package/lib/commonjs/convertSwaggerFile.js +0 -37
  24. package/lib/commonjs/convertSwaggerFile.js.map +0 -1
  25. package/lib/commonjs/generateHooks.js +0 -492
  26. package/lib/commonjs/generateHooks.js.map +0 -1
  27. package/lib/commonjs/generateImports.js +0 -48
  28. package/lib/commonjs/generateImports.js.map +0 -1
  29. package/lib/commonjs/generateSchemas.js +0 -119
  30. package/lib/commonjs/generateSchemas.js.map +0 -1
  31. package/lib/commonjs/importSpecs.js +0 -117
  32. package/lib/commonjs/importSpecs.js.map +0 -1
  33. package/lib/commonjs/index.js +0 -22
  34. package/lib/commonjs/index.js.map +0 -1
  35. package/lib/commonjs/utils.js +0 -212
  36. package/lib/commonjs/utils.js.map +0 -1
  37. package/lib/src/generateHooks.js +0 -249
  38. package/lib/src/generateImports.js +0 -29
  39. package/lib/src/generateSchemas.js +0 -108
  40. package/lib/src/importSpecs.js +0 -134
  41. package/lib/src/index.js +0 -7
@@ -1,119 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateSchemas = void 0;
7
-
8
- var _case = _interopRequireDefault(require("case"));
9
-
10
- var _lodash = _interopRequireDefault(require("lodash"));
11
-
12
- var _utils = require("./utils.js");
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- const {
17
- isEmpty
18
- } = _lodash.default;
19
- const {
20
- pascal
21
- } = _case.default;
22
-
23
- /**
24
- * Generate the interface string
25
- */
26
- const generateInterface = (name, schema) => {
27
- const scalar = (0, _utils.getScalar)(schema);
28
- return `${(0, _utils.formatDescription)(schema.description)}
29
- export type ${pascal(name)} = ${scalar}
30
- `;
31
- };
32
- /**
33
- * Extract all types from #/components/schemas
34
- */
35
-
36
-
37
- const generateSchemasDefinition = function () {
38
- let schemas = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
-
40
- if (isEmpty(schemas)) {
41
- return '';
42
- }
43
-
44
- return '\n // SCEHMAS \n' + Object.entries(schemas).map(_ref => {
45
- let [name, schema] = _ref;
46
- return !(0, _utils.isReference)(schema) && (!schema.type || schema.type === 'object') && !schema.allOf && !schema.oneOf && !(0, _utils.isReference)(schema) && !schema.nullable ? generateInterface(name, schema) : `${(0, _utils.formatDescription)((0, _utils.isReference)(schema) ? undefined : schema.description)} export type ${pascal(name)} = ${(0, _utils.resolveValue)(schema)};`;
47
- }).join('\n\n') + '\n';
48
- };
49
- /**
50
- * Extract all types from #/components/requestBodies
51
- */
52
-
53
-
54
- const generateRequestBodiesDefinition = function () {
55
- let requestBodies = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
56
-
57
- if (isEmpty(requestBodies)) {
58
- return '';
59
- }
60
-
61
- return '\n // REQUEST BODIES \n' + Object.entries(requestBodies).map(_ref2 => {
62
- let [name, requestBody] = _ref2;
63
- const doc = (0, _utils.getDocs)(requestBody);
64
- const type = (0, _utils.getResReqTypes)([['', requestBody]]);
65
- const isEmptyInterface = type === '{}';
66
-
67
- if (isEmptyInterface) {
68
- return `${doc}\nexport type ${pascal(name)}RequestBody = ${type}`;
69
- } else if (type.includes('{') && !type.includes('|') && !type.includes('&')) {
70
- return `${doc}\nexport type ${pascal(name)}RequestBody = ${type}`;
71
- } else {
72
- return `${doc}\nexport type ${pascal(name)}RequestBody = ${type};`;
73
- }
74
- }).join('\n\n') + '\n';
75
- };
76
- /**
77
- * Extract all types from #/components/responses
78
- */
79
-
80
-
81
- const generateResponsesDefinition = function () {
82
- let responses = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
83
-
84
- if (isEmpty(responses)) {
85
- return '';
86
- }
87
-
88
- return '\n // RESPONSES \n' + Object.entries(responses).map(_ref3 => {
89
- let [name, response] = _ref3;
90
- const doc = (0, _utils.getDocs)(response);
91
- const type = (0, _utils.getResReqTypes)([['', response]]);
92
- const isEmptyInterface = type === '{}';
93
-
94
- if (isEmptyInterface) {
95
- return `export type RQ${pascal(name)}Response = ${type}`;
96
- } else if (type.includes('{') && !type.includes('|') && !type.includes('&')) {
97
- return `${doc}export type RQ${pascal(name)}Response = ${type}`;
98
- } else {
99
- return `${doc}export type RQ${pascal(name)}Response = ${type};`;
100
- }
101
- }).join('\n\n') + '\n';
102
- };
103
- /**
104
- * Extract all types from #/components/schemas
105
- */
106
-
107
-
108
- const generateSchemas = _ref4 => {
109
- var _spec$components, _spec$components2, _spec$components3;
110
-
111
- let {
112
- spec
113
- } = _ref4;
114
- const schemaOutput = generateRequestBodiesDefinition((_spec$components = spec.components) === null || _spec$components === void 0 ? void 0 : _spec$components.requestBodies) + generateResponsesDefinition((_spec$components2 = spec.components) === null || _spec$components2 === void 0 ? void 0 : _spec$components2.responses) + generateSchemasDefinition((_spec$components3 = spec.components) === null || _spec$components3 === void 0 ? void 0 : _spec$components3.schemas);
115
- return schemaOutput;
116
- };
117
-
118
- exports.generateSchemas = generateSchemas;
119
- //# sourceMappingURL=generateSchemas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["isEmpty","lodash","pascal","pasCase","generateInterface","name","schema","scalar","getScalar","formatDescription","description","generateSchemasDefinition","schemas","Object","entries","map","isReference","type","allOf","oneOf","nullable","undefined","resolveValue","join","generateRequestBodiesDefinition","requestBodies","requestBody","doc","getDocs","getResReqTypes","isEmptyInterface","includes","generateResponsesDefinition","responses","response","generateSchemas","spec","schemaOutput","components"],"sources":["generateSchemas.ts"],"sourcesContent":["import pasCase from 'case';\nimport lodash from 'lodash';\nconst { isEmpty } = lodash;\nconst { pascal } = pasCase;\nimport { ComponentsObject, OpenAPIObject, SchemaObject } from 'openapi3-ts';\nimport { formatDescription, getScalar, isReference, resolveValue } from './utils.js';\n\nimport { getDocs, getResReqTypes } from './utils.js';\n\n/**\n * Generate the interface string\n */\nconst generateInterface = (name: string, schema: SchemaObject) => {\n const scalar = getScalar(schema);\n return `${formatDescription(schema.description)}\n export type ${pascal(name)} = ${scalar}\n `;\n};\n\n/**\n * Extract all types from #/components/schemas\n */\nconst generateSchemasDefinition = (schemas: ComponentsObject['schemas'] = {}) => {\n if (isEmpty(schemas)) {\n return '';\n }\n\n return (\n '\\n // SCEHMAS \\n' +\n Object.entries(schemas)\n .map(([name, schema]) =>\n !isReference(schema) &&\n (!schema.type || schema.type === 'object') &&\n !schema.allOf &&\n !schema.oneOf &&\n !isReference(schema) &&\n !schema.nullable\n ? generateInterface(name, schema)\n : `${formatDescription(isReference(schema) ? undefined : schema.description)} export type ${pascal(\n name\n )} = ${resolveValue(schema)};`\n )\n .join('\\n\\n') +\n '\\n'\n );\n};\n\n/**\n * Extract all types from #/components/requestBodies\n */\nconst generateRequestBodiesDefinition = (requestBodies: ComponentsObject['requestBodies'] = {}) => {\n if (isEmpty(requestBodies)) {\n return '';\n }\n\n return (\n '\\n // REQUEST BODIES \\n' +\n Object.entries(requestBodies)\n .map(([name, requestBody]) => {\n const doc = getDocs(requestBody);\n const type = getResReqTypes([['', requestBody]]);\n const isEmptyInterface = type === '{}';\n if (isEmptyInterface) {\n return `${doc}\\nexport type ${pascal(name)}RequestBody = ${type}`;\n } else if (type.includes('{') && !type.includes('|') && !type.includes('&')) {\n return `${doc}\\nexport type ${pascal(name)}RequestBody = ${type}`;\n } else {\n return `${doc}\\nexport type ${pascal(name)}RequestBody = ${type};`;\n }\n })\n .join('\\n\\n') +\n '\\n'\n );\n};\n\n/**\n * Extract all types from #/components/responses\n */\nconst generateResponsesDefinition = (responses: ComponentsObject['responses'] = {}) => {\n if (isEmpty(responses)) {\n return '';\n }\n\n return (\n '\\n // RESPONSES \\n' +\n Object.entries(responses)\n .map(([name, response]) => {\n const doc = getDocs(response);\n const type = getResReqTypes([['', response]]);\n const isEmptyInterface = type === '{}';\n if (isEmptyInterface) {\n return `export type RQ${pascal(name)}Response = ${type}`;\n } else if (type.includes('{') && !type.includes('|') && !type.includes('&')) {\n return `${doc}export type RQ${pascal(name)}Response = ${type}`;\n } else {\n return `${doc}export type RQ${pascal(name)}Response = ${type};`;\n }\n })\n .join('\\n\\n') +\n '\\n'\n );\n};\n\n/**\n * Extract all types from #/components/schemas\n */\nexport const generateSchemas = ({ spec }: { spec: OpenAPIObject }) => {\n const schemaOutput =\n generateRequestBodiesDefinition(spec.components?.requestBodies) +\n generateResponsesDefinition(spec.components?.responses) +\n generateSchemasDefinition(spec.components?.schemas);\n\n return schemaOutput;\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAIA;;;;AAHA,MAAM;EAAEA;AAAF,IAAcC,eAApB;AACA,MAAM;EAAEC;AAAF,IAAaC,aAAnB;;AAMA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,CAACC,IAAD,EAAeC,MAAf,KAAwC;EAChE,MAAMC,MAAM,GAAG,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CAAb;IACA,MAAMJ,gBAAgB,GAAGb,IAAI,KAAK,IAAlC;;IACA,IAAIa,gBAAJ,EAAsB;MACpB,OAAQ,iBAAgB5B,MAAM,CAACG,IAAD,CAAO,cAAaY,IAAK,EAAvD;IACD,CAFD,MAEO,IAAIA,IAAI,CAACc,QAAL,CAAc,GAAd,KAAsB,CAACd,IAAI,CAACc,QAAL,CAAc,GAAd,CAAvB,IAA6C,CAACd,IAAI,CAACc,QAAL,CAAc,GAAd,CAAlD,EAAsE;MAC3E,OAAQ,GAAEJ,GAAI,iBAAgBzB,MAAM,CAACG,IAAD,CAAO,cAAaY,IAAK,EAA7D;IACD,CAFM,MAEA;MACL,OAAQ,GAAEU,GAAI,iBAAgBzB,MAAM,CAACG,IAAD,CAAO,cAAaY,IAAK,GAA7D;IACD;EACF,CAZH,EAaGM,IAbH,CAaQ,MAbR,CADA,GAeA,IAhBF;AAkBD,CAvBD;AAyBA;AACA;AACA;;;AACO,MAAMY,eAAe,GAAG,SAAuC;EAAA;;EAAA,IAAtC;IAAEC;EAAF,CAAsC;EACpE,MAAMC,YAAY,GAChBb,+BAA+B,qBAACY,IAAI,CAACE,UAAN,qDAAC,iBAAiBb,aAAlB,CAA/B,GACAO,2BAA2B,sBAACI,IAAI,CAACE,UAAN,sDAAC,kBAAiBL,SAAlB,CAD3B,GAEAtB,yBAAyB,sBAACyB,IAAI,CAACE,UAAN,sDAAC,kBAAiB1B,OAAlB,CAH3B;EAKA,OAAOyB,YAAP;AACD,CAPM"}
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.importSpecs = importSpecs;
7
-
8
- var _chalk = _interopRequireDefault(require("chalk"));
9
-
10
- var _fs = require("fs");
11
-
12
- var _path = require("path");
13
-
14
- var _convertSwaggerFile = require("./convertSwaggerFile.js");
15
-
16
- var _generateHooks = require("./generateHooks.js");
17
-
18
- var _generateImports = require("./generateImports.js");
19
-
20
- var _generateSchemas = require("./generateSchemas.js");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- function importSpecs(_ref) {
25
- let {
26
- sourceDirectory,
27
- exportDirectory,
28
- apiDirectory,
29
- queryClientDir,
30
- headerFilters,
31
- overrides
32
- } = _ref;
33
- (0, _fs.readdir)(sourceDirectory, function (err, filenames) {
34
- if (err) {
35
- console.log(err);
36
- throw err;
37
- }
38
-
39
- filenames.map(async filename => {
40
- try {
41
- const data = (0, _fs.readFileSync)((0, _path.join)(process.cwd(), sourceDirectory + '/' + filename), 'utf-8');
42
- const {
43
- ext
44
- } = (0, _path.parse)(sourceDirectory + '/' + filename);
45
- const format = ['.yaml', '.yml'].includes(ext.toLowerCase()) ? 'yaml' : 'json';
46
- let spec = await (0, _convertSwaggerFile.convertSwaggerFile)(data, format);
47
- const schemaName = `useQueries${filename.split('.')[0]}.schema`;
48
- const hooksName = `useQueries${filename.split('.')[0]}`;
49
- const name = filename.split('.')[0];
50
- (0, _fs.mkdirSync)((0, _path.join)(process.cwd(), `${exportDirectory}/${name}`), {
51
- recursive: true
52
- });
53
- const operationIds = [];
54
- let hooks = '';
55
- let schemaImportsArray = [];
56
- let collectedQueryImports = [];
57
- Object.entries(spec.paths).forEach(_ref2 => {
58
- let [route, verbs] = _ref2;
59
- Object.entries(verbs).forEach(_ref3 => {
60
- let [verb, operation] = _ref3;
61
-
62
- if (['get', 'post', 'patch', 'put', 'delete'].includes(verb) && !operation.deprecated) {
63
- const {
64
- implementation,
65
- imports,
66
- queryImports
67
- } = (0, _generateHooks.createHook)({
68
- operation,
69
- verb,
70
- route: (spec.basePath || '') + route,
71
- operationIds,
72
- parameters: verbs.parameters,
73
- schemasComponents: spec.components,
74
- headerFilters,
75
- overrides
76
- });
77
- hooks += implementation;
78
- imports.forEach(element => {
79
- const formattedImport = element.replace('[]', '');
80
-
81
- if (!schemaImportsArray.includes(formattedImport) && element !== 'void' && element !== 'string' && !element.includes('{')) {
82
- schemaImportsArray.push(formattedImport);
83
- }
84
- });
85
- queryImports.forEach(element => {
86
- if (!schemaImportsArray.includes(element)) {
87
- collectedQueryImports.push(element);
88
- }
89
- });
90
- }
91
- });
92
- });
93
- const imports = (0, _generateImports.generateImports)({
94
- apiDirectory,
95
- queryClientDir,
96
- schemaName,
97
- schemaImports: schemaImportsArray,
98
- queryImports: collectedQueryImports
99
- });
100
- (0, _fs.writeFileSync)((0, _path.join)(process.cwd(), `${exportDirectory}/${name}/${hooksName}.tsx`), imports + hooks);
101
- const schemas = (0, _generateSchemas.generateSchemas)({
102
- spec
103
- });
104
- (0, _fs.writeFileSync)((0, _path.join)(process.cwd(), `${exportDirectory}/${name}/${schemaName}.tsx`), schemas);
105
- console.log(_chalk.default.green(`🎉 [${filename}] Your OpenAPI spec has been converted into react query hooks`));
106
- } catch (error) {
107
- if (error.code === 'EISDIR') {
108
- console.log(_chalk.default.red('nested folder structure not supported'));
109
- return;
110
- }
111
-
112
- console.log(_chalk.default.red(`[${filename}]:`), _chalk.default.red(error));
113
- }
114
- });
115
- });
116
- }
117
- //# sourceMappingURL=importSpecs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["importSpecs","sourceDirectory","exportDirectory","apiDirectory","queryClientDir","headerFilters","overrides","readdir","err","filenames","console","log","map","filename","data","readFileSync","join","process","cwd","ext","parse","format","includes","toLowerCase","spec","convertSwaggerFile","schemaName","split","hooksName","name","mkdirSync","recursive","operationIds","hooks","schemaImportsArray","collectedQueryImports","Object","entries","paths","forEach","route","verbs","verb","operation","deprecated","implementation","imports","queryImports","createHook","basePath","parameters","schemasComponents","components","element","formattedImport","replace","push","generateImports","schemaImports","writeFileSync","schemas","generateSchemas","chalk","green","error","code","red"],"sources":["importSpecs.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { readFileSync, writeFileSync, readdir, mkdirSync } from 'fs';\nimport { OperationObject, PathItemObject } from 'openapi3-ts';\nimport { join, parse } from 'path';\nimport { convertSwaggerFile } from './convertSwaggerFile.js';\nimport { createHook } from './generateHooks.js';\nimport { generateImports } from './generateImports.js';\nimport { generateSchemas } from './generateSchemas.js';\n\nexport function importSpecs({\n sourceDirectory,\n exportDirectory,\n apiDirectory,\n queryClientDir,\n headerFilters,\n overrides,\n}: {\n sourceDirectory: string;\n exportDirectory: string;\n apiDirectory: string;\n queryClientDir: string;\n headerFilters?: string[];\n overrides?: Record<\n string,\n { type: 'query' } | { type: 'mutation' } | { type: 'infiniteQuery'; infiniteQueryParm: string }\n >;\n}) {\n readdir(sourceDirectory, function (err, filenames) {\n if (err) {\n console.log(err);\n throw err;\n }\n filenames.map(async (filename) => {\n try {\n const data = readFileSync(join(process.cwd(), sourceDirectory + '/' + filename), 'utf-8');\n const { ext } = parse(sourceDirectory + '/' + filename);\n const format = ['.yaml', '.yml'].includes(ext.toLowerCase()) ? 'yaml' : 'json';\n let spec = await convertSwaggerFile(data, format);\n\n const schemaName = `useQueries${filename.split('.')[0]}.schema`;\n const hooksName = `useQueries${filename.split('.')[0]}`;\n const name = filename.split('.')[0];\n mkdirSync(join(process.cwd(), `${exportDirectory}/${name}`), { recursive: true });\n\n const operationIds: string[] = [];\n\n let hooks = '';\n let schemaImportsArray = [] as string[];\n let collectedQueryImports = [] as ('query' | 'mutation' | 'infiniteQuery')[];\n Object.entries(spec.paths).forEach(([route, verbs]: [string, PathItemObject]) => {\n Object.entries(verbs).forEach(([verb, operation]: [string, OperationObject]) => {\n if (['get', 'post', 'patch', 'put', 'delete'].includes(verb) && !operation.deprecated) {\n const { implementation, imports, queryImports } = createHook({\n operation,\n verb,\n route: (spec.basePath || '') + route,\n operationIds,\n parameters: verbs.parameters,\n schemasComponents: spec.components,\n headerFilters,\n overrides,\n });\n\n hooks += implementation;\n imports.forEach((element) => {\n const formattedImport = element.replace('[]', '');\n if (\n !schemaImportsArray.includes(formattedImport) &&\n element !== 'void' &&\n element !== 'string' &&\n !element.includes('{')\n ) {\n schemaImportsArray.push(formattedImport);\n }\n });\n queryImports.forEach((element) => {\n if (!schemaImportsArray.includes(element)) {\n collectedQueryImports.push(element);\n }\n });\n }\n });\n });\n\n const imports = generateImports({\n apiDirectory,\n queryClientDir,\n schemaName,\n schemaImports: schemaImportsArray,\n queryImports: collectedQueryImports,\n });\n\n writeFileSync(join(process.cwd(), `${exportDirectory}/${name}/${hooksName}.tsx`), imports + hooks);\n\n const schemas = generateSchemas({ spec });\n writeFileSync(join(process.cwd(), `${exportDirectory}/${name}/${schemaName}.tsx`), schemas);\n\n console.log(\n chalk.green(`🎉 [${filename}] Your OpenAPI spec has been converted into react query hooks`)\n );\n } catch (error) {\n if ((error as any).code === 'EISDIR') {\n console.log(chalk.red('nested folder structure not supported'));\n return;\n }\n console.log(chalk.red(`[${filename}]:`), chalk.red(error));\n }\n });\n });\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,SAASA,WAAT,OAiBJ;EAAA,IAjByB;IAC1BC,eAD0B;IAE1BC,eAF0B;IAG1BC,YAH0B;IAI1BC,cAJ0B;IAK1BC,aAL0B;IAM1BC;EAN0B,CAiBzB;EACD,IAAAC,WAAA,EAAQN,eAAR,EAAyB,UAAUO,GAAV,EAAeC,SAAf,EAA0B;IACjD,IAAID,GAAJ,EAAS;MACPE,OAAO,CAACC,GAAR,CAAYH,GAAZ;MACA,MAAMA,GAAN;IACD;;IACDC,SAAS,CAACG,GAAV,CAAc,MAAOC,QAAP,IAAoB;MAChC,IAAI;QACF,MAAMC,IAAI,GAAG,IAAAC,gBAAA,EAAa,IAAAC,UAAA,EAAKC,OAAO,CAACC,GAAR,EAAL,EAAoBjB,eAAe,GAAG,GAAlB,GAAwBY,QAA5C,CAAb,EAAoE,OAApE,CAAb;QACA,MAAM;UAAEM;QAAF,IAAU,IAAAC,WAAA,EAAMnB,eAAe,GAAG,GAAlB,GAAwBY,QAA9B,CAAhB;QACA,MAAMQ,MAAM,GAAG,CAAC,OAAD,EAAU,MAAV,EAAkBC,QAAlB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,CAAhB;QACA,IAAAmC,iBAAA,EAAc,IAAA3C,UAAA,EAAKC,OAAO,CAACC,GAAR,EAAL,EAAqB,GAAEhB,eAAgB,IAAG2B,IAAK,IAAGH,UAAW,MAA7D,CAAd,EAAmFkC,OAAnF;QAEAlD,OAAO,CAACC,GAAR,CACEmD,cAAA,CAAMC,KAAN,CAAa,OAAMlD,QAAS,+DAA5B,CADF;MAGD,CAnED,CAmEE,OAAOmD,KAAP,EAAc;QACd,IAAKA,KAAD,CAAeC,IAAf,KAAwB,QAA5B,EAAsC;UACpCvD,OAAO,CAACC,GAAR,CAAYmD,cAAA,CAAMI,GAAN,CAAU,uCAAV,CAAZ;UACA;QACD;;QACDxD,OAAO,CAACC,GAAR,CAAYmD,cAAA,CAAMI,GAAN,CAAW,IAAGrD,QAAS,IAAvB,CAAZ,EAAyCiD,cAAA,CAAMI,GAAN,CAAUF,KAAV,CAAzC;MACD;IACF,CA3ED;EA4ED,CAjFD;AAkFD"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "convertSwaggerFile", {
7
- enumerable: true,
8
- get: function () {
9
- return _convertSwaggerFile.convertSwaggerFile;
10
- }
11
- });
12
- Object.defineProperty(exports, "importSpecs", {
13
- enumerable: true,
14
- get: function () {
15
- return _importSpecs.importSpecs;
16
- }
17
- });
18
-
19
- var _convertSwaggerFile = require("./convertSwaggerFile.js");
20
-
21
- var _importSpecs = require("./importSpecs.js");
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import { convertSwaggerFile } from './convertSwaggerFile.js';\nimport { importSpecs } from './importSpecs.js';\nexport { importSpecs, convertSwaggerFile };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
@@ -1,212 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveValue = exports.isReference = exports.getScalar = exports.getResReqTypes = exports.getDocs = exports.formatDescription = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
- var _case = _interopRequireDefault(require("case"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const {
15
- uniq,
16
- isEmpty
17
- } = _lodash.default;
18
- const {
19
- pascal
20
- } = _case.default;
21
-
22
- const getDocs = data => isReference(data) ? '' : formatDescription(data.description);
23
- /**
24
- * Discriminator helper for `ReferenceObject`
25
- */
26
-
27
-
28
- exports.getDocs = getDocs;
29
-
30
- const isReference = property => {
31
- return Boolean(property.$ref);
32
- };
33
- /**
34
- * Return the typescript equivalent of open-api data type
35
- */
36
-
37
-
38
- exports.isReference = isReference;
39
-
40
- const getScalar = item => {
41
- const nullable = item.nullable ? ' | null' : '';
42
-
43
- switch (item.type) {
44
- case 'number':
45
- case 'integer':
46
- return 'number' + nullable;
47
-
48
- case 'boolean':
49
- return 'boolean' + nullable;
50
-
51
- case 'array':
52
- return getArray(item) + nullable;
53
-
54
- case 'string':
55
- return (item.enum ? `"${item.enum.join(`" | "`)}"` : 'string') + nullable;
56
-
57
- case 'object':
58
- default:
59
- return getObject(item) + nullable;
60
- }
61
- };
62
- /**
63
- * Return the output type from the $ref
64
- */
65
-
66
-
67
- exports.getScalar = getScalar;
68
-
69
- const getRef = $ref => {
70
- if ($ref.startsWith('#/components/schemas')) {
71
- return pascal($ref.replace('#/components/schemas/', ''));
72
- } else if ($ref.startsWith('#/components/responses')) {
73
- return pascal($ref.replace('#/components/responses/', '')) + 'Response';
74
- } else if ($ref.startsWith('#/components/parameters')) {
75
- return pascal($ref.replace('#/components/parameters/', '')) + 'Parameter';
76
- } else if ($ref.startsWith('#/components/requestBodies')) {
77
- return pascal($ref.replace('#/components/requestBodies/', '')) + 'RequestBody';
78
- } else {
79
- throw new Error('This library only resolve $ref that are include into `#/components/*` for now');
80
- }
81
- };
82
- /**
83
- * Return the output type from an array
84
- */
85
-
86
-
87
- const getArray = item => {
88
- if (item.items) {
89
- if (!isReference(item.items) && (item.items.oneOf || item.items.allOf || item.items.enum)) {
90
- return `(${resolveValue(item.items)})[]`;
91
- } else {
92
- return `${resolveValue(item.items)}[]`;
93
- }
94
- } else {
95
- throw new Error('All arrays must have an `items` key define');
96
- }
97
- };
98
- /**
99
- * Return the output type from an object
100
- */
101
-
102
-
103
- const getObject = item => {
104
- if (isReference(item)) {
105
- return getRef(item.$ref);
106
- }
107
-
108
- if (item.allOf) {
109
- return item.allOf.map(resolveValue).join(' & ');
110
- }
111
-
112
- if (item.oneOf) {
113
- return item.oneOf.map(resolveValue).join(' | ');
114
- }
115
-
116
- if (!item.type && !item.properties && !item.additionalProperties) {
117
- return '{}';
118
- } // Free form object (https://swagger.io/docs/specification/data-models/data-types/#free-form)
119
-
120
-
121
- if (item.type === 'object' && !item.properties && (!item.additionalProperties || item.additionalProperties === true || isEmpty(item.additionalProperties))) {
122
- return '{[key: string]: any}';
123
- }
124
-
125
- const IdentifierRegexp = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/; // Consolidation of item.properties & item.additionalProperties
126
-
127
- let output = '{\n';
128
-
129
- if (item.properties) {
130
- output += Object.entries(item.properties).map(_ref => {
131
- let [key, prop] = _ref;
132
- const doc = getDocs(prop);
133
- const isRequired = (item.required || []).includes(key);
134
- const processedKey = IdentifierRegexp.test(key) ? key : `"${key}"`;
135
- return `${doc}\n${processedKey}${isRequired ? '' : '?'}: ${resolveValue(prop)};`;
136
- }).join('');
137
- }
138
-
139
- if (item.additionalProperties) {
140
- if (item.properties) {
141
- output += '\n';
142
- }
143
-
144
- output += `} & { [key: string]: ${item.additionalProperties === true ? 'any' : resolveValue(item.additionalProperties)}`;
145
- }
146
-
147
- if (item.properties || item.additionalProperties) {
148
- if (output === '{\n') {
149
- return '{}';
150
- }
151
-
152
- return output + '\n}';
153
- }
154
-
155
- return item.type === 'object' ? '{[key: string]: any}' : 'any';
156
- };
157
- /**
158
- * Resolve the value of a schema object to a proper type definition.
159
- */
160
-
161
-
162
- const resolveValue = schema => isReference(schema) ? getRef(schema.$ref) : getScalar(schema);
163
- /**
164
- * Format a description to code documentation.
165
- */
166
-
167
-
168
- exports.resolveValue = resolveValue;
169
-
170
- const formatDescription = description => {
171
- if (!description) {
172
- return '';
173
- }
174
-
175
- return `\n/**\n${description.split('\n').map(i => `* ${i}`).join('\n')}\n */`;
176
- };
177
- /**
178
- * Extract responses / request types from open-api specs
179
- */
180
-
181
-
182
- exports.formatDescription = formatDescription;
183
-
184
- const getResReqTypes = responsesOrRequests => {
185
- return uniq(responsesOrRequests.map(_ref2 => {
186
- let [_, res] = _ref2;
187
-
188
- if (!res) {
189
- return;
190
- }
191
-
192
- if (isReference(res)) {
193
- return getRef(res.$ref);
194
- }
195
-
196
- if (res.content) {
197
- for (let contentType of Object.keys(res.content)) {
198
- if (contentType.startsWith('application/json') || contentType.startsWith('application/octet-stream')) {
199
- const schema = res.content[contentType].schema;
200
- return resolveValue(schema);
201
- }
202
- }
203
-
204
- return;
205
- }
206
-
207
- return;
208
- })).join(' | ');
209
- };
210
-
211
- exports.getResReqTypes = getResReqTypes;
212
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["uniq","isEmpty","lodash","pascal","pasCase","getDocs","data","isReference","formatDescription","description","property","Boolean","$ref","getScalar","item","nullable","type","getArray","enum","join","getObject","getRef","startsWith","replace","Error","items","oneOf","allOf","resolveValue","map","properties","additionalProperties","IdentifierRegexp","output","Object","entries","key","prop","doc","isRequired","required","includes","processedKey","test","schema","split","i","getResReqTypes","responsesOrRequests","_","res","content","contentType","keys"],"sources":["utils.ts"],"sourcesContent":["import lodash from 'lodash';\nconst { uniq, isEmpty } = lodash;\nimport pasCase from 'case';\n\nconst { pascal } = pasCase;\n\nimport { ReferenceObject, RequestBodyObject, ResponseObject, SchemaObject } from 'openapi3-ts';\n\nexport const getDocs = (data: ReferenceObject | { description?: string }) =>\n isReference(data) ? '' : formatDescription(data.description);\n/**\n * Discriminator helper for `ReferenceObject`\n */\nexport const isReference = (property: any): property is ReferenceObject => {\n return Boolean(property.$ref);\n};\n\n/**\n * Return the typescript equivalent of open-api data type\n */\nexport const getScalar = (item: SchemaObject) => {\n const nullable = item.nullable ? ' | null' : '';\n\n switch (item.type) {\n case 'number':\n case 'integer':\n return 'number' + nullable;\n\n case 'boolean':\n return 'boolean' + nullable;\n\n case 'array':\n return getArray(item) + nullable;\n\n case 'string':\n return (item.enum ? `\"${item.enum.join(`\" | \"`)}\"` : 'string') + nullable;\n\n case 'object':\n default:\n return getObject(item) + nullable;\n }\n};\n\n/**\n * Return the output type from the $ref\n */\nconst getRef = ($ref: ReferenceObject['$ref']) => {\n if ($ref.startsWith('#/components/schemas')) {\n return pascal($ref.replace('#/components/schemas/', ''));\n } else if ($ref.startsWith('#/components/responses')) {\n return pascal($ref.replace('#/components/responses/', '')) + 'Response';\n } else if ($ref.startsWith('#/components/parameters')) {\n return pascal($ref.replace('#/components/parameters/', '')) + 'Parameter';\n } else if ($ref.startsWith('#/components/requestBodies')) {\n return pascal($ref.replace('#/components/requestBodies/', '')) + 'RequestBody';\n } else {\n throw new Error('This library only resolve $ref that are include into `#/components/*` for now');\n }\n};\n\n/**\n * Return the output type from an array\n */\nconst getArray = (item: SchemaObject): string => {\n if (item.items) {\n if (!isReference(item.items) && (item.items.oneOf || item.items.allOf || item.items.enum)) {\n return `(${resolveValue(item.items)})[]`;\n } else {\n return `${resolveValue(item.items)}[]`;\n }\n } else {\n throw new Error('All arrays must have an `items` key define');\n }\n};\n\n/**\n * Return the output type from an object\n */\nconst getObject = (item: SchemaObject): string => {\n if (isReference(item)) {\n return getRef(item.$ref);\n }\n\n if (item.allOf) {\n return item.allOf.map(resolveValue).join(' & ');\n }\n\n if (item.oneOf) {\n return item.oneOf.map(resolveValue).join(' | ');\n }\n\n if (!item.type && !item.properties && !item.additionalProperties) {\n return '{}';\n }\n\n // Free form object (https://swagger.io/docs/specification/data-models/data-types/#free-form)\n if (\n item.type === 'object' &&\n !item.properties &&\n (!item.additionalProperties || item.additionalProperties === true || isEmpty(item.additionalProperties))\n ) {\n return '{[key: string]: any}';\n }\n\n const IdentifierRegexp = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n // Consolidation of item.properties & item.additionalProperties\n let output = '{\\n';\n if (item.properties) {\n output += Object.entries(item.properties)\n .map(([key, prop]: [string, ReferenceObject | SchemaObject]) => {\n const doc = getDocs(prop);\n const isRequired = (item.required || []).includes(key);\n const processedKey = IdentifierRegexp.test(key) ? key : `\"${key}\"`;\n return `${doc}\\n${processedKey}${isRequired ? '' : '?'}: ${resolveValue(prop)};`;\n })\n .join('');\n }\n\n if (item.additionalProperties) {\n if (item.properties) {\n output += '\\n';\n }\n output += `} & { [key: string]: ${\n item.additionalProperties === true ? 'any' : resolveValue(item.additionalProperties)\n }`;\n }\n\n if (item.properties || item.additionalProperties) {\n if (output === '{\\n') {\n return '{}';\n }\n return output + '\\n}';\n }\n\n return item.type === 'object' ? '{[key: string]: any}' : 'any';\n};\n\n/**\n * Resolve the value of a schema object to a proper type definition.\n */\nexport const resolveValue = (schema: SchemaObject) =>\n isReference(schema) ? getRef(schema.$ref) : getScalar(schema);\n\n/**\n * Format a description to code documentation.\n */\nexport const formatDescription = (description?: string) => {\n if (!description) {\n return '';\n }\n return `\\n/**\\n${description\n .split('\\n')\n .map((i) => `* ${i}`)\n .join('\\n')}\\n */`;\n};\n\n/**\n * Extract responses / request types from open-api specs\n */\nexport const getResReqTypes = (\n responsesOrRequests: Array<[string, ResponseObject | ReferenceObject | RequestBodyObject]>\n) => {\n return uniq(\n responsesOrRequests.map(([_, res]) => {\n if (!res) {\n return;\n }\n\n if (isReference(res)) {\n return getRef(res.$ref);\n }\n\n if (res.content) {\n for (let contentType of Object.keys(res.content)) {\n if (\n contentType.startsWith('application/json') ||\n contentType.startsWith('application/octet-stream')\n ) {\n const schema = res.content[contentType].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