@xano/developer-mcp 1.0.25 → 1.0.27

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.
Files changed (91) hide show
  1. package/README.md +50 -0
  2. package/dist/cli_docs/format.d.ts +12 -0
  3. package/dist/cli_docs/format.js +98 -0
  4. package/dist/{api_docs → cli_docs}/index.d.ts +6 -11
  5. package/dist/cli_docs/index.js +86 -0
  6. package/dist/cli_docs/topics/function.js +114 -0
  7. package/dist/cli_docs/topics/integration.d.ts +2 -0
  8. package/dist/cli_docs/topics/integration.js +157 -0
  9. package/dist/{api_docs/topics/agent.d.ts → cli_docs/topics/profile.d.ts} +1 -1
  10. package/dist/cli_docs/topics/profile.js +153 -0
  11. package/dist/{api_docs/topics/api.d.ts → cli_docs/topics/run.d.ts} +1 -1
  12. package/dist/cli_docs/topics/run.js +248 -0
  13. package/dist/cli_docs/topics/start.js +111 -0
  14. package/dist/cli_docs/topics/static_host.d.ts +2 -0
  15. package/dist/cli_docs/topics/static_host.js +77 -0
  16. package/dist/cli_docs/topics/workspace.js +119 -0
  17. package/dist/cli_docs/types.d.ts +44 -0
  18. package/dist/cli_docs/types.js +4 -0
  19. package/dist/index.js +42 -0
  20. package/dist/xanoscript_docs/README.md +78 -64
  21. package/dist/xanoscript_docs/apis.md +81 -27
  22. package/dist/xanoscript_docs/branch.md +13 -13
  23. package/dist/xanoscript_docs/database.md +57 -17
  24. package/dist/xanoscript_docs/functions.md +43 -71
  25. package/dist/xanoscript_docs/performance.md +14 -23
  26. package/dist/xanoscript_docs/tables.md +47 -1
  27. package/dist/xanoscript_docs/tools.md +9 -7
  28. package/dist/xanoscript_docs/types.md +12 -10
  29. package/package.json +1 -1
  30. package/dist/api_docs/format.d.ts +0 -5
  31. package/dist/api_docs/format.js +0 -171
  32. package/dist/api_docs/index.js +0 -111
  33. package/dist/api_docs/topics/agent.js +0 -142
  34. package/dist/api_docs/topics/api.js +0 -176
  35. package/dist/api_docs/topics/apigroup.d.ts +0 -2
  36. package/dist/api_docs/topics/apigroup.js +0 -124
  37. package/dist/api_docs/topics/authentication.d.ts +0 -2
  38. package/dist/api_docs/topics/authentication.js +0 -61
  39. package/dist/api_docs/topics/branch.d.ts +0 -2
  40. package/dist/api_docs/topics/branch.js +0 -73
  41. package/dist/api_docs/topics/file.d.ts +0 -2
  42. package/dist/api_docs/topics/file.js +0 -70
  43. package/dist/api_docs/topics/function.js +0 -164
  44. package/dist/api_docs/topics/history.d.ts +0 -2
  45. package/dist/api_docs/topics/history.js +0 -149
  46. package/dist/api_docs/topics/mcp_server.d.ts +0 -2
  47. package/dist/api_docs/topics/mcp_server.js +0 -139
  48. package/dist/api_docs/topics/middleware.d.ts +0 -2
  49. package/dist/api_docs/topics/middleware.js +0 -156
  50. package/dist/api_docs/topics/realtime.d.ts +0 -2
  51. package/dist/api_docs/topics/realtime.js +0 -112
  52. package/dist/api_docs/topics/start.js +0 -107
  53. package/dist/api_docs/topics/table.d.ts +0 -2
  54. package/dist/api_docs/topics/table.js +0 -195
  55. package/dist/api_docs/topics/task.d.ts +0 -2
  56. package/dist/api_docs/topics/task.js +0 -165
  57. package/dist/api_docs/topics/tool.d.ts +0 -2
  58. package/dist/api_docs/topics/tool.js +0 -150
  59. package/dist/api_docs/topics/workflows.d.ts +0 -2
  60. package/dist/api_docs/topics/workflows.js +0 -131
  61. package/dist/api_docs/topics/workspace.js +0 -153
  62. package/dist/api_docs/types.d.ts +0 -79
  63. package/dist/api_docs/types.js +0 -4
  64. package/dist/templates/init-workspace.d.ts +0 -10
  65. package/dist/templates/init-workspace.js +0 -278
  66. package/dist/templates/xanoscript-index.d.ts +0 -11
  67. package/dist/templates/xanoscript-index.js +0 -72
  68. package/dist/xanoscript_docs/ephemeral.md +0 -330
  69. package/dist/xanoscript_docs_auto/README.md +0 -119
  70. package/dist/xanoscript_docs_auto/agents.md +0 -446
  71. package/dist/xanoscript_docs_auto/apis.md +0 -517
  72. package/dist/xanoscript_docs_auto/control-flow.md +0 -543
  73. package/dist/xanoscript_docs_auto/database.md +0 -551
  74. package/dist/xanoscript_docs_auto/debugging.md +0 -527
  75. package/dist/xanoscript_docs_auto/filters.md +0 -464
  76. package/dist/xanoscript_docs_auto/functions.md +0 -431
  77. package/dist/xanoscript_docs_auto/integrations.md +0 -657
  78. package/dist/xanoscript_docs_auto/mcp-servers.md +0 -408
  79. package/dist/xanoscript_docs_auto/operators.md +0 -368
  80. package/dist/xanoscript_docs_auto/syntax.md +0 -287
  81. package/dist/xanoscript_docs_auto/tables.md +0 -447
  82. package/dist/xanoscript_docs_auto/tasks.md +0 -479
  83. package/dist/xanoscript_docs_auto/testing.md +0 -574
  84. package/dist/xanoscript_docs_auto/tools.md +0 -485
  85. package/dist/xanoscript_docs_auto/triggers.md +0 -595
  86. package/dist/xanoscript_docs_auto/types.md +0 -323
  87. package/dist/xanoscript_docs_auto/variables.md +0 -462
  88. package/dist/xanoscript_docs_auto/version.json +0 -5
  89. /package/dist/{api_docs → cli_docs}/topics/function.d.ts +0 -0
  90. /package/dist/{api_docs → cli_docs}/topics/start.d.ts +0 -0
  91. /package/dist/{api_docs → cli_docs}/topics/workspace.d.ts +0 -0
