@dbml/parse 8.0.0-alpha.12 → 8.0.0-alpha.14

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.
@@ -8612,7 +8612,7 @@ var TableBinder = class {
8612
8612
  let F = r.expression ? this.compiler.nodeReferee(r.expression).getFiltered(UNHANDLED) : void 0, I = this.compiler.parseFile(this.filepath).getValue().ast, L = this.compiler.nodeSymbol(I).getFiltered(UNHANDLED);
8613
8613
  if (F && !L.inNestedSchema(this.compiler, F)) {
8614
8614
  let M = this.compiler.nodeSymbol(this.declarationNode).getFiltered(UNHANDLED), I = M ? (this.compiler.symbolUses(M).getFiltered(UNHANDLED) ?? []).find((r) => r.filepath.equals(this.filepath)) : void 0;
8615
- N.push(new CompileError(CompileErrorCode.UNSUPPORTED, `Import TablePartial ${P.name} from '${F.filepath}' first. Currently, importing a table that uses a table partial requires that table partial to also be in scope.`, I?.useSpecifierDeclaration ?? r));
8615
+ N.push(new CompileError(CompileErrorCode.UNSUPPORTED, `TablePartial ${P.name} from '${F.filepath}' should be imported. Currently, importing a table that uses a table partial requires that table partial to also be in scope.`, I?.useSpecifierDeclaration ?? r));
8616
8616
  }
8617
8617
  return this.table.partials.push(P), N;
8618
8618
  }
