hcloud-sdk 14.13.2 → 16.0.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.
- package/changelog.md +60 -806
- package/lib/Hcloud.d.ts +20 -10
- package/lib/Hcloud.js +60 -10
- package/lib/interfaces/auditor/index.d.ts +4 -2
- package/lib/interfaces/bouncer/features/index.d.ts +3 -6
- package/lib/interfaces/frontend/featureflags/index.d.ts +7 -0
- package/lib/interfaces/frontend/featureflags/index.js +2 -0
- package/lib/interfaces/high5/execution/index.d.ts +22 -0
- package/lib/interfaces/high5/execution/index.js +10 -0
- package/lib/interfaces/high5/index.d.ts +2 -2
- package/lib/interfaces/high5/index.js +2 -2
- package/lib/interfaces/high5/space/event/stream/design/StreamDesign.d.ts +1 -0
- package/lib/interfaces/high5/space/event/stream/node/index.d.ts +16 -1
- package/lib/interfaces/high5/space/execution/index.d.ts +14 -0
- package/lib/interfaces/high5/space/pool/index.d.ts +30 -0
- package/lib/interfaces/high5/space/pool/index.js +9 -0
- package/lib/interfaces/high5/wave/changelog.d.ts +30 -0
- package/lib/interfaces/high5/wave/changelog.js +18 -0
- package/lib/interfaces/high5/wave/index.d.ts +48 -1
- package/lib/interfaces/high5/wave/index.js +14 -1
- package/lib/interfaces/idp/organization/member/index.d.ts +2 -0
- package/lib/interfaces/idp/organization/settings/oauthApp/index.d.ts +1 -0
- package/lib/interfaces/idp/user/GeneralSettings.d.ts +1 -0
- package/lib/interfaces/idp/user/Scopes.d.ts +1 -0
- package/lib/interfaces/idp/user/Scopes.js +21 -1
- package/lib/interfaces/idp/user/Totp.d.ts +4 -2
- package/lib/interfaces/idp/user/index.d.ts +1 -0
- package/lib/interfaces/mothership/index.d.ts +1 -0
- package/lib/interfaces/nats/index.d.ts +35 -20
- package/lib/interfaces/nats/index.js +132 -94
- package/lib/service/agent/bundle/dev/index.d.ts +5 -2
- package/lib/service/agent/bundle/dev/index.js +30 -10
- package/lib/service/agent/context/index.d.ts +7 -9
- package/lib/service/agent/context/index.js +41 -32
- package/lib/service/agent/index.d.ts +9 -7
- package/lib/service/agent/index.js +23 -6
- package/lib/service/auditor/index.d.ts +6 -7
- package/lib/service/auditor/index.js +23 -17
- package/lib/service/auditor/internal/index.d.ts +2 -2
- package/lib/service/auditor/internal/index.js +24 -20
- package/lib/service/bouncer/features/index.d.ts +1 -1
- package/lib/service/bouncer/features/index.js +5 -3
- package/lib/service/bouncer/index.d.ts +3 -10
- package/lib/service/bouncer/index.js +6 -21
- package/lib/service/dali/DaliAvatar.d.ts +21 -11
- package/lib/service/dali/DaliAvatar.js +63 -8
- package/lib/service/dali/avatar/DaliFuseSpace.d.ts +5 -7
- package/lib/service/dali/avatar/DaliFuseSpace.js +29 -26
- package/lib/service/dali/avatar/DaliHigh5Pool.d.ts +29 -0
- package/lib/service/dali/avatar/DaliHigh5Pool.js +61 -0
- package/lib/service/dali/avatar/DaliHigh5Space.d.ts +5 -7
- package/lib/service/dali/avatar/DaliHigh5Space.js +29 -26
- package/lib/service/dali/avatar/DaliOAuthApp.d.ts +4 -6
- package/lib/service/dali/avatar/DaliOAuthApp.js +26 -23
- package/lib/service/dali/avatar/DaliOrganization.d.ts +4 -6
- package/lib/service/dali/avatar/DaliOrganization.js +23 -20
- package/lib/service/dali/avatar/DaliTeam.d.ts +4 -6
- package/lib/service/dali/avatar/DaliTeam.js +26 -23
- package/lib/service/dali/avatar/DaliUser.d.ts +4 -6
- package/lib/service/dali/avatar/DaliUser.js +20 -17
- package/lib/service/dali/index.d.ts +4 -5
- package/lib/service/dali/index.js +14 -7
- package/lib/service/fuse/index.d.ts +8 -7
- package/lib/service/fuse/index.js +23 -9
- package/lib/service/fuse/internal/index.d.ts +3 -4
- package/lib/service/fuse/internal/index.js +5 -3
- package/lib/service/fuse/internal/space/cronjob/index.d.ts +3 -4
- package/lib/service/fuse/internal/space/cronjob/index.js +5 -3
- package/lib/service/fuse/internal/space/cronjob/log/index.d.ts +2 -4
- package/lib/service/fuse/internal/space/cronjob/log/index.js +11 -12
- package/lib/service/fuse/internal/space/index.d.ts +5 -6
- package/lib/service/fuse/internal/space/index.js +24 -18
- package/lib/service/fuse/space/cronjob/index.d.ts +15 -15
- package/lib/service/fuse/space/cronjob/index.js +133 -105
- package/lib/service/fuse/space/cronjob/log/index.d.ts +3 -3
- package/lib/service/fuse/space/cronjob/log/index.js +24 -23
- package/lib/service/fuse/space/index.d.ts +13 -14
- package/lib/service/fuse/space/index.js +88 -70
- package/lib/service/high5/execution/index.d.ts +13 -5
- package/lib/service/high5/execution/index.js +32 -4
- package/lib/service/high5/execution/log/index.d.ts +2 -2
- package/lib/service/high5/execution/log/index.js +11 -12
- package/lib/service/high5/execution/status/index.d.ts +2 -2
- package/lib/service/high5/execution/status/index.js +11 -12
- package/lib/service/high5/index.d.ts +12 -9
- package/lib/service/high5/index.js +36 -12
- package/lib/service/high5/internal/index.d.ts +3 -4
- package/lib/service/high5/internal/index.js +5 -3
- package/lib/service/high5/internal/space/index.d.ts +2 -2
- package/lib/service/high5/internal/space/index.js +19 -15
- package/lib/service/high5/joinToken/index.d.ts +4 -4
- package/lib/service/high5/joinToken/index.js +36 -28
- package/lib/service/high5/space/event/index.d.ts +9 -10
- package/lib/service/high5/space/event/index.js +58 -46
- package/lib/service/high5/space/event/stream/design/DesignOperations.d.ts +1 -2
- package/lib/service/high5/space/event/stream/design/DesignOperations.js +2 -0
- package/lib/service/high5/space/event/stream/design/index.d.ts +23 -8
- package/lib/service/high5/space/event/stream/design/index.js +60 -25
- package/lib/service/high5/space/event/stream/design/snapshot/index.d.ts +5 -5
- package/lib/service/high5/space/event/stream/design/snapshot/index.js +65 -58
- package/lib/service/high5/space/event/stream/index.d.ts +14 -15
- package/lib/service/high5/space/event/stream/index.js +125 -103
- package/lib/service/high5/space/execution/index.d.ts +36 -9
- package/lib/service/high5/space/execution/index.js +96 -42
- package/lib/service/high5/space/execution/log/index.d.ts +4 -6
- package/lib/service/high5/space/execution/log/index.js +22 -21
- package/lib/service/high5/space/execution/status/index.d.ts +1 -1
- package/lib/service/high5/space/execution/status/index.js +10 -8
- package/lib/service/high5/space/index.d.ts +28 -21
- package/lib/service/high5/space/index.js +138 -86
- package/lib/service/high5/space/pool/index.d.ts +97 -0
- package/lib/service/high5/space/pool/index.js +171 -0
- package/lib/service/high5/space/secret/index.d.ts +6 -6
- package/lib/service/high5/space/secret/index.js +59 -49
- package/lib/service/high5/space/wave/index.d.ts +7 -9
- package/lib/service/high5/space/wave/index.js +40 -33
- package/lib/service/high5/space/webhook/index.d.ts +21 -14
- package/lib/service/high5/space/webhook/index.js +106 -73
- package/lib/service/high5/space/webhook/log/index.d.ts +2 -4
- package/lib/service/high5/space/webhook/log/index.js +11 -12
- package/lib/service/high5/wave/s3/index.d.ts +14 -7
- package/lib/service/high5/wave/s3/index.js +64 -38
- package/lib/service/idp/index.d.ts +17 -15
- package/lib/service/idp/index.js +104 -56
- package/lib/service/idp/internal/index.d.ts +2 -4
- package/lib/service/idp/internal/index.js +10 -11
- package/lib/service/idp/oauth/index.d.ts +16 -12
- package/lib/service/idp/oauth/index.js +56 -45
- package/lib/service/idp/organization/index.d.ts +12 -10
- package/lib/service/idp/organization/index.js +63 -28
- package/lib/service/idp/organization/license/index.d.ts +2 -2
- package/lib/service/idp/organization/license/index.js +5 -4
- package/lib/service/idp/organization/member/index.d.ts +10 -11
- package/lib/service/idp/organization/member/index.js +62 -48
- package/lib/service/idp/organization/member/invitations/index.d.ts +3 -3
- package/lib/service/idp/organization/member/invitations/index.js +47 -43
- package/lib/service/idp/organization/settings/domain/index.d.ts +7 -8
- package/lib/service/idp/organization/settings/domain/index.js +42 -29
- package/lib/service/idp/organization/settings/domain/saml/index.d.ts +5 -5
- package/lib/service/idp/organization/settings/domain/saml/index.js +58 -48
- package/lib/service/idp/organization/settings/index.d.ts +5 -5
- package/lib/service/idp/organization/settings/index.js +17 -4
- package/lib/service/idp/organization/settings/oauth/index.d.ts +9 -11
- package/lib/service/idp/organization/settings/oauth/index.js +67 -56
- package/lib/service/idp/organization/team/index.d.ts +8 -8
- package/lib/service/idp/organization/team/index.js +64 -55
- package/lib/service/idp/registration/index.d.ts +4 -6
- package/lib/service/idp/registration/index.js +38 -35
- package/lib/service/idp/user/index.d.ts +20 -15
- package/lib/service/idp/user/index.js +94 -51
- package/lib/service/idp/user/license/index.d.ts +2 -2
- package/lib/service/idp/user/license/index.js +5 -4
- package/lib/service/idp/user/password/index.d.ts +1 -1
- package/lib/service/idp/user/password/index.js +10 -11
- package/lib/service/idp/user/settings/connections/index.d.ts +2 -4
- package/lib/service/idp/user/settings/connections/index.js +9 -10
- package/lib/service/idp/user/settings/general/index.d.ts +10 -6
- package/lib/service/idp/user/settings/general/index.js +25 -13
- package/lib/service/idp/user/settings/index.d.ts +13 -9
- package/lib/service/idp/user/settings/index.js +53 -8
- package/lib/service/idp/user/settings/notifications/index.d.ts +3 -5
- package/lib/service/idp/user/settings/notifications/index.js +14 -13
- package/lib/service/idp/user/settings/oauthApps/index.d.ts +3 -5
- package/lib/service/idp/user/settings/oauthApps/index.js +17 -16
- package/lib/service/idp/user/settings/pats/index.d.ts +8 -10
- package/lib/service/idp/user/settings/pats/index.js +55 -44
- package/lib/service/idp/user/settings/twoFactor/index.d.ts +3 -4
- package/lib/service/idp/user/settings/twoFactor/index.js +8 -3
- package/lib/service/idp/user/settings/twoFactor/totp/index.d.ts +7 -9
- package/lib/service/idp/user/settings/twoFactor/totp/index.js +36 -29
- package/lib/service/mailer/index.d.ts +4 -5
- package/lib/service/mailer/index.js +12 -8
- package/lib/service/mailer/internal/index.d.ts +4 -4
- package/lib/service/mailer/internal/index.js +38 -33
- package/lib/service/mothership/index.d.ts +12 -12
- package/lib/service/mothership/index.js +92 -79
- package/lib/service/nats/index.d.ts +1 -3
- package/lib/service/nats/index.js +2 -2
- package/lib/utils/bouncer/features/Provider.d.ts +3 -0
- package/lib/utils/bouncer/features/Provider.js +20 -2
- package/package.json +1 -1
|
@@ -13,25 +13,26 @@ const Base_1 = require("../../Base");
|
|
|
13
13
|
const paginatedResponseHelper_1 = require("../../helper/paginatedResponseHelper");
|
|
14
14
|
const searchFilter_1 = require("../../helper/searchFilter");
|
|
15
15
|
class MothershipService extends Base_1.default {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.version = () => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
/**
|
|
17
|
+
* Requests the endpoint version
|
|
18
|
+
* @returns Version object
|
|
19
|
+
*/
|
|
20
|
+
version() {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
22
|
const resp = yield this.axios.get(this.getEndpoint("/v1/version"));
|
|
24
23
|
return resp.data;
|
|
25
24
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Say hello as an agent to the mothership
|
|
28
|
+
*
|
|
29
|
+
* @param uuid Agent's UUID
|
|
30
|
+
* @param uuidSignature HMAC-SHA256 hash of the Agent's UUID using the Agent's secret as the key
|
|
31
|
+
* @param info Information about the agent's uuid, hardware and nickname
|
|
32
|
+
* @return an Agent object
|
|
33
|
+
*/
|
|
34
|
+
hello(uuid, uuidSignature, info) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
36
|
const resp = yield this.axios.post(this.getEndpoint("/v1/hello"), info, {
|
|
36
37
|
headers: {
|
|
37
38
|
Authorization: `Bearer ${uuid}.${uuidSignature}`,
|
|
@@ -39,84 +40,96 @@ class MothershipService extends Base_1.default {
|
|
|
39
40
|
});
|
|
40
41
|
return { agent: resp.data, token: resp.headers.authorization };
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Say hello again as an agent to the mothership.
|
|
46
|
+
*
|
|
47
|
+
* This call should only be made after an initial hello.
|
|
48
|
+
*
|
|
49
|
+
* The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
|
|
50
|
+
*
|
|
51
|
+
* @param info Information about the agent's system resources.
|
|
52
|
+
* @return an Agent object
|
|
53
|
+
*/
|
|
54
|
+
helloAgain(info) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
56
|
const resp = yield this.axios.patch(this.getEndpoint("/v1/hello/again"), info);
|
|
54
57
|
return resp.data;
|
|
55
58
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Register an agent to the mothership.
|
|
62
|
+
*
|
|
63
|
+
* This call should only be made once per agent, not once per agent session.
|
|
64
|
+
*
|
|
65
|
+
* @param uuid UUID of the Agent
|
|
66
|
+
* @param info Information about the agent's hardware and nickname.
|
|
67
|
+
* @param publicKey the public key of the agent that will be used for cryptography. The agent should remember its private key.
|
|
68
|
+
* @return an object holding a secret encrypted with the public key. The agent must decrypt it using its private key in order to use the /hello endpoint.
|
|
69
|
+
*/
|
|
70
|
+
// eslint-disable-next-line complexity
|
|
71
|
+
register(uuid, info, publicKey) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
73
|
if (typeof publicKey !== "string") {
|
|
69
74
|
publicKey = publicKey.toString("hex");
|
|
70
75
|
}
|
|
71
76
|
const resp = yield this.axios.post(this.getEndpoint("/v1/register"), Object.assign({ uuid, publicKey }, info));
|
|
72
77
|
return resp.data;
|
|
73
78
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Connect to an organization.
|
|
82
|
+
*
|
|
83
|
+
* This call should only be made after an initial hello.
|
|
84
|
+
*
|
|
85
|
+
* The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
|
|
86
|
+
*
|
|
87
|
+
* @param orgName Name of the organization
|
|
88
|
+
* @param memberToken JWT assigned to a member of the organization
|
|
89
|
+
* @param email Email of the user owner of the JWT
|
|
90
|
+
*/
|
|
91
|
+
connect(orgName, memberToken, email) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
93
|
yield this.axios.post(this.getEndpoint(`/v1/org/${orgName}/connect`), { memberToken, email });
|
|
87
94
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Disconnect from an organization.
|
|
98
|
+
*
|
|
99
|
+
* This call should only be made after an initial hello.
|
|
100
|
+
*
|
|
101
|
+
* The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
|
|
102
|
+
*
|
|
103
|
+
* @param orgName Name of the organization
|
|
104
|
+
* @param email Email of the user
|
|
105
|
+
*/
|
|
106
|
+
disconnect(orgName, email) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
108
|
yield this.axios.delete(this.getEndpoint(`/v1/org/${orgName}/connect/${email}`));
|
|
100
109
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Disconnect as a target.
|
|
113
|
+
*
|
|
114
|
+
* This call should only be made after an initial hello.
|
|
115
|
+
*
|
|
116
|
+
* The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
|
|
117
|
+
*
|
|
118
|
+
* @param email Email of the target
|
|
119
|
+
*/
|
|
120
|
+
disconnectTarget(email) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
122
|
yield this.axios.delete(this.getEndpoint(`/v1/connect/${email}`));
|
|
112
123
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Search among the available targets for a given organization.
|
|
127
|
+
*
|
|
128
|
+
* @param orgName Name of the organization
|
|
129
|
+
* @returns Object containing an array of retrieved agents and the total number of available found in the database (independent of limit and page)
|
|
130
|
+
*/
|
|
131
|
+
searchAvailableTargets(_a) {
|
|
132
|
+
return __awaiter(this, arguments, void 0, function* ({ orgName, filters, sorting, limit = 25, page = 0, }) {
|
|
120
133
|
const filtersDTO = filters === null || filters === void 0 ? void 0 : filters.map((f) => {
|
|
121
134
|
return new searchFilter_1.SearchFilterDTO(f);
|
|
122
135
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios";
|
|
2
1
|
import { Msg, NatsConnection, PublishOptions, RequestOptions, Subscription, SubscriptionOptions } from "nats";
|
|
3
|
-
import Base
|
|
2
|
+
import Base from "../../Base";
|
|
4
3
|
import { NatsCallback, NatsMessageType, NatsObject, NatsObjectType, RawMsg } from "../../interfaces/nats";
|
|
5
4
|
/**
|
|
6
5
|
* Connect and authenticate using email and jwt
|
|
@@ -37,7 +36,6 @@ declare class Nats extends Base {
|
|
|
37
36
|
private natsConnection;
|
|
38
37
|
private subMap;
|
|
39
38
|
private connection;
|
|
40
|
-
constructor(options: Options, axios: AxiosInstance);
|
|
41
39
|
connect(params: ConnectParamsJwt | ConnectParamsPassword): Promise<NatsConnection>;
|
|
42
40
|
getConnection: () => NatsConnection | undefined;
|
|
43
41
|
sub(subject: string, callback: NatsCallback, options?: SubscriptionOptions): Promise<Subscription>;
|
|
@@ -14,8 +14,8 @@ const nats_ws_1 = require("nats.ws");
|
|
|
14
14
|
const Base_1 = require("../../Base");
|
|
15
15
|
const isBrowser = typeof window !== "undefined";
|
|
16
16
|
class Nats extends Base_1.default {
|
|
17
|
-
constructor(
|
|
18
|
-
super(
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
19
|
this.subMap = [];
|
|
20
20
|
this.connection = isBrowser ? nats_ws_1.connect : nats_1.connect;
|
|
21
21
|
this.getConnection = () => {
|
|
@@ -4,8 +4,11 @@ export declare class BouncerProvider {
|
|
|
4
4
|
private features;
|
|
5
5
|
private context?;
|
|
6
6
|
private logger?;
|
|
7
|
+
private refs;
|
|
7
8
|
constructor(features: HcloudFeature[], context?: BouncerContext, logger?: BouncerProviderLogger);
|
|
8
9
|
isEnabled(featureName: string, defaultValue: boolean, context?: BouncerContext): boolean;
|
|
10
|
+
isEnabledFn(featureName: string, defaultValue: boolean, fn: (val: boolean) => void, context?: BouncerContext): boolean;
|
|
11
|
+
processRefs(): void;
|
|
9
12
|
addFeature(feature: HcloudFeature): void;
|
|
10
13
|
setFeatures(features: HcloudFeature[]): void;
|
|
11
14
|
setContext(context: BouncerContext): void;
|
|
@@ -3,17 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BouncerProvider = void 0;
|
|
4
4
|
class BouncerProvider {
|
|
5
5
|
constructor(features, context, logger) {
|
|
6
|
+
// refs holds a list of previous isEnabledFn requests
|
|
7
|
+
// with their according callback function (fn)
|
|
8
|
+
// that is being called whenever features or the context has changed
|
|
9
|
+
this.refs = [];
|
|
6
10
|
this.features = features;
|
|
7
11
|
this.context = context;
|
|
8
12
|
this.logger = logger;
|
|
9
13
|
}
|
|
10
14
|
/* eslint-disable complexity */
|
|
11
15
|
isEnabled(featureName, defaultValue, context) {
|
|
12
|
-
const feature = this.features.find(f => f.
|
|
16
|
+
const feature = this.features.find(f => f.name === featureName);
|
|
13
17
|
let result = defaultValue;
|
|
14
18
|
if (feature) {
|
|
15
19
|
result =
|
|
16
|
-
feature.
|
|
20
|
+
feature.enabled &&
|
|
17
21
|
this.doesMatchOrganization(feature, context !== null && context !== void 0 ? context : this.context) &&
|
|
18
22
|
this.doesMatchUser(feature, context !== null && context !== void 0 ? context : this.context) &&
|
|
19
23
|
this.doesMatchRegion(feature, context !== null && context !== void 0 ? context : this.context);
|
|
@@ -23,14 +27,27 @@ class BouncerProvider {
|
|
|
23
27
|
}
|
|
24
28
|
return result;
|
|
25
29
|
}
|
|
30
|
+
isEnabledFn(featureName, defaultValue, fn, context) {
|
|
31
|
+
this.refs.push({ featureName, defaultValue, fn, context });
|
|
32
|
+
return this.isEnabled(featureName, defaultValue, context);
|
|
33
|
+
}
|
|
34
|
+
// processRefs iterates over all refs and calls their callback function with the result of isEnabled
|
|
35
|
+
processRefs() {
|
|
36
|
+
this.refs.forEach(ref => {
|
|
37
|
+
ref.fn(this.isEnabled(ref.featureName, ref.defaultValue, ref.context));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
26
40
|
addFeature(feature) {
|
|
27
41
|
this.features.push(feature);
|
|
42
|
+
this.processRefs();
|
|
28
43
|
}
|
|
29
44
|
setFeatures(features) {
|
|
30
45
|
this.features = features;
|
|
46
|
+
this.processRefs();
|
|
31
47
|
}
|
|
32
48
|
setContext(context) {
|
|
33
49
|
this.context = context;
|
|
50
|
+
this.processRefs();
|
|
34
51
|
}
|
|
35
52
|
updateContext({ region, email, organization }) {
|
|
36
53
|
if (!this.context) {
|
|
@@ -45,6 +62,7 @@ class BouncerProvider {
|
|
|
45
62
|
this.context.organization = organization !== null && organization !== void 0 ? organization : this.context.organization;
|
|
46
63
|
this.context.region = region !== null && region !== void 0 ? region : this.context.region;
|
|
47
64
|
}
|
|
65
|
+
this.processRefs();
|
|
48
66
|
}
|
|
49
67
|
/* eslint-disable @typescript-eslint/no-non-null-assertion*/
|
|
50
68
|
doesMatchRegion(feature, context) {
|