@wildix/xbees-connect 1.3.8 → 1.3.10
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 +22 -0
- package/dist-cjs/package.json +1 -1
- package/dist-cjs/src/Client.js +56 -6
- package/dist-cjs/src/enums/index.js +3 -0
- package/dist-es/package.json +1 -1
- package/dist-es/src/Client.js +56 -6
- package/dist-es/src/enums/index.js +3 -0
- package/dist-types/src/Client.d.ts +3 -2
- package/dist-types/src/enums/index.d.ts +5 -2
- package/dist-types/types/Client.d.ts +9 -2
- package/dist-types/types/Event.d.ts +4 -2
- package/dist-types/types/Payload.d.ts +33 -2
- package/dist-types/types/Resolver.d.ts +2 -0
- package/dist-types/types/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -302,6 +302,28 @@ Client.getInstance().onLookupAndMatchBatchContacts(async (queries, returnResults
|
|
|
302
302
|
});
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
+
#### `onIntegrationProxyRequest(callback: (request, resolve, reject) => void): RemoveEventListener`
|
|
306
|
+
|
|
307
|
+
Registers a handler for **read-only** Salesforce REST proxy requests from x-bees. Subscribe during app startup (same pattern as contact flows). On registration, x-bees is notified that the integration supports this flow (`INTEGRATION_PROXY_REQUEST_IS_SUPPORTED`).
|
|
308
|
+
|
|
309
|
+
- **Request** (`IntegrationProxyRequest`): `path` (relative Salesforce URL only), optional `query`, optional `requestId`.
|
|
310
|
+
- **Resolve** (`IntegrationProxyRequestResolver`): pass `IntegrationProxyResponse` with `ok`, `path`, optional `requestId` / `data` / `error`, and required `meta: { source: 'salesforce', validated, validationWarnings? }`. Structured domain errors use `error.code` (e.g. `NOT_AUTHORIZED`, `INVALID_PATH`, `PATH_NOT_ALLOWED`, `MISSING_QUERY_PARAM`, `INVALID_QUERY_PARAM`, `EXECUTION_FAILED`).
|
|
311
|
+
- If `response.error?.code === 'NOT_AUTHORIZED'`, the client calls `isNotAuthorized()` before sending the proxy response to x-bees.
|
|
312
|
+
- **Reject** (`Reject`): use only for unexpected runtime exceptions (string reason).
|
|
313
|
+
|
|
314
|
+
**Scope (first iteration):** read-only calls only. Use relative paths such as `/services/data/v59.0/sobjects/Contact/003...` or `/services/data/v59.0/query` with `query: { q: 'SELECT ...' }`. No composite, tooling, OAuth, create, update, or delete.
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
Client.getInstance().onIntegrationProxyRequest(async (request, resolve, reject) => {
|
|
318
|
+
try {
|
|
319
|
+
const response = await handleIntegrationProxyRequest(request);
|
|
320
|
+
resolve(response);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
reject(String(error));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
305
327
|
#### `createContactIsSupported(): Promise<ResponseMessage>`
|
|
306
328
|
|
|
307
329
|
Sends a signal to x-bees indicating that this integration supports creating contacts. Call once during initialization if your integration handles contact creation.
|
package/dist-cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "This library provides easy communication between x-bees and integrated web applications",
|
|
5
5
|
"author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
|
|
6
6
|
"homepage": "",
|
package/dist-cjs/src/Client.js
CHANGED
|
@@ -133,7 +133,11 @@ class Client {
|
|
|
133
133
|
ready(props = types_1.SupportedPlatformVariant.ALL) {
|
|
134
134
|
const payload = typeof props === 'string'
|
|
135
135
|
? { version: this.version(), platform: props }
|
|
136
|
-
: {
|
|
136
|
+
: {
|
|
137
|
+
version: this.version(),
|
|
138
|
+
...props,
|
|
139
|
+
platform: props.platform ?? types_1.SupportedPlatformVariant.ALL,
|
|
140
|
+
};
|
|
137
141
|
this.getXBeesUser();
|
|
138
142
|
return this.sendAsync({
|
|
139
143
|
type: enums_1.ClientEventType.READY,
|
|
@@ -141,10 +145,15 @@ class Client {
|
|
|
141
145
|
});
|
|
142
146
|
}
|
|
143
147
|
async requestXbeesUser() {
|
|
144
|
-
const responseMessageUser = await this.sendAsync({
|
|
148
|
+
const responseMessageUser = await this.sendAsync({
|
|
149
|
+
type: enums_1.ClientEventType.USER,
|
|
150
|
+
});
|
|
145
151
|
if (responseMessageUser.payload) {
|
|
146
152
|
const { extension, domain } = responseMessageUser.payload;
|
|
147
|
-
this.user = {
|
|
153
|
+
this.user = {
|
|
154
|
+
...responseMessageUser.payload,
|
|
155
|
+
email: this.getUserEmail(),
|
|
156
|
+
};
|
|
148
157
|
if (extension) {
|
|
149
158
|
this.userExtension = extension;
|
|
150
159
|
}
|
|
@@ -243,10 +252,16 @@ class Client {
|
|
|
243
252
|
return this.sendAsync({ type: enums_1.ClientEventType.AVAILABLE_CONTACT_DATA });
|
|
244
253
|
}
|
|
245
254
|
contactUpdated(query, contact) {
|
|
246
|
-
return this.sendAsync({
|
|
255
|
+
return this.sendAsync({
|
|
256
|
+
type: enums_1.ClientEventType.CONTACT_CREATE_OR_UPDATE,
|
|
257
|
+
payload: { query, contact },
|
|
258
|
+
});
|
|
247
259
|
}
|
|
248
260
|
contactMatchUpdated(query, contact) {
|
|
249
|
-
return this.sendAsync({
|
|
261
|
+
return this.sendAsync({
|
|
262
|
+
type: enums_1.ClientEventType.CONTACT_MATCH_UPDATE,
|
|
263
|
+
payload: { query, contact },
|
|
264
|
+
});
|
|
250
265
|
}
|
|
251
266
|
getThemeMode() {
|
|
252
267
|
return this.sendAsync({ type: enums_1.ClientEventType.THEME_MODE });
|
|
@@ -273,7 +288,10 @@ class Client {
|
|
|
273
288
|
return this.sendAsync({ type: enums_1.ClientEventType.TO_CLIPBOARD, payload });
|
|
274
289
|
}
|
|
275
290
|
showToast(message, severity = 'INFO') {
|
|
276
|
-
return this.sendAsync({
|
|
291
|
+
return this.sendAsync({
|
|
292
|
+
type: enums_1.ClientEventType.TOAST,
|
|
293
|
+
payload: { message, severity },
|
|
294
|
+
});
|
|
277
295
|
}
|
|
278
296
|
isNotAuthorized() {
|
|
279
297
|
return this.sendAsync({ type: enums_1.ClientEventType.NOT_AUTHORIZED });
|
|
@@ -402,6 +420,38 @@ class Client {
|
|
|
402
420
|
}
|
|
403
421
|
});
|
|
404
422
|
}
|
|
423
|
+
onIntegrationProxyRequest(callback) {
|
|
424
|
+
void this.sendAsyncErrorSafe({
|
|
425
|
+
type: enums_1.ClientEventType.INTEGRATION_PROXY_REQUEST_IS_SUPPORTED,
|
|
426
|
+
});
|
|
427
|
+
return this.addEventListener(enums_1.EventType.GET_INTEGRATION_PROXY_REQUEST, (request) => {
|
|
428
|
+
const resolve = (response) => {
|
|
429
|
+
void (async () => {
|
|
430
|
+
try {
|
|
431
|
+
if (response.error?.code === 'NOT_AUTHORIZED') {
|
|
432
|
+
await this.isNotAuthorized();
|
|
433
|
+
}
|
|
434
|
+
await this.sendAsync({
|
|
435
|
+
type: enums_1.ClientEventType.INTEGRATION_PROXY_RESPONSE,
|
|
436
|
+
payload: response,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
console.debug('integration proxy response send error', error);
|
|
441
|
+
}
|
|
442
|
+
})();
|
|
443
|
+
};
|
|
444
|
+
const reject = (reason) => {
|
|
445
|
+
console.debug(reason);
|
|
446
|
+
};
|
|
447
|
+
try {
|
|
448
|
+
callback(request, resolve, reject);
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
451
|
+
reject(`${error}`);
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
405
455
|
createContactIsSupported() {
|
|
406
456
|
return this.sendAsync({
|
|
407
457
|
type: enums_1.ClientEventType.CREATE_CONTACT_IS_SUPPORTED,
|
|
@@ -17,6 +17,7 @@ var EventType;
|
|
|
17
17
|
EventType["CONTACT_REFRESH"] = "xBeesContactRefresh";
|
|
18
18
|
EventType["START_REDIRECT_TO_ENTITY_PAGE"] = "xBeesStartRedirectToEntityPage";
|
|
19
19
|
EventType["CANCEL_REDIRECT_TO_ENTITY_PAGE"] = "xBeesCancelRedirectToEntityPage";
|
|
20
|
+
EventType["GET_INTEGRATION_PROXY_REQUEST"] = "xBeesGetIntegrationProxyRequest";
|
|
20
21
|
})(EventType || (exports.EventType = EventType = {}));
|
|
21
22
|
var ClientEventType;
|
|
22
23
|
(function (ClientEventType) {
|
|
@@ -56,6 +57,8 @@ var ClientEventType;
|
|
|
56
57
|
ClientEventType["CUSTOM_EVENT"] = "xBeesCustomEvent";
|
|
57
58
|
ClientEventType["CREATE_CONTACT_IS_SUPPORTED"] = "xBeesCreateContactIsSupported";
|
|
58
59
|
ClientEventType["CREATE_CONTACT_HAS_NO_PERMISSION"] = "xBeesCreateContactHasNoPermission";
|
|
60
|
+
ClientEventType["INTEGRATION_PROXY_RESPONSE"] = "xBeesIntegrationProxyResponse";
|
|
61
|
+
ClientEventType["INTEGRATION_PROXY_REQUEST_IS_SUPPORTED"] = "xBeesIntegrationProxyRequestIsSupported";
|
|
59
62
|
})(ClientEventType || (exports.ClientEventType = ClientEventType = {}));
|
|
60
63
|
var UrlParams;
|
|
61
64
|
(function (UrlParams) {
|
package/dist-es/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "This library provides easy communication between x-bees and integrated web applications",
|
|
5
5
|
"author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
|
|
6
6
|
"homepage": "",
|
package/dist-es/src/Client.js
CHANGED
|
@@ -127,7 +127,11 @@ export class Client {
|
|
|
127
127
|
ready(props = SupportedPlatformVariant.ALL) {
|
|
128
128
|
const payload = typeof props === 'string'
|
|
129
129
|
? { version: this.version(), platform: props }
|
|
130
|
-
: {
|
|
130
|
+
: {
|
|
131
|
+
version: this.version(),
|
|
132
|
+
...props,
|
|
133
|
+
platform: props.platform ?? SupportedPlatformVariant.ALL,
|
|
134
|
+
};
|
|
131
135
|
this.getXBeesUser();
|
|
132
136
|
return this.sendAsync({
|
|
133
137
|
type: ClientEventType.READY,
|
|
@@ -135,10 +139,15 @@ export class Client {
|
|
|
135
139
|
});
|
|
136
140
|
}
|
|
137
141
|
async requestXbeesUser() {
|
|
138
|
-
const responseMessageUser = await this.sendAsync({
|
|
142
|
+
const responseMessageUser = await this.sendAsync({
|
|
143
|
+
type: ClientEventType.USER,
|
|
144
|
+
});
|
|
139
145
|
if (responseMessageUser.payload) {
|
|
140
146
|
const { extension, domain } = responseMessageUser.payload;
|
|
141
|
-
this.user = {
|
|
147
|
+
this.user = {
|
|
148
|
+
...responseMessageUser.payload,
|
|
149
|
+
email: this.getUserEmail(),
|
|
150
|
+
};
|
|
142
151
|
if (extension) {
|
|
143
152
|
this.userExtension = extension;
|
|
144
153
|
}
|
|
@@ -237,10 +246,16 @@ export class Client {
|
|
|
237
246
|
return this.sendAsync({ type: ClientEventType.AVAILABLE_CONTACT_DATA });
|
|
238
247
|
}
|
|
239
248
|
contactUpdated(query, contact) {
|
|
240
|
-
return this.sendAsync({
|
|
249
|
+
return this.sendAsync({
|
|
250
|
+
type: ClientEventType.CONTACT_CREATE_OR_UPDATE,
|
|
251
|
+
payload: { query, contact },
|
|
252
|
+
});
|
|
241
253
|
}
|
|
242
254
|
contactMatchUpdated(query, contact) {
|
|
243
|
-
return this.sendAsync({
|
|
255
|
+
return this.sendAsync({
|
|
256
|
+
type: ClientEventType.CONTACT_MATCH_UPDATE,
|
|
257
|
+
payload: { query, contact },
|
|
258
|
+
});
|
|
244
259
|
}
|
|
245
260
|
getThemeMode() {
|
|
246
261
|
return this.sendAsync({ type: ClientEventType.THEME_MODE });
|
|
@@ -267,7 +282,10 @@ export class Client {
|
|
|
267
282
|
return this.sendAsync({ type: ClientEventType.TO_CLIPBOARD, payload });
|
|
268
283
|
}
|
|
269
284
|
showToast(message, severity = 'INFO') {
|
|
270
|
-
return this.sendAsync({
|
|
285
|
+
return this.sendAsync({
|
|
286
|
+
type: ClientEventType.TOAST,
|
|
287
|
+
payload: { message, severity },
|
|
288
|
+
});
|
|
271
289
|
}
|
|
272
290
|
isNotAuthorized() {
|
|
273
291
|
return this.sendAsync({ type: ClientEventType.NOT_AUTHORIZED });
|
|
@@ -396,6 +414,38 @@ export class Client {
|
|
|
396
414
|
}
|
|
397
415
|
});
|
|
398
416
|
}
|
|
417
|
+
onIntegrationProxyRequest(callback) {
|
|
418
|
+
void this.sendAsyncErrorSafe({
|
|
419
|
+
type: ClientEventType.INTEGRATION_PROXY_REQUEST_IS_SUPPORTED,
|
|
420
|
+
});
|
|
421
|
+
return this.addEventListener(EventType.GET_INTEGRATION_PROXY_REQUEST, (request) => {
|
|
422
|
+
const resolve = (response) => {
|
|
423
|
+
void (async () => {
|
|
424
|
+
try {
|
|
425
|
+
if (response.error?.code === 'NOT_AUTHORIZED') {
|
|
426
|
+
await this.isNotAuthorized();
|
|
427
|
+
}
|
|
428
|
+
await this.sendAsync({
|
|
429
|
+
type: ClientEventType.INTEGRATION_PROXY_RESPONSE,
|
|
430
|
+
payload: response,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
catch (error) {
|
|
434
|
+
console.debug('integration proxy response send error', error);
|
|
435
|
+
}
|
|
436
|
+
})();
|
|
437
|
+
};
|
|
438
|
+
const reject = (reason) => {
|
|
439
|
+
console.debug(reason);
|
|
440
|
+
};
|
|
441
|
+
try {
|
|
442
|
+
callback(request, resolve, reject);
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
reject(`${error}`);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
399
449
|
createContactIsSupported() {
|
|
400
450
|
return this.sendAsync({
|
|
401
451
|
type: ClientEventType.CREATE_CONTACT_IS_SUPPORTED,
|
|
@@ -14,6 +14,7 @@ export var EventType;
|
|
|
14
14
|
EventType["CONTACT_REFRESH"] = "xBeesContactRefresh";
|
|
15
15
|
EventType["START_REDIRECT_TO_ENTITY_PAGE"] = "xBeesStartRedirectToEntityPage";
|
|
16
16
|
EventType["CANCEL_REDIRECT_TO_ENTITY_PAGE"] = "xBeesCancelRedirectToEntityPage";
|
|
17
|
+
EventType["GET_INTEGRATION_PROXY_REQUEST"] = "xBeesGetIntegrationProxyRequest";
|
|
17
18
|
})(EventType || (EventType = {}));
|
|
18
19
|
export var ClientEventType;
|
|
19
20
|
(function (ClientEventType) {
|
|
@@ -53,6 +54,8 @@ export var ClientEventType;
|
|
|
53
54
|
ClientEventType["CUSTOM_EVENT"] = "xBeesCustomEvent";
|
|
54
55
|
ClientEventType["CREATE_CONTACT_IS_SUPPORTED"] = "xBeesCreateContactIsSupported";
|
|
55
56
|
ClientEventType["CREATE_CONTACT_HAS_NO_PERMISSION"] = "xBeesCreateContactHasNoPermission";
|
|
57
|
+
ClientEventType["INTEGRATION_PROXY_RESPONSE"] = "xBeesIntegrationProxyResponse";
|
|
58
|
+
ClientEventType["INTEGRATION_PROXY_REQUEST_IS_SUPPORTED"] = "xBeesIntegrationProxyRequestIsSupported";
|
|
56
59
|
})(ClientEventType || (ClientEventType = {}));
|
|
57
60
|
export var UrlParams;
|
|
58
61
|
(function (UrlParams) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Callback, ConnectClient, Contact, ContactQuery, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, StorageEventCallback, SuggestContactsResolver, SupportedPlatformVariant, ToastSeverity, XBeesUser } from '../types';
|
|
1
|
+
import { Callback, ConnectClient, Contact, ContactQuery, IntegrationProxyRequest, IPayloadViewPort, LookupAndMatchContactsResolver, Message, Reject, RemoveEventListener, ResponseMessage, StorageEventCallback, SuggestContactsResolver, SupportedPlatformVariant, ToastSeverity, XBeesUser } from '../types';
|
|
2
2
|
import { ReadyExtendedProps } from '../types/Event';
|
|
3
3
|
import { JSONValue } from '../types/Json';
|
|
4
|
-
import { LookupAndMatchBatchContactsResolver } from '../types/Resolver';
|
|
4
|
+
import { IntegrationProxyRequestResolver, LookupAndMatchBatchContactsResolver } from '../types/Resolver';
|
|
5
5
|
import { ClientEventType, EventType, Product, StartPage } from './enums';
|
|
6
6
|
import TechnicalSupport from './helpers/TechnicalSupport';
|
|
7
7
|
/**
|
|
@@ -93,6 +93,7 @@ export declare class Client implements ConnectClient {
|
|
|
93
93
|
onSuggestContacts(callback: (query: string, resolve: SuggestContactsResolver, reject: Reject) => void): RemoveEventListener;
|
|
94
94
|
onLookupAndMatchContact(callback: (query: ContactQuery, resolve: LookupAndMatchContactsResolver, reject: Reject) => void): RemoveEventListener;
|
|
95
95
|
onLookupAndMatchBatchContacts(callback: (query: ContactQuery[], returnResults: LookupAndMatchBatchContactsResolver) => void): RemoveEventListener;
|
|
96
|
+
onIntegrationProxyRequest(callback: (request: IntegrationProxyRequest, resolve: IntegrationProxyRequestResolver, reject: Reject) => void): RemoveEventListener;
|
|
96
97
|
createContactIsSupported(): Promise<ResponseMessage>;
|
|
97
98
|
createContactHasNoPermission(): Promise<ResponseMessage>;
|
|
98
99
|
onThemeChange(callback: Callback<EventType.USE_THEME>): RemoveEventListener;
|
|
@@ -12,7 +12,8 @@ export declare enum EventType {
|
|
|
12
12
|
CONTACT_WEIGHT_UPDATE = "xBeesContactWeightUpdate",
|
|
13
13
|
CONTACT_REFRESH = "xBeesContactRefresh",
|
|
14
14
|
START_REDIRECT_TO_ENTITY_PAGE = "xBeesStartRedirectToEntityPage",
|
|
15
|
-
CANCEL_REDIRECT_TO_ENTITY_PAGE = "xBeesCancelRedirectToEntityPage"
|
|
15
|
+
CANCEL_REDIRECT_TO_ENTITY_PAGE = "xBeesCancelRedirectToEntityPage",
|
|
16
|
+
GET_INTEGRATION_PROXY_REQUEST = "xBeesGetIntegrationProxyRequest"
|
|
16
17
|
}
|
|
17
18
|
export declare enum ClientEventType {
|
|
18
19
|
READY = "xBeesReady",
|
|
@@ -50,7 +51,9 @@ export declare enum ClientEventType {
|
|
|
50
51
|
DROPDOWN_VISIBILITY = "xBeesDropdownVisibility",
|
|
51
52
|
CUSTOM_EVENT = "xBeesCustomEvent",
|
|
52
53
|
CREATE_CONTACT_IS_SUPPORTED = "xBeesCreateContactIsSupported",
|
|
53
|
-
CREATE_CONTACT_HAS_NO_PERMISSION = "xBeesCreateContactHasNoPermission"
|
|
54
|
+
CREATE_CONTACT_HAS_NO_PERMISSION = "xBeesCreateContactHasNoPermission",
|
|
55
|
+
INTEGRATION_PROXY_RESPONSE = "xBeesIntegrationProxyResponse",
|
|
56
|
+
INTEGRATION_PROXY_REQUEST_IS_SUPPORTED = "xBeesIntegrationProxyRequestIsSupported"
|
|
54
57
|
}
|
|
55
58
|
export declare enum UrlParams {
|
|
56
59
|
TOKEN = "t",
|
|
@@ -6,9 +6,9 @@ import { ReadyExtendedProps } from './Event';
|
|
|
6
6
|
import { JSONValue } from './Json';
|
|
7
7
|
import { RemoveEventListener } from './Listener';
|
|
8
8
|
import { ResponseMessage } from './Message';
|
|
9
|
-
import { IPayloadViewPort } from './Payload';
|
|
9
|
+
import { IntegrationProxyRequest, IPayloadViewPort } from './Payload';
|
|
10
10
|
import { SupportedPlatformVariant } from './Platform';
|
|
11
|
-
import { LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
|
|
11
|
+
import { IntegrationProxyRequestResolver, LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver } from './Resolver';
|
|
12
12
|
import { StorageEventCallback } from './Storage';
|
|
13
13
|
import { ToastSeverity } from './Toast';
|
|
14
14
|
import { XBeesUser } from './XBeesUser';
|
|
@@ -148,6 +148,13 @@ export interface ConnectClient {
|
|
|
148
148
|
/**
|
|
149
149
|
* Starts listen for the events of searching batch contacts info and handle match with the provided callback */
|
|
150
150
|
onLookupAndMatchBatchContacts: (callback: (queries: ContactQuery[], returnResults: LookupAndMatchBatchContactsResolver) => void) => RemoveEventListener;
|
|
151
|
+
/**
|
|
152
|
+
* Listens for read-only Salesforce REST proxy requests from x-bees.
|
|
153
|
+
* On registration, notifies x-bees that this integration supports the proxy flow.
|
|
154
|
+
* Call `resolve(response)` with structured success or error; use `reject(reason)` only for unexpected runtime failures.
|
|
155
|
+
* When `response.error?.code === 'NOT_AUTHORIZED'`, the client notifies x-bees via `isNotAuthorized()` before sending the proxy response.
|
|
156
|
+
*/
|
|
157
|
+
onIntegrationProxyRequest: (callback: (request: IntegrationProxyRequest, resolve: IntegrationProxyRequestResolver, reject: Reject) => void) => RemoveEventListener;
|
|
151
158
|
/**
|
|
152
159
|
* Send event for indicate if create contact functionality is supported */
|
|
153
160
|
createContactIsSupported: () => Promise<ResponseMessage>;
|
|
@@ -2,10 +2,10 @@ import { ClientEventType, EventType } from '../src/enums';
|
|
|
2
2
|
import { AvailableContactData } from './AvailableContactData';
|
|
3
3
|
import { ContactQuery } from './Contact';
|
|
4
4
|
import { Message, MessageType } from './Message';
|
|
5
|
-
import { IPayloadAutoSuggestResult, IPayloadBatchContactsMatchResult, IPayloadBatchContactsMatchResultError, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadCancelRedirectToEntityPage, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContactWeightUpdate, IPayloadContextResult, IPayloadConversationResult, IPayloadCustomEvent, IPayloadDropdownVisibility, IPayloadGetFromStorage, IPayloadSaveToStorage, IPayloadSendAnalytics, IPayloadStartRedirectToEntityPage, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
|
|
5
|
+
import { IntegrationProxyRequest, IntegrationProxyResponse, IPayloadAutoSuggestResult, IPayloadBatchContactsMatchResult, IPayloadBatchContactsMatchResultError, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadCancelRedirectToEntityPage, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContactWeightUpdate, IPayloadContextResult, IPayloadConversationResult, IPayloadCustomEvent, IPayloadDropdownVisibility, IPayloadGetFromStorage, IPayloadSaveToStorage, IPayloadSendAnalytics, IPayloadStartRedirectToEntityPage, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort } from './Payload';
|
|
6
6
|
import { SupportedPlatformVariant } from './Platform';
|
|
7
7
|
import { XBeesUser } from './XBeesUser';
|
|
8
|
-
export type EventPayload<T extends MessageType> = T extends EventType.GET_CONTACTS_AUTO_SUGGEST ? string : T extends ClientEventType.CONTACTS_AUTO_SUGGEST ? IPayloadAutoSuggestResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH | ClientEventType.CONTACT_CREATE_OR_UPDATE | ClientEventType.CONTACT_MATCH_UPDATE ? IPayloadContactMatchResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH_NOT_FOUND ? IPayloadContactMatchResultNotFound : T extends ClientEventType.LOOKUP_AND_MATCH_BATCH_ERROR ? IPayloadBatchContactsMatchResultError : T extends ClientEventType.CONTEXT ? IPayloadContextResult : T extends ClientEventType.CURRENT_CONTACT ? IPayloadContactResult : T extends ClientEventType.CURRENT_CONVERSATION ? IPayloadConversationResult : T extends EventType.ADD_CALL ? IPayloadCallStartedInfo : T extends ClientEventType.START_CALL ? IPayloadCallStart : T extends ClientEventType.READY ? IPayloadVersion : T extends ClientEventType.VIEW_PORT ? IPayloadViewPort : T extends ClientEventType.THEME ? IPayloadThemeChange : T extends EventType.USE_THEME ? IPayloadThemeChange : T extends ClientEventType.TOAST ? IPayloadToast : T extends ClientEventType.SEND_ANALYTICS ? IPayloadSendAnalytics : T extends ClientEventType.SEND_TECHNICAL_SUPPORT_INFORMATION ? IPayloadTechSupport : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : T extends EventType.GET_LOOK_UP_AND_MATCH ? ContactQuery : T extends EventType.GET_LOOK_UP_AND_MATCH_BATCH ? ContactQuery[] : T extends EventType.VISIBILITY ? boolean : T extends ClientEventType.USER ? XBeesUser : T extends ClientEventType.SAVE_TO_STORAGE ? IPayloadSaveToStorage : T extends ClientEventType.GET_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.REMOVE_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.AVAILABLE_CONTACT_DATA ? AvailableContactData | null : T extends ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS ? IPayloadBatchContactsMatchResult : T extends ClientEventType.DROPDOWN_VISIBILITY ? IPayloadDropdownVisibility : T extends ClientEventType.CUSTOM_EVENT ? IPayloadCustomEvent : T extends EventType.START_REDIRECT_TO_ENTITY_PAGE ? IPayloadStartRedirectToEntityPage : T extends EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE ? IPayloadCancelRedirectToEntityPage : never;
|
|
8
|
+
export type EventPayload<T extends MessageType> = T extends EventType.GET_CONTACTS_AUTO_SUGGEST ? string : T extends ClientEventType.CONTACTS_AUTO_SUGGEST ? IPayloadAutoSuggestResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH | ClientEventType.CONTACT_CREATE_OR_UPDATE | ClientEventType.CONTACT_MATCH_UPDATE ? IPayloadContactMatchResult : T extends ClientEventType.CONTACT_LOOKUP_AND_MATCH_NOT_FOUND ? IPayloadContactMatchResultNotFound : T extends ClientEventType.LOOKUP_AND_MATCH_BATCH_ERROR ? IPayloadBatchContactsMatchResultError : T extends ClientEventType.CONTEXT ? IPayloadContextResult : T extends ClientEventType.CURRENT_CONTACT ? IPayloadContactResult : T extends ClientEventType.CURRENT_CONVERSATION ? IPayloadConversationResult : T extends EventType.ADD_CALL ? IPayloadCallStartedInfo : T extends ClientEventType.START_CALL ? IPayloadCallStart : T extends ClientEventType.READY ? IPayloadVersion : T extends ClientEventType.VIEW_PORT ? IPayloadViewPort : T extends ClientEventType.THEME ? IPayloadThemeChange : T extends EventType.USE_THEME ? IPayloadThemeChange : T extends ClientEventType.TOAST ? IPayloadToast : T extends ClientEventType.SEND_ANALYTICS ? IPayloadSendAnalytics : T extends ClientEventType.SEND_TECHNICAL_SUPPORT_INFORMATION ? IPayloadTechSupport : T extends EventType.PBX_TOKEN ? string : T extends ClientEventType.TOKEN ? string : T extends ClientEventType.TO_CLIPBOARD ? string : T extends EventType.GET_LOOK_UP_AND_MATCH ? ContactQuery : T extends EventType.GET_LOOK_UP_AND_MATCH_BATCH ? ContactQuery[] : T extends EventType.VISIBILITY ? boolean : T extends ClientEventType.USER ? XBeesUser : T extends ClientEventType.SAVE_TO_STORAGE ? IPayloadSaveToStorage : T extends ClientEventType.GET_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.REMOVE_FROM_STORAGE ? IPayloadGetFromStorage : T extends ClientEventType.AVAILABLE_CONTACT_DATA ? AvailableContactData | null : T extends ClientEventType.LOOK_UP_AND_MATCH_BATCH_CONTACTS ? IPayloadBatchContactsMatchResult : T extends ClientEventType.DROPDOWN_VISIBILITY ? IPayloadDropdownVisibility : T extends ClientEventType.CUSTOM_EVENT ? IPayloadCustomEvent : T extends EventType.START_REDIRECT_TO_ENTITY_PAGE ? IPayloadStartRedirectToEntityPage : T extends EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE ? IPayloadCancelRedirectToEntityPage : T extends EventType.GET_INTEGRATION_PROXY_REQUEST ? IntegrationProxyRequest : T extends ClientEventType.INTEGRATION_PROXY_RESPONSE ? IntegrationProxyResponse : T extends ClientEventType.INTEGRATION_PROXY_REQUEST_IS_SUPPORTED ? undefined : never;
|
|
9
9
|
export type EventPayloadMap = {
|
|
10
10
|
[EventType.GET_CONTACTS_AUTO_SUGGEST]: string;
|
|
11
11
|
[EventType.GET_LOOK_UP_AND_MATCH]: ContactQuery;
|
|
@@ -19,6 +19,7 @@ export type EventPayloadMap = {
|
|
|
19
19
|
[EventType.CONTACT_REFRESH]: string;
|
|
20
20
|
[EventType.START_REDIRECT_TO_ENTITY_PAGE]: IPayloadStartRedirectToEntityPage;
|
|
21
21
|
[EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE]: IPayloadCancelRedirectToEntityPage;
|
|
22
|
+
[EventType.GET_INTEGRATION_PROXY_REQUEST]: IntegrationProxyRequest;
|
|
22
23
|
};
|
|
23
24
|
export type EventCallbackMap = {
|
|
24
25
|
[EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
|
|
@@ -33,6 +34,7 @@ export type EventCallbackMap = {
|
|
|
33
34
|
[EventType.CONTACT_REFRESH]: (id: EventPayloadMap[EventType.CONTACT_REFRESH]) => void;
|
|
34
35
|
[EventType.START_REDIRECT_TO_ENTITY_PAGE]: (params: EventPayloadMap[EventType.START_REDIRECT_TO_ENTITY_PAGE]) => void;
|
|
35
36
|
[EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE]: (params: EventPayloadMap[EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE]) => void;
|
|
37
|
+
[EventType.GET_INTEGRATION_PROXY_REQUEST]: (request: EventPayloadMap[EventType.GET_INTEGRATION_PROXY_REQUEST]) => void;
|
|
36
38
|
};
|
|
37
39
|
export type RawMessageEvent = MessageEvent<string | Message>;
|
|
38
40
|
export type ReadyExtendedProps = {
|
|
@@ -89,10 +89,41 @@ export interface IPayloadContactWeightUpdate {
|
|
|
89
89
|
query: ContactQuery;
|
|
90
90
|
}
|
|
91
91
|
export interface IPayloadStartRedirectToEntityPage {
|
|
92
|
-
|
|
92
|
+
callId?: string;
|
|
93
|
+
conversationId?: string;
|
|
93
94
|
pageName: string;
|
|
94
95
|
}
|
|
95
96
|
export interface IPayloadCancelRedirectToEntityPage {
|
|
96
|
-
conversationId
|
|
97
|
+
conversationId?: string;
|
|
98
|
+
callId?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Error codes for Salesforce read-only integration proxy responses.
|
|
102
|
+
*/
|
|
103
|
+
export type IntegrationProxyErrorCode = 'INVALID_PATH' | 'PATH_NOT_ALLOWED' | 'MISSING_QUERY_PARAM' | 'INVALID_QUERY_PARAM' | 'NOT_AUTHORIZED' | 'EXECUTION_FAILED';
|
|
104
|
+
/**
|
|
105
|
+
* Request from x-bees to perform a read-only Salesforce REST call via the integration.
|
|
106
|
+
*/
|
|
107
|
+
export interface IntegrationProxyRequest {
|
|
108
|
+
path: string;
|
|
109
|
+
query?: Record<string, string | number | boolean | null | undefined>;
|
|
110
|
+
requestId?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Result sent back to x-bees after handling a proxy request (success or structured error).
|
|
114
|
+
*/
|
|
115
|
+
export interface IntegrationProxyResponse {
|
|
116
|
+
ok: boolean;
|
|
117
|
+
requestId?: string;
|
|
118
|
+
path: string;
|
|
119
|
+
data?: unknown;
|
|
120
|
+
error?: {
|
|
121
|
+
code: IntegrationProxyErrorCode;
|
|
122
|
+
message: string;
|
|
123
|
+
};
|
|
124
|
+
meta: {
|
|
125
|
+
validated: boolean;
|
|
126
|
+
validationWarnings?: string[];
|
|
127
|
+
};
|
|
97
128
|
}
|
|
98
129
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Contact, ContactQuery } from './Contact';
|
|
2
|
+
import { IntegrationProxyResponse } from './Payload';
|
|
2
3
|
export type SuggestContactsResolver = (contacts: Contact[]) => void;
|
|
3
4
|
export type LookupAndMatchContactsResolver = (contact: Contact) => void;
|
|
4
5
|
export type LookupAndMatchBatchContactsResolver = (contactResultsMap: Map<ContactQuery, Contact | null | undefined>) => void;
|
|
5
6
|
export type Reject = (reason: string) => void;
|
|
7
|
+
export type IntegrationProxyRequestResolver = (response: IntegrationProxyResponse) => void;
|
|
@@ -7,9 +7,9 @@ export type { JSONArray, JSONObject } from './Json';
|
|
|
7
7
|
export type { Listener, RemoveEventListener } from './Listener';
|
|
8
8
|
export type { Message, MessageIFrameResponse, MessageType, ResponseMessage } from './Message';
|
|
9
9
|
export type { MessageSender } from './MessageSender';
|
|
10
|
-
export type { IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort,
|
|
10
|
+
export type { IntegrationProxyErrorCode, IntegrationProxyRequest, IntegrationProxyResponse, IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadCancelRedirectToEntityPage, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadSendAnalytics, IPayloadStartRedirectToEntityPage, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort, } from './Payload';
|
|
11
11
|
export { SupportedPlatformVariant } from './Platform';
|
|
12
|
-
export type { LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver, } from './Resolver';
|
|
12
|
+
export type { IntegrationProxyRequestResolver, LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, SuggestContactsResolver, } from './Resolver';
|
|
13
13
|
export type { StorageEventCallback } from './Storage';
|
|
14
14
|
export type { ToastSeverity } from './Toast';
|
|
15
15
|
export type { WorkVariants } from './WorkVariant';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildix/xbees-connect",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.10",
|
|
4
4
|
"description": "This library provides easy communication between x-bees and integrated web applications",
|
|
5
5
|
"author": "dimitri.chernykh <dimitri.chernykh@wildix.com>",
|
|
6
6
|
"homepage": "",
|