@camunda/ccma-saas-frontend 0.35.3 → 0.35.5

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.
Files changed (33) hide show
  1. package/lib/esm/runtime/c4-console-data-store.js +3 -2
  2. package/lib/esm/runtime/use-cli-actions-api.d.ts +18 -0
  3. package/lib/esm/runtime/use-cli-actions-api.js +58 -0
  4. package/lib/esm/runtime/use-cli-cluster-api.d.ts +38 -0
  5. package/lib/esm/runtime/use-cli-cluster-api.js +53 -0
  6. package/lib/esm/runtime/use-cli-extras-api.d.ts +34 -0
  7. package/lib/esm/runtime/use-cli-extras-api.js +165 -0
  8. package/lib/esm/runtime/use-cli-org-api.d.ts +28 -0
  9. package/lib/esm/runtime/use-cli-org-api.js +87 -0
  10. package/lib/esm/runtime/use-cli-resources-api.d.ts +53 -0
  11. package/lib/esm/runtime/use-cli-resources-api.js +273 -0
  12. package/lib/esm/runtime/use-console-cli-api.d.ts +3 -3
  13. package/lib/esm/runtime/use-console-cli-api.js +3 -3
  14. package/lib/esm/widgets/cluster-client-details/c4-cluster-client-details-app.js +33 -13
  15. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +31 -13
  16. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-byom-clients-tab.js +8 -6
  17. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-clients-tab.js +13 -13
  18. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.js +31 -18
  19. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-encryption-tab.js +4 -2
  20. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +7 -6
  21. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.js +4 -3
  22. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +15 -16
  23. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-secure-connectivity-tab.js +8 -6
  24. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +49 -38
  25. package/lib/esm/widgets/clusters/c4-clusters-page.js +14 -12
  26. package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +5 -2
  27. package/lib/esm/widgets/dashboard/c4-dashboard-app.js +5 -2
  28. package/lib/esm/widgets/environment/use-cluster-api-clients.js +4 -3
  29. package/lib/esm/widgets/job-worker/c4-job-worker-details-page.js +5 -3
  30. package/lib/esm/widgets/job-worker/c4-job-worker-overview-page.js +5 -3
  31. package/lib/esm/widgets/job-worker/c4-job-worker.helpers.d.ts +1 -1
  32. package/lib/esm/widgets/management/c4-management-app.js +16 -31
  33. package/package.json +3 -3
@@ -3,10 +3,11 @@
3
3
  * under one or more contributor license agreements. Licensed under a commercial license.
4
4
  * You may not use this file except in compliance with the commercial license.
5
5
  */
6
- import { AuditLoggerService, ConsoleApiClientsService, ConsoleClusterService, EarlyAccessFeaturesService, ExternalAccountsService, ExternalConsoleService, GenerationService, HdpService, HttpError, OrganizationMembersService, OrgsService, } from '@camunda/ccma-api';
6
+ import { AuditLoggerService, ConsoleClusterService, EarlyAccessFeaturesService, ExternalAccountsService, ExternalConsoleService, GenerationService, HdpService, HttpError, OrganizationMembersService, OrgsService, } from '@camunda/ccma-api';
7
7
  import { SseEntity, SseType, } from '@camunda/ccma-shared-types';
8
8
  import { flow, types } from 'mobx-state-tree';
9
9
  import { toApiConfig } from './to-api-config.js';
10
+ import { cliOrgApi, isConsoleCliApiOn } from './use-cli-org-api.js';
10
11
  function isRecord(value) {
11
12
  return typeof value === 'object' && value !== null;
12
13
  }
@@ -776,7 +777,7 @@ export const ConsoleDataStore = types
776
777
  });
