@logto/cli 1.3.0 → 1.5.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.
|
@@ -18,5 +18,13 @@ export declare const getConnectorDirectory: (instancePath: string) => string;
|
|
|
18
18
|
export declare const isOfficialConnector: (packageName: string) => boolean;
|
|
19
19
|
export declare const getConnectorPackagesFrom: (instancePath?: string) => Promise<import("../../utils.js").ConnectorPackage[]>;
|
|
20
20
|
export declare const getLocalConnectorPackages: (instancePath: string) => Promise<(readonly [string, string])[]>;
|
|
21
|
+
export declare const addConnectorsToPath: (cwd: string, packageNames: string[]) => Promise<void>;
|
|
21
22
|
export declare const addConnectors: (instancePath: string, packageNames: string[]) => Promise<void>;
|
|
23
|
+
type PackageMeta = {
|
|
24
|
+
name: string;
|
|
25
|
+
scope: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const fetchOfficialConnectorList: (includingCloudConnectors?: boolean) => Promise<PackageMeta[]>;
|
|
22
29
|
export declare const addOfficialConnectors: (instancePath: string, includingCloudConnectors?: boolean) => Promise<void>;
|
|
30
|
+
export {};
|
|
@@ -93,8 +93,7 @@ export const getLocalConnectorPackages = async (instancePath) => {
|
|
|
93
93
|
}
|
|
94
94
|
return packages.map(({ name }) => [name, path.join(directory, name)]);
|
|
95
95
|
};
|
|
96
|
-
export const
|
|
97
|
-
const cwd = getConnectorDirectory(instancePath);
|
|
96
|
+
export const addConnectorsToPath = async (cwd, packageNames) => {
|
|
98
97
|
if (!existsSync(cwd)) {
|
|
99
98
|
await fs.mkdir(cwd, { recursive: true });
|
|
100
99
|
}
|
|
@@ -138,8 +137,12 @@ export const addConnectors = async (instancePath, packageNames) => {
|
|
|
138
137
|
consoleLog.warn('Failed to add ' + errorPackages.map((name) => chalk.green(name)).join(', '));
|
|
139
138
|
}
|
|
140
139
|
};
|
|
140
|
+
export const addConnectors = async (instancePath, packageNames) => {
|
|
141
|
+
const cwd = getConnectorDirectory(instancePath);
|
|
142
|
+
await addConnectorsToPath(cwd, packageNames);
|
|
143
|
+
};
|
|
141
144
|
const officialConnectorPrefix = '@logto/connector-';
|
|
142
|
-
const fetchOfficialConnectorList = async (includingCloudConnectors = false) => {
|
|
145
|
+
export const fetchOfficialConnectorList = async (includingCloudConnectors = false) => {
|
|
143
146
|
const fetchList = async (from = 0, size = 20) => {
|
|
144
147
|
const parameters = new URLSearchParams({
|
|
145
148
|
text: officialConnectorPrefix,
|
|
@@ -8,8 +8,8 @@ import { getDatabaseName } from '../../../queries/database.js';
|
|
|
8
8
|
export const createTenant = async (pool, tenantId) => {
|
|
9
9
|
const database = await getDatabaseName(pool, true);
|
|
10
10
|
const { parentRole, role, password } = createTenantMetadata(database, tenantId);
|
|
11
|
-
const
|
|
12
|
-
await pool.query(insertInto(
|
|
11
|
+
const createTenant = { id: tenantId, dbUser: role, dbUserPassword: password };
|
|
12
|
+
await pool.query(insertInto(createTenant, 'tenants'));
|
|
13
13
|
await pool.query(sql `
|
|
14
14
|
create role ${sql.identifier([role])} with inherit login
|
|
15
15
|
password '${raw(password)}'
|
|
@@ -17,8 +17,8 @@ export const createTenant = async (pool, tenantId) => {
|
|
|
17
17
|
`);
|
|
18
18
|
};
|
|
19
19
|
export const seedAdminData = async (pool, data, ...additionalScopes) => {
|
|
20
|
-
const { resource,
|
|
21
|
-
assert(resource.tenantId === scope.tenantId && scope.tenantId === role.tenantId, new Error('All data should have the same tenant ID'));
|
|
20
|
+
const { resource, scopes, role } = data;
|
|
21
|
+
assert(scopes.every((scope) => resource.tenantId === scope.tenantId && scope.tenantId === role.tenantId), new Error('All data should have the same tenant ID'));
|
|
22
22
|
const processRole = async () => {
|
|
23
23
|
if ('id' in role) {
|
|
24
24
|
await pool.query(insertInto(role, 'roles'));
|
|
@@ -33,15 +33,14 @@ export const seedAdminData = async (pool, data, ...additionalScopes) => {
|
|
|
33
33
|
return id;
|
|
34
34
|
};
|
|
35
35
|
await pool.query(insertInto(resource, 'resources'));
|
|
36
|
-
await pool.query(insertInto(scope, 'scopes'));
|
|
37
|
-
await Promise.all(additionalScopes.map(async (scope) => pool.query(insertInto(scope, 'scopes'))));
|
|
36
|
+
await Promise.all([...scopes, ...additionalScopes].map(async (scope) => pool.query(insertInto(scope, 'scopes'))));
|
|
38
37
|
const roleId = await processRole();
|
|
39
|
-
await pool.query(insertInto({
|
|
38
|
+
await Promise.all(scopes.map(async ({ id }) => pool.query(insertInto({
|
|
40
39
|
id: generateStandardId(),
|
|
41
40
|
roleId,
|
|
42
|
-
scopeId:
|
|
41
|
+
scopeId: id,
|
|
43
42
|
tenantId: resource.tenantId,
|
|
44
|
-
}, 'roles_scopes'));
|
|
43
|
+
}, 'roles_scopes'))));
|
|
45
44
|
};
|
|
46
45
|
export const assignScopesToRole = async (pool, tenantId, roleId, ...scopeIds) => {
|
|
47
46
|
await Promise.all(scopeIds.map(async (scopeId) => pool.query(insertInto({
|
|
@@ -8,7 +8,7 @@ const sync = {
|
|
|
8
8
|
command: ['sync'],
|
|
9
9
|
describe: 'Translate all untranslated phrases using ChatGPT. Note the environment variable `OPENAI_API_KEY` is required to work.',
|
|
10
10
|
handler: async ({ path: inputPath }) => {
|
|
11
|
-
const queue = new PQueue({ concurrency:
|
|
11
|
+
const queue = new PQueue({ concurrency: 1 });
|
|
12
12
|
const instancePath = await inquireInstancePath(inputPath);
|
|
13
13
|
for (const languageTag of Object.keys(languages)) {
|
|
14
14
|
if (languageTag === baseLanguage) {
|
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.5.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -46,9 +46,9 @@ export const packageJson = {
|
|
|
46
46
|
"@logto/connector-kit": "workspace:^1.1.1",
|
|
47
47
|
"@logto/core-kit": "workspace:^2.0.0",
|
|
48
48
|
"@logto/language-kit": "workspace:^1.0.0",
|
|
49
|
-
"@logto/phrases": "workspace:^1.
|
|
49
|
+
"@logto/phrases": "workspace:^1.4.0",
|
|
50
50
|
"@logto/phrases-ui": "workspace:^1.2.0",
|
|
51
|
-
"@logto/schemas": "workspace:1.
|
|
51
|
+
"@logto/schemas": "workspace:1.5.0",
|
|
52
52
|
"@logto/shared": "workspace:^2.0.0",
|
|
53
53
|
"@silverhand/essentials": "^2.5.0",
|
|
54
54
|
"chalk": "^5.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Logto CLI.",
|
|
5
5
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
6
6
|
"homepage": "https://github.com/logto-io/logto#readme",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@logto/connector-kit": "^1.1.1",
|
|
32
32
|
"@logto/core-kit": "^2.0.0",
|
|
33
33
|
"@logto/language-kit": "^1.0.0",
|
|
34
|
-
"@logto/phrases": "^1.
|
|
34
|
+
"@logto/phrases": "^1.4.0",
|
|
35
35
|
"@logto/phrases-ui": "^1.2.0",
|
|
36
|
-
"@logto/schemas": "1.
|
|
36
|
+
"@logto/schemas": "1.5.0",
|
|
37
37
|
"@logto/shared": "^2.0.0",
|
|
38
38
|
"@silverhand/essentials": "^2.5.0",
|
|
39
39
|
"chalk": "^5.0.0",
|