-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.types.ts
264 lines (218 loc) · 5.93 KB
/
api.types.ts
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
export type Executable = {
id: string;
content: string;
arguments: ArgumentValues;
};
export const ExecutableIdConsole = 'console';
export function isExecutableConsole(id: string): boolean {
return id === ExecutableIdConsole;
}
export function isExecutableScript(id: string): boolean {
return id.startsWith('/conf/acm/settings/script');
}
export function isExecutableExplicit(id: string): boolean {
return isExecutableConsole(id) || isExecutableScript(id);
}
export type Description = {
execution: Execution;
arguments: {
[name: string]: Argument<ArgumentValue>;
};
};
export type ArgumentType = 'BOOL' | 'STRING' | 'TEXT' | 'SELECT' | 'MULTISELECT' | 'INTEGER' | 'DECIMAL' | 'PATH';
export type ArgumentValue = string | string[] | number | number[] | boolean | null | undefined;
export type ArgumentValues = Record<string, ArgumentValue>;
export const ArgumentGroupDefault = 'general';
export type Argument<T> = {
name: string;
type: ArgumentType;
value: T;
label: string;
required: boolean;
group: string;
validator?: string;
};
export type BoolArgument = Argument<boolean> & {
display: 'SWITCHER' | 'CHECKBOX';
};
export type TextArgument = Argument<string> & {
language?: string;
};
export type NumberArgument = Argument<number> & {
min: number;
max: number;
};
export type SelectArgument = Argument<ArgumentValue> & {
options: Record<string, ArgumentValue>;
display: 'AUTO' | 'DROPDOWN' | 'RADIO';
};
export type MultiSelectArgument = Argument<ArgumentValue> & {
options: Record<string, ArgumentValue>;
display: 'AUTO' | 'CHECKBOX' | 'DROPDOWN';
};
export type PathArgument = Argument<ArgumentValue> & {
rootPath: string;
};
export function isStringArgument(arg: Argument<ArgumentValue>): arg is Argument<string> {
return arg.type === 'STRING';
}
export function isBoolArgument(arg: Argument<ArgumentValue>): arg is BoolArgument {
return arg.type === 'BOOL';
}
export function isTextArgument(arg: Argument<ArgumentValue>): arg is TextArgument {
return arg.type === 'TEXT';
}
export function isSelectArgument(arg: Argument<ArgumentValue>): arg is SelectArgument {
return arg.type === 'SELECT';
}
export function isNumberArgument(arg: Argument<ArgumentValue>): arg is NumberArgument {
return arg.type === 'INTEGER' || arg.type === 'DECIMAL';
}
export function isMultiSelectArgument(arg: Argument<ArgumentValue>): arg is MultiSelectArgument {
return arg.type === 'MULTISELECT';
}
export function isPathArgument(arg: Argument<ArgumentValue>): arg is PathArgument {
return arg.type === 'PATH';
}
export type Execution = {
id: string;
userId: string;
executable: Executable;
status: ExecutionStatus;
startDate: string;
endDate: string;
duration: number;
output: string;
error: string | null;
};
export type ExecutionSummary = {
id: string;
userId: string;
executableId: string;
status: ExecutionStatus;
startDate: string;
endDate: string;
duration: number;
};
export enum ExecutionStatus {
QUEUED = 'QUEUED',
ACTIVE = 'ACTIVE',
PARSING = 'PARSING',
CHECKING = 'CHECKING',
RUNNING = 'RUNNING',
STOPPED = 'STOPPED',
FAILED = 'FAILED',
SKIPPED = 'SKIPPED',
ABORTED = 'ABORTED',
SUCCEEDED = 'SUCCEEDED',
}
export function isExecutionNegative(status: ExecutionStatus | null | undefined): boolean {
return !!status && [ExecutionStatus.FAILED, ExecutionStatus.ABORTED].includes(status);
}
export function isExecutionPending(status: ExecutionStatus | null | undefined): boolean {
return !!status && (status === ExecutionStatus.QUEUED || isExecutionActive(status));
}
export function isExecutionActive(status: ExecutionStatus | null | undefined): boolean {
return !!status && [ExecutionStatus.ACTIVE, ExecutionStatus.PARSING, ExecutionStatus.CHECKING, ExecutionStatus.RUNNING].includes(status);
}
export function isExecutionCompleted(status: ExecutionStatus | null | undefined): boolean {
return !!status && [ExecutionStatus.FAILED, ExecutionStatus.SUCCEEDED].includes(status);
}
export type QueueOutput = {
executions: Execution[];
};
export type ExecutionOutput<E> = {
list: E[];
};
export type AssistCodeOutputSuggestion = {
k: string; // kind
l: string; // label
it: string; // insert text
i: string;
};
export type AssistCodeOutput = {
code: string;
suggestions: AssistCodeOutputSuggestion[];
};
export type SnippetOutput = {
list: Snippet[];
};
export type Snippet = {
name: string;
id: string;
group: string;
content: string;
documentation: string;
};
export enum ScriptType {
MANUAL = 'MANUAL',
ENABLED = 'ENABLED',
DISABLED = 'DISABLED',
EXTENSION = 'EXTENSION',
}
export type Script = {
id: string;
type: ScriptType;
path: string;
name: string;
content: string;
};
export type ScriptStats = {
path: string;
statusCount: { [key in ExecutionStatus]: number };
lastExecution: Execution | null;
};
export type ScriptOutput = {
list: Script[];
stats: ScriptStats[];
};
export type State = {
spaSettings: SpaSettings;
healthStatus: HealthStatus;
instanceSettings: InstanceSettings;
queuedExecutions: ExecutionSummary[];
};
export type SpaSettings = {
appStateInterval: number;
executionPollInterval: number;
};
export type InstanceSettings = {
id: string;
timezoneId: string;
role: InstanceRole;
type: InstanceType;
};
export enum InstanceRole {
AUTHOR = 'AUTHOR',
PUBLISH = 'PUBLISH',
}
export enum InstanceType {
ON_PREM = 'ON_PREM',
CLOUD_SDK = 'CLOUD_SDK',
CLOUD_CONTAINER = 'CLOUD_CONTAINER',
}
export type HealthStatus = {
healthy: boolean;
issues: HealthIssue[];
};
export type HealthIssue = {
message: string;
severity: HealthIssueSeverity;
};
export enum HealthIssueSeverity {
CRITICAL = 'CRITICAL',
WARNING = 'WARNING',
INFO = 'INFO',
}
export enum ExecutionFormat {
SUMMARY = 'SUMMARY',
FULL = 'FULL',
}
export enum ExecutionQueryParams {
FORMAT = 'format',
START_DATE = 'startDate',
END_DATE = 'endDate',
STATUS = 'status',
EXECUTABLE_ID = 'executableId',
DURATION = 'duration',
}