From 42f2f7a2cd6e5c79246a621df084c10366a3941d Mon Sep 17 00:00:00 2001 From: widmogrod Date: Sat, 4 Nov 2023 19:35:51 +0100 Subject: [PATCH] example/my-app use new workflow version --- example/my-app/server.go | 60 ++-- example/my-app/src/App.css | 9 + example/my-app/src/App.tsx | 49 ++- example/my-app/src/workflow/workflow.ts | 388 ++++++++++++------------ 4 files changed, 287 insertions(+), 219 deletions(-) diff --git a/example/my-app/server.go b/example/my-app/server.go index 4be9cc1a..a3bcef5a 100644 --- a/example/my-app/server.go +++ b/example/my-app/server.go @@ -63,18 +63,28 @@ func main() { func(state workflow.State) *machine.Machine[workflow.Command, workflow.State] { return workflow.NewMachine(di, state) }, - func(cmd workflow.Command) (string, bool) { + func(cmd workflow.Command) (*predicate.WherePredicates, bool) { if cmd == nil { - return "", false + return nil, false } switch cmd := cmd.(type) { case *workflow.StopSchedule: - return cmd.RunID, true + return predicate.MustWhere( + `Data["workflow.Scheduled"].ParentRunID = :runID`, + predicate.ParamBinds{ + ":runID": schema.MkString(cmd.ParentRunID), + }, + ), true case *workflow.ResumeSchedule: - return cmd.RunID, true + return predicate.MustWhere( + `Data["workflow.ScheduleStopped"].ParentRunID = :runID`, + predicate.ParamBinds{ + ":runID": schema.MkString(cmd.ParentRunID), + }, + ), true default: - return "", false + return nil, false } }, func(state workflow.State) (string, bool) { @@ -436,37 +446,47 @@ func NewService[CMD any, State any]( recordType string, statesRepo *typedful.TypedRepoWithAggregator[State, any], newMachine func(state State) *machine.Machine[CMD, State], - extractID func(CMD) (string, bool), + extractWhere func(CMD) (*predicate.WherePredicates, bool), extractIDFromState func(State) (string, bool), ) *Service[CMD, State] { return &Service[CMD, State]{ - repo: statesRepo, - extractIDFromCommandF: extractID, - recordType: recordType, - newMachine: newMachine, - extractIDFromStateF: extractIDFromState, + repo: statesRepo, + extractWhereFromCommandF: extractWhere, + recordType: recordType, + newMachine: newMachine, + extractIDFromStateF: extractIDFromState, } } type Service[CMD any, State any] struct { - repo *typedful.TypedRepoWithAggregator[State, any] - extractIDFromCommandF func(CMD) (string, bool) - extractIDFromStateF func(State) (string, bool) - recordType string - newMachine func(state State) *machine.Machine[CMD, State] + repo *typedful.TypedRepoWithAggregator[State, any] + extractWhereFromCommandF func(CMD) (*predicate.WherePredicates, bool) + extractIDFromStateF func(State) (string, bool) + recordType string + newMachine func(state State) *machine.Machine[CMD, State] } func (service *Service[CMD, State]) CreateOrUpdate(cmd CMD) (res State, err error) { version := uint16(0) - recordID, foundAndUpdate := service.extractIDFromCommandF(cmd) + recordID := "" + where, foundAndUpdate := service.extractWhereFromCommandF(cmd) if foundAndUpdate { - record, err := service.repo.Get(recordID, service.recordType) + records, err := service.repo.FindingRecords(schemaless.FindingRecords[schemaless.Record[State]]{ + RecordType: service.recordType, + Where: where, + Limit: 1, + }) if err != nil { return res, err } + if len(records.Items) == 0 { + return res, fmt.Errorf("expected at least one record") + } + record := records.Items[0] res = record.Data version = record.Version + recordID = record.ID } work := service.newMachine(res) @@ -485,6 +505,10 @@ func (service *Service[CMD, State]) CreateOrUpdate(cmd CMD) (res State, err erro recordID = saveId } + if recordID == "" { + return res, fmt.Errorf("expected recordID in state") + } + err = service.repo.UpdateRecords(schemaless.Save(schemaless.Record[State]{ ID: recordID, Type: service.recordType, diff --git a/example/my-app/src/App.css b/example/my-app/src/App.css index 6897d662..9ddb66b8 100644 --- a/example/my-app/src/App.css +++ b/example/my-app/src/App.css @@ -52,4 +52,13 @@ tbody tr:nth-of-type(even) { tbody tr:last-of-type { border-bottom: 2px solid #009879; +} + +/* tables inside a table should be smaller */ +table table { + font-size: 0.8em; + min-width: 0; +} +table table th, td { + padding: 5px 10px; } \ No newline at end of file diff --git a/example/my-app/src/App.tsx b/example/my-app/src/App.tsx index 74151a5f..97025d3f 100644 --- a/example/my-app/src/App.tsx +++ b/example/my-app/src/App.tsx @@ -484,14 +484,14 @@ function App() { workflow.Scheduled {JSON.stringify(data["workflow.Scheduled"].ExpectedRunTimestamp)} - + ) } else if ("workflow.ScheduleStopped") { return <> workflow.ScheduleStopped - + } else { return JSON.stringify(data) @@ -562,13 +562,46 @@ function ListVariables(props: { data: workflow.BaseState }) { } function SchemaValue(props: { data: schema.Schema }) { + // check if props.data is an object + if (typeof props.data !== 'object') { + return <>{JSON.stringify(props.data)} + } + if ("schema.String" in props.data) { return <>{props.data["schema.String"]} } else if ("schema.Binary" in props.data) { return <>binary - } else { - return <>{JSON.stringify(props.data)} + } else if ("schema.Map" in props.data) { + const mapData = props.data["schema.Map"]; + const keys = Object.keys(mapData); + + if (keys.length === 0) { + return null; // If the map is empty, return null (no table to display) + } + + return ( + + + + + + + + + {keys.map((key) => ( + + + + + ))} + +
KeyValue
{key} + +
+ ); } + + return <>{JSON.stringify(props.data)} } function PaginatedTable(props: { table: { Items: any[] }, mapData: (data: any) => any }) { @@ -751,10 +784,10 @@ function CreateAttachment(props: { input: string }) { } -function StopSchedule(props: { runId: string }) { +function StopSchedule(props: { parentRunID: string }) { const cmd: workflow.Command = { "workflow.StopSchedule": { - RunID: props.runId, + ParentRunID: props.parentRunID, } } @@ -772,10 +805,10 @@ function StopSchedule(props: { runId: string }) { } -function ResumeSchedule(props: { runId: string }) { +function ResumeSchedule(props: { parentRunID: string }) { const cmd: workflow.Command = { "workflow.ResumeSchedule": { - RunID: props.runId, + ParentRunID: props.parentRunID, } } diff --git a/example/my-app/src/workflow/workflow.ts b/example/my-app/src/workflow/workflow.ts index a4decf87..f0fe8634 100644 --- a/example/my-app/src/workflow/workflow.ts +++ b/example/my-app/src/workflow/workflow.ts @@ -1,10 +1,10 @@ //generated by mkunion /** -* This function is used to remove $type field from Expr, so it can be understood by mkunion, +* This function is used to remove $type field from Command, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateExpr(x: Expr): Expr { +export function dediscriminateCommand(x: Command): Command { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -13,10 +13,10 @@ export function dediscriminateExpr(x: Expr): Expr { } /** -* This function is used to populate $type field in Expr, so it can be used as discriminative switch statement +* This function is used to populate $type field in Command, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateExpr(x: Expr): Expr { +export function discriminateCommand(x: Command): Command { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -26,57 +26,57 @@ export function discriminateExpr(x: Expr): Expr { return x } -export type Expr = { +export type Command = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.End", - "workflow.End": End + "$type"?: "workflow.Run", + "workflow.Run": Run } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Assign", - "workflow.Assign": Assign + "$type"?: "workflow.Callback", + "workflow.Callback": Callback } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Apply", - "workflow.Apply": Apply + "$type"?: "workflow.TryRecover", + "workflow.TryRecover": TryRecover } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Choose", - "workflow.Choose": Choose + "$type"?: "workflow.StopSchedule", + "workflow.StopSchedule": StopSchedule +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.ResumeSchedule", + "workflow.ResumeSchedule": ResumeSchedule } -export type End = { - ID?: string, - Result?: Reshaper, +export type Run = { + Flow?: Worflow, + Input?: schema.Schema, + RunOption?: RunOption, } -export type Assign = { - ID?: string, - VarOk?: string, - VarErr?: string, - Val?: Expr, +export type Callback = { + CallbackID?: string, + Result?: schema.Schema, } -export type Apply = { - ID?: string, - Name?: string, - Args?: Reshaper[], - Await?: ApplyAwaitOptions, +export type TryRecover = { } -export type Choose = { - ID?: string, - If?: Predicate, - Then?: Expr[], - Else?: Expr[], +export type StopSchedule = { + ParentRunID?: string, +} + +export type ResumeSchedule = { + ParentRunID?: string, } //generated by mkunion /** -* This function is used to remove $type field from Reshaper, so it can be understood by mkunion, +* This function is used to remove $type field from State, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateReshaper(x: Reshaper): Reshaper { +export function dediscriminateState(x: State): State { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -85,10 +85,10 @@ export function dediscriminateReshaper(x: Reshaper): Reshaper { } /** -* This function is used to populate $type field in Reshaper, so it can be used as discriminative switch statement +* This function is used to populate $type field in State, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateReshaper(x: Reshaper): Reshaper { +export function discriminateState(x: State): State { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -98,31 +98,73 @@ export function discriminateReshaper(x: Reshaper): Reshaper { return x } -export type Reshaper = { +export type State = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.GetValue", - "workflow.GetValue": GetValue + "$type"?: "workflow.NextOperation", + "workflow.NextOperation": NextOperation } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.SetValue", - "workflow.SetValue": SetValue + "$type"?: "workflow.Done", + "workflow.Done": Done +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.Error", + "workflow.Error": Error +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.Await", + "workflow.Await": Await +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.Scheduled", + "workflow.Scheduled": Scheduled +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.ScheduleStopped", + "workflow.ScheduleStopped": ScheduleStopped } -export type GetValue = { - Path?: string, +export type NextOperation = { + Result?: schema.Schema, + BaseState?: BaseState, } -export type SetValue = { - Value?: schema.Schema, +export type Done = { + Result?: schema.Schema, + BaseState?: BaseState, +} + +export type Error = { + Code?: string, + Reason?: string, + Retried?: number, + BaseState?: BaseState, +} + +export type Await = { + CallbackID?: string, + Timeout?: number, + BaseState?: BaseState, +} + +export type Scheduled = { + ExpectedRunTimestamp?: number, + ParentRunID?: string, + BaseState?: BaseState, +} + +export type ScheduleStopped = { + ParentRunID?: string, + BaseState?: BaseState, } //generated by mkunion /** -* This function is used to remove $type field from Predicate, so it can be understood by mkunion, +* This function is used to remove $type field from Worflow, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminatePredicate(x: Predicate): Predicate { +export function dediscriminateWorflow(x: Worflow): Worflow { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -131,10 +173,10 @@ export function dediscriminatePredicate(x: Predicate): Predicate { } /** -* This function is used to populate $type field in Predicate, so it can be used as discriminative switch statement +* This function is used to populate $type field in Worflow, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminatePredicate(x: Predicate): Predicate { +export function discriminateWorflow(x: Worflow): Worflow { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -144,49 +186,33 @@ export function discriminatePredicate(x: Predicate): Predicate { return x } -export type Predicate = { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.And", - "workflow.And": And -} | { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Or", - "workflow.Or": Or -} | { +export type Worflow = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Not", - "workflow.Not": Not + "$type"?: "workflow.Flow", + "workflow.Flow": Flow } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Compare", - "workflow.Compare": Compare -} - -export type And = { - L?: Predicate[], -} - -export type Or = { - L?: Predicate[], + "$type"?: "workflow.FlowRef", + "workflow.FlowRef": FlowRef } -export type Not = { - P?: Predicate, +export type Flow = { + Name?: string, + Arg?: string, + Body?: Expr[], } -export type Compare = { - Operation?: string, - Left?: Reshaper, - Right?: Reshaper, +export type FlowRef = { + FlowID?: string, } //generated by mkunion /** -* This function is used to remove $type field from RunOption, so it can be understood by mkunion, +* This function is used to remove $type field from Expr, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateRunOption(x: RunOption): RunOption { +export function dediscriminateExpr(x: Expr): Expr { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -195,10 +221,10 @@ export function dediscriminateRunOption(x: RunOption): RunOption { } /** -* This function is used to populate $type field in RunOption, so it can be used as discriminative switch statement +* This function is used to populate $type field in Expr, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateRunOption(x: RunOption): RunOption { +export function discriminateExpr(x: Expr): Expr { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -208,31 +234,57 @@ export function discriminateRunOption(x: RunOption): RunOption { return x } -export type RunOption = { +export type Expr = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.ScheduleRun", - "workflow.ScheduleRun": ScheduleRun + "$type"?: "workflow.End", + "workflow.End": End } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.DelayRun", - "workflow.DelayRun": DelayRun + "$type"?: "workflow.Assign", + "workflow.Assign": Assign +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.Apply", + "workflow.Apply": Apply +} | { + // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema + "$type"?: "workflow.Choose", + "workflow.Choose": Choose } -export type ScheduleRun = { - Interval?: string, +export type End = { + ID?: string, + Result?: Reshaper, } -export type DelayRun = { - DelayBySeconds?: number, +export type Assign = { + ID?: string, + VarOk?: string, + VarErr?: string, + Val?: Expr, +} + +export type Apply = { + ID?: string, + Name?: string, + Args?: Reshaper[], + Await?: ApplyAwaitOptions, +} + +export type Choose = { + ID?: string, + If?: Predicate, + Then?: Expr[], + Else?: Expr[], } //generated by mkunion /** -* This function is used to remove $type field from Command, so it can be understood by mkunion, +* This function is used to remove $type field from Reshaper, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateCommand(x: Command): Command { +export function dediscriminateReshaper(x: Reshaper): Reshaper { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -241,10 +293,10 @@ export function dediscriminateCommand(x: Command): Command { } /** -* This function is used to populate $type field in Command, so it can be used as discriminative switch statement +* This function is used to populate $type field in Reshaper, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateCommand(x: Command): Command { +export function discriminateReshaper(x: Reshaper): Reshaper { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -254,57 +306,31 @@ export function discriminateCommand(x: Command): Command { return x } -export type Command = { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Run", - "workflow.Run": Run -} | { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Callback", - "workflow.Callback": Callback -} | { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.TryRecover", - "workflow.TryRecover": TryRecover -} | { +export type Reshaper = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.StopSchedule", - "workflow.StopSchedule": StopSchedule + "$type"?: "workflow.GetValue", + "workflow.GetValue": GetValue } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.ResumeSchedule", - "workflow.ResumeSchedule": ResumeSchedule -} - -export type Run = { - Flow?: Worflow, - Input?: schema.Schema, - RunOption?: RunOption, -} - -export type Callback = { - CallbackID?: string, - Result?: schema.Schema, -} - -export type TryRecover = { + "$type"?: "workflow.SetValue", + "workflow.SetValue": SetValue } -export type StopSchedule = { - RunID?: string, +export type GetValue = { + Path?: string, } -export type ResumeSchedule = { - RunID?: string, +export type SetValue = { + Value?: schema.Schema, } //generated by mkunion /** -* This function is used to remove $type field from State, so it can be understood by mkunion, +* This function is used to remove $type field from Predicate, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateState(x: State): State { +export function dediscriminatePredicate(x: Predicate): Predicate { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -313,10 +339,10 @@ export function dediscriminateState(x: State): State { } /** -* This function is used to populate $type field in State, so it can be used as discriminative switch statement +* This function is used to populate $type field in Predicate, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateState(x: State): State { +export function discriminatePredicate(x: Predicate): Predicate { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -326,71 +352,49 @@ export function discriminateState(x: State): State { return x } -export type State = { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.NextOperation", - "workflow.NextOperation": NextOperation -} | { - // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Done", - "workflow.Done": Done -} | { +export type Predicate = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Error", - "workflow.Error": Error + "$type"?: "workflow.And", + "workflow.And": And } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Await", - "workflow.Await": Await + "$type"?: "workflow.Or", + "workflow.Or": Or } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Scheduled", - "workflow.Scheduled": Scheduled + "$type"?: "workflow.Not", + "workflow.Not": Not } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.ScheduleStopped", - "workflow.ScheduleStopped": ScheduleStopped -} - -export type NextOperation = { - Result?: schema.Schema, - BaseState?: BaseState, -} - -export type Done = { - Result?: schema.Schema, - BaseState?: BaseState, + "$type"?: "workflow.Compare", + "workflow.Compare": Compare } -export type Error = { - Code?: string, - Reason?: string, - Retried?: number, - BaseState?: BaseState, +export type And = { + L?: Predicate[], } -export type Await = { - CallbackID?: string, - Timeout?: number, - BaseState?: BaseState, +export type Or = { + L?: Predicate[], } -export type Scheduled = { - ExpectedRunTimestamp?: number, - BaseState?: BaseState, +export type Not = { + P?: Predicate, } -export type ScheduleStopped = { - BaseState?: BaseState, +export type Compare = { + Operation?: string, + Left?: Reshaper, + Right?: Reshaper, } //generated by mkunion /** -* This function is used to remove $type field from Worflow, so it can be understood by mkunion, +* This function is used to remove $type field from RunOption, so it can be understood by mkunion, * that is assuming unions have one field in object, that is used to discriminate between variants. */ -export function dediscriminateWorflow(x: Worflow): Worflow { +export function dediscriminateRunOption(x: RunOption): RunOption { if (x["$type"] !== undefined) { delete x["$type"] return x @@ -399,10 +403,10 @@ export function dediscriminateWorflow(x: Worflow): Worflow { } /** -* This function is used to populate $type field in Worflow, so it can be used as discriminative switch statement +* This function is used to populate $type field in RunOption, so it can be used as discriminative switch statement * @example https://www.typescriptlang.org/play#example/discriminate-types */ -export function discriminateWorflow(x: Worflow): Worflow { +export function discriminateRunOption(x: RunOption): RunOption { if (x["$type"] === undefined) { let keyx = Object.keys(x) if (keyx.length === 1) { @@ -412,26 +416,30 @@ export function discriminateWorflow(x: Worflow): Worflow { return x } -export type Worflow = { +export type RunOption = { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.Flow", - "workflow.Flow": Flow + "$type"?: "workflow.ScheduleRun", + "workflow.ScheduleRun": ScheduleRun } | { // $type this is optional field, that is used to enable discriminative switch-statement in TypeScript, its not part of mkunion schema - "$type"?: "workflow.FlowRef", - "workflow.FlowRef": FlowRef + "$type"?: "workflow.DelayRun", + "workflow.DelayRun": DelayRun } -export type Flow = { - Name?: string, - Arg?: string, - Body?: Expr[], +export type ScheduleRun = { + Interval?: string, } -export type FlowRef = { - FlowID?: string, +export type DelayRun = { + DelayBySeconds?: number, } +export type ApplyAwaitOptions = { + Timeout?: number, +} +export type ResumeOptions = { + Timeout?: number, +} export type BaseState = { Flow?: Worflow, RunID?: string, @@ -441,9 +449,6 @@ export type BaseState = { DefaultMaxRetries?: number, RunOption?: RunOption, } -export type ResumeOptions = { - Timeout?: number, -} export type Execution = { FlowID?: string, Status?: State, @@ -452,9 +457,6 @@ export type Execution = { EndTime?: number, Variables?: {[key: string]: any}, } -export type ApplyAwaitOptions = { - Timeout?: number, -} //eslint-disable-next-line import * as schema from './github_com_widmogrod_mkunion_x_schema'