@stack-spot/portal-network 0.20.0 → 0.22.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 (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/api/notification.d.ts +158 -0
  3. package/dist/api/notification.d.ts.map +1 -0
  4. package/dist/api/notification.js +113 -0
  5. package/dist/api/notification.js.map +1 -0
  6. package/dist/api/workspace.d.ts +1 -1
  7. package/dist/api/workspace.d.ts.map +1 -1
  8. package/dist/apis.json +8 -0
  9. package/dist/client/account.d.ts +4 -0
  10. package/dist/client/account.d.ts.map +1 -1
  11. package/dist/client/account.js +10 -1
  12. package/dist/client/account.js.map +1 -1
  13. package/dist/client/content.d.ts +6 -6
  14. package/dist/client/content.d.ts.map +1 -1
  15. package/dist/client/content.js +4 -3
  16. package/dist/client/content.js.map +1 -1
  17. package/dist/client/notification.d.ts +36 -0
  18. package/dist/client/notification.d.ts.map +1 -0
  19. package/dist/client/notification.js +42 -0
  20. package/dist/client/notification.js.map +1 -0
  21. package/dist/client/workflow.d.ts +8 -8
  22. package/dist/client/workflow.d.ts.map +1 -1
  23. package/dist/client/workflow.js +5 -4
  24. package/dist/client/workflow.js.map +1 -1
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/utils/remove-authorization-param.d.ts +5 -0
  30. package/dist/utils/remove-authorization-param.d.ts.map +1 -0
  31. package/dist/utils/remove-authorization-param.js +4 -0
  32. package/dist/utils/remove-authorization-param.js.map +1 -0
  33. package/package.json +1 -1
  34. package/src/api/notification.ts +278 -0
  35. package/src/api/workspace.ts +1 -1
  36. package/src/apis.json +8 -0
  37. package/src/client/account.ts +5 -0
  38. package/src/client/content.ts +4 -3
  39. package/src/client/notification.ts +32 -0
  40. package/src/client/workflow.ts +5 -4
  41. package/src/index.ts +1 -0
  42. package/src/utils/remove-authorization-param.ts +5 -0
@@ -0,0 +1,278 @@
1
+ /**
2
+ * Notification Engine
3
+ * 1.0.0
4
+ * DO NOT MODIFY - This file has been generated using oazapfts.
5
+ * See https://www.npmjs.com/package/oazapfts
6
+ */
7
+ import * as Oazapfts from "@oazapfts/runtime";
8
+ import * as QS from "@oazapfts/runtime/query";
9
+ export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
10
+ headers: {},
11
+ baseUrl: "https://account-notification-engine.dev.stackspot.com",
12
+ };
13
+ const oazapfts = Oazapfts.runtime(defaults);
14
+ export const servers = {
15
+ generatedServerUrl: "https://account-notification-engine.dev.stackspot.com"
16
+ };
17
+ export type GetTenantNotificationsResponse = {
18
+ id: string;
19
+ title: string;
20
+ description: string;
21
+ broadcast_level: "ACCOUNT" | "INDIVIDUAL" | "PLATFORM" | "RESOURCE";
22
+ context: "ACCOUNT" | "STUDIO" | "WORKSPACE" | "AI";
23
+ target?: string;
24
+ criticality: "LOW" | "MEDIUM" | "HIGH";
25
+ call_to_action: string;
26
+ persistent: boolean;
27
+ committed: boolean;
28
+ last_until?: string;
29
+ trigger_at: string;
30
+ created_at?: string;
31
+ };
32
+ export type PagingResponseModelGetTenantNotificationsResponse = {
33
+ items: GetTenantNotificationsResponse[];
34
+ size: number;
35
+ total_elements: number;
36
+ };
37
+ export type ErrorDetails = {
38
+ code: "INTEGRATION_EXCEPTION" | "INVALID_TENANT" | "VALIDATION_ERROR" | "MANDATORY_FIELD_NOT_INFORMED" | "INVALID_REQUEST" | "NOTIFICATION_NOT_FOUND" | "INVALID_FIELD" | "MISSING_TOKEN";
39
+ field?: string;
40
+ details?: string;
41
+ values?: string[];
42
+ };
43
+ export type ApiErrorResponse = {
44
+ code?: "INTEGRATION_EXCEPTION" | "INVALID_TENANT" | "VALIDATION_ERROR" | "MANDATORY_FIELD_NOT_INFORMED" | "INVALID_REQUEST" | "NOTIFICATION_NOT_FOUND" | "INVALID_FIELD" | "MISSING_TOKEN";
45
+ status: number;
46
+ message: string;
47
+ details?: ErrorDetails[];
48
+ };
49
+ export type CreateTenantNotificationRequest = {
50
+ /** User friendly title for the notification */
51
+ title: string;
52
+ /** User friendly description for the notification (allows the use of markdown) */
53
+ description: string;
54
+ /** Level of broadcasting to the notification. */
55
+ broadcast_level: "ACCOUNT" | "INDIVIDUAL" | "PLATFORM" | "RESOURCE" | "ACCOUNT" | "INDIVIDUAL" | "RESOURCE";
56
+ /** The target of the notification, user id for 'individual', resource id for 'resource', leave empty for any other */
57
+ target: string;
58
+ /** Criticality of the notification. */
59
+ criticality: "LOW" | "MEDIUM" | "HIGH" | "LOW" | "MEDIUM" | "HIGH";
60
+ /** Which context to publish the notification */
61
+ context: "ACCOUNT" | "STUDIO" | "WORKSPACE" | "AI" | "Account" | "Studio" | "Workspace";
62
+ /** Possible redirect link for the notification button. */
63
+ call_to_action: string;
64
+ /** If the notification should be re-consumed until 'last_until' is reached. */
65
+ persistent: boolean;
66
+ /** UTC formatted timestamp to when the notification should finally end, if the persistent is set to true. */
67
+ last_until?: string;
68
+ /** UTC formatted timestamp for when to triggers the notification. */
69
+ trigger_at: string;
70
+ };
71
+ export type CreatePlatformNotificationRequest = {
72
+ /** User friendly title for the notification */
73
+ title: string;
74
+ /** User friendly description for the notification (allows the use of markdown) */
75
+ description: string;
76
+ /** Criticality of the notification. */
77
+ criticality: "LOW" | "MEDIUM" | "HIGH" | "LOW" | "MEDIUM" | "HIGH";
78
+ /** Which context to publish the notification */
79
+ context: "ACCOUNT" | "STUDIO" | "WORKSPACE" | "AI" | "Account" | "Studio" | "Workspace";
80
+ /** Possible redirect link for the notification button. */
81
+ call_to_action: string;
82
+ /** If the notification should be re-consumed until last_until is reached. */
83
+ persistent: boolean;
84
+ /** UTC formatted timestamp to when the notification should finally ended if the persistent is set to true. */
85
+ last_until?: string;
86
+ /** UTC formatted timestamp for when to triggers the notification. */
87
+ trigger_at: string;
88
+ };
89
+ export type CreatePlatformNotificationResponse = {
90
+ id: string;
91
+ };
92
+ export type GetCommittedNotificationsResponse = {
93
+ /** If there are uncommitted notifications for the user */
94
+ uncommitted_messages: boolean;
95
+ };
96
+ /**
97
+ * Get notifications for tenant
98
+ */
99
+ export function findAll({ size, page, createdSince, context, criticality, content, committed, tenantId }: {
100
+ size?: number;
101
+ page?: number;
102
+ createdSince?: number;
103
+ context?: "ACCOUNT" | "STUDIO" | "WORKSPACE" | "AI";
104
+ criticality?: "LOW" | "MEDIUM" | "HIGH";
105
+ content?: string;
106
+ committed?: boolean;
107
+ tenantId: string;
108
+ }, opts?: Oazapfts.RequestOpts) {
109
+ return oazapfts.ok(oazapfts.fetchJson<{
110
+ status: 200;
111
+ data: PagingResponseModelGetTenantNotificationsResponse;
112
+ } | {
113
+ status: 403;
114
+ data: ApiErrorResponse;
115
+ } | {
116
+ status: 500;
117
+ data: ApiErrorResponse;
118
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications${QS.query(QS.explode({
119
+ size,
120
+ page,
121
+ createdSince,
122
+ context,
123
+ criticality,
124
+ content,
125
+ committed
126
+ }))}`, {
127
+ ...opts
128
+ }));
129
+ }
130
+ /**
131
+ * Generate a new notification intent to the specified tenant
132
+ */
133
+ export function create({ tenantId, createTenantNotificationRequest }: {
134
+ tenantId: string;
135
+ createTenantNotificationRequest: CreateTenantNotificationRequest;
136
+ }, opts?: Oazapfts.RequestOpts) {
137
+ return oazapfts.ok(oazapfts.fetchJson<{
138
+ status: 201;
139
+ data: object;
140
+ } | {
141
+ status: 403;
142
+ data: ApiErrorResponse;
143
+ } | {
144
+ status: 500;
145
+ data: ApiErrorResponse;
146
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications`, oazapfts.json({
147
+ ...opts,
148
+ method: "POST",
149
+ body: createTenantNotificationRequest
150
+ })));
151
+ }
152
+ /**
153
+ * Allows to mark a notification as committed
154
+ */
155
+ export function commit({ notificationId, tenantId }: {
156
+ notificationId: string;
157
+ tenantId: string;
158
+ }, opts?: Oazapfts.RequestOpts) {
159
+ return oazapfts.ok(oazapfts.fetchJson<{
160
+ status: 204;
161
+ } | {
162
+ status: 403;
163
+ data: ApiErrorResponse;
164
+ } | {
165
+ status: 500;
166
+ data: ApiErrorResponse;
167
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications/${encodeURIComponent(notificationId)}/commit`, {
168
+ ...opts,
169
+ method: "POST"
170
+ }));
171
+ }
172
+ /**
173
+ * Generate a new notification intent to the specified tenant
174
+ */
175
+ export function create1({ createPlatformNotificationRequest }: {
176
+ createPlatformNotificationRequest: CreatePlatformNotificationRequest;
177
+ }, opts?: Oazapfts.RequestOpts) {
178
+ return oazapfts.ok(oazapfts.fetchJson<{
179
+ status: 200;
180
+ data: CreatePlatformNotificationResponse;
181
+ }>("/v1/notifications", oazapfts.json({
182
+ ...opts,
183
+ method: "POST",
184
+ body: createPlatformNotificationRequest
185
+ })));
186
+ }
187
+ /**
188
+ * Allows to check if there are any uncommitted notifications for the user
189
+ */
190
+ export function committedNotifications({ tenantId }: {
191
+ tenantId: string;
192
+ }, opts?: Oazapfts.RequestOpts) {
193
+ return oazapfts.ok(oazapfts.fetchJson<{
194
+ status: 200;
195
+ data: GetCommittedNotificationsResponse;
196
+ } | {
197
+ status: 403;
198
+ data: ApiErrorResponse;
199
+ } | {
200
+ status: 500;
201
+ data: ApiErrorResponse;
202
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications/committed`, {
203
+ ...opts
204
+ }));
205
+ }
206
+ /**
207
+ * Actuator web endpoint 'health'
208
+ */
209
+ export function health(opts?: Oazapfts.RequestOpts) {
210
+ return oazapfts.ok(oazapfts.fetchJson<{
211
+ status: 200;
212
+ data: object;
213
+ }>("/healthz", {
214
+ ...opts
215
+ }));
216
+ }
217
+ /**
218
+ * Actuator web endpoint 'health-path'
219
+ */
220
+ export function getHealthz(opts?: Oazapfts.RequestOpts) {
221
+ return oazapfts.ok(oazapfts.fetchJson<{
222
+ status: 200;
223
+ data: object;
224
+ }>("/healthz/**", {
225
+ ...opts
226
+ }));
227
+ }
228
+ /**
229
+ * Delete notification by id
230
+ */
231
+ export function deleteV1TenantsByTenantIdNotificationsAndNotificationId({ notificationId, tenantId }: {
232
+ notificationId: string;
233
+ tenantId: string;
234
+ }, opts?: Oazapfts.RequestOpts) {
235
+ return oazapfts.ok(oazapfts.fetchJson<{
236
+ status: 204;
237
+ } | {
238
+ status: 403;
239
+ data: ApiErrorResponse;
240
+ } | {
241
+ status: 500;
242
+ data: ApiErrorResponse;
243
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications/${encodeURIComponent(notificationId)}`, {
244
+ ...opts,
245
+ method: "DELETE"
246
+ }));
247
+ }
248
+ /**
249
+ * Allows to unmark a notification as committed
250
+ */
251
+ export function uncommit({ notificationId, tenantId }: {
252
+ notificationId: string;
253
+ tenantId: string;
254
+ }, opts?: Oazapfts.RequestOpts) {
255
+ return oazapfts.ok(oazapfts.fetchJson<{
256
+ status: 204;
257
+ } | {
258
+ status: 403;
259
+ data: ApiErrorResponse;
260
+ } | {
261
+ status: 500;
262
+ data: ApiErrorResponse;
263
+ }>(`/v1/tenants/${encodeURIComponent(tenantId)}/notifications/${encodeURIComponent(notificationId)}/uncommit`, {
264
+ ...opts,
265
+ method: "DELETE"
266
+ }));
267
+ }
268
+ /**
269
+ * Batches deletes the notification in all tenants
270
+ */
271
+ export function delete1({ notificationId }: {
272
+ notificationId: string;
273
+ }, opts?: Oazapfts.RequestOpts) {
274
+ return oazapfts.ok(oazapfts.fetchText(`/v1/notifications/${encodeURIComponent(notificationId)}`, {
275
+ ...opts,
276
+ method: "DELETE"
277
+ }));
278
+ }
@@ -1047,7 +1047,7 @@ export type ActivityResponse = {
1047
1047
  title?: string;
1048
1048
  version?: string;
1049
1049
  owner?: string;
1050
- status: "SUCCESS" | "FAILED" | "SKIPPED" | "CANCELLED" | "RUNTIME_ERROR" | "INTERNAL_ERROR" | "EXTERNAL_ERROR" | "ABORTED" | "ABORTING" | "SUCCEEDED" | "USER_ERROR" | "DRIFT" | "RUNNING" | "READY_TO_RUN" | "PENDING" | "NONE";
1050
+ status: "SUCCESS" | "FAILED" | "SKIPPED" | "CANCELLED" | "RUNTIME_ERROR" | "INTERNAL_ERROR" | "EXTERNAL_ERROR" | "ABORTED" | "ABORTING" | "SUCCEEDED" | "USER_ERROR" | "DRIFT" | "TIMEOUT" | "RUNNING" | "READY_TO_RUN" | "PENDING" | "NONE";
1051
1051
  "type"?: "DEPLOY" | "ACTION" | "WORKFLOW" | "DRIFT" | "DESTROY" | "ROLLBACK" | "IAC" | "DEPLOY_SELF_HOSTED" | "DESTROY_SELF_HOSTED" | "ROLLBACK_SELF_HOSTED" | "IAC_SELF_HOSTED" | "CUSTOMER_WORKFLOW";
1052
1052
  requestedBy?: string;
1053
1053
  action?: "CREATE" | "UPDATE" | "DELETE" | "RUN";
package/src/apis.json CHANGED
@@ -133,5 +133,13 @@
133
133
  "prd": "https://secrets-api.v1.stackspot.com"
134
134
  },
135
135
  "docs": "/v3/api-docs"
136
+ },
137
+ "notification": {
138
+ "url": {
139
+ "dev": "https://account-notification-engine.dev.stackspot.com",
140
+ "stg": "https://account-notification-engine.stg.stackspot.com",
141
+ "prd": "https://account-notification-engine.stackspot.com"
142
+ },
143
+ "docs": "/v3/api-docs"
136
144
  }
137
145
  }
@@ -47,6 +47,7 @@ import {
47
47
  isCreatedScmCredentials,
48
48
  isCreatedScmCredentials1, listScmCredentials, listScmCredentials1, partialUpdateSso, personalAccessTokenAuthorization,
49
49
  removeRoleFromMember,
50
+ resetOtp,
50
51
  resetPassword, revokeServiceCredential1, save,
51
52
  scmCredentialSave, scmCredentialSave1, scmCredentialUpdate, scmCredentialUpdate1, scmDelete, sendDownloadEmail, ssoAddAttributes,
52
53
  ssoConfigure, ssoGetAttributesConfig, ssoParseConfigurationFile, update1,
@@ -187,6 +188,10 @@ class AccountClient extends ReactQueryNetworkClient {
187
188
  * Sends an e-mail to reset the password of the member with the provided e-mail address.
188
189
  */
189
190
  resetMemberPassword = this.mutation(resetPassword)
191
+ /**
192
+ * Reset member OTP
193
+ */
194
+ resetOtp = this.mutation(resetOtp)
190
195
  /**
191
196
  * Enables Fido credentials for the given member.
192
197
  */
@@ -5,6 +5,7 @@ import { DefaultAPIError } from '../error/DefaultAPIError'
5
5
  import { cntDictionary } from '../error/dictionary/cnt'
6
6
  import { StackspotAPIError } from '../error/StackspotAPIError'
7
7
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+ import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
9
 
9
10
  class ContentClient extends ReactQueryNetworkClient {
10
11
  constructor() {
@@ -33,11 +34,11 @@ class ContentClient extends ReactQueryNetworkClient {
33
34
  /**
34
35
  * Gets all studios
35
36
  */
36
- studios = this.query(getStudios1)
37
+ studios = this.query(removeAuthorizationParam(getStudios1))
37
38
  /**
38
39
  * Gets all studios
39
40
  */
40
- studiosUserHasCreatePermission = this.query(getStudiosToCreateButton)
41
+ studiosUserHasCreatePermission = this.query(removeAuthorizationParam(getStudiosToCreateButton))
41
42
  /**
42
43
  * Gets a studio
43
44
  */
@@ -45,7 +46,7 @@ class ContentClient extends ReactQueryNetworkClient {
45
46
  /**
46
47
  * Creates a studio
47
48
  */
48
- createStudio = this.mutation(createStudio)
49
+ createStudio = this.mutation(removeAuthorizationParam(createStudio))
49
50
  /**
50
51
  * Updates a studio
51
52
  */
@@ -0,0 +1,32 @@
1
+ import { HttpError } from '@oazapfts/runtime'
2
+ import { commit, committedNotifications, defaults, findAll } from '../api/notification'
3
+ import apis from '../apis.json'
4
+ import { DefaultAPIError } from '../error/DefaultAPIError'
5
+ import { baseDictionary } from '../error/dictionary/base'
6
+ import { StackspotAPIError } from '../error/StackspotAPIError'
7
+ import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+
9
+ class NotificationClient extends ReactQueryNetworkClient {
10
+
11
+ constructor() {
12
+ super(apis.notification.url, defaults)
13
+ }
14
+
15
+ protected buildStackSpotError(error: HttpError): StackspotAPIError {
16
+ return new DefaultAPIError(error.data, error.status, baseDictionary, error.headers)
17
+ }
18
+ /**
19
+ * Gets all notification by tenant
20
+ */
21
+ notifications = this.query(findAll)
22
+ /**
23
+ * Gets all committed notifications by tenant
24
+ */
25
+ committedNotifications = this.query(committedNotifications)
26
+ /**
27
+ * Mark a notification as committed (mark as read)
28
+ */
29
+ commit = this.mutation(commit)
30
+ }
31
+
32
+ export const notificationClient = new NotificationClient()
@@ -5,6 +5,7 @@ import { DefaultAPIError } from '../error/DefaultAPIError'
5
5
  import { actionDictionary } from '../error/dictionary/action'
6
6
  import { StackspotAPIError } from '../error/StackspotAPIError'
7
7
  import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
8
+ import { removeAuthorizationParam } from '../utils/remove-authorization-param'
8
9
 
9
10
  class WorkflowClient extends ReactQueryNetworkClient {
10
11
  constructor() {
@@ -18,7 +19,7 @@ class WorkflowClient extends ReactQueryNetworkClient {
18
19
  /**
19
20
  * Runs an action
20
21
  */
21
- runAction = this.mutation(runActionServiceWorkflowsRunActionDispatchPost)
22
+ runAction = this.mutation(removeAuthorizationParam(runActionServiceWorkflowsRunActionDispatchPost))
22
23
 
23
24
  /**
24
25
  * Creates an api
@@ -28,17 +29,17 @@ class WorkflowClient extends ReactQueryNetworkClient {
28
29
  /**
29
30
  * Gets the execution status of a workflow by id
30
31
  */
31
- executionStatus = this.query(getExecutionStatusServiceWorkflowsExecutionStatusExecutionIdGet)
32
+ executionStatus = this.query(removeAuthorizationParam(getExecutionStatusServiceWorkflowsExecutionStatusExecutionIdGet))
32
33
 
33
34
  /**
34
35
  * Gets the execution dispatch service
35
36
  */
36
- executionDispatchInfo = this.query(getExecutionDispatchRequestServiceWorkflowsExecutionIdRequestGet)
37
+ executionDispatchInfo = this.query(removeAuthorizationParam(getExecutionDispatchRequestServiceWorkflowsExecutionIdRequestGet))
37
38
 
38
39
  /**
39
40
  * Gets the health check of an execution id
40
41
  */
41
- executionHealthCheck = this.mutation(healthCheckServiceWorkflowsHealthCheckDispatchPost)
42
+ executionHealthCheck = this.mutation(removeAuthorizationParam(healthCheckServiceWorkflowsHealthCheckDispatchPost))
42
43
  }
43
44
 
44
45
  export const workflowClient = new WorkflowClient()
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export { runtimeManagerClient } from './client/runtime-manager'
7
7
  export { workspaceSearchClient } from './client/workspace-search'
8
8
  export { workflowClient } from './client/workflow'
9
9
  export { eventBusClient } from './client/event-bus'
10
+ export { notificationClient } from './client/notification'
10
11
  export * from './client/types'
11
12
  export { UseQueryObjectOptions } from './network/types'
12
13
  export { DefaultAPIError } from './error/DefaultAPIError'
@@ -0,0 +1,5 @@
1
+ import { FixVariables, OazapftsFunction } from '../client/types'
2
+
3
+ export function removeAuthorizationParam<T extends OazapftsFunction>(fn: T): FixVariables<T, { authorization: never }> {
4
+ return fn
5
+ }