@conduitplatform/module-tools 0.16.0-alpha.7
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/README.mdx +18 -0
- package/dist/ManagedModule.d.ts +79 -0
- package/dist/ManagedModule.js +433 -0
- package/dist/ManagedModule.js.map +1 -0
- package/dist/classes/ConduitActiveSchema.d.ts +16 -0
- package/dist/classes/ConduitActiveSchema.js +57 -0
- package/dist/classes/ConduitActiveSchema.js.map +1 -0
- package/dist/classes/ConduitServiceModule.d.ts +26 -0
- package/dist/classes/ConduitServiceModule.js +184 -0
- package/dist/classes/ConduitServiceModule.js.map +1 -0
- package/dist/classes/ConfigController.d.ts +7 -0
- package/dist/classes/ConfigController.js +27 -0
- package/dist/classes/ConfigController.js.map +1 -0
- package/dist/classes/GrpcServer.d.ts +22 -0
- package/dist/classes/GrpcServer.js +207 -0
- package/dist/classes/GrpcServer.js.map +1 -0
- package/dist/classes/index.d.ts +4 -0
- package/dist/classes/index.js +21 -0
- package/dist/classes/index.js.map +1 -0
- package/dist/grpc_health_check.proto +21 -0
- package/dist/helpers/GrpcHelper.d.ts +8 -0
- package/dist/helpers/GrpcHelper.js +43 -0
- package/dist/helpers/GrpcHelper.js.map +1 -0
- package/dist/helpers/TypeHelpers.d.ts +44 -0
- package/dist/helpers/TypeHelpers.js +144 -0
- package/dist/helpers/TypeHelpers.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +20 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/wrapGrpcFunctions.d.ts +5 -0
- package/dist/helpers/wrapGrpcFunctions.js +56 -0
- package/dist/helpers/wrapGrpcFunctions.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/ConduitService.d.ts +8 -0
- package/dist/interfaces/ConduitService.js +3 -0
- package/dist/interfaces/ConduitService.js.map +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +18 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/logging/index.d.ts +16 -0
- package/dist/logging/index.js +255 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/metrics/MetricsServer.d.ts +9 -0
- package/dist/metrics/MetricsServer.js +94 -0
- package/dist/metrics/MetricsServer.js.map +1 -0
- package/dist/metrics/clientMiddleware.d.ts +2 -0
- package/dist/metrics/clientMiddleware.js +265 -0
- package/dist/metrics/clientMiddleware.js.map +1 -0
- package/dist/metrics/config/defaults.d.ts +91 -0
- package/dist/metrics/config/defaults.js +93 -0
- package/dist/metrics/config/defaults.js.map +1 -0
- package/dist/metrics/index.d.ts +22 -0
- package/dist/metrics/index.js +152 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/module.proto +14 -0
- package/dist/routing/ProxyRouteBuilder.d.ts +21 -0
- package/dist/routing/ProxyRouteBuilder.js +81 -0
- package/dist/routing/ProxyRouteBuilder.js.map +1 -0
- package/dist/routing/RouteBuilder.d.ts +23 -0
- package/dist/routing/RouteBuilder.js +107 -0
- package/dist/routing/RouteBuilder.js.map +1 -0
- package/dist/routing/RoutingManager.d.ts +32 -0
- package/dist/routing/RoutingManager.js +198 -0
- package/dist/routing/RoutingManager.js.map +1 -0
- package/dist/routing/RoutingUtilities.d.ts +7 -0
- package/dist/routing/RoutingUtilities.js +13 -0
- package/dist/routing/RoutingUtilities.js.map +1 -0
- package/dist/routing/index.d.ts +5 -0
- package/dist/routing/index.js +22 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/wrapRouterFunctions.d.ts +7 -0
- package/dist/routing/wrapRouterFunctions.js +136 -0
- package/dist/routing/wrapRouterFunctions.js.map +1 -0
- package/dist/utilities/convictConfigParser.d.ts +2 -0
- package/dist/utilities/convictConfigParser.js +18 -0
- package/dist/utilities/convictConfigParser.js.map +1 -0
- package/dist/utilities/index.d.ts +3 -0
- package/dist/utilities/index.js +20 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/initializeSdk.d.ts +2 -0
- package/dist/utilities/initializeSdk.js +64 -0
- package/dist/utilities/initializeSdk.js.map +1 -0
- package/dist/utilities/linearBackoffTimeout.d.ts +9 -0
- package/dist/utilities/linearBackoffTimeout.js +119 -0
- package/dist/utilities/linearBackoffTimeout.js.map +1 -0
- package/dist/utilities/merge.d.ts +1 -0
- package/dist/utilities/merge.js +15 -0
- package/dist/utilities/merge.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,184 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (_) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.ConduitServiceModule = void 0;
|
|
66
|
+
var path_1 = __importDefault(require("path"));
|
|
67
|
+
var events_1 = require("events");
|
|
68
|
+
var lodash_1 = require("lodash");
|
|
69
|
+
var grpc_sdk_1 = __importStar(require("@conduitplatform/grpc-sdk"));
|
|
70
|
+
var ConduitServiceModule = /** @class */ (function () {
|
|
71
|
+
function ConduitServiceModule(moduleName) {
|
|
72
|
+
this.events = new events_1.EventEmitter();
|
|
73
|
+
this._serviceHealthState = grpc_sdk_1.HealthCheckStatus.SERVING; // default for health-agnostic modules
|
|
74
|
+
this._moduleName = (0, lodash_1.camelCase)(moduleName);
|
|
75
|
+
}
|
|
76
|
+
Object.defineProperty(ConduitServiceModule.prototype, "port", {
|
|
77
|
+
get: function () {
|
|
78
|
+
return this._port;
|
|
79
|
+
},
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(ConduitServiceModule.prototype, "grpcSdk", {
|
|
84
|
+
get: function () {
|
|
85
|
+
if (!this._grpcSdk)
|
|
86
|
+
throw new Error('grpcSdk not defined yet');
|
|
87
|
+
return this._grpcSdk;
|
|
88
|
+
},
|
|
89
|
+
set: function (grpcSdk) {
|
|
90
|
+
if (this._grpcSdk)
|
|
91
|
+
throw new Error('grpcSdk already defined');
|
|
92
|
+
this._grpcSdk = grpcSdk;
|
|
93
|
+
},
|
|
94
|
+
enumerable: false,
|
|
95
|
+
configurable: true
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(ConduitServiceModule.prototype, "healthState", {
|
|
98
|
+
get: function () {
|
|
99
|
+
return this._serviceHealthState;
|
|
100
|
+
},
|
|
101
|
+
enumerable: false,
|
|
102
|
+
configurable: true
|
|
103
|
+
});
|
|
104
|
+
ConduitServiceModule.prototype.updateHealth = function (state, init) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
if (init === void 0) { init = false; }
|
|
107
|
+
if ((state === grpc_sdk_1.HealthCheckStatus.UNKNOWN && !init) ||
|
|
108
|
+
state === grpc_sdk_1.HealthCheckStatus.SERVICE_UNKNOWN) {
|
|
109
|
+
throw new Error("Cannot explicitly set gRPC health state to ".concat(grpc_sdk_1.HealthCheckStatus[state]));
|
|
110
|
+
}
|
|
111
|
+
if (!init) {
|
|
112
|
+
(_a = grpc_sdk_1.default.Metrics) === null || _a === void 0 ? void 0 : _a.set('module_health_state', state === grpc_sdk_1.HealthCheckStatus.SERVING ? 1 : 0);
|
|
113
|
+
}
|
|
114
|
+
if (init) {
|
|
115
|
+
this._serviceHealthState = state;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (this._serviceHealthState !== state) {
|
|
119
|
+
this._serviceHealthState = state;
|
|
120
|
+
this.events.emit("grpc-health-change:".concat(this._serviceName), state);
|
|
121
|
+
(_b = this._grpcSdk) === null || _b === void 0 ? void 0 : _b.config.moduleHealthProbe(this._moduleName, this._address);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
ConduitServiceModule.prototype.healthCheck = function (call, callback) {
|
|
125
|
+
var service = call.request.service.substring(call.request.service.indexOf('.') + 1);
|
|
126
|
+
if (service && service !== this._serviceName) {
|
|
127
|
+
callback(null, {
|
|
128
|
+
status: grpc_sdk_1.HealthCheckStatus.SERVICE_UNKNOWN,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
callback(null, {
|
|
133
|
+
status: this._serviceHealthState,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
ConduitServiceModule.prototype.healthWatch = function (call) {
|
|
138
|
+
var service = call.request.service.substring(call.request.service.indexOf('.') + 1);
|
|
139
|
+
if (service && service !== this._serviceName) {
|
|
140
|
+
call.write({
|
|
141
|
+
status: grpc_sdk_1.HealthCheckStatus.SERVICE_UNKNOWN,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.events.on("grpc-health-change:".concat(this._serviceName), function (status) {
|
|
146
|
+
call.write({
|
|
147
|
+
status: status,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
ConduitServiceModule.prototype.addHealthCheckService = function () {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
switch (_a.label) {
|
|
156
|
+
case 0: return [4 /*yield*/, this.grpcServer.addService(path_1.default.resolve(__dirname, '../grpc_health_check.proto'), 'grpc.health.v1.Health', {
|
|
157
|
+
Check: this.healthCheck.bind(this),
|
|
158
|
+
Watch: this.healthWatch.bind(this),
|
|
159
|
+
})];
|
|
160
|
+
case 1:
|
|
161
|
+
_a.sent();
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
ConduitServiceModule.prototype.addModuleService = function () {
|
|
168
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0: return [4 /*yield*/, this.grpcServer.addService(path_1.default.resolve(__dirname, '../module.proto'), 'conduit.module.v1.ConduitModule', {
|
|
172
|
+
SetConfig: this.setConfig.bind(this),
|
|
173
|
+
})];
|
|
174
|
+
case 1:
|
|
175
|
+
_a.sent();
|
|
176
|
+
return [2 /*return*/];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
return ConduitServiceModule;
|
|
182
|
+
}());
|
|
183
|
+
exports.ConduitServiceModule = ConduitServiceModule;
|
|
184
|
+
//# sourceMappingURL=ConduitServiceModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitServiceModule.js","sourceRoot":"","sources":["../../src/classes/ConduitServiceModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,iCAAsC;AACtC,iCAAmC;AAGnC,oEAUmC;AAEnC;IAQE,8BAAsB,UAAkB;QAHrB,WAAM,GAAiB,IAAI,qBAAY,EAAE,CAAC;QACrD,wBAAmB,GAAsB,4BAAiB,CAAC,OAAO,CAAC,CAAC,sCAAsC;QAGhH,IAAI,CAAC,WAAW,GAAG,IAAA,kBAAS,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAID,sBAAI,sCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAID,sBAAW,yCAAO;aAAlB;YACE,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;aAED,UAAmB,OAAuB;YACxC,IAAI,IAAI,CAAC,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC1B,CAAC;;;OALA;IAOD,sBAAI,6CAAW;aAAf;YACE,OAAO,IAAI,CAAC,mBAAmB,CAAC;QAClC,CAAC;;;OAA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AA;;wBAND,SAMC,CAAC;;;;;KACH;IACH,2BAAC;AAAD,CAAC,AAxHD,IAwHC;AAxHqB,oDAAoB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigController = void 0;
|
|
4
|
+
var ConfigController = /** @class */ (function () {
|
|
5
|
+
function ConfigController() {
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(ConfigController.prototype, "config", {
|
|
8
|
+
get: function () {
|
|
9
|
+
// return copy of config and not the original object;
|
|
10
|
+
return Object.assign({}, this._config);
|
|
11
|
+
},
|
|
12
|
+
set: function (config) {
|
|
13
|
+
this._config = config;
|
|
14
|
+
},
|
|
15
|
+
enumerable: false,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
ConfigController.getInstance = function () {
|
|
19
|
+
if (!ConfigController.instance) {
|
|
20
|
+
ConfigController.instance = new ConfigController();
|
|
21
|
+
}
|
|
22
|
+
return ConfigController.instance;
|
|
23
|
+
};
|
|
24
|
+
return ConfigController;
|
|
25
|
+
}());
|
|
26
|
+
exports.ConfigController = ConfigController;
|
|
27
|
+
//# sourceMappingURL=ConfigController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigController.js","sourceRoot":"","sources":["../../src/classes/ConfigController.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAoBA,CAAC;IAfC,sBAAI,oCAAM;aAAV;YACE,qDAAqD;YACrD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,CAAC;aAED,UAAW,MAAW;YACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC;;;OAJA;IAMM,4BAAW,GAAlB;QACE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE;YAC9B,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;SACpD;QACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;IACH,uBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,4CAAgB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class GrpcServer {
|
|
2
|
+
private grpcServer?;
|
|
3
|
+
private started;
|
|
4
|
+
private startedOnce;
|
|
5
|
+
private _serviceNames;
|
|
6
|
+
private scheduledRestart;
|
|
7
|
+
private _postponeRequests;
|
|
8
|
+
private _useForce?;
|
|
9
|
+
private _services;
|
|
10
|
+
constructor(port?: string);
|
|
11
|
+
private _url;
|
|
12
|
+
get url(): string;
|
|
13
|
+
createNewServer(useForce?: boolean): Promise<number>;
|
|
14
|
+
addService(protoPath: string, protoDescription: string, functions: {
|
|
15
|
+
[name: string]: Function;
|
|
16
|
+
}): Promise<GrpcServer>;
|
|
17
|
+
wait(time: number): Promise<void>;
|
|
18
|
+
refresh(): Promise<void>;
|
|
19
|
+
scheduleRefresh(): void;
|
|
20
|
+
start(): void;
|
|
21
|
+
private postponeRestart;
|
|
22
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.GrpcServer = void 0;
|
|
43
|
+
var helpers_1 = require("../helpers");
|
|
44
|
+
var lodash_1 = require("lodash");
|
|
45
|
+
var grpc_sdk_1 = __importDefault(require("@conduitplatform/grpc-sdk"));
|
|
46
|
+
var GrpcServer = /** @class */ (function () {
|
|
47
|
+
function GrpcServer(port) {
|
|
48
|
+
this.started = false;
|
|
49
|
+
this.startedOnce = false;
|
|
50
|
+
this._serviceNames = [];
|
|
51
|
+
this._postponeRequests = 0;
|
|
52
|
+
this._services = [];
|
|
53
|
+
this._url = "0.0.0.0:".concat(port !== null && port !== void 0 ? port : '5000');
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(GrpcServer.prototype, "url", {
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._url;
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
GrpcServer.prototype.createNewServer = function (useForce) {
|
|
63
|
+
if (useForce === void 0) { useForce = false; }
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var serverResult;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
if ((0, lodash_1.isNil)(this._useForce)) {
|
|
70
|
+
this._useForce = useForce;
|
|
71
|
+
}
|
|
72
|
+
return [4 /*yield*/, (0, helpers_1.createServer)(this._url)];
|
|
73
|
+
case 1:
|
|
74
|
+
serverResult = _a.sent();
|
|
75
|
+
this.grpcServer = serverResult.server;
|
|
76
|
+
this._url = this._url.split(':')[0] + ':' + serverResult.port.toString();
|
|
77
|
+
return [2 /*return*/, serverResult.port];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
GrpcServer.prototype.addService = function (protoPath, protoDescription, functions) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
functions = (0, helpers_1.wrapGrpcFunctions)(functions, this.postponeRestart.bind(this));
|
|
88
|
+
if (!(this._serviceNames.indexOf(protoDescription) !== -1)) return [3 /*break*/, 1];
|
|
89
|
+
grpc_sdk_1.default.Logger.log('Service already exists, performing replace');
|
|
90
|
+
this._services[this._serviceNames.indexOf(protoDescription)] = {
|
|
91
|
+
protoPath: protoPath,
|
|
92
|
+
protoDescription: protoDescription,
|
|
93
|
+
functions: functions,
|
|
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];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
GrpcServer.prototype.wait = function (time) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
121
|
+
var timeout = setTimeout(function () {
|
|
122
|
+
clearTimeout(timeout);
|
|
123
|
+
resolve();
|
|
124
|
+
}, time);
|
|
125
|
+
})];
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
GrpcServer.prototype.refresh = function () {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
+
var _this = this;
|
|
132
|
+
return __generator(this, function (_a) {
|
|
133
|
+
switch (_a.label) {
|
|
134
|
+
case 0:
|
|
135
|
+
if (!this.started) return [3 /*break*/, 3];
|
|
136
|
+
this.started = false;
|
|
137
|
+
if (!this._useForce) return [3 /*break*/, 1];
|
|
138
|
+
this.grpcServer.forceShutdown();
|
|
139
|
+
return [3 /*break*/, 3];
|
|
140
|
+
case 1:
|
|
141
|
+
//gracefully shutdown so that there are no service disruption
|
|
142
|
+
return [4 /*yield*/, new Promise(function (resolve) { return _this.grpcServer.tryShutdown(function () { return resolve(); }); })];
|
|
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
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
GrpcServer.prototype.scheduleRefresh = function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
if (this.scheduledRestart) {
|
|
165
|
+
clearTimeout(this.scheduledRestart);
|
|
166
|
+
}
|
|
167
|
+
var self = this;
|
|
168
|
+
this.scheduledRestart = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
grpc_sdk_1.default.Logger.log('Begin refresh');
|
|
173
|
+
return [4 /*yield*/, self.refresh()];
|
|
174
|
+
case 1:
|
|
175
|
+
_a.sent();
|
|
176
|
+
grpc_sdk_1.default.Logger.log('Refresh complete');
|
|
177
|
+
clearTimeout(self.scheduledRestart);
|
|
178
|
+
self.scheduledRestart = undefined;
|
|
179
|
+
self._postponeRequests = 0;
|
|
180
|
+
return [2 /*return*/];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}); }, 2000);
|
|
184
|
+
};
|
|
185
|
+
GrpcServer.prototype.start = function () {
|
|
186
|
+
var _a;
|
|
187
|
+
if (this.started) {
|
|
188
|
+
grpc_sdk_1.default.Logger.error('gRPC server is already running!');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
else if (!this.started && this.startedOnce) {
|
|
192
|
+
grpc_sdk_1.default.Logger.error('gRPC server is down for refresh!');
|
|
193
|
+
}
|
|
194
|
+
this.started = true;
|
|
195
|
+
this.startedOnce = true;
|
|
196
|
+
(_a = this.grpcServer) === null || _a === void 0 ? void 0 : _a.start();
|
|
197
|
+
};
|
|
198
|
+
GrpcServer.prototype.postponeRestart = function () {
|
|
199
|
+
if (!this.scheduledRestart || this._postponeRequests > 5)
|
|
200
|
+
return;
|
|
201
|
+
this._postponeRequests++;
|
|
202
|
+
this.scheduleRefresh();
|
|
203
|
+
};
|
|
204
|
+
return GrpcServer;
|
|
205
|
+
}());
|
|
206
|
+
exports.GrpcServer = GrpcServer;
|
|
207
|
+
//# sourceMappingURL=GrpcServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrpcServer.js","sourceRoot":"","sources":["../../src/classes/GrpcServer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAiF;AAEjF,iCAA+B;AAC/B,uEAAuD;AAEvD;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C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;wBAClC,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;;;;aAC5B,EAAE,IAAI,CAAC,CAAC;IACX,CAAC;IAED,0BAAK,GAAL;;QACE,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,oCAAe,GAAvB;QACE,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;IACH,iBAAC;AAAD,CAAC,AApID,IAoIC;AApIY,gCAAU"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ConduitActiveSchema"), exports);
|
|
18
|
+
__exportStar(require("./GrpcServer"), exports);
|
|
19
|
+
__exportStar(require("./ConduitServiceModule"), exports);
|
|
20
|
+
__exportStar(require("./ConfigController"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,+CAA6B;AAC7B,yDAAuC;AACvC,qDAAmC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package grpc.health.v1;
|
|
3
|
+
|
|
4
|
+
message HealthCheckRequest {
|
|
5
|
+
string service = 1;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
message HealthCheckResponse {
|
|
9
|
+
enum ServingStatus {
|
|
10
|
+
UNKNOWN = 0;
|
|
11
|
+
SERVING = 1;
|
|
12
|
+
NOT_SERVING = 2;
|
|
13
|
+
SERVICE_UNKNOWN = 3;
|
|
14
|
+
}
|
|
15
|
+
ServingStatus status = 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
service Health {
|
|
19
|
+
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
|
|
20
|
+
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Server } from '@grpc/grpc-js';
|
|
2
|
+
export declare function createServer(port: string): Promise<{
|
|
3
|
+
server: Server;
|
|
4
|
+
port: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function addServiceToServer(server: Server, protoPath: string, descriptorObject: string, functions: {
|
|
7
|
+
[name: string]: Function;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addServiceToServer = exports.createServer = void 0;
|
|
4
|
+
var grpc_js_1 = require("@grpc/grpc-js");
|
|
5
|
+
var protoLoader = require('@grpc/proto-loader');
|
|
6
|
+
function createServer(port) {
|
|
7
|
+
var grpcServer = new grpc_js_1.Server({
|
|
8
|
+
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
9
|
+
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
10
|
+
});
|
|
11
|
+
return new Promise(function (resolve, reject) {
|
|
12
|
+
grpcServer.bindAsync(port, grpc_js_1.ServerCredentials.createInsecure(), function (err, port) {
|
|
13
|
+
if (err) {
|
|
14
|
+
reject(err);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolve({
|
|
18
|
+
server: grpcServer,
|
|
19
|
+
port: port,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.createServer = createServer;
|
|
26
|
+
function addServiceToServer(server, protoPath, descriptorObject, functions) {
|
|
27
|
+
var packageDefinition = protoLoader.loadSync(protoPath, {
|
|
28
|
+
keepCase: true,
|
|
29
|
+
longs: String,
|
|
30
|
+
enums: String,
|
|
31
|
+
defaults: true,
|
|
32
|
+
oneofs: true,
|
|
33
|
+
});
|
|
34
|
+
var protoDescriptor = (0, grpc_js_1.loadPackageDefinition)(packageDefinition);
|
|
35
|
+
var objs = descriptorObject.split('.');
|
|
36
|
+
var descObj = protoDescriptor;
|
|
37
|
+
objs.forEach(function (r) {
|
|
38
|
+
descObj = descObj[r];
|
|
39
|
+
});
|
|
40
|
+
server.addService(descObj.service, functions);
|
|
41
|
+
}
|
|
42
|
+
exports.addServiceToServer = addServiceToServer;
|
|
43
|
+
//# sourceMappingURL=GrpcHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GrpcHelper.js","sourceRoot":"","sources":["../../src/helpers/GrpcHelper.ts"],"names":[],"mappings":";;;AAAA,yCAKuB;AAEvB,IAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElD,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAM,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,UAAC,OAAO,EAAE,MAAM;QACjC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,2BAAiB,CAAC,cAAc,EAAE,EAAE,UAAC,GAAG,EAAE,IAAI;YACvE,IAAI,GAAG,EAAE;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;iBAAM;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,UAAU;oBAClB,IAAI,MAAA;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,IAAM,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,IAAM,eAAe,GAAG,IAAA,+BAAqB,EAAC,iBAAiB,CAAC,CAAC;IACjE,IAAM,IAAI,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,OAAO,GAAQ,eAAe,CAAC;IACnC,IAAI,CAAC,OAAO,CAAC,UAAC,CAAS;QACrB,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,44 @@
|
|
|
1
|
+
import { ConduitModelField, TYPE } from '@conduitplatform/grpc-sdk';
|
|
2
|
+
declare class ConduitStringConstructor {
|
|
3
|
+
private constructor();
|
|
4
|
+
static get Optional(): TYPE;
|
|
5
|
+
static get Required(): ConduitModelField;
|
|
6
|
+
}
|
|
7
|
+
export declare const ConduitString: typeof ConduitStringConstructor;
|
|
8
|
+
declare class ConduitNumberConstructor {
|
|
9
|
+
private constructor();
|
|
10
|
+
static get Optional(): TYPE;
|
|
11
|
+
static get Required(): ConduitModelField;
|
|
12
|
+
}
|
|
13
|
+
export declare const ConduitNumber: typeof ConduitNumberConstructor;
|
|
14
|
+
declare class ConduitBooleanConstructor {
|
|
15
|
+
private constructor();
|
|
16
|
+
static get Optional(): TYPE;
|
|
17
|
+
static get Required(): ConduitModelField;
|
|
18
|
+
}
|
|
19
|
+
export declare const ConduitBoolean: typeof ConduitBooleanConstructor;
|
|
20
|
+
declare class ConduitDateConstructor {
|
|
21
|
+
private constructor();
|
|
22
|
+
static get Optional(): TYPE;
|
|
23
|
+
static get Required(): ConduitModelField;
|
|
24
|
+
}
|
|
25
|
+
export declare const ConduitDate: typeof ConduitDateConstructor;
|
|
26
|
+
declare class ConduitObjectIdConstructor {
|
|
27
|
+
private constructor();
|
|
28
|
+
static get Optional(): TYPE;
|
|
29
|
+
static get Required(): ConduitModelField;
|
|
30
|
+
}
|
|
31
|
+
export declare const ConduitObjectId: typeof ConduitObjectIdConstructor;
|
|
32
|
+
declare class ConduitJSONConstructor {
|
|
33
|
+
private constructor();
|
|
34
|
+
static get Optional(): TYPE;
|
|
35
|
+
static get Required(): ConduitModelField;
|
|
36
|
+
}
|
|
37
|
+
export declare const ConduitJson: typeof ConduitJSONConstructor;
|
|
38
|
+
declare class ConduitRelationConstructor {
|
|
39
|
+
private constructor();
|
|
40
|
+
static Optional(model: string): ConduitModelField;
|
|
41
|
+
static Required(model: string): ConduitModelField;
|
|
42
|
+
}
|
|
43
|
+
export declare const ConduitRelation: typeof ConduitRelationConstructor;
|
|
44
|
+
export {};
|