paperclip-plugin-autopilot-ops 0.1.38 → 0.1.40
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 +9 -1
- package/dist/ui/index.js +9 -1
- package/dist/worker.js +36 -9
- 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.40";
|
|
4
4
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
5
5
|
var PAGE_ROUTE = "autopilot";
|
|
6
6
|
var TOOL_NAMES = {
|
|
@@ -402,6 +402,14 @@ var manifest = {
|
|
|
402
402
|
capability: "api.routes.register",
|
|
403
403
|
companyResolution: { from: "query", key: "companyId" }
|
|
404
404
|
},
|
|
405
|
+
{
|
|
406
|
+
routeKey: "retirar-tablero",
|
|
407
|
+
method: "POST",
|
|
408
|
+
path: "/tableros/:clave/retirar",
|
|
409
|
+
auth: "board",
|
|
410
|
+
capability: "api.routes.register",
|
|
411
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
412
|
+
},
|
|
405
413
|
{
|
|
406
414
|
routeKey: "reglas",
|
|
407
415
|
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.40";
|
|
12
12
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
13
13
|
var PAGE_ROUTE = "autopilot";
|
|
14
14
|
var TOOL_NAMES = {
|
|
@@ -410,6 +410,14 @@ var manifest = {
|
|
|
410
410
|
capability: "api.routes.register",
|
|
411
411
|
companyResolution: { from: "query", key: "companyId" }
|
|
412
412
|
},
|
|
413
|
+
{
|
|
414
|
+
routeKey: "retirar-tablero",
|
|
415
|
+
method: "POST",
|
|
416
|
+
path: "/tableros/:clave/retirar",
|
|
417
|
+
auth: "board",
|
|
418
|
+
capability: "api.routes.register",
|
|
419
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
420
|
+
},
|
|
413
421
|
{
|
|
414
422
|
routeKey: "reglas",
|
|
415
423
|
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.40";
|
|
39936
39936
|
var DB_NAMESPACE_SLUG = "autopilot_ops";
|
|
39937
39937
|
var PAGE_ROUTE = "autopilot";
|
|
39938
39938
|
var TOOL_NAMES = {
|
|
@@ -40334,6 +40334,14 @@ var manifest = {
|
|
|
40334
40334
|
capability: "api.routes.register",
|
|
40335
40335
|
companyResolution: { from: "query", key: "companyId" }
|
|
40336
40336
|
},
|
|
40337
|
+
{
|
|
40338
|
+
routeKey: "retirar-tablero",
|
|
40339
|
+
method: "POST",
|
|
40340
|
+
path: "/tableros/:clave/retirar",
|
|
40341
|
+
auth: "board",
|
|
40342
|
+
capability: "api.routes.register",
|
|
40343
|
+
companyResolution: { from: "query", key: "companyId" }
|
|
40344
|
+
},
|
|
40337
40345
|
{
|
|
40338
40346
|
routeKey: "reglas",
|
|
40339
40347
|
method: "GET",
|
|
@@ -41202,7 +41210,7 @@ function textoIndices(detalle, desde, hasta) {
|
|
|
41202
41210
|
}
|
|
41203
41211
|
var NOTA_POR_DEFECTO = {
|
|
41204
41212
|
asunto: "Actualizaci\xF3n de aranceles \xB7 {convenio} \xB7 {institucion}",
|
|
41205
|
-
texto: "Estimados de {financiador}:\n\
|
|
41213
|
+
texto: "Estimados de {financiador}:\n\n{fundamento}, proponemos actualizar los aranceles del convenio {convenio} en un {porcentaje}, con vigencia desde el {vigencia}.\n\nAdjuntamos el detalle de las {practicas} pr\xE1cticas con sus valores actuales y los propuestos.\n\nQuedamos a la espera de su conformidad.\n\nSaludos cordiales,\n{firma}\n{institucion}"
|
|
41206
41214
|
};
|
|
41207
41215
|
function armarNota(plantilla, d) {
|
|
41208
41216
|
const p = plantilla && typeof plantilla === "object" ? plantilla : {};
|
|
@@ -41213,6 +41221,8 @@ function armarNota(plantilla, d) {
|
|
|
41213
41221
|
convenio: d.convenio,
|
|
41214
41222
|
porcentaje: `${d.porcentaje.toLocaleString("es-AR", { maximumFractionDigits: 2 })} %`,
|
|
41215
41223
|
indices: d.indices,
|
|
41224
|
+
// «De acuerdo con la variación de …» si se propone lo que da la fórmula; si no, el índice queda como referencia.
|
|
41225
|
+
fundamento: d.calculado == null || Math.abs(d.calculado - d.porcentaje) < 5e-3 ? `De acuerdo con la variaci\xF3n de ${d.indices}` : `Teniendo en cuenta la variaci\xF3n de ${d.indices}, que da un ${d.calculado.toLocaleString("es-AR", { maximumFractionDigits: 2 })} %`,
|
|
41216
41226
|
vigencia: dia5 ? `${dia5}/${m}/${a}` : d.vigencia,
|
|
41217
41227
|
firma: d.firma,
|
|
41218
41228
|
practicas: String(d.practicas)
|
|
@@ -45482,6 +45492,7 @@ async function transicionar(ctx, input2) {
|
|
|
45482
45492
|
financiador: str2(caso.datos.financiador) ?? "",
|
|
45483
45493
|
convenio: str2(caso.datos.convenio) ?? "",
|
|
45484
45494
|
porcentaje: porcentajeNota,
|
|
45495
|
+
calculado: typeof caso.datos.porcentaje_calculado === "number" ? caso.datos.porcentaje_calculado : null,
|
|
45485
45496
|
indices: textoIndices(caso.datos.detalle ?? { fijo: porcentajeNota }, str2(caso.datos.ultimo_ajuste), str2(caso.datos.periodo_hasta)),
|
|
45486
45497
|
vigencia: str2(caso.datos.vigencia_desde) ?? "",
|
|
45487
45498
|
firma: str2(op.firma) ?? "",
|
|
@@ -47046,13 +47057,14 @@ function mapTablero(r) {
|
|
|
47046
47057
|
publicadoPorId: r.publicado_por_id ?? null,
|
|
47047
47058
|
versiones: Number(r.versiones ?? 1),
|
|
47048
47059
|
createdAt: iso4(r.created_at),
|
|
47049
|
-
updatedAt: iso4(r.updated_at)
|
|
47060
|
+
updatedAt: iso4(r.updated_at),
|
|
47061
|
+
retirado: r.retirado_at ? { en: iso4(r.retirado_at), por: r.retirado_por ?? null, motivo: r.retirado_motivo ?? null } : null
|
|
47050
47062
|
};
|
|
47051
47063
|
}
|
|
47052
|
-
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";
|
|
47064
|
+
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";
|
|
47053
47065
|
var CLAVE_RE2 = /^[a-z0-9][a-z0-9-]{1,60}$/;
|
|
47054
47066
|
async function listarTableros(ctx, companyId) {
|
|
47055
|
-
const rows = await ctx.db.query(`SELECT ${COLS2} FROM ${t5(ctx, "tablero")} WHERE company_id = $1 ORDER BY updated_at DESC`, [companyId]);
|
|
47067
|
+
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]);
|
|
47056
47068
|
return rows.map(mapTablero);
|
|
47057
47069
|
}
|
|
47058
47070
|
async function leerTablero(ctx, companyId, clave) {
|
|
@@ -47071,13 +47083,13 @@ async function publicarTablero(ctx, input2) {
|
|
|
47071
47083
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
47072
47084
|
if (previo) {
|
|
47073
47085
|
await ctx.db.execute(
|
|
47074
|
-
`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`,
|
|
47086
|
+
`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`,
|
|
47075
47087
|
[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]
|
|
47076
47088
|
);
|
|
47077
47089
|
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 } });
|
|
47078
47090
|
return {
|
|
47079
47091
|
creado: false,
|
|
47080
|
-
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 }
|
|
47092
|
+
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 }
|
|
47081
47093
|
};
|
|
47082
47094
|
}
|
|
47083
47095
|
const id3 = randomUUID5();
|
|
@@ -47088,9 +47100,20 @@ async function publicarTablero(ctx, input2) {
|
|
|
47088
47100
|
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 } });
|
|
47089
47101
|
return {
|
|
47090
47102
|
creado: true,
|
|
47091
|
-
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 }
|
|
47103
|
+
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 }
|
|
47092
47104
|
};
|
|
47093
47105
|
}
|
|
47106
|
+
async function retirarTablero(ctx, input2) {
|
|
47107
|
+
if (input2.actor.tipo !== "humano") throw new OpsError("actor_no_permitido", "un tablero lo da de baja una persona de la instituci\xF3n");
|
|
47108
|
+
const clave = typeof input2.clave === "string" ? input2.clave.trim().toLowerCase() : "";
|
|
47109
|
+
const previo = CLAVE_RE2.test(clave) ? await leerTablero(ctx, input2.companyId, clave) : null;
|
|
47110
|
+
if (!previo) throw new OpsError("tablero_inexistente", "no hay un tablero con esa clave");
|
|
47111
|
+
if (previo.retirado) return previo;
|
|
47112
|
+
const motivo = typeof input2.motivo === "string" && input2.motivo.trim() ? input2.motivo.trim().slice(0, 300) : null;
|
|
47113
|
+
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]);
|
|
47114
|
+
await ctx.activity.log({ companyId: input2.companyId, message: `Autopilot Care: tablero \xAB${previo.titulo}\xBB retirado (${clave})`, metadata: { clave, por: input2.actor.id, motivo } });
|
|
47115
|
+
return { ...previo, retirado: { en: (/* @__PURE__ */ new Date()).toISOString(), por: input2.actor.id, motivo } };
|
|
47116
|
+
}
|
|
47094
47117
|
|
|
47095
47118
|
// src/worker.ts
|
|
47096
47119
|
function str3(v) {
|
|
@@ -47423,7 +47446,11 @@ async function manejarApi(ctx, input2) {
|
|
|
47423
47446
|
return respuesta(200, { tableros: await listarTableros(ctx, companyId) });
|
|
47424
47447
|
case "tablero-publicado": {
|
|
47425
47448
|
const tb = await leerTablero(ctx, companyId, (input2.params.clave ?? "").toLowerCase());
|
|
47426
|
-
return tb ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
|
|
47449
|
+
return tb && !tb.retirado ? respuesta(200, tb) : respuesta(404, { error: "tablero_inexistente" });
|
|
47450
|
+
}
|
|
47451
|
+
case "retirar-tablero": {
|
|
47452
|
+
if (actor.tipo !== "humano") return respuesta(403, { error: "actor_no_permitido", motivo: "un tablero lo da de baja una persona de la instituci\xF3n" });
|
|
47453
|
+
return respuesta(200, { tablero: await retirarTablero(ctx, { companyId, clave: input2.params.clave ?? "", motivo: str3(body.motivo), actor: { tipo: "humano", id: decididoPor ?? actor.id } }) });
|
|
47427
47454
|
}
|
|
47428
47455
|
case "reglas":
|
|
47429
47456
|
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.40",
|
|
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": [
|