hcloud-sdk 21.1.0 → 21.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 (40) hide show
  1. package/changelog.md +6 -2
  2. package/lib/helper/ValidationHelper.d.ts +1 -0
  3. package/lib/helper/ValidationHelper.js +10 -2
  4. package/lib/interfaces/auditor/index.d.ts +2 -1
  5. package/lib/interfaces/auditor/index.js +1 -0
  6. package/lib/interfaces/cosmo/asset/index.d.ts +20 -2
  7. package/lib/interfaces/cosmo/comment/index.d.ts +3 -1
  8. package/lib/interfaces/cosmo/share/index.d.ts +4 -0
  9. package/lib/interfaces/cosmo/space/index.d.ts +1 -31
  10. package/lib/interfaces/cosmo/space/index.js +0 -6
  11. package/lib/interfaces/global/Storage.d.ts +40 -0
  12. package/lib/interfaces/global/Storage.js +2 -0
  13. package/lib/interfaces/high5/space/request.d.ts +0 -1
  14. package/lib/interfaces/high5/wave/Wave.d.ts +144 -0
  15. package/lib/interfaces/high5/wave/Wave.js +120 -0
  16. package/lib/interfaces/idp/organization/license/index.d.ts +6 -0
  17. package/lib/interfaces/idp/organization/settings/domain/oidc/index.d.ts +9 -0
  18. package/lib/interfaces/idp/organization/settings/domain/oidc/index.js +2 -0
  19. package/lib/interfaces/idp/user/Message.d.ts +27 -7
  20. package/lib/interfaces/idp/user/Message.js +20 -3
  21. package/lib/service/cosmo/asset/index.d.ts +7 -34
  22. package/lib/service/cosmo/asset/index.js +2 -36
  23. package/lib/service/cosmo/comment/index.d.ts +24 -0
  24. package/lib/service/cosmo/comment/index.js +32 -0
  25. package/lib/service/cosmo/organization/index.d.ts +30 -0
  26. package/lib/service/cosmo/organization/index.js +34 -0
  27. package/lib/service/cosmo/space/index.d.ts +1 -25
  28. package/lib/service/cosmo/space/index.js +0 -30
  29. package/lib/service/idp/index.d.ts +1 -1
  30. package/lib/service/idp/index.js +2 -1
  31. package/lib/service/idp/organization/index.d.ts +6 -0
  32. package/lib/service/idp/organization/index.js +10 -0
  33. package/lib/service/idp/organization/settings/domain/oidc/index.d.ts +41 -0
  34. package/lib/service/idp/organization/settings/domain/oidc/index.js +70 -0
  35. package/lib/service/idp/organization/storage/index.d.ts +56 -0
  36. package/lib/service/idp/organization/storage/index.js +93 -0
  37. package/lib/service/idp/user/message/index.d.ts +33 -8
  38. package/lib/service/idp/user/message/index.js +31 -3
  39. package/lib/service/nats/index.js +4 -5
  40. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.IdpOrganizationStorages = void 0;
