hcloud-sdk 22.15.0 → 22.16.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 +2 -2
- package/lib/Hcloud.d.ts +3 -0
- package/lib/Hcloud.js +7 -0
- package/lib/interfaces/ai/index.d.ts +40 -0
- package/lib/interfaces/ai/index.js +2 -0
- package/lib/interfaces/high5/space/index.d.ts +1 -0
- package/lib/service/ai/high5/index.d.ts +7 -0
- package/lib/service/ai/high5/index.js +19 -0
- package/lib/service/ai/high5/stream/index.d.ts +33 -0
- package/lib/service/ai/high5/stream/index.js +109 -0
- package/lib/service/ai/index.d.ts +15 -0
- package/lib/service/ai/index.js +38 -0
- package/lib/service/high5/space/index.d.ts +10 -0
- package/lib/service/high5/space/index.js +15 -0
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
## [22.
|
|
1
|
+
## [22.16.0](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/compare/v22.15.0...v22.16.0) (2026-08-11)
|
|
2
2
|
|
|
3
3
|
### Features
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* **experimental:** add high5/stream AI service ([3b6113b](https://github.com/moovit-sp-gmbh/hcloud-sdk-js/commit/3b6113b32038ee9d30e9859b3eeaa8b6919a72ca))
|
package/lib/Hcloud.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { AxiosInstance } from "axios";
|
|
|
2
2
|
import { HcloudLogger, Options } from "./Base";
|
|
3
3
|
import { RefreshToken } from "./interfaces/axios";
|
|
4
4
|
import AgentService from "./service/agent";
|
|
5
|
+
import AIService from "./service/ai";
|
|
5
6
|
import AuditorService from "./service/auditor";
|
|
6
7
|
import BouncerService from "./service/bouncer";
|
|
7
8
|
import CosmoService from "./service/cosmo";
|
|
@@ -14,6 +15,8 @@ import NatsService from "./service/nats";
|
|
|
14
15
|
import PanelService from "./service/panel";
|
|
15
16
|
import ShortsService from "./service/shorts";
|
|
16
17
|
export declare class HCloud {
|
|
18
|
+
get AI(): AIService;
|
|
19
|
+
private _AI?;
|
|
17
20
|
get Agent(): AgentService;
|
|
18
21
|
private _Agent?;
|
|
19
22
|
get Auditor(): AuditorService;
|
package/lib/Hcloud.js
CHANGED
|
@@ -19,6 +19,7 @@ const ErrorHelper_1 = __importDefault(require("./helper/ErrorHelper"));
|
|
|
19
19
|
const axios_2 = require("./interfaces/axios");
|
|
20
20
|
const idp_1 = require("./interfaces/idp");
|
|
21
21
|
const agent_1 = __importDefault(require("./service/agent"));
|
|
22
|
+
const ai_1 = __importDefault(require("./service/ai"));
|
|
22
23
|
const auditor_1 = __importDefault(require("./service/auditor"));
|
|
23
24
|
const bouncer_1 = __importDefault(require("./service/bouncer"));
|
|
24
25
|
const cosmo_1 = __importDefault(require("./service/cosmo"));
|
|
@@ -32,6 +33,12 @@ const panel_1 = __importDefault(require("./service/panel"));
|
|
|
32
33
|
const shorts_1 = __importDefault(require("./service/shorts"));
|
|
33
34
|
// tslint:disable-next-line
|
|
34
35
|
class HCloud {
|
|
36
|
+
get AI() {
|
|
37
|
+
if (this._AI === undefined) {
|
|
38
|
+
this._AI = new ai_1.default(this.options, this.axios);
|
|
39
|
+
}
|
|
40
|
+
return this._AI;
|
|
41
|
+
}
|
|
35
42
|
get Agent() {
|
|
36
43
|
if (this._Agent === undefined) {
|
|
37
44
|
this._Agent = new agent_1.default(this.options, this.axios);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReducedSpace } from "../global";
|
|
2
|
+
import type { DesignContent } from "../high5/space/event/stream/design/StreamDesign";
|
|
3
|
+
import { ReducedOrganization, ReducedUser } from "../idp";
|
|
4
|
+
export type AIHigh5StreamPayloadType = "design" | "documentation";
|
|
5
|
+
export interface AIHigh5StreamRequest {
|
|
6
|
+
message: string;
|
|
7
|
+
type: AIHigh5StreamPayloadType;
|
|
8
|
+
payload: DesignContent;
|
|
9
|
+
}
|
|
10
|
+
export type AIHigh5StreamEvent = {
|
|
11
|
+
type: "start";
|
|
12
|
+
response: AIHigh5StreamResponse;
|
|
13
|
+
} | {
|
|
14
|
+
type: "chunk";
|
|
15
|
+
message: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "done";
|
|
18
|
+
response: Omit<AIHigh5StreamResponse, "message">;
|
|
19
|
+
} | {
|
|
20
|
+
type: "error";
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
export type AIHigh5StreamResponse = {
|
|
24
|
+
message: string;
|
|
25
|
+
type: AIHigh5StreamPayloadType;
|
|
26
|
+
organization: ReducedOrganization;
|
|
27
|
+
space: ReducedSpace;
|
|
28
|
+
createdBy: ReducedUser;
|
|
29
|
+
createDate: number;
|
|
30
|
+
} & ({
|
|
31
|
+
source: "user";
|
|
32
|
+
} | {
|
|
33
|
+
source: "ai";
|
|
34
|
+
type: "design";
|
|
35
|
+
payload?: DesignContent;
|
|
36
|
+
} | {
|
|
37
|
+
source: "ai";
|
|
38
|
+
type: "documentation";
|
|
39
|
+
payload?: string;
|
|
40
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Base_1 = __importDefault(require("../../../Base"));
|
|
7
|
+
const stream_1 = require("./stream");
|
|
8
|
+
class AIHigh5 extends Base_1.default {
|
|
9
|
+
get stream() {
|
|
10
|
+
if (this._stream === undefined) {
|
|
11
|
+
this._stream = new stream_1.AIHigh5Stream(this.options, this.axios);
|
|
12
|
+
}
|
|
13
|
+
return this._stream;
|
|
14
|
+
}
|
|
15
|
+
getEndpoint(endpoint) {
|
|
16
|
+
return `${this.options.server}/api/ai${endpoint}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.default = AIHigh5;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import Base, { MaybeRaw, Options } from "../../../../Base";
|
|
3
|
+
import { AIHigh5StreamEvent, type AIHigh5StreamRequest, AIHigh5StreamResponse } from "../../../../interfaces/ai";
|
|
4
|
+
import { SortDirection } from "../../../../interfaces/global";
|
|
5
|
+
export declare class AIHigh5Stream extends Base {
|
|
6
|
+
constructor(options: Options, axios: AxiosInstance);
|
|
7
|
+
/**
|
|
8
|
+
* Get the message history of a High5 stream.
|
|
9
|
+
*
|
|
10
|
+
* @param organization Name of the Organization
|
|
11
|
+
* @param space Name of the Space
|
|
12
|
+
* @param streamId ID of the stream
|
|
13
|
+
* @param page (optional) The page to retrieve
|
|
14
|
+
* @param limit (optional) The maximum amount of streams that should be returned
|
|
15
|
+
* @param direction (optional) Sort direction of the returned streams
|
|
16
|
+
* @param raw (optional) If true, returns the raw Axios response
|
|
17
|
+
* @returns Array of stream responses
|
|
18
|
+
*/
|
|
19
|
+
get<R extends boolean = false>(organization: string, space: string, streamId: string, page?: number, limit?: number, direction?: SortDirection, raw?: {
|
|
20
|
+
raw: R;
|
|
21
|
+
}): Promise<MaybeRaw<R, AIHigh5StreamResponse[]>>;
|
|
22
|
+
/**
|
|
23
|
+
* Send a message to a High5 stream and receive the response as a stream of Server-Sent Events.
|
|
24
|
+
*
|
|
25
|
+
* @param organization Name of the Organization
|
|
26
|
+
* @param space Name of the Space
|
|
27
|
+
* @param streamId ID of the stream
|
|
28
|
+
* @param request The message request to send
|
|
29
|
+
* @param onMessage Callback invoked for each event received from the stream
|
|
30
|
+
*/
|
|
31
|
+
post(organization: string, space: string, streamId: string, request: AIHigh5StreamRequest, onMessage: (event: AIHigh5StreamEvent) => void): Promise<void>;
|
|
32
|
+
protected getEndpoint(endpoint: string): string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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.AIHigh5Stream = void 0;
|
|
16
|
+
const Base_1 = __importDefault(require("../../../../Base"));
|
|
17
|
+
class AIHigh5Stream extends Base_1.default {
|
|
18
|
+
constructor(options, axios) {
|
|
19
|
+
super(options, axios);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the message history of a High5 stream.
|
|
23
|
+
*
|
|
24
|
+
* @param organization Name of the Organization
|
|
25
|
+
* @param space Name of the Space
|
|
26
|
+
* @param streamId ID of the stream
|
|
27
|
+
* @param page (optional) The page to retrieve
|
|
28
|
+
* @param limit (optional) The maximum amount of streams that should be returned
|
|
29
|
+
* @param direction (optional) Sort direction of the returned streams
|
|
30
|
+
* @param raw (optional) If true, returns the raw Axios response
|
|
31
|
+
* @returns Array of stream responses
|
|
32
|
+
*/
|
|
33
|
+
get(organization, space, streamId, page, limit, direction, raw) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const resp = yield this.axios.get(this.getEndpoint(`/v1/high5/org/${organization}/spaces/${space}/streams/${streamId}`), {
|
|
36
|
+
params: { limit, page, direction },
|
|
37
|
+
});
|
|
38
|
+
return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Send a message to a High5 stream and receive the response as a stream of Server-Sent Events.
|
|
43
|
+
*
|
|
44
|
+
* @param organization Name of the Organization
|
|
45
|
+
* @param space Name of the Space
|
|
46
|
+
* @param streamId ID of the stream
|
|
47
|
+
* @param request The message request to send
|
|
48
|
+
* @param onMessage Callback invoked for each event received from the stream
|
|
49
|
+
*/
|
|
50
|
+
post(organization, space, streamId, request, onMessage) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
var _a;
|
|
53
|
+
const resp = yield this.axios.post(this.getEndpoint(`/v1/high5/org/${organization}/spaces/${space}/streams/${streamId}`), request, {
|
|
54
|
+
responseType: "stream",
|
|
55
|
+
adapter: "fetch",
|
|
56
|
+
headers: {
|
|
57
|
+
Accept: "text/event-stream",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
const reader = resp.data.getReader();
|
|
61
|
+
const decoder = new TextDecoder();
|
|
62
|
+
let buffer = "";
|
|
63
|
+
let response;
|
|
64
|
+
while (true) {
|
|
65
|
+
const { done, value } = yield reader.read();
|
|
66
|
+
if (done) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
buffer += decoder.decode(value, { stream: true });
|
|
70
|
+
const events = buffer.split(/\r?\n\r?\n/);
|
|
71
|
+
buffer = (_a = events.pop()) !== null && _a !== void 0 ? _a : "";
|
|
72
|
+
for (const event of events) {
|
|
73
|
+
const data = event.split(/\r?\n/).find(line => line.startsWith("data:"));
|
|
74
|
+
if (!data) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const parsed = JSON.parse(data.slice("data:".length).trim());
|
|
78
|
+
switch (parsed.type) {
|
|
79
|
+
case "start":
|
|
80
|
+
response = parsed.response;
|
|
81
|
+
onMessage({ type: "start", response });
|
|
82
|
+
break;
|
|
83
|
+
case "chunk":
|
|
84
|
+
if (!response) {
|
|
85
|
+
throw new Error("Received chunk before start");
|
|
86
|
+
}
|
|
87
|
+
response.message += parsed.message;
|
|
88
|
+
onMessage({ type: "chunk", message: parsed.message });
|
|
89
|
+
break;
|
|
90
|
+
case "done":
|
|
91
|
+
if (!response) {
|
|
92
|
+
throw new Error("Received done before start");
|
|
93
|
+
}
|
|
94
|
+
onMessage({ type: "done", response });
|
|
95
|
+
return;
|
|
96
|
+
case "error":
|
|
97
|
+
throw new Error(parsed.message);
|
|
98
|
+
default:
|
|
99
|
+
throw new Error("Unknown event type");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getEndpoint(endpoint) {
|
|
106
|
+
return `${this.options.server}/api/ai${endpoint}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.AIHigh5Stream = AIHigh5Stream;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Base, { MaybeRaw } from "../../Base";
|
|
2
|
+
import { Version } from "../../interfaces/global";
|
|
3
|
+
import AIHigh5 from "./high5";
|
|
4
|
+
export default class AIService extends Base {
|
|
5
|
+
get high5(): AIHigh5;
|
|
6
|
+
private _high5?;
|
|
7
|
+
/**
|
|
8
|
+
* Requests the endpoint version
|
|
9
|
+
* @returns Version object
|
|
10
|
+
*/
|
|
11
|
+
version<R extends boolean = false>(raw?: {
|
|
12
|
+
raw: R;
|
|
13
|
+
}): Promise<MaybeRaw<R, Version>>;
|
|
14
|
+
protected getEndpoint(endpoint: string): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
const Base_1 = __importDefault(require("../../Base"));
|
|
16
|
+
const high5_1 = __importDefault(require("./high5"));
|
|
17
|
+
class AIService extends Base_1.default {
|
|
18
|
+
get high5() {
|
|
19
|
+
if (this._high5 === undefined) {
|
|
20
|
+
this._high5 = new high5_1.default(this.options, this.axios);
|
|
21
|
+
}
|
|
22
|
+
return this._high5;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Requests the endpoint version
|
|
26
|
+
* @returns Version object
|
|
27
|
+
*/
|
|
28
|
+
version(raw) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const resp = yield this.axios.get(this.getEndpoint("/v1/version"), {});
|
|
31
|
+
return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getEndpoint(endpoint) {
|
|
35
|
+
return `${this.options.server}/api/ai${endpoint}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.default = AIService;
|
|
@@ -149,6 +149,16 @@ export declare class High5Space extends Base {
|
|
|
149
149
|
enableDev<R extends boolean = false>(orgName: string, spaceName: string, enableDev: boolean, raw?: {
|
|
150
150
|
raw: R;
|
|
151
151
|
}): Promise<MaybeRaw<R, Space>>;
|
|
152
|
+
/**
|
|
153
|
+
* Updates the execution target used when this space executes its own internal events.
|
|
154
|
+
* @param orgName Name of the organization
|
|
155
|
+
* @param spaceName Name of the space
|
|
156
|
+
* @param eventExecutionTarget New execution target: a user email or a pool name
|
|
157
|
+
* @returns The updated space
|
|
158
|
+
*/
|
|
159
|
+
setEventExecutionTarget<R extends boolean = false>(orgName: string, spaceName: string, eventExecutionTarget: string, raw?: {
|
|
160
|
+
raw: R;
|
|
161
|
+
}): Promise<MaybeRaw<R, Space>>;
|
|
152
162
|
/**
|
|
153
163
|
* Updates the avatar of the specified High5 space
|
|
154
164
|
* @param orgName Name of the organization
|
|
@@ -246,6 +246,21 @@ class High5Space extends Base_1.default {
|
|
|
246
246
|
return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Updates the execution target used when this space executes its own internal events.
|
|
251
|
+
* @param orgName Name of the organization
|
|
252
|
+
* @param spaceName Name of the space
|
|
253
|
+
* @param eventExecutionTarget New execution target: a user email or a pool name
|
|
254
|
+
* @returns The updated space
|
|
255
|
+
*/
|
|
256
|
+
setEventExecutionTarget(orgName, spaceName, eventExecutionTarget, raw) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
const resp = yield this.axios.patch(this.getEndpoint(`/v1/org/${orgName}/spaces/${spaceName}/target`), {
|
|
259
|
+
eventExecutionTarget,
|
|
260
|
+
});
|
|
261
|
+
return ((raw === null || raw === void 0 ? void 0 : raw.raw) ? resp : resp.data);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
249
264
|
/**
|
|
250
265
|
* Updates the avatar of the specified High5 space
|
|
251
266
|
* @param orgName Name of the organization
|