@interware/content-generator 0.6.1 → 0.7.0
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/_chunks/App-Cwr5ra5m.js +1380 -0
- package/dist/_chunks/App-h4_txTsI.mjs +1362 -0
- package/dist/_chunks/{ImageStudioTabs-BLAH3KYv.mjs → ImageStudioTabs-B-mOwDfY.mjs} +687 -682
- package/dist/_chunks/{ImageStudioTabs-DtusqpQO.js → ImageStudioTabs-CG4KTn1S.js} +683 -678
- package/dist/_chunks/{Settings-o2GngLaW.mjs → Settings-BT-EqvXs.mjs} +2 -2
- package/dist/_chunks/{Settings-BQXxV3LO.js → Settings-D4NGBTk1.js} +4 -4
- package/dist/_chunks/{StudioApp-BaySMwrk.js → StudioApp-_ViSAwCm.js} +2 -2
- package/dist/_chunks/{StudioApp-C_znlQRo.mjs → StudioApp-xaEy-uIk.mjs} +2 -2
- package/dist/_chunks/{index-BKigRXm3.mjs → index-D67xWUPz.mjs} +3 -28
- package/dist/_chunks/{index-BKhe-Jyx.js → index-NA9OuMGs.js} +3 -28
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/features/articles/ArticlePage.d.ts +5 -0
- package/dist/admin/src/features/articles/ArticlesPage.d.ts +7 -0
- package/dist/admin/src/features/articles/NewArticlePage.d.ts +6 -0
- package/dist/admin/src/features/articles/SharePreview.d.ts +19 -0
- package/dist/admin/src/features/articles/articlesApi.d.ts +94 -0
- package/dist/admin/src/features/articles/model.d.ts +24 -0
- package/dist/admin/src/features/articles/useArticlesApi.d.ts +19 -0
- package/dist/admin/src/features/library/LibraryImagePicker.d.ts +6 -1
- package/dist/admin/src/lib/postText.d.ts +25 -0
- package/dist/server/index.js +514 -320
- package/dist/server/index.mjs +514 -320
- package/dist/server/src/articles/generation.d.ts +135 -0
- package/dist/server/src/articles/schedule.d.ts +12 -0
- package/dist/server/src/articles/sources.d.ts +12 -0
- package/dist/server/src/bootstrap.d.ts +2 -0
- package/dist/server/src/controllers/articles.d.ts +30 -0
- package/dist/server/src/controllers/controller.d.ts +0 -4
- package/dist/server/src/controllers/index.d.ts +92 -4
- package/dist/server/src/index.d.ts +122 -67
- package/dist/server/src/services/articles.d.ts +126 -0
- package/dist/server/src/services/image-studio.d.ts +0 -10
- package/dist/server/src/services/index.d.ts +30 -63
- package/dist/server/src/services/service.d.ts +1 -62
- package/package.json +1 -1
- package/dist/_chunks/App-CJxSC8yt.js +0 -1105
- package/dist/_chunks/App-qbgUXlOZ.mjs +0 -1087
- package/dist/_chunks/getTranslation-B6Bsu-uq.mjs +0 -5
- package/dist/_chunks/getTranslation-BRVMWSf8.js +0 -4
- package/dist/admin/src/components/commons/dialog/index.d.ts +0 -12
- package/dist/admin/src/components/commons/generate-image-dialog/index.d.ts +0 -5
- package/dist/admin/src/components/generate-content/Form.d.ts +0 -15
- package/dist/admin/src/components/home/table.d.ts +0 -13
- package/dist/admin/src/components/index.d.ts +0 -12
- package/dist/admin/src/containers/generate-content/index.d.ts +0 -2
- package/dist/admin/src/containers/home/index.d.ts +0 -2
- package/dist/admin/src/hooks/useDialog.d.ts +0 -11
- package/dist/admin/src/lib/use-cases/articles/index.d.ts +0 -16
- package/dist/admin/src/lib/use-cases/categories/index.d.ts +0 -16
- package/dist/admin/src/lib/use-cases/facebook/index.d.ts +0 -5
- package/dist/admin/src/lib/use-cases/generate-content/index.d.ts +0 -6
- package/dist/admin/src/lib/use-cases/linkedin/index.d.ts +0 -5
- package/dist/admin/src/lib/use-cases/users/index.d.ts +0 -16
- package/dist/admin/src/pages/GenerateContent.d.ts +0 -2
- package/dist/admin/src/pages/HomePage.d.ts +0 -2
- package/dist/admin/src/reducers/dialog/index.d.ts +0 -6
- package/dist/admin/src/types/reducers.d.ts +0 -4
package/dist/server/index.mjs
CHANGED
|
@@ -23,7 +23,20 @@ const ensureFolder = async (strapi, name2) => {
|
|
|
23
23
|
const created = await strapi.plugin("upload").service("folder").create({ name: name2, parent: null });
|
|
24
24
|
return created.id;
|
|
25
25
|
};
|
|
26
|
+
const SCHEDULE_CRON = "content-generator-publicar-programados";
|
|
26
27
|
const bootstrap = async ({ strapi }) => {
|
|
28
|
+
strapi.cron.add({
|
|
29
|
+
[SCHEDULE_CRON]: {
|
|
30
|
+
task: async () => {
|
|
31
|
+
try {
|
|
32
|
+
await strapi.plugin(PLUGIN_ID).service("articles").publishDue();
|
|
33
|
+
} catch (err) {
|
|
34
|
+
strapi.log.error(`[content-generator] publicar programados: ${err.message}`);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
options: { rule: "* * * * *" }
|
|
38
|
+
}
|
|
39
|
+
});
|
|
27
40
|
strapi.admin.services.permission.actionProvider.registerMany([
|
|
28
41
|
{
|
|
29
42
|
section: "plugins",
|
|
@@ -82,26 +95,29 @@ const template = { schema };
|
|
|
82
95
|
const contentTypes = {
|
|
83
96
|
template
|
|
84
97
|
};
|
|
98
|
+
const POST_MAX = 3e3;
|
|
99
|
+
const hashtags = (keywords) => keywords.map((k) => k.trim().replace(/\s+/g, "").replace(/[^\p{L}\p{N}_]/gu, "")).filter(Boolean).map((k) => `#${k}`).join(" ");
|
|
100
|
+
const defaultPostText = ({ titulo, descripcion, keywords }, red) => [red === "facebook" ? titulo : "", descripcion, hashtags(keywords)].filter(Boolean).join("\n\n");
|
|
101
|
+
const checkPostText = (input) => {
|
|
102
|
+
const text2 = typeof input === "string" ? input.trim() : "";
|
|
103
|
+
if (!text2) return { ok: true, text: null };
|
|
104
|
+
if ([...text2].length > POST_MAX) return { ok: false, error: `El texto de la publicación puede tener hasta ${POST_MAX} caracteres.` };
|
|
105
|
+
return { ok: true, text: text2 };
|
|
106
|
+
};
|
|
107
|
+
const validarMensaje = (ctx) => {
|
|
108
|
+
const check = checkPostText(ctx.request.body?.mensaje);
|
|
109
|
+
if ("error" in check) {
|
|
110
|
+
ctx.status = 400;
|
|
111
|
+
ctx.body = { data: null, error: { status: 400, name: "ValidationError", message: check.error } };
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
ctx.request.body = { ...ctx.request.body, mensaje: check.text ?? void 0 };
|
|
115
|
+
if (!check.text) delete ctx.request.body.mensaje;
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
85
118
|
const controller = ({ strapi }) => {
|
|
86
119
|
const pluginService = () => strapi.plugin("strapi-content-generator-gemini").service("service");
|
|
87
120
|
return {
|
|
88
|
-
async getArticles(ctx) {
|
|
89
|
-
const contentType = strapi.contentType("api::articulo.articulo");
|
|
90
|
-
await strapi.contentAPI.validate.query(ctx.query, contentType, {
|
|
91
|
-
auth: ctx.state.auth
|
|
92
|
-
});
|
|
93
|
-
const sanitizedQueryParams = await strapi.contentAPI.sanitize.query(
|
|
94
|
-
ctx.query,
|
|
95
|
-
contentType,
|
|
96
|
-
{
|
|
97
|
-
auth: ctx.state.auth
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
const documents = await pluginService().getArticulos(sanitizedQueryParams);
|
|
101
|
-
return await strapi.contentAPI.sanitize.output(documents, contentType, {
|
|
102
|
-
auth: ctx.state.auth
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
121
|
async getCategories(ctx) {
|
|
106
122
|
const contentType = strapi.contentType("api::categoria.categoria");
|
|
107
123
|
await strapi.contentAPI.validate.query(ctx.query, contentType, {
|
|
@@ -119,29 +135,6 @@ const controller = ({ strapi }) => {
|
|
|
119
135
|
auth: ctx.state.auth
|
|
120
136
|
});
|
|
121
137
|
},
|
|
122
|
-
async getUsers(ctx) {
|
|
123
|
-
const contentType = strapi.contentType("plugin::users-permissions.user");
|
|
124
|
-
await strapi.contentAPI.validate.query(ctx.query, contentType, {
|
|
125
|
-
auth: ctx.state.auth
|
|
126
|
-
});
|
|
127
|
-
const sanitizedQueryParams = await strapi.contentAPI.sanitize.query(
|
|
128
|
-
ctx.query,
|
|
129
|
-
contentType,
|
|
130
|
-
{
|
|
131
|
-
auth: ctx.state.auth
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
const documents = await pluginService().getUsuarios(sanitizedQueryParams);
|
|
135
|
-
return await strapi.contentAPI.sanitize.output(documents, contentType, {
|
|
136
|
-
auth: ctx.state.auth
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
async generateArticle(ctx) {
|
|
140
|
-
ctx.body = await pluginService().generateArticle(ctx);
|
|
141
|
-
},
|
|
142
|
-
async generateImageForArticle(ctx) {
|
|
143
|
-
ctx.body = await pluginService().generateImageForArticle(ctx);
|
|
144
|
-
},
|
|
145
138
|
async downloadFile(ctx) {
|
|
146
139
|
await pluginService().downloadFile(ctx);
|
|
147
140
|
},
|
|
@@ -149,10 +142,10 @@ const controller = ({ strapi }) => {
|
|
|
149
142
|
ctx.body = await pluginService().generateVideo(ctx);
|
|
150
143
|
},
|
|
151
144
|
async publishToLinkedIn(ctx) {
|
|
152
|
-
ctx.body = await pluginService().publishToLinkedIn(ctx);
|
|
145
|
+
if (validarMensaje(ctx)) ctx.body = await pluginService().publishToLinkedIn(ctx);
|
|
153
146
|
},
|
|
154
147
|
async publishToFacebook(ctx) {
|
|
155
|
-
ctx.body = await pluginService().publishToFacebook(ctx);
|
|
148
|
+
if (validarMensaje(ctx)) ctx.body = await pluginService().publishToFacebook(ctx);
|
|
156
149
|
}
|
|
157
150
|
};
|
|
158
151
|
};
|
|
@@ -313,7 +306,7 @@ const INVISIBLE = /[----]/g;
|
|
|
313
306
|
const TAG = /<\/?[a-z][^>]*>/gi;
|
|
314
307
|
const sanitizePrompt = (text2) => text2.normalize("NFC").replace(CONTROL, "").replace(INVISIBLE, "").replace(TAG, "").replace(/\s+/g, " ").trim();
|
|
315
308
|
const PROMPT_LABELS = { label: "El prompt", empty: "Escribe un prompt." };
|
|
316
|
-
const INSTRUCTION_LABELS = { label: "La instrucción", empty: "Describe el cambio que quieres." };
|
|
309
|
+
const INSTRUCTION_LABELS$1 = { label: "La instrucción", empty: "Describe el cambio que quieres." };
|
|
317
310
|
const checkPrompt = (text2, { label, empty } = PROMPT_LABELS) => {
|
|
318
311
|
const clean2 = sanitizePrompt(text2);
|
|
319
312
|
if (!clean2) return { ok: false, error: empty };
|
|
@@ -369,25 +362,6 @@ const createImageStudio = (getClient, read = (p) => promises.readFile(p)) => ({
|
|
|
369
362
|
return availableModels(null);
|
|
370
363
|
}
|
|
371
364
|
},
|
|
372
|
-
/**
|
|
373
|
-
* Imagen para un artículo (S4.12): antes usaba Imagen 4, que Google apagó. Usa el primer modelo
|
|
374
|
-
* disponible del catálogo y ajusta proporción y tamaño a lo que admite. Devuelve base64.
|
|
375
|
-
*/
|
|
376
|
-
async generateForArticle(prompt, aspectRatio, imageSize) {
|
|
377
|
-
const [model] = (await this.models()).models;
|
|
378
|
-
const { image } = await this.generate({
|
|
379
|
-
prompt,
|
|
380
|
-
model,
|
|
381
|
-
aspectRatio: model.aspectRatios.includes(aspectRatio) ? aspectRatio : "16:9",
|
|
382
|
-
imageSize: model.sizes.includes(imageSize) ? imageSize : void 0,
|
|
383
|
-
safety: true,
|
|
384
|
-
// El estilo de marca de los artículos no lleva personas (su JSON ya lo pide); ahora también el parámetro.
|
|
385
|
-
allowPeople: false,
|
|
386
|
-
grounding: false,
|
|
387
|
-
references: []
|
|
388
|
-
});
|
|
389
|
-
return image;
|
|
390
|
-
},
|
|
391
365
|
async generate(input) {
|
|
392
366
|
const { models: api, backend } = await getClient();
|
|
393
367
|
const text2 = cleanPrompt(input.prompt);
|
|
@@ -465,7 +439,7 @@ const parseGenerateInput = (fields, files) => {
|
|
|
465
439
|
};
|
|
466
440
|
};
|
|
467
441
|
const parseEditInput = (fields, files) => {
|
|
468
|
-
const instruction = clean(str(fields.instruction), INSTRUCTION_LABELS);
|
|
442
|
+
const instruction = clean(str(fields.instruction), INSTRUCTION_LABELS$1);
|
|
469
443
|
const [image] = list(files.image);
|
|
470
444
|
if (!image) throw new InputError("Falta la imagen a editar.");
|
|
471
445
|
const model = editModelFor(str(fields.model) || void 0);
|
|
@@ -483,7 +457,7 @@ const parseEditInput = (fields, files) => {
|
|
|
483
457
|
aspectRatio: model.aspectRatios.includes(str(fields.aspectRatio)) ? str(fields.aspectRatio) : void 0
|
|
484
458
|
};
|
|
485
459
|
};
|
|
486
|
-
const fail$
|
|
460
|
+
const fail$3 = (ctx, status, name2, message) => {
|
|
487
461
|
ctx.status = status;
|
|
488
462
|
ctx.body = { data: null, error: { status, name: name2, message } };
|
|
489
463
|
};
|
|
@@ -493,10 +467,10 @@ const imageStudio = ({ strapi }) => {
|
|
|
493
467
|
try {
|
|
494
468
|
ctx.body = await work();
|
|
495
469
|
} catch (err) {
|
|
496
|
-
if (err instanceof InputError) return fail$
|
|
497
|
-
if (err instanceof BlockedError) return fail$
|
|
470
|
+
if (err instanceof InputError) return fail$3(ctx, 400, "BadRequestError", err.message);
|
|
471
|
+
if (err instanceof BlockedError) return fail$3(ctx, 422, "UnprocessableEntityError", err.message);
|
|
498
472
|
strapi.log.error(`[image-studio] ${err instanceof Error ? err.message : String(err)}`);
|
|
499
|
-
return fail$
|
|
473
|
+
return fail$3(ctx, 502, "BadGatewayError", "El servicio de imágenes no respondió. Intenta de nuevo en un momento.");
|
|
500
474
|
}
|
|
501
475
|
};
|
|
502
476
|
return {
|
|
@@ -510,6 +484,454 @@ const imageStudio = ({ strapi }) => {
|
|
|
510
484
|
})
|
|
511
485
|
};
|
|
512
486
|
};
|
|
487
|
+
const MAX_URLS = 3;
|
|
488
|
+
const isHttp = (value) => {
|
|
489
|
+
try {
|
|
490
|
+
const { protocol } = new URL(value);
|
|
491
|
+
return protocol === "http:" || protocol === "https:";
|
|
492
|
+
} catch {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const hostOf = (url) => {
|
|
497
|
+
try {
|
|
498
|
+
return new URL(url).hostname;
|
|
499
|
+
} catch {
|
|
500
|
+
return url;
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
const parseReferenceUrls = (input) => {
|
|
504
|
+
const list2 = (Array.isArray(input) ? input : []).filter((v) => typeof v === "string").map((v) => v.trim()).filter(Boolean);
|
|
505
|
+
const unique = [...new Set(list2)];
|
|
506
|
+
if (unique.length > MAX_URLS) throw new InputError(`Puedes dar hasta ${MAX_URLS} URLs de referencia.`);
|
|
507
|
+
const invalid = unique.find((u) => !isHttp(u));
|
|
508
|
+
if (invalid) throw new InputError(`La URL «${invalid}» no es válida.`);
|
|
509
|
+
return unique;
|
|
510
|
+
};
|
|
511
|
+
const sourcesFrom = (urls, res) => {
|
|
512
|
+
const referencias = urls.map((url) => ({ titulo: hostOf(url), url, tipo: "referencia" }));
|
|
513
|
+
const busqueda = (res?.candidates?.[0]?.groundingMetadata?.groundingChunks ?? []).map((chunk) => chunk.web).filter((web) => Boolean(web?.uri)).map((web) => ({ titulo: web.title || hostOf(web.uri), url: web.uri, tipo: "busqueda" }));
|
|
514
|
+
return [...referencias, ...busqueda].filter((f, i, all3) => all3.findIndex((o) => o.url === f.url) === i);
|
|
515
|
+
};
|
|
516
|
+
const ARTICLE_MODEL = "gemini-2.5-pro";
|
|
517
|
+
const ENRICH_MODEL = "gemini-2.5-flash";
|
|
518
|
+
const BASE_PROMPT_MAX = 2e4;
|
|
519
|
+
const INSTRUCTION_LABELS = { label: "Las instrucciones", empty: "Escribe las instrucciones del artículo." };
|
|
520
|
+
const parseCategoria = (input) => {
|
|
521
|
+
const c = input ?? {};
|
|
522
|
+
if (typeof c.id === "string" && c.id.trim()) return { id: c.id.trim() };
|
|
523
|
+
if (typeof c.nueva === "string" && c.nueva.trim()) return { nueva: c.nueva.trim().slice(0, 80) };
|
|
524
|
+
throw new InputError("Elige o escribe una categoría.");
|
|
525
|
+
};
|
|
526
|
+
const parseTemperatura = (input) => {
|
|
527
|
+
const n = typeof input === "number" ? input : typeof input === "string" ? Number(input) : NaN;
|
|
528
|
+
return Number.isFinite(n) ? Math.min(2, Math.max(0, n)) : 0.5;
|
|
529
|
+
};
|
|
530
|
+
const parseArticleInput = (body) => {
|
|
531
|
+
const check = checkPrompt(typeof body.instrucciones === "string" ? body.instrucciones : "", INSTRUCTION_LABELS);
|
|
532
|
+
if ("error" in check) throw new InputError(check.error);
|
|
533
|
+
return {
|
|
534
|
+
titulo: typeof body.titulo === "string" ? body.titulo.trim().slice(0, 200) : "",
|
|
535
|
+
categoria: parseCategoria(body.categoria),
|
|
536
|
+
temperatura: parseTemperatura(body.temperatura),
|
|
537
|
+
instrucciones: check.text,
|
|
538
|
+
urls: parseReferenceUrls(body.urls),
|
|
539
|
+
busqueda: body.busqueda === true || body.busqueda === "true",
|
|
540
|
+
usarPromptBase: !(body.usarPromptBase === false || body.usarPromptBase === "false"),
|
|
541
|
+
...optionalBase(body.promptBase)
|
|
542
|
+
};
|
|
543
|
+
};
|
|
544
|
+
const optionalBase = (input) => {
|
|
545
|
+
const text2 = typeof input === "string" ? input.trim() : "";
|
|
546
|
+
if (!text2) return {};
|
|
547
|
+
if (text2.length > BASE_PROMPT_MAX) throw new InputError(`El prompt base puede tener hasta ${BASE_PROMPT_MAX} caracteres.`);
|
|
548
|
+
return { promptBase: text2 };
|
|
549
|
+
};
|
|
550
|
+
const parseBasePrompt = (input) => {
|
|
551
|
+
const base = optionalBase(input).promptBase;
|
|
552
|
+
if (!base) throw new InputError("Escribe el prompt base.");
|
|
553
|
+
return base;
|
|
554
|
+
};
|
|
555
|
+
const researchTools = ({ urls, busqueda }) => [
|
|
556
|
+
...busqueda ? [{ googleSearch: {} }] : [],
|
|
557
|
+
...urls.length ? [{ urlContext: {} }] : []
|
|
558
|
+
];
|
|
559
|
+
const temaLines = ({ titulo, categoria, instrucciones }) => [
|
|
560
|
+
titulo ? `- Título sugerido: "${titulo}"` : "",
|
|
561
|
+
categoria ? `- Categoría o tópico: "${categoria}"` : "",
|
|
562
|
+
instrucciones ? `- Instrucciones: "${instrucciones}"` : ""
|
|
563
|
+
].filter(Boolean).join("\n");
|
|
564
|
+
const researchPrompt = (tema) => `
|
|
565
|
+
Eres analista de investigación de InterWare. Reúne la información que respaldará una columna de opinión para
|
|
566
|
+
directores de TI, operaciones y finanzas.
|
|
567
|
+
|
|
568
|
+
Tema:
|
|
569
|
+
${temaLines(tema)}
|
|
570
|
+
${tema.urls.length ? `
|
|
571
|
+
Lee y usa como referencia principal estas páginas:
|
|
572
|
+
${tema.urls.map((u) => `- ${u}`).join("\n")}
|
|
573
|
+
` : ""}
|
|
574
|
+
Entrega notas en español, concisas: hechos, cifras con su fuente, tendencias y ejemplos relevantes. No escribas el
|
|
575
|
+
artículo. Si un dato no está respaldado por una fuente, no lo incluyas.
|
|
576
|
+
`;
|
|
577
|
+
const DEFAULT_BASE_PROMPT = `# ROL Y PERSONA (EL FONDO)
|
|
578
|
+
Actúa como un Estratega Tecnológico de nivel C-Level y Arquitecto de Negocios de élite para 'InterWare'. Eres un columnista de opinión experto, escribiendo para una audiencia exclusiva de tomadores de decisión: Directores de TI (CTOs), Directores de Operaciones (COOs) y Directores Financieros (CFOs/FinOps).
|
|
579
|
+
No eres un redactor de marketing ni un vendedor de software; eres un consultor de alto nivel que diagnostica problemas sistémicos complejos y ofrece perspectivas de valor incalculable. Tu objetivo es hacer que el lector cuestione la madurez de su propia infraestructura.
|
|
580
|
+
|
|
581
|
+
# FILOSOFÍA DE MARCA: "ORQUESTACIÓN LATENTE"
|
|
582
|
+
Toda tu narrativa debe estar impregnada de nuestra visión de negocio: "Evolución por Continuidad"
|
|
583
|
+
- InterWare no inventa necesidades ni vende catálogos de servicios; InterWare resuelve la complejidad operativa con responsabilidad
|
|
584
|
+
- Somos el orquestador invisible que garantiza que ecosistemas heterogéneos trabajen en perfecta armonía.
|
|
585
|
+
- Tu ancla absoluta de confianza y diferenciador es: "El código tiene alma". Esto significa que no entregamos simple software; entregamos sistemas de misión crítica que no fallan, respaldados por equipos humanos de excelencia.
|
|
586
|
+
- Tu respaldo de autoridad (menciónelo sutilmente como validación, nunca como presunción): Nos avalan casi 30 años de historia, más de 9,000 proyectos exitosos, primer centro autorizado de Java en LATAM y más de 25 años como Partners Gold de IBM. Nuestra prueba de lealtad es que promediamos relaciones de más de 10 años con nuestros clientes.
|
|
587
|
+
|
|
588
|
+
# REGLAS DE TONO Y LÉXICO (LA FORMA)
|
|
589
|
+
1. El Tono: Profundamente autoritario, frío, elegante, quirúrgico y sofisticado. Escribe con la certeza de quien ha visto todas las fallas posibles en la industria y sabe cómo prevenirlas.
|
|
590
|
+
2. Vocabulario Obligatorio (Usa al menos 4 de forma natural): Orquestación, resiliencia, fricción operativa, deuda técnica, telemetría, anticipación, interoperabilidad, misión crítica, observabilidad profunda, ecosistemas híbridos, primitivas de orquestación.
|
|
591
|
+
3. Prohibición de Léxico Barato (Zero-Clutter Text): PROHIBIDO usar palabras literales o burdas como "fierros", "cables", "hardware", "servidores físicos" o "computadoras". En su lugar, usa "nodos", "infraestructura", "arquitecturas distribuidas", "activos digitales".
|
|
592
|
+
|
|
593
|
+
# RESTRICCIONES ESTRICTAS ANTI-IA (EL ESTILO)
|
|
594
|
+
- Cero Clichés de Marketing: NUNCA uses frases trilladas como "en el mundo digital de hoy", "en la era actual", "desata el poder", "revolucionar el mercado", "lleva tu empresa al siguiente nivel" o "somos tu mejor opción".
|
|
595
|
+
- Cero Estructuras Robóticas: Evita transiciones predecibles como "En resumen", "En conclusión", "En primer lugar", "En segundo lugar".
|
|
596
|
+
- Fluidez Orgánica: No abuses de las listas de viñetas (bullets). Si debes listar beneficios, intégralos en la prosa de manera fluida o usa negritas sutiles dentro de un párrafo.
|
|
597
|
+
- Espacio Negativo Textual: Los tomadores de decisión no leen bloques densos de texto. Usa párrafos cortos (máximo 3 o 4 líneas). El texto debe "respirar".
|
|
598
|
+
|
|
599
|
+
# INSTRUCCIÓN DE EJECUCIÓN: LA NARRATIVA DE LA COLUMNA
|
|
600
|
+
Redacta una columna de opinión profunda y analítica sobre el tema de la sección «TEMA DEL ARTÍCULO».
|
|
601
|
+
|
|
602
|
+
Tu artículo debe seguir este arco narrativo impecable (entre 600 y 800 palabras):
|
|
603
|
+
|
|
604
|
+
1. EL TÍTULO ABSTRACTO: Crea un título de menos de 10 palabras que evoque un dolor de negocio o una revelación financiera, no una característica de software. Debe sonar a un artículo de *Harvard Business Review*.
|
|
605
|
+
2. LA FRICCIÓN (El Diagnóstico Crudo): Abre el artículo sin introducciones banales. Golpea directamente diagnosticando el dolor del negocio (ej. la pérdida de rentabilidad por cuellos de botella operativos o el riesgo inminente de sistemas legados que nadie sabe mantener). Haz que el lector sienta que estás describiendo su empresa.
|
|
606
|
+
3. LA ORQUESTACIÓN (El Núcleo): Desarrolla tu argumento explicando cómo una arquitectura inteligente (ya sea a través de microservicios, DevSecOps, automatización inteligente de negocio, o monitoreo sintético con herramientas como iwRobot) resuelve este problema de raíz. Transmite la idea de que la tecnología debe ser un habilitador transparente, no una carga.
|
|
607
|
+
4. EL IMPACTO LATENTE: Teje dentro de la prosa (sin usar viñetas obvias de IA) los tres impactos estratégicos del tema. Habla de cómo se logra la Resiliencia, la Fluidez operativa, la Eficiencia financiera o la Anticipación ante el riesgo.
|
|
608
|
+
5. EL CIERRE SUTIL (El CTA Elegante): En lugar de un llamado a la acción desesperado de ventas, cierra con una reflexión ejecutiva o una pregunta abierta que invite al lector a auditar mentalmente la madurez de su propia infraestructura. Una despedida que demuestre que, para orquestar la complejidad, se requiere la maestría de tres décadas.
|
|
609
|
+
|
|
610
|
+
Recuerda: Eres un experto hablando con otro experto. Sé denso en valor y conciso en palabras`;
|
|
611
|
+
const investigacionBlock = (investigacion) => investigacion ? `
|
|
612
|
+
|
|
613
|
+
# INVESTIGACIÓN DE APOYO
|
|
614
|
+
Usa estos datos como base factual. No inventes cifras, nombres ni estudios que no aparezcan aquí:
|
|
615
|
+
${investigacion}` : "";
|
|
616
|
+
const articlePrompt = ({ base = DEFAULT_BASE_PROMPT, investigacion, ...tema }) => `${base}
|
|
617
|
+
|
|
618
|
+
# TEMA DEL ARTÍCULO
|
|
619
|
+
${temaLines(tema)}${investigacionBlock(investigacion)}`;
|
|
620
|
+
const rawPrompt = ({ instrucciones, investigacion }) => `${instrucciones}${investigacionBlock(investigacion)}`;
|
|
621
|
+
const enrichPrompt = (texto) => `
|
|
622
|
+
Eres editor de contenidos de InterWare, empresa mexicana de tecnología. Convierte esta idea en instrucciones claras
|
|
623
|
+
para redactar un artículo de blog.
|
|
624
|
+
|
|
625
|
+
Idea: "${texto}"
|
|
626
|
+
|
|
627
|
+
Responde solo con las instrucciones, en español y en texto plano, con estas líneas:
|
|
628
|
+
Tema: …
|
|
629
|
+
Público: …
|
|
630
|
+
Cubrir: …
|
|
631
|
+
Tono: …
|
|
632
|
+
Cierre: …
|
|
633
|
+
Máximo 1500 caracteres. Sin comillas ni Markdown.
|
|
634
|
+
`;
|
|
635
|
+
const ARTICLE_SCHEMA = {
|
|
636
|
+
type: "object",
|
|
637
|
+
required: ["titulo", "descripcion", "content", "seo", "minute_read"],
|
|
638
|
+
properties: {
|
|
639
|
+
seo: {
|
|
640
|
+
type: "object",
|
|
641
|
+
required: ["metaTitle", "metaDescription", "metadata"],
|
|
642
|
+
properties: {
|
|
643
|
+
metaTitle: { type: "string" },
|
|
644
|
+
metaDescription: { type: "string" },
|
|
645
|
+
metadata: {
|
|
646
|
+
type: "array",
|
|
647
|
+
items: {
|
|
648
|
+
type: "object",
|
|
649
|
+
required: ["name", "content"],
|
|
650
|
+
properties: { name: { type: "string" }, content: { type: "string" } }
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
},
|
|
655
|
+
titulo: { type: "string", minLength: 40, maxLength: 70, description: "Título del artículo" },
|
|
656
|
+
descripcion: { type: "string", minLength: 80, maxLength: 160, description: "Descripción breve del artículo" },
|
|
657
|
+
slug: {
|
|
658
|
+
type: "string",
|
|
659
|
+
minLength: 80,
|
|
660
|
+
maxLength: 160,
|
|
661
|
+
description: "URL-friendly basado en el título (ej: estrategias-migracion-nube)"
|
|
662
|
+
},
|
|
663
|
+
content: { type: "string", description: "Contenido HTML compatible con CKEditor" },
|
|
664
|
+
minute_read: {
|
|
665
|
+
type: "integer",
|
|
666
|
+
minimum: 1,
|
|
667
|
+
maximum: 30,
|
|
668
|
+
description: "Tiempo de lectura calculado usando 200 palabras por minuto"
|
|
669
|
+
},
|
|
670
|
+
keywords: {
|
|
671
|
+
type: "array",
|
|
672
|
+
minItems: 3,
|
|
673
|
+
maxItems: 5,
|
|
674
|
+
items: { type: "object", required: ["name"], properties: { name: { type: "string" } } },
|
|
675
|
+
description: "Hash tags y palabras clave para la publicación en LinkedIn y Facebook"
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
const ZONA = "America/Mexico_City";
|
|
680
|
+
const UN_ANIO_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
681
|
+
const fechaEnMexico = (date) => new Intl.DateTimeFormat("en-CA", { timeZone: ZONA, year: "numeric", month: "2-digit", day: "2-digit" }).format(date);
|
|
682
|
+
const parseScheduleAt = (input, now) => {
|
|
683
|
+
const date = typeof input === "string" ? new Date(input) : /* @__PURE__ */ new Date(NaN);
|
|
684
|
+
if (Number.isNaN(date.getTime())) throw new InputError("La fecha y hora no son válidas.");
|
|
685
|
+
if (date.getTime() <= now.getTime()) throw new InputError("Elige una fecha y hora futuras.");
|
|
686
|
+
if (date.getTime() - now.getTime() > UN_ANIO_MS) throw new InputError("Programa con menos de un año de anticipación.");
|
|
687
|
+
return date;
|
|
688
|
+
};
|
|
689
|
+
const estadoDe = ({ publicado, programada }) => publicado ? "publicado" : programada ? "programado" : "borrador";
|
|
690
|
+
class NotFoundError extends Error {
|
|
691
|
+
}
|
|
692
|
+
const memoryStore = () => {
|
|
693
|
+
let value = null;
|
|
694
|
+
return {
|
|
695
|
+
get: async () => value,
|
|
696
|
+
set: async (v) => {
|
|
697
|
+
value = v;
|
|
698
|
+
},
|
|
699
|
+
remove: async () => {
|
|
700
|
+
value = null;
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
const ROW_FIELDS = ["titulo", "fecha_publicacion", "publicacion_programada", "linkedInPostId", "facebookPostId"];
|
|
705
|
+
const DETAIL_POPULATE = { image: true, categoria: true, seo: true, keywords: true };
|
|
706
|
+
const silentLog = { info: () => void 0, warn: () => void 0, error: () => void 0 };
|
|
707
|
+
const slugify = (text2) => text2.toLowerCase().normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
708
|
+
const textOf = (res) => (res.text ?? res.candidates?.[0]?.content?.parts?.[0]?.text ?? "").trim();
|
|
709
|
+
const toRow = (d, publicado) => ({
|
|
710
|
+
documentId: d.documentId,
|
|
711
|
+
titulo: d.titulo ?? "",
|
|
712
|
+
categoria: d.categoria?.categoria ?? null,
|
|
713
|
+
estado: estadoDe({ publicado, programada: d.publicacion_programada }),
|
|
714
|
+
imagen: Boolean(d.image),
|
|
715
|
+
fechaPublicacion: d.fecha_publicacion ?? null,
|
|
716
|
+
programadaPara: d.publicacion_programada ?? null,
|
|
717
|
+
linkedInPostId: d.linkedInPostId ?? null,
|
|
718
|
+
facebookPostId: d.facebookPostId ?? null
|
|
719
|
+
});
|
|
720
|
+
const toDetail = (d, publicado) => ({
|
|
721
|
+
...toRow(d, publicado),
|
|
722
|
+
descripcion: d.descripcion ?? "",
|
|
723
|
+
content: d.content ?? "",
|
|
724
|
+
minuteRead: d.minute_read ?? null,
|
|
725
|
+
slug: d.slug ?? null,
|
|
726
|
+
imageUrl: d.image ? d.image.formats?.small?.url ?? d.image.formats?.thumbnail?.url ?? d.image.url ?? null : null,
|
|
727
|
+
imageName: d.image?.name ?? null,
|
|
728
|
+
seo: d.seo ? { metaTitle: d.seo.metaTitle, metaDescription: d.seo.metaDescription } : null,
|
|
729
|
+
keywords: (d.keywords ?? []).map((k) => k.name ?? "").filter(Boolean),
|
|
730
|
+
fuentes: Array.isArray(d.fuentes) ? d.fuentes : []
|
|
731
|
+
});
|
|
732
|
+
const createArticles = ({ articulos, categorias, getModels, now = () => /* @__PURE__ */ new Date(), log = silentLog, promptStore = memoryStore() }) => {
|
|
733
|
+
const draftOf = async (documentId, populate = DETAIL_POPULATE) => {
|
|
734
|
+
const d = await articulos.findOne({ documentId, status: "draft", populate });
|
|
735
|
+
if (!d) throw new NotFoundError("El artículo no existe.");
|
|
736
|
+
return d;
|
|
737
|
+
};
|
|
738
|
+
const isPublished = async (documentId) => Boolean(await articulos.findOne({ documentId, status: "published", fields: ["titulo"] }));
|
|
739
|
+
const detail = async (documentId) => {
|
|
740
|
+
const d = await draftOf(documentId);
|
|
741
|
+
return toDetail(d, await isPublished(documentId));
|
|
742
|
+
};
|
|
743
|
+
const resolveCategoria = async (input) => {
|
|
744
|
+
if ("id" in input) {
|
|
745
|
+
const c = await categorias.findOne({ documentId: input.id });
|
|
746
|
+
if (!c) throw new InputError("La categoría elegida ya no existe.");
|
|
747
|
+
return { id: c.documentId, nombre: c.categoria };
|
|
748
|
+
}
|
|
749
|
+
const found = await categorias.findFirst({ filters: { categoria: { $eqi: input.nueva } } });
|
|
750
|
+
if (found) return { id: found.documentId, nombre: found.categoria };
|
|
751
|
+
const created = await categorias.create({ data: { categoria: input.nueva, slug: slugify(input.nueva) } });
|
|
752
|
+
return { id: created.documentId, nombre: input.nueva };
|
|
753
|
+
};
|
|
754
|
+
const basePrompt = async () => {
|
|
755
|
+
const guardado = await promptStore.get();
|
|
756
|
+
return { prompt: guardado || DEFAULT_BASE_PROMPT, personalizado: Boolean(guardado) };
|
|
757
|
+
};
|
|
758
|
+
return {
|
|
759
|
+
basePrompt,
|
|
760
|
+
async saveBasePrompt(prompt) {
|
|
761
|
+
await promptStore.set(prompt);
|
|
762
|
+
return basePrompt();
|
|
763
|
+
},
|
|
764
|
+
async resetBasePrompt() {
|
|
765
|
+
await promptStore.remove();
|
|
766
|
+
return basePrompt();
|
|
767
|
+
},
|
|
768
|
+
async list() {
|
|
769
|
+
const [drafts, published] = await Promise.all([
|
|
770
|
+
articulos.findMany({ status: "draft", fields: ROW_FIELDS, populate: { image: { fields: ["id"] }, categoria: { fields: ["categoria"] } }, sort: ["createdAt:desc"] }),
|
|
771
|
+
articulos.findMany({ status: "published", fields: ["titulo"] })
|
|
772
|
+
]);
|
|
773
|
+
const publicados = new Set(published.map((p) => p.documentId));
|
|
774
|
+
return { articles: drafts.map((d) => toRow(d, publicados.has(d.documentId))) };
|
|
775
|
+
},
|
|
776
|
+
detail,
|
|
777
|
+
async generate(input) {
|
|
778
|
+
const categoria = await resolveCategoria(input.categoria);
|
|
779
|
+
const models = await getModels();
|
|
780
|
+
const tema = { titulo: input.titulo, categoria: categoria.nombre, instrucciones: input.instrucciones };
|
|
781
|
+
const tools = researchTools(input);
|
|
782
|
+
let investigacion;
|
|
783
|
+
let fuentes = [];
|
|
784
|
+
if (tools.length) {
|
|
785
|
+
const research = await models.generateContent({ model: ARTICLE_MODEL, contents: researchPrompt({ ...tema, urls: input.urls }), config: { tools, temperature: 0.2 } });
|
|
786
|
+
investigacion = textOf(research) || void 0;
|
|
787
|
+
fuentes = sourcesFrom(input.urls, research);
|
|
788
|
+
}
|
|
789
|
+
const contents = input.usarPromptBase === false ? rawPrompt({ instrucciones: input.instrucciones, investigacion }) : articlePrompt({ ...tema, investigacion, base: input.promptBase ?? (await basePrompt()).prompt });
|
|
790
|
+
const res = await models.generateContent({
|
|
791
|
+
model: ARTICLE_MODEL,
|
|
792
|
+
contents,
|
|
793
|
+
config: { responseMimeType: "application/json", temperature: input.temperatura, responseSchema: ARTICLE_SCHEMA }
|
|
794
|
+
});
|
|
795
|
+
let parsed;
|
|
796
|
+
try {
|
|
797
|
+
parsed = JSON.parse(textOf(res));
|
|
798
|
+
} catch {
|
|
799
|
+
throw new Error("La respuesta del modelo no es un JSON válido.");
|
|
800
|
+
}
|
|
801
|
+
const created = await articulos.create({
|
|
802
|
+
data: {
|
|
803
|
+
titulo: parsed.titulo,
|
|
804
|
+
descripcion: parsed.descripcion,
|
|
805
|
+
content: parsed.content,
|
|
806
|
+
seo: parsed.seo,
|
|
807
|
+
minute_read: parsed.minute_read,
|
|
808
|
+
slug: parsed.slug,
|
|
809
|
+
keywords: parsed.keywords,
|
|
810
|
+
categoria: categoria.id,
|
|
811
|
+
image: null,
|
|
812
|
+
fuentes
|
|
813
|
+
},
|
|
814
|
+
status: "draft"
|
|
815
|
+
});
|
|
816
|
+
return { documentId: created.documentId };
|
|
817
|
+
},
|
|
818
|
+
async enrich(texto) {
|
|
819
|
+
const models = await getModels();
|
|
820
|
+
const res = await models.generateContent({ model: ENRICH_MODEL, contents: enrichPrompt(texto) });
|
|
821
|
+
const out = textOf(res).replace(/^["'«“]+|["'»”]+$/g, "").trim();
|
|
822
|
+
if (!out) throw new InputError("No se pudieron enriquecer las instrucciones. Intenta de nuevo.");
|
|
823
|
+
return out.slice(0, 2e3);
|
|
824
|
+
},
|
|
825
|
+
async setImage(documentId, fileId) {
|
|
826
|
+
const id = typeof fileId === "number" ? fileId : Number(fileId);
|
|
827
|
+
if (!Number.isInteger(id) || id <= 0) throw new InputError("Elige una imagen válida.");
|
|
828
|
+
await draftOf(documentId, {});
|
|
829
|
+
await articulos.update({ documentId, data: { image: id } });
|
|
830
|
+
if (await isPublished(documentId)) await articulos.publish({ documentId });
|
|
831
|
+
return detail(documentId);
|
|
832
|
+
},
|
|
833
|
+
async publish(documentId) {
|
|
834
|
+
const d = await draftOf(documentId);
|
|
835
|
+
if (!d.image) throw new InputError("Elige una imagen antes de publicar.");
|
|
836
|
+
await articulos.update({ documentId, data: { fecha_publicacion: fechaEnMexico(now()), publicacion_programada: null } });
|
|
837
|
+
await articulos.publish({ documentId });
|
|
838
|
+
return detail(documentId);
|
|
839
|
+
},
|
|
840
|
+
async schedule(documentId, at) {
|
|
841
|
+
const date = parseScheduleAt(at, now());
|
|
842
|
+
const d = await draftOf(documentId);
|
|
843
|
+
if (!d.image) throw new InputError("Elige una imagen antes de programar.");
|
|
844
|
+
if (await isPublished(documentId)) throw new InputError("El artículo ya está publicado.");
|
|
845
|
+
await articulos.update({ documentId, data: { publicacion_programada: date.toISOString(), fecha_publicacion: fechaEnMexico(date) } });
|
|
846
|
+
return detail(documentId);
|
|
847
|
+
},
|
|
848
|
+
async unschedule(documentId) {
|
|
849
|
+
await draftOf(documentId, {});
|
|
850
|
+
await articulos.update({ documentId, data: { publicacion_programada: null, fecha_publicacion: null } });
|
|
851
|
+
return detail(documentId);
|
|
852
|
+
},
|
|
853
|
+
/** D4: publica los borradores con programación vencida. Devuelve cuántos publicó. */
|
|
854
|
+
async publishDue() {
|
|
855
|
+
const due = await articulos.findMany({
|
|
856
|
+
status: "draft",
|
|
857
|
+
filters: { publicacion_programada: { $notNull: true, $lte: now().toISOString() } },
|
|
858
|
+
fields: ["publicacion_programada"],
|
|
859
|
+
populate: { image: { fields: ["id"] } }
|
|
860
|
+
});
|
|
861
|
+
let count = 0;
|
|
862
|
+
for (const d of due) {
|
|
863
|
+
if (!d.image) {
|
|
864
|
+
log.warn(`[articles] ${d.documentId} está programado pero no tiene imagen; no se publicó.`);
|
|
865
|
+
continue;
|
|
866
|
+
}
|
|
867
|
+
try {
|
|
868
|
+
await articulos.update({ documentId: d.documentId, data: { publicacion_programada: null } });
|
|
869
|
+
await articulos.publish({ documentId: d.documentId });
|
|
870
|
+
count += 1;
|
|
871
|
+
} catch (err) {
|
|
872
|
+
log.error(`[articles] no se pudo publicar ${d.documentId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if (count) log.info(`[articles] ${count} artículo(s) programado(s) publicados.`);
|
|
876
|
+
return count;
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
const articles$1 = ({ strapi }) => createArticles({
|
|
881
|
+
articulos: strapi.documents("api::articulo.articulo"),
|
|
882
|
+
categorias: strapi.documents("api::categoria.categoria"),
|
|
883
|
+
getModels: async () => (await strapi.plugin("strapi-content-generator-gemini").service("service").geminiClient()).ai.models,
|
|
884
|
+
log: strapi.log,
|
|
885
|
+
promptStore: /* @__PURE__ */ (() => {
|
|
886
|
+
const store = () => strapi.store({ type: "plugin", name: "strapi-content-generator-gemini" });
|
|
887
|
+
const key = "ARTICLE_BASE_PROMPT";
|
|
888
|
+
return {
|
|
889
|
+
get: async () => await store().get({ key }) ?? null,
|
|
890
|
+
set: async (value) => {
|
|
891
|
+
await store().set({ key, value });
|
|
892
|
+
},
|
|
893
|
+
remove: async () => {
|
|
894
|
+
await store().delete({ key });
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
})()
|
|
898
|
+
});
|
|
899
|
+
const fail$2 = (ctx, status, name2, message) => {
|
|
900
|
+
ctx.status = status;
|
|
901
|
+
ctx.body = { data: null, error: { status, name: name2, message } };
|
|
902
|
+
};
|
|
903
|
+
const articles = ({ strapi }) => {
|
|
904
|
+
const articles2 = () => strapi.plugin("strapi-content-generator-gemini").service("articles");
|
|
905
|
+
const id = (ctx) => ctx.params?.documentId ?? "";
|
|
906
|
+
const run = async (ctx, work) => {
|
|
907
|
+
try {
|
|
908
|
+
ctx.body = await work();
|
|
909
|
+
} catch (err) {
|
|
910
|
+
if (err instanceof InputError) return fail$2(ctx, 400, "BadRequestError", err.message);
|
|
911
|
+
if (err instanceof NotFoundError) return fail$2(ctx, 404, "NotFoundError", err.message);
|
|
912
|
+
if (err instanceof Error && err.name === "ValidationError") return fail$2(ctx, 400, "ValidationError", err.message);
|
|
913
|
+
strapi.log.error(`[articles] ${err instanceof Error ? err.message : String(err)}`);
|
|
914
|
+
return fail$2(ctx, 502, "BadGatewayError", "El servicio de generación no respondió. Intenta de nuevo en un momento.");
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
return {
|
|
918
|
+
list: (ctx) => run(ctx, () => articles2().list()),
|
|
919
|
+
detail: (ctx) => run(ctx, () => articles2().detail(id(ctx))),
|
|
920
|
+
generate: (ctx) => run(ctx, () => articles2().generate(parseArticleInput(ctx.request.body ?? {}))),
|
|
921
|
+
enrich: (ctx) => run(ctx, async () => {
|
|
922
|
+
const raw = typeof ctx.request.body?.texto === "string" ? ctx.request.body.texto : "";
|
|
923
|
+
const texto = clean(raw, { label: "La idea", empty: "Escribe una idea para enriquecer." });
|
|
924
|
+
return { texto: await articles2().enrich(texto) };
|
|
925
|
+
}),
|
|
926
|
+
basePrompt: (ctx) => run(ctx, () => articles2().basePrompt()),
|
|
927
|
+
saveBasePrompt: (ctx) => run(ctx, () => articles2().saveBasePrompt(parseBasePrompt(ctx.request.body?.prompt))),
|
|
928
|
+
resetBasePrompt: (ctx) => run(ctx, () => articles2().resetBasePrompt()),
|
|
929
|
+
setImage: (ctx) => run(ctx, () => articles2().setImage(id(ctx), ctx.request.body?.fileId)),
|
|
930
|
+
publish: (ctx) => run(ctx, () => articles2().publish(id(ctx))),
|
|
931
|
+
schedule: (ctx) => run(ctx, () => articles2().schedule(id(ctx), ctx.request.body?.at)),
|
|
932
|
+
unschedule: (ctx) => run(ctx, () => articles2().unschedule(id(ctx)))
|
|
933
|
+
};
|
|
934
|
+
};
|
|
513
935
|
const NAVY = "#1F2A44";
|
|
514
936
|
const RED = "#E4002B";
|
|
515
937
|
const TEAL = "#00C7B1";
|
|
@@ -873,7 +1295,8 @@ const controllers = {
|
|
|
873
1295
|
controller,
|
|
874
1296
|
config: config$1,
|
|
875
1297
|
"image-studio": imageStudio,
|
|
876
|
-
templates
|
|
1298
|
+
templates,
|
|
1299
|
+
articles
|
|
877
1300
|
};
|
|
878
1301
|
const middlewares = {};
|
|
879
1302
|
const policies = {};
|
|
@@ -887,12 +1310,20 @@ const ADMIN_ACCESS_POLICIES = [
|
|
|
887
1310
|
];
|
|
888
1311
|
const config = { policies: ADMIN_ACCESS_POLICIES };
|
|
889
1312
|
const admin = [
|
|
890
|
-
{ method: "GET", path: "/
|
|
1313
|
+
{ method: "GET", path: "/articles", handler: "articles.list", config },
|
|
1314
|
+
// Las rutas fijas van antes de `/articles/:documentId` para que no las tome como id.
|
|
1315
|
+
{ method: "POST", path: "/articles/generate", handler: "articles.generate", config },
|
|
1316
|
+
{ method: "POST", path: "/articles/enrich", handler: "articles.enrich", config },
|
|
1317
|
+
{ method: "GET", path: "/articles/base-prompt", handler: "articles.basePrompt", config },
|
|
1318
|
+
{ method: "PUT", path: "/articles/base-prompt", handler: "articles.saveBasePrompt", config },
|
|
1319
|
+
{ method: "DELETE", path: "/articles/base-prompt", handler: "articles.resetBasePrompt", config },
|
|
1320
|
+
{ method: "GET", path: "/articles/:documentId", handler: "articles.detail", config },
|
|
1321
|
+
{ method: "PUT", path: "/articles/:documentId/image", handler: "articles.setImage", config },
|
|
1322
|
+
{ method: "POST", path: "/articles/:documentId/publish", handler: "articles.publish", config },
|
|
1323
|
+
{ method: "POST", path: "/articles/:documentId/schedule", handler: "articles.schedule", config },
|
|
1324
|
+
{ method: "DELETE", path: "/articles/:documentId/schedule", handler: "articles.unschedule", config },
|
|
891
1325
|
{ method: "GET", path: "/categories", handler: "controller.getCategories", config },
|
|
892
|
-
{ method: "GET", path: "/users", handler: "controller.getUsers", config },
|
|
893
1326
|
{ method: "POST", path: "/download-file", handler: "controller.downloadFile", config },
|
|
894
|
-
{ method: "POST", path: "/generate-article", handler: "controller.generateArticle", config },
|
|
895
|
-
{ method: "POST", path: "/generate-image", handler: "controller.generateImageForArticle", config },
|
|
896
1327
|
{ method: "GET", path: "/image-studio/models", handler: "image-studio.models", config },
|
|
897
1328
|
{ method: "POST", path: "/image-studio/generate", handler: "image-studio.generate", config },
|
|
898
1329
|
{ method: "POST", path: "/image-studio/edit", handler: "image-studio.edit", config },
|
|
@@ -4171,6 +4602,11 @@ const createGeminiClient = ({ serviceAccount, apiKey, allowVertex = true }, Ctor
|
|
|
4171
4602
|
allowVertex ? "Configura la cuenta de servicio de Vertex AI o la llave de Gemini en Ajustes del plugin." : "El video necesita la llave de Gemini en Ajustes del plugin."
|
|
4172
4603
|
);
|
|
4173
4604
|
};
|
|
4605
|
+
const postData = (article) => ({
|
|
4606
|
+
titulo: article.titulo ?? "",
|
|
4607
|
+
descripcion: article.descripcion ?? "",
|
|
4608
|
+
keywords: (Array.isArray(article.keywords) ? article.keywords : []).map((k) => k?.name ?? "")
|
|
4609
|
+
});
|
|
4174
4610
|
const service = ({ strapi }) => {
|
|
4175
4611
|
return {
|
|
4176
4612
|
// ───────────────────────────────
|
|
@@ -4190,15 +4626,9 @@ const service = ({ strapi }) => {
|
|
|
4190
4626
|
async geminiConfig() {
|
|
4191
4627
|
return (await this.geminiClient()).ai;
|
|
4192
4628
|
},
|
|
4193
|
-
async getArticulos(sanitizedQueryParams) {
|
|
4194
|
-
return await strapi.entityService.findMany("api::articulo.articulo", sanitizedQueryParams);
|
|
4195
|
-
},
|
|
4196
4629
|
async getCategorias(sanitizedQueryParams) {
|
|
4197
4630
|
return await strapi.entityService.findMany("api::categoria.categoria", sanitizedQueryParams);
|
|
4198
4631
|
},
|
|
4199
|
-
async getUsuarios(sanitizedQueryParams) {
|
|
4200
|
-
return await strapi.documents("plugin::users-permissions.user").findMany(sanitizedQueryParams);
|
|
4201
|
-
},
|
|
4202
4632
|
// ───────────────────────────────
|
|
4203
4633
|
// 📥 Proxy File Download (bypasses browser CORS)
|
|
4204
4634
|
// ───────────────────────────────
|
|
@@ -4268,232 +4698,6 @@ const service = ({ strapi }) => {
|
|
|
4268
4698
|
}
|
|
4269
4699
|
return uploadedFiles[0];
|
|
4270
4700
|
},
|
|
4271
|
-
// ───────────────────────────────
|
|
4272
|
-
// 🧠 Generate Article with AI
|
|
4273
|
-
// ───────────────────────────────
|
|
4274
|
-
async generateArticle(ctx) {
|
|
4275
|
-
const { titulo, categoria, autor, temperatura = 0.5, instrucciones } = ctx.request.body;
|
|
4276
|
-
const promptArticulo = `
|
|
4277
|
-
# ROL Y PERSONA (EL FONDO)
|
|
4278
|
-
Actúa como un Estratega Tecnológico de nivel C-Level y Arquitecto de Negocios de élite para 'InterWare'. Eres un columnista de opinión experto, escribiendo para una audiencia exclusiva de tomadores de decisión: Directores de TI (CTOs), Directores de Operaciones (COOs) y Directores Financieros (CFOs/FinOps).
|
|
4279
|
-
No eres un redactor de marketing ni un vendedor de software; eres un consultor de alto nivel que diagnostica problemas sistémicos complejos y ofrece perspectivas de valor incalculable. Tu objetivo es hacer que el lector cuestione la madurez de su propia infraestructura.
|
|
4280
|
-
|
|
4281
|
-
# FILOSOFÍA DE MARCA: "ORQUESTACIÓN LATENTE"
|
|
4282
|
-
Toda tu narrativa debe estar impregnada de nuestra visión de negocio: "Evolución por Continuidad"
|
|
4283
|
-
- InterWare no inventa necesidades ni vende catálogos de servicios; InterWare resuelve la complejidad operativa con responsabilidad
|
|
4284
|
-
- Somos el orquestador invisible que garantiza que ecosistemas heterogéneos trabajen en perfecta armonía.
|
|
4285
|
-
- Tu ancla absoluta de confianza y diferenciador es: "El código tiene alma". Esto significa que no entregamos simple software; entregamos sistemas de misión crítica que no fallan, respaldados por equipos humanos de excelencia.
|
|
4286
|
-
- Tu respaldo de autoridad (menciónelo sutilmente como validación, nunca como presunción): Nos avalan casi 30 años de historia, más de 9,000 proyectos exitosos, primer centro autorizado de Java en LATAM y más de 25 años como Partners Gold de IBM. Nuestra prueba de lealtad es que promediamos relaciones de más de 10 años con nuestros clientes.
|
|
4287
|
-
|
|
4288
|
-
# REGLAS DE TONO Y LÉXICO (LA FORMA)
|
|
4289
|
-
1. El Tono: Profundamente autoritario, frío, elegante, quirúrgico y sofisticado. Escribe con la certeza de quien ha visto todas las fallas posibles en la industria y sabe cómo prevenirlas.
|
|
4290
|
-
2. Vocabulario Obligatorio (Usa al menos 4 de forma natural): Orquestación, resiliencia, fricción operativa, deuda técnica, telemetría, anticipación, interoperabilidad, misión crítica, observabilidad profunda, ecosistemas híbridos, primitivas de orquestación.
|
|
4291
|
-
3. Prohibición de Léxico Barato (Zero-Clutter Text): PROHIBIDO usar palabras literales o burdas como "fierros", "cables", "hardware", "servidores físicos" o "computadoras". En su lugar, usa "nodos", "infraestructura", "arquitecturas distribuidas", "activos digitales".
|
|
4292
|
-
|
|
4293
|
-
# RESTRICCIONES ESTRICTAS ANTI-IA (EL ESTILO)
|
|
4294
|
-
- Cero Clichés de Marketing: NUNCA uses frases trilladas como "en el mundo digital de hoy", "en la era actual", "desata el poder", "revolucionar el mercado", "lleva tu empresa al siguiente nivel" o "somos tu mejor opción".
|
|
4295
|
-
- Cero Estructuras Robóticas: Evita transiciones predecibles como "En resumen", "En conclusión", "En primer lugar", "En segundo lugar".
|
|
4296
|
-
- Fluidez Orgánica: No abuses de las listas de viñetas (bullets). Si debes listar beneficios, intégralos en la prosa de manera fluida o usa negritas sutiles dentro de un párrafo.
|
|
4297
|
-
- Espacio Negativo Textual: Los tomadores de decisión no leen bloques densos de texto. Usa párrafos cortos (máximo 3 o 4 líneas). El texto debe "respirar".
|
|
4298
|
-
|
|
4299
|
-
# INSTRUCCIÓN DE EJECUCIÓN: LA NARRATIVA DE LA COLUMNA
|
|
4300
|
-
Redacta una columna de opinión profunda y analítica sobre el siguiente tema:
|
|
4301
|
-
${titulo ? `- Título sugerido: "${titulo}"` : ""}
|
|
4302
|
-
${categoria ? `- Categoría or tópico: "${categoria}"` : ""}
|
|
4303
|
-
${instrucciones ? `- Instrucciones adicionales: "${instrucciones}"` : ""}
|
|
4304
|
-
|
|
4305
|
-
Tu artículo debe seguir este arco narrativo impecable (entre 600 y 800 palabras):
|
|
4306
|
-
|
|
4307
|
-
1. EL TÍTULO ABSTRACTO: Crea un título de menos de 10 palabras que evoque un dolor de negocio o una revelación financiera, no una característica de software. Debe sonar a un artículo de *Harvard Business Review*.
|
|
4308
|
-
2. LA FRICCIÓN (El Diagnóstico Crudo): Abre el artículo sin introducciones banales. Golpea directamente diagnosticando el dolor del negocio (ej. la pérdida de rentabilidad por cuellos de botella operativos o el riesgo inminente de sistemas legados que nadie sabe mantener). Haz que el lector sienta que estás describiendo su empresa.
|
|
4309
|
-
3. LA ORQUESTACIÓN (El Núcleo): Desarrolla tu argumento explicando cómo una arquitectura inteligente (ya sea a través de microservicios, DevSecOps, automatización inteligente de negocio, o monitoreo sintético con herramientas como iwRobot) resuelve este problema de raíz. Transmite la idea de que la tecnología debe ser un habilitador transparente, no una carga.
|
|
4310
|
-
4. EL IMPACTO LATENTE: Teje dentro de la prosa (sin usar viñetas obvias de IA) los tres impactos estratégicos del tema. Habla de cómo se logra la Resiliencia, la Fluidez operativa, la Eficiencia financiera o la Anticipación ante el riesgo.
|
|
4311
|
-
5. EL CIERRE SUTIL (El CTA Elegante): En lugar de un llamado a la acción desesperado de ventas, cierra con una reflexión ejecutiva o una pregunta abierta que invite al lector a auditar mentalmente la madurez de su propia infraestructura. Una despedida que demuestre que, para orquestar la complejidad, se requiere la maestría de tres décadas.
|
|
4312
|
-
|
|
4313
|
-
Recuerda: Eres un experto hablando con otro experto. Sé denso en valor y conciso en palabras
|
|
4314
|
-
`;
|
|
4315
|
-
try {
|
|
4316
|
-
const ai = await this.geminiConfig();
|
|
4317
|
-
const result = await ai.models.generateContent({
|
|
4318
|
-
model: "gemini-2.5-pro",
|
|
4319
|
-
contents: promptArticulo,
|
|
4320
|
-
config: {
|
|
4321
|
-
responseMimeType: "application/json",
|
|
4322
|
-
temperature: temperatura,
|
|
4323
|
-
responseSchema: {
|
|
4324
|
-
type: "object",
|
|
4325
|
-
required: ["titulo", "descripcion", "content", "seo", "minute_read"],
|
|
4326
|
-
properties: {
|
|
4327
|
-
seo: {
|
|
4328
|
-
type: "object",
|
|
4329
|
-
required: ["metaTitle", "metaDescription", "metadata"],
|
|
4330
|
-
properties: {
|
|
4331
|
-
metaTitle: {
|
|
4332
|
-
type: "string"
|
|
4333
|
-
},
|
|
4334
|
-
metaDescription: {
|
|
4335
|
-
type: "string"
|
|
4336
|
-
},
|
|
4337
|
-
metadata: {
|
|
4338
|
-
type: "array",
|
|
4339
|
-
items: {
|
|
4340
|
-
type: "object",
|
|
4341
|
-
required: ["name", "content"],
|
|
4342
|
-
properties: {
|
|
4343
|
-
name: { type: "string" },
|
|
4344
|
-
content: { type: "string" }
|
|
4345
|
-
}
|
|
4346
|
-
}
|
|
4347
|
-
}
|
|
4348
|
-
}
|
|
4349
|
-
},
|
|
4350
|
-
titulo: {
|
|
4351
|
-
type: "string",
|
|
4352
|
-
minLength: 40,
|
|
4353
|
-
maxLength: 70,
|
|
4354
|
-
description: "Título del artículo"
|
|
4355
|
-
},
|
|
4356
|
-
descripcion: {
|
|
4357
|
-
type: "string",
|
|
4358
|
-
minLength: 80,
|
|
4359
|
-
maxLength: 160,
|
|
4360
|
-
description: "Descripción breve del artículo"
|
|
4361
|
-
},
|
|
4362
|
-
slug: {
|
|
4363
|
-
type: "string",
|
|
4364
|
-
minLength: 80,
|
|
4365
|
-
maxLength: 160,
|
|
4366
|
-
description: "URL-friendly basado en el título (ej: estrategias-migracion-nube)"
|
|
4367
|
-
},
|
|
4368
|
-
content: {
|
|
4369
|
-
type: "string",
|
|
4370
|
-
description: "Contenido HTML compatible con CKEditor"
|
|
4371
|
-
},
|
|
4372
|
-
minute_read: {
|
|
4373
|
-
type: "integer",
|
|
4374
|
-
minimum: 1,
|
|
4375
|
-
maximum: 30,
|
|
4376
|
-
description: "Tiempo de lectura calculado usando 200 palabras por minuto"
|
|
4377
|
-
},
|
|
4378
|
-
keywords: {
|
|
4379
|
-
type: "array",
|
|
4380
|
-
minItems: 3,
|
|
4381
|
-
maxItems: 5,
|
|
4382
|
-
items: {
|
|
4383
|
-
type: "object",
|
|
4384
|
-
required: ["name"],
|
|
4385
|
-
properties: {
|
|
4386
|
-
name: { type: "string" }
|
|
4387
|
-
}
|
|
4388
|
-
},
|
|
4389
|
-
description: "Hash tags y palabras clave para la publicación en LinkedIn y Facebook"
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
}
|
|
4393
|
-
}
|
|
4394
|
-
});
|
|
4395
|
-
const rawText = result.candidates?.[0]?.content?.parts?.[0]?.text ?? "";
|
|
4396
|
-
if (!rawText) {
|
|
4397
|
-
throw new Error(
|
|
4398
|
-
"La IA no generó texto. Revisa el prompt o el modelo."
|
|
4399
|
-
);
|
|
4400
|
-
}
|
|
4401
|
-
const parsed = JSON.parse(rawText);
|
|
4402
|
-
const article = await strapi.documents("api::articulo.articulo").create({
|
|
4403
|
-
data: {
|
|
4404
|
-
titulo: parsed.titulo,
|
|
4405
|
-
descripcion: parsed.descripcion,
|
|
4406
|
-
content: parsed.content,
|
|
4407
|
-
seo: parsed.seo,
|
|
4408
|
-
minute_read: parsed.minute_read,
|
|
4409
|
-
slug: parsed.slug,
|
|
4410
|
-
categoria,
|
|
4411
|
-
autor,
|
|
4412
|
-
image: null,
|
|
4413
|
-
keywords: parsed.keywords
|
|
4414
|
-
},
|
|
4415
|
-
status: "draft"
|
|
4416
|
-
});
|
|
4417
|
-
return article;
|
|
4418
|
-
} catch (err) {
|
|
4419
|
-
console.error("🚀 ~ generateArticle ~ err:", err);
|
|
4420
|
-
throw new Error(
|
|
4421
|
-
"Error al generar el artículo. Revisa el prompt, el modelo o el JSON generado."
|
|
4422
|
-
);
|
|
4423
|
-
}
|
|
4424
|
-
},
|
|
4425
|
-
// ───────────────────────────────
|
|
4426
|
-
// 🖼️ Generate Image for Article
|
|
4427
|
-
// ───────────────────────────────
|
|
4428
|
-
async generateImageForArticle(ctx) {
|
|
4429
|
-
const { articleId, aspectRatio, imageSize } = ctx.request.body;
|
|
4430
|
-
if (!articleId) {
|
|
4431
|
-
throw new Error(
|
|
4432
|
-
"Se requiere 'articleId' en el cuerpo de la petición."
|
|
4433
|
-
);
|
|
4434
|
-
}
|
|
4435
|
-
try {
|
|
4436
|
-
const article = await strapi.documents("api::articulo.articulo").findOne({
|
|
4437
|
-
documentId: articleId
|
|
4438
|
-
});
|
|
4439
|
-
const promptJson = {
|
|
4440
|
-
label: `blog-header-${articleId}`,
|
|
4441
|
-
task: "generate_image",
|
|
4442
|
-
canvas: {
|
|
4443
|
-
resolution: imageSize || "1K",
|
|
4444
|
-
aspect_ratio: aspectRatio || "16:9"
|
|
4445
|
-
},
|
|
4446
|
-
style: {
|
|
4447
|
-
type: "architectural software engineering visualization",
|
|
4448
|
-
aesthetic: "high-end technical 3D render / octane style",
|
|
4449
|
-
background: "view of a bright white minimalist architectural gallery, sun-drenched space, white polished floors and tall glass windows",
|
|
4450
|
-
lighting: "intense natural daylight, soft global illumination, clean diffused light with subtle volumetric rays from windows"
|
|
4451
|
-
},
|
|
4452
|
-
concept_brief: `Create a sophisticated 3D visualization that metaphorically represents the concept: "${article.titulo}" — ${article.descripcion}`,
|
|
4453
|
-
subject: [
|
|
4454
|
-
"a complex holographic or architectural 3D structure floating at the center of the gallery, inspired by the concept brief above",
|
|
4455
|
-
"materials: frosted glass panels, white matte ceramic components, and polished metal accents",
|
|
4456
|
-
"glowing energy connections and data filaments in red #E4002B and teal #00C7B1 connecting the structural elements",
|
|
4457
|
-
"the structure casts a sharp, clean reflection on the white polished gallery floor",
|
|
4458
|
-
"STRICTLY NO people, NO humans, NO hands, NO chairs",
|
|
4459
|
-
"STRICTLY NO text, NO labels, NO words, NO letters, NO numbers",
|
|
4460
|
-
"high-end 3D render, architectural photography style, 4k quality"
|
|
4461
|
-
],
|
|
4462
|
-
camera: {
|
|
4463
|
-
perspective: "three-quarter wide shot, slightly elevated, eye-level with the structure, showing both the subject and the gallery environment",
|
|
4464
|
-
depth_of_field: "the main structure in sharp focus, gallery background beautifully blurred"
|
|
4465
|
-
},
|
|
4466
|
-
render: {
|
|
4467
|
-
engine: "Octane or Cinema 4D",
|
|
4468
|
-
effects: "bloom on glowing filaments and energy elements, ray-traced reflections on the white polished floor, subsurface scattering on frosted glass panels, volumetric light rays from gallery windows",
|
|
4469
|
-
quality: "masterpiece, hyper-detailed"
|
|
4470
|
-
},
|
|
4471
|
-
output_format: "image/png"
|
|
4472
|
-
};
|
|
4473
|
-
const promptText = JSON.stringify(promptJson);
|
|
4474
|
-
const generatedBase64Image = await strapi.plugin("strapi-content-generator-gemini").service("image-studio").generateForArticle(promptText, aspectRatio || "16:9", imageSize || "1K");
|
|
4475
|
-
const buffer = Buffer.from(generatedBase64Image, "base64");
|
|
4476
|
-
const uploadedFile = await this._uploadGeneratedFile(buffer, `article-${articleId}.png`, "image/png");
|
|
4477
|
-
const articleModel = await strapi.getModel("api::articulo.articulo");
|
|
4478
|
-
const sanitizedData = await strapi.contentAPI.sanitize.input(
|
|
4479
|
-
{
|
|
4480
|
-
image: uploadedFile.id
|
|
4481
|
-
},
|
|
4482
|
-
articleModel
|
|
4483
|
-
);
|
|
4484
|
-
await strapi.documents("api::articulo.articulo").update({
|
|
4485
|
-
documentId: articleId,
|
|
4486
|
-
data: sanitizedData
|
|
4487
|
-
});
|
|
4488
|
-
return {
|
|
4489
|
-
message: "Imagen generada y asociada correctamente.",
|
|
4490
|
-
image: uploadedFile
|
|
4491
|
-
};
|
|
4492
|
-
} catch (err) {
|
|
4493
|
-
console.log("🚀 ~ service ~ err:", err);
|
|
4494
|
-
throw new Error("Error al generar la imagen para el artículo.");
|
|
4495
|
-
}
|
|
4496
|
-
},
|
|
4497
4701
|
// 🎞️ Internal Veo Video Generation / Extension Helper
|
|
4498
4702
|
async _callVeoVideoGeneration(promptText, aspectRatio, durationSeconds, sceneRefs, previousVideo) {
|
|
4499
4703
|
const { ai } = await this.geminiClient({ allowVertex: false });
|
|
@@ -4583,7 +4787,7 @@ const service = ({ strapi }) => {
|
|
|
4583
4787
|
// 🌐 Social Media Publishing
|
|
4584
4788
|
// ───────────────────────────────
|
|
4585
4789
|
async publishToLinkedIn(ctx) {
|
|
4586
|
-
const { articleId } = ctx.request.body;
|
|
4790
|
+
const { articleId, mensaje } = ctx.request.body;
|
|
4587
4791
|
const pluginStore = strapi.store({
|
|
4588
4792
|
type: "plugin",
|
|
4589
4793
|
name: "strapi-content-generator-gemini"
|
|
@@ -4598,7 +4802,6 @@ const service = ({ strapi }) => {
|
|
|
4598
4802
|
populate: ["image", "keywords"]
|
|
4599
4803
|
});
|
|
4600
4804
|
if (!article) throw new Error(`Artículo con ID ${articleId} no encontrado.`);
|
|
4601
|
-
const hashtags = article.keywords.map((k) => `#${k.name.trim().replace(/\s+/g, "").replace(/[^\w]/g, "")}`).join(" ");
|
|
4602
4805
|
const articleUrl = `https://interware.com.mx/blog/${article.slug}`;
|
|
4603
4806
|
const imageUrl = article.image?.url;
|
|
4604
4807
|
if (!imageUrl) throw new Error("El artículo no tiene imagen.");
|
|
@@ -4633,9 +4836,7 @@ const service = ({ strapi }) => {
|
|
|
4633
4836
|
});
|
|
4634
4837
|
const postBody = {
|
|
4635
4838
|
author: `urn:li:organization:${linkedInOrganizationId}`,
|
|
4636
|
-
commentary:
|
|
4637
|
-
|
|
4638
|
-
${hashtags}`,
|
|
4839
|
+
commentary: typeof mensaje === "string" && mensaje.trim() || defaultPostText(postData(article), "linkedin"),
|
|
4639
4840
|
visibility: "PUBLIC",
|
|
4640
4841
|
distribution: {
|
|
4641
4842
|
feedDistribution: "MAIN_FEED",
|
|
@@ -4673,7 +4874,7 @@ ${hashtags}`,
|
|
|
4673
4874
|
}
|
|
4674
4875
|
},
|
|
4675
4876
|
async publishToFacebook(ctx) {
|
|
4676
|
-
const { articleId } = ctx.request.body;
|
|
4877
|
+
const { articleId, mensaje } = ctx.request.body;
|
|
4677
4878
|
const pluginStore = strapi.store({
|
|
4678
4879
|
type: "plugin",
|
|
4679
4880
|
name: "strapi-content-generator-gemini"
|
|
@@ -4702,16 +4903,8 @@ ${hashtags}`,
|
|
|
4702
4903
|
throw new Error(`Artículo con ID ${articleId} no encontrado.`);
|
|
4703
4904
|
}
|
|
4704
4905
|
const articleUrl = `https://interware.com.mx/blog/${article.slug}`;
|
|
4705
|
-
const hashtags = article.keywords.map(
|
|
4706
|
-
(keyword) => `#${keyword.name.trim().replace(/\s+/g, "").replace(/[^\w]/g, "")}`
|
|
4707
|
-
// quita caracteres raros
|
|
4708
|
-
).join(" ");
|
|
4709
4906
|
const postBody = {
|
|
4710
|
-
message:
|
|
4711
|
-
|
|
4712
|
-
${article.descripcion}
|
|
4713
|
-
|
|
4714
|
-
${hashtags}`,
|
|
4907
|
+
message: typeof mensaje === "string" && mensaje.trim() || defaultPostText(postData(article), "facebook"),
|
|
4715
4908
|
link: articleUrl,
|
|
4716
4909
|
access_token: facebookAccessToken
|
|
4717
4910
|
};
|
|
@@ -4748,7 +4941,8 @@ ${hashtags}`,
|
|
|
4748
4941
|
const services = {
|
|
4749
4942
|
service,
|
|
4750
4943
|
"image-studio": imageStudio$1,
|
|
4751
|
-
templates: templates$1
|
|
4944
|
+
templates: templates$1,
|
|
4945
|
+
articles: articles$1
|
|
4752
4946
|
};
|
|
4753
4947
|
const index = {
|
|
4754
4948
|
register,
|