@jsb188/mday 1.1.5 → 1.1.7

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.
package/package.json CHANGED
@@ -1,22 +1,35 @@
1
1
  {
2
2
  "name": "@jsb188/mday",
3
- "version": "1.1.5",
4
- "description": "Mday specific functions and constants.",
3
+ "version": "1.1.7",
4
+ "description": "Functions and constants for Marketday app only.",
5
5
  "license": "ISC",
6
6
  "author": "jsb188",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  "./constants/log": "./src/constants/log.ts",
10
+ "./constants/organization": "./src/constants/organization.ts",
11
+ "./constants/product": "./src/constants/product.ts",
10
12
  "./schemas/editLogEntry": "./src/schemas/editLogEntry.ts",
11
- "./schemas/logsQueryParam": "./src/schemas/logsQueryParam.ts",
13
+ "./schemas/logsQuery": "./src/schemas/logsQuery.ts",
14
+ "./schemas/organization": "./src/schemas/organization.ts",
15
+ "./schemas/childOrganizationsQuery": "./src/schemas/childOrganizationsQuery.ts",
16
+ "./schemas/productsQuery": "./src/schemas/productsQuery.ts",
17
+ "./schemas/reportsQuery": "./src/schemas/reportsQuery.ts",
18
+ "./types/action.d": "./src/types/action.d.ts",
12
19
  "./types/log.d": "./src/types/log.d.ts",
13
- "./utils/log": "./src/utils/log.ts"
20
+ "./types/organization.d": "./src/types/organization.d.ts",
21
+ "./types/product.d": "./src/types/product.d.ts",
22
+ "./types/report.d": "./src/types/report.d.ts",
23
+ "./utils/log": "./src/utils/log.ts",
24
+ "./utils/organization": "./src/utils/organization.ts",
25
+ "./utils/product-calEvent": "./src/utils/product-calEvent.ts",
26
+ "./utils/route": "./src/utils/route-helpers.ts"
14
27
  },
15
28
  "dependencies": {
16
29
  "zod": "^3.25.67"
17
30
  },
18
31
  "peerDependencies": {
19
- "@jsb188/app": "1.1.5"
32
+ "@jsb188/app": "1.1.7"
20
33
  },
