@lorikeetai/react-native-sdk 1.2.0 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,51 +1,169 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { WebViewProps, WebViewMessageEvent, WebView } from 'react-native-webview';
4
- import { Customisations } from '@lorikeetai/web-sdk/types';
5
- import { StyleProp, TextStyle } from 'react-native';
6
-
1
+ import { StyleProp, TextStyle } from "react-native";
2
+ import { WebView, WebViewMessageEvent, WebViewProps } from "react-native-webview";
3
+ //#region src/conversation-metadata.d.ts
4
+ type ConversationMetadata = Record<string, unknown>;
5
+ //#endregion
6
+ //#region src/customisations.d.ts
7
+ interface ViewportCustomisations {
8
+ borderRadius?: string;
9
+ default_open?: boolean;
10
+ height?: string;
11
+ topClearance?: string;
12
+ width?: string;
13
+ }
14
+ interface Customisations {
15
+ avatarUrl?: string;
16
+ botName?: string;
17
+ desktop?: ViewportCustomisations;
18
+ hideHeader?: boolean;
19
+ linkTarget?: '_blank' | '_parent';
20
+ logoUrl?: string;
21
+ messages?: {
22
+ failOver?: string;
23
+ unavailable?: string;
24
+ escalated?: string;
25
+ };
26
+ mobile?: ViewportCustomisations;
27
+ mode?: 'controlled' | 'uncontrolled';
28
+ rootElement?: {
29
+ border?: string;
30
+ borderRadius?: string;
31
+ zIndex?: number;
32
+ bottom?: string;
33
+ right?: string;
34
+ size?: string;
35
+ };
36
+ showVerboseTimestamps?: boolean;
37
+ theme?: CustomisationTheme;
38
+ title?: string;
39
+ useSubtleBranding?: boolean;
40
+ }
41
+ interface CustomisationTheme {
42
+ background?: string;
43
+ backgroundColor?: string;
44
+ brandAccentColor?: string;
45
+ brandColor?: string;
46
+ colorMode?: 'light' | 'dark';
47
+ fontFamily?: string;
48
+ fontUrl?: string;
49
+ headerBackground?: string;
50
+ inverseTextColor?: string;
51
+ linkColor?: string;
52
+ linkHoverColor?: string;
53
+ secondaryBrandColor?: string;
54
+ subtleBrandColor?: string;
55
+ textColor?: string;
56
+ }
57
+ //#endregion
58
+ //#region src/events.d.ts
59
+ type LorikeetWidgetEvent = {
60
+ type: 'ready';
61
+ } | {
62
+ type: 'ticket_created';
63
+ ticketId: string;
64
+ } | {
65
+ type: 'customer_message';
66
+ } | {
67
+ type: 'agent_message';
68
+ markUnread?: boolean;
69
+ } | {
70
+ type: 'close';
71
+ reason?: 'ended_by_customer' | 'minimised';
72
+ } | {
73
+ type: 'conversation_ended';
74
+ } | {
75
+ type: 'new_chat';
76
+ } | {
77
+ type: 'persist_ticket_id';
78
+ ticketId: string;
79
+ } | {
80
+ type: 'persist_session';
81
+ session: string;
82
+ } | {
83
+ type: 'logged_out';
84
+ } | {
85
+ type: 'logout_failed';
86
+ } | {
87
+ type: 'error';
88
+ error: string;
89
+ } | {
90
+ type: 'preload_complete';
91
+ clientStart: boolean;
92
+ lazyTicketCreationEnabled: boolean;
93
+ };
94
+ type LorikeetWidgetEventType = 'agent_message' | 'close' | 'conversation_ended' | 'customer_message' | 'error' | 'logged_out' | 'logout_failed' | 'new_chat' | 'persist_session' | 'persist_ticket_id' | 'preload_complete' | 'ready' | 'ticket_created';
95
+ //#endregion
96
+ //#region src/types.d.ts
7
97
  interface LorikeetInitOptions {
8
- api_base?: string;
9
- customisations?: Customisations;
10
- public_key: string;
98
+ api_base?: string;
99
+ customisations?: Customisations;
100
+ metadata?: ConversationMetadata;
101
+ public_key: string;
11
102
  }
