@volorio/sdk 0.1.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/README.md +89 -0
- package/dist/src/browser.d.ts +53 -0
- package/dist/src/browser.js +97 -0
- package/dist/src/browser.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +20 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/node.d.ts +28 -0
- package/dist/src/node.js +50 -0
- package/dist/src/node.js.map +1 -0
- package/dist/src/pricing.d.ts +13 -0
- package/dist/src/pricing.js +28 -0
- package/dist/src/pricing.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @volorio/sdk
|
|
2
|
+
|
|
3
|
+
Volorio SDK lets customers sell and embed RTC video, voice, live streaming, chat, screen share, and usage metering in their own websites.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @volorio/sdk livekit-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Server-side token endpoint
|
|
12
|
+
|
|
13
|
+
Never expose a Volorio API key in browser code. Put it in your backend and return short-lived room sessions to your website.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import express from "express";
|
|
17
|
+
import { VolorioServerClient } from "@volorio/sdk/node";
|
|
18
|
+
|
|
19
|
+
const app = express();
|
|
20
|
+
app.use(express.json());
|
|
21
|
+
|
|
22
|
+
const volorio = new VolorioServerClient({
|
|
23
|
+
apiBaseUrl: "https://api.volorio.com",
|
|
24
|
+
apiKey: process.env.VOLORIO_API_KEY!,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
app.post("/api/volorio/session", async (request, response) => {
|
|
28
|
+
const session = await volorio.createRoomSession({
|
|
29
|
+
projectId: request.body.projectId,
|
|
30
|
+
roomId: request.body.roomId,
|
|
31
|
+
identity: request.body.identity,
|
|
32
|
+
quality: request.body.quality ?? "hd",
|
|
33
|
+
ttlSeconds: 3600,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
response.json(session);
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Browser usage
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { VolorioRoomClient } from "@volorio/sdk/browser";
|
|
44
|
+
|
|
45
|
+
const session = await fetch("/api/volorio/session", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: { "content-type": "application/json" },
|
|
48
|
+
body: JSON.stringify({
|
|
49
|
+
projectId: "proj_123",
|
|
50
|
+
roomId: "sales-demo",
|
|
51
|
+
identity: "visitor_42",
|
|
52
|
+
quality: "fullhd",
|
|
53
|
+
}),
|
|
54
|
+
}).then((response) => response.json());
|
|
55
|
+
|
|
56
|
+
const room = new VolorioRoomClient({
|
|
57
|
+
participantMinutePriceMicros: 590,
|
|
58
|
+
videoMinutePriceMicros: 890,
|
|
59
|
+
screenShareMinutePriceMicros: 120,
|
|
60
|
+
chatMinutePriceMicros: 80,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
room.on("usageEstimateChanged", (estimate) => {
|
|
64
|
+
console.log("live participant minutes", estimate.participantMinutes);
|
|
65
|
+
console.log("estimated amount micros", estimate.estimatedAmountMicros);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await room.join(session);
|
|
69
|
+
await room.enableCamera(true);
|
|
70
|
+
await room.enableMicrophone(true);
|
|
71
|
+
await room.sendMessage("hello");
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Product catalog
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { volorioPricingCatalog } from "@volorio/sdk/pricing";
|
|
78
|
+
|
|
79
|
+
console.table(volorioPricingCatalog);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Current catalog includes separate products for conversational AI, RTC voice, RTC video HD, RTC video FullHD, RTC video 2K, RTC video 4K, live streaming, signaling, chat MAU, speech-to-text, translation, recording, media gateway, transcoding, media push, media pull, AI noise suppression, 3D spatial audio, whiteboard, analytics, and flexible classroom.
|
|
83
|
+
|
|
84
|
+
## Local package build
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pnpm --filter @volorio/sdk build
|
|
88
|
+
pnpm --filter @volorio/sdk pack:local
|
|
89
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type EventName = "participantsChanged" | "messageReceived" | "usageEstimateChanged" | "connected" | "disconnected";
|
|
2
|
+
type Handler = (event: unknown) => void;
|
|
3
|
+
export interface VolorioBrowserSession {
|
|
4
|
+
livekitUrl: string;
|
|
5
|
+
token: string;
|
|
6
|
+
identity: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VolorioUsageEstimate {
|
|
9
|
+
participantMinutes: number;
|
|
10
|
+
estimatedAmountMicros: number;
|
|
11
|
+
}
|
|
12
|
+
export interface VolorioRoomClientOptions {
|
|
13
|
+
roomFactory?: () => VolorioRoomLike;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
participantMinutePriceMicros?: number;
|
|
16
|
+
videoMinutePriceMicros?: number;
|
|
17
|
+
screenShareMinutePriceMicros?: number;
|
|
18
|
+
chatMinutePriceMicros?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface VolorioRoomLike {
|
|
21
|
+
localParticipant: {
|
|
22
|
+
setCameraEnabled(enabled: boolean): Promise<void>;
|
|
23
|
+
setMicrophoneEnabled(enabled: boolean): Promise<void>;
|
|
24
|
+
setScreenShareEnabled(enabled: boolean): Promise<void>;
|
|
25
|
+
publishData(payload: Uint8Array, options?: {
|
|
26
|
+
reliable?: boolean;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
30
|
+
connect(url: string, token: string): Promise<void>;
|
|
31
|
+
disconnect(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class VolorioRoomClient {
|
|
34
|
+
private readonly handlers;
|
|
35
|
+
private readonly roomFactory;
|
|
36
|
+
private readonly now;
|
|
37
|
+
private readonly rates;
|
|
38
|
+
private room;
|
|
39
|
+
private joinedAt;
|
|
40
|
+
private featureState;
|
|
41
|
+
constructor(options?: VolorioRoomClientOptions);
|
|
42
|
+
on(event: EventName, handler: Handler): () => void;
|
|
43
|
+
join(session: VolorioBrowserSession): Promise<void>;
|
|
44
|
+
disconnect(): void;
|
|
45
|
+
enableCamera(enabled: boolean): Promise<void>;
|
|
46
|
+
enableMicrophone(enabled: boolean): Promise<void>;
|
|
47
|
+
enableScreenShare(enabled: boolean): Promise<void>;
|
|
48
|
+
sendMessage(message: string): Promise<void>;
|
|
49
|
+
updateUsageEstimate(): VolorioUsageEstimate;
|
|
50
|
+
private requireRoom;
|
|
51
|
+
private emit;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolorioRoomClient = void 0;
|
|
4
|
+
class VolorioRoomClient {
|
|
5
|
+
handlers = new Map();
|
|
6
|
+
roomFactory;
|
|
7
|
+
now;
|
|
8
|
+
rates;
|
|
9
|
+
room;
|
|
10
|
+
joinedAt = 0;
|
|
11
|
+
featureState = { camera: false, screenShare: false, chat: false };
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.roomFactory = options.roomFactory ?? createLiveKitRoom;
|
|
14
|
+
this.now = options.now ?? Date.now;
|
|
15
|
+
this.rates = {
|
|
16
|
+
participantMinutePriceMicros: options.participantMinutePriceMicros ?? 590,
|
|
17
|
+
videoMinutePriceMicros: options.videoMinutePriceMicros ?? 250,
|
|
18
|
+
screenShareMinutePriceMicros: options.screenShareMinutePriceMicros ?? 120,
|
|
19
|
+
chatMinutePriceMicros: options.chatMinutePriceMicros ?? 80,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
on(event, handler) {
|
|
23
|
+
const handlers = this.handlers.get(event) ?? [];
|
|
24
|
+
handlers.push(handler);
|
|
25
|
+
this.handlers.set(event, handlers);
|
|
26
|
+
return () => this.handlers.set(event, handlers.filter((item) => item !== handler));
|
|
27
|
+
}
|
|
28
|
+
async join(session) {
|
|
29
|
+
this.room = this.roomFactory();
|
|
30
|
+
this.room.on("disconnected", () => this.emit("disconnected", undefined));
|
|
31
|
+
this.room.on("participantConnected", () => this.emit("participantsChanged", undefined));
|
|
32
|
+
this.room.on("participantDisconnected", () => this.emit("participantsChanged", undefined));
|
|
33
|
+
this.room.on("dataReceived", (payload, participant) => {
|
|
34
|
+
this.emit("messageReceived", { payload, participant });
|
|
35
|
+
});
|
|
36
|
+
await this.room.connect(session.livekitUrl, session.token);
|
|
37
|
+
this.joinedAt = this.now();
|
|
38
|
+
this.emit("connected", { identity: session.identity });
|
|
39
|
+
this.updateUsageEstimate();
|
|
40
|
+
}
|
|
41
|
+
disconnect() {
|
|
42
|
+
this.room?.disconnect();
|
|
43
|
+
this.room = undefined;
|
|
44
|
+
this.emit("disconnected", undefined);
|
|
45
|
+
}
|
|
46
|
+
async enableCamera(enabled) {
|
|
47
|
+
await this.requireRoom().localParticipant.setCameraEnabled(enabled);
|
|
48
|
+
this.featureState.camera = enabled;
|
|
49
|
+
this.updateUsageEstimate();
|
|
50
|
+
}
|
|
51
|
+
async enableMicrophone(enabled) {
|
|
52
|
+
await this.requireRoom().localParticipant.setMicrophoneEnabled(enabled);
|
|
53
|
+
}
|
|
54
|
+
async enableScreenShare(enabled) {
|
|
55
|
+
await this.requireRoom().localParticipant.setScreenShareEnabled(enabled);
|
|
56
|
+
this.featureState.screenShare = enabled;
|
|
57
|
+
this.updateUsageEstimate();
|
|
58
|
+
}
|
|
59
|
+
async sendMessage(message) {
|
|
60
|
+
await this.requireRoom().localParticipant.publishData(new TextEncoder().encode(message), { reliable: true });
|
|
61
|
+
this.featureState.chat = true;
|
|
62
|
+
this.updateUsageEstimate();
|
|
63
|
+
}
|
|
64
|
+
updateUsageEstimate() {
|
|
65
|
+
const elapsedMinutes = Math.max(0, (this.now() - this.joinedAt) / 60000);
|
|
66
|
+
const perMinute = this.rates.participantMinutePriceMicros +
|
|
67
|
+
(this.featureState.camera ? this.rates.videoMinutePriceMicros : 0) +
|
|
68
|
+
(this.featureState.screenShare ? this.rates.screenShareMinutePriceMicros : 0) +
|
|
69
|
+
(this.featureState.chat ? this.rates.chatMinutePriceMicros : 0);
|
|
70
|
+
const estimate = {
|
|
71
|
+
participantMinutes: elapsedMinutes,
|
|
72
|
+
estimatedAmountMicros: Math.round(elapsedMinutes * perMinute),
|
|
73
|
+
};
|
|
74
|
+
this.emit("usageEstimateChanged", estimate);
|
|
75
|
+
return estimate;
|
|
76
|
+
}
|
|
77
|
+
requireRoom() {
|
|
78
|
+
if (this.room === undefined) {
|
|
79
|
+
throw new Error("Volorio room is not connected");
|
|
80
|
+
}
|
|
81
|
+
return this.room;
|
|
82
|
+
}
|
|
83
|
+
emit(event, payload) {
|
|
84
|
+
for (const handler of this.handlers.get(event) ?? []) {
|
|
85
|
+
handler(payload);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.VolorioRoomClient = VolorioRoomClient;
|
|
90
|
+
function createLiveKitRoom() {
|
|
91
|
+
const livekit = globalThis.LivekitClient;
|
|
92
|
+
if (livekit === undefined) {
|
|
93
|
+
throw new Error("livekit-client is required. Pass roomFactory or load LivekitClient in the browser.");
|
|
94
|
+
}
|
|
95
|
+
return new livekit.Room();
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":";;;AAmCA,MAAa,iBAAiB;IACX,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC3C,WAAW,CAAwB;IACnC,GAAG,CAAe;IAClB,KAAK,CAAiK;IAC/K,IAAI,CAA8B;IAClC,QAAQ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;QAClE,MAAM,QAAQ,GAAG;YACf,kBAAkB,EAAE,cAAc;YAClC,qBAAqB,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAAC;SAC9D,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEO,IAAI,CAAC,KAAgB,EAAE,OAAgB;QAC7C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACrD,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAhGD,8CAgGC;AAED,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAI,UAAiF,CAAC,aAAa,CAAC;IACjH,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./node"), exports);
|
|
18
|
+
__exportStar(require("./browser"), exports);
|
|
19
|
+
__exportStar(require("./pricing"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B;AAC1B,4CAA0B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface VolorioServerClientOptions {
|
|
2
|
+
apiBaseUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
fetch?: typeof fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface CreateRoomSessionInput {
|
|
7
|
+
projectId: string;
|
|
8
|
+
roomId: string;
|
|
9
|
+
identity: string;
|
|
10
|
+
regionId?: string;
|
|
11
|
+
ttlSeconds?: number;
|
|
12
|
+
quality?: "voice" | "hd" | "fullhd" | "2k" | "4k";
|
|
13
|
+
}
|
|
14
|
+
export interface VolorioRoomSession {
|
|
15
|
+
projectId: string;
|
|
16
|
+
roomId: string;
|
|
17
|
+
identity: string;
|
|
18
|
+
token: string;
|
|
19
|
+
livekitUrl: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class VolorioServerClient {
|
|
22
|
+
private readonly apiBaseUrl;
|
|
23
|
+
private readonly apiKey;
|
|
24
|
+
private readonly fetchImpl;
|
|
25
|
+
constructor(options: VolorioServerClientOptions);
|
|
26
|
+
createRoomSession(input: CreateRoomSessionInput): Promise<VolorioRoomSession>;
|
|
27
|
+
private post;
|
|
28
|
+
}
|
package/dist/src/node.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolorioServerClient = void 0;
|
|
4
|
+
class VolorioServerClient {
|
|
5
|
+
apiBaseUrl;
|
|
6
|
+
apiKey;
|
|
7
|
+
fetchImpl;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.apiBaseUrl = options.apiBaseUrl.replace(/\/+$/, "");
|
|
10
|
+
this.apiKey = options.apiKey;
|
|
11
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
12
|
+
}
|
|
13
|
+
async createRoomSession(input) {
|
|
14
|
+
await this.post("/v1/media-rooms", {
|
|
15
|
+
roomId: input.roomId,
|
|
16
|
+
regionId: input.regionId ?? "default",
|
|
17
|
+
metadata: JSON.stringify({ projectId: input.projectId, quality: input.quality ?? "hd" }),
|
|
18
|
+
});
|
|
19
|
+
const token = await this.post("/v1/tokens", {
|
|
20
|
+
projectId: input.projectId,
|
|
21
|
+
roomId: input.roomId,
|
|
22
|
+
identity: input.identity,
|
|
23
|
+
ttlSeconds: input.ttlSeconds ?? 3600,
|
|
24
|
+
quality: input.quality ?? "hd",
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
projectId: input.projectId,
|
|
28
|
+
roomId: input.roomId,
|
|
29
|
+
identity: input.identity,
|
|
30
|
+
token: token.token,
|
|
31
|
+
livekitUrl: token.livekitUrl ?? "",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async post(path, body) {
|
|
35
|
+
const response = await this.fetchImpl(`${this.apiBaseUrl}${path}`, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: {
|
|
38
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
39
|
+
"content-type": "application/json",
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify(body),
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new Error(`Volorio API ${path} returned ${response.status}: ${await response.text()}`);
|
|
45
|
+
}
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.VolorioServerClient = VolorioServerClient;
|
|
50
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":";;;AAuBA,MAAa,mBAAmB;IACb,UAAU,CAAS;IACnB,MAAM,CAAS;IACf,SAAS,CAAe;IAEzC,YAAY,OAAmC;QAC7C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAA6B;QACnD,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YACjC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;YACrC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;SACzF,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAyC,YAAY,EAAE;YAClF,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;YACpC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;SAC/B,CAAC,CAAC;QAEH,OAAO;YACL,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE;SACnC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,IAAI,CAAe,IAAY,EAAE,IAAa;QAC1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE,EAAE;YACjE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACtC,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,aAAa,QAAQ,CAAC,MAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/F,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAA2B,CAAC;IAClD,CAAC;CACF;AAlDD,kDAkDC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type VolorioProductUnit = "minute" | "participant_minute" | "message" | "monthly_active_user" | "month";
|
|
2
|
+
export interface VolorioProductPrice {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
category: "core" | "media_service" | "ai_extension" | "addon" | "apaas";
|
|
6
|
+
unit: VolorioProductUnit;
|
|
7
|
+
unitPriceMicros: number;
|
|
8
|
+
freeAllowance?: {
|
|
9
|
+
quantity: number;
|
|
10
|
+
period: "month" | "one_time";
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare const volorioPricingCatalog: readonly VolorioProductPrice[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.volorioPricingCatalog = void 0;
|
|
4
|
+
exports.volorioPricingCatalog = [
|
|
5
|
+
{ id: "conversational_ai_platform", name: "Conversational AI Platform", category: "core", unit: "minute", unitPriceMicros: 100_000, freeAllowance: { quantity: 300, period: "one_time" } },
|
|
6
|
+
{ id: "rtc_voice", name: "RTC Voice", category: "core", unit: "participant_minute", unitPriceMicros: 590 },
|
|
7
|
+
{ id: "rtc_video_hd", name: "RTC Video HD", category: "core", unit: "participant_minute", unitPriceMicros: 590, freeAllowance: { quantity: 10_000, period: "month" } },
|
|
8
|
+
{ id: "rtc_video_fullhd", name: "RTC Video FullHD", category: "core", unit: "participant_minute", unitPriceMicros: 890 },
|
|
9
|
+
{ id: "rtc_video_2k", name: "RTC Video 2K", category: "core", unit: "participant_minute", unitPriceMicros: 1_490 },
|
|
10
|
+
{ id: "rtc_video_4k", name: "RTC Video 4K", category: "core", unit: "participant_minute", unitPriceMicros: 2_490 },
|
|
11
|
+
{ id: "live_streaming", name: "Live Streaming", category: "core", unit: "participant_minute", unitPriceMicros: 590 },
|
|
12
|
+
{ id: "screen_share", name: "Screen Share", category: "core", unit: "participant_minute", unitPriceMicros: 590 },
|
|
13
|
+
{ id: "signaling", name: "Signaling", category: "core", unit: "message", unitPriceMicros: 1_500, freeAllowance: { quantity: 1_000_000, period: "month" } },
|
|
14
|
+
{ id: "chat_mau", name: "Chat MAU", category: "core", unit: "monthly_active_user", unitPriceMicros: 50_000, freeAllowance: { quantity: 500, period: "month" } },
|
|
15
|
+
{ id: "speech_to_text", name: "Real-Time Speech to Text", category: "media_service", unit: "minute", unitPriceMicros: 16_990 },
|
|
16
|
+
{ id: "real_time_translation", name: "Real-Time Translation", category: "media_service", unit: "minute", unitPriceMicros: 8_990 },
|
|
17
|
+
{ id: "recording", name: "Recording", category: "media_service", unit: "minute", unitPriceMicros: 990 },
|
|
18
|
+
{ id: "media_gateway", name: "Media Gateway", category: "media_service", unit: "minute", unitPriceMicros: 990 },
|
|
19
|
+
{ id: "cloud_transcoding", name: "Cloud Transcoding", category: "media_service", unit: "minute", unitPriceMicros: 1_990 },
|
|
20
|
+
{ id: "media_push", name: "Media Push", category: "media_service", unit: "minute", unitPriceMicros: 1_990 },
|
|
21
|
+
{ id: "media_pull", name: "Media Pull", category: "media_service", unit: "minute", unitPriceMicros: 1_150 },
|
|
22
|
+
{ id: "ai_noise_suppression", name: "AI Noise Suppression", category: "ai_extension", unit: "minute", unitPriceMicros: 590, freeAllowance: { quantity: 10_000, period: "month" } },
|
|
23
|
+
{ id: "spatial_audio_3d", name: "3D Spatial Audio", category: "ai_extension", unit: "minute", unitPriceMicros: 990, freeAllowance: { quantity: 10_000, period: "month" } },
|
|
24
|
+
{ id: "interactive_whiteboard", name: "Interactive Whiteboard", category: "addon", unit: "minute", unitPriceMicros: 1_400, freeAllowance: { quantity: 10_000, period: "month" } },
|
|
25
|
+
{ id: "analytics", name: "Analytics", category: "addon", unit: "month", unitPriceMicros: 449_000_000 },
|
|
26
|
+
{ id: "flexible_classroom", name: "Flexible Classroom", category: "apaas", unit: "minute", unitPriceMicros: 2_190, freeAllowance: { quantity: 10_000, period: "month" } },
|
|
27
|
+
];
|
|
28
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/pricing.ts"],"names":[],"mappings":";;;AAmBa,QAAA,qBAAqB,GAAmC;IACnE,EAAE,EAAE,EAAE,4BAA4B,EAAE,IAAI,EAAE,4BAA4B,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;I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AE,sBAAsB,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAClL,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAC1K,EAAE,EAAE,EAAE,wBAAwB,EAAE,IAAI,EAAE,wBAAwB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IACjL,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE;IACtG,EAAE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;CAC1K,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@volorio/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Volorio RTC, chat, usage, and billing SDK for Node.js and browsers.",
|
|
6
|
+
"main": "dist/src/index.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/src/index.d.ts",
|
|
11
|
+
"default": "./dist/src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./node": {
|
|
14
|
+
"types": "./dist/src/node.d.ts",
|
|
15
|
+
"default": "./dist/src/node.js"
|
|
16
|
+
},
|
|
17
|
+
"./browser": {
|
|
18
|
+
"types": "./dist/src/browser.d.ts",
|
|
19
|
+
"default": "./dist/src/browser.js"
|
|
20
|
+
},
|
|
21
|
+
"./pricing": {
|
|
22
|
+
"types": "./dist/src/pricing.d.ts",
|
|
23
|
+
"default": "./dist/src/pricing.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/src",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json",
|
|
36
|
+
"test": "tsc -p tsconfig.json && node --test dist/test/*.spec.js",
|
|
37
|
+
"pack:local": "pnpm build && npm pack --pack-destination dist"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"livekit-client": "^2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependenciesMeta": {
|
|
43
|
+
"livekit-client": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|