@jsb188/mday 1.1.10 → 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 +140 -54
  2. package/src/constants/agentMemory.ts +123 -0
  3. package/src/constants/agentNote.ts +212 -0
  4. package/src/constants/aiChat.ts +10 -0
  5. package/src/constants/billing.ts +126 -0
  6. package/src/constants/campaign.ts +236 -0
  7. package/src/constants/contact.ts +72 -0
  8. package/src/constants/csvExport.ts +133 -0
  9. package/src/constants/dataTable.ts +21 -21
  10. package/src/constants/dataTableFieldTypes.generated.ts +59 -0
  11. package/src/constants/docAccess.ts +33 -0
  12. package/src/constants/dt.ts +234 -0
  13. package/src/constants/email.ts +125 -7
  14. package/src/constants/fieldDoc.ts +104 -0
  15. package/src/constants/graphqlReactivity.ts +196 -0
  16. package/src/constants/integration.ts +8 -9
  17. package/src/constants/log.ts +14 -408
  18. package/src/constants/logDisplay/README.md +88 -0
  19. package/src/constants/logDisplay/defaults.ts +39 -0
  20. package/src/constants/logDisplay/index.ts +27 -0
  21. package/src/constants/logDisplay/operations/arable.ts +16 -0
  22. package/src/constants/logDisplay/operations/farmersMarket.ts +10 -0
  23. package/src/constants/logDisplay/operations/foodManufacturing.ts +13 -0
  24. package/src/constants/logDisplay/shared/accounting.ts +13 -0
  25. package/src/constants/logDisplay/shared/interactions.ts +13 -0
  26. package/src/constants/logDisplay/shared/rackTemperatures.ts +42 -0
  27. package/src/constants/logTaxonomy.generated.ts +2207 -0
  28. package/src/constants/noteDoc.ts +77 -0
  29. package/src/constants/organization.ts +18 -21
  30. package/src/constants/pageRoute.ts +23 -0
  31. package/src/constants/qrCode.ts +30 -0
  32. package/src/constants/sheet.ts +126 -14
  33. package/src/constants/sms.ts +18 -0
  34. package/src/constants/square.ts +6 -6
  35. package/src/constants/storage.ts +80 -7
  36. package/src/constants/usage.ts +82 -0
  37. package/src/constants/workflowSteps.ts +60 -0
  38. package/src/schemas/editLogEntry.ts +836 -780
  39. package/src/schemas/inboundContact.ts +60 -55
  40. package/src/schemas/logsQuery.ts +55 -49
  41. package/src/types/account.d.ts +4 -1
  42. package/src/types/agentMemory.d.ts +98 -0
  43. package/src/types/agentNote.d.ts +443 -0
  44. package/src/types/billing.d.ts +537 -0
  45. package/src/types/campaign.d.ts +1533 -0
  46. package/src/types/contact.d.ts +15 -0
  47. package/src/types/csvExport.d.ts +213 -0
  48. package/src/types/dataAnalysis.d.ts +44 -0
  49. package/src/types/dataTable.d.ts +115 -403
  50. package/src/types/definitionElement.d.ts +35 -0
  51. package/src/types/docAccess.d.ts +96 -0
  52. package/src/types/dt.d.ts +257 -0
  53. package/src/types/email.d.ts +184 -24
  54. package/src/types/emailReplyReport.d.ts +76 -0
  55. package/src/types/fieldDoc.d.ts +702 -0
  56. package/src/types/fieldDocContract.d.ts +90 -0
  57. package/src/types/inboundContact.d.ts +10 -1
  58. package/src/types/log.d.ts +254 -295
  59. package/src/types/logDisplay.types.ts +85 -0
  60. package/src/types/organization.d.ts +91 -43
  61. package/src/types/pageRoute.d.ts +48 -0
  62. package/src/types/qrCode.d.ts +96 -0
  63. package/src/types/richText.d.ts +81 -0
  64. package/src/types/sheet.d.ts +678 -129
  65. package/src/types/sms.d.ts +38 -0
  66. package/src/types/storage.d.ts +449 -129
  67. package/src/types/usage.d.ts +106 -0
  68. package/src/types/workflow.d.ts +315 -54
  69. package/src/utils/agentMemory.ts +15 -0
  70. package/src/utils/agentNote.ts +850 -0
  71. package/src/utils/aiChat.ts +43 -0
  72. package/src/utils/aiChatWork.ts +64 -0
  73. package/src/utils/billing.ts +37 -0
  74. package/src/utils/campaign.ts +1174 -0
  75. package/src/utils/campaignAI.ts +72 -0
  76. package/src/utils/campaignAccess.ts +239 -0
  77. package/src/utils/campaignEmail.ts +601 -0
  78. package/src/utils/campaignEmailCompiler.ts +372 -0
  79. package/src/utils/campaignEmailImages.ts +60 -0
  80. package/src/utils/campaignEmailStyles.ts +544 -0
  81. package/src/utils/campaignLifecycle.ts +104 -0
  82. package/src/utils/campaignPreview.ts +285 -0
  83. package/src/utils/contact.ts +50 -0
  84. package/src/utils/csvExport.ts +19 -0
  85. package/src/utils/dataTable.ts +95 -618
  86. package/src/utils/dataTableFieldTypeRegistry.ts +106 -0
  87. package/src/utils/dataTableRelativeDate.ts +447 -0
  88. package/src/utils/definitionElement.ts +84 -0
  89. package/src/utils/docAccess.ts +383 -0
  90. package/src/utils/documentName.ts +53 -0
  91. package/src/utils/email.ts +317 -51
  92. package/src/utils/emailReplyReport.test.ts +187 -0
  93. package/src/utils/emailReplyReport.ts +143 -0
  94. package/src/utils/fieldDoc.ts +157 -0
  95. package/src/utils/fieldDocAnswers.ts +128 -0
  96. package/src/utils/fieldDocDefaults.ts +36 -0
  97. package/src/utils/fieldDocProgram.ts +36 -0
  98. package/src/utils/fieldDocSummary.ts +30 -0
  99. package/src/utils/log.ts +276 -192
  100. package/src/utils/logDisplay.helpers.ts +177 -0
  101. package/src/utils/logDisplay.ts +87 -0
  102. package/src/utils/logRegistryValue.ts +90 -0
  103. package/src/utils/logStoreRead.ts +262 -0
  104. package/src/utils/logTaxonomy.helpers.ts +17 -0
  105. package/src/utils/logTaxonomy.ts +76 -0
  106. package/src/utils/logTaxonomyDisplay.ts +395 -0
  107. package/src/utils/noteDoc.ts +609 -0
  108. package/src/utils/organization.ts +337 -84
  109. package/src/utils/pageRoute.ts +71 -0
  110. package/src/utils/qrCode.helpers.ts +189 -0
  111. package/src/utils/qrCode.test.ts +519 -0
  112. package/src/utils/qrCode.ts +273 -0
  113. package/src/utils/richTextHTML.ts +385 -0
  114. package/src/utils/sheet.ts +199 -107
  115. package/src/utils/sheetAxisMove.ts +616 -0
  116. package/src/utils/sheetBootstrap.ts +1402 -0
  117. package/src/utils/sheetCellLiteral.ts +101 -0
  118. package/src/utils/sheetCommand.ts +358 -0
  119. package/src/utils/sheetDesign.ts +705 -0
  120. package/src/utils/sheetExport.ts +186 -0
  121. package/src/utils/sheetFeatureReference.ts +183 -0
  122. package/src/utils/sheetFormulaArgs.ts +168 -0
  123. package/src/utils/sheetFormulaCompile.ts +475 -0
  124. package/src/utils/sheetFormulaConditionalAggregate.ts +254 -0
  125. package/src/utils/sheetFormulaCriteria.ts +656 -0
  126. package/src/utils/sheetFormulaDate.ts +444 -0
  127. package/src/utils/sheetFormulaEvaluation.ts +899 -0
  128. package/src/utils/sheetFormulaEvaluator.ts +997 -0
  129. package/src/utils/sheetFormulaFunctionHandlers.ts +403 -0
  130. package/src/utils/sheetFormulaLogical.ts +116 -0
  131. package/src/utils/sheetFormulaLookup.ts +488 -0
  132. package/src/utils/sheetFormulaMath.ts +48 -0
  133. package/src/utils/sheetFormulaParser.ts +729 -0
  134. package/src/utils/sheetFormulaRange.ts +330 -0
  135. package/src/utils/sheetFormulaReference.ts +703 -0
  136. package/src/utils/sheetFormulaReferenceAggregates.ts +313 -0
  137. package/src/utils/sheetFormulaReferenceDates.ts +237 -0
  138. package/src/utils/sheetFormulaReferenceLogical.ts +330 -0
  139. package/src/utils/sheetFormulaReferenceLookup.ts +341 -0
  140. package/src/utils/sheetFormulaReferenceMath.ts +95 -0
  141. package/src/utils/sheetFormulaReferenceRewrite.ts +220 -0
  142. package/src/utils/sheetFormulaReferenceText.ts +462 -0
  143. package/src/utils/sheetFormulaSyntax.ts +1027 -0
  144. package/src/utils/sheetFormulaText.ts +430 -0
  145. package/src/utils/sheetJournal.ts +200 -0
  146. package/src/utils/sheetNumberFormat.ts +1012 -0
  147. package/src/utils/sheetPreview.ts +68 -0
  148. package/src/utils/sheetSequence.ts +118 -0
  149. package/src/utils/sheetSnapshot.ts +739 -0
  150. package/src/utils/sheetStructureEdit.ts +914 -0
  151. package/src/utils/sheetStructureReferences.ts +389 -0
  152. package/src/utils/square.ts +22 -12
  153. package/src/utils/storage.ts +198 -0
  154. package/src/utils/table-route.ts +127 -11
  155. package/src/utils/time.ts +12 -0
  156. package/src/utils/workflow.ts +334 -40
  157. package/src/utils/workflowLogFingerprint.ts +302 -0
  158. package/src/utils/workflowLogRevisionSnapshot.ts +424 -0
  159. package/src/utils/workflowProgress.ts +280 -0
  160. package/src/utils/workflowTriggers.ts +61 -0
  161. package/tests/agentNote.test.ts +395 -0
  162. package/tests/campaignAI.test.ts +119 -0
  163. package/tests/campaignAccess.test.ts +239 -0
  164. package/tests/campaignEmail.test.ts +441 -0
  165. package/tests/campaignLifecycle.test.ts +134 -0
  166. package/tests/campaignPublication.test.ts +309 -0
  167. package/tests/dataTableFieldTypeRegistry.test.ts +111 -0
  168. package/tests/dataTableRelativeDate.test.ts +412 -0
  169. package/tests/docAccess.test.ts +525 -0
  170. package/tests/editLogEntry.test.ts +112 -0
  171. package/tests/email.test.ts +39 -0
  172. package/tests/fieldDocProgram.test.ts +114 -0
  173. package/tests/logDisplay.fixtures.ts +67 -0
  174. package/tests/logDisplay.test.ts +227 -0
  175. package/tests/noteDoc.test.ts +514 -0
  176. package/tests/richTextHTML.test.ts +185 -0
  177. package/tests/sheetAxisMove.test.ts +352 -0
  178. package/tests/sheetBootstrap.test.ts +1967 -0
  179. package/tests/sheetFeatureReference.test.ts +22 -0
  180. package/tests/sheetFormulaCriteria.test.ts +269 -0
  181. package/tests/sheetFormulaEvaluator.test.ts +468 -0
  182. package/tests/sheetFormulaFunctions.test.ts +538 -0
  183. package/tests/sheetFormulaLanguage.test.ts +361 -0
  184. package/tests/sheetFormulaParity.fixtures.ts +872 -0
  185. package/tests/sheetFormulaParity.test.ts +188 -0
  186. package/tests/sheetFormulaRange.test.ts +167 -0
  187. package/tests/sheetFormulaReference.test.ts +78 -0
  188. package/tests/sheetFormulaReferenceRewrite.test.ts +117 -0
  189. package/tests/sheetFormulaTextDate.test.ts +512 -0
  190. package/tests/sheetSequence.test.ts +22 -0
  191. package/tests/sheetSnapshot.test.ts +134 -0
  192. package/tests/sheetStructureEdit.test.ts +537 -0
  193. package/tests/sheetStructureReferences.test.ts +589 -0
  194. package/tests/workflowLifecycleStatus.test.ts +60 -0
  195. package/tests/workflowLogFingerprint.test.ts +203 -0
  196. package/tests/workflowLogRevisionSnapshot.test.ts +96 -0
  197. package/tests/workflowProgress.test.ts +180 -0
  198. package/tests/workflowTriggers.test.ts +29 -0
  199. package/tsconfig.json +10 -10
  200. package/vitest.config.ts +8 -0
  201. package/src/constants/log-activityTexts.ts +0 -235
  202. package/src/constants/product.ts +0 -42
  203. package/src/constants/report.ts +0 -44
  204. package/src/schemas/organization.ts +0 -65
  205. package/src/schemas/productsQuery.ts +0 -53
  206. package/src/schemas/reportsQuery.ts +0 -20
  207. package/src/types/product.d.ts +0 -84
  208. package/src/types/report.d.ts +0 -290
  209. package/src/utils/product-calEvent.ts +0 -455
  210. package/src/utils/report.ts +0 -158
