@xano/developer-mcp 2.1.0 → 2.2.1-beta.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/dist/cli_docs/topics/auth.js +41 -7
- package/dist/cli_docs/topics/profile.js +71 -2
- package/dist/cli_docs/topics/sandbox.js +2 -1
- package/dist/cli_docs/topics/start.js +10 -3
- package/dist/cli_docs/topics/static_host.js +221 -26
- package/dist/tools/index.d.ts +1 -3
- package/dist/tools/xanoscript_docs.d.ts +1 -3
- package/dist/tools/xanoscript_docs.js +4 -4
- package/dist/xanoscript.d.ts +8 -0
- package/dist/xanoscript.js +43 -3
- package/dist/xanoscript_docs/README.md +1 -0
- package/dist/xanoscript_docs/docs_index.json +17 -4
- package/dist/xanoscript_docs/essentials.md +27 -0
- package/dist/xanoscript_docs/file-uploads.md +408 -0
- package/dist/xanoscript_docs/integrations/utilities.md +61 -21
- package/dist/xanoscript_docs/types.md +12 -1
- package/dist/xanoscript_docs/version.json +1 -1
- package/package.json +1 -1
|
@@ -23,42 +23,70 @@ applyTo: "function/**/*.xs, api/**/*.xs, task/*.xs"
|
|
|
23
23
|
|
|
24
24
|
### File Operations
|
|
25
25
|
|
|
26
|
+
> **⚠️ XanoScript comments use `//`, never `#`.** A `#` inside a `.xs` file is a parse error. Also: comments are not allowed inside an operation's `{ ... }` argument block — keep them on their own line above the op.
|
|
27
|
+
|
|
26
28
|
```xs
|
|
27
|
-
|
|
29
|
+
// create_file_resource turns in-stack data (CSV/JSON/zip output) into a FILE
|
|
30
|
+
// RESOURCE — the same value type a `file?` input produces. It is NOT a stored
|
|
31
|
+
// vault file and has no servable URL/path of its own; to persist or serve it,
|
|
32
|
+
// pass it to storage.create_attachment (see "Storing a generated file" below).
|
|
28
33
|
storage.create_file_resource {
|
|
29
34
|
filename = "report.csv"
|
|
30
35
|
filedata = $csv_content
|
|
31
|
-
} as $
|
|
36
|
+
} as $resource
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
// read_file_resource returns the contents of a file resource (e.g. to parse it).
|
|
34
39
|
storage.read_file_resource {
|
|
35
|
-
value = $input.
|
|
40
|
+
value = $input.upload
|
|
36
41
|
} as $content
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
storage.delete_file { pathname =
|
|
43
|
+
// Delete a stored vault file by its `.path` (the value saved on the DB record).
|
|
44
|
+
storage.delete_file { pathname = $stored_file.path }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Storing a generated file (so it has a URL)
|
|
48
|
+
|
|
49
|
+
A `create_file_resource` value cannot be served directly. Store it via `storage.create_attachment` (or `create_image`), then serve it like any uploaded file — `sign_private_url` for private, or instance URL + `.path` for public:
|
|
50
|
+
|
|
51
|
+
```xs
|
|
52
|
+
storage.create_file_resource {
|
|
53
|
+
filename = "export.csv"
|
|
54
|
+
filedata = $csv_content
|
|
55
|
+
} as $resource
|
|
56
|
+
storage.create_attachment {
|
|
57
|
+
value = $resource
|
|
58
|
+
access = "public"
|
|
59
|
+
filename = "export.csv"
|
|
60
|
+
} as $stored_file
|
|
40
61
|
```
|
|
41
62
|
|
|
63
|
+
Then return `($env.PUBLIC_BASE_URL ~ $stored_file.path)` for public, or `storage.sign_private_url` for private. See `xano_xanoscript_docs({ topic: "file-uploads" })`.
|
|
64
|
+
|
|
42
65
|
### Image/Attachment Handling
|
|
43
66
|
|
|
67
|
+
> **⚠️ Upload inputs must be typed `file?`, not `image?`/`attachment?`.** Only `file` populates `.path` on a multipart upload; the others pass the raw object and `storage.*` fails with `Missing param: path`. Use `storage.create_attachment` (any file type) over `storage.create_image` (image extensions only). Full pattern: `xano_xanoscript_docs({ topic: "file-uploads" })`.
|
|
68
|
+
|
|
44
69
|
```xs
|
|
45
|
-
|
|
70
|
+
// The upload input is declared `file?` so Xano populates `.path` first.
|
|
71
|
+
// input { file? upload }
|
|
72
|
+
|
|
73
|
+
// Create image metadata (images only: JPEG/PNG/GIF/WEBP)
|
|
46
74
|
storage.create_image {
|
|
47
|
-
value = $input.
|
|
75
|
+
value = $input.upload
|
|
48
76
|
access = "public"
|
|
49
|
-
filename =
|
|
77
|
+
filename = $input.upload.name
|
|
50
78
|
} as $image_meta
|
|
51
79
|
|
|
52
|
-
|
|
80
|
+
// Create attachment metadata (any file type — recommended default)
|
|
53
81
|
storage.create_attachment {
|
|
54
|
-
value = $input.
|
|
82
|
+
value = $input.upload
|
|
55
83
|
access = "private"
|
|
56
|
-
filename =
|
|
84
|
+
filename = $input.upload.name
|
|
57
85
|
} as $attachment_meta
|
|
58
86
|
|
|
59
|
-
|
|
87
|
+
// Sign private URL (use the stored .path, never a hand-built path)
|
|
60
88
|
storage.sign_private_url {
|
|
61
|
-
pathname =
|
|
89
|
+
pathname = $attachment_meta.path
|
|
62
90
|
ttl = 300
|
|
63
91
|
} as $signed_url
|
|
64
92
|
```
|
|
@@ -70,12 +98,12 @@ storage.sign_private_url {
|
|
|
70
98
|
### Password Hashing
|
|
71
99
|
|
|
72
100
|
```xs
|
|
73
|
-
|
|
101
|
+
// Password is auto-hashed on insert
|
|
74
102
|
db.add "user" {
|
|
75
103
|
data = { email: $input.email, password: $input.password }
|
|
76
104
|
}
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
// Verify password
|
|
79
107
|
security.check_password {
|
|
80
108
|
text_password = $input.password
|
|
81
109
|
hash_password = $user.password
|
|
@@ -85,7 +113,7 @@ security.check_password {
|
|
|
85
113
|
### Encryption
|
|
86
114
|
|
|
87
115
|
```xs
|
|
88
|
-
|
|
116
|
+
// Encrypt
|
|
89
117
|
security.encrypt {
|
|
90
118
|
data = $sensitive_data
|
|
91
119
|
algorithm = "aes-256-cbc"
|
|
@@ -93,7 +121,7 @@ security.encrypt {
|
|
|
93
121
|
iv = $env.ENCRYPTION_IV
|
|
94
122
|
} as $encrypted
|
|
95
123
|
|
|
96
|
-
|
|
124
|
+
// Decrypt
|
|
97
125
|
security.decrypt {
|
|
98
126
|
data = $encrypted
|
|
99
127
|
algorithm = "aes-256-cbc"
|
|
@@ -105,7 +133,7 @@ security.decrypt {
|
|
|
105
133
|
### JWT (JWS/JWE)
|
|
106
134
|
|
|
107
135
|
```xs
|
|
108
|
-
|
|
136
|
+
// Sign JWT
|
|
109
137
|
security.jws_encode {
|
|
110
138
|
claims = { user_id: $user.id, role: $user.role }
|
|
111
139
|
key = $env.JWT_SECRET
|
|
@@ -113,7 +141,7 @@ security.jws_encode {
|
|
|
113
141
|
ttl = 3600
|
|
114
142
|
} as $token
|
|
115
143
|
|
|
116
|
-
|
|
144
|
+
// Verify JWT
|
|
117
145
|
security.jws_decode {
|
|
118
146
|
token = $input.token
|
|
119
147
|
key = $env.JWT_SECRET
|
|
@@ -264,9 +292,21 @@ query "export_data" {
|
|
|
264
292
|
storage.create_file_resource {
|
|
265
293
|
filename = "export.zip"
|
|
266
294
|
filedata = $archive
|
|
295
|
+
} as $resource
|
|
296
|
+
|
|
297
|
+
// create_file_resource is not directly servable — store it to get a vault path.
|
|
298
|
+
storage.create_attachment {
|
|
299
|
+
value = $resource
|
|
300
|
+
access = "private"
|
|
301
|
+
filename = "export.zip"
|
|
267
302
|
} as $download
|
|
303
|
+
|
|
304
|
+
storage.sign_private_url {
|
|
305
|
+
pathname = $download.path
|
|
306
|
+
ttl = 600
|
|
307
|
+
} as $download_url
|
|
268
308
|
}
|
|
269
|
-
response = { download_url: $
|
|
309
|
+
response = { download_url: $download_url }
|
|
270
310
|
}
|
|
271
311
|
```
|
|
272
312
|
|
|
@@ -204,14 +204,25 @@ object[] items {
|
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
### File Types
|
|
207
|
+
|
|
208
|
+
> **⚠️ For uploaded files, always use `file`.** Only `file` pre-processes a multipart upload and populates `.path`; `image`/`attachment`/`video`/`audio` pass the raw upload object, so any `storage.*` op fails with `Missing param: path`. The names look like semantic choices but are technical. See `xano_xanoscript_docs({ topic: "file-uploads" })`.
|
|
209
|
+
|
|
207
210
|
```xs
|
|
211
|
+
// ✅ use `file` for ALL uploads — only `file` populates .path
|
|
212
|
+
file generic_file
|
|
213
|
+
// optional upload
|
|
214
|
+
file? document
|
|
215
|
+
// multiple uploads
|
|
216
|
+
file[]? attachments
|
|
217
|
+
|
|
218
|
+
// image/attachment/video/audio exist but DO NOT populate .path on upload —
|
|
219
|
+
// they are mainly useful as table column types for stored file metadata.
|
|
208
220
|
image photo {
|
|
209
221
|
description = "Profile photo"
|
|
210
222
|
}
|
|
211
223
|
attachment document
|
|
212
224
|
video recording
|
|
213
225
|
audio clip
|
|
214
|
-
file generic_file
|
|
215
226
|
```
|
|
216
227
|
|
|
217
228
|
### Geographic Types
|
package/package.json
CHANGED