16
+ const Base_1 = __importDefault(require("../../../../Base"));
17
+ const paginatedResponseHelper_1 = require("../../../../helper/paginatedResponseHelper");
18
+ const searchFilter_1 = require("../../../../helper/searchFilter");
19
+ class IdpOrganizationStorages extends Base_1.default {
20
+ /**
21
+ * Creates a new Storage in the specified Organization.
22
+ * @param orgName Name of the Organization
23
+ * @param storageCreate Storage creation data
24
+ * @returns The created Storage
25
+ */
26
+ createStorage(orgName, storageCreate, raw) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const resp = yield this.axios.post(this.getEndpoint(`/${orgName}/storage`), storageCreate);
29
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
30
+ });
31
+ }
32
+ /**
33
+ * Updates an existing Storage.
34
+ * @param orgName Name of the Organization
35
+ * @param storageId ID of the Storage
36
+ * @param storagePatchDto Storage patch data
37
+ * @param raw (optional) If true, returns the raw Axios response instead of the data
38
+ * @returns The updated Storage object
39
+ */
40
+ patchStorage(orgName, storageId, storagePatchDto, raw) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const resp = yield this.axios.patch(this.getEndpoint(`/${orgName}/storage/${storageId}`), storagePatchDto);
43
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
44
+ });
45
+ }
46
+ /**
47
+ * Retrieves all Storages of an Organization that match the provided search filter(s). Returns all Storages if no search filter is provided.
48
+ * @param orgName Name of the organization
49
+ * @param filters (optional) Array of search filters
50
+ * @param sorting (optional) Sorting object
51
+ * @param limit (optional) Max number of results (1-100; defaults to 25)
52
+ * @param page (optional) Page number: Skip the first (page * limit) results (defaults to 0)
53
+ * @returns Object containing an array of Storages and the total number of results found in the database (independent of limit and page)
54
+ */
55
+ searchStorages(params, raw) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const limit = params.limit || 25;
58
+ const page = params.page || 0;
59
+ const filtersDTO = params.filters.map((f) => {
60
+ return new searchFilter_1.SearchFilterDTO(f);
61
+ });
62
+ const resp = yield this.axios.post(this.getEndpoint(`/${params.orgName}/storage/search?limit=${limit}&page=${page}`), {
63
+ filters: filtersDTO,
64
+ sorting: params.sorting,
65
+ });
66
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? Object.assign(Object.assign({}, resp), { data: (0, paginatedResponseHelper_1.createPaginatedResponse)(resp) }) : (0, paginatedResponseHelper_1.createPaginatedResponse)(resp));
67
+ });
68
+ }
69
+ /**
70
+ * Retrieves the Storage configuration for the specified Storage ID or the default Storage if no ID is provided. Requires a Personal Access Token (PAT) with appropriate permissions.
71
+ *
72
+ * @param pat Personal Access Token
73
+ * @param storageId (optional) ID of storage. If not provided or "default", retrieves the default storage configuration.
74
+ * @param decrypt (optional) If true, decrypts the storage configuration
75
+ * @param raw (optional) If true, returns the raw Axios response instead of the data
76
+ * @returns The Storage configuration
77
+ */
78
+ getStorageConfig(pat_1) {
79
+ return __awaiter(this, arguments, void 0, function* (pat, storageId = "default", decrypt = false, raw) {
80
+ const resp = yield this.axios.get(`${this.options.server}/api/account/v1/storage/${storageId}?decrypt=${decrypt}`, {
81
+ headers: {
82
+ Authorization: `Bearer ${pat}`,
83
+ "x-hcloud-login-enforce": "true",
84
+ },
85
+ });
86
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
87
+ });
88
+ }
89
+ getEndpoint(endpoint) {
90
+ return `${this.options.server}/api/account/v1/org${endpoint}`;
91
+ }
92
+ }
93
+ exports.IdpOrganizationStorages = IdpOrganizationStorages;
@@ -1,6 +1,6 @@
1
1
  import Base, { MaybeRaw } from "../../../../Base";
2
2
  import { PaginatedResponse, SearchParams } from "../../../../interfaces/global";
3
- import { Message, RecipientType } from "../../../../interfaces/idp/user/Message";
3
+ import { Message, MessageLevel, MessageSource, MessageType, RecipientType } from "../../../../interfaces/idp/user/Message";
4
4
  export declare class IdpMessage extends Base {
5
5
  /**
6
6
  * Search all messages of the requesting user.
@@ -26,6 +26,28 @@ export declare class IdpMessage extends Base {
26
26
  updateMessage<R extends boolean = false>(messageId: string, read: boolean, raw?: {
27
27
  raw: R;
28
28
  }): Promise<MaybeRaw<R, Message>>;
29
+ /**
30
+ * Bulk-update the read status of multiple messages by ID.
31
+ *
32
+ * @param ids IDs of the messages to update
33
+ * @param read Read status to apply to all specified messages
34
+ * @returns The number of messages that were modified
35
+ */
36
+ bulkReadMessages<R extends boolean = false>(ids: string[], read: boolean, raw?: {
37
+ raw: R;
38
+ }): Promise<MaybeRaw<R, {
39
+ modifiedCount: number;
40
+ }>>;
41
+ /**
42
+ * Set the soft-delete state of a received message.
43
+ *
44
+ * @param messageId ID of the Message object
45
+ * @param deleted Whether the message should be soft-deleted (true) or restored (false)
46
+ * @returns the updated Message object
47
+ */
48
+ softDeleteMessage<R extends boolean = false>(messageId: string, deleted: boolean, raw?: {
49
+ raw: R;
50
+ }): Promise<MaybeRaw<R, Message>>;
29
51
  /**
30
52
  * Deletes a message of the requesting User.
31
53
  * @param messageId Id of the Message
@@ -42,19 +64,22 @@ export declare class IdpMessage extends Base {
42
64
  * - to - should be email, orgName or teamName
43
65
  * - recipient - enum type USER, ORGANIZATION or TEAM (by default is USER)
44
66
  * - orgName - should be only specified if recipient===TEAM
45
- * - title - title of the message (max 255 characters)
46
- * - subject - subject of the message (max 255 characters)
47
- * - message - content of the message (max 5000 characters)
67
+ * - source - the system or service that originated this message
68
+ * - type - the specific type of message, scoped to its source
69
+ * - properties - payload specific to the message source and type
70
+ * - level - severity level of the message (defaults to "info")
71
+ * - group - optional UUID to group related messages
48
72
  * @returns the Message object
49
73
  */
50
74
  sendMessage<R extends boolean = false>(msg: {
51
75
  to: string;
52
76
  recipient?: RecipientType;
53
77
  orgName?: string;
54
- title?: string;
55
- subject?: string;
56
- message: string;
57
- link?: string;
78
+ source: MessageSource;
79
+ type: MessageType;
80
+ properties: Record<string, unknown>;
81
+ level?: MessageLevel;
82
+ group?: string;
58
83
  }, raw?: {
59
84
  raw: R;
60
85
  }): Promise<MaybeRaw<R, Message>>;
@@ -58,6 +58,32 @@ class IdpMessage extends Base_1.default {
58
58
  return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
59
59
  });
