Initial commit: notification-elements-demo app

Interactive Angular 19 demo for @sda/notification-elements-ui with
6 sections: Bell & Feed, Notification Center, Inbox, Comments &
Threads, Mention Input, and Full-Featured layout. Includes mock
data, dark mode toggle, and real-time event log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Giuliano Silvestro
2026-02-13 21:49:19 +10:00
commit 5d0c9ec7eb
36473 changed files with 3778146 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import type { BinaryJsonDecoder } from '../types';
export declare class AvroDecoder implements BinaryJsonDecoder {
reader: Reader;
read(uint8: Uint8Array): unknown;
decode(uint8: Uint8Array): unknown;
readAny(): unknown;
readNull(): null;
readBoolean(): boolean;
readInt(): number;
readLong(): number | bigint;
readFloat(): number;
readDouble(): number;
readBytes(): Uint8Array;
readString(): string;
readArray<T>(itemReader: () => T): T[];
readMap<T>(valueReader: () => T): Record<string, T>;
readUnion<T>(schemaReaders: Array<() => T>): {
index: number;
value: T;
};
readEnum(): number;
readFixed(size: number): Uint8Array;
readRecord<T>(fieldReaders: Array<() => any>): T;
private readVarIntUnsigned;
private readVarLong;
private decodeZigZag32;
private decodeZigZag64;
}

View File

@@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AvroDecoder = void 0;
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
class AvroDecoder {
constructor() {
this.reader = new Reader_1.Reader();
}
read(uint8) {
this.reader.reset(uint8);
return this.readAny();
}
decode(uint8) {
this.reader.reset(uint8);
return this.readAny();
}
readAny() {
throw new Error('readAny() requires schema information. Use readNull, readBoolean, etc. directly.');
}
readNull() {
return null;
}
readBoolean() {
return this.reader.u8() === 1;
}
readInt() {
const zigzag = this.readVarIntUnsigned();
return this.decodeZigZag32(zigzag);
}
readLong() {
const zigzag = this.readVarLong();
const decoded = this.decodeZigZag64(zigzag);
if (decoded >= BigInt(Number.MIN_SAFE_INTEGER) && decoded <= BigInt(Number.MAX_SAFE_INTEGER)) {
return Number(decoded);
}
return decoded;
}
readFloat() {
const reader = this.reader;
const value = reader.view.getFloat32(reader.x, true);
reader.x += 4;
return value;
}
readDouble() {
const reader = this.reader;
const value = reader.view.getFloat64(reader.x, true);
reader.x += 8;
return value;
}
readBytes() {
const length = this.readVarIntUnsigned();
return this.reader.buf(length);
}
readString() {
const length = this.readVarIntUnsigned();
const bytes = this.reader.buf(length);
return new TextDecoder().decode(bytes);
}
readArray(itemReader) {
const result = [];
while (true) {
const count = this.readVarIntUnsigned();
if (count === 0)
break;
for (let i = 0; i < count; i++) {
result.push(itemReader());
}
}
return result;
}
readMap(valueReader) {
const result = {};
while (true) {
const count = this.readVarIntUnsigned();
if (count === 0)
break;
for (let i = 0; i < count; i++) {
const key = this.readString();
if (key === '__proto__')
throw new Error('INVALID_KEY');
result[key] = valueReader();
}
}
return result;
}
readUnion(schemaReaders) {
const index = this.decodeZigZag32(this.readVarIntUnsigned());
if (index < 0 || index >= schemaReaders.length) {
throw new Error(`Invalid union index: ${index}`);
}
const value = schemaReaders[index]();
return { index, value };
}
readEnum() {
return this.decodeZigZag32(this.readVarIntUnsigned());
}
readFixed(size) {
return this.reader.buf(size);
}
readRecord(fieldReaders) {
const result = {};
for (let i = 0; i < fieldReaders.length; i++) {
const fieldValue = fieldReaders[i]();
result[`field${i}`] = fieldValue;
}
return result;
}
readVarIntUnsigned() {
const reader = this.reader;
let result = 0;
let shift = 0;
while (true) {
const byte = reader.u8();
result |= (byte & 0x7f) << shift;
if ((byte & 0x80) === 0)
break;
shift += 7;
if (shift >= 32) {
throw new Error('Variable-length integer is too long');
}
}
return result >>> 0;
}
readVarLong() {
const reader = this.reader;
let result = BigInt(0);
let shift = BigInt(0);
while (true) {
const byte = BigInt(reader.u8());
result |= (byte & BigInt(0x7f)) << shift;
if ((byte & BigInt(0x80)) === BigInt(0))
break;
shift += BigInt(7);
if (shift >= BigInt(64)) {
throw new Error('Variable-length long is too long');
}
}
return result;
}
decodeZigZag32(value) {
return (value >>> 1) ^ -(value & 1);
}
decodeZigZag64(value) {
return (value >> BigInt(1)) ^ -(value & BigInt(1));
}
}
exports.AvroDecoder = AvroDecoder;
//# sourceMappingURL=AvroDecoder.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AvroDecoder.js","sourceRoot":"","sources":["../../src/avro/AvroDecoder.ts"],"names":[],"mappings":";;;AAAA,4DAAuD;AAQvD,MAAa,WAAW;IAAxB;QACS,WAAM,GAAG,IAAI,eAAM,EAAE,CAAC;IA8O/B,CAAC;IA5OQ,IAAI,CAAC,KAAiB;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,KAAiB;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAKM,OAAO;QACZ,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;IACtG,CAAC;IAKM,QAAQ;QAEb,OAAO,IAAI,CAAC;IACd,CAAC;IAKM,WAAW;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;IAKM,OAAO;QACZ,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAKM,QAAQ;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAG5C,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,gBAAg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AAC,CAAC,IAAI,KAAK,CAAC;YAEzC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC;gBAAE,MAAM;YAE/C,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC;YACnB,IAAI,KAAK,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAKO,cAAc,CAAC,KAAa;QAClC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC;IAKO,cAAc,CAAC,KAAa;QAClC,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;CACF;AA/OD,kCA+OC"}

