@agroyaar/sdk 1.0.1

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 ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ createSDK: () => createSDK
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/core/client.ts
38
+ var import_axios = __toESM(require("axios"), 1);
39
+
40
+ // src/core/middlewares/logger.ts
41
+ var requestLogger = (config) => {
42
+ console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
43
+ return config;
44
+ };
45
+ var responseLogger = (response) => {
46
+ console.log(`[Response] ${response.status} ${response.config.url}`);
47
+ return response;
48
+ };
49
+
50
+ // src/core/middlewares/errorHandler.ts
51
+ var errorHandler = (error) => {
52
+ console.error("[HTTP Error]", {
53
+ url: error.config?.url,
54
+ status: error.response?.status,
55
+ message: error.message
56
+ });
57
+ return Promise.reject(error);
58
+ };
59
+
60
+ // src/core/client.ts
61
+ var createClient = (config) => {
62
+ const client = import_axios.default.create({
63
+ baseURL: config.baseURL,
64
+ headers: {
65
+ "Content-Type": "application/json"
66
+ }
67
+ });
68
+ client.interceptors.request.use((request) => {
69
+ if (config.token) {
70
+ request.headers.Authorization = `Bearer ${config.token}`;
71
+ }
72
+ return request;
73
+ });
74
+ client.interceptors.request.use(requestLogger);
75
+ client.interceptors.response.use(responseLogger, errorHandler);
76
+ return client;
77
+ };
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
+ });
88
+
89
+ // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
90
+ 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);
97
+ }
98
+ });
99
+
100
+ // src/index.ts
101
+ var createSDK = (config) => {
102
+ const client = createClient(config);
103
+ return {
104
+ mechanization: createMechanizationServices(client)
105
+ };
106
+ };
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ createSDK
110
+ });
@@ -0,0 +1,21 @@
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 };
@@ -0,0 +1,21 @@
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 };
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ // src/core/client.ts
2
+ import axios from "axios";
3
+
4
+ // src/core/middlewares/logger.ts
5
+ var requestLogger = (config) => {
6
+ console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
7
+ return config;
8
+ };
9
+ var responseLogger = (response) => {
10
+ console.log(`[Response] ${response.status} ${response.config.url}`);
11
+ return response;
12
+ };
13
+
14
+ // src/core/middlewares/errorHandler.ts
15
+ var errorHandler = (error) => {
16
+ console.error("[HTTP Error]", {
17
+ url: error.config?.url,
18
+ status: error.response?.status,
19
+ message: error.message
20
+ });
21
+ return Promise.reject(error);
22
+ };
23
+
24
+ // src/core/client.ts
25
+ var createClient = (config) => {
26
+ const client = axios.create({
27
+ baseURL: config.baseURL,
28
+ headers: {
29
+ "Content-Type": "application/json"
30
+ }
31
+ });
32
+ client.interceptors.request.use((request) => {
33
+ if (config.token) {
34
+ request.headers.Authorization = `Bearer ${config.token}`;
35
+ }
36
+ return request;
37
+ });
38
+ client.interceptors.request.use(requestLogger);
39
+ client.interceptors.response.use(responseLogger, errorHandler);
40
+ return client;
41
+ };
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
+ });
52
+
53
+ // src/services/dashboard/mechanization/mechanizations-varieties/mechanization.service.ts
54
+ 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);
61
+ }
62
+ });
63
+
64
+ // src/index.ts
65
+ var createSDK = (config) => {
66
+ const client = createClient(config);
67
+ return {
68
+ mechanization: createMechanizationServices(client)
69
+ };
70
+ };
71
+ export {
72
+ createSDK
73
+ };
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@agroyaar/sdk",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.mjs",
9
+ "require": "./dist/index.cjs",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "type": "module",
14
+ "files": [
15
+ "dist",
16
+ "package.json"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "type-check": "tsc --noEmit",
21
+ "lint": "eslint src --ext .ts",
22
+ "spell-check": "cspell \"src/**/*.{ts,js,json,md}\"",
23
+ "check-all": "pnpm type-check && pnpm lint && pnpm spell-check",
24
+ "release": "release-it"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "release-it": {
30
+ "git": {
31
+ "requireCleanWorkingDir": false,
32
+ "tagName": "v${version}"
33
+ },
34
+ "npm": {
35
+ "publish": true
36
+ },
37
+ "hooks": {
38
+ "before:init": [
39
+ "pnpm build"
40
+ ]
41
+ },
42
+ "github": {
43
+ "release": false
44
+ }
45
+ },
46
+ "keywords": [],
47
+ "author": "",
48
+ "license": "MIT",
49
+ "packageManager": "pnpm@10.12.3",
50
+ "dependencies": {
51
+ "@mobily/ts-belt": "^3.13.1",
52
+ "axios": "^1.10.0",
53
+ "graphql-request": "^7.2.0",
54
+ "release-it": "12.3.0",
55
+ "zod": "^3.25.75"
56
+ },
57
+ "devDependencies": {
58
+ "@eslint/eslintrc": "^3.3.1",
59
+ "@typescript-eslint/eslint-plugin": "^8.35.1",
60
+ "@typescript-eslint/parser": "^8.35.1",
61
+ "cspell": "^9.1.2",
62
+ "dotenv": "^17.0.1",
63
+ "eslint": "^9.30.1",
64
+ "eslint-plugin-functional": "^9.0.2",
65
+ "prettier": "^3.6.2",
66
+ "tsup": "^8.5.0",
67
+ "type-fest": "^4.41.0",
68
+ "typescript": "^5.8.3"
69
+ }
70
+ }