@@ -1,14 +1,9 @@
1
1
  import { REQUEST_SOURCE_ENUMS } from '@jsb188/app/constants/agent.ts';
2
2
  import type { LabelAndValue } from '@jsb188/app/types/other.d.ts';
3
- import {
4
- LOG_ARABLE_ACTIVITY_ENUMS,
5
- LOG_FARMERS_MARKET_ACTIVITY_ENUMS,
6
- LOG_GROWER_NETWORK_ACTIVITY_ENUMS,
7
- LOG_LIVESTOCK_ACTIVITY_ENUMS,
8
- LOG_SORT_ENUMS
9
- } from '../constants/log.ts';
3
+ import { LOG_SORT_ENUMS } from '../constants/log.ts';
10
4
  import type { OrganizationOperationEnum } from '../types/organization.d.ts';
11
5
  import type { AccountObj } from './account.d.ts';
6
+ import type { AppliedMemoriesSnapshot } from './agentMemory.d.ts';
12
7
  import type { StorageGQL } from './storage.d.ts';
13
8
 
14
9
  /**
@@ -16,351 +11,315 @@ import type { StorageGQL } from './storage.d.ts';
16
11
  */
17
12
 
18
13
  export type LogContentName = 'log' | 'invoice' | 'receipt'; // For UI visuals, client-side only
