@514labs/moose-lsp 0.1.0-dev.11.3.1

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.
Files changed (104) hide show
  1. package/dist/clickhouseData.d.ts +78 -0
  2. package/dist/clickhouseData.js +111 -0
  3. package/dist/clickhouseData.js.map +1 -0
  4. package/dist/clickhouseData.test.d.ts +2 -0
  5. package/dist/clickhouseData.test.js +92 -0
  6. package/dist/clickhouseData.test.js.map +1 -0
  7. package/dist/clickhouseVersion.d.ts +49 -0
  8. package/dist/clickhouseVersion.js +148 -0
  9. package/dist/clickhouseVersion.js.map +1 -0
  10. package/dist/clickhouseVersion.test.d.ts +2 -0
  11. package/dist/clickhouseVersion.test.js +113 -0
  12. package/dist/clickhouseVersion.test.js.map +1 -0
  13. package/dist/codeActions.d.ts +27 -0
  14. package/dist/codeActions.js +172 -0
  15. package/dist/codeActions.js.map +1 -0
  16. package/dist/codeActions.test.d.ts +2 -0
  17. package/dist/codeActions.test.js +206 -0
  18. package/dist/codeActions.test.js.map +1 -0
  19. package/dist/completions.d.ts +22 -0
  20. package/dist/completions.js +227 -0
  21. package/dist/completions.js.map +1 -0
  22. package/dist/completions.test.d.ts +2 -0
  23. package/dist/completions.test.js +282 -0
  24. package/dist/completions.test.js.map +1 -0
  25. package/dist/data/clickhouse-25.6.json +30772 -0
  26. package/dist/data/clickhouse-25.8.json +31872 -0
  27. package/dist/diagnostics.d.ts +18 -0
  28. package/dist/diagnostics.js +53 -0
  29. package/dist/diagnostics.js.map +1 -0
  30. package/dist/diagnostics.test.d.ts +2 -0
  31. package/dist/diagnostics.test.js +109 -0
  32. package/dist/diagnostics.test.js.map +1 -0
  33. package/dist/formatting.d.ts +36 -0
  34. package/dist/formatting.js +69 -0
  35. package/dist/formatting.js.map +1 -0
  36. package/dist/formatting.test.d.ts +2 -0
  37. package/dist/formatting.test.js +92 -0
  38. package/dist/formatting.test.js.map +1 -0
  39. package/dist/hover.d.ts +44 -0
  40. package/dist/hover.js +209 -0
  41. package/dist/hover.js.map +1 -0
  42. package/dist/hover.test.d.ts +2 -0
  43. package/dist/hover.test.js +354 -0
  44. package/dist/hover.test.js.map +1 -0
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +25 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/node_modules/@514labs/moose-sql-validator-wasm/dist/index.js +56 -0
  49. package/dist/node_modules/@514labs/moose-sql-validator-wasm/dist/index.js.map +1 -0
  50. package/dist/node_modules/@514labs/moose-sql-validator-wasm/dist/index.test.js +185 -0
  51. package/dist/node_modules/@514labs/moose-sql-validator-wasm/dist/index.test.js.map +1 -0
  52. package/dist/node_modules/@514labs/moose-sql-validator-wasm/package.json +40 -0
  53. package/dist/node_modules/@514labs/moose-sql-validator-wasm/pkg/package.json +11 -0
  54. package/dist/node_modules/@514labs/moose-sql-validator-wasm/pkg/sql_validator.js +176 -0
  55. package/dist/node_modules/@514labs/moose-sql-validator-wasm/pkg/sql_validator_bg.wasm +0 -0
  56. package/dist/projectDetector.d.ts +21 -0
  57. package/dist/projectDetector.js +162 -0
  58. package/dist/projectDetector.js.map +1 -0
  59. package/dist/projectDetector.test.d.ts +2 -0
  60. package/dist/projectDetector.test.js +303 -0
  61. package/dist/projectDetector.test.js.map +1 -0
  62. package/dist/pythonService.d.ts +40 -0
  63. package/dist/pythonService.js +121 -0
  64. package/dist/pythonService.js.map +1 -0
  65. package/dist/pythonService.test.d.ts +2 -0
  66. package/dist/pythonService.test.js +208 -0
  67. package/dist/pythonService.test.js.map +1 -0
  68. package/dist/pythonSqlExtractor.d.ts +25 -0
  69. package/dist/pythonSqlExtractor.js +258 -0
  70. package/dist/pythonSqlExtractor.js.map +1 -0
  71. package/dist/pythonSqlExtractor.test.d.ts +2 -0
  72. package/dist/pythonSqlExtractor.test.js +227 -0
  73. package/dist/pythonSqlExtractor.test.js.map +1 -0
  74. package/dist/server.d.ts +2 -0
  75. package/dist/server.integration.test.d.ts +2 -0
  76. package/dist/server.integration.test.js +189 -0
  77. package/dist/server.integration.test.js.map +1 -0
  78. package/dist/server.js +228412 -0
  79. package/dist/server.js.map +1 -0
  80. package/dist/serverLogic.d.ts +40 -0
  81. package/dist/serverLogic.js +61 -0
  82. package/dist/serverLogic.js.map +1 -0
  83. package/dist/serverLogic.test.d.ts +2 -0
  84. package/dist/serverLogic.test.js +263 -0
  85. package/dist/serverLogic.test.js.map +1 -0
  86. package/dist/sqlExtractor.d.ts +15 -0
  87. package/dist/sqlExtractor.js +105 -0
  88. package/dist/sqlExtractor.js.map +1 -0
  89. package/dist/sqlExtractor.test.d.ts +2 -0
  90. package/dist/sqlExtractor.test.js +267 -0
  91. package/dist/sqlExtractor.test.js.map +1 -0
  92. package/dist/sqlLocations.d.ts +31 -0
  93. package/dist/sqlLocations.js +51 -0
  94. package/dist/sqlLocations.js.map +1 -0
  95. package/dist/sqlLocations.test.d.ts +2 -0
  96. package/dist/sqlLocations.test.js +94 -0
  97. package/dist/sqlLocations.test.js.map +1 -0
  98. package/dist/typescriptService.d.ts +29 -0
  99. package/dist/typescriptService.js +137 -0
  100. package/dist/typescriptService.js.map +1 -0
  101. package/dist/typescriptService.test.d.ts +2 -0
  102. package/dist/typescriptService.test.js +200 -0
  103. package/dist/typescriptService.test.js.map +1 -0
  104. package/package.json +49 -0
