@jsb188/mday 1.1.10 → 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 (119) hide show
  1. package/package.json +105 -54
  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 +35 -9
  7. package/src/constants/dataTableFieldTypes.generated.ts +63 -0
  8. package/src/constants/docAccess.ts +32 -0
  9. package/src/constants/email.ts +20 -4
  10. package/src/constants/fieldDoc.ts +34 -0
  11. package/src/constants/graphqlReactivity.ts +113 -0
  12. package/src/constants/integration.ts +8 -9
  13. package/src/constants/log.ts +7 -410
  14. package/src/constants/logActivityGroupColors.generated.ts +19 -0
  15. package/src/constants/logTaxonomy.generated.ts +1103 -0
  16. package/src/constants/noteDoc.ts +77 -0
  17. package/src/constants/organization.ts +13 -15
  18. package/src/constants/pageRoute.ts +23 -0
  19. package/src/constants/schedule.ts +220 -0
  20. package/src/constants/scheduleRuleTemplateSeed.ts +138 -0
  21. package/src/constants/scheduleRuleTemplates.generated.ts +145 -0
  22. package/src/constants/sheet.ts +154 -6
  23. package/src/constants/sheetRegionSources.generated.ts +578 -0
  24. package/src/constants/square.ts +6 -6
  25. package/src/constants/storage.ts +56 -7
  26. package/src/constants/usage.ts +79 -0
  27. package/src/schemas/editLogEntry.ts +1010 -777
  28. package/src/schemas/fieldDocsQuery.ts +12 -0
  29. package/src/schemas/inboundContact.ts +60 -55
  30. package/src/schemas/logsQuery.ts +55 -49
  31. package/src/schemas/organization.ts +49 -46
  32. package/src/types/account.d.ts +4 -1
  33. package/src/types/agentDoc.d.ts +64 -0
  34. package/src/types/agentMemory.d.ts +74 -0
  35. package/src/types/campaign.d.ts +683 -0
  36. package/src/types/dataTable.d.ts +175 -256
  37. package/src/types/docAccess.d.ts +96 -0
  38. package/src/types/email.d.ts +83 -12
  39. package/src/types/fieldDoc.d.ts +273 -0
  40. package/src/types/inboundContact.d.ts +2 -1
  41. package/src/types/log.d.ts +209 -341
  42. package/src/types/noteDoc.d.ts +86 -0
  43. package/src/types/organization.d.ts +83 -40
  44. package/src/types/pageRoute.d.ts +48 -0
  45. package/src/types/schedule.d.ts +391 -0
  46. package/src/types/sheet.d.ts +862 -30
  47. package/src/types/storage.d.ts +206 -125
  48. package/src/types/usage.d.ts +106 -0
  49. package/src/types/workflow.d.ts +149 -18
  50. package/src/utils/agentDoc.ts +109 -0
  51. package/src/utils/aiChat.ts +26 -0
  52. package/src/utils/campaign.ts +741 -0
  53. package/src/utils/campaignFormEditor.ts +871 -0
  54. package/src/utils/dataTable.ts +425 -410
  55. package/src/utils/dataTableFieldTypeRegistry.ts +105 -0
  56. package/src/utils/dataTableRealtimeAuthority.ts +209 -0
  57. package/src/utils/dataTableRealtimeSelection.ts +134 -0
  58. package/src/utils/dataTableRowDocument.ts +508 -0
  59. package/src/utils/dataTableSource.ts +230 -0
  60. package/src/utils/docAccess.ts +383 -0
  61. package/src/utils/documentName.ts +53 -0
  62. package/src/utils/email.ts +112 -53
  63. package/src/utils/fieldDoc.ts +113 -0
  64. package/src/utils/log.ts +169 -176
  65. package/src/utils/logRegistryValue.ts +90 -0
  66. package/src/utils/logStoreRead.ts +266 -0
  67. package/src/utils/logTaxonomy.ts +76 -0
  68. package/src/utils/logTaxonomyDisplay.ts +439 -0
  69. package/src/utils/noteDoc.ts +827 -0
  70. package/src/utils/organization.ts +510 -91
  71. package/src/utils/pageRoute.ts +71 -0
  72. package/src/utils/schedule.ts +799 -0
  73. package/src/utils/scheduleEvaluation.ts +1994 -0
  74. package/src/utils/scheduleICS.ts +246 -0
  75. package/src/utils/scheduleRuleTemplates.ts +188 -0
  76. package/src/utils/sheet.ts +4842 -39
  77. package/src/utils/sheetAxisMove.ts +830 -0
  78. package/src/utils/sheetBootstrap.ts +1769 -0
  79. package/src/utils/sheetCommand.ts +423 -0
  80. package/src/utils/sheetExport.ts +238 -0
  81. package/src/utils/sheetFormulaEvaluation.ts +914 -0
  82. package/src/utils/sheetFormulaEvaluator.ts +852 -0
  83. package/src/utils/sheetJournal.ts +78 -0
  84. package/src/utils/sheetNumberFormat.ts +1211 -0
  85. package/src/utils/sheetRegion.ts +374 -0
  86. package/src/utils/sheetRegionFilter.ts +1259 -0
  87. package/src/utils/sheetRegionSourceRegistry.ts +594 -0
  88. package/src/utils/sheetSequence.ts +148 -0
  89. package/src/utils/sheetSnapshot.ts +992 -0
  90. package/src/utils/sheetStructureEdit.ts +1284 -0
  91. package/src/utils/square.ts +22 -12
  92. package/src/utils/storage.ts +152 -0
  93. package/src/utils/table-route.ts +127 -11
  94. package/src/utils/workflow.ts +191 -23
  95. package/tests/dataTableFieldTypeRegistry.test.ts +110 -0
  96. package/tests/docAccess.test.ts +525 -0
  97. package/tests/editLogEntry.test.ts +112 -0
  98. package/tests/noteDoc.test.ts +669 -0
  99. package/tests/schedule.test.ts +693 -0
  100. package/tests/scheduleEvaluation.test.ts +1970 -0
  101. package/tests/scheduleICS.test.ts +208 -0
  102. package/tests/scheduleRuleTemplates.test.ts +176 -0
  103. package/tests/scheduleSweepInvariants.test.ts +428 -0
  104. package/tests/sheetAxisMove.test.ts +343 -0
  105. package/tests/sheetFormulaEvaluator.test.ts +575 -0
  106. package/tests/sheetRegionFilter.test.ts +1135 -0
  107. package/tests/sheetSequence.test.ts +41 -0
  108. package/tests/sheetStructureEdit.test.ts +82 -0
  109. package/tsconfig.json +10 -10
  110. package/vitest.config.ts +8 -0
  111. package/src/constants/log-activityTexts.ts +0 -235
  112. package/src/constants/product.ts +0 -42
  113. package/src/constants/report.ts +0 -44
  114. package/src/schemas/productsQuery.ts +0 -53
  115. package/src/schemas/reportsQuery.ts +0 -20
  116. package/src/types/product.d.ts +0 -84
  117. package/src/types/report.d.ts +0 -290
  118. package/src/utils/product-calEvent.ts +0 -455
  119. package/src/utils/report.ts +0 -158
