@tagsamurai/gsts-api-services 1.1.0-alpha.2 → 1.1.0-alpha.4

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,34 +1,34 @@
1
- import R from "axios";
2
- const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_APP_TAGSAMURAI_API: "https://dev-api.tagsamurai.local" }, T = (t = "APP_TAGSAMURAI_API") => E["VITE_" + t], i = (t = {}, e = !1) => {
1
+ import L from "axios";
2
+ const C = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_APP_TAGSAMURAI_API: "https://dev-api.tagsamurai.local" }, T = (t = "APP_TAGSAMURAI_API") => C["VITE_" + t], i = (t = {}, e = !1) => {
3
3
  const {
4
4
  env: r = "APP_TAGSAMURAI_API",
5
- prefix: o = "",
5
+ prefix: n = "",
6
6
  headers: u = {},
7
- ...d
8
- } = t, O = "".concat(T(r)).concat(o), y = R.create({
9
- ...d,
10
- baseURL: O,
7
+ ...f
8
+ } = t, w = "".concat(T(r)).concat(n), b = L.create({
9
+ ...f,
10
+ baseURL: w,
11
11
  headers: e ? u : {
12
12
  "Content-Type": "application/json",
13
13
  ...u
14
14
  }
15
15
  });
16
- return y.interceptors.request.use((A) => {
17
- var m, S, P;
18
- const $ = JSON.parse((m = localStorage.getItem("user")) != null ? m : "{}"), w = (P = (S = $.jwt) != null ? S : $.token) != null ? P : "";
19
- return A.headers.Authorization = "Bearer ".concat(w), A;
20
- }), y;
16
+ return b.interceptors.request.use((v) => {
17
+ var S, P, h;
18
+ const $ = JSON.parse((S = localStorage.getItem("user")) != null ? S : "{}"), R = (h = (P = $.jwt) != null ? P : $.token) != null ? h : "";
19
+ return v.headers.Authorization = "Bearer ".concat(R), v;
20
+ }), b;
21
21
  }, l = i({
22
- prefix: "/global-settings/v1/global-settings/auth"
23
- }), L = (t) => {
24
- var e, r, o, u;
25
- return ((e = t.response) == null ? void 0 : e.status) === 401 || ((r = t.response) == null ? void 0 : r.status) === 500 || ((u = (o = t.response) == null ? void 0 : o.data) == null ? void 0 : u.message) === "jwt malformed" ? (window.onblur = null, window.onfocus = null, window.sessionExpired = !0, window.dispatchEvent(new CustomEvent("user:expired"))) : Promise.reject(t);
22
+ prefix: "/global-settings/auth"
23
+ }), E = (t) => {
24
+ var e, r, n, u;
25
+ return ((e = t.response) == null ? void 0 : e.status) === 401 || ((r = t.response) == null ? void 0 : r.status) === 500 || ((u = (n = t.response) == null ? void 0 : n.data) == null ? void 0 : u.message) === "jwt malformed" ? (window.onblur = null, window.onfocus = null, window.sessionExpired = !0, window.dispatchEvent(new CustomEvent("user:expired"))) : Promise.reject(t);
26
26
  }, j = {
27
27
  login: (t) => {
28
28
  const e = { ...t, isMobile: !1 };
29
29
  return l.post("/login", e);
30
30
  },
31
- reLogin: (t) => (l.interceptors.response.use((e) => e, L), l.post("/login", t)),
31
+ reLogin: (t) => (l.interceptors.response.use((e) => e, E), l.post("/login", t)),
32
32
  requestOTP: (t) => {
33
33
  const e = { email: t };
34
34
  return l.post("/request-otp", e);
@@ -50,17 +50,17 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
50
50
  */
51
51
  logout: () => l.post("/logout")
52
52
  }, U = (t, e, r) => {
53
- const o = new URL(T("APP_TAGSAMURAI_API") || "").origin;
54
- let u = t.startsWith("http") ? t : "".concat(o, "/file-storage/api/file/").concat(t.replace(/^\/+/, ""));
53
+ const n = new URL(T("APP_TAGSAMURAI_API") || "").origin;
54
+ let u = t.startsWith("http") ? t : "".concat(n, "/file-storage/api/file/").concat(t.replace(/^\/+/, ""));
55
55
  if (e || r) {
56
- const d = new URLSearchParams();
57
- e && (d.set("width", e.toString()), d.set("height", (r == null ? void 0 : r.toString()) || e.toString())), u += "?".concat(d.toString());
56
+ const f = new URLSearchParams();
57
+ e && (f.set("width", e.toString()), f.set("height", (r == null ? void 0 : r.toString()) || e.toString())), u += "?".concat(f.toString());
58
58
  }
59
59
  return u;
60
60
  }, x = () => {
61
- var e, r, o;
61
+ var e, r, n;
62
62
  const t = JSON.parse((e = localStorage.getItem("user")) != null ? e : "{}");
63
- return (o = (r = t.jwt) != null ? r : t.token) != null ? o : "";
63
+ return (n = (r = t.jwt) != null ? r : t.token) != null ? n : "";
64
64
  }, D = async (t, e) => {
65
65
  const r = await fetch(t, {
66
66
  headers: {
@@ -69,22 +69,22 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
69
69
  });
70
70
  if (!r.ok)
71
71
  throw new Error("Image fetch failed: ".concat(r.status, " ").concat(r.statusText));
72
- const o = await r.arrayBuffer();
73
- return new Blob([o], {
72
+ const n = await r.arrayBuffer();
73
+ return new Blob([n], {
74
74
  type: r.headers.get("Content-Type") || "image/webp"
75
75
  });
76
- }, C = async (t) => {
76
+ }, _ = async (t) => {
77
77
  try {
78
78
  const e = x(), r = await D(t, e);
79
79
  return URL.createObjectURL(r);
80
80
  } catch (e) {
81
81
  return;
82
82
  }
83
- }, B = async (t, e, r, o) => {
83
+ }, B = async (t, e, r, n) => {
84
84
  if (!t) return;
85
85
  const u = U(t, e, r);
86
- return o ? u : C(u);
87
- }, M = (t) => {
86
+ return n ? u : _(u);
87
+ }, J = (t) => {
88
88
  if (!t || typeof t == "string")
89
89
  return;
90
90
  const e = {};
@@ -95,7 +95,7 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
95
95
  [r]: t[r]
96
96
  });
97
97
  }), e;
98
- }, _ = (t) => {
98
+ }, G = (t) => {
99
99
  if (typeof t != "string") return !1;
100
100
  const e = t.trim();
101
101
  if (!e) return !1;
@@ -104,71 +104,71 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
104
104
  } catch (r) {
105
105
  return !1;
106
106
  }
