gufi-cli 0.1.49 → 0.1.51

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 (36) hide show
  1. package/dist/commands/docs.js +1 -5
  2. package/dist/lib/docs-resolver.d.ts +8 -0
  3. package/dist/lib/docs-resolver.js +27 -0
  4. package/dist/lib/security.js +5 -0
  5. package/dist/mcp.js +56 -43
  6. package/docs/dev-guide/1-01-architecture.md +358 -0
  7. package/docs/dev-guide/1-02-multi-tenant.md +415 -0
  8. package/docs/dev-guide/1-03-column-types.md +594 -0
  9. package/docs/dev-guide/1-04-json-config.md +442 -0
  10. package/docs/dev-guide/1-05-authentication.md +427 -0
  11. package/docs/dev-guide/2-01-api-reference.md +564 -0
  12. package/docs/dev-guide/2-02-automations.md +508 -0
  13. package/docs/dev-guide/2-03-gufi-cli.md +568 -0
  14. package/docs/dev-guide/2-04-realtime.md +401 -0
  15. package/docs/dev-guide/2-05-permissions.md +497 -0
  16. package/docs/dev-guide/2-06-integrations-overview.md +104 -0
  17. package/docs/dev-guide/2-07-stripe.md +173 -0
  18. package/docs/dev-guide/2-08-nayax.md +297 -0
  19. package/docs/dev-guide/2-09-ourvend.md +226 -0
  20. package/docs/dev-guide/2-10-tns.md +177 -0
  21. package/docs/dev-guide/2-11-custom-http.md +268 -0
  22. package/docs/dev-guide/3-01-custom-views.md +555 -0
  23. package/docs/dev-guide/3-02-webhooks-api.md +446 -0
  24. package/docs/mcp/00-overview.md +329 -0
  25. package/docs/mcp/01-architecture.md +226 -0
  26. package/docs/mcp/02-modules.md +285 -0
  27. package/docs/mcp/03-fields.md +357 -0
  28. package/docs/mcp/04-views.md +613 -0
  29. package/docs/mcp/05-automations.md +461 -0
  30. package/docs/mcp/06-api.md +531 -0
  31. package/docs/mcp/07-packages.md +246 -0
  32. package/docs/mcp/08-common-errors.md +284 -0
  33. package/docs/mcp/09-examples.md +453 -0
  34. package/docs/mcp/README.md +71 -0
  35. package/docs/mcp/tool-descriptions.json +64 -0
  36. package/package.json +3 -2