@@ -13179,48 +13179,6 @@ var dbmlMonarchTokensProvider = {
13179
13179
  [/[/*]/, "comment"]
13180
13180
  ]
13181
13181
  }
13182
- }, MemoryProjectLayout = class r {
13183
- constructor(r = {}) {
13184
- this.files = r instanceof Map ? new Map(r) : new Map(Object.entries(r));
13185
- }
13186
- setSource(r, j) {
13187
- this.files.set(r.absolute, j);
13188
- }
13189
- getSource(r) {
13190
- return this.files.get(r.absolute) ?? void 0;
13191
- }
13192
- deleteSource(r) {
13193
- this.files.delete(r.absolute);
13194
- }
13195
- clearSource() {
13196
- this.files.clear();
13197
- }
13198
- exists(r) {
13199
- return this.isFile(r) || this.isDirectory(r);
13200
- }
13201
- isFile(r) {
13202
- return this.files.has(r.absolute);
13203
- }
13204
- isDirectory(r) {
13205
- let j = r.absolute.endsWith("/") ? r.absolute : `${r.absolute}/`;
13206
- for (let r of this.files.keys()) if (r.startsWith(j)) return !0;
13207
- return !1;
13208
- }
13209
- listDirectory(r) {
13210
- let j = r?.absolute ?? "/", M = j.endsWith("/") ? j : j + "/", N = /* @__PURE__ */ new Set();
13211
- for (let r of this.files.keys()) {
13212
- if (!r.startsWith(M)) continue;
13213
- let j = r.slice(M.length), P = j.indexOf("/");
13214
- N.add(M + (P === -1 ? j : j.slice(0, P)));
13215
- }
13216
- return [...N].sort().map(Filepath.from);
13217
- }
13218
- getEntrypoints() {
13219
- return [...this.files.keys()].map(Filepath.from).sort((r, j) => r.absolute.localeCompare(j.absolute));
13220
- }
13221
- clone() {
13222
- return new r(this.files);
13223
- }
13224
13182
  };
13225
13183
  function containerStack(r, j) {
13226
13184
  let M = this.token.flatStream(r), { index: N, token: P } = this.container.token(r, j), F = N === void 0 ? -1 : findLastIndex_default(M, (r) => !r.isInvalid, N);
@@ -13422,10 +13380,17 @@ function bindProject() {
13422
13380
  return j;
13423
13381
  }
13424
13382
  function interpretFile(r) {
13425
- let N = this.bindFile(r);
13426
- if (N.getErrors().length > 0) return N.map(() => void 0);
13427
- let P = this.parseFile(r).getValue().ast, F = this.nodeSymbol(P).getFiltered(UNHANDLED);
13428
- return F ? this.interpretSymbol(F, r).map((r) => r === UNHANDLED || !r ? void 0 : r) : Report.create(void 0);
13383
+ let N = [], P = [];
13384
+ for (let j of this.reachableFiles(r)) {
13385
+ let r = this.parseFile(j);
13386
+ N.push(...r.getErrors()), P.push(...r.getWarnings());
13387
+ }
13388
+ let F = this.bindFile(r);
13389
+ if (N.push(...F.getErrors()), P.push(...F.getWarnings()), N.length > 0) return new Report(void 0, N, P);
13390
+ let { ast: I } = this.parseFile(r).getValue(), L = this.nodeSymbol(I).getFiltered(UNHANDLED);
13391
+ if (!L) return new Report(void 0, N, P);
13392
+ let R = this.interpretSymbol(L, r).map((r) => r === UNHANDLED || !r ? void 0 : r);
13393
+ return N.push(...R.getErrors()), P.push(...R.getWarnings()), new Report(R.getValue(), N, P);
13429
13394
  }
13430
13395
  function interpretProject() {
13431
13396
  let r = [], N = [], P = /* @__PURE__ */ new Set(), F = [];
@@ -13439,7 +13404,7 @@ function interpretProject() {
13439
13404
  r.push(...F.getErrors()), N.push(...F.getWarnings());
13440
13405
  let L = this.bindFile(P);
13441
13406
  r.push(...L.getErrors()), N.push(...L.getWarnings());
13442
- let R = F.getValue().ast, z = this.nodeSymbol(R).getFiltered(UNHANDLED), B = z ? this.interpretSymbol(z, P) : Report.create(UNHANDLED), V = B.getFiltered(UNHANDLED);
13407
+ let { ast: R } = F.getValue(), z = this.nodeSymbol(R).getFiltered(UNHANDLED), B = z ? this.interpretSymbol(z, P) : Report.create(UNHANDLED), V = B.getFiltered(UNHANDLED);
13443
13408
  V && I.set(P.absolute, V), r.push(...B.getErrors()), N.push(...B.getWarnings());
13444
13409
  }
13445
13410
  let L = {};
@@ -14855,8 +14820,8 @@ function computeDeleteEdit(r, j, M) {
14855
14820
  }];
14856
14821
  }
14857
14822
  var COMPUTING = Symbol("COMPUTING"), Compiler = class {
14858
- constructor(r = new MemoryProjectLayout()) {
14859
- this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), 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.bind(this), this.syncDiagramView = syncDiagramView.bind(this), this.token = {
14823
+ constructor(r) {
14824
+ this.layout = r, this.nodeIdGenerator = new SyntaxNodeIdGenerator(), this.symbolIdGenerator = new NodeSymbolIdGenerator(), this.symbolFactory = new SymbolFactory(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), 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.bind(this), this.syncDiagramView = syncDiagramView.bind(this), this.token = {
14860
14825
  invalidStream: this.localQuery(invalidStream),
14861
14826
  flatStream: this.localQuery(flatStream)
14862
14827
  }, this.parse = {
@@ -14873,7 +14838,7 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
14873
14838
  element: this.localQuery(containerElement),
14874
14839
  scope: this.localQuery(containerScope),
14875
14840
  scopeKind: this.localQuery(containerScopeKind)
14876
- }, this.layout = r;
14841
+ };
14877
14842
  }
14878
14843
  getSource(r) {
14879
14844
  return this.layout.getSource(r);
@@ -14955,5 +14920,47 @@ var COMPUTING = Symbol("COMPUTING"), Compiler = class {
14955
14920
  diagnosticsProvider: new DBMLDiagnosticsProvider(this)
14956
14921
  };
14957
14922
  }
14923
+ }, MemoryProjectLayout = class r {
14924
+ constructor(r = {}) {
14925
+ this.files = r instanceof Map ? new Map(r) : new Map(Object.entries(r));
14926
+ }
14927
+ setSource(r, j) {
14928
+ this.files.set(r.absolute, j);
14929
+ }
14930
+ getSource(r) {
14931
+ return this.files.get(r.absolute) ?? void 0;
14932
+ }
14933
+ deleteSource(r) {
14934
+ this.files.delete(r.absolute);
14935
+ }
14936
+ clearSource() {
14937
+ this.files.clear();
14938
+ }
14939
+ exists(r) {
14940
+ return this.isFile(r) || this.isDirectory(r);
14941
+ }
14942
+ isFile(r) {
14943
+ return this.files.has(r.absolute);
14944
+ }
14945
+ isDirectory(r) {
14946
+ let j = r.absolute.endsWith("/") ? r.absolute : `${r.absolute}/`;
14947
+ for (let r of this.files.keys()) if (r.startsWith(j)) return !0;
14948
+ return !1;
14949
+ }
14950
+ listDirectory(r) {
14951
+ let j = r?.absolute ?? "/", M = j.endsWith("/") ? j : j + "/", N = /* @__PURE__ */ new Set();
14952
+ for (let r of this.files.keys()) {
14953
+ if (!r.startsWith(M)) continue;
14954
+ let j = r.slice(M.length), P = j.indexOf("/");
14955
+ N.add(M + (P === -1 ? j : j.slice(0, P)));
14956
+ }
14957
+ return [...N].sort().map(Filepath.from);
14958
+ }
14959
+ getEntrypoints() {
14960
+ return [...this.files.keys()].map(Filepath.from).sort((r, j) => r.absolute.localeCompare(j.absolute));
14961
+ }
14962
+ clone() {
14963
+ return new r(this.files);
14964
+ }
14958
14965
  };
14959
14966
  export { ArrayNode, AttributeNode, BlockExpressionNode, CallExpressionNode, CommaExpressionNode, CompileError, CompileErrorCode, Compiler, CompletionItemInsertTextRule, CompletionItemKind, DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLDiagnosticsProvider, DBMLReferencesProvider, DEFAULT_ENTRY, ElementDeclarationNode, ElementKind, EmptyNode, FALSY_VALUES, Filepath, FunctionApplicationNode, FunctionExpressionNode, GroupExpressionNode, IdentifierStreamNode, InfixExpressionNode, ListExpressionNode, LiteralNode, MarkerSeverity, MemoryProjectLayout, PostfixExpressionNode, PrefixExpressionNode, PrimaryExpressionNode, ProgramNode, ScopeKind, SymbolKind, SyntaxNode, SyntaxNodeIdGenerator, SyntaxNodeKind, SyntaxToken, SyntaxTokenKind, TRUTHY_VALUES, TupleExpressionNode, UNHANDLED, URI as Uri, UseDeclarationNode, UseSpecifierListNode, UseSpecifierNode, VariableNode, WildcardNode, addDoubleQuoteIfNeeded, dbmlLanguageConfig, dbmlMonarchTokensProvider, escapeString, extractNumericLiteral, extractSignedNumber, formatRecordValue, getRecordValueType, isBinaryType, isBooleanType, isDateTimeType, isEmptyStringLiteral, isFloatType, isFunctionExpression, isIntegerType, isNullish, isNumericType, isOp, isOpToken, isSerialType, isStringType, isTriviaToken, isValidIdentifier, normalizeTypeName, splitQualifiedIdentifier, tryExtractBoolean, tryExtractDateTime, tryExtractEnum, tryExtractInteger, tryExtractNumeric, tryExtractString, unescapeString, validateForeignKeys, validatePrimaryKey, validateUnique };
@@ -9,11 +9,11 @@ export { ScopeKind } from './types';
9
9
  export type { DiagramViewBlock, TableNameInput, TextEdit } from './queries/transform';
10
10
  export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString, findDiagramViewBlocks, };
