@jsonjoy.com/json-pack 1.5.0 → 1.7.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/lib/avro/AvroEncoder.d.ts +30 -0
- package/lib/avro/AvroEncoder.js +190 -0
- package/lib/avro/AvroEncoder.js.map +1 -0
- package/lib/avro/AvroSchemaEncoder.d.ts +33 -0
- package/lib/avro/AvroSchemaEncoder.js +321 -0
- package/lib/avro/AvroSchemaEncoder.js.map +1 -0
- package/lib/avro/AvroSchemaValidator.d.ts +32 -0
- package/lib/avro/AvroSchemaValidator.js +260 -0
- package/lib/avro/AvroSchemaValidator.js.map +1 -0
- package/lib/avro/index.d.ts +4 -0
- package/lib/avro/index.js +8 -0
- package/lib/avro/index.js.map +1 -0
- package/lib/cbor/CborDecoder.d.ts +1 -1
- package/lib/msgpack/MsgPackDecoder.d.ts +1 -1
- package/lib/msgpack/shallow-read.d.ts +1 -1
- package/package.json +2 -1
- package/lib/json-pointer/index.d.ts +0 -1
- package/lib/json-pointer/index.js +0 -5
- package/lib/json-pointer/index.js.map +0 -1
- package/lib/json-pointer/types.d.ts +0 -2
- package/lib/json-pointer/types.js +0 -3
- package/lib/json-pointer/types.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
|
|
2
|
+
import type { BinaryJsonEncoder } from '../types';
|
|
3
|
+
export declare class AvroEncoder implements BinaryJsonEncoder {
|
|
4
|
+
readonly writer: IWriter & IWriterGrowable;
|
|
5
|
+
constructor(writer: IWriter & IWriterGrowable);
|
|
6
|
+
encode(value: unknown): Uint8Array;
|
|
7
|
+
writeUnknown(value: unknown): void;
|
|
8
|
+
writeAny(value: unknown): void;
|
|
9
|
+
writeNull(): void;
|
|
10
|
+
writeBoolean(bool: boolean): void;
|
|
11
|
+
writeInt(int: number): void;
|
|
12
|
+
writeLong(long: number | bigint): void;
|
|
13
|
+
writeFloatAvro(float: number): void;
|
|
14
|
+
writeDouble(double: number): void;
|
|
15
|
+
writeBin(bytes: Uint8Array): void;
|
|
16
|
+
writeStr(str: string): void;
|
|
17
|
+
writeArr(arr: unknown[]): void;
|
|
18
|
+
writeObj(obj: Record<string, unknown>): void;
|
|
19
|
+
writeNumber(num: number): void;
|
|
20
|
+
writeInteger(int: number): void;
|
|
21
|
+
writeUInteger(uint: number): void;
|
|
22
|
+
writeFloat(float: number): void;
|
|
23
|
+
private writeFloatValue;
|
|
24
|
+
writeAsciiStr(str: string): void;
|
|
25
|
+
private writeVarIntSigned;
|
|
26
|
+
private writeVarIntUnsigned;
|
|
27
|
+
private writeVarLong;
|
|
28
|
+
private encodeZigZag32;
|
|
29
|
+
private encodeZigZag64;
|
|
30
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AvroEncoder = void 0;
|
|
4
|
+
class AvroEncoder {
|
|
5
|
+
constructor(writer) {
|
|
6
|
+
this.writer = writer;
|
|
7
|
+
}
|
|
8
|
+
encode(value) {
|
|
9
|
+
const writer = this.writer;
|
|
10
|
+
writer.reset();
|
|
11
|
+
this.writeAny(value);
|
|
12
|
+
return writer.flush();
|
|
13
|
+
}
|
|
14
|
+
writeUnknown(value) {
|
|
15
|
+
this.writeNull();
|
|
16
|
+
}
|
|
17
|
+
writeAny(value) {
|
|
18
|
+
switch (typeof value) {
|
|
19
|
+
case 'boolean':
|
|
20
|
+
return this.writeBoolean(value);
|
|
21
|
+
case 'number':
|
|
22
|
+
return this.writeNumber(value);
|
|
23
|
+
case 'string':
|
|
24
|
+
return this.writeStr(value);
|
|
25
|
+
case 'object': {
|
|
26
|
+
if (value === null)
|
|
27
|
+
return this.writeNull();
|
|
28
|
+
const constructor = value.constructor;
|
|
29
|
+
switch (constructor) {
|
|
30
|
+
case Object:
|
|
31
|
+
return this.writeObj(value);
|
|
32
|
+
case Array:
|
|
33
|
+
return this.writeArr(value);
|
|
34
|
+
case Uint8Array:
|
|
35
|
+
return this.writeBin(value);
|
|
36
|
+
default:
|
|
37
|
+
return this.writeUnknown(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
case 'bigint':
|
|
41
|
+
return this.writeLong(value);
|
|
42
|
+
case 'undefined':
|
|
43
|
+
return this.writeNull();
|
|
44
|
+
default:
|
|
45
|
+
return this.writeUnknown(value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
writeNull() {
|
|
49
|
+
}
|
|
50
|
+
writeBoolean(bool) {
|
|
51
|
+
this.writer.u8(bool ? 1 : 0);
|
|
52
|
+
}
|
|
53
|
+
writeInt(int) {
|
|
54
|
+
this.writeVarIntSigned(this.encodeZigZag32(Math.trunc(int)));
|
|
55
|
+
}
|
|
56
|
+
writeLong(long) {
|
|
57
|
+
if (typeof long === 'bigint') {
|
|
58
|
+
this.writeVarLong(this.encodeZigZag64(long));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.writeVarLong(this.encodeZigZag64(BigInt(Math.trunc(long))));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
writeFloatAvro(float) {
|
|
65
|
+
const writer = this.writer;
|
|
66
|
+
writer.ensureCapacity(4);
|
|
67
|
+
writer.view.setFloat32(writer.x, float, true);
|
|
68
|
+
writer.move(4);
|
|
69
|
+
}
|
|
70
|
+
writeDouble(double) {
|
|
71
|
+
const writer = this.writer;
|
|
72
|
+
writer.ensureCapacity(8);
|
|
73
|
+
writer.view.setFloat64(writer.x, double, true);
|
|
74
|
+
writer.move(8);
|
|
75
|
+
}
|
|
76
|
+
writeBin(bytes) {
|
|
77
|
+
this.writeVarIntUnsigned(bytes.length);
|
|
78
|
+
this.writer.buf(bytes, bytes.length);
|
|
79
|
+
}
|
|
80
|
+
writeStr(str) {
|
|
81
|
+
const writer = this.writer;
|
|
82
|
+
const maxSize = str.length * 4;
|
|
83
|
+
writer.ensureCapacity(5 + maxSize);
|
|
84
|
+
const lengthOffset = writer.x;
|
|
85
|
+
writer.x += 5;
|
|
86
|
+
const bytesWritten = writer.utf8(str);
|
|
87
|
+
const endPos = writer.x;
|
|
88
|
+
writer.x = lengthOffset;
|
|
89
|
+
this.writeVarIntUnsigned(bytesWritten);
|
|
90
|
+
const actualLengthSize = writer.x - lengthOffset;
|
|
91
|
+
if (actualLengthSize < 5) {
|
|
92
|
+
const stringStart = lengthOffset + 5;
|
|
93
|
+
const stringData = writer.uint8.slice(stringStart, endPos);
|
|
94
|
+
writer.x = lengthOffset + actualLengthSize;
|
|
95
|
+
writer.buf(stringData, stringData.length);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
writer.x = endPos;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
writeArr(arr) {
|
|
102
|
+
this.writeVarIntUnsigned(arr.length);
|
|
103
|
+
const length = arr.length;
|
|
104
|
+
for (let i = 0; i < length; i++) {
|
|
105
|
+
this.writeAny(arr[i]);
|
|
106
|
+
}
|
|
107
|
+
this.writeVarIntUnsigned(0);
|
|
108
|
+
}
|
|
109
|
+
writeObj(obj) {
|
|
110
|
+
const entries = Object.entries(obj);
|
|
111
|
+
const length = entries.length;
|
|
112
|
+
this.writeVarIntUnsigned(length);
|
|
113
|
+
for (let i = 0; i < length; i++) {
|
|
114
|
+
const entry = entries[i];
|
|
115
|
+
this.writeStr(entry[0]);
|
|
116
|
+
this.writeAny(entry[1]);
|
|
117
|
+
}
|
|
118
|
+
this.writeVarIntUnsigned(0);
|
|
119
|
+
}
|
|
120
|
+
writeNumber(num) {
|
|
121
|
+
if (Number.isInteger(num)) {
|
|
122
|
+
if (num >= -2147483648 && num <= 2147483647) {
|
|
123
|
+
this.writeInt(num);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.writeLong(num);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.writeDouble(num);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
writeInteger(int) {
|
|
134
|
+
this.writeInt(int);
|
|
135
|
+
}
|
|
136
|
+
writeUInteger(uint) {
|
|
137
|
+
this.writeInt(uint);
|
|
138
|
+
}
|
|
139
|
+
writeFloat(float) {
|
|
140
|
+
this.writeFloatValue(float);
|
|
141
|
+
}
|
|
142
|
+
writeFloatValue(float) {
|
|
143
|
+
const writer = this.writer;
|
|
144
|
+
writer.ensureCapacity(4);
|
|
145
|
+
writer.view.setFloat32(writer.x, float, true);
|
|
146
|
+
writer.move(4);
|
|
147
|
+
}
|
|
148
|
+
writeAsciiStr(str) {
|
|
149
|
+
const writer = this.writer;
|
|
150
|
+
this.writeVarIntUnsigned(str.length);
|
|
151
|
+
writer.ascii(str);
|
|
152
|
+
}
|
|
153
|
+
writeVarIntSigned(value) {
|
|
154
|
+
const writer = this.writer;
|
|
155
|
+
let n = value >>> 0;
|
|
156
|
+
while (n >= 0x80) {
|
|
157
|
+
writer.u8((n & 0x7f) | 0x80);
|
|
158
|
+
n >>>= 7;
|
|
159
|
+
}
|
|
160
|
+
writer.u8(n & 0x7f);
|
|
161
|
+
}
|
|
162
|
+
writeVarIntUnsigned(value) {
|
|
163
|
+
const writer = this.writer;
|
|
164
|
+
let n = value >>> 0;
|
|
165
|
+
while (n >= 0x80) {
|
|
166
|
+
writer.u8((n & 0x7f) | 0x80);
|
|
167
|
+
n >>>= 7;
|
|
168
|
+
}
|
|
169
|
+
writer.u8(n & 0x7f);
|
|
170
|
+
}
|
|
171
|
+
writeVarLong(value) {
|
|
172
|
+
const writer = this.writer;
|
|
173
|
+
let n = value;
|
|
174
|
+
const mask = BigInt(0x7f);
|
|
175
|
+
const shift = BigInt(7);
|
|
176
|
+
while (n >= BigInt(0x80)) {
|
|
177
|
+
writer.u8(Number((n & mask) | BigInt(0x80)));
|
|
178
|
+
n >>= shift;
|
|
179
|
+
}
|
|
180
|
+
writer.u8(Number(n & mask));
|
|
181
|
+
}
|
|
182
|
+
encodeZigZag32(value) {
|
|
183
|
+
return (value << 1) ^ (value >> 31);
|
|
184
|
+
}
|
|
185
|
+
encodeZigZag64(value) {
|
|
186
|
+
return (value << BigInt(1)) ^ (value >> BigInt(63));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.AvroEncoder = AvroEncoder;
|
|
190
|
+
//# sourceMappingURL=AvroEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvroEncoder.js","sourceRoot":"","sources":["../../src/avro/AvroEncoder.ts"],"names":[],"mappings":";;;AAQA,MAAa,WAAW;IACtB,YAA4B,MAAiC;QAAjC,WAAM,GAAN,MAAM,CAA2B;IAAG,CAAC;IAE1D,MAAM,CAAC,KAAc;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAKM,YAAY,CAAC,KAAc;QAChC,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,KAAc;QAC5B,QAAQ,OAAO,KAAK,EAAE,CAAC;YACrB,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YAClC,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACjC,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC9B,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,IAAI,KAAK,KAAK,IAAI;oBAAE,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;gBACtC,QAAQ,WAAW,EAAE,CAAC;oBACpB,KAAK,MAAM;wBAC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9B,CAAC;IAKO,cAAc,CAAC,KAAa;QAClC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAKO,cAAc,CAAC,KAAa;QAClC,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AAzRD,kCAyRC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/util/lib/buffers';
|
|
2
|
+
import type { AvroSchema, AvroRecordSchema, AvroEnumSchema, AvroArraySchema, AvroMapSchema, AvroUnionSchema, AvroFixedSchema, AvroNullSchema } from './types';
|
|
3
|
+
export declare class AvroSchemaEncoder {
|
|
4
|
+
readonly writer: IWriter & IWriterGrowable;
|
|
5
|
+
private encoder;
|
|
6
|
+
private validator;
|
|
7
|
+
private namedSchemas;
|
|
8
|
+
constructor(writer: IWriter & IWriterGrowable);
|
|
9
|
+
encode(value: unknown, schema: AvroSchema, selectedIndex?: number): Uint8Array;
|
|
10
|
+
writeNull(schema: AvroNullSchema | AvroSchema): void;
|
|
11
|
+
writeBoolean(value: boolean, schema: AvroSchema): void;
|
|
12
|
+
writeInt(value: number, schema: AvroSchema): void;
|
|
13
|
+
writeLong(value: number | bigint, schema: AvroSchema): void;
|
|
14
|
+
writeFloat(value: number, schema: AvroSchema): void;
|
|
15
|
+
writeDouble(value: number, schema: AvroSchema): void;
|
|
16
|
+
writeBytes(value: Uint8Array, schema: AvroSchema): void;
|
|
17
|
+
writeString(value: string, schema: AvroSchema): void;
|
|
18
|
+
writeRecord(value: Record<string, unknown>, schema: AvroRecordSchema): void;
|
|
19
|
+
writeEnum(value: string, schema: AvroEnumSchema): void;
|
|
20
|
+
writeArray(value: unknown[], schema: AvroArraySchema): void;
|
|
21
|
+
writeMap(value: Record<string, unknown>, schema: AvroMapSchema): void;
|
|
22
|
+
writeUnion(value: unknown, schema: AvroUnionSchema, selectedIndex?: number): void;
|
|
23
|
+
writeFixed(value: Uint8Array, schema: AvroFixedSchema): void;
|
|
24
|
+
writeNumber(value: number, schema: AvroSchema): void;
|
|
25
|
+
private writeValue;
|
|
26
|
+
private validateSchemaType;
|
|
27
|
+
private resolveSchema;
|
|
28
|
+
private collectNamedSchemas;
|
|
29
|
+
private getFullName;
|
|
30
|
+
private writeVarIntUnsigned;
|
|
31
|
+
private writeVarIntSigned;
|
|
32
|
+
private encodeZigZag32;
|
|
33
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AvroSchemaEncoder = void 0;
|
|
4
|
+
const AvroEncoder_1 = require("./AvroEncoder");
|
|
5
|
+
const AvroSchemaValidator_1 = require("./AvroSchemaValidator");
|
|
6
|
+
class AvroSchemaEncoder {
|
|
7
|
+
constructor(writer) {
|
|
8
|
+
this.writer = writer;
|
|
9
|
+
this.namedSchemas = new Map();
|
|
10
|
+
this.encoder = new AvroEncoder_1.AvroEncoder(writer);
|
|
11
|
+
this.validator = new AvroSchemaValidator_1.AvroSchemaValidator();
|
|
12
|
+
}
|
|
13
|
+
encode(value, schema, selectedIndex) {
|
|
14
|
+
this.writer.reset();
|
|
15
|
+
this.namedSchemas.clear();
|
|
16
|
+
if (!this.validator.validateSchema(schema)) {
|
|
17
|
+
throw new Error('Invalid Avro schema');
|
|
18
|
+
}
|
|
19
|
+
if (!this.validator.validateValue(value, schema)) {
|
|
20
|
+
throw new Error('Value does not conform to schema');
|
|
21
|
+
}
|
|
22
|
+
this.collectNamedSchemas(schema);
|
|
23
|
+
if (Array.isArray(schema) && selectedIndex !== undefined) {
|
|
24
|
+
this.writeUnion(value, schema, selectedIndex);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.writeValue(value, schema);
|
|
28
|
+
}
|
|
29
|
+
return this.writer.flush();
|
|
30
|
+
}
|
|
31
|
+
writeNull(schema) {
|
|
32
|
+
this.validateSchemaType(schema, 'null');
|
|
33
|
+
this.encoder.writeNull();
|
|
34
|
+
}
|
|
35
|
+
writeBoolean(value, schema) {
|
|
36
|
+
this.validateSchemaType(schema, 'boolean');
|
|
37
|
+
this.encoder.writeBoolean(value);
|
|
38
|
+
}
|
|
39
|
+
writeInt(value, schema) {
|
|
40
|
+
this.validateSchemaType(schema, 'int');
|
|
41
|
+
if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
|
|
42
|
+
throw new Error('Value is not a valid 32-bit integer');
|
|
43
|
+
}
|
|
44
|
+
this.encoder.writeInt(value);
|
|
45
|
+
}
|
|
46
|
+
writeLong(value, schema) {
|
|
47
|
+
this.validateSchemaType(schema, 'long');
|
|
48
|
+
this.encoder.writeLong(value);
|
|
49
|
+
}
|
|
50
|
+
writeFloat(value, schema) {
|
|
51
|
+
this.validateSchemaType(schema, 'float');
|
|
52
|
+
this.encoder.writeFloat(value);
|
|
53
|
+
}
|
|
54
|
+
writeDouble(value, schema) {
|
|
55
|
+
this.validateSchemaType(schema, 'double');
|
|
56
|
+
this.encoder.writeDouble(value);
|
|
57
|
+
}
|
|
58
|
+
writeBytes(value, schema) {
|
|
59
|
+
this.validateSchemaType(schema, 'bytes');
|
|
60
|
+
this.encoder.writeBin(value);
|
|
61
|
+
}
|
|
62
|
+
writeString(value, schema) {
|
|
63
|
+
this.validateSchemaType(schema, 'string');
|
|
64
|
+
this.encoder.writeStr(value);
|
|
65
|
+
}
|
|
66
|
+
writeRecord(value, schema) {
|
|
67
|
+
if (typeof schema === 'object' && schema.type !== 'record') {
|
|
68
|
+
throw new Error('Schema is not a record schema');
|
|
69
|
+
}
|
|
70
|
+
const recordSchema = this.resolveSchema(schema);
|
|
71
|
+
if (recordSchema.type !== 'record') {
|
|
72
|
+
throw new Error('Schema is not a record schema');
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < recordSchema.fields.length; i++) {
|
|
75
|
+
const field = recordSchema.fields[i];
|
|
76
|
+
const fieldValue = value[field.name];
|
|
77
|
+
if (fieldValue !== undefined) {
|
|
78
|
+
this.writeValue(fieldValue, field.type);
|
|
79
|
+
}
|
|
80
|
+
else if (field.default !== undefined) {
|
|
81
|
+
this.writeValue(field.default, field.type);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error(`Missing required field: ${field.name}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
writeEnum(value, schema) {
|
|
89
|
+
if (typeof schema === 'object' && schema.type !== 'enum') {
|
|
90
|
+
throw new Error('Schema is not an enum schema');
|
|
91
|
+
}
|
|
92
|
+
const enumSchema = this.resolveSchema(schema);
|
|
93
|
+
if (enumSchema.type !== 'enum') {
|
|
94
|
+
throw new Error('Schema is not an enum schema');
|
|
95
|
+
}
|
|
96
|
+
const index = enumSchema.symbols.indexOf(value);
|
|
97
|
+
if (index === -1) {
|
|
98
|
+
throw new Error(`Invalid enum value: ${value}`);
|
|
99
|
+
}
|
|
100
|
+
this.writeVarIntSigned(this.encodeZigZag32(index));
|
|
101
|
+
}
|
|
102
|
+
writeArray(value, schema) {
|
|
103
|
+
if (typeof schema === 'object' && schema.type !== 'array') {
|
|
104
|
+
throw new Error('Schema is not an array schema');
|
|
105
|
+
}
|
|
106
|
+
const arraySchema = this.resolveSchema(schema);
|
|
107
|
+
if (arraySchema.type !== 'array') {
|
|
108
|
+
throw new Error('Schema is not an array schema');
|
|
109
|
+
}
|
|
110
|
+
this.writeVarIntUnsigned(value.length);
|
|
111
|
+
const length = value.length;
|
|
112
|
+
for (let i = 0; i < length; i++) {
|
|
113
|
+
this.writeValue(value[i], arraySchema.items);
|
|
114
|
+
}
|
|
115
|
+
this.writeVarIntUnsigned(0);
|
|
116
|
+
}
|
|
117
|
+
writeMap(value, schema) {
|
|
118
|
+
if (typeof schema === 'object' && schema.type !== 'map') {
|
|
119
|
+
throw new Error('Schema is not a map schema');
|
|
120
|
+
}
|
|
121
|
+
const mapSchema = this.resolveSchema(schema);
|
|
122
|
+
if (mapSchema.type !== 'map') {
|
|
123
|
+
throw new Error('Schema is not a map schema');
|
|
124
|
+
}
|
|
125
|
+
const entries = Object.entries(value);
|
|
126
|
+
this.writeVarIntUnsigned(entries.length);
|
|
127
|
+
const length = entries.length;
|
|
128
|
+
for (let i = 0; i < length; i++) {
|
|
129
|
+
const entry = entries[i];
|
|
130
|
+
this.encoder.writeStr(entry[0]);
|
|
131
|
+
this.writeValue(entry[1], mapSchema.values);
|
|
132
|
+
}
|
|
133
|
+
this.writeVarIntUnsigned(0);
|
|
134
|
+
}
|
|
135
|
+
writeUnion(value, schema, selectedIndex) {
|
|
136
|
+
if (!Array.isArray(schema)) {
|
|
137
|
+
throw new Error('Schema is not a union schema');
|
|
138
|
+
}
|
|
139
|
+
let index = selectedIndex;
|
|
140
|
+
if (index === undefined) {
|
|
141
|
+
index = schema.findIndex((subSchema) => this.validator.validateValue(value, subSchema));
|
|
142
|
+
if (index === -1) {
|
|
143
|
+
throw new Error('Value does not match any schema in the union');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (index < 0 || index >= schema.length) {
|
|
147
|
+
throw new Error('Invalid union index');
|
|
148
|
+
}
|
|
149
|
+
this.writeVarIntSigned(this.encodeZigZag32(index));
|
|
150
|
+
this.writeValue(value, schema[index]);
|
|
151
|
+
}
|
|
152
|
+
writeFixed(value, schema) {
|
|
153
|
+
if (typeof schema === 'object' && schema.type !== 'fixed') {
|
|
154
|
+
throw new Error('Schema is not a fixed schema');
|
|
155
|
+
}
|
|
156
|
+
const fixedSchema = this.resolveSchema(schema);
|
|
157
|
+
if (fixedSchema.type !== 'fixed') {
|
|
158
|
+
throw new Error('Schema is not a fixed schema');
|
|
159
|
+
}
|
|
160
|
+
if (value.length !== fixedSchema.size) {
|
|
161
|
+
throw new Error(`Fixed value length ${value.length} does not match schema size ${fixedSchema.size}`);
|
|
162
|
+
}
|
|
163
|
+
this.writer.buf(value, value.length);
|
|
164
|
+
}
|
|
165
|
+
writeNumber(value, schema) {
|
|
166
|
+
const resolvedSchema = this.resolveSchema(schema);
|
|
167
|
+
const schemaType = typeof resolvedSchema === 'string'
|
|
168
|
+
? resolvedSchema
|
|
169
|
+
: Array.isArray(resolvedSchema)
|
|
170
|
+
? 'union'
|
|
171
|
+
: resolvedSchema.type;
|
|
172
|
+
switch (schemaType) {
|
|
173
|
+
case 'int':
|
|
174
|
+
this.writeInt(value, schema);
|
|
175
|
+
break;
|
|
176
|
+
case 'long':
|
|
177
|
+
this.writeLong(value, schema);
|
|
178
|
+
break;
|
|
179
|
+
case 'float':
|
|
180
|
+
this.writeFloat(value, schema);
|
|
181
|
+
break;
|
|
182
|
+
case 'double':
|
|
183
|
+
this.writeDouble(value, schema);
|
|
184
|
+
break;
|
|
185
|
+
default:
|
|
186
|
+
throw new Error(`Schema type ${schemaType} is not a numeric type`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
writeValue(value, schema) {
|
|
190
|
+
const resolvedSchema = this.resolveSchema(schema);
|
|
191
|
+
if (typeof resolvedSchema === 'string') {
|
|
192
|
+
switch (resolvedSchema) {
|
|
193
|
+
case 'null':
|
|
194
|
+
this.encoder.writeNull();
|
|
195
|
+
break;
|
|
196
|
+
case 'boolean':
|
|
197
|
+
this.encoder.writeBoolean(value);
|
|
198
|
+
break;
|
|
199
|
+
case 'int':
|
|
200
|
+
this.encoder.writeInt(value);
|
|
201
|
+
break;
|
|
202
|
+
case 'long':
|
|
203
|
+
this.encoder.writeLong(value);
|
|
204
|
+
break;
|
|
205
|
+
case 'float':
|
|
206
|
+
this.encoder.writeFloat(value);
|
|
207
|
+
break;
|
|
208
|
+
case 'double':
|
|
209
|
+
this.encoder.writeDouble(value);
|
|
210
|
+
break;
|
|
211
|
+
case 'bytes':
|
|
212
|
+
this.encoder.writeBin(value);
|
|
213
|
+
break;
|
|
214
|
+
case 'string':
|
|
215
|
+
this.encoder.writeStr(value);
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
throw new Error(`Unknown primitive type: ${resolvedSchema}`);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (Array.isArray(resolvedSchema)) {
|
|
223
|
+
this.writeUnion(value, resolvedSchema);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
switch (resolvedSchema.type) {
|
|
227
|
+
case 'record':
|
|
228
|
+
this.writeRecord(value, resolvedSchema);
|
|
229
|
+
break;
|
|
230
|
+
case 'enum':
|
|
231
|
+
this.writeEnum(value, resolvedSchema);
|
|
232
|
+
break;
|
|
233
|
+
case 'array':
|
|
234
|
+
this.writeArray(value, resolvedSchema);
|
|
235
|
+
break;
|
|
236
|
+
case 'map':
|
|
237
|
+
this.writeMap(value, resolvedSchema);
|
|
238
|
+
break;
|
|
239
|
+
case 'fixed':
|
|
240
|
+
this.writeFixed(value, resolvedSchema);
|
|
241
|
+
break;
|
|
242
|
+
default:
|
|
243
|
+
throw new Error(`Unknown schema type: ${resolvedSchema.type}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
validateSchemaType(schema, expectedType) {
|
|
247
|
+
const resolvedSchema = this.resolveSchema(schema);
|
|
248
|
+
const actualType = typeof resolvedSchema === 'string'
|
|
249
|
+
? resolvedSchema
|
|
250
|
+
: Array.isArray(resolvedSchema)
|
|
251
|
+
? 'union'
|
|
252
|
+
: resolvedSchema.type;
|
|
253
|
+
if (actualType !== expectedType) {
|
|
254
|
+
throw new Error(`Expected schema type ${expectedType}, got ${actualType}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
resolveSchema(schema) {
|
|
258
|
+
if (typeof schema === 'string') {
|
|
259
|
+
const namedSchema = this.namedSchemas.get(schema);
|
|
260
|
+
return namedSchema || schema;
|
|
261
|
+
}
|
|
262
|
+
return schema;
|
|
263
|
+
}
|
|
264
|
+
collectNamedSchemas(schema) {
|
|
265
|
+
if (typeof schema === 'string' || Array.isArray(schema)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
269
|
+
switch (schema.type) {
|
|
270
|
+
case 'record':
|
|
271
|
+
const recordSchema = schema;
|
|
272
|
+
const recordFullName = this.getFullName(recordSchema.name, recordSchema.namespace);
|
|
273
|
+
this.namedSchemas.set(recordFullName, recordSchema);
|
|
274
|
+
recordSchema.fields.forEach((field) => this.collectNamedSchemas(field.type));
|
|
275
|
+
break;
|
|
276
|
+
case 'enum':
|
|
277
|
+
const enumSchema = schema;
|
|
278
|
+
const enumFullName = this.getFullName(enumSchema.name, enumSchema.namespace);
|
|
279
|
+
this.namedSchemas.set(enumFullName, enumSchema);
|
|
280
|
+
break;
|
|
281
|
+
case 'fixed':
|
|
282
|
+
const fixedSchema = schema;
|
|
283
|
+
const fixedFullName = this.getFullName(fixedSchema.name, fixedSchema.namespace);
|
|
284
|
+
this.namedSchemas.set(fixedFullName, fixedSchema);
|
|
285
|
+
break;
|
|
286
|
+
case 'array':
|
|
287
|
+
this.collectNamedSchemas(schema.items);
|
|
288
|
+
break;
|
|
289
|
+
case 'map':
|
|
290
|
+
this.collectNamedSchemas(schema.values);
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
getFullName(name, namespace) {
|
|
296
|
+
return namespace ? `${namespace}.${name}` : name;
|
|
297
|
+
}
|
|
298
|
+
writeVarIntUnsigned(value) {
|
|
299
|
+
const writer = this.writer;
|
|
300
|
+
let n = value >>> 0;
|
|
301
|
+
while (n >= 0x80) {
|
|
302
|
+
writer.u8((n & 0x7f) | 0x80);
|
|
303
|
+
n >>>= 7;
|
|
304
|
+
}
|
|
305
|
+
writer.u8(n & 0x7f);
|
|
306
|
+
}
|
|
307
|
+
writeVarIntSigned(value) {
|
|
308
|
+
const writer = this.writer;
|
|
309
|
+
let n = value >>> 0;
|
|
310
|
+
while (n >= 0x80) {
|
|
311
|
+
writer.u8((n & 0x7f) | 0x80);
|
|
312
|
+
n >>>= 7;
|
|
313
|
+
}
|
|
314
|
+
writer.u8(n & 0x7f);
|
|
315
|
+
}
|
|
316
|
+
encodeZigZag32(value) {
|
|
317
|
+
return (value << 1) ^ (value >> 31);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
exports.AvroSchemaEncoder = AvroSchemaEncoder;
|
|
321
|
+
//# sourceMappingURL=AvroSchemaEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvroSchemaEncoder.js","sourceRoot":"","sources":["../../src/avro/AvroSchemaEncoder.ts"],"names":[],"mappings":";;;AACA,+CAA0C;AAC1C,+DAA0D;AAkB1D,MAAa,iBAAiB;IAK5B,YAA4B,MAAiC;QAAjC,WAAM,GAAN,MAAM,CAA2B;QAFrD,iBAAY,GAAG,IAAI,GAAG,EAA2B,CAAC;QAGxD,IAAI,CAAC,OAAO,GAAG,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,yCAAmB,EAAE,CAAC;IAC7C,CAAC;IAKM,MAAM,CAAC,KAAc,EAAE,MAAkB,EAAE,aAAsB;QACtE,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAG1B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAGD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,mBAAmB,CAAC,MAAM,CA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C;IACtC,CAAC;CACF;AAzbD,8CAybC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AvroSchema } from './types';
|
|
2
|
+
export declare class AvroSchemaValidator {
|
|
3
|
+
private namedSchemas;
|
|
4
|
+
validateSchema(schema: AvroSchema): boolean;
|
|
5
|
+
validateValue(value: unknown, schema: AvroSchema): boolean;
|
|
6
|
+
private validateSchemaInternal;
|
|
7
|
+
private validateStringSchema;
|
|
8
|
+
private validateUnionSchema;
|
|
9
|
+
private validateNullSchema;
|
|
10
|
+
private validateBooleanSchema;
|
|
11
|
+
private validateIntSchema;
|
|
12
|
+
private validateLongSchema;
|
|
13
|
+
private validateFloatSchema;
|
|
14
|
+
private validateDoubleSchema;
|
|
15
|
+
private validateBytesSchema;
|
|
16
|
+
private validateStringTypeSchema;
|
|
17
|
+
private validateRecordSchema;
|
|
18
|
+
private validateRecordField;
|
|
19
|
+
private validateEnumSchema;
|
|
20
|
+
private validateArraySchema;
|
|
21
|
+
private validateMapSchema;
|
|
22
|
+
private validateFixedSchema;
|
|
23
|
+
private validateValueAgainstSchema;
|
|
24
|
+
private validateValueAgainstStringSchema;
|
|
25
|
+
private validateValueAgainstRecord;
|
|
26
|
+
private validateValueAgainstEnum;
|
|
27
|
+
private validateValueAgainstArray;
|
|
28
|
+
private validateValueAgainstMap;
|
|
29
|
+
private validateValueAgainstFixed;
|
|
30
|
+
private getSchemaTypeName;
|
|
31
|
+
private getFullName;
|
|
32
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AvroSchemaValidator = void 0;
|
|
4
|
+
class AvroSchemaValidator {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.namedSchemas = new Map();
|
|
7
|
+
}
|
|
8
|
+
validateSchema(schema) {
|
|
9
|
+
this.namedSchemas.clear();
|
|
10
|
+
return this.validateSchemaInternal(schema);
|
|
11
|
+
}
|
|
12
|
+
validateValue(value, schema) {
|
|
13
|
+
this.namedSchemas.clear();
|
|
14
|
+
this.validateSchemaInternal(schema);
|
|
15
|
+
return this.validateValueAgainstSchema(value, schema);
|
|
16
|
+
}
|
|
17
|
+
validateSchemaInternal(schema) {
|
|
18
|
+
if (typeof schema === 'string') {
|
|
19
|
+
return this.validateStringSchema(schema);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(schema)) {
|
|
22
|
+
return this.validateUnionSchema(schema);
|
|
23
|
+
}
|
|
24
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
25
|
+
switch (schema.type) {
|
|
26
|
+
case 'null':
|
|
27
|
+
return this.validateNullSchema(schema);
|
|
28
|
+
case 'boolean':
|
|
29
|
+
return this.validateBooleanSchema(schema);
|
|
30
|
+
case 'int':
|
|
31
|
+
return this.validateIntSchema(schema);
|
|
32
|
+
case 'long':
|
|
33
|
+
return this.validateLongSchema(schema);
|
|
34
|
+
case 'float':
|
|
35
|
+
return this.validateFloatSchema(schema);
|
|
36
|
+
case 'double':
|
|
37
|
+
return this.validateDoubleSchema(schema);
|
|
38
|
+
case 'bytes':
|
|
39
|
+
return this.validateBytesSchema(schema);
|
|
40
|
+
case 'string':
|
|
41
|
+
return this.validateStringTypeSchema(schema);
|
|
42
|
+
case 'record':
|
|
43
|
+
return this.validateRecordSchema(schema);
|
|
44
|
+
case 'enum':
|
|
45
|
+
return this.validateEnumSchema(schema);
|
|
46
|
+
case 'array':
|
|
47
|
+
return this.validateArraySchema(schema);
|
|
48
|
+
case 'map':
|
|
49
|
+
return this.validateMapSchema(schema);
|
|
50
|
+
case 'fixed':
|
|
51
|
+
return this.validateFixedSchema(schema);
|
|
52
|
+
default:
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
validateStringSchema(schema) {
|
|
59
|
+
const primitiveTypes = ['null', 'boolean', 'int', 'long', 'float', 'double', 'bytes', 'string'];
|
|
60
|
+
return primitiveTypes.includes(schema) || this.namedSchemas.has(schema);
|
|
61
|
+
}
|
|
62
|
+
validateUnionSchema(schema) {
|
|
63
|
+
if (schema.length === 0)
|
|
64
|
+
return false;
|
|
65
|
+
const typeSet = new Set();
|
|
66
|
+
for (const subSchema of schema) {
|
|
67
|
+
if (!this.validateSchemaInternal(subSchema))
|
|
68
|
+
return false;
|
|
69
|
+
const typeName = this.getSchemaTypeName(subSchema);
|
|
70
|
+
if (typeSet.has(typeName))
|
|
71
|
+
return false;
|
|
72
|
+
typeSet.add(typeName);
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
validateNullSchema(schema) {
|
|
77
|
+
return schema.type === 'null';
|
|
78
|
+
}
|
|
79
|
+
validateBooleanSchema(schema) {
|
|
80
|
+
return schema.type === 'boolean';
|
|
81
|
+
}
|
|
82
|
+
validateIntSchema(schema) {
|
|
83
|
+
return schema.type === 'int';
|
|
84
|
+
}
|
|
85
|
+
validateLongSchema(schema) {
|
|
86
|
+
return schema.type === 'long';
|
|
87
|
+
}
|
|
88
|
+
validateFloatSchema(schema) {
|
|
89
|
+
return schema.type === 'float';
|
|
90
|
+
}
|
|
91
|
+
validateDoubleSchema(schema) {
|
|
92
|
+
return schema.type === 'double';
|
|
93
|
+
}
|
|
94
|
+
validateBytesSchema(schema) {
|
|
95
|
+
return schema.type === 'bytes';
|
|
96
|
+
}
|
|
97
|
+
validateStringTypeSchema(schema) {
|
|
98
|
+
return schema.type === 'string';
|
|
99
|
+
}
|
|
100
|
+
validateRecordSchema(schema) {
|
|
101
|
+
if (schema.type !== 'record' || !schema.name || !Array.isArray(schema.fields))
|
|
102
|
+
return false;
|
|
103
|
+
const fullName = this.getFullName(schema.name, schema.namespace);
|
|
104
|
+
if (this.namedSchemas.has(fullName))
|
|
105
|
+
return false;
|
|
106
|
+
this.namedSchemas.set(fullName, schema);
|
|
107
|
+
const fieldNames = new Set();
|
|
108
|
+
for (const field of schema.fields) {
|
|
109
|
+
if (!this.validateRecordField(field))
|
|
110
|
+
return false;
|
|
111
|
+
if (fieldNames.has(field.name))
|
|
112
|
+
return false;
|
|
113
|
+
fieldNames.add(field.name);
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
validateRecordField(field) {
|
|
118
|
+
return typeof field.name === 'string' && field.name.length > 0 && this.validateSchemaInternal(field.type);
|
|
119
|
+
}
|
|
120
|
+
validateEnumSchema(schema) {
|
|
121
|
+
if (schema.type !== 'enum' || !schema.name || !Array.isArray(schema.symbols))
|
|
122
|
+
return false;
|
|
123
|
+
const fullName = this.getFullName(schema.name, schema.namespace);
|
|
124
|
+
if (this.namedSchemas.has(fullName))
|
|
125
|
+
return false;
|
|
126
|
+
this.namedSchemas.set(fullName, schema);
|
|
127
|
+
if (schema.symbols.length === 0)
|
|
128
|
+
return false;
|
|
129
|
+
const symbolSet = new Set();
|
|
130
|
+
for (const symbol of schema.symbols) {
|
|
131
|
+
if (typeof symbol !== 'string' || symbolSet.has(symbol))
|
|
132
|
+
return false;
|
|
133
|
+
symbolSet.add(symbol);
|
|
134
|
+
}
|
|
135
|
+
if (schema.default !== undefined && !schema.symbols.includes(schema.default))
|
|
136
|
+
return false;
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
validateArraySchema(schema) {
|
|
140
|
+
return schema.type === 'array' && this.validateSchemaInternal(schema.items);
|
|
141
|
+
}
|
|
142
|
+
validateMapSchema(schema) {
|
|
143
|
+
return schema.type === 'map' && this.validateSchemaInternal(schema.values);
|
|
144
|
+
}
|
|
145
|
+
validateFixedSchema(schema) {
|
|
146
|
+
if (schema.type !== 'fixed' || !schema.name || typeof schema.size !== 'number')
|
|
147
|
+
return false;
|
|
148
|
+
if (schema.size < 0)
|
|
149
|
+
return false;
|
|
150
|
+
const fullName = this.getFullName(schema.name, schema.namespace);
|
|
151
|
+
if (this.namedSchemas.has(fullName))
|
|
152
|
+
return false;
|
|
153
|
+
this.namedSchemas.set(fullName, schema);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
validateValueAgainstSchema(value, schema) {
|
|
157
|
+
if (typeof schema === 'string') {
|
|
158
|
+
return this.validateValueAgainstStringSchema(value, schema);
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(schema)) {
|
|
161
|
+
return schema.some((subSchema) => this.validateValueAgainstSchema(value, subSchema));
|
|
162
|
+
}
|
|
163
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
164
|
+
switch (schema.type) {
|
|
165
|
+
case 'null':
|
|
166
|
+
return value === null;
|
|
167
|
+
case 'boolean':
|
|
168
|
+
return typeof value === 'boolean';
|
|
169
|
+
case 'int':
|
|
170
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;
|
|
171
|
+
case 'long':
|
|
172
|
+
return (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint';
|
|
173
|
+
case 'float':
|
|
174
|
+
case 'double':
|
|
175
|
+
return typeof value === 'number';
|
|
176
|
+
case 'bytes':
|
|
177
|
+
return value instanceof Uint8Array;
|
|
178
|
+
case 'string':
|
|
179
|
+
return typeof value === 'string';
|
|
180
|
+
case 'record':
|
|
181
|
+
return this.validateValueAgainstRecord(value, schema);
|
|
182
|
+
case 'enum':
|
|
183
|
+
return this.validateValueAgainstEnum(value, schema);
|
|
184
|
+
case 'array':
|
|
185
|
+
return this.validateValueAgainstArray(value, schema);
|
|
186
|
+
case 'map':
|
|
187
|
+
return this.validateValueAgainstMap(value, schema);
|
|
188
|
+
case 'fixed':
|
|
189
|
+
return this.validateValueAgainstFixed(value, schema);
|
|
190
|
+
default:
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
validateValueAgainstStringSchema(value, schema) {
|
|
197
|
+
switch (schema) {
|
|
198
|
+
case 'null':
|
|
199
|
+
return value === null;
|
|
200
|
+
case 'boolean':
|
|
201
|
+
return typeof value === 'boolean';
|
|
202
|
+
case 'int':
|
|
203
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;
|
|
204
|
+
case 'long':
|
|
205
|
+
return (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint';
|
|
206
|
+
case 'float':
|
|
207
|
+
case 'double':
|
|
208
|
+
return typeof value === 'number';
|
|
209
|
+
case 'bytes':
|
|
210
|
+
return value instanceof Uint8Array;
|
|
211
|
+
case 'string':
|
|
212
|
+
return typeof value === 'string';
|
|
213
|
+
default:
|
|
214
|
+
const namedSchema = this.namedSchemas.get(schema);
|
|
215
|
+
return namedSchema ? this.validateValueAgainstSchema(value, namedSchema) : false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
validateValueAgainstRecord(value, schema) {
|
|
219
|
+
if (typeof value !== 'object' || value === null)
|
|
220
|
+
return false;
|
|
221
|
+
const obj = value;
|
|
222
|
+
for (const field of schema.fields) {
|
|
223
|
+
const fieldValue = obj[field.name];
|
|
224
|
+
if (fieldValue === undefined && field.default === undefined)
|
|
225
|
+
return false;
|
|
226
|
+
if (fieldValue !== undefined && !this.validateValueAgainstSchema(fieldValue, field.type))
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
validateValueAgainstEnum(value, schema) {
|
|
232
|
+
return typeof value === 'string' && schema.symbols.includes(value);
|
|
233
|
+
}
|
|
234
|
+
validateValueAgainstArray(value, schema) {
|
|
235
|
+
if (!Array.isArray(value))
|
|
236
|
+
return false;
|
|
237
|
+
return value.every((item) => this.validateValueAgainstSchema(item, schema.items));
|
|
238
|
+
}
|
|
239
|
+
validateValueAgainstMap(value, schema) {
|
|
240
|
+
if (typeof value !== 'object' || value === null)
|
|
241
|
+
return false;
|
|
242
|
+
const obj = value;
|
|
243
|
+
return Object.values(obj).every((val) => this.validateValueAgainstSchema(val, schema.values));
|
|
244
|
+
}
|
|
245
|
+
validateValueAgainstFixed(value, schema) {
|
|
246
|
+
return value instanceof Uint8Array && value.length === schema.size;
|
|
247
|
+
}
|
|
248
|
+
getSchemaTypeName(schema) {
|
|
249
|
+
if (typeof schema === 'string')
|
|
250
|
+
return schema;
|
|
251
|
+
if (Array.isArray(schema))
|
|
252
|
+
return 'union';
|
|
253
|
+
return schema.type;
|
|
254
|
+
}
|
|
255
|
+
getFullName(name, namespace) {
|
|
256
|
+
return namespace ? `${namespace}.${name}` : name;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
exports.AvroSchemaValidator = AvroSchemaValidator;
|
|
260
|
+
//# sourceMappingURL=AvroSchemaValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AvroSchemaValidator.js","sourceRoot":"","sources":["../../src/avro/AvroSchemaValidator.ts"],"names":[],"mappings":";;;AAwBA,MAAa,mBAAmB;IAAhC;QACU,iBAAY,GAAG,IAAI,GAAG,EAA2B,CAAC;IAiS5D,CAAC;IA5RQ,cAAc,CAAC,MAAkB;QACtC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAKM,aAAa,CAAC,KAAc,EAAE,MAAkB;QACrD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;IAEO,sBAAsB,CAAC,MAAkB;QAC/C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAE/B,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAE1B,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM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,CAAC,IAAY,EAAE,SAAkB;QAClD,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,CAAC;CACF;AAlSD,kDAkSC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./AvroSchemaValidator"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./AvroEncoder"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./AvroSchemaEncoder"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/avro/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,gEAAsC;AACtC,wDAA8B;AAC9B,8DAAoC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CborDecoderBase } from './CborDecoderBase';
|
|
2
2
|
import { JsonPackValue } from '../JsonPackValue';
|
|
3
|
-
import type { Path } from '
|
|
3
|
+
import type { Path } from '@jsonjoy.com/json-pointer';
|
|
4
4
|
import type { IReader, IReaderResettable } from '@jsonjoy.com/util/lib/buffers';
|
|
5
5
|
export declare class CborDecoder<R extends IReader & IReaderResettable = IReader & IReaderResettable> extends CborDecoderBase<R> {
|
|
6
6
|
readAsMap(): Map<unknown, unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MsgPackDecoderFast } from './MsgPackDecoderFast';
|
|
2
|
-
import type { Path } from '
|
|
2
|
+
import type { Path } from '@jsonjoy.com/json-pointer';
|
|
3
3
|
import type { Reader } from '@jsonjoy.com/util/lib/buffers/Reader';
|
|
4
4
|
export declare class MsgPackDecoder extends MsgPackDecoderFast<Reader> {
|
|
5
5
|
skipAny(): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Path } from '
|
|
1
|
+
import type { Path } from '@jsonjoy.com/json-pointer';
|
|
2
2
|
import type { MsgPackDecoder } from './MsgPackDecoder';
|
|
3
3
|
type Decoder = Pick<MsgPackDecoder, 'readObjHdr' | 'readStrHdr' | 'readArrHdr' | 'skipAny'>;
|
|
4
4
|
type Fn = (decoder: Decoder) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsonjoy.com/json-pack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "High-performance JSON serialization library",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "streamich",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@jsonjoy.com/base64": "^1.1.1",
|
|
67
|
+
"@jsonjoy.com/json-pointer": "^1.0.1",
|
|
67
68
|
"@jsonjoy.com/util": "^1.1.2",
|
|
68
69
|
"hyperdyperid": "^1.2.0",
|
|
69
70
|
"thingies": "^1.20.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/json-pointer/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/json-pointer/types.ts"],"names":[],"mappings":""}
|