@jsb188/mday 1.1.8 → 1.1.11

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 (123) hide show
  1. package/package.json +105 -35
  2. package/src/constants/agentDoc.ts +12 -0
  3. package/src/constants/agentMemory.ts +154 -0
  4. package/src/constants/aiChat.ts +5 -0
  5. package/src/constants/campaign.ts +127 -0
  6. package/src/constants/dataTable.ts +48 -0
  7. package/src/constants/dataTableFieldTypes.generated.ts +63 -0
  8. package/src/constants/docAccess.ts +32 -0
  9. package/src/constants/email.ts +44 -0
  10. package/src/constants/fieldDoc.ts +34 -0
  11. package/src/constants/graphqlReactivity.ts +113 -0
  12. package/src/constants/inboundContact.ts +8 -0
  13. package/src/constants/integration.ts +13 -0
  14. package/src/constants/log.ts +7 -366
  15. package/src/constants/logActivityGroupColors.generated.ts +19 -0
  16. package/src/constants/logTaxonomy.generated.ts +1103 -0
  17. package/src/constants/noteDoc.ts +77 -0
  18. package/src/constants/organization.ts +18 -11
  19. package/src/constants/pageRoute.ts +23 -0
  20. package/src/constants/schedule.ts +220 -0
  21. package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
  22. package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
  23. package/src/constants/sheet.ts +168 -0
  24. package/src/constants/sheetRegionSources.generated.ts +578 -0
  25. package/src/constants/square.ts +16 -0
  26. package/src/constants/storage.ts +61 -0
  27. package/src/constants/usage.ts +79 -0
  28. package/src/schemas/editLogEntry.ts +1017 -738
  29. package/src/schemas/fieldDocsQuery.ts +12 -0
  30. package/src/schemas/inboundContact.ts +77 -0
  31. package/src/schemas/logsQuery.ts +57 -316
  32. package/src/schemas/organization.ts +53 -213
  33. package/src/types/account.d.ts +81 -0
  34. package/src/types/agentDoc.d.ts +64 -0
  35. package/src/types/agentMemory.d.ts +74 -0
  36. package/src/types/campaign.d.ts +683 -0
  37. package/src/types/dataTable.d.ts +366 -0
  38. package/src/types/docAccess.d.ts +96 -0
  39. package/src/types/email.d.ts +142 -0
  40. package/src/types/fieldDoc.d.ts +273 -0
  41. package/src/types/inboundContact.d.ts +57 -0
  42. package/src/types/integration.d.ts +42 -0
  43. package/src/types/log.d.ts +169 -190
  44. package/src/types/noteDoc.d.ts +86 -0
  45. package/src/types/organization.d.ts +175 -76
  46. package/src/types/pageRoute.d.ts +48 -0
  47. package/src/types/schedule.d.ts +391 -0
  48. package/src/types/sheet.d.ts +1130 -0
  49. package/src/types/storage.d.ts +242 -0
  50. package/src/types/usage.d.ts +106 -0
  51. package/src/types/workflow.d.ts +305 -0
  52. package/src/utils/agentDoc.ts +109 -0
  53. package/src/utils/aiChat.ts +26 -0
  54. package/src/utils/campaign.ts +741 -0
  55. package/src/utils/campaignFormEditor.ts +871 -0
  56. package/src/utils/dataTable.ts +849 -0
  57. package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
  58. package/src/utils/dataTableRealtimeAuthority.ts +209 -0
  59. package/src/utils/dataTableRealtimeSelection.ts +134 -0
  60. package/src/utils/dataTableRowDocument.ts +508 -0
  61. package/src/utils/dataTableSource.ts +230 -0
  62. package/src/utils/docAccess.ts +383 -0
  63. package/src/utils/documentName.ts +53 -0
  64. package/src/utils/email.ts +172 -0
  65. package/src/utils/fieldDoc.ts +113 -0
  66. package/src/utils/log.ts +173 -778
  67. package/src/utils/logRegistryValue.ts +90 -0
  68. package/src/utils/logStoreRead.ts +266 -0
  69. package/src/utils/logTaxonomy.ts +76 -0
  70. package/src/utils/logTaxonomyDisplay.ts +439 -0
  71. package/src/utils/noteDoc.ts +827 -0
  72. package/src/utils/organization.ts +683 -81
  73. package/src/utils/pageRoute.ts +71 -0
  74. package/src/utils/schedule.ts +799 -0
  75. package/src/utils/scheduleEvaluation.ts +1994 -0
  76. package/src/utils/scheduleICS.ts +246 -0
  77. package/src/utils/scheduleRuleTemplates.ts +188 -0
  78. package/src/utils/sheet.ts +4973 -0
  79. package/src/utils/sheetAxisMove.ts +830 -0
  80. package/src/utils/sheetBootstrap.ts +1769 -0
  81. package/src/utils/sheetCommand.ts +423 -0
  82. package/src/utils/sheetExport.ts +238 -0
  83. package/src/utils/sheetFormulaEvaluation.ts +914 -0
  84. package/src/utils/sheetFormulaEvaluator.ts +852 -0
  85. package/src/utils/sheetJournal.ts +78 -0
  86. package/src/utils/sheetNumberFormat.ts +1211 -0
  87. package/src/utils/sheetRegion.ts +374 -0
  88. package/src/utils/sheetRegionFilter.ts +1259 -0
  89. package/src/utils/sheetRegionSourceRegistry.ts +594 -0
  90. package/src/utils/sheetSequence.ts +148 -0
  91. package/src/utils/sheetSnapshot.ts +992 -0
  92. package/src/utils/sheetStructureEdit.ts +1284 -0
  93. package/src/utils/square.ts +32 -0
  94. package/src/utils/storage.ts +152 -0
  95. package/src/utils/table-route.ts +262 -0
  96. package/src/utils/workflow.ts +380 -0
  97. package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
  98. package/tests/docAccess.test.ts +525 -0
  99. package/tests/editLogEntry.test.ts +112 -0
  100. package/tests/noteDoc.test.ts +669 -0
  101. package/tests/schedule.test.ts +693 -0
  102. package/tests/scheduleEvaluation.test.ts +1970 -0
  103. package/tests/scheduleICS.test.ts +208 -0
  104. package/tests/scheduleRuleTemplates.test.ts +176 -0
  105. package/tests/scheduleSweepInvariants.test.ts +428 -0
  106. package/tests/sheetAxisMove.test.ts +343 -0
  107. package/tests/sheetFormulaEvaluator.test.ts +575 -0
  108. package/tests/sheetRegionFilter.test.ts +1135 -0
  109. package/tests/sheetSequence.test.ts +41 -0
  110. package/tests/sheetStructureEdit.test.ts +82 -0
  111. package/tsconfig.json +12 -0
  112. package/vitest.config.ts +8 -0
  113. package/src/constants/log-activityTexts.ts +0 -209
  114. package/src/constants/product.ts +0 -66
  115. package/src/constants/report.ts +0 -25
  116. package/src/schemas/childOrganizationsQuery.ts +0 -44
  117. package/src/schemas/productsQuery.ts +0 -145
  118. package/src/schemas/reportsQuery.ts +0 -107
  119. package/src/types/action.d.ts +0 -42
  120. package/src/types/product.d.ts +0 -173
  121. package/src/types/report.d.ts +0 -203
  122. package/src/utils/product-calEvent.ts +0 -508
  123. package/src/utils/route-helpers.ts +0 -583
