@agroyaar/sdk 1.0.3 → 1.0.4

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
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(src_exports);
37
37
  // src/core/client.ts
38
38
  var import_axios = __toESM(require("axios"), 1);
39
39
 
40
- // src/core/middlewares/logger.ts
40
+ // src/middlewares/logger.ts
41
41
  var requestLogger = (config) => {
42
42
  console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
43
43
  return config;
@@ -47,7 +47,7 @@ var responseLogger = (response) => {
47
47
  return response;
48
48
  };
49
49
 
50
- // src/core/middlewares/errorHandler.ts
50
+ // src/middlewares/errorHandler.ts
51
51
  var errorHandler = (error) => {
52
52
  console.error("[HTTP Error]", {
53
53
  url: error.config?.url,
@@ -76,24 +76,42 @@ var createClient = (config) => {
76
76
  return client;
77
77
  };
78
78
 
79
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.mapper.ts
80
- var mapMechanizationVariety = (model) => ({
81
- id: model.id,
82
- name: model.name,
83
- iconUrl: model.iconURL,
84
- kindLabel: model.kind.label,
85
- seasonProcessIds: model.seasonProcessIds,
86
- machineUsageIds: model.machineUsageIds
87
- });
79
+ // src/services/dashboard/mechanization/mechanization.service.ts
80
+ var import_ts_belt = require("@mobily/ts-belt");
81
+
82
+ // src/services/dashboard/mechanization/mechanization.mapper.ts
83
+ var mappers = {
84
+ getMechanizationVariety: (response) => ({
85
+ id: response.id,
86
+ name: response.name,
87
+ iconURL: response.iconURL,
88
+ kind: {
89
+ id: response.kind.id,
90
+ label: response.kind.label,
91
+ name: response.kind.name
92
+ },
93
+ seasonProcessIds: response.seasonProcessIds,
94
+ machineUsageIds: response.machineUsageIds
95
+ })
96
+ };
88
97
 
89
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
98
+ // src/services/dashboard/mechanization/mechanization.service.ts
90
99
  var createMechanizationServices = (client) => ({
91
- getMechanizationVarieties: async (kindName) => {
92
- const response = await client.get(
93
- `/statics/mechanizations-varieties?kindName=${kindName}`
94
- );
95
- const models = response.data.result.data.mechanizationVarieties;
96
- return models.map(mapMechanizationVariety);
100
+ getMechanizationVarieties: async ({
101
+ kindName
102
+ }) => {
103
+ try {
104
+ const { data } = await client.get(
105
+ `/statics/mechanizations-varieties?kindName=${kindName}`
106
+ );
107
+ return data && import_ts_belt.R.Ok(
108
+ mappers.getMechanizationVariety(
109
+ data.result.data.mechanizationVarieties
110
+ )
111
+ );
112
+ } catch (_error) {
113
+ return import_ts_belt.R.Error(new Error());
114
+ }
97
115
  }
98
116
  });
99
117
 
@@ -101,7 +119,9 @@ var createMechanizationServices = (client) => ({
101
119
  var createSDK = (config) => {
102
120
  const client = createClient(config);
103
121
  return {
104
- mechanization: createMechanizationServices(client)
122
+ dashboardServices: {
123
+ mechanization: createMechanizationServices(client)
124
+ }
105
125
  };
106
126
  };
107
127
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.d.ts CHANGED
@@ -1,11 +1,29 @@
1
- type MechanizationVarietyDto = {
2
- id: string;
1
+ declare const __brand: unique symbol;
2
+ type Brand<B> = {
3
+ readonly [__brand]: B;
4
+ };
5
+ type Branded<T, B> = Brand<B> & T;
6
+
7
+ declare namespace Identifiers {
8
+ type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
9
+ type KindId = Branded<string, "kind-id">;
10
+ }
11
+
12
+ type MechanizationVarietyModel = {
13
+ id: Identifiers.MechanizationVarietyId;
3
14
  name: string;
4
- iconUrl: string;
5
- kindLabel: string;
15
+ iconURL: string;
16
+ kind: {
17
+ id: Identifiers.KindId;
18
+ label: string;
19
+ name: string;
20
+ };
6
21
  seasonProcessIds: string[];
7
22
  machineUsageIds: string[];
8
23
  };
24
+ type MechanizationVarietyVariables = {
25
+ kindName: "MOTORIZED" | "NON_MOTORIZED";
26
+ };
9
27
 
10
28
  type ClientConfig = {
11
29
  readonly baseURL: string;
@@ -13,9 +31,11 @@ type ClientConfig = {
13
31
  };
14
32
 
15
33
  declare const createSDK: (config: ClientConfig) => {
16
- mechanization: {
17
- getMechanizationVarieties: (kindName: "MOTORIZED" | "NON_MOTORIZED") => Promise<MechanizationVarietyDto[]>;
34
+ dashboardServices: {
35
+ mechanization: {
36
+ getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<any>;
37
+ };
18
38
  };
19
39
  };
20
40
 
21
- export { type MechanizationVarietyDto, createSDK };
41
+ export { type MechanizationVarietyModel, type MechanizationVarietyVariables, createSDK };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/core/client.ts
2
2
  import axios from "axios";
3
3
 
4
- // src/core/middlewares/logger.ts
4
+ // src/middlewares/logger.ts
5
5
  var requestLogger = (config) => {
6
6
  console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
7
7
  return config;
@@ -11,7 +11,7 @@ var responseLogger = (response) => {
11
11
  return response;
12
12
  };
13
13
 
14
- // src/core/middlewares/errorHandler.ts
14
+ // src/middlewares/errorHandler.ts
15
15
  var errorHandler = (error) => {
16
16
  console.error("[HTTP Error]", {
17
17
  url: error.config?.url,
@@ -40,24 +40,42 @@ var createClient = (config) => {
40
40
  return client;
41
41
  };
42
42
 
43
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.mapper.ts
44
- var mapMechanizationVariety = (model) => ({
45
- id: model.id,
46
- name: model.name,
47
- iconUrl: model.iconURL,
48
- kindLabel: model.kind.label,
49
- seasonProcessIds: model.seasonProcessIds,
50
- machineUsageIds: model.machineUsageIds
51
- });
43
+ // src/services/dashboard/mechanization/mechanization.service.ts
44
+ import { R } from "@mobily/ts-belt";
45
+
46
+ // src/services/dashboard/mechanization/mechanization.mapper.ts
47
+ var mappers = {
48
+ getMechanizationVariety: (response) => ({
49
+ id: response.id,
50
+ name: response.name,
51
+ iconURL: response.iconURL,
52
+ kind: {
53
+ id: response.kind.id,
54
+ label: response.kind.label,
55
+ name: response.kind.name
56
+ },
57
+ seasonProcessIds: response.seasonProcessIds,
58
+ machineUsageIds: response.machineUsageIds
59
+ })
60
+ };
52
61
 
53
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
62
+ // src/services/dashboard/mechanization/mechanization.service.ts
54
63
  var createMechanizationServices = (client) => ({
55
- getMechanizationVarieties: async (kindName) => {
56
- const response = await client.get(
57
- `/statics/mechanizations-varieties?kindName=${kindName}`
58
- );
59
- const models = response.data.result.data.mechanizationVarieties;
60
- return models.map(mapMechanizationVariety);
64
+ getMechanizationVarieties: async ({
65
+ kindName
66
+ }) => {
67
+ try {
68
+ const { data } = await client.get(
69
+ `/statics/mechanizations-varieties?kindName=${kindName}`
70
+ );
71
+ return data && R.Ok(
72
+ mappers.getMechanizationVariety(
73
+ data.result.data.mechanizationVarieties
74
+ )
75
+ );
76
+ } catch (_error) {
77
+ return R.Error(new Error());
78
+ }
61
79
  }
62
80
  });
63
81
 
@@ -65,7 +83,9 @@ var createMechanizationServices = (client) => ({
65
83
  var createSDK = (config) => {
66
84
  const client = createClient(config);
67
85
  return {
68
- mechanization: createMechanizationServices(client)
86
+ dashboardServices: {
87
+ mechanization: createMechanizationServices(client)
88
+ }
69
89
  };
70
90
  };
71
91
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",