@faable/faable 4.36.0 → 4.38.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/api/FaableApi.js +4 -2
- package/dist/commands/deploy/domains/add.js +37 -4
- package/dist/commands/deploy/domains/check.js +3 -0
- package/dist/commands/deploy/domains/format.js +15 -1
- package/dist/commands/deploy/domains/index.js +3 -1
- package/dist/commands/deploy/domains/list.js +3 -3
- package/dist/commands/deploy/domains/redirect.js +77 -0
- package/dist/commands/deploy/domains/rm.js +18 -6
- package/dist/mcp/tools.js +111 -36
- package/package.json +1 -1
package/dist/api/FaableApi.js
CHANGED
|
@@ -495,8 +495,10 @@ class FaableApi {
|
|
|
495
495
|
headers: projectHeader(team)
|
|
496
496
|
}));
|
|
497
497
|
}
|
|
498
|
-
// Relink a domain to another app of its project (or `null` to
|
|
499
|
-
//
|
|
498
|
+
// Relink a domain to another app of its project (`app_id`, or `null` to
|
|
499
|
+
// unlink it), or make it redirect to another domain of the project
|
|
500
|
+
// (`redirect`, `null` to serve again). Keeps the row: same id, same CNAME
|
|
501
|
+
// target, same certificate.
|
|
500
502
|
async updateDomain(domain_id, team, params) {
|
|
501
503
|
return data(this.client.post(`/domain/${domain_id}`, params, {
|
|
502
504
|
headers: projectHeader(team)
|
|
@@ -2,7 +2,7 @@ import { requireApi } from '../../../api/context.js';
|
|
|
2
2
|
import { print_json, json_option } from '../../../lib/listing.js';
|
|
3
3
|
import { log } from '../../../log.js';
|
|
4
4
|
import { resolve_app_id } from '../resolve_app_id.js';
|
|
5
|
-
import { acme_record, cname_target } from './format.js';
|
|
5
|
+
import { pair_fqdn, acme_record, cname_target } from './format.js';
|
|
6
6
|
import { add_conflict_hint } from './locate.js';
|
|
7
7
|
|
|
8
8
|
const domains_add = {
|
|
@@ -23,33 +23,62 @@ const domains_add = {
|
|
|
23
23
|
type: 'boolean',
|
|
24
24
|
default: true,
|
|
25
25
|
description: 'Provision a TLS certificate automatically (default)'
|
|
26
|
+
})
|
|
27
|
+
.option('www', {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
description: 'Also add the www (or root) counterpart, redirecting to this domain: example.com and www.example.com'
|
|
26
30
|
})
|
|
27
31
|
.example('$0 deploy domains add www.example.com', 'Attach www.example.com to the linked app')
|
|
32
|
+
.example('$0 deploy domains add example.com --www', 'Attach example.com, and www.example.com redirecting to it')
|
|
28
33
|
.showHelpOnFail(false),
|
|
29
34
|
handler: async (args) => {
|
|
30
35
|
const ctx = await requireApi();
|
|
31
36
|
const app_id = await resolve_app_id(args.app, ctx.appId, ctx.api);
|
|
32
37
|
const app = await ctx.api.getApp(app_id);
|
|
33
38
|
const domain = await ctx.api
|
|
34
|
-
.createDomain(app.team, {
|
|
39
|
+
.createDomain(app.team, {
|
|
40
|
+
fqdn: args.fqdn,
|
|
41
|
+
app_id,
|
|
42
|
+
tls: args.tls,
|
|
43
|
+
...(args.www ? { www: true } : {})
|
|
44
|
+
})
|
|
35
45
|
.catch(async (err) => {
|
|
36
46
|
// Already in this project (an app deletion leaves its domains linked
|
|
37
47
|
// to no app): name the command that fixes it, not "another project".
|
|
38
48
|
throw ((await add_conflict_hint(ctx.api, app.team, args.fqdn, app_id, err)) ?? err);
|
|
39
49
|
});
|
|
50
|
+
// The pair's other half was created by the api with the main one; its DNS
|
|
51
|
+
// is a second record to create, so it is shown too.
|
|
52
|
+
const pair = args.www
|
|
53
|
+
? (await ctx.api.listDomains(app_id, app.team)).find(d => d.fqdn === pair_fqdn(domain.fqdn))
|
|
54
|
+
: undefined;
|
|
40
55
|
// Same shape as `domains check --json`: the record plus the CNAME to
|
|
41
56
|
// create, which is the whole next step.
|
|
42
57
|
if (args.json) {
|
|
43
58
|
return print_json({
|
|
44
59
|
...domain,
|
|
45
60
|
expected_cname: cname_target(domain),
|
|
46
|
-
...(args.tls ? { prevalidation_cname: acme_record(domain) } : {})
|
|
61
|
+
...(args.tls ? { prevalidation_cname: acme_record(domain) } : {}),
|
|
62
|
+
...(pair
|
|
63
|
+
? {
|
|
64
|
+
pair: {
|
|
65
|
+
...pair,
|
|
66
|
+
expected_cname: cname_target(pair),
|
|
67
|
+
...(args.tls ? { prevalidation_cname: acme_record(pair) } : {})
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
: {})
|
|
47
71
|
});
|
|
48
72
|
}
|
|
49
73
|
log.info(`🌐 Domain ${domain.fqdn} added to ${app.name} (${app_id}).`);
|
|
74
|
+
if (pair) {
|
|
75
|
+
log.info(` ${pair.fqdn} added too, redirecting to ${domain.fqdn}.`);
|
|
76
|
+
}
|
|
50
77
|
log.info(``);
|
|
51
|
-
log.info(`Now create a CNAME record at your DNS provider:`);
|
|
78
|
+
log.info(`Now create ${pair ? 'these records' : 'a CNAME record'} at your DNS provider:`);
|
|
52
79
|
log.info(` ${domain.fqdn} → ${cname_target(domain)}`);
|
|
80
|
+
if (pair)
|
|
81
|
+
log.info(` ${pair.fqdn} → ${cname_target(pair)}`);
|
|
53
82
|
log.info(``);
|
|
54
83
|
log.info(`Faable verifies the record automatically once DNS propagates${args.tls ? ' and then provisions the TLS certificate' : ''}.`);
|
|
55
84
|
if (args.tls) {
|
|
@@ -57,6 +86,10 @@ const domains_add = {
|
|
|
57
86
|
log.info(``);
|
|
58
87
|
log.info(`Already serving ${domain.fqdn} somewhere else? Create this record FIRST and leave the CNAME above for later:`);
|
|
59
88
|
log.info(` ${acme.name} → ${acme.target}`);
|
|
89
|
+
if (pair) {
|
|
90
|
+
const pacme = acme_record(pair);
|
|
91
|
+
log.info(` ${pacme.name} → ${pacme.target}`);
|
|
92
|
+
}
|
|
60
93
|
log.info(`Faable then issues the certificate before any traffic moves, and switching the CNAME has no TLS gap.`);
|
|
61
94
|
}
|
|
62
95
|
log.info(`Track it with: faable deploy domains check ${domain.fqdn}`);
|
|
@@ -36,6 +36,9 @@ const domains_check = {
|
|
|
36
36
|
if (!domain.app_id) {
|
|
37
37
|
log.warn(` Linked to no app: it answers DOMAIN_NOT_LINKED. Serve it with: faable deploy domains attach ${domain.fqdn} --app <app>`);
|
|
38
38
|
}
|
|
39
|
+
if (domain.redirect) {
|
|
40
|
+
log.info(` Redirects to: https://${domain.redirect} (path and query kept). Serve it again with: faable deploy domains redirect ${domain.fqdn} --off`);
|
|
41
|
+
}
|
|
39
42
|
log.info(` Expected CNAME: ${domain.fqdn} → ${cname_target(domain)}`);
|
|
40
43
|
if (status?.dns_observed?.length) {
|
|
41
44
|
log.info(` Observed: ${status.dns_observed.join(', ')}`);
|
|
@@ -41,5 +41,19 @@ const tls_line = (domain) => {
|
|
|
41
41
|
: '⏳ issued once the CNAME (or the pre-validation record) is in place';
|
|
42
42
|
};
|
|
43
43
|
const find_by_fqdn = (domains, fqdn) => domains.find(d => d.fqdn.toLowerCase() === fqdn.toLowerCase());
|
|
44
|
+
/**
|
|
45
|
+
* The other half of an apex/www pair created with `--www`. The api has already
|
|
46
|
+
* checked the name is an apex or its www (Public Suffix List); this only names
|
|
47
|
+
* the counterpart to look it up.
|
|
48
|
+
*/
|
|
49
|
+
const pair_fqdn = (fqdn) => fqdn.startsWith('www.') ? fqdn.slice(4) : `www.${fqdn}`;
|
|
50
|
+
/** ` ↪ example.com` for a domain that redirects, '' for one that serves. */
|
|
51
|
+
const redirect_badge = (domain) => domain.redirect ? `↪ ${domain.redirect}` : '';
|
|
52
|
+
/**
|
|
53
|
+
* The domains of `all` that redirect to `domain`. They are part of it: deleting
|
|
54
|
+
* `domain` deletes them too (the api cascades; same project only).
|
|
55
|
+
*/
|
|
56
|
+
const redirects_to = (all, domain) => all.filter(d => d.id !== domain.id &&
|
|
57
|
+
d.redirect?.toLowerCase() === domain.fqdn.toLowerCase());
|
|
44
58
|
|
|
45
|
-
export { acme_record, cname_target, dns_badge, find_by_fqdn, tls_line };
|
|
59
|
+
export { acme_record, cname_target, dns_badge, find_by_fqdn, pair_fqdn, redirect_badge, redirects_to, tls_line };
|
|
@@ -2,6 +2,7 @@ import { domains_add } from './add.js';
|
|
|
2
2
|
import { domains_attach } from './attach.js';
|
|
3
3
|
import { domains_check } from './check.js';
|
|
4
4
|
import { domains_list } from './list.js';
|
|
5
|
+
import { domains_redirect } from './redirect.js';
|
|
5
6
|
import { domains_rm } from './rm.js';
|
|
6
7
|
|
|
7
8
|
const domains = {
|
|
@@ -12,8 +13,9 @@ const domains = {
|
|
|
12
13
|
.command(domains_add)
|
|
13
14
|
.command(domains_attach)
|
|
14
15
|
.command(domains_check)
|
|
16
|
+
.command(domains_redirect)
|
|
15
17
|
.command(domains_rm)
|
|
16
|
-
.demandCommand(1, 'Specify a domains command: list, add, attach, check or rm'),
|
|
18
|
+
.demandCommand(1, 'Specify a domains command: list, add, attach, check, redirect or rm'),
|
|
17
19
|
handler: () => {
|
|
18
20
|
// Unreachable: demandCommand(1) either routes to a subcommand or fails
|
|
19
21
|
// through the global .fail() in src/index.ts.
|
|
@@ -3,7 +3,7 @@ import { fetch_page, print_json, print, more_hint, list_options } from '../../..
|
|
|
3
3
|
import { log } from '../../../log.js';
|
|
4
4
|
import { requireProject } from '../../../api/project.js';
|
|
5
5
|
import { find_app_id } from '../resolve_app_id.js';
|
|
6
|
-
import { dns_badge, cname_target } from './format.js';
|
|
6
|
+
import { dns_badge, redirect_badge, cname_target } from './format.js';
|
|
7
7
|
|
|
8
8
|
const domains_list = {
|
|
9
9
|
command: 'list',
|
|
@@ -35,7 +35,7 @@ const domains_list = {
|
|
|
35
35
|
const width = Math.max(...domains.map(d => d.fqdn.length));
|
|
36
36
|
for (const domain of domains) {
|
|
37
37
|
const tls = domain.tls ? 'tls' : 'no-tls';
|
|
38
|
-
print(` ${domain.fqdn.padEnd(width)} ${dns_badge(domain)} (${tls})
|
|
38
|
+
print(` ${domain.fqdn.padEnd(width)} ${dns_badge(domain)} (${tls}) ${redirect_badge(domain)}`.trimEnd());
|
|
39
39
|
}
|
|
40
40
|
const hint = more_hint(page);
|
|
41
41
|
if (hint)
|
|
@@ -75,7 +75,7 @@ const list_project_domains = async (api, args) => {
|
|
|
75
75
|
const app_width = Math.max(...domains.map(d => label(d).length));
|
|
76
76
|
for (const domain of domains) {
|
|
77
77
|
const tls = domain.tls ? 'tls' : 'no-tls';
|
|
78
|
-
print(` ${domain.fqdn.padEnd(width)} ${label(domain).padEnd(app_width)} ${dns_badge(domain)} (${tls})
|
|
78
|
+
print(` ${domain.fqdn.padEnd(width)} ${label(domain).padEnd(app_width)} ${dns_badge(domain)} (${tls}) ${redirect_badge(domain)}`.trimEnd());
|
|
79
79
|
}
|
|
80
80
|
const hint = more_hint(page);
|
|
81
81
|
if (hint)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { requireApi } from '../../../api/context.js';
|
|
2
|
+
import { CliError } from '../../../lib/errors.js';
|
|
3
|
+
import { print_json, json_option } from '../../../lib/listing.js';
|
|
4
|
+
import { log } from '../../../log.js';
|
|
5
|
+
import { find_by_fqdn } from './format.js';
|
|
6
|
+
import { domain_scope, project_domains, not_in_project } from './locate.js';
|
|
7
|
+
|
|
8
|
+
const domains_redirect = {
|
|
9
|
+
command: 'redirect <fqdn> [target]',
|
|
10
|
+
describe: 'Make a domain redirect every request to another domain of the project (or serve again with --off)',
|
|
11
|
+
builder: yargs => json_option(yargs)
|
|
12
|
+
.positional('fqdn', {
|
|
13
|
+
type: 'string',
|
|
14
|
+
demandOption: true,
|
|
15
|
+
description: 'The domain that redirects'
|
|
16
|
+
})
|
|
17
|
+
.positional('target', {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description: 'The domain it redirects to: same project, and one that serves'
|
|
20
|
+
})
|
|
21
|
+
.option('off', {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
default: false,
|
|
24
|
+
description: 'Stop redirecting: the domain serves its app again'
|
|
25
|
+
})
|
|
26
|
+
.option('app', {
|
|
27
|
+
alias: 'a',
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'App id, name or slug. Optional: the domain is looked up in the project'
|
|
30
|
+
})
|
|
31
|
+
.example('$0 deploy domains redirect www.example.com example.com', 'www.example.com/path?q → https://example.com/path?q')
|
|
32
|
+
.example('$0 deploy domains redirect www.example.com --off', 'www.example.com serves its app again')
|
|
33
|
+
.epilog('GET gets a 301, every other method (HEAD included) a 308: the path and the query are kept. A domain redirects to the one it names, never further: no chains. Removing the target removes the domains that redirect to it.')
|
|
34
|
+
.showHelpOnFail(false),
|
|
35
|
+
handler: async (args) => {
|
|
36
|
+
if (!args.off && !args.target) {
|
|
37
|
+
throw new CliError('usage', 'Name the domain to redirect to, or pass --off to stop redirecting.');
|
|
38
|
+
}
|
|
39
|
+
if (args.off && args.target) {
|
|
40
|
+
throw new CliError('usage', 'Pass either a target or --off, not both.');
|
|
41
|
+
}
|
|
42
|
+
const ctx = await requireApi();
|
|
43
|
+
const scope = await domain_scope(ctx.api, args.app, ctx.appId);
|
|
44
|
+
const all = await project_domains(ctx.api, scope.team);
|
|
45
|
+
const domain = find_by_fqdn(all, args.fqdn);
|
|
46
|
+
if (!domain)
|
|
47
|
+
throw not_in_project(args.fqdn, scope.team);
|
|
48
|
+
const target = args.off ? null : args.target.toLowerCase();
|
|
49
|
+
if ((domain.redirect ?? null) === target) {
|
|
50
|
+
if (args.json)
|
|
51
|
+
return print_json(domain);
|
|
52
|
+
log.info(target
|
|
53
|
+
? `↪ ${domain.fqdn} already redirects to ${target}.`
|
|
54
|
+
: `🌐 ${domain.fqdn} already serves its app: it redirects nowhere.`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// The api checks the target (same project, serving, no chains) and says
|
|
58
|
+
// why in its error; this only spares the round trip for the plain typo.
|
|
59
|
+
if (target && !find_by_fqdn(all, target)) {
|
|
60
|
+
throw new CliError('domain_redirect_invalid', `${target} is not a domain of this project. Add it first with "faable deploy domains add ${target}": a domain can only redirect to another domain of the same project.`);
|
|
61
|
+
}
|
|
62
|
+
const updated = await ctx.api.updateDomain(domain.id, scope.team, {
|
|
63
|
+
redirect: target
|
|
64
|
+
});
|
|
65
|
+
if (args.json)
|
|
66
|
+
return print_json(updated);
|
|
67
|
+
if (target) {
|
|
68
|
+
log.info(`↪ ${updated.fqdn} now redirects to ${target}: GET → 301, other methods → 308, path and query kept.`);
|
|
69
|
+
log.info(`Removing ${target} will remove ${updated.fqdn} too. Its CNAME and certificate stay as they are.`);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
log.info(`🌐 ${updated.fqdn} no longer redirects: it serves ${updated.app_id ?? 'no app (link one with "faable deploy domains attach")'}.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { domains_redirect };
|
|
@@ -2,7 +2,8 @@ import { requireApi } from '../../../api/context.js';
|
|
|
2
2
|
import { confirm } from '../../../lib/interactive.js';
|
|
3
3
|
import { print_json, json_option } from '../../../lib/listing.js';
|
|
4
4
|
import { log } from '../../../log.js';
|
|
5
|
-
import {
|
|
5
|
+
import { redirects_to } from './format.js';
|
|
6
|
+
import { domain_scope, locate_domain, project_domains } from './locate.js';
|
|
6
7
|
|
|
7
8
|
const domains_rm = {
|
|
8
9
|
command: 'rm <fqdn>',
|
|
@@ -36,10 +37,16 @@ const domains_rm = {
|
|
|
36
37
|
? `${scope.app.name} (${domain.app_id})`
|
|
37
38
|
: domain.app_id
|
|
38
39
|
: null;
|
|
40
|
+
// The domains that redirect to it go with it (the api cascades): say so
|
|
41
|
+
// before, not after.
|
|
42
|
+
const dependents = redirects_to(await project_domains(ctx.api, scope.team), domain);
|
|
43
|
+
const also = dependents.length
|
|
44
|
+
? ` ${dependents.map(d => d.fqdn).join(', ')} redirect${dependents.length === 1 ? 's' : ''} to it and will be removed too.`
|
|
45
|
+
: '';
|
|
39
46
|
const go = await confirm({
|
|
40
47
|
message: serves
|
|
41
|
-
? `Remove domain "${domain.fqdn}" from ${serves}? Traffic to it will stop being served
|
|
42
|
-
: `Remove domain "${domain.fqdn}"? It is linked to no app. To serve it again with the same CNAME and certificate, use "faable deploy domains attach" instead
|
|
48
|
+
? `Remove domain "${domain.fqdn}" from ${serves}? Traffic to it will stop being served.${also}`
|
|
49
|
+
: `Remove domain "${domain.fqdn}"? It is linked to no app. To serve it again with the same CNAME and certificate, use "faable deploy domains attach" instead.${also}`,
|
|
43
50
|
yes: args.yes
|
|
44
51
|
});
|
|
45
52
|
if (!go) {
|
|
@@ -48,10 +55,15 @@ const domains_rm = {
|
|
|
48
55
|
}
|
|
49
56
|
await ctx.api.deleteDomain(domain.id, scope.team);
|
|
50
57
|
if (args.json) {
|
|
51
|
-
return print_json({
|
|
58
|
+
return print_json({
|
|
59
|
+
deleted: true,
|
|
60
|
+
id: domain.id,
|
|
61
|
+
fqdn: domain.fqdn,
|
|
62
|
+
also_deleted: dependents.map(d => ({ id: d.id, fqdn: d.fqdn }))
|
|
63
|
+
});
|
|
52
64
|
}
|
|
53
|
-
log.info(`🗑️ Removed domain ${domain.fqdn}${serves ? ` from ${serves}` : ''}.`);
|
|
54
|
-
log.info(`Remember to delete the CNAME at your DNS provider.`);
|
|
65
|
+
log.info(`🗑️ Removed domain ${domain.fqdn}${serves ? ` from ${serves}` : ''}${dependents.length ? `, and ${dependents.map(d => d.fqdn).join(', ')} that redirected to it` : ''}.`);
|
|
66
|
+
log.info(`Remember to delete the CNAME${dependents.length ? 's' : ''} at your DNS provider.`);
|
|
55
67
|
}
|
|
56
68
|
};
|
|
57
69
|
|
package/dist/mcp/tools.js
CHANGED
|
@@ -73,12 +73,8 @@ const tenant = z
|
|
|
73
73
|
.optional()
|
|
74
74
|
.describe("Auth tenant id (account_…). Defaults to the project's tenant (list_auth_tenants when it has several).");
|
|
75
75
|
const auth_scope = (a) => [...opt('--account', a.tenant), ...scope(a)];
|
|
76
|
-
const user_ref = z
|
|
77
|
-
|
|
78
|
-
.describe('User id (user_…) or exact email');
|
|
79
|
-
const time = z
|
|
80
|
-
.string()
|
|
81
|
-
.regex(/^(\d+[mhd]|\d{4}-\d{2}-\d{2}|\d{10,})$/);
|
|
76
|
+
const user_ref = z.string().describe('User id (user_…) or exact email');
|
|
77
|
+
const time = z.string().regex(/^(\d+[mhd]|\d{4}-\d{2}-\d{2}|\d{10,})$/);
|
|
82
78
|
const limit_flag = (a, d = 50) => ['--limit', String(a.limit ?? d)];
|
|
83
79
|
const limit = z
|
|
84
80
|
.number()
|
|
@@ -179,7 +175,7 @@ const api_detail = (a) => ({
|
|
|
179
175
|
permissions: (a.permissions ?? []).map((p) => p.value)
|
|
180
176
|
});
|
|
181
177
|
// Which product a tool works on — /tools.json and the landing group by it.
|
|
182
|
-
const product_of = (tool) => tool.command[0] === 'auth' ? 'auth' : 'deploy';
|
|
178
|
+
const product_of = (tool) => (tool.command[0] === 'auth' ? 'auth' : 'deploy');
|
|
183
179
|
const AUTH_WRITE = {
|
|
184
180
|
readOnlyHint: false,
|
|
185
181
|
destructiveHint: false,
|
|
@@ -424,7 +420,7 @@ const TOOLS = [
|
|
|
424
420
|
{
|
|
425
421
|
name: 'list_domains',
|
|
426
422
|
title: 'List custom domains',
|
|
427
|
-
description: 'Custom domains of an app and whether their DNS is verified. Without `app`, every domain of the project with the app it serves: `app_id: null` is a domain linked to no app (its app was deleted), which answers DOMAIN_NOT_LINKED until attach_domain links it.',
|
|
423
|
+
description: 'Custom domains of an app and whether their DNS is verified. Without `app`, every domain of the project with the app it serves: `app_id: null` is a domain linked to no app (its app was deleted), which answers DOMAIN_NOT_LINKED until attach_domain links it. `redirect` names the domain it sends every request to (the www half of a pair, or an alias); null when it serves its app.',
|
|
428
424
|
input: { app: optional_app, project },
|
|
429
425
|
command: ['deploy', 'domains', 'list'],
|
|
430
426
|
flags: app_or_project,
|
|
@@ -434,6 +430,7 @@ const TOOLS = [
|
|
|
434
430
|
app_id: d.app_id ?? null,
|
|
435
431
|
verified: d.verified,
|
|
436
432
|
tls: d.tls,
|
|
433
|
+
redirect: d.redirect ?? null,
|
|
437
434
|
dns_message: d.status?.dns_message
|
|
438
435
|
})),
|
|
439
436
|
annotations: READ,
|
|
@@ -454,6 +451,7 @@ const TOOLS = [
|
|
|
454
451
|
fqdn: d.fqdn,
|
|
455
452
|
app_id: d.app_id ?? null,
|
|
456
453
|
verified: d.verified,
|
|
454
|
+
redirect: d.redirect ?? null,
|
|
457
455
|
expected_cname: d.expected_cname,
|
|
458
456
|
observed: d.status?.dns_observed ?? [],
|
|
459
457
|
diagnostic: d.status?.dns_message,
|
|
@@ -481,7 +479,7 @@ const TOOLS = [
|
|
|
481
479
|
{
|
|
482
480
|
name: 'list_auth_tenants',
|
|
483
481
|
title: 'List Auth tenants',
|
|
484
|
-
description:
|
|
482
|
+
description: 'The Faable Auth tenants (user directories) of a project. Most projects have one and every Auth tool uses it; with several, pass the right one as `tenant`.',
|
|
485
483
|
input: { project },
|
|
486
484
|
command: ['auth', 'accounts', 'list'],
|
|
487
485
|
flags: scope,
|
|
@@ -539,7 +537,9 @@ const TOOLS = [
|
|
|
539
537
|
last_login_since: time
|
|
540
538
|
.optional()
|
|
541
539
|
.describe('Logged in at or after: 24h, 7d, a date'),
|
|
542
|
-
created_since: time
|
|
540
|
+
created_since: time
|
|
541
|
+
.optional()
|
|
542
|
+
.describe('Signed up at or after: 24h, 7d, a date'),
|
|
543
543
|
created_until: time.optional().describe('Signed up at or before'),
|
|
544
544
|
suspended: z.boolean().optional(),
|
|
545
545
|
tenant,
|
|
@@ -551,7 +551,9 @@ const TOOLS = [
|
|
|
551
551
|
...opt('--last-login-since', a.last_login_since),
|
|
552
552
|
...opt('--created-since', a.created_since),
|
|
553
553
|
...opt('--created-until', a.created_until),
|
|
554
|
-
...(a.suspended === undefined
|
|
554
|
+
...(a.suspended === undefined
|
|
555
|
+
? []
|
|
556
|
+
: [a.suspended ? '--suspended' : '--no-suspended']),
|
|
555
557
|
...auth_scope(a)
|
|
556
558
|
],
|
|
557
559
|
annotations: AUTH_READ,
|
|
@@ -560,15 +562,23 @@ const TOOLS = [
|
|
|
560
562
|
{
|
|
561
563
|
name: 'list_auth_users',
|
|
562
564
|
title: 'List users',
|
|
563
|
-
description:
|
|
565
|
+
description: 'Users of the Auth tenant. Find one by email or text, list the suspended ones, or sort: `-last_login` (most recent login first), `last_login` (longest without logging in), `-logins_count` (most active), `-createdAt` (newest sign-ups, the default). Sorting by last_login leaves out users who never logged in.',
|
|
564
566
|
input: {
|
|
565
567
|
search: z.string().optional().describe('Text in name, email or phone'),
|
|
566
568
|
email: z.string().optional().describe('Exact email'),
|
|
567
569
|
suspended: z.boolean().optional(),
|
|
568
570
|
sort: z
|
|
569
|
-
.enum([
|
|
571
|
+
.enum([
|
|
572
|
+
'-last_login',
|
|
573
|
+
'last_login',
|
|
574
|
+
'-logins_count',
|
|
575
|
+
'-createdAt',
|
|
576
|
+
'createdAt'
|
|
577
|
+
])
|
|
570
578
|
.optional(),
|
|
571
|
-
last_login_since: time
|
|
579
|
+
last_login_since: time
|
|
580
|
+
.optional()
|
|
581
|
+
.describe('Logged in at or after: 24h, 7d, a date'),
|
|
572
582
|
created_since: time.optional().describe('Signed up at or after'),
|
|
573
583
|
limit,
|
|
574
584
|
cursor,
|
|
@@ -579,7 +589,9 @@ const TOOLS = [
|
|
|
579
589
|
flags: a => [
|
|
580
590
|
...opt('-q', a.search),
|
|
581
591
|
...opt('--email', a.email),
|
|
582
|
-
...(a.suspended === undefined
|
|
592
|
+
...(a.suspended === undefined
|
|
593
|
+
? []
|
|
594
|
+
: [a.suspended ? '--suspended' : '--no-suspended']),
|
|
583
595
|
// `--sort=-x`: as two words yargs would read `-last_login` as flags.
|
|
584
596
|
...(a.sort ? [`--sort=${a.sort}`] : []),
|
|
585
597
|
...opt('--last-login-since', a.last_login_since),
|
|
@@ -649,9 +661,15 @@ const TOOLS = [
|
|
|
649
661
|
title: 'Read the Auth audit log',
|
|
650
662
|
description: "The Auth tenant's audit log, newest first: logins, failed logins (`status: failed`), sign-ups, password resets, admin changes (`type` prefix `admin.user`). Filter by user to answer 'why can't X log in?' — the failed attempts say why. On a failed login no user resolves, so each row also carries `attempted_identifier`: the email/username the person actually typed (diagnose_auth_login turns that into the account they should be using).",
|
|
651
663
|
input: {
|
|
652
|
-
email: z
|
|
664
|
+
email: z
|
|
665
|
+
.string()
|
|
666
|
+
.optional()
|
|
667
|
+
.describe("Only this user's events (exact email)"),
|
|
653
668
|
user: z.string().optional().describe('Only this user id (user_…)'),
|
|
654
|
-
type: z
|
|
669
|
+
type: z
|
|
670
|
+
.string()
|
|
671
|
+
.optional()
|
|
672
|
+
.describe('Exact event type, e.g. user.login, user.signup'),
|
|
655
673
|
origin: z.string().optional().describe('Type prefix, e.g. oauth, admin'),
|
|
656
674
|
status: z.enum(['success', 'failed', 'skipped', 'info']).optional(),
|
|
657
675
|
since: time.optional().describe('30m, 24h, 7d or a date (default 7d)'),
|
|
@@ -713,7 +731,10 @@ const TOOLS = [
|
|
|
713
731
|
description: 'The devices a user is signed in on (one row per login session): IP, device, last activity and whether it is still active.',
|
|
714
732
|
input: {
|
|
715
733
|
user: user_ref,
|
|
716
|
-
active: z
|
|
734
|
+
active: z
|
|
735
|
+
.boolean()
|
|
736
|
+
.optional()
|
|
737
|
+
.describe('Only active sessions (default true)'),
|
|
717
738
|
tenant,
|
|
718
739
|
project
|
|
719
740
|
},
|
|
@@ -791,7 +812,10 @@ const TOOLS = [
|
|
|
791
812
|
.describe('Wait until live or failed, up to 5 minutes (default false)')
|
|
792
813
|
},
|
|
793
814
|
command: ['deploy', 'trigger'],
|
|
794
|
-
flags: a => [
|
|
815
|
+
flags: a => [
|
|
816
|
+
...target(a),
|
|
817
|
+
...(a.wait ? ['--wait', '--timeout', '300'] : [])
|
|
818
|
+
],
|
|
795
819
|
timeout_ms: 330_000,
|
|
796
820
|
annotations: {
|
|
797
821
|
readOnlyHint: false,
|
|
@@ -987,10 +1011,18 @@ const TOOLS = [
|
|
|
987
1011
|
{
|
|
988
1012
|
name: 'add_domain',
|
|
989
1013
|
title: 'Add a custom domain',
|
|
990
|
-
description:
|
|
991
|
-
input: {
|
|
1014
|
+
description: 'Attach a custom domain to an app. Returns the CNAME record the user must create at their DNS provider; Faable verifies it and issues the certificate on its own. If the domain already serves traffic somewhere else, tell the user to create `prevalidation_cname` (`_acme-challenge.<fqdn>` CNAME) FIRST and switch the main CNAME only once check_domain shows it ready: the certificate then exists before traffic moves, with no TLS gap. If it says the domain is already in this project, use attach_domain instead: adding it again cannot work.',
|
|
1015
|
+
input: {
|
|
1016
|
+
app,
|
|
1017
|
+
project,
|
|
1018
|
+
fqdn: z.string().describe('e.g. www.example.com'),
|
|
1019
|
+
www: z
|
|
1020
|
+
.boolean()
|
|
1021
|
+
.optional()
|
|
1022
|
+
.describe('Also add the www (or root) counterpart, redirecting to this domain: example.com and www.example.com. Only for a root domain or its www. Both need their DNS record.')
|
|
1023
|
+
},
|
|
992
1024
|
command: ['deploy', 'domains', 'add'],
|
|
993
|
-
flags: a => [a.fqdn, ...target(a)],
|
|
1025
|
+
flags: a => [a.fqdn, ...(a.www ? ['--www'] : []), ...target(a)],
|
|
994
1026
|
write: true,
|
|
995
1027
|
annotations: {
|
|
996
1028
|
readOnlyHint: false,
|
|
@@ -1017,6 +1049,40 @@ const TOOLS = [
|
|
|
1017
1049
|
},
|
|
1018
1050
|
example: { app: 'web', fqdn: 'app.example.com' }
|
|
1019
1051
|
},
|
|
1052
|
+
{
|
|
1053
|
+
name: 'set_domain_redirect',
|
|
1054
|
+
title: 'Redirect a domain to another',
|
|
1055
|
+
description: 'Make a custom domain send every request to another domain of the same project (GET → 301, other methods → 308, path and query kept), e.g. www.example.com to example.com, or an old name to the new one. `target: null` stops it: the domain serves its app again. The target must be a domain of the project that serves (no chains). Deleting the target later deletes the domains that redirect to it. DNS and certificate do not change.',
|
|
1056
|
+
input: {
|
|
1057
|
+
app: optional_app,
|
|
1058
|
+
project,
|
|
1059
|
+
fqdn: z.string().describe('The domain that redirects, e.g. www.example.com'),
|
|
1060
|
+
target: z
|
|
1061
|
+
.string()
|
|
1062
|
+
.nullable()
|
|
1063
|
+
.describe('The domain it redirects to, e.g. example.com; null to stop redirecting')
|
|
1064
|
+
},
|
|
1065
|
+
command: ['deploy', 'domains', 'redirect'],
|
|
1066
|
+
flags: a => [
|
|
1067
|
+
a.fqdn,
|
|
1068
|
+
...(a.target ? [a.target] : ['--off']),
|
|
1069
|
+
...app_or_project(a)
|
|
1070
|
+
],
|
|
1071
|
+
write: true,
|
|
1072
|
+
shape: (d) => ({
|
|
1073
|
+
id: d.id,
|
|
1074
|
+
fqdn: d.fqdn,
|
|
1075
|
+
app_id: d.app_id ?? null,
|
|
1076
|
+
redirect: d.redirect ?? null
|
|
1077
|
+
}),
|
|
1078
|
+
annotations: {
|
|
1079
|
+
readOnlyHint: false,
|
|
1080
|
+
destructiveHint: false,
|
|
1081
|
+
idempotentHint: true,
|
|
1082
|
+
openWorldHint: true
|
|
1083
|
+
},
|
|
1084
|
+
example: { fqdn: 'www.example.com', target: 'example.com' }
|
|
1085
|
+
},
|
|
1020
1086
|
{
|
|
1021
1087
|
name: 'configure_repo',
|
|
1022
1088
|
title: 'Configure how an app deploys',
|
|
@@ -1052,7 +1118,7 @@ const TOOLS = [
|
|
|
1052
1118
|
{
|
|
1053
1119
|
name: 'link_repo',
|
|
1054
1120
|
title: 'Link a repository to an app',
|
|
1055
|
-
description:
|
|
1121
|
+
description: 'Link a GitHub repository to an app that already exists, so a push deploys it (for a new app, create_app does both). What is live keeps serving until the next push — linking starts no deploy. Needs the Faable GitHub App installed on the repository; if not, the error says what to fix.',
|
|
1056
1122
|
input: {
|
|
1057
1123
|
app,
|
|
1058
1124
|
repo: z.string().describe('GitHub repository, owner/repo'),
|
|
@@ -1063,12 +1129,7 @@ const TOOLS = [
|
|
|
1063
1129
|
project
|
|
1064
1130
|
},
|
|
1065
1131
|
command: ['deploy', 'link'],
|
|
1066
|
-
flags: a => [
|
|
1067
|
-
'--repo',
|
|
1068
|
-
a.repo,
|
|
1069
|
-
...opt('--branch', a.branch),
|
|
1070
|
-
...target(a)
|
|
1071
|
-
],
|
|
1132
|
+
flags: a => ['--repo', a.repo, ...opt('--branch', a.branch), ...target(a)],
|
|
1072
1133
|
write: true,
|
|
1073
1134
|
annotations: {
|
|
1074
1135
|
readOnlyHint: false,
|
|
@@ -1296,7 +1357,7 @@ const TOOLS = [
|
|
|
1296
1357
|
{
|
|
1297
1358
|
name: 'suspend_auth_user',
|
|
1298
1359
|
title: 'Suspend a user',
|
|
1299
|
-
description:
|
|
1360
|
+
description: 'Suspend one user of the Auth tenant: they can no longer log in, and their sessions and refresh tokens stop working (access tokens already issued live until they expire). Reversible with reinstate_auth_user. Confirm with get_auth_user that it is the right person first, and say why in `reason` — it is recorded on the user.',
|
|
1300
1361
|
input: {
|
|
1301
1362
|
user: user_ref,
|
|
1302
1363
|
reason: z.string().max(512).describe('Why — recorded on the user'),
|
|
@@ -1380,7 +1441,7 @@ const TOOLS = [
|
|
|
1380
1441
|
},
|
|
1381
1442
|
{
|
|
1382
1443
|
name: 'update_auth_client_login',
|
|
1383
|
-
title:
|
|
1444
|
+
title: 'Change how users sign in to an app',
|
|
1384
1445
|
description: "Choose which login methods one Auth application offers: which connections (by id or name, as list_auth_connections shows them) and whether the passkey button appears. `only` keeps exactly those connections and removes the rest; `disable`/`enable` change one at a time. A removed connection is refused at /authorize too, not just hidden. `passkey` needs the Pro plan. `inherit: true` drops the app's own settings and follows the tenant's again. Settings not mentioned keep their current value.",
|
|
1385
1446
|
input: {
|
|
1386
1447
|
client: z
|
|
@@ -1447,7 +1508,12 @@ const TOOLS = [
|
|
|
1447
1508
|
project
|
|
1448
1509
|
},
|
|
1449
1510
|
command: ['auth', 'users', 'password-setup'],
|
|
1450
|
-
flags: a => [
|
|
1511
|
+
flags: a => [
|
|
1512
|
+
a.user,
|
|
1513
|
+
...opt('--channel', a.channel),
|
|
1514
|
+
'--yes',
|
|
1515
|
+
...auth_scope(a)
|
|
1516
|
+
],
|
|
1451
1517
|
write: true,
|
|
1452
1518
|
annotations: { ...AUTH_WRITE, idempotentHint: false },
|
|
1453
1519
|
example: { user: 'ana@example.com', channel: 'email' }
|
|
@@ -1458,9 +1524,15 @@ const TOOLS = [
|
|
|
1458
1524
|
description: "Change a user's profile: `email`, `name`, `email_verified`. Changing `email` also moves their database login identifier (the email they type at the password login) so sign-in keeps working — pass `profile_only: true` to change only the profile email and leave the login identifier. Use this when someone cannot log in because the address they were given is not the one on their account. Confirm the person first with get_auth_user.",
|
|
1459
1525
|
input: {
|
|
1460
1526
|
user: user_ref,
|
|
1461
|
-
email: z
|
|
1527
|
+
email: z
|
|
1528
|
+
.string()
|
|
1529
|
+
.optional()
|
|
1530
|
+
.describe('New email — also the database login identifier unless profile_only'),
|
|
1462
1531
|
name: z.string().optional(),
|
|
1463
|
-
email_verified: z
|
|
1532
|
+
email_verified: z
|
|
1533
|
+
.boolean()
|
|
1534
|
+
.optional()
|
|
1535
|
+
.describe('Mark the email verified (true) or clear verification (false)'),
|
|
1464
1536
|
profile_only: z
|
|
1465
1537
|
.boolean()
|
|
1466
1538
|
.optional()
|
|
@@ -1499,7 +1571,10 @@ const TOOLS = [
|
|
|
1499
1571
|
.string()
|
|
1500
1572
|
.optional()
|
|
1501
1573
|
.describe('The exact new password. Omit and set generate:true to have one made.'),
|
|
1502
|
-
generate: z
|
|
1574
|
+
generate: z
|
|
1575
|
+
.boolean()
|
|
1576
|
+
.optional()
|
|
1577
|
+
.describe('Generate a strong password and return it once'),
|
|
1503
1578
|
connection: z
|
|
1504
1579
|
.string()
|
|
1505
1580
|
.optional()
|
|
@@ -1525,7 +1600,7 @@ const TOOLS = [
|
|
|
1525
1600
|
{
|
|
1526
1601
|
name: 'get_auth_recovery_link',
|
|
1527
1602
|
title: 'Get a password-reset link',
|
|
1528
|
-
description:
|
|
1603
|
+
description: 'Mint a fresh password-reset link for a user and return it, so you can hand it over by another channel when the reset email will not reach them (e.g. the address on the account is not a real inbox). This ALSO sends the standard reset email. The link lets whoever holds it set the password, so treat it like a password; it works once, until used or expired. Returns `link` (email channel only), `ticket_id` and `channel`.',
|
|
1529
1604
|
input: { user: user_ref, tenant, project },
|
|
1530
1605
|
command: ['auth', 'users', 'password-setup'],
|
|
1531
1606
|
flags: a => [a.user, '--print', '--yes', ...auth_scope(a)],
|