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.
- package/dist/commands/docs.js +1 -5
- package/dist/index.js +1 -0
- package/dist/lib/docs-resolver.d.ts +8 -0
- package/dist/lib/docs-resolver.js +27 -0
- package/dist/mcp.d.ts +3 -1
- package/dist/mcp.js +232 -34
- package/docs/dev-guide/1-01-architecture.md +358 -0
- package/docs/dev-guide/1-02-multi-tenant.md +415 -0
- package/docs/dev-guide/1-03-column-types.md +594 -0
- package/docs/dev-guide/1-04-json-config.md +442 -0
- package/docs/dev-guide/1-05-authentication.md +427 -0
- package/docs/dev-guide/2-01-api-reference.md +564 -0
- package/docs/dev-guide/2-02-automations.md +508 -0
- package/docs/dev-guide/2-03-gufi-cli.md +568 -0
- package/docs/dev-guide/2-04-realtime.md +401 -0
- package/docs/dev-guide/2-05-permissions.md +497 -0
- package/docs/dev-guide/2-06-integrations-overview.md +104 -0
- package/docs/dev-guide/2-07-stripe.md +173 -0
- package/docs/dev-guide/2-08-nayax.md +297 -0
- package/docs/dev-guide/2-09-ourvend.md +226 -0
- package/docs/dev-guide/2-10-tns.md +177 -0
- package/docs/dev-guide/2-11-custom-http.md +268 -0
- package/docs/dev-guide/3-01-custom-views.md +555 -0
- package/docs/dev-guide/3-02-webhooks-api.md +446 -0
- package/docs/mcp/00-overview.md +329 -0
- package/docs/mcp/01-architecture.md +220 -0
- package/docs/mcp/02-modules.md +285 -0
- package/docs/mcp/03-fields.md +357 -0
- package/docs/mcp/04-views.md +613 -0
- package/docs/mcp/05-automations.md +461 -0
- package/docs/mcp/06-api.md +480 -0
- package/docs/mcp/07-packages.md +246 -0
- package/docs/mcp/08-common-errors.md +284 -0
- package/docs/mcp/09-examples.md +453 -0
- package/docs/mcp/README.md +71 -0
- package/docs/mcp/tool-descriptions.json +49 -0
- package/package.json +3 -2
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Endpoints principales del backend de Gufi.
|
|
4
|
+
|
|
5
|
+
## Autenticacion
|
|
6
|
+
|
|
7
|
+
### Login
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
POST /api/auth/login
|
|
11
|
+
{
|
|
12
|
+
"email": "user@example.com",
|
|
13
|
+
"password": "password123"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Response:
|
|
17
|
+
{
|
|
18
|
+
"accessToken": "eyJ...",
|
|
19
|
+
"refreshToken": "abc...",
|
|
20
|
+
"user": { "id": 16, "email": "...", "name": "..." }
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Refresh token
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
POST /api/auth/refresh
|
|
28
|
+
Headers:
|
|
29
|
+
X-Refresh-Token: {refreshToken}
|
|
30
|
+
|
|
31
|
+
Response:
|
|
32
|
+
{
|
|
33
|
+
"accessToken": "eyJ...",
|
|
34
|
+
"refreshToken": "abc..."
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Headers requeridos
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Authorization: Bearer {accessToken}
|
|
42
|
+
X-Company-ID: {companyId}
|
|
43
|
+
Content-Type: application/json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Companies
|
|
47
|
+
|
|
48
|
+
### Listar companies
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
GET /api/companies
|
|
52
|
+
|
|
53
|
+
Response:
|
|
54
|
+
{
|
|
55
|
+
"items": [
|
|
56
|
+
{ "id": 116, "name": "Mi Empresa", "created_at": "..." }
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Schema de company
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
GET /api/company/schema
|
|
65
|
+
|
|
66
|
+
Response:
|
|
67
|
+
{
|
|
68
|
+
"modules": [
|
|
69
|
+
{
|
|
70
|
+
"id": 360,
|
|
71
|
+
"name": "Ventas",
|
|
72
|
+
"submodules": [...]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Modules
|
|
79
|
+
|
|
80
|
+
### Listar modulos
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
GET /api/company/modules
|
|
84
|
+
|
|
85
|
+
Response:
|
|
86
|
+
[
|
|
87
|
+
{ "id": 360, "name": "ventas", "displayName": "Ventas", "entity_count": 3 }
|
|
88
|
+
]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Obtener modulo
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
GET /api/company/modules/{moduleId}
|
|
95
|
+
|
|
96
|
+
Response:
|
|
97
|
+
{
|
|
98
|
+
"id": 360,
|
|
99
|
+
"name": "ventas",
|
|
100
|
+
"json_definition": {...}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Actualizar modulo
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
PUT /api/company/modules/{moduleId}
|
|
108
|
+
{
|
|
109
|
+
"json_definition": {...}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Crear modulo
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
POST /api/company/modules
|
|
117
|
+
{
|
|
118
|
+
"json_definition": {...}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Tables (CRUD generico)
|
|
123
|
+
|
|
124
|
+
### Listar registros
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
POST /api/tables/{tableName}/list
|
|
128
|
+
{
|
|
129
|
+
"page": 1,
|
|
130
|
+
"perPage": 20,
|
|
131
|
+
"sorters": [{ "field": "created_at", "order": "desc" }],
|
|
132
|
+
"filter": [
|
|
133
|
+
{ "field": "estado", "operator": "eq", "value": "pendiente" }
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
Response:
|
|
138
|
+
{
|
|
139
|
+
"data": [...],
|
|
140
|
+
"meta": { "page": 1, "perPage": 20, "hasMore": true }
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
> **IMPORTANTE**: La paginacion usa `page` y `perPage` directamente en el body,
|
|
145
|
+
> NO `pagination: { current, pageSize }`. Usar el formato incorrecto hace que
|
|
146
|
+
> la API ignore la paginacion y siempre devuelva la primera pagina.
|
|
147
|
+
|
|
148
|
+
### Obtener registro
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
POST /api/tables/{tableName}/getOne
|
|
152
|
+
{
|
|
153
|
+
"id": 123
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
Response:
|
|
157
|
+
{
|
|
158
|
+
"data": { "id": 123, "nombre": "...", ... }
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Crear registro
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
POST /api/tables/{tableName}
|
|
166
|
+
{
|
|
167
|
+
"nombre": "Nuevo",
|
|
168
|
+
"precio": 150,
|
|
169
|
+
"estado": "pendiente"
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
Response (objeto directamente, NO envuelto en data):
|
|
173
|
+
{ "id": 124, "nombre": "Nuevo", "precio": 150, ... }
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
> **IMPORTANTE**: El endpoint de crear devuelve el objeto directamente,
|
|
177
|
+
> NO envuelto en `{ data: {...} }`. Verificar con `'id' in response`, no `'data' in response`.
|
|
178
|
+
|
|
179
|
+
### Actualizar registro
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
PUT /api/tables/{tableName}/{id}
|
|
183
|
+
{
|
|
184
|
+
"estado": "completado",
|
|
185
|
+
"estado__display": "Completado"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Eliminar registro
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
DELETE /api/tables/{tableName}/{id}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Eliminar multiples
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
POST /api/tables/{tableName}/deleteMany
|
|
199
|
+
{
|
|
200
|
+
"ids": [1, 2, 3]
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Agregaciones (Analytics)
|
|
205
|
+
|
|
206
|
+
Usar `gufi_data` con `action: 'aggregate'` para métricas y agregaciones.
|
|
207
|
+
|
|
208
|
+
### Count total
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
gufi_data({
|
|
212
|
+
action: 'aggregate',
|
|
213
|
+
table: 'ventas.pedidos',
|
|
214
|
+
agg: 'count',
|
|
215
|
+
company_id: '146'
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
// Response: { value: 1250 }
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Sum, Avg, Min, Max
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
// Suma total de ventas
|
|
225
|
+
gufi_data({
|
|
226
|
+
action: 'aggregate',
|
|
227
|
+
table: 'ventas.pedidos',
|
|
228
|
+
agg: 'sum',
|
|
229
|
+
field: 'total',
|
|
230
|
+
company_id: '146'
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
// Precio promedio
|
|
234
|
+
gufi_data({
|
|
235
|
+
action: 'aggregate',
|
|
236
|
+
table: 'ventas.productos',
|
|
237
|
+
agg: 'avg',
|
|
238
|
+
field: 'precio',
|
|
239
|
+
company_id: '146'
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Group By
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
// Ventas por cliente
|
|
247
|
+
gufi_data({
|
|
248
|
+
action: 'aggregate',
|
|
249
|
+
table: 'ventas.pedidos',
|
|
250
|
+
agg: 'sum',
|
|
251
|
+
field: 'total',
|
|
252
|
+
groupBy: 'cliente_id',
|
|
253
|
+
limit: 10,
|
|
254
|
+
company_id: '146'
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
// Response:
|
|
258
|
+
// { results: [
|
|
259
|
+
// { group: 'cliente_123', value: 15000 },
|
|
260
|
+
// { group: 'cliente_456', value: 12500 },
|
|
261
|
+
// ...
|
|
262
|
+
// ]}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Con filtros simples
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
// Filtrar por campo = valor
|
|
269
|
+
gufi_data({
|
|
270
|
+
action: 'aggregate',
|
|
271
|
+
table: 'ventas.pedidos',
|
|
272
|
+
agg: 'sum',
|
|
273
|
+
field: 'total',
|
|
274
|
+
filter: 'estado=completado',
|
|
275
|
+
company_id: '146'
|
|
276
|
+
})
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Con filtros de fecha
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
// Ventas del último mes
|
|
283
|
+
gufi_data({
|
|
284
|
+
action: 'aggregate',
|
|
285
|
+
table: 'ventas.pedidos',
|
|
286
|
+
agg: 'sum',
|
|
287
|
+
field: 'total',
|
|
288
|
+
groupBy: 'cliente_id',
|
|
289
|
+
dateField: 'fecha_venta',
|
|
290
|
+
dateFrom: '2025-12-26T00:00:00Z',
|
|
291
|
+
dateTo: '2026-01-26T23:59:59Z',
|
|
292
|
+
company_id: '146'
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
// Top 10 máquinas por ventas del mes
|
|
296
|
+
gufi_data({
|
|
297
|
+
action: 'aggregate',
|
|
298
|
+
table: 'nayax.machine_sales',
|
|
299
|
+
agg: 'sum',
|
|
300
|
+
field: 'settlement_value',
|
|
301
|
+
groupBy: 'machine_id',
|
|
302
|
+
dateField: 'settlement_datetime_gmt',
|
|
303
|
+
dateFrom: '2025-12-26T00:00:00Z',
|
|
304
|
+
dateTo: '2026-01-26T23:59:59Z',
|
|
305
|
+
company_id: '116'
|
|
306
|
+
})
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**Parámetros de fecha:**
|
|
310
|
+
- `dateField`: Campo de fecha para filtrar (requerido para filtros de fecha)
|
|
311
|
+
- `dateFrom`: Fecha inicio (ISO string, inclusive >=)
|
|
312
|
+
- `dateTo`: Fecha fin (ISO string, inclusive <=)
|
|
313
|
+
|
|
314
|
+
### Agregaciones disponibles
|
|
315
|
+
|
|
316
|
+
| agg | Descripcion | Requiere field |
|
|
317
|
+
|-----|-------------|----------------|
|
|
318
|
+
| `count` | Cuenta registros | No (opcional) |
|
|
319
|
+
| `sum` | Suma valores | Sí |
|
|
320
|
+
| `avg` | Promedio | Sí |
|
|
321
|
+
| `min` | Valor mínimo | Sí |
|
|
322
|
+
| `max` | Valor máximo | Sí |
|
|
323
|
+
|
|
324
|
+
## Automations
|
|
325
|
+
|
|
326
|
+
### Listar scripts
|
|
327
|
+
|
|
328
|
+
```
|
|
329
|
+
GET /api/automation-scripts
|
|
330
|
+
|
|
331
|
+
Response:
|
|
332
|
+
[
|
|
333
|
+
{ "id": 15, "name": "mi_script", "company_id": 116 }
|
|
334
|
+
]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Obtener script
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
GET /api/automation-scripts/{name}
|
|
341
|
+
|
|
342
|
+
Response:
|
|
343
|
+
{
|
|
344
|
+
"id": 15,
|
|
345
|
+
"name": "mi_script",
|
|
346
|
+
"js_code": "async function...",
|
|
347
|
+
"description": "..."
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Crear/actualizar script
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
PUT /api/automation-scripts/{name}
|
|
355
|
+
{
|
|
356
|
+
"js_code": "async function mi_script(gufi) {...}",
|
|
357
|
+
"description": "Descripcion"
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Trigger click automation
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
POST /api/automation-scripts/triggerClick
|
|
365
|
+
{
|
|
366
|
+
"table": "m360_t16192",
|
|
367
|
+
"row_id": 123,
|
|
368
|
+
"function_name": "generar_pdf",
|
|
369
|
+
"input": { "formato": "A4" }
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Ver executions
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
GET /api/automation-executions?limit=20&script_name=mi_script
|
|
377
|
+
|
|
378
|
+
Response:
|
|
379
|
+
[
|
|
380
|
+
{
|
|
381
|
+
"id": 456,
|
|
382
|
+
"script_name": "mi_script",
|
|
383
|
+
"status": "completed",
|
|
384
|
+
"duration_ms": 234,
|
|
385
|
+
"created_at": "..."
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Files
|
|
391
|
+
|
|
392
|
+
### Upload
|
|
393
|
+
|
|
394
|
+
```
|
|
395
|
+
POST /api/files/upload
|
|
396
|
+
Content-Type: multipart/form-data
|
|
397
|
+
|
|
398
|
+
FormData:
|
|
399
|
+
file: (binary)
|
|
400
|
+
|
|
401
|
+
Response:
|
|
402
|
+
{
|
|
403
|
+
"url": "company_116/abc123_file.pdf",
|
|
404
|
+
"name": "documento.pdf",
|
|
405
|
+
"size": 12345,
|
|
406
|
+
"mime": "application/pdf"
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Download
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
GET /api/files/download?path=company_116/abc123_file.pdf
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## Environment Variables
|
|
417
|
+
|
|
418
|
+
### Listar
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
GET /api/cli/env
|
|
422
|
+
|
|
423
|
+
Response:
|
|
424
|
+
[
|
|
425
|
+
{ "key": "SLACK_WEBHOOK", "is_secret": true },
|
|
426
|
+
{ "key": "PUBLIC_URL", "is_secret": false, "value": "https://..." }
|
|
427
|
+
]
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Crear/actualizar
|
|
431
|
+
|
|
432
|
+
```
|
|
433
|
+
POST /api/cli/env
|
|
434
|
+
{
|
|
435
|
+
"key": "NEW_API_KEY",
|
|
436
|
+
"value": "sk-..."
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Eliminar
|
|
441
|
+
|
|
442
|
+
```
|
|
443
|
+
DELETE /api/cli/env/{key}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
## Operadores de filtro
|
|
447
|
+
|
|
448
|
+
Para usar en `/api/tables/{table}/list`:
|
|
449
|
+
|
|
450
|
+
| Operador | Descripcion | Ejemplo |
|
|
451
|
+
|----------|-------------|---------|
|
|
452
|
+
| `eq` | Igual | `{ "field": "estado", "operator": "eq", "value": "activo" }` |
|
|
453
|
+
| `ne` | No igual | `{ "field": "estado", "operator": "ne", "value": "cancelado" }` |
|
|
454
|
+
| `gt` | Mayor que | `{ "field": "total", "operator": "gt", "value": 100 }` |
|
|
455
|
+
| `gte` | Mayor o igual | `{ "field": "total", "operator": "gte", "value": 100 }` |
|
|
456
|
+
| `lt` | Menor que | `{ "field": "total", "operator": "lt", "value": 1000 }` |
|
|
457
|
+
| `lte` | Menor o igual | `{ "field": "total", "operator": "lte", "value": 1000 }` |
|
|
458
|
+
| `contains` | Contiene texto | `{ "field": "nombre", "operator": "contains", "value": "juan" }` |
|
|
459
|
+
| `in` | En lista | `{ "field": "estado", "operator": "in", "value": ["a", "b"] }` |
|
|
460
|
+
| `null` | Es nulo | `{ "field": "deleted_at", "operator": "null", "value": true }` |
|
|
461
|
+
|
|
462
|
+
## Codigos de error
|
|
463
|
+
|
|
464
|
+
| Codigo | Significado |
|
|
465
|
+
|--------|-------------|
|
|
466
|
+
| 400 | Bad Request - Parametros invalidos |
|
|
467
|
+
| 401 | Unauthorized - Token invalido/expirado |
|
|
468
|
+
| 403 | Forbidden - Sin permisos |
|
|
469
|
+
| 404 | Not Found - Recurso no existe |
|
|
470
|
+
| 409 | Conflict - Ya existe |
|
|
471
|
+
| 429 | Too Many Requests - Rate limit |
|
|
472
|
+
| 500 | Internal Server Error |
|
|
473
|
+
|
|
474
|
+
## Rate limits
|
|
475
|
+
|
|
476
|
+
Por defecto (configurables):
|
|
477
|
+
- Login: 5 intentos/minuto
|
|
478
|
+
- Uploads: 20/minuto
|
|
479
|
+
- AI: 10/minuto
|
|
480
|
+
- General: 100/minuto
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Packages y Marketplace
|
|
2
|
+
|
|
3
|
+
Los packages agrupan modulos y vistas para distribucion en el Marketplace.
|
|
4
|
+
|
|
5
|
+
## Estructura de un package
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Package
|
|
9
|
+
├── Modules (snapshots)
|
|
10
|
+
│ └── Module JSON congelado
|
|
11
|
+
├── Views (referencias)
|
|
12
|
+
│ └── IDs de vistas marketplace
|
|
13
|
+
└── Migrations
|
|
14
|
+
└── SQL para actualizaciones
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Flujo de desarrollo
|
|
18
|
+
|
|
19
|
+
### 1. Crear package
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
gufi_package_create({
|
|
23
|
+
name: "CRM Basico",
|
|
24
|
+
description: "Gestion de clientes y contactos"
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Agregar modulos
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
gufi_package_add_module({
|
|
32
|
+
package_id: "14",
|
|
33
|
+
company_id: "116",
|
|
34
|
+
module_id: "360"
|
|
35
|
+
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Esto crea un **snapshot** del modulo (copia congelada).
|
|
39
|
+
|
|
40
|
+
### 3. Agregar vistas
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
gufi_package_add_view({
|
|
44
|
+
package_id: "14",
|
|
45
|
+
view_id: "13"
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 4. Publicar
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
gufi_package_publish({ package_id: "14" })
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Versionado
|
|
56
|
+
|
|
57
|
+
### Sincronizar cambios
|
|
58
|
+
|
|
59
|
+
Cuando modificas un modulo fuente, sincroniza el snapshot:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
gufi_package_sync({ package_id: "14" })
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Esto:
|
|
66
|
+
- Actualiza snapshots de modulos
|
|
67
|
+
- Incrementa version (1.0.0 -> 1.0.1)
|
|
68
|
+
|
|
69
|
+
### Verificar cambios pendientes
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
gufi_package_check({ package_id: "14" })
|
|
73
|
+
|
|
74
|
+
Response:
|
|
75
|
+
{
|
|
76
|
+
"has_changes": true,
|
|
77
|
+
"modules_changed": [360],
|
|
78
|
+
"current_version": "1.0.0"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Migraciones
|
|
83
|
+
|
|
84
|
+
Cuando cambias la estructura de un modulo publicado, necesitas migraciones para actualizar instalaciones existentes.
|
|
85
|
+
|
|
86
|
+
### Listar migraciones
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
gufi_package_migrations({ package_id: "14" })
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Crear migracion
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
gufi_package_migration_create({
|
|
96
|
+
package_id: "14",
|
|
97
|
+
description: "Add phone column to clients",
|
|
98
|
+
target_entity: "crm.clientes",
|
|
99
|
+
up_sql: "ALTER TABLE {tableName} ADD COLUMN telefono JSONB",
|
|
100
|
+
down_sql: "ALTER TABLE {tableName} DROP COLUMN telefono",
|
|
101
|
+
is_breaking: false
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Placeholders disponibles:**
|
|
106
|
+
- `{tableName}` - Nombre fisico de la tabla (m360_t4136)
|
|
107
|
+
- `{entityId}` - ID de la entidad
|
|
108
|
+
- `{companyId}` - ID de la company instaladora
|
|
109
|
+
|
|
110
|
+
### Eliminar migracion (solo si no aplicada)
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
gufi_package_migration_delete({
|
|
114
|
+
package_id: "14",
|
|
115
|
+
migration_id: "5"
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Ver entidades para target_entity
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
gufi_package_entities({ package_id: "14" })
|
|
123
|
+
|
|
124
|
+
Response:
|
|
125
|
+
[
|
|
126
|
+
{ "path": "crm.clientes", "name": "Clientes", "entity_id": 4136 },
|
|
127
|
+
{ "path": "crm.contactos", "name": "Contactos", "entity_id": 4137 }
|
|
128
|
+
]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Operaciones con MCP
|
|
132
|
+
|
|
133
|
+
### Listar mis packages
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
gufi_packages()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Ver detalle de package
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
gufi_package({ package_id: "14" })
|
|
143
|
+
|
|
144
|
+
Response:
|
|
145
|
+
{
|
|
146
|
+
"id": 14,
|
|
147
|
+
"name": "CRM Basico",
|
|
148
|
+
"version": "1.0.3",
|
|
149
|
+
"published": true,
|
|
150
|
+
"modules": [...],
|
|
151
|
+
"views": [...],
|
|
152
|
+
"installations_count": 25
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Quitar modulo
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
gufi_package_remove_module({
|
|
160
|
+
package_id: "14",
|
|
161
|
+
module_id: "5" // ID del module DENTRO del package
|
|
162
|
+
})
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Quitar vista
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
gufi_package_remove_view({
|
|
169
|
+
package_id: "14",
|
|
170
|
+
package_view_id: "3" // ID de la relacion package-view
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Despublicar
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
gufi_package_unpublish({ package_id: "14" })
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Eliminar package
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
gufi_package_delete({ package_id: "14" })
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Solo funciona si NO esta publicado.
|
|
187
|
+
|
|
188
|
+
## Instalacion (para compradores)
|
|
189
|
+
|
|
190
|
+
Cuando alguien instala un package:
|
|
191
|
+
|
|
192
|
+
1. Se crea copia de modulos en su company
|
|
193
|
+
2. Se configuran vistas con sus tablas
|
|
194
|
+
3. Se ejecutan migraciones pendientes
|
|
195
|
+
|
|
196
|
+
## Actualizaciones
|
|
197
|
+
|
|
198
|
+
Cuando publicas nueva version:
|
|
199
|
+
|
|
200
|
+
1. Instalaciones existentes ven "actualizacion disponible"
|
|
201
|
+
2. Al actualizar, se ejecutan migraciones en orden
|
|
202
|
+
3. Se actualizan snapshots de modulos
|
|
203
|
+
|
|
204
|
+
## Precios y monetizacion
|
|
205
|
+
|
|
206
|
+
El Marketplace soporta:
|
|
207
|
+
- **Gratis** - Cualquiera puede instalar
|
|
208
|
+
- **Pago unico** - Se cobra una vez
|
|
209
|
+
- **Suscripcion** - Cobro mensual/anual
|
|
210
|
+
|
|
211
|
+
Configuracion via UI de Developer Center (no via MCP).
|
|
212
|
+
|
|
213
|
+
## Buenas practicas
|
|
214
|
+
|
|
215
|
+
### 1. Versionado semantico
|
|
216
|
+
|
|
217
|
+
- **MAJOR** (2.0.0): Cambios breaking (eliminaciones, renombres)
|
|
218
|
+
- **MINOR** (1.1.0): Nuevas features compatibles
|
|
219
|
+
- **PATCH** (1.0.1): Fixes y mejoras menores
|
|
220
|
+
|
|
221
|
+
### 2. Migraciones seguras
|
|
222
|
+
|
|
223
|
+
```sql
|
|
224
|
+
-- CORRECTO: Add column (safe)
|
|
225
|
+
ALTER TABLE {tableName} ADD COLUMN IF NOT EXISTS nuevo_campo TEXT;
|
|
226
|
+
|
|
227
|
+
-- CUIDADO: Drop column (perdida de datos)
|
|
228
|
+
ALTER TABLE {tableName} DROP COLUMN IF EXISTS campo_viejo;
|
|
229
|
+
|
|
230
|
+
-- INCORRECTO: Rename (no soportado bien)
|
|
231
|
+
ALTER TABLE {tableName} RENAME COLUMN viejo TO nuevo;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 3. Test antes de publicar
|
|
235
|
+
|
|
236
|
+
1. Instalar en company de prueba
|
|
237
|
+
2. Verificar que todo funciona
|
|
238
|
+
3. Probar migraciones en BD de test
|
|
239
|
+
|
|
240
|
+
### 4. Documentacion
|
|
241
|
+
|
|
242
|
+
Incluir en descripcion del package:
|
|
243
|
+
- Que hace
|
|
244
|
+
- Como configurar
|
|
245
|
+
- Requisitos previos
|
|
246
|
+
- Changelog de versiones
|