@agroyaar/sdk 2.1.1 → 2.1.3
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 +38 -34
- package/dist/index.d.ts +9 -7
- package/dist/index.mjs +38 -34
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -110,18 +110,18 @@ var mappers = {
|
|
|
110
110
|
date: response.date
|
|
111
111
|
}),
|
|
112
112
|
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
113
|
-
getMechanization: (
|
|
114
|
-
id:
|
|
115
|
-
commonName:
|
|
116
|
-
model:
|
|
117
|
-
avatarURL:
|
|
118
|
-
manufactureYear:
|
|
119
|
-
code:
|
|
120
|
-
kind:
|
|
121
|
-
kindName:
|
|
122
|
-
variety: mappers.getMechanizationVariety(
|
|
113
|
+
getMechanization: (res) => ({
|
|
114
|
+
id: res.id,
|
|
115
|
+
commonName: res.commonName,
|
|
116
|
+
model: res.model,
|
|
117
|
+
avatarURL: res.avatarURL,
|
|
118
|
+
manufactureYear: res.manufactureYear,
|
|
119
|
+
code: res.code,
|
|
120
|
+
kind: res.kind,
|
|
121
|
+
kindName: res.kindName,
|
|
122
|
+
variety: mappers.getMechanizationVariety(res.variety)
|
|
123
123
|
}),
|
|
124
|
-
|
|
124
|
+
getMechanizations: (response) => response.map(mappers.getMechanization),
|
|
125
125
|
getSeasonsProcess: (response) => ({
|
|
126
126
|
id: response.id,
|
|
127
127
|
label: response.label,
|
|
@@ -150,6 +150,9 @@ var mappers = {
|
|
|
150
150
|
UpdateTrackingDeviceData: (response) => ({
|
|
151
151
|
deviceCode: response.deviceCode
|
|
152
152
|
}),
|
|
153
|
+
DeleteTrackingDeviceData: (response) => ({
|
|
154
|
+
deviceCode: response.deviceCode
|
|
155
|
+
}),
|
|
153
156
|
getQuestion: (dto) => ({
|
|
154
157
|
id: dto.id,
|
|
155
158
|
name: dto.key,
|
|
@@ -157,7 +160,10 @@ var mappers = {
|
|
|
157
160
|
placeholder: dto.placeholder,
|
|
158
161
|
isRequired: dto.required,
|
|
159
162
|
type: dto.kindName,
|
|
160
|
-
options: dto.options
|
|
163
|
+
options: dto.options?.map((item) => ({
|
|
164
|
+
label: item.label,
|
|
165
|
+
value: item.id
|
|
166
|
+
})) ?? []
|
|
161
167
|
}),
|
|
162
168
|
getQuestions: (dto) => dto.map(mappers.getQuestion),
|
|
163
169
|
getMechanizationMovementChange: ({
|
|
@@ -171,10 +177,7 @@ var mappers = {
|
|
|
171
177
|
date,
|
|
172
178
|
heading
|
|
173
179
|
}),
|
|
174
|
-
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
|
|
175
|
-
DeleteTrackingDeviceData: (response) => ({
|
|
176
|
-
deviceCode: response.deviceCode
|
|
177
|
-
})
|
|
180
|
+
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
|
|
178
181
|
};
|
|
179
182
|
|
|
180
183
|
// src/utils/wrapError.ts
|
|
@@ -217,20 +220,22 @@ var createMechanizationServices = (client) => ({
|
|
|
217
220
|
return wrapError(error);
|
|
218
221
|
}
|
|
219
222
|
},
|
|
220
|
-
getMechanizations: async (
|
|
223
|
+
getMechanizations: async ({ farmerId, kindName }) => {
|
|
221
224
|
try {
|
|
222
225
|
const response = await client.typed(
|
|
223
226
|
"get",
|
|
224
227
|
"/farmers/{farmerId}/mechanizations",
|
|
225
228
|
{
|
|
226
229
|
params: {
|
|
227
|
-
kindName
|
|
230
|
+
kindName
|
|
231
|
+
},
|
|
232
|
+
pathParams: {
|
|
233
|
+
farmerId
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
);
|
|
237
|
+
const mechanizations = response.result.data.mechanizations;
|
|
238
|
+
return import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations));
|
|
234
239
|
} catch (error) {
|
|
235
240
|
return wrapError(error);
|
|
236
241
|
}
|
|
@@ -250,10 +255,9 @@ var createMechanizationServices = (client) => ({
|
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
257
|
);
|
|
258
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
253
259
|
return import_ts_belt2.R.Ok(
|
|
254
|
-
mappers.getMotorizedMechanizationSensors(
|
|
255
|
-
response.result.data.motorizedMechanizationSensors
|
|
256
|
-
)
|
|
260
|
+
mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
|
|
257
261
|
);
|
|
258
262
|
} catch (error) {
|
|
259
263
|
return wrapError(error);
|
|
@@ -318,13 +322,14 @@ var createMechanizationServices = (client) => ({
|
|
|
318
322
|
}
|
|
319
323
|
);
|
|
320
324
|
const questions = data?.result?.data.mechanizationsQuestions;
|
|
321
|
-
console.log("in SDK - qustions", questions);
|
|
322
325
|
return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
|
|
323
326
|
} catch (error) {
|
|
324
327
|
return wrapError(error);
|
|
325
328
|
}
|
|
326
329
|
},
|
|
327
330
|
getMechanizationMovementChanges: async ({
|
|
331
|
+
farmerId,
|
|
332
|
+
mechanizationId,
|
|
328
333
|
fromDate,
|
|
329
334
|
toDate
|
|
330
335
|
}) => {
|
|
@@ -336,14 +341,15 @@ var createMechanizationServices = (client) => ({
|
|
|
336
341
|
params: {
|
|
337
342
|
fromDate,
|
|
338
343
|
toDate
|
|
344
|
+
},
|
|
345
|
+
pathParams: {
|
|
346
|
+
farmerId,
|
|
347
|
+
mechanizationId
|
|
339
348
|
}
|
|
340
349
|
}
|
|
341
350
|
);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
response.result.data.movementChanges
|
|
345
|
-
)
|
|
346
|
-
);
|
|
351
|
+
const movementChanges = response.result.data.movementChanges;
|
|
352
|
+
return import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges));
|
|
347
353
|
} catch (error) {
|
|
348
354
|
return wrapError(error);
|
|
349
355
|
}
|
|
@@ -357,14 +363,12 @@ var createMechanizationServices = (client) => ({
|
|
|
357
363
|
const { data } = await client.delete(
|
|
358
364
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
359
365
|
{
|
|
360
|
-
data: verificationToken
|
|
366
|
+
data: { verificationToken }
|
|
361
367
|
}
|
|
362
368
|
);
|
|
363
369
|
return import_ts_belt2.R.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
364
370
|
} catch (error) {
|
|
365
|
-
|
|
366
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
367
|
-
return import_ts_belt2.R.Error(err);
|
|
371
|
+
return wrapError(error);
|
|
368
372
|
}
|
|
369
373
|
}
|
|
370
374
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -119,6 +119,11 @@ type UpdateTrackingDeviceVariables = {
|
|
|
119
119
|
deviceCode: string;
|
|
120
120
|
verificationToken: string;
|
|
121
121
|
};
|
|
122
|
+
type DeleteTrackingDeviceVariables = {
|
|
123
|
+
farmerId: string;
|
|
124
|
+
mechanizationId: string;
|
|
125
|
+
verificationToken: string;
|
|
126
|
+
};
|
|
122
127
|
type MechanizationQuestionModel = {
|
|
123
128
|
id: Identifiers.QuestionId;
|
|
124
129
|
name: string;
|
|
@@ -141,14 +146,11 @@ type MechanizationMovementChangesModel = {
|
|
|
141
146
|
date: string;
|
|
142
147
|
};
|
|
143
148
|
type MechanizationMovementChangesVariable = {
|
|
149
|
+
farmerId: string;
|
|
150
|
+
mechanizationId: string;
|
|
144
151
|
fromDate?: string | null | undefined;
|
|
145
152
|
toDate?: string | null | undefined;
|
|
146
153
|
};
|
|
147
|
-
type DeleteTrackingDeviceVariables = {
|
|
148
|
-
farmerId: Identifiers.FarmerId;
|
|
149
|
-
mechanizationId: Identifiers.MechanizationId;
|
|
150
|
-
verificationToken: string;
|
|
151
|
-
};
|
|
152
154
|
|
|
153
155
|
/**
|
|
154
156
|
* This file was auto-generated by openapi-typescript.
|
|
@@ -2963,13 +2965,13 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
2963
2965
|
mechanization: {
|
|
2964
2966
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
|
|
2965
2967
|
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
|
|
2966
|
-
getMechanizations: (
|
|
2968
|
+
getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
2967
2969
|
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
2968
2970
|
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2969
2971
|
getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
|
|
2970
2972
|
UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2971
2973
|
getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
|
|
2972
|
-
getMechanizationMovementChanges: ({ fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2974
|
+
getMechanizationMovementChanges: ({ farmerId, mechanizationId, fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2973
2975
|
DeleteTrackingDeviceCode: ({ farmerId, mechanizationId, verificationToken, }: DeleteTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2974
2976
|
};
|
|
2975
2977
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -74,18 +74,18 @@ var mappers = {
|
|
|
74
74
|
date: response.date
|
|
75
75
|
}),
|
|
76
76
|
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
77
|
-
getMechanization: (
|
|
78
|
-
id:
|
|
79
|
-
commonName:
|
|
80
|
-
model:
|
|
81
|
-
avatarURL:
|
|
82
|
-
manufactureYear:
|
|
83
|
-
code:
|
|
84
|
-
kind:
|
|
85
|
-
kindName:
|
|
86
|
-
variety: mappers.getMechanizationVariety(
|
|
77
|
+
getMechanization: (res) => ({
|
|
78
|
+
id: res.id,
|
|
79
|
+
commonName: res.commonName,
|
|
80
|
+
model: res.model,
|
|
81
|
+
avatarURL: res.avatarURL,
|
|
82
|
+
manufactureYear: res.manufactureYear,
|
|
83
|
+
code: res.code,
|
|
84
|
+
kind: res.kind,
|
|
85
|
+
kindName: res.kindName,
|
|
86
|
+
variety: mappers.getMechanizationVariety(res.variety)
|
|
87
87
|
}),
|
|
88
|
-
|
|
88
|
+
getMechanizations: (response) => response.map(mappers.getMechanization),
|
|
89
89
|
getSeasonsProcess: (response) => ({
|
|
90
90
|
id: response.id,
|
|
91
91
|
label: response.label,
|
|
@@ -114,6 +114,9 @@ var mappers = {
|
|
|
114
114
|
UpdateTrackingDeviceData: (response) => ({
|
|
115
115
|
deviceCode: response.deviceCode
|
|
116
116
|
}),
|
|
117
|
+
DeleteTrackingDeviceData: (response) => ({
|
|
118
|
+
deviceCode: response.deviceCode
|
|
119
|
+
}),
|
|
117
120
|
getQuestion: (dto) => ({
|
|
118
121
|
id: dto.id,
|
|
119
122
|
name: dto.key,
|
|
@@ -121,7 +124,10 @@ var mappers = {
|
|
|
121
124
|
placeholder: dto.placeholder,
|
|
122
125
|
isRequired: dto.required,
|
|
123
126
|
type: dto.kindName,
|
|
124
|
-
options: dto.options
|
|
127
|
+
options: dto.options?.map((item) => ({
|
|
128
|
+
label: item.label,
|
|
129
|
+
value: item.id
|
|
130
|
+
})) ?? []
|
|
125
131
|
}),
|
|
126
132
|
getQuestions: (dto) => dto.map(mappers.getQuestion),
|
|
127
133
|
getMechanizationMovementChange: ({
|
|
@@ -135,10 +141,7 @@ var mappers = {
|
|
|
135
141
|
date,
|
|
136
142
|
heading
|
|
137
143
|
}),
|
|
138
|
-
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
|
|
139
|
-
DeleteTrackingDeviceData: (response) => ({
|
|
140
|
-
deviceCode: response.deviceCode
|
|
141
|
-
})
|
|
144
|
+
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
|
|
142
145
|
};
|
|
143
146
|
|
|
144
147
|
// src/utils/wrapError.ts
|
|
@@ -181,20 +184,22 @@ var createMechanizationServices = (client) => ({
|
|
|
181
184
|
return wrapError(error);
|
|
182
185
|
}
|
|
183
186
|
},
|
|
184
|
-
getMechanizations: async (
|
|
187
|
+
getMechanizations: async ({ farmerId, kindName }) => {
|
|
185
188
|
try {
|
|
186
189
|
const response = await client.typed(
|
|
187
190
|
"get",
|
|
188
191
|
"/farmers/{farmerId}/mechanizations",
|
|
189
192
|
{
|
|
190
193
|
params: {
|
|
191
|
-
kindName
|
|
194
|
+
kindName
|
|
195
|
+
},
|
|
196
|
+
pathParams: {
|
|
197
|
+
farmerId
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
);
|
|
201
|
+
const mechanizations = response.result.data.mechanizations;
|
|
202
|
+
return R2.Ok(mappers.getMechanizations(mechanizations));
|
|
198
203
|
} catch (error) {
|
|
199
204
|
return wrapError(error);
|
|
200
205
|
}
|
|
@@ -214,10 +219,9 @@ var createMechanizationServices = (client) => ({
|
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
221
|
);
|
|
222
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
217
223
|
return R2.Ok(
|
|
218
|
-
mappers.getMotorizedMechanizationSensors(
|
|
219
|
-
response.result.data.motorizedMechanizationSensors
|
|
220
|
-
)
|
|
224
|
+
mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
|
|
221
225
|
);
|
|
222
226
|
} catch (error) {
|
|
223
227
|
return wrapError(error);
|
|
@@ -282,13 +286,14 @@ var createMechanizationServices = (client) => ({
|
|
|
282
286
|
}
|
|
283
287
|
);
|
|
284
288
|
const questions = data?.result?.data.mechanizationsQuestions;
|
|
285
|
-
console.log("in SDK - qustions", questions);
|
|
286
289
|
return R2.Ok(mappers.getQuestions(questions));
|
|
287
290
|
} catch (error) {
|
|
288
291
|
return wrapError(error);
|
|
289
292
|
}
|
|
290
293
|
},
|
|
291
294
|
getMechanizationMovementChanges: async ({
|
|
295
|
+
farmerId,
|
|
296
|
+
mechanizationId,
|
|
292
297
|
fromDate,
|
|
293
298
|
toDate
|
|
294
299
|
}) => {
|
|
@@ -300,14 +305,15 @@ var createMechanizationServices = (client) => ({
|
|
|
300
305
|
params: {
|
|
301
306
|
fromDate,
|
|
302
307
|
toDate
|
|
308
|
+
},
|
|
309
|
+
pathParams: {
|
|
310
|
+
farmerId,
|
|
311
|
+
mechanizationId
|
|
303
312
|
}
|
|
304
313
|
}
|
|
305
314
|
);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
response.result.data.movementChanges
|
|
309
|
-
)
|
|
310
|
-
);
|
|
315
|
+
const movementChanges = response.result.data.movementChanges;
|
|
316
|
+
return R2.Ok(mappers.getMechanizationMovementChanges(movementChanges));
|
|
311
317
|
} catch (error) {
|
|
312
318
|
return wrapError(error);
|
|
313
319
|
}
|
|
@@ -321,14 +327,12 @@ var createMechanizationServices = (client) => ({
|
|
|
321
327
|
const { data } = await client.delete(
|
|
322
328
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
323
329
|
{
|
|
324
|
-
data: verificationToken
|
|
330
|
+
data: { verificationToken }
|
|
325
331
|
}
|
|
326
332
|
);
|
|
327
333
|
return R2.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
328
334
|
} catch (error) {
|
|
329
|
-
|
|
330
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
331
|
-
return R2.Error(err);
|
|
335
|
+
return wrapError(error);
|
|
332
336
|
}
|
|
333
337
|
}
|
|
334
338
|
});
|