septor-store 1.3.4 → 1.3.5
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/README.md +44 -3
- package/dist/index.cjs +18 -3
- package/dist/index.d.cts +24 -6
- package/dist/index.d.ts +24 -6
- package/dist/index.js +18 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -300,12 +300,53 @@ const handleSubmit = async () => {
|
|
|
300
300
|
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
### Usage
|
|
307
|
+
###### Note: % wish to use your external axios Instance%
|
|
308
|
+
```
|
|
309
|
+
const usePomStore = pomPinia('myCustomStoreId',null,{StateClean:true});
|
|
310
|
+
const pomStore = usePomStore();
|
|
311
|
+
async function fetchTableData({ data, props, Store, saveData = true,}: {
|
|
312
|
+
data: any
|
|
313
|
+
props: any
|
|
314
|
+
Store: any
|
|
315
|
+
saveData?: boolean
|
|
316
|
+
}) {
|
|
317
|
+
const subdomain = getSubdomainName()
|
|
318
|
+
const axiosInstance = subdomain ? Instance1 : Instance2
|
|
319
|
+
|
|
320
|
+
const stateName =props?.state || props?.url.replace(/[^a-z0-9]+/gi, '-')
|
|
321
|
+
const collection = {
|
|
322
|
+
reload: props?.reload ? 0 : 1,
|
|
323
|
+
StateStore: stateName,
|
|
324
|
+
time: props?.time ?? 0,
|
|
325
|
+
reqs: {
|
|
326
|
+
...props,
|
|
327
|
+
url:props.url,
|
|
328
|
+
method: 'post',
|
|
329
|
+
data,
|
|
330
|
+
},
|
|
331
|
+
config: props?.config,
|
|
332
|
+
axiosInstance,// here how to pass it
|
|
333
|
+
mStore: {
|
|
334
|
+
mUse: saveData // not much vital this helps in data persistence
|
|
335
|
+
},
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
return Store.stateGenaratorApi(collection)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
```
|
|
303
345
|
🤝 Contributing and Feedback
|
|
304
|
-
|
|
346
|
+
I welcome all contributions and feedback to improve septor-store!
|
|
305
347
|
If you encounter any bugs, have suggestions, or want to contribute,
|
|
306
|
-
please open an issue or submit a pull request:
|
|
348
|
+
please open an issue or submit a pull request: ssenegendonazil@gmail.com
|
|
307
349
|
👉 Report Issues or Suggestions : <https://github.com/ssengedonazil/septor-store-testing>
|
|
308
|
-
|
|
309
350
|
If you find this package useful, consider supporting me:
|
|
310
351
|
|
|
311
352
|
[](https://ko-fi.com/ssengendonazil)
|
package/dist/index.cjs
CHANGED
|
@@ -77,7 +77,6 @@ var requestHandler = (request) => {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
request.headers = { ...(request == null ? void 0 : request.headers) ?? {} };
|
|
80
|
-
console.log("default call");
|
|
81
80
|
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
82
81
|
if (request.data instanceof FormData) {
|
|
83
82
|
const formData = request.data;
|
|
@@ -118,7 +117,6 @@ var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
|
118
117
|
}
|
|
119
118
|
};
|
|
120
119
|
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
121
|
-
console.log(axiosInstance);
|
|
122
120
|
try {
|
|
123
121
|
const axiosMethods = {
|
|
124
122
|
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
@@ -130,7 +128,7 @@ var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
|
130
128
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
131
129
|
}
|
|
132
130
|
const response = await axiosMethods[uniformMethod]();
|
|
133
|
-
if (response == null ? void 0 : response.
|
|
131
|
+
if (response == null ? void 0 : response.data) {
|
|
134
132
|
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
135
133
|
}
|
|
136
134
|
return false;
|
|
@@ -223,9 +221,25 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
223
221
|
return new Promise((r) => setTimeout(r, timer));
|
|
224
222
|
},
|
|
225
223
|
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config, axiosInstance = null) {
|
|
224
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
226
225
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
227
226
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
228
227
|
let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
|
|
228
|
+
if (res == null ? void 0 : res.error) {
|
|
229
|
+
const msg = { msg: "", error: true };
|
|
230
|
+
if ((_b = (_a = res.error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
|
|
231
|
+
msg.msg = res.error.response.data.error;
|
|
232
|
+
} else if (res.error.message) {
|
|
233
|
+
msg.msg = res.error.message;
|
|
234
|
+
} else if ((_d = (_c = res.error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.errors) {
|
|
235
|
+
const errors = res.error.response.data.errors;
|
|
236
|
+
msg.msg = Object.values(errors)[0][0] || msg.msg;
|
|
237
|
+
}
|
|
238
|
+
if ((_h = (_g = (_f = (_e = res == null ? void 0 : res.error) == null ? void 0 : _e.response) == null ? void 0 : _f.data) == null ? void 0 : _g.payload) == null ? void 0 : _h.message) {
|
|
239
|
+
msg.msg = res.error.response.data.payload.message;
|
|
240
|
+
}
|
|
241
|
+
return res;
|
|
242
|
+
}
|
|
229
243
|
if (res) {
|
|
230
244
|
this[StateStore] = res;
|
|
231
245
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -306,6 +320,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
306
320
|
const counters = this.validateObjectLength(StateVariable);
|
|
307
321
|
if (typeof fasterDataCollection == "function")
|
|
308
322
|
fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
|
|
323
|
+
console.log({ counters, reload, StateStore });
|
|
309
324
|
if (counters > 0) {
|
|
310
325
|
if (reload) {
|
|
311
326
|
await this.sleep(1e3 * time);
|
package/dist/index.d.cts
CHANGED
|
@@ -31,7 +31,6 @@ const requestHandler = (request) => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
request.headers = { ...(request?.headers ?? {}) } || {};
|
|
34
|
-
console.log("default call");
|
|
35
34
|
|
|
36
35
|
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
37
36
|
// Handle FormData explicitly if needed
|
|
@@ -76,7 +75,7 @@ const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
|
76
75
|
},
|
|
77
76
|
};
|
|
78
77
|
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
79
|
-
console.log(
|
|
78
|
+
// console.log({headerC,data});
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
|
|
@@ -92,7 +91,8 @@ const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
|
92
91
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
93
92
|
}
|
|
94
93
|
const response = await axiosMethods[uniformMethod]();
|
|
95
|
-
if(response?.
|
|
94
|
+
if(response?.data){
|
|
95
|
+
// if(response?.status){
|
|
96
96
|
return response?.data ?? response ??{ Empty: "Empty" };
|
|
97
97
|
}
|
|
98
98
|
return false
|
|
@@ -218,14 +218,30 @@ function createPomStore(
|
|
|
218
218
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
219
219
|
let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
|
|
220
220
|
// const collection=;
|
|
221
|
+
if (res?.error) {
|
|
222
|
+
const msg = { msg: ""};
|
|
223
|
+
if (res.error.response?.data?.error) {
|
|
224
|
+
msg.msg = res.error.response.data.error;
|
|
225
|
+
} else if (res.error.message) {
|
|
226
|
+
msg.msg = res.error.message;
|
|
227
|
+
} else if (res.error.response?.data?.errors) {
|
|
228
|
+
const errors = res.error.response.data.errors;
|
|
229
|
+
msg.msg = Object.values(errors)[0][0] || msg.msg;
|
|
230
|
+
}
|
|
231
|
+
if (res?.error?.response?.data?.payload?.message) {
|
|
232
|
+
msg.msg = res.error.response.data.payload.message;
|
|
233
|
+
}
|
|
234
|
+
return res
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
221
239
|
if (res) {
|
|
222
240
|
this[StateStore] = res;
|
|
223
241
|
if (mStore?.mUse) {
|
|
224
|
-
const checkType =
|
|
225
|
-
typeof res === "object" ? JSON.stringify(res) : res;
|
|
242
|
+
const checkType =typeof res === "object" ? JSON.stringify(res) : res;
|
|
226
243
|
sessionStorage.setItem(StateStore, JSON.stringify(checkType));
|
|
227
244
|
}
|
|
228
|
-
|
|
229
245
|
delete this.CheckQueriesInQue[callApi];
|
|
230
246
|
} else {
|
|
231
247
|
delete this.CheckQueriesInQue[callApi];
|
|
@@ -318,7 +334,9 @@ function createPomStore(
|
|
|
318
334
|
if (typeof fasterDataCollection == "function")
|
|
319
335
|
fasterDataCollection?.(StateVariable);
|
|
320
336
|
|
|
337
|
+
console.log({counters,reload,StateStore});
|
|
321
338
|
if (counters > 0) {
|
|
339
|
+
|
|
322
340
|
if (reload) {
|
|
323
341
|
await this.sleep(1000 * time);
|
|
324
342
|
return await this.CallApiData(
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ const requestHandler = (request) => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
request.headers = { ...(request?.headers ?? {}) } || {};
|
|
34
|
-
console.log("default call");
|
|
35
34
|
|
|
36
35
|
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
37
36
|
// Handle FormData explicitly if needed
|
|
@@ -76,7 +75,7 @@ const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
|
76
75
|
},
|
|
77
76
|
};
|
|
78
77
|
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
79
|
-
console.log(
|
|
78
|
+
// console.log({headerC,data});
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
|
|
@@ -92,7 +91,8 @@ const useFetch = async ({ url, method, data = {}, config,axiosInstance }) => {
|
|
|
92
91
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
93
92
|
}
|
|
94
93
|
const response = await axiosMethods[uniformMethod]();
|
|
95
|
-
if(response?.
|
|
94
|
+
if(response?.data){
|
|
95
|
+
// if(response?.status){
|
|
96
96
|
return response?.data ?? response ??{ Empty: "Empty" };
|
|
97
97
|
}
|
|
98
98
|
return false
|
|
@@ -218,14 +218,30 @@ function createPomStore(
|
|
|
218
218
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
219
219
|
let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
|
|
220
220
|
// const collection=;
|
|
221
|
+
if (res?.error) {
|
|
222
|
+
const msg = { msg: ""};
|
|
223
|
+
if (res.error.response?.data?.error) {
|
|
224
|
+
msg.msg = res.error.response.data.error;
|
|
225
|
+
} else if (res.error.message) {
|
|
226
|
+
msg.msg = res.error.message;
|
|
227
|
+
} else if (res.error.response?.data?.errors) {
|
|
228
|
+
const errors = res.error.response.data.errors;
|
|
229
|
+
msg.msg = Object.values(errors)[0][0] || msg.msg;
|
|
230
|
+
}
|
|
231
|
+
if (res?.error?.response?.data?.payload?.message) {
|
|
232
|
+
msg.msg = res.error.response.data.payload.message;
|
|
233
|
+
}
|
|
234
|
+
return res
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
221
239
|
if (res) {
|
|
222
240
|
this[StateStore] = res;
|
|
223
241
|
if (mStore?.mUse) {
|
|
224
|
-
const checkType =
|
|
225
|
-
typeof res === "object" ? JSON.stringify(res) : res;
|
|
242
|
+
const checkType =typeof res === "object" ? JSON.stringify(res) : res;
|
|
226
243
|
sessionStorage.setItem(StateStore, JSON.stringify(checkType));
|
|
227
244
|
}
|
|
228
|
-
|
|
229
245
|
delete this.CheckQueriesInQue[callApi];
|
|
230
246
|
} else {
|
|
231
247
|
delete this.CheckQueriesInQue[callApi];
|
|
@@ -318,7 +334,9 @@ function createPomStore(
|
|
|
318
334
|
if (typeof fasterDataCollection == "function")
|
|
319
335
|
fasterDataCollection?.(StateVariable);
|
|
320
336
|
|
|
337
|
+
console.log({counters,reload,StateStore});
|
|
321
338
|
if (counters > 0) {
|
|
339
|
+
|
|
322
340
|
if (reload) {
|
|
323
341
|
await this.sleep(1000 * time);
|
|
324
342
|
return await this.CallApiData(
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,6 @@ var requestHandler = (request) => {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
request.headers = { ...(request == null ? void 0 : request.headers) ?? {} };
|
|
39
|
-
console.log("default call");
|
|
40
39
|
if (token) request.headers.Authorization = `Bearer ${token}`;
|
|
41
40
|
if (request.data instanceof FormData) {
|
|
42
41
|
const formData = request.data;
|
|
@@ -77,7 +76,6 @@ var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
78
|
const axiosClient = axiosInstance ?? axiosSetUps;
|
|
80
|
-
console.log(axiosInstance);
|
|
81
79
|
try {
|
|
82
80
|
const axiosMethods = {
|
|
83
81
|
get: () => axiosClient.get(`${url}${generateParams(data)}`, headerC),
|
|
@@ -89,7 +87,7 @@ var useFetch = async ({ url, method, data = {}, config, axiosInstance }) => {
|
|
|
89
87
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
90
88
|
}
|
|
91
89
|
const response = await axiosMethods[uniformMethod]();
|
|
92
|
-
if (response == null ? void 0 : response.
|
|
90
|
+
if (response == null ? void 0 : response.data) {
|
|
93
91
|
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
94
92
|
}
|
|
95
93
|
return false;
|
|
@@ -182,9 +180,25 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
182
180
|
return new Promise((r) => setTimeout(r, timer));
|
|
183
181
|
},
|
|
184
182
|
async CallApiData(StateStore, callApi, dataParams, pagnated, mStore = {}, config, axiosInstance = null) {
|
|
183
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
185
184
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
186
185
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
187
186
|
let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
|
|
187
|
+
if (res == null ? void 0 : res.error) {
|
|
188
|
+
const msg = { msg: "", error: true };
|
|
189
|
+
if ((_b = (_a = res.error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
|
|
190
|
+
msg.msg = res.error.response.data.error;
|
|
191
|
+
} else if (res.error.message) {
|
|
192
|
+
msg.msg = res.error.message;
|
|
193
|
+
} else if ((_d = (_c = res.error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.errors) {
|
|
194
|
+
const errors = res.error.response.data.errors;
|
|
195
|
+
msg.msg = Object.values(errors)[0][0] || msg.msg;
|
|
196
|
+
}
|
|
197
|
+
if ((_h = (_g = (_f = (_e = res == null ? void 0 : res.error) == null ? void 0 : _e.response) == null ? void 0 : _f.data) == null ? void 0 : _g.payload) == null ? void 0 : _h.message) {
|
|
198
|
+
msg.msg = res.error.response.data.payload.message;
|
|
199
|
+
}
|
|
200
|
+
return res;
|
|
201
|
+
}
|
|
188
202
|
if (res) {
|
|
189
203
|
this[StateStore] = res;
|
|
190
204
|
if (mStore == null ? void 0 : mStore.mUse) {
|
|
@@ -265,6 +279,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
265
279
|
const counters = this.validateObjectLength(StateVariable);
|
|
266
280
|
if (typeof fasterDataCollection == "function")
|
|
267
281
|
fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
|
|
282
|
+
console.log({ counters, reload, StateStore });
|
|
268
283
|
if (counters > 0) {
|
|
269
284
|
if (reload) {
|
|
270
285
|
await this.sleep(1e3 * time);
|
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.3.
|
|
6
|
+
"version": "1.3.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|