@xano/xanoscript-language-server 11.0.3 → 11.0.5

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.
@@ -19,7 +19,14 @@
19
19
  "Bash(git -C /Users/justinalbrecht/git/xs-language-server log --oneline -5)",
20
20
  "Bash(git -C /Users/justinalbrecht/git/xs-language-server add README.md LICENSE package.json lexer/tests/query/valid_sources/basic_query.xs parser/functions/stream/streamFromRequestFn.js parser/functions/stream/streamFromRequestFn.spec.js parser/tests/function/valid_sources/discord_poll_send_to_slack.xs parser/tests/query/valid_sources/all_basics.xs)",
21
21
  "Bash(git -C /Users/justinalbrecht/git/xs-language-server commit -m \"$\\(cat <<''EOF''\nPrepare package for public npm release as @xano/xanoscript-language-server\n\n- Rename package to @xano/xanoscript-language-server\n- Add MIT LICENSE file\n- Add npm metadata \\(description, repository, author, license, bugs, homepage\\)\n- Remove private flag to allow publishing\n- Sanitize test files: replace internal URLs, IDs, and env var names with placeholders\n- Simplify README maintainer section\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
22
- "Bash(git -C /Users/justinalbrecht/git/xs-language-server log -1 --oneline)"
22
+ "Bash(git -C /Users/justinalbrecht/git/xs-language-server log -1 --oneline)",
23
+ "Bash(git add:*)",
24
+ "Bash(git commit:*)",
25
+ "Bash(git push)",
26
+ "Bash(npm whoami:*)",
27
+ "Bash(npm view:*)",
28
+ "Bash(npm version:*)",
29
+ "Bash(npm publish:*)"
23
30
  ],
24
31
  "deny": [],
25
32
  "ask": []
