septor-store 1.2.0 → 1.2.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/dist/index.cjs +60 -34
- package/dist/index.d.cts +111 -62
- package/dist/index.d.ts +111 -62
- package/dist/index.js +59 -34
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
getBearerToken: () => getBearerToken,
|
|
34
34
|
pomPinia: () => createPomStore,
|
|
35
35
|
setBearerToken: () => setBearerToken,
|
|
36
|
+
setUpAxiosToUse: () => setUpAxiosToUse,
|
|
36
37
|
useFetch: () => useFetch
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -104,23 +105,30 @@ customAxios.interceptors.request.use(
|
|
|
104
105
|
var custom_axios_default = customAxios;
|
|
105
106
|
|
|
106
107
|
// src/utils/useFetch.js
|
|
107
|
-
var
|
|
108
|
-
|
|
108
|
+
var axiosSetUps = custom_axios_default;
|
|
109
|
+
function setUpAxiosToUse(setUp) {
|
|
110
|
+
axiosSetUps = setUp ?? custom_axios_default;
|
|
111
|
+
}
|
|
112
|
+
var useFetch = async ({ url, method, data = {}, config }) => {
|
|
113
|
+
const uniformMethod = method.toLowerCase();
|
|
114
|
+
const headerC = {
|
|
115
|
+
...config,
|
|
116
|
+
headers: {
|
|
117
|
+
...(config == null ? void 0 : config.headers) || {}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
109
120
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
else if (uniformMethod === "put")
|
|
118
|
-
response = await custom_axios_default.put(url, _data, config ?? {});
|
|
119
|
-
else if (uniformMethod === "delete")
|
|
120
|
-
response = await custom_axios_default.delete(url, { data: _data, ...config ?? {} });
|
|
121
|
-
else
|
|
121
|
+
const axiosMethods = {
|
|
122
|
+
get: () => axiosSetUps.get(`${url}${generateParams(data)}`, headerC),
|
|
123
|
+
post: () => axiosSetUps.post(url, data, headerC),
|
|
124
|
+
put: () => axiosSetUps.put(url, data, headerC),
|
|
125
|
+
delete: () => axiosSetUps.delete(url, { data, ...headerC })
|
|
126
|
+
};
|
|
127
|
+
if (!axiosMethods[uniformMethod]) {
|
|
122
128
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
123
|
-
|
|
129
|
+
}
|
|
130
|
+
const response = await axiosMethods[uniformMethod]();
|
|
131
|
+
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
124
132
|
} catch (err2) {
|
|
125
133
|
console.error(err2);
|
|
126
134
|
return { success: false, error: err2 };
|
|
@@ -150,7 +158,9 @@ var generateParams = (params = {}) => {
|
|
|
150
158
|
};
|
|
151
159
|
function setBearerToken(name = { token: null }) {
|
|
152
160
|
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
153
|
-
throw new TypeError(
|
|
161
|
+
throw new TypeError(
|
|
162
|
+
"setBearerToken expects an object {token} with a 'token' property."
|
|
163
|
+
);
|
|
154
164
|
const tokenObj = { token: null, ...name, timestamp: Date.now() };
|
|
155
165
|
localStorage.setItem("logginToken", JSON.stringify(tokenObj));
|
|
156
166
|
}
|
|
@@ -165,10 +175,10 @@ function getBearerToken() {
|
|
|
165
175
|
}
|
|
166
176
|
|
|
167
177
|
// src/StoreManager/pomStateManagement.js
|
|
168
|
-
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0 }) {
|
|
178
|
+
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
179
|
+
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
169
180
|
const storeId = "POM" + piniaStore;
|
|
170
181
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
171
|
-
;
|
|
172
182
|
const piniaData = (0, import_pinia.defineStore)(storeId, {
|
|
173
183
|
state: () => {
|
|
174
184
|
const StateObjectsContainer = {
|
|
@@ -207,12 +217,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
207
217
|
sleep(timer) {
|
|
208
218
|
return new Promise((r) => setTimeout(r, timer));
|
|
209
219
|
},
|
|
210
|
-
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}) {
|
|
220
|
+
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config) {
|
|
211
221
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
212
222
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
213
|
-
let [res] = await Promise.all([
|
|
214
|
-
useFetch(dataParams)
|
|
215
|
-
]);
|
|
223
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
216
224
|
if (res) {
|
|
217
225
|
this[StateStore] = res;
|
|
218
226
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -236,7 +244,9 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
236
244
|
sessionStorage.removeItem(dataResponseName);
|
|
237
245
|
}
|
|
238
246
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
239
|
-
const thisData = JSON.parse(
|
|
247
|
+
const thisData = JSON.parse(
|
|
248
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
249
|
+
);
|
|
240
250
|
return thisData;
|
|
241
251
|
}
|
|
242
252
|
} catch (error) {
|
|
@@ -246,16 +256,22 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
246
256
|
WipeStates(storeKeyToRemove = null) {
|
|
247
257
|
const sptStateData = localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
248
258
|
let previousState = JSON.parse(sptStateData);
|
|
249
|
-
if (storeKeyToRemove)
|
|
250
|
-
|
|
251
|
-
else
|
|
252
|
-
previousState = {};
|
|
259
|
+
if (storeKeyToRemove) delete previousState[storeKeyToRemove];
|
|
260
|
+
else previousState = {};
|
|
253
261
|
const regroup = JSON.stringify(previousState);
|
|
254
262
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
255
263
|
},
|
|
256
|
-
async stateGenaratorApi(dd = {
|
|
264
|
+
async stateGenaratorApi(dd = {
|
|
265
|
+
reload: true,
|
|
266
|
+
StateStore: "",
|
|
267
|
+
reqs: {},
|
|
268
|
+
config: {},
|
|
269
|
+
time: 0,
|
|
270
|
+
pagnated: false,
|
|
271
|
+
mStore: { mUse: 0, reset: 0 }
|
|
272
|
+
}, fasterDataCollection = null) {
|
|
257
273
|
this.Loading = true;
|
|
258
|
-
const { reload, StateStore, reqs, time, pagnated, mStore } = dd;
|
|
274
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
259
275
|
const callApi = JSON.stringify(reqs);
|
|
260
276
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
261
277
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -263,7 +279,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
263
279
|
const sptStateData = localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
264
280
|
const previousState = JSON.parse(sptStateData);
|
|
265
281
|
const stateKey = typeof StateStore === "string" ? StateStore : "septore-store-";
|
|
266
|
-
const regroup = JSON.stringify({
|
|
282
|
+
const regroup = JSON.stringify({
|
|
283
|
+
...previousState,
|
|
284
|
+
[storeId + "(-_+_-)" + stateKey]: StateStore
|
|
285
|
+
});
|
|
267
286
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
268
287
|
}
|
|
269
288
|
if (this.StateValue[StateStore]) {
|
|
@@ -271,7 +290,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
271
290
|
this[StateStore] = false;
|
|
272
291
|
}
|
|
273
292
|
if (this.CheckQueriesInQue[callApi]) {
|
|
274
|
-
console.warn(
|
|
293
|
+
console.warn(
|
|
294
|
+
`************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
|
|
295
|
+
reqs
|
|
296
|
+
);
|
|
275
297
|
return;
|
|
276
298
|
}
|
|
277
299
|
try {
|
|
@@ -280,13 +302,14 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
280
302
|
fasterDataCollection(StateVariable);
|
|
281
303
|
if (counters > 0) {
|
|
282
304
|
if (reload) {
|
|
283
|
-
|
|
305
|
+
await this.sleep(1e3 * time);
|
|
284
306
|
return await this.CallApiData(
|
|
285
307
|
StateStore,
|
|
286
308
|
callApi,
|
|
287
309
|
reqs,
|
|
288
310
|
pagnated,
|
|
289
|
-
mStore
|
|
311
|
+
mStore,
|
|
312
|
+
config
|
|
290
313
|
);
|
|
291
314
|
}
|
|
292
315
|
this.Loading = false;
|
|
@@ -299,9 +322,11 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
299
322
|
callApi,
|
|
300
323
|
reqs,
|
|
301
324
|
pagnated,
|
|
302
|
-
mStore
|
|
325
|
+
mStore,
|
|
326
|
+
config
|
|
303
327
|
);
|
|
304
328
|
} catch (error) {
|
|
329
|
+
console.error(error);
|
|
305
330
|
if (this.CheckQueriesInQue[callApi])
|
|
306
331
|
delete this.CheckQueriesInQue[callApi];
|
|
307
332
|
}
|
|
@@ -328,5 +353,6 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
328
353
|
getBearerToken,
|
|
329
354
|
pomPinia,
|
|
330
355
|
setBearerToken,
|
|
356
|
+
setUpAxiosToUse,
|
|
331
357
|
useFetch
|
|
332
358
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -26,7 +26,9 @@ const requestHandler = (request) => {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
|
|
29
30
|
request.headers = {...(request?.headers??{}),} || {};
|
|
31
|
+
|
|
30
32
|
if (token)
|
|
31
33
|
request.headers.Authorization = `Bearer ${token}`;
|
|
32
34
|
// Handle FormData explicitly if needed
|
|
@@ -55,39 +57,47 @@ customAxios.interceptors.request.use(requestHandler, (error) =>
|
|
|
55
57
|
Promise.reject(error)
|
|
56
58
|
);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
let axiosSetUps = customAxios;
|
|
61
|
+
|
|
62
|
+
function setUpAxiosToUse(setUp) {
|
|
63
|
+
axiosSetUps = setUp??customAxios;
|
|
64
|
+
}
|
|
65
|
+
const useFetch = async ({ url, method, data = {}, config }) => {
|
|
66
|
+
const uniformMethod = method.toLowerCase();
|
|
67
|
+
const headerC = {
|
|
68
|
+
...config,
|
|
69
|
+
headers: {
|
|
70
|
+
...(config?.headers || {}),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
60
74
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
74
|
-
|
|
75
|
-
return response?.data ?? { Empty: 'Empty' };
|
|
75
|
+
const axiosMethods = {
|
|
76
|
+
get: () => axiosSetUps.get(`${url}${generateParams(data)}`, headerC),
|
|
77
|
+
post: () => axiosSetUps.post(url, data, headerC),
|
|
78
|
+
put: () => axiosSetUps.put(url, data, headerC),
|
|
79
|
+
delete: () => axiosSetUps.delete(url, { data, ...headerC }),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (!axiosMethods[uniformMethod]) {
|
|
83
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
84
|
+
}
|
|
85
|
+
const response = await axiosMethods[uniformMethod]();
|
|
86
|
+
return response?.data ?? response ??{ Empty: "Empty" };
|
|
76
87
|
} catch (err) {
|
|
77
88
|
console.error(err);
|
|
78
89
|
return { success: false, error: err };
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
|
|
82
|
-
const generateParams = (params={}) => {
|
|
93
|
+
const generateParams = (params = {}) => {
|
|
83
94
|
try {
|
|
84
|
-
|
|
85
95
|
let data = "?";
|
|
86
96
|
for (let key in params) {
|
|
87
97
|
if (Object.hasOwnProperty.call(params, key)) {
|
|
88
98
|
if (params[key]) {
|
|
89
99
|
if (Array.isArray(params[key])) {
|
|
90
|
-
const elements = params[key]
|
|
100
|
+
const elements = params[key];
|
|
91
101
|
for (const ele of elements) {
|
|
92
102
|
data += `${key}[]=${ele}&`;
|
|
93
103
|
}
|
|
@@ -100,31 +110,37 @@ const generateParams = (params={}) => {
|
|
|
100
110
|
return data.slice(0, -1);
|
|
101
111
|
} catch (error) {
|
|
102
112
|
console.error(err);
|
|
103
|
-
|
|
104
113
|
}
|
|
105
114
|
};
|
|
106
115
|
|
|
107
|
-
function setBearerToken(name = { token: null }) {
|
|
108
|
-
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
function setBearerToken(name = { token: null }) {
|
|
117
|
+
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
118
|
+
throw new TypeError(
|
|
119
|
+
"setBearerToken expects an object {token} with a 'token' property.",
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const tokenObj = { token: null, ...name, timestamp: Date.now() };
|
|
123
|
+
localStorage.setItem("logginToken", JSON.stringify(tokenObj));
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
function getBearerToken() {
|
|
116
|
-
const token = localStorage.getItem(
|
|
127
|
+
const token = localStorage.getItem("logginToken");
|
|
117
128
|
try {
|
|
118
129
|
return token ? JSON.parse(token) : null;
|
|
119
130
|
} catch (e) {
|
|
120
|
-
console.error(
|
|
131
|
+
console.error("Invalid token format in localStorage:", e);
|
|
121
132
|
return null;
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
135
|
|
|
125
|
-
function createPomStore(
|
|
136
|
+
function createPomStore(
|
|
137
|
+
piniaStore = "7286204094",
|
|
138
|
+
callBack = null,
|
|
139
|
+
ds = { StateClean: 0,extenalSetup:null }) {
|
|
140
|
+
setUpAxiosToUse(ds?.extenalSetup);
|
|
126
141
|
const storeId = "POM" + piniaStore;
|
|
127
|
-
const StateNameUsedSoferList = "septor-store-collection";
|
|
142
|
+
const StateNameUsedSoferList = "septor-store-collection";
|
|
143
|
+
const piniaData = defineStore(storeId, {
|
|
128
144
|
state: () => {
|
|
129
145
|
const StateObjectsContainer = {
|
|
130
146
|
CheckQueriesInQue: {},
|
|
@@ -133,7 +149,7 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
133
149
|
isThereAnyDataChangeInAform: false,
|
|
134
150
|
};
|
|
135
151
|
|
|
136
|
-
return StateObjectsContainer;
|
|
152
|
+
return StateObjectsContainer;
|
|
137
153
|
},
|
|
138
154
|
|
|
139
155
|
getters: {
|
|
@@ -144,7 +160,6 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
144
160
|
**/
|
|
145
161
|
return (state[TagetState] = state[TagetState]);
|
|
146
162
|
},
|
|
147
|
-
|
|
148
163
|
},
|
|
149
164
|
actions: {
|
|
150
165
|
validateObjectLength(object) {
|
|
@@ -176,17 +191,27 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
176
191
|
return new Promise((r) => setTimeout(r, timer));
|
|
177
192
|
},
|
|
178
193
|
|
|
179
|
-
async CallApiData(
|
|
194
|
+
async CallApiData(
|
|
195
|
+
StateStore,
|
|
196
|
+
callApi,
|
|
197
|
+
dataParams,
|
|
198
|
+
pagnated,
|
|
199
|
+
mStore = {},
|
|
200
|
+
config
|
|
201
|
+
) {
|
|
180
202
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
181
203
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
204
|
+
// console.log({...dataParams,config});
|
|
205
|
+
// alert()
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
let [res] = await Promise.all([useFetch({...dataParams,config})]);
|
|
185
209
|
|
|
186
|
-
if (res) {
|
|
210
|
+
if (res) {
|
|
187
211
|
this[StateStore] = res;
|
|
188
|
-
if (mStore?.mUse) {
|
|
189
|
-
const checkType =
|
|
212
|
+
if (mStore?.mUse) {
|
|
213
|
+
const checkType =
|
|
214
|
+
typeof res === "object" ? JSON.stringify(res) : res;
|
|
190
215
|
sessionStorage.setItem(StateStore, JSON.stringify(checkType));
|
|
191
216
|
}
|
|
192
217
|
|
|
@@ -211,35 +236,53 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
211
236
|
}
|
|
212
237
|
|
|
213
238
|
if (mStore?.mUse) {
|
|
214
|
-
const thisData = JSON.parse(
|
|
239
|
+
const thisData = JSON.parse(
|
|
240
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
241
|
+
);
|
|
215
242
|
return thisData;
|
|
216
243
|
}
|
|
217
244
|
} catch (error) {}
|
|
218
245
|
|
|
219
246
|
return this[dataResponseName];
|
|
220
247
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
248
|
+
WipeStates(storeKeyToRemove = null) {
|
|
249
|
+
const sptStateData =
|
|
250
|
+
localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
251
|
+
let previousState = JSON.parse(sptStateData);
|
|
252
|
+
if (storeKeyToRemove) delete previousState[storeKeyToRemove];
|
|
253
|
+
else previousState = {};
|
|
254
|
+
|
|
255
|
+
const regroup = JSON.stringify(previousState);
|
|
256
|
+
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
231
257
|
},
|
|
232
|
-
async stateGenaratorApi(
|
|
258
|
+
async stateGenaratorApi(
|
|
259
|
+
dd = {
|
|
260
|
+
reload: true,
|
|
261
|
+
StateStore: "",
|
|
262
|
+
reqs: {},
|
|
263
|
+
config: {},
|
|
264
|
+
time: 0,
|
|
265
|
+
pagnated: false,
|
|
266
|
+
mStore: { mUse: 0, reset: 0 },
|
|
267
|
+
},
|
|
268
|
+
fasterDataCollection = null
|
|
269
|
+
) {
|
|
270
|
+
|
|
233
271
|
this.Loading = true;
|
|
234
|
-
const { reload, StateStore, reqs, time, pagnated, mStore } = dd;
|
|
272
|
+
const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
|
|
235
273
|
const callApi = JSON.stringify(reqs);
|
|
236
274
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
237
275
|
this[StateStore] = StateVariable ?? [];
|
|
238
276
|
if (ds?.StateClean) {
|
|
239
|
-
const sptStateData =
|
|
277
|
+
const sptStateData =
|
|
278
|
+
localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
240
279
|
const previousState = JSON.parse(sptStateData);
|
|
241
|
-
const stateKey =
|
|
242
|
-
|
|
280
|
+
const stateKey =
|
|
281
|
+
typeof StateStore === "string" ? StateStore : "septore-store-";
|
|
282
|
+
const regroup = JSON.stringify({
|
|
283
|
+
...previousState,
|
|
284
|
+
[storeId + "(-_+_-)" + stateKey]: StateStore,
|
|
285
|
+
});
|
|
243
286
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
244
287
|
}
|
|
245
288
|
if (this.StateValue[StateStore]) {
|
|
@@ -252,7 +295,10 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
252
295
|
}
|
|
253
296
|
|
|
254
297
|
if (this.CheckQueriesInQue[callApi]) {
|
|
255
|
-
console.warn(
|
|
298
|
+
console.warn(
|
|
299
|
+
`************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
|
|
300
|
+
reqs
|
|
301
|
+
);
|
|
256
302
|
return;
|
|
257
303
|
}
|
|
258
304
|
try {
|
|
@@ -262,13 +308,15 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
262
308
|
|
|
263
309
|
if (counters > 0) {
|
|
264
310
|
if (reload) {
|
|
265
|
-
|
|
311
|
+
|
|
312
|
+
await this.sleep(1000 * time);
|
|
266
313
|
return await this.CallApiData(
|
|
267
314
|
StateStore,
|
|
268
315
|
callApi,
|
|
269
316
|
reqs,
|
|
270
317
|
pagnated,
|
|
271
|
-
mStore
|
|
318
|
+
mStore,
|
|
319
|
+
config
|
|
272
320
|
);
|
|
273
321
|
}
|
|
274
322
|
|
|
@@ -283,10 +331,11 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
283
331
|
callApi,
|
|
284
332
|
reqs,
|
|
285
333
|
pagnated,
|
|
286
|
-
mStore
|
|
334
|
+
mStore,
|
|
335
|
+
config
|
|
287
336
|
);
|
|
288
337
|
} catch (error) {
|
|
289
|
-
|
|
338
|
+
console.error(error);
|
|
290
339
|
if (this.CheckQueriesInQue[callApi])
|
|
291
340
|
delete this.CheckQueriesInQue[callApi];
|
|
292
341
|
}
|
|
@@ -314,4 +363,4 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
314
363
|
|
|
315
364
|
// module.e = createPomStore
|
|
316
365
|
|
|
317
|
-
export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, useFetch };
|
|
366
|
+
export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, setUpAxiosToUse, useFetch };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,9 @@ const requestHandler = (request) => {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
|
|
29
30
|
request.headers = {...(request?.headers??{}),} || {};
|
|
31
|
+
|
|
30
32
|
if (token)
|
|
31
33
|
request.headers.Authorization = `Bearer ${token}`;
|
|
32
34
|
// Handle FormData explicitly if needed
|
|
@@ -55,39 +57,47 @@ customAxios.interceptors.request.use(requestHandler, (error) =>
|
|
|
55
57
|
Promise.reject(error)
|
|
56
58
|
);
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
let axiosSetUps = customAxios;
|
|
61
|
+
|
|
62
|
+
function setUpAxiosToUse(setUp) {
|
|
63
|
+
axiosSetUps = setUp??customAxios;
|
|
64
|
+
}
|
|
65
|
+
const useFetch = async ({ url, method, data = {}, config }) => {
|
|
66
|
+
const uniformMethod = method.toLowerCase();
|
|
67
|
+
const headerC = {
|
|
68
|
+
...config,
|
|
69
|
+
headers: {
|
|
70
|
+
...(config?.headers || {}),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
60
74
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
74
|
-
|
|
75
|
-
return response?.data ?? { Empty: 'Empty' };
|
|
75
|
+
const axiosMethods = {
|
|
76
|
+
get: () => axiosSetUps.get(`${url}${generateParams(data)}`, headerC),
|
|
77
|
+
post: () => axiosSetUps.post(url, data, headerC),
|
|
78
|
+
put: () => axiosSetUps.put(url, data, headerC),
|
|
79
|
+
delete: () => axiosSetUps.delete(url, { data, ...headerC }),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (!axiosMethods[uniformMethod]) {
|
|
83
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
84
|
+
}
|
|
85
|
+
const response = await axiosMethods[uniformMethod]();
|
|
86
|
+
return response?.data ?? response ??{ Empty: "Empty" };
|
|
76
87
|
} catch (err) {
|
|
77
88
|
console.error(err);
|
|
78
89
|
return { success: false, error: err };
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
|
|
82
|
-
const generateParams = (params={}) => {
|
|
93
|
+
const generateParams = (params = {}) => {
|
|
83
94
|
try {
|
|
84
|
-
|
|
85
95
|
let data = "?";
|
|
86
96
|
for (let key in params) {
|
|
87
97
|
if (Object.hasOwnProperty.call(params, key)) {
|
|
88
98
|
if (params[key]) {
|
|
89
99
|
if (Array.isArray(params[key])) {
|
|
90
|
-
const elements = params[key]
|
|
100
|
+
const elements = params[key];
|
|
91
101
|
for (const ele of elements) {
|
|
92
102
|
data += `${key}[]=${ele}&`;
|
|
93
103
|
}
|
|
@@ -100,31 +110,37 @@ const generateParams = (params={}) => {
|
|
|
100
110
|
return data.slice(0, -1);
|
|
101
111
|
} catch (error) {
|
|
102
112
|
console.error(err);
|
|
103
|
-
|
|
104
113
|
}
|
|
105
114
|
};
|
|
106
115
|
|
|
107
|
-
function setBearerToken(name = { token: null }) {
|
|
108
|
-
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
function setBearerToken(name = { token: null }) {
|
|
117
|
+
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
118
|
+
throw new TypeError(
|
|
119
|
+
"setBearerToken expects an object {token} with a 'token' property.",
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const tokenObj = { token: null, ...name, timestamp: Date.now() };
|
|
123
|
+
localStorage.setItem("logginToken", JSON.stringify(tokenObj));
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
function getBearerToken() {
|
|
116
|
-
const token = localStorage.getItem(
|
|
127
|
+
const token = localStorage.getItem("logginToken");
|
|
117
128
|
try {
|
|
118
129
|
return token ? JSON.parse(token) : null;
|
|
119
130
|
} catch (e) {
|
|
120
|
-
console.error(
|
|
131
|
+
console.error("Invalid token format in localStorage:", e);
|
|
121
132
|
return null;
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
135
|
|
|
125
|
-
function createPomStore(
|
|
136
|
+
function createPomStore(
|
|
137
|
+
piniaStore = "7286204094",
|
|
138
|
+
callBack = null,
|
|
139
|
+
ds = { StateClean: 0,extenalSetup:null }) {
|
|
140
|
+
setUpAxiosToUse(ds?.extenalSetup);
|
|
126
141
|
const storeId = "POM" + piniaStore;
|
|
127
|
-
const StateNameUsedSoferList = "septor-store-collection";
|
|
142
|
+
const StateNameUsedSoferList = "septor-store-collection";
|
|
143
|
+
const piniaData = defineStore(storeId, {
|
|
128
144
|
state: () => {
|
|
129
145
|
const StateObjectsContainer = {
|
|
130
146
|
CheckQueriesInQue: {},
|
|
@@ -133,7 +149,7 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
133
149
|
isThereAnyDataChangeInAform: false,
|
|
134
150
|
};
|
|
135
151
|
|
|
136
|
-
return StateObjectsContainer;
|
|
152
|
+
return StateObjectsContainer;
|
|
137
153
|
},
|
|
138
154
|
|
|
139
155
|
getters: {
|
|
@@ -144,7 +160,6 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
144
160
|
**/
|
|
145
161
|
return (state[TagetState] = state[TagetState]);
|
|
146
162
|
},
|
|
147
|
-
|
|
148
163
|
},
|
|
149
164
|
actions: {
|
|
150
165
|
validateObjectLength(object) {
|
|
@@ -176,17 +191,27 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
176
191
|
return new Promise((r) => setTimeout(r, timer));
|
|
177
192
|
},
|
|
178
193
|
|
|
179
|
-
async CallApiData(
|
|
194
|
+
async CallApiData(
|
|
195
|
+
StateStore,
|
|
196
|
+
callApi,
|
|
197
|
+
dataParams,
|
|
198
|
+
pagnated,
|
|
199
|
+
mStore = {},
|
|
200
|
+
config
|
|
201
|
+
) {
|
|
180
202
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
181
203
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
204
|
+
// console.log({...dataParams,config});
|
|
205
|
+
// alert()
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
let [res] = await Promise.all([useFetch({...dataParams,config})]);
|
|
185
209
|
|
|
186
|
-
if (res) {
|
|
210
|
+
if (res) {
|
|
187
211
|
this[StateStore] = res;
|
|
188
|
-
if (mStore?.mUse) {
|
|
189
|
-
const checkType =
|
|
212
|
+
if (mStore?.mUse) {
|
|
213
|
+
const checkType =
|
|
214
|
+
typeof res === "object" ? JSON.stringify(res) : res;
|
|
190
215
|
sessionStorage.setItem(StateStore, JSON.stringify(checkType));
|
|
191
216
|
}
|
|
192
217
|
|
|
@@ -211,35 +236,53 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
211
236
|
}
|
|
212
237
|
|
|
213
238
|
if (mStore?.mUse) {
|
|
214
|
-
const thisData = JSON.parse(
|
|
239
|
+
const thisData = JSON.parse(
|
|
240
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
241
|
+
);
|
|
215
242
|
return thisData;
|
|
216
243
|
}
|
|
217
244
|
} catch (error) {}
|
|
218
245
|
|
|
219
246
|
return this[dataResponseName];
|
|
220
247
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
248
|
+
WipeStates(storeKeyToRemove = null) {
|
|
249
|
+
const sptStateData =
|
|
250
|
+
localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
251
|
+
let previousState = JSON.parse(sptStateData);
|
|
252
|
+
if (storeKeyToRemove) delete previousState[storeKeyToRemove];
|
|
253
|
+
else previousState = {};
|
|
254
|
+
|
|
255
|
+
const regroup = JSON.stringify(previousState);
|
|
256
|
+
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
231
257
|
},
|
|
232
|
-
async stateGenaratorApi(
|
|
258
|
+
async stateGenaratorApi(
|
|
259
|
+
dd = {
|
|
260
|
+
reload: true,
|
|
261
|
+
StateStore: "",
|
|
262
|
+
reqs: {},
|
|
263
|
+
config: {},
|
|
264
|
+
time: 0,
|
|
265
|
+
pagnated: false,
|
|
266
|
+
mStore: { mUse: 0, reset: 0 },
|
|
267
|
+
},
|
|
268
|
+
fasterDataCollection = null
|
|
269
|
+
) {
|
|
270
|
+
|
|
233
271
|
this.Loading = true;
|
|
234
|
-
const { reload, StateStore, reqs, time, pagnated, mStore } = dd;
|
|
272
|
+
const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
|
|
235
273
|
const callApi = JSON.stringify(reqs);
|
|
236
274
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
237
275
|
this[StateStore] = StateVariable ?? [];
|
|
238
276
|
if (ds?.StateClean) {
|
|
239
|
-
const sptStateData =
|
|
277
|
+
const sptStateData =
|
|
278
|
+
localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
240
279
|
const previousState = JSON.parse(sptStateData);
|
|
241
|
-
const stateKey =
|
|
242
|
-
|
|
280
|
+
const stateKey =
|
|
281
|
+
typeof StateStore === "string" ? StateStore : "septore-store-";
|
|
282
|
+
const regroup = JSON.stringify({
|
|
283
|
+
...previousState,
|
|
284
|
+
[storeId + "(-_+_-)" + stateKey]: StateStore,
|
|
285
|
+
});
|
|
243
286
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
244
287
|
}
|
|
245
288
|
if (this.StateValue[StateStore]) {
|
|
@@ -252,7 +295,10 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
252
295
|
}
|
|
253
296
|
|
|
254
297
|
if (this.CheckQueriesInQue[callApi]) {
|
|
255
|
-
console.warn(
|
|
298
|
+
console.warn(
|
|
299
|
+
`************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
|
|
300
|
+
reqs
|
|
301
|
+
);
|
|
256
302
|
return;
|
|
257
303
|
}
|
|
258
304
|
try {
|
|
@@ -262,13 +308,15 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
262
308
|
|
|
263
309
|
if (counters > 0) {
|
|
264
310
|
if (reload) {
|
|
265
|
-
|
|
311
|
+
|
|
312
|
+
await this.sleep(1000 * time);
|
|
266
313
|
return await this.CallApiData(
|
|
267
314
|
StateStore,
|
|
268
315
|
callApi,
|
|
269
316
|
reqs,
|
|
270
317
|
pagnated,
|
|
271
|
-
mStore
|
|
318
|
+
mStore,
|
|
319
|
+
config
|
|
272
320
|
);
|
|
273
321
|
}
|
|
274
322
|
|
|
@@ -283,10 +331,11 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
283
331
|
callApi,
|
|
284
332
|
reqs,
|
|
285
333
|
pagnated,
|
|
286
|
-
mStore
|
|
334
|
+
mStore,
|
|
335
|
+
config
|
|
287
336
|
);
|
|
288
337
|
} catch (error) {
|
|
289
|
-
|
|
338
|
+
console.error(error);
|
|
290
339
|
if (this.CheckQueriesInQue[callApi])
|
|
291
340
|
delete this.CheckQueriesInQue[callApi];
|
|
292
341
|
}
|
|
@@ -314,4 +363,4 @@ function createPomStore( piniaStore = "7286204094", callBack=null,ds={StateClean
|
|
|
314
363
|
|
|
315
364
|
// module.e = createPomStore
|
|
316
365
|
|
|
317
|
-
export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, useFetch };
|
|
366
|
+
export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, setUpAxiosToUse, useFetch };
|
package/dist/index.js
CHANGED
|
@@ -64,23 +64,30 @@ customAxios.interceptors.request.use(
|
|
|
64
64
|
var custom_axios_default = customAxios;
|
|
65
65
|
|
|
66
66
|
// src/utils/useFetch.js
|
|
67
|
-
var
|
|
68
|
-
|
|
67
|
+
var axiosSetUps = custom_axios_default;
|
|
68
|
+
function setUpAxiosToUse(setUp) {
|
|
69
|
+
axiosSetUps = setUp ?? custom_axios_default;
|
|
70
|
+
}
|
|
71
|
+
var useFetch = async ({ url, method, data = {}, config }) => {
|
|
72
|
+
const uniformMethod = method.toLowerCase();
|
|
73
|
+
const headerC = {
|
|
74
|
+
...config,
|
|
75
|
+
headers: {
|
|
76
|
+
...(config == null ? void 0 : config.headers) || {}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
69
79
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
else if (uniformMethod === "put")
|
|
78
|
-
response = await custom_axios_default.put(url, _data, config ?? {});
|
|
79
|
-
else if (uniformMethod === "delete")
|
|
80
|
-
response = await custom_axios_default.delete(url, { data: _data, ...config ?? {} });
|
|
81
|
-
else
|
|
80
|
+
const axiosMethods = {
|
|
81
|
+
get: () => axiosSetUps.get(`${url}${generateParams(data)}`, headerC),
|
|
82
|
+
post: () => axiosSetUps.post(url, data, headerC),
|
|
83
|
+
put: () => axiosSetUps.put(url, data, headerC),
|
|
84
|
+
delete: () => axiosSetUps.delete(url, { data, ...headerC })
|
|
85
|
+
};
|
|
86
|
+
if (!axiosMethods[uniformMethod]) {
|
|
82
87
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
83
|
-
|
|
88
|
+
}
|
|
89
|
+
const response = await axiosMethods[uniformMethod]();
|
|
90
|
+
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
84
91
|
} catch (err2) {
|
|
85
92
|
console.error(err2);
|
|
86
93
|
return { success: false, error: err2 };
|
|
@@ -110,7 +117,9 @@ var generateParams = (params = {}) => {
|
|
|
110
117
|
};
|
|
111
118
|
function setBearerToken(name = { token: null }) {
|
|
112
119
|
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
113
|
-
throw new TypeError(
|
|
120
|
+
throw new TypeError(
|
|
121
|
+
"setBearerToken expects an object {token} with a 'token' property."
|
|
122
|
+
);
|
|
114
123
|
const tokenObj = { token: null, ...name, timestamp: Date.now() };
|
|
115
124
|
localStorage.setItem("logginToken", JSON.stringify(tokenObj));
|
|
116
125
|
}
|
|
@@ -125,10 +134,10 @@ function getBearerToken() {
|
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
// src/StoreManager/pomStateManagement.js
|
|
128
|
-
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0 }) {
|
|
137
|
+
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
138
|
+
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
129
139
|
const storeId = "POM" + piniaStore;
|
|
130
140
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
131
|
-
;
|
|
132
141
|
const piniaData = defineStore(storeId, {
|
|
133
142
|
state: () => {
|
|
134
143
|
const StateObjectsContainer = {
|
|
@@ -167,12 +176,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
167
176
|
sleep(timer) {
|
|
168
177
|
return new Promise((r) => setTimeout(r, timer));
|
|
169
178
|
},
|
|
170
|
-
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}) {
|
|
179
|
+
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config) {
|
|
171
180
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
172
181
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
173
|
-
let [res] = await Promise.all([
|
|
174
|
-
useFetch(dataParams)
|
|
175
|
-
]);
|
|
182
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
176
183
|
if (res) {
|
|
177
184
|
this[StateStore] = res;
|
|
178
185
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -196,7 +203,9 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
196
203
|
sessionStorage.removeItem(dataResponseName);
|
|
197
204
|
}
|
|
198
205
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
199
|
-
const thisData = JSON.parse(
|
|
206
|
+
const thisData = JSON.parse(
|
|
207
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
208
|
+
);
|
|
200
209
|
return thisData;
|
|
201
210
|
}
|
|
202
211
|
} catch (error) {
|
|
@@ -206,16 +215,22 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
206
215
|
WipeStates(storeKeyToRemove = null) {
|
|
207
216
|
const sptStateData = localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
208
217
|
let previousState = JSON.parse(sptStateData);
|
|
209
|
-
if (storeKeyToRemove)
|
|
210
|
-
|
|
211
|
-
else
|
|
212
|
-
previousState = {};
|
|
218
|
+
if (storeKeyToRemove) delete previousState[storeKeyToRemove];
|
|
219
|
+
else previousState = {};
|
|
213
220
|
const regroup = JSON.stringify(previousState);
|
|
214
221
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
215
222
|
},
|
|
216
|
-
async stateGenaratorApi(dd = {
|
|
223
|
+
async stateGenaratorApi(dd = {
|
|
224
|
+
reload: true,
|
|
225
|
+
StateStore: "",
|
|
226
|
+
reqs: {},
|
|
227
|
+
config: {},
|
|
228
|
+
time: 0,
|
|
229
|
+
pagnated: false,
|
|
230
|
+
mStore: { mUse: 0, reset: 0 }
|
|
231
|
+
}, fasterDataCollection = null) {
|
|
217
232
|
this.Loading = true;
|
|
218
|
-
const { reload, StateStore, reqs, time, pagnated, mStore } = dd;
|
|
233
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
219
234
|
const callApi = JSON.stringify(reqs);
|
|
220
235
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
221
236
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -223,7 +238,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
223
238
|
const sptStateData = localStorage.getItem(StateNameUsedSoferList) ?? "{}";
|
|
224
239
|
const previousState = JSON.parse(sptStateData);
|
|
225
240
|
const stateKey = typeof StateStore === "string" ? StateStore : "septore-store-";
|
|
226
|
-
const regroup = JSON.stringify({
|
|
241
|
+
const regroup = JSON.stringify({
|
|
242
|
+
...previousState,
|
|
243
|
+
[storeId + "(-_+_-)" + stateKey]: StateStore
|
|
244
|
+
});
|
|
227
245
|
localStorage.setItem(StateNameUsedSoferList, regroup);
|
|
228
246
|
}
|
|
229
247
|
if (this.StateValue[StateStore]) {
|
|
@@ -231,7 +249,10 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
231
249
|
this[StateStore] = false;
|
|
232
250
|
}
|
|
233
251
|
if (this.CheckQueriesInQue[callApi]) {
|
|
234
|
-
console.warn(
|
|
252
|
+
console.warn(
|
|
253
|
+
`************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
|
|
254
|
+
reqs
|
|
255
|
+
);
|
|
235
256
|
return;
|
|
236
257
|
}
|
|
237
258
|
try {
|
|
@@ -240,13 +261,14 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
240
261
|
fasterDataCollection(StateVariable);
|
|
241
262
|
if (counters > 0) {
|
|
242
263
|
if (reload) {
|
|
243
|
-
|
|
264
|
+
await this.sleep(1e3 * time);
|
|
244
265
|
return await this.CallApiData(
|
|
245
266
|
StateStore,
|
|
246
267
|
callApi,
|
|
247
268
|
reqs,
|
|
248
269
|
pagnated,
|
|
249
|
-
mStore
|
|
270
|
+
mStore,
|
|
271
|
+
config
|
|
250
272
|
);
|
|
251
273
|
}
|
|
252
274
|
this.Loading = false;
|
|
@@ -259,9 +281,11 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
259
281
|
callApi,
|
|
260
282
|
reqs,
|
|
261
283
|
pagnated,
|
|
262
|
-
mStore
|
|
284
|
+
mStore,
|
|
285
|
+
config
|
|
263
286
|
);
|
|
264
287
|
} catch (error) {
|
|
288
|
+
console.error(error);
|
|
265
289
|
if (this.CheckQueriesInQue[callApi])
|
|
266
290
|
delete this.CheckQueriesInQue[callApi];
|
|
267
291
|
}
|
|
@@ -287,5 +311,6 @@ export {
|
|
|
287
311
|
getBearerToken,
|
|
288
312
|
createPomStore as pomPinia,
|
|
289
313
|
setBearerToken,
|
|
314
|
+
setUpAxiosToUse,
|
|
290
315
|
useFetch
|
|
291
316
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A powerful, modular state management solution for Vue 3 applications, built on top of Pinia. Septor Store leverages the Plain Old Module (POM) pattern to provide dynamic store generation, intelligent API request handling, smart caching, and clean separation of concerns—making it ideal for scalable, maintainable, and high-performance frontend development.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -76,5 +76,6 @@
|
|
|
76
76
|
"bugs": {
|
|
77
77
|
"url": "https://github.com/ssengedonazil/septor-store-testing.git/issues"
|
|
78
78
|
},
|
|
79
|
-
"homepage": "https://github.com/ssengedonazil/septor-store-testing.git#readme"
|
|
79
|
+
"homepage": "https://github.com/ssengedonazil/septor-store-testing.git#readme",
|
|
80
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
80
81
|
}
|