@camunda/ccma-saas-frontend 0.35.4 → 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 +2 -2
@@ -0,0 +1,273 @@
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 { ConsoleAlertsService, ConsoleCliResourcesService, ConsoleClusterClientsService, ConsoleConnectorSecretsService, ConsoleHotBackupsService, } from '@camunda/ccma-api';
7
+ import { useMemo } from 'react';
8
+ import { useConsoleCliApi } from './use-console-cli-api.js';
9
+ const cluster = ({ config, params }) => ({
10
+ config,
11
+ params: { orgId: params.orgId, clusterId: params.clusterId },
12
+ });
13
+ const toBackupDto = (backup) => {
14
+ const status = backup.status;
15
+ return {
16
+ uuid: backup.id,
17
+ name: backup.name,
18
+ created: backup.createdAt ?? '',
19
+ completed: backup.completedAt ?? '',
20
+ status,
21
+ zeebeStatus: backup.zeebeStatus ?? status,
22
+ operateStatus: backup.operateStatus ?? status,
23
+ tasklistStatus: backup.tasklistStatus ?? status,
24
+ optimizeStatus: backup.optimizeStatus ?? status,
25
+ generationUuid: backup.generationId,
26
+ generationName: backup.generation,
27
+ };
28
+ };
29
+ /**
30
+ * A secret create found the name on the cluster. The widget turns it into
31
+ * its own text, from `secretName`.
32
+ */
33
+ export class SecretExistsError extends Error {
34
+ secretName;
35
+ constructor(secretName) {
36
+ super(`A secret named ${secretName} exists already`);
37
+ this.name = 'SecretExistsError';
38
+ this.secretName = secretName;
39
+ }
40
+ }
41
+ /**
42
+ * The alert, client, connector secret and hot backup calls of a cluster. They
43
+ * go to the `/cli/v1` routes while `useConsoleCliApi` is on, else to the
44
+ * internal routes. Each function takes the parameters of the old service and
45
+ * gives its answer, so a call site only changes the function it calls. Delete
46
+ * it with the flag (#11623).
47
+ */
48
+ export const useCliResourcesApi = () => {
49
+ const cliApi = useConsoleCliApi();
50
+ return useMemo(() => ({
51
+ alerts: {
52
+ getAll: async (request) => {
53
+ if (!cliApi)
54
+ return ConsoleAlertsService.getAll(request);
55
+ const alerts = await ConsoleCliResourcesService.listAlerts(cluster(request));
56
+ return alerts.map((alert) => ({
57
+ uuid: alert.id,
58
+ userIdOrWebhook: alert.webhookUrl ?? alert.email ?? '',
59
+ type: alert.type,
60
+ report: alert.report,
61
+ // The list never gives the secret. Callers only test if it is set.
62
+ webhookAuth: alert.hmac ? { hmac: { secret: '' } } : undefined,
63
+ createdBy: alert.createdBy ?? '',
64
+ createdByName: alert.createdBy ?? '',
65
+ created: new Date(alert.createdAt ?? ''),
66
+ updatedBy: alert.updatedBy ?? '',
67
+ updatedByName: alert.updatedBy ?? '',
68
+ updated: new Date(alert.updatedAt ?? ''),
69
+ lastTimeTriggered: alert.lastTriggeredAt
70
+ ? new Date(alert.lastTriggeredAt)
71
+ : undefined,
72
+ numberOfTimesTriggered: alert.triggerCount ?? 0,
73
+ recepientEmail: alert.email,
74
+ }));
75
+ },
76
+ create: async (request) => {
77
+ if (!cliApi) {
78
+ await ConsoleAlertsService.create(request);
79
+ return;
80
+ }
81
+ const { body } = request;
82
+ await ConsoleCliResourcesService.createAlert({
83
+ ...cluster(request),
84
+ body: {
85
+ type: body.alertType,
86
+ report: body.reportType,
87
+ webhookUrl: body.webhookUrl,
88
+ hmacSecret: body.webhookAuth?.hmac?.secret,
89
+ ignoreHead: body.ignoreHead,
90
+ },
91
+ });
92
+ },
93
+ // `webhookAuth: null` removes the HMAC secret, `undefined` keeps it.
94
+ update: async (request) => {
95
+ if (!cliApi)
96
+ return ConsoleAlertsService.update(request);
97
+ const { body } = request;
98
+ await ConsoleCliResourcesService.updateAlert({
99
+ ...cluster(request),
100
+ alertId: request.params.alertUuid,
101
+ body: {
102
+ type: body.alertType,
103
+ report: body.reportType,
104
+ webhookUrl: body.webhookUrl,
105
+ hmacSecret: body.webhookAuth?.hmac?.secret,
106
+ removeHmac: body.webhookAuth === null ? true : undefined,
107
+ },
108
+ });
109
+ },
110
+ delete: async (request) => {
111
+ if (!cliApi)
112
+ return ConsoleAlertsService.delete(request);
113
+ await ConsoleCliResourcesService.deleteAlert({
114
+ ...cluster(request),
115
+ alertId: request.params.alertUuid,
116
+ });
117
+ },
118
+ },
119
+ clients: {
120
+ getAll: async (request) => {
121
+ if (!cliApi)
122
+ return ConsoleClusterClientsService.getAll(request);
123
+ const clients = await ConsoleCliResourcesService.listClients(cluster(request));
124
+ return clients.map((client) => ({
125
+ uuid: client.uuid ?? client.id,
126
+ clientId: client.id,
127
+ name: client.name,
128
+ permissions: client.permissions,
129
+ created: client.createdAt,
130
+ lastUsed: client.lastUsedAt,
131
+ createdBy: client.createdBy,
132
+ createdByName: client.createdBy,
133
+ }));
134
+ },
135
+ create: async (request) => {
136
+ if (!cliApi)
137
+ return ConsoleClusterClientsService.create(request);
138
+ const client = await ConsoleCliResourcesService.createClient({
139
+ ...cluster(request),
140
+ body: {
141
+ name: request.body.clientName,
142
+ permissions: request.body.permissions,
143
+ },
144
+ });
145
+ return {
146
+ uuid: client.uuid ?? client.id,
147
+ clientId: client.id,
148
+ clientSecret: client.secret,
149
+ };
150
+ },
151
+ // The CLI route finds the client by its public `clientId`.
152
+ update: async (request, clientId) => {
153
+ if (!cliApi)
154
+ return ConsoleClusterClientsService.update(request);
155
+ await ConsoleCliResourcesService.updateClient({
156
+ ...cluster(request),
157
+ clientId,
158
+ name: request.body.clientName,
159
+ });
160
+ },
161
+ rotateSecret: async (request, clientId) => {
162
+ if (!cliApi)
163
+ return ConsoleClusterClientsService.rotateSecret(request);
164
+ const client = await ConsoleCliResourcesService.rotateClientSecret({
165
+ ...cluster(request),
166
+ clientId,
167
+ });
168
+ return {
169
+ uuid: client.uuid ?? request.params.clientUuid,
170
+ clientId: client.id,
171
+ clientSecret: client.secret,
172
+ };
173
+ },
174
+ delete: async (request) => {
175
+ if (!cliApi)
176
+ return ConsoleClusterClientsService.delete(request);
177
+ await ConsoleCliResourcesService.deleteClient({
178
+ ...cluster(request),
179
+ clientId: request.params.clientId,
180
+ });
181
+ },
182
+ },
183
+ secrets: {
184
+ /**
185
+ * Name to value. With the CLI routes and `withValues` false, each
186
+ * value is empty: give `withValues` only to a user who can create or
187
+ * update a secret, else the route answers 403.
188
+ */
189
+ getAll: async (request, { withValues }) => {
190
+ if (!cliApi)
191
+ return ConsoleConnectorSecretsService.getAll(request);
192
+ const secrets = await ConsoleCliResourcesService.listSecrets({
193
+ ...cluster(request),
194
+ withValues,
195
+ });
196
+ return Object.fromEntries(secrets.map((secret) => [secret.name, secret.value ?? '']));
197
+ },
198
+ // The CLI route overwrites a secret that exists. The internal route
199
+ // answers 409, so look for the name first: no silent overwrite. A loop
200
+ // that creates many secrets passes the names that it knows, so that
201
+ // each create does not list the secrets again.
202
+ create: async (request, { knownNames } = {}) => {
203
+ if (!cliApi)
204
+ return ConsoleConnectorSecretsService.create(request);
205
+ const names = knownNames ??
206
+ new Set((await ConsoleCliResourcesService.listSecrets({
207
+ ...cluster(request),
208
+ withValues: false,
209
+ })).map((secret) => secret.name));
210
+ if (names.has(request.body.secretName)) {
211
+ throw new SecretExistsError(request.body.secretName);
212
+ }
213
+ await ConsoleCliResourcesService.setSecret({
214
+ ...cluster(request),
215
+ name: request.body.secretName,
216
+ value: request.body.secretValue,
217
+ });
218
+ },
219
+ // The CLI route also makes a secret that does not exist.
220
+ update: async (request) => {
221
+ if (!cliApi)
222
+ return ConsoleConnectorSecretsService.update(request);
223
+ await ConsoleCliResourcesService.setSecret({
224
+ ...cluster(request),
225
+ name: request.body.secretName,
226
+ value: request.body.secretValue,
227
+ });
228
+ },
229
+ delete: async (request) => {
230
+ if (!cliApi)
231
+ return ConsoleConnectorSecretsService.delete(request);
232
+ await ConsoleCliResourcesService.deleteSecret({
233
+ ...cluster(request),
234
+ name: request.params.secretName,
235
+ });
236
+ },
237
+ },
238
+ backups: {
239
+ getHotBackups: async (request) => {
240
+ if (!cliApi)
241
+ return ConsoleHotBackupsService.getHotBackups(request);
242
+ const backups = await ConsoleCliResourcesService.listBackups(cluster(request));
243
+ return backups.map(toBackupDto);
244
+ },
245
+ createHotBackup: async (request) => {
246
+ if (!cliApi)
247
+ return ConsoleHotBackupsService.createHotBackup(request);
248
+ return toBackupDto(await ConsoleCliResourcesService.createBackup(cluster(request)));
249
+ },
250
+ deleteHotBackup: async (request) => {
251
+ if (!cliApi)
252
+ return ConsoleHotBackupsService.deleteHotBackup(request);
253
+ await ConsoleCliResourcesService.deleteBackup({
254
+ ...cluster(request),
255
+ backupId: request.params.backupId,
256
+ });
257
+ },
258
+ restoreHotBackup: async (request) => {
259
+ if (!cliApi)
260
+ return ConsoleHotBackupsService.restoreHotBackup(request);
261
+ const restore = await ConsoleCliResourcesService.restoreBackup({
262
+ ...cluster(request),
263
+ backupId: request.params.backupId,
264
+ });
265
+ return {
266
+ uuid: restore.id,
267
+ backupId: restore.backupId,
268
+ state: restore.state,
269
+ };
270
+ },
271
+ },
272
+ }), [cliApi]);
273
+ };
@@ -2,13 +2,13 @@ export declare const CONSOLE_CLI_API_FLAG = "console.c4CliApi";
2
2
  export declare const CLI_API_GATE_FLAG = "shared.cliApi";
