@fonoster/apiserver 0.61.0 → 0.62.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.
|
@@ -6,9 +6,11 @@ import * as grpc from "@grpc/grpc-js";
|
|
|
6
6
|
export declare function ownerOfCall(call: unknown): string | undefined;
|
|
7
7
|
/**
|
|
8
8
|
* The Billing API for the dashboard (billing.proto), when billing is on: each call is passed to
|
|
9
|
-
* the billing service with owner_ref set from the caller, never from the request.
|
|
9
|
+
* the billing service with owner_ref set from the caller, never from the request. GetCallsStatus
|
|
10
|
+
* is for anyone in the workspace (the authorization interceptor checks the role) and gets
|
|
11
|
+
* access_key_id from the call.
|
|
10
12
|
*/
|
|
11
|
-
declare function buildService(address: string, ownerOf?: typeof ownerOfCall): {
|
|
13
|
+
declare function buildService(address: string, ownerOf?: typeof ownerOfCall, accessKeyIdOf?: (call: unknown) => string | undefined): {
|
|
12
14
|
definition: {
|
|
13
15
|
serviceName: string;
|
|
14
16
|
pckg: string;
|
|
@@ -16,7 +18,7 @@ declare function buildService(address: string, ownerOf?: typeof ownerOfCall): {
|
|
|
16
18
|
proto: string;
|
|
17
19
|
};
|
|
18
20
|
handlers: {
|
|
19
|
-
|
|
21
|
+
getCallsStatus: (call: {
|
|
20
22
|
request: Record<string, unknown>;
|
|
21
23
|
}, callback: (error: grpc.ServiceError | null | Partial<grpc.ServiceError>, response?: unknown) => void) => void;
|
|
22
24
|
};
|
|
@@ -85,10 +85,17 @@ function ownerOfCall(call) {
|
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
87
|
* The Billing API for the dashboard (billing.proto), when billing is on: each call is passed to
|
|
88
|
-
* the billing service with owner_ref set from the caller, never from the request.
|
|
88
|
+
* the billing service with owner_ref set from the caller, never from the request. GetCallsStatus
|
|
89
|
+
* is for anyone in the workspace (the authorization interceptor checks the role) and gets
|
|
90
|
+
* access_key_id from the call.
|
|
89
91
|
*/
|
|
90
|
-
function buildService(address, ownerOf = ownerOfCall) {
|
|
92
|
+
function buildService(address, ownerOf = ownerOfCall, accessKeyIdOf = (call) => (0, common_1.getAccessKeyIdFromCall)(call)) {
|
|
91
93
|
const client = new (grpc.makeGenericClientConstructor(definition(), "Billing", {}))(address, grpc.credentials.createInsecure());
|
|
94
|
+
const send = (method, request, callback) => client[method](request, (error, response) => {
|
|
95
|
+
if (error)
|
|
96
|
+
logger.verbose("billing call refused", { method, code: error.code });
|
|
97
|
+
callback(error ? { code: error.code, message: error.details } : null, response);
|
|
98
|
+
});
|
|
92
99
|
const forward = (method) => (call, callback) => {
|
|
93
100
|
const ownerRef = ownerOf(call);
|
|
94
101
|
if (!ownerRef) {
|
|
@@ -98,12 +105,9 @@ function buildService(address, ownerOf = ownerOfCall) {
|
|
|
98
105
|
});
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
|
-
|
|
102
|
-
if (error)
|
|
103
|
-
logger.verbose("billing call refused", { method, code: error.code });
|
|
104
|
-
callback(error ? { code: error.code, message: error.details } : null, response);
|
|
105
|
-
});
|
|
108
|
+
send(method, Object.assign(Object.assign({}, call.request), { ownerRef }), callback);
|
|
106
109
|
};
|
|
110
|
+
const getCallsStatus = (call, callback) => send("getCallsStatus", Object.assign(Object.assign({}, call.request), { accessKeyId: accessKeyIdOf(call) }), callback);
|
|
107
111
|
return {
|
|
108
112
|
definition: {
|
|
109
113
|
serviceName: "Billing",
|
|
@@ -111,6 +115,6 @@ function buildService(address, ownerOf = ownerOfCall) {
|
|
|
111
115
|
version: "v1beta2",
|
|
112
116
|
proto: "billing.proto"
|
|
113
117
|
},
|
|
114
|
-
handlers: Object.fromEntries(METHODS.map((m) => [m, forward(m)]))
|
|
118
|
+
handlers: Object.assign(Object.assign({}, Object.fromEntries(METHODS.map((m) => [m, forward(m)]))), { getCallsStatus })
|
|
115
119
|
};
|
|
116
120
|
}
|
package/dist/core/services.d.ts
CHANGED
|
@@ -410,7 +410,7 @@ declare const services: Promise<[{
|
|
|
410
410
|
proto: string;
|
|
411
411
|
};
|
|
412
412
|
handlers: {
|
|
413
|
-
|
|
413
|
+
getCallsStatus: (call: {
|
|
414
414
|
request: Record<string, unknown>;
|
|
415
415
|
}, callback: (error: import("@grpc/grpc-js").ServiceError | null | Partial<import("@grpc/grpc-js").ServiceError>, response?: unknown) => void) => void;
|
|
416
416
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"fonoster-owner": "./dist/bin/owner.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@fonoster/authz": "^0.
|
|
27
|
-
"@fonoster/autopilot": "^0.
|
|
28
|
-
"@fonoster/callrecord": "^0.
|
|
29
|
-
"@fonoster/common": "^0.
|
|
30
|
-
"@fonoster/identity": "^0.
|
|
31
|
-
"@fonoster/logger": "^0.
|
|
32
|
-
"@fonoster/sipnet": "^0.
|
|
33
|
-
"@fonoster/types": "^0.
|
|
26
|
+
"@fonoster/authz": "^0.62.0",
|
|
27
|
+
"@fonoster/autopilot": "^0.62.0",
|
|
28
|
+
"@fonoster/callrecord": "^0.62.0",
|
|
29
|
+
"@fonoster/common": "^0.62.0",
|
|
30
|
+
"@fonoster/identity": "^0.62.0",
|
|
31
|
+
"@fonoster/logger": "^0.62.0",
|
|
32
|
+
"@fonoster/sipnet": "^0.62.0",
|
|
33
|
+
"@fonoster/types": "^0.62.0",
|
|
34
34
|
"@grpc/grpc-js": "~1.14.6",
|
|
35
35
|
"@prisma/client": "^6.19.1",
|
|
36
36
|
"@routr/common": "^2.24.0",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@fonoster/ops": "^0.
|
|
65
|
+
"@fonoster/ops": "^0.62.0",
|
|
66
66
|
"@types/express": "^5.0.6",
|
|
67
67
|
"@types/jsonwebtoken": "^9.0.10",
|
|
68
68
|
"@types/uuid": "^10.0.0",
|
|
69
69
|
"@types/validator": "^13.15.10"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "2fe4ba952809d7f460f57089cf8cee34dd053baf",
|
|
72
72
|
"prisma": {
|
|
73
73
|
"seed": "tsx src/core/seed.ts"
|
|
74
74
|
}
|