@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 +40 -19
- package/dist/index.d.ts +27 -7
- package/dist/index.mjs +40 -19
- package/package.json +1 -1
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/
|
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/
|
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/
|
80
|
-
var
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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/
|
99
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
90
100
|
var createMechanizationServices = (client) => ({
|
91
|
-
getMechanizationVarieties: async (
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
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
|
-
|
2
|
-
|
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
|
-
|
5
|
-
|
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
|
-
|
17
|
-
|
34
|
+
dashboardServices: {
|
35
|
+
mechanization: {
|
36
|
+
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<any>;
|
37
|
+
};
|
18
38
|
};
|
19
39
|
};
|
20
40
|
|
21
|
-
export { type
|
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/
|
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/
|
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/
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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/
|
63
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
54
64
|
var createMechanizationServices = (client) => ({
|
55
|
-
getMechanizationVarieties: async (
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
87
|
+
dashboardServices: {
|
88
|
+
mechanization: createMechanizationServices(client)
|
89
|
+
}
|
69
90
|
};
|
70
91
|
};
|
71
92
|
export {
|