@agroyaar/sdk 1.1.6-2 → 1.2.0
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/dist/index.cjs +33 -25
- package/dist/index.d.ts +18 -125
- package/dist/index.mjs +33 -25
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,11 @@ var mappers = {
|
|
|
87
87
|
machineUsageIds: response.machineUsageIds
|
|
88
88
|
}),
|
|
89
89
|
getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
|
|
90
|
+
getSpeedChangesChart: (response) => ({
|
|
91
|
+
speed: response.speed,
|
|
92
|
+
date: response.date
|
|
93
|
+
}),
|
|
94
|
+
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
90
95
|
getMechanization: (response) => ({
|
|
91
96
|
id: response.id,
|
|
92
97
|
commonName: response.commonName,
|
|
@@ -99,20 +104,8 @@ var mappers = {
|
|
|
99
104
|
variety: mappers.getMechanizationVariety(response.variety)
|
|
100
105
|
}),
|
|
101
106
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
speed: response.speed,
|
|
105
|
-
heading: response.heading,
|
|
106
|
-
latitude: response.latitude,
|
|
107
|
-
longitude: response.longitude,
|
|
108
|
-
fuelLevel: response.fuelLevel,
|
|
109
|
-
engineRpm: response.engineRpm,
|
|
110
|
-
deviceCode: response.deviceCode,
|
|
111
|
-
stateEngine: response.stateEngine,
|
|
112
|
-
engineOilPressure: response.engineOilPressure,
|
|
113
|
-
engineWaterTemperature: response.engineWaterTemperature,
|
|
114
|
-
batteryChargePercentage: response.batteryChargePercentage,
|
|
115
|
-
mechanizationId: response.mechanizationId
|
|
107
|
+
SubmitTrackingDeviceData: (response) => ({
|
|
108
|
+
deviceCode: response.deviceCode
|
|
116
109
|
})
|
|
117
110
|
};
|
|
118
111
|
|
|
@@ -136,10 +129,26 @@ var createMechanizationServices = (client) => ({
|
|
|
136
129
|
return import_ts_belt.R.Error(err);
|
|
137
130
|
}
|
|
138
131
|
},
|
|
139
|
-
|
|
132
|
+
getSpeedChangesChartData: async ({
|
|
133
|
+
farmerId,
|
|
134
|
+
mechanizationId
|
|
135
|
+
}) => {
|
|
136
|
+
try {
|
|
137
|
+
const { data } = await client.get(
|
|
138
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
139
|
+
);
|
|
140
|
+
return import_ts_belt.R.Ok(
|
|
141
|
+
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
142
|
+
);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
145
|
+
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
getMechanizations: async ({ kindName }) => {
|
|
140
149
|
try {
|
|
141
150
|
const { data } = await client.get(
|
|
142
|
-
`/farmers
|
|
151
|
+
`/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
|
|
143
152
|
);
|
|
144
153
|
return import_ts_belt.R.Ok(
|
|
145
154
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
@@ -150,21 +159,20 @@ var createMechanizationServices = (client) => ({
|
|
|
150
159
|
return import_ts_belt.R.Error(err);
|
|
151
160
|
}
|
|
152
161
|
},
|
|
153
|
-
|
|
162
|
+
SubmitTrackingDeviceCode: async ({
|
|
154
163
|
farmerId,
|
|
155
|
-
mechanizationId
|
|
164
|
+
mechanizationId,
|
|
165
|
+
deviceCode
|
|
156
166
|
}) => {
|
|
157
167
|
try {
|
|
158
|
-
const { data } = await client.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
mappers.getMotorizedMechanizationSensors(
|
|
162
|
-
data.result.data.motorizedMechanizationSensors
|
|
163
|
-
)
|
|
168
|
+
const { data } = await client.put(
|
|
169
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
170
|
+
{ deviceCode }
|
|
164
171
|
);
|
|
172
|
+
return import_ts_belt.R.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
165
173
|
} catch (error) {
|
|
166
174
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
167
|
-
console.error("
|
|
175
|
+
console.error("SubmitTrackingDevice API Error:", err);
|
|
168
176
|
return import_ts_belt.R.Error(err);
|
|
169
177
|
}
|
|
170
178
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,94 +11,7 @@ type Branded<T, B> = Brand<B> & T;
|
|
|
11
11
|
declare namespace Identifiers {
|
|
12
12
|
type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
|
|
13
13
|
type MechanizationId = Branded<string, "mechanizationId-id">;
|
|
14
|
-
type
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type FarmerDTO = {
|
|
18
|
-
id: string;
|
|
19
|
-
username: string;
|
|
20
|
-
firstName: string;
|
|
21
|
-
lastName: string;
|
|
22
|
-
fullName: string;
|
|
23
|
-
phoneNumber: string;
|
|
24
|
-
nationalCode: string;
|
|
25
|
-
farmerCode: string;
|
|
26
|
-
birthDate: string;
|
|
27
|
-
avatar: string;
|
|
28
|
-
province: string;
|
|
29
|
-
provinceId: number;
|
|
30
|
-
city: string;
|
|
31
|
-
cityId: number;
|
|
32
|
-
zone: string;
|
|
33
|
-
address: string;
|
|
34
|
-
postalCode: number;
|
|
35
|
-
role: string;
|
|
36
|
-
productsIds: number[];
|
|
37
|
-
status: string;
|
|
38
|
-
walletBalance: number;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type MechanizationAnswerOptionDTO = {
|
|
42
|
-
id: string;
|
|
43
|
-
label: string;
|
|
44
|
-
mechanizationQuestionId: string;
|
|
45
|
-
};
|
|
46
|
-
type InformationDTO = {
|
|
47
|
-
id: string;
|
|
48
|
-
status: Status;
|
|
49
|
-
answerOptions: MechanizationAnswerOptionDTO;
|
|
50
|
-
answerValue: string;
|
|
51
|
-
mechanizationId: string;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
declare namespace ServerResponseTypes {
|
|
55
|
-
namespace Dashboard {
|
|
56
|
-
type MechanizationVarietyDTO = {
|
|
57
|
-
id: string;
|
|
58
|
-
name: string;
|
|
59
|
-
code: string;
|
|
60
|
-
iconURL: string;
|
|
61
|
-
kind: VarietyKind;
|
|
62
|
-
kindName: MechanizationType;
|
|
63
|
-
seasonsProcess: MechanizationSeasonProcessKind[];
|
|
64
|
-
seasonProcessIds: string[];
|
|
65
|
-
machinesUsage: MechanizationMachineUsageKind[];
|
|
66
|
-
machineUsageIds: string[];
|
|
67
|
-
mechanizationQuestions: string[];
|
|
68
|
-
};
|
|
69
|
-
type MechanizationDTO = {
|
|
70
|
-
id: string;
|
|
71
|
-
model: string;
|
|
72
|
-
commonName: string;
|
|
73
|
-
avatarURL: string;
|
|
74
|
-
manufactureYear: string;
|
|
75
|
-
code: string;
|
|
76
|
-
kind: VarietyKind;
|
|
77
|
-
kindName: MechanizationType;
|
|
78
|
-
deviceCode: string;
|
|
79
|
-
status: Status;
|
|
80
|
-
farmer: FarmerDTO;
|
|
81
|
-
farmerId: string;
|
|
82
|
-
variety: MechanizationVarietyDTO;
|
|
83
|
-
information: InformationDTO[];
|
|
84
|
-
};
|
|
85
|
-
type MotorizedMechanizationSensorsDTO = {
|
|
86
|
-
id: string;
|
|
87
|
-
speed: number;
|
|
88
|
-
heading: string;
|
|
89
|
-
latitude: number;
|
|
90
|
-
longitude: number;
|
|
91
|
-
fuelLevel: number;
|
|
92
|
-
engineRpm: number;
|
|
93
|
-
deviceCode: string;
|
|
94
|
-
stateEngine: boolean;
|
|
95
|
-
engineOilPressure: boolean;
|
|
96
|
-
engineWaterTemperature: string;
|
|
97
|
-
batteryChargePercentage: string;
|
|
98
|
-
mechanizationId: string;
|
|
99
|
-
mechanization: MechanizationDTO;
|
|
100
|
-
};
|
|
101
|
-
}
|
|
14
|
+
type FarmerId = Branded<string, "farmer-id">;
|
|
102
15
|
}
|
|
103
16
|
|
|
104
17
|
type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
|
|
@@ -108,14 +21,6 @@ type MechanizationType = "MOTORIZED" | "NON_MOTORIZED";
|
|
|
108
21
|
type MechanizationSeasonProcessType = "GROWING" | "HARVESTING" | "PLANTING" | "TRANSPORTATION";
|
|
109
22
|
type MechanizationMachineUsageType = "BALER" | "CRUSHING" | "CRUST_BREAKER" | "FERTILIZER_SPREADER" | "FORAGE_COLLECTOR" | "FURROWER" | "GRASS_CUTTER" | "GRINDING" | "HARVESTING" | "LEVELING" | "LOADER" | "MULTI_PURPOSE" | "SEEDER" | "SPRAYER" | "TILLAGE" | "TRANSPORTATION" | "WEEDER";
|
|
110
23
|
|
|
111
|
-
type ServerResponse<T> = {
|
|
112
|
-
message: string;
|
|
113
|
-
code: string;
|
|
114
|
-
data: T;
|
|
115
|
-
};
|
|
116
|
-
type BaseResponse<T> = {
|
|
117
|
-
result: ServerResponse<T>;
|
|
118
|
-
};
|
|
119
24
|
type Status = {
|
|
120
25
|
id: string;
|
|
121
26
|
label: string;
|
|
@@ -136,15 +41,6 @@ type MechanizationMachineUsageKind = {
|
|
|
136
41
|
label: string;
|
|
137
42
|
name: MechanizationMachineUsageType;
|
|
138
43
|
};
|
|
139
|
-
type MechanizationListData = {
|
|
140
|
-
meta: Record<string, unknown>;
|
|
141
|
-
totalItems: number;
|
|
142
|
-
mechanizations: ServerResponseTypes.Dashboard.MechanizationDTO[];
|
|
143
|
-
};
|
|
144
|
-
type MotorizedMechanizationSensorsData = {
|
|
145
|
-
meta: Record<string, unknown>;
|
|
146
|
-
motorizedMechanizationSensors: ServerResponseTypes.Dashboard.MotorizedMechanizationSensorsDTO;
|
|
147
|
-
};
|
|
148
44
|
|
|
149
45
|
type MechanizationVarietyModel = {
|
|
150
46
|
id: Identifiers.MechanizationVarietyId;
|
|
@@ -169,27 +65,23 @@ type MechanizationModel = {
|
|
|
169
65
|
variety: MechanizationVarietyModel;
|
|
170
66
|
};
|
|
171
67
|
type MechanizationVariables = {
|
|
172
|
-
farmerId: string;
|
|
173
68
|
kindName: MechanizationType;
|
|
174
69
|
};
|
|
175
|
-
type
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
fuelLevel: number;
|
|
182
|
-
engineRpm: number;
|
|
70
|
+
type SubmitTrackingDeviceModel = {
|
|
71
|
+
deviceCode: string;
|
|
72
|
+
};
|
|
73
|
+
type SubmitTrackingDeviceVariables = {
|
|
74
|
+
farmerId: Identifiers.FarmerId;
|
|
75
|
+
mechanizationId: Identifiers.MechanizationId;
|
|
183
76
|
deviceCode: string;
|
|
184
|
-
stateEngine: boolean;
|
|
185
|
-
engineOilPressure: boolean;
|
|
186
|
-
engineWaterTemperature: string;
|
|
187
|
-
batteryChargePercentage: string;
|
|
188
|
-
mechanizationId: string;
|
|
189
77
|
};
|
|
190
|
-
type
|
|
191
|
-
|
|
192
|
-
|
|
78
|
+
type SpeedChangesChartModel = {
|
|
79
|
+
speed: number;
|
|
80
|
+
date: string;
|
|
81
|
+
};
|
|
82
|
+
type SpeedChangesChartVariables = {
|
|
83
|
+
farmerId: Identifiers.FarmerId;
|
|
84
|
+
mechanizationId: Identifiers.MechanizationId;
|
|
193
85
|
};
|
|
194
86
|
|
|
195
87
|
type ClientConfig = {
|
|
@@ -201,10 +93,11 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
201
93
|
dashboardServices: {
|
|
202
94
|
mechanization: {
|
|
203
95
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
|
|
204
|
-
|
|
205
|
-
|
|
96
|
+
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Ok<SpeedChangesChartModel[]> | undefined>;
|
|
97
|
+
getMechanizations: ({ kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
98
|
+
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SubmitTrackingDeviceModel>>;
|
|
206
99
|
};
|
|
207
100
|
};
|
|
208
101
|
};
|
|
209
102
|
|
|
210
|
-
export { type
|
|
103
|
+
export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type ServiceType, type SpeedChangesChartModel, type SpeedChangesChartVariables, type Status, type StatusType, type SubmitTrackingDeviceModel, type SubmitTrackingDeviceVariables, type TaskType, type VarietyKind, createSDK };
|
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,11 @@ var mappers = {
|
|
|
51
51
|
machineUsageIds: response.machineUsageIds
|
|
52
52
|
}),
|
|
53
53
|
getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
|
|
54
|
+
getSpeedChangesChart: (response) => ({
|
|
55
|
+
speed: response.speed,
|
|
56
|
+
date: response.date
|
|
57
|
+
}),
|
|
58
|
+
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
54
59
|
getMechanization: (response) => ({
|
|
55
60
|
id: response.id,
|
|
56
61
|
commonName: response.commonName,
|
|
@@ -63,20 +68,8 @@ var mappers = {
|
|
|
63
68
|
variety: mappers.getMechanizationVariety(response.variety)
|
|
64
69
|
}),
|
|
65
70
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
speed: response.speed,
|
|
69
|
-
heading: response.heading,
|
|
70
|
-
latitude: response.latitude,
|
|
71
|
-
longitude: response.longitude,
|
|
72
|
-
fuelLevel: response.fuelLevel,
|
|
73
|
-
engineRpm: response.engineRpm,
|
|
74
|
-
deviceCode: response.deviceCode,
|
|
75
|
-
stateEngine: response.stateEngine,
|
|
76
|
-
engineOilPressure: response.engineOilPressure,
|
|
77
|
-
engineWaterTemperature: response.engineWaterTemperature,
|
|
78
|
-
batteryChargePercentage: response.batteryChargePercentage,
|
|
79
|
-
mechanizationId: response.mechanizationId
|
|
71
|
+
SubmitTrackingDeviceData: (response) => ({
|
|
72
|
+
deviceCode: response.deviceCode
|
|
80
73
|
})
|
|
81
74
|
};
|
|
82
75
|
|
|
@@ -100,10 +93,26 @@ var createMechanizationServices = (client) => ({
|
|
|
100
93
|
return R.Error(err);
|
|
101
94
|
}
|
|
102
95
|
},
|
|
103
|
-
|
|
96
|
+
getSpeedChangesChartData: async ({
|
|
97
|
+
farmerId,
|
|
98
|
+
mechanizationId
|
|
99
|
+
}) => {
|
|
100
|
+
try {
|
|
101
|
+
const { data } = await client.get(
|
|
102
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
103
|
+
);
|
|
104
|
+
return R.Ok(
|
|
105
|
+
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
106
|
+
);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
109
|
+
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
getMechanizations: async ({ kindName }) => {
|
|
104
113
|
try {
|
|
105
114
|
const { data } = await client.get(
|
|
106
|
-
`/farmers
|
|
115
|
+
`/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
|
|
107
116
|
);
|
|
108
117
|
return R.Ok(
|
|
109
118
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
@@ -114,21 +123,20 @@ var createMechanizationServices = (client) => ({
|
|
|
114
123
|
return R.Error(err);
|
|
115
124
|
}
|
|
116
125
|
},
|
|
117
|
-
|
|
126
|
+
SubmitTrackingDeviceCode: async ({
|
|
118
127
|
farmerId,
|
|
119
|
-
mechanizationId
|
|
128
|
+
mechanizationId,
|
|
129
|
+
deviceCode
|
|
120
130
|
}) => {
|
|
121
131
|
try {
|
|
122
|
-
const { data } = await client.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
mappers.getMotorizedMechanizationSensors(
|
|
126
|
-
data.result.data.motorizedMechanizationSensors
|
|
127
|
-
)
|
|
132
|
+
const { data } = await client.put(
|
|
133
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
134
|
+
{ deviceCode }
|
|
128
135
|
);
|
|
136
|
+
return R.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
129
137
|
} catch (error) {
|
|
130
138
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
131
|
-
console.error("
|
|
139
|
+
console.error("SubmitTrackingDevice API Error:", err);
|
|
132
140
|
return R.Error(err);
|
|
133
141
|
}
|
|
134
142
|
}
|