@base44-preview/cli 0.1.8-pr.584.371343c → 0.1.8-pr.584.ae3c2f4
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 +583 -586
- package/dist/cli/index.js.map +7 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -119578,11 +119578,11 @@ function chooseDescription(descriptions, printWidth) {
|
|
|
119578
119578
|
return firstWidth > printWidth && firstWidth > secondWidth ? secondDescription : firstDescription;
|
|
119579
119579
|
}
|
|
119580
119580
|
function createSchema(SchemaConstructor, parameters) {
|
|
119581
|
-
const
|
|
119582
|
-
const subSchema = Object.create(
|
|
119581
|
+
const schema12 = new SchemaConstructor(parameters);
|
|
119582
|
+
const subSchema = Object.create(schema12);
|
|
119583
119583
|
for (const handlerKey of HANDLER_KEYS) {
|
|
119584
119584
|
if (handlerKey in parameters) {
|
|
119585
|
-
subSchema[handlerKey] = normalizeHandler(parameters[handlerKey],
|
|
119585
|
+
subSchema[handlerKey] = normalizeHandler(parameters[handlerKey], schema12, Schema2.prototype[handlerKey].length);
|
|
119586
119586
|
}
|
|
119587
119587
|
}
|
|
119588
119588
|
return subSchema;
|
|
@@ -120896,7 +120896,7 @@ function parse42(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
120896
120896
|
}
|
|
120897
120897
|
return res;
|
|
120898
120898
|
}
|
|
120899
|
-
async function
|
|
120899
|
+
async function readFile6(file2) {
|
|
120900
120900
|
if (isUrlString(file2)) {
|
|
120901
120901
|
file2 = new URL(file2);
|
|
120902
120902
|
}
|
|
@@ -122922,9 +122922,9 @@ function optionInfoToSchema(optionInfo, {
|
|
|
122922
122922
|
throw new Error(`Unexpected type ${optionInfo.type}`);
|
|
122923
122923
|
}
|
|
122924
122924
|
if (optionInfo.exception) {
|
|
122925
|
-
parameters.validate = (value,
|
|
122925
|
+
parameters.validate = (value, schema12, utils3) => optionInfo.exception(value) || schema12.validate(value, utils3);
|
|
122926
122926
|
} else {
|
|
122927
|
-
parameters.validate = (value,
|
|
122927
|
+
parameters.validate = (value, schema12, utils3) => value === undefined || schema12.validate(value, utils3);
|
|
122928
122928
|
}
|
|
122929
122929
|
if (optionInfo.redirect) {
|
|
122930
122930
|
handlers.redirect = (value) => !value ? undefined : {
|
|
@@ -122939,7 +122939,7 @@ function optionInfoToSchema(optionInfo, {
|
|
|
122939
122939
|
}
|
|
122940
122940
|
if (isCLI && !optionInfo.array) {
|
|
122941
122941
|
const originalPreprocess = parameters.preprocess || ((x10) => x10);
|
|
122942
|
-
parameters.preprocess = (value,
|
|
122942
|
+
parameters.preprocess = (value, schema12, utils3) => schema12.preprocess(originalPreprocess(Array.isArray(value) ? method_at_default2(0, value, -1) : value), utils3);
|
|
122943
122943
|
}
|
|
122944
122944
|
return optionInfo.array ? ArraySchema.create({
|
|
122945
122945
|
...isCLI ? {
|
|
@@ -124516,9 +124516,9 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124516
124516
|
};
|
|
124517
124517
|
applyNormalization();
|
|
124518
124518
|
for (const key2 of Object.keys(this._utils.schemas)) {
|
|
124519
|
-
const
|
|
124519
|
+
const schema12 = this._utils.schemas[key2];
|
|
124520
124520
|
if (!(key2 in newOptions)) {
|
|
124521
|
-
const defaultResult = normalizeDefaultResult(
|
|
124521
|
+
const defaultResult = normalizeDefaultResult(schema12.default(this._utils));
|
|
124522
124522
|
if ("value" in defaultResult) {
|
|
124523
124523
|
restOptionsArray.push({ [key2]: defaultResult.value });
|
|
124524
124524
|
}
|
|
@@ -124529,13 +124529,13 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124529
124529
|
if (!(key2 in newOptions)) {
|
|
124530
124530
|
continue;
|
|
124531
124531
|
}
|
|
124532
|
-
const
|
|
124532
|
+
const schema12 = this._utils.schemas[key2];
|
|
124533
124533
|
const value = newOptions[key2];
|
|
124534
|
-
const newValue =
|
|
124534
|
+
const newValue = schema12.postprocess(value, this._utils);
|
|
124535
124535
|
if (newValue === VALUE_UNCHANGED) {
|
|
124536
124536
|
continue;
|
|
124537
124537
|
}
|
|
124538
|
-
this._applyValidation(newValue, key2,
|
|
124538
|
+
this._applyValidation(newValue, key2, schema12);
|
|
124539
124539
|
newOptions[key2] = newValue;
|
|
124540
124540
|
}
|
|
124541
124541
|
this._applyPostprocess(newOptions);
|
|
@@ -124546,14 +124546,14 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124546
124546
|
const transferredOptionsArray = [];
|
|
124547
124547
|
const { knownKeys, unknownKeys } = this._partitionOptionKeys(options8);
|
|
124548
124548
|
for (const key2 of knownKeys) {
|
|
124549
|
-
const
|
|
124550
|
-
const value =
|
|
124551
|
-
this._applyValidation(value, key2,
|
|
124549
|
+
const schema12 = this._utils.schemas[key2];
|
|
124550
|
+
const value = schema12.preprocess(options8[key2], this._utils);
|
|
124551
|
+
this._applyValidation(value, key2, schema12);
|
|
124552
124552
|
const appendTransferredOptions = ({ from, to: to5 }) => {
|
|
124553
124553
|
transferredOptionsArray.push(typeof to5 === "string" ? { [to5]: from } : { [to5.key]: to5.value });
|
|
124554
124554
|
};
|
|
124555
124555
|
const warnDeprecated = ({ value: currentValue, redirectTo }) => {
|
|
124556
|
-
const deprecatedResult = normalizeDeprecatedResult(
|
|
124556
|
+
const deprecatedResult = normalizeDeprecatedResult(schema12.deprecated(currentValue, this._utils), value, true);
|
|
124557
124557
|
if (deprecatedResult === false) {
|
|
124558
124558
|
return;
|
|
124559
124559
|
}
|
|
@@ -124571,13 +124571,13 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124571
124571
|
}
|
|
124572
124572
|
}
|
|
124573
124573
|
};
|
|
124574
|
-
const forwardResult = normalizeForwardResult(
|
|
124574
|
+
const forwardResult = normalizeForwardResult(schema12.forward(value, this._utils), value);
|
|
124575
124575
|
forwardResult.forEach(appendTransferredOptions);
|
|
124576
|
-
const redirectResult = normalizeRedirectResult(
|
|
124576
|
+
const redirectResult = normalizeRedirectResult(schema12.redirect(value, this._utils), value);
|
|
124577
124577
|
redirectResult.redirect.forEach(appendTransferredOptions);
|
|
124578
124578
|
if ("remain" in redirectResult) {
|
|
124579
124579
|
const remainingValue = redirectResult.remain;
|
|
124580
|
-
newOptions[key2] = key2 in newOptions ?
|
|
124580
|
+
newOptions[key2] = key2 in newOptions ? schema12.overlap(newOptions[key2], remainingValue, this._utils) : remainingValue;
|
|
124581
124581
|
warnDeprecated({ value: remainingValue });
|
|
124582
124582
|
}
|
|
124583
124583
|
for (const { from, to: to5 } of redirectResult.redirect) {
|
|
@@ -124605,8 +124605,8 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124605
124605
|
const [knownKeys, unknownKeys] = partition(Object.keys(options8).filter((key2) => !this._identifyMissing(key2, options8)), (key2) => (key2 in this._utils.schemas));
|
|
124606
124606
|
return { knownKeys, unknownKeys };
|
|
124607
124607
|
}
|
|
124608
|
-
_applyValidation(value, key2,
|
|
124609
|
-
const validateResult = normalizeValidateResult(
|
|
124608
|
+
_applyValidation(value, key2, schema12) {
|
|
124609
|
+
const validateResult = normalizeValidateResult(schema12.validate(value, this._utils), value);
|
|
124610
124610
|
if (validateResult !== true) {
|
|
124611
124611
|
throw this._invalidHandler(key2, validateResult.value, this._utils);
|
|
124612
124612
|
}
|
|
@@ -124648,8 +124648,8 @@ var require2, __filename2, __dirname3, __create2, __defProp3, __getOwnPropDesc2,
|
|
|
124648
124648
|
for (const key2 of unknownKeys) {
|
|
124649
124649
|
const value = postprocessed.override[key2];
|
|
124650
124650
|
this._applyUnknownHandler(key2, value, options8, (knownResultKey, knownResultValue) => {
|
|
124651
|
-
const
|
|
124652
|
-
this._applyValidation(knownResultValue, knownResultKey,
|
|
124651
|
+
const schema12 = this._utils.schemas[knownResultKey];
|
|
124652
|
+
this._applyValidation(knownResultValue, knownResultKey, schema12);
|
|
124653
124653
|
options8[knownResultKey] = knownResultValue;
|
|
124654
124654
|
});
|
|
124655
124655
|
}
|
|
@@ -134690,7 +134690,7 @@ ${codeblock}`, options8);
|
|
|
134690
134690
|
"\\": "\\"
|
|
134691
134691
|
};
|
|
134692
134692
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
134693
|
-
read_file_default =
|
|
134693
|
+
read_file_default = readFile6;
|
|
134694
134694
|
loadConfigFromPackageJson = process.versions.bun ? async function loadConfigFromBunPackageJson(file2) {
|
|
134695
134695
|
const { prettier } = await readBunPackageJson(file2);
|
|
134696
134696
|
return prettier;
|
|
@@ -138362,23 +138362,23 @@ var require_JSONSchema = __commonJS((exports) => {
|
|
|
138362
138362
|
exports.Parent = Symbol("Parent");
|
|
138363
138363
|
exports.Types = Symbol("Types");
|
|
138364
138364
|
exports.Intersection = Symbol("Intersection");
|
|
138365
|
-
exports.getRootSchema = (0, lodash_1.memoize)((
|
|
138366
|
-
const parent =
|
|
138365
|
+
exports.getRootSchema = (0, lodash_1.memoize)((schema12) => {
|
|
138366
|
+
const parent = schema12[exports.Parent];
|
|
138367
138367
|
if (!parent) {
|
|
138368
|
-
return
|
|
138368
|
+
return schema12;
|
|
138369
138369
|
}
|
|
138370
138370
|
return (0, exports.getRootSchema)(parent);
|
|
138371
138371
|
});
|
|
138372
|
-
function isBoolean(
|
|
138373
|
-
return
|
|
138372
|
+
function isBoolean(schema12) {
|
|
138373
|
+
return schema12 === true || schema12 === false;
|
|
138374
138374
|
}
|
|
138375
138375
|
exports.isBoolean = isBoolean;
|
|
138376
|
-
function isPrimitive(
|
|
138377
|
-
return !(0, lodash_1.isPlainObject)(
|
|
138376
|
+
function isPrimitive(schema12) {
|
|
138377
|
+
return !(0, lodash_1.isPlainObject)(schema12);
|
|
138378
138378
|
}
|
|
138379
138379
|
exports.isPrimitive = isPrimitive;
|
|
138380
|
-
function isCompound(
|
|
138381
|
-
return Array.isArray(
|
|
138380
|
+
function isCompound(schema12) {
|
|
138381
|
+
return Array.isArray(schema12.type) || "anyOf" in schema12 || "oneOf" in schema12;
|
|
138382
138382
|
}
|
|
138383
138383
|
exports.isCompound = isCompound;
|
|
138384
138384
|
});
|
|
@@ -138605,9 +138605,9 @@ var require_type2 = __commonJS((exports, module) => {
|
|
|
138605
138605
|
var require_schema5 = __commonJS((exports, module) => {
|
|
138606
138606
|
var YAMLException = require_exception2();
|
|
138607
138607
|
var Type = require_type2();
|
|
138608
|
-
function compileList(
|
|
138608
|
+
function compileList(schema12, name2) {
|
|
138609
138609
|
var result = [];
|
|
138610
|
-
|
|
138610
|
+
schema12[name2].forEach(function(currentType) {
|
|
138611
138611
|
var newIndex = result.length;
|
|
138612
138612
|
result.forEach(function(previousType, previousIndex) {
|
|
138613
138613
|
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
@@ -140552,7 +140552,7 @@ var require_dumper2 = __commonJS((exports, module) => {
|
|
|
140552
140552
|
"OFF"
|
|
140553
140553
|
];
|
|
140554
140554
|
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
140555
|
-
function compileStyleMap(
|
|
140555
|
+
function compileStyleMap(schema12, map2) {
|
|
140556
140556
|
var result, keys, index, length, tag, style, type;
|
|
140557
140557
|
if (map2 === null)
|
|
140558
140558
|
return {};
|
|
@@ -140564,7 +140564,7 @@ var require_dumper2 = __commonJS((exports, module) => {
|
|
|
140564
140564
|
if (tag.slice(0, 2) === "!!") {
|
|
140565
140565
|
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
140566
140566
|
}
|
|
140567
|
-
type =
|
|
140567
|
+
type = schema12.compiledTypeMap["fallback"][tag];
|
|
140568
140568
|
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
140569
140569
|
style = type.styleAliases[style];
|
|
140570
140570
|
}
|
|
@@ -141223,11 +141223,11 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141223
141223
|
function traverseArray(arr, callback, processed) {
|
|
141224
141224
|
arr.forEach((s5, k9) => traverse(s5, callback, processed, k9.toString()));
|
|
141225
141225
|
}
|
|
141226
|
-
function traverseIntersection(
|
|
141227
|
-
if (typeof
|
|
141226
|
+
function traverseIntersection(schema12, callback, processed) {
|
|
141227
|
+
if (typeof schema12 !== "object" || !schema12) {
|
|
141228
141228
|
return;
|
|
141229
141229
|
}
|
|
141230
|
-
const r5 =
|
|
141230
|
+
const r5 = schema12;
|
|
141231
141231
|
const intersection2 = r5[JSONSchema_1.Intersection];
|
|
141232
141232
|
if (!intersection2) {
|
|
141233
141233
|
return;
|
|
@@ -141236,60 +141236,60 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141236
141236
|
traverseArray(intersection2.allOf, callback, processed);
|
|
141237
141237
|
}
|
|
141238
141238
|
}
|
|
141239
|
-
function traverse(
|
|
141240
|
-
if (processed.has(
|
|
141239
|
+
function traverse(schema12, callback, processed = new Set, key2) {
|
|
141240
|
+
if (processed.has(schema12)) {
|
|
141241
141241
|
return;
|
|
141242
141242
|
}
|
|
141243
|
-
processed.add(
|
|
141244
|
-
callback(
|
|
141245
|
-
if (
|
|
141246
|
-
traverseArray(
|
|
141243
|
+
processed.add(schema12);
|
|
141244
|
+
callback(schema12, key2 !== null && key2 !== undefined ? key2 : null);
|
|
141245
|
+
if (schema12.anyOf) {
|
|
141246
|
+
traverseArray(schema12.anyOf, callback, processed);
|
|
141247
141247
|
}
|
|
141248
|
-
if (
|
|
141249
|
-
traverseArray(
|
|
141248
|
+
if (schema12.allOf) {
|
|
141249
|
+
traverseArray(schema12.allOf, callback, processed);
|
|
141250
141250
|
}
|
|
141251
|
-
if (
|
|
141252
|
-
traverseArray(
|
|
141251
|
+
if (schema12.oneOf) {
|
|
141252
|
+
traverseArray(schema12.oneOf, callback, processed);
|
|
141253
141253
|
}
|
|
141254
|
-
if (
|
|
141255
|
-
traverseObjectKeys(
|
|
141254
|
+
if (schema12.properties) {
|
|
141255
|
+
traverseObjectKeys(schema12.properties, callback, processed);
|
|
141256
141256
|
}
|
|
141257
|
-
if (
|
|
141258
|
-
traverseObjectKeys(
|
|
141257
|
+
if (schema12.patternProperties) {
|
|
141258
|
+
traverseObjectKeys(schema12.patternProperties, callback, processed);
|
|
141259
141259
|
}
|
|
141260
|
-
if (
|
|
141261
|
-
traverse(
|
|
141260
|
+
if (schema12.additionalProperties && typeof schema12.additionalProperties === "object") {
|
|
141261
|
+
traverse(schema12.additionalProperties, callback, processed);
|
|
141262
141262
|
}
|
|
141263
|
-
if (
|
|
141264
|
-
const { items } =
|
|
141263
|
+
if (schema12.items) {
|
|
141264
|
+
const { items } = schema12;
|
|
141265
141265
|
if (Array.isArray(items)) {
|
|
141266
141266
|
traverseArray(items, callback, processed);
|
|
141267
141267
|
} else {
|
|
141268
141268
|
traverse(items, callback, processed);
|
|
141269
141269
|
}
|
|
141270
141270
|
}
|
|
141271
|
-
if (
|
|
141272
|
-
traverse(
|
|
141271
|
+
if (schema12.additionalItems && typeof schema12.additionalItems === "object") {
|
|
141272
|
+
traverse(schema12.additionalItems, callback, processed);
|
|
141273
141273
|
}
|
|
141274
|
-
if (
|
|
141275
|
-
if (Array.isArray(
|
|
141276
|
-
traverseArray(
|
|
141274
|
+
if (schema12.dependencies) {
|
|
141275
|
+
if (Array.isArray(schema12.dependencies)) {
|
|
141276
|
+
traverseArray(schema12.dependencies, callback, processed);
|
|
141277
141277
|
} else {
|
|
141278
|
-
traverseObjectKeys(
|
|
141278
|
+
traverseObjectKeys(schema12.dependencies, callback, processed);
|
|
141279
141279
|
}
|
|
141280
141280
|
}
|
|
141281
|
-
if (
|
|
141282
|
-
traverseObjectKeys(
|
|
141281
|
+
if (schema12.definitions) {
|
|
141282
|
+
traverseObjectKeys(schema12.definitions, callback, processed);
|
|
141283
141283
|
}
|
|
141284
|
-
if (
|
|
141285
|
-
traverseObjectKeys(
|
|
141284
|
+
if (schema12.$defs) {
|
|
141285
|
+
traverseObjectKeys(schema12.$defs, callback, processed);
|
|
141286
141286
|
}
|
|
141287
|
-
if (
|
|
141288
|
-
traverse(
|
|
141287
|
+
if (schema12.not) {
|
|
141288
|
+
traverse(schema12.not, callback, processed);
|
|
141289
141289
|
}
|
|
141290
|
-
traverseIntersection(
|
|
141291
|
-
Object.keys(
|
|
141292
|
-
const child =
|
|
141290
|
+
traverseIntersection(schema12, callback, processed);
|
|
141291
|
+
Object.keys(schema12).filter((key3) => !BLACKLISTED_KEYS.has(key3)).forEach((key3) => {
|
|
141292
|
+
const child = schema12[key3];
|
|
141293
141293
|
if (child && typeof child === "object") {
|
|
141294
141294
|
traverseObjectKeys(child, callback, processed);
|
|
141295
141295
|
}
|
|
@@ -141371,14 +141371,14 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141371
141371
|
return (_g2 = color()) === null || _g2 === undefined ? undefined : _g2.whiteBright.bgYellow;
|
|
141372
141372
|
}
|
|
141373
141373
|
}
|
|
141374
|
-
function escapeBlockComment(
|
|
141374
|
+
function escapeBlockComment(schema12) {
|
|
141375
141375
|
const replacer = "* /";
|
|
141376
|
-
if (
|
|
141376
|
+
if (schema12 === null || typeof schema12 !== "object") {
|
|
141377
141377
|
return;
|
|
141378
141378
|
}
|
|
141379
|
-
for (const key2 of Object.keys(
|
|
141380
|
-
if (key2 === "description" && typeof
|
|
141381
|
-
|
|
141379
|
+
for (const key2 of Object.keys(schema12)) {
|
|
141380
|
+
if (key2 === "description" && typeof schema12[key2] === "string") {
|
|
141381
|
+
schema12[key2] = schema12[key2].replace(/\*\//g, replacer);
|
|
141382
141382
|
}
|
|
141383
141383
|
}
|
|
141384
141384
|
}
|
|
@@ -141390,45 +141390,45 @@ var require_utils7 = __commonJS((exports) => {
|
|
|
141390
141390
|
return path_1.posix.join(path_1.posix.normalize(outputPath), ...filePathRel);
|
|
141391
141391
|
}
|
|
141392
141392
|
exports.pathTransform = pathTransform;
|
|
141393
|
-
function maybeStripDefault(
|
|
141394
|
-
if (!("default" in
|
|
141395
|
-
return
|
|
141393
|
+
function maybeStripDefault(schema12) {
|
|
141394
|
+
if (!("default" in schema12)) {
|
|
141395
|
+
return schema12;
|
|
141396
141396
|
}
|
|
141397
|
-
switch (
|
|
141397
|
+
switch (schema12.type) {
|
|
141398
141398
|
case "array":
|
|
141399
|
-
if (Array.isArray(
|
|
141400
|
-
return
|
|
141399
|
+
if (Array.isArray(schema12.default)) {
|
|
141400
|
+
return schema12;
|
|
141401
141401
|
}
|
|
141402
141402
|
break;
|
|
141403
141403
|
case "boolean":
|
|
141404
|
-
if (typeof
|
|
141405
|
-
return
|
|
141404
|
+
if (typeof schema12.default === "boolean") {
|
|
141405
|
+
return schema12;
|
|
141406
141406
|
}
|
|
141407
141407
|
break;
|
|
141408
141408
|
case "integer":
|
|
141409
141409
|
case "number":
|
|
141410
|
-
if (typeof
|
|
141411
|
-
return
|
|
141410
|
+
if (typeof schema12.default === "number") {
|
|
141411
|
+
return schema12;
|
|
141412
141412
|
}
|
|
141413
141413
|
break;
|
|
141414
141414
|
case "string":
|
|
141415
|
-
if (typeof
|
|
141416
|
-
return
|
|
141415
|
+
if (typeof schema12.default === "string") {
|
|
141416
|
+
return schema12;
|
|
141417
141417
|
}
|
|
141418
141418
|
break;
|
|
141419
141419
|
case "null":
|
|
141420
|
-
if (
|
|
141421
|
-
return
|
|
141420
|
+
if (schema12.default === null) {
|
|
141421
|
+
return schema12;
|
|
141422
141422
|
}
|
|
141423
141423
|
break;
|
|
141424
141424
|
case "object":
|
|
141425
|
-
if ((0, lodash_1.isPlainObject)(
|
|
141426
|
-
return
|
|
141425
|
+
if ((0, lodash_1.isPlainObject)(schema12.default)) {
|
|
141426
|
+
return schema12;
|
|
141427
141427
|
}
|
|
141428
141428
|
break;
|
|
141429
141429
|
}
|
|
141430
|
-
delete
|
|
141431
|
-
return
|
|
141430
|
+
delete schema12.default;
|
|
141431
|
+
return schema12;
|
|
141432
141432
|
}
|
|
141433
141433
|
exports.maybeStripDefault = maybeStripDefault;
|
|
141434
141434
|
function appendToDescription(existingDescription, ...values) {
|
|
@@ -141442,11 +141442,11 @@ ${values.join(`
|
|
|
141442
141442
|
`);
|
|
141443
141443
|
}
|
|
141444
141444
|
exports.appendToDescription = appendToDescription;
|
|
141445
|
-
function isSchemaLike(
|
|
141446
|
-
if (!(0, lodash_1.isPlainObject)(
|
|
141445
|
+
function isSchemaLike(schema12) {
|
|
141446
|
+
if (!(0, lodash_1.isPlainObject)(schema12)) {
|
|
141447
141447
|
return false;
|
|
141448
141448
|
}
|
|
141449
|
-
const parent =
|
|
141449
|
+
const parent = schema12[JSONSchema_1.Parent];
|
|
141450
141450
|
if (parent === null) {
|
|
141451
141451
|
return true;
|
|
141452
141452
|
}
|
|
@@ -141463,7 +141463,7 @@ ${values.join(`
|
|
|
141463
141463
|
"properties",
|
|
141464
141464
|
"required"
|
|
141465
141465
|
];
|
|
141466
|
-
if (JSON_SCHEMA_KEYWORDS.some((_10) => parent[_10] ===
|
|
141466
|
+
if (JSON_SCHEMA_KEYWORDS.some((_10) => parent[_10] === schema12)) {
|
|
141467
141467
|
return false;
|
|
141468
141468
|
}
|
|
141469
141469
|
return true;
|
|
@@ -141761,13 +141761,13 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141761
141761
|
exports.typesOfSchema = undefined;
|
|
141762
141762
|
var lodash_1 = require_lodash8();
|
|
141763
141763
|
var JSONSchema_1 = require_JSONSchema();
|
|
141764
|
-
function typesOfSchema(
|
|
141765
|
-
if (
|
|
141764
|
+
function typesOfSchema(schema12) {
|
|
141765
|
+
if (schema12.tsType) {
|
|
141766
141766
|
return new Set(["CUSTOM_TYPE"]);
|
|
141767
141767
|
}
|
|
141768
141768
|
const matchedTypes = new Set;
|
|
141769
141769
|
for (const [schemaType, f7] of Object.entries(matchers)) {
|
|
141770
|
-
if (f7(
|
|
141770
|
+
if (f7(schema12)) {
|
|
141771
141771
|
matchedTypes.add(schemaType);
|
|
141772
141772
|
}
|
|
141773
141773
|
}
|
|
@@ -141778,26 +141778,26 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141778
141778
|
}
|
|
141779
141779
|
exports.typesOfSchema = typesOfSchema;
|
|
141780
141780
|
var matchers = {
|
|
141781
|
-
ALL_OF(
|
|
141782
|
-
return "allOf" in
|
|
141781
|
+
ALL_OF(schema12) {
|
|
141782
|
+
return "allOf" in schema12;
|
|
141783
141783
|
},
|
|
141784
|
-
ANY(
|
|
141785
|
-
if (Object.keys(
|
|
141784
|
+
ANY(schema12) {
|
|
141785
|
+
if (Object.keys(schema12).length === 0) {
|
|
141786
141786
|
return true;
|
|
141787
141787
|
}
|
|
141788
|
-
return
|
|
141788
|
+
return schema12.type === "any";
|
|
141789
141789
|
},
|
|
141790
|
-
ANY_OF(
|
|
141791
|
-
return "anyOf" in
|
|
141790
|
+
ANY_OF(schema12) {
|
|
141791
|
+
return "anyOf" in schema12;
|
|
141792
141792
|
},
|
|
141793
|
-
BOOLEAN(
|
|
141794
|
-
if ("enum" in
|
|
141793
|
+
BOOLEAN(schema12) {
|
|
141794
|
+
if ("enum" in schema12) {
|
|
141795
141795
|
return false;
|
|
141796
141796
|
}
|
|
141797
|
-
if (
|
|
141797
|
+
if (schema12.type === "boolean") {
|
|
141798
141798
|
return true;
|
|
141799
141799
|
}
|
|
141800
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141800
|
+
if (!(0, JSONSchema_1.isCompound)(schema12) && typeof schema12.default === "boolean") {
|
|
141801
141801
|
return true;
|
|
141802
141802
|
}
|
|
141803
141803
|
return false;
|
|
@@ -141805,74 +141805,74 @@ var require_typesOfSchema = __commonJS((exports) => {
|
|
|
141805
141805
|
CUSTOM_TYPE() {
|
|
141806
141806
|
return false;
|
|
141807
141807
|
},
|
|
141808
|
-
NAMED_ENUM(
|
|
141809
|
-
return "enum" in
|
|
141808
|
+
NAMED_ENUM(schema12) {
|
|
141809
|
+
return "enum" in schema12 && "tsEnumNames" in schema12;
|
|
141810
141810
|
},
|
|
141811
|
-
NAMED_SCHEMA(
|
|
141812
|
-
return "$id" in
|
|
141811
|
+
NAMED_SCHEMA(schema12) {
|
|
141812
|
+
return "$id" in schema12 && (("patternProperties" in schema12) || ("properties" in schema12));
|
|
141813
141813
|
},
|
|
141814
|
-
NEVER(
|
|
141815
|
-
return
|
|
141814
|
+
NEVER(schema12) {
|
|
141815
|
+
return schema12 === false;
|
|
141816
141816
|
},
|
|
141817
|
-
NULL(
|
|
141818
|
-
return
|
|
141817
|
+
NULL(schema12) {
|
|
141818
|
+
return schema12.type === "null";
|
|
141819
141819
|
},
|
|
141820
|
-
NUMBER(
|
|
141821
|
-
if ("enum" in
|
|
141820
|
+
NUMBER(schema12) {
|
|
141821
|
+
if ("enum" in schema12) {
|
|
141822
141822
|
return false;
|
|
141823
141823
|
}
|
|
141824
|
-
if (
|
|
141824
|
+
if (schema12.type === "integer" || schema12.type === "number") {
|
|
141825
141825
|
return true;
|
|
141826
141826
|
}
|
|
141827
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141827
|
+
if (!(0, JSONSchema_1.isCompound)(schema12) && typeof schema12.default === "number") {
|
|
141828
141828
|
return true;
|
|
141829
141829
|
}
|
|
141830
141830
|
return false;
|
|
141831
141831
|
},
|
|
141832
|
-
OBJECT(
|
|
141833
|
-
return
|
|
141832
|
+
OBJECT(schema12) {
|
|
141833
|
+
return schema12.type === "object" && !(0, lodash_1.isPlainObject)(schema12.additionalProperties) && !schema12.allOf && !schema12.anyOf && !schema12.oneOf && !schema12.patternProperties && !schema12.properties && !schema12.required;
|
|
141834
141834
|
},
|
|
141835
|
-
ONE_OF(
|
|
141836
|
-
return "oneOf" in
|
|
141835
|
+
ONE_OF(schema12) {
|
|
141836
|
+
return "oneOf" in schema12;
|
|
141837
141837
|
},
|
|
141838
|
-
REFERENCE(
|
|
141839
|
-
return "$ref" in
|
|
141838
|
+
REFERENCE(schema12) {
|
|
141839
|
+
return "$ref" in schema12;
|
|
141840
141840
|
},
|
|
141841
|
-
STRING(
|
|
141842
|
-
if ("enum" in
|
|
141841
|
+
STRING(schema12) {
|
|
141842
|
+
if ("enum" in schema12) {
|
|
141843
141843
|
return false;
|
|
141844
141844
|
}
|
|
141845
|
-
if (
|
|
141845
|
+
if (schema12.type === "string") {
|
|
141846
141846
|
return true;
|
|
141847
141847
|
}
|
|
141848
|
-
if (!(0, JSONSchema_1.isCompound)(
|
|
141848
|
+
if (!(0, JSONSchema_1.isCompound)(schema12) && typeof schema12.default === "string") {
|
|
141849
141849
|
return true;
|
|
141850
141850
|
}
|
|
141851
141851
|
return false;
|
|
141852
141852
|
},
|
|
141853
|
-
TYPED_ARRAY(
|
|
141854
|
-
if (
|
|
141853
|
+
TYPED_ARRAY(schema12) {
|
|
141854
|
+
if (schema12.type && schema12.type !== "array") {
|
|
141855
141855
|
return false;
|
|
141856
141856
|
}
|
|
141857
|
-
return "items" in
|
|
141857
|
+
return "items" in schema12;
|
|
141858
141858
|
},
|
|
141859
|
-
UNION(
|
|
141860
|
-
return Array.isArray(
|
|
141859
|
+
UNION(schema12) {
|
|
141860
|
+
return Array.isArray(schema12.type);
|
|
141861
141861
|
},
|
|
141862
|
-
UNNAMED_ENUM(
|
|
141863
|
-
if ("tsEnumNames" in
|
|
141862
|
+
UNNAMED_ENUM(schema12) {
|
|
141863
|
+
if ("tsEnumNames" in schema12) {
|
|
141864
141864
|
return false;
|
|
141865
141865
|
}
|
|
141866
|
-
if (
|
|
141866
|
+
if (schema12.type && schema12.type !== "boolean" && schema12.type !== "integer" && schema12.type !== "number" && schema12.type !== "string") {
|
|
141867
141867
|
return false;
|
|
141868
141868
|
}
|
|
141869
|
-
return "enum" in
|
|
141869
|
+
return "enum" in schema12;
|
|
141870
141870
|
},
|
|
141871
141871
|
UNNAMED_SCHEMA() {
|
|
141872
141872
|
return false;
|
|
141873
141873
|
},
|
|
141874
|
-
UNTYPED_ARRAY(
|
|
141875
|
-
return
|
|
141874
|
+
UNTYPED_ARRAY(schema12) {
|
|
141875
|
+
return schema12.type === "array" && !("items" in schema12);
|
|
141876
141876
|
}
|
|
141877
141877
|
};
|
|
141878
141878
|
});
|
|
@@ -141883,10 +141883,10 @@ var require_applySchemaTyping = __commonJS((exports) => {
|
|
|
141883
141883
|
exports.applySchemaTyping = undefined;
|
|
141884
141884
|
var JSONSchema_1 = require_JSONSchema();
|
|
141885
141885
|
var typesOfSchema_1 = require_typesOfSchema();
|
|
141886
|
-
function applySchemaTyping(
|
|
141886
|
+
function applySchemaTyping(schema12) {
|
|
141887
141887
|
var _a7;
|
|
141888
|
-
const types = (0, typesOfSchema_1.typesOfSchema)(
|
|
141889
|
-
Object.defineProperty(
|
|
141888
|
+
const types = (0, typesOfSchema_1.typesOfSchema)(schema12);
|
|
141889
|
+
Object.defineProperty(schema12, JSONSchema_1.Types, {
|
|
141890
141890
|
enumerable: false,
|
|
141891
141891
|
value: types,
|
|
141892
141892
|
writable: false
|
|
@@ -141895,23 +141895,23 @@ var require_applySchemaTyping = __commonJS((exports) => {
|
|
|
141895
141895
|
return;
|
|
141896
141896
|
}
|
|
141897
141897
|
const intersection2 = {
|
|
141898
|
-
[JSONSchema_1.Parent]:
|
|
141898
|
+
[JSONSchema_1.Parent]: schema12,
|
|
141899
141899
|
[JSONSchema_1.Types]: new Set(["ALL_OF"]),
|
|
141900
|
-
$id:
|
|
141901
|
-
description:
|
|
141902
|
-
name:
|
|
141903
|
-
title:
|
|
141904
|
-
allOf: (_a7 =
|
|
141900
|
+
$id: schema12.$id,
|
|
141901
|
+
description: schema12.description,
|
|
141902
|
+
name: schema12.name,
|
|
141903
|
+
title: schema12.title,
|
|
141904
|
+
allOf: (_a7 = schema12.allOf) !== null && _a7 !== undefined ? _a7 : [],
|
|
141905
141905
|
required: [],
|
|
141906
141906
|
additionalProperties: false
|
|
141907
141907
|
};
|
|
141908
141908
|
types.delete("ALL_OF");
|
|
141909
|
-
delete
|
|
141910
|
-
delete
|
|
141911
|
-
delete
|
|
141912
|
-
delete
|
|
141913
|
-
delete
|
|
141914
|
-
Object.defineProperty(
|
|
141909
|
+
delete schema12.allOf;
|
|
141910
|
+
delete schema12.$id;
|
|
141911
|
+
delete schema12.description;
|
|
141912
|
+
delete schema12.name;
|
|
141913
|
+
delete schema12.title;
|
|
141914
|
+
Object.defineProperty(schema12, JSONSchema_1.Intersection, {
|
|
141915
141915
|
enumerable: false,
|
|
141916
141916
|
value: intersection2,
|
|
141917
141917
|
writable: false
|
|
@@ -141929,186 +141929,186 @@ var require_normalizer = __commonJS((exports) => {
|
|
|
141929
141929
|
var applySchemaTyping_1 = require_applySchemaTyping();
|
|
141930
141930
|
var util_1 = __require("util");
|
|
141931
141931
|
var rules = new Map;
|
|
141932
|
-
function hasType(
|
|
141933
|
-
return
|
|
141932
|
+
function hasType(schema12, type) {
|
|
141933
|
+
return schema12.type === type || Array.isArray(schema12.type) && schema12.type.includes(type);
|
|
141934
141934
|
}
|
|
141935
|
-
function isObjectType(
|
|
141936
|
-
return
|
|
141935
|
+
function isObjectType(schema12) {
|
|
141936
|
+
return schema12.properties !== undefined || hasType(schema12, "object") || hasType(schema12, "any");
|
|
141937
141937
|
}
|
|
141938
|
-
function isArrayType(
|
|
141939
|
-
return
|
|
141938
|
+
function isArrayType(schema12) {
|
|
141939
|
+
return schema12.items !== undefined || hasType(schema12, "array") || hasType(schema12, "any");
|
|
141940
141940
|
}
|
|
141941
|
-
function isEnumTypeWithoutTsEnumNames(
|
|
141942
|
-
return
|
|
141941
|
+
function isEnumTypeWithoutTsEnumNames(schema12) {
|
|
141942
|
+
return schema12.type === "string" && schema12.enum !== undefined && schema12.tsEnumNames === undefined;
|
|
141943
141943
|
}
|
|
141944
|
-
rules.set('Remove `type=["null"]` if `enum=[null]`', (
|
|
141945
|
-
if (Array.isArray(
|
|
141946
|
-
|
|
141944
|
+
rules.set('Remove `type=["null"]` if `enum=[null]`', (schema12) => {
|
|
141945
|
+
if (Array.isArray(schema12.enum) && schema12.enum.some((e8) => e8 === null) && Array.isArray(schema12.type) && schema12.type.includes("null")) {
|
|
141946
|
+
schema12.type = schema12.type.filter((type) => type !== "null");
|
|
141947
141947
|
}
|
|
141948
141948
|
});
|
|
141949
|
-
rules.set("Destructure unary types", (
|
|
141950
|
-
if (
|
|
141951
|
-
|
|
141949
|
+
rules.set("Destructure unary types", (schema12) => {
|
|
141950
|
+
if (schema12.type && Array.isArray(schema12.type) && schema12.type.length === 1) {
|
|
141951
|
+
schema12.type = schema12.type[0];
|
|
141952
141952
|
}
|
|
141953
141953
|
});
|
|
141954
|
-
rules.set("Add empty `required` property if none is defined", (
|
|
141955
|
-
if (isObjectType(
|
|
141956
|
-
|
|
141954
|
+
rules.set("Add empty `required` property if none is defined", (schema12) => {
|
|
141955
|
+
if (isObjectType(schema12) && !("required" in schema12)) {
|
|
141956
|
+
schema12.required = [];
|
|
141957
141957
|
}
|
|
141958
141958
|
});
|
|
141959
|
-
rules.set("Transform `required`=false to `required`=[]", (
|
|
141960
|
-
if (
|
|
141961
|
-
|
|
141959
|
+
rules.set("Transform `required`=false to `required`=[]", (schema12) => {
|
|
141960
|
+
if (schema12.required === false) {
|
|
141961
|
+
schema12.required = [];
|
|
141962
141962
|
}
|
|
141963
141963
|
});
|
|
141964
|
-
rules.set("Default additionalProperties", (
|
|
141965
|
-
if (isObjectType(
|
|
141966
|
-
|
|
141964
|
+
rules.set("Default additionalProperties", (schema12, _10, options8) => {
|
|
141965
|
+
if (isObjectType(schema12) && !("additionalProperties" in schema12) && schema12.patternProperties === undefined) {
|
|
141966
|
+
schema12.additionalProperties = options8.additionalProperties;
|
|
141967
141967
|
}
|
|
141968
141968
|
});
|
|
141969
|
-
rules.set("Transform id to $id", (
|
|
141970
|
-
if (!(0, utils_1.isSchemaLike)(
|
|
141969
|
+
rules.set("Transform id to $id", (schema12, fileName) => {
|
|
141970
|
+
if (!(0, utils_1.isSchemaLike)(schema12)) {
|
|
141971
141971
|
return;
|
|
141972
141972
|
}
|
|
141973
|
-
if (
|
|
141974
|
-
throw ReferenceError(`Schema must define either id or $id, not both. Given id=${
|
|
141973
|
+
if (schema12.id && schema12.$id && schema12.id !== schema12.$id) {
|
|
141974
|
+
throw ReferenceError(`Schema must define either id or $id, not both. Given id=${schema12.id}, $id=${schema12.$id} in ${fileName}`);
|
|
141975
141975
|
}
|
|
141976
|
-
if (
|
|
141977
|
-
|
|
141978
|
-
delete
|
|
141976
|
+
if (schema12.id) {
|
|
141977
|
+
schema12.$id = schema12.id;
|
|
141978
|
+
delete schema12.id;
|
|
141979
141979
|
}
|
|
141980
141980
|
});
|
|
141981
|
-
rules.set("Add an $id to anything that needs it", (
|
|
141982
|
-
if (!(0, utils_1.isSchemaLike)(
|
|
141981
|
+
rules.set("Add an $id to anything that needs it", (schema12, fileName, _options, _key, dereferencedPaths) => {
|
|
141982
|
+
if (!(0, utils_1.isSchemaLike)(schema12)) {
|
|
141983
141983
|
return;
|
|
141984
141984
|
}
|
|
141985
|
-
if (!
|
|
141986
|
-
|
|
141985
|
+
if (!schema12.$id && !schema12[JSONSchema_1.Parent]) {
|
|
141986
|
+
schema12.$id = (0, utils_1.toSafeString)((0, utils_1.justName)(fileName));
|
|
141987
141987
|
return;
|
|
141988
141988
|
}
|
|
141989
|
-
if (!isArrayType(
|
|
141989
|
+
if (!isArrayType(schema12) && !isObjectType(schema12)) {
|
|
141990
141990
|
return;
|
|
141991
141991
|
}
|
|
141992
|
-
const dereferencedName = dereferencedPaths.get(
|
|
141993
|
-
if (!
|
|
141994
|
-
|
|
141992
|
+
const dereferencedName = dereferencedPaths.get(schema12);
|
|
141993
|
+
if (!schema12.$id && !schema12.title && dereferencedName) {
|
|
141994
|
+
schema12.$id = (0, utils_1.toSafeString)((0, utils_1.justName)(dereferencedName));
|
|
141995
141995
|
}
|
|
141996
141996
|
if (dereferencedName) {
|
|
141997
|
-
dereferencedPaths.delete(
|
|
141997
|
+
dereferencedPaths.delete(schema12);
|
|
141998
141998
|
}
|
|
141999
141999
|
});
|
|
142000
|
-
rules.set("Escape closing JSDoc comment", (
|
|
142001
|
-
(0, utils_1.escapeBlockComment)(
|
|
142000
|
+
rules.set("Escape closing JSDoc comment", (schema12) => {
|
|
142001
|
+
(0, utils_1.escapeBlockComment)(schema12);
|
|
142002
142002
|
});
|
|
142003
|
-
rules.set("Add JSDoc comments for minItems and maxItems", (
|
|
142004
|
-
if (!isArrayType(
|
|
142003
|
+
rules.set("Add JSDoc comments for minItems and maxItems", (schema12) => {
|
|
142004
|
+
if (!isArrayType(schema12)) {
|
|
142005
142005
|
return;
|
|
142006
142006
|
}
|
|
142007
142007
|
const commentsToAppend = [
|
|
142008
|
-
"minItems" in
|
|
142009
|
-
"maxItems" in
|
|
142008
|
+
"minItems" in schema12 ? `@minItems ${schema12.minItems}` : "",
|
|
142009
|
+
"maxItems" in schema12 ? `@maxItems ${schema12.maxItems}` : ""
|
|
142010
142010
|
].filter(Boolean);
|
|
142011
142011
|
if (commentsToAppend.length) {
|
|
142012
|
-
|
|
142012
|
+
schema12.description = (0, utils_1.appendToDescription)(schema12.description, ...commentsToAppend);
|
|
142013
142013
|
}
|
|
142014
142014
|
});
|
|
142015
|
-
rules.set("Optionally remove maxItems and minItems", (
|
|
142016
|
-
if (!isArrayType(
|
|
142015
|
+
rules.set("Optionally remove maxItems and minItems", (schema12, _fileName, options8) => {
|
|
142016
|
+
if (!isArrayType(schema12)) {
|
|
142017
142017
|
return;
|
|
142018
142018
|
}
|
|
142019
|
-
if ("minItems" in
|
|
142020
|
-
delete
|
|
142019
|
+
if ("minItems" in schema12 && options8.ignoreMinAndMaxItems) {
|
|
142020
|
+
delete schema12.minItems;
|
|
142021
142021
|
}
|
|
142022
|
-
if ("maxItems" in
|
|
142023
|
-
delete
|
|
142022
|
+
if ("maxItems" in schema12 && (options8.ignoreMinAndMaxItems || options8.maxItems === -1)) {
|
|
142023
|
+
delete schema12.maxItems;
|
|
142024
142024
|
}
|
|
142025
142025
|
});
|
|
142026
|
-
rules.set("Normalize schema.minItems", (
|
|
142026
|
+
rules.set("Normalize schema.minItems", (schema12, _fileName, options8) => {
|
|
142027
142027
|
if (options8.ignoreMinAndMaxItems) {
|
|
142028
142028
|
return;
|
|
142029
142029
|
}
|
|
142030
|
-
if (!isArrayType(
|
|
142030
|
+
if (!isArrayType(schema12)) {
|
|
142031
142031
|
return;
|
|
142032
142032
|
}
|
|
142033
|
-
const { minItems } =
|
|
142034
|
-
|
|
142033
|
+
const { minItems } = schema12;
|
|
142034
|
+
schema12.minItems = typeof minItems === "number" ? minItems : 0;
|
|
142035
142035
|
});
|
|
142036
|
-
rules.set("Remove maxItems if it is big enough to likely cause OOMs", (
|
|
142036
|
+
rules.set("Remove maxItems if it is big enough to likely cause OOMs", (schema12, _fileName, options8) => {
|
|
142037
142037
|
if (options8.ignoreMinAndMaxItems || options8.maxItems === -1) {
|
|
142038
142038
|
return;
|
|
142039
142039
|
}
|
|
142040
|
-
if (!isArrayType(
|
|
142040
|
+
if (!isArrayType(schema12)) {
|
|
142041
142041
|
return;
|
|
142042
142042
|
}
|
|
142043
|
-
const { maxItems, minItems } =
|
|
142043
|
+
const { maxItems, minItems } = schema12;
|
|
142044
142044
|
if (maxItems !== undefined && maxItems - minItems > options8.maxItems) {
|
|
142045
|
-
delete
|
|
142045
|
+
delete schema12.maxItems;
|
|
142046
142046
|
}
|
|
142047
142047
|
});
|
|
142048
|
-
rules.set("Normalize schema.items", (
|
|
142048
|
+
rules.set("Normalize schema.items", (schema12, _fileName, options8) => {
|
|
142049
142049
|
if (options8.ignoreMinAndMaxItems) {
|
|
142050
142050
|
return;
|
|
142051
142051
|
}
|
|
142052
|
-
const { maxItems, minItems } =
|
|
142052
|
+
const { maxItems, minItems } = schema12;
|
|
142053
142053
|
const hasMaxItems = typeof maxItems === "number" && maxItems >= 0;
|
|
142054
142054
|
const hasMinItems = typeof minItems === "number" && minItems > 0;
|
|
142055
|
-
if (
|
|
142056
|
-
const items =
|
|
142055
|
+
if (schema12.items && !Array.isArray(schema12.items) && (hasMaxItems || hasMinItems)) {
|
|
142056
|
+
const items = schema12.items;
|
|
142057
142057
|
const newItems = Array(maxItems || minItems || 0).fill(items);
|
|
142058
142058
|
if (!hasMaxItems) {
|
|
142059
|
-
|
|
142059
|
+
schema12.additionalItems = items;
|
|
142060
142060
|
}
|
|
142061
|
-
|
|
142061
|
+
schema12.items = newItems;
|
|
142062
142062
|
}
|
|
142063
|
-
if (Array.isArray(
|
|
142064
|
-
|
|
142063
|
+
if (Array.isArray(schema12.items) && hasMaxItems && maxItems < schema12.items.length) {
|
|
142064
|
+
schema12.items = schema12.items.slice(0, maxItems);
|
|
142065
142065
|
}
|
|
142066
|
-
return
|
|
142066
|
+
return schema12;
|
|
142067
142067
|
});
|
|
142068
|
-
rules.set("Remove extends, if it is empty", (
|
|
142069
|
-
if (!
|
|
142068
|
+
rules.set("Remove extends, if it is empty", (schema12) => {
|
|
142069
|
+
if (!schema12.hasOwnProperty("extends")) {
|
|
142070
142070
|
return;
|
|
142071
142071
|
}
|
|
142072
|
-
if (
|
|
142073
|
-
delete
|
|
142072
|
+
if (schema12.extends == null || Array.isArray(schema12.extends) && schema12.extends.length === 0) {
|
|
142073
|
+
delete schema12.extends;
|
|
142074
142074
|
}
|
|
142075
142075
|
});
|
|
142076
|
-
rules.set("Make extends always an array, if it is defined", (
|
|
142077
|
-
if (
|
|
142076
|
+
rules.set("Make extends always an array, if it is defined", (schema12) => {
|
|
142077
|
+
if (schema12.extends == null) {
|
|
142078
142078
|
return;
|
|
142079
142079
|
}
|
|
142080
|
-
if (!Array.isArray(
|
|
142081
|
-
|
|
142080
|
+
if (!Array.isArray(schema12.extends)) {
|
|
142081
|
+
schema12.extends = [schema12.extends];
|
|
142082
142082
|
}
|
|
142083
142083
|
});
|
|
142084
|
-
rules.set("Transform definitions to $defs", (
|
|
142085
|
-
if (
|
|
142086
|
-
throw ReferenceError(`Schema must define either definitions or $defs, not both. Given id=${
|
|
142084
|
+
rules.set("Transform definitions to $defs", (schema12, fileName) => {
|
|
142085
|
+
if (schema12.definitions && schema12.$defs && !(0, util_1.isDeepStrictEqual)(schema12.definitions, schema12.$defs)) {
|
|
142086
|
+
throw ReferenceError(`Schema must define either definitions or $defs, not both. Given id=${schema12.id} in ${fileName}`);
|
|
142087
142087
|
}
|
|
142088
|
-
if (
|
|
142089
|
-
|
|
142090
|
-
delete
|
|
142088
|
+
if (schema12.definitions) {
|
|
142089
|
+
schema12.$defs = schema12.definitions;
|
|
142090
|
+
delete schema12.definitions;
|
|
142091
142091
|
}
|
|
142092
142092
|
});
|
|
142093
|
-
rules.set("Transform const to singleton enum", (
|
|
142094
|
-
if (
|
|
142095
|
-
|
|
142096
|
-
delete
|
|
142093
|
+
rules.set("Transform const to singleton enum", (schema12) => {
|
|
142094
|
+
if (schema12.const !== undefined) {
|
|
142095
|
+
schema12.enum = [schema12.const];
|
|
142096
|
+
delete schema12.const;
|
|
142097
142097
|
}
|
|
142098
142098
|
});
|
|
142099
|
-
rules.set("Add tsEnumNames to enum types", (
|
|
142099
|
+
rules.set("Add tsEnumNames to enum types", (schema12, _10, options8) => {
|
|
142100
142100
|
var _a7;
|
|
142101
|
-
if (isEnumTypeWithoutTsEnumNames(
|
|
142102
|
-
|
|
142101
|
+
if (isEnumTypeWithoutTsEnumNames(schema12) && options8.inferStringEnumKeysFromValues) {
|
|
142102
|
+
schema12.tsEnumNames = (_a7 = schema12.enum) === null || _a7 === undefined ? undefined : _a7.map(String);
|
|
142103
142103
|
}
|
|
142104
142104
|
});
|
|
142105
|
-
rules.set("Pre-calculate schema types and intersections", (
|
|
142106
|
-
if (
|
|
142107
|
-
(0, applySchemaTyping_1.applySchemaTyping)(
|
|
142105
|
+
rules.set("Pre-calculate schema types and intersections", (schema12) => {
|
|
142106
|
+
if (schema12 !== null && typeof schema12 === "object") {
|
|
142107
|
+
(0, applySchemaTyping_1.applySchemaTyping)(schema12);
|
|
142108
142108
|
}
|
|
142109
142109
|
});
|
|
142110
142110
|
function normalize2(rootSchema, dereferencedPaths, filename, options8) {
|
|
142111
|
-
rules.forEach((rule) => (0, utils_1.traverse)(rootSchema, (
|
|
142111
|
+
rules.forEach((rule) => (0, utils_1.traverse)(rootSchema, (schema12, key2) => rule(schema12, filename, options8, key2, dereferencedPaths)));
|
|
142112
142112
|
return rootSchema;
|
|
142113
142113
|
}
|
|
142114
142114
|
exports.normalize = normalize2;
|
|
@@ -142190,37 +142190,37 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142190
142190
|
var AST_1 = require_AST();
|
|
142191
142191
|
var JSONSchema_1 = require_JSONSchema();
|
|
142192
142192
|
var utils_1 = require_utils7();
|
|
142193
|
-
function parse11(
|
|
142194
|
-
if ((0, JSONSchema_1.isPrimitive)(
|
|
142195
|
-
if ((0, JSONSchema_1.isBoolean)(
|
|
142196
|
-
return parseBooleanSchema(
|
|
142193
|
+
function parse11(schema12, options8, keyName, processed = new Map, usedNames = new Set) {
|
|
142194
|
+
if ((0, JSONSchema_1.isPrimitive)(schema12)) {
|
|
142195
|
+
if ((0, JSONSchema_1.isBoolean)(schema12)) {
|
|
142196
|
+
return parseBooleanSchema(schema12, keyName, options8);
|
|
142197
142197
|
}
|
|
142198
|
-
return parseLiteral(
|
|
142198
|
+
return parseLiteral(schema12, keyName);
|
|
142199
142199
|
}
|
|
142200
|
-
const intersection2 =
|
|
142201
|
-
const types =
|
|
142200
|
+
const intersection2 = schema12[JSONSchema_1.Intersection];
|
|
142201
|
+
const types = schema12[JSONSchema_1.Types];
|
|
142202
142202
|
if (intersection2) {
|
|
142203
142203
|
const ast = parseAsTypeWithCache(intersection2, "ALL_OF", options8, keyName, processed, usedNames);
|
|
142204
142204
|
types.forEach((type) => {
|
|
142205
|
-
ast.params.push(parseAsTypeWithCache(
|
|
142205
|
+
ast.params.push(parseAsTypeWithCache(schema12, type, options8, keyName, processed, usedNames));
|
|
142206
142206
|
});
|
|
142207
|
-
(0, utils_1.log)("blue", "parser", "Types:", [...types], "Input:",
|
|
142207
|
+
(0, utils_1.log)("blue", "parser", "Types:", [...types], "Input:", schema12, "Output:", ast);
|
|
142208
142208
|
return ast;
|
|
142209
142209
|
}
|
|
142210
142210
|
if (types.size === 1) {
|
|
142211
142211
|
const type = [...types][0];
|
|
142212
|
-
const ast = parseAsTypeWithCache(
|
|
142213
|
-
(0, utils_1.log)("blue", "parser", "Type:", type, "Input:",
|
|
142212
|
+
const ast = parseAsTypeWithCache(schema12, type, options8, keyName, processed, usedNames);
|
|
142213
|
+
(0, utils_1.log)("blue", "parser", "Type:", type, "Input:", schema12, "Output:", ast);
|
|
142214
142214
|
return ast;
|
|
142215
142215
|
}
|
|
142216
142216
|
throw new ReferenceError("Expected intersection schema. Please file an issue on GitHub.");
|
|
142217
142217
|
}
|
|
142218
142218
|
exports.parse = parse11;
|
|
142219
|
-
function parseAsTypeWithCache(
|
|
142220
|
-
let cachedTypeMap = processed.get(
|
|
142219
|
+
function parseAsTypeWithCache(schema12, type, options8, keyName, processed = new Map, usedNames = new Set) {
|
|
142220
|
+
let cachedTypeMap = processed.get(schema12);
|
|
142221
142221
|
if (!cachedTypeMap) {
|
|
142222
142222
|
cachedTypeMap = new Map;
|
|
142223
|
-
processed.set(
|
|
142223
|
+
processed.set(schema12, cachedTypeMap);
|
|
142224
142224
|
}
|
|
142225
142225
|
const cachedAST = cachedTypeMap.get(type);
|
|
142226
142226
|
if (cachedAST) {
|
|
@@ -142228,10 +142228,10 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142228
142228
|
}
|
|
142229
142229
|
const ast = {};
|
|
142230
142230
|
cachedTypeMap.set(type, ast);
|
|
142231
|
-
return Object.assign(ast, parseNonLiteral(
|
|
142231
|
+
return Object.assign(ast, parseNonLiteral(schema12, type, options8, keyName, processed, usedNames));
|
|
142232
142232
|
}
|
|
142233
|
-
function parseBooleanSchema(
|
|
142234
|
-
if (
|
|
142233
|
+
function parseBooleanSchema(schema12, keyName, options8) {
|
|
142234
|
+
if (schema12) {
|
|
142235
142235
|
return {
|
|
142236
142236
|
keyName,
|
|
142237
142237
|
type: options8.unknownAny ? "UNKNOWN" : "ANY"
|
|
@@ -142242,157 +142242,157 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142242
142242
|
type: "NEVER"
|
|
142243
142243
|
};
|
|
142244
142244
|
}
|
|
142245
|
-
function parseLiteral(
|
|
142245
|
+
function parseLiteral(schema12, keyName) {
|
|
142246
142246
|
return {
|
|
142247
142247
|
keyName,
|
|
142248
|
-
params:
|
|
142248
|
+
params: schema12,
|
|
142249
142249
|
type: "LITERAL"
|
|
142250
142250
|
};
|
|
142251
142251
|
}
|
|
142252
|
-
function parseNonLiteral(
|
|
142253
|
-
const definitions = getDefinitionsMemoized((0, JSONSchema_1.getRootSchema)(
|
|
142254
|
-
const keyNameFromDefinition = (0, lodash_1.findKey)(definitions, (_10) => _10 ===
|
|
142252
|
+
function parseNonLiteral(schema12, type, options8, keyName, processed, usedNames) {
|
|
142253
|
+
const definitions = getDefinitionsMemoized((0, JSONSchema_1.getRootSchema)(schema12));
|
|
142254
|
+
const keyNameFromDefinition = (0, lodash_1.findKey)(definitions, (_10) => _10 === schema12);
|
|
142255
142255
|
switch (type) {
|
|
142256
142256
|
case "ALL_OF":
|
|
142257
142257
|
return {
|
|
142258
|
-
comment:
|
|
142259
|
-
deprecated:
|
|
142258
|
+
comment: schema12.description,
|
|
142259
|
+
deprecated: schema12.deprecated,
|
|
142260
142260
|
keyName,
|
|
142261
|
-
standaloneName: standaloneName(
|
|
142262
|
-
params:
|
|
142261
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142262
|
+
params: schema12.allOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142263
142263
|
type: "INTERSECTION"
|
|
142264
142264
|
};
|
|
142265
142265
|
case "ANY":
|
|
142266
|
-
return Object.assign(Object.assign({}, options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY), { comment:
|
|
142266
|
+
return Object.assign(Object.assign({}, options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY), { comment: schema12.description, deprecated: schema12.deprecated, keyName, standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8) });
|
|
142267
142267
|
case "ANY_OF":
|
|
142268
142268
|
return {
|
|
142269
|
-
comment:
|
|
142270
|
-
deprecated:
|
|
142269
|
+
comment: schema12.description,
|
|
142270
|
+
deprecated: schema12.deprecated,
|
|
142271
142271
|
keyName,
|
|
142272
|
-
standaloneName: standaloneName(
|
|
142273
|
-
params:
|
|
142272
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142273
|
+
params: schema12.anyOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142274
142274
|
type: "UNION"
|
|
142275
142275
|
};
|
|
142276
142276
|
case "BOOLEAN":
|
|
142277
142277
|
return {
|
|
142278
|
-
comment:
|
|
142279
|
-
deprecated:
|
|
142278
|
+
comment: schema12.description,
|
|
142279
|
+
deprecated: schema12.deprecated,
|
|
142280
142280
|
keyName,
|
|
142281
|
-
standaloneName: standaloneName(
|
|
142281
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142282
142282
|
type: "BOOLEAN"
|
|
142283
142283
|
};
|
|
142284
142284
|
case "CUSTOM_TYPE":
|
|
142285
142285
|
return {
|
|
142286
|
-
comment:
|
|
142287
|
-
deprecated:
|
|
142286
|
+
comment: schema12.description,
|
|
142287
|
+
deprecated: schema12.deprecated,
|
|
142288
142288
|
keyName,
|
|
142289
|
-
params:
|
|
142290
|
-
standaloneName: standaloneName(
|
|
142289
|
+
params: schema12.tsType,
|
|
142290
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142291
142291
|
type: "CUSTOM_TYPE"
|
|
142292
142292
|
};
|
|
142293
142293
|
case "NAMED_ENUM":
|
|
142294
142294
|
return {
|
|
142295
|
-
comment:
|
|
142296
|
-
deprecated:
|
|
142295
|
+
comment: schema12.description,
|
|
142296
|
+
deprecated: schema12.deprecated,
|
|
142297
142297
|
keyName,
|
|
142298
|
-
standaloneName: standaloneName(
|
|
142299
|
-
params:
|
|
142298
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition !== null && keyNameFromDefinition !== undefined ? keyNameFromDefinition : keyName, usedNames, options8),
|
|
142299
|
+
params: schema12.enum.map((_10, n5) => ({
|
|
142300
142300
|
ast: parseLiteral(_10, undefined),
|
|
142301
|
-
keyName:
|
|
142301
|
+
keyName: schema12.tsEnumNames[n5]
|
|
142302
142302
|
})),
|
|
142303
142303
|
type: "ENUM"
|
|
142304
142304
|
};
|
|
142305
142305
|
case "NAMED_SCHEMA":
|
|
142306
|
-
return newInterface(
|
|
142306
|
+
return newInterface(schema12, options8, processed, usedNames, keyName);
|
|
142307
142307
|
case "NEVER":
|
|
142308
142308
|
return {
|
|
142309
|
-
comment:
|
|
142310
|
-
deprecated:
|
|
142309
|
+
comment: schema12.description,
|
|
142310
|
+
deprecated: schema12.deprecated,
|
|
142311
142311
|
keyName,
|
|
142312
|
-
standaloneName: standaloneName(
|
|
142312
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142313
142313
|
type: "NEVER"
|
|
142314
142314
|
};
|
|
142315
142315
|
case "NULL":
|
|
142316
142316
|
return {
|
|
142317
|
-
comment:
|
|
142318
|
-
deprecated:
|
|
142317
|
+
comment: schema12.description,
|
|
142318
|
+
deprecated: schema12.deprecated,
|
|
142319
142319
|
keyName,
|
|
142320
|
-
standaloneName: standaloneName(
|
|
142320
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142321
142321
|
type: "NULL"
|
|
142322
142322
|
};
|
|
142323
142323
|
case "NUMBER":
|
|
142324
142324
|
return {
|
|
142325
|
-
comment:
|
|
142326
|
-
deprecated:
|
|
142325
|
+
comment: schema12.description,
|
|
142326
|
+
deprecated: schema12.deprecated,
|
|
142327
142327
|
keyName,
|
|
142328
|
-
standaloneName: standaloneName(
|
|
142328
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142329
142329
|
type: "NUMBER"
|
|
142330
142330
|
};
|
|
142331
142331
|
case "OBJECT":
|
|
142332
142332
|
return {
|
|
142333
|
-
comment:
|
|
142333
|
+
comment: schema12.description,
|
|
142334
142334
|
keyName,
|
|
142335
|
-
standaloneName: standaloneName(
|
|
142335
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142336
142336
|
type: "OBJECT",
|
|
142337
|
-
deprecated:
|
|
142337
|
+
deprecated: schema12.deprecated
|
|
142338
142338
|
};
|
|
142339
142339
|
case "ONE_OF":
|
|
142340
142340
|
return {
|
|
142341
|
-
comment:
|
|
142342
|
-
deprecated:
|
|
142341
|
+
comment: schema12.description,
|
|
142342
|
+
deprecated: schema12.deprecated,
|
|
142343
142343
|
keyName,
|
|
142344
|
-
standaloneName: standaloneName(
|
|
142345
|
-
params:
|
|
142344
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142345
|
+
params: schema12.oneOf.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142346
142346
|
type: "UNION"
|
|
142347
142347
|
};
|
|
142348
142348
|
case "REFERENCE":
|
|
142349
|
-
throw Error((0, util_1.format)("Refs should have been resolved by the resolver!",
|
|
142349
|
+
throw Error((0, util_1.format)("Refs should have been resolved by the resolver!", schema12));
|
|
142350
142350
|
case "STRING":
|
|
142351
142351
|
return {
|
|
142352
|
-
comment:
|
|
142353
|
-
deprecated:
|
|
142352
|
+
comment: schema12.description,
|
|
142353
|
+
deprecated: schema12.deprecated,
|
|
142354
142354
|
keyName,
|
|
142355
|
-
standaloneName: standaloneName(
|
|
142355
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142356
142356
|
type: "STRING"
|
|
142357
142357
|
};
|
|
142358
142358
|
case "TYPED_ARRAY":
|
|
142359
|
-
if (Array.isArray(
|
|
142360
|
-
const minItems2 =
|
|
142361
|
-
const maxItems2 =
|
|
142359
|
+
if (Array.isArray(schema12.items)) {
|
|
142360
|
+
const minItems2 = schema12.minItems;
|
|
142361
|
+
const maxItems2 = schema12.maxItems;
|
|
142362
142362
|
const arrayType = {
|
|
142363
|
-
comment:
|
|
142364
|
-
deprecated:
|
|
142363
|
+
comment: schema12.description,
|
|
142364
|
+
deprecated: schema12.deprecated,
|
|
142365
142365
|
keyName,
|
|
142366
142366
|
maxItems: maxItems2,
|
|
142367
142367
|
minItems: minItems2,
|
|
142368
|
-
standaloneName: standaloneName(
|
|
142369
|
-
params:
|
|
142368
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142369
|
+
params: schema12.items.map((_10) => parse11(_10, options8, undefined, processed, usedNames)),
|
|
142370
142370
|
type: "TUPLE"
|
|
142371
142371
|
};
|
|
142372
|
-
if (
|
|
142372
|
+
if (schema12.additionalItems === true) {
|
|
142373
142373
|
arrayType.spreadParam = options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY;
|
|
142374
|
-
} else if (
|
|
142375
|
-
arrayType.spreadParam = parse11(
|
|
142374
|
+
} else if (schema12.additionalItems) {
|
|
142375
|
+
arrayType.spreadParam = parse11(schema12.additionalItems, options8, undefined, processed, usedNames);
|
|
142376
142376
|
}
|
|
142377
142377
|
return arrayType;
|
|
142378
142378
|
} else {
|
|
142379
142379
|
return {
|
|
142380
|
-
comment:
|
|
142381
|
-
deprecated:
|
|
142380
|
+
comment: schema12.description,
|
|
142381
|
+
deprecated: schema12.deprecated,
|
|
142382
142382
|
keyName,
|
|
142383
|
-
standaloneName: standaloneName(
|
|
142384
|
-
params: parse11(
|
|
142383
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142384
|
+
params: parse11(schema12.items, options8, `{keyNameFromDefinition}Items`, processed, usedNames),
|
|
142385
142385
|
type: "ARRAY"
|
|
142386
142386
|
};
|
|
142387
142387
|
}
|
|
142388
142388
|
case "UNION":
|
|
142389
142389
|
return {
|
|
142390
|
-
comment:
|
|
142391
|
-
deprecated:
|
|
142390
|
+
comment: schema12.description,
|
|
142391
|
+
deprecated: schema12.deprecated,
|
|
142392
142392
|
keyName,
|
|
142393
|
-
standaloneName: standaloneName(
|
|
142394
|
-
params:
|
|
142395
|
-
const member = Object.assign(Object.assign({}, (0, lodash_1.omit)(
|
|
142393
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142394
|
+
params: schema12.type.map((type2) => {
|
|
142395
|
+
const member = Object.assign(Object.assign({}, (0, lodash_1.omit)(schema12, "$id", "description", "title")), { type: type2 });
|
|
142396
142396
|
(0, utils_1.maybeStripDefault)(member);
|
|
142397
142397
|
(0, applySchemaTyping_1.applySchemaTyping)(member);
|
|
142398
142398
|
return parse11(member, options8, undefined, processed, usedNames);
|
|
@@ -142401,80 +142401,80 @@ var require_parser2 = __commonJS((exports) => {
|
|
|
142401
142401
|
};
|
|
142402
142402
|
case "UNNAMED_ENUM":
|
|
142403
142403
|
return {
|
|
142404
|
-
comment:
|
|
142405
|
-
deprecated:
|
|
142404
|
+
comment: schema12.description,
|
|
142405
|
+
deprecated: schema12.deprecated,
|
|
142406
142406
|
keyName,
|
|
142407
|
-
standaloneName: standaloneName(
|
|
142408
|
-
params:
|
|
142407
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142408
|
+
params: schema12.enum.map((_10) => parseLiteral(_10, undefined)),
|
|
142409
142409
|
type: "UNION"
|
|
142410
142410
|
};
|
|
142411
142411
|
case "UNNAMED_SCHEMA":
|
|
142412
|
-
return newInterface(
|
|
142412
|
+
return newInterface(schema12, options8, processed, usedNames, keyName, keyNameFromDefinition);
|
|
142413
142413
|
case "UNTYPED_ARRAY":
|
|
142414
|
-
const minItems =
|
|
142415
|
-
const maxItems = typeof
|
|
142414
|
+
const minItems = schema12.minItems;
|
|
142415
|
+
const maxItems = typeof schema12.maxItems === "number" ? schema12.maxItems : -1;
|
|
142416
142416
|
const params = options8.unknownAny ? AST_1.T_UNKNOWN : AST_1.T_ANY;
|
|
142417
142417
|
if (minItems > 0 || maxItems >= 0) {
|
|
142418
142418
|
return {
|
|
142419
|
-
comment:
|
|
142420
|
-
deprecated:
|
|
142419
|
+
comment: schema12.description,
|
|
142420
|
+
deprecated: schema12.deprecated,
|
|
142421
142421
|
keyName,
|
|
142422
|
-
maxItems:
|
|
142422
|
+
maxItems: schema12.maxItems,
|
|
142423
142423
|
minItems,
|
|
142424
142424
|
params: Array(Math.max(maxItems, minItems) || 0).fill(params),
|
|
142425
142425
|
spreadParam: maxItems >= 0 ? undefined : params,
|
|
142426
|
-
standaloneName: standaloneName(
|
|
142426
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142427
142427
|
type: "TUPLE"
|
|
142428
142428
|
};
|
|
142429
142429
|
}
|
|
142430
142430
|
return {
|
|
142431
|
-
comment:
|
|
142432
|
-
deprecated:
|
|
142431
|
+
comment: schema12.description,
|
|
142432
|
+
deprecated: schema12.deprecated,
|
|
142433
142433
|
keyName,
|
|
142434
142434
|
params,
|
|
142435
|
-
standaloneName: standaloneName(
|
|
142435
|
+
standaloneName: standaloneName(schema12, keyNameFromDefinition, usedNames, options8),
|
|
142436
142436
|
type: "ARRAY"
|
|
142437
142437
|
};
|
|
142438
142438
|
}
|
|
142439
142439
|
}
|
|
142440
|
-
function standaloneName(
|
|
142440
|
+
function standaloneName(schema12, keyNameFromDefinition, usedNames, options8) {
|
|
142441
142441
|
var _a7;
|
|
142442
|
-
const name2 = ((_a7 = options8.customName) === null || _a7 === undefined ? undefined : _a7.call(options8,
|
|
142442
|
+
const name2 = ((_a7 = options8.customName) === null || _a7 === undefined ? undefined : _a7.call(options8, schema12, keyNameFromDefinition)) || schema12.title || schema12.$id || keyNameFromDefinition;
|
|
142443
142443
|
if (name2) {
|
|
142444
142444
|
return (0, utils_1.generateName)(name2, usedNames);
|
|
142445
142445
|
}
|
|
142446
142446
|
}
|
|
142447
|
-
function newInterface(
|
|
142448
|
-
const name2 = standaloneName(
|
|
142447
|
+
function newInterface(schema12, options8, processed, usedNames, keyName, keyNameFromDefinition) {
|
|
142448
|
+
const name2 = standaloneName(schema12, keyNameFromDefinition, usedNames, options8);
|
|
142449
142449
|
return {
|
|
142450
|
-
comment:
|
|
142451
|
-
deprecated:
|
|
142450
|
+
comment: schema12.description,
|
|
142451
|
+
deprecated: schema12.deprecated,
|
|
142452
142452
|
keyName,
|
|
142453
|
-
params: parseSchema(
|
|
142453
|
+
params: parseSchema(schema12, options8, processed, usedNames, name2),
|
|
142454
142454
|
standaloneName: name2,
|
|
142455
|
-
superTypes: parseSuperTypes(
|
|
142455
|
+
superTypes: parseSuperTypes(schema12, options8, processed, usedNames),
|
|
142456
142456
|
type: "INTERFACE"
|
|
142457
142457
|
};
|
|
142458
142458
|
}
|
|
142459
|
-
function parseSuperTypes(
|
|
142460
|
-
const superTypes =
|
|
142459
|
+
function parseSuperTypes(schema12, options8, processed, usedNames) {
|
|
142460
|
+
const superTypes = schema12.extends;
|
|
142461
142461
|
if (!superTypes) {
|
|
142462
142462
|
return [];
|
|
142463
142463
|
}
|
|
142464
142464
|
return superTypes.map((_10) => parse11(_10, options8, undefined, processed, usedNames));
|
|
142465
142465
|
}
|
|
142466
|
-
function parseSchema(
|
|
142467
|
-
let asts = (0, lodash_1.map)(
|
|
142466
|
+
function parseSchema(schema12, options8, processed, usedNames, parentSchemaName) {
|
|
142467
|
+
let asts = (0, lodash_1.map)(schema12.properties, (value, key2) => ({
|
|
142468
142468
|
ast: parse11(value, options8, key2, processed, usedNames),
|
|
142469
142469
|
isPatternProperty: false,
|
|
142470
|
-
isRequired: (0, lodash_1.includes)(
|
|
142470
|
+
isRequired: (0, lodash_1.includes)(schema12.required || [], key2),
|
|
142471
142471
|
isUnreachableDefinition: false,
|
|
142472
142472
|
keyName: key2
|
|
142473
142473
|
}));
|
|
142474
142474
|
let singlePatternProperty = false;
|
|
142475
|
-
if (
|
|
142476
|
-
singlePatternProperty = !
|
|
142477
|
-
asts = asts.concat((0, lodash_1.map)(
|
|
142475
|
+
if (schema12.patternProperties) {
|
|
142476
|
+
singlePatternProperty = !schema12.additionalProperties && Object.keys(schema12.patternProperties).length === 1;
|
|
142477
|
+
asts = asts.concat((0, lodash_1.map)(schema12.patternProperties, (value, key2) => {
|
|
142478
142478
|
const ast = parse11(value, options8, key2, processed, usedNames);
|
|
142479
142479
|
const comment = `This interface was referenced by \`${parentSchemaName}\`'s JSON-Schema definition
|
|
142480
142480
|
via the \`patternProperty\` "${key2.replace("*/", "*\\/")}".`;
|
|
@@ -142484,14 +142484,14 @@ ${comment}` : comment;
|
|
|
142484
142484
|
return {
|
|
142485
142485
|
ast,
|
|
142486
142486
|
isPatternProperty: !singlePatternProperty,
|
|
142487
|
-
isRequired: singlePatternProperty || (0, lodash_1.includes)(
|
|
142487
|
+
isRequired: singlePatternProperty || (0, lodash_1.includes)(schema12.required || [], key2),
|
|
142488
142488
|
isUnreachableDefinition: false,
|
|
142489
142489
|
keyName: singlePatternProperty ? "[k: string]" : key2
|
|
142490
142490
|
};
|
|
142491
142491
|
}));
|
|
142492
142492
|
}
|
|
142493
142493
|
if (options8.unreachableDefinitions) {
|
|
142494
|
-
asts = asts.concat((0, lodash_1.map)(
|
|
142494
|
+
asts = asts.concat((0, lodash_1.map)(schema12.$defs, (value, key2) => {
|
|
142495
142495
|
const ast = parse11(value, options8, key2, processed, usedNames);
|
|
142496
142496
|
const comment = `This interface was referenced by \`${parentSchemaName}\`'s JSON-Schema
|
|
142497
142497
|
via the \`definition\` "${key2}".`;
|
|
@@ -142501,13 +142501,13 @@ ${comment}` : comment;
|
|
|
142501
142501
|
return {
|
|
142502
142502
|
ast,
|
|
142503
142503
|
isPatternProperty: false,
|
|
142504
|
-
isRequired: (0, lodash_1.includes)(
|
|
142504
|
+
isRequired: (0, lodash_1.includes)(schema12.required || [], key2),
|
|
142505
142505
|
isUnreachableDefinition: true,
|
|
142506
142506
|
keyName: key2
|
|
142507
142507
|
};
|
|
142508
142508
|
}));
|
|
142509
142509
|
}
|
|
142510
|
-
switch (
|
|
142510
|
+
switch (schema12.additionalProperties) {
|
|
142511
142511
|
case undefined:
|
|
142512
142512
|
case true:
|
|
142513
142513
|
if (singlePatternProperty) {
|
|
@@ -142524,7 +142524,7 @@ ${comment}` : comment;
|
|
|
142524
142524
|
return asts;
|
|
142525
142525
|
default:
|
|
142526
142526
|
return asts.concat({
|
|
142527
|
-
ast: parse11(
|
|
142527
|
+
ast: parse11(schema12.additionalProperties, options8, "[k: string]", processed, usedNames),
|
|
142528
142528
|
isPatternProperty: false,
|
|
142529
142529
|
isRequired: true,
|
|
142530
142530
|
isUnreachableDefinition: false,
|
|
@@ -142532,22 +142532,22 @@ ${comment}` : comment;
|
|
|
142532
142532
|
});
|
|
142533
142533
|
}
|
|
142534
142534
|
}
|
|
142535
|
-
function getDefinitions(
|
|
142536
|
-
if (processed.has(
|
|
142535
|
+
function getDefinitions(schema12, isSchema = true, processed = new Set) {
|
|
142536
|
+
if (processed.has(schema12)) {
|
|
142537
142537
|
return {};
|
|
142538
142538
|
}
|
|
142539
|
-
processed.add(
|
|
142540
|
-
if (Array.isArray(
|
|
142541
|
-
return
|
|
142539
|
+
processed.add(schema12);
|
|
142540
|
+
if (Array.isArray(schema12)) {
|
|
142541
|
+
return schema12.reduce((prev, cur) => Object.assign(Object.assign({}, prev), getDefinitions(cur, false, processed)), {});
|
|
142542
142542
|
}
|
|
142543
|
-
if ((0, lodash_1.isPlainObject)(
|
|
142544
|
-
return Object.assign(Object.assign({}, isSchema && hasDefinitions(
|
|
142543
|
+
if ((0, lodash_1.isPlainObject)(schema12)) {
|
|
142544
|
+
return Object.assign(Object.assign({}, isSchema && hasDefinitions(schema12) ? schema12.$defs : {}), Object.keys(schema12).reduce((prev, cur) => Object.assign(Object.assign({}, prev), getDefinitions(schema12[cur], false, processed)), {}));
|
|
142545
142545
|
}
|
|
142546
142546
|
return {};
|
|
142547
142547
|
}
|
|
142548
142548
|
var getDefinitionsMemoized = (0, lodash_1.memoize)(getDefinitions);
|
|
142549
|
-
function hasDefinitions(
|
|
142550
|
-
return "$defs" in
|
|
142549
|
+
function hasDefinitions(schema12) {
|
|
142550
|
+
return "$defs" in schema12;
|
|
142551
142551
|
}
|
|
142552
142552
|
});
|
|
142553
142553
|
|
|
@@ -143925,7 +143925,7 @@ var require_parse7 = __commonJS((exports) => {
|
|
|
143925
143925
|
extension: url3.getExtension(path18)
|
|
143926
143926
|
};
|
|
143927
143927
|
try {
|
|
143928
|
-
const resolver = await
|
|
143928
|
+
const resolver = await readFile7(file2, options8, $refs);
|
|
143929
143929
|
$ref.pathType = resolver.plugin.name;
|
|
143930
143930
|
file2.data = resolver.result;
|
|
143931
143931
|
const parser2 = await parseFile(file2, options8, $refs);
|
|
@@ -143938,7 +143938,7 @@ var require_parse7 = __commonJS((exports) => {
|
|
|
143938
143938
|
throw err;
|
|
143939
143939
|
}
|
|
143940
143940
|
}
|
|
143941
|
-
async function
|
|
143941
|
+
async function readFile7(file2, options8, $refs) {
|
|
143942
143942
|
let resolvers = plugins.all(options8.resolve);
|
|
143943
143943
|
resolvers = plugins.filter(resolvers, "canRead", file2);
|
|
143944
143944
|
plugins.sort(resolvers);
|
|
@@ -144371,7 +144371,7 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144371
144371
|
var options_js_1 = require_options();
|
|
144372
144372
|
function normalizeArgs(_args) {
|
|
144373
144373
|
let path18;
|
|
144374
|
-
let
|
|
144374
|
+
let schema12;
|
|
144375
144375
|
let options8;
|
|
144376
144376
|
let callback;
|
|
144377
144377
|
const args = Array.prototype.slice.call(_args);
|
|
@@ -144381,15 +144381,15 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144381
144381
|
if (typeof args[0] === "string") {
|
|
144382
144382
|
path18 = args[0];
|
|
144383
144383
|
if (typeof args[2] === "object") {
|
|
144384
|
-
|
|
144384
|
+
schema12 = args[1];
|
|
144385
144385
|
options8 = args[2];
|
|
144386
144386
|
} else {
|
|
144387
|
-
|
|
144387
|
+
schema12 = undefined;
|
|
144388
144388
|
options8 = args[1];
|
|
144389
144389
|
}
|
|
144390
144390
|
} else {
|
|
144391
144391
|
path18 = "";
|
|
144392
|
-
|
|
144392
|
+
schema12 = args[0];
|
|
144393
144393
|
options8 = args[1];
|
|
144394
144394
|
}
|
|
144395
144395
|
try {
|
|
@@ -144397,12 +144397,12 @@ var require_normalize_args = __commonJS((exports) => {
|
|
|
144397
144397
|
} catch (e8) {
|
|
144398
144398
|
console.error(`JSON Schema Ref Parser: Error normalizing options: ${e8}`);
|
|
144399
144399
|
}
|
|
144400
|
-
if (!options8.mutateInputSchema && typeof
|
|
144401
|
-
|
|
144400
|
+
if (!options8.mutateInputSchema && typeof schema12 === "object") {
|
|
144401
|
+
schema12 = JSON.parse(JSON.stringify(schema12));
|
|
144402
144402
|
}
|
|
144403
144403
|
return {
|
|
144404
144404
|
path: path18,
|
|
144405
|
-
schema:
|
|
144405
|
+
schema: schema12,
|
|
144406
144406
|
options: options8,
|
|
144407
144407
|
callback
|
|
144408
144408
|
};
|
|
@@ -145191,12 +145191,12 @@ var require_resolver = __commonJS((exports) => {
|
|
|
145191
145191
|
var json_schema_ref_parser_1 = require_lib3();
|
|
145192
145192
|
var utils_1 = require_utils7();
|
|
145193
145193
|
function dereference(schema_1, _a7) {
|
|
145194
|
-
return __awaiter(this, arguments, undefined, function* (
|
|
145195
|
-
(0, utils_1.log)("green", "dereferencer", "Dereferencing input schema:", cwd,
|
|
145194
|
+
return __awaiter(this, arguments, undefined, function* (schema12, { cwd, $refOptions }) {
|
|
145195
|
+
(0, utils_1.log)("green", "dereferencer", "Dereferencing input schema:", cwd, schema12);
|
|
145196
145196
|
const parser2 = new json_schema_ref_parser_1.$RefParser;
|
|
145197
145197
|
const dereferencedPaths = new WeakMap;
|
|
145198
|
-
const dereferencedSchema = yield parser2.dereference(cwd,
|
|
145199
|
-
dereferencedPaths.set(
|
|
145198
|
+
const dereferencedSchema = yield parser2.dereference(cwd, schema12, Object.assign(Object.assign({}, $refOptions), { dereference: Object.assign(Object.assign({}, $refOptions.dereference), { onDereference($ref, schema13) {
|
|
145199
|
+
dereferencedPaths.set(schema13, $ref);
|
|
145200
145200
|
} }) }));
|
|
145201
145201
|
return { dereferencedPaths, dereferencedSchema };
|
|
145202
145202
|
});
|
|
@@ -145210,46 +145210,46 @@ var require_validator = __commonJS((exports) => {
|
|
|
145210
145210
|
exports.validate = undefined;
|
|
145211
145211
|
var utils_1 = require_utils7();
|
|
145212
145212
|
var rules = new Map;
|
|
145213
|
-
rules.set("Enum members and tsEnumNames must be of the same length", (
|
|
145214
|
-
if (
|
|
145213
|
+
rules.set("Enum members and tsEnumNames must be of the same length", (schema12) => {
|
|
145214
|
+
if (schema12.enum && schema12.tsEnumNames && schema12.enum.length !== schema12.tsEnumNames.length) {
|
|
145215
145215
|
return false;
|
|
145216
145216
|
}
|
|
145217
145217
|
});
|
|
145218
|
-
rules.set("tsEnumNames must be an array of strings", (
|
|
145219
|
-
if (
|
|
145218
|
+
rules.set("tsEnumNames must be an array of strings", (schema12) => {
|
|
145219
|
+
if (schema12.tsEnumNames && schema12.tsEnumNames.some((_10) => typeof _10 !== "string")) {
|
|
145220
145220
|
return false;
|
|
145221
145221
|
}
|
|
145222
145222
|
});
|
|
145223
|
-
rules.set("When both maxItems and minItems are present, maxItems >= minItems", (
|
|
145224
|
-
const { maxItems, minItems } =
|
|
145223
|
+
rules.set("When both maxItems and minItems are present, maxItems >= minItems", (schema12) => {
|
|
145224
|
+
const { maxItems, minItems } = schema12;
|
|
145225
145225
|
if (typeof maxItems === "number" && typeof minItems === "number") {
|
|
145226
145226
|
return maxItems >= minItems;
|
|
145227
145227
|
}
|
|
145228
145228
|
});
|
|
145229
|
-
rules.set("When maxItems exists, maxItems >= 0", (
|
|
145230
|
-
const { maxItems } =
|
|
145229
|
+
rules.set("When maxItems exists, maxItems >= 0", (schema12) => {
|
|
145230
|
+
const { maxItems } = schema12;
|
|
145231
145231
|
if (typeof maxItems === "number") {
|
|
145232
145232
|
return maxItems >= 0;
|
|
145233
145233
|
}
|
|
145234
145234
|
});
|
|
145235
|
-
rules.set("When minItems exists, minItems >= 0", (
|
|
145236
|
-
const { minItems } =
|
|
145235
|
+
rules.set("When minItems exists, minItems >= 0", (schema12) => {
|
|
145236
|
+
const { minItems } = schema12;
|
|
145237
145237
|
if (typeof minItems === "number") {
|
|
145238
145238
|
return minItems >= 0;
|
|
145239
145239
|
}
|
|
145240
145240
|
});
|
|
145241
|
-
rules.set("deprecated must be a boolean", (
|
|
145242
|
-
const typeOfDeprecated = typeof
|
|
145241
|
+
rules.set("deprecated must be a boolean", (schema12) => {
|
|
145242
|
+
const typeOfDeprecated = typeof schema12.deprecated;
|
|
145243
145243
|
return typeOfDeprecated === "boolean" || typeOfDeprecated === "undefined";
|
|
145244
145244
|
});
|
|
145245
|
-
function validate2(
|
|
145245
|
+
function validate2(schema12, filename) {
|
|
145246
145246
|
const errors5 = [];
|
|
145247
145247
|
rules.forEach((rule, ruleName) => {
|
|
145248
|
-
(0, utils_1.traverse)(
|
|
145249
|
-
if (rule(
|
|
145248
|
+
(0, utils_1.traverse)(schema12, (schema13, key2) => {
|
|
145249
|
+
if (rule(schema13) === false) {
|
|
145250
145250
|
errors5.push(`Error at key "${key2}" in file "${filename}": ${ruleName}`);
|
|
145251
145251
|
}
|
|
145252
|
-
return
|
|
145252
|
+
return schema13;
|
|
145253
145253
|
});
|
|
145254
145254
|
});
|
|
145255
145255
|
return errors5;
|
|
@@ -145263,25 +145263,25 @@ var require_linker = __commonJS((exports) => {
|
|
|
145263
145263
|
exports.link = undefined;
|
|
145264
145264
|
var JSONSchema_1 = require_JSONSchema();
|
|
145265
145265
|
var lodash_1 = require_lodash8();
|
|
145266
|
-
function link2(
|
|
145267
|
-
if (!Array.isArray(
|
|
145268
|
-
return
|
|
145266
|
+
function link2(schema12, parent = null) {
|
|
145267
|
+
if (!Array.isArray(schema12) && !(0, lodash_1.isPlainObject)(schema12)) {
|
|
145268
|
+
return schema12;
|
|
145269
145269
|
}
|
|
145270
|
-
if (
|
|
145271
|
-
return
|
|
145270
|
+
if (schema12.hasOwnProperty(JSONSchema_1.Parent)) {
|
|
145271
|
+
return schema12;
|
|
145272
145272
|
}
|
|
145273
|
-
Object.defineProperty(
|
|
145273
|
+
Object.defineProperty(schema12, JSONSchema_1.Parent, {
|
|
145274
145274
|
enumerable: false,
|
|
145275
145275
|
value: parent,
|
|
145276
145276
|
writable: false
|
|
145277
145277
|
});
|
|
145278
|
-
if (Array.isArray(
|
|
145279
|
-
|
|
145278
|
+
if (Array.isArray(schema12)) {
|
|
145279
|
+
schema12.forEach((child) => link2(child, schema12));
|
|
145280
145280
|
}
|
|
145281
|
-
for (const key2 in
|
|
145282
|
-
link2(
|
|
145281
|
+
for (const key2 in schema12) {
|
|
145282
|
+
link2(schema12[key2], schema12);
|
|
145283
145283
|
}
|
|
145284
|
-
return
|
|
145284
|
+
return schema12;
|
|
145285
145285
|
}
|
|
145286
145286
|
exports.link = link2;
|
|
145287
145287
|
});
|
|
@@ -145373,8 +145373,8 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145373
145373
|
unknownAny: true
|
|
145374
145374
|
};
|
|
145375
145375
|
function compileFromFile(filename, options8 = exports.DEFAULT_OPTIONS) {
|
|
145376
|
-
const
|
|
145377
|
-
return compile(
|
|
145376
|
+
const schema12 = parseAsJSONSchema(filename);
|
|
145377
|
+
return compile(schema12, (0, utils_1.stripExtension)(filename), Object.assign({ cwd: (0, path_1.dirname)(filename) }, options8));
|
|
145378
145378
|
}
|
|
145379
145379
|
exports.compileFromFile = compileFromFile;
|
|
145380
145380
|
function parseAsJSONSchema(filename) {
|
|
@@ -145384,7 +145384,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145384
145384
|
return (0, utils_1.parseFileAsJSONSchema)(filename, contents.toString());
|
|
145385
145385
|
}
|
|
145386
145386
|
function compile(schema_1, name_1) {
|
|
145387
|
-
return __awaiter(this, arguments, undefined, function* (
|
|
145387
|
+
return __awaiter(this, arguments, undefined, function* (schema12, name2, options8 = {}) {
|
|
145388
145388
|
(0, optionValidator_1.validateOptions)(options8);
|
|
145389
145389
|
const _options = (0, lodash_1.merge)({}, exports.DEFAULT_OPTIONS, options8);
|
|
145390
145390
|
const start = Date.now();
|
|
@@ -145394,7 +145394,7 @@ var require_src3 = __commonJS((exports) => {
|
|
|
145394
145394
|
if (!(0, lodash_1.endsWith)(_options.cwd, "/")) {
|
|
145395
145395
|
_options.cwd += "/";
|
|
145396
145396
|
}
|
|
145397
|
-
const _schema = (0, lodash_1.cloneDeep)(
|
|
145397
|
+
const _schema = (0, lodash_1.cloneDeep)(schema12);
|
|
145398
145398
|
const { dereferencedPaths, dereferencedSchema } = yield (0, resolver_1.dereference)(_schema, _options);
|
|
145399
145399
|
if (process.env.VERBOSE) {
|
|
145400
145400
|
if ((0, util_1.isDeepStrictEqual)(_schema, dereferencedSchema)) {
|
|
@@ -221220,7 +221220,7 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
221220
221220
|
determineAgent: () => determineAgent
|
|
221221
221221
|
});
|
|
221222
221222
|
module.exports = __toCommonJS2(src_exports);
|
|
221223
|
-
var
|
|
221223
|
+
var import_promises26 = __require("node:fs/promises");
|
|
221224
221224
|
var import_node_fs24 = __require("node:fs");
|
|
221225
221225
|
var DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
221226
221226
|
var CURSOR2 = "cursor";
|
|
@@ -221278,7 +221278,7 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
221278
221278
|
return { isAgent: true, agent: { name: REPLIT } };
|
|
221279
221279
|
}
|
|
221280
221280
|
try {
|
|
221281
|
-
await (0,
|
|
221281
|
+
await (0, import_promises26.access)(DEVIN_LOCAL_PATH, import_node_fs24.constants.F_OK);
|
|
221282
221282
|
return { isAgent: true, agent: { name: DEVIN } };
|
|
221283
221283
|
} catch (error48) {}
|
|
221284
221284
|
return { isAgent: false, agent: undefined };
|
|
@@ -245661,6 +245661,45 @@ var DeployResponseSchema = exports_external.object({
|
|
|
245661
245661
|
var PublishedUrlResponseSchema = exports_external.object({
|
|
245662
245662
|
url: exports_external.string()
|
|
245663
245663
|
});
|
|
245664
|
+
var CreateDeploymentResponseSchema = exports_external.object({
|
|
245665
|
+
deployment_id: exports_external.string(),
|
|
245666
|
+
asset_uploads: exports_external.discriminatedUnion("type", [
|
|
245667
|
+
exports_external.object({
|
|
245668
|
+
type: exports_external.literal("cf"),
|
|
245669
|
+
url: exports_external.string(),
|
|
245670
|
+
jwt: exports_external.string(),
|
|
245671
|
+
buckets: exports_external.array(exports_external.array(exports_external.string()))
|
|
245672
|
+
}),
|
|
245673
|
+
exports_external.object({
|
|
245674
|
+
type: exports_external.literal("s3"),
|
|
245675
|
+
uploads: exports_external.array(exports_external.object({
|
|
245676
|
+
path: exports_external.string(),
|
|
245677
|
+
content_type: exports_external.string(),
|
|
245678
|
+
content_length: exports_external.number(),
|
|
245679
|
+
url: exports_external.string()
|
|
245680
|
+
}))
|
|
245681
|
+
})
|
|
245682
|
+
]).nullable().optional()
|
|
245683
|
+
}).transform((data) => ({
|
|
245684
|
+
deploymentId: data.deployment_id,
|
|
245685
|
+
assetUploads: data.asset_uploads == null ? null : data.asset_uploads.type === "cf" ? data.asset_uploads : {
|
|
245686
|
+
type: "s3",
|
|
245687
|
+
uploads: data.asset_uploads.uploads.map((upload) => ({
|
|
245688
|
+
path: upload.path,
|
|
245689
|
+
contentType: upload.content_type,
|
|
245690
|
+
contentLength: upload.content_length,
|
|
245691
|
+
url: upload.url
|
|
245692
|
+
}))
|
|
245693
|
+
}
|
|
245694
|
+
}));
|
|
245695
|
+
var AssetUploadResponseSchema = exports_external.looseObject({
|
|
245696
|
+
result: exports_external.looseObject({ jwt: exports_external.string().nullable().optional() }).nullable().optional()
|
|
245697
|
+
});
|
|
245698
|
+
var FinalizeDeploymentResponseSchema = exports_external.object({
|
|
245699
|
+
deployment_id: exports_external.string()
|
|
245700
|
+
}).transform((data) => ({
|
|
245701
|
+
deploymentId: data.deployment_id
|
|
245702
|
+
}));
|
|
245664
245703
|
|
|
245665
245704
|
// src/core/project/api.ts
|
|
245666
245705
|
var PUBLIC_SETTINGS = {
|
|
@@ -248255,97 +248294,6 @@ async function uploadSite(archivePath) {
|
|
|
248255
248294
|
}
|
|
248256
248295
|
return result.data;
|
|
248257
248296
|
}
|
|
248258
|
-
// src/core/site/config.ts
|
|
248259
|
-
async function getSiteFilePaths(outputDir) {
|
|
248260
|
-
return await globby("**/*", {
|
|
248261
|
-
cwd: outputDir,
|
|
248262
|
-
onlyFiles: true,
|
|
248263
|
-
absolute: false
|
|
248264
|
-
});
|
|
248265
|
-
}
|
|
248266
|
-
// src/core/site/deploy.ts
|
|
248267
|
-
import { randomUUID } from "node:crypto";
|
|
248268
|
-
import { tmpdir } from "node:os";
|
|
248269
|
-
import { join as join14 } from "node:path";
|
|
248270
|
-
async function deploySite(siteOutputDir) {
|
|
248271
|
-
if (!await pathExists(siteOutputDir)) {
|
|
248272
|
-
throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
|
|
248273
|
-
hints: [
|
|
248274
|
-
{ message: "Run your build command (e.g., 'npm run build') first" }
|
|
248275
|
-
]
|
|
248276
|
-
});
|
|
248277
|
-
}
|
|
248278
|
-
const filePaths = await getSiteFilePaths(siteOutputDir);
|
|
248279
|
-
if (filePaths.length === 0) {
|
|
248280
|
-
throw new ConfigInvalidError(`No files found in output directory: ${siteOutputDir}. Make sure to build your project first.`, siteOutputDir, {
|
|
248281
|
-
hints: [
|
|
248282
|
-
{ message: "Run your build command (e.g., 'npm run build') first" }
|
|
248283
|
-
]
|
|
248284
|
-
});
|
|
248285
|
-
}
|
|
248286
|
-
const archivePath = join14(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
|
|
248287
|
-
try {
|
|
248288
|
-
await createArchive(siteOutputDir, archivePath);
|
|
248289
|
-
return await uploadSite(archivePath);
|
|
248290
|
-
} finally {
|
|
248291
|
-
await deleteFile(archivePath);
|
|
248292
|
-
}
|
|
248293
|
-
}
|
|
248294
|
-
async function createArchive(pathToArchive, targetArchivePath) {
|
|
248295
|
-
await create({
|
|
248296
|
-
gzip: true,
|
|
248297
|
-
file: targetArchivePath,
|
|
248298
|
-
cwd: pathToArchive
|
|
248299
|
-
}, ["."]);
|
|
248300
|
-
}
|
|
248301
|
-
// src/core/site/deploy-app.ts
|
|
248302
|
-
import { resolve as resolve5 } from "node:path";
|
|
248303
|
-
|
|
248304
|
-
// src/core/deployments/api.ts
|
|
248305
|
-
import { readFile as readFile2 } from "node:fs/promises";
|
|
248306
|
-
|
|
248307
|
-
// src/core/deployments/schema.ts
|
|
248308
|
-
var CreateDeploymentResponseSchema = exports_external.object({
|
|
248309
|
-
deployment_id: exports_external.string(),
|
|
248310
|
-
asset_uploads: exports_external.discriminatedUnion("type", [
|
|
248311
|
-
exports_external.object({
|
|
248312
|
-
type: exports_external.literal("cf"),
|
|
248313
|
-
url: exports_external.string(),
|
|
248314
|
-
jwt: exports_external.string(),
|
|
248315
|
-
buckets: exports_external.array(exports_external.array(exports_external.string()))
|
|
248316
|
-
}),
|
|
248317
|
-
exports_external.object({
|
|
248318
|
-
type: exports_external.literal("s3"),
|
|
248319
|
-
uploads: exports_external.array(exports_external.object({
|
|
248320
|
-
path: exports_external.string(),
|
|
248321
|
-
content_type: exports_external.string(),
|
|
248322
|
-
content_length: exports_external.number(),
|
|
248323
|
-
url: exports_external.string()
|
|
248324
|
-
}))
|
|
248325
|
-
})
|
|
248326
|
-
]).nullable().optional()
|
|
248327
|
-
}).transform((data) => ({
|
|
248328
|
-
deploymentId: data.deployment_id,
|
|
248329
|
-
assetUploads: data.asset_uploads == null ? null : data.asset_uploads.type === "cf" ? data.asset_uploads : {
|
|
248330
|
-
type: "s3",
|
|
248331
|
-
uploads: data.asset_uploads.uploads.map((upload) => ({
|
|
248332
|
-
path: upload.path,
|
|
248333
|
-
contentType: upload.content_type,
|
|
248334
|
-
contentLength: upload.content_length,
|
|
248335
|
-
url: upload.url
|
|
248336
|
-
}))
|
|
248337
|
-
}
|
|
248338
|
-
}));
|
|
248339
|
-
var AssetUploadResponseSchema = exports_external.looseObject({
|
|
248340
|
-
result: exports_external.looseObject({ jwt: exports_external.string().nullable().optional() }).nullable().optional()
|
|
248341
|
-
});
|
|
248342
|
-
var FinalizeDeploymentResponseSchema = exports_external.object({
|
|
248343
|
-
deployment_id: exports_external.string()
|
|
248344
|
-
}).transform((data) => ({
|
|
248345
|
-
deploymentId: data.deployment_id
|
|
248346
|
-
}));
|
|
248347
|
-
|
|
248348
|
-
// src/core/deployments/api.ts
|
|
248349
248297
|
var MODULE_CONTENT_TYPES = {
|
|
248350
248298
|
esm: "application/javascript+module",
|
|
248351
248299
|
sourcemap: "application/source-map",
|
|
@@ -248386,7 +248334,7 @@ async function finalizeDeployment(deploymentId, completionJwt, modules) {
|
|
|
248386
248334
|
const formData = new FormData;
|
|
248387
248335
|
formData.append("payload", JSON.stringify({ completion_jwt: completionJwt }));
|
|
248388
248336
|
for (const module of modules) {
|
|
248389
|
-
const content = await
|
|
248337
|
+
const content = await readFile(module.absolutePath);
|
|
248390
248338
|
formData.append(module.name, new File([new Uint8Array(content)], module.name, {
|
|
248391
248339
|
type: MODULE_CONTENT_TYPES[module.type]
|
|
248392
248340
|
}));
|
|
@@ -248412,9 +248360,55 @@ async function postFinalize(deploymentId, formData) {
|
|
|
248412
248360
|
}
|
|
248413
248361
|
return result.data;
|
|
248414
248362
|
}
|
|
248415
|
-
// src/core/
|
|
248363
|
+
// src/core/site/config.ts
|
|
248364
|
+
async function getSiteFilePaths(outputDir) {
|
|
248365
|
+
return await globby("**/*", {
|
|
248366
|
+
cwd: outputDir,
|
|
248367
|
+
onlyFiles: true,
|
|
248368
|
+
absolute: false
|
|
248369
|
+
});
|
|
248370
|
+
}
|
|
248371
|
+
// src/core/site/deploy.ts
|
|
248372
|
+
import { randomUUID } from "node:crypto";
|
|
248373
|
+
import { tmpdir } from "node:os";
|
|
248374
|
+
import { join as join14 } from "node:path";
|
|
248375
|
+
async function deploySite(siteOutputDir) {
|
|
248376
|
+
if (!await pathExists(siteOutputDir)) {
|
|
248377
|
+
throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
|
|
248378
|
+
hints: [
|
|
248379
|
+
{ message: "Run your build command (e.g., 'npm run build') first" }
|
|
248380
|
+
]
|
|
248381
|
+
});
|
|
248382
|
+
}
|
|
248383
|
+
const filePaths = await getSiteFilePaths(siteOutputDir);
|
|
248384
|
+
if (filePaths.length === 0) {
|
|
248385
|
+
throw new ConfigInvalidError(`No files found in output directory: ${siteOutputDir}. Make sure to build your project first.`, siteOutputDir, {
|
|
248386
|
+
hints: [
|
|
248387
|
+
{ message: "Run your build command (e.g., 'npm run build') first" }
|
|
248388
|
+
]
|
|
248389
|
+
});
|
|
248390
|
+
}
|
|
248391
|
+
const archivePath = join14(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
|
|
248392
|
+
try {
|
|
248393
|
+
await createArchive(siteOutputDir, archivePath);
|
|
248394
|
+
return await uploadSite(archivePath);
|
|
248395
|
+
} finally {
|
|
248396
|
+
await deleteFile(archivePath);
|
|
248397
|
+
}
|
|
248398
|
+
}
|
|
248399
|
+
async function createArchive(pathToArchive, targetArchivePath) {
|
|
248400
|
+
await create({
|
|
248401
|
+
gzip: true,
|
|
248402
|
+
file: targetArchivePath,
|
|
248403
|
+
cwd: pathToArchive
|
|
248404
|
+
}, ["."]);
|
|
248405
|
+
}
|
|
248406
|
+
// src/core/site/deploy-app.ts
|
|
248407
|
+
import { resolve as resolve5 } from "node:path";
|
|
248408
|
+
|
|
248409
|
+
// src/core/site/manifest.ts
|
|
248416
248410
|
import { createHash } from "node:crypto";
|
|
248417
|
-
import { readFile as
|
|
248411
|
+
import { readFile as readFile2, stat } from "node:fs/promises";
|
|
248418
248412
|
import { basename as basename4, extname, join as join15 } from "node:path";
|
|
248419
248413
|
var MAX_ASSET_SIZE_BYTES = 25 * 1024 * 1024;
|
|
248420
248414
|
var MAX_ASSET_COUNT = 1e5;
|
|
@@ -248480,7 +248474,7 @@ async function buildAssetManifest(assetsDir, appId) {
|
|
|
248480
248474
|
if (size > MAX_ASSET_SIZE_BYTES) {
|
|
248481
248475
|
throw new InvalidInputError(`Static asset "${relativePath}" is ${size} bytes, which exceeds the 25 MiB per-file limit.`);
|
|
248482
248476
|
}
|
|
248483
|
-
const content = await
|
|
248477
|
+
const content = await readFile2(absolutePath);
|
|
248484
248478
|
const hash2 = hashAsset(appId, content);
|
|
248485
248479
|
manifest[`/${relativePath}`] = { hash: hash2, size };
|
|
248486
248480
|
if (!filesByHash.has(hash2)) {
|
|
@@ -248495,7 +248489,7 @@ async function buildAssetManifest(assetsDir, appId) {
|
|
|
248495
248489
|
return { manifest, filesByHash };
|
|
248496
248490
|
}
|
|
248497
248491
|
|
|
248498
|
-
// src/core/
|
|
248492
|
+
// src/core/site/modules.ts
|
|
248499
248493
|
import { stat as stat2 } from "node:fs/promises";
|
|
248500
248494
|
import { relative as relative3, resolve as resolve3, sep } from "node:path";
|
|
248501
248495
|
var MAX_TOTAL_MODULE_BYTES = 40 * 1024 * 1024;
|
|
@@ -248590,8 +248584,8 @@ function addSourcemap(modulesByName, configDir, name2) {
|
|
|
248590
248584
|
});
|
|
248591
248585
|
}
|
|
248592
248586
|
|
|
248593
|
-
// src/core/
|
|
248594
|
-
import { readFile as
|
|
248587
|
+
// src/core/site/upload.ts
|
|
248588
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
248595
248589
|
|
|
248596
248590
|
// ../../node_modules/p-map/index.js
|
|
248597
248591
|
async function pMap(iterable, mapper, {
|
|
@@ -248717,7 +248711,7 @@ async function pMap(iterable, mapper, {
|
|
|
248717
248711
|
}
|
|
248718
248712
|
var pMapSkip = Symbol("skip");
|
|
248719
248713
|
|
|
248720
|
-
// src/core/
|
|
248714
|
+
// src/core/site/upload.ts
|
|
248721
248715
|
var DEFAULT_UPLOAD_CONCURRENCY = 3;
|
|
248722
248716
|
var MAX_UPLOAD_CONCURRENCY = 50;
|
|
248723
248717
|
var MAX_UPLOAD_ATTEMPTS = 3;
|
|
@@ -248775,7 +248769,7 @@ async function buildBucketForm(bucket, filesByHash) {
|
|
|
248775
248769
|
if (!file2) {
|
|
248776
248770
|
throw new InternalError(`Server requested upload of unknown asset hash: ${hash2}`);
|
|
248777
248771
|
}
|
|
248778
|
-
const content = await
|
|
248772
|
+
const content = await readFile3(file2.absolutePath);
|
|
248779
248773
|
formData.append(hash2, new File([content.toString("base64")], hash2, { type: file2.contentType }));
|
|
248780
248774
|
}
|
|
248781
248775
|
return formData;
|
|
@@ -248795,7 +248789,7 @@ async function uploadPresignedAsset(upload, assets) {
|
|
|
248795
248789
|
if (!file2) {
|
|
248796
248790
|
throw new InternalError(`Server requested upload of unknown asset path: ${upload.path}`);
|
|
248797
248791
|
}
|
|
248798
|
-
const content = await
|
|
248792
|
+
const content = await readFile3(file2.absolutePath);
|
|
248799
248793
|
try {
|
|
248800
248794
|
await distribution_default.put(upload.url, {
|
|
248801
248795
|
body: new Uint8Array(content),
|
|
@@ -248814,7 +248808,7 @@ function sleep3(ms) {
|
|
|
248814
248808
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
248815
248809
|
}
|
|
248816
248810
|
|
|
248817
|
-
// src/core/
|
|
248811
|
+
// src/core/site/wrangler-config.ts
|
|
248818
248812
|
import { dirname as dirname10, join as join16, resolve as resolve4 } from "node:path";
|
|
248819
248813
|
var WRANGLER_REDIRECT_PATH = join16(".wrangler", "deploy", "config.json");
|
|
248820
248814
|
var RedirectConfigSchema = exports_external.looseObject({
|
|
@@ -248900,7 +248894,7 @@ function toResolvedAssetsConfig(assets) {
|
|
|
248900
248894
|
};
|
|
248901
248895
|
}
|
|
248902
248896
|
|
|
248903
|
-
// src/core/
|
|
248897
|
+
// src/core/site/full-stack.ts
|
|
248904
248898
|
async function deployFullStack(options) {
|
|
248905
248899
|
const { projectRoot, gitHash, concurrency, progress } = options;
|
|
248906
248900
|
const config9 = await resolveWranglerConfig(projectRoot);
|
|
@@ -248957,6 +248951,7 @@ function buildAssetsConfig(assetsConfig, progress) {
|
|
|
248957
248951
|
run_worker_first: runWorkerFirst
|
|
248958
248952
|
};
|
|
248959
248953
|
}
|
|
248954
|
+
|
|
248960
248955
|
// ../../node_modules/is-plain-obj/index.js
|
|
248961
248956
|
function isPlainObject2(value) {
|
|
248962
248957
|
if (typeof value !== "object" || value === null) {
|
|
@@ -255459,7 +255454,7 @@ function isGitCommitHash(value) {
|
|
|
255459
255454
|
return GIT_HASH_PATTERN.test(value);
|
|
255460
255455
|
}
|
|
255461
255456
|
|
|
255462
|
-
// src/core/
|
|
255457
|
+
// src/core/site/git-hash.ts
|
|
255463
255458
|
async function resolveGitHash(projectRoot, explicit) {
|
|
255464
255459
|
const hash2 = explicit ?? await gitHead(projectRoot);
|
|
255465
255460
|
if (!hash2 || !isGitCommitHash(hash2)) {
|
|
@@ -255483,8 +255478,9 @@ async function gitHead(projectRoot) {
|
|
|
255483
255478
|
return null;
|
|
255484
255479
|
}
|
|
255485
255480
|
}
|
|
255486
|
-
|
|
255487
|
-
|
|
255481
|
+
|
|
255482
|
+
// src/core/site/static-site.ts
|
|
255483
|
+
import { readFile as readFile4 } from "node:fs/promises";
|
|
255488
255484
|
import { join as join17 } from "node:path";
|
|
255489
255485
|
var STATIC_DEPLOYMENTS_ENV = "BASE44_STATIC_DEPLOYMENTS";
|
|
255490
255486
|
function staticDeploymentsEnabled(env2 = process.env) {
|
|
@@ -255515,10 +255511,11 @@ async function deployStaticSite(options) {
|
|
|
255515
255511
|
onProgress: progress?.onAssetUpload
|
|
255516
255512
|
});
|
|
255517
255513
|
}
|
|
255518
|
-
const indexHtml = await
|
|
255514
|
+
const indexHtml = await readFile4(join17(outputDir, "index.html"));
|
|
255519
255515
|
const finalized = await finalizeStaticDeployment(created.deploymentId, new Uint8Array(indexHtml));
|
|
255520
255516
|
return { deploymentId: finalized.deploymentId, gitHash };
|
|
255521
255517
|
}
|
|
255518
|
+
|
|
255522
255519
|
// src/core/site/deploy-app.ts
|
|
255523
255520
|
async function planAppDeploy(target) {
|
|
255524
255521
|
if (await detectFullStackArtifact(target.root)) {
|
|
@@ -258299,7 +258296,7 @@ async function completeProjectSetup({
|
|
|
258299
258296
|
projectId,
|
|
258300
258297
|
name: name2,
|
|
258301
258298
|
resolvedPath,
|
|
258302
|
-
deploy:
|
|
258299
|
+
deploy: deploy5,
|
|
258303
258300
|
skills,
|
|
258304
258301
|
isInteractive
|
|
258305
258302
|
}, { runTask: runTask2 }) {
|
|
@@ -258313,7 +258310,7 @@ async function completeProjectSetup({
|
|
|
258313
258310
|
});
|
|
258314
258311
|
shouldPushEntities = !Ct(result) && result;
|
|
258315
258312
|
} else {
|
|
258316
|
-
shouldPushEntities = !!
|
|
258313
|
+
shouldPushEntities = !!deploy5;
|
|
258317
258314
|
}
|
|
258318
258315
|
if (shouldPushEntities) {
|
|
258319
258316
|
await runTask2(`Pushing ${entities.length} data models to Base44...`, async () => {
|
|
@@ -258333,7 +258330,7 @@ async function completeProjectSetup({
|
|
|
258333
258330
|
});
|
|
258334
258331
|
shouldDeploy = !Ct(result) && result;
|
|
258335
258332
|
} else {
|
|
258336
|
-
shouldDeploy = !!
|
|
258333
|
+
shouldDeploy = !!deploy5;
|
|
258337
258334
|
}
|
|
258338
258335
|
if (shouldDeploy && installCommand && buildCommand && outputDirectory) {
|
|
258339
258336
|
const { appUrl } = await runTask2("Installing dependencies...", async (updateMessage) => {
|
|
@@ -258487,7 +258484,7 @@ async function executeCreate({
|
|
|
258487
258484
|
name: rawName,
|
|
258488
258485
|
description,
|
|
258489
258486
|
projectPath,
|
|
258490
|
-
deploy:
|
|
258487
|
+
deploy: deploy5,
|
|
258491
258488
|
skills,
|
|
258492
258489
|
workspaceId: flagWorkspaceId,
|
|
258493
258490
|
isInteractive
|
|
@@ -258509,7 +258506,7 @@ async function executeCreate({
|
|
|
258509
258506
|
errorMessage: "Failed to create project"
|
|
258510
258507
|
});
|
|
258511
258508
|
setAppContext({ id: projectId, projectRoot: resolvedPath });
|
|
258512
|
-
const summary = await completeProjectSetup({ projectId, name: name2, resolvedPath, deploy:
|
|
258509
|
+
const summary = await completeProjectSetup({ projectId, name: name2, resolvedPath, deploy: deploy5, skills, isInteractive }, ctx);
|
|
258513
258510
|
printProjectSummary(summary, log);
|
|
258514
258511
|
return { outroMessage: "Your project is set up and ready to use" };
|
|
258515
258512
|
}
|
|
@@ -259295,7 +259292,7 @@ function withSandboxAuthHint(error48) {
|
|
|
259295
259292
|
cause: error48
|
|
259296
259293
|
});
|
|
259297
259294
|
}
|
|
259298
|
-
async function callTool(appId, tool, payload,
|
|
259295
|
+
async function callTool(appId, tool, payload, schema12, context, timeout2 = 60000) {
|
|
259299
259296
|
const client = getSandboxClient(appId);
|
|
259300
259297
|
let response;
|
|
259301
259298
|
try {
|
|
@@ -259303,7 +259300,7 @@ async function callTool(appId, tool, payload, schema13, context, timeout2 = 6000
|
|
|
259303
259300
|
} catch (error48) {
|
|
259304
259301
|
throw withSandboxAuthHint(await ApiError.fromHttpError(error48, context));
|
|
259305
259302
|
}
|
|
259306
|
-
const result =
|
|
259303
|
+
const result = schema12.safeParse(await response.json());
|
|
259307
259304
|
if (!result.success) {
|
|
259308
259305
|
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
259309
259306
|
}
|
|
@@ -259312,7 +259309,7 @@ async function callTool(appId, tool, payload, schema13, context, timeout2 = 6000
|
|
|
259312
259309
|
function listDirectory(appId, params) {
|
|
259313
259310
|
return callTool(appId, "list_directory", { ...params }, ListDirectoryResponseSchema, "listing directory");
|
|
259314
259311
|
}
|
|
259315
|
-
function
|
|
259312
|
+
function readFile5(appId, params) {
|
|
259316
259313
|
return callTool(appId, "read_file", { ...params }, ReadFileResponseSchema, "reading file");
|
|
259317
259314
|
}
|
|
259318
259315
|
function writeFile2(appId, params) {
|
|
@@ -259442,7 +259439,7 @@ async function readFileAction({ runTask: runTask2 }, paths, options) {
|
|
|
259442
259439
|
const { id: appId } = getAppContext();
|
|
259443
259440
|
const offset = parsePositiveInt(options.offset, "--offset");
|
|
259444
259441
|
const limit = parsePositiveInt(options.limit, "--limit");
|
|
259445
|
-
const result = await runTask2("Reading file", () =>
|
|
259442
|
+
const result = await runTask2("Reading file", () => readFile5(appId, { paths, offset, limit }));
|
|
259446
259443
|
return { outroMessage: "Read file", stdout: toJsonStdout(result) };
|
|
259447
259444
|
}
|
|
259448
259445
|
function getSandboxReadFileCommand() {
|
|
@@ -259710,9 +259707,9 @@ async function generateContent(input) {
|
|
|
259710
259707
|
`);
|
|
259711
259708
|
}
|
|
259712
259709
|
async function compileEntity(entity2) {
|
|
259713
|
-
const { name: name2, source: _source, ...
|
|
259710
|
+
const { name: name2, source: _source, ...schema12 } = entity2;
|
|
259714
259711
|
const jsonSchema = {
|
|
259715
|
-
...
|
|
259712
|
+
...schema12,
|
|
259716
259713
|
title: name2,
|
|
259717
259714
|
additionalProperties: false
|
|
259718
259715
|
};
|
|
@@ -261002,22 +260999,22 @@ class Database {
|
|
|
261002
260999
|
this.schemas.clear();
|
|
261003
261000
|
}
|
|
261004
261001
|
validate(entityName, record2, partial2 = false) {
|
|
261005
|
-
const
|
|
261006
|
-
if (!
|
|
261002
|
+
const schema12 = this.schemas.get(this.normalizeName(entityName));
|
|
261003
|
+
if (!schema12) {
|
|
261007
261004
|
throw new Error(`Entity "${entityName}" not found`);
|
|
261008
261005
|
}
|
|
261009
|
-
return this.validator.validate(record2,
|
|
261006
|
+
return this.validator.validate(record2, schema12, partial2);
|
|
261010
261007
|
}
|
|
261011
261008
|
prepareRecord(entityName, record2, partial2 = false) {
|
|
261012
|
-
const
|
|
261013
|
-
if (!
|
|
261009
|
+
const schema12 = this.schemas.get(this.normalizeName(entityName));
|
|
261010
|
+
if (!schema12) {
|
|
261014
261011
|
throw new Error(`Entity "${entityName}" not found`);
|
|
261015
261012
|
}
|
|
261016
|
-
const filteredRecord = this.validator.filterFields(record2,
|
|
261013
|
+
const filteredRecord = this.validator.filterFields(record2, schema12);
|
|
261017
261014
|
if (partial2) {
|
|
261018
261015
|
return filteredRecord;
|
|
261019
261016
|
}
|
|
261020
|
-
return this.validator.applyDefaults(filteredRecord,
|
|
261017
|
+
return this.validator.applyDefaults(filteredRecord, schema12);
|
|
261021
261018
|
}
|
|
261022
261019
|
normalizeName(entityName) {
|
|
261023
261020
|
return entityName.toLowerCase();
|
|
@@ -261311,13 +261308,13 @@ function checkRLS(rule, record2, user) {
|
|
|
261311
261308
|
return false;
|
|
261312
261309
|
return evaluateCondition(rule, record2, user);
|
|
261313
261310
|
}
|
|
261314
|
-
function applyFLS(record2,
|
|
261311
|
+
function applyFLS(record2, schema12, user, operation) {
|
|
261315
261312
|
if (Array.isArray(record2)) {
|
|
261316
|
-
return record2.map((r5) => applyFLS(r5,
|
|
261313
|
+
return record2.map((r5) => applyFLS(r5, schema12, user, operation));
|
|
261317
261314
|
}
|
|
261318
261315
|
const result = {};
|
|
261319
261316
|
for (const [key2, value] of Object.entries(record2)) {
|
|
261320
|
-
const rule =
|
|
261317
|
+
const rule = schema12.properties[key2]?.rls?.[operation];
|
|
261321
261318
|
if (rule === undefined || checkRLS(rule, record2, user)) {
|
|
261322
261319
|
result[key2] = value;
|
|
261323
261320
|
}
|
|
@@ -261545,14 +261542,14 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261545
261542
|
res.status(404).json({ error: `Entity "${entityName}" not found` });
|
|
261546
261543
|
return;
|
|
261547
261544
|
}
|
|
261548
|
-
const
|
|
261549
|
-
if (!
|
|
261545
|
+
const schema12 = db2.getSchema(entityName);
|
|
261546
|
+
if (!schema12) {
|
|
261550
261547
|
res.status(404).json({ error: `Schema for "${entityName}" not found` });
|
|
261551
261548
|
return;
|
|
261552
261549
|
}
|
|
261553
261550
|
const currentUserResult = await resolveCurrentUser(db2, req);
|
|
261554
261551
|
const currentUser = currentUserResult.ok ? currentUserResult.user : undefined;
|
|
261555
|
-
await handler(req, res, collection,
|
|
261552
|
+
await handler(req, res, collection, schema12, currentUser);
|
|
261556
261553
|
};
|
|
261557
261554
|
}
|
|
261558
261555
|
function emit(appId, entityName, type, data) {
|
|
@@ -261570,19 +261567,19 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261570
261567
|
}
|
|
261571
261568
|
broadcast(appId, entityName, createData(data));
|
|
261572
261569
|
}
|
|
261573
|
-
function prepareCreateRecord(entityName, body,
|
|
261570
|
+
function prepareCreateRecord(entityName, body, schema12, currentUser, now) {
|
|
261574
261571
|
const { _id, ...recordBody } = body;
|
|
261575
261572
|
const ownerFields = {
|
|
261576
261573
|
created_by: currentUser?.email,
|
|
261577
261574
|
created_by_id: currentUser?.id
|
|
261578
261575
|
};
|
|
261579
|
-
if (!checkRLS(
|
|
261576
|
+
if (!checkRLS(schema12.rls?.create, {
|
|
261580
261577
|
...recordBody,
|
|
261581
261578
|
...ownerFields
|
|
261582
261579
|
}, currentUser)) {
|
|
261583
261580
|
return;
|
|
261584
261581
|
}
|
|
261585
|
-
const filteredBody = applyFLS(db2.prepareRecord(entityName, recordBody),
|
|
261582
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, recordBody), schema12, currentUser, "write");
|
|
261586
261583
|
db2.validate(entityName, filteredBody);
|
|
261587
261584
|
return {
|
|
261588
261585
|
...filteredBody,
|
|
@@ -261594,7 +261591,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261594
261591
|
}
|
|
261595
261592
|
const userRouter = createUserRouter(db2, logger2);
|
|
261596
261593
|
router.use("/User", userRouter);
|
|
261597
|
-
router.get("/:entityName/:id", withCollection(async (req, res, collection,
|
|
261594
|
+
router.get("/:entityName/:id", withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261598
261595
|
const { entityName, id: id2 } = req.params;
|
|
261599
261596
|
try {
|
|
261600
261597
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -261602,27 +261599,27 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261602
261599
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
261603
261600
|
return;
|
|
261604
261601
|
}
|
|
261605
|
-
if (!checkRLS(
|
|
261602
|
+
if (!checkRLS(schema12.rls?.read, doc2, currentUser)) {
|
|
261606
261603
|
res.status(404).json({
|
|
261607
261604
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
261608
261605
|
});
|
|
261609
261606
|
return;
|
|
261610
261607
|
}
|
|
261611
|
-
const result = applyFLS(stripInternalFields(doc2),
|
|
261608
|
+
const result = applyFLS(stripInternalFields(doc2), schema12, currentUser, "read");
|
|
261612
261609
|
res.json(result);
|
|
261613
261610
|
} catch (error48) {
|
|
261614
261611
|
logger2.error(`Error in GET /${entityName}/${id2}:`, error48);
|
|
261615
261612
|
res.status(500).json({ error: "Internal server error" });
|
|
261616
261613
|
}
|
|
261617
261614
|
}));
|
|
261618
|
-
router.get("/:entityName", withCollection(async (req, res, collection,
|
|
261615
|
+
router.get("/:entityName", withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261619
261616
|
const { entityName } = req.params;
|
|
261620
261617
|
try {
|
|
261621
261618
|
let results = stripInternalFields(await queryEntity(collection, req.query));
|
|
261622
|
-
if (
|
|
261623
|
-
results = results.filter((doc2) => checkRLS(
|
|
261619
|
+
if (schema12.rls?.read !== undefined && schema12.rls.read !== true) {
|
|
261620
|
+
results = results.filter((doc2) => checkRLS(schema12.rls.read, doc2, currentUser));
|
|
261624
261621
|
}
|
|
261625
|
-
results = results.map((doc2) => applyFLS(doc2,
|
|
261622
|
+
results = results.map((doc2) => applyFLS(doc2, schema12, currentUser, "read"));
|
|
261626
261623
|
res.json(results);
|
|
261627
261624
|
} catch (error48) {
|
|
261628
261625
|
if (error48 instanceof InvalidInputError) {
|
|
@@ -261633,16 +261630,16 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261633
261630
|
}
|
|
261634
261631
|
}
|
|
261635
261632
|
}));
|
|
261636
|
-
router.post("/:entityName", parseBody, withCollection(async (req, res, collection,
|
|
261633
|
+
router.post("/:entityName", parseBody, withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261637
261634
|
const { appId, entityName } = req.params;
|
|
261638
261635
|
try {
|
|
261639
261636
|
const now = new Date().toISOString();
|
|
261640
|
-
const record2 = prepareCreateRecord(entityName, req.body,
|
|
261637
|
+
const record2 = prepareCreateRecord(entityName, req.body, schema12, currentUser, now);
|
|
261641
261638
|
if (!record2) {
|
|
261642
261639
|
res.status(403).json({ error: "Permission denied" });
|
|
261643
261640
|
return;
|
|
261644
261641
|
}
|
|
261645
|
-
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)),
|
|
261642
|
+
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)), schema12, currentUser, "read");
|
|
261646
261643
|
emit(appId, entityName, "create", inserted);
|
|
261647
261644
|
res.status(201).json(inserted);
|
|
261648
261645
|
} catch (error48) {
|
|
@@ -261654,7 +261651,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261654
261651
|
res.status(500).json({ error: "Internal server error" });
|
|
261655
261652
|
}
|
|
261656
261653
|
}));
|
|
261657
|
-
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection,
|
|
261654
|
+
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261658
261655
|
const { appId, entityName } = req.params;
|
|
261659
261656
|
if (!Array.isArray(req.body)) {
|
|
261660
261657
|
res.status(400).json({ error: "Request body must be an array" });
|
|
@@ -261664,14 +261661,14 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261664
261661
|
const now = new Date().toISOString();
|
|
261665
261662
|
const records = [];
|
|
261666
261663
|
for (const body of req.body) {
|
|
261667
|
-
const record2 = prepareCreateRecord(entityName, body,
|
|
261664
|
+
const record2 = prepareCreateRecord(entityName, body, schema12, currentUser, now);
|
|
261668
261665
|
if (!record2) {
|
|
261669
261666
|
res.status(403).json({ error: "Permission denied" });
|
|
261670
261667
|
return;
|
|
261671
261668
|
}
|
|
261672
261669
|
records.push(record2);
|
|
261673
261670
|
}
|
|
261674
|
-
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(records)),
|
|
261671
|
+
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(records)), schema12, currentUser, "read");
|
|
261675
261672
|
emit(appId, entityName, "create", inserted);
|
|
261676
261673
|
res.status(201).json(inserted);
|
|
261677
261674
|
} catch (error48) {
|
|
@@ -261683,24 +261680,24 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261683
261680
|
res.status(500).json({ error: "Internal server error" });
|
|
261684
261681
|
}
|
|
261685
261682
|
}));
|
|
261686
|
-
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection,
|
|
261683
|
+
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261687
261684
|
const { appId, entityName, id: id2 } = req.params;
|
|
261688
261685
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
261689
261686
|
try {
|
|
261690
|
-
if (
|
|
261687
|
+
if (schema12.rls?.update !== undefined) {
|
|
261691
261688
|
const existing = await collection.findOneAsync({ id: id2 });
|
|
261692
261689
|
if (!existing) {
|
|
261693
261690
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
261694
261691
|
return;
|
|
261695
261692
|
}
|
|
261696
|
-
if (!checkRLS(
|
|
261693
|
+
if (!checkRLS(schema12.rls.update, existing, currentUser)) {
|
|
261697
261694
|
res.status(404).json({
|
|
261698
261695
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
261699
261696
|
});
|
|
261700
261697
|
return;
|
|
261701
261698
|
}
|
|
261702
261699
|
}
|
|
261703
|
-
const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true),
|
|
261700
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true), schema12, currentUser, "write");
|
|
261704
261701
|
db2.validate(entityName, filteredBody, true);
|
|
261705
261702
|
const updateData = {
|
|
261706
261703
|
...filteredBody,
|
|
@@ -261711,7 +261708,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261711
261708
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
261712
261709
|
return;
|
|
261713
261710
|
}
|
|
261714
|
-
const updated = applyFLS(stripInternalFields(result.affectedDocuments),
|
|
261711
|
+
const updated = applyFLS(stripInternalFields(result.affectedDocuments), schema12, currentUser, "read");
|
|
261715
261712
|
emit(appId, entityName, "update", updated);
|
|
261716
261713
|
res.json(updated);
|
|
261717
261714
|
} catch (error48) {
|
|
@@ -261723,7 +261720,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261723
261720
|
res.status(500).json({ error: "Internal server error" });
|
|
261724
261721
|
}
|
|
261725
261722
|
}));
|
|
261726
|
-
router.delete("/:entityName/:id", withCollection(async (req, res, collection,
|
|
261723
|
+
router.delete("/:entityName/:id", withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261727
261724
|
const { appId, entityName, id: id2 } = req.params;
|
|
261728
261725
|
try {
|
|
261729
261726
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -261731,7 +261728,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261731
261728
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
261732
261729
|
return;
|
|
261733
261730
|
}
|
|
261734
|
-
if (!checkRLS(
|
|
261731
|
+
if (!checkRLS(schema12.rls?.delete, doc2, currentUser)) {
|
|
261735
261732
|
res.status(404).json({
|
|
261736
261733
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
261737
261734
|
});
|
|
@@ -261745,11 +261742,11 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
261745
261742
|
res.status(500).json({ error: "Internal server error" });
|
|
261746
261743
|
}
|
|
261747
261744
|
}));
|
|
261748
|
-
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection,
|
|
261745
|
+
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection, schema12, currentUser) => {
|
|
261749
261746
|
const { entityName } = req.params;
|
|
261750
261747
|
try {
|
|
261751
261748
|
const query = req.body || {};
|
|
261752
|
-
const rlsDelete =
|
|
261749
|
+
const rlsDelete = schema12?.rls?.delete;
|
|
261753
261750
|
if (rlsDelete !== undefined && rlsDelete !== true) {
|
|
261754
261751
|
if (rlsDelete === false && currentUser?.is_service !== true) {
|
|
261755
261752
|
res.status(403).json({ error: "Permission denied" });
|
|
@@ -268426,4 +268423,4 @@ export {
|
|
|
268426
268423
|
CLIExitError
|
|
268427
268424
|
};
|
|
268428
268425
|
|
|
268429
|
-
//# debugId=
|
|
268426
|
+
//# debugId=0F2CA340A345A14E64756E2164756E21
|