@tagsamurai/gsts-api-services 1.0.2-beta.3 → 1.0.2-beta.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.
@@ -2,10 +2,10 @@ import _ from "axios";
2
2
  const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP_GLOBAL_SETTINGS_API: "https://staging-api.global-settings.tagsamurai.com", VITE_APP_IMAGE_BASE_URL: "https://staging-api.tagsamurai.com/fam/utility/v2/files", VITE_APP_LOGS_NOTIFICATION_API: "https://staging-api-logs-notification.tagsamurai.com", VITE_APP_TAGSAMURAI_API: "https://staging-api.tagsamurai.com" }, T = (t = "APP_TAGSAMURAI_API") => b["VITE_" + t], a = (t = {}, e = !1) => {
3
3
  const {
4
4
  env: r = "APP_GLOBAL_SETTINGS_API",
5
- prefix: s = "",
5
+ prefix: n = "",
6
6
  headers: i = {},
7
7
  ...c
8
- } = t, y = "".concat(T(r)).concat(s), A = _.create({
8
+ } = t, y = "".concat(T(r)).concat(n), A = _.create({
9
9
  ...c,
10
10
  baseURL: y,
11
11
  headers: e ? i : {
@@ -20,15 +20,15 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
20
20
  }), A;
21
21
  }, g = a({
22
22
  prefix: "/v1/global-settings/auth"
23
- }), h = (t) => {
24
- var e, r, s, i;
25
- return ((e = t.response) == null ? void 0 : e.status) === 401 || ((r = t.response) == null ? void 0 : r.status) === 500 || ((i = (s = t.response) == null ? void 0 : s.data) == null ? void 0 : i.message) === "jwt malformed" ? (window.onblur = null, window.onfocus = null, window.sessionExpired = !0, window.dispatchEvent(new CustomEvent("user:expired"))) : Promise.reject(t);
23
+ }), E = (t) => {
24
+ var e, r, n, i;
25
+ return ((e = t.response) == null ? void 0 : e.status) === 401 || ((r = t.response) == null ? void 0 : r.status) === 500 || ((i = (n = t.response) == null ? void 0 : n.data) == null ? void 0 : i.message) === "jwt malformed" ? (window.onblur = null, window.onfocus = null, window.sessionExpired = !0, window.dispatchEvent(new CustomEvent("user:expired"))) : Promise.reject(t);
26
26
  }, x = {
27
27
  login: (t) => {
28
28
  const e = { ...t, isMobile: !1 };
29
29
  return g.post("/login", e);
30
30
  },
31
- reLogin: (t) => (g.interceptors.response.use((e) => e, h), g.post("/login", t)),
31
+ reLogin: (t) => (g.interceptors.response.use((e) => e, E), g.post("/login", t)),
32
32
  requestOTP: (t) => {
33
33
  const e = { email: t };
34
34
  return g.post("/request-otp", e);
@@ -49,18 +49,18 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
49
49
  * @deprecated use postLogout instead
50
50
  */
51
51
  logout: () => g.post("/logout")
52
- }, E = (t, e, r) => {
53
- const s = new URL(T("APP_TAGSAMURAI_API") || "").origin;
54
- let i = t.startsWith("http") ? t : "".concat(s, "/file-storage/api/file/").concat(t.replace(/^\/+/, ""));
52
+ }, h = (t, e, r) => {
53
+ const n = new URL(T("APP_TAGSAMURAI_API") || "").origin;
54
+ let i = t.startsWith("http") ? t : "".concat(n, "/file-storage/api/file/").concat(t.replace(/^\/+/, ""));
55
55
  if (e || r) {
56
56
  const c = new URLSearchParams();
57
57
  e && (c.set("width", e.toString()), c.set("height", (r == null ? void 0 : r.toString()) || e.toString())), i += "?".concat(c.toString());
58
58
  }
59
59
  return i;
60
60
  }, L = () => {
61
- var e, r, s;
61
+ var e, r, n;
62
62
  const t = JSON.parse((e = localStorage.getItem("user")) != null ? e : "{}");
63
- return (s = (r = t.jwt) != null ? r : t.token) != null ? s : "";
63
+ return (n = (r = t.jwt) != null ? r : t.token) != null ? n : "";
64
64
  }, R = async (t, e) => {
65
65
  const r = await fetch(t, {
66
66
  headers: {
@@ -69,8 +69,8 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
69
69
  });
70
70
  if (!r.ok)
71
71
  throw new Error("Image fetch failed: ".concat(r.status, " ").concat(r.statusText));
72
- const s = await r.arrayBuffer();
73
- return new Blob([s], {
72
+ const n = await r.arrayBuffer();
73
+ return new Blob([n], {
74
74
  type: r.headers.get("Content-Type") || "image/webp"
75
75
  });
76
76
  }, w = async (t) => {
@@ -80,11 +80,11 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
80
80
  } catch (e) {
81
81
  return;
82
82
  }
83
- }, C = async (t, e, r, s) => {
83
+ }, C = async (t, e, r, n) => {
84
84
  if (!t) return;
85
- const i = E(t, e, r);
86
- return s ? i : w(i);
87
- }, k = (t) => {
85
+ const i = h(t, e, r);
86
+ return n ? i : w(i);
87
+ }, N = (t) => {
88
88
  if (!t || typeof t == "string")
89
89
  return;
90
90
  const e = {};
@@ -95,11 +95,11 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
95
95
  [r]: t[r]
96
96
  });
97
97
  }), e;
98
- }, I = a({
98
+ }, m = a({
99
99
  prefix: "/v1/global-settings/change-log"
100
- }), N = {
101
- getChangelogs: (t) => I.get("", { params: t }),
102
- getChangelogOptions: (t) => I.get("/options", { params: t })
100
+ }), k = {
101
+ getChangelogs: (t) => m.get("", { params: t }),
102
+ getChangelogOptions: (t) => m.get("/options", { params: t })
103
103
  }, p = a({
104
104
  prefix: "/v1/global-settings/division"
105
105
  }), B = {
@@ -111,7 +111,10 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
111
111
  const e = { id: JSON.stringify(t) };
112
112
  return p.delete("", { params: e });
113
113
  },
