@camunda/ccma-api 0.0.10 → 0.3.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 (96) hide show
  1. package/dist/index.d.ts +38 -8
  2. package/dist/index.js +56 -2
  3. package/dist/index.js.map +2 -2
  4. package/dist/services/accounts/admin-tools.service.d.ts +27 -0
  5. package/dist/services/accounts/admin-tools.service.js +70 -0
  6. package/dist/services/accounts/admin-tools.service.js.map +7 -0
  7. package/dist/services/accounts/connections.service.d.ts +85 -0
  8. package/dist/services/accounts/connections.service.js +150 -0
  9. package/dist/services/accounts/connections.service.js.map +2 -2
  10. package/dist/services/accounts/early-access-features.service.d.ts +59 -0
  11. package/dist/services/accounts/early-access-features.service.js +142 -0
  12. package/dist/services/accounts/early-access-features.service.js.map +2 -2
  13. package/dist/services/accounts/invites.service.d.ts +28 -0
  14. package/dist/services/accounts/invites.service.js +53 -0
  15. package/dist/services/accounts/invites.service.js.map +7 -0
  16. package/dist/services/accounts/orgs.service.d.ts +48 -0
  17. package/dist/services/accounts/orgs.service.js +153 -0
  18. package/dist/services/accounts/orgs.service.js.map +2 -2
  19. package/dist/services/accounts/orgs.v2.service.d.ts +32 -0
  20. package/dist/services/accounts/orgs.v2.service.js +158 -0
  21. package/dist/services/accounts/orgs.v2.service.js.map +7 -0
  22. package/dist/services/accounts/pdf-watermark.service.d.ts +93 -0
  23. package/dist/services/accounts/pdf-watermark.service.js +147 -0
  24. package/dist/services/accounts/pdf-watermark.service.js.map +7 -0
  25. package/dist/services/accounts/release-train.service.d.ts +25 -0
  26. package/dist/services/accounts/release-train.service.js +46 -0
  27. package/dist/services/accounts/release-train.service.js.map +7 -0
  28. package/dist/services/accounts/salesplan.service.d.ts +45 -0
  29. package/dist/services/accounts/salesplan.service.js +185 -0
  30. package/dist/services/accounts/salesplan.service.js.map +2 -2
  31. package/dist/services/accounts/token-issuer.service.d.ts +31 -0
  32. package/dist/services/accounts/token-issuer.service.js +63 -0
  33. package/dist/services/accounts/token-issuer.service.js.map +7 -0
  34. package/dist/services/accounts/users.service.d.ts +59 -0
  35. package/dist/services/accounts/users.service.js +296 -4
  36. package/dist/services/accounts/users.service.js.map +2 -2
  37. package/dist/services/console/console.admin.service.d.ts +11 -0
  38. package/dist/services/console/console.admin.service.js +37 -0
  39. package/dist/services/console/console.admin.service.js.map +2 -2
  40. package/dist/services/console/console.channel.service.d.ts +49 -0
  41. package/dist/services/console/console.channel.service.js +123 -0
  42. package/dist/services/console/console.channel.service.js.map +7 -0
  43. package/dist/services/console/console.cluster.service.d.ts +23 -11
  44. package/dist/services/console/console.cluster.service.js +36 -1
  45. package/dist/services/console/console.cluster.service.js.map +2 -2
  46. package/dist/services/console/console.cluster.v2.service.d.ts +43 -0
  47. package/dist/services/console/console.cluster.v2.service.js +219 -0
  48. package/dist/services/console/console.cluster.v2.service.js.map +7 -0
  49. package/dist/services/console/console.clusterplan.service.d.ts +14 -0
  50. package/dist/services/console/console.clusterplan.service.js +59 -0
  51. package/dist/services/console/console.clusterplan.service.js.map +2 -2
  52. package/dist/services/console/console.clusterplantype.service.d.ts +54 -0
  53. package/dist/services/console/console.clusterplantype.service.js +152 -0
  54. package/dist/services/console/console.clusterplantype.service.js.map +7 -0
  55. package/dist/services/console/console.k8scontext.service.d.ts +10 -0
  56. package/dist/services/console/console.k8scontext.service.js +41 -0
  57. package/dist/services/console/console.k8scontext.service.js.map +7 -0
  58. package/dist/services/console/console.storybook-config.service.d.ts +10 -0
  59. package/dist/services/console/console.storybook-config.service.js +40 -0
  60. package/dist/services/console/console.storybook-config.service.js.map +7 -0
  61. package/dist/services/console/generation.service.d.ts +42 -0
  62. package/dist/services/console/generation.service.js +115 -0
  63. package/dist/services/console/generation.service.js.map +2 -2
  64. package/dist/services/external/external.accounts.service.d.ts +27 -0
  65. package/dist/services/external/external.accounts.service.js +80 -0
  66. package/dist/services/external/external.accounts.service.js.map +7 -0
  67. package/dist/services/external/external.console.service.d.ts +37 -0
  68. package/dist/services/external/external.console.service.js +81 -0
  69. package/dist/services/external/external.console.service.js.map +7 -0
  70. package/dist/services/external/external.notifications.service.d.ts +78 -0
  71. package/dist/services/external/external.notifications.service.js +220 -0
  72. package/dist/services/external/external.notifications.service.js.map +7 -0
  73. package/dist/services/external/external.services.spec.d.ts +1 -0
  74. package/dist/services/helpcenter/helpcenter.service.d.ts +42 -0
  75. package/dist/services/helpcenter/helpcenter.service.js +84 -0
  76. package/dist/services/helpcenter/helpcenter.service.js.map +7 -0
  77. package/dist/services/helpcenter/helpcenter.service.spec.d.ts +1 -0
  78. package/dist/services/notifications/notifications.service.d.ts +45 -1
  79. package/dist/services/notifications/notifications.service.js +162 -0
  80. package/dist/services/notifications/notifications.service.js.map +2 -2
  81. package/dist/types/general.types.d.ts +8 -0
  82. package/dist/utils/api.d.ts +1 -1
  83. package/dist/utils/api.js +13 -2
  84. package/dist/utils/api.js.map +2 -2
  85. package/dist/utils/query.d.ts +7 -0
  86. package/dist/utils/query.js +29 -0
  87. package/dist/utils/query.js.map +7 -0
  88. package/dist/utils/sse.d.ts +51 -0
  89. package/dist/utils/sse.js +247 -0
  90. package/dist/utils/sse.js.map +7 -0
  91. package/dist/utils/sse.spec.d.ts +1 -0
  92. package/dist/utils/traceparent.d.ts +12 -0
  93. package/dist/utils/traceparent.js +16 -0
  94. package/dist/utils/traceparent.js.map +7 -0
  95. package/dist/utils/traceparent.spec.d.ts +1 -0
  96. package/package.json +2 -2