3
3
  /**
4
4
  * Whether c4 calls the `/cli/v1` routes of console-backend (the customer API
5
- * of c8cloud) in place of the internal `/api/orgs/...` routes. A pilot of
6
- * #11623: only the backup schedule and the IP allowlist move.
5
+ * of c8cloud) in place of the internal `/api/orgs/...` routes, for everything
6
+ * that a customer CLI can use (#11623).
7
7
  *
8
8
  * Both flags must be on. The routes answer 404 while `shared.cliApi` is off.
9
9
  * The backend reads that flag with no user, but c4 reads it for the user and
10
10
  * the org. So `shared.cliApi` must be enabled for all (no org or email list)
11
- * while the pilot runs: else c4 can send calls that get a 404. When the move
11
+ * while the move runs: else c4 can send calls that get a 404. When the move
12
12
  * is done or stopped, delete this hook, the branch at each call site and
13
13
  * the flag rows.
14
14
  */
@@ -8,13 +8,13 @@ export const CONSOLE_CLI_API_FLAG = 'console.c4CliApi';
8
8
  export const CLI_API_GATE_FLAG = 'shared.cliApi';
9
9
  /**
10
10
  * Whether c4 calls the `/cli/v1` routes of console-backend (the customer API
11
- * of c8cloud) in place of the internal `/api/orgs/...` routes. A pilot of
12
- * #11623: only the backup schedule and the IP allowlist move.
11
+ * of c8cloud) in place of the internal `/api/orgs/...` routes, for everything
12
+ * that a customer CLI can use (#11623).
13
13
  *
14
14
  * Both flags must be on. The routes answer 404 while `shared.cliApi` is off.
15
15
  * The backend reads that flag with no user, but c4 reads it for the user and
16
16
  * the org. So `shared.cliApi` must be enabled for all (no org or email list)
17
- * while the pilot runs: else c4 can send calls that get a 404. When the move
17
+ * while the move runs: else c4 can send calls that get a 404. When the move
18
18
  * is done or stopped, delete this hook, the branch at each call site and
19
19
  * the flag rows.
20
20
  */
