@jsb188/mday 1.1.8 → 1.1.10

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 (45) hide show
  1. package/package.json +39 -20
  2. package/src/constants/dataTable.ts +22 -0
  3. package/src/constants/email.ts +28 -0
  4. package/src/constants/inboundContact.ts +8 -0
  5. package/src/constants/integration.ts +14 -0
  6. package/src/constants/log-activityTexts.ts +54 -28
  7. package/src/constants/log.ts +82 -38
  8. package/src/constants/organization.ts +11 -2
  9. package/src/constants/product.ts +9 -33
  10. package/src/constants/report.ts +29 -10
  11. package/src/constants/sheet.ts +20 -0
  12. package/src/constants/square.ts +16 -0
  13. package/src/constants/storage.ts +12 -0
  14. package/src/schemas/editLogEntry.ts +90 -44
  15. package/src/schemas/inboundContact.ts +72 -0
  16. package/src/schemas/logsQuery.ts +7 -272
  17. package/src/schemas/organization.ts +11 -174
  18. package/src/schemas/productsQuery.ts +2 -94
  19. package/src/schemas/reportsQuery.ts +8 -95
  20. package/src/types/account.d.ts +78 -0
  21. package/src/types/dataTable.d.ts +447 -0
  22. package/src/types/email.d.ts +71 -0
  23. package/src/types/inboundContact.d.ts +56 -0
  24. package/src/types/integration.d.ts +42 -0
  25. package/src/types/log.d.ts +289 -178
  26. package/src/types/organization.d.ts +106 -50
  27. package/src/types/product.d.ts +7 -96
  28. package/src/types/report.d.ts +239 -152
  29. package/src/types/sheet.d.ts +298 -0
  30. package/src/types/storage.d.ts +161 -0
  31. package/src/types/workflow.d.ts +174 -0
  32. package/src/utils/dataTable.ts +834 -0
  33. package/src/utils/email.ts +113 -0
  34. package/src/utils/log.ts +30 -628
  35. package/src/utils/organization.ts +227 -44
  36. package/src/utils/product-calEvent.ts +7 -60
  37. package/src/utils/report.ts +158 -0
  38. package/src/utils/sheet.ts +170 -0
  39. package/src/utils/square.ts +22 -0
  40. package/src/utils/table-route.ts +146 -0
  41. package/src/utils/workflow.ts +212 -0
  42. package/tsconfig.json +12 -0
  43. package/src/schemas/childOrganizationsQuery.ts +0 -44
  44. package/src/types/action.d.ts +0 -42
  45. package/src/utils/route-helpers.ts +0 -583
