@conduitplatform/grpc-sdk 0.13.0-rc.1
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.md +20 -0
- package/dist/classes/ConduitActiveSchema.d.ts +19 -0
- package/dist/classes/ConduitActiveSchema.js +57 -0
- package/dist/classes/ConduitActiveSchema.js.map +1 -0
- package/dist/classes/ConduitMiddleware.d.ts +8 -0
- package/dist/classes/ConduitMiddleware.js +26 -0
- package/dist/classes/ConduitMiddleware.js.map +1 -0
- package/dist/classes/ConduitModule.d.ts +26 -0
- package/dist/classes/ConduitModule.js +170 -0
- package/dist/classes/ConduitModule.js.map +1 -0
- package/dist/classes/ConduitParser.d.ts +20 -0
- package/dist/classes/ConduitParser.js +84 -0
- package/dist/classes/ConduitParser.js.map +1 -0
- package/dist/classes/ConduitRoute.d.ts +12 -0
- package/dist/classes/ConduitRoute.js +44 -0
- package/dist/classes/ConduitRoute.js.map +1 -0
- package/dist/classes/ConduitRouteReturn.d.ts +48 -0
- package/dist/classes/ConduitRouteReturn.js +66 -0
- package/dist/classes/ConduitRouteReturn.js.map +1 -0
- package/dist/classes/ConduitSchema.d.ts +10 -0
- package/dist/classes/ConduitSchema.js +22 -0
- package/dist/classes/ConduitSchema.js.map +1 -0
- package/dist/classes/ConduitSchemaExtension.d.ts +7 -0
- package/dist/classes/ConduitSchemaExtension.js +19 -0
- package/dist/classes/ConduitSchemaExtension.js.map +1 -0
- package/dist/classes/ConduitServiceModule.d.ts +25 -0
- package/dist/classes/ConduitServiceModule.js +139 -0
- package/dist/classes/ConduitServiceModule.js.map +1 -0
- package/dist/classes/ConduitSocket.d.ts +9 -0
- package/dist/classes/ConduitSocket.js +27 -0
- package/dist/classes/ConduitSocket.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/Error.d.ts +11 -0
- package/dist/classes/Error.js +51 -0
- package/dist/classes/Error.js.map +1 -0
- package/dist/classes/GrpcServer.d.ts +19 -0
- package/dist/classes/GrpcServer.js +185 -0
- package/dist/classes/GrpcServer.js.map +1 -0
- package/dist/classes/ManagedModule.d.ts +20 -0
- package/dist/classes/ManagedModule.js +212 -0
- package/dist/classes/ManagedModule.js.map +1 -0
- package/dist/classes/ModuleManager.d.ts +11 -0
- package/dist/classes/ModuleManager.js +191 -0
- package/dist/classes/ModuleManager.js.map +1 -0
- package/dist/classes/Routing/RouteBuilder.d.ts +28 -0
- package/dist/classes/Routing/RouteBuilder.js +107 -0
- package/dist/classes/Routing/RouteBuilder.js.map +1 -0
- package/dist/classes/Routing/RoutingManager.d.ts +25 -0
- package/dist/classes/Routing/RoutingManager.js +193 -0
- package/dist/classes/Routing/RoutingManager.js.map +1 -0
- package/dist/classes/index.d.ts +16 -0
- package/dist/classes/index.js +29 -0
- package/dist/classes/index.js.map +1 -0
- package/dist/constants/enums/PlatformTypesEnum.d.ts +9 -0
- package/dist/constants/enums/PlatformTypesEnum.js +14 -0
- package/dist/constants/enums/PlatformTypesEnum.js.map +1 -0
- package/dist/constants/enums/index.d.ts +1 -0
- package/dist/constants/enums/index.js +14 -0
- package/dist/constants/enums/index.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +14 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/helpers/GrpcHelper.d.ts +8 -0
- package/dist/helpers/GrpcHelper.js +44 -0
- package/dist/helpers/GrpcHelper.js.map +1 -0
- package/dist/helpers/RoutingJsonConstructor.d.ts +9 -0
- package/dist/helpers/RoutingJsonConstructor.js +89 -0
- package/dist/helpers/RoutingJsonConstructor.js.map +1 -0
- package/dist/helpers/RoutingUtilities.d.ts +13 -0
- package/dist/helpers/RoutingUtilities.js +69 -0
- package/dist/helpers/RoutingUtilities.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 +5 -0
- package/dist/helpers/index.js +18 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/wrapGrpcFunctions.d.ts +5 -0
- package/dist/helpers/wrapGrpcFunctions.js +37 -0
- package/dist/helpers/wrapGrpcFunctions.js.map +1 -0
- package/dist/helpers/wrapRouterFunctions.d.ts +7 -0
- package/dist/helpers/wrapRouterFunctions.js +111 -0
- package/dist/helpers/wrapRouterFunctions.js.map +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +481 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/grpcSignedToken.d.ts +2 -0
- package/dist/interceptors/grpcSignedToken.js +88 -0
- package/dist/interceptors/grpcSignedToken.js.map +1 -0
- package/dist/interceptors/index.d.ts +2 -0
- package/dist/interceptors/index.js +15 -0
- package/dist/interceptors/index.js.map +1 -0
- package/dist/interceptors/moduleName.d.ts +2 -0
- package/dist/interceptors/moduleName.js +88 -0
- package/dist/interceptors/moduleName.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/GrpcCallback.d.ts +4 -0
- package/dist/interfaces/GrpcCallback.js +3 -0
- package/dist/interfaces/GrpcCallback.js.map +1 -0
- package/dist/interfaces/Indexable.d.ts +9 -0
- package/dist/interfaces/Indexable.js +3 -0
- package/dist/interfaces/Indexable.js.map +1 -0
- package/dist/interfaces/Middleware.d.ts +7 -0
- package/dist/interfaces/Middleware.js +3 -0
- package/dist/interfaces/Middleware.js.map +1 -0
- package/dist/interfaces/Model.d.ts +37 -0
- package/dist/interfaces/Model.js +19 -0
- package/dist/interfaces/Model.js.map +1 -0
- package/dist/interfaces/Route.d.ts +54 -0
- package/dist/interfaces/Route.js +21 -0
- package/dist/interfaces/Route.js.map +1 -0
- package/dist/interfaces/Socket.d.ts +34 -0
- package/dist/interfaces/Socket.js +9 -0
- package/dist/interfaces/Socket.js.map +1 -0
- package/dist/interfaces/index.d.ts +7 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/modules/admin/index.d.ts +13 -0
- package/dist/modules/admin/index.js +131 -0
- package/dist/modules/admin/index.js.map +1 -0
- package/dist/modules/authentication/index.d.ts +11 -0
- package/dist/modules/authentication/index.js +50 -0
- package/dist/modules/authentication/index.js.map +1 -0
- package/dist/modules/chat/index.d.ts +10 -0
- package/dist/modules/chat/index.js +46 -0
- package/dist/modules/chat/index.js.map +1 -0
- package/dist/modules/config/index.d.ts +25 -0
- package/dist/modules/config/index.js +234 -0
- package/dist/modules/config/index.js.map +1 -0
- package/dist/modules/core/index.d.ts +6 -0
- package/dist/modules/core/index.js +32 -0
- package/dist/modules/core/index.js.map +1 -0
- package/dist/modules/database/index.d.ts +30 -0
- package/dist/modules/database/index.js +201 -0
- package/dist/modules/database/index.js.map +1 -0
- package/dist/modules/email/index.d.ts +21 -0
- package/dist/modules/email/index.js +63 -0
- package/dist/modules/email/index.js.map +1 -0
- package/dist/modules/forms/index.d.ts +7 -0
- package/dist/modules/forms/index.js +37 -0
- package/dist/modules/forms/index.js.map +1 -0
- package/dist/modules/index.d.ts +11 -0
- package/dist/modules/index.js +24 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/pushNotifications/index.d.ts +10 -0
- package/dist/modules/pushNotifications/index.js +63 -0
- package/dist/modules/pushNotifications/index.js.map +1 -0
- package/dist/modules/router/index.d.ts +8 -0
- package/dist/modules/router/index.js +43 -0
- package/dist/modules/router/index.js.map +1 -0
- package/dist/modules/sms/index.d.ts +10 -0
- package/dist/modules/sms/index.js +46 -0
- package/dist/modules/sms/index.js.map +1 -0
- package/dist/modules/storage/index.d.ts +10 -0
- package/dist/modules/storage/index.js +47 -0
- package/dist/modules/storage/index.js.map +1 -0
- package/dist/protoUtils/authentication.d.ts +209 -0
- package/dist/protoUtils/authentication.js +533 -0
- package/dist/protoUtils/authentication.js.map +1 -0
- package/dist/protoUtils/chat.d.ts +178 -0
- package/dist/protoUtils/chat.js +534 -0
- package/dist/protoUtils/chat.js.map +1 -0
- package/dist/protoUtils/core.d.ts +607 -0
- package/dist/protoUtils/core.js +1883 -0
- package/dist/protoUtils/core.js.map +1 -0
- package/dist/protoUtils/database.d.ts +496 -0
- package/dist/protoUtils/database.js +1275 -0
- package/dist/protoUtils/database.js.map +1 -0
- package/dist/protoUtils/email.d.ts +153 -0
- package/dist/protoUtils/email.js +543 -0
- package/dist/protoUtils/email.js.map +1 -0
- package/dist/protoUtils/forms.d.ts +54 -0
- package/dist/protoUtils/forms.js +141 -0
- package/dist/protoUtils/forms.js.map +1 -0
- package/dist/protoUtils/grpc_health_check.d.ts +83 -0
- package/dist/protoUtils/grpc_health_check.js +197 -0
- package/dist/protoUtils/grpc_health_check.js.map +1 -0
- package/dist/protoUtils/push-notifications.d.ts +179 -0
- package/dist/protoUtils/push-notifications.js +512 -0
- package/dist/protoUtils/push-notifications.js.map +1 -0
- package/dist/protoUtils/sms.d.ts +176 -0
- package/dist/protoUtils/sms.js +459 -0
- package/dist/protoUtils/sms.js.map +1 -0
- package/dist/protoUtils/storage.d.ts +203 -0
- package/dist/protoUtils/storage.js +522 -0
- package/dist/protoUtils/storage.js.map +1 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/index.js +37 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utilities/EventBus.d.ts +10 -0
- package/dist/utilities/EventBus.js +52 -0
- package/dist/utilities/EventBus.js.map +1 -0
- package/dist/utilities/RedisManager.d.ts +6 -0
- package/dist/utilities/RedisManager.js +32 -0
- package/dist/utilities/RedisManager.js.map +1 -0
- package/dist/utilities/StateManager.d.ts +10 -0
- package/dist/utilities/StateManager.js +31 -0
- package/dist/utilities/StateManager.js.map +1 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +10 -0
- package/dist/utilities/index.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Conduit SDK module
|
|
2
|
+
|
|
3
|
+
This module provides a framework to bind all Conduit modules in a safe and consistent way.
|
|
4
|
+
|
|
5
|
+
It is also used to provide syntactic sugar that makes development easier.
|
|
6
|
+
|
|
7
|
+
## Build Steps
|
|
8
|
+
|
|
9
|
+
- run build.sh
|
|
10
|
+
- run npm build
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Service registration & Discovery
|
|
15
|
+
- Route registration
|
|
16
|
+
- Provides wrappers for grpc handlers to support async
|
|
17
|
+
- Parses incoming requests and outgoing responses to JSON
|
|
18
|
+
- Provides health check service out of the box
|
|
19
|
+
- Manages the grpc server so you don't have to
|
|
20
|
+
- Provides typings for common Conduit models
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConduitModel, ConduitModelOptions } from '../interfaces';
|
|
2
|
+
import { ConduitSchema } from './ConduitSchema';
|
|
3
|
+
import { DatabaseProvider } from '../modules';
|
|
4
|
+
import { Query } from '../interfaces';
|
|
5
|
+
export declare class ConduitActiveSchema<T> extends ConduitSchema {
|
|
6
|
+
private readonly dbInstance;
|
|
7
|
+
constructor(dbInstance: DatabaseProvider, name: string, fields?: ConduitModel, schemaOptions?: ConduitModelOptions, collectionName?: string);
|
|
8
|
+
findOne(query: Query, select?: string, populate?: string | string[]): Promise<T | null>;
|
|
9
|
+
findMany(query: Query, select?: string, skip?: number, limit?: number, sort?: {
|
|
10
|
+
[key: string]: number;
|
|
11
|
+
} | string[], populate?: string | string[]): Promise<T[]>;
|
|
12
|
+
create(query: Query): Promise<T>;
|
|
13
|
+
createMany(query: Query): Promise<T[]>;
|
|
14
|
+
findByIdAndUpdate(id: string, document: Query, updateProvidedOnly?: boolean, populate?: string | string[]): Promise<T | null>;
|
|
15
|
+
updateMany(filterQuery: Query, query: Query, updateProvidedOnly?: boolean): Promise<any>;
|
|
16
|
+
deleteOne(query: Query): Promise<any>;
|
|
17
|
+
deleteMany(query: Query): Promise<any>;
|
|
18
|
+
countDocuments(query: Query): Promise<number>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ConduitActiveSchema = void 0;
|
|
19
|
+
var ConduitSchema_1 = require("./ConduitSchema");
|
|
20
|
+
var ConduitActiveSchema = /** @class */ (function (_super) {
|
|
21
|
+
__extends(ConduitActiveSchema, _super);
|
|
22
|
+
function ConduitActiveSchema(dbInstance, name, fields, schemaOptions, collectionName) {
|
|
23
|
+
var _this = _super.call(this, name, fields !== null && fields !== void 0 ? fields : {}, schemaOptions, collectionName) || this;
|
|
24
|
+
_this.dbInstance = dbInstance;
|
|
25
|
+
return _this;
|
|
26
|
+
}
|
|
27
|
+
ConduitActiveSchema.prototype.findOne = function (query, select, populate) {
|
|
28
|
+
return this.dbInstance.findOne(this.name, query, select, populate);
|
|
29
|
+
};
|
|
30
|
+
ConduitActiveSchema.prototype.findMany = function (query, select, skip, limit, sort, populate) {
|
|
31
|
+
return this.dbInstance.findMany(this.name, query, select, skip, limit, sort, populate);
|
|
32
|
+
};
|
|
33
|
+
ConduitActiveSchema.prototype.create = function (query) {
|
|
34
|
+
return this.dbInstance.create(this.name, query);
|
|
35
|
+
};
|
|
36
|
+
ConduitActiveSchema.prototype.createMany = function (query) {
|
|
37
|
+
return this.dbInstance.createMany(this.name, query);
|
|
38
|
+
};
|
|
39
|
+
ConduitActiveSchema.prototype.findByIdAndUpdate = function (id, document, updateProvidedOnly, populate) {
|
|
40
|
+
return this.dbInstance.findByIdAndUpdate(this.name, id, document, updateProvidedOnly, populate);
|
|
41
|
+
};
|
|
42
|
+
ConduitActiveSchema.prototype.updateMany = function (filterQuery, query, updateProvidedOnly) {
|
|
43
|
+
return this.dbInstance.updateMany(this.name, filterQuery, query, updateProvidedOnly);
|
|
44
|
+
};
|
|
45
|
+
ConduitActiveSchema.prototype.deleteOne = function (query) {
|
|
46
|
+
return this.dbInstance.deleteOne(this.name, query);
|
|
47
|
+
};
|
|
48
|
+
ConduitActiveSchema.prototype.deleteMany = function (query) {
|
|
49
|
+
return this.dbInstance.deleteMany(this.name, query);
|
|
50
|
+
};
|
|
51
|
+
ConduitActiveSchema.prototype.countDocuments = function (query) {
|
|
52
|
+
return this.dbInstance.countDocuments(this.name, query);
|
|
53
|
+
};
|
|
54
|
+
return ConduitActiveSchema;
|
|
55
|
+
}(ConduitSchema_1.ConduitSchema));
|
|
56
|
+
exports.ConduitActiveSchema = ConduitActiveSchema;
|
|
57
|
+
//# sourceMappingURL=ConduitActiveSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitActiveSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitActiveSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,iDAAgD;AAIhD;IAA4C,uCAAa;IAGvD,6BACE,UAA4B,EAC5B,IAAY,EACZ,MAAqB,EACrB,aAAmC,EACnC,cAAuB;QALzB,YAOE,kBAAM,IAAI,EAAE,MAAM,aAAN,MAAM,cA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U,KAAY;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,wCAAU,GAAV,UAAW,KAAY;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,4CAAc,GAAd,UAAe,KAAY;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IACH,0BAAC;AAAD,CAAC,AA/ED,CAA4C,6BAAa,GA+ExD;AA/EY,kDAAmB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConduitMiddlewareOptions } from '../interfaces';
|
|
2
|
+
export declare class ConduitMiddleware {
|
|
3
|
+
private _input;
|
|
4
|
+
private _handler;
|
|
5
|
+
constructor(input: ConduitMiddlewareOptions, handler: string);
|
|
6
|
+
get input(): ConduitMiddlewareOptions;
|
|
7
|
+
get handler(): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConduitMiddleware = void 0;
|
|
4
|
+
var ConduitMiddleware = /** @class */ (function () {
|
|
5
|
+
function ConduitMiddleware(input, handler) {
|
|
6
|
+
this._input = input;
|
|
7
|
+
this._handler = handler;
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(ConduitMiddleware.prototype, "input", {
|
|
10
|
+
get: function () {
|
|
11
|
+
return this._input;
|
|
12
|
+
},
|
|
13
|
+
enumerable: false,
|
|
14
|
+
configurable: true
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(ConduitMiddleware.prototype, "handler", {
|
|
17
|
+
get: function () {
|
|
18
|
+
return this._handler;
|
|
19
|
+
},
|
|
20
|
+
enumerable: false,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
return ConduitMiddleware;
|
|
24
|
+
}());
|
|
25
|
+
exports.ConduitMiddleware = ConduitMiddleware;
|
|
26
|
+
//# sourceMappingURL=ConduitMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitMiddleware.js","sourceRoot":"","sources":["../../src/classes/ConduitMiddleware.ts"],"names":[],"mappings":";;;AAEA;IAIE,2BAAY,KAA+B,EAAE,OAAe;QAC1D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,sBAAI,oCAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,sCAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IACH,wBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,8CAAiB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { CompatServiceDefinition } from 'nice-grpc/lib/service-definitions';
|
|
3
|
+
import { Channel, Client } from 'nice-grpc';
|
|
4
|
+
import { HealthDefinition } from '../protoUtils/grpc_health_check';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
export declare class ConduitModule<T extends CompatServiceDefinition> {
|
|
7
|
+
active: boolean;
|
|
8
|
+
private _client?;
|
|
9
|
+
private _healthClient?;
|
|
10
|
+
protected channel?: Channel;
|
|
11
|
+
protected protoPath?: string;
|
|
12
|
+
protected type?: T;
|
|
13
|
+
protected readonly _clientName: string;
|
|
14
|
+
protected readonly _serviceUrl: string;
|
|
15
|
+
protected readonly healthCheckEmitter: EventEmitter;
|
|
16
|
+
protected readonly _grpcToken?: string;
|
|
17
|
+
constructor(clientName: string, serviceName: string, serviceUrl: string, grpcToken?: string);
|
|
18
|
+
initializeClient(type: T): Client<T>;
|
|
19
|
+
openConnection(): void;
|
|
20
|
+
get client(): Client<T> | undefined;
|
|
21
|
+
get healthClient(): Client<typeof HealthDefinition> | undefined;
|
|
22
|
+
get healthCheckWatcher(): EventEmitter;
|
|
23
|
+
closeConnection(): void;
|
|
24
|
+
check(service?: string): Promise<import("../protoUtils/grpc_health_check").HealthCheckResponse_ServingStatus>;
|
|
25
|
+
watch(service?: string): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
39
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
40
|
+
var m = o[Symbol.asyncIterator], i;
|
|
41
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
42
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
43
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.ConduitModule = void 0;
|
|
47
|
+
var interceptors_1 = require("../interceptors");
|
|
48
|
+
var nice_grpc_1 = require("nice-grpc");
|
|
49
|
+
var grpc_health_check_1 = require("../protoUtils/grpc_health_check");
|
|
50
|
+
var events_1 = require("events");
|
|
51
|
+
var ConduitModule = /** @class */ (function () {
|
|
52
|
+
function ConduitModule(clientName, serviceName, serviceUrl, grpcToken) {
|
|
53
|
+
this.active = false;
|
|
54
|
+
this.healthCheckEmitter = new events_1.EventEmitter();
|
|
55
|
+
this._clientName = clientName;
|
|
56
|
+
this._serviceUrl = serviceUrl;
|
|
57
|
+
this._grpcToken = grpcToken;
|
|
58
|
+
}
|
|
59
|
+
ConduitModule.prototype.initializeClient = function (type) {
|
|
60
|
+
if (this._client)
|
|
61
|
+
return this._client;
|
|
62
|
+
this.type = type;
|
|
63
|
+
this.openConnection();
|
|
64
|
+
return this._client;
|
|
65
|
+
};
|
|
66
|
+
ConduitModule.prototype.openConnection = function () {
|
|
67
|
+
this.channel = nice_grpc_1.createChannel(this._serviceUrl, undefined, {
|
|
68
|
+
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
69
|
+
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
70
|
+
});
|
|
71
|
+
var clientFactory = nice_grpc_1.createClientFactory().use(this._grpcToken
|
|
72
|
+
? interceptors_1.getGrpcSignedTokenInterceptor(this._grpcToken)
|
|
73
|
+
: interceptors_1.getModuleNameInterceptor(this._clientName));
|
|
74
|
+
this._client = clientFactory.create(this.type, this.channel);
|
|
75
|
+
this._healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, this.channel);
|
|
76
|
+
this.active = true;
|
|
77
|
+
};
|
|
78
|
+
Object.defineProperty(ConduitModule.prototype, "client", {
|
|
79
|
+
get: function () {
|
|
80
|
+
return this._client;
|
|
81
|
+
},
|
|
82
|
+
enumerable: false,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(ConduitModule.prototype, "healthClient", {
|
|
86
|
+
get: function () {
|
|
87
|
+
return this._healthClient;
|
|
88
|
+
},
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(ConduitModule.prototype, "healthCheckWatcher", {
|
|
93
|
+
get: function () {
|
|
94
|
+
return this.healthCheckEmitter;
|
|
95
|
+
},
|
|
96
|
+
enumerable: false,
|
|
97
|
+
configurable: true
|
|
98
|
+
});
|
|
99
|
+
ConduitModule.prototype.closeConnection = function () {
|
|
100
|
+
if (!this.channel)
|
|
101
|
+
return;
|
|
102
|
+
this.channel.close();
|
|
103
|
+
this.channel = undefined;
|
|
104
|
+
this.active = false;
|
|
105
|
+
};
|
|
106
|
+
ConduitModule.prototype.check = function (service) {
|
|
107
|
+
if (service === void 0) { service = ''; }
|
|
108
|
+
return this.healthClient.check({ service: service }).then(function (res) {
|
|
109
|
+
return res.status;
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
ConduitModule.prototype.watch = function (service) {
|
|
113
|
+
var e_1, _a;
|
|
114
|
+
var _b;
|
|
115
|
+
if (service === void 0) { service = ''; }
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var self, serviceName, call, call_1, call_1_1, data, e_1_1, error_1;
|
|
118
|
+
return __generator(this, function (_c) {
|
|
119
|
+
switch (_c.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
self = this;
|
|
122
|
+
serviceName = (_b = this.type) === null || _b === void 0 ? void 0 : _b.name;
|
|
123
|
+
this.healthCheckEmitter.setMaxListeners(150);
|
|
124
|
+
_c.label = 1;
|
|
125
|
+
case 1:
|
|
126
|
+
_c.trys.push([1, 14, , 15]);
|
|
127
|
+
call = this.healthClient.watch({ service: service });
|
|
128
|
+
_c.label = 2;
|
|
129
|
+
case 2:
|
|
130
|
+
_c.trys.push([2, 7, 8, 13]);
|
|
131
|
+
call_1 = __asyncValues(call);
|
|
132
|
+
_c.label = 3;
|
|
133
|
+
case 3: return [4 /*yield*/, call_1.next()];
|
|
134
|
+
case 4:
|
|
135
|
+
if (!(call_1_1 = _c.sent(), !call_1_1.done)) return [3 /*break*/, 6];
|
|
136
|
+
data = call_1_1.value;
|
|
137
|
+
self.healthCheckEmitter.emit("grpc-health-change:" + serviceName, data.status);
|
|
138
|
+
_c.label = 5;
|
|
139
|
+
case 5: return [3 /*break*/, 3];
|
|
140
|
+
case 6: return [3 /*break*/, 13];
|
|
141
|
+
case 7:
|
|
142
|
+
e_1_1 = _c.sent();
|
|
143
|
+
e_1 = { error: e_1_1 };
|
|
144
|
+
return [3 /*break*/, 13];
|
|
145
|
+
case 8:
|
|
146
|
+
_c.trys.push([8, , 11, 12]);
|
|
147
|
+
if (!(call_1_1 && !call_1_1.done && (_a = call_1.return))) return [3 /*break*/, 10];
|
|
148
|
+
return [4 /*yield*/, _a.call(call_1)];
|
|
149
|
+
case 9:
|
|
150
|
+
_c.sent();
|
|
151
|
+
_c.label = 10;
|
|
152
|
+
case 10: return [3 /*break*/, 12];
|
|
153
|
+
case 11:
|
|
154
|
+
if (e_1) throw e_1.error;
|
|
155
|
+
return [7 /*endfinally*/];
|
|
156
|
+
case 12: return [7 /*endfinally*/];
|
|
157
|
+
case 13: return [3 /*break*/, 15];
|
|
158
|
+
case 14:
|
|
159
|
+
error_1 = _c.sent();
|
|
160
|
+
console.error('Connection to gRPC server closed');
|
|
161
|
+
return [3 /*break*/, 15];
|
|
162
|
+
case 15: return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
return ConduitModule;
|
|
168
|
+
}());
|
|
169
|
+
exports.ConduitModule = ConduitModule;
|
|
170
|
+
//# sourceMappingURL=ConduitModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitModule.js","sourceRoot":"","sources":["../../src/classes/ConduitModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;wBAGjF,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;;;;;;KAErD;IACH,oBAAC;AAAD,CAAC,AAnFD,IAmFC;AAnFY,sCAAa"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Array, ConduitModel, ConduitRouteOption, TYPE } from '../interfaces';
|
|
2
|
+
export declare abstract class ConduitParser<ParseResult, ProcessingObject> {
|
|
3
|
+
result: ParseResult;
|
|
4
|
+
isInput: boolean;
|
|
5
|
+
abstract extractTypes(name: string, fields: ConduitModel | ConduitRouteOption | string, isInput: boolean): ParseResult;
|
|
6
|
+
protected abstract getType(conduitType: TYPE): string | {
|
|
7
|
+
type?: string;
|
|
8
|
+
format?: string;
|
|
9
|
+
properties?: object;
|
|
10
|
+
};
|
|
11
|
+
protected abstract getInitializedResult(): ParseResult;
|
|
12
|
+
protected abstract getProcessingObject(name: string, isArray: boolean): ProcessingObject;
|
|
13
|
+
protected abstract finalizeProcessingObject(object: ProcessingObject): ProcessingObject;
|
|
14
|
+
protected abstract getResultFromString(processingObject: ProcessingObject, name: string, value: any, isRequired: boolean, isArray: boolean): void;
|
|
15
|
+
protected abstract getResultFromObject(processingObject: ProcessingObject, name: string, fieldName: string, value: any, isRequired: boolean, isArray: boolean): void;
|
|
16
|
+
protected abstract getResultFromArray(processingObject: ProcessingObject, resolverName: string, name: string, value: any[], isRequired: boolean, nestedType?: boolean): void;
|
|
17
|
+
protected abstract getResultFromRelation(processingObject: ProcessingObject, resolverName: string, name: string, value: any, isRequired: boolean, isArray: boolean): void;
|
|
18
|
+
protected extractTypesInternal(name: string, fields: ConduitModel | ConduitRouteOption | string): ProcessingObject;
|
|
19
|
+
protected arrayHandler(name: string, field: string, value: Array): ProcessingObject;
|
|
20
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConduitParser = void 0;
|
|
4
|
+
var ConduitParser = /** @class */ (function () {
|
|
5
|
+
function ConduitParser() {
|
|
6
|
+
}
|
|
7
|
+
ConduitParser.prototype.extractTypesInternal = function (name, fields) {
|
|
8
|
+
var processingObject = this.getProcessingObject(name, false);
|
|
9
|
+
if (typeof fields === 'string') {
|
|
10
|
+
this.getResultFromString(processingObject, 'result', fields, false, false);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
for (var field in fields) {
|
|
14
|
+
if (!fields.hasOwnProperty(field))
|
|
15
|
+
continue;
|
|
16
|
+
// if field is simply a type
|
|
17
|
+
if (typeof fields[field] === 'string') {
|
|
18
|
+
this.getResultFromString(processingObject, field, fields[field], false, false);
|
|
19
|
+
}
|
|
20
|
+
// if field is an array
|
|
21
|
+
else if (Array.isArray(fields[field])) {
|
|
22
|
+
this.getResultFromArray(processingObject, name, field, fields[field], false);
|
|
23
|
+
}
|
|
24
|
+
else if (typeof fields[field] === 'object') {
|
|
25
|
+
// if it has "type" as a property we assume that the value is a string
|
|
26
|
+
if (fields[field].type) {
|
|
27
|
+
// if type is simply a type
|
|
28
|
+
if (typeof fields[field].type === 'string') {
|
|
29
|
+
if (fields[field].type === 'Relation') {
|
|
30
|
+
this.getResultFromRelation(processingObject, name, field, fields[field].model, fields[field].required, false);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.getResultFromString(processingObject, field, fields[field].type, fields[field].required, false);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// if type is an array
|
|
37
|
+
else if (Array.isArray(fields[field].type)) {
|
|
38
|
+
this.getResultFromArray(processingObject, name, field, fields[field].type, fields[field].required, true);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.getResultFromObject(processingObject, name, field, fields[field].type, fields[field].required, false);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.getResultFromObject(processingObject, name, field, fields[field], false, false);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
processingObject = this.finalizeProcessingObject(processingObject);
|
|
51
|
+
return processingObject;
|
|
52
|
+
};
|
|
53
|
+
ConduitParser.prototype.arrayHandler = function (name, field, value) {
|
|
54
|
+
var processingObject = this.getProcessingObject(name, true);
|
|
55
|
+
// if array contains simply a type
|
|
56
|
+
if (typeof value[0] === 'string') {
|
|
57
|
+
this.getResultFromString(processingObject, field, value[0], false, true);
|
|
58
|
+
}
|
|
59
|
+
else if (value[0].type) {
|
|
60
|
+
// if array contains a model
|
|
61
|
+
if (value[0].type === 'Relation') {
|
|
62
|
+
this.getResultFromRelation(processingObject, name, field, value[0].model, value[0].required, true);
|
|
63
|
+
}
|
|
64
|
+
else if (typeof value[0].type === 'string') {
|
|
65
|
+
this.getResultFromString(processingObject, field, value[0].type, value[0].required, true);
|
|
66
|
+
}
|
|
67
|
+
else if (Array.isArray(value[0].type)) {
|
|
68
|
+
this.getResultFromArray(processingObject, name, field, value[0].type, value[0].required, true);
|
|
69
|
+
}
|
|
70
|
+
// if the array has "type" but is an object
|
|
71
|
+
else {
|
|
72
|
+
this.getResultFromObject(processingObject, name, field, value[0].type, value[0].required, true);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// if array contains an object
|
|
76
|
+
else {
|
|
77
|
+
this.getResultFromObject(processingObject, name, field, value[0], false, true);
|
|
78
|
+
}
|
|
79
|
+
return processingObject;
|
|
80
|
+
};
|
|
81
|
+
return ConduitParser;
|
|
82
|
+
}());
|
|
83
|
+
exports.ConduitParser = ConduitParser;
|
|
84
|
+
//# sourceMappingURL=ConduitParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitParser.js","sourceRoot":"","sources":["../../src/classes/ConduitParser.ts"],"names":[],"mappings":";;;AAQA;IAAA;IAwMA,CAAC;IAxIW,4CAAoB,GAA9B,UACE,IAAY,EACZ,MAAkD;QAElD,IAAI,gBAAgB,GAAqB,IAAI,CAAC,mBAAmB,C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AAC;AAAD,CAAC,AAxMD,IAwMC;AAxMqB,sCAAa"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConduitModel, ConduitRouteOptions } from '../interfaces';
|
|
2
|
+
import { ConduitRouteReturnDefinition } from './ConduitRouteReturn';
|
|
3
|
+
export declare class ConduitRoute {
|
|
4
|
+
private _returnType;
|
|
5
|
+
private _input;
|
|
6
|
+
private _handler;
|
|
7
|
+
constructor(input: ConduitRouteOptions, type: ConduitRouteReturnDefinition, handler: string);
|
|
8
|
+
get returnTypeName(): string;
|
|
9
|
+
get input(): ConduitRouteOptions;
|
|
10
|
+
get returnTypeFields(): ConduitModel | string;
|
|
11
|
+
get handler(): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConduitRoute = void 0;
|
|
4
|
+
var ConduitRoute = /** @class */ (function () {
|
|
5
|
+
function ConduitRoute(input, type, handler) {
|
|
6
|
+
this._input = input;
|
|
7
|
+
if (!this._input.middlewares) {
|
|
8
|
+
this._input.middlewares = [];
|
|
9
|
+
}
|
|
10
|
+
this._returnType = type;
|
|
11
|
+
this._handler = handler;
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(ConduitRoute.prototype, "returnTypeName", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this._returnType.name;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(ConduitRoute.prototype, "input", {
|
|
21
|
+
get: function () {
|
|
22
|
+
return this._input;
|
|
23
|
+
},
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(ConduitRoute.prototype, "returnTypeFields", {
|
|
28
|
+
get: function () {
|
|
29
|
+
return this._returnType.fields;
|
|
30
|
+
},
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(ConduitRoute.prototype, "handler", {
|
|
35
|
+
get: function () {
|
|
36
|
+
return this._handler;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
return ConduitRoute;
|
|
42
|
+
}());
|
|
43
|
+
exports.ConduitRoute = ConduitRoute;
|
|
44
|
+
//# sourceMappingURL=ConduitRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitRoute.js","sourceRoot":"","sources":["../../src/classes/ConduitRoute.ts"],"names":[],"mappings":";;;AAGA;IAKE,sBACE,KAA0B,EAC1B,IAAkC,EAClC,OAAe;QAEf,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,EAAE,CAAC;SAC9B;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,sBAAI,wCAAc;aAAlB;YACE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAC/B,CAAC;;;OAAA;IAED,sBAAI,+BAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAI,0CAAgB;aAApB;YACE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACjC,CAAC;;;OAAA;IAED,sBAAI,iCAAO;aAAX;YACE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IACH,mBAAC;AAAD,CAAC,AAjCD,IAiCC;AAjCY,oCAAY"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ConduitModel } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Supports:
|
|
4
|
+
* {
|
|
5
|
+
* name: 'String',
|
|
6
|
+
* age: 'Number
|
|
7
|
+
* ....
|
|
8
|
+
* }
|
|
9
|
+
*
|
|
10
|
+
* or
|
|
11
|
+
*
|
|
12
|
+
* {
|
|
13
|
+
* name: {
|
|
14
|
+
* type: 'String',
|
|
15
|
+
* required: true
|
|
16
|
+
* },
|
|
17
|
+
* age: 'Number'
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* or
|
|
21
|
+
*
|
|
22
|
+
* {
|
|
23
|
+
* user: {
|
|
24
|
+
* username: 'String',
|
|
25
|
+
* age: {
|
|
26
|
+
* type: 'Number',
|
|
27
|
+
* required: true
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* or
|
|
33
|
+
*
|
|
34
|
+
* {
|
|
35
|
+
* user:{
|
|
36
|
+
* friends: ['String'],
|
|
37
|
+
* post: [{type: 'String', required:trues}]
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export declare class ConduitRouteReturnDefinition {
|
|
43
|
+
private _name;
|
|
44
|
+
private _fields;
|
|
45
|
+
constructor(name: string, fields: ConduitModel | string);
|
|
46
|
+
get name(): string;
|
|
47
|
+
get fields(): ConduitModel | string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConduitRouteReturnDefinition = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Supports:
|
|
6
|
+
* {
|
|
7
|
+
* name: 'String',
|
|
8
|
+
* age: 'Number
|
|
9
|
+
* ....
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* or
|
|
13
|
+
*
|
|
14
|
+
* {
|
|
15
|
+
* name: {
|
|
16
|
+
* type: 'String',
|
|
17
|
+
* required: true
|
|
18
|
+
* },
|
|
19
|
+
* age: 'Number'
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* or
|
|
23
|
+
*
|
|
24
|
+
* {
|
|
25
|
+
* user: {
|
|
26
|
+
* username: 'String',
|
|
27
|
+
* age: {
|
|
28
|
+
* type: 'Number',
|
|
29
|
+
* required: true
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* or
|
|
35
|
+
*
|
|
36
|
+
* {
|
|
37
|
+
* user:{
|
|
38
|
+
* friends: ['String'],
|
|
39
|
+
* post: [{type: 'String', required:trues}]
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
var ConduitRouteReturnDefinition = /** @class */ (function () {
|
|
45
|
+
function ConduitRouteReturnDefinition(name, fields) {
|
|
46
|
+
this._name = name;
|
|
47
|
+
this._fields = fields;
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(ConduitRouteReturnDefinition.prototype, "name", {
|
|
50
|
+
get: function () {
|
|
51
|
+
return this._name;
|
|
52
|
+
},
|
|
53
|
+
enumerable: false,
|
|
54
|
+
configurable: true
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(ConduitRouteReturnDefinition.prototype, "fields", {
|
|
57
|
+
get: function () {
|
|
58
|
+
return this._fields;
|
|
59
|
+
},
|
|
60
|
+
enumerable: false,
|
|
61
|
+
configurable: true
|
|
62
|
+
});
|
|
63
|
+
return ConduitRouteReturnDefinition;
|
|
64
|
+
}());
|
|
65
|
+
exports.ConduitRouteReturnDefinition = ConduitRouteReturnDefinition;
|
|
66
|
+
//# sourceMappingURL=ConduitRouteReturn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConduitRouteReturn.js","sourceRoot":"","sources":["../../src/classes/ConduitRouteReturn.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH;IAIE,sCAAY,IAAY,EAAE,MAA6B;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,sBAAI,8CAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAED,sBAAI,gDAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IACH,mCAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,oEAA4B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConduitModel, ConduitModelOptions } from '../interfaces';
|
|
2
|
+
export declare class ConduitSchema {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly fields: ConduitModel;
|
|
5
|
+
readonly collectionName: string | '';
|
|
6
|
+
readonly schemaOptions: ConduitModelOptions;
|
|
7
|
+
ownerModule: string;
|
|
8
|
+
constructor(name: string, fields: ConduitModel, schemaOptions?: ConduitModelOptions, collectionName?: string);
|
|
9
|
+
get modelSchema(): ConduitModel;
|
|
10
|
+
}
|