@agroyaar/sdk 2.0.3 → 2.0.5-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 +32 -33
- package/dist/index.d.ts +14 -10
- package/dist/index.mjs +32 -33
- 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,
|
|
@@ -217,22 +217,22 @@ var createMechanizationServices = (client) => ({
|
|
|
217
217
|
return wrapError(error);
|
|
218
218
|
}
|
|
219
219
|
},
|
|
220
|
-
getMechanizations: async (
|
|
220
|
+
getMechanizations: async ({ farmerId, kindName }) => {
|
|
221
221
|
try {
|
|
222
222
|
const response = await client.typed(
|
|
223
223
|
"get",
|
|
224
224
|
"/farmers/{farmerId}/mechanizations",
|
|
225
225
|
{
|
|
226
226
|
params: {
|
|
227
|
-
kindName
|
|
227
|
+
kindName
|
|
228
|
+
},
|
|
229
|
+
pathParams: {
|
|
230
|
+
farmerId
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
response.content["application/json"].result.data.mechanizations
|
|
234
|
-
)
|
|
235
|
-
);
|
|
234
|
+
const mechanizations = response.result.data.mechanizations;
|
|
235
|
+
return mechanizations ? import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations)) : import_ts_belt2.R.Error("missing questions in response");
|
|
236
236
|
} catch (error) {
|
|
237
237
|
return wrapError(error);
|
|
238
238
|
}
|
|
@@ -252,11 +252,12 @@ var createMechanizationServices = (client) => ({
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
);
|
|
255
|
-
|
|
255
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
256
|
+
return motorizedMechanizationSensors ? import_ts_belt2.R.Ok(
|
|
256
257
|
mappers.getMotorizedMechanizationSensors(
|
|
257
|
-
|
|
258
|
+
motorizedMechanizationSensors
|
|
258
259
|
)
|
|
259
|
-
);
|
|
260
|
+
) : import_ts_belt2.R.Error("missing questions in response");
|
|
260
261
|
} catch (error) {
|
|
261
262
|
return wrapError(error);
|
|
262
263
|
}
|
|
@@ -319,18 +320,15 @@ var createMechanizationServices = (client) => ({
|
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
);
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
throw new Error(
|
|
325
|
-
"Invalid API response: 'mechanizationsQuestions' missing"
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
|
|
323
|
+
const maybeQuestions = data?.result?.data.mechanizationsQuestions;
|
|
324
|
+
return maybeQuestions ? import_ts_belt2.R.Ok(mappers.getQuestions(maybeQuestions)) : import_ts_belt2.R.Error("missing questions in response");
|
|
329
325
|
} catch (error) {
|
|
330
326
|
return wrapError(error);
|
|
331
327
|
}
|
|
332
328
|
},
|
|
333
329
|
getMechanizationMovementChanges: async ({
|
|
330
|
+
farmerId,
|
|
331
|
+
mechanizationId,
|
|
334
332
|
fromDate,
|
|
335
333
|
toDate
|
|
336
334
|
}) => {
|
|
@@ -342,14 +340,15 @@ var createMechanizationServices = (client) => ({
|
|
|
342
340
|
params: {
|
|
343
341
|
fromDate,
|
|
344
342
|
toDate
|
|
343
|
+
},
|
|
344
|
+
pathParams: {
|
|
345
|
+
farmerId,
|
|
346
|
+
mechanizationId
|
|
345
347
|
}
|
|
346
348
|
}
|
|
347
349
|
);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
response.content["application/json"].result.data.movementChanges
|
|
351
|
-
)
|
|
352
|
-
);
|
|
350
|
+
const movementChanges = response.result.data.movementChanges;
|
|
351
|
+
return movementChanges ? import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges)) : import_ts_belt2.R.Error("missing questions in response");
|
|
353
352
|
} catch (error) {
|
|
354
353
|
return wrapError(error);
|
|
355
354
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ type MechanizationModel = {
|
|
|
62
62
|
model: string;
|
|
63
63
|
commonName: string;
|
|
64
64
|
avatarURL: string;
|
|
65
|
-
manufactureYear:
|
|
65
|
+
manufactureYear: string;
|
|
66
66
|
code: string;
|
|
67
67
|
kind: VarietyKind;
|
|
68
68
|
kindName: MechanizationType;
|
|
@@ -141,6 +141,8 @@ type MechanizationMovementChangesModel = {
|
|
|
141
141
|
date: string;
|
|
142
142
|
};
|
|
143
143
|
type MechanizationMovementChangesVariable = {
|
|
144
|
+
farmerId: string;
|
|
145
|
+
mechanizationId: string;
|
|
144
146
|
fromDate?: string | null | undefined;
|
|
145
147
|
toDate?: string | null | undefined;
|
|
146
148
|
};
|
|
@@ -925,8 +927,7 @@ interface components {
|
|
|
925
927
|
readonly model: string;
|
|
926
928
|
/** @example shrek */
|
|
927
929
|
readonly commonName: string;
|
|
928
|
-
|
|
929
|
-
readonly manufactureYear: number;
|
|
930
|
+
readonly manufactureYear: string;
|
|
930
931
|
/** @example code */
|
|
931
932
|
readonly code: string;
|
|
932
933
|
/** @example deviceCode */
|
|
@@ -1364,7 +1365,6 @@ interface operations {
|
|
|
1364
1365
|
responses: {
|
|
1365
1366
|
/** @description لیست اطلاعات با موفقیت دریافت شد */
|
|
1366
1367
|
200: {
|
|
1367
|
-
result: any;
|
|
1368
1368
|
headers: {
|
|
1369
1369
|
[name: string]: unknown;
|
|
1370
1370
|
};
|
|
@@ -2926,7 +2926,7 @@ type RequestParams<Op> = Op extends {
|
|
|
2926
2926
|
};
|
|
2927
2927
|
} ? Q extends object ? Q : never : never;
|
|
2928
2928
|
type RequestBody<Op> = Op extends {
|
|
2929
|
-
requestBody
|
|
2929
|
+
requestBody?: {
|
|
2930
2930
|
content: {
|
|
2931
2931
|
"application/json": infer B;
|
|
2932
2932
|
};
|
|
@@ -2939,7 +2939,11 @@ type PathParams<Op> = Op extends {
|
|
|
2939
2939
|
} ? P extends object ? P : never : never;
|
|
2940
2940
|
type ResponseData<Op> = Op extends {
|
|
2941
2941
|
responses: {
|
|
2942
|
-
200:
|
|
2942
|
+
200: {
|
|
2943
|
+
content: {
|
|
2944
|
+
"application/json": infer R;
|
|
2945
|
+
};
|
|
2946
|
+
};
|
|
2943
2947
|
};
|
|
2944
2948
|
} ? R : unknown;
|
|
2945
2949
|
|
|
@@ -2961,13 +2965,13 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
2961
2965
|
mechanization: {
|
|
2962
2966
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
|
|
2963
2967
|
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
|
|
2964
|
-
getMechanizations: (
|
|
2965
|
-
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
2968
|
+
getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]> | _mobily_ts_belt.Error<"missing questions in response">>;
|
|
2969
|
+
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Error<"missing questions in response"> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
2966
2970
|
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2967
2971
|
getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
|
|
2968
2972
|
UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2969
|
-
getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
|
|
2970
|
-
getMechanizationMovementChanges: ({ fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2973
|
+
getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Error<"missing questions in response"> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
|
|
2974
|
+
getMechanizationMovementChanges: ({ farmerId, mechanizationId, fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Error<"missing questions in response"> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2971
2975
|
DeleteTrackingDeviceCode: ({ farmerId, mechanizationId, verificationToken, }: DeleteTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2972
2976
|
};
|
|
2973
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,
|
|
@@ -181,22 +181,22 @@ var createMechanizationServices = (client) => ({
|
|
|
181
181
|
return wrapError(error);
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
|
-
getMechanizations: async (
|
|
184
|
+
getMechanizations: async ({ farmerId, kindName }) => {
|
|
185
185
|
try {
|
|
186
186
|
const response = await client.typed(
|
|
187
187
|
"get",
|
|
188
188
|
"/farmers/{farmerId}/mechanizations",
|
|
189
189
|
{
|
|
190
190
|
params: {
|
|
191
|
-
kindName
|
|
191
|
+
kindName
|
|
192
|
+
},
|
|
193
|
+
pathParams: {
|
|
194
|
+
farmerId
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
response.content["application/json"].result.data.mechanizations
|
|
198
|
-
)
|
|
199
|
-
);
|
|
198
|
+
const mechanizations = response.result.data.mechanizations;
|
|
199
|
+
return mechanizations ? R2.Ok(mappers.getMechanizations(mechanizations)) : R2.Error("missing questions in response");
|
|
200
200
|
} catch (error) {
|
|
201
201
|
return wrapError(error);
|
|
202
202
|
}
|
|
@@ -216,11 +216,12 @@ var createMechanizationServices = (client) => ({
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
);
|
|
219
|
-
|
|
219
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
220
|
+
return motorizedMechanizationSensors ? R2.Ok(
|
|
220
221
|
mappers.getMotorizedMechanizationSensors(
|
|
221
|
-
|
|
222
|
+
motorizedMechanizationSensors
|
|
222
223
|
)
|
|
223
|
-
);
|
|
224
|
+
) : R2.Error("missing questions in response");
|
|
224
225
|
} catch (error) {
|
|
225
226
|
return wrapError(error);
|
|
226
227
|
}
|
|
@@ -283,18 +284,15 @@ var createMechanizationServices = (client) => ({
|
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
);
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
throw new Error(
|
|
289
|
-
"Invalid API response: 'mechanizationsQuestions' missing"
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return R2.Ok(mappers.getQuestions(questions));
|
|
287
|
+
const maybeQuestions = data?.result?.data.mechanizationsQuestions;
|
|
288
|
+
return maybeQuestions ? R2.Ok(mappers.getQuestions(maybeQuestions)) : R2.Error("missing questions in response");
|
|
293
289
|
} catch (error) {
|
|
294
290
|
return wrapError(error);
|
|
295
291
|
}
|
|
296
292
|
},
|
|
297
293
|
getMechanizationMovementChanges: async ({
|
|
294
|
+
farmerId,
|
|
295
|
+
mechanizationId,
|
|
298
296
|
fromDate,
|
|
299
297
|
toDate
|
|
300
298
|
}) => {
|
|
@@ -306,14 +304,15 @@ var createMechanizationServices = (client) => ({
|
|
|
306
304
|
params: {
|
|
307
305
|
fromDate,
|
|
308
306
|
toDate
|
|
307
|
+
},
|
|
308
|
+
pathParams: {
|
|
309
|
+
farmerId,
|
|
310
|
+
mechanizationId
|
|
309
311
|
}
|
|
310
312
|
}
|
|
311
313
|
);
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
response.content["application/json"].result.data.movementChanges
|
|
315
|
-
)
|
|
316
|
-
);
|
|
314
|
+
const movementChanges = response.result.data.movementChanges;
|
|
315
|
+
return movementChanges ? R2.Ok(mappers.getMechanizationMovementChanges(movementChanges)) : R2.Error("missing questions in response");
|
|
317
316
|
} catch (error) {
|
|
318
317
|
return wrapError(error);
|
|
319
318
|
}
|