@camunda/camunda-composite-components 0.0.33 → 0.0.35-rc1
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.
- package/lib/esm/api/api.d.ts +2 -1
- package/lib/esm/api/api.js +7 -2
- package/lib/esm/api/endpoints.const.d.ts +8 -0
- package/lib/esm/api/endpoints.const.js +12 -0
- package/lib/esm/api/notifications.js +10 -2
- package/lib/esm/components/c3-navigation/c3-navigation.types.d.ts +3 -2
- package/package.json +1 -1
package/lib/esm/api/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stage } from "./endpoints.const";
|
|
1
|
+
import { Endpoints, Stage } from "./endpoints.const";
|
|
2
2
|
export declare class HttpError extends Error {
|
|
3
3
|
status: number;
|
|
4
4
|
constructor(message: string, status: number);
|
|
@@ -6,6 +6,7 @@ export declare class HttpError extends Error {
|
|
|
6
6
|
export interface RequestPayload {
|
|
7
7
|
base?: "notifications";
|
|
8
8
|
stage?: Stage;
|
|
9
|
+
endpoints?: Endpoints;
|
|
9
10
|
url: string;
|
|
10
11
|
method: "get" | "post" | "put" | "delete" | "patch";
|
|
11
12
|
headers?: {
|
package/lib/esm/api/api.js
CHANGED
|
@@ -31,10 +31,15 @@ export async function request(payload) {
|
|
|
31
31
|
}
|
|
32
32
|
const body = payload.body ? JSON.stringify(payload.body) : undefined;
|
|
33
33
|
let base;
|
|
34
|
-
if (payload.base
|
|
34
|
+
if (payload.base) {
|
|
35
35
|
switch (payload.base) {
|
|
36
36
|
case "notifications":
|
|
37
|
-
|
|
37
|
+
if (payload.endpoints?.notifications) {
|
|
38
|
+
base = payload.endpoints.notifications;
|
|
39
|
+
}
|
|
40
|
+
else if (payload.stage) {
|
|
41
|
+
base = getEndpoint(payload.stage, NOTIFICATIONS);
|
|
42
|
+
}
|
|
38
43
|
break;
|
|
39
44
|
}
|
|
40
45
|
}
|
|
@@ -4,6 +4,14 @@ export interface Endpoint {
|
|
|
4
4
|
int: string;
|
|
5
5
|
prod: string;
|
|
6
6
|
}
|
|
7
|
+
export interface Endpoints {
|
|
8
|
+
notifications?: string;
|
|
9
|
+
}
|
|
7
10
|
export declare const NOTIFICATIONS: Endpoint;
|
|
8
11
|
export declare type Stage = "dev" | "int" | "prod";
|
|
9
12
|
export declare function getEndpoint(stage: Stage, endpoint: Endpoint): string;
|
|
13
|
+
export declare function getEndpointByOptions(options: {
|
|
14
|
+
stage?: Stage;
|
|
15
|
+
endpoints?: Endpoints;
|
|
16
|
+
endpoint: Endpoint;
|
|
17
|
+
}): string;
|
|
@@ -16,3 +16,15 @@ export function getEndpoint(stage, endpoint) {
|
|
|
16
16
|
throw new Error(`Unknown stage: ${stage}`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
+
export function getEndpointByOptions(options) {
|
|
20
|
+
switch (options.endpoint.id) {
|
|
21
|
+
case "notifications":
|
|
22
|
+
if (options.endpoints?.notifications) {
|
|
23
|
+
return options.endpoints.notifications;
|
|
24
|
+
}
|
|
25
|
+
else if (options.stage) {
|
|
26
|
+
return getEndpoint(options.stage, options.endpoint);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Missing stage or notifications endpoint`);
|
|
30
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventSourcePolyfill } from "event-source-polyfill";
|
|
2
2
|
import { request } from "./api";
|
|
3
|
-
import {
|
|
3
|
+
import { getEndpointByOptions, NOTIFICATIONS } from "./endpoints.const";
|
|
4
4
|
export class NotificationService {
|
|
5
5
|
static async getNotifications(options) {
|
|
6
6
|
let notifications = [];
|
|
@@ -9,6 +9,7 @@ export class NotificationService {
|
|
|
9
9
|
method: "get",
|
|
10
10
|
base: "notifications",
|
|
11
11
|
stage: options.stage,
|
|
12
|
+
endpoints: options.endpoints,
|
|
12
13
|
camundaAuth: {
|
|
13
14
|
token: options.userToken,
|
|
14
15
|
refreshTokenMethod: options.getNewUserToken,
|
|
@@ -27,6 +28,7 @@ export class NotificationService {
|
|
|
27
28
|
method: "post",
|
|
28
29
|
base: "notifications",
|
|
29
30
|
stage: options.stage,
|
|
31
|
+
endpoints: options.endpoints,
|
|
30
32
|
camundaAuth: {
|
|
31
33
|
token: options.userToken,
|
|
32
34
|
refreshTokenMethod: options.getNewUserToken,
|
|
@@ -49,6 +51,7 @@ export class NotificationService {
|
|
|
49
51
|
method: "patch",
|
|
50
52
|
base: "notifications",
|
|
51
53
|
stage: options.stage,
|
|
54
|
+
endpoints: options.endpoints,
|
|
52
55
|
camundaAuth: {
|
|
53
56
|
token: options.userToken,
|
|
54
57
|
refreshTokenMethod: options.getNewUserToken,
|
|
@@ -70,6 +73,7 @@ export class NotificationService {
|
|
|
70
73
|
method: "patch",
|
|
71
74
|
base: "notifications",
|
|
72
75
|
stage: options.stage,
|
|
76
|
+
endpoints: options.endpoints,
|
|
73
77
|
camundaAuth: {
|
|
74
78
|
token: options.userToken,
|
|
75
79
|
refreshTokenMethod: options.getNewUserToken,
|
|
@@ -87,7 +91,11 @@ export class NotificationService {
|
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
static notificationsStream(options, handler) {
|
|
90
|
-
const
|
|
94
|
+
const baseUrl = getEndpointByOptions({
|
|
95
|
+
...options,
|
|
96
|
+
endpoint: NOTIFICATIONS,
|
|
97
|
+
});
|
|
98
|
+
const source = new EventSourcePolyfill(`${baseUrl}/notifications/events`, {
|
|
91
99
|
headers: {
|
|
92
100
|
authorization: `Bearer ${options.userToken}`,
|
|
93
101
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Tag } from "@carbon/react";
|
|
3
|
-
import { Stage } from "../../api/endpoints.const";
|
|
3
|
+
import { Endpoints, Stage } from "../../api/endpoints.const";
|
|
4
4
|
import { C3NavigationAppBarProps, C3NavigationInfoSideBarProps, C3NavigationNotificationsSideBarProps, C3NavigationOrgSideBarProps, C3NavigationUserSideBarProps } from "./c3-navigation-sidebar/c3-navigation-sidebar.types";
|
|
5
5
|
export interface C3NavigationAppProps {
|
|
6
6
|
prefix: string;
|
|
@@ -41,7 +41,8 @@ export interface C3NavigationNavBarProps {
|
|
|
41
41
|
orgName?: string;
|
|
42
42
|
}
|
|
43
43
|
export interface C3NotificationsProps {
|
|
44
|
-
stage
|
|
44
|
+
stage?: Stage;
|
|
45
|
+
endpoints?: Endpoints;
|
|
45
46
|
activeOrganizationId: string;
|
|
46
47
|
userToken: string;
|
|
47
48
|
getNewUserToken: () => Promise<string>;
|