septor-store 0.0.5 → 0.0.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 +4 -2
- package/dist/index.cjs +20 -19
- package/dist/index.d.cts +22 -25
- package/dist/index.d.ts +22 -25
- package/dist/index.js +20 -19
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
# septor-store
|
|
9
9
|
|
|
10
|
-
Description (Full)
|
|
11
10
|
septor-store is a structured and scalable state management solution built on top of Pinia for Vue 3. It embraces the Plain Old Module (POM) pattern to simplify how developers—junior or senior—write, organize, and scale their application state. Whether you're just starting out or architecting large Vue applications, this tool helps you keep your stores clean, predictable, and easy to maintain.
|
|
12
11
|
|
|
13
12
|
### Features
|
|
@@ -262,9 +261,12 @@ const handleSubmit = async () => {
|
|
|
262
261
|
const res = await store.stateGenaratorApi(config, (oldData) => {
|
|
263
262
|
console.log('Previous post result if any:', oldData)
|
|
264
263
|
})
|
|
265
|
-
|
|
266
264
|
result.value = res
|
|
267
265
|
}
|
|
268
266
|
</script>
|
|
269
267
|
|
|
270
268
|
```
|
|
269
|
+
If you find this package useful, consider supporting me:
|
|
270
|
+
|
|
271
|
+
[](https://ko-fi.com/ssengendonazil)
|
|
272
|
+
|
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ var abortHandler_default = AbortHandler;
|
|
|
56
56
|
|
|
57
57
|
// src/utils/custom-axios.js
|
|
58
58
|
var import_meta = {};
|
|
59
|
-
var baseURL = typeof import_meta !== "undefined" ? import_meta.env.VITE_BACKEND_URL ?? "" :
|
|
59
|
+
var baseURL = typeof import_meta !== "undefined" ? import_meta.env.VITE_BACKEND_URL ?? "" : "";
|
|
60
60
|
var customAxios = import_axios.default.create({
|
|
61
61
|
baseURL,
|
|
62
62
|
signal: abortHandler_default.abortController.signal
|
|
@@ -112,32 +112,35 @@ var useFetch = async ({ url, method, data }) => {
|
|
|
112
112
|
if (uniformMethod === "get") {
|
|
113
113
|
const params = generateParams(_data ?? {});
|
|
114
114
|
response = await custom_axios_default.get(`${url}${params}`);
|
|
115
|
-
} else
|
|
115
|
+
} else
|
|
116
116
|
response = await custom_axios_default.post(url, _data);
|
|
117
|
-
}
|
|
118
117
|
return (response == null ? void 0 : response.data) ?? { Empty: "Empty" };
|
|
119
|
-
} catch (
|
|
120
|
-
console.error(
|
|
121
|
-
return { success: false, error:
|
|
118
|
+
} catch (err2) {
|
|
119
|
+
console.error(err2);
|
|
120
|
+
return { success: false, error: err2 };
|
|
122
121
|
}
|
|
123
122
|
};
|
|
124
123
|
var generateParams = (params = {}) => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (params
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
try {
|
|
125
|
+
let data = "?";
|
|
126
|
+
for (let key in params) {
|
|
127
|
+
if (Object.hasOwnProperty.call(params, key)) {
|
|
128
|
+
if (params[key]) {
|
|
129
|
+
if (Array.isArray(params[key])) {
|
|
130
|
+
const elements = params[key];
|
|
131
|
+
for (const ele of elements) {
|
|
132
|
+
data += `${key}[]=${ele}&`;
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
data += `${key}=${params[key]}&`;
|
|
133
136
|
}
|
|
134
|
-
} else {
|
|
135
|
-
data += `${key}=${params[key]}&`;
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|
|
140
|
+
return data.slice(0, -1);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error(err);
|
|
139
143
|
}
|
|
140
|
-
return data.slice(0, -1);
|
|
141
144
|
};
|
|
142
145
|
function setBearerToken(name = { token: null }) {
|
|
143
146
|
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
@@ -172,8 +175,6 @@ function createPomStore(piniaStore = "7286204094", callBack = null) {
|
|
|
172
175
|
stateItems: (state) => (TagetState) => {
|
|
173
176
|
return state[TagetState] = state[TagetState];
|
|
174
177
|
}
|
|
175
|
-
// store.getStateItem(key1) usage to ge the ge
|
|
176
|
-
// getStateItem: (state) => (stateKey=nu) => state[stateKey],
|
|
177
178
|
},
|
|
178
179
|
actions: {
|
|
179
180
|
validateObjectLength(object) {
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
+
const baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
|
|
8
8
|
|
|
9
9
|
const customAxios = axios.create({
|
|
10
10
|
baseURL: baseURL,
|
|
@@ -33,7 +33,6 @@ const requestHandler = (request) => {
|
|
|
33
33
|
|
|
34
34
|
// Handle FormData explicitly if needed
|
|
35
35
|
if (request.data instanceof FormData) {
|
|
36
|
-
// Keep FormData unchanged
|
|
37
36
|
const formData = request.data;
|
|
38
37
|
request.data = formData;
|
|
39
38
|
} else if (request.data) {
|
|
@@ -66,11 +65,9 @@ const useFetch = async ({ url, method, data }) => {
|
|
|
66
65
|
if (uniformMethod === 'get') {
|
|
67
66
|
const params = generateParams(_data ?? {});
|
|
68
67
|
response = await customAxios.get(`${url}${params}`);
|
|
69
|
-
} else
|
|
68
|
+
} else
|
|
70
69
|
response = await customAxios.post(url, _data);
|
|
71
70
|
|
|
72
|
-
}
|
|
73
|
-
// console.log(response, "responseresponseresponseresponse");
|
|
74
71
|
return response?.data ?? { Empty: 'Empty' };
|
|
75
72
|
} catch (err) {
|
|
76
73
|
console.error(err);
|
|
@@ -79,22 +76,28 @@ const useFetch = async ({ url, method, data }) => {
|
|
|
79
76
|
};
|
|
80
77
|
|
|
81
78
|
const generateParams = (params={}) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
try {
|
|
80
|
+
|
|
81
|
+
let data = "?";
|
|
82
|
+
for (let key in params) {
|
|
83
|
+
if (Object.hasOwnProperty.call(params, key)) {
|
|
84
|
+
if (params[key]) {
|
|
85
|
+
if (Array.isArray(params[key])) {
|
|
86
|
+
const elements = params[key] ;
|
|
87
|
+
for (const ele of elements) {
|
|
88
|
+
data += `${key}[]=${ele}&`;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
data += `${key}=${params[key]}&`;
|
|
90
92
|
}
|
|
91
|
-
} else {
|
|
92
|
-
data += `${key}=${params[key]}&`;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
return data.slice(0, -1);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(err);
|
|
99
|
+
|
|
96
100
|
}
|
|
97
|
-
return data.slice(0, -1);
|
|
98
101
|
};
|
|
99
102
|
|
|
100
103
|
function setBearerToken(name = { token: null }) {
|
|
@@ -115,10 +118,7 @@ function getBearerToken() {
|
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
function createPomStore(
|
|
119
|
-
piniaStore = "7286204094",
|
|
120
|
-
callBack=null
|
|
121
|
-
) {
|
|
121
|
+
function createPomStore( piniaStore = "7286204094", callBack=null) {
|
|
122
122
|
const storeId = "POM" + piniaStore;
|
|
123
123
|
const piniaData = defineStore(storeId, {
|
|
124
124
|
state: () => {
|
|
@@ -129,8 +129,7 @@ function createPomStore(
|
|
|
129
129
|
isThereAnyDataChangeInAform: false,
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
return StateObjectsContainer;
|
|
133
|
-
// return {...this.state,...StateObjectsContainer}
|
|
132
|
+
return StateObjectsContainer;
|
|
134
133
|
},
|
|
135
134
|
|
|
136
135
|
getters: {
|
|
@@ -142,9 +141,7 @@ function createPomStore(
|
|
|
142
141
|
*/
|
|
143
142
|
return (state[TagetState] = state[TagetState]);
|
|
144
143
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// getStateItem: (state) => (stateKey=nu) => state[stateKey],
|
|
144
|
+
|
|
148
145
|
},
|
|
149
146
|
actions: {
|
|
150
147
|
validateObjectLength(object) {
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
+
const baseURL = typeof import.meta !== 'undefined' ? (import.meta.env.VITE_BACKEND_URL ??""): "";
|
|
8
8
|
|
|
9
9
|
const customAxios = axios.create({
|
|
10
10
|
baseURL: baseURL,
|
|
@@ -33,7 +33,6 @@ const requestHandler = (request) => {
|
|
|
33
33
|
|
|
34
34
|
// Handle FormData explicitly if needed
|
|
35
35
|
if (request.data instanceof FormData) {
|
|
36
|
-
// Keep FormData unchanged
|
|
37
36
|
const formData = request.data;
|
|
38
37
|
request.data = formData;
|
|
39
38
|
} else if (request.data) {
|
|
@@ -66,11 +65,9 @@ const useFetch = async ({ url, method, data }) => {
|
|
|
66
65
|
if (uniformMethod === 'get') {
|
|
67
66
|
const params = generateParams(_data ?? {});
|
|
68
67
|
response = await customAxios.get(`${url}${params}`);
|
|
69
|
-
} else
|
|
68
|
+
} else
|
|
70
69
|
response = await customAxios.post(url, _data);
|
|
71
70
|
|
|
72
|
-
}
|
|
73
|
-
// console.log(response, "responseresponseresponseresponse");
|
|
74
71
|
return response?.data ?? { Empty: 'Empty' };
|
|
75
72
|
} catch (err) {
|
|
76
73
|
console.error(err);
|
|
@@ -79,22 +76,28 @@ const useFetch = async ({ url, method, data }) => {
|
|
|
79
76
|
};
|
|
80
77
|
|
|
81
78
|
const generateParams = (params={}) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
try {
|
|
80
|
+
|
|
81
|
+
let data = "?";
|
|
82
|
+
for (let key in params) {
|
|
83
|
+
if (Object.hasOwnProperty.call(params, key)) {
|
|
84
|
+
if (params[key]) {
|
|
85
|
+
if (Array.isArray(params[key])) {
|
|
86
|
+
const elements = params[key] ;
|
|
87
|
+
for (const ele of elements) {
|
|
88
|
+
data += `${key}[]=${ele}&`;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
data += `${key}=${params[key]}&`;
|
|
90
92
|
}
|
|
91
|
-
} else {
|
|
92
|
-
data += `${key}=${params[key]}&`;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
return data.slice(0, -1);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(err);
|
|
99
|
+
|
|
96
100
|
}
|
|
97
|
-
return data.slice(0, -1);
|
|
98
101
|
};
|
|
99
102
|
|
|
100
103
|
function setBearerToken(name = { token: null }) {
|
|
@@ -115,10 +118,7 @@ function getBearerToken() {
|
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
function createPomStore(
|
|
119
|
-
piniaStore = "7286204094",
|
|
120
|
-
callBack=null
|
|
121
|
-
) {
|
|
121
|
+
function createPomStore( piniaStore = "7286204094", callBack=null) {
|
|
122
122
|
const storeId = "POM" + piniaStore;
|
|
123
123
|
const piniaData = defineStore(storeId, {
|
|
124
124
|
state: () => {
|
|
@@ -129,8 +129,7 @@ function createPomStore(
|
|
|
129
129
|
isThereAnyDataChangeInAform: false,
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
return StateObjectsContainer;
|
|
133
|
-
// return {...this.state,...StateObjectsContainer}
|
|
132
|
+
return StateObjectsContainer;
|
|
134
133
|
},
|
|
135
134
|
|
|
136
135
|
getters: {
|
|
@@ -142,9 +141,7 @@ function createPomStore(
|
|
|
142
141
|
*/
|
|
143
142
|
return (state[TagetState] = state[TagetState]);
|
|
144
143
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
// getStateItem: (state) => (stateKey=nu) => state[stateKey],
|
|
144
|
+
|
|
148
145
|
},
|
|
149
146
|
actions: {
|
|
150
147
|
validateObjectLength(object) {
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var AbortHandler = {
|
|
|
16
16
|
var abortHandler_default = AbortHandler;
|
|
17
17
|
|
|
18
18
|
// src/utils/custom-axios.js
|
|
19
|
-
var baseURL = typeof import.meta !== "undefined" ? import.meta.env.VITE_BACKEND_URL ?? "" :
|
|
19
|
+
var baseURL = typeof import.meta !== "undefined" ? import.meta.env.VITE_BACKEND_URL ?? "" : "";
|
|
20
20
|
var customAxios = axios.create({
|
|
21
21
|
baseURL,
|
|
22
22
|
signal: abortHandler_default.abortController.signal
|
|
@@ -72,32 +72,35 @@ var useFetch = async ({ url, method, data }) => {
|
|
|
72
72
|
if (uniformMethod === "get") {
|
|
73
73
|
const params = generateParams(_data ?? {});
|
|
74
74
|
response = await custom_axios_default.get(`${url}${params}`);
|
|
75
|
-
} else
|
|
75
|
+
} else
|
|
76
76
|
response = await custom_axios_default.post(url, _data);
|
|
77
|
-
}
|
|
78
77
|
return (response == null ? void 0 : response.data) ?? { Empty: "Empty" };
|
|
79
|
-
} catch (
|
|
80
|
-
console.error(
|
|
81
|
-
return { success: false, error:
|
|
78
|
+
} catch (err2) {
|
|
79
|
+
console.error(err2);
|
|
80
|
+
return { success: false, error: err2 };
|
|
82
81
|
}
|
|
83
82
|
};
|
|
84
83
|
var generateParams = (params = {}) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (params
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
try {
|
|
85
|
+
let data = "?";
|
|
86
|
+
for (let key in params) {
|
|
87
|
+
if (Object.hasOwnProperty.call(params, key)) {
|
|
88
|
+
if (params[key]) {
|
|
89
|
+
if (Array.isArray(params[key])) {
|
|
90
|
+
const elements = params[key];
|
|
91
|
+
for (const ele of elements) {
|
|
92
|
+
data += `${key}[]=${ele}&`;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
data += `${key}=${params[key]}&`;
|
|
93
96
|
}
|
|
94
|
-
} else {
|
|
95
|
-
data += `${key}=${params[key]}&`;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
}
|
|
100
|
+
return data.slice(0, -1);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error(err);
|
|
99
103
|
}
|
|
100
|
-
return data.slice(0, -1);
|
|
101
104
|
};
|
|
102
105
|
function setBearerToken(name = { token: null }) {
|
|
103
106
|
if (typeof name !== "object" || name === null || Array.isArray(name))
|
|
@@ -132,8 +135,6 @@ function createPomStore(piniaStore = "7286204094", callBack = null) {
|
|
|
132
135
|
stateItems: (state) => (TagetState) => {
|
|
133
136
|
return state[TagetState] = state[TagetState];
|
|
134
137
|
}
|
|
135
|
-
// store.getStateItem(key1) usage to ge the ge
|
|
136
|
-
// getStateItem: (state) => (stateKey=nu) => state[stateKey],
|
|
137
138
|
},
|
|
138
139
|
actions: {
|
|
139
140
|
validateObjectLength(object) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "septor-store is a structured and scalable state management solution built on top of Pinia for Vue 3. It embraces the Plain Old Module (POM) pattern to simplify how developers—junior or senior—write, organize, and scale their application state. Whether you're just starting out or architecting large Vue applications, this tool helps you keep your stores clean, predictable, and easy to indextain.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.6",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.cjs",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -66,6 +66,12 @@
|
|
|
66
66
|
"septor-store-vue",
|
|
67
67
|
"reload-control"
|
|
68
68
|
],
|
|
69
|
+
"funding": [
|
|
70
|
+
{
|
|
71
|
+
"type": "ko-fi",
|
|
72
|
+
"url": "https://ko-fi.com/ssengedonazil"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
69
75
|
"author": "Ssengendo Nazil",
|
|
70
76
|
"repository": {
|
|
71
77
|
"type": "git",
|