@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
@@ -0,0 +1,34 @@
1
+ /**
2
+ * FieldDocs; all types
3
+ */
4
+
5
+ export const FIELD_DOC_SORT_OPTS = ['PERIOD_DESC', 'ACTIVITY_DESC'];
6
+
7
+ export const FIELD_DOC_ELEMENT_KINDS = [
8
+ 'SECTION', // Top-level container; all other kinds are children of a section
9
+ 'SUMMARY', // AI-generated summary widget
10
+ 'TITLE', // Static title/paragraph line
11
+ 'LINE_ITEM', // One Q&A line item (numbered)
12
+ 'TEXT', // One standalone text input
13
+ ];
14
+
15
+ // Element kinds that hold an answerable question key
16
+ export const FIELD_DOC_QUESTION_ELEMENT_KINDS = [
17
+ 'TITLE', // Titles accept AI notes/references, but render no input
18
+ 'LINE_ITEM',
19
+ 'TEXT',
20
+ ];
21
+
22
+ export const FIELD_DOC_FREQUENCY_ENUMS = [
23
+ 'DAILY',
24
+ 'WEEKLY',
25
+ 'MONTHLY',
26
+ 'QUARTERLY',
27
+ 'ANNUALLY',
28
+ ];
29
+
30
+ export const FIELD_DOC_STATUS_ENUMS = ['PASS', 'WARNING', 'FAIL'];
31
+
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;
@@ -0,0 +1,113 @@
1
+ /*
2
+ * Single source of truth for realtime GraphQL reactivity keys shared by
3
+ * server emitters (queueWSDataUpdate payloads) and the client cache
4
+ * (fragment observers, PARTIALS_MAP, PAGE_QUERY). Server rules: fragment
5
+ * names start with '$'; query reset targets use GraphQL operation names.
6
+ */
7
+ export const FRAGMENT_NAMES = {
8
+ accountSession: '$accountSessionFragment',
9
+ agentDoc: '$agentDocFragment',
10
+ agentDocFolder: '$agentDocFolderFragment',
11
+ agentMemory: '$agentMemoryFragment',
12
+ aiChat: '$aiChatFragment',
13
+ aiChatMessage: '$aiChatMessageFragment',
14
+ campaign: '$campaignFragment',
15
+ campaignRecipient: '$campaignRecipientFragment',
16
+ campaignResponse: '$campaignResponseFragment',
17
+ campaignTemplate: '$campaignTemplateFragment',
18
+ campaignTemplateElement: '$campaignTemplateElementFragment',
19
+ dataTable: '$dataTableFragment',
20
+ dataTableCell: '$dataTableCellFragment',
21
+ dataTableRow: '$dataTableRowFragment',
22
+ email: '$emailFragment',
23
+ fieldDoc: '$fieldDocFragment',
24
+ fieldDocElementData: '$fieldDocElementDataFragment',
25
+ fieldDocSubmission: '$fieldDocSubmissionFragment',
26
+ generatedFile: '$generatedFileFragment',
27
+ inboundContact: '$inboundContactFragment',
28
+ inboundEmail: '$inboundEmailFragment',
29
+ integrationConnection: '$integrationConnectionFragment',
30
+ logEntry: '$logEntryFragment',
31
+ logEntryDetails: '$logEntryDetailsFragment',
32
+ organization: '$organizationFragment',
33
+ organizationChild: '$organizationChildFragment',
34
+ organizationCompliance: '$organizationComplianceFragment',
35
+ organizationRelationship: '$organizationRelationshipFragment',
36
+ organizationSettings: '$organizationSettingsFragment',
37
+ organizationSite: '$organizationSiteFragment',
38
+ scheduleCalendar: '$scheduleCalendarFragment',
39
+ scheduleOccurrence: '$scheduleOccurrenceFragment',
40
+ scheduleRequest: '$scheduleRequestFragment',
41
+ scheduleResource: '$scheduleResourceFragment',
42
+ scheduleSeries: '$scheduleSeriesFragment',
43
+ sheet: '$sheetFragment',
44
+ sheetCell: '$sheetCellFragment',
45
+ sheetImportJob: '$sheetImportJobFragment',
46
+ sheetTab: '$sheetTabFragment',
47
+ sheetView: '$sheetViewFragment',
48
+ storageFile: '$storageFileFragment',
49
+ workflow: '$workflowFragment',
50
+ workflowRun: '$workflowRunFragment',
51
+ } as const;
52
+
53
+ export type WSFragmentName =
54
+ (typeof FRAGMENT_NAMES)[keyof typeof FRAGMENT_NAMES];
55
+
56
+ /*
57
+ * GraphQL query names shared by structured reset targets and local cache
58
+ * invalidation.
59
+ */
60
+ export const QUERY_NAMES = {
61
+ agentDoc: 'agentDoc',
62
+ agentDocFolders: 'agentDocFolders',
63
+ agentDocs: 'agentDocs',
64
+ aiChat: 'aiChat',
65
+ aiChatMessages: 'aiChatMessages',
66
+ aiChats: 'aiChats',
67
+ campaign: 'campaign',
68
+ campaignResponses: 'campaignResponses',
69
+ campaignTemplate: 'campaignTemplate',
70
+ campaignTemplates: 'campaignTemplates',
71
+ campaigns: 'campaigns',
72
+ childOrganizations: 'childOrganizations',
73
+ fieldDoc: 'fieldDoc',
74
+ fieldDocGroups: 'fieldDocGroups',
75
+ fieldDocs: 'fieldDocs',
76
+ fieldDocSubmissions: 'fieldDocSubmissions',
77
+ generatedFiles: 'generatedFiles',
78
+ agentMemories: 'agentMemories',
79
+ inboundContact: 'inboundContact',
80
+ inboundContacts: 'inboundContacts',
81
+ logEntries: 'logEntries',
82
+ logEntriesForFieldDoc: 'logEntriesForFieldDoc',
83
+ myAccountSessions: 'myAccountSessions',
84
+ myOrganizations: 'myOrganizations',
85
+ organizationMembers: 'organizationMembers',
86
+ organizationMemberSessions: 'organizationMemberSessions',
87
+ organizationSites: 'organizationSites',
88
+ scheduleCalendars: 'scheduleCalendars',
89
+ scheduleOccurrences: 'scheduleOccurrences',
90
+ scheduleRequests: 'scheduleRequests',
91
+ scheduleResources: 'scheduleResources',
92
+ workflowRuns: 'workflowRuns',
93
+ } as const;
94
+
95
+ /*
96
+ * Build one reactive fragment key, e.g. makeFragmentKey(FRAGMENT_NAMES.agentDoc, id)
97
+ * → '$agentDocFragment:<id>'. Used for server reactiveFragmentKeys and client
98
+ * fragment-observer keys (they share the exact same format).
99
+ */
100
+ export function makeFragmentKey(
101
+ name: WSFragmentName,
102
+ dataId: string | number,
103
+ ): string {
104
+ return `${name}:${dataId}`;
105
+ }
106
+
107
+ /*
108
+ * Return the fragment name without its '$' prefix, for consumers keyed by the
109
+ * GraphQL document name (PARTIALS_MAP values, useReactiveFragmentMap).
110
+ */
111
+ export function getFragmentBaseName(name: WSFragmentName): string {
112
+ return name.slice(1);
113
+ }
@@ -1,14 +1,13 @@
1
- export const INTEGRATION_PROVIDERS = [
2
- 'SQUARE',
3
- ] as const;
1
+ export const INTEGRATION_PROVIDERS = ['SQUARE'] as const;
4
2
 
