septor-store 1.2.2 → 1.2.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 CHANGED
@@ -110,7 +110,8 @@ function setUpAxiosToUse(setUp) {
110
110
  axiosSetUps = setUp ?? custom_axios_default;
111
111
  }
112
112
  var useFetch = async ({ url, method, data = {}, config }) => {
113
- const uniformMethod = method.toLowerCase();
113
+ console.log(method, "------");
114
+ const uniformMethod = `${method}`.toLowerCase();
114
115
  const headerC = {
115
116
  ...config,
116
117
  headers: {
@@ -128,7 +129,10 @@ var useFetch = async ({ url, method, data = {}, config }) => {
128
129
  throw new Error(`Unsupported HTTP method: ${method}`);
129
130
  }
130
131
  const response = await axiosMethods[uniformMethod]();
131
- return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
132
+ if (response == null ? void 0 : response.status) {
133
+ return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
134
+ }
135
+ return false;
132
136
  } catch (err2) {
133
137
  console.error(err2);
134
138
  return { success: false, error: err2 };
@@ -299,7 +303,8 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
299
303
  try {
300
304
  const counters = this.validateObjectLength(StateVariable);
301
305
  if (typeof fasterDataCollection == "function")
302
- fasterDataCollection(StateVariable);
306
+ fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
307
+ console.log(counters);
303
308
  if (counters > 0) {
304
309
  if (reload) {
305
310
  await this.sleep(1e3 * time);
package/dist/index.d.cts CHANGED
@@ -4,13 +4,14 @@ import axios from 'axios';
4
4
  const AbortHandler = {
5
5
  abortController: new AbortController()};
6
6
 
7
- const baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
7
+ let baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
8
8
 
9
9
  const customAxios = axios.create({
10
10
  baseURL: baseURL,
11
11
  signal: AbortHandler.abortController.signal, // Signal that is assiciated with any request to be made with this axios instance
12
12
  });
13
13
 
14
+
14
15
  // Request Interceptor
15
16
  const requestHandler = (request) => {
16
17
  const tokenData = getBearerToken();
@@ -63,7 +64,9 @@ function setUpAxiosToUse(setUp) {
63
64
  axiosSetUps = setUp??customAxios;
64
65
  }
65
66
  const useFetch = async ({ url, method, data = {}, config }) => {
66
- const uniformMethod = method.toLowerCase();
67
+ console.log(method,'------');
68
+
69
+ const uniformMethod = `${method}`.toLowerCase();
67
70
  const headerC = {
68
71
  ...config,
69
72
  headers: {
@@ -83,7 +86,11 @@ const useFetch = async ({ url, method, data = {}, config }) => {
83
86
  throw new Error(`Unsupported HTTP method: ${method}`);
84
87
  }
85
88
  const response = await axiosMethods[uniformMethod]();
86
- return response?.data ?? response ??{ Empty: "Empty" };
89
+ if(response?.status){
90
+ return response?.data ?? response ??{ Empty: "Empty" };
91
+ }
92
+ return false
93
+
87
94
  } catch (err) {
88
95
  console.error(err);
89
96
  return { success: false, error: err };
@@ -133,14 +140,15 @@ function getBearerToken() {
133
140
  }
134
141
  }
135
142
 
136
- function createPomStore(
143
+ function createPomStore(
137
144
  piniaStore = "7286204094",
138
145
  callBack = null,
139
- ds = { StateClean: 0,extenalSetup:null }) {
146
+ ds = { StateClean: 0, extenalSetup: null },
147
+ ) {
140
148
  setUpAxiosToUse(ds?.extenalSetup);
141
149
  const storeId = "POM" + piniaStore;
142
150
  const StateNameUsedSoferList = "septor-store-collection";
143
- const piniaData = defineStore(storeId, {
151
+ const piniaData= defineStore(storeId, {
144
152
  state: () => {
145
153
  const StateObjectsContainer = {
146
154
  CheckQueriesInQue: {},
@@ -197,16 +205,13 @@ function createPomStore(
197
205
  dataParams,
198
206
  pagnated,
199
207
  mStore = {},
200
- config
208
+ config,
201
209
  ) {
202
210
  if (!this.CheckQueriesInQue[callApi]) {
203
211
  this.CheckQueriesInQue[callApi] = callApi;
204
- // console.log({...dataParams,config});
205
- // alert()
206
-
207
-
208
- let [res] = await Promise.all([useFetch({...dataParams,config})]);
209
212
 
213
+ let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
214
+ // const collection=;
210
215
  if (res) {
211
216
  this[StateStore] = res;
212
217
  if (mStore?.mUse) {
@@ -228,7 +233,7 @@ function createPomStore(
228
233
  },
229
234
  async parseData(
230
235
  dataResponseName = "xxx",
231
- mStore = { mUse: false, reset: false }
236
+ mStore = { mUse: false, reset: false },
232
237
  ) {
233
238
  try {
234
239
  if (mStore?.reset) {
@@ -237,7 +242,7 @@ function createPomStore(
237
242
 
238
243
  if (mStore?.mUse) {
239
244
  const thisData = JSON.parse(
240
- JSON.parse(sessionStorage.getItem(dataResponseName) || {})
245
+ JSON.parse(sessionStorage.getItem(dataResponseName) || {}),
241
246
  );
242
247
  return thisData;
243
248
  }
@@ -265,11 +270,10 @@ function createPomStore(
265
270
  pagnated: false,
266
271
  mStore: { mUse: 0, reset: 0 },
267
272
  },
268
- fasterDataCollection = null
273
+ fasterDataCollection = null,
269
274
  ) {
270
-
271
275
  this.Loading = true;
272
- const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
276
+ const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
273
277
  const callApi = JSON.stringify(reqs);
274
278
  const StateVariable = await this.parseData(StateStore, mStore);
275
279
  this[StateStore] = StateVariable ?? [];
@@ -297,18 +301,19 @@ function createPomStore(
297
301
  if (this.CheckQueriesInQue[callApi]) {
298
302
  console.warn(
299
303
  `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
300
- reqs
304
+ reqs,
301
305
  );
302
306
  return;
303
307
  }
304
308
  try {
305
309
  const counters = this.validateObjectLength(StateVariable);
310
+
306
311
  if (typeof fasterDataCollection == "function")
307
- fasterDataCollection(StateVariable);
312
+ fasterDataCollection?.(StateVariable);
313
+ console.log(counters);
308
314
 
309
315
  if (counters > 0) {
310
316
  if (reload) {
311
-
312
317
  await this.sleep(1000 * time);
313
318
  return await this.CallApiData(
314
319
  StateStore,
@@ -316,8 +321,8 @@ function createPomStore(
316
321
  reqs,
317
322
  pagnated,
318
323
  mStore,
319
- config
320
- );
324
+ config,
325
+ );
321
326
  }
322
327
 
323
328
  this.Loading = false;
@@ -332,7 +337,7 @@ function createPomStore(
332
337
  reqs,
333
338
  pagnated,
334
339
  mStore,
335
- config
340
+ config,
336
341
  );
337
342
  } catch (error) {
338
343
  console.error(error);
@@ -357,10 +362,13 @@ function createPomStore(
357
362
  pagenatedData() {},
358
363
  },
359
364
  });
360
-
361
365
  return piniaData();
362
366
  }
363
367
 
368
+ // export default function createPomStore() {
369
+ // return motherCreatePomStore();
370
+ // }
371
+
364
372
  // module.e = createPomStore
365
373
 
366
374
  export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, setUpAxiosToUse, useFetch };
package/dist/index.d.ts CHANGED
@@ -4,13 +4,14 @@ import axios from 'axios';
4
4
  const AbortHandler = {
5
5
  abortController: new AbortController()};
6
6
 
7
- const baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
7
+ let baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
8
8
 
9
9
  const customAxios = axios.create({
10
10
  baseURL: baseURL,
11
11
  signal: AbortHandler.abortController.signal, // Signal that is assiciated with any request to be made with this axios instance
12
12
  });
13
13
 
14
+
14
15
  // Request Interceptor
15
16
  const requestHandler = (request) => {
16
17
  const tokenData = getBearerToken();
@@ -63,7 +64,9 @@ function setUpAxiosToUse(setUp) {
63
64
  axiosSetUps = setUp??customAxios;
64
65
  }
65
66
  const useFetch = async ({ url, method, data = {}, config }) => {
66
- const uniformMethod = method.toLowerCase();
67
+ console.log(method,'------');
68
+
69
+ const uniformMethod = `${method}`.toLowerCase();
67
70
  const headerC = {
68
71
  ...config,
69
72
  headers: {
@@ -83,7 +86,11 @@ const useFetch = async ({ url, method, data = {}, config }) => {
83
86
  throw new Error(`Unsupported HTTP method: ${method}`);
84
87
  }
85
88
  const response = await axiosMethods[uniformMethod]();
86
- return response?.data ?? response ??{ Empty: "Empty" };
89
+ if(response?.status){
90
+ return response?.data ?? response ??{ Empty: "Empty" };
91
+ }
92
+ return false
93
+
87
94
  } catch (err) {
88
95
  console.error(err);
89
96
  return { success: false, error: err };
@@ -133,14 +140,15 @@ function getBearerToken() {
133
140
  }
134
141
  }
135
142
 
136
- function createPomStore(
143
+ function createPomStore(
137
144
  piniaStore = "7286204094",
138
145
  callBack = null,
139
- ds = { StateClean: 0,extenalSetup:null }) {
146
+ ds = { StateClean: 0, extenalSetup: null },
147
+ ) {
140
148
  setUpAxiosToUse(ds?.extenalSetup);
141
149
  const storeId = "POM" + piniaStore;
142
150
  const StateNameUsedSoferList = "septor-store-collection";
143
- const piniaData = defineStore(storeId, {
151
+ const piniaData= defineStore(storeId, {
144
152
  state: () => {
145
153
  const StateObjectsContainer = {
146
154
  CheckQueriesInQue: {},
@@ -197,16 +205,13 @@ function createPomStore(
197
205
  dataParams,
198
206
  pagnated,
199
207
  mStore = {},
200
- config
208
+ config,
201
209
  ) {
202
210
  if (!this.CheckQueriesInQue[callApi]) {
203
211
  this.CheckQueriesInQue[callApi] = callApi;
204
- // console.log({...dataParams,config});
205
- // alert()
206
-
207
-
208
- let [res] = await Promise.all([useFetch({...dataParams,config})]);
209
212
 
213
+ let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
214
+ // const collection=;
210
215
  if (res) {
211
216
  this[StateStore] = res;
212
217
  if (mStore?.mUse) {
@@ -228,7 +233,7 @@ function createPomStore(
228
233
  },
229
234
  async parseData(
230
235
  dataResponseName = "xxx",
231
- mStore = { mUse: false, reset: false }
236
+ mStore = { mUse: false, reset: false },
232
237
  ) {
233
238
  try {
234
239
  if (mStore?.reset) {
@@ -237,7 +242,7 @@ function createPomStore(
237
242
 
238
243
  if (mStore?.mUse) {
239
244
  const thisData = JSON.parse(
240
- JSON.parse(sessionStorage.getItem(dataResponseName) || {})
245
+ JSON.parse(sessionStorage.getItem(dataResponseName) || {}),
241
246
  );
242
247
  return thisData;
243
248
  }
@@ -265,11 +270,10 @@ function createPomStore(
265
270
  pagnated: false,
266
271
  mStore: { mUse: 0, reset: 0 },
267
272
  },
268
- fasterDataCollection = null
273
+ fasterDataCollection = null,
269
274
  ) {
270
-
271
275
  this.Loading = true;
272
- const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
276
+ const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
273
277
  const callApi = JSON.stringify(reqs);
274
278
  const StateVariable = await this.parseData(StateStore, mStore);
275
279
  this[StateStore] = StateVariable ?? [];
@@ -297,18 +301,19 @@ function createPomStore(
297
301
  if (this.CheckQueriesInQue[callApi]) {
298
302
  console.warn(
299
303
  `************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
300
- reqs
304
+ reqs,
301
305
  );
302
306
  return;
303
307
  }
304
308
  try {
305
309
  const counters = this.validateObjectLength(StateVariable);
310
+
306
311
  if (typeof fasterDataCollection == "function")
307
- fasterDataCollection(StateVariable);
312
+ fasterDataCollection?.(StateVariable);
313
+ console.log(counters);
308
314
 
309
315
  if (counters > 0) {
310
316
  if (reload) {
311
-
312
317
  await this.sleep(1000 * time);
313
318
  return await this.CallApiData(
314
319
  StateStore,
@@ -316,8 +321,8 @@ function createPomStore(
316
321
  reqs,
317
322
  pagnated,
318
323
  mStore,
319
- config
320
- );
324
+ config,
325
+ );
321
326
  }
322
327
 
323
328
  this.Loading = false;
@@ -332,7 +337,7 @@ function createPomStore(
332
337
  reqs,
333
338
  pagnated,
334
339
  mStore,
335
- config
340
+ config,
336
341
  );
337
342
  } catch (error) {
338
343
  console.error(error);
@@ -357,10 +362,13 @@ function createPomStore(
357
362
  pagenatedData() {},
358
363
  },
359
364
  });
360
-
361
365
  return piniaData();
362
366
  }
363
367
 
368
+ // export default function createPomStore() {
369
+ // return motherCreatePomStore();
370
+ // }
371
+
364
372
  // module.e = createPomStore
365
373
 
366
374
  export { generateParams, getBearerToken, createPomStore as pomPinia, setBearerToken, setUpAxiosToUse, useFetch };
package/dist/index.js CHANGED
@@ -69,7 +69,8 @@ function setUpAxiosToUse(setUp) {
69
69
  axiosSetUps = setUp ?? custom_axios_default;
70
70
  }
71
71
  var useFetch = async ({ url, method, data = {}, config }) => {
72
- const uniformMethod = method.toLowerCase();
72
+ console.log(method, "------");
73
+ const uniformMethod = `${method}`.toLowerCase();
73
74
  const headerC = {
74
75
  ...config,
75
76
  headers: {
@@ -87,7 +88,10 @@ var useFetch = async ({ url, method, data = {}, config }) => {
87
88
  throw new Error(`Unsupported HTTP method: ${method}`);
88
89
  }
89
90
  const response = await axiosMethods[uniformMethod]();
90
- return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
91
+ if (response == null ? void 0 : response.status) {
92
+ return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
93
+ }
94
+ return false;
91
95
  } catch (err2) {
92
96
  console.error(err2);
93
97
  return { success: false, error: err2 };
@@ -258,7 +262,8 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
258
262
  try {
259
263
  const counters = this.validateObjectLength(StateVariable);
260
264
  if (typeof fasterDataCollection == "function")
261
- fasterDataCollection(StateVariable);
265
+ fasterDataCollection == null ? void 0 : fasterDataCollection(StateVariable);
266
+ console.log(counters);
262
267
  if (counters > 0) {
263
268
  if (reload) {
264
269
  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.2.2",
6
+ "version": "1.2.4",
7
7
  "type": "module",
8
8
  "main": "dist/index.cjs",
9
9
  "module": "dist/index.js",