koigrid 0.8.0 → 0.10.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 +26 -0
- package/dist/actualizacion.js +49 -0
- package/dist/agente.js +103 -0
- package/dist/api.js +84 -4
- package/dist/commands/apps.js +203 -12
- package/dist/commands/auth.js +10 -1
- package/dist/commands/billing.js +70 -14
- package/dist/commands/db.js +393 -17
- package/dist/commands/events.js +15 -3
- package/dist/commands/experiments.js +105 -0
- package/dist/commands/flags.js +21 -2
- package/dist/commands/network.js +28 -0
- package/dist/commands/notifications.js +2 -2
- package/dist/commands/pricing.js +37 -0
- package/dist/commands/redis.js +62 -0
- package/dist/commands/registry.js +15 -0
- package/dist/commands/rewards.js +34 -19
- package/dist/commands/sandboxes.js +506 -1
- package/dist/commands/storage.js +23 -0
- package/dist/commands/tokens.js +5 -1
- package/dist/config.js +4 -1
- package/dist/esperar.js +41 -0
- package/dist/help.js +14 -1
- package/dist/index.js +20 -3
- package/dist/manifest.js +26 -12
- package/dist/registry.js +3 -1
- package/package.json +5 -1
package/dist/commands/billing.js
CHANGED
|
@@ -1,31 +1,87 @@
|
|
|
1
1
|
import { api } from '../api.js';
|
|
2
2
|
import { green, dim } from '../output.js';
|
|
3
|
-
// koigrid billing —
|
|
3
|
+
// koigrid billing — cómo paga la organización y el TRASPASO al pago. Ver docs/products/BILLING.md.
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// Desde los precios por recurso (ficha 91d809ff) ya no hay planes que comprar: se paga lo reservado por horas a la
|
|
6
|
+
// tarjeta guardada. `card` no cobra: pide al proveedor el enlace para GUARDAR una tarjeta y lo imprime, porque un
|
|
7
|
+
// agente puede conducir toda una migración por API y se paraba justo aquí — el único paso que no puede dar él.
|
|
7
8
|
export async function billing(a) {
|
|
8
9
|
const json = !!a.flags.json;
|
|
9
10
|
const sub = a.sub || 'show';
|
|
10
|
-
if (sub === 'show' || sub === 'status'
|
|
11
|
+
if (sub === 'show' || sub === 'status') {
|
|
11
12
|
const r = await api('/billing');
|
|
12
13
|
if (json)
|
|
13
14
|
return console.log(JSON.stringify(r, null, 2));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const modo = { free: 'gratis (sin tarjeta)', card: 'tarjeta guardada', granted: 'concedido por koigrid (no paga)', legacy_plan: `plan antiguo '${r.plan}'` };
|
|
16
|
+
console.log(`pago: ${modo[r.paymentMode] ?? r.paymentMode}${r.cardSetupAvailable || r.cardOnFile ? '' : dim(' (cobro con tarjeta no configurado)')}`);
|
|
17
|
+
console.log(`reservado este mes (desde ${r.monthToDate?.since}): $${Number(r.monthToDate?.reservedUsd ?? 0).toFixed(2)}${r.cardOnFile ? '' : dim(' (no se cobra sin tarjeta)')}`);
|
|
18
|
+
console.log(`modo de cobro: ${r.billingMode === 'monthly' ? 'factura mensual a la tarjeta' : 'prepago (cada hora sale del saldo)'}${dim(' (koigrid billing mode prepaid|monthly)')}`);
|
|
19
|
+
const p = r.pricing?.prices ?? {};
|
|
20
|
+
console.log(dim(`tarifa: $${p.ramGbMonth}/GB RAM${p.vcpuMonth ? ` · $${p.vcpuMonth}/vCPU` : ' (vCPU compartida incluida)'} · $${p.diskGbMonth}/GB disco · $${p.objectStorageGbMonth}/GB objetos, al mes, por horas · tráfico incluido`));
|
|
17
21
|
return;
|
|
18
22
|
}
|
|
19
|
-
if (sub === '
|
|
20
|
-
const
|
|
21
|
-
if (!plan)
|
|
22
|
-
throw new Error('usage: koigrid billing upgrade <starter|pro|scale>');
|
|
23
|
-
const r = await api('/billing/checkout-session', { method: 'POST', body: { plan: String(plan) } });
|
|
23
|
+
if (sub === 'card' || sub === 'add-card') {
|
|
24
|
+
const r = await api('/billing/checkout-session', { method: 'POST', body: {} });
|
|
24
25
|
if (json)
|
|
25
26
|
return console.log(JSON.stringify(r, null, 2));
|
|
26
|
-
console.log(green(
|
|
27
|
+
console.log(green('✓ enlace para guardar una tarjeta (no se cobra nada al guardarla):'));
|
|
27
28
|
console.log(` ${r.url}`);
|
|
28
|
-
return console.log(dim(' Ábrelo tú (o pásaselo a quien
|
|
29
|
+
return console.log(dim(' Ábrelo tú (o pásaselo a quien paga): koigrid no recoge tarjetas por API.'));
|
|
30
|
+
}
|
|
31
|
+
// MONEDERO prepagado (docs/design/MONEDERO.md): `wallet` · `topup <usd>` · `auto-topup <usd>|off` · `entries`.
|
|
32
|
+
if (sub === 'wallet' || sub === 'balance') {
|
|
33
|
+
const r = (await api('/billing/wallet')).wallet;
|
|
34
|
+
if (json)
|
|
35
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
36
|
+
console.log(`saldo: $${Number(r.balanceUsd).toFixed(2)}${r.creditUsd ? ` · crédito de koigrid: $${Number(r.creditUsd).toFixed(2)} (se gasta antes)` : ''}`);
|
|
37
|
+
const at = r.autoTopUp;
|
|
38
|
+
console.log(at.enabled ? `recarga automática: $${at.amountUsd} cuando el saldo baje de $${at.thresholdUsd}` : at.disabledAfterFailures ? `recarga automática: APAGADA tras ${at.consecutiveFailures} rechazos (revisa la tarjeta y vuelve a encenderla)` : dim('recarga automática: apagada'));
|
|
39
|
+
if (r.graceUntil)
|
|
40
|
+
console.log(`⚠ saldo agotado: todo sigue hasta ${r.graceUntil}; después se pausan apps y VMs (las bases y los datos nunca)`);
|
|
41
|
+
if (!r.hourlyChargingActive)
|
|
42
|
+
console.log(dim('el cargo por horas al saldo aún no está activo'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (sub === 'topup' || sub === 'add-funds') {
|
|
46
|
+
const usd = Number(a.positionals[0] ?? a.flags.amount);
|
|
47
|
+
if (!Number.isFinite(usd) || usd <= 0)
|
|
48
|
+
throw new Error('uso: koigrid billing topup <dólares> (de 10 a 10000)');
|
|
49
|
+
const r = await api('/billing/wallet/topup', { method: 'POST', body: { amountCents: Math.round(usd * 100) } });
|
|
50
|
+
if (json)
|
|
51
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
52
|
+
console.log(green(`✓ recarga de $${Number(r.amountUsd).toFixed(2)}: ábrela para pagar (emite la factura y guarda la tarjeta para las recargas automáticas)`));
|
|
53
|
+
console.log(` ${r.url}`);
|
|
54
|
+
return console.log(dim(' koigrid no recoge tarjetas por API: la página es del proveedor de pagos.'));
|
|
55
|
+
}
|
|
56
|
+
if (sub === 'auto-topup') {
|
|
57
|
+
const v = String(a.positionals[0] ?? '');
|
|
58
|
+
const amountCents = v === 'off' ? null : Math.round(Number(v) * 100);
|
|
59
|
+
if (amountCents !== null && !(amountCents > 0))
|
|
60
|
+
throw new Error('uso: koigrid billing auto-topup <dólares>|off');
|
|
61
|
+
const r = (await api('/billing/wallet/auto-topup', { method: 'PUT', body: { amountCents } })).wallet;
|
|
62
|
+
if (json)
|
|
63
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
64
|
+
return console.log(green(amountCents === null ? '✓ recarga automática apagada' : `✓ recarga automática: $${r.autoTopUp.amountUsd} cuando el saldo baje de $${r.autoTopUp.thresholdUsd}`));
|
|
65
|
+
}
|
|
66
|
+
if (sub === 'entries' || sub === 'movements') {
|
|
67
|
+
const r = await api(`/billing/wallet/entries?limit=${Number(a.flags.limit ?? 30)}`);
|
|
68
|
+
if (json)
|
|
69
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
70
|
+
for (const e of r.entries)
|
|
71
|
+
console.log(`${e.createdAt.slice(0, 16).replace('T', ' ')} ${e.kind.padEnd(10)} ${(e.amountUsd >= 0 ? '+' : '') + Number(e.amountUsd).toFixed(4)} ${dim(e.description ?? '')}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Cómo se paga lo reservado: `mode` enseña el actual; `mode prepaid|monthly` lo cambia (owner/admin).
|
|
75
|
+
if (sub === 'mode') {
|
|
76
|
+
const nuevo = a.positionals[0];
|
|
77
|
+
const r = nuevo ? await api('/billing/mode', { method: 'PUT', body: { mode: nuevo } }) : await api('/billing/mode');
|
|
78
|
+
if (json)
|
|
79
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
80
|
+
const texto = r.billingMode === 'monthly' ? 'factura mensual a la tarjeta guardada' : 'prepago: cada hora sale del saldo del monedero';
|
|
81
|
+
return console.log(nuevo ? (r.changed ? green(`✓ modo de cobro: ${texto}`) : `ya estaba en: ${texto}`) : `modo de cobro: ${texto}${dim(' (cámbialo con: koigrid billing mode prepaid|monthly)')}`);
|
|
82
|
+
}
|
|
83
|
+
if (sub === 'upgrade' || sub === 'checkout' || sub === 'change' || sub === 'set') {
|
|
84
|
+
throw new Error('koigrid ya no vende planes: pagas lo reservado por horas. Guarda una tarjeta con `koigrid billing card` y mira precios con `koigrid pricing`.');
|
|
29
85
|
}
|
|
30
86
|
throw new Error(`unknown: billing ${sub}`);
|
|
31
87
|
}
|