fix(core): update
This commit is contained in:
parent
83b43f501d
commit
1b76e6882f
10
package.json
10
package.json
@ -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
654
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -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'
|
||||
}
|
||||
|
44
ts/typedrequest.classes.streamobject.ts
Normal file
44
ts/typedrequest.classes.streamobject.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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> = (
|
||||
|
@ -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) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './typedrequest.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export class TypedResponseError {
|
||||
public errorText: string;
|
||||
|
@ -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';
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user