@tagsamurai/gsts-api-services 1.0.2-beta.1 → 2.0.1-alpha.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/api-services.es.js
CHANGED
|
@@ -1,35 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import _ from "axios";
|
|
2
|
+
const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_APP_GLOBAL_SETTINGS_API: "https://dev-api.global-settings.tagsamurai.com", VITE_APP_IMAGE_BASE_URL: "https://dev-api.tagsamurai.com/fam/utility/v2/files", VITE_APP_LOGS_NOTIFICATION_API: "https://dev-api-logs-notification.tagsamurai.com", VITE_APP_TAGSAMURAI_API: "https://dev-api.tagsamurai.com" }, T = (t = "APP_TAGSAMURAI_API") => E["VITE_" + t], a = (t = {}, e = !1) => {
|
|
3
3
|
const {
|
|
4
4
|
env: r = "APP_GLOBAL_SETTINGS_API",
|
|
5
|
-
prefix:
|
|
6
|
-
headers:
|
|
7
|
-
...
|
|
8
|
-
} = t,
|
|
9
|
-
...
|
|
10
|
-
baseURL:
|
|
11
|
-
headers: e ?
|
|
5
|
+
prefix: s = "",
|
|
6
|
+
headers: i = {},
|
|
7
|
+
...p
|
|
8
|
+
} = t, y = "".concat(T(r)).concat(s), A = _.create({
|
|
9
|
+
...p,
|
|
10
|
+
baseURL: y,
|
|
11
|
+
headers: e ? i : {
|
|
12
12
|
"Content-Type": "application/json",
|
|
13
|
-
...
|
|
13
|
+
...i
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
return A.interceptors.request.use((
|
|
17
|
-
var
|
|
18
|
-
const
|
|
19
|
-
return
|
|
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
|
+
}, u = a({
|
|
22
|
+
prefix: "/v1/global-settings/auth"
|
|
23
|
+
}), b = (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 u.post("/login", e);
|
|
30
|
+
},
|
|
31
|
+
reLogin: (t) => (u.interceptors.response.use((e) => e, b), u.post("/login", t)),
|
|
32
|
+
requestOTP: (t) => {
|
|
33
|
+
const e = { email: t };
|
|
34
|
+
return u.post("/request-otp", e);
|
|
35
|
+
},
|
|
36
|
+
requestResetPassLink: (t) => {
|
|
37
|
+
const e = { email: t };
|
|
38
|
+
return u.post("/request-reset-link", e);
|
|
39
|
+
},
|
|
40
|
+
setPassword: (t) => u.post("/set-password", t),
|
|
41
|
+
verifyToken: (t) => u.get("/verify-token/".concat(t)),
|
|
42
|
+
confirmEmailChange: (t) => {
|
|
43
|
+
const e = { token: t };
|
|
44
|
+
return u.put("/confirm-email-change/confirm", e);
|
|
45
|
+
},
|
|
46
|
+
postLogout: () => u.post("/logout"),
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @deprecated use postLogout instead
|
|
50
|
+
*/
|
|
51
|
+
logout: () => u.post("/logout")
|
|
21
52
|
}, h = (t, e, r) => {
|
|
22
|
-
const
|
|
23
|
-
let
|
|
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
|
|
26
|
-
e && (
|
|
56
|
+
const p = new URLSearchParams();
|
|
57
|
+
e && (p.set("width", e.toString()), p.set("height", (r == null ? void 0 : r.toString()) || e.toString())), i += "?".concat(p.toString());
|
|
27
58
|
}
|
|
28
|
-
return
|
|
29
|
-
},
|
|
30
|
-
var e, r,
|
|
59
|
+
return i;
|
|
60
|
+
}, L = () => {
|
|
61
|
+
var e, r, s;
|
|
31
62
|
const t = JSON.parse((e = localStorage.getItem("user")) != null ? e : "{}");
|
|
32
|
-
return (
|
|
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,21 +69,21 @@ 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
|
|
42
|
-
return new Blob([
|
|
72
|
+
const s = await r.arrayBuffer();
|
|
73
|
+
return new Blob([s], {
|
|
43
74
|
type: r.headers.get("Content-Type") || "image/webp"
|
|
44
75
|
});
|
|
45
|
-
},
|
|
76
|
+
}, w = async (t) => {
|
|
46
77
|
try {
|
|
47
|
-
const 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,
|
|
83
|
+
}, C = async (t, e, r, s) => {
|
|
53
84
|
if (!t) return;
|
|
54
|
-
const
|
|
55
|
-
return
|
|
85
|
+
const i = h(t, e, r);
|
|
86
|
+
return s ? i : w(i);
|
|
56
87
|
}, N = (t) => {
|
|
57
88
|
if (!t || typeof t == "string")
|
|
58
89
|
return;
|
|
@@ -64,37 +95,35 @@ 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
|
-
},
|
|
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({
|
|
75
|
-
prefix: "/v1/global-settings/division"
|
|
76
100
|
}), k = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
101
|
+
getChangelogs: (t) => I.get("", { params: t }),
|
|
102
|
+
getChangelogOptions: (t) => I.get("/options", { params: t })
|
|
103
|
+
}, c = a({
|
|
104
|
+
prefix: "/v1/global-settings/division"
|
|
105
|
+
}), B = {
|
|
106
|
+
getDivisions: (t) => c.get("", { params: t }),
|
|
107
|
+
getDivisionDetail: (t) => c.get("/".concat(t)),
|
|
108
|
+
postCreateDivision: (t) => c.post("/", t),
|
|
109
|
+
putEditDivision: (t, e) => c.put("/".concat(t), e),
|
|
81
110
|
deleteDivisions: (t) => {
|
|
82
111
|
const e = { id: JSON.stringify(t) };
|
|
83
|
-
return
|
|
112
|
+
return c.delete("", { params: e });
|
|
84
113
|
}
|
|
85
|
-
},
|
|
114
|
+
}, g = a({
|
|
86
115
|
prefix: "/v1/global-settings"
|
|
87
116
|
}), j = {
|
|
88
|
-
getTAGAllPaired: (t, e) =>
|
|
89
|
-
getTAGAllPairedOptions: (t, e) =>
|
|
90
|
-
getTAGNotPaired: (t, e) =>
|
|
91
|
-
getTAGNotPairedOptions: (t, e) =>
|
|
92
|
-
getScanTAG: (t, e) =>
|
|
93
|
-
putDetailAuditTAG: (t, e) =>
|
|
94
|
-
putAuditTAG: (t, e) =>
|
|
95
|
-
putAllocateTAG: (t, e) =>
|
|
96
|
-
putCombineTAG: (t) =>
|
|
97
|
-
}, n =
|
|
117
|
+
getTAGAllPaired: (t, e) => g.get("/".concat(t), { params: e }),
|
|
118
|
+
getTAGAllPairedOptions: (t, e) => g.get("/".concat(t, "/options"), { params: e }),
|
|
119
|
+
getTAGNotPaired: (t, e) => g.get("/".concat(t, "/not-paired"), { params: e }),
|
|
120
|
+
getTAGNotPairedOptions: (t, e) => g.get("/".concat(t, "/not-paired/options"), { params: e }),
|
|
121
|
+
getScanTAG: (t, e) => g.get("/".concat(t, "/scan"), { params: e }),
|
|
122
|
+
putDetailAuditTAG: (t, e) => g.put("/".concat(t, "/audit-detail"), e),
|
|
123
|
+
putAuditTAG: (t, e) => g.put("/".concat(t, "/audit"), e),
|
|
124
|
+
putAllocateTAG: (t, e) => g.put("/".concat(t, "/allocate"), e),
|
|
125
|
+
putCombineTAG: (t) => g.put("/combine", t)
|
|
126
|
+
}, n = a({
|
|
98
127
|
prefix: "/v1/global-settings"
|
|
99
128
|
}), M = {
|
|
100
129
|
getHandheldReader: (t) => n.get("/reader", { params: t }),
|
|
@@ -123,80 +152,80 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "staging", PROD: !0, SSR: !1, VITE_APP
|
|
|
123
152
|
getDetailActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
|
|
124
153
|
getExistingAliasNames: () => n.get("/reader/alias-names"),
|
|
125
154
|
getIotReaderPort: (t, e) => n.get("/iot-reader/".concat(t, "/ports"), { params: e })
|
|
126
|
-
},
|
|
155
|
+
}, G = a({
|
|
127
156
|
env: "APP_LOGS_NOTIFICATION_API",
|
|
128
157
|
prefix: "/v2"
|
|
129
|
-
}),
|
|
130
|
-
getSessionLogList: (t) =>
|
|
131
|
-
},
|
|
158
|
+
}), q = {
|
|
159
|
+
getSessionLogList: (t) => G.get("/session-log", { params: t })
|
|
160
|
+
}, m = a({
|
|
132
161
|
prefix: "/v1/global-settings/option"
|
|
133
|
-
}),
|
|
134
|
-
getPositions: () =>
|
|
135
|
-
getDivisions: () =>
|
|
136
|
-
},
|
|
162
|
+
}), J = {
|
|
163
|
+
getPositions: () => m.get("/position"),
|
|
164
|
+
getDivisions: () => m.get("/division")
|
|
165
|
+
}, l = a({
|
|
137
166
|
prefix: "/v1/global-settings/position"
|
|
138
|
-
}),
|
|
139
|
-
getPositions: (t) =>
|
|
140
|
-
getPositionDetail: (t) =>
|
|
141
|
-
postCreatePosition: (t) =>
|
|
142
|
-
putEditPosition: (t, e) =>
|
|
167
|
+
}), V = {
|
|
168
|
+
getPositions: (t) => l.get("", { params: t }),
|
|
169
|
+
getPositionDetail: (t) => l.get("/".concat(t)),
|
|
170
|
+
postCreatePosition: (t) => l.post("/", t),
|
|
171
|
+
putEditPosition: (t, e) => l.put("/".concat(t), e),
|
|
143
172
|
deletePositions: (t) => {
|
|
144
173
|
const e = { id: JSON.stringify(t) };
|
|
145
|
-
return
|
|
174
|
+
return l.delete("", { params: e });
|
|
146
175
|
}
|
|
147
|
-
},
|
|
176
|
+
}, U = a({
|
|
148
177
|
env: "APP_TAGSAMURAI_API",
|
|
149
178
|
prefix: "/tag/v2"
|
|
150
|
-
}),
|
|
151
|
-
getTagInfo: (t) =>
|
|
152
|
-
},
|
|
179
|
+
}), H = {
|
|
180
|
+
getTagInfo: (t) => U.get("/rfid-qr/scan", { params: t })
|
|
181
|
+
}, d = a({
|
|
153
182
|
prefix: "/v1/global-settings/change-log"
|
|
154
|
-
}),
|
|
155
|
-
getTAGEventlog: (t) =>
|
|
156
|
-
getTAGEventlogOptions: (t) =>
|
|
157
|
-
getDetailTAGEventlog: (t) =>
|
|
158
|
-
},
|
|
183
|
+
}), F = {
|
|
184
|
+
getTAGEventlog: (t) => d.get("/tag-event-log", { params: t }),
|
|
185
|
+
getTAGEventlogOptions: (t) => d.get("/tag-event-log/options", { params: t }),
|
|
186
|
+
getDetailTAGEventlog: (t) => d.get("/tag-event-log/".concat(t))
|
|
187
|
+
}, o = a({
|
|
159
188
|
prefix: "/v1/global-settings/user"
|
|
160
189
|
}), z = {
|
|
161
|
-
getUsers: (t) =>
|
|
162
|
-
getUserDetail: (t) =>
|
|
163
|
-
getUserSystemLogs: (t, e) =>
|
|
190
|
+
getUsers: (t) => o.get("", { params: t }),
|
|
191
|
+
getUserDetail: (t) => o.get("/".concat(t)),
|
|
192
|
+
getUserSystemLogs: (t, e) => o.get("/".concat(t, "/system-logs"), { params: e }),
|
|
164
193
|
getUserSystemLogOptions: (t, e) => {
|
|
165
194
|
const r = {};
|
|
166
|
-
return r[e] = !0,
|
|
195
|
+
return r[e] = !0, o.get("/".concat(t, "/system-logs/options"), { params: r });
|
|
167
196
|
},
|
|
168
197
|
postCreateUser: (t) => {
|
|
169
198
|
const e = { "Content-Type": "multipart/form-data" };
|
|
170
|
-
return
|
|
199
|
+
return o.post("", t, { headers: e });
|
|
171
200
|
},
|
|
172
201
|
putEditUser: (t, e) => {
|
|
173
202
|
const r = { "Content-Type": "multipart/form-data" };
|
|
174
|
-
return
|
|
203
|
+
return o.put("/".concat(t), e, { headers: r });
|
|
175
204
|
},
|
|
176
205
|
deleteUsers: (t) => {
|
|
177
206
|
const e = { id: JSON.stringify(t) };
|
|
178
|
-
return
|
|
207
|
+
return o.delete("", { params: e });
|
|
179
208
|
},
|
|
180
|
-
putToggleStatusUsers: (t) =>
|
|
209
|
+
putToggleStatusUsers: (t) => o.put("/active-status", t),
|
|
181
210
|
getUserOptions: (t) => {
|
|
182
211
|
const e = {};
|
|
183
|
-
return e[t] = !0,
|
|
212
|
+
return e[t] = !0, o.get("/options", { params: e });
|
|
184
213
|
},
|
|
185
|
-
deleteCancelEmailChange: (t) =>
|
|
186
|
-
postResendEmail: (t) =>
|
|
187
|
-
putChangePassword: (t, e) =>
|
|
214
|
+
deleteCancelEmailChange: (t) => o.delete("/cancel-email-change/".concat(t)),
|
|
215
|
+
postResendEmail: (t) => o.post("/resend-email", t),
|
|
216
|
+
putChangePassword: (t, e) => o.put("/change-password/".concat(t), e)
|
|
188
217
|
};
|
|
189
218
|
export {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
219
|
+
x as AuthServices,
|
|
220
|
+
k as ChangelogServices,
|
|
221
|
+
B as DivisionServices,
|
|
193
222
|
j as GlobalTagServices,
|
|
194
223
|
M as HardwareServices,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
224
|
+
q as LogServices,
|
|
225
|
+
J as OptionServices,
|
|
226
|
+
V as PositionServices,
|
|
227
|
+
F as TagEventlogServices,
|
|
228
|
+
H as TagServices,
|
|
200
229
|
z as UserServices,
|
|
201
230
|
T as getBaseURL,
|
|
202
231
|
C as getImageURL,
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
sessionExpired: boolean;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export default AuthServices;
|
package/src/types/user.type.d.ts
CHANGED
|
@@ -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 {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds body parameters by processing and parsing JSON values if valid.
|
|
3
|
+
*
|
|
4
|
+
* @param params - Optional filter parameters for asset data
|
|
5
|
+
* @returns An object containing processed parameters where JSON strings are parsed into objects
|
|
6
|
+
*/
|
|
7
|
+
export declare const buildBodyParams: (params?: Record<string, unknown>) => Record<string, unknown>;
|
package/src/utils/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { createAxiosInstance } from './createInstance.util';
|
|
|
2
2
|
export { getBaseURL } from './getBaseURL.util';
|
|
3
3
|
export { getImageURL } from './getImageURL.util';
|
|
4
4
|
export { queryParamsStringfy } from './queryParamsStringify.util';
|
|
5
|
+
export { buildBodyParams } from './buildBodyParams.util';
|