ponch-mcp-server 1.0.79 → 1.0.80

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/index.js CHANGED
@@ -10204,7 +10204,7 @@ function calcularProximaEjecucion(rutina, tenantTimezone, desdeISO) {
10204
10204
  }
10205
10205
  switch (frecuencia) {
10206
10206
  case "diaria":
10207
- return candidate.toISO();
10207
+ return candidate.toISO({ includeOffset: true });
10208
10208
  case "semanal": {
10209
10209
  if (config.diaSemana === null) {
10210
10210
  throw new Error("Frecuencia semanal requires config.diaSemana (0-6)");
@@ -10213,7 +10213,7 @@ function calcularProximaEjecucion(rutina, tenantTimezone, desdeISO) {
10213
10213
  while (candidate.weekday !== targetWeekday) {
10214
10214
  candidate = candidate.plus({ days: 1 });
10215
10215
  }
10216
- return candidate.toISO();
10216
+ return candidate.toISO({ includeOffset: true });
10217
10217
  }
10218
10218
  case "quincenal": {
10219
10219
  if (config.diaSemana === null) {
@@ -10225,13 +10225,13 @@ function calcularProximaEjecucion(rutina, tenantTimezone, desdeISO) {
10225
10225
  while (next.weekday !== targetWeekday) {
10226
10226
  next = next.plus({ days: 1 });
10227
10227
  }
10228
- return next.toISO();
10228
+ return next.toISO({ includeOffset: true });
10229
10229
  }
10230
10230
  while (candidate.weekday !== targetWeekday) {
10231
10231
  candidate = candidate.plus({ days: 1 });
10232
10232
  }
10233
10233
  candidate = candidate.plus({ days: 7 });
10234
- return candidate.toISO();
10234
+ return candidate.toISO({ includeOffset: true });
10235
10235
  }
10236
10236
  case "mensual": {
10237
10237
  if (config.diaMes === null) {
@@ -10242,7 +10242,7 @@ function calcularProximaEjecucion(rutina, tenantTimezone, desdeISO) {
10242
10242
  target = target.plus({ months: 1 });
10243
10243
  target = target.set({ day: Math.min(config.diaMes, target.daysInMonth) });
10244
10244
  }
10245
- return target.toISO();
10245
+ return target.toISO({ includeOffset: true });
10246
10246
  }
10247
10247
  case "trimestral": {
10248
10248
  if (config.diaMes === null) {
@@ -10253,7 +10253,7 @@ function calcularProximaEjecucion(rutina, tenantTimezone, desdeISO) {
10253
10253
  target = target.plus({ months: 3 });
10254
10254
  target = target.set({ day: Math.min(config.diaMes, target.daysInMonth) });
10255
10255
  }
10256
- return target.toISO();
10256
+ return target.toISO({ includeOffset: true });
10257
10257
  }
10258
10258
  }
10259
10259
  }
@@ -10649,7 +10649,9 @@ async function getUserContext({
10649
10649
  throw new Error(`userContext: usuario ${uid} no encontrado.`);
10650
10650
  }
10651
10651
  const tenantsMap = userDoc.tenants;
10652
- const rol = tenantsMap?.[tenantId]?.rol ?? null;
10652
+ const saasLevelRol = userDoc.rol;
10653
+ const tenantRol = tenantsMap?.[tenantId]?.rol;
10654
+ const rol = saasLevelRol && SUPER_ADMIN_ROLES.includes(saasLevelRol) ? saasLevelRol : tenantRol ?? null;
10653
10655
  let rolNombre;
10654
10656
  if (rol === null) {
10655
10657
  rolNombre = null;
@@ -16164,7 +16166,12 @@ function registerMarketingTools(server, session) {
16164
16166
  mensaje: out.mensaje
16165
16167
  };
16166
16168
  } else {
16167
- payload = { ok: false, state: result.state, mensaje: result.text };
16169
+ payload = {
16170
+ ok: false,
16171
+ state: result.state,
16172
+ mensaje: result.text,
16173
+ ...result.validationErrors && result.validationErrors.length > 0 ? { validationErrors: result.validationErrors } : {}
16174
+ };
16168
16175
  }
16169
16176
  return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
16170
16177
  }
@@ -16310,7 +16317,12 @@ function registerMarketingTools(server, session) {
16310
16317
  } else if (result.state === "success") {
16311
16318
  returnPayload = result.structuredOutput;
16312
16319
  } else {
16313
- returnPayload = { ok: false, state: result.state, mensaje: result.text };
16320
+ returnPayload = {
16321
+ ok: false,
16322
+ state: result.state,
16323
+ mensaje: result.text,
16324
+ ...result.validationErrors && result.validationErrors.length > 0 ? { validationErrors: result.validationErrors } : {}
16325
+ };
16314
16326
  }
16315
16327
  return { content: [{ type: "text", text: JSON.stringify(returnPayload, null, 2) }] };
16316
16328
  }
@@ -16757,7 +16769,8 @@ function renderResult(result) {
16757
16769
  state: result.state,
16758
16770
  text: result.text,
16759
16771
  structuredOutput: result.structuredOutput,
16760
- ...result.disabledReason ? { disabledReason: result.disabledReason } : {}
16772
+ ...result.disabledReason ? { disabledReason: result.disabledReason } : {},
16773
+ ...result.validationErrors && result.validationErrors.length > 0 ? { validationErrors: result.validationErrors } : {}
16761
16774
  };
16762
16775
  return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
16763
16776
  }
@@ -16839,17 +16852,24 @@ function registerMartinTools(server, session) {
16839
16852
  const dst = uidDestinatario ?? ctx.user.uid;
16840
16853
  const result = await dispatchWithContract({
16841
16854
  contract: programarRutinaContract,
16842
- helper: async (parsed) => createRutina({
16843
- db: parsed.db,
16844
- tenantId: parsed.tenantId,
16845
- uidCreador: parsed.uid,
16846
- uidDestinatario: parsed.uidDestinatario,
16847
- tipo: parsed.tipo,
16848
- frecuencia: parsed.frecuencia,
16849
- config: parsed.config,
16850
- accion: parsed.accion,
16851
- origen: parsed.origen
16852
- }),
16855
+ helper: async (parsed) => {
16856
+ const out = await createRutina({
16857
+ db: parsed.db,
16858
+ tenantId: parsed.tenantId,
16859
+ uidCreador: parsed.uid,
16860
+ uidDestinatario: parsed.uidDestinatario,
16861
+ tipo: parsed.tipo,
16862
+ frecuencia: parsed.frecuencia,
16863
+ config: parsed.config,
16864
+ accion: parsed.accion,
16865
+ origen: parsed.origen
16866
+ });
16867
+ console.error(
16868
+ "[programar_rutina] createRutina output:",
16869
+ JSON.stringify(out)
16870
+ );
16871
+ return out;
16872
+ },
16853
16873
  callable: callProgramarRutina,
16854
16874
  input: { tenantId: ctx.tenantId, uid: ctx.user.uid, uidDestinatario: dst, tipo, frecuencia, config, accion, origen },
16855
16875
  ctx