12
103
  type LorikeetWidgetWebViewProps = {
13
- uri: string;
14
- baseUrl?: string;
15
- webviewProps?: WebViewProps;
104
+ uri: string;
105
+ baseUrl?: string;
106
+ webviewProps?: WebViewProps;
107
+ onEvent?: (event: LorikeetWidgetEvent) => void;
16
108
  };
17
109
  type LorikeetWidgetHeaderProps = {
18
- title: string;
19
- style?: StyleProp<TextStyle>;
20
- icon?: React.ReactNode;
21
- onIconPress?: () => void;
110
+ title: string;
111
+ style?: StyleProp<TextStyle>;
112
+ icon?: React.ReactNode;
113
+ onIconPress?: () => void;
114
+ };
115
+ type LorikeetWidgetHandle = {
116
+ getConversation: () => {
117
+ minimised: boolean;
118
+ session?: string;
119
+ ticketId?: string;
120
+ } | null;
121
+ logout: () => void;
122
+ reopen: () => void;
22
123
  };
23
124
  type LorikeetWidgetViewProps = {
24
- publicKey: string;
25
- baseUrl?: string;
26
- authToken: string;
27
- onWebViewMessage?: (event: WebViewMessageEvent) => void;
28
- customisations?: Customisations;
29
- styles?: {
30
- header?: StyleProp<TextStyle>;
31
- };
125
+ publicKey: string;
126
+ baseUrl?: string;
127
+ authToken: string;
128
+ onWebViewMessage?: (event: WebViewMessageEvent) => void;
129
+ onEvent?: (event: LorikeetWidgetEvent) => void;
130
+ customisations?: Customisations;
131
+ styles?: {
132
+ header?: StyleProp<TextStyle>;
133
+ };
134
+ ticketId?: string;
135
+ session?: string;
136
+ metadata?: ConversationMetadata;
137
+ webviewProps?: WebViewProps;
32
138
  };
33
-
34
- declare const LorikeetWidgetWebView: react.ForwardRefExoticComponent<LorikeetWidgetWebViewProps & react.RefAttributes<WebView<{}>>>;
35
- declare const LorikeetWidgetHeader: ({ title, style, icon, onIconPress, }: LorikeetWidgetHeaderProps) => react_jsx_runtime.JSX.Element;
36
- declare function LorikeetWidgetView({ publicKey, baseUrl, authToken, customisations, styles, onWebViewMessage, }: LorikeetWidgetViewProps): react_jsx_runtime.JSX.Element | null;
37
-
139
+ //#endregion
140
+ //#region src/widget.d.ts
141
+ declare const LorikeetWidgetWebView: import("react").ForwardRefExoticComponent<LorikeetWidgetWebViewProps & import("react").RefAttributes<WebView<{}>>>;
142
+ declare const LorikeetWidgetHeader: ({ title, style, icon, onIconPress }: LorikeetWidgetHeaderProps) => import("react").JSX.Element;
143
+ declare const LorikeetWidgetView: import("react").ForwardRefExoticComponent<LorikeetWidgetViewProps & import("react").RefAttributes<LorikeetWidgetHandle>>;
144
+ //#endregion
145
+ //#region src/client.d.ts
38
146
  declare class LorikeetClient {
39
- baseUrl: string;
40
- customisations: Customisations | null;
41
- publicKey: string;
42
- constructor({ customisations, api_base, public_key }: LorikeetInitOptions);
43
- getWebviewUrl: ({ customer_email, customer_name, token, ticket_id, }: {
44
- customer_email?: string;
45
- customer_name?: string;
46
- token: string;
47
- ticket_id?: string;
48
- }) => string;
147
+ baseUrl: string;
148
+ customisations: Customisations | null;
149
+ metadata: ConversationMetadata | null;
150
+ publicKey: string;
151
+ constructor({ customisations, api_base, metadata, public_key }: LorikeetInitOptions);
152
+ getWebviewUrl: ({ customer_email, customer_name, token, ticket_id, session }: {
153
+ customer_email?: string;
154
+ customer_name?: string;
155
+ session?: string;
156
+ ticket_id?: string;
157
+ token: string;
158
+ }) => string;
159
+ getLogoutUrl: () => string;
49
160
  }
