@monorise/react 1.0.1 → 1.0.2
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/actions/config.action.d.ts +10 -0
- package/dist/actions/config.action.d.ts.map +1 -0
- package/dist/actions/config.action.js +31 -0
- package/dist/actions/config.action.js.map +1 -0
- package/dist/actions/core.action.d.ts.map +1 -1
- package/dist/actions/core.action.js +2 -3
- package/dist/actions/core.action.js.map +1 -1
- package/dist/index.d.ts +388 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/index.jsx +48 -0
- package/dist/index.jsx.map +1 -0
- package/dist/services/core.service.d.ts +2 -1
- package/dist/services/core.service.d.ts.map +1 -1
- package/dist/services/core.service.js +9 -10
- package/dist/services/core.service.js.map +1 -1
- package/dist/store/monorise.store.d.ts +9 -3
- package/dist/store/monorise.store.d.ts.map +1 -1
- package/dist/store/monorise.store.js +3 -11
- package/dist/store/monorise.store.js.map +1 -1
- package/index.ts +18 -4
- package/package.json +6 -4
- package/actions/app.action.ts +0 -218
- package/actions/auth.action.ts +0 -71
- package/actions/core.action.ts +0 -878
- package/lib/api.tsx +0 -132
- package/lib/config.ts +0 -36
- package/lib/constant.ts +0 -1
- package/lib/entity.ts +0 -81
- package/lib/utils.ts +0 -12
- package/services/auth.service.ts +0 -59
- package/services/core.service.ts +0 -416
- package/services/filestore.service.ts +0 -136
- package/store/monorise.store.ts +0 -111
- package/types/api.type.ts +0 -57
- package/types/axios.type.ts +0 -14
- package/types/monorise.type.ts +0 -8
package/dist/index.jsx
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { initAppActions } from './actions/app.action';
|
|
2
|
+
import { initAuthActions } from './actions/auth.action';
|
|
3
|
+
import { initConfigActions } from './actions/config.action';
|
|
4
|
+
import { initCoreActions } from './actions/core.action';
|
|
5
|
+
import { initAxiosInterceptor, injectAxiosInterceptor } from './lib/api';
|
|
6
|
+
import initAuthService from './services/auth.service';
|
|
7
|
+
import initCoreService from './services/core.service';
|
|
8
|
+
import initFilestoreService from './services/filestore.service';
|
|
9
|
+
import { initMonoriseStore } from './store/monorise.store';
|
|
10
|
+
const initMonorise = () => {
|
|
11
|
+
const { monoriseStore: store, setOptions: setMonoriseOptions } = initMonoriseStore();
|
|
12
|
+
const appActions = initAppActions(store);
|
|
13
|
+
const configActions = initConfigActions(store);
|
|
14
|
+
const axios = initAxiosInterceptor(store, appActions);
|
|
15
|
+
const authService = initAuthService(axios);
|
|
16
|
+
const filestoreService = initFilestoreService(axios);
|
|
17
|
+
const coreService = initCoreService(store, axios);
|
|
18
|
+
const authActions = initAuthActions(store, authService);
|
|
19
|
+
const coreActions = initCoreActions(store, appActions, coreService);
|
|
20
|
+
injectAxiosInterceptor(appActions, authActions, axios);
|
|
21
|
+
const config = (opts) => {
|
|
22
|
+
setMonoriseOptions({
|
|
23
|
+
modals: opts.modals,
|
|
24
|
+
});
|
|
25
|
+
authService.setOptions({
|
|
26
|
+
apiBaseUrl: opts.authBaseUrl,
|
|
27
|
+
});
|
|
28
|
+
filestoreService.setOptions({
|
|
29
|
+
apiBaseUrl: opts.filestoreBaseUrl,
|
|
30
|
+
});
|
|
31
|
+
coreService.setOptions({
|
|
32
|
+
entityApiBaseUrl: opts.entityBaseUrl,
|
|
33
|
+
mutualApiBaseUrl: opts.mutualBaseUrl,
|
|
34
|
+
tagApiBaseUrl: opts.tagBaseUrl,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({ config,
|
|
38
|
+
store,
|
|
39
|
+
axios,
|
|
40
|
+
authService,
|
|
41
|
+
filestoreService,
|
|
42
|
+
coreService }, configActions), appActions), authActions), coreActions);
|
|
43
|
+
};
|
|
44
|
+
const Monorise = initMonorise();
|
|
45
|
+
const { store, axios, authService, filestoreService, coreService, setConfig, getConfig, useConfig, startLoading, endLoading, setError, getError, clearError, openModal, closeModal, useLoadStore, useInterruptiveLoadStore, useErrorStore, useModalStore, requestLogin, useProfile, getProfile, useIsUnauthorized, setIsUnauthorized, listMoreEntities, createEntity, upsertEntity, editEntity, updateLocalEntity, deleteEntity, getMutual, createMutual, upsertLocalMutual, deleteMutual, deleteLocalMutual, useEntity, useEntities, useMutual, useMutuals, useEntityState, } = Monorise;
|
|
46
|
+
export { store, axios, authService, filestoreService, coreService, setConfig, getConfig, useConfig, startLoading, endLoading, setError, getError, clearError, openModal, closeModal, useLoadStore, useInterruptiveLoadStore, useErrorStore, useModalStore, requestLogin, useProfile, getProfile, useIsUnauthorized, setIsUnauthorized, listMoreEntities, createEntity, upsertEntity, editEntity, updateLocalEntity, deleteEntity, getMutual, createMutual, upsertLocalMutual, deleteMutual, deleteLocalMutual, useEntity, useEntities, useMutual, useMutuals, useEntityState, };
|
|
47
|
+
export default Monorise;
|
|
48
|
+
//# sourceMappingURL=index.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.jsx","sourceRoot":"","sources":["../index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAW3D,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAC5D,iBAAiB,EA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,CAAC;AAEhC,MAAM,EACJ,KAAK,EACL,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,GACf,GAAG,QAAQ,CAAC;AAEb,OAAO,EACL,KAAK,EACL,KAAK,EACL,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,GACf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CreatedEntity, DraftEntity, Entity, Mutual, MutualData } from '@monorise/base';
|
|
2
2
|
import type { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import type { MonoriseStore } from '../store/monorise.store';
|
|
3
4
|
import type { AxiosInterceptor } from '../types/api.type';
|
|
4
5
|
type ListEntitiesPayload = {
|
|
5
6
|
limit?: number;
|
|
@@ -28,7 +29,7 @@ export type CommonOptions = Partial<AxiosRequestConfig> & {
|
|
|
28
29
|
loading?: string;
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
|
-
declare const initCoreService: (axios: AxiosInterceptor, opts?: ConfigOptions) => {
|
|
32
|
+
declare const initCoreService: (monoriseStore: MonoriseStore, axios: AxiosInterceptor, opts?: ConfigOptions) => {
|
|
32
33
|
makeEntityService: <T extends Entity>(entityType: T) => {
|
|
33
34
|
listEntities: (payload: ListEntitiesPayload, opts?: CommonOptions) => Promise<import("axios").AxiosResponse<{
|
|
34
35
|
data: CreatedEntity<T>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.service.d.ts","sourceRoot":"","sources":["../../services/core.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,MAAM,EACN,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"core.service.d.ts","sourceRoot":"","sources":["../../services/core.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,MAAM,EACN,MAAM,EACN,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,KAAK,mBAAmB,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd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M,EAAE,CAAC,SAAS,MAAM,gBAC7C,CAAC,cACH,CAAC;2CAGC,MAAM,SACZ,aAAa,qBACA,MAAM;;qBA5I2B,MAAM;;gCAsJ9C,MAAM,YACR,MAAM,SACV,aAAa;mCAGP,MAAM,YACR,MAAM,WACP,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;iCAYvC,MAAM,YACR,MAAM,WACP,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;mCAKvC,MAAM,YACR,MAAM,SACV,aAAa;;uBAIG,aAAa;CAYxC,CAAC;AAEF,eAAe,eAAe,CAAC;AAE/B,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { getEntityConfig } from '../lib/config';
|
|
2
1
|
const ENTITY_API_BASE_URL = '/api/core/entity';
|
|
3
2
|
const MUTUAL_API_BASE_URL = '/api/core/mutual';
|
|
4
3
|
const TAG_API_BASE_URL = '/api/core/tag';
|
|
5
|
-
const initCoreService = (axios, opts) => {
|
|
4
|
+
const initCoreService = (monoriseStore, axios, opts) => {
|
|
6
5
|
let options = opts || {};
|
|
7
6
|
const listEntities = (entityType, payload, opts = {}) => {
|
|
8
7
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
@@ -40,40 +39,40 @@ const initCoreService = (axios, opts) => {
|
|
|
40
39
|
feedback: Object.assign({ loading: `Retrieving ${entityType}` }, (opts.feedback || {})),
|
|
41
40
|
});
|
|
42
41
|
};
|
|
43
|
-
const createEntity =
|
|
42
|
+
const createEntity = (entityType, values, opts = {}) => {
|
|
44
43
|
var _a;
|
|
45
44
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
46
|
-
const entityConfig =
|
|
45
|
+
const entityConfig = monoriseStore.getState().config;
|
|
47
46
|
return axios.post(opts.customUrl || `${entityApiBaseUrl}/${entityType}`, values, {
|
|
48
47
|
requestKey: `entity/${entityType}/create`,
|
|
49
48
|
isInterruptive: (_a = opts.isInterruptive) !== null && _a !== void 0 ? _a : true,
|
|
50
49
|
feedback: Object.assign({ loading: `Creating ${entityConfig[entityType].displayName}`, success: `${entityConfig[entityType].displayName} created` }, (opts.feedback || {})),
|
|
51
50
|
});
|
|
52
51
|
};
|
|
53
|
-
const upsertEntity =
|
|
52
|
+
const upsertEntity = (entityType, id, values, opts = {}) => {
|
|
54
53
|
var _a;
|
|
55
54
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
56
|
-
const entityConfig =
|
|
55
|
+
const entityConfig = monoriseStore.getState().config;
|
|
57
56
|
return axios.put(opts.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`, values, {
|
|
58
57
|
requestKey: `entity/${entityType}/upsert/${id}`,
|
|
59
58
|
isInterruptive: (_a = opts.isInterruptive) !== null && _a !== void 0 ? _a : true,
|
|
60
59
|
feedback: Object.assign({ loading: `Updating ${entityConfig[entityType].displayName}`, success: `${entityConfig[entityType].displayName} updated` }, (opts.feedback || {})),
|
|
61
60
|
});
|
|
62
61
|
};
|
|
63
|
-
const editEntity =
|
|
62
|
+
const editEntity = (entityType, id, values, opts = {}) => {
|
|
64
63
|
var _a;
|
|
65
64
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
66
|
-
const entityConfig =
|
|
65
|
+
const entityConfig = monoriseStore.getState().config;
|
|
67
66
|
return axios.patch(opts.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`, values, {
|
|
68
67
|
requestKey: `entity/${entityType}/edit/${id}`,
|
|
69
68
|
isInterruptive: (_a = opts.isInterruptive) !== null && _a !== void 0 ? _a : true,
|
|
70
69
|
feedback: Object.assign({ loading: `Updating ${entityConfig[entityType].displayName}`, success: `${entityConfig[entityType].displayName} updated` }, (opts.feedback || {})),
|
|
71
70
|
});
|
|
72
71
|
};
|
|
73
|
-
const deleteEntity =
|
|
72
|
+
const deleteEntity = (entityType, id, opts = {}) => {
|
|
74
73
|
var _a;
|
|
75
74
|
const { entityApiBaseUrl = ENTITY_API_BASE_URL } = options;
|
|
76
|
-
const entityConfig =
|
|
75
|
+
const entityConfig = monoriseStore.getState().config;
|
|
77
76
|
return axios.delete(opts.customUrl || `${entityApiBaseUrl}/${entityType}/${id}`, {
|
|
78
77
|
requestKey: `entity/${entityType}/delete/${id}`,
|
|
79
78
|
isInterruptive: (_a = opts.isInterruptive) !== null && _a !== void 0 ? _a : true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.service.js","sourceRoot":"","sources":["../../services/core.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.service.js","sourceRoot":"","sources":["../../services/core.service.ts"],"names":[],"mappings":"AAWA,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAiCzC,MAAM,eAAe,GAAG,CACtB,aAA4B,EAC5B,KAAuB,EACvB,IAAoB,EACpB,EAAE;IACF,IAAI,OAAO,GAAkB,IAAI,IAAI,EAAE,CAAC;IAExC,MAAM,YAAY,GAAG,CACnB,UAAa,EACb,OAA6B,EAC7B,OAAsB,EAAE,EACxB,EAAE;QACF,MAAM,EAAE,gBAAgB,GAAG,mBAAmB,EAAE,GAAG,OAAO,CAAC;QAC3D,OAAO,KAAK,CAAC,GAAG,CAIb,IAAI,CAAC,SAAS,IAAI,GAAG,gBAAgB,IAAI,UAAU,EAAE,EAAE;YACxD,UAAU,EAAE,UAAU,UAAU,OAAO;YACvC,MAAM,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,SAAS;YAC5B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;I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AAY,EAAE,CACZ,UAAkB,EAClB,QAAgB,EAChB,OAAmD,EACnD,IAAI,GAAG,EAAE,EACT,EAAE,CACF,YAAY,CACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,OAAO,EACP,IAAI,CACL;QACH,UAAU,EAAE,CACV,UAAkB,EAClB,QAAgB,EAChB,OAAmD,EACnD,IAAI,GAAG,EAAE,EACT,EAAE,CACF,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;QAC3E,YAAY,EAAE,CACZ,UAAkB,EAClB,QAAgB,EAChB,OAAsB,EAAE,EACxB,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC;KACxE,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,CAAC,IAAmB,EAAE,EAAE;QACzC,OAAO,mCACF,OAAO,GACP,IAAI,CACR,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,iBAAiB;QACjB,iBAAiB;QACjB,UAAU;KACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { CreatedEntity, Entity, Mutual } from '@monorise/base';
|
|
1
|
+
import type { CreatedEntity, Entity, MonoriseEntityConfig, Mutual } from '@monorise/base';
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import type { ApplicationRequestError } from '../types/api.type';
|
|
4
4
|
import type { CommonStore } from '../types/monorise.type';
|
|
5
5
|
type Options = {
|
|
6
6
|
modals?: Record<string, React.ComponentType<unknown>>;
|
|
7
7
|
};
|
|
8
|
-
declare const initMonoriseStore: () =>
|
|
8
|
+
declare const initMonoriseStore: () => {
|
|
9
9
|
setOptions: (opts: Options) => void;
|
|
10
10
|
monoriseStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<{
|
|
11
11
|
app: {
|
|
@@ -19,6 +19,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
19
19
|
context?: unknown;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
22
23
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
23
24
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
24
25
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -45,6 +46,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
45
46
|
context?: unknown;
|
|
46
47
|
};
|
|
47
48
|
};
|
|
49
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
48
50
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
49
51
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
50
52
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -68,6 +70,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
68
70
|
context?: unknown;
|
|
69
71
|
};
|
|
70
72
|
};
|
|
73
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
71
74
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
72
75
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
73
76
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -91,6 +94,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
91
94
|
context?: unknown;
|
|
92
95
|
};
|
|
93
96
|
};
|
|
97
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
94
98
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
95
99
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
96
100
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -114,6 +118,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
114
118
|
context?: unknown;
|
|
115
119
|
};
|
|
116
120
|
};
|
|
121
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
117
122
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
118
123
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
119
124
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -137,6 +142,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
137
142
|
context?: unknown;
|
|
138
143
|
};
|
|
139
144
|
};
|
|
145
|
+
config: Record<Entity, MonoriseEntityConfig>;
|
|
140
146
|
entity: Record<Entity, CommonStore<CreatedEntity<Entity>>>;
|
|
141
147
|
mutual: Record<string, CommonStore<Mutual>>;
|
|
142
148
|
tag: Record<string, CommonStore<CreatedEntity<Entity>>>;
|
|
@@ -150,7 +156,7 @@ declare const initMonoriseStore: () => Promise<{
|
|
|
150
156
|
};
|
|
151
157
|
}>), replace?: boolean | undefined, action?: A | undefined): void;
|
|
152
158
|
}>;
|
|
153
|
-
}
|
|
159
|
+
};
|
|
154
160
|
export { initMonoriseStore };
|
|
155
161
|
export type MonoriseStore = Awaited<ReturnType<typeof initMonoriseStore>>['monoriseStore'];
|
|
156
162
|
//# sourceMappingURL=monorise.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorise.store.d.ts","sourceRoot":"","sources":["../../store/monorise.store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"monorise.store.d.ts","sourceRoot":"","sources":["../../store/monorise.store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,MAAM,EACN,oBAAoB,EACpB,MAAM,EACP,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAc,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAe1D,KAAK,OAAO,GAAG;IACb,MAAM,CAAC,EAAE,MAA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M,CAAC,MAAM,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;kBACjD;gBACJ,cAAc,EAAE,OAAO,CAAC;gBACxB,OAAO,EAAE;oBACP,WAAW,EAAE,MAAM,CAAC;oBACpB,KAAK,EAAE,MAAM,CAAC;oBACd,SAAS,EAAE,MAAM,CAAC;iBACnB,CAAC;aACH;;;CAqCR,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CACrC,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { enableMapSet } from 'immer';
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
import { devtools } from 'zustand/middleware';
|
|
4
|
-
import { getEntityConfig } from '../lib/config';
|
|
5
4
|
enableMapSet();
|
|
6
5
|
const configureDevtools = (storeName) => {
|
|
7
6
|
var _a;
|
|
@@ -16,17 +15,9 @@ const configureDevtools = (storeName) => {
|
|
|
16
15
|
},
|
|
17
16
|
});
|
|
18
17
|
};
|
|
19
|
-
const initMonoriseStore =
|
|
18
|
+
const initMonoriseStore = () => {
|
|
20
19
|
let options = {};
|
|
21
20
|
const { modals = {} } = options;
|
|
22
|
-
const entityMaps = Object.keys(await getEntityConfig()).reduce((acc, entity) => {
|
|
23
|
-
acc[entity] = {
|
|
24
|
-
dataMap: new Map(),
|
|
25
|
-
isFirstFetched: false,
|
|
26
|
-
lastKey: '',
|
|
27
|
-
};
|
|
28
|
-
return acc;
|
|
29
|
-
}, {});
|
|
30
21
|
const monoriseStore = create(devtools(() => ({
|
|
31
22
|
app: {
|
|
32
23
|
ongoingRequests: new Map(),
|
|
@@ -38,7 +29,8 @@ const initMonoriseStore = async () => {
|
|
|
38
29
|
name: null,
|
|
39
30
|
},
|
|
40
31
|
},
|
|
41
|
-
|
|
32
|
+
config: {},
|
|
33
|
+
entity: {},
|
|
42
34
|
mutual: {},
|
|
43
35
|
tag: {},
|
|
44
36
|
auth: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monorise.store.js","sourceRoot":"","sources":["../../store/monorise.store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monorise.store.js","sourceRoot":"","sources":["../../store/monorise.store.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,YAAY,EAAE,CAAC;AAEf,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;;IAAC,OAAA,CAAC;QAChD,IAAI,EAAE,GAAG,SAAS,QAAQ;QAC1B,mBAAmB,EAAE,GAAG,SAAS,CAAC,WAAW,EAAE,SAAS;QACxD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,mCAAI,EAAE,CAAC;QAC7E,SAAS,EAAE;YACT,OAAO,EAAE;gBACP,GAAG,EAAE,IAAI;aACV;SACF;KACF,CAAC,CAAA;CAAA,CAAC;AAMH,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,IAAI,OAAO,GAAY,EAAE,CAAC;IAC1B,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAIhC,MAAM,aAAa,GAAG,MAAM,CAC1B,QAAQ,CACN,GAwBE,EAAE,CAAC,CAAC;QACJ,GAAG,EAAE;YACH,eAAe,EAAE,IAAI,GAAG,EAAE;YAC1B,SAAS,EAAE,IAAI,GAAG,EAAE;YACpB,YAAY,EAAE,IAAI,GAAG,EAAE;YACvB,cAAc,EAAE,EAAE;YAClB,UAAU,EAAE,IAAI,GAAG,EAAE;YACrB,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI;aACX;SACF;QACD,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,MAAM,EAAE,EAAE;QACV,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACJ,cAAc,EAAE,KAAK;YACrB,OAAO,EAAE;gBACP,WAAW,EAAE,EAAE;gBACf,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,EAAE;aACd;SACF;KACF,CAAC,EACF,iBAAiB,CAAC,UAAU,CAAC,CAC9B,CACF,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,IAAa,EAAE,EAAE;QACnC,OAAO,mCACF,OAAO,GACP,IAAI,CACR,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AACvC,CAAC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Entity, MonoriseEntityConfig } from '@monorise/base';
|
|
1
2
|
import { initAppActions } from './actions/app.action';
|
|
2
3
|
import { initAuthActions } from './actions/auth.action';
|
|
4
|
+
import { initConfigActions } from './actions/config.action';
|
|
3
5
|
import { initCoreActions } from './actions/core.action';
|
|
4
6
|
import { initAxiosInterceptor, injectAxiosInterceptor } from './lib/api';
|
|
5
7
|
import initAuthService from './services/auth.service';
|
|
@@ -14,17 +16,19 @@ type Options<T extends Record<string, React.ComponentType<any>>> = {
|
|
|
14
16
|
mutualBaseUrl?: string;
|
|
15
17
|
tagBaseUrl?: string;
|
|
16
18
|
modals?: T;
|
|
19
|
+
entityConfig: Record<Entity, MonoriseEntityConfig>;
|
|
17
20
|
};
|
|
18
21
|
|
|
19
|
-
const initMonorise =
|
|
22
|
+
const initMonorise = () => {
|
|
20
23
|
const { monoriseStore: store, setOptions: setMonoriseOptions } =
|
|
21
|
-
|
|
24
|
+
initMonoriseStore();
|
|
22
25
|
const appActions = initAppActions(store);
|
|
26
|
+
const configActions = initConfigActions(store);
|
|
23
27
|
const axios = initAxiosInterceptor(store, appActions);
|
|
24
28
|
|
|
25
29
|
const authService = initAuthService(axios);
|
|
26
30
|
const filestoreService = initFilestoreService(axios);
|
|
27
|
-
const coreService = initCoreService(axios);
|
|
31
|
+
const coreService = initCoreService(store, axios);
|
|
28
32
|
|
|
29
33
|
const authActions = initAuthActions(store, authService);
|
|
30
34
|
const coreActions = initCoreActions(store, appActions, coreService);
|
|
@@ -37,6 +41,7 @@ const initMonorise = async () => {
|
|
|
37
41
|
setMonoriseOptions({
|
|
38
42
|
modals: opts.modals,
|
|
39
43
|
});
|
|
44
|
+
configActions.setConfig(opts.entityConfig);
|
|
40
45
|
authService.setOptions({
|
|
41
46
|
apiBaseUrl: opts.authBaseUrl,
|
|
42
47
|
});
|
|
@@ -57,13 +62,14 @@ const initMonorise = async () => {
|
|
|
57
62
|
authService,
|
|
58
63
|
filestoreService,
|
|
59
64
|
coreService,
|
|
65
|
+
...configActions,
|
|
60
66
|
...appActions,
|
|
61
67
|
...authActions,
|
|
62
68
|
...coreActions,
|
|
63
69
|
};
|
|
64
70
|
};
|
|
65
71
|
|
|
66
|
-
const Monorise =
|
|
72
|
+
const Monorise = initMonorise();
|
|
67
73
|
|
|
68
74
|
const {
|
|
69
75
|
store,
|
|
@@ -71,6 +77,9 @@ const {
|
|
|
71
77
|
authService,
|
|
72
78
|
filestoreService,
|
|
73
79
|
coreService,
|
|
80
|
+
setConfig,
|
|
81
|
+
getConfig,
|
|
82
|
+
useConfig,
|
|
74
83
|
startLoading,
|
|
75
84
|
endLoading,
|
|
76
85
|
setError,
|
|
@@ -111,6 +120,9 @@ export {
|
|
|
111
120
|
authService,
|
|
112
121
|
filestoreService,
|
|
113
122
|
coreService,
|
|
123
|
+
setConfig,
|
|
124
|
+
getConfig,
|
|
125
|
+
useConfig,
|
|
114
126
|
startLoading,
|
|
115
127
|
endLoading,
|
|
116
128
|
setError,
|
|
@@ -144,3 +156,5 @@ export {
|
|
|
144
156
|
useMutuals,
|
|
145
157
|
useEntityState,
|
|
146
158
|
};
|
|
159
|
+
|
|
160
|
+
export default Monorise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monorise/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,17 +14,19 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@monorise/base": "
|
|
17
|
+
"@monorise/base": "^1.0.2",
|
|
18
18
|
"@tabler/icons-react": "^3.30.0",
|
|
19
19
|
"axios": "^1.8.1",
|
|
20
20
|
"immer": "^10.1.1",
|
|
21
|
-
"react": "^18",
|
|
22
|
-
"react-dom": "^18",
|
|
23
21
|
"sonner": "^2.0.1",
|
|
24
22
|
"zustand": "^4.5.2"
|
|
25
23
|
},
|
|
26
24
|
"devDependencies": {
|
|
27
25
|
"@types/react": "^18",
|
|
28
26
|
"@types/react-dom": "^18"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18",
|
|
30
|
+
"react-dom": "^18"
|
|
29
31
|
}
|
|
30
32
|
}
|
package/actions/app.action.ts
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { produce } from 'immer';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import type { ApplicationRequestError, ModalProps } from '../types/api.type';
|
|
4
|
-
import type { MonoriseStore } from '../store/monorise.store';
|
|
5
|
-
|
|
6
|
-
type StartLoadingPayload<T> = {
|
|
7
|
-
requestKey: string;
|
|
8
|
-
isInterruptive?: boolean;
|
|
9
|
-
message?: string | boolean;
|
|
10
|
-
request: Promise<T>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type EndLoadingPayload = {
|
|
14
|
-
requestKey: string;
|
|
15
|
-
isInterruptive?: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type SetErrorPayload = {
|
|
19
|
-
requestKey: string;
|
|
20
|
-
error: ApplicationRequestError;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type Options = {
|
|
24
|
-
modals?: Record<string, React.ComponentType<unknown>>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const initAppActions = (store: MonoriseStore) => {
|
|
28
|
-
let options: Options = {};
|
|
29
|
-
|
|
30
|
-
const { modals = {} } = options;
|
|
31
|
-
type AppModalProps = ModalProps<typeof modals>;
|
|
32
|
-
|
|
33
|
-
const startLoading = <T>({
|
|
34
|
-
requestKey,
|
|
35
|
-
isInterruptive,
|
|
36
|
-
message,
|
|
37
|
-
request,
|
|
38
|
-
}: StartLoadingPayload<T>) => {
|
|
39
|
-
store.setState(
|
|
40
|
-
produce((state) => {
|
|
41
|
-
const stackType = isInterruptive ? 'intLoadStack' : 'loadStack';
|
|
42
|
-
const requestKeyCount = state.app[stackType].get(requestKey);
|
|
43
|
-
|
|
44
|
-
state.app.loadingMessage =
|
|
45
|
-
typeof message === 'string' ? message : 'Loading';
|
|
46
|
-
state.app.ongoingRequests.set(requestKey, request);
|
|
47
|
-
state.app[stackType].set(
|
|
48
|
-
requestKey,
|
|
49
|
-
requestKeyCount ? requestKeyCount + 1 : 1,
|
|
50
|
-
);
|
|
51
|
-
}),
|
|
52
|
-
undefined,
|
|
53
|
-
`mr/start-loading/${requestKey}`,
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const endLoading = ({ requestKey, isInterruptive }: EndLoadingPayload) => {
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
store.setState(
|
|
60
|
-
produce((state) => {
|
|
61
|
-
const stackType = isInterruptive ? 'intLoadStack' : 'loadStack';
|
|
62
|
-
const requestKeyCount = state.app[stackType].get(requestKey);
|
|
63
|
-
|
|
64
|
-
if (state.app.ongoingRequests.has(requestKey)) {
|
|
65
|
-
state.app.ongoingRequests.delete(requestKey);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (typeof requestKeyCount === 'number' && requestKeyCount > 1) {
|
|
69
|
-
state.app[stackType].set(requestKey, requestKeyCount - 1);
|
|
70
|
-
} else {
|
|
71
|
-
state.app[stackType].delete(requestKey);
|
|
72
|
-
}
|
|
73
|
-
}),
|
|
74
|
-
undefined,
|
|
75
|
-
`mr/end-loading/${requestKey}`,
|
|
76
|
-
);
|
|
77
|
-
}, 500);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const checkIsLoading = (requestKey?: string) => {
|
|
81
|
-
const { intLoadStack, loadStack } = store.getState().app;
|
|
82
|
-
if (!requestKey) {
|
|
83
|
-
return intLoadStack.size > 0 || loadStack.size > 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const activeIntLoadingCount = intLoadStack.get(requestKey);
|
|
87
|
-
const isIntLoading =
|
|
88
|
-
typeof activeIntLoadingCount === 'number' && activeIntLoadingCount > 0;
|
|
89
|
-
|
|
90
|
-
const activeLoadingCount = loadStack.get(requestKey);
|
|
91
|
-
const isLoading =
|
|
92
|
-
typeof activeLoadingCount === 'number' && activeLoadingCount > 0;
|
|
93
|
-
|
|
94
|
-
return isIntLoading || isLoading;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const setError = ({ requestKey, error }: SetErrorPayload) =>
|
|
98
|
-
store.setState(
|
|
99
|
-
produce((state) => {
|
|
100
|
-
state.app.errorStack.set(requestKey, error);
|
|
101
|
-
}),
|
|
102
|
-
undefined,
|
|
103
|
-
`mr/set-error/${requestKey}`,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const getError = (requestKey: string) => {
|
|
107
|
-
const { errorStack } = store.getState().app;
|
|
108
|
-
return errorStack.get(requestKey);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const clearError = (requestKey: string) => {
|
|
112
|
-
const { errorStack } = store.getState().app;
|
|
113
|
-
|
|
114
|
-
if (errorStack.has(requestKey)) {
|
|
115
|
-
store.setState(
|
|
116
|
-
produce((state) => {
|
|
117
|
-
state.app.errorStack.delete(requestKey);
|
|
118
|
-
}),
|
|
119
|
-
undefined,
|
|
120
|
-
`mr/clear-error/${requestKey}`,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const openModal = (modal: {
|
|
126
|
-
name: keyof AppModalProps;
|
|
127
|
-
context?: AppModalProps[keyof AppModalProps];
|
|
128
|
-
}) =>
|
|
129
|
-
store.setState(
|
|
130
|
-
produce((state) => {
|
|
131
|
-
state.app.modal = modal;
|
|
132
|
-
}),
|
|
133
|
-
undefined,
|
|
134
|
-
`mr/open-modal/${modal.name}`,
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const closeModal = () =>
|
|
138
|
-
store.setState(
|
|
139
|
-
produce((state) => {
|
|
140
|
-
state.app.modal = { name: null };
|
|
141
|
-
}),
|
|
142
|
-
undefined,
|
|
143
|
-
'mr/close-modal',
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
const useLoadStore = (requestKey?: string) => {
|
|
147
|
-
const { loadStack, intLoadStack } = store((state) => ({
|
|
148
|
-
loadStack: state.app.loadStack,
|
|
149
|
-
intLoadStack: state.app.intLoadStack,
|
|
150
|
-
}));
|
|
151
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
152
|
-
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
if (loadStack && intLoadStack && requestKey) {
|
|
155
|
-
setIsLoading(checkIsLoading(requestKey));
|
|
156
|
-
}
|
|
157
|
-
}, [loadStack, intLoadStack, requestKey]);
|
|
158
|
-
|
|
159
|
-
return isLoading;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const useInterruptiveLoadStore = () => {
|
|
163
|
-
const { intLoadStack, loadingMessage } = store((state) => ({
|
|
164
|
-
intLoadStack: state.app.intLoadStack,
|
|
165
|
-
loadingMessage: state.app.loadingMessage,
|
|
166
|
-
}));
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
isLoading: intLoadStack.size > 0,
|
|
170
|
-
message: loadingMessage,
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const useErrorStore = (requestKey: string) => {
|
|
175
|
-
const error = store((state) => state.app.errorStack.get(requestKey));
|
|
176
|
-
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
if (error) {
|
|
179
|
-
return () => {
|
|
180
|
-
clearError(requestKey);
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}, [error, requestKey]);
|
|
184
|
-
|
|
185
|
-
return error;
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const useModalStore = () => {
|
|
189
|
-
return store((state) => state.app.modal);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const setOptions = (opts: Options) => {
|
|
193
|
-
options = {
|
|
194
|
-
...options,
|
|
195
|
-
...opts,
|
|
196
|
-
};
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
return {
|
|
200
|
-
startLoading,
|
|
201
|
-
endLoading,
|
|
202
|
-
setError,
|
|
203
|
-
getError,
|
|
204
|
-
clearError,
|
|
205
|
-
openModal,
|
|
206
|
-
closeModal,
|
|
207
|
-
checkIsLoading,
|
|
208
|
-
useLoadStore,
|
|
209
|
-
useInterruptiveLoadStore,
|
|
210
|
-
useErrorStore,
|
|
211
|
-
useModalStore,
|
|
212
|
-
setOptions,
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export { initAppActions };
|
|
217
|
-
|
|
218
|
-
export type AppActions = ReturnType<typeof initAppActions>;
|