@thzero/library_client_vue3_store_pinia 0.18.34 → 0.18.35
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 +17 -17
- package/license.md +8 -8
- package/openSource.js +52 -52
- package/package.json +34 -34
- package/service/store/index.js +51 -51
- package/store/admin/news/index.js +76 -76
- package/store/admin/users/index.js +63 -63
- package/store/index.js +323 -316
- package/store/news/index.js +43 -43
- package/store/user/index.js +135 -135
package/store/index.js
CHANGED
|
@@ -1,316 +1,323 @@
|
|
|
1
|
-
import { createPinia, defineStore } from 'pinia';
|
|
2
|
-
import piniaPluginPersistedState from 'pinia-plugin-persistedstate';
|
|
3
|
-
import { createPersistedStatePlugin } from 'pinia-plugin-persistedstate-2';
|
|
4
|
-
|
|
5
|
-
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
6
|
-
|
|
7
|
-
import LibraryClientUtility from '@thzero/library_client/utility/index';
|
|
8
|
-
import LibraryCommonUtility from '@thzero/library_common/utility/index';
|
|
9
|
-
|
|
10
|
-
import Response from '@thzero/library_common/response';
|
|
11
|
-
|
|
12
|
-
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
13
|
-
|
|
14
|
-
// import adminNews from './admin/news/pinia';
|
|
15
|
-
// import adminUsers from './admin/users/pinia';
|
|
16
|
-
|
|
17
|
-
import news from './news';
|
|
18
|
-
import user from './user';
|
|
19
|
-
|
|
20
|
-
class BaseStore {
|
|
21
|
-
async initialize() {
|
|
22
|
-
this.pinia = createPinia();
|
|
23
|
-
|
|
24
|
-
this._initPluginPersist();
|
|
25
|
-
|
|
26
|
-
return this.pinia;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setup() {
|
|
30
|
-
// const logger = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_LOGGER);
|
|
31
|
-
|
|
32
|
-
const initialStoreConfig = this._initStoreConfigBase();
|
|
33
|
-
const appStoreConfig = this._initStoreConfig();
|
|
34
|
-
initialStoreConfig.actions = Object.assign(initialStoreConfig.actions, appStoreConfig.actions);
|
|
35
|
-
initialStoreConfig.dispatcher = Object.assign(initialStoreConfig.dispatcher, appStoreConfig.dispatcher);
|
|
36
|
-
initialStoreConfig.getters = Object.assign(initialStoreConfig.getters, appStoreConfig.getters);
|
|
37
|
-
|
|
38
|
-
const initialState = initialStoreConfig.state();
|
|
39
|
-
const appState = appStoreConfig.state();
|
|
40
|
-
const state = Object.assign(initialState, appState);
|
|
41
|
-
initialStoreConfig.state = () => state;
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
func: {
|
|
45
|
-
install(app, options) {
|
|
46
|
-
const storeConfig = options.storeConfig;
|
|
47
|
-
|
|
48
|
-
options.actionGetters = storeConfig.getters;
|
|
49
|
-
options.actionDispatcher = storeConfig.dispatcher;
|
|
50
|
-
if (!options.actionDispatcher)
|
|
51
|
-
options.actionDispatcher = {};
|
|
52
|
-
|
|
53
|
-
const pluginPersistType = options.pluginPersistType();
|
|
54
|
-
const additionalPaths = storeConfig.pluginPersistPaths ? storeConfig.pluginPersistPaths[pluginPersistType] : null;
|
|
55
|
-
|
|
56
|
-
if (options.pluginPersistSetup && options.pluginPersistType && options.pluginPersistConfig && options.pluginPersistConfig && options.pluginPersistConfig[pluginPersistType])
|
|
57
|
-
options.pluginPersistSetup(pluginPersistType, storeConfig, options.pluginPersistConfig[pluginPersistType], options.pluginPersistSetupOverride, {
|
|
58
|
-
additionalPaths: additionalPaths
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// if (storeConfig.pluginPersistPaths && storeConfig.pluginPersistPaths[pluginPersistType])
|
|
62
|
-
// storeConfig[pluginPersistType].paths = [ ...storeConfig[pluginPersistType].paths, ...storeConfig.pluginPersistPaths[pluginPersistType] ];
|
|
63
|
-
delete storeConfig.pluginPersistPaths;
|
|
64
|
-
|
|
65
|
-
const storeFunc = defineStore('main', storeConfig);
|
|
66
|
-
LibraryClientUtility.$store = storeFunc(options.pinia);
|
|
67
|
-
//LibraryClientUtility.$store.$logger = options.logger;
|
|
68
|
-
Object.defineProperty(LibraryClientUtility.$store, '$logger', {
|
|
69
|
-
get() {
|
|
70
|
-
if (!this._logger)
|
|
71
|
-
this._logger = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_LOGGER);
|
|
72
|
-
return this._logger;
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const storeFuncModules = [];
|
|
77
|
-
// options.addModule('adminNews', adminNews, options.actionDispatcher, pluginPersistType, options.pluginPersistConfig, options.pinia, logger);
|
|
78
|
-
// options.addModule('adminUsers', adminUsers, options.actionDispatcher, pluginPersistType, options.pluginPersistConfig, options.pinia, logger);
|
|
79
|
-
// storeFuncModules.push(options.addModule('news', news, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia, logger));
|
|
80
|
-
// storeFuncModules.push(options.addModule('user', user, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia, logger));
|
|
81
|
-
storeFuncModules.push(options.
|
|
82
|
-
storeFuncModules.push(options.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
throw
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
this.$logger.debug('store', '
|
|
272
|
-
this.
|
|
273
|
-
this
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
this.$logger.debug('store', '
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
1
|
+
import { createPinia, defineStore } from 'pinia';
|
|
2
|
+
import piniaPluginPersistedState from 'pinia-plugin-persistedstate';
|
|
3
|
+
import { createPersistedStatePlugin } from 'pinia-plugin-persistedstate-2';
|
|
4
|
+
|
|
5
|
+
import LibraryClientConstants from '@thzero/library_client/constants';
|
|
6
|
+
|
|
7
|
+
import LibraryClientUtility from '@thzero/library_client/utility/index';
|
|
8
|
+
import LibraryCommonUtility from '@thzero/library_common/utility/index';
|
|
9
|
+
|
|
10
|
+
import Response from '@thzero/library_common/response';
|
|
11
|
+
|
|
12
|
+
import NotImplementedError from '@thzero/library_common/errors/notImplemented';
|
|
13
|
+
|
|
14
|
+
// import adminNews from './admin/news/pinia';
|
|
15
|
+
// import adminUsers from './admin/users/pinia';
|
|
16
|
+
|
|
17
|
+
import news from './news';
|
|
18
|
+
import user from './user';
|
|
19
|
+
|
|
20
|
+
class BaseStore {
|
|
21
|
+
async initialize() {
|
|
22
|
+
this.pinia = createPinia();
|
|
23
|
+
|
|
24
|
+
this._initPluginPersist();
|
|
25
|
+
|
|
26
|
+
return this.pinia;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setup() {
|
|
30
|
+
// const logger = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_LOGGER);
|
|
31
|
+
|
|
32
|
+
const initialStoreConfig = this._initStoreConfigBase();
|
|
33
|
+
const appStoreConfig = this._initStoreConfig();
|
|
34
|
+
initialStoreConfig.actions = Object.assign(initialStoreConfig.actions, appStoreConfig.actions);
|
|
35
|
+
initialStoreConfig.dispatcher = Object.assign(initialStoreConfig.dispatcher, appStoreConfig.dispatcher);
|
|
36
|
+
initialStoreConfig.getters = Object.assign(initialStoreConfig.getters, appStoreConfig.getters);
|
|
37
|
+
|
|
38
|
+
const initialState = initialStoreConfig.state();
|
|
39
|
+
const appState = appStoreConfig.state();
|
|
40
|
+
const state = Object.assign(initialState, appState);
|
|
41
|
+
initialStoreConfig.state = () => state;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
func: {
|
|
45
|
+
install(app, options) {
|
|
46
|
+
const storeConfig = options.storeConfig;
|
|
47
|
+
|
|
48
|
+
options.actionGetters = storeConfig.getters;
|
|
49
|
+
options.actionDispatcher = storeConfig.dispatcher;
|
|
50
|
+
if (!options.actionDispatcher)
|
|
51
|
+
options.actionDispatcher = {};
|
|
52
|
+
|
|
53
|
+
const pluginPersistType = options.pluginPersistType();
|
|
54
|
+
const additionalPaths = storeConfig.pluginPersistPaths ? storeConfig.pluginPersistPaths[pluginPersistType] : null;
|
|
55
|
+
|
|
56
|
+
if (options.pluginPersistSetup && options.pluginPersistType && options.pluginPersistConfig && options.pluginPersistConfig && options.pluginPersistConfig[pluginPersistType])
|
|
57
|
+
options.pluginPersistSetup(pluginPersistType, storeConfig, options.pluginPersistConfig[pluginPersistType], options.pluginPersistSetupOverride, {
|
|
58
|
+
additionalPaths: additionalPaths
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// if (storeConfig.pluginPersistPaths && storeConfig.pluginPersistPaths[pluginPersistType])
|
|
62
|
+
// storeConfig[pluginPersistType].paths = [ ...storeConfig[pluginPersistType].paths, ...storeConfig.pluginPersistPaths[pluginPersistType] ];
|
|
63
|
+
delete storeConfig.pluginPersistPaths;
|
|
64
|
+
|
|
65
|
+
const storeFunc = defineStore('main', storeConfig);
|
|
66
|
+
LibraryClientUtility.$store = storeFunc(options.pinia);
|
|
67
|
+
//LibraryClientUtility.$store.$logger = options.logger;
|
|
68
|
+
Object.defineProperty(LibraryClientUtility.$store, '$logger', {
|
|
69
|
+
get() {
|
|
70
|
+
if (!this._logger)
|
|
71
|
+
this._logger = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_LOGGER);
|
|
72
|
+
return this._logger;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const storeFuncModules = [];
|
|
77
|
+
// options.addModule('adminNews', adminNews, options.actionDispatcher, pluginPersistType, options.pluginPersistConfig, options.pinia, logger);
|
|
78
|
+
// options.addModule('adminUsers', adminUsers, options.actionDispatcher, pluginPersistType, options.pluginPersistConfig, options.pinia, logger);
|
|
79
|
+
// storeFuncModules.push(options.addModule('news', news, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia, logger));
|
|
80
|
+
// storeFuncModules.push(options.addModule('user', user, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia, logger));
|
|
81
|
+
storeFuncModules.push(options.initModule('news', news, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia));
|
|
82
|
+
storeFuncModules.push(options.initModule('user', user, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia));
|
|
83
|
+
|
|
84
|
+
const modules = options.initModules(options.addModule);
|
|
85
|
+
for(const module of modules)
|
|
86
|
+
storeFuncModules.push(options.initModule(module.key, module.storeConfig, options.actionDispatcher, options.actionGetters, storeConfig.persist, pluginPersistType, options.pluginPersistSetup, options.pluginPersistSetupOverride, options.pinia));
|
|
87
|
+
|
|
88
|
+
LibraryClientUtility.$store.dispatcher = options.actionDispatcher;
|
|
89
|
+
LibraryClientUtility.$store.getters = options.actionGetters;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
options: {
|
|
93
|
+
actionDispatcher: this.actionDispatcher,
|
|
94
|
+
actionGetters: this.actionGetters,
|
|
95
|
+
addModule: this._addModule,
|
|
96
|
+
initModule: this._initModule,
|
|
97
|
+
initModules: this._initModules,
|
|
98
|
+
// logger: logger,
|
|
99
|
+
pinia: this.pinia,
|
|
100
|
+
pluginPersistConfig: this._initPluginPersistConfig(),
|
|
101
|
+
pluginPersistSetupOverride: this._initPluginPersistConfigSetupOverride,
|
|
102
|
+
pluginPersistSetup: this._initPluginPersistConfigSetup,
|
|
103
|
+
pluginPersistType: this._initPluginPersistType,
|
|
104
|
+
storeConfig: initialStoreConfig
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_addModule(key, storeConfig) {
|
|
110
|
+
return { key: key, storeConfig: storeConfig };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// _addModule(key, storeConfig, actionDispatcher, actionGetters, pluginPersistConfig, pluginPersistType, pluginPersistSetup, pluginPersistSetupOverride, pinia, logger) {
|
|
114
|
+
_initModule(key, storeConfig, actionDispatcher, actionGetters, pluginPersistConfig, pluginPersistType, pluginPersistSetup, pluginPersistSetupOverride, pinia) {
|
|
115
|
+
if (pluginPersistType && pluginPersistSetup && storeConfig.pluginPersistPaths && storeConfig.pluginPersistPaths[pluginPersistType]) {
|
|
116
|
+
pluginPersistConfig = LibraryCommonUtility.cloneDeep(pluginPersistConfig);
|
|
117
|
+
pluginPersistSetup(pluginPersistType, storeConfig, pluginPersistConfig, pluginPersistSetupOverride, {
|
|
118
|
+
additionalPaths: storeConfig.pluginPersistPaths[pluginPersistType],
|
|
119
|
+
keySuffix: `_${key}`
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
actionDispatcher[key] = storeConfig.dispatcher;
|
|
123
|
+
delete storeConfig.dispatcher;
|
|
124
|
+
actionGetters[key] = storeConfig.getters;
|
|
125
|
+
delete storeConfig.getters;
|
|
126
|
+
delete storeConfig.pluginPersistPaths;
|
|
127
|
+
const storeFunc = defineStore(key, storeConfig);
|
|
128
|
+
LibraryClientUtility.$store[key] = storeFunc(pinia);
|
|
129
|
+
// LibraryClientUtility.$store[key].$logger = logger;
|
|
130
|
+
Object.defineProperty(LibraryClientUtility.$store[key], '$logger', {
|
|
131
|
+
get() {
|
|
132
|
+
if (!this._logger)
|
|
133
|
+
this._logger = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_LOGGER);
|
|
134
|
+
return this._logger;
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
return { key: key, storeFunc: storeFunc };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_initPluginPersist() {
|
|
141
|
+
if (this._initPluginPersistType() === BaseStore.PersistanceTypePersist) {
|
|
142
|
+
this.pinia.use(piniaPluginPersistedState);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (this._initPluginPersistType() === BaseStore.PersistanceTypePersist2) {
|
|
146
|
+
const installPersistedStatePlugin = createPersistedStatePlugin();
|
|
147
|
+
this.pinia.use((context) => installPersistedStatePlugin(context));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (this._initPluginPersistType() === BaseStore.PersistanceTypeOverride) {
|
|
151
|
+
const override = this._initPluginPersistOverride();
|
|
152
|
+
if (override) {
|
|
153
|
+
override(this.pinia);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
throw Error('Unknown persistance engine for Pinia store.');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
_initModules() {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_initPluginPersistConfig() {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_initPluginPersistOverride() {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_initPluginPersistType() {
|
|
174
|
+
return BaseStore.PersistanceTypePersist;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_initPluginPersistConfigSetup(type, storeConfig, persistConfig, override, options) {
|
|
178
|
+
if (type === BaseStore.PersistanceTypePersist) {
|
|
179
|
+
if (options && !String.isNullOrEmpty(options.keyOverride))
|
|
180
|
+
persistConfig.key = options.keyOverride;
|
|
181
|
+
if (options && !String.isNullOrEmpty(options.keySuffix))
|
|
182
|
+
persistConfig.key += options.keySuffix;
|
|
183
|
+
if (options && options.additionalPaths)
|
|
184
|
+
persistConfig.pick = [ ...persistConfig.paths, ...options.additionalPaths ];
|
|
185
|
+
storeConfig.persist = persistConfig;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (type === BaseStore.PersistanceTypePersist2) {
|
|
189
|
+
if (options && !String.isNullOrEmpty(options.keyOverride))
|
|
190
|
+
persistConfig.key = options.keyOverride;
|
|
191
|
+
if (options && !String.isNullOrEmpty(options.keySuffix))
|
|
192
|
+
persistConfig.key += options.keySuffix;
|
|
193
|
+
if (options && options.additionalPaths)
|
|
194
|
+
persistConfig.includePaths = [ ...persistConfig.includePaths, ...options.additionalPaths ];
|
|
195
|
+
storeConfig.persistedState = persistConfig;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (type === BaseStore.PersistanceTypeOverride) {
|
|
199
|
+
if (override) {
|
|
200
|
+
override(storeConfig, persistConfig);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
throw Error('Unknown persistance engine for Pinia store.');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_initPluginPersistConfigSetupOverride(storeConfig, persistConfig) {
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
_initStoreConfig() {
|
|
212
|
+
throw new NotImplementedError();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
_initStoreConfigBase() {
|
|
216
|
+
return {
|
|
217
|
+
pluginPersistPaths: {
|
|
218
|
+
persist: [
|
|
219
|
+
'openSource',
|
|
220
|
+
'plans',
|
|
221
|
+
'version'
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
state: () => ({
|
|
225
|
+
checksumLastUpdate: [],
|
|
226
|
+
openSource: [],
|
|
227
|
+
plans: [],
|
|
228
|
+
version: null
|
|
229
|
+
}),
|
|
230
|
+
actions: {
|
|
231
|
+
async initialize(correlationId) {
|
|
232
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_UTILITY);
|
|
233
|
+
const response = await service.initialize(correlationId);
|
|
234
|
+
if (Response.hasSucceeded(response)) {
|
|
235
|
+
await this.setPlans(correlationId, response.results.plans);
|
|
236
|
+
await this.setVersion(correlationId, response.results.version);
|
|
237
|
+
if (this._initialize)
|
|
238
|
+
await this._initialize(correlationId, response.results);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
async requestOpenSource(correlationId) {
|
|
242
|
+
const openSourceCheck = LibraryClientUtility.$store.openSource;
|
|
243
|
+
if (openSourceCheck && Array.isArray(openSourceCheck) && openSourceCheck.length > 0)
|
|
244
|
+
return Response.success(correlationId, openSourceCheck);
|
|
245
|
+
|
|
246
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_UTILITY);
|
|
247
|
+
const response = await service.openSource(correlationId);
|
|
248
|
+
this.$logger.debug('store', 'requestOpenSource', 'response', response, correlationId);
|
|
249
|
+
const openSource = response.results ? response.results : null;
|
|
250
|
+
if (Response.hasFailed(response))
|
|
251
|
+
return response;
|
|
252
|
+
await this.setOpenSource(correlationId, openSource);
|
|
253
|
+
return Response.success(correlationId, openSource);
|
|
254
|
+
},
|
|
255
|
+
async requestPlans(correlationId) {
|
|
256
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_PLANS);
|
|
257
|
+
const response = await service.plans(correlationId);
|
|
258
|
+
this.$logger.debug('store', 'requestPlans', 'response', response, correlationId);
|
|
259
|
+
const plans = response.results ? response.results.data : [];
|
|
260
|
+
if (Response.hasFailed(response))
|
|
261
|
+
return response;
|
|
262
|
+
await this.setPlans(correlationId, plans);
|
|
263
|
+
return Response.success(plans);
|
|
264
|
+
},
|
|
265
|
+
async requestVersion(correlationId) {
|
|
266
|
+
const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_VERSION);
|
|
267
|
+
const version = await service.version(correlationId);
|
|
268
|
+
await this.setVersion(correlationId, version);
|
|
269
|
+
},
|
|
270
|
+
async setOpenSource(correlationId, openSource) {
|
|
271
|
+
this.$logger.debug('store', 'setOpenSource', 'openSource.a', openSource, correlationId);
|
|
272
|
+
this.$logger.debug('store', 'setOpenSource', 'openSource.b', this.openSource, correlationId);
|
|
273
|
+
this.openSource = openSource;
|
|
274
|
+
this.$logger.debug('store', 'setOpenSource', 'openSource.c', this.openSource, correlationId);
|
|
275
|
+
},
|
|
276
|
+
async setPlans(correlationId, plans) {
|
|
277
|
+
this.$logger.debug('store', 'setPlans', 'plans.a', plans, correlationId);
|
|
278
|
+
this.$logger.debug('store', 'setPlans', 'plans.b', this.plans, correlationId);
|
|
279
|
+
this.plans = plans;
|
|
280
|
+
this.$logger.debug('store', 'setPlans', 'plans.c', this.plans, correlationId);
|
|
281
|
+
},
|
|
282
|
+
async setVersion(correlationId, version) {
|
|
283
|
+
if (!version)
|
|
284
|
+
return;
|
|
285
|
+
// this.$logger.debug('store', 'getVersion', 'version', version, correlationId);
|
|
286
|
+
// commit('setVersion', { correlationId: correlationId, version: version });
|
|
287
|
+
this.$logger.debug('store', 'setVersion', 'version', version, correlationId);
|
|
288
|
+
this.version = version;
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
getters: {
|
|
292
|
+
getOpenSource(correlationId) {
|
|
293
|
+
return LibraryClientUtility.$store.openSource;
|
|
294
|
+
},
|
|
295
|
+
getPlan(correlationId, id) {
|
|
296
|
+
if (LibraryClientUtility.$store.plans == null)
|
|
297
|
+
return null;
|
|
298
|
+
return LibraryClientUtility.$store.plans.find(plan => plan.id === id);
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
dispatcher: {
|
|
302
|
+
async requestOpenSource(correlationId) {
|
|
303
|
+
return await LibraryClientUtility.$store.requestOpenSource(correlationId);
|
|
304
|
+
},
|
|
305
|
+
async requestPlans(correlationId) {
|
|
306
|
+
return await LibraryClientUtility.$store.requestPlans(correlationId);
|
|
307
|
+
},
|
|
308
|
+
async requestVersion(correlationId) {
|
|
309
|
+
await LibraryClientUtility.$store.requestVersion(correlationId);
|
|
310
|
+
},
|
|
311
|
+
async initialize(correlationId) {
|
|
312
|
+
await LibraryClientUtility.$store.initialize(correlationId);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
static PersistanceTypeOverride = 'override';
|
|
319
|
+
static PersistanceTypePersist = 'persist';
|
|
320
|
+
static PersistanceTypePersist2 = 'persist2';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export default BaseStore;
|