View File

@@ -0,0 +1,30 @@
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/buffers/lib';
import type { BinaryJsonEncoder } from '../types';
export declare class AvroEncoder implements BinaryJsonEncoder {
readonly writer: IWriter & IWriterGrowable;
constructor(writer: IWriter & IWriterGrowable);
encode(value: unknown): Uint8Array;
writeUnknown(value: unknown): void;
writeAny(value: unknown): void;
writeNull(): void;
writeBoolean(bool: boolean): void;
writeInt(int: number): void;
writeLong(long: number | bigint): void;
writeFloatAvro(float: number): void;
writeDouble(double: number): void;
writeBin(bytes: Uint8Array): void;
writeStr(str: string): void;
writeArr(arr: unknown[]): void;
writeObj(obj: Record<string, unknown>): void;
writeNumber(num: number): void;
writeInteger(int: number): void;
writeUInteger(uint: number): void;
writeFloat(float: number): void;
private writeFloatValue;
writeAsciiStr(str: string): void;
private writeVarIntSigned;
private writeVarIntUnsigned;
private writeVarLong;
private encodeZigZag32;
private encodeZigZag64;
}

View File

@@ -0,0 +1,190 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AvroEncoder = void 0;
class AvroEncoder {
constructor(writer) {
this.writer = writer;
}
encode(value) {
const writer = this.writer;
writer.reset();
this.writeAny(value);
return writer.flush();
}
writeUnknown(value) {
this.writeNull();
}
writeAny(value) {
switch (typeof value) {
case 'boolean':
return this.writeBoolean(value);
case 'number':
return this.writeNumber(value);
case 'string':
return this.writeStr(value);
case 'object': {
if (value === null)
return this.writeNull();
const constructor = value.constructor;
switch (constructor) {
case Object:
return this.writeObj(value);
case Array:
return this.writeArr(value);
case Uint8Array:
return this.writeBin(value);
default:
return this.writeUnknown(value);
}
}
case 'bigint':
return this.writeLong(value);
case 'undefined':
return this.writeNull();
default:
return this.writeUnknown(value);
}
}
writeNull() {
}
writeBoolean(bool) {
this.writer.u8(bool ? 1 : 0);
}
writeInt(int) {
this.writeVarIntSigned(this.encodeZigZag32(Math.trunc(int)));
}
writeLong(long) {
if (typeof long === 'bigint') {
this.writeVarLong(this.encodeZigZag64(long));
}
else {
this.writeVarLong(this.encodeZigZag64(BigInt(Math.trunc(long))));
}
}
writeFloatAvro(float) {
const writer = this.writer;
writer.ensureCapacity(4);
writer.view.setFloat32(writer.x, float, true);
writer.move(4);
}
writeDouble(double) {
const writer = this.writer;
writer.ensureCapacity(8);
writer.view.setFloat64(writer.x, double, true);
writer.move(8);
}
writeBin(bytes) {
this.writeVarIntUnsigned(bytes.length);
this.writer.buf(bytes, bytes.length);
}
writeStr(str) {
const writer = this.writer;
const maxSize = str.length * 4;
writer.ensureCapacity(5 + maxSize);
const lengthOffset = writer.x;
writer.x += 5;
const bytesWritten = writer.utf8(str);
const endPos = writer.x;
writer.x = lengthOffset;
this.writeVarIntUnsigned(bytesWritten);
const actualLengthSize = writer.x - lengthOffset;
if (actualLengthSize < 5) {
const stringStart = lengthOffset + 5;
const stringData = writer.uint8.slice(stringStart, endPos);
writer.x = lengthOffset + actualLengthSize;
writer.buf(stringData, stringData.length);
}
else {
writer.x = endPos;
}
}
writeArr(arr) {
this.writeVarIntUnsigned(arr.length);
const length = arr.length;
for (let i = 0; i < length; i++) {
this.writeAny(arr[i]);
}
this.writeVarIntUnsigned(0);
}
writeObj(obj) {
const entries = Object.entries(obj);
const length = entries.length;
this.writeVarIntUnsigned(length);
for (let i = 0; i < length; i++) {
const entry = entries[i];
this.writeStr(entry[0]);
this.writeAny(entry[1]);
}
this.writeVarIntUnsigned(0);
}
writeNumber(num) {
if (Number.isInteger(num)) {
if (num >= -2147483648 && num <= 2147483647) {
this.writeInt(num);
}
else {
this.writeLong(num);
}
}
else {
this.writeDouble(num);
}
}
writeInteger(int) {
this.writeInt(int);
}
writeUInteger(uint) {
this.writeInt(uint);
}
writeFloat(float) {
this.writeFloatValue(float);
}
writeFloatValue(float) {
const writer = this.writer;
writer.ensureCapacity(4);
writer.view.setFloat32(writer.x, float, true);
writer.move(4);
}
writeAsciiStr(str) {
const writer = this.writer;
this.writeVarIntUnsigned(str.length);
writer.ascii(str);
}
writeVarIntSigned(value) {
const writer = this.writer;
let n = value >>> 0;
while (n >= 0x80) {
writer.u8((n & 0x7f) | 0x80);
n >>>= 7;
}
writer.u8(n & 0x7f);
}
writeVarIntUnsigned(value) {
const writer = this.writer;
let n = value >>> 0;
while (n >= 0x80) {
writer.u8((n & 0x7f) | 0x80);
n >>>= 7;
}
writer.u8(n & 0x7f);
}
writeVarLong(value) {
const writer = this.writer;
let n = value;
const mask = BigInt(0x7f);
const shift = BigInt(7);
while (n >= BigInt(0x80)) {
writer.u8(Number((n & mask) | BigInt(0x80)));
n >>= shift;
}
writer.u8(Number(n & mask));
}
encodeZigZag32(value) {
return (value << 1) ^ (value >> 31);
}
encodeZigZag64(value) {
return (value << BigInt(1)) ^ (value >> BigInt(63));
}
}
exports.AvroEncoder = AvroEncoder;
//# sourceMappingURL=AvroEncoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,29 @@
import { Reader } from '@jsonjoy.com/buffers/lib/Reader';
import type { AvroSchema } from './types';
export declare class AvroSchemaDecoder {
readonly reader: Reader;
private decoder;
private validator;
private namedSchemas;
constructor(reader?: Reader);
decode(data: Uint8Array, schema: AvroSchema): unknown;
private readValue;
private readRecord;
private readEnum;
private readArray;
private readMap;
private readUnion;
private readFixed;
readNull(schema: AvroSchema): null;
readBoolean(schema: AvroSchema): boolean;
readInt(schema: AvroSchema): number;
readLong(schema: AvroSchema): number | bigint;
readFloat(schema: AvroSchema): number;
readDouble(schema: AvroSchema): number;
readBytes(schema: AvroSchema): Uint8Array;
readString(schema: AvroSchema): string;
private validateSchemaType;
private resolveSchema;
private collectNamedSchemas;
private getFullName;
}