@@ -2,39 +2,46 @@ import type {
2
2
  EMAIL_STATUS_ENUMS,
3
3
  INBOUND_EMAIL_BODY_FORMAT_ENUMS,
4
4
  INBOUND_EMAIL_SORT_ENUMS,
5
+ OUTBOUND_EMAIL_SORT_ENUMS,
6
+ OUTBOUND_EMAIL_STATUS_ENUMS,
5
7
  } from '../constants/email.ts';
8
+ import type { StorageGQL } from './storage.d.ts';
6
9
 
7
10
  /**
8
11
  * Email handling lifecycle status.
9
12
  */
10
- export type EmailStatusEnum = typeof EMAIL_STATUS_ENUMS[number];
13
+ export type EmailStatusEnum = (typeof EMAIL_STATUS_ENUMS)[number];
11
14
 
12
15
  /**
13
16
  * Inbound email list sort.
14
17
  */
15
- export type InboundEmailsSortEnum = typeof INBOUND_EMAIL_SORT_ENUMS[number];
18
+ export type InboundEmailsSortEnum = (typeof INBOUND_EMAIL_SORT_ENUMS)[number];
16
19
 
17
20
  /**
18
- * Inbound email display body source.
21
+ * Outbound email delivery status.
19
22
  */
20
- export type InboundEmailBodyFormatEnum = typeof INBOUND_EMAIL_BODY_FORMAT_ENUMS[number];
23
+ export type OutboundEmailStatusEnum =
24
+ (typeof OUTBOUND_EMAIL_STATUS_ENUMS)[number];
21
25
 
