gufi-cli 0.1.50 → 0.1.52

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 (37) hide show
  1. package/dist/commands/docs.js +1 -5
  2. package/dist/index.js +1 -0
  3. package/dist/lib/docs-resolver.d.ts +8 -0
  4. package/dist/lib/docs-resolver.js +27 -0
  5. package/dist/mcp.d.ts +3 -1
  6. package/dist/mcp.js +232 -34
  7. package/docs/dev-guide/1-01-architecture.md +358 -0
  8. package/docs/dev-guide/1-02-multi-tenant.md +415 -0
  9. package/docs/dev-guide/1-03-column-types.md +594 -0
  10. package/docs/dev-guide/1-04-json-config.md +442 -0
  11. package/docs/dev-guide/1-05-authentication.md +427 -0
  12. package/docs/dev-guide/2-01-api-reference.md +564 -0
  13. package/docs/dev-guide/2-02-automations.md +508 -0
  14. package/docs/dev-guide/2-03-gufi-cli.md +568 -0
  15. package/docs/dev-guide/2-04-realtime.md +401 -0
  16. package/docs/dev-guide/2-05-permissions.md +497 -0
  17. package/docs/dev-guide/2-06-integrations-overview.md +104 -0
  18. package/docs/dev-guide/2-07-stripe.md +173 -0
  19. package/docs/dev-guide/2-08-nayax.md +297 -0
  20. package/docs/dev-guide/2-09-ourvend.md +226 -0
  21. package/docs/dev-guide/2-10-tns.md +177 -0
  22. package/docs/dev-guide/2-11-custom-http.md +268 -0
  23. package/docs/dev-guide/3-01-custom-views.md +555 -0
  24. package/docs/dev-guide/3-02-webhooks-api.md +446 -0
  25. package/docs/mcp/00-overview.md +329 -0
  26. package/docs/mcp/01-architecture.md +220 -0
  27. package/docs/mcp/02-modules.md +285 -0
  28. package/docs/mcp/03-fields.md +357 -0
  29. package/docs/mcp/04-views.md +613 -0
  30. package/docs/mcp/05-automations.md +461 -0
  31. package/docs/mcp/06-api.md +480 -0
  32. package/docs/mcp/07-packages.md +246 -0
  33. package/docs/mcp/08-common-errors.md +284 -0
  34. package/docs/mcp/09-examples.md +453 -0
  35. package/docs/mcp/README.md +71 -0
  36. package/docs/mcp/tool-descriptions.json +49 -0
  37. package/package.json +3 -2
