dinocollab-core 2.0.0 → 2.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/bin/codegen.js +66 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +2 -2
- package/dist/api-context/drawer-global.js +1 -1
- package/dist/api-context/global-modal.js +1 -1
- package/dist/api-context/popover-global.js +1 -1
- package/dist/api-context/popover.js +1 -1
- package/dist/components/copy-to-clipboard.js +1 -1
- package/dist/components/create.multi-select-dropdown.js +1 -1
- package/dist/components/create.multi-select-dropdown.js.map +1 -1
- package/dist/components/help-tooltip.js +1 -1
- package/dist/data-view/convert-filter-to-graphql.js +1 -1
- package/dist/data-view/convert-filter-to-graphql.js.map +1 -1
- package/dist/data-view/create.active-filters-panel.js +1 -1
- package/dist/data-view/create.active-filters-panel.js.map +1 -1
- package/dist/data-view/create.data-view.js +1 -1
- package/dist/data-view/dino.js +1 -1
- package/dist/data-view/dino.js.map +1 -1
- package/dist/data-view/filter-store.js +1 -1
- package/dist/data-view/filter-store.js.map +1 -1
- package/dist/data-view/index.js +1 -1
- package/dist/data-view/query-param-url.js +1 -1
- package/dist/data-view/query-param-url.js.map +1 -1
- package/dist/data-view/ui.units.js.map +1 -1
- package/dist/data-view/view-mode.content.js +1 -1
- package/dist/form/create.autocomplete.chips.js +1 -1
- package/dist/form/create.date-expired.js +1 -1
- package/dist/form/create.date-expired.js.map +1 -1
- package/dist/form/create.date-picker.js +1 -1
- package/dist/form/create.date-picker.js.map +1 -1
- package/dist/form/create.form-comfirm.js +1 -1
- package/dist/form/create.form-comfirm.js.map +1 -1
- package/dist/form/create.form-grid-layout.js +1 -1
- package/dist/form/create.form-grid-layout.js.map +1 -1
- package/dist/form/create.input-file.csv-local-parser.js +1 -1
- package/dist/form/create.input-file.csv-local-parser.js.map +1 -1
- package/dist/form/create.input.file.js +1 -1
- package/dist/form/create.input.image-file.js +1 -1
- package/dist/form/create.input.js +1 -1
- package/dist/form/create.input.js.map +1 -1
- package/dist/form/create.select-simple.js +1 -1
- package/dist/form/create.select-simple.js.map +1 -1
- package/dist/form/create.select-with-api.js +1 -1
- package/dist/form/create.select-with-api.js.map +1 -1
- package/dist/form/modal-wrapper.js +1 -1
- package/dist/form/modal-wrapper.js.map +1 -1
- package/dist/form/validator.js +1 -1
- package/dist/form/validator.js.map +1 -1
- package/dist/http-service/base/crud-service-base.js +2 -0
- package/dist/http-service/base/crud-service-base.js.map +1 -0
- package/dist/http-service/base/gateway.js +2 -0
- package/dist/http-service/base/gateway.js.map +1 -0
- package/dist/http-service/base/helpers.js +2 -0
- package/dist/http-service/base/helpers.js.map +1 -0
- package/dist/http-service/base/service-base.js +2 -0
- package/dist/http-service/base/service-base.js.map +1 -0
- package/dist/http-service/graphql/app-profile.js +2 -0
- package/dist/http-service/graphql/app-profile.js.map +1 -0
- package/dist/http-service/graphql/graphql-request.js +2 -0
- package/dist/http-service/graphql/graphql-request.js.map +1 -0
- package/dist/http-service/graphql/key-converter.js.map +1 -0
- package/dist/http-service/graphql/request-param.js +2 -0
- package/dist/http-service/graphql/request-param.js.map +1 -0
- package/dist/http-service/graphql/types.js +2 -0
- package/dist/http-service/graphql/types.js.map +1 -0
- package/dist/http-service/index.js +2 -0
- package/dist/http-service/index.js.map +1 -0
- package/dist/mfe-auth/auth-enums.js +2 -0
- package/dist/mfe-auth/auth-enums.js.map +1 -0
- package/dist/mfe-auth/auth-mfe-manager.js +2 -0
- package/dist/mfe-auth/auth-mfe-manager.js.map +1 -0
- package/dist/mfe-auth/auth-mfe-provider.js +2 -0
- package/dist/mfe-auth/auth-mfe-provider.js.map +1 -0
- package/dist/mfe-auth/auth-types.js +2 -0
- package/dist/mfe-auth/auth-types.js.map +1 -0
- package/dist/mfe-auth/index.js +2 -0
- package/dist/mfe-auth/index.js.map +1 -0
- package/dist/mfe-auth/micro-frontend-auth-hooks.js +2 -0
- package/dist/mfe-auth/micro-frontend-auth-hooks.js.map +1 -0
- package/dist/mfe-navigate/index.js +2 -0
- package/dist/mfe-navigate/index.js.map +1 -0
- package/dist/mfe-navigate/mfe-navigate.debug.js +2 -0
- package/dist/mfe-navigate/mfe-navigate.debug.js.map +1 -0
- package/dist/mfe-navigate/mfe-navigate.remote.js +2 -0
- package/dist/mfe-navigate/mfe-navigate.remote.js.map +1 -0
- package/dist/mfe-navigate/nextjs/index.js +2 -0
- package/dist/mfe-navigate/nextjs/index.js.map +1 -0
- package/dist/mfe-navigate/nextjs/provider.js +2 -0
- package/dist/mfe-navigate/nextjs/provider.js.map +1 -0
- package/dist/mfe-navigate/react/index.js +2 -0
- package/dist/mfe-navigate/react/index.js.map +1 -0
- package/dist/mfe-navigate/react/provider.js +2 -0
- package/dist/mfe-navigate/react/provider.js.map +1 -0
- package/dist/redux/create.hoc-lazy.js +1 -1
- package/dist/table/create.action-row.js +1 -1
- package/dist/table/create.action-row.js.map +1 -1
- package/dist/table/create.table.js +1 -1
- package/dist/table/create.table.js.map +1 -1
- package/dist/table/dino.js +1 -1
- package/dist/table/dino.js.map +1 -1
- package/dist/table/helpers.js +1 -1
- package/dist/table/helpers.js.map +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/toolbar-pannel.js +1 -1
- package/dist/table/ui.buttons.js +1 -1
- package/dist/table/ui.buttons.js.map +1 -1
- package/dist/table/ui.units.js +1 -1
- package/dist/table/ui.units.js.map +1 -1
- package/dist/table-grid/create.table-grid.js +1 -1
- package/dist/table-grid/create.table-grid.js.map +1 -1
- package/dist/table-grid/filter-bar/create.filter-bar.js +1 -1
- package/dist/table-grid/item-actions.js +1 -1
- package/dist/table-grid/item-actions.js.map +1 -1
- package/dist/table-grid/toolbar-pannel.js +1 -1
- package/dist/table-grid/toolbar-pannel.js.map +1 -1
- package/dist/table-grid/url-query-param.js +1 -1
- package/dist/table-grid/url-query-param.js.map +1 -1
- package/dist/types/data-view/convert-filter-to-graphql.d.ts +3 -3
- package/dist/types/data-view/dino.d.ts +1 -1
- package/dist/types/data-view/index.d.ts +0 -1
- package/dist/types/http-service/base/crud-service-base.d.ts +68 -0
- package/dist/types/http-service/base/gateway.d.ts +3 -0
- package/dist/types/http-service/base/helpers.d.ts +31 -0
- package/dist/types/http-service/base/index.d.ts +5 -0
- package/dist/types/http-service/base/service-base.d.ts +132 -0
- package/dist/types/http-service/base/type.api-alert.d.ts +17 -0
- package/dist/types/http-service/base/types.d.ts +45 -0
- package/dist/types/http-service/graphql/app-profile.d.ts +17 -0
- package/dist/types/http-service/graphql/graphql-request.d.ts +83 -0
- package/dist/types/http-service/graphql/index.d.ts +5 -0
- package/dist/types/{data-view → http-service/graphql}/key-converter.d.ts +2 -1
- package/dist/types/http-service/graphql/request-param.d.ts +65 -0
- package/dist/types/http-service/graphql/types.d.ts +62 -0
- package/dist/types/http-service/index.d.ts +2 -0
- package/dist/types/mfe-auth/auth-enums.d.ts +40 -0
- package/dist/types/mfe-auth/auth-mfe-manager.d.ts +68 -0
- package/dist/types/mfe-auth/auth-mfe-provider.d.ts +19 -0
- package/dist/types/mfe-auth/auth-types.d.ts +33 -0
- package/dist/types/mfe-auth/index.d.ts +6 -0
- package/dist/types/mfe-auth/micro-frontend-auth-hooks.d.ts +164 -0
- package/dist/types/mfe-navigate/index.d.ts +2 -0
- package/dist/types/mfe-navigate/mfe-navigate.debug.d.ts +4 -0
- package/dist/types/mfe-navigate/mfe-navigate.remote.d.ts +11 -0
- package/dist/types/mfe-navigate/nextjs/index.d.ts +1 -0
- package/dist/types/mfe-navigate/nextjs/provider.d.ts +2 -0
- package/dist/types/mfe-navigate/react/index.d.ts +1 -0
- package/dist/types/mfe-navigate/react/provider.d.ts +3 -0
- package/dist/types/mfe-navigate/types.d.ts +13 -0
- package/dist/types/utils/index.d.ts +0 -1
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/query-param.js +1 -1
- package/dist/utils/query-param.js.map +1 -1
- package/package.json +87 -47
- package/dist/data-view/key-converter.js.map +0 -1
- package/dist/types/utils/mfe-events.d.ts +0 -12
- package/dist/utils/mfe-events.js +0 -2
- package/dist/utils/mfe-events.js.map +0 -1
- /package/dist/{data-view → http-service/graphql}/key-converter.js +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { IFilterModelSwagger, IReponseAll } from './types';
|
|
2
|
+
import ServiceBase from './service-base';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for HTTP CRUD services.
|
|
5
|
+
*
|
|
6
|
+
* @template T - Entity type.
|
|
7
|
+
* @template K - Entity ID type.
|
|
8
|
+
*
|
|
9
|
+
* Provides common methods:
|
|
10
|
+
* - all: Get list with filter and pagination
|
|
11
|
+
* - single: Get detail by ID
|
|
12
|
+
* - create: Add new entity
|
|
13
|
+
* - update: Update entity by ID
|
|
14
|
+
* - remove: Delete entity by ID
|
|
15
|
+
*
|
|
16
|
+
* Supports request cancellation and artificial delay.
|
|
17
|
+
*/
|
|
18
|
+
declare class CRUDServiceBase<T, K> extends ServiceBase {
|
|
19
|
+
constructor(baseUri: string);
|
|
20
|
+
/**
|
|
21
|
+
* Fetches a list of entities with optional filters and pagination.
|
|
22
|
+
*
|
|
23
|
+
* @param filters - Filters and pagination options.
|
|
24
|
+
* @param signal - Optional AbortSignal for request cancellation.
|
|
25
|
+
* @param options - Optional delay configuration.
|
|
26
|
+
* @returns A promise resolving to the response containing the list of entities.
|
|
27
|
+
*/
|
|
28
|
+
all: (filters: Partial<IFilterModelSwagger<T>>, signal?: AbortSignal, options?: {
|
|
29
|
+
delay?: number;
|
|
30
|
+
}) => Promise<IReponseAll<T> | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetches a single entity by its ID.
|
|
33
|
+
*
|
|
34
|
+
* @param id - The ID of the entity to fetch.
|
|
35
|
+
* @param signal - Optional AbortSignal for request cancellation.
|
|
36
|
+
* @returns A promise resolving to the entity data.
|
|
37
|
+
*/
|
|
38
|
+
single: (id: K, signal?: AbortSignal) => Promise<T | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new entity.
|
|
41
|
+
*
|
|
42
|
+
* @param model - The entity data to create.
|
|
43
|
+
* @param signal - Optional AbortSignal for request cancellation.
|
|
44
|
+
* @param options - Optional delay configuration.
|
|
45
|
+
* @returns A promise resolving to the created entity data.
|
|
46
|
+
*/
|
|
47
|
+
create: (model: Partial<T>, signal?: AbortSignal, options?: {
|
|
48
|
+
delay?: number;
|
|
49
|
+
}) => Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates an existing entity by its ID.
|
|
52
|
+
*
|
|
53
|
+
* @param id - The ID of the entity to update.
|
|
54
|
+
* @param model - The partial entity data to update.
|
|
55
|
+
* @param signal - Optional AbortSignal for request cancellation.
|
|
56
|
+
* @returns A promise resolving to the updated entity data.
|
|
57
|
+
*/
|
|
58
|
+
update: (id: K, model: Partial<T>, signal?: AbortSignal) => Promise<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Deletes an entity by its ID.
|
|
61
|
+
*
|
|
62
|
+
* @param id - The ID of the entity to delete.
|
|
63
|
+
* @param signal - Optional AbortSignal for request cancellation.
|
|
64
|
+
* @returns A promise resolving to the deletion response.
|
|
65
|
+
*/
|
|
66
|
+
remove: (id: K, signal?: AbortSignal) => Promise<T>;
|
|
67
|
+
}
|
|
68
|
+
export default CRUDServiceBase;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import type { IApiContext } from './type.api-alert';
|
|
3
|
+
export declare const ApiAlertContext: IApiContext | undefined;
|
|
4
|
+
export declare const sleep: (sec: number) => Promise<unknown>;
|
|
5
|
+
export declare const fetchDelay: <TModel>(action: () => Promise<TModel>, sec: number) => Promise<TModel>;
|
|
6
|
+
interface ErrorModel {
|
|
7
|
+
[key: string]: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Processes axios errors and displays error messages to the user
|
|
11
|
+
* @param err - The axios error containing response data
|
|
12
|
+
*/
|
|
13
|
+
export declare const processError: (err: AxiosError<ErrorModel>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the current user's token is expired.
|
|
16
|
+
* @returns {Promise<boolean>} True if token is expired or user not logged in, false otherwise.
|
|
17
|
+
*/
|
|
18
|
+
export declare const checkTokenExpiry: () => Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Refreshes the token once if at least 4 seconds have passed since the last refresh.
|
|
21
|
+
* Uses localStorage key 'ltt' to track last refresh time.
|
|
22
|
+
*/
|
|
23
|
+
export declare const refreshTokenOnce: () => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Handles errors from Axios HTTP responses.
|
|
26
|
+
* Redirects or signs out user based on error code and status.
|
|
27
|
+
* @param {AxiosError} err - The error object from Axios.
|
|
28
|
+
* @returns {Promise<never>} Always rejects with the error.
|
|
29
|
+
*/
|
|
30
|
+
export declare const handleResponseError: (err: AxiosError) => Promise<never>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
/**
|
|
3
|
+
* Base service class for HTTP operations with authentication and error handling
|
|
4
|
+
* Provides common CRUD operations with automatic token management and retry logic
|
|
5
|
+
*/
|
|
6
|
+
export default class ServiceBase {
|
|
7
|
+
private _http;
|
|
8
|
+
constructor(http?: AxiosInstance);
|
|
9
|
+
/**
|
|
10
|
+
* Maps response and request interceptors for handling authentication and errors
|
|
11
|
+
* Automatically adds authorization headers and retries requests on 401 errors
|
|
12
|
+
*/
|
|
13
|
+
mapResponse: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Tries to fetch a new token if the current one is expired
|
|
16
|
+
* @param error - The axios error containing response data
|
|
17
|
+
* @param next - The next middleware function to call
|
|
18
|
+
* @returns A promise resolving to the response data or an error
|
|
19
|
+
*/
|
|
20
|
+
tryFetchToken: (error: AxiosError, next: (error: AxiosError) => Promise<any>) => Promise<any>;
|
|
21
|
+
private _token?;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the token to be used for authentication
|
|
24
|
+
* @param token - The token string to set
|
|
25
|
+
*/
|
|
26
|
+
setToken(token?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current token, fetching a new one if not set
|
|
29
|
+
* @returns A promise resolving to the token string
|
|
30
|
+
*/
|
|
31
|
+
getToken: () => Promise<string | null | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Adds custom headers to the request configuration
|
|
34
|
+
* @param config - The Axios request configuration object
|
|
35
|
+
* @returns A promise resolving to the updated configuration object
|
|
36
|
+
*/
|
|
37
|
+
addCustomHeader(config?: AxiosRequestConfig): Promise<AxiosRequestConfig<any>>;
|
|
38
|
+
/**
|
|
39
|
+
* Intercepts the request to add the authorization token
|
|
40
|
+
* @param config - The Axios request configuration object
|
|
41
|
+
* @returns The updated configuration object with the token added
|
|
42
|
+
*/
|
|
43
|
+
private interuptHeader;
|
|
44
|
+
/**
|
|
45
|
+
* Adds the authorization token to the request headers
|
|
46
|
+
* @param config - The Axios request configuration object
|
|
47
|
+
* @returns The updated configuration object with the token added
|
|
48
|
+
*/
|
|
49
|
+
private addtoken;
|
|
50
|
+
/**
|
|
51
|
+
* HTTP GET request with automatic authentication
|
|
52
|
+
* @param url - The request URL
|
|
53
|
+
* @param config - Optional axios configuration
|
|
54
|
+
* @returns Promise with the response data
|
|
55
|
+
*/
|
|
56
|
+
get<TModel>(url: string, config?: AxiosRequestConfig | undefined): Promise<TModel>;
|
|
57
|
+
/**
|
|
58
|
+
* HTTP GET request with error handling
|
|
59
|
+
* @param url - The request URL
|
|
60
|
+
* @param config - Optional axios configuration
|
|
61
|
+
* @returns Promise with the response data or null if an error occurs
|
|
62
|
+
*/
|
|
63
|
+
tryGet<TModel>(url: string, config?: AxiosRequestConfig | undefined): Promise<TModel | null>;
|
|
64
|
+
/**
|
|
65
|
+
* HTTP POST request with automatic authentication
|
|
66
|
+
* @param url - The request URL
|
|
67
|
+
* @param data - Optional data to send in the request body
|
|
68
|
+
* @param config - Optional axios configuration
|
|
69
|
+
* @returns Promise with the response data
|
|
70
|
+
*/
|
|
71
|
+
post<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined): Promise<TModel>;
|
|
72
|
+
/**
|
|
73
|
+
* HTTP PUT request with automatic authentication
|
|
74
|
+
* @param url - The request URL
|
|
75
|
+
* @param data - Optional data to send in the request body
|
|
76
|
+
* @param config - Optional axios configuration
|
|
77
|
+
* @returns Promise with the response data
|
|
78
|
+
*/
|
|
79
|
+
put<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined): Promise<TModel>;
|
|
80
|
+
/**
|
|
81
|
+
* HTTP PUT request with error handling
|
|
82
|
+
* @param url - The request URL
|
|
83
|
+
* @param data - Optional data to send in the request body
|
|
84
|
+
* @param config - Optional axios configuration
|
|
85
|
+
* @returns Promise with the response data or null if an error occurs
|
|
86
|
+
*/
|
|
87
|
+
tryPut<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined): Promise<TModel | null>;
|
|
88
|
+
/**
|
|
89
|
+
* HTTP POST request with error handling
|
|
90
|
+
* @param url - The request URL
|
|
91
|
+
* @param data - Optional data to send in the request body
|
|
92
|
+
* @param config - Optional axios configuration
|
|
93
|
+
* @returns Promise with the response data or null if an error occurs
|
|
94
|
+
*/
|
|
95
|
+
tryPost<TModel>(url: string, data?: any, config?: AxiosRequestConfig | undefined): Promise<TModel | null>;
|
|
96
|
+
/**
|
|
97
|
+
* HTTP DELETE request with automatic authentication
|
|
98
|
+
* @param url - The request URL
|
|
99
|
+
* @param config - Optional axios configuration
|
|
100
|
+
* @returns Promise with the response data
|
|
101
|
+
*/
|
|
102
|
+
delete<TModel>(url: string, config?: AxiosRequestConfig | undefined): Promise<TModel>;
|
|
103
|
+
/**
|
|
104
|
+
* HTTP DELETE request with error handling
|
|
105
|
+
* @param url - The request URL
|
|
106
|
+
* @param config - Optional axios configuration
|
|
107
|
+
* @returns Promise with the response data or null if an error occurs
|
|
108
|
+
*/
|
|
109
|
+
tryDelete<TModel>(url: string, config?: AxiosRequestConfig | undefined): Promise<TModel | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Push notification with error handling
|
|
112
|
+
* @param action - The function to execute
|
|
113
|
+
* @param p - Parameters to pass to the function
|
|
114
|
+
* @returns Promise with the result of the function execution
|
|
115
|
+
*/
|
|
116
|
+
tryPushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>): Promise<ReturnType<TFunc> | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* Push notification with error handling
|
|
119
|
+
* @param action - The function to execute
|
|
120
|
+
* @param p - Parameters to pass to the function
|
|
121
|
+
* @returns Promise with the result of the function execution
|
|
122
|
+
*/
|
|
123
|
+
pushNotify<TFunc extends (...param: any[]) => any>(action: TFunc, ...p: Parameters<TFunc>): Promise<ReturnType<TFunc>>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* CancelAction class extends AbortController to provide a cancel method
|
|
127
|
+
* This class can be used to cancel ongoing HTTP requests
|
|
128
|
+
*/
|
|
129
|
+
export declare class CancelAction extends AbortController {
|
|
130
|
+
cancel: () => void;
|
|
131
|
+
trigger?: () => void;
|
|
132
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface IMessageData {
|
|
2
|
+
id: string;
|
|
3
|
+
text: string;
|
|
4
|
+
type: 'success' | 'info' | 'warning' | 'error';
|
|
5
|
+
duration?: number;
|
|
6
|
+
}
|
|
7
|
+
interface IApiAlert {
|
|
8
|
+
PushMessage: (data: IMessageData) => void;
|
|
9
|
+
PushInfo: (data: string) => void;
|
|
10
|
+
PushError: (data: string) => void;
|
|
11
|
+
PushWarning: (data: string) => void;
|
|
12
|
+
PushSuccess: (data: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface IApiContext {
|
|
15
|
+
ApiAlert?: IApiAlert;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare enum ELogic {
|
|
2
|
+
And = 0,
|
|
3
|
+
Or = 1
|
|
4
|
+
}
|
|
5
|
+
export declare enum EOperator {
|
|
6
|
+
GreaterThan = 0,
|
|
7
|
+
LessThan = 1,
|
|
8
|
+
GreaterThanOrEqual = 2,
|
|
9
|
+
LessThanOrEqual = 3,
|
|
10
|
+
NotEqual = 4,
|
|
11
|
+
Equal = 5,
|
|
12
|
+
Contains = 6
|
|
13
|
+
}
|
|
14
|
+
export declare enum EOrder {
|
|
15
|
+
Ascending = 0,
|
|
16
|
+
Descending = 1
|
|
17
|
+
}
|
|
18
|
+
interface IFilterField<T> {
|
|
19
|
+
Logic?: ELogic;
|
|
20
|
+
Operator?: EOperator;
|
|
21
|
+
FieldName: keyof T;
|
|
22
|
+
Value: string;
|
|
23
|
+
}
|
|
24
|
+
interface IFilterScope<T> {
|
|
25
|
+
Logic?: ELogic;
|
|
26
|
+
Scopes: IPropFilter<T>[];
|
|
27
|
+
}
|
|
28
|
+
export type IPropFilter<T> = IFilterField<T> | IFilterScope<T>;
|
|
29
|
+
export interface IPropOrderBy<T> {
|
|
30
|
+
Type: EOrder;
|
|
31
|
+
FieldName: keyof T;
|
|
32
|
+
}
|
|
33
|
+
export interface IFilterModelSwagger<T> {
|
|
34
|
+
Page?: number;
|
|
35
|
+
Amount?: number;
|
|
36
|
+
PropFilters?: IPropFilter<T>[];
|
|
37
|
+
PropOrders?: IPropOrderBy<T>[];
|
|
38
|
+
}
|
|
39
|
+
export interface IReponseAll<T> {
|
|
40
|
+
Data?: T[];
|
|
41
|
+
Total?: number;
|
|
42
|
+
Page?: number;
|
|
43
|
+
Amount?: number;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EAppName } from './types';
|
|
2
|
+
declare enum RoleKeyInternalSite {
|
|
3
|
+
Admin = "Admin",
|
|
4
|
+
User = "User",
|
|
5
|
+
Manage = "Manage"
|
|
6
|
+
}
|
|
7
|
+
declare class AppProfileBase {
|
|
8
|
+
window: Window & {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
constructor();
|
|
12
|
+
getAppName: () => EAppName;
|
|
13
|
+
isAdmin: (roles?: string[]) => boolean;
|
|
14
|
+
getGraphqlSite: () => Promise<RoleKeyInternalSite>;
|
|
15
|
+
}
|
|
16
|
+
export declare const AppProfile: AppProfileBase;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { Fetcher } from 'graphql-ts-client-api';
|
|
3
|
+
import type { IGraphqlQueryOptions, IGraphqlRequestOptions } from './types';
|
|
4
|
+
import ServiceBase from '../base/service-base';
|
|
5
|
+
export interface IGraphqlRequestParams {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
execute: (...p: any[]) => Promise<any>;
|
|
8
|
+
options?: IGraphqlRequestOptions;
|
|
9
|
+
}
|
|
10
|
+
declare class GraphqlRequest extends ServiceBase {
|
|
11
|
+
private _execute;
|
|
12
|
+
private _options;
|
|
13
|
+
/**
|
|
14
|
+
* Constructor for GraphqlRequest.
|
|
15
|
+
* @param url The GraphQL endpoint URL.
|
|
16
|
+
* @param executor Custom executor function for GraphQL requests.
|
|
17
|
+
* @param options Additional options for the request.
|
|
18
|
+
*/
|
|
19
|
+
constructor(params: IGraphqlRequestParams);
|
|
20
|
+
private site?;
|
|
21
|
+
/**
|
|
22
|
+
* Adds the site to the request configuration headers.
|
|
23
|
+
* @param config Optional AxiosRequestConfig to modify.
|
|
24
|
+
* @param ignoreSite If true, skips adding the site header.
|
|
25
|
+
* @returns Modified AxiosRequestConfig with the site header.
|
|
26
|
+
*/
|
|
27
|
+
addSite(config?: AxiosRequestConfig, ignoreSite?: boolean): AxiosRequestConfig<any>;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the current site for GraphQL requests.
|
|
30
|
+
* @param site The site string to set.
|
|
31
|
+
*/
|
|
32
|
+
setSite: (site: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Default executor for GraphQL requests using POST.
|
|
35
|
+
* @param request GraphQL query string.
|
|
36
|
+
* @param variables Variables for the query.
|
|
37
|
+
* @param signal Optional AbortSignal for cancellation.
|
|
38
|
+
* @param ignoreSite If true, skips adding the site header.
|
|
39
|
+
* @returns Promise with the server response.
|
|
40
|
+
*/
|
|
41
|
+
private setGraphQLExecutor;
|
|
42
|
+
/**
|
|
43
|
+
* Default implementation to get the current site.
|
|
44
|
+
* Stores the site in global.window.wwfd.GraphqlSite for reuse.
|
|
45
|
+
* @returns Promise resolving to the current site string.
|
|
46
|
+
*/
|
|
47
|
+
getSite: () => Promise<string>;
|
|
48
|
+
private _getSite;
|
|
49
|
+
/**
|
|
50
|
+
* Automatically detects the site by calling getSite.
|
|
51
|
+
* Sets the detected site using setSite.
|
|
52
|
+
*/
|
|
53
|
+
private autoDetectSite;
|
|
54
|
+
/**
|
|
55
|
+
* Adds a custom header to the request configuration.
|
|
56
|
+
* @param config Optional AxiosRequestConfig to modify.
|
|
57
|
+
* @param ignoreSite If true, skips adding the site header.
|
|
58
|
+
* @returns Modified AxiosRequestConfig with the custom header.
|
|
59
|
+
*/
|
|
60
|
+
addCustomHeader(config?: AxiosRequestConfig, ignoreSite?: boolean): Promise<AxiosRequestConfig<any>>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the current site for GraphQL requests.
|
|
63
|
+
* @returns The current site string.
|
|
64
|
+
*/
|
|
65
|
+
private getParamExecutor;
|
|
66
|
+
/**
|
|
67
|
+
* Executes a GraphQL query or mutation with the provided fetcher.
|
|
68
|
+
* Automatically detects the site if autoDetectSite is true.
|
|
69
|
+
* @param fetcher The fetcher function for the query or mutation.
|
|
70
|
+
* @param options Optional IGraphqlQueryOptions for the request.
|
|
71
|
+
* @returns Promise with the result of the query or mutation.
|
|
72
|
+
*/
|
|
73
|
+
query<TData extends object, TVariables extends object>(fetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>, options?: IGraphqlQueryOptions): Promise<TData>;
|
|
74
|
+
/**
|
|
75
|
+
* Executes a GraphQL query or mutation and handles errors by pushing them to ApiAlertContext.
|
|
76
|
+
* @param fetcher The fetcher function for the query or mutation.
|
|
77
|
+
* @param options Optional IGraphqlQueryOptions for the request.
|
|
78
|
+
* @returns Promise with the result of the query or mutation.
|
|
79
|
+
*/
|
|
80
|
+
queryPushNotify<TData extends object, TVariables extends object>(fetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>, options?: IGraphqlQueryOptions): Promise<TData>;
|
|
81
|
+
}
|
|
82
|
+
export default GraphqlRequest;
|
|
83
|
+
export declare const createGraphqlRequest: (params: IGraphqlRequestParams) => GraphqlRequest;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type SingleOrArray<T> = T | T[];
|
|
2
2
|
export interface IKeyConverterDef<Q> {
|
|
3
3
|
field?: keyof Q;
|
|
4
4
|
deep?: string;
|
|
@@ -11,3 +11,4 @@ export type IKeyConverterModel<T, Q> = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare const createKeyConverter: <T, Q>(params: IKeyConverterModel<T, Q>) => IKeyConverterModel<T, Q>;
|
|
13
13
|
export declare const getKeyConverter: <T, Q>(key: keyof T, converter: IKeyConverterModel<T, Q>) => IKeyConverterDef<Q>[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type IVariable<T extends object> = keyof T;
|
|
2
|
+
export type ILogic = 'Or' | 'And';
|
|
3
|
+
export type ISortDirection = 'ASC' | 'DESC';
|
|
4
|
+
export interface ISeedModel<T> {
|
|
5
|
+
key: string;
|
|
6
|
+
field: keyof T;
|
|
7
|
+
}
|
|
8
|
+
export interface IFilterOption {
|
|
9
|
+
logic: ILogic;
|
|
10
|
+
ignoreEmpty: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IRequestParamOption {
|
|
13
|
+
ignoreEmpty: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ISortOption {
|
|
16
|
+
direction: ISortDirection;
|
|
17
|
+
}
|
|
18
|
+
export type ISortStore<T extends object> = {
|
|
19
|
+
[key in keyof T]?: ISortDirection;
|
|
20
|
+
};
|
|
21
|
+
export type IAllOptions = IFilterOption & IRequestParamOption & ISortOption;
|
|
22
|
+
export type IRequestParamResult<T extends object> = {
|
|
23
|
+
sort?: ISortStore<T>[];
|
|
24
|
+
skip: number;
|
|
25
|
+
take: number;
|
|
26
|
+
filter?: string;
|
|
27
|
+
noTotal?: boolean;
|
|
28
|
+
seedKey?: string;
|
|
29
|
+
seedField?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare class RequestParam<T extends object = any> {
|
|
32
|
+
private readonly _option?;
|
|
33
|
+
constructor(option?: Partial<IRequestParamOption>);
|
|
34
|
+
private mergeOptions;
|
|
35
|
+
private ignoreEmpty;
|
|
36
|
+
private _filter;
|
|
37
|
+
private _filterBase;
|
|
38
|
+
filter: (field1: IVariable<T>, field2: string | number, option?: Partial<IFilterOption>) => this;
|
|
39
|
+
filterNotEquals: (field1: IVariable<T>, field2: string | number, option?: Partial<IFilterOption>) => this;
|
|
40
|
+
filterEnum: (field1: IVariable<T>, field2: string | number, option?: Partial<IFilterOption>) => this;
|
|
41
|
+
filterStartsWith: (field1: IVariable<T>, field2: string, option?: Partial<IFilterOption>) => this;
|
|
42
|
+
filterContains: (field1: IVariable<T>, field2: string, option?: Partial<IFilterOption>) => this;
|
|
43
|
+
filterLast: (field1: IVariable<T>, field2: string, option?: Partial<IFilterOption>) => this;
|
|
44
|
+
filterNumber: (field1: IVariable<T>, operator: string, field2: string, option?: Partial<IFilterOption>) => this;
|
|
45
|
+
filterGreater: (field1: IVariable<T>, field2: string, option?: Partial<IFilterOption>) => this;
|
|
46
|
+
filterLess: (field1: IVariable<T>, field2: string, option?: Partial<IFilterOption>) => this;
|
|
47
|
+
filterCustom: (field1: string, option?: Partial<IFilterOption>) => this;
|
|
48
|
+
scope: (action: (crd: RequestParam<T>) => RequestParam<T>, option?: Partial<IFilterOption>) => this;
|
|
49
|
+
private seedStore?;
|
|
50
|
+
seed: (field: keyof T, key: string) => this;
|
|
51
|
+
private _skip?;
|
|
52
|
+
skip: (skip: number) => this;
|
|
53
|
+
private _take?;
|
|
54
|
+
take: (take: number) => this;
|
|
55
|
+
private sortStore;
|
|
56
|
+
private sortBase;
|
|
57
|
+
sort: (field1: IVariable<T>, option?: Partial<ISortOption>) => this;
|
|
58
|
+
private _noTotal?;
|
|
59
|
+
noTotal: (value?: boolean) => this;
|
|
60
|
+
private buildFilter;
|
|
61
|
+
private buildPage;
|
|
62
|
+
private buildRandomWithSeedKey;
|
|
63
|
+
build: () => IRequestParamResult<T>;
|
|
64
|
+
}
|
|
65
|
+
export declare const createRequestBuilder: <T extends object>(option?: Partial<IRequestParamOption>) => RequestParam<T>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** Options for initializing a GraphQL request instance. */
|
|
2
|
+
export interface IGraphqlRequestOptions {
|
|
3
|
+
/** If true, the site property will be ignored and the site will be auto-detected. */
|
|
4
|
+
autoDetectSite?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The site identifier, can be a string or a function returning a Promise<string>.
|
|
7
|
+
* If autoDetectSite is true, this field is not used.
|
|
8
|
+
*/
|
|
9
|
+
site?: string | (() => Promise<string>);
|
|
10
|
+
/**
|
|
11
|
+
* If true, the site will be ignored in the request headers.
|
|
12
|
+
*/
|
|
13
|
+
ignoreSite?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Enum for application names using the system. */
|
|
16
|
+
export declare enum EAppName {
|
|
17
|
+
ClientApp = "ClientApp",
|
|
18
|
+
ClientAdmin = "ClientAdmin"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Standard result type for GraphQL list queries.
|
|
22
|
+
* @template T The type of items in the result.
|
|
23
|
+
*/
|
|
24
|
+
export type IGraphqlResult<T> = {
|
|
25
|
+
/** The array of items returned by the query. */
|
|
26
|
+
items?: T[];
|
|
27
|
+
/** Indicates if there is a next page of results. */
|
|
28
|
+
hasNextPage?: boolean;
|
|
29
|
+
/** Indicates if there is a previous page of results. */
|
|
30
|
+
hasPreviousPage?: boolean;
|
|
31
|
+
/** The total number of items available. */
|
|
32
|
+
totalItems?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Type definition for a GraphQL executor function.
|
|
36
|
+
* @param request The GraphQL query string.
|
|
37
|
+
* @param variables The variables for the query.
|
|
38
|
+
* @returns Promise resolving to any data.
|
|
39
|
+
*/
|
|
40
|
+
export type IGraphqlExecutor = (request: string, variables: object) => Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Options for executing a GraphQL query or mutation.
|
|
43
|
+
* @template TSite The type of the site property (default is string).
|
|
44
|
+
*/
|
|
45
|
+
export interface IGraphqlQueryOptions<TSite extends string = string> {
|
|
46
|
+
/** The operation name of the GraphQL query. */
|
|
47
|
+
readonly operationName?: string;
|
|
48
|
+
/** Variables for the query. */
|
|
49
|
+
readonly variables?: object;
|
|
50
|
+
/** Custom executor function for the query. */
|
|
51
|
+
readonly executor?: IGraphqlExecutor;
|
|
52
|
+
/** AbortSignal to cancel the request. */
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
/** Delay before executing the request, in milliseconds. */
|
|
55
|
+
readonly delay?: number;
|
|
56
|
+
/** Whether to auto-detect the site for this query. */
|
|
57
|
+
readonly autoDetectSite?: boolean;
|
|
58
|
+
/** The site value or name for this query. */
|
|
59
|
+
readonly site?: TSite;
|
|
60
|
+
/** If true, the site will be ignored in the request headers. */
|
|
61
|
+
readonly ignoreSite?: boolean;
|
|
62
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Status Enumeration
|
|
3
|
+
* Defines possible states of user authentication
|
|
4
|
+
*/
|
|
5
|
+
export declare enum AuthStatus {
|
|
6
|
+
/** User is not authenticated */
|
|
7
|
+
UNAUTHENTICATED = "UNAUTHENTICATED",
|
|
8
|
+
/** User is successfully authenticated */
|
|
9
|
+
AUTHENTICATED = "AUTHENTICATED",
|
|
10
|
+
/** Authentication process is in progress */
|
|
11
|
+
AUTHENTICATING = "AUTHENTICATING",
|
|
12
|
+
/** Loading authentication state or user data */
|
|
13
|
+
LOADING = "LOADING",
|
|
14
|
+
/** Authentication error occurred */
|
|
15
|
+
ERROR = "ERROR"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Micro Frontend Type Enumeration
|
|
19
|
+
* Identifies different types of micro frontend components
|
|
20
|
+
*/
|
|
21
|
+
export declare enum MicroFrontendType {
|
|
22
|
+
/** Main dashboard component */
|
|
23
|
+
DASHBOARD = "DASHBOARD",
|
|
24
|
+
/** User profile component */
|
|
25
|
+
PROFILE = "PROFILE",
|
|
26
|
+
/** Settings and configuration component */
|
|
27
|
+
SETTINGS = "SETTINGS",
|
|
28
|
+
/** Media store and gallery component */
|
|
29
|
+
MEDIA_STORE = "MEDIA_STORE",
|
|
30
|
+
/** Application header component */
|
|
31
|
+
APP_HEADER = "APP_HEADER",
|
|
32
|
+
/** Application footer component */
|
|
33
|
+
APP_FOOTER = "APP_FOOTER",
|
|
34
|
+
/** Video player and gallery component */
|
|
35
|
+
VIDEO_GROUP = "VIDEO_GROUP",
|
|
36
|
+
/** Audio track and playlist component */
|
|
37
|
+
TRACK_GROUP = "TRACK_GROUP",
|
|
38
|
+
/** Generic or custom micro frontend component */
|
|
39
|
+
GENERIC = "GENERIC"
|
|
40
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { AuthEventData, AuthEventListener } from './auth-types';
|
|
2
|
+
/**
|
|
3
|
+
* Global Authentication Manager for Module Federation
|
|
4
|
+
* Manages authentication state across host and micro frontend applications
|
|
5
|
+
*/
|
|
6
|
+
declare class AuthMFEManager {
|
|
7
|
+
private static instance;
|
|
8
|
+
private authData;
|
|
9
|
+
private listeners;
|
|
10
|
+
private isInitialized;
|
|
11
|
+
private constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Get singleton instance
|
|
14
|
+
*/
|
|
15
|
+
static getInstance(): AuthMFEManager;
|
|
16
|
+
/**
|
|
17
|
+
* Initialize global window object for cross-component communication
|
|
18
|
+
*/
|
|
19
|
+
private initializeGlobalWindow;
|
|
20
|
+
/**
|
|
21
|
+
* Setup event listeners for authentication events
|
|
22
|
+
*/
|
|
23
|
+
private setupEventListeners;
|
|
24
|
+
/**
|
|
25
|
+
* Handle authentication state requests
|
|
26
|
+
*/
|
|
27
|
+
private handleAuthRequest;
|
|
28
|
+
/**
|
|
29
|
+
* Handle login requests from micro frontends
|
|
30
|
+
*/
|
|
31
|
+
private handleLoginRequest;
|
|
32
|
+
/**
|
|
33
|
+
* Handle logout requests from micro frontends
|
|
34
|
+
*/
|
|
35
|
+
private handleLogoutRequest;
|
|
36
|
+
/**
|
|
37
|
+
* Update authentication data and notify all subscribers
|
|
38
|
+
*/
|
|
39
|
+
updateAuthData(newData: Partial<AuthEventData>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Subscribe to authentication changes
|
|
42
|
+
*/
|
|
43
|
+
subscribe(microFrontendId: string, callback: AuthEventListener): void;
|
|
44
|
+
/**
|
|
45
|
+
* Unsubscribe from authentication changes
|
|
46
|
+
*/
|
|
47
|
+
unsubscribe(microFrontendId: string, callback: AuthEventListener): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get current authentication data
|
|
50
|
+
*/
|
|
51
|
+
getAuthData(): AuthEventData;
|
|
52
|
+
/**
|
|
53
|
+
* Check if manager is initialized
|
|
54
|
+
*/
|
|
55
|
+
isReady(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get debug information
|
|
58
|
+
*/
|
|
59
|
+
getDebugInfo(): {
|
|
60
|
+
isInitialized: boolean;
|
|
61
|
+
authData: AuthEventData;
|
|
62
|
+
subscriberCount: number;
|
|
63
|
+
subscribers: string[];
|
|
64
|
+
windowAvailable: boolean;
|
|
65
|
+
globalObjectAvailable: boolean;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export default AuthMFEManager;
|