@tagsamurai/gsts-api-services 1.0.2-alpha.1 → 1.0.2-alpha.2

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,33 +1,59 @@
1
- import m 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 = "APP_TAGSAMURAI_API") => E["VITE_" + t], o = (t = {}, e = !1) => {
1
+ import O from "axios";
2
+ const y = { 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") => y["VITE_" + t], o = (t = {}, e = !1) => {
3
3
  const {
4
4
  env: r = "APP_GLOBAL_SETTINGS_API",
5
- prefix: c = "",
6
- headers: a = {},
7
- ...l
8
- } = t, g = "".concat(_(r)).concat(c), d = m.create({
9
- ...l,
10
- baseURL: g,
11
- headers: e ? a : {
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 : {
12
12
  "Content-Type": "application/json",
13
- ...a
13
+ ...g
14
14
  }
15
15
  });
16
- return d.interceptors.request.use((v) => {
17
- var $, S, I;
18
- const P = JSON.parse(($ = localStorage.getItem("user")) != null ? $ : "{}"), O = (I = (S = P.jwt) != null ? S : P.token) != null ? I : "";
19
- return v.headers.Authorization = "Bearer ".concat(O), v;
20
- }), d;
21
- }, D = (t, e, r) => {
22
- var l;
23
- if (!t) return;
24
- const c = _("APP_IMAGE_BASE_URL"), a = t.startsWith("http") ? t : "".concat(c, "/").concat(t.replace(/^\/+/, ""));
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;
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(/^\/+/, ""));
25
24
  if (e || r) {
26
- const g = new URLSearchParams();
27
- return e && g.set("width", e.toString()), r && g.set("height", (l = r == null ? void 0 : r.toString()) != null ? l : e == null ? void 0 : e.toString()), "".concat(a, "?").concat(g.toString());
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());
27
+ }
28
+ return g;
29
+ }, E = () => {
30
+ var e, r, i;
31
+ const t = JSON.parse((e = localStorage.getItem("user")) != null ? e : "{}");
32
+ return (i = (r = t.jwt) != null ? r : t.token) != null ? i : "";
33
+ }, R = async (t, e) => {
34
+ const r = await fetch(t, {
35
+ headers: {
36
+ Authorization: "Bearer ".concat(e)
37
+ }
38
+ });
39
+ if (!r.ok)
40
+ throw new Error("Image fetch failed: ".concat(r.status, " ").concat(r.statusText));
41
+ const i = await r.arrayBuffer();
42
+ return new Blob([i], {
43
+ type: r.headers.get("Content-Type") || "image/webp"
44
+ });
45
+ }, G = async (t) => {
46
+ try {
47
+ const e = E(), r = await R(t, e);
48
+ return URL.createObjectURL(r);
49
+ } catch (e) {
50
+ return;
28
51
  }
29
- return a;
30
- }, b = (t) => {
52
+ }, C = async (t, e, r, i) => {
53
+ if (!t) return;
54
+ const g = h(t, e, r);
55
+ return i ? g : G(g);
56
+ }, N = (t) => {
31
57
  if (!t || typeof t == "string")
32
58
  return;
33
59
  const e = {};
@@ -38,141 +64,141 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
38
64
  [r]: t[r]
39
65
  });
40
66
  }), e;
