@streamerly/sdk 0.0.1
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/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/package.json +17 -0
- package/src/index.ts +1 -0
- package/src/types.ts +95 -0
- package/tsconfig.json +10 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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("./types"), exports);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventListener
|
|
3
|
+
* Contains the onMessage and onAlert listener to register.
|
|
4
|
+
*/
|
|
5
|
+
export interface EventListener {
|
|
6
|
+
/**
|
|
7
|
+
* gets triggered on every live chat message from any configured platform.
|
|
8
|
+
* @param handler - the handler to work with the message
|
|
9
|
+
*/
|
|
10
|
+
onMessage(handler: (platform: string, username: string, message: string) => void): () => void;
|
|
11
|
+
/**
|
|
12
|
+
* gets triggered on every live alert like "follower", "sub", "gift", etc. from any configured platform.
|
|
13
|
+
* @param handler - the handler to work with the alerts
|
|
14
|
+
*/
|
|
15
|
+
onAlert(handler: (platform: string, username: string, title: string, message: string) => void): () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* RouteManager
|
|
19
|
+
* Contains the registerRoute to register routes
|
|
20
|
+
*/
|
|
21
|
+
export interface RouteManager {
|
|
22
|
+
/**
|
|
23
|
+
* registers a route
|
|
24
|
+
* Routing for plugin starts with http://localhost:8090/rest/plugin/$pluginKey/...
|
|
25
|
+
* @param method - the method of the route
|
|
26
|
+
* @param path
|
|
27
|
+
* @param handler - the handler to work with the message
|
|
28
|
+
*/
|
|
29
|
+
registerRoute(method: "get" | "post" | "put" | "delete", path: string, handler: (req: any, res: any) => any): () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* WidgetManager
|
|
33
|
+
* Contains the registerDashboardWidget to register widgets
|
|
34
|
+
*/
|
|
35
|
+
export interface WidgetManager {
|
|
36
|
+
/**
|
|
37
|
+
* Registers a dashboard widget
|
|
38
|
+
* There must be a directory with the same name like the key and contains index.html and all needed css/js files
|
|
39
|
+
* @param key - the key of the widget
|
|
40
|
+
* @param title - the name of the widget
|
|
41
|
+
*/
|
|
42
|
+
registerDashboardWidget(key: string, title: string): () => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* TunnelManager
|
|
46
|
+
* Contains the onMessage to register to Tunnel-Frontend-Backend-Events and
|
|
47
|
+
* sendMessage to send a message from backend to frontend.
|
|
48
|
+
*/
|
|
49
|
+
export interface TunnelManager {
|
|
50
|
+
/**
|
|
51
|
+
* gets triggered on every tunnel message from the react frontend.
|
|
52
|
+
* @param handler - the handler to work with the message
|
|
53
|
+
*/
|
|
54
|
+
onMessage(handler: (message: TunnelMessage) => void): void;
|
|
55
|
+
/**
|
|
56
|
+
* sends a tunnel message to the frontend
|
|
57
|
+
* @param message - the message
|
|
58
|
+
*/
|
|
59
|
+
sendMessage(message: TunnelMessage): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The plugin context containing all register functions
|
|
63
|
+
* for rest, storage, websockets, listener, etc.
|
|
64
|
+
*/
|
|
65
|
+
export interface PluginContext {
|
|
66
|
+
id: string;
|
|
67
|
+
eventListener: EventListener;
|
|
68
|
+
routeManager: RouteManager;
|
|
69
|
+
widgetManager: WidgetManager;
|
|
70
|
+
tunnelManager: TunnelManager;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The abstract plugin definition to be registered.
|
|
74
|
+
*/
|
|
75
|
+
export interface Plugin {
|
|
76
|
+
register(ctx: PluginContext): void;
|
|
77
|
+
}
|
|
78
|
+
export interface TunnelMessage {
|
|
79
|
+
pluginKey: string;
|
|
80
|
+
type: string;
|
|
81
|
+
action: string;
|
|
82
|
+
jsonBody: any;
|
|
83
|
+
}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@streamerly/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.json"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "^5.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {}
|
|
17
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types"
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventListener
|
|
3
|
+
* Contains the onMessage and onAlert listener to register.
|
|
4
|
+
*/
|
|
5
|
+
export interface EventListener {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* gets triggered on every live chat message from any configured platform.
|
|
9
|
+
* @param handler - the handler to work with the message
|
|
10
|
+
*/
|
|
11
|
+
onMessage(handler: (platform: string, username: string, message: string) => void): () => void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* gets triggered on every live alert like "follower", "sub", "gift", etc. from any configured platform.
|
|
15
|
+
* @param handler - the handler to work with the alerts
|
|
16
|
+
*/
|
|
17
|
+
onAlert(handler: (platform: string, username: string, title: string, message: string) => void): () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* RouteManager
|
|
22
|
+
* Contains the registerRoute to register routes
|
|
23
|
+
*/
|
|
24
|
+
export interface RouteManager {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* registers a route
|
|
28
|
+
* Routing for plugin starts with http://localhost:8090/rest/plugin/$pluginKey/...
|
|
29
|
+
* @param method - the method of the route
|
|
30
|
+
* @param path
|
|
31
|
+
* @param handler - the handler to work with the message
|
|
32
|
+
*/
|
|
33
|
+
registerRoute(method: "get" | "post" | "put" | "delete", path: string, handler: (req: any, res: any) => any): () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* WidgetManager
|
|
38
|
+
* Contains the registerDashboardWidget to register widgets
|
|
39
|
+
*/
|
|
40
|
+
export interface WidgetManager {
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Registers a dashboard widget
|
|
44
|
+
* There must be a directory with the same name like the key and contains index.html and all needed css/js files
|
|
45
|
+
* @param key - the key of the widget
|
|
46
|
+
* @param title - the name of the widget
|
|
47
|
+
*/
|
|
48
|
+
registerDashboardWidget(key: string, title: string): () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* TunnelManager
|
|
53
|
+
* Contains the onMessage to register to Tunnel-Frontend-Backend-Events and
|
|
54
|
+
* sendMessage to send a message from backend to frontend.
|
|
55
|
+
*/
|
|
56
|
+
export interface TunnelManager {
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* gets triggered on every tunnel message from the react frontend.
|
|
60
|
+
* @param handler - the handler to work with the message
|
|
61
|
+
*/
|
|
62
|
+
onMessage(handler: (message: TunnelMessage) => void): void;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* sends a tunnel message to the frontend
|
|
66
|
+
* @param message - the message
|
|
67
|
+
*/
|
|
68
|
+
sendMessage(message: TunnelMessage): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The plugin context containing all register functions
|
|
73
|
+
* for rest, storage, websockets, listener, etc.
|
|
74
|
+
*/
|
|
75
|
+
export interface PluginContext {
|
|
76
|
+
id: string;
|
|
77
|
+
eventListener: EventListener;
|
|
78
|
+
routeManager: RouteManager;
|
|
79
|
+
widgetManager: WidgetManager;
|
|
80
|
+
tunnelManager: TunnelManager;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The abstract plugin definition to be registered.
|
|
85
|
+
*/
|
|
86
|
+
export interface Plugin {
|
|
87
|
+
register(ctx: PluginContext): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface TunnelMessage {
|
|
91
|
+
pluginKey: string;
|
|
92
|
+
type: string;
|
|
93
|
+
action: string;
|
|
94
|
+
jsonBody: any;
|
|
95
|
+
}
|