@logto/cli 1.24.0 → 1.25.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.
@@ -24,6 +24,23 @@ type PackageMeta = {
24
24
  scope: string;
25
25
  version: string;
26
26
  };
27
+ /**
28
+ * This function fetches the list of Logto official connectors from the NPM registry.
29
+ *
30
+ * @remarks
31
+ * This fetching logic is based on the NPM registry API.
32
+ * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search}
33
+ *
34
+ * @remarks
35
+ * Known limitations of the NPM registry API:
36
+ * 1. The `fetchList` API request performs a 'fuzzy' search using the `text` parameter with the package name prefix `@logto/connector-`, resulting in many irrelevant results (over 1000), making it difficult to filter all official connectors.
37
+ * 2. The `scope:logto` search qualifier does not function as intended, failing to properly filter `@logto` scope packages.
38
+ *
39
+ * To mitigate these limitations:
40
+ * - We replace `scope:logto` with the `maintainer:gaosun` qualifier to reduce irrelevant results, which helps in filtering official connectors.
41
+ * - In addition to the API search, we filter results by checking the package name prefix `@logto/connector-`.
42
+ * - We continue fetching pages from the registry search API until the last page, applying the above filtering logic to compile the final list of official connectors.
43
+ */
27
44
  export declare const fetchOfficialConnectorList: (includingCloudConnectors?: boolean) => Promise<PackageMeta[]>;
28
45
  export declare const addOfficialConnectors: (instancePath: string, includingCloudConnectors?: boolean) => Promise<void>;
29
46
  export {};
@@ -96,10 +96,28 @@ export const addConnectors = async (instancePath, packageNames) => {
96
96
  await addConnectorsToPath(cwd, packageNames);
97
97
  };
98
98
  const officialConnectorPrefix = '@logto/connector-';
