@getsoren/shared-module 2.43.4
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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/axios/axiosCustomInstance.d.ts +5 -0
- package/dist/axiosCustomInstance.ts +23 -0
- package/dist/chat/ChatClient.d.ts +35 -0
- package/dist/chat/tests/ChatClient.test.d.ts +1 -0
- package/dist/chat/types.d.ts +116 -0
- package/dist/components/Inputs/MaskTextField.d.ts +32 -0
- package/dist/components/Utils/GTMSendPageView.d.ts +23 -0
- package/dist/components/Utils/InitializeAmplitude.d.ts +27 -0
- package/dist/components/Utils/InitializeAxiosConfig.d.ts +41 -0
- package/dist/components/Utils/InitializeDaysJSConfig.d.ts +27 -0
- package/dist/components/Utils/InitializeHubSpot.d.ts +27 -0
- package/dist/components/Utils/InitializeI18nConfig.d.ts +26 -0
- package/dist/components/Utils/InitializeSentryConfig.d.ts +81 -0
- package/dist/components/Utils/RequireAuth.d.ts +48 -0
- package/dist/components/Utils/ShowHubSpotBubble.d.ts +10 -0
- package/dist/config/orval/index.d.ts +2 -0
- package/dist/config/orval/orval.d.ts +81 -0
- package/dist/config/orval/orval.test.d.ts +1 -0
- package/dist/constants/hubspot.d.ts +12 -0
- package/dist/context/ChatProvider.d.ts +33 -0
- package/dist/context/InjectDependenciesProvider.d.ts +72 -0
- package/dist/context/QueryClientProviderWithConfig.d.ts +26 -0
- package/dist/hooks/tests/useFilters.test.d.ts +1 -0
- package/dist/hooks/useAdapter.d.ts +22 -0
- package/dist/hooks/useAmplitude.d.ts +16 -0
- package/dist/hooks/useAuth.d.ts +20 -0
- package/dist/hooks/useChat.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.d.ts +13 -0
- package/dist/hooks/useCurrentLanguage/useCurrentLanguage.test.d.ts +1 -0
- package/dist/hooks/useFilters.d.ts +44 -0
- package/dist/hooks/useHubSpot.d.ts +9 -0
- package/dist/hooks/useInfiniteDataGrid.d.ts +30 -0
- package/dist/hooks/useResponseError/useResponseError.d.ts +33 -0
- package/dist/hooks/useResponseError/useResponseError.test.d.ts +1 -0
- package/dist/main.d.ts +52 -0
- package/dist/main.js +823 -0
- package/dist/utils/adapter/dateAdapter.d.ts +17 -0
- package/dist/utils/adapter/distanceAdapter.d.ts +12 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.d.ts +9 -0
- package/dist/utils/adapter/worksiteNameAdapter/worksiteNameAdapter.test.d.ts +1 -0
- package/dist/utils/isReactNative.d.ts +5 -0
- package/dist/utils/lazyWithRetry.d.ts +18 -0
- package/package.json +117 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mickaël Austoni
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# @getsoren/shared-module
|
|
2
|
+
|
|
3
|
+
> This package contains shared components, hooks and utilities.
|
|
4
|
+
> This package use dependencies only with injection.
|
|
5
|
+
|
|
6
|
+
- [Installation](#Installation)
|
|
7
|
+
- [Usage](#Usage)
|
|
8
|
+
- [Inject dependencies with provider](#Inject-dependencies-with-provider)
|
|
9
|
+
- [WebSocket](#WebSocket)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```console
|
|
14
|
+
yarn add @getsoren/shared-module
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript jsx
|
|
20
|
+
import { InitializeAxiosConfig } from "@getsoren/shared-module";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Inject dependencies with provider
|
|
24
|
+
|
|
25
|
+
```typescript jsx
|
|
26
|
+
import { InjectDependenciesProvider, InitializeAxiosConfig } from "@getsoren/shared-module";
|
|
27
|
+
|
|
28
|
+
const App = () => (
|
|
29
|
+
<InjectDependenciesProvider apiURL={import.meta.env.VITE_API_URL} libraries={{
|
|
30
|
+
axios,
|
|
31
|
+
}}>
|
|
32
|
+
<InitializeAxiosConfig/>
|
|
33
|
+
...
|
|
34
|
+
</InjectDependenciesProvider>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default App;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Providers
|
|
41
|
+
| Module | Description | Dependencies |
|
|
42
|
+
|-------------------------------|-------------------------------------------------------|--------------|
|
|
43
|
+
| InjectDependenciesProvider | Inject dependencies for other shared component | - |
|
|
44
|
+
| QueryClientProviderWithConfig | React Query provider with default config | React Query |
|
|
45
|
+
| ChatProvider | Shared WebSocket chat connection provider via context | - |
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Components
|
|
49
|
+
| Module | Type | Description | Dependencies |
|
|
50
|
+
|------------------------|-----------------|-----------------------------------------------------|------------------------------------------------------------|
|
|
51
|
+
| RequireAuth | React Component | Component for protected routing | Axios & react-router-dom |
|
|
52
|
+
| GTMSendPageView | React Component | Send page view event to Google Tag Manager | @getsoren/react-google-tag-manager & react-router-dom |
|
|
53
|
+
| InitializeAxiosConfig | React Component | Initialize Axios with custom default config options | Axios |
|
|
54
|
+
| InitializeI18nConfig | React Component | Initialize i18n with custom config options | i18next & react-i18next & i18next-browser-languagedetector |
|
|
55
|
+
| InitializeSentryConfig | React Component | Initialize Sentry | @sentry/react & react-router-dom |
|
|
56
|
+
| InitializeMapBoxConfig | React Component | Initialize MapBox | mapbox-gl |
|
|
57
|
+
| InitializeDaysJSConfig | React Component | Initialize DayJS | dayjs |
|
|
58
|
+
| InitializeHubSpot | React Component | Initialize HubSpot chat widget | - |
|
|
59
|
+
| PreloadErrorHandler | React Component | his component is used to handle preload error. | dayjs |
|
|
60
|
+
|
|
61
|
+
## Hooks
|
|
62
|
+
| Module | Description | Dependencies |
|
|
63
|
+
|---------------------|----------------------------------------------------------------------------|-------------------|
|
|
64
|
+
| useAdapter | Hook with several adapter | - |
|
|
65
|
+
| useAuth | Hook for authentification management | Axios |
|
|
66
|
+
| useHubSpot | Hook to interact with the HubSpot chat widget (toggle, availability) | InitializeHubSpot |
|
|
67
|
+
| useResponseError | This hook is used to print error messages from the API | i18next |
|
|
68
|
+
| useInfiniteDataGrid | This hook is used to handle the infinite scroll of the DataGrid component. | - |
|
|
69
|
+
| useCurrentLanguage | This get the current language of app | - |
|
|
70
|
+
| useFilters | Hook to handle filter | - |
|
|
71
|
+
| useChat | Hook to consume the ChatProvider context (threads, messaging, presence) | ChatProvider |
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## WebSocket
|
|
75
|
+
|
|
76
|
+
### Chat
|
|
77
|
+
|
|
78
|
+
The chat module provides a WebSocket client for thread subscription, messaging, read receipts, and presence events.
|
|
79
|
+
|
|
80
|
+
**With the React provider** (recommended):
|
|
81
|
+
|
|
82
|
+
First, wrap your app with `ChatProvider` (inside `InjectDependenciesProvider`):
|
|
83
|
+
|
|
84
|
+
```typescript jsx
|
|
85
|
+
import { ChatProvider, InjectDependenciesProvider } from "@getsoren/shared-module";
|
|
86
|
+
|
|
87
|
+
const App = () => (
|
|
88
|
+
<InjectDependenciesProvider apiURL={import.meta.env.VITE_API_URL} libraries={libraries} localStorageKeys={localStorageKeys}>
|
|
89
|
+
<ChatProvider>
|
|
90
|
+
<MyApp />
|
|
91
|
+
</ChatProvider>
|
|
92
|
+
</InjectDependenciesProvider>
|
|
93
|
+
);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Then use `useChat()` in any component:
|
|
97
|
+
|
|
98
|
+
```typescript jsx
|
|
99
|
+
import { useChat } from "@getsoren/shared-module";
|
|
100
|
+
|
|
101
|
+
const Chat = ({ threadId }: { threadId: string }) => {
|
|
102
|
+
const { isReady, sendMessage, joinThread } = useChat();
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<div>
|
|
106
|
+
<p>{isReady ? "Connected" : "Connecting..."}</p>
|
|
107
|
+
<button onClick={() => joinThread(threadId)}>Join</button>
|
|
108
|
+
<button onClick={() => sendMessage(threadId, "Hello!")}>Send</button>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The provider reads `apiURL` and the user token from `InjectDependenciesProvider` automatically. You can override both via props:
|
|
115
|
+
|
|
116
|
+
```typescript jsx
|
|
117
|
+
<ChatProvider url="wss://api.example.com/v2/threads/ws" token="my-jwt">
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Without React** (class only):
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { ChatClient } from "@getsoren/shared-module";
|
|
124
|
+
|
|
125
|
+
const client = new ChatClient({
|
|
126
|
+
url: "wss://api.example.com/v2/threads/ws",
|
|
127
|
+
getToken: () => "my-jwt",
|
|
128
|
+
onEvent: (event) => console.log(event),
|
|
129
|
+
onConnectionChange: (connected) => console.log("connected:", connected),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
client.connect();
|
|
133
|
+
client.joinThread("thread-1");
|
|
134
|
+
client.sendMessage("thread-1", "Hello!");
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
| Module | Description | Dependencies |
|
|
138
|
+
|--------------|-----------------------------------------------------------|--------------|
|
|
139
|
+
| ChatClient | Framework-agnostic WebSocket client for the chat protocol | - |
|
|
140
|
+
| ChatProvider | Provider for shared WebSocket connection via context | - |
|
|
141
|
+
| useChat | React hook to consume the ChatProvider context | ChatProvider |
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
## Config
|
|
145
|
+
| Module | Description |
|
|
146
|
+
|-----------------------|------------------------------------|
|
|
147
|
+
| getOrvalOperationName | Get config for orval operationName |
|
|
148
|
+
|
|
149
|
+
## Utils function
|
|
150
|
+
| Module | Description |
|
|
151
|
+
|---------------------|----------------------|
|
|
152
|
+
| dateAdapter | Adapt given date |
|
|
153
|
+
| distanceAdapter | Adapt given distance |
|
|
154
|
+
| worksiteNameAdapter | Adapt worksite name |
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AxiosError, AxiosRequestConfig } from 'axios';
|
|
2
|
+
export declare const axiosCustomInstance: <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig) => Promise<T>;
|
|
3
|
+
export default axiosCustomInstance;
|
|
4
|
+
export type ErrorType<Error> = AxiosError<Error>;
|
|
5
|
+
export type BodyType<BodyData> = BodyData;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import axios, { AxiosError, AxiosRequestConfig } from "axios";
|
|
2
|
+
|
|
3
|
+
export const axiosCustomInstance = <T>(config: AxiosRequestConfig, options?: AxiosRequestConfig): Promise<T> => {
|
|
4
|
+
const source = axios.CancelToken.source();
|
|
5
|
+
|
|
6
|
+
const promise = axios({
|
|
7
|
+
...config,
|
|
8
|
+
...options,
|
|
9
|
+
cancelToken: source.token,
|
|
10
|
+
}).then(({ data }) => data);
|
|
11
|
+
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
promise.cancel = () => {
|
|
14
|
+
source.cancel("Query was cancelled");
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return promise;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default axiosCustomInstance;
|
|
21
|
+
|
|
22
|
+
export type ErrorType<Error> = AxiosError<Error>;
|
|
23
|
+
export type BodyType<BodyData> = BodyData;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChatClientOptions } from './types';
|
|
2
|
+
declare class ChatClient {
|
|
3
|
+
private readonly url;
|
|
4
|
+
private readonly getToken;
|
|
5
|
+
private readonly onEvent?;
|
|
6
|
+
private readonly onConnectionChange?;
|
|
7
|
+
private readonly shouldReconnect;
|
|
8
|
+
private readonly maxReconnectAttempts;
|
|
9
|
+
private readonly reconnectBaseDelay;
|
|
10
|
+
private readonly maxMessageBodyLength;
|
|
11
|
+
private ws;
|
|
12
|
+
private reconnectAttempt;
|
|
13
|
+
private reconnectTimer;
|
|
14
|
+
private intentionalClose;
|
|
15
|
+
private joinedThreads;
|
|
16
|
+
private pendingMessages;
|
|
17
|
+
private _connected;
|
|
18
|
+
private _ready;
|
|
19
|
+
constructor(options: ChatClientOptions);
|
|
20
|
+
get connected(): boolean;
|
|
21
|
+
get ready(): boolean;
|
|
22
|
+
connect(): void;
|
|
23
|
+
disconnect(): void;
|
|
24
|
+
joinThread(threadId: string): void;
|
|
25
|
+
leaveThread(threadId: string): void;
|
|
26
|
+
sendMessage(threadId: string, body: string): void;
|
|
27
|
+
markRead(threadId: string): void;
|
|
28
|
+
listThreads(limit?: number, offset?: number): void;
|
|
29
|
+
private send;
|
|
30
|
+
private flushPendingMessages;
|
|
31
|
+
private rejoinThreads;
|
|
32
|
+
private scheduleReconnect;
|
|
33
|
+
private clearReconnectTimer;
|
|
34
|
+
}
|
|
35
|
+
export default ChatClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface Thread {
|
|
2
|
+
id: string;
|
|
3
|
+
participants: string[];
|
|
4
|
+
lastMessage?: Message;
|
|
5
|
+
unreadCount?: number;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface Message {
|
|
10
|
+
id: string;
|
|
11
|
+
authorId: string;
|
|
12
|
+
body: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface JoinThread {
|
|
16
|
+
type: "join_thread";
|
|
17
|
+
threadId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface LeaveThread {
|
|
20
|
+
type: "leave_thread";
|
|
21
|
+
threadId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SendMessage {
|
|
24
|
+
type: "send_message";
|
|
25
|
+
threadId: string;
|
|
26
|
+
body: string;
|
|
27
|
+
}
|
|
28
|
+
export interface MarkRead {
|
|
29
|
+
type: "mark_read";
|
|
30
|
+
threadId: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ListThreads {
|
|
33
|
+
type: "list_threads";
|
|
34
|
+
limit?: number;
|
|
35
|
+
offset?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ReadyEvent {
|
|
38
|
+
type: "ready";
|
|
39
|
+
userId: string;
|
|
40
|
+
unreadCount?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface JoinedThread {
|
|
43
|
+
type: "joined_thread";
|
|
44
|
+
threadId: string;
|
|
45
|
+
thread: Thread;
|
|
46
|
+
}
|
|
47
|
+
export interface LeftThread {
|
|
48
|
+
type: "left_thread";
|
|
49
|
+
threadId: string;
|
|
50
|
+
}
|
|
51
|
+
export interface NewMessageEvent {
|
|
52
|
+
type: "new_message";
|
|
53
|
+
threadId: string;
|
|
54
|
+
message: Message;
|
|
55
|
+
}
|
|
56
|
+
export interface NewMessageNotification {
|
|
57
|
+
type: "new_message_notification";
|
|
58
|
+
threadId: string;
|
|
59
|
+
messageId: string;
|
|
60
|
+
bodyPreview: string;
|
|
61
|
+
}
|
|
62
|
+
export interface MarkedRead {
|
|
63
|
+
type: "marked_read";
|
|
64
|
+
threadId: string;
|
|
65
|
+
userId: string;
|
|
66
|
+
}
|
|
67
|
+
export interface ThreadsListEvent {
|
|
68
|
+
type: "threads_list";
|
|
69
|
+
threads: Thread[];
|
|
70
|
+
total: number;
|
|
71
|
+
}
|
|
72
|
+
export interface PresenceEvent {
|
|
73
|
+
type: "presence";
|
|
74
|
+
userId: string;
|
|
75
|
+
online: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface ThreadArchivedEvent {
|
|
78
|
+
type: "thread_archived";
|
|
79
|
+
threadId: string;
|
|
80
|
+
}
|
|
81
|
+
export interface ErrorEvent {
|
|
82
|
+
type: "error";
|
|
83
|
+
code: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ChatClientOptions {
|
|
87
|
+
url: string;
|
|
88
|
+
getToken: () => string | null;
|
|
89
|
+
onEvent?: (event: ServerEvent) => void;
|
|
90
|
+
onConnectionChange?: (connected: boolean) => void;
|
|
91
|
+
reconnect?: boolean;
|
|
92
|
+
maxReconnectAttempts?: number;
|
|
93
|
+
reconnectBaseDelay?: number;
|
|
94
|
+
maxMessageBodyLength?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface BrowserNotificationOptions extends NotificationOptions {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
title?: string;
|
|
99
|
+
onClick?: (event: NewMessageNotification) => void;
|
|
100
|
+
}
|
|
101
|
+
export interface UseChatParams {
|
|
102
|
+
enabled?: boolean;
|
|
103
|
+
browserNotification?: BrowserNotificationOptions;
|
|
104
|
+
onReady?: (event: ReadyEvent) => void;
|
|
105
|
+
onNewMessage?: (event: NewMessageEvent) => void;
|
|
106
|
+
onNewMessageNotification?: (event: NewMessageNotification) => void;
|
|
107
|
+
onPresence?: (event: PresenceEvent) => void;
|
|
108
|
+
onError?: (event: ErrorEvent) => void;
|
|
109
|
+
onJoinedThread?: (event: JoinedThread) => void;
|
|
110
|
+
onLeftThread?: (event: LeftThread) => void;
|
|
111
|
+
onMarkedRead?: (event: MarkedRead) => void;
|
|
112
|
+
onThreadArchived?: (event: ThreadArchivedEvent) => void;
|
|
113
|
+
onThreadsList?: (event: ThreadsListEvent) => void;
|
|
114
|
+
}
|
|
115
|
+
export type ClientMessage = JoinThread | LeaveThread | SendMessage | MarkRead | ListThreads;
|
|
116
|
+
export type ServerEvent = ReadyEvent | JoinedThread | LeftThread | NewMessageEvent | NewMessageNotification | MarkedRead | ThreadsListEvent | PresenceEvent | ThreadArchivedEvent | ErrorEvent;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ComponentProps, ComponentType } from 'react';
|
|
2
|
+
interface MaskTextFieldProps<T> {
|
|
3
|
+
/**
|
|
4
|
+
* Mask pattern.
|
|
5
|
+
* e.g. `Date: {d}.{m}.{y}`
|
|
6
|
+
* e.g. `Phone: +{7}(000)000-00-00`
|
|
7
|
+
* @see https://imask.js.org/guide.html#masked-pattern
|
|
8
|
+
*/
|
|
9
|
+
mask?: unknown;
|
|
10
|
+
/**
|
|
11
|
+
* On accept callback. Should be used to get the value from the mask instead onChange for controlled components.
|
|
12
|
+
* @param value
|
|
13
|
+
* @param maskRef
|
|
14
|
+
*/
|
|
15
|
+
onAccept?: (value: unknown, maskRef: unknown) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Definitions.
|
|
18
|
+
*/
|
|
19
|
+
definitions?: unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Text field component dependency.
|
|
22
|
+
*/
|
|
23
|
+
TextField: T;
|
|
24
|
+
/**
|
|
25
|
+
* Mask mixin dependency.
|
|
26
|
+
* @param param
|
|
27
|
+
* @constructor
|
|
28
|
+
*/
|
|
29
|
+
IMaskMixin: (param: (props: any) => any) => any;
|
|
30
|
+
}
|
|
31
|
+
declare const MaskTextField: <T extends ComponentType>({ IMaskMixin, ...props }: MaskTextFieldProps<T> & ComponentProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export default MaskTextField;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
export interface GTMSendPageViewProps {
|
|
3
|
+
/**
|
|
4
|
+
* GTM library from @tracktor
|
|
5
|
+
*/
|
|
6
|
+
gtm?: NonNullable<InjectDependenciesContextProps["libraries"]>["gtm"];
|
|
7
|
+
/**
|
|
8
|
+
* React Router library
|
|
9
|
+
*/
|
|
10
|
+
reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
|
|
11
|
+
/**
|
|
12
|
+
* Data to send to GTM
|
|
13
|
+
*/
|
|
14
|
+
data?: object;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This component send page view to Google Tag Manager
|
|
18
|
+
* @param data
|
|
19
|
+
* @param props
|
|
20
|
+
* @constructor
|
|
21
|
+
*/
|
|
22
|
+
declare const GTMSendPageView: ({ data, ...props }: GTMSendPageViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default GTMSendPageView;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
interface InitializeAmplitudeProps {
|
|
3
|
+
/**
|
|
4
|
+
* Amplitude libraries. Pass `{ analytics, sessionReplayPlugin }` here or inject them via `InjectDependenciesProvider`.
|
|
5
|
+
*/
|
|
6
|
+
amplitude?: NonNullable<InjectDependenciesContextProps["libraries"]>["amplitude"];
|
|
7
|
+
/**
|
|
8
|
+
* Amplitude project API key. When absent the component is a no-op, so dev builds without a key stay silent.
|
|
9
|
+
*/
|
|
10
|
+
apiKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Value injected as `platform` on every tracked event (e.g. "desktop", "supplier", "mobile"). Defaults to "desktop".
|
|
13
|
+
*/
|
|
14
|
+
platform?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Session replay sample rate between 0 and 1. Defaults to 0.25.
|
|
17
|
+
*/
|
|
18
|
+
sessionReplaySampleRate?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initializes the Amplitude SDK once at mount:
|
|
22
|
+
* - disables click autocapture so only explicit `track` calls are sent,
|
|
23
|
+
* - registers the session replay plugin with configurable sampling (when provided),
|
|
24
|
+
* - registers an enrichment plugin that adds `platform` to every event's properties.
|
|
25
|
+
*/
|
|
26
|
+
declare const InitializeAmplitude: ({ apiKey, platform, sessionReplaySampleRate, ...props }: InitializeAmplitudeProps) => null;
|
|
27
|
+
export default InitializeAmplitude;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
interface InitializeAxiosConfigProps {
|
|
3
|
+
/**
|
|
4
|
+
* Axios library
|
|
5
|
+
*/
|
|
6
|
+
axios?: NonNullable<InjectDependenciesContextProps["libraries"]>["axios"];
|
|
7
|
+
/**
|
|
8
|
+
* User local storage key
|
|
9
|
+
* @default user
|
|
10
|
+
*/
|
|
11
|
+
userLocalStorageKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for Axios instance
|
|
14
|
+
*/
|
|
15
|
+
apiURL?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Post-content type for Axios instance
|
|
18
|
+
* @default application/json
|
|
19
|
+
*/
|
|
20
|
+
postContentType?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Token type key for Axios instance
|
|
23
|
+
* @default tokenType
|
|
24
|
+
*/
|
|
25
|
+
tokenTypeKey?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Token key for Axios instance
|
|
28
|
+
* @default accessToken
|
|
29
|
+
*/
|
|
30
|
+
tokenKey?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This component initializes Axios instance with custom default config options
|
|
34
|
+
* @param axios
|
|
35
|
+
* @param tokenTypeKey
|
|
36
|
+
* @param tokenKey
|
|
37
|
+
* @param postContentType
|
|
38
|
+
* @constructor
|
|
39
|
+
*/
|
|
40
|
+
declare const InitializeAxiosConfig: ({ tokenTypeKey, tokenKey, postContentType, ...props }: InitializeAxiosConfigProps) => null;
|
|
41
|
+
export default InitializeAxiosConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
interface InitializeDaysJSConfigProps {
|
|
3
|
+
/**
|
|
4
|
+
* Dayjs library
|
|
5
|
+
*/
|
|
6
|
+
dayjs?: NonNullable<InjectDependenciesContextProps["libraries"]>["dayjs"];
|
|
7
|
+
/**
|
|
8
|
+
* Dayjs localizedFormat plugin (required for localized date formats like "ll")
|
|
9
|
+
*/
|
|
10
|
+
localizedFormat: any;
|
|
11
|
+
/**
|
|
12
|
+
* Dayjs plugin
|
|
13
|
+
*/
|
|
14
|
+
plugin?: NonNullable<InjectDependenciesContextProps["libraries"]>["dayjsPlugin"];
|
|
15
|
+
/**
|
|
16
|
+
* Language
|
|
17
|
+
*/
|
|
18
|
+
language?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initialize dayjs
|
|
22
|
+
* @param language
|
|
23
|
+
* @param props
|
|
24
|
+
* @constructor
|
|
25
|
+
*/
|
|
26
|
+
declare const InitializeDaysJSConfig: ({ language, ...props }: InitializeDaysJSConfigProps) => null;
|
|
27
|
+
export default InitializeDaysJSConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
hsConversationsOnReady?: Array<() => void>;
|
|
4
|
+
HubSpotConversations?: {
|
|
5
|
+
widget: {
|
|
6
|
+
close: () => void;
|
|
7
|
+
open: () => void;
|
|
8
|
+
};
|
|
9
|
+
on: (event: string, callback: () => void) => void;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
interface InitializeHubSpotProps {
|
|
14
|
+
/**
|
|
15
|
+
* HubSpot account ID used to load the chat widget script
|
|
16
|
+
*/
|
|
17
|
+
hubId: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Initializes the HubSpot chat widget by injecting the script and CSS.
|
|
21
|
+
* The default launcher bubble is hidden by default via CSS (the selectors
|
|
22
|
+
* use `div#id` to outweigh HubSpot's own `#id !important` rules).
|
|
23
|
+
* Mount `<ShowHubSpotBubble />` inside a page to make the launcher visible there.
|
|
24
|
+
* Use the `useHubSpot` hook to open/close the chat from anywhere.
|
|
25
|
+
*/
|
|
26
|
+
declare const InitializeHubSpot: ({ hubId }: InitializeHubSpotProps) => null;
|
|
27
|
+
export default InitializeHubSpot;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
interface InitializeI18nConfigProps {
|
|
3
|
+
/**
|
|
4
|
+
* i18 library
|
|
5
|
+
*/
|
|
6
|
+
i18?: NonNullable<InjectDependenciesContextProps["libraries"]>["i18"];
|
|
7
|
+
/**
|
|
8
|
+
* Resources to initialize with (if not using loading or not appending using addResourceBundle)
|
|
9
|
+
*/
|
|
10
|
+
resources?: {
|
|
11
|
+
[language: string]: any;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Enable debug mode
|
|
15
|
+
*/
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This component initializes i18n instance with custom config options
|
|
20
|
+
* @param i18n
|
|
21
|
+
* @param debug
|
|
22
|
+
* @param resources
|
|
23
|
+
* @constructor
|
|
24
|
+
*/
|
|
25
|
+
declare const InitializeI18nConfig: ({ debug, resources, ...props }: InitializeI18nConfigProps) => null;
|
|
26
|
+
export default InitializeI18nConfig;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
2
|
+
interface InitializeSentryConfigProps {
|
|
3
|
+
/**
|
|
4
|
+
* Sentry library
|
|
5
|
+
*/
|
|
6
|
+
sentry?: NonNullable<InjectDependenciesContextProps["libraries"]>["sentry"];
|
|
7
|
+
/**
|
|
8
|
+
* React Router library
|
|
9
|
+
*/
|
|
10
|
+
reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
|
|
11
|
+
/**
|
|
12
|
+
* Sentry DSN
|
|
13
|
+
*/
|
|
14
|
+
dsn: string;
|
|
15
|
+
/**
|
|
16
|
+
* List of integrations that should be installed after SDK was initialized.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* List of integrations that should be installed after SDK was initialized.
|
|
20
|
+
*/
|
|
21
|
+
integrations?: any[];
|
|
22
|
+
/**
|
|
23
|
+
* Tracing is enabled if either this or tracesSampler is defined.
|
|
24
|
+
* If both are defined, tracesSampleRate is ignored.
|
|
25
|
+
*/
|
|
26
|
+
tracesSampleRate?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The sample rate for session-long replays.
|
|
29
|
+
* 1.0 will record all sessions and 0 will record none.
|
|
30
|
+
*/
|
|
31
|
+
replaysSessionSampleRate?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The sample rate for sessions that has had an error occur.
|
|
34
|
+
* This is independent of sessionSampleRate. 1.0 will record all sessions and 0 will record none.
|
|
35
|
+
*/
|
|
36
|
+
replaysOnErrorSampleRate?: number;
|
|
37
|
+
/**
|
|
38
|
+
* List of strings/regex controlling to which outgoing requests the SDK will attach tracing headers.
|
|
39
|
+
* By default, the SDK will attach those headers to all requests to localhost and same origin. If this option is provided, the SDK will match the request URL of outgoing requests against the items in this array, and only attach tracing headers if a match was found.
|
|
40
|
+
* Example:
|
|
41
|
+
* Sentry.init({
|
|
42
|
+
* tracePropagationTargets: ['api.site.com'],
|
|
43
|
+
* });
|
|
44
|
+
* Default: ['localhost', /^//]
|
|
45
|
+
*/
|
|
46
|
+
tracePropagationTargets?: (string | RegExp)[];
|
|
47
|
+
/**
|
|
48
|
+
* Enable debug mode.
|
|
49
|
+
*/
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A pattern for error messages which should not be sent to Sentry.
|
|
53
|
+
* By default, all errors will be sent.
|
|
54
|
+
*/
|
|
55
|
+
ignoreErrors?: Array<string | RegExp>;
|
|
56
|
+
/**
|
|
57
|
+
* The current environment of your application (e.g. "production").
|
|
58
|
+
*/
|
|
59
|
+
environment?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The release identifier used when uploading respective source maps.
|
|
62
|
+
* Specify this value to allow Sentry to resolve the correct source maps when processing events.
|
|
63
|
+
*/
|
|
64
|
+
release?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* This component is used to initialize Sentry
|
|
68
|
+
* @param dsn
|
|
69
|
+
* @param sentry
|
|
70
|
+
* @param integrations
|
|
71
|
+
* @param tracesSampleRate
|
|
72
|
+
* @param replaysSessionSampleRate
|
|
73
|
+
* @param replaysOnErrorSampleRate
|
|
74
|
+
* @param tracePropagationTargets
|
|
75
|
+
* @param ignoreErrors
|
|
76
|
+
* @param debug
|
|
77
|
+
* @param environment
|
|
78
|
+
* @constructor
|
|
79
|
+
*/
|
|
80
|
+
declare const InitializeSentryConfig: ({ dsn, integrations, tracesSampleRate, replaysSessionSampleRate, replaysOnErrorSampleRate, tracePropagationTargets, ignoreErrors, debug, environment, release, ...props }: InitializeSentryConfigProps) => null;
|
|
81
|
+
export default InitializeSentryConfig;
|