Merge pull request #3058 from specklesystems/fabians/automate-ioc-6
chore(server): automate IoC 6 - functionManagement cleanup
This commit is contained in:
@@ -43,8 +43,8 @@ import {
|
||||
import {
|
||||
convertFunctionReleaseToGraphQLReturn,
|
||||
convertFunctionToGraphQLReturn,
|
||||
createFunctionFromTemplate,
|
||||
updateFunction
|
||||
createFunctionFromTemplateFactory,
|
||||
updateFunctionFactory
|
||||
} from '@/modules/automate/services/functionManagement'
|
||||
import {
|
||||
Resolvers,
|
||||
@@ -441,7 +441,7 @@ export = (FF_AUTOMATE_MODULE_ENABLED
|
||||
},
|
||||
AutomateMutations: {
|
||||
async createFunction(_parent, args, ctx) {
|
||||
const create = createFunctionFromTemplate({
|
||||
const create = createFunctionFromTemplateFactory({
|
||||
createExecutionEngineFn: createFunction,
|
||||
getUser,
|
||||
createStoredAuthCode: createStoredAuthCodeFactory({
|
||||
@@ -453,7 +453,7 @@ export = (FF_AUTOMATE_MODULE_ENABLED
|
||||
.graphqlReturn
|
||||
},
|
||||
async updateFunction(_parent, args, ctx) {
|
||||
const update = updateFunction({
|
||||
const update = updateFunctionFactory({
|
||||
updateFunction: execEngineUpdateFunction,
|
||||
getFunction,
|
||||
createStoredAuthCode: createStoredAuthCodeFactory({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createStoredAuthCodeFactory } from '@/modules/automate/services/authCode'
|
||||
import {
|
||||
handleAutomateFunctionCreatorAuthCallback,
|
||||
startAutomateFunctionCreatorAuth
|
||||
handleAutomateFunctionCreatorAuthCallbackFactory,
|
||||
startAutomateFunctionCreatorAuthFactory
|
||||
} from '@/modules/automate/services/functionManagement'
|
||||
import { getGenericRedis } from '@/modules/core'
|
||||
import { corsMiddleware } from '@/modules/core/configs/cors'
|
||||
@@ -19,7 +19,7 @@ export default (app: Application) => {
|
||||
validateScope({ requiredScope: Scopes.AutomateFunctions.Write })
|
||||
]),
|
||||
async (req, res) => {
|
||||
const startAuth = startAutomateFunctionCreatorAuth({
|
||||
const startAuth = startAutomateFunctionCreatorAuthFactory({
|
||||
createStoredAuthCode: createStoredAuthCodeFactory({
|
||||
redis: getGenericRedis()
|
||||
})
|
||||
@@ -36,7 +36,7 @@ export default (app: Application) => {
|
||||
validateScope({ requiredScope: Scopes.AutomateFunctions.Write })
|
||||
]),
|
||||
async (req, res) => {
|
||||
const handleCallback = handleAutomateFunctionCreatorAuthCallback()
|
||||
const handleCallback = handleAutomateFunctionCreatorAuthCallbackFactory()
|
||||
await handleCallback({ req, res })
|
||||
}
|
||||
)
|
||||
|
||||
@@ -122,7 +122,7 @@ export type CreateFunctionDeps = {
|
||||
getUser: typeof getUser
|
||||
}
|
||||
|
||||
export const createFunctionFromTemplate =
|
||||
export const createFunctionFromTemplateFactory =
|
||||
(deps: CreateFunctionDeps) =>
|
||||
async (params: { input: CreateAutomateFunctionInput; userId: string }) => {
|
||||
const { input, userId } = params
|
||||
@@ -187,7 +187,7 @@ export type UpdateFunctionDeps = {
|
||||
createStoredAuthCode: CreateStoredAuthCode
|
||||
}
|
||||
|
||||
export const updateFunction =
|
||||
export const updateFunctionFactory =
|
||||
(deps: UpdateFunctionDeps) =>
|
||||
async (params: { input: UpdateAutomateFunctionInput; userId: string }) => {
|
||||
const { updateFunction, createStoredAuthCode } = deps
|
||||
@@ -233,7 +233,7 @@ export type StartAutomateFunctionCreatorAuthDeps = {
|
||||
createStoredAuthCode: CreateStoredAuthCode
|
||||
}
|
||||
|
||||
export const startAutomateFunctionCreatorAuth =
|
||||
export const startAutomateFunctionCreatorAuthFactory =
|
||||
(deps: StartAutomateFunctionCreatorAuthDeps) =>
|
||||
async (params: { req: Request; res: Response }) => {
|
||||
const { createStoredAuthCode } = deps
|
||||
@@ -260,7 +260,7 @@ export const startAutomateFunctionCreatorAuth =
|
||||
return res.redirect(redirectUrl.toString())
|
||||
}
|
||||
|
||||
export const handleAutomateFunctionCreatorAuthCallback =
|
||||
export const handleAutomateFunctionCreatorAuthCallbackFactory =
|
||||
() => async (params: { req: Request; res: Response }) => {
|
||||
const { req, res } = params
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user