19
- export type LogSortEnum = typeof LOG_SORT_ENUMS[number];
20
- export type RequestSourceEnum = typeof REQUEST_SOURCE_ENUMS[number];
14
+ export type LogSortEnum = (typeof LOG_SORT_ENUMS)[number];
15
+ export type RequestSourceEnum = (typeof REQUEST_SOURCE_ENUMS)[number];
16
+
17
+ // Activity and group keys are registry data and can be extended per organization.
18
+ export type LogTypeEnum = string;
19
+ export type LogActivityEnum = string;
21
20
 
22
21
  /**
23
- * Arable
22
+ * Structured text translated for one ordered log item.
24
23
  */
25
24
 
26
- export type LogArableTypeEnum =
27
- | 'SEED'
28
- | 'PLANTING'
29
- | 'FIELD'
30
- | 'HARVEST'
31
- | 'POST_HARVEST'
32
- | 'SALES'
33
- | 'WATER'
34
- | 'HYGIENE'
35
- | 'SANITATION'
36
- | 'EQUIPMENT'
37
- | 'BIOSECURITY'
38
- | 'EMPLOYEE';
39
- export type LogArableActivityEnum = typeof LOG_ARABLE_ACTIVITY_ENUMS[number];
25
+ export interface LogTranslationValueText {
26
+ ordinal: number;
27
+ label: string;
28
+ }
40
29
 