21
34
  "scripts": {
22
35
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -8,19 +8,17 @@ export const WATER_TESTING_ACTIVITY_TO_TEXT = {
8
8
  };
9
9
 
10
10
  /**
11
- * Arable farming activities
11
+ * #### #### #### ####
12
+ * Arable farming
13
+ * #### #### #### ####
12
14
  */
13
15
 
14
- export const ARABLE_FARMING_ACTIVITY_TO_TEXT = {
15
- // # Seed purchase activities
16
- SEED_PURCHASE_INFO: 'seed purchase information',
17
- SEED_COMPLIANCE_NOTE: 'seed compliance notes',
18
- OTHER_SEED_ACTIVITY: 'other seed purchase related activities',
19
-
16
+ export const ARABLE_FARMING_TO_TEXT = {
20
17
  // # Seeding & transplanting activities
21
18
  SEEDING: 'seeding crops',
22
19
  DIRECT_SEEDING: 'direct seeding crops',
23
20
  TRANSPLANTING: 'transplanting crops',
21
+ SEED_COMPLIANCE_NOTE: 'seed compliance notes',
24
22
  OTHER_TRANSPLANT_ACTIVITY: 'other seeding or transplanting activities',
25
23
 
26
24
  // # Field activities
@@ -32,7 +30,7 @@ export const ARABLE_FARMING_ACTIVITY_TO_TEXT = {
32
30
  PRUNING: 'pruning',
33
31
  STRUCTURE_MAINTENANCE: 'trellising, structure maintenance',
34
32
  PREPARE_HARVEST: 'preparing crops for harvest',
35
- OTHER_FIELD_ACTIVITY: 'other field activities',
33
+ OTHER_FIELD_ACTIVITY: 'other field activities or farm operation notes',
36
34
 
37
35
  // # Harvest activities
38
36
  HARVEST_CROP: 'harvesting crops',
@@ -44,26 +42,168 @@ export const ARABLE_FARMING_ACTIVITY_TO_TEXT = {
44
42
  // # Post-harvest activities
45
43
  POST_HARVEST_HANDLING: 'washing, drying, trimming, sorting, or grading produce',
46
44
  POST_HARVEST_PACKAGING: 'packaging, cooling, or moving produce to storage',
47
- OTHER_POST_HARVEST_ACTIVITY: 'other post-harvest activities',
45
+ OTHER_POST_HARVEST_ACTIVITY: 'other post-harvest activities such as cleaning, storage, and maintenance',
46
+ };
47
+
48
+ export const ARABLE_TRANSACTIONS_TO_TEXT = {
49
+ // # Seed purchase activities
50
+ SEED_PURCHASE_INFO: 'seed purchase',
51
+ OTHER_SUPPLY_PURCHASE_ACTIVITY: 'other supply purchase',
48
52
 
49
- // # Sales activities
50
- SALE_TRANSACTION: 'sale transactions',
51
- SALE_DETAILS: 'sale details',
52
- SALE_FEEDBACK: 'sale feedback or issues',
53
- OTHER_SALES_ACTIVITY: 'other sales related activities',
53
+ // # Sales activities
54
+ SALE_PRODUCE_ORDER: 'purchase order (produce)',
55
+ OTHER_SALE_ORDER: 'purchase order (other)',
54
56
  };
55
57
 
56
- export const ARABLE_ACTIVITIES_TO_TEXT = {
57
- // * Arable-specific activities (these have their own functions)
58
+ export const ARABLE_SEED_TO_SALE_TO_TEXT = {
58
59
  COLD_STORAGE_TEMPERATURE: 'checking or changing temperature (cold storage)',
60
+ ...ARABLE_TRANSACTIONS_TO_TEXT,
61
+ ...ARABLE_FARMING_TO_TEXT,
62
+ ...WATER_TESTING_ACTIVITY_TO_TEXT,
63
+ };
59
64
 
60
- // # Farming activities
61
- ...ARABLE_FARMING_ACTIVITY_TO_TEXT,
65
+ // Food Safety is separate from arable farming
62
66
 
63
- // # Water testing activities
64
- ...WATER_TESTING_ACTIVITY_TO_TEXT,
67
+ export const ARABLE_FOOD_SAFETY_TO_TEXT = {
68
+ // # Hygiene
69
+ HYGIENE_PROCEDURE: 'hygiene procedures',
70
+ CONTAMINANT_RISK: 'contaminant risk assessment and mitigation (physical, chemical, microbial)',
71
+ BODILY_FLUID_CONTAMINATION: 'vomitting/bodily fluid decontamination',
72
+ SMOKING_EATING_DRINKING_CONTROL: 'smoking, eating, and drinking control actions',
73
+ PPE_USAGE: 'personal protective equipment (PPE) usage',
74
+
75
+ // # Sanitation
76
+ SANITATION_RISK: 'sanitation risk assessment and mitigation',
77
+ SANITATION_CONSTRUCTION_MAINTENANCE: 'sanitation facilities construction, repairs, or maintenance',
78
+ SANITATION_CLEANING: 'sanitation facilities cleaning activities',
79
+ SANITATION_PEST_CONTROL: 'pest control in sanitation facilities',
80
+
81
+ // # Equpiments & Materials
82
+ EQUIPMENTS_MATERIALS_RISK: 'Materials, food containers/equipments - safety assessment and mitigation',
83
+ EQUIPMENTS_MATERIALS_CLEANING: 'Materials, food containers/equipments - cleaning activities',
84
+
85
+ // # Environment & Biosecurity
86
+ ENVIRONMENT_RISK: 'environmental food safety risk assessment and mitigation',
87
+
88
+ // # Employees
89
+ EMPLOYEE_ORIENTATION: 'new employee orientation',
90
+ EMPLOYEE_TRAINING: 'employee training',
91
+ SICK_EMPLOYEE: 'employee sick report',
92
+ EMPLOYEE_INJURED: 'employee injury report',
93
+ // All texts for same activity names must be same across all operations
94
+ // ie. ARABLE vs FARMERS_MARKET
95
+ EMPLOYEE_NOTES: 'notes about an employee',
96
+ OPERATION_NOTES: 'general operation notes',
97
+ };
98
+
99
+ export const ARABLE_ACTIVITIES_TO_TEXT = {
100
+ ...ARABLE_SEED_TO_SALE_TO_TEXT,
101
+ ...ARABLE_FOOD_SAFETY_TO_TEXT,
102
+ };
103
+
104
+ /**
105
+ * #### #### #### ####
106
+ * Farmers Market
107
+ * #### #### #### ####
108
+ */
109
+
110
+ export const FARMERS_MARKET_RECEIPT_TO_TEXT = {
111
+ MARKET_CREDIT_RECEIPT: 'market credits, coins, or voucher receipts',
112
+ };
113
+
114
+ export const FARMERS_MARKET_OPERATION_TO_TEXT = {
115
+ MARKET_ATTENDANCE: 'attendance for vendor',
116
+ MARKET_LOAD_LIST: 'vendor load list',
117
+ VENDOR_NOTES: 'notes about a vendor',
118
+ // All texts for same activity names must be same across all operations
119
+ // ie. ARABLE vs FARMERS_MARKET
120
+ EMPLOYEE_NOTES: 'notes about an employee',
121
+ FARMERS_MARKET_NOTES: 'notes about farmers market',
65
122
  };
66
123
 
67
- export const TEXT_TO_ARABLE_ACTIVITIES = Object.fromEntries(
68
- Object.entries(ARABLE_ACTIVITIES_TO_TEXT).map(([key, value]) => [value, key]),
69
- ) as Record<string, string>;
124
+ export const FARMERS_MARKET_ACTIVITIES_TO_TEXT = {
125
+ ...FARMERS_MARKET_RECEIPT_TO_TEXT,
126
+ ...FARMERS_MARKET_OPERATION_TO_TEXT,
127
+ };
128
+
129
+ /**
130
+ * #### #### #### ####
131
+ * Livestock ranching
132
+ * #### #### #### ####
133
+ */
134
+
135
+ export const LIVESTOCK_LIFECYCLE_TO_TEXT = {
136
+ // # Livestock life cycle
137
+ LIVESTOCK_PURCHASE: 'livestock purchase',
138
+ LIVESTOCK_BIRTH: 'livestock birth',
139
+ LIVESTOCK_REPRODUCTION: 'livestock reproduction',
140
+ LIVESTOCK_DEATH: 'livestock death',
141
+ OTHER_LIVESTOCK_LIFE_CYCLE_ACTIVITY: 'other livestock life cycle notes',
142
+
143
+ // # Livestock tracking
144
+ LIVESTOCK_GROUP_TRACKING: 'livestock group tracking/movement based on age or other criteria',
145
+ LIVESTOCK_PASTURE_TRACKING: 'livestock pasture tracking/movement', // where they are in pasture
146
+ LIVESTOCK_ROTATIONAL_GRAZING: 'livestock rotational grazing/movement',
147
+ OTHER_LIVESTOCK_TRACKING_ACTIVITY: 'other livestock tracking notes',
148
+
149
+ // # Livestock healthcare
150
+ LIVESTOCK_VACCINATION: 'livestock vaccination',
151
+ LIVESTOCK_SICK: 'livestock sickness',
152
+ LIVESTOCK_INJURY: 'livestock injury',
153
+ LIVESTOCK_CULL: 'livestock culling',
154
+ LIVESTOCK_TREATMENT: 'livestock treatment and recovery',
155
+ OTHER_LIVESTOCK_HEALTHCARE_ACTIVITY: 'other livestock healthcare notes',
156
+
157
+ // # Livestock sale
158
+ LIVESTOCK_SALE: 'livestock sale',
159
+ OTHER_LIVESTOCK_SALE_ACTIVITY: 'other sales activities',
160
+ };
161
+
162
+ export const LIVESTOCK_RANCH_MANAGEMENT_TO_TEXT = {
163
+ // # Ranch management activities
164
+ PASTURE_SEEDING: 'pasture seeding',
165
+ FENCE_MAINTENANCE: 'fence maintenance and buffer management', // buffer zones/buffer management
166
+ WATER_SOURCE_MAINTENANCE: 'water source maintenance',
167
+ OTHER_PASTURE_LAND_MANAGEMENT_ACTIVITY: 'other pasture or ranch operation notes',
168
+ };
169
+
170
+ export const LIVESTOCK_TRANSACTIONS_TO_TEXT = {
171
+ // # Supply purchases
172
+ FEED_PURCHASE: 'feed purchase',
173
+ OTHER_SUPPLY_PURCHASE_ACTIVITY: 'other supply purchase',
174
+ };
175
+
176
+ export const LIVESTOCK_ACTIVITIES_TO_TEXT = {
177
+ ...LIVESTOCK_LIFECYCLE_TO_TEXT,
178
+ ...LIVESTOCK_RANCH_MANAGEMENT_TO_TEXT,
179
+ ...LIVESTOCK_TRANSACTIONS_TO_TEXT,
180
+ };
181
+
182
+ /**
183
+ * #### #### #### ####
184
+ * AI tasks
185
+ * #### #### #### ####
186
+ */
187
+
188
+ export const AI_TASKS_TO_TEXT = {
189
+ // NOTE: If updating this, update [functions-aiTasks.ts] too
190
+ AI_SEND_MESSAGE: 'message',
191
+ AI_REMINDER: 'reminder message',
192
+ AI_CHECK_IN: 'check-in message',
193
+ AI_SCHEDULED_TASK: 'scheduled task',
194
+ };
195
+
196
+ /**
197
+ * Combine all activity texts;
198
+ * NOTE: If one of these Objects have same key and different value,
199
+ * That would cause a *huge* problem in the agent functions.
200
+ */
201
+
202
+ export const AGENT_TEXT_TO_ACTIVITIES: Record<string, string> = Object.fromEntries(
203
+ Object.entries({
204
+ ...ARABLE_ACTIVITIES_TO_TEXT,
205
+ ...FARMERS_MARKET_ACTIVITIES_TO_TEXT,
206
+ ...LIVESTOCK_ACTIVITIES_TO_TEXT,
207
+ ...AI_TASKS_TO_TEXT,
208
+ }).map(([key, value]) => [value, key]),
209
+ );
@@ -1,33 +1,65 @@
1
- import type { LogArableTypeEnum } from '../types/log.d.ts';
2
- import type { OrganizationOperationEnum } from '@jsb188/app/types/organization.d';
1
+ import type { OrganizationOperationEnum } from '../types/organization.d';
3
2
 
4
3
  /**
5
- * IMPORTANT: Keep this list updated.
6
- *
7
- * These are the function call names where the AI can see the args for after calling the function.
8
- * When you include the args for functions such as write_log(), it's unnecessary data that only confuses the AI,
9
- * and makes the AI less accurate.
4
+ * Constants
10
5
  */
11
6
 
12
- // Not using this any more (?)
13
- // export const SHOW_ARGS_FUNCTION_CALL_NAMES = [
14
- // 'search_logs_arable_farming',
15
- // 'search_logs_livestock_farming',
16
- // 'get_arable_farming_logs_file',
17
- // 'get_livestock_farming_logs_file',
18
- // 'find_persons',
19
- // ];
7
+ export const LOG_SORT_ENUMS = [
8
+ 'GROUP_BY_VENDORS',
9
+ 'DATE_AND_VENDOR_DESC',
10
+ 'DATE_DESC',
11
+ ];
12
+
13
+ export const LOG_ACTION_STATUS_ENUMS = [
14
+ 'STARTED',
15
+ 'COMPLETED',
16
+ 'ERRORED',
17
+ 'QUEUED', // Used for AI Tasks
18
+ 'CANCELED', // Used for AI Tasks
19
+ ];
20
+
21
+ export const PURCHASE_ACTIVITIES = [
22
+ // # Arable
23
+ 'SEED_PURCHASE_INFO',
24
+ 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
25
+ // # Livestock
26
+ 'FEED_PURCHASE',
27
+ ];
28
+
29
+ export const SALE_ACTIVITIES = [
30
+ // # Arable
31
+ 'SALE_PRODUCE_ORDER',
32
+ 'OTHER_SALE_ORDER',
33
+ // # Farmers Market
34
+ 'MARKET_CREDIT_RECEIPT',
35
+ ];
20
36
 
21
- // Arable farming logs
22
- // NOTE: This constant defines all the enums and activities for both GraphQL and database
37
+ export const AI_TASKS_GROUP: [string, string[]] = [
38
+ 'AI_TASK',
39
+ [
40
+ 'AI_SEND_MESSAGE',
41
+ 'AI_REMINDER',
42
+ 'AI_CHECK_IN',
43
+ 'AI_SCHEDULED_TASK',
44
+ ],
45
+ ];
46
+
47
+ export const AI_TASK_ACTIVITIES = AI_TASKS_GROUP[1];
48
+
49
+ /**
50
+ * #### #### #### ####
51
+ * Arable farming logs
52
+ * NOTE: This constant defines all the enums and activities for both GraphQL and database
53
+ * #### #### #### ####
54
+ */
23
55
 
24
- export const ARABLE_ACTIVITIES_GROUPED = [
56
+ export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
57
+ AI_TASKS_GROUP,
25
58
  [
26
59
  'SEED',
27
60
  [
28
61
  'SEED_PURCHASE_INFO',
29
- 'SEED_COMPLIANCE_NOTE',
30
- 'OTHER_SEED_ACTIVITY',
62
+ 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
31
63
  ],
32
64
  ],
33
65
  [
@@ -36,6 +68,7 @@ export const ARABLE_ACTIVITIES_GROUPED = [
36
68
  'SEEDING',
37
69
  'DIRECT_SEEDING',
38
70
  'TRANSPLANTING',
71
+ 'SEED_COMPLIANCE_NOTE',
39
72
  'OTHER_TRANSPLANT_ACTIVITY',
40
73
  ],
41
74
  ],
@@ -76,10 +109,8 @@ export const ARABLE_ACTIVITIES_GROUPED = [
76
109
  [
77
110
  'SALES',
78
111
  [
79
- 'SALE_TRANSACTION',
80
- 'SALE_DETAILS',
81
- 'SALE_FEEDBACK',
82
- 'OTHER_SALES_ACTIVITY',
112
+ 'SALE_PRODUCE_ORDER',
113
+ 'OTHER_SALE_ORDER',
83
114
  ],
84
115
  ],
85
116
  [
@@ -89,55 +120,252 @@ export const ARABLE_ACTIVITIES_GROUPED = [
89
120
  'OTHER_WATER_TESTING_ACTIVITY',
90
121
  ],
91
122
  ],
92
- ] as [LogArableTypeEnum, string[]][];
123
+ [
124
+ 'HYGIENE',
125
+ [
126
+ 'HYGIENE_PROCEDURE',
127
+ 'CONTAMINANT_RISK',
128
+ 'BODILY_FLUID_CONTAMINATION',
129
+ 'SMOKING_EATING_DRINKING_CONTROL',
130
+ 'PPE_USAGE',
131
+ ],
132
+ [
133
+ 'FOOD_SAFETY',
134
+ 'GLOBAL_GAP',
135
+ ],
136
+ ],
137
+ [
138
+ 'SANITATION',
139
+ [
140
+ 'SANITATION_RISK',
141
+ 'SANITATION_CONSTRUCTION_MAINTENANCE',
142
+ 'SANITATION_CLEANING',
143
+ 'SANITATION_PEST_CONTROL',
144
+ ],
145
+ [
146
+ 'FOOD_SAFETY',
147
+ 'GLOBAL_GAP',
148
+ ],
149
+ ],
150
+ [
151
+ 'EQUIPMENTS',
152
+ [
153
+ 'EQUIPMENTS_MATERIALS_RISK',
154
+ 'EQUIPMENTS_MATERIALS_CLEANING',
155
+ ],
156
+ [
157
+ 'FOOD_SAFETY',
158
+ 'GLOBAL_GAP',
159
+ ],
160
+ ],
161
+ [
162
+ 'BIOSECURITY',
163
+ [
164
+ 'ENVIRONMENT_RISK',
165
+ ],
166
+ [
167
+ 'FOOD_SAFETY',
168
+ 'GLOBAL_GAP',
169
+ ],
170
+ ],
171
+ [
172
+ 'EMPLOYEES',
173
+ [
174
+ 'EMPLOYEE_ORIENTATION',
175
+ 'EMPLOYEE_TRAINING',
176
+ 'SICK_EMPLOYEE',
177
+ 'EMPLOYEE_INJURED',
178
+ 'EMPLOYEE_NOTES',
179
+ 'OPERATION_NOTES',
180
+ ],
181
+ [
182
+ 'FOOD_SAFETY',
183
+ 'GLOBAL_GAP',
184
+ ],
185
+ ],
186
+ ];
187
+
188
+ export const LOG_ARABLE_TYPE_ENUMS = ARABLE_ACTIVITIES_GROUPED.map(([type]) => type);
93
189
 
94
190
  export const ARABLE_TYPES_TO_TEXT = {
95
- SEED: 'seed purchases',
96
- PLANTING: 'seeding, transplanting activities',
97
- FIELD: 'field activities',
191
+ SEED: 'seed & supply purchases',
192
+ PLANTING: 'seeding & transplanting',
193
+ FIELD: 'field work',
98
194
  HARVEST: 'harvest activities',
99
- POST_HARVEST: 'after-harvest activities such as handling, packaging produce and cold storage',
100
- SALES: 'sales related activities',
195
+ POST_HARVEST: 'post-harvest (cleaning, storage, maintenance, packaging produce, cold storage)',
196
+ SALES: 'sales & purchase orders',
101
197
  WATER: 'water testing activities',
198
+ EVERYTHING: 'all farming activities', // Not part of enums
199
+ };
200
+
201
+ export const ARABLE_FOOD_SAFETY_TYPES_TO_TEXT = {
202
+ HYGIENE: 'hygiene procdedures',
203
+ SANITATION: 'sanitation infrastructure & practices',
204
+ EQUIPMENTS: 'equipments & materials sanitation',
205
+ BIOSECURITY: 'environment & biosecurity measures',
206
+ EMPLOYEES: 'employee & operation notes',
207
+ EVERYTHING: 'all food safety logs', // Not part of enums
208
+ };
209
+
210
+ export const LOG_ARABLE_ACTIVITY_ENUMS = ARABLE_ACTIVITIES_GROUPED.reduce(
211
+ (acc, a) => acc.concat(a[1]),
212
+ [] as string[],
213
+ );
214
+
215
+ /**
216
+ * #### #### #### ####
217
+ * Farmers Market logs
218
+ * #### #### #### ####
219
+ */
102
220
 
103
- // This is not part of the enums
104
- EVERYTHING: 'all activities',
105
- } as Record<LogArableTypeEnum, string>;
221
+ export const FARMERS_MARKET_ACTIVITIES_GROUPED: [string, string[]][] = [
222
+ AI_TASKS_GROUP,
223
+ [
224
+ 'MARKET_RECEIPTS',
225
+ [
226
+ 'MARKET_CREDIT_RECEIPT',
227
+ ],
228
+ ],
229
+ [
230
+ 'MARKET_OPERATIONS',
231
+ [
232
+ 'MARKET_ATTENDANCE',
233
+ 'MARKET_LOAD_LIST',
234
+ 'VENDOR_NOTES',
235
+ 'EMPLOYEE_NOTES',
236
+ 'FARMERS_MARKET_NOTES',
237
+ ],
238
+ ],
239
+ ];
106
240
 
107
- export const TEXT_TO_ARABLE_TYPES = Object.fromEntries(
108
- Object.entries(ARABLE_TYPES_TO_TEXT).map(([key, value]) => [value, key]),
109
- ) as Record<string, string>;
241
+ export const LOG_FARMERS_MARKET_TYPE_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUPED.map(([type]) => type);
110
242
 
111
- export const LOG_ARABLE_TYPE_ENUMS = [
112
- 'SEED',
113
- 'PLANTING',
114
- 'FIELD',
115
- 'HARVEST',
116
- 'POST_HARVEST',
117
- 'SALES',
118
- 'WATER',
119
- ] as LogArableTypeEnum[];
243
+ export const FARMERS_MARKET_TYPES_TO_TEXT = {
244
+ MARKET_RECEIPTS: 'market credit receipts and coins redemption',
245
+ MARKET_OPERATIONS: 'notes about farmers and markets',
246
+ EVERYTHING: 'all market activities', // Not part of enums
247
+ };
120
248
 
121
- export const LOG_ARABLE_ACTIVITY_ENUMS = ARABLE_ACTIVITIES_GROUPED.reduce(
249
+ export const LOG_FARMERS_MARKET_ACTIVITY_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUPED.reduce(
122
250
  (acc, a) => acc.concat(a[1]),
123
251
  [] as string[],
124
252
  );
125
253
 
126
- // All log types & activities
254
+ /**
255
+ * #### #### #### ####
256
+ * Livestock logs
257
+ * #### #### #### ####
258
+ */
127
259
 
128
- export const LOG_ACTIVITIES_GROUPED = [
129
- ...ARABLE_ACTIVITIES_GROUPED,
260
+ export const LIVESTOCK_ACTIVITIES_GROUPED: [string, string[]][] = [
261
+ AI_TASKS_GROUP,
262
+ [
263
+ 'SUPPLY_PURCHASE',
264
+ [
265
+ 'FEED_PURCHASE',
266
+ 'OTHER_SUPPLY_PURCHASE_ACTIVITY',
267
+ ],
268
+ ],
269
+ [
270
+ 'LIVESTOCK_LIFE_CYCLE',
271
+ [
272
+ 'LIVESTOCK_PURCHASE',
273
+ 'LIVESTOCK_BIRTH',
274
+ 'LIVESTOCK_REPRODUCTION',
275
+ 'LIVESTOCK_DEATH',
276
+ 'OTHER_LIVESTOCK_LIFE_CYCLE_ACTIVITY',
277
+ ],
278
+ ],
279
+ [
280
+ 'LIVESTOCK_TRACKING',
281
+ [
282
+ 'LIVESTOCK_GROUP_TRACKING', // moving to different group because of age
283
+ 'LIVESTOCK_PASTURE_TRACKING', // where they are in pasture
284
+ 'LIVESTOCK_ROTATIONAL_GRAZING',
285
+ 'OTHER_LIVESTOCK_TRACKING_ACTIVITY',
286
+ ],
287
+ ],
288
+ [
289
+ 'PASTURE_LAND_MANAGEMENT',
290
+ [
291
+ 'PASTURE_SEEDING',
292
+ 'FENCE_MAINTENANCE', // buffer zones/buffer management
293
+ 'WATER_SOURCE_MAINTENANCE',
294
+ 'OTHER_PASTURE_LAND_MANAGEMENT_ACTIVITY',
295
+ ],
296
+ ],
297
+ [
298
+ 'LIVESTOCK_HEALTHCARE',
299
+ [
300
+ 'LIVESTOCK_VACCINATION',
301
+ 'LIVESTOCK_SICK',
302
+ 'LIVESTOCK_INJURY',
303
+ 'LIVESTOCK_CULL',
304
+ 'LIVESTOCK_TREATMENT',
305
+ 'OTHER_LIVESTOCK_HEALTHCARE_ACTIVITY',
306
+ ],
307
+ ],
308
+ [
309
+ 'LIVESTOCK_SALE',
310
+ [
311
+ 'LIVESTOCK_SALE',
312
+ 'OTHER_LIVESTOCK_SALE_ACTIVITY',
313
+ ],
314
+ ],
130
315
  ];
131
316
 
132
- export const LOG_TYPE_ENUMS = [
317
+ export const LOG_LIVESTOCK_TYPE_ENUMS = LIVESTOCK_ACTIVITIES_GROUPED.map(([type]) => type);
318
+
319
+ export const LIVESTOCK_TYPES_TO_TEXT = {
320
+ SUPPLY_PURCHASE: 'supply purchases',
321
+ LIVESTOCK_LIFE_CYCLE: 'livestock life cycle events',
322
+ LIVESTOCK_TRACKING: 'livestock movement and tracking',
323
+ PASTURE_LAND_MANAGEMENT: 'pasture and land management',
324
+ LIVESTOCK_HEALTHCARE: 'livestock healthcare',
325
+ LIVESTOCK_SALE: 'livestock sale',
326
+ EVERYTHING: 'all ranching activities', // Not part of enums
327
+ };
328
+
329
+ export const LOG_LIVESTOCK_ACTIVITY_ENUMS = LIVESTOCK_ACTIVITIES_GROUPED.reduce(
330
+ (acc, a) => acc.concat(a[1]),
331
+ [] as string[],
332
+ );
333
+
334
+ /**
335
+ * #### #### #### ####
336
+ * All log types & activities
337
+ * #### #### #### ####
338
+ */
339
+
340
+ export const LOG_ANY_TYPE_ENUMS = [
133
341
  ...LOG_ARABLE_TYPE_ENUMS,
134
- ];
342
+ ...LOG_FARMERS_MARKET_TYPE_ENUMS,
343
+ ...LOG_LIVESTOCK_TYPE_ENUMS,
344
+ ].filter((value, index, self) => self.indexOf(value) === index);
135
345
 
136
- export const LOG_ACTIVITY_ENUMS = [
346
+ export const LOG_ANY_ACTIVITY_ENUMS = [
137
347
  ...LOG_ARABLE_ACTIVITY_ENUMS,
138
- ];
348
+ ...LOG_FARMERS_MARKET_ACTIVITY_ENUMS,
349
+ ...LOG_LIVESTOCK_ACTIVITY_ENUMS,
350
+ ].filter((value, index, self) => self.indexOf(value) === index);
351
+
352
+ export const LOG_ACTIVITIES_BY_OPERATION: Record<OrganizationOperationEnum, any> = {
353
+ ARABLE: ARABLE_ACTIVITIES_GROUPED,
354
+ FARMERS_MARKET: FARMERS_MARKET_ACTIVITIES_GROUPED,
355
+ LIVESTOCK: LIVESTOCK_ACTIVITIES_GROUPED,
356
+ };
139
357
 
140
- export const LOG_TYPES_BY_OPERATION = {
358
+ export const LOG_TYPES_BY_OPERATION: Record<OrganizationOperationEnum, (typeof LOG_ANY_TYPE_ENUMS)[number][]> = {
141
359
  ARABLE: LOG_ARABLE_TYPE_ENUMS,
142
- LIVESTOCK: [],
143
- } as Record<OrganizationOperationEnum, (typeof LOG_TYPE_ENUMS)[number][]>;
360
+ FARMERS_MARKET: LOG_FARMERS_MARKET_TYPE_ENUMS,
361
+ LIVESTOCK: LOG_LIVESTOCK_TYPE_ENUMS,
362
+ };
363
+
364
+ export const ALL_TEXT_TO_TYPES = {
365
+ // Each Object has to be fromEntries() one by one to avoid key conflicts
366
+ // (Because, for example: "EVERYTHING" exists in multiple objects)
367
+ ...Object.fromEntries(Object.entries(ARABLE_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
368
+ ...Object.fromEntries(Object.entries(ARABLE_FOOD_SAFETY_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
369
+ ...Object.fromEntries(Object.entries(FARMERS_MARKET_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
370
+ ...Object.fromEntries(Object.entries(LIVESTOCK_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
371
+ };