114
- checkDivisionAvailability: (t) => p.get("/available", { params: t })
114
+ getAvailableDivision: (t) => {
115
+ const e = { name: t };
116
+ return p.get("/available", { params: e });
117
+ }
115
118
  }, u = a({
116
119
  prefix: "/v1/global-settings"
117
120
  }), j = {
@@ -124,45 +127,45 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
124
127
  putAuditTAG: (t, e) => u.put("/".concat(t, "/audit"), e),
125
128
  putAllocateTAG: (t, e) => u.put("/".concat(t, "/allocate"), e),
126
129
  putCombineTAG: (t) => u.put("/combine", t)
127
- }, n = a({
130
+ }, s = a({
128
131
  prefix: "/v1/global-settings"
129
132
  }), M = {
130
- getHandheldReader: (t) => n.get("/reader", { params: t }),
131
- getHandheldReaderDetail: (t) => n.get("/reader/".concat(t)),
132
- getHandheldReaderOptions: (t) => n.get("/reader/options", { params: t }),
133
- putMarkHandheldStatus: (t) => n.put("/reader/mark-status", t),
134
- putPingReaders: (t) => n.put("/iot-reader/ping", t),
135
- putMarkIOTStatus: (t, e) => n.put("/".concat(e, "/mark-status"), t),
136
- putEditReaderGroup: (t, e, r) => n.put(
133
+ getHandheldReader: (t) => s.get("/reader", { params: t }),
134
+ getHandheldReaderDetail: (t) => s.get("/reader/".concat(t)),
135
+ getHandheldReaderOptions: (t) => s.get("/reader/options", { params: t }),
136
+ putMarkHandheldStatus: (t) => s.put("/reader/mark-status", t),
137
+ putPingReaders: (t) => s.put("/iot-reader/ping", t),
138
+ putMarkIOTStatus: (t, e) => s.put("/".concat(e, "/mark-status"), t),
139
+ putEditReaderGroup: (t, e, r) => s.put(
137
140
  "/".concat(t === "iot" ? "iot-" : "", "reader/").concat(r, "/set-group"),
138
141
  e
139
142
  ),
140
- putEditAntennaGroup: (t, e) => n.put("/iot-reader/".concat(e, "/set-port-group"), t),
141
- putEditPortStatus: (t, e) => n.put("/iot-reader/".concat(e, "/set-port-status"), t),
142
- putEditAliasName: (t, e, r) => n.put(
143
+ putEditAntennaGroup: (t, e) => s.put("/iot-reader/".concat(e, "/set-port-group"), t),
144
+ putEditPortStatus: (t, e) => s.put("/iot-reader/".concat(e, "/set-port-status"), t),
145
+ putEditAliasName: (t, e, r) => s.put(
143
146
  "/".concat(t === "iot" ? "iot-" : "", "reader/").concat(r, "/set-alias-name"),
144
147
  e
145
148
  ),
146
- putAntennaPower: (t, e) => n.put("/iot-reader/".concat(e, "/set-antenna-power"), t),
147
- getIOTReaderOrAntenna: (t, e) => n.get("/".concat(t), { params: e }),
148
- getIOTReaderDetail: (t) => n.get("/iot-reader/".concat(t)),
149
- getIOTReaderOrAntennaOptions: (t, e) => n.get("/".concat(t, "/options"), { params: e }),
150
- getActivityLog: (t) => n.get("/activity-log", { params: t }),
151
- getActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
152
- getDetailActivityLog: (t) => n.get("/activity-log", { params: t }),
153
- getDetailActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
154
- getExistingAliasNames: () => n.get("/reader/alias-names"),
155
- getIotReaderPort: (t, e) => n.get("/iot-reader/".concat(t, "/ports"), { params: e })
149
+ putAntennaPower: (t, e) => s.put("/iot-reader/".concat(e, "/set-antenna-power"), t),
150
+ getIOTReaderOrAntenna: (t, e) => s.get("/".concat(t), { params: e }),
151
+ getIOTReaderDetail: (t) => s.get("/iot-reader/".concat(t)),
152
+ getIOTReaderOrAntennaOptions: (t, e) => s.get("/".concat(t, "/options"), { params: e }),
153
+ getActivityLog: (t) => s.get("/activity-log", { params: t }),
154
+ getActivityLogOptions: (t) => s.get("/activity-log/options", { params: t }),
155
+ getDetailActivityLog: (t) => s.get("/activity-log", { params: t }),
156
+ getDetailActivityLogOptions: (t) => s.get("/activity-log/options", { params: t }),
157
+ getExistingAliasNames: () => s.get("/reader/alias-names"),
158
+ getIotReaderPort: (t, e) => s.get("/iot-reader/".concat(t, "/ports"), { params: e })
156
159
  }, G = a({
157
160
  env: "APP_LOGS_NOTIFICATION_API",
158
161
  prefix: "/v2"
159
162
  }), q = {
160
163
  getSessionLogList: (t) => G.get("/session-log", { params: t })
161
- }, m = a({
164
+ }, I = a({
162
165
  prefix: "/v1/global-settings/option"
163
166
  }), J = {
164
- getPositions: () => m.get("/position"),
165
- getDivisions: () => m.get("/division")
167
+ getPositions: () => I.get("/position"),
168
+ getDivisions: () => I.get("/division")
166
169
  }, l = a({
167
170
  prefix: "/v1/global-settings/position"
168
171
  }), V = {
@@ -174,7 +177,10 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
174
177
  const e = { id: JSON.stringify(t) };
175
178
  return l.delete("", { params: e });
176
179
  },
177
- checkPositionAvailability: (t) => l.get("/available", { params: t })
180
+ getAvailablePosition: (t) => {
181
+ const e = { name: t };
182
+ return l.get("/available", { params: e });
183
+ }
178
184
  }, U = a({
179
185
  env: "APP_TAGSAMURAI_API",
180
186
  prefix: "/tag/v2"
@@ -219,7 +225,7 @@ const b = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
219
225
  };
220
226
  export {
221
227
  x as AuthServices,
222
- N as ChangelogServices,
228
+ k as ChangelogServices,
223
229
  B as DivisionServices,
224
230
  j as GlobalTagServices,
225
231
  M as HardwareServices,
@@ -231,5 +237,5 @@ export {
231
237
  z as UserServices,
232
238
  T as getBaseURL,
233
239
  C as getImageURL,
234
- k as queryParamsStringfy
240
+ N as queryParamsStringfy
235
241
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagsamurai/gsts-api-services",
3
- "version": "1.0.2-beta.3",
3
+ "version": "1.0.2-beta.5",
4
4
  "author": "developer.tagsamurai",
5
5
  "description": "Global Settings Tag Samurai Services Library",
6
6
  "module": "./api-services.es.js",
@@ -8,7 +8,10 @@ interface PasswordLoginCredentials extends Credentials {
8
8
  interface OTPLoginCredentials extends Credentials {
9
9
  otp: string;
10
10
  }
11
- export type LoginCredentials = PasswordLoginCredentials | OTPLoginCredentials;
11
+ export interface TokenCredential {
12
+ jwt: string;
13
+ }
14
+ export type LoginCredentials = PasswordLoginCredentials | OTPLoginCredentials | TokenCredential;
12
15
  export interface SetPasswordBody {
13
16
  password: string;
14
17
  token: string;
@@ -1,5 +1,5 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { LoginCredentials, SetPasswordBody } from '../dto/auth.dto';
2
+ import { LoginCredentials, SetPasswordBody, TokenCredential } from '../dto/auth.dto';
3
3
  interface LoginResponse {
4
4
  data: {
5
5
  token: string;
@@ -9,9 +9,7 @@ interface LoginResponse {
9
9
  }
10
10
  declare const AuthServices: {
11
11
  login: (form: LoginCredentials) => Promise<AxiosResponse<LoginResponse>>;
12
- reLogin: (body: {
13
- jwt: string;
14
- }) => Promise<AxiosResponse<LoginResponse>>;
12
+ reLogin: (body: TokenCredential) => Promise<AxiosResponse<LoginResponse>>;
15
13
  requestOTP: (email: string) => Promise<AxiosResponse<any, any>>;
16
14
  requestResetPassLink: (email: string) => Promise<AxiosResponse<any, any>>;
17
15
  setPassword: (body: SetPasswordBody) => Promise<AxiosResponse<any, any>>;
@@ -9,8 +9,6 @@ declare const DivisionServices: {
9
9
  postCreateDivision: (body: CreateEditMasterDataBody) => Promise<AxiosResponse>;
10
10
  putEditDivision: (id: string, body: CreateEditMasterDataBody) => Promise<AxiosResponse>;
11
11
  deleteDivisions: (ids: string[]) => Promise<AxiosResponse>;
12
- checkDivisionAvailability: (params: {
13
- name: string;
14
- }) => Promise<AxiosResponse>;
12
+ getAvailableDivision: (name: string) => Promise<AxiosResponse>;
15
13
  };
16
14
  export default DivisionServices;
@@ -9,8 +9,6 @@ declare const PositionServices: {
9
9
  postCreatePosition: (body: CreateEditMasterDataBody) => Promise<AxiosResponse>;
10
10
  putEditPosition: (id: string, body: CreateEditMasterDataBody) => Promise<AxiosResponse>;
11
11
  deletePositions: (ids: string[]) => Promise<AxiosResponse>;
12
- checkPositionAvailability: (params: {
13
- name: string;
14
- }) => Promise<AxiosResponse>;
12
+ getAvailablePosition: (name: string) => Promise<AxiosResponse>;
15
13
  };
16
14
  export default PositionServices;