41
- }, G = o({
67
+ }, L = o({
42
68
  prefix: "/v1/global-settings/auth"
43
- }), y = () => G.post("/logout"), h = { logout: y }, f = o({
69
+ }), U = () => L.post("/logout"), w = { logout: U }, S = o({
44
70
  prefix: "/v1/global-settings/change-log"
45
- }), x = {
46
- getChangelogs: (t) => f.get("", { params: t }),
47
- getChangelogOptions: (t) => f.get("/options", { params: t })
48
- }, u = o({
71
+ }), B = {
72
+ getChangelogs: (t) => S.get("", { params: t }),
73
+ getChangelogOptions: (t) => S.get("/options", { params: t })
74
+ }, p = o({
49
75
  prefix: "/v1/global-settings/division"
50
- }), C = {
51
- getDivisions: (t) => u.get("", { params: t }),
52
- getDivisionDetail: (t) => u.get("/".concat(t)),
53
- postCreateDivision: (t) => u.post("/", t),
54
- putEditDivision: (t, e) => u.put("/".concat(t), e),
76
+ }), k = {
77
+ getDivisions: (t) => p.get("", { params: t }),
78
+ getDivisionDetail: (t) => p.get("/".concat(t)),
79
+ postCreateDivision: (t) => p.post("/", t),
80
+ putEditDivision: (t, e) => p.put("/".concat(t), e),
55
81
  deleteDivisions: (t) => {
56
82
  const e = { id: JSON.stringify(t) };
57
- return u.delete("", { params: e });
83
+ return p.delete("", { params: e });
58
84
  }
59
- }, i = o({
85
+ }, a = o({
60
86
  prefix: "/v1/global-settings"
61
- }), N = {
62
- getTAGAllPaired: (t, e) => i.get("/".concat(t), { params: e }),
63
- getTAGAllPairedOptions: (t, e) => i.get("/".concat(t, "/options"), { params: e }),
64
- getTAGNotPaired: (t, e) => i.get("/".concat(t, "/not-paired"), { params: e }),
65
- getTAGNotPairedOptions: (t, e) => i.get("/".concat(t, "/not-paired/options"), { params: e }),
66
- getScanTAG: (t, e) => i.get("/".concat(t, "/scan"), { params: e }),
67
- putDetailAuditTAG: (t, e) => i.put("/".concat(t, "/audit-detail"), e),
68
- putAuditTAG: (t, e) => i.put("/".concat(t, "/audit"), e),
69
- putAllocateTAG: (t, e) => i.put("/".concat(t, "/allocate"), e),
70
- putCombineTAG: (t) => i.put("/combine", t)
71
- }, s = o({
87
+ }), 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({
72
98
  prefix: "/v1/global-settings"
73
- }), B = {
74
- getHandheldReader: (t) => s.get("/reader", { params: t }),
75
- getHandheldReaderDetail: (t) => s.get("/reader/".concat(t)),
76
- getHandheldReaderOptions: (t) => s.get("/reader/options", { params: t }),
77
- putMarkHandheldStatus: (t) => s.put("/reader/mark-status", t),
78
- putPingReaders: (t) => s.put("/iot-reader/ping", t),
79
- putMarkIOTStatus: (t, e) => s.put("/".concat(e, "/mark-status"), t),
80
- putEditReaderGroup: (t, e, r) => s.put(
99
+ }), M = {
100
+ getHandheldReader: (t) => n.get("/reader", { params: t }),
101
+ getHandheldReaderDetail: (t) => n.get("/reader/".concat(t)),
102
+ getHandheldReaderOptions: (t) => n.get("/reader/options", { params: t }),
103
+ putMarkHandheldStatus: (t) => n.put("/reader/mark-status", t),
104
+ putPingReaders: (t) => n.put("/iot-reader/ping", t),
105
+ putMarkIOTStatus: (t, e) => n.put("/".concat(e, "/mark-status"), t),
106
+ putEditReaderGroup: (t, e, r) => n.put(
81
107
  "/".concat(t === "iot" ? "iot-" : "", "reader/").concat(r, "/set-group"),
82
108
  e
83
109
  ),
84
- putEditAntennaGroup: (t, e) => s.put("/iot-reader/".concat(e, "/set-port-group"), t),
85
- putEditPortStatus: (t, e) => s.put("/iot-reader/".concat(e, "/set-port-status"), t),
86
- putEditAliasName: (t, e, r) => s.put(
110
+ putEditAntennaGroup: (t, e) => n.put("/iot-reader/".concat(e, "/set-port-group"), t),
111
+ putEditPortStatus: (t, e) => n.put("/iot-reader/".concat(e, "/set-port-status"), t),
112
+ putEditAliasName: (t, e, r) => n.put(
87
113
  "/".concat(t === "iot" ? "iot-" : "", "reader/").concat(r, "/set-alias-name"),
88
114
  e
89
115
  ),
90
- putAntennaPower: (t, e) => s.put("/iot-reader/".concat(e, "/set-antenna-power"), t),
91
- getIOTReaderOrAntenna: (t, e) => s.get("/".concat(t), { params: e }),
92
- getIOTReaderDetail: (t) => s.get("/iot-reader/".concat(t)),
93
- getIOTReaderOrAntennaOptions: (t, e) => s.get("/".concat(t, "/options"), { params: e }),
94
- getActivityLog: (t) => s.get("/activity-log", { params: t }),
95
- getActivityLogOptions: (t) => s.get("/activity-log/options", { params: t }),
96
- getDetailActivityLog: (t) => s.get("/activity-log", { params: t }),
97
- getDetailActivityLogOptions: (t) => s.get("/activity-log/options", { params: t }),
98
- getExistingAliasNames: () => s.get("/reader/alias-names"),
99
- getIotReaderPort: (t, e) => s.get("/iot-reader/".concat(t, "/ports"), { params: e })
100
- }, L = o({
116
+ putAntennaPower: (t, e) => n.put("/iot-reader/".concat(e, "/set-antenna-power"), t),
117
+ getIOTReaderOrAntenna: (t, e) => n.get("/".concat(t), { params: e }),
118
+ getIOTReaderDetail: (t) => n.get("/iot-reader/".concat(t)),
119
+ getIOTReaderOrAntennaOptions: (t, e) => n.get("/".concat(t, "/options"), { params: e }),
120
+ getActivityLog: (t) => n.get("/activity-log", { params: t }),
121
+ getActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
122
+ getDetailActivityLog: (t) => n.get("/activity-log", { params: t }),
123
+ getDetailActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
124
+ getExistingAliasNames: () => n.get("/reader/alias-names"),
125
+ getIotReaderPort: (t, e) => n.get("/iot-reader/".concat(t, "/ports"), { params: e })
126
+ }, b = o({
101
127
  env: "APP_LOGS_NOTIFICATION_API",
102
128
  prefix: "/v2"
103
- }), M = {
104
- getSessionLogList: (t) => L.get("/session-log", { params: t })
105
- }, T = o({
129
+ }), J = {
130
+ getSessionLogList: (t) => b.get("/session-log", { params: t })
131
+ }, I = o({
106
132
  prefix: "/v1/global-settings/option"
107
- }), j = {
108
- getPositions: () => T.get("/position"),
109
- getDivisions: () => T.get("/division")
110
- }, p = o({
133
+ }), V = {
134
+ getPositions: () => I.get("/position"),
135
+ getDivisions: () => I.get("/division")
136
+ }, c = o({
111
137
  prefix: "/v1/global-settings/position"
112
- }), k = {
113
- getPositions: (t) => p.get("", { params: t }),
114
- getPositionDetail: (t) => p.get("/".concat(t)),
115
- postCreatePosition: (t) => p.post("/", t),
116
- putEditPosition: (t, e) => p.put("/".concat(t), e),
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),
117
143
  deletePositions: (t) => {
118
144
  const e = { id: JSON.stringify(t) };
119
- return p.delete("", { params: e });
145
+ return c.delete("", { params: e });
120
146
  }
121
- }, R = o({
147
+ }, D = o({
122
148
  env: "APP_TAGSAMURAI_API",
123
149
  prefix: "/tag/v2"
124
- }), V = {
125
- getTagInfo: (t) => R.get("/rfid-qr/scan", { params: t })
126
- }, A = o({
150
+ }), F = {
151
+ getTagInfo: (t) => D.get("/rfid-qr/scan", { params: t })
152
+ }, l = o({
127
153
  prefix: "/v1/global-settings/change-log"
128
- }), H = {
129
- getTAGEventlog: (t) => A.get("/tag-event-log", { params: t }),
130
- getTAGEventlogOptions: (t) => A.get("/tag-event-log/options", { params: t }),
131
- getDetailTAGEventlog: (t) => A.get("/tag-event-log/".concat(t))
132
- }, n = o({
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({
133
159
  prefix: "/v1/global-settings/user"
134
- }), J = {
135
- getUsers: (t) => n.get("", { params: t }),
136
- getUserDetail: (t) => n.get("/".concat(t)),
137
- getUserSystemLogs: (t, e) => n.get("/".concat(t, "/system-logs"), { params: e }),
160
+ }), 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 }),
138
164
  getUserSystemLogOptions: (t, e) => {
139
165
  const r = {};
140
- return r[e] = !0, n.get("/".concat(t, "/system-logs/options"), { params: r });
166
+ return r[e] = !0, s.get("/".concat(t, "/system-logs/options"), { params: r });
141
167
  },
142
168
  postCreateUser: (t) => {
143
169
  const e = { "Content-Type": "multipart/form-data" };
144
- return n.post("", t, { headers: e });
170
+ return s.post("", t, { headers: e });
145
171
  },
146
172
  putEditUser: (t, e) => {
147
173
  const r = { "Content-Type": "multipart/form-data" };
148
- return n.put("/".concat(t), e, { headers: r });
174
+ return s.put("/".concat(t), e, { headers: r });
149
175
  },
150
176
  deleteUsers: (t) => {
151
177
  const e = { id: JSON.stringify(t) };
152
- return n.delete("", { params: e });
178
+ return s.delete("", { params: e });
153
179
  },
154
- putToggleStatusUsers: (t) => n.put("/active-status", t),
180
+ putToggleStatusUsers: (t) => s.put("/active-status", t),
155
181
  getUserOptions: (t) => {
156
182
  const e = {};
157
- return e[t] = !0, n.get("/options", { params: e });
183
+ return e[t] = !0, s.get("/options", { params: e });
158
184
  },
159
- deleteCancelEmailChange: (t) => n.delete("/cancel-email-change/".concat(t)),
160
- postResendEmail: (t) => n.post("/resend-email", t),
161
- putChangePassword: (t, e) => n.put("/change-password/".concat(t), e)
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)
162
188
  };
