@monorise/react 1.0.12 → 3.0.1
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/auth.action.d.ts +4 -1
- package/dist/actions/auth.action.d.ts.map +1 -1
- package/dist/actions/auth.action.js +7 -6
- package/dist/actions/auth.action.js.map +1 -1
- package/dist/actions/core.action.d.ts +163 -12
- package/dist/actions/core.action.d.ts.map +1 -1
- package/dist/actions/core.action.js +594 -168
- package/dist/actions/core.action.js.map +1 -1
- package/dist/index.d.ts +456 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +15 -5
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +12 -6
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +24 -0
- package/dist/lib/utils.js.map +1 -1
- package/dist/services/core.service.d.ts +9 -1
- package/dist/services/core.service.d.ts.map +1 -1
- package/dist/services/core.service.js +32 -20
- package/dist/services/core.service.js.map +1 -1
- package/dist/services/filestore.service.d.ts +4 -1
- package/dist/services/filestore.service.d.ts.map +1 -1
- package/dist/services/filestore.service.js +49 -4
- package/dist/services/filestore.service.js.map +1 -1
- package/dist/store/monorise.store.d.ts +6 -0
- package/dist/store/monorise.store.d.ts.map +1 -1
- package/dist/store/monorise.store.js +1 -0
- package/dist/store/monorise.store.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/api.type.d.ts +2 -0
- package/dist/types/api.type.d.ts.map +1 -1
- package/dist/types/api.type.js.map +1 -1
- package/package.json +20 -10
- package/actions/app.action.ts +0 -218
- package/actions/auth.action.ts +0 -94
- package/actions/config.action.ts +0 -51
- package/actions/core.action.ts +0 -940
- package/dist/index.esm.js +0 -1601
- package/dist/index.jsx +0 -48
- package/dist/index.jsx.map +0 -1
- package/dist/lib/api.jsx +0 -70
- package/dist/lib/api.jsx.map +0 -1
- package/dist/lib/config.d.ts +0 -5
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -24
- package/dist/lib/config.js.map +0 -1
- package/index.ts +0 -194
- package/lib/api.ts +0 -150
- package/lib/constant.ts +0 -1
- package/lib/entity.ts +0 -76
- package/lib/utils.ts +0 -12
- package/services/auth.service.ts +0 -65
- package/services/core.service.ts +0 -415
- package/services/filestore.service.ts +0 -136
- package/store/monorise.store.ts +0 -105
- package/tsconfig.json +0 -118
- package/types/api.type.ts +0 -57
- package/types/axios.type.ts +0 -14
- package/types/monorise.type.ts +0 -8
- package/types/mutual.type.ts +0 -32
package/dist/index.jsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
//# source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,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"}
|
package/dist/lib/api.jsx
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { IconCircleCheckFilled } from '@tabler/icons-react';
|
|
2
|
-
import request from 'axios';
|
|
3
|
-
import { Fragment } from 'react';
|
|
4
|
-
import { toast } from 'sonner';
|
|
5
|
-
const initAxiosInterceptor = (store, appActions) => {
|
|
6
|
-
const { startLoading } = appActions;
|
|
7
|
-
const axiosInstance = request.create();
|
|
8
|
-
function makeRequest(url, config, data) {
|
|
9
|
-
const { requestKey, isInterruptive = false, feedback } = config;
|
|
10
|
-
const { ongoingRequests } = store.getState().app;
|
|
11
|
-
if (ongoingRequests.has(requestKey)) {
|
|
12
|
-
return ongoingRequests.get(requestKey);
|
|
13
|
-
}
|
|
14
|
-
const promise = axiosInstance.request(Object.assign(Object.assign({}, config), { url,
|
|
15
|
-
data, headers: {
|
|
16
|
-
'Mr-Interruptive': String(isInterruptive),
|
|
17
|
-
} }));
|
|
18
|
-
startLoading({
|
|
19
|
-
requestKey,
|
|
20
|
-
isInterruptive,
|
|
21
|
-
message: feedback === null || feedback === void 0 ? void 0 : feedback.loading,
|
|
22
|
-
request: promise,
|
|
23
|
-
});
|
|
24
|
-
return promise;
|
|
25
|
-
}
|
|
26
|
-
const axios = Object.assign(Object.assign({}, axiosInstance), { post: (url, data, config) => makeRequest(url, Object.assign(Object.assign({}, config), { method: 'POST' }), data), put: (url, data, config) => makeRequest(url, Object.assign(Object.assign({}, config), { method: 'PUT' }), data), patch: (url, data, config) => makeRequest(url, Object.assign(Object.assign({}, config), { method: 'PATCH' }), data), delete: (url, config) => makeRequest(url, Object.assign(Object.assign({}, config), { method: 'DELETE' })), get: (url, config) => makeRequest(url, Object.assign(Object.assign({}, config), { method: 'GET' })) });
|
|
27
|
-
return axios;
|
|
28
|
-
};
|
|
29
|
-
const injectAxiosInterceptor = (appActions, authActions, axios) => {
|
|
30
|
-
const { endLoading, setError, clearError } = appActions;
|
|
31
|
-
const { setIsUnauthorized } = authActions;
|
|
32
|
-
const unknownError = {
|
|
33
|
-
code: 'UNKNOWN_EXCEPTION',
|
|
34
|
-
message: "Ops, something doesn't seems right",
|
|
35
|
-
};
|
|
36
|
-
axios.interceptors.response.use((response) => {
|
|
37
|
-
const { requestKey, isInterruptive, feedback } = response.config;
|
|
38
|
-
endLoading({ requestKey, isInterruptive });
|
|
39
|
-
clearError(requestKey);
|
|
40
|
-
if (!(feedback === null || feedback === void 0 ? void 0 : feedback.success)) {
|
|
41
|
-
return Promise.resolve(response);
|
|
42
|
-
}
|
|
43
|
-
switch (typeof feedback.success) {
|
|
44
|
-
case 'function':
|
|
45
|
-
toast(feedback.success(response.data));
|
|
46
|
-
break;
|
|
47
|
-
case 'string':
|
|
48
|
-
toast(<Fragment>
|
|
49
|
-
<IconCircleCheckFilled color='rgb(34 197 94)'/>
|
|
50
|
-
{feedback.success}
|
|
51
|
-
</Fragment>);
|
|
52
|
-
break;
|
|
53
|
-
case 'boolean':
|
|
54
|
-
toast('Request success');
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
return Promise.resolve(response);
|
|
58
|
-
}, (error) => {
|
|
59
|
-
var _a, _b;
|
|
60
|
-
const { requestKey, isInterruptive } = error.config;
|
|
61
|
-
endLoading({ requestKey, isInterruptive });
|
|
62
|
-
setError({ requestKey, error: ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || unknownError });
|
|
63
|
-
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 401) {
|
|
64
|
-
setIsUnauthorized(true);
|
|
65
|
-
}
|
|
66
|
-
return Promise.reject(error);
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
export { initAxiosInterceptor, injectAxiosInterceptor };
|
|
70
|
-
//# sourceMappingURL=api.jsx.map
|
package/dist/lib/api.jsx.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.jsx","sourceRoot":"","sources":["../../lib/api.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,OAIN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAM/B,MAAM,oBAAoB,GAAG,CAAC,KAAoB,EAAE,UAAsB,EAAE,EAAE;IAC5E,MAAM,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC;IAEpC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEvC,SAAS,WAAW,CAClB,GAAW,EACX,MAA6B,EAC7B,IAAQ;QAER,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QAChE,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC;QAEjD,IAAI,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,OAAO,eAAe,CAAC,GAAG,CAAC,UAAU,CAAe,CAAC;QACvD,CAAC;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO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AE,UAAU,EAAE,KAAK,EAAE,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,KAAI,YAAY,EAAE,CAAC,CAAC;QACtE,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;YACnC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
package/dist/lib/config.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { MonoriseConfig } from '@monorise/base';
|
|
2
|
-
export declare function loadConfig(configPath: string): Promise<MonoriseConfig>;
|
|
3
|
-
export declare function getConfig(): MonoriseConfig;
|
|
4
|
-
export declare function getEntityConfig(): Promise<any>;
|
|
5
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAiB5E;AAED,wBAAgB,SAAS,IAAI,cAAc,CAO1C;AAED,wBAAsB,eAAe,iBAEpC"}
|
package/dist/lib/config.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
let config = null;
|
|
2
|
-
export async function loadConfig(configPath) {
|
|
3
|
-
try {
|
|
4
|
-
const module = await import(configPath);
|
|
5
|
-
config = module.default;
|
|
6
|
-
if (!config.configPath) {
|
|
7
|
-
throw new Error('Configuration file must export a `customPath` property.');
|
|
8
|
-
}
|
|
9
|
-
return config;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
throw new Error(`Failed to load configuration file at ${configPath}: ${error.message}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function getConfig() {
|
|
16
|
-
if (!config) {
|
|
17
|
-
throw new Error('Configuration has not been loaded. Call `loadConfig()` first.');
|
|
18
|
-
}
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
export async function getEntityConfig() {
|
|
22
|
-
return await import(getConfig().configPath);
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=config.js.map
|
package/dist/lib/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/config.ts"],"names":[],"mappings":"AAGA,IAAI,MAAM,GAA0B,IAAI,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,GAAG,MAAM,CAAC,OAAyB,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,wCAAwC,UAAU,KAAM,KAAe,CAAC,OAAO,EAAE,CAClF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,OAAO,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,CAAC;AAC9C,CAAC"}
|
package/index.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import type { Entity, MonoriseEntityConfig } from '@monorise/base';
|
|
2
|
-
import type { AxiosResponse } from 'axios';
|
|
3
|
-
import { initAppActions } from './actions/app.action';
|
|
4
|
-
import { initAuthActions } from './actions/auth.action';
|
|
5
|
-
import { initConfigActions } from './actions/config.action';
|
|
6
|
-
import { initCoreActions } from './actions/core.action';
|
|
7
|
-
import { initAxiosInterceptor, injectAxiosInterceptor } from './lib/api';
|
|
8
|
-
import initAuthService from './services/auth.service';
|
|
9
|
-
import initCoreService from './services/core.service';
|
|
10
|
-
import initFilestoreService from './services/filestore.service';
|
|
11
|
-
import { initMonoriseStore } from './store/monorise.store';
|
|
12
|
-
import {
|
|
13
|
-
Mutual,
|
|
14
|
-
MutualData,
|
|
15
|
-
MutualDataMapping,
|
|
16
|
-
MutualDataWithIndex,
|
|
17
|
-
} from './types/mutual.type';
|
|
18
|
-
|
|
19
|
-
type Options<T extends Record<string, React.ComponentType<any>>> = {
|
|
20
|
-
authBaseUrl?: string;
|
|
21
|
-
filestoreBaseUrl?: string;
|
|
22
|
-
entityBaseUrl?: string;
|
|
23
|
-
mutualBaseUrl?: string;
|
|
24
|
-
tagBaseUrl?: string;
|
|
25
|
-
modals?: T;
|
|
26
|
-
entityConfig: Record<Entity, MonoriseEntityConfig>;
|
|
27
|
-
onApiSuccess?: <T>(
|
|
28
|
-
response: AxiosResponse<T>,
|
|
29
|
-
feedbackSuccess:
|
|
30
|
-
| ((data: AxiosResponse<T>['data']) => React.ReactNode)
|
|
31
|
-
| string
|
|
32
|
-
| boolean,
|
|
33
|
-
) => void;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const initMonorise = () => {
|
|
37
|
-
const { monoriseStore: store, setOptions: setMonoriseOptions } =
|
|
38
|
-
initMonoriseStore();
|
|
39
|
-
const appActions = initAppActions(store);
|
|
40
|
-
const configActions = initConfigActions(store);
|
|
41
|
-
const axios = initAxiosInterceptor(store, appActions);
|
|
42
|
-
|
|
43
|
-
const authService = initAuthService(axios);
|
|
44
|
-
const filestoreService = initFilestoreService(axios);
|
|
45
|
-
const coreService = initCoreService(store, axios);
|
|
46
|
-
|
|
47
|
-
const authActions = initAuthActions(store, authService);
|
|
48
|
-
const coreActions = initCoreActions(store, appActions, coreService);
|
|
49
|
-
|
|
50
|
-
const axiosInterceptor = injectAxiosInterceptor(
|
|
51
|
-
appActions,
|
|
52
|
-
authActions,
|
|
53
|
-
axios,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const config = <T extends Record<string, React.ComponentType<any>>>(
|
|
57
|
-
opts: Options<T>,
|
|
58
|
-
) => {
|
|
59
|
-
setMonoriseOptions({
|
|
60
|
-
modals: opts.modals,
|
|
61
|
-
});
|
|
62
|
-
configActions.setConfig(opts.entityConfig);
|
|
63
|
-
authService.setOptions({
|
|
64
|
-
apiBaseUrl: opts.authBaseUrl,
|
|
65
|
-
});
|
|
66
|
-
filestoreService.setOptions({
|
|
67
|
-
apiBaseUrl: opts.filestoreBaseUrl,
|
|
68
|
-
});
|
|
69
|
-
coreService.setOptions({
|
|
70
|
-
entityApiBaseUrl: opts.entityBaseUrl,
|
|
71
|
-
mutualApiBaseUrl: opts.mutualBaseUrl,
|
|
72
|
-
tagApiBaseUrl: opts.tagBaseUrl,
|
|
73
|
-
});
|
|
74
|
-
axiosInterceptor.setOptions({
|
|
75
|
-
onApiSuccess: opts.onApiSuccess,
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
config,
|
|
81
|
-
store,
|
|
82
|
-
axios,
|
|
83
|
-
authService,
|
|
84
|
-
filestoreService,
|
|
85
|
-
coreService,
|
|
86
|
-
...configActions,
|
|
87
|
-
...appActions,
|
|
88
|
-
...authActions,
|
|
89
|
-
...coreActions,
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const Monorise = initMonorise();
|
|
94
|
-
|
|
95
|
-
const {
|
|
96
|
-
store,
|
|
97
|
-
axios,
|
|
98
|
-
authService,
|
|
99
|
-
filestoreService,
|
|
100
|
-
coreService,
|
|
101
|
-
setConfig,
|
|
102
|
-
getConfig,
|
|
103
|
-
useConfig,
|
|
104
|
-
startLoading,
|
|
105
|
-
endLoading,
|
|
106
|
-
setError,
|
|
107
|
-
getError,
|
|
108
|
-
clearError,
|
|
109
|
-
openModal,
|
|
110
|
-
closeModal,
|
|
111
|
-
useLoadStore,
|
|
112
|
-
useInterruptiveLoadStore,
|
|
113
|
-
useErrorStore,
|
|
114
|
-
useModalStore,
|
|
115
|
-
requestLogin,
|
|
116
|
-
useProfile,
|
|
117
|
-
getProfile,
|
|
118
|
-
useIsUnauthorized,
|
|
119
|
-
setIsUnauthorized,
|
|
120
|
-
logout,
|
|
121
|
-
listMoreEntities,
|
|
122
|
-
createEntity,
|
|
123
|
-
upsertEntity,
|
|
124
|
-
editEntity,
|
|
125
|
-
updateLocalEntity,
|
|
126
|
-
deleteEntity,
|
|
127
|
-
getMutual,
|
|
128
|
-
createMutual,
|
|
129
|
-
upsertLocalMutual,
|
|
130
|
-
editMutual,
|
|
131
|
-
deleteMutual,
|
|
132
|
-
deleteLocalMutual,
|
|
133
|
-
useEntity,
|
|
134
|
-
useEntities,
|
|
135
|
-
useMutual,
|
|
136
|
-
useMutuals,
|
|
137
|
-
useEntityState,
|
|
138
|
-
} = Monorise;
|
|
139
|
-
|
|
140
|
-
export {
|
|
141
|
-
store,
|
|
142
|
-
axios,
|
|
143
|
-
authService,
|
|
144
|
-
filestoreService,
|
|
145
|
-
coreService,
|
|
146
|
-
setConfig,
|
|
147
|
-
getConfig,
|
|
148
|
-
useConfig,
|
|
149
|
-
startLoading,
|
|
150
|
-
endLoading,
|
|
151
|
-
setError,
|
|
152
|
-
getError,
|
|
153
|
-
clearError,
|
|
154
|
-
openModal,
|
|
155
|
-
closeModal,
|
|
156
|
-
useLoadStore,
|
|
157
|
-
useInterruptiveLoadStore,
|
|
158
|
-
useErrorStore,
|
|
159
|
-
useModalStore,
|
|
160
|
-
requestLogin,
|
|
161
|
-
useProfile,
|
|
162
|
-
getProfile,
|
|
163
|
-
useIsUnauthorized,
|
|
164
|
-
setIsUnauthorized,
|
|
165
|
-
logout,
|
|
166
|
-
listMoreEntities,
|
|
167
|
-
createEntity,
|
|
168
|
-
upsertEntity,
|
|
169
|
-
editEntity,
|
|
170
|
-
updateLocalEntity,
|
|
171
|
-
deleteEntity,
|
|
172
|
-
getMutual,
|
|
173
|
-
createMutual,
|
|
174
|
-
upsertLocalMutual,
|
|
175
|
-
editMutual,
|
|
176
|
-
deleteMutual,
|
|
177
|
-
deleteLocalMutual,
|
|
178
|
-
useEntity,
|
|
179
|
-
useEntities,
|
|
180
|
-
useMutual,
|
|
181
|
-
useMutuals,
|
|
182
|
-
useEntityState,
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
export default Monorise;
|
|
186
|
-
|
|
187
|
-
export { MutualDataWithIndex, MutualDataMapping, MutualData, Mutual };
|
|
188
|
-
|
|
189
|
-
export type {
|
|
190
|
-
CreatedEntity,
|
|
191
|
-
DraftEntity,
|
|
192
|
-
Entity,
|
|
193
|
-
EntitySchemaMap,
|
|
194
|
-
} from '@monorise/base';
|
package/lib/api.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import request, {
|
|
2
|
-
type AxiosError,
|
|
3
|
-
type AxiosRequestConfig,
|
|
4
|
-
type AxiosResponse,
|
|
5
|
-
} from 'axios';
|
|
6
|
-
import type { AppActions } from '../actions/app.action';
|
|
7
|
-
import type { AuthActions } from '../actions/auth.action';
|
|
8
|
-
import type { MonoriseStore } from '../store/monorise.store';
|
|
9
|
-
import type { ApplicationRequestError } from '../types/api.type';
|
|
10
|
-
|
|
11
|
-
const initAxiosInterceptor = (store: MonoriseStore, appActions: AppActions) => {
|
|
12
|
-
const { startLoading } = appActions;
|
|
13
|
-
|
|
14
|
-
const axiosInstance = request.create();
|
|
15
|
-
|
|
16
|
-
function makeRequest<T = any, R = AxiosResponse<T, any>, D = any>(
|
|
17
|
-
url: string,
|
|
18
|
-
config: AxiosRequestConfig<D>,
|
|
19
|
-
data?: D,
|
|
20
|
-
): Promise<R> {
|
|
21
|
-
const { requestKey, isInterruptive = false, feedback } = config;
|
|
22
|
-
const { ongoingRequests } = store.getState().app;
|
|
23
|
-
|
|
24
|
-
if (ongoingRequests.has(requestKey)) {
|
|
25
|
-
return ongoingRequests.get(requestKey) as Promise<R>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const promise = axiosInstance.request<T, R, D>({
|
|
29
|
-
...config,
|
|
30
|
-
url,
|
|
31
|
-
data,
|
|
32
|
-
headers: {
|
|
33
|
-
'Mr-Interruptive': String(isInterruptive),
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
startLoading({
|
|
37
|
-
requestKey,
|
|
38
|
-
isInterruptive,
|
|
39
|
-
message: feedback?.loading,
|
|
40
|
-
request: promise,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return promise;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const axios = {
|
|
47
|
-
...axiosInstance,
|
|
48
|
-
post: <T = any, R = AxiosResponse<T, any>, D = any>(
|
|
49
|
-
url: string,
|
|
50
|
-
data: D,
|
|
51
|
-
config: AxiosRequestConfig<D>,
|
|
52
|
-
): Promise<R> => makeRequest(url, { ...config, method: 'POST' }, data),
|
|
53
|
-
put: <T = any, R = AxiosResponse<T, any>, D = any>(
|
|
54
|
-
url: string,
|
|
55
|
-
data: D,
|
|
56
|
-
config: AxiosRequestConfig<D>,
|
|
57
|
-
): Promise<R> => makeRequest(url, { ...config, method: 'PUT' }, data),
|
|
58
|
-
patch: <T = any, R = AxiosResponse<T, any>, D = any>(
|
|
59
|
-
url: string,
|
|
60
|
-
data: D,
|
|
61
|
-
config: AxiosRequestConfig<D>,
|
|
62
|
-
): Promise<R> => makeRequest(url, { ...config, method: 'PATCH' }, data),
|
|
63
|
-
delete: <T = any, R = AxiosResponse<T, any>, D = any>(
|
|
64
|
-
url: string,
|
|
65
|
-
config: AxiosRequestConfig<D>,
|
|
66
|
-
): Promise<R> => makeRequest(url, { ...config, method: 'DELETE' }),
|
|
67
|
-
get: <T = any, R = AxiosResponse<T, any>, D = any>(
|
|
68
|
-
url: string,
|
|
69
|
-
config: AxiosRequestConfig<D>,
|
|
70
|
-
): Promise<R> => makeRequest(url, { ...config, method: 'GET' }),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return axios;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
type ConfigOptions = {
|
|
77
|
-
onApiSuccess?: <T>(
|
|
78
|
-
response: AxiosResponse<T>,
|
|
79
|
-
feedbackSuccess:
|
|
80
|
-
| ((data: AxiosResponse<T>['data']) => React.ReactNode)
|
|
81
|
-
| string
|
|
82
|
-
| boolean,
|
|
83
|
-
) => void;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const injectAxiosInterceptor = (
|
|
87
|
-
appActions: AppActions,
|
|
88
|
-
authActions: AuthActions,
|
|
89
|
-
axios: ReturnType<typeof initAxiosInterceptor>,
|
|
90
|
-
opts?: ConfigOptions,
|
|
91
|
-
) => {
|
|
92
|
-
let options: ConfigOptions = opts || {};
|
|
93
|
-
const { endLoading, setError, clearError } = appActions;
|
|
94
|
-
const { setIsUnauthorized } = authActions;
|
|
95
|
-
|
|
96
|
-
const unknownError: ApplicationRequestError = {
|
|
97
|
-
code: 'UNKNOWN_EXCEPTION',
|
|
98
|
-
message: "Ops, something doesn't seems right",
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
axios.interceptors.response.use(
|
|
102
|
-
(response) => {
|
|
103
|
-
const { requestKey, isInterruptive, feedback } = response.config;
|
|
104
|
-
endLoading({ requestKey, isInterruptive });
|
|
105
|
-
clearError(requestKey);
|
|
106
|
-
|
|
107
|
-
if (feedback?.success) {
|
|
108
|
-
options.onApiSuccess?.(response, feedback.success);
|
|
109
|
-
}
|
|
110
|
-
// switch (typeof feedback.success) {
|
|
111
|
-
// case 'function':
|
|
112
|
-
// toast(feedback.success(response.data));
|
|
113
|
-
// break;
|
|
114
|
-
// case 'string':
|
|
115
|
-
// toast(
|
|
116
|
-
// <Fragment>
|
|
117
|
-
// <IconCircleCheckFilled color='rgb(34 197 94)' />
|
|
118
|
-
// {feedback.success}
|
|
119
|
-
// </Fragment>,
|
|
120
|
-
// );
|
|
121
|
-
// break;
|
|
122
|
-
// case 'boolean':
|
|
123
|
-
// toast('Request success');
|
|
124
|
-
// break;
|
|
125
|
-
// }
|
|
126
|
-
|
|
127
|
-
return Promise.resolve(response);
|
|
128
|
-
},
|
|
129
|
-
(error: AxiosError<ApplicationRequestError>) => {
|
|
130
|
-
const { requestKey, isInterruptive } = error.config as AxiosRequestConfig;
|
|
131
|
-
endLoading({ requestKey, isInterruptive });
|
|
132
|
-
setError({ requestKey, error: error.response?.data || unknownError });
|
|
133
|
-
if (error.response?.status === 401) {
|
|
134
|
-
setIsUnauthorized(true);
|
|
135
|
-
}
|
|
136
|
-
return Promise.reject(error);
|
|
137
|
-
},
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const setOptions = (opts: ConfigOptions) => {
|
|
141
|
-
options = {
|
|
142
|
-
...options,
|
|
143
|
-
...opts,
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
return { setOptions };
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
export { initAxiosInterceptor, injectAxiosInterceptor };
|
package/lib/constant.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const HTML_TAG_REGEX = /<\/?("[^"]*"|'[^']*'|[^>])*(>|$)/g;
|
package/lib/entity.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { CreatedEntity, Entity, EntitySchemaMap } from '@monorise/base';
|
|
2
|
-
import type { Mutual, MutualData } from '../types/mutual.type';
|
|
3
|
-
|
|
4
|
-
export const constructLocal = (
|
|
5
|
-
entityType: Entity,
|
|
6
|
-
entityId: string,
|
|
7
|
-
data: any,
|
|
8
|
-
): CreatedEntity<Entity> => {
|
|
9
|
-
return {
|
|
10
|
-
entityType: entityType as unknown as string,
|
|
11
|
-
entityId,
|
|
12
|
-
data,
|
|
13
|
-
createdAt: new Date().toISOString(),
|
|
14
|
-
updatedAt: new Date().toISOString(),
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const constructMutual = <B extends Entity, T extends Entity>(
|
|
19
|
-
byEntityType: B,
|
|
20
|
-
byEntityId: string,
|
|
21
|
-
entityType: T,
|
|
22
|
-
entityId: string,
|
|
23
|
-
mutualData: Partial<MutualData<B, T>>,
|
|
24
|
-
data: EntitySchemaMap[T],
|
|
25
|
-
): Mutual => {
|
|
26
|
-
return {
|
|
27
|
-
mutualId: `${byEntityId}-${entityId}`,
|
|
28
|
-
byEntityType,
|
|
29
|
-
byEntityId,
|
|
30
|
-
entityType,
|
|
31
|
-
entityId,
|
|
32
|
-
mutualData,
|
|
33
|
-
data,
|
|
34
|
-
createdAt: new Date().toISOString(),
|
|
35
|
-
updatedAt: new Date().toISOString(),
|
|
36
|
-
mutualUpdatedAt: new Date().toISOString(),
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const flipMutual = (mutual: Mutual): Mutual => {
|
|
41
|
-
return {
|
|
42
|
-
...mutual,
|
|
43
|
-
entityId: mutual.byEntityId,
|
|
44
|
-
entityType: mutual.byEntityType,
|
|
45
|
-
byEntityId: mutual.entityId,
|
|
46
|
-
byEntityType: mutual.entityType,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const byMutualIndex = (a: Mutual<any, any>, b: Mutual<any, any>) => {
|
|
51
|
-
return a.mutualData.index - b.mutualData.index;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const byEntityId = (a: CreatedEntity<any>, b: CreatedEntity<any>) => {
|
|
55
|
-
if (b.entityId < a.entityId) return -1;
|
|
56
|
-
return 1;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const constructOrderByIndex = (mutuals: Mutual<any, any>[]) => {
|
|
60
|
-
return mutuals.sort(byMutualIndex).map((mutual) => mutual.entityId);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const injectFields = <T extends Entity>(
|
|
64
|
-
entity: CreatedEntity<T> | undefined,
|
|
65
|
-
fields: Record<string, any>,
|
|
66
|
-
): CreatedEntity<T> | undefined => {
|
|
67
|
-
return entity
|
|
68
|
-
? {
|
|
69
|
-
...entity,
|
|
70
|
-
data: {
|
|
71
|
-
...entity.data,
|
|
72
|
-
...fields,
|
|
73
|
-
},
|
|
74
|
-
}
|
|
75
|
-
: undefined;
|
|
76
|
-
};
|
package/lib/utils.ts
DELETED
package/services/auth.service.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Entity } from '@monorise/base';
|
|
2
|
-
import type { AxiosInterceptor } from '../types/api.type';
|
|
3
|
-
|
|
4
|
-
type LoginPayload = {
|
|
5
|
-
email: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type Options = {
|
|
9
|
-
apiBaseUrl?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const initAuthService = (axios: AxiosInterceptor) => {
|
|
13
|
-
let options: Options = {};
|
|
14
|
-
const { apiBaseUrl = '/api/auth' } = options;
|
|
15
|
-
|
|
16
|
-
const requestLoginMagicLink = (entityType: Entity, payload: LoginPayload) => {
|
|
17
|
-
return axios.post(
|
|
18
|
-
`${apiBaseUrl}/${entityType}`,
|
|
19
|
-
{
|
|
20
|
-
body: { ...payload },
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
requestKey: `auth/${entityType}/request-login`,
|
|
24
|
-
isInterruptive: true,
|
|
25
|
-
feedback: {
|
|
26
|
-
loading: 'Requesting login link',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const getSessionProfile = <T extends Record<string, unknown>>() =>
|
|
33
|
-
axios.get<
|
|
34
|
-
T & {
|
|
35
|
-
displayName: string;
|
|
36
|
-
email: string;
|
|
37
|
-
accountId: string;
|
|
38
|
-
}
|
|
39
|
-
>('/session', {
|
|
40
|
-
requestKey: 'auth/session',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const logout = () =>
|
|
44
|
-
axios.get('/logout', {
|
|
45
|
-
requestKey: 'auth/logout',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const setOptions = (opts: Options) => {
|
|
49
|
-
options = {
|
|
50
|
-
...options,
|
|
51
|
-
...opts,
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
requestLoginMagicLink,
|
|
57
|
-
getSessionProfile,
|
|
58
|
-
logout,
|
|
59
|
-
setOptions,
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default initAuthService;
|
|
64
|
-
|
|
65
|
-
export type AuthService = ReturnType<typeof initAuthService>;
|