@conduitplatform/module-tools 0.16.0-alpha.10

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 (91) hide show
  1. package/README.mdx +18 -0
  2. package/dist/ManagedModule.d.ts +79 -0
  3. package/dist/ManagedModule.js +433 -0
  4. package/dist/ManagedModule.js.map +1 -0
  5. package/dist/classes/ConduitActiveSchema.d.ts +16 -0
  6. package/dist/classes/ConduitActiveSchema.js +57 -0
  7. package/dist/classes/ConduitActiveSchema.js.map +1 -0
  8. package/dist/classes/ConduitServiceModule.d.ts +26 -0
  9. package/dist/classes/ConduitServiceModule.js +184 -0
  10. package/dist/classes/ConduitServiceModule.js.map +1 -0
  11. package/dist/classes/ConfigController.d.ts +7 -0
  12. package/dist/classes/ConfigController.js +27 -0
  13. package/dist/classes/ConfigController.js.map +1 -0
  14. package/dist/classes/GrpcServer.d.ts +23 -0
  15. package/dist/classes/GrpcServer.js +222 -0
  16. package/dist/classes/GrpcServer.js.map +1 -0
  17. package/dist/classes/index.d.ts +4 -0
  18. package/dist/classes/index.js +21 -0
  19. package/dist/classes/index.js.map +1 -0
  20. package/dist/grpc_health_check.proto +21 -0
  21. package/dist/helpers/GrpcHelper.d.ts +8 -0
  22. package/dist/helpers/GrpcHelper.js +43 -0
  23. package/dist/helpers/GrpcHelper.js.map +1 -0
  24. package/dist/helpers/TypeHelpers.d.ts +70 -0
  25. package/dist/helpers/TypeHelpers.js +144 -0
  26. package/dist/helpers/TypeHelpers.js.map +1 -0
  27. package/dist/helpers/index.d.ts +3 -0
  28. package/dist/helpers/index.js +20 -0
  29. package/dist/helpers/index.js.map +1 -0
  30. package/dist/helpers/wrapGrpcFunctions.d.ts +5 -0
  31. package/dist/helpers/wrapGrpcFunctions.js +56 -0
  32. package/dist/helpers/wrapGrpcFunctions.js.map +1 -0
  33. package/dist/index.d.ts +6 -0
  34. package/dist/index.js +23 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/interfaces/ConduitService.d.ts +8 -0
  37. package/dist/interfaces/ConduitService.js +3 -0
  38. package/dist/interfaces/ConduitService.js.map +1 -0
  39. package/dist/interfaces/index.d.ts +1 -0
  40. package/dist/interfaces/index.js +18 -0
  41. package/dist/interfaces/index.js.map +1 -0
  42. package/dist/logging/index.d.ts +16 -0
  43. package/dist/logging/index.js +255 -0
  44. package/dist/logging/index.js.map +1 -0
  45. package/dist/metrics/MetricsServer.d.ts +10 -0
  46. package/dist/metrics/MetricsServer.js +94 -0
  47. package/dist/metrics/MetricsServer.js.map +1 -0
  48. package/dist/metrics/clientMiddleware.d.ts +2 -0
  49. package/dist/metrics/clientMiddleware.js +273 -0
  50. package/dist/metrics/clientMiddleware.js.map +1 -0
  51. package/dist/metrics/config/defaults.d.ts +91 -0
  52. package/dist/metrics/config/defaults.js +93 -0
  53. package/dist/metrics/config/defaults.js.map +1 -0
  54. package/dist/metrics/index.d.ts +22 -0
  55. package/dist/metrics/index.js +152 -0
  56. package/dist/metrics/index.js.map +1 -0
  57. package/dist/module.proto +14 -0
  58. package/dist/routing/ProxyRouteBuilder.d.ts +21 -0
  59. package/dist/routing/ProxyRouteBuilder.js +81 -0
  60. package/dist/routing/ProxyRouteBuilder.js.map +1 -0
  61. package/dist/routing/RouteBuilder.d.ts +23 -0
  62. package/dist/routing/RouteBuilder.js +107 -0
  63. package/dist/routing/RouteBuilder.js.map +1 -0
  64. package/dist/routing/RoutingManager.d.ts +32 -0
  65. package/dist/routing/RoutingManager.js +201 -0
  66. package/dist/routing/RoutingManager.js.map +1 -0
  67. package/dist/routing/RoutingUtilities.d.ts +7 -0
  68. package/dist/routing/RoutingUtilities.js +13 -0
  69. package/dist/routing/RoutingUtilities.js.map +1 -0
  70. package/dist/routing/index.d.ts +5 -0
  71. package/dist/routing/index.js +22 -0
  72. package/dist/routing/index.js.map +1 -0
  73. package/dist/routing/wrapRouterFunctions.d.ts +7 -0
  74. package/dist/routing/wrapRouterFunctions.js +136 -0
  75. package/dist/routing/wrapRouterFunctions.js.map +1 -0
  76. package/dist/utilities/convictConfigParser.d.ts +2 -0
  77. package/dist/utilities/convictConfigParser.js +18 -0
  78. package/dist/utilities/convictConfigParser.js.map +1 -0
  79. package/dist/utilities/index.d.ts +3 -0
  80. package/dist/utilities/index.js +20 -0
  81. package/dist/utilities/index.js.map +1 -0
  82. package/dist/utilities/initializeSdk.d.ts +2 -0
  83. package/dist/utilities/initializeSdk.js +64 -0
  84. package/dist/utilities/initializeSdk.js.map +1 -0
  85. package/dist/utilities/linearBackoffTimeout.d.ts +9 -0
  86. package/dist/utilities/linearBackoffTimeout.js +119 -0
  87. package/dist/utilities/linearBackoffTimeout.js.map +1 -0
  88. package/dist/utilities/merge.d.ts +1 -0
  89. package/dist/utilities/merge.js +15 -0
  90. package/dist/utilities/merge.js.map +1 -0
  91. package/package.json +58 -0
