mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(core): enable creating a new connector with specified id (#3099)
This commit is contained in:
parent
af272446d9
commit
84bb5b29f0
1 changed files with 10 additions and 8 deletions
|
@ -128,16 +128,18 @@ export default function connectorRoutes<T extends AuthedRouter>(
|
||||||
router.post(
|
router.post(
|
||||||
'/connectors',
|
'/connectors',
|
||||||
koaGuard({
|
koaGuard({
|
||||||
body: Connectors.createGuard.pick({
|
body: Connectors.createGuard
|
||||||
|
.pick({
|
||||||
config: true,
|
config: true,
|
||||||
connectorId: true,
|
connectorId: true,
|
||||||
metadata: true,
|
metadata: true,
|
||||||
syncProfile: true,
|
syncProfile: true,
|
||||||
}),
|
})
|
||||||
|
.merge(Connectors.createGuard.pick({ id: true }).partial()), // `id` is optional
|
||||||
}),
|
}),
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
const {
|
const {
|
||||||
body: { connectorId, metadata, config, syncProfile },
|
body: { id: proposedId, connectorId, metadata, config, syncProfile },
|
||||||
} = ctx.guard;
|
} = ctx.guard;
|
||||||
|
|
||||||
const connectorFactories = await loadConnectorFactories();
|
const connectorFactories = await loadConnectorFactories();
|
||||||
|
@ -190,7 +192,7 @@ export default function connectorRoutes<T extends AuthedRouter>(
|
||||||
validateConfig(config, rawConnector.configGuard);
|
validateConfig(config, rawConnector.configGuard);
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertConnectorId = generateConnectorId();
|
const insertConnectorId = proposedId ?? generateConnectorId();
|
||||||
await insertConnector({
|
await insertConnector({
|
||||||
id: insertConnectorId,
|
id: insertConnectorId,
|
||||||
connectorId,
|
connectorId,
|
||||||
|
|
Loading…
Reference in a new issue