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.
Files changed (181) hide show
  1. package/changelog.md +60 -806
  2. package/lib/Hcloud.d.ts +20 -10
  3. package/lib/Hcloud.js +60 -10
  4. package/lib/interfaces/auditor/index.d.ts +4 -2
  5. package/lib/interfaces/bouncer/features/index.d.ts +3 -6
  6. package/lib/interfaces/frontend/featureflags/index.d.ts +7 -0
  7. package/lib/interfaces/frontend/featureflags/index.js +2 -0
  8. package/lib/interfaces/high5/execution/index.d.ts +22 -0
  9. package/lib/interfaces/high5/execution/index.js +10 -0
  10. package/lib/interfaces/high5/index.d.ts +2 -2
  11. package/lib/interfaces/high5/index.js +2 -2
  12. package/lib/interfaces/high5/space/event/stream/design/StreamDesign.d.ts +1 -0
  13. package/lib/interfaces/high5/space/event/stream/node/index.d.ts +16 -1
  14. package/lib/interfaces/high5/space/execution/index.d.ts +14 -0
  15. package/lib/interfaces/high5/space/pool/index.d.ts +30 -0
  16. package/lib/interfaces/high5/space/pool/index.js +9 -0
  17. package/lib/interfaces/high5/wave/changelog.d.ts +30 -0
  18. package/lib/interfaces/high5/wave/changelog.js +18 -0
  19. package/lib/interfaces/high5/wave/index.d.ts +48 -1
  20. package/lib/interfaces/high5/wave/index.js +14 -1
  21. package/lib/interfaces/idp/organization/member/index.d.ts +2 -0
  22. package/lib/interfaces/idp/organization/settings/oauthApp/index.d.ts +1 -0
  23. package/lib/interfaces/idp/user/GeneralSettings.d.ts +1 -0
  24. package/lib/interfaces/idp/user/Scopes.d.ts +1 -0
  25. package/lib/interfaces/idp/user/Scopes.js +21 -1
  26. package/lib/interfaces/idp/user/Totp.d.ts +4 -2
  27. package/lib/interfaces/idp/user/index.d.ts +1 -0
  28. package/lib/interfaces/mothership/index.d.ts +1 -0
  29. package/lib/interfaces/nats/index.d.ts +35 -20
  30. package/lib/interfaces/nats/index.js +132 -94
  31. package/lib/service/agent/bundle/dev/index.d.ts +5 -2
  32. package/lib/service/agent/bundle/dev/index.js +30 -10
  33. package/lib/service/agent/context/index.d.ts +7 -9
  34. package/lib/service/agent/context/index.js +41 -32
  35. package/lib/service/agent/index.d.ts +9 -7
  36. package/lib/service/agent/index.js +23 -6
  37. package/lib/service/auditor/index.d.ts +6 -7
  38. package/lib/service/auditor/index.js +23 -17
  39. package/lib/service/auditor/internal/index.d.ts +2 -2
  40. package/lib/service/auditor/internal/index.js +24 -20
  41. package/lib/service/bouncer/features/index.d.ts +1 -1
  42. package/lib/service/bouncer/features/index.js +5 -3
  43. package/lib/service/bouncer/index.d.ts +3 -10
  44. package/lib/service/bouncer/index.js +6 -21
  45. package/lib/service/dali/DaliAvatar.d.ts +21 -11
  46. package/lib/service/dali/DaliAvatar.js +63 -8
  47. package/lib/service/dali/avatar/DaliFuseSpace.d.ts +5 -7
  48. package/lib/service/dali/avatar/DaliFuseSpace.js +29 -26
  49. package/lib/service/dali/avatar/DaliHigh5Pool.d.ts +29 -0
  50. package/lib/service/dali/avatar/DaliHigh5Pool.js +61 -0
  51. package/lib/service/dali/avatar/DaliHigh5Space.d.ts +5 -7
  52. package/lib/service/dali/avatar/DaliHigh5Space.js +29 -26
  53. package/lib/service/dali/avatar/DaliOAuthApp.d.ts +4 -6
  54. package/lib/service/dali/avatar/DaliOAuthApp.js +26 -23
  55. package/lib/service/dali/avatar/DaliOrganization.d.ts +4 -6
  56. package/lib/service/dali/avatar/DaliOrganization.js +23 -20
  57. package/lib/service/dali/avatar/DaliTeam.d.ts +4 -6
  58. package/lib/service/dali/avatar/DaliTeam.js +26 -23
  59. package/lib/service/dali/avatar/DaliUser.d.ts +4 -6
  60. package/lib/service/dali/avatar/DaliUser.js +20 -17
  61. package/lib/service/dali/index.d.ts +4 -5
  62. package/lib/service/dali/index.js +14 -7
  63. package/lib/service/fuse/index.d.ts +8 -7
  64. package/lib/service/fuse/index.js +23 -9
  65. package/lib/service/fuse/internal/index.d.ts +3 -4
  66. package/lib/service/fuse/internal/index.js +5 -3
  67. package/lib/service/fuse/internal/space/cronjob/index.d.ts +3 -4
  68. package/lib/service/fuse/internal/space/cronjob/index.js +5 -3
  69. package/lib/service/fuse/internal/space/cronjob/log/index.d.ts +2 -4
  70. package/lib/service/fuse/internal/space/cronjob/log/index.js +11 -12
  71. package/lib/service/fuse/internal/space/index.d.ts +5 -6
  72. package/lib/service/fuse/internal/space/index.js +24 -18
  73. package/lib/service/fuse/space/cronjob/index.d.ts +15 -15
  74. package/lib/service/fuse/space/cronjob/index.js +133 -105
  75. package/lib/service/fuse/space/cronjob/log/index.d.ts +3 -3
  76. package/lib/service/fuse/space/cronjob/log/index.js +24 -23
  77. package/lib/service/fuse/space/index.d.ts +13 -14
  78. package/lib/service/fuse/space/index.js +88 -70
  79. package/lib/service/high5/execution/index.d.ts +13 -5
  80. package/lib/service/high5/execution/index.js +32 -4
  81. package/lib/service/high5/execution/log/index.d.ts +2 -2
  82. package/lib/service/high5/execution/log/index.js +11 -12
  83. package/lib/service/high5/execution/status/index.d.ts +2 -2
  84. package/lib/service/high5/execution/status/index.js +11 -12
  85. package/lib/service/high5/index.d.ts +12 -9
  86. package/lib/service/high5/index.js +36 -12
  87. package/lib/service/high5/internal/index.d.ts +3 -4
  88. package/lib/service/high5/internal/index.js +5 -3
  89. package/lib/service/high5/internal/space/index.d.ts +2 -2
  90. package/lib/service/high5/internal/space/index.js +19 -15
  91. package/lib/service/high5/joinToken/index.d.ts +4 -4
  92. package/lib/service/high5/joinToken/index.js +36 -28
  93. package/lib/service/high5/space/event/index.d.ts +9 -10
  94. package/lib/service/high5/space/event/index.js +58 -46
  95. package/lib/service/high5/space/event/stream/design/DesignOperations.d.ts +1 -2
  96. package/lib/service/high5/space/event/stream/design/DesignOperations.js +2 -0
  97. package/lib/service/high5/space/event/stream/design/index.d.ts +23 -8
  98. package/lib/service/high5/space/event/stream/design/index.js +60 -25
  99. package/lib/service/high5/space/event/stream/design/snapshot/index.d.ts +5 -5
  100. package/lib/service/high5/space/event/stream/design/snapshot/index.js +65 -58
  101. package/lib/service/high5/space/event/stream/index.d.ts +14 -15
  102. package/lib/service/high5/space/event/stream/index.js +125 -103
  103. package/lib/service/high5/space/execution/index.d.ts +36 -9
  104. package/lib/service/high5/space/execution/index.js +96 -42
  105. package/lib/service/high5/space/execution/log/index.d.ts +4 -6
  106. package/lib/service/high5/space/execution/log/index.js +22 -21
  107. package/lib/service/high5/space/execution/status/index.d.ts +1 -1
  108. package/lib/service/high5/space/execution/status/index.js +10 -8
  109. package/lib/service/high5/space/index.d.ts +28 -21
  110. package/lib/service/high5/space/index.js +138 -86
  111. package/lib/service/high5/space/pool/index.d.ts +97 -0
  112. package/lib/service/high5/space/pool/index.js +171 -0
  113. package/lib/service/high5/space/secret/index.d.ts +6 -6
  114. package/lib/service/high5/space/secret/index.js +59 -49
  115. package/lib/service/high5/space/wave/index.d.ts +7 -9
  116. package/lib/service/high5/space/wave/index.js +40 -33
  117. package/lib/service/high5/space/webhook/index.d.ts +21 -14
  118. package/lib/service/high5/space/webhook/index.js +106 -73
  119. package/lib/service/high5/space/webhook/log/index.d.ts +2 -4
  120. package/lib/service/high5/space/webhook/log/index.js +11 -12
  121. package/lib/service/high5/wave/s3/index.d.ts +14 -7
  122. package/lib/service/high5/wave/s3/index.js +64 -38
  123. package/lib/service/idp/index.d.ts +17 -15
  124. package/lib/service/idp/index.js +104 -56
  125. package/lib/service/idp/internal/index.d.ts +2 -4
  126. package/lib/service/idp/internal/index.js +10 -11
  127. package/lib/service/idp/oauth/index.d.ts +16 -12
  128. package/lib/service/idp/oauth/index.js +56 -45
  129. package/lib/service/idp/organization/index.d.ts +12 -10
  130. package/lib/service/idp/organization/index.js +63 -28
  131. package/lib/service/idp/organization/license/index.d.ts +2 -2
  132. package/lib/service/idp/organization/license/index.js +5 -4
  133. package/lib/service/idp/organization/member/index.d.ts +10 -11
  134. package/lib/service/idp/organization/member/index.js +62 -48
  135. package/lib/service/idp/organization/member/invitations/index.d.ts +3 -3
  136. package/lib/service/idp/organization/member/invitations/index.js +47 -43
  137. package/lib/service/idp/organization/settings/domain/index.d.ts +7 -8
  138. package/lib/service/idp/organization/settings/domain/index.js +42 -29
  139. package/lib/service/idp/organization/settings/domain/saml/index.d.ts +5 -5
  140. package/lib/service/idp/organization/settings/domain/saml/index.js +58 -48
  141. package/lib/service/idp/organization/settings/index.d.ts +5 -5
  142. package/lib/service/idp/organization/settings/index.js +17 -4
  143. package/lib/service/idp/organization/settings/oauth/index.d.ts +9 -11
  144. package/lib/service/idp/organization/settings/oauth/index.js +67 -56
  145. package/lib/service/idp/organization/team/index.d.ts +8 -8
  146. package/lib/service/idp/organization/team/index.js +64 -55
  147. package/lib/service/idp/registration/index.d.ts +4 -6
  148. package/lib/service/idp/registration/index.js +38 -35
  149. package/lib/service/idp/user/index.d.ts +20 -15
  150. package/lib/service/idp/user/index.js +94 -51
  151. package/lib/service/idp/user/license/index.d.ts +2 -2
  152. package/lib/service/idp/user/license/index.js +5 -4
  153. package/lib/service/idp/user/password/index.d.ts +1 -1
  154. package/lib/service/idp/user/password/index.js +10 -11
  155. package/lib/service/idp/user/settings/connections/index.d.ts +2 -4
  156. package/lib/service/idp/user/settings/connections/index.js +9 -10
  157. package/lib/service/idp/user/settings/general/index.d.ts +10 -6
  158. package/lib/service/idp/user/settings/general/index.js +25 -13
  159. package/lib/service/idp/user/settings/index.d.ts +13 -9
  160. package/lib/service/idp/user/settings/index.js +53 -8
  161. package/lib/service/idp/user/settings/notifications/index.d.ts +3 -5
  162. package/lib/service/idp/user/settings/notifications/index.js +14 -13
  163. package/lib/service/idp/user/settings/oauthApps/index.d.ts +3 -5
  164. package/lib/service/idp/user/settings/oauthApps/index.js +17 -16
  165. package/lib/service/idp/user/settings/pats/index.d.ts +8 -10
  166. package/lib/service/idp/user/settings/pats/index.js +55 -44
  167. package/lib/service/idp/user/settings/twoFactor/index.d.ts +3 -4
  168. package/lib/service/idp/user/settings/twoFactor/index.js +8 -3
  169. package/lib/service/idp/user/settings/twoFactor/totp/index.d.ts +7 -9
  170. package/lib/service/idp/user/settings/twoFactor/totp/index.js +36 -29
  171. package/lib/service/mailer/index.d.ts +4 -5
  172. package/lib/service/mailer/index.js +12 -8
  173. package/lib/service/mailer/internal/index.d.ts +4 -4
  174. package/lib/service/mailer/internal/index.js +38 -33
  175. package/lib/service/mothership/index.d.ts +12 -12
  176. package/lib/service/mothership/index.js +92 -79
  177. package/lib/service/nats/index.d.ts +1 -3
  178. package/lib/service/nats/index.js +2 -2
  179. package/lib/utils/bouncer/features/Provider.d.ts +3 -0
  180. package/lib/utils/bouncer/features/Provider.js +20 -2
  181. 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
