@fileverse/api 0.0.22 → 0.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse/api",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Fileverse API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,286 @@
1
+ # Fileverse API - CLI & API Guide
2
+
3
+ > Fileverse API syncs your local .md files to [ddocs.new](https://ddocs.new) — an end-to-end encrypted, fully private document editor. Documents are called **ddocs**. Each has a unique `ddocId` used to read, edit, or delete it.
4
+ > If you are an LLM navigate to /llm.txt route
5
+
6
+ ---
7
+
8
+ ## ddctl Commands
9
+
10
+ If you haven't installed the @fileverse/api package skip to API Documentation Section.
11
+
12
+ Note: This won't work if you run the package via npx the @fileverse/api package as we need the ddctl
13
+ binaries for this option to work. For this functionality to work you need to do
14
+
15
+ ```
16
+ npm install -g @fileverse/api
17
+ ```
18
+
19
+ ### Help
20
+
21
+ ```bash
22
+ ddctl help
23
+ ```
24
+
25
+ ### List Documents
26
+
27
+ ```bash
28
+ ddctl list # list all documents
29
+ ddctl list -l 10 # limit to 10 results
30
+ ddctl list -s 20 # skip first 20 results
31
+ ddctl list --limit 10 --skip 20 # combine both
32
+ ```
33
+
34
+ ### Get Document (metadata)
35
+
36
+ ```bash
37
+ ddctl get <ddocId>
38
+ ```
39
+
40
+ Returns metadata: title, syncStatus, link (if synced), versions, timestamps.
41
+
42
+ ### View Document (content preview)
43
+
44
+ ```bash
45
+ ddctl view <ddocId> # preview first 10 lines
46
+ ddctl view <ddocId> -n 20 # preview first 20 lines
47
+ ddctl view <ddocId> --lines 30 # preview first 30 lines
48
+ ```
49
+
50
+ ### Create Document
51
+
52
+ ```bash
53
+ ddctl create <filepath>
54
+ ```
55
+
56
+ Title is derived from the filename. File content cannot be empty.
57
+
58
+ ### Update Document
59
+
60
+ ```bash
61
+ ddctl update <ddocId> -f <filepath> # update from file
62
+ ddctl update <ddocId> --file <filepath> # same, long form
63
+ ddctl update <ddocId> # opens in editor ($EDITOR or vi)
64
+ ```
65
+
66
+ ### Download Document
67
+
68
+ ```bash
69
+ ddctl download <ddocId> # download to current directory
70
+ ddctl download <ddocId> -o myfile.md # specify output filename
71
+ ddctl download <ddocId> --output myfile.md
72
+ ```
73
+
74
+ ### Delete Document
75
+
76
+ ```bash
77
+ ddctl delete <ddocId> # delete one document
78
+ ddctl delete <id1> <id2> <id3> # delete multiple (space-separated)
79
+ ```
80
+
81
+ ### Failed Events (sync troubleshooting)
82
+
83
+ ```bash
84
+ ddctl events list-failed # list failed blockchain sync events
85
+ ddctl events retry <eventId> # retry a specific failed event
86
+ ddctl events retry-all # retry all failed events
87
+ ```
88
+
89
+ ---
90
+
91
+ ## API Endpoints
92
+
93
+ Base URL: `{SERVER_URL}` (e.g. `http://localhost:8001`)
94
+
95
+ All authenticated endpoints require `apiKey` as a **query parameter**.
96
+
97
+ ### Health Check
98
+
99
+ ```
100
+ GET /ping
101
+ ```
102
+
103
+ No auth required. Returns `{"reply": "pong"}`.
104
+
105
+ ### List Documents
106
+
107
+ ```
108
+ GET /api/ddocs?apiKey={API_KEY}&limit=10&skip=0
109
+ ```
110
+
111
+ Response:
112
+ ```json
113
+ {
114
+ "ddocs": [ ... ],
115
+ "total": 100,
116
+ "hasNext": true
117
+ }
118
+ ```
119
+
120
+ ### Get Document
121
+
122
+ ```
123
+ GET /api/ddocs/{ddocId}?apiKey={API_KEY}
124
+ ```
125
+
126
+ Response:
127
+ ```json
128
+ {
129
+ "ddocId": "abc123",
130
+ "title": "My Document",
131
+ "content": "...",
132
+ "syncStatus": "pending | synced | failed",
133
+ "link": "https://...",
134
+ "localVersion": 2,
135
+ "onchainVersion": 2,
136
+ "isDeleted": 0,
137
+ "createdAt": "...",
138
+ "updatedAt": "..."
139
+ }
140
+ ```
141
+
142
+ ### Create Document (JSON)
143
+
144
+ ```
145
+ POST /api/ddocs?apiKey={API_KEY}
146
+ Content-Type: application/json
147
+
148
+ {
149
+ "title": "Document Title",
150
+ "content": "Document content here..."
151
+ }
152
+ ```
153
+
154
+ Response (201):
155
+ ```json
156
+ {
157
+ "message": "...",
158
+ "data": {
159
+ "ddocId": "abc123",
160
+ "title": "...",
161
+ "syncStatus": "pending",
162
+ ...
163
+ }
164
+ }
165
+ ```
166
+
167
+ Extract `ddocId` from `response.data.ddocId`.
168
+
169
+ ### Create Document (File Upload)
170
+
171
+ ```
172
+ POST /api/ddocs?apiKey={API_KEY}
173
+ Content-Type: multipart/form-data
174
+
175
+ Field: "file" = <your file>
176
+ ```
177
+
178
+ Title is derived from filename. Max file size: 10MB.
179
+
180
+ ### Update Document (JSON)
181
+
182
+ ```
183
+ PUT /api/ddocs/{ddocId}?apiKey={API_KEY}
184
+ Content-Type: application/json
185
+
186
+ {
187
+ "title": "New Title",
188
+ "content": "Updated content..."
189
+ }
190
+ ```
191
+
192
+ Both fields are optional — send only what you want to change.
193
+
194
+ ### Update Document (File Upload)
195
+
196
+ ```
197
+ PUT /api/ddocs/{ddocId}?apiKey={API_KEY}
198
+ Content-Type: multipart/form-data
199
+
200
+ Field: "file" = <your updated file>
201
+ ```
202
+
203
+ ### Delete Document
204
+
205
+ ```
206
+ DELETE /api/ddocs/{ddocId}?apiKey={API_KEY}
207
+ ```
208
+
209
+ ### Search Documents
210
+
211
+ ```
212
+ GET /api/search?apiKey={API_KEY}&q={query}&limit=10&skip=0
213
+ ```
214
+
215
+ Response:
216
+ ```json
217
+ {
218
+ "nodes": [ ... ],
219
+ "total": 5,
220
+ "hasNext": false
221
+ }
222
+ ```
223
+
224
+ Note: search returns `nodes`, not `ddocs`.
225
+
226
+ ### OpenAPI Spec
227
+
228
+ ```
229
+ GET {SERVER_URL}/openapi.json
230
+ ```
231
+
232
+ Machine-readable OpenAPI 3.1 specification.
233
+
234
+ ---
235
+
236
+ ## Quick Reference
237
+
238
+ ### API Endpoints
239
+
240
+ | Method | Path | Description |
241
+ |--------|-----------------------------------|--------------------------|
242
+ | GET | /ping | Health check (no auth) |
243
+ | GET | /api/ddocs | List documents |
244
+ | GET | /api/ddocs/{ddocId} | Get document |
245
+ | POST | /api/ddocs | Create document |
246
+ | PUT | /api/ddocs/{ddocId} | Update document |
247
+ | DELETE | /api/ddocs/{ddocId} | Delete document |
248
+ | GET | /api/search?q={query} | Search documents |
249
+
250
+ ### ddctl Commands
251
+
252
+ | Command | Description |
253
+ |--------------------------------|------------------------------------|
254
+ | ddctl list | List documents |
255
+ | ddctl get {ddocId} | Get document metadata |
256
+ | ddctl view {ddocId} | Preview document content |
257
+ | ddctl create {filepath} | Create document from file |
258
+ | ddctl update {ddocId} | Update document (editor or file) |
259
+ | ddctl download {ddocId} | Download document to file |
260
+ | ddctl delete {ddocId} [...] | Delete one or more documents |
261
+
262
+ ---
263
+
264
+ ## Sync Status
265
+
266
+ After creating or updating a document, it syncs to the blockchain asynchronously:
267
+
268
+ | Status | Meaning |
269
+ |-----------|--------------------------------------------|
270
+ | `pending` | Saved locally, blockchain sync in progress |
271
+ | `synced` | Published on blockchain, `link` available |
272
+ | `failed` | Sync failed — use events retry to fix |
273
+
274
+ Typical sync time: 5-30 seconds.
275
+
276
+ ---
277
+
278
+ ## Error Codes
279
+
280
+ | Code | Meaning |
281
+ |------|--------------------------------------------------|
282
+ | 400 | Validation error (missing/invalid body or params)|
283
+ | 401 | Invalid or missing API key |
284
+ | 404 | Resource not found |
285
+ | 429 | Rate limited — respect Retry-After header |
286
+ | 500 | Internal server error |