@observertc/observer-js 0.30.5-beta → 0.30.6-beta
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/lib/CallSummary.d.ts +22 -0
- package/lib/CallSummary.d.ts.map +1 -0
- package/lib/CallSummary.js +2 -0
- package/lib/ObservedSfu.d.ts +12 -0
- package/lib/ObservedSfu.d.ts.map +1 -1
- package/lib/ObservedSfu.js +53 -2
- package/package.json +1 -1
- package/src/CallSummary.ts +23 -0
- package/src/ObservedSfu.ts +53 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ClientSummary {
|
|
2
|
+
clientId: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
joined: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DetectedIssues {
|
|
8
|
+
clientId: string;
|
|
9
|
+
issue: string;
|
|
10
|
+
started: number;
|
|
11
|
+
ended: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CallSummary {
|
|
14
|
+
serviceId: string;
|
|
15
|
+
roomId: string;
|
|
16
|
+
callId: string;
|
|
17
|
+
started: number;
|
|
18
|
+
ended: number;
|
|
19
|
+
clients: ClientSummary[];
|
|
20
|
+
detectedIssues: DetectedIssues[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=CallSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallSummary.d.ts","sourceRoot":"","sources":["../src/CallSummary.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,cAAc,EAAE,cAAc,EAAE,CAAC;CACjC"}
|
package/lib/ObservedSfu.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { Observer } from './Observer';
|
|
4
|
+
import { SfuSample } from '@observertc/sample-schemas-js';
|
|
4
5
|
export type ObservedSfuConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
5
6
|
serviceId: string;
|
|
6
7
|
sfuId: string;
|
|
@@ -19,8 +20,19 @@ export declare interface ObservedSfu {
|
|
|
19
20
|
}
|
|
20
21
|
export declare class ObservedSfu<AppData extends Record<string, unknown> = Record<string, unknown>> extends EventEmitter {
|
|
21
22
|
private readonly _model;
|
|
23
|
+
readonly observer: Observer;
|
|
22
24
|
readonly appData: AppData;
|
|
23
25
|
static create<T extends Record<string, unknown> = Record<string, unknown>>(config: ObservedSfuConfig<T>, observer: Observer): Promise<ObservedSfu<T>>;
|
|
26
|
+
private _updated;
|
|
27
|
+
private readonly _execute;
|
|
28
|
+
private _closed;
|
|
24
29
|
private constructor();
|
|
30
|
+
get serviceId(): string;
|
|
31
|
+
get sfuId(): string;
|
|
32
|
+
get joined(): number;
|
|
33
|
+
get closed(): boolean;
|
|
34
|
+
close(): void;
|
|
35
|
+
update(sample: SfuSample): Promise<void>;
|
|
36
|
+
private _save;
|
|
25
37
|
}
|
|
26
38
|
//# sourceMappingURL=ObservedSfu.d.ts.map
|
package/lib/ObservedSfu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedSfu.d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C,KAAK,IAAI,GAAG,IAAI,CAAC;IAC3G,IAAI,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;CAC1F;AAED,qBAAa,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAE,SAAQ,YAAY;IA8B9G,OAAO,CAAC,QAAQ,CAAC,MAAM;aACP,QAAQ,EAAE,QAAQ;aAClB,OAAO,EAAE,OAAO;WA/Bb,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrF,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC5B,QAAQ,EAAE,QAAQ;IAsBnB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IACnD,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO;IAQP,IAAW,SAAS,WAGnB;IAED,IAAW,KAAK,WAGf;IAED,IAAW,MAAM,WAGhB;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAMC,MAAM,CAAC,MAAM,EAAE,SAAS;YAWvB,KAAK;CASnB"}
|
package/lib/ObservedSfu.js
CHANGED
|
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
exports.ObservedSfu = void 0;
|
|
36
36
|
const events_1 = require("events");
|
|
37
37
|
const Models = __importStar(require("./models/Models"));
|
|
38
|
+
const SingleExecutor_1 = require("./common/SingleExecutor");
|
|
38
39
|
class ObservedSfu extends events_1.EventEmitter {
|
|
39
40
|
static create(config, observer) {
|
|
40
41
|
var _a;
|
|
@@ -45,17 +46,67 @@ class ObservedSfu extends events_1.EventEmitter {
|
|
|
45
46
|
sfuTransportIds: [],
|
|
46
47
|
joined: BigInt((_a = config.joined) !== null && _a !== void 0 ? _a : Date.now()),
|
|
47
48
|
});
|
|
48
|
-
const result = new ObservedSfu(model, config.appData);
|
|
49
|
+
const result = new ObservedSfu(model, observer, config.appData);
|
|
49
50
|
const alreadyInserted = yield observer.storage.sfuStorage.insert(config.sfuId, model);
|
|
50
51
|
if (alreadyInserted)
|
|
51
52
|
throw new Error(`Sfu with id ${config.sfuId} already exists`);
|
|
52
53
|
return result;
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
constructor(_model, appData) {
|
|
56
|
+
constructor(_model, observer, appData) {
|
|
56
57
|
super();
|
|
57
58
|
this._model = _model;
|
|
59
|
+
this.observer = observer;
|
|
58
60
|
this.appData = appData;
|
|
61
|
+
this._updated = Date.now();
|
|
62
|
+
this._execute = (0, SingleExecutor_1.createSingleExecutor)();
|
|
63
|
+
this._closed = false;
|
|
64
|
+
}
|
|
65
|
+
get serviceId() {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
67
|
+
return this._model.serviceId;
|
|
68
|
+
}
|
|
69
|
+
get sfuId() {
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
71
|
+
return this._model.sfuId;
|
|
72
|
+
}
|
|
73
|
+
get joined() {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
75
|
+
return Number(this._model.joined);
|
|
76
|
+
}
|
|
77
|
+
get closed() {
|
|
78
|
+
return this._closed;
|
|
79
|
+
}
|
|
80
|
+
close() {
|
|
81
|
+
if (this._closed)
|
|
82
|
+
return;
|
|
83
|
+
this._closed = true;
|
|
84
|
+
this.emit('close');
|
|
85
|
+
}
|
|
86
|
+
update(sample) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
if (this._closed)
|
|
89
|
+
throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
90
|
+
if (sample.sfuId !== this.sfuId)
|
|
91
|
+
throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
|
|
92
|
+
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
if (this._closed)
|
|
94
|
+
throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
95
|
+
yield this._save();
|
|
96
|
+
this.emit('update');
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
_save() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
if (this._closed)
|
|
103
|
+
throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
104
|
+
return this._execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (this._closed)
|
|
106
|
+
throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
107
|
+
yield this.observer.storage.sfuStorage.set(this.sfuId, this._model);
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
59
110
|
}
|
|
60
111
|
}
|
|
61
112
|
exports.ObservedSfu = ObservedSfu;
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ClientSummary {
|
|
2
|
+
clientId: string;
|
|
3
|
+
userId: string;
|
|
4
|
+
joined: number;
|
|
5
|
+
left: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DetectedIssues {
|
|
9
|
+
clientId: string,
|
|
10
|
+
issue: string,
|
|
11
|
+
started: number,
|
|
12
|
+
ended: number,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CallSummary {
|
|
16
|
+
serviceId: string;
|
|
17
|
+
roomId: string;
|
|
18
|
+
callId: string;
|
|
19
|
+
started: number;
|
|
20
|
+
ended: number;
|
|
21
|
+
clients: ClientSummary[];
|
|
22
|
+
detectedIssues: DetectedIssues[];
|
|
23
|
+
}
|
package/src/ObservedSfu.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import * as Models from './models/Models';
|
|
3
3
|
import { Observer } from './Observer';
|
|
4
|
+
import { createSingleExecutor } from './common/SingleExecutor';
|
|
5
|
+
import { SfuSample } from '@observertc/sample-schemas-js';
|
|
4
6
|
|
|
5
7
|
export type ObservedSfuConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
6
8
|
serviceId: string;
|
|
@@ -35,6 +37,7 @@ export class ObservedSfu<AppData extends Record<string, unknown> = Record<string
|
|
|
35
37
|
});
|
|
36
38
|
const result = new ObservedSfu(
|
|
37
39
|
model,
|
|
40
|
+
observer,
|
|
38
41
|
config.appData,
|
|
39
42
|
);
|
|
40
43
|
|
|
@@ -44,12 +47,62 @@ export class ObservedSfu<AppData extends Record<string, unknown> = Record<string
|
|
|
44
47
|
|
|
45
48
|
return result;
|
|
46
49
|
}
|
|
50
|
+
|
|
51
|
+
private _updated = Date.now();
|
|
52
|
+
private readonly _execute = createSingleExecutor();
|
|
53
|
+
private _closed = false;
|
|
47
54
|
|
|
48
55
|
private constructor(
|
|
49
56
|
private readonly _model: Models.Sfu,
|
|
57
|
+
public readonly observer: Observer,
|
|
50
58
|
public readonly appData: AppData,
|
|
51
59
|
) {
|
|
52
60
|
super();
|
|
53
61
|
}
|
|
62
|
+
|
|
63
|
+
public get serviceId() {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
|
+
return this._model.serviceId!;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public get sfuId() {
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
70
|
+
return this._model.sfuId!;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public get joined() {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
75
|
+
return Number(this._model.joined!);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public get closed() {
|
|
79
|
+
return this._closed;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public close() {
|
|
83
|
+
if (this._closed) return;
|
|
84
|
+
this._closed = true;
|
|
85
|
+
this.emit('close');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public async update(sample: SfuSample) {
|
|
89
|
+
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
90
|
+
if (sample.sfuId !== this.sfuId) throw new Error(`Sfu ${this.sfuId} is not the same as sample.sfuId`);
|
|
91
|
+
|
|
92
|
+
return this._execute(async () => {
|
|
93
|
+
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
94
|
+
await this._save();
|
|
95
|
+
this.emit('update');
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private async _save() {
|
|
100
|
+
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
101
|
+
|
|
102
|
+
return this._execute(async () => {
|
|
103
|
+
if (this._closed) throw new Error(`Sfu ${this.sfuId} is closed`);
|
|
104
|
+
await this.observer.storage.sfuStorage.set(this.sfuId, this._model);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
54
107
|
|
|
55
108
|
}
|