41
30
  /**
42
- * Farmers Market
31
+ * Structured text translated for one keyed log field.
43
32
  */
44
33
 
45
- export type LogFarmersMarketTypeEnum = 'MARKET_RECEIPT' | 'MARKET_OPERATION';
46
- export type LogFarmersMarketActivityEnum =
47
- typeof LOG_FARMERS_MARKET_ACTIVITY_ENUMS[number];
34
+ export interface LogTranslationFieldText {
35
+ key: string;
36
+ textValue: string;
37
+ }
48
38
 
49
39
  /**
50
- * Grower Network
40
+ * One locale-specific translation of the current original log text.
51
41
  */
52
42
 
53
- export type LogGrowerNetworkTypeEnum =
54
- | 'WORKER_PRACTICE'
55
- | 'EQUIPMENT'
56
- | 'FIELD'
57
- | 'PRODUCTION_INPUT'
58
- | 'OPERATION';
59
- export type LogGrowerNetworkActivityEnum =
60
- typeof LOG_GROWER_NETWORK_ACTIVITY_ENUMS[number];
43
+ export interface LogTranslationLocaleText {
44
+ translatedAt: string;
45
+ summary: string | null;
46
+ notes: string | null;
47
+ item: string | null;
48
+ values: LogTranslationValueText[];
49
+ fields: LogTranslationFieldText[];
50
+ searchText: string;
51
+ }
61
52
 
62
53
  /**
63
- * Livestock
54
+ * Stored JSONB translation bundle keyed by target language code.
64
55
  */
65
56
 
66
- export type LogLivestockTypeEnum =
67
- | 'SUPPLY_PURCHASE'
68
- | 'LIVESTOCK_LIFE_CYCLE'
69
- | 'LIVESTOCK_TRACKING'
70
- | 'PASTURE_LAND_MANAGEMENT'
71
- | 'LIVESTOCK_HEALTHCARE'
72
- | 'LIVESTOCK_SALE';
73
- export type LogLivestockActivityEnum =
74
- typeof LOG_LIVESTOCK_ACTIVITY_ENUMS[number];
57
+ export interface LogTranslationBundle {
58
+ version: 1;
59
+ sourceHash: string;
60
+ originalLanguage: string;
61
+ // Target languages checked by the detector that required no translated payload.
62
+ noTranslationLanguages: string[];
63
+ texts: Record<string, LogTranslationLocaleText>;
64
+ }
75
65
 
76
66
  /**
77
- * All log types/activities Union
67
+ * GraphQL representation of one locale-specific translation.
78
68
  */
