@conduitplatform/module-tools 0.16.0-alpha.8 → 0.16.0-rc.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/ManagedModule.d.ts +1 -0
- package/dist/ManagedModule.js +153 -358
- package/dist/ManagedModule.js.map +1 -1
- package/dist/classes/ConduitActiveSchema.d.ts +12 -9
- package/dist/classes/ConduitActiveSchema.js +43 -52
- package/dist/classes/ConduitActiveSchema.js.map +1 -1
- package/dist/classes/ConduitServiceModule.d.ts +2 -0
- package/dist/classes/ConduitServiceModule.js +65 -112
- package/dist/classes/ConduitServiceModule.js.map +1 -1
- package/dist/classes/ConfigController.js +10 -17
- package/dist/classes/ConfigController.js.map +1 -1
- package/dist/classes/GrpcServer.d.ts +1 -0
- package/dist/classes/GrpcServer.js +93 -172
- package/dist/classes/GrpcServer.js.map +1 -1
- package/dist/helpers/GrpcHelper.js +11 -11
- package/dist/helpers/GrpcHelper.js.map +1 -1
- package/dist/helpers/GrpcToParsedRouterRequest.d.ts +2 -0
- package/dist/helpers/GrpcToParsedRouterRequest.js +19 -0
- package/dist/helpers/GrpcToParsedRouterRequest.js.map +1 -0
- package/dist/helpers/TypeHelpers.d.ts +41 -15
- package/dist/helpers/TypeHelpers.js +57 -119
- package/dist/helpers/TypeHelpers.js.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/wrapGrpcFunctions.js +14 -15
- package/dist/helpers/wrapGrpcFunctions.js.map +1 -1
- package/dist/interfaces/ModuleLifecycleStage.d.ts +7 -0
- package/dist/interfaces/ModuleLifecycleStage.js +12 -0
- package/dist/interfaces/ModuleLifecycleStage.js.map +1 -0
- package/dist/logging/index.js +80 -180
- package/dist/logging/index.js.map +1 -1
- package/dist/metrics/MetricsServer.d.ts +2 -1
- package/dist/metrics/MetricsServer.js +25 -70
- package/dist/metrics/MetricsServer.js.map +1 -1
- package/dist/metrics/clientMiddleware.js +76 -217
- package/dist/metrics/clientMiddleware.js.map +1 -1
- package/dist/metrics/config/defaults.js +1 -1
- package/dist/metrics/config/defaults.js.map +1 -1
- package/dist/metrics/index.js +53 -89
- package/dist/metrics/index.js.map +1 -1
- package/dist/module.proto +58 -0
- package/dist/routing/ProxyRouteBuilder.js +21 -24
- package/dist/routing/ProxyRouteBuilder.js.map +1 -1
- package/dist/routing/RouteBuilder.d.ts +5 -5
- package/dist/routing/RouteBuilder.js +31 -34
- package/dist/routing/RouteBuilder.js.map +1 -1
- package/dist/routing/RoutingController.d.ts +8 -0
- package/dist/routing/RoutingController.js +25 -0
- package/dist/routing/RoutingController.js.map +1 -0
- package/dist/routing/RoutingManager.d.ts +5 -2
- package/dist/routing/RoutingManager.js +61 -115
- package/dist/routing/RoutingManager.js.map +1 -1
- package/dist/routing/RoutingUtilities.js +3 -3
- package/dist/routing/RoutingUtilities.js.map +1 -1
- package/dist/routing/wrapRouterFunctions.d.ts +5 -5
- package/dist/routing/wrapRouterFunctions.js +30 -39
- package/dist/routing/wrapRouterFunctions.js.map +1 -1
- package/dist/utilities/convictConfigParser.js +2 -2
- package/dist/utilities/convictConfigParser.js.map +1 -1
- package/dist/utilities/initializeSdk.js +9 -11
- package/dist/utilities/initializeSdk.js.map +1 -1
- package/dist/utilities/linearBackoffTimeout.d.ts +1 -1
- package/dist/utilities/linearBackoffTimeout.js +35 -92
- package/dist/utilities/linearBackoffTimeout.js.map +1 -1
- package/dist/utilities/merge.js +2 -2
- package/dist/utilities/merge.js.map +1 -1
- package/package.json +19 -20
|
@@ -1,188 +1,110 @@
|
|
|
1
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.GrpcServer = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
7
|
+
const helpers_1 = require("../helpers");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const grpc_sdk_1 = __importDefault(require("@conduitplatform/grpc-sdk"));
|
|
10
|
+
class GrpcServer {
|
|
11
|
+
constructor(port) {
|
|
48
12
|
this.started = false;
|
|
49
13
|
this.startedOnce = false;
|
|
50
14
|
this._serviceNames = [];
|
|
51
15
|
this._postponeRequests = 0;
|
|
52
16
|
this._services = [];
|
|
53
|
-
this._url =
|
|
17
|
+
this._url = `0.0.0.0:${port !== null && port !== void 0 ? port : '5000'}`;
|
|
54
18
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.scheduleRefresh();
|
|
96
|
-
return [2 /*return*/, this];
|
|
97
|
-
case 1:
|
|
98
|
-
this._services.push({ protoPath: protoPath, protoDescription: protoDescription, functions: functions });
|
|
99
|
-
this._serviceNames.push(protoDescription);
|
|
100
|
-
if (!this.started) return [3 /*break*/, 2];
|
|
101
|
-
grpc_sdk_1.default.Logger.log('Server already started, scheduling refresh..');
|
|
102
|
-
this.scheduleRefresh();
|
|
103
|
-
return [2 /*return*/, this];
|
|
104
|
-
case 2:
|
|
105
|
-
if (!!this.grpcServer) return [3 /*break*/, 4];
|
|
106
|
-
return [4 /*yield*/, this.wait(1000)];
|
|
107
|
-
case 3:
|
|
108
|
-
_a.sent();
|
|
109
|
-
_a.label = 4;
|
|
110
|
-
case 4:
|
|
111
|
-
(0, helpers_1.addServiceToServer)(this.grpcServer, protoPath, protoDescription, functions);
|
|
112
|
-
return [2 /*return*/, this];
|
|
19
|
+
async waitForReady() {
|
|
20
|
+
while (!(0, lodash_1.isNil)(this.scheduledRestart)) {
|
|
21
|
+
await this.wait(200);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
get url() {
|
|
25
|
+
return this._url;
|
|
26
|
+
}
|
|
27
|
+
async createNewServer(useForce = false) {
|
|
28
|
+
if ((0, lodash_1.isNil)(this._useForce)) {
|
|
29
|
+
this._useForce = useForce;
|
|
30
|
+
}
|
|
31
|
+
const serverResult = await (0, helpers_1.createServer)(this._url);
|
|
32
|
+
this.grpcServer = serverResult.server;
|
|
33
|
+
this._url = this._url.split(':')[0] + ':' + serverResult.port.toString();
|
|
34
|
+
return serverResult.port;
|
|
35
|
+
}
|
|
36
|
+
async addService(protoPath, protoDescription, functions) {
|
|
37
|
+
functions = (0, helpers_1.wrapGrpcFunctions)(functions, this.postponeRestart.bind(this));
|
|
38
|
+
if (this._serviceNames.indexOf(protoDescription) !== -1) {
|
|
39
|
+
grpc_sdk_1.default.Logger.log('Service already exists, performing replace');
|
|
40
|
+
this._services[this._serviceNames.indexOf(protoDescription)] = {
|
|
41
|
+
protoPath,
|
|
42
|
+
protoDescription,
|
|
43
|
+
functions,
|
|
44
|
+
};
|
|
45
|
+
this.scheduleRefresh();
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._services.push({ protoPath, protoDescription, functions });
|
|
50
|
+
this._serviceNames.push(protoDescription);
|
|
51
|
+
if (this.started) {
|
|
52
|
+
grpc_sdk_1.default.Logger.log('Server already started, scheduling refresh..');
|
|
53
|
+
this.scheduleRefresh();
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if (!this.grpcServer) {
|
|
58
|
+
await this.wait(1000);
|
|
113
59
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
})];
|
|
126
|
-
});
|
|
60
|
+
(0, helpers_1.addServiceToServer)(this.grpcServer, protoPath, protoDescription, functions);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async wait(time) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const timeout = setTimeout(() => {
|
|
68
|
+
clearTimeout(timeout);
|
|
69
|
+
resolve();
|
|
70
|
+
}, time);
|
|
127
71
|
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
case 2:
|
|
144
|
-
//gracefully shutdown so that there are no service disruption
|
|
145
|
-
_a.sent();
|
|
146
|
-
_a.label = 3;
|
|
147
|
-
case 3: return [4 /*yield*/, this.createNewServer()];
|
|
148
|
-
case 4:
|
|
149
|
-
_a.sent();
|
|
150
|
-
this._services.forEach(function (service) {
|
|
151
|
-
(0, helpers_1.addServiceToServer)(_this.grpcServer, service.protoPath, service.protoDescription, service.functions);
|
|
152
|
-
});
|
|
153
|
-
if (!this.started && this.startedOnce) {
|
|
154
|
-
this.grpcServer.start();
|
|
155
|
-
this.started = true;
|
|
156
|
-
}
|
|
157
|
-
return [2 /*return*/];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
72
|
+
}
|
|
73
|
+
async refresh() {
|
|
74
|
+
if (this.started) {
|
|
75
|
+
this.started = false;
|
|
76
|
+
if (this._useForce) {
|
|
77
|
+
this.grpcServer.forceShutdown();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
//gracefully shutdown so that there are no service disruption
|
|
81
|
+
await new Promise(resolve => this.grpcServer.tryShutdown(() => resolve()));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
await this.createNewServer();
|
|
85
|
+
this._services.forEach(service => {
|
|
86
|
+
(0, helpers_1.addServiceToServer)(this.grpcServer, service.protoPath, service.protoDescription, service.functions);
|
|
160
87
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
88
|
+
if (!this.started && this.startedOnce) {
|
|
89
|
+
this.grpcServer.start();
|
|
90
|
+
this.started = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
scheduleRefresh() {
|
|
164
94
|
if (this.scheduledRestart) {
|
|
165
95
|
clearTimeout(this.scheduledRestart);
|
|
166
96
|
}
|
|
167
|
-
|
|
168
|
-
this.scheduledRestart = setTimeout(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
self.scheduledRestart = undefined;
|
|
179
|
-
self._postponeRequests = 0;
|
|
180
|
-
return [2 /*return*/];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}); }, 2000);
|
|
184
|
-
};
|
|
185
|
-
GrpcServer.prototype.start = function () {
|
|
97
|
+
const self = this;
|
|
98
|
+
this.scheduledRestart = setTimeout(async () => {
|
|
99
|
+
grpc_sdk_1.default.Logger.log('Begin refresh');
|
|
100
|
+
await self.refresh();
|
|
101
|
+
grpc_sdk_1.default.Logger.log('Refresh complete');
|
|
102
|
+
clearTimeout(self.scheduledRestart);
|
|
103
|
+
self.scheduledRestart = undefined;
|
|
104
|
+
self._postponeRequests = 0;
|
|
105
|
+
}, 2000);
|
|
106
|
+
}
|
|
107
|
+
start() {
|
|
186
108
|
var _a;
|
|
187
109
|
if (this.started) {
|
|
188
110
|
grpc_sdk_1.default.Logger.error('gRPC server is already running!');
|
|
@@ -194,14 +116,13 @@ var GrpcServer = /** @class */ (function () {
|
|
|
194
116
|
this.started = true;
|
|
195
117
|
this.startedOnce = true;
|
|
196
118
|
(_a = this.grpcServer) === null || _a === void 0 ? void 0 : _a.start();
|
|
197
|
-
}
|
|
198
|
-
|
|
119
|
+
}
|
|
120
|
+
postponeRestart() {
|
|
199
121
|
if (!this.scheduledRestart || this._postponeRequests > 5)
|
|
200
122
|
return;
|
|
201
123
|
this._postponeRequests++;
|
|
202
124
|
this.scheduleRefresh();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
}());
|
|
125
|
+
}
|
|
126
|
+
}
|
|
206
127
|
exports.GrpcServer = GrpcServer;
|
|
207
128
|
//# sourceMappingURL=GrpcServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrpcServer.js","sourceRoot":"","sources":["../../src/classes/GrpcServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GrpcServer.js","sourceRoot":"","sources":["../../src/classes/GrpcServer.ts"],"names":[],"mappings":";;;;;;AAAA,wCAAiF;AAEjF,mCAA+B;AAC/B,yEAAuD;AAEvD,MAAa,UAAU;IAcrB,YAAY,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G,CAAC,CAAC;QAC7B,CAAC,EAAE,IAAI,CAAC,CAAC;IACX,CAAC;IAED,KAAK;;QACH,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,kBAAc,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YAC/D,OAAO;SACR;aAAM,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE;YAC5C,kBAAc,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACjE;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,MAAA,IAAI,CAAC,UAAU,0CAAE,KAAK,EAAE,CAAC;IAC3B,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,iBAAiB,GAAG,CAAC;YAAE,OAAO;QACjE,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;CACF;AA1ID,gCA0IC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addServiceToServer = exports.createServer = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
5
|
+
const protoLoader = require('@grpc/proto-loader');
|
|
6
6
|
function createServer(port) {
|
|
7
|
-
|
|
7
|
+
const grpcServer = new grpc_js_1.Server({
|
|
8
8
|
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
9
9
|
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
10
10
|
});
|
|
11
|
-
return new Promise(
|
|
12
|
-
grpcServer.bindAsync(port, grpc_js_1.ServerCredentials.createInsecure(),
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
grpcServer.bindAsync(port, grpc_js_1.ServerCredentials.createInsecure(), (err, port) => {
|
|
13
13
|
if (err) {
|
|
14
14
|
reject(err);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
resolve({
|
|
18
18
|
server: grpcServer,
|
|
19
|
-
port
|
|
19
|
+
port,
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -24,17 +24,17 @@ function createServer(port) {
|
|
|
24
24
|
}
|
|
25
25
|
exports.createServer = createServer;
|
|
26
26
|
function addServiceToServer(server, protoPath, descriptorObject, functions) {
|
|
27
|
-
|
|
27
|
+
const packageDefinition = protoLoader.loadSync(protoPath, {
|
|
28
28
|
keepCase: true,
|
|
29
29
|
longs: String,
|
|
30
30
|
enums: String,
|
|
31
31
|
defaults: true,
|
|
32
32
|
oneofs: true,
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
objs.forEach(
|
|
34
|
+
const protoDescriptor = (0, grpc_js_1.loadPackageDefinition)(packageDefinition);
|
|
35
|
+
const objs = descriptorObject.split('.');
|
|
36
|
+
let descObj = protoDescriptor;
|
|
37
|
+
objs.forEach((r) => {
|
|
38
38
|
descObj = descObj[r];
|
|
39
39
|
});
|
|
40
40
|
server.addService(descObj.service, functions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GrpcHelper.js","sourceRoot":"","sources":["../../src/helpers/GrpcHelper.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"GrpcHelper.js","sourceRoot":"","sources":["../../src/helpers/GrpcHelper.ts"],"names":[],"mappings":";;;AAAA,2CAKuB;AAEvB,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,SAAgB,YAAY,CAAC,IAAY;IACvC,MAAM,UAAU,GAAW,IAAI,gBAAM,CAAC;QACpC,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;QACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;KAClD,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,2BAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YAC3E,IAAI,GAAG,EAAE;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,UAAU;oBAClB,IAAI;iBACL,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAjBD,oCAiBC;AAED,SAAgB,kBAAkB,CAChC,MAAc,EACd,SAAiB,EACjB,gBAAwB,EACxB,SAAuC;IAEvC,MAAM,iBAAiB,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE;QACxD,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,IAAA,+BAAqB,EAAC,iBAAiB,CAAC,CAAC;IACjE,MAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,OAAO,GAAQ,eAAe,CAAC;IACnC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;QACzB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAQ,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,SAAyC,CAAC,CAAC;AAChF,CAAC;AArBD,gDAqBC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Context, Cookies, Params, ParsedRouterRequest } from '@conduitplatform/grpc-sdk';
|
|
2
|
+
export declare function createParsedRouterRequest(params: Params, urlParams?: Params, queryParams?: Params, bodyParams?: Params, path?: string, headers?: Headers, context?: Context, cookies?: Cookies): ParsedRouterRequest;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createParsedRouterRequest = void 0;
|
|
4
|
+
function createParsedRouterRequest(params, urlParams, queryParams, bodyParams, path, headers, context, cookies) {
|
|
5
|
+
return {
|
|
6
|
+
request: {
|
|
7
|
+
params,
|
|
8
|
+
urlParams: urlParams !== null && urlParams !== void 0 ? urlParams : {},
|
|
9
|
+
queryParams: queryParams !== null && queryParams !== void 0 ? queryParams : {},
|
|
10
|
+
bodyParams: bodyParams !== null && bodyParams !== void 0 ? bodyParams : {},
|
|
11
|
+
path: path !== null && path !== void 0 ? path : '',
|
|
12
|
+
headers: headers,
|
|
13
|
+
context: context !== null && context !== void 0 ? context : {},
|
|
14
|
+
cookies: cookies !== null && cookies !== void 0 ? cookies : {},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.createParsedRouterRequest = createParsedRouterRequest;
|
|
19
|
+
//# sourceMappingURL=GrpcToParsedRouterRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrpcToParsedRouterRequest.js","sourceRoot":"","sources":["../../src/helpers/GrpcToParsedRouterRequest.ts"],"names":[],"mappings":";;;AAEA,SAAgB,yBAAyB,CACvC,MAAc,EACd,SAAkB,EAClB,WAAoB,EACpB,UAAmB,EACnB,IAAa,EACb,OAAiB,EACjB,OAAiB,EACjB,OAAiB;IAEjB,OAA4B;QAC1B,OAAO,EAAE;YACP,MAAM;YACN,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE;YAC1B,WAAW,EAAE,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE;YAC9B,UAAU,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE;YAC5B,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE;YAChB,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;YACtB,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;SACvB;KACF,CAAC;AACJ,CAAC;AAtBD,8DAsBC"}
|
|
@@ -1,44 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TYPE } from '@conduitplatform/grpc-sdk';
|
|
2
2
|
declare class ConduitStringConstructor {
|
|
3
3
|
private constructor();
|
|
4
|
-
static get Optional(): TYPE;
|
|
5
|
-
static get Required():
|
|
4
|
+
static get Optional(): TYPE.String;
|
|
5
|
+
static get Required(): {
|
|
6
|
+
type: TYPE.String;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
6
9
|
}
|
|
7
10
|
export declare const ConduitString: typeof ConduitStringConstructor;
|
|
8
11
|
declare class ConduitNumberConstructor {
|
|
9
12
|
private constructor();
|
|
10
|
-
static get Optional(): TYPE;
|
|
11
|
-
static get Required():
|
|
13
|
+
static get Optional(): TYPE.Number;
|
|
14
|
+
static get Required(): {
|
|
15
|
+
type: TYPE.Number;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
12
18
|
}
|
|
13
19
|
export declare const ConduitNumber: typeof ConduitNumberConstructor;
|
|
14
20
|
declare class ConduitBooleanConstructor {
|
|
15
21
|
private constructor();
|
|
16
|
-
static get Optional(): TYPE;
|
|
17
|
-
static get Required():
|
|
22
|
+
static get Optional(): TYPE.Boolean;
|
|
23
|
+
static get Required(): {
|
|
24
|
+
type: TYPE.Boolean;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
18
27
|
}
|
|
19
28
|
export declare const ConduitBoolean: typeof ConduitBooleanConstructor;
|
|
20
29
|
declare class ConduitDateConstructor {
|
|
21
30
|
private constructor();
|
|
22
|
-
static get Optional(): TYPE;
|
|
23
|
-
static get Required():
|
|
31
|
+
static get Optional(): TYPE.Date;
|
|
32
|
+
static get Required(): {
|
|
33
|
+
type: TYPE.Date;
|
|
34
|
+
required: true;
|
|
35
|
+
};
|
|
24
36
|
}
|
|
25
37
|
export declare const ConduitDate: typeof ConduitDateConstructor;
|
|
26
38
|
declare class ConduitObjectIdConstructor {
|
|
27
39
|
private constructor();
|
|
28
|
-
static get Optional(): TYPE;
|
|
29
|
-
static get Required():
|
|
40
|
+
static get Optional(): TYPE.ObjectId;
|
|
41
|
+
static get Required(): {
|
|
42
|
+
type: TYPE.ObjectId;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
30
45
|
}
|
|
31
46
|
export declare const ConduitObjectId: typeof ConduitObjectIdConstructor;
|
|
32
47
|
declare class ConduitJSONConstructor {
|
|
33
48
|
private constructor();
|
|
34
|
-
static get Optional(): TYPE;
|
|
35
|
-
static get Required():
|
|
49
|
+
static get Optional(): TYPE.JSON;
|
|
50
|
+
static get Required(): {
|
|
51
|
+
type: TYPE.JSON;
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
36
54
|
}
|
|
37
55
|
export declare const ConduitJson: typeof ConduitJSONConstructor;
|
|
38
56
|
declare class ConduitRelationConstructor {
|
|
39
57
|
private constructor();
|
|
40
|
-
static Optional(model: string):
|
|
41
|
-
|
|
58
|
+
static Optional(model: string): {
|
|
59
|
+
type: TYPE.Relation;
|
|
60
|
+
model: string;
|
|
61
|
+
required: false;
|
|
62
|
+
};
|
|
63
|
+
static Required(model: string): {
|
|
64
|
+
type: TYPE.Relation;
|
|
65
|
+
model: string;
|
|
66
|
+
required: true;
|
|
67
|
+
};
|
|
42
68
|
}
|
|
43
69
|
export declare const ConduitRelation: typeof ConduitRelationConstructor;
|
|
44
70
|
export {};
|