@xano/xanoscript-language-server 12.12.0 → 12.13.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
CHANGED
|
@@ -62,7 +62,7 @@ The parser supports the following XanoScript constructs:
|
|
|
62
62
|
| `realtime_server` | Realtime v2 server definitions (the container that owns channels) |
|
|
63
63
|
| `channel` | Realtime v2 channel definitions (path templates) |
|
|
64
64
|
| `message` | Realtime v2 channel message handlers |
|
|
65
|
-
| `channel_trigger` | Realtime v2 channel
|
|
65
|
+
| `channel_trigger` | Realtime v2 channel triggers (join/leave lifecycle, deliver per-recipient) |
|
|
66
66
|
| `realtime_server_trigger` | Realtime v2 connection lifecycle triggers (connect/disconnect) |
|
|
67
67
|
| `tool` | Tool definitions |
|
|
68
68
|
| `workspace` | Workspace definitions |
|
package/lexer/realtime.js
CHANGED
|
@@ -13,12 +13,23 @@ export const GetSessionToken = createTokenByName("get_session", {
|
|
|
13
13
|
categories: [Identifier],
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// publish
|
|
17
|
+
export const PublishToken = createTokenByName("publish", {
|
|
18
|
+
longer_alt: Identifier,
|
|
19
|
+
categories: [Identifier],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const RealtimeStatementTokens = [
|
|
23
|
+
RealtimeToken,
|
|
24
|
+
GetSessionToken,
|
|
25
|
+
PublishToken,
|
|
26
|
+
];
|
|
17
27
|
|
|
18
28
|
export function mapTokenToType(token) {
|
|
19
29
|
switch (token) {
|
|
20
30
|
case RealtimeToken.name:
|
|
21
31
|
case GetSessionToken.name:
|
|
32
|
+
case PublishToken.name:
|
|
22
33
|
return "function";
|
|
23
34
|
default:
|
|
24
35
|
return null;
|
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PublishToken } from "../../../lexer/realtime.js";
|
|
2
|
+
|
|
3
|
+
// realtime.publish {
|
|
4
|
+
// realtime_server = "main"
|
|
5
|
+
// channel = "rooms/42"
|
|
6
|
+
// message = "chat" // optional — becomes the delivered frame's `type`
|
|
7
|
+
// data = $payload
|
|
8
|
+
// auth_table = "user" // optional — asserted identity (attribution only)
|
|
9
|
+
// auth_id = $auth.id // optional
|
|
10
|
+
// }
|
|
11
|
+
//
|
|
12
|
+
// Injects a server-authored event onto a realtime v2 channel (cloud-client
|
|
13
|
+
// mvp:realtime_publish). `realtime_server` + `channel` + `data` are required;
|
|
14
|
+
// `message`/`auth_table`/`auth_id` are optional. Flat attrs (the PHP transform
|
|
15
|
+
// maps auth_table/auth_id into the nested context.auth.{dbo_id,row_id} shape).
|
|
16
|
+
// Unlike realtime.get_session it has NO `as $var` binding.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('../../base_parser.js').XanoBaseParser} $
|
|
20
|
+
*/
|
|
21
|
+
export function realtimePublishFn($) {
|
|
22
|
+
const requiredAttrs = ["realtime_server", "channel", "data"];
|
|
23
|
+
const optionalAttrs = [
|
|
24
|
+
"message",
|
|
25
|
+
"auth_table",
|
|
26
|
+
"auth_id",
|
|
27
|
+
"description",
|
|
28
|
+
"disabled",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
$.sectionStack.push("realtimePublishFn");
|
|
33
|
+
const fnToken = $.CONSUME(PublishToken); // "publish"
|
|
34
|
+
$.SUBRULE($.functionAttrReq, {
|
|
35
|
+
ARGS: [fnToken, requiredAttrs, optionalAttrs],
|
|
36
|
+
});
|
|
37
|
+
$.sectionStack.pop();
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { realtimeGetSessionFn } from "./realtimeGetSessionFn.js";
|
|
2
|
+
import { realtimePublishFn } from "./realtimePublishFn.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Registers all the parsers in this folder
|
|
@@ -9,4 +10,5 @@ export const register = ($) => {
|
|
|
9
10
|
"realtimeGetSessionFn",
|
|
10
11
|
realtimeGetSessionFn($),
|
|
11
12
|
);
|
|
13
|
+
$.realtimePublishFn = $.RULE("realtimePublishFn", realtimePublishFn($));
|
|
12
14
|
};
|