septor-store 1.2.3 → 1.3.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.
- package/dist/index.cjs +23 -22
- package/dist/index.d.cts +38 -28
- package/dist/index.d.ts +38 -28
- package/dist/index.js +23 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -77,8 +77,8 @@ var requestHandler = (request) => {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
request.headers = { ...(request == null ? void 0 : request.headers) ?? {} };
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
console.log("default call");
|
|
81
|
+
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
82
82
|
if (request.data instanceof FormData) {
|
|
83
83
|
const formData = request.data;
|
|
84
84
|
request.data = formData;
|
|
@@ -106,23 +106,25 @@ var custom_axios_default = customAxios;
|
|
|
106
106
|
|
|
107
107
|
// src/utils/useFetch.js
|
|
108
108
|
var axiosSetUps = custom_axios_default;
|
|
109
|
-
function setUpAxiosToUse(setUp) {
|
|
109
|
+
async function setUpAxiosToUse(setUp) {
|
|
110
110
|
axiosSetUps = setUp ?? custom_axios_default;
|
|
111
111
|
}
|
|
112
|
-
var useFetch = async ({ url, method, data = {}, config }) => {
|
|
113
|
-
const uniformMethod = method
|
|
112
|
+
var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
113
|
+
const uniformMethod = `${method}`.toLowerCase();
|
|
114
114
|
const headerC = {
|
|
115
115
|
...config,
|
|
116
116
|
headers: {
|
|
117
117
|
...(config == null ? void 0 : config.headers) || {}
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
|
+
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
121
|
+
console.log(axiosInstance);
|
|
120
122
|
try {
|
|
121
123
|
const axiosMethods = {
|
|
122
|
-
get: () =>
|
|
123
|
-
post: () =>
|
|
124
|
-
put: () =>
|
|
125
|
-
delete: () =>
|
|
124
|
+
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
125
|
+
post: () => axiosClient.post(url, data, headerC),
|
|
126
|
+
put: () => axiosClient.put(url, data, headerC),
|
|
127
|
+
delete: () => axiosClient.delete(url, { data, ...headerC })
|
|
126
128
|
};
|
|
127
129
|
if (!axiosMethods[uniformMethod]) {
|
|
128
130
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
@@ -178,11 +180,11 @@ function getBearerToken() {
|
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
// src/StoreManager/pomStateManagement.js
|
|
181
|
-
function
|
|
183
|
+
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
182
184
|
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
183
185
|
const storeId = "POM" + piniaStore;
|
|
184
186
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
185
|
-
|
|
187
|
+
const piniaData = (0, import_pinia.defineStore)(storeId, {
|
|
186
188
|
state: () => {
|
|
187
189
|
const StateObjectsContainer = {
|
|
188
190
|
CheckQueriesInQue: {},
|
|
@@ -220,10 +222,10 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
220
222
|
sleep(timer) {
|
|
221
223
|
return new Promise((r) => setTimeout(r, timer));
|
|
222
224
|
},
|
|
223
|
-
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config) {
|
|
225
|
+
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config, axiosInstance = null) {
|
|
224
226
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
225
227
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
226
|
-
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
228
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
|
|
227
229
|
if (res) {
|
|
228
230
|
this[StateStore] = res;
|
|
229
231
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -271,11 +273,11 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
271
273
|
config: {},
|
|
272
274
|
time: 0,
|
|
273
275
|
pagnated: false,
|
|
274
|
-
mStore: { mUse: 0, reset: 0 }
|
|
276
|
+
mStore: { mUse: 0, reset: 0 },
|
|
277
|
+
axiosInstance: null
|
|
275
278
|
}, fasterDataCollection = null) {
|
|
276
|
-
alert("stateGenaratorApi");
|
|
277
279
|
this.Loading = true;
|
|
278
|
-
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
280
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config, axiosInstance } = dd;
|
|
279
281
|
const callApi = JSON.stringify(reqs);
|
|
280
282
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
281
283
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -304,7 +306,6 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
304
306
|
const counters = this.validateObjectLength(StateVariable);
|
|
305
307
|
if (typeof fasterDataCollection == "function")
|
|
306
308
|
fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
|
|
307
|
-
console.log(counters);
|
|
308
309
|
if (counters > 0) {
|
|
309
310
|
if (reload) {
|
|
310
311
|
await this.sleep(1e3 * time);
|
|
@@ -314,7 +315,8 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
314
315
|
reqs,
|
|
315
316
|
pagnated,
|
|
316
317
|
mStore,
|
|
317
|
-
config
|
|
318
|
+
config,
|
|
319
|
+
axiosInstance
|
|
318
320
|
);
|
|
319
321
|
}
|
|
320
322
|
this.Loading = false;
|
|
@@ -328,7 +330,8 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
328
330
|
reqs,
|
|
329
331
|
pagnated,
|
|
330
332
|
mStore,
|
|
331
|
-
config
|
|
333
|
+
config,
|
|
334
|
+
axiosInstance
|
|
332
335
|
);
|
|
333
336
|
} catch (error) {
|
|
334
337
|
console.error(error);
|
|
@@ -350,9 +353,7 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
350
353
|
}
|
|
351
354
|
}
|
|
352
355
|
});
|
|
353
|
-
|
|
354
|
-
function createPomStore() {
|
|
355
|
-
return motherCreatePomStore();
|
|
356
|
+
return piniaData();
|
|
356
357
|
}
|
|
357
358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
358
359
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -4,14 +4,16 @@ import axios from 'axios';
|
|
|
4
4
|
const AbortHandler = {
|
|
5
5
|
abortController: new AbortController()};
|
|
6
6
|
|
|
7
|
-
let baseURL =
|
|
7
|
+
let baseURL =
|
|
8
|
+
typeof import.meta !== "undefined"
|
|
9
|
+
? (import.meta.env.VITE_BACKEND_URL ?? "")
|
|
10
|
+
: "";
|
|
8
11
|
|
|
9
12
|
const customAxios = axios.create({
|
|
10
13
|
baseURL: baseURL,
|
|
11
14
|
signal: AbortHandler.abortController.signal, // Signal that is assiciated with any request to be made with this axios instance
|
|
12
15
|
});
|
|
13
16
|
|
|
14
|
-
|
|
15
17
|
// Request Interceptor
|
|
16
18
|
const requestHandler = (request) => {
|
|
17
19
|
const tokenData = getBearerToken();
|
|
@@ -21,17 +23,17 @@ const requestHandler = (request) => {
|
|
|
21
23
|
if (expiresIn) {
|
|
22
24
|
const timestamp = tokenData?.timestamp ?? null;
|
|
23
25
|
const now = Date.now();
|
|
24
|
-
if (expiresIn &&
|
|
26
|
+
if (expiresIn && now - timestamp > expiresIn * 1000) {
|
|
25
27
|
console.warn("Token has expired.");
|
|
26
|
-
localStorage.removeItem("logginToken");
|
|
28
|
+
localStorage.removeItem("logginToken");
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
request.headers = {...(request?.headers??{})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
|
|
33
|
+
request.headers = { ...(request?.headers ?? {}) } || {};
|
|
34
|
+
console.log("default call");
|
|
35
|
+
|
|
36
|
+
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
35
37
|
// Handle FormData explicitly if needed
|
|
36
38
|
if (request.data instanceof FormData) {
|
|
37
39
|
const formData = request.data;
|
|
@@ -50,34 +52,40 @@ customAxios.interceptors.response.use(
|
|
|
50
52
|
console.log("Error.....", error);
|
|
51
53
|
if (error.response?.status === 401) ;
|
|
52
54
|
return Promise.reject(error); // Reject the error for further handling
|
|
53
|
-
}
|
|
55
|
+
},
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
// Attach Request Interceptor
|
|
57
59
|
customAxios.interceptors.request.use(requestHandler, (error) =>
|
|
58
|
-
Promise.reject(error)
|
|
60
|
+
Promise.reject(error),
|
|
59
61
|
);
|
|
60
62
|
|
|
61
63
|
let axiosSetUps = customAxios;
|
|
62
64
|
|
|
63
|
-
function setUpAxiosToUse(setUp) {
|
|
65
|
+
async function setUpAxiosToUse(setUp) {
|
|
64
66
|
axiosSetUps = setUp??customAxios;
|
|
67
|
+
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
|
|
70
|
+
const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
71
|
+
const uniformMethod = `${method}`.toLowerCase();
|
|
68
72
|
const headerC = {
|
|
69
73
|
...config,
|
|
70
74
|
headers: {
|
|
71
75
|
...(config?.headers || {}),
|
|
72
76
|
},
|
|
73
77
|
};
|
|
78
|
+
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
79
|
+
console.log(axiosInstance);
|
|
80
|
+
|
|
74
81
|
|
|
82
|
+
|
|
75
83
|
try {
|
|
76
84
|
const axiosMethods = {
|
|
77
|
-
get: () =>
|
|
78
|
-
post: () =>
|
|
79
|
-
put: () =>
|
|
80
|
-
delete: () =>
|
|
85
|
+
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
86
|
+
post: () => axiosClient.post(url, data, headerC),
|
|
87
|
+
put: () => axiosClient.put(url, data, headerC),
|
|
88
|
+
delete: () => axiosClient.delete(url, { data, ...headerC }),
|
|
81
89
|
};
|
|
82
90
|
|
|
83
91
|
if (!axiosMethods[uniformMethod]) {
|
|
@@ -138,7 +146,7 @@ function getBearerToken() {
|
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
|
|
141
|
-
function
|
|
149
|
+
function createPomStore(
|
|
142
150
|
piniaStore = "7286204094",
|
|
143
151
|
callBack = null,
|
|
144
152
|
ds = { StateClean: 0, extenalSetup: null },
|
|
@@ -146,7 +154,7 @@ function motherCreatePomStore(
|
|
|
146
154
|
setUpAxiosToUse(ds?.extenalSetup);
|
|
147
155
|
const storeId = "POM" + piniaStore;
|
|
148
156
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
149
|
-
|
|
157
|
+
const piniaData = defineStore(storeId, {
|
|
150
158
|
state: () => {
|
|
151
159
|
const StateObjectsContainer = {
|
|
152
160
|
CheckQueriesInQue: {},
|
|
@@ -204,11 +212,11 @@ function motherCreatePomStore(
|
|
|
204
212
|
pagnated,
|
|
205
213
|
mStore = {},
|
|
206
214
|
config,
|
|
215
|
+
axiosInstance = null,
|
|
207
216
|
) {
|
|
208
217
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
209
218
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
210
|
-
|
|
211
|
-
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
219
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
|
|
212
220
|
// const collection=;
|
|
213
221
|
if (res) {
|
|
214
222
|
this[StateStore] = res;
|
|
@@ -267,12 +275,12 @@ function motherCreatePomStore(
|
|
|
267
275
|
time: 0,
|
|
268
276
|
pagnated: false,
|
|
269
277
|
mStore: { mUse: 0, reset: 0 },
|
|
278
|
+
axiosInstance : null,
|
|
270
279
|
},
|
|
271
280
|
fasterDataCollection = null,
|
|
272
281
|
) {
|
|
273
|
-
alert("stateGenaratorApi");
|
|
274
282
|
this.Loading = true;
|
|
275
|
-
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
283
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config,axiosInstance } = dd;
|
|
276
284
|
const callApi = JSON.stringify(reqs);
|
|
277
285
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
278
286
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -309,7 +317,6 @@ function motherCreatePomStore(
|
|
|
309
317
|
|
|
310
318
|
if (typeof fasterDataCollection == "function")
|
|
311
319
|
fasterDataCollection?.(StateVariable);
|
|
312
|
-
console.log(counters);
|
|
313
320
|
|
|
314
321
|
if (counters > 0) {
|
|
315
322
|
if (reload) {
|
|
@@ -321,6 +328,7 @@ function motherCreatePomStore(
|
|
|
321
328
|
pagnated,
|
|
322
329
|
mStore,
|
|
323
330
|
config,
|
|
331
|
+
axiosInstance,
|
|
324
332
|
);
|
|
325
333
|
}
|
|
326
334
|
|
|
@@ -337,6 +345,7 @@ function motherCreatePomStore(
|
|
|
337
345
|
pagnated,
|
|
338
346
|
mStore,
|
|
339
347
|
config,
|
|
348
|
+
axiosInstance
|
|
340
349
|
);
|
|
341
350
|
} catch (error) {
|
|
342
351
|
console.error(error);
|
|
@@ -361,11 +370,12 @@ function motherCreatePomStore(
|
|
|
361
370
|
pagenatedData() {},
|
|
362
371
|
},
|
|
363
372
|
});
|
|
373
|
+
return piniaData();
|
|
364
374
|
}
|
|
365
375
|
|
|
366
|
-
function createPomStore() {
|
|
367
|
-
|
|
368
|
-
}
|
|
376
|
+
// export default function createPomStore() {
|
|
377
|
+
// return motherCreatePomStore();
|
|
378
|
+
// }
|
|
369
379
|
|
|
370
380
|
// module.e = createPomStore
|
|
371
381
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,14 +4,16 @@ import axios from 'axios';
|
|
|
4
4
|
const AbortHandler = {
|
|
5
5
|
abortController: new AbortController()};
|
|
6
6
|
|
|
7
|
-
let baseURL =
|
|
7
|
+
let baseURL =
|
|
8
|
+
typeof import.meta !== "undefined"
|
|
9
|
+
? (import.meta.env.VITE_BACKEND_URL ?? "")
|
|
10
|
+
: "";
|
|
8
11
|
|
|
9
12
|
const customAxios = axios.create({
|
|
10
13
|
baseURL: baseURL,
|
|
11
14
|
signal: AbortHandler.abortController.signal, // Signal that is assiciated with any request to be made with this axios instance
|
|
12
15
|
});
|
|
13
16
|
|
|
14
|
-
|
|
15
17
|
// Request Interceptor
|
|
16
18
|
const requestHandler = (request) => {
|
|
17
19
|
const tokenData = getBearerToken();
|
|
@@ -21,17 +23,17 @@ const requestHandler = (request) => {
|
|
|
21
23
|
if (expiresIn) {
|
|
22
24
|
const timestamp = tokenData?.timestamp ?? null;
|
|
23
25
|
const now = Date.now();
|
|
24
|
-
if (expiresIn &&
|
|
26
|
+
if (expiresIn && now - timestamp > expiresIn * 1000) {
|
|
25
27
|
console.warn("Token has expired.");
|
|
26
|
-
localStorage.removeItem("logginToken");
|
|
28
|
+
localStorage.removeItem("logginToken");
|
|
27
29
|
return null;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
request.headers = {...(request?.headers??{})
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
|
|
33
|
+
request.headers = { ...(request?.headers ?? {}) } || {};
|
|
34
|
+
console.log("default call");
|
|
35
|
+
|
|
36
|
+
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
35
37
|
// Handle FormData explicitly if needed
|
|
36
38
|
if (request.data instanceof FormData) {
|
|
37
39
|
const formData = request.data;
|
|
@@ -50,34 +52,40 @@ customAxios.interceptors.response.use(
|
|
|
50
52
|
console.log("Error.....", error);
|
|
51
53
|
if (error.response?.status === 401) ;
|
|
52
54
|
return Promise.reject(error); // Reject the error for further handling
|
|
53
|
-
}
|
|
55
|
+
},
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
// Attach Request Interceptor
|
|
57
59
|
customAxios.interceptors.request.use(requestHandler, (error) =>
|
|
58
|
-
Promise.reject(error)
|
|
60
|
+
Promise.reject(error),
|
|
59
61
|
);
|
|
60
62
|
|
|
61
63
|
let axiosSetUps = customAxios;
|
|
62
64
|
|
|
63
|
-
function setUpAxiosToUse(setUp) {
|
|
65
|
+
async function setUpAxiosToUse(setUp) {
|
|
64
66
|
axiosSetUps = setUp??customAxios;
|
|
67
|
+
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
|
|
70
|
+
const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
71
|
+
const uniformMethod = `${method}`.toLowerCase();
|
|
68
72
|
const headerC = {
|
|
69
73
|
...config,
|
|
70
74
|
headers: {
|
|
71
75
|
...(config?.headers || {}),
|
|
72
76
|
},
|
|
73
77
|
};
|
|
78
|
+
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
79
|
+
console.log(axiosInstance);
|
|
80
|
+
|
|
74
81
|
|
|
82
|
+
|
|
75
83
|
try {
|
|
76
84
|
const axiosMethods = {
|
|
77
|
-
get: () =>
|
|
78
|
-
post: () =>
|
|
79
|
-
put: () =>
|
|
80
|
-
delete: () =>
|
|
85
|
+
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
86
|
+
post: () => axiosClient.post(url, data, headerC),
|
|
87
|
+
put: () => axiosClient.put(url, data, headerC),
|
|
88
|
+
delete: () => axiosClient.delete(url, { data, ...headerC }),
|
|
81
89
|
};
|
|
82
90
|
|
|
83
91
|
if (!axiosMethods[uniformMethod]) {
|
|
@@ -138,7 +146,7 @@ function getBearerToken() {
|
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
|
|
141
|
-
function
|
|
149
|
+
function createPomStore(
|
|
142
150
|
piniaStore = "7286204094",
|
|
143
151
|
callBack = null,
|
|
144
152
|
ds = { StateClean: 0, extenalSetup: null },
|
|
@@ -146,7 +154,7 @@ function motherCreatePomStore(
|
|
|
146
154
|
setUpAxiosToUse(ds?.extenalSetup);
|
|
147
155
|
const storeId = "POM" + piniaStore;
|
|
148
156
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
149
|
-
|
|
157
|
+
const piniaData = defineStore(storeId, {
|
|
150
158
|
state: () => {
|
|
151
159
|
const StateObjectsContainer = {
|
|
152
160
|
CheckQueriesInQue: {},
|
|
@@ -204,11 +212,11 @@ function motherCreatePomStore(
|
|
|
204
212
|
pagnated,
|
|
205
213
|
mStore = {},
|
|
206
214
|
config,
|
|
215
|
+
axiosInstance = null,
|
|
207
216
|
) {
|
|
208
217
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
209
218
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
210
|
-
|
|
211
|
-
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
219
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
|
|
212
220
|
// const collection=;
|
|
213
221
|
if (res) {
|
|
214
222
|
this[StateStore] = res;
|
|
@@ -267,12 +275,12 @@ function motherCreatePomStore(
|
|
|
267
275
|
time: 0,
|
|
268
276
|
pagnated: false,
|
|
269
277
|
mStore: { mUse: 0, reset: 0 },
|
|
278
|
+
axiosInstance : null,
|
|
270
279
|
},
|
|
271
280
|
fasterDataCollection = null,
|
|
272
281
|
) {
|
|
273
|
-
alert("stateGenaratorApi");
|
|
274
282
|
this.Loading = true;
|
|
275
|
-
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
283
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config,axiosInstance } = dd;
|
|
276
284
|
const callApi = JSON.stringify(reqs);
|
|
277
285
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
278
286
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -309,7 +317,6 @@ function motherCreatePomStore(
|
|
|
309
317
|
|
|
310
318
|
if (typeof fasterDataCollection == "function")
|
|
311
319
|
fasterDataCollection?.(StateVariable);
|
|
312
|
-
console.log(counters);
|
|
313
320
|
|
|
314
321
|
if (counters > 0) {
|
|
315
322
|
if (reload) {
|
|
@@ -321,6 +328,7 @@ function motherCreatePomStore(
|
|
|
321
328
|
pagnated,
|
|
322
329
|
mStore,
|
|
323
330
|
config,
|
|
331
|
+
axiosInstance,
|
|
324
332
|
);
|
|
325
333
|
}
|
|
326
334
|
|
|
@@ -337,6 +345,7 @@ function motherCreatePomStore(
|
|
|
337
345
|
pagnated,
|
|
338
346
|
mStore,
|
|
339
347
|
config,
|
|
348
|
+
axiosInstance
|
|
340
349
|
);
|
|
341
350
|
} catch (error) {
|
|
342
351
|
console.error(error);
|
|
@@ -361,11 +370,12 @@ function motherCreatePomStore(
|
|
|
361
370
|
pagenatedData() {},
|
|
362
371
|
},
|
|
363
372
|
});
|
|
373
|
+
return piniaData();
|
|
364
374
|
}
|
|
365
375
|
|
|
366
|
-
function createPomStore() {
|
|
367
|
-
|
|
368
|
-
}
|
|
376
|
+
// export default function createPomStore() {
|
|
377
|
+
// return motherCreatePomStore();
|
|
378
|
+
// }
|
|
369
379
|
|
|
370
380
|
// module.e = createPomStore
|
|
371
381
|
|
package/dist/index.js
CHANGED
|
@@ -36,8 +36,8 @@ var requestHandler = (request) => {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
request.headers = { ...(request == null ? void 0 : request.headers) ?? {} };
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
console.log("default call");
|
|
40
|
+
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
41
41
|
if (request.data instanceof FormData) {
|
|
42
42
|
const formData = request.data;
|
|
43
43
|
request.data = formData;
|
|
@@ -65,23 +65,25 @@ var custom_axios_default = customAxios;
|
|
|
65
65
|
|
|
66
66
|
// src/utils/useFetch.js
|
|
67
67
|
var axiosSetUps = custom_axios_default;
|
|
68
|
-
function setUpAxiosToUse(setUp) {
|
|
68
|
+
async function setUpAxiosToUse(setUp) {
|
|
69
69
|
axiosSetUps = setUp ?? custom_axios_default;
|
|
70
70
|
}
|
|
71
|
-
var useFetch = async ({ url, method, data = {}, config }) => {
|
|
72
|
-
const uniformMethod = method
|
|
71
|
+
var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
72
|
+
const uniformMethod = `${method}`.toLowerCase();
|
|
73
73
|
const headerC = {
|
|
74
74
|
...config,
|
|
75
75
|
headers: {
|
|
76
76
|
...(config == null ? void 0 : config.headers) || {}
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
+
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
80
|
+
console.log(axiosInstance);
|
|
79
81
|
try {
|
|
80
82
|
const axiosMethods = {
|
|
81
|
-
get: () =>
|
|
82
|
-
post: () =>
|
|
83
|
-
put: () =>
|
|
84
|
-
delete: () =>
|
|
83
|
+
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
84
|
+
post: () => axiosClient.post(url, data, headerC),
|
|
85
|
+
put: () => axiosClient.put(url, data, headerC),
|
|
86
|
+
delete: () => axiosClient.delete(url, { data, ...headerC })
|
|
85
87
|
};
|
|
86
88
|
if (!axiosMethods[uniformMethod]) {
|
|
87
89
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
@@ -137,11 +139,11 @@ function getBearerToken() {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
// src/StoreManager/pomStateManagement.js
|
|
140
|
-
function
|
|
142
|
+
function createPomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
141
143
|
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
142
144
|
const storeId = "POM" + piniaStore;
|
|
143
145
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
144
|
-
|
|
146
|
+
const piniaData = defineStore(storeId, {
|
|
145
147
|
state: () => {
|
|
146
148
|
const StateObjectsContainer = {
|
|
147
149
|
CheckQueriesInQue: {},
|
|
@@ -179,10 +181,10 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
179
181
|
sleep(timer) {
|
|
180
182
|
return new Promise((r) => setTimeout(r, timer));
|
|
181
183
|
},
|
|
182
|
-
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config) {
|
|
184
|
+
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config, axiosInstance = null) {
|
|
183
185
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
184
186
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
185
|
-
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
187
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
|
|
186
188
|
if (res) {
|
|
187
189
|
this[StateStore] = res;
|
|
188
190
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -230,11 +232,11 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
230
232
|
config: {},
|
|
231
233
|
time: 0,
|
|
232
234
|
pagnated: false,
|
|
233
|
-
mStore: { mUse: 0, reset: 0 }
|
|
235
|
+
mStore: { mUse: 0, reset: 0 },
|
|
236
|
+
axiosInstance: null
|
|
234
237
|
}, fasterDataCollection = null) {
|
|
235
|
-
alert("stateGenaratorApi");
|
|
236
238
|
this.Loading = true;
|
|
237
|
-
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
239
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config, axiosInstance } = dd;
|
|
238
240
|
const callApi = JSON.stringify(reqs);
|
|
239
241
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
240
242
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -263,7 +265,6 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
263
265
|
const counters = this.validateObjectLength(StateVariable);
|
|
264
266
|
if (typeof fasterDataCollection == "function")
|
|
265
267
|
fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
|
|
266
|
-
console.log(counters);
|
|
267
268
|
if (counters > 0) {
|
|
268
269
|
if (reload) {
|
|
269
270
|
await this.sleep(1e3 * time);
|
|
@@ -273,7 +274,8 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
273
274
|
reqs,
|
|
274
275
|
pagnated,
|
|
275
276
|
mStore,
|
|
276
|
-
config
|
|
277
|
+
config,
|
|
278
|
+
axiosInstance
|
|
277
279
|
);
|
|
278
280
|
}
|
|
279
281
|
this.Loading = false;
|
|
@@ -287,7 +289,8 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
287
289
|
reqs,
|
|
288
290
|
pagnated,
|
|
289
291
|
mStore,
|
|
290
|
-
config
|
|
292
|
+
config,
|
|
293
|
+
axiosInstance
|
|
291
294
|
);
|
|
292
295
|
} catch (error) {
|
|
293
296
|
console.error(error);
|
|
@@ -309,9 +312,7 @@ function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = {
|
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
314
|
});
|
|
312
|
-
|
|
313
|
-
function createPomStore() {
|
|
314
|
-
return motherCreatePomStore();
|
|
315
|
+
return piniaData();
|
|
315
316
|
}
|
|
316
317
|
export {
|
|
317
318
|
generateParams,
|
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.
|
|
6
|
+
"version": "1.3.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|