@@ -0,0 +1,220 @@
1
+ import { request } from "../../utils/api.js";
2
+ import { getEnvParam } from "../../utils/environments.js";
3
+ import { HttpError } from "../../utils/errors.js";
4
+ import {
5
+ connectSse
6
+ } from "../../utils/sse.js";
7
+ class ExternalNotificationsService {
8
+ /** The user's notifications for an org (`GET notifications/orgs/:orgId`). */
9
+ static async getUserNotifications(params) {
10
+ const serviceContext = {
11
+ method: {
12
+ name: "ExternalNotificationsService.getUserNotifications",
13
+ url: `notifications/orgs/${params.params.orgId}`,
14
+ normalizedUrl: "notifications/orgs/:orgId",
15
+ type: "get"
16
+ },
17
+ source: params.config.metrics?.source || "unset",
18
+ target: {
19
+ name: "notifications",
20
+ type: "internal"
21
+ }
22
+ };
23
+ const response = await request({
24
+ ...params,
25
+ base: { id: "notifications" },
26
+ url: serviceContext.method.url,
27
+ method: serviceContext.method.type,
28
+ metricsDetails: serviceContext,
29
+ responseType: "json"
30
+ });
31
+ if (!response.ok) {
32
+ throw new HttpError(
33
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
34
+ response.status,
35
+ response.statusText
36
+ );
37
+ }
38
+ return response.body ?? [];
39
+ }
40
+ /**
41
+ * Mark a single notification read or dismissed
42
+ * (`PATCH notifications/:uuid/:state`).
43
+ */
44
+ static async setNotificationState(params) {
45
+ const serviceContext = {
46
+ method: {
47
+ name: "ExternalNotificationsService.setNotificationState",
48
+ url: `notifications/${params.params.uuid}/${params.params.state}`,
49
+ normalizedUrl: "notifications/:uuid/:state",
50
+ type: "patch"
51
+ },
52
+ source: params.config.metrics?.source || "unset",
53
+ target: {
54
+ name: "notifications",
55
+ type: "internal"
56
+ }
57
+ };
58
+ const response = await request({
59
+ config: params.config,
60
+ base: { id: "notifications" },
61
+ url: serviceContext.method.url,
62
+ method: serviceContext.method.type,
63
+ metricsDetails: serviceContext,
64
+ responseType: "none"
65
+ });
66
+ if (!response.ok) {
67
+ throw new HttpError(
68
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
69
+ response.status,
70
+ response.statusText
71
+ );
72
+ }
73
+ }
74
+ /**
75
+ * Mark many notifications read in one call
76
+ * (`PATCH notifications/batch/state/read`, body `{ uuids }`). No-op for an
77
+ * empty list.
78
+ */
79
+ static async markManyAsRead(params) {
80
+ if (params.params.uuids.length === 0) {
81
+ return;
82
+ }
83
+ const serviceContext = {
84
+ method: {
85
+ name: "ExternalNotificationsService.markManyAsRead",
86
+ url: "notifications/batch/state/read",
87
+ normalizedUrl: "notifications/batch/state/read",
88
+ type: "patch"
89
+ },
90
+ source: params.config.metrics?.source || "unset",
91
+ target: {
92
+ name: "notifications",
93
+ type: "internal"
94
+ }
95
+ };
96
+ const response = await request({
97
+ config: params.config,
98
+ base: { id: "notifications" },
99
+ url: serviceContext.method.url,
100
+ method: serviceContext.method.type,
101
+ metricsDetails: serviceContext,
102
+ body: { uuids: params.params.uuids },
103
+ responseType: "none"
104
+ });
105
+ if (!response.ok) {
106
+ throw new HttpError(
107
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
108
+ response.status,
109
+ response.statusText
110
+ );
111
+ }
112
+ }
113
+ /**
114
+ * Dismiss every notification for an org
115
+ * (`PATCH notifications/dismissAll?orgId=:orgId`).
116
+ */
117
+ static async dismissAll(params) {
118
+ const serviceContext = {
119
+ method: {
120
+ name: "ExternalNotificationsService.dismissAll",
121
+ url: `notifications/dismissAll?orgId=${encodeURIComponent(params.params.orgId)}`,
122
+ normalizedUrl: "notifications/dismissAll",
123
+ type: "patch"
124
+ },
125
+ source: params.config.metrics?.source || "unset",
126
+ target: {
127
+ name: "notifications",
128
+ type: "internal"
129
+ }
130
+ };
131
+ const response = await request({
132
+ config: params.config,
133
+ base: { id: "notifications" },
134
+ url: serviceContext.method.url,
135
+ method: serviceContext.method.type,
136
+ metricsDetails: serviceContext,
137
+ responseType: "none"
138
+ });
139
+ if (!response.ok) {
140
+ throw new HttpError(
141
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
142
+ response.status,
143
+ response.statusText
144
+ );
145
+ }
146
+ }
147
+ /**
148
+ * Fire-and-forget analytics event
149
+ * (`POST analytics/:orgId/:event`, body `{ id }`). Errors are logged and
150
+ * swallowed — analytics must never break the UI.
151
+ */
152
+ static async trackEvent(params) {
153
+ const serviceContext = {
154
+ method: {
155
+ name: "ExternalNotificationsService.trackEvent",
156
+ url: `analytics/${encodeURIComponent(params.params.orgId)}/${params.params.event}`,
157
+ normalizedUrl: "analytics/:orgId/:event",
158
+ type: "post"
159
+ },
160
+ source: params.config.metrics?.source || "unset",
161
+ target: {
162
+ name: "notifications",
163
+ type: "internal"
164
+ }
165
+ };
166
+ try {
167
+ await request({
168
+ config: params.config,
169
+ base: { id: "notifications" },
170
+ url: serviceContext.method.url,
171
+ method: serviceContext.method.type,
172
+ metricsDetails: serviceContext,
173
+ body: { id: params.params.id },
174
+ responseType: "text"
175
+ });
176
+ } catch (error) {
177
+ params.config.logger?.debug(
178
+ "ExternalNotificationsService.trackEvent failed (ignored)",
179
+ { error }
180
+ );
181
+ }
182
+ }
183
+ /**
184
+ * Subscribe to the user's live notification stream
185
+ * (`GET notifications/events`, `text/event-stream`). `keepAlive` frames are
186
+ * skipped. Auto-reconnects with a fresh token; heartbeat window is 1h to
187
+ * match the backend's keep-alive cadence. Call `.close()` to stop.
188
+ */
189
+ static streamUserNotifications(params) {
190
+ const base = getEnvParam("notifications", params.config);
191
+ const url = `${base}/notifications/events`;
192
+ return connectSse({
193
+ url,
194
+ config: params.config,
195
+ heartbeatTimeoutMs: 60 * 60 * 1e3,
196
+ onStateChange: params.onStateChange,
197
+ onMessage: (message) => {
198
+ if (!message.data) {
199
+ return;
200
+ }
201
+ try {
202
+ const parsed = JSON.parse(message.data);
203
+ if (parsed.keepAlive) {
204
+ return;
205
+ }
206
+ params.onEvent(parsed);
207
+ } catch (error) {
208
+ params.config.logger?.debug(
209
+ "ExternalNotificationsService.streamUserNotifications: failed to parse event",
210
+ { error }
211
+ );
212
+ }
213
+ }
214
+ });
215
+ }
216
+ }
217
+ export {
218
+ ExternalNotificationsService
219
+ };
220
+ //# sourceMappingURL=external.notifications.service.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/external/external.notifications.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 { NotificationDto } from '@camunda/ccma-shared-types'\nimport type {\n RequestBaseParams,\n RequestBaseParamsConfig,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { getEnvParam } from '../../utils/environments.js'\nimport { HttpError } from '../../utils/errors.js'\nimport {\n connectSse,\n type SseConnection,\n type SseConnectionState,\n} from '../../utils/sse.js'\n\nexport type UserNotificationAnalyticsEvent =\n | 'notification-panel-opened'\n | 'notification-clicked-cta'\n\nexport interface GetUserNotificationsParams extends RequestBaseParams {\n params: {\n orgId: string\n }\n}\n\nexport interface SetNotificationStateParams extends RequestBaseParams {\n params: {\n uuid: string\n state: 'read' | 'dismiss'\n }\n}\n\nexport interface MarkManyNotificationsReadParams extends RequestBaseParams {\n params: {\n uuids: string[]\n }\n}\n\nexport interface DismissAllNotificationsParams extends RequestBaseParams {\n params: {\n orgId: string\n }\n}\n\nexport interface TrackNotificationEventParams extends RequestBaseParams {\n params: {\n orgId: string\n event: UserNotificationAnalyticsEvent\n id?: string\n }\n}\n\nexport interface StreamUserNotificationsParams {\n config: RequestBaseParamsConfig\n /** Called for each parsed user notification. `keepAlive` frames are skipped. */\n onEvent: (notification: NotificationDto) => void\n onStateChange?: (state: SseConnectionState) => void\n}\n\n/**\n * Per-user notification **feed** on the notifications backend \u2014 the bell-icon\n * inbox (list, mark read/dismiss, live updates), distinct from\n * `NotificationsService`, which is the admin/authoring surface\n * (`notifications/global` CRUD). Use this from webapp navigation; use\n * `NotificationsService` from internal admin tooling.\n */\nexport class ExternalNotificationsService {\n /** The user's notifications for an org (`GET notifications/orgs/:orgId`). */\n public static async getUserNotifications(\n params: GetUserNotificationsParams,\n ): Promise<NotificationDto[]> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'ExternalNotificationsService.getUserNotifications',\n url: `notifications/orgs/${params.params.orgId}`,\n normalizedUrl: 'notifications/orgs/:orgId',\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request<NotificationDto[]>({\n ...params,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n responseType: 'json',\n })\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\n return response.body ?? []\n }\n\n /**\n * Mark a single notification read or dismissed\n * (`PATCH notifications/:uuid/:state`).\n */\n public static async setNotificationState(\n params: SetNotificationStateParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'ExternalNotificationsService.setNotificationState',\n url: `notifications/${params.params.uuid}/${params.params.state}`,\n normalizedUrl: 'notifications/:uuid/:state',\n type: 'patch',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n responseType: 'none',\n })\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 }\n\n /**\n * Mark many notifications read in one call\n * (`PATCH notifications/batch/state/read`, body `{ uuids }`). No-op for an\n * empty list.\n */\n public static async markManyAsRead(\n params: MarkManyNotificationsReadParams,\n ): Promise<void> {\n if (params.params.uuids.length === 0) {\n return\n }\n\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'ExternalNotificationsService.markManyAsRead',\n url: 'notifications/batch/state/read',\n normalizedUrl: 'notifications/batch/state/read',\n type: 'patch',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: { uuids: params.params.uuids },\n responseType: 'none',\n })\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 }\n\n /**\n * Dismiss every notification for an org\n * (`PATCH notifications/dismissAll?orgId=:orgId`).\n */\n public static async dismissAll(\n params: DismissAllNotificationsParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'ExternalNotificationsService.dismissAll',\n url: `notifications/dismissAll?orgId=${encodeURIComponent(params.params.orgId)}`,\n normalizedUrl: 'notifications/dismissAll',\n type: 'patch',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n responseType: 'none',\n })\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 }\n\n /**\n * Fire-and-forget analytics event\n * (`POST analytics/:orgId/:event`, body `{ id }`). Errors are logged and\n * swallowed \u2014 analytics must never break the UI.\n */\n public static async trackEvent(\n params: TrackNotificationEventParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'ExternalNotificationsService.trackEvent',\n url: `analytics/${encodeURIComponent(params.params.orgId)}/${params.params.event}`,\n normalizedUrl: 'analytics/:orgId/:event',\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n try {\n await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: { id: params.params.id },\n responseType: 'text',\n })\n } catch (error) {\n params.config.logger?.debug(\n 'ExternalNotificationsService.trackEvent failed (ignored)',\n { error },\n )\n }\n }\n\n /**\n * Subscribe to the user's live notification stream\n * (`GET notifications/events`, `text/event-stream`). `keepAlive` frames are\n * skipped. Auto-reconnects with a fresh token; heartbeat window is 1h to\n * match the backend's keep-alive cadence. Call `.close()` to stop.\n */\n public static streamUserNotifications(\n params: StreamUserNotificationsParams,\n ): SseConnection {\n const base = getEnvParam('notifications', params.config)\n const url = `${base}/notifications/events`\n\n return connectSse({\n url,\n config: params.config,\n heartbeatTimeoutMs: 60 * 60 * 1000,\n onStateChange: params.onStateChange,\n onMessage: (message) => {\n if (!message.data) {\n return\n }\n try {\n const parsed = JSON.parse(message.data) as NotificationDto & {\n keepAlive?: boolean\n }\n if (parsed.keepAlive) {\n return\n }\n params.onEvent(parsed)\n } catch (error) {\n params.config.logger?.debug(\n 'ExternalNotificationsService.streamUserNotifications: failed to parse event',\n { error },\n )\n }\n },\n })\n }\n}\n"],
5
+ "mappings": "AAYA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,OAGK;AAqDA,MAAM,6BAA6B;AAAA;AAAA,EAExC,aAAoB,qBAClB,QAC4B;AAC5B,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK,sBAAsB,OAAO,OAAO,KAAK;AAAA,QAC9C,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAA2B;AAAA,MAChD,GAAG;AAAA,MACH,MAAM,EAAE,IAAI,gBAAgB;AAAA,MAC5B,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,cAAc;AAAA,IAChB,CAAC;AAED,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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0 +1,42 @@
1
+ import type { RequestBaseParams } from '../../types/general.types.js';
2
+ export interface HelpCenterGetConfigRequest extends RequestBaseParams {
3
+ params: {
4
+ audience: string;
5
+ orgId: string;
6
+ };
7
+ }
8
+ export interface HelpCenterConfigResponse {
9
+ tabs?: Array<{
10
+ id: string;
11
+ label: string;
12
+ title: string;
13
+ tiletype: string;
14
+ tiles: Array<{
15
+ id: string;
16
+ }>;
17
+ }>;
18
+ links?: Array<{
19
+ id: string;
20
+ label: string;
21
+ link: string;
22
+ }>;
23
+ }
24
+ export interface HelpCenterGetCardsRequest extends RequestBaseParams {
25
+ params: {
26
+ audience: string;
27
+ cardIds: string[];
28
+ };
29
+ }
30
+ export interface HelpCenterCardResponse {
31
+ card_id: string;
32
+ title: string;
33
+ description: string;
34
+ image: string;
35
+ timeToComplete?: string;
36
+ cta?: string;
37
+ link?: string;
38
+ }
39
+ export declare class HelpCenterService {
40
+ static getConfig(params: HelpCenterGetConfigRequest): Promise<HelpCenterConfigResponse>;
41
+ static getCards(params: HelpCenterGetCardsRequest): Promise<HelpCenterCardResponse[]>;
42
+ }
@@ -0,0 +1,84 @@
1
+ import { request } from "../../utils/api.js";
2
+ import { HttpError } from "../../utils/errors.js";
3
+ class HelpCenterService {
4
+ static async getConfig(params) {
5
+ const url = `https://helpcenter.${params.params.audience}/helpcenter/config/${params.params.orgId}`;
6
+ const serviceContext = {
7
+ method: {
8
+ name: "HelpCenterService.getConfig",
9
+ url,
10
+ normalizedUrl: "https://helpcenter.:audience/helpcenter/config/:orgId",
11
+ type: "get"
12
+ },
13
+ source: params.config.metrics?.source || "unset",
14
+ target: {
15
+ name: "helpcenter",
16
+ type: "external"
17
+ }
18
+ };
19
+ const response = await request({
20
+ ...params,
21
+ url: serviceContext.method.url,
22
+ method: serviceContext.method.type,
23
+ metricsDetails: serviceContext,
24
+ type: "json"
25
+ });
26
+ if (!response.ok) {
27
+ throw new HttpError(
28
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
29
+ response.status,
30
+ response.statusText
31
+ );
32
+ }
33
+ if (response.body === void 0) {
34
+ throw new HttpError(
35
+ `${serviceContext.method.name}: missing response body`,
36
+ response.status,
37
+ response.statusText
38
+ );
39
+ }
40
+ return response.body;
41
+ }
42
+ static async getCards(params) {
43
+ const url = `https://helpcenter.${params.params.audience}/cards?card_id=${params.params.cardIds.join(",")}`;
44
+ const serviceContext = {
45
+ method: {
46
+ name: "HelpCenterService.getCards",
47
+ url,
48
+ normalizedUrl: "https://helpcenter.:audience/cards?card_id=:card_id",
49
+ type: "get"
50
+ },
51
+ source: params.config.metrics?.source || "unset",
52
+ target: {
53
+ name: "helpcenter",
54
+ type: "external"
55
+ }
56
+ };
57
+ const response = await request({
58
+ ...params,
59
+ url: serviceContext.method.url,
60
+ method: serviceContext.method.type,
61
+ metricsDetails: serviceContext,
62
+ type: "json"
63
+ });
64
+ if (!response.ok) {
65
+ throw new HttpError(
66
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
67
+ response.status,
68
+ response.statusText
69
+ );
70
+ }
71
+ if (response.body === void 0) {
72
+ throw new HttpError(
73
+ `${serviceContext.method.name}: missing response body`,
74
+ response.status,
75
+ response.statusText
76
+ );
77
+ }
78
+ return response.body;
79
+ }
80
+ }
81
+ export {
82
+ HelpCenterService
83
+ };
84
+ //# sourceMappingURL=helpcenter.service.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/helpcenter/helpcenter.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 RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\nexport interface HelpCenterGetConfigRequest extends RequestBaseParams {\n params: {\n audience: string\n orgId: string\n }\n}\n\nexport interface HelpCenterConfigResponse {\n tabs?: Array<{\n id: string\n label: string\n title: string\n tiletype: string\n tiles: Array<{ id: string }>\n }>\n links?: Array<{\n id: string\n label: string\n link: string\n }>\n}\n\nexport interface HelpCenterGetCardsRequest extends RequestBaseParams {\n params: {\n audience: string\n cardIds: string[]\n }\n}\n\nexport interface HelpCenterCardResponse {\n card_id: string\n title: string\n description: string\n image: string\n timeToComplete?: string\n cta?: string\n link?: string\n}\n\nexport class HelpCenterService {\n public static async getConfig(\n params: HelpCenterGetConfigRequest,\n ): Promise<HelpCenterConfigResponse> {\n const url = `https://helpcenter.${params.params.audience}/helpcenter/config/${params.params.orgId}`\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'HelpCenterService.getConfig',\n url,\n normalizedUrl: 'https://helpcenter.:audience/helpcenter/config/:orgId',\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'helpcenter',\n type: 'external',\n },\n }\n\n const response = await request<HelpCenterConfigResponse>({\n ...params,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n })\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\n if (response.body === undefined) {\n throw new HttpError(\n `${serviceContext.method.name}: missing response body`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body\n }\n\n public static async getCards(\n params: HelpCenterGetCardsRequest,\n ): Promise<HelpCenterCardResponse[]> {\n const url = `https://helpcenter.${params.params.audience}/cards?card_id=${params.params.cardIds.join(',')}`\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: 'HelpCenterService.getCards',\n url,\n normalizedUrl: 'https://helpcenter.:audience/cards?card_id=:card_id',\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'helpcenter',\n type: 'external',\n },\n }\n\n const response = await request<HelpCenterCardResponse[]>({\n ...params,\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n type: 'json',\n })\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\n if (response.body === undefined) {\n throw new HttpError(\n `${serviceContext.method.name}: missing response body`,\n response.status,\n response.statusText,\n )\n }\n\n return response.body\n }\n}\n"],
5
+ "mappings": "AAUA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAyCnB,MAAM,kBAAkB;AAAA,EAC7B,aAAoB,UAClB,QACmC;AACnC,UAAM,MAAM,sBAAsB,OAAO,OAAO,QAAQ,sBAAsB,OAAO,OAAO,KAAK;AACjG,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAkC;AAAA,MACvD,GAAG;AAAA,MACH,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,MAAM;AAAA,IACR,CAAC;AAED,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,QAAI,SAAS,SAAS,QAAW;AAC/B,YAAM,IAAI;AAAA,QACR,GAAG,eAAe,OAAO,IAAI;AAAA,QAC7B,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AAAA,EAEA,aAAoB,SAClB,QACmC;AACnC,UAAM,MAAM,sBAAsB,OAAO,OAAO,QAAQ,kBAAkB,OAAO,OAAO,QAAQ,KAAK,GAAG,CAAC;AACzG,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAkC;AAAA,MACvD,GAAG;AAAA,MACH,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,MAAM;AAAA,IACR,CAAC;AAED,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,QAAI,SAAS,SAAS,QAAW;AAC/B,YAAM,IAAI;AAAA,QACR,GAAG,eAAe,OAAO,IAAI;AAAA,QAC7B,SAAS;AAAA,QACT,SAAS;AAAA,MACX;AAAA,IACF;AAEA,WAAO,SAAS;AAAA,EAClB;AACF;",
6
+ "names": []
7
+ }
@@ -1,7 +1,51 @@
1
- import type { NotificationOptions } from '@camunda/ccma-shared-types';
1
+ import type { NotificationDto, NotificationOptions } from '@camunda/ccma-shared-types';
2
2
  import type { RequestBaseParams } from '../../types/general.types.js';
