@goast/core 0.1.0 → 0.2.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/cjs/index.js +1 -0
- package/cjs/lib/ast/index.js +4 -0
- package/cjs/lib/ast/node.js +27 -0
- package/cjs/lib/parse/deref-proxy.js +9 -3
- package/cjs/lib/parse/parser.js +1 -1
- package/cjs/lib/transform/transform-endpoint.js +1 -1
- package/cjs/lib/transform/transform-schema.js +10 -5
- package/cjs/lib/utils/array.utils.js +11 -0
- package/cjs/lib/utils/class.utils.js +33 -0
- package/cjs/lib/utils/common.utils.js +75 -1
- package/cjs/lib/utils/error.utils.js +7 -0
- package/cjs/lib/utils/index.js +4 -0
- package/cjs/lib/utils/object.utils.js +6 -2
- package/cjs/lib/utils/schema.utils.js +2 -1
- package/cjs/lib/utils/source-builder.js +171 -81
- package/cjs/lib/utils/string-builder/index.js +8 -0
- package/cjs/lib/utils/string-builder/options.js +7 -0
- package/cjs/lib/utils/string-builder/string-builder.js +142 -0
- package/cjs/lib/utils/string-builder/utils.js +38 -0
- package/cjs/lib/utils/string.utils.js +123 -107
- package/cjs/lib/utils/type.utils.js +9 -0
- package/esm/index.js +1 -0
- package/esm/lib/ast/index.js +1 -0
- package/esm/lib/ast/node.js +23 -0
- package/esm/lib/parse/deref-proxy.js +9 -3
- package/esm/lib/parse/parser.js +1 -1
- package/esm/lib/transform/transform-endpoint.js +1 -1
- package/esm/lib/transform/transform-schema.js +10 -5
- package/esm/lib/utils/array.utils.js +7 -0
- package/esm/lib/utils/class.utils.js +27 -0
- package/esm/lib/utils/common.utils.js +64 -0
- package/esm/lib/utils/error.utils.js +3 -0
- package/esm/lib/utils/index.js +4 -0
- package/esm/lib/utils/object.utils.js +6 -2
- package/esm/lib/utils/schema.utils.js +2 -1
- package/esm/lib/utils/source-builder.js +170 -80
- package/esm/lib/utils/string-builder/index.js +3 -0
- package/esm/lib/utils/string-builder/options.js +4 -0
- package/esm/lib/utils/string-builder/string-builder.js +138 -0
- package/esm/lib/utils/string-builder/utils.js +30 -0
- package/esm/lib/utils/string.utils.js +111 -105
- package/esm/lib/utils/type.utils.js +6 -1
- package/package.json +5 -5
- package/types/index.d.ts +1 -0
- package/types/lib/ast/index.d.ts +1 -0
- package/types/lib/ast/node.d.ts +14 -0
- package/types/lib/transform/api-types.d.ts +3 -1
- package/types/lib/utils/array.utils.d.ts +1 -0
- package/types/lib/utils/class.utils.d.ts +7 -0
- package/types/lib/utils/common.utils.d.ts +14 -2
- package/types/lib/utils/error.utils.d.ts +1 -0
- package/types/lib/utils/index.d.ts +4 -0
- package/types/lib/utils/object.utils.d.ts +1 -1
- package/types/lib/utils/source-builder.d.ts +55 -37
- package/types/lib/utils/string-builder/index.d.ts +3 -0
- package/types/lib/utils/string-builder/options.d.ts +8 -0
- package/types/lib/utils/string-builder/string-builder.d.ts +72 -0
- package/types/lib/utils/string-builder/utils.d.ts +21 -0
- package/types/lib/utils/string.utils.d.ts +20 -66
- package/types/lib/utils/type.utils.d.ts +43 -1
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const os_1 = require("os");
|
|
3
|
+
exports.removeStr = exports.trim = exports.trimStart = exports.trimEnd = exports.trimIndent = exports.spliceString = exports.escapeRegExp = exports.toCustomCase = exports.toSnakeCase = exports.toKebabCase = exports.toPascalCase = exports.toCamelCase = exports.toCasing = exports.wordToCasing = exports.getWords = exports.uncapitalize = exports.capitalize = exports.uppercase = exports.lowercase = exports.adjustCasing = void 0;
|
|
5
4
|
const common_utils_1 = require("./common.utils");
|
|
5
|
+
function adjustCasing(a, b) {
|
|
6
|
+
if (typeof a === 'string') {
|
|
7
|
+
if (typeof b === 'string') {
|
|
8
|
+
return b;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return Object.assign({ casing: a }, b);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else if (typeof b === 'string') {
|
|
15
|
+
return Object.assign(Object.assign({}, a), { casing: b });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return Object.assign(Object.assign({}, a), b);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.adjustCasing = adjustCasing;
|
|
22
|
+
function lowercase(str) {
|
|
23
|
+
return str.toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
exports.lowercase = lowercase;
|
|
26
|
+
function uppercase(str) {
|
|
27
|
+
return str.toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
exports.uppercase = uppercase;
|
|
30
|
+
function capitalize(str) {
|
|
31
|
+
return (str.charAt(0).toUpperCase() + str.slice(1));
|
|
32
|
+
}
|
|
33
|
+
exports.capitalize = capitalize;
|
|
34
|
+
function uncapitalize(str) {
|
|
35
|
+
return (str.charAt(0).toLowerCase() + str.slice(1));
|
|
36
|
+
}
|
|
37
|
+
exports.uncapitalize = uncapitalize;
|
|
6
38
|
/**
|
|
7
39
|
* Gets the words from a string. Words are separated by capital letters. Leading numbers are removed. Non-alphanumerical characters are removed and interpreted as word seperators. Multiple uppercase letters are interpreted as one word.
|
|
8
40
|
* @param str The string to get the words from.
|
|
@@ -230,112 +262,96 @@ function escapeRegExp(str) {
|
|
|
230
262
|
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
231
263
|
}
|
|
232
264
|
exports.escapeRegExp = escapeRegExp;
|
|
233
|
-
exports.defaultStringBuilderOptions = {
|
|
234
|
-
newLine: os_1.EOL,
|
|
235
|
-
};
|
|
236
265
|
/**
|
|
237
|
-
*
|
|
266
|
+
* Removes characters from a string and, if necessary, inserts new characters in their place, returning the spliced string.
|
|
267
|
+
* @param str The string to splice.
|
|
268
|
+
* @param start The index at which to start changing the string.
|
|
269
|
+
* @param deleteCount The number of characters to remove.
|
|
270
|
+
* @param insert The string to insert.
|
|
271
|
+
* @returns The spliced string.
|
|
238
272
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
* Prepends one or more strings to the beginning of the current StringBuilder, followed by a line terminator.
|
|
321
|
-
* @param value The string(s) to prepend.
|
|
322
|
-
* @returns The current StringBuilder.
|
|
323
|
-
*/
|
|
324
|
-
prependLine(...value) {
|
|
325
|
-
return this.prepend(...value, this._options.newLine);
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Converts the value of this instance to a string.
|
|
329
|
-
* @returns A string whose value is the same as this instance.
|
|
330
|
-
*/
|
|
331
|
-
toString() {
|
|
332
|
-
return this._str;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Removes all characters from the current StringBuilder.
|
|
336
|
-
*/
|
|
337
|
-
clear() {
|
|
338
|
-
this._str = '';
|
|
273
|
+
function spliceString(str, start, deleteCount, insert) {
|
|
274
|
+
return str.slice(0, start) + insert + str.slice(start + deleteCount);
|
|
275
|
+
}
|
|
276
|
+
exports.spliceString = spliceString;
|
|
277
|
+
/**
|
|
278
|
+
* Removes leading indentation based on the last line. Also removes the first line if it is empty.
|
|
279
|
+
* @param str The string to trim.
|
|
280
|
+
*/
|
|
281
|
+
function trimIndent(str) {
|
|
282
|
+
var _a, _b;
|
|
283
|
+
const indent = (_b = (_a = str.match(/\n( *).*$/)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
284
|
+
if (indent.length === 0)
|
|
285
|
+
return str;
|
|
286
|
+
return str.replace(/^\r?\n/, '').replace(new RegExp(`^ {0,${indent.length}}`, 'gm'), '');
|
|
287
|
+
}
|
|
288
|
+
exports.trimIndent = trimIndent;
|
|
289
|
+
function isNonLineBreakWhitespaceChar(char) {
|
|
290
|
+
return (char === ' ' ||
|
|
291
|
+
char === '\t' ||
|
|
292
|
+
char === '\f' ||
|
|
293
|
+
char === '\v' ||
|
|
294
|
+
char === '\u00a0' ||
|
|
295
|
+
char === '\u1680' ||
|
|
296
|
+
char === '\u2000' ||
|
|
297
|
+
char === '\u2001' ||
|
|
298
|
+
char === '\u2002' ||
|
|
299
|
+
char === '\u2003' ||
|
|
300
|
+
char === '\u2004' ||
|
|
301
|
+
char === '\u2005' ||
|
|
302
|
+
char === '\u2006' ||
|
|
303
|
+
char === '\u2007' ||
|
|
304
|
+
char === '\u2008' ||
|
|
305
|
+
char === '\u2009' ||
|
|
306
|
+
char === '\u200a' ||
|
|
307
|
+
char === '\u2028' ||
|
|
308
|
+
char === '\u2029' ||
|
|
309
|
+
char === '\u202f' ||
|
|
310
|
+
char === '\u205f' ||
|
|
311
|
+
char === '\u3000' ||
|
|
312
|
+
char === '\ufeff');
|
|
313
|
+
}
|
|
314
|
+
function trimEnd(str, includeNewLine = true) {
|
|
315
|
+
if (includeNewLine)
|
|
316
|
+
return str.trimEnd();
|
|
317
|
+
let i = str.length;
|
|
318
|
+
for (; isNonLineBreakWhitespaceChar(str[i - 1]); i--)
|
|
319
|
+
;
|
|
320
|
+
return str.substring(0, i);
|
|
321
|
+
}
|
|
322
|
+
exports.trimEnd = trimEnd;
|
|
323
|
+
function trimStart(str, includeNewLine = true) {
|
|
324
|
+
if (includeNewLine)
|
|
325
|
+
return str.trimStart();
|
|
326
|
+
let i = 0;
|
|
327
|
+
for (; isNonLineBreakWhitespaceChar(str[i]); i++)
|
|
328
|
+
;
|
|
329
|
+
return str.substring(i);
|
|
330
|
+
}
|
|
331
|
+
exports.trimStart = trimStart;
|
|
332
|
+
function trim(str, includeNewLine = true) {
|
|
333
|
+
if (includeNewLine)
|
|
334
|
+
return str.trim();
|
|
335
|
+
let s = 0;
|
|
336
|
+
for (; isNonLineBreakWhitespaceChar(str[s]); s++)
|
|
337
|
+
;
|
|
338
|
+
let e = str.length;
|
|
339
|
+
for (; isNonLineBreakWhitespaceChar(str[e - 1]); e--)
|
|
340
|
+
;
|
|
341
|
+
return str.substring(s, e);
|
|
342
|
+
}
|
|
343
|
+
exports.trim = trim;
|
|
344
|
+
function removeStr(str, rem) {
|
|
345
|
+
let i = str.indexOf(rem);
|
|
346
|
+
if (i === -1)
|
|
347
|
+
return str;
|
|
348
|
+
let result = '';
|
|
349
|
+
let s = 0;
|
|
350
|
+
while (i !== -1) {
|
|
351
|
+
result += str.substring(s, i);
|
|
352
|
+
s = i + rem.length;
|
|
353
|
+
i = str.indexOf(rem, s);
|
|
339
354
|
}
|
|
355
|
+
return result + str.substring(s);
|
|
340
356
|
}
|
|
341
|
-
exports.
|
|
357
|
+
exports.removeStr = removeStr;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.suggestionsAsString = exports.stringUnionToArray = void 0;
|
|
4
|
+
function stringUnionToArray() {
|
|
5
|
+
return (...elements) => elements;
|
|
6
|
+
}
|
|
7
|
+
exports.stringUnionToArray = stringUnionToArray;
|
|
8
|
+
function suggestionsAsString(value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
exports.suggestionsAsString = suggestionsAsString;
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './node';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const NODE_HISTORY_SYMBOL = Symbol('node-history');
|
|
2
|
+
export class AstNode {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
var _a;
|
|
5
|
+
this.inject = (_a = options.inject) !== null && _a !== void 0 ? _a : {};
|
|
6
|
+
}
|
|
7
|
+
write(builder) {
|
|
8
|
+
let history = builder[NODE_HISTORY_SYMBOL];
|
|
9
|
+
if (!history) {
|
|
10
|
+
history = [];
|
|
11
|
+
builder[NODE_HISTORY_SYMBOL] = history;
|
|
12
|
+
}
|
|
13
|
+
history.push(this);
|
|
14
|
+
builder.append(this.inject.before);
|
|
15
|
+
this.onWrite(builder);
|
|
16
|
+
builder.append(this.inject.after);
|
|
17
|
+
history.pop();
|
|
18
|
+
}
|
|
19
|
+
getParentNode(builder) {
|
|
20
|
+
const history = builder[NODE_HISTORY_SYMBOL];
|
|
21
|
+
return history === null || history === void 0 ? void 0 : history.at(-2);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -10,16 +10,22 @@ class DerefProxyHandler {
|
|
|
10
10
|
this._overwrittenValues = {};
|
|
11
11
|
}
|
|
12
12
|
get(target, prop) {
|
|
13
|
-
var _a
|
|
13
|
+
var _a;
|
|
14
14
|
if (prop === '$ref') {
|
|
15
15
|
return this._ref;
|
|
16
16
|
}
|
|
17
17
|
else if (prop === '$src') {
|
|
18
18
|
return this._source;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
if (this._overwrittenValues[prop] !== undefined) {
|
|
21
|
+
return this._overwrittenValues[prop];
|
|
22
|
+
}
|
|
23
|
+
if (target[prop] !== undefined) {
|
|
24
|
+
return target[prop];
|
|
25
|
+
}
|
|
26
|
+
return propertiesNotDerivedFromRef.includes(prop)
|
|
21
27
|
? undefined
|
|
22
|
-
: (
|
|
28
|
+
: (_a = this._ref) === null || _a === void 0 ? void 0 : _a[prop];
|
|
23
29
|
}
|
|
24
30
|
set(target, prop, value) {
|
|
25
31
|
if (prop === '$ref' && (typeof value === 'object' || typeof value === 'undefined')) {
|
package/esm/lib/parse/parser.js
CHANGED
|
@@ -53,7 +53,7 @@ export class OpenApiParser {
|
|
|
53
53
|
});
|
|
54
54
|
existingDocument.dereferencedComponents.set(path, result);
|
|
55
55
|
if (value.$ref) {
|
|
56
|
-
result.$ref = yield this.resolveReference(file, value);
|
|
56
|
+
result.$ref = (yield this.resolveReference(file, value));
|
|
57
57
|
}
|
|
58
58
|
for (const key of Object.keys(value)) {
|
|
59
59
|
if (key === '$ref')
|
|
@@ -141,7 +141,7 @@ function transformResponse(context, response, status) {
|
|
|
141
141
|
$src: Object.assign(Object.assign({}, response.$src), { component: response }),
|
|
142
142
|
$ref: ref,
|
|
143
143
|
id: context.idGenerator.generateId('response'),
|
|
144
|
-
statusCode: Number(status),
|
|
144
|
+
statusCode: Number(status) || undefined,
|
|
145
145
|
description: response.description,
|
|
146
146
|
headers: transformHeaders(context, response.headers),
|
|
147
147
|
contentOptions: transformContent(context, response.content),
|
|
@@ -14,14 +14,14 @@ export function transformSchema(context, schema) {
|
|
|
14
14
|
if (existing)
|
|
15
15
|
return existing;
|
|
16
16
|
let kind = determineSchemaKind(schema);
|
|
17
|
-
let nullable =
|
|
17
|
+
let nullable = kind === 'null';
|
|
18
18
|
if (kind === 'multi-type') {
|
|
19
19
|
const types = schema.type;
|
|
20
20
|
let isSingleType = types.length === 1;
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
22
|
-
if (types.
|
|
22
|
+
if (types.includes('null') || types.includes(null)) {
|
|
23
23
|
nullable = true;
|
|
24
|
-
isSingleType =
|
|
24
|
+
isSingleType = types.length === 2;
|
|
25
25
|
}
|
|
26
26
|
if (isSingleType) {
|
|
27
27
|
const newType = types.filter((t) => t !== 'null' && t !== null)[0];
|
|
@@ -29,6 +29,9 @@ export function transformSchema(context, schema) {
|
|
|
29
29
|
schema.type = newType;
|
|
30
30
|
kind = determineSchemaKind(schema);
|
|
31
31
|
}
|
|
32
|
+
else {
|
|
33
|
+
schema.type = types.filter((t) => t !== 'null' && t !== null);
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
const id = context.idGenerator.generateId('schema');
|
|
34
37
|
const nameInfo = determineSchemaName(schema, id);
|
|
@@ -150,7 +153,9 @@ function resolveDescriminatorMapping(context, schema) {
|
|
|
150
153
|
for (const key of Object.keys(discriminator.mapping)) {
|
|
151
154
|
const mappedSchemaRef = discriminator.mapping[key];
|
|
152
155
|
const mappedSchema = transformSchema(context, mappedSchemaRef);
|
|
153
|
-
schema.discriminator
|
|
154
|
-
|
|
156
|
+
if (schema.discriminator) {
|
|
157
|
+
schema.discriminator.mapping[key] = mappedSchema;
|
|
158
|
+
mappedSchema.inheritedSchemas.push(schema);
|
|
159
|
+
}
|
|
155
160
|
}
|
|
156
161
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function classifyArray(items, classification) {
|
|
2
|
+
const result = { rest: [] };
|
|
3
|
+
for (const key in classification) {
|
|
4
|
+
result[key] = [];
|
|
5
|
+
}
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
let classified = false;
|
|
8
|
+
for (const key in classification) {
|
|
9
|
+
const type = classification[key];
|
|
10
|
+
if (item instanceof type) {
|
|
11
|
+
result[key].push(item);
|
|
12
|
+
classified = true;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!classified) {
|
|
17
|
+
result.rest.push(item);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
export function isInstanceOf(item, type) {
|
|
23
|
+
return item instanceof type;
|
|
24
|
+
}
|
|
25
|
+
export function getIsInstanceOf(type) {
|
|
26
|
+
return (item) => item instanceof type;
|
|
27
|
+
}
|
|
@@ -4,3 +4,67 @@ export function isNullish(value) {
|
|
|
4
4
|
export function notNullish(value) {
|
|
5
5
|
return !isNullish(value);
|
|
6
6
|
}
|
|
7
|
+
export function concatSingleOrMultiple(...values) {
|
|
8
|
+
if (values.length === 1) {
|
|
9
|
+
return values[0];
|
|
10
|
+
}
|
|
11
|
+
const result = [];
|
|
12
|
+
for (const value of values) {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
result.push(...value);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
result.push(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
export function isIterable(value) {
|
|
23
|
+
return typeof value === 'object' && value !== null && Symbol.iterator in value;
|
|
24
|
+
}
|
|
25
|
+
export function toArray(value) {
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
if (isIterable(value)) {
|
|
30
|
+
return Array.from(value);
|
|
31
|
+
}
|
|
32
|
+
return [value];
|
|
33
|
+
}
|
|
34
|
+
export function modify(value, callback) {
|
|
35
|
+
if (notNullish(value)) {
|
|
36
|
+
callback(value);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
export function run(value, callback) {
|
|
41
|
+
callback(value);
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
export function transform(value, callback) {
|
|
45
|
+
return callback(value);
|
|
46
|
+
}
|
|
47
|
+
export function modifyEach(values, callback) {
|
|
48
|
+
for (const value of values) {
|
|
49
|
+
if (notNullish(value)) {
|
|
50
|
+
callback(value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return values;
|
|
54
|
+
}
|
|
55
|
+
export function runEach(values, callback) {
|
|
56
|
+
for (const value of values) {
|
|
57
|
+
callback(value);
|
|
58
|
+
}
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
export function transformEach(values, callback) {
|
|
62
|
+
const result = [];
|
|
63
|
+
for (const value of values) {
|
|
64
|
+
result.push(callback(value));
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
export function asVoid(_) {
|
|
69
|
+
// Do nothing
|
|
70
|
+
}
|
package/esm/lib/utils/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
export * from './array.utils';
|
|
2
|
+
export * from './class.utils';
|
|
1
3
|
export * from './common.utils';
|
|
2
4
|
export * from './endpoint.utils';
|
|
5
|
+
export * from './error.utils';
|
|
3
6
|
export * from './factory';
|
|
4
7
|
export * from './generator.utils';
|
|
5
8
|
export * from './object.utils';
|
|
6
9
|
export * from './schema.utils';
|
|
7
10
|
export * from './source-builder';
|
|
11
|
+
export * from './string-builder';
|
|
8
12
|
export * from './string.utils';
|
|
9
13
|
export * from './string.utils.types';
|
|
10
14
|
export * from './type.utils';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
export function createOverwriteProxy(target) {
|
|
2
|
-
|
|
1
|
+
export function createOverwriteProxy(target, values) {
|
|
2
|
+
const proxy = new Proxy(target, new OverwriteProxyHandler());
|
|
3
|
+
if (values) {
|
|
4
|
+
Object.assign(proxy, values);
|
|
5
|
+
}
|
|
6
|
+
return proxy;
|
|
3
7
|
}
|
|
4
8
|
class OverwriteProxyHandler {
|
|
5
9
|
constructor() {
|
|
@@ -33,7 +33,8 @@ function collectSubSchemaProperties(subSchemas, properties, required, optional)
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
function hasInvalidSubSchema(subSchemas) {
|
|
36
|
-
return subSchemas.some((x) => x.kind !== 'object' &&
|
|
36
|
+
return subSchemas.some((x) => x.kind !== 'object' &&
|
|
37
|
+
(x.kind !== 'combined' || (!hasInvalidSubSchema(x.allOf) && !hasInvalidSubSchema(x.anyOf))));
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Retrieves the first schema reference and the reference chain of a given schema that
|