@xano/xanoscript-language-server 12.10.0 → 12.12.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/README.md +1 -0
- package/package.json +1 -1
- package/parser/channel_parser.js +2 -8
- package/parser/channel_trigger_parser.js +2 -8
- package/parser/message_parser.js +2 -8
- package/parser/parser.js +3 -0
- package/parser/realtime_server_parser.js +95 -0
- package/parser/register.js +5 -0
- package/utils.js +1 -0
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ The parser supports the following XanoScript constructs:
|
|
|
59
59
|
| `middleware` | Middleware definitions |
|
|
60
60
|
| `realtime_channel` | Realtime v1 channel definitions |
|
|
61
61
|
| `realtime_trigger` | Realtime v1 trigger handlers |
|
|
62
|
+
| `realtime_server` | Realtime v2 server definitions (the container that owns channels) |
|
|
62
63
|
| `channel` | Realtime v2 channel definitions (path templates) |
|
|
63
64
|
| `message` | Realtime v2 channel message handlers |
|
|
64
65
|
| `channel_trigger` | Realtime v2 channel lifecycle triggers (join/leave) |
|
package/package.json
CHANGED
package/parser/channel_parser.js
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
DeliveryToken,
|
|
5
5
|
PublishToken,
|
|
6
6
|
RateLimitToken,
|
|
7
|
-
ServerToken,
|
|
8
7
|
} from "../lexer/channel.js";
|
|
9
8
|
import { ChannelToken } from "../lexer/columns.js";
|
|
10
9
|
import { EqualToken, LCurly, RCurly } from "../lexer/control.js";
|
|
@@ -46,12 +45,7 @@ export function channelDeclaration($) {
|
|
|
46
45
|
GATE: () => !hasServer,
|
|
47
46
|
ALT: () => {
|
|
48
47
|
hasServer = true;
|
|
49
|
-
|
|
50
|
-
$.CONSUME(EqualToken); // "="
|
|
51
|
-
const result = $.CONSUME2(StringLiteral); // "server_name"
|
|
52
|
-
if (result.image === `""`) {
|
|
53
|
-
$.addMissingError(subParent, "server cannot be empty");
|
|
54
|
-
}
|
|
48
|
+
$.SUBRULE($.realtimeServerClause);
|
|
55
49
|
},
|
|
56
50
|
},
|
|
57
51
|
{
|
|
@@ -178,7 +172,7 @@ export function channelDeclaration($) {
|
|
|
178
172
|
});
|
|
179
173
|
|
|
180
174
|
if (!hasServer) {
|
|
181
|
-
$.addMissingError(parent, "{} is missing a
|
|
175
|
+
$.addMissingError(parent, "{} is missing a realtime_server clause");
|
|
182
176
|
}
|
|
183
177
|
|
|
184
178
|
$.MANY1(() => $.CONSUME1(NewlineToken)); // optional new line
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ServerToken } from "../lexer/channel.js";
|
|
2
1
|
import { ChannelTriggerToken } from "../lexer/channel_trigger.js";
|
|
3
2
|
import { EqualToken, LCurly, RCurly } from "../lexer/control.js";
|
|
4
3
|
import { StringLiteral } from "../lexer/literal.js";
|
|
@@ -68,12 +67,7 @@ export function channelTriggerDeclaration($) {
|
|
|
68
67
|
GATE: () => !hasServer,
|
|
69
68
|
ALT: () => {
|
|
70
69
|
hasServer = true;
|
|
71
|
-
|
|
72
|
-
$.CONSUME3(EqualToken); // "="
|
|
73
|
-
const result = $.CONSUME2(StringLiteral); // "server_name"
|
|
74
|
-
if (result.image === `""`) {
|
|
75
|
-
$.addMissingError(subParent, "server cannot be empty");
|
|
76
|
-
}
|
|
70
|
+
$.SUBRULE($.realtimeServerClause);
|
|
77
71
|
},
|
|
78
72
|
},
|
|
79
73
|
{
|
|
@@ -136,7 +130,7 @@ export function channelTriggerDeclaration($) {
|
|
|
136
130
|
});
|
|
137
131
|
|
|
138
132
|
if (!hasServer) {
|
|
139
|
-
$.addMissingError(parent, "{} is missing a
|
|
133
|
+
$.addMissingError(parent, "{} is missing a realtime_server clause");
|
|
140
134
|
}
|
|
141
135
|
|
|
142
136
|
if (!hasChannel) {
|
package/parser/message_parser.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ServerToken } from "../lexer/channel.js";
|
|
2
1
|
import { EqualToken, LCurly, RCurly } from "../lexer/control.js";
|
|
3
2
|
import { StringLiteral } from "../lexer/literal.js";
|
|
4
3
|
import { DeliverToToken, MessageToken } from "../lexer/message.js";
|
|
@@ -48,12 +47,7 @@ export function messageDeclaration($) {
|
|
|
48
47
|
GATE: () => !hasServer,
|
|
49
48
|
ALT: () => {
|
|
50
49
|
hasServer = true;
|
|
51
|
-
|
|
52
|
-
$.CONSUME3(EqualToken); // "="
|
|
53
|
-
const result = $.CONSUME3(StringLiteral); // "server_name"
|
|
54
|
-
if (result.image === `""`) {
|
|
55
|
-
$.addMissingError(subParent, "server cannot be empty");
|
|
56
|
-
}
|
|
50
|
+
$.SUBRULE($.realtimeServerClause);
|
|
57
51
|
},
|
|
58
52
|
},
|
|
59
53
|
{
|
|
@@ -142,7 +136,7 @@ export function messageDeclaration($) {
|
|
|
142
136
|
if (!hasServer) {
|
|
143
137
|
$.addMissingError(
|
|
144
138
|
parent,
|
|
145
|
-
`{} ${nameToken.image} is missing a
|
|
139
|
+
`{} ${nameToken.image} is missing a realtime_server clause`,
|
|
146
140
|
);
|
|
147
141
|
}
|
|
148
142
|
|
package/parser/parser.js
CHANGED
|
@@ -60,6 +60,9 @@ export function xanoscriptParser(text, scheme, preTokenized = null) {
|
|
|
60
60
|
case "middleware":
|
|
61
61
|
parser.middlewareDeclaration();
|
|
62
62
|
return parser;
|
|
63
|
+
case "realtime_server":
|
|
64
|
+
parser.realtimeServerDeclaration();
|
|
65
|
+
return parser;
|
|
63
66
|
case "realtime_server_trigger":
|
|
64
67
|
parser.realtimeServerTriggerDeclaration();
|
|
65
68
|
return parser;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { EqualToken, LCurly, RCurly } from "../lexer/control.js";
|
|
2
|
+
import { StringLiteral } from "../lexer/literal.js";
|
|
3
|
+
import { ActiveToken } from "../lexer/mcp_server.js";
|
|
4
|
+
import { RealtimeServerToken } from "../lexer/realtime_server_trigger.js";
|
|
5
|
+
import { Identifier, NewlineToken } from "../lexer/tokens.js";
|
|
6
|
+
|
|
7
|
+
export function realtimeServerDeclaration($) {
|
|
8
|
+
return () => {
|
|
9
|
+
let hasActive = false;
|
|
10
|
+
let hasCanonical = false;
|
|
11
|
+
let hasDescription = false;
|
|
12
|
+
let hasGuid = false;
|
|
13
|
+
let hasDocs = false;
|
|
14
|
+
let hasHistory = false;
|
|
15
|
+
let hasTags = false;
|
|
16
|
+
|
|
17
|
+
$.sectionStack.push("realtimeServerDeclaration");
|
|
18
|
+
// Allow leading comments and newlines before the realtime_server declaration
|
|
19
|
+
$.SUBRULE($.optionalCommentBlockFn);
|
|
20
|
+
$.CONSUME(RealtimeServerToken); // realtime_server
|
|
21
|
+
const nameToken = $.OR([
|
|
22
|
+
{ ALT: () => $.CONSUME(StringLiteral) },
|
|
23
|
+
{ ALT: () => $.CONSUME(Identifier) },
|
|
24
|
+
]);
|
|
25
|
+
$.validateDeclarationName(nameToken, "realtime_server");
|
|
26
|
+
$.CONSUME(LCurly); // "{"
|
|
27
|
+
$.MANY(() => {
|
|
28
|
+
$.AT_LEAST_ONE(() => $.CONSUME(NewlineToken)); // at least one new line
|
|
29
|
+
$.OR2([
|
|
30
|
+
{
|
|
31
|
+
ALT: () => $.SUBRULE($.commentBlockFn),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
GATE: () => !hasActive,
|
|
35
|
+
ALT: () => {
|
|
36
|
+
hasActive = true;
|
|
37
|
+
|
|
38
|
+
$.CONSUME(ActiveToken); // "active"
|
|
39
|
+
$.CONSUME(EqualToken); // "="
|
|
40
|
+
$.SUBRULE($.booleanValue); // true/false
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
GATE: () => !hasCanonical,
|
|
45
|
+
ALT: () => {
|
|
46
|
+
hasCanonical = true;
|
|
47
|
+
$.SUBRULE($.canonicalClause);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
GATE: () => !hasDescription,
|
|
52
|
+
ALT: () => {
|
|
53
|
+
hasDescription = true;
|
|
54
|
+
$.SUBRULE($.descriptionFieldAttribute);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
GATE: () => !hasGuid,
|
|
59
|
+
ALT: () => {
|
|
60
|
+
hasGuid = true;
|
|
61
|
+
$.SUBRULE($.guidFieldAttribute);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
GATE: () => !hasDocs,
|
|
66
|
+
ALT: () => {
|
|
67
|
+
hasDocs = true;
|
|
68
|
+
$.SUBRULE($.docsFieldAttribute);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
GATE: () => !hasHistory,
|
|
73
|
+
ALT: () => {
|
|
74
|
+
hasHistory = true;
|
|
75
|
+
$.SUBRULE($.historyClause);
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
GATE: () => !hasTags,
|
|
80
|
+
ALT: () => {
|
|
81
|
+
hasTags = true;
|
|
82
|
+
$.SUBRULE($.tagsAttribute);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// All fields are optional — only the declaration name is required.
|
|
89
|
+
|
|
90
|
+
$.MANY1(() => $.CONSUME1(NewlineToken)); // optional new line
|
|
91
|
+
$.CONSUME(RCurly); // "}"
|
|
92
|
+
$.MANY2(() => $.CONSUME2(NewlineToken)); // optional new line
|
|
93
|
+
$.sectionStack.pop();
|
|
94
|
+
};
|
|
95
|
+
}
|
package/parser/register.js
CHANGED
|
@@ -19,6 +19,7 @@ import { register as register_metadata } from "./metadata/register.js";
|
|
|
19
19
|
import { middlewareDeclaration } from "./middleware_parser.js";
|
|
20
20
|
import { queryDeclaration } from "./query_parser.js";
|
|
21
21
|
import { realtimeChannelDeclaration } from "./realtime_channel_parser.js";
|
|
22
|
+
import { realtimeServerDeclaration } from "./realtime_server_parser.js";
|
|
22
23
|
import { realtimeServerTriggerDeclaration } from "./realtime_server_trigger_parser.js";
|
|
23
24
|
import { realtimeTriggerDeclaration } from "./realtime_trigger_parser.js";
|
|
24
25
|
import {
|
|
@@ -78,6 +79,10 @@ export const register = ($) => {
|
|
|
78
79
|
"middlewareDeclaration",
|
|
79
80
|
middlewareDeclaration($)
|
|
80
81
|
);
|
|
82
|
+
$.realtimeServerDeclaration = $.RULE(
|
|
83
|
+
"realtimeServerDeclaration",
|
|
84
|
+
realtimeServerDeclaration($)
|
|
85
|
+
);
|
|
81
86
|
$.realtimeServerTriggerDeclaration = $.RULE(
|
|
82
87
|
"realtimeServerTriggerDeclaration",
|
|
83
88
|
realtimeServerTriggerDeclaration($)
|
package/utils.js
CHANGED
|
@@ -32,6 +32,7 @@ const schemeByFirstWord = {
|
|
|
32
32
|
message: "message",
|
|
33
33
|
middleware: "middleware",
|
|
34
34
|
query: "api",
|
|
35
|
+
realtime_server: "realtime_server",
|
|
35
36
|
realtime_server_trigger: "realtime_server_trigger",
|
|
36
37
|
realtime_trigger: "realtime_trigger",
|
|
37
38
|
realtime_channel: "realtime_channel",
|