package/package.json CHANGED
@@ -1,35 +1,54 @@
1
1
  {
2
2
  "name": "@jsb188/mday",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
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
- "./constants/log": "./src/constants/log.ts",
10
- "./constants/organization": "./src/constants/organization.ts",
11
- "./constants/product": "./src/constants/product.ts",
12
- "./schemas/editLogEntry": "./src/schemas/editLogEntry.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",
19
- "./types/log.d": "./src/types/log.d.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"
9
+ "./constants/log.ts": "./src/constants/log.ts",
10
+ "./constants/log-activityTexts.ts": "./src/constants/log-activityTexts.ts",
11
+ "./constants/email.ts": "./src/constants/email.ts",
12
+ "./constants/organization.ts": "./src/constants/organization.ts",
13
+ "./constants/product.ts": "./src/constants/product.ts",
14
+ "./constants/dataTable.ts": "./src/constants/dataTable.ts",
15
+ "./constants/sheet.ts": "./src/constants/sheet.ts",
16
+ "./constants/storage.ts": "./src/constants/storage.ts",
17
+ "./types/email.d.ts": "./src/types/email.d.ts",
18
+ "./types/inboundContact.d.ts": "./src/types/inboundContact.d.ts",
19
+ "./types/storage.d.ts": "./src/types/storage.d.ts",
20
+ "./schemas/editLogEntry.ts": "./src/schemas/editLogEntry.ts",
21
+ "./schemas/inboundContact.ts": "./src/schemas/inboundContact.ts",
22
+ "./schemas/logsQuery.ts": "./src/schemas/logsQuery.ts",
23
+ "./schemas/organization.ts": "./src/schemas/organization.ts",
24
+ "./schemas/childOrganizationsQuery.ts": "./src/schemas/childOrganizationsQuery.ts",
25
+ "./schemas/productsQuery.ts": "./src/schemas/productsQuery.ts",
26
+ "./schemas/reportsQuery.ts": "./src/schemas/reportsQuery.ts",
27
+ "./types/account.d.ts": "./src/types/account.d.ts",
28
+ "./types/integration.d.ts": "./src/types/integration.d.ts",
29
+ "./types/log.d.ts": "./src/types/log.d.ts",
30
+ "./types/organization.d.ts": "./src/types/organization.d.ts",
31
+ "./types/product.d.ts": "./src/types/product.d.ts",
32
+ "./types/report.d.ts": "./src/types/report.d.ts",
33
+ "./types/dataTable.d.ts": "./src/types/dataTable.d.ts",
34
+ "./types/sheet.d.ts": "./src/types/sheet.d.ts",
35
+ "./types/workflow.d.ts": "./src/types/workflow.d.ts",
36
+ "./utils/email.ts": "./src/utils/email.ts",
37
+ "./utils/log.ts": "./src/utils/log.ts",
38
+ "./utils/organization.ts": "./src/utils/organization.ts",
39
+ "./utils/product-calEvent.ts": "./src/utils/product-calEvent.ts",
40
+ "./utils/report.ts": "./src/utils/report.ts",
41
+ "./utils/dataTable.ts": "./src/utils/dataTable.ts",
42
+ "./utils/sheet.ts": "./src/utils/sheet.ts",
43
+ "./utils/table-route.ts": "./src/utils/table-route.ts",
44
+ "./utils/square.ts": "./src/utils/square.ts",
45
+ "./utils/workflow.ts": "./src/utils/workflow.ts"
27
46
  },
28
47
  "dependencies": {
29
48
  "zod": "^3.25.67"
30
49
  },
31
50
  "peerDependencies": {
32
- "@jsb188/app": "1.1.8"
51
+ "@jsb188/app": "1.1.10"
33
52
  },
