@jsb188/mday 1.1.11 → 1.1.12

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 (210) hide show
  1. package/package.json +58 -23
  2. package/src/constants/agentMemory.ts +14 -45
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +5 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +156 -47
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +12 -38
  10. package/src/constants/dataTableFieldTypes.generated.ts +3 -7
  11. package/src/constants/docAccess.ts +3 -2
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +114 -12
  14. package/src/constants/fieldDoc.ts +74 -4
  15. package/src/constants/graphqlReactivity.ts +108 -25
  16. package/src/constants/log.ts +9 -0
  17. package/src/constants/logDisplay/README.md +88 -0
  18. package/src/constants/logDisplay/defaults.ts +39 -0
  19. package/src/constants/logDisplay/index.ts +27 -0
  20. package/src/constants/logDisplay/operations/arable.ts +16 -0
  21. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  22. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  23. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  24. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  25. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  26. package/src/constants/logTaxonomy.generated.ts +1834 -730
  27. package/src/constants/organization.ts +13 -14
  28. package/src/constants/qrCode.ts +30 -0
  29. package/src/constants/sheet.ts +65 -101
  30. package/src/constants/sms.ts +18 -0
  31. package/src/constants/storage.ts +33 -9
  32. package/src/constants/usage.ts +3 -0
  33. package/src/constants/workflowSteps.ts +60 -0
  34. package/src/schemas/editLogEntry.ts +106 -283
  35. package/src/schemas/inboundContact.ts +5 -5
  36. package/src/types/agentMemory.d.ts +38 -14
  37. package/src/types/agentNote.d.ts +443 -0
  38. package/src/types/billing.d.ts +537 -0
  39. package/src/types/campaign.d.ts +1043 -193
  40. package/src/types/contact.d.ts +15 -0
  41. package/src/types/csvExport.d.ts +213 -0
  42. package/src/types/dataAnalysis.d.ts +44 -0
  43. package/src/types/dataTable.d.ts +102 -309
  44. package/src/types/definitionElement.d.ts +35 -0
  45. package/src/types/dt.d.ts +257 -0
  46. package/src/types/email.d.ts +144 -55
  47. package/src/types/emailReplyReport.d.ts +76 -0
  48. package/src/types/fieldDoc.d.ts +579 -150
  49. package/src/types/fieldDocContract.d.ts +90 -0
  50. package/src/types/inboundContact.d.ts +8 -0
  51. package/src/types/log.d.ts +94 -3
  52. package/src/types/logDisplay.types.ts +85 -0
  53. package/src/types/organization.d.ts +8 -3
  54. package/src/types/qrCode.d.ts +96 -0
  55. package/src/types/richText.d.ts +81 -0
  56. package/src/types/sheet.d.ts +180 -463
  57. package/src/types/sms.d.ts +38 -0
  58. package/src/types/storage.d.ts +266 -27
  59. package/src/types/workflow.d.ts +196 -66
  60. package/src/utils/agentMemory.ts +15 -0
  61. package/src/utils/agentNote.ts +850 -0
  62. package/src/utils/aiChat.ts +31 -14
  63. package/src/utils/aiChatWork.ts +64 -0
  64. package/src/utils/billing.ts +37 -0
  65. package/src/utils/campaign.ts +642 -209
  66. package/src/utils/campaignAI.ts +72 -0
  67. package/src/utils/campaignAccess.ts +239 -0
  68. package/src/utils/campaignEmail.ts +601 -0
  69. package/src/utils/campaignEmailCompiler.ts +372 -0
  70. package/src/utils/campaignEmailImages.ts +60 -0
  71. package/src/utils/campaignEmailStyles.ts +544 -0
  72. package/src/utils/campaignLifecycle.ts +104 -0
  73. package/src/utils/campaignPreview.ts +285 -0
  74. package/src/utils/contact.ts +50 -0
  75. package/src/utils/csvExport.ts +19 -0
  76. package/src/utils/dataTable.ts +18 -556
  77. package/src/utils/dataTableFieldTypeRegistry.ts +1 -0
  78. package/src/utils/dataTableRelativeDate.ts +447 -0
  79. package/src/utils/definitionElement.ts +84 -0
  80. package/src/utils/email.ts +208 -1
  81. package/src/utils/emailReplyReport.test.ts +187 -0
  82. package/src/utils/emailReplyReport.ts +143 -0
  83. package/src/utils/fieldDoc.ts +81 -37
  84. package/src/utils/fieldDocAnswers.ts +128 -0
  85. package/src/utils/fieldDocDefaults.ts +36 -0
  86. package/src/utils/fieldDocProgram.ts +36 -0
  87. package/src/utils/fieldDocSummary.ts +30 -0
  88. package/src/utils/log.ts +232 -141
  89. package/src/utils/logDisplay.helpers.ts +177 -0
  90. package/src/utils/logDisplay.ts +87 -0
  91. package/src/utils/logStoreRead.ts +9 -13
  92. package/src/utils/logTaxonomy.helpers.ts +17 -0
  93. package/src/utils/logTaxonomyDisplay.ts +80 -124
  94. package/src/utils/noteDoc.ts +66 -284
  95. package/src/utils/organization.ts +117 -283
  96. package/src/utils/qrCode.helpers.ts +189 -0
  97. package/src/utils/qrCode.test.ts +519 -0
  98. package/src/utils/qrCode.ts +273 -0
  99. package/src/utils/richTextHTML.ts +385 -0
  100. package/src/utils/sheet.ts +123 -4834
  101. package/src/utils/sheetAxisMove.ts +77 -291
  102. package/src/utils/sheetBootstrap.ts +771 -1138
  103. package/src/utils/sheetCellLiteral.ts +101 -0
  104. package/src/utils/sheetCommand.ts +23 -88
  105. package/src/utils/sheetDesign.ts +705 -0
  106. package/src/utils/sheetExport.ts +17 -69
  107. package/src/utils/sheetFeatureReference.ts +183 -0
  108. package/src/utils/sheetFormulaArgs.ts +168 -0
  109. package/src/utils/sheetFormulaCompile.ts +475 -0
  110. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  111. package/src/utils/sheetFormulaCriteria.ts +656 -0
  112. package/src/utils/sheetFormulaDate.ts +444 -0
  113. package/src/utils/sheetFormulaEvaluation.ts +388 -403
  114. package/src/utils/sheetFormulaEvaluator.ts +589 -444
  115. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  116. package/src/utils/sheetFormulaLogical.ts +116 -0
  117. package/src/utils/sheetFormulaLookup.ts +488 -0
  118. package/src/utils/sheetFormulaMath.ts +48 -0
  119. package/src/utils/sheetFormulaParser.ts +729 -0
  120. package/src/utils/sheetFormulaRange.ts +330 -0
  121. package/src/utils/sheetFormulaReference.ts +703 -0
  122. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  123. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  124. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  125. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  126. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  127. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  128. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  129. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  130. package/src/utils/sheetFormulaText.ts +430 -0
  131. package/src/utils/sheetJournal.ts +140 -18
  132. package/src/utils/sheetNumberFormat.ts +68 -267
  133. package/src/utils/sheetPreview.ts +68 -0
  134. package/src/utils/sheetSequence.ts +13 -43
  135. package/src/utils/sheetSnapshot.ts +176 -429
  136. package/src/utils/sheetStructureEdit.ts +537 -907
  137. package/src/utils/sheetStructureReferences.ts +389 -0
  138. package/src/utils/storage.ts +49 -3
  139. package/src/utils/time.ts +12 -0
  140. package/src/utils/workflow.ts +199 -73
  141. package/src/utils/workflowLogFingerprint.ts +302 -0
  142. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  143. package/src/utils/workflowProgress.ts +280 -0
  144. package/src/utils/workflowTriggers.ts +61 -0
  145. package/tests/agentNote.test.ts +395 -0
  146. package/tests/campaignAI.test.ts +119 -0
  147. package/tests/campaignAccess.test.ts +239 -0
  148. package/tests/campaignEmail.test.ts +441 -0
  149. package/tests/campaignLifecycle.test.ts +134 -0
  150. package/tests/campaignPublication.test.ts +309 -0
  151. package/tests/dataTableFieldTypeRegistry.test.ts +2 -1
  152. package/tests/dataTableRelativeDate.test.ts +412 -0
  153. package/tests/email.test.ts +39 -0
  154. package/tests/fieldDocProgram.test.ts +114 -0
  155. package/tests/logDisplay.fixtures.ts +67 -0
  156. package/tests/logDisplay.test.ts +227 -0
  157. package/tests/noteDoc.test.ts +37 -192
  158. package/tests/richTextHTML.test.ts +185 -0
  159. package/tests/sheetAxisMove.test.ts +49 -40
  160. package/tests/sheetBootstrap.test.ts +1967 -0
  161. package/tests/sheetFeatureReference.test.ts +22 -0
  162. package/tests/sheetFormulaCriteria.test.ts +269 -0
  163. package/tests/sheetFormulaEvaluator.test.ts +93 -200
  164. package/tests/sheetFormulaFunctions.test.ts +538 -0
  165. package/tests/sheetFormulaLanguage.test.ts +361 -0
  166. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  167. package/tests/sheetFormulaParity.test.ts +188 -0
  168. package/tests/sheetFormulaRange.test.ts +167 -0
  169. package/tests/sheetFormulaReference.test.ts +78 -0
  170. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  171. package/tests/sheetFormulaTextDate.test.ts +512 -0
  172. package/tests/sheetSequence.test.ts +4 -23
  173. package/tests/sheetSnapshot.test.ts +134 -0
  174. package/tests/sheetStructureEdit.test.ts +492 -37
  175. package/tests/sheetStructureReferences.test.ts +589 -0
  176. package/tests/workflowLifecycleStatus.test.ts +60 -0
  177. package/tests/workflowLogFingerprint.test.ts +203 -0
  178. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  179. package/tests/workflowProgress.test.ts +180 -0
  180. package/tests/workflowTriggers.test.ts +29 -0
  181. package/src/constants/agentDoc.ts +0 -12
  182. package/src/constants/logActivityGroupColors.generated.ts +0 -19
  183. package/src/constants/schedule.ts +0 -220
  184. package/src/constants/scheduleRuleTemplateSeed.ts +0 -138
  185. package/src/constants/scheduleRuleTemplates.generated.ts +0 -145
  186. package/src/constants/sheetRegionSources.generated.ts +0 -578
  187. package/src/schemas/fieldDocsQuery.ts +0 -12
  188. package/src/schemas/organization.ts +0 -68
  189. package/src/types/agentDoc.d.ts +0 -64
  190. package/src/types/noteDoc.d.ts +0 -86
  191. package/src/types/schedule.d.ts +0 -391
  192. package/src/utils/agentDoc.ts +0 -109
  193. package/src/utils/campaignFormEditor.ts +0 -871
  194. package/src/utils/dataTableRealtimeAuthority.ts +0 -209
  195. package/src/utils/dataTableRealtimeSelection.ts +0 -134
  196. package/src/utils/dataTableRowDocument.ts +0 -508
  197. package/src/utils/dataTableSource.ts +0 -230
  198. package/src/utils/schedule.ts +0 -799
  199. package/src/utils/scheduleEvaluation.ts +0 -1994
  200. package/src/utils/scheduleICS.ts +0 -246
  201. package/src/utils/scheduleRuleTemplates.ts +0 -188
  202. package/src/utils/sheetRegion.ts +0 -374
  203. package/src/utils/sheetRegionFilter.ts +0 -1259
  204. package/src/utils/sheetRegionSourceRegistry.ts +0 -594
  205. package/tests/schedule.test.ts +0 -693
  206. package/tests/scheduleEvaluation.test.ts +0 -1970
  207. package/tests/scheduleICS.test.ts +0 -208
  208. package/tests/scheduleRuleTemplates.test.ts +0 -176
  209. package/tests/scheduleSweepInvariants.test.ts +0 -428
  210. package/tests/sheetRegionFilter.test.ts +0 -1135
