@agroyaar/sdk 2.0.0 → 2.0.2
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 +92 -18
- package/dist/index.d.ts +33 -189
- package/dist/index.mjs +92 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -102,16 +102,16 @@ var mappers = {
|
|
|
102
102
|
date: response.date
|
|
103
103
|
}),
|
|
104
104
|
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
105
|
-
getMechanization: (
|
|
106
|
-
id:
|
|
107
|
-
commonName:
|
|
108
|
-
model:
|
|
109
|
-
avatarURL:
|
|
110
|
-
manufactureYear:
|
|
111
|
-
code:
|
|
112
|
-
kind:
|
|
113
|
-
kindName:
|
|
114
|
-
variety: mappers.getMechanizationVariety(
|
|
105
|
+
getMechanization: (dto) => ({
|
|
106
|
+
id: dto.id,
|
|
107
|
+
commonName: dto.commonName,
|
|
108
|
+
model: dto.model,
|
|
109
|
+
avatarURL: dto.avatarURL,
|
|
110
|
+
manufactureYear: dto.manufactureYear,
|
|
111
|
+
code: dto.code,
|
|
112
|
+
kind: dto.kind,
|
|
113
|
+
kindName: dto.kindName,
|
|
114
|
+
variety: mappers.getMechanizationVariety(dto.variety)
|
|
115
115
|
}),
|
|
116
116
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
117
117
|
getSeasonsProcess: (response) => ({
|
|
@@ -151,7 +151,22 @@ var mappers = {
|
|
|
151
151
|
type: dto.kindName,
|
|
152
152
|
options: dto.options.map((item) => ({ label: item.label, value: item.id }))
|
|
153
153
|
}),
|
|
154
|
-
getQuestions: (dto) => dto.map(mappers.getQuestion)
|
|
154
|
+
getQuestions: (dto) => dto.map(mappers.getQuestion),
|
|
155
|
+
getMechanizationMovementChange: ({
|
|
156
|
+
date,
|
|
157
|
+
heading,
|
|
158
|
+
latitude,
|
|
159
|
+
longitude
|
|
160
|
+
}) => ({
|
|
161
|
+
longitude,
|
|
162
|
+
latitude,
|
|
163
|
+
date,
|
|
164
|
+
heading
|
|
165
|
+
}),
|
|
166
|
+
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange),
|
|
167
|
+
DeleteTrackingDeviceData: (response) => ({
|
|
168
|
+
deviceCode: response.deviceCode
|
|
169
|
+
})
|
|
155
170
|
};
|
|
156
171
|
|
|
157
172
|
// src/utils/wrapError.ts
|
|
@@ -194,13 +209,21 @@ var createMechanizationServices = (client) => ({
|
|
|
194
209
|
return wrapError(error);
|
|
195
210
|
}
|
|
196
211
|
},
|
|
197
|
-
getMechanizations: async (
|
|
212
|
+
getMechanizations: async (variables) => {
|
|
198
213
|
try {
|
|
199
|
-
const
|
|
200
|
-
|
|
214
|
+
const response = await client.typed(
|
|
215
|
+
"get",
|
|
216
|
+
"/farmers/{farmerId}/mechanizations",
|
|
217
|
+
{
|
|
218
|
+
params: {
|
|
219
|
+
kindName: variables.kindName
|
|
220
|
+
}
|
|
221
|
+
}
|
|
201
222
|
);
|
|
202
223
|
return import_ts_belt2.R.Ok(
|
|
203
|
-
mappers.getMechanizationsList(
|
|
224
|
+
mappers.getMechanizationsList(
|
|
225
|
+
response.content["application/json"].result.data.mechanizations
|
|
226
|
+
)
|
|
204
227
|
);
|
|
205
228
|
} catch (error) {
|
|
206
229
|
return wrapError(error);
|
|
@@ -211,10 +234,14 @@ var createMechanizationServices = (client) => ({
|
|
|
211
234
|
mechanizationId
|
|
212
235
|
}) => {
|
|
213
236
|
try {
|
|
214
|
-
|
|
237
|
+
console.log(farmerId, mechanizationId);
|
|
238
|
+
const response = await client.typed(
|
|
239
|
+
"get",
|
|
240
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors"
|
|
241
|
+
);
|
|
215
242
|
return import_ts_belt2.R.Ok(
|
|
216
243
|
mappers.getMotorizedMechanizationSensors(
|
|
217
|
-
|
|
244
|
+
response.content["application/json"].result.data.motorizedMechanizationSensors
|
|
218
245
|
)
|
|
219
246
|
);
|
|
220
247
|
} catch (error) {
|
|
@@ -279,12 +306,59 @@ var createMechanizationServices = (client) => ({
|
|
|
279
306
|
}
|
|
280
307
|
}
|
|
281
308
|
);
|
|
309
|
+
const questions = data.result?.data?.mechanizationsQuestions;
|
|
310
|
+
if (!questions) {
|
|
311
|
+
throw new Error(
|
|
312
|
+
"Invalid API response: 'mechanizationsQuestions' missing"
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
|
|
316
|
+
} catch (error) {
|
|
317
|
+
return wrapError(error);
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
getMechanizationMovementChanges: async ({
|
|
321
|
+
fromDate,
|
|
322
|
+
toDate
|
|
323
|
+
}) => {
|
|
324
|
+
try {
|
|
325
|
+
const response = await client.typed(
|
|
326
|
+
"get",
|
|
327
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/movement-changes",
|
|
328
|
+
{
|
|
329
|
+
params: {
|
|
330
|
+
fromDate,
|
|
331
|
+
toDate
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
);
|
|
282
335
|
return import_ts_belt2.R.Ok(
|
|
283
|
-
mappers.
|
|
336
|
+
mappers.getMechanizationMovementChanges(
|
|
337
|
+
response.content["application/json"].result.data.movementChanges
|
|
338
|
+
)
|
|
284
339
|
);
|
|
285
340
|
} catch (error) {
|
|
286
341
|
return wrapError(error);
|
|
287
342
|
}
|
|
343
|
+
},
|
|
344
|
+
DeleteTrackingDeviceCode: async ({
|
|
345
|
+
farmerId,
|
|
346
|
+
mechanizationId,
|
|
347
|
+
verificationToken
|
|
348
|
+
}) => {
|
|
349
|
+
try {
|
|
350
|
+
const { data } = await client.delete(
|
|
351
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
352
|
+
{
|
|
353
|
+
data: verificationToken
|
|
354
|
+
}
|
|
355
|
+
);
|
|
356
|
+
return import_ts_belt2.R.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
357
|
+
} catch (error) {
|
|
358
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
359
|
+
console.error("UpdateTrackingDevice API Error:", err);
|
|
360
|
+
return import_ts_belt2.R.Error(err);
|
|
361
|
+
}
|
|
288
362
|
}
|
|
289
363
|
});
|
|
290
364
|
|
package/dist/index.d.ts
CHANGED
|
@@ -11,175 +11,10 @@ declare namespace Identifiers {
|
|
|
11
11
|
type MechanizationVarietyId = Branded<string, "mechanizationVariety-id">;
|
|
12
12
|
type MechanizationId = Branded<string, "mechanization-id">;
|
|
13
13
|
type SeasonsProcessId = Branded<string, " seasonsProcess-id">;
|
|
14
|
-
type
|
|
14
|
+
type MotorizedMechanizationSensorId = Branded<string, "motorized-mechanization-sensorsId-id">;
|
|
15
15
|
type FarmerId = Branded<string, "farmer-id">;
|
|
16
16
|
type QuestionId = Branded<string, "question-id">;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
type FarmerDTO = {
|
|
20
|
-
id: string;
|
|
21
|
-
username: string;
|
|
22
|
-
firstName: string;
|
|
23
|
-
lastName: string;
|
|
24
|
-
fullName: string;
|
|
25
|
-
phoneNumber: string;
|
|
26
|
-
nationalCode: string;
|
|
27
|
-
farmerCode: string;
|
|
28
|
-
birthDate: string;
|
|
29
|
-
avatar: string;
|
|
30
|
-
province: string;
|
|
31
|
-
provinceId: number;
|
|
32
|
-
city: string;
|
|
33
|
-
cityId: number;
|
|
34
|
-
zone: string;
|
|
35
|
-
address: string;
|
|
36
|
-
postalCode: number;
|
|
37
|
-
role: string;
|
|
38
|
-
productsIds: number[];
|
|
39
|
-
status: string;
|
|
40
|
-
walletBalance: number;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type MechanizationAnswerOptionDTO = {
|
|
44
|
-
id: string;
|
|
45
|
-
label: string;
|
|
46
|
-
mechanizationQuestionId: string;
|
|
47
|
-
};
|
|
48
|
-
type InformationDTO = {
|
|
49
|
-
id: string;
|
|
50
|
-
status: Status;
|
|
51
|
-
answerOptions: MechanizationAnswerOptionDTO;
|
|
52
|
-
answerValue: string;
|
|
53
|
-
mechanizationId: string;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
declare namespace ServerResponseTypes {
|
|
57
|
-
namespace Dashboard {
|
|
58
|
-
type MechanizationVarietyDTO = {
|
|
59
|
-
id: string;
|
|
60
|
-
name: string;
|
|
61
|
-
code: string;
|
|
62
|
-
iconURL: string;
|
|
63
|
-
kind: VarietyKind;
|
|
64
|
-
kindName: MechanizationType;
|
|
65
|
-
seasonsProcess: MechanizationSeasonProcessKind[];
|
|
66
|
-
seasonProcessIds: string[];
|
|
67
|
-
machinesUsage: MechanizationMachineUsageKind[];
|
|
68
|
-
machineUsageIds: string[];
|
|
69
|
-
mechanizationQuestions: string[];
|
|
70
|
-
};
|
|
71
|
-
type MechanizationDTO = {
|
|
72
|
-
id: string;
|
|
73
|
-
model: string;
|
|
74
|
-
commonName: string;
|
|
75
|
-
avatarURL: string;
|
|
76
|
-
manufactureYear: string;
|
|
77
|
-
code: string;
|
|
78
|
-
kind: VarietyKind;
|
|
79
|
-
kindName: MechanizationType;
|
|
80
|
-
deviceCode: string;
|
|
81
|
-
status: Status;
|
|
82
|
-
farmer: FarmerDTO;
|
|
83
|
-
farmerId: string;
|
|
84
|
-
variety: MechanizationVarietyDTO;
|
|
85
|
-
information: InformationDTO[];
|
|
86
|
-
};
|
|
87
|
-
type MotorizedMechanizationSensorsDTO = {
|
|
88
|
-
id: string;
|
|
89
|
-
speed: number;
|
|
90
|
-
heading: number;
|
|
91
|
-
latitude: number;
|
|
92
|
-
longitude: number;
|
|
93
|
-
fuelLevel: number;
|
|
94
|
-
engineRpm: number;
|
|
95
|
-
deviceCode: string;
|
|
96
|
-
stateEngine: boolean;
|
|
97
|
-
engineOilPressure: boolean;
|
|
98
|
-
engineWaterTemperature: string;
|
|
99
|
-
batteryChargePercentage: string;
|
|
100
|
-
mechanizationId: string;
|
|
101
|
-
mechanization: MechanizationDTO;
|
|
102
|
-
};
|
|
103
|
-
type TrackingDeviceResultDTO = {
|
|
104
|
-
model: string;
|
|
105
|
-
commonName: string;
|
|
106
|
-
manufactureYear: number;
|
|
107
|
-
code: string;
|
|
108
|
-
deviceCode: string;
|
|
109
|
-
status: {
|
|
110
|
-
id: string;
|
|
111
|
-
label: string;
|
|
112
|
-
name: string;
|
|
113
|
-
};
|
|
114
|
-
farmer: {
|
|
115
|
-
id: string;
|
|
116
|
-
createdAt: string;
|
|
117
|
-
updatedAt: string;
|
|
118
|
-
deletedAt: string | null;
|
|
119
|
-
firstName: string;
|
|
120
|
-
lastName: string;
|
|
121
|
-
phoneNumber: string;
|
|
122
|
-
city: {};
|
|
123
|
-
cityId: string;
|
|
124
|
-
nationalCode: string;
|
|
125
|
-
province: {};
|
|
126
|
-
provinceId: string;
|
|
127
|
-
zone: string;
|
|
128
|
-
farmerCode: string;
|
|
129
|
-
avatar: string;
|
|
130
|
-
walletBalance: number;
|
|
131
|
-
status: string;
|
|
132
|
-
};
|
|
133
|
-
farmerId: string;
|
|
134
|
-
variety: {
|
|
135
|
-
id: string;
|
|
136
|
-
name: string;
|
|
137
|
-
code: string;
|
|
138
|
-
iconURL: string;
|
|
139
|
-
kind: {
|
|
140
|
-
id: string;
|
|
141
|
-
label: string;
|
|
142
|
-
name: string;
|
|
143
|
-
};
|
|
144
|
-
kindName: string;
|
|
145
|
-
seasonsProcess: {
|
|
146
|
-
id: string;
|
|
147
|
-
label: string;
|
|
148
|
-
name: string;
|
|
149
|
-
}[];
|
|
150
|
-
seasonProcessIds: string[];
|
|
151
|
-
machinesUsage: {
|
|
152
|
-
id: string;
|
|
153
|
-
label: string;
|
|
154
|
-
name: string;
|
|
155
|
-
}[];
|
|
156
|
-
machineUsageIds: string[];
|
|
157
|
-
mechanizationQuestions: string[];
|
|
158
|
-
};
|
|
159
|
-
information: {
|
|
160
|
-
id: string;
|
|
161
|
-
createdAt: string;
|
|
162
|
-
updatedAt: string;
|
|
163
|
-
deletedAt: string | null;
|
|
164
|
-
status: {
|
|
165
|
-
id: string;
|
|
166
|
-
label: string;
|
|
167
|
-
name: string;
|
|
168
|
-
};
|
|
169
|
-
answerOptions: {
|
|
170
|
-
id: string;
|
|
171
|
-
label: string;
|
|
172
|
-
mechanizationQuestionId: string;
|
|
173
|
-
};
|
|
174
|
-
answerValue: string;
|
|
175
|
-
mechanizationId: string;
|
|
176
|
-
}[];
|
|
177
|
-
};
|
|
178
|
-
type SpeedChangesChartDTO = {
|
|
179
|
-
speed: number;
|
|
180
|
-
date: string;
|
|
181
|
-
};
|
|
182
|
-
}
|
|
17
|
+
type MechanizationMovementChangeId = Branded<string, " movement-changes-id">;
|
|
183
18
|
}
|
|
184
19
|
|
|
185
20
|
type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
|
|
@@ -189,14 +24,6 @@ type MechanizationType = "MOTORIZED" | "NON_MOTORIZED";
|
|
|
189
24
|
type MechanizationSeasonProcessType = "GROWING" | "HARVESTING" | "PLANTING" | "TRANSPORTATION";
|
|
190
25
|
type MechanizationMachineUsageType = "BALER" | "CRUSHING" | "CRUST_BREAKER" | "FERTILIZER_SPREADER" | "FORAGE_COLLECTOR" | "FURROWER" | "GRASS_CUTTER" | "GRINDING" | "HARVESTING" | "LEVELING" | "LOADER" | "MULTI_PURPOSE" | "SEEDER" | "SPRAYER" | "TILLAGE" | "TRANSPORTATION" | "WEEDER";
|
|
191
26
|
|
|
192
|
-
type ServerResponse<T> = {
|
|
193
|
-
message: string;
|
|
194
|
-
code: string;
|
|
195
|
-
data: T;
|
|
196
|
-
};
|
|
197
|
-
type BaseResponse<T> = {
|
|
198
|
-
result: ServerResponse<T>;
|
|
199
|
-
};
|
|
200
27
|
type Status = {
|
|
201
28
|
id: string;
|
|
202
29
|
label: string;
|
|
@@ -217,15 +44,6 @@ type MechanizationMachineUsageKind = {
|
|
|
217
44
|
label: string;
|
|
218
45
|
name: MechanizationMachineUsageType;
|
|
219
46
|
};
|
|
220
|
-
type MechanizationListData = {
|
|
221
|
-
meta: Record<string, unknown>;
|
|
222
|
-
totalItems: number;
|
|
223
|
-
mechanizations: ServerResponseTypes.Dashboard.MechanizationDTO[];
|
|
224
|
-
};
|
|
225
|
-
type MotorizedMechanizationSensorsData = {
|
|
226
|
-
meta: Record<string, unknown>;
|
|
227
|
-
motorizedMechanizationSensors: ServerResponseTypes.Dashboard.MotorizedMechanizationSensorsDTO;
|
|
228
|
-
};
|
|
229
47
|
|
|
230
48
|
type MechanizationVarietyModel = {
|
|
231
49
|
id: Identifiers.MechanizationVarietyId;
|
|
@@ -244,7 +62,7 @@ type MechanizationModel = {
|
|
|
244
62
|
model: string;
|
|
245
63
|
commonName: string;
|
|
246
64
|
avatarURL: string;
|
|
247
|
-
manufactureYear:
|
|
65
|
+
manufactureYear: number;
|
|
248
66
|
code: string;
|
|
249
67
|
kind: VarietyKind;
|
|
250
68
|
kindName: MechanizationType;
|
|
@@ -271,8 +89,8 @@ type MotorizedMechanizationSensorsModel = {
|
|
|
271
89
|
deviceCode: string;
|
|
272
90
|
stateEngine: boolean;
|
|
273
91
|
engineOilPressure: boolean;
|
|
274
|
-
engineWaterTemperature:
|
|
275
|
-
batteryChargePercentage:
|
|
92
|
+
engineWaterTemperature: number;
|
|
93
|
+
batteryChargePercentage: number;
|
|
276
94
|
mechanizationId: string;
|
|
277
95
|
};
|
|
278
96
|
type MotorizedMechanizationSensorsVariables = {
|
|
@@ -316,6 +134,21 @@ type MechanizationQuestionModel = {
|
|
|
316
134
|
type GetMechanizationQuestionVariable = {
|
|
317
135
|
varietyId: string;
|
|
318
136
|
};
|
|
137
|
+
type MechanizationMovementChangesModel = {
|
|
138
|
+
longitude: number;
|
|
139
|
+
latitude: number;
|
|
140
|
+
heading: number;
|
|
141
|
+
date: string;
|
|
142
|
+
};
|
|
143
|
+
type MechanizationMovementChangesVariable = {
|
|
144
|
+
fromDate?: string | null | undefined;
|
|
145
|
+
toDate?: string | null | undefined;
|
|
146
|
+
};
|
|
147
|
+
type DeleteTrackingDeviceVariables = {
|
|
148
|
+
farmerId: Identifiers.FarmerId;
|
|
149
|
+
mechanizationId: Identifiers.MechanizationId;
|
|
150
|
+
verificationToken: string;
|
|
151
|
+
};
|
|
319
152
|
|
|
320
153
|
/**
|
|
321
154
|
* This file was auto-generated by openapi-typescript.
|
|
@@ -1080,6 +913,13 @@ interface components {
|
|
|
1080
913
|
readonly mechanizationId: string;
|
|
1081
914
|
};
|
|
1082
915
|
Mechanization: {
|
|
916
|
+
readonly id: string;
|
|
917
|
+
/** Format: date-time */
|
|
918
|
+
readonly createdAt: string;
|
|
919
|
+
/** Format: date-time */
|
|
920
|
+
readonly updatedAt: string;
|
|
921
|
+
/** Format: date-time */
|
|
922
|
+
readonly deletedAt: string;
|
|
1083
923
|
readonly avatarURL: string;
|
|
1084
924
|
/** @example pride */
|
|
1085
925
|
readonly model: string;
|
|
@@ -1097,6 +937,8 @@ interface components {
|
|
|
1097
937
|
readonly variety: components["schemas"]["MechanizationVariety"];
|
|
1098
938
|
readonly information: components["schemas"]["MechanizationInformation"][];
|
|
1099
939
|
readonly kind: components["schemas"]["MechanizationKind"];
|
|
940
|
+
/** @enum {string} */
|
|
941
|
+
readonly kindName: "MOTORIZED" | "NON_MOTORIZED";
|
|
1100
942
|
};
|
|
1101
943
|
MechanizationResponseData: {
|
|
1102
944
|
readonly meta: Record<string, never>;
|
|
@@ -3113,14 +2955,16 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
3113
2955
|
mechanization: {
|
|
3114
2956
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
|
|
3115
2957
|
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
|
|
3116
|
-
getMechanizations: (
|
|
2958
|
+
getMechanizations: (variables: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
3117
2959
|
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
3118
2960
|
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
3119
2961
|
getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
|
|
3120
2962
|
UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
3121
2963
|
getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
|
|
2964
|
+
getMechanizationMovementChanges: ({ fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2965
|
+
DeleteTrackingDeviceCode: ({ farmerId, mechanizationId, verificationToken, }: DeleteTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
3122
2966
|
};
|
|
3123
2967
|
};
|
|
3124
2968
|
};
|
|
3125
2969
|
|
|
3126
|
-
export { type
|
|
2970
|
+
export { type DeleteTrackingDeviceVariables, type GetMechanizationQuestionVariable, Identifiers, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationMovementChangesModel, type MechanizationMovementChangesVariable, type MechanizationQuestionModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type SeasonsProcessModel, type ServiceType, type SpeedChangesChartModel, type SpeedChangesChartVariables, type Status, type StatusType, type SubmitTrackingDeviceVariables, type TaskType, type TrackingDeviceCodeModel, type UpdateTrackingDeviceVariables, type VarietyKind, createSDK };
|
package/dist/index.mjs
CHANGED
|
@@ -66,16 +66,16 @@ var mappers = {
|
|
|
66
66
|
date: response.date
|
|
67
67
|
}),
|
|
68
68
|
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
69
|
-
getMechanization: (
|
|
70
|
-
id:
|
|
71
|
-
commonName:
|
|
72
|
-
model:
|
|
73
|
-
avatarURL:
|
|
74
|
-
manufactureYear:
|
|
75
|
-
code:
|
|
76
|
-
kind:
|
|
77
|
-
kindName:
|
|
78
|
-
variety: mappers.getMechanizationVariety(
|
|
69
|
+
getMechanization: (dto) => ({
|
|
70
|
+
id: dto.id,
|
|
71
|
+
commonName: dto.commonName,
|
|
72
|
+
model: dto.model,
|
|
73
|
+
avatarURL: dto.avatarURL,
|
|
74
|
+
manufactureYear: dto.manufactureYear,
|
|
75
|
+
code: dto.code,
|
|
76
|
+
kind: dto.kind,
|
|
77
|
+
kindName: dto.kindName,
|
|
78
|
+
variety: mappers.getMechanizationVariety(dto.variety)
|
|
79
79
|
}),
|
|
80
80
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
81
81
|
getSeasonsProcess: (response) => ({
|
|
@@ -115,7 +115,22 @@ var mappers = {
|
|
|
115
115
|
type: dto.kindName,
|
|
116
116
|
options: dto.options.map((item) => ({ label: item.label, value: item.id }))
|
|
117
117
|
}),
|
|
118
|
-
getQuestions: (dto) => dto.map(mappers.getQuestion)
|
|
118
|
+
getQuestions: (dto) => dto.map(mappers.getQuestion),
|
|
119
|
+
getMechanizationMovementChange: ({
|
|
120
|
+
date,
|
|
121
|
+
heading,
|
|
122
|
+
latitude,
|
|
123
|
+
longitude
|
|
124
|
+
}) => ({
|
|
125
|
+
longitude,
|
|
126
|
+
latitude,
|
|
127
|
+
date,
|
|
128
|
+
heading
|
|
129
|
+
}),
|
|
130
|
+
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange),
|
|
131
|
+
DeleteTrackingDeviceData: (response) => ({
|
|
132
|
+
deviceCode: response.deviceCode
|
|
133
|
+
})
|
|
119
134
|
};
|
|
120
135
|
|
|
121
136
|
// src/utils/wrapError.ts
|
|
@@ -158,13 +173,21 @@ var createMechanizationServices = (client) => ({
|
|
|
158
173
|
return wrapError(error);
|
|
159
174
|
}
|
|
160
175
|
},
|
|
161
|
-
getMechanizations: async (
|
|
176
|
+
getMechanizations: async (variables) => {
|
|
162
177
|
try {
|
|
163
|
-
const
|
|
164
|
-
|
|
178
|
+
const response = await client.typed(
|
|
179
|
+
"get",
|
|
180
|
+
"/farmers/{farmerId}/mechanizations",
|
|
181
|
+
{
|
|
182
|
+
params: {
|
|
183
|
+
kindName: variables.kindName
|
|
184
|
+
}
|
|
185
|
+
}
|
|
165
186
|
);
|
|
166
187
|
return R2.Ok(
|
|
167
|
-
mappers.getMechanizationsList(
|
|
188
|
+
mappers.getMechanizationsList(
|
|
189
|
+
response.content["application/json"].result.data.mechanizations
|
|
190
|
+
)
|
|
168
191
|
);
|
|
169
192
|
} catch (error) {
|
|
170
193
|
return wrapError(error);
|
|
@@ -175,10 +198,14 @@ var createMechanizationServices = (client) => ({
|
|
|
175
198
|
mechanizationId
|
|
176
199
|
}) => {
|
|
177
200
|
try {
|
|
178
|
-
|
|
201
|
+
console.log(farmerId, mechanizationId);
|
|
202
|
+
const response = await client.typed(
|
|
203
|
+
"get",
|
|
204
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors"
|
|
205
|
+
);
|
|
179
206
|
return R2.Ok(
|
|
180
207
|
mappers.getMotorizedMechanizationSensors(
|
|
181
|
-
|
|
208
|
+
response.content["application/json"].result.data.motorizedMechanizationSensors
|
|
182
209
|
)
|
|
183
210
|
);
|
|
184
211
|
} catch (error) {
|
|
@@ -243,12 +270,59 @@ var createMechanizationServices = (client) => ({
|
|
|
243
270
|
}
|
|
244
271
|
}
|
|
245
272
|
);
|
|
273
|
+
const questions = data.result?.data?.mechanizationsQuestions;
|
|
274
|
+
if (!questions) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
"Invalid API response: 'mechanizationsQuestions' missing"
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
return R2.Ok(mappers.getQuestions(questions));
|
|
280
|
+
} catch (error) {
|
|
281
|
+
return wrapError(error);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
getMechanizationMovementChanges: async ({
|
|
285
|
+
fromDate,
|
|
286
|
+
toDate
|
|
287
|
+
}) => {
|
|
288
|
+
try {
|
|
289
|
+
const response = await client.typed(
|
|
290
|
+
"get",
|
|
291
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/movement-changes",
|
|
292
|
+
{
|
|
293
|
+
params: {
|
|
294
|
+
fromDate,
|
|
295
|
+
toDate
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
);
|
|
246
299
|
return R2.Ok(
|
|
247
|
-
mappers.
|
|
300
|
+
mappers.getMechanizationMovementChanges(
|
|
301
|
+
response.content["application/json"].result.data.movementChanges
|
|
302
|
+
)
|
|
248
303
|
);
|
|
249
304
|
} catch (error) {
|
|
250
305
|
return wrapError(error);
|
|
251
306
|
}
|
|
307
|
+
},
|
|
308
|
+
DeleteTrackingDeviceCode: async ({
|
|
309
|
+
farmerId,
|
|
310
|
+
mechanizationId,
|
|
311
|
+
verificationToken
|
|
312
|
+
}) => {
|
|
313
|
+
try {
|
|
314
|
+
const { data } = await client.delete(
|
|
315
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
316
|
+
{
|
|
317
|
+
data: verificationToken
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
return R2.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
323
|
+
console.error("UpdateTrackingDevice API Error:", err);
|
|
324
|
+
return R2.Error(err);
|
|
325
|
+
}
|
|
252
326
|
}
|
|
253
327
|
});
|
|
254
328
|
|