@kubb/core 1.10.0-canary.20231007T144632 → 1.10.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/dist/index.cjs +62 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -14
- package/dist/index.d.ts +29 -14
- package/dist/index.js +60 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { Ora } from 'ora';
|
|
2
1
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
2
|
+
import { Ora } from 'ora';
|
|
3
3
|
export { default as pc } from 'picocolors';
|
|
4
4
|
|
|
5
|
-
type LogType = 'error' | 'info' | 'warning';
|
|
6
|
-
type Logger = {
|
|
7
|
-
log: (message: string | null) => void;
|
|
8
|
-
error: (message: string | null) => void;
|
|
9
|
-
info: (message: string | null) => void;
|
|
10
|
-
warn: (message: string | null) => void;
|
|
11
|
-
spinner?: Ora;
|
|
12
|
-
logs: string[];
|
|
13
|
-
};
|
|
14
|
-
declare function createLogger(spinner?: Ora): Logger;
|
|
15
|
-
|
|
16
5
|
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
17
6
|
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
18
7
|
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
@@ -150,10 +139,30 @@ declare class Warning extends Error {
|
|
|
150
139
|
});
|
|
151
140
|
}
|
|
152
141
|
|
|
142
|
+
type LogType = 'error' | 'info' | 'warning';
|
|
143
|
+
type Logger = {
|
|
144
|
+
log: (message: string | null) => void;
|
|
145
|
+
error: (message: string | null) => void;
|
|
146
|
+
info: (message: string | null) => void;
|
|
147
|
+
warn: (message: string | null) => void;
|
|
148
|
+
spinner?: Ora;
|
|
149
|
+
logs: string[];
|
|
150
|
+
};
|
|
151
|
+
declare function createLogger(spinner?: Ora): Logger;
|
|
152
|
+
|
|
153
153
|
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
154
154
|
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
155
155
|
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
156
156
|
|
|
157
|
+
type URLObject = {
|
|
158
|
+
url: string;
|
|
159
|
+
params?: Record<string, string>;
|
|
160
|
+
};
|
|
161
|
+
type ObjectOptions = {
|
|
162
|
+
type?: 'path' | 'template';
|
|
163
|
+
replacer?: (pathParam: string) => string;
|
|
164
|
+
stringify?: boolean;
|
|
165
|
+
};
|
|
157
166
|
declare class URLPath {
|
|
158
167
|
path: string;
|
|
159
168
|
constructor(path: string);
|
|
@@ -170,26 +179,32 @@ declare class URLPath {
|
|
|
170
179
|
* @example /account/userID => `/account/${userId}`
|
|
171
180
|
*/
|
|
172
181
|
get template(): string;
|
|
182
|
+
get object(): URLObject | string;
|
|
183
|
+
get params(): Record<string, string> | undefined;
|
|
184
|
+
toObject(options?: ObjectOptions): URLObject | string;
|
|
173
185
|
/**
|
|
174
186
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
175
187
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
176
188
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
177
189
|
* @example /account/userID => `/account/${userId}`
|
|
178
190
|
*/
|
|
179
|
-
toTemplateString(): string;
|
|
191
|
+
toTemplateString(replacer?: (pathParam: string) => string): string;
|
|
180
192
|
/**
|
|
181
193
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
182
194
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
183
195
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
184
196
|
* @example /account/userID => `/account/${userId}`
|
|
185
197
|
*/
|
|
186
|
-
static toTemplateString(path: string): string;
|
|
198
|
+
static toTemplateString(path: string, replacer?: (pathParam: string) => string): string;
|
|
199
|
+
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
200
|
+
static getParams(path: string, replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
187
201
|
/**
|
|
188
202
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
189
203
|
* @example /pet/{petId} => /pet/:petId
|
|
190
204
|
*/
|
|
191
205
|
toURLPath(): string;
|
|
192
206
|
static toURLPath(path: string): string;
|
|
207
|
+
static toObject(path: string, { type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
193
208
|
static isURL(path: string): boolean;
|
|
194
209
|
}
|
|
195
210
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { Ora } from 'ora';
|
|
2
1
|
import { DirectoryTreeOptions } from 'directory-tree';
|
|
2
|
+
import { Ora } from 'ora';
|
|
3
3
|
export { default as pc } from 'picocolors';
|
|
4
4
|
|
|
5
|
-
type LogType = 'error' | 'info' | 'warning';
|
|
6
|
-
type Logger = {
|
|
7
|
-
log: (message: string | null) => void;
|
|
8
|
-
error: (message: string | null) => void;
|
|
9
|
-
info: (message: string | null) => void;
|
|
10
|
-
warn: (message: string | null) => void;
|
|
11
|
-
spinner?: Ora;
|
|
12
|
-
logs: string[];
|
|
13
|
-
};
|
|
14
|
-
declare function createLogger(spinner?: Ora): Logger;
|
|
15
|
-
|
|
16
5
|
declare function isPromise<T>(result: PossiblePromise<T>): result is Promise<T>;
|
|
17
6
|
declare function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T>;
|
|
18
7
|
declare function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & {
|
|
@@ -150,10 +139,30 @@ declare class Warning extends Error {
|
|
|
150
139
|
});
|
|
151
140
|
}
|
|
152
141
|
|
|
142
|
+
type LogType = 'error' | 'info' | 'warning';
|
|
143
|
+
type Logger = {
|
|
144
|
+
log: (message: string | null) => void;
|
|
145
|
+
error: (message: string | null) => void;
|
|
146
|
+
info: (message: string | null) => void;
|
|
147
|
+
warn: (message: string | null) => void;
|
|
148
|
+
spinner?: Ora;
|
|
149
|
+
logs: string[];
|
|
150
|
+
};
|
|
151
|
+
declare function createLogger(spinner?: Ora): Logger;
|
|
152
|
+
|
|
153
153
|
declare const defaultColours: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"];
|
|
154
154
|
declare function randomColour(text?: string, colours?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
155
155
|
declare function randomPicoColour(text?: string, colors?: readonly ["black", "blue", "darkBlue", "cyan", "gray", "green", "darkGreen", "magenta", "red", "darkRed", "yellow", "darkYellow"]): string;
|
|
156
156
|
|
|
157
|
+
type URLObject = {
|
|
158
|
+
url: string;
|
|
159
|
+
params?: Record<string, string>;
|
|
160
|
+
};
|
|
161
|
+
type ObjectOptions = {
|
|
162
|
+
type?: 'path' | 'template';
|
|
163
|
+
replacer?: (pathParam: string) => string;
|
|
164
|
+
stringify?: boolean;
|
|
165
|
+
};
|
|
157
166
|
declare class URLPath {
|
|
158
167
|
path: string;
|
|
159
168
|
constructor(path: string);
|
|
@@ -170,26 +179,32 @@ declare class URLPath {
|
|
|
170
179
|
* @example /account/userID => `/account/${userId}`
|
|
171
180
|
*/
|
|
172
181
|
get template(): string;
|
|
182
|
+
get object(): URLObject | string;
|
|
183
|
+
get params(): Record<string, string> | undefined;
|
|
184
|
+
toObject(options?: ObjectOptions): URLObject | string;
|
|
173
185
|
/**
|
|
174
186
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
175
187
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
176
188
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
177
189
|
* @example /account/userID => `/account/${userId}`
|
|
178
190
|
*/
|
|
179
|
-
toTemplateString(): string;
|
|
191
|
+
toTemplateString(replacer?: (pathParam: string) => string): string;
|
|
180
192
|
/**
|
|
181
193
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
182
194
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
183
195
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
184
196
|
* @example /account/userID => `/account/${userId}`
|
|
185
197
|
*/
|
|
186
|
-
static toTemplateString(path: string): string;
|
|
198
|
+
static toTemplateString(path: string, replacer?: (pathParam: string) => string): string;
|
|
199
|
+
getParams(replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
200
|
+
static getParams(path: string, replacer?: (pathParam: string) => string): Record<string, string> | undefined;
|
|
187
201
|
/**
|
|
188
202
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
189
203
|
* @example /pet/{petId} => /pet/:petId
|
|
190
204
|
*/
|
|
191
205
|
toURLPath(): string;
|
|
192
206
|
static toURLPath(path: string): string;
|
|
207
|
+
static toObject(path: string, { type, replacer, stringify }?: ObjectOptions): URLObject | string;
|
|
193
208
|
static isURL(path: string): boolean;
|
|
194
209
|
}
|
|
195
210
|
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
+
import pc3 from 'picocolors';
|
|
3
|
+
export { default as pc } from 'picocolors';
|
|
2
4
|
import crypto from 'node:crypto';
|
|
3
|
-
import fs, { remove } from 'fs-extra';
|
|
4
5
|
import pathParser2 from 'node:path';
|
|
6
|
+
import fs, { remove } from 'fs-extra';
|
|
5
7
|
import { switcher } from 'js-runtime';
|
|
6
8
|
import { camelCase, camelCaseTransformMerge } from 'change-case';
|
|
7
9
|
import { orderBy } from 'natural-orderby';
|
|
8
10
|
import { performance } from 'node:perf_hooks';
|
|
9
11
|
import dirTree from 'directory-tree';
|
|
10
12
|
import mod from 'node:module';
|
|
11
|
-
import { pathToFileURL } from 'node:url';
|
|
12
13
|
import os from 'node:os';
|
|
13
|
-
import
|
|
14
|
-
export { default as pc } from 'picocolors';
|
|
14
|
+
import { pathToFileURL } from 'node:url';
|
|
15
15
|
import seedrandom from 'seedrandom';
|
|
16
16
|
import { createImportDeclaration, print, createExportDeclaration } from '@kubb/ts-codegen';
|
|
17
17
|
import isEqual from 'lodash.isequal';
|
|
@@ -635,14 +635,23 @@ var URLPath = class _URLPath {
|
|
|
635
635
|
get template() {
|
|
636
636
|
return this.toTemplateString();
|
|
637
637
|
}
|
|
638
|
+
get object() {
|
|
639
|
+
return this.toObject();
|
|
640
|
+
}
|
|
641
|
+
get params() {
|
|
642
|
+
return this.getParams();
|
|
643
|
+
}
|
|
644
|
+
toObject(options = {}) {
|
|
645
|
+
return _URLPath.toObject(this.path, options);
|
|
646
|
+
}
|
|
638
647
|
/**
|
|
639
648
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
640
649
|
* @example /pet/{petId} => `/pet/${petId}`
|
|
641
650
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
642
651
|
* @example /account/userID => `/account/${userId}`
|
|
643
652
|
*/
|
|
644
|
-
toTemplateString() {
|
|
645
|
-
return _URLPath.toTemplateString(this.path);
|
|
653
|
+
toTemplateString(replacer) {
|
|
654
|
+
return _URLPath.toTemplateString(this.path, replacer);
|
|
646
655
|
}
|
|
647
656
|
/**
|
|
648
657
|
* Convert Swagger path to template literals/ template strings(camelcase)
|
|
@@ -650,18 +659,36 @@ var URLPath = class _URLPath {
|
|
|
650
659
|
* @example /account/monetary-accountID => `/account/${monetaryAccountId}`
|
|
651
660
|
* @example /account/userID => `/account/${userId}`
|
|
652
661
|
*/
|
|
653
|
-
static toTemplateString(path) {
|
|
662
|
+
static toTemplateString(path, replacer) {
|
|
654
663
|
const regex = /{(\w|-)*}/g;
|
|
655
664
|
const found = path.match(regex);
|
|
656
665
|
let newPath = path.replaceAll("{", "${");
|
|
657
666
|
if (found) {
|
|
658
667
|
newPath = found.reduce((prev, curr) => {
|
|
659
|
-
const
|
|
668
|
+
const pathParam = replacer ? replacer(camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(curr, { delimiter: "", transform: camelCaseTransformMerge });
|
|
669
|
+
const replacement = `\${${pathParam}}`;
|
|
660
670
|
return prev.replace(curr, replacement);
|
|
661
671
|
}, path);
|
|
662
672
|
}
|
|
663
673
|
return `\`${newPath}\``;
|
|
664
674
|
}
|
|
675
|
+
getParams(replacer) {
|
|
676
|
+
return _URLPath.getParams(this.path, replacer);
|
|
677
|
+
}
|
|
678
|
+
static getParams(path, replacer) {
|
|
679
|
+
const regex = /{(\w|-)*}/g;
|
|
680
|
+
const found = path.match(regex);
|
|
681
|
+
if (!found) {
|
|
682
|
+
return void 0;
|
|
683
|
+
}
|
|
684
|
+
const params = {};
|
|
685
|
+
found.forEach((item) => {
|
|
686
|
+
item = item.replaceAll("{", "").replaceAll("}", "");
|
|
687
|
+
const pathParam = replacer ? replacer(camelCase(item, { delimiter: "", transform: camelCaseTransformMerge })) : camelCase(item, { delimiter: "", transform: camelCaseTransformMerge });
|
|
688
|
+
params[pathParam] = pathParam;
|
|
689
|
+
}, path);
|
|
690
|
+
return params;
|
|
691
|
+
}
|
|
665
692
|
/**
|
|
666
693
|
* Convert Swagger path to URLPath(syntax of Express)
|
|
667
694
|
* @example /pet/{petId} => /pet/:petId
|
|
@@ -672,6 +699,19 @@ var URLPath = class _URLPath {
|
|
|
672
699
|
static toURLPath(path) {
|
|
673
700
|
return path.replaceAll("{", ":").replaceAll("}", "");
|
|
674
701
|
}
|
|
702
|
+
static toObject(path, { type = "path", replacer, stringify } = {}) {
|
|
703
|
+
const object = {
|
|
704
|
+
url: type === "path" ? _URLPath.toURLPath(path) : _URLPath.toTemplateString(path, replacer),
|
|
705
|
+
params: _URLPath.getParams(path)
|
|
706
|
+
};
|
|
707
|
+
if (stringify) {
|
|
708
|
+
if (type !== "template") {
|
|
709
|
+
throw new Error("Type should be `template` when using stringiyf");
|
|
710
|
+
}
|
|
711
|
+
return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
712
|
+
}
|
|
713
|
+
return object;
|
|
714
|
+
}
|
|
675
715
|
static isURL(path) {
|
|
676
716
|
try {
|
|
677
717
|
const url = new URL(path);
|
|
@@ -1027,6 +1067,18 @@ var definePlugin = createPlugin((options) => {
|
|
|
1027
1067
|
}
|
|
1028
1068
|
};
|
|
1029
1069
|
});
|
|
1070
|
+
var EventEmitter = class {
|
|
1071
|
+
emitter = new EventEmitter$1();
|
|
1072
|
+
emit(eventName, ...eventArg) {
|
|
1073
|
+
this.emitter.emit(eventName, ...eventArg);
|
|
1074
|
+
}
|
|
1075
|
+
on(eventName, handler) {
|
|
1076
|
+
this.emitter.on(eventName, handler);
|
|
1077
|
+
}
|
|
1078
|
+
off(eventName, handler) {
|
|
1079
|
+
this.emitter.off(eventName, handler);
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1030
1082
|
|
|
1031
1083
|
// src/managers/pluginManager/ParallelPluginError.ts
|
|
1032
1084
|
var ParallelPluginError = class extends Error {
|
|
@@ -1065,18 +1117,6 @@ var PluginError = class extends Error {
|
|
|
1065
1117
|
this.pluginManager = options.pluginManager;
|
|
1066
1118
|
}
|
|
1067
1119
|
};
|
|
1068
|
-
var EventEmitter = class {
|
|
1069
|
-
emitter = new EventEmitter$1();
|
|
1070
|
-
emit(eventName, ...eventArg) {
|
|
1071
|
-
this.emitter.emit(eventName, ...eventArg);
|
|
1072
|
-
}
|
|
1073
|
-
on(eventName, handler) {
|
|
1074
|
-
this.emitter.on(eventName, handler);
|
|
1075
|
-
}
|
|
1076
|
-
off(eventName, handler) {
|
|
1077
|
-
this.emitter.off(eventName, handler);
|
|
1078
|
-
}
|
|
1079
|
-
};
|
|
1080
1120
|
|
|
1081
1121
|
// src/managers/pluginManager/pluginParser.ts
|
|
1082
1122
|
function pluginParser(plugin, context) {
|