@jsb188/mday 1.1.7 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +39 -20
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/email.ts +28 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +14 -0
- package/src/constants/log-activityTexts.ts +54 -28
- package/src/constants/log.ts +82 -38
- package/src/constants/organization.ts +11 -2
- package/src/constants/product.ts +9 -33
- package/src/constants/report.ts +29 -10
- package/src/constants/sheet.ts +20 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +12 -0
- package/src/schemas/editLogEntry.ts +90 -44
- package/src/schemas/inboundContact.ts +72 -0
- package/src/schemas/logsQuery.ts +7 -272
- package/src/schemas/organization.ts +11 -174
- package/src/schemas/productsQuery.ts +2 -94
- package/src/schemas/reportsQuery.ts +8 -95
- package/src/types/account.d.ts +78 -0
- package/src/types/dataTable.d.ts +447 -0
- package/src/types/email.d.ts +71 -0
- package/src/types/inboundContact.d.ts +56 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +289 -178
- package/src/types/organization.d.ts +106 -50
- package/src/types/product.d.ts +7 -96
- package/src/types/report.d.ts +239 -152
- package/src/types/sheet.d.ts +298 -0
- package/src/types/storage.d.ts +161 -0
- package/src/types/workflow.d.ts +174 -0
- package/src/utils/dataTable.ts +834 -0
- package/src/utils/email.ts +113 -0
- package/src/utils/log.ts +30 -628
- package/src/utils/organization.ts +227 -44
- package/src/utils/product-calEvent.ts +7 -60
- package/src/utils/report.ts +158 -0
- package/src/utils/sheet.ts +170 -0
- package/src/utils/square.ts +22 -0
- package/src/utils/table-route.ts +146 -0
- package/src/utils/workflow.ts +212 -0
- package/tsconfig.json +12 -0
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/types/action.d.ts +0 -42
- package/src/utils/route-helpers.ts +0 -583
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SHEET_CELL_SOURCE_TYPE_ENUMS,
|
|
3
|
+
SHEET_REGION_CONFLICT_POLICY_ENUMS,
|
|
4
|
+
SHEET_REGION_TYPE_ENUMS,
|
|
5
|
+
} from '../constants/sheet.ts';
|
|
6
|
+
|
|
7
|
+
export type SheetCellSourceTypeEnum = typeof SHEET_CELL_SOURCE_TYPE_ENUMS[number];
|
|
8
|
+
export type SheetRegionTypeEnum = typeof SHEET_REGION_TYPE_ENUMS[number];
|
|
9
|
+
export type SheetRegionConflictPolicyEnum = typeof SHEET_REGION_CONFLICT_POLICY_ENUMS[number];
|
|
10
|
+
|
|
11
|
+
export type SheetCellValue =
|
|
12
|
+
| string
|
|
13
|
+
| number
|
|
14
|
+
| boolean
|
|
15
|
+
| null
|
|
16
|
+
| Record<string, any>
|
|
17
|
+
| any[];
|
|
18
|
+
|
|
19
|
+
export interface SheetGridDesignObj {
|
|
20
|
+
rowCount: number;
|
|
21
|
+
columnCount: number;
|
|
22
|
+
frozenRows?: number | null;
|
|
23
|
+
frozenColumns?: number | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SheetAxisDesignObj {
|
|
27
|
+
width?: number | null;
|
|
28
|
+
height?: number | null;
|
|
29
|
+
hidden?: boolean | null;
|
|
30
|
+
style?: Record<string, any> | null;
|
|
31
|
+
format?: Record<string, any> | null;
|
|
32
|
+
metadata?: Record<string, any> | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SheetNamedRangeObj {
|
|
36
|
+
name: string;
|
|
37
|
+
startRowIndex: number;
|
|
38
|
+
startColumnIndex: number;
|
|
39
|
+
endRowIndex: number;
|
|
40
|
+
endColumnIndex: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SheetDesignObj {
|
|
44
|
+
version: number;
|
|
45
|
+
grid: SheetGridDesignObj;
|
|
46
|
+
columns?: Record<string, SheetAxisDesignObj>;
|
|
47
|
+
rows?: Record<string, SheetAxisDesignObj>;
|
|
48
|
+
defaultCellStyle?: Record<string, any>;
|
|
49
|
+
defaultCellFormat?: Record<string, any>;
|
|
50
|
+
namedRanges?: SheetNamedRangeObj[];
|
|
51
|
+
metadata?: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SheetFormulaObj {
|
|
55
|
+
version: number;
|
|
56
|
+
kind: string;
|
|
57
|
+
text: string;
|
|
58
|
+
dataTableName?: string | null;
|
|
59
|
+
rowIdentifier?: string | null;
|
|
60
|
+
cellKey?: string | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface SheetData {
|
|
64
|
+
__table: 'sheets';
|
|
65
|
+
|
|
66
|
+
id: number | bigint;
|
|
67
|
+
organizationId: number | bigint;
|
|
68
|
+
name: string;
|
|
69
|
+
title: string;
|
|
70
|
+
description?: string | null;
|
|
71
|
+
position: number;
|
|
72
|
+
design: SheetDesignObj;
|
|
73
|
+
active: boolean;
|
|
74
|
+
createdAt: Date;
|
|
75
|
+
updatedAt: Date;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SheetCellData {
|
|
79
|
+
__table: 'sheet_cells';
|
|
80
|
+
|
|
81
|
+
id: number | bigint | string;
|
|
82
|
+
organizationId: number | bigint;
|
|
83
|
+
sheetId: number | bigint;
|
|
84
|
+
rowIndex: number;
|
|
85
|
+
columnIndex: number;
|
|
86
|
+
rawInput?: string | null;
|
|
87
|
+
value?: SheetCellValue;
|
|
88
|
+
textValue?: string | null;
|
|
89
|
+
numberValue?: number | null;
|
|
90
|
+
booleanValue?: boolean | null;
|
|
91
|
+
dateValue?: Date | string | null;
|
|
92
|
+
datetimeValue?: Date | string | null;
|
|
93
|
+
formula?: SheetFormulaObj | null;
|
|
94
|
+
style?: Record<string, any> | null;
|
|
95
|
+
format?: Record<string, any> | null;
|
|
96
|
+
note?: string | null;
|
|
97
|
+
sourceType: SheetCellSourceTypeEnum;
|
|
98
|
+
regionId?: number | bigint | null;
|
|
99
|
+
region?: SheetCellRegionSourceObj | null;
|
|
100
|
+
createdAt: Date;
|
|
101
|
+
updatedAt: Date;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface SheetRangeData {
|
|
105
|
+
__table: 'sheet_ranges';
|
|
106
|
+
|
|
107
|
+
id: number | bigint;
|
|
108
|
+
organizationId: number | bigint;
|
|
109
|
+
sheetId: number | bigint;
|
|
110
|
+
startRowIndex: number;
|
|
111
|
+
startColumnIndex: number;
|
|
112
|
+
endRowIndex: number;
|
|
113
|
+
endColumnIndex: number;
|
|
114
|
+
position: number;
|
|
115
|
+
style?: Record<string, any> | null;
|
|
116
|
+
format?: Record<string, any> | null;
|
|
117
|
+
metadata?: Record<string, any> | null;
|
|
118
|
+
active: boolean;
|
|
119
|
+
createdAt: Date;
|
|
120
|
+
updatedAt: Date;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface SheetRegionSourceObj {
|
|
124
|
+
type: 'DATA_TABLE';
|
|
125
|
+
dataTableId: number | bigint | string;
|
|
126
|
+
viewId?: string | null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface SheetRegionColumnObj {
|
|
130
|
+
sourceCellKey: string;
|
|
131
|
+
label?: string | null;
|
|
132
|
+
width?: number | null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface SheetRegionOptionsObj {
|
|
136
|
+
conflictPolicy?: SheetRegionConflictPolicyEnum | null;
|
|
137
|
+
includeHeaderRow?: boolean | null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface SheetRegionData {
|
|
141
|
+
__table: 'sheet_regions';
|
|
142
|
+
|
|
143
|
+
id: number | bigint;
|
|
144
|
+
organizationId: number | bigint;
|
|
145
|
+
sheetId: number | bigint;
|
|
146
|
+
type: SheetRegionTypeEnum;
|
|
147
|
+
startRowIndex: number;
|
|
148
|
+
startColumnIndex: number;
|
|
149
|
+
sourceDataTableId?: number | bigint | null;
|
|
150
|
+
sourceViewId?: string | null;
|
|
151
|
+
source: SheetRegionSourceObj;
|
|
152
|
+
columns: SheetRegionColumnObj[];
|
|
153
|
+
options: SheetRegionOptionsObj;
|
|
154
|
+
active: boolean;
|
|
155
|
+
createdAt: Date;
|
|
156
|
+
updatedAt: Date;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface SheetGridViewportObj {
|
|
160
|
+
startRowIndex: number;
|
|
161
|
+
startColumnIndex: number;
|
|
162
|
+
rowCount: number;
|
|
163
|
+
columnCount: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface SheetCellRegionSourceObj {
|
|
167
|
+
regionId?: number | bigint | string | null;
|
|
168
|
+
sourceRowId?: number | bigint | string | null;
|
|
169
|
+
sourceCellKey?: string | null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface SheetGridRowObj {
|
|
173
|
+
rowIndex: number;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface SheetGridPageInfoObj {
|
|
177
|
+
hasMoreRows: boolean;
|
|
178
|
+
lastContentRowIndex?: number | null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface SheetGridObj {
|
|
182
|
+
id: number | bigint;
|
|
183
|
+
sheet: SheetData;
|
|
184
|
+
viewport: SheetGridViewportObj;
|
|
185
|
+
rows: SheetGridRowObj[];
|
|
186
|
+
cells: SheetCellData[];
|
|
187
|
+
ranges: SheetRangeData[];
|
|
188
|
+
regions: SheetRegionData[];
|
|
189
|
+
pageInfo: SheetGridPageInfoObj;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface SheetGridDesignGQL {
|
|
193
|
+
rowCount?: number | null;
|
|
194
|
+
columnCount?: number | null;
|
|
195
|
+
frozenRows?: number | null;
|
|
196
|
+
frozenColumns?: number | null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface SheetDesignGQL {
|
|
200
|
+
id?: string | null;
|
|
201
|
+
version?: number | null;
|
|
202
|
+
grid?: SheetGridDesignGQL | null;
|
|
203
|
+
columns?: string | null;
|
|
204
|
+
rows?: string | null;
|
|
205
|
+
defaultCellStyle?: string | null;
|
|
206
|
+
defaultCellFormat?: string | null;
|
|
207
|
+
namedRanges?: SheetNamedRangeObj[];
|
|
208
|
+
metadata?: string | null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface SheetGQL {
|
|
212
|
+
id?: string | null;
|
|
213
|
+
organizationId?: string | null;
|
|
214
|
+
name?: string | null;
|
|
215
|
+
title?: string | null;
|
|
216
|
+
description?: string | null;
|
|
217
|
+
position?: number | null;
|
|
218
|
+
design?: SheetDesignGQL | null;
|
|
219
|
+
active?: boolean | null;
|
|
220
|
+
createdAt?: string | null;
|
|
221
|
+
updatedAt?: string | null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface SheetCellGQL {
|
|
225
|
+
id?: string | null;
|
|
226
|
+
organizationId?: string | null;
|
|
227
|
+
sheetId?: string | null;
|
|
228
|
+
rowIndex?: number | null;
|
|
229
|
+
columnIndex?: number | null;
|
|
230
|
+
rawInput?: string | null;
|
|
231
|
+
value?: string | null;
|
|
232
|
+
textValue?: string | null;
|
|
233
|
+
numberValue?: number | null;
|
|
234
|
+
booleanValue?: boolean | null;
|
|
235
|
+
dateValue?: string | null;
|
|
236
|
+
datetimeValue?: string | null;
|
|
237
|
+
formula?: SheetFormulaObj | null;
|
|
238
|
+
style?: string | null;
|
|
239
|
+
format?: string | null;
|
|
240
|
+
note?: string | null;
|
|
241
|
+
sourceType?: SheetCellSourceTypeEnum | null;
|
|
242
|
+
regionId?: string | null;
|
|
243
|
+
region?: SheetCellRegionSourceObj | null;
|
|
244
|
+
createdAt?: string | null;
|
|
245
|
+
updatedAt?: string | null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface SheetGridRowGQL {
|
|
249
|
+
rowIndex: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface SheetGridPageInfoGQL {
|
|
253
|
+
hasMoreRows?: boolean | null;
|
|
254
|
+
lastContentRowIndex?: number | null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface SheetRangeGQL {
|
|
258
|
+
id?: string | null;
|
|
259
|
+
organizationId?: string | null;
|
|
260
|
+
sheetId?: string | null;
|
|
261
|
+
startRowIndex?: number | null;
|
|
262
|
+
startColumnIndex?: number | null;
|
|
263
|
+
endRowIndex?: number | null;
|
|
264
|
+
endColumnIndex?: number | null;
|
|
265
|
+
position?: number | null;
|
|
266
|
+
style?: string | null;
|
|
267
|
+
format?: string | null;
|
|
268
|
+
metadata?: string | null;
|
|
269
|
+
active?: boolean | null;
|
|
270
|
+
createdAt?: string | null;
|
|
271
|
+
updatedAt?: string | null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface SheetRegionGQL {
|
|
275
|
+
id?: string | null;
|
|
276
|
+
organizationId?: string | null;
|
|
277
|
+
sheetId?: string | null;
|
|
278
|
+
type?: SheetRegionTypeEnum | null;
|
|
279
|
+
startRowIndex?: number | null;
|
|
280
|
+
startColumnIndex?: number | null;
|
|
281
|
+
source?: SheetRegionSourceObj | null;
|
|
282
|
+
columns?: SheetRegionColumnObj[];
|
|
283
|
+
options?: SheetRegionOptionsObj | null;
|
|
284
|
+
active?: boolean | null;
|
|
285
|
+
createdAt?: string | null;
|
|
286
|
+
updatedAt?: string | null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface SheetGridGQL {
|
|
290
|
+
id?: string | null;
|
|
291
|
+
sheet?: SheetGQL | null;
|
|
292
|
+
viewport?: SheetGridViewportObj | null;
|
|
293
|
+
rows?: SheetGridRowGQL[];
|
|
294
|
+
cells?: SheetCellGQL[];
|
|
295
|
+
ranges?: SheetRangeGQL[];
|
|
296
|
+
regions?: SheetRegionGQL[];
|
|
297
|
+
pageInfo?: SheetGridPageInfoGQL | null;
|
|
298
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FILE_STATUS_ENUMS,
|
|
3
|
+
STORAGE_INTENT_ENUMS,
|
|
4
|
+
} from "../constants/storage.ts";
|
|
5
|
+
import type { OrganizationData } from "./organization.d.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Enums
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type StorageIntentEnum = typeof STORAGE_INTENT_ENUMS[number];
|
|
12
|
+
export type FileStatusEnum = typeof FILE_STATUS_ENUMS[number];
|
|
13
|
+
|
|
14
|
+
export type CSVColumnFormat =
|
|
15
|
+
| "NUMBER"
|
|
16
|
+
| "NUMBER_ROUND"
|
|
17
|
+
| "DECIMAL_1"
|
|
18
|
+
| "DECIMAL_2"
|
|
19
|
+
| "CURRENCY"
|
|
20
|
+
| "PERCENT"
|
|
21
|
+
| "STRING";
|
|
22
|
+
|
|
23
|
+
export type CSVFooterSummaryExpression =
|
|
24
|
+
| "SUM"
|
|
25
|
+
| "AVG"
|
|
26
|
+
| "MIN"
|
|
27
|
+
| "MAX"
|
|
28
|
+
| "COUNT"
|
|
29
|
+
| "CUSTOM";
|
|
30
|
+
|
|
31
|
+
export interface CSVColumnRequest {
|
|
32
|
+
label: string;
|
|
33
|
+
format: CSVColumnFormat;
|
|
34
|
+
hint: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CSVFooterSummaryRowRequest {
|
|
38
|
+
label: string;
|
|
39
|
+
expression: CSVFooterSummaryExpression;
|
|
40
|
+
format: CSVColumnFormat;
|
|
41
|
+
formula?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface CSVFileCreationRequest {
|
|
45
|
+
fileName: string;
|
|
46
|
+
fileDescription?: string;
|
|
47
|
+
maxRowsLength: number;
|
|
48
|
+
dataStartDate: string;
|
|
49
|
+
dataEndDate: string;
|
|
50
|
+
descriptionOfDataToSearch: string;
|
|
51
|
+
analysisGoal: string;
|
|
52
|
+
columns: CSVColumnRequest[];
|
|
53
|
+
footerSummaryRows?: CSVFooterSummaryRowRequest[];
|
|
54
|
+
sentFromSMS?: boolean;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Storage
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export interface StorageData {
|
|
63
|
+
__table: "storage";
|
|
64
|
+
id: number;
|
|
65
|
+
oaiFileId: string | null;
|
|
66
|
+
organizationId: number | null;
|
|
67
|
+
accountId: number | null;
|
|
68
|
+
uri: string;
|
|
69
|
+
size: number;
|
|
70
|
+
checked: boolean;
|
|
71
|
+
at: Date;
|
|
72
|
+
contentType: string;
|
|
73
|
+
values: Record<string, any> | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface StorageGeneratedData {
|
|
77
|
+
__table: "storage_generated";
|
|
78
|
+
|
|
79
|
+
code: string;
|
|
80
|
+
fileName: string;
|
|
81
|
+
fileDescription: string;
|
|
82
|
+
summaryReport: string | null;
|
|
83
|
+
payload: CSVFileCreationRequest | Record<string, any>;
|
|
84
|
+
accountId: number | bigint;
|
|
85
|
+
organizationId: number | bigint;
|
|
86
|
+
organization?: OrganizationData;
|
|
87
|
+
account?: {
|
|
88
|
+
id: number | bigint;
|
|
89
|
+
profile?: {
|
|
90
|
+
id: number | bigint;
|
|
91
|
+
firstName: string | null;
|
|
92
|
+
lastName: string | null;
|
|
93
|
+
} | null;
|
|
94
|
+
email?: {
|
|
95
|
+
id: number | bigint;
|
|
96
|
+
address: string | null;
|
|
97
|
+
} | null;
|
|
98
|
+
phone?: {
|
|
99
|
+
id: number | bigint;
|
|
100
|
+
number: string | null;
|
|
101
|
+
} | null;
|
|
102
|
+
};
|
|
103
|
+
storageId: number | bigint | null;
|
|
104
|
+
status: FileStatusEnum;
|
|
105
|
+
generatedAt: Date | null;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface StorageGQL {
|
|
111
|
+
__deleted?: boolean;
|
|
112
|
+
|
|
113
|
+
id: string;
|
|
114
|
+
organizationId: string | null;
|
|
115
|
+
accountId: string | null;
|
|
116
|
+
uri: string;
|
|
117
|
+
size: number;
|
|
118
|
+
checked: boolean;
|
|
119
|
+
at: string; // ISO Date string
|
|
120
|
+
contentType: string;
|
|
121
|
+
|
|
122
|
+
// client-side only
|
|
123
|
+
uploadStatus?: "ERROR" | "UPLOADING" | null;
|
|
124
|
+
|
|
125
|
+
// metadata
|
|
126
|
+
name: string | null;
|
|
127
|
+
description?: string | null;
|
|
128
|
+
aiNote?: string | null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type StorageUploadEvent = Partial<{
|
|
132
|
+
oaiFileId: string;
|
|
133
|
+
uploaderAccountId: number | bigint | string;
|
|
134
|
+
values: Partial<{
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
aiNote: string;
|
|
138
|
+
cacheDuration: number;
|
|
139
|
+
|
|
140
|
+
// For PDF only
|
|
141
|
+
pageCount: number;
|
|
142
|
+
isEncrypted: boolean;
|
|
143
|
+
pdfVersion: string;
|
|
144
|
+
}>;
|
|
145
|
+
uploadIntent: {
|
|
146
|
+
intent: StorageIntentEnum;
|
|
147
|
+
entries: [string, string][];
|
|
148
|
+
};
|
|
149
|
+
upsertQuery?: RelatedDocumentUpsertQuery;
|
|
150
|
+
realTimeUpdate?: string; // JSON.stringified object; "{{storageId}}" will be replaced with actual storage ID after upload
|
|
151
|
+
}>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Post-upload related document query execution object
|
|
155
|
+
*/
|
|
156
|
+
|
|
157
|
+
export interface RelatedDocumentUpsertQuery {
|
|
158
|
+
__table: string;
|
|
159
|
+
conflictKeys: string[];
|
|
160
|
+
data: Record<string, any>;
|
|
161
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { LabelAndValue } from '@jsb188/app/types/other.d.ts';
|
|
2
|
+
import type { BuildSingleTextLine } from '@jsb188/app/utils/string.ts';
|
|
3
|
+
import type { LogTypeEnum } from '../types/log.d.ts';
|
|
4
|
+
import type { OrganizationData, OrganizationFeatureEnum } from '../types/organization.d.ts';
|
|
5
|
+
import type { WORKFLOW_RUN_STATUS_ENUMS } from '@jsb188/app/constants/agent.ts';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Enums
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type WorkflowStatusEnum = (typeof WORKFLOW_RUN_STATUS_ENUMS)[number];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Workflow prompt instructions
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface WorkflowPrompts {
|
|
18
|
+
main: BuildSingleTextLine[];
|
|
19
|
+
identity?: BuildSingleTextLine[];
|
|
20
|
+
progressReport?: BuildSingleTextLine[];
|
|
21
|
+
dataTable?: BuildSingleTextLine[];
|
|
22
|
+
summary?: BuildSingleTextLine[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Workflow data; each step object
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export interface WorkflowStep extends LabelAndValue {
|
|
30
|
+
conditional?: Partial<LabelAndValue> & {
|
|
31
|
+
required?: string[]; // If this value doesn't exist or is not an array, that's a data error, and this object should be ignored
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Workflow data object
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export interface WorkflowData {
|
|
40
|
+
__table: 'workflows';
|
|
41
|
+
|
|
42
|
+
id: number | bigint;
|
|
43
|
+
organizationId: number | bigint;
|
|
44
|
+
org?: OrganizationData; // Included if query joined with organization table
|
|
45
|
+
reportId: number | bigint | null;
|
|
46
|
+
|
|
47
|
+
logType: LogTypeEnum;
|
|
48
|
+
feature?: OrganizationFeatureEnum;
|
|
49
|
+
|
|
50
|
+
title: string;
|
|
51
|
+
instructions?: null | WorkflowPrompts;
|
|
52
|
+
|
|
53
|
+
schedule: string | null;
|
|
54
|
+
scheduleInterval: number;
|
|
55
|
+
active: boolean;
|
|
56
|
+
values: Partial<{
|
|
57
|
+
model: 'advanced' | 'standard' | 'basic' | 'lesser' | 'smallest';
|
|
58
|
+
effort: 'minimal' | 'low' | 'medium' | 'high';
|
|
59
|
+
verbosity: 'low' | 'medium' | 'high';
|
|
60
|
+
steps: WorkflowStep[];
|
|
61
|
+
requireDataTables?: boolean;
|
|
62
|
+
dataTableRowIdentifier?: 'logId' | 'reportSubmissionId' | null;
|
|
63
|
+
config: Record<string, string | number | boolean | null> & {
|
|
64
|
+
endTime: string; // HHMM format
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
|
|
68
|
+
startedAt: Date | null;
|
|
69
|
+
nextAt: Date | null;
|
|
70
|
+
createdAt: Date;
|
|
71
|
+
updatedAt: Date;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Workflow instance data object
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
export interface WorkflowRunData {
|
|
79
|
+
__table: 'workflow_runs';
|
|
80
|
+
|
|
81
|
+
id: number | bigint;
|
|
82
|
+
workflowId: number | bigint;
|
|
83
|
+
logId: number | bigint | null;
|
|
84
|
+
reportSubmissionId?: number | bigint | null;
|
|
85
|
+
runKey: string;
|
|
86
|
+
iterations: number;
|
|
87
|
+
values:
|
|
88
|
+
| null
|
|
89
|
+
| Partial<{
|
|
90
|
+
progressReport: string;
|
|
91
|
+
}>;
|
|
92
|
+
message: string | null;
|
|
93
|
+
status: WorkflowStatusEnum;
|
|
94
|
+
scheduledDate: Date | null;
|
|
95
|
+
followUpAt: Date | null;
|
|
96
|
+
activityAt: Date;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Workflow dataTable target data object
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
export interface WorkflowDataTableTargetData {
|
|
104
|
+
__table: 'workflow_data_table_targets';
|
|
105
|
+
|
|
106
|
+
id: number | bigint;
|
|
107
|
+
workflowId: number | bigint;
|
|
108
|
+
dataTableId: number | bigint;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Workflow dataTable write receipt data object
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
export interface WorkflowDataTableRecordWriteData {
|
|
116
|
+
__table: 'workflow_data_table_record_writes';
|
|
117
|
+
|
|
118
|
+
id: number | bigint;
|
|
119
|
+
organizationId: number | bigint;
|
|
120
|
+
workflowId: number | bigint;
|
|
121
|
+
workflowRunId?: number | bigint | null;
|
|
122
|
+
logId?: number | bigint | null;
|
|
123
|
+
reportSubmissionId?: number | bigint | null;
|
|
124
|
+
dataTableId: number | bigint;
|
|
125
|
+
dataTableRowId?: number | bigint | null;
|
|
126
|
+
status: 'CREATED' | 'UPDATED' | 'SKIPPED' | 'FAILED';
|
|
127
|
+
error?: string | null;
|
|
128
|
+
metadata: Record<string, any>;
|
|
129
|
+
createdAt: Date;
|
|
130
|
+
updatedAt: Date;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface WorkflowRunGQL {
|
|
134
|
+
__deleted?: boolean;
|
|
135
|
+
|
|
136
|
+
id: string;
|
|
137
|
+
workflowId: string;
|
|
138
|
+
logId: string | null;
|
|
139
|
+
runKey: string;
|
|
140
|
+
iterations: number;
|
|
141
|
+
progressReport: string | null;
|
|
142
|
+
message: string | null;
|
|
143
|
+
status: WorkflowStatusEnum;
|
|
144
|
+
scheduledDate: string | null;
|
|
145
|
+
followUpAt: string | null;
|
|
146
|
+
activityAt: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Workflow GraphQL data
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
export interface WorkflowGQL {
|
|
154
|
+
__deleted?: boolean;
|
|
155
|
+
|
|
156
|
+
id: string;
|
|
157
|
+
organizationId: string;
|
|
158
|
+
reportId: string | null;
|
|
159
|
+
|
|
160
|
+
logType: LogTypeEnum;
|
|
161
|
+
feature: OrganizationFeatureEnum | null;
|
|
162
|
+
|
|
163
|
+
title: string;
|
|
164
|
+
steps: LabelAndValue[];
|
|
165
|
+
|
|
166
|
+
schedule: string | null;
|
|
167
|
+
scheduleInterval: number;
|
|
168
|
+
active: boolean;
|
|
169
|
+
|
|
170
|
+
startedAt: string | null;
|
|
171
|
+
nextAt: string | null;
|
|
172
|
+
createdAt: string;
|
|
173
|
+
updatedAt: string;
|
|
174
|
+
}
|