@dbml/parse 9.0.0-alpha.7 → 9.0.0-alpha.8
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/dbml-parse.js +6 -6
- package/dist/dbml-parse.mjs +209 -209
- package/dist/src/compiler/index.d.ts +6 -8
- package/dist/src/compiler/queries/transform/index.d.ts +2 -1
- package/dist/src/compiler/queries/transform/renameTable.d.ts +2 -2
- package/dist/src/compiler/queries/transform/types.d.ts +48 -0
- package/dist/src/compiler/queries/transform/updateElementSetting.d.ts +4 -0
- package/dist/src/compiler/queries/transform/utils.d.ts +6 -10
- package/dist/src/core/utils/setting.d.ts +6 -2
- package/dist/src/index.d.ts +3 -0
- package/package.json +2 -2
package/dist/dbml-parse.js
CHANGED
|
@@ -18,15 +18,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Symbol(
|
|
|
18
18
|
`,{allowNewline:!0,allowEof:!0,raw:!0,consumeStopSequence:!1})}multilineComment(){this.consumeUntil(_.MULTILINE_COMMENT,`*/`,{allowNewline:!0,allowEof:!1,raw:!0})}identifier(){for(;!this.isAtEnd()&&jo(this.peek());)this.advance();this.addToken(_.IDENTIFIER)}operator(e){switch(e){case`<`:[`>`,`=`,`-`].includes(this.peek())&&this.advance();break;case`>`:this.peek()===`=`&&this.advance();break;case`-`:this.peek()===`>`&&this.advance();break;case`=`:this.peek()===`=`&&this.advance();break;case`!`:this.peek()===`=`&&this.advance();break;default:break}this.addToken(_.OP)}numericLiteralOrIdentifier(){let e=0;if(this.isAtEnd())return this.addToken(_.NUMERIC_LITERAL);for(;!this.isAtEnd();){let t=this.check(`.`);if(e+=+!!t,e>1)break;if(this.check(`e`)||this.check(`E`)){let e=this.peek(1),t=e===`+`||e===`-`,n=t?this.peek(2):e;if(n&&ko(n)){for(this.advance(),t&&this.advance();!this.isAtEnd()&&ko(this.peek());)this.advance();if(this.isAtEnd()||!jo(this.peek()))return this.addToken(_.NUMERIC_LITERAL);break}break}if(!t&&this.current.offset===this.text.length-1)return this.advance(),this.addToken(_.NUMERIC_LITERAL);if(!t&&!jo(this.peek()))return this.addToken(_.NUMERIC_LITERAL);if(!t&&!ko(this.peek()))break;this.advance()}if(e>0){for(;!this.isAtEnd()&&(this.check(`.`)||jo(this.peek()));)this.advance();let e=this.createToken(_.NUMERIC_LITERAL,!0);this.tokens.push(e),this.errors.push(new b(y.UNKNOWN_TOKEN,`Invalid number`,e))}else{for(;!this.isAtEnd()&&jo(this.peek());)this.advance();let e=this.createToken(_.IDENTIFIER,!1);this.tokens.push(e)}}colorLiteral(){for(;!this.isAtEnd()&&jo(this.peek());)this.advance();this.addToken(_.COLOR_LITERAL)}escapedString(){let e={column:this.current.column-1,offset:this.current.offset-1,line:this.current.line};if(this.isAtEnd())return`\\`;switch(this.advance()){case`\r`:return this.check(`
|
|
19
19
|
`)&&this.advance(),``;case`
|
|
20
20
|
`:return``;case`t`:return` `;case`n`:return`
|
|
21
|
-
`;case`\\`:return`\\`;case`r`:return`\r`;case`'`:return`'`;case`"`:return`"`;case"`":return"`";case`0`:return`\0`;case`b`:return`\b`;case`v`:return`\v`;case`f`:return`\f`;case` `:return`\\ `;case`u`:{let t=``;for(let n=0;n<=3;n+=1){if(this.isAtEnd()||!jo(this.peek()))return this.errors.push(new b(y.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${t}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ha.create(_.STRING_LITERAL,this.filepath,e,this.current,`\\u${t}`,!0))),`\\u${t}`;t+=this.advance()}return String.fromCharCode(parseInt(t,16))}default:return this.text[this.current.offset-1]}}},jb=function(e){return e[e.ListExpression=0]=`ListExpression`,e[e.GroupExpression=1]=`GroupExpression`,e[e.BlockExpression=2]=`BlockExpression`,e}({}),Mb=class{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===0&&(this.numberOfNestedLBrackets+=1),e===1&&(this.numberOfNestedLParens+=1),e===2&&(this.numberOfNestedLBraces+=1)}pop(){let e=this.stack.pop();return e===0&&--this.numberOfNestedLBrackets,e===1&&--this.numberOfNestedLParens,e===2&&--this.numberOfNestedLBraces,e}top(){return h(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,t){return()=>{this.push(e);try{return t()}finally{this.pop()}}}findHandlerContext(e,t){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let n=t;n<e.length-1;n+=1)switch(e[n].kind){case _.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(e=>[1,0].includes(e));break;case _.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case _.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case _.RBRACKET:if(this.isWithinListExpressionContext())return 0;break;default:break}}},Nb=class{constructor(e,t){this.generator=e,this.filepath=t}create(e,t){return new e(t,this.generator.nextId(),this.filepath)}},$=class{constructor(e,t,n){this.token=e,this.partialNode=t,this.handlerContext=n}},Pb=class{constructor(e,t,n,r){this.current=0,this.errors=[],this.contextStack=new Mb,this.useSpecifierList=this.contextStack.withContextDo(jb.BlockExpression,()=>{let e={specifiers:[]},t=()=>this.nodeFactory.create(Xs,e);try{this.consume(`Expect an opening brace '{'`,_.LBRACE),e.openBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeUseSpecifierList()}for(;!this.isAtEnd()&&!this.check(_.RBRACE);){try{e.specifiers.push(this.useSpecifier())}catch(n){if(!(n instanceof $))throw n;if(n.partialNode instanceof Ys&&e.specifiers.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeUseSpecifierList()}if(this.check(_.IDENTIFIER)&&Za(this.peek()))break;!Ua(this.previous())&&!this.check(_.RBRACE)&&this.logError(this.peek(),y.MISSING_SPACES,`Expect a newline between use specifiers`)}try{this.consume(`Expect a closing brace '}'`,_.RBRACE),e.closeBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeUseSpecifierList()}return t()}),this.synchronizeUseSpecifierList=()=>{if(!this.check(_.RBRACE))for(H(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(_.RBRACE)||this.check(_.STRING_LITERAL)||this.check(_.IDENTIFIER)&&Za(e)||Wa(this.previous(),e))break;H(e),this.advance()}},this.synchronizeProgram=()=>{let e=this.peek();e.kind===_.EOF?this.logError(e,y.UNEXPECTED_EOF,`Unexpected EOF`):H(this.advance())},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(Ya(e)||this.check(_.COLON,_.LBRACE,_.LBRACKET))break;H(e),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COLON,_.LBRACE,_.LBRACKET))break;H(e),this.advance()}},this.blockExpression=this.contextStack.withContextDo(jb.BlockExpression,()=>{let e={body:[]},t=()=>this.nodeFactory.create(z,e);try{this.consume(`Expect an opening brace '{'`,_.LBRACE),e.blockOpenBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(_.RBRACE);)try{e.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(n){if(!(n instanceof $))throw n;if(e.body.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeBlock()}try{this.consume(`Expect a closing brace '}'`,_.RBRACE),e.blockCloseBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeBlock()}return t()}),this.synchronizeBlock=()=>{if(!this.check(_.RBRACE))for(H(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(_.RBRACE)||Wa(this.previous(),e))break;H(e),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(jb.GroupExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(nc,{groupOpenParen:e.tupleOpenParen,groupCloseParen:e.tupleCloseParen,expression:e.elementList[0]}),n=()=>this.nodeFactory.create(ec,e);try{this.consume(`Expect an opening parenthesis '('`,_.LPAREN),e.tupleOpenParen=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,n(),e.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(_.RPAREN))try{e.elementList.push(this.normalExpression())}catch(n){if(!(n instanceof $))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(_.RPAREN);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.normalExpression())}catch(t){if(!(t instanceof $))throw t;if(t.partialNode instanceof M&&e.elementList.push(t.partialNode),!this.canHandle(t))throw new $(t.token,n(),t.handlerContext);this.synchronizeTuple()}try{this.consume(`Expect a closing parenthesis ')'`,_.RPAREN),e.tupleCloseParen=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,n(),e.handlerContext);this.synchronizeTuple()}return e.elementList.length===1?t():n()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.RPAREN,_.COMMA))break;H(e),this.advance()}},this.listExpression=this.contextStack.withContextDo(jb.ListExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(B,e);try{this.consume(`Expect an opening bracket '['`,_.LBRACKET),e.listOpenBracket=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(_.RBRACKET))try{e.elementList.push(this.attribute())}catch(n){if(!(n instanceof $))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(_.RBRACKET);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.attribute())}catch(n){if(!(n instanceof $))throw n;if(n.partialNode instanceof M&&e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeList()}try{this.consume(`Expect a closing bracket ']'`,_.RBRACKET),e.listCloseBracket=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeList()}return t()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;H(e),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET,_.COLON))break;H(e),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;H(e),this.advance()}},this.source=e,this.tokens=t,this.nodeFactory=new Nb(n,r),this.filepath=r}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===_.EOF}advance(){return this.isAtEnd()?h(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?h(this.tokens):this.tokens[this.current+e]}match(...e){let t=this.check(...e);return t&&this.advance(),t}check(...e){let t=this.peek();return e.includes(t.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...t){if(!this.match(...t))throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,e),new $(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...t){if(this.isAtEnd()||!this.check(...t)){for(H(this.peek()),this.logError(this.advance(),y.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...t);)H(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){let e=[],t=[],n,r=0;for(;r<this.tokens.length&&this.tokens[r].isInvalid;r+=1)t.push(this.tokens[r]);for(n=this.tokens[r],n.leadingInvalid=[...t,...n.leadingInvalid],e.push(n),r+=1;r<this.tokens.length;r+=1){let t=this.tokens[r];t.isInvalid?n.trailingInvalid.push(t):(n=t,e.push(n))}this.tokens=e}parse(){let e=this.program(),t=this.advance(),r=this.nodeFactory.create(N,{body:e,eof:t,source:this.source});return this.gatherInvalid(),this.assignParents(r),new n({ast:r,tokens:this.tokens},this.errors)}assignParents(e){jc(e).forEach(t=>{t instanceof M&&(t.parentNode=e,this.assignParents(t))})}program(){let e=[];for(;!this.isAtEnd();)if(Xa(this.peek())||Qa(this.peek()))try{e.push(this.useDeclaration())}catch(t){if(!(t instanceof $))throw t;t.partialNode instanceof Js&&e.push(t.partialNode),this.synchronizeProgram()}else try{e.push(this.elementDeclaration())}catch(t){if(!(t instanceof $))throw t;e.push(t.partialNode),this.synchronizeProgram()}return e}useDeclaration(){let e={},t=()=>this.nodeFactory.create(Js,e);if(this.advance(),e.useKeyword=this.previous(),this.peek().kind===_.WILDCARD)this.advance(),e.specifiers=this.nodeFactory.create(ic,{token:this.previous()});else try{e.specifiers=this.useSpecifierList()}catch(t){if(!(t instanceof $))throw t;t.partialNode instanceof Xs&&(e.specifiers=t.partialNode)}let n=e.specifiers instanceof ic?`'*'`:`specifier list`;return Za(this.peek())?e.fromKeyword=this.advance():this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect 'from' after ${n}`),this.match(_.STRING_LITERAL)?e.importPath=this.previous():this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect a string literal path`),t()}useSpecifier(){let e={},t=()=>this.nodeFactory.create(Ys,e);try{this.consume(`Expect an import kind specifier (e.g. table, enum)`,_.IDENTIFIER),e.importKind=this.previous()}catch(e){throw e instanceof $?new $(e.token,t(),e.handlerContext):e}if(this.check(_.IDENTIFIER,_.QUOTED_STRING))try{e.name=this.normalExpression()}catch(n){throw n instanceof $?(n.partialNode instanceof M&&(e.name=n.partialNode),new $(n.token,t(),n.handlerContext)):n}else e.importKind&&this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an element name`);if(Ya(this.peek())){e.asKeyword=this.advance();try{if(!this.check(_.IDENTIFIER,_.QUOTED_STRING))throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an alias name after 'as'`),new $(this.peek(),t(),this.contextStack.findHandlerContext(this.tokens,this.current));e.alias=this.normalExpression()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext)}}return t()}elementDeclaration(){let e={},t=()=>this.nodeFactory.create(P,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(e){throw e instanceof $?new $(e.token,t(),e.handlerContext):e}if(!this.check(_.COLON,_.LBRACE,_.LBRACKET))try{e.name=this.normalExpression()}catch(n){if(!(n instanceof $))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationName()}if(Ya(this.peek()))if(e.as=this.advance(),this.check(_.COLON,_.LBRACE,_.LBRACKET))this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an alias`);else try{e.alias=this.normalExpression()}catch(n){if(!(n instanceof $))throw n;if(e.alias=n.partialNode,!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(_.LBRACKET)?this.listExpression():void 0}catch(n){throw n instanceof $?(e.attributeList=n.partialNode,new $(n.token,t(),n.handlerContext)):n}if(!this.discardUntil(`Expect an opening brace '{' or a colon ':'`,_.LBRACE,_.COLON))return t();try{if(this.match(_.COLON)){e.bodyColon=this.previous();let t=this.expression();t instanceof P?(H(t),this.logError(t,y.UNEXPECTED_ELEMENT_DECLARATION,`An element's simple body must not be an element declaration`)):e.body=t}else e.body=this.blockExpression()}catch(n){throw n instanceof $?(e.body=n.partialNode,new $(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(P,e)}fieldDeclaration(){let e={},t=()=>this.nodeFactory.create(P,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(n){throw n instanceof $?(e.type=n.partialNode,new $(n.token,t(),n.handlerContext)):n}try{this.consume(`Expect a colon ':'`,_.COLON),e.bodyColon=this.previous()}catch(n){throw n instanceof $?(e.bodyColon=n.partialNode,new $(n.token,t(),n.handlerContext)):n}try{let t=this.expression();t instanceof P?this.errors.push(new b(y.INVALID_ELEMENT_IN_SIMPLE_BODY,`Simple body cannot be an element declaration`,t)):e.body=t}catch(n){throw n instanceof $?(e.body=n.partialNode,new $(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(P,e)}expression(){let e={args:[]},t=()=>Dc(e.callee,e.args,this.nodeFactory)??this.nodeFactory.create(R,e);try{e.callee=this.commaExpression()}catch(n){throw n instanceof $?(e.callee=n.partialNode,new $(n.token,t(),n.handlerContext)):n}if(this.shouldStopFunctionApplication())return t();let n=e.callee;for(;!this.shouldStopFunctionApplication();){Ga(this.previous())||this.logError(n,y.MISSING_SPACES,`Expect a following space`);try{n=this.commaExpression(),e.args.push(n)}catch(r){throw r instanceof $?(n=r.partialNode,e.args.push(n),new $(r.token,t(),r.handlerContext)):r}}return t()}shouldStopFunctionApplication(){if(this.isAtEnd()||Ua(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.RBRACKET,_.RPAREN,_.COMMA,_.COLON].includes(e)}commaExpression(){let e=this.check(_.COMMA)?this.nodeFactory.create(sc,{prevToken:this.previous()}):this.normalExpression();if(!this.check(_.COMMA))return e;let t={elementList:[e],commaList:[]};do{if(t.commaList.push(this.advance()),this.shouldStopCommaExpression()){t.elementList.push(this.nodeFactory.create(sc,{prevToken:this.previous()}));break}if(this.check(_.COMMA)){t.elementList.push(this.nodeFactory.create(sc,{prevToken:this.previous()}));continue}try{let e=this.normalExpression();t.elementList.push(e)}catch(e){throw e instanceof $?(e.partialNode&&t.elementList.push(e.partialNode),new $(e.token,this.nodeFactory.create(tc,t),e.handlerContext)):e}}while(!this.shouldStopCommaExpression()&&this.check(_.COMMA));return this.nodeFactory.create(tc,t)}shouldStopCommaExpression(){if(this.isAtEnd()||Ua(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.LBRACE,_.RBRACKET,_.LBRACKET,_.RPAREN,_.LPAREN,_.COLON].includes(e)}normalExpression(){return this.expression_bp(0)}expression_bp(e){let t=this.leftExpression_bp();for(;!this.isAtEnd();){let n=this.peek();if(n.kind===_.LPAREN){let{left:r}=Bb(n);if(r<e||Wa(this.previous(),n)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{t=this.nodeFactory.create(V,{callee:t,argumentList:this.tupleExpression()})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(V,{callee:t,argumentList:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}else if(n.kind===_.LBRACKET){if(Ga(this.previous()))break;try{t=this.nodeFactory.create(cc,{expression:t,indexer:this.listExpression()})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(cc,{expression:t,indexer:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}else if(Va(n)){let r=n,i=Bb(r);if(i.left!==null){if(i.left<=e)break;this.advance(),t=this.nodeFactory.create(Qs,{expression:t,op:r})}else{let n=Ib(r);if(n.left===null||n.left<=e)break;this.advance();try{t=this.nodeFactory.create(L,{leftExpression:t,op:r,rightExpression:r.value===`.`?this.extractOperand():this.expression_bp(n.right)})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(L,{leftExpression:t,op:r,rightExpression:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}}else break}return t}leftExpression_bp(){let e;if(Va(this.peek())){let t={};t.op=this.peek();let n=Rb(t.op);if(n.right===null)throw this.logError(t.op,y.UNKNOWN_PREFIX_OP,`Unexpected '${t.op.value}' in an expression`),new $(t.op,this.nodeFactory.create(sc,{prevToken:t.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{t.expression=this.expression_bp(n.right)}catch(e){throw e instanceof $?(t.expression=e.partialNode,new $(e.token,this.nodeFactory.create(I,t),e.handlerContext)):e}e=this.nodeFactory.create(I,t)}else if(e=this.extractOperand(),e instanceof sc)throw new $(this.peek(),this.nodeFactory.create(sc,{prevToken:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(_.WILDCARD)?this.wildcardExpression():this.check(_.NUMERIC_LITERAL,_.STRING_LITERAL,_.COLOR_LITERAL,_.QUOTED_STRING,_.IDENTIFIER)?this.primaryExpression():this.check(_.FUNCTION_EXPRESSION)?this.functionExpression():this.check(_.LBRACKET)?this.listExpression():this.check(_.LBRACE)?this.blockExpression():this.check(_.LPAREN)?this.tupleExpression():(this.peek().kind===_.EOF?this.logError(this.peek(),y.UNEXPECTED_EOF,`Unexpected EOF`):this.logError(this.peek(),y.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(sc,{prevToken:this.previous()}))}functionExpression(){let e={};try{this.consume(`Expect a function expression`,_.FUNCTION_EXPRESSION),e.value=this.previous()}catch(t){throw t instanceof $?new $(t.token,this.nodeFactory.create($s,e),t.handlerContext):t}return this.nodeFactory.create($s,e)}wildcardExpression(){return this.advance(),this.nodeFactory.create(ic,{token:this.previous()})}canBeField(){return this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.COLON}primaryExpression(){if(this.match(_.COLOR_LITERAL,_.STRING_LITERAL,_.NUMERIC_LITERAL))return this.nodeFactory.create(oc,{expression:this.nodeFactory.create(rc,{literal:this.previous()})});if(this.match(_.QUOTED_STRING,_.IDENTIFIER))return this.nodeFactory.create(oc,{expression:this.nodeFactory.create(ac,{variable:this.previous()})});throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect a variable or literal`),new $(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){let e={};if(this.check(_.COLON,_.RBRACKET,_.COMMA)){let t=this.peek();this.logError(t,y.EMPTY_ATTRIBUTE_NAME,`Expect a non-empty attribute name`),e.name=this.nodeFactory.create(Zs,{identifiers:[]})}else try{e.name=this.attributeName()}catch(t){if(!(t instanceof $))throw t;if(e.name=t.partialNode,!this.canHandle(t))throw new $(t.token,this.nodeFactory.create(F,e),t.handlerContext);this.synchronizeAttributeName()}return this.match(_.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(F,e)}attributeValue(){let e;try{e=this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.IDENTIFIER?this.attributeName():this.normalExpression()}catch(t){if(!(t instanceof $)||!this.canHandle(t))throw t;e=t.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){let e=[];if(this.peek().kind!==_.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(_.COLON,_.COMMA,_.RBRACKET);)try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.push(this.previous())}catch(t){throw t instanceof $?new $(t.token,this.nodeFactory.create(Zs,{identifiers:e}),t.handlerContext):t}return this.nodeFactory.create(Zs,{identifiers:e})}logError(e,t,n){this.errors.push(new b(t,n,e))}},Fb={"+":{left:9,right:10},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"->":{left:7,right:8},"<-":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function Ib(e){return Fb[e.value]||{left:null,right:null}}var Lb={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"->":{left:null,right:15},"<-":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function Rb(e){return Lb[e.value]||{left:null,right:null}}var zb={"(":{left:14,right:null}};function Bb(e){return zb[e.value]||{left:null,right:null}}function Vb(e){let t=this.getSource(e);return new Ab(t??``,e).lex().chain(n=>new Pb(t??``,n,this.nodeIdGenerator,e).parse()).map(({ast:t,tokens:n})=>({ast:t,tokens:n,path:e}))}function Hb(){let e=xg(this,this.layout.getEntrypoints()),t=new Map;for(let n of e){let e=this.parseFile(n);t.set(n.absolute,e)}return t}function Ub(e){let n=this.symbolMembers(e).getFiltered(t),r=new Map;if(n)for(let e of n){let t=e instanceof Ws?Jh.visibleName(this,e)?.at(-1):e.name;if(t===void 0)continue;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}return r}function Wb(e,n,r){let i;if(e instanceof Ts)i=e;else{let n=this.nodeSymbol(e).getFiltered(t);if(!(n instanceof Ts))return;i=n}let a=Array.isArray(n)?n:[n],o=this.symbolMembersLookupMap(i).get(r);if(o)return o.find(e=>!(a.length===1&&e.kind!==a[0]||a.length>1&&!a.includes(e.kind)))}function Gb(e){let t=e.originalSymbol;return Sg(this).map(n=>n.filter(n=>n instanceof Us&&n.originalSymbol===t&&n!==e))}function Kb(){let e=new Map,n=new Map,r=this.parseProject();this.bindProject();let i=new Set,a=(t,n)=>{if(i.has(n))return;i.add(n);let r=t.intern(),a=e.get(r);a||(a=[],e.set(r,a)),a.push(n);let o=t.originalSymbol;if(o!==t){let t=o.intern(),r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}},o=e=>{for(let t of e.owners(this)){let r=t.intern(),i=n.get(r);i||(i=[],n.set(r,i)),i.push(e)}};for(let e of r.values()){let n=e.getValue().ast,r=e=>{if(C(e)){let n=this.nodeReferee(e).getFiltered(t);n&&a(n,e);return}if(e instanceof ec&&w(e.parentNode)&&e.parentNode.rightExpression===e){let n=e.parentNode.leftExpression;if(n){let e=rs(n);if(e){let n=this.nodeReferee(e).getFiltered(t);n&&a(n,e)}}}let n=this.nodeMetadata(e).getFiltered(t);n&&o(n);for(let t of jc(e))t instanceof M&&r(t)};r(n)}let s=new Map,c=new Set;function l(e,n){let r=n.intern();if(c.has(r))return;c.add(r);let i=e.symbolMembers(n).getFiltered(t);if(i)for(let t of i){let r=t.intern(),i=s.get(r);i||(i=[],s.set(r,i)),i.push(n),t instanceof Es&&t.isKind(j.Schema)&&l(e,t)}}for(let e of r.values()){let n=e.getValue().ast,r=this.nodeSymbol(n).getFiltered(t);r&&l(this,r)}return{references:e,metadata:n,parents:s}}function qb(e){return this.resolutionIndex().parents.get(e.intern())??[]}function Jb(e){return this.resolutionIndex().references.get(e.intern())??[]}function Yb(e){return this.resolutionIndex().metadata.get(e.intern())??[]}function Xb(e){let t=e.originalSymbol;return Sg(this).map(n=>n.filter(n=>n instanceof Ws&&n.originalSymbol===t&&n!==e))}function Zb(e,t,n=!1){let r=n?t:[...t].sort((e,t)=>t.start-e.start),i=e;for(let{start:e,end:t,newText:n}of r)i=i.substring(0,e)+n+i.substring(t);return i}function Qb(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=bg(e);if(t.length===0)return{schema:v,table:``};if(t.length===1)return{schema:v,table:t[0]};if(t.length===2)return{schema:t[0],table:t[1]};let n=t[t.length-1];return{schema:t.slice(0,-1).join(`.`),table:n}}function $b(e,n,r,i){let a=e.parseFile(n).getValue().ast,o=e.nodeSymbol(a).getFiltered(t);if(!o)return null;if(r===`public`)return e.lookupMembers(o,j.Table,i)??null;let s=e.lookupMembers(o,j.Schema,r);return s?e.lookupMembers(s,j.Table,i)??null:null}function ex(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function tx(e,t){if(!e||!(e instanceof P))return!1;let n=e.name;return n?t.substring(n.start,n.end).includes(`"`):!1}function nx(e,t,n){let r=!hg(t),i=!hg(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function rx(e,t,n,r,i,a){return n===i&&r===a?!1:$b(e,t,i,a)!==null}function ix(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return ex(n.substring(i,a))===t?{start:i,end:e.end}:null}function ax(e){return e.schema===`public`?e.formattedTable:`${e.formattedSchema}.${e.formattedTable}`}function ox(e,t,n,r,i){let a=[],o=new Set,s=ax(r);for(let r of e){if(ex(i.substring(r.start,r.end))!==n)continue;let e=ix(r,t,i)??{start:r.start,end:r.end},c=`${e.start}-${e.end}`;o.has(c)||(o.add(c),a.push({start:e.start,end:e.end,newText:s}))}return a}function sx(e,n,r){let i=Qb(n),a=Qb(r),o=i.schema,s=i.table,c=a.schema,l=a.table,u=$b(this,e,o,s);if(!u||u instanceof Us||rx(this,e,o,s,c,l))return new Map;if(u instanceof Ws&&u.useSpecifierDeclaration instanceof Ys&&u.useSpecifierDeclaration.alias){let n=u.useSpecifierDeclaration;if(this.nodeAlias(n).getFiltered(t)===s)return cx(this,e,n,u,c,l)}return lx(this,u,o,s,c,l)}function cx(e,t,n,r,i,a){let o=e.getSource(t)??``;if(!n.alias)return new Map;let s=nx(i,a,o.substring(n.alias.start,n.alias.end).includes(`"`)),c=[];c.push({start:n.alias.start,end:n.alias.end,newText:s.formattedTable});let l=e.symbolReferences(r);for(let e of l)e.filepath.absolute===t.absolute&&e!==n.alias&&c.push({start:e.start,end:e.end,newText:s.formattedTable});return new Map([[t.absolute,Zb(o,c)]])}function lx(e,t,n,r,i,a){let o=t.originalSymbol,s=o.declaration;if(!s||!(s instanceof P))return new Map;let c=s.filepath;if(!c)return new Map;let l=nx(i,a,tx(s,e.getSource(c)??``)),u=new Map,d=(e,t)=>{let n=e.absolute,r=u.get(n);r||(r={fp:e,edits:[]},u.set(n,r)),r.edits.push(t)},f=s.name;f&&d(c,{start:f.start,end:f.end,newText:ax(l)});let p=e.symbolReferences(o);for(let t of p){if(t===f)continue;let i=t.filepath,a=e.getSource(i)??``;for(let e of ox([t],n,r,l,a))d(i,e)}let m=new Map;for(let{fp:t,edits:n}of u.values()){let r=e.getSource(t)??``;m.set(t.absolute,Zb(r,n))}return m}function ux(e){let t=[],n=new Ab(e,Eo).lex();if(n.getErrors().length>0)return t;let i=new Pb(e,n.getValue(),new Ks,Eo).parse();if(i.getErrors().length>0)return t;let a=i.getValue().ast;for(let e of a.declarations)if(e.isKind(r.DiagramView)){let n=e.name?D(e.name)??[]:[],r=n.length>0?n[n.length-1]:``;t.push({name:r,startIndex:e.start,endIndex:e.end})}return t}function dx(e,t,n){e.push(` ${t} {`),n.forEach(t=>e.push(` ${t}`)),e.push(` }`)}function fx(e,t){e.push(` ${t} { * }`)}function px(e){return e==null?`null`:e.length===0?`empty`:`items`}function mx(e,t){let n=`DiagramView ${gg(e)} {`,r=e=>gg(e.name),i=t?.tables?.map(e=>{let t=gg(e.name);return e.schemaName===`public`?t:`${gg(e.schemaName)}.${t}`})??[],a=t?.tableGroups?.map(r)??[],o=t?.schemas?.map(r)??[],s=t?.stickyNotes?.map(r)??[];if(!t)return`${n}\n}`;let c={tables:px(t.tables),tableGroups:px(t.tableGroups),schemas:px(t.schemas),stickyNotes:px(t.stickyNotes)};if(Object.values(c).every(e=>e===`null`))return`${n}\n}`;if(Object.values(c).every(e=>e===`empty`))return`${n}\n *\n}`;let l=c.tables===`items`||c.tableGroups===`items`||c.schemas===`items`,u=c.tables===`empty`&&c.tableGroups===`empty`&&c.schemas===`empty`,d=[n];return l?(c.tables===`items`&&dx(d,`Tables`,i),c.tableGroups===`items`&&dx(d,`TableGroups`,a),c.schemas===`items`&&dx(d,`Schemas`,o)):u&&fx(d,`Tables`),c.stickyNotes===`items`?dx(d,`Notes`,s):c.stickyNotes===`empty`&&fx(d,`Notes`),d.push(`}`),d.join(`
|
|
22
|
-
`)}function
|
|
21
|
+
`;case`\\`:return`\\`;case`r`:return`\r`;case`'`:return`'`;case`"`:return`"`;case"`":return"`";case`0`:return`\0`;case`b`:return`\b`;case`v`:return`\v`;case`f`:return`\f`;case` `:return`\\ `;case`u`:{let t=``;for(let n=0;n<=3;n+=1){if(this.isAtEnd()||!jo(this.peek()))return this.errors.push(new b(y.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${t}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ha.create(_.STRING_LITERAL,this.filepath,e,this.current,`\\u${t}`,!0))),`\\u${t}`;t+=this.advance()}return String.fromCharCode(parseInt(t,16))}default:return this.text[this.current.offset-1]}}},jb=function(e){return e[e.ListExpression=0]=`ListExpression`,e[e.GroupExpression=1]=`GroupExpression`,e[e.BlockExpression=2]=`BlockExpression`,e}({}),Mb=class{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===0&&(this.numberOfNestedLBrackets+=1),e===1&&(this.numberOfNestedLParens+=1),e===2&&(this.numberOfNestedLBraces+=1)}pop(){let e=this.stack.pop();return e===0&&--this.numberOfNestedLBrackets,e===1&&--this.numberOfNestedLParens,e===2&&--this.numberOfNestedLBraces,e}top(){return h(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,t){return()=>{this.push(e);try{return t()}finally{this.pop()}}}findHandlerContext(e,t){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let n=t;n<e.length-1;n+=1)switch(e[n].kind){case _.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(e=>[1,0].includes(e));break;case _.RPAREN:if(this.isWithinGroupExpressionContext())return 1;break;case _.RBRACE:if(this.isWithinBlockExpressionContext())return 2;break;case _.RBRACKET:if(this.isWithinListExpressionContext())return 0;break;default:break}}},Nb=class{constructor(e,t){this.generator=e,this.filepath=t}create(e,t){return new e(t,this.generator.nextId(),this.filepath)}},$=class{constructor(e,t,n){this.token=e,this.partialNode=t,this.handlerContext=n}},Pb=class{constructor(e,t,n,r){this.current=0,this.errors=[],this.contextStack=new Mb,this.useSpecifierList=this.contextStack.withContextDo(jb.BlockExpression,()=>{let e={specifiers:[]},t=()=>this.nodeFactory.create(Xs,e);try{this.consume(`Expect an opening brace '{'`,_.LBRACE),e.openBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeUseSpecifierList()}for(;!this.isAtEnd()&&!this.check(_.RBRACE);){try{e.specifiers.push(this.useSpecifier())}catch(n){if(!(n instanceof $))throw n;if(n.partialNode instanceof Ys&&e.specifiers.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeUseSpecifierList()}if(this.check(_.IDENTIFIER)&&Za(this.peek()))break;!Ua(this.previous())&&!this.check(_.RBRACE)&&this.logError(this.peek(),y.MISSING_SPACES,`Expect a newline between use specifiers`)}try{this.consume(`Expect a closing brace '}'`,_.RBRACE),e.closeBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeUseSpecifierList()}return t()}),this.synchronizeUseSpecifierList=()=>{if(!this.check(_.RBRACE))for(H(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(_.RBRACE)||this.check(_.STRING_LITERAL)||this.check(_.IDENTIFIER)&&Za(e)||Wa(this.previous(),e))break;H(e),this.advance()}},this.synchronizeProgram=()=>{let e=this.peek();e.kind===_.EOF?this.logError(e,y.UNEXPECTED_EOF,`Unexpected EOF`):H(this.advance())},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(Ya(e)||this.check(_.COLON,_.LBRACE,_.LBRACKET))break;H(e),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COLON,_.LBRACE,_.LBRACKET))break;H(e),this.advance()}},this.blockExpression=this.contextStack.withContextDo(jb.BlockExpression,()=>{let e={body:[]},t=()=>this.nodeFactory.create(z,e);try{this.consume(`Expect an opening brace '{'`,_.LBRACE),e.blockOpenBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(_.RBRACE);)try{e.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(n){if(!(n instanceof $))throw n;if(e.body.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeBlock()}try{this.consume(`Expect a closing brace '}'`,_.RBRACE),e.blockCloseBrace=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeBlock()}return t()}),this.synchronizeBlock=()=>{if(!this.check(_.RBRACE))for(H(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(_.RBRACE)||Wa(this.previous(),e))break;H(e),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(jb.GroupExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(nc,{groupOpenParen:e.tupleOpenParen,groupCloseParen:e.tupleCloseParen,expression:e.elementList[0]}),n=()=>this.nodeFactory.create(ec,e);try{this.consume(`Expect an opening parenthesis '('`,_.LPAREN),e.tupleOpenParen=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,n(),e.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(_.RPAREN))try{e.elementList.push(this.normalExpression())}catch(n){if(!(n instanceof $))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(_.RPAREN);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.normalExpression())}catch(t){if(!(t instanceof $))throw t;if(t.partialNode instanceof M&&e.elementList.push(t.partialNode),!this.canHandle(t))throw new $(t.token,n(),t.handlerContext);this.synchronizeTuple()}try{this.consume(`Expect a closing parenthesis ')'`,_.RPAREN),e.tupleCloseParen=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,n(),e.handlerContext);this.synchronizeTuple()}return e.elementList.length===1?t():n()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.RPAREN,_.COMMA))break;H(e),this.advance()}},this.listExpression=this.contextStack.withContextDo(jb.ListExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(B,e);try{this.consume(`Expect an opening bracket '['`,_.LBRACKET),e.listOpenBracket=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(_.RBRACKET))try{e.elementList.push(this.attribute())}catch(n){if(!(n instanceof $))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(_.RBRACKET);)try{this.consume(`Expect a comma ','`,_.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.attribute())}catch(n){if(!(n instanceof $))throw n;if(n.partialNode instanceof M&&e.elementList.push(n.partialNode),!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeList()}try{this.consume(`Expect a closing bracket ']'`,_.RBRACKET),e.listCloseBracket=this.previous()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext);this.synchronizeList()}return t()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;H(e),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET,_.COLON))break;H(e),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(_.COMMA,_.RBRACKET))break;H(e),this.advance()}},this.source=e,this.tokens=t,this.nodeFactory=new Nb(n,r),this.filepath=r}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===_.EOF}advance(){return this.isAtEnd()?h(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?h(this.tokens):this.tokens[this.current+e]}match(...e){let t=this.check(...e);return t&&this.advance(),t}check(...e){let t=this.peek();return e.includes(t.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...t){if(!this.match(...t))throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,e),new $(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...t){if(this.isAtEnd()||!this.check(...t)){for(H(this.peek()),this.logError(this.advance(),y.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...t);)H(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){let e=[],t=[],n,r=0;for(;r<this.tokens.length&&this.tokens[r].isInvalid;r+=1)t.push(this.tokens[r]);for(n=this.tokens[r],n.leadingInvalid=[...t,...n.leadingInvalid],e.push(n),r+=1;r<this.tokens.length;r+=1){let t=this.tokens[r];t.isInvalid?n.trailingInvalid.push(t):(n=t,e.push(n))}this.tokens=e}parse(){let e=this.program(),t=this.advance(),r=this.nodeFactory.create(N,{body:e,eof:t,source:this.source});return this.gatherInvalid(),this.assignParents(r),new n({ast:r,tokens:this.tokens},this.errors)}assignParents(e){jc(e).forEach(t=>{t instanceof M&&(t.parentNode=e,this.assignParents(t))})}program(){let e=[];for(;!this.isAtEnd();)if(Xa(this.peek())||Qa(this.peek()))try{e.push(this.useDeclaration())}catch(t){if(!(t instanceof $))throw t;t.partialNode instanceof Js&&e.push(t.partialNode),this.synchronizeProgram()}else try{e.push(this.elementDeclaration())}catch(t){if(!(t instanceof $))throw t;e.push(t.partialNode),this.synchronizeProgram()}return e}useDeclaration(){let e={},t=()=>this.nodeFactory.create(Js,e);if(this.advance(),e.useKeyword=this.previous(),this.peek().kind===_.WILDCARD)this.advance(),e.specifiers=this.nodeFactory.create(ic,{token:this.previous()});else try{e.specifiers=this.useSpecifierList()}catch(t){if(!(t instanceof $))throw t;t.partialNode instanceof Xs&&(e.specifiers=t.partialNode)}let n=e.specifiers instanceof ic?`'*'`:`specifier list`;return Za(this.peek())?e.fromKeyword=this.advance():this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect 'from' after ${n}`),this.match(_.STRING_LITERAL)?e.importPath=this.previous():this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect a string literal path`),t()}useSpecifier(){let e={},t=()=>this.nodeFactory.create(Ys,e);try{this.consume(`Expect an import kind specifier (e.g. table, enum)`,_.IDENTIFIER),e.importKind=this.previous()}catch(e){throw e instanceof $?new $(e.token,t(),e.handlerContext):e}if(this.check(_.IDENTIFIER,_.QUOTED_STRING))try{e.name=this.normalExpression()}catch(n){throw n instanceof $?(n.partialNode instanceof M&&(e.name=n.partialNode),new $(n.token,t(),n.handlerContext)):n}else e.importKind&&this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an element name`);if(Ya(this.peek())){e.asKeyword=this.advance();try{if(!this.check(_.IDENTIFIER,_.QUOTED_STRING))throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an alias name after 'as'`),new $(this.peek(),t(),this.contextStack.findHandlerContext(this.tokens,this.current));e.alias=this.normalExpression()}catch(e){if(!(e instanceof $))throw e;if(!this.canHandle(e))throw new $(e.token,t(),e.handlerContext)}}return t()}elementDeclaration(){let e={},t=()=>this.nodeFactory.create(P,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(e){throw e instanceof $?new $(e.token,t(),e.handlerContext):e}if(!this.check(_.COLON,_.LBRACE,_.LBRACKET))try{e.name=this.normalExpression()}catch(n){if(!(n instanceof $))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationName()}if(Ya(this.peek()))if(e.as=this.advance(),this.check(_.COLON,_.LBRACE,_.LBRACKET))this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect an alias`);else try{e.alias=this.normalExpression()}catch(n){if(!(n instanceof $))throw n;if(e.alias=n.partialNode,!this.canHandle(n))throw new $(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(_.LBRACKET)?this.listExpression():void 0}catch(n){throw n instanceof $?(e.attributeList=n.partialNode,new $(n.token,t(),n.handlerContext)):n}if(!this.discardUntil(`Expect an opening brace '{' or a colon ':'`,_.LBRACE,_.COLON))return t();try{if(this.match(_.COLON)){e.bodyColon=this.previous();let t=this.expression();t instanceof P?(H(t),this.logError(t,y.UNEXPECTED_ELEMENT_DECLARATION,`An element's simple body must not be an element declaration`)):e.body=t}else e.body=this.blockExpression()}catch(n){throw n instanceof $?(e.body=n.partialNode,new $(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(P,e)}fieldDeclaration(){let e={},t=()=>this.nodeFactory.create(P,e);try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.type=this.previous()}catch(n){throw n instanceof $?(e.type=n.partialNode,new $(n.token,t(),n.handlerContext)):n}try{this.consume(`Expect a colon ':'`,_.COLON),e.bodyColon=this.previous()}catch(n){throw n instanceof $?(e.bodyColon=n.partialNode,new $(n.token,t(),n.handlerContext)):n}try{let t=this.expression();t instanceof P?this.errors.push(new b(y.INVALID_ELEMENT_IN_SIMPLE_BODY,`Simple body cannot be an element declaration`,t)):e.body=t}catch(n){throw n instanceof $?(e.body=n.partialNode,new $(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(P,e)}expression(){let e={args:[]},t=()=>Dc(e.callee,e.args,this.nodeFactory)??this.nodeFactory.create(R,e);try{e.callee=this.commaExpression()}catch(n){throw n instanceof $?(e.callee=n.partialNode,new $(n.token,t(),n.handlerContext)):n}if(this.shouldStopFunctionApplication())return t();let n=e.callee;for(;!this.shouldStopFunctionApplication();){Ga(this.previous())||this.logError(n,y.MISSING_SPACES,`Expect a following space`);try{n=this.commaExpression(),e.args.push(n)}catch(r){throw r instanceof $?(n=r.partialNode,e.args.push(n),new $(r.token,t(),r.handlerContext)):r}}return t()}shouldStopFunctionApplication(){if(this.isAtEnd()||Ua(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.RBRACKET,_.RPAREN,_.COMMA,_.COLON].includes(e)}commaExpression(){let e=this.check(_.COMMA)?this.nodeFactory.create(sc,{prevToken:this.previous()}):this.normalExpression();if(!this.check(_.COMMA))return e;let t={elementList:[e],commaList:[]};do{if(t.commaList.push(this.advance()),this.shouldStopCommaExpression()){t.elementList.push(this.nodeFactory.create(sc,{prevToken:this.previous()}));break}if(this.check(_.COMMA)){t.elementList.push(this.nodeFactory.create(sc,{prevToken:this.previous()}));continue}try{let e=this.normalExpression();t.elementList.push(e)}catch(e){throw e instanceof $?(e.partialNode&&t.elementList.push(e.partialNode),new $(e.token,this.nodeFactory.create(tc,t),e.handlerContext)):e}}while(!this.shouldStopCommaExpression()&&this.check(_.COMMA));return this.nodeFactory.create(tc,t)}shouldStopCommaExpression(){if(this.isAtEnd()||Ua(this.previous()))return!0;let e=this.peek().kind;return[_.RBRACE,_.LBRACE,_.RBRACKET,_.LBRACKET,_.RPAREN,_.LPAREN,_.COLON].includes(e)}normalExpression(){return this.expression_bp(0)}expression_bp(e){let t=this.leftExpression_bp();for(;!this.isAtEnd();){let n=this.peek();if(n.kind===_.LPAREN){let{left:r}=Bb(n);if(r<e||Wa(this.previous(),n)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{t=this.nodeFactory.create(V,{callee:t,argumentList:this.tupleExpression()})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(V,{callee:t,argumentList:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}else if(n.kind===_.LBRACKET){if(Ga(this.previous()))break;try{t=this.nodeFactory.create(cc,{expression:t,indexer:this.listExpression()})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(cc,{expression:t,indexer:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}else if(Va(n)){let r=n,i=Bb(r);if(i.left!==null){if(i.left<=e)break;this.advance(),t=this.nodeFactory.create(Qs,{expression:t,op:r})}else{let n=Ib(r);if(n.left===null||n.left<=e)break;this.advance();try{t=this.nodeFactory.create(L,{leftExpression:t,op:r,rightExpression:r.value===`.`?this.extractOperand():this.expression_bp(n.right)})}catch(e){throw e instanceof $?(t=this.nodeFactory.create(L,{leftExpression:t,op:r,rightExpression:e.partialNode}),new $(e.token,t,e.handlerContext)):e}}}else break}return t}leftExpression_bp(){let e;if(Va(this.peek())){let t={};t.op=this.peek();let n=Rb(t.op);if(n.right===null)throw this.logError(t.op,y.UNKNOWN_PREFIX_OP,`Unexpected '${t.op.value}' in an expression`),new $(t.op,this.nodeFactory.create(sc,{prevToken:t.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{t.expression=this.expression_bp(n.right)}catch(e){throw e instanceof $?(t.expression=e.partialNode,new $(e.token,this.nodeFactory.create(I,t),e.handlerContext)):e}e=this.nodeFactory.create(I,t)}else if(e=this.extractOperand(),e instanceof sc)throw new $(this.peek(),this.nodeFactory.create(sc,{prevToken:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(_.WILDCARD)?this.wildcardExpression():this.check(_.NUMERIC_LITERAL,_.STRING_LITERAL,_.COLOR_LITERAL,_.QUOTED_STRING,_.IDENTIFIER)?this.primaryExpression():this.check(_.FUNCTION_EXPRESSION)?this.functionExpression():this.check(_.LBRACKET)?this.listExpression():this.check(_.LBRACE)?this.blockExpression():this.check(_.LPAREN)?this.tupleExpression():(this.peek().kind===_.EOF?this.logError(this.peek(),y.UNEXPECTED_EOF,`Unexpected EOF`):this.logError(this.peek(),y.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(sc,{prevToken:this.previous()}))}functionExpression(){let e={};try{this.consume(`Expect a function expression`,_.FUNCTION_EXPRESSION),e.value=this.previous()}catch(t){throw t instanceof $?new $(t.token,this.nodeFactory.create($s,e),t.handlerContext):t}return this.nodeFactory.create($s,e)}wildcardExpression(){return this.advance(),this.nodeFactory.create(ic,{token:this.previous()})}canBeField(){return this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.COLON}primaryExpression(){if(this.match(_.COLOR_LITERAL,_.STRING_LITERAL,_.NUMERIC_LITERAL))return this.nodeFactory.create(oc,{expression:this.nodeFactory.create(rc,{literal:this.previous()})});if(this.match(_.QUOTED_STRING,_.IDENTIFIER))return this.nodeFactory.create(oc,{expression:this.nodeFactory.create(ac,{variable:this.previous()})});throw this.logError(this.peek(),y.UNEXPECTED_TOKEN,`Expect a variable or literal`),new $(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){let e={};if(this.check(_.COLON,_.RBRACKET,_.COMMA)){let t=this.peek();this.logError(t,y.EMPTY_ATTRIBUTE_NAME,`Expect a non-empty attribute name`),e.name=this.nodeFactory.create(Zs,{identifiers:[]})}else try{e.name=this.attributeName()}catch(t){if(!(t instanceof $))throw t;if(e.name=t.partialNode,!this.canHandle(t))throw new $(t.token,this.nodeFactory.create(F,e),t.handlerContext);this.synchronizeAttributeName()}return this.match(_.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(F,e)}attributeValue(){let e;try{e=this.peek().kind===_.IDENTIFIER&&this.peek(1).kind===_.IDENTIFIER?this.attributeName():this.normalExpression()}catch(t){if(!(t instanceof $)||!this.canHandle(t))throw t;e=t.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){let e=[];if(this.peek().kind!==_.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(_.COLON,_.COMMA,_.RBRACKET);)try{this.consume(`Expect an identifier`,_.IDENTIFIER),e.push(this.previous())}catch(t){throw t instanceof $?new $(t.token,this.nodeFactory.create(Zs,{identifiers:e}),t.handlerContext):t}return this.nodeFactory.create(Zs,{identifiers:e})}logError(e,t,n){this.errors.push(new b(t,n,e))}},Fb={"+":{left:9,right:10},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"->":{left:7,right:8},"<-":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function Ib(e){return Fb[e.value]||{left:null,right:null}}var Lb={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"->":{left:null,right:15},"<-":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function Rb(e){return Lb[e.value]||{left:null,right:null}}var zb={"(":{left:14,right:null}};function Bb(e){return zb[e.value]||{left:null,right:null}}function Vb(e){let t=this.getSource(e);return new Ab(t??``,e).lex().chain(n=>new Pb(t??``,n,this.nodeIdGenerator,e).parse()).map(({ast:t,tokens:n})=>({ast:t,tokens:n,path:e}))}function Hb(){let e=xg(this,this.layout.getEntrypoints()),t=new Map;for(let n of e){let e=this.parseFile(n);t.set(n.absolute,e)}return t}function Ub(e){let n=this.symbolMembers(e).getFiltered(t),r=new Map;if(n)for(let e of n){let t=e instanceof Ws?Jh.visibleName(this,e)?.at(-1):e.name;if(t===void 0)continue;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}return r}function Wb(e,n,r){let i;if(e instanceof Ts)i=e;else{let n=this.nodeSymbol(e).getFiltered(t);if(!(n instanceof Ts))return;i=n}let a=Array.isArray(n)?n:[n],o=this.symbolMembersLookupMap(i).get(r);if(o)return o.find(e=>!(a.length===1&&e.kind!==a[0]||a.length>1&&!a.includes(e.kind)))}function Gb(e){let t=e.originalSymbol;return Sg(this).map(n=>n.filter(n=>n instanceof Us&&n.originalSymbol===t&&n!==e))}function Kb(){let e=new Map,n=new Map,r=this.parseProject();this.bindProject();let i=new Set,a=(t,n)=>{if(i.has(n))return;i.add(n);let r=t.intern(),a=e.get(r);a||(a=[],e.set(r,a)),a.push(n);let o=t.originalSymbol;if(o!==t){let t=o.intern(),r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}},o=e=>{for(let t of e.owners(this)){let r=t.intern(),i=n.get(r);i||(i=[],n.set(r,i)),i.push(e)}};for(let e of r.values()){let n=e.getValue().ast,r=e=>{if(C(e)){let n=this.nodeReferee(e).getFiltered(t);n&&a(n,e);return}if(e instanceof ec&&w(e.parentNode)&&e.parentNode.rightExpression===e){let n=e.parentNode.leftExpression;if(n){let e=rs(n);if(e){let n=this.nodeReferee(e).getFiltered(t);n&&a(n,e)}}}let n=this.nodeMetadata(e).getFiltered(t);n&&o(n);for(let t of jc(e))t instanceof M&&r(t)};r(n)}let s=new Map,c=new Set;function l(e,n){let r=n.intern();if(c.has(r))return;c.add(r);let i=e.symbolMembers(n).getFiltered(t);if(i)for(let t of i){let r=t.intern(),i=s.get(r);i||(i=[],s.set(r,i)),i.push(n),t instanceof Es&&t.isKind(j.Schema)&&l(e,t)}}for(let e of r.values()){let n=e.getValue().ast,r=this.nodeSymbol(n).getFiltered(t);r&&l(this,r)}return{references:e,metadata:n,parents:s}}function qb(e){return this.resolutionIndex().parents.get(e.intern())??[]}function Jb(e){return this.resolutionIndex().references.get(e.intern())??[]}function Yb(e){return this.resolutionIndex().metadata.get(e.intern())??[]}function Xb(e){let t=e.originalSymbol;return Sg(this).map(n=>n.filter(n=>n instanceof Ws&&n.originalSymbol===t&&n!==e))}function Zb(e,t,n=!1){let r=n?t:[...t].sort((e,t)=>t.start-e.start),i=e;for(let{start:e,end:t,newText:n}of r)i=i.substring(0,e)+n+i.substring(t);return i}function Qb(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=bg(e);if(t.length===0)return{schema:v,table:``};if(t.length===1)return{schema:v,table:t[0]};if(t.length===2)return{schema:t[0],table:t[1]};let n=t[t.length-1];return{schema:t.slice(0,-1).join(`.`),table:n}}function $b(e,n,r,i,a=j.Table){let o=e.parseFile(n).getValue().ast,s=e.nodeSymbol(o).getFiltered(t);if(!s)return null;if(r===`public`)return e.lookupMembers(s,a,i)??null;let c=e.lookupMembers(s,j.Schema,r);return c?e.lookupMembers(c,a,i)??null:null}function ex(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function tx(e,t){if(!e||!(e instanceof P))return!1;let n=e.name;return n?t.substring(n.start,n.end).includes(`"`):!1}function nx(e,t,n){let r=!hg(t),i=!hg(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function rx(e,t,n,r,i,a){return n===i&&r===a?!1:$b(e,t,i,a)!==null}function ix(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return ex(n.substring(i,a))===t?{start:i,end:e.end}:null}function ax(e){return e.schema===`public`?e.formattedTable:`${e.formattedSchema}.${e.formattedTable}`}function ox(e,t,n,r,i){let a=[],o=new Set,s=ax(r);for(let r of e){if(ex(i.substring(r.start,r.end))!==n)continue;let e=ix(r,t,i)??{start:r.start,end:r.end},c=`${e.start}-${e.end}`;o.has(c)||(o.add(c),a.push({start:e.start,end:e.end,newText:s}))}return a}function sx(e,n,r){let i=Qb(n),a=Qb(r),o=i.schema,s=i.table,c=a.schema,l=a.table,u=$b(this,e,o,s);if(!u||u instanceof Us||rx(this,e,o,s,c,l))return new Map;if(u instanceof Ws&&u.useSpecifierDeclaration instanceof Ys&&u.useSpecifierDeclaration.alias){let n=u.useSpecifierDeclaration;if(this.nodeAlias(n).getFiltered(t)===s)return cx(this,e,n,u,c,l)}return lx(this,u,o,s,c,l)}function cx(e,t,n,r,i,a){let o=e.getSource(t)??``;if(!n.alias)return new Map;let s=nx(i,a,o.substring(n.alias.start,n.alias.end).includes(`"`)),c=[];c.push({start:n.alias.start,end:n.alias.end,newText:s.formattedTable});let l=e.symbolReferences(r);for(let e of l)e.filepath.absolute===t.absolute&&e!==n.alias&&c.push({start:e.start,end:e.end,newText:s.formattedTable});return new Map([[t.absolute,Zb(o,c)]])}function lx(e,t,n,r,i,a){let o=t.originalSymbol,s=o.declaration;if(!s||!(s instanceof P))return new Map;let c=s.filepath;if(!c)return new Map;let l=nx(i,a,tx(s,e.getSource(c)??``)),u=new Map,d=(e,t)=>{let n=e.absolute,r=u.get(n);r||(r={fp:e,edits:[]},u.set(n,r)),r.edits.push(t)},f=s.name;f&&d(c,{start:f.start,end:f.end,newText:ax(l)});let p=e.symbolReferences(o);for(let t of p){if(t===f)continue;let i=t.filepath,a=e.getSource(i)??``;for(let e of ox([t],n,r,l,a))d(i,e)}let m=new Map;for(let{fp:t,edits:n}of u.values()){let r=e.getSource(t)??``;m.set(t.absolute,Zb(r,n))}return m}function ux(e,t){let n=px(e);if(n){let e=n.end-1;return{start:e,end:e,newText:`, ${t}`}}if(e instanceof P){let n=e.body;if(n&&!(n instanceof R))return{start:n.start,end:n.start,newText:`[${t}] `}}return{start:e.end,end:e.end,newText:` [${t}]`}}function dx(e,t,n,r){if(n===null)return fx(e,t,r);let i=n===void 0?t:`${t}: ${n}`,a=hx(e,t);if(a)return{start:a.settingNode.start,end:a.settingNode.end,newText:i};let o=gx(e,t);return o?{start:o.start,end:o.end,newText:i}:ux(e,i)}function fx(e,t,n){let r=hx(e,t);if(r){let{settingsList:e,settingIndex:t}=r,i=e.elementList??[];if(i.length===1){let t=e.start;for(;t>0&&n[t-1]===` `;)t--;return{start:t,end:e.end,newText:``}}let a=i[t];if(t===0){let e=i[t+1];return{start:a.start,end:e.start,newText:``}}return{start:i[t-1].end,end:a.end,newText:``}}let i=gx(e,t);if(i)return{start:i.start,end:i.end,newText:``}}function px(e){if(e instanceof R)return e.args.find(e=>e instanceof B);if(e instanceof P){if(e.attributeList)return e.attributeList;let t=e.body;if(t instanceof R)return t.args.find(e=>e instanceof B)}}function mx(e){if(e.name instanceof Zs)return os(e.name)?.toLowerCase()}function hx(e,t){let n=px(e);if(!n)return;let r=t.toLowerCase(),i=n.elementList??[],a=i.findIndex(e=>e instanceof F?mx(e)===r:!1);if(a!==-1)return{settingsList:n,settingNode:i[a],settingIndex:a}}function gx(e,t){if(!(e instanceof P))return;let n=e.body;if(!(!n||n instanceof R)){for(let e of n.body)if(e instanceof P&&e.type?.value?.toLowerCase()===t.toLowerCase()&&e.body instanceof R&&e.body.callee)return e}}function _x(e,t,n,r){let i=this.getSource(e)??``,a=t.kind,o=(`schema`in t?t.schema:void 0)??`public`,s=`table`in t?t.table:`name`in t?t.name:``,c=$b(this,e,o,s,a);if(!c?.declaration)return i;let l=dx(c.declaration,n,r,i);return l?Zb(i,[l]):i}function vx(e){let t=[],n=new Ab(e,Eo).lex();if(n.getErrors().length>0)return t;let i=new Pb(e,n.getValue(),new Ks,Eo).parse();if(i.getErrors().length>0)return t;let a=i.getValue().ast;for(let e of a.declarations)if(e.isKind(r.DiagramView)){let n=e.name?D(e.name)??[]:[],r=n.length>0?n[n.length-1]:``;t.push({name:r,startIndex:e.start,endIndex:e.end})}return t}function yx(e,t,n){e.push(` ${t} {`),n.forEach(t=>e.push(` ${t}`)),e.push(` }`)}function bx(e,t){e.push(` ${t} { * }`)}function xx(e){return e==null?`null`:e.length===0?`empty`:`items`}function Sx(e,t){let n=`DiagramView ${gg(e)} {`,r=e=>gg(e.name),i=t?.tables?.map(e=>{let t=gg(e.name);return e.schemaName===`public`?t:`${gg(e.schemaName)}.${t}`})??[],a=t?.tableGroups?.map(r)??[],o=t?.schemas?.map(r)??[],s=t?.stickyNotes?.map(r)??[];if(!t)return`${n}\n}`;let c={tables:xx(t.tables),tableGroups:xx(t.tableGroups),schemas:xx(t.schemas),stickyNotes:xx(t.stickyNotes)};if(Object.values(c).every(e=>e===`null`))return`${n}\n}`;if(Object.values(c).every(e=>e===`empty`))return`${n}\n *\n}`;let l=c.tables===`items`||c.tableGroups===`items`||c.schemas===`items`,u=c.tables===`empty`&&c.tableGroups===`empty`&&c.schemas===`empty`,d=[n];return l?(c.tables===`items`&&yx(d,`Tables`,i),c.tableGroups===`items`&&yx(d,`TableGroups`,a),c.schemas===`items`&&yx(d,`Schemas`,o)):u&&bx(d,`Tables`),c.stickyNotes===`items`?yx(d,`Notes`,s):c.stickyNotes===`empty`&&bx(d,`Notes`),d.push(`}`),d.join(`
|
|
22
|
+
`)}function Cx(e,t,n){let r=this.getSource(e)??``,i=n??vx(r),a=[];for(let e of t){let t=wx(r,e,i);a.push(...t)}return a.sort((e,t)=>t.start-e.start),{newDbml:Zb(r,a,!0),edits:a}}function wx(e,t,n){switch(t.operation){case`create`:return Tx(e,t,n);case`update`:return Ex(e,t,n);case`delete`:return Dx(e,t,n);default:return[]}}function Tx(e,t,n){if(n.find(e=>e.name===t.name))return Ex(e,t,n);let r=`
|
|
23
23
|
|
|
24
|
-
`+
|
|
25
|
-
`;return[{start:e.length,end:e.length,newText:r}]}function
|
|
24
|
+
`+Sx(t.name,t.visibleEntities)+`
|
|
25
|
+
`;return[{start:e.length,end:e.length,newText:r}]}function Ex(e,t,n){let r=n.find(e=>e.name===t.name);if(!r)return[];let i=[];if(t.newName||t.visibleEntities){let e=Sx(t.newName||t.name,t.visibleEntities);i.push({start:r.startIndex,end:r.endIndex,newText:e})}return i}function Dx(e,t,n){let r=n.find(e=>e.name===t.name);if(!r)return[];let i=r.startIndex,a=r.endIndex;for(;i>0&&e[i-1]===`
|
|
26
26
|
`;){i--,i>0&&e[i-1]===`\r`&&i--;let t=e.lastIndexOf(`
|
|
27
27
|
`,i-1)+1;if(e.substring(t,i).trim()!==``){i=r.startIndex,i>0&&e[i-1]===`
|
|
28
28
|
`&&(i--,i>0&&e[i-1]===`\r`&&i--);break}}return a<e.length&&e[a]===`\r`&&a++,a<e.length&&e[a]===`
|
|
29
|
-
`&&a++,[{start:i,end:a,newText:``}]}function
|
|
29
|
+
`&&a++,[{start:i,end:a,newText:``}]}function Ox(e,t){let n=jx(e);if(n)return{start:n.noteValueStart,end:n.noteValueEnd,newText:Cg(t)}}function kx(e){let t=jx(e);if(t)return{start:t.fullNoteStart,end:t.fullNoteEnd,newText:``}}function Ax(e,t){if(jx(e)||!(e instanceof P))return;let n=Mx(e);if(n!==void 0)return{start:n,end:n,newText:` note: ${Cg(t)}\n`};let r=e.body;if(r instanceof R){let n=r.args.find(e=>e instanceof B);if(n&&n.listCloseBracket){let e=n.elementList.length===0?``:`, `;return{start:n.listCloseBracket.start,end:n.listCloseBracket.start,newText:`${e}note: ${Cg(t)}`}}return{start:e.end,end:e.end,newText:` [note: ${Cg(t)}]`}}}function jx(e){if(!(e instanceof P))return;let t=e.body;if(t&&!(t instanceof R))for(let e of t.body){if(!(e instanceof P)||!e.isKind(r.Note))continue;let t=Nx(e);if(t)return{kind:qs.ELEMENT_DECLARATION,noteValueStart:t.start,noteValueEnd:t.end,fullNoteStart:e.start,fullNoteEnd:e.end}}let n=e.attributeList??(t instanceof R?t.args.find(e=>e instanceof B):void 0);if(n)return Px(n)}function Mx(e){let t=e.body;if(!(!t||t instanceof R)&&t.blockCloseBrace)return t.blockCloseBrace.start}function Nx(e){let t=e.body;if(t instanceof R)return t.callee??void 0;if(t instanceof z&&t.body[0]instanceof R)return t.body[0].callee??void 0}function Px(e){let t=x(e).getValue()[i.Note];if(!t?.length)return;let n=t[0];if(!n.value)return;let r=e.elementList,a=r.indexOf(n),o=n.start,s=n.end;return r.length===1?(o=e.start,s=e.end):a<r.length-1?s=r[a+1].start:o=r[a-1].end,{kind:qs.ATTRIBUTE,noteValueStart:n.value.start,noteValueEnd:n.value.end,fullNoteStart:o,fullNoteEnd:s}}function Fx(e){let t=[],n=new Ab(e,Eo).lex();if(n.getErrors().length>0)return t;let i=new Pb(e,n.getValue(),new Ks,Eo).parse();if(i.getErrors().length>0)return t;let a=i.getValue().ast;for(let e of a.declarations){if(!(e instanceof P)||!e.isKind(r.Dep))continue;let n=[],i=e.body;if(i instanceof R){if(i.callee instanceof L){let e=Wx(i.callee);e&&n.push(e)}}else if(i){for(let e of i.body)if(e instanceof R&&e.callee instanceof L){let t=Wx(e.callee);t&&n.push(t)}}t.push({startIndex:e.start,endIndex:e.end,declaration:e,edges:n})}return t}function Ix(e){let t=[],n=new Ab(e,Eo).lex();if(n.getErrors().length>0)return t;let a=new Pb(e,n.getValue(),new Ks,Eo).parse();if(a.getErrors().length>0)return t;let o=a.getValue().ast;for(let n of o.declarations){if(!(n instanceof P)||!n.isKind(r.Table))continue;let a=n.name?D(n.name)??[]:[];if(a.length===0)continue;let o=a[a.length-1],s=a.length>1?a[a.length-2]:null,c=n.body;if(!(!c||c instanceof R))for(let n of c.body){if(!(n instanceof R)||!n.callee)continue;let r=D(n.callee)?.at(-1);if(!r)continue;let a={schemaName:s,tableName:o,fieldNames:[r]},c=fx(n,i.Dep,e);if(c)for(let e of Zx(n,a))t.push({edge:e,stripStart:c.start,stripEnd:c.end})}}return t}function Lx(e,t){return`Dep [color: ${t}] {\n ${Kx(e.upstream)} -> ${Kx(e.downstream)}\n}`}function Rx(e,t,n){let r=this.getSource(e)??``,i=n??Fx(r),a=Ix(r),o=[];for(let e of t)o.push(...Qx(r,e,i,a));return o.sort((e,t)=>t.start-e.start),{newDbml:Zb(r,o,!0),edits:o}}function zx(e){return e&&e.length>0?e:v}function Bx(e,t){if(e.length===0)return;if(!t){let t=e[e.length-1];return{schemaName:e.length>1?e[e.length-2]:null,tableName:t,fieldNames:[]}}let n=[e[e.length-1]],r=e[e.length-2];return{schemaName:e.length>2?e[e.length-3]:null,tableName:r,fieldNames:n}}function Vx(e,t){if(zx(e.schemaName)!==zx(t.schemaName)||e.tableName!==t.tableName)return!1;let n=e.fieldNames??[],r=t.fieldNames??[];return n.length===r.length?n.every((e,t)=>e===r[t]):!1}function Hx(e,t){return Vx(e.upstream,t.upstream)&&Vx(e.downstream,t.downstream)}function Ux(e,t){return e.edges.some(e=>Hx(e,t))}function Wx(e){let t=e.op?.value;if(t!==`->`&&t!==`<-`)return;let n=e.leftExpression,r=e.rightExpression;if(!n||!r)return;let i=t===`<-`?r:n,a=t===`<-`?n:r,o=D(i),s=D(a);if(!o||!s)return;let c=o.length>1&&s.length>1,l=Bx(o,c),u=Bx(s,c);if(!(!l||!u))return{upstream:l,downstream:u}}function Gx(e){if(e.name instanceof Zs)return os(e.name)?.toLowerCase()}function Kx(e){let t=zx(e.schemaName),n=[];t!==`public`&&n.push(gg(t)),n.push(gg(e.tableName));for(let t of e.fieldNames??[])n.push(gg(t));return n.join(`.`)}function qx(e,t){return e.find(e=>Ux(e,t))}function Jx(e,t,n){let r=[];if(e.color!==void 0){let a=dx(t.declaration,i.Color,e.color,n);a&&r.push(a)}if(e.note===null){let e=kx(t.declaration);e&&r.push(e)}else if(e.note!==void 0){let n=Ox(t.declaration,e.note)??Ax(t.declaration,e.note);n&&r.push(n)}return r}function Yx(e,t,n,r){let i=qx(n,t.edge);if(i)return Jx(t,i,e);let a=Lx(t.edge,t.color??``),o={start:e.length,end:e.length,newText:`
|
|
30
30
|
|
|
31
31
|
`+a+`
|
|
32
|
-
`},s=r.find(e=>
|
|
32
|
+
`},s=r.find(e=>Hx(e.edge,t.edge));return s?[{start:s.stripStart,end:s.stripEnd,newText:``},o]:[o]}function Xx(e,t,n){let r=e.color===void 0&&e.note===void 0;return Jx({...e,color:r?null:e.color},t,n)}function Zx(e,t){let n=e.args.find(e=>e instanceof B);if(!n)return[];let r=[];for(let e of n.elementList){if(Gx(e)!==i.Dep)continue;let n=e.value;if(!(n instanceof I)||!n.expression)continue;let a=n.op?.value;if(a!==`->`&&a!==`<-`)continue;let o=D(n.expression);if(!o)continue;let s=Bx(o,o.length>1);s&&r.push(a===`->`?{upstream:t,downstream:s}:{upstream:s,downstream:t})}return r}function Qx(e,t,n,r){switch(t.operation){case`create`:return Yx(e,t,n,r);case`update`:{let r=qx(n,t.edge);return r?Jx(t,r,e):[]}case`remove`:{let r=qx(n,t.edge);return r?Xx(t,r,e):[]}default:return[]}}var $x=Symbol(`COMPUTING`),eS=class{constructor(e){this.layout=e,this.nodeIdGenerator=new Ks,this.symbolIdGenerator=new ws,this.symbolFactory=new eo(this.symbolIdGenerator),this.sourceSnapshot=new Map,this.globalCache=new Map,this.globallyQuerying=!1,this.localCache=new Map,this.parseFile=this.localQuery(Vb),this.parseProject=this.globalQuery(Hb),this.validateNode=this.localQuery(H_),this.validateFile=this.localQuery(kb),this.nodeFullname=this.localQuery(W_),this.nodeAlias=this.localQuery(G_),this.nodeSettings=this.localQuery(U_),this.canonicalName=this.globalQuery(ub),this.bindNode=this.globalQuery(Qg),this.bindFile=this.globalQuery(Tb),this.bindProject=this.globalQuery(Eb),this.interpretSymbol=this.globalQuery(e_),this.interpretMetadata=this.globalQuery(t_),this.interpretFile=this.globalQuery(Db),this.interpretProject=this.globalQuery(Ob),this.nodeSymbol=this.globalQuery(Yg),this.nodeMetadata=this.globalQuery($g),this.symbolMembers=this.globalQuery(Xg),this.symbolMembersLookupMap=this.globalQuery(Ub),this.lookupMembers=this.globalQuery(Wb),this.nodeReferee=this.globalQuery(Zg),this.resolutionIndex=this.globalQuery(Kb),this.symbolReferences=this.globalQuery(Jb),this.symbolParent=this.globalQuery(qb),this.symbolMetadata=this.globalQuery(Yb),this.symbolAliases=this.globalQuery(Gb),this.symbolUses=this.globalQuery(Xb),this.fileDependencies=this.localQuery(pb),this.reachableFiles=this.globalQuery(hb),this.usableMembers=this.globalQuery(Zh),this.nodeAtPosition=this.localQuery(wb),this.renameTable=sx.bind(this),this.updateElementSetting=_x.bind(this),this.syncDiagramView=Cx.bind(this),this.syncDep=Rx.bind(this),this.token={invalidStream:this.localQuery(Cb),flatStream:this.localQuery(Sb)},this.parse={source:e=>this.getSource(e)||``,ast:(e=Eo)=>gb.call(this,e),errors:(e=Eo)=>_b.call(this,e),warnings:(e=Eo)=>vb.call(this,e),tokens:(e=Eo)=>yb.call(this,e),rawDb:(e=Eo)=>bb.call(this,e),publicSymbolTable:(e=Eo)=>xb.call(this,e)},this.container={stack:this.localQuery(ab),token:this.localQuery(ob),element:this.localQuery(sb),scope:this.localQuery(cb),scopeKind:this.localQuery(lb)}}getSource(e){return this.layout.getSource(e)}cleanStaleLocalCache(e){let t=this.layout.getSource(e),n=e.absolute,r=this.sourceSnapshot.get(n);r===void 0?this.sourceSnapshot.set(n,t):r!==t&&(this.localCache.delete(e.intern()),this.globalCache.clear(),this.sourceSnapshot.set(n,t))}cleanStaleGlobalCache(){let e=this.layout.getEntrypoints(),t=!1;this.entrypointsSnapshot!==void 0&&(this.entrypointsSnapshot.length!==e.length||this.entrypointsSnapshot.some((t,n)=>t.absolute!==e[n].absolute))&&(t=!0),this.entrypointsSnapshot=e;for(let t of mb(this,e))this.cleanStaleLocalCache(t);t&&this.globalCache.clear()}globalQuery(e){let t=Symbol();return((...n)=>{let r=!this.globallyQuerying;r&&(this.globallyQuerying=!0,this.cleanStaleGlobalCache());try{let r=this.globalCache.get(t);r||(r=new Map,this.globalCache.set(t,r));let i=n.length===0?``:n.length===1?Ec(n[0]):n.map(e=>Ec(e)).join(`\0`),a=r.get(i);if(a){if(a===$x)throw Error(`Cycle detected in query: ${e.name}(${i})`);return a}r.set(i,$x);try{let t=e.apply(this,n);return r.set(i,t),t}catch(e){throw r.delete(i),e}}finally{r&&(this.globallyQuerying=!1)}})}localQuery(e){let t=Symbol();return((...n)=>{let[r]=n,i=r instanceof M?r.filepath:r;this.cleanStaleLocalCache(i);let a=i.intern(),o=n.length===0?``:n.length===1?Ec(n[0]):n.map(e=>Ec(e)).join(`\0`),s=this.localCache.get(a);s||(s=new Map,this.localCache.set(a,s));let c=s.get(t);if(c||(c=new Map,s.set(t,c)),c.has(o)){let t=c.get(o);if(t===$x)throw Error(`Cycle detected in query: ${e.name}(${a}, ${o})`);return t}c.set(o,$x);try{let t=e.apply(this,n);return c.set(o,t),t}catch(e){throw c.delete(o),e}})}initMonacoServices(e){let t=e?.autocompletion?.triggerCharacters??[];return{definitionProvider:new ey(this),referenceProvider:new ny(this),autocompletionProvider:new ky(this,{triggerCharacters:t}),diagnosticsProvider:new ty(this)}}},tS=class e{constructor(e={}){this.files=e instanceof Map?new Map(e):new Map(Object.entries(e))}setSource(e,t){this.files.set(e.absolute,t)}getSource(e){return this.files.get(e.absolute)??void 0}deleteSource(e){this.files.delete(e.absolute)}clearSource(){this.files.clear()}exists(e){return this.isFile(e)||this.isDirectory(e)}isFile(e){return this.files.has(e.absolute)}isDirectory(e){let t=e.absolute.endsWith(`/`)?e.absolute:`${e.absolute}/`;for(let e of this.files.keys())if(e.startsWith(t))return!0;return!1}listDirectory(e){let t=e?.absolute??`/`,n=t.endsWith(`/`)?t:t+`/`,r=new Set;for(let e of this.files.keys()){if(!e.startsWith(n))continue;let t=e.slice(n.length),i=t.indexOf(`/`);r.add(n+(i===-1?t:t.slice(0,i)))}return[...r].sort().map(bo.from)}getEntrypoints(){return[...this.files.keys()].map(bo.from).sort((e,t)=>e.absolute.localeCompare(t.absolute))}clone(){return new e(this.files)}};exports.ArrayNode=cc,exports.AttributeNode=F,exports.BlockExpressionNode=z,exports.CallExpressionNode=V,exports.CommaExpressionNode=tc,exports.CompileError=b,exports.CompileErrorCode=y,exports.Compiler=eS,exports.CompletionItemInsertTextRule=X,exports.CompletionItemKind=Y,exports.DBMLCompletionItemProvider=ky,exports.DBMLDefinitionProvider=ey,exports.DBMLDiagnosticsProvider=ty,exports.DBMLReferencesProvider=ny,exports.DEFAULT_ENTRY=Eo,exports.ElementDeclarationNode=P,exports.ElementKind=r,exports.EmptyNode=sc,exports.FALSY_VALUES=Zm,exports.Filepath=bo,exports.FunctionApplicationNode=R,exports.FunctionExpressionNode=$s,exports.GroupExpressionNode=nc,exports.IdentifierStreamNode=Zs,exports.InfixExpressionNode=L,exports.ListExpressionNode=B,exports.LiteralNode=rc,exports.MarkerSeverity=Zv,exports.MemoryProjectLayout=tS,exports.MetadataKind=dc,exports.PostfixExpressionNode=Qs,exports.PrefixExpressionNode=I,exports.PrimaryExpressionNode=oc,exports.ProgramNode=N,exports.ScopeKind=Q,exports.SymbolKind=j,exports.SyntaxNode=M,exports.SyntaxNodeIdGenerator=Ks,exports.SyntaxNodeKind=qs,exports.SyntaxToken=Ha,exports.SyntaxTokenKind=_,exports.TRUTHY_VALUES=Xm,exports.TupleExpressionNode=ec,exports.UNHANDLED=t,exports.Uri=Bv,exports.UseDeclarationNode=Js,exports.UseSpecifierListNode=Xs,exports.UseSpecifierNode=Ys,exports.VariableNode=ac,exports.WildcardNode=ic,exports.addDoubleQuoteIfNeeded=gg,exports.dbmlLanguageConfig=rb,exports.dbmlMonarchTokensProvider=ib,exports.escapeString=vg,exports.extractNumericLiteral=ps,exports.extractSignedNumber=qm,exports.findDepBlocks=Fx,exports.findDiagramViewBlocks=vx,exports.formatRecordValue=yg,exports.getRecordValueType=Al,exports.isBinaryType=Dl,exports.isBooleanType=Tl,exports.isDateTimeType=Ol,exports.isEmptyStringLiteral=Gm,exports.isFloatType=Cl,exports.isFunctionExpression=Km,exports.isIntegerType=Sl,exports.isNullish=Wm,exports.isNumericType=wl,exports.isOp=Ba,exports.isOpToken=Va,exports.isSerialType=kl,exports.isStringType=El,exports.isTriviaToken=za,exports.isValidIdentifier=hg,exports.normalizeTypeName=xl,exports.splitQualifiedIdentifier=bg,exports.tryExtractBoolean=Qm,exports.tryExtractDateTime=ih,exports.tryExtractEnum=$m,exports.tryExtractInteger=Ym,exports.tryExtractNumeric=Jm,exports.tryExtractString=eh,exports.unescapeString=_g,exports.validateForeignKeys=Dh,exports.validatePrimaryKey=gh,exports.validateUnique=Ch;
|
package/dist/dbml-parse.mjs
CHANGED
|
@@ -15480,12 +15480,12 @@ function Qb(e) {
|
|
|
15480
15480
|
table: n
|
|
15481
15481
|
};
|
|
15482
15482
|
}
|
|
15483
|
-
function $b(e, n, r, i) {
|
|
15484
|
-
let
|
|
15485
|
-
if (!
|
|
15486
|
-
if (r === "public") return e.lookupMembers(
|
|
15487
|
-
let
|
|
15488
|
-
return
|
|
15483
|
+
function $b(e, n, r, i, a = j.Table) {
|
|
15484
|
+
let o = e.parseFile(n).getValue().ast, s = e.nodeSymbol(o).getFiltered(t);
|
|
15485
|
+
if (!s) return null;
|
|
15486
|
+
if (r === "public") return e.lookupMembers(s, a, i) ?? null;
|
|
15487
|
+
let c = e.lookupMembers(s, j.Schema, r);
|
|
15488
|
+
return c ? e.lookupMembers(c, a, i) ?? null : null;
|
|
15489
15489
|
}
|
|
15490
15490
|
function ex(e) {
|
|
15491
15491
|
return e.startsWith("\"") && e.endsWith("\"") && e.length >= 2 ? e.slice(1, -1) : e;
|
|
@@ -15607,8 +15607,120 @@ function lx(e, t, n, r, i, a) {
|
|
|
15607
15607
|
return m;
|
|
15608
15608
|
}
|
|
15609
15609
|
//#endregion
|
|
15610
|
+
//#region src/core/utils/setting.ts
|
|
15611
|
+
function ux(e, t) {
|
|
15612
|
+
let n = px(e);
|
|
15613
|
+
if (n) {
|
|
15614
|
+
let e = n.end - 1;
|
|
15615
|
+
return {
|
|
15616
|
+
start: e,
|
|
15617
|
+
end: e,
|
|
15618
|
+
newText: `, ${t}`
|
|
15619
|
+
};
|
|
15620
|
+
}
|
|
15621
|
+
if (e instanceof P) {
|
|
15622
|
+
let n = e.body;
|
|
15623
|
+
if (n && !(n instanceof R)) return {
|
|
15624
|
+
start: n.start,
|
|
15625
|
+
end: n.start,
|
|
15626
|
+
newText: `[${t}] `
|
|
15627
|
+
};
|
|
15628
|
+
}
|
|
15629
|
+
return {
|
|
15630
|
+
start: e.end,
|
|
15631
|
+
end: e.end,
|
|
15632
|
+
newText: ` [${t}]`
|
|
15633
|
+
};
|
|
15634
|
+
}
|
|
15635
|
+
function dx(e, t, n, r) {
|
|
15636
|
+
if (n === null) return fx(e, t, r);
|
|
15637
|
+
let i = n === void 0 ? t : `${t}: ${n}`, a = hx(e, t);
|
|
15638
|
+
if (a) return {
|
|
15639
|
+
start: a.settingNode.start,
|
|
15640
|
+
end: a.settingNode.end,
|
|
15641
|
+
newText: i
|
|
15642
|
+
};
|
|
15643
|
+
let o = gx(e, t);
|
|
15644
|
+
return o ? {
|
|
15645
|
+
start: o.start,
|
|
15646
|
+
end: o.end,
|
|
15647
|
+
newText: i
|
|
15648
|
+
} : ux(e, i);
|
|
15649
|
+
}
|
|
15650
|
+
function fx(e, t, n) {
|
|
15651
|
+
let r = hx(e, t);
|
|
15652
|
+
if (r) {
|
|
15653
|
+
let { settingsList: e, settingIndex: t } = r, i = e.elementList ?? [];
|
|
15654
|
+
if (i.length === 1) {
|
|
15655
|
+
let t = e.start;
|
|
15656
|
+
for (; t > 0 && n[t - 1] === " ";) t--;
|
|
15657
|
+
return {
|
|
15658
|
+
start: t,
|
|
15659
|
+
end: e.end,
|
|
15660
|
+
newText: ""
|
|
15661
|
+
};
|
|
15662
|
+
}
|
|
15663
|
+
let a = i[t];
|
|
15664
|
+
if (t === 0) {
|
|
15665
|
+
let e = i[t + 1];
|
|
15666
|
+
return {
|
|
15667
|
+
start: a.start,
|
|
15668
|
+
end: e.start,
|
|
15669
|
+
newText: ""
|
|
15670
|
+
};
|
|
15671
|
+
}
|
|
15672
|
+
return {
|
|
15673
|
+
start: i[t - 1].end,
|
|
15674
|
+
end: a.end,
|
|
15675
|
+
newText: ""
|
|
15676
|
+
};
|
|
15677
|
+
}
|
|
15678
|
+
let i = gx(e, t);
|
|
15679
|
+
if (i) return {
|
|
15680
|
+
start: i.start,
|
|
15681
|
+
end: i.end,
|
|
15682
|
+
newText: ""
|
|
15683
|
+
};
|
|
15684
|
+
}
|
|
15685
|
+
function px(e) {
|
|
15686
|
+
if (e instanceof R) return e.args.find((e) => e instanceof B);
|
|
15687
|
+
if (e instanceof P) {
|
|
15688
|
+
if (e.attributeList) return e.attributeList;
|
|
15689
|
+
let t = e.body;
|
|
15690
|
+
if (t instanceof R) return t.args.find((e) => e instanceof B);
|
|
15691
|
+
}
|
|
15692
|
+
}
|
|
15693
|
+
function mx(e) {
|
|
15694
|
+
if (e.name instanceof Zs) return os(e.name)?.toLowerCase();
|
|
15695
|
+
}
|
|
15696
|
+
function hx(e, t) {
|
|
15697
|
+
let n = px(e);
|
|
15698
|
+
if (!n) return;
|
|
15699
|
+
let r = t.toLowerCase(), i = n.elementList ?? [], a = i.findIndex((e) => e instanceof F ? mx(e) === r : !1);
|
|
15700
|
+
if (a !== -1) return {
|
|
15701
|
+
settingsList: n,
|
|
15702
|
+
settingNode: i[a],
|
|
15703
|
+
settingIndex: a
|
|
15704
|
+
};
|
|
15705
|
+
}
|
|
15706
|
+
function gx(e, t) {
|
|
15707
|
+
if (!(e instanceof P)) return;
|
|
15708
|
+
let n = e.body;
|
|
15709
|
+
if (!(!n || n instanceof R)) {
|
|
15710
|
+
for (let e of n.body) if (e instanceof P && e.type?.value?.toLowerCase() === t.toLowerCase() && e.body instanceof R && e.body.callee) return e;
|
|
15711
|
+
}
|
|
15712
|
+
}
|
|
15713
|
+
//#endregion
|
|
15714
|
+
//#region src/compiler/queries/transform/updateElementSetting.ts
|
|
15715
|
+
function _x(e, t, n, r) {
|
|
15716
|
+
let i = this.getSource(e) ?? "", a = t.kind, o = ("schema" in t ? t.schema : void 0) ?? "public", s = "table" in t ? t.table : "name" in t ? t.name : "", c = $b(this, e, o, s, a);
|
|
15717
|
+
if (!c?.declaration) return i;
|
|
15718
|
+
let l = dx(c.declaration, n, r, i);
|
|
15719
|
+
return l ? Zb(i, [l]) : i;
|
|
15720
|
+
}
|
|
15721
|
+
//#endregion
|
|
15610
15722
|
//#region src/compiler/queries/transform/syncDiagramView.ts
|
|
15611
|
-
function
|
|
15723
|
+
function vx(e) {
|
|
15612
15724
|
let t = [], n = new Ab(e, Eo).lex();
|
|
15613
15725
|
if (n.getErrors().length > 0) return t;
|
|
15614
15726
|
let i = new Pb(e, n.getValue(), new Ks(), Eo).parse();
|
|
@@ -15624,36 +15736,36 @@ function ux(e) {
|
|
|
15624
15736
|
}
|
|
15625
15737
|
return t;
|
|
15626
15738
|
}
|
|
15627
|
-
function
|
|
15739
|
+
function yx(e, t, n) {
|
|
15628
15740
|
e.push(` ${t} {`), n.forEach((t) => e.push(` ${t}`)), e.push(" }");
|
|
15629
15741
|
}
|
|
15630
|
-
function
|
|
15742
|
+
function bx(e, t) {
|
|
15631
15743
|
e.push(` ${t} { * }`);
|
|
15632
15744
|
}
|
|
15633
|
-
function
|
|
15745
|
+
function xx(e) {
|
|
15634
15746
|
return e == null ? "null" : e.length === 0 ? "empty" : "items";
|
|
15635
15747
|
}
|
|
15636
|
-
function
|
|
15748
|
+
function Sx(e, t) {
|
|
15637
15749
|
let n = `DiagramView ${gg(e)} {`, r = (e) => gg(e.name), i = t?.tables?.map((e) => {
|
|
15638
15750
|
let t = gg(e.name);
|
|
15639
15751
|
return e.schemaName === "public" ? t : `${gg(e.schemaName)}.${t}`;
|
|
15640
15752
|
}) ?? [], a = t?.tableGroups?.map(r) ?? [], o = t?.schemas?.map(r) ?? [], s = t?.stickyNotes?.map(r) ?? [];
|
|
15641
15753
|
if (!t) return `${n}\n}`;
|
|
15642
15754
|
let c = {
|
|
15643
|
-
tables:
|
|
15644
|
-
tableGroups:
|
|
15645
|
-
schemas:
|
|
15646
|
-
stickyNotes:
|
|
15755
|
+
tables: xx(t.tables),
|
|
15756
|
+
tableGroups: xx(t.tableGroups),
|
|
15757
|
+
schemas: xx(t.schemas),
|
|
15758
|
+
stickyNotes: xx(t.stickyNotes)
|
|
15647
15759
|
};
|
|
15648
15760
|
if (Object.values(c).every((e) => e === "null")) return `${n}\n}`;
|
|
15649
15761
|
if (Object.values(c).every((e) => e === "empty")) return `${n}\n *\n}`;
|
|
15650
15762
|
let l = c.tables === "items" || c.tableGroups === "items" || c.schemas === "items", u = c.tables === "empty" && c.tableGroups === "empty" && c.schemas === "empty", d = [n];
|
|
15651
|
-
return l ? (c.tables === "items" &&
|
|
15763
|
+
return l ? (c.tables === "items" && yx(d, "Tables", i), c.tableGroups === "items" && yx(d, "TableGroups", a), c.schemas === "items" && yx(d, "Schemas", o)) : u && bx(d, "Tables"), c.stickyNotes === "items" ? yx(d, "Notes", s) : c.stickyNotes === "empty" && bx(d, "Notes"), d.push("}"), d.join("\n");
|
|
15652
15764
|
}
|
|
15653
|
-
function
|
|
15654
|
-
let r = this.getSource(e) ?? "", i = n ??
|
|
15765
|
+
function Cx(e, t, n) {
|
|
15766
|
+
let r = this.getSource(e) ?? "", i = n ?? vx(r), a = [];
|
|
15655
15767
|
for (let e of t) {
|
|
15656
|
-
let t =
|
|
15768
|
+
let t = wx(r, e, i);
|
|
15657
15769
|
a.push(...t);
|
|
15658
15770
|
}
|
|
15659
15771
|
return a.sort((e, t) => t.start - e.start), {
|
|
@@ -15661,29 +15773,29 @@ function hx(e, t, n) {
|
|
|
15661
15773
|
edits: a
|
|
15662
15774
|
};
|
|
15663
15775
|
}
|
|
15664
|
-
function
|
|
15776
|
+
function wx(e, t, n) {
|
|
15665
15777
|
switch (t.operation) {
|
|
15666
|
-
case "create": return
|
|
15667
|
-
case "update": return
|
|
15668
|
-
case "delete": return
|
|
15778
|
+
case "create": return Tx(e, t, n);
|
|
15779
|
+
case "update": return Ex(e, t, n);
|
|
15780
|
+
case "delete": return Dx(e, t, n);
|
|
15669
15781
|
default: return [];
|
|
15670
15782
|
}
|
|
15671
15783
|
}
|
|
15672
|
-
function
|
|
15673
|
-
if (n.find((e) => e.name === t.name)) return
|
|
15674
|
-
let r = "\n\n" +
|
|
15784
|
+
function Tx(e, t, n) {
|
|
15785
|
+
if (n.find((e) => e.name === t.name)) return Ex(e, t, n);
|
|
15786
|
+
let r = "\n\n" + Sx(t.name, t.visibleEntities) + "\n";
|
|
15675
15787
|
return [{
|
|
15676
15788
|
start: e.length,
|
|
15677
15789
|
end: e.length,
|
|
15678
15790
|
newText: r
|
|
15679
15791
|
}];
|
|
15680
15792
|
}
|
|
15681
|
-
function
|
|
15793
|
+
function Ex(e, t, n) {
|
|
15682
15794
|
let r = n.find((e) => e.name === t.name);
|
|
15683
15795
|
if (!r) return [];
|
|
15684
15796
|
let i = [];
|
|
15685
15797
|
if (t.newName || t.visibleEntities) {
|
|
15686
|
-
let e =
|
|
15798
|
+
let e = Sx(t.newName || t.name, t.visibleEntities);
|
|
15687
15799
|
i.push({
|
|
15688
15800
|
start: r.startIndex,
|
|
15689
15801
|
end: r.endIndex,
|
|
@@ -15692,7 +15804,7 @@ function vx(e, t, n) {
|
|
|
15692
15804
|
}
|
|
15693
15805
|
return i;
|
|
15694
15806
|
}
|
|
15695
|
-
function
|
|
15807
|
+
function Dx(e, t, n) {
|
|
15696
15808
|
let r = n.find((e) => e.name === t.name);
|
|
15697
15809
|
if (!r) return [];
|
|
15698
15810
|
let i = r.startIndex, a = r.endIndex;
|
|
@@ -15712,25 +15824,25 @@ function yx(e, t, n) {
|
|
|
15712
15824
|
}
|
|
15713
15825
|
//#endregion
|
|
15714
15826
|
//#region src/core/utils/note.ts
|
|
15715
|
-
function
|
|
15716
|
-
let n =
|
|
15827
|
+
function Ox(e, t) {
|
|
15828
|
+
let n = jx(e);
|
|
15717
15829
|
if (n) return {
|
|
15718
15830
|
start: n.noteValueStart,
|
|
15719
15831
|
end: n.noteValueEnd,
|
|
15720
15832
|
newText: Cg(t)
|
|
15721
15833
|
};
|
|
15722
15834
|
}
|
|
15723
|
-
function
|
|
15724
|
-
let t =
|
|
15835
|
+
function kx(e) {
|
|
15836
|
+
let t = jx(e);
|
|
15725
15837
|
if (t) return {
|
|
15726
15838
|
start: t.fullNoteStart,
|
|
15727
15839
|
end: t.fullNoteEnd,
|
|
15728
15840
|
newText: ""
|
|
15729
15841
|
};
|
|
15730
15842
|
}
|
|
15731
|
-
function
|
|
15732
|
-
if (
|
|
15733
|
-
let n =
|
|
15843
|
+
function Ax(e, t) {
|
|
15844
|
+
if (jx(e) || !(e instanceof P)) return;
|
|
15845
|
+
let n = Mx(e);
|
|
15734
15846
|
if (n !== void 0) return {
|
|
15735
15847
|
start: n,
|
|
15736
15848
|
end: n,
|
|
@@ -15754,12 +15866,12 @@ function Sx(e, t) {
|
|
|
15754
15866
|
};
|
|
15755
15867
|
}
|
|
15756
15868
|
}
|
|
15757
|
-
function
|
|
15869
|
+
function jx(e) {
|
|
15758
15870
|
if (!(e instanceof P)) return;
|
|
15759
15871
|
let t = e.body;
|
|
15760
15872
|
if (t && !(t instanceof R)) for (let e of t.body) {
|
|
15761
15873
|
if (!(e instanceof P) || !e.isKind(r.Note)) continue;
|
|
15762
|
-
let t =
|
|
15874
|
+
let t = Nx(e);
|
|
15763
15875
|
if (t) return {
|
|
15764
15876
|
kind: qs.ELEMENT_DECLARATION,
|
|
15765
15877
|
noteValueStart: t.start,
|
|
@@ -15769,18 +15881,18 @@ function Cx(e) {
|
|
|
15769
15881
|
};
|
|
15770
15882
|
}
|
|
15771
15883
|
let n = e.attributeList ?? (t instanceof R ? t.args.find((e) => e instanceof B) : void 0);
|
|
15772
|
-
if (n) return
|
|
15884
|
+
if (n) return Px(n);
|
|
15773
15885
|
}
|
|
15774
|
-
function
|
|
15886
|
+
function Mx(e) {
|
|
15775
15887
|
let t = e.body;
|
|
15776
15888
|
if (!(!t || t instanceof R) && t.blockCloseBrace) return t.blockCloseBrace.start;
|
|
15777
15889
|
}
|
|
15778
|
-
function
|
|
15890
|
+
function Nx(e) {
|
|
15779
15891
|
let t = e.body;
|
|
15780
15892
|
if (t instanceof R) return t.callee ?? void 0;
|
|
15781
15893
|
if (t instanceof z && t.body[0] instanceof R) return t.body[0].callee ?? void 0;
|
|
15782
15894
|
}
|
|
15783
|
-
function
|
|
15895
|
+
function Px(e) {
|
|
15784
15896
|
let t = x(e).getValue()[i.Note];
|
|
15785
15897
|
if (!t?.length) return;
|
|
15786
15898
|
let n = t[0];
|
|
@@ -15795,111 +15907,8 @@ function Ex(e) {
|
|
|
15795
15907
|
};
|
|
15796
15908
|
}
|
|
15797
15909
|
//#endregion
|
|
15798
|
-
//#region src/core/utils/setting.ts
|
|
15799
|
-
function Dx(e, t) {
|
|
15800
|
-
let n = Ax(e);
|
|
15801
|
-
if (n) {
|
|
15802
|
-
let e = n.end - 1;
|
|
15803
|
-
return {
|
|
15804
|
-
start: e,
|
|
15805
|
-
end: e,
|
|
15806
|
-
newText: `, ${t}`
|
|
15807
|
-
};
|
|
15808
|
-
}
|
|
15809
|
-
if (e instanceof P) {
|
|
15810
|
-
let n = e.body;
|
|
15811
|
-
if (n && !(n instanceof R)) return {
|
|
15812
|
-
start: n.start,
|
|
15813
|
-
end: n.start,
|
|
15814
|
-
newText: `[${t}] `
|
|
15815
|
-
};
|
|
15816
|
-
}
|
|
15817
|
-
return {
|
|
15818
|
-
start: e.end,
|
|
15819
|
-
end: e.end,
|
|
15820
|
-
newText: ` [${t}]`
|
|
15821
|
-
};
|
|
15822
|
-
}
|
|
15823
|
-
function Ox(e, t, n, r) {
|
|
15824
|
-
let i = Mx(e, t);
|
|
15825
|
-
if (i) return {
|
|
15826
|
-
start: i.settingNode.start,
|
|
15827
|
-
end: i.settingNode.end,
|
|
15828
|
-
newText: n
|
|
15829
|
-
};
|
|
15830
|
-
let a = Nx(e, t);
|
|
15831
|
-
if (a) return {
|
|
15832
|
-
start: a.start,
|
|
15833
|
-
end: a.end,
|
|
15834
|
-
newText: n
|
|
15835
|
-
};
|
|
15836
|
-
}
|
|
15837
|
-
function kx(e, t, n) {
|
|
15838
|
-
let r = Mx(e, t);
|
|
15839
|
-
if (r) {
|
|
15840
|
-
let { settingsList: e, settingIndex: t } = r, i = e.elementList ?? [];
|
|
15841
|
-
if (i.length === 1) {
|
|
15842
|
-
let t = e.start;
|
|
15843
|
-
for (; t > 0 && n[t - 1] === " ";) t--;
|
|
15844
|
-
return {
|
|
15845
|
-
start: t,
|
|
15846
|
-
end: e.end,
|
|
15847
|
-
newText: ""
|
|
15848
|
-
};
|
|
15849
|
-
}
|
|
15850
|
-
let a = i[t];
|
|
15851
|
-
if (t === 0) {
|
|
15852
|
-
let e = i[t + 1];
|
|
15853
|
-
return {
|
|
15854
|
-
start: a.start,
|
|
15855
|
-
end: e.start,
|
|
15856
|
-
newText: ""
|
|
15857
|
-
};
|
|
15858
|
-
}
|
|
15859
|
-
return {
|
|
15860
|
-
start: i[t - 1].end,
|
|
15861
|
-
end: a.end,
|
|
15862
|
-
newText: ""
|
|
15863
|
-
};
|
|
15864
|
-
}
|
|
15865
|
-
let i = Nx(e, t);
|
|
15866
|
-
if (i) return {
|
|
15867
|
-
start: i.start,
|
|
15868
|
-
end: i.end,
|
|
15869
|
-
newText: ""
|
|
15870
|
-
};
|
|
15871
|
-
}
|
|
15872
|
-
function Ax(e) {
|
|
15873
|
-
if (e instanceof R) return e.args.find((e) => e instanceof B);
|
|
15874
|
-
if (e instanceof P) {
|
|
15875
|
-
if (e.attributeList) return e.attributeList;
|
|
15876
|
-
let t = e.body;
|
|
15877
|
-
if (t instanceof R) return t.args.find((e) => e instanceof B);
|
|
15878
|
-
}
|
|
15879
|
-
}
|
|
15880
|
-
function jx(e) {
|
|
15881
|
-
if (e.name instanceof Zs) return os(e.name)?.toLowerCase();
|
|
15882
|
-
}
|
|
15883
|
-
function Mx(e, t) {
|
|
15884
|
-
let n = Ax(e);
|
|
15885
|
-
if (!n) return;
|
|
15886
|
-
let r = t.toLowerCase(), i = n.elementList ?? [], a = i.findIndex((e) => e instanceof F ? jx(e) === r : !1);
|
|
15887
|
-
if (a !== -1) return {
|
|
15888
|
-
settingsList: n,
|
|
15889
|
-
settingNode: i[a],
|
|
15890
|
-
settingIndex: a
|
|
15891
|
-
};
|
|
15892
|
-
}
|
|
15893
|
-
function Nx(e, t) {
|
|
15894
|
-
if (!(e instanceof P)) return;
|
|
15895
|
-
let n = e.body;
|
|
15896
|
-
if (!(!n || n instanceof R)) {
|
|
15897
|
-
for (let e of n.body) if (e instanceof P && e.type?.value?.toLowerCase() === t.toLowerCase() && e.body instanceof R && e.body.callee) return e;
|
|
15898
|
-
}
|
|
15899
|
-
}
|
|
15900
|
-
//#endregion
|
|
15901
15910
|
//#region src/compiler/queries/transform/syncDep.ts
|
|
15902
|
-
function
|
|
15911
|
+
function Fx(e) {
|
|
15903
15912
|
let t = [], n = new Ab(e, Eo).lex();
|
|
15904
15913
|
if (n.getErrors().length > 0) return t;
|
|
15905
15914
|
let i = new Pb(e, n.getValue(), new Ks(), Eo).parse();
|
|
@@ -15910,12 +15919,12 @@ function Px(e) {
|
|
|
15910
15919
|
let n = [], i = e.body;
|
|
15911
15920
|
if (i instanceof R) {
|
|
15912
15921
|
if (i.callee instanceof L) {
|
|
15913
|
-
let e =
|
|
15922
|
+
let e = Wx(i.callee);
|
|
15914
15923
|
e && n.push(e);
|
|
15915
15924
|
}
|
|
15916
15925
|
} else if (i) {
|
|
15917
15926
|
for (let e of i.body) if (e instanceof R && e.callee instanceof L) {
|
|
15918
|
-
let t =
|
|
15927
|
+
let t = Wx(e.callee);
|
|
15919
15928
|
t && n.push(t);
|
|
15920
15929
|
}
|
|
15921
15930
|
}
|
|
@@ -15928,7 +15937,7 @@ function Px(e) {
|
|
|
15928
15937
|
}
|
|
15929
15938
|
return t;
|
|
15930
15939
|
}
|
|
15931
|
-
function
|
|
15940
|
+
function Ix(e) {
|
|
15932
15941
|
let t = [], n = new Ab(e, Eo).lex();
|
|
15933
15942
|
if (n.getErrors().length > 0) return t;
|
|
15934
15943
|
let a = new Pb(e, n.getValue(), new Ks(), Eo).parse();
|
|
@@ -15947,8 +15956,8 @@ function Fx(e) {
|
|
|
15947
15956
|
schemaName: s,
|
|
15948
15957
|
tableName: o,
|
|
15949
15958
|
fieldNames: [r]
|
|
15950
|
-
}, c =
|
|
15951
|
-
if (c) for (let e of
|
|
15959
|
+
}, c = fx(n, i.Dep, e);
|
|
15960
|
+
if (c) for (let e of Zx(n, a)) t.push({
|
|
15952
15961
|
edge: e,
|
|
15953
15962
|
stripStart: c.start,
|
|
15954
15963
|
stripEnd: c.end
|
|
@@ -15957,21 +15966,21 @@ function Fx(e) {
|
|
|
15957
15966
|
}
|
|
15958
15967
|
return t;
|
|
15959
15968
|
}
|
|
15960
|
-
function
|
|
15961
|
-
return `Dep [color: ${t}] {\n ${
|
|
15969
|
+
function Lx(e, t) {
|
|
15970
|
+
return `Dep [color: ${t}] {\n ${Kx(e.upstream)} -> ${Kx(e.downstream)}\n}`;
|
|
15962
15971
|
}
|
|
15963
|
-
function
|
|
15964
|
-
let r = this.getSource(e) ?? "", i = n ??
|
|
15965
|
-
for (let e of t) o.push(...
|
|
15972
|
+
function Rx(e, t, n) {
|
|
15973
|
+
let r = this.getSource(e) ?? "", i = n ?? Fx(r), a = Ix(r), o = [];
|
|
15974
|
+
for (let e of t) o.push(...Qx(r, e, i, a));
|
|
15966
15975
|
return o.sort((e, t) => t.start - e.start), {
|
|
15967
15976
|
newDbml: Zb(r, o, !0),
|
|
15968
15977
|
edits: o
|
|
15969
15978
|
};
|
|
15970
15979
|
}
|
|
15971
|
-
function
|
|
15980
|
+
function zx(e) {
|
|
15972
15981
|
return e && e.length > 0 ? e : v;
|
|
15973
15982
|
}
|
|
15974
|
-
function
|
|
15983
|
+
function Bx(e, t) {
|
|
15975
15984
|
if (e.length === 0) return;
|
|
15976
15985
|
if (!t) {
|
|
15977
15986
|
let t = e[e.length - 1];
|
|
@@ -15988,94 +15997,91 @@ function zx(e, t) {
|
|
|
15988
15997
|
fieldNames: n
|
|
15989
15998
|
};
|
|
15990
15999
|
}
|
|
15991
|
-
function
|
|
15992
|
-
if (
|
|
16000
|
+
function Vx(e, t) {
|
|
16001
|
+
if (zx(e.schemaName) !== zx(t.schemaName) || e.tableName !== t.tableName) return !1;
|
|
15993
16002
|
let n = e.fieldNames ?? [], r = t.fieldNames ?? [];
|
|
15994
16003
|
return n.length === r.length ? n.every((e, t) => e === r[t]) : !1;
|
|
15995
16004
|
}
|
|
15996
|
-
function Vx(e, t) {
|
|
15997
|
-
return Bx(e.upstream, t.upstream) && Bx(e.downstream, t.downstream);
|
|
15998
|
-
}
|
|
15999
16005
|
function Hx(e, t) {
|
|
16000
|
-
return e.
|
|
16006
|
+
return Vx(e.upstream, t.upstream) && Vx(e.downstream, t.downstream);
|
|
16007
|
+
}
|
|
16008
|
+
function Ux(e, t) {
|
|
16009
|
+
return e.edges.some((e) => Hx(e, t));
|
|
16001
16010
|
}
|
|
16002
|
-
function
|
|
16011
|
+
function Wx(e) {
|
|
16003
16012
|
let t = e.op?.value;
|
|
16004
16013
|
if (t !== "->" && t !== "<-") return;
|
|
16005
16014
|
let n = e.leftExpression, r = e.rightExpression;
|
|
16006
16015
|
if (!n || !r) return;
|
|
16007
16016
|
let i = t === "<-" ? r : n, a = t === "<-" ? n : r, o = D(i), s = D(a);
|
|
16008
16017
|
if (!o || !s) return;
|
|
16009
|
-
let c = o.length > 1 && s.length > 1, l =
|
|
16018
|
+
let c = o.length > 1 && s.length > 1, l = Bx(o, c), u = Bx(s, c);
|
|
16010
16019
|
if (!(!l || !u)) return {
|
|
16011
16020
|
upstream: l,
|
|
16012
16021
|
downstream: u
|
|
16013
16022
|
};
|
|
16014
16023
|
}
|
|
16015
|
-
function
|
|
16024
|
+
function Gx(e) {
|
|
16016
16025
|
if (e.name instanceof Zs) return os(e.name)?.toLowerCase();
|
|
16017
16026
|
}
|
|
16018
|
-
function
|
|
16019
|
-
let t =
|
|
16027
|
+
function Kx(e) {
|
|
16028
|
+
let t = zx(e.schemaName), n = [];
|
|
16020
16029
|
t !== "public" && n.push(gg(t)), n.push(gg(e.tableName));
|
|
16021
16030
|
for (let t of e.fieldNames ?? []) n.push(gg(t));
|
|
16022
16031
|
return n.join(".");
|
|
16023
16032
|
}
|
|
16024
|
-
function
|
|
16025
|
-
return e.find((e) =>
|
|
16033
|
+
function qx(e, t) {
|
|
16034
|
+
return e.find((e) => Ux(e, t));
|
|
16026
16035
|
}
|
|
16027
|
-
function
|
|
16036
|
+
function Jx(e, t, n) {
|
|
16028
16037
|
let r = [];
|
|
16029
|
-
if (e.color
|
|
16030
|
-
let
|
|
16031
|
-
e && r.push(e);
|
|
16032
|
-
} else if (e.color !== void 0) {
|
|
16033
|
-
let a = Ox(t.declaration, i.Color, `${i.Color}: ${e.color}`, n) ?? Dx(t.declaration, `${i.Color}: ${e.color}`);
|
|
16038
|
+
if (e.color !== void 0) {
|
|
16039
|
+
let a = dx(t.declaration, i.Color, e.color, n);
|
|
16034
16040
|
a && r.push(a);
|
|
16035
16041
|
}
|
|
16036
16042
|
if (e.note === null) {
|
|
16037
|
-
let e =
|
|
16043
|
+
let e = kx(t.declaration);
|
|
16038
16044
|
e && r.push(e);
|
|
16039
16045
|
} else if (e.note !== void 0) {
|
|
16040
|
-
let n =
|
|
16046
|
+
let n = Ox(t.declaration, e.note) ?? Ax(t.declaration, e.note);
|
|
16041
16047
|
n && r.push(n);
|
|
16042
16048
|
}
|
|
16043
16049
|
return r;
|
|
16044
16050
|
}
|
|
16045
|
-
function
|
|
16046
|
-
let i =
|
|
16047
|
-
if (i) return
|
|
16048
|
-
let a =
|
|
16051
|
+
function Yx(e, t, n, r) {
|
|
16052
|
+
let i = qx(n, t.edge);
|
|
16053
|
+
if (i) return Jx(t, i, e);
|
|
16054
|
+
let a = Lx(t.edge, t.color ?? ""), o = {
|
|
16049
16055
|
start: e.length,
|
|
16050
16056
|
end: e.length,
|
|
16051
16057
|
newText: "\n\n" + a + "\n"
|
|
16052
|
-
}, s = r.find((e) =>
|
|
16058
|
+
}, s = r.find((e) => Hx(e.edge, t.edge));
|
|
16053
16059
|
return s ? [{
|
|
16054
16060
|
start: s.stripStart,
|
|
16055
16061
|
end: s.stripEnd,
|
|
16056
16062
|
newText: ""
|
|
16057
16063
|
}, o] : [o];
|
|
16058
16064
|
}
|
|
16059
|
-
function
|
|
16065
|
+
function Xx(e, t, n) {
|
|
16060
16066
|
let r = e.color === void 0 && e.note === void 0;
|
|
16061
|
-
return
|
|
16067
|
+
return Jx({
|
|
16062
16068
|
...e,
|
|
16063
16069
|
color: r ? null : e.color
|
|
16064
16070
|
}, t, n);
|
|
16065
16071
|
}
|
|
16066
|
-
function
|
|
16072
|
+
function Zx(e, t) {
|
|
16067
16073
|
let n = e.args.find((e) => e instanceof B);
|
|
16068
16074
|
if (!n) return [];
|
|
16069
16075
|
let r = [];
|
|
16070
16076
|
for (let e of n.elementList) {
|
|
16071
|
-
if (
|
|
16077
|
+
if (Gx(e) !== i.Dep) continue;
|
|
16072
16078
|
let n = e.value;
|
|
16073
16079
|
if (!(n instanceof I) || !n.expression) continue;
|
|
16074
16080
|
let a = n.op?.value;
|
|
16075
16081
|
if (a !== "->" && a !== "<-") continue;
|
|
16076
16082
|
let o = D(n.expression);
|
|
16077
16083
|
if (!o) continue;
|
|
16078
|
-
let s =
|
|
16084
|
+
let s = Bx(o, o.length > 1);
|
|
16079
16085
|
s && r.push(a === "->" ? {
|
|
16080
16086
|
upstream: t,
|
|
16081
16087
|
downstream: s
|
|
@@ -16086,25 +16092,25 @@ function Xx(e, t) {
|
|
|
16086
16092
|
}
|
|
16087
16093
|
return r;
|
|
16088
16094
|
}
|
|
16089
|
-
function
|
|
16095
|
+
function Qx(e, t, n, r) {
|
|
16090
16096
|
switch (t.operation) {
|
|
16091
|
-
case "create": return
|
|
16097
|
+
case "create": return Yx(e, t, n, r);
|
|
16092
16098
|
case "update": {
|
|
16093
|
-
let r =
|
|
16094
|
-
return r ?
|
|
16099
|
+
let r = qx(n, t.edge);
|
|
16100
|
+
return r ? Jx(t, r, e) : [];
|
|
16095
16101
|
}
|
|
16096
16102
|
case "remove": {
|
|
16097
|
-
let r =
|
|
16098
|
-
return r ?
|
|
16103
|
+
let r = qx(n, t.edge);
|
|
16104
|
+
return r ? Xx(t, r, e) : [];
|
|
16099
16105
|
}
|
|
16100
16106
|
default: return [];
|
|
16101
16107
|
}
|
|
16102
16108
|
}
|
|
16103
16109
|
//#endregion
|
|
16104
16110
|
//#region src/compiler/index.ts
|
|
16105
|
-
var
|
|
16111
|
+
var $x = Symbol("COMPUTING"), eS = class {
|
|
16106
16112
|
constructor(e) {
|
|
16107
|
-
this.layout = e, this.nodeIdGenerator = new Ks(), this.symbolIdGenerator = new ws(), this.symbolFactory = new eo(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.globallyQuerying = !1, this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(Vb), this.parseProject = this.globalQuery(Hb), this.validateNode = this.localQuery(H_), this.validateFile = this.localQuery(kb), this.nodeFullname = this.localQuery(W_), this.nodeAlias = this.localQuery(G_), this.nodeSettings = this.localQuery(U_), this.canonicalName = this.globalQuery(ub), this.bindNode = this.globalQuery(Qg), this.bindFile = this.globalQuery(Tb), this.bindProject = this.globalQuery(Eb), this.interpretSymbol = this.globalQuery(e_), this.interpretMetadata = this.globalQuery(t_), this.interpretFile = this.globalQuery(Db), this.interpretProject = this.globalQuery(Ob), this.nodeSymbol = this.globalQuery(Yg), this.nodeMetadata = this.globalQuery($g), this.symbolMembers = this.globalQuery(Xg), this.symbolMembersLookupMap = this.globalQuery(Ub), this.lookupMembers = this.globalQuery(Wb), this.nodeReferee = this.globalQuery(Zg), this.resolutionIndex = this.globalQuery(Kb), this.symbolReferences = this.globalQuery(Jb), this.symbolParent = this.globalQuery(qb), this.symbolMetadata = this.globalQuery(Yb), this.symbolAliases = this.globalQuery(Gb), this.symbolUses = this.globalQuery(Xb), this.fileDependencies = this.localQuery(pb), this.reachableFiles = this.globalQuery(hb), this.usableMembers = this.globalQuery(Zh), this.nodeAtPosition = this.localQuery(wb), this.renameTable = sx.bind(this), this.syncDiagramView =
|
|
16113
|
+
this.layout = e, this.nodeIdGenerator = new Ks(), this.symbolIdGenerator = new ws(), this.symbolFactory = new eo(this.symbolIdGenerator), this.sourceSnapshot = /* @__PURE__ */ new Map(), this.globalCache = /* @__PURE__ */ new Map(), this.globallyQuerying = !1, this.localCache = /* @__PURE__ */ new Map(), this.parseFile = this.localQuery(Vb), this.parseProject = this.globalQuery(Hb), this.validateNode = this.localQuery(H_), this.validateFile = this.localQuery(kb), this.nodeFullname = this.localQuery(W_), this.nodeAlias = this.localQuery(G_), this.nodeSettings = this.localQuery(U_), this.canonicalName = this.globalQuery(ub), this.bindNode = this.globalQuery(Qg), this.bindFile = this.globalQuery(Tb), this.bindProject = this.globalQuery(Eb), this.interpretSymbol = this.globalQuery(e_), this.interpretMetadata = this.globalQuery(t_), this.interpretFile = this.globalQuery(Db), this.interpretProject = this.globalQuery(Ob), this.nodeSymbol = this.globalQuery(Yg), this.nodeMetadata = this.globalQuery($g), this.symbolMembers = this.globalQuery(Xg), this.symbolMembersLookupMap = this.globalQuery(Ub), this.lookupMembers = this.globalQuery(Wb), this.nodeReferee = this.globalQuery(Zg), this.resolutionIndex = this.globalQuery(Kb), this.symbolReferences = this.globalQuery(Jb), this.symbolParent = this.globalQuery(qb), this.symbolMetadata = this.globalQuery(Yb), this.symbolAliases = this.globalQuery(Gb), this.symbolUses = this.globalQuery(Xb), this.fileDependencies = this.localQuery(pb), this.reachableFiles = this.globalQuery(hb), this.usableMembers = this.globalQuery(Zh), this.nodeAtPosition = this.localQuery(wb), this.renameTable = sx.bind(this), this.updateElementSetting = _x.bind(this), this.syncDiagramView = Cx.bind(this), this.syncDep = Rx.bind(this), this.token = {
|
|
16108
16114
|
invalidStream: this.localQuery(Cb),
|
|
16109
16115
|
flatStream: this.localQuery(Sb)
|
|
16110
16116
|
}, this.parse = {
|
|
@@ -16146,10 +16152,10 @@ var Qx = Symbol("COMPUTING"), $x = class {
|
|
|
16146
16152
|
r || (r = /* @__PURE__ */ new Map(), this.globalCache.set(t, r));
|
|
16147
16153
|
let i = n.length === 0 ? "" : n.length === 1 ? Ec(n[0]) : n.map((e) => Ec(e)).join("\0"), a = r.get(i);
|
|
16148
16154
|
if (a) {
|
|
16149
|
-
if (a ===
|
|
16155
|
+
if (a === $x) throw Error(`Cycle detected in query: ${e.name}(${i})`);
|
|
16150
16156
|
return a;
|
|
16151
16157
|
}
|
|
16152
|
-
r.set(i,
|
|
16158
|
+
r.set(i, $x);
|
|
16153
16159
|
try {
|
|
16154
16160
|
let t = e.apply(this, n);
|
|
16155
16161
|
return r.set(i, t), t;
|
|
@@ -16171,10 +16177,10 @@ var Qx = Symbol("COMPUTING"), $x = class {
|
|
|
16171
16177
|
let c = s.get(t);
|
|
16172
16178
|
if (c || (c = /* @__PURE__ */ new Map(), s.set(t, c)), c.has(o)) {
|
|
16173
16179
|
let t = c.get(o);
|
|
16174
|
-
if (t ===
|
|
16180
|
+
if (t === $x) throw Error(`Cycle detected in query: ${e.name}(${a}, ${o})`);
|
|
16175
16181
|
return t;
|
|
16176
16182
|
}
|
|
16177
|
-
c.set(o,
|
|
16183
|
+
c.set(o, $x);
|
|
16178
16184
|
try {
|
|
16179
16185
|
let t = e.apply(this, n);
|
|
16180
16186
|
return c.set(o, t), t;
|
|
@@ -16183,12 +16189,6 @@ var Qx = Symbol("COMPUTING"), $x = class {
|
|
|
16183
16189
|
}
|
|
16184
16190
|
});
|
|
16185
16191
|
}
|
|
16186
|
-
findDiagramViewBlocks(e) {
|
|
16187
|
-
return ux(this.getSource(e) ?? "");
|
|
16188
|
-
}
|
|
16189
|
-
findDepBlocks(e) {
|
|
16190
|
-
return Px(this.getSource(e) ?? "");
|
|
16191
|
-
}
|
|
16192
16192
|
initMonacoServices(e) {
|
|
16193
16193
|
let t = e?.autocompletion?.triggerCharacters ?? [];
|
|
16194
16194
|
return {
|
|
@@ -16198,7 +16198,7 @@ var Qx = Symbol("COMPUTING"), $x = class {
|
|
|
16198
16198
|
diagnosticsProvider: new ty(this)
|
|
16199
16199
|
};
|
|
16200
16200
|
}
|
|
16201
|
-
},
|
|
16201
|
+
}, tS = class e {
|
|
16202
16202
|
constructor(e = {}) {
|
|
16203
16203
|
this.files = e instanceof Map ? new Map(e) : new Map(Object.entries(e));
|
|
16204
16204
|
}
|
|
@@ -16242,4 +16242,4 @@ var Qx = Symbol("COMPUTING"), $x = class {
|
|
|
16242
16242
|
}
|
|
16243
16243
|
};
|
|
16244
16244
|
//#endregion
|
|
16245
|
-
export { cc as ArrayNode, F as AttributeNode, z as BlockExpressionNode, V as CallExpressionNode, tc as CommaExpressionNode, b as CompileError, y as CompileErrorCode,
|
|
16245
|
+
export { cc as ArrayNode, F as AttributeNode, z as BlockExpressionNode, V as CallExpressionNode, tc as CommaExpressionNode, b as CompileError, y as CompileErrorCode, eS as Compiler, X as CompletionItemInsertTextRule, Y as CompletionItemKind, ky as DBMLCompletionItemProvider, ey as DBMLDefinitionProvider, ty as DBMLDiagnosticsProvider, ny as DBMLReferencesProvider, Eo as DEFAULT_ENTRY, P as ElementDeclarationNode, r as ElementKind, sc as EmptyNode, Zm as FALSY_VALUES, bo as Filepath, R as FunctionApplicationNode, $s as FunctionExpressionNode, nc as GroupExpressionNode, Zs as IdentifierStreamNode, L as InfixExpressionNode, B as ListExpressionNode, rc as LiteralNode, Zv as MarkerSeverity, tS as MemoryProjectLayout, dc as MetadataKind, Qs as PostfixExpressionNode, I as PrefixExpressionNode, oc as PrimaryExpressionNode, N as ProgramNode, Q as ScopeKind, j as SymbolKind, M as SyntaxNode, Ks as SyntaxNodeIdGenerator, qs as SyntaxNodeKind, Ha as SyntaxToken, _ as SyntaxTokenKind, Xm as TRUTHY_VALUES, ec as TupleExpressionNode, t as UNHANDLED, Bv as Uri, Js as UseDeclarationNode, Xs as UseSpecifierListNode, Ys as UseSpecifierNode, ac as VariableNode, ic as WildcardNode, gg as addDoubleQuoteIfNeeded, rb as dbmlLanguageConfig, ib as dbmlMonarchTokensProvider, vg as escapeString, ps as extractNumericLiteral, qm as extractSignedNumber, Fx as findDepBlocks, vx as findDiagramViewBlocks, yg as formatRecordValue, Al as getRecordValueType, Dl as isBinaryType, Tl as isBooleanType, Ol as isDateTimeType, Gm as isEmptyStringLiteral, Cl as isFloatType, Km as isFunctionExpression, Sl as isIntegerType, Wm as isNullish, wl as isNumericType, Ba as isOp, Va as isOpToken, kl as isSerialType, El as isStringType, za as isTriviaToken, hg as isValidIdentifier, xl as normalizeTypeName, bg as splitQualifiedIdentifier, Qm as tryExtractBoolean, ih as tryExtractDateTime, $m as tryExtractEnum, Ym as tryExtractInteger, Jm as tryExtractNumeric, eh as tryExtractString, _g as unescapeString, Dh as validateForeignKeys, gh as validatePrimaryKey, Ch as validateUnique };
|
|
@@ -3,11 +3,10 @@ import { SyntaxNode, SyntaxNodeIdGenerator } from '../core/types/nodes';
|
|
|
3
3
|
import { NodeSymbolIdGenerator, SymbolFactory } from '../core/types/symbol';
|
|
4
4
|
import { DBMLCompletionItemProvider, DBMLDefinitionProvider, DBMLDiagnosticsProvider, DBMLReferencesProvider } from '../services/index';
|
|
5
5
|
import { DbmlProjectLayout } from './projectLayout';
|
|
6
|
-
import { DiagramViewBlock, DepBlock, findDiagramViewBlocks, findDepBlocks } from './queries/transform';
|
|
7
6
|
import { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString } from './queries/utils';
|
|
8
7
|
export { ScopeKind } from './types';
|
|
9
|
-
export type {
|
|
10
|
-
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString,
|
|
8
|
+
export type { TextEdit } from './queries/transform';
|
|
9
|
+
export { addDoubleQuoteIfNeeded, escapeString, formatRecordValue, isValidIdentifier, splitQualifiedIdentifier, unescapeString, };
|
|
11
10
|
export default class Compiler {
|
|
12
11
|
layout: DbmlProjectLayout;
|
|
13
12
|
readonly nodeIdGenerator: SyntaxNodeIdGenerator;
|
|
@@ -72,17 +71,16 @@ export default class Compiler {
|
|
|
72
71
|
};
|
|
73
72
|
}>;
|
|
74
73
|
nodeAtPosition: (filepath: Filepath, offset: number) => SyntaxNode | import('..').SyntaxToken | undefined;
|
|
75
|
-
renameTable: (filepath: Filepath, oldName: import('
|
|
76
|
-
|
|
74
|
+
renameTable: (filepath: Filepath, oldName: string | import('..').TableIdentifier, newName: string | import('..').TableIdentifier) => Map<string, string>;
|
|
75
|
+
updateElementSetting: (filepath: Filepath, target: import('..').ElementIdentifier, settingName: string, value: string | null | undefined) => string;
|
|
76
|
+
syncDiagramView: (filepath: Filepath, operations: import('..').DiagramViewSyncOperation[], blocks?: import('..').DiagramViewBlock[] | undefined) => {
|
|
77
77
|
newDbml: string;
|
|
78
78
|
edits: import('.').TextEdit[];
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[], blocks?: DepBlock[] | undefined) => {
|
|
80
|
+
syncDep: (filepath: Filepath, operations: import('..').DepSyncOperation[], blocks?: import('..').DepBlock[] | undefined) => {
|
|
82
81
|
newDbml: string;
|
|
83
82
|
edits: import('.').TextEdit[];
|
|
84
83
|
};
|
|
85
|
-
findDepBlocks(filepath: Filepath): DepBlock[];
|
|
86
84
|
readonly token: {
|
|
87
85
|
invalidStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
88
86
|
flatStream: (filepath: Filepath) => readonly import('..').SyntaxToken[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { renameTable } from './renameTable';
|
|
2
|
+
export { updateElementSetting } from './updateElementSetting';
|
|
2
3
|
export { syncDiagramView, findDiagramViewBlocks, type DiagramViewSyncOperation, type DiagramViewBlock, } from './syncDiagramView';
|
|
3
4
|
export { syncDep, findDepBlocks, generateDepBlock, type DepSyncOperation, type DepSyncEdge, type DepEndpointRef, type DepBlock, } from './syncDep';
|
|
4
5
|
export { applyTextEdits, type TextEdit } from './applyTextEdits';
|
|
5
|
-
export {
|
|
6
|
+
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
2
|
import { default as Compiler } from '../../index';
|
|
3
|
-
import {
|
|
3
|
+
import { TableIdentifier } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* Renames a table across every file in the project layout.
|
|
6
6
|
*
|
|
@@ -23,4 +23,4 @@ import { TableNameInput } from './utils';
|
|
|
23
23
|
* only the files that were actually changed by the rename. An empty map
|
|
24
24
|
* indicates a no-op (lookup miss, name collision, or alias rename attempt).
|
|
25
25
|
*/
|
|
26
|
-
export declare function renameTable(this: Compiler, filepath: Filepath, oldName:
|
|
26
|
+
export declare function renameTable(this: Compiler, filepath: Filepath, oldName: string | TableIdentifier, newName: string | TableIdentifier): Map<string, string>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SymbolKind } from '../../../core/types/symbol';
|
|
2
|
+
import { MetadataKind } from '../../../core/types/symbol/metadata';
|
|
3
|
+
export type ElementIdentifier = (SchemaIdentifier | TableIdentifier | ColumnIdentifier | EnumIdentifier | RefIdentifier | DepIdentifier | NoteIdentifier | TableGroupIdentifier) & {
|
|
4
|
+
kind: string;
|
|
5
|
+
};
|
|
6
|
+
export interface SchemaIdentifier {
|
|
7
|
+
kind?: typeof SymbolKind.Schema;
|
|
8
|
+
schema: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TableIdentifier {
|
|
11
|
+
kind?: typeof SymbolKind.Table;
|
|
12
|
+
schema?: string;
|
|
13
|
+
table: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ColumnIdentifier {
|
|
16
|
+
kind?: typeof SymbolKind.Column;
|
|
17
|
+
schema?: string;
|
|
18
|
+
table: string;
|
|
19
|
+
column: string;
|
|
20
|
+
}
|
|
21
|
+
export interface EnumIdentifier {
|
|
22
|
+
kind?: typeof SymbolKind.Enum;
|
|
23
|
+
schema?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
}
|
|
26
|
+
export interface EndpointRef {
|
|
27
|
+
schema?: string;
|
|
28
|
+
table: string;
|
|
29
|
+
fields?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface RefIdentifier {
|
|
32
|
+
kind?: typeof MetadataKind.Ref;
|
|
33
|
+
endpoints: [EndpointRef, EndpointRef];
|
|
34
|
+
}
|
|
35
|
+
export interface DepIdentifier {
|
|
36
|
+
kind?: typeof MetadataKind.Dep;
|
|
37
|
+
upstream: EndpointRef;
|
|
38
|
+
downstream: EndpointRef;
|
|
39
|
+
}
|
|
40
|
+
export interface NoteIdentifier {
|
|
41
|
+
kind?: typeof SymbolKind.StickyNote;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
export interface TableGroupIdentifier {
|
|
45
|
+
kind?: typeof SymbolKind.TableGroup;
|
|
46
|
+
schema?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
+
import { default as Compiler } from '../../index';
|
|
3
|
+
import { ElementIdentifier } from './types';
|
|
4
|
+
export declare function updateElementSetting(this: Compiler, filepath: Filepath, target: ElementIdentifier, settingName: string, value: string | null | undefined): string;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { Filepath } from '../../../core/types/filepath';
|
|
2
|
-
import { NodeSymbol } from '../../../core/types/symbol';
|
|
2
|
+
import { NodeSymbol, SymbolKind } from '../../../core/types/symbol';
|
|
3
3
|
import { default as Compiler } from '../../index';
|
|
4
|
-
export type
|
|
4
|
+
export type { ElementIdentifier } from './types';
|
|
5
|
+
export declare function normalizeTableName(input: string | {
|
|
5
6
|
schema?: string;
|
|
6
7
|
table: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Normalizes a table name input to { schema, table } format.
|
|
10
|
-
* Properly handles quoted identifiers with dots inside.
|
|
11
|
-
*/
|
|
12
|
-
export declare function normalizeTableName(input: TableNameInput): {
|
|
8
|
+
}): {
|
|
13
9
|
schema: string;
|
|
14
10
|
table: string;
|
|
15
11
|
};
|
|
16
12
|
/**
|
|
17
|
-
* Looks up
|
|
13
|
+
* Looks up an element symbol by its qualified name and kind.
|
|
18
14
|
*/
|
|
19
|
-
export declare function
|
|
15
|
+
export declare function lookupElementSymbol(compiler: Compiler, filepath: Filepath, schema: string, name: string, kind?: SymbolKind): NodeSymbol | null;
|
|
20
16
|
/**
|
|
21
17
|
* Removes surrounding double quotes from a string if present.
|
|
22
18
|
*/
|
|
@@ -7,9 +7,13 @@ import { TextEdit } from '../../compiler/queries/transform/applyTextEdits';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function addSettingEdit(declaration: SyntaxNode, setting: string): TextEdit | undefined;
|
|
9
9
|
/**
|
|
10
|
-
* Produces a TextEdit that updates
|
|
10
|
+
* Produces a TextEdit that updates a setting's value in a declaration.
|
|
11
|
+
* value: string - update or create with "name: value"
|
|
12
|
+
* value: undefined - name-only setting (e.g. [pk])
|
|
13
|
+
* value: null - remove the setting
|
|
14
|
+
* If the setting does not exist, adds it.
|
|
11
15
|
*/
|
|
12
|
-
export declare function updateSettingEdit(declaration: SyntaxNode, settingName: string,
|
|
16
|
+
export declare function updateSettingEdit(declaration: SyntaxNode, settingName: string, value: string | null | undefined, source: string): TextEdit | undefined;
|
|
13
17
|
/**
|
|
14
18
|
* Produces a TextEdit that removes a setting from a declaration.
|
|
15
19
|
* If it's the only setting, removes the entire settings block [...].
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { Filepath } from './core/types/filepath';
|
|
|
4
4
|
export { UNHANDLED, type Unhandled, } from './core/types/module';
|
|
5
5
|
export { ElementKind } from './core/types/keywords';
|
|
6
6
|
export { type NodeSymbol, SymbolKind, } from './core/types/symbol';
|
|
7
|
+
export { MetadataKind } from './core/types/symbol/metadata';
|
|
7
8
|
export * from './core/global_modules/records/utils';
|
|
8
9
|
export * from './core/types/nodes';
|
|
9
10
|
export { SyntaxToken, SyntaxTokenKind, isTriviaToken, isOp, isOpToken, } from './core/types/tokens';
|
|
@@ -12,7 +13,9 @@ export type { Position, } from './core/types';
|
|
|
12
13
|
export { ScopeKind, splitQualifiedIdentifier, unescapeString, escapeString, formatRecordValue, isValidIdentifier, addDoubleQuoteIfNeeded, } from './compiler/index';
|
|
13
14
|
export { type Database, type MasterDatabase, type Table, type Note, type Column, type ColumnType, type Index, type Check, type InlineRef, type Ref, type RefEndpointPair, type RefEndpoint, type RelationCardinality, type Enum, type EnumField, type TableGroup, type TableGroupField, type Alias, type AliasKind, type TablePartial, type TablePartialInjection, type RecordValue, type RecordValueType, type TableRecord, type Project, type SchemaElement, type TokenPosition, type ElementRef, type FilterConfig, type DiagramView, } from './core/types/schemaJson';
|
|
14
15
|
export type { DiagramViewSyncOperation, DiagramViewBlock, TextEdit, } from './compiler/queries/transform';
|
|
16
|
+
export { findDiagramViewBlocks, findDepBlocks } from './compiler/queries/transform';
|
|
15
17
|
export type { DepSyncOperation, DepSyncEdge, DepEndpointRef, DepBlock, } from './compiler/queries/transform';
|
|
18
|
+
export type { ElementIdentifier, SchemaIdentifier, TableIdentifier, ColumnIdentifier, EnumIdentifier, EndpointRef, RefIdentifier, DepIdentifier, NoteIdentifier, TableGroupIdentifier, } from './compiler/queries/transform';
|
|
16
19
|
export { dbmlLanguageConfig, dbmlMonarchTokensProvider, } from './services/monarch';
|
|
17
20
|
export * from './compiler/projectLayout/layout';
|
|
18
21
|
export { Compiler };
|
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": "9.0.0-alpha.
|
|
4
|
+
"version": "9.0.0-alpha.8",
|
|
5
5
|
"description": "DBML parser v2",
|
|
6
6
|
"author": "Holistics <dev@holistics.io>",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "3049d76952a6bf7e05aa51188bf5546145ba2b17"
|
|
54
54
|
}
|