@@ -0,0 +1,27 @@
1
+ import ts from 'typescript';
2
+ import { TextEdit } from 'vscode-languageserver/node';
3
+ import { SqlLocation } from './sqlLocations.js';
4
+
5
+ /**
6
+ * Finds the SQL template that contains the given cursor position.
7
+ * @param locations - Array of SQL template locations
8
+ * @param line - 0-indexed cursor line
9
+ * @param character - 0-indexed cursor column
10
+ * @returns The SqlLocation containing the cursor, or undefined
11
+ */
12
+ declare function findSqlTemplateAtPosition(locations: SqlLocation[], line: number, character: number): SqlLocation | undefined;
13
+ /**
14
+ * Extract original ${expr} expressions from a template literal.
15
+ * Returns array of expression source texts like ['${col}', '${table}'].
16
+ */
17
+ declare function extractOriginalExpressions(template: ts.TemplateLiteral): string[];
18
+ /**
19
+ * Creates the text edit for formatting a SQL template.
20
+ */
21
+ declare function createFormatSqlEdit(sourceFile: ts.SourceFile, node: ts.TaggedTemplateExpression): TextEdit | undefined;
22
+ /**
23
+ * Finds a TaggedTemplateExpression by its location ID.
24
+ */
25
+ declare function findTemplateNodeById(sourceFile: ts.SourceFile, locationId: string): ts.TaggedTemplateExpression | undefined;
26
+
27
+ export { createFormatSqlEdit, extractOriginalExpressions, findSqlTemplateAtPosition, findTemplateNodeById };
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var codeActions_exports = {};
30
+ __export(codeActions_exports, {
31
+ createFormatSqlEdit: () => createFormatSqlEdit,
32
+ extractOriginalExpressions: () => extractOriginalExpressions,
33
+ findSqlTemplateAtPosition: () => findSqlTemplateAtPosition,
34
+ findTemplateNodeById: () => findTemplateNodeById
35
+ });
36
+ module.exports = __toCommonJS(codeActions_exports);
37
+ var import_typescript = __toESM(require("typescript"));
38
+ var import_formatting = require("./formatting");
39
+ function findSqlTemplateAtPosition(locations, line, character) {
40
+ const cursorLine = line + 1;
41
+ const cursorColumn = character + 1;
42
+ for (const loc of locations) {
43
+ const afterStart = cursorLine > loc.line || cursorLine === loc.line && cursorColumn >= loc.column;
44
+ const beforeEnd = cursorLine < loc.endLine || cursorLine === loc.endLine && cursorColumn <= loc.endColumn;
45
+ if (afterStart && beforeEnd) {
46
+ return loc;
47
+ }
48
+ }
49
+ return void 0;
50
+ }
51
+ function extractOriginalExpressions(template) {
52
+ if (import_typescript.default.isNoSubstitutionTemplateLiteral(template)) {
53
+ return [];
54
+ }
55
+ const expressions = [];
56
+ for (const span of template.templateSpans) {
57
+ const exprText = span.expression.getText();
58
+ expressions.push(`\${${exprText}}`);
59
+ }
60
+ return expressions;
61
+ }
62
+ function extractTemplateText(template) {
63
+ if (import_typescript.default.isNoSubstitutionTemplateLiteral(template)) {
64
+ return template.text;
65
+ }
66
+ let text = template.head.text;
67
+ for (const span of template.templateSpans) {
68
+ text += `\${...}${span.literal.text}`;
69
+ }
70
+ return text;
71
+ }
72
+ function detectTemplateIndentation(templateText) {
73
+ const hasLeadingNewline = templateText.startsWith("\n");
74
+ const hasTrailingNewline = templateText.endsWith("\n") || /\n\s*$/.test(templateText);
75
+ let indent = "";
76
+ if (hasLeadingNewline) {
77
+ const lines = templateText.split("\n");
78
+ for (let i = 1; i < lines.length; i++) {
79
+ const line = lines[i];
80
+ if (line.trim().length > 0) {
81
+ const match = line.match(/^(\s*)/);
82
+ if (match) {
83
+ indent = match[1];
84
+ }
85
+ break;
86
+ }
87
+ }
88
+ }
89
+ let trailingIndent = "";
90
+ if (hasTrailingNewline) {
91
+ const match = templateText.match(/\n(\s*)$/);
92
+ if (match) {
93
+ trailingIndent = match[1];
94
+ }
95
+ }
96
+ return { indent, hasLeadingNewline, hasTrailingNewline, trailingIndent };
97
+ }
98
+ function applyIndentation(formatted, indent, hasLeadingNewline, hasTrailingNewline, trailingIndent) {
99
+ const lines = formatted.split("\n");
100
+ const indentedLines = lines.map(
101
+ (line) => line.length > 0 ? indent + line : line
102
+ );
103
+ let result = indentedLines.join("\n");
104
+ if (hasLeadingNewline) {
105
+ result = `
106
+ ${result}`;
107
+ }
108
+ if (hasTrailingNewline) {
109
+ result = `${result}
110
+ ${trailingIndent}`;
111
+ }
112
+ return result;
113
+ }
114
+ function createFormatSqlEdit(sourceFile, node) {
115
+ const originalExprs = extractOriginalExpressions(node.template);
116
+ const templateText = extractTemplateText(node.template);
117
+ const result = (0, import_formatting.formatSqlTemplate)(templateText, originalExprs);
118
+ if (!result.success || !result.formatted) {
119
+ return void 0;
120
+ }
121
+ const { indent, hasLeadingNewline, hasTrailingNewline, trailingIndent } = detectTemplateIndentation(templateText);
122
+ const formattedWithIndent = applyIndentation(
123
+ result.formatted,
124
+ indent,
125
+ hasLeadingNewline,
126
+ hasTrailingNewline,
127
+ trailingIndent
128
+ );
129
+ const templateStart = sourceFile.getLineAndCharacterOfPosition(
130
+ node.template.getStart() + 1
131
+ );
132
+ const templateEnd = sourceFile.getLineAndCharacterOfPosition(
133
+ node.template.getEnd() - 1
134
+ );
135
+ return {
136
+ range: {
137
+ start: { line: templateStart.line, character: templateStart.character },
138
+ end: { line: templateEnd.line, character: templateEnd.character }
139
+ },
140
+ newText: formattedWithIndent
141
+ };
142
+ }
143
+ function findTemplateNodeById(sourceFile, locationId) {
144
+ let targetNode;
145
+ function visit(node) {
146
+ if (import_typescript.default.isTaggedTemplateExpression(node)) {
147
+ const tag = node.tag;
148
+ if (import_typescript.default.isIdentifier(tag) && tag.text === "sql") {
149
+ const start = sourceFile.getLineAndCharacterOfPosition(
150
+ node.template.getStart()
151
+ );
152
+ const id = `${sourceFile.fileName}:${start.line + 1}:${start.character + 1}`;
153
+ if (id === locationId) {
154
+ targetNode = node;
155
+ }
156
+ }
157
+ }
158
+ if (!targetNode) {
159
+ import_typescript.default.forEachChild(node, visit);
160
+ }
161
+ }
162
+ visit(sourceFile);
163
+ return targetNode;
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ createFormatSqlEdit,
168
+ extractOriginalExpressions,
169
+ findSqlTemplateAtPosition,
170
+ findTemplateNodeById
171
+ });
172
+ //# sourceMappingURL=codeActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/codeActions.ts"],"sourcesContent":["import ts from 'typescript';\nimport type { TextEdit } from 'vscode-languageserver/node';\nimport { formatSqlTemplate } from './formatting';\nimport type { SqlLocation } from './sqlLocations';\n\n/**\n * Finds the SQL template that contains the given cursor position.\n * @param locations - Array of SQL template locations\n * @param line - 0-indexed cursor line\n * @param character - 0-indexed cursor column\n * @returns The SqlLocation containing the cursor, or undefined\n */\nexport function findSqlTemplateAtPosition(\n locations: SqlLocation[],\n line: number,\n character: number,\n): SqlLocation | undefined {\n // Convert to 1-indexed for comparison with SqlLocation\n const cursorLine = line + 1;\n const cursorColumn = character + 1;\n\n for (const loc of locations) {\n // Check if cursor is within the template bounds\n const afterStart =\n cursorLine > loc.line ||\n (cursorLine === loc.line && cursorColumn >= loc.column);\n\n const beforeEnd =\n cursorLine < loc.endLine ||\n (cursorLine === loc.endLine && cursorColumn <= loc.endColumn);\n\n if (afterStart && beforeEnd) {\n return loc;\n }\n }\n\n return undefined;\n}\n\n/**\n * Extract original ${expr} expressions from a template literal.\n * Returns array of expression source texts like ['${col}', '${table}'].\n */\nexport function extractOriginalExpressions(\n template: ts.TemplateLiteral,\n): string[] {\n if (ts.isNoSubstitutionTemplateLiteral(template)) {\n return [];\n }\n\n const expressions: string[] = [];\n for (const span of template.templateSpans) {\n const exprText = span.expression.getText();\n expressions.push(`\\${${exprText}}`);\n }\n return expressions;\n}\n\n/**\n * Extract template text with ${...} placeholders.\n */\nfunction extractTemplateText(template: ts.TemplateLiteral): string {\n if (ts.isNoSubstitutionTemplateLiteral(template)) {\n return template.text;\n }\n\n let text = template.head.text;\n for (const span of template.templateSpans) {\n text += `\\${...}${span.literal.text}`;\n }\n return text;\n}\n\n/**\n * Detects the indentation used in the original template.\n * Returns the indentation string (spaces/tabs) and whether it starts with a newline.\n */\nfunction detectTemplateIndentation(templateText: string): {\n indent: string;\n hasLeadingNewline: boolean;\n hasTrailingNewline: boolean;\n trailingIndent: string;\n} {\n const hasLeadingNewline = templateText.startsWith('\\n');\n const hasTrailingNewline =\n templateText.endsWith('\\n') || /\\n\\s*$/.test(templateText);\n\n // Find indentation from the first non-empty line after the opening\n let indent = '';\n if (hasLeadingNewline) {\n const lines = templateText.split('\\n');\n // Find first line with actual content (skip empty lines)\n for (let i = 1; i < lines.length; i++) {\n const line = lines[i];\n if (line.trim().length > 0) {\n const match = line.match(/^(\\s*)/);\n if (match) {\n indent = match[1];\n }\n break;\n }\n }\n }\n\n // Find trailing indentation (indentation of the closing backtick line)\n let trailingIndent = '';\n if (hasTrailingNewline) {\n const match = templateText.match(/\\n(\\s*)$/);\n if (match) {\n trailingIndent = match[1];\n }\n }\n\n return { indent, hasLeadingNewline, hasTrailingNewline, trailingIndent };\n}\n\n/**\n * Applies indentation to formatted SQL, preserving the original template structure.\n */\nfunction applyIndentation(\n formatted: string,\n indent: string,\n hasLeadingNewline: boolean,\n hasTrailingNewline: boolean,\n trailingIndent: string,\n): string {\n // Split formatted SQL into lines and apply indentation\n const lines = formatted.split('\\n');\n const indentedLines = lines.map((line) =>\n line.length > 0 ? indent + line : line,\n );\n\n let result = indentedLines.join('\\n');\n\n // Add leading newline if original had one\n if (hasLeadingNewline) {\n result = `\\n${result}`;\n }\n\n // Add trailing newline and indentation if original had it\n if (hasTrailingNewline) {\n result = `${result}\\n${trailingIndent}`;\n }\n\n return result;\n}\n\n/**\n * Creates the text edit for formatting a SQL template.\n */\nexport function createFormatSqlEdit(\n sourceFile: ts.SourceFile,\n node: ts.TaggedTemplateExpression,\n): TextEdit | undefined {\n const originalExprs = extractOriginalExpressions(node.template);\n const templateText = extractTemplateText(node.template);\n\n const result = formatSqlTemplate(templateText, originalExprs);\n if (!result.success || !result.formatted) {\n return undefined;\n }\n\n // Detect indentation from original template\n const { indent, hasLeadingNewline, hasTrailingNewline, trailingIndent } =\n detectTemplateIndentation(templateText);\n\n // Apply indentation to formatted SQL\n const formattedWithIndent = applyIndentation(\n result.formatted,\n indent,\n hasLeadingNewline,\n hasTrailingNewline,\n trailingIndent,\n );\n\n // Get positions inside the backticks\n const templateStart = sourceFile.getLineAndCharacterOfPosition(\n node.template.getStart() + 1,\n );\n const templateEnd = sourceFile.getLineAndCharacterOfPosition(\n node.template.getEnd() - 1,\n );\n\n return {\n range: {\n start: { line: templateStart.line, character: templateStart.character },\n end: { line: templateEnd.line, character: templateEnd.character },\n },\n newText: formattedWithIndent,\n };\n}\n\n/**\n * Finds a TaggedTemplateExpression by its location ID.\n */\nexport function findTemplateNodeById(\n sourceFile: ts.SourceFile,\n locationId: string,\n): ts.TaggedTemplateExpression | undefined {\n let targetNode: ts.TaggedTemplateExpression | undefined;\n\n function visit(node: ts.Node): void {\n if (ts.isTaggedTemplateExpression(node)) {\n const tag = node.tag;\n if (ts.isIdentifier(tag) && tag.text === 'sql') {\n const start = sourceFile.getLineAndCharacterOfPosition(\n node.template.getStart(),\n );\n const id = `${sourceFile.fileName}:${start.line + 1}:${start.character + 1}`;\n if (id === locationId) {\n targetNode = node;\n }\n }\n }\n if (!targetNode) {\n ts.forEachChild(node, visit);\n }\n }\n\n visit(sourceFile);\n return targetNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAe;AAEf,wBAAkC;AAU3B,SAAS,0BACd,WACA,MACA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,MAAM,YAAY,MAAM,WAAW,YAAY,UAAU;AAAA,IAClE;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAKO,SAAS,qBACd,YACA,YACyC;AACzC,MAAI;AAEJ,WAAS,MAAM,MAAqB;AAClC,QAAI,kBAAAA,QAAG,2BAA2B,IAAI,GAAG;AACvC,YAAM,MAAM,KAAK;AACjB,UAAI,kBAAAA,QAAG,aAAa,GAAG,KAAK,IAAI,SAAS,OAAO;AAC9C,cAAM,QAAQ,WAAW;AAAA,UACvB,KAAK,SAAS,SAAS;AAAA,QACzB;AACA,cAAM,KAAK,GAAG,WAAW,QAAQ,IAAI,MAAM,OAAO,CAAC,IAAI,MAAM,YAAY,CAAC;AAC1E,YAAI,OAAO,YAAY;AACrB,uBAAa;AAAA,QACf;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,YAAY;AACf,wBAAAA,QAAG,aAAa,MAAM,KAAK;AAAA,IAC7B;AAAA,EACF;AAEA,QAAM,UAAU;AAChB,SAAO;AACT;","names":["ts"]}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_node_assert = __toESM(require("node:assert"));
25
+ var import_node_test = require("node:test");
26
+ var import_typescript = __toESM(require("typescript"));
27
+ var import_codeActions = require("./codeActions");
28
+ (0, import_node_test.test)("findSqlTemplateAtPosition Tests", async (t) => {
29
+ const locations = [
30
+ {
31
+ id: "test.ts:5:10",
32
+ file: "/project/test.ts",
33
+ line: 5,
34
+ column: 10,
35
+ endLine: 5,
36
+ endColumn: 50,
37
+ templateText: "SELECT * FROM users"
38
+ },
39
+ {
40
+ id: "test.ts:10:5",
41
+ file: "/project/test.ts",
42
+ line: 10,
43
+ column: 5,
44
+ endLine: 15,
45
+ endColumn: 10,
46
+ templateText: "SELECT ${...} FROM ${...}"
47
+ }
48
+ ];
49
+ await t.test("finds template when cursor is inside", () => {
50
+ const result = (0, import_codeActions.findSqlTemplateAtPosition)(locations, 4, 20);
51
+ import_node_assert.default.ok(result);
52
+ import_node_assert.default.strictEqual(result.id, "test.ts:5:10");
53
+ });
54
+ await t.test("finds multiline template when cursor is inside", () => {
55
+ const result = (0, import_codeActions.findSqlTemplateAtPosition)(locations, 11, 5);
56
+ import_node_assert.default.ok(result);
57
+ import_node_assert.default.strictEqual(result.id, "test.ts:10:5");
58
+ });
59
+ await t.test("returns undefined when cursor is outside all templates", () => {
60
+ const result = (0, import_codeActions.findSqlTemplateAtPosition)(locations, 0, 0);
61
+ import_node_assert.default.strictEqual(result, void 0);
62
+ });
63
+ await t.test(
64
+ "returns undefined when cursor is after template on same line",
65
+ () => {
66
+ const result = (0, import_codeActions.findSqlTemplateAtPosition)(locations, 4, 55);
67
+ import_node_assert.default.strictEqual(result, void 0);
68
+ }
69
+ );
70
+ await t.test("returns undefined for empty locations", () => {
71
+ const result = (0, import_codeActions.findSqlTemplateAtPosition)([], 5, 10);
72
+ import_node_assert.default.strictEqual(result, void 0);
73
+ });
74
+ });
75
+ function createSourceFileWithSqlTemplate(code) {
76
+ const sourceFile = import_typescript.default.createSourceFile(
77
+ "test.ts",
78
+ code,
79
+ import_typescript.default.ScriptTarget.Latest,
80
+ true
81
+ );
82
+ let templateNode;
83
+ function visit(node) {
84
+ if (import_typescript.default.isTaggedTemplateExpression(node)) {
85
+ templateNode = node;
86
+ }
87
+ if (!templateNode) {
88
+ import_typescript.default.forEachChild(node, visit);
89
+ }
90
+ }
91
+ visit(sourceFile);
92
+ return { sourceFile, templateNode };
93
+ }
94
+ (0, import_node_test.test)("extractOriginalExpressions Tests", async (t) => {
95
+ await t.test("extracts expressions from template with substitutions", () => {
96
+ const code = "const q = sql`SELECT ${col} FROM ${table}`;";
97
+ const { templateNode } = createSourceFileWithSqlTemplate(code);
98
+ import_node_assert.default.ok(templateNode);
99
+ const expressions = (0, import_codeActions.extractOriginalExpressions)(templateNode.template);
100
+ import_node_assert.default.strictEqual(expressions.length, 2);
101
+ import_node_assert.default.strictEqual(expressions[0], "${col}");
102
+ import_node_assert.default.strictEqual(expressions[1], "${table}");
103
+ });
104
+ await t.test("returns empty array for template without substitutions", () => {
105
+ const code = "const q = sql`SELECT * FROM users`;";
106
+ const { templateNode } = createSourceFileWithSqlTemplate(code);
107
+ import_node_assert.default.ok(templateNode);
108
+ const expressions = (0, import_codeActions.extractOriginalExpressions)(templateNode.template);
109
+ import_node_assert.default.strictEqual(expressions.length, 0);
110
+ });
111
+ await t.test("handles complex expressions", () => {
112
+ const code = "const q = sql`SELECT * FROM ${getTable()} WHERE id = ${user.id}`;";
113
+ const { templateNode } = createSourceFileWithSqlTemplate(code);
114
+ import_node_assert.default.ok(templateNode);
115
+ const expressions = (0, import_codeActions.extractOriginalExpressions)(templateNode.template);
116
+ import_node_assert.default.strictEqual(expressions.length, 2);
117
+ import_node_assert.default.strictEqual(expressions[0], "${getTable()}");
118
+ import_node_assert.default.strictEqual(expressions[1], "${user.id}");
119
+ });
120
+ });
121
+ (0, import_node_test.test)("findTemplateNodeById Tests", async (t) => {
122
+ await t.test("finds template node by location id", () => {
123
+ const code = "const q = sql`SELECT * FROM users`;";
124
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
125
+ import_node_assert.default.ok(templateNode);
126
+ const start = sourceFile.getLineAndCharacterOfPosition(
127
+ templateNode.template.getStart()
128
+ );
129
+ const locationId = `test.ts:${start.line + 1}:${start.character + 1}`;
130
+ const found = (0, import_codeActions.findTemplateNodeById)(sourceFile, locationId);
131
+ import_node_assert.default.ok(found);
132
+ import_node_assert.default.strictEqual(found, templateNode);
133
+ });
134
+ await t.test("returns undefined for non-existent location id", () => {
135
+ const code = "const q = sql`SELECT * FROM users`;";
136
+ const { sourceFile } = createSourceFileWithSqlTemplate(code);
137
+ const found = (0, import_codeActions.findTemplateNodeById)(sourceFile, "test.ts:999:999");
138
+ import_node_assert.default.strictEqual(found, void 0);
139
+ });
140
+ await t.test("ignores non-sql tagged templates", () => {
141
+ const code = "const q = html`<div>Hello</div>`;";
142
+ const sourceFile = import_typescript.default.createSourceFile(
143
+ "test.ts",
144
+ code,
145
+ import_typescript.default.ScriptTarget.Latest,
146
+ true
147
+ );
148
+ const found = (0, import_codeActions.findTemplateNodeById)(sourceFile, "test.ts:1:15");
149
+ import_node_assert.default.strictEqual(found, void 0);
150
+ });
151
+ });
152
+ (0, import_node_test.test)("createFormatSqlEdit Tests", async (t) => {
153
+ await t.test("creates edit for simple SQL template", () => {
154
+ const code = "const q = sql`select * from users`;";
155
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
156
+ import_node_assert.default.ok(templateNode);
157
+ const edit = (0, import_codeActions.createFormatSqlEdit)(sourceFile, templateNode);
158
+ import_node_assert.default.ok(edit);
159
+ import_node_assert.default.ok(edit.newText.includes("SELECT"));
160
+ import_node_assert.default.ok(edit.newText.includes("FROM"));
161
+ });
162
+ await t.test("preserves placeholders in formatted output", () => {
163
+ const code = "const q = sql`select ${col} from ${table}`;";
164
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
165
+ import_node_assert.default.ok(templateNode);
166
+ const edit = (0, import_codeActions.createFormatSqlEdit)(sourceFile, templateNode);
167
+ import_node_assert.default.ok(edit);
168
+ import_node_assert.default.ok(edit.newText.includes("${col}"));
169
+ import_node_assert.default.ok(edit.newText.includes("${table}"));
170
+ });
171
+ await t.test("returns undefined for invalid SQL", () => {
172
+ const code = "const q = sql`SELCT * FROM users`;";
173
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
174
+ import_node_assert.default.ok(templateNode);
175
+ const edit = (0, import_codeActions.createFormatSqlEdit)(sourceFile, templateNode);
176
+ import_node_assert.default.strictEqual(edit, void 0);
177
+ });
178
+ await t.test("preserves indentation for multiline template", () => {
179
+ const code = `const q = sql\`
180
+ select * from users
181
+ \`;`;
182
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
183
+ import_node_assert.default.ok(templateNode);
184
+ const edit = (0, import_codeActions.createFormatSqlEdit)(sourceFile, templateNode);
185
+ import_node_assert.default.ok(edit);
186
+ import_node_assert.default.ok(edit.newText.startsWith("\n"), "Should start with newline");
187
+ import_node_assert.default.ok(
188
+ edit.newText.includes(" SELECT"),
189
+ "Should preserve 6-space indent"
190
+ );
191
+ });
192
+ await t.test("preserves trailing newline and closing indent", () => {
193
+ const code = `const q = sql\`
194
+ select * from users
195
+ \`;`;
196
+ const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);
197
+ import_node_assert.default.ok(templateNode);
198
+ const edit = (0, import_codeActions.createFormatSqlEdit)(sourceFile, templateNode);
199
+ import_node_assert.default.ok(edit);
200
+ import_node_assert.default.ok(
201
+ edit.newText.endsWith("\n "),
202
+ "Should end with newline and 4-space indent"
203
+ );
204
+ });
205
+ });
206
+ //# sourceMappingURL=codeActions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/codeActions.test.ts"],"sourcesContent":["import assert from 'node:assert';\nimport { test } from 'node:test';\nimport ts from 'typescript';\nimport {\n createFormatSqlEdit,\n extractOriginalExpressions,\n findSqlTemplateAtPosition,\n findTemplateNodeById,\n} from './codeActions';\nimport type { SqlLocation } from './sqlLocations';\n\ntest('findSqlTemplateAtPosition Tests', async (t) => {\n const locations: SqlLocation[] = [\n {\n id: 'test.ts:5:10',\n file: '/project/test.ts',\n line: 5,\n column: 10,\n endLine: 5,\n endColumn: 50,\n templateText: 'SELECT * FROM users',\n },\n {\n id: 'test.ts:10:5',\n file: '/project/test.ts',\n line: 10,\n column: 5,\n endLine: 15,\n endColumn: 10,\n templateText: 'SELECT ${...} FROM ${...}',\n },\n ];\n\n await t.test('finds template when cursor is inside', () => {\n // Cursor at line 5, column 20 (inside first template)\n const result = findSqlTemplateAtPosition(locations, 4, 20); // 0-indexed\n\n assert.ok(result);\n assert.strictEqual(result.id, 'test.ts:5:10');\n });\n\n await t.test('finds multiline template when cursor is inside', () => {\n // Cursor at line 12 (inside second template which spans lines 10-15)\n const result = findSqlTemplateAtPosition(locations, 11, 5); // 0-indexed\n\n assert.ok(result);\n assert.strictEqual(result.id, 'test.ts:10:5');\n });\n\n await t.test('returns undefined when cursor is outside all templates', () => {\n // Cursor at line 1 (before any template)\n const result = findSqlTemplateAtPosition(locations, 0, 0);\n\n assert.strictEqual(result, undefined);\n });\n\n await t.test(\n 'returns undefined when cursor is after template on same line',\n () => {\n // Cursor at line 5, column 55 (after first template ends at 50)\n const result = findSqlTemplateAtPosition(locations, 4, 55);\n\n assert.strictEqual(result, undefined);\n },\n );\n\n await t.test('returns undefined for empty locations', () => {\n const result = findSqlTemplateAtPosition([], 5, 10);\n\n assert.strictEqual(result, undefined);\n });\n});\n\n// Helper to create a source file and find the first tagged template expression\nfunction createSourceFileWithSqlTemplate(code: string): {\n sourceFile: ts.SourceFile;\n templateNode: ts.TaggedTemplateExpression | undefined;\n} {\n const sourceFile = ts.createSourceFile(\n 'test.ts',\n code,\n ts.ScriptTarget.Latest,\n true,\n );\n\n let templateNode: ts.TaggedTemplateExpression | undefined;\n\n function visit(node: ts.Node): void {\n if (ts.isTaggedTemplateExpression(node)) {\n templateNode = node;\n }\n if (!templateNode) {\n ts.forEachChild(node, visit);\n }\n }\n\n visit(sourceFile);\n return { sourceFile, templateNode };\n}\n\ntest('extractOriginalExpressions Tests', async (t) => {\n await t.test('extracts expressions from template with substitutions', () => {\n const code = 'const q = sql`SELECT ${col} FROM ${table}`;';\n const { templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const expressions = extractOriginalExpressions(templateNode.template);\n\n assert.strictEqual(expressions.length, 2);\n assert.strictEqual(expressions[0], '${col}');\n assert.strictEqual(expressions[1], '${table}');\n });\n\n await t.test('returns empty array for template without substitutions', () => {\n const code = 'const q = sql`SELECT * FROM users`;';\n const { templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const expressions = extractOriginalExpressions(templateNode.template);\n\n assert.strictEqual(expressions.length, 0);\n });\n\n await t.test('handles complex expressions', () => {\n const code =\n 'const q = sql`SELECT * FROM ${getTable()} WHERE id = ${user.id}`;';\n const { templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const expressions = extractOriginalExpressions(templateNode.template);\n\n assert.strictEqual(expressions.length, 2);\n assert.strictEqual(expressions[0], '${getTable()}');\n assert.strictEqual(expressions[1], '${user.id}');\n });\n});\n\ntest('findTemplateNodeById Tests', async (t) => {\n await t.test('finds template node by location id', () => {\n const code = 'const q = sql`SELECT * FROM users`;';\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n\n // Get the expected location ID\n const start = sourceFile.getLineAndCharacterOfPosition(\n templateNode.template.getStart(),\n );\n const locationId = `test.ts:${start.line + 1}:${start.character + 1}`;\n\n const found = findTemplateNodeById(sourceFile, locationId);\n\n assert.ok(found);\n assert.strictEqual(found, templateNode);\n });\n\n await t.test('returns undefined for non-existent location id', () => {\n const code = 'const q = sql`SELECT * FROM users`;';\n const { sourceFile } = createSourceFileWithSqlTemplate(code);\n\n const found = findTemplateNodeById(sourceFile, 'test.ts:999:999');\n\n assert.strictEqual(found, undefined);\n });\n\n await t.test('ignores non-sql tagged templates', () => {\n const code = 'const q = html`<div>Hello</div>`;';\n const sourceFile = ts.createSourceFile(\n 'test.ts',\n code,\n ts.ScriptTarget.Latest,\n true,\n );\n\n const found = findTemplateNodeById(sourceFile, 'test.ts:1:15');\n\n assert.strictEqual(found, undefined);\n });\n});\n\ntest('createFormatSqlEdit Tests', async (t) => {\n await t.test('creates edit for simple SQL template', () => {\n const code = 'const q = sql`select * from users`;';\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const edit = createFormatSqlEdit(sourceFile, templateNode);\n\n assert.ok(edit);\n assert.ok(edit.newText.includes('SELECT'));\n assert.ok(edit.newText.includes('FROM'));\n });\n\n await t.test('preserves placeholders in formatted output', () => {\n const code = 'const q = sql`select ${col} from ${table}`;';\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const edit = createFormatSqlEdit(sourceFile, templateNode);\n\n assert.ok(edit);\n assert.ok(edit.newText.includes('${col}'));\n assert.ok(edit.newText.includes('${table}'));\n });\n\n await t.test('returns undefined for invalid SQL', () => {\n const code = 'const q = sql`SELCT * FROM users`;';\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const edit = createFormatSqlEdit(sourceFile, templateNode);\n\n assert.strictEqual(edit, undefined);\n });\n\n await t.test('preserves indentation for multiline template', () => {\n const code = `const q = sql\\`\n select * from users\n \\`;`;\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const edit = createFormatSqlEdit(sourceFile, templateNode);\n\n assert.ok(edit);\n // Should start with newline (preserving original structure)\n assert.ok(edit.newText.startsWith('\\n'), 'Should start with newline');\n // Should have indentation on content lines\n assert.ok(\n edit.newText.includes(' SELECT'),\n 'Should preserve 6-space indent',\n );\n });\n\n await t.test('preserves trailing newline and closing indent', () => {\n const code = `const q = sql\\`\n select * from users\n \\`;`;\n const { sourceFile, templateNode } = createSourceFileWithSqlTemplate(code);\n\n assert.ok(templateNode);\n const edit = createFormatSqlEdit(sourceFile, templateNode);\n\n assert.ok(edit);\n // Should end with newline + trailing indent (4 spaces before backtick)\n assert.ok(\n edit.newText.endsWith('\\n '),\n 'Should end with newline and 4-space indent',\n );\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAmB;AACnB,uBAAqB;AACrB,wBAAe;AACf,yBAKO;AAAA,IAGP,uBAAK,mCAAmC,OAAO,MAAM;AACnD,QAAM,YAA2B;AAAA,IAC/B;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,WAAW;AAAA,MACX,cAAc;AAAA,IAChB;AAAA,IACA;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,WAAW;AAAA,MACX,cAAc;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,EAAE,KAAK,wCAAwC,MAAM;AAEzD,UAAM,aAAS,8CAA0B,WAAW,GAAG,EAAE;AAEzD,uBAAAA,QAAO,GAAG,MAAM;AAChB,uBAAAA,QAAO,YAAY,OAAO,IAAI,cAAc;AAAA,EAC9C,CAAC;AAED,QAAM,EAAE,KAAK,kDAAkD,MAAM;AAEnE,UAAM,aAAS,8CAA0B,WAAW,IAAI,CAAC;AAEzD,uBAAAA,QAAO,GAAG,MAAM;AAChB,uBAAAA,QAAO,YAAY,OAAO,IAAI,cAAc;AAAA,EAC9C,CAAC;AAED,QAAM,EAAE,KAAK,0DAA0D,MAAM;AAE3E,UAAM,aAAS,8CAA0B,WAAW,GAA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AAM,EAAE,YAAY,aAAa,IAAI,gCAAgC,IAAI;AAEzE,uBAAAA,QAAO,GAAG,YAAY;AACtB,UAAM,WAAO,wCAAoB,YAAY,YAAY;AAEzD,uBAAAA,QAAO,GAAG,IAAI;AAEd,uBAAAA,QAAO,GAAG,KAAK,QAAQ,WAAW,IAAI,GAAG,2BAA2B;AAEpE,uBAAAA,QAAO;AAAA,MACL,KAAK,QAAQ,SAAS,cAAc;AAAA,MACpC;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,EAAE,KAAK,iDAAiD,MAAM;AAClE,UAAM,OAAO;AAAA;AAAA;AAGb,UAAM,EAAE,YAAY,aAAa,IAAI,gCAAgC,IAAI;AAEzE,uBAAAA,QAAO,GAAG,YAAY;AACtB,UAAM,WAAO,wCAAoB,YAAY,YAAY;AAEzD,uBAAAA,QAAO,GAAG,IAAI;AAEd,uBAAAA,QAAO;AAAA,MACL,KAAK,QAAQ,SAAS,QAAQ;AAAA,MAC9B;AAAA,IACF;AAAA,EACF,CAAC;AACH,CAAC;","names":["assert","ts"]}
@@ -0,0 +1,22 @@
1
+ import { CompletionItem } from 'vscode-languageserver/node';
2
+ import { ClickHouseData } from './clickhouseData.js';
3
+
4
+ /**
5
+ * Options for generating completion items.
6
+ */
7
+ interface CompletionOptions {
8
+ /** Whether the client supports snippet format (default: true for backward compat) */
9
+ useSnippets?: boolean;
10
+ }
11
+ declare function generateCompletionItems(data: ClickHouseData, options?: CompletionOptions): CompletionItem[];
12
+ /**
13
+ * Filters completion items based on the current word prefix.
14
+ * Uses case-insensitive prefix matching.
15
+ */
16
+ declare function filterCompletions(items: CompletionItem[], prefix: string): CompletionItem[];
17
+ /**
18
+ * Clears the completion cache. Useful for testing or when data is reloaded.
19
+ */
20
+ declare function clearCompletionCache(): void;
21
+
22
+ export { type CompletionOptions, clearCompletionCache, filterCompletions, generateCompletionItems };