mirror of
https://github.com/logto-io/logto.git
synced 2025-03-24 22:41:28 -05:00
feat(core): add README.md for connectors (#362)
* feat(core): add README.md for connectors * feat(core): add README.md files' existence check * feat(core): fix path of README.md
This commit is contained in:
parent
74d7dd6603
commit
cde61b77b1
14 changed files with 73 additions and 0 deletions
2
packages/core/src/connectors/aliyun-dm/README.md
Normal file
2
packages/core/src/connectors/aliyun-dm/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
### Aliyun DM README
|
||||
placeholder
|
|
@ -1,3 +1,6 @@
|
|||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import assertThat from '@/utils/assert-that';
|
||||
|
@ -13,6 +16,9 @@ import {
|
|||
import { getConnectorConfig } from '../utilities';
|
||||
import { singleSendMail } from './single-send-mail';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'aliyun-dm',
|
||||
type: ConnectorType.Email,
|
||||
|
@ -27,6 +33,9 @@ export const metadata: ConnectorMetadata = {
|
|||
'zh-CN':
|
||||
'邮件推送(DirectMail)是款简单高效的电子邮件群发服务,构建在阿里云基础之上,帮您快速、精准地实现事务邮件、通知邮件和批量邮件的发送。',
|
||||
},
|
||||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
2
packages/core/src/connectors/aliyun-sms/README.md
Normal file
2
packages/core/src/connectors/aliyun-sms/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
### Aliyun SMS README
|
||||
placeholder
|
|
@ -1,3 +1,6 @@
|
|||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import assertThat from '@/utils/assert-that';
|
||||
|
@ -13,6 +16,9 @@ import {
|
|||
import { getConnectorConfig } from '../utilities';
|
||||
import { sendSms } from './single-send-text';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'aliyun-sms',
|
||||
type: ConnectorType.SMS,
|
||||
|
@ -27,6 +33,9 @@ export const metadata: ConnectorMetadata = {
|
|||
'zh-CN':
|
||||
'短信服务(Short Message Service)是指通过调用短信发送API,将指定短信内容发送给指定手机用户。',
|
||||
},
|
||||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
2
packages/core/src/connectors/facebook/README.md
Normal file
2
packages/core/src/connectors/facebook/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
### FB Social Connector README
|
||||
placeholder
|
|
@ -2,6 +2,9 @@
|
|||
* Reference: Manually Build a Login Flow
|
||||
* https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
|
||||
*/
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import got, { RequestError as GotRequestError } from 'got';
|
||||
import { stringify } from 'query-string';
|
||||
import { z } from 'zod';
|
||||
|
@ -25,6 +28,9 @@ import {
|
|||
import { getConnectorConfig, getConnectorRequestTimeout } from '@/connectors/utilities';
|
||||
import assertThat from '@/utils/assert-that';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'facebook',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -38,6 +44,9 @@ export const metadata: ConnectorMetadata = {
|
|||
en: 'Sign In with Facebook',
|
||||
'zh-CN': 'Facebook 登录',
|
||||
},
|
||||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
};
|
||||
|
||||
const facebookConfigGuard = z.object({
|
||||
|
|
2
packages/core/src/connectors/github/README.md
Normal file
2
packages/core/src/connectors/github/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
### Github Social Connector README
|
||||
placeholder
|
|
@ -1,3 +1,6 @@
|
|||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import got, { RequestError as GotRequestError } from 'got';
|
||||
import { stringify } from 'query-string';
|
||||
import { z } from 'zod';
|
||||
|
@ -17,6 +20,9 @@ import {
|
|||
import { getConnectorConfig, getConnectorRequestTimeout } from '../utilities';
|
||||
import { authorizationEndpoint, accessTokenEndpoint, scope, userInfoEndpoint } from './constant';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'github',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -29,6 +35,9 @@ export const metadata: ConnectorMetadata = {
|
|||
en: 'Sign In with GitHub',
|
||||
'zh-CN': 'GitHub登录',
|
||||
},
|
||||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
};
|
||||
|
||||
const githubConfigGuard = z.object({
|
||||
|
|
2
packages/core/src/connectors/google/README.md
Normal file
2
packages/core/src/connectors/google/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
### Google Social Connector README
|
||||
placeholder
|
|
@ -2,6 +2,8 @@
|
|||
* The Implementation of OpenID Connect of Google Identity Platform.
|
||||
* https://developers.google.com/identity/protocols/oauth2/openid-connect
|
||||
*/
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import got, { RequestError as GotRequestError } from 'got';
|
||||
|
@ -23,6 +25,9 @@ import {
|
|||
import { getConnectorConfig, getConnectorRequestTimeout } from '../utilities';
|
||||
import { accessTokenEndpoint, authorizationEndpoint, scope, userInfoEndpoint } from './constant';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'google',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -36,6 +41,9 @@ export const metadata: ConnectorMetadata = {
|
|||
en: 'Sign In with Google',
|
||||
'zh-CN': 'Google登录',
|
||||
},
|
||||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
};
|
||||
|
||||
const googleConfigGuard = z.object({
|
||||
|
|
|
@ -134,6 +134,7 @@ describe('sendPasscode', () => {
|
|||
name: {},
|
||||
logo: '',
|
||||
description: {},
|
||||
readme: '',
|
||||
},
|
||||
sendMessage,
|
||||
validateConfig: jest.fn(),
|
||||
|
|
|
@ -196,6 +196,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -235,6 +236,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -254,6 +256,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
|
@ -275,6 +278,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -309,6 +313,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
|
@ -329,6 +334,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -348,6 +354,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
|
@ -406,6 +413,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
validateConfig: async (_config) => {
|
||||
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig);
|
||||
|
@ -433,6 +441,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
validateConfig: async (_config) => {},
|
||||
|
@ -454,6 +463,7 @@ describe('connector route', () => {
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
|
|
|
@ -252,6 +252,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -267,6 +268,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -282,6 +284,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -297,6 +300,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -312,6 +316,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -327,6 +332,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -342,6 +348,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
name: {},
|
||||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
@ -13,6 +13,7 @@ export interface ConnectorMetadata {
|
|||
name: Record<Languages, string>;
|
||||
logo: string;
|
||||
description: Record<Languages, string>;
|
||||
readme: string;
|
||||
}
|
||||
export interface ConnectorDTO extends Connector {
|
||||
metadata: ConnectorMetadata;
|
||||
|
|
Loading…
Add table
Reference in a new issue