@logto/cli 1.15.0 → 1.17.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/lib/commands/connector/utils.js +2 -2
- package/lib/commands/database/alteration/index.d.ts +2 -2
- package/lib/commands/database/seed/roles.d.ts +8 -0
- package/lib/commands/database/seed/roles.js +33 -0
- package/lib/commands/database/seed/tables.js +8 -0
- package/lib/commands/database/seed/tenant.js +2 -2
- package/lib/commands/install/utils.js +2 -2
- package/lib/commands/translate/sync-keys/utils.js +2 -2
- package/lib/package-json.js +13 -13
- package/lib/utils.js +1 -1
- package/package.json +13 -13
|
@@ -8,7 +8,7 @@ import chalk from 'chalk';
|
|
|
8
8
|
import { got } from 'got';
|
|
9
9
|
import pLimit from 'p-limit';
|
|
10
10
|
import pRetry from 'p-retry';
|
|
11
|
-
import
|
|
11
|
+
import { extract } from 'tar';
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { connectorDirectory, coreDirectory } from '../../constants.js';
|
|
14
14
|
import { consoleLog, getConnectorPackagesFromDirectory, inquireInstancePath, oraPromise, } from '../../utils.js';
|
|
@@ -68,7 +68,7 @@ export const addConnectorsToPath = async (cwd, packageNames) => {
|
|
|
68
68
|
const packageDirectory = path.join(cwd, name.replaceAll('/', '-'));
|
|
69
69
|
await fs.rm(packageDirectory, { force: true, recursive: true });
|
|
70
70
|
await fs.mkdir(packageDirectory, { recursive: true });
|
|
71
|
-
await
|
|
71
|
+
await extract({ cwd: packageDirectory, file: tarPath, strip: 1 });
|
|
72
72
|
await fs.unlink(tarPath);
|
|
73
73
|
consoleLog.succeed(`Added ${chalk.green(name)} v${version}`);
|
|
74
74
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonQueryMethods } from '@silverhand/slonik';
|
|
2
2
|
import type { CommandModule } from 'yargs';
|
|
3
3
|
import type { AlterationFile } from './type.js';
|
|
4
4
|
export declare const getLatestAlterationTimestamp: () => Promise<number>;
|
|
5
|
-
export declare const getAvailableAlterations: (pool:
|
|
5
|
+
export declare const getAvailableAlterations: (pool: CommonQueryMethods, compareMode?: 'gt' | 'lte') => Promise<AlterationFile[]>;
|
|
6
6
|
declare const alteration: CommandModule<unknown, {
|
|
7
7
|
action: string;
|
|
8
8
|
target?: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CommonQueryMethods } from '@silverhand/slonik';
|
|
2
|
+
/**
|
|
3
|
+
* Create a pre-configured role with Management API access
|
|
4
|
+
*
|
|
5
|
+
* Caution:
|
|
6
|
+
* This function should only be called after the tenant's Management API resource and the related all scope have been created.
|
|
7
|
+
*/
|
|
8
|
+
export declare const seedPreConfiguredManagementApiAccessRole: (pool: CommonQueryMethods, tenantId: string) => Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PredefinedScope, getManagementApiResourceIndicator, createPreConfiguredManagementApiAccessRole, } from '@logto/schemas';
|
|
2
|
+
import { generateStandardId } from '@logto/shared';
|
|
3
|
+
import { sql } from '@silverhand/slonik';
|
|
4
|
+
import { insertInto } from '../../../database.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create a pre-configured role with Management API access
|
|
7
|
+
*
|
|
8
|
+
* Caution:
|
|
9
|
+
* This function should only be called after the tenant's Management API resource and the related all scope have been created.
|
|
10
|
+
*/
|
|
11
|
+
export const seedPreConfiguredManagementApiAccessRole = async (pool, tenantId) => {
|
|
12
|
+
const role = createPreConfiguredManagementApiAccessRole(tenantId);
|
|
13
|
+
await pool.query(insertInto(role, 'roles'));
|
|
14
|
+
// Assign Logto Management API permission `all` to the Logto Management API M2M role
|
|
15
|
+
await pool.query(sql `
|
|
16
|
+
insert into roles_scopes (id, role_id, scope_id, tenant_id)
|
|
17
|
+
values (
|
|
18
|
+
${generateStandardId()},
|
|
19
|
+
${role.id},
|
|
20
|
+
(
|
|
21
|
+
select scopes.id
|
|
22
|
+
from scopes
|
|
23
|
+
join resources on
|
|
24
|
+
scopes.tenant_id = resources.tenant_id and
|
|
25
|
+
scopes.resource_id = resources.id
|
|
26
|
+
where resources.indicator = ${getManagementApiResourceIndicator(tenantId)}
|
|
27
|
+
and scopes.name = ${PredefinedScope.All}
|
|
28
|
+
and scopes.tenant_id = ${tenantId}
|
|
29
|
+
),
|
|
30
|
+
${tenantId}
|
|
31
|
+
)
|
|
32
|
+
`);
|
|
33
|
+
};
|
|
@@ -12,6 +12,7 @@ import { convertToIdentifiers } from '../../../sql.js';
|
|
|
12
12
|
import { consoleLog, getPathInModule } from '../../../utils.js';
|
|
13
13
|
import { appendAdminConsoleRedirectUris, seedTenantCloudServiceApplication } from './cloud.js';
|
|
14
14
|
import { seedOidcConfigs } from './oidc-config.js';
|
|
15
|
+
import { seedPreConfiguredManagementApiAccessRole } from './roles.js';
|
|
15
16
|
import { seedTenantOrganizations } from './tenant-organizations.js';
|
|
16
17
|
import { assignScopesToRole, createTenant, seedAdminData, seedLegacyManagementApiUserRole, seedManagementApiProxyApplications, } from './tenant.js';
|
|
17
18
|
const getExplicitOrder = (query) => {
|
|
@@ -81,6 +82,13 @@ export const seedTables = async (connection, latestTimestamp, isCloud) => {
|
|
|
81
82
|
await createTenant(connection, defaultTenantId);
|
|
82
83
|
await seedOidcConfigs(connection, defaultTenantId);
|
|
83
84
|
await seedAdminData(connection, defaultManagementApi);
|
|
85
|
+
/**
|
|
86
|
+
* Create a pre-configured role for the Logto Management API access
|
|
87
|
+
* in the default tenant (the default tenant is the only tenant for the OSS version, and the initial tenant for cloud).
|
|
88
|
+
*
|
|
89
|
+
* Called after the default tenant's Management API resource and the related all scope have been created.
|
|
90
|
+
*/
|
|
91
|
+
await seedPreConfiguredManagementApiAccessRole(connection, defaultTenantId);
|
|
84
92
|
await createTenant(connection, adminTenantId);
|
|
85
93
|
await seedOidcConfigs(connection, adminTenantId);
|
|
86
94
|
await seedAdminData(connection, createAdminDataInAdminTenant(defaultTenantId));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createTenantDatabaseMetadata } from '@logto/core-kit';
|
|
2
2
|
import { defaultTenantId, adminTenantId, Applications, ApplicationsRoles, getMapiProxyM2mApp, getMapiProxyRole, defaultManagementApiAdminName, Roles, PredefinedScope, getManagementApiResourceIndicator, } from '@logto/schemas';
|
|
3
3
|
import { generateStandardId } from '@logto/shared';
|
|
4
4
|
import { assert } from '@silverhand/essentials';
|
|
@@ -8,7 +8,7 @@ import { getDatabaseName } from '../../../queries/database.js';
|
|
|
8
8
|
import { consoleLog } from '../../../utils.js';
|
|
9
9
|
export const createTenant = async (pool, tenantId) => {
|
|
10
10
|
const database = await getDatabaseName(pool, true);
|
|
11
|
-
const { parentRole, role, password } =
|
|
11
|
+
const { parentRole, role, password } = createTenantDatabaseMetadata(database, tenantId);
|
|
12
12
|
const createTenant = {
|
|
13
13
|
id: tenantId,
|
|
14
14
|
dbUser: role,
|
|
@@ -8,7 +8,7 @@ import chalk from 'chalk';
|
|
|
8
8
|
import { got, RequestError } from 'got';
|
|
9
9
|
import inquirer from 'inquirer';
|
|
10
10
|
import * as semver from 'semver';
|
|
11
|
-
import
|
|
11
|
+
import { extract } from 'tar';
|
|
12
12
|
import { defaultPath } from '../../constants.js';
|
|
13
13
|
import { createPoolAndDatabaseIfNeeded } from '../../database.js';
|
|
14
14
|
import { packageJson } from '../../package-json.js';
|
|
@@ -98,7 +98,7 @@ export const decompress = async (toPath, tarPath) => {
|
|
|
98
98
|
const run = async () => {
|
|
99
99
|
try {
|
|
100
100
|
await fs.mkdir(toPath);
|
|
101
|
-
await
|
|
101
|
+
await extract({ file: tarPath, cwd: toPath, strip: 1 });
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
104
|
consoleLog.fatal(error);
|
|
@@ -205,7 +205,7 @@ const traverseNode = async (baseline, targetObject, targetFilePath, isRoot = fal
|
|
|
205
205
|
await fs.mkdir(targetDirectory, { recursive: true });
|
|
206
206
|
await fs.writeFile(targetFilePath, '', { flag: 'w+' });
|
|
207
207
|
if (isRoot) {
|
|
208
|
-
await fs.appendFile(targetFilePath, "import type { LocalePhrase } from '../../types.js';\n\n");
|
|
208
|
+
await fs.appendFile(targetFilePath, "import { type DeepPartial } from '@silverhand/essentials';\n\nimport type { LocalePhrase } from '../../types.js';\n\n");
|
|
209
209
|
}
|
|
210
210
|
// Write imports first
|
|
211
211
|
const baselineEntries = getCurrentFileImports(baselineStructure);
|
|
@@ -267,7 +267,7 @@ const traverseNode = async (baseline, targetObject, targetFilePath, isRoot = fal
|
|
|
267
267
|
};
|
|
268
268
|
await traverseObject(baseline, targetObject, 2);
|
|
269
269
|
await (isRoot
|
|
270
|
-
? fs.appendFile(targetFilePath, '} satisfies LocalePhrase
|
|
270
|
+
? fs.appendFile(targetFilePath, '} satisfies DeepPartial<LocalePhrase>;\n\n')
|
|
271
271
|
: fs.appendFile(targetFilePath, '};\n\n'));
|
|
272
272
|
await fs.appendFile(targetFilePath, `export default Object.freeze(${identifier});\n`);
|
|
273
273
|
};
|
package/lib/package-json.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const packageJson = {
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -43,13 +43,13 @@ export const packageJson = {
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@logto/connector-kit": "workspace:^3.0.0",
|
|
46
|
-
"@logto/core-kit": "workspace:^2.
|
|
46
|
+
"@logto/core-kit": "workspace:^2.5.0",
|
|
47
47
|
"@logto/language-kit": "workspace:^1.1.0",
|
|
48
|
-
"@logto/phrases": "workspace:^1.
|
|
48
|
+
"@logto/phrases": "workspace:^1.11.0",
|
|
49
49
|
"@logto/phrases-experience": "workspace:^1.6.1",
|
|
50
|
-
"@logto/schemas": "workspace:1.
|
|
51
|
-
"@logto/shared": "workspace:^3.1.
|
|
52
|
-
"@silverhand/essentials": "^2.9.
|
|
50
|
+
"@logto/schemas": "workspace:1.17.0",
|
|
51
|
+
"@logto/shared": "workspace:^3.1.1",
|
|
52
|
+
"@silverhand/essentials": "^2.9.1",
|
|
53
53
|
"@silverhand/slonik": "31.0.0-beta.2",
|
|
54
54
|
"chalk": "^5.0.0",
|
|
55
55
|
"decamelize": "^6.0.0",
|
|
@@ -65,26 +65,26 @@ export const packageJson = {
|
|
|
65
65
|
"pg-protocol": "^1.6.0",
|
|
66
66
|
"roarr": "^7.11.0",
|
|
67
67
|
"semver": "^7.3.8",
|
|
68
|
-
"tar": "^
|
|
68
|
+
"tar": "^7.0.0",
|
|
69
69
|
"typescript": "^5.3.3",
|
|
70
70
|
"yargs": "^17.6.0",
|
|
71
71
|
"zod": "^3.22.4"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@silverhand/eslint-config": "
|
|
75
|
-
"@silverhand/ts-config": "
|
|
74
|
+
"@silverhand/eslint-config": "6.0.1",
|
|
75
|
+
"@silverhand/ts-config": "6.0.0",
|
|
76
76
|
"@types/inquirer": "^9.0.0",
|
|
77
77
|
"@types/node": "^20.9.5",
|
|
78
78
|
"@types/semver": "^7.3.12",
|
|
79
79
|
"@types/sinon": "^17.0.0",
|
|
80
|
-
"@types/tar": "^6.1.
|
|
80
|
+
"@types/tar": "^6.1.12",
|
|
81
81
|
"@types/yargs": "^17.0.13",
|
|
82
82
|
"@vitest/coverage-v8": "^1.4.0",
|
|
83
|
-
"@withtyped/server": "^0.13.
|
|
84
|
-
"eslint": "^8.
|
|
83
|
+
"@withtyped/server": "^0.13.6",
|
|
84
|
+
"eslint": "^8.56.0",
|
|
85
85
|
"lint-staged": "^15.0.0",
|
|
86
86
|
"prettier": "^3.0.0",
|
|
87
|
-
"sinon": "^
|
|
87
|
+
"sinon": "^18.0.0",
|
|
88
88
|
"vitest": "^1.4.0"
|
|
89
89
|
},
|
|
90
90
|
"eslintConfig": {
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@logto/connector-kit": "^3.0.0",
|
|
32
|
-
"@logto/core-kit": "^2.
|
|
32
|
+
"@logto/core-kit": "^2.5.0",
|
|
33
33
|
"@logto/language-kit": "^1.1.0",
|
|
34
|
-
"@logto/phrases": "^1.
|
|
34
|
+
"@logto/phrases": "^1.11.0",
|
|
35
35
|
"@logto/phrases-experience": "^1.6.1",
|
|
36
|
-
"@logto/schemas": "1.
|
|
37
|
-
"@logto/shared": "^3.1.
|
|
38
|
-
"@silverhand/essentials": "^2.9.
|
|
36
|
+
"@logto/schemas": "1.17.0",
|
|
37
|
+
"@logto/shared": "^3.1.1",
|
|
38
|
+
"@silverhand/essentials": "^2.9.1",
|
|
39
39
|
"@silverhand/slonik": "31.0.0-beta.2",
|
|
40
40
|
"chalk": "^5.0.0",
|
|
41
41
|
"decamelize": "^6.0.0",
|
|
@@ -51,26 +51,26 @@
|
|
|
51
51
|
"pg-protocol": "^1.6.0",
|
|
52
52
|
"roarr": "^7.11.0",
|
|
53
53
|
"semver": "^7.3.8",
|
|
54
|
-
"tar": "^
|
|
54
|
+
"tar": "^7.0.0",
|
|
55
55
|
"typescript": "^5.3.3",
|
|
56
56
|
"yargs": "^17.6.0",
|
|
57
57
|
"zod": "^3.22.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@silverhand/eslint-config": "
|
|
61
|
-
"@silverhand/ts-config": "
|
|
60
|
+
"@silverhand/eslint-config": "6.0.1",
|
|
61
|
+
"@silverhand/ts-config": "6.0.0",
|
|
62
62
|
"@types/inquirer": "^9.0.0",
|
|
63
63
|
"@types/node": "^20.9.5",
|
|
64
64
|
"@types/semver": "^7.3.12",
|
|
65
65
|
"@types/sinon": "^17.0.0",
|
|
66
|
-
"@types/tar": "^6.1.
|
|
66
|
+
"@types/tar": "^6.1.12",
|
|
67
67
|
"@types/yargs": "^17.0.13",
|
|
68
68
|
"@vitest/coverage-v8": "^1.4.0",
|
|
69
|
-
"@withtyped/server": "^0.13.
|
|
70
|
-
"eslint": "^8.
|
|
69
|
+
"@withtyped/server": "^0.13.6",
|
|
70
|
+
"eslint": "^8.56.0",
|
|
71
71
|
"lint-staged": "^15.0.0",
|
|
72
72
|
"prettier": "^3.0.0",
|
|
73
|
-
"sinon": "^
|
|
73
|
+
"sinon": "^18.0.0",
|
|
74
74
|
"vitest": "^1.4.0"
|
|
75
75
|
},
|
|
76
76
|
"eslintConfig": {
|