From 3ee06809af77be6a4a7cb67084f83f60b8544d6f Mon Sep 17 00:00:00 2001 From: Chuck Driesler Date: Tue, 7 Oct 2025 08:42:41 +0100 Subject: [PATCH] feat(automate): add version results to run result schema (#5682) * feat(automate): add version results to run result schema * fix(automate): use new types on FE --- .../automate/viewer/panel/FunctionRunRow.vue | 15 +++++--------- .../panel/FunctionRunRowObjectResult.vue | 6 ++++-- packages/shared/src/automate/helpers/types.ts | 20 ++++++++++++++++--- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRow.vue b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRow.vue index 774e02c23..4c84186a8 100644 --- a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRow.vue +++ b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRow.vue @@ -70,29 +70,23 @@ -
+
Results
- Load more ({{ results.values.objectResults.length - pageRunLimit }} + Load more ({{ objectResults.length - pageRunLimit }} hidden results)
@@ -147,6 +141,7 @@ const expanded = ref(false) const attachments = computed(() => (results.value?.values.blobIds || []).filter((b) => !!b) ) +const objectResults = computed(() => results.value?.values.objectResults ?? []) const hasValidContextView = computed(() => { const ctxView = props.functionRun.contextView if (!ctxView?.length) return false diff --git a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue index d0eb12ddd..6c7e15273 100644 --- a/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue +++ b/packages/frontend-2/components/automate/viewer/panel/FunctionRunRowObjectResult.vue @@ -46,7 +46,9 @@ import type { NumericFilterData } from '~/lib/viewer/helpers/filters/types' import { isNumericFilter } from '~/lib/viewer/helpers/filters/types' import { injectGradientDataIntoDataStore } from '~/lib/viewer/helpers/filters/utils' -type ObjectResult = Automate.AutomateTypes.ResultsSchema['values']['objectResults'][0] +type ObjectResult = Required< + Automate.AutomateTypes.ResultsSchema['values'] +>['objectResults'][number] const props = defineProps<{ result: ObjectResult @@ -64,7 +66,7 @@ const { isolateObjects, unIsolateObjects, resetFilters, addActiveFilter, filters const { setColorFilter, removeColorFilter } = useFilterColoringHelpers() const hasMetadataGradient = computed(() => { - const hasGradient = !!props.result.metadata?.gradient + const hasGradient = !!props.result?.metadata?.gradient return hasGradient }) diff --git a/packages/shared/src/automate/helpers/types.ts b/packages/shared/src/automate/helpers/types.ts index 09006749c..11542f193 100644 --- a/packages/shared/src/automate/helpers/types.ts +++ b/packages/shared/src/automate/helpers/types.ts @@ -81,13 +81,27 @@ export const resultSchemaV2 = z.object({ }) }) +export type ResultSchemaV2 = z.infer + +const versionResultV3 = z.record(z.string(), z.unknown()) + +export const resultSchemaV3 = z.object({ + version: z.literal(3), + values: z.object({ + versionResult: versionResultV3.optional(), + objectResults: objectResultV2.array().optional(), + blobIds: z.string().array().optional() + }) +}) + +export type ResultSchemaV3 = z.infer + export const resultSchema = z.discriminatedUnion('version', [ resultSchemaV1, - resultSchemaV2 + resultSchemaV2, + resultSchemaV3 ]) -export type ResultSchemaV2 = z.infer - export type ResultsSchema = z.infer type UnformattedTriggerDefinitionSchema = PartialDeep