3
+ export interface CreateGlobalNotificationParams extends RequestBaseParams {
4
+ body: {
5
+ /** Scheduling rides on `meta.scheduleTs` (epoch ms). */
6
+ notification: NotificationOptions;
7
+ };
8
+ }
9
+ export interface CreateNotificationBySalesPlanParams extends RequestBaseParams {
10
+ params: {
11
+ salesPlanType: string;
12
+ };
13
+ body: {
14
+ notification: NotificationOptions;
15
+ };
16
+ }
17
+ export interface UpdateNotificationParams extends RequestBaseParams {
18
+ params: {
19
+ uuid: string;
20
+ };
21
+ body: {
22
+ /** Only draft/scheduled notifications are editable (backend-enforced). */
23
+ notification: Partial<NotificationOptions>;
24
+ };
25
+ }
26
+ export interface DeleteGlobalNotificationParams extends RequestBaseParams {
27
+ params: {
28
+ notificationId: string;
29
+ };
30
+ }
3
31
  export declare class NotificationsService {
4
32
  static sendNotification(params: {
5
33
  notification: NotificationOptions;
6
34
  } & RequestBaseParams): Promise<void>;
35
+ /** All global notifications (sent, draft, scheduled) for the admin list. */
36
+ static getGlobalNotifications(params: RequestBaseParams): Promise<NotificationDto[]>;
37
+ /**
38
+ * Create a global notification (visible to every user). Scheduling rides on
39
+ * `meta.scheduleTs`; an `initState` of `draft` keeps it unsent.
40
+ */
41
+ static createGlobalNotification(params: CreateGlobalNotificationParams): Promise<void>;
42
+ /**
43
+ * Create a notification for every member of the orgs on a sales-plan type
44
+ * (fans out via the accounts backend, `POST api/notifications/:salesPlanType`).
45
+ */
46
+ static createNotificationBySalesPlan(params: CreateNotificationBySalesPlanParams): Promise<void>;
47
+ /** Update a draft/scheduled notification (`PATCH notifications/:uuid`). */
48
+ static updateNotification(params: UpdateNotificationParams): Promise<void>;
49
+ /** Delete a global notification (`DELETE notifications/global/:id`). */
50
+ static deleteGlobalNotification(params: DeleteGlobalNotificationParams): Promise<void>;
7
51
  }
