@pristine-ts/networking 0.0.225 → 0.0.227
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/package.json +6 -6
- package/dist/lib/cjs/models/cached.router-route.js +0 -33
- package/dist/lib/cjs/models/cached.router-route.js.map +0 -1
- package/dist/lib/cjs/models/router.cache.js +0 -52
- package/dist/lib/cjs/models/router.cache.js.map +0 -1
- package/dist/lib/esm/models/cached.router-route.js +0 -29
- package/dist/lib/esm/models/cached.router-route.js.map +0 -1
- package/dist/lib/esm/models/router.cache.js +0 -49
- package/dist/lib/esm/models/router.cache.js.map +0 -1
- package/dist/types/models/cached.router-route.d.ts +0 -13
- package/dist/types/models/router.cache.d.ts +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pristine-ts/networking",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.227",
|
|
4
4
|
"description": "",
|
|
5
5
|
"module": "dist/lib/esm/networking.module.js",
|
|
6
6
|
"main": "dist/lib/cjs/networking.module.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pristine-ts/common": "^0.0.
|
|
24
|
-
"@pristine-ts/core": "^0.0.
|
|
25
|
-
"@pristine-ts/security": "^0.0.
|
|
26
|
-
"@pristine-ts/telemetry": "^0.0.
|
|
23
|
+
"@pristine-ts/common": "^0.0.227",
|
|
24
|
+
"@pristine-ts/core": "^0.0.227",
|
|
25
|
+
"@pristine-ts/security": "^0.0.227",
|
|
26
|
+
"@pristine-ts/telemetry": "^0.0.227",
|
|
27
27
|
"lodash": "^4.17.21"
|
|
28
28
|
},
|
|
29
29
|
"jest": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"src/*.{js,ts}"
|
|
61
61
|
]
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "a926c2c98ecb07f45ca7554a537f7b0d904a87b8"
|
|
64
64
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CachedRouterRoute = void 0;
|
|
4
|
-
const common_1 = require("@pristine-ts/common");
|
|
5
|
-
class CachedRouterRoute {
|
|
6
|
-
constructor(methodNode) {
|
|
7
|
-
this.methodNode = methodNode;
|
|
8
|
-
this.cachedControllerMethodArguments = {};
|
|
9
|
-
}
|
|
10
|
-
hashRequest(request) {
|
|
11
|
-
return common_1.RequestUtil.hash(request);
|
|
12
|
-
}
|
|
13
|
-
getCachedControllerMethodArguments(request) {
|
|
14
|
-
// Hashed the request
|
|
15
|
-
const hash = this.hashRequest(request);
|
|
16
|
-
if (hash === null) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// Return the arguments if the hashed request exists
|
|
20
|
-
return this.cachedControllerMethodArguments[hash];
|
|
21
|
-
}
|
|
22
|
-
cacheControllerMethodArguments(request, methodArguments) {
|
|
23
|
-
// Hashed the request
|
|
24
|
-
const hash = this.hashRequest(request);
|
|
25
|
-
if (hash === null) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
// Save the method arguments
|
|
29
|
-
this.cachedControllerMethodArguments[hash] = methodArguments;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.CachedRouterRoute = CachedRouterRoute;
|
|
33
|
-
//# sourceMappingURL=cached.router-route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/models/cached.router-route.ts"],"names":[],"mappings":";;;AACA,gDAAyD;AAEzD,MAAa,iBAAiB;IAI1B,YAA4B,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAHhD,oCAA+B,GAAqC,EAAE,CAAC;IAK/E,CAAC;IAEO,WAAW,CAAC,OAAgB;QAChC,OAAO,oBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,kCAAkC,CAAC,OAAgB;QAC/C,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAG,IAAI,KAAK,IAAI,EAAE;YACd,OAAO;SACV;QAED,oDAAoD;QACpD,OAAO,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,8BAA8B,CAAC,OAAgB,EAAE,eAAsB;QACnE,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAG,IAAI,KAAK,IAAI,EAAE;YACd,OAAO;SACV;QAED,4BAA4B;QAC5B,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;IACjE,CAAC;CACJ;AAnCD,8CAmCC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RouterCache = void 0;
|
|
10
|
-
const tsyringe_1 = require("tsyringe");
|
|
11
|
-
const cached_router_route_1 = require("./cached.router-route");
|
|
12
|
-
let RouterCache = class RouterCache {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.currentSize = 0;
|
|
15
|
-
this.maximumSize = 100; // In Bytes
|
|
16
|
-
this.routes = {};
|
|
17
|
-
}
|
|
18
|
-
cleanIfNeeded() {
|
|
19
|
-
if (this.currentSize < this.maximumSize) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
// For now, we will eliminate starting from the first key to the last, when the maximum size is achieved.
|
|
23
|
-
// We will eliminate 25% of the cache whenever we go over the threshold.
|
|
24
|
-
}
|
|
25
|
-
get(keyname) {
|
|
26
|
-
return this.routes[keyname];
|
|
27
|
-
}
|
|
28
|
-
set(keyname, methodNode) {
|
|
29
|
-
const cachedRouterRoute = new cached_router_route_1.CachedRouterRoute(methodNode);
|
|
30
|
-
// todo Calculate the size and add it to the current total
|
|
31
|
-
// Whenever we add a new elemen to the cache, we have to check if the cache needs to be cleaned
|
|
32
|
-
this.cleanIfNeeded();
|
|
33
|
-
this.routes[keyname] = cachedRouterRoute;
|
|
34
|
-
return cachedRouterRoute;
|
|
35
|
-
}
|
|
36
|
-
getCachedControllerMethodArguments(keyname, request) {
|
|
37
|
-
var _a;
|
|
38
|
-
return (_a = this.routes[keyname]) === null || _a === void 0 ? void 0 : _a.getCachedControllerMethodArguments(request);
|
|
39
|
-
}
|
|
40
|
-
setControllerMethodArguments(keyname, request, methodArguments) {
|
|
41
|
-
var _a;
|
|
42
|
-
(_a = this.routes[keyname]) === null || _a === void 0 ? void 0 : _a.cacheControllerMethodArguments(request, methodArguments);
|
|
43
|
-
// todo Increase the size and add it to the current total;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
RouterCache = __decorate([
|
|
48
|
-
(0, tsyringe_1.injectable)(),
|
|
49
|
-
(0, tsyringe_1.singleton)()
|
|
50
|
-
], RouterCache);
|
|
51
|
-
exports.RouterCache = RouterCache;
|
|
52
|
-
//# sourceMappingURL=router.cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.cache.js","sourceRoot":"","sources":["../../../../src/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} from "@pristine-ts/common";
|
|
2
|
-
export class CachedRouterRoute {
|
|
3
|
-
constructor(methodNode) {
|
|
4
|
-
this.methodNode = methodNode;
|
|
5
|
-
this.cachedControllerMethodArguments = {};
|
|
6
|
-
}
|
|
7
|
-
hashRequest(request) {
|
|
8
|
-
return RequestUtil.hash(request);
|
|
9
|
-
}
|
|
10
|
-
getCachedControllerMethodArguments(request) {
|
|
11
|
-
// Hashed the request
|
|
12
|
-
const hash = this.hashRequest(request);
|
|
13
|
-
if (hash === null) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
// Return the arguments if the hashed request exists
|
|
17
|
-
return this.cachedControllerMethodArguments[hash];
|
|
18
|
-
}
|
|
19
|
-
cacheControllerMethodArguments(request, methodArguments) {
|
|
20
|
-
// Hashed the request
|
|
21
|
-
const hash = this.hashRequest(request);
|
|
22
|
-
if (hash === null) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
// Save the method arguments
|
|
26
|
-
this.cachedControllerMethodArguments[hash] = methodArguments;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=cached.router-route.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cached.router-route.js","sourceRoot":"","sources":["../../../../src/models/cached.router-route.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAEzD,MAAM,OAAO,iBAAiB;IAI1B,YAA4B,UAA4B;QAA5B,eAAU,GAAV,UAAU,CAAkB;QAHhD,oCAA+B,GAAqC,EAAE,CAAC;IAK/E,CAAC;IAEO,WAAW,CAAC,OAAgB;QAChC,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,kCAAkC,CAAC,OAAgB;QAC/C,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAG,IAAI,KAAK,IAAI,EAAE;YACd,OAAO;SACV;QAED,oDAAoD;QACpD,OAAO,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,8BAA8B,CAAC,OAAgB,EAAE,eAAsB;QACnE,qBAAqB;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAEvC,IAAG,IAAI,KAAK,IAAI,EAAE;YACd,OAAO;SACV;QAED,4BAA4B;QAC5B,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;IACjE,CAAC;CACJ"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { singleton, injectable } from "tsyringe";
|
|
8
|
-
import { CachedRouterRoute } from "./cached.router-route";
|
|
9
|
-
let RouterCache = class RouterCache {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.currentSize = 0;
|
|
12
|
-
this.maximumSize = 100; // In Bytes
|
|
13
|
-
this.routes = {};
|
|
14
|
-
}
|
|
15
|
-
cleanIfNeeded() {
|
|
16
|
-
if (this.currentSize < this.maximumSize) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// For now, we will eliminate starting from the first key to the last, when the maximum size is achieved.
|
|
20
|
-
// We will eliminate 25% of the cache whenever we go over the threshold.
|
|
21
|
-
}
|
|
22
|
-
get(keyname) {
|
|
23
|
-
return this.routes[keyname];
|
|
24
|
-
}
|
|
25
|
-
set(keyname, methodNode) {
|
|
26
|
-
const cachedRouterRoute = new CachedRouterRoute(methodNode);
|
|
27
|
-
// todo Calculate the size and add it to the current total
|
|
28
|
-
// Whenever we add a new elemen to the cache, we have to check if the cache needs to be cleaned
|
|
29
|
-
this.cleanIfNeeded();
|
|
30
|
-
this.routes[keyname] = cachedRouterRoute;
|
|
31
|
-
return cachedRouterRoute;
|
|
32
|
-
}
|
|
33
|
-
getCachedControllerMethodArguments(keyname, request) {
|
|
34
|
-
var _a;
|
|
35
|
-
return (_a = this.routes[keyname]) === null || _a === void 0 ? void 0 : _a.getCachedControllerMethodArguments(request);
|
|
36
|
-
}
|
|
37
|
-
setControllerMethodArguments(keyname, request, methodArguments) {
|
|
38
|
-
var _a;
|
|
39
|
-
(_a = this.routes[keyname]) === null || _a === void 0 ? void 0 : _a.cacheControllerMethodArguments(request, methodArguments);
|
|
40
|
-
// todo Increase the size and add it to the current total;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
RouterCache = __decorate([
|
|
45
|
-
injectable(),
|
|
46
|
-
singleton()
|
|
47
|
-
], RouterCache);
|
|
48
|
-
export { RouterCache };
|
|
49
|
-
//# sourceMappingURL=router.cache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.cache.js","sourceRoot":"","sources":["../../../../src/models/router.cache.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAKxD,IAAa,WAAW,GAAxB,MAAa,WAAW;IAAxB;QACW,gBAAW,GAAG,CAAC,CAAC;QAEhB,gBAAW,GAAG,GAAG,CAAC,CAAC,WAAW;QAE9B,WAAM,GAAkD,EAAE,CAAC;IAwCtE,CAAC;IAtCW,aAAa;QACjB,IAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE;YACpC,OAAO;SACV;QAED,yGAAyG;QACzG,wEAAwE;IAC5E,CAAC;IAEM,GAAG,CAAC,OAAe;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAEM,GAAG,CAAC,OAAe,EAAE,UAA4B;QACpD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAE5D,0DAA0D;QAE1D,+FAA+F;QAC/F,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC;QAEzC,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAEM,kCAAkC,CAAC,OAAe,EAAE,OAAgB;;QACvE,OAAO,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;IAEM,4BAA4B,CAAC,OAAe,EAAE,OAAgB,EAAE,eAAsB;;QACzF,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,0CAAE,8BAA8B,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAE/E,0DAA0D;QAE1D,OAAO;IACX,CAAC;CAEJ,CAAA;AA7CY,WAAW;IAFvB,UAAU,EAAE;IACZ,SAAS,EAAE;GACC,WAAW,CA6CvB;SA7CY,WAAW"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
2
|
-
import { Request } from "@pristine-ts/common";
|
|
3
|
-
export declare class CachedRouterRoute {
|
|
4
|
-
readonly methodNode: MethodRouterNode;
|
|
5
|
-
private cachedControllerMethodArguments;
|
|
6
|
-
routeParameters?: {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
};
|
|
9
|
-
constructor(methodNode: MethodRouterNode);
|
|
10
|
-
private hashRequest;
|
|
11
|
-
getCachedControllerMethodArguments(request: Request): any[] | undefined;
|
|
12
|
-
cacheControllerMethodArguments(request: Request, methodArguments: any[]): void;
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Request } from "@pristine-ts/common";
|
|
2
|
-
import { CachedRouterRoute } from "./cached.router-route";
|
|
3
|
-
import { MethodRouterNode } from "../nodes/method-router.node";
|
|
4
|
-
export declare class RouterCache {
|
|
5
|
-
currentSize: number;
|
|
6
|
-
maximumSize: number;
|
|
7
|
-
routes: {
|
|
8
|
-
[methodAndPath: string]: CachedRouterRoute;
|
|
9
|
-
};
|
|
10
|
-
private cleanIfNeeded;
|
|
11
|
-
get(keyname: string): CachedRouterRoute;
|
|
12
|
-
set(keyname: string, methodNode: MethodRouterNode): CachedRouterRoute;
|
|
13
|
-
getCachedControllerMethodArguments(keyname: string, request: Request): any[] | undefined;
|
|
14
|
-
setControllerMethodArguments(keyname: string, request: Request, methodArguments: any[]): void;
|
|
15
|
-
}
|