@wildix/xbees-connect 1.3.8-alpha.1 → 1.3.8-alpha.3

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 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.8-alpha.1",
3
+ "version": "1.3.8-alpha.3",
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": "",
@@ -420,6 +420,38 @@ class Client {
420
420
  }
421
421
  });
422
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
+ }
423
455
  createContactIsSupported() {
424
456
  return this.sendAsync({
425
457
  type: enums_1.ClientEventType.CREATE_CONTACT_IS_SUPPORTED,
@@ -516,43 +548,5 @@ class Client {
516
548
  onCancelRedirectToEntityPage(callback) {
517
549
  return this.addEventListener(enums_1.EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE, callback);
518
550
  }
519
- onGetSupportedIntegrationContextKeys(callback) {
520
- // send event to x-bees
521
- void this.sendAsyncErrorSafe({
522
- type: enums_1.ClientEventType.SUPPORTED_INTEGRATION_CONTEXT_KEYS_IS_SUPPORTED,
523
- });
524
- return this.addEventListener(enums_1.EventType.GET_SUPPORTED_INTEGRATION_CONTEXT_KEYS, () => {
525
- const resolve = (keys) => this.sendAsync({
526
- type: enums_1.ClientEventType.SUPPORTED_INTEGRATION_CONTEXT_KEYS,
527
- payload: { keys },
528
- });
529
- const reject = (reason) => {
530
- console.debug(reason);
531
- };
532
- try {
533
- callback(resolve, reject);
534
- }
535
- catch (error) {
536
- reject(`${error}`);
537
- }
538
- });
539
- }
540
- onRequestIntegrationContext(callback) {
541
- return this.addEventListener(enums_1.EventType.REQUEST_INTEGRATION_CONTEXT, (payload) => {
542
- const resolve = (response) => this.sendAsync({
543
- type: enums_1.ClientEventType.INTEGRATION_CONTEXT_RESPONSE,
544
- payload: response,
545
- });
546
- const reject = (reason) => {
547
- console.debug(reason);
548
- };
549
- try {
550
- callback(payload, resolve, reject);
551
- }
552
- catch (error) {
553
- reject(`${error}`);
554
- }
555
- });
556
- }
557
551
  }
558
552
  exports.Client = Client;
@@ -17,8 +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_SUPPORTED_INTEGRATION_CONTEXT_KEYS"] = "xBeesGetSupportedIntegrationContextKeys";
21
- EventType["REQUEST_INTEGRATION_CONTEXT"] = "xBeesRequestIntegrationContext";
20
+ EventType["GET_INTEGRATION_PROXY_REQUEST"] = "xBeesGetIntegrationProxyRequest";
22
21
  })(EventType || (exports.EventType = EventType = {}));
23
22
  var ClientEventType;
24
23
  (function (ClientEventType) {
@@ -58,9 +57,8 @@ var ClientEventType;
58
57
  ClientEventType["CUSTOM_EVENT"] = "xBeesCustomEvent";
59
58
  ClientEventType["CREATE_CONTACT_IS_SUPPORTED"] = "xBeesCreateContactIsSupported";
60
59
  ClientEventType["CREATE_CONTACT_HAS_NO_PERMISSION"] = "xBeesCreateContactHasNoPermission";
61
- ClientEventType["SUPPORTED_INTEGRATION_CONTEXT_KEYS_IS_SUPPORTED"] = "xBeesSupportedIntegrationContextKeysIsSupported";
62
- ClientEventType["SUPPORTED_INTEGRATION_CONTEXT_KEYS"] = "xBeesSupportedIntegrationContextKeys";
63
- ClientEventType["INTEGRATION_CONTEXT_RESPONSE"] = "xBeesIntegrationContextResponse";
60
+ ClientEventType["INTEGRATION_PROXY_RESPONSE"] = "xBeesIntegrationProxyResponse";
61
+ ClientEventType["INTEGRATION_PROXY_REQUEST_IS_SUPPORTED"] = "xBeesIntegrationProxyRequestIsSupported";
64
62
  })(ClientEventType || (exports.ClientEventType = ClientEventType = {}));
65
63
  var UrlParams;
66
64
  (function (UrlParams) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildix/xbees-connect",
3
- "version": "1.3.8-alpha.1",
3
+ "version": "1.3.8-alpha.3",
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": "",
@@ -414,6 +414,38 @@ export class Client {
414
414
  }
415
415
  });
