@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.
Files changed (45) hide show
  1. package/package.json +39 -20
  2. package/src/constants/dataTable.ts +22 -0
  3. package/src/constants/email.ts +28 -0
  4. package/src/constants/inboundContact.ts +8 -0
  5. package/src/constants/integration.ts +14 -0
  6. package/src/constants/log-activityTexts.ts +54 -28
  7. package/src/constants/log.ts +82 -38
  8. package/src/constants/organization.ts +11 -2
  9. package/src/constants/product.ts +9 -33
  10. package/src/constants/report.ts +29 -10
  11. package/src/constants/sheet.ts +20 -0
  12. package/src/constants/square.ts +16 -0
  13. package/src/constants/storage.ts +12 -0
  14. package/src/schemas/editLogEntry.ts +90 -44
  15. package/src/schemas/inboundContact.ts +72 -0
  16. package/src/schemas/logsQuery.ts +7 -272
  17. package/src/schemas/organization.ts +11 -174
  18. package/src/schemas/productsQuery.ts +2 -94
  19. package/src/schemas/reportsQuery.ts +8 -95
  20. package/src/types/account.d.ts +78 -0
  21. package/src/types/dataTable.d.ts +447 -0
  22. package/src/types/email.d.ts +71 -0
  23. package/src/types/inboundContact.d.ts +56 -0
  24. package/src/types/integration.d.ts +42 -0
  25. package/src/types/log.d.ts +289 -178
  26. package/src/types/organization.d.ts +106 -50
  27. package/src/types/product.d.ts +7 -96
  28. package/src/types/report.d.ts +239 -152
  29. package/src/types/sheet.d.ts +298 -0
  30. package/src/types/storage.d.ts +161 -0
  31. package/src/types/workflow.d.ts +174 -0
  32. package/src/utils/dataTable.ts +834 -0
  33. package/src/utils/email.ts +113 -0
  34. package/src/utils/log.ts +30 -628
  35. package/src/utils/organization.ts +227 -44
  36. package/src/utils/product-calEvent.ts +7 -60
  37. package/src/utils/report.ts +158 -0
  38. package/src/utils/sheet.ts +170 -0
  39. package/src/utils/square.ts +22 -0
  40. package/src/utils/table-route.ts +146 -0
  41. package/src/utils/workflow.ts +212 -0
  42. package/tsconfig.json +12 -0
  43. package/src/schemas/childOrganizationsQuery.ts +0 -44
  44. package/src/types/action.d.ts +0 -42
  45. package/src/utils/route-helpers.ts +0 -583
@@ -1,8 +1,4 @@
1
1
  import z from 'zod';
2
- import type { OrganizationOperationEnum } from '../types/organization';
3
- import type { ReportsFilterArgs } from '../types/report';
4
- import { convertDigitToProductType } from './productsQuery';
5
- import { REPORT_TYPES } from '../constants/report';
6
2
 
