@motherbase/cli 0.2.4 → 0.2.5
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/README.md +247 -134
- package/package.json +2 -2
- package/src/api.js +14 -2
- package/src/commands/_util.js +49 -6
- package/src/commands/backups.js +16 -0
- package/src/commands/branches.js +113 -0
- package/src/commands/completion.js +90 -0
- package/src/commands/db-catalog.js +326 -0
- package/src/commands/db.js +16 -5
- package/src/commands/domains.js +124 -0
- package/src/commands/functions.js +297 -274
- package/src/commands/gen.js +172 -126
- package/src/commands/import.js +23 -3
- package/src/commands/index.js +27 -6
- package/src/commands/inspect.js +142 -5
- package/src/commands/keys.js +72 -72
- package/src/commands/local.js +273 -273
- package/src/commands/mcp.js +61 -43
- package/src/commands/migrate.js +179 -0
- package/src/commands/migration.js +81 -6
- package/src/commands/network.js +83 -0
- package/src/commands/orgs.js +40 -0
- package/src/commands/postgres-config.js +113 -0
- package/src/commands/projects.js +8 -3
- package/src/commands/queues.js +133 -0
- package/src/commands/secrets.js +29 -8
- package/src/commands/signing.js +130 -0
- package/src/commands/snippets.js +44 -0
- package/src/commands/storage.js +192 -44
- package/src/commands/test.js +9 -0
- package/src/commands/users.js +30 -1
- package/src/commands/vault.js +82 -0
- package/src/commands/wrappers.js +150 -0
- package/src/edge-templates.js +194 -0
- package/src/format.js +92 -0
- package/src/inspect/csv.js +22 -0
- package/src/inspect/queries.js +562 -0
- package/src/main.js +41 -7
- package/src/mcp/platform-tools.js +233 -0
- package/src/mcp/protocol.js +149 -149
- package/src/mcp/storage-tools.js +93 -0
- package/src/mcp/tools.js +478 -166
- package/src/migration/commands.js +375 -0
- package/src/migration/files.js +245 -0
- package/src/prompt.js +1 -1
- package/src/storage/remote.js +62 -0
- package/src/commands/migrations.js +0 -85
package/src/commands/keys.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// Project API keys. `secrets` next door is a different thing: those are values
|
|
4
|
-
// an edge function reads, these are what a client presents to reach the project.
|
|
5
|
-
|
|
6
|
-
const api = require('../api');
|
|
7
|
-
const { output, requireArg } = require('./_util');
|
|
8
|
-
|
|
9
|
-
const TYPES = ['publishable', 'secret'];
|
|
10
|
-
|
|
11
|
-
const subcommands = {
|
|
12
|
-
list: {
|
|
13
|
-
summary: 'List project API keys',
|
|
14
|
-
usage: 'motherbase keys list',
|
|
15
|
-
async run(ctx) {
|
|
16
|
-
const data = await api.adminRequest(ctx, 'GET', '/api-keys');
|
|
17
|
-
const keys = (data && data.keys) || [];
|
|
18
|
-
output(ctx, data, (_d, ui) =>
|
|
19
|
-
ui.table(
|
|
20
|
-
keys.map(k => ({
|
|
21
|
-
name: k.name,
|
|
22
|
-
type: k.type,
|
|
23
|
-
// A secret key has no stored clear value; the prefix is all there is.
|
|
24
|
-
key: k.token || `${k.prefix}…`,
|
|
25
|
-
status: k.revokedAt ? 'revoked' : 'active',
|
|
26
|
-
})),
|
|
27
|
-
[
|
|
28
|
-
{ key: 'name', label: 'NAME' },
|
|
29
|
-
{ key: 'type', label: 'TYPE' },
|
|
30
|
-
{ key: 'key', label: 'KEY' },
|
|
31
|
-
{ key: 'status', label: 'STATUS' },
|
|
32
|
-
],
|
|
33
|
-
),
|
|
34
|
-
);
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
create: {
|
|
38
|
-
summary: 'Create a key. A secret key is printed once and never again',
|
|
39
|
-
usage: 'motherbase keys create <NAME> [--type publishable|secret]',
|
|
40
|
-
async run(ctx, args, flags) {
|
|
41
|
-
const name = requireArg(args[0], 'NAME');
|
|
42
|
-
const type = flags.type || 'secret';
|
|
43
|
-
if (!TYPES.includes(type)) {
|
|
44
|
-
throw new Error(`--type must be one of: ${TYPES.join(', ')}`);
|
|
45
|
-
}
|
|
46
|
-
const data = await api.adminRequest(ctx, 'POST', '/api-keys', { body: { name, type } });
|
|
47
|
-
output(ctx, data, (d, ui) => {
|
|
48
|
-
ui.success(`Created ${type} key "${name}"`);
|
|
49
|
-
ui.print(d.clearToken);
|
|
50
|
-
if (type === 'secret') {
|
|
51
|
-
ui.warn('Copy it now. It is stored hashed and cannot be shown again.');
|
|
52
|
-
ui.warn('It bypasses row level security: keep it server side.');
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
revoke: {
|
|
58
|
-
summary: 'Revoke a key by id',
|
|
59
|
-
usage: 'motherbase keys revoke <ID>',
|
|
60
|
-
async run(ctx, args) {
|
|
61
|
-
const id = requireArg(args[0], 'ID');
|
|
62
|
-
const data = await api.adminRequest(ctx, 'DELETE', `/api-keys/${encodeURIComponent(id)}`);
|
|
63
|
-
output(ctx, data, (d, ui) => ui.success(`Revoked key ${d.name || id}`));
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
module.exports = {
|
|
69
|
-
summary: 'Project API keys (publishable and secret)',
|
|
70
|
-
usage: 'motherbase keys <list|create|revoke> ...',
|
|
71
|
-
subcommands,
|
|
72
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Project API keys. `secrets` next door is a different thing: those are values
|
|
4
|
+
// an edge function reads, these are what a client presents to reach the project.
|
|
5
|
+
|
|
6
|
+
const api = require('../api');
|
|
7
|
+
const { output, requireArg } = require('./_util');
|
|
8
|
+
|
|
9
|
+
const TYPES = ['publishable', 'secret'];
|
|
10
|
+
|
|
11
|
+
const subcommands = {
|
|
12
|
+
list: {
|
|
13
|
+
summary: 'List project API keys',
|
|
14
|
+
usage: 'motherbase keys list',
|
|
15
|
+
async run(ctx) {
|
|
16
|
+
const data = await api.adminRequest(ctx, 'GET', '/api-keys');
|
|
17
|
+
const keys = (data && data.keys) || [];
|
|
18
|
+
output(ctx, data, (_d, ui) =>
|
|
19
|
+
ui.table(
|
|
20
|
+
keys.map(k => ({
|
|
21
|
+
name: k.name,
|
|
22
|
+
type: k.type,
|
|
23
|
+
// A secret key has no stored clear value; the prefix is all there is.
|
|
24
|
+
key: k.token || `${k.prefix}…`,
|
|
25
|
+
status: k.revokedAt ? 'revoked' : 'active',
|
|
26
|
+
})),
|
|
27
|
+
[
|
|
28
|
+
{ key: 'name', label: 'NAME' },
|
|
29
|
+
{ key: 'type', label: 'TYPE' },
|
|
30
|
+
{ key: 'key', label: 'KEY' },
|
|
31
|
+
{ key: 'status', label: 'STATUS' },
|
|
32
|
+
],
|
|
33
|
+
),
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
create: {
|
|
38
|
+
summary: 'Create a key. A secret key is printed once and never again',
|
|
39
|
+
usage: 'motherbase keys create <NAME> [--type publishable|secret]',
|
|
40
|
+
async run(ctx, args, flags) {
|
|
41
|
+
const name = requireArg(args[0], 'NAME');
|
|
42
|
+
const type = flags.type || 'secret';
|
|
43
|
+
if (!TYPES.includes(type)) {
|
|
44
|
+
throw new Error(`--type must be one of: ${TYPES.join(', ')}`);
|
|
45
|
+
}
|
|
46
|
+
const data = await api.adminRequest(ctx, 'POST', '/api-keys', { body: { name, type } });
|
|
47
|
+
output(ctx, data, (d, ui) => {
|
|
48
|
+
ui.success(`Created ${type} key "${name}"`);
|
|
49
|
+
ui.print(d.clearToken);
|
|
50
|
+
if (type === 'secret') {
|
|
51
|
+
ui.warn('Copy it now. It is stored hashed and cannot be shown again.');
|
|
52
|
+
ui.warn('It bypasses row level security: keep it server side.');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
revoke: {
|
|
58
|
+
summary: 'Revoke a key by id',
|
|
59
|
+
usage: 'motherbase keys revoke <ID>',
|
|
60
|
+
async run(ctx, args) {
|
|
61
|
+
const id = requireArg(args[0], 'ID');
|
|
62
|
+
const data = await api.adminRequest(ctx, 'DELETE', `/api-keys/${encodeURIComponent(id)}`);
|
|
63
|
+
output(ctx, data, (d, ui) => ui.success(`Revoked key ${d.name || id}`));
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
summary: 'Project API keys (publishable and secret)',
|
|
70
|
+
usage: 'motherbase keys <list|create|revoke> ...',
|
|
71
|
+
subcommands,
|
|
72
|
+
};
|