@@ -0,0 +1,366 @@
1
+ import type {
2
+ DATA_TABLE_CHANGE_KIND_ENUMS,
3
+ DATA_TABLE_FIELD_TYPE_ENUMS,
4
+ DATA_TABLE_RECORD_RESOLVED_VALUE_KIND_ENUMS,
5
+ DATA_TABLE_RECORD_VALUE_KIND_ENUMS,
6
+ DATA_TABLE_ROW_DOCUMENT_VERSION,
7
+ } from '../constants/dataTable.ts';
8
+
9
+ export type DataTableFieldTypeEnum =
10
+ (typeof DATA_TABLE_FIELD_TYPE_ENUMS)[number];
11
+
12
+ export type DataTableRecordValueKind =
13
+ (typeof DATA_TABLE_RECORD_VALUE_KIND_ENUMS)[number];
14
+
15
+ export type DataTableRecordResolvedValueKind =
16
+ (typeof DATA_TABLE_RECORD_RESOLVED_VALUE_KIND_ENUMS)[number];
17
+
18
+ export type DataTableChangeKind = (typeof DATA_TABLE_CHANGE_KIND_ENUMS)[number];
19
+
20
+ export type DataTableFieldTypeGQL = DataTableFieldTypeEnum;
21
+
22
+ export type DataTableCellReferenceStatus = 'NONE' | 'ACTIVE' | 'DELETED';
23
+
24
+ export interface DataTablesFilterArgs {
25
+ active?: boolean | null;
26
+ }
27
+
28
+ export type DataTableRecordValue =
29
+ | string
30
+ | number
31
+ | boolean
32
+ | null
33
+ | Record<string, any>
34
+ | any[];
35
+
36
+ export interface DataTableDesignCellOptionObj {
37
+ label: string;
38
+ value: string;
39
+ color?: string | null;
40
+ }
41
+
42
+ export interface DataTableDesignCellObj {
43
+ key: string;
44
+ label: string;
45
+ humanLabel?: string | null;
46
+ iconName?: string | null;
47
+ fieldType: DataTableFieldTypeEnum;
48
+ format?: string | null;
49
+ instructions?: string | null;
50
+ source?: {
51
+ path: string;
52
+ table: string;
53
+ } | null;
54
+ options?: DataTableDesignCellOptionObj[];
55
+ openLink?: boolean;
56
+ humansOnly?: boolean;
57
+ humansCannotEdit?: boolean; // If true, humans cannot edit this cell
58
+ hidden?: boolean; // If true, this cell is hidden from the default dataTable grid
59
+ indexed?: boolean;
60
+ width?: number | null;
61
+ }
62
+
63
+ export interface DataTableDesignObj {
64
+ cells: DataTableDesignCellObj[];
65
+ cellsOrder?: string[];
66
+ instructions?: string;
67
+ humansCannotEdit?: boolean; // If true, humans cannot edit any cells in this dataTable
68
+ rowIdentifier?: string[];
69
+ stickyTop?: number;
70
+ stickyLeft?: number;
71
+ }
72
+
73
+ export interface DataTableData {
74
+ __table: 'data_tables';
75
+
76
+ id: number | bigint;
77
+ organizationId: number | bigint;
78
+ name?: string | null;
79
+ title: string;
80
+ description?: string | null;
81
+ design: DataTableDesignObj;
82
+ active: boolean;
83
+ deletedAt?: Date | string | null;
84
+ createdAt: Date;
85
+ updatedAt: Date;
86
+ }
87
+
88
+ export interface DataTableRowData {
89
+ __table: 'data_table_rows';
90
+
91
+ id: number | bigint;
92
+ organizationId: number | bigint;
93
+ dataTableId: number | bigint;
94
+ identifier?: string | null;
95
+ orderKey: number | bigint;
96
+ /* Persisted reads carry DataTableRowDocument; GraphQL hydration exposes the
97
+ * public DataTableRecordData[] facade. */
98
+ cells: DataTableRowDocument | DataTableRecordData[];
99
+ rowRevision: number | bigint;
100
+ metadata: Record<string, any>;
101
+ }
102
+
103
+ export interface DataTableRecordData {
104
+ __table: 'data_table_records';
105
+
106
+ id: number | bigint;
107
+ organizationId: number | bigint;
108
+ dataTableId: number | bigint;
109
+ dataTableRowId: number | bigint;
110
+ columnId: number | bigint;
111
+ cellKey: string;
112
+ valueKind: DataTableRecordValueKind;
113
+ resolvedValueKind?: DataTableRecordResolvedValueKind | null;
114
+ iconName?: string | null;
115
+ value?: DataTableRecordValue;
116
+ textValue?: string | null;
117
+ numberValue?: number | null;
118
+ booleanValue?: boolean | null;
119
+ dateValue?: Date | string | null;
120
+ datetimeValue?: Date | string | null;
121
+ relatedTable?: string | null;
122
+ relatedId?: number | bigint | null;
123
+ referenceDataTableId?: number | bigint | null;
124
+ referenceDataTableRowId?: number | bigint | null;
125
+ referenceColumnId?: number | bigint | null;
126
+ referenceCellKey?: string | null;
127
+ createdAt: Date;
128
+ updatedAt: Date;
129
+ }
130
+
131
+ export type DataTableRowDocumentRecordInput = Pick<
132
+ DataTableRecordData,
133
+ | 'id'
134
+ | 'columnId'
135
+ | 'valueKind'
136
+ | 'resolvedValueKind'
137
+ | 'value'
138
+ | 'textValue'
139
+ | 'numberValue'
140
+ | 'booleanValue'
141
+ | 'dateValue'
142
+ | 'datetimeValue'
143
+ | 'relatedTable'
144
+ | 'relatedId'
145
+ | 'referenceDataTableId'
146
+ | 'referenceDataTableRowId'
147
+ | 'referenceColumnId'
148
+ > &
149
+ Partial<Pick<DataTableRecordData, 'createdAt' | 'updatedAt'>>;
150
+
151
+ export interface DataTableColumnData {
152
+ __table: 'data_table_columns';
153
+
154
+ id: number | bigint;
155
+ organizationId: number | bigint;
156
+ dataTableId: number | bigint;
157
+ key: string;
158
+ fieldType: DataTableFieldTypeEnum;
159
+ ordinal: number;
160
+ config: Record<string, any>;
161
+ version: number | bigint;
162
+ deletedAt?: Date | string | null;
163
+ createdAt: Date;
164
+ updatedAt: Date;
165
+ }
166
+
167
+ export interface DataTableColumnAliasData {
168
+ __table: 'data_table_column_aliases';
169
+
170
+ id: number | bigint;
171
+ organizationId: number | bigint;
172
+ dataTableId: number | bigint;
173
+ dataTableColumnId: number | bigint;
174
+ key: string;
175
+ retiredAt?: Date | string | null;
176
+ createdAt: Date;
177
+ }
178
+
179
+ export interface DataTableStateData {
180
+ __table: 'data_table_state';
181
+
182
+ dataTableId: number | bigint;
183
+ organizationId: number | bigint;
184
+ currentSeq: number | bigint;
185
+ lastOrderKey: number | bigint;
186
+ createdAt: Date;
187
+ updatedAt: Date;
188
+ }
189
+
190
+ export interface DataTableChangeData {
191
+ __table: 'data_table_changes';
192
+
193
+ dataTableId: number | bigint;
194
+ seq: number | bigint;
195
+ organizationId: number | bigint;
196
+ kind: DataTableChangeKind;
197
+ payload: Record<string, any>;
198
+ actorAccountId?: number | bigint | null;
199
+ sourceSocketId?: string | null;
200
+ commandId?: string | null;
201
+ correlationId?: string | null;
202
+ causationId?: string | null;
203
+ createdAt: Date;
204
+ }
205
+
206
+ export interface DataTableRowDocumentRelatedValue {
207
+ table: string;
208
+ id: string;
209
+ }
210
+
211
+ export interface DataTableRowDocumentReferenceValue {
212
+ dataTableId: string;
213
+ dataTableRowId: string | null;
214
+ columnId: string;
215
+ status: 'ACTIVE' | 'DELETED';
216
+ }
217
+
218
+ export interface DataTableRowDocumentCell {
219
+ recordId: string;
220
+ valueKind: DataTableRecordValueKind;
221
+ resolvedValueKind?: DataTableRecordResolvedValueKind;
222
+ value: DataTableRecordValue;
223
+ textValue?: string;
224
+ numberValue?: number;
225
+ booleanValue?: boolean;
226
+ dateValue?: string;
227
+ datetimeValue?: string;
228
+ createdAt?: string;
229
+ updatedAt?: string;
230
+ related?: DataTableRowDocumentRelatedValue;
231
+ reference?: DataTableRowDocumentReferenceValue;
232
+ }
233
+
234
+ /*
235
+ * Versioned render projection. byColumnId is keyed by decimal-string stable
236
+ * data_table_columns IDs so JSON never rounds a BIGINT through JavaScript.
237
+ * data_table_records remains the normalized typed query projection.
238
+ */
239
+ export interface DataTableRowDocument {
240
+ v: typeof DATA_TABLE_ROW_DOCUMENT_VERSION;
241
+ byColumnId: Record<string, DataTableRowDocumentCell>;
242
+ }
243
+
244
+ export interface DataTableCellReferenceGQL {
245
+ dataTableId?: string | null;
246
+ dataTableRowId?: string | null;
247
+ cellKey?: string | null;
248
+ }
249
+
250
+ export interface DataTableDesignCellOptionGQL {
251
+ label: string;
252
+ value: string;
253
+ color?: string | null;
254
+ }
255
+
256
+ export interface DataTableDesignCellSourceGQL {
257
+ path: string;
258
+ table: string;
259
+ }
260
+
261
+ export interface DataTableDesignCellGQL {
262
+ key: string;
263
+ label: string;
264
+ humanLabel?: string | null;
265
+ iconName?: string | null;
266
+ fieldType: DataTableFieldTypeGQL;
267
+ format?: string | null;
268
+ instructions?: string | null;
269
+ source?: DataTableDesignCellSourceGQL | null;
270
+ options?: DataTableDesignCellOptionGQL[];
271
+ openLink?: boolean | null;
272
+ humansOnly?: boolean | null;
273
+ humansCannotEdit?: boolean | null;
274
+ hidden?: boolean | null;
275
+ indexed?: boolean | null;
276
+ width?: number | null;
277
+ }
278
+
279
+ export interface DataTableDesignGQL {
280
+ id: string;
281
+ cells: DataTableDesignCellGQL[];
282
+ cellsOrder: string[];
283
+ instructions?: string | null;
284
+ humansCannotEdit?: boolean | null;
285
+ rowIdentifier?: string[] | null;
286
+ stickyTop?: number | null;
287
+ stickyLeft?: number | null;
288
+ }
289
+
290
+ export interface DataTableGQL {
291
+ __deleted?: boolean;
292
+
293
+ id: string;
294
+ cursor?: string | null;
295
+ organizationId: string;
296
+ realtimeToken?: string | null;
297
+
298
+ name: string;
299
+ title: string;
300
+ description?: string | null;
301
+ design: DataTableDesignGQL;
302
+ active: boolean;
303
+ deletedAt?: string | null;
304
+
305
+ createdAt: string;
306
+ updatedAt: string;
307
+ }
308
+
309
+ export interface DataTableRowGQL {
310
+ __deleted?: boolean;
311
+
312
+ id: string;
313
+ cursor: string;
314
+ organizationId: string;
315
+ dataTableId?: string | null;
316
+
317
+ identifier?: string | null;
318
+ metadata: string;
319
+ cells?: DataTableCellGQL[];
320
+ updatedAt?: string | null;
321
+ }
322
+
323
+ export interface DataTableRowsForSheetRegionColumnGQL {
324
+ formulaText?: string | null;
325
+ kind?: string | null;
326
+ sheetColumnIndex?: number | null;
327
+ sourceCellKey?: string | null;
328
+ }
329
+
330
+ export interface DataTableRowsForSheetRegionRowGQL {
331
+ row?: DataTableRowGQL | null;
332
+ sheetRowIndex?: number | null;
333
+ }
334
+
335
+ export interface DataTableRowsForSheetRegionGQL {
336
+ columns?: DataTableRowsForSheetRegionColumnGQL[] | null;
337
+ dataTableId?: string | null;
338
+ regionId?: string | null;
339
+ rows?: DataTableRowsForSheetRegionRowGQL[] | null;
340
+ sourceId?: string | null;
341
+ sourceType?: string | null;
342
+ }
343
+
344
+ export interface DataTableCellGQL {
345
+ __deleted?: boolean;
346
+
347
+ id: string;
348
+ dataTableId?: string | null;
349
+ dataTableRowId?: string | null;
350
+
351
+ cellKey: string;
352
+ iconName?: string | null;
353
+ value?: string | null;
354
+ textValue?: string | null;
355
+ numberValue?: number | null;
356
+ booleanValue?: boolean | null;
357
+ dateValue?: string | null;
358
+ datetimeValue?: string | null;
359
+ relatedTable?: string | null;
360
+ relatedId?: string | null;
361
+ reference?: DataTableCellReferenceGQL | null;
362
+ referenceStatus?: DataTableCellReferenceStatus | null;
363
+
364
+ createdAt: string;
365
+ updatedAt: string;
366
+ }
@@ -0,0 +1,96 @@
1
+ import type {
2
+ DOC_ACCESS_ENTITY_TYPE_ENUMS,
3
+ DOC_ACCESS_GRANTEE_TYPE_ENUMS,
4
+ DOC_ACCESS_SCOPE_ENUMS,
5
+ DOC_GRANT_PERMISSION_ENUMS,
6
+ DOC_PERMISSION_ENUMS,
7
+ } from '../constants/docAccess.ts';
8
+
9
+ export type DocPermissionEnum = (typeof DOC_PERMISSION_ENUMS)[number];
10
+ export type DocGrantPermissionEnum =
11
+ (typeof DOC_GRANT_PERMISSION_ENUMS)[number];
12
+ export type DocAccessGranteeTypeEnum =
13
+ (typeof DOC_ACCESS_GRANTEE_TYPE_ENUMS)[number];
14
+ export type DocAccessEntityTypeEnum =
15
+ (typeof DOC_ACCESS_ENTITY_TYPE_ENUMS)[number];
16
+ export type DocAccessScopeEnum = (typeof DOC_ACCESS_SCOPE_ENUMS)[number];
17
+
18
+ /**
19
+ * Base access policy stored on the document row itself (jsonb "access"):
20
+ * - team: what every owner-org member gets ("NONE" restricts the document
21
+ * to grant holders and owner-org members with the document edit ACL)
22
+ * - public: what everyone with the link gets
23
+ * - network: what every member of the owner org's network (child)
24
+ * organizations gets
25
+ */
26
+
27
+ export interface DocAccessBaseObj {
28
+ team: DocPermissionEnum;
29
+ public: DocPermissionEnum;
30
+ network: DocPermissionEnum;
31
+ }
32
+
33
+ /**
34
+ * One access grant for one account or one organization. A grant overrides
35
+ * the base policy for its grantee (ACCOUNT grants override the team rule,
36
+ * ORGANIZATION grants override the network rule), so it can raise or lower
37
+ * access, including an explicit "NONE" block. Grants are stored relationally
38
+ * in access_grants; ids are serialized GenericIDs on the client and parsed
39
+ * numeric ids in server storage.
40
+ */
41
+
42
+ export interface DocAccessGrantObj {
43
+ granteeType: DocAccessGranteeTypeEnum;
44
+ granteeId: string | number | bigint;
45
+ permission: DocGrantPermissionEnum;
46
+ }
47
+
48
+ /**
49
+ * Full access settings for one document: the base policy plus the grants
50
+ * list. Fetch paths that skip the grants table leave "grants" undefined.
51
+ */
52
+
53
+ export interface DocAccessObj extends DocAccessBaseObj {
54
+ grants?: DocAccessGrantObj[] | null;
55
+ }
56
+
57
+ /**
58
+ * Viewer facts needed to evaluate one document's access settings.
59
+ * - isOwnerOrgMember: viewer passes the owner org's "general_read" ACL
60
+ * - isAdminOrOwner: viewer's role in the owner org is ADMIN or OWNER
61
+ * (admins and owners always keep full view and edit access)
62
+ * - hasWriteACL: viewer passes the owner org's "general_write" ACL; the
63
+ * team policy only grants EDIT to members who can write org data
64
+ * (read-only members cap at VIEW unless an explicit grant raises them)
65
+ * - isNetworkOrgMember: viewer belongs to one of the owner org's network
66
+ * (child) organizations
67
+ * - viewerOrganizationIds: every organization the viewer belongs to
68
+ */
69
+
70
+ export interface DocAccessViewerCtx {
71
+ accountId?: string | number | bigint | null;
72
+ isOwnerOrgMember?: boolean | null;
73
+ isAdminOrOwner?: boolean | null;
74
+ hasWriteACL?: boolean | null;
75
+ isNetworkOrgMember?: boolean | null;
76
+ viewerOrganizationIds?: Array<string | number | bigint> | null;
77
+ }
78
+
79
+ /**
80
+ * One access_grants database row.
81
+ */
82
+
83
+ export interface DocAccessGrantData {
84
+ __table: 'access_grants';
85
+
86
+ id: number | bigint;
87
+ organizationId: number | bigint;
88
+ entityType: DocAccessEntityTypeEnum;
89
+ entityId: number | bigint;
90
+ granteeType: DocAccessGranteeTypeEnum;
91
+ granteeAccountId?: number | bigint | null;
92
+ granteeOrganizationId?: number | bigint | null;
93
+ permission: DocGrantPermissionEnum;
94
+ createdAt: Date;
95
+ updatedAt: Date;
96
+ }
@@ -0,0 +1,142 @@
1
+ import type {
2
+ EMAIL_STATUS_ENUMS,
3
+ INBOUND_EMAIL_BODY_FORMAT_ENUMS,
4
+ INBOUND_EMAIL_SORT_ENUMS,
5
+ OUTBOUND_EMAIL_SORT_ENUMS,
6
+ OUTBOUND_EMAIL_STATUS_ENUMS,
7
+ } from '../constants/email.ts';
8
+ import type { StorageGQL } from './storage.d.ts';
9
+
10
+ /**
11
+ * Email handling lifecycle status.
12
+ */
13
+ export type EmailStatusEnum = (typeof EMAIL_STATUS_ENUMS)[number];
14
+
15
+ /**
16
+ * Inbound email list sort.
17
+ */
18
+ export type InboundEmailsSortEnum = (typeof INBOUND_EMAIL_SORT_ENUMS)[number];
19
+
20
+ /**
21
+ * Outbound email delivery status.
22
+ */
23
+ export type OutboundEmailStatusEnum =
24
+ (typeof OUTBOUND_EMAIL_STATUS_ENUMS)[number];
25
+
26
+ /**
27
+ * Outbound email list sort.
28
+ */
29
+ export type OutboundEmailsSortEnum = (typeof OUTBOUND_EMAIL_SORT_ENUMS)[number];
30
+
31
+ /**
32
+ * Inbound email display body source.
33
+ */
34
+ export type InboundEmailBodyFormatEnum =
35
+ (typeof INBOUND_EMAIL_BODY_FORMAT_ENUMS)[number];
36
+
37
+ /**
38
+ * Saved inbound email database row.
39
+ */
40
+ export interface InboundEmailData {
41
+ __table?: 'emails_inbound';
42
+ id: bigint;
43
+ organizationId: bigint;
44
+ sourceOutboundEmailId: bigint | null;
45
+ recipientEmail: string;
46
+ senderEmail: string | null;
47
+ subject: string | null;
48
+ postmarkMessageId: string | null;
49
+ payload: Record<string, any>;
50
+ status: EmailStatusEnum;
51
+ statusSummary: string | null;
52
+ processingLeaseId: string | null;
53
+ processingStartedAt: Date | null;
54
+ processingCompletedAt: Date | null;
55
+ receivedAt: Date;
56
+ }
57
+
58
+ /**
59
+ * GraphQL inbound email record.
60
+ */
61
+ export interface InboundEmailGQL {
62
+ __deleted?: boolean;
63
+ id: string;
64
+ cursor: string;
65
+ organizationId: string;
66
+ recipientEmail: string;
67
+ senderEmail: string | null;
68
+ subject: string | null;
69
+ postmarkMessageId: string | null;
70
+ status: EmailStatusEnum;
71
+ statusSummary: string | null;
72
+ previewText: string;
73
+ bodyFormat: InboundEmailBodyFormatEnum | null;
74
+ bodyText: string;
75
+ receivedAt: string;
76
+ processingStartedAt: string | null;
77
+ processingCompletedAt: string | null;
78
+ }
79
+
80
+ /**
81
+ * Saved outbound email database row.
82
+ */
83
+ export interface OutboundEmailData {
84
+ __table?: 'emails_outbound';
85
+ id: bigint;
86
+ organizationId: bigint;
87
+ campaignTemplateId: bigint | null;
88
+ campaignId: bigint | null;
89
+ campaignRecipientId: bigint | null;
90
+ sendBatchId: string | null;
91
+ replyToken: string | null;
92
+ sourceInboundEmailId: bigint | null;
93
+ idempotencyKey: string;
94
+ toEmail: string;
95
+ replyToEmail: string | null;
96
+ replyToName: string | null;
97
+ subject: string;
98
+ body: string;
99
+ bodyHTML: string | null;
100
+ replyHeaders: { Name: string; Value: string }[] | null;
101
+ status: OutboundEmailStatusEnum;
102
+ postmarkMessageId: string | null;
103
+ errorMessage: string | null;
104
+ sentAt: Date | null;
105
+ deliveredAt: Date | null;
106
+ firstOpenedAt: Date | null;
107
+ bouncedAt: Date | null;
108
+ bounceType: string | null;
109
+ spamComplaintAt: Date | null;
110
+ spamScore: number | null;
111
+ broadcast: boolean;
112
+ createdAt: Date;
113
+ updatedAt: Date;
114
+ relatedLogIds?: Array<number | bigint>;
115
+ files?: StorageGQL[];
116
+ }
117
+
118
+ /**
119
+ * GraphQL outbound email record.
120
+ */
121
+ export interface OutboundEmailGQL {
122
+ __deleted?: boolean;
123
+ id: string;
124
+ cursor: string;
125
+ organizationId: string;
126
+ sourceInboundEmailId: string | null;
127
+ toEmail: string;
128
+ replyToEmail: string | null;
129
+ replyToName: string | null;
130
+ subject: string;
131
+ body: string;
132
+ status: OutboundEmailStatusEnum;
133
+ postmarkMessageId: string | null;
134
+ errorMessage: string | null;
135
+ sentAt: string | null;
136
+ bouncedAt: string | null;
137
+ broadcast: boolean;
138
+ createdAt: string;
139
+ updatedAt: string;
140
+ relatedLogIds: string[];
141
+ files: StorageGQL[];
142
+ }