@dbml/core 8.0.0-alpha.5 → 8.0.0-alpha.7
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/lib/index.cjs +70 -70
- package/lib/index.mjs +61 -28
- package/package.json +3 -3
package/lib/index.mjs
CHANGED
|
@@ -9400,9 +9400,9 @@ var useUtils = { visibleName(_, VY) {
|
|
|
9400
9400
|
nodeSymbol(_, VY) {
|
|
9401
9401
|
if (!isUseSpecifier(VY) || !VY.name) return Report.create(PASS_THROUGH);
|
|
9402
9402
|
let P = VY.getSymbolKind();
|
|
9403
|
-
if (P === void 0) return Report.create(PASS_THROUGH);
|
|
9403
|
+
if (P === void 0 || P === SymbolKind.Schema) return Report.create(PASS_THROUGH);
|
|
9404
9404
|
let HY = _.nodeReferee(VY.name).getFiltered(UNHANDLED);
|
|
9405
|
-
return HY && !HY.canBeImported
|
|
9405
|
+
return HY && !HY.canBeImported ? Report.create(PASS_THROUGH) : Report.create(_.symbolFactory.create(UseSymbol, {
|
|
9406
9406
|
useSpecifierDeclaration: VY,
|
|
9407
9407
|
declaration: HY?.declaration,
|
|
9408
9408
|
usedSymbol: HY,
|
|
@@ -10642,12 +10642,14 @@ var schemaModule = { symbolMembers(_, VY) {
|
|
|
10642
10642
|
for (let HY of P) KY.push(...expandTableGroup(_, VY, HY));
|
|
10643
10643
|
}
|
|
10644
10644
|
let qY = /* @__PURE__ */ new Set(), JY = KY.filter((_) => {
|
|
10645
|
+
if (_ instanceof UseSymbol && _.isKind(SymbolKind.Schema)) return !1;
|
|
10645
10646
|
let VY = `${_.originalSymbol.intern()}:${_.name ?? ""}`;
|
|
10646
10647
|
return qY.has(VY) ? !1 : (qY.add(VY), !0);
|
|
10647
10648
|
}), YY = /* @__PURE__ */ new Map();
|
|
10648
10649
|
for (let _ of JY) {
|
|
10649
10650
|
let VY = `${_.kind}:${_.name}`;
|
|
10650
10651
|
if (YY.get(VY)) {
|
|
10652
|
+
if (_.isKind(SymbolKind.Schema)) continue;
|
|
10651
10653
|
let VY = _ instanceof UseSymbol ? _.useSpecifierDeclaration ?? _.declaration : _.declaration instanceof ElementDeclarationNode && _.declaration.name ? _.declaration.name : _.declaration;
|
|
10652
10654
|
VY && _.name !== void 0 && GY.push(getDuplicateSchemaMemberError(_.kind, _.name, P.join("."), VY));
|
|
10653
10655
|
} else YY.set(VY, _);
|
|
@@ -10679,7 +10681,7 @@ function handleMemberSelectiveUses(_, VY, P, HY) {
|
|
|
10679
10681
|
function mergeImportedSchema(_, VY, P, HY = /* @__PURE__ */ new Set()) {
|
|
10680
10682
|
if (P.getSymbolKind() !== SymbolKind.Schema || !P.name) return [];
|
|
10681
10683
|
let UY = _.nodeReferee(P.name).getFiltered(UNHANDLED);
|
|
10682
|
-
if (!UY || !UY.isKind(SymbolKind.Schema) ||
|
|
10684
|
+
if (!UY || !UY.isKind(SymbolKind.Schema) || (_.nodeAlias(P).getFiltered(UNHANDLED) ?? _.nodeFullname(P).getFiltered(UNHANDLED)?.at(0)) !== VY.name) return [];
|
|
10683
10685
|
let WY = UY.intern();
|
|
10684
10686
|
if (HY.has(WY)) return [];
|
|
10685
10687
|
HY.add(WY);
|
|
@@ -13193,10 +13195,14 @@ function scanExistingUses(_, VY, P) {
|
|
|
13193
13195
|
let _ = HY.importKind.value ?? void 0;
|
|
13194
13196
|
_ && !VY.has(_.toLowerCase()) && (WY = _);
|
|
13195
13197
|
}
|
|
13196
|
-
WY && WY.toLowerCase() !== "from"
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13198
|
+
if (WY && WY.toLowerCase() !== "from") {
|
|
13199
|
+
let VY = HY.alias ? extractVariableFromExpression(HY.alias) : void 0;
|
|
13200
|
+
UY.push({
|
|
13201
|
+
kind: _,
|
|
13202
|
+
name: WY,
|
|
13203
|
+
alias: VY
|
|
13204
|
+
});
|
|
13205
|
+
}
|
|
13200
13206
|
}
|
|
13201
13207
|
} else _.specifiers instanceof WildcardNode && UY.push({ name: "*" });
|
|
13202
13208
|
if (UY.length === 0 && !(_.specifiers instanceof WildcardNode)) continue;
|
|
@@ -13220,7 +13226,7 @@ function mergeSymbolIntoUses(_, VY, P, HY, UY, WY) {
|
|
|
13220
13226
|
if (qY !== -1) {
|
|
13221
13227
|
let _ = GY[qY];
|
|
13222
13228
|
return _.specifiers.some((_) => _.name === VY) ? { topInsert: "" } : {
|
|
13223
|
-
topInsert: buildUseStatement(uniqueInOrder([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}`), JY]), KY, YY),
|
|
13229
|
+
topInsert: buildUseStatement(uniqueInOrder([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}${_.alias ? ` as ${_.alias}` : ""}`), JY]), KY, YY),
|
|
13224
13230
|
removeRange: expandToFullLines(WY, _.startOffset, _.endOffset)
|
|
13225
13231
|
};
|
|
13226
13232
|
}
|
|
@@ -14390,31 +14396,39 @@ function containerScopeKind(_, VY) {
|
|
|
14390
14396
|
function canonicalName(_, VY) {
|
|
14391
14397
|
let P = VY.originalSymbol;
|
|
14392
14398
|
if (P.filepath.intern() === _.intern()) return Report.create(fullnameToCanonical(this, P));
|
|
14393
|
-
let HY = this.
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
VY && GY.push(...VY);
|
|
14399
|
-
}
|
|
14400
|
-
for (let VY of GY) if (VY.filepath.intern() === _.intern() && VY.originalSymbol === P && (VY instanceof UseSymbol || VY instanceof AliasSymbol)) {
|
|
14401
|
-
let _ = VY.name;
|
|
14402
|
-
if (!_) continue;
|
|
14403
|
-
if (_ !== P.name) return Report.create({
|
|
14399
|
+
let HY = [...this.symbolUses(P).getValue(), ...this.symbolAliases(P).getValue()].filter((VY) => VY.filepath.equals(_));
|
|
14400
|
+
for (let _ of HY) {
|
|
14401
|
+
let VY = _.name;
|
|
14402
|
+
if (!VY) continue;
|
|
14403
|
+
if (VY !== P.name) return Report.create({
|
|
14404
14404
|
schema: "",
|
|
14405
|
-
name:
|
|
14405
|
+
name: VY
|
|
14406
14406
|
});
|
|
14407
|
-
let HY =
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
name:
|
|
14407
|
+
let HY = getSchemaChain(this, _);
|
|
14408
|
+
if (HY.length > 0) return Report.create({
|
|
14409
|
+
schema: HY.join("."),
|
|
14410
|
+
name: VY
|
|
14411
|
+
});
|
|
14412
|
+
let UY = fullnameToCanonical(this, P);
|
|
14413
|
+
return UY ? Report.create({
|
|
14414
|
+
...UY,
|
|
14415
|
+
name: VY
|
|
14411
14416
|
}) : Report.create({
|
|
14412
14417
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
14413
|
-
name:
|
|
14418
|
+
name: VY
|
|
14414
14419
|
});
|
|
14415
14420
|
}
|
|
14416
14421
|
return Report.create(fullnameToCanonical(this, P));
|
|
14417
14422
|
}
|
|
14423
|
+
function getSchemaChain(_, VY) {
|
|
14424
|
+
let P = [], HY = VY;
|
|
14425
|
+
for (; HY;) {
|
|
14426
|
+
let VY = _.symbolParent(HY).find((_) => _ instanceof SchemaSymbol && _.isKind(SymbolKind.Schema));
|
|
14427
|
+
if (!VY || VY.isPublicSchema()) break;
|
|
14428
|
+
P.unshift(VY.name ?? ""), HY = VY;
|
|
14429
|
+
}
|
|
14430
|
+
return P;
|
|
14431
|
+
}
|
|
14418
14432
|
function fullnameToCanonical(_, VY) {
|
|
14419
14433
|
if (!VY.declaration) return VY.name ? {
|
|
14420
14434
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
@@ -15609,11 +15623,30 @@ function resolutionIndex() {
|
|
|
15609
15623
|
};
|
|
15610
15624
|
P(VY);
|
|
15611
15625
|
}
|
|
15626
|
+
let GY = /* @__PURE__ */ new Map(), KY = /* @__PURE__ */ new Set();
|
|
15627
|
+
function qY(_, VY) {
|
|
15628
|
+
let P = VY.intern();
|
|
15629
|
+
if (KY.has(P)) return;
|
|
15630
|
+
KY.add(P);
|
|
15631
|
+
let HY = _.symbolMembers(VY).getFiltered(UNHANDLED);
|
|
15632
|
+
if (HY) for (let P of HY) {
|
|
15633
|
+
let HY = P.intern(), UY = GY.get(HY);
|
|
15634
|
+
UY || (UY = [], GY.set(HY, UY)), UY.push(VY), P instanceof SchemaSymbol && P.isKind(SymbolKind.Schema) && qY(_, P);
|
|
15635
|
+
}
|
|
15636
|
+
}
|
|
15637
|
+
for (let _ of P.values()) {
|
|
15638
|
+
let VY = _.getValue().ast, P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
|
|
15639
|
+
P && qY(this, P);
|
|
15640
|
+
}
|
|
15612
15641
|
return {
|
|
15613
15642
|
references: _,
|
|
15614
|
-
metadata: VY
|
|
15643
|
+
metadata: VY,
|
|
15644
|
+
parents: GY
|
|
15615
15645
|
};
|
|
15616
15646
|
}
|
|
15647
|
+
function symbolParent(_) {
|
|
15648
|
+
return this.resolutionIndex().parents.get(_.intern()) ?? [];
|
|
15649
|
+
}
|
|
15617
15650
|
function symbolReferences(_) {
|
|
15618
15651
|
return this.resolutionIndex().references.get(_.intern()) ?? [];
|
|
15619
15652
|
}
|
|
@@ -15898,7 +15931,7 @@ function computeDeleteEdit(_, VY, P) {
|
|
|
15898
15931
|
}
|
|
15899
15932
|
var COMPUTING = Symbol("COMPUTING"), Compiler = class {
|
|
15900
15933
|
constructor() {
|
|
15901
|
-
this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.layout = new MemoryProjectLayout(), this.globalCache = /* @__PURE__ */ new Map(), this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(parseFile), this.parseProject = this.globalQuery(parseProject), this.validateNode = this.localQuery(validateNode), this.validateFile = this.localQuery(validateFile), this.nodeFullname = this.localQuery(nodeFullname), this.nodeAlias = this.localQuery(nodeAlias), this.nodeSettings = this.localQuery(nodeSettings), this.canonicalName = this.globalQuery(canonicalName), this.bindNode = this.globalQuery(bindNode), this.bindFile = this.globalQuery(bindFile), this.bindProject = this.globalQuery(bindProject), this.interpretSymbol = this.globalQuery(interpretSymbol), this.interpretMetadata = interpretMetadata.bind(this), this.interpretFile = this.globalQuery(interpretFile), this.interpretProject = this.globalQuery(interpretProject), this.nodeSymbol = this.globalQuery(nodeSymbol), this.nodeMetadata = this.globalQuery(nodeMetadata), this.symbolMembers = this.globalQuery(symbolMembers), this.lookupMembers = this.globalQuery(lookupMembers), this.nodeReferee = this.globalQuery(nodeReferee), this.resolutionIndex = this.globalQuery(resolutionIndex), this.symbolReferences = this.globalQuery(symbolReferences), this.symbolMetadata = this.globalQuery(symbolMetadata), this.symbolAliases = this.globalQuery(symbolAliases), this.symbolUses = this.globalQuery(symbolUses), this.fileDependencies = this.localQuery(fileDependencies), this.reachableFiles = this.globalQuery(reachableFiles), this.usableMembers = this.globalQuery(usableMembers), this.nodeAtPosition = this.localQuery(nodeAtPosition), this.renameTable = renameTable$1.bind(this), this.syncDiagramView = syncDiagramView$1.bind(this), this.token = {
|
|
15934
|
+
this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.layout = new MemoryProjectLayout(), this.globalCache = /* @__PURE__ */ new Map(), this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(parseFile), this.parseProject = this.globalQuery(parseProject), this.validateNode = this.localQuery(validateNode), this.validateFile = this.localQuery(validateFile), this.nodeFullname = this.localQuery(nodeFullname), this.nodeAlias = this.localQuery(nodeAlias), this.nodeSettings = this.localQuery(nodeSettings), this.canonicalName = this.globalQuery(canonicalName), this.bindNode = this.globalQuery(bindNode), this.bindFile = this.globalQuery(bindFile), this.bindProject = this.globalQuery(bindProject), this.interpretSymbol = this.globalQuery(interpretSymbol), this.interpretMetadata = interpretMetadata.bind(this), this.interpretFile = this.globalQuery(interpretFile), this.interpretProject = this.globalQuery(interpretProject), this.nodeSymbol = this.globalQuery(nodeSymbol), this.nodeMetadata = this.globalQuery(nodeMetadata), this.symbolMembers = this.globalQuery(symbolMembers), this.lookupMembers = this.globalQuery(lookupMembers), this.nodeReferee = this.globalQuery(nodeReferee), this.resolutionIndex = this.globalQuery(resolutionIndex), this.symbolReferences = this.globalQuery(symbolReferences), this.symbolParent = this.globalQuery(symbolParent), this.symbolMetadata = this.globalQuery(symbolMetadata), this.symbolAliases = this.globalQuery(symbolAliases), this.symbolUses = this.globalQuery(symbolUses), this.fileDependencies = this.localQuery(fileDependencies), this.reachableFiles = this.globalQuery(reachableFiles), this.usableMembers = this.globalQuery(usableMembers), this.nodeAtPosition = this.localQuery(nodeAtPosition), this.renameTable = renameTable$1.bind(this), this.syncDiagramView = syncDiagramView$1.bind(this), this.token = {
|
|
15902
15935
|
invalidStream: this.localQuery(invalidStream),
|
|
15903
15936
|
flatStream: this.localQuery(flatStream)
|
|
15904
15937
|
}, this.parse = {
|
|
@@ -1825742,5 +1825775,5 @@ function findDiagramViewBlocks(_) {
|
|
|
1825742
1825775
|
let VY = new Compiler();
|
|
1825743
1825776
|
return VY.setSource(DEFAULT_ENTRY, _), VY.findDiagramViewBlocks(DEFAULT_ENTRY);
|
|
1825744
1825777
|
}
|
|
1825745
|
-
const VERSION = "8.0.0-alpha.
|
|
1825778
|
+
const VERSION = "8.0.0-alpha.7";
|
|
1825746
1825779
|
export { CompilerError, ModelExporter_default as ModelExporter, Parser_default as Parser, VERSION, addDoubleQuoteIfNeeded, dbmlMonarchTokensProvider, export_default as exporter, findDiagramViewBlocks, formatRecordValue, import_default as importer, isBinaryType, isBooleanType, isDateTimeType, isFloatType, isIntegerType, isNumericType, isSerialType, isStringType, renameTable, syncDiagramView, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@dbml/core",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.7",
|
|
5
5
|
"description": "> TODO: description",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lint:fix": "eslint --fix ."
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@dbml/parse": "^8.0.0-alpha.
|
|
49
|
+
"@dbml/parse": "^8.0.0-alpha.7",
|
|
50
50
|
"antlr4": "^4.13.1",
|
|
51
51
|
"lodash": "^4.18.1",
|
|
52
52
|
"lodash-es": "^4.18.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"bluebird": "^3.5.5"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "4c4389c0126b09613bc4daec1c4b938dddb3c434",
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=16"
|
|
63
63
|
}
|