feat(automate): use updated hybrid function search (#4085)
* fix(automate): use new function query for workspace functions * fix(automate): include workspace resource claims in auth flow * chore(automate): do not use btoa
This commit is contained in:
@@ -41,7 +41,7 @@ import {
|
||||
import { createProjectInviteFactory } from '@/modules/serverinvites/services/projectInviteManagement'
|
||||
import { getInvitationTargetUsersFactory } from '@/modules/serverinvites/services/retrieval'
|
||||
import { authorizeResolver } from '@/modules/shared'
|
||||
import { getFeatureFlags, getServerOrigin } from '@/modules/shared/helpers/envHelper'
|
||||
import { getFeatureFlags } from '@/modules/shared/helpers/envHelper'
|
||||
import { getEventBus } from '@/modules/shared/services/eventBus'
|
||||
import { WorkspaceInviteResourceType } from '@/modules/workspacesCore/domain/constants'
|
||||
import {
|
||||
@@ -169,17 +169,12 @@ import {
|
||||
listWorkspaceSsoMembershipsFactory
|
||||
} from '@/modules/workspaces/repositories/sso'
|
||||
import { getDecryptor } from '@/modules/workspaces/helpers/sso'
|
||||
import { getWorkspaceFunctions } from '@/modules/automate/clients/executionEngine'
|
||||
import { getFunctions } from '@/modules/automate/clients/executionEngine'
|
||||
import {
|
||||
ExecutionEngineFailedResponseError,
|
||||
ExecutionEngineNetworkError
|
||||
} from '@/modules/automate/errors/executionEngine'
|
||||
import { getDefaultRegionFactory } from '@/modules/workspaces/repositories/regions'
|
||||
import {
|
||||
AuthCodePayloadAction,
|
||||
createStoredAuthCodeFactory
|
||||
} from '@/modules/automate/services/authCode'
|
||||
import { getGenericRedis } from '@/modules/shared/redis/redis'
|
||||
import { convertFunctionToGraphQLReturn } from '@/modules/automate/services/functionManagement'
|
||||
import {
|
||||
getWorkspacePlanFactory,
|
||||
@@ -202,6 +197,11 @@ import { OperationTypeNode } from 'graphql'
|
||||
import { updateWorkspacePlanFactory } from '@/modules/gatekeeper/services/workspacePlans'
|
||||
import { GetWorkspaceCollaboratorsArgs } from '@/modules/workspaces/domain/operations'
|
||||
import { WorkspaceTeamMember } from '@/modules/workspaces/domain/types'
|
||||
import { getGenericRedis } from '@/modules/shared/redis/redis'
|
||||
import {
|
||||
AuthCodePayloadAction,
|
||||
createStoredAuthCodeFactory
|
||||
} from '@/modules/automate/services/authCode'
|
||||
|
||||
const eventBus = getEventBus()
|
||||
const getServerInfo = getServerInfoFactory({ db })
|
||||
@@ -1079,6 +1079,13 @@ export = FF_WORKSPACES_MODULE_ENABLED
|
||||
},
|
||||
automateFunctions: async (parent, args, context) => {
|
||||
try {
|
||||
await authorizeResolver(
|
||||
context.userId,
|
||||
parent.id,
|
||||
Roles.Workspace.Member,
|
||||
context.resourceAccessRules
|
||||
)
|
||||
|
||||
const authCode = await createStoredAuthCodeFactory({
|
||||
redis: getGenericRedis()
|
||||
})({
|
||||
@@ -1086,14 +1093,16 @@ export = FF_WORKSPACES_MODULE_ENABLED
|
||||
action: AuthCodePayloadAction.ListWorkspaceFunctions
|
||||
})
|
||||
|
||||
const res = await getWorkspaceFunctions({
|
||||
workspaceId: parent.id,
|
||||
query: removeNullOrUndefinedKeys(args),
|
||||
body: {
|
||||
speckleServerAuthenticationPayload: {
|
||||
...authCode,
|
||||
origin: getServerOrigin()
|
||||
}
|
||||
const res = await getFunctions({
|
||||
auth: authCode,
|
||||
filters: {
|
||||
query: args.filter?.search ?? undefined,
|
||||
cursor: args.cursor ?? undefined,
|
||||
limit: args.limit,
|
||||
requireRelease: true,
|
||||
includeFeatured: true,
|
||||
includeWorkspaces: [parent.id],
|
||||
includeUsers: []
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1105,12 +1114,12 @@ export = FF_WORKSPACES_MODULE_ENABLED
|
||||
}
|
||||
}
|
||||
|
||||
const items = res.functions.map(convertFunctionToGraphQLReturn)
|
||||
const items = res.items.map(convertFunctionToGraphQLReturn)
|
||||
|
||||
return {
|
||||
cursor: undefined,
|
||||
totalCount: res.functions.length,
|
||||
items
|
||||
items,
|
||||
cursor: res.cursor,
|
||||
totalCount: res.totalCount
|
||||
}
|
||||
} catch (e) {
|
||||
const isNotFound =
|
||||
|
||||
Reference in New Issue
Block a user