@agroyaar/sdk 1.4.1-2 → 1.4.1

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 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,13 +104,24 @@ var mappers = {
99
104
  variety: mappers.getMechanizationVariety(response.variety)
100
105
  }),
101
106
  getMechanizationsList: (response) => response.map(mappers.getMechanization),
102
- getSeasonsProcess: (response) => ({
107
+ getMotorizedMechanizationSensors: (response) => ({
103
108
  id: response.id,
104
- label: response.label,
105
- mechanizationVarietyIds: response.mechanizationVarietyIds,
106
- name: response.name
109
+ speed: response.speed,
110
+ heading: response.heading,
111
+ latitude: response.latitude,
112
+ longitude: response.longitude,
113
+ fuelLevel: response.fuelLevel,
114
+ engineRpm: response.engineRpm,
115
+ deviceCode: response.deviceCode,
116
+ stateEngine: response.stateEngine,
117
+ engineOilPressure: response.engineOilPressure,
118
+ engineWaterTemperature: response.engineWaterTemperature,
119
+ batteryChargePercentage: response.batteryChargePercentage,
120
+ mechanizationId: response.mechanizationId
107
121
  }),
108
- getSeasonsProcessList: (response) => response.map(mappers.getSeasonsProcess)
122
+ SubmitTrackingDeviceData: (response) => ({
123
+ deviceCode: response.deviceCode
124
+ })
109
125
  };
110
126
 
111
127
  // src/services/dashboard/mechanization/mechanization.service.ts
@@ -128,10 +144,26 @@ var createMechanizationServices = (client) => ({
128
144
  return import_ts_belt.R.Error(err);
129
145
  }
130
146
  },
131
- getMechanizations: async ({ kindName }) => {
147
+ getSpeedChangesChartData: async ({
148
+ farmerId,
149
+ mechanizationId
150
+ }) => {
151
+ try {
152
+ const { data } = await client.get(
153
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
154
+ );
155
+ return import_ts_belt.R.Ok(
156
+ mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
157
+ );
158
+ } catch (error) {
159
+ const err = error instanceof Error ? error : new Error(String(error));
160
+ console.error("SpeedChangesChartPointsList API Error:", err);
161
+ }
162
+ },
163
+ getMechanizations: async ({ kindName, farmerId }) => {
132
164
  try {
133
165
  const { data } = await client.get(
134
- `/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
166
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
135
167
  );
136
168
  return import_ts_belt.R.Ok(
137
169
  mappers.getMechanizationsList(data.result.data.mechanizations)
@@ -142,19 +174,36 @@ var createMechanizationServices = (client) => ({
142
174
  return import_ts_belt.R.Error(err);
143
175
  }
144
176
  },
145
- getSeasonsProcess: async () => {
177
+ getMotorizedMechanizationSensors: async ({
178
+ farmerId,
179
+ mechanizationId
180
+ }) => {
146
181
  try {
147
- const { data } = await client.get(
148
- "/statics/mechanizations-seasons-process-kinds"
149
- );
182
+ const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
150
183
  return import_ts_belt.R.Ok(
151
- mappers.getSeasonsProcessList(
152
- data.result.data.mechanizationSeasonProcessKinds
184
+ mappers.getMotorizedMechanizationSensors(
185
+ data.result.data.motorizedMechanizationSensors
153
186
  )
154
187
  );
155
188
  } catch (error) {
156
189
  const err = error instanceof Error ? error : new Error(String(error));
157
- console.error("getSeasonsProcess API Error:", err);
190
+ console.error("Mechanization API Error:", err);
191
+ }
192
+ },
193
+ SubmitTrackingDeviceCode: async ({
194
+ farmerId,
195
+ mechanizationId,
196
+ deviceCode
197
+ }) => {
198
+ try {
199
+ const { data } = await client.put(
200
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
201
+ { deviceCode }
202
+ );
203
+ return import_ts_belt.R.Ok(mappers.SubmitTrackingDeviceData(data));
204
+ } catch (error) {
205
+ const err = error instanceof Error ? error : new Error(String(error));
206
+ console.error("SubmitTrackingDevice API Error:", err);
158
207
  return import_ts_belt.R.Error(err);
159
208
  }
160
209
  }
package/dist/index.d.ts CHANGED
@@ -9,9 +9,176 @@ type Brand<B> = {
9
9
  type Branded<T, B> = Brand<B> & T;
10
10
 
11
11
  declare namespace Identifiers {
12
- type MechanizationVarietyId = Branded<string, "mechanizationVariety-id">;
13
- type MechanizationId = Branded<string, "mechanization-id">;
14
- type SeasonsProcessId = Branded<string, " seasonsProcess-id">;
12
+ type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
13
+ type MechanizationId = Branded<string, "mechanizationId-id">;
14
+ type MotorizedMechanizationSensorsId = Branded<string, "motorized-mechanization-sensorsId-id">;
15
+ type FarmerId = Branded<string, "farmer-id">;
16
+ }
17
+
18
+ type FarmerDTO = {
19
+ id: string;
20
+ username: string;
21
+ firstName: string;
22
+ lastName: string;
23
+ fullName: string;
24
+ phoneNumber: string;
25
+ nationalCode: string;
26
+ farmerCode: string;
27
+ birthDate: string;
28
+ avatar: string;
29
+ province: string;
30
+ provinceId: number;
31
+ city: string;
32
+ cityId: number;
33
+ zone: string;
34
+ address: string;
35
+ postalCode: number;
36
+ role: string;
37
+ productsIds: number[];
38
+ status: string;
39
+ walletBalance: number;
40
+ };
41
+
42
+ type MechanizationAnswerOptionDTO = {
43
+ id: string;
44
+ label: string;
45
+ mechanizationQuestionId: string;
46
+ };
47
+ type InformationDTO = {
48
+ id: string;
49
+ status: Status;
50
+ answerOptions: MechanizationAnswerOptionDTO;
51
+ answerValue: string;
52
+ mechanizationId: string;
53
+ };
54
+
55
+ declare namespace ServerResponseTypes {
56
+ namespace Dashboard {
57
+ type MechanizationVarietyDTO = {
58
+ id: string;
59
+ name: string;
60
+ code: string;
61
+ iconURL: string;
62
+ kind: VarietyKind;
63
+ kindName: MechanizationType;
64
+ seasonsProcess: MechanizationSeasonProcessKind[];
65
+ seasonProcessIds: string[];
66
+ machinesUsage: MechanizationMachineUsageKind[];
67
+ machineUsageIds: string[];
68
+ mechanizationQuestions: string[];
69
+ };
70
+ type MechanizationDTO = {
71
+ id: string;
72
+ model: string;
73
+ commonName: string;
74
+ avatarURL: string;
75
+ manufactureYear: string;
76
+ code: string;
77
+ kind: VarietyKind;
78
+ kindName: MechanizationType;
79
+ deviceCode: string;
80
+ status: Status;
81
+ farmer: FarmerDTO;
82
+ farmerId: string;
83
+ variety: MechanizationVarietyDTO;
84
+ information: InformationDTO[];
85
+ };
86
+ type MotorizedMechanizationSensorsDTO = {
87
+ id: string;
88
+ speed: number;
89
+ heading: string;
90
+ latitude: number;
91
+ longitude: number;
92
+ fuelLevel: number;
93
+ engineRpm: number;
94
+ deviceCode: string;
95
+ stateEngine: boolean;
96
+ engineOilPressure: boolean;
97
+ engineWaterTemperature: string;
98
+ batteryChargePercentage: string;
99
+ mechanizationId: string;
100
+ mechanization: MechanizationDTO;
101
+ };
102
+ type SubmitTrackingDeviceDTO = {
103
+ model: string;
104
+ commonName: string;
105
+ manufactureYear: number;
106
+ code: string;
107
+ deviceCode: string;
108
+ status: {
109
+ id: string;
110
+ label: string;
111
+ name: string;
112
+ };
113
+ farmer: {
114
+ id: string;
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ deletedAt: string | null;
118
+ firstName: string;
119
+ lastName: string;
120
+ phoneNumber: string;
121
+ city: {};
122
+ cityId: string;
123
+ nationalCode: string;
124
+ province: {};
125
+ provinceId: string;
126
+ zone: string;
127
+ farmerCode: string;
128
+ avatar: string;
129
+ walletBalance: number;
130
+ status: string;
131
+ };
132
+ farmerId: string;
133
+ variety: {
134
+ id: string;
135
+ name: string;
136
+ code: string;
137
+ iconURL: string;
138
+ kind: {
139
+ id: string;
140
+ label: string;
141
+ name: string;
142
+ };
143
+ kindName: string;
144
+ seasonsProcess: {
145
+ id: string;
146
+ label: string;
147
+ name: string;
148
+ }[];
149
+ seasonProcessIds: string[];
150
+ machinesUsage: {
151
+ id: string;
152
+ label: string;
153
+ name: string;
154
+ }[];
155
+ machineUsageIds: string[];
156
+ mechanizationQuestions: string[];
157
+ };
158
+ information: {
159
+ id: string;
160
+ createdAt: string;
161
+ updatedAt: string;
162
+ deletedAt: string | null;
163
+ status: {
164
+ id: string;
165
+ label: string;
166
+ name: string;
167
+ };
168
+ answerOptions: {
169
+ id: string;
170
+ label: string;
171
+ mechanizationQuestionId: string;
172
+ };
173
+ answerValue: string;
174
+ mechanizationId: string;
175
+ }[];
176
+ };
177
+ type SpeedChangesChartDTO = {
178
+ speed: number;
179
+ date: string;
180
+ };
181
+ }
15
182
  }
16
183
 
17
184
  type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
@@ -21,6 +188,14 @@ type MechanizationType = "MOTORIZED" | "NON_MOTORIZED";
21
188
  type MechanizationSeasonProcessType = "GROWING" | "HARVESTING" | "PLANTING" | "TRANSPORTATION";
22
189
  type MechanizationMachineUsageType = "BALER" | "CRUSHING" | "CRUST_BREAKER" | "FERTILIZER_SPREADER" | "FORAGE_COLLECTOR" | "FURROWER" | "GRASS_CUTTER" | "GRINDING" | "HARVESTING" | "LEVELING" | "LOADER" | "MULTI_PURPOSE" | "SEEDER" | "SPRAYER" | "TILLAGE" | "TRANSPORTATION" | "WEEDER";
23
190
 
191
+ type ServerResponse<T> = {
192
+ message: string;
193
+ code: string;
194
+ data: T;
195
+ };
196
+ type BaseResponse<T> = {
197
+ result: ServerResponse<T>;
198
+ };
24
199
  type Status = {
25
200
  id: string;
26
201
  label: string;
@@ -41,6 +216,15 @@ type MechanizationMachineUsageKind = {
41
216
  label: string;
42
217
  name: MechanizationMachineUsageType;
43
218
  };
219
+ type MechanizationListData = {
220
+ meta: Record<string, unknown>;
221
+ totalItems: number;
222
+ mechanizations: ServerResponseTypes.Dashboard.MechanizationDTO[];
223
+ };
224
+ type MotorizedMechanizationSensorsData = {
225
+ meta: Record<string, unknown>;
226
+ motorizedMechanizationSensors: ServerResponseTypes.Dashboard.MotorizedMechanizationSensorsDTO;
227
+ };
44
228
 
45
229
  type MechanizationVarietyModel = {
46
230
  id: Identifiers.MechanizationVarietyId;
@@ -65,13 +249,43 @@ type MechanizationModel = {
65
249
  variety: MechanizationVarietyModel;
66
250
  };
67
251
  type MechanizationVariables = {
252
+ farmerId: string;
68
253
  kindName: MechanizationType;
69
254
  };
70
- type SeasonsProcessModel = {
71
- id: Identifiers.SeasonsProcessId;
72
- name: string;
73
- label: string;
74
- mechanizationVarietyIds: string[];
255
+ type MotorizedMechanizationSensorsModel = {
256
+ id: string;
257
+ speed: number;
258
+ heading: string;
259
+ latitude: number;
260
+ longitude: number;
261
+ fuelLevel: number;
262
+ engineRpm: number;
263
+ deviceCode: string;
264
+ stateEngine: boolean;
265
+ engineOilPressure: boolean;
266
+ engineWaterTemperature: string;
267
+ batteryChargePercentage: string;
268
+ mechanizationId: string;
269
+ };
270
+ type MotorizedMechanizationSensorsVariables = {
271
+ farmerId: string;
272
+ mechanizationId: string;
273
+ };
274
+ type SubmitTrackingDeviceModel = {
275
+ deviceCode: string;
276
+ };
277
+ type SubmitTrackingDeviceVariables = {
278
+ farmerId: Identifiers.FarmerId;
279
+ mechanizationId: Identifiers.MechanizationId;
280
+ deviceCode: string;
281
+ };
282
+ type SpeedChangesChartModel = {
283
+ speed: number;
284
+ date: string;
285
+ };
286
+ type SpeedChangesChartVariables = {
287
+ farmerId: Identifiers.FarmerId;
288
+ mechanizationId: Identifiers.MechanizationId;
75
289
  };
76
290
 
77
291
  type ClientConfig = {
@@ -83,10 +297,12 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
83
297
  dashboardServices: {
84
298
  mechanization: {
85
299
  getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
86
- getMechanizations: ({ kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
87
- getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
300
+ getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Ok<SpeedChangesChartModel[]> | undefined>;
301
+ getMechanizations: ({ kindName, farmerId }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
302
+ getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel> | undefined>;
303
+ SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SubmitTrackingDeviceModel>>;
88
304
  };
89
305
  };
90
306
  };
91
307
 
92
- export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type SeasonsProcessModel, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
308
+ export { type BaseResponse, type MechanizationListData, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsData, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type ServerResponse, 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,13 +68,24 @@ var mappers = {
63
68
  variety: mappers.getMechanizationVariety(response.variety)
64
69
  }),
65
70
  getMechanizationsList: (response) => response.map(mappers.getMechanization),
66
- getSeasonsProcess: (response) => ({
71
+ getMotorizedMechanizationSensors: (response) => ({
67
72
  id: response.id,
68
- label: response.label,
69
- mechanizationVarietyIds: response.mechanizationVarietyIds,
70
- name: response.name
73
+ speed: response.speed,
74
+ heading: response.heading,
75
+ latitude: response.latitude,
76
+ longitude: response.longitude,
77
+ fuelLevel: response.fuelLevel,
78
+ engineRpm: response.engineRpm,
79
+ deviceCode: response.deviceCode,
80
+ stateEngine: response.stateEngine,
81
+ engineOilPressure: response.engineOilPressure,
82
+ engineWaterTemperature: response.engineWaterTemperature,
83
+ batteryChargePercentage: response.batteryChargePercentage,
84
+ mechanizationId: response.mechanizationId
71
85
  }),
72
- getSeasonsProcessList: (response) => response.map(mappers.getSeasonsProcess)
86
+ SubmitTrackingDeviceData: (response) => ({
87
+ deviceCode: response.deviceCode
88
+ })
73
89
  };
74
90
 
75
91
  // src/services/dashboard/mechanization/mechanization.service.ts
@@ -92,10 +108,26 @@ var createMechanizationServices = (client) => ({
92
108
  return R.Error(err);
93
109
  }
94
110
  },
95
- getMechanizations: async ({ kindName }) => {
111
+ getSpeedChangesChartData: async ({
112
+ farmerId,
113
+ mechanizationId
114
+ }) => {
115
+ try {
116
+ const { data } = await client.get(
117
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
118
+ );
119
+ return R.Ok(
120
+ mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
121
+ );
122
+ } catch (error) {
123
+ const err = error instanceof Error ? error : new Error(String(error));
124
+ console.error("SpeedChangesChartPointsList API Error:", err);
125
+ }
126
+ },
127
+ getMechanizations: async ({ kindName, farmerId }) => {
96
128
  try {
97
129
  const { data } = await client.get(
98
- `/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
130
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
99
131
  );
100
132
  return R.Ok(
101
133
  mappers.getMechanizationsList(data.result.data.mechanizations)
@@ -106,19 +138,36 @@ var createMechanizationServices = (client) => ({
106
138
  return R.Error(err);
107
139
  }
108
140
  },
109
- getSeasonsProcess: async () => {
141
+ getMotorizedMechanizationSensors: async ({
142
+ farmerId,
143
+ mechanizationId
144
+ }) => {
110
145
  try {
111
- const { data } = await client.get(
112
- "/statics/mechanizations-seasons-process-kinds"
113
- );
146
+ const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
114
147
  return R.Ok(
115
- mappers.getSeasonsProcessList(
116
- data.result.data.mechanizationSeasonProcessKinds
148
+ mappers.getMotorizedMechanizationSensors(
149
+ data.result.data.motorizedMechanizationSensors
117
150
  )
118
151
  );
119
152
  } catch (error) {
120
153
  const err = error instanceof Error ? error : new Error(String(error));
121
- console.error("getSeasonsProcess API Error:", err);
154
+ console.error("Mechanization API Error:", err);
155
+ }
156
+ },
157
+ SubmitTrackingDeviceCode: async ({
158
+ farmerId,
159
+ mechanizationId,
160
+ deviceCode
161
+ }) => {
162
+ try {
163
+ const { data } = await client.put(
164
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
165
+ { deviceCode }
166
+ );
167
+ return R.Ok(mappers.SubmitTrackingDeviceData(data));
168
+ } catch (error) {
169
+ const err = error instanceof Error ? error : new Error(String(error));
170
+ console.error("SubmitTrackingDevice API Error:", err);
122
171
  return R.Error(err);
123
172
  }
124
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "1.4.1-2",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",