@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.
Files changed (206) hide show
  1. package/README.md +20 -0
  2. package/dist/classes/ConduitActiveSchema.d.ts +19 -0
  3. package/dist/classes/ConduitActiveSchema.js +57 -0
  4. package/dist/classes/ConduitActiveSchema.js.map +1 -0
  5. package/dist/classes/ConduitMiddleware.d.ts +8 -0
  6. package/dist/classes/ConduitMiddleware.js +26 -0
  7. package/dist/classes/ConduitMiddleware.js.map +1 -0
  8. package/dist/classes/ConduitModule.d.ts +26 -0
  9. package/dist/classes/ConduitModule.js +170 -0
  10. package/dist/classes/ConduitModule.js.map +1 -0
  11. package/dist/classes/ConduitParser.d.ts +20 -0
  12. package/dist/classes/ConduitParser.js +84 -0
  13. package/dist/classes/ConduitParser.js.map +1 -0
  14. package/dist/classes/ConduitRoute.d.ts +12 -0
  15. package/dist/classes/ConduitRoute.js +44 -0
  16. package/dist/classes/ConduitRoute.js.map +1 -0
  17. package/dist/classes/ConduitRouteReturn.d.ts +48 -0
  18. package/dist/classes/ConduitRouteReturn.js +66 -0
  19. package/dist/classes/ConduitRouteReturn.js.map +1 -0
  20. package/dist/classes/ConduitSchema.d.ts +10 -0
  21. package/dist/classes/ConduitSchema.js +22 -0
  22. package/dist/classes/ConduitSchema.js.map +1 -0
  23. package/dist/classes/ConduitSchemaExtension.d.ts +7 -0
  24. package/dist/classes/ConduitSchemaExtension.js +19 -0
  25. package/dist/classes/ConduitSchemaExtension.js.map +1 -0
  26. package/dist/classes/ConduitServiceModule.d.ts +25 -0
  27. package/dist/classes/ConduitServiceModule.js +139 -0
  28. package/dist/classes/ConduitServiceModule.js.map +1 -0
  29. package/dist/classes/ConduitSocket.d.ts +9 -0
  30. package/dist/classes/ConduitSocket.js +27 -0
  31. package/dist/classes/ConduitSocket.js.map +1 -0
  32. package/dist/classes/ConfigController.d.ts +7 -0
  33. package/dist/classes/ConfigController.js +27 -0
  34. package/dist/classes/ConfigController.js.map +1 -0
  35. package/dist/classes/Error.d.ts +11 -0
  36. package/dist/classes/Error.js +51 -0
  37. package/dist/classes/Error.js.map +1 -0
  38. package/dist/classes/GrpcServer.d.ts +19 -0
  39. package/dist/classes/GrpcServer.js +185 -0
  40. package/dist/classes/GrpcServer.js.map +1 -0
  41. package/dist/classes/ManagedModule.d.ts +20 -0
  42. package/dist/classes/ManagedModule.js +212 -0
  43. package/dist/classes/ManagedModule.js.map +1 -0
  44. package/dist/classes/ModuleManager.d.ts +11 -0
  45. package/dist/classes/ModuleManager.js +191 -0
  46. package/dist/classes/ModuleManager.js.map +1 -0
  47. package/dist/classes/Routing/RouteBuilder.d.ts +28 -0
  48. package/dist/classes/Routing/RouteBuilder.js +107 -0
  49. package/dist/classes/Routing/RouteBuilder.js.map +1 -0
  50. package/dist/classes/Routing/RoutingManager.d.ts +25 -0
  51. package/dist/classes/Routing/RoutingManager.js +193 -0
  52. package/dist/classes/Routing/RoutingManager.js.map +1 -0
  53. package/dist/classes/index.d.ts +16 -0
  54. package/dist/classes/index.js +29 -0
  55. package/dist/classes/index.js.map +1 -0
  56. package/dist/constants/enums/PlatformTypesEnum.d.ts +9 -0
  57. package/dist/constants/enums/PlatformTypesEnum.js +14 -0
  58. package/dist/constants/enums/PlatformTypesEnum.js.map +1 -0
  59. package/dist/constants/enums/index.d.ts +1 -0
  60. package/dist/constants/enums/index.js +14 -0
  61. package/dist/constants/enums/index.js.map +1 -0
  62. package/dist/constants/index.d.ts +1 -0
  63. package/dist/constants/index.js +14 -0
  64. package/dist/constants/index.js.map +1 -0
  65. package/dist/helpers/GrpcHelper.d.ts +8 -0
  66. package/dist/helpers/GrpcHelper.js +44 -0
  67. package/dist/helpers/GrpcHelper.js.map +1 -0
  68. package/dist/helpers/RoutingJsonConstructor.d.ts +9 -0
  69. package/dist/helpers/RoutingJsonConstructor.js +89 -0
  70. package/dist/helpers/RoutingJsonConstructor.js.map +1 -0
  71. package/dist/helpers/RoutingUtilities.d.ts +13 -0
  72. package/dist/helpers/RoutingUtilities.js +69 -0
  73. package/dist/helpers/RoutingUtilities.js.map +1 -0
  74. package/dist/helpers/TypeHelpers.d.ts +44 -0
  75. package/dist/helpers/TypeHelpers.js +144 -0
  76. package/dist/helpers/TypeHelpers.js.map +1 -0
  77. package/dist/helpers/index.d.ts +5 -0
  78. package/dist/helpers/index.js +18 -0
  79. package/dist/helpers/index.js.map +1 -0
  80. package/dist/helpers/wrapGrpcFunctions.d.ts +5 -0
  81. package/dist/helpers/wrapGrpcFunctions.js +37 -0
  82. package/dist/helpers/wrapGrpcFunctions.js.map +1 -0
  83. package/dist/helpers/wrapRouterFunctions.d.ts +7 -0
  84. package/dist/helpers/wrapRouterFunctions.js +111 -0
  85. package/dist/helpers/wrapRouterFunctions.js.map +1 -0
  86. package/dist/index.d.ts +70 -0
  87. package/dist/index.js +481 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/interceptors/grpcSignedToken.d.ts +2 -0
  90. package/dist/interceptors/grpcSignedToken.js +88 -0
  91. package/dist/interceptors/grpcSignedToken.js.map +1 -0
  92. package/dist/interceptors/index.d.ts +2 -0
  93. package/dist/interceptors/index.js +15 -0
  94. package/dist/interceptors/index.js.map +1 -0
  95. package/dist/interceptors/moduleName.d.ts +2 -0
  96. package/dist/interceptors/moduleName.js +88 -0
  97. package/dist/interceptors/moduleName.js.map +1 -0
  98. package/dist/interfaces/ConduitService.d.ts +8 -0
  99. package/dist/interfaces/ConduitService.js +3 -0
  100. package/dist/interfaces/ConduitService.js.map +1 -0
  101. package/dist/interfaces/GrpcCallback.d.ts +4 -0
  102. package/dist/interfaces/GrpcCallback.js +3 -0
  103. package/dist/interfaces/GrpcCallback.js.map +1 -0
  104. package/dist/interfaces/Indexable.d.ts +9 -0
  105. package/dist/interfaces/Indexable.js +3 -0
  106. package/dist/interfaces/Indexable.js.map +1 -0
  107. package/dist/interfaces/Middleware.d.ts +7 -0
  108. package/dist/interfaces/Middleware.js +3 -0
  109. package/dist/interfaces/Middleware.js.map +1 -0
  110. package/dist/interfaces/Model.d.ts +37 -0
  111. package/dist/interfaces/Model.js +19 -0
  112. package/dist/interfaces/Model.js.map +1 -0
  113. package/dist/interfaces/Route.d.ts +54 -0
  114. package/dist/interfaces/Route.js +21 -0
  115. package/dist/interfaces/Route.js.map +1 -0
  116. package/dist/interfaces/Socket.d.ts +34 -0
  117. package/dist/interfaces/Socket.js +9 -0
  118. package/dist/interfaces/Socket.js.map +1 -0
  119. package/dist/interfaces/index.d.ts +7 -0
  120. package/dist/interfaces/index.js +20 -0
  121. package/dist/interfaces/index.js.map +1 -0
  122. package/dist/modules/admin/index.d.ts +13 -0
  123. package/dist/modules/admin/index.js +131 -0
  124. package/dist/modules/admin/index.js.map +1 -0
  125. package/dist/modules/authentication/index.d.ts +11 -0
  126. package/dist/modules/authentication/index.js +50 -0
  127. package/dist/modules/authentication/index.js.map +1 -0
  128. package/dist/modules/chat/index.d.ts +10 -0
  129. package/dist/modules/chat/index.js +46 -0
  130. package/dist/modules/chat/index.js.map +1 -0
  131. package/dist/modules/config/index.d.ts +25 -0
  132. package/dist/modules/config/index.js +234 -0
  133. package/dist/modules/config/index.js.map +1 -0
  134. package/dist/modules/core/index.d.ts +6 -0
  135. package/dist/modules/core/index.js +32 -0
  136. package/dist/modules/core/index.js.map +1 -0
  137. package/dist/modules/database/index.d.ts +30 -0
  138. package/dist/modules/database/index.js +201 -0
  139. package/dist/modules/database/index.js.map +1 -0
  140. package/dist/modules/email/index.d.ts +21 -0
  141. package/dist/modules/email/index.js +63 -0
  142. package/dist/modules/email/index.js.map +1 -0
  143. package/dist/modules/forms/index.d.ts +7 -0
  144. package/dist/modules/forms/index.js +37 -0
  145. package/dist/modules/forms/index.js.map +1 -0
  146. package/dist/modules/index.d.ts +11 -0
  147. package/dist/modules/index.js +24 -0
  148. package/dist/modules/index.js.map +1 -0
  149. package/dist/modules/pushNotifications/index.d.ts +10 -0
  150. package/dist/modules/pushNotifications/index.js +63 -0
  151. package/dist/modules/pushNotifications/index.js.map +1 -0
  152. package/dist/modules/router/index.d.ts +8 -0
  153. package/dist/modules/router/index.js +43 -0
  154. package/dist/modules/router/index.js.map +1 -0
  155. package/dist/modules/sms/index.d.ts +10 -0
  156. package/dist/modules/sms/index.js +46 -0
  157. package/dist/modules/sms/index.js.map +1 -0
  158. package/dist/modules/storage/index.d.ts +10 -0
  159. package/dist/modules/storage/index.js +47 -0
  160. package/dist/modules/storage/index.js.map +1 -0
  161. package/dist/protoUtils/authentication.d.ts +209 -0
  162. package/dist/protoUtils/authentication.js +533 -0
  163. package/dist/protoUtils/authentication.js.map +1 -0
  164. package/dist/protoUtils/chat.d.ts +178 -0
  165. package/dist/protoUtils/chat.js +534 -0
  166. package/dist/protoUtils/chat.js.map +1 -0
  167. package/dist/protoUtils/core.d.ts +607 -0
  168. package/dist/protoUtils/core.js +1883 -0
  169. package/dist/protoUtils/core.js.map +1 -0
  170. package/dist/protoUtils/database.d.ts +496 -0
  171. package/dist/protoUtils/database.js +1275 -0
  172. package/dist/protoUtils/database.js.map +1 -0
  173. package/dist/protoUtils/email.d.ts +153 -0
  174. package/dist/protoUtils/email.js +543 -0
  175. package/dist/protoUtils/email.js.map +1 -0
  176. package/dist/protoUtils/forms.d.ts +54 -0
  177. package/dist/protoUtils/forms.js +141 -0
  178. package/dist/protoUtils/forms.js.map +1 -0
  179. package/dist/protoUtils/grpc_health_check.d.ts +83 -0
  180. package/dist/protoUtils/grpc_health_check.js +197 -0
  181. package/dist/protoUtils/grpc_health_check.js.map +1 -0
  182. package/dist/protoUtils/push-notifications.d.ts +179 -0
  183. package/dist/protoUtils/push-notifications.js +512 -0
  184. package/dist/protoUtils/push-notifications.js.map +1 -0
  185. package/dist/protoUtils/sms.d.ts +176 -0
  186. package/dist/protoUtils/sms.js +459 -0
  187. package/dist/protoUtils/sms.js.map +1 -0
  188. package/dist/protoUtils/storage.d.ts +203 -0
  189. package/dist/protoUtils/storage.js +522 -0
  190. package/dist/protoUtils/storage.js.map +1 -0
  191. package/dist/types/index.d.ts +55 -0
  192. package/dist/types/index.js +37 -0
  193. package/dist/types/index.js.map +1 -0
  194. package/dist/utilities/EventBus.d.ts +10 -0
  195. package/dist/utilities/EventBus.js +52 -0
  196. package/dist/utilities/EventBus.js.map +1 -0
  197. package/dist/utilities/RedisManager.d.ts +6 -0
  198. package/dist/utilities/RedisManager.js +32 -0
  199. package/dist/utilities/RedisManager.js.map +1 -0
  200. package/dist/utilities/StateManager.d.ts +10 -0
  201. package/dist/utilities/StateManager.js +31 -0
  202. package/dist/utilities/StateManager.js.map +1 -0
  203. package/dist/utilities/index.d.ts +1 -0
  204. package/dist/utilities/index.js +10 -0
  205. package/dist/utilities/index.js.map +1 -0
  206. package/package.json +56 -0
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConduitRelation = exports.ConduitJson = exports.ConduitObjectId = exports.ConduitDate = exports.ConduitBoolean = exports.ConduitNumber = exports.ConduitString = void 0;
4
+ var interfaces_1 = require("../interfaces");
5
+ var ConduitStringConstructor = /** @class */ (function () {
6
+ // private to disallow creating other instances of this type
7
+ function ConduitStringConstructor() {
8
+ }
9
+ Object.defineProperty(ConduitStringConstructor, "Optional", {
10
+ get: function () {
11
+ return interfaces_1.TYPE.String;
12
+ },
13
+ enumerable: false,
14
+ configurable: true
15
+ });
16
+ Object.defineProperty(ConduitStringConstructor, "Required", {
17
+ get: function () {
18
+ return { type: interfaces_1.TYPE.String, required: true };
19
+ },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+ return ConduitStringConstructor;
24
+ }());
25
+ exports.ConduitString = ConduitStringConstructor;
26
+ var ConduitNumberConstructor = /** @class */ (function () {
27
+ // private to disallow creating other instances of this type
28
+ function ConduitNumberConstructor() {
29
+ }
30
+ Object.defineProperty(ConduitNumberConstructor, "Optional", {
31
+ get: function () {
32
+ return interfaces_1.TYPE.Number;
33
+ },
34
+ enumerable: false,
35
+ configurable: true
36
+ });
37
+ Object.defineProperty(ConduitNumberConstructor, "Required", {
38
+ get: function () {
39
+ return { type: interfaces_1.TYPE.Number, required: true };
40
+ },
41
+ enumerable: false,
42
+ configurable: true
43
+ });
44
+ return ConduitNumberConstructor;
45
+ }());
46
+ exports.ConduitNumber = ConduitNumberConstructor;
47
+ var ConduitBooleanConstructor = /** @class */ (function () {
48
+ // private to disallow creating other instances of this type
49
+ function ConduitBooleanConstructor() {
50
+ }
51
+ Object.defineProperty(ConduitBooleanConstructor, "Optional", {
52
+ get: function () {
53
+ return interfaces_1.TYPE.Boolean;
54
+ },
55
+ enumerable: false,
56
+ configurable: true
57
+ });
58
+ Object.defineProperty(ConduitBooleanConstructor, "Required", {
59
+ get: function () {
60
+ return { type: interfaces_1.TYPE.Boolean, required: true };
61
+ },
62
+ enumerable: false,
63
+ configurable: true
64
+ });
65
+ return ConduitBooleanConstructor;
66
+ }());
67
+ exports.ConduitBoolean = ConduitBooleanConstructor;
68
+ var ConduitDateConstructor = /** @class */ (function () {
69
+ // private to disallow creating other instances of this type
70
+ function ConduitDateConstructor() {
71
+ }
72
+ Object.defineProperty(ConduitDateConstructor, "Optional", {
73
+ get: function () {
74
+ return interfaces_1.TYPE.Date;
75
+ },
76
+ enumerable: false,
77
+ configurable: true
78
+ });
79
+ Object.defineProperty(ConduitDateConstructor, "Required", {
80
+ get: function () {
81
+ return { type: interfaces_1.TYPE.Date, required: true };
82
+ },
83
+ enumerable: false,
84
+ configurable: true
85
+ });
86
+ return ConduitDateConstructor;
87
+ }());
88
+ exports.ConduitDate = ConduitDateConstructor;
89
+ var ConduitObjectIdConstructor = /** @class */ (function () {
90
+ // private to disallow creating other instances of this type
91
+ function ConduitObjectIdConstructor() {
92
+ }
93
+ Object.defineProperty(ConduitObjectIdConstructor, "Optional", {
94
+ get: function () {
95
+ return interfaces_1.TYPE.ObjectId;
96
+ },
97
+ enumerable: false,
98
+ configurable: true
99
+ });
100
+ Object.defineProperty(ConduitObjectIdConstructor, "Required", {
101
+ get: function () {
102
+ return { type: interfaces_1.TYPE.ObjectId, required: true };
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ return ConduitObjectIdConstructor;
108
+ }());
109
+ exports.ConduitObjectId = ConduitObjectIdConstructor;
110
+ var ConduitJSONConstructor = /** @class */ (function () {
111
+ // private to disallow creating other instances of this type
112
+ function ConduitJSONConstructor() {
113
+ }
114
+ Object.defineProperty(ConduitJSONConstructor, "Optional", {
115
+ get: function () {
116
+ return interfaces_1.TYPE.JSON;
117
+ },
118
+ enumerable: false,
119
+ configurable: true
120
+ });
121
+ Object.defineProperty(ConduitJSONConstructor, "Required", {
122
+ get: function () {
123
+ return { type: interfaces_1.TYPE.JSON, required: true };
124
+ },
125
+ enumerable: false,
126
+ configurable: true
127
+ });
128
+ return ConduitJSONConstructor;
129
+ }());
130
+ exports.ConduitJson = ConduitJSONConstructor;
131
+ var ConduitRelationConstructor = /** @class */ (function () {
132
+ // private to disallow creating other instances of this type
133
+ function ConduitRelationConstructor() {
134
+ }
135
+ ConduitRelationConstructor.Optional = function (model) {
136
+ return { type: interfaces_1.TYPE.Relation, model: model, required: false };
137
+ };
138
+ ConduitRelationConstructor.Required = function (model) {
139
+ return { type: interfaces_1.TYPE.Relation, model: model, required: true };
140
+ };
141
+ return ConduitRelationConstructor;
142
+ }());
143
+ exports.ConduitRelation = ConduitRelationConstructor;
144
+ //# sourceMappingURL=TypeHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeHelpers.js","sourceRoot":"","sources":["../../src/helpers/TypeHelpers.ts"],"names":[],"mappings":";;;AAAA,4CAAwD;AAExD;IACE,4DAA4D;IAC5D;IAAuB,CAAC;IAExB,sBAAW,oCAAQ;aAAnB;YACE,OAAO,iBAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAED,sBAAW,oCAAQ;aAAnB;YACE,OAAO,EAAE,IAAI,EAAE,iBAAI,CA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AAI,CAAC,QAAQ,CAAC;QACvB,CAAC;;;OAAA;IAED,sBAAW,sCAAQ;aAAnB;YACE,OAAO,EAAE,IAAI,EAAE,iBAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACjD,CAAC;;;OAAA;IACH,iCAAC;AAAD,CAAC,AAXD,IAWC;AAEU,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAExD;IACE,4DAA4D;IAC5D;IAAuB,CAAC;IAExB,sBAAW,kCAAQ;aAAnB;YACE,OAAO,iBAAI,CAAC,IAAI,CAAC;QACnB,CAAC;;;OAAA;IAED,sBAAW,kCAAQ;aAAnB;YACE,OAAO,EAAE,IAAI,EAAE,iBAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC7C,CAAC;;;OAAA;IACH,6BAAC;AAAD,CAAC,AAXD,IAWC;AAEU,QAAA,WAAW,GAAG,sBAAsB,CAAC;AAEhD;IACE,4DAA4D;IAC5D;IAAuB,CAAC;IAEjB,mCAAQ,GAAf,UAAgB,KAAa;QAC3B,OAAO,EAAE,IAAI,EAAE,iBAAI,CAAC,QAAQ,EAAE,KAAK,OAAA,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACzD,CAAC;IAEM,mCAAQ,GAAf,UAAgB,KAAa;QAC3B,OAAO,EAAE,IAAI,EAAE,iBAAI,CAAC,QAAQ,EAAE,KAAK,OAAA,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;IACH,iCAAC;AAAD,CAAC,AAXD,IAWC;AAEU,QAAA,eAAe,GAAG,0BAA0B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './TypeHelpers';
2
+ export * from './RoutingJsonConstructor';
3
+ export * from './GrpcHelper';
4
+ export * from './wrapRouterFunctions';
5
+ export * from './wrapGrpcFunctions';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./TypeHelpers"), exports);
14
+ __exportStar(require("./RoutingJsonConstructor"), exports);
15
+ __exportStar(require("./GrpcHelper"), exports);
16
+ __exportStar(require("./wrapRouterFunctions"), exports);
17
+ __exportStar(require("./wrapGrpcFunctions"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2DAAyC;AACzC,+CAA6B;AAC7B,wDAAsC;AACtC,sDAAoC"}
@@ -0,0 +1,5 @@
1
+ export declare function wrapGrpcFunctions(functions: {
2
+ [name: string]: Function;
3
+ }): {
4
+ [name: string]: Function;
5
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapGrpcFunctions = void 0;
4
+ var fast_jwt_1 = require("fast-jwt");
5
+ var grpc_js_1 = require("@grpc/grpc-js");
6
+ function wrapGrpcFunctions(functions) {
7
+ var grpcKey = process.env.GRPC_KEY;
8
+ var verify = fast_jwt_1.createVerifier({ key: grpcKey });
9
+ var wrappedFunctions = {};
10
+ Object.keys(functions).forEach(function (name) {
11
+ wrappedFunctions[name] = function (call, callback) {
12
+ var grpcToken = call.metadata.get('grpc-token')[0];
13
+ if (!grpcToken) {
14
+ callback({
15
+ code: grpc_js_1.status.PERMISSION_DENIED,
16
+ message: 'No gRPC protection token provided',
17
+ });
18
+ return;
19
+ }
20
+ try {
21
+ var jwt = verify(grpcToken);
22
+ call.metadata.set('module-name', jwt.moduleName);
23
+ }
24
+ catch (_a) {
25
+ callback({
26
+ code: grpc_js_1.status.PERMISSION_DENIED,
27
+ message: 'Failed to verify gRPC protection token. GRPC_KEY value differs',
28
+ });
29
+ return;
30
+ }
31
+ functions[name](call, callback);
32
+ };
33
+ });
34
+ return wrappedFunctions;
35
+ }
36
+ exports.wrapGrpcFunctions = wrapGrpcFunctions;
37
+ //# sourceMappingURL=wrapGrpcFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapGrpcFunctions.js","sourceRoot":"","sources":["../../src/helpers/wrapGrpcFunctions.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAC1C,yCAAuC;AAOvC,SAAgB,iBAAiB,CAAC,SAAuC;IACvE,IAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrC,IAAM,MAAM,GAAG,yBAAc,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IAChD,IAAM,gBAAgB,GAAiC,EAAE,CAAC;IAC1D,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;QACjC,gBAAgB,CAAC,IAAI,CAAC,GAAG,UAAC,IAAS,EAAE,QAAa;YAChD,IAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YACrD,IAAI,CAAC,SAAS,EAAE;gBACd,QAAQ,CAAC;oBACP,IAAI,EAAE,gBAAM,CAAC,iBAAiB;oBAC9B,OAAO,EAAE,mCAAmC;iBAC7C,CAAC,CAAC;gBACH,OAAO;aACR;YACD,IAAI;gBACF,IAAM,GAAG,GAAQ,MAAM,CAAC,SAAS,CAAC,CAAC;gBACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;aAClD;YAAC,WAAM;gBACN,QAAQ,CAAC;oBACP,IAAI,EAAE,gBAAM,CAAC,iBAAiB;oBAC9B,OAAO,EAAE,gEAAgE;iBAC1E,CAAC,CAAC;gBACH,OAAO;aACR;YACD,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AA5BD,8CA4BC"}
@@ -0,0 +1,7 @@
1
+ import { ParsedRouterRequest, ParsedSocketRequest, UnparsedRouterResponse, UnparsedSocketResponse } from '../types';
2
+ import { Indexable } from '../interfaces';
3
+ export declare type RouterRequestHandler = (call: ParsedRouterRequest) => Promise<UnparsedRouterResponse>;
4
+ export declare type SocketRequestHandler = (call: ParsedSocketRequest) => Promise<UnparsedSocketResponse>;
5
+ export declare type RequestHandlers = RouterRequestHandler | SocketRequestHandler;
6
+ export declare function wrapCallObjectForRouter(call: Indexable): ParsedRouterRequest;
7
+ export declare function wrapRouterGrpcFunction(fun: RequestHandlers): (call: Indexable, callback: any) => void;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.wrapRouterGrpcFunction = exports.wrapCallObjectForRouter = void 0;
15
+ var grpc_js_1 = require("@grpc/grpc-js");
16
+ function wrapCallObjectForRouter(call) {
17
+ return {
18
+ request: {
19
+ params: call.request,
20
+ path: '',
21
+ headers: {},
22
+ context: {},
23
+ },
24
+ };
25
+ }
26
+ exports.wrapCallObjectForRouter = wrapCallObjectForRouter;
27
+ function generateLog(routerRequest, requestReceive, call, status) {
28
+ var log = '';
29
+ if (routerRequest) {
30
+ log += "Request: " + call.request.path;
31
+ }
32
+ else {
33
+ log += "Socket: " + call.request.event + " socket: " + call.request.socket;
34
+ }
35
+ log += " " + (status !== null && status !== void 0 ? status : '200') + " " + (Date.now() - requestReceive);
36
+ console.log(log);
37
+ }
38
+ function parseRequestData(data) {
39
+ if (typeof data === 'string' && data.length !== 0) {
40
+ return JSON.parse(data);
41
+ }
42
+ else if (typeof data === 'string') {
43
+ return {};
44
+ }
45
+ }
46
+ function wrapRouterGrpcFunction(fun) {
47
+ return function (call, callback) {
48
+ var _a, _b;
49
+ var requestReceive = Date.now();
50
+ var routerRequest = true;
51
+ try {
52
+ call.request.context = parseRequestData(call.request.context);
53
+ call.request.params = parseRequestData(call.request.params);
54
+ routerRequest = !call.request.hasOwnProperty('event');
55
+ if (routerRequest) {
56
+ call.request.headers = parseRequestData(call.request.headers);
57
+ }
58
+ }
59
+ catch (e) {
60
+ generateLog(routerRequest, requestReceive, call, grpc_js_1.status.INTERNAL);
61
+ console.log((_a = e.message) !== null && _a !== void 0 ? _a : 'Something went wrong');
62
+ return callback({
63
+ code: grpc_js_1.status.INTERNAL,
64
+ message: (_b = e.message) !== null && _b !== void 0 ? _b : 'Something went wrong',
65
+ });
66
+ }
67
+ fun(call)
68
+ .then(function (r) {
69
+ var _a;
70
+ if (!r)
71
+ return;
72
+ if (routerRequest) {
73
+ if (typeof r === 'string') {
74
+ callback(null, { result: r });
75
+ }
76
+ else {
77
+ var respObject = void 0;
78
+ if (r.removeCookies || r.setCookies) {
79
+ respObject = {
80
+ removeCookies: r.removeCookies,
81
+ setCookies: r.setCookies,
82
+ };
83
+ }
84
+ if (r.result || r.redirect) {
85
+ callback(null, __assign(__assign({}, respObject), { redirect: (_a = r.redirect) !== null && _a !== void 0 ? _a : undefined, result: r.result ? JSON.stringify(r.result) : undefined }));
86
+ }
87
+ else {
88
+ callback(null, __assign(__assign({}, respObject), { result: JSON.stringify(r) }));
89
+ }
90
+ }
91
+ }
92
+ else {
93
+ if (r.hasOwnProperty('data'))
94
+ r.data = JSON.stringify(r.data);
95
+ callback(null, r);
96
+ }
97
+ generateLog(routerRequest, requestReceive, call, undefined);
98
+ })
99
+ .catch(function (error) {
100
+ var _a, _b, _c, _d;
101
+ generateLog(routerRequest, requestReceive, call, (_a = error.code) !== null && _a !== void 0 ? _a : grpc_js_1.status.INTERNAL);
102
+ console.log((_b = error.message) !== null && _b !== void 0 ? _b : 'Something went wrong');
103
+ callback({
104
+ code: (_c = error.code) !== null && _c !== void 0 ? _c : grpc_js_1.status.INTERNAL,
105
+ message: (_d = error.message) !== null && _d !== void 0 ? _d : 'Something went wrong',
106
+ });
107
+ });
108
+ };
109
+ }
110
+ exports.wrapRouterGrpcFunction = wrapRouterGrpcFunction;
111
+ //# sourceMappingURL=wrapRouterFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapRouterFunctions.js","sourceRoot":"","sources":["../../src/helpers/wrapRouterFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,yCAAuC;AAYvC,SAAgB,uBAAuB,CAAC,IAAe;IACrD,OAAO;QACL,OAAO,EAAE;YACP,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,EAAE;SACZ;KACF,CAAC;AACJ,CAAC;AATD,0DASC;AAED,SAAS,WAAW,CAClB,aAAsB,EACtB,cAAsB,EACtB,IAAe,EACf,MAAe;IAEf,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,aAAa,EAAE;QACjB,GAAG,IAAI,cAAY,IAAI,CAAC,OAAO,CAAC,IAAM,CAAC;KACxC;SAAM;QACL,GAAG,IAAI,aAAW,IAAI,CAAC,OAAO,CAAC,KAAK,iBAAY,IAAI,CAAC,OAAO,CAAC,MAAQ,CAAC;KACvE;IACD,GAAG,IAAI,OAAI,MAAM,aAAN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AAE,SAAS,CAAC,CAAC;QAC9D,CAAC,CAAC;aACD,KAAK,CAAC,UAAA,KAAK;;YACV,WAAW,CAAC,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,gBAAM,CAAC,QAAQ,CAAC,CAAC;YAChF,OAAO,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,sBAAsB,CAAC,CAAC;YACrD,QAAQ,CAAC;gBACP,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,gBAAM,CAAC,QAAQ;gBACnC,OAAO,EAAE,MAAA,KAAK,CAAC,OAAO,mCAAI,sBAAsB;aACjD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACJ,CAAC;AA9DD,wDA8DC"}
@@ -0,0 +1,70 @@
1
+ import { Admin, Chat, Config, Core, DatabaseProvider, Email, Forms, PushNotifications, Router, SMS, Storage } from './modules';
2
+ import { Authentication } from './modules/authentication';
3
+ import { EventBus } from './utilities/EventBus';
4
+ import { StateManager } from './utilities/StateManager';
5
+ import { CompatServiceDefinition } from 'nice-grpc/lib/service-definitions';
6
+ import { Client } from 'nice-grpc';
7
+ import { HealthDefinition } from './protoUtils/grpc_health_check';
8
+ export default class ConduitGrpcSdk {
9
+ private readonly serverUrl;
10
+ private readonly _watchModules;
11
+ private readonly _core?;
12
+ private readonly _config?;
13
+ private readonly _admin?;
14
+ private readonly _router?;
15
+ private readonly _modules;
16
+ private readonly _availableModules;
17
+ private _dynamicModules;
18
+ private _eventBus?;
19
+ private _stateManager?;
20
+ private lastSearch;
21
+ private readonly name;
22
+ private readonly _serviceHealthStatusGetter;
23
+ private readonly _grpcToken?;
24
+ private _initialized;
25
+ constructor(serverUrl: string, serviceHealthStatusGetter: Function, name?: string, watchModules?: boolean);
26
+ initialize(): Promise<void>;
27
+ private _initialize;
28
+ get bus(): EventBus | null;
29
+ get state(): StateManager | null;
30
+ get core(): Core;
31
+ get config(): Config;
32
+ get admin(): Admin;
33
+ get router(): Router;
34
+ get database(): DatabaseProvider | null;
35
+ get databaseProvider(): DatabaseProvider | null;
36
+ get storage(): Storage | null;
37
+ get forms(): Forms | null;
38
+ get emailProvider(): Email | null;
39
+ get pushNotifications(): PushNotifications | null;
40
+ get authentication(): Authentication | null;
41
+ get sms(): SMS | null;
42
+ get chat(): Chat | null;
43
+ watchModules(): void;
44
+ monitorModule(moduleName: string, callback: (serving: boolean) => void, wait?: boolean): Promise<void>;
45
+ unmonitorModule(moduleName: string): void;
46
+ initializeEventBus(): Promise<EventBus>;
47
+ /**
48
+ * Gets all the registered modules from the config and creates clients for them.
49
+ * This will only work on known modules, since the primary usage for the sdk is internal
50
+ */
51
+ initializeModules(): Promise<string | void>;
52
+ createModuleClient(moduleName: string, moduleUrl: string): void;
53
+ moduleClient(name: string, type: CompatServiceDefinition): void;
54
+ getModule<T extends CompatServiceDefinition>(name: string): Client<T> | undefined;
55
+ getHealthClient<T extends CompatServiceDefinition>(name: string): Client<typeof HealthDefinition> | undefined;
56
+ isAvailable(moduleName: string): boolean;
57
+ waitForExistence(moduleName: string): Promise<boolean>;
58
+ /**
59
+ * Used to refresh all modules to check for new registrations
60
+ * @param force If true will check for new modules no matter the interval
61
+ */
62
+ refreshModules(force?: boolean): Promise<string | void>;
63
+ get grpcToken(): string | undefined;
64
+ }
65
+ export * from './interfaces';
66
+ export * from './classes';
67
+ export * from './modules';
68
+ export * from './helpers';
69
+ export * from './constants';
70
+ export * from './types';