7
3
  /**
8
4
  * Zod schema for query params to filter
@@ -12,96 +8,13 @@ export const ReportsFilterSchema = z.object({
12
8
  preset: z.string()
13
9
  .optional()
14
10
  .nullable(),
15
- reportType: z.enum(REPORT_TYPES as [string]),
16
- query: z.string()
11
+ reportGroupId: z.string()
12
+ .optional()
13
+ .nullable(),
14
+ startPeriod: z.string()
15
+ .optional()
16
+ .nullable(),
17
+ endPeriod: z.string()
18
+ .optional()
17
19
  .nullable(),
18
20
  });
19
-
20
- /**
21
- * Create a filter object for reports() query from the URL search query.
22
- * @param operationType - The organization operation type
23
- * @param searchQuery - The search query string from the URL
24
- * @param otherFiltersObj - Additional filter properties to merge into the result
25
- * @returns ReportsFilterArgs - The filter object to be used in the productsList() query
26
- */
27
-
28
- export function getReportsFilterFromURL(
29
- _operationType: OrganizationOperationEnum | null,
30
- searchQuery: string,
31
- otherFiltersObj?: {
32
- withoutPreset?: Partial<ReportsFilterArgs>,
33
- withPreset?: Partial<ReportsFilterArgs>
34
- }
35
- ) {
36
- if (!searchQuery && otherFiltersObj?.withPreset) {
37
- return otherFiltersObj.withPreset;
38
- } else if (searchQuery === '?preset=none' && otherFiltersObj?.withoutPreset) {
39
- return otherFiltersObj.withoutPreset;
40
- }
41
-
42
- const urlParams = new URLSearchParams(searchQuery);
43
-
44
- // let startDate = urlParams.get('sd');
45
- // let endDate = urlParams.get('ed');
46
- // if (startDate && !endDate) {
47
- // endDate = startDate;
48
- // } else if (endDate && !startDate) {
49
- // startDate = endDate;
50
- // }
51
-
52
- const filter: ReportsFilterArgs = {
53
- reportType: convertDigitToProductType(urlParams.get('t'))!,
54
- period: urlParams.get('p') || '',
55
- // startDate,
56
- // endDate,
57
- query: urlParams.get('q') || '',
58
- ...otherFiltersObj?.withoutPreset,
59
- };
60
-
61
- const validation = ReportsFilterSchema.safeParse(filter);
62
-
63
- // console.log(otherFiltersObj);
64
- // console.log('filter', filter);
65
- // console.log('validation', validation);
66
-
67
- if (!validation.success) {
68
- // console.log('validation error', validation.error);
69
- // Return null and force the client to go to a valid page
70
- return null;
71
- }
72
-
73
- return filter;
74
- }
75
-
76
- /**
77
- * Test if URL search query is valid against actual filter object
78
- */
79
-
80
- export function reportsSearchQueryIsValid(
81
- searchQuery: string,
82
- filter: ReportsFilterArgs | null
83
- ) {
84
- if (!filter) {
85
- return !searchQuery; // If no filter, searchQuery must be empty to be valid
86
- } else if (!searchQuery || searchQuery === '?preset=none') {
87
- return true; // If no searchQuery, any filter is valid
88
- }
89
-
90
- const urlParams = new URLSearchParams(searchQuery);
91
- // const operation = urlParams.get('o');
92
- const reportType = urlParams.get('t');
93
- // const accountId = urlParams.get('a');
94
- // const startDate = urlParams.get('sd');
95
- // const endDate = urlParams.get('ed');
96
- const query = urlParams.get('q');
97
-
98
- return (
99
- // operation is allowed to pass through
100
- // !!filter.operation === !!operation &&
101
- !!filter.reportType === !!reportType &&
102
- // !!filter.accountId === !!accountId &&
103
- // !!filter.startDate === !!startDate &&
104
- // !!filter.endDate === !!endDate &&
105
- !!filter.query === !!query
106
- );
107
- }
@@ -0,0 +1,78 @@
1
+ import type { OrganizationACL, OrganizationRoleEnum } from './organization.d.ts';
2
+
3
+ /**
4
+ * Account; phone
5
+ */
6
+
7
+ export interface AccountPhoneObj {
8
+ id: number;
9
+ number: string;
10
+ verified: boolean;
11
+ }
12
+
13
+ /**
14
+ * Account
15
+ */
16
+
17
+ export interface AccountObj {
18
+ id: number | bigint;
19
+ readableId?: string | null;
20
+ settings: Record<string, any>;
21
+ profile: Partial<{
22
+ firstName: string;
23
+ lastName: string;
24
+ storageId: number | null;
25
+ // phone: AccountPhoneObj | null; // ?? This is a coding mistake, I think
26
+ }>;
27
+ }
28
+
29
+ export interface AccountData {
30
+ __table: 'accounts';
31
+
32
+ id: number | bigint;
33
+ readableId?: string | null;
34
+ settings: Record<string, any>;
35
+
36
+ profile: {
37
+ __table: 'account_profiles';
38
+ id: number | bigint;
39
+ firstName: string;
40
+ lastName: string;
41
+ storageId: number | bigint | null;
42
+ };
43
+ phone: {
44
+ __table: 'account_phones';
45
+ id: number;
46
+ number: string;
47
+ verified: boolean;
48
+ banned: boolean;
49
+ editAt: Date;
50
+ };
51
+ email: {
52
+ __table: 'account_emails';
53
+ id: number;
54
+ address: string;
55
+ verified: boolean;
56
+ banned: boolean;
57
+ editAt: Date;
58
+ };
59
+ createdAt: Date;
60
+ updatedAt: Date;
61
+ }
62
+
63
+ /**
64
+ * Account with membership
65
+ */
66
+
67
+ export interface AccountMembershipData {
68
+ id: number;
69
+ accountId: number;
70
+ organizationId: number;
71
+ role: OrganizationRoleEnum;
72
+ acl: OrganizationACL;
73
+ notes?: string;
74
+ primary: boolean;
75
+ createdAt: Date;
76
+ updatedAt: Date;
77
+ account: AccountData;
78
+ }
@@ -0,0 +1,447 @@
1
+ import type { DATA_TABLE_FIELD_TYPE_ENUMS } from '../constants/dataTable.ts';
2
+
3
+ export type DataTableFieldTypeEnum = typeof DATA_TABLE_FIELD_TYPE_ENUMS[number];
4
+
5
+ export type DataTableFieldTypeGQL = DataTableFieldTypeEnum;
6
+
7
+ export type DataTableCellReferenceStatus = 'NONE' | 'ACTIVE' | 'DELETED';
8
+
9
+ export type DataTableRecordValue =
10
+ | string
11
+ | number
12
+ | boolean
13
+ | null
14
+ | Record<string, any>
15
+ | any[];
16
+
17
+ export interface DataTableDesignCellOptionObj {
18
+ label: string;
19
+ value: string;
20
+ color?: string | null;
21
+ }
22
+
23
+ export interface DataTableDesignCellObj {
24
+ key: string;
25
+ label: string;
26
+ humanLabel?: string | null;
27
+ iconName?: string | null;
28
+ fieldType: DataTableFieldTypeEnum;
29
+ humanFieldType: DataTableFieldTypeEnum;
30
+ format?: string | null;
31
+ instructions?: string | null;
32
+ source?: {
33
+ path: string;
34
+ table: string;
35
+ } | null;
36
+ options?: DataTableDesignCellOptionObj[];
37
+ openLink?: boolean;
38
+ humansOnly?: boolean;
39
+ humansCannotEdit?: boolean; // If true, humans cannot edit this cell
40
+ hidden?: boolean; // If true, this cell is hidden from the default dataTable grid
41
+ indexed?: boolean;
42
+ width?: number | null;
43
+ }
44
+
45
+ export interface DataTableDesignViewColumnSourceObj {
46
+ type: 'MASTER_CELL' | 'FORMULA' | 'STATIC' | 'DIMENSION' | 'CUSTOM' | 'RELATED_RECORD' | 'COMPUTED';
47
+ cellKey?: string | null;
48
+ formulaKey?: string | null;
49
+ dimensionKey?: string | null;
50
+ table?: string | null;
51
+ path?: string | null;
52
+ sourceCellKey?: string | null;
53
+ sourceCellKeys?: string[];
54
+ operation?: 'SUM' | null;
55
+ }
56
+
57
+ export interface DataTableDesignViewDimensionObj {
58
+ key: string;
59
+ label?: string | null;
60
+ source?: DataTableDesignViewColumnSourceObj | null;
61
+ }
62
+
63
+ export interface DataTableDesignViewGeneratorDateSeriesObj {
64
+ key: string;
65
+ label?: string | null;
66
+ sourceCellKey?: string | null;
67
+ grain: 'DAY' | 'WEEK';
68
+ weekStart?: 'MONDAY';
69
+ range: {
70
+ type: 'CURRENT_MONTH' | 'FIXED';
71
+ start?: string;
72
+ end?: string;
73
+ };
74
+ }
75
+
76
+ export interface DataTableDesignViewGeneratorDimensionObj {
77
+ key: string;
78
+ label?: string | null;
79
+ source:
80
+ | {
81
+ type: 'MASTER_CELL_OPTIONS';
82
+ cellKey: string;
83
+ }
84
+ | {
85
+ type: 'STATIC_VALUES';
86
+ values: Array<{
87
+ value: string;
88
+ label?: string | null;
89
+ }>;
90
+ };
91
+ }
92
+
93
+ export interface DataTableDesignViewGeneratorMeasureObj {
94
+ key: string;
95
+ label?: string | null;
96
+ operation: 'COUNT' | 'SUM';
97
+ sourceCellKey?: string | null;
98
+ }
99
+
100
+ export interface DataTableDesignViewGeneratorObj {
101
+ keyPrefix: string;
102
+ dateSeries?: DataTableDesignViewGeneratorDateSeriesObj;
103
+ dimensions?: DataTableDesignViewGeneratorDimensionObj[];
104
+ measures?: DataTableDesignViewGeneratorMeasureObj[];
105
+ }
106
+
107
+ export interface DataTableDesignViewRowModelObj {
108
+ type: 'MASTER_ROWS' | 'GROUPED_ROWS';
109
+ dimensions?: DataTableDesignViewDimensionObj[];
110
+ generator?: DataTableDesignViewGeneratorObj | null;
111
+ }
112
+
113
+ export interface DataTableDesignViewColumnObj {
114
+ key: string;
115
+ label: string;
116
+ humanLabel?: string | null;
117
+ iconName?: string | null;
118
+ fieldType?: DataTableFieldTypeEnum | null;
119
+ humanFieldType: DataTableFieldTypeEnum;
120
+ source?: DataTableDesignViewColumnSourceObj | null;
121
+ options?: DataTableDesignCellOptionObj[];
122
+ openLink?: boolean;
123
+ humansCannotEdit?: boolean;
124
+ width?: number | null;
125
+ }
126
+
127
+ export interface DataTableDesignViewFilterObj {
128
+ id: string;
129
+ columnKey: string;
130
+ operator: string;
131
+ value?: any;
132
+ enabled?: boolean;
133
+ }
134
+
135
+ export interface DataTableDesignViewSortObj {
136
+ columnKey: string;
137
+ direction: 'ASC' | 'DESC';
138
+ }
139
+
140
+ export interface DataTableDesignViewGroupObj {
141
+ columnKey: string;
142
+ direction?: 'ASC' | 'DESC';
143
+ }
144
+
145
+ export interface DataTableDesignViewObj {
146
+ id: string;
147
+ name: string;
148
+ layout: 'GRID';
149
+ iconName?: string | null;
150
+ color?: string | null;
151
+ description?: string | null;
152
+ rowModel?: DataTableDesignViewRowModelObj | null;
153
+ columns: DataTableDesignViewColumnObj[];
154
+ columnsOrder?: string[];
155
+ filters?: DataTableDesignViewFilterObj[];
156
+ sorts?: DataTableDesignViewSortObj[];
157
+ groups?: DataTableDesignViewGroupObj[];
158
+ stickyTop?: number | null;
159
+ stickyLeft?: number | null;
160
+ humansCannotEdit?: boolean | null;
161
+ }
162
+
163
+ export interface DataTableDesignObj {
164
+ cells: DataTableDesignCellObj[];
165
+ cellsOrder?: string[];
166
+ views?: DataTableDesignViewObj[];
167
+ viewsOrder?: string[];
168
+ defaultViewId?: string | null;
169
+ instructions?: string;
170
+ humansCannotEdit?: boolean; // If true, humans cannot edit any cells in this dataTable
171
+ stickyTop?: number;
172
+ stickyLeft?: number;
173
+ }
174
+
175
+ export interface DataTableData {
176
+ __table: 'data_tables';
177
+
178
+ id: number | bigint;
179
+ organizationId: number | bigint;
180
+ name: string;
181
+ title: string;
182
+ description?: string | null;
183
+ design: DataTableDesignObj;
184
+ active: boolean;
185
+ createdAt: Date;
186
+ updatedAt: Date;
187
+ }
188
+
189
+ export interface DataTableRowData {
190
+ __table: 'data_table_rows';
191
+
192
+ id: number | bigint;
193
+ organizationId: number | bigint;
194
+ dataTableId: number | bigint;
195
+ identifier?: string | null;
196
+ viewId?: string | null;
197
+ viewRowKey?: string | null;
198
+ position: number;
199
+ metadata: Record<string, any>;
200
+ }
201
+
202
+ export interface DataTableRecordData {
203
+ __table: 'data_table_records';
204
+
205
+ id: number | bigint;
206
+ dataTableId: number | bigint;
207
+ dataTableRowId: number | bigint;
208
+ cellKey: string;
209
+ iconName?: string | null;
210
+ value?: DataTableRecordValue;
211
+ textValue?: string | null;
212
+ numberValue?: number | null;
213
+ booleanValue?: boolean | null;
214
+ dateValue?: Date | string | null;
215
+ datetimeValue?: Date | string | null;
216
+ relatedTable?: string | null;
217
+ relatedId?: number | bigint | null;
218
+ referenceDataTableId?: number | bigint | null;
219
+ referenceDataTableRowId?: number | bigint | null;
220
+ referenceCellKey?: string | null;
221
+ createdAt: Date;
222
+ updatedAt: Date;
223
+ }
224
+
225
+ export interface DataTableCellReferenceGQL {
226
+ dataTableId?: string | null;
227
+ dataTableRowId?: string | null;
228
+ cellKey?: string | null;
229
+ }
230
+
231
+ export interface DataTableDesignCellOptionGQL {
232
+ label: string;
233
+ value: string;
234
+ color?: string | null;
235
+ }
236
+
237
+ export interface DataTableDesignCellSourceGQL {
238
+ path: string;
239
+ table: string;
240
+ }
241
+
242
+ export interface DataTableDesignCellGQL {
243
+ key: string;
244
+ label: string;
245
+ humanLabel?: string | null;
246
+ iconName?: string | null;
247
+ fieldType: DataTableFieldTypeGQL;
248
+ humanFieldType: DataTableFieldTypeGQL;
249
+ format?: string | null;
250
+ instructions?: string | null;
251
+ source?: DataTableDesignCellSourceGQL | null;
252
+ options?: DataTableDesignCellOptionGQL[];
253
+ openLink?: boolean | null;
254
+ humansOnly?: boolean | null;
255
+ humansCannotEdit?: boolean | null;
256
+ hidden?: boolean | null;
257
+ indexed?: boolean | null;
258
+ width?: number | null;
259
+ }
260
+
261
+ export interface DataTableDesignViewColumnSourceGQL {
262
+ type: 'MASTER_CELL' | 'FORMULA' | 'STATIC' | 'DIMENSION' | 'CUSTOM' | 'RELATED_RECORD' | 'COMPUTED';
263
+ cellKey?: string | null;
264
+ formulaKey?: string | null;
265
+ dimensionKey?: string | null;
266
+ table?: string | null;
267
+ path?: string | null;
268
+ sourceCellKey?: string | null;
269
+ sourceCellKeys?: string[];
270
+ operation?: 'SUM' | null;
271
+ }
272
+
273
+ export interface DataTableDesignViewDimensionGQL {
274
+ key: string;
275
+ label?: string | null;
276
+ source?: DataTableDesignViewColumnSourceGQL | null;
277
+ }
278
+
279
+ export interface DataTableDesignViewGeneratorDateSeriesGQL {
280
+ key: string;
281
+ label?: string | null;
282
+ sourceCellKey?: string | null;
283
+ grain: 'DAY' | 'WEEK';
284
+ weekStart?: 'MONDAY' | null;
285
+ range: {
286
+ type: 'CURRENT_MONTH' | 'FIXED';
287
+ start?: string | null;
288
+ end?: string | null;
289
+ };
290
+ }
291
+
292
+ export interface DataTableDesignViewGeneratorDimensionGQL {
293
+ key: string;
294
+ label?: string | null;
295
+ source:
296
+ | {
297
+ type: 'MASTER_CELL_OPTIONS';
298
+ cellKey: string;
299
+ }
300
+ | {
301
+ type: 'STATIC_VALUES';
302
+ values: Array<{
303
+ value: string;
304
+ label?: string | null;
305
+ }>;
306
+ };
307
+ }
308
+
309
+ export interface DataTableDesignViewGeneratorMeasureGQL {
310
+ key: string;
311
+ label?: string | null;
312
+ operation: 'COUNT' | 'SUM';
313
+ sourceCellKey?: string | null;
314
+ }
315
+
316
+ export interface DataTableDesignViewGeneratorGQL {
317
+ keyPrefix: string;
318
+ dateSeries?: DataTableDesignViewGeneratorDateSeriesGQL | null;
319
+ dimensions?: DataTableDesignViewGeneratorDimensionGQL[];
320
+ measures?: DataTableDesignViewGeneratorMeasureGQL[];
321
+ }
322
+
323
+ export interface DataTableDesignViewRowModelGQL {
324
+ type: 'MASTER_ROWS' | 'GROUPED_ROWS';
325
+ dimensions?: DataTableDesignViewDimensionGQL[];
326
+ generator?: DataTableDesignViewGeneratorGQL | null;
327
+ }
328
+
329
+ export interface DataTableDesignViewColumnGQL {
330
+ key: string;
331
+ label: string;
332
+ humanLabel?: string | null;
333
+ iconName?: string | null;
334
+ fieldType?: DataTableFieldTypeGQL | null;
335
+ humanFieldType: DataTableFieldTypeGQL;
336
+ source?: DataTableDesignViewColumnSourceGQL | null;
337
+ options?: DataTableDesignCellOptionGQL[];
338
+ openLink?: boolean | null;
339
+ humansCannotEdit?: boolean | null;
340
+ width?: number | null;
341
+ }
342
+
343
+ export interface DataTableDesignViewFilterGQL {
344
+ id: string;
345
+ columnKey: string;
346
+ operator: string;
347
+ value?: string | null;
348
+ enabled?: boolean | null;
349
+ }
350
+
351
+ export interface DataTableDesignViewSortGQL {
352
+ columnKey: string;
353
+ direction: 'ASC' | 'DESC';
354
+ }
355
+
356
+ export interface DataTableDesignViewGroupGQL {
357
+ columnKey: string;
358
+ direction?: 'ASC' | 'DESC' | null;
359
+ }
360
+
361
+ export interface DataTableDesignViewGQL {
362
+ id: string;
363
+ name: string;
364
+ layout: 'GRID';
365
+ iconName?: string | null;
366
+ color?: string | null;
367
+ description?: string | null;
368
+ rowModel?: DataTableDesignViewRowModelGQL | null;
369
+ columns: DataTableDesignViewColumnGQL[];
370
+ columnsOrder: string[];
371
+ filters: DataTableDesignViewFilterGQL[];
372
+ sorts: DataTableDesignViewSortGQL[];
373
+ groups: DataTableDesignViewGroupGQL[];
374
+ stickyTop?: number | null;
375
+ stickyLeft?: number | null;
376
+ humansCannotEdit?: boolean | null;
377
+ }
378
+
379
+ export interface DataTableDesignGQL {
380
+ id: string;
381
+ cells: DataTableDesignCellGQL[];
382
+ cellsOrder: string[];
383
+ views?: DataTableDesignViewGQL[];
384
+ viewsOrder?: string[];
385
+ defaultViewId?: string | null;
386
+ instructions?: string | null;
387
+ humansCannotEdit?: boolean | null;
388
+ stickyTop?: number | null;
389
+ stickyLeft?: number | null;
390
+ }
391
+
392
+ export interface DataTableGQL {
393
+ __deleted?: boolean;
394
+
395
+ id: string;
396
+ organizationId: string;
397
+
398
+ name: string;
399
+ title: string;
400
+ description?: string | null;
401
+ design: DataTableDesignGQL;
402
+ active: boolean;
403
+
404
+ createdAt: string;
405
+ updatedAt: string;
406
+ }
407
+
408
+ export interface DataTableRowGQL {
409
+ __deleted?: boolean;
410
+
411
+ id: string;
412
+ cursor: string;
413
+ organizationId: string;
414
+ dataTableId: string;
415
+
416
+ identifier?: string | null;
417
+ viewId?: string | null;
418
+ viewRowKey?: string | null;
419
+ position: number;
420
+ metadata: string;
421
+ cells?: DataTableCellGQL[];
422
+ updatedAt?: string | null;
423
+ }
424
+
425
+ export interface DataTableCellGQL {
426
+ __deleted?: boolean;
427
+
428
+ id: string;
429
+ dataTableId: string;
430
+ dataTableRowId: string;
431
+
432
+ cellKey: string;
433
+ iconName?: string | null;
434
+ value?: string | null;
435
+ textValue?: string | null;
436
+ numberValue?: number | null;
437
+ booleanValue?: boolean | null;
438
+ dateValue?: string | null;
439
+ datetimeValue?: string | null;
440
+ relatedTable?: string | null;
441
+ relatedId?: string | null;
442
+ reference?: DataTableCellReferenceGQL | null;
443
+ referenceStatus?: DataTableCellReferenceStatus | null;
444
+
445
+ createdAt: string;
446
+ updatedAt: string;
447
+ }
@@ -0,0 +1,71 @@
1
+ import type {
2
+ EMAIL_STATUS_ENUMS,
3
+ INBOUND_EMAIL_BODY_FORMAT_ENUMS,
4
+ INBOUND_EMAIL_SORT_ENUMS,
5
+ } from '../constants/email.ts';
6
+
7
+ /**
8
+ * Email handling lifecycle status.
9
+ */
10
+ export type EmailStatusEnum = typeof EMAIL_STATUS_ENUMS[number];
11
+
12
+ /**
13
+ * Inbound email list sort.
14
+ */
15
+ export type InboundEmailsSortEnum = typeof INBOUND_EMAIL_SORT_ENUMS[number];
16
+
17
+ /**
18
+ * Inbound email display body source.
19
+ */
20
+ export type InboundEmailBodyFormatEnum = typeof INBOUND_EMAIL_BODY_FORMAT_ENUMS[number];
21
+
22
+ /**
23
+ * Safe attachment metadata from one inbound email payload.
24
+ */
25
+ export interface InboundEmailAttachmentGQL {
26
+ name: string | null;
27
+ contentType: string | null;
28
+ contentLength: number | null;
29
+ }
30
+
31
+ /**
32
+ * Saved inbound email database row.
33
+ */
34
+ export interface InboundEmailData {
35
+ __table?: 'emails';
36
+ id: bigint;
37
+ organizationId: bigint;
38
+ recipientEmail: string;
39
+ senderEmail: string | null;
40
+ subject: string | null;
41
+ postmarkMessageId: string | null;
42
+ payload: Record<string, any>;
43
+ status: EmailStatusEnum;
44
+ statusSummary: string | null;
45
+ processingStartedAt: Date | null;
46
+ processingCompletedAt: Date | null;
47
+ receivedAt: Date;
48
+ }
49
+
50
+ /**
51
+ * GraphQL inbound email record.
52
+ */
53
+ export interface InboundEmailGQL {
54
+ __deleted?: boolean;
55
+ id: string;
56
+ cursor: string;
57
+ organizationId: string;
58
+ recipientEmail: string;
59
+ senderEmail: string | null;
60
+ subject: string | null;
61
+ postmarkMessageId: string | null;
62
+ status: EmailStatusEnum;
63
+ statusSummary: string | null;
64
+ previewText: string;
65
+ bodyFormat: InboundEmailBodyFormatEnum | null;
66
+ bodyText: string;
67
+ attachments: InboundEmailAttachmentGQL[];
68
+ receivedAt: string;
69
+ processingStartedAt: string | null;
70
+ processingCompletedAt: string | null;
71
+ }