@@ -12,7 +12,7 @@ HTTP endpoint definitions in XanoScript.
12
12
  query "endpoint-path" verb=<METHOD> {
13
13
  api_group = "<GroupName>" // Required: API group for organization
14
14
  description = "What this endpoint does"
15
- auth = "<table>" // Optional: require authentication
15
+ auth = "<table>" // Optional: table with auth = true (usually "user")
16
16
  input { ... }
17
17
  stack { ... }
18
18
  response = $result
@@ -24,16 +24,19 @@ query "endpoint-path" verb=<METHOD> {
24
24
  The query name is **required** and **must be a non-empty string**. Empty names (`query "" verb=...`) are invalid. The name defines the endpoint path after the API group canonical.
25
25
 
26
26
  **Full URL path structure:**
27
+
27
28
  ```
28
29
  /<api_group canonical>/<query name>
29
30
  ```
30
31
 
31
32
  The query name can include slashes for nested paths:
33
+
32
34
  - `query "list" verb=GET` → `/<canonical>/list`
33
35
  - `query "users/{id}" verb=GET` → `/<canonical>/users/{id}`
34
36
  - `query "admin/reports/daily" verb=GET` → `/<canonical>/admin/reports/daily`
35
37
 
36
38
  ### HTTP Methods
39
+
37
40
  `GET`, `POST`, `PUT`, `PATCH`, `DELETE`
38
41
 
39
42
  ### API Groups (Required)
@@ -41,25 +44,50 @@ The query name can include slashes for nested paths:
41
44
  Every endpoint must belong to an API group. Each group is a folder with an `api_group.xs` file:
42
45
 
43
46
  ```xs
47
+ // Minimal definition
44
48
  api_group "users" {
45
- canonical = "users" // Required: URL path segment
49
+ canonical = "myapp-users" // Required: URL path segment (unique at instance level)
46
50
  description = "User management" // Optional
47
51
  }
48
52
  ```
49
53
 
54
+ **Full definition with all options:**
55
+
56
+ ```xs
57
+ api_group Authentication {
58
+ active = false // Disable group (cannot be externally invoked)
59
+ canonical = "plmgzl-s" // Required: unique at instance level
60
+ swagger = {token: "cbO83nMTt7BVgq3QcQgKikDfHeo"} // Protect Swagger docs behind a token (plain text)
61
+ tags = ["auth", "security", "encrypted"] // Tags for organization
62
+ history = 100 // Request history: up to 100 statements per request
63
+ }
64
+ ```
65
+
66
+ | Property | Type | Required | Description |
67
+ | ------------- | ------ | -------- | --------------------------------------------------------------------------- |
68
+ | `canonical` | text | Yes | URL path segment, must be unique at the instance level |
69
+ | `description` | text | No | Human-readable description |
70
+ | `active` | bool | No | Whether the group accepts external requests (default: `true`) |
71
+ | `swagger` | object | No | Swagger documentation settings. `token` protects access (stored plain text) |
72
+ | `tags` | list | No | Tags for organization and filtering |
73
+ | `history` | int | No | Max number of statements recorded per request for debugging |
74
+
75
+ **Canonical uniqueness:** A Xano instance can host multiple workspaces. The `canonical` is used to route requests between workspaces and must be **unique at the instance level**, not just within your workspace. Use a descriptive, project-specific prefix to avoid collisions (e.g., `myapp-users` instead of `users`). A generic name like `user` is likely to conflict with another workspace's canonical on the same instance.
76
+
50
77
  ### File Structure
78
+
51
79
  ```
52
80
  apis/
53
81
  ├── users/
54
- │ ├── api_group.xs // Defines group (canonical = "users")
55
- │ ├── list.xs // GET /users/list
56
- │ └── by-id.xs // GET/PATCH/DELETE /users/{id}
82
+ │ ├── api_group.xs // Defines group (canonical = "myapp-users")
83
+ │ ├── list.xs // GET /myapp-users/list
84
+ │ └── by-id.xs // GET/PATCH/DELETE /myapp-users/{id}
57
85
  └── products/
58
- ├── api_group.xs // Defines group (canonical = "products")
59
- └── search.xs // GET /products/search
86
+ ├── api_group.xs // Defines group (canonical = "myapp-products")
87
+ └── search.xs // GET /myapp-products/search
60
88
  ```
61
89
 
62
- Full URL: `/<canonical>/<query name>` (e.g., `/users/profile`)
90
+ Full URL: `/<canonical>/<query name>` (e.g., `/myapp-users/profile`)
63
91
 
64
92
  ---
65
93
 
@@ -88,22 +116,24 @@ query "products" verb=GET {
88
116
 
89
117
  For complete type and filter reference, use `xanoscript_docs({ topic: "types" })`.
90
118
 
91
- ### Empty Input Blocks
119
+ ### Empty and Single-Input Blocks
92
120
 
93
- **CRITICAL:** When an endpoint has no input parameters, the input block braces MUST be on separate lines. `input {}` on a single line will cause parsing errors.
121
+ Empty input blocks and single-input blocks can be written as one-liners. When there are two or more inputs, each must be on its own line.
94
122
 
95
123
  ```xs
96
- // CORRECT - braces on separate lines
124
+ // OK - empty input
97
125
  query "health" verb=GET {
98
126
  api_group = "System"
99
- input {
100
- }
127
+ input {}
101
128
  stack { ... }
102
129
  response = { status: "ok" }
103
130
  }
104
131
 
105
- // WRONG - causes parsing errors
106
- input {}
132
+ // OK - single input as one-liner
133
+ input { text query filters=trim }
134
+
135
+ // WRONG - multiple inputs on one line will cause parsing errors
136
+ input { text query filters=trim int limit }
107
137
  ```
108
138
 
109
139
  ---
@@ -111,6 +141,7 @@ input {}
111
141
  ## Authentication
112
142
 
113
143
  ### Public Endpoint (default)
144
+
114
145
  ```xs
115
146
  query "status" verb=GET {
116
147
  api_group = "System"
@@ -120,10 +151,13 @@ query "status" verb=GET {
120
151
  ```
121
152
 
122
153
  ### Authenticated Endpoint
154
+
155
+ The `auth` attribute references a table that has `auth = true` in its definition (see [tables.md](tables.md)). This is typically the `user` table. While multiple auth tables are supported, it's recommended to use a single auth table and control access levels with a role flag or RBAC pattern.
156
+
123
157
  ```xs
124
158
  query "profile" verb=GET {
125
159
  api_group = "Users"
126
- auth = "user" // Requires valid JWT
160
+ auth = "user" // Must reference a table with auth = true
127
161
  stack {
128
162
  db.get "user" {
129
163
  field_name = "id"
@@ -135,6 +169,8 @@ query "profile" verb=GET {
135
169
  ```
136
170
 
137
171
  When `auth` is set:
172
+
173
+ - The referenced table must have `auth = true` in its table definition
138
174
  - Endpoint requires Bearer token in `Authorization` header
139
175
  - `$auth.id` contains authenticated user's ID
140
176
  - Invalid/missing token returns 401
@@ -143,21 +179,26 @@ When `auth` is set:
143
179
 
144
180
  ## Path Parameters
145
181
 
146
- Use `{param}` in the path:
182
+ Use `{param}` in the path and capture its value in the input block:
147
183
 
148
184
  ```xs
149
185
  query "users/{user_id}" verb=GET {
150
- api_group = "Users"
186
+ api_group = "Authentication"
151
187
  auth = "user"
188
+
152
189
  input {
153
- int user_id { table = "user" }
190
+ int user_id {
191
+ table = "user"
192
+ }
154
193
  }
194
+
155
195
  stack {
156
196
  db.get "user" {
157
197
  field_name = "id"
158
198
  field_value = $input.user_id
159
199
  } as $user
160
200
  }
201
+
161
202
  response = $user
162
203
  }
163
204
  ```
@@ -167,6 +208,7 @@ query "users/{user_id}" verb=GET {
167
208
  ## CRUD Examples
168
209
 
169
210
  ### List (GET)
211
+
170
212
  ```xs
171
213
  query "products" verb=GET {
172
214
  api_group = "Products"
@@ -187,6 +229,7 @@ query "products" verb=GET {
187
229
  ```
188
230
 
189
231
  ### Create (POST)
232
+
190
233
  ```xs
191
234
  query "products" verb=POST {
192
235
  api_group = "Products"
@@ -213,6 +256,7 @@ query "products" verb=POST {
213
256
  ```
214
257
 
215
258
  ### Read (GET with ID)
259
+
216
260
  ```xs
217
261
  query "products/{product_id}" verb=GET {
218
262
  api_group = "Products"
@@ -235,6 +279,7 @@ query "products/{product_id}" verb=GET {
235
279
  ```
236
280
 
237
281
  ### Update (PATCH)
282
+
238
283
  ```xs
239
284
  query "products/{product_id}" verb=PATCH {
240
285
  api_group = "Products"
@@ -250,15 +295,19 @@ query "products/{product_id}" verb=PATCH {
250
295
 
251
296
  conditional {
252
297
  if ($input.name != null) {
253
- var.update $updates { value = $updates|set:"name":$input.name }
298
+ var.update $updates.name { value = $input.name }
254
299
  }
255
300
  }
256
301
  conditional {
257
302
  if ($input.price != null) {
258
- var.update $updates { value = $updates|set:"price":$input.price }
303
+ var.update $updates.price { value = $input.price }
259
304
  }
260
305
  }
261
306
 
307
+ precondition (($updates|is_empty) == false) {
308
+ error = "No updates provided"
309
+ }
310
+
262
311
  db.patch "product" {
263
312
  field_name = "id"
264
313
  field_value = $input.product_id
@@ -270,6 +319,7 @@ query "products/{product_id}" verb=PATCH {
270
319
  ```
271
320
 
272
321
  ### Delete (DELETE)
322
+
273
323
  ```xs
274
324
  query "products/{product_id}" verb=DELETE {
275
325
  api_group = "Products"
@@ -292,11 +342,13 @@ query "products/{product_id}" verb=DELETE {
292
342
  ## Response Types
293
343
 
294
344
  ### JSON (default)
345
+
295
346
  ```xs
296
347
  response = $data
297
348
  ```
298
349
 
299
350
  ### HTML
351
+
300
352
  ```xs
301
353
  stack {
302
354
  util.set_header {
@@ -316,6 +368,7 @@ response = $html
316
368
  ```
317
369
 
318
370
  ### Streaming
371
+
319
372
  ```xs
320
373
  stack {
321
374
  api.stream { value = $processed_data }
@@ -347,12 +400,12 @@ stack {
347
400
 
348
401
  For complete error handling reference, use `xanoscript_docs({ topic: "syntax" })`.
349
402
 
350
- | Type | HTTP Status |
351
- |------|-------------|
352
- | `inputerror` | 400 |
353
- | `accessdenied` | 403 |
354
- | `notfound` | 404 |
355
- | `standard` | 500 |
403
+ | Type | HTTP Status |
404
+ | -------------- | ----------- |
405
+ | `inputerror` | 400 |
406
+ | `accessdenied` | 403 |
407
+ | `notfound` | 404 |
408
+ | `standard` | 500 |
356
409
 
357
410
  ---
358
411
 
@@ -381,3 +434,4 @@ When using `return = { type: "list", paging: {...} }`:
381
434
  3. **Authenticate writes** - Always require auth for POST/PATCH/DELETE
382
435
  4. **Paginate lists** - Never return unbounded result sets
383
436
  5. **Group by resource** - Organize endpoints in logical api groups
437
+ 6. **Use specific canonicals** - Prefix canonicals to avoid instance-level collisions (e.g., `myapp-users` not `users`)
@@ -89,7 +89,7 @@ branch "production" {
89
89
 
90
90
  ## History Configuration
91
91
 
92
- Control how many historical executions are retained for debugging and auditing.
92
+ Control how many statements from the execution trace are retained per request. Execution traces are kept for 24 hours; this setting limits how many stack statements are recorded in each trace.
93
93
 
94
94
  ### Syntax
95
95
 
@@ -112,23 +112,23 @@ branch "production" {
112
112
 
113
113
  | Value | Description |
114
114
  |-------|-------------|
115
- | `false` | Disable history (no retention) |
116
- | `10` | Keep last 10 executions |
117
- | `100` | Keep last 100 executions |
118
- | `1000` | Keep last 1000 executions |
119
- | `10000` | Keep last 10000 executions |
120
- | `"all"` | Keep all executions (use with caution) |
115
+ | `false` | Disable history (no statements recorded) |
116
+ | `10` | Record up to 10 statements per trace |
117
+ | `100` | Record up to 100 statements per trace |
118
+ | `1000` | Record up to 1000 statements per trace |
119
+ | `10000` | Record up to 10000 statements per trace |
120
+ | `"all"` | Record all statements (use with caution) |
121
121
 
122
122
  ### History Targets
123
123
 
124
124
  | Target | Description |
125
125
  |--------|-------------|
126
- | `function` | Function execution history |
127
- | `query` | API endpoint request history |
128
- | `task` | Scheduled task execution history |
129
- | `tool` | AI tool invocation history |
130
- | `trigger` | Trigger execution history |
131
- | `middleware` | Middleware execution history |
126
+ | `function` | Statement limit for function traces |
127
+ | `query` | Statement limit for API endpoint traces |
128
+ | `task` | Statement limit for scheduled task traces |
129
+ | `tool` | Statement limit for AI tool traces |
130
+ | `trigger` | Statement limit for trigger traces |
131
+ | `middleware` | Statement limit for middleware traces |
132
132
 
133
133
  ---
134
134
 
@@ -8,17 +8,17 @@ Complete reference for XanoScript database operations.
8
8
 
9
9
  ## Quick Reference
10
10
 
11
- | Operation | Purpose | Returns |
12
- |-----------|---------|---------|
13
- | `db.query` | Query multiple records | List/single/count/exists |
14
- | `db.get` | Get single record by field | Record or null |
15
- | `db.has` | Check if record exists | Boolean |
16
- | `db.add` | Insert new record | Created record |
17
- | `db.edit` | Update record (inline data) | Updated record |
18
- | `db.patch` | Update record (variable data) | Updated record |
19
- | `db.add_or_edit` | Upsert record | Record |
20
- | `db.del` | Delete record | None |
21
- | `db.truncate` | Delete all records | None |
11
+ | Operation | Purpose | Returns |
12
+ | ---------------- | ----------------------------- | ------------------------ |
13
+ | `db.query` | Query multiple records | List/single/count/exists |
14
+ | `db.get` | Get single record by field | Record or null |
15
+ | `db.has` | Check if record exists | Boolean |
16
+ | `db.add` | Insert new record | Created record |
17
+ | `db.edit` | Update record (inline data) | Updated record |
18
+ | `db.patch` | Update record (variable data) | Updated record |
19
+ | `db.add_or_edit` | Upsert record | Record |
20
+ | `db.del` | Delete record | None |
21
+ | `db.truncate` | Delete all records | None |
22
22
 
23
23
  ---
24
24
 
@@ -27,6 +27,7 @@ Complete reference for XanoScript database operations.
27
27
  Query multiple records with filters, sorting, and pagination.
28
28
 
29
29
  ### Basic Query
30
+
30
31
  ```xs
31
32
  db.query "product" {
32
33
  where = $db.product.is_active == true
@@ -34,6 +35,7 @@ db.query "product" {
34
35
  ```
35
36
 
36
37
  ### Where Operators
38
+
37
39
  ```xs
38
40
  // Comparison
39
41
  $db.product.price == 100
@@ -62,13 +64,14 @@ $db.product.category == "electronics" || $db.product.featured == true
62
64
  ```
63
65
 
64
66
  ### Return Types
67
+
65
68
  ```xs
66
- // List (default)
69
+ // returns an array of products (default)
67
70
  db.query "product" {
68
71
  return = { type: "list" }
69
72
  } as $products
70
73
 
71
- // With pagination
74
+ // Returns a paginated list of products
72
75
  db.query "product" {
73
76
  return = {
74
77
  type: "list",
@@ -76,19 +79,19 @@ db.query "product" {
76
79
  }
77
80
  } as $products
78
81
 
79
- // Single record
82
+ // Returns a single record
80
83
  db.query "product" {
81
84
  where = $db.product.sku == $input.sku
82
85
  return = { type: "single" }
83
86
  } as $product
84
87
 
85
- // Count
88
+ // Returns a count (number)
86
89
  db.query "product" {
87
90
  where = $db.product.is_active == true
88
91
  return = { type: "count" }
89
92
  } as $count
90
93
 
91
- // Exists
94
+ // Returns a boolean indicating existence
92
95
  db.query "product" {
93
96
  where = $db.product.email == $input.email
94
97
  return = { type: "exists" }
@@ -96,6 +99,7 @@ db.query "product" {
96
99
  ```
97
100
 
98
101
  ### Sorting
102
+
99
103
  ```xs
100
104
  db.query "product" {
101
105
  sort = { created_at: "desc" } // Descending
@@ -105,6 +109,7 @@ db.query "product" {
105
109
  ```
106
110
 
107
111
  ### Joins
112
+
108
113
  ```xs
109
114
  db.query "comment" {
110
115
  join = {
@@ -114,11 +119,15 @@ db.query "comment" {
114
119
  where: $db.comment.post_id == $db.post.id
115
120
  }
116
121
  }
122
+ eval = {
123
+ post_title: $db.post.title
124
+ }
117
125
  where = $db.post.author_id == $auth.id
118
126
  } as $comments
119
127
  ```
120
128
 
121
129
  ### Eval (Computed Fields)
130
+
122
131
  ```xs
123
132
  db.query "order" {
124
133
  join = {
@@ -132,6 +141,7 @@ db.query "order" {
132
141
  ```
133
142
 
134
143
  ### Addons (Related Data)
144
+
135
145
  ```xs
136
146
  db.query "post" {
137
147
  where = $db.post.author_id == $auth.id
@@ -141,6 +151,30 @@ db.query "post" {
141
151
  } as $posts
142
152
  ```
143
153
 
154
+ ### Vector Search (Similarity)
155
+
156
+ Search by vector similarity using embeddings. Requires a `vector` column with a `vector` index on the table (see [tables.md](tables.md)).
157
+
158
+ ```xs
159
+ // Embeddings from an LLM engine
160
+ var $embeddings {
161
+ value = [0.345, 0.1553, ...]
162
+ }
163
+
164
+ db.query agent_message {
165
+ sort = {distance: "asc"}
166
+ eval = {
167
+ distance: $db.agent_message.embeddings|cosine_distance:$embeddings
168
+ }
169
+ return = {
170
+ type : "list"
171
+ paging: {page: 1, per_page: 5, metadata: false}
172
+ }
173
+ } as $search_results
174
+ ```
175
+
176
+ The `cosine_distance` filter computes the distance between the row's vector and the provided embeddings. Sort by `distance` ascending (smallest distance = most similar) — this ordering is required to leverage the PostgreSQL vector index.
177
+
144
178
  ---
145
179
 
146
180
  ## db.get
@@ -338,6 +372,7 @@ db.transaction {
338
372
  Filters for use in `where` clauses:
339
373
 
340
374
  ### String/Text
375
+
341
376
  ```xs
342
377
  $db.name|to_lower // Case conversion
343
378
  $db.name|concat:" " // Concatenation
@@ -345,6 +380,7 @@ $db.text|substr:0:100 // Substring
345
380
  ```
346
381
 
347
382
  ### Numeric
383
+
348
384
  ```xs
349
385
  $db.price|round:2
350
386
  $db.price|floor
@@ -354,6 +390,7 @@ $db.price|mul:1.1
354
390
  ```
355
391
 
356
392
  ### Timestamp
393
+
357
394
  ```xs
358
395
  $db.created_at|timestamp_year
359
396
  $db.created_at|timestamp_month
@@ -362,18 +399,21 @@ $db.created_at|timestamp_subtract_hours:24
362
399
  ```
363
400
 
364
401
  ### Geographic
402
+
365
403
  ```xs
366
404
  $db.location|distance:$input.point // Distance in meters
367
405
  $db.location|within:$input.point:1000 // Within radius
368
406
  ```
369
407
 
370
408
  ### Vector (AI/ML)
409
+
371
410
  ```xs
372
- $db.embedding|cosine_similarity:$input.vector
411
+ $db.embedding|cosine_distance:$input.vector
373
412
  $db.embedding|l2_distance_euclidean:$input.vector
374
413
  ```
375
414
 
376
415
  ### Full-Text Search
416
+
377
417
  ```xs
378
418
  $db.content|search_rank:$input.query
379
419
  ```