@openfin/cloud-api 0.0.1-alpha.fe79c9b → 0.0.1-alpha.fec3349
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +351 -26
- package/dist/index.d.ts +351 -26
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as OpenFin from '@openfin/core';
|
|
2
|
-
import OpenFin__default from '@openfin/core';
|
|
2
|
+
import OpenFin__default, { OpenFin as OpenFin$1 } from '@openfin/core';
|
|
3
3
|
import * as NotificationsTypes from '@openfin/workspace/notifications';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -305,7 +305,7 @@ declare function launchWorkspace(id: string): Promise<void>;
|
|
|
305
305
|
*
|
|
306
306
|
* @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required.
|
|
307
307
|
*/
|
|
308
|
-
type OnActionListener = (action: SearchAction, result: SearchResult) => SearchResultActionResponse | Promise<SearchResultActionResponse>;
|
|
308
|
+
type OnActionListener = (action: SearchAction$1, result: SearchResult$1) => SearchResultActionResponse$1 | Promise<SearchResultActionResponse$1>;
|
|
309
309
|
/**
|
|
310
310
|
* Function that is called when the Search Agent receives a query from Here™’s search UI
|
|
311
311
|
*
|
|
@@ -313,13 +313,13 @@ type OnActionListener = (action: SearchAction, result: SearchResult) => SearchRe
|
|
|
313
313
|
*
|
|
314
314
|
* @returns Search response data that includes the search results.
|
|
315
315
|
*/
|
|
316
|
-
type OnSearchListener = (request: SearchListenerRequest) => SearchResponse | Promise<SearchResponse>;
|
|
316
|
+
type OnSearchListener = (request: SearchListenerRequest$1) => SearchResponse$1 | Promise<SearchResponse$1>;
|
|
317
317
|
/**
|
|
318
318
|
* An action that can be triggered by a user on a search result returned by a Search Agent.
|
|
319
319
|
*
|
|
320
320
|
* Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result.
|
|
321
321
|
*/
|
|
322
|
-
type SearchAction = {
|
|
322
|
+
type SearchAction$1 = {
|
|
323
323
|
/**
|
|
324
324
|
* URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode.
|
|
325
325
|
*/
|
|
@@ -343,6 +343,8 @@ type SearchAction = {
|
|
|
343
343
|
};
|
|
344
344
|
/**
|
|
345
345
|
* A Search Agent returns search results to Here™’s search UI in response to user input, and acts on the user’s actions regarding those results.
|
|
346
|
+
*
|
|
347
|
+
* @deprecated Use {@link Agent} instead.
|
|
346
348
|
*/
|
|
347
349
|
type SearchAgent = {
|
|
348
350
|
/**
|
|
@@ -351,6 +353,8 @@ type SearchAgent = {
|
|
|
351
353
|
* When a Search Agent is first registered, it will not receive search queries until it is set as ready by calling this function.
|
|
352
354
|
*
|
|
353
355
|
* @param ready Whether the Search Agent is ready to provide search results (defaults to `true`).
|
|
356
|
+
*
|
|
357
|
+
* @deprecated Use {@link Agent.setIsReady} instead.
|
|
354
358
|
*/
|
|
355
359
|
isReady: (ready?: boolean) => Promise<void>;
|
|
356
360
|
};
|
|
@@ -401,11 +405,11 @@ type SearchAgentRegistrationConfig = {
|
|
|
401
405
|
/**
|
|
402
406
|
* Search request data provided to the {@link OnSearchListener}.
|
|
403
407
|
*/
|
|
404
|
-
type SearchListenerRequest = {
|
|
408
|
+
type SearchListenerRequest$1 = {
|
|
405
409
|
/**
|
|
406
410
|
* Provides additional context for the search request.
|
|
407
411
|
*/
|
|
408
|
-
context: SearchRequestContext;
|
|
412
|
+
context: SearchRequestContext$1;
|
|
409
413
|
/**
|
|
410
414
|
* The query entered by the user in Here™’s search UI.
|
|
411
415
|
*/
|
|
@@ -418,7 +422,7 @@ type SearchListenerRequest = {
|
|
|
418
422
|
/**
|
|
419
423
|
* Context data included with a search request.
|
|
420
424
|
*/
|
|
421
|
-
type SearchRequestContext = {
|
|
425
|
+
type SearchRequestContext$1 = {
|
|
422
426
|
/**
|
|
423
427
|
* The page number of the search results to return.
|
|
424
428
|
*/
|
|
@@ -435,20 +439,20 @@ type SearchRequestContext = {
|
|
|
435
439
|
/**
|
|
436
440
|
* Return type of the {@link OnSearchListener}.
|
|
437
441
|
*/
|
|
438
|
-
type SearchResponse = {
|
|
442
|
+
type SearchResponse$1 = {
|
|
439
443
|
/**
|
|
440
444
|
* The search results to display in Here™’s search UI.
|
|
441
445
|
*/
|
|
442
|
-
results: SearchResult[];
|
|
446
|
+
results: SearchResult$1[];
|
|
443
447
|
};
|
|
444
448
|
/**
|
|
445
449
|
* A search result returned by a Search Agent in response to a search request.
|
|
446
450
|
*/
|
|
447
|
-
type SearchResult = {
|
|
451
|
+
type SearchResult$1 = {
|
|
448
452
|
/**
|
|
449
453
|
* Actions that can be triggered by the user against the search result.
|
|
450
454
|
*/
|
|
451
|
-
actions: SearchAction[];
|
|
455
|
+
actions: SearchAction$1[];
|
|
452
456
|
/**
|
|
453
457
|
* Additional data that can be used by the {@link OnActionListener} when an action is triggered.
|
|
454
458
|
*/
|
|
@@ -473,7 +477,7 @@ type SearchResult = {
|
|
|
473
477
|
/**
|
|
474
478
|
* Return type of the {@link OnActionListener}.
|
|
475
479
|
*/
|
|
476
|
-
type SearchResultActionResponse = {
|
|
480
|
+
type SearchResultActionResponse$1 = {
|
|
477
481
|
/**
|
|
478
482
|
* URL that Here™ should navigate to.
|
|
479
483
|
*/
|
|
@@ -583,24 +587,345 @@ declare function getAgentConfiguration<T extends object>(): Promise<SearchAgentC
|
|
|
583
587
|
* // Set the Search Agent as ready to receive search requests
|
|
584
588
|
* await searchAgent.isReady();
|
|
585
589
|
* ```
|
|
590
|
+
*
|
|
591
|
+
* @deprecated Use `Agent.register` instead.
|
|
592
|
+
*/
|
|
593
|
+
declare function register$1(config: SearchAgentRegistrationConfig): Promise<SearchAgent>;
|
|
594
|
+
|
|
595
|
+
type index$1_OnActionListener = OnActionListener;
|
|
596
|
+
type index$1_OnSearchListener = OnSearchListener;
|
|
597
|
+
type index$1_SearchAgent = SearchAgent;
|
|
598
|
+
type index$1_SearchAgentConfigurationData<T> = SearchAgentConfigurationData<T>;
|
|
599
|
+
type index$1_SearchAgentRegistrationConfig = SearchAgentRegistrationConfig;
|
|
600
|
+
declare const index$1_getAgentConfiguration: typeof getAgentConfiguration;
|
|
601
|
+
declare namespace index$1 {
|
|
602
|
+
export { type index$1_OnActionListener as OnActionListener, type index$1_OnSearchListener as OnSearchListener, type SearchAction$1 as SearchAction, type index$1_SearchAgent as SearchAgent, type index$1_SearchAgentConfigurationData as SearchAgentConfigurationData, type index$1_SearchAgentRegistrationConfig as SearchAgentRegistrationConfig, type SearchListenerRequest$1 as SearchListenerRequest, type SearchRequestContext$1 as SearchRequestContext, type SearchResponse$1 as SearchResponse, type SearchResult$1 as SearchResult, type SearchResultActionResponse$1 as SearchResultActionResponse, index$1_getAgentConfiguration as getAgentConfiguration, register$1 as register };
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Function that is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results.
|
|
607
|
+
*
|
|
608
|
+
* @param action The action that was triggered.
|
|
609
|
+
* @param result The search result that the action was triggered on.
|
|
610
|
+
*
|
|
611
|
+
* @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required.
|
|
612
|
+
*/
|
|
613
|
+
type OnSearchActionListener = (action: SearchAction, result: SearchResult) => SearchResultActionResponse | Promise<SearchResultActionResponse>;
|
|
614
|
+
/**
|
|
615
|
+
* Function that is called when the Agent receives a query from Here™’s search UI
|
|
616
|
+
*
|
|
617
|
+
* @param request Search request data that includes the query.
|
|
618
|
+
*
|
|
619
|
+
* @returns Search response data that includes the search results.
|
|
620
|
+
*/
|
|
621
|
+
type OnSearchRequestListener = (request: SearchListenerRequest) => SearchResponse | Promise<SearchResponse>;
|
|
622
|
+
/**
|
|
623
|
+
* An action that can be triggered by a user on a search result returned by a Agent.
|
|
624
|
+
*
|
|
625
|
+
* Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result.
|
|
626
|
+
*/
|
|
627
|
+
type SearchAction = {
|
|
628
|
+
/**
|
|
629
|
+
* URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode.
|
|
630
|
+
*/
|
|
631
|
+
darkIcon?: string;
|
|
632
|
+
/**
|
|
633
|
+
* A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button.
|
|
634
|
+
*/
|
|
635
|
+
description?: string;
|
|
636
|
+
/**
|
|
637
|
+
* URL or data URI of an icon that will be displayed within the action button when Here™ is in Dark mode.
|
|
638
|
+
*/
|
|
639
|
+
lightIcon?: string;
|
|
640
|
+
/**
|
|
641
|
+
* Internal identifier for the action which is used to identify the action in the {@link OnSearchActionListener}.
|
|
642
|
+
*/
|
|
643
|
+
name: string;
|
|
644
|
+
/**
|
|
645
|
+
* Compact title of the action displayed within the action button.
|
|
646
|
+
*/
|
|
647
|
+
title?: string;
|
|
648
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* Search request data provided to the {@link OnSearchRequestListener}.
|
|
651
|
+
*/
|
|
652
|
+
type SearchListenerRequest = {
|
|
653
|
+
/**
|
|
654
|
+
* Provides additional context for the search request.
|
|
655
|
+
*/
|
|
656
|
+
context: SearchRequestContext;
|
|
657
|
+
/**
|
|
658
|
+
* The query entered by the user in Here™’s search UI.
|
|
659
|
+
*/
|
|
660
|
+
query: string;
|
|
661
|
+
/**
|
|
662
|
+
* Provide this signal to any `fetch` requests executed in the {@link OnSearchRequestListener} function as a result of this search request, so that they will be automatically cancelled if a new search request is received before they complete.
|
|
663
|
+
*/
|
|
664
|
+
signal: AbortSignal;
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* Context data included with a search request.
|
|
668
|
+
*/
|
|
669
|
+
type SearchRequestContext = {
|
|
670
|
+
/**
|
|
671
|
+
* Filters to apply to the search results.
|
|
672
|
+
*/
|
|
673
|
+
filters: string[];
|
|
674
|
+
/**
|
|
675
|
+
* The locale of the client.
|
|
676
|
+
*/
|
|
677
|
+
locale: string;
|
|
678
|
+
/**
|
|
679
|
+
* The page number of the search results to return.
|
|
680
|
+
*/
|
|
681
|
+
pageNumber: number;
|
|
682
|
+
/**
|
|
683
|
+
* The number of search results to return per page.
|
|
684
|
+
*/
|
|
685
|
+
pageSize: number;
|
|
686
|
+
/**
|
|
687
|
+
* The unique ID of the query.
|
|
688
|
+
*/
|
|
689
|
+
queryId: string;
|
|
690
|
+
/**
|
|
691
|
+
* The timezone of the client.
|
|
692
|
+
*/
|
|
693
|
+
timeZone: string;
|
|
694
|
+
};
|
|
695
|
+
/**
|
|
696
|
+
* Return type of the {@link OnSearchRequestListener}.
|
|
697
|
+
*/
|
|
698
|
+
type SearchResponse = {
|
|
699
|
+
/**
|
|
700
|
+
* The search results to display in Here™’s search UI.
|
|
701
|
+
*/
|
|
702
|
+
results: SearchResult[];
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* A search result returned by a Agent in response to a search request.
|
|
706
|
+
*/
|
|
707
|
+
type SearchResult = {
|
|
708
|
+
/**
|
|
709
|
+
* Actions that can be triggered by the user against the search result.
|
|
710
|
+
*/
|
|
711
|
+
actions: SearchAction[];
|
|
712
|
+
/**
|
|
713
|
+
* Additional data that can be used by the {@link OnSearchActionListener} when an action is triggered.
|
|
714
|
+
*/
|
|
715
|
+
data?: Record<string, unknown>;
|
|
716
|
+
/**
|
|
717
|
+
* URL or data URI of an icon that will be displayed with the search result in Here™’s search UI.
|
|
718
|
+
*/
|
|
719
|
+
icon?: string;
|
|
720
|
+
/**
|
|
721
|
+
* Unique identifier for the search result.
|
|
722
|
+
*/
|
|
723
|
+
key: string;
|
|
724
|
+
/**
|
|
725
|
+
* Secondary text that will be displayed with the search result in Here™’s search UI.
|
|
726
|
+
*/
|
|
727
|
+
label?: string;
|
|
728
|
+
/**
|
|
729
|
+
* Primary text that will be displayed with the search result in Here™’s search UI.
|
|
730
|
+
*/
|
|
731
|
+
title: string;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* Return type of the {@link OnSearchActionListener}.
|
|
735
|
+
*/
|
|
736
|
+
type SearchResultActionResponse = {
|
|
737
|
+
/**
|
|
738
|
+
* URL that Here™ should navigate to.
|
|
739
|
+
*/
|
|
740
|
+
url: string;
|
|
741
|
+
} | undefined;
|
|
742
|
+
|
|
743
|
+
type Agent = {
|
|
744
|
+
/**
|
|
745
|
+
* The features supported by the Agent.
|
|
746
|
+
*/
|
|
747
|
+
features: AgentFeatures;
|
|
748
|
+
/**
|
|
749
|
+
* Joins the agent to a specific interop channel.
|
|
750
|
+
*
|
|
751
|
+
* @throws {InteropFeatureNotSupportedError} if the interop feature is not supported by the agent.
|
|
752
|
+
*/
|
|
753
|
+
joinInteropChannel: (channelName: InteropColorChannel) => Promise<void>;
|
|
754
|
+
/**
|
|
755
|
+
* Sets whether or not the Agent is ready.
|
|
756
|
+
*
|
|
757
|
+
* @param ready Whether the Agent is ready (defaults to `true`).
|
|
758
|
+
*/
|
|
759
|
+
setIsReady: (ready?: boolean) => Promise<void>;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* The features supported by the Agent.
|
|
763
|
+
*/
|
|
764
|
+
type AgentFeatures = {
|
|
765
|
+
interop?: {
|
|
766
|
+
defaultChannel?: InteropColorChannel;
|
|
767
|
+
fdc3Version: OpenFin$1.FDC3.Version;
|
|
768
|
+
};
|
|
769
|
+
search?: {
|
|
770
|
+
filters?: AgentSearchFilter[];
|
|
771
|
+
supportsPaging: boolean;
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* Configuration provided when registering a Agent.
|
|
776
|
+
*/
|
|
777
|
+
type AgentRegistrationConfig = {
|
|
778
|
+
/**
|
|
779
|
+
* Search configuration required if the Agent supports search functionality.
|
|
780
|
+
*/
|
|
781
|
+
search?: {
|
|
782
|
+
/**
|
|
783
|
+
* This listener is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results.
|
|
784
|
+
*
|
|
785
|
+
* The listener returns a response back to Here™ that includes a URL to navigate to.
|
|
786
|
+
*/
|
|
787
|
+
onAction: OnSearchActionListener;
|
|
788
|
+
/**
|
|
789
|
+
* This listener is called when the Agent receives a query from Here™’s search UI and returns relevant search results.
|
|
790
|
+
*
|
|
791
|
+
* Note: When the Agent is not ready this listener will not be called.
|
|
792
|
+
*/
|
|
793
|
+
onSearch: OnSearchRequestListener;
|
|
794
|
+
};
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* A filter that can be applied to the Agent’s search results.
|
|
798
|
+
*/
|
|
799
|
+
type AgentSearchFilter = {
|
|
800
|
+
icon?: string | {
|
|
801
|
+
dark: string;
|
|
802
|
+
light: string;
|
|
803
|
+
};
|
|
804
|
+
id: string;
|
|
805
|
+
title: string;
|
|
806
|
+
};
|
|
807
|
+
type InteropColorChannel = 'blue' | 'indigo' | 'pink' | 'teal' | 'green' | 'orange' | 'red' | 'yellow' | 'gray' | 'none';
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Retrieves the Agent’s configuration data, as has been configured in the Here™ Admin Console.
|
|
811
|
+
*
|
|
812
|
+
* @returns A promise that resolves with an object containing properties that match the Agent’s configuration.
|
|
813
|
+
*
|
|
814
|
+
* @example Retrieving the Agent’s configuration data:
|
|
815
|
+
* ```ts
|
|
816
|
+
* import { Agent } from "@openfin/cloud-api";
|
|
817
|
+
*
|
|
818
|
+
* // Get the configuration data
|
|
819
|
+
* const configData = await Agent.getConfiguration<{ customField1: string, customField2: string }>();
|
|
820
|
+
*
|
|
821
|
+
* // Pick out the standard configuration properties
|
|
822
|
+
* const { customData, description, id, title, url } = configData;
|
|
823
|
+
*
|
|
824
|
+
* // Pick out the custom configuration properties
|
|
825
|
+
* if (customData) {
|
|
826
|
+
* const { customField1, customField2 } = customData;
|
|
827
|
+
* }
|
|
828
|
+
* ```
|
|
829
|
+
*/
|
|
830
|
+
declare const getConfiguration: <T extends Record<string, unknown>>() => Promise<T>;
|
|
831
|
+
/**
|
|
832
|
+
* Registers an Agent.
|
|
833
|
+
*
|
|
834
|
+
* @param config The configuration for the Agent.
|
|
835
|
+
*
|
|
836
|
+
* @returns A promise that resolves with the Agent.
|
|
837
|
+
*
|
|
838
|
+
* @example Registering an Agent that will provide search results:
|
|
839
|
+
* ```ts
|
|
840
|
+
* import { Agent } from "@openfin/cloud-api";
|
|
841
|
+
*
|
|
842
|
+
* // Handle incoming action and return a response that includes the URL to navigate to
|
|
843
|
+
* const onAction: Agent.OnSearchActionListener = (action, result) => {
|
|
844
|
+
* const { name } = action;
|
|
845
|
+
* const { data, key } = result;
|
|
846
|
+
* const { owner, searchResultHostUrl } = data as { owner: { id: string, name: string }, searchResultHostUrl: string };
|
|
847
|
+
* const { id: ownerId } = owner;
|
|
848
|
+
*
|
|
849
|
+
* console.log(`Action "${name}" triggered on search result with key "${key}"`);
|
|
850
|
+
*
|
|
851
|
+
* switch (name) {
|
|
852
|
+
* case "view-owner":
|
|
853
|
+
* return { url: `${searchResultHostUrl}/people/${ownerId}` };
|
|
854
|
+
* case "view-result":
|
|
855
|
+
* return { url: `${searchResultHostUrl}/record/${key}` };
|
|
856
|
+
* default:
|
|
857
|
+
* console.warn(`Unknown action: ${name}`);
|
|
858
|
+
* }
|
|
859
|
+
* };
|
|
860
|
+
*
|
|
861
|
+
* // Handle incoming search request and return relevant search results
|
|
862
|
+
* const onSearch: Agent.OnSearchRequestListener = ({ context, query, signal }) => {
|
|
863
|
+
* const { pageNumber, pageSize } = context;
|
|
864
|
+
* try {
|
|
865
|
+
* let results: Agent.SearchResult[] = [];
|
|
866
|
+
* const url = `https://my-web-app.com/search?q=${query}&page=${pageNumber}&limit=${pageSize}`;
|
|
867
|
+
* const response = await fetch(url, { signal });
|
|
868
|
+
* if (!response.ok) {
|
|
869
|
+
* throw new Error(`Request failed: ${response.status}`);
|
|
870
|
+
* }
|
|
871
|
+
* const { searchResults } = await response.json();
|
|
872
|
+
* results = searchResults.map((result) => {
|
|
873
|
+
* const { iconUrl, id: key, owner, subTitle, title } = result;
|
|
874
|
+
* const { name: ownerName } = owner as { id: string, name: string };
|
|
875
|
+
* return {
|
|
876
|
+
* actions: [
|
|
877
|
+
* {
|
|
878
|
+
* name: "view-result",
|
|
879
|
+
* description: `Go to ${title} in My Web App`,
|
|
880
|
+
* },
|
|
881
|
+
* {
|
|
882
|
+
* name: "view-owner",
|
|
883
|
+
* description: `Go to ${ownerName} in My Web App`,
|
|
884
|
+
* title: "View Owner",
|
|
885
|
+
* },
|
|
886
|
+
* ],
|
|
887
|
+
* data: {
|
|
888
|
+
* owner,
|
|
889
|
+
* searchResultHostUrl: `https://my-web-app.com`,
|
|
890
|
+
* },
|
|
891
|
+
* icon: iconUrl,
|
|
892
|
+
* key,
|
|
893
|
+
* label: subTitle,
|
|
894
|
+
* title,
|
|
895
|
+
* };
|
|
896
|
+
* });
|
|
897
|
+
* console.log("Returning results", results);
|
|
898
|
+
* return { results };
|
|
899
|
+
* } catch (err) {
|
|
900
|
+
* if ((err as Error).name === "AbortError") {
|
|
901
|
+
* // Ignore errors for cancelled requests
|
|
902
|
+
* return { results: [] };
|
|
903
|
+
* }
|
|
904
|
+
* throw err;
|
|
905
|
+
* }
|
|
906
|
+
* };
|
|
907
|
+
*
|
|
908
|
+
* // Register the agent
|
|
909
|
+
* const agent = await Agent.register({ search: { onAction, onSearch } });
|
|
910
|
+
*
|
|
911
|
+
* // Set the Agent as ready to receive requests
|
|
912
|
+
* await agent.isReady();
|
|
913
|
+
* ```
|
|
586
914
|
*/
|
|
587
|
-
declare function register(config:
|
|
915
|
+
declare function register(config: AgentRegistrationConfig): Promise<Agent>;
|
|
588
916
|
|
|
589
|
-
type
|
|
590
|
-
type
|
|
591
|
-
type
|
|
592
|
-
type
|
|
593
|
-
type
|
|
594
|
-
type
|
|
917
|
+
type index_Agent = Agent;
|
|
918
|
+
type index_AgentFeatures = AgentFeatures;
|
|
919
|
+
type index_AgentRegistrationConfig = AgentRegistrationConfig;
|
|
920
|
+
type index_AgentSearchFilter = AgentSearchFilter;
|
|
921
|
+
type index_InteropColorChannel = InteropColorChannel;
|
|
922
|
+
type index_OnSearchActionListener = OnSearchActionListener;
|
|
923
|
+
type index_OnSearchRequestListener = OnSearchRequestListener;
|
|
595
924
|
type index_SearchListenerRequest = SearchListenerRequest;
|
|
596
|
-
|
|
597
|
-
type index_SearchResponse = SearchResponse;
|
|
598
|
-
type index_SearchResult = SearchResult;
|
|
599
|
-
type index_SearchResultActionResponse = SearchResultActionResponse;
|
|
600
|
-
declare const index_getAgentConfiguration: typeof getAgentConfiguration;
|
|
925
|
+
declare const index_getConfiguration: typeof getConfiguration;
|
|
601
926
|
declare const index_register: typeof register;
|
|
602
927
|
declare namespace index {
|
|
603
|
-
export { type
|
|
928
|
+
export { type index_Agent as Agent, type index_AgentFeatures as AgentFeatures, type index_AgentRegistrationConfig as AgentRegistrationConfig, type index_AgentSearchFilter as AgentSearchFilter, type index_InteropColorChannel as InteropColorChannel, type index_OnSearchActionListener as OnSearchActionListener, type index_OnSearchRequestListener as OnSearchRequestListener, type index_SearchListenerRequest as SearchListenerRequest, index_getConfiguration as getConfiguration, index_register as register };
|
|
604
929
|
}
|
|
605
930
|
|
|
606
931
|
declare global {
|
|
@@ -609,4 +934,4 @@ declare global {
|
|
|
609
934
|
}
|
|
610
935
|
}
|
|
611
936
|
|
|
612
|
-
export { type AppPermissions, type LaunchContentOptions, index as Search, type FlannelChannelProvider as __INTERNAL_FlannelChannelProvider, type FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest, type FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse, type FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest, type FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse, type FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest, type FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse, getAppSettings, getAppUserPermissions, getAppUserSettings, getNotificationsClient, launchContent, launchSupertab, launchWorkspace, setAppUserSettings };
|
|
937
|
+
export { index as Agent, type AppPermissions, type LaunchContentOptions, index$1 as Search, type FlannelChannelProvider as __INTERNAL_FlannelChannelProvider, type FlannelClearNotificationRequest as __INTERNAL_FlannelClearNotificationRequest, type FlannelClearNotificationResponse as __INTERNAL_FlannelClearNotificationResponse, type FlannelCreateNotificationRequest as __INTERNAL_FlannelCreateNotificationRequest, type FlannelCreateNotificationResponse as __INTERNAL_FlannelCreateNotificationResponse, type FlannelUpdateNotificationRequest as __INTERNAL_FlannelUpdateNotificationRequest, type FlannelUpdateNotificationResponse as __INTERNAL_FlannelUpdateNotificationResponse, getAppSettings, getAppUserPermissions, getAppUserSettings, getNotificationsClient, launchContent, launchSupertab, launchWorkspace, setAppUserSettings };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Ve=Object.create;var mn=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var je=(o,u)=>()=>(u||o((u={exports:{}}).exports,u),u.exports),ze=(o,u)=>{for(var a in u)mn(o,a,{get:u[a],enumerable:!0})},Xe=(o,u,a,l)=>{if(u&&typeof u=="object"||typeof u=="function")for(let f of He(u))!Ge.call(o,f)&&f!==a&&mn(o,f,{get:()=>u[f],enumerable:!(l=qe(u,f))||l.enumerable});return o};var Je=(o,u,a)=>(a=o!=null?Ve(Ke(o)):{},Xe(u||!o||!o.__esModule?mn(a,"default",{value:o,enumerable:!0}):a,o));var Hn=je((Lt,qn)=>{"use strict";(()=>{"use strict";var o={d:(n,e)=>{for(var t in e)o.o(e,t)&&!o.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},u={};o.r(u),o.d(u,{SearchTagBackground:()=>on,create:()=>Un,defaultTopic:()=>Bn,subscribe:()=>Dn});var a={};o.r(a),o.d(a,{B:()=>de});var l={};o.r(l),o.d(l,{v:()=>De});let f="deregistered or does not exist",y=new Error(`provider ${f}`),P=new Error("provider with name already exists"),v=new Error("bad payload"),b=new Error("subscription rejected"),R=new Error(`channel ${f}`),x;function O(){if(x)return x;throw R}function K(){return x}function Sn(n){x=n}var S,$,tn,on;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(S||(S={})),function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"}($||($={})),function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"}(tn||(tn={})),function(n){n.Active="active",n.Default="default"}(on||(on={}));let G="0",Rn="1",En="2",bn="3",Pn="4",j="5",z="6",Jn=()=>{},rn=new Set;function Qn(n){rn.add(n)}function Yn(n){rn.delete(n)}let sn=new Set;function Zn(n){sn.add(n)}function ne(n){sn.delete(n)}let q=new Map;async function an(n){q.set(n.id,n);let e=[...rn].map(t=>t());await Promise.all(e)}async function X(n){q.delete(n);let e=[...sn].map(t=>t());await Promise.all(e)}function cn(){return[...q.values()]}function An(){q.clear()}function I(n){return q.get(n)}function On(n,e,t){return{...n,action:t||{...n.actions[0],trigger:tn.UserAction},dispatcherIdentity:e}}function un(n,e,t="ascending"){let i=n||[];if(!e?.length)return i;let r=[],s=new Map;e.forEach(d=>{if(d.key)return s.set(d.key,d);r.push(d)});let c=i.map(d=>{let{key:h}=d;if(h&&s.has(h)){let C=s.get(h);return s.delete(h),C}return d});return c.push(...s.values(),...r),c=t==="ascending"?c.sort((d,h)=>(d?.score??1/0)-(h?.score??1/0)):c.sort((d,h)=>(h?.score??1/0)-(d?.score??1/0)),c}function In(n){let e={},t=[],i=[],r=null,s=S.Initial;e.getStatus=()=>s,e.getResultBuffer=()=>t,e.setResultBuffer=d=>{t=d,t?.length&&e.onChange()},e.getRevokedBuffer=()=>i,e.setRevokedBuffer=d=>{i=d,i?.length&&e.onChange()},e.setUpdatedContext=d=>{r=d,e.onChange()},e.getUpdatedContext=()=>r,e.onChange=Jn;let c={};return e.res=c,c.close=()=>{s!==S.Close&&(s=S.Close,e.onChange())},c.open=()=>{s!==S.Open&&(s=S.Open,e.onChange())},c.respond=d=>{let h=un(e.getResultBuffer(),d,n);e.setResultBuffer(h)},c.revoke=(...d)=>{let h=new Set(d),C=e.getResultBuffer().filter(({key:p})=>{let g=h.has(p);return g&&h.delete(p),!g});e.setResultBuffer(C),h.size&&(e.getRevokedBuffer().forEach(p=>h.add(p)),e.setRevokedBuffer([...h]))},c.updateContext=d=>{e.setUpdatedContext(d)},e}function Ln(n,e){let t=new Set,i=!1;return{close:()=>{i=!0;for(let r of t)r()},req:{id:n,...e,context:e?.context||{},onClose:r=>{t.add(r),i&&r()},removeListener:r=>{t.delete(r)}}}}function J(){return{name:fin.me.name,uuid:fin.me.uuid}}let Nn=50,ee=1e3,te=new Map;function ln(){return te}let oe=100;function ie(){return async n=>{if(!n||!n.id||!n.providerId){let p=v;return console.error(p),{error:p.message}}let{id:e,providerId:t}=n,i=I(t);if(!i){let p=y;return console.error(p),{error:p.message}}let r=ln(),s=r.get(n.id);s||(s=Ln(e,n),r.set(n.id,s));let c=In(),d=()=>{let p=c.getResultBuffer();c.setResultBuffer([]);let g=c.getRevokedBuffer();c.setRevokedBuffer([]);let L=c.getUpdatedContext();c.setUpdatedContext(null);let k=c.getStatus();(async function(D){(await O()).dispatch(G,D)})({id:e,providerId:t,results:p,revoked:g,status:k,context:L})},h=!0,C=!1;c.onChange=()=>{if(h)return h=!1,void d();C||(C=!0,setTimeout(()=>{C=!1,d()},oe))};try{let{results:p,context:g}=await i.onUserInput(s.req,c.res),L=c.getStatus();return{id:e,providerId:t,status:L,results:p,context:g}}catch(p){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${t} for search ${e}`,"This is likely a bug in the implementation of the search provider.",p),{id:e,providerId:t,error:p?.message}}}}async function Fn(n,e){let t=e||await O(),i=J(),r={...n,identity:i,onResultDispatch:void 0},s=await t.dispatch(En,r);return await an({identity:i,...n}),s}async function re(n){return await(await O()).dispatch(bn,n),X(n)}async function se(n,e,t,i){let r=On(e,i??J(),t),s=I(n);if(s){let{onResultDispatch:d}=s;return d?d(r):void 0}let c={providerId:n,result:r};return(await O()).dispatch(j,c)}async function ae(n){let e={...n,context:n?.context||{}},t={},i=async function*(s,{setState:c}){let d=await O();for(;;){let h=await d.dispatch(Rn,s),C=h.error;if(C)throw new Error(C);let p=h;if(s.id=p.id,c(p.state),p.done)return p.value;yield p.value}}(e,{setState:s=>{t.state=s}}),r=await i.next();return t.id=e.id||"",t.close=()=>{(async function(s){(await O()).dispatch(z,{id:s})})(t.id)},t.next=()=>{if(r){let s=r;return r=void 0,s}return i.next()},t}async function ce(){return(await O()).dispatch(Pn,null)}async function ue(){let n=await O();x=void 0,An(),await n.disconnect()}let le=async n=>{let e=await xn(n);for(let t of cn())await Fn(t,e);return e};async function xn(n){let e=await async function(t){for(let i=0;i<Nn;i++)try{return await fin.InterApplicationBus.Channel.connect(t,{wait:!1})}catch(r){if(i===Nn-1)throw r;await new Promise(s=>setTimeout(s,ee))}}(n);return e.register(G,ie()),e.register(z,t=>{let i=ln(),r=i.get(t.id);r&&(r.close(),i.delete(t.id))}),e.register(j,async(t,i)=>{if(!t||!t.providerId||!t.result)return void console.error(v);let r=I(t.providerId);if(!r)return void console.error(y);let{onResultDispatch:s}=r;return s?(t.result.dispatcherIdentity=t.result.dispatcherIdentity??i,s(t.result)):void 0}),e.onDisconnection(function(t){return async()=>{if(!K())return;let i=ln();for(let{req:r,close:s}of i.values())s(),i.delete(r.id);Sn(le(t))}}(n)),e}async function de(n){let e=K();e||(e=xn(n),Sn(e));let t=await e;return{getAllProviders:ce.bind(null),register:Fn.bind(null),search:ae.bind(null),deregister:re.bind(null),dispatch:se.bind(null),disconnect:ue.bind(null),channel:t}}let H;function Q(){if(H)return H;throw R}function pe(){return H}function fe(n){H=n}function he(){H=void 0}let dn=new Set;function we(n){dn.add(n)}function ge(n){dn.delete(n)}var T;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(T||(T={}));let pn=typeof window<"u"&&typeof fin<"u",ye=(typeof process>"u"||process.env,typeof window<"u"),me=ye?window.origin:T.Local,Y=(pn&&fin.me.uuid,pn&&fin.me.name,pn&&fin.me.entityType,T.Local,T.Dev,T.Staging,T.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:me+n),$n=(Y("http://localhost:4002"),Y("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Y(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Y(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Tn(){return[...cn()].map(n=>({...n,onUserInput:void 0,onResultDispatch:void 0}))}async function Ce(n){if(I(n.id))throw new Error("provider with name already exists");let e=J();return await an({identity:e,...n}),{workspaceVersion:$n||"",clientAPIVersion:n.clientAPIVersion||""}}async function ve(n){await X(n)}async function Se(n,e,t,i){let r=I(n);if(!r)throw y;let{onResultDispatch:s}=r;if(s)return s(On(e,i??J(),t))}async function*Re(n,e){let t=function(g,L){let k=[],D=[],B=[],E=[];for(let m of g){let N=In(m.scoreOrder),F={results:[],provider:{id:m.id,identity:m.identity,title:m.title,scoreOrder:m.scoreOrder,icon:m.icon,dispatchFocusEvents:m.dispatchFocusEvents}};k.push(F),D.push(N);let M=(async()=>{try{let{results:W,context:nn}=await m.onUserInput(L,N.res);F.results=un(F.results||[],W,m.scoreOrder),F.context={...F.context,...nn}}catch(W){F.error=W}})();M.finally(()=>{M.done=!0}),E.push(M),B.push(B.length)}return{providerResponses:k,listenerResponses:D,openListenerResponses:B,initialResponsePromises:E}}(n.targets?n.targets.map(g=>I(g)).filter(g=>!!g):[...cn().filter(g=>!g.hidden)],n),{providerResponses:i,listenerResponses:r}=t,{openListenerResponses:s,initialResponsePromises:c}=t,d=$.Fetching,h=g=>{d=g,e.setState(d)},C,p=!1;n.onClose(()=>{p=!0,C&&C()});do{let g=!1;if(c.length){let E=[];for(let m of c)m.done?g=!0:E.push(m);c=E,c.length||(h($.Fetched),g=!0)}let L,k=!1,D=()=>{k=!0,L&&L()},B=[];for(let E of s){let m=r[E],N=i[E],F=m.getStatus();(F===S.Open||d===$.Fetching&&F===S.Initial)&&(B.push(E),m.onChange=D);let M=m.getResultBuffer();M.length&&(m.setResultBuffer([]),N.results=un(N.results||[],M),g=!0);let W=m.getRevokedBuffer();if(W.length){m.setRevokedBuffer([]);let Me=new Set(W);N.results=(N.results||[]).filter(({key:We})=>!Me.has(We)),g=!0}let nn=m.getUpdatedContext();nn&&(m.setUpdatedContext(null),N.context={...N.context,...nn},g=!0)}if(s=B,g&&(yield i),p)break;k||(s.length||c.length)&&await Promise.race([...c,new Promise(E=>{L=E}),new Promise(E=>{C=E})])}while(s.length||c.length);return h($.Complete),i}let fn=0;async function kn(n){fn+=1;let e=Ln(fn.toString(),n),t=Re(e.req,{setState:i=>{t.state=i}});return t.id=fn.toString(),t.close=e.close,t.state=$.Fetching,t}let Z=new Map,Ee=1e4;function be(){return async n=>{if(!n)return console.error(v),{error:v.message};let e;if(n.id)e=n.id;else{let r=await kn(n);e=r.id,n.id=r.id,Z.set(e,{generator:r})}let t=Z.get(e);clearTimeout(t.timeout);let i=await t.generator.next();return t.timeout=function(r){return window.setTimeout(()=>{Z.delete(r)},Ee)}(e),{...i,id:n.id,state:t.generator.state}}}function Pe(n,e){return Q().dispatch(n,z,{id:e})}function Ae(){return n=>function(e){let t=Z.get(e);t&&t.generator.close()}(n.id)}async function Oe(n,{id:e,query:t,context:i,targets:r=[]}){let s=Q(),c={id:e,query:t,context:i,targets:r,providerId:n.id},d=await s.dispatch(n.identity,G,c),h=d.error;if(h)throw new Error(h);return d}let hn=new Map;function Ie(n,e){return`${n.name}:${n.uuid}:${e}`}let wn=new Map;function _n(n,e){return`${n}:${e}`}function Le(n){let e=Ie.bind(null,n.identity),t=Pe.bind(null,n.identity),i=Oe.bind(null,n);return async(r,s)=>{let c=e(r.id);if(!hn.has(c)){let p=()=>{t(r.id),hn.delete(c)};hn.set(c,p),r.onClose(p)}let d=_n(n.id,r.id),h=()=>{wn.delete(d),s.close()};r.onClose(h),wn.set(d,p=>{p.results?.length&&s.respond(p.results),p.revoked?.length&&s.revoke(...p.revoked),p.context&&s.updateContext(p.context),p.status===S.Open&&s.open(),p.status===S.Close&&h()});let C=await i(r);return C.status===S.Open&&s.open(),C.status!==S.Close&&C.status!==S.Initial||h(),C}}function Ne(n){return async e=>{let t=Q(),i={providerId:n.id,result:e};return t.dispatch(n.identity,j,i)}}let U=new Map;function gn(n){return`${n.name}-${n.uuid}`}function Fe(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(v);if(I(n.id))throw P;return n.identity=e,await async function(t){let i=gn(t.identity);U.has(i)||U.set(i,[]),U.get(i).push(t.id),await an({...t,onUserInput:Le(t),onResultDispatch:Ne(t)})}(n),{workspaceVersion:$n||"",clientAPIVersion:n.clientAPIVersion||""}}}function xe(){return(n,e)=>{n?function(t,i){let r=I(t);if(!r)return;if(r.identity.uuid!==i.uuid||r.identity.name!==i.name)throw y;let s=gn(r.identity),c=U.get(s);if(c){let d=c.findIndex(h=>h===t);d!==-1&&(c.splice(d,1),X(t))}}(n,e):console.error(v)}}let yn=new Set;function $e(n){yn.add(n)}function Te(n){yn.delete(n)}function ke(){return async n=>{(function(e){let t=gn(e),i=U.get(t);if(i){for(let r of i)X(r);U.delete(t)}})(n),yn.forEach(e=>e(n))}}async function _e(n){let e=await(t=n,fin.InterApplicationBus.Channel.create(t));var t;return e.onConnection(async i=>{for(let r of dn)if(!await r(i))throw b}),e.onDisconnection(ke()),e.register(z,Ae()),e.register(G,i=>{let r=_n(i.providerId,i.id),s=wn.get(r);s&&s(i)}),e.register(En,Fe()),e.register(bn,xe()),e.register(Pn,async()=>Tn()),e.register(Rn,be()),e.register(j,async(i,r)=>{if(!i||!i.providerId||!i.result)return void console.error(v);let s=I(i.providerId);if(!s)throw y;let{onResultDispatch:c}=s;return c?(i.result.dispatcherIdentity=i.result.dispatcherIdentity??r,c(i.result)):void 0}),e}async function Ue(){let n=Q();he(),await n.destroy(),An()}async function De(n){let e=pe();e||(e=await _e(n),fe(e));let t=ge.bind(null),i=Te.bind(null),r=Yn.bind(null),s=ne.bind(null);return{getAllProviders:Tn.bind(null),search:kn.bind(null),register:Ce.bind(null),deregister:ve.bind(null),onSubscription:we.bind(null),onDisconnect:$e.bind(null),onRegister:Qn.bind(null),onDeregister:Zn.bind(null),dispatch:Se.bind(null),disconnect:Ue.bind(null),removeListener:c=>{t(c),i(c),r(c),s(c)},channel:e}}let{v:Un}=l,{B:Dn}=a,Bn="all",Be={create:Un,subscribe:Dn,defaultTopic:Bn},Mn=()=>{window.search=Be},Wn=n=>{let e=()=>{Mn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Mn();let n="load",e=Wn(n);window.addEventListener(n,e);let t="DOMContentLoaded",i=Wn(t);window.addEventListener(t,i)}qn.exports=u})()});var w="@openfin/cloud-api";async function A(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch{return!1}}function Vn(o){if(o.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(o.name)?o.name.split("/")[0]||"":o.name}var V="@openfin/cloud-api";function Qe(){return`${window.fin.me.uuid}-cloud-api-notifications`}var Cn=null;async function mt(){return Cn||(Cn=Ye()),Cn}async function Ye(){if(!window.fin)throw new Error(`\`${V}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${V}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);Vn(window.fin.me);let o=await Ze();console.log(o),o.register("openfin-cloud-event",a=>{for(let l of u.get(a.type)??[])typeof a.payload.timestamp=="string"&&(a.payload.timestamp=new Date(a.payload.timestamp)),l(a.payload)});let u=new Map;return{addEventListener:(a,l)=>{let f=u.get(a)||new Set;f.add(l),u.set(a,f)},removeEventListener:(a,l)=>{let f=u.get(a);if(!f){console.warn(`\`${V}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,a);return}f.delete(l)===!1&&console.warn(`\`${V}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,a)},update:async a=>(await o.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:a}})).payload.response,clear:async a=>(await o.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:a}})).payload.response,createNotification:async a=>(a.id&&console.warn(`\`${V}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await o.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...a,id:void 0}}})).payload.response)}}var en=null;async function Ze(){return en||(en=nt()),en}async function nt(){let o=await window.fin.InterApplicationBus.Channel.connect(Qe());return o.onDisconnection(u=>{console.warn(`\`${V}\`: Channel Disconnected from`,u,"Reconnecting..."),en=null}),o}var vn;function et(){return`${window.fin.me.uuid}-client-api`}async function _(){return vn||(vn=window.fin.InterApplicationBus.Channel.connect(et())),vn}async function St(){if(!window.fin)throw new Error(`\`${w}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await _()).dispatch("get-settings")}async function Rt(){if(!window.fin)throw new Error(`\`${w}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await _()).dispatch("get-user-settings")}async function Et(o){if(!window.fin)throw new Error(`\`${w}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await _()).dispatch("set-user-settings",o)}async function bt(){if(!window.fin)throw new Error(`\`${w}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await _()).dispatch("get-user-permissions")}async function Pt(o,u){if(!window.fin)throw new Error(`\`${w}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let a=await _();try{await a.dispatch("launch-content",{id:o,options:u})}catch(l){switch(l instanceof Error?l.message:String(l)){case"UnableToLookup":throw new Error(`${w}: \`launchContent\` was unable to lookup content with id: ${o}`);case"UnableToLaunch":throw new Error(`${w}: \`launchContent\` was unable to launch content with id: ${o}`);case"NoContentFound":throw new Error(`${w}: \`launchContent\` did not find content with id: ${o}`);default:throw new Error(`${w}: \`launchContent\` was unable to look up or launch content with id: ${o} or the content did not exist.`)}}}async function At(o){if(!window.fin)throw new Error(`\`${w}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let u=await _();try{await u.dispatch("launch-supertab",{id:o})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${w}: \`launchSupertab\` was unable to lookup content with id: ${o}`);case"UnableToLaunch":throw new Error(`${w}: \`launchSupertab\` was unable to launch content with id: ${o}`);case"NoContentFound":throw new Error(`${w}: \`launchSupertab\` did not find content with id: ${o}`);default:throw new Error(`${w}: \`launchSupertab\` was unable to look up or launch content with id: ${o} or the content did not exist.`)}}}async function Ot(o){if(!window.fin)throw new Error(`\`${w}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await A()===!1)throw new Error(`${w}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let u=await _();try{await u.dispatch("launch-workspace",{id:o})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${w}: \`launchWorkspace\` was unable to lookup content with id: ${o}`);case"UnableToLaunch":throw new Error(`${w}: \`launchWorkspace\` was unable to launch content with id: ${o}`);case"NoContentFound":throw new Error(`${w}: \`launchWorkspace\` did not find content with id: ${o}`);default:throw new Error(`${w}: \`launchWorkspace\` was unable to look up or launch content with id: ${o} or the content did not exist.`)}}}var Xn={};ze(Xn,{getAgentConfiguration:()=>jn,register:()=>zn});var Gn=Je(Hn(),1),tt="[here-agent]",ot="log-message-",it="open-url",rt="provider-status-",st="registered-",at="1.0";function ct(o,u){let{data:a,iconSize:l,rightSideIcon:f,...y}=o;return{...y,data:{customData:a,iconSize:l,providerId:u,resultType:"app",rightSideIcon:f}}}function Kn(o){return{...o,data:o.data.customData}}async function jn(){let{customData:o}=await window.fin.me.getOptions();return o}function ut(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function lt(o,u,a,l=!0){await u("info",`Setting status as ${l?"ready":"not ready"}`);try{await o.dispatch(`${rt}${a}`,{isReady:l})}catch(f){let y=["Error setting provider status",f];console.error(...y),u("error",...y)}}async function dt(o,u,a,...l){try{console.log(tt,...l),await o.dispatch(`${ot}${u}`,{level:a,message:l})}catch(f){console.error("Error logging message",f)}}async function pt(o,u,a,l,f){let{action:y,dispatcherIdentity:P,...v}=f;await a("info","Handling action",{action:y,dispatcherIdentity:P,result:v});let b;try{let x=Kn(f).actions?.find(({name:K})=>K===y.name);if(!x)throw new Error("Original action not found in search result");b=(await l(x,Kn(f)))?.url}catch(R){throw await a("error","Error handling dispatch",R),R}if(!b){await a("warn","OnActionListener did not return a URL");return}await ht(o,a,u,b,P)}async function ft(o,u,a,l){await u("info","Getting search results",{request:l});try{let f=new AbortController;l.onClose(()=>f.abort());let{context:y,query:P}=l,{results:v}=await a({context:y,query:P,signal:f.signal}),b=v.map(R=>ct(R,o));return await u("info","Returning results",b),{results:b}}catch(f){let y=["Error handling search",f];throw console.error(...y),u("error",...y),f}}async function ht(o,u,a,l,f){await u("info","Opening URL",{url:l,targetIdentity:f});try{await o.dispatch(it,{url:l,targetIdentity:f,providerId:a})}catch(y){let P=["Error opening URL",y];console.error(...P),u("error",...P)}}async function zn(o){let a=(await window.fin.me.getOptions()).customData,{id:l,title:f}=a,{onAction:y,onSearch:P}=o,v=await Gn.subscribe(ut()),b=v.channel,R=dt.bind(null,b,l);return await v.register({icon:"",id:l,onResultDispatch:pt.bind(null,b,l,R,y),onUserInput:ft.bind(null,l,R,P),title:f}),await v.channel.dispatch(`${st}${l}`,{version:at}),R("info","Registered search topic",{id:l,title:f}),{isReady:lt.bind(null,b,R,l)}}export{Xn as Search,St as getAppSettings,bt as getAppUserPermissions,Rt as getAppUserSettings,mt as getNotificationsClient,Pt as launchContent,At as launchSupertab,Ot as launchWorkspace,Et as setAppUserSettings};
|
|
1
|
+
var tt=Object.create;var En=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Kn=(t,i)=>{for(var r in i)En(t,r,{get:i[r],enumerable:!0})},ct=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of rt(i))!st.call(t,d)&&d!==r&&En(t,d,{get:()=>i[d],enumerable:!(a=ot(i,d))||a.enumerable});return t};var vn=(t,i,r)=>(r=t!=null?tt(it(t)):{},ct(i||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t));var on=at((no,Xn)=>{"use strict";(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},i={};t.r(i),t.d(i,{SearchTagBackground:()=>cn,create:()=>Vn,defaultTopic:()=>jn,subscribe:()=>qn});var r={};t.r(r),t.d(r,{B:()=>Oe});var a={};t.r(a),t.d(a,{v:()=>Ye});let d="deregistered or does not exist",h=new Error(`provider ${d}`),m=new Error("provider with name already exists"),w=new Error("bad payload"),C=new Error("subscription rejected"),S=new Error(`channel ${d}`),P;function b(){if(P)return P;throw S}function H(){return P}function In(n){P=n}var O,x,an,cn;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(O||(O={})),function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"}(x||(x={})),function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"}(an||(an={})),function(n){n.Active="active",n.Default="default"}(cn||(cn={}));let K="0",Pn="1",bn="2",Nn="3",Ln="4",z="5",X="6",ue=()=>{},ln=new Set;function de(n){ln.add(n)}function pe(n){ln.delete(n)}let un=new Set;function fe(n){un.add(n)}function he(n){un.delete(n)}let j=new Map;async function dn(n){j.set(n.id,n);let e=[...ln].map(o=>o());await Promise.all(e)}async function J(n){j.delete(n);let e=[...un].map(o=>o());await Promise.all(e)}function pn(){return[...j.values()]}function Fn(){j.clear()}function L(n){return j.get(n)}function _n(n,e,o){return{...n,action:o||{...n.actions[0],trigger:an.UserAction},dispatcherIdentity:e}}function fn(n,e,o="ascending"){let s=n||[];if(!e?.length)return s;let c=[],l=new Map;e.forEach(p=>{if(p.key)return l.set(p.key,p);c.push(p)});let u=s.map(p=>{let{key:g}=p;if(g&&l.has(g)){let v=l.get(g);return l.delete(g),v}return p});return u.push(...l.values(),...c),u=o==="ascending"?u.sort((p,g)=>(p?.score??1/0)-(g?.score??1/0)):u.sort((p,g)=>(g?.score??1/0)-(p?.score??1/0)),u}function Tn(n){let e={},o=[],s=[],c=null,l=O.Initial;e.getStatus=()=>l,e.getResultBuffer=()=>o,e.setResultBuffer=p=>{o=p,o?.length&&e.onChange()},e.getRevokedBuffer=()=>s,e.setRevokedBuffer=p=>{s=p,s?.length&&e.onChange()},e.setUpdatedContext=p=>{c=p,e.onChange()},e.getUpdatedContext=()=>c,e.onChange=ue;let u={};return e.res=u,u.close=()=>{l!==O.Close&&(l=O.Close,e.onChange())},u.open=()=>{l!==O.Open&&(l=O.Open,e.onChange())},u.respond=p=>{let g=fn(e.getResultBuffer(),p,n);e.setResultBuffer(g)},u.revoke=(...p)=>{let g=new Set(p),v=e.getResultBuffer().filter(({key:f})=>{let R=g.has(f);return R&&g.delete(f),!R});e.setResultBuffer(v),g.size&&(e.getRevokedBuffer().forEach(f=>g.add(f)),e.setRevokedBuffer([...g]))},u.updateContext=p=>{e.setUpdatedContext(p)},e}function xn(n,e){let o=new Set,s=!1;return{close:()=>{s=!0;for(let c of o)c()},req:{id:n,...e,context:e?.context||{},onClose:c=>{o.add(c),s&&c()},removeListener:c=>{o.delete(c)}}}}function Q(){return{name:fin.me.name,uuid:fin.me.uuid}}let kn=50,ge=1e3,we=new Map;function hn(){return we}let ye=100;function me(){return async n=>{if(!n||!n.id||!n.providerId){let f=w;return console.error(f),{error:f.message}}let{id:e,providerId:o}=n,s=L(o);if(!s){let f=h;return console.error(f),{error:f.message}}let c=hn(),l=c.get(n.id);l||(l=xn(e,n),c.set(n.id,l));let u=Tn(),p=()=>{let f=u.getResultBuffer();u.setResultBuffer([]);let R=u.getRevokedBuffer();u.setRevokedBuffer([]);let F=u.getUpdatedContext();u.setUpdatedContext(null);let $=u.getStatus();(async function(M){(await b()).dispatch(K,M)})({id:e,providerId:o,results:f,revoked:R,status:$,context:F})},g=!0,v=!1;u.onChange=()=>{if(g)return g=!1,void p();v||(v=!0,setTimeout(()=>{v=!1,p()},ye))};try{let{results:f,context:R}=await s.onUserInput(l.req,u.res),F=u.getStatus();return{id:e,providerId:o,status:F,results:f,context:R}}catch(f){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${o} for search ${e}`,"This is likely a bug in the implementation of the search provider.",f),{id:e,providerId:o,error:f?.message}}}}async function $n(n,e){let o=e||await b(),s=Q(),c={...n,identity:s,onResultDispatch:void 0},l=await o.dispatch(bn,c);return await dn({identity:s,...n}),l}async function Ce(n){return await(await b()).dispatch(Nn,n),J(n)}async function Se(n,e,o,s){let c=_n(e,s??Q(),o),l=L(n);if(l){let{onResultDispatch:p}=l;return p?p(c):void 0}let u={providerId:n,result:c};return(await b()).dispatch(z,u)}async function Re(n){let e={...n,context:n?.context||{}},o={},s=async function*(l,{setState:u}){let p=await b();for(;;){let g=await p.dispatch(Pn,l),v=g.error;if(v)throw new Error(v);let f=g;if(l.id=f.id,u(f.state),f.done)return f.value;yield f.value}}(e,{setState:l=>{o.state=l}}),c=await s.next();return o.id=e.id||"",o.close=()=>{(async function(l){(await b()).dispatch(X,{id:l})})(o.id)},o.next=()=>{if(c){let l=c;return c=void 0,l}return s.next()},o}async function Ee(){return(await b()).dispatch(Ln,null)}async function ve(){let n=await b();P=void 0,Fn(),await n.disconnect()}let Ae=async n=>{let e=await Un(n);for(let o of pn())await $n(o,e);return e};async function Un(n){let e=await async function(o){for(let s=0;s<kn;s++)try{return await fin.InterApplicationBus.Channel.connect(o,{wait:!1})}catch(c){if(s===kn-1)throw c;await new Promise(l=>setTimeout(l,ge))}}(n);return e.register(K,me()),e.register(X,o=>{let s=hn(),c=s.get(o.id);c&&(c.close(),s.delete(o.id))}),e.register(z,async(o,s)=>{if(!o||!o.providerId||!o.result)return void console.error(w);let c=L(o.providerId);if(!c)return void console.error(h);let{onResultDispatch:l}=c;return l?(o.result.dispatcherIdentity=o.result.dispatcherIdentity??s,l(o.result)):void 0}),e.onDisconnection(function(o){return async()=>{if(!H())return;let s=hn();for(let{req:c,close:l}of s.values())l(),s.delete(c.id);In(Ae(o))}}(n)),e}async function Oe(n){let e=H();e||(e=Un(n),In(e));let o=await e;return{getAllProviders:Ee.bind(null),register:$n.bind(null),search:Re.bind(null),deregister:Ce.bind(null),dispatch:Se.bind(null),disconnect:ve.bind(null),channel:o}}let G;function Y(){if(G)return G;throw S}function Ie(){return G}function Pe(n){G=n}function be(){G=void 0}let gn=new Set;function Ne(n){gn.add(n)}function Le(n){gn.delete(n)}var k;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(k||(k={}));let wn=typeof window<"u"&&typeof fin<"u",Fe=(typeof process>"u"||process.env,typeof window<"u"),_e=Fe?window.origin:k.Local,Z=(wn&&fin.me.uuid,wn&&fin.me.name,wn&&fin.me.entityType,k.Local,k.Dev,k.Staging,k.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:_e+n),Dn=(Z("http://localhost:4002"),Z("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Z(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Z(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Mn(){return[...pn()].map(n=>({...n,onUserInput:void 0,onResultDispatch:void 0}))}async function Te(n){if(L(n.id))throw new Error("provider with name already exists");let e=Q();return await dn({identity:e,...n}),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}async function xe(n){await J(n)}async function ke(n,e,o,s){let c=L(n);if(!c)throw h;let{onResultDispatch:l}=c;if(l)return l(_n(e,s??Q(),o))}async function*$e(n,e){let o=function(R,F){let $=[],M=[],B=[],I=[];for(let E of R){let _=Tn(E.scoreOrder),T={results:[],provider:{id:E.id,identity:E.identity,title:E.title,scoreOrder:E.scoreOrder,icon:E.icon,dispatchFocusEvents:E.dispatchFocusEvents}};$.push(T),M.push(_);let W=(async()=>{try{let{results:V,context:en}=await E.onUserInput(F,_.res);T.results=fn(T.results||[],V,E.scoreOrder),T.context={...T.context,...en}}catch(V){T.error=V}})();W.finally(()=>{W.done=!0}),I.push(W),B.push(B.length)}return{providerResponses:$,listenerResponses:M,openListenerResponses:B,initialResponsePromises:I}}(n.targets?n.targets.map(R=>L(R)).filter(R=>!!R):[...pn().filter(R=>!R.hidden)],n),{providerResponses:s,listenerResponses:c}=o,{openListenerResponses:l,initialResponsePromises:u}=o,p=x.Fetching,g=R=>{p=R,e.setState(p)},v,f=!1;n.onClose(()=>{f=!0,v&&v()});do{let R=!1;if(u.length){let I=[];for(let E of u)E.done?R=!0:I.push(E);u=I,u.length||(g(x.Fetched),R=!0)}let F,$=!1,M=()=>{$=!0,F&&F()},B=[];for(let I of l){let E=c[I],_=s[I],T=E.getStatus();(T===O.Open||p===x.Fetching&&T===O.Initial)&&(B.push(I),E.onChange=M);let W=E.getResultBuffer();W.length&&(E.setResultBuffer([]),_.results=fn(_.results||[],W),R=!0);let V=E.getRevokedBuffer();if(V.length){E.setRevokedBuffer([]);let nt=new Set(V);_.results=(_.results||[]).filter(({key:et})=>!nt.has(et)),R=!0}let en=E.getUpdatedContext();en&&(E.setUpdatedContext(null),_.context={..._.context,...en},R=!0)}if(l=B,R&&(yield s),f)break;$||(l.length||u.length)&&await Promise.race([...u,new Promise(I=>{F=I}),new Promise(I=>{v=I})])}while(l.length||u.length);return g(x.Complete),s}let yn=0;async function Bn(n){yn+=1;let e=xn(yn.toString(),n),o=$e(e.req,{setState:s=>{o.state=s}});return o.id=yn.toString(),o.close=e.close,o.state=x.Fetching,o}let nn=new Map,Ue=1e4;function De(){return async n=>{if(!n)return console.error(w),{error:w.message};let e;if(n.id)e=n.id;else{let c=await Bn(n);e=c.id,n.id=c.id,nn.set(e,{generator:c})}let o=nn.get(e);clearTimeout(o.timeout);let s=await o.generator.next();return o.timeout=function(c){return window.setTimeout(()=>{nn.delete(c)},Ue)}(e),{...s,id:n.id,state:o.generator.state}}}function Me(n,e){return Y().dispatch(n,X,{id:e})}function Be(){return n=>function(e){let o=nn.get(e);o&&o.generator.close()}(n.id)}async function We(n,{id:e,query:o,context:s,targets:c=[]}){let l=Y(),u={id:e,query:o,context:s,targets:c,providerId:n.id},p=await l.dispatch(n.identity,K,u),g=p.error;if(g)throw new Error(g);return p}let mn=new Map;function Ve(n,e){return`${n.name}:${n.uuid}:${e}`}let Cn=new Map;function Wn(n,e){return`${n}:${e}`}function qe(n){let e=Ve.bind(null,n.identity),o=Me.bind(null,n.identity),s=We.bind(null,n);return async(c,l)=>{let u=e(c.id);if(!mn.has(u)){let f=()=>{o(c.id),mn.delete(u)};mn.set(u,f),c.onClose(f)}let p=Wn(n.id,c.id),g=()=>{Cn.delete(p),l.close()};c.onClose(g),Cn.set(p,f=>{f.results?.length&&l.respond(f.results),f.revoked?.length&&l.revoke(...f.revoked),f.context&&l.updateContext(f.context),f.status===O.Open&&l.open(),f.status===O.Close&&g()});let v=await s(c);return v.status===O.Open&&l.open(),v.status!==O.Close&&v.status!==O.Initial||g(),v}}function je(n){return async e=>{let o=Y(),s={providerId:n.id,result:e};return o.dispatch(n.identity,z,s)}}let D=new Map;function Sn(n){return`${n.name}-${n.uuid}`}function Ge(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(w);if(L(n.id))throw m;return n.identity=e,await async function(o){let s=Sn(o.identity);D.has(s)||D.set(s,[]),D.get(s).push(o.id),await dn({...o,onUserInput:qe(o),onResultDispatch:je(o)})}(n),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}}function He(){return(n,e)=>{n?function(o,s){let c=L(o);if(!c)return;if(c.identity.uuid!==s.uuid||c.identity.name!==s.name)throw h;let l=Sn(c.identity),u=D.get(l);if(u){let p=u.findIndex(g=>g===o);p!==-1&&(u.splice(p,1),J(o))}}(n,e):console.error(w)}}let Rn=new Set;function Ke(n){Rn.add(n)}function ze(n){Rn.delete(n)}function Xe(){return async n=>{(function(e){let o=Sn(e),s=D.get(o);if(s){for(let c of s)J(c);D.delete(o)}})(n),Rn.forEach(e=>e(n))}}async function Je(n){let e=await(o=n,fin.InterApplicationBus.Channel.create(o));var o;return e.onConnection(async s=>{for(let c of gn)if(!await c(s))throw C}),e.onDisconnection(Xe()),e.register(X,Be()),e.register(K,s=>{let c=Wn(s.providerId,s.id),l=Cn.get(c);l&&l(s)}),e.register(bn,Ge()),e.register(Nn,He()),e.register(Ln,async()=>Mn()),e.register(Pn,De()),e.register(z,async(s,c)=>{if(!s||!s.providerId||!s.result)return void console.error(w);let l=L(s.providerId);if(!l)throw h;let{onResultDispatch:u}=l;return u?(s.result.dispatcherIdentity=s.result.dispatcherIdentity??c,u(s.result)):void 0}),e}async function Qe(){let n=Y();be(),await n.destroy(),Fn()}async function Ye(n){let e=Ie();e||(e=await Je(n),Pe(e));let o=Le.bind(null),s=ze.bind(null),c=pe.bind(null),l=he.bind(null);return{getAllProviders:Mn.bind(null),search:Bn.bind(null),register:Te.bind(null),deregister:xe.bind(null),onSubscription:Ne.bind(null),onDisconnect:Ke.bind(null),onRegister:de.bind(null),onDeregister:fe.bind(null),dispatch:ke.bind(null),disconnect:Qe.bind(null),removeListener:u=>{o(u),s(u),c(u),l(u)},channel:e}}let{v:Vn}=a,{B:qn}=r,jn="all",Ze={create:Vn,subscribe:qn,defaultTopic:jn},Gn=()=>{window.search=Ze},Hn=n=>{let e=()=>{Gn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Gn();let n="load",e=Hn(n);window.addEventListener(n,e);let o="DOMContentLoaded",s=Hn(o);window.addEventListener(o,s)}Xn.exports=i})()});var y="@openfin/cloud-api";async function N(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch{return!1}}function zn(t){if(t.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(t.name)?t.name.split("/")[0]||"":t.name}var q="@openfin/cloud-api";function lt(){return`${window.fin.me.uuid}-cloud-api-notifications`}var An=null;async function qt(){return An||(An=ut()),An}async function ut(){if(!window.fin)throw new Error(`\`${q}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${q}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);zn(window.fin.me);let t=await dt();console.log(t),t.register("openfin-cloud-event",r=>{for(let a of i.get(r.type)??[])typeof r.payload.timestamp=="string"&&(r.payload.timestamp=new Date(r.payload.timestamp)),a(r.payload)});let i=new Map;return{addEventListener:(r,a)=>{let d=i.get(r)||new Set;d.add(a),i.set(r,d)},removeEventListener:(r,a)=>{let d=i.get(r);if(!d){console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,r);return}d.delete(a)===!1&&console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,r)},update:async r=>(await t.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:r}})).payload.response,clear:async r=>(await t.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:r}})).payload.response,createNotification:async r=>(r.id&&console.warn(`\`${q}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await t.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...r,id:void 0}}})).payload.response)}}var tn=null;async function dt(){return tn||(tn=pt()),tn}async function pt(){let t=await window.fin.InterApplicationBus.Channel.connect(lt());return t.onDisconnection(i=>{console.warn(`\`${q}\`: Channel Disconnected from`,i,"Reconnecting..."),tn=null}),t}var On;function ft(){return`${window.fin.me.uuid}-client-api`}async function U(){return On||(On=window.fin.InterApplicationBus.Channel.connect(ft())),On}async function Ht(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-settings")}async function Kt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-settings")}async function zt(t){if(!window.fin)throw new Error(`\`${y}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("set-user-settings",t)}async function Xt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-permissions")}async function Jt(t,i){if(!window.fin)throw new Error(`\`${y}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let r=await U();try{await r.dispatch("launch-content",{id:t,options:i})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${y}: \`launchContent\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchContent\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchContent\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchContent\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Qt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-supertab",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchSupertab\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchSupertab\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchSupertab\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchSupertab\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Yt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-workspace",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchWorkspace\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchWorkspace\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchWorkspace\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchWorkspace\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}var ne={};Kn(ne,{getAgentConfiguration:()=>Yn,register:()=>Zn});var Qn=vn(on(),1),ht="[here-agent]",gt="log-message-",wt="open-url",yt="provider-status-",mt="registered-",Ct="1.0";function St(t,i){let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}}function Jn(t){return{...t,data:t.data.customData}}async function Yn(){let{customData:t}=await window.fin.me.getOptions();return t}function Rt(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function Et(t,i,r,a=!0){await i("info",`Setting status as ${a?"ready":"not ready"}`);try{await t.dispatch(`${yt}${r}`,{isReady:a})}catch(d){let h=["Error setting provider status",d];console.error(...h),i("error",...h)}}async function vt(t,i,r,...a){try{console.log(ht,...a),await t.dispatch(`${gt}${i}`,{level:r,message:a})}catch(d){console.error("Error logging message",d)}}async function At(t,i,r,a,d){let{action:h,dispatcherIdentity:m,...w}=d;await r("info","Handling action",{action:h,dispatcherIdentity:m,result:w});let C;try{let P=Jn(d).actions?.find(({name:H})=>H===h.name);if(!P)throw new Error("Original action not found in search result");C=(await a(P,Jn(d)))?.url}catch(S){throw await r("error","Error handling dispatch",S),S}if(!C){await r("warn","OnActionListener did not return a URL");return}await It(t,r,i,C,m)}async function Ot(t,i,r,a){await i("info","Getting search results",{request:a});try{let d=new AbortController;a.onClose(()=>d.abort());let{context:h,query:m}=a,{results:w}=await r({context:h,query:m,signal:d.signal}),C=w.map(S=>St(S,t));return await i("info","Returning results",C),{results:C}}catch(d){let h=["Error handling search",d];throw console.error(...h),i("error",...h),d}}async function It(t,i,r,a,d){await i("info","Opening URL",{url:a,targetIdentity:d});try{await t.dispatch(wt,{url:a,targetIdentity:d,providerId:r})}catch(h){let m=["Error opening URL",h];console.error(...m),i("error",...m)}}async function Zn(t){let r=(await window.fin.me.getOptions()).customData,{id:a,title:d}=r,{onAction:h,onSearch:m}=t,w=await Qn.subscribe(Rt()),C=w.channel,S=vt.bind(null,C,a);return await w.register({icon:"",id:a,onResultDispatch:At.bind(null,C,a,S,h),onUserInput:Ot.bind(null,a,S,m),title:d}),await w.channel.dispatch(`${mt}${a}`,{version:Ct}),S("info","Registered search topic",{id:a,title:d}),{isReady:Et.bind(null,C,S,a)}}var le={};Kn(le,{getConfiguration:()=>ae,register:()=>ce});var se=vn(on(),1);var rn=class extends Error{constructor(){super("Interop feature is not supported by the agent")}};async function sn(t,i){try{let r=await window.fin.me.interop.getFDC3(t);i==="none"?(A("Leaving current channel"),await r.leaveCurrentChannel()):(A(`Joining interop channel: ${i}`),await("joinUserChannel"in r?r.joinUserChannel(i):r.joinChannel(i)))}catch(r){A(`Failed to join interop channel: ${i}`,r)}}var ro=vn(on(),1);var Nt=(t,i)=>{let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}},ee=t=>({...t,data:t.data.customData}),te=()=>`${window.fin.me.identity.uuid}-cloud-api-search`,Lt=async({channel:t,url:i,targetIdentity:r})=>{A("Opening URL",{url:i,targetIdentity:r});try{await t.dispatch(ie,{url:i,targetIdentity:r})}catch(a){console.error("Failed opening URL",a)}},oe=async(t,i,r,a)=>{let{action:d,dispatcherIdentity:h,...m}=a;A("Handling action...",{action:d,dispatcherIdentity:h,result:m});let w;try{let S=ee(a).actions?.find(({name:b})=>b===d.name);if(!S)throw new Error("Original action not found in search result");w=(await r(S,ee(a)))?.url}catch(C){throw A("Error handling dispatch",C),C}if(!w){A("OnActionListener did not return a URL");return}await Lt({channel:t,url:w,targetIdentity:h})},re=async(t,i,r)=>{A("Getting search results...",{request:r});try{let a=new AbortController;r.onClose(()=>a.abort());let{context:d,query:h}=r,{results:m}=await i({context:d,query:h,signal:a.signal}),w=m.map(C=>Nt(C,t));return A("Returning results",w),{results:w}}catch(a){throw new Error("Error handling search request",{cause:a})}};var _t="[here-agent]",Tt="1.0",xt="-enterprise-component-bridge",ie="open-url",kt="set-agent-registered",$t="set-agent-status",ae=async()=>{let{customData:t}=await window.fin.me.getOptions(),i=t,{configurationFields:r}=i;return Object.fromEntries(r?.map(a=>[a.name,a.value])??[])};async function Ut(t,i){if(!t.interop)throw new rn;let{fdc3Version:r}=t.interop;await sn(r,i)}function A(...t){console.log(_t,...t)}var Dt=async(t,i,r=!0)=>{A(`Setting status to ${r?"ready":"not ready"}`);try{await t.dispatch($t,{id:i,isReady:r})}catch(a){throw new Error("Failed to set agent status",{cause:a})}};async function ce(t){let{customData:i}=await window.fin.me.getOptions(),r=i;A("Registering agent...",r);try{let a=`${window.fin.me.identity.uuid}${xt}`,d;try{d=await window.fin.InterApplicationBus.Channel.connect(a,{wait:!1})}catch(S){throw new Error("Failed to connect to enterprise component bridge channel",{cause:S})}let{id:h,features:m,title:w}=r,C={features:m,joinInteropChannel:Ut.bind(null,m),setIsReady:Dt.bind(null,d,h)};if(m.interop){A("Enabling interop features");let{defaultChannel:S,fdc3Version:P}=m.interop;S&&S!=="none"&&await sn(P,S),d.register("on-desktop-app-signals-changed",Mt.bind(null,r))}return m.search&&t.search&&(A("Enabling search features"),await(await se.subscribe(te())).register({icon:"",id:h,onResultDispatch:oe.bind(null,d,h,t.search.onAction),onUserInput:re.bind(null,h,t.search.onSearch),title:w})),await d.dispatch(kt,{id:h,apiVersion:Tt}),A("Registered successfully"),C}catch(a){throw new Error("Failed to register agent",{cause:a})}}function Mt(t,i){A("Desktop app signals changed",i);let r=i,{type:a,id:d,features:h}=t,{fdc3Version:m}=h.interop,w=r.find(C=>a==="agent"?C.appKey===t.name:a==="custom"?C.appKey===d:!1);w&&sn(m,w.selectedColorChannel)}export{le as Agent,ne as Search,Ht as getAppSettings,Xt as getAppUserPermissions,Kt as getAppUserSettings,qt as getNotificationsClient,Jt as launchContent,Qt as launchSupertab,Yt as launchWorkspace,zt as setAppUserSettings};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|