@agroyaar/sdk 1.1.3 → 1.1.4-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 CHANGED
@@ -98,7 +98,23 @@ var mappers = {
98
98
  kindName: response.kindName,
99
99
  variety: mappers.getMechanizationVariety(response.variety)
100
100
  }),
101
- getMechanizationsList: (response) => response.map(mappers.getMechanization)
101
+ getMechanizationsList: (response) => response.map(mappers.getMechanization),
102
+ getMotorizedMechanizationSensor: (response) => ({
103
+ id: response.id,
104
+ speed: response.speed,
105
+ heading: response.heading,
106
+ latitude: response.latitude,
107
+ longitude: response.longitude,
108
+ fuelLevel: response.fuelLevel,
109
+ engineRpm: response.engineRpm,
110
+ deviceCode: response.deviceCode,
111
+ stateEngine: response.stateEngine,
112
+ engineOilPressure: response.engineOilPressure,
113
+ engineWaterTemperature: response.engineWaterTemperature,
114
+ batteryChargePercentage: response.batteryChargePercentage,
115
+ mechanizationId: response.mechanizationId,
116
+ mechanization: mappers.getMechanization(response.mechanization)
117
+ })
102
118
  };
103
119
 
104
120
  // src/services/dashboard/mechanization/mechanization.service.ts
@@ -121,10 +137,27 @@ var createMechanizationServices = (client) => ({
121
137
  return import_ts_belt.R.Error(err);
122
138
  }
123
139
  },
124
- getMechanizations: async ({ kindName }) => {
140
+ getMechanizations: async ({ farmerId, kindName }) => {
141
+ try {
142
+ const { data } = await client.get(
143
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
144
+ );
145
+ return import_ts_belt.R.Ok(
146
+ mappers.getMechanizationsList(data.result.data.mechanizations)
147
+ );
148
+ } catch (error) {
149
+ const err = error instanceof Error ? error : new Error(String(error));
150
+ console.error("Mechanization API Error:", err);
151
+ return import_ts_belt.R.Error(err);
152
+ }
153
+ },
154
+ getMotorizedMechanizationSensors: async ({
155
+ farmerId,
156
+ mechanizationId
157
+ }) => {
125
158
  try {
126
159
  const { data } = await client.get(
127
- `/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
160
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
128
161
  );
129
162
  return import_ts_belt.R.Ok(
130
163
  mappers.getMechanizationsList(data.result.data.mechanizations)
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ type Branded<T, B> = Brand<B> & T;
11
11
  declare namespace Identifiers {
12
12
  type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
13
13
  type MechanizationId = Branded<string, "mechanizationId-id">;
14
+ type MotorizedMechanizationSensorsId = Branded<string, "motorized-mechanization-sensorsId-id">;
14
15
  }
15
16
 
16
17
  type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
@@ -64,8 +65,29 @@ type MechanizationModel = {
64
65
  variety: MechanizationVarietyModel;
65
66
  };
66
67
  type MechanizationVariables = {
68
+ farmerId: string;
67
69
  kindName: MechanizationType;
68
70
  };
71
+ type MotorizedMechanizationSensorsModel = {
72
+ id: string;
73
+ speed: number;
74
+ heading: string;
75
+ latitude: number;
76
+ longitude: number;
77
+ fuelLevel: number;
78
+ engineRpm: number;
79
+ deviceCode: string;
80
+ stateEngine: boolean;
81
+ engineOilPressure: boolean;
82
+ engineWaterTemperature: string;
83
+ batteryChargePercentage: string;
84
+ mechanizationId: string;
85
+ mechanization: MechanizationModel;
86
+ };
87
+ type MotorizedMechanizationSensorsVariables = {
88
+ farmerId: string;
89
+ mechanizationId: string;
90
+ };
69
91
 
70
92
  type ClientConfig = {
71
93
  readonly baseURL: string;
@@ -76,9 +98,10 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
76
98
  dashboardServices: {
77
99
  mechanization: {
78
100
  getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
79
- getMechanizations: ({ kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
101
+ getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
102
+ getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
80
103
  };
81
104
  };
82
105
  };
83
106
 
84
- export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
107
+ export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
package/dist/index.mjs CHANGED
@@ -62,7 +62,23 @@ var mappers = {
62
62
  kindName: response.kindName,
63
63
  variety: mappers.getMechanizationVariety(response.variety)
64
64
  }),
65
- getMechanizationsList: (response) => response.map(mappers.getMechanization)
65
+ getMechanizationsList: (response) => response.map(mappers.getMechanization),
66
+ getMotorizedMechanizationSensor: (response) => ({
67
+ id: response.id,
68
+ speed: response.speed,
69
+ heading: response.heading,
70
+ latitude: response.latitude,
71
+ longitude: response.longitude,
72
+ fuelLevel: response.fuelLevel,
73
+ engineRpm: response.engineRpm,
74
+ deviceCode: response.deviceCode,
75
+ stateEngine: response.stateEngine,
76
+ engineOilPressure: response.engineOilPressure,
77
+ engineWaterTemperature: response.engineWaterTemperature,
78
+ batteryChargePercentage: response.batteryChargePercentage,
79
+ mechanizationId: response.mechanizationId,
80
+ mechanization: mappers.getMechanization(response.mechanization)
81
+ })
66
82
  };
67
83
 
68
84
  // src/services/dashboard/mechanization/mechanization.service.ts
@@ -85,10 +101,27 @@ var createMechanizationServices = (client) => ({
85
101
  return R.Error(err);
86
102
  }
87
103
  },
88
- getMechanizations: async ({ kindName }) => {
104
+ getMechanizations: async ({ farmerId, kindName }) => {
105
+ try {
106
+ const { data } = await client.get(
107
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
108
+ );
109
+ return R.Ok(
110
+ mappers.getMechanizationsList(data.result.data.mechanizations)
111
+ );
112
+ } catch (error) {
113
+ const err = error instanceof Error ? error : new Error(String(error));
114
+ console.error("Mechanization API Error:", err);
115
+ return R.Error(err);
116
+ }
117
+ },
118
+ getMotorizedMechanizationSensors: async ({
119
+ farmerId,
120
+ mechanizationId
121
+ }) => {
89
122
  try {
90
123
  const { data } = await client.get(
91
- `/farmers/681f11f87eeba74f9bb8f422/mechanizations?kindName=${kindName}`
124
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
92
125
  );
93
126
  return R.Ok(
94
127
  mappers.getMechanizationsList(data.result.data.mechanizations)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.4-0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",