@xano/xanoscript-language-server 11.4.0 → 11.6.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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm test:*)",
5
+ "Bash(node -e:*)",
6
+ "Bash(node --input-type=module -e:*)",
7
+ "Bash(git checkout:*)",
8
+ "Bash(ls:*)"
9
+ ]
10
+ }
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/xanoscript-language-server",
3
- "version": "11.4.0",
3
+ "version": "11.6.0",
4
4
  "description": "Language Server Protocol implementation for XanoScript",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -250,18 +250,16 @@ export function agentDeclaration($) {
250
250
  $.CONSUME2(EqualToken); // "="
251
251
 
252
252
  // [{"name":"tool_name"}]
253
- $.SUBRULE($.arrayOfObjectAttrReq, {
253
+ $.SUBRULE($.schemaParseArrayFn, {
254
254
  ARGS: [
255
255
  subParent,
256
- ["name"], // required
257
- ["active", "auth"], // optional
258
- {
259
- types: {
260
- active: "boolean",
261
- auth: "string",
262
- name: "string",
256
+ [
257
+ {
258
+ name: "[string]",
259
+ "active?": "[boolean]",
260
+ "auth?": "[string]",
263
261
  },
264
- },
262
+ ],
265
263
  ],
266
264
  });
267
265
  },
@@ -59,27 +59,16 @@ export function apiGroupDeclaration($) {
59
59
 
60
60
  const subParent = $.CONSUME(CorsToken);
61
61
  $.CONSUME3(EqualToken); // "="
62
- $.SUBRULE($.objectAttrReq, {
62
+ $.SUBRULE($.schemaParseObjectFn, {
63
63
  ARGS: [
64
64
  subParent,
65
- [], // required
66
- [
67
- "mode",
68
- "origins",
69
- "methods",
70
- "headers",
71
- "credentials",
72
- "max_age",
73
- ], // optional
74
65
  {
75
- types: {
76
- mode: "string",
77
- origins: ($) => $.SUBRULE($.arrayOfStringLiterals),
78
- methods: ($) => $.SUBRULE1($.arrayOfStringLiterals),
79
- headers: ($) => $.SUBRULE2($.arrayOfStringLiterals),
80
- credentials: "boolean",
81
- max_age: "number",
82
- },
66
+ "mode?": "[string]",
67
+ "origins?": ["[string]"],
68
+ "methods?": ["[string]"],
69
+ "headers?": ["[string]"],
70
+ "credentials?": "[boolean]",
71
+ "max_age?": "[number]",
83
72
  },
84
73
  ],
85
74
  });
@@ -112,14 +101,12 @@ export function apiGroupDeclaration($) {
112
101
  hasSwagger = true;
113
102
  const subRule = $.CONSUME(SwaggerToken);
114
103
  $.CONSUME4(EqualToken); // "="
115
- $.SUBRULE2($.objectAttrReq, {
104
+ $.SUBRULE2($.schemaParseObjectFn, {
116
105
  ARGS: [
117
106
  subRule,
118
- [], // required
119
- ["active", "token"], // optional
120
107
  {
121
- active: "boolean",
122
- token: "string",
108
+ "active?": "[boolean]",
109
+ "token?": "[string]",
123
110
  },
124
111
  ],
125
112
  });
@@ -10,19 +10,18 @@ export function cacheClause($) {
10
10
  $.sectionStack.push("cacheClause");
11
11
  const parent = $.CONSUME(Cachetoken); // "cache"
12
12
  $.CONSUME(EqualToken); // "="
13
- $.SUBRULE($.objectAttrReq, {
13
+
14
+ $.SUBRULE($.schemaParseObjectFn, {
14
15
  ARGS: [
15
16
  parent,
16
- ["ttl", "input", "auth", "datasource", "ip"],
17
- ["headers", "env"],
18
17
  {
19
- types: {
20
- ttl: "number",
21
- input: "boolean",
22
- auth: "boolean",
23
- datasource: "boolean",
24
- ip: "boolean",
25
- },
18
+ ttl: "[number]",
19
+ input: "[boolean]",
20
+ auth: "[boolean]",
21
+ datasource: "[boolean]",
22
+ ip: "[boolean]",
23
+ "headers?": ["[string]"],
24
+ "env?": ["[string]"],
26
25
  },
27
26
  ],
28
27
  });
@@ -1,6 +1,4 @@
1
- import { EqualToken, LCurly, RCurly } from "../../../lexer/control.js";
2
1
  import { CreateAuthTokenToken } from "../../../lexer/security.js";
3
- import { Identifier, NewlineToken } from "../../../lexer/tokens.js";
4
2
 
5
3
  /**
6
4
  * @param {import('../../base_parser.js').XanoBaseParser} $
@@ -9,15 +7,21 @@ export function securityCreateAuthTokenFn($) {
9
7
  return () => {
10
8
  $.sectionStack.push("securityCreateAuthTokenFn");
11
9
  const fnToken = $.CONSUME(CreateAuthTokenToken); // "create_auth_token"
12
- $.CONSUME(LCurly); // "{"
13
- $.MANY(() => {
14
- $.AT_LEAST_ONE(() => $.CONSUME(NewlineToken));
15
- $.CONSUME1(Identifier); // "field_name"
16
- $.CONSUME(EqualToken); // "="
17
- $.SUBRULE($.expressionFn);
10
+
11
+ $.SUBRULE($.schemaParseAttributeFn, {
12
+ ARGS: [
13
+ fnToken,
14
+ {
15
+ extras: "[expression]",
16
+ table: "[expression]",
17
+ expiration: "[expression]",
18
+ id: "[expression]",
19
+ "description?": "[string]",
20
+ "disabled?": "[boolean]",
21
+ },
22
+ ],
18
23
  });
19
- $.MANY1(() => $.CONSUME1(NewlineToken));
20
- $.CONSUME(RCurly); // "}"
24
+
21
25
  $.SUBRULE($.asVariable, { ARGS: [fnToken] });
22
26
  $.sectionStack.pop();
23
27
  };
@@ -17,8 +17,35 @@ describe("securityCreateAuthTokenFn", () => {
17
17
  table = "empty"
18
18
  extras = {}
19
19
  expiration = 86400
20
- id = ""
20
+ id = $user.id
21
21
  } as $authToken`);
22
22
  expect(parser.errors).to.be.empty;
23
23
  });
24
+
25
+ it("securityCreateAuthTokenFn requires an expiration attribute", () => {
26
+ const parser = parse(`create_auth_token {
27
+ table = "empty"
28
+ extras = {}
29
+ id = $user.id
30
+ } as $authToken`);
31
+ expect(parser.errors).to.not.be.empty;
32
+ });
33
+
34
+ it("securityCreateAuthTokenFn requires an extra attribute", () => {
35
+ const parser = parse(`create_auth_token {
36
+ table = "empty"
37
+ expiration = 86400
38
+ id = $user.id
39
+ } as $authToken`);
40
+ expect(parser.errors).to.not.be.empty;
41
+ });
42
+
43
+ it("securityCreateAuthTokenFn requires a table attribute", () => {
44
+ const parser = parse(`create_auth_token {
45
+ expiration = 86400
46
+ id = $user.id
47
+ extras = {"role": "admin"}
48
+ } as $authToken`);
49
+ expect(parser.errors).to.not.be.empty;
50
+ });
24
51
  });
@@ -1,5 +1,3 @@
1
- import { arrayOfObjectAttrReq } from "./arrayOfObjectAttrReq.js";
2
- import { arrayOfStringLiterals } from "./arrayOfStringLiterals.js";
3
1
  import { arrayWithValues } from "./arrayWithValues.js";
4
2
  import { assignableVariableAs } from "./assignableVariableAs.js";
5
3
  import { assignableVariableProperty } from "./assignableVariableProperty.js";
@@ -28,7 +26,6 @@ import { minimalFnBody } from "./minimalFnBody.js";
28
26
  import { mockAttribute } from "./mockAttribute.js";
29
27
  import { multilineFilterFn } from "./multilineFilterFn.js";
30
28
  import { numberValue } from "./numberValue.js";
31
- import { objectAttrReq } from "./objectAttrReq.js";
32
29
  import { objectWithAttributes } from "./objectWithAttributes.js";
33
30
  import {
34
31
  commentBlockFn,
@@ -48,29 +45,21 @@ import { variableOnly } from "./variableOnly.js";
48
45
  */
49
46
  export const register = ($) => {
50
47
  $.mockAttribute = $.RULE("mockAttribute", mockAttribute($));
51
- $.arrayOfObjectAttrReq = $.RULE(
52
- "arrayOfObjectAttrReq",
53
- arrayOfObjectAttrReq($)
54
- );
55
- $.arrayOfStringLiterals = $.RULE(
56
- "arrayOfStringLiterals",
57
- arrayOfStringLiterals($)
58
- );
59
48
  $.arrayWithValues = $.RULE("arrayWithValues", arrayWithValues($));
60
49
  $.assignableVariableAs = $.RULE(
61
50
  "assignableVariableAs",
62
- assignableVariableAs($)
51
+ assignableVariableAs($),
63
52
  );
64
53
  $.assignableVariableProperty = $.RULE(
65
54
  "assignableVariableProperty",
66
- assignableVariableProperty($)
55
+ assignableVariableProperty($),
67
56
  );
68
57
  $.booleanValue = $.RULE("booleanValue", booleanValue($));
69
58
  $.castedValue = $.RULE("castedValue", castedValue($));
70
59
  $.chainedIdentifier = $.RULE("chainedIdentifier", chainedIdentifier($));
71
60
  $.singleChainedIdentifier = $.RULE(
72
61
  "singleChainedIdentifier",
73
- singleChainedIdentifier($)
62
+ singleChainedIdentifier($),
74
63
  );
75
64
  $.enumValue = $.RULE("enumValue", enumValue($));
76
65
  $.expressionFn = $.RULE("expressionFn", expressionFn($));
@@ -82,10 +71,9 @@ export const register = ($) => {
82
71
  $.longFormVariable = $.RULE("longFormVariable", longFormVariable($));
83
72
  $.minimalFnBody = $.RULE("minimalFnBody", minimalFnBody($));
84
73
  $.numberValue = $.RULE("numberValue", numberValue($));
85
- $.objectAttrReq = $.RULE("objectAttrReq", objectAttrReq($));
86
74
  $.objectWithAttributes = $.RULE(
87
75
  "objectWithAttributes",
88
- objectWithAttributes($)
76
+ objectWithAttributes($),
89
77
  );
90
78
  $.pipedFilter = $.RULE("pipedFilter", pipedFilter($));
91
79
  $.requiredValueFnBody = $.RULE("requiredValueFnBody", requiredValueFnBody($));
@@ -94,31 +82,31 @@ export const register = ($) => {
94
82
  $.tagsAttribute = $.RULE("tagsAttribute", tagsAttribute($));
95
83
  $.expressionFnForResponse = $.RULE(
96
84
  "valueExpressionForResponse",
97
- valueExpressionForResponse($)
85
+ valueExpressionForResponse($),
98
86
  );
99
87
  $.variableOnly = $.RULE("variableOnly", variableOnly($));
100
88
  $.completeAuthVariable = $.RULE(
101
89
  "completeAuthVariable",
102
- completeAuthVariable($)
90
+ completeAuthVariable($),
103
91
  );
104
92
  $.bracketAccessor = $.RULE("bracketAccessor", bracketAccessor($));
105
93
  $.bracketArrayAccessor = $.RULE(
106
94
  "bracketArrayAccessor",
107
- bracketArrayAccessor($)
95
+ bracketArrayAccessor($),
108
96
  );
109
97
  $.completeInputVariable = $.RULE(
110
98
  "completeInputVariable",
111
- completeInputVariable($)
99
+ completeInputVariable($),
112
100
  );
113
101
  $.completeErrorVariable = $.RULE(
114
102
  "completeErrorVariable",
115
- completeErrorVariable($)
103
+ completeErrorVariable($),
116
104
  );
117
105
  $.completeEnvVariable = $.RULE("completeEnvVariable", completeEnvVariable($));
118
106
  $.asVariable = $.RULE("asVariable", asVariable($));
119
107
  $.optionalCommentBlockFn = $.RULE(
120
108
  "optionalCommentBlockFn",
121
- optionalCommentBlockFn($)
109
+ optionalCommentBlockFn($),
122
110
  );
123
111
  $.commentBlockFn = $.RULE("commentBlockFn", commentBlockFn($));
124
112
  };
@@ -99,18 +99,16 @@ export function mcpServerDeclaration($) {
99
99
  $.CONSUME2(EqualToken); // "="
100
100
 
101
101
  // [{"name":"tool_name"}]
102
- $.SUBRULE($.arrayOfObjectAttrReq, {
102
+ $.SUBRULE($.schemaParseArrayFn, {
103
103
  ARGS: [
104
104
  subParent,
105
- ["name"], // required
106
- ["active", "auth"], // optional
107
- {
108
- types: {
109
- active: "boolean",
110
- auth: "string",
111
- name: "string",
105
+ [
106
+ {
107
+ name: "[string]",
108
+ "active?": "[boolean]",
109
+ "auth?": "[string]",
112
110
  },
113
- },
111
+ ],
114
112
  ],
115
113
  });
116
114
  },
@@ -43,15 +43,11 @@ export function mcpServerTriggerDeclaration($) {
43
43
  const subParent = $.CONSUME(ActionsToken); // "actions"
44
44
  $.CONSUME(EqualToken); // "="
45
45
 
46
- $.SUBRULE($.objectAttrReq, {
46
+ $.SUBRULE($.schemaParseObjectFn, {
47
47
  ARGS: [
48
48
  subParent,
49
- ["connection"],
50
- [],
51
49
  {
52
- types: {
53
- connection: "boolean",
54
- },
50
+ connection: "[boolean]",
55
51
  },
56
52
  ],
57
53
  });
@@ -41,16 +41,12 @@ export function realtimeTriggerDeclaration($) {
41
41
  const subParent = $.CONSUME(ActionsToken); // "actions"
42
42
  $.CONSUME(EqualToken); // "="
43
43
 
44
- $.SUBRULE($.objectAttrReq, {
44
+ $.SUBRULE($.schemaParseObjectFn, {
45
45
  ARGS: [
46
46
  subParent,
47
- [], // required
48
- ["join", "message"], // optional
49
47
  {
50
- types: {
51
- join: "boolean",
52
- message: "boolean",
53
- },
48
+ "join?": "[boolean]",
49
+ "message?": "[boolean]",
54
50
  },
55
51
  ],
56
52
  });
@@ -44,18 +44,14 @@ export function tableTriggerDeclaration($) {
44
44
  const subParent = $.CONSUME(ActionsToken); // "actions"
45
45
  $.CONSUME(EqualToken); // "="
46
46
 
47
- $.SUBRULE($.objectAttrReq, {
47
+ $.SUBRULE($.schemaParseObjectFn, {
48
48
  ARGS: [
49
49
  subParent,
50
- [], // required
51
- ["delete", "insert", "truncate", "update"], // optional
52
50
  {
53
- types: {
54
- delete: "boolean",
55
- insert: "boolean",
56
- truncate: "boolean",
57
- update: "boolean",
58
- },
51
+ "delete?": "[boolean]",
52
+ "insert?": "[boolean]",
53
+ "truncate?": "[boolean]",
54
+ "update?": "[boolean]",
59
55
  },
60
56
  ],
61
57
  });
@@ -74,9 +70,11 @@ export function tableTriggerDeclaration($) {
74
70
  GATE: () => !hasDatasources,
75
71
  ALT: () => {
76
72
  hasDatasources = true;
77
- $.CONSUME(DatasourcesToken);
73
+ const parent = $.CONSUME(DatasourcesToken);
78
74
  $.CONSUME3(EqualToken);
79
- $.SUBRULE($.arrayOfStringLiterals);
75
+ $.SUBRULE($.schemaFn, {
76
+ ARGS: [parent, ["[string]"]],
77
+ });
80
78
  },
81
79
  },
82
80
  {
@@ -7,9 +7,7 @@ import { parserExtension as schemaParseConstantFnExtension } from "./functions/s
7
7
  import { parserExtension as schemaParseEnumFnExtension } from "./functions/schema/schemaParseEnum.spec.js";
8
8
  import { parserExtension as schemaParseImmutableFnExtension } from "./functions/schema/schemaParseImmutableFn.spec.js";
9
9
  import { parserExtension as schemaParseObjectFnExtension } from "./functions/schema/schemaParseObjectFn.spec.js";
10
- import { parserExtension as arrayOfObjectAttrReqExtension } from "./generic/arrayOfObjectAttrReq.spec.js";
11
10
  import { parserExtension as functionAttrReqExtension } from "./generic/functionAttrReq.spec.js";
12
- import { parserExtension as objectAttrReqExtension } from "./generic/objectAttrReq.spec.js";
13
11
  import { parserExtension as objectWithAttributesExtension } from "./generic/objectWithAttributes.spec.js";
14
12
 
15
13
  /**
@@ -26,9 +24,7 @@ class TestParser extends XanoBaseParser {
26
24
  schemaParseObjectFnExtension.bind(this)();
27
25
  schemaParseEnumFnExtension.bind(this)();
28
26
  schemaParseImmutableFnExtension.bind(this)();
29
- arrayOfObjectAttrReqExtension.bind(this)();
30
27
  functionAttrReqExtension.bind(this)();
31
- objectAttrReqExtension.bind(this)();
32
28
  objectWithAttributesExtension.bind(this)();
33
29
  schemaParseAttributeFnExtension.bind(this)();
34
30
 
@@ -39,17 +39,13 @@ export function workspaceTriggerDeclaration($) {
39
39
  const subParent = $.CONSUME(ActionsToken); // "actions"
40
40
  $.CONSUME(EqualToken); // "="
41
41
 
42
- $.SUBRULE($.objectAttrReq, {
42
+ $.SUBRULE($.schemaParseObjectFn, {
43
43
  ARGS: [
44
44
  subParent,
45
- [], // required
46
- ["branch_live", "branch_merge", "branch_new"], // optional
47
45
  {
48
- types: {
49
- branch_live: "boolean",
50
- branch_merge: "boolean",
51
- branch_new: "boolean",
52
- },
46
+ "branch_live?": "[boolean]",
47
+ "branch_merge?": "[boolean]",
48
+ "branch_new?": "[boolean]",
53
49
  },
54
50
  ],
55
51
  });
@@ -1,47 +0,0 @@
1
- import { CommaToken, LSquare, RSquare } from "../../lexer/control.js";
2
- import { NewlineToken } from "../../lexer/tokens.js";
3
-
4
- /**
5
- * see objectAttrReq signature for arrayOfObjectAttrReq arguments details
6
- * @param {import('../base_parser.js').XanoBaseParser} $
7
- */
8
- export function arrayOfObjectAttrReq($) {
9
- /**
10
- * @param {import('chevrotain').Rule} rule
11
- **/
12
- return (parent, required, optional, options = {}) => {
13
- $.CONSUME(LSquare); // "["
14
- $.OPTION(() => {
15
- $.OR([
16
- // multi line, each value on a new line
17
- {
18
- ALT: () => {
19
- $.CONSUME(NewlineToken);
20
- $.AT_LEAST_ONE(() => {
21
- $.SUBRULE($.objectAttrReq, {
22
- ARGS: [parent, required, optional, options],
23
- });
24
- $.OPTION1(() => $.CONSUME(CommaToken)); // optional comma
25
- $.AT_LEAST_ONE1(() => $.CONSUME3(NewlineToken));
26
- });
27
- },
28
- },
29
- // one line, comma separated [ ..., ... ]
30
- {
31
- ALT: () => {
32
- $.AT_LEAST_ONE_SEP({
33
- SEP: CommaToken,
34
- DEF: () => {
35
- $.SUBRULE1($.objectAttrReq, {
36
- ARGS: [parent, required, optional, options],
37
- });
38
- },
39
- });
40
- $.MANY(() => $.CONSUME2(NewlineToken));
41
- },
42
- },
43
- ]);
44
- });
45
- $.CONSUME(RSquare); // "]"
46
- };
47
- }