@@ -0,0 +1,119 @@
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.linearBackoffTimeoutAsync = exports.linearBackoffTimeout = void 0;
40
+ /**
41
+ * Registers a timeout with linear backoff.
42
+ * onFailure() only runs on rep exhaustion.
43
+ * Timeout can be cleared through returned clear() or inside onTry().
44
+ */
45
+ var timers_1 = require("timers");
46
+ function linearBackoffTimeout(onTry, delay, reps, onFailure) {
47
+ var _this = this;
48
+ var nextRep = function () { return reps === undefined || --reps > 0; };
49
+ var timeout;
50
+ var invoker = function () { return __awaiter(_this, void 0, void 0, function () {
51
+ return __generator(this, function (_a) {
52
+ delay = Math.floor(delay * 2);
53
+ if (delay > 0 && nextRep()) {
54
+ timeout = setTimeout(invoker, delay);
55
+ onTry(timeout);
56
+ }
57
+ else {
58
+ timeout = null;
59
+ onFailure && onFailure();
60
+ }
61
+ return [2 /*return*/];
62
+ });
63
+ }); };
64
+ timeout = setTimeout(invoker, delay);
65
+ return {
66
+ clear: function () {
67
+ if (timeout) {
68
+ (0, timers_1.clearTimeout)(timeout);
69
+ timeout = null;
70
+ }
71
+ },
72
+ };
73
+ }
74
+ exports.linearBackoffTimeout = linearBackoffTimeout;
75
+ /**
76
+ * Registers a timeout with linear backoff.
77
+ * onFailure() only runs on rep exhaustion.
78
+ * @param {() => Promise<boolean>} onTry - Async handler, returns 'continue' boolean flag
79
+ */
80
+ function linearBackoffTimeoutAsync(onTry, delay, reps, onFailure, startNow) {
81
+ if (startNow === void 0) { startNow = false; }
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var nextRep, invoker;
84
+ var _this = this;
85
+ return __generator(this, function (_a) {
86
+ nextRep = function () { return reps === undefined || --reps > 0; };
87
+ invoker = function () { return __awaiter(_this, void 0, void 0, function () {
88
+ var _a;
89
+ return __generator(this, function (_b) {
90
+ switch (_b.label) {
91
+ case 0:
92
+ delay = Math.floor(delay * 2);
93
+ if (!(delay > 0 && nextRep())) return [3 /*break*/, 2];
94
+ return [4 /*yield*/, onTry()];
95
+ case 1:
96
+ if (_b.sent())
97
+ setTimeout(invoker, delay);
98
+ return [3 /*break*/, 5];
99
+ case 2:
100
+ _a = onFailure;
101
+ if (!_a) return [3 /*break*/, 4];
102
+ return [4 /*yield*/, onFailure()];
103
+ case 3:
104
+ _a = (_b.sent());
105
+ _b.label = 4;
106
+ case 4:
107
+ _a;
108
+ _b.label = 5;
109
+ case 5: return [2 /*return*/];
110
+ }
111
+ });
112
+ }); };
113
+ setTimeout(invoker, startNow ? 0 : delay);
114
+ return [2 /*return*/];
115
+ });
116
+ });
117
+ }
118
+ exports.linearBackoffTimeoutAsync = linearBackoffTimeoutAsync;
119
+ //# sourceMappingURL=linearBackoffTimeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linearBackoffTimeout.js","sourceRoot":"","sources":["../../src/utilities/linearBackoffTimeout.ts"],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AAA,KAAK,GAAG,CAAC,IAAI,OAAO,EAAE,CAAA,EAAtB,wBAAsB;4BACpB,qBAAM,KAAK,EAAE,EAAA;;4BAAjB,IAAI,SAAa;gCAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;;;4BAE9C,KAAA,SAAS,CAAA;qCAAT,wBAAS;4BAAK,qBAAM,SAAS,EAAE,EAAA;;4BAAlB,KAAA,CAAC,SAAiB,CAAC,CAAA;;;4BAAhC,GAAiC;;;;;iBAEpC,CAAC;YACF,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;;;;CAC3C;AAjBD,8DAiBC"}
@@ -0,0 +1 @@
1
+ export declare function merge<T extends object>(objA: T, objB: T): {} & T;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge = void 0;
4
+ var lodash_1 = require("lodash");
5
+ function merge(objA, objB) {
6
+ var customizer = function (objValue, srcValue) {
7
+ if (Array.isArray(objValue)) {
8
+ // don't merge arrays
9
+ return srcValue;
10
+ }
11
+ };
12
+ return (0, lodash_1.mergeWith)({}, objA, objB, customizer);
13
+ }
14
+ exports.merge = merge;
15
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/utilities/merge.ts"],"names":[],"mappings":";;;AAAA,iCAAiD;AAEjD,SAAgB,KAAK,CAAmB,IAAO,EAAE,IAAO;IACtD,IAAM,UAAU,GAAG,UAAC,QAAiB,EAAE,QAAiB;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,qBAAqB;YACrB,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC,CAAC;IACF,OAAO,IAAA,kBAAU,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC;AARD,sBAQC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@conduitplatform/module-tools",
3
+ "version": "0.16.0-alpha.10",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "engines": {
7
+ "node": ">=14"
8
+ },
9
+ "scripts": {
10
+ "prepublish": "npm run build",
11
+ "build": "rimraf dist && tsc",
12
+ "postbuild": "copyfiles -u 1 src/*.proto src/**/*.json ./dist/"
13
+ },
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "@grpc/grpc-js": "^1.8.13",
17
+ "@grpc/proto-loader": "^0.7.6",
18
+ "abort-controller-x": "^0.4.1",
19
+ "convict": "^6.2.4",
20
+ "express": "^4.18.2",
21
+ "fast-jwt": "^2.2.1",
22
+ "lodash": "^4.17.21",
23
+ "prom-client": "^14.2.0",
24
+ "protobufjs": "^7.2.3",
25
+ "winston": "^3.8.2",
26
+ "winston-loki": "^6.0.6"
27
+ },
28
+ "directories": {
29
+ "lib": "dist",
30
+ "src": "src"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "ssh://git@github.com/ConduitPlatform/conduit.git",
38
+ "directory": "libraries/module-tools"
39
+ },
40
+ "devDependencies": {
41
+ "@conduitplatform/grpc-sdk": "*",
42
+ "@types/convict": "^6.1.1",
43
+ "@types/express": "^4.17.17",
44
+ "@types/fs-extra": "^11.0.1",
45
+ "@types/google-protobuf": "^3.15.6",
46
+ "@types/ioredis": "^4.28.10",
47
+ "@types/lodash": "^4.14.192",
48
+ "@types/node": "18.15.11",
49
+ "copyfiles": "^2.4.1",
50
+ "rimraf": "^5.0.0",
51
+ "ts-proto": "^1.146.0",
52
+ "typescript": "~5.0.4"
53
+ },
54
+ "peerDependencies": {
55
+ "@conduitplatform/grpc-sdk": "*",
56
+ "@grpc/grpc-js": "^1.5.2"
57
+ }
58
+ }