777
778
  try {
778
779
  const apiConfig = toApiConfig(self.runtime);
779
- const clientsList = yield ConsoleApiClientsService.getAll({
780
+ const clientsList = yield cliOrgApi(isConsoleCliApiOn(self.runtime)).listApiClients({
780
781
  params: { orgId },
781
782
  config: apiConfig,
782
783
  });
@@ -0,0 +1,18 @@
1
+ import type { CreateConsoleClusterRequest, CreateConsoleClusterResponse, DeleteConsoleClusterRequest, DeleteExternalIdpRequest, DuplicateConsoleClusterRequest, DuplicateConsoleClusterResponse, FailoverConsoleClusterRequest, FailoverConsoleClusterResult, SuspendConsoleClusterRequest, UpdateExternalIdpSecretRequest, WakeConsoleClusterRequest } from '@camunda/ccma-api';
2
+ /**
3
+ * The cluster actions of c4: create, duplicate, delete, suspend, wake,
4
+ * failover and the OIDC provider. They go to the `/cli/v1` routes while
5
+ * `useConsoleCliApi` is on, else to the internal routes. Each function takes
6
+ * and returns the shapes of `ConsoleClusterService`. Part of #11623: delete it
7
+ * with the flag.
8
+ */
9
+ export declare const useCliActionsApi: () => {
10
+ createCluster: (request: CreateConsoleClusterRequest) => Promise<CreateConsoleClusterResponse>;
11
+ duplicateCluster: (request: DuplicateConsoleClusterRequest) => Promise<DuplicateConsoleClusterResponse>;
12
+ deleteCluster: (request: DeleteConsoleClusterRequest) => Promise<void>;
13
+ suspendCluster: (request: SuspendConsoleClusterRequest) => Promise<void>;
14
+ wakeCluster: (request: WakeConsoleClusterRequest) => Promise<void>;
15
+ failoverCluster: (request: FailoverConsoleClusterRequest) => Promise<FailoverConsoleClusterResult>;
16
+ updateExternalIdpSecret: (request: UpdateExternalIdpSecretRequest) => Promise<void>;
17
+ deleteExternalIdp: (request: DeleteExternalIdpRequest) => Promise<void>;
18
+ };
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ import { ConsoleCliActionsService, ConsoleClusterService, } from '@camunda/ccma-api';
7
+ import { useMemo } from 'react';
8
+ import { useConsoleCliApi } from './use-console-cli-api.js';
9
+ /**
10
+ * `/cli/v1` names the region `regionId`, the internal routes `k8sContextId`.
11
+ */
12
+ const toCliBody = ({ k8sContextId, ...body }) => ({ ...body, regionId: k8sContextId });
13
+ /**
14
+ * The cluster actions of c4: create, duplicate, delete, suspend, wake,
15
+ * failover and the OIDC provider. They go to the `/cli/v1` routes while
16
+ * `useConsoleCliApi` is on, else to the internal routes. Each function takes
17
+ * and returns the shapes of `ConsoleClusterService`. Part of #11623: delete it
18
+ * with the flag.
19
+ */
20
+ export const useCliActionsApi = () => {
21
+ const cliApi = useConsoleCliApi();
22
+ return useMemo(() => ({
23
+ createCluster: async (request) => {
24
+ if (!cliApi) {
25
+ return ConsoleClusterService.createCluster(request);
26
+ }
27
+ const { id } = await ConsoleCliActionsService.createCluster({
28
+ ...request,
29
+ body: toCliBody(request.body),
30
+ });
31
+ return { clusterId: id };
32
+ },
33
+ duplicateCluster: (request) => cliApi
34
+ ? ConsoleCliActionsService.duplicateCluster({
35
+ ...request,
36
+ body: toCliBody(request.body),
37
+ })
38
+ : ConsoleClusterService.duplicateCluster(request),
39
+ deleteCluster: (request) => cliApi
40
+ ? ConsoleCliActionsService.deleteCluster(request)
41
+ : ConsoleClusterService.deleteCluster(request),
42
+ suspendCluster: (request) => cliApi
43
+ ? ConsoleCliActionsService.suspendCluster(request)
44
+ : ConsoleClusterService.suspendCluster(request),
45
+ wakeCluster: (request) => cliApi
46
+ ? ConsoleCliActionsService.wakeCluster(request)
47
+ : ConsoleClusterService.wakeCluster(request),
48
+ failoverCluster: (request) => cliApi
49
+ ? ConsoleCliActionsService.failoverCluster(request)
50
+ : ConsoleClusterService.failoverCluster(request),
51
+ updateExternalIdpSecret: (request) => cliApi
52
+ ? ConsoleCliActionsService.setExternalIdpSecret(request)
53
+ : ConsoleClusterService.updateExternalIdpSecret(request),
54
+ deleteExternalIdp: (request) => cliApi
55
+ ? ConsoleCliActionsService.deleteExternalIdp(request)
56
+ : ConsoleClusterService.deleteExternalIdp(request),
57
+ }), [cliApi]);
58
+ };
@@ -0,0 +1,38 @@
1
+ import type { ConsoleCliCluster, RequestBaseParamsConfig, UpdateClusterRequest } from '@camunda/ccma-api';
2
+ import type { ConsoleClusterDto } from '@camunda/ccma-shared-types';
3
+ interface ClusterRequest {
4
+ config: RequestBaseParamsConfig;
5
+ params: {
6
+ orgId: string;
7
+ clusterId: string;
8
+ };
9
+ }
10
+ /**
11
+ * The fields of a cluster that the job worker pages and the client details
12
+ * page read. Both routes give them.
13
+ */
14
+ export type C4ClusterBasics = Pick<ConsoleClusterDto, 'uuid' | 'name' | 'status'> & {
15
+ generation?: {
16
+ uuid: string;
17
+ name: string;
18
+ versions?: {
19
+ zeebe?: string;
20
+ };
21
+ };
22
+ };
23
+ /** Maps the `/cli/v1` cluster to the field names of the internal route. */
24
+ export declare const toC4ClusterBasics: (cluster: ConsoleCliCluster) => C4ClusterBasics;
25
+ /**
26
+ * The cluster read and the cluster settings change. They go to the `/cli/v1`
27
+ * routes while `useConsoleCliApi` is on, else to the internal routes (#11623).
28
+ * Delete it with the flag.
29
+ */
30
+ export declare const useCliClusterApi: () => {
31
+ getClusterBasics: (request: ClusterRequest) => Promise<C4ClusterBasics>;
32
+ /**
33
+ * Changes the settings in `body`. Both routes take the same names and
34
+ * run the same checks.
35
+ */
36
+ updateCluster: (request: UpdateClusterRequest) => Promise<void>;
37
+ };
38
+ export {};
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ import { ConsoleCliClusterService, ConsoleClusterService, } from '@camunda/ccma-api';
7
+ import { useMemo } from 'react';
8
+ import { useConsoleCliApi } from './use-console-cli-api.js';
9
+ /** Maps the `/cli/v1` cluster to the field names of the internal route. */
10
+ export const toC4ClusterBasics = (cluster) => ({
11
+ uuid: cluster.id,
12
+ name: cluster.name,
13
+ status: {
14
+ ready: cluster.statusDetail ?? '',
15
+ zeebeUrl: cluster.urls.zeebeGrpc,
16
+ zeebeRestUrl: cluster.urls.zeebeRest,
17
+ operateUrl: cluster.urls.operate,
18
+ tasklistUrl: cluster.urls.tasklist,
19
+ optimizeUrl: cluster.urls.optimize,
20
+ connectorsUrl: cluster.urls.connectors,
21
+ identityUrl: cluster.urls.identity,
22
+ },
23
+ generation: {
24
+ uuid: cluster.generation.id,
25
+ name: cluster.generation.name,
26
+ versions: cluster.generation.versions,
27
+ },
28
+ });
29
+ /**
30
+ * The cluster read and the cluster settings change. They go to the `/cli/v1`
31
+ * routes while `useConsoleCliApi` is on, else to the internal routes (#11623).
32
+ * Delete it with the flag.
33
+ */
34
+ export const useCliClusterApi = () => {
35
+ const cliApi = useConsoleCliApi();
36
+ return useMemo(() => ({
37
+ getClusterBasics: async (request) => cliApi
38
+ ? toC4ClusterBasics(await ConsoleCliClusterService.getCluster(request))
39
+ : ConsoleClusterService.getCluster(request),
40
+ /**
41
+ * Changes the settings in `body`. Both routes take the same names and
42
+ * run the same checks.
43
+ */
44
+ updateCluster: async (request) => {
45
+ if (cliApi) {
46
+ await ConsoleCliClusterService.updateCluster(request);
47
+ }
48
+ else {
49
+ await ConsoleClusterService.updateCluster(request);
50
+ }
51
+ },
52
+ }), [cliApi]);
53
+ };
@@ -0,0 +1,34 @@
1
+ import type { ActivateConsoleByomMonitoringParams, ActivateSecureConnectivityParams, CreateConsoleByomMonitoringClientParams, DeactivateConsoleByomMonitoringParams, DeactivateSecureConnectivityParams, DeleteConsoleByomMonitoringClientParams, GetConsoleByomMonitoringClientsParams, GetSecureConnectivityStatusParams, GetValueMetricsPerDayParams, RotateConsoleByomMonitoringClientPasswordParams, UpdateSecureConnectivityParams } from '@camunda/ccma-api';
2
+ import type { ByomClientDto, ByomStatus, ClusterUsageMetricsData, SecureConnectivityDto } from '@camunda/ccma-shared-types';
3
+ /** A BYOM client of either API. The `/cli/v1` route leaves out unset fields. */
4
+ export type MonitoringClient = Omit<ByomClientDto, 'created' | 'createdBy' | 'lastUsed'> & Partial<Pick<ByomClientDto, 'created' | 'createdBy' | 'lastUsed'>>;
5
+ export interface MonitoringClients {
6
+ status: ByomStatus | Record<string, never>;
7
+ clients: MonitoringClient[];
8
+ }
9
+ export type MonitoringClientWithPassword = MonitoringClient & {
10
+ password: string;
11
+ };
12
+ /**
13
+ * The secure connectivity, external monitoring (BYOM) and value metrics calls
14
+ * of c4. They go to the `/cli/v1` routes while `useConsoleCliApi` is on, else
15
+ * to the internal routes. Each call gives the same shape on both paths. Part
16
+ * of #11623: delete it with the flag.
17
+ */
18
+ export declare const useCliExtrasApi: () => {
19
+ /** Gives `undefined` when the cluster has no secure connectivity. */
20
+ getSecureConnectivityStatus: (request: GetSecureConnectivityStatusParams) => Promise<SecureConnectivityDto | undefined>;
21
+ activateSecureConnectivity: (request: ActivateSecureConnectivityParams) => Promise<void>;
22
+ updateSecureConnectivity: (request: UpdateSecureConnectivityParams) => Promise<void>;
23
+ deactivateSecureConnectivity: (request: DeactivateSecureConnectivityParams) => Promise<void>;
24
+ getMonitoringClients: (request: GetConsoleByomMonitoringClientsParams) => Promise<MonitoringClients>;
25
+ activateMonitoring: (request: ActivateConsoleByomMonitoringParams) => Promise<void>;
26
+ deactivateMonitoring: (request: DeactivateConsoleByomMonitoringParams) => Promise<void>;
27
+ createMonitoringClient: (request: CreateConsoleByomMonitoringClientParams) => Promise<MonitoringClientWithPassword>;
28
+ rotateMonitoringClientPassword: (request: RotateConsoleByomMonitoringClientPasswordParams) => Promise<MonitoringClientWithPassword>;
29
+ deleteMonitoringClient: (request: DeleteConsoleByomMonitoringClientParams) => Promise<void>;
30
+ /** Per cluster and month. `params.days` is not read. */
31
+ getValueMetrics: (request: GetValueMetricsPerDayParams) => Promise<ClusterUsageMetricsData[]>;
32
+ /** Per cluster and day, for the last `params.days` days. */
33
+ getValueMetricsPerDays: (request: GetValueMetricsPerDayParams) => Promise<ClusterUsageMetricsData[]>;
34
+ };
@@ -0,0 +1,165 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ import { ConsoleByomMonitoringService, ConsoleCliExtrasService, ConsoleSecureConnectivityService, ConsoleValueMetricsService, } from '@camunda/ccma-api';
7
+ import { useMemo } from 'react';
8
+ import { useConsoleCliApi } from './use-console-cli-api.js';
9
+ const toDate = (value) => value ? new Date(value) : undefined;
10
+ const toMonitoringClient = (client) => ({
11
+ uuid: client.id,
12
+ username: client.username,
13
+ created: toDate(client.createdAt),
14
+ lastUsed: toDate(client.lastUsedAt),
15
+ createdBy: client.createdBy,
16
+ createdByName: client.createdBy,
17
+ });
18
+ // The `/cli/v1` shape has no metadata, urls or observed generations. c4 does
19
+ // not read them.
20
+ const toSecureConnectivityDto = (status, { orgId, clusterId }) => ({
21
+ metadata: { namespace: '', labels: { orgId }, name: clusterId },
22
+ spec: {
23
+ cluster: { id: clusterId },
24
+ allowedRegions: status.allowedRegions,
25
+ allowedPrincipals: status.allowedPrincipals,
26
+ },
27
+ status: {
28
+ conditions: status.conditions.map((condition) => ({
29
+ type: condition.type,
30
+ status: condition.status,
31
+ reason: condition.reason ?? '',
32
+ message: condition.message ?? '',
33
+ observedGeneration: 0,
34
+ lastTransitionTime: condition.lastTransitionTime ?? '',
35
+ })),
36
+ endpoint: {
37
+ region: status.endpoint?.region ?? '',
38
+ serviceName: status.endpoint?.serviceName ?? '',
39
+ type: status.endpoint?.type ?? '',
40
+ privateDnsName: status.endpoint?.privateDnsName ?? '',
41
+ },
42
+ endpointConnectionCount: status.endpointConnectionCount ?? 0,
43
+ endpointConnections: status.endpointConnections.map((connection) => ({
44
+ creationTimestamp: connection.createdAt ?? '',
45
+ endpointId: connection.endpointId,
46
+ owner: connection.owner ?? '',
47
+ serviceId: '',
48
+ state: connection.state,
49
+ })),
50
+ observedGeneration: 0,
51
+ urls: {},
52
+ },
53
+ });
54
+ const toValueMetric = (orgId) => (metric) => ({
55
+ ...metric,
56
+ orgId,
57
+ startDate: new Date(metric.startDate),
58
+ });
59
+ /**
60
+ * The secure connectivity, external monitoring (BYOM) and value metrics calls
61
+ * of c4. They go to the `/cli/v1` routes while `useConsoleCliApi` is on, else
62
+ * to the internal routes. Each call gives the same shape on both paths. Part
63
+ * of #11623: delete it with the flag.
64
+ */
65
+ export const useCliExtrasApi = () => {
66
+ const cliApi = useConsoleCliApi();
67
+ return useMemo(() => ({
68
+ /** Gives `undefined` when the cluster has no secure connectivity. */
69
+ getSecureConnectivityStatus: async (request) => {
70
+ if (!cliApi) {
71
+ return ((await ConsoleSecureConnectivityService.getStatus(request)) ??
72
+ undefined);
73
+ }
74
+ const status = await ConsoleCliExtrasService.getSecureConnectivity(request);
75
+ return status.active
76
+ ? toSecureConnectivityDto(status, request.params)
77
+ : undefined;
78
+ },
79
+ activateSecureConnectivity: (request) => cliApi
80
+ ? ConsoleCliExtrasService.activateSecureConnectivity(request)
81
+ : ConsoleSecureConnectivityService.activate(request),
82
+ updateSecureConnectivity: (request) => cliApi
83
+ ? ConsoleCliExtrasService.setSecureConnectivity(request)
84
+ : ConsoleSecureConnectivityService.update(request),
85
+ deactivateSecureConnectivity: (request) => cliApi
86
+ ? ConsoleCliExtrasService.deactivateSecureConnectivity(request)
87
+ : ConsoleSecureConnectivityService.deactivate(request),
88
+ getMonitoringClients: async (request) => {
89
+ if (!cliApi) {
90
+ return ConsoleByomMonitoringService.getMonitoringClients(request);
91
+ }
92
+ const monitoring = await ConsoleCliExtrasService.getMonitoring(request);
93
+ return {
94
+ // The internal route sends the conditions with no endpoint too (the
95
+ // endpoint is missing while the monitoring is starting or down).
96
+ status: monitoring.active
97
+ ? {
98
+ metricsEndpoint: monitoring.metricsEndpoint,
99
+ conditions: monitoring.conditions,
100
+ }
101
+ : {},
102
+ clients: monitoring.clients.map(toMonitoringClient),
103
+ };
104
+ },
105
+ activateMonitoring: (request) => cliApi
106
+ ? ConsoleCliExtrasService.activateMonitoring(request)
107
+ : ConsoleByomMonitoringService.activateMonitoring(request),
108
+ deactivateMonitoring: (request) => cliApi
109
+ ? ConsoleCliExtrasService.deactivateMonitoring(request)
110
+ : ConsoleByomMonitoringService.deactivateMonitoring(request),
111
+ createMonitoringClient: async (request) => {
112
+ if (!cliApi) {
113
+ return ConsoleByomMonitoringService.createMonitoringClient(request);
114
+ }
115
+ const created = await ConsoleCliExtrasService.createMonitoringClient(request);
116
+ return { ...toMonitoringClient(created), password: created.password };
117
+ },
118
+ rotateMonitoringClientPassword: async (request) => {
119
+ if (!cliApi) {
120
+ return ConsoleByomMonitoringService.rotateMonitoringClientPassword(request);
121
+ }
122
+ const { clientUuid, ...params } = request.params;
123
+ const rotated = await ConsoleCliExtrasService.rotateMonitoringClientPassword({
124
+ ...request,
125
+ params: { ...params, clientId: clientUuid },
126
+ });
127
+ return { ...toMonitoringClient(rotated), password: rotated.password };
128
+ },
129
+ deleteMonitoringClient: (request) => {
130
+ if (!cliApi) {
131
+ return ConsoleByomMonitoringService.deleteMonitoringClient(request);
132
+ }
133
+ const { clientUuid, ...params } = request.params;
134
+ return ConsoleCliExtrasService.deleteMonitoringClient({
135
+ ...request,
136
+ params: { ...params, clientId: clientUuid },
137
+ });
138
+ },
139
+ /** Per cluster and month. `params.days` is not read. */
140
+ getValueMetrics: async (request) => {
141
+ if (!cliApi) {
142
+ return ConsoleValueMetricsService.getValueMetrics(request);
143
+ }
144
+ const { orgId } = request.params;
145
+ const metrics = await ConsoleCliExtrasService.getValueMetrics({
146
+ ...request,
147
+ params: { orgId },
148
+ });
149
+ return metrics.map(toValueMetric(orgId));
150
+ },
151
+ /** Per cluster and day, for the last `params.days` days. */
152
+ getValueMetricsPerDays: async (request) => {
153
+ if (!cliApi) {
154
+ return ConsoleValueMetricsService.getValueMetricsPerDays(request);
155
+ }
156
+ const { orgId, days } = request.params;
157
+ const metrics = await ConsoleCliExtrasService.getDailyValueMetrics({
158
+ ...request,
159
+ params: { orgId },
160
+ days,
161
+ });
162
+ return metrics.map(toValueMetric(orgId));
163
+ },
164
+ }), [cliApi]);
165
+ };
@@ -0,0 +1,28 @@
1
+ import type { ConsoleApiClientDto, CreateConsoleApiClientResponse, RequestBaseParamsConfig } from '@camunda/ccma-api';
2
+ import type { C4ConsoleRuntimeConfig } from './c4-console-runtime.types.js';
3
+ interface OrgRequest {
4
+ config: RequestBaseParamsConfig;
5
+ params: {
6
+ orgId: string;
7
+ };
8
+ }
9
+ /**
10
+ * The API client calls of an org. They go to the `/cli/v1` routes when
11
+ * `cliApi` is on, else to the internal routes. Both give the shapes of the
12
+ * internal routes. Part of #11623: delete it with the flag.
13
+ */
14
+ export declare const cliOrgApi: (cliApi: boolean) => {
15
+ listApiClients: (request: OrgRequest) => Promise<ConsoleApiClientDto[]>;
16
+ createApiClient: (request: OrgRequest, name: string, permissions: string[]) => Promise<CreateConsoleApiClientResponse>;
17
+ updateApiClient: (request: OrgRequest, clientUuid: string, name: string) => Promise<void>;
18
+ deleteApiClient: (request: OrgRequest, clientUuid: string) => Promise<void>;
19
+ };
20
+ /** `useConsoleCliApi` for code outside React, such as the data store. */
21
+ export declare const isConsoleCliApiOn: (runtime: C4ConsoleRuntimeConfig | undefined) => boolean;
22
+ export declare const useCliOrgApi: () => {
23
+ listApiClients: (request: OrgRequest) => Promise<ConsoleApiClientDto[]>;
24
+ createApiClient: (request: OrgRequest, name: string, permissions: string[]) => Promise<CreateConsoleApiClientResponse>;
25
+ updateApiClient: (request: OrgRequest, clientUuid: string, name: string) => Promise<void>;
26
+ deleteApiClient: (request: OrgRequest, clientUuid: string) => Promise<void>;
27
+ };
28
+ export {};
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ import { ConsoleApiClientsService, ConsoleCliOrgService, } from '@camunda/ccma-api';
7
+ import { useMemo } from 'react';
8
+ import { CLI_API_GATE_FLAG, CONSOLE_CLI_API_FLAG, useConsoleCliApi, } from './use-console-cli-api.js';
9
+ const toDto = (orgId, client) => ({
10
+ uuid: client.id,
11
+ clientId: client.clientId,
12
+ name: client.name,
13
+ organizationUuid: orgId,
14
+ permissions: client.permissions,
15
+ created: client.createdAt ?? '',
16
+ lastUsed: client.lastUsedAt,
17
+ createdBy: client.createdBy,
18
+ });
19
+ /**
20
+ * The API client calls of an org. They go to the `/cli/v1` routes when
21
+ * `cliApi` is on, else to the internal routes. Both give the shapes of the
22
+ * internal routes. Part of #11623: delete it with the flag.
23
+ */
24
+ export const cliOrgApi = (cliApi) => ({
25
+ listApiClients: async (request) => {
26
+ if (!cliApi) {
27
+ return ConsoleApiClientsService.getAll(request);
28
+ }
29
+ const clients = await ConsoleCliOrgService.listApiClients(request);
30
+ return clients.map((client) => toDto(request.params.orgId, client));
31
+ },
32
+ createApiClient: async (request, name, permissions) => {
33
+ if (!cliApi) {
34
+ return ConsoleApiClientsService.create({
35
+ ...request,
36
+ params: { ...request.params, clientName: name, permissions },
37
+ });
38
+ }
39
+ const created = await ConsoleCliOrgService.createApiClient({
40
+ ...request,
41
+ body: { name, permissions },
42
+ });
43
+ return {
44
+ uuid: created.id,
45
+ clientId: created.clientId,
46
+ clientSecret: created.secret,
47
+ };
48
+ },
49
+ updateApiClient: async (request, clientUuid, name) => {
50
+ if (cliApi) {
51
+ await ConsoleCliOrgService.updateApiClient({
52
+ ...request,
53
+ params: { ...request.params, clientId: clientUuid },
54
+ body: { name },
55
+ });
56
+ }
57
+ else {
58
+ await ConsoleApiClientsService.update({
59
+ ...request,
60
+ params: { ...request.params, clientUuid, clientName: name },
61
+ });
62
+ }
63
+ },
64
+ deleteApiClient: async (request, clientUuid) => {
65
+ if (cliApi) {
66
+ await ConsoleCliOrgService.deleteApiClient({
67
+ ...request,
68
+ params: { ...request.params, clientId: clientUuid },
69
+ });
70
+ }
71
+ else {
72
+ await ConsoleApiClientsService.delete({
73
+ ...request,
74
+ params: { ...request.params, clientUuid },
75
+ });
76
+ }
77
+ },
78
+ });
79
+ /** `useConsoleCliApi` for code outside React, such as the data store. */
80
+ export const isConsoleCliApiOn = (runtime) => {
81
+ const isEnabled = runtime?.featureFlags?.isEnabled;
82
+ return Boolean(isEnabled?.(CONSOLE_CLI_API_FLAG) && isEnabled(CLI_API_GATE_FLAG));
83
+ };
84
+ export const useCliOrgApi = () => {
85
+ const cliApi = useConsoleCliApi();
86
+ return useMemo(() => cliOrgApi(cliApi), [cliApi]);
87
+ };
@@ -0,0 +1,53 @@
1
+ import type { ConsoleClusterClientDto, CreateConsoleAlertParams, CreateConsoleClusterClientParams, CreateConsoleClusterClientResponse, CreateConsoleHotBackupParams, DeleteConsoleAlertParams, DeleteConsoleClusterClientParams, DeleteConsoleConnectorSecretParams, DeleteConsoleHotBackupParams, GetConsoleAlertsParams, GetConsoleClusterClientsParams, GetConsoleConnectorSecretsParams, GetConsoleHotBackupsParams, PutConsoleConnectorSecretParams, RestoreConsoleHotBackupParams, RotateConsoleClusterClientSecretParams, RotateConsoleClusterClientSecretResponse, UpdateConsoleAlertParams, UpdateConsoleClusterClientParams } from '@camunda/ccma-api';
2
+ import type { AlertSubscriptionDto, BackupDto, RestoreDto } from '@camunda/ccma-shared-types';
3
+ /**
4
+ * A secret create found the name on the cluster. The widget turns it into
5
+ * its own text, from `secretName`.
6
+ */
7
+ export declare class SecretExistsError extends Error {
8
+ readonly secretName: string;
9
+ constructor(secretName: string);
10
+ }
11
+ /**
12
+ * The alert, client, connector secret and hot backup calls of a cluster. They
13
+ * go to the `/cli/v1` routes while `useConsoleCliApi` is on, else to the
14
+ * internal routes. Each function takes the parameters of the old service and
15
+ * gives its answer, so a call site only changes the function it calls. Delete
16
+ * it with the flag (#11623).
17
+ */
18
+ export declare const useCliResourcesApi: () => {
19
+ alerts: {
20
+ getAll: (request: GetConsoleAlertsParams) => Promise<AlertSubscriptionDto[]>;
21
+ create: (request: CreateConsoleAlertParams) => Promise<void>;
22
+ update: (request: UpdateConsoleAlertParams) => Promise<void>;
23
+ delete: (request: DeleteConsoleAlertParams) => Promise<void>;
24
+ };
25
+ clients: {
26
+ getAll: (request: GetConsoleClusterClientsParams) => Promise<ConsoleClusterClientDto[]>;
27
+ create: (request: CreateConsoleClusterClientParams) => Promise<CreateConsoleClusterClientResponse>;
28
+ update: (request: UpdateConsoleClusterClientParams, clientId: string) => Promise<void>;
29
+ rotateSecret: (request: RotateConsoleClusterClientSecretParams, clientId: string) => Promise<RotateConsoleClusterClientSecretResponse>;
30
+ delete: (request: DeleteConsoleClusterClientParams) => Promise<void>;
31
+ };
32
+ secrets: {
33
+ /**
34
+ * Name to value. With the CLI routes and `withValues` false, each
35
+ * value is empty: give `withValues` only to a user who can create or
36
+ * update a secret, else the route answers 403.
37
+ */
38
+ getAll: (request: GetConsoleConnectorSecretsParams, { withValues }: {
39
+ withValues: boolean;
40
+ }) => Promise<Record<string, string>>;
41
+ create: (request: PutConsoleConnectorSecretParams, { knownNames }?: {
42
+ knownNames?: ReadonlySet<string>;
43
+ }) => Promise<void>;
44
+ update: (request: PutConsoleConnectorSecretParams) => Promise<void>;
45
+ delete: (request: DeleteConsoleConnectorSecretParams) => Promise<void>;
46
+ };
47
+ backups: {
48
+ getHotBackups: (request: GetConsoleHotBackupsParams) => Promise<BackupDto[]>;
49
+ createHotBackup: (request: CreateConsoleHotBackupParams) => Promise<BackupDto>;
50
+ deleteHotBackup: (request: DeleteConsoleHotBackupParams) => Promise<void>;
51
+ restoreHotBackup: (request: RestoreConsoleHotBackupParams) => Promise<RestoreDto>;
52
+ };
53
+ };