50
-
51
- export { LorikeetClient, type LorikeetInitOptions, LorikeetWidgetHeader, type LorikeetWidgetHeaderProps, LorikeetWidgetView, type LorikeetWidgetViewProps, LorikeetWidgetWebView, type LorikeetWidgetWebViewProps };
161
+ //#endregion
162
+ //#region src/errors.d.ts
163
+ declare const LORIKEET_ERROR_CODES: readonly ["MISSING_TOKEN", "CORRUPT_TOKEN_DATA", "DECRYPT_FAILED", "EXPIRED_TOKEN", "MALFORMED_TOKEN", "MISSING_PUBLIC_KEY", "UNKNOWN_PUBLIC_KEY", "CUSTOMER_ID_CONFLICT", "CUSTOMER_ID_MISSING", "FATAL_ERROR", "INVALID_SESSION", "DOMAIN_NOT_ALLOWED", "TICKET_NOT_FOUND"];
164
+ type LorikeetErrorCode = (typeof LORIKEET_ERROR_CODES)[number];
165
+ declare function isUnusableConversationCode(code: string): boolean;
166
+ declare function isUnusableConversation(message: unknown): boolean;
167
+ //#endregion
168
+ export { type CustomisationTheme, type Customisations, LORIKEET_ERROR_CODES, LorikeetClient, type LorikeetErrorCode, type LorikeetInitOptions, type LorikeetWidgetEvent, type LorikeetWidgetEventType, type LorikeetWidgetHandle, LorikeetWidgetHeader, type LorikeetWidgetHeaderProps, LorikeetWidgetView, type LorikeetWidgetViewProps, LorikeetWidgetWebView, type LorikeetWidgetWebViewProps, isUnusableConversation, isUnusableConversationCode };
169
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/conversation-metadata.ts","../src/customisations.ts","../src/events.ts","../src/types.ts","../src/widget.tsx","../src/client.ts","../src/errors.ts"],"mappings":";;;KAEY,uBAAuB;;;UCezB;EAER;EACA;EAEA;EAEA;EACA;;UAGe;EAEf;EACA;EACA,UAAU;EAEV;EAEA;EACA;EACA;IAEE;IAEA;IAMA;;EAEF,SAAS;EACT;EAOA;IACE;IACA;IACA;IACA;IACA;IAEA;;EAGF;EACA,QAAQ;EACR;EAEA;;UAGe;EAMf;EACA;EAEA;EACA;EAEA;EACA;EAQA;EAKA;EAEA;EAEA;EACA;EACA;EACA;EACA;;;;KC9FU;EAEN;;EAKA;EAAwB;;EAExB;;EAUA;EAAuB;;EASvB;EAAe;;EAOf;;EAKA;;EAKA;EAA2B;;EAE3B;EAAyB;;EAczB;;EAUA;;EAEA;EAAe;;EAYf;EACA;EACA;;KAIM;;;UCnGK;EAIf;EAIA,iBAAiB;EAKjB,WAAW;EAIX;;KAGU;EAIV;EAIA;EAIA,eAAe;EASf,WAAW,OAAO;;KAGR;EAIV;EAIA,QAAQ,UAAU;EAIlB,OAAO,MAAM;EAIb;;KAQU;EAwBV;IACE;IACA;IACA;;EA4BF;EAaA;;KAGU;EAIV;EAIA;EAIA;EAQA,oBAAoB,OAAO;EAK3B,WAAW,OAAO;EAIlB,iBAAiB;EAIjB;IACE,SAAS,UAAU;;EASrB;EAMA;EAMA,WAAW;EAOX,eAAe;;;;cCtHJ,uCAAqB,0BAAA,6CAAA,cAAA;cA2HrB,yBAAwB,OAAA,OAAA,MAAA,eAKlC,8CAAyB,IAAA;cAYf,oCAAkB,0BAAA,0CAAA,cAAA;;;cCjOlB;EACX;EACA,gBAAgB;EAChB,UAAU;EACV;EAEY,cACV,gBACA,UACA,UACA,cACC;EAeH,kBAAiB,gBAAA,eAAA,OAAA,WAAA;IAOf;IACA;IACA;IACA;IACA;;EAmDF;;;;cCxFW;KAgBD,4BAA4B;iBAexB,2BAA2B;iBAK3B,uBAAuB"}