34
53
  "scripts": {
35
54
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,22 @@
1
+ export const DATA_TABLE_FIELD_TYPE_ENUMS = [
2
+ 'TEXT',
3
+ 'ID',
4
+ 'ID_OR_TEXT',
5
+ 'NUMBER',
6
+ 'PRICE',
7
+ 'BOOLEAN',
8
+ 'DATE',
9
+ 'WEEK_OF_MON',
10
+ 'WEEK_OF_SUN',
11
+ 'DATETIME',
12
+ 'SELECT',
13
+ 'SELECT_OR_TEXT',
14
+ 'MULTI_SELECT',
15
+ 'JSON',
16
+ ] as const;
17
+
18
+ export const DATA_TABLE_COLUMN_WIDTH = 160;
19
+ export const DATA_TABLE_COLUMN_MIN_WIDTH = 72;
20
+ export const DATA_TABLE_COLUMN_MAX_WIDTH = 640;
21
+ export const DATA_TABLE_HUMAN_LABEL_MAX_LENGTH = 70;
22
+ export const DATA_TABLE_ROWS_MAX_LIMIT = 400;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Email handling lifecycle statuses.
3
+ */
4
+ export const EMAIL_STATUS_ENUMS = [
5
+ 'RECEIVED',
6
+ 'QUEUED',
7
+ 'SUPERSEDED',
8
+ 'PROCESSING',
9
+ 'COMPLETED',
10
+ 'IGNORED',
11
+ 'ERRORED',
12
+ ] as const;
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
+ /**
23
+ * Inbound email body display source options.
24
+ */
25
+ export const INBOUND_EMAIL_BODY_FORMAT_ENUMS = [
26
+ 'TEXT',
27
+ 'HTML_TEXT',
28
+ ] as const;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Inbound contacts; sorting options
3
+ */
4
+
5
+ export const INBOUND_CONTACT_SORT_ENUMS = [
6
+ 'UPDATED_AT_DESC',
7
+ 'PERSON_NAME_ASC',
8
+ ] as const;
@@ -0,0 +1,14 @@
1
+ export const INTEGRATION_PROVIDERS = [
2
+ 'SQUARE',
3
+ ] as const;
4
+
5
+ export type IntegrationProviderEnum = typeof INTEGRATION_PROVIDERS[number];
6
+
7
+ export const INTEGRATION_CONNECTION_STATUSES = [
8
+ 'CONNECTED',
9
+ 'DISCONNECTED',
10
+ 'ERROR',
11
+ 'REVOKED',
12
+ ] as const;
13
+
14
+ export type IntegrationConnectionStatusEnum = typeof INTEGRATION_CONNECTION_STATUSES[number];
@@ -17,8 +17,9 @@ export const ARABLE_FARMING_TO_TEXT = {
17
17
  // # Seeding & transplanting activities
18
18
  SEEDING: 'seeding crops',
19
19
  DIRECT_SEEDING: 'direct seeding crops',
20
+ GREENHOUSE_SEEDING: 'greenhouse seeding crops',
20
21
  TRANSPLANTING: 'transplanting crops',
21
- SEED_COMPLIANCE_NOTE: 'seed compliance notes',
22
+ SEED_COMPLIANCE_NOTE: 'seeding compliance notes',
22
23
  OTHER_TRANSPLANT_ACTIVITY: 'other seeding or transplanting activities',
23
24
 
24
25
  // # Field activities
@@ -45,19 +46,22 @@ export const ARABLE_FARMING_TO_TEXT = {
45
46
  OTHER_POST_HARVEST_ACTIVITY: 'other post-harvest activities such as cleaning, storage, and maintenance',
46
47
  };
47
48
 
48
- export const ARABLE_TRANSACTIONS_TO_TEXT = {
49
+ export const ARABLE_PURCHASES_TO_TEXT = {
49
50
  // # Seed purchase activities
50
51
  SEED_PURCHASE_INFO: 'seed purchase',
51
52
  OTHER_SUPPLY_PURCHASE_ACTIVITY: 'other supply purchase',
53
+ };
52
54
 
55
+ export const ARABLE_SALES_TO_TEXT = {
53
56
  // # Sales activities
54
- SALE_PRODUCE_ORDER: 'purchase order (produce)',
55
- OTHER_SALE_ORDER: 'purchase order (other)',
57
+ SALE_PRODUCE_ORDER: 'sales order (produce)',
58
+ OTHER_SALE_ORDER: 'sales order (other)',
56
59
  };
57
60
 
58
61
  export const ARABLE_SEED_TO_SALE_TO_TEXT = {
59
62
  COLD_STORAGE_TEMPERATURE: 'checking or changing temperature (cold storage)',
60
- ...ARABLE_TRANSACTIONS_TO_TEXT,
63
+ ...ARABLE_PURCHASES_TO_TEXT,
64
+ ...ARABLE_SALES_TO_TEXT,
61
65
  ...ARABLE_FARMING_TO_TEXT,
62
66
  ...WATER_TESTING_ACTIVITY_TO_TEXT,
63
67
  };
@@ -108,22 +112,58 @@ export const ARABLE_ACTIVITIES_TO_TEXT = {
108
112
  */
109
113
 
110
114
  export const FARMERS_MARKET_RECEIPT_TO_TEXT = {
111
- MARKET_CREDIT_RECEIPT: 'market credits, coins, or voucher receipts',
115
+ MARKET_CREDIT_RECEIPT: 'receipts for market credits, coins, or voucher redemption',
112
116
  };
113
117
 
114
- export const FARMERS_MARKET_OPERATION_TO_TEXT = {
118
+ export const FARMERS_MARKET_MANAGEMENT_TO_TEXT = {
115
119
  MARKET_ATTENDANCE: 'attendance for vendor',
116
120
  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',
121
+ };
122
+
123
+ export const FARMERS_MARKET_NOTE_TO_TEXT = {
124
+ OPERATION_NOTE: 'general operation notes',
122
125
  };
123
126
 
124
127
  export const FARMERS_MARKET_ACTIVITIES_TO_TEXT = {
125
128
  ...FARMERS_MARKET_RECEIPT_TO_TEXT,
126
- ...FARMERS_MARKET_OPERATION_TO_TEXT,
129
+ ...FARMERS_MARKET_MANAGEMENT_TO_TEXT,
130
+ ...FARMERS_MARKET_NOTE_TO_TEXT,
131
+ };
132
+
133
+ /**
134
+ * #### #### #### ####
135
+ * Grower Network
136
+ * #### #### #### ####
137
+ */
138
+
139
+ export const GROWER_NETWORK_INSPECTION_TO_TEXT = {
140
+ // # WORKER_PRACTICE
141
+ HYGIENE_PROCEDURE: 'worker hygiene procedures',
142
+ SANITATION_PRACTICE: 'sanitation conditions and cleanliness',
143
+ PERSONNEL_PRACTICE: 'PPE compliance, worker practices, training, illness',
144
+
145
+ // # EQUIPMENT
146
+ EQUIPMENT_MATERIAL: 'production and harvest equipments/tools/materials',
147
+ PACKAGING_STORAGE: 'packaging and storage of produce',
148
+
149
+ // # FIELD
150
+ ENVIRONMENT: 'environmental exposure and wildlife activity',
151
+ FIELD_CONDITION: 'field conditions, flood zones, erosion',
152
+ ADJACENT_LAND: 'adjacent land observations, risks',
153
+
154
+ // # PRODUCTION_INPUT
155
+ WATER_INPUT: 'water source, quality, treatment, testing, and application',
156
+ CHEMICAL_INPUT: 'chemical inputs handling and application',
157
+ FERTILIZER_INPUT: 'fertilizer inputs handling and application',
158
+
159
+ // # OPERATION
160
+ RECORDKEEPING: 'document control, record availability, and accuracy',
161
+ FACILITIES: 'facilities, physical infrastructure, and maintenance',
162
+ OPERATION_NOTE: 'general operation notes',
163
+ };
164
+
165
+ export const GROWER_NETWORK_ACTIVITIES_TO_TEXT = {
166
+ ...GROWER_NETWORK_INSPECTION_TO_TEXT,
127
167
  };
128
168
 
129
169
  /**
@@ -179,20 +219,6 @@ export const LIVESTOCK_ACTIVITIES_TO_TEXT = {
179
219
  ...LIVESTOCK_TRANSACTIONS_TO_TEXT,
180
220
  };
181
221
 
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
222
  /**
197
223
  * Combine all activity texts;
198
224
  * NOTE: If one of these Objects have same key and different value,
@@ -203,7 +229,7 @@ export const AGENT_TEXT_TO_ACTIVITIES: Record<string, string> = Object.fromEntri
203
229
  Object.entries({
204
230
  ...ARABLE_ACTIVITIES_TO_TEXT,
205
231
  ...FARMERS_MARKET_ACTIVITIES_TO_TEXT,
232
+ ...GROWER_NETWORK_ACTIVITIES_TO_TEXT,
206
233
  ...LIVESTOCK_ACTIVITIES_TO_TEXT,
207
- ...AI_TASKS_TO_TEXT,
208
234
  }).map(([key, value]) => [value, key]),
209
235
  );
@@ -1,4 +1,4 @@
1
- import type { OrganizationOperationEnum } from '../types/organization.d';
1
+ import type { OrganizationOperationEnum } from '../types/organization.d.ts';
2
2
 
3
3
  /**
4
4
  * Constants
@@ -10,14 +10,6 @@ export const LOG_SORT_ENUMS = [
10
10
  'DATE_DESC',
11
11
  ];
12
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
13
  export const PURCHASE_ACTIVITIES = [
22
14
  // # Arable
23
15
  'SEED_PURCHASE_INFO',
@@ -34,18 +26,6 @@ export const SALE_ACTIVITIES = [
34
26
  'MARKET_CREDIT_RECEIPT',
35
27
  ];
36
28
 
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
29
  /**
50
30
  * #### #### #### ####
51
31
  * Arable farming logs
@@ -54,7 +34,6 @@ export const AI_TASK_ACTIVITIES = AI_TASKS_GROUP[1];
54
34
  */
55
35
 
56
36
  export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
57
- AI_TASKS_GROUP,
58
37
  [
59
38
  'SEED',
60
39
  [
@@ -67,6 +46,7 @@ export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
67
46
  [
68
47
  'SEEDING',
69
48
  'DIRECT_SEEDING',
49
+ 'GREENHOUSE_SEEDING',
70
50
  'TRANSPLANTING',
71
51
  'SEED_COMPLIANCE_NOTE',
72
52
  'OTHER_TRANSPLANT_ACTIVITY',
@@ -76,7 +56,6 @@ export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
76
56
  'FIELD',
77
57
  [
78
58
  'PREPARE_SOIL',
79
- // 'PLANTING', // <!--------------------------------- Deprecated & moved to "PLANTING" category
80
59
  'IRRIGATION',
81
60
  'FERTILIZATION_COMPOST',
82
61
  'PROTECT_CROP',
@@ -148,7 +127,7 @@ export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
148
127
  ],
149
128
  ],
150
129
  [
151
- 'EQUIPMENTS',
130
+ 'EQUIPMENT',
152
131
  [
153
132
  'EQUIPMENTS_MATERIALS_RISK',
154
133
  'EQUIPMENTS_MATERIALS_CLEANING',
@@ -169,14 +148,14 @@ export const ARABLE_ACTIVITIES_GROUPED: [string, string[], string[]?][] = [
169
148
  ],
170
149
  ],
171
150
  [
172
- 'EMPLOYEES',
151
+ 'EMPLOYEE',
173
152
  [
174
153
  'EMPLOYEE_ORIENTATION',
175
154
  'EMPLOYEE_TRAINING',
176
155
  'SICK_EMPLOYEE',
177
156
  'EMPLOYEE_INJURED',
178
157
  'EMPLOYEE_NOTES',
179
- 'OPERATION_NOTES',
158
+ 'OPERATION_NOTES', // need to change to singular form
180
159
  ],
181
160
  [
182
161
  'FOOD_SAFETY',
@@ -193,7 +172,7 @@ export const ARABLE_TYPES_TO_TEXT = {
193
172
  FIELD: 'field work',
194
173
  HARVEST: 'harvest activities',
195
174
  POST_HARVEST: 'post-harvest (cleaning, storage, maintenance, packaging produce, cold storage)',
196
- SALES: 'sales & purchase orders',
175
+ SALES: 'sales orders',
197
176
  WATER: 'water testing activities',
198
177
  EVERYTHING: 'all farming activities', // Not part of enums
199
178
  };
@@ -201,9 +180,9 @@ export const ARABLE_TYPES_TO_TEXT = {
201
180
  export const ARABLE_FOOD_SAFETY_TYPES_TO_TEXT = {
202
181
  HYGIENE: 'hygiene procdedures',
203
182
  SANITATION: 'sanitation infrastructure & practices',
204
- EQUIPMENTS: 'equipments & materials sanitation',
183
+ EQUIPMENT: 'equipments & materials sanitation',
205
184
  BIOSECURITY: 'environment & biosecurity measures',
206
- EMPLOYEES: 'employee & operation notes',
185
+ EMPLOYEE: 'employee & operation notes',
207
186
  EVERYTHING: 'all food safety logs', // Not part of enums
208
187
  };
209
188
 
@@ -219,21 +198,18 @@ export const LOG_ARABLE_ACTIVITY_ENUMS = ARABLE_ACTIVITIES_GROUPED.reduce(
219
198
  */
220
199
 
221
200
  export const FARMERS_MARKET_ACTIVITIES_GROUPED: [string, string[]][] = [
222
- AI_TASKS_GROUP,
223
201
  [
224
- 'MARKET_RECEIPTS',
202
+ 'MARKET_RECEIPT',
225
203
  [
226
204
  'MARKET_CREDIT_RECEIPT',
227
205
  ],
228
206
  ],
229
207
  [
230
- 'MARKET_OPERATIONS',
208
+ 'MARKET_OPERATION',
231
209
  [
232
210
  'MARKET_ATTENDANCE',
233
211
  'MARKET_LOAD_LIST',
234
- 'VENDOR_NOTES',
235
- 'EMPLOYEE_NOTES',
236
- 'FARMERS_MARKET_NOTES',
212
+ 'OPERATION_NOTE'
237
213
  ],
238
214
  ],
239
215
  ];
@@ -241,8 +217,8 @@ export const FARMERS_MARKET_ACTIVITIES_GROUPED: [string, string[]][] = [
241
217
  export const LOG_FARMERS_MARKET_TYPE_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUPED.map(([type]) => type);
242
218
 
243
219
  export const FARMERS_MARKET_TYPES_TO_TEXT = {
244
- MARKET_RECEIPTS: 'market credit receipts and coins redemption',
245
- MARKET_OPERATIONS: 'notes about farmers and markets',
220
+ MARKET_RECEIPT: 'market credit receipts and coins redemption',
221
+ MARKET_OPERATION: 'notes about farmers and markets',
246
222
  EVERYTHING: 'all market activities', // Not part of enums
247
223
  };
248
224
 
@@ -251,6 +227,70 @@ export const LOG_FARMERS_MARKET_ACTIVITY_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUP
251
227
  [] as string[],
252
228
  );
253
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
+
254
294
  /**
255
295
  * #### #### #### ####
256
296
  * Livestock logs
@@ -258,7 +298,6 @@ export const LOG_FARMERS_MARKET_ACTIVITY_ENUMS = FARMERS_MARKET_ACTIVITIES_GROUP
258
298
  */
259
299
 
260
300
  export const LIVESTOCK_ACTIVITIES_GROUPED: [string, string[]][] = [
261
- AI_TASKS_GROUP,
262
301
  [
263
302
  'SUPPLY_PURCHASE',
264
303
  [
@@ -340,24 +379,28 @@ export const LOG_LIVESTOCK_ACTIVITY_ENUMS = LIVESTOCK_ACTIVITIES_GROUPED.reduce(
340
379
  export const LOG_ANY_TYPE_ENUMS = [
341
380
  ...LOG_ARABLE_TYPE_ENUMS,
342
381
  ...LOG_FARMERS_MARKET_TYPE_ENUMS,
382
+ ...LOG_GROWER_NETWORK_TYPE_ENUMS,
343
383
  ...LOG_LIVESTOCK_TYPE_ENUMS,
344
384
  ].filter((value, index, self) => self.indexOf(value) === index);
345
385
 
346
386
  export const LOG_ANY_ACTIVITY_ENUMS = [
347
387
  ...LOG_ARABLE_ACTIVITY_ENUMS,
348
388
  ...LOG_FARMERS_MARKET_ACTIVITY_ENUMS,
389
+ ...LOG_GROWER_NETWORK_ACTIVITY_ENUMS,
349
390
  ...LOG_LIVESTOCK_ACTIVITY_ENUMS,
350
391
  ].filter((value, index, self) => self.indexOf(value) === index);
351
392
 
352
393
  export const LOG_ACTIVITIES_BY_OPERATION: Record<OrganizationOperationEnum, any> = {
353
394
  ARABLE: ARABLE_ACTIVITIES_GROUPED,
354
395
  FARMERS_MARKET: FARMERS_MARKET_ACTIVITIES_GROUPED,
396
+ GROWER_NETWORK: GROWER_NETWORK_ACTIVITIES_GROUPED,
355
397
  LIVESTOCK: LIVESTOCK_ACTIVITIES_GROUPED,
356
398
  };
357
399
 
358
400
  export const LOG_TYPES_BY_OPERATION: Record<OrganizationOperationEnum, (typeof LOG_ANY_TYPE_ENUMS)[number][]> = {
359
401
  ARABLE: LOG_ARABLE_TYPE_ENUMS,
360
402
  FARMERS_MARKET: LOG_FARMERS_MARKET_TYPE_ENUMS,
403
+ GROWER_NETWORK: LOG_GROWER_NETWORK_TYPE_ENUMS,
361
404
  LIVESTOCK: LOG_LIVESTOCK_TYPE_ENUMS,
362
405
  };
363
406
 
@@ -367,5 +410,6 @@ export const ALL_TEXT_TO_TYPES = {
367
410
  ...Object.fromEntries(Object.entries(ARABLE_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
368
411
  ...Object.fromEntries(Object.entries(ARABLE_FOOD_SAFETY_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
369
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])),
370
414
  ...Object.fromEntries(Object.entries(LIVESTOCK_TYPES_TO_TEXT).map(([key, value]) => [value, key])),
371
415
  };
@@ -11,7 +11,10 @@ export const OPERATION_ENUMS = [
11
11
  'GROWER_NETWORK',
12
12
 
13
13
  // External orgs
14
+ 'RESTAURANT',
14
15
  'VENDOR',
16
+ 'WHOLESALE_FOOD',
17
+ 'UNKNOWN',
15
18
  ];
16
19
 
17
20
  export const PARENT_ORG_OPERATIONS = [
@@ -19,9 +22,15 @@ export const PARENT_ORG_OPERATIONS = [
19
22
  'GROWER_NETWORK',
20
23
  ];
21
24
 
22
- // Employee ACL
25
+ export const AUDITOR_ORG_OPERATIONS = [
26
+ 'GROWER_NETWORK',
27
+ ];
28
+
29
+ // Membership roles
30
+ // Order of roles matter (for visualization)
31
+ // second item is default value
23
32
 
24
- export const ROLE_ENUMS = ['MEMBER', 'MANAGER', 'ADMIN', 'OWNER', 'GUEST']; // first is default value
33
+ export const ROLE_ENUMS = ['GUEST', 'MEMBER', 'MANAGER', 'ADMIN', 'OWNER'];
25
34
 
26
35
  // Role categories (used for reminders)
27
36
 
@@ -3,8 +3,6 @@
3
3
  */
4
4
 
5
5
  export const PRODUCT_TYPES = [
6
- 'LIVESTOCK',
7
- 'CAL_EVENTS',
8
6
  'FOOD_SAFETY',
9
7
  'GLOBAL_GAP',
10
8
  ];
@@ -18,49 +16,27 @@ export const FEATURES_BY_OPERATION = {
18
16
  'NORMAL_LOGGING', // First item is always the default
19
17
  'FOOD_SAFETY',
20
18
  'GLOBAL_GAP',
21
- 'ORGANIC_CERTIFICATION',
22
19
  ],
23
20
  FARMERS_MARKET: [
24
21
  'NORMAL_LOGGING',
25
- 'CAL_EVENTS',
26
- 'CAL_EVENTS_ATTENDANCE',
27
- 'CAL_EVENTS_LOAD_LIST',
22
+ 'MARKET_ATTENDANCE',
28
23
  ],
29
24
  LIVESTOCK: [
30
25
  'NORMAL_LOGGING',
31
- 'LIVESTOCK', // DEPRECATED
32
- 'LIVESTOCK_MANAGEMENT',
33
26
  ],
27
+ GROWER_NETWORK: [
28
+ 'NORMAL_LOGGING',
29
+ 'SITE_INSPECTION'
30
+ ]
34
31
  };
35
32
 
36
33
  export const PRODUCT_FEATURES = [
37
34
  ...FEATURES_BY_OPERATION.ARABLE,
38
35
  ...FEATURES_BY_OPERATION.FARMERS_MARKET,
39
36
  ...FEATURES_BY_OPERATION.LIVESTOCK,
37
+ ...FEATURES_BY_OPERATION.GROWER_NETWORK,
40
38
  ].filter((value, index, self) => self.indexOf(value) === index);
41
39
 
42
- export const ACTIVITY_TO_FEATURE_MAP = {
43
- CAL_EVENTS_ATTENDANCE: ['MARKET_ATTENDANCE'],
44
- CAL_EVENTS_LOAD_LIST: ['MARKET_LOAD_LIST'],
45
- };
46
-
47
- /**
48
- * Products; Livestock
49
- */
50
-
51
- export const PRODUCT_LIVESTOCK_TYPES = [
52
- 'CATTLE',
53
- 'HORSE',
54
- 'GOAT',
55
- 'SHEEP',
56
- 'POULTRY',
57
- 'PIG',
58
- 'OTHER_LIVESTOCK',
59
- ];
60
-
61
- export const PRODUCT_LIVESTOCK_STATUS = [
62
- 'ALIVE',
63
- 'SICK',
64
- 'SOLD',
65
- 'DECEASED',
66
- ];
40
+ export const PRODUCT_FEATURES_WORKFLOW = PRODUCT_FEATURES.filter((feature) =>
41
+ !['NORMAL_LOGGING'].includes(feature)
42
+ );