- constructor(options, axios) {
17
- super(options, axios);
18
- /**
19
- * Requests the endpoint version
20
- * @returns Version object
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
- * 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
- this.hello = (uuid, uuidSignature, info) => __awaiter(this, void 0, void 0, function* () {
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
- * Say hello again as an agent to the mothership.
44
- *
45
- * This call should only be made after an initial hello.
46
- *
47
- * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
48
- *
49
- * @param info Information about the agent's system resources.
50
- * @return an Agent object
51
- */
52
- this.helloAgain = (info) => __awaiter(this, void 0, void 0, function* () {
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
- * Register an agent to the mothership.
58
- *
59
- * This call should only be made once per agent, not once per agent session.
60
- *
61
- * @param uuid UUID of the Agent
62
- * @param info Information about the agent's hardware and nickname.
63
- * @param publicKey the public key of the agent that will be used for cryptography. The agent should remember its private key.
64
- * @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.
65
- */
66
- // eslint-disable-next-line complexity
67
- this.register = (uuid, info, publicKey) => __awaiter(this, void 0, void 0, function* () {
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
- * Connect to an organization.
76
- *
77
- * This call should only be made after an initial hello.
78
- *
79
- * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
80
- *
81
- * @param orgName Name of the organization
82
- * @param memberToken JWT assigned to a member of the organization
83
- * @param email Email of the user owner of the JWT
84
- */
85
- this.connect = (orgName, memberToken, email) => __awaiter(this, void 0, void 0, function* () {
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
- * Disconnect from an organization.
90
- *
91
- * This call should only be made after an initial hello.
92
- *
93
- * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
94
- *
95
- * @param orgName Name of the organization
96
- * @param email Email of the user
97
- */
98
- this.disconnect = (orgName, email) => __awaiter(this, void 0, void 0, function* () {
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
- * Disconnect as a target.
103
- *
104
- * This call should only be made after an initial hello.
105
- *
106
- * The session token obtained in the hello endpoint must be used here. Use the setAuthToken method to do so.
107
- *
108
- * @param email Email of the target
109
- */
110
- this.disconnectTarget = (email) => __awaiter(this, void 0, void 0, function* () {
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
- * Search among the available targets for a given organization.
115
- *
116
- * @param orgName Name of the organization
117
- * @returns Object containing an array of retrieved agents and the total number of available found in the database (independent of limit and page)
118
- */
119
- this.searchAvailableTargets = (_a) => __awaiter(this, [_a], void 0, function* ({ orgName, filters, sorting, limit = 25, page = 0, }) {
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, { Options } from "../../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(options, axios) {
18
- super(options, axios);
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.feature.name === featureName);
16
+ const feature = this.features.find(f => f.name === featureName);
13
17
  let result = defaultValue;
14
18
  if (feature) {
15
19
  result =
16
- feature.feature.enabled &&
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hcloud-sdk",
3
- "version": "14.13.2",
3
+ "version": "16.0.0",
4
4
  "description": "hcloud platform sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",