feat(server): posting origin to automate (#2301)

This commit is contained in:
Kristaps Fabians Geikins
2024-05-30 14:14:44 +03:00
committed by GitHub
parent d00baf774e
commit bd7dd40d71
5 changed files with 37 additions and 13 deletions
@@ -956,7 +956,7 @@ export type GendoAiRender = {
modelId: Scalars['String'];
projectId: Scalars['String'];
prompt: Scalars['String'];
/** This is a reference to a blob's id. */
/** This is a blob id. */
responseImage?: Maybe<Scalars['String']>;
status: Scalars['String'];
updatedAt: Scalars['String'];
@@ -972,7 +972,7 @@ export type GendoAiRenderCollection = {
};
export type GendoAiRenderInput = {
/** Base64 encoded image of the depthmap, resized to 1024 on the longest size. */
/** Base64 encoded image of the depthmap. */
baseImage: Scalars['String'];
camera: Scalars['JSONObject'];
modelId: Scalars['ID'];
@@ -134,13 +134,14 @@ export const createAutomation = async (params: {
const { speckleServerUrl, authCode } = params
const url = getApiUrl(`/api/v2/automations`)
const speckleServerDomain = new URL(speckleServerUrl).hostname
const speckleServerOrigin = new URL(speckleServerUrl).origin
const result = await invokeJsonRequest<AutomationCreateResponse>({
url,
method: 'post',
body: {
speckleServerDomain,
speckleServerOrigin,
speckleServerAuthenticationCode: authCode
},
retry: false
@@ -323,6 +324,12 @@ export const getFunctionReleases = async (params: {
if (e instanceof ExecutionEngineNetworkError) {
return null
}
if (
e instanceof ExecutionEngineFailedResponseError &&
e.response.statusMessage === 'FunctionNotFound'
) {
return null
}
throw e
}
@@ -93,7 +93,10 @@ import {
mapGqlStatusToDbStatus
} from '@/modules/automate/utils/automateFunctionRunStatus'
import { AutomateApiDisabledError } from '@/modules/automate/errors/core'
import { ExecutionEngineNetworkError } from '@/modules/automate/errors/executionEngine'
import {
ExecutionEngineFailedResponseError,
ExecutionEngineNetworkError
} from '@/modules/automate/errors/executionEngine'
import { automateLogger } from '@/logging/logging'
/**
@@ -381,7 +384,10 @@ export = (FF_AUTOMATE_MODULE_ENABLED
)
}
} catch (e) {
if (e instanceof ExecutionEngineNetworkError) {
const isNotFound =
e instanceof ExecutionEngineFailedResponseError &&
e.response.statusMessage === 'FunctionNotFound'
if (e instanceof ExecutionEngineNetworkError || isNotFound) {
return {
cursor: null,
totalCount: 0,
@@ -536,7 +542,10 @@ export = (FF_AUTOMATE_MODULE_ENABLED
items
}
} catch (e) {
if (e instanceof ExecutionEngineNetworkError) {
const isNotFound =
e instanceof ExecutionEngineFailedResponseError &&
e.response.statusMessage === 'FunctionNotFound'
if (e instanceof ExecutionEngineNetworkError || isNotFound) {
return {
cursor: null,
totalCount: 0,
@@ -20,10 +20,10 @@ const AutomationRunStatusOrder: { [key in AutomationRunStatus]: number } = {
initializing: 1,
running: 2,
succeeded: 3,
failed: 4,
failed: 3,
canceled: 4,
exception: 5,
timeout: 6,
canceled: 7
timeout: 5
}
/**
@@ -118,7 +118,9 @@ export const reportFunctionRunStatus =
const { automationId, ...currentFunctionRunRecord } = currentFunctionRunRecordResult
if (statusReportData.results) {
Automate.AutomateTypes.formatResultsSchema(statusReportData.results)
statusReportData.results = Automate.AutomateTypes.formatResultsSchema(
statusReportData.results
)
}
if (statusReportData.contextView) validateContextView(statusReportData.contextView)
+8 -2
View File
@@ -82,7 +82,10 @@ import {
FunctionReleaseSchemaType,
FunctionSchemaType
} from '@/modules/automate/helpers/executionEngine'
import { ExecutionEngineNetworkError } from '@/modules/automate/errors/executionEngine'
import {
ExecutionEngineFailedResponseError,
ExecutionEngineNetworkError
} from '@/modules/automate/errors/executionEngine'
const simpleTupleCacheKey = (key: [string, string]) => `${key[0]}:${key[1]}`
@@ -609,7 +612,10 @@ export function buildRequestLoaders(
try {
return await getFunction({ functionId: fnId })
} catch (e) {
if (e instanceof ExecutionEngineNetworkError) {
const isNotFound =
e instanceof ExecutionEngineFailedResponseError &&
e.response.statusMessage === 'FunctionNotFound'
if (e instanceof ExecutionEngineNetworkError || isNotFound) {
return null
}