@camunda/ccma-api 12.0.0 → 12.2.0

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 (28) hide show
  1. package/dist/index.d.ts +7 -0
  2. package/dist/index.js +22 -0
  3. package/dist/index.js.map +2 -2
  4. package/dist/services/console/console.cli.actions.service.d.ts +47 -0
  5. package/dist/services/console/console.cli.actions.service.js +115 -0
  6. package/dist/services/console/console.cli.actions.service.js.map +7 -0
  7. package/dist/services/console/console.cli.actions.service.spec.d.ts +1 -0
  8. package/dist/services/console/console.cli.cluster.service.d.ts +94 -0
  9. package/dist/services/console/console.cli.cluster.service.js +53 -0
  10. package/dist/services/console/console.cli.cluster.service.js.map +7 -0
  11. package/dist/services/console/console.cli.cluster.service.spec.d.ts +1 -0
  12. package/dist/services/console/console.cli.extras.service.d.ts +119 -0
  13. package/dist/services/console/console.cli.extras.service.js +169 -0
  14. package/dist/services/console/console.cli.extras.service.js.map +7 -0
  15. package/dist/services/console/console.cli.extras.service.spec.d.ts +1 -0
  16. package/dist/services/console/console.cli.org.service.d.ts +53 -0
  17. package/dist/services/console/console.cli.org.service.js +60 -0
  18. package/dist/services/console/console.cli.org.service.js.map +7 -0
  19. package/dist/services/console/console.cli.org.service.spec.d.ts +1 -0
  20. package/dist/services/console/console.cli.resources.service.d.ts +136 -0
  21. package/dist/services/console/console.cli.resources.service.js +218 -0
  22. package/dist/services/console/console.cli.resources.service.js.map +7 -0
  23. package/dist/services/console/console.cli.resources.service.spec.d.ts +1 -0
  24. package/dist/services/control/control.leaflets.service.d.ts +44 -0
  25. package/dist/services/control/control.leaflets.service.js +95 -0
  26. package/dist/services/control/control.leaflets.service.js.map +7 -0
  27. package/dist/services/control/control.leaflets.service.spec.d.ts +1 -0
  28. package/package.json +2 -2
