@jsb188/mday 1.1.7 → 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.
- package/package.json +39 -20
- package/src/constants/dataTable.ts +22 -0
- package/src/constants/email.ts +28 -0
- package/src/constants/inboundContact.ts +8 -0
- package/src/constants/integration.ts +14 -0
- package/src/constants/log-activityTexts.ts +54 -28
- package/src/constants/log.ts +82 -38
- package/src/constants/organization.ts +11 -2
- package/src/constants/product.ts +9 -33
- package/src/constants/report.ts +29 -10
- package/src/constants/sheet.ts +20 -0
- package/src/constants/square.ts +16 -0
- package/src/constants/storage.ts +12 -0
- package/src/schemas/editLogEntry.ts +90 -44
- package/src/schemas/inboundContact.ts +72 -0
- package/src/schemas/logsQuery.ts +7 -272
- package/src/schemas/organization.ts +11 -174
- package/src/schemas/productsQuery.ts +2 -94
- package/src/schemas/reportsQuery.ts +8 -95
- package/src/types/account.d.ts +78 -0
- package/src/types/dataTable.d.ts +447 -0
- package/src/types/email.d.ts +71 -0
- package/src/types/inboundContact.d.ts +56 -0
- package/src/types/integration.d.ts +42 -0
- package/src/types/log.d.ts +289 -178
- package/src/types/organization.d.ts +106 -50
- package/src/types/product.d.ts +7 -96
- package/src/types/report.d.ts +239 -152
- package/src/types/sheet.d.ts +298 -0
- package/src/types/storage.d.ts +161 -0
- package/src/types/workflow.d.ts +174 -0
- package/src/utils/dataTable.ts +834 -0
- package/src/utils/email.ts +113 -0
- package/src/utils/log.ts +30 -628
- package/src/utils/organization.ts +227 -44
- package/src/utils/product-calEvent.ts +7 -60
- package/src/utils/report.ts +158 -0
- package/src/utils/sheet.ts +170 -0
- package/src/utils/square.ts +22 -0
- package/src/utils/table-route.ts +146 -0
- package/src/utils/workflow.ts +212 -0
- package/tsconfig.json +12 -0
- package/src/schemas/childOrganizationsQuery.ts +0 -44
- package/src/types/action.d.ts +0 -42
- 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.
|
|
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/
|
|
11
|
-
"./constants/
|
|
12
|
-
"./
|
|
13
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
16
|
-
"./
|
|
17
|
-
"./
|
|
18
|
-
"./types/
|
|
19
|
-
"./types/
|
|
20
|
-
"./
|
|
21
|
-
"./
|
|
22
|
-
"./
|
|
23
|
-
"./
|
|
24
|
-
"./
|
|
25
|
-
"./
|
|
26
|
-
"./
|
|
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.
|
|
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,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: '
|
|
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
|
|
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: '
|
|
55
|
-
OTHER_SALE_ORDER: '
|
|
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
|
-
...
|
|
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
|
|
115
|
+
MARKET_CREDIT_RECEIPT: 'receipts for market credits, coins, or voucher redemption',
|
|
112
116
|
};
|
|
113
117
|
|
|
114
|
-
export const
|
|
118
|
+
export const FARMERS_MARKET_MANAGEMENT_TO_TEXT = {
|
|
115
119
|
MARKET_ATTENDANCE: 'attendance for vendor',
|
|
116
120
|
MARKET_LOAD_LIST: 'vendor load list',
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
...
|
|
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
|
);
|
package/src/constants/log.ts
CHANGED
|
@@ -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
|
-
'
|
|
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
|
-
'
|
|
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
|
|
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
|
-
|
|
183
|
+
EQUIPMENT: 'equipments & materials sanitation',
|
|
205
184
|
BIOSECURITY: 'environment & biosecurity measures',
|
|
206
|
-
|
|
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
|
-
'
|
|
202
|
+
'MARKET_RECEIPT',
|
|
225
203
|
[
|
|
226
204
|
'MARKET_CREDIT_RECEIPT',
|
|
227
205
|
],
|
|
228
206
|
],
|
|
229
207
|
[
|
|
230
|
-
'
|
|
208
|
+
'MARKET_OPERATION',
|
|
231
209
|
[
|
|
232
210
|
'MARKET_ATTENDANCE',
|
|
233
211
|
'MARKET_LOAD_LIST',
|
|
234
|
-
|
|
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
|
-
|
|
245
|
-
|
|
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
|
-
|
|
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'
|
|
33
|
+
export const ROLE_ENUMS = ['GUEST', 'MEMBER', 'MANAGER', 'ADMIN', 'OWNER'];
|
|
25
34
|
|
|
26
35
|
// Role categories (used for reminders)
|
|
27
36
|
|
package/src/constants/product.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
);
|