@agroyaar/sdk 1.5.3-1 → 1.5.3-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 +40 -44
- package/dist/index.d.ts +86 -12
- package/dist/index.mjs +40 -44
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -74,7 +74,7 @@ var createClient = (config, middlewares = []) => {
|
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
77
|
-
var
|
|
77
|
+
var import_ts_belt2 = require("@mobily/ts-belt");
|
|
78
78
|
|
|
79
79
|
// src/services/dashboard/mechanization/mechanization.mapper.ts
|
|
80
80
|
var mappers = {
|
|
@@ -133,9 +133,23 @@ var mappers = {
|
|
|
133
133
|
UpdateTrackingDeviceData: (response) => ({
|
|
134
134
|
deviceCode: response.deviceCode
|
|
135
135
|
}),
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
getQuestion: (dto) => ({
|
|
137
|
+
id: dto.id,
|
|
138
|
+
name: dto.key,
|
|
139
|
+
label: dto.title,
|
|
140
|
+
placeholder: dto.placeholder,
|
|
141
|
+
isRequired: dto.required,
|
|
142
|
+
type: dto.kindName,
|
|
143
|
+
options: dto.options.map((item) => ({ label: item.label, value: item.id }))
|
|
144
|
+
}),
|
|
145
|
+
getQuestions: (dto) => dto.map(mappers.getQuestion)
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/utils/wrapError.ts
|
|
149
|
+
var import_ts_belt = require("@mobily/ts-belt");
|
|
150
|
+
var wrapError = (error) => {
|
|
151
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
152
|
+
return import_ts_belt.R.Error(err);
|
|
139
153
|
};
|
|
140
154
|
|
|
141
155
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
@@ -147,15 +161,13 @@ var createMechanizationServices = (client) => ({
|
|
|
147
161
|
const { data } = await client.get(
|
|
148
162
|
`/statics/mechanizations-varieties?kindName=${kindName}`
|
|
149
163
|
);
|
|
150
|
-
return
|
|
164
|
+
return import_ts_belt2.R.Ok(
|
|
151
165
|
mappers.getMechanizationVarietyList(
|
|
152
166
|
data.result.data.mechanizationVarieties
|
|
153
167
|
)
|
|
154
168
|
);
|
|
155
169
|
} catch (error) {
|
|
156
|
-
|
|
157
|
-
console.error("MechanizationVariety API Error:", err);
|
|
158
|
-
return import_ts_belt.R.Error(err);
|
|
170
|
+
return wrapError(error);
|
|
159
171
|
}
|
|
160
172
|
},
|
|
161
173
|
getSpeedChangesChartData: async ({
|
|
@@ -166,12 +178,11 @@ var createMechanizationServices = (client) => ({
|
|
|
166
178
|
const { data } = await client.get(
|
|
167
179
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
168
180
|
);
|
|
169
|
-
return
|
|
181
|
+
return import_ts_belt2.R.Ok(
|
|
170
182
|
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
171
183
|
);
|
|
172
184
|
} catch (error) {
|
|
173
|
-
|
|
174
|
-
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
185
|
+
return wrapError(error);
|
|
175
186
|
}
|
|
176
187
|
},
|
|
177
188
|
getMechanizations: async ({ kindName, farmerId }) => {
|
|
@@ -179,13 +190,11 @@ var createMechanizationServices = (client) => ({
|
|
|
179
190
|
const { data } = await client.get(
|
|
180
191
|
`/farmers/${farmerId}/mechanizations?kindName=${kindName}`
|
|
181
192
|
);
|
|
182
|
-
return
|
|
193
|
+
return import_ts_belt2.R.Ok(
|
|
183
194
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
184
195
|
);
|
|
185
196
|
} catch (error) {
|
|
186
|
-
|
|
187
|
-
console.error("Mechanization API Error:", err);
|
|
188
|
-
return import_ts_belt.R.Error(err);
|
|
197
|
+
return wrapError(error);
|
|
189
198
|
}
|
|
190
199
|
},
|
|
191
200
|
getMotorizedMechanizationSensors: async ({
|
|
@@ -194,15 +203,13 @@ var createMechanizationServices = (client) => ({
|
|
|
194
203
|
}) => {
|
|
195
204
|
try {
|
|
196
205
|
const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
|
|
197
|
-
return
|
|
206
|
+
return import_ts_belt2.R.Ok(
|
|
198
207
|
mappers.getMotorizedMechanizationSensors(
|
|
199
208
|
data.result.data.motorizedMechanizationSensors
|
|
200
209
|
)
|
|
201
210
|
);
|
|
202
211
|
} catch (error) {
|
|
203
|
-
|
|
204
|
-
console.error("Motorized Mechanization Sensors API Error:", err);
|
|
205
|
-
return import_ts_belt.R.Error(err);
|
|
212
|
+
return wrapError(error);
|
|
206
213
|
}
|
|
207
214
|
},
|
|
208
215
|
SubmitTrackingDeviceCode: async ({
|
|
@@ -215,11 +222,9 @@ var createMechanizationServices = (client) => ({
|
|
|
215
222
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
216
223
|
{ deviceCode }
|
|
217
224
|
);
|
|
218
|
-
return
|
|
225
|
+
return import_ts_belt2.R.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
219
226
|
} catch (error) {
|
|
220
|
-
|
|
221
|
-
console.error("SubmitTrackingDevice API Error:", err);
|
|
222
|
-
return import_ts_belt.R.Error(err);
|
|
227
|
+
return wrapError(error);
|
|
223
228
|
}
|
|
224
229
|
},
|
|
225
230
|
getSeasonsProcess: async () => {
|
|
@@ -227,15 +232,13 @@ var createMechanizationServices = (client) => ({
|
|
|
227
232
|
const { data } = await client.get(
|
|
228
233
|
"/statics/mechanizations-seasons-process-kinds"
|
|
229
234
|
);
|
|
230
|
-
return
|
|
235
|
+
return import_ts_belt2.R.Ok(
|
|
231
236
|
mappers.getSeasonsProcessList(
|
|
232
237
|
data.result.data.mechanizationSeasonProcessKinds
|
|
233
238
|
)
|
|
234
239
|
);
|
|
235
240
|
} catch (error) {
|
|
236
|
-
|
|
237
|
-
console.error("getSeasonsProcess API Error:", err);
|
|
238
|
-
return import_ts_belt.R.Error(err);
|
|
241
|
+
return wrapError(error);
|
|
239
242
|
}
|
|
240
243
|
},
|
|
241
244
|
UpdateTrackingDeviceCode: async ({
|
|
@@ -249,30 +252,23 @@ var createMechanizationServices = (client) => ({
|
|
|
249
252
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/update-device-code`,
|
|
250
253
|
{ deviceCode, verificationToken }
|
|
251
254
|
);
|
|
252
|
-
return
|
|
255
|
+
return import_ts_belt2.R.Ok(mappers.UpdateTrackingDeviceData(data));
|
|
253
256
|
} catch (error) {
|
|
254
|
-
|
|
255
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
256
|
-
return import_ts_belt.R.Error(err);
|
|
257
|
+
return wrapError(error);
|
|
257
258
|
}
|
|
258
259
|
},
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
mechanizationId,
|
|
262
|
-
verificationToken
|
|
260
|
+
getMechanizationQuestionList: async ({
|
|
261
|
+
varietyId
|
|
263
262
|
}) => {
|
|
264
263
|
try {
|
|
265
|
-
const { data } = await client.
|
|
266
|
-
`/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
264
|
+
const { data } = await client.get(
|
|
265
|
+
`/statics/mechanizations-questions?mechanizationVarietyId=${varietyId}`
|
|
266
|
+
);
|
|
267
|
+
return import_ts_belt2.R.Ok(
|
|
268
|
+
mappers.getQuestions(data.result.data.mechanizationsQuestions)
|
|
270
269
|
);
|
|
271
|
-
return import_ts_belt.R.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
272
270
|
} catch (error) {
|
|
273
|
-
|
|
274
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
275
|
-
return import_ts_belt.R.Error(err);
|
|
271
|
+
return wrapError(error);
|
|
276
272
|
}
|
|
277
273
|
}
|
|
278
274
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare namespace Identifiers {
|
|
|
14
14
|
type SeasonsProcessId = Branded<string, " seasonsProcess-id">;
|
|
15
15
|
type MotorizedMechanizationSensorsId = Branded<string, "motorized-mechanization-sensorsId-id">;
|
|
16
16
|
type FarmerId = Branded<string, "farmer-id">;
|
|
17
|
+
type QuestionId = Branded<string, "question-id">;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
type FarmerDTO = {
|
|
@@ -106,11 +107,74 @@ declare namespace ServerResponseTypes {
|
|
|
106
107
|
manufactureYear: number;
|
|
107
108
|
code: string;
|
|
108
109
|
deviceCode: string;
|
|
109
|
-
status:
|
|
110
|
-
|
|
110
|
+
status: {
|
|
111
|
+
id: string;
|
|
112
|
+
label: string;
|
|
113
|
+
name: string;
|
|
114
|
+
};
|
|
115
|
+
farmer: {
|
|
116
|
+
id: string;
|
|
117
|
+
createdAt: string;
|
|
118
|
+
updatedAt: string;
|
|
119
|
+
deletedAt: string | null;
|
|
120
|
+
firstName: string;
|
|
121
|
+
lastName: string;
|
|
122
|
+
phoneNumber: string;
|
|
123
|
+
city: {};
|
|
124
|
+
cityId: string;
|
|
125
|
+
nationalCode: string;
|
|
126
|
+
province: {};
|
|
127
|
+
provinceId: string;
|
|
128
|
+
zone: string;
|
|
129
|
+
farmerCode: string;
|
|
130
|
+
avatar: string;
|
|
131
|
+
walletBalance: number;
|
|
132
|
+
status: string;
|
|
133
|
+
};
|
|
111
134
|
farmerId: string;
|
|
112
|
-
variety:
|
|
113
|
-
|
|
135
|
+
variety: {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
code: string;
|
|
139
|
+
iconURL: string;
|
|
140
|
+
kind: {
|
|
141
|
+
id: string;
|
|
142
|
+
label: string;
|
|
143
|
+
name: string;
|
|
144
|
+
};
|
|
145
|
+
kindName: string;
|
|
146
|
+
seasonsProcess: {
|
|
147
|
+
id: string;
|
|
148
|
+
label: string;
|
|
149
|
+
name: string;
|
|
150
|
+
}[];
|
|
151
|
+
seasonProcessIds: string[];
|
|
152
|
+
machinesUsage: {
|
|
153
|
+
id: string;
|
|
154
|
+
label: string;
|
|
155
|
+
name: string;
|
|
156
|
+
}[];
|
|
157
|
+
machineUsageIds: string[];
|
|
158
|
+
mechanizationQuestions: string[];
|
|
159
|
+
};
|
|
160
|
+
information: {
|
|
161
|
+
id: string;
|
|
162
|
+
createdAt: string;
|
|
163
|
+
updatedAt: string;
|
|
164
|
+
deletedAt: string | null;
|
|
165
|
+
status: {
|
|
166
|
+
id: string;
|
|
167
|
+
label: string;
|
|
168
|
+
name: string;
|
|
169
|
+
};
|
|
170
|
+
answerOptions: {
|
|
171
|
+
id: string;
|
|
172
|
+
label: string;
|
|
173
|
+
mechanizationQuestionId: string;
|
|
174
|
+
};
|
|
175
|
+
answerValue: string;
|
|
176
|
+
mechanizationId: string;
|
|
177
|
+
}[];
|
|
114
178
|
};
|
|
115
179
|
type SpeedChangesChartDTO = {
|
|
116
180
|
speed: number;
|
|
@@ -238,10 +302,20 @@ type UpdateTrackingDeviceVariables = {
|
|
|
238
302
|
deviceCode: string;
|
|
239
303
|
verificationToken: string;
|
|
240
304
|
};
|
|
241
|
-
type
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
305
|
+
type MechanizationQuestionModel = {
|
|
306
|
+
id: Identifiers.QuestionId;
|
|
307
|
+
name: string;
|
|
308
|
+
label: string;
|
|
309
|
+
placeholder: string;
|
|
310
|
+
isRequired: boolean;
|
|
311
|
+
options?: {
|
|
312
|
+
value: string | number;
|
|
313
|
+
label: string;
|
|
314
|
+
}[];
|
|
315
|
+
type: "TEXT" | "FILE" | "DATE" | "RADIO" | "NUMBER" | "SELECT" | "PASSWORD" | "CHECK_BOX" | "MULTI_SELECT" | "RADIO";
|
|
316
|
+
};
|
|
317
|
+
type GetMechanizationQuestionVariable = {
|
|
318
|
+
varietyId: Identifiers.MechanizationVarietyId;
|
|
245
319
|
};
|
|
246
320
|
|
|
247
321
|
type ClientConfig = {
|
|
@@ -252,16 +326,16 @@ declare const createClient: (config: ClientConfig, middlewares?: ((_config: Inte
|
|
|
252
326
|
declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof createClient>[1]) => {
|
|
253
327
|
dashboardServices: {
|
|
254
328
|
mechanization: {
|
|
255
|
-
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.
|
|
256
|
-
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Ok<SpeedChangesChartModel[]
|
|
329
|
+
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
|
|
330
|
+
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
|
|
257
331
|
getMechanizations: ({ kindName, farmerId }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
258
332
|
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
259
333
|
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
260
334
|
getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
|
|
261
335
|
UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
262
|
-
|
|
336
|
+
getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
|
|
263
337
|
};
|
|
264
338
|
};
|
|
265
339
|
};
|
|
266
340
|
|
|
267
|
-
export { type BaseResponse, type
|
|
341
|
+
export { type BaseResponse, type GetMechanizationQuestionVariable, type MechanizationListData, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationQuestionModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsData, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type SeasonsProcessModel, type ServerResponse, 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
|
@@ -38,7 +38,7 @@ var createClient = (config, middlewares = []) => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
41
|
-
import { R } from "@mobily/ts-belt";
|
|
41
|
+
import { R as R2 } from "@mobily/ts-belt";
|
|
42
42
|
|
|
43
43
|
// src/services/dashboard/mechanization/mechanization.mapper.ts
|
|
44
44
|
var mappers = {
|
|
@@ -97,9 +97,23 @@ var mappers = {
|
|
|
97
97
|
UpdateTrackingDeviceData: (response) => ({
|
|
98
98
|
deviceCode: response.deviceCode
|
|
99
99
|
}),
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
getQuestion: (dto) => ({
|
|
101
|
+
id: dto.id,
|
|
102
|
+
name: dto.key,
|
|
103
|
+
label: dto.title,
|
|
104
|
+
placeholder: dto.placeholder,
|
|
105
|
+
isRequired: dto.required,
|
|
106
|
+
type: dto.kindName,
|
|
107
|
+
options: dto.options.map((item) => ({ label: item.label, value: item.id }))
|
|
108
|
+
}),
|
|
109
|
+
getQuestions: (dto) => dto.map(mappers.getQuestion)
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/utils/wrapError.ts
|
|
113
|
+
import { R } from "@mobily/ts-belt";
|
|
114
|
+
var wrapError = (error) => {
|
|
115
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
116
|
+
return R.Error(err);
|
|
103
117
|
};
|
|
104
118
|
|
|
105
119
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
@@ -111,15 +125,13 @@ var createMechanizationServices = (client) => ({
|
|
|
111
125
|
const { data } = await client.get(
|
|
112
126
|
`/statics/mechanizations-varieties?kindName=${kindName}`
|
|
113
127
|
);
|
|
114
|
-
return
|
|
128
|
+
return R2.Ok(
|
|
115
129
|
mappers.getMechanizationVarietyList(
|
|
116
130
|
data.result.data.mechanizationVarieties
|
|
117
131
|
)
|
|
118
132
|
);
|
|
119
133
|
} catch (error) {
|
|
120
|
-
|
|
121
|
-
console.error("MechanizationVariety API Error:", err);
|
|
122
|
-
return R.Error(err);
|
|
134
|
+
return wrapError(error);
|
|
123
135
|
}
|
|
124
136
|
},
|
|
125
137
|
getSpeedChangesChartData: async ({
|
|
@@ -130,12 +142,11 @@ var createMechanizationServices = (client) => ({
|
|
|
130
142
|
const { data } = await client.get(
|
|
131
143
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
132
144
|
);
|
|
133
|
-
return
|
|
145
|
+
return R2.Ok(
|
|
134
146
|
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
135
147
|
);
|
|
136
148
|
} catch (error) {
|
|
137
|
-
|
|
138
|
-
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
149
|
+
return wrapError(error);
|
|
139
150
|
}
|
|
140
151
|
},
|
|
141
152
|
getMechanizations: async ({ kindName, farmerId }) => {
|
|
@@ -143,13 +154,11 @@ var createMechanizationServices = (client) => ({
|
|
|
143
154
|
const { data } = await client.get(
|
|
144
155
|
`/farmers/${farmerId}/mechanizations?kindName=${kindName}`
|
|
145
156
|
);
|
|
146
|
-
return
|
|
157
|
+
return R2.Ok(
|
|
147
158
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
148
159
|
);
|
|
149
160
|
} catch (error) {
|
|
150
|
-
|
|
151
|
-
console.error("Mechanization API Error:", err);
|
|
152
|
-
return R.Error(err);
|
|
161
|
+
return wrapError(error);
|
|
153
162
|
}
|
|
154
163
|
},
|
|
155
164
|
getMotorizedMechanizationSensors: async ({
|
|
@@ -158,15 +167,13 @@ var createMechanizationServices = (client) => ({
|
|
|
158
167
|
}) => {
|
|
159
168
|
try {
|
|
160
169
|
const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
|
|
161
|
-
return
|
|
170
|
+
return R2.Ok(
|
|
162
171
|
mappers.getMotorizedMechanizationSensors(
|
|
163
172
|
data.result.data.motorizedMechanizationSensors
|
|
164
173
|
)
|
|
165
174
|
);
|
|
166
175
|
} catch (error) {
|
|
167
|
-
|
|
168
|
-
console.error("Motorized Mechanization Sensors API Error:", err);
|
|
169
|
-
return R.Error(err);
|
|
176
|
+
return wrapError(error);
|
|
170
177
|
}
|
|
171
178
|
},
|
|
172
179
|
SubmitTrackingDeviceCode: async ({
|
|
@@ -179,11 +186,9 @@ var createMechanizationServices = (client) => ({
|
|
|
179
186
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
180
187
|
{ deviceCode }
|
|
181
188
|
);
|
|
182
|
-
return
|
|
189
|
+
return R2.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
183
190
|
} catch (error) {
|
|
184
|
-
|
|
185
|
-
console.error("SubmitTrackingDevice API Error:", err);
|
|
186
|
-
return R.Error(err);
|
|
191
|
+
return wrapError(error);
|
|
187
192
|
}
|
|
188
193
|
},
|
|
189
194
|
getSeasonsProcess: async () => {
|
|
@@ -191,15 +196,13 @@ var createMechanizationServices = (client) => ({
|
|
|
191
196
|
const { data } = await client.get(
|
|
192
197
|
"/statics/mechanizations-seasons-process-kinds"
|
|
193
198
|
);
|
|
194
|
-
return
|
|
199
|
+
return R2.Ok(
|
|
195
200
|
mappers.getSeasonsProcessList(
|
|
196
201
|
data.result.data.mechanizationSeasonProcessKinds
|
|
197
202
|
)
|
|
198
203
|
);
|
|
199
204
|
} catch (error) {
|
|
200
|
-
|
|
201
|
-
console.error("getSeasonsProcess API Error:", err);
|
|
202
|
-
return R.Error(err);
|
|
205
|
+
return wrapError(error);
|
|
203
206
|
}
|
|
204
207
|
},
|
|
205
208
|
UpdateTrackingDeviceCode: async ({
|
|
@@ -213,30 +216,23 @@ var createMechanizationServices = (client) => ({
|
|
|
213
216
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/update-device-code`,
|
|
214
217
|
{ deviceCode, verificationToken }
|
|
215
218
|
);
|
|
216
|
-
return
|
|
219
|
+
return R2.Ok(mappers.UpdateTrackingDeviceData(data));
|
|
217
220
|
} catch (error) {
|
|
218
|
-
|
|
219
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
220
|
-
return R.Error(err);
|
|
221
|
+
return wrapError(error);
|
|
221
222
|
}
|
|
222
223
|
},
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
mechanizationId,
|
|
226
|
-
verificationToken
|
|
224
|
+
getMechanizationQuestionList: async ({
|
|
225
|
+
varietyId
|
|
227
226
|
}) => {
|
|
228
227
|
try {
|
|
229
|
-
const { data } = await client.
|
|
230
|
-
`/
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
const { data } = await client.get(
|
|
229
|
+
`/statics/mechanizations-questions?mechanizationVarietyId=${varietyId}`
|
|
230
|
+
);
|
|
231
|
+
return R2.Ok(
|
|
232
|
+
mappers.getQuestions(data.result.data.mechanizationsQuestions)
|
|
234
233
|
);
|
|
235
|
-
return R.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
236
234
|
} catch (error) {
|
|
237
|
-
|
|
238
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
239
|
-
return R.Error(err);
|
|
235
|
+
return wrapError(error);
|
|
240
236
|
}
|
|
241
237
|
}
|
|
242
238
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agroyaar/sdk",
|
|
3
|
-
"version": "1.5.3-
|
|
3
|
+
"version": "1.5.3-3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"lint": "eslint src --ext .ts",
|
|
24
24
|
"spell-check": "cspell \"src/**/*.{ts,js,json,md}\"",
|
|
25
25
|
"check-all": "pnpm type-check && pnpm lint && pnpm spell-check",
|
|
26
|
-
"release": "release-it"
|
|
26
|
+
"release": "release-it",
|
|
27
|
+
"gen-schema": "openapi-typescript https://stgapi-automation.agroyaar.com/docs/json -o src/core/schema.ts"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"access": "public"
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
"dotenv": "^17.0.1",
|
|
65
66
|
"eslint": "^9.30.1",
|
|
66
67
|
"eslint-plugin-functional": "^9.0.2",
|
|
68
|
+
"openapi-typescript": "^7.8.0",
|
|
67
69
|
"prettier": "^3.6.2",
|
|
68
70
|
"tsup": "^8.5.0",
|
|
69
71
|
"type-fest": "^4.41.0",
|