@agroyaar/sdk 1.0.2 → 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 +42 -22
- package/dist/index.d.ts +27 -7
- package/dist/{index.js → index.mjs} +39 -19
- package/package.json +1 -1
- package/dist/index.d.cts +0 -21
package/dist/index.cjs
CHANGED
@@ -28,16 +28,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
29
|
|
30
30
|
// src/index.ts
|
31
|
-
var
|
32
|
-
__export(
|
31
|
+
var src_exports = {};
|
32
|
+
__export(src_exports, {
|
33
33
|
createSDK: () => createSDK
|
34
34
|
});
|
35
|
-
module.exports = __toCommonJS(
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
36
36
|
|
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,42 @@ 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
|
+
};
|
88
97
|
|
89
|
-
// src/services/dashboard/mechanization/
|
98
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
90
99
|
var createMechanizationServices = (client) => ({
|
91
|
-
getMechanizationVarieties: async (
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
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
|
-
|
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 };
|
@@ -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,42 @@ 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
|
+
};
|
52
61
|
|
53
|
-
// src/services/dashboard/mechanization/
|
62
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
54
63
|
var createMechanizationServices = (client) => ({
|
55
|
-
getMechanizationVarieties: async (
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
86
|
+
dashboardServices: {
|
87
|
+
mechanization: createMechanizationServices(client)
|
88
|
+
}
|
69
89
|
};
|
70
90
|
};
|
71
91
|
export {
|
package/package.json
CHANGED
package/dist/index.d.cts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
type MechanizationVarietyDto = {
|
2
|
-
id: string;
|
3
|
-
name: string;
|
4
|
-
iconUrl: string;
|
5
|
-
kindLabel: string;
|
6
|
-
seasonProcessIds: string[];
|
7
|
-
machineUsageIds: string[];
|
8
|
-
};
|
9
|
-
|
10
|
-
type ClientConfig = {
|
11
|
-
readonly baseURL: string;
|
12
|
-
readonly token?: string;
|
13
|
-
};
|
14
|
-
|
15
|
-
declare const createSDK: (config: ClientConfig) => {
|
16
|
-
mechanization: {
|
17
|
-
getMechanizationVarieties: (kindName: "MOTORIZED" | "NON_MOTORIZED") => Promise<MechanizationVarietyDto[]>;
|
18
|
-
};
|
19
|
-
};
|
20
|
-
|
21
|
-
export { type MechanizationVarietyDto, createSDK };
|