@agroyaar/sdk 1.0.8-2 → 1.0.8-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,16 +37,6 @@ module.exports = __toCommonJS(src_exports);
37
37
  // src/core/client.ts
38
38
  var import_axios = __toESM(require("axios"), 1);
39
39
 
40
- // src/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
40
  // src/middlewares/errorHandler.ts
51
41
  var errorHandler = (error) => {
52
42
  console.error("[HTTP Error]", {
@@ -57,20 +47,27 @@ var errorHandler = (error) => {
57
47
  return Promise.reject(error);
58
48
  };
59
49
 
50
+ // src/middlewares/logger.ts
51
+ var requestLogger = (config) => {
52
+ console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
53
+ return config;
54
+ };
55
+ var responseLogger = (response) => {
56
+ console.log(`[Response] ${response.status} ${response.config.url}`);
57
+ return response;
58
+ };
59
+
60
60
  // src/core/client.ts
61
- var createClient = (config) => {
61
+ var createClient = (config, middlewares = []) => {
62
62
  const client = import_axios.default.create({
63
63
  baseURL: config.baseURL,
64
64
  headers: {
65
65
  "Content-Type": "application/json"
66
66
  }
67
67
  });
68
- client.interceptors.request.use((request) => {
69
- if (config.token) {
70
- request.headers.Authorization = `Bearer ${config.token}`;
71
- }
72
- return request;
73
- });
68
+ for (const middleware of middlewares) {
69
+ client.interceptors.request.use(middleware);
70
+ }
74
71
  client.interceptors.request.use(requestLogger);
75
72
  client.interceptors.response.use(responseLogger, errorHandler);
76
73
  return client;
@@ -94,6 +91,7 @@ var mappers = {
94
91
  id: response.id,
95
92
  commonName: response.commonName,
96
93
  model: response.model,
94
+ avatarURL: response.avatarURL,
97
95
  manufactureYear: response.manufactureYear,
98
96
  code: response.code,
99
97
  variety: mappers.getMechanizationVariety(response.variety)
@@ -138,8 +136,8 @@ var createMechanizationServices = (client) => ({
138
136
  });
139
137
 
140
138
  // src/index.ts
141
- var createSDK = (config) => {
142
- const client = createClient(config);
139
+ var createSDK = (config, middlewares = []) => {
140
+ const client = createClient(config, middlewares);
143
141
  return {
144
142
  dashboardServices: {
145
143
  mechanization: createMechanizationServices(client)
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as _mobily_ts_belt from '@mobily/ts-belt';
2
+ import * as axios from 'axios';
3
+ import { InternalAxiosRequestConfig } from 'axios';
2
4
 
3
5
  declare const __brand: unique symbol;
4
6
  type Brand<B> = {
@@ -54,7 +56,8 @@ type MechanizationModel = {
54
56
  id: Identifiers.MechanizationId;
55
57
  model: string;
56
58
  commonName: string;
57
- manufactureYear: number;
59
+ avatarURL: string;
60
+ manufactureYear: string;
58
61
  code: string;
59
62
  variety: MechanizationVarietyModel;
60
63
  };
@@ -64,10 +67,10 @@ type MechanizationVariables = {
64
67
 
65
68
  type ClientConfig = {
66
69
  readonly baseURL: string;
67
- readonly token?: string;
68
70
  };
71
+ declare const createClient: (config: ClientConfig, middlewares?: ((_config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig)[]) => axios.AxiosInstance;
69
72
 
70
- declare const createSDK: (config: ClientConfig) => {
73
+ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof createClient>[1]) => {
71
74
  dashboardServices: {
72
75
  mechanization: {
73
76
  getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
@@ -76,4 +79,4 @@ declare const createSDK: (config: ClientConfig) => {
76
79
  };
77
80
  };
78
81
 
79
- export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVarietyModel, type MechanizationVarietyVariables, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
82
+ export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
package/dist/index.mjs CHANGED
@@ -1,16 +1,6 @@
1
1
  // src/core/client.ts
2
2
  import axios from "axios";
3
3
 
4
- // src/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
4
  // src/middlewares/errorHandler.ts
15
5
  var errorHandler = (error) => {
16
6
  console.error("[HTTP Error]", {
@@ -21,20 +11,27 @@ var errorHandler = (error) => {
21
11
  return Promise.reject(error);
22
12
  };
23
13
 
14
+ // src/middlewares/logger.ts
15
+ var requestLogger = (config) => {
16
+ console.log(`[Request] ${config.method?.toUpperCase()} ${config.url}`);
17
+ return config;
18
+ };
19
+ var responseLogger = (response) => {
20
+ console.log(`[Response] ${response.status} ${response.config.url}`);
21
+ return response;
22
+ };
23
+
24
24
  // src/core/client.ts
25
- var createClient = (config) => {
25
+ var createClient = (config, middlewares = []) => {
26
26
  const client = axios.create({
27
27
  baseURL: config.baseURL,
28
28
  headers: {
29
29
  "Content-Type": "application/json"
30
30
  }
31
31
  });
32
- client.interceptors.request.use((request) => {
33
- if (config.token) {
34
- request.headers.Authorization = `Bearer ${config.token}`;
35
- }
36
- return request;
37
- });
32
+ for (const middleware of middlewares) {
33
+ client.interceptors.request.use(middleware);
34
+ }
38
35
  client.interceptors.request.use(requestLogger);
39
36
  client.interceptors.response.use(responseLogger, errorHandler);
40
37
  return client;
@@ -58,6 +55,7 @@ var mappers = {
58
55
  id: response.id,
59
56
  commonName: response.commonName,
60
57
  model: response.model,
58
+ avatarURL: response.avatarURL,
61
59
  manufactureYear: response.manufactureYear,
62
60
  code: response.code,
63
61
  variety: mappers.getMechanizationVariety(response.variety)
@@ -102,8 +100,8 @@ var createMechanizationServices = (client) => ({
102
100
  });
103
101
 
104
102
  // src/index.ts
105
- var createSDK = (config) => {
106
- const client = createClient(config);
103
+ var createSDK = (config, middlewares = []) => {
104
+ const client = createClient(config, middlewares);
107
105
  return {
108
106
  dashboardServices: {
109
107
  mechanization: createMechanizationServices(client)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "1.0.8-2",
3
+ "version": "1.0.8-4",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",