79
69
 
80
- export type LogTypeEnum =
81
- | LogArableTypeEnum
82
- | LogFarmersMarketTypeEnum
83
- | LogGrowerNetworkTypeEnum
84
- | LogLivestockTypeEnum;
85
-
86
- export type LogActivityEnum =
87
- | LogArableActivityEnum
88
- | LogFarmersMarketActivityEnum
89
- | LogGrowerNetworkActivityEnum
90
- | LogLivestockActivityEnum;
70
+ export interface LogTranslationLocaleTextGQL extends LogTranslationLocaleText {
71
+ language: string;
72
+ }
91
73
 
92
74
  /**
93
- * Log metadata
75
+ * GraphQL representation of a stored translation bundle.
94
76
  */
95
77
 
96
- interface LogMetadataBase {
97
- __before: any;
98
- item: string;
99
- date: string;
100
- time: string;
101
- otherParty?: string;
102
- referenceNumber?: string;
103
-
104
- // Interface specific
105
- values?: LabelAndValue[];
106
- voided?: boolean;
107
-
108
- summary?: string;
109
- location?: string;
110
- tax?: number; // Need to be removed and replaced by values[#].tax -- but this will require some logic changes
78
+ export interface LogTranslationBundleGQL extends Omit<LogTranslationBundle, 'noTranslationLanguages' | 'texts'> {
79
+ texts: LogTranslationLocaleTextGQL[];
111
80
  }
112
81
 
113
- export interface LogArableMetadata extends LogMetadataBase {
114
- fieldLocation?: string;
115
- quantity: number;
116
- unit: string;
117
- concentration: number;
118
- concentrationUnit: string;
119
- }
82
+ /**
83
+ * Read-only log text selected for a viewer's display language.
84
+ */
120
85
 
121
- export interface LogFarmersMarketMetadata extends LogMetadataBase {
122
- values: LabelAndValue[];
86
+ export interface LogDisplayText {
87
+ summary: string;
88
+ notes: string | null;
89
+ item: string | null;
90
+ values: LabelAndValue[] | null;
91
+ fields: LogEntryDetailsFieldGQL[] | null;
123
92
  }
124
93
 
125
- export interface LogGrowerNetworkMetadata extends LogMetadataBase {
126
- fieldLocation?: string;
127
- }
94
+ /**
95
+ * Canonical translatable source payload used for hashing and LLM input.
96
+ */
128
97
 
129
- export interface LogLivestockMetadata extends LogMetadataBase {
130
- fieldLocation?: string;
98
+ export interface LogTranslationSourceTexts {
99
+ summary: string | null;
100
+ notes: string | null;
101
+ item: string | null;
102
+ values: LogTranslationValueText[];
103
+ fields: LogTranslationFieldText[];
131
104
  }
132
105
 
133
106
  /**
134
- * Log *_details table
107
+ * Shared log details fields
135
108
  */
136
109
 
137
110
  export interface LogDetailsBase {
138
- id: number | bigint;
139
- childOrg?: {
140
- id: number | bigint;
141
- name: string;
142
- operation?: OrganizationOperationEnum | null;
143
- };
144
- childOrgId?: number | bigint | null;
145
- reportId?: number | bigint | null;
146
- reportSubmissionId?: number | bigint | null;
147
- siteId?: number | bigint | null;
148
- site?: {
149
- id: number | bigint;
150
- name: string;
151
- };
152
- location?: {
153
- name: string;
154
- } | null;
155
- notes: string | null;
156
- translation: string | null;
111
+ id: number | bigint;
112
+ childOrg?: {
113
+ id: number | bigint;
114
+ name: string;
115
+ operation?: OrganizationOperationEnum | null;
116
+ };
117
+ childOrgId?: number | bigint | null;
118
+ fieldDocId?: number | bigint | null;
119
+ fieldDocSubmissionId?: number | bigint | null;
120
+ siteId?: number | bigint | null;
121
+ site?: {
122
+ id: number | bigint;
123
+ name: string;
124
+ };
125
+ location?: {
126
+ name: string;
127
+ } | null;
128
+ notes: string | null;
129
+ translation: LogTranslationBundle | null;
157
130
  }
158
131
 
159
- export interface LogArableDetailsData extends LogDetailsBase {
160
- __table: 'logs_arable';
161
- activity: LogArableActivityEnum;
162
- metadata?: Partial<LogArableMetadata> | null;
132
+ // All operations use one registry-driven details shape.
133
+ export interface LogEntryDetailsData extends LogDetailsBase {
134
+ __table: 'log_entry_details';
135
+ activity: string;
136
+ logType?: string | null;
137
+ fields?: LogEntryDetailsFieldGQL[] | null;
138
+ metadata?: Record<string, any> | null;
163
139
  }
164
140
 
165
- export interface LogFarmersMarketDetailsData extends LogDetailsBase {
166
- __table: 'logs_farmers_market';
167
- activity: LogFarmersMarketActivityEnum;
168
- metadata?: Partial<LogFarmersMarketMetadata> | null;
141
+ // One typed field-def value on a registry-driven operation's log
142
+ export interface LogEntryDetailsFieldGQL {
143
+ key: string;
144
+ fieldType: string | null;
145
+ textValue: string | null;
146
+ numberValue: number | null;
147
+ booleanValue: boolean | null;
148
+ dateValue: string | null;
149
+ datetimeValue: string | null;
150
+ unit: string | null;
169
151
  }
170
152
 
171
- export interface LogGrowerNetworkDetailsData extends LogDetailsBase {
172
- __table: 'logs_grower_network';
173
- activity: LogGrowerNetworkActivityEnum;
174
- animalRisk: boolean;
175
- equipmentRisk: boolean;
176
- fieldRisk: boolean;
177
- contaminationRisk: boolean;
178
- hygieneRisk: boolean;
179
- pestsRisk: boolean;
180
- sanitationRisk: boolean;
181
- metadata?: Partial<LogGrowerNetworkMetadata> | null;
153
+ // One typed field-def value sent when editing a registry-driven log
154
+ export interface LogEntryDetailsFieldInput {
155
+ key: string;
156
+ textValue?: string | null;
157
+ numberValue?: number | null;
158
+ booleanValue?: boolean | null;
159
+ dateValue?: string | null;
160
+ datetimeValue?: string | null;
161
+ unit?: string | null;
162
+ clear?: boolean | null;
182
163
  }
183
164
 
184
- export interface LogLivestockDetailsData extends LogDetailsBase {
185
- __table: 'logs_livestock';
186
- activity: LogLivestockActivityEnum;
187
- metadata?: Partial<LogLivestockMetadata> | null;
165
+ // Details for registry-driven operations; type/activity are registry keys
166
+ export interface LogEntryDetailsGQL {
167
+ __typename: 'LogEntryDetails';
168
+
169
+ id: string;
170
+ type: string | null;
171
+ activity: string;
172
+ notes: string;
173
+
174
+ item: string | null;
175
+ quantity: number | null;
176
+ unit: string | null;
177
+ price: number | null;
178
+ values: LabelAndValue[] | null;
179
+ fields: LogEntryDetailsFieldGQL[] | null;
180
+
181
+ otherParty: string | null;
182
+ referenceNumber: string | null;
183
+ fieldLocation: string | null;
184
+ voided: boolean | null;
188
185
  }
189
186
 
190
- /**
191
- * Log details union - GraphQL
192
- */
193
-
194
- interface LogDetailsBaseGQL {
195
- id: string;
196
- type: LogTypeEnum;
197
- activity: LogActivityEnum;
198
- summary: string | null;
199
- notes: string;
187
+ // Log taxonomy carried by the existing organization bootstrap (registry rows)
188
+ export interface LogTaxonomyGroupGQL {
189
+ key: string;
190
+ label: string | null;
191
+ ordinal: number | null;
192
+ requiredFields: string[] | null;
193
+ orRequiredFields: string[] | null;
200
194
  }
201
195
 
202
- export interface LogArableDetailsGQL extends LogDetailsBaseGQL {
203
- __typename: 'LogArable';
204
-
205
- item: string | null;
206
- quantity: number | null;
207
- unit: string | null;
208
- concentration: number | null;
209
- concentrationUnit: string | null;
210
- fieldLocation: string | null;
211
- otherParty: string | null;
212
- referenceNumber: string | null;
213
- values: LabelAndValue[] | null;
214
- tax: number | null;
215
- voided: boolean | null;
196
+ export interface LogTaxonomyActivityGQL {
197
+ systemOnly?: boolean | null;
198
+ key: string;
199
+ groupKey: string | null;
200
+ agentText: string | null;
201
+ ordinal: number | null;
202
+ requiredFields: string[] | null;
203
+ orRequiredFields: string[] | null;
216
204
  }
217
205
 
218
- export interface LogFarmersMarketDetailsGQL extends LogDetailsBaseGQL {
219
- __typename: 'LogFarmersMarket';
220
-
221
- item: string | null;
222
- otherParty: string | null;
223
- referenceNumber: string | null;
224
- values: LabelAndValue[] | null;
225
- tax: number | null;
226
- voided: boolean | null;
206
+ export interface LogTaxonomyFieldDefGQL {
207
+ key: string;
208
+ fieldType: string;
209
+ required: boolean | null;
210
+ ordinal: number | null;
211
+ agentHint: string | null;
212
+ options: string[] | null;
213
+ allowedUnits: string[] | null;
214
+ includedActivityKeys?: string[] | null;
215
+ excludedActivityKeys?: string[] | null;
216
+ groupKey: string | null;
217
+ activityKey: string | null;
227
218
  }
228
219
 
229
- export interface LogGrowerNetworkDetailsGQL extends LogDetailsBaseGQL {
230
- __typename: 'LogGrowerNetwork';
231
-
232
- animalRisk: boolean;
233
- equipmentRisk: boolean;
234
- fieldRisk: boolean;
235
- contaminationRisk: boolean;
236
- hygieneRisk: boolean;
237
- pestsRisk: boolean;
238
- sanitationRisk: boolean;
239
- otherParty: string | null;
240
- item: string | null;
241
- fieldLocation: string | null;
220
+ export interface LogTaxonomyGQL {
221
+ operation: string;
222
+ groups: LogTaxonomyGroupGQL[];
223
+ activities: LogTaxonomyActivityGQL[];
224
+ fieldDefs: LogTaxonomyFieldDefGQL[];
242
225
  }
243
226
 
244
- export interface LogLivestockDetailsGQL extends LogDetailsBaseGQL {
245
- __typename: 'LogLivestock';
246
-
247
- livestock: string | null;
248
- livestockIdentifiers: string[] | null;
249
- livestockGroup: string | null;
250
- damIdentifier: string | null;
251
- otherParty: string | null;
252
- referenceNumber: string | null;
253
- values: LabelAndValue[] | null;
254
- tax: number | null;
255
- voided: boolean | null;
256
- item: string | null;
257
- quantity: number | null;
258
- unit: string | null;
259
- price: number | null;
260
- fieldLocation: string | null;
261
- }
262
-
263
- /**
264
- * Union type for log details
265
- */
266
-
267
- export type LogMetadataGQL =
268
- | LogArableDetailsGQL
269
- | LogFarmersMarketDetailsGQL
270
- | LogGrowerNetworkDetailsGQL
271
- | LogLivestockDetailsGQL;
272
-
273
227
  /**
274
228
  * GQL data interfaces
275
229
  */
276
230
 
277
231
  export interface LogEntryGQL {
278
- __typename: string;
279
- __deleted?: boolean;
280
-
281
- id: string;
282
- accountId: string;
283
- organizationId: string;
284
- childOrgId: string | null;
285
- childOrgName: string | null;
286
- inboundContactId: string | null;
287
- inboundContactName: string | null;
288
- reportId: string | null;
289
- reportSubmissionId: string | null;
290
- siteId: string | null;
291
- location: string | null;
292
- details: LogMetadataGQL;
293
- summary: string;
294
- source?: RequestSourceEnum | null;
295
- confidence?: number | null;
296
- originalMessage?: string | null;
297
- flagColor?: string | null;
298
-
299
- account: any;
300
- files: StorageGQL[];
301
-
302
- date: string; // ISO date string
303
- createdAt: string; // ISO date string
304
- updatedAt: string; // ISO date string
232
+ __typename: string;
233
+ __deleted?: boolean;
234
+
235
+ id: string;
236
+ cursor?: string | null;
237
+ accountId: string;
238
+ organizationId: string;
239
+ childOrgId: string | null;
240
+ childOrgName: string | null;
241
+ inboundContactId: string | null;
242
+ inboundContactName: string | null;
243
+ inboundContactEmail?: string | null;
244
+ inboundContactPhone?: string | null;
245
+ fieldDocId: string | null;
246
+ fieldDocSubmissionId: string | null;
247
+ siteId: string | null;
248
+ siteName?: string | null;
249
+ location: string | null;
250
+ accountPersonName?: string | null;
251
+ details: LogEntryDetailsGQL;
252
+ summary: string;
253
+ source?: RequestSourceEnum | null;
254
+ confidence?: number | null;
255
+ originalMessage?: string | null;
256
+ flagColor?: string | null;
257
+ translation: LogTranslationBundleGQL | null;
258
+
259
+ account: any;
260
+ files: StorageGQL[];
261
+
262
+ date: string; // ISO date string
263
+ createdAt: string; // ISO date string
264
+ updatedAt: string; // ISO date string
305
265
  }
306
266
 
307
267
  export interface LogEntryInsertObj {
308
- id?: number | bigint; // Only for edits
309
- accountId: number | bigint | null;
310
- organizationId: number | bigint;
311
- childOrgId?: number | bigint | null;
312
- inboundContactId?: number | bigint | null;
313
- emailId?: number | bigint | null;
314
- reportId?: number | bigint | null;
315
- reportSubmissionId?: number | bigint | null;
316
- siteId?: number | bigint | null;
317
- summary: string;
318
- source?: RequestSourceEnum | null;
319
- confidence?: number | null;
320
- originalMessage?: string | null;
321
- details: any;
322
- date: Date;
268
+ id?: number | bigint; // Only for edits
269
+ accountId: number | bigint | null;
270
+ organizationId: number | bigint;
271
+ childOrgId?: number | bigint | null;
272
+ inboundContactId?: number | bigint | null;
273
+ emailId?: number | bigint | null;
274
+ fieldDocId?: number | bigint | null;
275
+ fieldDocSubmissionId?: number | bigint | null;
276
+ siteId?: number | bigint | null;
277
+ summary: string;
278
+ source?: RequestSourceEnum | null;
279
+ confidence?: number | null;
280
+ originalMessage?: string | null;
281
+ appliedMemories?: AppliedMemoriesSnapshot | null;
282
+ details: any;
283
+ date: Date;
323
284
  }
324
285
 
325
286
  export interface LogEntryData {
326
- __table: 'logs';
327
- id: number | bigint;
328
- accountId: number | bigint;
329
- organizationId: number | bigint;
330
- childOrgId?: number | bigint | null;
331
- inboundContactId?: number | bigint | null;
332
- emailId?: number | bigint | null;
333
- inboundContact?: {
334
- id: number | bigint;
335
- personName?: string | null;
336
- } | null;
337
- childOrg?: {
338
- id: number | bigint;
339
- name: string;
340
- operation?: OrganizationOperationEnum | null;
341
- } | null;
342
- reportId?: number | bigint | null;
343
- reportSubmissionId?: number | bigint | null;
344
- siteId?: number | bigint | null;
345
- summary: string;
346
- source?: RequestSourceEnum | null;
347
- confidence?: number | null;
348
- originalMessage?: string | null;
349
- location?: {
350
- name: string;
351
- } | null;
352
- distance?: number; // For vector search
353
- details:
354
- | LogArableDetailsData
355
- | LogFarmersMarketDetailsData
356
- | LogGrowerNetworkDetailsData
357
- | LogLivestockDetailsData;
358
- date: Date;
359
- createdAt: Date;
360
- updatedAt: Date;
361
-
362
- // This is for outputs, but will never be set for inserts
363
- account?: AccountObj;
287
+ revisionNumber?: number;
288
+ __table: 'logs';
289
+ id: number | bigint;
290
+ accountId: number | bigint;
291
+ organizationId: number | bigint;
292
+ childOrgId?: number | bigint | null;
293
+ inboundContactId?: number | bigint | null;
294
+ emailId?: number | bigint | null;
295
+ inboundContact?: {
296
+ id: number | bigint;
297
+ personName?: string | null;
298
+ } | null;
299
+ childOrg?: {
300
+ id: number | bigint;
301
+ name: string;
302
+ operation?: OrganizationOperationEnum | null;
303
+ } | null;
304
+ fieldDocId?: number | bigint | null;
305
+ fieldDocSubmissionId?: number | bigint | null;
306
+ siteId?: number | bigint | null;
307
+ summary: string;
308
+ source?: RequestSourceEnum | null;
309
+ confidence?: number | null;
310
+ originalMessage?: string | null;
311
+ translation?: LogTranslationBundle | null;
312
+ location?: {
313
+ name: string;
314
+ } | null;
315
+ distance?: number; // For vector search
316
+ details: LogEntryDetailsData;
317
+ date: Date;
318
+ createdAt: Date;
319
+ updatedAt: Date;
320
+
321
+ // This is for outputs, but will never be set for inserts
322
+ account?: AccountObj;
364
323
  }
365
324
 
366
325
  /**
@@ -368,12 +327,12 @@ export interface LogEntryData {
368
327
  */
369
328
 
370
329
  export interface FilterLogEntriesArgs {
371
- accountId?: string | null; // Account ID to filter logs by account
372
- siteId?: string | number | bigint | null; // Site ID to filter logs by site
373
- preset?: 'WEEKS_5' | null;
374
- types?: LogTypeEnum[] | null;
375
- activities?: LogActivityEnum[] | null;
376
- startDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
377
- endDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
378
- query?: string | null;
330
+ accountId?: string | null; // Account ID to filter logs by account
331
+ siteId?: string | number | bigint | null; // Site ID to filter logs by site
332
+ preset?: 'WEEKS_5' | null;
333
+ types?: string[] | null;
334
+ activities?: string[] | null;
335
+ startDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
336
+ endDate?: string | null; // CalDate, with dashes (YYYY-MM-DD)
337
+ query?: string | null;
379
338
  }