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
This commit is contained in:
@@ -70,29 +70,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- Results -->
|
||||
<div
|
||||
v-if="!!results?.values.objectResults.length"
|
||||
class="border-t pt-2 border-outline-2"
|
||||
>
|
||||
<div v-if="!!objectResults.length" class="border-t pt-2 border-outline-2">
|
||||
<div class="text-body-2xs font-medium text-foreground-2 mb-2">Results</div>
|
||||
<div class="space-y-1">
|
||||
<AutomateViewerPanelFunctionRunRowObjectResult
|
||||
v-for="(result, index) in results.values.objectResults.slice(
|
||||
0,
|
||||
pageRunLimit
|
||||
)"
|
||||
v-for="(result, index) in objectResults.slice(0, pageRunLimit)"
|
||||
:key="index"
|
||||
:function-id="functionRun.function?.id"
|
||||
:result="result"
|
||||
/>
|
||||
<FormButton
|
||||
v-if="pageRunLimit < results.values.objectResults.length"
|
||||
v-if="pageRunLimit < objectResults.length"
|
||||
size="sm"
|
||||
color="outline"
|
||||
class="w-full"
|
||||
@click="pageRunLimit += 10"
|
||||
>
|
||||
Load more ({{ results.values.objectResults.length - pageRunLimit }}
|
||||
Load more ({{ objectResults.length - pageRunLimit }}
|
||||
hidden results)
|
||||
</FormButton>
|
||||
</div>
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -81,13 +81,27 @@ export const resultSchemaV2 = z.object({
|
||||
})
|
||||
})
|
||||
|
||||
export type ResultSchemaV2 = z.infer<typeof resultSchemaV2>
|
||||
|
||||
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<typeof resultSchemaV3>
|
||||
|
||||
export const resultSchema = z.discriminatedUnion('version', [
|
||||
resultSchemaV1,
|
||||
resultSchemaV2
|
||||
resultSchemaV2,
|
||||
resultSchemaV3
|
||||
])
|
||||
|
||||
export type ResultSchemaV2 = z.infer<typeof resultSchemaV2>
|
||||
|
||||
export type ResultsSchema = z.infer<typeof resultSchema>
|
||||
|
||||
type UnformattedTriggerDefinitionSchema = PartialDeep<TriggerDefinitionsSchema>
|
||||
|
||||
Reference in New Issue
Block a user