@conduitplatform/grpc-sdk 0.15.1 → 0.15.3
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/classes/GrpcServer.d.ts +1 -1
- package/dist/classes/GrpcServer.js +5 -5
- package/dist/classes/GrpcServer.js.map +1 -1
- package/dist/helpers/GrpcHelper.d.ts +1 -1
- package/dist/helpers/GrpcHelper.js +2 -2
- package/dist/helpers/GrpcHelper.js.map +1 -1
- package/dist/modules/admin/index.d.ts +2 -0
- package/dist/modules/admin/index.js +7 -0
- package/dist/modules/admin/index.js.map +1 -1
- package/dist/modules/pushNotifications/index.d.ts +11 -1
- package/dist/modules/pushNotifications/index.js +20 -1
- package/dist/modules/pushNotifications/index.js.map +1 -1
- package/dist/modules/router/index.d.ts +2 -0
- package/dist/modules/router/index.js +7 -0
- package/dist/modules/router/index.js.map +1 -1
- package/dist/protoUtils/core.d.ts +42 -0
- package/dist/protoUtils/core.js +142 -10
- package/dist/protoUtils/core.js.map +1 -1
- package/dist/protoUtils/push-notifications.d.ts +65 -0
- package/dist/protoUtils/push-notifications.js +192 -7
- package/dist/protoUtils/push-notifications.js.map +1 -1
- package/dist/protoUtils/router.d.ts +42 -0
- package/dist/protoUtils/router.js +144 -12
- package/dist/protoUtils/router.js.map +1 -1
- package/dist/routing/RoutingManager.js +14 -4
- package/dist/routing/RoutingManager.js.map +1 -1
- package/dist/routing/RoutingUtilities.d.ts +0 -6
- package/dist/routing/RoutingUtilities.js +1 -60
- package/dist/routing/RoutingUtilities.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,30 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.wrapFunctionsAsync =
|
|
3
|
+
exports.wrapFunctionsAsync = void 0;
|
|
7
4
|
var wrapRouterFunctions_1 = require("./wrapRouterFunctions");
|
|
8
|
-
var path_1 = __importDefault(require("path"));
|
|
9
|
-
var fs_1 = __importDefault(require("fs"));
|
|
10
|
-
var protofile_template = "\nsyntax = \"proto3\";\npackage MODULE_NAME.router;\n\nservice Router {\n MODULE_FUNCTIONS\n}\n\nmessage RouterRequest {\n string params = 1;\n string path = 2;\n string headers = 3;\n string context = 4;\n string cookies = 5;\n}\n\nmessage RouterResponse {\n string result = 1;\n string redirect = 2;\n repeated Cookie setCookies = 3;\n repeated Cookie removeCookies = 4;\n}\n\nmessage SocketRequest {\n string event = 1;\n string socketId = 2;\n string params = 3;\n string context = 4;\n}\n\nmessage Cookie {\n string name = 1;\n optional string value = 2;\n Options options = 3;\n}\n\nmessage Options {\n bool httpOnly = 1;\n bool secure = 2;\n bool signed = 3;\n int32 maxAge = 4;\n string path = 5;\n string domain = 6;\n string sameSite = 7;\n \n}\nmessage SocketResponse {\n string event = 1;\n string data = 2;\n repeated string receivers = 3;\n repeated string rooms = 4;\n}\n";
|
|
11
|
-
var admin_protofile_template = "\nsyntax = \"proto3\";\npackage MODULE_NAME.admin;\n\nservice Admin {\n MODULE_FUNCTIONS\n}\n\nmessage AdminRequest {\n string params = 1;\n string path = 2;\n string headers = 3;\n string context = 4;\n string cookies = 5;\n}\n\nmessage AdminResponse {\n string result = 1;\n string redirect = 2;\n repeated Cookie setCookies = 3;\n repeated Cookie removeCookies = 4;\n}\n\nmessage SocketRequest {\n string event = 1;\n string socketId = 2;\n string params = 3;\n string context = 4;\n}\n\nmessage Cookie {\n string name = 1;\n optional string value = 2;\n Options options = 3;\n}\n\nmessage Options {\n bool httpOnly = 1;\n bool secure = 2;\n bool signed = 3;\n int32 maxAge = 4;\n string path = 5;\n string domain = 6;\n string sameSite = 7;\n \n}\nmessage SocketResponse {\n string event = 1;\n string data = 2;\n repeated string receivers = 3;\n repeated string rooms = 4;\n}\n";
|
|
12
|
-
function constructProtoFile(moduleName, paths, isAdmin) {
|
|
13
|
-
if (isAdmin === void 0) { isAdmin = false; }
|
|
14
|
-
var formattedModuleName = getFormattedModuleName(moduleName);
|
|
15
|
-
var protoFunctions = createProtoFunctions(paths, isAdmin);
|
|
16
|
-
var protoFile = (isAdmin ? admin_protofile_template : protofile_template)
|
|
17
|
-
.toString()
|
|
18
|
-
.replace('MODULE_FUNCTIONS', protoFunctions);
|
|
19
|
-
protoFile = protoFile.replace('MODULE_NAME', formattedModuleName);
|
|
20
|
-
var protoPath = path_1.default.resolve(__dirname, Math.random().toString(36).substring(7));
|
|
21
|
-
fs_1.default.writeFileSync(protoPath, protoFile);
|
|
22
|
-
return { path: protoPath, name: formattedModuleName, file: protoFile };
|
|
23
|
-
}
|
|
24
|
-
exports.constructProtoFile = constructProtoFile;
|
|
25
|
-
function getFormattedModuleName(moduleName) {
|
|
26
|
-
return moduleName.replace('-', '_');
|
|
27
|
-
}
|
|
28
5
|
function wrapFunctionsAsync(functions, routerType) {
|
|
29
6
|
var modifiedFunctions = {};
|
|
30
7
|
Object.keys(functions).forEach(function (key) {
|
|
@@ -33,40 +10,4 @@ function wrapFunctionsAsync(functions, routerType) {
|
|
|
33
10
|
return modifiedFunctions;
|
|
34
11
|
}
|
|
35
12
|
exports.wrapFunctionsAsync = wrapFunctionsAsync;
|
|
36
|
-
function createProtoFunctions(paths, isAdmin) {
|
|
37
|
-
var protoFunctions = '';
|
|
38
|
-
paths.forEach(function (r) {
|
|
39
|
-
if (r.hasOwnProperty('events')) {
|
|
40
|
-
protoFunctions += createProtoFunctionsForSocket(r, protoFunctions);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
protoFunctions += createProtoFunctionForRoute(r, protoFunctions, isAdmin);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return protoFunctions;
|
|
47
|
-
}
|
|
48
|
-
function createProtoFunctionsForSocket(path, protoFunctions) {
|
|
49
|
-
var newFunctions = '';
|
|
50
|
-
var events = JSON.parse(path.events);
|
|
51
|
-
Object.keys(events).forEach(function (event) {
|
|
52
|
-
var newFunction = createGrpcFunctionName(events[event].grpcFunction);
|
|
53
|
-
if (protoFunctions.indexOf("rpc ".concat(newFunction, "(")) !== -1) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
newFunctions += "rpc ".concat(newFunction, "(SocketRequest) returns (SocketResponse);\n");
|
|
57
|
-
});
|
|
58
|
-
return newFunctions;
|
|
59
|
-
}
|
|
60
|
-
function createProtoFunctionForRoute(path, protoFunctions, isAdmin) {
|
|
61
|
-
var newFunction = createGrpcFunctionName(path.grpcFunction);
|
|
62
|
-
if (protoFunctions.indexOf("rpc ".concat(newFunction, "(")) !== -1) {
|
|
63
|
-
return '';
|
|
64
|
-
}
|
|
65
|
-
return isAdmin
|
|
66
|
-
? "rpc ".concat(newFunction, "(AdminRequest) returns (AdminResponse);\n")
|
|
67
|
-
: "rpc ".concat(newFunction, "(RouterRequest) returns (RouterResponse);\n");
|
|
68
|
-
}
|
|
69
|
-
function createGrpcFunctionName(grpcFunction) {
|
|
70
|
-
return grpcFunction.charAt(0).toUpperCase() + grpcFunction.slice(1);
|
|
71
|
-
}
|
|
72
13
|
//# sourceMappingURL=RoutingUtilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutingUtilities.js","sourceRoot":"","sources":["../../src/routing/RoutingUtilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RoutingUtilities.js","sourceRoot":"","sources":["../../src/routing/RoutingUtilities.ts"],"names":[],"mappings":";;;AAAA,6DAAgF;AAGhF,SAAgB,kBAAkB,CAChC,SAA8C,EAC9C,UAA8B;IAI9B,IAAM,iBAAiB,GAEnB,EAAE,CAAC;IACP,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;QAChC,iBAAiB,CAAC,GAAG,CAAC,GAAG,IAAA,4CAAsB,EAAC,SAAS,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAbD,gDAaC"}
|