@vc-shell/api-client-generator 1.1.30 → 1.1.31
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/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/dist/api-client-generator.js +141 -141
- package/dist/assets/config.nswag +76 -76
- package/package.json +2 -2
- package/public/assets/config.nswag +76 -76
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.1.31](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.30...v1.1.31) (2025-06-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **api-client:** add APP_TYPE_STYLE argument for customizable DTO type generation in API client ([4ae0edd](https://github.com/VirtoCommerce/vc-shell/commit/4ae0edd272a580972adacf86a4da4929ef1c056a))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
## [1.1.30](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.29...v1.1.30) (2025-06-11)
|
|
2
11
|
|
|
3
12
|
|
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ Add the dependencies to your project's **package.json**:
|
|
|
63
63
|
| `--APP_PACKAGE_NAME` | Package name for generated API clients. <br>{==string==} | `--APP_PACKAGE_NAME=@api-client` |
|
|
64
64
|
| `--APP_PACKAGE_VERSION` | Package version for generated API clients. <br>{==string==} | `--APP_PACKAGE_VERSION=1.1.0` |
|
|
65
65
|
| `--APP_OUT_DIR` | Output directory for generated API clients. <br>{==string==} | `--APP_OUT_DIR=./src/api_client/` |
|
|
66
|
+
| `--APP_TYPE_STYLE` | Sets the type style for generated DTOs. Can be 'Class' or 'Interface'.<br>{==string==} | `--APP_TYPE_STYLE=Interface` |
|
|
66
67
|
| `--APP_BUILD_DIR` | Directory where TypeScript files will be compiled. <br>{==string==} | `--APP_BUILD_DIR=lib` (default is "dist") |
|
|
67
68
|
| `--SKIP_BUILD` | Skip build step. <br>{==boolean==} | `--SKIP_BUILD=true` |
|
|
68
69
|
| `--VERBOSE` | Enable verbose logging. <br>{==boolean==} | `--VERBOSE=true` |
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import t from "chalk";
|
|
2
2
|
import { sync as E } from "cross-spawn";
|
|
3
|
-
import { resolveConfig as
|
|
4
|
-
import { existsSync as _, mkdirSync as B, writeFileSync as I, readFileSync as
|
|
5
|
-
import m, { dirname as
|
|
3
|
+
import { resolveConfig as j } from "vite";
|
|
4
|
+
import { existsSync as _, mkdirSync as B, writeFileSync as I, readFileSync as R } from "node:fs";
|
|
5
|
+
import m, { dirname as O, resolve as T, join as w, relative as x } from "node:path";
|
|
6
6
|
import { fileURLToPath as S } from "node:url";
|
|
7
|
-
import { cwd as
|
|
8
|
-
import
|
|
9
|
-
const b = S(import.meta.url), $ =
|
|
7
|
+
import { cwd as L } from "node:process";
|
|
8
|
+
import k from "mri";
|
|
9
|
+
const b = S(import.meta.url), $ = O(b);
|
|
10
10
|
class v {
|
|
11
11
|
workingDirectory;
|
|
12
12
|
generatorDirectory;
|
|
@@ -14,78 +14,78 @@ class v {
|
|
|
14
14
|
apiClientDirectory;
|
|
15
15
|
nswagPaths;
|
|
16
16
|
constructor(e) {
|
|
17
|
-
this.workingDirectory =
|
|
17
|
+
this.workingDirectory = L(), this.generatorDirectory = T($, ".."), this.assetsDirectory = w(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = T(this.workingDirectory, e), this.nswagPaths = {
|
|
18
18
|
configuration: w(x(this.workingDirectory, this.assetsDirectory), "config.nswag"),
|
|
19
19
|
authApiBase: "authApiBase.ts",
|
|
20
20
|
templates: "templates"
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
resolveApiClientPaths(e) {
|
|
24
|
-
const
|
|
24
|
+
const g = `${e.toLowerCase()}.ts`;
|
|
25
25
|
return {
|
|
26
|
-
fileName:
|
|
27
|
-
nswag: w(x(this.assetsDirectory, this.apiClientDirectory),
|
|
28
|
-
console: w(x(this.workingDirectory, this.apiClientDirectory),
|
|
26
|
+
fileName: g,
|
|
27
|
+
nswag: w(x(this.assetsDirectory, this.apiClientDirectory), g),
|
|
28
|
+
console: w(x(this.workingDirectory, this.apiClientDirectory), g)
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function D(o, e, g = []) {
|
|
33
33
|
const r = { ...o };
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
for (const [
|
|
37
|
-
const
|
|
38
|
-
|
|
34
|
+
for (const s of g)
|
|
35
|
+
s in e && (r[s] = e[s]);
|
|
36
|
+
for (const [s, a] of Object.entries(e)) {
|
|
37
|
+
const c = s;
|
|
38
|
+
s in r && typeof r[c] == "object" && !Array.isArray(r[c]) && typeof a == "object" && !Array.isArray(a) && a !== null ? r[c] = { ...r[c], ...a } : g.includes(s) || (r[c] = a);
|
|
39
39
|
}
|
|
40
40
|
return r;
|
|
41
41
|
}
|
|
42
|
-
function F(o, e,
|
|
43
|
-
const
|
|
42
|
+
function F(o, e, g, r) {
|
|
43
|
+
const s = {
|
|
44
44
|
extends: "@vc-shell/ts-config/tsconfig.json",
|
|
45
45
|
compilerOptions: {
|
|
46
46
|
baseUrl: ".",
|
|
47
|
-
declarationDir: m.join(
|
|
47
|
+
declarationDir: m.join(g, "types"),
|
|
48
48
|
outDir: r,
|
|
49
49
|
rootDir: "./"
|
|
50
50
|
},
|
|
51
51
|
files: [],
|
|
52
52
|
include: ["*.ts"]
|
|
53
53
|
};
|
|
54
|
-
let
|
|
54
|
+
let a = { ...s };
|
|
55
55
|
if (_(o))
|
|
56
56
|
try {
|
|
57
|
-
const
|
|
57
|
+
const c = R(o, "utf-8");
|
|
58
58
|
try {
|
|
59
|
-
const n = JSON.parse(
|
|
60
|
-
|
|
61
|
-
...
|
|
59
|
+
const n = JSON.parse(c);
|
|
60
|
+
a = D(s, n), n.compilerOptions && typeof n.compilerOptions == "object" && (a.compilerOptions = {
|
|
61
|
+
...s.compilerOptions,
|
|
62
62
|
...n.compilerOptions
|
|
63
|
-
},
|
|
64
|
-
const
|
|
65
|
-
|
|
63
|
+
}, a.compilerOptions.outDir = r, a.compilerOptions.declarationDir = m.join(r, "types"));
|
|
64
|
+
const y = Array.isArray(n.files) ? n.files : [];
|
|
65
|
+
a.files = Array.from(/* @__PURE__ */ new Set([...e, ...y])), console.log("api-client-generator %s Updated existing tsconfig.json", t.greenBright("success"));
|
|
66
66
|
} catch (n) {
|
|
67
67
|
console.error(
|
|
68
68
|
"api-client-generator %s Failed to parse existing tsconfig.json, creating new one",
|
|
69
69
|
t.yellow("warning"),
|
|
70
70
|
n
|
|
71
|
-
),
|
|
71
|
+
), a = { ...s }, a.files = e;
|
|
72
72
|
}
|
|
73
|
-
} catch (
|
|
74
|
-
console.error("api-client-generator %s Failed to read existing tsconfig.json", t.red("error"),
|
|
73
|
+
} catch (c) {
|
|
74
|
+
console.error("api-client-generator %s Failed to read existing tsconfig.json", t.red("error"), c);
|
|
75
75
|
}
|
|
76
76
|
else
|
|
77
|
-
|
|
78
|
-
return
|
|
77
|
+
a.files = e, console.log("api-client-generator %s Created new tsconfig.json", t.greenBright("success"));
|
|
78
|
+
return a;
|
|
79
79
|
}
|
|
80
80
|
function A(o) {
|
|
81
81
|
let e = o;
|
|
82
|
-
const
|
|
82
|
+
const g = [".d.ts", ".ts", ".js"];
|
|
83
83
|
let r;
|
|
84
84
|
do {
|
|
85
85
|
r = !1;
|
|
86
|
-
for (const
|
|
87
|
-
if (e.toLowerCase().endsWith(
|
|
88
|
-
e = e.substring(0, e.length -
|
|
86
|
+
for (const s of g)
|
|
87
|
+
if (e.toLowerCase().endsWith(s.toLowerCase())) {
|
|
88
|
+
e = e.substring(0, e.length - s.length), r = !0;
|
|
89
89
|
break;
|
|
90
90
|
}
|
|
91
91
|
} while (r);
|
|
@@ -98,115 +98,115 @@ function P(o) {
|
|
|
98
98
|
function M(o) {
|
|
99
99
|
return o ? [`./${o}`, `./virtocommerce.${o}`] : [];
|
|
100
100
|
}
|
|
101
|
-
function N(o, e,
|
|
102
|
-
const
|
|
103
|
-
for (const
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
106
|
-
const
|
|
101
|
+
function N(o, e, g, r) {
|
|
102
|
+
const s = {}, a = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const d of o) {
|
|
104
|
+
const i = P(d);
|
|
105
|
+
if (!i) continue;
|
|
106
|
+
const l = `virtocommerce.${i}`, f = `./${m.join(e, `${l}.js`)}`, h = `./${m.join(e, "types", `${l}.d.ts`)}`, p = { import: f, types: h }, u = M(i);
|
|
107
107
|
for (const C of u)
|
|
108
|
-
|
|
108
|
+
s[C] = p, r && console.log(
|
|
109
109
|
"api-client-generator %s Generated standard export: %s -> { import: %s, types: %s }",
|
|
110
110
|
t.blue("debug"),
|
|
111
111
|
t.whiteBright(C),
|
|
112
|
-
t.whiteBright(
|
|
113
|
-
t.whiteBright(
|
|
112
|
+
t.whiteBright(f),
|
|
113
|
+
t.whiteBright(h)
|
|
114
114
|
);
|
|
115
|
-
|
|
115
|
+
a.add(i);
|
|
116
116
|
}
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
for (const [
|
|
120
|
-
if (
|
|
117
|
+
const c = { ...s };
|
|
118
|
+
if (g)
|
|
119
|
+
for (const [d, i] of Object.entries(g)) {
|
|
120
|
+
if (d === ".")
|
|
121
121
|
continue;
|
|
122
|
-
if (typeof
|
|
122
|
+
if (typeof i != "object" || i === null) {
|
|
123
123
|
r && console.log(
|
|
124
124
|
"api-client-generator %s Skipping malformed existing export value for key: %s",
|
|
125
125
|
t.yellow("warning"),
|
|
126
|
-
|
|
126
|
+
d
|
|
127
127
|
);
|
|
128
128
|
continue;
|
|
129
129
|
}
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
130
|
+
const l = i;
|
|
131
|
+
if (!l.import || !l.types) {
|
|
132
132
|
r && console.log(
|
|
133
133
|
"api-client-generator %s Skipping existing export with missing import/types for key: %s",
|
|
134
134
|
t.yellow("warning"),
|
|
135
|
-
|
|
135
|
+
d
|
|
136
136
|
);
|
|
137
137
|
continue;
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
if (!(!
|
|
141
|
-
if (P(
|
|
139
|
+
const f = A(d);
|
|
140
|
+
if (!(!f || f === "."))
|
|
141
|
+
if (P(f), f in s)
|
|
142
142
|
r && console.log(
|
|
143
143
|
"api-client-generator %s Existing export key '%s' was handled by new generation.",
|
|
144
144
|
t.blue("debug"),
|
|
145
|
-
t.whiteBright(
|
|
145
|
+
t.whiteBright(f)
|
|
146
146
|
);
|
|
147
147
|
else {
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
import: `${
|
|
151
|
-
types: `${
|
|
148
|
+
const h = A(l.import), p = A(l.types);
|
|
149
|
+
c[f] = {
|
|
150
|
+
import: `${h}.js`,
|
|
151
|
+
types: `${p}.d.ts`
|
|
152
152
|
}, r && console.log(
|
|
153
153
|
"api-client-generator %s Preserved existing export: %s -> { import: %s, types: %s }",
|
|
154
154
|
t.blue("debug"),
|
|
155
|
-
t.whiteBright(
|
|
156
|
-
t.whiteBright(`${
|
|
157
|
-
t.whiteBright(`${
|
|
155
|
+
t.whiteBright(f),
|
|
156
|
+
t.whiteBright(`${h}.js`),
|
|
157
|
+
t.whiteBright(`${p}.d.ts`)
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
const n = /* @__PURE__ */ new Set();
|
|
162
|
-
for (const
|
|
163
|
-
if (
|
|
164
|
-
const
|
|
165
|
-
|
|
162
|
+
for (const d in c) {
|
|
163
|
+
if (d === ".") continue;
|
|
164
|
+
const i = P(d);
|
|
165
|
+
i && n.add(i);
|
|
166
166
|
}
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
import:
|
|
172
|
-
types:
|
|
167
|
+
const y = Array.from(n);
|
|
168
|
+
if (y.length === 1) {
|
|
169
|
+
const d = y[0], i = `virtocommerce.${d}`, l = `./${m.join(e, `${i}.js`)}`, f = `./${m.join(e, "types", `${i}.d.ts`)}`;
|
|
170
|
+
c["."] = {
|
|
171
|
+
import: l,
|
|
172
|
+
types: f
|
|
173
173
|
}, r && console.log(
|
|
174
174
|
"api-client-generator %s Set root export for single module '%s': { import: %s, types: %s }",
|
|
175
175
|
t.blue("debug"),
|
|
176
|
-
t.whiteBright(
|
|
177
|
-
t.whiteBright(
|
|
178
|
-
t.whiteBright(
|
|
176
|
+
t.whiteBright(d),
|
|
177
|
+
t.whiteBright(l),
|
|
178
|
+
t.whiteBright(f)
|
|
179
179
|
);
|
|
180
|
-
} else if (
|
|
181
|
-
const
|
|
182
|
-
if (typeof
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
|
|
180
|
+
} else if (g && "." in g) {
|
|
181
|
+
const d = g["."];
|
|
182
|
+
if (typeof d == "object" && d !== null) {
|
|
183
|
+
const i = d;
|
|
184
|
+
if (i.import && i.types) {
|
|
185
|
+
const l = P(i.import);
|
|
186
|
+
if (l && y.includes(l)) {
|
|
187
|
+
const f = `virtocommerce.${l}`, h = `./${m.join(e, `${f}.js`)}`, p = `./${m.join(e, "types", `${f}.d.ts`)}`;
|
|
188
|
+
c["."] = { import: h, types: p }, r && console.log(
|
|
189
189
|
"api-client-generator %s Preserved and standardized existing root export pointing to module '%s'",
|
|
190
190
|
t.blue("debug"),
|
|
191
|
-
t.whiteBright(
|
|
191
|
+
t.whiteBright(l)
|
|
192
192
|
);
|
|
193
193
|
} else r && console.log(
|
|
194
194
|
"api-client-generator %s Removed existing root export as it pointed to an unknown or unhandled module '%s'",
|
|
195
195
|
t.yellow("warning"),
|
|
196
|
-
|
|
196
|
+
l || "unknown"
|
|
197
197
|
);
|
|
198
198
|
} else r && console.log("api-client-generator %s Removed malformed existing root export.", t.yellow("warning"));
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
return
|
|
201
|
+
return c;
|
|
202
202
|
}
|
|
203
|
-
function U(o, e,
|
|
204
|
-
const r =
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
name:
|
|
208
|
-
version:
|
|
209
|
-
files:
|
|
203
|
+
function U(o, e, g) {
|
|
204
|
+
const r = g.VERBOSE ?? !1, s = g.APP_BUILD_DIR ?? "dist", a = [];
|
|
205
|
+
s && a.push(s), a.push("package.json");
|
|
206
|
+
const c = {
|
|
207
|
+
name: g.APP_PACKAGE_NAME || "api-client",
|
|
208
|
+
version: g.APP_PACKAGE_VERSION || "1.0.0",
|
|
209
|
+
files: a,
|
|
210
210
|
exports: {},
|
|
211
211
|
// Add metadata to track generated content
|
|
212
212
|
apiClientGenerator: {
|
|
@@ -214,13 +214,13 @@ function U(o, e, p) {
|
|
|
214
214
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
215
215
|
}
|
|
216
216
|
};
|
|
217
|
-
let n = { ...
|
|
217
|
+
let n = { ...c }, y, d, i;
|
|
218
218
|
if (_(o))
|
|
219
219
|
try {
|
|
220
|
-
const
|
|
220
|
+
const p = R(o, "utf-8");
|
|
221
221
|
try {
|
|
222
|
-
const u = JSON.parse(
|
|
223
|
-
typeof u.module == "string" && (
|
|
222
|
+
const u = JSON.parse(p);
|
|
223
|
+
typeof u.module == "string" && (d = u.module), typeof u.types == "string" && (i = u.types), n = D(c, u, [
|
|
224
224
|
"name",
|
|
225
225
|
"version",
|
|
226
226
|
"description",
|
|
@@ -231,7 +231,7 @@ function U(o, e, p) {
|
|
|
231
231
|
"scripts",
|
|
232
232
|
"devDependencies",
|
|
233
233
|
"dependencies"
|
|
234
|
-
]), n.apiClientGenerator =
|
|
234
|
+
]), n.apiClientGenerator = c.apiClientGenerator, u.files && Array.isArray(u.files) && (n.files = Array.from(/* @__PURE__ */ new Set([...a, ...u.files]))), y = u.exports, console.log("api-client-generator %s Updated existing package.json", t.greenBright("success"));
|
|
235
235
|
} catch (u) {
|
|
236
236
|
console.error(
|
|
237
237
|
"api-client-generator %s Failed to parse existing package.json, creating new one",
|
|
@@ -239,36 +239,36 @@ function U(o, e, p) {
|
|
|
239
239
|
u
|
|
240
240
|
);
|
|
241
241
|
}
|
|
242
|
-
} catch (
|
|
243
|
-
console.error("api-client-generator %s Failed to read existing package.json", t.red("error"),
|
|
242
|
+
} catch (p) {
|
|
243
|
+
console.error("api-client-generator %s Failed to read existing package.json", t.red("error"), p);
|
|
244
244
|
}
|
|
245
245
|
else
|
|
246
246
|
console.log("api-client-generator %s Creating new package.json", t.greenBright("success"));
|
|
247
|
-
n.exports = N(e,
|
|
248
|
-
const
|
|
249
|
-
for (const
|
|
250
|
-
if (
|
|
251
|
-
const u = P(
|
|
252
|
-
u &&
|
|
247
|
+
n.exports = N(e, s, y, r);
|
|
248
|
+
const l = Object.keys(n.exports), f = /* @__PURE__ */ new Set();
|
|
249
|
+
for (const p of l) {
|
|
250
|
+
if (p === ".") continue;
|
|
251
|
+
const u = P(p);
|
|
252
|
+
u && f.add(u);
|
|
253
253
|
}
|
|
254
|
-
if (Array.from(
|
|
255
|
-
const
|
|
256
|
-
|
|
254
|
+
if (Array.from(f).length, n.exports && "." in n.exports) {
|
|
255
|
+
const p = n.exports["."];
|
|
256
|
+
p && p.import && (n.module = p.import, r && console.log(
|
|
257
257
|
"api-client-generator %s Set 'module' field from root export: %s",
|
|
258
258
|
t.blue("debug"),
|
|
259
|
-
t.whiteBright(
|
|
260
|
-
)),
|
|
259
|
+
t.whiteBright(p.import)
|
|
260
|
+
)), p && p.types && (n.types = p.types, r && console.log(
|
|
261
261
|
"api-client-generator %s Set 'types' field from root export: %s",
|
|
262
262
|
t.blue("debug"),
|
|
263
|
-
t.whiteBright(
|
|
263
|
+
t.whiteBright(p.types)
|
|
264
264
|
));
|
|
265
265
|
} else
|
|
266
266
|
"module" in n && (delete n.module, r && console.log("api-client-generator %s Removed 'module' field (no clear root export).", t.blue("debug"))), "types" in n && (delete n.types, r && console.log("api-client-generator %s Removed 'types' field (no clear root export).", t.blue("debug")));
|
|
267
267
|
return n;
|
|
268
268
|
}
|
|
269
|
-
async function
|
|
270
|
-
await
|
|
271
|
-
const o =
|
|
269
|
+
async function Y() {
|
|
270
|
+
await j({}, "build");
|
|
271
|
+
const o = k(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? o.APP_PLATFORM_URL, g = o.VERBOSE ?? !1, r = o.APP_TYPE_STYLE ?? "Class";
|
|
272
272
|
if (!e)
|
|
273
273
|
return console.log(
|
|
274
274
|
t.red("error"),
|
|
@@ -278,7 +278,7 @@ async function J() {
|
|
|
278
278
|
return console.log(t.red("error"), "api-client-generator modules command is required");
|
|
279
279
|
if (!o.APP_API_CLIENT_DIRECTORY)
|
|
280
280
|
return console.log(t.red("error"), "api-client-generator outDir command is required");
|
|
281
|
-
const
|
|
281
|
+
const s = o.APP_OUT_DIR ?? "./", a = o.APP_BUILD_DIR ?? "dist", c = new v(o.APP_API_CLIENT_DIRECTORY);
|
|
282
282
|
if (!_(o.APP_API_CLIENT_DIRECTORY))
|
|
283
283
|
try {
|
|
284
284
|
B(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
|
|
@@ -295,25 +295,25 @@ async function J() {
|
|
|
295
295
|
);
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
|
-
const
|
|
299
|
-
if (!_(
|
|
298
|
+
const n = m.join(o.APP_API_CLIENT_DIRECTORY, a);
|
|
299
|
+
if (!_(n))
|
|
300
300
|
try {
|
|
301
|
-
B(
|
|
301
|
+
B(n, { recursive: !0 }), console.log(
|
|
302
302
|
"api-client-generator %s Created build directory %s",
|
|
303
303
|
t.greenBright("success"),
|
|
304
|
-
t.whiteBright(
|
|
304
|
+
t.whiteBright(n)
|
|
305
305
|
);
|
|
306
306
|
} catch (i) {
|
|
307
307
|
console.error(
|
|
308
308
|
"api-client-generator %s Failed to create build directory %s",
|
|
309
309
|
t.red("error"),
|
|
310
|
-
t.whiteBright(
|
|
310
|
+
t.whiteBright(n),
|
|
311
311
|
i
|
|
312
312
|
);
|
|
313
313
|
}
|
|
314
|
-
const
|
|
315
|
-
for (const i of
|
|
316
|
-
const
|
|
314
|
+
const y = o.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), d = [];
|
|
315
|
+
for (const i of y) {
|
|
316
|
+
const l = c.resolveApiClientPaths(i);
|
|
317
317
|
console.log(
|
|
318
318
|
"api-client-generator %s Generating API client for %s module on %s environment",
|
|
319
319
|
t.green("info"),
|
|
@@ -322,31 +322,31 @@ async function J() {
|
|
|
322
322
|
);
|
|
323
323
|
const f = [
|
|
324
324
|
"run",
|
|
325
|
-
|
|
326
|
-
`/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${i},APP_AUTH_API_BASE_PATH=${
|
|
325
|
+
c.nswagPaths.configuration,
|
|
326
|
+
`/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${i},APP_AUTH_API_BASE_PATH=${c.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${c.nswagPaths.templates},APP_API_CLIENT_PATH=${l.nswag},APP_TYPE_STYLE=${r}`,
|
|
327
327
|
"/runtime:Net60"
|
|
328
328
|
];
|
|
329
|
-
|
|
329
|
+
g && console.log("api-client-generator %s Running command: npx nswag %s", t.blue("debug"), f.join(" ")), E("npx nswag", f, {
|
|
330
330
|
stdio: ["ignore", "inherit", "ignore"],
|
|
331
331
|
shell: !0
|
|
332
332
|
}).status === 0 ? (console.log(
|
|
333
333
|
"api-client-generator %s Successfully generated %s",
|
|
334
334
|
t.greenBright("success"),
|
|
335
|
-
t.whiteBright(
|
|
336
|
-
), o.SKIP_BUILD ||
|
|
335
|
+
t.whiteBright(l.console)
|
|
336
|
+
), o.SKIP_BUILD || d.push(`${i.toLowerCase()}.ts`)) : console.error(
|
|
337
337
|
"api-client-generator %s Failed to generate %s",
|
|
338
338
|
t.red("error"),
|
|
339
|
-
t.whiteBright(
|
|
339
|
+
t.whiteBright(l.console)
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
if (!o.SKIP_BUILD) {
|
|
343
|
-
const i = m.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"),
|
|
344
|
-
I(i, JSON.stringify(
|
|
343
|
+
const i = m.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), l = F(i, d, s, a);
|
|
344
|
+
I(i, JSON.stringify(l, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", t.green("info")), E("npx tsc", ["--project", i], {
|
|
345
345
|
stdio: ["ignore", "inherit", "ignore"],
|
|
346
346
|
shell: !0
|
|
347
347
|
}).status === 0 ? console.log("api-client-generator %s Successfully compiled TypeScript files", t.greenBright("success")) : console.error("api-client-generator %s Failed to compile TypeScript files", t.red("error"));
|
|
348
|
-
const
|
|
349
|
-
I(
|
|
348
|
+
const h = m.join(o.APP_API_CLIENT_DIRECTORY, "package.json"), p = U(h, d, o);
|
|
349
|
+
I(h, JSON.stringify(p, null, 2)), console.log("api-client-generator %s Generated package.json", t.greenBright("success"));
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
Y();
|
package/dist/assets/config.nswag
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
{
|
|
2
|
-
"runtime": "Default",
|
|
3
|
-
"defaultVariables": null,
|
|
4
|
-
"documentGenerator": {
|
|
5
|
-
"fromDocument": {
|
|
6
|
-
"url": "$(APP_PLATFORM_URL)docs/$(APP_PLATFORM_MODULE)/swagger.json",
|
|
7
|
-
"output": null,
|
|
8
|
-
"newLineBehavior": "Auto"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"codeGenerators": {
|
|
12
|
-
"openApiToTypeScriptClient": {
|
|
13
|
-
"className": "{controller}Client",
|
|
14
|
-
"moduleName": "",
|
|
15
|
-
"namespace": "",
|
|
16
|
-
"typeScriptVersion": 4.3,
|
|
17
|
-
"template": "Fetch",
|
|
18
|
-
"promiseType": "Promise",
|
|
19
|
-
"httpClass": "HttpClient",
|
|
20
|
-
"withCredentials": false,
|
|
21
|
-
"useSingletonProvider": false,
|
|
22
|
-
"injectionTokenType": "OpaqueToken",
|
|
23
|
-
"rxJsVersion": 6.0,
|
|
24
|
-
"dateTimeType": "Date",
|
|
25
|
-
"nullValue": "Undefined",
|
|
26
|
-
"generateClientClasses": true,
|
|
27
|
-
"generateClientInterfaces": false,
|
|
28
|
-
"generateOptionalParameters": true,
|
|
29
|
-
"exportTypes": true,
|
|
30
|
-
"wrapDtoExceptions": false,
|
|
31
|
-
"exceptionClass": "ApiException",
|
|
32
|
-
"clientBaseClass": "AuthApiBase",
|
|
33
|
-
"wrapResponses": false,
|
|
34
|
-
"wrapResponseMethods": [],
|
|
35
|
-
"generateResponseClasses": true,
|
|
36
|
-
"responseClass": "SwaggerResponse",
|
|
37
|
-
"protectedMethods": [],
|
|
38
|
-
"configurationClass": "",
|
|
39
|
-
"useTransformOptionsMethod": true,
|
|
40
|
-
"useTransformResultMethod": false,
|
|
41
|
-
"generateDtoTypes": true,
|
|
42
|
-
"operationGenerationMode": "MultipleClientsFromOperationId",
|
|
43
|
-
"markOptionalProperties": true,
|
|
44
|
-
"generateCloneMethod": false,
|
|
45
|
-
"typeStyle": "
|
|
46
|
-
"enumStyle": "Enum",
|
|
47
|
-
"useLeafType": false,
|
|
48
|
-
"classTypes": [],
|
|
49
|
-
"extendedClasses": [],
|
|
50
|
-
"extensionCode": "$(APP_AUTH_API_BASE_PATH)",
|
|
51
|
-
"generateDefaultValues": true,
|
|
52
|
-
"excludedTypeNames": [],
|
|
53
|
-
"excludedParameterNames": [],
|
|
54
|
-
"handleReferences": false,
|
|
55
|
-
"generateTypeCheckFunctions": false,
|
|
56
|
-
"generateConstructorInterface": true,
|
|
57
|
-
"convertConstructorInterfaceData": false,
|
|
58
|
-
"importRequiredTypes": true,
|
|
59
|
-
"useGetBaseUrlMethod": true,
|
|
60
|
-
"baseUrlTokenName": "API_BASE_URL",
|
|
61
|
-
"queryNullValue": "",
|
|
62
|
-
"useAbortSignal": false,
|
|
63
|
-
"inlineNamedDictionaries": false,
|
|
64
|
-
"inlineNamedAny": false,
|
|
65
|
-
"includeHttpContext": false,
|
|
66
|
-
"templateDirectory": "$(APP_TEMPLATE_DIRECTORY)",
|
|
67
|
-
"typeNameGeneratorType": null,
|
|
68
|
-
"propertyNameGeneratorType": null,
|
|
69
|
-
"enumNameGeneratorType": null,
|
|
70
|
-
"serviceHost": null,
|
|
71
|
-
"serviceSchemes": null,
|
|
72
|
-
"output": "$(APP_API_CLIENT_PATH)",
|
|
73
|
-
"newLineBehavior": "Auto"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"runtime": "Default",
|
|
3
|
+
"defaultVariables": null,
|
|
4
|
+
"documentGenerator": {
|
|
5
|
+
"fromDocument": {
|
|
6
|
+
"url": "$(APP_PLATFORM_URL)docs/$(APP_PLATFORM_MODULE)/swagger.json",
|
|
7
|
+
"output": null,
|
|
8
|
+
"newLineBehavior": "Auto"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"codeGenerators": {
|
|
12
|
+
"openApiToTypeScriptClient": {
|
|
13
|
+
"className": "{controller}Client",
|
|
14
|
+
"moduleName": "",
|
|
15
|
+
"namespace": "",
|
|
16
|
+
"typeScriptVersion": 4.3,
|
|
17
|
+
"template": "Fetch",
|
|
18
|
+
"promiseType": "Promise",
|
|
19
|
+
"httpClass": "HttpClient",
|
|
20
|
+
"withCredentials": false,
|
|
21
|
+
"useSingletonProvider": false,
|
|
22
|
+
"injectionTokenType": "OpaqueToken",
|
|
23
|
+
"rxJsVersion": 6.0,
|
|
24
|
+
"dateTimeType": "Date",
|
|
25
|
+
"nullValue": "Undefined",
|
|
26
|
+
"generateClientClasses": true,
|
|
27
|
+
"generateClientInterfaces": false,
|
|
28
|
+
"generateOptionalParameters": true,
|
|
29
|
+
"exportTypes": true,
|
|
30
|
+
"wrapDtoExceptions": false,
|
|
31
|
+
"exceptionClass": "ApiException",
|
|
32
|
+
"clientBaseClass": "AuthApiBase",
|
|
33
|
+
"wrapResponses": false,
|
|
34
|
+
"wrapResponseMethods": [],
|
|
35
|
+
"generateResponseClasses": true,
|
|
36
|
+
"responseClass": "SwaggerResponse",
|
|
37
|
+
"protectedMethods": [],
|
|
38
|
+
"configurationClass": "",
|
|
39
|
+
"useTransformOptionsMethod": true,
|
|
40
|
+
"useTransformResultMethod": false,
|
|
41
|
+
"generateDtoTypes": true,
|
|
42
|
+
"operationGenerationMode": "MultipleClientsFromOperationId",
|
|
43
|
+
"markOptionalProperties": true,
|
|
44
|
+
"generateCloneMethod": false,
|
|
45
|
+
"typeStyle": "$(APP_TYPE_STYLE)",
|
|
46
|
+
"enumStyle": "Enum",
|
|
47
|
+
"useLeafType": false,
|
|
48
|
+
"classTypes": [],
|
|
49
|
+
"extendedClasses": [],
|
|
50
|
+
"extensionCode": "$(APP_AUTH_API_BASE_PATH)",
|
|
51
|
+
"generateDefaultValues": true,
|
|
52
|
+
"excludedTypeNames": [],
|
|
53
|
+
"excludedParameterNames": [],
|
|
54
|
+
"handleReferences": false,
|
|
55
|
+
"generateTypeCheckFunctions": false,
|
|
56
|
+
"generateConstructorInterface": true,
|
|
57
|
+
"convertConstructorInterfaceData": false,
|
|
58
|
+
"importRequiredTypes": true,
|
|
59
|
+
"useGetBaseUrlMethod": true,
|
|
60
|
+
"baseUrlTokenName": "API_BASE_URL",
|
|
61
|
+
"queryNullValue": "",
|
|
62
|
+
"useAbortSignal": false,
|
|
63
|
+
"inlineNamedDictionaries": false,
|
|
64
|
+
"inlineNamedAny": false,
|
|
65
|
+
"includeHttpContext": false,
|
|
66
|
+
"templateDirectory": "$(APP_TEMPLATE_DIRECTORY)",
|
|
67
|
+
"typeNameGeneratorType": null,
|
|
68
|
+
"propertyNameGeneratorType": null,
|
|
69
|
+
"enumNameGeneratorType": null,
|
|
70
|
+
"serviceHost": null,
|
|
71
|
+
"serviceSchemes": null,
|
|
72
|
+
"output": "$(APP_API_CLIENT_PATH)",
|
|
73
|
+
"newLineBehavior": "Auto"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/api-client-generator",
|
|
3
3
|
"description": "Tool for API clients generation",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.31",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/api-client-generator.js",
|
|
7
7
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/cross-spawn": "^6.0.6",
|
|
16
|
-
"@vc-shell/ts-config": "^1.1.
|
|
16
|
+
"@vc-shell/ts-config": "^1.1.31",
|
|
17
17
|
"typescript": "^5.8.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
{
|
|
2
|
-
"runtime": "Default",
|
|
3
|
-
"defaultVariables": null,
|
|
4
|
-
"documentGenerator": {
|
|
5
|
-
"fromDocument": {
|
|
6
|
-
"url": "$(APP_PLATFORM_URL)docs/$(APP_PLATFORM_MODULE)/swagger.json",
|
|
7
|
-
"output": null,
|
|
8
|
-
"newLineBehavior": "Auto"
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"codeGenerators": {
|
|
12
|
-
"openApiToTypeScriptClient": {
|
|
13
|
-
"className": "{controller}Client",
|
|
14
|
-
"moduleName": "",
|
|
15
|
-
"namespace": "",
|
|
16
|
-
"typeScriptVersion": 4.3,
|
|
17
|
-
"template": "Fetch",
|
|
18
|
-
"promiseType": "Promise",
|
|
19
|
-
"httpClass": "HttpClient",
|
|
20
|
-
"withCredentials": false,
|
|
21
|
-
"useSingletonProvider": false,
|
|
22
|
-
"injectionTokenType": "OpaqueToken",
|
|
23
|
-
"rxJsVersion": 6.0,
|
|
24
|
-
"dateTimeType": "Date",
|
|
25
|
-
"nullValue": "Undefined",
|
|
26
|
-
"generateClientClasses": true,
|
|
27
|
-
"generateClientInterfaces": false,
|
|
28
|
-
"generateOptionalParameters": true,
|
|
29
|
-
"exportTypes": true,
|
|
30
|
-
"wrapDtoExceptions": false,
|
|
31
|
-
"exceptionClass": "ApiException",
|
|
32
|
-
"clientBaseClass": "AuthApiBase",
|
|
33
|
-
"wrapResponses": false,
|
|
34
|
-
"wrapResponseMethods": [],
|
|
35
|
-
"generateResponseClasses": true,
|
|
36
|
-
"responseClass": "SwaggerResponse",
|
|
37
|
-
"protectedMethods": [],
|
|
38
|
-
"configurationClass": "",
|
|
39
|
-
"useTransformOptionsMethod": true,
|
|
40
|
-
"useTransformResultMethod": false,
|
|
41
|
-
"generateDtoTypes": true,
|
|
42
|
-
"operationGenerationMode": "MultipleClientsFromOperationId",
|
|
43
|
-
"markOptionalProperties": true,
|
|
44
|
-
"generateCloneMethod": false,
|
|
45
|
-
"typeStyle": "
|
|
46
|
-
"enumStyle": "Enum",
|
|
47
|
-
"useLeafType": false,
|
|
48
|
-
"classTypes": [],
|
|
49
|
-
"extendedClasses": [],
|
|
50
|
-
"extensionCode": "$(APP_AUTH_API_BASE_PATH)",
|
|
51
|
-
"generateDefaultValues": true,
|
|
52
|
-
"excludedTypeNames": [],
|
|
53
|
-
"excludedParameterNames": [],
|
|
54
|
-
"handleReferences": false,
|
|
55
|
-
"generateTypeCheckFunctions": false,
|
|
56
|
-
"generateConstructorInterface": true,
|
|
57
|
-
"convertConstructorInterfaceData": false,
|
|
58
|
-
"importRequiredTypes": true,
|
|
59
|
-
"useGetBaseUrlMethod": true,
|
|
60
|
-
"baseUrlTokenName": "API_BASE_URL",
|
|
61
|
-
"queryNullValue": "",
|
|
62
|
-
"useAbortSignal": false,
|
|
63
|
-
"inlineNamedDictionaries": false,
|
|
64
|
-
"inlineNamedAny": false,
|
|
65
|
-
"includeHttpContext": false,
|
|
66
|
-
"templateDirectory": "$(APP_TEMPLATE_DIRECTORY)",
|
|
67
|
-
"typeNameGeneratorType": null,
|
|
68
|
-
"propertyNameGeneratorType": null,
|
|
69
|
-
"enumNameGeneratorType": null,
|
|
70
|
-
"serviceHost": null,
|
|
71
|
-
"serviceSchemes": null,
|
|
72
|
-
"output": "$(APP_API_CLIENT_PATH)",
|
|
73
|
-
"newLineBehavior": "Auto"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"runtime": "Default",
|
|
3
|
+
"defaultVariables": null,
|
|
4
|
+
"documentGenerator": {
|
|
5
|
+
"fromDocument": {
|
|
6
|
+
"url": "$(APP_PLATFORM_URL)docs/$(APP_PLATFORM_MODULE)/swagger.json",
|
|
7
|
+
"output": null,
|
|
8
|
+
"newLineBehavior": "Auto"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"codeGenerators": {
|
|
12
|
+
"openApiToTypeScriptClient": {
|
|
13
|
+
"className": "{controller}Client",
|
|
14
|
+
"moduleName": "",
|
|
15
|
+
"namespace": "",
|
|
16
|
+
"typeScriptVersion": 4.3,
|
|
17
|
+
"template": "Fetch",
|
|
18
|
+
"promiseType": "Promise",
|
|
19
|
+
"httpClass": "HttpClient",
|
|
20
|
+
"withCredentials": false,
|
|
21
|
+
"useSingletonProvider": false,
|
|
22
|
+
"injectionTokenType": "OpaqueToken",
|
|
23
|
+
"rxJsVersion": 6.0,
|
|
24
|
+
"dateTimeType": "Date",
|
|
25
|
+
"nullValue": "Undefined",
|
|
26
|
+
"generateClientClasses": true,
|
|
27
|
+
"generateClientInterfaces": false,
|
|
28
|
+
"generateOptionalParameters": true,
|
|
29
|
+
"exportTypes": true,
|
|
30
|
+
"wrapDtoExceptions": false,
|
|
31
|
+
"exceptionClass": "ApiException",
|
|
32
|
+
"clientBaseClass": "AuthApiBase",
|
|
33
|
+
"wrapResponses": false,
|
|
34
|
+
"wrapResponseMethods": [],
|
|
35
|
+
"generateResponseClasses": true,
|
|
36
|
+
"responseClass": "SwaggerResponse",
|
|
37
|
+
"protectedMethods": [],
|
|
38
|
+
"configurationClass": "",
|
|
39
|
+
"useTransformOptionsMethod": true,
|
|
40
|
+
"useTransformResultMethod": false,
|
|
41
|
+
"generateDtoTypes": true,
|
|
42
|
+
"operationGenerationMode": "MultipleClientsFromOperationId",
|
|
43
|
+
"markOptionalProperties": true,
|
|
44
|
+
"generateCloneMethod": false,
|
|
45
|
+
"typeStyle": "$(APP_TYPE_STYLE)",
|
|
46
|
+
"enumStyle": "Enum",
|
|
47
|
+
"useLeafType": false,
|
|
48
|
+
"classTypes": [],
|
|
49
|
+
"extendedClasses": [],
|
|
50
|
+
"extensionCode": "$(APP_AUTH_API_BASE_PATH)",
|
|
51
|
+
"generateDefaultValues": true,
|
|
52
|
+
"excludedTypeNames": [],
|
|
53
|
+
"excludedParameterNames": [],
|
|
54
|
+
"handleReferences": false,
|
|
55
|
+
"generateTypeCheckFunctions": false,
|
|
56
|
+
"generateConstructorInterface": true,
|
|
57
|
+
"convertConstructorInterfaceData": false,
|
|
58
|
+
"importRequiredTypes": true,
|
|
59
|
+
"useGetBaseUrlMethod": true,
|
|
60
|
+
"baseUrlTokenName": "API_BASE_URL",
|
|
61
|
+
"queryNullValue": "",
|
|
62
|
+
"useAbortSignal": false,
|
|
63
|
+
"inlineNamedDictionaries": false,
|
|
64
|
+
"inlineNamedAny": false,
|
|
65
|
+
"includeHttpContext": false,
|
|
66
|
+
"templateDirectory": "$(APP_TEMPLATE_DIRECTORY)",
|
|
67
|
+
"typeNameGeneratorType": null,
|
|
68
|
+
"propertyNameGeneratorType": null,
|
|
69
|
+
"enumNameGeneratorType": null,
|
|
70
|
+
"serviceHost": null,
|
|
71
|
+
"serviceSchemes": null,
|
|
72
|
+
"output": "$(APP_API_CLIENT_PATH)",
|
|
73
|
+
"newLineBehavior": "Auto"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|