View File

@@ -0,0 +1,190 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AvroSchemaDecoder = void 0;
const Reader_1 = require("@jsonjoy.com/buffers/lib/Reader");
const AvroDecoder_1 = require("./AvroDecoder");
const AvroSchemaValidator_1 = require("./AvroSchemaValidator");
class AvroSchemaDecoder {
constructor(reader = new Reader_1.Reader()) {
this.reader = reader;
this.namedSchemas = new Map();
this.decoder = new AvroDecoder_1.AvroDecoder();
this.decoder.reader = reader;
this.validator = new AvroSchemaValidator_1.AvroSchemaValidator();
}
decode(data, schema) {
this.reader.reset(data);
this.namedSchemas.clear();
if (!this.validator.validateSchema(schema)) {
throw new Error('Invalid Avro schema');
}
this.collectNamedSchemas(schema);
return this.readValue(schema);
}
readValue(schema) {
const resolvedSchema = this.resolveSchema(schema);
if (typeof resolvedSchema === 'string') {
switch (resolvedSchema) {
case 'null':
return this.decoder.readNull();
case 'boolean':
return this.decoder.readBoolean();
case 'int':
return this.decoder.readInt();
case 'long':
return this.decoder.readLong();
case 'float':
return this.decoder.readFloat();
case 'double':
return this.decoder.readDouble();
case 'bytes':
return this.decoder.readBytes();
case 'string':
return this.decoder.readString();
default:
throw new Error(`Unknown primitive type: ${resolvedSchema}`);
}
}
if (Array.isArray(resolvedSchema)) {
return this.readUnion(resolvedSchema);
}
switch (resolvedSchema.type) {
case 'record':
return this.readRecord(resolvedSchema);
case 'enum':
return this.readEnum(resolvedSchema);
case 'array':
return this.readArray(resolvedSchema);
case 'map':
return this.readMap(resolvedSchema);
case 'fixed':
return this.readFixed(resolvedSchema);
default:
throw new Error(`Unknown schema type: ${resolvedSchema.type}`);
}
}
readRecord(schema) {
const result = {};
for (let i = 0; i < schema.fields.length; i++) {
const field = schema.fields[i];
try {
result[field.name] = this.readValue(field.type);
}
catch (error) {
throw new Error(`Error reading field '${field.name}': ${error.message}`);
}
}
return result;
}
readEnum(schema) {
const index = this.decoder.readEnum();
if (index < 0 || index >= schema.symbols.length) {
throw new Error(`Invalid enum index ${index} for enum with ${schema.symbols.length} symbols`);
}
return schema.symbols[index];
}
readArray(schema) {
return this.decoder.readArray(() => this.readValue(schema.items));
}
readMap(schema) {
return this.decoder.readMap(() => this.readValue(schema.values));
}
readUnion(schema) {
const schemaReaders = schema.map((subSchema) => () => this.readValue(subSchema));
const result = this.decoder.readUnion(schemaReaders);
return result.value;
}
readFixed(schema) {
return this.decoder.readFixed(schema.size);
}
readNull(schema) {
this.validateSchemaType(schema, 'null');
return this.decoder.readNull();
}
readBoolean(schema) {
this.validateSchemaType(schema, 'boolean');
return this.decoder.readBoolean();
}
readInt(schema) {
this.validateSchemaType(schema, 'int');
const value = this.decoder.readInt();
if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
throw new Error('Decoded value is not a valid 32-bit integer');
}
return value;
}
readLong(schema) {
this.validateSchemaType(schema, 'long');
return this.decoder.readLong();
}
readFloat(schema) {
this.validateSchemaType(schema, 'float');
return this.decoder.readFloat();
}
readDouble(schema) {
this.validateSchemaType(schema, 'double');
return this.decoder.readDouble();
}
readBytes(schema) {
this.validateSchemaType(schema, 'bytes');
return this.decoder.readBytes();
}
readString(schema) {
this.validateSchemaType(schema, 'string');
return this.decoder.readString();
}
validateSchemaType(schema, expectedType) {
const resolvedSchema = this.resolveSchema(schema);
const actualType = typeof resolvedSchema === 'string'
? resolvedSchema
: Array.isArray(resolvedSchema)
? 'union'
: resolvedSchema.type;
if (actualType !== expectedType) {
throw new Error(`Expected schema type ${expectedType}, got ${actualType}`);
}
}
resolveSchema(schema) {
if (typeof schema === 'string') {
const namedSchema = this.namedSchemas.get(schema);
return namedSchema || schema;
}
return schema;
}
collectNamedSchemas(schema) {
if (typeof schema === 'string' || Array.isArray(schema)) {
return;
}
if (typeof schema === 'object' && schema !== null) {
switch (schema.type) {
case 'record':
const recordSchema = schema;
const recordFullName = this.getFullName(recordSchema.name, recordSchema.namespace);
this.namedSchemas.set(recordFullName, recordSchema);
recordSchema.fields.forEach((field) => this.collectNamedSchemas(field.type));
break;
case 'enum':
const enumSchema = schema;
const enumFullName = this.getFullName(enumSchema.name, enumSchema.namespace);
this.namedSchemas.set(enumFullName, enumSchema);
break;
case 'fixed':
const fixedSchema = schema;
const fixedFullName = this.getFullName(fixedSchema.name, fixedSchema.namespace);
this.namedSchemas.set(fixedFullName, fixedSchema);
break;
case 'array':
this.collectNamedSchemas(schema.items);
break;
case 'map':
this.collectNamedSchemas(schema.values);
break;
}
}
}
getFullName(name, namespace) {
return namespace ? `${namespace}.${name}` : name;
}
}
exports.AvroSchemaDecoder = AvroSchemaDecoder;
//# sourceMappingURL=AvroSchemaDecoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
import type { IWriter, IWriterGrowable } from '@jsonjoy.com/buffers/lib';
import type { AvroSchema, AvroRecordSchema, AvroEnumSchema, AvroArraySchema, AvroMapSchema, AvroUnionSchema, AvroFixedSchema, AvroNullSchema } from './types';
export declare class AvroSchemaEncoder {
readonly writer: IWriter & IWriterGrowable;
private encoder;
private validator;
private namedSchemas;
constructor(writer: IWriter & IWriterGrowable);
encode(value: unknown, schema: AvroSchema, selectedIndex?: number): Uint8Array;
writeNull(schema: AvroNullSchema | AvroSchema): void;
writeBoolean(value: boolean, schema: AvroSchema): void;
writeInt(value: number, schema: AvroSchema): void;
writeLong(value: number | bigint, schema: AvroSchema): void;
writeFloat(value: number, schema: AvroSchema): void;
writeDouble(value: number, schema: AvroSchema): void;
writeBytes(value: Uint8Array, schema: AvroSchema): void;
writeString(value: string, schema: AvroSchema): void;
writeRecord(value: Record<string, unknown>, schema: AvroRecordSchema): void;
writeEnum(value: string, schema: AvroEnumSchema): void;
writeArray(value: unknown[], schema: AvroArraySchema): void;
writeMap(value: Record<string, unknown>, schema: AvroMapSchema): void;
writeUnion(value: unknown, schema: AvroUnionSchema, selectedIndex?: number): void;
writeFixed(value: Uint8Array, schema: AvroFixedSchema): void;
writeNumber(value: number, schema: AvroSchema): void;
private writeValue;
private validateSchemaType;
private resolveSchema;
private collectNamedSchemas;
private getFullName;
private writeVarIntUnsigned;
private writeVarIntSigned;
private encodeZigZag32;
}

