@kubb/core 1.0.3 → 1.1.1

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/README.md CHANGED
@@ -10,13 +10,13 @@
10
10
  <!-- Badges -->
11
11
  <p>
12
12
  <a href="https://www.npmjs.com/package/@kubb/core">
13
- <img alt="Npm version" src="https://img.shields.io/npm/v/@kubb/core?style=for-the-badge"/>
13
+ <img alt="npm version" src="https://img.shields.io/npm/v/@kubb/core?style=for-the-badge"/>
14
14
  </a>
15
15
  <a href="https://www.npmjs.com/package/@kubb/core">
16
- <img alt="Npm downloads" src="https://img.shields.io/bundlephobia/min/@kubb/core?style=for-the-badge"/>
16
+ <img alt="npm downloads" src="https://img.shields.io/bundlephobia/min/@kubb/core?style=for-the-badge"/>
17
17
  </a>
18
18
  <a href="https://www.npmjs.com/package/@kubb/core">
19
- <img alt="Npm downloads" src="https://img.shields.io/npm/dm/@kubb/core?style=for-the-badge"/>
19
+ <img alt="npm downloads" src="https://img.shields.io/npm/dm/@kubb/core?style=for-the-badge"/>
20
20
  </a>
21
21
  </p>
22
22
 
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 {
@@ -339,7 +343,7 @@ type KubbConfig = {
339
343
  hooks?: {
340
344
  /**
341
345
  * Hook that will be triggerend at the end of all executions.
342
- * Useful for running Prettier or Eslint to use your own linting structure.
346
+ * Useful for running Prettier or ESLint to use your own linting structure.
343
347
  */
344
348
  done?: string | string[];
345
349
  };
@@ -399,10 +403,10 @@ type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOptions> =
399
403
  */
400
404
  options?: TOptions['options'];
401
405
  } & Partial<PluginLifecycle<TOptions>>;
402
- type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, Api = any, resolvePathOptions = Record<string, any>> = {
406
+ type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, API = any, resolvePathOptions = Record<string, any>> = {
403
407
  options: Options;
404
408
  nested: Nested;
405
- api: Api;
409
+ api: API;
406
410
  resolvePathOptions: resolvePathOptions;
407
411
  };
408
412
  type PluginLifecycle<TOptions extends PluginFactoryOptions = PluginFactoryOptions> = {
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.3",
3
+ "version": "1.1.1",
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.3"
46
+ "@kubb/ts-codegen": "1.1.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsup": "^6.7.0",
package/src/types.ts CHANGED
@@ -74,7 +74,7 @@ export type KubbConfig = {
74
74
  hooks?: {
75
75
  /**
76
76
  * Hook that will be triggerend at the end of all executions.
77
- * Useful for running Prettier or Eslint to use your own linting structure.
77
+ * Useful for running Prettier or ESLint to use your own linting structure.
78
78
  */
79
79
  done?: string | string[]
80
80
  }
@@ -144,10 +144,10 @@ export type KubbPlugin<TOptions extends PluginFactoryOptions = PluginFactoryOpti
144
144
  } & Partial<PluginLifecycle<TOptions>>
145
145
 
146
146
  // use of type objects
147
- export type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, Api = any, resolvePathOptions = Record<string, any>> = {
147
+ export type PluginFactoryOptions<Options = unknown, Nested extends boolean = false, API = any, resolvePathOptions = Record<string, any>> = {
148
148
  options: Options
149
149
  nested: Nested
150
- api: Api
150
+ api: API
151
151
  resolvePathOptions: resolvePathOptions
152
152
  }
153
153
 
@@ -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