@@ -1,5 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { ConsoleClusterClientsService, ConsoleClusterService, } from '@camunda/ccma-api';
3
2
  import { checkVersion, IDENTITY_MANAGEMENT_MIN_VERSION, REST_API_URL_TRANSFORM_MIN_VERSION, REST_API_V2_MIN_VERSION, VersionCheckOperator, ZEEBE_REST_URL_MIN_VERSION, } from '@camunda/ccma-shared-types';
4
3
  import { observer } from 'mobx-react-lite';
5
4
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -10,6 +9,8 @@ import { getC4ClusterClientDetailsDocsUrl } from '../../externalUrls.const.js';
10
9
  import { useC4ConsoleAuthz } from '../../runtime/c4-console-authz.js';
11
10
  import { useC4ConsoleRuntime } from '../../runtime/c4-console-runtime-context.js';
12
11
  import { toApiConfig } from '../../runtime/to-api-config.js';
12
+ import { useCliClusterApi, } from '../../runtime/use-cli-cluster-api.js';
13
+ import { useCliResourcesApi } from '../../runtime/use-cli-resources-api.js';
13
14
  import { BreadcrumbSkeleton, CodeSnippet, Link, Modal, Stack, TextInput, } from '../../ui/index.js';
14
15
  import { safeTranslate } from '../../utils/safe-translate.js';
