@dbml/core 8.0.0-alpha.5 → 8.0.0-alpha.6
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 +57 -26
- package/package.json +3 -3
package/lib/index.mjs
CHANGED
|
@@ -10679,7 +10679,7 @@ function handleMemberSelectiveUses(_, VY, P, HY) {
|
|
|
10679
10679
|
function mergeImportedSchema(_, VY, P, HY = /* @__PURE__ */ new Set()) {
|
|
10680
10680
|
if (P.getSymbolKind() !== SymbolKind.Schema || !P.name) return [];
|
|
10681
10681
|
let UY = _.nodeReferee(P.name).getFiltered(UNHANDLED);
|
|
10682
|
-
if (!UY || !UY.isKind(SymbolKind.Schema) ||
|
|
10682
|
+
if (!UY || !UY.isKind(SymbolKind.Schema) || (_.nodeAlias(P).getFiltered(UNHANDLED) ?? _.nodeFullname(P).getFiltered(UNHANDLED)?.at(0)) !== VY.name) return [];
|
|
10683
10683
|
let WY = UY.intern();
|
|
10684
10684
|
if (HY.has(WY)) return [];
|
|
10685
10685
|
HY.add(WY);
|
|
@@ -13193,10 +13193,14 @@ function scanExistingUses(_, VY, P) {
|
|
|
13193
13193
|
let _ = HY.importKind.value ?? void 0;
|
|
13194
13194
|
_ && !VY.has(_.toLowerCase()) && (WY = _);
|
|
13195
13195
|
}
|
|
13196
|
-
WY && WY.toLowerCase() !== "from"
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13196
|
+
if (WY && WY.toLowerCase() !== "from") {
|
|
13197
|
+
let VY = HY.alias ? extractVariableFromExpression(HY.alias) : void 0;
|
|
13198
|
+
UY.push({
|
|
13199
|
+
kind: _,
|
|
13200
|
+
name: WY,
|
|
13201
|
+
alias: VY
|
|
13202
|
+
});
|
|
13203
|
+
}
|
|
13200
13204
|
}
|
|
13201
13205
|
} else _.specifiers instanceof WildcardNode && UY.push({ name: "*" });
|
|
13202
13206
|
if (UY.length === 0 && !(_.specifiers instanceof WildcardNode)) continue;
|
|
@@ -13220,7 +13224,7 @@ function mergeSymbolIntoUses(_, VY, P, HY, UY, WY) {
|
|
|
13220
13224
|
if (qY !== -1) {
|
|
13221
13225
|
let _ = GY[qY];
|
|
13222
13226
|
return _.specifiers.some((_) => _.name === VY) ? { topInsert: "" } : {
|
|
13223
|
-
topInsert: buildUseStatement(uniqueInOrder([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}`), JY]), KY, YY),
|
|
13227
|
+
topInsert: buildUseStatement(uniqueInOrder([..._.specifiers.filter((_) => _.name !== "*").map((_) => `${_.kind ?? P} ${_.name}${_.alias ? ` as ${_.alias}` : ""}`), JY]), KY, YY),
|
|
13224
13228
|
removeRange: expandToFullLines(WY, _.startOffset, _.endOffset)
|
|
13225
13229
|
};
|
|
13226
13230
|
}
|
|
@@ -14390,31 +14394,39 @@ function containerScopeKind(_, VY) {
|
|
|
14390
14394
|
function canonicalName(_, VY) {
|
|
14391
14395
|
let P = VY.originalSymbol;
|
|
14392
14396
|
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({
|
|
14397
|
+
let HY = [...this.symbolUses(P).getValue(), ...this.symbolAliases(P).getValue()].filter((VY) => VY.filepath.equals(_));
|
|
14398
|
+
for (let _ of HY) {
|
|
14399
|
+
let VY = _.name;
|
|
14400
|
+
if (!VY) continue;
|
|
14401
|
+
if (VY !== P.name) return Report.create({
|
|
14404
14402
|
schema: "",
|
|
14405
|
-
name:
|
|
14403
|
+
name: VY
|
|
14406
14404
|
});
|
|
14407
|
-
let HY =
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
name:
|
|
14405
|
+
let HY = getSchemaChain(this, _);
|
|
14406
|
+
if (HY.length > 0) return Report.create({
|
|
14407
|
+
schema: HY.join("."),
|
|
14408
|
+
name: VY
|
|
14409
|
+
});
|
|
14410
|
+
let UY = fullnameToCanonical(this, P);
|
|
14411
|
+
return UY ? Report.create({
|
|
14412
|
+
...UY,
|
|
14413
|
+
name: VY
|
|
14411
14414
|
}) : Report.create({
|
|
14412
14415
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
14413
|
-
name:
|
|
14416
|
+
name: VY
|
|
14414
14417
|
});
|
|
14415
14418
|
}
|
|
14416
14419
|
return Report.create(fullnameToCanonical(this, P));
|
|
14417
14420
|
}
|
|
14421
|
+
function getSchemaChain(_, VY) {
|
|
14422
|
+
let P = [], HY = VY;
|
|
14423
|
+
for (; HY;) {
|
|
14424
|
+
let VY = _.symbolParent(HY).find((_) => _ instanceof SchemaSymbol && _.isKind(SymbolKind.Schema));
|
|
14425
|
+
if (!VY || VY.isPublicSchema()) break;
|
|
14426
|
+
P.unshift(VY.name ?? ""), HY = VY;
|
|
14427
|
+
}
|
|
14428
|
+
return P;
|
|
14429
|
+
}
|
|
14418
14430
|
function fullnameToCanonical(_, VY) {
|
|
14419
14431
|
if (!VY.declaration) return VY.name ? {
|
|
14420
14432
|
schema: DEFAULT_SCHEMA_NAME$1,
|
|
@@ -15609,11 +15621,30 @@ function resolutionIndex() {
|
|
|
15609
15621
|
};
|
|
15610
15622
|
P(VY);
|
|
15611
15623
|
}
|
|
15624
|
+
let GY = /* @__PURE__ */ new Map(), KY = /* @__PURE__ */ new Set();
|
|
15625
|
+
function qY(_, VY) {
|
|
15626
|
+
let P = VY.intern();
|
|
15627
|
+
if (KY.has(P)) return;
|
|
15628
|
+
KY.add(P);
|
|
15629
|
+
let HY = _.symbolMembers(VY).getFiltered(UNHANDLED);
|
|
15630
|
+
if (HY) for (let P of HY) {
|
|
15631
|
+
let HY = P.intern(), UY = GY.get(HY);
|
|
15632
|
+
UY || (UY = [], GY.set(HY, UY)), UY.push(VY), P instanceof SchemaSymbol && P.isKind(SymbolKind.Schema) && qY(_, P);
|
|
15633
|
+
}
|
|
15634
|
+
}
|
|
15635
|
+
for (let _ of P.values()) {
|
|
15636
|
+
let VY = _.getValue().ast, P = this.nodeSymbol(VY).getFiltered(UNHANDLED);
|
|
15637
|
+
P && qY(this, P);
|
|
15638
|
+
}
|
|
15612
15639
|
return {
|
|
15613
15640
|
references: _,
|
|
15614
|
-
metadata: VY
|
|
15641
|
+
metadata: VY,
|
|
15642
|
+
parents: GY
|
|
15615
15643
|
};
|
|
15616
15644
|
}
|
|
15645
|
+
function symbolParent(_) {
|
|
15646
|
+
return this.resolutionIndex().parents.get(_.intern()) ?? [];
|
|
15647
|
+
}
|
|
15617
15648
|
function symbolReferences(_) {
|
|
15618
15649
|
return this.resolutionIndex().references.get(_.intern()) ?? [];
|
|
15619
15650
|
}
|
|
@@ -15898,7 +15929,7 @@ function computeDeleteEdit(_, VY, P) {
|
|
|
15898
15929
|
}
|
|
15899
15930
|
var COMPUTING = Symbol("COMPUTING"), Compiler = class {
|
|
15900
15931
|
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 = {
|
|
15932
|
+
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
15933
|
invalidStream: this.localQuery(invalidStream),
|
|
15903
15934
|
flatStream: this.localQuery(flatStream)
|
|
15904
15935
|
}, this.parse = {
|
|
@@ -1825742,5 +1825773,5 @@ function findDiagramViewBlocks(_) {
|
|
|
1825742
1825773
|
let VY = new Compiler();
|
|
1825743
1825774
|
return VY.setSource(DEFAULT_ENTRY, _), VY.findDiagramViewBlocks(DEFAULT_ENTRY);
|
|
1825744
1825775
|
}
|
|
1825745
|
-
const VERSION = "8.0.0-alpha.
|
|
1825776
|
+
const VERSION = "8.0.0-alpha.6";
|
|
1825746
1825777
|
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.6",
|
|
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.6",
|
|
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": "52721b96504df2eeb4ff7fc13292896221a837ef",
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": ">=16"
|
|
63
63
|
}
|