@dbcube/schema-builder 5.1.1 → 5.1.4
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/bun.lockb +0 -0
- package/dist/index.cjs +34 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +129 -127
- package/dist/index.d.ts +129 -127
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/tsup.config.ts +1 -1
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -295,7 +295,7 @@ var CubeValidator = class {
|
|
|
295
295
|
validTypes = ["varchar", "int", "string", "text", "boolean", "date", "datetime", "timestamp", "decimal", "float", "double", "enum", "json"];
|
|
296
296
|
validOptions = ["not null", "primary", "autoincrement", "unique", "zerofill", "index", "required", "unsigned"];
|
|
297
297
|
validProperties = ["type", "length", "options", "value", "defaultValue", "foreign", "enumValues", "description"];
|
|
298
|
-
knownAnnotations = ["database", "table", "meta", "columns", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
|
|
298
|
+
knownAnnotations = ["database", "table", "meta", "columns", "indexes", "fields", "dataset", "beforeAdd", "afterAdd", "beforeUpdate", "afterUpdate", "beforeDelete", "afterDelete", "compute", "column", "changeName", "addColumn", "deleteColumn", "renameColumn", "changeType", "changeLength", "changeDefault", "changeOptions", "changeEnumValues"];
|
|
299
299
|
/**
|
|
300
300
|
* Validates a cube file comprehensively
|
|
301
301
|
*/
|
|
@@ -426,6 +426,18 @@ var CubeValidator = class {
|
|
|
426
426
|
if (/^\s*[a-zA-Z_][a-zA-Z0-9_]*\s*:\s*\{/.test(line)) {
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
|
+
if (this.isInsideIndexesBlock(content, lineNumber - 1)) {
|
|
430
|
+
const validIndexProperties = ["columns", "unique"];
|
|
431
|
+
if (!validIndexProperties.includes(propertyName)) {
|
|
432
|
+
errors.push({
|
|
433
|
+
itemName: fileName,
|
|
434
|
+
error: `Invalid index property '${propertyName}'. Valid index properties: ${validIndexProperties.join(", ")}`,
|
|
435
|
+
filePath,
|
|
436
|
+
lineNumber
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
429
441
|
if (this.isInsideForeignKeyObject(content, lineNumber - 1)) {
|
|
430
442
|
const validForeignKeyProperties = ["table", "column"];
|
|
431
443
|
if (!validForeignKeyProperties.includes(propertyName)) {
|
|
@@ -457,6 +469,27 @@ var CubeValidator = class {
|
|
|
457
469
|
});
|
|
458
470
|
}
|
|
459
471
|
}
|
|
472
|
+
isInsideIndexesBlock(content, lineIndex) {
|
|
473
|
+
const lines = content.split("\n");
|
|
474
|
+
let indexesStartLine = -1;
|
|
475
|
+
let indexesEndLine = -1;
|
|
476
|
+
for (let i = 0; i < lines.length; i++) {
|
|
477
|
+
if (lines[i].includes("@indexes")) {
|
|
478
|
+
indexesStartLine = i;
|
|
479
|
+
let braceCount = 0;
|
|
480
|
+
for (let j = i; j < lines.length; j++) {
|
|
481
|
+
braceCount += (lines[j].match(/\{/g) || []).length;
|
|
482
|
+
braceCount -= (lines[j].match(/\}/g) || []).length;
|
|
483
|
+
if (braceCount === 0 && j > i) {
|
|
484
|
+
indexesEndLine = j;
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return indexesStartLine !== -1 && indexesEndLine !== -1 && lineIndex > indexesStartLine && lineIndex < indexesEndLine;
|
|
492
|
+
}
|
|
460
493
|
validateRequiredColumnProperties(lines, lineNumber, filePath, fileName, errors) {
|
|
461
494
|
const line = lines[lineNumber - 1];
|
|
462
495
|
if (!/^\s*\}\s*;?\s*$/.test(line)) {
|