22
26
  /**
23
- * Safe attachment metadata from one inbound email payload.
27
+ * Outbound email list sort.
24
28
  */
25
- export interface InboundEmailAttachmentGQL {
26
- name: string | null;
27
- contentType: string | null;
28
- contentLength: number | null;
29
- }
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];
30
36
 
31
37
  /**
32
38
  * Saved inbound email database row.
33
39
  */
34
40
  export interface InboundEmailData {
35
- __table?: 'emails';
41
+ __table?: 'emails_inbound';
36
42
  id: bigint;
37
43
  organizationId: bigint;
44
+ sourceOutboundEmailId: bigint | null;
38
45
  recipientEmail: string;
39
46
  senderEmail: string | null;
40
47
  subject: string | null;
@@ -42,6 +49,7 @@ export interface InboundEmailData {
42
49
  payload: Record<string, any>;
43
50
  status: EmailStatusEnum;
44
51
  statusSummary: string | null;
52
+ processingLeaseId: string | null;
45
53
  processingStartedAt: Date | null;
46
54
  processingCompletedAt: Date | null;
47
55
  receivedAt: Date;
@@ -64,8 +72,71 @@ export interface InboundEmailGQL {
64
72
  previewText: string;
65
73
  bodyFormat: InboundEmailBodyFormatEnum | null;
66
74
  bodyText: string;
67
- attachments: InboundEmailAttachmentGQL[];
68
75
  receivedAt: string;
69
76
  processingStartedAt: string | null;
70
77
  processingCompletedAt: string | null;
71
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
+ }
@@ -0,0 +1,273 @@
1
+ import {
2
+ FIELD_DOC_ELEMENT_KINDS,
3
+ FIELD_DOC_FREQUENCY_ENUMS,
4
+ FIELD_DOC_SORT_OPTS,
5
+ FIELD_DOC_STATUS_ENUMS,
6
+ } from '../constants/fieldDoc.ts';
7
+ import type {
8
+ OrganizationData,
9
+ OrganizationSiteData,
10
+ } from './organization.d.ts';
11
+ import type { StorageData, StorageGQL } from './storage.d.ts';
12
+
13
+ /**
14
+ * Enums
15
+ */
16
+
17
+ export type FieldDocElementKindEnum = (typeof FIELD_DOC_ELEMENT_KINDS)[number];
18
+ export type FieldDocsSortEnum = (typeof FIELD_DOC_SORT_OPTS)[number];
19
+ export type FieldDocFrequencyEnum = (typeof FIELD_DOC_FREQUENCY_ENUMS)[number];
20
+ export type FieldDocSubmissionStatusEnum =
21
+ (typeof FIELD_DOC_STATUS_ENUMS)[number];
22
+
23
+ /**
24
+ * Filters
25
+ */
26
+
27
+ export interface FieldDocsFilterArgs {
28
+ preset?: '?' | null;
29
+ fieldDocGroupId?: string | null;
30
+ startPeriod?: string | null; // YYYY-MM-DD
31
+ endPeriod?: string | null; // YYYY-MM-DD
32
+ }
33
+
34
+ /**
35
+ * FieldDoc; elements (the field_doc_elements table)
36
+ */
37
+
38
+ export interface FieldDocFieldsVariables {
39
+ month?: number; // Used for {{month}} template expressions
40
+ [key: string]: any;
41
+ }
42
+
43
+ // Sparse behavior flags; absent means false
44
+ export interface FieldDocElementSettingsObj {
45
+ confirmationNeeded?: boolean; // AI must confirm the answer with the user before saving
46
+ allowCorrectiveActions?: boolean; // AI Agents may record corrective actions for this question
47
+ allowMultipleAnswers?: boolean;
48
+ doNotAllowNotes?: boolean; // If true, AI/respondents will NOT leave notes for this question
49
+ }
50
+
51
+ export interface FieldDocElementData {
52
+ __table: 'field_doc_elements';
53
+ id: number | bigint;
54
+ fieldDocId: number | bigint;
55
+ parentId?: number | bigint | null; // NULL for SECTION elements
56
+ kind: FieldDocElementKindEnum;
57
+ key: string; // Answers reference this key; unique per fieldDoc
58
+ order: number;
59
+ label?: string | null; // Question label / title text / section title
60
+ description?: string | null;
61
+ hint?: string | null; // Additional AI answering guidance
62
+ options?: string[] | null; // If set, answers *must* be one of these options
63
+ required?: boolean; // Public web forms: submission is blocked until answered
64
+ settings?: FieldDocElementSettingsObj | null;
65
+ storageRels?: FieldDocElementStorageRelData[]; // Element images
66
+ }
67
+
68
+ export interface FieldDocElementStorageRelData {
69
+ __table: 'field_doc_element_storage_rels';
70
+ fieldDocElementId: number | bigint;
71
+ storageId: number | bigint;
72
+ order: number;
73
+ file: StorageData;
74
+ }
75
+
76
+ // One hydrated top-level section with its ordered child elements
77
+ export interface FieldDocSectionWithElementsObj extends FieldDocElementData {
78
+ elements: FieldDocElementData[];
79
+ }
80
+
81
+ // The full resolved definition of one fieldDoc (replaces the old fields JSONB)
82
+ export interface FieldDocDefinitionObj {
83
+ sections: FieldDocSectionWithElementsObj[];
84
+ aside?: FieldDocFieldsAsideBlock[]; // From field_doc_templates.fields
85
+ variables: FieldDocFieldsVariables; // Runtime-injected (org name, timezone, etc.)
86
+ }
87
+
88
+ /**
89
+ * FieldDoc; template fields (field_doc_templates.fields JSONB)
90
+ */
91
+
92
+ export interface FieldDocTemplateFieldsObj {
93
+ aside?: FieldDocFieldsAsideBlock[];
94
+ variables?: FieldDocFieldsVariables;
95
+ }
96
+
97
+ export interface FieldDocFieldsAsideBlock {
98
+ title: string;
99
+ nullText?: string;
100
+ items: FieldDocFieldsAsideItem[];
101
+ }
102
+
103
+ export interface FieldDocFieldsAsideItem {
104
+ className?: string;
105
+ label: string;
106
+ text: string;
107
+ }
108
+
109
+ /**
110
+ * FieldDoc; GraphQL element shapes (definition + resolved answer projection)
111
+ */
112
+
113
+ export interface FieldDocElementGQL {
114
+ id: string; // Realtime fragment data ID for question elements; cursor otherwise
115
+ key: string;
116
+ kind: FieldDocElementKindEnum;
117
+ label?: string | null;
118
+ description?: string | null;
119
+ options?: string[] | null;
120
+ required?: boolean;
121
+ allowMultipleAnswers?: boolean;
122
+ doNotAllowNotes?: boolean;
123
+
124
+ // Resolved answer projection (from field_doc_submissions.answers)
125
+ text?: string | null; // The saved answer value
126
+ note?: string | null;
127
+ warningNote?: string | null;
128
+ referenceIds?: string[] | null;
129
+ lineNumber?: string | null;
130
+
131
+ files?: StorageGQL[]; // Element images
132
+ }
133
+
134
+ export interface FieldDocGroupLayoutObj {
135
+ columns: string[];
136
+ headers: string[];
137
+ gridLayoutStyle: string;
138
+ }
139
+
140
+ /**
141
+ * FieldDoc data
142
+ */
143
+
144
+ export interface FieldDocGroupData {
145
+ __table: 'field_doc_groups';
146
+ id: number;
147
+ name: string;
148
+ shortName?: string | null;
149
+ layout?: Partial<FieldDocGroupLayoutObj> | null;
150
+ }
151
+
152
+ export interface FieldDocData {
153
+ __table: 'field_docs';
154
+
155
+ id: number;
156
+ fieldDocTemplateId?: number | null;
157
+ fieldDocGroupId: number;
158
+ fieldDocGroup?: FieldDocGroupData | null;
159
+ documentName: string;
160
+ title: string;
161
+ description: string;
162
+ agentHint?: string | null;
163
+ frequency: FieldDocFrequencyEnum;
164
+ order: number;
165
+
166
+ elements?: FieldDocElementData[]; // Attached by attachFieldDocElements() after fetching
167
+ submission?: FieldDocSubmissionData | null; // Present when field_doc_submissions was joined onto the fieldDoc row.
168
+
169
+ template?: {
170
+ __table: 'field_doc_templates';
171
+ id: number;
172
+ fields: FieldDocTemplateFieldsObj;
173
+ description: string | null;
174
+ };
175
+
176
+ site?: Pick<OrganizationSiteData, 'id' | 'name'> | null;
177
+ childOrg?: OrganizationData;
178
+ organization?: OrganizationData;
179
+ }
180
+
181
+ export interface FieldDocGQL {
182
+ __deleted?: boolean;
183
+
184
+ id: string;
185
+ organizationId: string;
186
+ documentName: string;
187
+ title: string;
188
+ description: string;
189
+ agentHint?: string | null;
190
+ frequency?: FieldDocFrequencyEnum | null;
191
+ fieldDocGroupId: string;
192
+ groupName: string;
193
+ groupShortName?: string | null;
194
+ period: string; // YYYY-MM-DD
195
+ summary?: string | null;
196
+ submission?: FieldDocSubmissionGQL | null;
197
+
198
+ aside?: FieldDocFieldsAsideBlock[];
199
+ sections?: FieldDocSectionGQL[];
200
+ }
201
+
202
+ export interface FieldDocSectionGQL {
203
+ id: string;
204
+ key?: string | null;
205
+ title?: string | null;
206
+ description?: string | null;
207
+ elements?: FieldDocElementGQL[];
208
+ }
209
+
210
+ export interface FieldDocSubmissionGQL {
211
+ __deleted?: boolean;
212
+
213
+ id: string;
214
+ fieldDocSubmissionId: string;
215
+ fieldDocId: string;
216
+ value?: string | null;
217
+ frequency: FieldDocFrequencyEnum;
218
+ fieldDocSubmissionIdEnc?: string | null;
219
+ organizationId: string;
220
+ organizationIdEnc?: string | null;
221
+ location?: string | null;
222
+ childOrgId: string | null;
223
+ childOrgIdEnc?: string | null;
224
+ childOrgName: string | null;
225
+ childOrgOperation: string | null;
226
+ organizationName?: string | null;
227
+ organizationOperation?: string | null;
228
+ fieldDocGroupId: string;
229
+ groupName: string;
230
+ groupShortName?: string | null;
231
+ period: string; // YYYY-MM-DD
232
+ status: FieldDocSubmissionStatusEnum | null;
233
+ activityAt: string | null; // ISO date string
234
+ createdAt: string | null; // ISO date string
235
+ updatedAt: string | null; // ISO date string
236
+ }
237
+
238
+ export interface FieldDocSubmissionData {
239
+ __table: 'field_doc_submissions';
240
+ id: number;
241
+ childOrgId?: number | bigint | null;
242
+ siteId?: number | bigint | null;
243
+ value?: string | null;
244
+ fieldDoc?: Pick<FieldDocData, 'id' | 'frequency'> | null;
245
+ site?: Pick<OrganizationSiteData, 'id' | 'name'> | null;
246
+ childOrg?: OrganizationData;
247
+ organization?: OrganizationData;
248
+ organizationId: number;
249
+ fieldDocId: number;
250
+ period: Date; // YYYY-MM-DD in database, Date object in server via ORM
251
+ answers: Record<string, any>; // key-value pairs of answers
252
+ status?: FieldDocSubmissionStatusEnum | null;
253
+ activityAt: Date;
254
+ createdAt: Date;
255
+ updatedAt: Date;
256
+ }
257
+
258
+ /**
259
+ * Reusable FieldDoc public-form and email templates
260
+ */
261
+
262
+ /**
263
+ * FieldDoc groups
264
+ */
265
+
266
+ export interface FieldDocGroupGQL {
267
+ id: string;
268
+ name: string;
269
+ shortName?: string | null;
270
+ layout?: Partial<FieldDocGroupLayoutObj> | null;
271
+ lastSubmissionPeriod?: string | null; // YYYY-MM-DD
272
+ lastSubmissionFieldDocId?: string | null;
273
+ }
@@ -1,7 +1,8 @@
1
1
  import type { OrganizationData } from './organization.d.ts';
2
2
  import type { INBOUND_CONTACT_SORT_ENUMS } from '../constants/inboundContact.ts';
3
3
 
4
- export type InboundContactsSortEnum = typeof INBOUND_CONTACT_SORT_ENUMS[number];
4
+ export type InboundContactsSortEnum =
5
+ (typeof INBOUND_CONTACT_SORT_ENUMS)[number];
5
6
 
6
7
  /**
7
8
  * Inbound contact relationship to one organization.