septor-store 1.2.1 → 1.2.3
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 +12 -5
- package/dist/index.d.cts +28 -22
- package/dist/index.d.ts +28 -22
- package/dist/index.js +12 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -128,7 +128,10 @@ var useFetch = async ({ url, method, data = {}, config }) => {
|
|
|
128
128
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
129
129
|
}
|
|
130
130
|
const response = await axiosMethods[uniformMethod]();
|
|
131
|
-
|
|
131
|
+
if (response == null ? void 0 : response.status) {
|
|
132
|
+
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
132
135
|
} catch (err2) {
|
|
133
136
|
console.error(err2);
|
|
134
137
|
return { success: false, error: err2 };
|
|
@@ -175,11 +178,11 @@ function getBearerToken() {
|
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
// src/StoreManager/pomStateManagement.js
|
|
178
|
-
function
|
|
181
|
+
function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
179
182
|
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
180
183
|
const storeId = "POM" + piniaStore;
|
|
181
184
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
182
|
-
|
|
185
|
+
return (0, import_pinia.defineStore)(storeId, {
|
|
183
186
|
state: () => {
|
|
184
187
|
const StateObjectsContainer = {
|
|
185
188
|
CheckQueriesInQue: {},
|
|
@@ -270,6 +273,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
270
273
|
pagnated: false,
|
|
271
274
|
mStore: { mUse: 0, reset: 0 }
|
|
272
275
|
}, fasterDataCollection = null) {
|
|
276
|
+
alert("stateGenaratorApi");
|
|
273
277
|
this.Loading = true;
|
|
274
278
|
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
275
279
|
const callApi = JSON.stringify(reqs);
|
|
@@ -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);
|
|
@@ -345,7 +350,9 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
345
350
|
}
|
|
346
351
|
}
|
|
347
352
|
});
|
|
348
|
-
|
|
353
|
+
}
|
|
354
|
+
function createPomStore() {
|
|
355
|
+
return motherCreatePomStore();
|
|
349
356
|
}
|
|
350
357
|
// Annotate the CommonJS export names for ESM import in node:
|
|
351
358
|
0 && (module.exports = {
|
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
|
-
|
|
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();
|
|
@@ -83,7 +84,11 @@ const useFetch = async ({ url, method, data = {}, config }) => {
|
|
|
83
84
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
84
85
|
}
|
|
85
86
|
const response = await axiosMethods[uniformMethod]();
|
|
86
|
-
|
|
87
|
+
if(response?.status){
|
|
88
|
+
return response?.data ?? response ??{ Empty: "Empty" };
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
|
|
87
92
|
} catch (err) {
|
|
88
93
|
console.error(err);
|
|
89
94
|
return { success: false, error: err };
|
|
@@ -133,14 +138,15 @@ function getBearerToken() {
|
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
function
|
|
141
|
+
function motherCreatePomStore(
|
|
137
142
|
piniaStore = "7286204094",
|
|
138
143
|
callBack = null,
|
|
139
|
-
ds = { StateClean: 0,extenalSetup:null }
|
|
144
|
+
ds = { StateClean: 0, extenalSetup: null },
|
|
145
|
+
) {
|
|
140
146
|
setUpAxiosToUse(ds?.extenalSetup);
|
|
141
147
|
const storeId = "POM" + piniaStore;
|
|
142
148
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
143
|
-
|
|
149
|
+
return defineStore(storeId, {
|
|
144
150
|
state: () => {
|
|
145
151
|
const StateObjectsContainer = {
|
|
146
152
|
CheckQueriesInQue: {},
|
|
@@ -197,16 +203,13 @@ function createPomStore(
|
|
|
197
203
|
dataParams,
|
|
198
204
|
pagnated,
|
|
199
205
|
mStore = {},
|
|
200
|
-
config
|
|
206
|
+
config,
|
|
201
207
|
) {
|
|
202
208
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
203
209
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
204
|
-
// console.log({...dataParams,config});
|
|
205
|
-
// alert()
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
let [res] = await Promise.all([useFetch({...dataParams,config})]);
|
|
209
210
|
|
|
211
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
212
|
+
// const collection=;
|
|
210
213
|
if (res) {
|
|
211
214
|
this[StateStore] = res;
|
|
212
215
|
if (mStore?.mUse) {
|
|
@@ -228,7 +231,7 @@ function createPomStore(
|
|
|
228
231
|
},
|
|
229
232
|
async parseData(
|
|
230
233
|
dataResponseName = "xxx",
|
|
231
|
-
mStore = { mUse: false, reset: false }
|
|
234
|
+
mStore = { mUse: false, reset: false },
|
|
232
235
|
) {
|
|
233
236
|
try {
|
|
234
237
|
if (mStore?.reset) {
|
|
@@ -237,7 +240,7 @@ function createPomStore(
|
|
|
237
240
|
|
|
238
241
|
if (mStore?.mUse) {
|
|
239
242
|
const thisData = JSON.parse(
|
|
240
|
-
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
243
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {}),
|
|
241
244
|
);
|
|
242
245
|
return thisData;
|
|
243
246
|
}
|
|
@@ -265,11 +268,11 @@ function createPomStore(
|
|
|
265
268
|
pagnated: false,
|
|
266
269
|
mStore: { mUse: 0, reset: 0 },
|
|
267
270
|
},
|
|
268
|
-
fasterDataCollection = null
|
|
271
|
+
fasterDataCollection = null,
|
|
269
272
|
) {
|
|
270
|
-
|
|
273
|
+
alert("stateGenaratorApi");
|
|
271
274
|
this.Loading = true;
|
|
272
|
-
const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
|
|
275
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
273
276
|
const callApi = JSON.stringify(reqs);
|
|
274
277
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
275
278
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -297,18 +300,19 @@ function createPomStore(
|
|
|
297
300
|
if (this.CheckQueriesInQue[callApi]) {
|
|
298
301
|
console.warn(
|
|
299
302
|
`************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
|
|
300
|
-
reqs
|
|
303
|
+
reqs,
|
|
301
304
|
);
|
|
302
305
|
return;
|
|
303
306
|
}
|
|
304
307
|
try {
|
|
305
308
|
const counters = this.validateObjectLength(StateVariable);
|
|
309
|
+
|
|
306
310
|
if (typeof fasterDataCollection == "function")
|
|
307
|
-
fasterDataCollection(StateVariable);
|
|
311
|
+
fasterDataCollection?.(StateVariable);
|
|
312
|
+
console.log(counters);
|
|
308
313
|
|
|
309
314
|
if (counters > 0) {
|
|
310
315
|
if (reload) {
|
|
311
|
-
|
|
312
316
|
await this.sleep(1000 * time);
|
|
313
317
|
return await this.CallApiData(
|
|
314
318
|
StateStore,
|
|
@@ -316,7 +320,7 @@ function createPomStore(
|
|
|
316
320
|
reqs,
|
|
317
321
|
pagnated,
|
|
318
322
|
mStore,
|
|
319
|
-
config
|
|
323
|
+
config,
|
|
320
324
|
);
|
|
321
325
|
}
|
|
322
326
|
|
|
@@ -332,7 +336,7 @@ function createPomStore(
|
|
|
332
336
|
reqs,
|
|
333
337
|
pagnated,
|
|
334
338
|
mStore,
|
|
335
|
-
config
|
|
339
|
+
config,
|
|
336
340
|
);
|
|
337
341
|
} catch (error) {
|
|
338
342
|
console.error(error);
|
|
@@ -357,8 +361,10 @@ function createPomStore(
|
|
|
357
361
|
pagenatedData() {},
|
|
358
362
|
},
|
|
359
363
|
});
|
|
364
|
+
}
|
|
360
365
|
|
|
361
|
-
|
|
366
|
+
function createPomStore() {
|
|
367
|
+
return motherCreatePomStore();
|
|
362
368
|
}
|
|
363
369
|
|
|
364
370
|
// module.e = createPomStore
|
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
|
-
|
|
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();
|
|
@@ -83,7 +84,11 @@ const useFetch = async ({ url, method, data = {}, config }) => {
|
|
|
83
84
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
84
85
|
}
|
|
85
86
|
const response = await axiosMethods[uniformMethod]();
|
|
86
|
-
|
|
87
|
+
if(response?.status){
|
|
88
|
+
return response?.data ?? response ??{ Empty: "Empty" };
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
|
|
87
92
|
} catch (err) {
|
|
88
93
|
console.error(err);
|
|
89
94
|
return { success: false, error: err };
|
|
@@ -133,14 +138,15 @@ function getBearerToken() {
|
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
function
|
|
141
|
+
function motherCreatePomStore(
|
|
137
142
|
piniaStore = "7286204094",
|
|
138
143
|
callBack = null,
|
|
139
|
-
ds = { StateClean: 0,extenalSetup:null }
|
|
144
|
+
ds = { StateClean: 0, extenalSetup: null },
|
|
145
|
+
) {
|
|
140
146
|
setUpAxiosToUse(ds?.extenalSetup);
|
|
141
147
|
const storeId = "POM" + piniaStore;
|
|
142
148
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
143
|
-
|
|
149
|
+
return defineStore(storeId, {
|
|
144
150
|
state: () => {
|
|
145
151
|
const StateObjectsContainer = {
|
|
146
152
|
CheckQueriesInQue: {},
|
|
@@ -197,16 +203,13 @@ function createPomStore(
|
|
|
197
203
|
dataParams,
|
|
198
204
|
pagnated,
|
|
199
205
|
mStore = {},
|
|
200
|
-
config
|
|
206
|
+
config,
|
|
201
207
|
) {
|
|
202
208
|
if (!this.CheckQueriesInQue[callApi]) {
|
|
203
209
|
this.CheckQueriesInQue[callApi] = callApi;
|
|
204
|
-
// console.log({...dataParams,config});
|
|
205
|
-
// alert()
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
let [res] = await Promise.all([useFetch({...dataParams,config})]);
|
|
209
210
|
|
|
211
|
+
let [res] = await Promise.all([useFetch({ ...dataParams, config })]);
|
|
212
|
+
// const collection=;
|
|
210
213
|
if (res) {
|
|
211
214
|
this[StateStore] = res;
|
|
212
215
|
if (mStore?.mUse) {
|
|
@@ -228,7 +231,7 @@ function createPomStore(
|
|
|
228
231
|
},
|
|
229
232
|
async parseData(
|
|
230
233
|
dataResponseName = "xxx",
|
|
231
|
-
mStore = { mUse: false, reset: false }
|
|
234
|
+
mStore = { mUse: false, reset: false },
|
|
232
235
|
) {
|
|
233
236
|
try {
|
|
234
237
|
if (mStore?.reset) {
|
|
@@ -237,7 +240,7 @@ function createPomStore(
|
|
|
237
240
|
|
|
238
241
|
if (mStore?.mUse) {
|
|
239
242
|
const thisData = JSON.parse(
|
|
240
|
-
JSON.parse(sessionStorage.getItem(dataResponseName) || {})
|
|
243
|
+
JSON.parse(sessionStorage.getItem(dataResponseName) || {}),
|
|
241
244
|
);
|
|
242
245
|
return thisData;
|
|
243
246
|
}
|
|
@@ -265,11 +268,11 @@ function createPomStore(
|
|
|
265
268
|
pagnated: false,
|
|
266
269
|
mStore: { mUse: 0, reset: 0 },
|
|
267
270
|
},
|
|
268
|
-
fasterDataCollection = null
|
|
271
|
+
fasterDataCollection = null,
|
|
269
272
|
) {
|
|
270
|
-
|
|
273
|
+
alert("stateGenaratorApi");
|
|
271
274
|
this.Loading = true;
|
|
272
|
-
const { reload, StateStore, reqs, time, pagnated, mStore,config } = dd;
|
|
275
|
+
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
273
276
|
const callApi = JSON.stringify(reqs);
|
|
274
277
|
const StateVariable = await this.parseData(StateStore, mStore);
|
|
275
278
|
this[StateStore] = StateVariable ?? [];
|
|
@@ -297,18 +300,19 @@ function createPomStore(
|
|
|
297
300
|
if (this.CheckQueriesInQue[callApi]) {
|
|
298
301
|
console.warn(
|
|
299
302
|
`************************************* dont call this api again ${reqs["url"]} 🛩️ *************************************`,
|
|
300
|
-
reqs
|
|
303
|
+
reqs,
|
|
301
304
|
);
|
|
302
305
|
return;
|
|
303
306
|
}
|
|
304
307
|
try {
|
|
305
308
|
const counters = this.validateObjectLength(StateVariable);
|
|
309
|
+
|
|
306
310
|
if (typeof fasterDataCollection == "function")
|
|
307
|
-
fasterDataCollection(StateVariable);
|
|
311
|
+
fasterDataCollection?.(StateVariable);
|
|
312
|
+
console.log(counters);
|
|
308
313
|
|
|
309
314
|
if (counters > 0) {
|
|
310
315
|
if (reload) {
|
|
311
|
-
|
|
312
316
|
await this.sleep(1000 * time);
|
|
313
317
|
return await this.CallApiData(
|
|
314
318
|
StateStore,
|
|
@@ -316,7 +320,7 @@ function createPomStore(
|
|
|
316
320
|
reqs,
|
|
317
321
|
pagnated,
|
|
318
322
|
mStore,
|
|
319
|
-
config
|
|
323
|
+
config,
|
|
320
324
|
);
|
|
321
325
|
}
|
|
322
326
|
|
|
@@ -332,7 +336,7 @@ function createPomStore(
|
|
|
332
336
|
reqs,
|
|
333
337
|
pagnated,
|
|
334
338
|
mStore,
|
|
335
|
-
config
|
|
339
|
+
config,
|
|
336
340
|
);
|
|
337
341
|
} catch (error) {
|
|
338
342
|
console.error(error);
|
|
@@ -357,8 +361,10 @@ function createPomStore(
|
|
|
357
361
|
pagenatedData() {},
|
|
358
362
|
},
|
|
359
363
|
});
|
|
364
|
+
}
|
|
360
365
|
|
|
361
|
-
|
|
366
|
+
function createPomStore() {
|
|
367
|
+
return motherCreatePomStore();
|
|
362
368
|
}
|
|
363
369
|
|
|
364
370
|
// module.e = createPomStore
|
package/dist/index.js
CHANGED
|
@@ -87,7 +87,10 @@ var useFetch = async ({ url, method, data = {}, config }) => {
|
|
|
87
87
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
88
88
|
}
|
|
89
89
|
const response = await axiosMethods[uniformMethod]();
|
|
90
|
-
|
|
90
|
+
if (response == null ? void 0 : response.status) {
|
|
91
|
+
return (response == null ? void 0 : response.data) ?? response ?? { Empty: "Empty" };
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
91
94
|
} catch (err2) {
|
|
92
95
|
console.error(err2);
|
|
93
96
|
return { success: false, error: err2 };
|
|
@@ -134,11 +137,11 @@ function getBearerToken() {
|
|
|
134
137
|
}
|
|
135
138
|
|
|
136
139
|
// src/StoreManager/pomStateManagement.js
|
|
137
|
-
function
|
|
140
|
+
function motherCreatePomStore(piniaStore = "7286204094", callBack = null, ds = { StateClean: 0, extenalSetup: null }) {
|
|
138
141
|
setUpAxiosToUse(ds == null ? void 0 : ds.extenalSetup);
|
|
139
142
|
const storeId = "POM" + piniaStore;
|
|
140
143
|
const StateNameUsedSoferList = "septor-store-collection";
|
|
141
|
-
|
|
144
|
+
return defineStore(storeId, {
|
|
142
145
|
state: () => {
|
|
143
146
|
const StateObjectsContainer = {
|
|
144
147
|
CheckQueriesInQue: {},
|
|
@@ -229,6 +232,7 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
229
232
|
pagnated: false,
|
|
230
233
|
mStore: { mUse: 0, reset: 0 }
|
|
231
234
|
}, fasterDataCollection = null) {
|
|
235
|
+
alert("stateGenaratorApi");
|
|
232
236
|
this.Loading = true;
|
|
233
237
|
const { reload, StateStore, reqs, time, pagnated, mStore, config } = dd;
|
|
234
238
|
const callApi = JSON.stringify(reqs);
|
|
@@ -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);
|
|
@@ -304,7 +309,9 @@ function createPomStore(piniaStore = "7286204094", callBack = null, ds = { State
|
|
|
304
309
|
}
|
|
305
310
|
}
|
|
306
311
|
});
|
|
307
|
-
|
|
312
|
+
}
|
|
313
|
+
function createPomStore() {
|
|
314
|
+
return motherCreatePomStore();
|
|
308
315
|
}
|
|
309
316
|
export {
|
|
310
317
|
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.2.
|
|
6
|
+
"version": "1.2.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|