@@ -0,0 +1,218 @@
1
+ import { request } from "../../utils/api.js";
2
+ import { HttpError } from "../../utils/errors.js";
3
+ class ConsoleCliResourcesService {
4
+ /**
5
+ * `path` is the template with `:name` parts, `values` fills them. Only the
6
+ * template goes to the logs and metrics: it holds no ids.
7
+ */
8
+ static async call(params, name, type, path, options = {}) {
9
+ const { orgId, clusterId } = params.params;
10
+ const template = `cli/v1/orgs/:orgId/clusters/:clusterId/${path}`;
11
+ const realPath = path.replace(
12
+ /:(\w+)/gu,
13
+ (_match, key) => encodeURIComponent(options.values?.[key] ?? "")
14
+ );
15
+ const serviceContext = {
16
+ method: {
17
+ name: `ConsoleCliResourcesService.${name}`,
18
+ url: template,
19
+ normalizedUrl: template,
20
+ type
21
+ },
22
+ source: params.config.metrics?.source || "unset",
23
+ target: { name: "console", type: "internal" }
24
+ };
25
+ const response = await request({
26
+ ...params,
27
+ base: { id: "console" },
28
+ url: `cli/v1/orgs/${encodeURIComponent(orgId)}/clusters/${encodeURIComponent(clusterId)}/${realPath}${options.query ?? ""}`,
29
+ logUrl: template,
30
+ method: type,
31
+ metricsDetails: serviceContext,
32
+ body: options.body,
33
+ redactBody: options.redactBody,
34
+ // A 204 gives `{}`.
35
+ responseType: "json"
36
+ });
37
+ if (!response.ok || response.body === void 0) {
38
+ throw new HttpError(
39
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
40
+ response.status,
41
+ response.statusText
42
+ );
43
+ }
44
+ return response.body;
45
+ }
46
+ /** Values only with `withValues`: that needs the right to change secrets. */
47
+ static listSecrets(params) {
48
+ return ConsoleCliResourcesService.call(
49
+ params,
50
+ "listSecrets",
51
+ "get",
52
+ "secrets",
53
+ {
54
+ query: params.withValues ? "?withValues=true" : void 0
55
+ }
56
+ );
57
+ }
58
+ /** Creates the secret, or changes it if it exists. */
59
+ static async setSecret(params) {
60
+ await ConsoleCliResourcesService.call(
61
+ params,
62
+ "setSecret",
63
+ "put",
64
+ "secrets/:name",
65
+ {
66
+ values: { name: params.name },
67
+ body: { value: params.value },
68
+ redactBody: true
69
+ }
70
+ );
71
+ }
72
+ static async deleteSecret(params) {
73
+ await ConsoleCliResourcesService.call(
74
+ params,
75
+ "deleteSecret",
76
+ "delete",
77
+ "secrets/:name",
78
+ {
79
+ values: { name: params.name }
80
+ }
81
+ );
82
+ }
83
+ static listAlerts(params) {
84
+ return ConsoleCliResourcesService.call(
85
+ params,
86
+ "listAlerts",
87
+ "get",
88
+ "alerts"
89
+ );
90
+ }
91
+ static createAlert(params) {
92
+ return ConsoleCliResourcesService.call(
93
+ params,
94
+ "createAlert",
95
+ "post",
96
+ "alerts",
97
+ {
98
+ body: params.body
99
+ }
100
+ );
101
+ }
102
+ static updateAlert(params) {
103
+ return ConsoleCliResourcesService.call(
104
+ params,
105
+ "updateAlert",
106
+ "patch",
107
+ "alerts/:alertId",
108
+ {
109
+ values: { alertId: params.alertId },
110
+ body: params.body
111
+ }
112
+ );
113
+ }
114
+ static async deleteAlert(params) {
115
+ await ConsoleCliResourcesService.call(
116
+ params,
117
+ "deleteAlert",
118
+ "delete",
119
+ "alerts/:alertId",
120
+ {
121
+ values: { alertId: params.alertId }
122
+ }
123
+ );
124
+ }
125
+ static listClients(params) {
126
+ return ConsoleCliResourcesService.call(
127
+ params,
128
+ "listClients",
129
+ "get",
130
+ "clients"
131
+ );
132
+ }
133
+ /** The answer holds the secret. It is the only time that it is shown. */
134
+ static createClient(params) {
135
+ return ConsoleCliResourcesService.call(
136
+ params,
137
+ "createClient",
138
+ "post",
139
+ "clients",
140
+ {
141
+ body: params.body
142
+ }
143
+ );
144
+ }
145
+ static updateClient(params) {
146
+ return ConsoleCliResourcesService.call(
147
+ params,
148
+ "updateClient",
149
+ "patch",
150
+ "clients/:clientId",
151
+ {
152
+ values: { clientId: params.clientId },
153
+ body: { name: params.name }
154
+ }
155
+ );
156
+ }
157
+ /** The answer holds the new secret. It is the only time that it is shown. */
158
+ static rotateClientSecret(params) {
159
+ return ConsoleCliResourcesService.call(
160
+ params,
161
+ "rotateClientSecret",
162
+ "post",
163
+ "clients/:clientId/rotate-secret",
164
+ { values: { clientId: params.clientId } }
165
+ );
166
+ }
167
+ static async deleteClient(params) {
168
+ await ConsoleCliResourcesService.call(
169
+ params,
170
+ "deleteClient",
171
+ "delete",
172
+ "clients/:clientId",
173
+ {
174
+ values: { clientId: params.clientId }
175
+ }
176
+ );
177
+ }
178
+ static listBackups(params) {
179
+ return ConsoleCliResourcesService.call(
180
+ params,
181
+ "listBackups",
182
+ "get",
183
+ "backups"
184
+ );
185
+ }
186
+ static createBackup(params) {
187
+ return ConsoleCliResourcesService.call(
188
+ params,
189
+ "createBackup",
190
+ "post",
191
+ "backups"
192
+ );
193
+ }
194
+ static async deleteBackup(params) {
195
+ await ConsoleCliResourcesService.call(
196
+ params,
197
+ "deleteBackup",
198
+ "delete",
199
+ "backups/:backupId",
200
+ {
201
+ values: { backupId: params.backupId }
202
+ }
203
+ );
204
+ }
205
+ static restoreBackup(params) {
206
+ return ConsoleCliResourcesService.call(
207
+ params,
208
+ "restoreBackup",
209
+ "post",
210
+ "backups/:backupId/restore",
211
+ { values: { backupId: params.backupId } }
212
+ );
213
+ }
214
+ }
215
+ export {
216
+ ConsoleCliResourcesService
217
+ };
218
+ //# sourceMappingURL=console.cli.resources.service.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/console/console.cli.resources.service.ts"],
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport type {\n RequestBaseMethodType,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\nimport type { ConsoleCliClusterParams } from './console.cli.service.js'\n\n/** The shapes of `packages/shared-route-schemas/src/console/cli*.ts`. */\nexport interface ConsoleCliSecret {\n name: string\n /** Set only when the list was read with `withValues`. */\n value?: string\n}\n\nexport interface ConsoleCliAlert {\n id: string\n type: string\n report: 'Email' | 'Webhook'\n webhookUrl?: string\n email?: string\n createdAt?: string\n createdBy?: string\n updatedAt?: string\n updatedBy?: string\n lastTriggeredAt?: string\n triggerCount?: number\n /** True if webhook calls are signed. The secret is never shown. */\n hmac?: boolean\n}\n\nexport interface ConsoleCliCreateAlert {\n type: string\n report: 'Email' | 'Webhook'\n webhookUrl?: string\n hmacSecret?: string\n ignoreHead?: boolean\n}\n\n/** A missing field keeps its value. */\nexport interface ConsoleCliUpdateAlert {\n type?: string\n report?: 'Email' | 'Webhook'\n webhookUrl?: string\n hmacSecret?: string\n removeHmac?: boolean\n}\n\nexport interface ConsoleCliClient {\n /** The `clientId`. */\n id: string\n uuid?: string\n name: string\n permissions: string[]\n createdAt?: string\n createdBy?: string\n lastUsedAt?: string\n}\n\nexport interface ConsoleCliCreatedClient extends ConsoleCliClient {\n secret: string\n connection: {\n clusterId: string\n zeebeGrpc?: string\n zeebeRest?: string\n oauthUrl?: string\n audience: string\n }\n}\n\nexport interface ConsoleCliBackup {\n id: string\n name: string\n status: string\n createdAt?: string\n completedAt?: string\n generation?: string\n generationId?: string\n zeebeStatus?: string\n operateStatus?: string\n tasklistStatus?: string\n optimizeStatus?: string\n}\n\nexport interface ConsoleCliRestore {\n id: string\n backupId: string\n state: string\n}\n\n/**\n * The `/cli/v1` routes of console-backend for secrets, alerts, clients and\n * backups. c4 calls them while the flag `console.c4CliApi` is on (#11623).\n */\nexport class ConsoleCliResourcesService {\n /**\n * `path` is the template with `:name` parts, `values` fills them. Only the\n * template goes to the logs and metrics: it holds no ids.\n */\n private static async call<T>(\n params: ConsoleCliClusterParams,\n name: string,\n type: RequestBaseMethodType,\n path: string,\n options: {\n values?: Record<string, string>\n body?: unknown\n query?: string\n redactBody?: boolean\n } = {},\n ): Promise<T> {\n const { orgId, clusterId } = params.params\n const template = `cli/v1/orgs/:orgId/clusters/:clusterId/${path}`\n const realPath = path.replace(/:(\\w+)/gu, (_match, key: string) =>\n encodeURIComponent(options.values?.[key] ?? ''),\n )\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `ConsoleCliResourcesService.${name}`,\n url: template,\n normalizedUrl: template,\n type,\n },\n source: params.config.metrics?.source || 'unset',\n target: { name: 'console', type: 'internal' },\n }\n\n const response = await request<T>({\n ...params,\n base: { id: 'console' },\n url: `cli/v1/orgs/${encodeURIComponent(orgId)}/clusters/${encodeURIComponent(clusterId)}/${realPath}${options.query ?? ''}`,\n logUrl: template,\n method: type,\n metricsDetails: serviceContext,\n body: options.body,\n redactBody: options.redactBody,\n // A 204 gives `{}`.\n responseType: 'json',\n })\n\n if (!response.ok || response.body === undefined) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n return response.body\n }\n\n /** Values only with `withValues`: that needs the right to change secrets. */\n public static listSecrets(\n params: ConsoleCliClusterParams & { withValues?: boolean },\n ): Promise<ConsoleCliSecret[]> {\n return ConsoleCliResourcesService.call(\n params,\n 'listSecrets',\n 'get',\n 'secrets',\n {\n query: params.withValues ? '?withValues=true' : undefined,\n },\n )\n }\n\n /** Creates the secret, or changes it if it exists. */\n public static async setSecret(\n params: ConsoleCliClusterParams & { name: string; value: string },\n ): Promise<void> {\n await ConsoleCliResourcesService.call(\n params,\n 'setSecret',\n 'put',\n 'secrets/:name',\n {\n values: { name: params.name },\n body: { value: params.value },\n redactBody: true,\n },\n )\n }\n\n public static async deleteSecret(\n params: ConsoleCliClusterParams & { name: string },\n ): Promise<void> {\n await ConsoleCliResourcesService.call(\n params,\n 'deleteSecret',\n 'delete',\n 'secrets/:name',\n {\n values: { name: params.name },\n },\n )\n }\n\n public static listAlerts(\n params: ConsoleCliClusterParams,\n ): Promise<ConsoleCliAlert[]> {\n return ConsoleCliResourcesService.call(\n params,\n 'listAlerts',\n 'get',\n 'alerts',\n )\n }\n\n public static createAlert(\n params: ConsoleCliClusterParams & { body: ConsoleCliCreateAlert },\n ): Promise<ConsoleCliAlert> {\n return ConsoleCliResourcesService.call(\n params,\n 'createAlert',\n 'post',\n 'alerts',\n {\n body: params.body,\n },\n )\n }\n\n public static updateAlert(\n params: ConsoleCliClusterParams & {\n alertId: string\n body: ConsoleCliUpdateAlert\n },\n ): Promise<ConsoleCliAlert> {\n return ConsoleCliResourcesService.call(\n params,\n 'updateAlert',\n 'patch',\n 'alerts/:alertId',\n {\n values: { alertId: params.alertId },\n body: params.body,\n },\n )\n }\n\n public static async deleteAlert(\n params: ConsoleCliClusterParams & { alertId: string },\n ): Promise<void> {\n await ConsoleCliResourcesService.call(\n params,\n 'deleteAlert',\n 'delete',\n 'alerts/:alertId',\n {\n values: { alertId: params.alertId },\n },\n )\n }\n\n public static listClients(\n params: ConsoleCliClusterParams,\n ): Promise<ConsoleCliClient[]> {\n return ConsoleCliResourcesService.call(\n params,\n 'listClients',\n 'get',\n 'clients',\n )\n }\n\n /** The answer holds the secret. It is the only time that it is shown. */\n public static createClient(\n params: ConsoleCliClusterParams & {\n body: { name: string; permissions: string[] }\n },\n ): Promise<ConsoleCliCreatedClient> {\n return ConsoleCliResourcesService.call(\n params,\n 'createClient',\n 'post',\n 'clients',\n {\n body: params.body,\n },\n )\n }\n\n public static updateClient(\n params: ConsoleCliClusterParams & { clientId: string; name: string },\n ): Promise<ConsoleCliClient> {\n return ConsoleCliResourcesService.call(\n params,\n 'updateClient',\n 'patch',\n 'clients/:clientId',\n {\n values: { clientId: params.clientId },\n body: { name: params.name },\n },\n )\n }\n\n /** The answer holds the new secret. It is the only time that it is shown. */\n public static rotateClientSecret(\n params: ConsoleCliClusterParams & { clientId: string },\n ): Promise<ConsoleCliCreatedClient> {\n return ConsoleCliResourcesService.call(\n params,\n 'rotateClientSecret',\n 'post',\n 'clients/:clientId/rotate-secret',\n { values: { clientId: params.clientId } },\n )\n }\n\n public static async deleteClient(\n params: ConsoleCliClusterParams & { clientId: string },\n ): Promise<void> {\n await ConsoleCliResourcesService.call(\n params,\n 'deleteClient',\n 'delete',\n 'clients/:clientId',\n {\n values: { clientId: params.clientId },\n },\n )\n }\n\n public static listBackups(\n params: ConsoleCliClusterParams,\n ): Promise<ConsoleCliBackup[]> {\n return ConsoleCliResourcesService.call(\n params,\n 'listBackups',\n 'get',\n 'backups',\n )\n }\n\n public static createBackup(\n params: ConsoleCliClusterParams,\n ): Promise<ConsoleCliBackup> {\n return ConsoleCliResourcesService.call(\n params,\n 'createBackup',\n 'post',\n 'backups',\n )\n }\n\n public static async deleteBackup(\n params: ConsoleCliClusterParams & { backupId: string },\n ): Promise<void> {\n await ConsoleCliResourcesService.call(\n params,\n 'deleteBackup',\n 'delete',\n 'backups/:backupId',\n {\n values: { backupId: params.backupId },\n },\n )\n }\n\n public static restoreBackup(\n params: ConsoleCliClusterParams & { backupId: string },\n ): Promise<ConsoleCliRestore> {\n return ConsoleCliResourcesService.call(\n params,\n 'restoreBackup',\n 'post',\n 'backups/:backupId/restore',\n { values: { backupId: params.backupId } },\n )\n }\n}\n"],
5
+ "mappings": "AAUA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAyFnB,MAAM,2BAA2B;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtC,aAAqB,KACnB,QACA,MACA,MACA,MACA,UAKI,CAAC,GACO;AACZ,UAAM,EAAE,OAAO,UAAU,IAAI,OAAO;AACpC,UAAM,WAAW,0CAA0C,IAAI;AAC/D,UAAM,WAAW,KAAK;AAAA,MAAQ;AAAA,MAAY,CAAC,QAAQ,QACjD,mBAAmB,QAAQ,SAAS,GAAG,KAAK,EAAE;AAAA,IAChD;AACA,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM,8BAA8B,IAAI;AAAA,QACxC,KAAK;AAAA,QACL,eAAe;AAAA,QACf;AAAA,MACF;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ,EAAE,MAAM,WAAW,MAAM,WAAW;AAAA,IAC9C;AAEA,UAAM,WAAW,MAAM,QAAW;AAAA,MAChC,GAAG;AAAA,MACH,MAAM,EAAE,IAAI,UAAU;AAAA,MACtB,KAAK,eAAe,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AClB,QACe;AACf,UAAM,2BAA2B;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ,EAAE,UAAU,OAAO,SAAS;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAc,YACZ,QAC6B;AAC7B,WAAO,2BAA2B;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAc,aACZ,QAC2B;AAC3B,WAAO,2BAA2B;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,aAAoB,aAClB,QACe;AACf,UAAM,2BAA2B;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,QAAQ,EAAE,UAAU,OAAO,SAAS;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAc,cACZ,QAC4B;AAC5B,WAAO,2BAA2B;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,EAAE,QAAQ,EAAE,UAAU,OAAO,SAAS,EAAE;AAAA,IAC1C;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ import type { CreateLeafletRequest, LeafletDto, LeafletSummaryDto, UpdateLeafletRequest } from '@camunda/ccma-shared-types';
2
+ import type { RequestBaseParams } from '../../types/general.types.js';
3
+ export interface ListLeafletsRequest extends RequestBaseParams {
4
+ params?: {
5
+ limit?: number;
6
+ offset?: number;
7
+ };
8
+ }
9
+ export interface LeafletIdRequest extends RequestBaseParams {
10
+ params: {
11
+ id: string;
12
+ };
13
+ }
14
+ export interface CreateLeafletParams extends RequestBaseParams {
15
+ params: CreateLeafletRequest;
16
+ }
17
+ export interface UpdateLeafletParams extends RequestBaseParams {
18
+ params: {
19
+ id: string;
20
+ } & UpdateLeafletRequest;
21
+ }
22
+ export interface LeafletPageInfoDto {
23
+ limit: number;
24
+ offset: number;
25
+ /** True when the next page holds more. Never read the length instead. */
26
+ hasMore: boolean;
27
+ }
28
+ export interface LeafletPageDto {
29
+ leaflets: LeafletSummaryDto[];
30
+ page: LeafletPageInfoDto;
31
+ }
32
+ export declare class ControlLeafletsService {
33
+ /** One page of the live leaflets, the newest change first. No HTML. */
34
+ static list(params: ListLeafletsRequest): Promise<LeafletPageDto>;
35
+ /** One live leaflet with its HTML. An expired leaflet answers 404. */
36
+ static get(params: LeafletIdRequest): Promise<LeafletDto>;
37
+ /** Stores a leaflet. Without `expiresAt` it expires in 30 days. */
38
+ static create(params: CreateLeafletParams): Promise<LeafletDto>;
39
+ /** Changes a leaflet. `expiresAt: null` means that it never expires. */
40
+ static update(params: UpdateLeafletParams): Promise<LeafletDto>;
41
+ /** Deletes a leaflet. Humans only: a machine token answers 403. */
42
+ static remove(params: LeafletIdRequest): Promise<void>;
43
+ private static send;
44
+ }
@@ -0,0 +1,95 @@
1
+ import { request } from "../../utils/api.js";
2
+ import { HttpError } from "../../utils/errors.js";
3
+ const BASE = { id: "control" };
4
+ class ControlLeafletsService {
5
+ /** One page of the live leaflets, the newest change first. No HTML. */
6
+ static async list(params) {
7
+ const query = new URLSearchParams();
8
+ for (const [key, value] of Object.entries(params.params ?? {})) {
9
+ if (value !== void 0) {
10
+ query.set(key, String(value));
11
+ }
12
+ }
13
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
14
+ return ControlLeafletsService.send(
15
+ params,
16
+ "list",
17
+ `api/leaflets${suffix}`,
18
+ "api/leaflets",
19
+ "get"
20
+ );
21
+ }
22
+ /** One live leaflet with its HTML. An expired leaflet answers 404. */
23
+ static async get(params) {
24
+ const { leaflet } = await ControlLeafletsService.send(
25
+ params,
26
+ "get",
27
+ `api/leaflets/${encodeURIComponent(params.params.id)}`,
28
+ "api/leaflets/:id",
29
+ "get"
30
+ );
31
+ return leaflet;
32
+ }
33
+ /** Stores a leaflet. Without `expiresAt` it expires in 30 days. */
34
+ static async create(params) {
35
+ const { leaflet } = await ControlLeafletsService.send(params, "create", "api/leaflets", "api/leaflets", "post", params.params);
36
+ return leaflet;
37
+ }
38
+ /** Changes a leaflet. `expiresAt: null` means that it never expires. */
39
+ static async update(params) {
40
+ const { id, ...patch } = params.params;
41
+ const { leaflet } = await ControlLeafletsService.send(
42
+ params,
43
+ "update",
44
+ `api/leaflets/${encodeURIComponent(id)}`,
45
+ "api/leaflets/:id",
46
+ "patch",
47
+ patch
48
+ );
49
+ return leaflet;
50
+ }
51
+ /** Deletes a leaflet. Humans only: a machine token answers 403. */
52
+ static async remove(params) {
53
+ await ControlLeafletsService.send(
54
+ params,
55
+ "remove",
56
+ `api/leaflets/${encodeURIComponent(params.params.id)}`,
57
+ "api/leaflets/:id",
58
+ "delete"
59
+ );
60
+ }
61
+ static async send(params, name, url, normalizedUrl, method, body) {
62
+ const serviceContext = {
63
+ method: {
64
+ name: `ControlLeafletsService.${name}`,
65
+ url: normalizedUrl,
66
+ normalizedUrl,
67
+ type: method
68
+ },
69
+ source: params.config.metrics?.source || "unset",
70
+ target: { name: "control", type: "internal" }
71
+ };
72
+ const response = await request({
73
+ ...params,
74
+ config: params.config,
75
+ base: BASE,
76
+ url,
77
+ logUrl: normalizedUrl,
78
+ method,
79
+ metricsDetails: serviceContext,
80
+ body
81
+ });
82
+ if (!response.ok) {
83
+ throw new HttpError(
84
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
85
+ response.status,
86
+ response.statusText
87
+ );
88
+ }
89
+ return response.body;
90
+ }
91
+ }
92
+ export {
93
+ ControlLeafletsService
94
+ };
95
+ //# sourceMappingURL=control.leaflets.service.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/control/control.leaflets.service.ts"],
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport type {\n CreateLeafletRequest,\n LeafletDto,\n LeafletSummaryDto,\n UpdateLeafletRequest,\n} from '@camunda/ccma-shared-types'\nimport type {\n RequestBaseMethodType,\n RequestBaseParams,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\n/**\n * The leaflets of control-backend: pages of HTML and CSS that a Camundi or a\n * bot stores, and that a Camundi with `admin.readAll` can open. The backend\n * removes scripts before it stores a page. Every route answers 404 while the\n * feature flag `control.leaflets` is off on the stage.\n */\n\nconst BASE = { id: 'control' } as const\n\nexport interface ListLeafletsRequest extends RequestBaseParams {\n params?: { limit?: number; offset?: number }\n}\n\nexport interface LeafletIdRequest extends RequestBaseParams {\n params: { id: string }\n}\n\nexport interface CreateLeafletParams extends RequestBaseParams {\n params: CreateLeafletRequest\n}\n\nexport interface UpdateLeafletParams extends RequestBaseParams {\n params: { id: string } & UpdateLeafletRequest\n}\n\nexport interface LeafletPageInfoDto {\n limit: number\n offset: number\n /** True when the next page holds more. Never read the length instead. */\n hasMore: boolean\n}\n\nexport interface LeafletPageDto {\n leaflets: LeafletSummaryDto[]\n page: LeafletPageInfoDto\n}\n\nexport class ControlLeafletsService {\n /** One page of the live leaflets, the newest change first. No HTML. */\n public static async list(\n params: ListLeafletsRequest,\n ): Promise<LeafletPageDto> {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(params.params ?? {})) {\n if (value !== undefined) {\n query.set(key, String(value))\n }\n }\n const suffix = query.size > 0 ? `?${query.toString()}` : ''\n return ControlLeafletsService.send<LeafletPageDto>(\n params,\n 'list',\n `api/leaflets${suffix}`,\n 'api/leaflets',\n 'get',\n )\n }\n\n /** One live leaflet with its HTML. An expired leaflet answers 404. */\n public static async get(params: LeafletIdRequest): Promise<LeafletDto> {\n const { leaflet } = await ControlLeafletsService.send<{\n leaflet: LeafletDto\n }>(\n params,\n 'get',\n `api/leaflets/${encodeURIComponent(params.params.id)}`,\n 'api/leaflets/:id',\n 'get',\n )\n return leaflet\n }\n\n /** Stores a leaflet. Without `expiresAt` it expires in 30 days. */\n public static async create(params: CreateLeafletParams): Promise<LeafletDto> {\n const { leaflet } = await ControlLeafletsService.send<{\n leaflet: LeafletDto\n }>(params, 'create', 'api/leaflets', 'api/leaflets', 'post', params.params)\n return leaflet\n }\n\n /** Changes a leaflet. `expiresAt: null` means that it never expires. */\n public static async update(params: UpdateLeafletParams): Promise<LeafletDto> {\n const { id, ...patch } = params.params\n const { leaflet } = await ControlLeafletsService.send<{\n leaflet: LeafletDto\n }>(\n params,\n 'update',\n `api/leaflets/${encodeURIComponent(id)}`,\n 'api/leaflets/:id',\n 'patch',\n patch,\n )\n return leaflet\n }\n\n /** Deletes a leaflet. Humans only: a machine token answers 403. */\n public static async remove(params: LeafletIdRequest): Promise<void> {\n await ControlLeafletsService.send<undefined>(\n params,\n 'remove',\n `api/leaflets/${encodeURIComponent(params.params.id)}`,\n 'api/leaflets/:id',\n 'delete',\n )\n }\n\n private static async send<TResponse>(\n params: RequestBaseParams,\n name: string,\n url: string,\n normalizedUrl: string,\n method: RequestBaseMethodType,\n body?: object,\n ): Promise<TResponse> {\n const serviceContext = {\n method: {\n name: `ControlLeafletsService.${name}`,\n url: normalizedUrl,\n normalizedUrl,\n type: method,\n },\n source: params.config.metrics?.source || 'unset',\n target: { name: 'control', type: 'internal' as const },\n }\n const response = await request<TResponse>({\n ...params,\n config: params.config,\n base: BASE,\n url,\n logUrl: normalizedUrl,\n method,\n metricsDetails: serviceContext,\n body,\n })\n if (!response.ok) {\n throw new HttpError(\n `${serviceContext.method.name}: ${response.status} ${response.statusText}`,\n response.status,\n response.statusText,\n )\n }\n // `remove` answers 204 with no body. Its caller reads nothing.\n return response.body as TResponse\n }\n}\n"],
5
+ "mappings": "AAgBA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAS1B,MAAM,OAAO,EAAE,IAAI,UAAU;AA8BtB,MAAM,uBAAuB;AAAA;AAAA,EAElC,aAAoB,KA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B,KACnB,QACA,MACA,KACA,eACA,QACA,MACoB;AACpB,UAAM,iBAAiB;AAAA,MACrB,QAAQ;AAAA,QACN,MAAM,0BAA0B,IAAI;AAAA,QACpC,KAAK;AAAA,QACL;AAAA,QACA,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ,EAAE,MAAM,WAAW,MAAM,WAAoB;AAAA,IACvD;AACA,UAAM,WAAW,MAAM,QAAmB;AAAA,MACxC,GAAG;AAAA,MACH,QAAQ,OAAO;AAAA,MACf,MAAM;AAAA,MACN;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA,gBAAgB;AAAA,MAChB;AAAA,IACF,CAAC;AACD,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI;AAAA,QACR,GAAG,eAAe,OAAO,IAAI,KAAK,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,QACxE,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/ccma-api",
3
- "version": "12.0.0",
3
+ "version": "12.2.0",
4
4
  "description": "Centralized API service layer for Camunda Cloud Management Apps",
5
5
  "bugs": {
6
6
  "url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
@@ -41,7 +41,7 @@
41
41
  }
42
42
  },
43
43
  "dependencies": {
44
- "@camunda/ccma-shared-types": "18.0.0"
44
+ "@camunda/ccma-shared-types": "18.1.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "node esbuild.mjs && tsc --emitDeclarationOnly --outDir dist",