@xano/xanoscript-language-server 11.8.4 → 11.9.0

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 (59) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/cache/documentCache.js +58 -10
  3. package/lexer/comment.js +14 -24
  4. package/lexer/db.js +1 -2
  5. package/lexer/security.js +16 -0
  6. package/onCompletion/onCompletion.js +61 -1
  7. package/onDefinition/onDefinition.js +150 -0
  8. package/onDefinition/onDefinition.spec.js +313 -0
  9. package/onDidChangeContent/onDidChangeContent.js +53 -6
  10. package/onHover/functions.md +28 -0
  11. package/package.json +1 -1
  12. package/parser/base_parser.js +61 -3
  13. package/parser/clauses/middlewareClause.js +16 -0
  14. package/parser/definitions/columnDefinition.js +5 -0
  15. package/parser/functions/api/apiCallFn.js +5 -3
  16. package/parser/functions/controls/functionCallFn.js +5 -3
  17. package/parser/functions/controls/functionRunFn.js +61 -5
  18. package/parser/functions/controls/taskCallFn.js +5 -3
  19. package/parser/functions/db/captureFieldName.js +63 -0
  20. package/parser/functions/db/dbAddFn.js +5 -3
  21. package/parser/functions/db/dbAddOrEditFn.js +13 -3
  22. package/parser/functions/db/dbBulkAddFn.js +5 -3
  23. package/parser/functions/db/dbBulkDeleteFn.js +5 -3
  24. package/parser/functions/db/dbBulkPatchFn.js +5 -3
  25. package/parser/functions/db/dbBulkUpdateFn.js +5 -3
  26. package/parser/functions/db/dbDelFn.js +10 -3
  27. package/parser/functions/db/dbEditFn.js +13 -3
  28. package/parser/functions/db/dbGetFn.js +10 -3
  29. package/parser/functions/db/dbHasFn.js +9 -3
  30. package/parser/functions/db/dbPatchFn.js +10 -3
  31. package/parser/functions/db/dbQueryFn.js +29 -3
  32. package/parser/functions/db/dbSchemaFn.js +5 -3
  33. package/parser/functions/db/dbTruncateFn.js +5 -3
  34. package/parser/functions/middlewareCallFn.js +3 -1
  35. package/parser/functions/security/register.js +19 -9
  36. package/parser/functions/security/securityCreateAuthTokenFn.js +22 -0
  37. package/parser/functions/security/securityJweDecodeLegacyFn.js +24 -0
  38. package/parser/functions/security/securityJweDecodeLegacyFn.spec.js +26 -0
  39. package/parser/functions/security/securityJweEncodeLegacyFn.js +24 -0
  40. package/parser/functions/security/securityJweEncodeLegacyFn.spec.js +25 -0
  41. package/parser/functions/securityFn.js +2 -0
  42. package/parser/functions/varFn.js +1 -1
  43. package/parser/generic/asVariable.js +2 -0
  44. package/parser/generic/assignableVariableAs.js +1 -0
  45. package/parser/generic/assignableVariableProperty.js +5 -2
  46. package/parser/task_parser.js +2 -1
  47. package/parser/tests/task/valid_sources/create_leak.xs +165 -0
  48. package/parser/tests/variable_test/coverage_check.xs +293 -0
  49. package/parser/variableScanner.js +64 -0
  50. package/parser/variableValidator.js +44 -0
  51. package/parser/variableValidator.spec.js +179 -0
  52. package/server.js +206 -18
  53. package/utils.js +32 -0
  54. package/utils.spec.js +93 -1
  55. package/workspace/crossFileValidator.js +166 -0
  56. package/workspace/crossFileValidator.spec.js +654 -0
  57. package/workspace/referenceTracking.spec.js +420 -0
  58. package/workspace/workspaceIndex.js +149 -0
  59. package/workspace/workspaceIndex.spec.js +189 -0