@@ -0,0 +1,234 @@
1
+ import { DATA_TABLE_FIELD_TYPE_ENUMS } from './dataTableFieldTypes.generated.ts';
2
+
3
+ /**
4
+ * Data tables v2 (dt_* store); what a table holds. SOURCE tables project one
5
+ * row per source record from a declarative spec; AGENT tables hold rows that
6
+ * agents, or workflows with a writer grant, upsert by key.
7
+ */
8
+
9
+ export const DT_TABLE_KIND_ENUMS = ['SOURCE', 'AGENT'] as const;
10
+
11
+ /**
12
+ * Data tables v2; the source records a SOURCE table projects. AGENT tables
13
+ * have no source.
14
+ */
15
+
16
+ export const DT_SOURCE_ENUMS = ['LOGS', 'CAMPAIGN_RESPONSES', 'CAMPAIGN_RECIPIENTS', 'FIELD_DOC_SUBMISSIONS'] as const;
17
+
18
+ /**
19
+ * Data tables v2; one row per source record (RECORD) or per log item or
20
+ * field-doc TABLE answer row (LINE).
21
+ */
22
+
23
+ export const DT_GRAIN_ENUMS = ['RECORD', 'LINE'] as const;
24
+
25
+ /**
26
+ * Data tables v2; LISTED tables appear in listings and the read-only viewer.
27
+ * INTERNAL tables are hidden, unowned SOURCE query caches behind notes.
28
+ */
29
+
30
+ export const DT_VISIBILITY_ENUMS = ['LISTED', 'INTERNAL'] as const;
31
+
32
+ /**
33
+ * Data tables v2; projection state of a table. PAUSED and FAILED tables skip
34
+ * syncs; resuming always runs a full re-projection.
35
+ */
36
+
37
+ export const DT_SYNC_STATE_ENUMS = ['BACKFILLING', 'READY', 'PAUSED', 'FAILED'] as const;
38
+
39
+ /**
40
+ * Data tables v2; who fills a column. SOURCE columns are projected from a
41
+ * source path, DERIVED columns are filled by the model from "inputKeys", and
42
+ * AGENT columns are written by agents and writer workflows.
43
+ */
44
+
45
+ export const DT_COLUMN_ORIGIN_ENUMS = ['SOURCE', 'DERIVED', 'AGENT'] as const;
46
+
47
+ /**
48
+ * Data tables v2; why a dt_runs row was written. Routine syncs write no run.
49
+ */
50
+
51
+ export const DT_RUN_CAUSE_ENUMS = ['BACKFILL', 'RECONCILE', 'DERIVE', 'AGENT_WRITE', 'DEFINITION', 'MIGRATION'] as const;
52
+
53
+ /**
54
+ * Data tables v2; why DERIVED columns stopped being filled. OWNER_ARCHIVED is
55
+ * cleared when the owner note is unarchived.
56
+ */
57
+
58
+ export const DT_DERIVE_PAUSE_REASON_ENUMS = ['OWNER_ARCHIVED', 'PUBLISH_FAILED', 'PERSON'] as const;
59
+
60
+ /**
61
+ * Data tables v2; why a table's projection has a gap that evidence and the
62
+ * viewer show. QUESTION_REMOVED: a bound form or field-doc question no longer
63
+ * exists in its definition. CAMPAIGN_UNBOUND: a campaign of a bound template
64
+ * or of an explicit campaign scope has no question matching an answer column
65
+ * (same key and label).
66
+ */
67
+
68
+ export const DT_COVERAGE_WARNING_CODE_ENUMS = ['QUESTION_REMOVED', 'CAMPAIGN_UNBOUND'] as const;
69
+
70
+ /**
71
+ * Data tables v2; who wrote a row's DERIVED values. An AGENT override holds
72
+ * until the row's derive inputs change.
73
+ */
74
+
75
+ export const DT_DERIVED_BY_ENUMS = ['MODEL', 'AGENT'] as const;
76
+
77
+ /**
78
+ * Data tables v2; how a note shows one saved query's result block.
79
+ */
80
+
81
+ export const DT_QUERY_DISPLAY_ENUMS = ['TABLE', 'VALUE', 'ROWS'] as const;
82
+
83
+ /**
84
+ * Data tables v2; entity kinds an ENTITY column stores ids of. Labels are
85
+ * resolved when results are rendered.
86
+ */
87
+
88
+ export const DT_ENTITY_ENUMS = ['CHILD_ORG', 'SITE', 'ACCOUNT', 'ACTIVITY', 'CONTACT'] as const;
89
+
90
+ /**
91
+ * Data tables v2; source scopes a SOURCE table projects records from.
92
+ */
93
+
94
+ export const DT_SCOPE_TYPE_ENUMS = ['LOG_ACTIVITY', 'LOG_GROUP', 'CAMPAIGN', 'CAMPAIGN_TEMPLATE', 'FIELD_DOC'] as const;
95
+
96
+ /**
97
+ * Data tables v2; query condition operators.
98
+ */
99
+
100
+ export const DT_CONDITION_OPERATOR_ENUMS = [
101
+ 'EQUALS',
102
+ 'NOT_EQUALS',
103
+ 'IN',
104
+ 'NOT_IN',
105
+ 'CONTAINS',
106
+ 'STARTS_WITH',
107
+ 'IS_EMPTY',
108
+ 'IS_NOT_EMPTY',
109
+ 'GT',
110
+ 'GTE',
111
+ 'LT',
112
+ 'LTE',
113
+ 'BETWEEN',
114
+ ] as const;
115
+
116
+ /**
117
+ * Data tables v2; relative date windows a date condition accepts, resolved in
118
+ * the organization time zone when the query runs. LAST_N_DAYS takes "n".
119
+ */
120
+
121
+ export const DT_RELATIVE_DATE_ENUMS = [
122
+ 'TODAY',
123
+ 'LAST_N_DAYS',
124
+ 'CURRENT_WEEK',
125
+ 'CURRENT_MONTH',
126
+ 'CURRENT_YEAR',
127
+ 'PREVIOUS_WEEK',
128
+ 'PREVIOUS_MONTH',
129
+ 'PREVIOUS_YEAR',
130
+ ] as const;
131
+
132
+ /**
133
+ * Data tables v2; date buckets a query can group by.
134
+ */
135
+
136
+ export const DT_DATE_BUCKET_ENUMS = ['DAY', 'WEEK', 'MONTH', 'YEAR'] as const;
137
+
138
+ /**
139
+ * Data tables v2; query metric functions.
140
+ */
141
+
142
+ export const DT_METRIC_FN_ENUMS = ['COUNT', 'COUNT_DISTINCT', 'SUM', 'AVG', 'MIN', 'MAX', 'PERCENT_TRUE', 'LATEST'] as const;
143
+
144
+ /**
145
+ * Data tables v2; query sort directions.
146
+ */
147
+
148
+ export const DT_SORT_DIRECTION_ENUMS = ['ASC', 'DESC'] as const;
149
+
150
+ /**
151
+ * Data tables v2; column types. The shared column-type registry
152
+ * (data_table_field_types) without REFERENCE (rows never reference other rows)
153
+ * and JSON (cells hold canonical scalars).
154
+ */
155
+
156
+ export const DT_COLUMN_TYPES = DATA_TABLE_FIELD_TYPE_ENUMS.filter(
157
+ (type): type is Exclude<(typeof DATA_TABLE_FIELD_TYPE_ENUMS)[number], 'REFERENCE' | 'JSON'> =>
158
+ type !== 'REFERENCE' && type !== 'JSON',
159
+ );
160
+
161
+ /**
162
+ * Data tables v2; output and input caps. Rows per agent write, rows per read,
163
+ * groups per aggregate, and the query spec's list sizes. Queries never cap
164
+ * their input: overflow returns "truncated" plus "matched". "statementTimeoutMS"
165
+ * bounds one compiled query. The definition caps bound one table: columns, key
166
+ * columns, scopes, and the character lengths of a title, description, column
167
+ * label, row key and text cell (longer text cells are cut).
168
+ */
169
+
170
+ export const DT_LIMITS = {
171
+ writeRows: 200,
172
+ readRows: 100,
173
+ groups: 500,
174
+ conditions: 20,
175
+ groupBy: 3,
176
+ metrics: 10,
177
+ sort: 3,
178
+ statementTimeoutMS: 5000,
179
+ columns: 100,
180
+ keyColumns: 5,
181
+ scopes: 50,
182
+ titleChars: 120,
183
+ descriptionChars: 750,
184
+ columnLabelChars: 120,
185
+ rowKeyChars: 160,
186
+ cellTextChars: 10000,
187
+ } as const;
188
+
189
+ /**
190
+ * Data tables v2; durable job timing. Each job runs "debounceMS" after the
191
+ * latest change, but never later than "maxWaitMS" after the first unserved
192
+ * change. "sync.batch" is the dirty source rows (or backfill and reconcile
193
+ * source records) read per sync transaction. "reconcile" coalesces the full
194
+ * re-projections requested by definition edits. A sync or reconcile run stops
195
+ * after "runBudgetMS" and continues in a follow-up run.
196
+ */
197
+
198
+ export const DT_TIMING = {
199
+ sync: { debounceMS: 3000, maxWaitMS: 30000, batch: 1000 },
200
+ changed: { debounceMS: 2000, maxWaitMS: 15000 },
201
+ derive: { debounceMS: 60000, maxWaitMS: 600000 },
202
+ reconcile: { debounceMS: 3000, maxWaitMS: 30000 },
203
+ runBudgetMS: 20000,
204
+ } as const;
205
+
206
+ /**
207
+ * Data tables v2; DERIVED column batches. A batch holds up to "batchRows" rows
208
+ * or "batchChars" input characters. A row that fails "maxAttempts" times gets
209
+ * a derive error until its inputs change. "dailyCallBudgetPerOrg" is a
210
+ * runaway-cost circuit breaker, not a creation limit.
211
+ */
212
+
213
+ export const DT_DERIVE = {
214
+ batchRows: 25,
215
+ batchChars: 32000,
216
+ maxAttempts: 3,
217
+ dailyCallBudgetPerOrg: 2000,
218
+ } as const;
219
+
220
+ /**
221
+ * Data tables v2; retention in days. Tombstoned rows and dt_runs rows are
222
+ * purged after "tombstoneDays" and "runsDays"; an INTERNAL table without saved
223
+ * queries for "internalGcDays" is deleted, and one no active note queries is
224
+ * paused once it is "internalPauseGraceDays" old. Archived tables follow the
225
+ * server's trash-bin retention. "coverageWarnings" caps a table's warnings.
226
+ */
227
+
228
+ export const DT_RETENTION = {
229
+ tombstoneDays: 30,
230
+ runsDays: 90,
231
+ internalGcDays: 7,
232
+ internalPauseGraceDays: 1,
233
+ coverageWarnings: 50,
234
+ } as const;
@@ -11,34 +11,136 @@ export const EMAIL_STATUS_ENUMS = [
11
11
  'ERRORED',
12
12
  ] as const;
