@agroyaar/sdk 1.0.3 → 1.0.5

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,43 @@ 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
+ getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety)
97
+ };
88
98
 
89
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
99
+ // src/services/dashboard/mechanization/mechanization.service.ts
90
100
  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);
101
+ getMechanizationVarieties: async ({
102
+ kindName
103
+ }) => {
104
+ try {
105
+ const { data } = await client.get(
106
+ `/statics/mechanizations-varieties?kindName=${kindName}`
107
+ );
108
+ return data && import_ts_belt.R.Ok(
109
+ mappers.getMechanizationVarietyList(
110
+ data.result.data.mechanizationVarieties
111
+ )
112
+ );
113
+ } catch (_error) {
114
+ return import_ts_belt.R.Error(new Error());
115
+ }
97
116
  }
98
117
  });
99
118
 
@@ -101,7 +120,9 @@ var createMechanizationServices = (client) => ({
101
120
  var createSDK = (config) => {
102
121
  const client = createClient(config);
103
122
  return {
104
- mechanization: createMechanizationServices(client)
123
+ dashboardServices: {
124
+ mechanization: createMechanizationServices(client)
125
+ }
105
126
  };
106
127
  };
107
128
  // 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,43 @@ 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
+ getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety)
61
+ };
52
62
 
53
- // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
63
+ // src/services/dashboard/mechanization/mechanization.service.ts
54
64
  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);
65
+ getMechanizationVarieties: async ({
66
+ kindName
67
+ }) => {
68
+ try {
69
+ const { data } = await client.get(
70
+ `/statics/mechanizations-varieties?kindName=${kindName}`
71
+ );
72
+ return data && R.Ok(
73
+ mappers.getMechanizationVarietyList(
74
+ data.result.data.mechanizationVarieties
75
+ )
76
+ );
77
+ } catch (_error) {
78
+ return R.Error(new Error());
79
+ }
61
80
  }
62
81
  });
63
82
 
@@ -65,7 +84,9 @@ var createMechanizationServices = (client) => ({
65
84
  var createSDK = (config) => {
66
85
  const client = createClient(config);
67
86
  return {
68
- mechanization: createMechanizationServices(client)
87
+ dashboardServices: {
88
+ mechanization: createMechanizationServices(client)
89
+ }
69
90
  };
70
91
  };
71
92
  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.5",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",