fix(core): update

This commit is contained in:
Philipp Kunz 2024-02-20 17:40:30 +01:00
parent 83b43f501d
commit 1b76e6882f
10 changed files with 412 additions and 313 deletions

View File

@ -14,14 +14,14 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@api.global/typedserver": "^3.0.9",
"@git.zone/tsbuild": "^2.1.66",
"@git.zone/tsbundle": "^2.0.8",
"@api.global/typedserver": "^3.0.20",
"@git.zone/tsbuild": "^2.1.72",
"@git.zone/tsbundle": "^2.0.15",
"@git.zone/tsrun": "^1.2.44",
"@git.zone/tstest": "^1.0.84",
"@git.zone/tstest": "^1.0.86",
"@push.rocks/smartenv": "^5.0.12",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.10.3"
"@types/node": "^20.11.19"
},
"dependencies": {
"@api.global/typedrequest-interfaces": "^3.0.1",

654
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedrequest',
version: '3.0.4',
version: '3.0.5',
description: 'make typed requests towards apis'
}

View File

@ -0,0 +1,44 @@
import * as plugins from './plugins.js';
export class VirtualStream {
public streamId: string = plugins.isounique.uni();
constructor() {}
public static encodePayloadForNetwork(objectPayload: any): any {
if (objectPayload instanceof VirtualStream) {
return {
_isVirtualStream: true,
streamId: objectPayload.streamId,
};
} else if (Array.isArray(objectPayload)) {
return objectPayload.map(VirtualStream.encodePayloadForNetwork);
} else if (objectPayload !== null && typeof objectPayload === 'object') {
return Object.keys(objectPayload).reduce((acc, key) => {
acc[key] = VirtualStream.encodePayloadForNetwork(objectPayload[key]);
return acc;
}, {});
} else {
return objectPayload;
}
}
public static decodePayloadFromNetwork(objectPayload: any): any {
if (objectPayload !== null && typeof objectPayload === 'object') {
if (objectPayload._isVirtualStream) {
const virtualStream = new VirtualStream();
virtualStream.streamId = objectPayload.streamId;
return virtualStream;
} else if (Array.isArray(objectPayload)) {
return objectPayload.map(VirtualStream.decodePayloadFromNetwork);
} else {
return Object.keys(objectPayload).reduce((acc, key) => {
acc[key] = VirtualStream.decodePayloadFromNetwork(objectPayload[key]);
return acc;
}, {});
}
} else {
return objectPayload;
}
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './typedrequest.plugins.js';
import * as plugins from './plugins.js';
import { TypedResponseError } from './typedrequest.classes.typedresponseerror.js';
export type THandlerFunction<T extends plugins.typedRequestInterfaces.ITypedRequest> = (

View File

@ -1,4 +1,4 @@
import * as plugins from './typedrequest.plugins.js';
import * as plugins from './plugins.js';
import { TypedResponseError } from './typedrequest.classes.typedresponseerror.js';
import { TypedRouter } from './typedrequest.classes.typedrouter.js';
import { TypedTarget } from './typedrequest.classes.typedtarget.js';
@ -36,7 +36,8 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
* fires the request
*/
public async fire(fireArg: T['request'], useCacheArg: boolean = false): Promise<T['response']> {
const payload: plugins.typedRequestInterfaces.ITypedRequest = {
let payload: plugins.typedRequestInterfaces.ITypedRequest = {
method: this.method,
request: fireArg,
response: null,
@ -56,7 +57,7 @@ export class TypedRequest<T extends plugins.typedRequestInterfaces.ITypedRequest
if (responseBody.error) {
console.error(
`Got an error ${responseBody.error.text} with data ${JSON.stringify(
responseBody.error.data
responseBody.error.data, null, 2
)}`
);
if (!responseBody.retry) {

View File

@ -1,4 +1,4 @@
import * as plugins from './typedrequest.plugins.js';
import * as plugins from './plugins.js';
export class TypedResponseError {
public errorText: string;

View File

@ -1,4 +1,4 @@
import * as plugins from './typedrequest.plugins.js';
import * as plugins from './plugins.js';
import { TypedHandler } from './typedrequest.classes.typedhandler.js';
import { TypedRequest } from './typedrequest.classes.typedrequest.js';

View File

@ -1,5 +1,5 @@
import { TypedRouter } from './typedrequest.classes.typedrouter.js';
import * as plugins from './typedrequest.plugins.js';
import * as plugins from './plugins.js';
export type IPostMethod = (
typedRequestPostObject: plugins.typedRequestInterfaces.ITypedRequest