13
13
 
14
- /**
15
- * Inbound email list sort options.
16
- */
17
- export const INBOUND_EMAIL_SORT_ENUMS = [
18
- 'RECEIVED_AT_DESC',
19
- 'RECEIVED_AT_ASC',
20
- ] as const;
21
-
22
14
  /**
23
15
  * Outbound email delivery statuses.
24
16
  */
25
17
  export const OUTBOUND_EMAIL_STATUS_ENUMS = [
26
18
  'QUEUED',
27
19
  'PROCESSING',
20
+ 'DELIVERY_UNKNOWN',
28
21
  'SENT',
29
22
  'ERRORED',
30
23
  'BOUNCED',
24
+ 'SUPPRESSED',
31
25
  ] as const;
32
26
 
33
27
  /**
34
- * Outbound email list sort options.
28
+ * Organization-level campaign email preference states.
35
29
  */
36
- export const OUTBOUND_EMAIL_SORT_ENUMS = [
37
- 'CREATED_AT_DESC',
38
- 'CREATED_AT_ASC',
30
+ export const CAMPAIGN_EMAIL_PREFERENCE_STATUS_ENUMS = [
31
+ 'OPTED_IN',
32
+ 'OPTED_OUT',
33
+ ] as const;
34
+
35
+ /**
36
+ * Append-only campaign email preference transition kinds.
37
+ */
38
+ export const CAMPAIGN_EMAIL_PREFERENCE_EVENT_ENUMS = [
39
+ 'UNSUBSCRIBED',
40
+ 'RESUBSCRIBED',
41
+ ] as const;
42
+
43
+ /**
44
+ * Verified sources allowed to change a campaign email preference.
45
+ */
46
+ export const CAMPAIGN_EMAIL_PREFERENCE_SOURCE_ENUMS = [
47
+ 'RECIPIENT_LINK',
48
+ 'RECIPIENT_ONE_CLICK',
49
+ 'POSTMARK_RECIPIENT',
50
+ 'RECIPIENT_RESUBSCRIBE',
39
51
  ] as const;
40
52
 
41
53
  /**
42
54
  * Inbound email body display source options.
43
55
  */
44
56
  export const INBOUND_EMAIL_BODY_FORMAT_ENUMS = ['TEXT'] as const;
57
+
58
+ /**
59
+ * Whether an email message was received by or sent from an organization.
60
+ */
61
+ export const EMAIL_DIRECTION_ENUMS = ['INBOUND', 'OUTBOUND'] as const;
62
+
63
+ /**
64
+ * What sent one outbound email; mirrors the emails_outbound_kind enum.
65
+ */
66
+ export const OUTBOUND_EMAIL_KIND_ENUMS = [
67
+ 'AGENT_REPLY',
68
+ 'AGENT_SEND',
69
+ 'WORKFLOW_SEND',
70
+ 'REMINDER',
71
+ 'SCHEDULE_NOTIFICATION',
72
+ 'CAMPAIGN',
73
+ 'FORM_RESPONSE_COPY',
74
+ 'CSV_EXPORT',
75
+ 'OTHER',
76
+ ] as const;
77
+
78
+ /**
79
+ * What one inbound email is, derived from the outbound email it replies to.
80
+ */
81
+ export const INBOUND_EMAIL_KIND_ENUMS = [
82
+ 'INBOX_MESSAGE',
83
+ 'CAMPAIGN_REPLY',
84
+ 'REPLY',
85
+ ] as const;
86
+
87
+ /**
88
+ * Every email message kind across both directions.
89
+ */
90
+ export const EMAIL_MESSAGE_KIND_ENUMS = [
91
+ ...INBOUND_EMAIL_KIND_ENUMS,
92
+ ...OUTBOUND_EMAIL_KIND_ENUMS,
93
+ ] as const;
94
+
95
+ /**
96
+ * Every email message status across both directions.
97
+ */
98
+ export const EMAIL_MESSAGE_STATUS_ENUMS = [
99
+ 'RECEIVED',
100
+ 'QUEUED',
101
+ 'PROCESSING',
102
+ 'SUPERSEDED',
103
+ 'COMPLETED',
104
+ 'IGNORED',
105
+ 'SENT',
106
+ 'DELIVERY_UNKNOWN',
107
+ 'BOUNCED',
108
+ 'SUPPRESSED',
109
+ 'ERRORED',
110
+ ] as const;
111
+
112
+ /**
113
+ * Direction-neutral status buckets used to filter and color email messages.
114
+ */
115
+ export const EMAIL_STATUS_GROUP_ENUMS = [
116
+ 'PENDING',
117
+ 'DONE',
118
+ 'SKIPPED',
119
+ 'FAILED',
120
+ ] as const;
121
+
122
+ /**
123
+ * Raw statuses in each status group, per direction.
124
+ */
125
+ export const EMAIL_STATUS_GROUP_STATUSES = {
126
+ INBOUND: {
127
+ PENDING: ['RECEIVED', 'QUEUED', 'PROCESSING'],
128
+ DONE: ['COMPLETED'],
129
+ SKIPPED: ['IGNORED', 'SUPERSEDED'],
130
+ FAILED: ['ERRORED'],
131
+ },
132
+ OUTBOUND: {
133
+ PENDING: ['QUEUED', 'PROCESSING'],
134
+ DONE: ['SENT'],
135
+ SKIPPED: ['SUPPRESSED'],
136
+ FAILED: ['ERRORED', 'BOUNCED', 'DELIVERY_UNKNOWN'],
137
+ },
138
+ } as const;
139
+
140
+ /**
141
+ * Email message list sort options.
142
+ */
143
+ export const EMAIL_MESSAGE_SORT_ENUMS = [
144
+ 'OCCURRED_AT_DESC',
145
+ 'OCCURRED_AT_ASC',
146
+ ] as const;
@@ -1,8 +1,21 @@
1
+ import type { FieldDocAsideBlockObj } from '../types/fieldDoc.d.ts';
2
+
1
3
  /**
2
4
  * FieldDocs; all types
3
5
  */
4
6
 
5
- export const FIELD_DOC_SORT_OPTS = ['PERIOD_DESC', 'ACTIVITY_DESC'];
7
+ export const DEFAULT_FIELD_DOC_SUMMARY_ELEMENT = {
8
+ key: 'field_doc_summary',
9
+ kind: 'SUMMARY' as const,
10
+ label: 'Summary',
11
+ required: false,
12
+ settings: {},
13
+ };
14
+
15
+ export const DEFAULT_FIELD_DOC_SUMMARY_SECTION = {
16
+ key: 'field_doc_summary_section',
17
+ label: 'Summary',
18
+ };
6
19
 
7
20
  export const FIELD_DOC_ELEMENT_KINDS = [
8
21
  'SECTION', // Top-level container; all other kinds are children of a section
@@ -25,10 +38,67 @@ export const FIELD_DOC_FREQUENCY_ENUMS = [
25
38
  'MONTHLY',
26
39
  'QUARTERLY',
27
40
  'ANNUALLY',
41
+ 'PER_INSTANCE', // One submission per external job (instanceKey), any number per day; no calendar period
28
42
  ];
29
43
 
30
44
  export const FIELD_DOC_STATUS_ENUMS = ['PASS', 'WARNING', 'FAIL'];
31
45
 
32
- // Longest allowed agent-only matching hint on a fieldDoc; shared by the
33
- // server-side mutation validation and the client textarea maxLength
34
- export const FIELD_DOC_AGENT_HINT_MAX_LENGTH = 2000;
46
+ export const FIELD_DOC_SUBMISSION_FILTER_STATUS_ENUMS = ['OPEN', ...FIELD_DOC_STATUS_ENUMS];
47
+
48
+ // Lifecycle of a PER_INSTANCE submission; periodic submissions have none
49
+ export const FIELD_DOC_INSTANCE_STATUS_ENUMS = ['OPEN', 'COMPLETED', 'CANCELLED'];
50
+
51
+ /**
52
+ * Field doc programs
53
+ */
54
+
55
+ // Program categories in display order; display names come from i18n field_docs.category.<KEY>
56
+ export const FIELD_DOC_CATEGORIES = [
57
+ 'FOOD_SAFETY',
58
+ 'QUALITY_ASSURANCE',
59
+ 'WORKER_SAFETY',
60
+ 'SUSTAINABILITY',
61
+ 'ENVIRONMENTAL',
62
+ 'REGULATORY_INSPECTION',
63
+ 'LOGISTICS',
64
+ 'OTHER',
65
+ ] as const;
66
+
67
+ // Reserved custom-instructions key for the doc-level agentHint; element keys start with a letter, so it never collides
68
+ export const FIELD_DOC_DOCUMENT_INSTRUCTIONS_KEY = '$document';
69
+
70
+ // documentName rule for every doc (catalog codes like FS07 included); matches the field_docs CHECK and varchar(40)
71
+ export const FIELD_DOC_DOCUMENT_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,39}$/;
72
+
73
+ // Per-key custom instructions limit; matches the field_doc_custom_instructions CHECK
74
+ export const FIELD_DOC_CUSTOM_INSTRUCTIONS_MAX = 2000;
75
+
76
+ // Program-managed workflow user instructions limit; matches the workflows."userInstructions" CHECK
77
+ export const PROGRAM_WORKFLOW_USER_INSTRUCTIONS_MAX = 2000;
78
+
79
+ // Stored submission summary limit; matches field_doc_submissions.summary varchar(750)
80
+ export const FIELD_DOC_SUMMARY_MAX = 750;
81
+
82
+ // Aside for programs whose layout has no populated aside; rendered by the field doc template engine
83
+ export const FIELD_DOC_DEFAULT_ASIDE: FieldDocAsideBlockObj[] = [
84
+ {
85
+ title: 'Document',
86
+ items: [
87
+ { text: '{{documentName}}', label: 'Name' },
88
+ { text: '{{identifierHint}}', label: 'For', hideIfEmpty: true },
89
+ { text: '{{documentRevision}}', label: 'Revision' },
90
+ { text: '{{fieldDocSubmissionId}}', label: 'Record No.' },
91
+ { text: '{{instanceKey}}', label: 'Batch No.', hideIfEmpty: true },
92
+ { text: '{{status}}', label: 'Status' },
93
+ { text: '{{date}}', label: 'Date' },
94
+ { text: '{{activityAt}}', label: 'Updated' },
95
+ ],
96
+ },
97
+ {
98
+ title: 'Location',
99
+ items: [
100
+ { text: '{{childOrgName}}', label: 'Organization', hideIfEmpty: true },
101
+ { text: '{{siteLocation}}', label: 'Site' },
102
+ ],
103
+ },
104
+ ];
@@ -6,26 +6,33 @@
6
6
  */
7
7
  export const FRAGMENT_NAMES = {
8
8
  accountSession: '$accountSessionFragment',
9
- agentDoc: '$agentDocFragment',
10
- agentDocFolder: '$agentDocFolderFragment',
11
9
  agentMemory: '$agentMemoryFragment',
10
+ agentNote: '$agentNoteFragment',
12
11
  aiChat: '$aiChatFragment',
13
12
  aiChatMessage: '$aiChatMessageFragment',
13
+ aiChatRun: '$aiChatRunFragment',
14
+ audienceList: '$audienceListFragment',
15
+ audienceListMember: '$audienceListMemberFragment',
16
+ audienceEmailAddress: '$audienceEmailAddressFragment',
14
17
  campaign: '$campaignFragment',
18
+ campaignAudienceMember: '$campaignAudienceMemberFragment',
19
+ campaignAudiencePreview: '$campaignAudiencePreviewFragment',
20
+ campaignAudienceSession: '$campaignAudienceSessionFragment',
15
21
  campaignRecipient: '$campaignRecipientFragment',
16
- campaignResponse: '$campaignResponseFragment',
22
+ campaignRecipientOverview: '$campaignRecipientOverviewFragment',
23
+ campaignResponseOverview: '$campaignResponseOverviewFragment',
24
+ campaignResponseSummary: '$campaignResponseSummaryFragment',
17
25
  campaignTemplate: '$campaignTemplateFragment',
18
- campaignTemplateElement: '$campaignTemplateElementFragment',
19
26
  dataTable: '$dataTableFragment',
20
- dataTableCell: '$dataTableCellFragment',
21
27
  dataTableRow: '$dataTableRowFragment',
22
28
  email: '$emailFragment',
23
- fieldDoc: '$fieldDocFragment',
24
- fieldDocElementData: '$fieldDocElementDataFragment',
29
+ emailMessage: '$emailMessageFragment',
30
+ fieldDocAnswer: '$fieldDocAnswerFragment',
31
+ fieldDocEditSession: '$fieldDocEditSessionFragment',
32
+ fieldDocProgram: '$fieldDocProgramFragment',
25
33
  fieldDocSubmission: '$fieldDocSubmissionFragment',
26
34
  generatedFile: '$generatedFileFragment',
27
35
  inboundContact: '$inboundContactFragment',
28
- inboundEmail: '$inboundEmailFragment',
29
36
  integrationConnection: '$integrationConnectionFragment',
30
37
  logEntry: '$logEntryFragment',
31
38
  logEntryDetails: '$logEntryDetailsFragment',
@@ -35,14 +42,24 @@ export const FRAGMENT_NAMES = {
35
42
  organizationRelationship: '$organizationRelationshipFragment',
36
43
  organizationSettings: '$organizationSettingsFragment',
37
44
  organizationSite: '$organizationSiteFragment',
45
+ qrCode: '$qrCodeFragment',
46
+ scheduleActivity: '$scheduleActivityFragment',
38
47
  scheduleCalendar: '$scheduleCalendarFragment',
39
48
  scheduleOccurrence: '$scheduleOccurrenceFragment',
49
+ scheduleProject: '$scheduleProjectFragment',
50
+ scheduleRun: '$scheduleProjectRunFragment',
40
51
  scheduleRequest: '$scheduleRequestFragment',
52
+ scheduleTimeOff: '$scheduleTimeOffFragment',
53
+ scheduleViolation: '$scheduleViolationFragment',
54
+ schedulePublication: '$schedulePublicationFragment',
55
+ scheduleRelationship: '$scheduleRelationshipFragment',
41
56
  scheduleResource: '$scheduleResourceFragment',
42
57
  scheduleSeries: '$scheduleSeriesFragment',
58
+ scheduleWorkCalendar: '$scheduleWorkCalendarFragment',
43
59
  sheet: '$sheetFragment',
44
60
  sheetCell: '$sheetCellFragment',
45
61
  sheetImportJob: '$sheetImportJobFragment',
62
+ sheetManifest: '$sheetManifestFragment',
46
63
  sheetTab: '$sheetTabFragment',
47
64
  sheetView: '$sheetViewFragment',
48
65
  storageFile: '$storageFileFragment',
@@ -50,57 +67,123 @@ export const FRAGMENT_NAMES = {
50
67
  workflowRun: '$workflowRunFragment',
51
68
  } as const;
52
69
 
53
- export type WSFragmentName =
54
- (typeof FRAGMENT_NAMES)[keyof typeof FRAGMENT_NAMES];
70
+ export type WSFragmentName = (typeof FRAGMENT_NAMES)[keyof typeof FRAGMENT_NAMES];
55
71
 
56
72
  /*
57
73
  * GraphQL query names shared by structured reset targets and local cache
58
74
  * invalidation.
59
75
  */
60
76
  export const QUERY_NAMES = {
61
- agentDoc: 'agentDoc',
62
- agentDocFolders: 'agentDocFolders',
63
- agentDocs: 'agentDocs',
64
77
  aiChat: 'aiChat',
65
78
  aiChatMessages: 'aiChatMessages',
66
79
  aiChats: 'aiChats',
67
- campaign: 'campaign',
80
+ audienceAddressHistory: 'audienceAddressHistory',
81
+ audienceEmailAddress: 'audienceEmailAddress',
82
+ audienceList: 'audienceList',
83
+ audienceListMembers: 'audienceListMembers',
84
+ audienceListOverview: 'audienceListOverview',
85
+ audienceLists: 'audienceLists',
86
+ billingPlans: 'billingPlans',
87
+ campaignAudience: 'campaignAudience',
88
+ campaignAudienceMembers: 'campaignAudienceMembers',
89
+ campaignEditSession: 'campaignEditSession',
90
+ campaignFormAccessSession: 'campaignFormAccessSession',
91
+ campaignRecipientOverview: 'campaignRecipientOverview',
92
+ campaignRecipients: 'campaignRecipients',
93
+ campaignResponseOverview: 'campaignResponseOverview',
68
94
  campaignResponses: 'campaignResponses',
69
- campaignTemplate: 'campaignTemplate',
95
+ campaignTemplateEditSession: 'campaignTemplateEditSession',
70
96
  campaignTemplates: 'campaignTemplates',
97
+ systemCampaignTemplates: 'systemCampaignTemplates',
71
98
  campaigns: 'campaigns',
72
99
  childOrganizations: 'childOrganizations',
73
- fieldDoc: 'fieldDoc',
74
- fieldDocGroups: 'fieldDocGroups',
75
- fieldDocs: 'fieldDocs',
100
+ dataTable: 'dataTable',
101
+ dataTableRows: 'dataTableRows',
102
+ dataTables: 'dataTables',
103
+ emailCampaignReplyReport: 'emailCampaignReplyReport',
104
+ emailMessage: 'emailMessage',
105
+ emailMessages: 'emailMessages',
106
+ fieldDocProgramEnrollments: 'fieldDocProgramEnrollments',
107
+ fieldDocProgramCatalog: 'fieldDocProgramCatalog',
108
+ fieldDocProgramMetadata: 'fieldDocProgramMetadata',
76
109
  fieldDocSubmissions: 'fieldDocSubmissions',
110
+ fieldDocSubmissionDocument: 'fieldDocSubmissionDocument',
111
+ fieldDocSubmissionLogs: 'fieldDocSubmissionLogs',
112
+ fieldDocEditSession: 'fieldDocEditSession',
77
113
  generatedFiles: 'generatedFiles',
78
114
  agentMemories: 'agentMemories',
115
+ agentNote: 'agentNote',
116
+ agentNoteBootstrapProgress: 'agentNoteBootstrapProgress',
117
+ agentNotes: 'agentNotes',
118
+ searchAgentNotes: 'searchAgentNotes',
119
+ campaignTemplateAgentNoteFocus: 'campaignTemplateAgentNoteFocus',
79
120
  inboundContact: 'inboundContact',
80
121
  inboundContacts: 'inboundContacts',
81
122
  logEntries: 'logEntries',
82
- logEntriesForFieldDoc: 'logEntriesForFieldDoc',
83
123
  myAccountSessions: 'myAccountSessions',
84
124
  myOrganizations: 'myOrganizations',
125
+ organizationBilling: 'organizationBilling',
85
126
  organizationMembers: 'organizationMembers',
86
127
  organizationMemberSessions: 'organizationMemberSessions',
87
128
  organizationSites: 'organizationSites',
129
+ qrCode: 'qrCode',
130
+ qrCodes: 'qrCodes',
131
+ scheduleCalendar: 'scheduleCalendar',
132
+ scheduleProject: 'scheduleProject',
133
+ scheduleResource: 'scheduleResource',
134
+ scheduleWorkCalendar: 'scheduleWorkCalendar',
135
+ scheduleRules: 'scheduleRules',
136
+ scheduleDemands: 'scheduleDemands',
137
+ scheduleOccurrence: 'scheduleOccurrence',
138
+ scheduleShiftEligibility: 'scheduleShiftEligibility',
139
+ scheduleShiftCandidates: 'scheduleShiftCandidates',
140
+ schedulePublishPreflight: 'schedulePublishPreflight',
141
+ scheduleSeriesList: 'scheduleSeriesList',
142
+ scheduleSeries: 'scheduleSeries',
143
+ scheduleRequest: 'scheduleRequest',
144
+ scheduleCodeTypes: 'scheduleCodeTypes',
88
145
  scheduleCalendars: 'scheduleCalendars',
89
146
  scheduleOccurrences: 'scheduleOccurrences',
147
+ scheduleProjectNetwork: 'scheduleProjectNetwork',
148
+ scheduleProjects: 'scheduleProjects',
149
+ scheduleProjectRuns: 'scheduleProjectRuns',
150
+ scheduleProjectRun: 'scheduleProjectRun',
151
+ scheduleOpenShifts: 'scheduleOpenShifts',
152
+ scheduleMyShifts: 'scheduleMyShifts',
90
153
  scheduleRequests: 'scheduleRequests',
154
+ scheduleTimeOff: 'scheduleTimeOffList',
155
+ scheduleResourceUsage: 'scheduleResourceUsage',
156
+ scheduleBaselines: 'scheduleBaselines',
157
+ scheduleBaselineActivities: 'scheduleBaselineActivities',
158
+ scheduleBaselineVariance: 'scheduleBaselineVariance',
159
+ schedulePublications: 'schedulePublications',
91
160
  scheduleResources: 'scheduleResources',
161
+ scheduleViolations: 'scheduleViolations',
162
+ scheduleWorkCalendars: 'scheduleWorkCalendars',
92
163
  workflowRuns: 'workflowRuns',
93
164
  } as const;
94
165
 
95
166
  /*
96
- * Build one reactive fragment key, e.g. makeFragmentKey(FRAGMENT_NAMES.agentDoc, id)
97
- * → '$agentDocFragment:<id>'. Used for server reactiveFragmentKeys and client
167
+ * Keep entity-scoped campaign editor operation names and cache-key variables
168
+ * aligned across client documents and server reset targets.
169
+ */
170
+ export const CAMPAIGN_EDITOR_SESSION_QUERY_CONTRACTS = {
171
+ campaign: {
172
+ idVariableName: 'campaignId',
173
+ queryName: QUERY_NAMES.campaignEditSession,
174
+ },
175
+ template: {
176
+ idVariableName: 'templateId',
177
+ queryName: QUERY_NAMES.campaignTemplateEditSession,
178
+ },
179
+ } as const;
180
+
181
+ /*
182
+ * Build one reactive fragment key, e.g. makeFragmentKey(FRAGMENT_NAMES.agentNote, id)
183
+ * → '$agentNoteFragment:<id>'. Used for server reactiveFragmentKeys and client
98
184
  * fragment-observer keys (they share the exact same format).
99
185
  */
100
- export function makeFragmentKey(
101
- name: WSFragmentName,
102
- dataId: string | number,
103
- ): string {
186
+ export function makeFragmentKey(name: WSFragmentName, dataId: string | number): string {
104
187
  return `${name}:${dataId}`;
105
188
  }
106
189