@stolostron/multicluster-sdk 0.10.3 → 1.0.1-preview
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 +182 -10
- package/lib/api/FleetResourceLink.d.ts +3 -0
- package/lib/api/FleetResourceLink.d.ts.map +1 -0
- package/lib/api/FleetResourceLink.js +32 -0
- package/lib/api/FleetResourceLink.js.map +1 -0
- package/lib/api/FleetSupport.d.ts +6 -0
- package/lib/api/FleetSupport.d.ts.map +1 -0
- package/lib/api/FleetSupport.js +45 -0
- package/lib/api/FleetSupport.js.map +1 -0
- package/lib/api/apiRequests.d.ts +70 -0
- package/lib/api/apiRequests.d.ts.map +1 -0
- package/lib/api/apiRequests.js +193 -0
- package/lib/api/apiRequests.js.map +1 -0
- package/lib/api/constants.d.ts +1 -1
- package/lib/api/constants.js +1 -1
- package/lib/api/index.d.ts +3 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +3 -2
- package/lib/api/index.js.map +1 -1
- package/lib/api/search/search-client.d.ts +3 -0
- package/lib/api/search/search-client.d.ts.map +1 -0
- package/lib/api/search/search-client.js +39 -0
- package/lib/api/search/search-client.js.map +1 -0
- package/lib/api/search/search-sdk.d.ts +502 -0
- package/lib/api/search/search-sdk.d.ts.map +1 -0
- package/lib/api/search/search-sdk.js +354 -0
- package/lib/api/search/search-sdk.js.map +1 -0
- package/lib/api/search/searchUtils.d.ts +10 -0
- package/lib/api/search/searchUtils.d.ts.map +1 -0
- package/lib/api/search/searchUtils.js +35 -0
- package/lib/api/search/searchUtils.js.map +1 -0
- package/lib/api/search/types.d.ts +9 -0
- package/lib/api/search/types.d.ts.map +1 -0
- package/lib/api/search/types.js +3 -0
- package/lib/api/search/types.js.map +1 -0
- package/lib/api/search/useFleetSearchPoll.d.ts +3 -0
- package/lib/api/search/useFleetSearchPoll.d.ts.map +1 -0
- package/lib/api/search/useFleetSearchPoll.js +104 -0
- package/lib/api/search/useFleetSearchPoll.js.map +1 -0
- package/lib/api/search/useMulticlusterSearchWatch.d.ts +3 -0
- package/lib/api/search/useMulticlusterSearchWatch.d.ts.map +1 -0
- package/lib/api/search/useMulticlusterSearchWatch.js +69 -0
- package/lib/api/search/useMulticlusterSearchWatch.js.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.d.ts +4 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.d.ts.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.js +132 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.js.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.d.ts +2 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.d.ts.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.js +56 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.js.map +1 -0
- package/lib/api/useBackendURL.d.ts +2 -0
- package/lib/api/useBackendURL.d.ts.map +1 -0
- package/lib/api/useBackendURL.js +45 -0
- package/lib/api/useBackendURL.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/constants.d.ts +8 -0
- package/lib/api/useFleetPrometheusPoll/constants.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/constants.js +12 -0
- package/lib/api/useFleetPrometheusPoll/constants.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/index.d.ts +8 -0
- package/lib/api/useFleetPrometheusPoll/index.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/index.js +39 -0
- package/lib/api/useFleetPrometheusPoll/index.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.d.ts +2 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.js +27 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.d.ts +2 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.js +23 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.d.ts +4 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.js +40 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/utils.d.ts +13 -0
- package/lib/api/useFleetPrometheusPoll/utils.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/utils.js +76 -0
- package/lib/api/useFleetPrometheusPoll/utils.js.map +1 -0
- package/lib/api/useFleetSearch.d.ts +72 -0
- package/lib/api/useFleetSearch.d.ts.map +1 -0
- package/lib/api/useFleetSearch.js +363 -0
- package/lib/api/useFleetSearch.js.map +1 -0
- package/lib/api/useFleetSearchSubscription.d.ts +43 -0
- package/lib/api/useFleetSearchSubscription.d.ts.map +1 -0
- package/lib/api/useFleetSearchSubscription.js +54 -0
- package/lib/api/useFleetSearchSubscription.js.map +1 -0
- package/lib/api/utils/api-resource-list.d.ts +2 -0
- package/lib/api/utils/api-resource-list.d.ts.map +1 -0
- package/lib/api/utils/api-resource-list.js +18 -0
- package/lib/api/utils/api-resource-list.js.map +1 -0
- package/lib/api/utils/requirements.d.ts +6 -0
- package/lib/api/utils/requirements.d.ts.map +1 -0
- package/lib/api/utils/requirements.js +60 -0
- package/lib/api/utils/requirements.js.map +1 -0
- package/lib/api/utils/searchPaths.d.ts +2 -0
- package/lib/api/utils/searchPaths.d.ts.map +1 -0
- package/lib/api/utils/searchPaths.js +28 -0
- package/lib/api/utils/searchPaths.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventComponent.d.ts +5 -0
- package/lib/components/FleetResourceEventStream/EventComponent.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventComponent.js +52 -0
- package/lib/components/FleetResourceEventStream/EventComponent.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStream.d.ts +6 -0
- package/lib/components/FleetResourceEventStream/EventStream.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStream.js +183 -0
- package/lib/components/FleetResourceEventStream/EventStream.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.d.ts +17 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.js +92 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.js.map +1 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.d.ts +8 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.js +17 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.js.map +1 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.d.ts +7 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.js +51 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.js.map +1 -0
- package/lib/components/FleetResourceEventStream/constants.d.ts +30 -0
- package/lib/components/FleetResourceEventStream/constants.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/constants.js +6 -0
- package/lib/components/FleetResourceEventStream/constants.js.map +1 -0
- package/lib/components/FleetResourceEventStream/utils.d.ts +16 -0
- package/lib/components/FleetResourceEventStream/utils.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/utils.js +143 -0
- package/lib/components/FleetResourceEventStream/utils.js.map +1 -0
- package/lib/components/FleetResourceLink.js +2 -2
- package/lib/components/FleetResourceLink.js.map +1 -1
- package/lib/extensions/resource.d.ts +4 -4
- package/lib/extensions/resource.d.ts.map +1 -1
- package/lib/internal/FleetResourceEventStream/EventComponent.d.ts.map +1 -1
- package/lib/internal/FleetResourceEventStream/EventComponent.js +6 -3
- package/lib/internal/FleetResourceEventStream/EventComponent.js.map +1 -1
- package/lib/internal/cachedHubClusterName.d.ts +3 -0
- package/lib/internal/cachedHubClusterName.d.ts.map +1 -0
- package/lib/internal/cachedHubClusterName.js +32 -0
- package/lib/internal/cachedHubClusterName.js.map +1 -0
- package/lib/internal/context/FleetSupportContext.d.ts +7 -0
- package/lib/internal/context/FleetSupportContext.d.ts.map +1 -0
- package/lib/internal/context/FleetSupportContext.js +7 -0
- package/lib/internal/context/FleetSupportContext.js.map +1 -0
- package/lib/internal/hooks/index.d.ts +2 -0
- package/lib/internal/hooks/index.d.ts.map +1 -0
- package/lib/internal/hooks/index.js +19 -0
- package/lib/internal/hooks/index.js.map +1 -0
- package/lib/internal/hooks/useFleetSupport.d.ts +2 -0
- package/lib/internal/hooks/useFleetSupport.d.ts.map +1 -0
- package/lib/internal/hooks/useFleetSupport.js +10 -0
- package/lib/internal/hooks/useFleetSupport.js.map +1 -0
- package/lib/internal/index.d.ts +3 -0
- package/lib/internal/index.d.ts.map +1 -0
- package/lib/internal/index.js +20 -0
- package/lib/internal/index.js.map +1 -0
- package/lib/internal/resourceRouteUtils.d.ts +3 -3
- package/lib/internal/resourceRouteUtils.d.ts.map +1 -1
- package/lib/internal/search/convertSearchItemToResource.d.ts.map +1 -1
- package/lib/internal/search/convertSearchItemToResource.js +7 -4
- package/lib/internal/search/convertSearchItemToResource.js.map +1 -1
- package/lib/internal/search/search-client.d.ts.map +1 -1
- package/lib/internal/search/search-client.js +33 -5
- package/lib/internal/search/search-client.js.map +1 -1
- package/lib/internal/search/search-sdk.d.ts +91 -1
- package/lib/internal/search/search-sdk.d.ts.map +1 -1
- package/lib/internal/search/search-sdk.js +33 -1
- package/lib/internal/search/search-sdk.js.map +1 -1
- package/lib/internal/types/index.d.ts +2 -0
- package/lib/internal/types/index.d.ts.map +1 -0
- package/lib/internal/types/index.js +19 -0
- package/lib/internal/types/index.js.map +1 -0
- package/lib/internal/types/multicluster-sdk.d.ts +18 -0
- package/lib/internal/types/multicluster-sdk.d.ts.map +1 -0
- package/lib/internal/types/multicluster-sdk.js +10 -0
- package/lib/internal/types/multicluster-sdk.js.map +1 -0
- package/lib/internal/utils/shouldUseFleetSupport.d.ts +3 -0
- package/lib/internal/utils/shouldUseFleetSupport.d.ts.map +1 -0
- package/lib/internal/utils/shouldUseFleetSupport.js +8 -0
- package/lib/internal/utils/shouldUseFleetSupport.js.map +1 -0
- package/lib/setupTests.js +0 -2
- package/lib/setupTests.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/search.d.ts +94 -0
- package/lib/types/search.d.ts.map +1 -1
- package/package.json +18 -16
package/README.md
CHANGED
|
@@ -8,7 +8,14 @@ This SDK provides extensions and APIs that dynamic plugins can use to leverage m
|
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
11
|
-
- Red Hat Advanced Cluster Management for Kubernetes
|
|
11
|
+
- Red Hat Advanced Cluster Management for Kubernetes
|
|
12
|
+
|
|
13
|
+
Version compatibility:
|
|
14
|
+
|
|
15
|
+
| multicluster SDK | RHACM | OpenShift Container Platform |
|
|
16
|
+
| ----------------- | -------- | ----------------------------- |
|
|
17
|
+
| 0.x | >=2.15.0 | >=4.19.0 |
|
|
18
|
+
| 1.x | >=5.0.0 | >=4.22.0 |
|
|
12
19
|
|
|
13
20
|
## Installation
|
|
14
21
|
|
|
@@ -57,6 +64,7 @@ Setup depends on your usage scenarios.
|
|
|
57
64
|
- [useFleetK8sWatchResource](#gear-usefleetk8swatchresource)
|
|
58
65
|
- [useFleetK8sWatchResources](#gear-usefleetk8swatchresources)
|
|
59
66
|
- [useFleetPrometheusPoll](#gear-usefleetprometheuspoll)
|
|
67
|
+
- [useFleetSearch](#gear-usefleetsearch)
|
|
60
68
|
- [useFleetSearchPoll](#gear-usefleetsearchpoll)
|
|
61
69
|
- [useHubClusterName](#gear-usehubclustername)
|
|
62
70
|
- [useIsFleetAvailable](#gear-useisfleetavailable)
|
|
@@ -861,6 +869,88 @@ if (error) {
|
|
|
861
869
|
|
|
862
870
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetPrometheusPoll.ts#L86)
|
|
863
871
|
|
|
872
|
+
### :gear: useFleetSearch
|
|
873
|
+
|
|
874
|
+
A React hook that provides fleet-wide search functionality using the ACM search API,
|
|
875
|
+
with optional real-time updates via a GraphQL WebSocket subscription.
|
|
876
|
+
|
|
877
|
+
When `subscriptionEnabled` is `false` (the default), the hook issues a one-shot
|
|
878
|
+
GraphQL query and returns the results. When `subscriptionEnabled` is `true`, the
|
|
879
|
+
hook additionally opens a WebSocket subscription and patches the locally-held
|
|
880
|
+
results as INSERT, UPDATE, and DELETE events arrive — keeping the data always
|
|
881
|
+
up to date without polling.
|
|
882
|
+
|
|
883
|
+
Pagination is supported by setting `limit` and `offset` on the `SearchInput`
|
|
884
|
+
object. The caller is responsible for constructing those values.
|
|
885
|
+
|
|
886
|
+
| Function | Type |
|
|
887
|
+
| ---------- | ---------- |
|
|
888
|
+
| `useFleetSearch` | `<T extends K8sResourceCommon = K8sResourceCommon>(input: SearchInput or undefined, subscriptionEnabled?: boolean or undefined) => [Fleet<T>[] or undefined, boolean, Error or undefined, () => void]` |
|
|
889
|
+
|
|
890
|
+
Parameters:
|
|
891
|
+
|
|
892
|
+
* `input`: - The search input object (filters, keywords, limit, offset, etc.).
|
|
893
|
+
Pass `undefined` to skip the query entirely.
|
|
894
|
+
* `subscriptionEnabled`: - When `true`, a WebSocket subscription is opened
|
|
895
|
+
and the local result set is kept current via incremental event patches.
|
|
896
|
+
Defaults to `false`.
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
Returns:
|
|
900
|
+
|
|
901
|
+
A tuple of:
|
|
902
|
+
- `data` — The current search results mapped through
|
|
903
|
+
{@link convertSearchItemToResource }, or `undefined` before the first
|
|
904
|
+
response arrives.
|
|
905
|
+
- `loaded` — `true` once the initial query has completed (regardless of
|
|
906
|
+
whether the subscription is active).
|
|
907
|
+
- `error` — Any query or subscription error, or `undefined` on success.
|
|
908
|
+
- `refetch` — A stable callback that re-executes the base query and resets
|
|
909
|
+
the local state to the fresh result.
|
|
910
|
+
|
|
911
|
+
Examples:
|
|
912
|
+
|
|
913
|
+
```typescript
|
|
914
|
+
// Basic query — no real-time updates
|
|
915
|
+
const [resources, loaded, error, refetch] = useFleetSearch({
|
|
916
|
+
filters: [
|
|
917
|
+
{ property: 'kind', values: ['Pod'] },
|
|
918
|
+
{ property: 'namespace', values: ['default'] },
|
|
919
|
+
],
|
|
920
|
+
limit: 100,
|
|
921
|
+
})
|
|
922
|
+
|
|
923
|
+
// With real-time subscription — results update automatically
|
|
924
|
+
const [resources, loaded, error, refetch] = useFleetSearch(
|
|
925
|
+
{
|
|
926
|
+
filters: [
|
|
927
|
+
{ property: 'kind', values: ['Pod'] },
|
|
928
|
+
{ property: 'namespace', values: ['default'] },
|
|
929
|
+
],
|
|
930
|
+
},
|
|
931
|
+
true,
|
|
932
|
+
)
|
|
933
|
+
|
|
934
|
+
// With subscription enabled and pagination/ordering — page 2 of 20 results sorted by name
|
|
935
|
+
const PAGE_SIZE = 20
|
|
936
|
+
const [page, setPage] = useState(1)
|
|
937
|
+
const [resources, loaded, error, refetch] = useFleetSearch(
|
|
938
|
+
{
|
|
939
|
+
filters: [
|
|
940
|
+
{ property: 'kind', values: ['Pod'] },
|
|
941
|
+
{ property: 'namespace', values: ['default'] },
|
|
942
|
+
],
|
|
943
|
+
limit: PAGE_SIZE,
|
|
944
|
+
offset: (page - 1) * PAGE_SIZE,
|
|
945
|
+
orderBy: 'name asc',
|
|
946
|
+
},
|
|
947
|
+
true,
|
|
948
|
+
)
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetSearch.ts#L246)
|
|
953
|
+
|
|
864
954
|
### :gear: useFleetSearchPoll
|
|
865
955
|
|
|
866
956
|
A React hook that provides fleet-wide search functionality using the ACM search API.
|
|
@@ -1010,7 +1100,7 @@ if (error) {
|
|
|
1010
1100
|
|
|
1011
1101
|
| Constant | Type |
|
|
1012
1102
|
| ---------- | ---------- |
|
|
1013
|
-
| `REQUIRED_PROVIDER_FLAG` | `"
|
|
1103
|
+
| `REQUIRED_PROVIDER_FLAG` | `"MULTICLUSTER_SDK_PROVIDER_2"` |
|
|
1014
1104
|
|
|
1015
1105
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/constants.ts#L2)
|
|
1016
1106
|
|
|
@@ -1045,9 +1135,14 @@ if (error) {
|
|
|
1045
1135
|
- [FleetWatchK8sResult](#gear-fleetwatchk8sresult)
|
|
1046
1136
|
- [FleetWatchK8sResults](#gear-fleetwatchk8sresults)
|
|
1047
1137
|
- [FleetWatchK8sResultsObject](#gear-fleetwatchk8sresultsobject)
|
|
1138
|
+
- [InputMaybe](#gear-inputmaybe)
|
|
1139
|
+
- [Maybe](#gear-maybe)
|
|
1048
1140
|
- [ResourceRoute](#gear-resourceroute)
|
|
1049
1141
|
- [ResourceRouteHandler](#gear-resourceroutehandler)
|
|
1050
1142
|
- [ResourceRouteProps](#gear-resourcerouteprops)
|
|
1143
|
+
- [Scalars](#gear-scalars)
|
|
1144
|
+
- [SearchFilter](#gear-searchfilter)
|
|
1145
|
+
- [SearchInput](#gear-searchinput)
|
|
1051
1146
|
- [SearchResult](#gear-searchresult)
|
|
1052
1147
|
|
|
1053
1148
|
### :gear: AdvancedSearchFilter
|
|
@@ -1056,7 +1151,7 @@ if (error) {
|
|
|
1056
1151
|
| ---------- | ---------- |
|
|
1057
1152
|
| `AdvancedSearchFilter` | `{ property: string; values: string[] }[]` |
|
|
1058
1153
|
|
|
1059
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#
|
|
1154
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L87)
|
|
1060
1155
|
|
|
1061
1156
|
### :gear: ClusterSetData
|
|
1062
1157
|
|
|
@@ -1091,9 +1186,16 @@ The "global" key is a special set that contains all clusters (when includeGlobal
|
|
|
1091
1186
|
|
|
1092
1187
|
Options for advanced cluster name retrieval with cluster set organization.
|
|
1093
1188
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1189
|
+
```typescript
|
|
1190
|
+
type FleetClusterNamesOptions = {
|
|
1191
|
+
/** Whether to return all clusters regardless of availability status. Defaults to false. */
|
|
1192
|
+
returnAllClusters?: boolean
|
|
1193
|
+
/** Specific cluster set names to include. If not specified, includes all cluster sets including "default". Should not include "global" - use includeGlobal instead. */
|
|
1194
|
+
clusterSets?: string[]
|
|
1195
|
+
/** Whether to include a special "global" set containing all clusters. Defaults to false. */
|
|
1196
|
+
includeGlobal?: boolean
|
|
1197
|
+
}
|
|
1198
|
+
```
|
|
1097
1199
|
|
|
1098
1200
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L101)
|
|
1099
1201
|
|
|
@@ -1209,13 +1311,29 @@ Options for advanced cluster name retrieval with cluster set organization.
|
|
|
1209
1311
|
|
|
1210
1312
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L26)
|
|
1211
1313
|
|
|
1314
|
+
### :gear: InputMaybe
|
|
1315
|
+
|
|
1316
|
+
| Type | Type |
|
|
1317
|
+
| ---------- | ---------- |
|
|
1318
|
+
| `InputMaybe` | `Maybe<T>` |
|
|
1319
|
+
|
|
1320
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L6)
|
|
1321
|
+
|
|
1322
|
+
### :gear: Maybe
|
|
1323
|
+
|
|
1324
|
+
| Type | Type |
|
|
1325
|
+
| ---------- | ---------- |
|
|
1326
|
+
| `Maybe` | `T or null` |
|
|
1327
|
+
|
|
1328
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L5)
|
|
1329
|
+
|
|
1212
1330
|
### :gear: ResourceRoute
|
|
1213
1331
|
|
|
1214
1332
|
This extension allows plugins to customize the route used for resources of the given kind. Search results and resource links will direct to the route returned by the implementing function.
|
|
1215
1333
|
|
|
1216
1334
|
| Type | Type |
|
|
1217
1335
|
| ---------- | ---------- |
|
|
1218
|
-
| `ResourceRoute` | `
|
|
1336
|
+
| `ResourceRoute` | `Extension<typeof RESOURCE_ROUTE_TYPE, ResourceRouteProps>` |
|
|
1219
1337
|
|
|
1220
1338
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/extensions/resource.ts#L28)
|
|
1221
1339
|
|
|
@@ -1229,11 +1347,65 @@ This extension allows plugins to customize the route used for resources of the g
|
|
|
1229
1347
|
|
|
1230
1348
|
### :gear: ResourceRouteProps
|
|
1231
1349
|
|
|
1350
|
+
```typescript
|
|
1351
|
+
type ResourceRouteProps = {
|
|
1352
|
+
/** The model for which this resource route should be used. */
|
|
1353
|
+
model: ExtensionK8sGroupKindModel
|
|
1354
|
+
/** The handler function that returns the route path for the resource. */
|
|
1355
|
+
handler: CodeRef<ResourceRouteHandler>
|
|
1356
|
+
}
|
|
1357
|
+
```
|
|
1358
|
+
|
|
1359
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/extensions/resource.ts#L20)
|
|
1360
|
+
|
|
1361
|
+
### :gear: Scalars
|
|
1362
|
+
|
|
1363
|
+
All built-in and custom scalars, mapped to their actual values
|
|
1364
|
+
|
|
1232
1365
|
| Type | Type |
|
|
1233
1366
|
| ---------- | ---------- |
|
|
1234
|
-
| `
|
|
1367
|
+
| `Scalars` | `{ ID: { input: string; output: string } String: { input: string; output: string } Boolean: { input: boolean; output: boolean } Int: { input: number; output: number } Float: { input: number; output: number } Date: { input: any; output: any } Map: { input: any; output: any } }` |
|
|
1235
1368
|
|
|
1236
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/
|
|
1369
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L8)
|
|
1370
|
+
|
|
1371
|
+
### :gear: SearchFilter
|
|
1372
|
+
|
|
1373
|
+
Defines a key/value to filter results.
|
|
1374
|
+
When multiple values are provided for a property, it is interpreted as an OR operation.
|
|
1375
|
+
|
|
1376
|
+
```typescript
|
|
1377
|
+
type SearchFilter = {
|
|
1378
|
+
/** Name of the property (key). */
|
|
1379
|
+
property: string
|
|
1380
|
+
/** Values for the property. Multiple values per property are interpreted as an OR operation. Optionally one of these operations `=,!,!=,>,>=,<,<=` can be included at the beginning of the value. By default the equality operation is used. The values available for datetime fields (Ex: `created`, `startedAt`) are `hour`, `day`, `week`, `month` and `year`. Property `kind`, if included in the filter, will be matched using a case-insensitive comparison. For example, `kind:Pod` and `kind:pod` will bring up all pods. This is to maintain compatibility with Search V1. Wildcard matching: the `*` character can be used as a wildcard to match any sequence of characters. For example, a filter with property `name` and value `nginx-*` matches any resource whose name starts with `nginx-`. Similarly, property `namespace` with value `prod*` matches any namespace starting with `prod`. Wildcard matches are case-sensitive. */
|
|
1381
|
+
values: string[]
|
|
1382
|
+
}
|
|
1383
|
+
```
|
|
1384
|
+
|
|
1385
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L23)
|
|
1386
|
+
|
|
1387
|
+
### :gear: SearchInput
|
|
1388
|
+
|
|
1389
|
+
Input options to the search query.
|
|
1390
|
+
|
|
1391
|
+
```typescript
|
|
1392
|
+
type SearchInput = {
|
|
1393
|
+
/** List of SearchFilter, which is a key(property) and values. When multiple filters are provided, results will match all filters (AND operation). */
|
|
1394
|
+
filters?: SearchFilter[]
|
|
1395
|
+
/** List of strings to match resources. Will match resources containing any of the keywords in any text field. When multiple keywords are provided, it is interpreted as an AND operation. Matches are case insensitive. */
|
|
1396
|
+
keywords?: string[]
|
|
1397
|
+
/** Max number of results returned by the query. **Default is** 10,000 A value of -1 will remove the limit. Use carefully because it may impact the service. */
|
|
1398
|
+
limit?: number
|
|
1399
|
+
/** Number of results to skip before returning results. Used in combination with limit to implement pagination. **Default is** 0 */
|
|
1400
|
+
offset?: number
|
|
1401
|
+
/** Order results by a property and direction. Format: "property_name asc" or "property_name desc" Example: "name desc" or "created asc" */
|
|
1402
|
+
orderBy?: string
|
|
1403
|
+
/** Filter relationships to the specified kinds. If empty, all relationships will be included. This filter is used with the 'related' field on SearchResult. */
|
|
1404
|
+
relatedKinds?: string[]
|
|
1405
|
+
}
|
|
1406
|
+
```
|
|
1407
|
+
|
|
1408
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L44)
|
|
1237
1409
|
|
|
1238
1410
|
### :gear: SearchResult
|
|
1239
1411
|
|
|
@@ -1241,7 +1413,7 @@ This extension allows plugins to customize the route used for resources of the g
|
|
|
1241
1413
|
| ---------- | ---------- |
|
|
1242
1414
|
| `SearchResult` | `R extends (infer T)[] ? Fleet<T>[] : Fleet<R>` |
|
|
1243
1415
|
|
|
1244
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#
|
|
1416
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/search.ts#L83)
|
|
1245
1417
|
|
|
1246
1418
|
|
|
1247
1419
|
<!-- TSDOC_END -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.d.ts","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAGvD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAW9D,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.FleetResourceLink = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
17
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
18
|
+
const useFleetSupport_1 = require("../internal/hooks/useFleetSupport");
|
|
19
|
+
const FleetResourceLink = (_a) => {
|
|
20
|
+
var { cluster } = _a, props = __rest(_a, ["cluster"]);
|
|
21
|
+
const fleetSupport = (0, useFleetSupport_1.useFleetSupport)();
|
|
22
|
+
// not using shouldUseFleetSupport check here so that we always link to pages within "All Clusters" perspective
|
|
23
|
+
if (fleetSupport) {
|
|
24
|
+
const { sdkProvider: { FleetResourceLink }, } = fleetSupport;
|
|
25
|
+
return (0, jsx_runtime_1.jsx)(FleetResourceLink, Object.assign({ cluster: cluster }, props));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceLink, Object.assign({}, props));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.FleetResourceLink = FleetResourceLink;
|
|
32
|
+
//# sourceMappingURL=FleetResourceLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.js","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAAmE;AACnE,8EAAoE;AAEpE,uEAAmE;AAE5D,MAAM,iBAAiB,GAAqC,CAAC,EAAqB,EAAE,EAAE;QAAzB,EAAE,OAAO,OAAY,EAAP,KAAK,cAAnB,WAAqB,CAAF;IACrF,MAAM,YAAY,GAAG,IAAA,iCAAe,GAAE,CAAA;IACtC,+GAA+G;IAC/G,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,EACJ,WAAW,EAAE,EAAE,iBAAiB,EAAE,GACnC,GAAG,YAAY,CAAA;QAChB,OAAO,uBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAI,CAAA;IAC3D,CAAC;SAAM,CAAC;QACN,OAAO,uBAAC,iCAAY,oBAAK,KAAK,EAAI,CAAA;IACpC,CAAC;AACH,CAAC,CAAA;AAXY,QAAA,iBAAiB,qBAW7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetSupport.d.ts","sourceRoot":"","sources":["../../src/api/FleetSupport.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAA;AAGlG,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,CAyBtE,CAAA;AAED,eAAO,MAAM,mBAAmB,eAE/B,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useIsFleetSupported = exports.FleetSupport = void 0;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
15
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
16
|
+
const internal_1 = require("../internal");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const FleetSupportContext_1 = require("../internal/context/FleetSupportContext");
|
|
19
|
+
const FleetSupport = ({ children, loading }) => {
|
|
20
|
+
const [multiclusterSDKs, extensionsResolved] = (0, dynamic_plugin_sdk_1.useResolvedExtensions)(internal_1.isMulticlusterSDK);
|
|
21
|
+
const [hubClusterName, setHubClusterName] = (0, react_1.useState)();
|
|
22
|
+
const sdkProvider = (0, react_1.useMemo)(() => {
|
|
23
|
+
// TODO: Choose best compatible version
|
|
24
|
+
return extensionsResolved && multiclusterSDKs.length ? multiclusterSDKs[0].properties.sdkProvider : undefined;
|
|
25
|
+
}, [extensionsResolved, multiclusterSDKs]);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
function resolveHubClusterName() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (sdkProvider && !hubClusterName) {
|
|
30
|
+
setHubClusterName(yield sdkProvider.fetchHubClusterName());
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
resolveHubClusterName();
|
|
35
|
+
}, [sdkProvider, hubClusterName]);
|
|
36
|
+
const ready = (extensionsResolved && !sdkProvider) || hubClusterName;
|
|
37
|
+
const contextValue = (0, react_1.useMemo)(() => (sdkProvider && hubClusterName ? { sdkProvider, hubClusterName } : undefined), [sdkProvider, hubClusterName]);
|
|
38
|
+
return ready ? (0, jsx_runtime_1.jsx)(FleetSupportContext_1.FleetSupportContext.Provider, { value: contextValue, children: children }) : loading;
|
|
39
|
+
};
|
|
40
|
+
exports.FleetSupport = FleetSupport;
|
|
41
|
+
const useIsFleetSupported = () => {
|
|
42
|
+
return !!(0, react_1.useContext)(FleetSupportContext_1.FleetSupportContext);
|
|
43
|
+
};
|
|
44
|
+
exports.useIsFleetSupported = useIsFleetSupported;
|
|
45
|
+
//# sourceMappingURL=FleetSupport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetSupport.js","sourceRoot":"","sources":["../../src/api/FleetSupport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mEAAmE;AACnE,8EAA6E;AAC7E,0CAA+C;AAC/C,iCAAkG;AAClG,iFAA6E;AAEtE,MAAM,YAAY,GAAkD,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;IACnG,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,IAAA,0CAAqB,EAAC,4BAAiB,CAAC,CAAA;IACvF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAAU,CAAA;IAE9D,MAAM,WAAW,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC/B,uCAAuC;QACvC,OAAO,kBAAkB,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;IAC/G,CAAC,EAAE,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAE1C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAe,qBAAqB;;gBAClC,IAAI,WAAW,IAAI,CAAC,cAAc,EAAE,CAAC;oBACnC,iBAAiB,CAAC,MAAM,WAAW,CAAC,mBAAmB,EAAE,CAAC,CAAA;gBAC5D,CAAC;YACH,CAAC;SAAA;QACD,qBAAqB,EAAE,CAAA;IACzB,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAA;IAEjC,MAAM,KAAK,GAAG,CAAC,kBAAkB,IAAI,CAAC,WAAW,CAAC,IAAI,cAAc,CAAA;IACpE,MAAM,YAAY,GAAG,IAAA,eAAO,EAC1B,GAAG,EAAE,CAAC,CAAC,WAAW,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EACnF,CAAC,WAAW,EAAE,cAAc,CAAC,CAC9B,CAAA;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,uBAAC,yCAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAAgC,CAAC,CAAC,CAAC,OAAO,CAAA;AACvH,CAAC,CAAA;AAzBY,QAAA,YAAY,gBAyBxB;AAEM,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,OAAO,CAAC,CAAC,IAAA,kBAAU,EAAC,yCAAmB,CAAC,CAAA;AAC1C,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { K8sModel, Patch, QueryParams, Selector } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
|
+
export type BaseOptions = {
|
|
3
|
+
name?: string;
|
|
4
|
+
ns?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
cluster?: string;
|
|
7
|
+
queryParams?: QueryParams;
|
|
8
|
+
};
|
|
9
|
+
export type OptionsCreate<R extends K8sResourceCommon> = BaseOptions & {
|
|
10
|
+
model: K8sModel;
|
|
11
|
+
data: R;
|
|
12
|
+
};
|
|
13
|
+
export type OptionsGet = BaseOptions & {
|
|
14
|
+
model: K8sModel;
|
|
15
|
+
requestInit?: RequestInit;
|
|
16
|
+
};
|
|
17
|
+
export type OptionsUpdate<R extends K8sResourceCommon> = BaseOptions & {
|
|
18
|
+
model: K8sModel;
|
|
19
|
+
data: R;
|
|
20
|
+
};
|
|
21
|
+
export type OptionsPatch<R> = BaseOptions & {
|
|
22
|
+
model: K8sModel;
|
|
23
|
+
resource: R;
|
|
24
|
+
data: Patch[];
|
|
25
|
+
};
|
|
26
|
+
export type OptionsDelete<R> = BaseOptions & {
|
|
27
|
+
model: K8sModel;
|
|
28
|
+
resource: R;
|
|
29
|
+
requestInit?: RequestInit;
|
|
30
|
+
json?: Record<string, any>;
|
|
31
|
+
};
|
|
32
|
+
type GetResourceURL = (params: {
|
|
33
|
+
model: K8sModel;
|
|
34
|
+
ns?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
cluster?: string;
|
|
37
|
+
queryParams?: Partial<QueryParams>;
|
|
38
|
+
}) => Promise<string>;
|
|
39
|
+
export type Options = {
|
|
40
|
+
ns?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
queryParams?: Partial<QueryParams>;
|
|
44
|
+
cluster?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const getBackendUrl: () => string;
|
|
47
|
+
export declare const getResourcePath: (model: K8sModel, options: Options) => string;
|
|
48
|
+
export declare const buildResourceURL: (params: {
|
|
49
|
+
model: K8sModel;
|
|
50
|
+
ns?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
cluster?: string;
|
|
53
|
+
queryParams?: Partial<QueryParams>;
|
|
54
|
+
basePath: string;
|
|
55
|
+
}) => string;
|
|
56
|
+
export declare const getResourceURL: GetResourceURL;
|
|
57
|
+
export declare function fleetK8sGet<R extends K8sResourceCommon>(options: OptionsGet): Promise<R>;
|
|
58
|
+
export declare function fleetK8sUpdate<R extends K8sResourceCommon>(options: OptionsUpdate<R>): Promise<R>;
|
|
59
|
+
export declare function fleetK8sPatch<R extends K8sResourceCommon>(options: OptionsPatch<R>): Promise<R>;
|
|
60
|
+
export declare function fleetK8sCreate<R extends K8sResourceCommon>(options: OptionsCreate<R>): Promise<R>;
|
|
61
|
+
export declare function fleetK8sDelete<R extends K8sResourceCommon>(options: OptionsDelete<R>): Promise<R>;
|
|
62
|
+
export declare const fleetWatch: (model: K8sModel, query: {
|
|
63
|
+
labelSelector?: Selector;
|
|
64
|
+
resourceVersion?: string;
|
|
65
|
+
ns?: string;
|
|
66
|
+
fieldSelector?: string;
|
|
67
|
+
cluster?: string;
|
|
68
|
+
} | undefined, backendURL: string) => WebSocket;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=apiRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiRequests.d.ts","sourceRoot":"","sources":["../../src/api/apiRequests.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,QAAQ,EAGR,KAAK,EACL,WAAW,EACX,QAAQ,EACT,MAAM,uCAAuC,CAAA;AAK9C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,iBAAiB,IAAI,WAAW,GAAG;IACrE,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IACrC,KAAK,EAAE,QAAQ,CAAA;IACf,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,iBAAiB,IAAI,WAAW,GAAG;IACrE,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,WAAW,GAAG;IAC1C,KAAK,EAAE,QAAQ,CAAA;IACf,QAAQ,EAAE,CAAC,CAAA;IACX,IAAI,EAAE,KAAK,EAAE,CAAA;CACd,CAAA;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,WAAW,GAAG;IAC3C,KAAK,EAAE,QAAQ,CAAA;IACf,QAAQ,EAAE,CAAC,CAAA;IACX,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,KAAK,cAAc,GAAG,CAAC,MAAM,EAAE;IAC7B,KAAK,EAAE,QAAQ,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;CACnC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;AAErB,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAMD,eAAO,MAAM,aAAa,cAAmD,CAAA;AAmB7E,eAAO,MAAM,eAAe,GAAI,OAAO,QAAQ,EAAE,SAAS,OAAO,KAAG,MAsBnE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,QAAQ;IACvC,KAAK,EAAE,QAAQ,CAAA;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAClC,QAAQ,EAAE,MAAM,CAAA;CACjB,KAAG,MAIH,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,cAG5B,CAAA;AAED,wBAAsB,WAAW,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAU9F;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBvG;AAED,wBAAsB,aAAa,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAyBrG;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAyBvG;AAED,wBAAsB,cAAc,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAwBvG;AAED,eAAO,MAAM,UAAU,GACrB,OAAO,QAAQ,EACf,OAAO;IACL,aAAa,CAAC,EAAE,QAAQ,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,YAAK,EACN,YAAY,MAAM,KACjB,SA4BF,CAAA"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fleetWatch = exports.getResourceURL = exports.buildResourceURL = exports.getResourcePath = exports.getBackendUrl = void 0;
|
|
13
|
+
exports.fleetK8sGet = fleetK8sGet;
|
|
14
|
+
exports.fleetK8sUpdate = fleetK8sUpdate;
|
|
15
|
+
exports.fleetK8sPatch = fleetK8sPatch;
|
|
16
|
+
exports.fleetK8sCreate = fleetK8sCreate;
|
|
17
|
+
exports.fleetK8sDelete = fleetK8sDelete;
|
|
18
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
19
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
20
|
+
const requirements_1 = require("./utils/requirements");
|
|
21
|
+
const constants_1 = require("../internal/constants");
|
|
22
|
+
const getFleetK8sAPIPath_1 = require("./getFleetK8sAPIPath");
|
|
23
|
+
const commonHeaders = {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
};
|
|
26
|
+
const getBackendUrl = () => '/api/proxy/plugin/acm/console/multicloud';
|
|
27
|
+
exports.getBackendUrl = getBackendUrl;
|
|
28
|
+
const getK8sAPIPath = ({ apiGroup = 'core', apiVersion }) => {
|
|
29
|
+
const isLegacy = apiGroup === 'core' && apiVersion === 'v1';
|
|
30
|
+
let p = isLegacy ? '/api/' : '/apis/';
|
|
31
|
+
if (!isLegacy && apiGroup) {
|
|
32
|
+
p += `${apiGroup}/`;
|
|
33
|
+
}
|
|
34
|
+
p += apiVersion;
|
|
35
|
+
return p;
|
|
36
|
+
};
|
|
37
|
+
const excludeEmptyQueryParams = (queryParams) => Object.fromEntries(Object.entries(queryParams || {}).filter(([, value]) => value !== undefined && value !== null && value !== ''));
|
|
38
|
+
const getResourcePath = (model, options) => {
|
|
39
|
+
let url = getK8sAPIPath(model);
|
|
40
|
+
if (options.ns) {
|
|
41
|
+
url += `/namespaces/${options.ns}`;
|
|
42
|
+
}
|
|
43
|
+
url += `/${model.plural}`;
|
|
44
|
+
if (options.name) {
|
|
45
|
+
// Some resources like Users can have special characters in the name.
|
|
46
|
+
url += `/${encodeURIComponent(options.name)}`;
|
|
47
|
+
}
|
|
48
|
+
if (options.path) {
|
|
49
|
+
url += `/${options.path}`;
|
|
50
|
+
}
|
|
51
|
+
const queryParams = excludeEmptyQueryParams(options.queryParams || {});
|
|
52
|
+
if (Object.keys(queryParams).length > 0) {
|
|
53
|
+
const queryString = new URLSearchParams(queryParams).toString();
|
|
54
|
+
url += `?${queryString}`;
|
|
55
|
+
}
|
|
56
|
+
return url;
|
|
57
|
+
};
|
|
58
|
+
exports.getResourcePath = getResourcePath;
|
|
59
|
+
const buildResourceURL = (params) => {
|
|
60
|
+
const { model, ns, name, cluster, queryParams, basePath = constants_1.BASE_K8S_API_PATH } = params;
|
|
61
|
+
const resourcePath = (0, exports.getResourcePath)(model, { ns, name, queryParams, cluster });
|
|
62
|
+
return `${basePath}${resourcePath}`;
|
|
63
|
+
};
|
|
64
|
+
exports.buildResourceURL = buildResourceURL;
|
|
65
|
+
const getResourceURL = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
const basePath = yield (0, getFleetK8sAPIPath_1.getFleetK8sAPIPath)(params === null || params === void 0 ? void 0 : params.cluster);
|
|
67
|
+
return (0, exports.buildResourceURL)(Object.assign(Object.assign({}, params), { basePath }));
|
|
68
|
+
});
|
|
69
|
+
exports.getResourceURL = getResourceURL;
|
|
70
|
+
function fleetK8sGet(options) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const { model, name, ns, cluster } = options;
|
|
73
|
+
if (cluster === undefined) {
|
|
74
|
+
return (0, dynamic_plugin_sdk_1.k8sGet)(options);
|
|
75
|
+
}
|
|
76
|
+
const requestPath = yield (0, exports.getResourceURL)({ model, ns, name, cluster, queryParams: options.queryParams });
|
|
77
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'GET');
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function fleetK8sUpdate(options) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
const { model, name, ns, data } = options;
|
|
84
|
+
const cluster = options.cluster || data.cluster;
|
|
85
|
+
if (cluster === undefined) {
|
|
86
|
+
return (0, dynamic_plugin_sdk_1.k8sUpdate)(options);
|
|
87
|
+
}
|
|
88
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
89
|
+
model,
|
|
90
|
+
ns: ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
91
|
+
name: ((_b = data === null || data === void 0 ? void 0 : data.metadata) === null || _b === void 0 ? void 0 : _b.name) || name,
|
|
92
|
+
cluster: cluster,
|
|
93
|
+
queryParams: options.queryParams,
|
|
94
|
+
});
|
|
95
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'PUT');
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function fleetK8sPatch(options) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
const { resource, model, ns, name } = options !== null && options !== void 0 ? options : {};
|
|
102
|
+
const cluster = options.cluster || resource.cluster;
|
|
103
|
+
if (cluster === undefined) {
|
|
104
|
+
return (0, dynamic_plugin_sdk_1.k8sPatch)(options);
|
|
105
|
+
}
|
|
106
|
+
const headers = {};
|
|
107
|
+
if (Array.isArray(options.data)) {
|
|
108
|
+
headers['Content-Type'] = 'application/json-patch+json';
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
headers['Content-Type'] = 'application/merge-patch+json';
|
|
112
|
+
}
|
|
113
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
114
|
+
model,
|
|
115
|
+
ns: ((_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
116
|
+
name: ((_b = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _b === void 0 ? void 0 : _b.name) || name,
|
|
117
|
+
cluster,
|
|
118
|
+
queryParams: options.queryParams,
|
|
119
|
+
});
|
|
120
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'PATCH', { body: JSON.stringify(options.data), headers });
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function fleetK8sCreate(options) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
var _a;
|
|
126
|
+
const { data, model, ns } = options;
|
|
127
|
+
const cluster = options.cluster || data.cluster;
|
|
128
|
+
if (cluster === undefined) {
|
|
129
|
+
return (0, dynamic_plugin_sdk_1.k8sCreate)(options);
|
|
130
|
+
}
|
|
131
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
132
|
+
model,
|
|
133
|
+
ns: ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
134
|
+
cluster,
|
|
135
|
+
queryParams: options.queryParams,
|
|
136
|
+
});
|
|
137
|
+
const requestData = Object.assign({}, data);
|
|
138
|
+
delete requestData.cluster;
|
|
139
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'POST', {
|
|
140
|
+
body: JSON.stringify(requestData),
|
|
141
|
+
headers: commonHeaders,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function fleetK8sDelete(options) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
const { model, name, ns, json, resource } = options;
|
|
149
|
+
const cluster = (resource === null || resource === void 0 ? void 0 : resource.cluster) || (options === null || options === void 0 ? void 0 : options.cluster);
|
|
150
|
+
if (cluster === undefined) {
|
|
151
|
+
return (0, dynamic_plugin_sdk_1.k8sDelete)(options);
|
|
152
|
+
}
|
|
153
|
+
const { propagationPolicy } = model;
|
|
154
|
+
const jsonData = json !== null && json !== void 0 ? json : (propagationPolicy && { kind: 'DeleteOptions', apiVersion: 'v1', propagationPolicy });
|
|
155
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
156
|
+
model,
|
|
157
|
+
ns: ns || ((_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.namespace),
|
|
158
|
+
name: name || ((_b = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _b === void 0 ? void 0 : _b.name),
|
|
159
|
+
cluster,
|
|
160
|
+
queryParams: options === null || options === void 0 ? void 0 : options.queryParams,
|
|
161
|
+
});
|
|
162
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'DELETE', {
|
|
163
|
+
headers: commonHeaders,
|
|
164
|
+
body: JSON.stringify(jsonData),
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const fleetWatch = (model, query = {}, backendURL) => {
|
|
169
|
+
const queryParams = { watch: 'true' };
|
|
170
|
+
const { labelSelector } = query;
|
|
171
|
+
if (labelSelector) {
|
|
172
|
+
const encodedSelector = (0, requirements_1.selectorToString)(labelSelector);
|
|
173
|
+
if (encodedSelector) {
|
|
174
|
+
queryParams.labelSelector = encodedSelector;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (query.fieldSelector) {
|
|
178
|
+
queryParams.fieldSelector = query.fieldSelector;
|
|
179
|
+
}
|
|
180
|
+
if (query.resourceVersion) {
|
|
181
|
+
queryParams.resourceVersion = query.resourceVersion;
|
|
182
|
+
}
|
|
183
|
+
const requestPath = (0, exports.buildResourceURL)({
|
|
184
|
+
model,
|
|
185
|
+
cluster: query.cluster,
|
|
186
|
+
queryParams,
|
|
187
|
+
ns: query.ns,
|
|
188
|
+
basePath: backendURL,
|
|
189
|
+
});
|
|
190
|
+
return new WebSocket(requestPath);
|
|
191
|
+
};
|
|
192
|
+
exports.fleetWatch = fleetWatch;
|
|
193
|
+
//# sourceMappingURL=apiRequests.js.map
|