@opencx/widget-core 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/__tests__/api-caller.mock.d.ts +1 -0
- package/dist/__tests__/context/contact/auth/auto-create-unverified-anonymous.spec.d.ts +0 -0
- package/dist/__tests__/context/contact/auth/auto-create-unverified-with-user-data-provided-by-org.spec.d.ts +0 -0
- package/dist/__tests__/context/contact/auth/manually-create-unverified-with-user-data-provided-by-user.spec.d.ts +0 -0
- package/dist/__tests__/context/contact/auth/with-secure-token.spec.d.ts +0 -0
- package/dist/__tests__/context/contact/should-collect-data.spec.d.ts +0 -0
- package/dist/__tests__/test-utils.d.ts +419 -0
- package/dist/__tests__/utils/Poller.spec.d.ts +1 -0
- package/dist/__tests__/utils/PrimitiveState.spec.d.ts +1 -0
- package/dist/api/api-caller.d.ts +437 -0
- package/dist/api/client.d.ts +12 -0
- package/dist/api/schema.d.ts +928 -0
- package/dist/context/active-session-polling.ctx.d.ts +25 -0
- package/dist/context/contact.ctx.d.ts +30 -0
- package/dist/context/message.ctx.d.ts +38 -0
- package/dist/context/router.ctx.d.ts +33 -0
- package/dist/context/session.ctx.d.ts +119 -0
- package/dist/context/storage.ctx.d.ts +15 -0
- package/dist/context/widget.ctx.d.ts +27 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +699 -0
- package/dist/index.js.map +1 -0
- package/dist/types/agent-or-bot.d.ts +6 -0
- package/dist/types/component-name.d.ts +1 -0
- package/dist/types/dtos.d.ts +12 -0
- package/dist/types/external-storage.d.ts +5 -0
- package/dist/types/helpers.d.ts +2 -0
- package/dist/types/icons.d.ts +3 -0
- package/dist/types/json-value.d.ts +7 -0
- package/dist/types/messages.d.ts +55 -0
- package/dist/types/widget-config.d.ts +400 -0
- package/dist/utils/Poller.d.ts +12 -0
- package/dist/utils/PrimitiveState.d.ts +13 -0
- package/dist/utils/is-exhaustive.d.ts +1 -0
- package/dist/utils/run-catching.d.ts +13 -0
- package/dist/utils/uuid.d.ts +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AgentOrBotType } from './agent-or-bot';
|
|
3
|
+
import { IconNameU } from './icons';
|
|
4
|
+
import { JsonValue } from './json-value';
|
|
5
|
+
import { ModeDto } from './dtos';
|
|
6
|
+
import { SessionCtx } from '../context/session.ctx';
|
|
7
|
+
import { MessageCtx } from '../context/message.ctx';
|
|
8
|
+
type UserBaseConfig = {
|
|
9
|
+
token: string;
|
|
10
|
+
data?: never;
|
|
11
|
+
} | {
|
|
12
|
+
token?: never;
|
|
13
|
+
data?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
avatarUrl?: string;
|
|
17
|
+
customData?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type UserConfig = UserBaseConfig & {
|
|
21
|
+
/**
|
|
22
|
+
* An external ID is useful to scope the sessions of a single user based on workspace.
|
|
23
|
+
* For example, if a user uses one email for multiple accounts (organizations) in your application.
|
|
24
|
+
*/
|
|
25
|
+
externalId?: string;
|
|
26
|
+
};
|
|
27
|
+
type ThemeOptions = {
|
|
28
|
+
/**
|
|
29
|
+
* @default 'stone'
|
|
30
|
+
*/
|
|
31
|
+
palette?: 'neutral' | 'stone' | 'zinc' | 'slate';
|
|
32
|
+
primaryColor?: string;
|
|
33
|
+
widgetTrigger?: {
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
offset?: {
|
|
36
|
+
/** number in pixels */
|
|
37
|
+
right?: number;
|
|
38
|
+
/** number in pixels */
|
|
39
|
+
bottom?: number;
|
|
40
|
+
};
|
|
41
|
+
size?: {
|
|
42
|
+
/** number in pixels */
|
|
43
|
+
button?: number;
|
|
44
|
+
/** number in pixels */
|
|
45
|
+
icon?: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
widgetContentContainer?: {
|
|
49
|
+
zIndex?: number;
|
|
50
|
+
offset?: {
|
|
51
|
+
/** number in pixels */
|
|
52
|
+
side?: number;
|
|
53
|
+
/** number in pixels */
|
|
54
|
+
align?: number;
|
|
55
|
+
};
|
|
56
|
+
outline?: string;
|
|
57
|
+
outlineColor?: string;
|
|
58
|
+
borderRadius?: string;
|
|
59
|
+
boxShadow?: string;
|
|
60
|
+
transitionProperty?: string;
|
|
61
|
+
transitionTimingFunction?: string;
|
|
62
|
+
transitionDuration?: string;
|
|
63
|
+
};
|
|
64
|
+
screens?: {
|
|
65
|
+
welcome?: {
|
|
66
|
+
/**
|
|
67
|
+
* Because the welcome screen can have dynamic content (org description and extra data collection fields), it is better to set a minHeight instead of a fixed height.
|
|
68
|
+
*/
|
|
69
|
+
minHeight?: string;
|
|
70
|
+
width?: string;
|
|
71
|
+
};
|
|
72
|
+
sessions?: {
|
|
73
|
+
height?: string;
|
|
74
|
+
width?: string;
|
|
75
|
+
};
|
|
76
|
+
chat?: {
|
|
77
|
+
height?: string;
|
|
78
|
+
width?: string;
|
|
79
|
+
/** When the canvas is open */
|
|
80
|
+
withCanvas?: {
|
|
81
|
+
height?: string;
|
|
82
|
+
width?: string;
|
|
83
|
+
transitionTimingFunction?: string;
|
|
84
|
+
transitionDuration?: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
type TextContentOptions = {
|
|
90
|
+
welcomeScreen?: {
|
|
91
|
+
title?: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
};
|
|
94
|
+
sessionsScreen?: {
|
|
95
|
+
headerTitle?: string;
|
|
96
|
+
};
|
|
97
|
+
chatScreen?: {
|
|
98
|
+
headerTitle?: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
type HeaderButtonBase = {
|
|
102
|
+
icon?: IconNameU;
|
|
103
|
+
hideOnSmallScreen?: boolean;
|
|
104
|
+
hideOnLargeScreen?: boolean;
|
|
105
|
+
};
|
|
106
|
+
export type HeaderButtonU = (HeaderButtonBase & {
|
|
107
|
+
functionality: 'expand-shrink';
|
|
108
|
+
/** if `HeaderButtonBase.icon` is passed, it will override this option */
|
|
109
|
+
expandIcon?: IconNameU;
|
|
110
|
+
/** if `HeaderButtonBase.icon` is passed, it will override this option */
|
|
111
|
+
shrinkIcon?: IconNameU;
|
|
112
|
+
}) | (HeaderButtonBase & {
|
|
113
|
+
functionality: 'close-widget';
|
|
114
|
+
}) | (HeaderButtonBase & {
|
|
115
|
+
functionality: 'resolve-session';
|
|
116
|
+
/**
|
|
117
|
+
* The side effect after the session is resolved.
|
|
118
|
+
* @default 'stay-in-chat'
|
|
119
|
+
*/
|
|
120
|
+
onResolved?: 'stay-in-chat' | 'reset-chat' | 'close-widget' | 'reset-chat-and-close-widget';
|
|
121
|
+
/**
|
|
122
|
+
* Optional confirmation dialog before the session is resolved.
|
|
123
|
+
*/
|
|
124
|
+
confirmation?: {
|
|
125
|
+
type: 'modal';
|
|
126
|
+
title?: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
confirmButtonText?: string;
|
|
129
|
+
cancelButtonText?: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* The button's behavior before the session is created (before the user sends their first message).
|
|
133
|
+
* @default 'disabled'
|
|
134
|
+
*/
|
|
135
|
+
behaviorBeforeSessionCreation?: 'disabled' | 'close-widget';
|
|
136
|
+
/**
|
|
137
|
+
* The button's behavior after the session is resolved and the user is still in the same chat session.
|
|
138
|
+
* @default 'disabled'
|
|
139
|
+
*/
|
|
140
|
+
behaviorIfSessionIsResolved?: 'disabled' | 'reset-chat' | 'close-widget' | 'reset-chat-and-close-widget';
|
|
141
|
+
});
|
|
142
|
+
export type ModeComponentProps = {
|
|
143
|
+
react: typeof React;
|
|
144
|
+
mode: ModeDto;
|
|
145
|
+
createStateCheckpoint: SessionCtx['createStateCheckpoint'];
|
|
146
|
+
sendMessage: MessageCtx['sendMessage'];
|
|
147
|
+
isSendingMessage: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type ModeComponent = {
|
|
150
|
+
/** The mode's ID, name or slug */
|
|
151
|
+
key: string;
|
|
152
|
+
component: (props: ModeComponentProps) => ReturnType<typeof React.createElement>;
|
|
153
|
+
};
|
|
154
|
+
export interface WidgetConfig {
|
|
155
|
+
/**
|
|
156
|
+
* Your organization's widget token.
|
|
157
|
+
* Can be found in the dashboard in the web widget page.
|
|
158
|
+
*/
|
|
159
|
+
token: string;
|
|
160
|
+
/**
|
|
161
|
+
* The language of the widget.
|
|
162
|
+
* Translations are available in the default non-headless widget.
|
|
163
|
+
* Check available translations in `src/designs/translation`
|
|
164
|
+
* @default en
|
|
165
|
+
*/
|
|
166
|
+
language?: string;
|
|
167
|
+
/**
|
|
168
|
+
* A name and an avatar for the bot.
|
|
169
|
+
*/
|
|
170
|
+
bot?: Pick<AgentOrBotType, 'name' | 'avatar'>;
|
|
171
|
+
/**
|
|
172
|
+
* Whether the widget is open or not.
|
|
173
|
+
* Can be used to have the widget open by default (useful when embedded in a webview for a mobile app).
|
|
174
|
+
* Also useful to open and close the widget programmatically.
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
isOpen?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Automatically open the widget after N seconds.
|
|
180
|
+
* @default undefined
|
|
181
|
+
*/
|
|
182
|
+
openAfterNSeconds?: number;
|
|
183
|
+
/**
|
|
184
|
+
* A custom vanilla stylesheet to override the default styles. See {@link OpenCxComponentNameU} for available component names.
|
|
185
|
+
*
|
|
186
|
+
* @example Overriding a component's styles
|
|
187
|
+
* ```css
|
|
188
|
+
* [data-component="sessions_screen/new_conversation_button"] {
|
|
189
|
+
* background-color: orangered;
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example Changing the font family
|
|
194
|
+
* ```css
|
|
195
|
+
* \@import url('https://fonts.googleapis.com/css2?family=Baskervville:ital,wght@0,400..700;1,400..700&display=swap');
|
|
196
|
+
* * {
|
|
197
|
+
* font-family: "Baskervville", serif;
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
cssOverrides?: string;
|
|
202
|
+
theme?: ThemeOptions;
|
|
203
|
+
/**
|
|
204
|
+
* Disable tooltips for all components.
|
|
205
|
+
* @default false
|
|
206
|
+
*/
|
|
207
|
+
disableTooltips?: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Assets URLs to be used in the widget.
|
|
210
|
+
*/
|
|
211
|
+
assets?: {
|
|
212
|
+
organizationLogo?: string;
|
|
213
|
+
widgetTrigger?: {
|
|
214
|
+
openIcon?: string;
|
|
215
|
+
closeIcon?: string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Initial messages that the contact sees in a new chat session.
|
|
220
|
+
* These messages will disappear once the contact sends their first message.
|
|
221
|
+
* @default - ['Hello, how can I help you?']
|
|
222
|
+
*/
|
|
223
|
+
initialMessages?: string[];
|
|
224
|
+
/**
|
|
225
|
+
* Similar to `initialMessages`, but these messages will persist at the top of the chat session.
|
|
226
|
+
* Useful if you want to keep a notice or a privacy policy warning.
|
|
227
|
+
* @default undefined
|
|
228
|
+
*/
|
|
229
|
+
persistentInitialMessages?: string[];
|
|
230
|
+
/**
|
|
231
|
+
* Initial messages that the contact sees in a new chat session.
|
|
232
|
+
* Similar to the `initialMessages` option, but with more control over the messages.
|
|
233
|
+
* Using this option will override the `initialMessages` option.
|
|
234
|
+
* @default undefined
|
|
235
|
+
*/
|
|
236
|
+
advancedInitialMessages?: Array<{
|
|
237
|
+
message: string;
|
|
238
|
+
/** Whether it stays at the top of chat after the user sends their first message. */
|
|
239
|
+
persistent?: boolean;
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* Suggested initial questions that the contact sees in a new chat session.
|
|
243
|
+
* If a user clicks on one of the suggested questions, the widget will send it as the user's first message.
|
|
244
|
+
* @default undefined
|
|
245
|
+
* @example - ['What is my account balance?', 'How do I pay my bill?', 'How do I change my address?']
|
|
246
|
+
*/
|
|
247
|
+
initialQuestions?: string[];
|
|
248
|
+
/**
|
|
249
|
+
* Where to display the suggested initial questions.
|
|
250
|
+
* @default 'above-chat-input'
|
|
251
|
+
*/
|
|
252
|
+
initialQuestionsPosition?: 'above-chat-input' | 'below-initial-messages';
|
|
253
|
+
/**
|
|
254
|
+
* If turned on, the widget will have a login-like screen to collect user's name and email.
|
|
255
|
+
* A non-verified contact will be created based on the provided information.
|
|
256
|
+
* @default false
|
|
257
|
+
*/
|
|
258
|
+
collectUserData?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Provide initial values for the `name` and `email` inputs in the welcome screen.
|
|
261
|
+
* For this setting to take effect, `collectUserData` must be set to `true`.
|
|
262
|
+
* @default undefined
|
|
263
|
+
*/
|
|
264
|
+
prefillUserData?: {
|
|
265
|
+
name?: string;
|
|
266
|
+
email?: string;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Extra data collection fields besides `name` and `email`.
|
|
270
|
+
* For this setting to take effect, `collectUserData` must be set to `true`.
|
|
271
|
+
*
|
|
272
|
+
* Not to be confused with `WidgetConfig.user.data.customData`,
|
|
273
|
+
* the purpose of `extraDataCollectionFields` is to provide context to the session,
|
|
274
|
+
* the data collected will be prepended in the first contact message in a session.
|
|
275
|
+
*
|
|
276
|
+
* @default undefined
|
|
277
|
+
*/
|
|
278
|
+
extraDataCollectionFields?: string[];
|
|
279
|
+
/**
|
|
280
|
+
* Verified or non-verified contact data.
|
|
281
|
+
* To know more, check the README
|
|
282
|
+
* @default undefined
|
|
283
|
+
*/
|
|
284
|
+
user?: UserConfig;
|
|
285
|
+
/**
|
|
286
|
+
* Custom text content to override the defaults in the default widget.
|
|
287
|
+
*/
|
|
288
|
+
textContent?: TextContentOptions;
|
|
289
|
+
/**
|
|
290
|
+
* Custom header buttons to expand-shrink the size of the widget, close the widget, resolve the session, etc.
|
|
291
|
+
*
|
|
292
|
+
* Note that using this options will remove the default `close-widget` button on small screens.
|
|
293
|
+
*
|
|
294
|
+
* @default close-widget button on small screens
|
|
295
|
+
*/
|
|
296
|
+
headerButtons?: {
|
|
297
|
+
sessionsScreen?: Array<HeaderButtonU>;
|
|
298
|
+
chatScreen?: Array<HeaderButtonU>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Custom components to be mounted in the canvas if there is an active mode.
|
|
302
|
+
*/
|
|
303
|
+
modesComponents?: Array<ModeComponent>;
|
|
304
|
+
/**
|
|
305
|
+
* Customize the router behavior.
|
|
306
|
+
*/
|
|
307
|
+
router?: {
|
|
308
|
+
/**
|
|
309
|
+
* If true, the router will navigate to the `chat` screen instead of `sessions` screen if the contact has no previous sessions.
|
|
310
|
+
* @default true
|
|
311
|
+
*/
|
|
312
|
+
goToChatIfNoSessions?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* If true, only the `welcome` and `chat` screens are visible.
|
|
315
|
+
* The most recent `open` session will be selected.
|
|
316
|
+
* If none found, a new empty conversation will be opened, and a session will be created if the user sends a message.
|
|
317
|
+
* The `back to sessions screen` button in the header will be hidden.
|
|
318
|
+
*
|
|
319
|
+
* @default false
|
|
320
|
+
*/
|
|
321
|
+
chatScreenOnly?: boolean;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* By default, the user can have multiple open sessions.
|
|
325
|
+
*
|
|
326
|
+
* Setting this option to `true` will hide the `new conversation` button if there is an open session.
|
|
327
|
+
*
|
|
328
|
+
* @default false
|
|
329
|
+
*/
|
|
330
|
+
oneOpenSessionAllowed?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* The target attribute for all links in the AI or human agents responses.
|
|
333
|
+
*
|
|
334
|
+
* `_blank` opens links in a new tab or window.
|
|
335
|
+
*
|
|
336
|
+
* `_top` opens links in the same tab.
|
|
337
|
+
*
|
|
338
|
+
* @default '_top'
|
|
339
|
+
*/
|
|
340
|
+
anchorTarget?: '_blank' | '_top';
|
|
341
|
+
/**
|
|
342
|
+
* Headers to be added to every Http AI action taken.
|
|
343
|
+
* @default undefined
|
|
344
|
+
*/
|
|
345
|
+
headers?: Record<string, string>;
|
|
346
|
+
/**
|
|
347
|
+
* Query params to be added to every Http AI action taken.
|
|
348
|
+
* @default undefined
|
|
349
|
+
*/
|
|
350
|
+
queryParams?: Record<string, string>;
|
|
351
|
+
/**
|
|
352
|
+
* Properties to be added to the `body` of every Http AI action taken.
|
|
353
|
+
* @default undefined
|
|
354
|
+
*/
|
|
355
|
+
bodyProperties?: Record<string, JsonValue>;
|
|
356
|
+
/**
|
|
357
|
+
* Dynamic context to be sent with each send-message request from the widget.
|
|
358
|
+
* Useful if you want to send data regarding the current page the user is viewing.
|
|
359
|
+
* @default undefined
|
|
360
|
+
*/
|
|
361
|
+
context?: Record<string, unknown>;
|
|
362
|
+
/**
|
|
363
|
+
* Dynamic custom data to be sent with each contact message.
|
|
364
|
+
* This custom data is intended for human use only; the AI will not see it and it will not affect the AI's response.
|
|
365
|
+
* @default undefined
|
|
366
|
+
*/
|
|
367
|
+
messageCustomData?: Record<string, unknown>;
|
|
368
|
+
/**
|
|
369
|
+
* Custom data to be added to the session upon creation.
|
|
370
|
+
* This custom data is intended for human use only; the AI will not see it and it will not affect the AI's response.
|
|
371
|
+
* @default undefined
|
|
372
|
+
*/
|
|
373
|
+
sessionCustomData?: Record<string, unknown>;
|
|
374
|
+
/**
|
|
375
|
+
* If this is set to `true`:
|
|
376
|
+
* 1. The widget content will fill it's parent element.
|
|
377
|
+
* 2. The content will always be open.
|
|
378
|
+
* 3. The widget trigger will not be visible.
|
|
379
|
+
*
|
|
380
|
+
* This is useful if you want to embed the widget in a parent element and have it always open.
|
|
381
|
+
*
|
|
382
|
+
* @default false
|
|
383
|
+
*/
|
|
384
|
+
inline?: boolean;
|
|
385
|
+
/**
|
|
386
|
+
* This shows when the AI's response might have solved the user's issue.
|
|
387
|
+
* The prompt shows as two buttons: "This was helpful" and "I need more help".
|
|
388
|
+
*/
|
|
389
|
+
thisWasHelpfulOrNot?: {
|
|
390
|
+
/** @default true */
|
|
391
|
+
enabled?: boolean;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* An apiUrl to override production backend.
|
|
395
|
+
* This is for us to test the widget locally, you don't need to play with this option 😊.
|
|
396
|
+
* @default https://api.open.cx
|
|
397
|
+
*/
|
|
398
|
+
apiUrl?: string;
|
|
399
|
+
}
|
|
400
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PrimitiveState } from './PrimitiveState';
|
|
2
|
+
export type PollingState = {
|
|
3
|
+
isPolling: boolean;
|
|
4
|
+
isError: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare class Poller {
|
|
7
|
+
state: PrimitiveState<PollingState>;
|
|
8
|
+
private abortController;
|
|
9
|
+
reset: () => void;
|
|
10
|
+
private stopPolling;
|
|
11
|
+
startPolling: (cb: (abortSignal: AbortSignal) => Promise<void>, intervalMs: number) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Subscriber<T> = (data: T) => void;
|
|
2
|
+
export declare class PrimitiveState<S> {
|
|
3
|
+
private subscribers;
|
|
4
|
+
private state;
|
|
5
|
+
private initialState;
|
|
6
|
+
constructor(state: S);
|
|
7
|
+
get: () => S;
|
|
8
|
+
set: (newState: S) => void;
|
|
9
|
+
setPartial: (_s: Partial<S>) => void;
|
|
10
|
+
reset: () => void;
|
|
11
|
+
private notifySubscribers;
|
|
12
|
+
subscribe: (callback: Subscriber<S>) => (() => void);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isExhaustive(value: never, funcName: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function run<T>(fn: () => T): T;
|
|
2
|
+
export type Result<T, E> = {
|
|
3
|
+
data: T;
|
|
4
|
+
error?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
data?: undefined;
|
|
7
|
+
error: E;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Many thanks to @m-tabaza for this utility... Kotlin vibes
|
|
11
|
+
*/
|
|
12
|
+
export declare function runCatching<T, E = unknown>(callback: () => Promise<T>): Promise<Result<T, E>>;
|
|
13
|
+
export declare function runCatching<T, E = unknown>(callback: () => T): Result<T, E>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function genUuid(): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opencx/widget-core",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "4.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/openchatai/widget"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"lodash.isequal": "^4.5.0",
|
|
22
|
+
"openapi-fetch": "^0.13.4",
|
|
23
|
+
"uuid": "^11.0.4"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/lodash.isequal": "^4.5.8",
|
|
27
|
+
"lucide": "^0.525.0",
|
|
28
|
+
"openapi-typescript": "^7.5.2",
|
|
29
|
+
"@opencx/eslint-config": "0.0.0",
|
|
30
|
+
"@opencx/tsconfig": "0.0.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@types/react": ">=18 <20",
|
|
34
|
+
"@types/react-dom": ">=18 <20"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "rm -rf node_modules dist .turbo",
|
|
38
|
+
"clean:dist": "rm -rf dist .turbo",
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"gen:sdk": "pnpm dlx openapi-typescript http://localhost:8080/widget-api-yaml -o ./src/headless/core/api/schema.ts && prettier --write ./src/headless/core/api/schema.ts",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"cs": "changeset",
|
|
43
|
+
"csv": "changeset version",
|
|
44
|
+
"csp": "changeset publish",
|
|
45
|
+
"type-check": "tsc --noEmit",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"format": "prettier --write ."
|
|
48
|
+
}
|
|
49
|
+
}
|