@tagsamurai/gsts-api-services 1.0.2-alpha.0 → 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 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_LOGS_NOTIFICATION_API: "https://dev-api-logs-notification.tagsamurai.com", VITE_APP_TAGSAMURAI_API: "https://dev-api.tagsamurai.com" }, O = (t = "APP_TAGSAMURAI_API") => y["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(O(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 ? $ : "{}"), _ = (I = (S = P.jwt) != null ? S : P.token) != null ? I : "";
19
- return v.headers.Authorization = "Bearer ".concat(_), v;
20
- }), d;
21
- }, D = (t, e, r) => {
22
- var l;
23
- if (!t) return;
24
- const c = O("APP_UTILITY_API"), a = t.startsWith("http") ? t : "".concat(c, "/files/").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());
28
27
  }
29
- return a;
30
- }, b = (t) => {
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;
51
+ }
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,39 +64,39 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
38
64
  [r]: t[r]
39
65
  });
40
66
  }), e;
41
- }, E = o({
67
+ }, L = o({
42
68
  prefix: "/v1/global-settings/auth"
43
- }), G = () => E.post("/logout"), x = { logout: G }, T = o({
69
+ }), U = () => L.post("/logout"), w = { logout: U }, S = o({
44
70
  prefix: "/v1/global-settings/change-log"
45
- }), C = {
46
- getChangelogs: (t) => T.get("", { params: t }),
47
- getChangelogOptions: (t) => T.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
- }), h = {
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)
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)
71
97
  }, n = o({
72
98
  prefix: "/v1/global-settings"
73
- }), j = {
99
+ }), M = {
74
100
  getHandheldReader: (t) => n.get("/reader", { params: t }),
75
101
  getHandheldReaderDetail: (t) => n.get("/reader/".concat(t)),
76
102
  getHandheldReaderOptions: (t) => n.get("/reader/options", { params: t }),
@@ -97,41 +123,41 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
97
123
  getDetailActivityLogOptions: (t) => n.get("/activity-log/options", { params: t }),
98
124
  getExistingAliasNames: () => n.get("/reader/alias-names"),
99
125
  getIotReaderPort: (t, e) => n.get("/iot-reader/".concat(t, "/ports"), { params: e })
100
- }, L = o({
126
+ }, b = o({
101
127
  env: "APP_LOGS_NOTIFICATION_API",
102
128
  prefix: "/v2"
103
- }), k = {
104
- getSessionLogList: (t) => L.get("/session-log", { params: t })
105
- }, f = o({
129
+ }), J = {
130
+ getSessionLogList: (t) => b.get("/session-log", { params: t })
131
+ }, I = o({
106
132
  prefix: "/v1/global-settings/option"
107
- }), B = {
108
- getPositions: () => f.get("/position"),
109
- getDivisions: () => f.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
- }), M = {
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
- }), H = {
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
- }), J = {
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))
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))
132
158
  }, s = o({
133
159
  prefix: "/v1/global-settings/user"
134
- }), V = {
160
+ }), z = {
135
161
  getUsers: (t) => s.get("", { params: t }),
136
162
  getUserDetail: (t) => s.get("/".concat(t)),
137
163
  getUserSystemLogs: (t, e) => s.get("/".concat(t, "/system-logs"), { params: e }),
@@ -161,18 +187,18 @@ const y = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
161
187
  putChangePassword: (t, e) => s.put("/change-password/".concat(t), e)
162
188
  };
163
189
  export {
164
- x as AuthServices,
165
- C as ChangelogServices,
166
- h as DivisionServices,
167
- N as GlobalTagServices,
168
- j as HardwareServices,
169
- k as LogServices,
170
- B as OptionServices,
171
- M as PositionServices,
172
- J as TagEventlogServices,
173
- H as TagServices,
174
- V as UserServices,
175
- O 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.0",
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>;