@@ -31,6 +31,168 @@ class NotificationsService {
31
31
  );
32
32
  }
33
33
  }
34
+ /** All global notifications (sent, draft, scheduled) for the admin list. */
35
+ static async getGlobalNotifications(params) {
36
+ const serviceContext = {
37
+ method: {
38
+ name: `NotificationsService.getGlobalNotifications`,
39
+ url: `notifications/global`,
40
+ normalizedUrl: `notifications/global`,
41
+ type: "get"
42
+ },
43
+ source: params.config.metrics?.source || "unset",
44
+ target: {
45
+ name: "notifications",
46
+ type: "internal"
47
+ }
48
+ };
49
+ const response = await request({
50
+ ...params,
51
+ base: { id: "notifications" },
52
+ url: serviceContext.method.url,
53
+ method: serviceContext.method.type,
54
+ metricsDetails: serviceContext,
55
+ responseType: "json"
56
+ });
57
+ if (!response.ok) {
58
+ throw new HttpError(
59
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
60
+ response.status,
61
+ response.statusText
62
+ );
63
+ }
64
+ return response.body ?? [];
65
+ }
66
+ /**
67
+ * Create a global notification (visible to every user). Scheduling rides on
68
+ * `meta.scheduleTs`; an `initState` of `draft` keeps it unsent.
69
+ */
70
+ static async createGlobalNotification(params) {
71
+ const serviceContext = {
72
+ method: {
73
+ name: `NotificationsService.createGlobalNotification`,
74
+ url: `notifications/global`,
75
+ normalizedUrl: `notifications/global`,
76
+ type: "post"
77
+ },
78
+ source: params.config.metrics?.source || "unset",
79
+ target: {
80
+ name: "notifications",
81
+ type: "internal"
82
+ }
83
+ };
84
+ const response = await request({
85
+ config: params.config,
86
+ base: { id: "notifications" },
87
+ url: serviceContext.method.url,
88
+ method: serviceContext.method.type,
89
+ metricsDetails: serviceContext,
90
+ body: params.body
91
+ });
92
+ if (!response.ok) {
93
+ throw new HttpError(
94
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
95
+ response.status,
96
+ response.statusText
97
+ );
98
+ }
99
+ }
100
+ /**
101
+ * Create a notification for every member of the orgs on a sales-plan type
102
+ * (fans out via the accounts backend, `POST api/notifications/:salesPlanType`).
103
+ */
104
+ static async createNotificationBySalesPlan(params) {
105
+ const serviceContext = {
106
+ method: {
107
+ name: `NotificationsService.createNotificationBySalesPlan`,
108
+ url: `api/notifications/${encodeURIComponent(params.params.salesPlanType)}`,
109
+ normalizedUrl: `api/notifications/:salesPlanType`,
110
+ type: "post"
111
+ },
112
+ source: params.config.metrics?.source || "unset",
113
+ target: {
114
+ name: "accounts",
115
+ type: "internal"
116
+ }
117
+ };
118
+ const response = await request({
119
+ config: params.config,
120
+ base: { id: "accounts" },
121
+ url: serviceContext.method.url,
122
+ method: serviceContext.method.type,
123
+ metricsDetails: serviceContext,
124
+ body: params.body
125
+ });
126
+ if (!response.ok) {
127
+ throw new HttpError(
128
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
129
+ response.status,
130
+ response.statusText
131
+ );
132
+ }
133
+ }
134
+ /** Update a draft/scheduled notification (`PATCH notifications/:uuid`). */
135
+ static async updateNotification(params) {
136
+ const serviceContext = {
137
+ method: {
138
+ name: `NotificationsService.updateNotification`,
139
+ url: `notifications/${params.params.uuid}`,
140
+ normalizedUrl: `notifications/:uuid`,
141
+ type: "patch"
142
+ },
143
+ source: params.config.metrics?.source || "unset",
144
+ target: {
145
+ name: "notifications",
146
+ type: "internal"
147
+ }
148
+ };
149
+ const response = await request({
150
+ config: params.config,
151
+ base: { id: "notifications" },
152
+ url: serviceContext.method.url,
153
+ method: serviceContext.method.type,
154
+ metricsDetails: serviceContext,
155
+ body: params.body
156
+ });
157
+ if (!response.ok) {
158
+ throw new HttpError(
159
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
160
+ response.status,
161
+ response.statusText
162
+ );
163
+ }
164
+ }
165
+ /** Delete a global notification (`DELETE notifications/global/:id`). */
166
+ static async deleteGlobalNotification(params) {
167
+ const serviceContext = {
168
+ method: {
169
+ name: `NotificationsService.deleteGlobalNotification`,
170
+ url: `notifications/global/${params.params.notificationId}`,
171
+ normalizedUrl: `notifications/global/:notificationId`,
172
+ type: "delete"
173
+ },
174
+ source: params.config.metrics?.source || "unset",
175
+ target: {
176
+ name: "notifications",
177
+ type: "internal"
178
+ }
179
+ };
180
+ const response = await request({
181
+ config: params.config,
182
+ base: { id: "notifications" },
183
+ url: serviceContext.method.url,
184
+ method: serviceContext.method.type,
185
+ metricsDetails: serviceContext,
186
+ responseType: "none"
187
+ });
188
+ if (!response.ok) {
189
+ throw new HttpError(
190
+ `${serviceContext.method.name}: ${response.status} ${response.statusText}`,
191
+ response.status,
192
+ response.statusText
193
+ );
194
+ }
195
+ }
34
196
  }
