layero 0.11.14 → 0.11.16
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/commands/data-api.js +26 -6
- package/package.json +1 -1
|
@@ -125,6 +125,9 @@ function keyRow(k) {
|
|
|
125
125
|
expires_at: k.expires_at ?? null,
|
|
126
126
|
in_build: Boolean(k.in_build),
|
|
127
127
|
service: Boolean(k.is_service),
|
|
128
|
+
// Публичный ключ не секрет (он в бандле сайта) — отдаём значением, чтобы не
|
|
129
|
+
// выпускать новый ради уже существующего (T-20261026-9, п. 5).
|
|
130
|
+
value: k.is_public ? (k.value ?? null) : null,
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
133
|
export async function dataKeysListCmd(opts) {
|
|
@@ -147,7 +150,8 @@ export async function dataKeysListCmd(opts) {
|
|
|
147
150
|
console.log(`${chalk.bold(`${k.prefix}…`)} ${kind} ${k.label ?? ""} ${marks.join(" ")}\n` +
|
|
148
151
|
chalk.dim(` срок: ${k.expires_at ? `до ${day(k.expires_at)}` : "без срока"}` +
|
|
149
152
|
` · последний вызов: ${k.last_used_at ? day(k.last_used_at) : "не было"}` +
|
|
150
|
-
` · ${k.id}`)
|
|
153
|
+
` · ${k.id}`) +
|
|
154
|
+
(k.value ? `\n ${k.value}` : ""));
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
export async function dataKeysIssueCmd(opts) {
|
|
@@ -179,6 +183,9 @@ export async function dataKeysIssueCmd(opts) {
|
|
|
179
183
|
prefix: issued.prefix,
|
|
180
184
|
key: issued.key,
|
|
181
185
|
expires_at: issued.expires_at ?? null,
|
|
186
|
+
// Что маскировать (T-20261026-6), как у database_created: секретный ключ
|
|
187
|
+
// платформа не хранит и больше не покажет — в журнал агента он попасть не должен.
|
|
188
|
+
secrets: kind === "secret" ? ["key"] : [],
|
|
182
189
|
});
|
|
183
190
|
return;
|
|
184
191
|
}
|
|
@@ -492,15 +499,20 @@ export async function dataEnableCmd(opts) {
|
|
|
492
499
|
org,
|
|
493
500
|
database: ref,
|
|
494
501
|
slug: res.slug,
|
|
502
|
+
url: res.url ?? null,
|
|
503
|
+
url_note: res.url_note ?? null,
|
|
495
504
|
public_key: publicKey,
|
|
496
505
|
secret_key: secretKey,
|
|
506
|
+
// Что маскировать (T-20261026-6): секретный ключ показывается один раз.
|
|
507
|
+
secrets: secretKey ? ["secret_key"] : [],
|
|
497
508
|
reapplied,
|
|
498
509
|
// Итог включения словами: какие таблицы открыты, какие без RLS закрыты.
|
|
499
510
|
warnings: res.warnings ?? [],
|
|
500
511
|
...(publicKey || secretKey
|
|
501
|
-
? { next_action:
|
|
502
|
-
|
|
503
|
-
|
|
512
|
+
? { next_action: (secretKey
|
|
513
|
+
? "секретный ключ показан один раз — сохраните его сейчас, платформа его не хранит. "
|
|
514
|
+
: "") +
|
|
515
|
+
`Публичный ключ можно получить снова: layero data keys list --db ${shellArg(ref)}` }
|
|
504
516
|
: {}),
|
|
505
517
|
});
|
|
506
518
|
return;
|
|
@@ -511,6 +523,11 @@ export async function dataEnableCmd(opts) {
|
|
|
511
523
|
? `${chalk.green("✓")} Data API переприменён у базы «${db.name}»\n` +
|
|
512
524
|
chalk.yellow(" Выданные права на таблицы сохранились, права по умолчанию — как в Supabase")
|
|
513
525
|
: `${chalk.green("✓")} Data API включён у базы «${db.name}»`);
|
|
526
|
+
if (res.url) {
|
|
527
|
+
console.log(`\n адрес API: ${res.url}`);
|
|
528
|
+
if (res.url_note)
|
|
529
|
+
console.log(chalk.dim(` ${res.url_note}`));
|
|
530
|
+
}
|
|
514
531
|
for (const w of res.warnings ?? [])
|
|
515
532
|
console.log(chalk.yellow(`\n ⚠ ${w}`));
|
|
516
533
|
if (publicKey)
|
|
@@ -537,7 +554,9 @@ export function registerDataApiCommands(data, program) {
|
|
|
537
554
|
.option("--org <slug>", "organization (default: your only one, otherwise your personal organization)");
|
|
538
555
|
const json = (opts) => ({ ...opts, json: program.opts().json });
|
|
539
556
|
const keys = data.command("keys").description("Data API keys: list, issue, revoke.");
|
|
540
|
-
withDb(keys
|
|
557
|
+
withDb(keys
|
|
558
|
+
.command("list")
|
|
559
|
+
.description("The database's keys: prefix, expiry, last call; the public key's value too (it is not a secret)."))
|
|
541
560
|
.action(async (opts) => dataKeysListCmd(json(opts)));
|
|
542
561
|
withDb(keys
|
|
543
562
|
.command("issue")
|
|
@@ -581,7 +600,8 @@ export function registerDataApiCommands(data, program) {
|
|
|
581
600
|
"\nWithout --yes outside a terminal the command shows the SQL, changes nothing and exits with an error.")).action(async (object, opts) => dataGrantCmd(object, json(opts)));
|
|
582
601
|
withDb(data
|
|
583
602
|
.command("enable")
|
|
584
|
-
.description("Enable the Data API for a database: sets up the api schema and roles, issues a public key.
|
|
603
|
+
.description("Enable the Data API for a database: sets up the api schema and roles, issues a public key. " +
|
|
604
|
+
"As in Supabase, new tables, sequences and functions in public are open to the API roles; rows are decided by RLS.")
|
|
585
605
|
.option("--with-secret", "also issue a secret key for the server")
|
|
586
606
|
.option("--repair", "re-apply the roles and the api schema for a database whose Data API is already enabled; table grants are kept, default privileges for new tables are removed")
|
|
587
607
|
.option("-y, --yes", "do not ask for confirmation for --repair")).action(async (opts) => dataEnableCmd(json(opts)));
|
package/package.json
CHANGED