septor-store 1.3.4 → 1.3.6

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 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
- We welcome all contributions and feedback to improve septor-store!
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
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](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.status) {
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,29 @@ 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
- let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
227
+ let [res] = await Promise.all([
228
+ useFetch({ ...dataParams, config, axiosInstance })
229
+ ]);
230
+ if (res == null ? void 0 : res.error) {
231
+ const msg = { msg: "", error: true };
232
+ if ((_b = (_a = res.error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
233
+ msg.msg = res.error.response.data.error;
234
+ } else if (res.error.message) {
235
+ msg.msg = res.error.message;
236
+ } else if ((_d = (_c = res.error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.errors) {
237
+ const errors = res.error.response.data.errors;
238
+ msg.msg = Object.values(errors)[0][0] || msg.msg;
239
+ }
240
+ 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) {
241
+ msg.msg = res.error.response.data.payload.message;
242
+ }
243
+ delete this.CheckQueriesInQue[callApi];
244
+ console.error(msg);
245
+ return res;
246
+ }
229
247
  if (res) {
230
248
  this[StateStore] = res;
231
249
  if (mStore == null ? void 0 : mStore.mUse) {
@@ -277,7 +295,16 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
277
295
  axiosInstance: null
278
296
  }, fasterDataCollection = null) {
279
297
  this.Loading = true;
280
- const { reload, StateStore, reqs, time, pagnated, mStore, config, axiosInstance } = dd;
298
+ const {
299
+ reload,
300
+ StateStore,
301
+ reqs,
302
+ time,
303
+ pagnated,
304
+ mStore,
305
+ config,
306
+ axiosInstance
307
+ } = dd;
281
308
  const callApi = JSON.stringify(reqs);
282
309
  const StateVariable = await this.parseData(StateStore, mStore);
283
310
  this[StateStore] = StateVariable ?? [];
@@ -297,7 +324,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
297
324
  }
298
325
  if (this.CheckQueriesInQue[callApi]) {
299
326
  console.warn(
300
- `************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
327
+ `************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
301
328
  reqs
302
329
  );
303
330
  return;
@@ -306,6 +333,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
306
333
  const counters = this.validateObjectLength(StateVariable);
307
334
  if (typeof fasterDataCollection == "function")
308
335
  fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
336
+ console.log({ counters, reload, StateStore });
309
337
  if (counters > 0) {
310
338
  if (reload) {
311
339
  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(axiosInstance);
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?.status){
94
+ if(response?.data){
95
+ // if(response?.status){
96
96
  return response?.data ?? response ??{ Empty: "Empty" };
97
97
  }
98
98
  return false
@@ -216,8 +216,29 @@ function createPomStore(
216
216
  ) {
217
217
  if (!this.CheckQueriesInQue[callApi]) {
218
218
  this.CheckQueriesInQue[callApi] = callApi;
219
- let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
219
+ let [res] = await Promise.all([
220
+ useFetch({ ...dataParams, config, axiosInstance }),
221
+ ]);
220
222
  // const collection=;
223
+ if (res?.error) {
224
+ const msg = { msg: "", error: true };
225
+ if (res.error.response?.data?.error) {
226
+ msg.msg = res.error.response.data.error;
227
+ } else if (res.error.message) {
228
+ msg.msg = res.error.message;
229
+ } else if (res.error.response?.data?.errors) {
230
+ const errors = res.error.response.data.errors;
231
+ msg.msg = Object.values(errors)[0][0] || msg.msg;
232
+ }
233
+ if (res?.error?.response?.data?.payload?.message) {
234
+ msg.msg = res.error.response.data.payload.message;
235
+ }
236
+ delete this.CheckQueriesInQue[callApi];
237
+ console.error(msg);
238
+
239
+ return res;
240
+ }
241
+
221
242
  if (res) {
222
243
  this[StateStore] = res;
223
244
  if (mStore?.mUse) {
@@ -225,7 +246,6 @@ function createPomStore(
225
246
  typeof res === "object" ? JSON.stringify(res) : res;
226
247
  sessionStorage.setItem(StateStore, JSON.stringify(checkType));
227
248
  }
228
-
229
249
  delete this.CheckQueriesInQue[callApi];
230
250
  } else {
231
251
  delete this.CheckQueriesInQue[callApi];
@@ -275,12 +295,21 @@ function createPomStore(
275
295
  time: 0,
276
296
  pagnated: false,
277
297
  mStore: { mUse: 0, reset: 0 },
278
- axiosInstance : null,
298
+ axiosInstance: null,
279
299
  },
280
300
  fasterDataCollection = null,
281
301
  ) {
282
302
  this.Loading = true;
283
- const { reload, StateStore, reqs, time, pagnated, mStore, config,axiosInstance } = dd;
303
+ const {
304
+ reload,
305
+ StateStore,
306
+ reqs,
307
+ time,
308
+ pagnated,
309
+ mStore,
310
+ config,
311
+ axiosInstance,
312
+ } = dd;
284
313
  const callApi = JSON.stringify(reqs);
285
314
  const StateVariable = await this.parseData(StateStore, mStore);
286
315
  this[StateStore] = StateVariable ?? [];
@@ -307,7 +336,7 @@ function createPomStore(
307
336
 
308
337
  if (this.CheckQueriesInQue[callApi]) {
309
338
  console.warn(
310
- `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
339
+ `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
311
340
  reqs,
312
341
  );
313
342
  return;
@@ -318,6 +347,7 @@ function createPomStore(
318
347
  if (typeof fasterDataCollection == "function")
319
348
  fasterDataCollection?.(StateVariable);
320
349
 
350
+ console.log({ counters, reload, StateStore });
321
351
  if (counters > 0) {
322
352
  if (reload) {
323
353
  await this.sleep(1000 * time);
@@ -345,7 +375,7 @@ function createPomStore(
345
375
  pagnated,
346
376
  mStore,
347
377
  config,
348
- axiosInstance
378
+ axiosInstance,
349
379
  );
350
380
  } catch (error) {
351
381
  console.error(error);
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(axiosInstance);
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?.status){
94
+ if(response?.data){
95
+ // if(response?.status){
96
96
  return response?.data ?? response ??{ Empty: "Empty" };
97
97
  }
98
98
  return false
@@ -216,8 +216,29 @@ function createPomStore(
216
216
  ) {
217
217
  if (!this.CheckQueriesInQue[callApi]) {
218
218
  this.CheckQueriesInQue[callApi] = callApi;
219
- let [res] = await Promise.all([useFetch({ ...dataParams, config,axiosInstance })]);
219
+ let [res] = await Promise.all([
220
+ useFetch({ ...dataParams, config, axiosInstance }),
221
+ ]);
220
222
  // const collection=;
223
+ if (res?.error) {
224
+ const msg = { msg: "", error: true };
225
+ if (res.error.response?.data?.error) {
226
+ msg.msg = res.error.response.data.error;
227
+ } else if (res.error.message) {
228
+ msg.msg = res.error.message;
229
+ } else if (res.error.response?.data?.errors) {
230
+ const errors = res.error.response.data.errors;
231
+ msg.msg = Object.values(errors)[0][0] || msg.msg;
232
+ }
233
+ if (res?.error?.response?.data?.payload?.message) {
234
+ msg.msg = res.error.response.data.payload.message;
235
+ }
236
+ delete this.CheckQueriesInQue[callApi];
237
+ console.error(msg);
238
+
239
+ return res;
240
+ }
241
+
221
242
  if (res) {
222
243
  this[StateStore] = res;
223
244
  if (mStore?.mUse) {
@@ -225,7 +246,6 @@ function createPomStore(
225
246
  typeof res === "object" ? JSON.stringify(res) : res;
226
247
  sessionStorage.setItem(StateStore, JSON.stringify(checkType));
227
248
  }
228
-
229
249
  delete this.CheckQueriesInQue[callApi];
230
250
  } else {
231
251
  delete this.CheckQueriesInQue[callApi];
@@ -275,12 +295,21 @@ function createPomStore(
275
295
  time: 0,
276
296
  pagnated: false,
277
297
  mStore: { mUse: 0, reset: 0 },
278
- axiosInstance : null,
298
+ axiosInstance: null,
279
299
  },
280
300
  fasterDataCollection = null,
281
301
  ) {
282
302
  this.Loading = true;
283
- const { reload, StateStore, reqs, time, pagnated, mStore, config,axiosInstance } = dd;
303
+ const {
304
+ reload,
305
+ StateStore,
306
+ reqs,
307
+ time,
308
+ pagnated,
309
+ mStore,
310
+ config,
311
+ axiosInstance,
312
+ } = dd;
284
313
  const callApi = JSON.stringify(reqs);
285
314
  const StateVariable = await this.parseData(StateStore, mStore);
286
315
  this[StateStore] = StateVariable ?? [];
@@ -307,7 +336,7 @@ function createPomStore(
307
336
 
308
337
  if (this.CheckQueriesInQue[callApi]) {
309
338
  console.warn(
310
- `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
339
+ `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
311
340
  reqs,
312
341
  );
313
342
  return;
@@ -318,6 +347,7 @@ function createPomStore(
318
347
  if (typeof fasterDataCollection == "function")
319
348
  fasterDataCollection?.(StateVariable);
320
349
 
350
+ console.log({ counters, reload, StateStore });
321
351
  if (counters > 0) {
322
352
  if (reload) {
323
353
  await this.sleep(1000 * time);
@@ -345,7 +375,7 @@ function createPomStore(
345
375
  pagnated,
346
376
  mStore,
347
377
  config,
348
- axiosInstance
378
+ axiosInstance,
349
379
  );
350
380
  } catch (error) {
351
381
  console.error(error);
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.status) {
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,29 @@ 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
- let [res] = await Promise.all([useFetch({ ...dataParams, config, axiosInstance })]);
186
+ let [res] = await Promise.all([
187
+ useFetch({ ...dataParams, config, axiosInstance })
188
+ ]);
189
+ if (res == null ? void 0 : res.error) {
190
+ const msg = { msg: "", error: true };
191
+ if ((_b = (_a = res.error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.error) {
192
+ msg.msg = res.error.response.data.error;
193
+ } else if (res.error.message) {
194
+ msg.msg = res.error.message;
195
+ } else if ((_d = (_c = res.error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.errors) {
196
+ const errors = res.error.response.data.errors;
197
+ msg.msg = Object.values(errors)[0][0] || msg.msg;
198
+ }
199
+ 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) {
200
+ msg.msg = res.error.response.data.payload.message;
201
+ }
202
+ delete this.CheckQueriesInQue[callApi];
203
+ console.error(msg);
204
+ return res;
205
+ }
188
206
  if (res) {
189
207
  this[StateStore] = res;
190
208
  if (mStore == null ? void 0 : mStore.mUse) {
@@ -236,7 +254,16 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
236
254
  axiosInstance: null
237
255
  }, fasterDataCollection = null) {
238
256
  this.Loading = true;
239
- const { reload, StateStore, reqs, time, pagnated, mStore, config, axiosInstance } = dd;
257
+ const {
258
+ reload,
259
+ StateStore,
260
+ reqs,
261
+ time,
262
+ pagnated,
263
+ mStore,
264
+ config,
265
+ axiosInstance
266
+ } = dd;
240
267
  const callApi = JSON.stringify(reqs);
241
268
  const StateVariable = await this.parseData(StateStore, mStore);
242
269
  this[StateStore] = StateVariable ?? [];
@@ -256,7 +283,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
256
283
  }
257
284
  if (this.CheckQueriesInQue[callApi]) {
258
285
  console.warn(
259
- `************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
286
+ `************************************* dont call this api again ${reqs["url"]} \u{1F6E9}\uFE0F *************************************`,
260
287
  reqs
261
288
  );
262
289
  return;
@@ -265,6 +292,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
265
292
  const counters = this.validateObjectLength(StateVariable);
266
293
  if (typeof fasterDataCollection == "function")
267
294
  fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
295
+ console.log({ counters, reload, StateStore });
268
296
  if (counters > 0) {
269
297
  if (reload) {
270
298
  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.4",
6
+ "version": "1.3.6",
7
7
  "type": "module",
8
8
  "main": "dist/index.cjs",
9
9
  "module": "dist/index.js",