163
189
  export {
164
- h as AuthServices,
165
- x as ChangelogServices,
166
- C as DivisionServices,
167
- N as GlobalTagServices,
168
- B as HardwareServices,
169
- M as LogServices,
170
- j as OptionServices,
171
- k as PositionServices,
172
- H as TagEventlogServices,
173
- V as TagServices,
174
- J as UserServices,
175
- _ as getBaseURL,
176
- D as getImageURL,
177
- b as queryParamsStringfy
190
+ w as AuthServices,
191
+ B as ChangelogServices,
192
+ k as DivisionServices,
193
+ j as GlobalTagServices,
194
+ M as HardwareServices,
195
+ J as LogServices,
196
+ V as OptionServices,
197
+ H as PositionServices,
198
+ q as TagEventlogServices,
199
+ F as TagServices,
200
+ z as UserServices,
201
+ T as getBaseURL,
202
+ C as getImageURL,
203
+ N as queryParamsStringfy
178
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagsamurai/gsts-api-services",
3
- "version": "1.0.2-alpha.1",
3
+ "version": "1.0.2-alpha.2",
4
4
  "author": "developer.tagsamurai",
5
5
  "description": "Global Settings Tag Samurai Services Library",
6
6
  "module": "./api-services.es.js",
@@ -1 +1,11 @@
1
- export declare const getImageURL: (name?: string | null, width?: number, height?: number) => string | undefined;
1
+ export declare const buildFileURL: (name: string, width?: number, height?: number) => string;
2
+ export declare const fetchBlobFile: (url: string, token: string) => Promise<Blob>;
3
+ /**
4
+ *
5
+ * @param fileUrl The full URL
6
+ * @param fileName Custom File name
7
+ * @param immediateRevoke Immediately revoke the object URL after download - default to true
8
+ * @returns
9
+ */
10
+ export declare const downloadFile: (fileUrl: string, fileName: string, immediateRevoke?: boolean) => Promise<string>;
11
+ export declare const getImageURL: (name?: string | null, width?: number, height?: number, returnURLOnly?: boolean) => Promise<string | undefined>;