@fonoster/common 0.27.0 → 0.31.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/dist/{voice/PlayDtmf.d.ts → agents/index.d.ts} +3 -5
- package/dist/{assistants → agents}/index.js +2 -6
- package/dist/agents/sessionAgentSchema.d.ts +755 -0
- package/dist/agents/sessionAgentSchema.js +117 -0
- package/dist/{voice/Dial.d.ts → calls/index.d.ts} +16 -13
- package/dist/calls/index.js +44 -0
- package/dist/cellsecrets/index.d.ts +91 -0
- package/dist/cellsecrets/index.js +299 -0
- package/dist/config/cli/check.d.ts +6 -0
- package/dist/config/cli/check.js +202 -0
- package/dist/config/cli/envFile.d.ts +23 -0
- package/dist/config/cli/envFile.js +81 -0
- package/dist/config/cli/exposure.d.ts +10 -0
- package/dist/config/cli/exposure.js +93 -0
- package/dist/config/cli/index.d.ts +2 -0
- package/dist/{identity/tokenHasAccessKeyId.js → config/cli/index.js} +7 -8
- package/dist/config/cli/info.d.ts +6 -0
- package/dist/config/cli/info.js +62 -0
- package/dist/config/cli/init.d.ts +9 -0
- package/dist/config/cli/init.js +152 -0
- package/dist/config/cli/main.d.ts +11 -0
- package/dist/config/cli/main.js +155 -0
- package/dist/config/cli/render.d.ts +44 -0
- package/dist/config/cli/render.js +129 -0
- package/dist/config/cli/secrets.d.ts +21 -0
- package/dist/config/cli/secrets.js +117 -0
- package/dist/config/cli/types.d.ts +24 -0
- package/dist/config/cli/types.js +7 -0
- package/dist/{assistants/index.d.ts → config/configHints.d.ts} +8 -7
- package/dist/config/configHints.js +47 -0
- package/dist/{voice → config}/index.d.ts +11 -13
- package/dist/{voice → config}/index.js +11 -13
- package/dist/config/interpolateEnv.d.ts +34 -0
- package/dist/config/interpolateEnv.js +70 -0
- package/dist/config/loadServiceConfig.d.ts +28 -0
- package/dist/config/loadServiceConfig.js +112 -0
- package/dist/config/logsSchema.d.ts +76 -0
- package/dist/config/logsSchema.js +49 -0
- package/dist/config/natsConnection.d.ts +53 -0
- package/dist/config/natsConnection.js +58 -0
- package/dist/config/parseConfigFile.d.ts +7 -0
- package/dist/config/parseConfigFile.js +60 -0
- package/dist/config/resolveConfigFile.d.ts +17 -0
- package/dist/config/resolveConfigFile.js +54 -0
- package/dist/config/resolveSecretRefs.d.ts +35 -0
- package/dist/config/resolveSecretRefs.js +129 -0
- package/dist/{assistants/audioFiltersSchema.d.ts → config/strictDeep.d.ts} +9 -12
- package/dist/config/strictDeep.js +58 -0
- package/dist/config/telemetrySchema.d.ts +39 -0
- package/dist/config/telemetrySchema.js +44 -0
- package/dist/config/toJsonSchema.d.ts +30 -0
- package/dist/config/toJsonSchema.js +161 -0
- package/dist/constants.d.ts +1 -6
- package/dist/constants.js +4 -7
- package/dist/envs.d.ts +2 -1
- package/dist/envs.js +13 -11
- package/dist/errors/handleZodError.js +3 -1
- package/dist/filters/index.d.ts +70 -0
- package/dist/filters/index.js +101 -0
- package/dist/identity/createAuthInterceptor.d.ts +9 -2
- package/dist/identity/createAuthInterceptor.js +36 -30
- package/dist/identity/hasAccess.d.ts +9 -3
- package/dist/identity/hasAccess.js +32 -8
- package/dist/identity/index.d.ts +1 -0
- package/dist/identity/index.js +1 -0
- package/dist/identity/isValidToken.d.ts +12 -2
- package/dist/identity/isValidToken.js +25 -9
- package/dist/identity/roles.js +33 -7
- package/dist/identity/types.d.ts +6 -1
- package/dist/identity/types.js +1 -0
- package/dist/{assistants/LanguageModelProvider.js → identity/verifyAccessToken.d.ts} +10 -11
- package/dist/identity/verifyAccessToken.js +44 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +18 -3
- package/dist/net/assertPublicDestination.d.ts +52 -0
- package/dist/net/assertPublicDestination.js +342 -0
- package/dist/{voice/StopSay.d.ts → net/index.d.ts} +1 -6
- package/dist/net/index.js +35 -0
- package/dist/notifications/createSendEmail.js +3 -1
- package/dist/protos/applications.proto +138 -3
- package/dist/protos/authz.proto +26 -4
- package/dist/protos/billing.proto +92 -0
- package/dist/protos/calls.proto +4 -0
- package/dist/protos/capabilities.proto +102 -0
- package/dist/protos/identity.proto +26 -1
- package/dist/protos/providers.proto +139 -0
- package/dist/protos/roomr.proto +146 -0
- package/dist/protos/session.proto +194 -0
- package/dist/protos/usage.proto +59 -0
- package/dist/protos/webhooks.proto +140 -0
- package/dist/{utils/types.d.ts → regions/hub/index.d.ts} +1 -5
- package/dist/regions/hub/index.js +35 -0
- package/dist/regions/hub/natsJwt.d.ts +63 -0
- package/dist/regions/hub/natsJwt.js +195 -0
- package/dist/registry/Registry.d.ts +87 -0
- package/dist/registry/Registry.js +432 -0
- package/dist/registry/cli.d.ts +20 -0
- package/dist/registry/cli.js +436 -0
- package/dist/registry/features.d.ts +31 -0
- package/dist/registry/features.js +38 -0
- package/dist/registry/index.d.ts +24 -0
- package/dist/registry/index.js +40 -0
- package/dist/registry/prisma.d.ts +67 -0
- package/dist/registry/prisma.js +399 -0
- package/dist/registry/stores.d.ts +21 -0
- package/dist/{assistants/languageModelConfigSchema.js → registry/stores.js} +55 -38
- package/dist/registry/types.d.ts +110 -0
- package/dist/{assistants/LanguageModelProvider.d.ts → registry/types.js} +6 -8
- package/dist/registry/workspaceKeys.d.ts +41 -0
- package/dist/registry/workspaceKeys.js +64 -0
- package/dist/roomr/health.d.ts +9 -0
- package/dist/{assistants/eventsHookSchema.js → roomr/health.js} +22 -18
- package/dist/roomr/index.d.ts +75 -0
- package/dist/roomr/index.js +146 -0
- package/dist/roomr/session.d.ts +133 -0
- package/dist/roomr/session.js +132 -0
- package/dist/session/index.d.ts +19 -0
- package/dist/session/index.js +35 -0
- package/dist/session/schema.d.ts +2140 -0
- package/dist/session/schema.js +448 -0
- package/dist/sessions/index.d.ts +96 -0
- package/dist/sessions/index.js +197 -0
- package/dist/telemetry.d.ts +76 -0
- package/dist/telemetry.js +360 -0
- package/dist/types.d.ts +3 -5
- package/dist/{voice/Gather.d.ts → usage/CallUsage.d.ts} +19 -18
- package/dist/usage/CallUsage.js +76 -0
- package/dist/usage/index.d.ts +22 -0
- package/dist/usage/index.js +38 -0
- package/dist/usage/meters.d.ts +113 -0
- package/dist/usage/meters.js +90 -0
- package/dist/usage/types.d.ts +159 -0
- package/dist/usage/types.js +84 -0
- package/dist/usage/usageId.d.ts +6 -0
- package/dist/usage/usageId.js +45 -0
- package/dist/utils/{findIntegrationsCredentials.js → WriteBehind.d.ts} +13 -10
- package/dist/utils/WriteBehind.js +64 -0
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/index.js +1 -3
- package/dist/utils/{createFetchSingleCallByCallId.d.ts → logUnhandledRejections.d.ts} +8 -4
- package/dist/{assistants/audioFiltersSchema.js → utils/logUnhandledRejections.js} +17 -12
- package/dist/utils/withErrorHandling.js +1 -1
- package/dist/validators/calls.d.ts +3 -0
- package/dist/validators/calls.js +12 -2
- package/dist/validators/identity.d.ts +37 -8
- package/dist/validators/identity.js +22 -3
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.js +1 -0
- package/dist/validators/sip.d.ts +40 -0
- package/dist/validators/sip.js +99 -0
- package/dist/validators/sipnet/credentials.d.ts +2 -2
- package/dist/validators/sipnet/domains.js +7 -7
- package/dist/validators/sipnet/trunks.d.ts +14 -14
- package/dist/validators/sipnet/trunks.js +4 -2
- package/dist/webhooks/Dispatcher.d.ts +87 -0
- package/dist/webhooks/Dispatcher.js +225 -0
- package/dist/webhooks/bus.d.ts +68 -0
- package/dist/webhooks/bus.js +178 -0
- package/dist/webhooks/events.d.ts +66 -0
- package/dist/webhooks/events.js +62 -0
- package/dist/webhooks/index.d.ts +23 -0
- package/dist/webhooks/index.js +39 -0
- package/dist/webhooks/prisma.d.ts +55 -0
- package/dist/webhooks/prisma.js +242 -0
- package/dist/webhooks/signing.d.ts +8 -0
- package/dist/webhooks/signing.js +53 -0
- package/package.json +25 -11
- package/schema/session.v1.json +871 -0
- package/dist/assistants/assistantSchema.d.ts +0 -739
- package/dist/assistants/assistantSchema.js +0 -37
- package/dist/assistants/conversationSettingsSchema.d.ts +0 -122
- package/dist/assistants/conversationSettingsSchema.js +0 -133
- package/dist/assistants/eventsHookSchema.d.ts +0 -38
- package/dist/assistants/languageModelConfigSchema.d.ts +0 -206
- package/dist/identity/tokenHasAccessKeyId.d.ts +0 -2
- package/dist/protos/voice.proto +0 -557
- package/dist/utils/createFetchSingleCallByCallId.js +0 -33
- package/dist/utils/findIntegrationsCredentials.d.ts +0 -23
- package/dist/utils/types.js +0 -2
- package/dist/voice/Dial.js +0 -20
- package/dist/voice/Gather.js +0 -9
- package/dist/voice/Mute.d.ts +0 -31
- package/dist/voice/Mute.js +0 -9
- package/dist/voice/Play.d.ts +0 -30
- package/dist/voice/Play.js +0 -2
- package/dist/voice/PlayDtmf.js +0 -2
- package/dist/voice/PlaybackControl.d.ts +0 -31
- package/dist/voice/PlaybackControl.js +0 -11
- package/dist/voice/Record.d.ts +0 -36
- package/dist/voice/Record.js +0 -7
- package/dist/voice/Say.d.ts +0 -28
- package/dist/voice/Say.js +0 -2
- package/dist/voice/StopSay.js +0 -2
- package/dist/voice/Stream.d.ts +0 -53
- package/dist/voice/Stream.js +0 -19
- package/dist/voice/StreamGather.d.ts +0 -34
- package/dist/voice/StreamGather.js +0 -9
- package/dist/voice/Verb.d.ts +0 -27
- package/dist/voice/Verb.js +0 -2
- package/dist/voice/voice.d.ts +0 -171
- package/dist/voice/voice.js +0 -65
- package/dist/{assistants → agents}/testCasesSchema.d.ts +4 -4
- /package/dist/{assistants → agents}/testCasesSchema.js +0 -0
- /package/dist/{assistants → agents}/tools/index.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/index.js +0 -0
- /package/dist/{assistants → agents}/tools/propertySchema.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/propertySchema.js +0 -0
- /package/dist/{assistants → agents}/tools/toolSchema.d.ts +0 -0
- /package/dist/{assistants → agents}/tools/toolSchema.js +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { PrismaLike } from "./prisma";
|
|
20
|
+
export type WorkspaceKeysOptions = {
|
|
21
|
+
/** How long a looked-up key (or its absence) is reused (default 30 s). */
|
|
22
|
+
cacheMs?: number;
|
|
23
|
+
now?: () => number;
|
|
24
|
+
};
|
|
25
|
+
export declare class PrismaWorkspaceKeys {
|
|
26
|
+
private readonly prisma;
|
|
27
|
+
private readonly options;
|
|
28
|
+
private cache;
|
|
29
|
+
constructor(prisma: PrismaLike, options?: WorkspaceKeysOptions);
|
|
30
|
+
private now;
|
|
31
|
+
/** The workspace's key for a provider, or undefined (then the platform key applies). */
|
|
32
|
+
get(workspaceRef: string, providerId: string): Promise<string | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* The workspace's key for a credentialRef: the providers that use that ref (from the catalog)
|
|
35
|
+
* are tried in order.
|
|
36
|
+
*/
|
|
37
|
+
forCredentialRef(workspaceRef: string, credentialRef: string, providers: {
|
|
38
|
+
id: string;
|
|
39
|
+
credentialRef: string;
|
|
40
|
+
}[]): Promise<string | undefined>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PrismaWorkspaceKeys = void 0;
|
|
13
|
+
class PrismaWorkspaceKeys {
|
|
14
|
+
constructor(prisma, options = {}) {
|
|
15
|
+
this.prisma = prisma;
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.cache = new Map();
|
|
18
|
+
}
|
|
19
|
+
now() {
|
|
20
|
+
var _a, _b, _c;
|
|
21
|
+
return (_c = (_b = (_a = this.options).now) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Date.now();
|
|
22
|
+
}
|
|
23
|
+
/** The workspace's key for a provider, or undefined (then the platform key applies). */
|
|
24
|
+
get(workspaceRef, providerId) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
if (!workspaceRef || !providerId)
|
|
28
|
+
return undefined;
|
|
29
|
+
const id = `${workspaceRef}\u0000${providerId}`;
|
|
30
|
+
const hit = this.cache.get(id);
|
|
31
|
+
if (hit && this.now() - hit.at < ((_a = this.options.cacheMs) !== null && _a !== void 0 ? _a : 30000))
|
|
32
|
+
return hit.key;
|
|
33
|
+
const binding = yield this.prisma.workspaceProviderKey.findUnique({
|
|
34
|
+
where: {
|
|
35
|
+
accessKeyId_providerId: { accessKeyId: workspaceRef, providerId }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
let key;
|
|
39
|
+
if (binding) {
|
|
40
|
+
const secret = yield this.prisma.secret.findUnique({
|
|
41
|
+
where: { ref: binding.secretRef }
|
|
42
|
+
});
|
|
43
|
+
key = (secret === null || secret === void 0 ? void 0 : secret.secret) || undefined;
|
|
44
|
+
}
|
|
45
|
+
this.cache.set(id, { at: this.now(), key });
|
|
46
|
+
return key;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The workspace's key for a credentialRef: the providers that use that ref (from the catalog)
|
|
51
|
+
* are tried in order.
|
|
52
|
+
*/
|
|
53
|
+
forCredentialRef(workspaceRef, credentialRef, providers) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
for (const p of providers.filter((x) => x.credentialRef === credentialRef)) {
|
|
56
|
+
const key = yield this.get(workspaceRef, p.id);
|
|
57
|
+
if (key)
|
|
58
|
+
return key;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.PrismaWorkspaceKeys = PrismaWorkspaceKeys;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** How long one health check may take. */
|
|
2
|
+
export declare const HEALTH_CHECK_TIMEOUT_MS = 2000;
|
|
3
|
+
/**
|
|
4
|
+
* Whether `address` (host:port) answers the standard gRPC health check (grpc.health.v1) with
|
|
5
|
+
* SERVING for the server as a whole. False on any error, a timeout or any other status (a Roomr
|
|
6
|
+
* node or AppBridge replica draining after SIGTERM reports NOT_SERVING). Through a Kubernetes
|
|
7
|
+
* Service or a Compose service name the check reaches one ready replica.
|
|
8
|
+
*/
|
|
9
|
+
export declare function checkGrpcHealth(address: string, timeoutMs?: number): Promise<boolean>;
|
|
@@ -33,7 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.HEALTH_CHECK_TIMEOUT_MS = void 0;
|
|
37
|
+
exports.checkGrpcHealth = checkGrpcHealth;
|
|
37
38
|
/**
|
|
38
39
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
39
40
|
* http://github.com/fonoster/fonoster
|
|
@@ -52,20 +53,23 @@ exports.EventsHookAllowedEvents = exports.eventsHookSchema = void 0;
|
|
|
52
53
|
* See the License for the specific language governing permissions and
|
|
53
54
|
* limitations under the License.
|
|
54
55
|
*/
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
57
|
+
const grpc_health_check_1 = require("grpc-health-check");
|
|
58
|
+
/** How long one health check may take. */
|
|
59
|
+
exports.HEALTH_CHECK_TIMEOUT_MS = 2000;
|
|
60
|
+
/**
|
|
61
|
+
* Whether `address` (host:port) answers the standard gRPC health check (grpc.health.v1) with
|
|
62
|
+
* SERVING for the server as a whole. False on any error, a timeout or any other status (a Roomr
|
|
63
|
+
* node or AppBridge replica draining after SIGTERM reports NOT_SERVING). Through a Kubernetes
|
|
64
|
+
* Service or a Compose service name the check reaches one ready replica.
|
|
65
|
+
*/
|
|
66
|
+
function checkGrpcHealth(address, timeoutMs = exports.HEALTH_CHECK_TIMEOUT_MS) {
|
|
67
|
+
const Health = grpc.makeGenericClientConstructor(grpc_health_check_1.service, "Health");
|
|
68
|
+
const client = new Health(address, grpc.credentials.createInsecure());
|
|
69
|
+
return new Promise((resolve) => {
|
|
70
|
+
client.Check({ service: "" }, { deadline: Date.now() + timeoutMs }, (error, res) => {
|
|
71
|
+
client.close();
|
|
72
|
+
resolve(!error && ((res === null || res === void 0 ? void 0 : res.status) === "SERVING" || (res === null || res === void 0 ? void 0 : res.status) === 1));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
2
|
+
/** The proto file this package loads. */
|
|
3
|
+
export declare const ROOMR_PROTO: string;
|
|
4
|
+
export type SipAuth = {
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
};
|
|
8
|
+
export type SipTarget = {
|
|
9
|
+
uri: string;
|
|
10
|
+
proxy?: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
auth?: SipAuth;
|
|
13
|
+
};
|
|
14
|
+
export type CreateCallRequest = {
|
|
15
|
+
callRef?: string;
|
|
16
|
+
to: SipTarget;
|
|
17
|
+
from?: string;
|
|
18
|
+
roomRef?: string;
|
|
19
|
+
session?: string;
|
|
20
|
+
ringTimeoutS?: number;
|
|
21
|
+
/** Passed through untouched in the events for this call (e.g. { app_ref }). */
|
|
22
|
+
metadata?: Record<string, string>;
|
|
23
|
+
maxDurationS?: number;
|
|
24
|
+
};
|
|
25
|
+
export type Call = {
|
|
26
|
+
callRef: string;
|
|
27
|
+
roomRef: string;
|
|
28
|
+
state: "RINGING" | "ANSWERED" | "ENDED";
|
|
29
|
+
participantRef: string;
|
|
30
|
+
};
|
|
31
|
+
export type CreateRoomRequest = {
|
|
32
|
+
roomRef?: string;
|
|
33
|
+
maxDurationS?: number;
|
|
34
|
+
/** Overrides the node's emptyRoomTimeout for this room (0: the node's). */
|
|
35
|
+
emptyTimeoutS?: number;
|
|
36
|
+
/** Overrides the node's maxParticipants for this room (0: the node's). */
|
|
37
|
+
maxParticipants?: number;
|
|
38
|
+
};
|
|
39
|
+
export type Room = {
|
|
40
|
+
roomRef: string;
|
|
41
|
+
};
|
|
42
|
+
/** The RPCs the control plane uses, each against one node's control address. */
|
|
43
|
+
export type RoomrCalls = {
|
|
44
|
+
createCall(addr: string, request: CreateCallRequest): Promise<Call>;
|
|
45
|
+
createRoom(addr: string, request: CreateRoomRequest): Promise<Room>;
|
|
46
|
+
endCall(addr: string, request: {
|
|
47
|
+
callRef: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
endRoom(addr: string, request: {
|
|
50
|
+
roomRef: string;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
/** A failed RPC, with its gRPC status code. */
|
|
54
|
+
export declare class RoomrError extends Error {
|
|
55
|
+
readonly code: grpc.status;
|
|
56
|
+
constructor(code: grpc.status, message: string);
|
|
57
|
+
}
|
|
58
|
+
/** The roomr.v1 package (protoLoader options as for the other Fonoster services). */
|
|
59
|
+
export declare function roomrPackage(): grpc.GrpcObject;
|
|
60
|
+
/** The Roomr service definition (fakes serve it). */
|
|
61
|
+
export declare function roomrService(): grpc.ServiceDefinition;
|
|
62
|
+
/** Each call's deadline (ms). */
|
|
63
|
+
export declare const ROOMR_DEADLINE_MS = 2000;
|
|
64
|
+
/**
|
|
65
|
+
* One gRPC channel per node address, reused by every call to it, with HTTP/2 keepalive and a
|
|
66
|
+
* deadline per call. Plaintext: the control port is reachable only inside the deployment's
|
|
67
|
+
* network. `close()` closes every channel.
|
|
68
|
+
*/
|
|
69
|
+
export declare function createRoomrPool(options?: {
|
|
70
|
+
deadlineMs?: number;
|
|
71
|
+
}): RoomrCalls & {
|
|
72
|
+
close(): void;
|
|
73
|
+
};
|
|
74
|
+
export * from "./health";
|
|
75
|
+
export * from "./session";
|
|
@@ -0,0 +1,146 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
39
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
40
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
42
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
43
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
44
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.ROOMR_DEADLINE_MS = exports.RoomrError = exports.ROOMR_PROTO = void 0;
|
|
49
|
+
exports.roomrPackage = roomrPackage;
|
|
50
|
+
exports.roomrService = roomrService;
|
|
51
|
+
exports.createRoomrPool = createRoomrPool;
|
|
52
|
+
/**
|
|
53
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
54
|
+
* http://github.com/fonoster/fonoster
|
|
55
|
+
*
|
|
56
|
+
* This file is part of Fonoster
|
|
57
|
+
*
|
|
58
|
+
* Licensed under the MIT License (the "License");
|
|
59
|
+
* you may not use this file except in compliance with
|
|
60
|
+
* the License. You may obtain a copy of the License at
|
|
61
|
+
*
|
|
62
|
+
* https://opensource.org/licenses/MIT
|
|
63
|
+
*
|
|
64
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
65
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
66
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
67
|
+
* See the License for the specific language governing permissions and
|
|
68
|
+
* limitations under the License.
|
|
69
|
+
*/
|
|
70
|
+
const path = __importStar(require("path"));
|
|
71
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
72
|
+
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
73
|
+
// The controller's side of Roomr (roomr.v1.Roomr, redesign-roomr "Roomr is a gRPC service
|
|
74
|
+
// with three nouns"). The proto is fonoster/roomr's api/roomr/v1/roomr.proto; src/protos/roomr.proto
|
|
75
|
+
// is the copy of the pinned release (npm run sync:roomr; the client test checks it).
|
|
76
|
+
/** The proto file this package loads. */
|
|
77
|
+
exports.ROOMR_PROTO = path.join(__dirname, "..", "protos", "roomr.proto");
|
|
78
|
+
/** A failed RPC, with its gRPC status code. */
|
|
79
|
+
class RoomrError extends Error {
|
|
80
|
+
constructor(code, message) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.code = code;
|
|
83
|
+
this.name = "RoomrError";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.RoomrError = RoomrError;
|
|
87
|
+
let loaded;
|
|
88
|
+
/** The roomr.v1 package (protoLoader options as for the other Fonoster services). */
|
|
89
|
+
function roomrPackage() {
|
|
90
|
+
loaded !== null && loaded !== void 0 ? loaded : (loaded = grpc.loadPackageDefinition(protoLoader.loadSync(exports.ROOMR_PROTO, {
|
|
91
|
+
keepCase: false,
|
|
92
|
+
longs: String,
|
|
93
|
+
enums: String,
|
|
94
|
+
defaults: true,
|
|
95
|
+
oneofs: true
|
|
96
|
+
})));
|
|
97
|
+
return loaded.roomr.v1;
|
|
98
|
+
}
|
|
99
|
+
/** The Roomr service definition (fakes serve it). */
|
|
100
|
+
function roomrService() {
|
|
101
|
+
return roomrPackage().Roomr.service;
|
|
102
|
+
}
|
|
103
|
+
/** Each call's deadline (ms). */
|
|
104
|
+
exports.ROOMR_DEADLINE_MS = 2000;
|
|
105
|
+
/**
|
|
106
|
+
* One gRPC channel per node address, reused by every call to it, with HTTP/2 keepalive and a
|
|
107
|
+
* deadline per call. Plaintext: the control port is reachable only inside the deployment's
|
|
108
|
+
* network. `close()` closes every channel.
|
|
109
|
+
*/
|
|
110
|
+
function createRoomrPool(options = {}) {
|
|
111
|
+
const Client = roomrPackage().Roomr;
|
|
112
|
+
const clients = new Map();
|
|
113
|
+
const client = (addr) => {
|
|
114
|
+
let c = clients.get(addr);
|
|
115
|
+
if (!c) {
|
|
116
|
+
c = new Client(addr, grpc.credentials.createInsecure(), {
|
|
117
|
+
"grpc.keepalive_time_ms": 10000,
|
|
118
|
+
"grpc.keepalive_timeout_ms": 5000,
|
|
119
|
+
"grpc.keepalive_permit_without_calls": 1
|
|
120
|
+
});
|
|
121
|
+
clients.set(addr, c);
|
|
122
|
+
}
|
|
123
|
+
return c;
|
|
124
|
+
};
|
|
125
|
+
const call = (method) => (addr, request) => new Promise((resolve, reject) => {
|
|
126
|
+
var _a;
|
|
127
|
+
const rpc = client(addr)[method].bind(client(addr));
|
|
128
|
+
rpc(request, { deadline: Date.now() + ((_a = options.deadlineMs) !== null && _a !== void 0 ? _a : exports.ROOMR_DEADLINE_MS) }, (err, res) => err ? reject(new RoomrError(err.code, err.details)) : resolve(res));
|
|
129
|
+
});
|
|
130
|
+
const empty = (method) => (addr, request) => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
yield call(method)(addr, request);
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
createCall: call("CreateCall"),
|
|
135
|
+
createRoom: call("CreateRoom"),
|
|
136
|
+
endCall: empty("EndCall"),
|
|
137
|
+
endRoom: empty("EndRoom"),
|
|
138
|
+
close() {
|
|
139
|
+
for (const c of clients.values())
|
|
140
|
+
c.close();
|
|
141
|
+
clients.clear();
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
__exportStar(require("./health"), exports);
|
|
146
|
+
__exportStar(require("./session"), exports);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import * as grpc from "@grpc/grpc-js";
|
|
2
|
+
/** The proto file this module loads. */
|
|
3
|
+
export declare const SESSION_PROTO: string;
|
|
4
|
+
/** The port AppBridge serves Session.Connect (and grpc.health.v1) on by default. */
|
|
5
|
+
export declare const SESSION_PORT = 50071;
|
|
6
|
+
/** The gRPC service name, as the health service reports it. */
|
|
7
|
+
export declare const SESSION_SERVICE_NAME = "session.v1.Session";
|
|
8
|
+
/** An RTP endpoint: `codec` is "L16/16000" on app legs; `srtpKey` (SDES, base64) when encrypted. */
|
|
9
|
+
export type MediaEndpoint = {
|
|
10
|
+
ip: string;
|
|
11
|
+
port: number;
|
|
12
|
+
codec?: string;
|
|
13
|
+
srtpKey?: string;
|
|
14
|
+
};
|
|
15
|
+
export type SessionSipTarget = {
|
|
16
|
+
uri: string;
|
|
17
|
+
proxy?: string;
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
auth?: {
|
|
20
|
+
username: string;
|
|
21
|
+
password: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export type SessionStart = {
|
|
25
|
+
callRef: string;
|
|
26
|
+
direction: "INBOUND" | "OUTBOUND";
|
|
27
|
+
from: string;
|
|
28
|
+
to: string;
|
|
29
|
+
/** Every INVITE header (inbound) or CreateCall's to.headers (outbound). */
|
|
30
|
+
headers: Record<string, string>;
|
|
31
|
+
/** CreateCall's metadata, untouched (outbound calls carry `app_ref`). */
|
|
32
|
+
metadata: Record<string, string>;
|
|
33
|
+
roomRef: string;
|
|
34
|
+
/** The node's RTP endpoint for this call's app leg. */
|
|
35
|
+
media?: MediaEndpoint;
|
|
36
|
+
nodeRef: string;
|
|
37
|
+
};
|
|
38
|
+
export type SessionDtmf = {
|
|
39
|
+
digit: string;
|
|
40
|
+
source?: string;
|
|
41
|
+
};
|
|
42
|
+
export type SessionEvent = {
|
|
43
|
+
participantJoined?: {
|
|
44
|
+
participantRef: string;
|
|
45
|
+
trackId: number;
|
|
46
|
+
};
|
|
47
|
+
participantLeft?: {
|
|
48
|
+
participantRef: string;
|
|
49
|
+
cause: string;
|
|
50
|
+
};
|
|
51
|
+
transferResult?: {
|
|
52
|
+
status: string;
|
|
53
|
+
cause?: string;
|
|
54
|
+
sipStatus?: number;
|
|
55
|
+
};
|
|
56
|
+
ended?: {
|
|
57
|
+
cause: string;
|
|
58
|
+
sipStatus?: number;
|
|
59
|
+
};
|
|
60
|
+
/** The oneof member that is set (protoLoader `oneofs: true`). */
|
|
61
|
+
event?: "participantJoined" | "participantLeft" | "transferResult" | "ended";
|
|
62
|
+
};
|
|
63
|
+
/** A message from the node. */
|
|
64
|
+
export type NodeMessage = {
|
|
65
|
+
start?: SessionStart;
|
|
66
|
+
dtmf?: SessionDtmf;
|
|
67
|
+
event?: SessionEvent;
|
|
68
|
+
msg?: "start" | "dtmf" | "event";
|
|
69
|
+
};
|
|
70
|
+
export type ListenTrack = {
|
|
71
|
+
trackId: number;
|
|
72
|
+
rtp: MediaEndpoint;
|
|
73
|
+
};
|
|
74
|
+
/** A message to the node (exactly one member set). */
|
|
75
|
+
export type AppMessage = {
|
|
76
|
+
answer?: {
|
|
77
|
+
media: MediaEndpoint;
|
|
78
|
+
maxDurationS?: number;
|
|
79
|
+
};
|
|
80
|
+
ready?: {
|
|
81
|
+
media: MediaEndpoint;
|
|
82
|
+
};
|
|
83
|
+
reject?: {
|
|
84
|
+
sipStatus: number;
|
|
85
|
+
reason?: string;
|
|
86
|
+
};
|
|
87
|
+
transfer?: {
|
|
88
|
+
to: SessionSipTarget;
|
|
89
|
+
mode: "cold" | "warm" | "refer";
|
|
90
|
+
music?: string;
|
|
91
|
+
ringTimeoutS?: number;
|
|
92
|
+
};
|
|
93
|
+
transferComplete?: Record<string, never>;
|
|
94
|
+
/** Cuts the caller off from the app; the node loops `music` (a WAV URL) to the caller alone. */
|
|
95
|
+
hold?: {
|
|
96
|
+
music?: string;
|
|
97
|
+
};
|
|
98
|
+
resume?: Record<string, never>;
|
|
99
|
+
/** RFC 4733 events on the caller's leg, in order. */
|
|
100
|
+
sendDtmf?: {
|
|
101
|
+
digits: string;
|
|
102
|
+
};
|
|
103
|
+
addListener?: {
|
|
104
|
+
listenerRef: string;
|
|
105
|
+
listen: ListenTrack[];
|
|
106
|
+
};
|
|
107
|
+
removeListener?: {
|
|
108
|
+
listenerRef: string;
|
|
109
|
+
};
|
|
110
|
+
hangup?: {
|
|
111
|
+
sipStatus?: number;
|
|
112
|
+
reason?: string;
|
|
113
|
+
};
|
|
114
|
+
msg?: AppMessageType;
|
|
115
|
+
};
|
|
116
|
+
export type AppMessageType = "answer" | "ready" | "reject" | "transfer" | "transferComplete" | "hold" | "resume" | "sendDtmf" | "addListener" | "removeListener" | "hangup";
|
|
117
|
+
/** The member a message carries (the oneof's name), for logs and fakes. */
|
|
118
|
+
export declare function messageType<T extends Record<string, unknown>>(message: T, members: readonly string[]): string | undefined;
|
|
119
|
+
export declare const APP_MESSAGE_TYPES: readonly AppMessageType[];
|
|
120
|
+
export declare const NODE_MESSAGE_TYPES: readonly ["start", "dtmf", "event"];
|
|
121
|
+
export declare const SESSION_EVENT_TYPES: readonly ["participantJoined", "participantLeft", "transferResult", "ended"];
|
|
122
|
+
/** Ended causes the node sends (media-control "Endings carry a reason"). */
|
|
123
|
+
export declare const ENDED_CAUSES: readonly ["caller_hangup", "callee_hangup", "busy", "no_answer", "rejected", "media_timeout", "node_error", "max_duration", "removed", "app_gone"];
|
|
124
|
+
/** The session.v1 package (protoLoader options as for the other Fonoster services). */
|
|
125
|
+
export declare function sessionPackage(): grpc.GrpcObject;
|
|
126
|
+
/** The Session service definition (AppBridge serves it). */
|
|
127
|
+
export declare function sessionService(): grpc.ServiceDefinition;
|
|
128
|
+
/** The Session client constructor (the node's side; fakes use it). */
|
|
129
|
+
export declare function sessionClient(): grpc.ServiceClientConstructor;
|
|
130
|
+
/** The server side of one control stream. */
|
|
131
|
+
export type SessionServerStream = grpc.ServerDuplexStream<NodeMessage, AppMessage>;
|
|
132
|
+
/** The client side of one control stream. */
|
|
133
|
+
export type SessionClientStream = grpc.ClientDuplexStream<NodeMessage, AppMessage>;
|
|
@@ -0,0 +1,132 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ENDED_CAUSES = exports.SESSION_EVENT_TYPES = exports.NODE_MESSAGE_TYPES = exports.APP_MESSAGE_TYPES = exports.SESSION_SERVICE_NAME = exports.SESSION_PORT = exports.SESSION_PROTO = void 0;
|
|
37
|
+
exports.messageType = messageType;
|
|
38
|
+
exports.sessionPackage = sessionPackage;
|
|
39
|
+
exports.sessionService = sessionService;
|
|
40
|
+
exports.sessionClient = sessionClient;
|
|
41
|
+
/**
|
|
42
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
43
|
+
* http://github.com/fonoster/fonoster
|
|
44
|
+
*
|
|
45
|
+
* This file is part of Fonoster
|
|
46
|
+
*
|
|
47
|
+
* Licensed under the MIT License (the "License");
|
|
48
|
+
* you may not use this file except in compliance with
|
|
49
|
+
* the License. You may obtain a copy of the License at
|
|
50
|
+
*
|
|
51
|
+
* https://opensource.org/licenses/MIT
|
|
52
|
+
*
|
|
53
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
54
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
55
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
56
|
+
* See the License for the specific language governing permissions and
|
|
57
|
+
* limitations under the License.
|
|
58
|
+
*/
|
|
59
|
+
const path = __importStar(require("path"));
|
|
60
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
61
|
+
const protoLoader = __importStar(require("@grpc/proto-loader"));
|
|
62
|
+
// The per-call control stream (session.v1.Session, redesign-roomr media-control "Each call opens
|
|
63
|
+
// one control stream to the session endpoint"). The Roomr node is the client: it opens one
|
|
64
|
+
// connection per call and sends Start first; the session endpoint (AppBridge) answers with
|
|
65
|
+
// Answer, Ready or Reject and sends the app's commands. Audio never travels here. The proto is
|
|
66
|
+
// fonoster/roomr's api/session/v1/session.proto; src/protos/session.proto is the copy of the
|
|
67
|
+
// pinned release (npm run sync:roomr; the client test checks it).
|
|
68
|
+
/** The proto file this module loads. */
|
|
69
|
+
exports.SESSION_PROTO = path.join(__dirname, "..", "protos", "session.proto");
|
|
70
|
+
/** The port AppBridge serves Session.Connect (and grpc.health.v1) on by default. */
|
|
71
|
+
exports.SESSION_PORT = 50071;
|
|
72
|
+
/** The gRPC service name, as the health service reports it. */
|
|
73
|
+
exports.SESSION_SERVICE_NAME = "session.v1.Session";
|
|
74
|
+
/** The member a message carries (the oneof's name), for logs and fakes. */
|
|
75
|
+
function messageType(message, members) {
|
|
76
|
+
if (typeof message.msg === "string")
|
|
77
|
+
return message.msg;
|
|
78
|
+
return members.find((m) => message[m] !== undefined && message[m] !== null);
|
|
79
|
+
}
|
|
80
|
+
exports.APP_MESSAGE_TYPES = [
|
|
81
|
+
"answer",
|
|
82
|
+
"ready",
|
|
83
|
+
"reject",
|
|
84
|
+
"transfer",
|
|
85
|
+
"transferComplete",
|
|
86
|
+
"hold",
|
|
87
|
+
"resume",
|
|
88
|
+
"sendDtmf",
|
|
89
|
+
"addListener",
|
|
90
|
+
"removeListener",
|
|
91
|
+
"hangup"
|
|
92
|
+
];
|
|
93
|
+
exports.NODE_MESSAGE_TYPES = ["start", "dtmf", "event"];
|
|
94
|
+
exports.SESSION_EVENT_TYPES = [
|
|
95
|
+
"participantJoined",
|
|
96
|
+
"participantLeft",
|
|
97
|
+
"transferResult",
|
|
98
|
+
"ended"
|
|
99
|
+
];
|
|
100
|
+
/** Ended causes the node sends (media-control "Endings carry a reason"). */
|
|
101
|
+
exports.ENDED_CAUSES = [
|
|
102
|
+
"caller_hangup",
|
|
103
|
+
"callee_hangup",
|
|
104
|
+
"busy",
|
|
105
|
+
"no_answer",
|
|
106
|
+
"rejected",
|
|
107
|
+
"media_timeout",
|
|
108
|
+
"node_error",
|
|
109
|
+
"max_duration",
|
|
110
|
+
"removed",
|
|
111
|
+
"app_gone"
|
|
112
|
+
];
|
|
113
|
+
let loaded;
|
|
114
|
+
/** The session.v1 package (protoLoader options as for the other Fonoster services). */
|
|
115
|
+
function sessionPackage() {
|
|
116
|
+
loaded !== null && loaded !== void 0 ? loaded : (loaded = grpc.loadPackageDefinition(protoLoader.loadSync(exports.SESSION_PROTO, {
|
|
117
|
+
keepCase: false,
|
|
118
|
+
longs: Number,
|
|
119
|
+
enums: String,
|
|
120
|
+
defaults: true,
|
|
121
|
+
oneofs: true
|
|
122
|
+
})));
|
|
123
|
+
return loaded.session.v1;
|
|
124
|
+
}
|
|
125
|
+
/** The Session service definition (AppBridge serves it). */
|
|
126
|
+
function sessionService() {
|
|
127
|
+
return sessionPackage().Session.service;
|
|
128
|
+
}
|
|
129
|
+
/** The Session client constructor (the node's side; fakes use it). */
|
|
130
|
+
function sessionClient() {
|
|
131
|
+
return sessionPackage().Session;
|
|
132
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
export * from "./schema";
|