@tagsamurai/fats-api-services 2.0.0-alpha.5 → 2.0.0-alpha.7

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.
@@ -99,52 +99,94 @@ const getAssetsFile = async (file, type = "excel") => {
99
99
  );
100
100
  return response;
101
101
  };
102
- const API = createAxiosInstance({
102
+ const API$1 = createAxiosInstance({
103
103
  prefix: "/fam/settings-attribute/v2"
104
104
  });
105
105
  const BrandService = {
106
106
  getBrandList: (params) => {
107
- return API.get("/brands", { params });
107
+ return API$1.get("/brands", { params });
108
108
  },
109
109
  createBrand: (body) => {
110
- return API.post("/brands", body);
110
+ return API$1.post("/brands", body);
111
111
  },
112
112
  deleteBrand: (body) => {
113
- return API.delete("/brands", { data: body });
113
+ return API$1.delete("/brands", { data: body });
114
114
  },
115
115
  getBrandOptions: (params) => {
116
- return API.get("/brands/options", { params });
116
+ return API$1.get("/brands/options", { params });
117
117
  },
118
118
  getBrandDropdown: (params) => {
119
- return API.get("/brands/dropdown", { params });
119
+ return API$1.get("/brands/dropdown", { params });
120
120
  },
121
121
  getBrandDetail: (id) => {
122
- return API.get(`/brands/${id}`);
122
+ return API$1.get(`/brands/${id}`);
123
123
  },
124
124
  editBrand: (id, body) => {
125
- return API.put(`/brands/${id}`, body);
125
+ return API$1.put(`/brands/${id}`, body);
126
126
  },
127
127
  getBrandListCategory: (id, params) => {
128
- return API.get(`/brands/${id}/list-category`, { params });
128
+ return API$1.get(`/brands/${id}/list-category`, { params });
129
129
  },
130
130
  getBrandListCategoryOptions: (id, params) => {
131
- return API.get(`/brands/${id}/list-category/options`, { params });
131
+ return API$1.get(`/brands/${id}/list-category/options`, { params });
132
132
  },
133
133
  getBrandListAsset: (id, params) => {
134
- return API.get(`/brands/${id}/list-asset`, { params });
134
+ return API$1.get(`/brands/${id}/list-asset`, { params });
135
135
  },
136
136
  getBrandListAssetOptions: (id, params) => {
137
- return API.get(`/brands/${id}/list-asset/options`, { params });
137
+ return API$1.get(`/brands/${id}/list-asset/options`, { params });
138
138
  },
139
139
  assignCategory: (body) => {
140
- return API.put("/brands/assign-category", body);
140
+ return API$1.put("/brands/assign-category", body);
141
141
  },
142
142
  unassignCategory: (body) => {
143
- return API.put("/brands/unassign-category", body);
143
+ return API$1.put("/brands/unassign-category", body);
144
+ }
145
+ };
146
+ const isValidJSON = (value) => {
147
+ if (typeof value !== "string") return false;
148
+ const s = value.trim();
149
+ if (!s) return false;
150
+ try {
151
+ JSON.parse(s);
152
+ return true;
153
+ } catch {
154
+ return false;
155
+ }
156
+ };
157
+ const buildBodyParams = (params) => {
158
+ if (!params) {
159
+ return {};
160
+ }
161
+ const result = {};
162
+ Object.keys(params).forEach((key) => {
163
+ const val = params[key];
164
+ result[key] = isValidJSON(val) ? JSON.parse(val.trim()) : val;
165
+ });
166
+ return result;
167
+ };
168
+ const API = createAxiosInstance({
169
+ prefix: "/v2/analytics-reporting"
170
+ });
171
+ const ChangelogServices = {
172
+ getChangelogList: (params) => {
173
+ const body = buildBodyParams(params);
174
+ return API.post("/change-log/list", body);
175
+ },
176
+ getChangelogOptions: (body) => {
177
+ return API.post("/change-log/options", body);
178
+ },
179
+ getSessionLogList: (params) => {
180
+ const body = buildBodyParams(params);
181
+ return API.post("/session-log/list", body);
182
+ },
183
+ getSessionLogOptions: (body) => {
184
+ return API.post("/session-log/options", body);
144
185
  }
145
186
  };
146
187
  export {
147
188
  BrandService,
189
+ ChangelogServices,
148
190
  buildFileURL,
149
191
  downloadFile,
150
192
  fetchBlobFile,
package/main.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './src/utils/getImageURL.util';
2
2
  export { getAssetsFile, getBaseURL } from './src/utils';
3
3
  export { default as BrandService } from './src/services/brand.service';
4
+ export { default as ChangelogServices } from './src/services/changelog.service';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tagsamurai/fats-api-services",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.7",
4
4
  "type": "module",
5
5
  "author": "Tagsamurai",
6
6
  "description": "Fixed Asset Tagsamurai API Services",
@@ -0,0 +1,27 @@
1
+ import { AxiosResponse } from 'axios';
2
+ import { LoginCredentials, SetPasswordBody } from '../dto/globalAuth.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
+ declare global {
23
+ interface Window {
24
+ sessionExpired: boolean;
25
+ }
26
+ }
27
+ export default AuthServices;