416
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
+ }
417
449
  createContactIsSupported() {
418
450
  return this.sendAsync({
419
451
  type: ClientEventType.CREATE_CONTACT_IS_SUPPORTED,
@@ -510,42 +542,4 @@ export class Client {
510
542
  onCancelRedirectToEntityPage(callback) {
511
543
  return this.addEventListener(EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE, callback);
512
544
  }
513
- onGetSupportedIntegrationContextKeys(callback) {
514
- // send event to x-bees
515
- void this.sendAsyncErrorSafe({
516
- type: ClientEventType.SUPPORTED_INTEGRATION_CONTEXT_KEYS_IS_SUPPORTED,
517
- });
518
- return this.addEventListener(EventType.GET_SUPPORTED_INTEGRATION_CONTEXT_KEYS, () => {
519
- const resolve = (keys) => this.sendAsync({
520
- type: ClientEventType.SUPPORTED_INTEGRATION_CONTEXT_KEYS,
521
- payload: { keys },
522
- });
523
- const reject = (reason) => {
524
- console.debug(reason);
525
- };
526
- try {
527
- callback(resolve, reject);
528
- }
529
- catch (error) {
530
- reject(`${error}`);
531
- }
532
- });
533
- }
534
- onRequestIntegrationContext(callback) {
535
- return this.addEventListener(EventType.REQUEST_INTEGRATION_CONTEXT, (payload) => {
536
- const resolve = (response) => this.sendAsync({
537
- type: ClientEventType.INTEGRATION_CONTEXT_RESPONSE,
538
- payload: response,
539
- });
540
- const reject = (reason) => {
541
- console.debug(reason);
542
- };
543
- try {
544
- callback(payload, resolve, reject);
545
- }
546
- catch (error) {
547
- reject(`${error}`);
548
- }
549
- });
550
- }
551
545
  }
@@ -14,8 +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_SUPPORTED_INTEGRATION_CONTEXT_KEYS"] = "xBeesGetSupportedIntegrationContextKeys";
18
- EventType["REQUEST_INTEGRATION_CONTEXT"] = "xBeesRequestIntegrationContext";
17
+ EventType["GET_INTEGRATION_PROXY_REQUEST"] = "xBeesGetIntegrationProxyRequest";
19
18
  })(EventType || (EventType = {}));
20
19
  export var ClientEventType;
21
20
  (function (ClientEventType) {
@@ -55,9 +54,8 @@ export var ClientEventType;
55
54
  ClientEventType["CUSTOM_EVENT"] = "xBeesCustomEvent";
56
55
  ClientEventType["CREATE_CONTACT_IS_SUPPORTED"] = "xBeesCreateContactIsSupported";
57
56
  ClientEventType["CREATE_CONTACT_HAS_NO_PERMISSION"] = "xBeesCreateContactHasNoPermission";
58
- ClientEventType["SUPPORTED_INTEGRATION_CONTEXT_KEYS_IS_SUPPORTED"] = "xBeesSupportedIntegrationContextKeysIsSupported";
59
- ClientEventType["SUPPORTED_INTEGRATION_CONTEXT_KEYS"] = "xBeesSupportedIntegrationContextKeys";
60
- ClientEventType["INTEGRATION_CONTEXT_RESPONSE"] = "xBeesIntegrationContextResponse";
57
+ ClientEventType["INTEGRATION_PROXY_RESPONSE"] = "xBeesIntegrationProxyResponse";
58
+ ClientEventType["INTEGRATION_PROXY_REQUEST_IS_SUPPORTED"] = "xBeesIntegrationProxyRequestIsSupported";
61
59
  })(ClientEventType || (ClientEventType = {}));
62
60
  export var UrlParams;
63
61
  (function (UrlParams) {
@@ -1,7 +1,7 @@
1
- import { Callback, ConnectClient, Contact, ContactQuery, IPayloadRequestIntegrationContext, 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 { GetSupportedIntegrationContextKeysResolver, LookupAndMatchBatchContactsResolver, RequestIntegrationContextResolver } 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;
@@ -118,6 +119,4 @@ export declare class Client implements ConnectClient {
118
119
  onContactRefresh(callback: Callback<EventType.CONTACT_REFRESH>): RemoveEventListener;
119
120
  onStartRedirectToEntityPage(callback: Callback<EventType.START_REDIRECT_TO_ENTITY_PAGE>): RemoveEventListener;
120
121
  onCancelRedirectToEntityPage(callback: Callback<EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE>): RemoveEventListener;
121
- onGetSupportedIntegrationContextKeys(callback: (resolve: GetSupportedIntegrationContextKeysResolver, reject: Reject) => void): RemoveEventListener;
122
- onRequestIntegrationContext(callback: (payload: IPayloadRequestIntegrationContext, resolve: RequestIntegrationContextResolver, reject: Reject) => void): RemoveEventListener;
123
122
  }
@@ -13,8 +13,7 @@ export declare enum EventType {
13
13
  CONTACT_REFRESH = "xBeesContactRefresh",
14
14
  START_REDIRECT_TO_ENTITY_PAGE = "xBeesStartRedirectToEntityPage",
15
15
  CANCEL_REDIRECT_TO_ENTITY_PAGE = "xBeesCancelRedirectToEntityPage",
16
- GET_SUPPORTED_INTEGRATION_CONTEXT_KEYS = "xBeesGetSupportedIntegrationContextKeys",
17
- REQUEST_INTEGRATION_CONTEXT = "xBeesRequestIntegrationContext"
16
+ GET_INTEGRATION_PROXY_REQUEST = "xBeesGetIntegrationProxyRequest"
18
17
  }
19
18
  export declare enum ClientEventType {
20
19
  READY = "xBeesReady",
@@ -53,9 +52,8 @@ export declare enum ClientEventType {
53
52
  CUSTOM_EVENT = "xBeesCustomEvent",
54
53
  CREATE_CONTACT_IS_SUPPORTED = "xBeesCreateContactIsSupported",
55
54
  CREATE_CONTACT_HAS_NO_PERMISSION = "xBeesCreateContactHasNoPermission",
56
- SUPPORTED_INTEGRATION_CONTEXT_KEYS_IS_SUPPORTED = "xBeesSupportedIntegrationContextKeysIsSupported",
57
- SUPPORTED_INTEGRATION_CONTEXT_KEYS = "xBeesSupportedIntegrationContextKeys",
58
- INTEGRATION_CONTEXT_RESPONSE = "xBeesIntegrationContextResponse"
55
+ INTEGRATION_PROXY_RESPONSE = "xBeesIntegrationProxyResponse",
56
+ INTEGRATION_PROXY_REQUEST_IS_SUPPORTED = "xBeesIntegrationProxyRequestIsSupported"
59
57
  }
60
58
  export declare enum UrlParams {
61
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 { IPayloadRequestIntegrationContext, IPayloadViewPort } from './Payload';
9
+ import { IntegrationProxyRequest, IPayloadViewPort } from './Payload';
10
10
  import { SupportedPlatformVariant } from './Platform';
11
- import { GetSupportedIntegrationContextKeysResolver, LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, RequestIntegrationContextResolver, 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>;
@@ -229,18 +236,4 @@ export interface ConnectClient {
229
236
  * Removes data about redirect to entity page from integration storage
230
237
  */
231
238
  onCancelRedirectToEntityPage: (callback: Callback<EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE>) => RemoveEventListener;
232
- /**
233
- * Registers a handler that returns the list of integration context keys this integration supports.
234
- * Announces integration context capability to xBees on registration.
235
- * Suitable for headless/daemon integrations.
236
- * Use resolve(keys) to respond. Use reject(reason) only for fatal/initialization errors.
237
- */
238
- onGetSupportedIntegrationContextKeys: (callback: (resolve: GetSupportedIntegrationContextKeysResolver, reject: Reject) => void) => RemoveEventListener;
239
- /**
240
- * Registers a handler for integration context requests from xBees.
241
- * xBees provides a query and a set of requested keys; the integration should return aggregated data.
242
- * For partial success, use resolve({ data, errors }) instead of reject.
243
- * Use reject(reason) only for invalid payload or fatal errors.
244
- */
245
- onRequestIntegrationContext: (callback: (payload: IPayloadRequestIntegrationContext, resolve: RequestIntegrationContextResolver, reject: Reject) => void) => RemoveEventListener;
246
239
  }
@@ -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, IPayloadIntegrationContextResponse, IPayloadRequestIntegrationContext, IPayloadSaveToStorage, IPayloadSendAnalytics, IPayloadStartRedirectToEntityPage, IPayloadSupportedIntegrationContextKeys, 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 : T extends EventType.GET_SUPPORTED_INTEGRATION_CONTEXT_KEYS ? undefined : T extends EventType.REQUEST_INTEGRATION_CONTEXT ? IPayloadRequestIntegrationContext : T extends ClientEventType.SUPPORTED_INTEGRATION_CONTEXT_KEYS ? IPayloadSupportedIntegrationContextKeys : T extends ClientEventType.INTEGRATION_CONTEXT_RESPONSE ? IPayloadIntegrationContextResponse : 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,8 +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_SUPPORTED_INTEGRATION_CONTEXT_KEYS]: undefined;
23
- [EventType.REQUEST_INTEGRATION_CONTEXT]: IPayloadRequestIntegrationContext;
22
+ [EventType.GET_INTEGRATION_PROXY_REQUEST]: IntegrationProxyRequest;
24
23
  };
25
24
  export type EventCallbackMap = {
26
25
  [EventType.GET_CONTACTS_AUTO_SUGGEST]: (query: EventPayloadMap[EventType.GET_CONTACTS_AUTO_SUGGEST]) => void;
@@ -35,8 +34,7 @@ export type EventCallbackMap = {
35
34
  [EventType.CONTACT_REFRESH]: (id: EventPayloadMap[EventType.CONTACT_REFRESH]) => void;
36
35
  [EventType.START_REDIRECT_TO_ENTITY_PAGE]: (params: EventPayloadMap[EventType.START_REDIRECT_TO_ENTITY_PAGE]) => void;
37
36
  [EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE]: (params: EventPayloadMap[EventType.CANCEL_REDIRECT_TO_ENTITY_PAGE]) => void;
38
- [EventType.GET_SUPPORTED_INTEGRATION_CONTEXT_KEYS]: (_?: undefined) => void;
39
- [EventType.REQUEST_INTEGRATION_CONTEXT]: (payload: EventPayloadMap[EventType.REQUEST_INTEGRATION_CONTEXT]) => void;
37
+ [EventType.GET_INTEGRATION_PROXY_REQUEST]: (request: EventPayloadMap[EventType.GET_INTEGRATION_PROXY_REQUEST]) => void;
40
38
  };
41
39
  export type RawMessageEvent = MessageEvent<string | Message>;
42
40
  export type ReadyExtendedProps = {
@@ -1,9 +1,9 @@
1
- import ClientParams from '../src/helpers/ClientParams';
2
- import { Contact, ContactQuery } from './Contact';
3
- import { Conversation } from './Conversation';
4
- import { JSONArray, JSONObject, JSONValue } from './Json';
5
- import { SupportedPlatformVariant } from './Platform';
6
- import { ToastSeverity } from './Toast';
1
+ import ClientParams from "../src/helpers/ClientParams";
2
+ import { Contact, ContactQuery } from "./Contact";
3
+ import { Conversation } from "./Conversation";
4
+ import { JSONArray, JSONObject, JSONValue } from "./Json";
5
+ import { SupportedPlatformVariant } from "./Platform";
6
+ import { ToastSeverity } from "./Toast";
7
7
  export interface IPayloadViewPort {
8
8
  height: number | string;
9
9
  width: number | string;
@@ -23,7 +23,7 @@ interface ThemeOptions {
23
23
  palette?: unknown;
24
24
  }
25
25
  export interface IPayloadThemeChange {
26
- mode: 'light' | 'dark';
26
+ mode: "light" | "dark";
27
27
  themeOptions?: ThemeOptions;
28
28
  }
29
29
  export interface IPayloadCallStartedInfo {
@@ -73,7 +73,7 @@ export interface IPayloadGetFromStorage {
73
73
  key: string;
74
74
  }
75
75
  export interface IPayloadTechSupport {
76
- 'x-iframe-params': ClientParams;
76
+ "x-iframe-params": ClientParams;
77
77
  message: string;
78
78
  data?: JSONObject | JSONArray;
79
79
  }
@@ -95,25 +95,33 @@ export interface IPayloadStartRedirectToEntityPage {
95
95
  export interface IPayloadCancelRedirectToEntityPage {
96
96
  conversationId: string;
97
97
  }
98
- export type IntegrationContextKey = string;
99
- export interface IPayloadSupportedIntegrationContextKeys {
100
- keys: IntegrationContextKey[];
101
- }
102
- export interface IPayloadRequestIntegrationContext {
103
- query: ContactQuery;
104
- keys: IntegrationContextKey[];
105
- }
106
- export interface IResolvedIntegrationEntity {
107
- id: string;
108
- type: string;
109
- name?: string;
110
- }
111
- export interface IPayloadIntegrationContextResponse {
112
- query: ContactQuery;
113
- requestedKeys: IntegrationContextKey[];
114
- supportedKeys: IntegrationContextKey[];
115
- resolvedEntity?: IResolvedIntegrationEntity;
116
- data: Partial<Record<IntegrationContextKey, unknown>>;
117
- errors?: Partial<Record<IntegrationContextKey, string>>;
98
+ /**
99
+ * Error codes for Salesforce read-only integration proxy responses.
100
+ */
101
+ export type IntegrationProxyErrorCode = "INVALID_PATH" | "PATH_NOT_ALLOWED" | "MISSING_QUERY_PARAM" | "INVALID_QUERY_PARAM" | "NOT_AUTHORIZED" | "EXECUTION_FAILED";
102
+ /**
103
+ * Request from x-bees to perform a read-only Salesforce REST call via the integration.
104
+ */
105
+ export interface IntegrationProxyRequest {
106
+ path: string;
107
+ query?: Record<string, string | number | boolean | null | undefined>;
108
+ requestId?: string;
109
+ }
110
+ /**
111
+ * Result sent back to x-bees after handling a proxy request (success or structured error).
112
+ */
113
+ export interface IntegrationProxyResponse {
114
+ ok: boolean;
115
+ requestId?: string;
116
+ path: string;
117
+ data?: unknown;
118
+ error?: {
119
+ code: IntegrationProxyErrorCode;
120
+ message: string;
121
+ };
122
+ meta: {
123
+ validated: boolean;
124
+ validationWarnings?: string[];
125
+ };
118
126
  }
119
127
  export {};
@@ -1,8 +1,7 @@
1
1
  import { Contact, ContactQuery } from './Contact';
2
- import { IntegrationContextKey, IPayloadIntegrationContextResponse } from './Payload';
2
+ import { IntegrationProxyResponse } from './Payload';
3
3
  export type SuggestContactsResolver = (contacts: Contact[]) => void;
4
4
  export type LookupAndMatchContactsResolver = (contact: Contact) => void;
5
5
  export type LookupAndMatchBatchContactsResolver = (contactResultsMap: Map<ContactQuery, Contact | null | undefined>) => void;
6
6
  export type Reject = (reason: string) => void;
7
- export type GetSupportedIntegrationContextKeysResolver = (keys: IntegrationContextKey[]) => void;
8
- export type RequestIntegrationContextResolver = (response: IPayloadIntegrationContextResponse) => 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 { IntegrationContextKey, IPayloadAutoSuggestResult, IPayloadCallStart, IPayloadCallStartedInfo, IPayloadCancelRedirectToEntityPage, IPayloadContactMatchResult, IPayloadContactMatchResultNotFound, IPayloadContactResult, IPayloadContextResult, IPayloadConversationResult, IPayloadIntegrationContextResponse, IPayloadRequestIntegrationContext, IPayloadSendAnalytics, IPayloadStartRedirectToEntityPage, IPayloadSupportedIntegrationContextKeys, IPayloadTechSupport, IPayloadThemeChange, IPayloadToast, IPayloadVersion, IPayloadViewPort, IResolvedIntegrationEntity, } from './Payload';
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 { GetSupportedIntegrationContextKeysResolver, LookupAndMatchBatchContactsResolver, LookupAndMatchContactsResolver, Reject, RequestIntegrationContextResolver, 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.8-alpha.1",
3
+ "version": "1.3.8-alpha.3",
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": "",