-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathDurableOrchestrationStatus.ts
More file actions
80 lines (71 loc) · 2.09 KB
/
Copy pathDurableOrchestrationStatus.ts
File metadata and controls
80 lines (71 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
// A DTO used by DurableOrchestrationStatus.historyEvents
export class HistoryEvent {
timestamp: string;
eventType: string;
eventId: number;
name: string;
scheduledTime: string;
durationInMs: number;
subOrchestrationId: string;
input: any;
result: any;
details: any;
}
// Extends HistoryEvent with history for a suborchestration
export class EventWithHistory extends HistoryEvent {
history: EventWithHistory[];
}
// Could instead just iterate through field names of HistoryEvent, but reflection in TypeScript still looks tricky
export const HistoryEventFields = [
'Timestamp',
'EventType',
'EventId',
'Name',
'ScheduledTime',
'Input',
'Result',
'Details',
];
export const RuntimeStatuses = ['Completed', 'Running', 'Failed', 'Pending', 'Terminated', 'Canceled', 'ContinuedAsNew'] as const;
export type RuntimeStatus = typeof RuntimeStatuses[number];
export type EntityType = 'Orchestration' | 'DurableEntity';
export class EntityId {
name: string;
key: string;
}
// A DTO returned by DurableOrchestrationClient.getStatusAll()
export class DurableOrchestrationStatus {
instanceId: string;
parentInstanceId: string;
name: string;
entityId: EntityId;
runtimeStatus: RuntimeStatus;
entityType: EntityType;
lastEvent: string;
input: any;
customStatus: string;
output: any;
createdTime: string;
lastUpdatedTime: string;
duration: number;
tabTemplateNames?: string[];
static getFunctionName(instance: DurableOrchestrationStatus): string {
return instance.entityType === 'DurableEntity' ? instance.entityId.name : instance.name;
}
}
// Could instead just iterate through field names of DurableOrchestrationStatus, but reflection in TypeScript still looks tricky
export const DurableOrchestrationStatusFields = [
'instanceId',
'parentInstanceId',
'name',
'createdTime',
'lastUpdatedTime',
'duration',
'runtimeStatus',
'lastEvent',
'input',
'output',
'customStatus'
];