UNPKG

@aptpod/iscp-ts

Version:

iSCP 2.0 client library for TypeScript

95 lines 2.8 kB
import { UpstreamCloseRequest, UpstreamCloseRequestExtensionFields } from '../../message'; const WIRE_UPSTREAM_CLOSE_REQUEST = new UpstreamCloseRequest({ requestId: 100, streamId: '01020304-0506-4708-890a-111213141516', totalDataPoints: 1234n, finalSequenceNumber: 3000, extensionFields: undefined, }); const PROTO_UPSTREAM_CLOSE_REQUEST = { requestId: 100, streamId: new Uint8Array([ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x47, 0x08, 0x89, 0x0a, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, ]), totalDataPoints: 1234n, finalSequenceNumber: 3000, extensionFields: undefined, }; export const withoutExtensionFields = { toWire: () => { return new UpstreamCloseRequest({ ...WIRE_UPSTREAM_CLOSE_REQUEST, }); }, toProto: () => { return { message: { oneofKind: 'upstreamCloseRequest', upstreamCloseRequest: { ...PROTO_UPSTREAM_CLOSE_REQUEST, }, }, }; }, }; export const withExtensionFields = { toWire: () => { return new UpstreamCloseRequest({ ...WIRE_UPSTREAM_CLOSE_REQUEST, extensionFields: new UpstreamCloseRequestExtensionFields({ closeSession: true, }), }); }, toProto: () => { return { message: { oneofKind: 'upstreamCloseRequest', upstreamCloseRequest: { ...PROTO_UPSTREAM_CLOSE_REQUEST, extensionFields: { closeSession: true, }, }, }, }; }, }; export const invalidWire = { streamId: { toWire: () => { return new UpstreamCloseRequest({ ...WIRE_UPSTREAM_CLOSE_REQUEST, streamId: '00010203', }); }, toErrorClass: () => { return TypeError; }, toError: () => { return new (invalidWire.streamId.toErrorClass())('Invalid UUID'); }, }, }; export const invalidProto = { streamId: { toProto: () => { return { message: { oneofKind: 'upstreamCloseRequest', upstreamCloseRequest: { ...PROTO_UPSTREAM_CLOSE_REQUEST, streamId: new Uint8Array([0x00, 0x01, 0x02, 0x03]), }, }, }; }, toErrorClass: () => { return TypeError; }, toError: () => { return new (invalidProto.streamId.toErrorClass())('Stringified UUID is invalid'); }, }, }; //# sourceMappingURL=upstream-close-request.js.map