@@ -0,0 +1,564 @@
1
+ ---
2
+ id: api-reference
3
+ title: "API Reference"
4
+ description: "Complete REST API documentation"
5
+ icon: Code
6
+ category: dev
7
+ part: 2
8
+ ---
9
+
10
+ # API Reference
11
+
12
+ Complete REST API documentation
13
+
14
+ ## Base URL
15
+
16
+ ```
17
+ Production: https://api.gogufi.com/api
18
+ Development: http://localhost:3000/api
19
+ ```
20
+
21
+ ## Authentication
22
+
23
+ ### Login
24
+
25
+ ```http
26
+ POST /auth/login
27
+ Content-Type: application/json
28
+
29
+ {
30
+ "email": "user@example.com",
31
+ "password": "your_password"
32
+ }
33
+ ```
34
+
35
+ **Response:**
36
+ ```json
37
+ {
38
+ "token": "eyJhbGciOiJIUzI1NiIs...",
39
+ "user": {
40
+ "id": 123,
41
+ "email": "user@example.com",
42
+ "name": "John Doe"
43
+ }
44
+ }
45
+ ```
46
+
47
+ Also sets HttpOnly refresh cookie.
48
+
49
+ ### Using Authentication
50
+
51
+ Include token in Authorization header:
52
+
53
+ ```http
54
+ GET /api/tables/products
55
+ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
56
+ X-Company-ID: 146
57
+ ```
58
+
59
+ ### Refresh Token
60
+
61
+ ```http
62
+ POST /auth/refresh
63
+ Cookie: refresh_token=...
64
+ ```
65
+
66
+ Returns new access token.
67
+
68
+ ## Company Context
69
+
70
+ Most endpoints require company context:
71
+
72
+ ```http
73
+ X-Company-ID: 146
74
+ ```
75
+
76
+ This header specifies which company's data to access.
77
+
78
+ ## CRUD Operations
79
+
80
+ ### List Records
81
+
82
+ ```http
83
+ GET /tables/:tableId
84
+ ```
85
+
86
+ **Query Parameters:**
87
+
88
+ | Parameter | Type | Description |
89
+ |---|---|---|
90
+ | page | number | Page number (default: 1) |
91
+ | pageSize | number | Records per page (default: 20, max: 100) |
92
+ | sort | string | Sort field |
93
+ | order | string | asc or desc |
94
+ | filter | object | Filter conditions (JSON) |
95
+ | search | string | Full-text search |
96
+
97
+ **Example:**
98
+ ```http
99
+ GET /tables/products?page=1&pageSize=20&sort=created_at&order=desc
100
+ ```
101
+
102
+ **Response:**
103
+ ```json
104
+ {
105
+ "data": [
106
+ {
107
+ "id": 1,
108
+ "name": "Widget Pro",
109
+ "price": { "currency": "EUR", "amount": 99.99 },
110
+ "stock": 150,
111
+ "created_at": "2024-01-15T10:30:00Z"
112
+ }
113
+ ],
114
+ "meta": {
115
+ "total": 100,
116
+ "page": 1,
117
+ "pageSize": 20,
118
+ "totalPages": 5
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Get Single Record
124
+
125
+ ```http
126
+ GET /tables/:tableId/:rowId
127
+ ```
128
+
129
+ **Response:**
130
+ ```json
131
+ {
132
+ "data": {
133
+ "id": 1,
134
+ "name": "Widget Pro",
135
+ "price": { "currency": "EUR", "amount": 99.99 },
136
+ "stock": 150,
137
+ "category": {
138
+ "id": 5,
139
+ "name": "Electronics"
140
+ },
141
+ "created_at": "2024-01-15T10:30:00Z",
142
+ "updated_at": "2024-01-16T14:20:00Z"
143
+ }
144
+ }
145
+ ```
146
+
147
+ ### Create Record
148
+
149
+ ```http
150
+ POST /tables/:tableId
151
+ Content-Type: application/json
152
+
153
+ {
154
+ "name": "New Product",
155
+ "price": { "currency": "EUR", "amount": 49.99 },
156
+ "stock": 100,
157
+ "category": 5
158
+ }
159
+ ```
160
+
161
+ **Response:**
162
+ ```json
163
+ {
164
+ "data": {
165
+ "id": 101,
166
+ "name": "New Product",
167
+ ...
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### Update Record
173
+
174
+ ```http
175
+ PUT /tables/:tableId/:rowId
176
+ Content-Type: application/json
177
+
178
+ {
179
+ "price": { "currency": "EUR", "amount": 59.99 },
180
+ "stock": 80
181
+ }
182
+ ```
183
+
184
+ Only include fields you want to update.
185
+
186
+ ### Delete Record
187
+
188
+ ```http
189
+ DELETE /tables/:tableId/:rowId
190
+ ```
191
+
192
+ **Response:**
193
+ ```json
194
+ {
195
+ "success": true,
196
+ "message": "Record deleted"
197
+ }
198
+ ```
199
+
200
+ ## Filtering
201
+
202
+ ### Simple Filters
203
+
204
+ ```http
205
+ GET /tables/products?filter={"status":"active"}
206
+ ```
207
+
208
+ ### Comparison Operators
209
+
210
+ ```json
211
+ {
212
+ "price": { "$gt": 100 },
213
+ "stock": { "$lte": 50 },
214
+ "status": { "$ne": "archived" }
215
+ }
216
+ ```
217
+
218
+ | Operator | Description |
219
+ |---|---|
220
+ | $eq | Equals (default) |
221
+ | $ne | Not equals |
222
+ | $gt | Greater than |
223
+ | $gte | Greater or equal |
224
+ | $lt | Less than |
225
+ | $lte | Less or equal |
226
+ | $in | In array |
227
+ | $nin | Not in array |
228
+ | $like | Pattern match |
229
+ | $null | Is null |
230
+
231
+ ### Complex Filters
232
+
233
+ ```json
234
+ {
235
+ "$and": [
236
+ { "status": "active" },
237
+ { "price": { "$gt": 100 } }
238
+ ]
239
+ }
240
+ ```
241
+
242
+ ```json
243
+ {
244
+ "$or": [
245
+ { "status": "urgent" },
246
+ { "priority": "high" }
247
+ ]
248
+ }
249
+ ```
250
+
251
+ ### Date Filters
252
+
253
+ ```json
254
+ {
255
+ "created_at": {
256
+ "$gte": "2024-01-01",
257
+ "$lt": "2024-02-01"
258
+ }
259
+ }
260
+ ```
261
+
262
+ ## Bulk Operations
263
+
264
+ ### Bulk Create
265
+
266
+ ```http
267
+ POST /tables/:tableId/bulk
268
+ Content-Type: application/json
269
+
270
+ {
271
+ "records": [
272
+ { "name": "Product 1", "price": 10 },
273
+ { "name": "Product 2", "price": 20 },
274
+ { "name": "Product 3", "price": 30 }
275
+ ]
276
+ }
277
+ ```
278
+
279
+ ### Bulk Update
280
+
281
+ ```http
282
+ PUT /tables/:tableId/bulk
283
+ Content-Type: application/json
284
+
285
+ {
286
+ "ids": [1, 2, 3],
287
+ "data": {
288
+ "status": "archived"
289
+ }
290
+ }
291
+ ```
292
+
293
+ ### Bulk Delete
294
+
295
+ ```http
296
+ DELETE /tables/:tableId/bulk
297
+ Content-Type: application/json
298
+
299
+ {
300
+ "ids": [1, 2, 3]
301
+ }
302
+ ```
303
+
304
+ ## Module & Entity Endpoints
305
+
306
+ ### List Modules
307
+
308
+ ```http
309
+ GET /modules?company_id=146
310
+ ```
311
+
312
+ ### Get Module
313
+
314
+ ```http
315
+ GET /modules/:moduleId
316
+ ```
317
+
318
+ ### List Entities
319
+
320
+ ```http
321
+ GET /entities?module_id=360
322
+ ```
323
+
324
+ ### Get Entity
325
+
326
+ ```http
327
+ GET /entities/:entityId
328
+ ```
329
+
330
+ ### Get Company Schema
331
+
332
+ ```http
333
+ GET /companies/:companyId/schema
334
+ ```
335
+
336
+ Returns complete schema including all modules and entities.
337
+
338
+ ## File Upload
339
+
340
+ ### Upload File
341
+
342
+ ```http
343
+ POST /upload
344
+ Content-Type: multipart/form-data
345
+
346
+ file: (binary)
347
+ ```
348
+
349
+ **Response:**
350
+ ```json
351
+ {
352
+ "url": "https://storage.gufi.com/files/abc123.pdf",
353
+ "name": "document.pdf",
354
+ "mime": "application/pdf",
355
+ "size": 245678
356
+ }
357
+ ```
358
+
359
+ ### Upload Image
360
+
361
+ ```http
362
+ POST /upload/image
363
+ Content-Type: multipart/form-data
364
+
365
+ file: (binary)
366
+ ```
367
+
368
+ Also generates thumbnail.
369
+
370
+ ## Automations
371
+
372
+ ### Run Click Automation
373
+
374
+ ```http
375
+ POST /automations/click
376
+ Content-Type: application/json
377
+
378
+ {
379
+ "company_id": 146,
380
+ "module_id": 360,
381
+ "table_id": 4589,
382
+ "function_name": "send_email",
383
+ "table_name": "orders",
384
+ "input": {
385
+ "record_id": 123,
386
+ "template": "order_confirmation"
387
+ }
388
+ }
389
+ ```
390
+
391
+ ### Get Automation Scripts
392
+
393
+ ```http
394
+ GET /automations/scripts?company_id=146
395
+ ```
396
+
397
+ ### Get Execution History
398
+
399
+ ```http
400
+ GET /automations/executions?company_id=146&limit=50
401
+ ```
402
+
403
+ ## Webhooks
404
+
405
+ ### Entity Webhooks
406
+
407
+ When webhooks are enabled for an entity:
408
+
409
+ ```http
410
+ GET /webhook/e/:entityId/:token
411
+ POST /webhook/e/:entityId/:token
412
+ PUT /webhook/e/:entityId/:token/:rowId
413
+ DELETE /webhook/e/:entityId/:token/:rowId
414
+ ```
415
+
416
+ No authentication required (token in URL provides access).
417
+
418
+ ## Error Responses
419
+
420
+ ### Error Format
421
+
422
+ ```json
423
+ {
424
+ "error": {
425
+ "code": "VALIDATION_ERROR",
426
+ "message": "Validation failed",
427
+ "details": {
428
+ "field": "email",
429
+ "reason": "Invalid email format"
430
+ }
431
+ }
432
+ }
433
+ ```
434
+
435
+ ### Error Codes
436
+
437
+ | Code | HTTP Status | Description |
438
+ |---|---|---|
439
+ | UNAUTHORIZED | 401 | Invalid or missing token |
440
+ | FORBIDDEN | 403 | No permission |
441
+ | NOT_FOUND | 404 | Resource not found |
442
+ | VALIDATION_ERROR | 400 | Invalid input |
443
+ | CONFLICT | 409 | Duplicate or conflict |
444
+ | INTERNAL_ERROR | 500 | Server error |
445
+
446
+ ## Rate Limiting
447
+
448
+ | Tier | Limit |
449
+ |---|---|
450
+ | Standard | 100 requests/minute |
451
+ | Pro | 500 requests/minute |
452
+ | Enterprise | Custom |
453
+
454
+ Rate limit headers:
455
+
456
+ ```http
457
+ X-RateLimit-Limit: 100
458
+ X-RateLimit-Remaining: 95
459
+ X-RateLimit-Reset: 1699999999
460
+ ```
461
+
462
+ ## Pagination
463
+
464
+ ### Offset-Based (Default)
465
+
466
+ ```http
467
+ GET /tables/products?page=2&pageSize=20
468
+ ```
469
+
470
+ ### Keyset Pagination (Large Datasets)
471
+
472
+ ```http
473
+ GET /tables/products?after_id=1000&limit=20
474
+ ```
475
+
476
+ More efficient for large tables.
477
+
478
+ ## Field-Specific Formats
479
+
480
+ ### Currency Input
481
+
482
+ ```json
483
+ {
484
+ "price": {
485
+ "currency": "EUR",
486
+ "amount": 150.00
487
+ }
488
+ }
489
+ ```
490
+
491
+ ### Phone Input
492
+
493
+ ```json
494
+ {
495
+ "phone": {
496
+ "prefix": "+34",
497
+ "number": "612345678"
498
+ }
499
+ }
500
+ ```
501
+
502
+ ### Location Input
503
+
504
+ ```json
505
+ {
506
+ "address": {
507
+ "street": "Calle Mayor",
508
+ "number": "15",
509
+ "city": "Madrid",
510
+ "country": "Spain",
511
+ "postal_code": "28013"
512
+ }
513
+ }
514
+ ```
515
+
516
+ ### File Input
517
+
518
+ First upload file, then use returned URL:
519
+
520
+ ```json
521
+ {
522
+ "document": {
523
+ "url": "https://storage.gufi.com/...",
524
+ "name": "contract.pdf",
525
+ "mime": "application/pdf",
526
+ "size": 245678
527
+ }
528
+ }
529
+ ```
530
+
531
+ ## SDK Usage
532
+
533
+ ### JavaScript/TypeScript
534
+
535
+ ```typescript
536
+ import { GufiClient } from '@gufi/sdk';
537
+
538
+ const client = new GufiClient({
539
+ baseUrl: 'https://api.gogufi.com',
540
+ token: 'your_token',
541
+ companyId: 146
542
+ });
543
+
544
+ // List products
545
+ const products = await client.tables.list('products', {
546
+ filter: { status: 'active' },
547
+ page: 1,
548
+ pageSize: 20
549
+ });
550
+
551
+ // Create product
552
+ const newProduct = await client.tables.create('products', {
553
+ name: 'New Widget',
554
+ price: { currency: 'EUR', amount: 99.99 }
555
+ });
556
+
557
+ // Update product
558
+ await client.tables.update('products', 1, {
559
+ stock: 50
560
+ });
561
+
562
+ // Delete product
563
+ await client.tables.delete('products', 1);
564
+ ```