@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,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
+ }
@@ -0,0 +1,57 @@
1
+ import type { OrganizationData } from './organization.d.ts';
2
+ import type { INBOUND_CONTACT_SORT_ENUMS } from '../constants/inboundContact.ts';
3
+
4
+ export type InboundContactsSortEnum =
5
+ (typeof INBOUND_CONTACT_SORT_ENUMS)[number];
6
+
7
+ /**
8
+ * Inbound contact relationship to one organization.
9
+ */
10
+ export interface InboundContactOrgData {
11
+ __table: 'inbound_contact_orgs';
12
+ inboundContactId: bigint;
13
+ organizationId: bigint;
14
+ organization?: OrganizationData | null;
15
+ }
16
+
17
+ /**
18
+ * Inbound contact memory record owned by one organization.
19
+ */
20
+ export interface InboundContactData {
21
+ __table: 'inbound_contacts';
22
+ id: bigint;
23
+ organizationId: bigint;
24
+ personName: string | null;
25
+ email: string | null;
26
+ phone: string | null;
27
+ memory: string | null;
28
+ orgs?: InboundContactOrgData[] | null;
29
+ createdAt: Date;
30
+ updatedAt: Date;
31
+ }
32
+
33
+ /**
34
+ * GraphQL inbound contact relationship to one organization.
35
+ */
36
+ export interface InboundContactOrgGQL {
37
+ organizationId: string;
38
+ name: string | null;
39
+ }
40
+
41
+ /**
42
+ * GraphQL inbound contact memory record.
43
+ */
44
+ export interface InboundContactGQL {
45
+ __deleted?: boolean;
46
+
47
+ id: string;
48
+ organizationId: string;
49
+ cursor: string;
50
+ personName: string | null;
51
+ email: string | null;
52
+ phone: string | null;
53
+ memory: string | null;
54
+ associated?: InboundContactOrgGQL[] | null;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ }
@@ -0,0 +1,42 @@
1
+ import type { IntegrationConnectionStatusEnum } from '../constants/integration.ts';
2
+ import type { SquareConnectionCapabilities } from '../utils/square.ts';
3
+
4
+ /**
5
+ * Integration connection database object.
6
+ */
7
+ export interface IntegrationConnectionData {
8
+ __table: 'integrations';
9
+ id: bigint;
10
+ organizationId: bigint;
11
+ provider: 'SQUARE';
12
+ externalAccountId: string | null;
13
+ scopes: string[];
14
+ status: IntegrationConnectionStatusEnum;
15
+ expiresAt: Date | null;
16
+ refreshTokenExpiresAt: Date | null;
17
+ lastSyncedAt: Date | null;
18
+ lastTokenRefreshAt: Date | null;
19
+ lastError: string | null;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+
24
+ /**
25
+ * GraphQL data for integration connection types.
26
+ */
27
+ export interface IntegrationConnectionGQL {
28
+ id: string;
29
+ organizationId: string;
30
+ provider: 'SQUARE';
31
+ externalAccountId: string | null;
32
+ scopes: string[];
33
+ status: IntegrationConnectionStatusEnum;
34
+ expiresAt: string | null;
35
+ refreshTokenExpiresAt: string | null;
36
+ lastSyncedAt: string | null;
37
+ lastTokenRefreshAt: string | null;
38
+ lastError: string | null;
39
+ capabilities: SquareConnectionCapabilities;
40
+ createdAt: string | null;
41
+ updatedAt: string | null;
42
+ }