View File

@@ -0,0 +1,321 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AvroSchemaEncoder = void 0;
const AvroEncoder_1 = require("./AvroEncoder");
const AvroSchemaValidator_1 = require("./AvroSchemaValidator");
class AvroSchemaEncoder {
constructor(writer) {
this.writer = writer;
this.namedSchemas = new Map();
this.encoder = new AvroEncoder_1.AvroEncoder(writer);
this.validator = new AvroSchemaValidator_1.AvroSchemaValidator();
}
encode(value, schema, selectedIndex) {
this.writer.reset();
this.namedSchemas.clear();
if (!this.validator.validateSchema(schema)) {
throw new Error('Invalid Avro schema');
}
if (!this.validator.validateValue(value, schema)) {
throw new Error('Value does not conform to schema');
}
this.collectNamedSchemas(schema);
if (Array.isArray(schema) && selectedIndex !== undefined) {
this.writeUnion(value, schema, selectedIndex);
}
else {
this.writeValue(value, schema);
}
return this.writer.flush();
}
writeNull(schema) {
this.validateSchemaType(schema, 'null');
this.encoder.writeNull();
}
writeBoolean(value, schema) {
this.validateSchemaType(schema, 'boolean');
this.encoder.writeBoolean(value);
}
writeInt(value, schema) {
this.validateSchemaType(schema, 'int');
if (!Number.isInteger(value) || value < -2147483648 || value > 2147483647) {
throw new Error('Value is not a valid 32-bit integer');
}
this.encoder.writeInt(value);
}
writeLong(value, schema) {
this.validateSchemaType(schema, 'long');
this.encoder.writeLong(value);
}
writeFloat(value, schema) {
this.validateSchemaType(schema, 'float');
this.encoder.writeFloat(value);
}
writeDouble(value, schema) {
this.validateSchemaType(schema, 'double');
this.encoder.writeDouble(value);
}
writeBytes(value, schema) {
this.validateSchemaType(schema, 'bytes');
this.encoder.writeBin(value);
}
writeString(value, schema) {
this.validateSchemaType(schema, 'string');
this.encoder.writeStr(value);
}
writeRecord(value, schema) {
if (typeof schema === 'object' && schema.type !== 'record') {
throw new Error('Schema is not a record schema');
}
const recordSchema = this.resolveSchema(schema);
if (recordSchema.type !== 'record') {
throw new Error('Schema is not a record schema');
}
for (let i = 0; i < recordSchema.fields.length; i++) {
const field = recordSchema.fields[i];
const fieldValue = value[field.name];
if (fieldValue !== undefined) {
this.writeValue(fieldValue, field.type);
}
else if (field.default !== undefined) {
this.writeValue(field.default, field.type);
}
else {
throw new Error(`Missing required field: ${field.name}`);
}
}
}
writeEnum(value, schema) {
if (typeof schema === 'object' && schema.type !== 'enum') {
throw new Error('Schema is not an enum schema');
}
const enumSchema = this.resolveSchema(schema);
if (enumSchema.type !== 'enum') {
throw new Error('Schema is not an enum schema');
}
const index = enumSchema.symbols.indexOf(value);
if (index === -1) {
throw new Error(`Invalid enum value: ${value}`);
}
this.writeVarIntSigned(this.encodeZigZag32(index));
}
writeArray(value, schema) {
if (typeof schema === 'object' && schema.type !== 'array') {
throw new Error('Schema is not an array schema');
}
const arraySchema = this.resolveSchema(schema);
if (arraySchema.type !== 'array') {
throw new Error('Schema is not an array schema');
}
this.writeVarIntUnsigned(value.length);
const length = value.length;
for (let i = 0; i < length; i++) {
this.writeValue(value[i], arraySchema.items);
}
this.writeVarIntUnsigned(0);
}
writeMap(value, schema) {
if (typeof schema === 'object' && schema.type !== 'map') {
throw new Error('Schema is not a map schema');
}
const mapSchema = this.resolveSchema(schema);
if (mapSchema.type !== 'map') {
throw new Error('Schema is not a map schema');
}
const entries = Object.entries(value);
this.writeVarIntUnsigned(entries.length);
const length = entries.length;
for (let i = 0; i < length; i++) {
const entry = entries[i];
this.encoder.writeStr(entry[0]);
this.writeValue(entry[1], mapSchema.values);
}
this.writeVarIntUnsigned(0);
}
writeUnion(value, schema, selectedIndex) {
if (!Array.isArray(schema)) {
throw new Error('Schema is not a union schema');
}
let index = selectedIndex;
if (index === undefined) {
index = schema.findIndex((subSchema) => this.validator.validateValue(value, subSchema));
if (index === -1) {
throw new Error('Value does not match any schema in the union');
}
}
if (index < 0 || index >= schema.length) {
throw new Error('Invalid union index');
}
this.writeVarIntSigned(this.encodeZigZag32(index));
this.writeValue(value, schema[index]);
}
writeFixed(value, schema) {
if (typeof schema === 'object' && schema.type !== 'fixed') {
throw new Error('Schema is not a fixed schema');
}
const fixedSchema = this.resolveSchema(schema);
if (fixedSchema.type !== 'fixed') {
throw new Error('Schema is not a fixed schema');
}
if (value.length !== fixedSchema.size) {
throw new Error(`Fixed value length ${value.length} does not match schema size ${fixedSchema.size}`);
}
this.writer.buf(value, value.length);
}
writeNumber(value, schema) {
const resolvedSchema = this.resolveSchema(schema);
const schemaType = typeof resolvedSchema === 'string'
? resolvedSchema
: Array.isArray(resolvedSchema)
? 'union'
: resolvedSchema.type;
switch (schemaType) {
case 'int':
this.writeInt(value, schema);
break;
case 'long':
this.writeLong(value, schema);
break;
case 'float':
this.writeFloat(value, schema);
break;
case 'double':
this.writeDouble(value, schema);
break;
default:
throw new Error(`Schema type ${schemaType} is not a numeric type`);
}
}
writeValue(value, schema) {
const resolvedSchema = this.resolveSchema(schema);
if (typeof resolvedSchema === 'string') {
switch (resolvedSchema) {
case 'null':
this.encoder.writeNull();
break;
case 'boolean':
this.encoder.writeBoolean(value);
break;
case 'int':
this.encoder.writeInt(value);
break;
case 'long':
this.encoder.writeLong(value);
break;
case 'float':
this.encoder.writeFloat(value);
break;
case 'double':
this.encoder.writeDouble(value);
break;
case 'bytes':
this.encoder.writeBin(value);
break;
case 'string':
this.encoder.writeStr(value);
break;
default:
throw new Error(`Unknown primitive type: ${resolvedSchema}`);
}
return;
}
if (Array.isArray(resolvedSchema)) {
this.writeUnion(value, resolvedSchema);
return;
}
switch (resolvedSchema.type) {
case 'record':
this.writeRecord(value, resolvedSchema);
break;
case 'enum':
this.writeEnum(value, resolvedSchema);
break;
case 'array':
this.writeArray(value, resolvedSchema);
break;
case 'map':
this.writeMap(value, resolvedSchema);
break;
case 'fixed':
this.writeFixed(value, resolvedSchema);
break;
default:
throw new Error(`Unknown schema type: ${resolvedSchema.type}`);
}
}
validateSchemaType(schema, expectedType) {
const resolvedSchema = this.resolveSchema(schema);
const actualType = typeof resolvedSchema === 'string'
? resolvedSchema
: Array.isArray(resolvedSchema)
? 'union'
: resolvedSchema.type;
if (actualType !== expectedType) {
throw new Error(`Expected schema type ${expectedType}, got ${actualType}`);
}
}
resolveSchema(schema) {
if (typeof schema === 'string') {
const namedSchema = this.namedSchemas.get(schema);
return namedSchema || schema;
}
return schema;
}
collectNamedSchemas(schema) {
if (typeof schema === 'string' || Array.isArray(schema)) {
return;
}
if (typeof schema === 'object' && schema !== null) {
switch (schema.type) {
case 'record':
const recordSchema = schema;
const recordFullName = this.getFullName(recordSchema.name, recordSchema.namespace);
this.namedSchemas.set(recordFullName, recordSchema);
recordSchema.fields.forEach((field) => this.collectNamedSchemas(field.type));
break;
case 'enum':
const enumSchema = schema;
const enumFullName = this.getFullName(enumSchema.name, enumSchema.namespace);
this.namedSchemas.set(enumFullName, enumSchema);
break;
case 'fixed':
const fixedSchema = schema;
const fixedFullName = this.getFullName(fixedSchema.name, fixedSchema.namespace);
this.namedSchemas.set(fixedFullName, fixedSchema);
break;
case 'array':
this.collectNamedSchemas(schema.items);
break;
case 'map':
this.collectNamedSchemas(schema.values);
break;
}
}
}
getFullName(name, namespace) {
return namespace ? `${namespace}.${name}` : name;
}
writeVarIntUnsigned(value) {
const writer = this.writer;
let n = value >>> 0;
while (n >= 0x80) {
writer.u8((n & 0x7f) | 0x80);
n >>>= 7;
}
writer.u8(n & 0x7f);
}
writeVarIntSigned(value) {
const writer = this.writer;
let n = value >>> 0;
while (n >= 0x80) {
writer.u8((n & 0x7f) | 0x80);
n >>>= 7;
}
writer.u8(n & 0x7f);
}
encodeZigZag32(value) {
return (value << 1) ^ (value >> 31);
}
}
exports.AvroSchemaEncoder = AvroSchemaEncoder;
//# sourceMappingURL=AvroSchemaEncoder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,32 @@
import type { AvroSchema } from './types';
export declare class AvroSchemaValidator {
private namedSchemas;
validateSchema(schema: AvroSchema): boolean;
validateValue(value: unknown, schema: AvroSchema): boolean;
private validateSchemaInternal;
private validateStringSchema;
private validateUnionSchema;
private validateNullSchema;
private validateBooleanSchema;
private validateIntSchema;
private validateLongSchema;
private validateFloatSchema;
private validateDoubleSchema;
private validateBytesSchema;
private validateStringTypeSchema;
private validateRecordSchema;
private validateRecordField;
private validateEnumSchema;
private validateArraySchema;
private validateMapSchema;
private validateFixedSchema;
private validateValueAgainstSchema;
private validateValueAgainstStringSchema;
private validateValueAgainstRecord;
private validateValueAgainstEnum;
private validateValueAgainstArray;
private validateValueAgainstMap;
private validateValueAgainstFixed;
private getSchemaTypeName;
private getFullName;
}