@@ -0,0 +1,654 @@
1
+ import { expect } from "chai";
2
+ import { beforeEach, describe, it } from "mocha";
3
+ import { xanoscriptParser } from "../parser/parser.js";
4
+ import { getSchemeFromContent } from "../utils.js";
5
+ import { crossFileValidate } from "./crossFileValidator.js";
6
+ import { WorkspaceIndex } from "./workspaceIndex.js";
7
+
8
+ /**
9
+ * Helper to add a file with pre-parsed inputs (simulates what onDidChangeContent does).
10
+ */
11
+ function addWithInputs(index, uri, content) {
12
+ const scheme = getSchemeFromContent(content);
13
+ const parser = xanoscriptParser(content, scheme);
14
+ return index.addParsed(uri, content, parser.__symbolTable);
15
+ }
16
+
17
+ describe("crossFileValidator", () => {
18
+ let index;
19
+
20
+ beforeEach(() => {
21
+ index = new WorkspaceIndex();
22
+ index.addFile("file:///ws/users.xs", "table users {\n}");
23
+ index.addFile("file:///ws/helper.xs", 'function "helper" {\n}');
24
+ index.addFile("file:///ws/cleanup.xs", 'task "cleanup" {\n}');
25
+ index.addFile(
26
+ "file:///ws/get_user.xs",
27
+ 'query "/users/{user_id}" GET {\n}'
28
+ );
29
+ });
30
+
31
+ it("should return no warnings for valid references", () => {
32
+ const references = [
33
+ { refType: "table", name: "users", startOffset: 50, endOffset: 55 },
34
+ {
35
+ refType: "function",
36
+ name: "helper",
37
+ startOffset: 100,
38
+ endOffset: 108,
39
+ },
40
+ ];
41
+ const warnings = crossFileValidate(references, index);
42
+ expect(warnings).to.be.empty;
43
+ });
44
+
45
+ it("should return warning for unknown function reference", () => {
46
+ const references = [
47
+ {
48
+ refType: "function",
49
+ name: "nonexistent",
50
+ startOffset: 50,
51
+ endOffset: 63,
52
+ },
53
+ ];
54
+ const warnings = crossFileValidate(references, index);
55
+ expect(warnings).to.have.length(1);
56
+ expect(warnings[0].message).to.include("nonexistent");
57
+ expect(warnings[0].message).to.include("function");
58
+ expect(warnings[0].startOffset).to.equal(50);
59
+ expect(warnings[0].endOffset).to.equal(63);
60
+ });
61
+
62
+ it("should return warning for unknown table reference", () => {
63
+ const references = [
64
+ { refType: "table", name: "orders", startOffset: 30, endOffset: 36 },
65
+ ];
66
+ const warnings = crossFileValidate(references, index);
67
+ expect(warnings).to.have.length(1);
68
+ expect(warnings[0].message).to.include("orders");
69
+ expect(warnings[0].message).to.include("table");
70
+ });
71
+
72
+ it("should return warning for unknown task reference", () => {
73
+ const references = [
74
+ {
75
+ refType: "task",
76
+ name: "missing_task",
77
+ startOffset: 30,
78
+ endOffset: 44,
79
+ },
80
+ ];
81
+ const warnings = crossFileValidate(references, index);
82
+ expect(warnings).to.have.length(1);
83
+ expect(warnings[0].message).to.include("missing_task");
84
+ });
85
+
86
+ it("should return multiple warnings for multiple unknown references", () => {
87
+ const references = [
88
+ { refType: "table", name: "users", startOffset: 30, endOffset: 35 },
89
+ {
90
+ refType: "function",
91
+ name: "bad_func",
92
+ startOffset: 50,
93
+ endOffset: 60,
94
+ },
95
+ {
96
+ refType: "table",
97
+ name: "bad_table",
98
+ startOffset: 70,
99
+ endOffset: 80,
100
+ },
101
+ ];
102
+ const warnings = crossFileValidate(references, index);
103
+ expect(warnings).to.have.length(2);
104
+ });
105
+
106
+ it("should suggest 'did you mean' for similar function names", () => {
107
+ const references = [
108
+ { refType: "function", name: "helpr", startOffset: 50, endOffset: 55 },
109
+ ];
110
+ const warnings = crossFileValidate(references, index);
111
+ expect(warnings).to.have.length(1);
112
+ expect(warnings[0].message).to.include("helpr");
113
+ expect(warnings[0].message).to.include("Did you mean");
114
+ expect(warnings[0].message).to.include("helper");
115
+ });
116
+
117
+ it("should suggest 'did you mean' for similar table names", () => {
118
+ const references = [
119
+ { refType: "table", name: "user", startOffset: 30, endOffset: 34 },
120
+ ];
121
+ const warnings = crossFileValidate(references, index);
122
+ expect(warnings).to.have.length(1);
123
+ expect(warnings[0].message).to.include("Did you mean");
124
+ expect(warnings[0].message).to.include("users");
125
+ });
126
+
127
+ it("should suggest 'did you mean' when input is a prefix of a candidate", () => {
128
+ index.addFile(
129
+ "file:///ws/seed_vehicles.xs",
130
+ 'function seed_vehicles {\n stack {}\n}'
131
+ );
132
+ const references = [
133
+ {
134
+ refType: "function",
135
+ name: "seed_veh",
136
+ startOffset: 50,
137
+ endOffset: 58,
138
+ },
139
+ ];
140
+ const warnings = crossFileValidate(references, index);
141
+ expect(warnings).to.have.length(1);
142
+ expect(warnings[0].message).to.include("Did you mean");
143
+ expect(warnings[0].message).to.include("seed_vehicles");
144
+ });
145
+
146
+ it("should not suggest 'did you mean' for completely different resource names", () => {
147
+ const references = [
148
+ {
149
+ refType: "function",
150
+ name: "xyzzy_foobar",
151
+ startOffset: 50,
152
+ endOffset: 62,
153
+ },
154
+ ];
155
+ const warnings = crossFileValidate(references, index);
156
+ expect(warnings).to.have.length(1);
157
+ expect(warnings[0].message).to.not.include("Did you mean");
158
+ });
159
+
160
+ it("should return empty array for empty references", () => {
161
+ const warnings = crossFileValidate([], index);
162
+ expect(warnings).to.be.empty;
163
+ });
164
+
165
+ it("should warn about empty function reference", () => {
166
+ const references = [
167
+ { refType: "function", name: "", startOffset: 50, endOffset: 52 },
168
+ ];
169
+ const warnings = crossFileValidate(references, index);
170
+ expect(warnings).to.have.length(1);
171
+ expect(warnings[0].message).to.equal("Empty function reference");
172
+ });
173
+
174
+ it("should warn about empty table reference", () => {
175
+ const references = [
176
+ { refType: "table", name: "", startOffset: 50, endOffset: 52 },
177
+ ];
178
+ const warnings = crossFileValidate(references, index);
179
+ expect(warnings).to.have.length(1);
180
+ expect(warnings[0].message).to.equal("Empty table reference");
181
+ });
182
+
183
+ it("should return empty array for null/undefined references", () => {
184
+ expect(crossFileValidate(null, index)).to.deep.equal([]);
185
+ expect(crossFileValidate(undefined, index)).to.deep.equal([]);
186
+ });
187
+
188
+ describe("function input key validation", () => {
189
+ beforeEach(() => {
190
+ // Re-add helper with declared inputs (using addParsed for input resolution)
191
+ addWithInputs(
192
+ index,
193
+ "file:///ws/helper.xs",
194
+ `function "helper" {
195
+ input {
196
+ int user_id
197
+ text name
198
+ }
199
+ stack {}
200
+ }`
201
+ );
202
+ });
203
+
204
+ it("should return no warnings when args match declared inputs", () => {
205
+ const references = [
206
+ {
207
+ refType: "function",
208
+ name: "helper",
209
+ startOffset: 50,
210
+ endOffset: 56,
211
+ args: { user_id: { value: null }, name: { value: null } },
212
+ },
213
+ ];
214
+ const warnings = crossFileValidate(references, index);
215
+ expect(warnings).to.be.empty;
216
+ });
217
+
218
+ it("should warn about unknown input keys", () => {
219
+ const references = [
220
+ {
221
+ refType: "function",
222
+ name: "helper",
223
+ startOffset: 50,
224
+ endOffset: 56,
225
+ args: {
226
+ user_id: { value: null },
227
+ bad_key: { value: null, startOffset: 80, endOffset: 87 },
228
+ },
229
+ },
230
+ ];
231
+ const warnings = crossFileValidate(references, index);
232
+ expect(warnings).to.have.length(1);
233
+ expect(warnings[0].message).to.include("bad_key");
234
+ expect(warnings[0].message).to.include("helper");
235
+ expect(warnings[0].startOffset).to.equal(80);
236
+ expect(warnings[0].endOffset).to.equal(87);
237
+ });
238
+
239
+ it("should suggest 'did you mean' for similar input keys", () => {
240
+ const references = [
241
+ {
242
+ refType: "function",
243
+ name: "helper",
244
+ startOffset: 50,
245
+ endOffset: 56,
246
+ args: {
247
+ usr_id: { value: null, startOffset: 80, endOffset: 86 },
248
+ },
249
+ },
250
+ ];
251
+ const warnings = crossFileValidate(references, index);
252
+ expect(warnings).to.have.length(1);
253
+ expect(warnings[0].message).to.include("usr_id");
254
+ expect(warnings[0].message).to.include("Did you mean");
255
+ expect(warnings[0].message).to.include("user_id");
256
+ });
257
+
258
+ it("should not suggest 'did you mean' for completely different keys", () => {
259
+ const references = [
260
+ {
261
+ refType: "function",
262
+ name: "helper",
263
+ startOffset: 50,
264
+ endOffset: 56,
265
+ args: {
266
+ zzzzzzz: { value: null, startOffset: 80, endOffset: 87 },
267
+ },
268
+ },
269
+ ];
270
+ const warnings = crossFileValidate(references, index);
271
+ expect(warnings).to.have.length(1);
272
+ expect(warnings[0].message).to.not.include("Did you mean");
273
+ });
274
+
275
+ it("should skip input validation when args is undefined", () => {
276
+ const references = [
277
+ {
278
+ refType: "function",
279
+ name: "helper",
280
+ startOffset: 50,
281
+ endOffset: 56,
282
+ },
283
+ ];
284
+ const warnings = crossFileValidate(references, index);
285
+ expect(warnings).to.be.empty;
286
+ });
287
+
288
+ it("should skip input validation when target has no declared inputs", () => {
289
+ // cleanup task has no inputs
290
+ const references = [
291
+ {
292
+ refType: "task",
293
+ name: "cleanup",
294
+ startOffset: 50,
295
+ endOffset: 57,
296
+ args: { some_key: { value: null, startOffset: 70, endOffset: 78 } },
297
+ },
298
+ ];
299
+ const warnings = crossFileValidate(references, index);
300
+ expect(warnings).to.be.empty;
301
+ });
302
+
303
+ it("should warn about multiple unknown input keys", () => {
304
+ const references = [
305
+ {
306
+ refType: "function",
307
+ name: "helper",
308
+ startOffset: 50,
309
+ endOffset: 56,
310
+ args: {
311
+ bad_one: { value: null, startOffset: 80, endOffset: 87 },
312
+ bad_two: { value: null, startOffset: 90, endOffset: 97 },
313
+ },
314
+ },
315
+ ];
316
+ const warnings = crossFileValidate(references, index);
317
+ expect(warnings).to.have.length(2);
318
+ });
319
+
320
+ it("should warn about type mismatch on literal values", () => {
321
+ const references = [
322
+ {
323
+ refType: "function",
324
+ name: "helper",
325
+ startOffset: 50,
326
+ endOffset: 56,
327
+ args: {
328
+ user_id: {
329
+ value: '"hello"',
330
+ type: "text",
331
+ startOffset: 80,
332
+ endOffset: 87,
333
+ },
334
+ },
335
+ },
336
+ ];
337
+ const warnings = crossFileValidate(references, index);
338
+ expect(warnings).to.have.length(1);
339
+ expect(warnings[0].message).to.include("user_id");
340
+ expect(warnings[0].message).to.include("int");
341
+ expect(warnings[0].message).to.include("text");
342
+ });
343
+
344
+ it("should not warn when passing text literal to enum input", () => {
345
+ addWithInputs(
346
+ index,
347
+ "file:///ws/with_enum.xs",
348
+ `function "with_enum" {
349
+ input {
350
+ enum to_status ["a", "b"]
351
+ }
352
+ stack {}
353
+ }`
354
+ );
355
+ const references = [
356
+ {
357
+ refType: "function",
358
+ name: "with_enum",
359
+ startOffset: 50,
360
+ endOffset: 56,
361
+ args: {
362
+ to_status: {
363
+ value: '"a"',
364
+ type: "text",
365
+ startOffset: 80,
366
+ endOffset: 83,
367
+ },
368
+ },
369
+ },
370
+ ];
371
+ const warnings = crossFileValidate(references, index);
372
+ expect(warnings).to.be.empty;
373
+ });
374
+
375
+ it("should not warn about type when value type is unknown", () => {
376
+ const references = [
377
+ {
378
+ refType: "function",
379
+ name: "helper",
380
+ startOffset: 50,
381
+ endOffset: 56,
382
+ args: {
383
+ user_id: { value: null, type: null, startOffset: 80, endOffset: 87 },
384
+ },
385
+ },
386
+ ];
387
+ const warnings = crossFileValidate(references, index);
388
+ expect(warnings).to.be.empty;
389
+ });
390
+
391
+ it("should not warn when types match", () => {
392
+ const references = [
393
+ {
394
+ refType: "function",
395
+ name: "helper",
396
+ startOffset: 50,
397
+ endOffset: 56,
398
+ args: {
399
+ user_id: { value: "42", type: "int", startOffset: 80, endOffset: 82 },
400
+ name: {
401
+ value: '"test"',
402
+ type: "text",
403
+ startOffset: 90,
404
+ endOffset: 96,
405
+ },
406
+ },
407
+ },
408
+ ];
409
+ const warnings = crossFileValidate(references, index);
410
+ expect(warnings).to.be.empty;
411
+ });
412
+ });
413
+
414
+ describe("field_name column validation", () => {
415
+ beforeEach(() => {
416
+ // Add a table with columns (using addParsed for input resolution)
417
+ addWithInputs(
418
+ index,
419
+ "file:///ws/users.xs",
420
+ `table users {
421
+ schema {
422
+ int id
423
+ text name
424
+ text email
425
+ }
426
+ }`
427
+ );
428
+ });
429
+
430
+ it("should return no warnings when field_name matches a column", () => {
431
+ const references = [
432
+ {
433
+ refType: "table",
434
+ name: "users",
435
+ startOffset: 30,
436
+ endOffset: 35,
437
+ fieldName: "id",
438
+ fieldNameStartOffset: 50,
439
+ fieldNameEndOffset: 52,
440
+ },
441
+ ];
442
+ const warnings = crossFileValidate(references, index);
443
+ expect(warnings).to.be.empty;
444
+ });
445
+
446
+ it("should warn when field_name does not match any column", () => {
447
+ const references = [
448
+ {
449
+ refType: "table",
450
+ name: "users",
451
+ startOffset: 30,
452
+ endOffset: 35,
453
+ fieldName: "username",
454
+ fieldNameStartOffset: 50,
455
+ fieldNameEndOffset: 58,
456
+ },
457
+ ];
458
+ const warnings = crossFileValidate(references, index);
459
+ expect(warnings).to.have.length(1);
460
+ expect(warnings[0].message).to.include("username");
461
+ expect(warnings[0].message).to.include("users");
462
+ expect(warnings[0].startOffset).to.equal(50);
463
+ expect(warnings[0].endOffset).to.equal(58);
464
+ });
465
+
466
+ it("should suggest 'did you mean' for similar column names", () => {
467
+ const references = [
468
+ {
469
+ refType: "table",
470
+ name: "users",
471
+ startOffset: 30,
472
+ endOffset: 35,
473
+ fieldName: "emal",
474
+ fieldNameStartOffset: 50,
475
+ fieldNameEndOffset: 54,
476
+ },
477
+ ];
478
+ const warnings = crossFileValidate(references, index);
479
+ expect(warnings).to.have.length(1);
480
+ expect(warnings[0].message).to.include("Did you mean");
481
+ expect(warnings[0].message).to.include("email");
482
+ });
483
+
484
+ it("should skip field_name validation when fieldName is undefined", () => {
485
+ const references = [
486
+ {
487
+ refType: "table",
488
+ name: "users",
489
+ startOffset: 30,
490
+ endOffset: 35,
491
+ },
492
+ ];
493
+ const warnings = crossFileValidate(references, index);
494
+ expect(warnings).to.be.empty;
495
+ });
496
+
497
+ it("should skip field_name validation when table has no columns", () => {
498
+ index.addFile("file:///ws/empty.xs", "table empty {\n}");
499
+ const references = [
500
+ {
501
+ refType: "table",
502
+ name: "empty",
503
+ startOffset: 30,
504
+ endOffset: 35,
505
+ fieldName: "id",
506
+ fieldNameStartOffset: 50,
507
+ fieldNameEndOffset: 52,
508
+ },
509
+ ];
510
+ const warnings = crossFileValidate(references, index);
511
+ expect(warnings).to.be.empty;
512
+ });
513
+
514
+ it("should not validate field_name for unknown tables", () => {
515
+ const references = [
516
+ {
517
+ refType: "table",
518
+ name: "orders",
519
+ startOffset: 30,
520
+ endOffset: 36,
521
+ fieldName: "id",
522
+ fieldNameStartOffset: 50,
523
+ fieldNameEndOffset: 52,
524
+ },
525
+ ];
526
+ const warnings = crossFileValidate(references, index);
527
+ // Should only get the "Unknown table" warning, not a column warning
528
+ expect(warnings).to.have.length(1);
529
+ expect(warnings[0].message).to.include("Unknown table");
530
+ });
531
+ });
532
+
533
+ describe("middleware reference validation", () => {
534
+ beforeEach(() => {
535
+ index.addFile(
536
+ "file:///ws/auth.xs",
537
+ 'middleware "auth_middle" {\n input {}\n stack {}\n response = null\n}'
538
+ );
539
+ });
540
+
541
+ it("should return no warnings for valid middleware references", () => {
542
+ const references = [
543
+ {
544
+ refType: "middleware",
545
+ name: "auth_middle",
546
+ startOffset: 50,
547
+ endOffset: 63,
548
+ },
549
+ ];
550
+ const warnings = crossFileValidate(references, index);
551
+ expect(warnings).to.be.empty;
552
+ });
553
+
554
+ it("should warn about unknown middleware references", () => {
555
+ const references = [
556
+ {
557
+ refType: "middleware",
558
+ name: "nonexistent_middle",
559
+ startOffset: 50,
560
+ endOffset: 68,
561
+ },
562
+ ];
563
+ const warnings = crossFileValidate(references, index);
564
+ expect(warnings).to.have.length(1);
565
+ expect(warnings[0].message).to.include("middleware");
566
+ expect(warnings[0].message).to.include("nonexistent_middle");
567
+ });
568
+
569
+ it("should suggest 'did you mean' for similar middleware names", () => {
570
+ const references = [
571
+ {
572
+ refType: "middleware",
573
+ name: "auth_middl",
574
+ startOffset: 50,
575
+ endOffset: 60,
576
+ },
577
+ ];
578
+ const warnings = crossFileValidate(references, index);
579
+ expect(warnings).to.have.length(1);
580
+ expect(warnings[0].message).to.include("Did you mean");
581
+ expect(warnings[0].message).to.include("auth_middle");
582
+ });
583
+ });
584
+
585
+ describe("data keys column validation", () => {
586
+ beforeEach(() => {
587
+ addWithInputs(
588
+ index,
589
+ "file:///ws/users.xs",
590
+ `table users {
591
+ schema {
592
+ int id
593
+ text name
594
+ text email
595
+ }
596
+ }`
597
+ );
598
+ });
599
+
600
+ it("should return no warnings when data keys match columns", () => {
601
+ const references = [
602
+ {
603
+ refType: "table",
604
+ name: "users",
605
+ startOffset: 30,
606
+ endOffset: 35,
607
+ dataKeys: [
608
+ { name: "name", startOffset: 60, endOffset: 64 },
609
+ { name: "email", startOffset: 70, endOffset: 75 },
610
+ ],
611
+ },
612
+ ];
613
+ const warnings = crossFileValidate(references, index);
614
+ expect(warnings).to.be.empty;
615
+ });
616
+
617
+ it("should warn about unknown data keys", () => {
618
+ const references = [
619
+ {
620
+ refType: "table",
621
+ name: "users",
622
+ startOffset: 30,
623
+ endOffset: 35,
624
+ dataKeys: [
625
+ { name: "username", startOffset: 60, endOffset: 68 },
626
+ ],
627
+ },
628
+ ];
629
+ const warnings = crossFileValidate(references, index);
630
+ expect(warnings).to.have.length(1);
631
+ expect(warnings[0].message).to.include("username");
632
+ expect(warnings[0].message).to.include("users");
633
+ expect(warnings[0].startOffset).to.equal(60);
634
+ });
635
+
636
+ it("should suggest 'did you mean' for similar data keys", () => {
637
+ const references = [
638
+ {
639
+ refType: "table",
640
+ name: "users",
641
+ startOffset: 30,
642
+ endOffset: 35,
643
+ dataKeys: [
644
+ { name: "emal", startOffset: 60, endOffset: 64 },
645
+ ],
646
+ },
647
+ ];
648
+ const warnings = crossFileValidate(references, index);
649
+ expect(warnings).to.have.length(1);
650
+ expect(warnings[0].message).to.include("Did you mean");
651
+ expect(warnings[0].message).to.include("email");
652
+ });
653
+ });
654
+ });