107
- }, n = (t) => {
107
+ }, o = (t) => {
108
108
  if (!t)
109
109
  return {};
110
110
  const e = {};
111
111
  return Object.keys(t).forEach((r) => {
112
- const o = t[r];
113
- e[r] = _(o) ? JSON.parse(o.trim()) : o;
112
+ const n = t[r];
113
+ e[r] = G(n) ? JSON.parse(n.trim()) : n;
114
114
  }), e;
115
115
  }, p = i({
116
- prefix: "/global-settings/v1/global-settings/change-log"
117
- }), H = {
116
+ prefix: "/global-settings/change-log"
117
+ }), M = {
118
118
  getChangelogs: (t) => {
119
- const e = n(t);
119
+ const e = o(t);
120
120
  return p.post("/change-log/list", e);
121
121
  },
122
122
  getChangelogOptions: (t) => p.post("/change-log/options", t),
123
123
  getSessionList: (t) => {
124
- const e = n(t);
124
+ const e = o(t);
125
125
  return p.post("/session-log/list", e);
126
126
  },
127
127
  getSessionOptions: (t) => p.post("/session-log/options", t),
128
128
  getHardwareChangelogs: (t) => {
129
- const e = n(t);
129
+ const e = o(t);
130
130
  return p.post("/hardware-change-log/list", e);
131
131
  },
132
132
  getHardwareOptions: (t) => p.post("/hardware-change-log/options", t),
133
133
  getTaggingList: (t) => {
134
- const e = n(t);
134
+ const e = o(t);
135
135
  return p.post("/reader-tagging-log/list", e);
136
136
  },
137
137
  getTaggingOptions: (t) => p.post("/reader-tagging-log/options", t),
138
138
  getUserTagList: (t) => {
139
- const e = n(t);
139
+ const e = o(t);
140
140
  return p.post("/reader-user-tag-log/list", e);
141
141
  },
142
142
  getUserTagOptions: (t) => p.post("/reader-user-tag-log/options", t)
143
- }, b = i({
144
- prefix: "/global-settings/v1/global-settings/division"
145
- }), J = {
146
- getDivisions: (t) => b.get("", { params: t }),
147
- getDivisionDetail: (t) => b.get("/".concat(t)),
148
- postCreateDivision: (t) => b.post("/", t),
149
- putEditDivision: (t, e) => b.put("/".concat(t), e),
143
+ }, m = i({
144
+ prefix: "/global-settings/division"
145
+ }), H = {
146
+ getDivisions: (t) => m.get("", { params: t }),
147
+ getDivisionDetail: (t) => m.get("/".concat(t)),
148
+ postCreateDivision: (t) => m.post("/", t),
149
+ putEditDivision: (t, e) => m.put("/".concat(t), e),
150
150
  deleteDivisions: (t) => {
151
151
  const e = { id: JSON.stringify(t) };
152
- return b.delete("", { params: e });
152
+ return m.delete("", { params: e });
153
153
  }
154
154
  }, a = i({
155
- prefix: "/global-settings/v1/global-settings"
156
- }), F = {
155
+ prefix: "/global-settings"
156
+ }), q = {
157
157
  getAllTAG: (t) => {
158
- const e = n(t);
158
+ const e = o(t);
159
159
  return a.post("/all-tag/list", e);
160
160
  },
161
161
  getAllTAGOptions: (t) => {
162
- const e = n(t);
162
+ const e = o(t);
163
163
  return a.post("all-tag/options", e);
164
164
  },
165
165
  getNotPairedYetCounts: () => a.get("/not-paired-yet/tag-count"),
166
166
  getNotPairedYetList: (t) => {
167
- const e = n(t);
167
+ const e = o(t);
168
168
  return a.post("/not-paired-yet/list", e);
169
169
  },
170
170
  getNotPairedYetOptions: (t) => {
171
- const e = n(t);
171
+ const e = o(t);
172
172
  return a.post("/not-paired-yet/options", e);
173
173
  },
174
174
  getAuditTAGDetail: (t) => a.post("/audit/detail", t),
@@ -176,19 +176,19 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
176
176
  submitCombineTAG: (t) => a.post("/combine-tag/combine", t),
177
177
  submitSeparateTAG: (t) => a.post("/combine-tag/separate", t),
178
178
  getPairedList: (t) => {
179
- const e = n(t);
179
+ const e = o(t);
180
180
  return a.post("/paired/list", e);
181
181
  },
182
182
  getPairedOptions: (t) => {
183
- const e = n(t);
183
+ const e = o(t);
184
184
  return a.post("/paired/options", e);
185
185
  },
186
186
  getScanTag: (t) => a.get("/scan-tag", { params: { tag: t } })
187
187
  }, s = i({
188
- prefix: "/global-settings/v1/global-settings"
189
- }), q = {
188
+ prefix: "/global-settings"
189
+ }), V = {
190
190
  getHandheldReader: (t) => {
191
- const e = n(t);
191
+ const e = o(t);
192
192
  return s.post("/handheld-reader/list", e);
193
193
  },
194
194
  getHandheldReaderDetail: (t) => s.get("/handheld-reader/".concat(t)),
@@ -206,7 +206,7 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
206
206
  }),