5
- export type IntegrationProviderEnum = typeof INTEGRATION_PROVIDERS[number];
3
+ export type IntegrationProviderEnum = (typeof INTEGRATION_PROVIDERS)[number];
6
4
 
7
5
  export const INTEGRATION_CONNECTION_STATUSES = [
8
- 'CONNECTED',
9
- 'DISCONNECTED',
10
- 'ERROR',
11
- 'REVOKED',
6
+ 'CONNECTED',
7
+ 'DISCONNECTED',
8
+ 'ERROR',
9
+ 'REVOKED',
12
10
  ] as const;
13
11
 
14
- export type IntegrationConnectionStatusEnum = typeof INTEGRATION_CONNECTION_STATUSES[number];
12
+ export type IntegrationConnectionStatusEnum =
13
+ (typeof INTEGRATION_CONNECTION_STATUSES)[number];
@@ -1,415 +1,12 @@
1
- import type { OrganizationOperationEnum } from '../types/organization.d.ts';
2
-
3
- /**
4
- * Constants
1
+ /*
2
+ * Stable non-taxonomy log constants. Registry-backed taxonomy values are
3
+ * generated in logTaxonomy.generated.ts and re-exported here.
5
4
  */
6
5
 
6
+ export * from './logTaxonomy.generated.ts';
7
+
7
8
  export const LOG_SORT_ENUMS = [
8
9
  'GROUP_BY_VENDORS',
9
10
  'DATE_AND_VENDOR_DESC',
10
- 'DATE_DESC',
11
- ];
12
-
13
- export const PURCHASE_ACTIVITIES = [
14
- // # Arable
15
- 'SEED_PURCHASE_INFO',
16
- 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
17
- // # Livestock
18
- 'FEED_PURCHASE',
19
- ];
20
-
21
- export const SALE_ACTIVITIES = [
22
- // # Arable
23
- 'SALE_PRODUCE_ORDER',
24
- 'OTHER_SALE_ORDER',
25
- // # Farmers Market
26
- 'MARKET_CREDIT_RECEIPT',
27
- ];
28
-
29
- /**
30
- * #### #### #### ####
31
- * Arable farming logs
32
- * NOTE: This constant defines all the enums and activities for both GraphQL and database
33
- * #### #### #### ####
34
- */
35
-
36
- export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
37
- [
38
- 'SEED',
39
- [
40
- 'SEED_PURCHASE_INFO',
41
- 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
42
- ],
43
- ],
44
- [
45
- 'PLANTING',
46
- [
47
- 'SEEDING',
48
- 'DIRECT_SEEDING',
49
- 'GREENHOUSE_SEEDING',
50
- 'TRANSPLANTING',
51
- 'SEED_COMPLIANCE_NOTE',
52
- 'OTHER_TRANSPLANT_ACTIVITY',
53
- ],
54
- ],
55
- [
56
- 'FIELD',
57
- [
58
- 'PREPARE_SOIL',
59
- 'IRRIGATION',
60
- 'FERTILIZATION_COMPOST',
61
- 'PROTECT_CROP',
62
- 'MONITOR_CROP',
63
- 'PRUNING',
64
- 'STRUCTURE_MAINTENANCE',
65
- 'PREPARE_HARVEST',
66
- 'OTHER_FIELD_ACTIVITY',
67
- ],
68
- ],
69
- [
70
- 'HARVEST',
71
- [
72
- 'HARVEST_CROP',
73
- 'HARVEST_COUNT',
74
- 'SORT_GRADE',
75
- 'YIELD_LOSS_ESTIMATE',
76
- 'OTHER_HARVEST_ACTIVITY',
77
- ],
78
- ],
79
- [
80
- 'POST_HARVEST',
81
- [
82
- 'POST_HARVEST_HANDLING',
83
- 'POST_HARVEST_PACKAGING',
84
- 'COLD_STORAGE_TEMPERATURE',
85
- 'OTHER_POST_HARVEST_ACTIVITY',
86
- ],
87
- ],
88
- [
89
- 'SALES',
90
- [
91
- 'SALE_PRODUCE_ORDER',
92
- 'OTHER_SALE_ORDER',
93
- ],
94
- ],
95
- [
96
- 'WATER',
97
- [
98
- 'WATER_TESTING',
99
- 'OTHER_WATER_TESTING_ACTIVITY',
100
- ],
101
- ],
102
- [
103
- 'HYGIENE',
104
- [
105
- 'HYGIENE_PROCEDURE',
106
- 'CONTAMINANT_RISK',
107
- 'BODILY_FLUID_CONTAMINATION',
108
- 'SMOKING_EATING_DRINKING_CONTROL',
109
- 'PPE_USAGE',
110
- ],
111
- [
112
- 'FOOD_SAFETY',
113
- 'GLOBAL_GAP',
114
- ],
115
- ],
116
- [
117
- 'SANITATION',
118
- [
119
- 'SANITATION_RISK',
120
- 'SANITATION_CONSTRUCTION_MAINTENANCE',
121
- 'SANITATION_CLEANING',
122
- 'SANITATION_PEST_CONTROL',
123
- ],
124
- [
125
- 'FOOD_SAFETY',
126
- 'GLOBAL_GAP',
127
- ],
128
- ],
129
- [
130
- 'EQUIPMENT',
131
- [
132
- 'EQUIPMENTS_MATERIALS_RISK',
133
- 'EQUIPMENTS_MATERIALS_CLEANING',
134
- ],
135
- [
136
- 'FOOD_SAFETY',
137
- 'GLOBAL_GAP',
138
- ],
139
- ],
140
- [
141
- 'BIOSECURITY',
142
- [
143
- 'ENVIRONMENT_RISK',
144
- ],
145
- [
146
- 'FOOD_SAFETY',
147
- 'GLOBAL_GAP',
148
- ],
149
- ],
150
- [
151
- 'EMPLOYEE',
152
- [
153
- 'EMPLOYEE_ORIENTATION',
154
- 'EMPLOYEE_TRAINING',
155
- 'SICK_EMPLOYEE',
156
- 'EMPLOYEE_INJURED',
157
- 'EMPLOYEE_NOTES',
158
- 'OPERATION_NOTES', // need to change to singular form
159
- ],
160
- [
161
- 'FOOD_SAFETY',
162
- 'GLOBAL_GAP',
163
- ],
164
- ],
165
- ];
166
-
167
- export const LOG_ARABLE_TYPE_ENUMS = ARABLE_ACTIVITIES_GROUPED.map(([type]) => type);
168
-
169
- export const ARABLE_TYPES_TO_TEXT = {
170
- SEED: 'seed & supply purchases',
171
- PLANTING: 'seeding & transplanting',
172
- FIELD: 'field work',
173
- HARVEST: 'harvest activities',
174
- POST_HARVEST: 'post-harvest (cleaning, storage, maintenance, packaging produce, cold storage)',
175
- SALES: 'sales orders',
176
- WATER: 'water testing activities',
177
- EVERYTHING: 'all farming activities', // Not part of enums
178
- };
179
-
180
- export const ARABLE_FOOD_SAFETY_TYPES_TO_TEXT = {
181
- HYGIENE: 'hygiene procdedures',
182
- SANITATION: 'sanitation infrastructure & practices',
183
- EQUIPMENT: 'equipments & materials sanitation',
184
- BIOSECURITY: 'environment & biosecurity measures',
185
- EMPLOYEE: 'employee & operation notes',
186
- EVERYTHING: 'all food safety logs', // Not part of enums
187
- };
188
-
189
- export const LOG_ARABLE_ACTIVITY_ENUMS = ARABLE_ACTIVITIES_GROUPED.reduce(
190
- (acc, a) => acc.concat(a[1]),
191
- [] as string[],
192
- );
193
-
194
- /**
195
- * #### #### #### ####
196
- * Farmers Market logs
197
- * #### #### #### ####
198
- */
199
-
200
- export const FARMERS_MARKET_ACTIVITIES_GROUPED: [string, string[]][] = [
201
- [
202
- 'MARKET_RECEIPT',
203
- [
204
- 'MARKET_CREDIT_RECEIPT',
205
- ],
206
- ],
207
- [
208
- 'MARKET_OPERATION',
209
- [
210
- 'MARKET_ATTENDANCE',
211
- 'MARKET_LOAD_LIST',
212
- 'OPERATION_NOTE'
213
- ],
214
- ],
215
- ];
216
-
217
- export const LOG_FARMERS_MARKET_TYPE_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUPED.map(([type]) => type);
218
-
219
- export const FARMERS_MARKET_TYPES_TO_TEXT = {
220
- MARKET_RECEIPT: 'market credit receipts and coins redemption',
221
- MARKET_OPERATION: 'notes about farmers and markets',
222
- EVERYTHING: 'all market activities', // Not part of enums
223
- };
224
-
225
- export const LOG_FARMERS_MARKET_ACTIVITY_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUPED.reduce(
226
- (acc, a) => acc.concat(a[1]),
227
- [] as string[],
228
- );
229
-
230
- /**
231
- * #### #### #### ####
232
- * Grower Network logs
233
- * #### #### #### ####
234
- */
235
-
236
- export const GROWER_NETWORK_ACTIVITIES_GROUPED: [string, string[]][] = [
237
- [
238
- 'WORKER_PRACTICE',
239
- [
240
- 'HYGIENE_PROCEDURE', // Hygiene, Handwashing
241
- 'SANITATION_PRACTICE', // Sanitation risk, cleanliness/food-contact, and conditions
242
- 'PERSONNEL_PRACTICE' // PPE, training, illness, work practices, break area compliance
243
- ],
244
- ],
245
- [
246
- 'EQUIPMENT',
247
- [
248
- 'EQUIPMENT_MATERIAL', // Equipment, tools and materials risk, handling practices, and conditions
249
- 'PACKAGING_STORAGE', // Packaging, storage, and handling practices
250
- ],
251
- ],
252
- [
253
- 'PRODUCTION_INPUT',
254
- [
255
- 'WATER_INPUT', // Water source, quality, treatment, testing, and application
256
- 'CHEMICAL_INPUT', // Chemical storage, handling, and application
257
- 'FERTILIZER_INPUT', // Fertilizer storage, handling, and application
258
- ],
259
- ],
260
- [
261
- 'FIELD',
262
- [
263
- 'ENVIRONMENT', // Environmental exposure, risks
264
- 'FIELD_CONDITION', // Field conditions, flood zone, errosion risk, and control measures
265
- 'ADJACENT_LAND', // Adjacent land contamination risks and control measures
266
- ],
267
- ],
268
- [
269
- 'OPERATION',
270
- [
271
- 'RECORDKEEPING', // Notes/issues with document control, record availability and accuracy
272
- 'FACILITIES', // Notes/issues with facilities, physical infrastructure, and maintenance
273
- 'OPERATION_NOTE', // Other notes/issues with operations, management, and general observations
274
- ]
275
- ]
276
- ];
277
-
278
- export const LOG_GROWER_NETWORK_TYPE_ENUMS = GROWER_NETWORK_ACTIVITIES_GROUPED.map(([type]) => type);
279
-
280
- export const GROWER_NETWORK_TYPES_TO_TEXT = {
281
- WORKER_PRACTICE: 'hygiene, sanitation, and worker practices',
282
- EQUIPMENT: 'equipments, materials, packaging, storage',
283
- PRODUCTION_INPUT: 'water, chemical, and fertilizer inputs',
284
- FIELD: 'field/land conditions, control measures and environmental risks',
285
- OPERATION: 'recordkeeping, documentation, facilities, and general operations',
286
- EVERYTHING: 'all grower network activities', // Not part of enums
287
- };
288
-
289
- export const LOG_GROWER_NETWORK_ACTIVITY_ENUMS = GROWER_NETWORK_ACTIVITIES_GROUPED.reduce(
290
- (acc, a) => acc.concat(a[1]),
291
- [] as string[],
292
- );
293
-
294
- /**
295
- * #### #### #### ####
296
- * Livestock logs
297
- * #### #### #### ####
298
- */
299
-
300
- export const LIVESTOCK_ACTIVITIES_GROUPED: [string, string[]][] = [
301
- [
302
- 'SUPPLY_PURCHASE',
303
- [
304
- 'FEED_PURCHASE',
305
- 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
306
- ],
307
- ],
308
- [
309
- 'LIVESTOCK_LIFE_CYCLE',
310
- [
311
- 'LIVESTOCK_PURCHASE',
312
- 'LIVESTOCK_BIRTH',
313
- 'LIVESTOCK_REPRODUCTION',
314
- 'LIVESTOCK_DEATH',
315
- 'OTHER_LIVESTOCK_LIFE_CYCLE_ACTIVITY',
316
- ],
317
- ],
318
- [
319
- 'LIVESTOCK_TRACKING',
320
- [
321
- 'LIVESTOCK_GROUP_TRACKING', // moving to different group because of age
322
- 'LIVESTOCK_PASTURE_TRACKING', // where they are in pasture
323
- 'LIVESTOCK_ROTATIONAL_GRAZING',
324
- 'OTHER_LIVESTOCK_TRACKING_ACTIVITY',
325
- ],
326
- ],
327
- [
328
- 'PASTURE_LAND_MANAGEMENT',
329
- [
330
- 'PASTURE_SEEDING',
331
- 'FENCE_MAINTENANCE', // buffer zones/buffer management
332
- 'WATER_SOURCE_MAINTENANCE',
333
- 'OTHER_PASTURE_LAND_MANAGEMENT_ACTIVITY',
334
- ],
335
- ],
336
- [
337
- 'LIVESTOCK_HEALTHCARE',
338
- [
339
- 'LIVESTOCK_VACCINATION',
340
- 'LIVESTOCK_SICK',
341
- 'LIVESTOCK_INJURY',
342
- 'LIVESTOCK_CULL',
343
- 'LIVESTOCK_TREATMENT',
344
- 'OTHER_LIVESTOCK_HEALTHCARE_ACTIVITY',
345
- ],
346
- ],
347
- [
348
- 'LIVESTOCK_SALE',
349
- [
350
- 'LIVESTOCK_SALE',
351
- 'OTHER_LIVESTOCK_SALE_ACTIVITY',
352
- ],
353
- ],
354
- ];
355
-
356
- export const LOG_LIVESTOCK_TYPE_ENUMS = LIVESTOCK_ACTIVITIES_GROUPED.map(([type]) => type);
357
-
358
- export const LIVESTOCK_TYPES_TO_TEXT = {
359
- SUPPLY_PURCHASE: 'supply purchases',
360
- LIVESTOCK_LIFE_CYCLE: 'livestock life cycle events',
361
- LIVESTOCK_TRACKING: 'livestock movement and tracking',
362
- PASTURE_LAND_MANAGEMENT: 'pasture and land management',
363
- LIVESTOCK_HEALTHCARE: 'livestock healthcare',
364
- LIVESTOCK_SALE: 'livestock sale',
365
- EVERYTHING: 'all ranching activities', // Not part of enums
366
- };
367
-
368
- export const LOG_LIVESTOCK_ACTIVITY_ENUMS = LIVESTOCK_ACTIVITIES_GROUPED.reduce(
369
- (acc, a) => acc.concat(a[1]),
370
- [] as string[],
371
- );
372
-
373
- /**
374
- * #### #### #### ####
375
- * All log types & activities
376
- * #### #### #### ####
377
- */
378
-
379
- export const LOG_ANY_TYPE_ENUMS = [
380
- ...LOG_ARABLE_TYPE_ENUMS,
381
- ...LOG_FARMERS_MARKET_TYPE_ENUMS,
382
- ...LOG_GROWER_NETWORK_TYPE_ENUMS,
383
- ...LOG_LIVESTOCK_TYPE_ENUMS,
384
- ].filter((value, index, self) => self.indexOf(value) === index);
385
-
386
- export const LOG_ANY_ACTIVITY_ENUMS = [
387
- ...LOG_ARABLE_ACTIVITY_ENUMS,
388
- ...LOG_FARMERS_MARKET_ACTIVITY_ENUMS,
389
- ...LOG_GROWER_NETWORK_ACTIVITY_ENUMS,
390
- ...LOG_LIVESTOCK_ACTIVITY_ENUMS,
391
- ].filter((value, index, self) => self.indexOf(value) === index);
392
-
393
- export const LOG_ACTIVITIES_BY_OPERATION: Record<OrganizationOperationEnum, any> = {
394
- ARABLE: ARABLE_ACTIVITIES_GROUPED,
395
- FARMERS_MARKET: FARMERS_MARKET_ACTIVITIES_GROUPED,
396
- GROWER_NETWORK: GROWER_NETWORK_ACTIVITIES_GROUPED,
397
- LIVESTOCK: LIVESTOCK_ACTIVITIES_GROUPED,
398
- };
399
-
400
- export const LOG_TYPES_BY_OPERATION: Record<OrganizationOperationEnum, (typeof LOG_ANY_TYPE_ENUMS)[number][]> = {
401
- ARABLE: LOG_ARABLE_TYPE_ENUMS,
402
- FARMERS_MARKET: LOG_FARMERS_MARKET_TYPE_ENUMS,
403
- GROWER_NETWORK: LOG_GROWER_NETWORK_TYPE_ENUMS,
404
- LIVESTOCK: LOG_LIVESTOCK_TYPE_ENUMS,
405
- };
406
-
407
- export const ALL_TEXT_TO_TYPES = {
408
- // Each Object has to be fromEntries() one by one to avoid key conflicts
409
- // (Because, for example: "EVERYTHING" exists in multiple objects)
410
- ...Object.fromEntries(Object.entries(ARABLE_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
411
- ...Object.fromEntries(Object.entries(ARABLE_FOOD_SAFETY_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
412
- ...Object.fromEntries(Object.entries(FARMERS_MARKET_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
413
- ...Object.fromEntries(Object.entries(GROWER_NETWORK_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
414
- ...Object.fromEntries(Object.entries(LIVESTOCK_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
415
- };
11
+ 'DATE_DESC',
12
+ ] as const;
@@ -0,0 +1,19 @@
1
+ // GENERATED FILE — DO NOT EDIT BY HAND.
2
+ // Regenerate with: deno task generate:log-tools (reads the log taxonomy registry).
3
+
4
+ export const LOG_ACTIVITY_GROUP_COLORS: Readonly<Record<string, string>> = {
5
+ CLEANING_AND_SANITATION: 'teal',
6
+ EQUIPMENT: 'indigo',
7
+ FIELD: 'lime',
8
+ HARVEST: 'emerald',
9
+ MARKET_OPERATION: 'rose',
10
+ MARKET_RECEIPT: 'blue',
11
+ OPERATION: 'yellow',
12
+ PLANTING: 'amber',
13
+ POST_HARVEST: 'cyan',
14
+ PRODUCTION_INPUT: 'sky',
15
+ SALES: 'blue',
16
+ SEED: 'brown',
17
+ WATER: 'violet',
18
+ WORKER_PRACTICE: 'purple',
19
+ };