@xano/xanoscript-language-server 11.5.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.
- package/.claude/settings.local.json +11 -0
- package/package.json +1 -1
- package/parser/agent_parser.js +7 -9
- package/parser/api_group_parser.js +10 -23
- package/parser/clauses/cacheClause.js +9 -10
- package/parser/generic/register.js +10 -22
- package/parser/mcp_server_parser.js +7 -9
- package/parser/mcp_server_trigger_parser.js +2 -6
- package/parser/realtime_trigger_parser.js +3 -7
- package/parser/table_trigger_parser.js +9 -11
- package/parser/test_parser.js +0 -4
- package/parser/workspace_trigger_parser.js +4 -8
- package/parser/generic/arrayOfObjectAttrReq.js +0 -47
- package/parser/generic/arrayOfObjectAttrReq.spec.js +0 -254
- package/parser/generic/arrayOfStringLiterals.js +0 -45
- package/parser/generic/arrayOfStringLiterals.spec.js +0 -56
- package/parser/generic/objectAttrReq.js +0 -243
- package/parser/generic/objectAttrReq.spec.js +0 -412
package/package.json
CHANGED
package/parser/agent_parser.js
CHANGED
|
@@ -250,18 +250,16 @@ export function agentDeclaration($) {
|
|
|
250
250
|
$.CONSUME2(EqualToken); // "="
|
|
251
251
|
|
|
252
252
|
// [{"name":"tool_name"}]
|
|
253
|
-
$.SUBRULE($.
|
|
253
|
+
$.SUBRULE($.schemaParseArrayFn, {
|
|
254
254
|
ARGS: [
|
|
255
255
|
subParent,
|
|
256
|
-
[
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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($.
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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($.
|
|
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
|
-
|
|
13
|
+
|
|
14
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
14
15
|
ARGS: [
|
|
15
16
|
parent,
|
|
16
|
-
["ttl", "input", "auth", "datasource", "ip"],
|
|
17
|
-
["headers", "env"],
|
|
18
17
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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,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($.
|
|
102
|
+
$.SUBRULE($.schemaParseArrayFn, {
|
|
103
103
|
ARGS: [
|
|
104
104
|
subParent,
|
|
105
|
-
[
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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($.
|
|
46
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
47
47
|
ARGS: [
|
|
48
48
|
subParent,
|
|
49
|
-
["connection"],
|
|
50
|
-
[],
|
|
51
49
|
{
|
|
52
|
-
|
|
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($.
|
|
44
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
45
45
|
ARGS: [
|
|
46
46
|
subParent,
|
|
47
|
-
[], // required
|
|
48
|
-
["join", "message"], // optional
|
|
49
47
|
{
|
|
50
|
-
|
|
51
|
-
|
|
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($.
|
|
47
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
48
48
|
ARGS: [
|
|
49
49
|
subParent,
|
|
50
|
-
[], // required
|
|
51
|
-
["delete", "insert", "truncate", "update"], // optional
|
|
52
50
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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($.
|
|
75
|
+
$.SUBRULE($.schemaFn, {
|
|
76
|
+
ARGS: [parent, ["[string]"]],
|
|
77
|
+
});
|
|
80
78
|
},
|
|
81
79
|
},
|
|
82
80
|
{
|
package/parser/test_parser.js
CHANGED
|
@@ -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($.
|
|
42
|
+
$.SUBRULE($.schemaParseObjectFn, {
|
|
43
43
|
ARGS: [
|
|
44
44
|
subParent,
|
|
45
|
-
[], // required
|
|
46
|
-
["branch_live", "branch_merge", "branch_new"], // optional
|
|
47
45
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import { describe, it } from "mocha";
|
|
3
|
-
import { EqualToken } from "../../lexer/control.js";
|
|
4
|
-
import { lexDocument } from "../../lexer/lexer.js";
|
|
5
|
-
import { Identifier } from "../../lexer/tokens.js";
|
|
6
|
-
import { parser } from "../test_parser.js";
|
|
7
|
-
|
|
8
|
-
export function parserExtension() {
|
|
9
|
-
// this rule requires a foo field to be defined
|
|
10
|
-
this.arrayOfObjectAttrReq_test_required = this.RULE(
|
|
11
|
-
"arrayOfObjectAttrReq_test_required",
|
|
12
|
-
() => {
|
|
13
|
-
const name = this.CONSUME(Identifier);
|
|
14
|
-
this.CONSUME(EqualToken); // "="
|
|
15
|
-
this.SUBRULE(this.arrayOfObjectAttrReq, { ARGS: [name, ["foo"]] });
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
this.arrayOfObjectAttrReq_test_optionals = this.RULE(
|
|
20
|
-
"arrayOfObjectAttrReq_test_optionals",
|
|
21
|
-
() => {
|
|
22
|
-
const name = this.CONSUME(Identifier);
|
|
23
|
-
this.CONSUME(EqualToken); // "="
|
|
24
|
-
this.SUBRULE(this.arrayOfObjectAttrReq, {
|
|
25
|
-
ARGS: [name, [], ["foo", "bar"]],
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
this.arrayOfObjectAttrReq_test_index = this.RULE(
|
|
31
|
-
"arrayOfObjectAttrReq_test_index",
|
|
32
|
-
() => {
|
|
33
|
-
const parent = this.CONSUME(Identifier);
|
|
34
|
-
this.CONSUME(EqualToken); // "="
|
|
35
|
-
this.SUBRULE(this.arrayOfObjectAttrReq, {
|
|
36
|
-
ARGS: [
|
|
37
|
-
parent,
|
|
38
|
-
["type", "field"],
|
|
39
|
-
[],
|
|
40
|
-
{
|
|
41
|
-
types: {
|
|
42
|
-
type: "string",
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
this.arrayOfObjectAttrReq_test_recursive_value = this.RULE(
|
|
51
|
-
"test_recursive_value",
|
|
52
|
-
() => {
|
|
53
|
-
const name = this.CONSUME(Identifier);
|
|
54
|
-
this.CONSUME(EqualToken); // "="
|
|
55
|
-
this.SUBRULE(this.arrayOfObjectAttrReq, {
|
|
56
|
-
ARGS: [
|
|
57
|
-
name,
|
|
58
|
-
["name", "as", "input"],
|
|
59
|
-
["addon"],
|
|
60
|
-
{ recursive: ["addon"] },
|
|
61
|
-
],
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
this.arrayOfObjectAttrReq_test_recursive_array_addon = this.RULE(
|
|
66
|
-
"test_recursive_array_addon",
|
|
67
|
-
() => {
|
|
68
|
-
const name = this.CONSUME(Identifier);
|
|
69
|
-
this.CONSUME(EqualToken); // "="
|
|
70
|
-
this.SUBRULE(this.arrayOfObjectAttrReq, {
|
|
71
|
-
ARGS: [
|
|
72
|
-
name,
|
|
73
|
-
["name", "as", "input"],
|
|
74
|
-
["addon"],
|
|
75
|
-
{ recursiveArray: ["addon"] },
|
|
76
|
-
],
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function parse(inputText) {
|
|
83
|
-
parser.reset();
|
|
84
|
-
const lexResult = lexDocument(inputText);
|
|
85
|
-
parser.input = lexResult.tokens;
|
|
86
|
-
return parser;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
describe("arrayOfObjectAttrReq", () => {
|
|
90
|
-
it("arrayOfObjectAttrReq accepts required attribute", () => {
|
|
91
|
-
parse(`something = [ {foo: "true"}]`).arrayOfObjectAttrReq_test_required();
|
|
92
|
-
expect(parser.errors).to.be.empty;
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("arrayOfObjectAttrReq accepts multilines attributes", () => {
|
|
96
|
-
parse(`something = [
|
|
97
|
-
{
|
|
98
|
-
foo: true
|
|
99
|
-
bar: 12
|
|
100
|
-
}
|
|
101
|
-
]`).arrayOfObjectAttrReq_test_optionals();
|
|
102
|
-
expect(parser.errors).to.be.empty;
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("arrayOfObjectAttrReq accepts list of single lines", () => {
|
|
106
|
-
parse(`something = [
|
|
107
|
-
{foo: true, bar: 12}
|
|
108
|
-
]`).arrayOfObjectAttrReq_test_optionals();
|
|
109
|
-
expect(parser.errors).to.be.empty;
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("arrayOfObjectAttrReq accepts multiple values", () => {
|
|
113
|
-
parse(`something = [
|
|
114
|
-
{
|
|
115
|
-
foo: true
|
|
116
|
-
}
|
|
117
|
-
{
|
|
118
|
-
bar: 12
|
|
119
|
-
}
|
|
120
|
-
]`).arrayOfObjectAttrReq_test_optionals();
|
|
121
|
-
expect(parser.errors).to.be.empty;
|
|
122
|
-
|
|
123
|
-
parse(
|
|
124
|
-
`something = [{ foo: true }, {bar: 12}]`
|
|
125
|
-
).arrayOfObjectAttrReq_test_optionals();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("arrayOfObjectAttrReq detects missing required attribute", () => {
|
|
129
|
-
parse(`something = [ {}]`).arrayOfObjectAttrReq_test_required();
|
|
130
|
-
expect(parser.errors).to.not.be.empty;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("arrayOfObjectAttrReq allow for recursive definition", () => {
|
|
134
|
-
parse(`addon = [
|
|
135
|
-
{
|
|
136
|
-
name : "client"
|
|
137
|
-
as : "_client"
|
|
138
|
-
input: {client_id: ""}
|
|
139
|
-
addon: {
|
|
140
|
-
name : "client"
|
|
141
|
-
as : "_client"
|
|
142
|
-
input: {client_id: ""}
|
|
143
|
-
addon: {
|
|
144
|
-
name : "client"
|
|
145
|
-
as : "_client"
|
|
146
|
-
input: {client_id: ""}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
]`).arrayOfObjectAttrReq_test_recursive_value();
|
|
151
|
-
expect(parser.errors).to.be.empty;
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it("arrayOfObjectAttrReq detects missing definition on recursive attributes", () => {
|
|
155
|
-
parse(`addon = [
|
|
156
|
-
{
|
|
157
|
-
name : "client"
|
|
158
|
-
as : "_client"
|
|
159
|
-
input: {client_id: ""}
|
|
160
|
-
addon: {
|
|
161
|
-
name : "client"
|
|
162
|
-
input: {client_id: ""}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
]`).arrayOfObjectAttrReq_test_recursive_value();
|
|
166
|
-
expect(parser.errors).to.not.be.empty;
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("arrayOfObjectAttrReq allow for recursive array", () => {
|
|
170
|
-
parse(`addon = [
|
|
171
|
-
{
|
|
172
|
-
name : "client"
|
|
173
|
-
as : "_client"
|
|
174
|
-
input: {client_id: ""}
|
|
175
|
-
addon: [
|
|
176
|
-
{
|
|
177
|
-
name : "client"
|
|
178
|
-
as : "_client"
|
|
179
|
-
input: {client_id: ""}
|
|
180
|
-
addon: [
|
|
181
|
-
{
|
|
182
|
-
name : "client"
|
|
183
|
-
as : "_client"
|
|
184
|
-
input: {client_id: ""}
|
|
185
|
-
addon: []
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
}
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
]`).arrayOfObjectAttrReq_test_recursive_array_addon();
|
|
192
|
-
expect(parser.errors).to.be.empty;
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("arrayOfObjectAttrReq detects missing definition on recursive array", () => {
|
|
196
|
-
parse(`addon = [
|
|
197
|
-
{
|
|
198
|
-
name : "client"
|
|
199
|
-
as : "_client"
|
|
200
|
-
input: {client_id: ""}
|
|
201
|
-
addon: [
|
|
202
|
-
{
|
|
203
|
-
name : "client"
|
|
204
|
-
input: {client_id: ""}
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
]`).arrayOfObjectAttrReq_test_recursive_array_addon();
|
|
209
|
-
expect(parser.errors).to.not.be.empty;
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("arrayOfObjectAttrReq accepts optional attributes", () => {
|
|
213
|
-
parse(`something = [{}]`).arrayOfObjectAttrReq_test_optionals();
|
|
214
|
-
expect(parser.errors).to.be.empty;
|
|
215
|
-
|
|
216
|
-
parse(`something = [{foo: true}]`).arrayOfObjectAttrReq_test_optionals();
|
|
217
|
-
expect(parser.errors).to.be.empty;
|
|
218
|
-
|
|
219
|
-
parse(`something = [{bar: "ok"}]`).arrayOfObjectAttrReq_test_optionals();
|
|
220
|
-
expect(parser.errors).to.be.empty;
|
|
221
|
-
|
|
222
|
-
parse(
|
|
223
|
-
`something = [{bar: "ok", "foo": 12.1}]`
|
|
224
|
-
).arrayOfObjectAttrReq_test_optionals();
|
|
225
|
-
expect(parser.errors).to.be.empty;
|
|
226
|
-
|
|
227
|
-
parse(`something = [
|
|
228
|
-
{bar: "ok", "foo": 12.1},
|
|
229
|
-
{bar: "ok", "foo": 12.1}
|
|
230
|
-
]`).arrayOfObjectAttrReq_test_optionals();
|
|
231
|
-
expect(parser.errors).to.be.empty;
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("arrayOfObjectAttrReq can be used for single line index clause", () => {
|
|
235
|
-
parse(
|
|
236
|
-
`index = [{type: "primary", field: [{name: "id"}]}]`
|
|
237
|
-
).arrayOfObjectAttrReq_test_index();
|
|
238
|
-
expect(parser.errors).to.be.empty;
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("arrayOfObjectAttrReq can be used for index clause", () => {
|
|
242
|
-
parse(`index = [
|
|
243
|
-
{type: "primary", field: [{name: "id"}]}
|
|
244
|
-
{type: "gin", field: [{name: "xdo", op: "jsonb_path_op"}]}
|
|
245
|
-
{type: "btree", field: [{name: "created_at", op: "desc"}]}
|
|
246
|
-
]`).arrayOfObjectAttrReq_test_index();
|
|
247
|
-
expect(parser.errors).to.be.empty;
|
|
248
|
-
|
|
249
|
-
parse(`index = [
|
|
250
|
-
{type: "primary", field: [{name: "id"}]}
|
|
251
|
-
]`).arrayOfObjectAttrReq_test_index();
|
|
252
|
-
expect(parser.errors).to.be.empty;
|
|
253
|
-
});
|
|
254
|
-
});
|