11
11
  export default class Compiler {
12
+ layout: DbmlProjectLayout;
12
13
  readonly nodeIdGenerator: SyntaxNodeIdGenerator;
13
14
  readonly symbolIdGenerator: NodeSymbolIdGenerator;
14
15
  readonly symbolFactory: SymbolFactory;
15
- layout: DbmlProjectLayout;
16
- constructor(layout?: DbmlProjectLayout);
16
+ constructor(layout: DbmlProjectLayout);
17
17
  getSource(filepath: Filepath): string | undefined;
18
18
  private sourceSnapshot;
19
19
  private cleanStaleLocalCache;
@@ -8,7 +8,7 @@ export interface DbmlProjectLayout {
8
8
  getEntrypoints(): Filepath[];
9
9
  }
10
10
  export declare class MemoryProjectLayout implements DbmlProjectLayout {
11
- private files;
11
+ private readonly files;
12
12
  constructor(files?: Map<string, string> | Record<string, string>);
13
13
  setSource(filePath: Filepath, content: string): void;
14
14
  getSource(filePath: Filepath): string | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@dbml/parse",
4
- "version": "8.0.0-alpha.12",
4
+ "version": "8.0.0-alpha.14",
5
5
  "description": "DBML parser v2",
6
6
  "author": "Holistics <dev@holistics.io>",
7
7
  "license": "Apache-2.0",
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=18"
48
48
  },
49
- "gitHead": "53557d9ec226c4e7b8177229efce49594535502b"
49
+ "gitHead": "4f1c1fe17ac6e0e28038b0c5e28db69a9fae365e"
50
50
  }