@smithy/eventstream-codec 4.2.11 → 4.2.13
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/README.md +13 -0
- package/dist-cjs/index.js +13 -0
- package/package.json +6 -7
- package/dist-types/ts3.4/EventStreamCodec.d.ts +0 -31
- package/dist-types/ts3.4/HeaderMarshaller.d.ts +0 -12
- package/dist-types/ts3.4/Int64.d.ts +0 -20
- package/dist-types/ts3.4/Message.d.ts +0 -26
- package/dist-types/ts3.4/MessageDecoderStream.d.ts +0 -17
- package/dist-types/ts3.4/MessageEncoderStream.d.ts +0 -18
- package/dist-types/ts3.4/SmithyMessageDecoderStream.d.ts +0 -17
- package/dist-types/ts3.4/SmithyMessageEncoderStream.d.ts +0 -17
- package/dist-types/ts3.4/TestVectors.fixture.d.ts +0 -2
- package/dist-types/ts3.4/index.d.ts +0 -8
- package/dist-types/ts3.4/splitMessage.d.ts +0 -11
- package/dist-types/ts3.4/vectorTypes.fixture.d.ts +0 -12
package/README.md
CHANGED
|
@@ -2,3 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@smithy/eventstream-codec)
|
|
4
4
|
[](https://www.npmjs.com/package/@smithy/eventstream-codec)
|
|
5
|
+
|
|
6
|
+
### :warning: Internal API :warning:
|
|
7
|
+
|
|
8
|
+
> This is an internal package.
|
|
9
|
+
> That means this is used as a dependency for other, public packages, but
|
|
10
|
+
> should not be taken directly as a dependency in your application's `package.json`.
|
|
11
|
+
|
|
12
|
+
> If you are updating the version of this package, for example to bring in a
|
|
13
|
+
> bug-fix, you should do so by updating your application lockfile with
|
|
14
|
+
> e.g. `npm up @scope/package` or equivalent command in another
|
|
15
|
+
> package manager, rather than taking a direct dependency.
|
|
16
|
+
|
|
17
|
+
---
|
package/dist-cjs/index.js
CHANGED
|
@@ -206,6 +206,19 @@ class HeaderMarshaller {
|
|
|
206
206
|
return out;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
+
var HEADER_VALUE_TYPE;
|
|
210
|
+
(function (HEADER_VALUE_TYPE) {
|
|
211
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolTrue"] = 0] = "boolTrue";
|
|
212
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolFalse"] = 1] = "boolFalse";
|
|
213
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byte"] = 2] = "byte";
|
|
214
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["short"] = 3] = "short";
|
|
215
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["integer"] = 4] = "integer";
|
|
216
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["long"] = 5] = "long";
|
|
217
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byteArray"] = 6] = "byteArray";
|
|
218
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["string"] = 7] = "string";
|
|
219
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["timestamp"] = 8] = "timestamp";
|
|
220
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["uuid"] = 9] = "uuid";
|
|
221
|
+
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
209
222
|
const BOOLEAN_TAG = "boolean";
|
|
210
223
|
const BYTE_TAG = "byte";
|
|
211
224
|
const SHORT_TAG = "short";
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/eventstream-codec",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.13",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"build": "concurrently 'yarn:build:
|
|
6
|
-
"build:cjs": "node ../../scripts/inline eventstream-codec",
|
|
7
|
-
"build:es": "yarn g:tsc -p tsconfig.es.json",
|
|
5
|
+
"build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
|
|
6
|
+
"build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline eventstream-codec",
|
|
8
7
|
"build:types": "yarn g:tsc -p tsconfig.types.json",
|
|
9
8
|
"build:types:downlevel": "premove dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
|
|
10
|
-
"stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
|
|
11
9
|
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
12
|
-
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
|
|
13
10
|
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
|
|
11
|
+
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
|
|
12
|
+
"stage-release": "premove .release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
|
|
14
13
|
"test": "yarn g:vitest run",
|
|
15
14
|
"test:watch": "yarn g:vitest watch"
|
|
16
15
|
},
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
"sideEffects": false,
|
|
26
25
|
"dependencies": {
|
|
27
26
|
"@aws-crypto/crc32": "5.2.0",
|
|
28
|
-
"@smithy/types": "^4.
|
|
27
|
+
"@smithy/types": "^4.14.0",
|
|
29
28
|
"@smithy/util-hex-encoding": "^4.2.2",
|
|
30
29
|
"tslib": "^2.6.2"
|
|
31
30
|
},
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AvailableMessage, AvailableMessages, Message, MessageDecoder, MessageEncoder, MessageHeaders } from "@smithy/types";
|
|
2
|
-
import { Decoder, Encoder } from "@smithy/types";
|
|
3
|
-
/**
|
|
4
|
-
* A Codec that can convert binary-packed event stream messages into
|
|
5
|
-
* JavaScript objects and back again into their binary format.
|
|
6
|
-
*/
|
|
7
|
-
export declare class EventStreamCodec implements MessageEncoder, MessageDecoder {
|
|
8
|
-
private readonly headerMarshaller;
|
|
9
|
-
private messageBuffer;
|
|
10
|
-
private isEndOfStream;
|
|
11
|
-
constructor(toUtf8: Encoder, fromUtf8: Decoder);
|
|
12
|
-
feed(message: ArrayBufferView): void;
|
|
13
|
-
endOfStream(): void;
|
|
14
|
-
getMessage(): AvailableMessage;
|
|
15
|
-
getAvailableMessages(): AvailableMessages;
|
|
16
|
-
/**
|
|
17
|
-
* Convert a structured JavaScript object with tagged headers into a binary
|
|
18
|
-
* event stream message.
|
|
19
|
-
*/
|
|
20
|
-
encode({ headers: rawHeaders, body }: Message): Uint8Array;
|
|
21
|
-
/**
|
|
22
|
-
* Convert a binary event stream message into a JavaScript object with an
|
|
23
|
-
* opaque, binary body and tagged, parsed headers.
|
|
24
|
-
*/
|
|
25
|
-
decode(message: ArrayBufferView): Message;
|
|
26
|
-
/**
|
|
27
|
-
* Convert a structured JavaScript object with tagged headers into a binary
|
|
28
|
-
* event stream message header.
|
|
29
|
-
*/
|
|
30
|
-
formatHeaders(rawHeaders: MessageHeaders): Uint8Array;
|
|
31
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Decoder, Encoder, MessageHeaders } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare class HeaderMarshaller {
|
|
6
|
-
private readonly toUtf8;
|
|
7
|
-
private readonly fromUtf8;
|
|
8
|
-
constructor(toUtf8: Encoder, fromUtf8: Decoder);
|
|
9
|
-
format(headers: MessageHeaders): Uint8Array;
|
|
10
|
-
private formatHeaderValue;
|
|
11
|
-
parse(headers: DataView): MessageHeaders;
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Int64 as IInt64 } from "@smithy/types";
|
|
2
|
-
export interface Int64 extends IInt64 {
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* A lossless representation of a signed, 64-bit integer. Instances of this
|
|
6
|
-
* class may be used in arithmetic expressions as if they were numeric
|
|
7
|
-
* primitives, but the binary representation will be preserved unchanged as the
|
|
8
|
-
* `bytes` property of the object. The bytes should be encoded as big-endian,
|
|
9
|
-
* two's complement integers.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Int64 {
|
|
12
|
-
readonly bytes: Uint8Array;
|
|
13
|
-
constructor(bytes: Uint8Array);
|
|
14
|
-
static fromNumber(number: number): Int64;
|
|
15
|
-
/**
|
|
16
|
-
* Called implicitly by infix arithmetic operators.
|
|
17
|
-
*/
|
|
18
|
-
valueOf(): number;
|
|
19
|
-
toString(): string;
|
|
20
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Int64 } from "./Int64";
|
|
2
|
-
/**
|
|
3
|
-
* An event stream message. The headers and body properties will always be
|
|
4
|
-
* defined, with empty headers represented as an object with no keys and an
|
|
5
|
-
* empty body represented as a zero-length Uint8Array.
|
|
6
|
-
*/
|
|
7
|
-
export interface Message {
|
|
8
|
-
headers: MessageHeaders;
|
|
9
|
-
body: Uint8Array;
|
|
10
|
-
}
|
|
11
|
-
export type MessageHeaders = Record<string, MessageHeaderValue>;
|
|
12
|
-
type HeaderValue<K extends string, V> = {
|
|
13
|
-
type: K;
|
|
14
|
-
value: V;
|
|
15
|
-
};
|
|
16
|
-
export type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
|
|
17
|
-
export type ByteHeaderValue = HeaderValue<"byte", number>;
|
|
18
|
-
export type ShortHeaderValue = HeaderValue<"short", number>;
|
|
19
|
-
export type IntegerHeaderValue = HeaderValue<"integer", number>;
|
|
20
|
-
export type LongHeaderValue = HeaderValue<"long", Int64>;
|
|
21
|
-
export type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
|
|
22
|
-
export type StringHeaderValue = HeaderValue<"string", string>;
|
|
23
|
-
export type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
|
|
24
|
-
export type UuidHeaderValue = HeaderValue<"uuid", string>;
|
|
25
|
-
export type MessageHeaderValue = BooleanHeaderValue | ByteHeaderValue | ShortHeaderValue | IntegerHeaderValue | LongHeaderValue | BinaryHeaderValue | StringHeaderValue | TimestampHeaderValue | UuidHeaderValue;
|
|
26
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Message, MessageDecoder } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export interface MessageDecoderStreamOptions {
|
|
6
|
-
inputStream: AsyncIterable<Uint8Array>;
|
|
7
|
-
decoder: MessageDecoder;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare class MessageDecoderStream implements AsyncIterable<Message> {
|
|
13
|
-
private readonly options;
|
|
14
|
-
constructor(options: MessageDecoderStreamOptions);
|
|
15
|
-
[Symbol.asyncIterator](): AsyncIterator<Message>;
|
|
16
|
-
private asyncIterator;
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Message, MessageEncoder } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export interface MessageEncoderStreamOptions {
|
|
6
|
-
messageStream: AsyncIterable<Message>;
|
|
7
|
-
encoder: MessageEncoder;
|
|
8
|
-
includeEndFrame?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare class MessageEncoderStream implements AsyncIterable<Uint8Array> {
|
|
14
|
-
private readonly options;
|
|
15
|
-
constructor(options: MessageEncoderStreamOptions);
|
|
16
|
-
[Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
|
|
17
|
-
private asyncIterator;
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Message } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export interface SmithyMessageDecoderStreamOptions<T> {
|
|
6
|
-
readonly messageStream: AsyncIterable<Message>;
|
|
7
|
-
readonly deserializer: (input: Message) => Promise<T | undefined>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare class SmithyMessageDecoderStream<T> implements AsyncIterable<T> {
|
|
13
|
-
private readonly options;
|
|
14
|
-
constructor(options: SmithyMessageDecoderStreamOptions<T>);
|
|
15
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
16
|
-
private asyncIterator;
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Message } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export interface SmithyMessageEncoderStreamOptions<T> {
|
|
6
|
-
inputStream: AsyncIterable<T>;
|
|
7
|
-
serializer: (event: T) => Message;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
12
|
-
export declare class SmithyMessageEncoderStream<T> implements AsyncIterable<Message> {
|
|
13
|
-
private readonly options;
|
|
14
|
-
constructor(options: SmithyMessageEncoderStreamOptions<T>);
|
|
15
|
-
[Symbol.asyncIterator](): AsyncIterator<Message>;
|
|
16
|
-
private asyncIterator;
|
|
17
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from "./EventStreamCodec";
|
|
2
|
-
export * from "./HeaderMarshaller";
|
|
3
|
-
export * from "./Int64";
|
|
4
|
-
export * from "./Message";
|
|
5
|
-
export * from "./MessageDecoderStream";
|
|
6
|
-
export * from "./MessageEncoderStream";
|
|
7
|
-
export * from "./SmithyMessageDecoderStream";
|
|
8
|
-
export * from "./SmithyMessageEncoderStream";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Message } from "./Message";
|
|
2
|
-
export interface NegativeTestVector {
|
|
3
|
-
expectation: "failure";
|
|
4
|
-
encoded: Uint8Array;
|
|
5
|
-
}
|
|
6
|
-
export interface PositiveTestVector {
|
|
7
|
-
expectation: "success";
|
|
8
|
-
encoded: Uint8Array;
|
|
9
|
-
decoded: Message;
|
|
10
|
-
}
|
|
11
|
-
export type TestVector = NegativeTestVector | PositiveTestVector;
|
|
12
|
-
export type TestVectors = Record<string, TestVector>;
|