chore: cleaning up betaAutomations (#2413)

This commit is contained in:
Kristaps Fabians Geikins
2024-06-20 15:35:39 +03:00
committed by GitHub
parent 71d1ea7f62
commit d4f90a83e8
28 changed files with 1556 additions and 2603 deletions
+2 -2
View File
@@ -28,8 +28,8 @@
"dev:kind:helm:ci": "tilt ci --file ./.circleci/deployment/Tiltfile.helm --context kind-speckle-server --timeout 10m",
"dev": "yarn workspaces foreach -pivW -j unlimited run dev",
"dev:no-server": "yarn workspaces foreach --exclude @speckle/server -pivW -j unlimited run dev",
"dev:minimal": "yarn workspaces foreach -pivW -j unlimited --include '{@speckle/server,@speckle/frontend,@speckle/shared}' run dev",
"gqlgen": "yarn workspaces foreach -pivW -j unlimited --include '{@speckle/server,@speckle/frontend,@speckle/frontend-2}' run gqlgen",
"dev:minimal": "yarn workspaces foreach -pivW -j unlimited --include '{@speckle/server,@speckle/frontend-2}' run dev",
"gqlgen": "yarn workspaces foreach -pivW -j unlimited --include '{@speckle/server,@speckle/frontend,@speckle/frontend-2,@speckle/dui3}' run gqlgen",
"dev:server": "yarn workspace @speckle/server dev",
"dev:frontend": "yarn workspace @speckle/frontend dev",
"dev:frontend-2": "yarn workspace @speckle/frontend-2 dev",
@@ -375,62 +375,6 @@ export type AutomationCollection = {
totalCount: Scalars['Int']['output'];
};
export type AutomationCreateInput = {
automationId: Scalars['String']['input'];
automationName: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
modelId: Scalars['String']['input'];
projectId: Scalars['String']['input'];
webhookId?: InputMaybe<Scalars['String']['input']>;
};
export type AutomationFunctionRun = {
__typename?: 'AutomationFunctionRun';
contextView?: Maybe<Scalars['String']['output']>;
elapsed: Scalars['Float']['output'];
functionId: Scalars['String']['output'];
functionLogo?: Maybe<Scalars['String']['output']>;
functionName: Scalars['String']['output'];
id: Scalars['ID']['output'];
resultVersions: Array<Version>;
/**
* NOTE: this is the schema for the results field below!
* Current schema: {
* version: "1.0.0",
* values: {
* objectResults: Record<str, {
* category: string
* level: ObjectResultLevel
* objectIds: string[]
* message: str | null
* metadata: Records<str, unknown> | null
* visualoverrides: Records<str, unknown> | null
* }[]>
* blobIds?: string[]
* }
* }
*/
results?: Maybe<Scalars['JSONObject']['output']>;
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AutomationMutations = {
__typename?: 'AutomationMutations';
create: Scalars['Boolean']['output'];
functionRunStatusReport: Scalars['Boolean']['output'];
};
export type AutomationMutationsCreateArgs = {
input: AutomationCreateInput;
};
export type AutomationMutationsFunctionRunStatusReportArgs = {
input: AutomationRunStatusUpdateInput;
};
export type AutomationRevision = {
__typename?: 'AutomationRevision';
functions: Array<AutomationRevisionFunction>;
@@ -454,44 +398,8 @@ export type AutomationRevisionFunction = {
export type AutomationRevisionTriggerDefinition = VersionCreatedTriggerDefinition;
export type AutomationRun = {
__typename?: 'AutomationRun';
automationId: Scalars['String']['output'];
automationName: Scalars['String']['output'];
createdAt: Scalars['DateTime']['output'];
functionRuns: Array<AutomationFunctionRun>;
id: Scalars['ID']['output'];
/** Resolved from all function run statuses */
status: AutomationRunStatus;
updatedAt: Scalars['DateTime']['output'];
versionId: Scalars['String']['output'];
};
export enum AutomationRunStatus {
Failed = 'FAILED',
Initializing = 'INITIALIZING',
Running = 'RUNNING',
Succeeded = 'SUCCEEDED'
}
export type AutomationRunStatusUpdateInput = {
automationId: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
automationRunId: Scalars['String']['input'];
functionRuns: Array<FunctionRunStatusInput>;
versionId: Scalars['String']['input'];
};
export type AutomationRunTrigger = VersionCreatedTrigger;
export type AutomationsStatus = {
__typename?: 'AutomationsStatus';
automationRuns: Array<AutomationRun>;
id: Scalars['ID']['output'];
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AvatarUser = {
__typename?: 'AvatarUser';
avatar?: Maybe<Scalars['String']['output']>;
@@ -936,27 +844,6 @@ export type FileUpload = {
userId: Scalars['String']['output'];
};
export type FunctionRunStatusInput = {
contextView?: InputMaybe<Scalars['String']['input']>;
elapsed: Scalars['Float']['input'];
functionId: Scalars['String']['input'];
functionLogo?: InputMaybe<Scalars['String']['input']>;
functionName: Scalars['String']['input'];
resultVersionIds: Array<Scalars['String']['input']>;
/**
* Current schema: {
* version: "1.0.0",
* values: {
* speckleObjects: Record<ObjectId, {level: string; statusMessage: string}[]>
* blobIds?: string[]
* }
* }
*/
results?: InputMaybe<Scalars['JSONObject']['input']>;
status: AutomationRunStatus;
statusMessage?: InputMaybe<Scalars['String']['input']>;
};
export type GendoAiRender = {
__typename?: 'GendoAIRender';
camera?: Maybe<Scalars['JSONObject']['output']>;
@@ -1082,7 +969,6 @@ export type LimitedUserTimelineArgs = {
export type Model = {
__typename?: 'Model';
author: LimitedUser;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** Return a model tree of children */
childrenTree: Array<ModelsTreeItem>;
@@ -1215,7 +1101,6 @@ export type Mutation = {
appUpdate: Scalars['Boolean']['output'];
automateFunctionRunStatusReport: Scalars['Boolean']['output'];
automateMutations: AutomateMutations;
automationMutations: AutomationMutations;
branchCreate: Scalars['String']['output'];
branchDelete: Scalars['Boolean']['output'];
branchUpdate: Scalars['Boolean']['output'];
@@ -1901,14 +1786,6 @@ export type ProjectAutomationUpdateInput = {
name?: InputMaybe<Scalars['String']['input']>;
};
export type ProjectAutomationsStatusUpdatedMessage = {
__typename?: 'ProjectAutomationsStatusUpdatedMessage';
model: Model;
project: Project;
status: AutomationsStatus;
version: Version;
};
export type ProjectAutomationsUpdatedMessage = {
__typename?: 'ProjectAutomationsUpdatedMessage';
automation?: Maybe<Automation>;
@@ -2875,7 +2752,6 @@ export type Subscription = {
commitDeleted?: Maybe<Scalars['JSONObject']['output']>;
/** Subscribe to commit updated event. */
commitUpdated?: Maybe<Scalars['JSONObject']['output']>;
projectAutomationsStatusUpdated: ProjectAutomationsStatusUpdatedMessage;
/** Subscribe to updates to automations in the project */
projectAutomationsUpdated: ProjectAutomationsUpdatedMessage;
/**
@@ -2971,11 +2847,6 @@ export type SubscriptionCommitUpdatedArgs = {
};
export type SubscriptionProjectAutomationsStatusUpdatedArgs = {
projectId: Scalars['String']['input'];
};
export type SubscriptionProjectAutomationsUpdatedArgs = {
projectId: Scalars['String']['input'];
};
@@ -3317,7 +3188,6 @@ export type UserUpdateInput = {
export type Version = {
__typename?: 'Version';
authorUser?: Maybe<LimitedUser>;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** All comment threads in this version */
commentThreads: CommentCollection;
File diff suppressed because it is too large Load Diff
@@ -1,147 +0,0 @@
enum AutomationRunStatus {
INITIALIZING
RUNNING
SUCCEEDED
FAILED
}
extend type Model {
automationStatus: AutomationsStatus
}
extend type Version {
automationStatus: AutomationsStatus
}
type AutomationsStatus {
id: ID!
status: AutomationRunStatus!
statusMessage: String
automationRuns: [AutomationRun!]!
}
# TODO: Currently not needed
# type Automation {
# automationName: String!
# automationId: String!
# automationRevisionId: String!
# createdAt: DateTime!
# runs(cursor: String, limit: Int! = 25): AutomationRunsCollection!
# }
# type AutomationRunsCollection {
# totalCount: Int!
# cursor: String
# items: [AutomationRun!]!
# }
type AutomationRun {
id: ID!
automationId: String!
automationName: String!
versionId: String!
createdAt: DateTime!
updatedAt: DateTime!
functionRuns: [AutomationFunctionRun!]!
"""
Resolved from all function run statuses
"""
status: AutomationRunStatus!
}
type AutomationFunctionRun {
id: ID!
functionId: String!
functionName: String!
functionLogo: String
elapsed: Float!
status: AutomationRunStatus!
# Context view is just a url (most likely overlaid models)
contextView: String
resultVersions: [Version!]!
statusMessage: String
"""
NOTE: this is the schema for the results field below!
Current schema: {
version: "1.0.0",
values: {
objectResults: Record<str, {
category: string
level: ObjectResultLevel
objectIds: string[]
message: str | null
metadata: Records<str, unknown> | null
visualoverrides: Records<str, unknown> | null
}[]>
blobIds?: string[]
}
}
"""
results: JSONObject # blobIds are in here
}
input AutomationCreateInput {
projectId: String!
modelId: String!
automationName: String!
automationId: String!
automationRevisionId: String!
webhookId: String
}
input FunctionRunStatusInput {
# we cannot strictly require these values, cause local testers of function, wont have it...
# Or should we?
functionId: String!
functionName: String!
functionLogo: String
elapsed: Float!
status: AutomationRunStatus!
contextView: String
resultVersionIds: [String!]!
statusMessage: String
"""
Current schema: {
version: "1.0.0",
values: {
speckleObjects: Record<ObjectId, {level: string; statusMessage: string}[]>
blobIds?: string[]
}
}
"""
results: JSONObject
}
input AutomationRunStatusUpdateInput {
versionId: String!
automationId: String!
automationRevisionId: String!
automationRunId: String!
functionRuns: [FunctionRunStatusInput!]!
}
type AutomationMutations {
functionRunStatusReport(input: AutomationRunStatusUpdateInput!): Boolean!
@hasServerRole(role: SERVER_USER)
@hasScope(scope: "automate:report-results")
create(input: AutomationCreateInput!): Boolean!
@hasServerRole(role: SERVER_USER)
@hasScope(scope: "automate:report-results")
}
extend type Mutation {
automationMutations: AutomationMutations!
}
type ProjectAutomationsStatusUpdatedMessage {
status: AutomationsStatus!
version: Version!
model: Model!
project: Project!
}
extend type Subscription {
projectAutomationsStatusUpdated(
projectId: String!
): ProjectAutomationsStatusUpdatedMessage!
}
-2
View File
@@ -32,8 +32,6 @@ generates:
Comment: '@/modules/comments/helpers/graphTypes#CommentGraphQLReturn'
PendingStreamCollaborator: '@/modules/serverinvites/helpers/graphTypes#PendingStreamCollaboratorGraphQLReturn'
FileUpload: '@/modules/fileuploads/helpers/types#FileUploadGraphQLReturn'
AutomationMutations: '@/modules/core/helpers/graphTypes#MutationsObjectGraphQLReturn'
AutomationFunctionRun: '@/modules/betaAutomations/helpers/graphTypes#AutomationFunctionRunGraphQLReturn'
AutomateFunction: '@/modules/automate/helpers/graphTypes#AutomateFunctionGraphQLReturn'
AutomateFunctionRelease: '@/modules/automate/helpers/graphTypes#AutomateFunctionReleaseGraphQLReturn'
Automation: '@/modules/automate/helpers/graphTypes#AutomationGraphQLReturn'
@@ -0,0 +1,102 @@
import { Knex } from 'knex'
const AUTOMATIONS_TABLE_NAME_NEW = 'beta_automations'
const AUTOMATION_RUNS_TABLE_NAME_NEW = 'beta_automation_runs'
const AUTOMATION_FUNCTION_RUNS_TABLE_NAME_NEW = 'beta_automation_function_runs'
const AUTOMATION_FUNCTION_RUNS_RESULT_VERSIONS_TABLE_NAME_NEW =
'beta_automation_function_runs_result_versions'
const tableNames = [
AUTOMATION_FUNCTION_RUNS_RESULT_VERSIONS_TABLE_NAME_NEW,
AUTOMATION_FUNCTION_RUNS_TABLE_NAME_NEW,
AUTOMATION_RUNS_TABLE_NAME_NEW,
AUTOMATIONS_TABLE_NAME_NEW
]
const currentBetaTableCreationScript = `
create table beta_automations
(
"automationId" varchar(255) not null,
"automationRevisionId" varchar(255) not null,
"automationName" varchar(255) not null,
"projectId" varchar(255) not null
constraint automations_projectid_foreign
references streams
on delete cascade,
"modelId" varchar(255) not null
constraint automations_modelid_foreign
references branches
on delete cascade,
"createdAt" timestamp(3) with time zone default CURRENT_TIMESTAMP not null,
"updatedAt" timestamp(3) with time zone default CURRENT_TIMESTAMP not null,
"webhookId" varchar(255)
constraint automations_webhookid_foreign
references webhooks_config
on delete set null,
constraint automations_pkey
primary key ("automationId", "automationRevisionId")
);
create table beta_automation_runs
(
"automationId" varchar(255) not null,
"automationRevisionId" varchar(255) not null,
"versionId" varchar(255) not null
constraint automation_runs_versionid_foreign
references commits
on delete cascade,
"automationRunId" varchar(255) not null
constraint automation_runs_pkey
primary key,
"createdAt" timestamp(3) with time zone default CURRENT_TIMESTAMP not null,
"updatedAt" timestamp(3) with time zone default CURRENT_TIMESTAMP not null,
constraint automation_runs_automationid_automationrevisionid_foreign
foreign key ("automationId", "automationRevisionId") references beta_automations
on delete cascade
);
create table beta_automation_function_runs
(
"automationRunId" varchar(255) not null
constraint automation_function_runs_automationrunid_foreign
references beta_automation_runs
on delete cascade,
"functionId" varchar(255) not null,
elapsed real not null,
status varchar(255) not null,
"contextView" varchar(255),
"statusMessage" varchar(255),
results jsonb,
"functionName" varchar(255) default 'majestic function'::character varying not null,
"functionLogo" text,
constraint automation_function_runs_pkey
primary key ("automationRunId", "functionId")
);
create table beta_automation_function_runs_result_versions
(
"automationRunId" varchar(255) not null,
"functionId" varchar(255) not null,
"resultVersionId" varchar(255) not null
constraint automation_function_runs_result_versions_resultversionid_foreig
references commits
on delete cascade,
constraint automation_function_runs_result_versions_pkey
primary key ("automationRunId", "functionId", "resultVersionId"),
constraint automation_function_runs_result_versions_automationrunid_functi
foreign key ("automationRunId", "functionId") references beta_automation_function_runs
on delete cascade
);
`
export async function up(knex: Knex): Promise<void> {
// Delete in order
for (const tableName of tableNames) {
await knex.schema.dropTableIfExists(tableName)
}
}
export async function down(knex: Knex): Promise<void> {
// recreate tables from script
await knex.raw(currentBetaTableCreationScript)
}
@@ -1,6 +0,0 @@
import { BaseError } from '@/modules/shared/errors/base'
export class AutomationNotFoundError extends BaseError {
static defaultMessage = 'Attempting to work with a non-existant automation'
static code = 'AUTOMATION_NOT_FOUND'
}
@@ -1,100 +0,0 @@
import {
createModelAutomation,
getAutomationsStatus,
upsertModelAutomationRunResult
} from '@/modules/betaAutomations/services/management'
import { formatResults } from '@/modules/betaAutomations/services/results'
import { Resolvers } from '@/modules/core/graph/generated/graphql'
import { getStream } from '@/modules/core/repositories/streams'
import {
ProjectSubscriptions,
filteredSubscribe
} from '@/modules/shared/utils/subscriptions'
import { ForbiddenError } from 'apollo-server-express'
export = {
Model: {
async automationStatus(parent, _, ctx) {
const modelId = parent.id
const projectId = parent.streamId
const latestCommit = await ctx.loaders.branches.getLatestCommit.load(parent.id)
// if the model has no versions, no automations could have run
if (!latestCommit) return null
return await getAutomationsStatus({
projectId,
modelId,
versionId: latestCommit.id
})
}
},
Version: {
async automationStatus(parent, _, ctx) {
const versionId = parent.id
const branch = await ctx.loaders.commits.getCommitBranch.load(versionId)
if (!branch) throw Error('Invalid version Id')
const projectId = branch.streamId
const modelId = branch.id
return await getAutomationsStatus({
projectId,
modelId,
versionId
})
}
},
AutomationFunctionRun: {
async resultVersions(parent, _, ctx) {
return ctx.loaders.automationFunctionRuns.getResultVersions.load([
parent.automationRunId,
parent.functionId
])
},
async results(parent) {
const originalResults = parent.results
if (!originalResults) return null
return formatResults(originalResults)
},
id(parent) {
return `${parent.automationRunId}-${parent.functionId}`
}
},
Mutation: {
automationMutations: () => ({})
},
AutomationMutations: {
async create(_, args, context) {
await createModelAutomation(args.input, context.userId)
return true
},
async functionRunStatusReport(_, args, context) {
const { userId, log } = context
await upsertModelAutomationRunResult({ userId, input: args.input, logger: log })
return true
}
},
Subscription: {
projectAutomationsStatusUpdated: {
subscribe: filteredSubscribe(
ProjectSubscriptions.ProjectAutomationStatusUpdated,
async (payload, variables, context) => {
if (payload.projectId !== variables.projectId) return false
const stream = await getStream({
streamId: variables.projectId,
userId: context.userId
})
if (
!stream ||
(!(stream.isDiscoverable || stream.isPublic) && !stream.role)
) {
throw new ForbiddenError('You are not authorized.')
}
return true
}
)
}
}
} as Resolvers
@@ -1,3 +0,0 @@
import { AutomationFunctionRunRecord } from '@/modules/betaAutomations/helpers/types'
export type AutomationFunctionRunGraphQLReturn = AutomationFunctionRunRecord
@@ -1,79 +0,0 @@
import { AutomationRunStatus } from '@/modules/core/graph/generated/graphql'
import { z } from 'zod'
const CurrentObjectResultsVersion = '1.0.0'
const SupportedObjectResultsVersions = [CurrentObjectResultsVersion] as const
const ObjectResultLevel = ['INFO', 'WARNING', 'ERROR'] as const
const ObjectResultLevelEnum = z.enum(ObjectResultLevel)
const ObjectResultValuesSchema = z.object({
level: ObjectResultLevelEnum,
message: z.string().nullable(),
category: z.string(),
objectIds: z.string().array().nonempty(),
metadata: z.record(z.string(), z.unknown()).nullable(),
visualOverrides: z.record(z.string(), z.unknown()).nullable()
})
const FirstVersionResultsSchema = z.object({
version: z.enum(SupportedObjectResultsVersions),
values: z.object({
objectResults: ObjectResultValuesSchema.array(),
blobIds: z.string().array().optional()
})
})
export type FirstVersionResults = z.infer<typeof FirstVersionResultsSchema>
export type CurrentVersionResults = FirstVersionResults
// As new versions are added, add the type to this union
export type Results = FirstVersionResults // | SecondVersionResults | ThirdVersionResults
const FunctionRunStatusSchema = z
.object({
functionId: z.string().min(1),
functionName: z.string().min(1),
functionLogo: z.string().nullable(),
elapsed: z.number(),
status: z.nativeEnum(AutomationRunStatus),
contextView: z
.string()
.nullable()
.default(null)
.refine(
(v) => {
if (v === null) return true
return !!/^\/projects\/[a-zA-Z0-9]+\/models\//i.exec(v)
},
{ message: 'Invalid relative viewer URL' }
),
resultVersionIds: z.string().array(),
statusMessage: z.string().nullable().default(null),
results: FirstVersionResultsSchema.nullable().default(null)
})
.refine(
(schema) => {
if (schema.status === AutomationRunStatus.Succeeded && !schema.results) {
return false
}
return true
},
{ message: 'Results must be provided for successful runs' }
)
export const AutomationRunSchema = z.object({
automationId: z.string().min(1),
automationRevisionId: z.string().min(1),
automationRunId: z.string().min(1),
versionId: z.string().min(1),
createdAt: z.date(),
updatedAt: z.date(),
functionRuns: z.array(FunctionRunStatusSchema).min(1)
})
export type AutomationRun = z.infer<typeof AutomationRunSchema>
@@ -1,41 +0,0 @@
import { Results } from '@/modules/betaAutomations/helpers/inputTypes'
import { AutomationRunStatus } from '@/modules/core/graph/generated/graphql'
import { Nullable } from '@speckle/shared'
export type AutomationRecord = {
automationId: string
projectId: string
modelId: string
createdAt: Date
updatedAt: Date
automationRevisionId: string
automationName: string
}
export type AutomationRunRecord = {
automationId: string
automationRevisionId: string
automationRunId: string
versionId: string
createdAt: Date
updatedAt: Date
automationName: string
}
export type AutomationFunctionRunRecord = {
automationRunId: string
functionId: string
functionName: string
functionLogo: string | null
elapsed: number
status: AutomationRunStatus
contextView: Nullable<string>
statusMessage: Nullable<string>
results: Nullable<Results>
}
export type AutomationFunctionRunsResultVersionRecord = {
automationRunId: string
functionId: string
resultVersionId: string
}
@@ -1,28 +0,0 @@
import { moduleLogger } from '@/logging/logging'
import { ScopeRecord } from '@/modules/auth/helpers/types'
import { registerOrUpdateScope } from '@/modules/shared'
import { SpeckleModule } from '@/modules/shared/helpers/typeHelper'
import { Scopes } from '@speckle/shared'
async function initScopes() {
const scopes: ScopeRecord[] = [
{
name: Scopes.Automate.ReportResults,
description: 'Report automation results to the server.',
public: true
}
]
for (const scope of scopes) {
await registerOrUpdateScope(scope)
}
}
const automationModule: SpeckleModule = {
async init() {
moduleLogger.info('🤖 Init BETA automate module')
await initScopes()
}
}
export = automationModule
@@ -1,216 +0,0 @@
import { Logger } from '@/logging/logging'
import {
AutomationFunctionRunRecord,
AutomationFunctionRunsResultVersionRecord,
AutomationRecord,
AutomationRunRecord
} from '@/modules/betaAutomations/helpers/types'
import {
BetaAutomations,
BetaAutomationRuns,
BetaAutomationFunctionRuns,
BetaAutomationFunctionRunsResultVersions,
Commits
} from '@/modules/core/dbSchema'
import { CommitRecord } from '@/modules/core/helpers/types'
import { Optional } from '@speckle/shared'
import { isArray, pick } from 'lodash'
import { SetOptional } from 'type-fest'
export const upsertAutomation = async (
automation: SetOptional<AutomationRecord, 'createdAt' | 'updatedAt'>
) =>
await BetaAutomations.knex()
.insert(pick(automation, BetaAutomations.withoutTablePrefix.cols))
.onConflict([
BetaAutomations.withoutTablePrefix.col.automationId,
BetaAutomations.withoutTablePrefix.col.automationRevisionId
])
.merge(
BetaAutomations.withoutTablePrefix.cols.filter(
(c) => c !== BetaAutomations.withoutTablePrefix.col.createdAt
)
)
export const getAutomation = async (
automationId: string
): Promise<Optional<AutomationRecord>> => {
return await BetaAutomations.knex<AutomationRecord>()
.where({ [BetaAutomations.col.automationId]: automationId })
.first()
}
export const upsertAutomationRunData = async (automationRun: AutomationRunRecord) => {
const insertModel = pick(
automationRun,
BetaAutomationRuns.withoutTablePrefix.cols
) as AutomationRunRecord
return await BetaAutomationRuns.knex()
.insert(insertModel)
.onConflict(BetaAutomationRuns.withoutTablePrefix.col.automationRunId)
.merge()
}
export const upsertAutomationFunctionRunData = async (
automationFunctionRuns: AutomationFunctionRunRecord | AutomationFunctionRunRecord[],
logger: Logger
) => {
const runs = isArray(automationFunctionRuns)
? automationFunctionRuns
: [automationFunctionRuns]
logger.info({ runs }, 'Upserting runs.')
const normalizedModels = runs.map((run) => {
return pick(
run,
BetaAutomationFunctionRuns.withoutTablePrefix.cols
) as AutomationFunctionRunRecord
})
logger.info({ normalizedModels }, 'Normalized runs.')
return await BetaAutomationFunctionRuns.knex()
.insert(normalizedModels)
.onConflict([
BetaAutomationFunctionRuns.withoutTablePrefix.col.automationRunId,
BetaAutomationFunctionRuns.withoutTablePrefix.col.functionId
])
.merge()
}
export const insertAutomationFunctionRunResultVersion = async (
functionRunVersions:
| AutomationFunctionRunsResultVersionRecord
| AutomationFunctionRunsResultVersionRecord[]
) => {
const versions = isArray(functionRunVersions)
? functionRunVersions
: [functionRunVersions]
if (!versions.length) return
const normalizedModels = versions.map((run) => {
return pick(
run,
BetaAutomationFunctionRunsResultVersions.withoutTablePrefix.cols
) as AutomationFunctionRunsResultVersionRecord
})
return await BetaAutomationFunctionRunsResultVersions.knex().insert(normalizedModels)
}
export const deleteResultVersionsForRuns = async (
keyPairs: [functionId: string, automationRunId: string][]
) => {
return await BetaAutomationFunctionRunsResultVersions.knex()
.whereIn(
[
BetaAutomationFunctionRunsResultVersions.col.functionId,
BetaAutomationFunctionRunsResultVersions.col.automationRunId
],
keyPairs
)
.del()
}
export const getAutomationRun = async (
automationRunId: string
): Promise<Optional<AutomationRunRecord>> => {
return await BetaAutomationRuns.knex<AutomationRunRecord>()
.where({ [BetaAutomationRuns.col.automationRunId]: automationRunId })
.first()
}
export const getLatestAutomationRunsFor = async (
params: {
projectId: string
modelId: string
versionId: string
},
options?: Partial<{
limit: number
}>
): Promise<AutomationRunRecord[]> => {
const { projectId, modelId, versionId } = params
const { limit = 20 } = options || {}
const runs = await BetaAutomationRuns.knex()
.select<AutomationRunRecord[]>([
...BetaAutomationRuns.cols,
`${BetaAutomations.name}.${BetaAutomations.withoutTablePrefix.col.automationName}`
])
.join(
BetaAutomations.name,
BetaAutomationRuns.col.automationId,
BetaAutomations.col.automationId
)
.where({ [BetaAutomations.col.projectId]: projectId })
.andWhere({ [BetaAutomations.col.modelId]: modelId })
.andWhere({ [BetaAutomationRuns.col.versionId]: versionId })
.distinctOn(BetaAutomationRuns.col.automationId)
.orderBy([
{ column: BetaAutomationRuns.col.automationId },
{ column: BetaAutomationRuns.col.createdAt, order: 'desc' }
])
.limit(limit)
return runs
}
/**
* Get function runs for automation runs. The result is an object keyed by automationRunId,
* with each value being a map between functionId and function run.
*/
export const getFunctionRunsForAutomationRuns = async (
automationRunids: string[]
): Promise<Record<string, Record<string, AutomationFunctionRunRecord>>> => {
const runs = await BetaAutomationFunctionRuns.knex()
.select<AutomationFunctionRunRecord[]>(BetaAutomationFunctionRuns.cols)
.whereIn(BetaAutomationFunctionRuns.col.automationRunId, automationRunids)
const grouped = runs.reduce((acc, run) => {
if (!acc[run.automationRunId]) acc[run.automationRunId] = {}
acc[run.automationRunId][run.functionId] = run
return acc
}, {} as Record<string, Record<string, AutomationFunctionRunRecord>>)
return grouped
}
/**
* Get versions/commits for specified function runs. The result is an object keyed by automationRunId,
* with each value being a map between functionId and a commit.
*/
export const getAutomationFunctionRunResultVersions = async (
idPairs: Array<[automationRunId: string, functionId: string]>
): Promise<Record<string, Record<string, CommitRecord[]>>> => {
const q = BetaAutomationFunctionRunsResultVersions.knex()
.select<Array<CommitRecord & AutomationFunctionRunsResultVersionRecord>>(
...Commits.cols,
...BetaAutomationFunctionRunsResultVersions.cols
)
.innerJoin(
Commits.name,
BetaAutomationFunctionRunsResultVersions.col.resultVersionId,
Commits.col.id
)
.whereIn(
[
BetaAutomationFunctionRunsResultVersions.col.automationRunId,
BetaAutomationFunctionRunsResultVersions.col.functionId
],
idPairs
)
const versions = await q
const grouped = versions.reduce((acc, version) => {
if (!acc[version.automationRunId]) acc[version.automationRunId] = {}
if (!acc[version.automationRunId][version.functionId])
acc[version.automationRunId][version.functionId] = []
acc[version.automationRunId][version.functionId].push(version)
return acc
}, {} as Record<string, Record<string, CommitRecord[]>>)
return grouped
}
@@ -1,283 +0,0 @@
import { getBranchById } from '@/modules/core/repositories/branches'
import { getStream } from '@/modules/core/repositories/streams'
import { MaybeNullOrUndefined, Roles } from '@speckle/shared'
import {
getAutomationRun,
getAutomation,
upsertAutomation,
upsertAutomationFunctionRunData,
insertAutomationFunctionRunResultVersion,
getLatestAutomationRunsFor,
getFunctionRunsForAutomationRuns,
deleteResultVersionsForRuns
} from '@/modules/betaAutomations/repositories/automations'
import _, { flatMap, uniqBy } from 'lodash'
import {
AutomationCreateInput,
AutomationRunStatusUpdateInput,
AutomationRunStatus,
AutomationRun
} from '@/modules/core/graph/generated/graphql'
import { upsertAutomationRunData } from '@/modules/betaAutomations/repositories/automations'
import {
AutomationFunctionRunRecord,
AutomationFunctionRunsResultVersionRecord,
AutomationRunRecord
} from '@/modules/betaAutomations/helpers/types'
import { ForbiddenError } from '@/modules/shared/errors'
import { Merge } from 'type-fest'
import { AutomationFunctionRunGraphQLReturn } from '@/modules/betaAutomations/helpers/graphTypes'
import { AutomationRunSchema } from '@/modules/betaAutomations/helpers/inputTypes'
import { StreamNotFoundError } from '@/modules/core/errors/stream'
import { BranchNotFoundError } from '@/modules/core/errors/branch'
import {
getCommits,
getCommit,
getCommitBranch
} from '@/modules/core/repositories/commits'
import { AutomationNotFoundError } from '@/modules/betaAutomations/errors/automations'
import { CommitNotFoundError } from '@/modules/core/errors/commit'
import { ProjectSubscriptions, publish } from '@/modules/shared/utils/subscriptions'
import { Logger } from '@/logging/logging'
type AutomationRunWithFunctionRunsRecord = AutomationRunRecord & {
functionRuns: AutomationFunctionRunRecord[]
}
export const createModelAutomation = async (
automation: AutomationCreateInput,
userId?: string
) => {
// stream acl for user
const stream = await getStream({ userId, streamId: automation.projectId })
if (!stream) throw new StreamNotFoundError('Project not found')
if (stream.role !== Roles.Stream.Owner)
throw new ForbiddenError('Only project owners are allowed.')
const branch = await getBranchById(automation.modelId, {
streamId: automation.projectId
})
if (!branch) throw new BranchNotFoundError('Model not found')
const insertModel = { ...automation, modelId: branch.id, createdAt: new Date() }
await upsertAutomation(insertModel)
}
export async function upsertModelAutomationRunResult({
userId,
input,
logger
}: {
userId: MaybeNullOrUndefined<string>
input: AutomationRunStatusUpdateInput
logger: Logger
}) {
logger.info({ input }, 'Received automation run result data')
// validate input against schema
const validatedInput = AutomationRunSchema.parse({
...input,
createdAt: new Date(),
updatedAt: new Date()
})
logger.info({ validatedInput }, 'Validated automation run result data')
// get the automation from the DB
const automation = await getAutomation(input.automationId)
if (!automation) throw new AutomationNotFoundError()
const [stream, version, model] = await Promise.all([
getStream({
userId: userId || undefined,
streamId: automation.projectId
}),
getCommit(validatedInput.versionId, {
streamId: automation.projectId
}),
getCommitBranch(validatedInput.versionId)
])
// this is never going to happen, cause the automation has an FK to the streamId
if (!stream) throw new StreamNotFoundError('Project not found')
if (stream.role !== Roles.Stream.Owner)
throw new ForbiddenError('Only project owners are allowed')
if (!version) throw new CommitNotFoundError()
if (!model) throw new BranchNotFoundError()
// store the result of the run, if it already exists, patch it
const maybeAutomationRun = await getAutomationRun(input.automationRunId)
if (maybeAutomationRun) {
// some bits we do not allow overriding
validatedInput.createdAt = maybeAutomationRun.createdAt
validatedInput.versionId = maybeAutomationRun.versionId
validatedInput.automationId = maybeAutomationRun.automationId
validatedInput.automationRevisionId = maybeAutomationRun.automationRevisionId
}
await upsertAutomationRunData({ ...validatedInput, automationName: 'pasta' })
// upsert run function runs
const runs = uniqBy(
validatedInput.functionRuns.map(
(s): AutomationFunctionRunRecord => ({
...s,
automationRunId: validatedInput.automationRunId
})
),
(v) => `${v.automationRunId}-${v.functionId}`
)
logger.info({ runs }, 'Uniqued automation run result data')
await upsertAutomationFunctionRunData(runs, logger)
// create new result version records
const versionsRecords: AutomationFunctionRunsResultVersionRecord[] = flatMap(
validatedInput.functionRuns
.filter((s) => s.resultVersionIds?.length)
.map((s) => ({
functionId: s.functionId,
automationRunId: validatedInput.automationRunId,
resultVersionIds: s.resultVersionIds
})),
(i) => {
return i.resultVersionIds.map((v) => ({
functionId: i.functionId,
automationRunId: i.automationRunId,
resultVersionId: v
}))
}
)
logger.info({ versionsRecords }, 'Version records flat mapped')
const validatedVersions = await getCommits(
versionsRecords.map((r) => r.resultVersionId)
)
const validVersionsRecords = uniqBy(
versionsRecords.filter((r) =>
validatedVersions.find(
(vv) => vv.id === r.resultVersionId && vv.streamId === stream.id
)
),
(v) => `${v.automationRunId}-${v.functionId}-${v.resultVersionId}`
)
// delete old/stale versions and re-insert new valid ones (in case this is an update to an existing run)
await deleteResultVersionsForRuns(
validatedInput.functionRuns.map((s) => [
s.functionId,
validatedInput.automationRunId
])
)
await insertAutomationFunctionRunResultVersion(validVersionsRecords)
// Emit subscription
const newStatus = await getAutomationsStatus({
modelId: version.branchId,
projectId: stream.id,
versionId: version.id
})
logger.info({ newStatus }, 'Emiting new status event')
if (newStatus) {
await publish(ProjectSubscriptions.ProjectAutomationStatusUpdated, {
projectId: stream.id,
projectAutomationsStatusUpdated: {
status: newStatus,
version,
project: stream,
model
}
})
}
}
const anyFunctionRunsHaveStatus = (
ar: AutomationRunWithFunctionRunsRecord,
status: AutomationRunStatus
) => ar.functionRuns.some((st) => st.status === status)
const anyFunctionRunsHaveFailed = (ar: AutomationRunWithFunctionRunsRecord): boolean =>
anyFunctionRunsHaveStatus(ar, AutomationRunStatus.Failed)
const anyFunctionRunsRunning = (ar: AutomationRunWithFunctionRunsRecord): boolean =>
anyFunctionRunsHaveStatus(ar, AutomationRunStatus.Running)
const anyFunctionRunsInitializing = (
ar: AutomationRunWithFunctionRunsRecord
): boolean => anyFunctionRunsHaveStatus(ar, AutomationRunStatus.Initializing)
export const getAutomationsStatus = async ({
projectId,
modelId,
versionId
}: {
projectId: string
modelId: string
versionId: string
}) => {
const automationRunRecords = await getLatestAutomationRunsFor({
projectId,
modelId,
versionId
})
if (!automationRunRecords.length) return null
const functionRuns = await getFunctionRunsForAutomationRuns(
automationRunRecords.map((r) => r.automationRunId)
)
const runsWithFunctionRuns: AutomationRunWithFunctionRunsRecord[] =
automationRunRecords.map((ar) => {
return {
...ar,
functionRuns: Object.values(functionRuns[ar.automationRunId] || {})
}
})
const automationRuns: Array<
Merge<AutomationRun, { functionRuns: AutomationFunctionRunGraphQLReturn[] }>
> = runsWithFunctionRuns.map((ar) => {
let status: AutomationRunStatus = AutomationRunStatus.Succeeded
if (anyFunctionRunsHaveFailed(ar)) {
status = AutomationRunStatus.Failed
} else if (anyFunctionRunsRunning(ar)) {
status = AutomationRunStatus.Running
} else if (anyFunctionRunsInitializing(ar)) {
status = AutomationRunStatus.Initializing
}
return { ..._.cloneDeep(ar), status, id: ar.automationRunId }
})
const failedAutomations = automationRuns.filter(
(a) => a.status === AutomationRunStatus.Failed
)
const runningAutomations = automationRuns.filter(
(a) => a.status === AutomationRunStatus.Running
)
const initializingAutomations = automationRuns.filter(
(a) => a.status === AutomationRunStatus.Initializing
)
let status = AutomationRunStatus.Succeeded
let statusMessage = 'All automations have succeeded'
if (failedAutomations.length) {
status = AutomationRunStatus.Failed
statusMessage = 'Some automations have failed:'
for (const fa of failedAutomations) {
for (const functionRunStatus of fa.functionRuns) {
if (functionRunStatus.status === AutomationRunStatus.Failed)
statusMessage += `\n${functionRunStatus.statusMessage}`
}
}
} else if (runningAutomations.length) {
status = AutomationRunStatus.Running
statusMessage = 'Some automations are running'
} else if (initializingAutomations.length) {
status = AutomationRunStatus.Initializing
statusMessage = 'Some automations are initializing'
}
return {
status,
automationRuns,
statusMessage,
id: versionId
}
}
@@ -1,10 +0,0 @@
import {
Results,
CurrentVersionResults
} from '@/modules/betaAutomations/helpers/inputTypes'
export const formatResults = (results: Results): CurrentVersionResults => {
// TODO: As new versions are introduced, make sure this function is updated
// and able to convert all of them to `CurrentVersionResults`
return results
}
-40
View File
@@ -489,46 +489,6 @@ export const FileUploads = buildTableHelper('file_uploads', [
'convertedCommitId'
])
export const BetaAutomations = buildTableHelper('beta_automations', [
'automationId',
'automationRevisionId',
'automationName',
'projectId',
'modelId',
'createdAt',
'updatedAt',
'webhookId'
])
export const BetaAutomationRuns = buildTableHelper('beta_automation_runs', [
'automationId',
'automationRevisionId',
'automationRunId',
'versionId',
'createdAt',
'updatedAt'
])
export const BetaAutomationFunctionRuns = buildTableHelper(
'beta_automation_function_runs',
[
'automationRunId',
'functionId',
'functionName',
'functionLogo',
'elapsed',
'status',
'contextView',
'statusMessage',
'results'
]
)
export const BetaAutomationFunctionRunsResultVersions = buildTableHelper(
'beta_automation_function_runs_result_versions',
['automationRunId', 'functionId', 'resultVersionId']
)
export const ServerAppsScopes = buildTableHelper('server_apps_scopes', [
'appId',
'scopeName'
@@ -4,7 +4,6 @@ import { StreamAccessRequestGraphQLReturn } from '@/modules/accessrequests/helpe
import { CommentReplyAuthorCollectionGraphQLReturn, CommentGraphQLReturn } from '@/modules/comments/helpers/graphTypes';
import { PendingStreamCollaboratorGraphQLReturn } from '@/modules/serverinvites/helpers/graphTypes';
import { FileUploadGraphQLReturn } from '@/modules/fileuploads/helpers/types';
import { AutomationFunctionRunGraphQLReturn } from '@/modules/betaAutomations/helpers/graphTypes';
import { AutomateFunctionGraphQLReturn, AutomateFunctionReleaseGraphQLReturn, AutomationGraphQLReturn, AutomationRevisionGraphQLReturn, AutomationRevisionFunctionGraphQLReturn, AutomateRunGraphQLReturn, AutomationRunTriggerGraphQLReturn, AutomationRevisionTriggerDefinitionGraphQLReturn, AutomateFunctionRunGraphQLReturn, TriggeredAutomationsStatusGraphQLReturn, ProjectAutomationMutationsGraphQLReturn, ProjectTriggeredAutomationsStatusUpdatedMessageGraphQLReturn, ProjectAutomationsUpdatedMessageGraphQLReturn, UserAutomateInfoGraphQLReturn } from '@/modules/automate/helpers/graphTypes';
import { GraphQLContext } from '@/modules/shared/helpers/typeHelper';
export type Maybe<T> = T | null;
@@ -384,62 +383,6 @@ export type AutomationCollection = {
totalCount: Scalars['Int']['output'];
};
export type AutomationCreateInput = {
automationId: Scalars['String']['input'];
automationName: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
modelId: Scalars['String']['input'];
projectId: Scalars['String']['input'];
webhookId?: InputMaybe<Scalars['String']['input']>;
};
export type AutomationFunctionRun = {
__typename?: 'AutomationFunctionRun';
contextView?: Maybe<Scalars['String']['output']>;
elapsed: Scalars['Float']['output'];
functionId: Scalars['String']['output'];
functionLogo?: Maybe<Scalars['String']['output']>;
functionName: Scalars['String']['output'];
id: Scalars['ID']['output'];
resultVersions: Array<Version>;
/**
* NOTE: this is the schema for the results field below!
* Current schema: {
* version: "1.0.0",
* values: {
* objectResults: Record<str, {
* category: string
* level: ObjectResultLevel
* objectIds: string[]
* message: str | null
* metadata: Records<str, unknown> | null
* visualoverrides: Records<str, unknown> | null
* }[]>
* blobIds?: string[]
* }
* }
*/
results?: Maybe<Scalars['JSONObject']['output']>;
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AutomationMutations = {
__typename?: 'AutomationMutations';
create: Scalars['Boolean']['output'];
functionRunStatusReport: Scalars['Boolean']['output'];
};
export type AutomationMutationsCreateArgs = {
input: AutomationCreateInput;
};
export type AutomationMutationsFunctionRunStatusReportArgs = {
input: AutomationRunStatusUpdateInput;
};
export type AutomationRevision = {
__typename?: 'AutomationRevision';
functions: Array<AutomationRevisionFunction>;
@@ -463,44 +406,8 @@ export type AutomationRevisionFunction = {
export type AutomationRevisionTriggerDefinition = VersionCreatedTriggerDefinition;
export type AutomationRun = {
__typename?: 'AutomationRun';
automationId: Scalars['String']['output'];
automationName: Scalars['String']['output'];
createdAt: Scalars['DateTime']['output'];
functionRuns: Array<AutomationFunctionRun>;
id: Scalars['ID']['output'];
/** Resolved from all function run statuses */
status: AutomationRunStatus;
updatedAt: Scalars['DateTime']['output'];
versionId: Scalars['String']['output'];
};
export enum AutomationRunStatus {
Failed = 'FAILED',
Initializing = 'INITIALIZING',
Running = 'RUNNING',
Succeeded = 'SUCCEEDED'
}
export type AutomationRunStatusUpdateInput = {
automationId: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
automationRunId: Scalars['String']['input'];
functionRuns: Array<FunctionRunStatusInput>;
versionId: Scalars['String']['input'];
};
export type AutomationRunTrigger = VersionCreatedTrigger;
export type AutomationsStatus = {
__typename?: 'AutomationsStatus';
automationRuns: Array<AutomationRun>;
id: Scalars['ID']['output'];
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AvatarUser = {
__typename?: 'AvatarUser';
avatar?: Maybe<Scalars['String']['output']>;
@@ -950,27 +857,6 @@ export type FileUpload = {
userId: Scalars['String']['output'];
};
export type FunctionRunStatusInput = {
contextView?: InputMaybe<Scalars['String']['input']>;
elapsed: Scalars['Float']['input'];
functionId: Scalars['String']['input'];
functionLogo?: InputMaybe<Scalars['String']['input']>;
functionName: Scalars['String']['input'];
resultVersionIds: Array<Scalars['String']['input']>;
/**
* Current schema: {
* version: "1.0.0",
* values: {
* speckleObjects: Record<ObjectId, {level: string; statusMessage: string}[]>
* blobIds?: string[]
* }
* }
*/
results?: InputMaybe<Scalars['JSONObject']['input']>;
status: AutomationRunStatus;
statusMessage?: InputMaybe<Scalars['String']['input']>;
};
export type GendoAiRender = {
__typename?: 'GendoAIRender';
camera?: Maybe<Scalars['JSONObject']['output']>;
@@ -1096,7 +982,6 @@ export type LimitedUserTimelineArgs = {
export type Model = {
__typename?: 'Model';
author: LimitedUser;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** Return a model tree of children */
childrenTree: Array<ModelsTreeItem>;
@@ -1229,7 +1114,6 @@ export type Mutation = {
appUpdate: Scalars['Boolean']['output'];
automateFunctionRunStatusReport: Scalars['Boolean']['output'];
automateMutations: AutomateMutations;
automationMutations: AutomationMutations;
branchCreate: Scalars['String']['output'];
branchDelete: Scalars['Boolean']['output'];
branchUpdate: Scalars['Boolean']['output'];
@@ -1915,14 +1799,6 @@ export type ProjectAutomationUpdateInput = {
name?: InputMaybe<Scalars['String']['input']>;
};
export type ProjectAutomationsStatusUpdatedMessage = {
__typename?: 'ProjectAutomationsStatusUpdatedMessage';
model: Model;
project: Project;
status: AutomationsStatus;
version: Version;
};
export type ProjectAutomationsUpdatedMessage = {
__typename?: 'ProjectAutomationsUpdatedMessage';
automation?: Maybe<Automation>;
@@ -2889,7 +2765,6 @@ export type Subscription = {
commitDeleted?: Maybe<Scalars['JSONObject']['output']>;
/** Subscribe to commit updated event. */
commitUpdated?: Maybe<Scalars['JSONObject']['output']>;
projectAutomationsStatusUpdated: ProjectAutomationsStatusUpdatedMessage;
/** Subscribe to updates to automations in the project */
projectAutomationsUpdated: ProjectAutomationsUpdatedMessage;
/**
@@ -2985,11 +2860,6 @@ export type SubscriptionCommitUpdatedArgs = {
};
export type SubscriptionProjectAutomationsStatusUpdatedArgs = {
projectId: Scalars['String']['input'];
};
export type SubscriptionProjectAutomationsUpdatedArgs = {
projectId: Scalars['String']['input'];
};
@@ -3331,7 +3201,6 @@ export type UserUpdateInput = {
export type Version = {
__typename?: 'Version';
authorUser?: Maybe<LimitedUser>;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** All comment threads in this version */
commentThreads: CommentCollection;
@@ -3634,18 +3503,11 @@ export type ResolversTypes = {
AutomateRunTriggerType: AutomateRunTriggerType;
Automation: ResolverTypeWrapper<AutomationGraphQLReturn>;
AutomationCollection: ResolverTypeWrapper<Omit<AutomationCollection, 'items'> & { items: Array<ResolversTypes['Automation']> }>;
AutomationCreateInput: AutomationCreateInput;
AutomationFunctionRun: ResolverTypeWrapper<AutomationFunctionRunGraphQLReturn>;
AutomationMutations: ResolverTypeWrapper<MutationsObjectGraphQLReturn>;
AutomationRevision: ResolverTypeWrapper<AutomationRevisionGraphQLReturn>;
AutomationRevisionCreateFunctionInput: AutomationRevisionCreateFunctionInput;
AutomationRevisionFunction: ResolverTypeWrapper<AutomationRevisionFunctionGraphQLReturn>;
AutomationRevisionTriggerDefinition: ResolverTypeWrapper<AutomationRevisionTriggerDefinitionGraphQLReturn>;
AutomationRun: ResolverTypeWrapper<Omit<AutomationRun, 'functionRuns'> & { functionRuns: Array<ResolversTypes['AutomationFunctionRun']> }>;
AutomationRunStatus: AutomationRunStatus;
AutomationRunStatusUpdateInput: AutomationRunStatusUpdateInput;
AutomationRunTrigger: ResolverTypeWrapper<AutomationRunTriggerGraphQLReturn>;
AutomationsStatus: ResolverTypeWrapper<Omit<AutomationsStatus, 'automationRuns'> & { automationRuns: Array<ResolversTypes['AutomationRun']> }>;
AvatarUser: ResolverTypeWrapper<AvatarUser>;
BasicGitRepositoryMetadata: ResolverTypeWrapper<BasicGitRepositoryMetadata>;
BigInt: ResolverTypeWrapper<Scalars['BigInt']['output']>;
@@ -3690,7 +3552,6 @@ export type ResolversTypes = {
EmailAddress: ResolverTypeWrapper<Scalars['EmailAddress']['output']>;
FileUpload: ResolverTypeWrapper<FileUploadGraphQLReturn>;
Float: ResolverTypeWrapper<Scalars['Float']['output']>;
FunctionRunStatusInput: FunctionRunStatusInput;
GendoAIRender: ResolverTypeWrapper<GendoAiRender>;
GendoAIRenderCollection: ResolverTypeWrapper<GendoAiRenderCollection>;
GendoAIRenderInput: GendoAiRenderInput;
@@ -3718,7 +3579,6 @@ export type ResolversTypes = {
ProjectAutomationMutations: ResolverTypeWrapper<ProjectAutomationMutationsGraphQLReturn>;
ProjectAutomationRevisionCreateInput: ProjectAutomationRevisionCreateInput;
ProjectAutomationUpdateInput: ProjectAutomationUpdateInput;
ProjectAutomationsStatusUpdatedMessage: ResolverTypeWrapper<Omit<ProjectAutomationsStatusUpdatedMessage, 'model' | 'project' | 'status' | 'version'> & { model: ResolversTypes['Model'], project: ResolversTypes['Project'], status: ResolversTypes['AutomationsStatus'], version: ResolversTypes['Version'] }>;
ProjectAutomationsUpdatedMessage: ResolverTypeWrapper<ProjectAutomationsUpdatedMessageGraphQLReturn>;
ProjectAutomationsUpdatedMessageType: ProjectAutomationsUpdatedMessageType;
ProjectCollaborator: ResolverTypeWrapper<Omit<ProjectCollaborator, 'user'> & { user: ResolversTypes['LimitedUser'] }>;
@@ -3858,17 +3718,11 @@ export type ResolversParentTypes = {
AutomateRunCollection: Omit<AutomateRunCollection, 'items'> & { items: Array<ResolversParentTypes['AutomateRun']> };
Automation: AutomationGraphQLReturn;
AutomationCollection: Omit<AutomationCollection, 'items'> & { items: Array<ResolversParentTypes['Automation']> };
AutomationCreateInput: AutomationCreateInput;
AutomationFunctionRun: AutomationFunctionRunGraphQLReturn;
AutomationMutations: MutationsObjectGraphQLReturn;
AutomationRevision: AutomationRevisionGraphQLReturn;
AutomationRevisionCreateFunctionInput: AutomationRevisionCreateFunctionInput;
AutomationRevisionFunction: AutomationRevisionFunctionGraphQLReturn;
AutomationRevisionTriggerDefinition: AutomationRevisionTriggerDefinitionGraphQLReturn;
AutomationRun: Omit<AutomationRun, 'functionRuns'> & { functionRuns: Array<ResolversParentTypes['AutomationFunctionRun']> };
AutomationRunStatusUpdateInput: AutomationRunStatusUpdateInput;
AutomationRunTrigger: AutomationRunTriggerGraphQLReturn;
AutomationsStatus: Omit<AutomationsStatus, 'automationRuns'> & { automationRuns: Array<ResolversParentTypes['AutomationRun']> };
AvatarUser: AvatarUser;
BasicGitRepositoryMetadata: BasicGitRepositoryMetadata;
BigInt: Scalars['BigInt']['output'];
@@ -3912,7 +3766,6 @@ export type ResolversParentTypes = {
EmailAddress: Scalars['EmailAddress']['output'];
FileUpload: FileUploadGraphQLReturn;
Float: Scalars['Float']['output'];
FunctionRunStatusInput: FunctionRunStatusInput;
GendoAIRender: GendoAiRender;
GendoAIRenderCollection: GendoAiRenderCollection;
GendoAIRenderInput: GendoAiRenderInput;
@@ -3940,7 +3793,6 @@ export type ResolversParentTypes = {
ProjectAutomationMutations: ProjectAutomationMutationsGraphQLReturn;
ProjectAutomationRevisionCreateInput: ProjectAutomationRevisionCreateInput;
ProjectAutomationUpdateInput: ProjectAutomationUpdateInput;
ProjectAutomationsStatusUpdatedMessage: Omit<ProjectAutomationsStatusUpdatedMessage, 'model' | 'project' | 'status' | 'version'> & { model: ResolversParentTypes['Model'], project: ResolversParentTypes['Project'], status: ResolversParentTypes['AutomationsStatus'], version: ResolversParentTypes['Version'] };
ProjectAutomationsUpdatedMessage: ProjectAutomationsUpdatedMessageGraphQLReturn;
ProjectCollaborator: Omit<ProjectCollaborator, 'user'> & { user: ResolversParentTypes['LimitedUser'] };
ProjectCollection: Omit<ProjectCollection, 'items'> & { items: Array<ResolversParentTypes['Project']> };
@@ -4265,26 +4117,6 @@ export type AutomationCollectionResolvers<ContextType = GraphQLContext, ParentTy
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AutomationFunctionRunResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationFunctionRun'] = ResolversParentTypes['AutomationFunctionRun']> = {
contextView?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
elapsed?: Resolver<ResolversTypes['Float'], ParentType, ContextType>;
functionId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
functionLogo?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
functionName?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
resultVersions?: Resolver<Array<ResolversTypes['Version']>, ParentType, ContextType>;
results?: Resolver<Maybe<ResolversTypes['JSONObject']>, ParentType, ContextType>;
status?: Resolver<ResolversTypes['AutomationRunStatus'], ParentType, ContextType>;
statusMessage?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AutomationMutationsResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationMutations'] = ResolversParentTypes['AutomationMutations']> = {
create?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<AutomationMutationsCreateArgs, 'input'>>;
functionRunStatusReport?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<AutomationMutationsFunctionRunStatusReportArgs, 'input'>>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AutomationRevisionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationRevision'] = ResolversParentTypes['AutomationRevision']> = {
functions?: Resolver<Array<ResolversTypes['AutomationRevisionFunction']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
@@ -4302,30 +4134,10 @@ export type AutomationRevisionTriggerDefinitionResolvers<ContextType = GraphQLCo
__resolveType: TypeResolveFn<'VersionCreatedTriggerDefinition', ParentType, ContextType>;
};
export type AutomationRunResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationRun'] = ResolversParentTypes['AutomationRun']> = {
automationId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
automationName?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
createdAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
functionRuns?: Resolver<Array<ResolversTypes['AutomationFunctionRun']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
status?: Resolver<ResolversTypes['AutomationRunStatus'], ParentType, ContextType>;
updatedAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
versionId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AutomationRunTriggerResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationRunTrigger'] = ResolversParentTypes['AutomationRunTrigger']> = {
__resolveType: TypeResolveFn<'VersionCreatedTrigger', ParentType, ContextType>;
};
export type AutomationsStatusResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AutomationsStatus'] = ResolversParentTypes['AutomationsStatus']> = {
automationRuns?: Resolver<Array<ResolversTypes['AutomationRun']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
status?: Resolver<ResolversTypes['AutomationRunStatus'], ParentType, ContextType>;
statusMessage?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type AvatarUserResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['AvatarUser'] = ResolversParentTypes['AvatarUser']> = {
avatar?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
@@ -4569,7 +4381,6 @@ export type LimitedUserResolvers<ContextType = GraphQLContext, ParentType extend
export type ModelResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['Model'] = ResolversParentTypes['Model']> = {
author?: Resolver<ResolversTypes['LimitedUser'], ParentType, ContextType>;
automationStatus?: Resolver<Maybe<ResolversTypes['AutomationsStatus']>, ParentType, ContextType>;
automationsStatus?: Resolver<Maybe<ResolversTypes['TriggeredAutomationsStatus']>, ParentType, ContextType>;
childrenTree?: Resolver<Array<ResolversTypes['ModelsTreeItem']>, ParentType, ContextType>;
commentThreads?: Resolver<ResolversTypes['CommentCollection'], ParentType, ContextType, RequireFields<ModelCommentThreadsArgs, 'limit'>>;
@@ -4631,7 +4442,6 @@ export type MutationResolvers<ContextType = GraphQLContext, ParentType extends R
appUpdate?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationAppUpdateArgs, 'app'>>;
automateFunctionRunStatusReport?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationAutomateFunctionRunStatusReportArgs, 'input'>>;
automateMutations?: Resolver<ResolversTypes['AutomateMutations'], ParentType, ContextType>;
automationMutations?: Resolver<ResolversTypes['AutomationMutations'], ParentType, ContextType>;
branchCreate?: Resolver<ResolversTypes['String'], ParentType, ContextType, RequireFields<MutationBranchCreateArgs, 'branch'>>;
branchDelete?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationBranchDeleteArgs, 'branch'>>;
branchUpdate?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationBranchUpdateArgs, 'branch'>>;
@@ -4769,14 +4579,6 @@ export type ProjectAutomationMutationsResolvers<ContextType = GraphQLContext, Pa
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type ProjectAutomationsStatusUpdatedMessageResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['ProjectAutomationsStatusUpdatedMessage'] = ResolversParentTypes['ProjectAutomationsStatusUpdatedMessage']> = {
model?: Resolver<ResolversTypes['Model'], ParentType, ContextType>;
project?: Resolver<ResolversTypes['Project'], ParentType, ContextType>;
status?: Resolver<ResolversTypes['AutomationsStatus'], ParentType, ContextType>;
version?: Resolver<ResolversTypes['Version'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
export type ProjectAutomationsUpdatedMessageResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['ProjectAutomationsUpdatedMessage'] = ResolversParentTypes['ProjectAutomationsUpdatedMessage']> = {
automation?: Resolver<Maybe<ResolversTypes['Automation']>, ParentType, ContextType>;
automationId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
@@ -5112,7 +4914,6 @@ export type SubscriptionResolvers<ContextType = GraphQLContext, ParentType exten
commitCreated?: SubscriptionResolver<Maybe<ResolversTypes['JSONObject']>, "commitCreated", ParentType, ContextType, RequireFields<SubscriptionCommitCreatedArgs, 'streamId'>>;
commitDeleted?: SubscriptionResolver<Maybe<ResolversTypes['JSONObject']>, "commitDeleted", ParentType, ContextType, RequireFields<SubscriptionCommitDeletedArgs, 'streamId'>>;
commitUpdated?: SubscriptionResolver<Maybe<ResolversTypes['JSONObject']>, "commitUpdated", ParentType, ContextType, RequireFields<SubscriptionCommitUpdatedArgs, 'streamId'>>;
projectAutomationsStatusUpdated?: SubscriptionResolver<ResolversTypes['ProjectAutomationsStatusUpdatedMessage'], "projectAutomationsStatusUpdated", ParentType, ContextType, RequireFields<SubscriptionProjectAutomationsStatusUpdatedArgs, 'projectId'>>;
projectAutomationsUpdated?: SubscriptionResolver<ResolversTypes['ProjectAutomationsUpdatedMessage'], "projectAutomationsUpdated", ParentType, ContextType, RequireFields<SubscriptionProjectAutomationsUpdatedArgs, 'projectId'>>;
projectCommentsUpdated?: SubscriptionResolver<ResolversTypes['ProjectCommentsUpdatedMessage'], "projectCommentsUpdated", ParentType, ContextType, RequireFields<SubscriptionProjectCommentsUpdatedArgs, 'target'>>;
projectFileImportUpdated?: SubscriptionResolver<ResolversTypes['ProjectFileImportUpdatedMessage'], "projectFileImportUpdated", ParentType, ContextType, RequireFields<SubscriptionProjectFileImportUpdatedArgs, 'id'>>;
@@ -5218,7 +5019,6 @@ export type UserSearchResultCollectionResolvers<ContextType = GraphQLContext, Pa
export type VersionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['Version'] = ResolversParentTypes['Version']> = {
authorUser?: Resolver<Maybe<ResolversTypes['LimitedUser']>, ParentType, ContextType>;
automationStatus?: Resolver<Maybe<ResolversTypes['AutomationsStatus']>, ParentType, ContextType>;
automationsStatus?: Resolver<Maybe<ResolversTypes['TriggeredAutomationsStatus']>, ParentType, ContextType>;
commentThreads?: Resolver<ResolversTypes['CommentCollection'], ParentType, ContextType, RequireFields<VersionCommentThreadsArgs, 'limit'>>;
createdAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
@@ -5346,14 +5146,10 @@ export type Resolvers<ContextType = GraphQLContext> = {
AutomateRunCollection?: AutomateRunCollectionResolvers<ContextType>;
Automation?: AutomationResolvers<ContextType>;
AutomationCollection?: AutomationCollectionResolvers<ContextType>;
AutomationFunctionRun?: AutomationFunctionRunResolvers<ContextType>;
AutomationMutations?: AutomationMutationsResolvers<ContextType>;
AutomationRevision?: AutomationRevisionResolvers<ContextType>;
AutomationRevisionFunction?: AutomationRevisionFunctionResolvers<ContextType>;
AutomationRevisionTriggerDefinition?: AutomationRevisionTriggerDefinitionResolvers<ContextType>;
AutomationRun?: AutomationRunResolvers<ContextType>;
AutomationRunTrigger?: AutomationRunTriggerResolvers<ContextType>;
AutomationsStatus?: AutomationsStatusResolvers<ContextType>;
AvatarUser?: AvatarUserResolvers<ContextType>;
BasicGitRepositoryMetadata?: BasicGitRepositoryMetadataResolvers<ContextType>;
BigInt?: GraphQLScalarType;
@@ -5392,7 +5188,6 @@ export type Resolvers<ContextType = GraphQLContext> = {
PendingStreamCollaborator?: PendingStreamCollaboratorResolvers<ContextType>;
Project?: ProjectResolvers<ContextType>;
ProjectAutomationMutations?: ProjectAutomationMutationsResolvers<ContextType>;
ProjectAutomationsStatusUpdatedMessage?: ProjectAutomationsStatusUpdatedMessageResolvers<ContextType>;
ProjectAutomationsUpdatedMessage?: ProjectAutomationsUpdatedMessageResolvers<ContextType>;
ProjectCollaborator?: ProjectCollaboratorResolvers<ContextType>;
ProjectCollection?: ProjectCollectionResolvers<ContextType>;
-20
View File
@@ -55,7 +55,6 @@ import { metaHelpers } from '@/modules/core/helpers/meta'
import { Users } from '@/modules/core/dbSchema'
import { getStreamPendingModels } from '@/modules/fileuploads/repositories/fileUploads'
import { FileUploadRecord } from '@/modules/fileuploads/helpers/types'
import { getAutomationFunctionRunResultVersions } from '@/modules/betaAutomations/repositories/automations'
import { getAppScopes } from '@/modules/auth/repositories'
import {
AutomateRevisionFunctionRecord,
@@ -530,25 +529,6 @@ export function buildRequestLoaders(
return appIds.map((i) => results[i] || [])
})
},
automationFunctionRuns: {
/**
* Get result versions/commits from function runs
*/
getResultVersions: createLoader<
[automationRunId: string, functionId: string],
CommitRecord[],
string
>(
async (ids) => {
const results = await getAutomationFunctionRunResultVersions(ids.slice())
return ids.map((i) => {
const [automationRunId, functionId] = i
return results[automationRunId]?.[functionId] || []
})
},
{ cacheKeyFn: (key) => `${key[0]}:${key[1]}` }
)
},
automations: {
getFunctionAutomationCount: createLoader<string, number>(async (functionIds) => {
const results = await getFunctionAutomationCounts({
@@ -373,62 +373,6 @@ export type AutomationCollection = {
totalCount: Scalars['Int']['output'];
};
export type AutomationCreateInput = {
automationId: Scalars['String']['input'];
automationName: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
modelId: Scalars['String']['input'];
projectId: Scalars['String']['input'];
webhookId?: InputMaybe<Scalars['String']['input']>;
};
export type AutomationFunctionRun = {
__typename?: 'AutomationFunctionRun';
contextView?: Maybe<Scalars['String']['output']>;
elapsed: Scalars['Float']['output'];
functionId: Scalars['String']['output'];
functionLogo?: Maybe<Scalars['String']['output']>;
functionName: Scalars['String']['output'];
id: Scalars['ID']['output'];
resultVersions: Array<Version>;
/**
* NOTE: this is the schema for the results field below!
* Current schema: {
* version: "1.0.0",
* values: {
* objectResults: Record<str, {
* category: string
* level: ObjectResultLevel
* objectIds: string[]
* message: str | null
* metadata: Records<str, unknown> | null
* visualoverrides: Records<str, unknown> | null
* }[]>
* blobIds?: string[]
* }
* }
*/
results?: Maybe<Scalars['JSONObject']['output']>;
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AutomationMutations = {
__typename?: 'AutomationMutations';
create: Scalars['Boolean']['output'];
functionRunStatusReport: Scalars['Boolean']['output'];
};
export type AutomationMutationsCreateArgs = {
input: AutomationCreateInput;
};
export type AutomationMutationsFunctionRunStatusReportArgs = {
input: AutomationRunStatusUpdateInput;
};
export type AutomationRevision = {
__typename?: 'AutomationRevision';
functions: Array<AutomationRevisionFunction>;
@@ -452,44 +396,8 @@ export type AutomationRevisionFunction = {
export type AutomationRevisionTriggerDefinition = VersionCreatedTriggerDefinition;
export type AutomationRun = {
__typename?: 'AutomationRun';
automationId: Scalars['String']['output'];
automationName: Scalars['String']['output'];
createdAt: Scalars['DateTime']['output'];
functionRuns: Array<AutomationFunctionRun>;
id: Scalars['ID']['output'];
/** Resolved from all function run statuses */
status: AutomationRunStatus;
updatedAt: Scalars['DateTime']['output'];
versionId: Scalars['String']['output'];
};
export enum AutomationRunStatus {
Failed = 'FAILED',
Initializing = 'INITIALIZING',
Running = 'RUNNING',
Succeeded = 'SUCCEEDED'
}
export type AutomationRunStatusUpdateInput = {
automationId: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
automationRunId: Scalars['String']['input'];
functionRuns: Array<FunctionRunStatusInput>;
versionId: Scalars['String']['input'];
};
export type AutomationRunTrigger = VersionCreatedTrigger;
export type AutomationsStatus = {
__typename?: 'AutomationsStatus';
automationRuns: Array<AutomationRun>;
id: Scalars['ID']['output'];
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AvatarUser = {
__typename?: 'AvatarUser';
avatar?: Maybe<Scalars['String']['output']>;
@@ -939,27 +847,6 @@ export type FileUpload = {
userId: Scalars['String']['output'];
};
export type FunctionRunStatusInput = {
contextView?: InputMaybe<Scalars['String']['input']>;
elapsed: Scalars['Float']['input'];
functionId: Scalars['String']['input'];
functionLogo?: InputMaybe<Scalars['String']['input']>;
functionName: Scalars['String']['input'];
resultVersionIds: Array<Scalars['String']['input']>;
/**
* Current schema: {
* version: "1.0.0",
* values: {
* speckleObjects: Record<ObjectId, {level: string; statusMessage: string}[]>
* blobIds?: string[]
* }
* }
*/
results?: InputMaybe<Scalars['JSONObject']['input']>;
status: AutomationRunStatus;
statusMessage?: InputMaybe<Scalars['String']['input']>;
};
export type GendoAiRender = {
__typename?: 'GendoAIRender';
camera?: Maybe<Scalars['JSONObject']['output']>;
@@ -1085,7 +972,6 @@ export type LimitedUserTimelineArgs = {
export type Model = {
__typename?: 'Model';
author: LimitedUser;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** Return a model tree of children */
childrenTree: Array<ModelsTreeItem>;
@@ -1218,7 +1104,6 @@ export type Mutation = {
appUpdate: Scalars['Boolean']['output'];
automateFunctionRunStatusReport: Scalars['Boolean']['output'];
automateMutations: AutomateMutations;
automationMutations: AutomationMutations;
branchCreate: Scalars['String']['output'];
branchDelete: Scalars['Boolean']['output'];
branchUpdate: Scalars['Boolean']['output'];
@@ -1904,14 +1789,6 @@ export type ProjectAutomationUpdateInput = {
name?: InputMaybe<Scalars['String']['input']>;
};
export type ProjectAutomationsStatusUpdatedMessage = {
__typename?: 'ProjectAutomationsStatusUpdatedMessage';
model: Model;
project: Project;
status: AutomationsStatus;
version: Version;
};
export type ProjectAutomationsUpdatedMessage = {
__typename?: 'ProjectAutomationsUpdatedMessage';
automation?: Maybe<Automation>;
@@ -2878,7 +2755,6 @@ export type Subscription = {
commitDeleted?: Maybe<Scalars['JSONObject']['output']>;
/** Subscribe to commit updated event. */
commitUpdated?: Maybe<Scalars['JSONObject']['output']>;
projectAutomationsStatusUpdated: ProjectAutomationsStatusUpdatedMessage;
/** Subscribe to updates to automations in the project */
projectAutomationsUpdated: ProjectAutomationsUpdatedMessage;
/**
@@ -2974,11 +2850,6 @@ export type SubscriptionCommitUpdatedArgs = {
};
export type SubscriptionProjectAutomationsStatusUpdatedArgs = {
projectId: Scalars['String']['input'];
};
export type SubscriptionProjectAutomationsUpdatedArgs = {
projectId: Scalars['String']['input'];
};
@@ -3320,7 +3191,6 @@ export type UserUpdateInput = {
export type Version = {
__typename?: 'Version';
authorUser?: Maybe<LimitedUser>;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** All comment threads in this version */
commentThreads: CommentCollection;
-1
View File
@@ -48,7 +48,6 @@ const getEnabledModuleNames = () => {
'activitystream',
'apiexplorer',
'auth',
'betaAutomations',
'blobstorage',
'comments',
'core',
@@ -5,9 +5,6 @@ import Redis from 'ioredis'
import { withFilter } from 'graphql-subscriptions'
import { GraphQLContext } from '@/modules/shared/helpers/typeHelper'
import {
AutomationRun,
AutomationsStatus,
ProjectAutomationsStatusUpdatedMessage,
ProjectCommentsUpdatedMessage,
ProjectFileImportUpdatedMessage,
ProjectModelsUpdatedMessage,
@@ -16,7 +13,6 @@ import {
ProjectUpdatedMessage,
ProjectVersionsPreviewGeneratedMessage,
ProjectVersionsUpdatedMessage,
SubscriptionProjectAutomationsStatusUpdatedArgs,
SubscriptionProjectAutomationsUpdatedArgs,
SubscriptionProjectCommentsUpdatedArgs,
SubscriptionProjectFileImportUpdatedArgs,
@@ -44,7 +40,6 @@ import {
} from '@/modules/core/helpers/graphTypes'
import { CommentGraphQLReturn } from '@/modules/comments/helpers/graphTypes'
import { FileUploadGraphQLReturn } from '@/modules/fileuploads/helpers/types'
import { AutomationFunctionRunGraphQLReturn } from '@/modules/betaAutomations/helpers/graphTypes'
import {
ProjectTriggeredAutomationsStatusUpdatedMessageGraphQLReturn,
ProjectAutomationsUpdatedMessageGraphQLReturn
@@ -100,7 +95,6 @@ export enum ProjectSubscriptions {
ProjectVersionsPreviewGenerated = 'PROJECT_VERSIONS_PREVIEW_GENERATED',
ProjectCommentsUpdated = 'PROJECT_COMMENTS_UPDATED',
// old beta subscription:
ProjectAutomationStatusUpdated = 'PROJECT_AUTOMATION_STATUS_UPDATED',
ProjectTriggeredAutomationsStatusUpdated = 'PROJECT_TRIGGERED_AUTOMATION_STATUS_UPDATED',
ProjectAutomationsUpdated = 'PROJECT_AUTOMATIONS_UPDATED',
ProjectVersionGendoAIRenderUpdated = 'PROJECT_VERSION_GENDO_AI_RENDER_UPDATED',
@@ -229,31 +223,6 @@ type SubscriptionTypeMap = {
}
variables: SubscriptionProjectFileImportUpdatedArgs
}
[ProjectSubscriptions.ProjectAutomationStatusUpdated]: {
payload: {
projectAutomationsStatusUpdated: Merge<
ProjectAutomationsStatusUpdatedMessage,
{
version: VersionGraphQLReturn
model: ModelGraphQLReturn
project: ProjectGraphQLReturn
status: Merge<
AutomationsStatus,
{
automationRuns: Array<
Merge<
AutomationRun,
{ functionRuns: AutomationFunctionRunGraphQLReturn[] }
>
>
}
>
}
>
projectId: string
}
variables: SubscriptionProjectAutomationsStatusUpdatedArgs
}
[ProjectSubscriptions.ProjectTriggeredAutomationsStatusUpdated]: {
payload: {
projectTriggeredAutomationsStatusUpdated: ProjectTriggeredAutomationsStatusUpdatedMessageGraphQLReturn
@@ -374,62 +374,6 @@ export type AutomationCollection = {
totalCount: Scalars['Int']['output'];
};
export type AutomationCreateInput = {
automationId: Scalars['String']['input'];
automationName: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
modelId: Scalars['String']['input'];
projectId: Scalars['String']['input'];
webhookId?: InputMaybe<Scalars['String']['input']>;
};
export type AutomationFunctionRun = {
__typename?: 'AutomationFunctionRun';
contextView?: Maybe<Scalars['String']['output']>;
elapsed: Scalars['Float']['output'];
functionId: Scalars['String']['output'];
functionLogo?: Maybe<Scalars['String']['output']>;
functionName: Scalars['String']['output'];
id: Scalars['ID']['output'];
resultVersions: Array<Version>;
/**
* NOTE: this is the schema for the results field below!
* Current schema: {
* version: "1.0.0",
* values: {
* objectResults: Record<str, {
* category: string
* level: ObjectResultLevel
* objectIds: string[]
* message: str | null
* metadata: Records<str, unknown> | null
* visualoverrides: Records<str, unknown> | null
* }[]>
* blobIds?: string[]
* }
* }
*/
results?: Maybe<Scalars['JSONObject']['output']>;
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AutomationMutations = {
__typename?: 'AutomationMutations';
create: Scalars['Boolean']['output'];
functionRunStatusReport: Scalars['Boolean']['output'];
};
export type AutomationMutationsCreateArgs = {
input: AutomationCreateInput;
};
export type AutomationMutationsFunctionRunStatusReportArgs = {
input: AutomationRunStatusUpdateInput;
};
export type AutomationRevision = {
__typename?: 'AutomationRevision';
functions: Array<AutomationRevisionFunction>;
@@ -453,44 +397,8 @@ export type AutomationRevisionFunction = {
export type AutomationRevisionTriggerDefinition = VersionCreatedTriggerDefinition;
export type AutomationRun = {
__typename?: 'AutomationRun';
automationId: Scalars['String']['output'];
automationName: Scalars['String']['output'];
createdAt: Scalars['DateTime']['output'];
functionRuns: Array<AutomationFunctionRun>;
id: Scalars['ID']['output'];
/** Resolved from all function run statuses */
status: AutomationRunStatus;
updatedAt: Scalars['DateTime']['output'];
versionId: Scalars['String']['output'];
};
export enum AutomationRunStatus {
Failed = 'FAILED',
Initializing = 'INITIALIZING',
Running = 'RUNNING',
Succeeded = 'SUCCEEDED'
}
export type AutomationRunStatusUpdateInput = {
automationId: Scalars['String']['input'];
automationRevisionId: Scalars['String']['input'];
automationRunId: Scalars['String']['input'];
functionRuns: Array<FunctionRunStatusInput>;
versionId: Scalars['String']['input'];
};
export type AutomationRunTrigger = VersionCreatedTrigger;
export type AutomationsStatus = {
__typename?: 'AutomationsStatus';
automationRuns: Array<AutomationRun>;
id: Scalars['ID']['output'];
status: AutomationRunStatus;
statusMessage?: Maybe<Scalars['String']['output']>;
};
export type AvatarUser = {
__typename?: 'AvatarUser';
avatar?: Maybe<Scalars['String']['output']>;
@@ -940,27 +848,6 @@ export type FileUpload = {
userId: Scalars['String']['output'];
};
export type FunctionRunStatusInput = {
contextView?: InputMaybe<Scalars['String']['input']>;
elapsed: Scalars['Float']['input'];
functionId: Scalars['String']['input'];
functionLogo?: InputMaybe<Scalars['String']['input']>;
functionName: Scalars['String']['input'];
resultVersionIds: Array<Scalars['String']['input']>;
/**
* Current schema: {
* version: "1.0.0",
* values: {
* speckleObjects: Record<ObjectId, {level: string; statusMessage: string}[]>
* blobIds?: string[]
* }
* }
*/
results?: InputMaybe<Scalars['JSONObject']['input']>;
status: AutomationRunStatus;
statusMessage?: InputMaybe<Scalars['String']['input']>;
};
export type GendoAiRender = {
__typename?: 'GendoAIRender';
camera?: Maybe<Scalars['JSONObject']['output']>;
@@ -1086,7 +973,6 @@ export type LimitedUserTimelineArgs = {
export type Model = {
__typename?: 'Model';
author: LimitedUser;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** Return a model tree of children */
childrenTree: Array<ModelsTreeItem>;
@@ -1219,7 +1105,6 @@ export type Mutation = {
appUpdate: Scalars['Boolean']['output'];
automateFunctionRunStatusReport: Scalars['Boolean']['output'];
automateMutations: AutomateMutations;
automationMutations: AutomationMutations;
branchCreate: Scalars['String']['output'];
branchDelete: Scalars['Boolean']['output'];
branchUpdate: Scalars['Boolean']['output'];
@@ -1905,14 +1790,6 @@ export type ProjectAutomationUpdateInput = {
name?: InputMaybe<Scalars['String']['input']>;
};
export type ProjectAutomationsStatusUpdatedMessage = {
__typename?: 'ProjectAutomationsStatusUpdatedMessage';
model: Model;
project: Project;
status: AutomationsStatus;
version: Version;
};
export type ProjectAutomationsUpdatedMessage = {
__typename?: 'ProjectAutomationsUpdatedMessage';
automation?: Maybe<Automation>;
@@ -2879,7 +2756,6 @@ export type Subscription = {
commitDeleted?: Maybe<Scalars['JSONObject']['output']>;
/** Subscribe to commit updated event. */
commitUpdated?: Maybe<Scalars['JSONObject']['output']>;
projectAutomationsStatusUpdated: ProjectAutomationsStatusUpdatedMessage;
/** Subscribe to updates to automations in the project */
projectAutomationsUpdated: ProjectAutomationsUpdatedMessage;
/**
@@ -2975,11 +2851,6 @@ export type SubscriptionCommitUpdatedArgs = {
};
export type SubscriptionProjectAutomationsStatusUpdatedArgs = {
projectId: Scalars['String']['input'];
};
export type SubscriptionProjectAutomationsUpdatedArgs = {
projectId: Scalars['String']['input'];
};
@@ -3321,7 +3192,6 @@ export type UserUpdateInput = {
export type Version = {
__typename?: 'Version';
authorUser?: Maybe<LimitedUser>;
automationStatus?: Maybe<AutomationsStatus>;
automationsStatus?: Maybe<TriggeredAutomationsStatus>;
/** All comment threads in this version */
commentThreads: CommentCollection;