60
60
  }
61
+ /**
62
+ * Bulk-update the read status of multiple messages by ID.
63
+ *
64
+ * @param ids IDs of the messages to update
65
+ * @param read Read status to apply to all specified messages
66
+ * @returns The number of messages that were modified
67
+ */
68
+ bulkReadMessages(ids, read, raw) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const resp = yield this.axios.patch(this.getEndpoint(`/v1/messages/bulk-read`), { ids, read });
71
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
72
+ });
73
+ }
74
+ /**
75
+ * Set the soft-delete state of a received message.
76
+ *
77
+ * @param messageId ID of the Message object
78
+ * @param deleted Whether the message should be soft-deleted (true) or restored (false)
79
+ * @returns the updated Message object
80
+ */
81
+ softDeleteMessage(messageId, deleted, raw) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const resp = yield this.axios.patch(this.getEndpoint(`/v1/messages/${messageId}/deleted`), { deleted });
84
+ return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
85
+ });
86
+ }
61
87
  /**
62
88
  * Deletes a message of the requesting User.
63
89
  * @param messageId Id of the Message
@@ -77,9 +103,11 @@ class IdpMessage extends Base_1.default {
77
103
  * - to - should be email, orgName or teamName
78
104
  * - recipient - enum type USER, ORGANIZATION or TEAM (by default is USER)
79
105
  * - orgName - should be only specified if recipient===TEAM
80
- * - title - title of the message (max 255 characters)
81
- * - subject - subject of the message (max 255 characters)
82
- * - message - content of the message (max 5000 characters)
106
+ * - source - the system or service that originated this message
107
+ * - type - the specific type of message, scoped to its source
108
+ * - properties - payload specific to the message source and type
109
+ * - level - severity level of the message (defaults to "info")
110
+ * - group - optional UUID to group related messages
83
111
  * @returns the Message object
84
112
  */
85
113
  sendMessage(msg, raw) {
@@ -85,19 +85,18 @@ class Nats extends Base_1.default {
85
85
  }
86
86
  return;
87
87
  }
88
- let parsedData;
88
+ let parsedData = undefined;
89
89
  try {
90
90
  const data = new TextDecoder("utf-8").decode(msg.data);
91
91
  parsedData = JSON.parse(data);
92
92
  }
93
- catch (e) {
94
- callback(e);
95
- return;
93
+ catch (_b) {
94
+ // if the message is not JSON just pass the raw message
96
95
  }
97
96
  try {
98
97
  callback(null, parsedData, msg);
99
98
  }
100
- catch (_b) {
99
+ catch (_c) {
101
100
  // ignore callback errors
102
101
  }
103
102
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hcloud-sdk",
3
- "version": "21.1.0",
3
+ "version": "21.3.0",
4
4
  "description": "hcloud platform sdk",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",