@roilab/crm-cli 0.23.0 → 0.25.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/CHANGELOG.md +76 -0
- package/LICENSE +21 -21
- package/README.md +197 -197
- package/SKILL.md +60 -3
- package/SURFACE.txt +38 -1
- package/dist/bin/crm.js +4 -0
- package/dist/bin/crm.js.map +1 -1
- package/dist/src/commands/credential.js +138 -0
- package/dist/src/commands/credential.js.map +1 -0
- package/dist/src/commands/guide.js +57 -0
- package/dist/src/commands/guide.js.map +1 -0
- package/dist/src/commands/marketplace.js +158 -0
- package/dist/src/commands/marketplace.js.map +1 -0
- package/dist/src/commands/site.js +120 -1
- package/dist/src/commands/site.js.map +1 -1
- package/dist/src/transport/run.js +20 -0
- package/dist/src/transport/run.js.map +1 -1
- package/package.json +1 -1
- package/skill-bundles/tools/ahrefs-tool/SKILL.md +5 -5
- package/skill-bundles/tools/brightlocal-tool/SKILL.md +5 -5
- package/skill-bundles/tools/dataforseo-tool/SKILL.md +5 -5
- package/skill-bundles/tools/google-analytics-tool/SKILL.md +5 -5
- package/skill-bundles/tools/google-search-console-tool/SKILL.md +5 -5
- package/skill-bundles/tools/local-falcon-tool/SKILL.md +5 -5
- package/skill-bundles/tools/localseodata-tool/SKILL.md +5 -5
- package/skill-bundles/tools/lsa-spy-tool/SKILL.md +5 -5
- package/skill-bundles/tools/screaming-frog-tool/SKILL.md +5 -5
- package/skill-bundles/tools/semrush-tool/SKILL.md +5 -5
- package/skill-bundles/tools/serpapi-tool/SKILL.md +5 -5
- package/skill-bundles/tools/task-preflight/SKILL.md +157 -157
- package/skill-bundles/tools/whitespark-tool/SKILL.md +5 -5
package/SURFACE.txt
CHANGED
|
@@ -259,9 +259,40 @@ CMD crm site update --task <id> --url <url> --ref <tipo:id> --connection <id> --
|
|
|
259
259
|
# Ventas reales de la tienda (PrestaShop), sumadas cada noche: de una ficha o
|
|
260
260
|
# categoría (28 y 90 días con interanual, puesto en su categoría o top 10 de
|
|
261
261
|
# la categoría) o ranking de fichas por facturación. Pedidos válidos y no
|
|
262
|
-
# cancelados de la tienda e idioma de la conexión; sin IVA
|
|
262
|
+
# cancelados de la tienda e idioma de la conexión; sin IVA, en la moneda de
|
|
263
|
+
# la tienda.
|
|
263
264
|
CMD crm site sales --url <url> --ref <product|category:id> --connection <id>
|
|
264
265
|
CMD crm site sales --top <n> --category <id> --days <28|90|365> --connection <id>
|
|
266
|
+
# Stock real de la tienda, leído en el momento (solo lectura). Ficha: total y
|
|
267
|
+
# por combinación, con cuántas están agotadas. Categoría: fichas activas con
|
|
268
|
+
# su stock y sus combinaciones (cuántas y cuántas agotadas), primero las
|
|
269
|
+
# agotadas (las que más venden arriba), con ventas de 90 días; el resumen
|
|
270
|
+
# cuenta las fichas con stock que tienen algún pack agotado. Solo en tiendas
|
|
271
|
+
# con el stock activado en la conexión (growbaratochile.cl).
|
|
272
|
+
CMD crm site stock --url <url> --ref <product|category:id> --connection <id> --agotados --combinaciones-agotadas --combinaciones --inactivos
|
|
273
|
+
# Redirecciones 301 del blog (WordPress, mu-plugin roilab-seo-rest 1.2.0), sin
|
|
274
|
+
# plugin de redirecciones ni .htaccess. Entrada publicada → entrada publicada:
|
|
275
|
+
# fusión (el origen a la papelera y WordPress responde 301 por su slug
|
|
276
|
+
# antiguo). Lo demás (páginas, categorías, URLs que ya no existen, destino en
|
|
277
|
+
# la tienda): por ruta, y el origen publicado a la papelera. Destino del mismo
|
|
278
|
+
# dominio, 200 y sin noindex (si no, bloquea); después comprueba el 301 y lo
|
|
279
|
+
# registra en la tarea. La tienda (PrestaShop) sigue por .htaccess.
|
|
280
|
+
CMD crm site redirect list --url <url> --connection <id>
|
|
281
|
+
CMD crm site redirect create --task <id> --from <url> --to <url> --connection <id> --note <t> --note-file <path> --dry-run
|
|
282
|
+
CMD crm site redirect delete --task <id> --from <url> --connection <id> --note <t> --dry-run
|
|
283
|
+
|
|
284
|
+
# credential — accesos de un cliente (usuario + contraseña de una plataforma).
|
|
285
|
+
# list nunca devuelve la contraseña. Para usarla, pídela: le llega un aviso a
|
|
286
|
+
# la persona dueña de la clave, que la aprueba en el CRM (solo si ella tiene
|
|
287
|
+
# acceso). Aprobada, se puede leer durante 15 min; cada lectura se registra.
|
|
288
|
+
# Pregunta siempre antes de usar una contraseña y no la copies en ningún sitio.
|
|
289
|
+
CMD crm credential list --client <id> --task <id>
|
|
290
|
+
# Alta: la contraseña por stdin o fichero, nunca como argumento. Úsalo al crear
|
|
291
|
+
# una cuenta o para sacar una contraseña de un comentario.
|
|
292
|
+
CMD crm credential create --label <text> --client <id> --task <id> --url <url> --username <text> --password-stdin --password-file <path> --notes <text>
|
|
293
|
+
CMD crm credential link <credential-id> --task <id>
|
|
294
|
+
CMD crm credential request <credential-id> --task <id> --reason <text> --wait
|
|
295
|
+
CMD crm credential fetch <request-id> --wait
|
|
265
296
|
|
|
266
297
|
CMD crm scope list --domain <id> --kind <saved|ephemeral>
|
|
267
298
|
CMD crm scope get <id>
|
|
@@ -384,6 +415,12 @@ CMD crm skill review list
|
|
|
384
415
|
CMD crm skill review approve <id>
|
|
385
416
|
CMD crm skill review reject <id> --reason <text>
|
|
386
417
|
|
|
418
|
+
# Guías de trabajo — biblioteca /dashboard/guias (internas y de clientes).
|
|
419
|
+
# Solo lectura y solo staff; leerlas aquí no las marca como leídas.
|
|
420
|
+
# El markdown va en data.body: `crm guide get <slug> --jq .data.body`.
|
|
421
|
+
CMD crm guide list --q <text> --area <name> --status <draft|published|archived>
|
|
422
|
+
CMD crm guide get <slug> --draft
|
|
423
|
+
|
|
387
424
|
# Documentos de trabajo de cliente — procesos en markdown editables por IA.
|
|
388
425
|
# Anclados a un cliente; internos por defecto, opt-in a cliente con `share`.
|
|
389
426
|
# Cuerpos largos/markdown SIEMPRE por `--body-file` (no `--body "$(cat)"`).
|
package/dist/bin/crm.js
CHANGED
|
@@ -21,6 +21,7 @@ import { registerIntegrations } from "../src/commands/integrations.js";
|
|
|
21
21
|
import { registerMerchant } from "../src/commands/merchant.js";
|
|
22
22
|
import { registerSkill } from "../src/commands/skill.js";
|
|
23
23
|
import { registerDoc } from "../src/commands/doc.js";
|
|
24
|
+
import { registerGuide } from "../src/commands/guide.js";
|
|
24
25
|
import { registerBrief } from "../src/commands/brief.js";
|
|
25
26
|
import { registerMention } from "../src/commands/mention.js";
|
|
26
27
|
import { registerTime } from "../src/commands/time.js";
|
|
@@ -28,6 +29,7 @@ import { registerRank } from "../src/commands/rank.js";
|
|
|
28
29
|
import { registerMeta } from "../src/commands/meta.js";
|
|
29
30
|
import { registerReport } from "../src/commands/report.js";
|
|
30
31
|
import { registerSite } from "../src/commands/site.js";
|
|
32
|
+
import { registerCredential } from "../src/commands/credential.js";
|
|
31
33
|
import { registerUpdate } from "../src/commands/update.js";
|
|
32
34
|
import { maybeNudgeFromCache, readInstalledVersion, refreshCacheInBackground, } from "../src/utils/version-check.js";
|
|
33
35
|
import { installUsageEnvelope, handleTopLevelError } from "../src/transport/usage.js";
|
|
@@ -57,11 +59,13 @@ registerIntegrations(program);
|
|
|
57
59
|
registerMerchant(program);
|
|
58
60
|
registerSkill(program);
|
|
59
61
|
registerDoc(program);
|
|
62
|
+
registerGuide(program);
|
|
60
63
|
registerTime(program);
|
|
61
64
|
registerRank(program);
|
|
62
65
|
registerMeta(program);
|
|
63
66
|
registerReport(program);
|
|
64
67
|
registerSite(program);
|
|
68
|
+
registerCredential(program);
|
|
65
69
|
registerCommands(program);
|
|
66
70
|
registerDoctor(program);
|
|
67
71
|
registerUpdate(program);
|
package/dist/bin/crm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crm.js","sourceRoot":"","sources":["../../bin/crm.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,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zB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC1B,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,WAAW,CAAC,OAAO,CAAC,CAAC;AACrB,aAAa,CAAC,OAAO,CAAC,CAAC;AACvB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,YAAY,CAAC,OAAO,CAAC,CAAC;AACtB,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5B,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAC1B,cAAc,CAAC,OAAO,CAAC,CAAC;AACxB,cAAc,CAAC,OAAO,CAAC,CAAC;AAExB,8EAA8E;AAC9E,6DAA6D;AAC7D,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAE9B,iFAAiF;AACjF,mBAAmB,EAAE,CAAC;AACtB,8EAA8E;AAC9E,0EAA0E;AAC1E,+BAA+B;AAC/B,wBAAwB,EAAE,CAAC;AAE3B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `crm credential` — accesos de un cliente (usuario + contraseña).
|
|
3
|
+
*
|
|
4
|
+
* - `list` accesos de un cliente o de una tarea. Nunca la contraseña.
|
|
5
|
+
* - `create` guarda un acceso nuevo; la contraseña entra por stdin o por
|
|
6
|
+
* fichero, nunca como argumento (quedaría en el historial).
|
|
7
|
+
* - `link` enlaza un acceso del cliente a una tarea.
|
|
8
|
+
* - `request` pide la contraseña. No llega hasta que la persona dueña de
|
|
9
|
+
* la clave la apruebe en el CRM; con `--wait` espera y la trae.
|
|
10
|
+
* - `fetch` estado de una petición y, si está aprobada (15 min), la
|
|
11
|
+
* contraseña.
|
|
12
|
+
*
|
|
13
|
+
* Pregunta siempre antes de usar una contraseña y no la copies en ficheros,
|
|
14
|
+
* tareas ni comentarios. Cada lectura queda registrada.
|
|
15
|
+
*/
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { run } from "../transport/run.js";
|
|
18
|
+
import { outputFromFlags, readFlags } from "./options.js";
|
|
19
|
+
function usageError(message) {
|
|
20
|
+
process.stderr.write(`error: ${message}\n`);
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
export function registerCredential(program) {
|
|
24
|
+
const credential = program
|
|
25
|
+
.command("credential")
|
|
26
|
+
.description("Accesos de un cliente (usuario y contraseña). La contraseña solo llega con la aprobación de una persona");
|
|
27
|
+
credential
|
|
28
|
+
.command("list")
|
|
29
|
+
.description("Accesos de un cliente o los enlazados a una tarea: nombre, URL de acceso, usuario y notas. Nunca la contraseña")
|
|
30
|
+
.option("--client <id>", "accesos de este cliente")
|
|
31
|
+
.option("--task <id>", "o los enlazados a esta tarea")
|
|
32
|
+
.action(async (opts, cmd) => {
|
|
33
|
+
const flags = readFlags(cmd);
|
|
34
|
+
if (!opts.client && !opts.task)
|
|
35
|
+
usageError("indica --client o --task");
|
|
36
|
+
await run({
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: "/credentials",
|
|
39
|
+
request: { query: { clientId: opts.client, taskId: opts.task } },
|
|
40
|
+
output: outputFromFlags(flags),
|
|
41
|
+
profile: flags.profile,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
credential
|
|
45
|
+
.command("create")
|
|
46
|
+
.description("Guarda un acceso nuevo del cliente (o del cliente de la tarea, que queda enlazada). " +
|
|
47
|
+
"La contraseña entra por stdin (--password-stdin) o por fichero (--password-file), nunca como argumento")
|
|
48
|
+
.requiredOption("--label <text>", "nombre visible (plataforma y cuenta)")
|
|
49
|
+
.option("--client <id>", "cliente del acceso")
|
|
50
|
+
.option("--task <id>", "o la tarea: toma su cliente y la enlaza")
|
|
51
|
+
.option("--url <url>", "URL de inicio de sesión")
|
|
52
|
+
.option("--username <text>", "usuario o email")
|
|
53
|
+
.option("--password-stdin", "lee la contraseña de la entrada estándar")
|
|
54
|
+
.option("--password-file <path>", "lee la contraseña de un fichero (UTF-8)")
|
|
55
|
+
.option("--notes <text>", "notas: doble factor, quién la creó…")
|
|
56
|
+
.action(async (opts, cmd) => {
|
|
57
|
+
const flags = readFlags(cmd);
|
|
58
|
+
if (!opts.client && !opts.task)
|
|
59
|
+
usageError("indica --client o --task");
|
|
60
|
+
if (!!opts.passwordStdin === !!opts.passwordFile)
|
|
61
|
+
usageError("indica --password-stdin o --password-file (uno de los dos)");
|
|
62
|
+
let password;
|
|
63
|
+
try {
|
|
64
|
+
password = readFileSync(opts.passwordStdin ? 0 : opts.passwordFile, "utf8").replace(/^\uFEFF/, "").replace(/\r?\n$/, "");
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
usageError(`no se pudo leer la contraseña: ${err instanceof Error ? err.message : String(err)}`);
|
|
68
|
+
}
|
|
69
|
+
if (!password)
|
|
70
|
+
usageError("la contraseña está vacía");
|
|
71
|
+
await run({
|
|
72
|
+
method: "POST",
|
|
73
|
+
path: "/credentials",
|
|
74
|
+
request: {
|
|
75
|
+
body: { clientId: opts.client, taskId: opts.task, label: opts.label, loginUrl: opts.url, username: opts.username, password, notes: opts.notes },
|
|
76
|
+
idempotencyKey: flags.idempotencyKey,
|
|
77
|
+
},
|
|
78
|
+
output: outputFromFlags(flags),
|
|
79
|
+
profile: flags.profile,
|
|
80
|
+
asAgent: flags.asAgent,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
credential
|
|
84
|
+
.command("link")
|
|
85
|
+
.description("Enlaza un acceso del cliente a una tarea del mismo cliente")
|
|
86
|
+
.argument("<credential-id>", "id del acceso (crm credential list)")
|
|
87
|
+
.requiredOption("--task <id>", "tarea a la que se enlaza")
|
|
88
|
+
.action(async (id, opts, cmd) => {
|
|
89
|
+
const flags = readFlags(cmd);
|
|
90
|
+
await run({
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: `/credentials/${encodeURIComponent(id)}/tasks`,
|
|
93
|
+
request: { body: { taskId: opts.task }, idempotencyKey: flags.idempotencyKey },
|
|
94
|
+
output: outputFromFlags(flags),
|
|
95
|
+
profile: flags.profile,
|
|
96
|
+
asAgent: flags.asAgent,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
credential
|
|
100
|
+
.command("request")
|
|
101
|
+
.description("Pide la contraseña de un acceso. Le llega un aviso a la persona dueña de la clave, que la aprueba o rechaza en el CRM. " +
|
|
102
|
+
"Con --wait espera la decisión (máximo 10 min) y devuelve la contraseña si se aprueba")
|
|
103
|
+
.argument("<credential-id>", "id del acceso (crm credential list)")
|
|
104
|
+
.option("--task <id>", "tarea para la que la necesitas")
|
|
105
|
+
.option("--reason <text>", "para qué la necesitas (lo ve quien aprueba)")
|
|
106
|
+
.option("--wait", "espera a la aprobación y devuelve la contraseña")
|
|
107
|
+
.action(async (id, opts, cmd) => {
|
|
108
|
+
const flags = readFlags(cmd);
|
|
109
|
+
await run({
|
|
110
|
+
method: "POST",
|
|
111
|
+
path: `/credentials/${encodeURIComponent(id)}/requests`,
|
|
112
|
+
request: { body: { taskId: opts.task, reason: opts.reason }, idempotencyKey: flags.idempotencyKey },
|
|
113
|
+
output: outputFromFlags(flags),
|
|
114
|
+
profile: flags.profile,
|
|
115
|
+
asAgent: flags.asAgent,
|
|
116
|
+
waitWhilePending: opts.wait
|
|
117
|
+
? { followPath: (data) => `/credentials/requests/${encodeURIComponent(String(data.requestId))}` }
|
|
118
|
+
: undefined,
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
credential
|
|
122
|
+
.command("fetch")
|
|
123
|
+
.description("Estado de una petición de contraseña; si está aprobada (15 min desde la aprobación) incluye usuario y contraseña")
|
|
124
|
+
.argument("<request-id>", "id de la petición (requestId)")
|
|
125
|
+
.option("--wait", "si sigue pendiente, espera a la decisión (máximo 10 min)")
|
|
126
|
+
.action(async (id, opts, cmd) => {
|
|
127
|
+
const flags = readFlags(cmd);
|
|
128
|
+
const path = `/credentials/requests/${encodeURIComponent(id)}`;
|
|
129
|
+
await run({
|
|
130
|
+
method: "GET",
|
|
131
|
+
path,
|
|
132
|
+
output: outputFromFlags(flags),
|
|
133
|
+
profile: flags.profile,
|
|
134
|
+
waitWhilePending: opts.wait ? { followPath: path } : undefined,
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../../src/commands/credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,OAAO,IAAI,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,UAAU,GAAG,OAAO;SACvB,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,yGAAyG,CAAC,CAAC;IAE1H,UAAU;SACP,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,gHAAgH,CAAC;SAC7H,MAAM,CAAC,eAAe,EAAE,yBAAyB,CAAC;SAClD,MAAM,CAAC,aAAa,EAAE,8BAA8B,CAAC;SACrD,MAAM,CAAC,KAAK,EAAE,I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,EAAE;YACnG,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,gBAAgB,EAAE,IAAI,CAAC,IAAI;gBACzB,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,kBAAkB,CAAC,MAAM,CAAE,IAA8B,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE;gBAC5H,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,UAAU;SACP,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,kHAAkH,CAAC;SAC/H,QAAQ,CAAC,cAAc,EAAE,+BAA+B,CAAC;SACzD,MAAM,CAAC,QAAQ,EAAE,0DAA0D,CAAC;SAC5E,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,IAAwB,EAAE,GAAY,EAAE,EAAE;QACnE,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,IAAI,GAAG,yBAAyB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;QAC/D,MAAM,GAAG,CAAC;YACR,MAAM,EAAE,KAAK;YACb,IAAI;YACJ,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,gBAAgB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS;SAC/D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `crm guide` — guías de trabajo de la biblioteca `/dashboard/guias`.
|
|
3
|
+
*
|
|
4
|
+
* Solo lectura y solo staff (scope `guides:read`): las internas de Roilab, las
|
|
5
|
+
* de todos los clientes y las de clientes concretos, con el mismo filtro que
|
|
6
|
+
* el web (un member ve las de sus clientes). Leer por aquí no marca la guía
|
|
7
|
+
* como leída para nadie.
|
|
8
|
+
*
|
|
9
|
+
* crm guide list [--q <text>] [--area <name>] [--status draft|published|archived]
|
|
10
|
+
* crm guide get <slug> [--draft]
|
|
11
|
+
*
|
|
12
|
+
* El markdown va en `data.body`; para sacarlo tal cual: `crm guide get <slug> --jq .data.body`.
|
|
13
|
+
*/
|
|
14
|
+
import { run } from "../transport/run.js";
|
|
15
|
+
import { outputFromFlags, readFlags } from "./options.js";
|
|
16
|
+
const GUIDE_STATUSES = ["draft", "published", "archived"];
|
|
17
|
+
export function registerGuide(program) {
|
|
18
|
+
const guide = program
|
|
19
|
+
.command("guide")
|
|
20
|
+
.description("Guías de trabajo (biblioteca /dashboard/guias): internas y de clientes. Solo lectura");
|
|
21
|
+
guide
|
|
22
|
+
.command("list")
|
|
23
|
+
.description("Lista las guías que puedes leer (sin el texto). Las archivadas solo con --status archived")
|
|
24
|
+
.option("--q <text>", "busca en título, resumen y texto (sin tildes, ≥2 caracteres)")
|
|
25
|
+
.option("--area <name>", "área de la biblioteca, coincidencia parcial (p. ej. contenido)")
|
|
26
|
+
.option("--status <name>", `filtra por estado: ${GUIDE_STATUSES.join(" | ")}`)
|
|
27
|
+
.action(async (opts, cmd) => {
|
|
28
|
+
if (opts.status !== undefined && !GUIDE_STATUSES.includes(opts.status)) {
|
|
29
|
+
process.stderr.write(`error: --status debe ser uno de ${GUIDE_STATUSES.join(", ")}\n`);
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
const flags = readFlags(cmd);
|
|
33
|
+
await run({
|
|
34
|
+
method: "GET",
|
|
35
|
+
path: "/guides",
|
|
36
|
+
request: { query: { q: opts.q, area: opts.area, status: opts.status } },
|
|
37
|
+
output: outputFromFlags(flags),
|
|
38
|
+
profile: flags.profile,
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
guide
|
|
42
|
+
.command("get")
|
|
43
|
+
.description("Lee una guía: metadatos y texto en markdown (data.body). Por defecto la versión publicada")
|
|
44
|
+
.argument("<slug>", "slug de la guía (el final de su URL)")
|
|
45
|
+
.option("--draft", "devuelve el borrador actual en vez de la versión publicada")
|
|
46
|
+
.action(async (slug, opts, cmd) => {
|
|
47
|
+
const flags = readFlags(cmd);
|
|
48
|
+
await run({
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: `/guides/${encodeURIComponent(slug)}`,
|
|
51
|
+
request: { query: { draft: opts.draft ? "true" : undefined } },
|
|
52
|
+
output: outputFromFlags(flags),
|
|
53
|
+
profile: flags.profile,
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=guide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide.js","sourceRoot":"","sources":["../../../src/commands/guide.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAE1D,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,MAAM,KAAK,GAAG,OAAO;SAClB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,sFAAsF,CAAC,CAAC;IAEvG,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,2FAA2F,CAAC;SACxG,MAAM,CAAC,YAAY,EAAE,8DAA8D,CAAC;SACpF,MAAM,CAAC,eAAe,EAAE,gEAAgE,CAAC;SACzF,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;SAC7E,MAAM,CAAC,KAAK,EAAE,IAAoD,EAAE,GAAY,EAAE,EAAE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AAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `crm marketplace` — comparador de precios de backlinks entre proveedores.
|
|
3
|
+
*
|
|
4
|
+
* Surface:
|
|
5
|
+
* compare compara precios por dominio (min/max/spread/mejor proveedor)
|
|
6
|
+
* domain precios de un dominio concreto en todos los proveedores
|
|
7
|
+
* providers estado de sincronización + credenciales por proveedor
|
|
8
|
+
* import importa listados de un proveedor (CSV/stdin: url,precio[,divisa])
|
|
9
|
+
* scrape encola un scraping bajo demanda (proveedores con scraper)
|
|
10
|
+
*
|
|
11
|
+
* Agency-only: el servidor rechaza llamadas de roles cliente. Las escrituras
|
|
12
|
+
* pasan por el gateway (idempotentes + atribuidas) — el CLI autogenera la
|
|
13
|
+
* Idempotency-Key igual que el resto de comandos.
|
|
14
|
+
*/
|
|
15
|
+
import { readFileSync } from "node:fs";
|
|
16
|
+
import { run } from "../transport/run.js";
|
|
17
|
+
import { outputFromFlags, readFlags } from "./options.js";
|
|
18
|
+
async function readStdin() {
|
|
19
|
+
if (process.stdin.isTTY)
|
|
20
|
+
return "";
|
|
21
|
+
const chunks = [];
|
|
22
|
+
for await (const chunk of process.stdin)
|
|
23
|
+
chunks.push(Buffer.from(chunk));
|
|
24
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
25
|
+
}
|
|
26
|
+
/** Parse `url, price[, currency][, link_type]` lines (comma- or tab-separated). */
|
|
27
|
+
function parseImportRows(raw) {
|
|
28
|
+
return raw
|
|
29
|
+
.split("\n")
|
|
30
|
+
.map((l) => l.trim())
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.map((line) => {
|
|
33
|
+
const parts = line.split(/[\t,]/).map((p) => p.trim());
|
|
34
|
+
return {
|
|
35
|
+
url: parts[0] ?? "",
|
|
36
|
+
price: parts[1] ?? "",
|
|
37
|
+
currency: parts[2] || undefined,
|
|
38
|
+
linkType: parts[3] || undefined,
|
|
39
|
+
};
|
|
40
|
+
})
|
|
41
|
+
.filter((r) => r.url && r.price);
|
|
42
|
+
}
|
|
43
|
+
export function registerMarketplace(program) {
|
|
44
|
+
const mp = program
|
|
45
|
+
.command("marketplace")
|
|
46
|
+
.description("Comparador de mercados de backlinks — precios por dominio entre proveedores");
|
|
47
|
+
mp
|
|
48
|
+
.command("compare")
|
|
49
|
+
.description("Compara precios por dominio (ordenado por mayor ahorro). Filtros opcionales.")
|
|
50
|
+
.option("--search <text>", "substring sobre dominio o título")
|
|
51
|
+
.option("--provider <id>", "restringir a un proveedor")
|
|
52
|
+
.option("--country <iso2>", "ISO-2 país")
|
|
53
|
+
.option("--min-dr <n>", "DR mínimo de Ahrefs", (v) => Number(v))
|
|
54
|
+
.option("--max-price <eur>", "precio máximo en euros", (v) => Number(v))
|
|
55
|
+
.option("--in-stock", "solo listados disponibles")
|
|
56
|
+
.action(async (opts, cmd) => {
|
|
57
|
+
const flags = readFlags(cmd);
|
|
58
|
+
await run({
|
|
59
|
+
method: "GET",
|
|
60
|
+
path: "/marketplace/compare",
|
|
61
|
+
request: {
|
|
62
|
+
query: {
|
|
63
|
+
search: opts.search,
|
|
64
|
+
provider: opts.provider,
|
|
65
|
+
country: opts.country,
|
|
66
|
+
minDr: opts.minDr,
|
|
67
|
+
maxPriceCents: opts.maxPrice != null ? Math.round(opts.maxPrice * 100) : undefined,
|
|
68
|
+
inStockOnly: opts.inStock,
|
|
69
|
+
limit: flags.limit,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
output: outputFromFlags(flags),
|
|
73
|
+
profile: flags.profile,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
mp
|
|
77
|
+
.command("domain")
|
|
78
|
+
.description("Precios de mercado de un dominio en todos los proveedores")
|
|
79
|
+
.argument("<rootDomain>", "dominio raíz normalizado (ej. ejemplo.com)")
|
|
80
|
+
.action(async (rootDomain, _opts, cmd) => {
|
|
81
|
+
const flags = readFlags(cmd);
|
|
82
|
+
await run({
|
|
83
|
+
method: "GET",
|
|
84
|
+
path: `/marketplace/domain/${encodeURIComponent(rootDomain)}`,
|
|
85
|
+
output: outputFromFlags(flags),
|
|
86
|
+
profile: flags.profile,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
mp
|
|
90
|
+
.command("providers")
|
|
91
|
+
.description("Estado de sincronización + credenciales por proveedor")
|
|
92
|
+
.action(async (_opts, cmd) => {
|
|
93
|
+
const flags = readFlags(cmd);
|
|
94
|
+
await run({
|
|
95
|
+
method: "GET",
|
|
96
|
+
path: "/marketplace/providers",
|
|
97
|
+
output: outputFromFlags(flags),
|
|
98
|
+
profile: flags.profile,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
mp
|
|
102
|
+
.command("import")
|
|
103
|
+
.description("Importa listados de un proveedor. Filas: 'url, precio[, divisa][, dofollow/nofollow]' por --file o stdin.")
|
|
104
|
+
.requiredOption("--provider <id>", "proveedor (ej. publisuites, ereferer)")
|
|
105
|
+
.option("--file <path>", "fichero con las filas")
|
|
106
|
+
.option("--stdin", "leer filas de stdin")
|
|
107
|
+
.action(async (opts, cmd) => {
|
|
108
|
+
const flags = readFlags(cmd);
|
|
109
|
+
let raw = "";
|
|
110
|
+
if (opts.file) {
|
|
111
|
+
try {
|
|
112
|
+
raw = readFileSync(opts.file, "utf8");
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
process.stderr.write(`error: no se pudo leer ${opts.file}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
116
|
+
process.exit(2);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else if (opts.stdin) {
|
|
120
|
+
raw = await readStdin();
|
|
121
|
+
}
|
|
122
|
+
const rows = parseImportRows(raw);
|
|
123
|
+
if (rows.length === 0) {
|
|
124
|
+
process.stderr.write("error: no hay filas válidas (formato: 'url, precio[, divisa][, tipo]')\n");
|
|
125
|
+
process.exit(2);
|
|
126
|
+
}
|
|
127
|
+
await run({
|
|
128
|
+
method: "POST",
|
|
129
|
+
path: "/marketplace/import",
|
|
130
|
+
request: {
|
|
131
|
+
body: { provider: opts.provider, rows },
|
|
132
|
+
idempotencyKey: flags.idempotencyKey,
|
|
133
|
+
},
|
|
134
|
+
output: outputFromFlags(flags),
|
|
135
|
+
profile: flags.profile,
|
|
136
|
+
asAgent: flags.asAgent,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
mp
|
|
140
|
+
.command("scrape")
|
|
141
|
+
.description("Encola un scraping bajo demanda para un proveedor con scraper")
|
|
142
|
+
.requiredOption("--provider <id>", "proveedor con scraper")
|
|
143
|
+
.action(async (opts, cmd) => {
|
|
144
|
+
const flags = readFlags(cmd);
|
|
145
|
+
await run({
|
|
146
|
+
method: "POST",
|
|
147
|
+
path: "/marketplace/scrape",
|
|
148
|
+
request: {
|
|
149
|
+
body: { provider: opts.provider },
|
|
150
|
+
idempotencyKey: flags.idempotencyKey,
|
|
151
|
+
},
|
|
152
|
+
output: outputFromFlags(flags),
|
|
153
|
+
profile: flags.profile,
|
|
154
|
+
asAgent: flags.asAgent,
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=marketplace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketplace.js","sourceRoot":"","sources":["../../../src/commands/marketplace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,KAAK,UAAU,SAAS;IACtB,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,MAAM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C;QAC7B,MAAM,GAAG,CAAC;YACR,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;gBACjC,cAAc,EAAE,KAAK,CAAC,cAAc;aACrC;YACD,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* `--allow-noindex` y enseña antes los clics de la URL.
|
|
13
13
|
* - `sales` ventas reales de la tienda (PrestaShop) por ficha o categoría,
|
|
14
14
|
* o el ranking de fichas que más facturan, para decidir con dinero.
|
|
15
|
+
* - `redirect create|list|delete` redirecciones 301 del blog (WordPress)
|
|
16
|
+
* con el mu-plugin roilab-seo-rest 1.2.0, sin plugin ni .htaccess.
|
|
15
17
|
*
|
|
16
18
|
* Los textos largos o con acentos (contenido HTML, metas) entran por fichero
|
|
17
19
|
* (`--content-file`, `--meta-title-file`…): en Windows los argumentos con
|
|
@@ -163,7 +165,7 @@ export function registerSite(program) {
|
|
|
163
165
|
.command("sales")
|
|
164
166
|
.description("Ventas reales de la tienda (PrestaShop), sumadas cada noche: de una ficha o categoría (28 y 90 días con interanual, " +
|
|
165
167
|
"puesto en su categoría o sus 10 fichas que más venden) o el ranking de fichas por facturación (--top). " +
|
|
166
|
-
"Para decidir con dinero usa esto, nunca
|
|
168
|
+
"Para decidir con dinero usa esto, nunca la facturación de Analytics")
|
|
167
169
|
.option("--url <url>", "URL de una ficha o categoría de la tienda")
|
|
168
170
|
.option("--ref <tipo:id>", "en vez de la URL: product:<id> o category:<id>")
|
|
169
171
|
.option("--connection <id>", "la tienda (crm site list); obligatoria con --ref o --top si tienes varias")
|
|
@@ -200,6 +202,42 @@ export function registerSite(program) {
|
|
|
200
202
|
profile: flags.profile,
|
|
201
203
|
});
|
|
202
204
|
});
|
|
205
|
+
site
|
|
206
|
+
.command("stock")
|
|
207
|
+
.description("Stock real de la tienda (PrestaShop), leído en el momento: de una ficha, unidades totales y por combinación; " +
|
|
208
|
+
"de una categoría, sus fichas activas con su stock y sus combinaciones (cuántas y cuántas agotadas; primero las agotadas, las que más venden arriba) y ventas de 90 días. " +
|
|
209
|
+
"Solo en tiendas con el stock activado (growbaratochile.cl); en growbarato.net no es real")
|
|
210
|
+
.option("--url <url>", "URL de una ficha o categoría de la tienda")
|
|
211
|
+
.option("--ref <tipo:id>", "en vez de la URL: product:<id> o category:<id>")
|
|
212
|
+
.option("--connection <id>", "la tienda (crm site list); obligatoria con --ref si tienes varias")
|
|
213
|
+
.option("--agotados", "en una categoría: solo las fichas sin stock")
|
|
214
|
+
.option("--combinaciones-agotadas", "en una categoría: solo las fichas con alguna combinación agotada (p. ej. un pack de semillas), incluidas las agotadas del todo")
|
|
215
|
+
.option("--combinaciones", "en una categoría: cada ficha con sus combinaciones (nombre y unidades)")
|
|
216
|
+
.option("--inactivos", "en una categoría: incluir también las fichas desactivadas")
|
|
217
|
+
.action(async (opts, cmd) => {
|
|
218
|
+
const flags = readFlags(cmd);
|
|
219
|
+
if (opts.url && opts.ref)
|
|
220
|
+
usageError("--url y --ref son excluyentes");
|
|
221
|
+
if (!opts.url && !opts.ref)
|
|
222
|
+
usageError("indica --url o --ref (una ficha o categoría)");
|
|
223
|
+
await run({
|
|
224
|
+
method: "GET",
|
|
225
|
+
path: "/sites/stock",
|
|
226
|
+
request: {
|
|
227
|
+
query: {
|
|
228
|
+
url: opts.url,
|
|
229
|
+
ref: opts.ref,
|
|
230
|
+
connectionId: opts.connection,
|
|
231
|
+
onlyOut: opts.agotados ? "true" : undefined,
|
|
232
|
+
onlyCombinationsOut: opts.combinacionesAgotadas ? "true" : undefined,
|
|
233
|
+
combinationNames: opts.combinaciones ? "true" : undefined,
|
|
234
|
+
includeInactive: opts.inactivos ? "true" : undefined,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
output: outputFromFlags(flags),
|
|
238
|
+
profile: flags.profile,
|
|
239
|
+
});
|
|
240
|
+
});
|
|
203
241
|
site
|
|
204
242
|
.command("update")
|
|
205
243
|
.description("Cambia campos de una página y lo deja en el registro de cambios de la tarea (antes y después reales). " +
|
|
@@ -237,6 +275,87 @@ export function registerSite(program) {
|
|
|
237
275
|
asAgent: flags.asAgent,
|
|
238
276
|
});
|
|
239
277
|
});
|
|
278
|
+
const redirect = site
|
|
279
|
+
.command("redirect")
|
|
280
|
+
.description("Redirecciones 301 del blog (WordPress), sin plugin ni .htaccess: entrada → entrada es una fusión (el origen a la papelera y WordPress " +
|
|
281
|
+
"responde 301 por su slug antiguo); lo demás, por ruta. Comprueba el destino antes y el 301 después, y lo registra en la tarea");
|
|
282
|
+
redirect
|
|
283
|
+
.command("list")
|
|
284
|
+
.description("Redirecciones hechas desde el CRM en un blog y, con --url, qué hay ahora en esa URL")
|
|
285
|
+
.option("--url <url>", "URL del blog que se quiere consultar")
|
|
286
|
+
.option("--connection <id>", "o el id de la conexión del blog (crm site list)")
|
|
287
|
+
.action(async (opts, cmd) => {
|
|
288
|
+
const flags = readFlags(cmd);
|
|
289
|
+
if (!opts.url && !opts.connection)
|
|
290
|
+
usageError("indica --url o --connection");
|
|
291
|
+
await run({
|
|
292
|
+
method: "GET",
|
|
293
|
+
path: "/sites/redirects",
|
|
294
|
+
request: { query: { url: opts.url, connectionId: opts.connection } },
|
|
295
|
+
output: outputFromFlags(flags),
|
|
296
|
+
profile: flags.profile,
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
redirect
|
|
300
|
+
.command("create")
|
|
301
|
+
.description("Redirige con 301 una URL del blog a otra del mismo dominio y lo deja en el registro de cambios de la tarea. Prueba antes con --dry-run")
|
|
302
|
+
.requiredOption("--task <id>", "tarea a la que se ancla el cambio (del mismo dominio que el blog)")
|
|
303
|
+
.requiredOption("--from <url>", "URL que deja de existir")
|
|
304
|
+
.requiredOption("--to <url>", "URL final (mismo dominio, responde 200 y se indexa)")
|
|
305
|
+
.option("--connection <id>", "fuerza la conexión del blog")
|
|
306
|
+
.option("--note <texto>", "por qué se redirige (va al registro de cambios)")
|
|
307
|
+
.option("--note-file <ruta>", "lee --note de un fichero UTF-8")
|
|
308
|
+
.option("--dry-run", "solo enseña el plan; no escribe")
|
|
309
|
+
.action(async (opts, cmd) => {
|
|
310
|
+
const flags = readFlags(cmd);
|
|
311
|
+
const note = pick(opts.note, opts.noteFile, "note");
|
|
312
|
+
await run({
|
|
313
|
+
method: "POST",
|
|
314
|
+
path: "/sites/redirects",
|
|
315
|
+
request: {
|
|
316
|
+
body: {
|
|
317
|
+
taskId: opts.task,
|
|
318
|
+
from: opts.from,
|
|
319
|
+
to: opts.to,
|
|
320
|
+
...(opts.connection ? { connectionId: opts.connection } : {}),
|
|
321
|
+
...(note !== undefined ? { note } : {}),
|
|
322
|
+
...(opts.dryRun ? { dryRun: true } : {}),
|
|
323
|
+
},
|
|
324
|
+
idempotencyKey: flags.idempotencyKey,
|
|
325
|
+
},
|
|
326
|
+
output: outputFromFlags(flags),
|
|
327
|
+
profile: flags.profile,
|
|
328
|
+
asAgent: flags.asAgent,
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
redirect
|
|
332
|
+
.command("delete")
|
|
333
|
+
.description("Quita una 301 hecha desde el CRM. Si era una fusión, la entrada de origen sale de la papelera como borrador; si era por ruta, sale de la lista")
|
|
334
|
+
.requiredOption("--task <id>", "tarea a la que se ancla el cambio")
|
|
335
|
+
.requiredOption("--from <url>", "URL de origen de la 301")
|
|
336
|
+
.option("--connection <id>", "fuerza la conexión del blog")
|
|
337
|
+
.option("--note <texto>", "por qué se quita")
|
|
338
|
+
.option("--dry-run", "solo enseña qué se haría")
|
|
339
|
+
.action(async (opts, cmd) => {
|
|
340
|
+
const flags = readFlags(cmd);
|
|
341
|
+
await run({
|
|
342
|
+
method: "POST",
|
|
343
|
+
path: "/sites/redirects/delete",
|
|
344
|
+
request: {
|
|
345
|
+
body: {
|
|
346
|
+
taskId: opts.task,
|
|
347
|
+
from: opts.from,
|
|
348
|
+
...(opts.connection ? { connectionId: opts.connection } : {}),
|
|
349
|
+
...(opts.note ? { note: opts.note } : {}),
|
|
350
|
+
...(opts.dryRun ? { dryRun: true } : {}),
|
|
351
|
+
},
|
|
352
|
+
idempotencyKey: flags.idempotencyKey,
|
|
353
|
+
},
|
|
354
|
+
output: outputFromFlags(flags),
|
|
355
|
+
profile: flags.profile,
|
|
356
|
+
asAgent: flags.asAgent,
|
|
357
|
+
});
|
|
358
|
+
});
|
|
240
359
|
}
|
|
241
360
|
const PATTERN_OPS = ["regex", "contains", "not_regex", "not_contains"];
|
|
242
361
|
/** Cuerpo de PATCH /tasks/:id/tracking (exportado para tests). */
|