@kubb/core 1.0.2 → 1.1.0

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.cjs CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var module$1 = require('module');
6
6
  var pathParser2 = require('path');
7
7
  var fs = require('fs');
8
+ var changeCase = require('change-case');
8
9
  var rimraf = require('rimraf');
9
10
  var dirTree = require('directory-tree');
10
11
  var crypto = require('crypto');
@@ -130,15 +131,14 @@ function isURL(data) {
130
131
  }
131
132
  return false;
132
133
  }
133
-
134
- // src/utils/objectToParameters.ts
135
134
  function objectToParameters(data, options = {}) {
136
135
  const { typed } = options;
137
136
  return data.reduce((acc, [key, value]) => {
137
+ const parameterName = changeCase.camelCase(key, { delimiter: "", transform: changeCase.camelCaseTransformMerge });
138
138
  if (typed) {
139
- acc.push(`${key}: ${value}["${key}"]`);
139
+ acc.push(`${parameterName}: ${value}["${key}"]`);
140
140
  } else {
141
- acc.push(`${key}`);
141
+ acc.push(`${parameterName}`);
142
142
  }
143
143
  return acc;
144
144
  }, []).join(", ");
package/dist/index.d.ts CHANGED
@@ -24,6 +24,10 @@ type Data = string[][];
24
24
  type Options$2 = {
25
25
  typed?: boolean;
26
26
  };
27
+ /**
28
+ * Convert an string array to a string of parameters that can be used inside a function
29
+ * The parameter name is converted to `camelcase`
30
+ */
27
31
  declare function objectToParameters(data: Data, options?: Options$2): string;
28
32
 
29
33
  declare function nameSorter<T extends {
@@ -345,6 +349,8 @@ type KubbConfig = {
345
349
  };
346
350
  /**
347
351
  * Log level to report when using the CLI
352
+ * Under construction, only info is implemented.
353
+ * @default `silent`
348
354
  */
349
355
  logLevel?: LogLevel;
350
356
  };
@@ -487,7 +493,7 @@ type TransformResult = string | null;
487
493
  type Path = string;
488
494
  type OptionalPath = Path | null | undefined;
489
495
  type FileName = string | null | undefined;
490
- type LogType = 'error' | 'warn' | 'info';
496
+ type LogType = 'error' | 'info';
491
497
  type LogLevel = LogType | 'silent';
492
498
 
493
499
  type Logger = {
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createRequire } from 'module';
2
2
  import pathParser2 from 'node:path';
3
3
  import { promises } from 'node:fs';
4
+ import { camelCase, camelCaseTransformMerge } from 'change-case';
4
5
  import { rimraf } from 'rimraf';
5
6
  import dirTree from 'directory-tree';
6
7
  import crypto from 'node:crypto';
@@ -120,15 +121,14 @@ function isURL(data) {
120
121
  }
121
122
  return false;
122
123
  }
123
-
124
- // src/utils/objectToParameters.ts
125
124
  function objectToParameters(data, options = {}) {
126
125
  const { typed } = options;
127
126
  return data.reduce((acc, [key, value]) => {
127
+ const parameterName = camelCase(key, { delimiter: "", transform: camelCaseTransformMerge });
128
128
  if (typed) {
129
- acc.push(`${key}: ${value}["${key}"]`);
129
+ acc.push(`${parameterName}: ${value}["${key}"]`);
130
130
  } else {
131
- acc.push(`${key}`);
131
+ acc.push(`${parameterName}`);
132
132
  }
133
133
  return acc;
134
134
  }, []).join(", ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Generator core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,7 +43,7 @@
43
43
  "change-case": "^4.1.2",
44
44
  "directory-tree": "^3.5.1",
45
45
  "rimraf": "^5.0.1",
46
- "@kubb/ts-codegen": "1.0.2"
46
+ "@kubb/ts-codegen": "1.1.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsup": "^6.7.0",
package/src/types.ts CHANGED
@@ -80,6 +80,8 @@ export type KubbConfig = {
80
80
  }
81
81
  /**
82
82
  * Log level to report when using the CLI
83
+ * Under construction, only info is implemented.
84
+ * @default `silent`
83
85
  */
84
86
  logLevel?: LogLevel
85
87
  }
@@ -241,5 +243,5 @@ export type Path = string
241
243
  export type OptionalPath = Path | null | undefined
242
244
  export type FileName = string | null | undefined
243
245
 
244
- export type LogType = 'error' | 'warn' | 'info'
246
+ export type LogType = 'error' | 'info'
245
247
  export type LogLevel = LogType | 'silent'
@@ -1,18 +1,25 @@
1
+ import { camelCase, camelCaseTransformMerge } from 'change-case'
2
+
1
3
  type Data = string[][]
2
4
 
3
5
  type Options = {
4
6
  typed?: boolean
5
7
  }
6
-
8
+ /**
9
+ * Convert an string array to a string of parameters that can be used inside a function
10
+ * The parameter name is converted to `camelcase`
11
+ */
7
12
  export function objectToParameters(data: Data, options: Options = {}) {
8
13
  const { typed } = options
9
14
 
10
15
  return data
11
16
  .reduce((acc, [key, value]) => {
17
+ const parameterName = camelCase(key, { delimiter: '', transform: camelCaseTransformMerge })
18
+
12
19
  if (typed) {
13
- acc.push(`${key}: ${value}["${key}"]`)
20
+ acc.push(`${parameterName}: ${value}["${key}"]`)
14
21
  } else {
15
- acc.push(`${key}`)
22
+ acc.push(`${parameterName}`)
16
23
  }
17
24
 
18
25
  return acc