99
+ const maintainer = 'gaosun';
100
+ /**
101
+ * This function fetches the list of Logto official connectors from the NPM registry.
102
+ *
103
+ * @remarks
104
+ * This fetching logic is based on the NPM registry API.
105
+ * @see {@link https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search}
106
+ *
107
+ * @remarks
108
+ * Known limitations of the NPM registry API:
109
+ * 1. The `fetchList` API request performs a 'fuzzy' search using the `text` parameter with the package name prefix `@logto/connector-`, resulting in many irrelevant results (over 1000), making it difficult to filter all official connectors.
110
+ * 2. The `scope:logto` search qualifier does not function as intended, failing to properly filter `@logto` scope packages.
111
+ *
112
+ * To mitigate these limitations:
113
+ * - We replace `scope:logto` with the `maintainer:gaosun` qualifier to reduce irrelevant results, which helps in filtering official connectors.
114
+ * - In addition to the API search, we filter results by checking the package name prefix `@logto/connector-`.
115
+ * - We continue fetching pages from the registry search API until the last page, applying the above filtering logic to compile the final list of official connectors.
116
+ */
99
117
  export const fetchOfficialConnectorList = async (includingCloudConnectors = false) => {
100
118
  const fetchList = async (from = 0, size = 20) => {
101
119
  const parameters = new URLSearchParams({
102
- text: officialConnectorPrefix,
120
+ text: `${officialConnectorPrefix} maintainer:${maintainer}`,
103
121
  from: String(from),
104
122
  size: String(size),
105
123
  });
@@ -107,8 +125,6 @@ export const fetchOfficialConnectorList = async (includingCloudConnectors = fals
107
125
  };
108
126
  const packages = [];
109
127
  const excludeList = ['mock', 'kit', ...conditionalArray(!includingCloudConnectors && 'logto')];
110
- // The API called by `fetchList` performs a 'fuzzy' search based on the `text` parameter, which will yield many irrelevant results. We need to filter out these irrelevant results (using `name.startsWith(officialConnectorPrefix)` for filtering).
111
- // Disable lint rules for business need
112
128
  // eslint-disable-next-line @silverhand/fp/no-let, @silverhand/fp/no-mutation
113
129
  for (let page = 0;; ++page) {
114
130
  // eslint-disable-next-line no-await-in-loop
@@ -117,7 +133,7 @@ export const fetchOfficialConnectorList = async (includingCloudConnectors = fals
117
133
  excludeList.every((excluded) => !name.slice(officialConnectorPrefix.length).startsWith(excluded)));
118
134
  // eslint-disable-next-line @silverhand/fp/no-mutating-methods
119
135
  packages.push(...objects.map(({ package: data }) => data));
120
- if (objects.length < 20) {
136
+ if (rawObjects.length < 20) {
121
137
  break;
122
138
  }
123
139
  }
@@ -1,11 +1,11 @@
1
- import type { AllConnector, BaseConnector, ConnectorMetadata, GetConnectorConfig, GetCloudServiceClient } from '@logto/connector-kit';
1
+ import type { AllConnector, BaseConnector, ConnectorMetadata, GetConnectorConfig, GetCloudServiceClient, GetI18nEmailTemplate, EmailConnector } from '@logto/connector-kit';
2
2
  import { ConnectorType } from '@logto/connector-kit';
3
3
  import type { BaseRoutes, Router } from '@withtyped/server';
4
4
  import type { ConnectorFactory } from './types.js';
5
5
  export declare function validateConnectorModule(connector: Partial<BaseConnector<ConnectorType>>): asserts connector is BaseConnector<ConnectorType>;
6
6
  export declare const readUrl: (url: string, baseUrl: string, type: "text" | "image") => Promise<string>;
7
7
  export declare const parseMetadata: (metadata: AllConnector["metadata"], packagePath: string) => Promise<AllConnector["metadata"]>;
8
- export declare const buildRawConnector: <T extends Router<any, any, BaseRoutes, string>, U extends AllConnector = AllConnector>(connectorFactory: ConnectorFactory<T, U>, getConnectorConfig?: GetConnectorConfig, getCloudServiceClient?: GetCloudServiceClient<T>) => Promise<{
8
+ export declare const buildRawConnector: <T extends Router<any, any, BaseRoutes, string>, U extends AllConnector = AllConnector>(connectorFactory: ConnectorFactory<T, U>, getConnectorConfig?: GetConnectorConfig, getCloudServiceClient?: GetCloudServiceClient<T>, getI18nEmailTemplate?: U extends EmailConnector ? GetI18nEmailTemplate : undefined) => Promise<{
9
9
  rawConnector: U;
10
10
  rawMetadata: ConnectorMetadata;
11
11
  }>;
@@ -51,11 +51,12 @@ export const parseMetadata = async (metadata, packagePath) => {
51
51
  configTemplate: metadata.configTemplate && (await readUrl(metadata.configTemplate, packagePath, 'text')),
52
52
  };
53
53
  };
54
- export const buildRawConnector = async (connectorFactory, getConnectorConfig, getCloudServiceClient) => {
54
+ export const buildRawConnector = async (connectorFactory, getConnectorConfig, getCloudServiceClient, getI18nEmailTemplate) => {
55
55
  const { createConnector, path: packagePath } = connectorFactory;
56
56
  const rawConnector = await createConnector({
57
57
  getConfig: getConnectorConfig ?? notImplemented,
58
58
  getCloudServiceClient,
59
+ getI18nEmailTemplate,
59
60
  });
60
61
  validateConnectorModule(rawConnector);
61
62
  const rawMetadata = await parseMetadata(rawConnector.metadata, packagePath);
@@ -1,6 +1,6 @@
1
1
  export const packageJson = {
2
2
  "name": "@logto/cli",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Logto CLI.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "homepage": "https://github.com/logto-io/logto#readme",
@@ -42,10 +42,10 @@ export const packageJson = {
42
42
  "url": "https://github.com/logto-io/logto/issues"
43
43
  },
44
44
  "dependencies": {
45
- "@logto/connector-kit": "workspace:^4.1.0",
46
- "@logto/core-kit": "workspace:^2.5.2",
47
- "@logto/schemas": "workspace:1.24.0",
48
- "@logto/shared": "workspace:^3.1.2",
45
+ "@logto/connector-kit": "workspace:^4.2.0",
46
+ "@logto/core-kit": "workspace:^2.5.4",
47
+ "@logto/schemas": "workspace:1.25.0",
48
+ "@logto/shared": "workspace:^3.1.4",
49
49
  "@silverhand/essentials": "^2.9.1",
50
50
  "@silverhand/slonik": "31.0.0-beta.2",
51
51
  "chalk": "^5.3.0",
@@ -73,14 +73,14 @@ export const packageJson = {
73
73
  "@types/sinon": "^17.0.0",
74
74
  "@types/tar": "^6.1.12",
75
75
  "@types/yargs": "^17.0.13",
76
- "@vitest/coverage-v8": "^2.1.8",
76
+ "@vitest/coverage-v8": "^2.1.9",
77
77
  "@withtyped/server": "^0.14.0",
78
78
  "eslint": "^8.56.0",
79
79
  "lint-staged": "^15.0.0",
80
80
  "prettier": "^3.0.0",
81
81
  "sinon": "^19.0.0",
82
82
  "typescript": "^5.5.3",
83
- "vitest": "^2.1.8"
83
+ "vitest": "^2.1.9"
84
84
  },
85
85
  "eslintConfig": {
86
86
  "extends": "@silverhand",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/cli",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Logto CLI.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "homepage": "https://github.com/logto-io/logto#readme",
@@ -28,10 +28,10 @@
28
28
  "url": "https://github.com/logto-io/logto/issues"
29
29
  },
30
30
  "dependencies": {
31
- "@logto/connector-kit": "^4.1.0",
32
- "@logto/core-kit": "^2.5.2",
33
- "@logto/schemas": "1.24.0",
34
- "@logto/shared": "^3.1.2",
31
+ "@logto/connector-kit": "^4.2.0",
32
+ "@logto/core-kit": "^2.5.4",
33
+ "@logto/schemas": "1.25.0",
34
+ "@logto/shared": "^3.1.4",
35
35
  "@silverhand/essentials": "^2.9.1",
36
36
  "@silverhand/slonik": "31.0.0-beta.2",
37
37
  "chalk": "^5.3.0",
@@ -59,14 +59,14 @@
59
59
  "@types/sinon": "^17.0.0",
60
60
  "@types/tar": "^6.1.12",
61
61
  "@types/yargs": "^17.0.13",
62
- "@vitest/coverage-v8": "^2.1.8",
62
+ "@vitest/coverage-v8": "^2.1.9",
63
63
  "@withtyped/server": "^0.14.0",
64
64
  "eslint": "^8.56.0",
65
65
  "lint-staged": "^15.0.0",
66
66
  "prettier": "^3.0.0",
67
67
  "sinon": "^19.0.0",
68
68
  "typescript": "^5.5.3",
69
- "vitest": "^2.1.8"
69
+ "vitest": "^2.1.9"
70
70
  },
71
71
  "eslintConfig": {
72
72
  "extends": "@silverhand",