View File

@@ -0,0 +1,260 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AvroSchemaValidator = void 0;
class AvroSchemaValidator {
constructor() {
this.namedSchemas = new Map();
}
validateSchema(schema) {
this.namedSchemas.clear();
return this.validateSchemaInternal(schema);
}
validateValue(value, schema) {
this.namedSchemas.clear();
this.validateSchemaInternal(schema);
return this.validateValueAgainstSchema(value, schema);
}
validateSchemaInternal(schema) {
if (typeof schema === 'string') {
return this.validateStringSchema(schema);
}
if (Array.isArray(schema)) {
return this.validateUnionSchema(schema);
}
if (typeof schema === 'object' && schema !== null) {
switch (schema.type) {
case 'null':
return this.validateNullSchema(schema);
case 'boolean':
return this.validateBooleanSchema(schema);
case 'int':
return this.validateIntSchema(schema);
case 'long':
return this.validateLongSchema(schema);
case 'float':
return this.validateFloatSchema(schema);
case 'double':
return this.validateDoubleSchema(schema);
case 'bytes':
return this.validateBytesSchema(schema);
case 'string':
return this.validateStringTypeSchema(schema);
case 'record':
return this.validateRecordSchema(schema);
case 'enum':
return this.validateEnumSchema(schema);
case 'array':
return this.validateArraySchema(schema);
case 'map':
return this.validateMapSchema(schema);
case 'fixed':
return this.validateFixedSchema(schema);
default:
return false;
}
}
return false;
}
validateStringSchema(schema) {
const primitiveTypes = ['null', 'boolean', 'int', 'long', 'float', 'double', 'bytes', 'string'];
return primitiveTypes.includes(schema) || this.namedSchemas.has(schema);
}
validateUnionSchema(schema) {
if (schema.length === 0)
return false;
const typeSet = new Set();
for (const subSchema of schema) {
if (!this.validateSchemaInternal(subSchema))
return false;
const typeName = this.getSchemaTypeName(subSchema);
if (typeSet.has(typeName))
return false;
typeSet.add(typeName);
}
return true;
}
validateNullSchema(schema) {
return schema.type === 'null';
}
validateBooleanSchema(schema) {
return schema.type === 'boolean';
}
validateIntSchema(schema) {
return schema.type === 'int';
}
validateLongSchema(schema) {
return schema.type === 'long';
}
validateFloatSchema(schema) {
return schema.type === 'float';
}
validateDoubleSchema(schema) {
return schema.type === 'double';
}
validateBytesSchema(schema) {
return schema.type === 'bytes';
}
validateStringTypeSchema(schema) {
return schema.type === 'string';
}
validateRecordSchema(schema) {
if (schema.type !== 'record' || !schema.name || !Array.isArray(schema.fields))
return false;
const fullName = this.getFullName(schema.name, schema.namespace);
if (this.namedSchemas.has(fullName))
return false;
this.namedSchemas.set(fullName, schema);
const fieldNames = new Set();
for (const field of schema.fields) {
if (!this.validateRecordField(field))
return false;
if (fieldNames.has(field.name))
return false;
fieldNames.add(field.name);
}
return true;
}
validateRecordField(field) {
return typeof field.name === 'string' && field.name.length > 0 && this.validateSchemaInternal(field.type);
}
validateEnumSchema(schema) {
if (schema.type !== 'enum' || !schema.name || !Array.isArray(schema.symbols))
return false;
const fullName = this.getFullName(schema.name, schema.namespace);
if (this.namedSchemas.has(fullName))
return false;
this.namedSchemas.set(fullName, schema);
if (schema.symbols.length === 0)
return false;
const symbolSet = new Set();
for (const symbol of schema.symbols) {
if (typeof symbol !== 'string' || symbolSet.has(symbol))
return false;
symbolSet.add(symbol);
}
if (schema.default !== undefined && !schema.symbols.includes(schema.default))
return false;
return true;
}
validateArraySchema(schema) {
return schema.type === 'array' && this.validateSchemaInternal(schema.items);
}
validateMapSchema(schema) {
return schema.type === 'map' && this.validateSchemaInternal(schema.values);
}
validateFixedSchema(schema) {
if (schema.type !== 'fixed' || !schema.name || typeof schema.size !== 'number')
return false;
if (schema.size < 0)
return false;
const fullName = this.getFullName(schema.name, schema.namespace);
if (this.namedSchemas.has(fullName))
return false;
this.namedSchemas.set(fullName, schema);
return true;
}
validateValueAgainstSchema(value, schema) {
if (typeof schema === 'string') {
return this.validateValueAgainstStringSchema(value, schema);
}
if (Array.isArray(schema)) {
return schema.some((subSchema) => this.validateValueAgainstSchema(value, subSchema));
}
if (typeof schema === 'object' && schema !== null) {
switch (schema.type) {
case 'null':
return value === null;
case 'boolean':
return typeof value === 'boolean';
case 'int':
return typeof value === 'number' && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;
case 'long':
return (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint';
case 'float':
case 'double':
return typeof value === 'number';
case 'bytes':
return value instanceof Uint8Array;
case 'string':
return typeof value === 'string';
case 'record':
return this.validateValueAgainstRecord(value, schema);
case 'enum':
return this.validateValueAgainstEnum(value, schema);
case 'array':
return this.validateValueAgainstArray(value, schema);
case 'map':
return this.validateValueAgainstMap(value, schema);
case 'fixed':
return this.validateValueAgainstFixed(value, schema);
default:
return false;
}
}
return false;
}
validateValueAgainstStringSchema(value, schema) {
switch (schema) {
case 'null':
return value === null;
case 'boolean':
return typeof value === 'boolean';
case 'int':
return typeof value === 'number' && Number.isInteger(value) && value >= -2147483648 && value <= 2147483647;
case 'long':
return (typeof value === 'number' && Number.isInteger(value)) || typeof value === 'bigint';
case 'float':
case 'double':
return typeof value === 'number';
case 'bytes':
return value instanceof Uint8Array;
case 'string':
return typeof value === 'string';
default:
const namedSchema = this.namedSchemas.get(schema);
return namedSchema ? this.validateValueAgainstSchema(value, namedSchema) : false;
}
}
validateValueAgainstRecord(value, schema) {
if (typeof value !== 'object' || value === null)
return false;
const obj = value;
for (const field of schema.fields) {
const fieldValue = obj[field.name];
if (fieldValue === undefined && field.default === undefined)
return false;
if (fieldValue !== undefined && !this.validateValueAgainstSchema(fieldValue, field.type))
return false;
}
return true;
}
validateValueAgainstEnum(value, schema) {
return typeof value === 'string' && schema.symbols.includes(value);
}
validateValueAgainstArray(value, schema) {
if (!Array.isArray(value))
return false;
return value.every((item) => this.validateValueAgainstSchema(item, schema.items));
}
validateValueAgainstMap(value, schema) {
if (typeof value !== 'object' || value === null)
return false;
const obj = value;
return Object.values(obj).every((val) => this.validateValueAgainstSchema(val, schema.values));
}
validateValueAgainstFixed(value, schema) {
return value instanceof Uint8Array && value.length === schema.size;
}
getSchemaTypeName(schema) {
if (typeof schema === 'string')
return schema;
if (Array.isArray(schema))
return 'union';
return schema.type;
}
getFullName(name, namespace) {
return namespace ? `${namespace}.${name}` : name;
}
}
exports.AvroSchemaValidator = AvroSchemaValidator;
//# sourceMappingURL=AvroSchemaValidator.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
export * from './types';
export * from './AvroSchemaValidator';
export * from './AvroEncoder';
export * from './AvroSchemaEncoder';
export * from './AvroDecoder';
export * from './AvroSchemaDecoder';

10
node_modules/@jsonjoy.com/json-pack/lib/avro/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./AvroSchemaValidator"), exports);
tslib_1.__exportStar(require("./AvroEncoder"), exports);
tslib_1.__exportStar(require("./AvroSchemaEncoder"), exports);
tslib_1.__exportStar(require("./AvroDecoder"), exports);
tslib_1.__exportStar(require("./AvroSchemaDecoder"), exports);
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/avro/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,gEAAsC;AACtC,wDAA8B;AAC9B,8DAAoC;AACpC,wDAA8B;AAC9B,8DAAoC"}

109
node_modules/@jsonjoy.com/json-pack/lib/avro/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,109 @@
export interface AvroBaseSchema {
type: string;
doc?: string;
[key: string]: any;
}
export interface AvroNullSchema extends AvroBaseSchema {
type: 'null';
}
export interface AvroBooleanSchema extends AvroBaseSchema {
type: 'boolean';
}
export interface AvroIntSchema extends AvroBaseSchema {
type: 'int';
}
export interface AvroLongSchema extends AvroBaseSchema {
type: 'long';
}
export interface AvroFloatSchema extends AvroBaseSchema {
type: 'float';
}
export interface AvroDoubleSchema extends AvroBaseSchema {
type: 'double';
}
export interface AvroBytesSchema extends AvroBaseSchema {
type: 'bytes';
}
export interface AvroStringSchema extends AvroBaseSchema {
type: 'string';
}
export interface AvroRecordField {
name: string;
type: AvroSchema;
doc?: string;
default?: any;
order?: 'ascending' | 'descending' | 'ignore';
aliases?: string[];
}
export interface AvroRecordSchema extends AvroBaseSchema {
type: 'record';
name: string;
namespace?: string;
fields: AvroRecordField[];
aliases?: string[];
}
export interface AvroEnumSchema extends AvroBaseSchema {
type: 'enum';
name: string;
namespace?: string;
symbols: string[];
default?: string;
aliases?: string[];
}
export interface AvroArraySchema extends AvroBaseSchema {
type: 'array';
items: AvroSchema;
}
export interface AvroMapSchema extends AvroBaseSchema {
type: 'map';
values: AvroSchema;
}
export interface AvroUnionSchema extends Array<AvroSchema> {
}
export interface AvroFixedSchema extends AvroBaseSchema {
type: 'fixed';
name: string;
namespace?: string;
size: number;
aliases?: string[];
}
export type AvroPrimitiveSchema = AvroNullSchema | AvroBooleanSchema | AvroIntSchema | AvroLongSchema | AvroFloatSchema | AvroDoubleSchema | AvroBytesSchema | AvroStringSchema;
export type AvroComplexSchema = AvroRecordSchema | AvroEnumSchema | AvroArraySchema | AvroMapSchema | AvroUnionSchema | AvroFixedSchema;
export type AvroSchema = AvroPrimitiveSchema | AvroComplexSchema | string;
export type AvroNamedSchema = AvroRecordSchema | AvroEnumSchema | AvroFixedSchema;
export interface AvroLogicalTypeSchema extends AvroBaseSchema {
logicalType: string;
}
export interface AvroDecimalLogicalType extends AvroLogicalTypeSchema {
logicalType: 'decimal';
precision: number;
scale?: number;
}
export interface AvroUuidLogicalType extends AvroStringSchema {
logicalType: 'uuid';
}
export interface AvroDateLogicalType extends AvroIntSchema {
logicalType: 'date';
}
export interface AvroTimeMillisLogicalType extends AvroIntSchema {
logicalType: 'time-millis';
}
export interface AvroTimeMicrosLogicalType extends AvroLongSchema {
logicalType: 'time-micros';
}
export interface AvroTimestampMillisLogicalType extends AvroLongSchema {
logicalType: 'timestamp-millis';
}
export interface AvroTimestampMicrosLogicalType extends AvroLongSchema {
logicalType: 'timestamp-micros';
}
export interface AvroLocalTimestampMillisLogicalType extends AvroLongSchema {
logicalType: 'local-timestamp-millis';
}
export interface AvroLocalTimestampMicrosLogicalType extends AvroLongSchema {
logicalType: 'local-timestamp-micros';
}
export interface AvroDurationLogicalType extends AvroFixedSchema {
logicalType: 'duration';
size: 12;
}

View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/avro/types.ts"],"names":[],"mappings":""}