@xano/xanoscript-language-server 11.6.3 → 11.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/xanoscript-language-server",
3
- "version": "11.6.3",
3
+ "version": "11.6.4",
4
4
  "description": "Language Server Protocol implementation for XanoScript",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -3,6 +3,7 @@ import { LCurly, RCurly } from "../lexer/control.js";
3
3
  import { FunctionToken } from "../lexer/function.js";
4
4
  import { StringLiteral } from "../lexer/literal.js";
5
5
  import { Identifier, NewlineToken } from "../lexer/tokens.js";
6
+ import { getVarName } from "./generic/utils.js";
6
7
 
7
8
  export function functionDeclaration($) {
8
9
  return () => {
@@ -22,10 +23,15 @@ export function functionDeclaration($) {
22
23
  // Allow leading comments and newlines before the function declaration
23
24
  $.SUBRULE($.optionalCommentBlockFn);
24
25
  const parent = $.CONSUME(FunctionToken);
25
- $.OR([
26
+ const nameToken = $.OR([
26
27
  { ALT: () => $.CONSUME(Identifier) },
27
28
  { ALT: () => $.CONSUME(StringLiteral) },
28
29
  ]);
30
+
31
+ if (nameToken?.image && getVarName(nameToken).startsWith("/")) {
32
+ $.addInvalidValueError(nameToken, "function name must not start with '/'");
33
+ }
34
+
29
35
  $.CONSUME(LCurly); // "{"
30
36
  $.MANY(() => {
31
37
  $.AT_LEAST_ONE(() => $.CONSUME(NewlineToken)); // at least one new line
@@ -16,6 +16,19 @@ describe("function_parser", () => {
16
16
  expect(parser.errors).to.be.empty;
17
17
  });
18
18
 
19
+ it("should raise an error when a function name starts with /", () => {
20
+ const parser = xanoscriptParser(`function "/foo" {
21
+ input {
22
+ }
23
+
24
+ stack {
25
+ }
26
+
27
+ response = null
28
+ }`);
29
+ expect(parser.errors).to.not.be.empty;
30
+ });
31
+
19
32
  it("should parse a function with a test", () => {
20
33
  const parser = xanoscriptParser(`function foo {
21
34
  input {
@@ -37,10 +37,15 @@ export function queryDeclaration($) {
37
37
  $.SUBRULE($.optionalCommentBlockFn);
38
38
 
39
39
  const parent = $.CONSUME(QueryToken);
40
- $.OR([
40
+ const nameToken = $.OR([
41
41
  { ALT: () => $.CONSUME(StringLiteral) }, // "foo/bar"
42
42
  { ALT: () => $.CONSUME(Identifier) }, // foo
43
43
  ]);
44
+
45
+ if (nameToken?.image && getVarName(nameToken).startsWith("/")) {
46
+ $.addInvalidValueError(nameToken, "query name must not start with '/'");
47
+ }
48
+
44
49
  $.CONSUME(VerbToken);
45
50
  $.CONSUME(EqualToken);
46
51
  $.OR1([
@@ -16,6 +16,19 @@ describe("query_parser", () => {
16
16
  expect(parser.errors).to.be.empty;
17
17
  });
18
18
 
19
+ it("should raise an error when a query starts with /", () => {
20
+ const parser = xanoscriptParser(`query "/foo" verb=GET {
21
+ input {
22
+ }
23
+
24
+ stack {
25
+ }
26
+
27
+ response = null
28
+ }`);
29
+ expect(parser.errors).to.not.be.empty;
30
+ });
31
+
19
32
  it("should accept an api_group", () => {
20
33
  const parser = xanoscriptParser(`query foo verb=GET {
21
34
  api_group = "Authentication";
@@ -36,7 +36,7 @@ export function runJobClause($) {
36
36
  {
37
37
  main: {
38
38
  name: "[string]",
39
- input: { "[string]?": "[constant]" },
39
+ "input?": { "[string]?": "[constant]" },
40
40
  },
41
41
  "env?": ["[string]"],
42
42
  },
@@ -5,7 +5,7 @@ import { xanoscriptParser } from "./parser.js";
5
5
  describe("run", () => {
6
6
  it("should parse a basic run.job", () => {
7
7
  const parser = xanoscriptParser(`run.job "Average of values" {
8
- main = {name: "avg_value", input: {}}
8
+ main = {name: "avg_value"}
9
9
  }`);
10
10
  expect(parser.errors).to.be.empty;
11
11
  });