@@ -0,0 +1,594 @@
1
+ ---
2
+ id: column-types
3
+ title: "Column Types Reference"
4
+ description: "Complete guide to Gufi field types"
5
+ icon: List
6
+ category: dev
7
+ part: 1
8
+ ---
9
+
10
+ # Column Types Reference
11
+
12
+ Complete guide to Gufi field types
13
+
14
+ ## Overview
15
+
16
+ Column types define how data is stored, validated, and displayed. Each type maps to specific PostgreSQL types and frontend components.
17
+
18
+ ## Type Mapping
19
+
20
+ | Gufi Type | PostgreSQL Type | Frontend Component |
21
+ |---|---|---|
22
+ | text | VARCHAR(255) | TextInput |
23
+ | longtext | TEXT | TextArea |
24
+ | number | NUMERIC | NumberInput |
25
+ | integer | INTEGER | NumberInput |
26
+ | currency | JSONB | CurrencyInput |
27
+ | percentage | NUMERIC(5,2) | PercentageInput |
28
+ | date | TIMESTAMP | DatePicker (+ includeTime para hora) |
29
+ | time | TIME | TimePicker |
30
+ | select | VARCHAR(100) | SelectDropdown |
31
+ | multiselect | JSONB | MultiSelect |
32
+ | checkbox | BOOLEAN | Checkbox |
33
+ | ref | INTEGER + FK | RelationPicker |
34
+ | multiref | JSONB | MultiRelationPicker |
35
+ | user | INTEGER + FK | UserPicker |
36
+ | file | JSONB | FileUpload |
37
+ | image | JSONB | ImageUpload |
38
+ | phone | JSONB | PhoneInput |
39
+ | email | VARCHAR(255) | EmailInput |
40
+ | url | VARCHAR(500) | UrlInput |
41
+ | location | JSONB | LocationInput |
42
+ | formula | (computed) | FormulaDisplay |
43
+ | autonumber | SERIAL | AutoNumber |
44
+ | rating | SMALLINT | RatingStars |
45
+
46
+ ## Text Types
47
+
48
+ ### text
49
+
50
+ Standard single-line text.
51
+
52
+ ```json
53
+ {
54
+ "name": "product_name",
55
+ "type": "text",
56
+ "label": "Product Name",
57
+ "required": true,
58
+ "maxLength": 255,
59
+ "unique": false
60
+ }
61
+ ```
62
+
63
+ **PostgreSQL:**
64
+ ```sql
65
+ product_name VARCHAR(255)
66
+ ```
67
+
68
+ ### longtext
69
+
70
+ Multi-line text for descriptions.
71
+
72
+ ```json
73
+ {
74
+ "name": "description",
75
+ "type": "longtext",
76
+ "label": "Description",
77
+ "maxLength": 10000
78
+ }
79
+ ```
80
+
81
+ **PostgreSQL:**
82
+ ```sql
83
+ description TEXT
84
+ ```
85
+
86
+ ### email
87
+
88
+ Email with validation.
89
+
90
+ ```json
91
+ {
92
+ "name": "contact_email",
93
+ "type": "email",
94
+ "label": "Email",
95
+ "unique": true
96
+ }
97
+ ```
98
+
99
+ **Validation:** Regex pattern for valid email format.
100
+
101
+ ### url
102
+
103
+ URL with validation.
104
+
105
+ ```json
106
+ {
107
+ "name": "website",
108
+ "type": "url",
109
+ "label": "Website"
110
+ }
111
+ ```
112
+
113
+ **Validation:** Must be valid URL format.
114
+
115
+ ## Numeric Types
116
+
117
+ ### number
118
+
119
+ Decimal numbers.
120
+
121
+ ```json
122
+ {
123
+ "name": "price",
124
+ "type": "number",
125
+ "label": "Price",
126
+ "decimalPlaces": 2,
127
+ "min": 0,
128
+ "max": 999999
129
+ }
130
+ ```
131
+
132
+ **PostgreSQL:**
133
+ ```sql
134
+ price NUMERIC(12, 2)
135
+ ```
136
+
137
+ ### number_int
138
+
139
+ Whole numbers only.
140
+
141
+ ```json
142
+ {
143
+ "name": "quantity",
144
+ "type": "number_int",
145
+ "label": "Quantity",
146
+ "min": 0
147
+ }
148
+ ```
149
+
150
+ **PostgreSQL:**
151
+ ```sql
152
+ quantity INTEGER
153
+ ```
154
+
155
+ ### currency
156
+
157
+ Dinero. El código de moneda se define en el schema del campo.
158
+
159
+ ```json
160
+ {
161
+ "name": "total",
162
+ "type": "currency",
163
+ "label": "Total",
164
+ "currency": "EUR"
165
+ }
166
+ ```
167
+
168
+ **PostgreSQL:**
169
+ ```sql
170
+ total NUMERIC -- Solo el número, currency code en schema
171
+ ```
172
+
173
+ **Storage:** `150.00` (número, NO objeto JSONB)
174
+
175
+ **Usar CB.currency():**
176
+ ```javascript
177
+ gufi.CB.currency(150) // → 150
178
+ ```
179
+
180
+ **Display:** "€ 150.00" (el símbolo se obtiene del schema)
181
+
182
+ ### percentage
183
+
184
+ Percentage values.
185
+
186
+ ```json
187
+ {
188
+ "name": "discount",
189
+ "type": "percentage",
190
+ "label": "Discount"
191
+ }
192
+ ```
193
+
194
+ **Storage:** Stored as decimal (15% = 0.15)
195
+
196
+ **Display:** "15%"
197
+
198
+ ### rating
199
+
200
+ Star rating.
201
+
202
+ ```json
203
+ {
204
+ "name": "customer_rating",
205
+ "type": "rating",
206
+ "label": "Rating",
207
+ "maxStars": 5
208
+ }
209
+ ```
210
+
211
+ **PostgreSQL:**
212
+ ```sql
213
+ customer_rating SMALLINT CHECK (customer_rating >= 0 AND customer_rating <= 5)
214
+ ```
215
+
216
+ ## Date/Time Types
217
+
218
+ ### date
219
+
220
+ Fecha. Siempre se almacena como TIMESTAMP en PostgreSQL.
221
+
222
+ ```json
223
+ {
224
+ "name": "due_date",
225
+ "type": "date",
226
+ "label": "Due Date"
227
+ }
228
+ ```
229
+
230
+ **Con hora (includeTime: true):**
231
+ ```json
232
+ {
233
+ "name": "appointment",
234
+ "type": "date",
235
+ "includeTime": true,
236
+ "label": "Appointment"
237
+ }
238
+ ```
239
+
240
+ **PostgreSQL:**
241
+ ```sql
242
+ due_date TIMESTAMP -- Siempre TIMESTAMP, no DATE
243
+ ```
244
+
245
+ **API Format:** `"2024-01-15T00:00:00.000Z"` (ISO 8601 completo)
246
+
247
+ **Usar CB.date():**
248
+ ```javascript
249
+ gufi.CB.date() // Hoy medianoche: "2024-01-15T00:00:00.000Z"
250
+ gufi.CB.date('2024-06-15') // Fecha específica: "2024-06-15T00:00:00.000Z"
251
+ gufi.CB.date(new Date()) // Ahora con hora: "2024-01-15T14:30:00.000Z"
252
+ ```
253
+
254
+ **Display:** Si `includeTime: true`, muestra fecha y hora. Si no, solo fecha.
255
+
256
+ ### time
257
+
258
+ Time of day only.
259
+
260
+ ```json
261
+ {
262
+ "name": "opening_time",
263
+ "type": "time",
264
+ "label": "Opens At"
265
+ }
266
+ ```
267
+
268
+ **PostgreSQL:**
269
+ ```sql
270
+ opening_time TIME
271
+ ```
272
+
273
+ **API Format:** "14:30:00"
274
+
275
+ ## Selection Types
276
+
277
+ ### select
278
+
279
+ Single choice from options.
280
+
281
+ ```json
282
+ {
283
+ "name": "status",
284
+ "type": "select",
285
+ "label": "Status",
286
+ "options": [
287
+ { "value": "draft", "label": "Draft", "color": "gray" },
288
+ { "value": "active", "label": "Active", "color": "green" },
289
+ { "value": "archived", "label": "Archived", "color": "red" }
290
+ ],
291
+ "default": "draft"
292
+ }
293
+ ```
294
+
295
+ **PostgreSQL:**
296
+ ```sql
297
+ status VARCHAR(100)
298
+ ```
299
+
300
+ ### multiselect
301
+
302
+ Multiple choices.
303
+
304
+ ```json
305
+ {
306
+ "name": "tags",
307
+ "type": "multiselect",
308
+ "label": "Tags",
309
+ "options": [
310
+ { "value": "urgent", "label": "Urgent" },
311
+ { "value": "featured", "label": "Featured" },
312
+ { "value": "new", "label": "New" }
313
+ ]
314
+ }
315
+ ```
316
+
317
+ **Storage Format (JSONB):**
318
+ ```json
319
+ ["urgent", "featured"]
320
+ ```
321
+
322
+ ### checkbox
323
+
324
+ Boolean yes/no.
325
+
326
+ ```json
327
+ {
328
+ "name": "is_active",
329
+ "type": "checkbox",
330
+ "label": "Active",
331
+ "default": true
332
+ }
333
+ ```
334
+
335
+ **PostgreSQL:**
336
+ ```sql
337
+ is_active BOOLEAN DEFAULT true
338
+ ```
339
+
340
+ ## Relationship Types
341
+
342
+ ### ref
343
+
344
+ Single relation to another entity.
345
+
346
+ ```json
347
+ {
348
+ "name": "category",
349
+ "type": "ref",
350
+ "label": "Category",
351
+ "ref": "inventory.categories"
352
+ }
353
+ ```
354
+
355
+ **PostgreSQL:**
356
+ ```sql
357
+ category INTEGER REFERENCES m360_t4590(id)
358
+ ```
359
+
360
+ **Important:** Always use full format `module.entity` for the ref value.
361
+
362
+ ### multiref
363
+
364
+ Multiple relations.
365
+
366
+ ```json
367
+ {
368
+ "name": "suppliers",
369
+ "type": "multiref",
370
+ "label": "Suppliers",
371
+ "ref": "inventory.suppliers"
372
+ }
373
+ ```
374
+
375
+ **Storage Format (JSONB):**
376
+ ```json
377
+ [1, 5, 12]
378
+ ```
379
+
380
+ ### user
381
+
382
+ Relation to Gufi user.
383
+
384
+ ```json
385
+ {
386
+ "name": "assigned_to",
387
+ "type": "user",
388
+ "label": "Assigned To"
389
+ }
390
+ ```
391
+
392
+ **PostgreSQL:**
393
+ ```sql
394
+ assigned_to INTEGER REFERENCES core.users(id)
395
+ ```
396
+
397
+ ## File Types
398
+
399
+ ### file
400
+
401
+ Document attachments.
402
+
403
+ ```json
404
+ {
405
+ "name": "contract",
406
+ "type": "file",
407
+ "label": "Contract",
408
+ "allowedTypes": ["pdf", "doc", "docx"],
409
+ "maxSize": 10485760
410
+ }
411
+ ```
412
+
413
+ **Storage Format (JSONB):**
414
+ ```json
415
+ {
416
+ "url": "https://storage.gufi.com/...",
417
+ "name": "contract.pdf",
418
+ "mime": "application/pdf",
419
+ "size": 245678
420
+ }
421
+ ```
422
+
423
+ ### image
424
+
425
+ Image attachments with thumbnails.
426
+
427
+ ```json
428
+ {
429
+ "name": "photo",
430
+ "type": "image",
431
+ "label": "Photo",
432
+ "multiple": true
433
+ }
434
+ ```
435
+
436
+ **Storage Format (JSONB) - Multiple:**
437
+ ```json
438
+ [
439
+ {
440
+ "url": "https://storage.gufi.com/...",
441
+ "name": "photo1.jpg",
442
+ "mime": "image/jpeg",
443
+ "size": 123456,
444
+ "thumbnail": "https://storage.gufi.com/thumb/..."
445
+ }
446
+ ]
447
+ ```
448
+
449
+ ## Location Types
450
+
451
+ ### phone
452
+
453
+ Phone number with country code.
454
+
455
+ ```json
456
+ {
457
+ "name": "phone",
458
+ "type": "phone",
459
+ "label": "Phone"
460
+ }
461
+ ```
462
+
463
+ **Storage Format (JSONB):**
464
+ ```json
465
+ {
466
+ "prefix": "+34",
467
+ "number": "612345678"
468
+ }
469
+ ```
470
+
471
+ **Display:** "+34 612 345 678"
472
+
473
+ ### location
474
+
475
+ Address with optional geocoding.
476
+
477
+ ```json
478
+ {
479
+ "name": "address",
480
+ "type": "location",
481
+ "label": "Address",
482
+ "geocode": true
483
+ }
484
+ ```
485
+
486
+ **Storage Format (JSONB):**
487
+ ```json
488
+ {
489
+ "street": "Calle Mayor",
490
+ "number": "15",
491
+ "city": "Madrid",
492
+ "state": "Madrid",
493
+ "country": "Spain",
494
+ "postal_code": "28013",
495
+ "lat": 40.4168,
496
+ "lng": -3.7038
497
+ }
498
+ ```
499
+
500
+ ## Special Types
501
+
502
+ ### formula
503
+
504
+ Calculated field (not stored, computed on read).
505
+
506
+ ```json
507
+ {
508
+ "name": "total",
509
+ "type": "formula",
510
+ "label": "Total",
511
+ "formula": "price * quantity",
512
+ "resultType": "number"
513
+ }
514
+ ```
515
+
516
+ **Note:** Formula fields don't create database columns. They're computed at query time.
517
+
518
+ ### autonumber
519
+
520
+ Auto-incrementing identifier.
521
+
522
+ ```json
523
+ {
524
+ "name": "invoice_number",
525
+ "type": "autonumber",
526
+ "label": "Invoice #",
527
+ "prefix": "INV-",
528
+ "padding": 5
529
+ }
530
+ ```
531
+
532
+ **Display:** "INV-00001", "INV-00002", ...
533
+
534
+ ## Field Properties
535
+
536
+ ### Common Properties
537
+
538
+ All field types support:
539
+
540
+ | Property | Type | Description |
541
+ |---|---|---|
542
+ | name | string | Internal field name |
543
+ | type | string | Column type |
544
+ | label | string/object | Display label |
545
+ | required | boolean | Must have value |
546
+ | unique | boolean | No duplicates |
547
+ | default | any | Default value |
548
+ | hidden | boolean | Hide from UI |
549
+ | readonly | boolean | Cannot edit |
550
+ | help | string | Help text |
551
+
552
+ ### Label Localization
553
+
554
+ Labels can be localized:
555
+
556
+ ```json
557
+ {
558
+ "name": "status",
559
+ "type": "select",
560
+ "label": {
561
+ "es": "Estado",
562
+ "en": "Status"
563
+ }
564
+ }
565
+ ```
566
+
567
+ ## Creating Fields via API
568
+
569
+ ```javascript
570
+ // Add field to entity
571
+ POST /api/entities/:entityId/fields
572
+ {
573
+ "name": "new_field",
574
+ "type": "text",
575
+ "label": "New Field",
576
+ "required": false
577
+ }
578
+ ```
579
+
580
+ ## Type Validation
581
+
582
+ Each type has built-in validation:
583
+
584
+ | Type | Validation |
585
+ |---|---|
586
+ | email | Valid email format |
587
+ | url | Valid URL format |
588
+ | phone | Valid phone format |
589
+ | number | Within min/max range |
590
+ | date | Valid date |
591
+ | select | Value in options |
592
+ | ref | Referenced record exists |
593
+
594
+ Custom validation can be added via automations.