fix(core): update
This commit is contained in:
parent
2a681644eb
commit
88022ea14b
65
package-lock.json
generated
65
package-lock.json
generated
@ -1384,9 +1384,9 @@
|
|||||||
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw=="
|
"integrity": "sha512-P1xLsuA1+8LQpoWCo2nP2vIQXKGUl5wDWU6CD7xTDZc3uw0He5V/qCPHM5zpIZsS7IuZOxDDpWb7aFveB11tXw=="
|
||||||
},
|
},
|
||||||
"@pushrocks/lik": {
|
"@pushrocks/lik": {
|
||||||
"version": "4.0.14",
|
"version": "4.0.17",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.14.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-4.0.17.tgz",
|
||||||
"integrity": "sha512-S4AMLp+hs1AQ2iCOz5PYReDEfVmfjdf/mf6S5TnAlEhsLU/v3u78xUmMcTPDFotTfuFQr57dGhncHNvljjQ7EQ==",
|
"integrity": "sha512-K5dX3k3i7iVxFMJ+IYwJRljewukJCc2zgj6+88R18/8SajVAq7ITOl3/FTbmEPFCJv5rl/LQ9FtcMynWlwSlzQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
"@pushrocks/smartmatch": "^1.0.7",
|
"@pushrocks/smartmatch": "^1.0.7",
|
||||||
@ -1395,49 +1395,6 @@
|
|||||||
"@pushrocks/smarttime": "^3.0.24",
|
"@pushrocks/smarttime": "^3.0.24",
|
||||||
"@types/minimatch": "^3.0.3",
|
"@types/minimatch": "^3.0.3",
|
||||||
"symbol-tree": "^3.2.4"
|
"symbol-tree": "^3.2.4"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@pushrocks/smartpromise": {
|
|
||||||
"version": "3.0.6",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
|
||||||
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
|
|
||||||
},
|
|
||||||
"@pushrocks/smartrx": {
|
|
||||||
"version": "2.0.18",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.18.tgz",
|
|
||||||
"integrity": "sha512-DqUmtS7mONO6bvWEZmSLy4M9hlxNWysMYc7XOZLr50BMaa0HUNYWI1myUFCMNcbUUOxuQNig01XqR1smfIN69g==",
|
|
||||||
"requires": {
|
|
||||||
"@pushrocks/lik": "^4.0.14",
|
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
|
||||||
"rxjs": "^6.6.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"@pushrocks/smarttime": {
|
|
||||||
"version": "3.0.24",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.24.tgz",
|
|
||||||
"integrity": "sha512-c/n0Y3CUnVNa3TnuXZ5aRc0bWj4RX7+XSjPes1J4HidU1yBOd9UOt6l08W8aPH5jMjT9Ei2jH0GsheaTGoVEYA==",
|
|
||||||
"requires": {
|
|
||||||
"@pushrocks/lik": "^4.0.13",
|
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
|
||||||
"croner": "^1.1.23",
|
|
||||||
"dayjs": "^1.8.29",
|
|
||||||
"is-nan": "^1.3.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dayjs": {
|
|
||||||
"version": "1.8.29",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/dayjs/-/dayjs-1.8.29.tgz",
|
|
||||||
"integrity": "sha512-Vm6teig8ZWK7rH/lxzVGxZJCljPdmUr6q/3f4fr5F0VWNGVkZEjZOQJsAN8hUHUqn+NK4XHNEpJZS1MwLyDcLw=="
|
|
||||||
},
|
|
||||||
"rxjs": {
|
|
||||||
"version": "6.6.0",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.0.tgz",
|
|
||||||
"integrity": "sha512-3HMA8z/Oz61DUHe+SdOiQyzIf4tOx5oQHmMir7IZEu6TMqCLHT4LRcmNaUS0NwOz8VLvmmBduMsoaUvMaIiqzg==",
|
|
||||||
"requires": {
|
|
||||||
"tslib": "^1.9.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartbrowser": {
|
"@pushrocks/smartbrowser": {
|
||||||
@ -1982,10 +1939,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.6",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
||||||
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ==",
|
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@pushrocks/smartpuppeteer": {
|
"@pushrocks/smartpuppeteer": {
|
||||||
"version": "1.0.15",
|
"version": "1.0.15",
|
||||||
@ -2023,7 +1979,6 @@
|
|||||||
"version": "2.0.18",
|
"version": "2.0.18",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.18.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrx/-/smartrx-2.0.18.tgz",
|
||||||
"integrity": "sha512-DqUmtS7mONO6bvWEZmSLy4M9hlxNWysMYc7XOZLr50BMaa0HUNYWI1myUFCMNcbUUOxuQNig01XqR1smfIN69g==",
|
"integrity": "sha512-DqUmtS7mONO6bvWEZmSLy4M9hlxNWysMYc7XOZLr50BMaa0HUNYWI1myUFCMNcbUUOxuQNig01XqR1smfIN69g==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/lik": "^4.0.14",
|
"@pushrocks/lik": "^4.0.14",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
@ -2033,14 +1988,12 @@
|
|||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
"version": "3.0.6",
|
"version": "3.0.6",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
||||||
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==",
|
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"rxjs": {
|
"rxjs": {
|
||||||
"version": "6.6.0",
|
"version": "6.6.0",
|
||||||
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.6.0.tgz",
|
||||||
"integrity": "sha512-3HMA8z/Oz61DUHe+SdOiQyzIf4tOx5oQHmMir7IZEu6TMqCLHT4LRcmNaUS0NwOz8VLvmmBduMsoaUvMaIiqzg==",
|
"integrity": "sha512-3HMA8z/Oz61DUHe+SdOiQyzIf4tOx5oQHmMir7IZEu6TMqCLHT4LRcmNaUS0NwOz8VLvmmBduMsoaUvMaIiqzg==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"tslib": "^1.9.0"
|
"tslib": "^1.9.0"
|
||||||
}
|
}
|
||||||
@ -2078,7 +2031,6 @@
|
|||||||
"version": "3.0.24",
|
"version": "3.0.24",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.24.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.24.tgz",
|
||||||
"integrity": "sha512-c/n0Y3CUnVNa3TnuXZ5aRc0bWj4RX7+XSjPes1J4HidU1yBOd9UOt6l08W8aPH5jMjT9Ei2jH0GsheaTGoVEYA==",
|
"integrity": "sha512-c/n0Y3CUnVNa3TnuXZ5aRc0bWj4RX7+XSjPes1J4HidU1yBOd9UOt6l08W8aPH5jMjT9Ei2jH0GsheaTGoVEYA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/lik": "^4.0.13",
|
"@pushrocks/lik": "^4.0.13",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
@ -4274,8 +4226,7 @@
|
|||||||
"dayjs": {
|
"dayjs": {
|
||||||
"version": "1.8.29",
|
"version": "1.8.29",
|
||||||
"resolved": "https://verdaccio.lossless.one/dayjs/-/dayjs-1.8.29.tgz",
|
"resolved": "https://verdaccio.lossless.one/dayjs/-/dayjs-1.8.29.tgz",
|
||||||
"integrity": "sha512-Vm6teig8ZWK7rH/lxzVGxZJCljPdmUr6q/3f4fr5F0VWNGVkZEjZOQJsAN8hUHUqn+NK4XHNEpJZS1MwLyDcLw==",
|
"integrity": "sha512-Vm6teig8ZWK7rH/lxzVGxZJCljPdmUr6q/3f4fr5F0VWNGVkZEjZOQJsAN8hUHUqn+NK4XHNEpJZS1MwLyDcLw=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"deasync": {
|
"deasync": {
|
||||||
"version": "0.1.20",
|
"version": "0.1.20",
|
||||||
|
@ -25,8 +25,9 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||||
"@pushrocks/isounique": "^1.0.4",
|
"@pushrocks/isounique": "^1.0.4",
|
||||||
"@pushrocks/lik": "^4.0.14",
|
"@pushrocks/lik": "^4.0.17",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.10",
|
||||||
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@pushrocks/webrequest": "^2.0.10"
|
"@pushrocks/webrequest": "^2.0.10"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -2,16 +2,38 @@ import * as plugins from './typedrequest.plugins';
|
|||||||
import { TypedResponseError } from './typedrequest.classes.typedresponseerror';
|
import { TypedResponseError } from './typedrequest.classes.typedresponseerror';
|
||||||
import { TypedRouter } from './typedrequest.classes.typedrouter';
|
import { TypedRouter } from './typedrequest.classes.typedrouter';
|
||||||
|
|
||||||
|
export type IPostMethod = (
|
||||||
|
typedRequestPostObject: plugins.typedRequestInterfaces.ITypedRequest
|
||||||
|
) => void | Promise<plugins.typedRequestInterfaces.ITypedRequest>;
|
||||||
|
|
||||||
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
|
export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest> {
|
||||||
public typedRouterRef: TypedRouter;
|
public typedRouterRef: TypedRouter;
|
||||||
public webrequest = new plugins.webrequest.WebRequest();
|
public webrequest = new plugins.webrequest.WebRequest();
|
||||||
public urlEndPoint: string;
|
|
||||||
|
/**
|
||||||
|
* in case we post against a url endpoint
|
||||||
|
*/
|
||||||
|
public urlEndPoint?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* in case we post with some other method, ec ipc communication
|
||||||
|
*/
|
||||||
|
public postMethod?: IPostMethod;
|
||||||
public method: string;
|
public method: string;
|
||||||
|
|
||||||
// STATIC
|
// STATIC
|
||||||
constructor(urlEndPointArg: string, methodArg: T['method']) {
|
constructor(
|
||||||
this.urlEndPoint = urlEndPointArg;
|
postEndPointArg: string | IPostMethod,
|
||||||
|
methodArg: T['method'],
|
||||||
|
typedrouterRefArg?: TypedRouter
|
||||||
|
) {
|
||||||
|
if (typeof postEndPointArg === 'string') {
|
||||||
|
this.urlEndPoint = postEndPointArg;
|
||||||
|
} else {
|
||||||
|
this.postMethod = postEndPointArg;
|
||||||
|
}
|
||||||
this.method = methodArg;
|
this.method = methodArg;
|
||||||
|
this.typedRouterRef = typedrouterRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,12 +46,34 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
|
|||||||
response: null,
|
response: null,
|
||||||
correlation: {
|
correlation: {
|
||||||
id: plugins.isounique.uni(),
|
id: plugins.isounique.uni(),
|
||||||
phase: 'request'
|
phase: 'request',
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this.webrequest.postJson(this.urlEndPoint, payload);
|
let responseBody: plugins.typedRequestInterfaces.ITypedRequest;
|
||||||
const responseBody: T = response;
|
if (this.urlEndPoint) {
|
||||||
|
const response = await this.webrequest.postJson(this.urlEndPoint, payload);
|
||||||
|
responseBody = response;
|
||||||
|
} else {
|
||||||
|
let responseInterest: plugins.lik.Interest<
|
||||||
|
string,
|
||||||
|
plugins.typedRequestInterfaces.ITypedRequest
|
||||||
|
>;
|
||||||
|
if (this.typedRouterRef) {
|
||||||
|
responseInterest = await this.typedRouterRef.fireEventInterestMap.addInterest(
|
||||||
|
payload.correlation.id,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const postMethodReturnValue = await this.postMethod(payload);
|
||||||
|
if (responseInterest) {
|
||||||
|
responseBody = await responseInterest.interestFullfilled;
|
||||||
|
} else if (postMethodReturnValue) {
|
||||||
|
responseBody = postMethodReturnValue;
|
||||||
|
} else {
|
||||||
|
responseBody = payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (responseBody.error) {
|
if (responseBody.error) {
|
||||||
console.error(
|
console.error(
|
||||||
`Got an error ${responseBody.error.text} with data ${JSON.stringify(
|
`Got an error ${responseBody.error.text} with data ${JSON.stringify(
|
||||||
@ -49,13 +93,4 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
|
|||||||
}
|
}
|
||||||
return responseBody.response;
|
return responseBody.response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public addTypedRouterForResponse(typedRouterArg: TypedRouter) {
|
|
||||||
if (!this.typedRouterRef) {
|
|
||||||
this.typedRouterRef = typedRouterArg;
|
|
||||||
typedRouterArg.addTypedRequest(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public registerAlternateFireMethod() {}
|
|
||||||
}
|
}
|
||||||
|
@ -12,21 +12,15 @@ export class TypedRouter {
|
|||||||
public upstreamTypedRouter: TypedRouter;
|
public upstreamTypedRouter: TypedRouter;
|
||||||
|
|
||||||
public routerMap = new plugins.lik.ObjectMap<TypedRouter>();
|
public routerMap = new plugins.lik.ObjectMap<TypedRouter>();
|
||||||
public typedRequestMap = new plugins.lik.ObjectMap<TypedRequest<any>>();
|
|
||||||
|
|
||||||
public handlerMap = new plugins.lik.ObjectMap<
|
public handlerMap = new plugins.lik.ObjectMap<
|
||||||
TypedHandler<plugins.typedRequestInterfaces.ITypedRequest>
|
TypedHandler<plugins.typedRequestInterfaces.ITypedRequest>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
public fireEventInterestMap = new plugins.lik.InterestMap((correlationId: string) => correlationId);
|
public fireEventInterestMap = new plugins.lik.InterestMap<
|
||||||
|
string,
|
||||||
public addTypedRequest(typedRequestArg: TypedRequest<any>) {
|
plugins.typedRequestInterfaces.ITypedRequest
|
||||||
if(!this.typedRequestMap.checkForObject(typedRequestArg)) {
|
>((correlationId: string) => correlationId);
|
||||||
this.typedRequestMap.add(typedRequestArg);
|
|
||||||
typedRequestArg.addTypedRouterForResponse(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds the handler to the routing map
|
* adds the handler to the routing map
|
||||||
@ -112,7 +106,7 @@ export class TypedRouter {
|
|||||||
|
|
||||||
typedRequestArg = await typedHandler.addResponse(typedRequestArg);
|
typedRequestArg = await typedHandler.addResponse(typedRequestArg);
|
||||||
} else if (typedRequestArg.correlation.phase === 'response') {
|
} else if (typedRequestArg.correlation.phase === 'response') {
|
||||||
|
this.fireEventInterestMap.findInterest(typedRequestArg.correlation.id)?.fullfillInterest(typedRequestArg);
|
||||||
}
|
}
|
||||||
return typedRequestArg;
|
return typedRequestArg;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ export { typedRequestInterfaces };
|
|||||||
import * as isounique from '@pushrocks/isounique';
|
import * as isounique from '@pushrocks/isounique';
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as webrequest from '@pushrocks/webrequest';
|
import * as webrequest from '@pushrocks/webrequest';
|
||||||
|
|
||||||
export { isounique, lik, smartdelay, webrequest };
|
export { isounique, lik, smartdelay, smartpromise, webrequest };
|
||||||
|
Loading…
Reference in New Issue
Block a user