@sachitv/avro-typescript 0.4.0
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/esm/_dnt.polyfills.d.ts +11 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/avro_reader.d.ts +156 -0
- package/esm/avro_reader.js +201 -0
- package/esm/avro_writer.d.ts +75 -0
- package/esm/avro_writer.js +105 -0
- package/esm/internal/collections/array_utils.d.ts +4 -0
- package/esm/internal/collections/array_utils.js +18 -0
- package/esm/internal/collections/circular_buffer.d.ts +48 -0
- package/esm/internal/collections/circular_buffer.js +129 -0
- package/esm/internal/crypto/md5.d.ts +12 -0
- package/esm/internal/crypto/md5.js +158 -0
- package/esm/internal/varint.d.ts +6 -0
- package/esm/internal/varint.js +30 -0
- package/esm/mod.d.ts +77 -0
- package/esm/mod.js +73 -0
- package/esm/package.json +3 -0
- package/esm/rpc/definitions/message_definition.d.ts +34 -0
- package/esm/rpc/definitions/message_definition.js +105 -0
- package/esm/rpc/definitions/protocol_definitions.d.ts +197 -0
- package/esm/rpc/definitions/protocol_definitions.js +1 -0
- package/esm/rpc/message_endpoint/base.d.ts +43 -0
- package/esm/rpc/message_endpoint/base.js +81 -0
- package/esm/rpc/message_endpoint/emitter.d.ts +96 -0
- package/esm/rpc/message_endpoint/emitter.js +245 -0
- package/esm/rpc/message_endpoint/helpers.d.ts +37 -0
- package/esm/rpc/message_endpoint/helpers.js +68 -0
- package/esm/rpc/message_endpoint/listener.d.ts +37 -0
- package/esm/rpc/message_endpoint/listener.js +212 -0
- package/esm/rpc/protocol/frame_assembler.d.ts +11 -0
- package/esm/rpc/protocol/frame_assembler.js +77 -0
- package/esm/rpc/protocol/protocol_helpers.d.ts +59 -0
- package/esm/rpc/protocol/protocol_helpers.js +123 -0
- package/esm/rpc/protocol/transports/fetch.d.ts +9 -0
- package/esm/rpc/protocol/transports/fetch.js +30 -0
- package/esm/rpc/protocol/transports/in_memory.d.ts +27 -0
- package/esm/rpc/protocol/transports/in_memory.js +125 -0
- package/esm/rpc/protocol/transports/transport_helpers.d.ts +118 -0
- package/esm/rpc/protocol/transports/transport_helpers.js +112 -0
- package/esm/rpc/protocol/transports/websocket.d.ts +9 -0
- package/esm/rpc/protocol/transports/websocket.js +102 -0
- package/esm/rpc/protocol/wire_format/framing.d.ts +44 -0
- package/esm/rpc/protocol/wire_format/framing.js +74 -0
- package/esm/rpc/protocol/wire_format/handshake.d.ts +110 -0
- package/esm/rpc/protocol/wire_format/handshake.js +239 -0
- package/esm/rpc/protocol/wire_format/messages.d.ts +192 -0
- package/esm/rpc/protocol/wire_format/messages.js +175 -0
- package/esm/rpc/protocol/wire_format/metadata.d.ts +44 -0
- package/esm/rpc/protocol/wire_format/metadata.js +74 -0
- package/esm/rpc/protocol_core.d.ts +121 -0
- package/esm/rpc/protocol_core.js +285 -0
- package/esm/schemas/base_type.d.ts +41 -0
- package/esm/schemas/base_type.js +49 -0
- package/esm/schemas/complex/array_type.d.ts +100 -0
- package/esm/schemas/complex/array_type.js +299 -0
- package/esm/schemas/complex/enum_type.d.ts +81 -0
- package/esm/schemas/complex/enum_type.js +217 -0
- package/esm/schemas/complex/fixed_type.d.ts +99 -0
- package/esm/schemas/complex/fixed_type.js +208 -0
- package/esm/schemas/complex/map_type.d.ts +97 -0
- package/esm/schemas/complex/map_type.js +290 -0
- package/esm/schemas/complex/named_type.d.ts +30 -0
- package/esm/schemas/complex/named_type.js +57 -0
- package/esm/schemas/complex/record_type.d.ts +165 -0
- package/esm/schemas/complex/record_type.js +547 -0
- package/esm/schemas/complex/resolve_names.d.ts +32 -0
- package/esm/schemas/complex/resolve_names.js +85 -0
- package/esm/schemas/complex/union_type.d.ts +116 -0
- package/esm/schemas/complex/union_type.js +392 -0
- package/esm/schemas/error.d.ts +31 -0
- package/esm/schemas/error.js +67 -0
- package/esm/schemas/json.d.ts +6 -0
- package/esm/schemas/json.js +35 -0
- package/esm/schemas/logical/decimal_logical_type.d.ts +49 -0
- package/esm/schemas/logical/decimal_logical_type.js +145 -0
- package/esm/schemas/logical/duration_logical_type.d.ts +66 -0
- package/esm/schemas/logical/duration_logical_type.js +112 -0
- package/esm/schemas/logical/logical_type.d.ts +138 -0
- package/esm/schemas/logical/logical_type.js +240 -0
- package/esm/schemas/logical/temporal_logical_types.d.ts +215 -0
- package/esm/schemas/logical/temporal_logical_types.js +364 -0
- package/esm/schemas/logical/uuid_logical_type.d.ts +63 -0
- package/esm/schemas/logical/uuid_logical_type.js +146 -0
- package/esm/schemas/primitive/boolean_type.d.ts +49 -0
- package/esm/schemas/primitive/boolean_type.js +75 -0
- package/esm/schemas/primitive/bytes_type.d.ts +49 -0
- package/esm/schemas/primitive/bytes_type.js +136 -0
- package/esm/schemas/primitive/double_type.d.ts +38 -0
- package/esm/schemas/primitive/double_type.js +98 -0
- package/esm/schemas/primitive/fixed_size_base_type.d.ts +28 -0
- package/esm/schemas/primitive/fixed_size_base_type.js +33 -0
- package/esm/schemas/primitive/float_type.d.ts +38 -0
- package/esm/schemas/primitive/float_type.js +88 -0
- package/esm/schemas/primitive/int_type.d.ts +31 -0
- package/esm/schemas/primitive/int_type.js +63 -0
- package/esm/schemas/primitive/long_type.d.ts +36 -0
- package/esm/schemas/primitive/long_type.js +95 -0
- package/esm/schemas/primitive/null_type.d.ts +45 -0
- package/esm/schemas/primitive/null_type.js +71 -0
- package/esm/schemas/primitive/primitive_type.d.ts +17 -0
- package/esm/schemas/primitive/primitive_type.js +27 -0
- package/esm/schemas/primitive/string_type.d.ts +34 -0
- package/esm/schemas/primitive/string_type.js +81 -0
- package/esm/schemas/resolver.d.ts +25 -0
- package/esm/schemas/resolver.js +25 -0
- package/esm/schemas/type.d.ts +101 -0
- package/esm/schemas/type.js +6 -0
- package/esm/serialization/avro_constants.d.ts +13 -0
- package/esm/serialization/avro_constants.js +29 -0
- package/esm/serialization/avro_file_parser.d.ts +68 -0
- package/esm/serialization/avro_file_parser.js +191 -0
- package/esm/serialization/avro_file_writer.d.ts +63 -0
- package/esm/serialization/avro_file_writer.js +235 -0
- package/esm/serialization/buffers/blob_readable_buffer.d.ts +53 -0
- package/esm/serialization/buffers/blob_readable_buffer.js +80 -0
- package/esm/serialization/buffers/buffer.d.ts +37 -0
- package/esm/serialization/buffers/buffer.js +1 -0
- package/esm/serialization/buffers/in_memory_buffer.d.ts +121 -0
- package/esm/serialization/buffers/in_memory_buffer.js +206 -0
- package/esm/serialization/clamp.d.ts +10 -0
- package/esm/serialization/clamp.js +19 -0
- package/esm/serialization/compare_bytes.d.ts +9 -0
- package/esm/serialization/compare_bytes.js +45 -0
- package/esm/serialization/conversion.d.ts +8 -0
- package/esm/serialization/conversion.js +15 -0
- package/esm/serialization/decoders/decoder.d.ts +16 -0
- package/esm/serialization/decoders/decoder.js +1 -0
- package/esm/serialization/decoders/deflate_decoder.d.ts +15 -0
- package/esm/serialization/decoders/deflate_decoder.js +26 -0
- package/esm/serialization/decoders/null_decoder.d.ts +12 -0
- package/esm/serialization/decoders/null_decoder.js +13 -0
- package/esm/serialization/encoders/deflate_encoder.d.ts +15 -0
- package/esm/serialization/encoders/deflate_encoder.js +26 -0
- package/esm/serialization/encoders/encoder.d.ts +16 -0
- package/esm/serialization/encoders/encoder.js +1 -0
- package/esm/serialization/encoders/null_encoder.d.ts +12 -0
- package/esm/serialization/encoders/null_encoder.js +13 -0
- package/esm/serialization/manipulate_bytes.d.ts +6 -0
- package/esm/serialization/manipulate_bytes.js +13 -0
- package/esm/serialization/read_uint_le.d.ts +4 -0
- package/esm/serialization/read_uint_le.js +14 -0
- package/esm/serialization/streams/fixed_size_stream_readable_buffer_adapter.d.ts +52 -0
- package/esm/serialization/streams/fixed_size_stream_readable_buffer_adapter.js +129 -0
- package/esm/serialization/streams/forward_only_stream_readable_buffer_adapter.d.ts +36 -0
- package/esm/serialization/streams/forward_only_stream_readable_buffer_adapter.js +114 -0
- package/esm/serialization/streams/stream_readable_buffer.d.ts +41 -0
- package/esm/serialization/streams/stream_readable_buffer.js +64 -0
- package/esm/serialization/streams/stream_readable_buffer_adapter.d.ts +38 -0
- package/esm/serialization/streams/stream_readable_buffer_adapter.js +105 -0
- package/esm/serialization/streams/stream_writable_buffer.d.ts +42 -0
- package/esm/serialization/streams/stream_writable_buffer.js +64 -0
- package/esm/serialization/streams/stream_writable_buffer_adapter.d.ts +36 -0
- package/esm/serialization/streams/stream_writable_buffer_adapter.js +65 -0
- package/esm/serialization/streams/streams.d.ts +29 -0
- package/esm/serialization/streams/streams.js +1 -0
- package/esm/serialization/tap.d.ts +427 -0
- package/esm/serialization/tap.js +605 -0
- package/esm/serialization/text_encoding.d.ts +12 -0
- package/esm/serialization/text_encoding.js +14 -0
- package/esm/type/create_type.d.ts +54 -0
- package/esm/type/create_type.js +401 -0
- package/package.json +33 -0
- package/sachitv-avro-typescript-0.4.0.tgz +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { ReadableTapLike, WritableTapLike } from "../../serialization/tap.js";
|
|
2
|
+
import { NamedType } from "./named_type.js";
|
|
3
|
+
import { Resolver } from "../resolver.js";
|
|
4
|
+
import { type JSONType, Type } from "../type.js";
|
|
5
|
+
import { type ErrorHook } from "../error.js";
|
|
6
|
+
import { type ResolvedNames } from "./resolve_names.js";
|
|
7
|
+
/**
|
|
8
|
+
* Specifies the sort order for record fields.
|
|
9
|
+
*/
|
|
10
|
+
export type RecordFieldOrder = "ascending" | "descending" | "ignore";
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for defining a record field.
|
|
13
|
+
*/
|
|
14
|
+
export interface RecordFieldParams {
|
|
15
|
+
/** The name of the field. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** The type of the field. */
|
|
18
|
+
type: Type;
|
|
19
|
+
/** Optional aliases for the field. */
|
|
20
|
+
aliases?: string[];
|
|
21
|
+
/** Optional ordering for the field. */
|
|
22
|
+
order?: RecordFieldOrder;
|
|
23
|
+
/** Optional default value for the field. */
|
|
24
|
+
default?: unknown;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parameters for creating a RecordType.
|
|
28
|
+
*/
|
|
29
|
+
export interface RecordTypeParams extends ResolvedNames {
|
|
30
|
+
/**
|
|
31
|
+
* Fields can be provided eagerly as an array or lazily via a thunk (a
|
|
32
|
+
* parameterless function returning the array). The lazy form lets schema
|
|
33
|
+
* factories register the record under its name before constructing field
|
|
34
|
+
* types, enabling recursive references to the record.
|
|
35
|
+
*/
|
|
36
|
+
fields: RecordFieldParams[] | (() => RecordFieldParams[]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Represents a field in an Avro record type.
|
|
40
|
+
*/
|
|
41
|
+
export declare class RecordField {
|
|
42
|
+
#private;
|
|
43
|
+
/**
|
|
44
|
+
* Constructs a new RecordField instance.
|
|
45
|
+
*/
|
|
46
|
+
constructor(params: RecordFieldParams);
|
|
47
|
+
/**
|
|
48
|
+
* Gets the name of the field.
|
|
49
|
+
*/
|
|
50
|
+
getName(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the type of the field.
|
|
53
|
+
*/
|
|
54
|
+
getType(): Type;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the aliases of the field.
|
|
57
|
+
*/
|
|
58
|
+
getAliases(): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Gets the order of the field.
|
|
61
|
+
*/
|
|
62
|
+
getOrder(): RecordFieldOrder;
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the field has a default value.
|
|
65
|
+
*/
|
|
66
|
+
hasDefault(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Gets the default value for the field.
|
|
69
|
+
* @returns The default value.
|
|
70
|
+
* @throws Error if the field has no default.
|
|
71
|
+
*/
|
|
72
|
+
getDefault(): unknown;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if the given name matches the field name or any of its aliases.
|
|
75
|
+
* @param name The name to check.
|
|
76
|
+
* @returns True if the name matches, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
nameMatches(name: string): boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Avro `record` type supporting ordered fields, aliases, and schema evolution.
|
|
82
|
+
*/
|
|
83
|
+
export declare class RecordType extends NamedType<Record<string, unknown>> {
|
|
84
|
+
#private;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a new RecordType.
|
|
87
|
+
* @param params The record type parameters.
|
|
88
|
+
*/
|
|
89
|
+
constructor(params: RecordTypeParams);
|
|
90
|
+
/**
|
|
91
|
+
* Gets the fields of the record.
|
|
92
|
+
*/
|
|
93
|
+
getFields(): ReadonlyArray<RecordField>;
|
|
94
|
+
/**
|
|
95
|
+
* Gets a specific field by name.
|
|
96
|
+
*/
|
|
97
|
+
getField(name: string): RecordField | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if the given value conforms to this record type.
|
|
100
|
+
* @param value The value to check.
|
|
101
|
+
* @param errorHook Optional error hook for validation errors.
|
|
102
|
+
* @param path The current path in the schema for error reporting.
|
|
103
|
+
* @returns True if the value is valid, false otherwise.
|
|
104
|
+
*/
|
|
105
|
+
check(value: unknown, errorHook?: ErrorHook, path?: string[]): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Writes the given record value to the tap.
|
|
108
|
+
* @param tap The writable tap to write to.
|
|
109
|
+
* @param value The record value to write.
|
|
110
|
+
*/
|
|
111
|
+
write(tap: WritableTapLike, value: Record<string, unknown>): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Reads a record value from the tap.
|
|
114
|
+
* @param tap The readable tap to read from.
|
|
115
|
+
* @returns The read record value.
|
|
116
|
+
*/
|
|
117
|
+
read(tap: ReadableTapLike): Promise<Record<string, unknown>>;
|
|
118
|
+
/**
|
|
119
|
+
* Skips a record value in the tap.
|
|
120
|
+
* @param tap The readable tap to skip in.
|
|
121
|
+
*/
|
|
122
|
+
skip(tap: ReadableTapLike): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Converts the given record value to a buffer.
|
|
125
|
+
* @param value The record value to convert.
|
|
126
|
+
* @returns The buffer representation of the value.
|
|
127
|
+
*/
|
|
128
|
+
toBuffer(value: Record<string, unknown>): Promise<ArrayBuffer>;
|
|
129
|
+
/**
|
|
130
|
+
* Clones a record value, ensuring it conforms to the schema.
|
|
131
|
+
* @param value The value to clone.
|
|
132
|
+
* @returns The cloned record value.
|
|
133
|
+
*/
|
|
134
|
+
cloneFromValue(value: unknown): Record<string, unknown>;
|
|
135
|
+
/**
|
|
136
|
+
* Compares two record values for ordering.
|
|
137
|
+
* @param val1 The first record value.
|
|
138
|
+
* @param val2 The second record value.
|
|
139
|
+
* @returns A negative number if val1 < val2, zero if equal, positive if val1 > val2.
|
|
140
|
+
*/
|
|
141
|
+
compare(val1: Record<string, unknown>, val2: Record<string, unknown>): number;
|
|
142
|
+
/**
|
|
143
|
+
* Generates a random record value conforming to this schema.
|
|
144
|
+
* @returns A random record value.
|
|
145
|
+
*/
|
|
146
|
+
random(): Record<string, unknown>;
|
|
147
|
+
/**
|
|
148
|
+
* Converts this record type to its JSON schema representation.
|
|
149
|
+
* @returns The JSON representation of the record type.
|
|
150
|
+
*/
|
|
151
|
+
toJSON(): JSONType;
|
|
152
|
+
/**
|
|
153
|
+
* Matches two record values from the taps for comparison.
|
|
154
|
+
* @param tap1 The first readable tap.
|
|
155
|
+
* @param tap2 The second readable tap.
|
|
156
|
+
* @returns A comparison result.
|
|
157
|
+
*/
|
|
158
|
+
match(tap1: ReadableTapLike, tap2: ReadableTapLike): Promise<number>;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a resolver for schema evolution from the writer type to this reader type.
|
|
161
|
+
* @param writerType The writer type to resolve from.
|
|
162
|
+
* @returns A resolver for reading writer data with this schema.
|
|
163
|
+
*/
|
|
164
|
+
createResolver(writerType: Type): Resolver;
|
|
165
|
+
}
|