35
197
  export {
36
198
  NotificationsService
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/services/notifications/notifications.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 { NotificationOptions } from '@camunda/ccma-shared-types'\nimport type {\n RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\nexport class NotificationsService {\n public static async sendNotification(\n params: { notification: NotificationOptions } & RequestBaseParams,\n ) {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.sendNotification`,\n url: `notifications/${params.notification.type}`,\n normalizedUrl: `notifications/:type`,\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: { notification: params.notification },\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 }\n}\n"],
5
- "mappings": "AAWA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAEnB,MAAM,qBAAqB;AAAA,EAChC,aAAoB,iBAClB,QACA;AACA,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK,iBAAiB,OAAO,aAAa,IAAI;AAAA,QAC9C,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ;AAAA,MAC7B,QAAQ,OAAO;AAAA,MACf,MAAM,EAAE,IAAI,gBAAgB;AAAA,MAC5B,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,MAAM,EAAE,cAAc,OAAO,aAAa;AAAA,IAC5C,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;AAAA,EACF;AACF;",
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 NotificationDto,\n NotificationOptions,\n} from '@camunda/ccma-shared-types'\nimport type {\n RequestBaseParams,\n RequestBaseServiceContext,\n} from '../../types/general.types.js'\nimport { request } from '../../utils/api.js'\nimport { HttpError } from '../../utils/errors.js'\n\nexport interface CreateGlobalNotificationParams extends RequestBaseParams {\n body: {\n /** Scheduling rides on `meta.scheduleTs` (epoch ms). */\n notification: NotificationOptions\n }\n}\n\nexport interface CreateNotificationBySalesPlanParams extends RequestBaseParams {\n params: {\n salesPlanType: string\n }\n body: {\n notification: NotificationOptions\n }\n}\n\nexport interface UpdateNotificationParams extends RequestBaseParams {\n params: {\n uuid: string\n }\n body: {\n /** Only draft/scheduled notifications are editable (backend-enforced). */\n notification: Partial<NotificationOptions>\n }\n}\n\nexport interface DeleteGlobalNotificationParams extends RequestBaseParams {\n params: {\n notificationId: string\n }\n}\n\nexport class NotificationsService {\n public static async sendNotification(\n params: { notification: NotificationOptions } & RequestBaseParams,\n ) {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.sendNotification`,\n url: `notifications/${params.notification.type}`,\n normalizedUrl: `notifications/:type`,\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: { notification: params.notification },\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 }\n\n /** All global notifications (sent, draft, scheduled) for the admin list. */\n public static async getGlobalNotifications(\n params: RequestBaseParams,\n ): Promise<NotificationDto[]> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.getGlobalNotifications`,\n url: `notifications/global`,\n normalizedUrl: `notifications/global`,\n type: 'get',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request<NotificationDto[]>({\n ...params,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n responseType: 'json',\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 return response.body ?? []\n }\n\n /**\n * Create a global notification (visible to every user). Scheduling rides on\n * `meta.scheduleTs`; an `initState` of `draft` keeps it unsent.\n */\n public static async createGlobalNotification(\n params: CreateGlobalNotificationParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.createGlobalNotification`,\n url: `notifications/global`,\n normalizedUrl: `notifications/global`,\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: params.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 }\n\n /**\n * Create a notification for every member of the orgs on a sales-plan type\n * (fans out via the accounts backend, `POST api/notifications/:salesPlanType`).\n */\n public static async createNotificationBySalesPlan(\n params: CreateNotificationBySalesPlanParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.createNotificationBySalesPlan`,\n url: `api/notifications/${encodeURIComponent(params.params.salesPlanType)}`,\n normalizedUrl: `api/notifications/:salesPlanType`,\n type: 'post',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'accounts',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'accounts' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: params.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 }\n\n /** Update a draft/scheduled notification (`PATCH notifications/:uuid`). */\n public static async updateNotification(\n params: UpdateNotificationParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.updateNotification`,\n url: `notifications/${params.params.uuid}`,\n normalizedUrl: `notifications/:uuid`,\n type: 'patch',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n body: params.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 }\n\n /** Delete a global notification (`DELETE notifications/global/:id`). */\n public static async deleteGlobalNotification(\n params: DeleteGlobalNotificationParams,\n ): Promise<void> {\n const serviceContext: RequestBaseServiceContext = {\n method: {\n name: `NotificationsService.deleteGlobalNotification`,\n url: `notifications/global/${params.params.notificationId}`,\n normalizedUrl: `notifications/global/:notificationId`,\n type: 'delete',\n },\n source: params.config.metrics?.source || 'unset',\n target: {\n name: 'notifications',\n type: 'internal',\n },\n }\n\n const response = await request({\n config: params.config,\n base: { id: 'notifications' },\n url: serviceContext.method.url,\n method: serviceContext.method.type,\n metricsDetails: serviceContext,\n responseType: 'none',\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 }\n}\n"],
5
+ "mappings": "AAcA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAkCnB,MAAM,qBAAqB;AAAA,EAChC,aAAoB,iBAClB,QACA;AACA,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK,iBAAiB,OAAO,aAAa,IAAI;AAAA,QAC9C,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ;AAAA,MAC7B,QAAQ,OAAO;AAAA,MACf,MAAM,EAAE,IAAI,gBAAgB;AAAA,MAC5B,KAAK,eAAe,OAAO;AAAA,MAC3B,QAAQ,eAAe,OAAO;AAAA,MAC9B,gBAAgB;AAAA,MAChB,MAAM,EAAE,cAAc,OAAO,aAAa;AAAA,IAC5C,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;AAAA,EACF;AAAA;AAAA,EAGA,aAAoB,uBAClB,QAC4B;AAC5B,UAAM,iBAA4C;AAAA,MAChD,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,KAAK;AAAA,QACL,eAAe;AAAA,QACf,MAAM;AAAA,MACR;AAAA,MACA,QAAQ,OAAO,OAAO,SAAS,UAAU;AAAA,MACzC,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,MACR;AAAA,IACF;AAEA,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