@gopowerteam/request-generate 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +21 -10
- package/dist/index.mjs +20 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _class; var _class2; var _class3;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
3
|
var _chunkXXPGZHWZjs = require('./chunk-XXPGZHWZ.js');
|
|
4
4
|
|
|
@@ -91,8 +91,16 @@ var Field = class {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
// src/utils/get-
|
|
94
|
+
// src/utils/get-built-in-type.ts
|
|
95
95
|
var TYPE_MAPPINGS = /* @__PURE__ */ new Map([
|
|
96
|
+
["MapStringObject", "Record<string, any>"]
|
|
97
|
+
]);
|
|
98
|
+
var getBuiltInType = (ref) => {
|
|
99
|
+
return TYPE_MAPPINGS.get(ref);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/utils/get-mapped-type.ts
|
|
103
|
+
var TYPE_MAPPINGS2 = /* @__PURE__ */ new Map([
|
|
96
104
|
["file", "binary"],
|
|
97
105
|
["any", "any"],
|
|
98
106
|
["object", "any"],
|
|
@@ -118,7 +126,7 @@ var getMappedType = (type = "object", format) => {
|
|
|
118
126
|
if (format === "binary") {
|
|
119
127
|
return "binary";
|
|
120
128
|
}
|
|
121
|
-
return
|
|
129
|
+
return TYPE_MAPPINGS2.get(type) || "any";
|
|
122
130
|
};
|
|
123
131
|
|
|
124
132
|
// src/parse/v2/strip-namespace.ts
|
|
@@ -145,10 +153,11 @@ function parseSchemaType(schema) {
|
|
|
145
153
|
}
|
|
146
154
|
if (!("$ref" in schema) && schema.type === "array" && schema.items && "$ref" in schema.items && schema.items.$ref) {
|
|
147
155
|
const ref = getCamelName(stripNamespace(schema.items.$ref));
|
|
156
|
+
const type = getBuiltInType(ref);
|
|
148
157
|
return {
|
|
149
158
|
type: "any[]",
|
|
150
|
-
ref: `${ref}[]`,
|
|
151
|
-
imports: [ref]
|
|
159
|
+
ref: `${_nullishCoalesce(type, () => ( ref))}[]`,
|
|
160
|
+
imports: type ? void 0 : [ref]
|
|
152
161
|
};
|
|
153
162
|
}
|
|
154
163
|
if (!("$ref" in schema) && schema.type === "array" && schema.items && !("$ref" in schema.items)) {
|
|
@@ -367,9 +376,7 @@ function parseParametersQuery(parameters) {
|
|
|
367
376
|
parameter.imports = imports || [];
|
|
368
377
|
parameter.enums = enums;
|
|
369
378
|
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
370
|
-
|
|
371
|
-
parameter.name = name;
|
|
372
|
-
parameter.ref = `{ ${subName}${parameter.required ? "?" : ""}: ${ref || "any"} }`;
|
|
379
|
+
parameter.name = `"${p.name}"`;
|
|
373
380
|
}
|
|
374
381
|
r.push(parameter);
|
|
375
382
|
}
|
|
@@ -498,10 +505,11 @@ function parseSchemaType2(schema) {
|
|
|
498
505
|
}
|
|
499
506
|
if (schema.type === "array" && "$ref" in schema.items) {
|
|
500
507
|
const ref = getCamelName(stripNamespace2(schema.items.$ref));
|
|
508
|
+
const type = getBuiltInType(ref);
|
|
501
509
|
return {
|
|
502
510
|
type: "any[]",
|
|
503
|
-
ref: `${ref}[]`,
|
|
504
|
-
imports: [ref]
|
|
511
|
+
ref: `${_nullishCoalesce(type, () => ( ref))}[]`,
|
|
512
|
+
imports: type ? void 0 : [ref]
|
|
505
513
|
};
|
|
506
514
|
}
|
|
507
515
|
if (schema.type === "array" && !("$ref" in schema.items)) {
|
|
@@ -635,6 +643,9 @@ function parseParametersQuery2(parameters) {
|
|
|
635
643
|
parameter.required = p.required;
|
|
636
644
|
parameter.imports = imports || [];
|
|
637
645
|
parameter.enums = enums;
|
|
646
|
+
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
647
|
+
parameter.name = `"${p.name}"`;
|
|
648
|
+
}
|
|
638
649
|
r.push(parameter);
|
|
639
650
|
}
|
|
640
651
|
return r;
|
package/dist/index.mjs
CHANGED
|
@@ -92,8 +92,16 @@ var Field = class {
|
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
// src/utils/get-
|
|
95
|
+
// src/utils/get-built-in-type.ts
|
|
96
96
|
var TYPE_MAPPINGS = /* @__PURE__ */ new Map([
|
|
97
|
+
["MapStringObject", "Record<string, any>"]
|
|
98
|
+
]);
|
|
99
|
+
var getBuiltInType = (ref) => {
|
|
100
|
+
return TYPE_MAPPINGS.get(ref);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/utils/get-mapped-type.ts
|
|
104
|
+
var TYPE_MAPPINGS2 = /* @__PURE__ */ new Map([
|
|
97
105
|
["file", "binary"],
|
|
98
106
|
["any", "any"],
|
|
99
107
|
["object", "any"],
|
|
@@ -119,7 +127,7 @@ var getMappedType = (type = "object", format) => {
|
|
|
119
127
|
if (format === "binary") {
|
|
120
128
|
return "binary";
|
|
121
129
|
}
|
|
122
|
-
return
|
|
130
|
+
return TYPE_MAPPINGS2.get(type) || "any";
|
|
123
131
|
};
|
|
124
132
|
|
|
125
133
|
// src/parse/v2/strip-namespace.ts
|
|
@@ -146,10 +154,11 @@ function parseSchemaType(schema) {
|
|
|
146
154
|
}
|
|
147
155
|
if (!("$ref" in schema) && schema.type === "array" && schema.items && "$ref" in schema.items && schema.items.$ref) {
|
|
148
156
|
const ref = getCamelName(stripNamespace(schema.items.$ref));
|
|
157
|
+
const type = getBuiltInType(ref);
|
|
149
158
|
return {
|
|
150
159
|
type: "any[]",
|
|
151
|
-
ref: `${ref}[]`,
|
|
152
|
-
imports: [ref]
|
|
160
|
+
ref: `${type ?? ref}[]`,
|
|
161
|
+
imports: type ? void 0 : [ref]
|
|
153
162
|
};
|
|
154
163
|
}
|
|
155
164
|
if (!("$ref" in schema) && schema.type === "array" && schema.items && !("$ref" in schema.items)) {
|
|
@@ -368,9 +377,7 @@ function parseParametersQuery(parameters) {
|
|
|
368
377
|
parameter.imports = imports || [];
|
|
369
378
|
parameter.enums = enums;
|
|
370
379
|
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
371
|
-
|
|
372
|
-
parameter.name = name;
|
|
373
|
-
parameter.ref = `{ ${subName}${parameter.required ? "?" : ""}: ${ref || "any"} }`;
|
|
380
|
+
parameter.name = `"${p.name}"`;
|
|
374
381
|
}
|
|
375
382
|
r.push(parameter);
|
|
376
383
|
}
|
|
@@ -499,10 +506,11 @@ function parseSchemaType2(schema) {
|
|
|
499
506
|
}
|
|
500
507
|
if (schema.type === "array" && "$ref" in schema.items) {
|
|
501
508
|
const ref = getCamelName(stripNamespace2(schema.items.$ref));
|
|
509
|
+
const type = getBuiltInType(ref);
|
|
502
510
|
return {
|
|
503
511
|
type: "any[]",
|
|
504
|
-
ref: `${ref}[]`,
|
|
505
|
-
imports: [ref]
|
|
512
|
+
ref: `${type ?? ref}[]`,
|
|
513
|
+
imports: type ? void 0 : [ref]
|
|
506
514
|
};
|
|
507
515
|
}
|
|
508
516
|
if (schema.type === "array" && !("$ref" in schema.items)) {
|
|
@@ -636,6 +644,9 @@ function parseParametersQuery2(parameters) {
|
|
|
636
644
|
parameter.required = p.required;
|
|
637
645
|
parameter.imports = imports || [];
|
|
638
646
|
parameter.enums = enums;
|
|
647
|
+
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
648
|
+
parameter.name = `"${p.name}"`;
|
|
649
|
+
}
|
|
639
650
|
r.push(parameter);
|
|
640
651
|
}
|
|
641
652
|
return r;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopowerteam/request-generate",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.15",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"tsup": "^6.6.3",
|
|
46
46
|
"typescript": "^4.9.5",
|
|
47
47
|
"vite": "^4.1.4",
|
|
48
|
-
"@gopowerteam/request": "0.1.
|
|
48
|
+
"@gopowerteam/request": "0.1.15"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@apidevtools/swagger-parser": "^10.1.0",
|