@prefecthq/prefect-ui-library
Version:
This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.
31 lines (29 loc) • 925 B
text/typescript
import { State } from '@/models/State'
import { MockFunction } from '@/services/Mocker'
import { capitalize } from '@/utilities'
import { random } from '@/utilities/math'
export const randomState: MockFunction<State, [Partial<State>?]> = function(overrides = {}) {
const type = this.create('stateType')
const name = capitalize(overrides.type ?? type)
return {
id: this.create('id'),
type: type,
kind: 'state',
message: this.create('sentence'),
stateDetails: {
flowRunId: this.create('id'),
taskRunId: this.create('id'),
childFlowRunId: random() > 0.9 ? this.create('id') : null,
scheduledTime: this.create('date'),
cacheKey: this.create('string'),
cacheExpiration: this.create('date'),
},
data: {
encoding: this.create('string'),
blob: this.create('string'),
},
timestamp: this.create('date'),
name: name,
...overrides,
}
}