swagger-typescript-api 13.0.21 → 13.0.22

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/types.d.cts CHANGED
@@ -8,17 +8,13 @@ declare class NameResolver {
8
8
 
9
9
  /** @type {CodeGenConfig} */
10
10
  config;
11
- /** @type {Logger} */
12
- logger;
13
11
 
14
12
  /**
15
13
  * @param {CodeGenConfig} config;
16
- * @param {Logger} logger;
17
14
  * @param {string[]} reservedNames
18
15
  */
19
- constructor(config, logger, reservedNames, getFallbackName) {
16
+ constructor(config, reservedNames, getFallbackName) {
20
17
  this.config = config;
21
- this.logger = logger;
22
18
  this.getFallbackName = getFallbackName;
23
19
  this.reserve(reservedNames);
24
20
  }
@@ -59,7 +55,7 @@ declare class NameResolver {
59
55
  const variant = resolver(variants, extras);
60
56
 
61
57
  if (variant === undefined) {
62
- this.logger.warn(
58
+ consola.warn(
63
59
  "unable to resolve name. current reserved names: ",
64
60
  this.reservedNames,
65
61
  );
@@ -89,14 +85,14 @@ declare class NameResolver {
89
85
  return usageName;
90
86
  }
91
87
 
92
- this.logger.debug(
88
+ consola.debug(
93
89
  "trying to resolve name with using fallback name generator using variants",
94
90
  variants,
95
91
  );
96
92
  return this.resolve(variants, this.getFallbackName, extras);
97
93
  }
98
94
 
99
- this.logger.debug(
95
+ consola.debug(
100
96
  "problem with reserving names. current reserved names: ",
101
97
  this.reservedNames,
102
98
  );
@@ -111,11 +107,10 @@ declare class ComponentTypeNameResolver extends NameResolver {
111
107
 
112
108
  /**
113
109
  * @param {CodeGenConfig} config;
114
- * @param {Logger} logger;
115
110
  * @param {string[]} reservedNames
116
111
  */
117
- constructor(config, logger, reservedNames) {
118
- super(config, logger, reservedNames, (variants) => {
112
+ constructor(config, reservedNames) {
113
+ super(config, reservedNames, (variants) => {
119
114
  const randomVariant = variants[getRandomInt(0, variants.length - 1)];
120
115
  if (randomVariant) {
121
116
  if (!this.countersByVariant.has(randomVariant)) {
@@ -124,7 +119,7 @@ declare class ComponentTypeNameResolver extends NameResolver {
124
119
  const variantCounter = this.countersByVariant.get(randomVariant) + 1;
125
120
  this.countersByVariant.set(randomVariant, variantCounter);
126
121
  const dirtyResolvedName = `${randomVariant}${variantCounter}`;
127
- this.logger.debug(
122
+ consola.debug(
128
123
  "generated dirty resolved type name for component - ",
129
124
  dirtyResolvedName,
130
125
  );
@@ -133,7 +128,7 @@ declare class ComponentTypeNameResolver extends NameResolver {
133
128
 
134
129
  const fallbackName = `${this.config.componentTypeNameResolver}${this
135
130
  .fallbackNameCounter++}`;
136
- this.logger.debug(
131
+ consola.debug(
137
132
  "generated fallback type name for component - ",
138
133
  fallbackName,
139
134
  );
@@ -147,8 +142,6 @@ declare class MonoSchemaParser {
147
142
  typeName;
148
143
  schemaPath;
149
144
 
150
- /** @type {Logger} */
151
- logger;
152
145
  /** @type {SchemaParser} */
153
146
  schemaParser;
154
147
  /** @type {SchemaParserFabric} */
@@ -167,7 +160,6 @@ declare class MonoSchemaParser {
167
160
  constructor(schemaParser, schema, typeName = null, schemaPath = []) {
168
161
  this.schemaParser = schemaParser;
169
162
  this.schemaParserFabric = schemaParser.schemaParserFabric;
170
- this.logger = schemaParser.logger;
171
163
  this.schema = schema;
172
164
  this.typeName = typeName;
173
165
  this.typeNameFormatter = schemaParser.typeNameFormatter;
@@ -192,8 +184,6 @@ declare class SchemaParser {
192
184
  schemaParserFabric;
193
185
  /** @type {CodeGenConfig} */
194
186
  config;
195
- /** @type {Logger} */
196
- logger;
197
187
  /** @type {SchemaComponentsMap} */
198
188
  schemaComponentsMap;
199
189
  /** @type {TypeNameFormatter} */
@@ -214,7 +204,6 @@ declare class SchemaParser {
214
204
  constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {
215
205
  this.schemaParserFabric = schemaParserFabric;
216
206
  this.config = schemaParserFabric.config;
217
- this.logger = schemaParserFabric.logger;
218
207
  this.templatesWorker = schemaParserFabric.templatesWorker;
219
208
  this.schemaComponentsMap = schemaParserFabric.schemaComponentsMap;
220
209
  this.typeNameFormatter = schemaParserFabric.typeNameFormatter;
@@ -379,7 +368,7 @@ declare class SchemaParser {
379
368
  this.schema.enum.length === 1 &&
380
369
  this.schema.enum[0] == null
381
370
  ) {
382
- this.logger.debug("invalid enum schema", this.schema);
371
+ consola.debug("invalid enum schema", this.schema);
383
372
  this.schema = { type: this.config.Ts.Keyword.Null };
384
373
  }
385
374
  // schema is response schema
@@ -470,8 +459,6 @@ declare class SchemaParser {
470
459
  */
471
460
 
472
461
  declare class Translator {
473
- /** @type {Logger} */
474
- logger;
475
462
  /** @type {CodeGenConfig} */
476
463
  config;
477
464
  /** @type {CodeFormatter} */
@@ -481,7 +468,6 @@ declare class Translator {
481
468
  * @param codeGenProcess
482
469
  */
483
470
  constructor(codeGenProcess) {
484
- this.logger = codeGenProcess.logger;
485
471
  this.config = codeGenProcess.config;
486
472
  this.codeFormatter = codeGenProcess.codeFormatter;
487
473
  }
@@ -491,7 +477,6 @@ declare class Translator {
491
477
  * @param input {TranslatorIO}
492
478
  * @return {Promise<TranslatorIO[]>}
493
479
  */
494
- // eslint-disable-next-line no-unused-vars
495
480
  translate(input) {
496
481
  throw new Error("not implemented");
497
482
  }
@@ -504,8 +489,6 @@ declare class CodeGenProcess {
504
489
  swaggerSchemaResolver;
505
490
  /** @type {SchemaComponentsMap} */
506
491
  schemaComponentsMap;
507
- /** @type {Logger} */
508
- logger;
509
492
  /** @type {TypeNameFormatter} */
510
493
  typeNameFormatter;
511
494
  /** @type {SchemaParserFabric} */
@@ -529,7 +512,6 @@ declare class CodeGenProcess {
529
512
  */
530
513
  constructor(config) {
531
514
  this.config = new CodeGenConfig(config);
532
- this.logger = new Logger(this);
533
515
  this.fileSystem = new FileSystem(this);
534
516
  this.schemaWalker = new SchemaWalker(this);
535
517
  this.swaggerSchemaResolver = new SwaggerSchemaResolver(this);
@@ -540,7 +522,6 @@ declare class CodeGenProcess {
540
522
  this.schemaParserFabric = new SchemaParserFabric(this);
541
523
  this.schemaRoutes = new SchemaRoutes(this);
542
524
  this.javascriptTranslator = new JavascriptTranslator(this);
543
- this.config.componentTypeNameResolver.logger = this.logger;
544
525
  }
545
526
 
546
527
  async start() {
@@ -563,7 +544,7 @@ declare class CodeGenProcess {
563
544
  this.schemaWalker.addSchema("$usage", swagger.usageSchema);
564
545
  this.schemaWalker.addSchema("$original", swagger.originalSchema);
565
546
 
566
- this.logger.event("start generating your typescript api");
547
+ consola.info("start generating your typescript api");
567
548
 
568
549
  this.config.update(
569
550
  this.config.hooks.onInit(this.config, this) || this.config,
@@ -628,11 +609,11 @@ declare class CodeGenProcess {
628
609
 
629
610
  if (this.fileSystem.pathIsExist(this.config.output)) {
630
611
  if (this.config.cleanOutput) {
631
- this.logger.debug(`cleaning dir ${this.config.output}`);
612
+ consola.debug("cleaning dir", this.config.output);
632
613
  this.fileSystem.cleanDir(this.config.output);
633
614
  }
634
615
  } else {
635
- this.logger.debug(
616
+ consola.debug(
636
617
  `path ${this.config.output} is not exist. creating dir by this path`,
637
618
  );
638
619
  this.fileSystem.createDir(this.config.output);
@@ -653,7 +634,7 @@ declare class CodeGenProcess {
653
634
  withPrefix: true,
654
635
  });
655
636
 
656
- this.logger.success(
637
+ consola.success(
657
638
  "api file",
658
639
  `"${file.fileName}${file.fileExtension}"`,
659
640
  `created in ${this.config.output}`,
@@ -978,7 +959,7 @@ declare class CodeGenProcess {
978
959
  const fileExtension = typescript.Extension.Ts;
979
960
 
980
961
  if (configuration.translateToJavaScript) {
981
- this.logger.debug("using js translator for", fileName);
962
+ consola.debug("using js translator for", fileName);
982
963
  return await this.javascriptTranslator.translate({
983
964
  fileName: fileName,
984
965
  fileExtension: fileExtension,
@@ -987,7 +968,7 @@ declare class CodeGenProcess {
987
968
  }
988
969
 
989
970
  if (configuration.customTranslator) {
990
- this.logger.debug("using custom translator for", fileName);
971
+ consola.debug("using custom translator for", fileName);
991
972
  return await configuration.customTranslator.translate({
992
973
  fileName: fileName,
993
974
  fileExtension: fileExtension,
@@ -995,7 +976,7 @@ declare class CodeGenProcess {
995
976
  });
996
977
  }
997
978
 
998
- this.logger.debug("generating output for", `${fileName}${fileExtension}`);
979
+ consola.debug("generating output for", `${fileName}${fileExtension}`);
999
980
 
1000
981
  return [
1001
982
  {
@@ -1240,7 +1221,6 @@ interface GenerateApiParamsBase {
1240
1221
  * translate({ fileName, fileExtension, fileContent }) {
1241
1222
  * this.codeFormatter.format()
1242
1223
  * this.config.
1243
- * this.logger.
1244
1224
  *
1245
1225
  * return [
1246
1226
  * {
package/dist/types.d.ts CHANGED
@@ -8,17 +8,13 @@ declare class NameResolver {
8
8
 
9
9
  /** @type {CodeGenConfig} */
10
10
  config;
11
- /** @type {Logger} */
12
- logger;
13
11
 
14
12
  /**
15
13
  * @param {CodeGenConfig} config;
16
- * @param {Logger} logger;
17
14
  * @param {string[]} reservedNames
18
15
  */
19
- constructor(config, logger, reservedNames, getFallbackName) {
16
+ constructor(config, reservedNames, getFallbackName) {
20
17
  this.config = config;
21
- this.logger = logger;
22
18
  this.getFallbackName = getFallbackName;
23
19
  this.reserve(reservedNames);
24
20
  }
@@ -59,7 +55,7 @@ declare class NameResolver {
59
55
  const variant = resolver(variants, extras);
60
56
 
61
57
  if (variant === undefined) {
62
- this.logger.warn(
58
+ consola.warn(
63
59
  "unable to resolve name. current reserved names: ",
64
60
  this.reservedNames,
65
61
  );
@@ -89,14 +85,14 @@ declare class NameResolver {
89
85
  return usageName;
90
86
  }
91
87
 
92
- this.logger.debug(
88
+ consola.debug(
93
89
  "trying to resolve name with using fallback name generator using variants",
94
90
  variants,
95
91
  );
96
92
  return this.resolve(variants, this.getFallbackName, extras);
97
93
  }
98
94
 
99
- this.logger.debug(
95
+ consola.debug(
100
96
  "problem with reserving names. current reserved names: ",
101
97
  this.reservedNames,
102
98
  );
@@ -111,11 +107,10 @@ declare class ComponentTypeNameResolver extends NameResolver {
111
107
 
112
108
  /**
113
109
  * @param {CodeGenConfig} config;
114
- * @param {Logger} logger;
115
110
  * @param {string[]} reservedNames
116
111
  */
117
- constructor(config, logger, reservedNames) {
118
- super(config, logger, reservedNames, (variants) => {
112
+ constructor(config, reservedNames) {
113
+ super(config, reservedNames, (variants) => {
119
114
  const randomVariant = variants[getRandomInt(0, variants.length - 1)];
120
115
  if (randomVariant) {
121
116
  if (!this.countersByVariant.has(randomVariant)) {
@@ -124,7 +119,7 @@ declare class ComponentTypeNameResolver extends NameResolver {
124
119
  const variantCounter = this.countersByVariant.get(randomVariant) + 1;
125
120
  this.countersByVariant.set(randomVariant, variantCounter);
126
121
  const dirtyResolvedName = `${randomVariant}${variantCounter}`;
127
- this.logger.debug(
122
+ consola.debug(
128
123
  "generated dirty resolved type name for component - ",
129
124
  dirtyResolvedName,
130
125
  );
@@ -133,7 +128,7 @@ declare class ComponentTypeNameResolver extends NameResolver {
133
128
 
134
129
  const fallbackName = `${this.config.componentTypeNameResolver}${this
135
130
  .fallbackNameCounter++}`;
136
- this.logger.debug(
131
+ consola.debug(
137
132
  "generated fallback type name for component - ",
138
133
  fallbackName,
139
134
  );
@@ -147,8 +142,6 @@ declare class MonoSchemaParser {
147
142
  typeName;
148
143
  schemaPath;
149
144
 
150
- /** @type {Logger} */
151
- logger;
152
145
  /** @type {SchemaParser} */
153
146
  schemaParser;
154
147
  /** @type {SchemaParserFabric} */
@@ -167,7 +160,6 @@ declare class MonoSchemaParser {
167
160
  constructor(schemaParser, schema, typeName = null, schemaPath = []) {
168
161
  this.schemaParser = schemaParser;
169
162
  this.schemaParserFabric = schemaParser.schemaParserFabric;
170
- this.logger = schemaParser.logger;
171
163
  this.schema = schema;
172
164
  this.typeName = typeName;
173
165
  this.typeNameFormatter = schemaParser.typeNameFormatter;
@@ -192,8 +184,6 @@ declare class SchemaParser {
192
184
  schemaParserFabric;
193
185
  /** @type {CodeGenConfig} */
194
186
  config;
195
- /** @type {Logger} */
196
- logger;
197
187
  /** @type {SchemaComponentsMap} */
198
188
  schemaComponentsMap;
199
189
  /** @type {TypeNameFormatter} */
@@ -214,7 +204,6 @@ declare class SchemaParser {
214
204
  constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {
215
205
  this.schemaParserFabric = schemaParserFabric;
216
206
  this.config = schemaParserFabric.config;
217
- this.logger = schemaParserFabric.logger;
218
207
  this.templatesWorker = schemaParserFabric.templatesWorker;
219
208
  this.schemaComponentsMap = schemaParserFabric.schemaComponentsMap;
220
209
  this.typeNameFormatter = schemaParserFabric.typeNameFormatter;
@@ -379,7 +368,7 @@ declare class SchemaParser {
379
368
  this.schema.enum.length === 1 &&
380
369
  this.schema.enum[0] == null
381
370
  ) {
382
- this.logger.debug("invalid enum schema", this.schema);
371
+ consola.debug("invalid enum schema", this.schema);
383
372
  this.schema = { type: this.config.Ts.Keyword.Null };
384
373
  }
385
374
  // schema is response schema
@@ -470,8 +459,6 @@ declare class SchemaParser {
470
459
  */
471
460
 
472
461
  declare class Translator {
473
- /** @type {Logger} */
474
- logger;
475
462
  /** @type {CodeGenConfig} */
476
463
  config;
477
464
  /** @type {CodeFormatter} */
@@ -481,7 +468,6 @@ declare class Translator {
481
468
  * @param codeGenProcess
482
469
  */
483
470
  constructor(codeGenProcess) {
484
- this.logger = codeGenProcess.logger;
485
471
  this.config = codeGenProcess.config;
486
472
  this.codeFormatter = codeGenProcess.codeFormatter;
487
473
  }
@@ -491,7 +477,6 @@ declare class Translator {
491
477
  * @param input {TranslatorIO}
492
478
  * @return {Promise<TranslatorIO[]>}
493
479
  */
494
- // eslint-disable-next-line no-unused-vars
495
480
  translate(input) {
496
481
  throw new Error("not implemented");
497
482
  }
@@ -504,8 +489,6 @@ declare class CodeGenProcess {
504
489
  swaggerSchemaResolver;
505
490
  /** @type {SchemaComponentsMap} */
506
491
  schemaComponentsMap;
507
- /** @type {Logger} */
508
- logger;
509
492
  /** @type {TypeNameFormatter} */
510
493
  typeNameFormatter;
511
494
  /** @type {SchemaParserFabric} */
@@ -529,7 +512,6 @@ declare class CodeGenProcess {
529
512
  */
530
513
  constructor(config) {
531
514
  this.config = new CodeGenConfig(config);
532
- this.logger = new Logger(this);
533
515
  this.fileSystem = new FileSystem(this);
534
516
  this.schemaWalker = new SchemaWalker(this);
535
517
  this.swaggerSchemaResolver = new SwaggerSchemaResolver(this);
@@ -540,7 +522,6 @@ declare class CodeGenProcess {
540
522
  this.schemaParserFabric = new SchemaParserFabric(this);
541
523
  this.schemaRoutes = new SchemaRoutes(this);
542
524
  this.javascriptTranslator = new JavascriptTranslator(this);
543
- this.config.componentTypeNameResolver.logger = this.logger;
544
525
  }
545
526
 
546
527
  async start() {
@@ -563,7 +544,7 @@ declare class CodeGenProcess {
563
544
  this.schemaWalker.addSchema("$usage", swagger.usageSchema);
564
545
  this.schemaWalker.addSchema("$original", swagger.originalSchema);
565
546
 
566
- this.logger.event("start generating your typescript api");
547
+ consola.info("start generating your typescript api");
567
548
 
568
549
  this.config.update(
569
550
  this.config.hooks.onInit(this.config, this) || this.config,
@@ -628,11 +609,11 @@ declare class CodeGenProcess {
628
609
 
629
610
  if (this.fileSystem.pathIsExist(this.config.output)) {
630
611
  if (this.config.cleanOutput) {
631
- this.logger.debug(`cleaning dir ${this.config.output}`);
612
+ consola.debug("cleaning dir", this.config.output);
632
613
  this.fileSystem.cleanDir(this.config.output);
633
614
  }
634
615
  } else {
635
- this.logger.debug(
616
+ consola.debug(
636
617
  `path ${this.config.output} is not exist. creating dir by this path`,
637
618
  );
638
619
  this.fileSystem.createDir(this.config.output);
@@ -653,7 +634,7 @@ declare class CodeGenProcess {
653
634
  withPrefix: true,
654
635
  });
655
636
 
656
- this.logger.success(
637
+ consola.success(
657
638
  "api file",
658
639
  `"${file.fileName}${file.fileExtension}"`,
659
640
  `created in ${this.config.output}`,
@@ -978,7 +959,7 @@ declare class CodeGenProcess {
978
959
  const fileExtension = typescript.Extension.Ts;
979
960
 
980
961
  if (configuration.translateToJavaScript) {
981
- this.logger.debug("using js translator for", fileName);
962
+ consola.debug("using js translator for", fileName);
982
963
  return await this.javascriptTranslator.translate({
983
964
  fileName: fileName,
984
965
  fileExtension: fileExtension,
@@ -987,7 +968,7 @@ declare class CodeGenProcess {
987
968
  }
988
969
 
989
970
  if (configuration.customTranslator) {
990
- this.logger.debug("using custom translator for", fileName);
971
+ consola.debug("using custom translator for", fileName);
991
972
  return await configuration.customTranslator.translate({
992
973
  fileName: fileName,
993
974
  fileExtension: fileExtension,
@@ -995,7 +976,7 @@ declare class CodeGenProcess {
995
976
  });
996
977
  }
997
978
 
998
- this.logger.debug("generating output for", `${fileName}${fileExtension}`);
979
+ consola.debug("generating output for", `${fileName}${fileExtension}`);
999
980
 
1000
981
  return [
1001
982
  {
@@ -1240,7 +1221,6 @@ interface GenerateApiParamsBase {
1240
1221
  * translate({ fileName, fileExtension, fileContent }) {
1241
1222
  * this.codeFormatter.format()
1242
1223
  * this.config.
1243
- * this.logger.
1244
1224
  *
1245
1225
  * return [
1246
1226
  * {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "13.0.21",
3
+ "version": "13.0.22",
4
4
  "description": "Generate the API client for Fetch or Axios from an OpenAPI Specification",
5
5
  "homepage": "https://github.com/acacode/swagger-typescript-api",
6
6
  "bugs": "https://github.com/acacode/swagger-typescript-api/issues",
@@ -47,13 +47,13 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@types/swagger-schema-official": "^2.0.25",
50
+ "consola": "^3.2.3",
50
51
  "cosmiconfig": "^9.0.0",
51
52
  "didyoumean": "^1.2.2",
52
53
  "eta": "^2.2.0",
53
54
  "js-yaml": "^4.1.0",
54
55
  "lodash": "^4.17.21",
55
56
  "nanoid": "^3.3.7",
56
- "node-emoji": "^2.1.3",
57
57
  "prettier": "~3.3.3",
58
58
  "swagger-schema-official": "2.0.0-bab6bed",
59
59
  "swagger2openapi": "^7.0.8",
@@ -66,14 +66,14 @@
66
66
  "@types/didyoumean": "1.2.2",
67
67
  "@types/js-yaml": "4.0.9",
68
68
  "@types/lodash": "4.17.7",
69
- "@types/node": "22.2.0",
69
+ "@types/node": "22.5.0",
70
70
  "@types/swagger2openapi": "7.0.4",
71
- "axios": "1.7.3",
71
+ "axios": "1.7.5",
72
72
  "shx": "0.3.4",
73
73
  "tsup": "8.2.4",
74
74
  "vitest": "2.0.5"
75
75
  },
76
- "packageManager": "yarn@4.4.0",
76
+ "packageManager": "yarn@4.4.1",
77
77
  "engines": {
78
78
  "node": ">=18.0.0"
79
79
  },