207
207
  putAntennaPower: (t, e) => s.put("/iot-reader/".concat(e, "/set-antenna-power"), t),
208
208
  getIotReader: (t) => {
209
- const e = n({ ...t });
209
+ const e = o({ ...t });
210
210
  return s.post("/iot-reader", e);
211
211
  },
212
212
  getIotReaderDetail: (t) => s.get("/iot-reader/".concat(t)),
@@ -224,45 +224,45 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
224
224
  getDetailActivityLog: (t) => s.get("/activity-log", { params: t }),
225
225
  getDetailActivityLogOptions: (t) => s.get("/activity-log/options", { params: t }),
226
226
  getExistingAliasNames: () => s.get("/reader/alias-names")
227
- }, G = i({
227
+ }, F = i({
228
228
  prefix: "/fam/utility/v2"
229
- }), V = {
230
- getSessionLogList: (t) => G.get("/session-log", { params: t })
231
- }, h = i({
232
- prefix: "/global-settings/v1/global-settings/option"
233
229
  }), Y = {
234
- getPositions: () => h.get("/position"),
235
- getDivisions: () => h.get("/division")
236
- }, f = i({
237
- prefix: "/global-settings/v1/global-settings/position"
230
+ getSessionLogList: (t) => F.get("/session-log", { params: t })
231
+ }, I = i({
232
+ prefix: "/global-settings/option"
238
233
  }), z = {
239
- getPositions: (t) => f.get("", { params: t }),
240
- getPositionDetail: (t) => f.get("/".concat(t)),
241
- postCreatePosition: (t) => f.post("/", t),
242
- putEditPosition: (t, e) => f.put("/".concat(t), e),
234
+ getPositions: () => I.get("/position"),
235
+ getDivisions: () => I.get("/division")
236
+ }, y = i({
237
+ prefix: "/global-settings/position"
238
+ }), W = {
239
+ getPositions: (t) => y.get("", { params: t }),
240
+ getPositionDetail: (t) => y.get("/".concat(t)),
241
+ postCreatePosition: (t) => y.post("/", t),
242
+ putEditPosition: (t, e) => y.put("/".concat(t), e),
243
243
  deletePositions: (t) => {
244
244
  const e = { id: JSON.stringify(t) };
245
- return f.delete("", { params: e });
245
+ return y.delete("", { params: e });
246
246
  }
247
247
  }, N = i({
248
248
  prefix: "/fam/tag/v2"
249
- }), W = {
250
- getTagInfo: (t) => N.get("/rfid-qr/scan", { params: t })
251
- }, v = i({
252
- prefix: "/global-settings/v1/global-settings/change-log"
253
249
  }), K = {
250
+ getTagInfo: (t) => N.get("/rfid-qr/scan", { params: t })
251
+ }, A = i({
252
+ prefix: "/global-settings/change-log"
253
+ }), Q = {
254
254
  getTAGEventlog: (t) => {
255
- const e = n(t);
256
- return v.post("/tag-event-log/list", e);
255
+ const e = o(t);
256
+ return A.post("/tag-event-log/list", e);
257
257
  },
258
258
  getTAGEventlogOptions: (t) => {
259
- const e = n(t);
260
- return v.post("/tag-event-log/options", e);
259
+ const e = o(t);
260
+ return A.post("/tag-event-log/options", e);
261
261
  },
262
- getDetailTAGEventlog: (t) => v.get("/tag-event-log/".concat(t))
262
+ getDetailTAGEventlog: (t) => A.get("/tag-event-log/".concat(t))
263
263
  }, g = i({
264
- prefix: "/global-settings/v1/global-settings/user"
265
- }), Q = {
264
+ prefix: "/global-settings/user"
265
+ }), X = {
266
266
  getUsers: (t) => g.get("", { params: t }),
267
267
  getUserDetail: (t) => g.get("/".concat(t)),
268
268
  getUserSystemLogs: (t, e) => g.get("/".concat(t, "/system-logs"), { params: e }),
@@ -290,42 +290,66 @@ const E = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1, VITE_
290
290
  deleteCancelEmailChange: (t) => g.delete("/cancel-email-change/".concat(t)),
291
291
  postResendEmail: (t) => g.post("/resend-email", t),
292
292
  putChangePassword: (t, e) => g.put("/change-password/".concat(t), e)
293
- }, I = i({
293
+ }, O = i({
294
294
  prefix: "/v2/general-settings"
295
- }), X = {
296
- get: () => I.get("/"),
297
- update: (t) => I.put("/", t)
298
- }, c = i({
299
- prefix: "/fam/utility/v2/file-manager"
300
295
  }), Z = {
301
- getStorageInformation: () => c.get("/files/storage"),
296
+ get: () => O.get("/"),
297
+ update: (t) => O.put("/", t)
298
+ }, d = i({
299
+ prefix: "/fam/utility/v2/file-manager"
300
+ }), tt = {
301
+ getStorageInformation: () => d.get("/files/storage"),
302
302
  postFileManager: (t, e) => {
303
- const r = n(e);
304
- return c.post("/".concat(t, "/list"), r);
303
+ const r = o(e);
304
+ return d.post("/".concat(t, "/list"), r);
305
305
  },
306
306
  postFileManagerOption: (t, e) => {
307
- const r = n(e);
308
- return c.post("/".concat(t, "/options"), r);
307
+ const r = o(e);
308
+ return d.post("/".concat(t, "/options"), r);
309
+ },
310
+ recoverFiles: (t, e) => d.put("/".concat(t, "/recover"), e),
311
+ deleteFiles: (t, e) => d.delete("/".concat(t), { params: e }),
312
+ deletePermanently: (t, e) => d.delete("/".concat(t, "/delete-permanent"), { params: e })
313
+ }, c = i({
314
+ prefix: "/v1/global-settings"
315
+ }), et = {
316
+ getCustomFieldList: (t) => {
317
+ const e = o(t);
318
+ return c.post("/custom-fields/list", e);
309
319
  },
310
- recoverFiles: (t, e) => c.put("/".concat(t, "/recover"), e),
311
- deleteFiles: (t, e) => c.delete("/".concat(t), { params: e }),
312
- deletePermanently: (t, e) => c.delete("/".concat(t, "/delete-permanent"), { params: e })
320
+ getCustomFieldOptions: (t) => c.post("/custom-fields/options", t),
321
+ createCustomField: (t) => c.post("/custom-fields", t),
322
+ editCustomField: (t, e) => c.patch("/custom-fields/".concat(t), e),
323
+ setActiveCustomField: (t, e) => {
324
+ const r = { ids: JSON.stringify(t) };
325
+ return c.patch("/custom-fields/set-active", e, { params: r });
326
+ },
327
+ deleteCustomField: (t) => {
328
+ const e = { ids: JSON.stringify(t) };
329
+ return c.delete("/custom-fields", { params: e });
330
+ },
331
+ getActiveCustomField: () => c.get("/custom-fields/active"),
332
+ getAvailableCustomField: (t) => {
333
+ const e = { name: t };
334
+ return c.get("/custom-fields", { params: e });
335
+ }
313
336
  };
314
337
  export {
315
338
  j as AuthServices,
316
- H as ChangelogServices,
317
- J as DivisionServices,
318
- Z as FileManagerServices,
319
- X as GeneralSettingServices,
320
- F as GlobalTagServices,
321
- q as HardwareServices,
322
- V as LogServices,
323
- Y as OptionServices,
324
- z as PositionServices,
325
- K as TagEventlogServices,
326
- W as TagServices,
327
- Q as UserServices,
339
+ M as ChangelogServices,
340
+ et as CustomFieldServices,
341
+ H as DivisionServices,
342
+ tt as FileManagerServices,
343
+ Z as GeneralSettingServices,
344
+ q as GlobalTagServices,
345
+ V as HardwareServices,
346
+ Y as LogServices,
347
+ z as OptionServices,
348
+ W as PositionServices,
349
+ Q as TagEventlogServices,
350
+ K as TagServices,
351
+ X as UserServices,
328
352
  T as getBaseURL,
329
353
  B as getImageURL,
330
- M as queryParamsStringfy
354
+ J as queryParamsStringfy
331
355
  };
package/main.d.ts CHANGED
@@ -11,4 +11,5 @@ export { default as TagEventlogServices } from './src/services/tagEventlog.servi
11
11
  export { default as UserServices } from './src/services/user.service';
12
12
  export { default as GeneralSettingServices } from './src/services/generalSetting.service';
13
13
  export { default as FileManagerServices } from './src/services/fileManager.service';
14
+ export { default as CustomFieldServices } from './src/services/customField.service';
14
15
  export { getBaseURL, getImageURL, queryParamsStringfy } from './src/utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagsamurai/gsts-api-services",
3
- "version": "1.1.0-alpha.2",
3
+ "version": "1.1.0-alpha.4",
4
4
  "author": "developer.tagsamurai",
5
5
  "description": "Global Settings Tag Samurai Services Library",
6
6
  "module": "./api-services.es.js",
@@ -0,0 +1,15 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { FetchDetailResponse, FetchListResponse } from '../types/fetchResponse.type';
3
+ import { CustomField, CustomFieldOptions, ActiveCustomField } from '../types/iam.type';
4
+ import { GetCustomFieldListParams, GetCustomFieldOptionsParams, CreateEditCustomFieldPayload, SetActiveCustomFieldPayload } from '../dto/iam.dto';
5
+ declare const CustomFieldServices: {
6
+ getCustomFieldList: (params: GetCustomFieldListParams) => Promise<AxiosResponse<FetchListResponse<CustomField>>>;
7
+ getCustomFieldOptions: (params: GetCustomFieldOptionsParams) => Promise<AxiosResponse<FetchDetailResponse<CustomFieldOptions>>>;
8
+ createCustomField: (payload: CreateEditCustomFieldPayload) => Promise<AxiosResponse>;
9
+ editCustomField: (id: string, payload: CreateEditCustomFieldPayload) => Promise<AxiosResponse>;
10
+ setActiveCustomField: (ids: string[], payload: SetActiveCustomFieldPayload) => Promise<AxiosResponse>;
11
+ deleteCustomField: (ids: string[]) => Promise<AxiosResponse>;
12
+ getActiveCustomField: () => Promise<AxiosResponse<FetchListResponse<ActiveCustomField>>>;
13
+ getAvailableCustomField: (name: string) => Promise<AxiosResponse>;
14
+ };
15
+ export default CustomFieldServices;