@portaidentity/cli 0.1.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/auth/browser-flow.d.ts +42 -0
- package/dist/auth/browser-flow.d.ts.map +1 -0
- package/dist/auth/browser-flow.js +193 -0
- package/dist/auth/browser-flow.js.map +1 -0
- package/dist/auth/callback-server.d.ts +81 -0
- package/dist/auth/callback-server.d.ts.map +1 -0
- package/dist/auth/callback-server.js +193 -0
- package/dist/auth/callback-server.js.map +1 -0
- package/dist/auth/metadata.d.ts +43 -0
- package/dist/auth/metadata.d.ts.map +1 -0
- package/dist/auth/metadata.js +66 -0
- package/dist/auth/metadata.js.map +1 -0
- package/dist/auth/pkce.d.ts +42 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +52 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/types.d.ts +72 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +11 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client-factory.d.ts +29 -0
- package/dist/client-factory.d.ts.map +1 -0
- package/dist/client-factory.js +43 -0
- package/dist/client-factory.js.map +1 -0
- package/dist/commands/app-claim.d.ts +9 -0
- package/dist/commands/app-claim.d.ts.map +1 -0
- package/dist/commands/app-claim.js +128 -0
- package/dist/commands/app-claim.js.map +1 -0
- package/dist/commands/app-module.d.ts +9 -0
- package/dist/commands/app-module.d.ts.map +1 -0
- package/dist/commands/app-module.js +104 -0
- package/dist/commands/app-module.js.map +1 -0
- package/dist/commands/app-permission.d.ts +9 -0
- package/dist/commands/app-permission.d.ts.map +1 -0
- package/dist/commands/app-permission.js +118 -0
- package/dist/commands/app-permission.js.map +1 -0
- package/dist/commands/app-role.d.ts +9 -0
- package/dist/commands/app-role.d.ts.map +1 -0
- package/dist/commands/app-role.js +166 -0
- package/dist/commands/app-role.js.map +1 -0
- package/dist/commands/app.d.ts +12 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +255 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/audit.d.ts +12 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +96 -0
- package/dist/commands/audit.js.map +1 -0
- package/dist/commands/bulk.d.ts +12 -0
- package/dist/commands/bulk.d.ts.map +1 -0
- package/dist/commands/bulk.js +77 -0
- package/dist/commands/bulk.js.map +1 -0
- package/dist/commands/client-secret.d.ts +18 -0
- package/dist/commands/client-secret.d.ts.map +1 -0
- package/dist/commands/client-secret.js +126 -0
- package/dist/commands/client-secret.js.map +1 -0
- package/dist/commands/client.d.ts +27 -0
- package/dist/commands/client.d.ts.map +1 -0
- package/dist/commands/client.js +385 -0
- package/dist/commands/client.js.map +1 -0
- package/dist/commands/completion.d.ts +27 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +42 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +14 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +85 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/doctor.d.ts +25 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +198 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/exports.d.ts +12 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +80 -0
- package/dist/commands/exports.js.map +1 -0
- package/dist/commands/health.d.ts +12 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +53 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/keys.d.ts +14 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +91 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/login.d.ts +36 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +78 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +25 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +43 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/org.d.ts +26 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +396 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/provision.d.ts +47 -0
- package/dist/commands/provision.d.ts.map +1 -0
- package/dist/commands/provision.js +400 -0
- package/dist/commands/provision.js.map +1 -0
- package/dist/commands/sessions.d.ts +14 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +122 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/stats.d.ts +12 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +46 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/user-claim.d.ts +17 -0
- package/dist/commands/user-claim.d.ts.map +1 -0
- package/dist/commands/user-claim.js +123 -0
- package/dist/commands/user-claim.js.map +1 -0
- package/dist/commands/user-role.d.ts +17 -0
- package/dist/commands/user-role.d.ts.map +1 -0
- package/dist/commands/user-role.js +118 -0
- package/dist/commands/user-role.js.map +1 -0
- package/dist/commands/user.d.ts +26 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +352 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/version.d.ts +25 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +83 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/commands/whoami.d.ts +26 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +66 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/credential-store.d.ts +101 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/credential-store.js +121 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/error-handler.d.ts +47 -0
- package/dist/error-handler.d.ts.map +1 -0
- package/dist/error-handler.js +166 -0
- package/dist/error-handler.js.map +1 -0
- package/dist/global-options.d.ts +50 -0
- package/dist/global-options.d.ts.map +1 -0
- package/dist/global-options.js +62 -0
- package/dist/global-options.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +75 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +100 -0
- package/dist/output.js.map +1 -0
- package/dist/parsers.d.ts +74 -0
- package/dist/parsers.d.ts.map +1 -0
- package/dist/parsers.js +125 -0
- package/dist/parsers.js.map +1 -0
- package/dist/prompt.d.ts +50 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +98 -0
- package/dist/prompt.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAQ1D;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAqBrE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI logout command — clear stored authentication tokens.
|
|
3
|
+
*
|
|
4
|
+
* Removes the ~/.porta/credentials.json file, effectively logging out
|
|
5
|
+
* the CLI user. Does NOT revoke tokens on the server — the access token
|
|
6
|
+
* will expire naturally based on its TTL.
|
|
7
|
+
*
|
|
8
|
+
* This is a local-only operation that does not require a network connection
|
|
9
|
+
* or a running Porta server.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* porta logout
|
|
13
|
+
*
|
|
14
|
+
* @module commands/logout
|
|
15
|
+
*/
|
|
16
|
+
import { clearCredentials, loadCredentials } from '../credential-store.js';
|
|
17
|
+
import { success, warn } from '../output.js';
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Command Definition
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* The logout command module — clears stored CLI authentication tokens.
|
|
23
|
+
*
|
|
24
|
+
* Reads existing credentials to show who was logged in, then deletes
|
|
25
|
+
* the credentials file. Safe to run even when not logged in.
|
|
26
|
+
*/
|
|
27
|
+
export const logoutCommand = {
|
|
28
|
+
command: 'logout',
|
|
29
|
+
describe: 'Clear stored authentication tokens',
|
|
30
|
+
handler: async () => {
|
|
31
|
+
// Check if there are existing credentials to clear
|
|
32
|
+
const existing = loadCredentials();
|
|
33
|
+
if (!existing) {
|
|
34
|
+
warn('Not logged in — nothing to clear.');
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
// Remove the credentials file
|
|
38
|
+
clearCredentials();
|
|
39
|
+
success(`Logged out${existing.userInfo.email ? ` (was: ${existing.userInfo.email})` : ''}`);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE7C,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgD;IACxE,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,oCAAoC;IAE9C,OAAO,EAAE,KAAK,IAAI,EAAE;QAClB,mDAAmD;QACnD,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;QAEnC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,mCAAmC,CAAC,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,8BAA8B;QAC9B,gBAAgB,EAAE,CAAC;QAEnB,OAAO,CACL,aAAa,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,QAAQ,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACnF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI organization management commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD and lifecycle management for organizations (tenants).
|
|
5
|
+
* All operations use the Porta SDK for Admin API communication.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* porta org create --name "Acme Corp" [--slug acme-corp] [--locale en]
|
|
9
|
+
* porta org list [--status active|suspended|archived] [--page 1] [--page-size 20]
|
|
10
|
+
* porta org show <id-or-slug>
|
|
11
|
+
* porta org update <id-or-slug> --name "New Name" [--default-locale fr]
|
|
12
|
+
* porta org suspend <id-or-slug>
|
|
13
|
+
* porta org activate <id-or-slug>
|
|
14
|
+
* porta org archive <id-or-slug>
|
|
15
|
+
* porta org restore <id-or-slug>
|
|
16
|
+
* porta org history <id-or-slug>
|
|
17
|
+
* porta org branding <id-or-slug> --primary-color "#..." [--company-name "..."]
|
|
18
|
+
* porta org destroy <id-or-slug>
|
|
19
|
+
*
|
|
20
|
+
* @module commands/org
|
|
21
|
+
*/
|
|
22
|
+
import type { CommandModule } from 'yargs';
|
|
23
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
24
|
+
/** The org command module — registered at the top level of the CLI */
|
|
25
|
+
export declare const orgCommand: CommandModule<GlobalOptions, GlobalOptions>;
|
|
26
|
+
//# sourceMappingURL=org.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.d.ts","sourceRoot":"","sources":["../../src/commands/org.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsD1D,sEAAsE;AACtE,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,aAAa,EAAE,aAAa,CAsdlE,CAAC"}
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI organization management commands.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD and lifecycle management for organizations (tenants).
|
|
5
|
+
* All operations use the Porta SDK for Admin API communication.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* porta org create --name "Acme Corp" [--slug acme-corp] [--locale en]
|
|
9
|
+
* porta org list [--status active|suspended|archived] [--page 1] [--page-size 20]
|
|
10
|
+
* porta org show <id-or-slug>
|
|
11
|
+
* porta org update <id-or-slug> --name "New Name" [--default-locale fr]
|
|
12
|
+
* porta org suspend <id-or-slug>
|
|
13
|
+
* porta org activate <id-or-slug>
|
|
14
|
+
* porta org archive <id-or-slug>
|
|
15
|
+
* porta org restore <id-or-slug>
|
|
16
|
+
* porta org history <id-or-slug>
|
|
17
|
+
* porta org branding <id-or-slug> --primary-color "#..." [--company-name "..."]
|
|
18
|
+
* porta org destroy <id-or-slug>
|
|
19
|
+
*
|
|
20
|
+
* @module commands/org
|
|
21
|
+
*/
|
|
22
|
+
import { createClient } from '../client-factory.js';
|
|
23
|
+
import { handleError } from '../error-handler.js';
|
|
24
|
+
import { printTable, printJson, success, warn, error, info, formatDate, truncate, } from '../output.js';
|
|
25
|
+
import { confirm, question } from '../prompt.js';
|
|
26
|
+
import { parseLoginMethods } from '../parsers.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Command definition
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/** The org command module — registered at the top level of the CLI */
|
|
31
|
+
export const orgCommand = {
|
|
32
|
+
command: 'org',
|
|
33
|
+
describe: 'Manage organizations',
|
|
34
|
+
builder: (yargs) => {
|
|
35
|
+
return yargs
|
|
36
|
+
// ── create ──────────────────────────────────────────────────────
|
|
37
|
+
.command('create', 'Create a new organization', (y) => y
|
|
38
|
+
.option('name', {
|
|
39
|
+
type: 'string',
|
|
40
|
+
demandOption: true,
|
|
41
|
+
description: 'Organization name',
|
|
42
|
+
})
|
|
43
|
+
.option('slug', {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: 'URL-friendly slug (auto-generated from name if omitted)',
|
|
46
|
+
})
|
|
47
|
+
.option('locale', {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Default locale (default: en)',
|
|
50
|
+
})
|
|
51
|
+
.option('login-methods', {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Comma-separated default login methods (password, magic_link)',
|
|
54
|
+
}), async (argv) => {
|
|
55
|
+
try {
|
|
56
|
+
const defaultLoginMethods = argv['login-methods']
|
|
57
|
+
? parseLoginMethods(argv['login-methods'])
|
|
58
|
+
: undefined;
|
|
59
|
+
const client = createClient(argv);
|
|
60
|
+
const org = await client.organizations.create({
|
|
61
|
+
name: argv.name,
|
|
62
|
+
slug: argv.slug,
|
|
63
|
+
defaultLocale: argv.locale,
|
|
64
|
+
...(defaultLoginMethods !== undefined && { defaultLoginMethods }),
|
|
65
|
+
});
|
|
66
|
+
if (argv.json) {
|
|
67
|
+
printJson(org);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
success(`Organization created: ${org.name} (${org.slug})`);
|
|
71
|
+
printTable(['Field', 'Value'], [
|
|
72
|
+
['ID', org.id],
|
|
73
|
+
['Name', org.name],
|
|
74
|
+
['Slug', org.slug],
|
|
75
|
+
['Status', org.status],
|
|
76
|
+
['Locale', org.defaultLocale],
|
|
77
|
+
['Default Login Methods', org.defaultLoginMethods.join(', ')],
|
|
78
|
+
['Created', formatDate(org.createdAt)],
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
handleError(err, argv.verbose);
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
// ── list ────────────────────────────────────────────────────────
|
|
87
|
+
.command('list', 'List organizations', (y) => y
|
|
88
|
+
.option('status', {
|
|
89
|
+
type: 'string',
|
|
90
|
+
choices: ['active', 'suspended', 'archived'],
|
|
91
|
+
description: 'Filter by status',
|
|
92
|
+
})
|
|
93
|
+
.option('page', {
|
|
94
|
+
type: 'number',
|
|
95
|
+
default: 1,
|
|
96
|
+
description: 'Page number',
|
|
97
|
+
})
|
|
98
|
+
.option('page-size', {
|
|
99
|
+
type: 'number',
|
|
100
|
+
default: 20,
|
|
101
|
+
description: 'Items per page',
|
|
102
|
+
}), async (argv) => {
|
|
103
|
+
try {
|
|
104
|
+
const client = createClient(argv);
|
|
105
|
+
const result = await client.organizations.list({
|
|
106
|
+
page: argv.page,
|
|
107
|
+
pageSize: argv['page-size'],
|
|
108
|
+
...(argv.status && { status: argv.status }),
|
|
109
|
+
});
|
|
110
|
+
if (result.data.length === 0) {
|
|
111
|
+
warn('No organizations found');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (argv.json) {
|
|
115
|
+
printJson(result);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
printTable(['ID', 'Name', 'Slug', 'Status', 'Created'], result.data.map((o) => [
|
|
119
|
+
truncate(o.id, 8),
|
|
120
|
+
o.name,
|
|
121
|
+
o.slug,
|
|
122
|
+
o.status,
|
|
123
|
+
formatDate(o.createdAt),
|
|
124
|
+
]));
|
|
125
|
+
info(`Total: ${result.total} organizations`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
handleError(err, argv.verbose);
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
// ── show ────────────────────────────────────────────────────────
|
|
133
|
+
.command('show <id-or-slug>', 'Show organization details', (y) => y.positional('id-or-slug', {
|
|
134
|
+
type: 'string',
|
|
135
|
+
demandOption: true,
|
|
136
|
+
description: 'Organization UUID or slug',
|
|
137
|
+
}), async (argv) => {
|
|
138
|
+
try {
|
|
139
|
+
const client = createClient(argv);
|
|
140
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
141
|
+
if (argv.json) {
|
|
142
|
+
printJson(org);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
printTable(['Field', 'Value'], [
|
|
146
|
+
['ID', org.id],
|
|
147
|
+
['Name', org.name],
|
|
148
|
+
['Slug', org.slug],
|
|
149
|
+
['Status', org.status],
|
|
150
|
+
['Super Admin', String(org.isSuperAdmin)],
|
|
151
|
+
['Default Locale', org.defaultLocale],
|
|
152
|
+
['Default Login Methods', org.defaultLoginMethods.join(', ')],
|
|
153
|
+
['Logo URL', org.brandingLogoUrl ?? '—'],
|
|
154
|
+
['Primary Color', org.brandingPrimaryColor ?? '—'],
|
|
155
|
+
['Created', formatDate(org.createdAt)],
|
|
156
|
+
['Updated', formatDate(org.updatedAt)],
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
handleError(err, argv.verbose);
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
// ── update ──────────────────────────────────────────────────────
|
|
165
|
+
.command('update <id-or-slug>', 'Update organization fields', (y) => y
|
|
166
|
+
.positional('id-or-slug', {
|
|
167
|
+
type: 'string',
|
|
168
|
+
demandOption: true,
|
|
169
|
+
description: 'Organization UUID or slug',
|
|
170
|
+
})
|
|
171
|
+
.option('name', {
|
|
172
|
+
type: 'string',
|
|
173
|
+
description: 'New organization name',
|
|
174
|
+
})
|
|
175
|
+
.option('default-locale', {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description: 'New default locale',
|
|
178
|
+
})
|
|
179
|
+
.option('login-methods', {
|
|
180
|
+
type: 'string',
|
|
181
|
+
description: 'Comma-separated default login methods (password, magic_link)',
|
|
182
|
+
}), async (argv) => {
|
|
183
|
+
try {
|
|
184
|
+
const defaultLoginMethods = argv['login-methods']
|
|
185
|
+
? parseLoginMethods(argv['login-methods'])
|
|
186
|
+
: undefined;
|
|
187
|
+
const client = createClient(argv);
|
|
188
|
+
const { data: current, etag } = await client.organizations.get(argv['id-or-slug']);
|
|
189
|
+
const updated = await client.organizations.update(current.id, {
|
|
190
|
+
name: argv.name,
|
|
191
|
+
defaultLocale: argv['default-locale'],
|
|
192
|
+
...(defaultLoginMethods !== undefined && { defaultLoginMethods }),
|
|
193
|
+
}, etag ?? undefined);
|
|
194
|
+
if (argv.json) {
|
|
195
|
+
printJson(updated);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
success(`Organization updated: ${updated.name} (${updated.slug})`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
handleError(err, argv.verbose);
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
// ── suspend ─────────────────────────────────────────────────────
|
|
206
|
+
.command('suspend <id-or-slug>', 'Suspend an organization', (y) => y.positional('id-or-slug', {
|
|
207
|
+
type: 'string',
|
|
208
|
+
demandOption: true,
|
|
209
|
+
description: 'Organization UUID or slug',
|
|
210
|
+
}), async (argv) => {
|
|
211
|
+
try {
|
|
212
|
+
const client = createClient(argv);
|
|
213
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
214
|
+
if (!argv.force) {
|
|
215
|
+
const confirmed = await confirm(`Suspend organization "${org.name}" (${org.slug})?`);
|
|
216
|
+
if (!confirmed) {
|
|
217
|
+
warn('Operation cancelled');
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
await client.organizations.suspend(org.id);
|
|
222
|
+
success(`Organization suspended: ${org.name} (${org.slug})`);
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
handleError(err, argv.verbose);
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
// ── activate ────────────────────────────────────────────────────
|
|
229
|
+
.command('activate <id-or-slug>', 'Activate a suspended organization', (y) => y.positional('id-or-slug', {
|
|
230
|
+
type: 'string',
|
|
231
|
+
demandOption: true,
|
|
232
|
+
description: 'Organization UUID or slug',
|
|
233
|
+
}), async (argv) => {
|
|
234
|
+
try {
|
|
235
|
+
const client = createClient(argv);
|
|
236
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
237
|
+
await client.organizations.activate(org.id);
|
|
238
|
+
success(`Organization activated: ${org.name} (${org.slug})`);
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
handleError(err, argv.verbose);
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
// ── archive ─────────────────────────────────────────────────────
|
|
245
|
+
.command('archive <id-or-slug>', 'Archive an organization (soft-delete)', (y) => y.positional('id-or-slug', {
|
|
246
|
+
type: 'string',
|
|
247
|
+
demandOption: true,
|
|
248
|
+
description: 'Organization UUID or slug',
|
|
249
|
+
}), async (argv) => {
|
|
250
|
+
try {
|
|
251
|
+
const client = createClient(argv);
|
|
252
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
253
|
+
if (!argv.force) {
|
|
254
|
+
const confirmed = await confirm(`Archive organization "${org.name}" (${org.slug})? This cannot be easily undone.`);
|
|
255
|
+
if (!confirmed) {
|
|
256
|
+
warn('Operation cancelled');
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
await client.organizations.archive(org.id);
|
|
261
|
+
success(`Organization archived: ${org.name} (${org.slug})`);
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
handleError(err, argv.verbose);
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
// ── restore (NEW) ──────────────────────────────────────────────
|
|
268
|
+
.command('restore <id-or-slug>', 'Restore an archived organization', (y) => y.positional('id-or-slug', {
|
|
269
|
+
type: 'string',
|
|
270
|
+
demandOption: true,
|
|
271
|
+
description: 'Organization UUID or slug',
|
|
272
|
+
}), async (argv) => {
|
|
273
|
+
try {
|
|
274
|
+
const client = createClient(argv);
|
|
275
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
276
|
+
await client.organizations.restore(org.id);
|
|
277
|
+
success(`Organization restored: ${org.name} (${org.slug})`);
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
handleError(err, argv.verbose);
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
// ── history (NEW) ──────────────────────────────────────────────
|
|
284
|
+
.command('history <id-or-slug>', 'Show organization change history', (y) => y.positional('id-or-slug', {
|
|
285
|
+
type: 'string',
|
|
286
|
+
demandOption: true,
|
|
287
|
+
description: 'Organization UUID or slug',
|
|
288
|
+
}), async (argv) => {
|
|
289
|
+
try {
|
|
290
|
+
const client = createClient(argv);
|
|
291
|
+
const history = await client.organizations.getHistory(argv['id-or-slug']);
|
|
292
|
+
if (history.length === 0) {
|
|
293
|
+
warn('No history entries found');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (argv.json) {
|
|
297
|
+
printJson(history);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
printTable(['Date', 'Action', 'Actor', 'Changes'], history.map((h) => [
|
|
301
|
+
formatDate(h.createdAt),
|
|
302
|
+
h.action,
|
|
303
|
+
h.performedBy ?? '—',
|
|
304
|
+
h.changes ? JSON.stringify(h.changes).slice(0, 60) : '—',
|
|
305
|
+
]));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
handleError(err, argv.verbose);
|
|
310
|
+
}
|
|
311
|
+
})
|
|
312
|
+
// ── branding ────────────────────────────────────────────────────
|
|
313
|
+
.command('branding <id-or-slug>', 'Update organization branding', (y) => y
|
|
314
|
+
.positional('id-or-slug', {
|
|
315
|
+
type: 'string',
|
|
316
|
+
demandOption: true,
|
|
317
|
+
description: 'Organization UUID or slug',
|
|
318
|
+
})
|
|
319
|
+
.option('primary-color', {
|
|
320
|
+
type: 'string',
|
|
321
|
+
description: 'Primary brand color (hex)',
|
|
322
|
+
})
|
|
323
|
+
.option('company-name', {
|
|
324
|
+
type: 'string',
|
|
325
|
+
description: 'Company display name',
|
|
326
|
+
})
|
|
327
|
+
.option('custom-css', {
|
|
328
|
+
type: 'string',
|
|
329
|
+
description: 'Custom CSS for login pages',
|
|
330
|
+
}), async (argv) => {
|
|
331
|
+
try {
|
|
332
|
+
const client = createClient(argv);
|
|
333
|
+
const { data: org } = await client.organizations.get(argv['id-or-slug']);
|
|
334
|
+
const result = await client.branding.updateSettings(org.id, {
|
|
335
|
+
brandingPrimaryColor: argv['primary-color'],
|
|
336
|
+
brandingCompanyName: argv['company-name'],
|
|
337
|
+
brandingCustomCss: argv['custom-css'],
|
|
338
|
+
});
|
|
339
|
+
if (argv.json) {
|
|
340
|
+
printJson(result);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
success(`Branding updated for: ${org.name} (${org.slug})`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
handleError(err, argv.verbose);
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
// ── destroy ─────────────────────────────────────────────────────
|
|
351
|
+
.command('destroy <id-or-slug>', 'Permanently destroy an organization and all its data (CASCADE)', (y) => y.positional('id-or-slug', {
|
|
352
|
+
type: 'string',
|
|
353
|
+
demandOption: true,
|
|
354
|
+
description: 'Organization UUID or slug',
|
|
355
|
+
}), async (argv) => {
|
|
356
|
+
try {
|
|
357
|
+
const client = createClient(argv);
|
|
358
|
+
const idOrSlug = argv['id-or-slug'];
|
|
359
|
+
// 1. Dry-run to get cascade counts
|
|
360
|
+
const preview = await client.organizations.destroy(idOrSlug, { dryRun: true });
|
|
361
|
+
const counts = preview.counts ?? {};
|
|
362
|
+
// 2. Resolve the org for display
|
|
363
|
+
const { data: org } = await client.organizations.get(idOrSlug);
|
|
364
|
+
// 3. Display what will be destroyed
|
|
365
|
+
console.log('');
|
|
366
|
+
warn('This will PERMANENTLY destroy the following:');
|
|
367
|
+
console.log('');
|
|
368
|
+
console.log(` Organization: ${org.name} (${org.slug})`);
|
|
369
|
+
for (const [entity, count] of Object.entries(counts)) {
|
|
370
|
+
const label = entity.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
371
|
+
console.log(` ${label.padEnd(20)} ${count}`);
|
|
372
|
+
}
|
|
373
|
+
console.log('');
|
|
374
|
+
// 4. Type-to-confirm (unless --force)
|
|
375
|
+
if (!argv.force) {
|
|
376
|
+
const confirmSlug = await question(`Type the organization slug "${org.slug}" to confirm destruction: `);
|
|
377
|
+
if (confirmSlug !== org.slug) {
|
|
378
|
+
error('Slug does not match. Destruction cancelled.');
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
// 5. Execute destruction
|
|
383
|
+
await client.organizations.destroy(idOrSlug);
|
|
384
|
+
success(`Organization "${org.name}" and all its data have been permanently destroyed.`);
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
handleError(err, argv.verbose);
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
.demandCommand(1, 'Specify an org subcommand: create, list, show, update, suspend, activate, archive, restore, history, branding, destroy');
|
|
391
|
+
},
|
|
392
|
+
handler: () => {
|
|
393
|
+
// No-op — subcommands handle execution
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.js","sourceRoot":"","sources":["../../src/commands/org.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW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O,GAAG,EAAE,CAAC;gBACb,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;QACH,CAAC,CACF;aACA,aAAa,CAAC,CAAC,EAAE,wHAAwH,CAAC,CAAC;IAChJ,CAAC;IACD,OAAO,EAAE,GAAG,EAAE;QACZ,uCAAuC;IACzC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provision command — declarative tenant infrastructure from YAML/JSON.
|
|
3
|
+
*
|
|
4
|
+
* Reads a YAML (or JSON) provisioning file with a nested structure
|
|
5
|
+
* (organizations → applications → clients/roles/permissions/claims),
|
|
6
|
+
* transforms it into the flat import manifest format, and sends it
|
|
7
|
+
* to the import API via the SDK. All entities are created in a single
|
|
8
|
+
* transaction.
|
|
9
|
+
*
|
|
10
|
+
* Supports three modes:
|
|
11
|
+
* merge (default): skip existing entities, create new
|
|
12
|
+
* overwrite: update existing entities, create new
|
|
13
|
+
* dry-run: preview what would change without applying
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* porta provision --file infrastructure.yaml
|
|
17
|
+
* porta provision --file infrastructure.yaml --dry-run
|
|
18
|
+
* porta provision --file infrastructure.yaml --mode overwrite
|
|
19
|
+
* porta provision --file infrastructure.yaml --json
|
|
20
|
+
*
|
|
21
|
+
* @module commands/provision
|
|
22
|
+
*/
|
|
23
|
+
import type { CommandModule } from 'yargs';
|
|
24
|
+
import type { GlobalOptions } from '../global-options.js';
|
|
25
|
+
/**
|
|
26
|
+
* Parse a duration string into a future Date.
|
|
27
|
+
*
|
|
28
|
+
* Supports: Nd (days), Nm (months), Ny (years), Nh (hours).
|
|
29
|
+
* Examples: "90d" (90 days), "6m" (6 months), "1y" (1 year), "24h" (24 hours).
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseDuration(duration: string): Date;
|
|
32
|
+
/**
|
|
33
|
+
* Read and parse a provisioning file from disk or stdin.
|
|
34
|
+
*
|
|
35
|
+
* Detects format by file extension (.yaml/.yml for YAML, .json for JSON).
|
|
36
|
+
* When reading from `/dev/stdin` (no extension), defaults to YAML parsing
|
|
37
|
+
* which also handles valid JSON since YAML is a superset of JSON.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseProvisioningFile(filePath: string): unknown;
|
|
40
|
+
interface ProvisionOptions extends GlobalOptions {
|
|
41
|
+
file: string;
|
|
42
|
+
mode: string;
|
|
43
|
+
'dry-run'?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const provisionCommand: CommandModule<GlobalOptions, ProvisionOptions>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=provision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../../src/commands/provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA4B1D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmBpD;AAMD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAoB/D;AAudD,UAAU,gBAAiB,SAAQ,aAAa;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,aAAa,EAAE,gBAAgB,CA0F3E,CAAC"}
|