@vc-shell/api-client-generator 1.1.29 → 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 CHANGED
@@ -1,3 +1,21 @@
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
+
10
+ ## [1.1.30](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.29...v1.1.30) (2025-06-11)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **api-client-generator:** update import and types path construction for core modules to use path.join for improved path handling ([1d730a1](https://github.com/VirtoCommerce/vc-shell/commit/1d730a19c7c4aa4a309354875d34ba2e8fc3d335))
16
+
17
+
18
+
1
19
  ## [1.1.29](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.28...v1.1.29) (2025-06-05)
2
20
 
3
21
 
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,212 +1,212 @@
1
1
  import t from "chalk";
2
2
  import { sync as E } from "cross-spawn";
3
- import { resolveConfig as T } from "vite";
4
- import { existsSync as _, mkdirSync as I, writeFileSync as B, readFileSync as D } from "node:fs";
5
- import y, { dirname as S, resolve as R, join as w, relative as x } from "node:path";
6
- import { fileURLToPath as j } from "node:url";
7
- import { cwd as k } from "node:process";
8
- import L from "mri";
9
- const b = j(import.meta.url), F = S(b);
10
- class $ {
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
+ import { fileURLToPath as S } from "node:url";
7
+ import { cwd as L } from "node:process";
8
+ import k from "mri";
9
+ const b = S(import.meta.url), $ = O(b);
10
+ class v {
11
11
  workingDirectory;
12
12
  generatorDirectory;
13
13
  assetsDirectory;
14
14
  apiClientDirectory;
15
15
  nswagPaths;
16
16
  constructor(e) {
17
- this.workingDirectory = k(), this.generatorDirectory = R(F, ".."), this.assetsDirectory = w(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = R(this.workingDirectory, e), this.nswagPaths = {
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 p = `${e.toLowerCase()}.ts`;
24
+ const g = `${e.toLowerCase()}.ts`;
25
25
  return {
26
- fileName: p,
27
- nswag: w(x(this.assetsDirectory, this.apiClientDirectory), p),
28
- console: w(x(this.workingDirectory, this.apiClientDirectory), p)
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 O(o, e, p = []) {
32
+ function D(o, e, g = []) {
33
33
  const r = { ...o };
34
- for (const a of p)
35
- a in e && (r[a] = e[a]);
36
- for (const [a, s] of Object.entries(e)) {
37
- const c = a;
38
- a in r && typeof r[c] == "object" && !Array.isArray(r[c]) && typeof s == "object" && !Array.isArray(s) && s !== null ? r[c] = { ...r[c], ...s } : p.includes(a) || (r[c] = s);
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 v(o, e, p, r) {
43
- const a = {
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: y.join(p, "types"),
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 s = { ...a };
54
+ let a = { ...s };
55
55
  if (_(o))
56
56
  try {
57
- const c = D(o, "utf-8");
57
+ const c = R(o, "utf-8");
58
58
  try {
59
59
  const n = JSON.parse(c);
60
- s = O(a, n), n.compilerOptions && typeof n.compilerOptions == "object" && (s.compilerOptions = {
61
- ...a.compilerOptions,
60
+ a = D(s, n), n.compilerOptions && typeof n.compilerOptions == "object" && (a.compilerOptions = {
61
+ ...s.compilerOptions,
62
62
  ...n.compilerOptions
63
- }, s.compilerOptions.outDir = r, s.compilerOptions.declarationDir = y.join(r, "types"));
64
- const h = Array.isArray(n.files) ? n.files : [];
65
- s.files = Array.from(/* @__PURE__ */ new Set([...e, ...h])), console.log("api-client-generator %s Updated existing tsconfig.json", t.greenBright("success"));
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
- ), s = { ...a }, s.files = e;
71
+ ), a = { ...s }, a.files = e;
72
72
  }
73
73
  } catch (c) {
74
74
  console.error("api-client-generator %s Failed to read existing tsconfig.json", t.red("error"), c);
75
75
  }
76
76
  else
77
- s.files = e, console.log("api-client-generator %s Created new tsconfig.json", t.greenBright("success"));
78
- return s;
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 p = [".d.ts", ".ts", ".js"];
82
+ const g = [".d.ts", ".ts", ".js"];
83
83
  let r;
84
84
  do {
85
85
  r = !1;
86
- for (const a of p)
87
- if (e.toLowerCase().endsWith(a.toLowerCase())) {
88
- e = e.substring(0, e.length - a.length), r = !0;
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);
92
- return e = e.replace(/\/\.\//g, "/"), e = e.replace(/\/+/g, "/"), e = e.replace(/\.\.\//g, ""), e !== "." && !e.startsWith("./") && !e.startsWith("/") && !y.isAbsolute(e) && (e = "./" + e), e.startsWith("//") && (e = "./" + e.substring(2)), e !== "." && e.startsWith("/") && !e.startsWith("./") && !y.isAbsolute(e) && (e = "." + e), e !== "." && e.startsWith("././") && (e = "./" + e.substring(3)), e;
92
+ return e = e.replace(/\/\.\//g, "/"), e = e.replace(/\/+/g, "/"), e = e.replace(/\.\.\//g, ""), e !== "." && !e.startsWith("./") && !e.startsWith("/") && !m.isAbsolute(e) && (e = "./" + e), e.startsWith("//") && (e = "./" + e.substring(2)), e !== "." && e.startsWith("/") && !e.startsWith("./") && !m.isAbsolute(e) && (e = "." + e), e !== "." && e.startsWith("././") && (e = "./" + e.substring(3)), e;
93
93
  }
94
94
  function P(o) {
95
95
  let e = A(o);
96
- return e = y.basename(e), e = e.replace(/^virtocommerce\./i, ""), e.toLowerCase();
96
+ return e = m.basename(e), e = e.replace(/^virtocommerce\./i, ""), e.toLowerCase();
97
97
  }
98
98
  function M(o) {
99
99
  return o ? [`./${o}`, `./virtocommerce.${o}`] : [];
100
100
  }
101
- function U(o, e, p, r) {
102
- const a = {}, s = /* @__PURE__ */ new Set();
103
- for (const i of o) {
104
- const l = P(i);
105
- if (!l) continue;
106
- const g = `virtocommerce.${l}`, d = `./${e}/${g}.js`, m = `./${e}/types/${g}.d.ts`, f = { import: d, types: m }, u = M(l);
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
- a[C] = f, r && console.log(
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(d),
113
- t.whiteBright(m)
112
+ t.whiteBright(f),
113
+ t.whiteBright(h)
114
114
  );
115
- s.add(l);
115
+ a.add(i);
116
116
  }
117
- const c = { ...a };
118
- if (p)
119
- for (const [i, l] of Object.entries(p)) {
120
- if (i === ".")
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 l != "object" || l === null) {
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
- i
126
+ d
127
127
  );
128
128
  continue;
129
129
  }
130
- const g = l;
131
- if (!g.import || !g.types) {
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
- i
135
+ d
136
136
  );
137
137
  continue;
138
138
  }
139
- const d = A(i);
140
- if (!(!d || d === "."))
141
- if (P(d), d in a)
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(d)
145
+ t.whiteBright(f)
146
146
  );
147
147
  else {
148
- const m = A(g.import), f = A(g.types);
149
- c[d] = {
150
- import: `${m}.js`,
151
- types: `${f}.d.ts`
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(d),
156
- t.whiteBright(`${m}.js`),
157
- t.whiteBright(`${f}.d.ts`)
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 i in c) {
163
- if (i === ".") continue;
164
- const l = P(i);
165
- l && n.add(l);
162
+ for (const d in c) {
163
+ if (d === ".") continue;
164
+ const i = P(d);
165
+ i && n.add(i);
166
166
  }
167
- const h = Array.from(n);
168
- if (h.length === 1) {
169
- const i = h[0], l = `./${e}/${i}.js`, g = `./${e}/types/${i}.d.ts`;
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
170
  c["."] = {
171
171
  import: l,
172
- types: g
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(i),
176
+ t.whiteBright(d),
177
177
  t.whiteBright(l),
178
- t.whiteBright(g)
178
+ t.whiteBright(f)
179
179
  );
180
- } else if (p && "." in p) {
181
- const i = p["."];
182
- if (typeof i == "object" && i !== null) {
183
- const l = i;
184
- if (l.import && l.types) {
185
- const g = P(l.import);
186
- if (g && h.includes(g)) {
187
- const d = `./${e}/${g}.js`, m = `./${e}/types/${g}.d.ts`;
188
- c["."] = { import: d, types: m }, r && console.log(
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(g)
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
- g || "unknown"
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
201
  return c;
202
202
  }
203
- function N(o, e, p) {
204
- const r = p.VERBOSE ?? !1, a = p.APP_BUILD_DIR ?? "dist", s = [];
205
- a && s.push(a), s.push("package.json");
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
206
  const c = {
207
- name: p.APP_PACKAGE_NAME || "api-client",
208
- version: p.APP_PACKAGE_VERSION || "1.0.0",
209
- files: s,
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 N(o, e, p) {
214
214
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
215
215
  }
216
216
  };
217
- let n = { ...c }, h, i, l;
217
+ let n = { ...c }, y, d, i;
218
218
  if (_(o))
219
219
  try {
220
- const f = D(o, "utf-8");
220
+ const p = R(o, "utf-8");
221
221
  try {
222
- const u = JSON.parse(f);
223
- typeof u.module == "string" && (i = u.module), typeof u.types == "string" && (l = u.types), n = O(c, u, [
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 N(o, e, p) {
231
231
  "scripts",
232
232
  "devDependencies",
233
233
  "dependencies"
234
- ]), n.apiClientGenerator = c.apiClientGenerator, u.files && Array.isArray(u.files) && (n.files = Array.from(/* @__PURE__ */ new Set([...s, ...u.files]))), h = u.exports, console.log("api-client-generator %s Updated existing package.json", t.greenBright("success"));
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 N(o, e, p) {
239
239
  u
240
240
  );
241
241
  }
242
- } catch (f) {
243
- console.error("api-client-generator %s Failed to read existing package.json", t.red("error"), f);
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 = U(e, a, h, r);
248
- const g = Object.keys(n.exports), d = /* @__PURE__ */ new Set();
249
- for (const f of g) {
250
- if (f === ".") continue;
251
- const u = P(f);
252
- u && d.add(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(d).length, n.exports && "." in n.exports) {
255
- const f = n.exports["."];
256
- f && f.import && (n.module = f.import, r && console.log(
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(f.import)
260
- )), f && f.types && (n.types = f.types, r && console.log(
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(f.types)
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 J() {
270
- await T({}, "build");
271
- const o = L(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? o.APP_PLATFORM_URL, p = o.VERBOSE ?? !1;
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,10 +278,10 @@ 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 r = o.APP_OUT_DIR ?? "./", a = o.APP_BUILD_DIR ?? "dist", s = new $(o.APP_API_CLIENT_DIRECTORY);
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
- I(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
284
+ B(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
285
285
  "api-client-generator %s Created directory %s",
286
286
  t.greenBright("success"),
287
287
  t.whiteBright(o.APP_API_CLIENT_DIRECTORY)
@@ -295,58 +295,58 @@ async function J() {
295
295
  );
296
296
  return;
297
297
  }
298
- const c = y.join(o.APP_API_CLIENT_DIRECTORY, a);
299
- if (!_(c))
298
+ const n = m.join(o.APP_API_CLIENT_DIRECTORY, a);
299
+ if (!_(n))
300
300
  try {
301
- I(c, { recursive: !0 }), console.log(
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(c)
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(c),
310
+ t.whiteBright(n),
311
311
  i
312
312
  );
313
313
  }
314
- const n = o.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), h = [];
315
- for (const i of n) {
316
- const l = s.resolveApiClientPaths(i);
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"),
320
320
  t.whiteBright(i),
321
321
  t.whiteBright(e)
322
322
  );
323
- const g = [
323
+ const f = [
324
324
  "run",
325
- s.nswagPaths.configuration,
326
- `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${i},APP_AUTH_API_BASE_PATH=${s.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${s.nswagPaths.templates},APP_API_CLIENT_PATH=${l.nswag}`,
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
- p && console.log("api-client-generator %s Running command: npx nswag %s", t.blue("debug"), g.join(" ")), E("npx nswag", g, {
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
335
  t.whiteBright(l.console)
336
- ), o.SKIP_BUILD || h.push(`${i.toLowerCase()}.ts`)) : console.error(
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
339
  t.whiteBright(l.console)
340
340
  );
341
341
  }
342
342
  if (!o.SKIP_BUILD) {
343
- const i = y.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), l = v(i, h, r, a);
344
- B(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], {
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 d = y.join(o.APP_API_CLIENT_DIRECTORY, "package.json"), m = N(d, h, o);
349
- B(d, JSON.stringify(m, null, 2)), console.log("api-client-generator %s Generated package.json", t.greenBright("success"));
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
- J();
352
+ Y();
@@ -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": "Class",
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.29",
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.29",
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": "Class",
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
+ }