@base44-preview/cli 0.1.1-pr.559.3bdd0a9 → 0.1.1-pr.559.d9cc6f9
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/cli/index.js +595 -464
- package/dist/cli/index.js.map +13 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -119560,11 +119560,11 @@ function chooseDescription(descriptions, printWidth) {
|
|
|
119560
119560
|
return firstWidth > printWidth && firstWidth > secondWidth ? secondDescription : firstDescription;
|
|
119561
119561
|
}
|
|
119562
119562
|
function createSchema(SchemaConstructor, parameters) {
|
|
119563
|
-
const
|
|
119564
|
-
const subSchema = Object.create(
|
|
119563
|
+
const schema13 = new SchemaConstructor(parameters);
|
|
119564
|
+
const subSchema = Object.create(schema13);
|
|
119565
119565
|
for (const handlerKey of HANDLER_KEYS) {
|
|
119566
119566
|
if (handlerKey in parameters) {
|
|
119567
|
-
subSchema[handlerKey] = normalizeHandler(parameters[handlerKey],
|
|
119567
|
+
subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema13, Schema2.prototype[handlerKey].length);
|
|
119568
119568
|
}
|
|
119569
119569
|
}
|
|
119570
119570
|
return subSchema;
|
|
@@ -122904,9 +122904,9 @@ function optionInfoToSchema(optionInfo, {
|
|
|
122904
122904
|
throw new Error(`Unexpected type ${optionInfo.type}`);
|
|
122905
122905
|
}
|
|
122906
122906
|
if (optionInfo.exception) {
|
|
122907
|
-
parameters.validate = (value,
|
|
122907
|
+
parameters.validate = (value, schema13, utils3) => optionInfo.exception(value) || schema13.validate(value, utils3);
|
|
122908
122908
|
} else {
|
|
122909
|
-
parameters.validate = (value,
|
|
122909
|
+
parameters.validate = (value, schema13, utils3) => value === undefined || schema13.validate(value, utils3);
|
|
122910
122910
|
}
|
|
122911
122911
|
if (optionInfo.redirect) {
|
|
122912
122912
|
handlers.redirect = (value) => !value ? undefined : {
|
|
@@ -122921,7 +122921,7 @@ function optionInfoToSchema(optionInfo, {
|
|
|
122921
122921
|
}
|
|
122922
122922
|
if (isCLI && !optionInfo.array) {
|
|
122923
122923
|
const originalPreprocess = parameters.preprocess || ((x10) => x10);
|
|
122924
|
-
parameters.preprocess = (value,
|
|
122924
|
+
parameters.preprocess = (value, schema13, utils3) => schema13.preprocess(originalPreprocess(Array.isArray(value) ? method_at_default2(0, value, -1) : value), utils3);
|
|
122925
122925
|
}
|
|
122926
122926
|
return optionInfo.array ? ArraySchema.create({
|
|
122927
122927
|
...isCLI ? {
|
|
@@ -124498,9 +124498,9 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124498
124498
|
};
|
|
124499
124499
|
applyNormalization();
|
|
124500
124500
|
for (const key2 of Object.keys(this._utils.schemas)) {
|
|
124501
|
-
const
|
|
124501
|
+
const schema13 = this._utils.schemas[key2];
|
|
124502
124502
|
if (!(key2 in newOptions)) {
|
|
124503
|
-
const defaultResult = normalizeDefaultResult(
|
|
124503
|
+
const defaultResult = normalizeDefaultResult(schema13.default(this._utils));
|
|
124504
124504
|
if ("value" in defaultResult) {
|
|
124505
124505
|
restOptionsArray.push({ [key2]: defaultResult.value });
|
|
124506
124506
|
}
|
|
@@ -124511,13 +124511,13 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124511
124511
|
if (!(key2 in newOptions)) {
|
|
124512
124512
|
continue;
|
|
124513
124513
|
}
|
|
124514
|
-
const
|
|
124514
|
+
const schema13 = this._utils.schemas[key2];
|
|
124515
124515
|
const value = newOptions[key2];
|
|
124516
|
-
const newValue =
|
|
124516
|
+
const newValue = schema13.postprocess(value, this._utils);
|
|
124517
124517
|
if (newValue === VALUE_UNCHANGED) {
|
|
124518
124518
|
continue;
|
|
124519
124519
|
}
|
|
124520
|
-
this._applyValidation(newValue, key2,
|
|
124520
|
+
this._applyValidation(newValue, key2, schema13);
|
|
124521
124521
|
newOptions[key2] = newValue;
|
|
124522
124522
|
}
|
|
124523
124523
|
this._applyPostprocess(newOptions);
|
|
@@ -124528,14 +124528,14 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124528
124528
|
const transferredOptionsArray = [];
|
|
124529
124529
|
const { knownKeys, unknownKeys } = this._partitionOptionKeys(options8);
|
|
124530
124530
|
for (const key2 of knownKeys) {
|
|
124531
|
-
const
|
|
124532
|
-
const value =
|
|
124533
|
-
this._applyValidation(value, key2,
|
|
124531
|
+
const schema13 = this._utils.schemas[key2];
|
|
124532
|
+
const value = schema13.preprocess(options8[key2], this._utils);
|
|
124533
|
+
this._applyValidation(value, key2, schema13);
|
|
124534
124534
|
const appendTransferredOptions = ({ from, to: to5 }) => {
|
|
124535
124535
|
transferredOptionsArray.push(typeof to5 === "string" ? { [to5]: from } : { [to5.key]: to5.value });
|
|
124536
124536
|
};
|
|
124537
124537
|
const warnDeprecated = ({ value: currentValue, redirectTo }) => {
|
|
124538
|
-
const deprecatedResult = normalizeDeprecatedResult(
|
|
124538
|
+
const deprecatedResult = normalizeDeprecatedResult(schema13.deprecated(currentValue, this._utils), value, true);
|
|
124539
124539
|
if (deprecatedResult === false) {
|
|
124540
124540
|
return;
|
|
124541
124541
|
}
|
|
@@ -124553,13 +124553,13 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124553
124553
|
}
|
|
124554
124554
|
}
|
|
124555
124555
|
};
|
|
124556
|
-
const forwardResult = normalizeForwardResult(
|
|
124556
|
+
const forwardResult = normalizeForwardResult(schema13.forward(value, this._utils), value);
|
|
124557
124557
|
forwardResult.forEach(appendTransferredOptions);
|
|
124558
|
-
const redirectResult = normalizeRedirectResult(
|
|
124558
|
+
const redirectResult = normalizeRedirectResult(schema13.redirect(value, this._utils), value);
|
|
124559
124559
|
redirectResult.redirect.forEach(appendTransferredOptions);
|
|
124560
124560
|
if ("remain" in redirectResult) {
|
|
124561
124561
|
const remainingValue = redirectResult.remain;
|
|
124562
|
-
newOptions[key2] = key2 in newOptions ?
|
|
124562
|
+
newOptions[key2] = key2 in newOptions ? schema13.overlap(newOptions[key2], remainingValue, this._utils) : remainingValue;
|
|
124563
124563
|
warnDeprecated({ value: remainingValue });
|
|
124564
124564
|
}
|
|
124565
124565
|
for (const { from, to: to5 } of redirectResult.redirect) {
|
|
@@ -124587,8 +124587,8 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124587
124587
|
const [knownKeys, unknownKeys] = partition(Object.keys(options8).filter((key2) => !this._identifyMissing(key2, options8)), (key2) => (key2 in this._utils.schemas));
|
|
124588
124588
|
return { knownKeys, unknownKeys };
|
|
124589
124589
|
}
|
|
124590
|
-
_applyValidation(value, key2,
|
|
124591
|
-
const validateResult = normalizeValidateResult(
|
|
124590
|
+
_applyValidation(value, key2, schema13) {
|
|
124591
|
+
const validateResult = normalizeValidateResult(schema13.validate(value, this._utils), value);
|
|
124592
124592
|
if (validateResult !== true) {
|
|
124593
124593
|
throw this._invalidHandler(key2, validateResult.value, this._utils);
|
|
124594
124594
|
}
|
|
@@ -124630,8 +124630,8 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc,
|
|
|
124630
124630
|
for (const key2 of unknownKeys) {
|
|
124631
124631
|
const value = postprocessed.override[key2];
|
|
124632
124632
|
this._applyUnknownHandler(key2, value, options8, (knownResultKey, knownResultValue) => {
|
|
124633
|
-
const
|
|
124634
|
-
this._applyValidation(knownResultValue, knownResultKey,
|
|
124633
|
+
const schema13 = this._utils.schemas[knownResultKey];
|
|
124634
|
+
this._applyValidation(knownResultValue, knownResultKey, schema13);
|
|
124635
124635
|
options8[knownResultKey] = knownResultValue;
|
|
124636
124636
|
});
|
|
124637
124637
|
}
|
|
@@ -138344,23 +138344,23 @@ var require_JSONSchema = __commonJS((exports) => {
|
|
|
138344
138344
|
exports.Parent = Symbol("Parent");
|
|
138345
138345
|
exports.Types = Symbol("Types");
|
|
138346
138346
|
exports.Intersection = Symbol("Intersection");
|
|
138347
|
-
exports.getRootSchema = (0, lodash_1.memoize)((
|
|
138348
|
-
const parent =
|
|
138347
|
+
exports.getRootSchema = (0, lodash_1.memoize)((schema13) => {
|
|
138348
|
+
const parent = schema13[exports.Parent];
|
|
138349
138349
|
if (!parent) {
|
|
138350
|
-
return
|
|
138350
|
+
return schema13;
|
|
138351
138351
|
}
|
|
138352
138352
|
return (0, exports.getRootSchema)(parent);
|
|
138353
138353
|
});
|
|
138354
|
-
function isBoolean(
|
|
138355
|
-
return
|
|
138354
|
+
function isBoolean(schema13) {
|
|
138355
|
+
return schema13 === true || schema13 === false;
|
|
138356
138356
|
}
|
|
138357
138357
|
exports.isBoolean = isBoolean;
|
|
138358
|
-
function isPrimitive(
|
|
138359
|
-
return !(0, lodash_1.isPlainObject)(
|
|
138358
|
+
function isPrimitive(schema13) {
|
|
138359
|
+
return !(0, lodash_1.isPlainObject)(schema13);
|
|
138360
138360
|
}
|
|
138361
138361
|
exports.isPrimitive = isPrimitive;
|
|
138362
|
-
function isCompound(
|
|
138363
|
-
return Array.isArray(
|
|
138362
|
+
function isCompound(schema13) {
|
|
138363
|
+
return Array.isArray(schema13.type) || "anyOf" in schema13 || "oneOf" in schema13;
|
|
138364
138364
|
}
|
|
138365
138365
|
exports.isCompound = isCompound;
|
|
138366
138366
|
});
|
|
@@ -138587,9 +138587,9 @@ var require_type2 = __commonJS((exports, module) => {
|
|
|
138587
138587
|
var require_schema5 = __commonJS((exports, module) => {
|
|
138588
138588
|
var YAMLException = require_exception2();
|
|
138589
138589
|
var Type = require_type2();
|
|
138590
|
-
function compileList(
|
|
138590
|
+
function compileList(schema13, name2) {
|
|
138591
138591
|
var result = [];
|
|
138592
|
-
|
|
138592
|
+
schema13[name2].forEach(function(currentType) {
|
|
138593
138593
|
var newIndex = result.length;
|
|
138594
138594
|
result.forEach(function(previousType, previousIndex) {
|
|
138595
138595
|
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
@@ -140534,7 +140534,7 @@ var require_dumper2 = __commonJS((exports, module) => {
|
|
|
140534
140534
|
"OFF"
|
|
140535
140535
|
];
|
|
140536
140536
|
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
140537
|
-
function compileStyleMap(
|
|
140537
|
+
function compileStyleMap(schema13, map2) {
|
|
140538
140538
|
var result, keys, index, length, tag, style, type;
|
|
140539
140539
|
if (map2 === null)
|
|
140540
140540
|
return {};
|
|
@@ -140546,7 +140546,7 @@ var require_dumper2 = __commonJS((exports, module) => {
|
|
|
140546
140546
|
if (tag.slice(0, 2) === "!!") {
|
|
140547
140547
|
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
140548
140548
|
}
|
|
140549
|
-
type =
|
|
140549
|
+
type = schema13.compiledTypeMap["fallback"][tag];
|
|
140550
140550
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
140551
140551
|
style = type.styleAliases[style];
|
|
140552
140552
|
}
|
|
@@ -141205,11 +141205,11 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141205
141205
|
function traverseArray(arr, callback, processed) {
|
|
141206
141206
|
arr.forEach((s5, k9) => traverse(s5, callback, processed, k9.toString()));
|
|
141207
141207
|
}
|
|
141208
|
-
function traverseIntersection(
|
|
141209
|
-
if (typeof
|
|
141208
|
+
function traverseIntersection(schema13, callback, processed) {
|
|
141209
|
+
if (typeof schema13 !== "object" || !schema13) {
|
|
141210
141210
|
return;
|
|
141211
141211
|
}
|
|
141212
|
-
const r5 =
|
|
141212
|
+
const r5 = schema13;
|
|
141213
141213
|
const intersection2 = r5[JSONSchema_1.Intersection];
|
|
141214
141214
|
if (!intersection2) {
|
|
141215
141215
|
return;
|
|
@@ -141218,60 +141218,60 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141218
141218
|
traverseArray(intersection2.allOf, callback, processed);
|
|
141219
141219
|
}
|
|
141220
141220
|
}
|
|
141221
|
-
function traverse(
|
|
141222
|
-
if (processed.has(
|
|
141221
|
+
function traverse(schema13, callback, processed = new Set, key2) {
|
|
141222
|
+
if (processed.has(schema13)) {
|
|
141223
141223
|
return;
|
|
141224
141224
|
}
|
|
141225
|
-
processed.add(
|
|
141226
|
-
callback(
|
|
141227
|
-
if (
|
|
141228
|
-
traverseArray(
|
|
141225
|
+
processed.add(schema13);
|
|
141226
|
+
callback(schema13, key2 !== null && key2 !== undefined ? key2 : null);
|
|
141227
|
+
if (schema13.anyOf) {
|
|
141228
|
+
traverseArray(schema13.anyOf, callback, processed);
|
|
141229
141229
|
}
|
|
141230
|
-
if (
|
|
141231
|
-
traverseArray(
|
|
141230
|
+
if (schema13.allOf) {
|
|
141231
|
+
traverseArray(schema13.allOf, callback, processed);
|
|
141232
141232
|
}
|
|
141233
|
-
if (
|
|
141234
|
-
traverseArray(
|
|
141233
|
+
if (schema13.oneOf) {
|
|
141234
|
+
traverseArray(schema13.oneOf, callback, processed);
|
|
141235
141235
|
}
|
|
141236
|
-
if (
|
|
141237
|
-
traverseObjectKeys(
|
|
141236
|
+
if (schema13.properties) {
|
|
141237
|
+
traverseObjectKeys(schema13.properties, callback, processed);
|
|
141238
141238
|
}
|
|
141239
|
-
if (
|
|
141240
|
-
traverseObjectKeys(
|
|
141239
|
+
if (schema13.patternProperties) {
|
|
141240
|
+
traverseObjectKeys(schema13.patternProperties, callback, processed);
|
|
141241
141241
|
}
|
|
141242
|
-
if (
|
|
141243
|
-
traverse(
|
|
141242
|
+
if (schema13.additionalProperties && typeof schema13.additionalProperties === "object") {
|
|
141243
|
+
traverse(schema13.additionalProperties, callback, processed);
|
|
141244
141244
|
}
|
|
141245
|
-
if (
|
|
141246
|
-
const { items } =
|
|
141245
|
+
if (schema13.items) {
|
|
141246
|
+
const { items } = schema13;
|
|
141247
141247
|
if (Array.isArray(items)) {
|
|
141248
141248
|
traverseArray(items, callback, processed);
|
|
141249
141249
|
} else {
|
|
141250
141250
|
traverse(items, callback, processed);
|
|
141251
141251
|
}
|
|
141252
141252
|
}
|
|
141253
|
-
if (
|
|
141254
|
-
traverse(
|
|
141253
|
+
if (schema13.additionalItems && typeof schema13.additionalItems === "object") {
|
|
141254
|
+
traverse(schema13.additionalItems, callback, processed);
|
|
141255
141255
|
}
|
|
141256
|
-
if (
|
|
141257
|
-
if (Array.isArray(
|
|
141258
|
-
traverseArray(
|
|
141256
|
+
if (schema13.dependencies) {
|
|
141257
|
+
if (Array.isArray(schema13.dependencies)) {
|
|
141258
|
+
traverseArray(schema13.dependencies, callback, processed);
|
|
141259
141259
|
} else {
|
|
141260
|
-
traverseObjectKeys(
|
|
141260
|
+
traverseObjectKeys(schema13.dependencies, callback, processed);
|
|
141261
141261
|
}
|
|
141262
141262
|
}
|
|
141263
|
-
if (
|
|
141264
|
-
traverseObjectKeys(
|
|
141263
|
+
if (schema13.definitions) {
|
|
141264
|
+
traverseObjectKeys(schema13.definitions, callback, processed);
|
|
141265
141265
|
}
|
|
141266
|
-
if (
|
|
141267
|
-
traverseObjectKeys(
|
|
141266
|
+
if (schema13.$defs) {
|
|
141267
|
+
traverseObjectKeys(schema13.$defs, callback, processed);
|
|
141268
141268
|
}
|
|
141269
|
-
if (
|
|
141270
|
-
traverse(
|
|
141269
|
+
if (schema13.not) {
|
|
141270
|
+
traverse(schema13.not, callback, processed);
|
|
141271
141271
|
}
|
|
141272
|
-
traverseIntersection(
|
|
141273
|
-
Object.keys(
|
|
141274
|
-
const child =
|
|
141272
|
+
traverseIntersection(schema13, callback, processed);
|
|
141273
|
+
Object.keys(schema13).filter((key3) => !BLACKLISTED_KEYS.has(key3)).forEach((key3) => {
|
|
141274
|
+
const child = schema13[key3];
|
|
141275
141275
|
if (child && typeof child === "object") {
|
|
141276
141276
|
traverseObjectKeys(child, callback, processed);
|
|
141277
141277
|
}
|
|
@@ -141353,14 +141353,14 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141353
141353
|
return (_g2 = color()) === null || _g2 === undefined ? undefined : _g2.whiteBright.bgYellow;
|
|
141354
141354
|
}
|
|
141355
141355
|
}
|
|
141356
|
-
function escapeBlockComment(
|
|
141356
|
+
function escapeBlockComment(schema13) {
|
|
141357
141357
|
const replacer = "* /";
|
|
141358
|
-
if (
|
|
141358
|
+
if (schema13 === null || typeof schema13 !== "object") {
|
|
141359
141359
|
return;
|
|
141360
141360
|
}
|
|
141361
|
-
for (const key2 of Object.keys(
|
|
141362
|
-
if (key2 === "description" && typeof
|
|
141363
|
-
|
|
141361
|
+
for (const key2 of Object.keys(schema13)) {
|
|
141362
|
+
if (key2 === "description" && typeof schema13[key2] === "string") {
|
|
141363
|
+
schema13[key2] = schema13[key2].replace(/\*\//g, replacer);
|
|
141364
141364
|
}
|
|
141365
141365
|
}
|
|
141366
141366
|
}
|
|
@@ -141372,45 +141372,45 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141372
141372
|
return path_1.posix.join(path_1.posix.normalize(outputPath), ...filePathRel);
|
|
141373
141373
|
}
|
|
141374
141374
|
exports.pathTransform = pathTransform;
|
|
141375
|
-
function maybeStripDefault(
|
|
141376
|
-
if (!("default" in
|
|
141377
|
-
return
|
|
141375
|
+
function maybeStripDefault(schema13) {
|
|
141376
|
+
if (!("default" in schema13)) {
|
|
141377
|
+
return schema13;
|
|
141378
141378
|
}
|
|
141379
|
-
switch (
|
|
141379
|
+
switch (schema13.type) {
|
|
141380
141380
|
case "array":
|
|
141381
|
-
if (Array.isArray(
|
|
141382
|
-
return
|
|
141381
|
+
if (Array.isArray(schema13.default)) {
|
|
141382
|
+
return schema13;
|
|
141383
141383
|
}
|
|
141384
141384
|
break;
|
|
141385
141385
|
case "boolean":
|
|
141386
|
-
if (typeof
|
|
141387
|
-
return
|
|
141386
|
+
if (typeof schema13.default === "boolean") {
|
|
141387
|
+
return schema13;
|
|
141388
141388
|
}
|
|
141389
141389
|
break;
|
|
141390
141390
|
case "integer":
|
|
141391
141391
|
case "number":
|
|
141392
|
-
if (typeof
|
|
141393
|
-
return
|
|
141392
|
+
if (typeof schema13.default === "number") {
|
|
141393
|
+
return schema13;
|
|
141394
141394
|
}
|
|
141395
141395
|
break;
|
|
141396
141396
|
case "string":
|
|
141397
|
-
if (typeof
|
|
141398
|
-
return
|
|
141397
|
+
if (typeof schema13.default === "string") {
|
|
141398
|
+
return schema13;
|
|
141399
141399
|
}
|
|
141400
141400
|
break;
|
|
141401
141401
|
case "null":
|
|
141402
|
-
if (
|
|
141403
|
-
return
|
|
141402
|
+
if (schema13.default === null) {
|
|
141403
|
+
return schema13;
|
|
141404
141404
|
}
|
|
141405
141405
|
break;
|
|
141406
141406
|
case "object":
|
|
141407
|
-
if ((0, lodash_1.isPlainObject)(
|
|
141408
|
-
return
|
|
141407
|
+
if ((0, lodash_1.isPlainObject)(schema13.default)) {
|
|
141408
|
+
return schema13;
|
|
141409
141409
|
}
|
|
141410
141410
|
break;
|
|
141411
141411
|
}
|
|
141412
|
-
delete
|
|
141413
|
-
return
|
|
141412
|
+
delete schema13.default;
|
|
141413
|
+
return schema13;
|
|
141414
141414
|
}
|
|
141415
141415
|
exports.maybeStripDefault = maybeStripDefault;
|
|
141416
141416
|
function appendToDescription(existingDescription, ...values) {
|
|
@@ -141424,11 +141424,11 @@ ${values.join(`
|
|
|
141424
141424
|
`);
|
|
141425
141425
|
}
|
|
141426
141426
|
exports.appendToDescription = appendToDescription;
|
|
141427
|
-
function isSchemaLike(
|
|
141428
|
-
if (!(0, lodash_1.isPlainObject)(
|
|
141427
|
+
function isSchemaLike(schema13) {
|
|
141428
|
+
if (!(0, lodash_1.isPlainObject)(schema13)) {
|
|
141429
141429
|
return false;
|
|
141430
141430
|
}
|
|
141431
|
-
const parent =
|
|
141431
|
+
const parent = schema13[JSONSchema_1.Parent];
|
|
141432
141432
|
if (parent === null) {
|
|
141433
141433
|
return true;
|
|
141434
141434
|
}
|
|
@@ -141445,7 +141445,7 @@ ${values.join(`
|
|
|
141445
141445
|
"properties",
|
|
141446
141446
|
"required"
|
|
141447
141447
|
];
|
|
141448
|
-
if (JSON_SCHEMA_KEYWORDS.some((_10) => parent[_10] ===
|
|
141448
|
+
if (JSON_SCHEMA_KEYWORDS.some((_10) => parent[_10] === schema13)) {
|
|
141449
141449
|
return false;
|
|
141450
141450
|
}
|
|
141451
141451
|
return true;
|
|
@@ -141743,13 +141743,13 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141743
141743
|
exports.typesOfSchema = undefined;
|
|
141744
141744
|
var lodash_1 = require_lodash8();
|
|
141745
141745
|
var JSONSchema_1 = require_JSONSchema();
|
|
141746
|
-
function typesOfSchema(
|
|
141747
|
-
if (
|
|
141746
|
+
function typesOfSchema(schema13) {
|
|
141747
|
+
if (schema13.tsType) {
|
|
141748
141748
|
return new Set(["CUSTOM_TYPE"]);
|
|
141749
141749
|
}
|
|
141750
141750
|
const matchedTypes = new Set;
|
|
141751
141751
|
for (const [schemaType, f7] of Object.entries(matchers)) {
|
|
141752
|
-
if (f7(
|
|
141752
|
+
if (f7(schema13)) {
|
|
141753
141753
|
matchedTypes.add(schemaType);
|
|
141754
141754
|
}
|
|
141755
141755
|
}
|
|
@@ -141760,26 +141760,26 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141760
141760
|
}
|
|
141761
141761
|
exports.typesOfSchema = typesOfSchema;
|
|
141762
141762
|
var matchers = {
|
|
141763
|
-
ALL_OF(
|
|
141764
|
-
return "allOf" in
|
|
141763
|
+
ALL_OF(schema13) {
|
|
141764
|
+
return "allOf" in schema13;
|
|
141765
141765
|
},
|
|
141766
|
-
ANY(
|
|
141767
|
-
if (Object.keys(
|
|
141766
|
+
ANY(schema13) {
|
|
141767
|
+
if (Object.keys(schema13).length === 0) {
|
|
141768
141768
|
return true;
|
|
141769
141769
|
}
|
|
141770
|
-
return
|
|
141770
|
+
return schema13.type === "any";
|
|
141771
141771
|
},
|
|
141772
|
-
ANY_OF(
|
|
141773
|
-
return "anyOf" in
|
|
141772
|
+
ANY_OF(schema13) {
|
|
141773
|
+
return "anyOf" in schema13;
|
|
141774
141774
|
},
|
|
141775
|
-
BOOLEAN(
|
|
141776
|
-
if ("enum" in
|
|
141775
|
+
BOOLEAN(schema13) {
|
|
141776
|
+
if ("enum" in schema13) {
|
|
141777
141777
|
return false;
|
|
141778
141778
|
}
|
|
141779
|
-
if (
|
|
141779
|
+
if (schema13.type === "boolean") {
|
|
141780
141780
|
return true;
|
|
141781
141781
|
}
|
|
141782
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141782
|
+
if (!(0, JSONSchema_1.isCompound)(schema13) && typeof schema13.default === "boolean") {
|
|
141783
141783
|
return true;
|
|
141784
141784
|
}
|
|
141785
141785
|
return false;
|
|
@@ -141787,74 +141787,74 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141787
141787
|
CUSTOM_TYPE() {
|
|
141788
141788
|
return false;
|
|
141789
141789
|
},
|
|
141790
|
-
NAMED_ENUM(
|
|
141791
|
-
return "enum" in
|
|
141790
|
+
NAMED_ENUM(schema13) {
|
|
141791
|
+
return "enum" in schema13 && "tsEnumNames" in schema13;
|
|
141792
141792
|
},
|
|
141793
|
-
NAMED_SCHEMA(
|
|
141794
|
-
return "$id" in
|
|
141793
|
+
NAMED_SCHEMA(schema13) {
|
|
141794
|
+
return "$id" in schema13 && (("patternProperties" in schema13) || ("properties" in schema13));
|
|
141795
141795
|
},
|
|
141796
|
-
NEVER(
|
|
141797
|
-
return
|
|
141796
|
+
NEVER(schema13) {
|
|
141797
|
+
return schema13 === false;
|
|
141798
141798
|
},
|
|
141799
|
-
NULL(
|
|
141800
|
-
return
|
|
141799
|
+
NULL(schema13) {
|
|
141800
|
+
return schema13.type === "null";
|
|
141801
141801
|
},
|
|
141802
|
-
NUMBER(
|
|
141803
|
-
if ("enum" in
|
|
141802
|
+
NUMBER(schema13) {
|
|
141803
|
+
if ("enum" in schema13) {
|
|
141804
141804
|
return false;
|
|
141805
141805
|
}
|
|
141806
|
-
if (
|
|
141806
|
+
if (schema13.type === "integer" || schema13.type === "number") {
|
|
141807
141807
|
return true;
|
|
141808
141808
|
}
|
|
141809
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141809
|
+
if (!(0, JSONSchema_1.isCompound)(schema13) && typeof schema13.default === "number") {
|
|
141810
141810
|
return true;
|
|
141811
141811
|
}
|
|
141812
141812
|
return false;
|
|
141813
141813
|
},
|
|
141814
|
-
OBJECT(
|
|
141815
|
-
return
|
|
141814
|
+
OBJECT(schema13) {
|
|
141815
|
+
return schema13.type === "object" && !(0, lodash_1.isPlainObject)(schema13.additionalProperties) && !schema13.allOf && !schema13.anyOf && !schema13.oneOf && !schema13.patternProperties && !schema13.properties && !schema13.required;
|
|
141816
141816
|
},
|
|
141817
|
-
ONE_OF(
|
|
141818
|
-
return "oneOf" in
|
|
141817
|
+
ONE_OF(schema13) {
|
|
141818
|
+
return "oneOf" in schema13;
|
|
141819
141819
|
},
|
|
141820
|
-
REFERENCE(
|
|
141821
|
-
return "$ref" in
|
|
141820
|
+
REFERENCE(schema13) {
|
|
141821
|
+
return "$ref" in schema13;
|
|
141822
141822
|
},
|
|
141823
|
-
STRING(
|
|
141824
|
-
if ("enum" in
|
|
141823
|
+
STRING(schema13) {
|
|
141824
|
+
if ("enum" in schema13) {
|
|
141825
141825
|
return false;
|
|
141826
141826
|
}
|
|
141827
|
-
if (
|
|
141827
|
+
if (schema13.type === "string") {
|
|
141828
141828
|
return true;
|
|
141829
141829
|
}
|
|
141830
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141830
|
+
if (!(0, JSONSchema_1.isCompound)(schema13) && typeof schema13.default === "string") {
|
|
141831
141831
|
return true;
|
|
141832
141832
|
}
|
|
141833
141833
|
return false;
|
|
141834
141834
|
},
|
|
141835
|
-
TYPED_ARRAY(
|
|
141836
|
-
if (
|
|
141835
|
+
TYPED_ARRAY(schema13) {
|
|
141836
|
+
if (schema13.type && schema13.type !== "array") {
|
|
141837
141837
|
return false;
|
|
141838
141838
|
}
|
|
141839
|
-
return "items" in
|
|
141839
|
+
return "items" in schema13;
|
|
141840
141840
|
},
|
|
141841
|
-
UNION(
|
|
141842
|
-
return Array.isArray(
|
|
141841
|
+
UNION(schema13) {
|
|
141842
|
+
return Array.isArray(schema13.type);
|
|
141843
141843
|
},
|
|
141844
|
-
UNNAMED_ENUM(
|
|
141845
|
-
if ("tsEnumNames" in
|
|
141844
|
+
UNNAMED_ENUM(schema13) {
|
|
141845
|
+
if ("tsEnumNames" in schema13) {
|
|
141846
141846
|
return false;
|
|
141847
141847
|
}
|
|
141848
|
-
if (
|
|
141848
|
+
if (schema13.type && schema13.type !== "boolean" && schema13.type !== "integer" && schema13.type !== "number" && schema13.type !== "string") {
|
|
141849
141849
|
return false;
|
|
141850
141850
|
}
|
|
141851
|
-
return "enum" in
|
|
141851
|
+
return "enum" in schema13;
|
|
141852
141852
|
},
|
|
141853
141853
|
UNNAMED_SCHEMA() {
|
|
141854
141854
|
return false;
|
|
141855
141855
|
},
|
|
141856
|
-
UNTYPED_ARRAY(
|
|
141857
|
-
return
|
|
141856
|
+
UNTYPED_ARRAY(schema13) {
|
|
141857
|
+
return schema13.type === "array" && !("items" in schema13);
|
|
141858
141858
|
}
|
|
141859
141859
|
};
|
|
141860
141860
|
});
|
|
@@ -141865,10 +141865,10 @@ var require_applySchemaTyping = __commonJS((exports) => {
|
|
|
141865
141865
|
exports.applySchemaTyping = undefined;
|
|
141866
141866
|
var JSONSchema_1 = require_JSONSchema();
|
|
141867
141867
|
var typesOfSchema_1 = require_typesOfSchema();
|
|
141868
|
-
function applySchemaTyping(
|
|
141868
|
+
function applySchemaTyping(schema13) {
|
|
141869
141869
|
var _a7;
|
|
141870
|
-
const types = (0, typesOfSchema_1.typesOfSchema)(
|
|
141871
|
-
Object.defineProperty(
|
|
141870
|
+
const types = (0, typesOfSchema_1.typesOfSchema)(schema13);
|
|
141871
|
+
Object.defineProperty(schema13, JSONSchema_1.Types, {
|
|
141872
141872
|
enumerable: false,
|
|
141873
141873
|
value: types,
|
|
141874
141874
|
writable: false
|
|
@@ -141877,23 +141877,23 @@ var require_applySchemaTyping = __commonJS((exports) => {
|
|
|
141877
141877
|
return;
|
|
141878
141878
|
}
|
|
141879
141879
|
const intersection2 = {
|
|
141880
|
-
[JSONSchema_1.Parent]:
|
|
141880
|
+
[JSONSchema_1.Parent]: schema13,
|
|
141881
141881
|
[JSONSchema_1.Types]: new Set(["ALL_OF"]),
|
|
141882
|
-
$id:
|
|
141883
|
-
description:
|
|
141884
|
-
name:
|
|
141885
|
-
title:
|
|
141886
|
-
allOf: (_a7 =
|
|
141882
|
+
$id: schema13.$id,
|
|
141883
|
+
description: schema13.description,
|
|
141884
|
+
name: schema13.name,
|
|
141885
|
+
title: schema13.title,
|
|
141886
|
+
allOf: (_a7 = schema13.allOf) !== null && _a7 !== undefined ? _a7 : [],
|
|
141887
141887
|
required: [],
|
|
141888
141888
|
additionalProperties: false
|
|
141889
141889
|
};
|
|
141890
141890
|
types.delete("ALL_OF");
|
|
141891
|
-
delete
|
|
141892
|
-
delete
|
|
141893
|
-
delete
|
|
141894
|
-
delete
|
|
141895
|
-
delete
|
|
141896
|
-
Object.defineProperty(
|
|
141891
|
+
delete schema13.allOf;
|
|
141892
|
+
delete schema13.$id;
|
|
141893
|
+
delete schema13.description;
|
|
141894
|
+
delete schema13.name;
|
|
141895
|
+
delete schema13.title;
|
|
141896
|
+
Object.defineProperty(schema13, JSONSchema_1.Intersection, {
|
|
141897
141897
|
enumerable: false,
|
|
141898
141898
|
value: intersection2,
|
|
141899
141899
|
writable: false
|
|
@@ -141911,186 +141911,186 @@ var require_normalizer = __commonJS((exports) => {
|
|
|
141911
141911
|
var applySchemaTyping_1 = require_applySchemaTyping();
|
|
141912
141912
|
var util_1 = __require("util");
|
|
141913
141913
|
var rules = new Map;
|
|
141914
|
-
function hasType(
|
|
141915
|
-
return
|
|
141914
|
+
function hasType(schema13, type) {
|
|
141915
|
+
return schema13.type === type || Array.isArray(schema13.type) && schema13.type.includes(type);
|
|
141916
141916
|
}
|
|
141917
|
-
function isObjectType(
|
|
141918
|
-
return
|
|
141917
|
+
function isObjectType(schema13) {
|
|
141918
|
+
return schema13.properties !== undefined || hasType(schema13, "object") || hasType(schema13, "any");
|
|
141919
141919
|
}
|
|
141920
|
-
function isArrayType(
|
|
141921
|
-
return
|
|
141920
|
+
function isArrayType(schema13) {
|
|
141921
|
+
return schema13.items !== undefined || hasType(schema13, "array") || hasType(schema13, "any");
|
|
141922
141922
|
}
|
|
141923
|
-
function isEnumTypeWithoutTsEnumNames(
|
|
141924
|
-
return
|
|
141923
|
+
function isEnumTypeWithoutTsEnumNames(schema13) {
|
|
141924
|
+
return schema13.type === "string" && schema13.enum !== undefined && schema13.tsEnumNames === undefined;
|
|
141925
141925
|
}
|
|
141926
|
-
rules.set('Remove `type=["null"]` if `enum=[null]`', (
|
|
141927
|
-
if (Array.isArray(
|
|
141928
|
-
|
|
141926
|
+
rules.set('Remove `type=["null"]` if `enum=[null]`', (schema13) => {
|
|
141927
|
+
if (Array.isArray(schema13.enum) && schema13.enum.some((e8) => e8 === null) && Array.isArray(schema13.type) && schema13.type.includes("null")) {
|
|
141928
|
+
schema13.type = schema13.type.filter((type) => type !== "null");
|
|
141929
141929
|
}
|
|
141930
141930
|
});
|
|
141931
|
-
rules.set("Destructure unary types", (
|
|
141932
|
-
if (
|
|
141933
|
-
|
|
141931
|
+
rules.set("Destructure unary types", (schema13) => {
|
|
141932
|
+
if (schema13.type && Array.isArray(schema13.type) && schema13.type.length === 1) {
|
|
141933
|
+
schema13.type = schema13.type[0];
|
|
141934
141934
|
}
|
|
141935
141935
|
});
|
|
141936
|
-
rules.set("Add empty `required` property if none is defined", (
|
|
141937
|
-
if (isObjectType(
|
|
141938
|
-
|
|
141936
|
+
rules.set("Add empty `required` property if none is defined", (schema13) => {
|
|
141937
|
+
if (isObjectType(schema13) && !("required" in schema13)) {
|
|
141938
|
+
schema13.required = [];
|
|
141939
141939
|
}
|
|
141940
141940
|
});
|
|
141941
|
-
rules.set("Transform `required`=false to `required`=[]", (
|
|
141942
|
-
if (
|
|
141943
|
-
|
|
141941
|
+
rules.set("Transform `required`=false to `required`=[]", (schema13) => {
|
|
141942
|
+
if (schema13.required === false) {
|
|
141943
|
+
schema13.required = [];
|
|
141944
141944
|
}
|
|
141945
141945
|
});
|
|
141946
|
-
rules.set("Default additionalProperties", (
|
|
141947
|
-
if (isObjectType(
|
|
141948
|
-
|
|
141946
|
+
rules.set("Default additionalProperties", (schema13, _10, options8) => {
|
|
141947
|
+
if (isObjectType(schema13) && !("additionalProperties" in schema13) && schema13.patternProperties === undefined) {
|
|
141948
|
+
schema13.additionalProperties = options8.additionalProperties;
|
|
141949
141949
|
}
|
|
141950
141950
|
});
|
|
141951
|
-
rules.set("Transform id to $id", (
|
|
141952
|
-
if (!(0, utils_1.isSchemaLike)(
|
|
141951
|
+
rules.set("Transform id to $id", (schema13, fileName) => {
|
|
141952
|
+
if (!(0, utils_1.isSchemaLike)(schema13)) {
|
|
141953
141953
|
return;
|
|
141954
141954
|
}
|
|
141955
|
-
if (
|
|
141956
|
-
throw ReferenceError(`Schema must define either id or $id, not both. Given id=${
|
|
141955
|
+
if (schema13.id && schema13.$id && schema13.id !== schema13.$id) {
|
|
141956
|
+
throw ReferenceError(`Schema must define either id or $id, not both. Given id=${schema13.id}, $id=${schema13.$id} in ${fileName}`);
|
|
141957
141957
|
}
|
|
141958
|
-
if (
|
|
141959
|
-
|
|
141960
|
-
delete
|
|
141958
|
+
if (schema13.id) {
|
|
141959
|
+
schema13.$id = schema13.id;
|
|
141960
|
+
delete schema13.id;
|
|
141961
141961
|
}
|
|
141962
141962
|
});
|
|
141963
|
-
rules.set("Add an $id to anything that needs it", (
|
|
141964
|
-
if (!(0, utils_1.isSchemaLike)(
|
|
141963
|
+
rules.set("Add an $id to anything that needs it", (schema13, fileName, _options, _key, dereferencedPaths) => {
|
|
141964
|
+
if (!(0, utils_1.isSchemaLike)(schema13)) {
|
|
141965
141965
|
return;
|
|
141966
141966
|
}
|
|
141967
|
-
if (!
|
|
141968
|
-
|
|
141967
|
+
if (!schema13.$id && !schema13[JSONSchema_1.Parent]) {
|
|
141968
|
+
schema13.$id = (0, utils_1.toSafeString)((0, utils_1.justName)(fileName));
|
|
141969
141969
|
return;
|
|
141970
141970
|
}
|
|
141971
|
-
if (!isArrayType(
|
|
141971
|
+
if (!isArrayType(schema13) && !isObjectType(schema13)) {
|
|
141972
141972
|
return;
|
|
141973
141973
|
}
|
|
141974
|
-
const dereferencedName = dereferencedPaths.get(
|
|
141975
|
-
if (!
|
|
141976
|
-
|
|
141974
|
+
const dereferencedName = dereferencedPaths.get(schema13);
|
|
141975
|
+
if (!schema13.$id && !schema13.title && dereferencedName) {
|
|
141976
|
+
schema13.$id = (0, utils_1.toSafeString)((0, utils_1.justName)(dereferencedName));
|
|
141977
141977
|
}
|
|
141978
141978
|
if (dereferencedName) {
|
|
141979
|
-
dereferencedPaths.delete(
|
|
141979
|
+
dereferencedPaths.delete(schema13);
|
|
141980
141980
|
}
|
|
141981
141981
|
});
|
|
141982
|
-
rules.set("Escape closing JSDoc comment", (
|
|
141983
|
-
(0, utils_1.escapeBlockComment)(
|
|
141982
|
+
rules.set("Escape closing JSDoc comment", (schema13) => {
|
|
141983
|
+
(0, utils_1.escapeBlockComment)(schema13);
|
|
141984
141984
|
});
|
|
141985
|
-
rules.set("Add JSDoc comments for minItems and maxItems", (
|
|
141986
|
-
if (!isArrayType(
|
|
141985
|
+
rules.set("Add JSDoc comments for minItems and maxItems", (schema13) => {
|
|
141986
|
+
if (!isArrayType(schema13)) {
|
|
141987
141987
|
return;
|
|
141988
141988
|
}
|
|
141989
141989
|
const commentsToAppend = [
|
|
141990
|
-
"minItems" in
|
|
141991
|
-
"maxItems" in
|
|
141990
|
+
"minItems" in schema13 ? `@minItems ${schema13.minItems}` : "",
|
|
141991
|
+
"maxItems" in schema13 ? `@maxItems ${schema13.maxItems}` : ""
|
|
141992
141992
|
].filter(Boolean);
|
|
141993
141993
|
if (commentsToAppend.length) {
|
|
141994
|
-
|
|
141994
|
+
schema13.description = (0, utils_1.appendToDescription)(schema13.description, ...commentsToAppend);
|
|
141995
141995
|
}
|
|
141996
141996
|
});
|
|
141997
|
-
rules.set("Optionally remove maxItems and minItems", (
|
|
141998
|
-
if (!isArrayType(
|
|
141997
|
+
rules.set("Optionally remove maxItems and minItems", (schema13, _fileName, options8) => {
|
|
141998
|
+
if (!isArrayType(schema13)) {
|
|
141999
141999
|
return;
|
|
142000
142000
|
}
|
|
142001
|
-
if ("minItems" in
|
|
142002
|
-
delete
|
|
142001
|
+
if ("minItems" in schema13 && options8.ignoreMinAndMaxItems) {
|
|
142002
|
+
delete schema13.minItems;
|
|
142003
142003
|
}
|
|
142004
|
-
if ("maxItems" in
|
|
142005
|
-
delete
|
|
142004
|
+
if ("maxItems" in schema13 && (options8.ignoreMinAndMaxItems || options8.maxItems === -1)) {
|
|
142005
|
+
delete schema13.maxItems;
|
|
142006
142006
|
}
|
|
142007
142007
|
});
|
|
142008
|
-
rules.set("Normalize schema.minItems", (
|
|
142008
|
+
rules.set("Normalize schema.minItems", (schema13, _fileName, options8) => {
|
|
142009
142009
|
if (options8.ignoreMinAndMaxItems) {
|
|
142010
142010
|
return;
|
|
142011
142011
|
}
|
|
142012
|
-
if (!isArrayType(
|
|
142012
|
+
if (!isArrayType(schema13)) {
|
|
142013
142013
|
return;
|
|
142014
142014
|
}
|
|
142015
|
-
const { minItems } =
|
|
142016
|
-
|
|
142015
|
+
const { minItems } = schema13;
|
|
142016
|
+
schema13.minItems = typeof minItems === "number" ? minItems : 0;
|
|
142017
142017
|
});
|
|
142018
|
-
rules.set("Remove maxItems if it is big enough to likely cause OOMs", (
|
|
142018
|
+
rules.set("Remove maxItems if it is big enough to likely cause OOMs", (schema13, _fileName, options8) => {
|
|
142019
142019
|
if (options8.ignoreMinAndMaxItems || options8.maxItems === -1) {
|
|
142020
142020
|
return;
|
|
142021
142021
|
}
|
|
142022
|
-
if (!isArrayType(
|
|
142022
|
+
if (!isArrayType(schema13)) {
|
|
142023
142023
|
return;
|
|
142024
142024
|
}
|
|
142025
|
-
const { maxItems, minItems } =
|
|
142025
|
+
const { maxItems, minItems } = schema13;
|
|
142026
142026
|
if (maxItems !== undefined && maxItems - minItems > options8.maxItems) {
|
|
142027
|
-
delete
|
|
142027
|
+
delete schema13.maxItems;
|
|
142028
142028
|
}
|
|
142029
142029
|
});
|
|
142030
|
-
rules.set("Normalize schema.items", (
|
|
142030
|
+
rules.set("Normalize schema.items", (schema13, _fileName, options8) => {
|
|
142031
142031
|
if (options8.ignoreMinAndMaxItems) {
|
|
142032
142032
|
return;
|
|
142033
142033
|
}
|
|
142034
|
-
const { maxItems, minItems } =
|
|
142034
|
+
const { maxItems, minItems } = schema13;
|
|
142035
142035
|
const hasMaxItems = typeof maxItems === "number" && maxItems >= 0;
|
|
142036
142036
|
const hasMinItems = typeof minItems === "number" && minItems > 0;
|
|
142037
|
-
if (
|
|
142038
|
-
const items =
|
|
142037
|
+
if (schema13.items && !Array.isArray(schema13.items) && (hasMaxItems || hasMinItems)) {
|
|
142038
|
+
const items = schema13.items;
|
|
142039
142039
|
const newItems = Array(maxItems || minItems || 0).fill(items);
|
|
142040
142040
|
if (!hasMaxItems) {
|
|
142041
|
-
|
|
142041
|
+
schema13.additionalItems = items;
|
|
142042
142042
|
}
|
|
142043
|
-
|
|
142043
|
+
schema13.items = newItems;
|
|
142044
142044
|
}
|
|
142045
|
-
if (Array.isArray(
|
|
142046
|
-
|
|
142045
|
+
if (Array.isArray(schema13.items) && hasMaxItems && maxItems < schema13.items.length) {
|
|
142046
|
+
schema13.items = schema13.items.slice(0, maxItems);
|
|
142047
142047
|
}
|
|
142048
|
-
return
|
|
142048
|
+
return schema13;
|
|
142049
142049
|
});
|
|
142050
|
-
rules.set("Remove extends, if it is empty", (
|
|
142051
|
-
if (!
|
|
142050
|
+
rules.set("Remove extends, if it is empty", (schema13) => {
|
|
142051
|
+
if (!schema13.hasOwnProperty("extends")) {
|
|
142052
142052
|
return;
|
|
142053
142053
|
}
|
|
142054
|
-
if (
|
|
142055
|
-
delete
|
|
142054
|
+
if (schema13.extends == null || Array.isArray(schema13.extends) && schema13.extends.length === 0) {
|
|
142055
|
+
delete schema13.extends;
|
|
142056
142056
|
}
|
|
142057
142057
|
});
|
|
142058
|
-
rules.set("Make extends always an array, if it is defined", (
|
|
142059
|
-
if (
|
|
142058
|
+
rules.set("Make extends always an array, if it is defined", (schema13) => {
|
|
142059
|
+
if (schema13.extends == null) {
|
|
142060
142060
|
return;
|
|
142061
142061
|
}
|
|
142062
|
-
if (!Array.isArray(
|
|
142063
|
-
|
|
142062
|
+
if (!Array.isArray(schema13.extends)) {
|
|
142063
|
+
schema13.extends = [schema13.extends];
|
|
142064
142064
|
}
|
|
142065
142065
|
});
|
|
142066
|
-
rules.set("Transform definitions to $defs", (
|
|
142067
|
-
if (
|
|
142068
|
-
throw ReferenceError(`Schema must define either definitions or $defs, not both. Given id=${
|
|
142066
|
+
rules.set("Transform definitions to $defs", (schema13, fileName) => {
|
|
142067
|
+
if (schema13.definitions && schema13.$defs && !(0, util_1.isDeepStrictEqual)(schema13.definitions, schema13.$defs)) {
|
|
142068
|
+
throw ReferenceError(`Schema must define either definitions or $defs, not both. Given id=${schema13.id} in ${fileName}`);
|
|
142069
142069
|
}
|
|
142070
|
-
if (
|
|
142071
|
-
|
|
142072
|
-
delete
|
|
142070
|
+
if (schema13.definitions) {
|
|
142071
|
+
schema13.$defs = schema13.definitions;
|
|
142072
|
+
delete schema13.definitions;
|
|
142073
142073
|
}
|
|
142074
142074
|
});
|
|
142075
|
-
rules.set("Transform const to singleton enum", (
|
|
142076
|
-
if (
|
|
142077
|
-
|
|
142078
|
-
delete
|
|
142075
|
+
rules.set("Transform const to singleton enum", (schema13) => {
|
|
142076
|
+
if (schema13.const !== undefined) {
|
|
142077
|
+
schema13.enum = [schema13.const];
|
|
142078
|
+
delete schema13.const;
|
|
142079
142079
|
}
|
|
142080
142080
|
});
|
|
142081
|
-
rules.set("Add tsEnumNames to enum types", (
|
|
142081
|
+
rules.set("Add tsEnumNames to enum types", (schema13, _10, options8) => {
|
|
142082
142082
|
var _a7;
|
|
142083
|
-
if (isEnumTypeWithoutTsEnumNames(
|
|
142084
|
-
|
|
142083
|
+
if (isEnumTypeWithoutTsEnumNames(schema13) && options8.inferStringEnumKeysFromValues) {
|
|
142084
|
+
schema13.tsEnumNames = (_a7 = schema13.enum) === null || _a7 === undefined ? undefined : _a7.map(String);
|
|
142085
142085
|
}
|
|
142086
142086
|
});
|
|
142087
|
-
rules.set("Pre-calculate schema types and intersections", (
|
|
142088
|
-
if (
|
|
142089
|
-
(0, applySchemaTyping_1.applySchemaTyping)(
|
|
142087
|
+
rules.set("Pre-calculate schema types and intersections", (schema13) => {
|
|
142088
|
+
if (schema13 !== null && typeof schema13 === "object") {
|
|
142089
|
+
(0, applySchemaTyping_1.applySchemaTyping)(schema13);
|
|
142090
142090
|
}
|
|
142091
142091
|
});
|
|
142092
142092
|
function normalize2(rootSchema, dereferencedPaths, filename, options8) {
|
|
142093
|
-
rules.forEach((rule) => (0, utils_1.traverse)(rootSchema, (
|
|
142093
|
+
rules.forEach((rule) => (0, utils_1.traverse)(rootSchema, (schema13, key2) => rule(schema13, filename, options8, key2, dereferencedPaths)));
|
|
142094
142094
|
return rootSchema;
|
|
142095
142095
|
}
|
|
142096
142096
|
exports.normalize = normalize2;
|
|
@@ -142172,37 +142172,37 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142172
142172
|
var AST_1 = require_AST();
|
|
142173
142173
|
var JSONSchema_1 = require_JSONSchema();
|
|
142174
142174
|
var utils_1 = require_utils7();
|
|
142175
|
-
function parse11(
|
|
142176
|
-
if ((0, JSONSchema_1.isPrimitive)(
|
|
142177
|
-
if ((0, JSONSchema_1.isBoolean)(
|
|
142178
|
-
return parseBooleanSchema(
|
|
142175
|
+
function parse11(schema13, options8, keyName, processed = new Map, usedNames = new Set) {
|
|
142176
|
+
if ((0, JSONSchema_1.isPrimitive)(schema13)) {
|
|
142177
|
+
if ((0, JSONSchema_1.isBoolean)(schema13)) {
|
|
142178
|
+
return parseBooleanSchema(schema13, keyName, options8);
|
|
142179
142179
|
}
|
|
142180
|
-
return parseLiteral(
|
|
142180
|
+
return parseLiteral(schema13, keyName);
|
|
142181
142181
|
}
|
|
142182
|
-
const intersection2 =
|
|
142183
|
-
const types =
|
|
142182
|
+
const intersection2 = schema13[JSONSchema_1.Intersection];
|
|
142183
|
+
const types = schema13[JSONSchema_1.Types];
|
|
142184
142184
|
if (intersection2) {
|
|
142185
142185
|
const ast = parseAsTypeWithCache(intersection2, "ALL_OF", options8, keyName, processed, usedNames);
|
|
142186
142186
|
types.forEach((type) => {
|
|
142187
|
-
ast.params.push(parseAsTypeWithCache(
|
|
142187
|
+
ast.params.push(parseAsTypeWithCache(schema13, type, options8, keyName, processed, usedNames));
|
|
142188
142188
|
});
|
|
142189
|
-
(0, utils_1.log)("blue", "parser", "Types:", [...types], "Input:",
|
|
142189
|
+
(0, utils_1.log)("blue", "parser", "Types:", [...types], "Input:", schema13, "Output:", ast);
|
|
142190
142190
|
return ast;
|
|
142191
142191
|
}
|
|
142192
142192
|
if (types.size === 1) {
|
|
142193
142193
|
const type = [...types][0];
|
|
142194
|
-
const ast = parseAsTypeWithCache(
|
|
142195
|
-
(0, utils_1.log)("blue", "parser", "Type:", type, "Input:",
|
|
142194
|
+
const ast = parseAsTypeWithCache(schema13, type, options8, keyName, processed, usedNames);
|
|
142195
|
+
(0, utils_1.log)("blue", "parser", "Type:", type, "Input:", schema13, "Output:", ast);
|
|
142196
142196
|
return ast;
|
|
142197
142197
|
}
|
|
142198
142198
|
throw new ReferenceError("Expected intersection schema. Please file an issue on GitHub.");
|
|
142199
142199
|
}
|
|
142200
142200
|
exports.parse = parse11;
|
|
142201
|
-
function parseAsTypeWithCache(
|
|
142202
|
-
let cachedTypeMap = processed.get(
|
|
142201
|
+
function parseAsTypeWithCache(schema13, type, options8, keyName, processed = new Map, usedNames = new Set) {
|
|
142202
|
+
let cachedTypeMap = processed.get(schema13);
|
|
142203
142203
|
if (!cachedTypeMap) {
|
|
142204
142204
|
cachedTypeMap = new Map;
|
|
142205
|
-
processed.set(
|
|
142205
|
+
processed.set(schema13, cachedTypeMap);
|
|
142206
142206
|
}
|
|
142207
142207
|
const cachedAST = cachedTypeMap.get(type);
|
|
142208
142208
|
if (cachedAST) {
|
|
@@ -142210,10 +142210,10 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142210
142210
|
}
|
|
142211
142211
|
const ast = {};
|
|
142212
142212
|
cachedTypeMap.set(type, ast);
|
|
142213
|
-
return Object.assign(ast, parseNonLiteral(
|
|
142213
|
+
return Object.assign(ast, parseNonLiteral(schema13, type, options8, keyName, processed, usedNames));
|
|
142214
142214
|
}
|
|
142215
|
-
function parseBooleanSchema(
|
|
142216
|
-
if (
|
|
142215
|
+
function parseBooleanSchema(schema13, keyName, options8) {
|
|
142216
|
+
if (schema13) {
|
|
142217
142217
|
return {
|
|
142218
142218
|
keyName,
|
|
142219
142219
|
type: options8.unknownAny ? "UNKNOWN" : "ANY"
|
|
@@ -142224,157 +142224,157 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142224
142224
|
type: "NEVER"
|
|
142225
142225
|
};
|
|
142226
142226
|
}
|
|
142227
|
-
function parseLiteral(
|
|
142227
|
+
function parseLiteral(schema13, keyName) {
|
|
142228
142228
|
return {
|
|
142229
142229
|
keyName,
|
|
142230
|
-
params:
|
|
142230
|
+
params: schema13,
|
|
142231
142231
|
type: "LITERAL"
|
|
142232
142232
|
};
|
|
142233
142233
|
}
|
|
142234
|
-
function parseNonLiteral(
|
|
142235
|
-
const definitions = getDefinitionsMemoized((0, JSONSchema_1.getRootSchema)(
|
|
142236
|
-
const keyNameFromDefinition = (0, lodash_1.findKey)(definitions, (_10) => _10 ===
|
|
142234
|
+
function parseNonLiteral(schema13, type, options8, keyName, processed, usedNames) {
|
|
142235
|
+
const definitions = getDefinitionsMemoized((0, JSONSchema_1.getRootSchema)(schema13));
|
|
142236
|
+
const keyNameFromDefinition = (0, lodash_1.findKey)(definitions, (_10) => _10 === schema13);
|
|
142237
142237
|
switch (type) {
|
|
142238
142238
|
case "ALL_OF":
|
|
142239
142239
|
return {
|
|
142240
|
-
comment:
|
|
142241
|
-
deprecated:
|
|
142240
|
+
comment: schema13.description,
|
|
142241
|
+
deprecated: schema13.deprecated,
|
|
142242
142242
|
keyName,
|
|
142243
|
-
standaloneName: standaloneName(
|
|
142244
|
-
params:
|
|
142243
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142244
|
+
params: schema13.allOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142245
142245
|
type: "INTERSECTION"
|
|
142246
142246
|
};
|
|
142247
142247
|
case "ANY":
|
|
142248
|
-
return Object.assign(Object.assign({}, options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY), { comment:
|
|
142248
|
+
return Object.assign(Object.assign({}, options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY), { comment: schema13.description, deprecated: schema13.deprecated, keyName, standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8) });
|
|
142249
142249
|
case "ANY_OF":
|
|
142250
142250
|
return {
|
|
142251
|
-
comment:
|
|
142252
|
-
deprecated:
|
|
142251
|
+
comment: schema13.description,
|
|
142252
|
+
deprecated: schema13.deprecated,
|
|
142253
142253
|
keyName,
|
|
142254
|
-
standaloneName: standaloneName(
|
|
142255
|
-
params:
|
|
142254
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142255
|
+
params: schema13.anyOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142256
142256
|
type: "UNION"
|
|
142257
142257
|
};
|
|
142258
142258
|
case "BOOLEAN":
|
|
142259
142259
|
return {
|
|
142260
|
-
comment:
|
|
142261
|
-
deprecated:
|
|
142260
|
+
comment: schema13.description,
|
|
142261
|
+
deprecated: schema13.deprecated,
|
|
142262
142262
|
keyName,
|
|
142263
|
-
standaloneName: standaloneName(
|
|
142263
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142264
142264
|
type: "BOOLEAN"
|
|
142265
142265
|
};
|
|
142266
142266
|
case "CUSTOM_TYPE":
|
|
142267
142267
|
return {
|
|
142268
|
-
comment:
|
|
142269
|
-
deprecated:
|
|
142268
|
+
comment: schema13.description,
|
|
142269
|
+
deprecated: schema13.deprecated,
|
|
142270
142270
|
keyName,
|
|
142271
|
-
params:
|
|
142272
|
-
standaloneName: standaloneName(
|
|
142271
|
+
params: schema13.tsType,
|
|
142272
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142273
142273
|
type: "CUSTOM_TYPE"
|
|
142274
142274
|
};
|
|
142275
142275
|
case "NAMED_ENUM":
|
|
142276
142276
|
return {
|
|
142277
|
-
comment:
|
|
142278
|
-
deprecated:
|
|
142277
|
+
comment: schema13.description,
|
|
142278
|
+
deprecated: schema13.deprecated,
|
|
142279
142279
|
keyName,
|
|
142280
|
-
standaloneName: standaloneName(
|
|
142281
|
-
params:
|
|
142280
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition !== null && keyNameFromDefinition !== undefined ? keyNameFromDefinition : keyName, usedNames, options8),
|
|
142281
|
+
params: schema13.enum.map((_10, n5) => ({
|
|
142282
142282
|
ast: parseLiteral(_10, undefined),
|
|
142283
|
-
keyName:
|
|
142283
|
+
keyName: schema13.tsEnumNames[n5]
|
|
142284
142284
|
})),
|
|
142285
142285
|
type: "ENUM"
|
|
142286
142286
|
};
|
|
142287
142287
|
case "NAMED_SCHEMA":
|
|
142288
|
-
return newInterface(
|
|
142288
|
+
return newInterface(schema13, options8, processed, usedNames, keyName);
|
|
142289
142289
|
case "NEVER":
|
|
142290
142290
|
return {
|
|
142291
|
-
comment:
|
|
142292
|
-
deprecated:
|
|
142291
|
+
comment: schema13.description,
|
|
142292
|
+
deprecated: schema13.deprecated,
|
|
142293
142293
|
keyName,
|
|
142294
|
-
standaloneName: standaloneName(
|
|
142294
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142295
142295
|
type: "NEVER"
|
|
142296
142296
|
};
|
|
142297
142297
|
case "NULL":
|
|
142298
142298
|
return {
|
|
142299
|
-
comment:
|
|
142300
|
-
deprecated:
|
|
142299
|
+
comment: schema13.description,
|
|
142300
|
+
deprecated: schema13.deprecated,
|
|
142301
142301
|
keyName,
|
|
142302
|
-
standaloneName: standaloneName(
|
|
142302
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142303
142303
|
type: "NULL"
|
|
142304
142304
|
};
|
|
142305
142305
|
case "NUMBER":
|
|
142306
142306
|
return {
|
|
142307
|
-
comment:
|
|
142308
|
-
deprecated:
|
|
142307
|
+
comment: schema13.description,
|
|
142308
|
+
deprecated: schema13.deprecated,
|
|
142309
142309
|
keyName,
|
|
142310
|
-
standaloneName: standaloneName(
|
|
142310
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142311
142311
|
type: "NUMBER"
|
|
142312
142312
|
};
|
|
142313
142313
|
case "OBJECT":
|
|
142314
142314
|
return {
|
|
142315
|
-
comment:
|
|
142315
|
+
comment: schema13.description,
|
|
142316
142316
|
keyName,
|
|
142317
|
-
standaloneName: standaloneName(
|
|
142317
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142318
142318
|
type: "OBJECT",
|
|
142319
|
-
deprecated:
|
|
142319
|
+
deprecated: schema13.deprecated
|
|
142320
142320
|
};
|
|
142321
142321
|
case "ONE_OF":
|
|
142322
142322
|
return {
|
|
142323
|
-
comment:
|
|
142324
|
-
deprecated:
|
|
142323
|
+
comment: schema13.description,
|
|
142324
|
+
deprecated: schema13.deprecated,
|
|
142325
142325
|
keyName,
|
|
142326
|
-
standaloneName: standaloneName(
|
|
142327
|
-
params:
|
|
142326
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142327
|
+
params: schema13.oneOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142328
142328
|
type: "UNION"
|
|
142329
142329
|
};
|
|
142330
142330
|
case "REFERENCE":
|
|
142331
|
-
throw Error((0, util_1.format)("Refs should have been resolved by the resolver!",
|
|
142331
|
+
throw Error((0, util_1.format)("Refs should have been resolved by the resolver!", schema13));
|
|
142332
142332
|
case "STRING":
|
|
142333
142333
|
return {
|
|
142334
|
-
comment:
|
|
142335
|
-
deprecated:
|
|
142334
|
+
comment: schema13.description,
|
|
142335
|
+
deprecated: schema13.deprecated,
|
|
142336
142336
|
keyName,
|
|
142337
|
-
standaloneName: standaloneName(
|
|
142337
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142338
142338
|
type: "STRING"
|
|
142339
142339
|
};
|
|
142340
142340
|
case "TYPED_ARRAY":
|
|
142341
|
-
if (Array.isArray(
|
|
142342
|
-
const minItems2 =
|
|
142343
|
-
const maxItems2 =
|
|
142341
|
+
if (Array.isArray(schema13.items)) {
|
|
142342
|
+
const minItems2 = schema13.minItems;
|
|
142343
|
+
const maxItems2 = schema13.maxItems;
|
|
142344
142344
|
const arrayType = {
|
|
142345
|
-
comment:
|
|
142346
|
-
deprecated:
|
|
142345
|
+
comment: schema13.description,
|
|
142346
|
+
deprecated: schema13.deprecated,
|
|
142347
142347
|
keyName,
|
|
142348
142348
|
maxItems: maxItems2,
|
|
142349
142349
|
minItems: minItems2,
|
|
142350
|
-
standaloneName: standaloneName(
|
|
142351
|
-
params:
|
|
142350
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142351
|
+
params: schema13.items.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142352
142352
|
type: "TUPLE"
|
|
142353
142353
|
};
|
|
142354
|
-
if (
|
|
142354
|
+
if (schema13.additionalItems === true) {
|
|
142355
142355
|
arrayType.spreadParam = options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY;
|
|
142356
|
-
} else if (
|
|
142357
|
-
arrayType.spreadParam = parse11(
|
|
142356
|
+
} else if (schema13.additionalItems) {
|
|
142357
|
+
arrayType.spreadParam = parse11(schema13.additionalItems, options8, undefined, processed, usedNames);
|
|
142358
142358
|
}
|
|
142359
142359
|
return arrayType;
|
|
142360
142360
|
} else {
|
|
142361
142361
|
return {
|
|
142362
|
-
comment:
|
|
142363
|
-
deprecated:
|
|
142362
|
+
comment: schema13.description,
|
|
142363
|
+
deprecated: schema13.deprecated,
|
|
142364
142364
|
keyName,
|
|
142365
|
-
standaloneName: standaloneName(
|
|
142366
|
-
params: parse11(
|
|
142365
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142366
|
+
params: parse11(schema13.items, options8, `{keyNameFromDefinition}Items`, processed, usedNames),
|
|
142367
142367
|
type: "ARRAY"
|
|
142368
142368
|
};
|
|
142369
142369
|
}
|
|
142370
142370
|
case "UNION":
|
|
142371
142371
|
return {
|
|
142372
|
-
comment:
|
|
142373
|
-
deprecated:
|
|
142372
|
+
comment: schema13.description,
|
|
142373
|
+
deprecated: schema13.deprecated,
|
|
142374
142374
|
keyName,
|
|
142375
|
-
standaloneName: standaloneName(
|
|
142376
|
-
params:
|
|
142377
|
-
const member = Object.assign(Object.assign({}, (0, lodash_1.omit)(
|
|
142375
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142376
|
+
params: schema13.type.map((type2) => {
|
|
142377
|
+
const member = Object.assign(Object.assign({}, (0, lodash_1.omit)(schema13, "$id", "description", "title")), { type: type2 });
|
|
142378
142378
|
(0, utils_1.maybeStripDefault)(member);
|
|
142379
142379
|
(0, applySchemaTyping_1.applySchemaTyping)(member);
|
|
142380
142380
|
return parse11(member, options8, undefined, processed, usedNames);
|
|
@@ -142383,80 +142383,80 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142383
142383
|
};
|
|
142384
142384
|
case "UNNAMED_ENUM":
|
|
142385
142385
|
return {
|
|
142386
|
-
comment:
|
|
142387
|
-
deprecated:
|
|
142386
|
+
comment: schema13.description,
|
|
142387
|
+
deprecated: schema13.deprecated,
|
|
142388
142388
|
keyName,
|
|
142389
|
-
standaloneName: standaloneName(
|
|
142390
|
-
params:
|
|
142389
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142390
|
+
params: schema13.enum.map((_10) => parseLiteral(_10, undefined)),
|
|
142391
142391
|
type: "UNION"
|
|
142392
142392
|
};
|
|
142393
142393
|
case "UNNAMED_SCHEMA":
|
|
142394
|
-
return newInterface(
|
|
142394
|
+
return newInterface(schema13, options8, processed, usedNames, keyName, keyNameFromDefinition);
|
|
142395
142395
|
case "UNTYPED_ARRAY":
|
|
142396
|
-
const minItems =
|
|
142397
|
-
const maxItems = typeof
|
|
142396
|
+
const minItems = schema13.minItems;
|
|
142397
|
+
const maxItems = typeof schema13.maxItems === "number" ? schema13.maxItems : -1;
|
|
142398
142398
|
const params = options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY;
|
|
142399
142399
|
if (minItems > 0 || maxItems >= 0) {
|
|
142400
142400
|
return {
|
|
142401
|
-
comment:
|
|
142402
|
-
deprecated:
|
|
142401
|
+
comment: schema13.description,
|
|
142402
|
+
deprecated: schema13.deprecated,
|
|
142403
142403
|
keyName,
|
|
142404
|
-
maxItems:
|
|
142404
|
+
maxItems: schema13.maxItems,
|
|
142405
142405
|
minItems,
|
|
142406
142406
|
params: Array(Math.max(maxItems, minItems) || 0).fill(params),
|
|
142407
142407
|
spreadParam: maxItems >= 0 ? undefined : params,
|
|
142408
|
-
standaloneName: standaloneName(
|
|
142408
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142409
142409
|
type: "TUPLE"
|
|
142410
142410
|
};
|
|
142411
142411
|
}
|
|
142412
142412
|
return {
|
|
142413
|
-
comment:
|
|
142414
|
-
deprecated:
|
|
142413
|
+
comment: schema13.description,
|
|
142414
|
+
deprecated: schema13.deprecated,
|
|
142415
142415
|
keyName,
|
|
142416
142416
|
params,
|
|
142417
|
-
standaloneName: standaloneName(
|
|
142417
|
+
standaloneName: standaloneName(schema13, keyNameFromDefinition, usedNames, options8),
|
|
142418
142418
|
type: "ARRAY"
|
|
142419
142419
|
};
|
|
142420
142420
|
}
|
|
142421
142421
|
}
|
|
142422
|
-
function standaloneName(
|
|
142422
|
+
function standaloneName(schema13, keyNameFromDefinition, usedNames, options8) {
|
|
142423
142423
|
var _a7;
|
|
142424
|
-
const name2 = ((_a7 = options8.customName) === null || _a7 === undefined ? undefined : _a7.call(options8,
|
|
142424
|
+
const name2 = ((_a7 = options8.customName) === null || _a7 === undefined ? undefined : _a7.call(options8, schema13, keyNameFromDefinition)) || schema13.title || schema13.$id || keyNameFromDefinition;
|
|
142425
142425
|
if (name2) {
|
|
142426
142426
|
return (0, utils_1.generateName)(name2, usedNames);
|
|
142427
142427
|
}
|
|
142428
142428
|
}
|
|
142429
|
-
function newInterface(
|
|
142430
|
-
const name2 = standaloneName(
|
|
142429
|
+
function newInterface(schema13, options8, processed, usedNames, keyName, keyNameFromDefinition) {
|
|
142430
|
+
const name2 = standaloneName(schema13, keyNameFromDefinition, usedNames, options8);
|
|
142431
142431
|
return {
|
|
142432
|
-
comment:
|
|
142433
|
-
deprecated:
|
|
142432
|
+
comment: schema13.description,
|
|
142433
|
+
deprecated: schema13.deprecated,
|
|
142434
142434
|
keyName,
|
|
142435
|
-
params: parseSchema(
|
|
142435
|
+
params: parseSchema(schema13, options8, processed, usedNames, name2),
|
|
142436
142436
|
standaloneName: name2,
|
|
142437
|
-
superTypes: parseSuperTypes(
|
|
142437
|
+
superTypes: parseSuperTypes(schema13, options8, processed, usedNames),
|
|
142438
142438
|
type: "INTERFACE"
|
|
142439
142439
|
};
|
|
142440
142440
|
}
|
|
142441
|
-
function parseSuperTypes(
|
|
142442
|
-
const superTypes =
|
|
142441
|
+
function parseSuperTypes(schema13, options8, processed, usedNames) {
|
|
142442
|
+
const superTypes = schema13.extends;
|
|
142443
142443
|
if (!superTypes) {
|
|
142444
142444
|
return [];
|
|
142445
142445
|
}
|
|
142446
142446
|
return superTypes.map((_10) => parse11(_10, options8, undefined, processed, usedNames));
|
|
142447
142447
|
}
|
|
142448
|
-
function parseSchema(
|
|
142449
|
-
let asts = (0, lodash_1.map)(
|
|
142448
|
+
function parseSchema(schema13, options8, processed, usedNames, parentSchemaName) {
|
|
142449
|
+
let asts = (0, lodash_1.map)(schema13.properties, (value, key2) => ({
|
|
142450
142450
|
ast: parse11(value, options8, key2, processed, usedNames),
|
|
142451
142451
|
isPatternProperty: false,
|
|
142452
|
-
isRequired: (0, lodash_1.includes)(
|
|
142452
|
+
isRequired: (0, lodash_1.includes)(schema13.required || [], key2),
|
|
142453
142453
|
isUnreachableDefinition: false,
|
|
142454
142454
|
keyName: key2
|
|
142455
142455
|
}));
|
|
142456
142456
|
let singlePatternProperty = false;
|
|
142457
|
-
if (
|
|
142458
|
-
singlePatternProperty = !
|
|
142459
|
-
asts = asts.concat((0, lodash_1.map)(
|
|
142457
|
+
if (schema13.patternProperties) {
|
|
142458
|
+
singlePatternProperty = !schema13.additionalProperties && Object.keys(schema13.patternProperties).length === 1;
|
|
142459
|
+
asts = asts.concat((0, lodash_1.map)(schema13.patternProperties, (value, key2) => {
|
|
142460
142460
|
const ast = parse11(value, options8, key2, processed, usedNames);
|
|
142461
142461
|
const comment = `This interface was referenced by \`${parentSchemaName}\`'s JSON-Schema definition
|
|
142462
142462
|
via the \`patternProperty\` "${key2.replace("*/", "*\\/")}".`;
|
|
@@ -142466,14 +142466,14 @@ ${comment}` : comment;
|
|
|
142466
142466
|
return {
|
|
142467
142467
|
ast,
|
|
142468
142468
|
isPatternProperty: !singlePatternProperty,
|
|
142469
|
-
isRequired: singlePatternProperty || (0, lodash_1.includes)(
|
|
142469
|
+
isRequired: singlePatternProperty || (0, lodash_1.includes)(schema13.required || [], key2),
|
|
142470
142470
|
isUnreachableDefinition: false,
|
|
142471
142471
|
keyName: singlePatternProperty ? "[k: string]" : key2
|
|
142472
142472
|
};
|
|
142473
142473
|
}));
|
|
142474
142474
|
}
|
|
142475
142475
|
if (options8.unreachableDefinitions) {
|
|
142476
|
-
asts = asts.concat((0, lodash_1.map)(
|
|
142476
|
+
asts = asts.concat((0, lodash_1.map)(schema13.$defs, (value, key2) => {
|
|
142477
142477
|
const ast = parse11(value, options8, key2, processed, usedNames);
|
|
142478
142478
|
const comment = `This interface was referenced by \`${parentSchemaName}\`'s JSON-Schema
|
|
142479
142479
|
via the \`definition\` "${key2}".`;
|
|
@@ -142483,13 +142483,13 @@ ${comment}` : comment;
|
|
|
142483
142483
|
return {
|
|
142484
142484
|
ast,
|
|
142485
142485
|
isPatternProperty: false,
|
|
142486
|
-
isRequired: (0, lodash_1.includes)(
|
|
142486
|
+
isRequired: (0, lodash_1.includes)(schema13.required || [], key2),
|
|
142487
142487
|
isUnreachableDefinition: true,
|
|
142488
142488
|
keyName: key2
|
|
142489
142489
|
};
|
|
142490
142490
|
}));
|
|
142491
142491
|
}
|
|
142492
|
-
switch (
|
|
142492
|
+
switch (schema13.additionalProperties) {
|
|
142493
142493
|
case undefined:
|
|
142494
142494
|
case true:
|
|
142495
142495
|
if (singlePatternProperty) {
|
|
@@ -142506,7 +142506,7 @@ ${comment}` : comment;
|
|
|
142506
142506
|
return asts;
|
|
142507
142507
|
default:
|
|
142508
142508
|
return asts.concat({
|
|
142509
|
-
ast: parse11(
|
|
142509
|
+
ast: parse11(schema13.additionalProperties, options8, "[k: string]", processed, usedNames),
|
|
142510
142510
|
isPatternProperty: false,
|
|
142511
142511
|
isRequired: true,
|
|
142512
142512
|
isUnreachableDefinition: false,
|
|
@@ -142514,22 +142514,22 @@ ${comment}` : comment;
|
|
|
142514
142514
|
});
|
|
142515
142515
|
}
|
|
142516
142516
|
}
|
|
142517
|
-
function getDefinitions(
|
|
142518
|
-
if (processed.has(
|
|
142517
|
+
function getDefinitions(schema13, isSchema = true, processed = new Set) {
|
|
142518
|
+
if (processed.has(schema13)) {
|
|
142519
142519
|
return {};
|
|
142520
142520
|
}
|
|
142521
|
-
processed.add(
|
|
142522
|
-
if (Array.isArray(
|
|
142523
|
-
return
|
|
142521
|
+
processed.add(schema13);
|
|
142522
|
+
if (Array.isArray(schema13)) {
|
|
142523
|
+
return schema13.reduce((prev, cur) => Object.assign(Object.assign({}, prev), getDefinitions(cur, false, processed)), {});
|
|
142524
142524
|
}
|
|
142525
|
-
if ((0, lodash_1.isPlainObject)(
|
|
142526
|
-
return Object.assign(Object.assign({}, isSchema && hasDefinitions(
|
|
142525
|
+
if ((0, lodash_1.isPlainObject)(schema13)) {
|
|
142526
|
+
return Object.assign(Object.assign({}, isSchema && hasDefinitions(schema13) ? schema13.$defs : {}), Object.keys(schema13).reduce((prev, cur) => Object.assign(Object.assign({}, prev), getDefinitions(schema13[cur], false, processed)), {}));
|
|
142527
142527
|
}
|
|
142528
142528
|
return {};
|
|
142529
142529
|
}
|
|
142530
142530
|
var getDefinitionsMemoized = (0, lodash_1.memoize)(getDefinitions);
|
|
142531
|
-
function hasDefinitions(
|
|
142532
|
-
return "$defs" in
|
|
142531
|
+
function hasDefinitions(schema13) {
|
|
142532
|
+
return "$defs" in schema13;
|
|
142533
142533
|
}
|
|
142534
142534
|
});
|
|
142535
142535
|
|
|
@@ -144353,7 +144353,7 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144353
144353
|
var options_js_1 = require_options();
|
|
144354
144354
|
function normalizeArgs(_args) {
|
|
144355
144355
|
let path18;
|
|
144356
|
-
let
|
|
144356
|
+
let schema13;
|
|
144357
144357
|
let options8;
|
|
144358
144358
|
let callback;
|
|
144359
144359
|
const args = Array.prototype.slice.call(_args);
|
|
@@ -144363,15 +144363,15 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144363
144363
|
if (typeof args[0] === "string") {
|
|
144364
144364
|
path18 = args[0];
|
|
144365
144365
|
if (typeof args[2] === "object") {
|
|
144366
|
-
|
|
144366
|
+
schema13 = args[1];
|
|
144367
144367
|
options8 = args[2];
|
|
144368
144368
|
} else {
|
|
144369
|
-
|
|
144369
|
+
schema13 = undefined;
|
|
144370
144370
|
options8 = args[1];
|
|
144371
144371
|
}
|
|
144372
144372
|
} else {
|
|
144373
144373
|
path18 = "";
|
|
144374
|
-
|
|
144374
|
+
schema13 = args[0];
|
|
144375
144375
|
options8 = args[1];
|
|
144376
144376
|
}
|
|
144377
144377
|
try {
|
|
@@ -144379,12 +144379,12 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144379
144379
|
} catch (e8) {
|
|
144380
144380
|
console.error(`JSON Schema Ref Parser: Error normalizing options: ${e8}`);
|
|
144381
144381
|
}
|
|
144382
|
-
if (!options8.mutateInputSchema && typeof
|
|
144383
|
-
|
|
144382
|
+
if (!options8.mutateInputSchema && typeof schema13 === "object") {
|
|
144383
|
+
schema13 = JSON.parse(JSON.stringify(schema13));
|
|
144384
144384
|
}
|
|
144385
144385
|
return {
|
|
144386
144386
|
path: path18,
|
|
144387
|
-
schema:
|
|
144387
|
+
schema: schema13,
|
|
144388
144388
|
options: options8,
|
|
144389
144389
|
callback
|
|
144390
144390
|
};
|
|
@@ -145173,12 +145173,12 @@ var require_resolver = __commonJS((exports) => {
|
|
|
145173
145173
|
var json_schema_ref_parser_1 = require_lib3();
|
|
145174
145174
|
var utils_1 = require_utils7();
|
|
145175
145175
|
function dereference(schema_1, _a7) {
|
|
145176
|
-
return __awaiter(this, arguments, undefined, function* (
|
|
145177
|
-
(0, utils_1.log)("green", "dereferencer", "Dereferencing input schema:", cwd,
|
|
145176
|
+
return __awaiter(this, arguments, undefined, function* (schema13, { cwd, $refOptions }) {
|
|
145177
|
+
(0, utils_1.log)("green", "dereferencer", "Dereferencing input schema:", cwd, schema13);
|
|
145178
145178
|
const parser2 = new json_schema_ref_parser_1.$RefParser;
|
|
145179
145179
|
const dereferencedPaths = new WeakMap;
|
|
145180
|
-
const dereferencedSchema = yield parser2.dereference(cwd,
|
|
145181
|
-
dereferencedPaths.set(
|
|
145180
|
+
const dereferencedSchema = yield parser2.dereference(cwd, schema13, Object.assign(Object.assign({}, $refOptions), { dereference: Object.assign(Object.assign({}, $refOptions.dereference), { onDereference($ref, schema14) {
|
|
145181
|
+
dereferencedPaths.set(schema14, $ref);
|
|
145182
145182
|
} }) }));
|
|
145183
145183
|
return { dereferencedPaths, dereferencedSchema };
|
|
145184
145184
|
});
|
|
@@ -145192,46 +145192,46 @@ var require_validator = __commonJS((exports) => {
|
|
|
145192
145192
|
exports.validate = undefined;
|
|
145193
145193
|
var utils_1 = require_utils7();
|
|
145194
145194
|
var rules = new Map;
|
|
145195
|
-
rules.set("Enum members and tsEnumNames must be of the same length", (
|
|
145196
|
-
if (
|
|
145195
|
+
rules.set("Enum members and tsEnumNames must be of the same length", (schema13) => {
|
|
145196
|
+
if (schema13.enum && schema13.tsEnumNames && schema13.enum.length !== schema13.tsEnumNames.length) {
|
|
145197
145197
|
return false;
|
|
145198
145198
|
}
|
|
145199
145199
|
});
|
|
145200
|
-
rules.set("tsEnumNames must be an array of strings", (
|
|
145201
|
-
if (
|
|
145200
|
+
rules.set("tsEnumNames must be an array of strings", (schema13) => {
|
|
145201
|
+
if (schema13.tsEnumNames && schema13.tsEnumNames.some((_10) => typeof _10 !== "string")) {
|
|
145202
145202
|
return false;
|
|
145203
145203
|
}
|
|
145204
145204
|
});
|
|
145205
|
-
rules.set("When both maxItems and minItems are present, maxItems >= minItems", (
|
|
145206
|
-
const { maxItems, minItems } =
|
|
145205
|
+
rules.set("When both maxItems and minItems are present, maxItems >= minItems", (schema13) => {
|
|
145206
|
+
const { maxItems, minItems } = schema13;
|
|
145207
145207
|
if (typeof maxItems === "number" && typeof minItems === "number") {
|
|
145208
145208
|
return maxItems >= minItems;
|
|
145209
145209
|
}
|
|
145210
145210
|
});
|
|
145211
|
-
rules.set("When maxItems exists, maxItems >= 0", (
|
|
145212
|
-
const { maxItems } =
|
|
145211
|
+
rules.set("When maxItems exists, maxItems >= 0", (schema13) => {
|
|
145212
|
+
const { maxItems } = schema13;
|
|
145213
145213
|
if (typeof maxItems === "number") {
|
|
145214
145214
|
return maxItems >= 0;
|
|
145215
145215
|
}
|
|
145216
145216
|
});
|
|
145217
|
-
rules.set("When minItems exists, minItems >= 0", (
|
|
145218
|
-
const { minItems } =
|
|
145217
|
+
rules.set("When minItems exists, minItems >= 0", (schema13) => {
|
|
145218
|
+
const { minItems } = schema13;
|
|
145219
145219
|
if (typeof minItems === "number") {
|
|
145220
145220
|
return minItems >= 0;
|
|
145221
145221
|
}
|
|
145222
145222
|
});
|
|
145223
|
-
rules.set("deprecated must be a boolean", (
|
|
145224
|
-
const typeOfDeprecated = typeof
|
|
145223
|
+
rules.set("deprecated must be a boolean", (schema13) => {
|
|
145224
|
+
const typeOfDeprecated = typeof schema13.deprecated;
|
|
145225
145225
|
return typeOfDeprecated === "boolean" || typeOfDeprecated === "undefined";
|
|
145226
145226
|
});
|
|
145227
|
-
function validate2(
|
|
145227
|
+
function validate2(schema13, filename) {
|
|
145228
145228
|
const errors5 = [];
|
|
145229
145229
|
rules.forEach((rule, ruleName) => {
|
|
145230
|
-
(0, utils_1.traverse)(
|
|
145231
|
-
if (rule(
|
|
145230
|
+
(0, utils_1.traverse)(schema13, (schema14, key2) => {
|
|
145231
|
+
if (rule(schema14) === false) {
|
|
145232
145232
|
errors5.push(`Error at key "${key2}" in file "${filename}": ${ruleName}`);
|
|
145233
145233
|
}
|
|
145234
|
-
return
|
|
145234
|
+
return schema14;
|
|
145235
145235
|
});
|
|
145236
145236
|
});
|
|
145237
145237
|
return errors5;
|
|
@@ -145245,25 +145245,25 @@ var require_linker = __commonJS((exports) => {
|
|
|
145245
145245
|
exports.link = undefined;
|
|
145246
145246
|
var JSONSchema_1 = require_JSONSchema();
|
|
145247
145247
|
var lodash_1 = require_lodash8();
|
|
145248
|
-
function link2(
|
|
145249
|
-
if (!Array.isArray(
|
|
145250
|
-
return
|
|
145248
|
+
function link2(schema13, parent = null) {
|
|
145249
|
+
if (!Array.isArray(schema13) && !(0, lodash_1.isPlainObject)(schema13)) {
|
|
145250
|
+
return schema13;
|
|
145251
145251
|
}
|
|
145252
|
-
if (
|
|
145253
|
-
return
|
|
145252
|
+
if (schema13.hasOwnProperty(JSONSchema_1.Parent)) {
|
|
145253
|
+
return schema13;
|
|
145254
145254
|
}
|
|
145255
|
-
Object.defineProperty(
|
|
145255
|
+
Object.defineProperty(schema13, JSONSchema_1.Parent, {
|
|
145256
145256
|
enumerable: false,
|
|
145257
145257
|
value: parent,
|
|
145258
145258
|
writable: false
|
|
145259
145259
|
});
|
|
145260
|
-
if (Array.isArray(
|
|
145261
|
-
|
|
145260
|
+
if (Array.isArray(schema13)) {
|
|
145261
|
+
schema13.forEach((child) => link2(child, schema13));
|
|
145262
145262
|
}
|
|
145263
|
-
for (const key2 in
|
|
145264
|
-
link2(
|
|
145263
|
+
for (const key2 in schema13) {
|
|
145264
|
+
link2(schema13[key2], schema13);
|
|
145265
145265
|
}
|
|
145266
|
-
return
|
|
145266
|
+
return schema13;
|
|
145267
145267
|
}
|
|
145268
145268
|
exports.link = link2;
|
|
145269
145269
|
});
|
|
@@ -145355,8 +145355,8 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145355
145355
|
unknownAny: true
|
|
145356
145356
|
};
|
|
145357
145357
|
function compileFromFile(filename, options8 = exports.DEFAULT_OPTIONS) {
|
|
145358
|
-
const
|
|
145359
|
-
return compile(
|
|
145358
|
+
const schema13 = parseAsJSONSchema(filename);
|
|
145359
|
+
return compile(schema13, (0, utils_1.stripExtension)(filename), Object.assign({ cwd: (0, path_1.dirname)(filename) }, options8));
|
|
145360
145360
|
}
|
|
145361
145361
|
exports.compileFromFile = compileFromFile;
|
|
145362
145362
|
function parseAsJSONSchema(filename) {
|
|
@@ -145366,7 +145366,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145366
145366
|
return (0, utils_1.parseFileAsJSONSchema)(filename, contents.toString());
|
|
145367
145367
|
}
|
|
145368
145368
|
function compile(schema_1, name_1) {
|
|
145369
|
-
return __awaiter(this, arguments, undefined, function* (
|
|
145369
|
+
return __awaiter(this, arguments, undefined, function* (schema13, name2, options8 = {}) {
|
|
145370
145370
|
(0, optionValidator_1.validateOptions)(options8);
|
|
145371
145371
|
const _options = (0, lodash_1.merge)({}, exports.DEFAULT_OPTIONS, options8);
|
|
145372
145372
|
const start = Date.now();
|
|
@@ -145376,7 +145376,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145376
145376
|
if (!(0, lodash_1.endsWith)(_options.cwd, "/")) {
|
|
145377
145377
|
_options.cwd += "/";
|
|
145378
145378
|
}
|
|
145379
|
-
const _schema = (0, lodash_1.cloneDeep)(
|
|
145379
|
+
const _schema = (0, lodash_1.cloneDeep)(schema13);
|
|
145380
145380
|
const { dereferencedPaths, dereferencedSchema } = yield (0, resolver_1.dereference)(_schema, _options);
|
|
145381
145381
|
if (process.env.VERBOSE) {
|
|
145382
145382
|
if ((0, util_1.isDeepStrictEqual)(_schema, dereferencedSchema)) {
|
|
@@ -255596,6 +255596,136 @@ function getSiteCommand() {
|
|
|
255596
255596
|
return new Command("site").description("Manage app site (frontend app)").addCommand(getSiteDeployCommand()).addCommand(getSiteOpenCommand());
|
|
255597
255597
|
}
|
|
255598
255598
|
|
|
255599
|
+
// src/core/slug/schema.ts
|
|
255600
|
+
var AppSlugResponseSchema = exports_external.object({ slug: exports_external.string().nullable().optional() }).transform((data) => ({ slug: data.slug ?? null }));
|
|
255601
|
+
var SlugSuggestionsSchema = exports_external.object({
|
|
255602
|
+
suggestions: exports_external.array(exports_external.string())
|
|
255603
|
+
});
|
|
255604
|
+
|
|
255605
|
+
// src/core/slug/api.ts
|
|
255606
|
+
async function getSlug() {
|
|
255607
|
+
const { id } = getAppContext();
|
|
255608
|
+
let response;
|
|
255609
|
+
try {
|
|
255610
|
+
response = await base44Client.get(`api/apps/${id}`);
|
|
255611
|
+
} catch (error48) {
|
|
255612
|
+
throw await ApiError.fromHttpError(error48, "fetching app slug");
|
|
255613
|
+
}
|
|
255614
|
+
const result = AppSlugResponseSchema.safeParse(await response.json());
|
|
255615
|
+
if (!result.success) {
|
|
255616
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
255617
|
+
}
|
|
255618
|
+
return result.data;
|
|
255619
|
+
}
|
|
255620
|
+
async function updateSlug(slug) {
|
|
255621
|
+
const appClient = getAppClient();
|
|
255622
|
+
const request = { slug };
|
|
255623
|
+
let response;
|
|
255624
|
+
try {
|
|
255625
|
+
response = await appClient.patch("metadata/slug", { json: request });
|
|
255626
|
+
} catch (error48) {
|
|
255627
|
+
const apiError = await ApiError.fromHttpError(error48, "updating slug");
|
|
255628
|
+
const suggestions = SlugSuggestionsSchema.safeParse(apiError.responseBody).data?.suggestions;
|
|
255629
|
+
if (suggestions && suggestions.length > 0) {
|
|
255630
|
+
apiError.hints.unshift({
|
|
255631
|
+
message: `Available alternatives: ${suggestions.join(", ")}`
|
|
255632
|
+
});
|
|
255633
|
+
}
|
|
255634
|
+
throw apiError;
|
|
255635
|
+
}
|
|
255636
|
+
const result = AppSlugResponseSchema.safeParse(await response.json());
|
|
255637
|
+
if (!result.success) {
|
|
255638
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
255639
|
+
}
|
|
255640
|
+
return result.data;
|
|
255641
|
+
}
|
|
255642
|
+
// src/cli/commands/slug/shared.ts
|
|
255643
|
+
function toJsonStdout4(result) {
|
|
255644
|
+
return `${JSON.stringify(result, null, 2)}
|
|
255645
|
+
`;
|
|
255646
|
+
}
|
|
255647
|
+
function logAppUrl(url2, log) {
|
|
255648
|
+
log.message(`${theme.styles.header("URL")}: ${theme.colors.links(url2)}`);
|
|
255649
|
+
}
|
|
255650
|
+
|
|
255651
|
+
// src/cli/commands/slug/reset.ts
|
|
255652
|
+
async function resetSlugAction({
|
|
255653
|
+
log,
|
|
255654
|
+
runTask: runTask2,
|
|
255655
|
+
jsonMode
|
|
255656
|
+
}) {
|
|
255657
|
+
const result = await runTask2("Resetting slug...", async () => {
|
|
255658
|
+
const updated = await updateSlug(null);
|
|
255659
|
+
return { slug: updated.slug, url: await getSiteUrl() };
|
|
255660
|
+
}, { errorMessage: "Failed to reset slug" });
|
|
255661
|
+
if (jsonMode) {
|
|
255662
|
+
return {
|
|
255663
|
+
outroMessage: `Slug reset to ${result.slug}`,
|
|
255664
|
+
stdout: toJsonStdout4(result)
|
|
255665
|
+
};
|
|
255666
|
+
}
|
|
255667
|
+
log.message(`${theme.styles.header("Slug")}: ${theme.styles.bold(result.slug ?? "")}`);
|
|
255668
|
+
logAppUrl(result.url, log);
|
|
255669
|
+
return { outroMessage: `Slug reset to ${result.slug}` };
|
|
255670
|
+
}
|
|
255671
|
+
function getSlugResetCommand() {
|
|
255672
|
+
return new Base44Command("reset").description("Reset the slug to an auto-generated one").action(resetSlugAction);
|
|
255673
|
+
}
|
|
255674
|
+
|
|
255675
|
+
// src/cli/commands/slug/set.ts
|
|
255676
|
+
async function setSlugAction({ log, runTask: runTask2, jsonMode }, slug) {
|
|
255677
|
+
const result = await runTask2(`Setting slug to ${slug}...`, async () => {
|
|
255678
|
+
const { slug: previousSlug } = await getSlug();
|
|
255679
|
+
const updated = await updateSlug(slug);
|
|
255680
|
+
return { previousSlug, slug: updated.slug, url: await getSiteUrl() };
|
|
255681
|
+
}, { errorMessage: "Failed to update slug" });
|
|
255682
|
+
if (jsonMode) {
|
|
255683
|
+
return {
|
|
255684
|
+
outroMessage: `Slug set to ${result.slug}`,
|
|
255685
|
+
stdout: toJsonStdout4(result)
|
|
255686
|
+
};
|
|
255687
|
+
}
|
|
255688
|
+
log.message(`${theme.styles.header("Slug")}: ${result.previousSlug ?? "(none)"} ${theme.styles.dim("→")} ${theme.styles.bold(result.slug ?? "")}`);
|
|
255689
|
+
logAppUrl(result.url, log);
|
|
255690
|
+
return { outroMessage: `Slug set to ${result.slug}` };
|
|
255691
|
+
}
|
|
255692
|
+
function getSlugSetCommand() {
|
|
255693
|
+
return new Base44Command("set").description("Set a custom slug for this app").argument("<slug>", "New slug, e.g. my-app (3-50 chars: lowercase letters, numbers, hyphens)").action(setSlugAction);
|
|
255694
|
+
}
|
|
255695
|
+
|
|
255696
|
+
// src/cli/commands/slug/show.ts
|
|
255697
|
+
async function showSlugAction({
|
|
255698
|
+
log,
|
|
255699
|
+
runTask: runTask2,
|
|
255700
|
+
jsonMode
|
|
255701
|
+
}) {
|
|
255702
|
+
const { slug, url: url2 } = await runTask2("Fetching slug...", async () => {
|
|
255703
|
+
const { slug: slug2 } = await getSlug();
|
|
255704
|
+
return { slug: slug2, url: slug2 ? await getSiteUrl() : null };
|
|
255705
|
+
}, { errorMessage: "Failed to fetch slug" });
|
|
255706
|
+
if (jsonMode) {
|
|
255707
|
+
return {
|
|
255708
|
+
outroMessage: slug ? `Slug: ${slug}` : "This app has no slug yet",
|
|
255709
|
+
stdout: toJsonStdout4({ slug, url: url2 })
|
|
255710
|
+
};
|
|
255711
|
+
}
|
|
255712
|
+
if (!slug) {
|
|
255713
|
+
return {
|
|
255714
|
+
outroMessage: "This app has no slug yet — set one with 'base44 slug set <slug>'"
|
|
255715
|
+
};
|
|
255716
|
+
}
|
|
255717
|
+
log.message(`${theme.styles.header("Slug")}: ${theme.styles.bold(slug)}`);
|
|
255718
|
+
if (url2) {
|
|
255719
|
+
logAppUrl(url2, log);
|
|
255720
|
+
}
|
|
255721
|
+
return { outroMessage: `Slug: ${slug}` };
|
|
255722
|
+
}
|
|
255723
|
+
|
|
255724
|
+
// src/cli/commands/slug/index.ts
|
|
255725
|
+
function getSlugCommand() {
|
|
255726
|
+
return new Base44Command("slug").description("Show or change the app's URL slug (its public subdomain)").allowExcessArguments(false).action(showSlugAction).addCommand(getSlugSetCommand()).addCommand(getSlugResetCommand());
|
|
255727
|
+
}
|
|
255728
|
+
|
|
255599
255729
|
// src/core/types/generator.ts
|
|
255600
255730
|
var import_common_tags = __toESM(require_lib2(), 1);
|
|
255601
255731
|
var import_json_schema_to_typescript = __toESM(require_src3(), 1);
|
|
@@ -255652,9 +255782,9 @@ async function generateContent(input) {
|
|
|
255652
255782
|
`);
|
|
255653
255783
|
}
|
|
255654
255784
|
async function compileEntity(entity2) {
|
|
255655
|
-
const { name: name2, source: _source, ...
|
|
255785
|
+
const { name: name2, source: _source, ...schema13 } = entity2;
|
|
255656
255786
|
const jsonSchema = {
|
|
255657
|
-
...
|
|
255787
|
+
...schema13,
|
|
255658
255788
|
title: name2,
|
|
255659
255789
|
additionalProperties: false
|
|
255660
255790
|
};
|
|
@@ -256397,22 +256527,22 @@ class Database {
|
|
|
256397
256527
|
this.schemas.clear();
|
|
256398
256528
|
}
|
|
256399
256529
|
validate(entityName, record2, partial2 = false) {
|
|
256400
|
-
const
|
|
256401
|
-
if (!
|
|
256530
|
+
const schema13 = this.schemas.get(this.normalizeName(entityName));
|
|
256531
|
+
if (!schema13) {
|
|
256402
256532
|
throw new Error(`Entity "${entityName}" not found`);
|
|
256403
256533
|
}
|
|
256404
|
-
return this.validator.validate(record2,
|
|
256534
|
+
return this.validator.validate(record2, schema13, partial2);
|
|
256405
256535
|
}
|
|
256406
256536
|
prepareRecord(entityName, record2, partial2 = false) {
|
|
256407
|
-
const
|
|
256408
|
-
if (!
|
|
256537
|
+
const schema13 = this.schemas.get(this.normalizeName(entityName));
|
|
256538
|
+
if (!schema13) {
|
|
256409
256539
|
throw new Error(`Entity "${entityName}" not found`);
|
|
256410
256540
|
}
|
|
256411
|
-
const filteredRecord = this.validator.filterFields(record2,
|
|
256541
|
+
const filteredRecord = this.validator.filterFields(record2, schema13);
|
|
256412
256542
|
if (partial2) {
|
|
256413
256543
|
return filteredRecord;
|
|
256414
256544
|
}
|
|
256415
|
-
return this.validator.applyDefaults(filteredRecord,
|
|
256545
|
+
return this.validator.applyDefaults(filteredRecord, schema13);
|
|
256416
256546
|
}
|
|
256417
256547
|
normalizeName(entityName) {
|
|
256418
256548
|
return entityName.toLowerCase();
|
|
@@ -256706,13 +256836,13 @@ function checkRLS(rule, record2, user) {
|
|
|
256706
256836
|
return false;
|
|
256707
256837
|
return evaluateCondition(rule, record2, user);
|
|
256708
256838
|
}
|
|
256709
|
-
function applyFLS(record2,
|
|
256839
|
+
function applyFLS(record2, schema13, user, operation) {
|
|
256710
256840
|
if (Array.isArray(record2)) {
|
|
256711
|
-
return record2.map((r5) => applyFLS(r5,
|
|
256841
|
+
return record2.map((r5) => applyFLS(r5, schema13, user, operation));
|
|
256712
256842
|
}
|
|
256713
256843
|
const result = {};
|
|
256714
256844
|
for (const [key2, value] of Object.entries(record2)) {
|
|
256715
|
-
const rule =
|
|
256845
|
+
const rule = schema13.properties[key2]?.rls?.[operation];
|
|
256716
256846
|
if (rule === undefined || checkRLS(rule, record2, user)) {
|
|
256717
256847
|
result[key2] = value;
|
|
256718
256848
|
}
|
|
@@ -256940,14 +257070,14 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
256940
257070
|
res.status(404).json({ error: `Entity "${entityName}" not found` });
|
|
256941
257071
|
return;
|
|
256942
257072
|
}
|
|
256943
|
-
const
|
|
256944
|
-
if (!
|
|
257073
|
+
const schema13 = db2.getSchema(entityName);
|
|
257074
|
+
if (!schema13) {
|
|
256945
257075
|
res.status(404).json({ error: `Schema for "${entityName}" not found` });
|
|
256946
257076
|
return;
|
|
256947
257077
|
}
|
|
256948
257078
|
const currentUserResult = await resolveCurrentUser(db2, req);
|
|
256949
257079
|
const currentUser = currentUserResult.ok ? currentUserResult.user : undefined;
|
|
256950
|
-
await handler(req, res, collection,
|
|
257080
|
+
await handler(req, res, collection, schema13, currentUser);
|
|
256951
257081
|
};
|
|
256952
257082
|
}
|
|
256953
257083
|
function emit(appId, entityName, type, data) {
|
|
@@ -256965,19 +257095,19 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
256965
257095
|
}
|
|
256966
257096
|
broadcast(appId, entityName, createData(data));
|
|
256967
257097
|
}
|
|
256968
|
-
function prepareCreateRecord(entityName, body,
|
|
257098
|
+
function prepareCreateRecord(entityName, body, schema13, currentUser, now) {
|
|
256969
257099
|
const { _id, ...recordBody } = body;
|
|
256970
257100
|
const ownerFields = {
|
|
256971
257101
|
created_by: currentUser?.email,
|
|
256972
257102
|
created_by_id: currentUser?.id
|
|
256973
257103
|
};
|
|
256974
|
-
if (!checkRLS(
|
|
257104
|
+
if (!checkRLS(schema13.rls?.create, {
|
|
256975
257105
|
...recordBody,
|
|
256976
257106
|
...ownerFields
|
|
256977
257107
|
}, currentUser)) {
|
|
256978
257108
|
return;
|
|
256979
257109
|
}
|
|
256980
|
-
const filteredBody = applyFLS(db2.prepareRecord(entityName, recordBody),
|
|
257110
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, recordBody), schema13, currentUser, "write");
|
|
256981
257111
|
db2.validate(entityName, filteredBody);
|
|
256982
257112
|
return {
|
|
256983
257113
|
...filteredBody,
|
|
@@ -256989,7 +257119,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
256989
257119
|
}
|
|
256990
257120
|
const userRouter = createUserRouter(db2, logger2);
|
|
256991
257121
|
router.use("/User", userRouter);
|
|
256992
|
-
router.get("/:entityName/:id", withCollection(async (req, res, collection,
|
|
257122
|
+
router.get("/:entityName/:id", withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
256993
257123
|
const { entityName, id: id2 } = req.params;
|
|
256994
257124
|
try {
|
|
256995
257125
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -256997,27 +257127,27 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
256997
257127
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
256998
257128
|
return;
|
|
256999
257129
|
}
|
|
257000
|
-
if (!checkRLS(
|
|
257130
|
+
if (!checkRLS(schema13.rls?.read, doc2, currentUser)) {
|
|
257001
257131
|
res.status(404).json({
|
|
257002
257132
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
257003
257133
|
});
|
|
257004
257134
|
return;
|
|
257005
257135
|
}
|
|
257006
|
-
const result = applyFLS(stripInternalFields(doc2),
|
|
257136
|
+
const result = applyFLS(stripInternalFields(doc2), schema13, currentUser, "read");
|
|
257007
257137
|
res.json(result);
|
|
257008
257138
|
} catch (error48) {
|
|
257009
257139
|
logger2.error(`Error in GET /${entityName}/${id2}:`, error48);
|
|
257010
257140
|
res.status(500).json({ error: "Internal server error" });
|
|
257011
257141
|
}
|
|
257012
257142
|
}));
|
|
257013
|
-
router.get("/:entityName", withCollection(async (req, res, collection,
|
|
257143
|
+
router.get("/:entityName", withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257014
257144
|
const { entityName } = req.params;
|
|
257015
257145
|
try {
|
|
257016
257146
|
let results = stripInternalFields(await queryEntity(collection, req.query));
|
|
257017
|
-
if (
|
|
257018
|
-
results = results.filter((doc2) => checkRLS(
|
|
257147
|
+
if (schema13.rls?.read !== undefined && schema13.rls.read !== true) {
|
|
257148
|
+
results = results.filter((doc2) => checkRLS(schema13.rls.read, doc2, currentUser));
|
|
257019
257149
|
}
|
|
257020
|
-
results = results.map((doc2) => applyFLS(doc2,
|
|
257150
|
+
results = results.map((doc2) => applyFLS(doc2, schema13, currentUser, "read"));
|
|
257021
257151
|
res.json(results);
|
|
257022
257152
|
} catch (error48) {
|
|
257023
257153
|
if (error48 instanceof InvalidInputError) {
|
|
@@ -257028,16 +257158,16 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257028
257158
|
}
|
|
257029
257159
|
}
|
|
257030
257160
|
}));
|
|
257031
|
-
router.post("/:entityName", parseBody, withCollection(async (req, res, collection,
|
|
257161
|
+
router.post("/:entityName", parseBody, withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257032
257162
|
const { appId, entityName } = req.params;
|
|
257033
257163
|
try {
|
|
257034
257164
|
const now = new Date().toISOString();
|
|
257035
|
-
const record2 = prepareCreateRecord(entityName, req.body,
|
|
257165
|
+
const record2 = prepareCreateRecord(entityName, req.body, schema13, currentUser, now);
|
|
257036
257166
|
if (!record2) {
|
|
257037
257167
|
res.status(403).json({ error: "Permission denied" });
|
|
257038
257168
|
return;
|
|
257039
257169
|
}
|
|
257040
|
-
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)),
|
|
257170
|
+
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)), schema13, currentUser, "read");
|
|
257041
257171
|
emit(appId, entityName, "create", inserted);
|
|
257042
257172
|
res.status(201).json(inserted);
|
|
257043
257173
|
} catch (error48) {
|
|
@@ -257049,7 +257179,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257049
257179
|
res.status(500).json({ error: "Internal server error" });
|
|
257050
257180
|
}
|
|
257051
257181
|
}));
|
|
257052
|
-
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection,
|
|
257182
|
+
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257053
257183
|
const { appId, entityName } = req.params;
|
|
257054
257184
|
if (!Array.isArray(req.body)) {
|
|
257055
257185
|
res.status(400).json({ error: "Request body must be an array" });
|
|
@@ -257059,14 +257189,14 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257059
257189
|
const now = new Date().toISOString();
|
|
257060
257190
|
const records = [];
|
|
257061
257191
|
for (const body of req.body) {
|
|
257062
|
-
const record2 = prepareCreateRecord(entityName, body,
|
|
257192
|
+
const record2 = prepareCreateRecord(entityName, body, schema13, currentUser, now);
|
|
257063
257193
|
if (!record2) {
|
|
257064
257194
|
res.status(403).json({ error: "Permission denied" });
|
|
257065
257195
|
return;
|
|
257066
257196
|
}
|
|
257067
257197
|
records.push(record2);
|
|
257068
257198
|
}
|
|
257069
|
-
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(records)),
|
|
257199
|
+
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(records)), schema13, currentUser, "read");
|
|
257070
257200
|
emit(appId, entityName, "create", inserted);
|
|
257071
257201
|
res.status(201).json(inserted);
|
|
257072
257202
|
} catch (error48) {
|
|
@@ -257078,24 +257208,24 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257078
257208
|
res.status(500).json({ error: "Internal server error" });
|
|
257079
257209
|
}
|
|
257080
257210
|
}));
|
|
257081
|
-
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection,
|
|
257211
|
+
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257082
257212
|
const { appId, entityName, id: id2 } = req.params;
|
|
257083
257213
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
257084
257214
|
try {
|
|
257085
|
-
if (
|
|
257215
|
+
if (schema13.rls?.update !== undefined) {
|
|
257086
257216
|
const existing = await collection.findOneAsync({ id: id2 });
|
|
257087
257217
|
if (!existing) {
|
|
257088
257218
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
257089
257219
|
return;
|
|
257090
257220
|
}
|
|
257091
|
-
if (!checkRLS(
|
|
257221
|
+
if (!checkRLS(schema13.rls.update, existing, currentUser)) {
|
|
257092
257222
|
res.status(404).json({
|
|
257093
257223
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
257094
257224
|
});
|
|
257095
257225
|
return;
|
|
257096
257226
|
}
|
|
257097
257227
|
}
|
|
257098
|
-
const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true),
|
|
257228
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true), schema13, currentUser, "write");
|
|
257099
257229
|
db2.validate(entityName, filteredBody, true);
|
|
257100
257230
|
const updateData = {
|
|
257101
257231
|
...filteredBody,
|
|
@@ -257106,7 +257236,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257106
257236
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
257107
257237
|
return;
|
|
257108
257238
|
}
|
|
257109
|
-
const updated = applyFLS(stripInternalFields(result.affectedDocuments),
|
|
257239
|
+
const updated = applyFLS(stripInternalFields(result.affectedDocuments), schema13, currentUser, "read");
|
|
257110
257240
|
emit(appId, entityName, "update", updated);
|
|
257111
257241
|
res.json(updated);
|
|
257112
257242
|
} catch (error48) {
|
|
@@ -257118,7 +257248,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257118
257248
|
res.status(500).json({ error: "Internal server error" });
|
|
257119
257249
|
}
|
|
257120
257250
|
}));
|
|
257121
|
-
router.delete("/:entityName/:id", withCollection(async (req, res, collection,
|
|
257251
|
+
router.delete("/:entityName/:id", withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257122
257252
|
const { appId, entityName, id: id2 } = req.params;
|
|
257123
257253
|
try {
|
|
257124
257254
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -257126,7 +257256,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257126
257256
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
257127
257257
|
return;
|
|
257128
257258
|
}
|
|
257129
|
-
if (!checkRLS(
|
|
257259
|
+
if (!checkRLS(schema13.rls?.delete, doc2, currentUser)) {
|
|
257130
257260
|
res.status(404).json({
|
|
257131
257261
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
257132
257262
|
});
|
|
@@ -257140,11 +257270,11 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
257140
257270
|
res.status(500).json({ error: "Internal server error" });
|
|
257141
257271
|
}
|
|
257142
257272
|
}));
|
|
257143
|
-
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection,
|
|
257273
|
+
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection, schema13, currentUser) => {
|
|
257144
257274
|
const { entityName } = req.params;
|
|
257145
257275
|
try {
|
|
257146
257276
|
const query = req.body || {};
|
|
257147
|
-
const rlsDelete =
|
|
257277
|
+
const rlsDelete = schema13?.rls?.delete;
|
|
257148
257278
|
if (rlsDelete !== undefined && rlsDelete !== true) {
|
|
257149
257279
|
if (rlsDelete === false && currentUser?.is_service !== true) {
|
|
257150
257280
|
res.status(403).json({ error: "Permission denied" });
|
|
@@ -259509,6 +259639,7 @@ function createProgram(context) {
|
|
|
259509
259639
|
program2.addCommand(getPromoteCommand());
|
|
259510
259640
|
program2.addCommand(getRollbackCommand());
|
|
259511
259641
|
program2.addCommand(getDomainsCommand());
|
|
259642
|
+
program2.addCommand(getSlugCommand());
|
|
259512
259643
|
program2.addCommand(getSecretsCommand());
|
|
259513
259644
|
program2.addCommand(getSandboxCommand());
|
|
259514
259645
|
program2.addCommand(getAuthCommand());
|
|
@@ -263764,4 +263895,4 @@ export {
|
|
|
263764
263895
|
CLIExitError
|
|
263765
263896
|
};
|
|
263766
263897
|
|
|
263767
|
-
//# debugId=
|
|
263898
|
+
//# debugId=6EF80DE0464F970A64756E2164756E21
|