paperclip-plugin-autopilot-ops 0.1.39 → 0.1.41
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/manifest.js +25 -1
- package/dist/ui/index.js +25 -1
- package/dist/worker.js +71 -10
- package/migrations/009_tablero_retirado.sql +5 -0
- package/package.json +1 -1
package/dist/manifest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/manifest.ts
|
|
2
2
|
var PLUGIN_ID = "alephoo.autopilot-ops";
|
|
3
|
-
var PLUGIN_VERSION = "0.1.
|
|
3
|
+
var PLUGIN_VERSION = "0.1.41";
|
|
4
4
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
5
5
|
var PAGE_ROUTE = "autopilot";
|
|
6
6
|
var TOOL_NAMES = {
|
|
@@ -402,6 +402,30 @@ var manifest = {
|
|
|
402
402
|
capability: "api.routes.register",
|
|
403
403
|
companyResolution: { from: "query", key: "companyId" }
|
|
404
404
|
},
|
|
405
|
+
{
|
|
406
|
+
routeKey: "tableros-retirados",
|
|
407
|
+
method: "GET",
|
|
408
|
+
path: "/tableros-retirados",
|
|
409
|
+
auth: "board",
|
|
410
|
+
capability: "api.routes.register",
|
|
411
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
routeKey: "restaurar-tablero",
|
|
415
|
+
method: "POST",
|
|
416
|
+
path: "/tableros/:clave/restaurar",
|
|
417
|
+
auth: "board",
|
|
418
|
+
capability: "api.routes.register",
|
|
419
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
routeKey: "retirar-tablero",
|
|
423
|
+
method: "POST",
|
|
424
|
+
path: "/tableros/:clave/retirar",
|
|
425
|
+
auth: "board",
|
|
426
|
+
capability: "api.routes.register",
|
|
427
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
428
|
+
},
|
|
405
429
|
{
|
|
406
430
|
routeKey: "reglas",
|
|
407
431
|
method: "GET",
|
package/dist/ui/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// src/manifest.ts
|
|
10
10
|
var PLUGIN_ID = "alephoo.autopilot-ops";
|
|
11
|
-
var PLUGIN_VERSION = "0.1.
|
|
11
|
+
var PLUGIN_VERSION = "0.1.41";
|
|
12
12
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
13
13
|
var PAGE_ROUTE = "autopilot";
|
|
14
14
|
var TOOL_NAMES = {
|
|
@@ -410,6 +410,30 @@ var manifest = {
|
|
|
410
410
|
capability: "api.routes.register",
|
|
411
411
|
companyResolution: { from: "query", key: "companyId" }
|
|
412
412
|
},
|
|
413
|
+
{
|
|
414
|
+
routeKey: "tableros-retirados",
|
|
415
|
+
method: "GET",
|
|
416
|
+
path: "/tableros-retirados",
|
|
417
|
+
auth: "board",
|
|
418
|
+
capability: "api.routes.register",
|
|
419
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
routeKey: "restaurar-tablero",
|
|
423
|
+
method: "POST",
|
|
424
|
+
path: "/tableros/:clave/restaurar",
|
|
425
|
+
auth: "board",
|
|
426
|
+
capability: "api.routes.register",
|
|
427
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
routeKey: "retirar-tablero",
|
|
431
|
+
method: "POST",
|
|
432
|
+
path: "/tableros/:clave/retirar",
|
|
433
|
+
auth: "board",
|
|
434
|
+
capability: "api.routes.register",
|
|
435
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
436
|
+
},
|
|
413
437
|
{
|
|
414
438
|
routeKey: "reglas",
|
|
415
439
|
method: "GET",
|
package/dist/worker.js
CHANGED
|
@@ -39932,7 +39932,7 @@ function startWorkerRpcHost(options) {
|
|
|
39932
39932
|
|
|
39933
39933
|
// src/manifest.ts
|
|
39934
39934
|
var PLUGIN_ID = "alephoo.autopilot-ops";
|
|
39935
|
-
var PLUGIN_VERSION = "0.1.
|
|
39935
|
+
var PLUGIN_VERSION = "0.1.41";
|
|
39936
39936
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
39937
39937
|
var PAGE_ROUTE = "autopilot";
|
|
39938
39938
|
var TOOL_NAMES = {
|
|
@@ -40334,6 +40334,30 @@ var manifest = {
|
|
|
40334
40334
|
capability: "api.routes.register",
|
|
40335
40335
|
companyResolution: { from: "query", key: "companyId" }
|
|
40336
40336
|
},
|
|
40337
|
+
{
|
|
40338
|
+
routeKey: "tableros-retirados",
|
|
40339
|
+
method: "GET",
|
|
40340
|
+
path: "/tableros-retirados",
|
|
40341
|
+
auth: "board",
|
|
40342
|
+
capability: "api.routes.register",
|
|
40343
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40344
|
+
},
|
|
40345
|
+
{
|
|
40346
|
+
routeKey: "restaurar-tablero",
|
|
40347
|
+
method: "POST",
|
|
40348
|
+
path: "/tableros/:clave/restaurar",
|
|
40349
|
+
auth: "board",
|
|
40350
|
+
capability: "api.routes.register",
|
|
40351
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40352
|
+
},
|
|
40353
|
+
{
|
|
40354
|
+
routeKey: "retirar-tablero",
|
|
40355
|
+
method: "POST",
|
|
40356
|
+
path: "/tableros/:clave/retirar",
|
|
40357
|
+
auth: "board",
|
|
40358
|
+
capability: "api.routes.register",
|
|
40359
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40360
|
+
},
|
|
40337
40361
|
{
|
|
40338
40362
|
routeKey: "reglas",
|
|
40339
40363
|
method: "GET",
|
|
@@ -46947,6 +46971,7 @@ function controlarTabla(ref, columnas, filas, problemas) {
|
|
|
46947
46971
|
}
|
|
46948
46972
|
}
|
|
46949
46973
|
}
|
|
46974
|
+
var MAX_BARRAS = 12;
|
|
46950
46975
|
function validarWidgets(entrada) {
|
|
46951
46976
|
const problemas = [];
|
|
46952
46977
|
const lista3 = Array.isArray(entrada) ? entrada : [];
|
|
@@ -46977,9 +47002,9 @@ function validarWidgets(entrada) {
|
|
|
46977
47002
|
case "barras": {
|
|
46978
47003
|
const titulo = texto9(o.titulo, 120, `${ref}.titulo`, problemas, true) ?? "";
|
|
46979
47004
|
const series = arr(o.series);
|
|
46980
|
-
if (series.length === 0 || series.length >
|
|
47005
|
+
if (series.length === 0 || series.length > MAX_BARRAS) problemas.push(`${ref}.series debe tener entre 1 y ${MAX_BARRAS} barras: mostr\xE1 las principales y sum\xE1 el resto en una barra \xABOtros\xBB (el detalle completo puede ir en una tabla)`);
|
|
46981
47006
|
const unidad = texto9(o.unidad, 16, `${ref}.unidad`, problemas);
|
|
46982
|
-
const barras = series.slice(0,
|
|
47007
|
+
const barras = series.slice(0, MAX_BARRAS).map((s, j) => {
|
|
46983
47008
|
const so = s && typeof s === "object" ? s : {};
|
|
46984
47009
|
return { etiqueta: texto9(so.etiqueta, 60, `${ref}.series[${j}].etiqueta`, problemas, true) ?? "", valor: numero2(so.valor, `${ref}.series[${j}].valor`, problemas) };
|
|
46985
47010
|
});
|
|
@@ -47049,13 +47074,14 @@ function mapTablero(r) {
|
|
|
47049
47074
|
publicadoPorId: r.publicado_por_id ?? null,
|
|
47050
47075
|
versiones: Number(r.versiones ?? 1),
|
|
47051
47076
|
createdAt: iso4(r.created_at),
|
|
47052
|
-
updatedAt: iso4(r.updated_at)
|
|
47077
|
+
updatedAt: iso4(r.updated_at),
|
|
47078
|
+
retirado: r.retirado_at ? { en: iso4(r.retirado_at), por: r.retirado_por ?? null, motivo: r.retirado_motivo ?? null } : null
|
|
47053
47079
|
};
|
|
47054
47080
|
}
|
|
47055
|
-
var COLS2 = "id, company_id, clave, titulo, descripcion, pedido, periodo, fuentes, widgets, agente_id, issue_id, publicado_por_tipo, publicado_por_id, versiones, created_at, updated_at";
|
|
47081
|
+
var COLS2 = "id, company_id, clave, titulo, descripcion, pedido, periodo, fuentes, widgets, agente_id, issue_id, publicado_por_tipo, publicado_por_id, versiones, created_at, updated_at, retirado_at, retirado_por, retirado_motivo";
|
|
47056
47082
|
var CLAVE_RE2 = /^[a-z0-9][a-z0-9-]{1,60}$/;
|
|
47057
47083
|
async function listarTableros(ctx, companyId) {
|
|
47058
|
-
const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 ORDER BY updated_at DESC`, [companyId]);
|
|
47084
|
+
const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 AND retirado_at IS NULL ORDER BY updated_at DESC`, [companyId]);
|
|
47059
47085
|
return rows.map(mapTablero);
|
|
47060
47086
|
}
|
|
47061
47087
|
async function leerTablero(ctx, companyId, clave) {
|
|
@@ -47074,13 +47100,13 @@ async function publicarTablero(ctx, input2) {
|
|
|
47074
47100
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
47075
47101
|
if (previo) {
|
|
47076
47102
|
await ctx.db.execute(
|
|
47077
|
-
`UPDATE ${t5(ctx, "tablero")} SET titulo = $3, descripcion = $4, pedido = COALESCE($5, pedido), periodo = $6, fuentes = $7::jsonb, widgets = $8::jsonb, agente_id = COALESCE($9, agente_id), issue_id = COALESCE($10, issue_id), publicado_por_tipo = $11, publicado_por_id = $12, versiones = versiones + 1, updated_at = now() WHERE company_id = $1 AND clave = $2`,
|
|
47103
|
+
`UPDATE ${t5(ctx, "tablero")} SET titulo = $3, descripcion = $4, pedido = COALESCE($5, pedido), periodo = $6, fuentes = $7::jsonb, widgets = $8::jsonb, agente_id = COALESCE($9, agente_id), issue_id = COALESCE($10, issue_id), publicado_por_tipo = $11, publicado_por_id = $12, versiones = versiones + 1, updated_at = now(), retirado_at = NULL, retirado_por = NULL, retirado_motivo = NULL WHERE company_id = $1 AND clave = $2`,
|
|
47078
47104
|
[input2.companyId, clave, titulo, limpio(input2.descripcion, 600), limpio(input2.pedido, 1e3), limpio(input2.periodo, 80), JSON.stringify(fuentes), JSON.stringify(widgets), input2.agenteId ?? null, input2.issueId ?? null, input2.actor.tipo, input2.actor.id]
|
|
47079
47105
|
);
|
|
47080
47106
|
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${titulo}\xBB actualizado (${clave}, versi\xF3n ${previo.versiones + 1})`, metadata: { clave, widgets: widgets.length, agentId: input2.agenteId ?? null, issueId: input2.issueId ?? null } });
|
|
47081
47107
|
return {
|
|
47082
47108
|
creado: false,
|
|
47083
|
-
tablero: { ...previo, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3) ?? previo.pedido, periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? previo.agenteId, issueId: input2.issueId ?? previo.issueId, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: previo.versiones + 1, updatedAt: now }
|
|
47109
|
+
tablero: { ...previo, retirado: null, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3) ?? previo.pedido, periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? previo.agenteId, issueId: input2.issueId ?? previo.issueId, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: previo.versiones + 1, updatedAt: now }
|
|
47084
47110
|
};
|
|
47085
47111
|
}
|
|
47086
47112
|
const id3 = randomUUID5();
|
|
@@ -47091,9 +47117,34 @@ async function publicarTablero(ctx, input2) {
|
|
|
47091
47117
|
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${titulo}\xBB publicado (${clave})`, metadata: { clave, widgets: widgets.length, agentId: input2.agenteId ?? null, issueId: input2.issueId ?? null } });
|
|
47092
47118
|
return {
|
|
47093
47119
|
creado: true,
|
|
47094
|
-
tablero: { id: id3, companyId: input2.companyId, clave, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3), periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? null, issueId: input2.issueId ?? null, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: 1, createdAt: now, updatedAt: now }
|
|
47120
|
+
tablero: { id: id3, companyId: input2.companyId, clave, titulo, descripcion: limpio(input2.descripcion, 600), pedido: limpio(input2.pedido, 1e3), periodo: limpio(input2.periodo, 80), fuentes, widgets, agenteId: input2.agenteId ?? null, issueId: input2.issueId ?? null, publicadoPorTipo: input2.actor.tipo, publicadoPorId: input2.actor.id, versiones: 1, createdAt: now, updatedAt: now, retirado: null }
|
|
47095
47121
|
};
|
|
47096
47122
|
}
|
|
47123
|
+
async function listarTablerosRetirados(ctx, companyId) {
|
|
47124
|
+
const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 AND retirado_at IS NOT NULL ORDER BY retirado_at DESC`, [companyId]);
|
|
47125
|
+
return rows.map(mapTablero);
|
|
47126
|
+
}
|
|
47127
|
+
async function restaurarTablero(ctx, input2) {
|
|
47128
|
+
if (input2.actor.tipo !== "humano") throw new OpsError("actor_no_permitido", "un tablero retirado lo vuelve a mostrar una persona de la instituci\xF3n");
|
|
47129
|
+
const clave = typeof input2.clave === "string" ? input2.clave.trim().toLowerCase() : "";
|
|
47130
|
+
const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
|
|
47131
|
+
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
|
|
47132
|
+
if (!previo.retirado) return previo;
|
|
47133
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = NULL, retirado_por = NULL, retirado_motivo = NULL WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave]);
|
|
47134
|
+
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB vuelve a mostrarse (${clave})`, metadata: { clave, por: input2.actor.id } });
|
|
47135
|
+
return { ...previo, retirado: null };
|
|
47136
|
+
}
|
|
47137
|
+
async function retirarTablero(ctx, input2) {
|
|
47138
|
+
if (input2.actor.tipo !== "humano") throw new OpsError("actor_no_permitido", "un tablero lo da de baja una persona de la instituci\xF3n");
|
|
47139
|
+
const clave = typeof input2.clave === "string" ? input2.clave.trim().toLowerCase() : "";
|
|
47140
|
+
const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
|
|
47141
|
+
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
|
|
47142
|
+
if (previo.retirado) return previo;
|
|
47143
|
+
const motivo = typeof input2.motivo === "string" && input2.motivo.trim() ? input2.motivo.trim().slice(0, 300) : null;
|
|
47144
|
+
await ctx.db.execute(`UPDATE ${t5(ctx, "tablero")} SET retirado_at = now(), retirado_por = $3, retirado_motivo = $4 WHERE company_id = $1 AND clave = $2`, [input2.companyId, clave, input2.actor.id, motivo]);
|
|
47145
|
+
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB retirado (${clave})`, metadata: { clave, por: input2.actor.id, motivo } });
|
|
47146
|
+
return { ...previo, retirado: { en: (/* @__PURE__ */ new Date()).toISOString(), por: input2.actor.id, motivo } };
|
|
47147
|
+
}
|
|
47097
47148
|
|
|
47098
47149
|
// src/worker.ts
|
|
47099
47150
|
function str3(v) {
|
|
@@ -47426,7 +47477,17 @@ async function manejarApi(ctx, input2) {
|
|
|
47426
47477
|
return respuesta(200, { tableros: await listarTableros(ctx, companyId) });
|
|
47427
47478
|
case "tablero-publicado": {
|
|
47428
47479
|
const tb = await leerTablero(ctx, companyId, (input2.params.clave ?? "").toLowerCase());
|
|
47429
|
-
return tb ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
|
|
47480
|
+
return tb && !tb.retirado ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
|
|
47481
|
+
}
|
|
47482
|
+
case "tableros-retirados":
|
|
47483
|
+
return respuesta(200, { tableros: await listarTablerosRetirados(ctx, companyId) });
|
|
47484
|
+
case "restaurar-tablero": {
|
|
47485
|
+
if (actor.tipo !== "humano") return respuesta(403, { error: "actor_no_permitido", motivo: "un tablero retirado lo vuelve a mostrar una persona de la instituci\xF3n" });
|
|
47486
|
+
return respuesta(200, { tablero: await restaurarTablero(ctx, { companyId, clave: input2.params.clave ?? "", actor: { tipo: "humano", id: decididoPor ?? actor.id } }) });
|
|
47487
|
+
}
|
|
47488
|
+
case "retirar-tablero": {
|
|
47489
|
+
if (actor.tipo !== "humano") return respuesta(403, { error: "actor_no_permitido", motivo: "un tablero lo da de baja una persona de la instituci\xF3n" });
|
|
47490
|
+
return respuesta(200, { tablero: await retirarTablero(ctx, { companyId, clave: input2.params.clave ?? "", motivo: str3(body.motivo), actor: { tipo: "humano", id: decididoPor ?? actor.id } }) });
|
|
47430
47491
|
}
|
|
47431
47492
|
case "reglas":
|
|
47432
47493
|
return respuesta(200, { reglas: await listarReglas(ctx, companyId, { workflow: qs("workflow") ?? "demanda_pendiente", estado: qs("estado") }) });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- Un tablero que la dirección da de baja deja de mostrarse, pero no se borra: queda quién lo retiró, cuándo y por qué.
|
|
2
|
+
-- Si el agente vuelve a publicar la misma clave (otro pedido), vuelve a estar a la vista.
|
|
3
|
+
ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_at timestamptz;
|
|
4
|
+
ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_por text;
|
|
5
|
+
ALTER TABLE plugin_autopilot_ops_1a68482ede.tablero ADD COLUMN retirado_motivo text;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperclip-plugin-autopilot-ops",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Autopilot Care · operación autónoma gobernada para instituciones de salud: workflows determinísticos, validaciones, registro de negocio, políticas (observa/propone/ejecuta/corte) y tablero del director, como plugin de Paperclip.",
|
|
6
6
|
"files": [
|