diff --git a/package.json b/package.json index d5f3859f7a..4930aa96d6 100644 --- a/package.json +++ b/package.json @@ -144,7 +144,7 @@ "ot-text-unicode": "^4.0.0", "p4-css": "^1.5.1", "pako": "^2.0.4", - "prettier": "^2.6.2", + "prettier": "^3.2.5", "pretty-quick": "^3.1.3", "quill-delta": "^5.0.0", "react": "^18.2.0", diff --git a/src/json-block/Block.ts b/src/json-block/Block.ts index d9dc05cdcc..562247ba21 100644 --- a/src/json-block/Block.ts +++ b/src/json-block/Block.ts @@ -20,7 +20,10 @@ export interface BlockModel { export class BasicBlock { public v$: BehaviorSubject; - constructor(version: number, public readonly model: BlockModel) { + constructor( + version: number, + public readonly model: BlockModel, + ) { this.v$ = new BehaviorSubject(version); } diff --git a/src/json-cli/routes/crdt.ts b/src/json-cli/routes/crdt.ts index 959bb7f451..a16355ffef 100644 --- a/src/json-cli/routes/crdt.ts +++ b/src/json-cli/routes/crdt.ts @@ -55,8 +55,8 @@ export const defineCrdtRoutes = >(r: ObjectValue< const model = serverClock ? Model.withServerClock() : sid !== undefined - ? Model.withLogicalClock(sid) - : Model.withLogicalClock(); + ? Model.withLogicalClock(sid) + : Model.withLogicalClock(); if (value !== undefined) model.api.root(value); const patch = model.api.flush(); const patchEncoded = patch && patch.ops.length ? encodePatch(patch) : null; diff --git a/src/json-crdt-patch/builder/schema.ts b/src/json-crdt-patch/builder/schema.ts index bf4e303eb0..5e63ec4d49 100644 --- a/src/json-crdt-patch/builder/schema.ts +++ b/src/json-crdt-patch/builder/schema.ts @@ -139,7 +139,10 @@ export namespace nodes { > extends NodeBuilder { public readonly type = 'obj'; - constructor(public readonly obj: T, public readonly opt?: O) { + constructor( + public readonly obj: T, + public readonly opt?: O, + ) { super((builder) => { const objId = builder.obj(); const keyValuePairs: [key: string, value: ITimestampStruct][] = []; diff --git a/src/json-crdt-patch/clock/clock.ts b/src/json-crdt-patch/clock/clock.ts index d3e4b0591c..7af5a11a2a 100644 --- a/src/json-crdt-patch/clock/clock.ts +++ b/src/json-crdt-patch/clock/clock.ts @@ -2,11 +2,18 @@ import {SESSION} from '../constants'; import type {IClock, IClockVector, ITimestampStruct, ITimespanStruct} from './types'; export class Timestamp implements ITimestampStruct { - constructor(public readonly sid: number, public time: number) {} + constructor( + public readonly sid: number, + public time: number, + ) {} } export class Timespan implements ITimespanStruct { - constructor(public readonly sid: number, public time: number, public span: number) {} + constructor( + public readonly sid: number, + public time: number, + public span: number, + ) {} } /** diff --git a/src/json-crdt-patch/codec/clock/ClockEncoder.ts b/src/json-crdt-patch/codec/clock/ClockEncoder.ts index c07567de7b..1391942a05 100644 --- a/src/json-crdt-patch/codec/clock/ClockEncoder.ts +++ b/src/json-crdt-patch/codec/clock/ClockEncoder.ts @@ -2,7 +2,10 @@ import {ITimestampStruct, IClockVector, tick, Timestamp} from '../../clock'; import {RelativeTimestamp} from './RelativeTimestamp'; class ClockTableEntry { - constructor(public index: number, public clock: ITimestampStruct) {} + constructor( + public index: number, + public clock: ITimestampStruct, + ) {} } export class ClockEncoder { diff --git a/src/json-crdt-patch/codec/clock/ClockTable.ts b/src/json-crdt-patch/codec/clock/ClockTable.ts index 0c2e9c38ee..9d3e04d19f 100644 --- a/src/json-crdt-patch/codec/clock/ClockTable.ts +++ b/src/json-crdt-patch/codec/clock/ClockTable.ts @@ -3,7 +3,10 @@ import {CrdtReader} from '../../util/binary/CrdtReader'; import {CrdtWriter} from '../../util/binary/CrdtWriter'; export class ClockTableEntry { - constructor(public index: number, public id: ITimestampStruct) {} + constructor( + public index: number, + public id: ITimestampStruct, + ) {} } export class ClockTable { diff --git a/src/json-crdt-patch/codec/clock/RelativeTimestamp.ts b/src/json-crdt-patch/codec/clock/RelativeTimestamp.ts index 3aaaa8ed8c..037c35eb99 100644 --- a/src/json-crdt-patch/codec/clock/RelativeTimestamp.ts +++ b/src/json-crdt-patch/codec/clock/RelativeTimestamp.ts @@ -8,5 +8,8 @@ export class RelativeTimestamp { * @param sessionIndex Index of the clock in clock table. * @param timeDiff Time difference relative to the clock time from the table. */ - public constructor(public readonly sessionIndex: number, public readonly timeDiff: number) {} + public constructor( + public readonly sessionIndex: number, + public readonly timeDiff: number, + ) {} } diff --git a/src/json-crdt-patch/operations.ts b/src/json-crdt-patch/operations.ts index 414dbcae78..b21470b9e6 100644 --- a/src/json-crdt-patch/operations.ts +++ b/src/json-crdt-patch/operations.ts @@ -7,7 +7,10 @@ import {type ITimestampStruct, type ITimespanStruct, Timestamp, toDisplayString} * @category Operations */ export class NewConOp implements IJsonCrdtPatchOperation { - constructor(public readonly id: ITimestampStruct, public readonly val: unknown | undefined | ITimestampStruct) {} + constructor( + public readonly id: ITimestampStruct, + public readonly val: unknown | undefined | ITimestampStruct, + ) {} public span(): number { return 1; @@ -23,10 +26,10 @@ export class NewConOp implements IJsonCrdtPatchOperation { val instanceof Timestamp ? `{ ${toDisplayString(val)} }` : val instanceof Uint8Array - ? val.length < 13 - ? `Uint8Array { ${('' + val).replaceAll(',', ', ')} }` - : `Uint8Array(${val.length})` - : `{ ${JSON.stringify(val)} }`; + ? val.length < 13 + ? `Uint8Array { ${('' + val).replaceAll(',', ', ')} }` + : `Uint8Array(${val.length})` + : `{ ${JSON.stringify(val)} }`; return `${this.name()} ${toDisplayString(this.id)} ${valFormatted}`; } } @@ -385,7 +388,10 @@ export class DelOp implements IJsonCrdtPatchEditOperation { * @category Operations */ export class NopOp implements IJsonCrdtPatchOperation { - constructor(public readonly id: ITimestampStruct, public readonly len: number) {} + constructor( + public readonly id: ITimestampStruct, + public readonly len: number, + ) {} public span(): number { return this.len; diff --git a/src/json-crdt/__tests__/fuzzer/SessionLogical.ts b/src/json-crdt/__tests__/fuzzer/SessionLogical.ts index 21cac3cf0e..eb2d749807 100644 --- a/src/json-crdt/__tests__/fuzzer/SessionLogical.ts +++ b/src/json-crdt/__tests__/fuzzer/SessionLogical.ts @@ -43,7 +43,10 @@ export class SessionLogical { public readonly debug = false; - public constructor(public fuzzer: JsonCrdtFuzzer, public concurrency: number) { + public constructor( + public fuzzer: JsonCrdtFuzzer, + public concurrency: number, + ) { if (this.debug) this.modelStart = jsonEncoder.encode(fuzzer.model); for (let i = 0; i < concurrency; i++) { const model = fuzzer.model.fork(); diff --git a/src/json-crdt/file/File.ts b/src/json-crdt/file/File.ts index 56e7157b9f..6dcbd44ef9 100644 --- a/src/json-crdt/file/File.ts +++ b/src/json-crdt/file/File.ts @@ -67,7 +67,10 @@ export class File implements Printable { return new File(model, PatchLog.fromModel(model)); } - constructor(public readonly model: Model, public readonly log: PatchLog) {} + constructor( + public readonly model: Model, + public readonly log: PatchLog, + ) {} public apply(patch: Patch): void { const id = patch.getId(); diff --git a/src/json-crdt/model/api/fanout.ts b/src/json-crdt/model/api/fanout.ts index 6b2cdaed81..ae7eb3bc30 100644 --- a/src/json-crdt/model/api/fanout.ts +++ b/src/json-crdt/model/api/fanout.ts @@ -67,7 +67,10 @@ export class MicrotaskBufferFanOut extends FanOut { * Maps the data from a fanout using a mapper function. */ export class MapFanOut extends FanOut { - constructor(private readonly source: FanOut, private readonly mapper: (data: I) => O) { + constructor( + private readonly source: FanOut, + private readonly mapper: (data: I) => O, + ) { super(); } @@ -96,7 +99,10 @@ export class MapFanOut extends FanOut { export class OnNewFanOut extends FanOut { private unsub?: FanOutUnsubscribe = undefined; - constructor(private readonly source: FanOut, private last: D | undefined = undefined) { + constructor( + private readonly source: FanOut, + private last: D | undefined = undefined, + ) { super(); } diff --git a/src/json-crdt/model/api/nodes.ts b/src/json-crdt/model/api/nodes.ts index 5eea7b67ec..cb46e21ece 100644 --- a/src/json-crdt/model/api/nodes.ts +++ b/src/json-crdt/model/api/nodes.ts @@ -19,7 +19,10 @@ export type ApiPath = string | number | Path | void; * @category Local API */ export class NodeApi implements Printable { - constructor(public node: N, public readonly api: ModelApi) {} + constructor( + public node: N, + public readonly api: ModelApi, + ) {} /** @ignore */ private ev: undefined | NodeEvents = undefined; diff --git a/src/json-crdt/nodes/arr/ArrNode.ts b/src/json-crdt/nodes/arr/ArrNode.ts index 9897414f1d..be7cee4221 100644 --- a/src/json-crdt/nodes/arr/ArrNode.ts +++ b/src/json-crdt/nodes/arr/ArrNode.ts @@ -75,7 +75,10 @@ export class ArrNode extends AbstractRga implements JsonNode[]>, Printable { - constructor(public readonly doc: Model, id: ITimestampStruct) { + constructor( + public readonly doc: Model, + id: ITimestampStruct, + ) { super(id); } diff --git a/src/json-crdt/nodes/const/ConNode.ts b/src/json-crdt/nodes/const/ConNode.ts index 62c15a2d96..c729b856a8 100644 --- a/src/json-crdt/nodes/const/ConNode.ts +++ b/src/json-crdt/nodes/const/ConNode.ts @@ -17,7 +17,10 @@ export class ConNode implements JsonNode { (self as PickNode).regId === undefined ? '' : (self as PickNode).regId === -1 - ? '' - : ` [${(self as PickNode).regId}]`; + ? '' + : ` [${(self as PickNode).regId}]`; return `${indexFormatted} ${self.constructor.name}${registerFormatted}${children}`; }; diff --git a/src/json-pack/JsonPackExtension.ts b/src/json-pack/JsonPackExtension.ts index 81ab8bbb73..e21ca138ae 100644 --- a/src/json-pack/JsonPackExtension.ts +++ b/src/json-pack/JsonPackExtension.ts @@ -7,5 +7,8 @@ * @category Value */ export class JsonPackExtension { - constructor(public readonly tag: number, public readonly val: T) {} + constructor( + public readonly tag: number, + public readonly val: T, + ) {} } diff --git a/src/json-pack/__bench__/profiler/slices.ts b/src/json-pack/__bench__/profiler/slices.ts index f34be18751..32c8881ecd 100644 --- a/src/json-pack/__bench__/profiler/slices.ts +++ b/src/json-pack/__bench__/profiler/slices.ts @@ -8,7 +8,11 @@ const arr3 = Buffer.allocUnsafe(1024 * 4); const FastBuffer = (Buffer as any)[Symbol.species] as any; class Slice { - constructor(public uint8: ArrayBuffer, public start: number, public end: number) {} + constructor( + public uint8: ArrayBuffer, + public start: number, + public end: number, + ) {} } const res = { diff --git a/src/json-pack/__bench__/profiler/truncate.ts b/src/json-pack/__bench__/profiler/truncate.ts index 606d43f7b4..8c8b0e9e3f 100644 --- a/src/json-pack/__bench__/profiler/truncate.ts +++ b/src/json-pack/__bench__/profiler/truncate.ts @@ -2,7 +2,11 @@ const i = 10000; class MySlice { - constructor(public uint8: ArrayBuffer, public start: number, public end: number) {} + constructor( + public uint8: ArrayBuffer, + public start: number, + public end: number, + ) {} } console.time('new Slice()'); diff --git a/src/json-pack/bson/values.ts b/src/json-pack/bson/values.ts index 84040c84e8..1ff8e6f6a5 100644 --- a/src/json-pack/bson/values.ts +++ b/src/json-pack/bson/values.ts @@ -1,9 +1,16 @@ export class BsonObjectId { - public constructor(public timestamp: number, public process: number, public counter: number) {} + public constructor( + public timestamp: number, + public process: number, + public counter: number, + ) {} } export class BsonDbPointer { - public constructor(public name: string, public id: BsonObjectId) {} + public constructor( + public name: string, + public id: BsonObjectId, + ) {} } export class BsonJavascriptCode { @@ -15,7 +22,10 @@ export class BsonSymbol { } export class BsonJavascriptCodeWithScope { - public constructor(public code: string, public scope: Record) {} + public constructor( + public code: string, + public scope: Record, + ) {} } export class BsonInt32 { @@ -31,7 +41,10 @@ export class BsonFloat { } export class BsonTimestamp { - public constructor(public increment: number, public timestamp: number) {} + public constructor( + public increment: number, + public timestamp: number, + ) {} } export class BsonDecimal128 { @@ -43,5 +56,8 @@ export class BsonMinKey {} export class BsonMaxKey {} export class BsonBinary { - public constructor(public subtype: number, public data: Uint8Array) {} + public constructor( + public subtype: number, + public data: Uint8Array, + ) {} } diff --git a/src/json-pack/cbor/__tests__/cbor-js.spec.ts b/src/json-pack/cbor/__tests__/cbor-js.spec.ts index f7283494ca..2c797bb3a8 100644 --- a/src/json-pack/cbor/__tests__/cbor-js.spec.ts +++ b/src/json-pack/cbor/__tests__/cbor-js.spec.ts @@ -28,8 +28,8 @@ const run = (encoder: CborEncoder, decoder: CborDecoder) => { decoded2 instanceof JsonPackExtension ? decoded2.val : decoded2 instanceof JsonPackValue - ? decoded2.val - : decoded2; + ? decoded2.val + : decoded2; expect(resultValue).toStrictEqual(value); } else { expect(() => decoder.decode(hex2arrayBuffer(expected))).toThrow(); diff --git a/src/json-pack/ion/Import.ts b/src/json-pack/ion/Import.ts index 01e443e6b7..cf240d53e6 100644 --- a/src/json-pack/ion/Import.ts +++ b/src/json-pack/ion/Import.ts @@ -6,7 +6,10 @@ export class Import { public length: number; protected readonly byText = new Map(); - constructor(public readonly parent: Import | null, public readonly symbols: SymbolTable) { + constructor( + public readonly parent: Import | null, + public readonly symbols: SymbolTable, + ) { this.offset = parent ? parent.offset + parent.length : 1; this.length = symbols.length; for (let i = 0; i < symbols.length; i++) { diff --git a/src/json-pack/ion/ast.ts b/src/json-pack/ion/ast.ts index 9d533a291a..9c56309f9e 100644 --- a/src/json-pack/ion/ast.ts +++ b/src/json-pack/ion/ast.ts @@ -141,7 +141,10 @@ export class ObjAstNode implements AstNode> | null> export class AnnotationAstNode implements AstNode> { public readonly len: number; public readonly annotationLen: number; - constructor(public readonly val: AstNode, public readonly annotations: number[]) { + constructor( + public readonly val: AstNode, + public readonly annotations: number[], + ) { let len = 0; for (let i = 0; i < annotations.length; i++) len += vUintLen(annotations[i]); this.annotationLen = len; diff --git a/src/json-pack/json/JsonEncoder.ts b/src/json-pack/json/JsonEncoder.ts index 1506d46b56..f20daf3d03 100644 --- a/src/json-pack/json/JsonEncoder.ts +++ b/src/json-pack/json/JsonEncoder.ts @@ -74,7 +74,8 @@ export class JsonEncoder implements BinaryJsonEncoder, StreamingBinaryJsonEncode } public writeBoolean(bool: boolean): void { - if (bool) this.writer.u32(0x74727565); // true + if (bool) + this.writer.u32(0x74727565); // true else this.writer.u8u32(0x66, 0x616c7365); // false } diff --git a/src/json-pack/msgpack/MsgPackDecoder.ts b/src/json-pack/msgpack/MsgPackDecoder.ts index 44bf199f2a..7da9929bed 100644 --- a/src/json-pack/msgpack/MsgPackDecoder.ts +++ b/src/json-pack/msgpack/MsgPackDecoder.ts @@ -42,15 +42,15 @@ export class MsgPackDecoder extends MsgPackDecoderFast { ? 1 + this.skip(4) // f32 : 1 + 1 + 4 + this.skip(this.reader.u32()) // ext32 : byte === 0xcc - ? 1 + this.skip(1) // u8 - : 1 + this.skip(8) // f64 + ? 1 + this.skip(1) // u8 + : 1 + this.skip(8) // f64 : byte <= 0xce - ? byte === 0xce - ? 1 + this.skip(4) // u32 - : 1 + this.skip(2) // u16 - : byte === 0xd0 - ? 1 + this.skip(1) // i8 - : 1 + this.skip(8); // u64 + ? byte === 0xce + ? 1 + this.skip(4) // u32 + : 1 + this.skip(2) // u16 + : byte === 0xd0 + ? 1 + this.skip(1) // i8 + : 1 + this.skip(8); // u64 } } else if (byte <= 0xd8) { return byte <= 0xd4 @@ -59,15 +59,15 @@ export class MsgPackDecoder extends MsgPackDecoderFast { ? 1 + this.skip(4) // i32 : 1 + this.skip(2) // i16 : byte === 0xd4 - ? 1 + this.skip(2) // ext1 - : 1 + this.skip(8) // i64 + ? 1 + this.skip(2) // ext1 + : 1 + this.skip(8) // i64 : byte <= 0xd6 - ? byte === 0xd6 - ? 1 + this.skip(5) // ext4 - : 1 + this.skip(3) // ext2 - : byte === 0xd8 - ? 1 + this.skip(17) // ext16 - : 1 + this.skip(9); // ext8 + ? byte === 0xd6 + ? 1 + this.skip(5) // ext4 + : 1 + this.skip(3) // ext2 + : byte === 0xd8 + ? 1 + this.skip(17) // ext16 + : 1 + this.skip(9); // ext8 } else { switch (byte) { case 0xd9: diff --git a/src/json-pack/msgpack/MsgPackDecoderFast.ts b/src/json-pack/msgpack/MsgPackDecoderFast.ts index 9b117f57b7..2cb4ab1781 100644 --- a/src/json-pack/msgpack/MsgPackDecoderFast.ts +++ b/src/json-pack/msgpack/MsgPackDecoderFast.ts @@ -54,15 +54,15 @@ export class MsgPackDecoderFast implements BinaryJsonDecoder { ? reader.f32() : this.ext(reader.u32()) : byte === 0xcc - ? reader.u8() - : reader.f64() + ? reader.u8() + : reader.f64() : byte <= 0xce - ? byte === 0xce - ? reader.u32() - : reader.u16() - : byte === 0xd0 - ? reader.i8() - : reader.u32() * 4294967296 + reader.u32(); + ? byte === 0xce + ? reader.u32() + : reader.u16() + : byte === 0xd0 + ? reader.i8() + : reader.u32() * 4294967296 + reader.u32(); } } else if (byte <= 0xd8) { return byte <= 0xd4 @@ -71,15 +71,15 @@ export class MsgPackDecoderFast implements BinaryJsonDecoder { ? reader.i32() : reader.i16() : byte === 0xd4 - ? this.ext(1) - : reader.i32() * 4294967296 + reader.u32() + ? this.ext(1) + : reader.i32() * 4294967296 + reader.u32() : byte <= 0xd6 - ? byte === 0xd6 - ? this.ext(4) - : this.ext(2) - : byte === 0xd8 - ? this.ext(16) - : this.ext(8); + ? byte === 0xd6 + ? this.ext(4) + : this.ext(2) + : byte === 0xd8 + ? this.ext(16) + : this.ext(8); } else { switch (byte) { case 0xd9: diff --git a/src/json-pack/msgpack/MsgPackToJsonConverter.ts b/src/json-pack/msgpack/MsgPackToJsonConverter.ts index f8c4c0c9f8..fa60d6edc3 100644 --- a/src/json-pack/msgpack/MsgPackToJsonConverter.ts +++ b/src/json-pack/msgpack/MsgPackToJsonConverter.ts @@ -62,15 +62,15 @@ export class MsgPackToJsonConverter { ? this.f32().toString() : this.ext(this.u32()) : byte === 0xcc - ? this.u8().toString() - : this.f64().toString() + ? this.u8().toString() + : this.f64().toString() : byte <= 0xce - ? byte === 0xce - ? this.u32().toString() - : this.u16().toString() - : byte === 0xd0 - ? this.i8().toString() - : (this.u32() * 4294967296 + this.u32()).toString(); + ? byte === 0xce + ? this.u32().toString() + : this.u16().toString() + : byte === 0xd0 + ? this.i8().toString() + : (this.u32() * 4294967296 + this.u32()).toString(); } } else if (byte <= 0xd8) { return byte <= 0xd4 @@ -79,15 +79,15 @@ export class MsgPackToJsonConverter { ? this.i32().toString() : this.i16().toString() : byte === 0xd4 - ? this.ext(1) - : (this.i32() * 4294967296 + this.i32()).toString() + ? this.ext(1) + : (this.i32() * 4294967296 + this.i32()).toString() : byte <= 0xd6 - ? byte === 0xd6 - ? this.ext(4) - : this.ext(2) - : byte === 0xd8 - ? this.ext(16) - : this.ext(8); + ? byte === 0xd6 + ? this.ext(4) + : this.ext(2) + : byte === 0xd8 + ? this.ext(16) + : this.ext(8); } else { switch (byte) { case 0xd9: diff --git a/src/json-patch/op/AbstractSecondOrderPredicateOp.ts b/src/json-patch/op/AbstractSecondOrderPredicateOp.ts index f879f1e171..9e07adc850 100644 --- a/src/json-patch/op/AbstractSecondOrderPredicateOp.ts +++ b/src/json-patch/op/AbstractSecondOrderPredicateOp.ts @@ -3,7 +3,10 @@ import type {Path} from '../../json-pointer'; import {AbstractPredicateOp} from './AbstractPredicateOp'; export abstract class AbstractSecondOrderPredicateOp extends AbstractPredicateOp { - constructor(path: Path, public readonly ops: AbstractPredicateOp[]) { + constructor( + path: Path, + public readonly ops: AbstractPredicateOp[], + ) { super(path); } } diff --git a/src/json-patch/op/OpAdd.ts b/src/json-patch/op/OpAdd.ts index 01d0889b12..b43b738912 100644 --- a/src/json-patch/op/OpAdd.ts +++ b/src/json-patch/op/OpAdd.ts @@ -10,7 +10,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch */ export class OpAdd extends AbstractOp<'add'> { - constructor(path: Path, public readonly value: unknown) { + constructor( + path: Path, + public readonly value: unknown, + ) { super(path); } diff --git a/src/json-patch/op/OpAnd.ts b/src/json-patch/op/OpAnd.ts index e36000d3c6..d5bb76d7b3 100644 --- a/src/json-patch/op/OpAnd.ts +++ b/src/json-patch/op/OpAnd.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpAnd extends AbstractSecondOrderPredicateOp<'and'> { - constructor(path: Path, public readonly ops: AbstractPredicateOp[]) { + constructor( + path: Path, + public readonly ops: AbstractPredicateOp[], + ) { super(path, ops); } diff --git a/src/json-patch/op/OpContains.ts b/src/json-patch/op/OpContains.ts index e159e4d9f5..94d33ff41d 100644 --- a/src/json-patch/op/OpContains.ts +++ b/src/json-patch/op/OpContains.ts @@ -11,7 +11,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; */ export class OpContains extends AbstractPredicateOp<'contains'> { // tslint:disable-next-line variable-name - constructor(path: Path, public readonly value: string, public readonly ignore_case: boolean) { + constructor( + path: Path, + public readonly value: string, + public readonly ignore_case: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpCopy.ts b/src/json-patch/op/OpCopy.ts index d54e388dd3..340b67e32b 100644 --- a/src/json-patch/op/OpCopy.ts +++ b/src/json-patch/op/OpCopy.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch */ export class OpCopy extends AbstractOp<'copy'> { - constructor(path: Path, public readonly from: Path) { + constructor( + path: Path, + public readonly from: Path, + ) { super(path); } diff --git a/src/json-patch/op/OpEnds.ts b/src/json-patch/op/OpEnds.ts index 6665c80b77..206edfe56d 100644 --- a/src/json-patch/op/OpEnds.ts +++ b/src/json-patch/op/OpEnds.ts @@ -11,7 +11,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; */ export class OpEnds extends AbstractPredicateOp<'ends'> { // tslint:disable-next-line variable-name - constructor(path: Path, public readonly value: string, public readonly ignore_case: boolean) { + constructor( + path: Path, + public readonly value: string, + public readonly ignore_case: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpExtend.ts b/src/json-patch/op/OpExtend.ts index 074be98ff1..a4de9b747a 100644 --- a/src/json-patch/op/OpExtend.ts +++ b/src/json-patch/op/OpExtend.ts @@ -11,7 +11,11 @@ const {isArray} = Array; * @category JSON Patch Extended */ export class OpExtend extends AbstractOp<'extend'> { - constructor(path: Path, public readonly props: Record, public readonly deleteNull: boolean) { + constructor( + path: Path, + public readonly props: Record, + public readonly deleteNull: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpIn.ts b/src/json-patch/op/OpIn.ts index 99917965e1..2b520abe10 100644 --- a/src/json-patch/op/OpIn.ts +++ b/src/json-patch/op/OpIn.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpIn extends AbstractPredicateOp<'in'> { - constructor(path: Path, public readonly value: unknown[]) { + constructor( + path: Path, + public readonly value: unknown[], + ) { super(path); } diff --git a/src/json-patch/op/OpInc.ts b/src/json-patch/op/OpInc.ts index 6e82d24c9e..74f1acf6c0 100644 --- a/src/json-patch/op/OpInc.ts +++ b/src/json-patch/op/OpInc.ts @@ -9,7 +9,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch Extended */ export class OpInc extends AbstractOp<'inc'> { - constructor(path: Path, public readonly inc: number) { + constructor( + path: Path, + public readonly inc: number, + ) { super(path); } diff --git a/src/json-patch/op/OpLess.ts b/src/json-patch/op/OpLess.ts index 1bdf21136e..affe7307ea 100644 --- a/src/json-patch/op/OpLess.ts +++ b/src/json-patch/op/OpLess.ts @@ -10,7 +10,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpLess extends AbstractPredicateOp<'less'> { - constructor(path: Path, public readonly value: number) { + constructor( + path: Path, + public readonly value: number, + ) { super(path); } diff --git a/src/json-patch/op/OpMerge.ts b/src/json-patch/op/OpMerge.ts index 6fbd89d0f9..8a3b34336c 100644 --- a/src/json-patch/op/OpMerge.ts +++ b/src/json-patch/op/OpMerge.ts @@ -10,7 +10,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch Extended */ export class OpMerge extends AbstractOp<'merge'> { - constructor(path: Path, public readonly pos: number, public readonly props: object | null) { + constructor( + path: Path, + public readonly pos: number, + public readonly props: object | null, + ) { super(path); } diff --git a/src/json-patch/op/OpMore.ts b/src/json-patch/op/OpMore.ts index 025d39bef4..9c96eea25a 100644 --- a/src/json-patch/op/OpMore.ts +++ b/src/json-patch/op/OpMore.ts @@ -10,7 +10,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpMore extends AbstractPredicateOp<'more'> { - constructor(path: Path, public readonly value: number) { + constructor( + path: Path, + public readonly value: number, + ) { super(path); } diff --git a/src/json-patch/op/OpMove.ts b/src/json-patch/op/OpMove.ts index e231a25fb1..5e5d487d38 100644 --- a/src/json-patch/op/OpMove.ts +++ b/src/json-patch/op/OpMove.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch */ export class OpMove extends AbstractOp<'move'> { - constructor(path: Path, public readonly from: Path) { + constructor( + path: Path, + public readonly from: Path, + ) { super(path); } diff --git a/src/json-patch/op/OpNot.ts b/src/json-patch/op/OpNot.ts index 21919e9100..ae9dcfaf1a 100644 --- a/src/json-patch/op/OpNot.ts +++ b/src/json-patch/op/OpNot.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpNot extends AbstractSecondOrderPredicateOp<'not'> { - constructor(path: Path, public readonly ops: AbstractPredicateOp[]) { + constructor( + path: Path, + public readonly ops: AbstractPredicateOp[], + ) { super(path, ops); } diff --git a/src/json-patch/op/OpOr.ts b/src/json-patch/op/OpOr.ts index cbdd5f7241..c409b5eca8 100644 --- a/src/json-patch/op/OpOr.ts +++ b/src/json-patch/op/OpOr.ts @@ -11,7 +11,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpOr extends AbstractSecondOrderPredicateOp<'or'> { - constructor(path: Path, public readonly ops: AbstractPredicateOp[]) { + constructor( + path: Path, + public readonly ops: AbstractPredicateOp[], + ) { super(path, ops); } diff --git a/src/json-patch/op/OpRemove.ts b/src/json-patch/op/OpRemove.ts index 1f6874ef13..a5f9b53be8 100644 --- a/src/json-patch/op/OpRemove.ts +++ b/src/json-patch/op/OpRemove.ts @@ -9,7 +9,10 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch */ export class OpRemove extends AbstractOp<'remove'> { - constructor(path: Path, public readonly oldValue: unknown) { + constructor( + path: Path, + public readonly oldValue: unknown, + ) { super(path); } diff --git a/src/json-patch/op/OpReplace.ts b/src/json-patch/op/OpReplace.ts index 7476fbf208..1b6fa8695f 100644 --- a/src/json-patch/op/OpReplace.ts +++ b/src/json-patch/op/OpReplace.ts @@ -9,7 +9,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch */ export class OpReplace extends AbstractOp<'replace'> { - constructor(path: Path, public readonly value: unknown, public readonly oldValue: unknown) { + constructor( + path: Path, + public readonly value: unknown, + public readonly oldValue: unknown, + ) { super(path); } diff --git a/src/json-patch/op/OpSplit.ts b/src/json-patch/op/OpSplit.ts index 28a6fc9e1c..ea7256b392 100644 --- a/src/json-patch/op/OpSplit.ts +++ b/src/json-patch/op/OpSplit.ts @@ -12,7 +12,11 @@ type Composable = string | number | SlateNode; * @category JSON Patch Extended */ export class OpSplit extends AbstractOp<'split'> { - constructor(path: Path, public readonly pos: number, public readonly props: object | null) { + constructor( + path: Path, + public readonly pos: number, + public readonly props: object | null, + ) { super(path); } diff --git a/src/json-patch/op/OpStarts.ts b/src/json-patch/op/OpStarts.ts index 245ec521a1..ad77ab4c3e 100644 --- a/src/json-patch/op/OpStarts.ts +++ b/src/json-patch/op/OpStarts.ts @@ -11,7 +11,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; */ export class OpStarts extends AbstractPredicateOp<'starts'> { // tslint:disable-next-line variable-name - constructor(path: Path, public readonly value: string, public readonly ignore_case: boolean) { + constructor( + path: Path, + public readonly value: string, + public readonly ignore_case: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpStrIns.ts b/src/json-patch/op/OpStrIns.ts index 48be1f5cea..6d56ba259c 100644 --- a/src/json-patch/op/OpStrIns.ts +++ b/src/json-patch/op/OpStrIns.ts @@ -9,7 +9,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch Extended */ export class OpStrIns extends AbstractOp<'str_ins'> { - constructor(path: Path, public readonly pos: number, public readonly str: string) { + constructor( + path: Path, + public readonly pos: number, + public readonly str: string, + ) { super(path); } diff --git a/src/json-patch/op/OpTest.ts b/src/json-patch/op/OpTest.ts index aeef04e5f3..71e2d31e37 100644 --- a/src/json-patch/op/OpTest.ts +++ b/src/json-patch/op/OpTest.ts @@ -12,7 +12,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Predicate */ export class OpTest extends AbstractPredicateOp<'test'> { - constructor(path: Path, public readonly value: unknown, public readonly not: boolean) { + constructor( + path: Path, + public readonly value: unknown, + public readonly not: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpTestString.ts b/src/json-patch/op/OpTestString.ts index 0976fe8991..de7df7602f 100644 --- a/src/json-patch/op/OpTestString.ts +++ b/src/json-patch/op/OpTestString.ts @@ -10,7 +10,12 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch Extended */ export class OpTestString extends AbstractPredicateOp<'test_string'> { - constructor(path: Path, public readonly pos: number, public readonly str: string, public readonly not: boolean) { + constructor( + path: Path, + public readonly pos: number, + public readonly str: string, + public readonly not: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpTestStringLen.ts b/src/json-patch/op/OpTestStringLen.ts index 1272696426..5e302cf0ea 100644 --- a/src/json-patch/op/OpTestStringLen.ts +++ b/src/json-patch/op/OpTestStringLen.ts @@ -10,7 +10,11 @@ import type {IMessagePackEncoder} from '../../json-pack/msgpack'; * @category JSON Patch Extended */ export class OpTestStringLen extends AbstractPredicateOp<'test_string_len'> { - constructor(path: Path, public readonly len: number, public readonly not: boolean) { + constructor( + path: Path, + public readonly len: number, + public readonly not: boolean, + ) { super(path); } diff --git a/src/json-patch/op/OpTestType.ts b/src/json-patch/op/OpTestType.ts index 85125e8ab9..4ec5d2c93e 100644 --- a/src/json-patch/op/OpTestType.ts +++ b/src/json-patch/op/OpTestType.ts @@ -12,7 +12,10 @@ const {isArray} = Array; * @category JSON Predicate */ export class OpTestType extends AbstractPredicateOp<'test_type'> { - constructor(path: Path, public readonly type: JsonPatchTypes[]) { + constructor( + path: Path, + public readonly type: JsonPatchTypes[], + ) { super(path); } diff --git a/src/json-patch/op/OpType.ts b/src/json-patch/op/OpType.ts index e067612f17..49f701d800 100644 --- a/src/json-patch/op/OpType.ts +++ b/src/json-patch/op/OpType.ts @@ -12,7 +12,10 @@ const {isArray} = Array; * @category JSON Predicate */ export class OpType extends AbstractPredicateOp<'type'> { - constructor(path: Path, public readonly value: JsonPatchTypes) { + constructor( + path: Path, + public readonly value: JsonPatchTypes, + ) { super(path); } diff --git a/src/json-random/RandomJson.ts b/src/json-random/RandomJson.ts index 8d4f61a4de..ba37c709ff 100644 --- a/src/json-random/RandomJson.ts +++ b/src/json-random/RandomJson.ts @@ -163,10 +163,10 @@ export class RandomJson { Math.random() > 0.2 ? Math.random() * 1e9 : Math.random() < 0.2 - ? Math.round(0xff * (2 * Math.random() - 1)) - : Math.random() < 0.2 - ? Math.round(0xffff * (2 * Math.random() - 1)) - : Math.round(Number.MAX_SAFE_INTEGER * (2 * Math.random() - 1)); + ? Math.round(0xff * (2 * Math.random() - 1)) + : Math.random() < 0.2 + ? Math.round(0xffff * (2 * Math.random() - 1)) + : Math.round(Number.MAX_SAFE_INTEGER * (2 * Math.random() - 1)); if (num === -0) return 0; return num; } @@ -237,10 +237,10 @@ export class RandomJson { this.opts.rootNode === 'object' ? {} : this.opts.rootNode === 'array' - ? [] - : this.pickContainerType() === 'object' - ? {} - : []; + ? [] + : this.pickContainerType() === 'object' + ? {} + : []; this.containers.push(this.root); } diff --git a/src/json-type-value/Value.ts b/src/json-type-value/Value.ts index d8780127e7..165a67f0bb 100644 --- a/src/json-type-value/Value.ts +++ b/src/json-type-value/Value.ts @@ -2,7 +2,10 @@ import type {JsonValueCodec} from '../json-pack/codecs/types'; import type {ResolveType, Type} from '../json-type'; export class Value { - constructor(public type: T, public data: ResolveType) {} + constructor( + public type: T, + public data: ResolveType, + ) {} public encode(codec: JsonValueCodec): void { const value = this.data; diff --git a/src/json-type/schema/schema.ts b/src/json-type/schema/schema.ts index b5552a8f62..ba1545995e 100644 --- a/src/json-type/schema/schema.ts +++ b/src/json-type/schema/schema.ts @@ -293,37 +293,38 @@ export type Schema = JsonSchema | RefSchema | OrSchema | AnySchema | FunctionSch export type NoT = Omit; -export type TypeOf = T extends OrSchema - ? TypeOfValue - : T extends RefSchema - ? TypeOf - : T extends AnySchema - ? unknown - : TypeOfValue; +export type TypeOf = + T extends OrSchema + ? TypeOfValue + : T extends RefSchema + ? TypeOf + : T extends AnySchema + ? unknown + : TypeOfValue; export type TypeOfValue = T extends BooleanSchema ? boolean : T extends NumberSchema - ? number - : T extends StringSchema - ? string - : T extends ArraySchema - ? TypeOf[] - : T extends ConstSchema - ? U - : T extends TupleSchema - ? {[K in keyof U]: TypeOf} - : T extends ObjectSchema - ? NoEmptyInterface>> - : T extends MapSchema - ? Record> - : T extends BinarySchema - ? Uint8Array - : T extends FunctionSchema - ? (req: TypeOf, ctx?: unknown) => Promise> - : T extends FunctionStreamingSchema - ? (req$: Observable>, ctx?: unknown) => Observable> - : never; + ? number + : T extends StringSchema + ? string + : T extends ArraySchema + ? TypeOf[] + : T extends ConstSchema + ? U + : T extends TupleSchema + ? {[K in keyof U]: TypeOf} + : T extends ObjectSchema + ? NoEmptyInterface>> + : T extends MapSchema + ? Record> + : T extends BinarySchema + ? Uint8Array + : T extends FunctionSchema + ? (req: TypeOf, ctx?: unknown) => Promise> + : T extends FunctionStreamingSchema + ? (req$: Observable>, ctx?: unknown) => Observable> + : never; export type TypeOfMap> = {[K in keyof M]: TypeOf}; diff --git a/src/json-type/system/TypeAlias.ts b/src/json-type/system/TypeAlias.ts index bdd77a1f0e..071cced893 100644 --- a/src/json-type/system/TypeAlias.ts +++ b/src/json-type/system/TypeAlias.ts @@ -9,7 +9,11 @@ import type {Printable} from '../../util/print/types'; import type * as ts from '../typescript/types'; export class TypeAlias implements Printable { - public constructor(public readonly system: TypeSystem, public readonly id: K, public readonly type: T) {} + public constructor( + public readonly system: TypeSystem, + public readonly id: K, + public readonly type: T, + ) {} public getType(): Type { return this.type; diff --git a/src/json-type/system/types.ts b/src/json-type/system/types.ts index cfe75c53ca..3e0dfc7c02 100644 --- a/src/json-type/system/types.ts +++ b/src/json-type/system/types.ts @@ -16,10 +16,11 @@ export interface CustomValidator { export type TypeOfAlias = T extends TypeAlias ? T : T extends Type ? T : never; -export type ResolveType = T extends TypeAlias - ? TypeOf> - : T extends Type - ? TypeOf> - : T extends Schema - ? TypeOf - : never; +export type ResolveType = + T extends TypeAlias + ? TypeOf> + : T extends Type + ? TypeOf> + : T extends Schema + ? TypeOf + : never; diff --git a/src/json-type/type/TypeBuilder.ts b/src/json-type/type/TypeBuilder.ts index e0cba75066..b9ca165017 100644 --- a/src/json-type/type/TypeBuilder.ts +++ b/src/json-type/type/TypeBuilder.ts @@ -68,12 +68,12 @@ export class TypeBuilder { type V2 = string extends V ? never : number extends V - ? never - : boolean extends V - ? never - : any[] extends V - ? never - : V; + ? never + : boolean extends V + ? never + : any[] extends V + ? never + : V; const type = new classes.ConstType(schema.s.Const(value, options)); type.system = this.system; return type; diff --git a/src/json-type/type/classes/AnyType.ts b/src/json-type/type/classes/AnyType.ts index 7d43633250..1bd35812a2 100644 --- a/src/json-type/type/classes/AnyType.ts +++ b/src/json-type/type/classes/AnyType.ts @@ -55,8 +55,8 @@ export class AnyType extends AbstractType { ctx instanceof CborEncoderCodegenContext ? EncodingFormat.Cbor : ctx instanceof MessagePackEncoderCodegenContext - ? EncodingFormat.MsgPack - : EncodingFormat.Json; + ? EncodingFormat.MsgPack + : EncodingFormat.Json; ctx.js(`${r}.type.encoder(${type})(${r}.data, encoder);`); }, () => { diff --git a/src/json-type/type/classes/ArrayType.ts b/src/json-type/type/classes/ArrayType.ts index 4d0a6e5f09..ab20ab3a39 100644 --- a/src/json-type/type/classes/ArrayType.ts +++ b/src/json-type/type/classes/ArrayType.ts @@ -27,7 +27,10 @@ import type {TypeExportContext} from '../../system/TypeExportContext'; export class ArrayType extends AbstractType>> { protected schema: schema.ArraySchema; - constructor(protected type: T, options?: schema.Optional) { + constructor( + protected type: T, + options?: schema.Optional, + ) { super(); this.schema = schema.s.Array(schema.s.any, options); } diff --git a/src/json-type/type/classes/BinaryType.ts b/src/json-type/type/classes/BinaryType.ts index b32f08b4fe..bb5edd39a1 100644 --- a/src/json-type/type/classes/BinaryType.ts +++ b/src/json-type/type/classes/BinaryType.ts @@ -26,7 +26,10 @@ import type {TypeExportContext} from '../../system/TypeExportContext'; export class BinaryType extends AbstractType { protected schema: schema.BinarySchema; - constructor(protected type: T, options?: schema.Optional) { + constructor( + protected type: T, + options?: schema.Optional, + ) { super(); this.schema = schema.s.Binary(schema.s.any, options); } diff --git a/src/json-type/type/classes/MapType.ts b/src/json-type/type/classes/MapType.ts index 98bf497fa0..f75afc0497 100644 --- a/src/json-type/type/classes/MapType.ts +++ b/src/json-type/type/classes/MapType.ts @@ -26,7 +26,10 @@ import type {TypeExportContext} from '../../system/TypeExportContext'; export class MapType extends AbstractType>> { protected schema: schema.MapSchema; - constructor(protected type: T, options?: schema.Optional) { + constructor( + protected type: T, + options?: schema.Optional, + ) { super(); this.schema = schema.s.Map(schema.s.any, options); } diff --git a/src/json-type/type/classes/ObjectType.ts b/src/json-type/type/classes/ObjectType.ts index 8b6a611ffd..4bb3881893 100644 --- a/src/json-type/type/classes/ObjectType.ts +++ b/src/json-type/type/classes/ObjectType.ts @@ -41,7 +41,10 @@ export class ObjectFieldType extends AbstractT > { protected schema: schema.ObjectFieldSchema; - constructor(public readonly key: K, public readonly value: V) { + constructor( + public readonly key: K, + public readonly value: V, + ) { super(); this.schema = schema.s.prop(key, schema.s.any); } @@ -79,7 +82,10 @@ export class ObjectFieldType extends AbstractT export class ObjectOptionalFieldType extends ObjectFieldType { public optional = true; - constructor(public readonly key: K, public readonly value: V) { + constructor( + public readonly key: K, + public readonly value: V, + ) { super(key, value); this.schema = schema.s.propOpt(key, schema.s.any); } diff --git a/src/json-type/type/classes/OrType.ts b/src/json-type/type/classes/OrType.ts index 731be45c2f..97d37bc7ac 100644 --- a/src/json-type/type/classes/OrType.ts +++ b/src/json-type/type/classes/OrType.ts @@ -27,7 +27,10 @@ import type {TypeExportContext} from '../../system/TypeExportContext'; export class OrType extends AbstractType}>> { protected schema: schema.OrSchema; - constructor(protected types: T, options?: Omit) { + constructor( + protected types: T, + options?: Omit, + ) { super(); this.schema = { ...schema.s.Or(), diff --git a/src/json-type/type/classes/RefType.ts b/src/json-type/type/classes/RefType.ts index b4797cce59..be1033e66f 100644 --- a/src/json-type/type/classes/RefType.ts +++ b/src/json-type/type/classes/RefType.ts @@ -94,8 +94,8 @@ export class RefType extends AbstractType extends AbstractType}>> { protected schema: schema.TupleSchema; - constructor(public readonly types: T, options?: Omit) { + constructor( + public readonly types: T, + options?: Omit, + ) { super(); this.schema = {...schema.s.Tuple(), ...options}; } diff --git a/src/json-type/type/discriminator.ts b/src/json-type/type/discriminator.ts index 42a94a8691..d1da9868a3 100644 --- a/src/json-type/type/discriminator.ts +++ b/src/json-type/type/discriminator.ts @@ -48,7 +48,10 @@ export class Discriminator { return expr; } - constructor(public readonly path: string, public readonly type: Type) {} + constructor( + public readonly path: string, + public readonly type: Type, + ) {} condition(): Expr { if (this.type instanceof ConstType) return ['==', this.type.value(), ['$', this.path]]; diff --git a/src/json-type/type/types.ts b/src/json-type/type/types.ts index 4b8b82ebd3..77a71f364d 100644 --- a/src/json-type/type/types.ts +++ b/src/json-type/type/types.ts @@ -26,11 +26,12 @@ export type Type = export type SchemaOf = T extends BaseType ? U : never; export type SchemaOfMap> = {[K in keyof M]: SchemaOf}; -export type SchemaOfObjectFieldType = F extends classes.ObjectOptionalFieldType - ? schema.ObjectOptionalFieldSchema> - : F extends classes.ObjectFieldType - ? schema.ObjectFieldSchema> - : never; +export type SchemaOfObjectFieldType = + F extends classes.ObjectOptionalFieldType + ? schema.ObjectOptionalFieldSchema> + : F extends classes.ObjectFieldType + ? schema.ObjectFieldSchema> + : never; export type SchemaOfObjectFields = {[K in keyof F]: SchemaOfObjectFieldType}; @@ -40,10 +41,10 @@ export type FilterFunctions = { [K in keyof T as T[K] extends classes.FunctionType ? K : T[K] extends classes.FunctionStreamingType - ? K - : never]: T[K] extends classes.FunctionType + ? K + : never]: T[K] extends classes.FunctionType ? T[K] : T[K] extends classes.FunctionStreamingType - ? T[K] - : never; + ? T[K] + : never; }; diff --git a/src/reactive-rpc/common/channel/mock.ts b/src/reactive-rpc/common/channel/mock.ts index 8092b36c97..f1799db9ca 100644 --- a/src/reactive-rpc/common/channel/mock.ts +++ b/src/reactive-rpc/common/channel/mock.ts @@ -55,7 +55,10 @@ export const createWebSocketMock = (params: Partial) return this._readyState; } - constructor(public readonly url: string, public readonly _protocol: string | string[] = '') {} + constructor( + public readonly url: string, + public readonly _protocol: string | string[] = '', + ) {} public close(code?: number, reason?: string): void { if (!params.onClose) return; diff --git a/src/reactive-rpc/common/codec/RpcCodecs.ts b/src/reactive-rpc/common/codec/RpcCodecs.ts index 22dc5b84c2..9116692c02 100644 --- a/src/reactive-rpc/common/codec/RpcCodecs.ts +++ b/src/reactive-rpc/common/codec/RpcCodecs.ts @@ -2,5 +2,8 @@ import {Codecs} from '../../../json-pack/codecs/Codecs'; import {RpcMessageCodecs} from './RpcMessageCodecs'; export class RpcCodecs { - constructor(public readonly value: Codecs, public readonly messages: RpcMessageCodecs) {} + constructor( + public readonly value: Codecs, + public readonly messages: RpcMessageCodecs, + ) {} } diff --git a/src/reactive-rpc/common/messages/Value.ts b/src/reactive-rpc/common/messages/Value.ts index 7be44822c9..f111ae81c5 100644 --- a/src/reactive-rpc/common/messages/Value.ts +++ b/src/reactive-rpc/common/messages/Value.ts @@ -5,7 +5,10 @@ import type {Type} from '../../../json-type'; * @deprecated Use `Value` directly. */ export class RpcValue extends V { - constructor(public data: V, public type: Type | undefined) { + constructor( + public data: V, + public type: Type | undefined, + ) { super(type, data); } } diff --git a/src/reactive-rpc/common/messages/messages.ts b/src/reactive-rpc/common/messages/messages.ts index 70b17f7cfc..e6af90e2ba 100644 --- a/src/reactive-rpc/common/messages/messages.ts +++ b/src/reactive-rpc/common/messages/messages.ts @@ -147,7 +147,10 @@ const encodeCompactWithPayload = ( * @category Message */ export class NotificationMessage = RpcValue> implements Message { - constructor(public readonly method: string, public readonly value: V) {} + constructor( + public readonly method: string, + public readonly value: V, + ) {} public validate(): void { validateMethod(this.method); @@ -208,7 +211,11 @@ export class NotificationMessage = RpcValue> implements * @category Message */ export class RequestDataMessage = RpcValue> implements Message { - constructor(public readonly id: number, public readonly method: string, public readonly value: undefined | V) {} + constructor( + public readonly id: number, + public readonly method: string, + public readonly value: undefined | V, + ) {} public validate(): void { validateId(this.id); @@ -234,7 +241,11 @@ export class RequestDataMessage = RpcValue> implements M * @category Message */ export class RequestCompleteMessage = RpcValue> implements Message { - constructor(public readonly id: number, public readonly method: string, public readonly value: undefined | V) {} + constructor( + public readonly id: number, + public readonly method: string, + public readonly value: undefined | V, + ) {} public validate(): void { validateId(this.id); @@ -260,7 +271,11 @@ export class RequestCompleteMessage = RpcValue> implemen * @category Message */ export class RequestErrorMessage = RpcValue> implements Message { - constructor(public readonly id: number, public method: string, public readonly value: V) {} + constructor( + public readonly id: number, + public method: string, + public readonly value: V, + ) {} public validate(): void { validateId(this.id); @@ -307,7 +322,10 @@ export class RequestUnsubscribeMessage implements Message { * @category Message */ export class ResponseCompleteMessage = RpcValue> implements Message { - constructor(public readonly id: number, public readonly value: undefined | V) {} + constructor( + public readonly id: number, + public readonly value: undefined | V, + ) {} public validate(): void { validateId(this.id); @@ -332,7 +350,10 @@ export class ResponseCompleteMessage = RpcValue> impleme * @category Message */ export class ResponseDataMessage = RpcValue> implements Message { - constructor(public readonly id: number, public readonly value: V) {} + constructor( + public readonly id: number, + public readonly value: V, + ) {} public validate(): void { validateId(this.id); @@ -355,7 +376,10 @@ export class ResponseDataMessage = RpcValue> implements * @category Message */ export class ResponseErrorMessage = RpcValue> implements Message { - constructor(public readonly id: number, public readonly value: V) {} + constructor( + public readonly id: number, + public readonly value: V, + ) {} public validate(): void { validateId(this.id); diff --git a/src/reactive-rpc/common/rpc/caller/ApiRpcCaller.ts b/src/reactive-rpc/common/rpc/caller/ApiRpcCaller.ts index 6185e36eb8..4fe350ea93 100644 --- a/src/reactive-rpc/common/rpc/caller/ApiRpcCaller.ts +++ b/src/reactive-rpc/common/rpc/caller/ApiRpcCaller.ts @@ -16,8 +16,8 @@ export class ApiRpcCaller< [K in keyof Api]: Api[K] extends IStaticRpcMethod ? StaticRpcMethod : Api[K] extends IStreamingRpcMethod - ? StreamingRpcMethod - : never; + ? StreamingRpcMethod + : never; }, > extends RpcCaller { protected readonly methods = new Map(); diff --git a/src/reactive-rpc/common/rpc/caller/ObjectValueCaller.ts b/src/reactive-rpc/common/rpc/caller/ObjectValueCaller.ts index baa93e32f6..71ee5674d9 100644 --- a/src/reactive-rpc/common/rpc/caller/ObjectValueCaller.ts +++ b/src/reactive-rpc/common/rpc/caller/ObjectValueCaller.ts @@ -22,23 +22,26 @@ type ToObject = T extends [string, unknown][] ? {[K in T[number] as K[0]]: K[ type ObjectFieldsToMap = ToObject<{[K in keyof F]: ObjectFieldToTuple}>; type ObjectValueToTypeMap = ObjectFieldsToMap>>; -type MethodReq = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodReq = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodRes = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodRes = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodDefinition = F extends FunctionType - ? StaticRpcMethodOptions, MethodRes> - : F extends FunctionStreamingType - ? StreamingRpcMethodOptions, MethodRes> - : never; +type MethodDefinition = + F extends FunctionType + ? StaticRpcMethodOptions, MethodRes> + : F extends FunctionStreamingType + ? StreamingRpcMethodOptions, MethodRes> + : never; export interface ObjectValueCallerOptions>, Ctx = unknown> extends Omit, 'getMethod'> { diff --git a/src/reactive-rpc/common/rpc/caller/TypeRouterCaller.ts b/src/reactive-rpc/common/rpc/caller/TypeRouterCaller.ts index ddec43f96a..796131474d 100644 --- a/src/reactive-rpc/common/rpc/caller/TypeRouterCaller.ts +++ b/src/reactive-rpc/common/rpc/caller/TypeRouterCaller.ts @@ -98,20 +98,23 @@ export class TypeRouterCaller, Ctx = unknown> ext type Routes = Router extends TypeRouter ? R : never; -type MethodReq = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodReq = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodRes = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodRes = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodDefinition = F extends FunctionType - ? StaticRpcMethodOptions, MethodRes> - : F extends FunctionStreamingType - ? StreamingRpcMethodOptions, MethodRes> - : never; +type MethodDefinition = + F extends FunctionType + ? StaticRpcMethodOptions, MethodRes> + : F extends FunctionStreamingType + ? StreamingRpcMethodOptions, MethodRes> + : never; diff --git a/src/reactive-rpc/common/rpc/caller/TypedApiCaller.ts b/src/reactive-rpc/common/rpc/caller/TypedApiCaller.ts index cbb2087f86..ae33cef99e 100644 --- a/src/reactive-rpc/common/rpc/caller/TypedApiCaller.ts +++ b/src/reactive-rpc/common/rpc/caller/TypedApiCaller.ts @@ -9,23 +9,26 @@ export interface TypedApiCallerOptions extends Omit = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodReq = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodRes = F extends FunctionType - ? TypeOf> - : F extends FunctionStreamingType - ? TypeOf> - : never; +type MethodRes = + F extends FunctionType + ? TypeOf> + : F extends FunctionStreamingType + ? TypeOf> + : never; -type MethodDefinition = F extends FunctionType - ? StaticRpcMethodOptions, MethodRes> - : F extends FunctionStreamingType - ? StreamingRpcMethodOptions, MethodRes> - : never; +type MethodDefinition = + F extends FunctionType + ? StaticRpcMethodOptions, MethodRes> + : F extends FunctionStreamingType + ? StreamingRpcMethodOptions, MethodRes> + : never; export class TypedApiCaller extends RpcCaller { protected readonly system: TypeSystem; @@ -71,13 +74,13 @@ export class TypedApiCaller extends RpcCal validate, }) : isStreamingMethodAlias - ? new StreamingRpcMethod({ - ...(definition as StreamingRpcMethodOptions), - req: type.req, - res: type.res, - validate, - }) - : null; + ? new StreamingRpcMethod({ + ...(definition as StreamingRpcMethodOptions), + req: type.req, + res: type.res, + validate, + }) + : null; if (!method) throw new Error(`Type [alias = ${alias.id}] is not a function.`); this.methods.set(id as string, method as any); } diff --git a/src/reactive-rpc/common/testing/buildE2eClient.ts b/src/reactive-rpc/common/testing/buildE2eClient.ts index e6fd97612f..9cf624db8a 100644 --- a/src/reactive-rpc/common/testing/buildE2eClient.ts +++ b/src/reactive-rpc/common/testing/buildE2eClient.ts @@ -113,13 +113,11 @@ export const buildE2eClient = >(caller: Caller, op }; type UnTypeRouterCaller = T extends TypeRouterCaller ? R : T extends ObjectValueCaller ? R : never; -type UnTypeRouter = T extends TypeRouter - ? R - : T extends ObjectValue - ? ObjectValueToTypeMap> - : never; -type UnwrapFunction = F extends FunctionType - ? (req: ResolveType) => Promise> - : F extends FunctionStreamingType - ? (req$: Observable>) => Observable> - : never; +type UnTypeRouter = + T extends TypeRouter ? R : T extends ObjectValue ? ObjectValueToTypeMap> : never; +type UnwrapFunction = + F extends FunctionType + ? (req: ResolveType) => Promise> + : F extends FunctionStreamingType + ? (req$: Observable>) => Observable> + : never; diff --git a/src/reactive-rpc/server/ws/server/WsServerConnection.ts b/src/reactive-rpc/server/ws/server/WsServerConnection.ts index 0e842e7c74..cdd092136e 100644 --- a/src/reactive-rpc/server/ws/server/WsServerConnection.ts +++ b/src/reactive-rpc/server/ws/server/WsServerConnection.ts @@ -39,7 +39,10 @@ export class WsServerConnection { public onpong: (data: Uint8Array | null) => void = () => {}; public onclose: (code: number, reason: string) => void = () => {}; - constructor(protected readonly encoder: WsFrameEncoder, public readonly socket: WsServerConnectionSocket) { + constructor( + protected readonly encoder: WsFrameEncoder, + public readonly socket: WsServerConnectionSocket, + ) { const decoder = new WsFrameDecoder(); let currentFrameHeader: WsFrameHeader | null = null; let fragmentStartFrameHeader: WsFrameHeader | null = null; diff --git a/src/util/buffers/Uint8ArrayCut.ts b/src/util/buffers/Uint8ArrayCut.ts index 403ec06e53..b57bfd6d00 100644 --- a/src/util/buffers/Uint8ArrayCut.ts +++ b/src/util/buffers/Uint8ArrayCut.ts @@ -1,3 +1,7 @@ export class Uint8ArrayCut { - constructor(public readonly uint8: Uint8Array, public readonly start: number, public readonly size: number) {} + constructor( + public readonly uint8: Uint8Array, + public readonly start: number, + public readonly size: number, + ) {} } diff --git a/src/util/buffers/utf8/CachedUtf8Decoder.ts b/src/util/buffers/utf8/CachedUtf8Decoder.ts index 4af0f9dd2b..01dd36f9b7 100644 --- a/src/util/buffers/utf8/CachedUtf8Decoder.ts +++ b/src/util/buffers/utf8/CachedUtf8Decoder.ts @@ -2,7 +2,10 @@ import decodeUtf8 from './decodeUtf8/v10'; import {randomU32} from 'hyperdyperid/lib/randomU32'; class CacheItem { - constructor(public readonly bytes: Uint8Array, public readonly value: string) {} + constructor( + public readonly bytes: Uint8Array, + public readonly value: string, + ) {} } const enum CONST { diff --git a/src/util/buffers/utf8/decodeUtf8/v15.ts b/src/util/buffers/utf8/decodeUtf8/v15.ts index 6fcae2ff17..b5557c0631 100644 --- a/src/util/buffers/utf8/decodeUtf8/v15.ts +++ b/src/util/buffers/utf8/decodeUtf8/v15.ts @@ -10,7 +10,7 @@ export default (buf: Uint8Array, start: number, length: number): string => { ? utf8Slice ? utf8Slice.call(buf, start, end) : from - ? from(buf).subarray(start, end).toString('utf8') - : v10(buf, start, length) + ? from(buf).subarray(start, end).toString('utf8') + : v10(buf, start, length) : v10(buf, start, length); }; diff --git a/src/util/buffers/utf8/decodeUtf8/v16.ts b/src/util/buffers/utf8/decodeUtf8/v16.ts index 2d6744d7f4..c95f699fdc 100644 --- a/src/util/buffers/utf8/decodeUtf8/v16.ts +++ b/src/util/buffers/utf8/decodeUtf8/v16.ts @@ -14,11 +14,11 @@ const midDecoder: Decoder = (buf, start, length) => decodeAscii(buf, start, leng const longDecoder: Decoder = utf8Slice ? (buf, start, length) => utf8Slice.call(buf, start, start + length) : from - ? (buf, start, length) => - from(buf) - .subarray(start, start + length) - .toString('utf8') - : v18; + ? (buf, start, length) => + from(buf) + .subarray(start, start + length) + .toString('utf8') + : v18; const decoder: Decoder = (buf, start, length): string => { if (length < 16) return shortDecoder(buf, start, length); diff --git a/src/util/router/codegen.ts b/src/util/router/codegen.ts index a2329e08af..cff9b898f8 100644 --- a/src/util/router/codegen.ts +++ b/src/util/router/codegen.ts @@ -17,7 +17,11 @@ export class RouterCodegenCtx { } export class RouterCodegenOpts { - constructor(public readonly slice: JsExpression, public readonly offset: string, public readonly depth: number = 0) {} + constructor( + public readonly slice: JsExpression, + public readonly offset: string, + public readonly depth: number = 0, + ) {} public create(offset: string): RouterCodegenOpts { const slice = new JsExpression(() => `str.slice(${offset})`); diff --git a/src/util/router/router.ts b/src/util/router/router.ts index 2176a905d0..5ffaf74023 100644 --- a/src/util/router/router.ts +++ b/src/util/router/router.ts @@ -67,7 +67,10 @@ export class Destination implements Printable { public readonly match: Match; - constructor(public readonly routes: Route[], public readonly data: unknown) { + constructor( + public readonly routes: Route[], + public readonly data: unknown, + ) { this.match = new Match(data, []); } @@ -131,5 +134,8 @@ export class Route implements Printable { } export class Match { - constructor(public readonly data: Data, public params: string[] | null) {} + constructor( + public readonly data: Data, + public params: string[] | null, + ) {} } diff --git a/src/util/router/steps.ts b/src/util/router/steps.ts index 2366eb0c22..500d9a2a96 100644 --- a/src/util/router/steps.ts +++ b/src/util/router/steps.ts @@ -7,7 +7,10 @@ export class ExactStep { } export class UntilStep { - constructor(public readonly name: string, public readonly until: string) {} + constructor( + public readonly name: string, + public readonly until: string, + ) {} public toText() { const until = this.until === '\n' ? '\\n' : this.until; @@ -16,7 +19,11 @@ export class UntilStep { } export class RegexStep { - constructor(public readonly name: string, public readonly regex: string, public readonly until: string) {} + constructor( + public readonly name: string, + public readonly regex: string, + public readonly until: string, + ) {} public toText() { const regex = this.regex || this.until ? ':' + this.regex : ''; diff --git a/src/util/trees/TreeNode.ts b/src/util/trees/TreeNode.ts index d1bdf28331..8f26515fb6 100644 --- a/src/util/trees/TreeNode.ts +++ b/src/util/trees/TreeNode.ts @@ -5,5 +5,8 @@ export class TreeNode implements ITreeNode { public l: ITreeNode | undefined = undefined; public r: ITreeNode | undefined = undefined; - constructor(public k: K, public v: V) {} + constructor( + public k: K, + public v: V, + ) {} } diff --git a/src/util/trees/avl/AvlBstNumNumMap.ts b/src/util/trees/avl/AvlBstNumNumMap.ts index b6bdfee11c..1e6417d503 100644 --- a/src/util/trees/avl/AvlBstNumNumMap.ts +++ b/src/util/trees/avl/AvlBstNumNumMap.ts @@ -10,7 +10,10 @@ export class NumNumItem implements IAvlTreeNode { public l: NumNumItem | undefined = undefined; public r: NumNumItem | undefined = undefined; public bf: number = 0; - constructor(public readonly k: number, public v: number) {} + constructor( + public readonly k: number, + public v: number, + ) {} } const comparator = (a: number, b: number) => a - b; diff --git a/src/util/trees/avl/AvlMap.ts b/src/util/trees/avl/AvlMap.ts index 375cf3704b..443c023300 100644 --- a/src/util/trees/avl/AvlMap.ts +++ b/src/util/trees/avl/AvlMap.ts @@ -10,7 +10,10 @@ export class AvlNode implements IAvlTreeNode { public l: AvlNode | undefined = undefined; public r: AvlNode | undefined = undefined; public bf: number = 0; - constructor(public readonly k: K, public v: V) {} + constructor( + public readonly k: K, + public v: V, + ) {} } const defaultComparator = (a: unknown, b: unknown) => (a === b ? 0 : (a as any) < (b as any) ? -1 : 1); diff --git a/src/util/trees/avl/util.ts b/src/util/trees/avl/util.ts index 24ed2b04df..0d82c1ffa4 100644 --- a/src/util/trees/avl/util.ts +++ b/src/util/trees/avl/util.ts @@ -198,8 +198,8 @@ export const print = (node: undefined | AvlHeadlessNode | IAvlTreeNode, tab: str v && typeof v === 'object' && v.constructor === Object ? stringify(v) : v && typeof v === 'object' - ? (v as any).toString(tab) - : stringify(v); + ? (v as any).toString(tab) + : stringify(v); const content = k !== undefined ? ` { ${stringify(k)} = ${vFormatted} }` : ''; const bfFormatted = bf ? ` [${bf}]` : ''; return ( diff --git a/src/util/trees/radix/radix.ts b/src/util/trees/radix/radix.ts index 1de0f83ee7..8d15da195c 100644 --- a/src/util/trees/radix/radix.ts +++ b/src/util/trees/radix/radix.ts @@ -182,11 +182,11 @@ export const print = (node: TrieNode, tab: string = ''): string => { ? Array.isArray(node.v) ? stringify(node.v) : node.v.constructor === Object - ? stringify(node.v) - : '' // `[${node.v.constructor.name}]` + ? stringify(node.v) + : '' // `[${node.v.constructor.name}]` : node.v === undefined - ? '' - : stringify(node.v); + ? '' + : stringify(node.v); const childrenNodes: TrieNode[] = []; node.forChildren((child) => childrenNodes.push(child)); return ( diff --git a/src/util/trees/red-black/RbMap.ts b/src/util/trees/red-black/RbMap.ts index 81b3106a71..1f55e12dbf 100644 --- a/src/util/trees/red-black/RbMap.ts +++ b/src/util/trees/red-black/RbMap.ts @@ -11,7 +11,10 @@ export class RbNode implements IRbTreeNode { public l: RbNode | undefined = undefined; public r: RbNode | undefined = undefined; public b: boolean = false; - constructor(public readonly k: K, public v: V) {} + constructor( + public readonly k: K, + public v: V, + ) {} } const defaultComparator = (a: unknown, b: unknown) => (a === b ? 0 : (a as any) < (b as any) ? -1 : 1); diff --git a/src/util/trees/trie/TrieNode.ts b/src/util/trees/trie/TrieNode.ts index 91cead0457..28ef0ec61a 100644 --- a/src/util/trees/trie/TrieNode.ts +++ b/src/util/trees/trie/TrieNode.ts @@ -9,7 +9,10 @@ export class TrieNode implements ITreeNode, Printa public r: TrieNode | undefined = undefined; public children: TrieNode | undefined = undefined; - constructor(public k: string, public v: V) {} + constructor( + public k: string, + public v: V, + ) {} public forChildren(callback: (child: TrieNode, index: number) => void): void { let child = first(this.children); diff --git a/yarn.lock b/yarn.lock index e1cde4b6c2..3f946f41f5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4500,10 +4500,10 @@ platform@^1.3.3: resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7" integrity sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg== -prettier@^2.6.2: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.2.5: + version "3.2.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" + integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== pretty-error@^4.0.0: version "4.0.0"