15
16
  function joinUrl(baseUrl, path) {
@@ -67,8 +68,10 @@ function validateClientName(opts) {
67
68
  }
68
69
  export const C4ClusterClientDetailsApp = observer((props) => {
69
70
  const runtime = useC4ConsoleRuntime();
71
+ const clusterApi = useCliClusterApi();
70
72
  const t = runtime.i18n?.t;
71
73
  const apiConfig = useMemo(() => toApiConfig(runtime), [runtime]);
74
+ const resourcesApi = useCliResourcesApi();
72
75
  const authz = useC4ConsoleAuthz({ orgId: props.orgId });
73
76
  const canMutateCluster = Boolean(authz.visibilities.clusters?.canEdit);
74
77
  // The rotate route asks for `cluster.clients.create`, the permission of a
@@ -91,7 +94,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
91
94
  setClusterLoading(true);
92
95
  setClusterError('');
93
96
  try {
94
- const loaded = await ConsoleClusterService.getCluster({
97
+ const loaded = await clusterApi.getClusterBasics({
95
98
  config: apiConfig,
96
99
  params: { orgId: props.orgId, clusterId: props.clusterId },
97
100
  });
@@ -105,7 +108,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
105
108
  finally {
106
109
  setClusterLoading(false);
107
110
  }
108
- }, [apiConfig, props.clusterId, props.orgId, t]);
111
+ }, [apiConfig, clusterApi, props.clusterId, props.orgId, t]);
109
112
  const loadClients = useCallback(async () => {
110
113
  if (!props.orgId || !props.clusterId) {
111
114
  setClients([]);
@@ -115,7 +118,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
115
118
  setClientsLoading(true);
116
119
  setClientsError('');
117
120
  try {
118
- const loaded = await ConsoleClusterClientsService.getAll({
121
+ const loaded = await resourcesApi.clients.getAll({
119
122
  config: apiConfig,
120
123
  params: { orgId: props.orgId, clusterId: props.clusterId },
121
124
  });
@@ -129,7 +132,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
129
132
  finally {
130
133
  setClientsLoading(false);
131
134
  }
132
- }, [apiConfig, props.clusterId, props.orgId, t]);
135
+ }, [apiConfig, props.clusterId, props.orgId, resourcesApi, t]);
133
136
  useEffect(() => {
134
137
  void loadCluster();
135
138
  void loadClients();
@@ -411,7 +414,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
411
414
  setMutationBusy(true);
412
415
  setMutationError('');
413
416
  try {
414
- await ConsoleClusterClientsService.update({
417
+ await resourcesApi.clients.update({
415
418
  config: apiConfig,
416
419
  params: {
417
420
  orgId: props.orgId,
@@ -419,7 +422,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
419
422
  clientId: client.uuid,
420
423
  },
421
424
  body: { clientName: clientName.trim() },
422
- });
425
+ }, client.clientId);
423
426
  await loadClients();
424
427
  setRenameOpen(false);
425
428
  }
@@ -430,7 +433,16 @@ export const C4ClusterClientDetailsApp = observer((props) => {
430
433
  finally {
431
434
  setMutationBusy(false);
432
435
  }
433
- }, [apiConfig, client, clientName, clients, loadClients, props, t]);
436
+ }, [
437
+ apiConfig,
438
+ client,
439
+ clientName,
440
+ clients,
441
+ loadClients,
442
+ props,
443
+ resourcesApi,
444
+ t,
445
+ ]);
434
446
  const onSubmitRotate = useCallback(async () => {
435
447
  if (!client) {
436
448
  return;
@@ -438,14 +450,14 @@ export const C4ClusterClientDetailsApp = observer((props) => {
438
450
  setMutationBusy(true);
439
451
  setMutationError('');
440
452
  try {
441
- const response = await ConsoleClusterClientsService.rotateSecret({
453
+ const response = await resourcesApi.clients.rotateSecret({
442
454
  config: apiConfig,
443
455
  params: {
444
456
  orgId: props.orgId,
445
457
  clusterId: props.clusterId,
446
458
  clientUuid: client.uuid,
447
459
  },
448
- });
460
+ }, client.clientId);
449
461
  setRotateOpen(false);
450
462
  // Console shows the secret one time. The customer reads it from the
451
463
  // modal that opens now.
@@ -464,7 +476,15 @@ export const C4ClusterClientDetailsApp = observer((props) => {
464
476
  finally {
465
477
  setMutationBusy(false);
466
478
  }
467
- }, [apiConfig, client, loadClients, props.clusterId, props.orgId, t]);
479
+ }, [
480
+ apiConfig,
481
+ client,
482
+ loadClients,
483
+ props.clusterId,
484
+ props.orgId,
485
+ resourcesApi,
486
+ t,
487
+ ]);
468
488
  const onSubmitDelete = useCallback(async () => {
469
489
  if (!client) {
470
490
  return;
@@ -472,7 +492,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
472
492
  setMutationBusy(true);
473
493
  setMutationError('');
474
494
  try {
475
- await ConsoleClusterClientsService.delete({
495
+ await resourcesApi.clients.delete({
476
496
  config: apiConfig,
477
497
  params: {
478
498
  orgId: props.orgId,
@@ -496,7 +516,7 @@ export const C4ClusterClientDetailsApp = observer((props) => {
496
516
  finally {
497
517
  setMutationBusy(false);
498
518
  }
499
- }, [apiConfig, client, loadClients, props, t]);
519
+ }, [apiConfig, client, loadClients, props, resourcesApi, t]);
500
520
  // -----------------------------
501
521
  // Render
502
522
  // -----------------------------
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
4
4
  * under one or more contributor license agreements. Licensed under a commercial license.
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
- import { AuditLoggerService, ConsoleAlertsService, ConsoleByomMonitoringService, ConsoleClusterParametersService, ConsoleClusterService, GenerationService, HdpService, HttpError, SaaSJobsService, } from '@camunda/ccma-api';
7
+ import { AuditLoggerService, ConsoleClusterParametersService, ConsoleClusterService, GenerationService, HdpService, HttpError, SaaSJobsService, } from '@camunda/ccma-api';
8
8
  import { AUDIT_LOG_TAB_MIN_VERSION, CLUSTER_STATISTICS_CONFIG_MIN_VERSION, checkVersion, deriveEncryptionKeyStatus, deriveEncryptionStatus, deriveSecondaryStorageStatus, needsKeyOwnerAction, SalesPlanType, SseEntity, VersionCheckOperator, } from '@camunda/ccma-shared-types';
9
9
  import { observer } from 'mobx-react-lite';
10
10
  import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
@@ -18,6 +18,10 @@ import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console
18
18
  import { CLUSTER_CREATION_BLOCKED_FLAG } from '../../runtime/cluster-creation-blocked.js';
19
19
  import { SELF_MANAGED_MIGRATION_FLAG } from '../../runtime/self-managed-migration.js';
20
20
  import { toApiConfig } from '../../runtime/to-api-config.js';
21
+ import { useCliActionsApi } from '../../runtime/use-cli-actions-api.js';
22
+ import { useCliClusterApi } from '../../runtime/use-cli-cluster-api.js';
23
+ import { useCliExtrasApi } from '../../runtime/use-cli-extras-api.js';
24
+ import { useCliResourcesApi } from '../../runtime/use-cli-resources-api.js';
21
25
  import { Modal, Stack, TextInput } from '../../ui/index.js';
22
26
  import { isMigrationLocked, } from '../../utils/migration-view.js';
23
27
  import { buildBackupChoiceUpdate, buildReopenTransferUpdate, buildTransferFinishedUpdate, getMigrationView, isMigrationPlan, MIGRATION_NAME_MAX_LENGTH, } from '../../utils/migration-workaround.js';
@@ -305,12 +309,16 @@ function isUnsupportedGenerationStarted(isUnsupportedStarting) {
305
309
  }
306
310
  export const C4ClusterDetailsApp = observer((props) => {
307
311
  const runtime = useC4ConsoleRuntime();
312
+ const clusterActions = useCliActionsApi();
313
+ const clusterApi = useCliClusterApi();
314
+ const cliExtras = useCliExtrasApi();
308
315
  const clusterCreationBlocked = useC4FeatureFlag(CLUSTER_CREATION_BLOCKED_FLAG);
309
316
  const upgradeReadinessGateEnabled = useC4FeatureFlag('console.upgradeReadinessGate');
310
317
  const data = useC4ConsoleData();
311
318
  const t = runtime.i18n?.t;
312
319
  const urls = useMemo(() => getC4ClusterDetailsUrls(props.urls), [props.urls]);
313
320
  const apiConfig = useMemo(() => toApiConfig(runtime), [runtime]);
321
+ const resourcesApi = useCliResourcesApi();
314
322
  const authz = useC4ConsoleAuthz({ orgId: props.orgId });
315
323
  const orgPermissions = authz.orgPermissions;
316
324
  // Tab visibilities (legacy console-frontend drives these via `orgPermissions`).
@@ -672,7 +680,7 @@ export const C4ClusterDetailsApp = observer((props) => {
672
680
  setClusterMutationBusy(true);
673
681
  setClusterMutationError('');
674
682
  try {
675
- await ConsoleClusterService.updateCluster({
683
+ await clusterApi.updateCluster({
676
684
  config: apiConfig,
677
685
  params: { orgId: props.orgId, clusterId: props.clusterId },
678
686
  body: build(migrationView, clusterLabels),
@@ -687,6 +695,7 @@ export const C4ClusterDetailsApp = observer((props) => {
687
695
  }
688
696
  }, [
689
697
  apiConfig,
698
+ clusterApi,
690
699
  props.orgId,
691
700
  props.clusterId,
692
701
  migrationView,
@@ -709,7 +718,7 @@ export const C4ClusterDetailsApp = observer((props) => {
709
718
  setClusterMutationBusy(true);
710
719
  setClusterMutationError('');
711
720
  try {
712
- await ConsoleClusterService.updateCluster({
721
+ await clusterApi.updateCluster({
713
722
  config: apiConfig,
714
723
  params: { orgId: props.orgId, clusterId: props.clusterId },
715
724
  body: { name: newClusterName },
@@ -728,7 +737,7 @@ export const C4ClusterDetailsApp = observer((props) => {
728
737
  setClusterMutationBusy(true);
729
738
  setClusterMutationError('');
730
739
  try {
731
- await ConsoleClusterService.deleteCluster({
740
+ await clusterActions.deleteCluster({
732
741
  config: apiConfig,
733
742
  params: { orgId: props.orgId, clusterId: props.clusterId },
734
743
  });
@@ -775,7 +784,7 @@ export const C4ClusterDetailsApp = observer((props) => {
775
784
  setAlertsLoading(true);
776
785
  try {
777
786
  const [loaded] = await Promise.all([
778
- ConsoleAlertsService.getAll({
787
+ resourcesApi.alerts.getAll({
779
788
  config: apiConfig,
780
789
  params: { orgId: props.orgId, clusterId: props.clusterId },
781
790
  }),
@@ -814,6 +823,7 @@ export const C4ClusterDetailsApp = observer((props) => {
814
823
  apiConfig,
815
824
  canViewAlertsTab,
816
825
  data,
826
+ resourcesApi,
817
827
  props.clusterId,
818
828
  props.orgId,
819
829
  resolveAlertTarget,
@@ -1011,7 +1021,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1011
1021
  setByomLoading(true);
1012
1022
  setByomError(false);
1013
1023
  try {
1014
- const response = await ConsoleByomMonitoringService.getMonitoringClients({
1024
+ const response = await cliExtras.getMonitoringClients({
1015
1025
  config: apiConfig,
1016
1026
  params: { orgId: props.orgId, clusterId: props.clusterId },
1017
1027
  });
@@ -1033,7 +1043,13 @@ export const C4ClusterDetailsApp = observer((props) => {
1033
1043
  byomLoadedRef.current = true;
1034
1044
  setByomLoading(false);
1035
1045
  }
1036
- }, [apiConfig, canViewMonitoringTab, props.clusterId, props.orgId]);
1046
+ }, [
1047
+ apiConfig,
1048
+ canViewMonitoringTab,
1049
+ cliExtras,
1050
+ props.clusterId,
1051
+ props.orgId,
1052
+ ]);
1037
1053
  // When CLUSTER SSE events arrive, the ConsoleDataStore patches the cached
1038
1054
  // cluster list from the SSE payload. Re-sync local cluster state from that
1039
1055
  // cache without refetching.
@@ -1230,7 +1246,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1230
1246
  ]);
1231
1247
  const alertsComponent = useMemo(() => {
1232
1248
  return (_jsx(C4ClusterDetailsAlertsTab, { alerts: alerts, isLoading: alertsLoading, canMutateCluster: canMutateClusterApiResources, docsAlertsUrl: urls.docs.alerts, userEmail: runtime.user?.email, t: t ?? ((key) => key), renderInlineStrong: renderInlineStrong, renderInlineLink0: renderInlineLink0, onNavigate: props.onNavigate, onCreateAlert: async (params) => {
1233
- await ConsoleAlertsService.create({
1249
+ await resourcesApi.alerts.create({
1234
1250
  config: apiConfig,
1235
1251
  params: { orgId: props.orgId, clusterId: props.clusterId },
1236
1252
  body: {
@@ -1249,7 +1265,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1249
1265
  });
1250
1266
  await reloadAlerts();
1251
1267
  }, onUpdateAlert: async (params) => {
1252
- await ConsoleAlertsService.update({
1268
+ await resourcesApi.alerts.update({
1253
1269
  config: apiConfig,
1254
1270
  params: {
1255
1271
  orgId: props.orgId,
@@ -1273,7 +1289,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1273
1289
  });
1274
1290
  await reloadAlerts();
1275
1291
  }, onDeleteAlert: async (alertId) => {
1276
- await ConsoleAlertsService.delete({
1292
+ await resourcesApi.alerts.delete({
1277
1293
  config: apiConfig,
1278
1294
  params: {
1279
1295
  orgId: props.orgId,
@@ -1294,6 +1310,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1294
1310
  t,
1295
1311
  apiConfig,
1296
1312
  reloadAlerts,
1313
+ resourcesApi,
1297
1314
  urls.docs.alerts,
1298
1315
  ]);
1299
1316
  const activityComponent = useMemo(() => {
@@ -1383,7 +1400,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1383
1400
  .filter((v) => typeof v === 'string')
1384
1401
  .filter(isAuditLogCategory);
1385
1402
  return (_jsx(C4ClusterDetailsAuditLogTab, { enabled: enabled, userCategories: userCategories, clientCategories: clientCategories, canMutateCluster: canMutateCluster, learnMoreUrl: urls.docs.auditlogs, onUpdate: async (nextUser, nextClient) => {
1386
- await ConsoleClusterService.updateCluster({
1403
+ await clusterApi.updateCluster({
1387
1404
  config: apiConfig,
1388
1405
  params: { orgId: props.orgId, clusterId: props.clusterId },
1389
1406
  body: {
@@ -1394,14 +1411,14 @@ export const C4ClusterDetailsApp = observer((props) => {
1394
1411
  });
1395
1412
  await reloadCluster();
1396
1413
  }, onEnable: async () => {
1397
- await ConsoleClusterService.updateCluster({
1414
+ await clusterApi.updateCluster({
1398
1415
  config: apiConfig,
1399
1416
  params: { orgId: props.orgId, clusterId: props.clusterId },
1400
1417
  body: { auditLogEnabled: true },
1401
1418
  });
1402
1419
  await reloadCluster();
1403
1420
  }, onDisable: async () => {
1404
- await ConsoleClusterService.updateCluster({
1421
+ await clusterApi.updateCluster({
1405
1422
  config: apiConfig,
1406
1423
  params: { orgId: props.orgId, clusterId: props.clusterId },
1407
1424
  body: { auditLogEnabled: false },
@@ -1411,6 +1428,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1411
1428
  }, [
1412
1429
  apiConfig,
1413
1430
  canMutateCluster,
1431
+ clusterApi,
1414
1432
  cluster?.externalMetadata?.auditLog,
1415
1433
  props.clusterId,
1416
1434
  props.orgId,