package/README.md CHANGED
@@ -1,55 +1,175 @@
1
- [![CI](https://github.com/xano-labs/xs-language-server/actions/workflows/ci.yml/badge.svg)](https://github.com/xano-labs/xs-language-server/actions/workflows/ci.yml)
1
+ ```
2
+ ██╗ ██╗███████╗ ██╗ █████╗ ███╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ███████╗
3
+ ╚██╗██╔╝██╔════╝ ██║ ██╔══██╗████╗ ██║██╔════╝ ██║ ██║██╔══██╗██╔════╝ ██╔════╝
4
+ ╚███╔╝ ███████╗ ██║ ███████║██╔██╗ ██║██║ ███╗██║ ██║███████║██║ ███╗█████╗
5
+ ██╔██╗ ╚════██║ ██║ ██╔══██║██║╚██╗██║██║ ██║██║ ██║██╔══██║██║ ██║██╔══╝
6
+ ██╔╝ ██╗███████║ ███████╗██║ ██║██║ ╚████║╚██████╔╝╚██████╔╝██║ ██║╚██████╔╝███████╗
7
+ ╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
8
+
9
+ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
10
+ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
11
+ ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
12
+ ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
13
+ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
14
+ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
15
+ ```
2
16
 
3
17
  # XanoScript Language Server
4
18
 
5
- The language server is based on [Chevrotain](https://chevrotain.io/), a powerful parsing library for JavaScript.
19
+ A Language Server Protocol (LSP) implementation for [XanoScript](https://xano.com), built on [Chevrotain](https://chevrotain.io/).
6
20
 
7
21
  Maintained by the [Xano](https://xano.com) team.
8
22
 
9
- ## File structure
23
+ ## Installation
10
24
 
11
- - `lexer/`: Contains the lexer implementation, including token definitions and the lexer itself.
12
- - `parser/`: Contains the parser implementation, including grammar definitions and the main parser class.
25
+ ```sh
26
+ npm install @xano/xanoscript-language-server
27
+ ```
13
28
 
14
- To integrate the language server with 3rd party tools, we also have a `server.js` file that sets up the language server and handles communication with clients.
29
+ **Requirements:** Node.js 20+
30
+
31
+ ## Features
32
+
33
+ The language server provides full LSP support including:
34
+
35
+ - **Code Completion** - Context-aware suggestions triggered by `.`, `:`, `$`, and `|`
36
+ - **Syntax Highlighting** - Semantic token-based highlighting for XanoScript constructs
37
+ - **Hover Information** - Documentation and type information on hover
38
+ - **Diagnostics** - Real-time error detection and reporting
39
+
40
+ ## Supported Object Types
41
+
42
+ The parser supports the following XanoScript constructs:
43
+
44
+ | Type | Description |
45
+ |------|-------------|
46
+ | `query` | API endpoints with HTTP verbs, input validation, and responses |
47
+ | `function` | Reusable logic blocks with testing capabilities |
48
+ | `task` | Scheduled operations with cron-like triggers |
49
+ | `api_group` | Collections of related API endpoints |
50
+ | `table` | Database schema definitions with column types |
51
+ | `table_trigger` | Database table trigger definitions |
52
+ | `workflow_test` | Test definitions for workflows |
53
+ | `addon` | Add-on definitions |
54
+ | `agent` | AI agent definitions |
55
+ | `agent_trigger` | Agent trigger handlers |
56
+ | `branch` | Branch logic |
57
+ | `mcp_server` | MCP server definitions |
58
+ | `mcp_server_trigger` | MCP server trigger handlers |
59
+ | `middleware` | Middleware definitions |
60
+ | `realtime_channel` | Realtime channel definitions |
61
+ | `realtime_trigger` | Realtime trigger handlers |
62
+ | `tool` | Tool definitions |
63
+ | `workspace` | Workspace definitions |
64
+ | `workspace_trigger` | Workspace trigger handlers |
65
+
66
+ ## Built-in Function Domains
67
+
68
+ XanoScript includes functions organized by domain:
69
+
70
+ - **ai** - AI and machine learning operations
71
+ - **api** - External API calls and HTTP requests
72
+ - **array** - Array manipulation and iteration
73
+ - **cloud** - Cloud service integrations
74
+ - **controls** - Flow control (conditionals, loops, etc.)
75
+ - **db** - Database queries and operations
76
+ - **debug** - Debugging and logging utilities
77
+ - **expect** - Testing assertions
78
+ - **math** - Mathematical operations
79
+ - **object** - Object manipulation
80
+ - **redis** - Redis cache operations
81
+ - **schema** - Schema operations
82
+ - **security** - Authentication and security functions
83
+ - **storage** - File storage operations
84
+ - **stream** - Streaming data operations
85
+ - **text** - String manipulation
86
+ - **util** - General utilities
87
+ - **var** - Variable operations
88
+ - **zip** - Compression utilities
89
+
90
+ ## Project Structure
15
91
 
16
- - `onCompletion/`: Contains the implementation for the completion feature, allowing the language server to provide suggestions for code completion.
17
- - `onDidChangeContent/`: Runs a diagnostic analysis on the content of the xanoscript (allow the editor to show errors + error message)
18
- - `onHover/`: Provides hover information for symbols in the xanoscript, such as type information and documentation.
19
- - `onSemanticCheck/`: Provides the highlight syntax for Xanoscript to the editor.
92
+ ```
93
+ ├── server.js # LSP server entry point
94
+ ├── lexer/ # Lexical analysis
95
+ │ ├── lexer.js # Chevrotain lexer implementation
96
+ │ ├── tokens.js # Main token registry
97
+ │ └── [domain].js # Domain-specific tokens (api, db, cloud, etc.)
98
+ ├── parser/ # Syntax parsing
99
+ │ ├── base_parser.js # Core XanoBaseParser
100
+ │ ├── [type]_parser.js # Object type parsers
101
+ │ ├── attributes/ # Field attributes (description, disabled, sensitive)
102
+ │ ├── clauses/ # Language blocks (stack, input, response, etc.)
103
+ │ ├── definitions/ # Type and column definitions
104
+ │ ├── functions/ # Built-in functions by domain
105
+ │ └── generic/ # Reusable parsing components
106
+ ├── onCompletion/ # Code completion logic
107
+ ├── onDidChangeContent/ # Diagnostics and error reporting
108
+ ├── onHover/ # Hover documentation
109
+ └── onSemanticCheck/ # Semantic token highlighting
110
+ ```
20
111
 
21
- ## How do I add a new object type?
112
+ ## Development
22
113
 
23
- Every new object requires a new parser in the `parser/` folder. Use one of our existing parser (`query_parser.js`, `function_parser.js`...) to create yours. Once created, you'll have to add it to `server.js`.
114
+ ```sh
115
+ # Install dependencies
116
+ npm install
24
117
 
25
- ## How do I add a new keyword/function ?
118
+ # Run all tests (~1800 tests)
119
+ npm test
26
120
 
27
- We have a hierarchy for the different statements Xanoscript uses.
121
+ # Run specific test
122
+ npm test -- -g "test name"
28
123
 
29
- 1. Parser: this is the top level, we have a Query parser, function parser, etc.
30
- 2. Clause: this is the main blocks in a given object type, could be stack, response, input...
31
- 3. functions: this would be a statement, like a `debug.log` or `db.query`
32
- 4. `attributes`, `definitions` would come next as component you can use to define your functions
33
- 5. `generic` is used by all the other statement, like a toolset for language.
124
+ # Lint code
125
+ npm run lint
34
126
 
35
- ## Testing
127
+ # Fix lint issues
128
+ npm run lint:fix
36
129
 
37
- The language server is heavily tested and should remain that way as it grows. Test should be easy to copy, paste, extends. Avoid dynamic test (like using a loop), your test should be straightforward, easy to read, easy to understand, trustworthy.
130
+ # Generate TextMate language definition
131
+ npm run tm
132
+ ```
38
133
 
39
- To run the tests:
134
+ ## Adding New Features
40
135
 
41
- ```sh
42
- npm test
43
- ```
136
+ ### New Object Type
44
137
 
45
- To run a specific test
138
+ 1. Create a new parser in `parser/` (e.g., `my_object_parser.js`)
139
+ 2. Follow existing parser patterns (see `query_parser.js`, `function_parser.js`)
140
+ 3. Register it in `server.js`
46
141
 
47
- ```sh
48
- npm test -- -g "my test name"
49
- ```
142
+ ### New Keyword/Function
143
+
144
+ We have a hierarchy for the different statements XanoScript uses:
145
+
146
+ 1. **Parser** - Top level (Query parser, Function parser, etc.)
147
+ 2. **Clause** - Main blocks in a given object type (stack, response, input, etc.)
148
+ 3. **Functions** - Statements like `debug.log` or `db.query`
149
+ 4. **Attributes/Definitions** - Components used to define functions
150
+ 5. **Generic** - Shared language toolset
151
+
152
+ To add a new function:
153
+
154
+ 1. Add token definition in appropriate `lexer/` file
155
+ 2. Create function implementation in `parser/functions/[domain]/`
156
+ 3. Register in parent clause or parser
157
+ 4. Add comprehensive tests in corresponding `.spec.js` file
158
+
159
+ ## Testing
160
+
161
+ The language server is heavily tested and should remain that way. Tests should be:
162
+
163
+ - Easy to copy, paste, and extend
164
+ - Straightforward and easy to read
165
+ - Avoid dynamic generation (no loops)
166
+
167
+ Test files use `.spec.js` naming convention and mirror the source structure.
168
+
169
+ ## CI/CD
50
170
 
51
- ## CI-CD
171
+ On commit, pre-commit hooks run linting via Husky. The CI pipeline runs all tests and linting checks. Configuration is in `.github/workflows/ci.yml`.
52
172
 
53
- On commit, the CI/CD pipeline will run all tests and linting checks to ensure code quality. If any tests fail, the commit will be rejected until the issues are resolved.
173
+ ## License
54
174
 
55
- You'll find the configuration of the action in the `.github/workflows/ci.yml` file.
175
+ MIT License - see [LICENSE](LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/xanoscript-language-server",
3
- "version": "11.0.3",
3
+ "version": "11.0.5",
4
4
  "description": "Language Server Protocol implementation for XanoScript",
5
5
  "type": "module",
6
6
  "main": "server.js",