@grandlinex/swagger-mate 0.32.1 → 1.0.1

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.
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getBaseFolder = void 0;
29
+ exports.getBaseFolder = getBaseFolder;
30
+ exports.default = PathHelp;
30
31
  const path_1 = __importDefault(require("path"));
31
32
  const process = __importStar(require("process"));
32
33
  function getBaseFolder() {
@@ -36,7 +37,6 @@ function getBaseFolder() {
36
37
  }
37
38
  return dir;
38
39
  }
39
- exports.getBaseFolder = getBaseFolder;
40
40
  function PathHelp(base, ...inp) {
41
41
  const { env } = process;
42
42
  if (env.dev) {
@@ -44,4 +44,3 @@ function PathHelp(base, ...inp) {
44
44
  }
45
45
  return path_1.default.join(base, '..', ...inp);
46
46
  }
47
- exports.default = PathHelp;
@@ -56,4 +56,4 @@ export declare function transformInterface(operation: string, tag: IFTag | strin
56
56
  * @param tag
57
57
  * @param schema
58
58
  */
59
- export declare function transformFormInterface(operation: string, tag: IFTag | string, schema: SSchemaEl): IfMappingType[];
59
+ export declare function transformFormInterface(operation: string, tag: IFTag | string): IfMappingType[];
@@ -1,6 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformFormInterface = exports.transformInterface = exports.typeByRef = exports.ifName = exports.saveName = exports.IFTag = exports.S = exports.fuc = exports.sK = exports.rq = exports.eS = void 0;
3
+ exports.IFTag = void 0;
4
+ exports.eS = eS;
5
+ exports.rq = rq;
6
+ exports.sK = sK;
7
+ exports.fuc = fuc;
8
+ exports.S = S;
9
+ exports.saveName = saveName;
10
+ exports.ifName = ifName;
11
+ exports.typeByRef = typeByRef;
12
+ exports.transformInterface = transformInterface;
13
+ exports.transformFormInterface = transformFormInterface;
4
14
  const SwaggerTypes_js_1 = require("../Meta/SwaggerTypes.js");
5
15
  /**
6
16
  * Save string from unknown
@@ -9,7 +19,6 @@ const SwaggerTypes_js_1 = require("../Meta/SwaggerTypes.js");
9
19
  function eS(e) {
10
20
  return e || '';
11
21
  }
12
- exports.eS = eS;
13
22
  /**
14
23
  * Optional field
15
24
  * @param required
@@ -20,14 +29,12 @@ function rq(required) {
20
29
  }
21
30
  return ':';
22
31
  }
23
- exports.rq = rq;
24
32
  function sK(e) {
25
33
  if (e.indexOf(':') >= 0) {
26
34
  return `'${e}'`;
27
35
  }
28
36
  return e;
29
37
  }
30
- exports.sK = sK;
31
38
  /**
32
39
  * Cast first letter to uppercase
33
40
  * @param e
@@ -38,7 +45,6 @@ function fuc(e) {
38
45
  }
39
46
  return e.charAt(0).toUpperCase() + e.substring(1);
40
47
  }
41
- exports.fuc = fuc;
42
48
  /**
43
49
  * Spacing function
44
50
  * @param c number of spaces
@@ -50,7 +56,6 @@ function S(c) {
50
56
  }
51
57
  return o;
52
58
  }
53
- exports.S = S;
54
59
  var IFTag;
55
60
  (function (IFTag) {
56
61
  IFTag["RequestBody"] = "RequestBody";
@@ -62,18 +67,15 @@ var IFTag;
62
67
  function saveName(inp) {
63
68
  return inp.replace(/[^a-zA-Z0-9[\]]/g, 'X');
64
69
  }
65
- exports.saveName = saveName;
66
70
  /**
67
71
  * InterfaceName Helper function
68
72
  */
69
73
  function ifName(operation, tag, use) {
70
74
  return `${use ? 'TX.' : ''}${saveName(fuc(operation))}${saveName(fuc(tag))}`;
71
75
  }
72
- exports.ifName = ifName;
73
76
  function typeByRef(ref, use) {
74
77
  return `${use ? 'TX.' : ''}${fuc(ref.substring(1 + ref.lastIndexOf('/')))}`;
75
78
  }
76
- exports.typeByRef = typeByRef;
77
79
  /**
78
80
  * Map schema to typescript interface
79
81
  * @param operation
@@ -177,6 +179,28 @@ function transformInterface(operation, tag, schema) {
177
179
  }
178
180
  }
179
181
  break;
182
+ case 'string':
183
+ out.push({
184
+ keys: [],
185
+ name: cur.name,
186
+ rawType: `string`,
187
+ });
188
+ break;
189
+ case 'integer':
190
+ case 'number':
191
+ out.push({
192
+ keys: [],
193
+ name: cur.name,
194
+ rawType: `number`,
195
+ });
196
+ break;
197
+ case 'boolean':
198
+ out.push({
199
+ keys: [],
200
+ name: cur.name,
201
+ rawType: `boolean`,
202
+ });
203
+ break;
180
204
  default:
181
205
  break;
182
206
  }
@@ -187,22 +211,20 @@ function transformInterface(operation, tag, schema) {
187
211
  }
188
212
  return out;
189
213
  }
190
- exports.transformInterface = transformInterface;
191
214
  /**
192
215
  * Map schema to typescript interface
193
216
  * @param operation
194
217
  * @param tag
195
218
  * @param schema
196
219
  */
197
- function transformFormInterface(operation, tag, schema) {
220
+ function transformFormInterface(operation, tag) {
198
221
  const out = [];
199
222
  const cur = {
200
223
  name: ifName(operation, tag),
201
224
  keys: [],
202
225
  };
203
- const keys = null;
226
+ // const keys: null | string[] = null;
204
227
  cur.rawType = `FormData`;
205
228
  out.push(cur);
206
229
  return out;
207
230
  }
208
- exports.transformFormInterface = transformFormInterface;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.abstractInterfaceTemplate = exports.functionInterfaceTemplate = exports.reqBody = exports.functionTemplate = void 0;
3
+ exports.functionTemplate = functionTemplate;
4
+ exports.reqBody = reqBody;
5
+ exports.functionInterfaceTemplate = functionInterfaceTemplate;
6
+ exports.abstractInterfaceTemplate = abstractInterfaceTemplate;
4
7
  const ClientUtil_js_1 = require("./ClientUtil.js");
5
8
  function docTemplate(inp, doc) {
6
9
  const dDoc = [];
@@ -18,17 +21,14 @@ function functionTemplate(FC_NAME, props) {
18
21
  ${(0, ClientUtil_js_1.S)(4)}${(0, ClientUtil_js_1.eS)(FC_BODY)}
19
22
  ${(0, ClientUtil_js_1.S)(2)}}`, props.FC_DOC);
20
23
  }
21
- exports.functionTemplate = functionTemplate;
22
24
  function functionInterfaceTemplate(FC_NAME, props) {
23
25
  const { FC_PROPS, FC_RETURN, FC_GEN, FC_DOC } = props;
24
26
  return docTemplate(`${(0, ClientUtil_js_1.S)(2)}${(0, ClientUtil_js_1.eS)(FC_NAME)}${(0, ClientUtil_js_1.eS)(FC_GEN)}(${(0, ClientUtil_js_1.eS)(FC_PROPS)})${(0, ClientUtil_js_1.eS)(FC_RETURN)}`, FC_DOC);
25
27
  }
26
- exports.functionInterfaceTemplate = functionInterfaceTemplate;
27
28
  function abstractInterfaceTemplate(FC_NAME, props) {
28
29
  const { FC_PROPS, FC_RETURN, FC_GEN, FC_DOC } = props;
29
30
  return docTemplate(`${(0, ClientUtil_js_1.S)(2)}abstract ${(0, ClientUtil_js_1.eS)(FC_NAME)}${(0, ClientUtil_js_1.eS)(FC_GEN)}(${(0, ClientUtil_js_1.eS)(FC_PROPS)})${(0, ClientUtil_js_1.eS)(FC_RETURN)};`, FC_DOC);
30
31
  }
31
- exports.abstractInterfaceTemplate = abstractInterfaceTemplate;
32
32
  function reqBody(rType, path, paramKey, hasBody, type, bodyType, queryKey) {
33
33
  let q = 'undefined';
34
34
  if (queryKey.length > 0 || paramKey.length > 0) {
@@ -43,4 +43,3 @@ function reqBody(rType, path, paramKey, hasBody, type, bodyType, queryKey) {
43
43
  }
44
44
  return `return this.handle<${type}, ${bodyType}>('${rType}','${path}',${hasBody ? 'body' : 'undefined'}, ${q});`;
45
45
  }
46
- exports.reqBody = reqBody;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interfaceTemplate = void 0;
3
+ exports.interfaceTemplate = interfaceTemplate;
4
4
  /* eslint-disable prettier/prettier */
5
5
  const ClientUtil_js_1 = require("./ClientUtil.js");
6
6
  function interfaceTemplate(IF_NAME, types, rawType) {
@@ -11,4 +11,3 @@ function interfaceTemplate(IF_NAME, types, rawType) {
11
11
  ${types.map(({ key, type, required }) => `${(0, ClientUtil_js_1.S)(2)}${(0, ClientUtil_js_1.sK)(key)}${(0, ClientUtil_js_1.rq)(required)} ${type};`).join('\n')}
12
12
  }`;
13
13
  }
14
- exports.interfaceTemplate = interfaceTemplate;
@@ -90,7 +90,7 @@ function interfaceHandler(conf) {
90
90
  interfaceList.push(...(0, ClientUtil_js_1.transformInterface)(cur.operationId, ClientUtil_js_1.IFTag.RequestBody, cur.requestBody.content['application/json'].schema).map((val) => (0, InterfaceTemplate_js_1.interfaceTemplate)(val.name, val.keys, val.rawType)));
91
91
  }
92
92
  if (cur.requestBody?.content?.['multipart/form-data']) {
93
- interfaceList.push(...(0, ClientUtil_js_1.transformFormInterface)(cur.operationId, ClientUtil_js_1.IFTag.RequestBody, cur.requestBody.content['multipart/form-data'].schema).map((val) => (0, InterfaceTemplate_js_1.interfaceTemplate)(val.name, val.keys, val.rawType)));
93
+ interfaceList.push(...(0, ClientUtil_js_1.transformFormInterface)(cur.operationId, ClientUtil_js_1.IFTag.RequestBody).map((val) => (0, InterfaceTemplate_js_1.interfaceTemplate)(val.name, val.keys, val.rawType)));
94
94
  }
95
95
  const active = cur.responses?.['200'] || cur.responses?.['201'];
96
96
  if (active &&
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSComponent = exports.SComponent = exports.getSPath = exports.getSwaggerMeta = exports.SPath = exports.Swagger = void 0;
3
+ exports.SComponent = exports.SPath = exports.Swagger = void 0;
4
+ exports.getSwaggerMeta = getSwaggerMeta;
5
+ exports.getSPath = getSPath;
6
+ exports.getSComponent = getSComponent;
4
7
  require("reflect-metadata");
5
8
  const swaggerKey = Symbol('swagger');
6
9
  const pathKey = Symbol('sPath');
@@ -14,7 +17,6 @@ exports.Swagger = Swagger;
14
17
  function getSwaggerMeta(target) {
15
18
  return Reflect.getMetadata(swaggerKey, target.constructor.prototype);
16
19
  }
17
- exports.getSwaggerMeta = getSwaggerMeta;
18
20
  const SPath = (path, prefix) => {
19
21
  return (target) => {
20
22
  Reflect.defineMetadata(pathKey, {
@@ -27,7 +29,6 @@ exports.SPath = SPath;
27
29
  function getSPath(target) {
28
30
  return Reflect.getMetadata(pathKey, target.constructor.prototype);
29
31
  }
30
- exports.getSPath = getSPath;
31
32
  const SComponent = (comp) => {
32
33
  return (target) => {
33
34
  Reflect.defineMetadata(compKey, comp, target.prototype);
@@ -37,4 +38,3 @@ exports.SComponent = SComponent;
37
38
  function getSComponent(target) {
38
39
  return Reflect.getMetadata(compKey, target.constructor.prototype);
39
40
  }
40
- exports.getSComponent = getSComponent;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/ban-types */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isSwaggerRef = void 0;
4
+ exports.isSwaggerRef = isSwaggerRef;
5
5
  function isSwaggerRef(o) {
6
6
  const a = o;
7
7
  return typeof a === 'object' && !!a?.$ref;
8
8
  }
9
- exports.isSwaggerRef = isSwaggerRef;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { ObjectLike } from '@grandlinex/core';
3
2
  import { Server } from 'net';
4
3
  import { MergeInputType, SwaggerConfig } from './Meta/SwaggerTypes.js';
@@ -7,12 +7,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  return (mod && mod.__esModule) ? mod : { "default": mod };
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.isErrorType = void 0;
10
+ exports.isErrorType = isErrorType;
11
11
  const form_data_1 = __importDefault(require("form-data"));
12
12
  function isErrorType(x) {
13
13
  return x && typeof x === 'object' && x.type === 'error';
14
14
  }
15
- exports.isErrorType = isErrorType;
16
15
  class BaseCon {
17
16
  constructor(conf) {
18
17
  this.api = conf.endpoint;
@@ -56,4 +56,4 @@ export declare function transformInterface(operation: string, tag: IFTag | strin
56
56
  * @param tag
57
57
  * @param schema
58
58
  */
59
- export declare function transformFormInterface(operation: string, tag: IFTag | string, schema: SSchemaEl): IfMappingType[];
59
+ export declare function transformFormInterface(operation: string, tag: IFTag | string): IfMappingType[];
@@ -166,6 +166,28 @@ export function transformInterface(operation, tag, schema) {
166
166
  }
167
167
  }
168
168
  break;
169
+ case 'string':
170
+ out.push({
171
+ keys: [],
172
+ name: cur.name,
173
+ rawType: `string`,
174
+ });
175
+ break;
176
+ case 'integer':
177
+ case 'number':
178
+ out.push({
179
+ keys: [],
180
+ name: cur.name,
181
+ rawType: `number`,
182
+ });
183
+ break;
184
+ case 'boolean':
185
+ out.push({
186
+ keys: [],
187
+ name: cur.name,
188
+ rawType: `boolean`,
189
+ });
190
+ break;
169
191
  default:
170
192
  break;
171
193
  }
@@ -182,13 +204,13 @@ export function transformInterface(operation, tag, schema) {
182
204
  * @param tag
183
205
  * @param schema
184
206
  */
185
- export function transformFormInterface(operation, tag, schema) {
207
+ export function transformFormInterface(operation, tag) {
186
208
  const out = [];
187
209
  const cur = {
188
210
  name: ifName(operation, tag),
189
211
  keys: [],
190
212
  };
191
- const keys = null;
213
+ // const keys: null | string[] = null;
192
214
  cur.rawType = `FormData`;
193
215
  out.push(cur);
194
216
  return out;
@@ -62,7 +62,7 @@ function interfaceHandler(conf) {
62
62
  interfaceList.push(...transformInterface(cur.operationId, IFTag.RequestBody, cur.requestBody.content['application/json'].schema).map((val) => interfaceTemplate(val.name, val.keys, val.rawType)));
63
63
  }
64
64
  if (cur.requestBody?.content?.['multipart/form-data']) {
65
- interfaceList.push(...transformFormInterface(cur.operationId, IFTag.RequestBody, cur.requestBody.content['multipart/form-data'].schema).map((val) => interfaceTemplate(val.name, val.keys, val.rawType)));
65
+ interfaceList.push(...transformFormInterface(cur.operationId, IFTag.RequestBody).map((val) => interfaceTemplate(val.name, val.keys, val.rawType)));
66
66
  }
67
67
  const active = cur.responses?.['200'] || cur.responses?.['201'];
68
68
  if (active &&
@@ -1,4 +1,3 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import { ObjectLike } from '@grandlinex/core';
3
2
  import { Server } from 'net';
4
3
  import { MergeInputType, SwaggerConfig } from './Meta/SwaggerTypes.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grandlinex/swagger-mate",
3
- "version": "0.32.1",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -27,52 +27,51 @@
27
27
  "pack": "npm run buildprep && npm pack",
28
28
  "start": "node dist/cjs/run.js",
29
29
  "start-dev": "npm run pre-build && cross-env dev=true ts-node src/run.ts",
30
- "run-dev": "npm run pre-build && cross-env dev=true ts-node src/tests/run.ts",
30
+ "run-dev": "npm run pre-build && cross-env dev=true node --no-warnings=ExperimentalWarning --loader ts-node/esm src/tests/run.ts",
31
31
  "lint": "eslint src",
32
32
  "test": "npm run pre-build && cross-env dev=true jest --runInBand ",
33
33
  "test-coverage": "npm run pre-build && cross-env dev=true jest --runInBand --ci --collectCoverage --coverageDirectory=\"./coverage\" --reporters=default --reporters=jest-junit",
34
- "makeDocs": "typedoc",
35
- "debug": "ts-node ./src/ArgReader.ts -i --debug -abc -d 5"
34
+ "makeDocs": "typedoc"
36
35
  },
37
36
  "bin": {
38
37
  "swagger-mate": "./dist/cjs/cli.js",
39
38
  "swagger-mate-esm": "./dist/mjs/cli.js"
40
39
  },
41
40
  "dependencies": {
42
- "@grandlinex/core": "0.32.0",
43
- "express": "4.18.2",
44
- "form-data": "^4.0.0",
41
+ "@grandlinex/core": "1.0.1",
42
+ "express": "4.19.2",
43
+ "form-data": "4.0.0",
45
44
  "js-yaml": "4.1.0",
46
- "reflect-metadata": "0.1.13"
45
+ "reflect-metadata": "0.2.2"
47
46
  },
48
47
  "devDependencies": {
49
- "@types/express": "^4.17.17",
50
- "@types/jest": "^29.5.2",
51
- "@types/js-yaml": "^4.0.5",
52
- "@types/node": "^20.3.0",
53
- "@types/node-fetch": "^2.6.4",
54
- "@typescript-eslint/eslint-plugin": "^5.59.11",
55
- "@typescript-eslint/parser": "^5.59.11",
56
- "axios": "1.4.0",
57
- "cross-env": "^7.0.3",
58
- "eslint": "^8.42.0",
59
- "eslint-config-airbnb": "^19.0.4",
60
- "eslint-config-airbnb-typescript": "^17.0.0",
61
- "eslint-config-prettier": "^8.8.0",
62
- "eslint-plugin-import": "^2.27.5",
63
- "eslint-plugin-jest": "^27.2.1",
64
- "eslint-plugin-jsx-a11y": "^6.7.1",
65
- "eslint-plugin-prettier": "^4.2.1",
66
- "html-webpack-plugin": "^5.5.3",
67
- "http-server": "^14.1.1",
68
- "jest": "^29.5.0",
69
- "jest-junit": "^16.0.0",
70
- "node-fetch": "3.3.1",
71
- "prettier": "^2.8.8",
72
- "ts-jest": "^29.1.0",
73
- "ts-loader": "^9.4.3",
74
- "ts-node": "^10.9.1",
75
- "typedoc": "^0.24.8",
76
- "typescript": "^5.1.3"
48
+ "@types/express": "4.17.21",
49
+ "@types/jest": "29.5.12",
50
+ "@types/js-yaml": "4.0.9",
51
+ "@types/node": "22.0.0",
52
+ "@types/node-fetch": "2.6.11",
53
+ "@typescript-eslint/eslint-plugin": "7.18.0",
54
+ "@typescript-eslint/parser": "7.18.0",
55
+ "axios": "1.7.2",
56
+ "cross-env": "7.0.3",
57
+ "eslint": "8.57.0",
58
+ "eslint-config-airbnb": "19.0.4",
59
+ "eslint-config-airbnb-typescript": "18.0.0",
60
+ "eslint-config-prettier": "9.1.0",
61
+ "eslint-plugin-import": "2.29.1",
62
+ "eslint-plugin-jest": "28.6.0",
63
+ "eslint-plugin-jsx-a11y": "6.9.0",
64
+ "eslint-plugin-prettier": "5.2.1",
65
+ "html-webpack-plugin": "5.6.0",
66
+ "http-server": "14.1.1",
67
+ "jest": "29.7.0",
68
+ "jest-junit": "16.0.0",
69
+ "node-fetch": "3.3.2",
70
+ "prettier": "3.3.3",
71
+ "ts-jest": "29.1.5",
72
+ "ts-loader": "9.5.1",
73
+ "ts-node": "10.9.2",
74
+ "typedoc": "0.26.5",
75
+ "typescript": "5.5.4"
77
76
  }
78
77
  }