mirror of
https://github.com/logto-io/logto.git
synced 2025-03-24 22:41:28 -05:00
feat(core): add connector config json templates
This commit is contained in:
parent
7dba17b867
commit
a710ec6ba5
16 changed files with 87 additions and 7 deletions
|
@ -71,6 +71,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -88,6 +89,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -105,6 +107,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -122,6 +125,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -139,6 +143,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -156,6 +161,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -173,6 +179,7 @@ export const mockConnectorInstanceList: Array<{
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -17,8 +17,12 @@ 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 currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'aliyun-dm',
|
||||
type: ConnectorType.Email,
|
||||
|
@ -36,6 +40,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -17,8 +17,12 @@ 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 currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'aliyun-sms',
|
||||
type: ConnectorType.SMS,
|
||||
|
@ -36,6 +40,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
3
packages/core/src/connectors/facebook/config-template.md
Normal file
3
packages/core/src/connectors/facebook/config-template.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -29,8 +29,12 @@ import { getConnectorConfig, getConnectorRequestTimeout } from '@/connectors/uti
|
|||
import assertThat from '@/utils/assert-that';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'facebook',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -47,6 +51,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
const facebookConfigGuard = z.object({
|
||||
|
|
3
packages/core/src/connectors/github/config-template.md
Normal file
3
packages/core/src/connectors/github/config-template.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -21,8 +21,12 @@ 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 currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'github',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -38,6 +42,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
const githubConfigGuard = z.object({
|
||||
|
|
3
packages/core/src/connectors/google/config-template.md
Normal file
3
packages/core/src/connectors/google/config-template.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -26,8 +26,12 @@ 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 currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'google',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -44,6 +48,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
const googleConfigGuard = z.object({
|
||||
|
|
3
packages/core/src/connectors/wechat/config-template.md
Normal file
3
packages/core/src/connectors/wechat/config-template.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
// placeholder
|
||||
}
|
|
@ -25,8 +25,12 @@ import { getConnectorConfig, getConnectorRequestTimeout } from '../utilities';
|
|||
import { authorizationEndpoint, accessTokenEndpoint, userInfoEndpoint, scope } from './constant';
|
||||
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
const pathToReadmeFile = path.join(__dirname, 'README.md');
|
||||
const currentPath = __dirname;
|
||||
const pathToReadmeFile = path.join(currentPath, 'README.md');
|
||||
const pathToConfigTemplate = path.join(currentPath, 'config-template.md');
|
||||
const readmeContentFallback = 'Please check README.md file directory.';
|
||||
const configTemplateFallback = 'Please check config-template.md file directory.';
|
||||
|
||||
export const metadata: ConnectorMetadata = {
|
||||
id: 'wechat',
|
||||
type: ConnectorType.Social,
|
||||
|
@ -43,6 +47,9 @@ export const metadata: ConnectorMetadata = {
|
|||
readme: existsSync(pathToReadmeFile)
|
||||
? readFileSync(pathToReadmeFile, 'utf8')
|
||||
: readmeContentFallback,
|
||||
configTemplate: existsSync(pathToConfigTemplate)
|
||||
? readFileSync(pathToConfigTemplate, 'utf-8')
|
||||
: configTemplateFallback,
|
||||
};
|
||||
|
||||
// As creating a WeChat Web/Mobile application needs a real App or Website record, the real test is temporarily not finished.
|
||||
|
|
|
@ -135,7 +135,8 @@ describe('sendPasscode', () => {
|
|||
name: {},
|
||||
logo: '',
|
||||
description: {},
|
||||
readme: '',
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
sendMessage,
|
||||
validateConfig: jest.fn(),
|
||||
|
|
|
@ -200,6 +200,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: jest.fn(),
|
||||
};
|
||||
|
@ -221,6 +222,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
});
|
||||
expect(response).toHaveProperty('statusCode', 200);
|
||||
|
@ -243,6 +245,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: async () => {
|
||||
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig);
|
||||
|
@ -272,6 +275,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -315,6 +319,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: jest.fn(),
|
||||
};
|
||||
|
@ -374,6 +379,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: async () => {
|
||||
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig);
|
||||
|
@ -403,6 +409,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -483,6 +490,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: async () => {
|
||||
throw new ConnectorError(ConnectorErrorCodes.InvalidConfig);
|
||||
|
@ -512,6 +520,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: jest.fn(),
|
||||
};
|
||||
|
@ -560,6 +569,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: jest.fn(),
|
||||
sendMessage: async (
|
||||
|
@ -605,6 +615,7 @@ describe('connector route', () => {
|
|||
logo: './logo.png',
|
||||
description: {},
|
||||
readme: 'README.md',
|
||||
configTemplate: 'config-template.md',
|
||||
},
|
||||
validateConfig: jest.fn(),
|
||||
sendMessage: async (
|
||||
|
|
|
@ -9,6 +9,7 @@ export interface ConnectorMetadata {
|
|||
logo: string;
|
||||
description: Record<Languages, string>;
|
||||
readme: string;
|
||||
configTemplate: string;
|
||||
}
|
||||
export interface ConnectorDTO extends Connector {
|
||||
metadata: ConnectorMetadata;
|
||||
|
|
Loading…
Add table
Reference in a new issue