@tagsamurai/gsts-api-services 1.0.2-beta.1 → 1.0.2-beta.3

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.
@@ -1,35 +1,66 @@
1
- import O from "axios";
2
- const y = { 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") => y["VITE_" + t], o = (t = {}, e = !1) => {
1
+ import _ from "axios";
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: i = "",
6
- headers: g = {},
7
- ...u
8
- } = t, _ = "".concat(T(r)).concat(i), A = O.create({
9
- ...u,
10
- baseURL: _,
11
- headers: e ? g : {
5
+ prefix: s = "",
6
+ headers: i = {},
7
+ ...c
8
+ } = t, y = "".concat(T(r)).concat(s), A = _.create({
9
+ ...c,
10
+ baseURL: y,
11
+ headers: e ? i : {
12
12
  "Content-Type": "application/json",
13
- ...g
13
+ ...i
14
14
  }
15
15
  });
16
- return A.interceptors.request.use((d) => {
17
- var P, $, f;
18
- const v = JSON.parse((P = localStorage.getItem("user")) != null ? P : "{}"), m = (f = ($ = v.jwt) != null ? $ : v.token) != null ? f : "";
19
- return d.headers.Authorization = "Bearer ".concat(m), d;
16
+ return A.interceptors.request.use((v) => {
17
+ var f, $, S;
18
+ const P = JSON.parse((f = localStorage.getItem("user")) != null ? f : "{}"), O = (S = ($ = P.jwt) != null ? $ : P.token) != null ? S : "";
19
+ return v.headers.Authorization = "Bearer ".concat(O), v;
20
20
  }), A;
21
- }, h = (t, e, r) => {
22
- const i = new URL(T("APP_TAGSAMURAI_API") || "").origin;
23
- let g = t.startsWith("http") ? t : "".concat(i, "/file-storage/api/file/").concat(t.replace(/^\/+/, ""));
21
+ }, g = a({
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);
26
+ }, x = {
27
+ login: (t) => {
28
+ const e = { ...t, isMobile: !1 };
29
+ return g.post("/login", e);
30
+ },
31
+ reLogin: (t) => (g.interceptors.response.use((e) => e, h), g.post("/login", t)),
32
+ requestOTP: (t) => {
33
+ const e = { email: t };
34
+ return g.post("/request-otp", e);
35
+ },
36
+ requestResetPassLink: (t) => {
37
+ const e = { email: t };
38
+ return g.post("/request-reset-link", e);
39
+ },
40
+ setPassword: (t) => g.post("/set-password", t),
41
+ verifyToken: (t) => g.get("/verify-token/".concat(t)),
42
+ confirmEmailChange: (t) => {
43
+ const e = { token: t };
44
+ return g.put("/confirm-email-change/confirm", e);
45
+ },
46
+ postLogout: () => g.post("/logout"),
47
+ /**
48
+ *
49
+ * @deprecated use postLogout instead
50
+ */
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(/^\/+/, ""));
24
55
  if (e || r) {
25
- const u = new URLSearchParams();
26
- e && (u.set("width", e.toString()), u.set("height", (r == null ? void 0 : r.toString()) || e.toString())), g += "?".concat(u.toString());
56
+ const c = new URLSearchParams();
57
+ e && (c.set("width", e.toString()), c.set("height", (r == null ? void 0 : r.toString()) || e.toString())), i += "?".concat(c.toString());
27
58
  }
28
- return g;
29
- }, E = () => {
30
- var e, r, i;
59
+ return i;
60
+ }, L = () => {
61
+ var e, r, s;
31
62
  const t = JSON.parse((e = localStorage.getItem("user")) != null ? e : "{}");
32
- return (i = (r = t.jwt) != null ? r : t.token) != null ? i : "";
63
+ return (s = (r = t.jwt) != null ? r : t.token) != null ? s : "";
33
64
  }, R = async (t, e) => {
34
65
  const r = await fetch(t, {
35
66
  headers: {
@@ -38,22 +69,22 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
38
69
  });
39
70
  if (!r.ok)
40
71
  throw new Error("Image fetch failed: ".concat(r.status, " ").concat(r.statusText));
41
- const i = await r.arrayBuffer();
42
- return new Blob([i], {
72
+ const s = await r.arrayBuffer();
73
+ return new Blob([s], {
43
74
  type: r.headers.get("Content-Type") || "image/webp"
44
75
  });
45
- }, G = async (t) => {
76
+ }, w = async (t) => {
46
77
  try {
47
- const e = E(), r = await R(t, e);
78
+ const e = L(), r = await R(t, e);
48
79
  return URL.createObjectURL(r);
49
80
  } catch (e) {
50
81
  return;
51
82
  }
52
- }, C = async (t, e, r, i) => {
83
+ }, C = async (t, e, r, s) => {
53
84
  if (!t) return;
54
- const g = h(t, e, r);
55
- return i ? g : G(g);
56
- }, N = (t) => {
85
+ const i = E(t, e, r);
86
+ return s ? i : w(i);
87
+ }, k = (t) => {
57
88
  if (!t || typeof t == "string")
58
89
  return;
59
90
  const e = {};
@@ -64,16 +95,14 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
64
95
  [r]: t[r]
65
96
  });
66
97
  }), e;
67
- }, L = o({
68
- prefix: "/v1/global-settings/auth"
69
- }), U = () => L.post("/logout"), w = { logout: U }, S = o({
98
+ }, I = a({
70
99
  prefix: "/v1/global-settings/change-log"
71
- }), B = {
72
- getChangelogs: (t) => S.get("", { params: t }),
73
- getChangelogOptions: (t) => S.get("/options", { params: t })
74
- }, p = o({
100
+ }), N = {
101
+ getChangelogs: (t) => I.get("", { params: t }),
102
+ getChangelogOptions: (t) => I.get("/options", { params: t })
103
+ }, p = a({
75
104
  prefix: "/v1/global-settings/division"
76
- }), k = {
105
+ }), B = {
77
106
  getDivisions: (t) => p.get("", { params: t }),
78
107
  getDivisionDetail: (t) => p.get("/".concat(t)),
79
108
  postCreateDivision: (t) => p.post("/", t),
@@ -81,20 +110,21 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
81
110
  deleteDivisions: (t) => {
82
111
  const e = { id: JSON.stringify(t) };
83
112
  return p.delete("", { params: e });
84
- }
85
- }, a = o({
113
+ },
114
+ checkDivisionAvailability: (t) => p.get("/available", { params: t })
115
+ }, u = a({
86
116
  prefix: "/v1/global-settings"
87
117
  }), j = {
88
- getTAGAllPaired: (t, e) => a.get("/".concat(t), { params: e }),
89
- getTAGAllPairedOptions: (t, e) => a.get("/".concat(t, "/options"), { params: e }),
90
- getTAGNotPaired: (t, e) => a.get("/".concat(t, "/not-paired"), { params: e }),
91
- getTAGNotPairedOptions: (t, e) => a.get("/".concat(t, "/not-paired/options"), { params: e }),
92
- getScanTAG: (t, e) => a.get("/".concat(t, "/scan"), { params: e }),
93
- putDetailAuditTAG: (t, e) => a.put("/".concat(t, "/audit-detail"), e),
94
- putAuditTAG: (t, e) => a.put("/".concat(t, "/audit"), e),
95
- putAllocateTAG: (t, e) => a.put("/".concat(t, "/allocate"), e),
96
- putCombineTAG: (t) => a.put("/combine", t)
97
- }, n = o({
118
+ getTAGAllPaired: (t, e) => u.get("/".concat(t), { params: e }),
119
+ getTAGAllPairedOptions: (t, e) => u.get("/".concat(t, "/options"), { params: e }),
120
+ getTAGNotPaired: (t, e) => u.get("/".concat(t, "/not-paired"), { params: e }),
121
+ getTAGNotPairedOptions: (t, e) => u.get("/".concat(t, "/not-paired/options"), { params: e }),
122
+ getScanTAG: (t, e) => u.get("/".concat(t, "/scan"), { params: e }),
123
+ putDetailAuditTAG: (t, e) => u.put("/".concat(t, "/audit-detail"), e),
124
+ putAuditTAG: (t, e) => u.put("/".concat(t, "/audit"), e),
125
+ putAllocateTAG: (t, e) => u.put("/".concat(t, "/allocate"), e),
126
+ putCombineTAG: (t) => u.put("/combine", t)
127
+ }, n = a({
98
128
  prefix: "/v1/global-settings"
99
129
  }), M = {
100
130
  getHandheldReader: (t) => n.get("/reader", { params: t }),
@@ -123,82 +153,83 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
123
153
  getDetailActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
124
154
  getExistingAliasNames: () => n.get("/reader/alias-names"),
125
155
  getIotReaderPort: (t, e) => n.get("/iot-reader/".concat(t, "/ports"), { params: e })
126
- }, b = o({
156
+ }, G = a({
127
157
  env: "APP_LOGS_NOTIFICATION_API",
128
158
  prefix: "/v2"
129
- }), J = {
130
- getSessionLogList: (t) => b.get("/session-log", { params: t })
131
- }, I = o({
159
+ }), q = {
160
+ getSessionLogList: (t) => G.get("/session-log", { params: t })
161
+ }, m = a({
132
162
  prefix: "/v1/global-settings/option"
133
- }), V = {
134
- getPositions: () => I.get("/position"),
135
- getDivisions: () => I.get("/division")
136
- }, c = o({
163
+ }), J = {
164
+ getPositions: () => m.get("/position"),
165
+ getDivisions: () => m.get("/division")
166
+ }, l = a({
137
167
  prefix: "/v1/global-settings/position"
138
- }), H = {
139
- getPositions: (t) => c.get("", { params: t }),
140
- getPositionDetail: (t) => c.get("/".concat(t)),
141
- postCreatePosition: (t) => c.post("/", t),
142
- putEditPosition: (t, e) => c.put("/".concat(t), e),
168
+ }), V = {
169
+ getPositions: (t) => l.get("", { params: t }),
170
+ getPositionDetail: (t) => l.get("/".concat(t)),
171
+ postCreatePosition: (t) => l.post("/", t),
172
+ putEditPosition: (t, e) => l.put("/".concat(t), e),
143
173
  deletePositions: (t) => {
144
174
  const e = { id: JSON.stringify(t) };
145
- return c.delete("", { params: e });
146
- }
147
- }, D = o({
175
+ return l.delete("", { params: e });
176
+ },
177
+ checkPositionAvailability: (t) => l.get("/available", { params: t })
178
+ }, U = a({
148
179
  env: "APP_TAGSAMURAI_API",
149
180
  prefix: "/tag/v2"
150
- }), F = {
151
- getTagInfo: (t) => D.get("/rfid-qr/scan", { params: t })
152
- }, l = o({
181
+ }), H = {
182
+ getTagInfo: (t) => U.get("/rfid-qr/scan", { params: t })
183
+ }, d = a({
153
184
  prefix: "/v1/global-settings/change-log"
154
- }), q = {
155
- getTAGEventlog: (t) => l.get("/tag-event-log", { params: t }),
156
- getTAGEventlogOptions: (t) => l.get("/tag-event-log/options", { params: t }),
157
- getDetailTAGEventlog: (t) => l.get("/tag-event-log/".concat(t))
158
- }, s = o({
185
+ }), F = {
186
+ getTAGEventlog: (t) => d.get("/tag-event-log", { params: t }),
187
+ getTAGEventlogOptions: (t) => d.get("/tag-event-log/options", { params: t }),
188
+ getDetailTAGEventlog: (t) => d.get("/tag-event-log/".concat(t))
189
+ }, o = a({
159
190
  prefix: "/v1/global-settings/user"
160
191
  }), z = {
161
- getUsers: (t) => s.get("", { params: t }),
162
- getUserDetail: (t) => s.get("/".concat(t)),
163
- getUserSystemLogs: (t, e) => s.get("/".concat(t, "/system-logs"), { params: e }),
192
+ getUsers: (t) => o.get("", { params: t }),
193
+ getUserDetail: (t) => o.get("/".concat(t)),
194
+ getUserSystemLogs: (t, e) => o.get("/".concat(t, "/system-logs"), { params: e }),
164
195
  getUserSystemLogOptions: (t, e) => {
165
196
  const r = {};
166
- return r[e] = !0, s.get("/".concat(t, "/system-logs/options"), { params: r });
197
+ return r[e] = !0, o.get("/".concat(t, "/system-logs/options"), { params: r });
167
198
  },
168
199
  postCreateUser: (t) => {
169
200
  const e = { "Content-Type": "multipart/form-data" };
170
- return s.post("", t, { headers: e });
201
+ return o.post("", t, { headers: e });
171
202
  },
172
203
  putEditUser: (t, e) => {
173
204
  const r = { "Content-Type": "multipart/form-data" };
174
- return s.put("/".concat(t), e, { headers: r });
205
+ return o.put("/".concat(t), e, { headers: r });
175
206
  },
176
207
  deleteUsers: (t) => {
177
208
  const e = { id: JSON.stringify(t) };
178
- return s.delete("", { params: e });
209
+ return o.delete("", { params: e });
179
210
  },
180
- putToggleStatusUsers: (t) => s.put("/active-status", t),
211
+ putToggleStatusUsers: (t) => o.put("/active-status", t),
181
212
  getUserOptions: (t) => {
182
213
  const e = {};
183
- return e[t] = !0, s.get("/options", { params: e });
214
+ return e[t] = !0, o.get("/options", { params: e });
184
215
  },
185
- deleteCancelEmailChange: (t) => s.delete("/cancel-email-change/".concat(t)),
186
- postResendEmail: (t) => s.post("/resend-email", t),
187
- putChangePassword: (t, e) => s.put("/change-password/".concat(t), e)
216
+ deleteCancelEmailChange: (t) => o.delete("/cancel-email-change/".concat(t)),
217
+ postResendEmail: (t) => o.post("/resend-email", t),
218
+ putChangePassword: (t, e) => o.put("/change-password/".concat(t), e)
188
219
  };
189
220
  export {
190
- w as AuthServices,
191
- B as ChangelogServices,
192
- k as DivisionServices,
221
+ x as AuthServices,
222
+ N as ChangelogServices,
223
+ B as DivisionServices,
193
224
  j as GlobalTagServices,
194
225
  M as HardwareServices,
195
- J as LogServices,
196
- V as OptionServices,
197
- H as PositionServices,
198
- q as TagEventlogServices,
199
- F as TagServices,
226
+ q as LogServices,
227
+ J as OptionServices,
228
+ V as PositionServices,
229
+ F as TagEventlogServices,
230
+ H as TagServices,
200
231
  z as UserServices,
201
232
  T as getBaseURL,
202
233
  C as getImageURL,
203
- N as queryParamsStringfy
234
+ k as queryParamsStringfy
204
235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagsamurai/gsts-api-services",
3
- "version": "1.0.2-beta.1",
3
+ "version": "1.0.2-beta.3",
4
4
  "author": "developer.tagsamurai",
5
5
  "description": "Global Settings Tag Samurai Services Library",
6
6
  "module": "./api-services.es.js",
@@ -0,0 +1,18 @@
1
+ interface Credentials {
2
+ email: string;
3
+ dontDeletePreviousSession: boolean;
4
+ }
5
+ interface PasswordLoginCredentials extends Credentials {
6
+ password: string;
7
+ }
8
+ interface OTPLoginCredentials extends Credentials {
9
+ otp: string;
10
+ }
11
+ export type LoginCredentials = PasswordLoginCredentials | OTPLoginCredentials;
12
+ export interface SetPasswordBody {
13
+ password: string;
14
+ token: string;
15
+ type: SetPasswordType;
16
+ }
17
+ export type SetPasswordType = 'reset' | 'confirm';
18
+ export {};
@@ -1,5 +1,32 @@
1
1
  import { AxiosResponse } from 'axios';
2
- declare const _default: {
3
- logout: () => Promise<AxiosResponse>;
2
+ import { LoginCredentials, SetPasswordBody } from '../dto/auth.dto';
3
+ interface LoginResponse {
4
+ data: {
5
+ token: string;
6
+ tokenExpiresAt: string;
7
+ [key: string]: any;
8
+ };
9
+ }
10
+ declare const AuthServices: {
11
+ login: (form: LoginCredentials) => Promise<AxiosResponse<LoginResponse>>;
12
+ reLogin: (body: {
13
+ jwt: string;
14
+ }) => Promise<AxiosResponse<LoginResponse>>;
15
+ requestOTP: (email: string) => Promise<AxiosResponse<any, any>>;
16
+ requestResetPassLink: (email: string) => Promise<AxiosResponse<any, any>>;
17
+ setPassword: (body: SetPasswordBody) => Promise<AxiosResponse<any, any>>;
18
+ verifyToken: (token: string) => Promise<AxiosResponse<any, any>>;
19
+ confirmEmailChange: (token: string) => Promise<AxiosResponse<any, any>>;
20
+ postLogout: () => Promise<AxiosResponse<any, any>>;
21
+ /**
22
+ *
23
+ * @deprecated use postLogout instead
24
+ */
25
+ logout: () => Promise<AxiosResponse<any, any>>;
4
26
  };
5
- export default _default;
27
+ declare global {
28
+ interface Window {
29
+ sessionExpired: boolean;
30
+ }
31
+ }
32
+ export default AuthServices;
@@ -9,5 +9,8 @@ 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
15
  };
13
16
  export default DivisionServices;
@@ -9,5 +9,8 @@ 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
15
  };
13
16
  export default PositionServices;
@@ -44,6 +44,7 @@ export type UserDetail = {
44
44
  isTemporary: boolean;
45
45
  expiryDate: string;
46
46
  access: string[];
47
+ isConfirmed: boolean;
47
48
  name: string;
48
49
  userTag?: string;
49
50
  isSelf?: boolean;
@@ -62,6 +63,7 @@ export type UserItem = {
62
63
  phoneNumber: string;
63
64
  modifiedBy: ModifiedBy;
64
65
  lastUpdate: string;
66
+ isEmailConfirmed: boolean;
65
67
  isSelf?: boolean;
66
68
  };
67
69
  interface ModifiedBy {