diff --git a/packages/driver/genErrors.mjs b/packages/driver/genErrors.mjs index 7a29acb29..0d15b0e56 100644 --- a/packages/driver/genErrors.mjs +++ b/packages/driver/genErrors.mjs @@ -70,7 +70,7 @@ const __filename = new URL("", import.meta.url).pathname; mappingBuf.nl(); mappingBuf.code(copy); mappingBuf.nl(); - mappingBuf.code('import {ErrorType} from "./base";'); + mappingBuf.code('import type { ErrorType } from "./base";'); mappingBuf.code('import * as errors from "./index";'); mappingBuf.nl(); mappingBuf.nl(); @@ -96,9 +96,13 @@ const __filename = new URL("", import.meta.url).pathname; let line = `export class ${err} extends ${base} `; line += `{\n`; if (tag_items.length > 0) { - line += ` protected static tags = {${tag_items.join(", ")}}\n`; + line += ` override protected static tags = {${tag_items.join(", ")}}\n`; + } + if (base !== "EdgeDBError") { + line += ` override get code(): number {\n return ${code};\n }\n`; + } else { + line += ` get code(): number {\n return ${code};\n }\n`; } - line += ` get code(): number {\n return ${code};\n }\n`; line += `}`; errorsBuf.code(line); @@ -112,6 +116,6 @@ const __filename = new URL("", import.meta.url).pathname; const errors_ts = prettier.format(errorsBuf.render(), prettierOptions); const mapping_ts = prettier.format(mappingBuf.render(), prettierOptions); - fs.writeFileSync(path.join(__dirname, "./src/errors/index.ts"), errors_ts); - fs.writeFileSync(path.join(__dirname, "./src/errors/map.ts"), mapping_ts); + fs.writeFileSync(path.join(__dirname, "./src/errors/index.ts"), await errors_ts); + fs.writeFileSync(path.join(__dirname, "./src/errors/map.ts"), await mapping_ts); })(); diff --git a/packages/driver/src/codecs/boolean.ts b/packages/driver/src/codecs/boolean.ts index 1d11eafb8..ec50124f5 100644 --- a/packages/driver/src/codecs/boolean.ts +++ b/packages/driver/src/codecs/boolean.ts @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces"; import { InvalidArgumentError } from "../errors"; export class BoolCodec extends ScalarCodec implements ICodec { - tsType = "boolean"; + override tsType = "boolean"; encode(buf: WriteBuffer, object: any): void { const typeOf = typeof object; diff --git a/packages/driver/src/codecs/bytes.ts b/packages/driver/src/codecs/bytes.ts index f356d6e7a..0bc62c593 100644 --- a/packages/driver/src/codecs/bytes.ts +++ b/packages/driver/src/codecs/bytes.ts @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces"; import { InvalidArgumentError } from "../errors"; export class BytesCodec extends ScalarCodec implements ICodec { - tsType = "Uint8Array"; + override tsType = "Uint8Array"; encode(buf: WriteBuffer, object: any): void { if (!(object instanceof Uint8Array)) { diff --git a/packages/driver/src/codecs/datetime.ts b/packages/driver/src/codecs/datetime.ts index 1422fc631..290ba5458 100644 --- a/packages/driver/src/codecs/datetime.ts +++ b/packages/driver/src/codecs/datetime.ts @@ -41,7 +41,7 @@ const TIMESHIFT = 946684800000; const DATESHIFT_ORD = ymd2ord(2000, 1, 1); export class DateTimeCodec extends ScalarCodec implements ICodec { - tsType = "Date"; + override tsType = "Date"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof Date)) { @@ -66,8 +66,8 @@ export class DateTimeCodec extends ScalarCodec implements ICodec { } export class LocalDateTimeCodec extends ScalarCodec implements ICodec { - tsType = "LocalDateTime"; - tsModule = "edgedb"; + override tsType = "LocalDateTime"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof LocalDateTime)) { @@ -123,8 +123,8 @@ export class LocalDateTimeCodec extends ScalarCodec implements ICodec { } export class LocalDateCodec extends ScalarCodec implements ICodec { - tsType = "LocalDate"; - tsModule = "edgedb"; + override tsType = "LocalDate"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof LocalDate)) { throw new InvalidArgumentError( @@ -142,8 +142,8 @@ export class LocalDateCodec extends ScalarCodec implements ICodec { } export class LocalTimeCodec extends ScalarCodec implements ICodec { - tsType = "LocalTime"; - tsModule = "edgedb"; + override tsType = "LocalTime"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof LocalTime)) { throw new InvalidArgumentError( @@ -199,8 +199,8 @@ export function checkValidEdgeDBDuration(duration: Duration): null | string { } export class DurationCodec extends ScalarCodec implements ICodec { - tsType = "Duration"; - tsModule = "edgedb"; + override tsType = "Duration"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof Duration)) { throw new InvalidArgumentError( @@ -283,8 +283,8 @@ export class DurationCodec extends ScalarCodec implements ICodec { } export class RelativeDurationCodec extends ScalarCodec implements ICodec { - tsType = "RelativeDuration"; - tsModule = "edgedb"; + override tsType = "RelativeDuration"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof RelativeDuration)) { throw new InvalidArgumentError(` @@ -350,8 +350,8 @@ export class RelativeDurationCodec extends ScalarCodec implements ICodec { } export class DateDurationCodec extends ScalarCodec implements ICodec { - tsType = "DateDuration"; - tsModule = "edgedb"; + override tsType = "DateDuration"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: unknown): void { if (!(object instanceof DateDuration)) { throw new InvalidArgumentError(` diff --git a/packages/driver/src/codecs/ifaces.ts b/packages/driver/src/codecs/ifaces.ts index fa1bc0f8b..ab9dd93f5 100644 --- a/packages/driver/src/codecs/ifaces.ts +++ b/packages/driver/src/codecs/ifaces.ts @@ -101,7 +101,7 @@ export abstract class ScalarCodec extends Codec { readonly tsType: string = "unknown"; readonly tsModule: string | null = null; - getKnownTypeName(): string { + override getKnownTypeName(): string { if (this.typeName) { return this.typeName; } diff --git a/packages/driver/src/codecs/json.ts b/packages/driver/src/codecs/json.ts index 5acdcb4d5..2a3fd5d2e 100644 --- a/packages/driver/src/codecs/json.ts +++ b/packages/driver/src/codecs/json.ts @@ -25,7 +25,7 @@ import { type ICodec, ScalarCodec } from "./ifaces"; import { InvalidArgumentError, ProtocolError } from "../errors"; export class JSONCodec extends ScalarCodec implements ICodec { - tsType = "unknown"; + override tsType = "unknown"; readonly jsonFormat: number | null = 1; @@ -68,7 +68,7 @@ export class JSONCodec extends ScalarCodec implements ICodec { } export class PgTextJSONCodec extends JSONCodec { - readonly jsonFormat = null; + override readonly jsonFormat = null; } export class JSONStringCodec extends ScalarCodec implements ICodec { @@ -101,5 +101,5 @@ export class JSONStringCodec extends ScalarCodec implements ICodec { } export class PgTextJSONStringCodec extends JSONStringCodec { - readonly jsonFormat = null; + override readonly jsonFormat = null; } diff --git a/packages/driver/src/codecs/memory.ts b/packages/driver/src/codecs/memory.ts index c29fd4701..dcb6cc8e4 100644 --- a/packages/driver/src/codecs/memory.ts +++ b/packages/driver/src/codecs/memory.ts @@ -22,8 +22,8 @@ import { ConfigMemory } from "../datatypes/memory"; import { InvalidArgumentError } from "../errors"; export class ConfigMemoryCodec extends ScalarCodec implements ICodec { - tsType = "ConfigMemory"; - tsModule = "edgedb"; + override tsType = "ConfigMemory"; + override tsModule = "edgedb"; encode(buf: WriteBuffer, object: any): void { if (!(object instanceof ConfigMemory)) { diff --git a/packages/driver/src/codecs/numbers.ts b/packages/driver/src/codecs/numbers.ts index 7f6a4cf63..ba143ddf0 100644 --- a/packages/driver/src/codecs/numbers.ts +++ b/packages/driver/src/codecs/numbers.ts @@ -21,7 +21,7 @@ import { type ICodec, ScalarCodec } from "./ifaces"; import { InvalidArgumentError } from "../errors"; export class Int64Codec extends ScalarCodec implements ICodec { - tsType = "number"; + override tsType = "number"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "number") { throw new InvalidArgumentError(`a number was expected, got "${object}"`); @@ -50,7 +50,7 @@ export class Int64BigintCodec extends ScalarCodec implements ICodec { } export class Int32Codec extends ScalarCodec implements ICodec { - tsType = "number"; + override tsType = "number"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "number") { throw new InvalidArgumentError(`a number was expected, got "${object}"`); @@ -65,7 +65,7 @@ export class Int32Codec extends ScalarCodec implements ICodec { } export class Int16Codec extends ScalarCodec implements ICodec { - tsType = "number"; + override tsType = "number"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "number") { throw new InvalidArgumentError(`a number was expected, got "${object}"`); @@ -80,7 +80,7 @@ export class Int16Codec extends ScalarCodec implements ICodec { } export class Float32Codec extends ScalarCodec implements ICodec { - tsType = "number"; + override tsType = "number"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "number") { throw new InvalidArgumentError(`a number was expected, got "${object}"`); @@ -95,7 +95,7 @@ export class Float32Codec extends ScalarCodec implements ICodec { } export class Float64Codec extends ScalarCodec implements ICodec { - tsType = "number"; + override tsType = "number"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "number") { throw new InvalidArgumentError(`a number was expected, got "${object}"`); diff --git a/packages/driver/src/codecs/numerics.ts b/packages/driver/src/codecs/numerics.ts index a59c0e9a3..59b22a51a 100644 --- a/packages/driver/src/codecs/numerics.ts +++ b/packages/driver/src/codecs/numerics.ts @@ -24,7 +24,7 @@ const NUMERIC_POS = 0x0000; const NUMERIC_NEG = 0x4000; export class BigIntCodec extends ScalarCodec implements ICodec { - tsType = "bigint"; + override tsType = "bigint"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "bigint") { @@ -73,7 +73,7 @@ export class BigIntCodec extends ScalarCodec implements ICodec { } export class DecimalStringCodec extends ScalarCodec implements ICodec { - tsType = "string"; + override tsType = "string"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "string") { diff --git a/packages/driver/src/codecs/pgvector.ts b/packages/driver/src/codecs/pgvector.ts index b81d076a2..e24034eb3 100644 --- a/packages/driver/src/codecs/pgvector.ts +++ b/packages/driver/src/codecs/pgvector.ts @@ -30,7 +30,7 @@ import { SparseVector } from "../datatypes/pgvector"; export const PG_VECTOR_MAX_DIM = (1 << 16) - 1; export class PgVectorCodec extends ScalarCodec implements ICodec { - readonly tsType = "Float32Array"; + override readonly tsType = "Float32Array"; encode(buf: WriteBuffer, object: any): void { if (!(object instanceof Float32Array || Array.isArray(object))) { @@ -87,8 +87,8 @@ export class PgVectorCodec extends ScalarCodec implements ICodec { } export class PgVectorHalfVecCodec extends ScalarCodec implements ICodec { - readonly tsType = "Float16Array"; - readonly tsModule = "edgedb"; + override readonly tsType = "Float16Array"; + override readonly tsModule = "edgedb"; encode(buf: WriteBuffer, object: any): void { if (!(isFloat16Array(object) || Array.isArray(object))) { @@ -154,8 +154,8 @@ export class PgVectorHalfVecCodec extends ScalarCodec implements ICodec { } export class PgVectorSparseVecCodec extends ScalarCodec implements ICodec { - readonly tsType = "SparseVector"; - readonly tsModule = "edgedb"; + override readonly tsType = "SparseVector"; + override readonly tsModule = "edgedb"; encode(buf: WriteBuffer, object: any): void { if (!(object instanceof SparseVector)) { diff --git a/packages/driver/src/codecs/text.ts b/packages/driver/src/codecs/text.ts index 1065d1235..26d33d757 100644 --- a/packages/driver/src/codecs/text.ts +++ b/packages/driver/src/codecs/text.ts @@ -22,7 +22,7 @@ import { type ICodec, ScalarCodec } from "./ifaces"; import { InvalidArgumentError } from "../errors"; export class StrCodec extends ScalarCodec implements ICodec { - tsType = "string"; + override tsType = "string"; encode(buf: WriteBuffer, object: any): void { if (typeof object !== "string") { diff --git a/packages/driver/src/codecs/uuid.ts b/packages/driver/src/codecs/uuid.ts index 91cd179cf..9578a2552 100644 --- a/packages/driver/src/codecs/uuid.ts +++ b/packages/driver/src/codecs/uuid.ts @@ -37,7 +37,7 @@ function UUIDBufferFromString(uuid: string): Uint8Array { } export class UUIDCodec extends ScalarCodec implements ICodec { - tsType = "string"; + override tsType = "string"; encode(buf: WriteBuffer, object: any): void { if (typeof object === "string") { diff --git a/packages/driver/src/datatypes/datetime.ts b/packages/driver/src/datatypes/datetime.ts index 17afc3db7..79f58bf3c 100644 --- a/packages/driver/src/datatypes/datetime.ts +++ b/packages/driver/src/datatypes/datetime.ts @@ -274,7 +274,7 @@ export class LocalDateTime extends LocalDate { return localTimeInstances.get(this)!.nanosecond; } - toString(): string { + override toString(): string { return `${super.toString()}T${localTimeInstances.get(this)!.toString()}`; } } diff --git a/packages/driver/src/errors/base.ts b/packages/driver/src/errors/base.ts index dc956f39c..f5c3ff190 100644 --- a/packages/driver/src/errors/base.ts +++ b/packages/driver/src/errors/base.ts @@ -22,7 +22,7 @@ export class EdgeDBError extends Error { this._message = message ?? ""; } - get message() { + override get message() { return ( this._message + (this._query && this._attrs @@ -31,7 +31,7 @@ export class EdgeDBError extends Error { ); } - get name(): string { + override get name(): string { return this.constructor.name; } diff --git a/packages/driver/src/errors/index.ts b/packages/driver/src/errors/index.ts index 77782dd60..6f73f848c 100644 --- a/packages/driver/src/errors/index.ts +++ b/packages/driver/src/errors/index.ts @@ -18,6 +18,8 @@ * limitations under the License. */ +/* tslint:disable */ + import { EdgeDBError } from "./base"; import * as tags from "./tags"; export { EdgeDBError } from "./base"; @@ -42,68 +44,68 @@ export class ProtocolError extends EdgeDBError { } export class BinaryProtocolError extends ProtocolError { - get code(): number { + override get code(): number { return 0x03_01_00_00; } } export class UnsupportedProtocolVersionError extends BinaryProtocolError { - get code(): number { + override get code(): number { return 0x03_01_00_01; } } export class TypeSpecNotFoundError extends BinaryProtocolError { - get code(): number { + override get code(): number { return 0x03_01_00_02; } } export class UnexpectedMessageError extends BinaryProtocolError { - get code(): number { + override get code(): number { return 0x03_01_00_03; } } export class InputDataError extends ProtocolError { - get code(): number { + override get code(): number { return 0x03_02_00_00; } } export class ParameterTypeMismatchError extends InputDataError { - get code(): number { + override get code(): number { return 0x03_02_01_00; } } export class StateMismatchError extends InputDataError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x03_02_02_00; } } export class ResultCardinalityMismatchError extends ProtocolError { - get code(): number { + override get code(): number { return 0x03_03_00_00; } } export class CapabilityError extends ProtocolError { - get code(): number { + override get code(): number { return 0x03_04_00_00; } } export class UnsupportedCapabilityError extends CapabilityError { - get code(): number { + override get code(): number { return 0x03_04_01_00; } } export class DisabledCapabilityError extends CapabilityError { - get code(): number { + override get code(): number { return 0x03_04_02_00; } } @@ -115,272 +117,278 @@ export class QueryError extends EdgeDBError { } export class InvalidSyntaxError extends QueryError { - get code(): number { + override get code(): number { return 0x04_01_00_00; } } export class EdgeQLSyntaxError extends InvalidSyntaxError { - get code(): number { + override get code(): number { return 0x04_01_01_00; } } export class SchemaSyntaxError extends InvalidSyntaxError { - get code(): number { + override get code(): number { return 0x04_01_02_00; } } export class GraphQLSyntaxError extends InvalidSyntaxError { - get code(): number { + override get code(): number { return 0x04_01_03_00; } } export class InvalidTypeError extends QueryError { - get code(): number { + override get code(): number { return 0x04_02_00_00; } } export class InvalidTargetError extends InvalidTypeError { - get code(): number { + override get code(): number { return 0x04_02_01_00; } } export class InvalidLinkTargetError extends InvalidTargetError { - get code(): number { + override get code(): number { return 0x04_02_01_01; } } export class InvalidPropertyTargetError extends InvalidTargetError { - get code(): number { + override get code(): number { return 0x04_02_01_02; } } export class InvalidReferenceError extends QueryError { - get code(): number { + override get code(): number { return 0x04_03_00_00; } } export class UnknownModuleError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_01; } } export class UnknownLinkError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_02; } } export class UnknownPropertyError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_03; } } export class UnknownUserError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_04; } } export class UnknownDatabaseError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_05; } } export class UnknownParameterError extends InvalidReferenceError { - get code(): number { + override get code(): number { return 0x04_03_00_06; } } +export class DeprecatedScopingError extends InvalidReferenceError { + override get code(): number { + return 0x04_03_00_07; + } +} + export class SchemaError extends QueryError { - get code(): number { + override get code(): number { return 0x04_04_00_00; } } export class SchemaDefinitionError extends QueryError { - get code(): number { + override get code(): number { return 0x04_05_00_00; } } export class InvalidDefinitionError extends SchemaDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_00; } } export class InvalidModuleDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_01; } } export class InvalidLinkDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_02; } } export class InvalidPropertyDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_03; } } export class InvalidUserDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_04; } } export class InvalidDatabaseDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_05; } } export class InvalidOperatorDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_06; } } export class InvalidAliasDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_07; } } export class InvalidFunctionDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_08; } } export class InvalidConstraintDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_09; } } export class InvalidCastDefinitionError extends InvalidDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_01_0a; } } export class DuplicateDefinitionError extends SchemaDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_00; } } export class DuplicateModuleDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_01; } } export class DuplicateLinkDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_02; } } export class DuplicatePropertyDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_03; } } export class DuplicateUserDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_04; } } export class DuplicateDatabaseDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_05; } } export class DuplicateOperatorDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_06; } } export class DuplicateViewDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_07; } } export class DuplicateFunctionDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_08; } } export class DuplicateConstraintDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_09; } } export class DuplicateCastDefinitionError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_0a; } } export class DuplicateMigrationError extends DuplicateDefinitionError { - get code(): number { + override get code(): number { return 0x04_05_02_0b; } } export class SessionTimeoutError extends QueryError { - get code(): number { + override get code(): number { return 0x04_06_00_00; } } export class IdleSessionTimeoutError extends SessionTimeoutError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x04_06_01_00; } } export class QueryTimeoutError extends SessionTimeoutError { - get code(): number { + override get code(): number { return 0x04_06_02_00; } } export class TransactionTimeoutError extends SessionTimeoutError { - get code(): number { + override get code(): number { return 0x04_06_0a_00; } } export class IdleTransactionTimeoutError extends TransactionTimeoutError { - get code(): number { + override get code(): number { return 0x04_06_0a_01; } } @@ -392,88 +400,88 @@ export class ExecutionError extends EdgeDBError { } export class InvalidValueError extends ExecutionError { - get code(): number { + override get code(): number { return 0x05_01_00_00; } } export class DivisionByZeroError extends InvalidValueError { - get code(): number { + override get code(): number { return 0x05_01_00_01; } } export class NumericOutOfRangeError extends InvalidValueError { - get code(): number { + override get code(): number { return 0x05_01_00_02; } } export class AccessPolicyError extends InvalidValueError { - get code(): number { + override get code(): number { return 0x05_01_00_03; } } export class QueryAssertionError extends InvalidValueError { - get code(): number { + override get code(): number { return 0x05_01_00_04; } } export class IntegrityError extends ExecutionError { - get code(): number { + override get code(): number { return 0x05_02_00_00; } } export class ConstraintViolationError extends IntegrityError { - get code(): number { + override get code(): number { return 0x05_02_00_01; } } export class CardinalityViolationError extends IntegrityError { - get code(): number { + override get code(): number { return 0x05_02_00_02; } } export class MissingRequiredError extends IntegrityError { - get code(): number { + override get code(): number { return 0x05_02_00_03; } } export class TransactionError extends ExecutionError { - get code(): number { + override get code(): number { return 0x05_03_00_00; } } export class TransactionConflictError extends TransactionError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x05_03_01_00; } } export class TransactionSerializationError extends TransactionConflictError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x05_03_01_01; } } export class TransactionDeadlockError extends TransactionConflictError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x05_03_01_02; } } export class WatchError extends ExecutionError { - get code(): number { + override get code(): number { return 0x05_04_00_00; } } @@ -491,7 +499,7 @@ export class AccessError extends EdgeDBError { } export class AuthenticationError extends AccessError { - get code(): number { + override get code(): number { return 0x07_01_00_00; } } @@ -503,34 +511,34 @@ export class AvailabilityError extends EdgeDBError { } export class BackendUnavailableError extends AvailabilityError { - protected static tags = { [tags.SHOULD_RETRY]: true }; - get code(): number { + protected static override tags = { [tags.SHOULD_RETRY]: true }; + override get code(): number { return 0x08_00_00_01; } } export class ServerOfflineError extends AvailabilityError { - protected static tags = { + protected static override tags = { [tags.SHOULD_RECONNECT]: true, [tags.SHOULD_RETRY]: true, }; - get code(): number { + override get code(): number { return 0x08_00_00_02; } } export class UnknownTenantError extends AvailabilityError { - protected static tags = { + protected static override tags = { [tags.SHOULD_RECONNECT]: true, [tags.SHOULD_RETRY]: true, }; - get code(): number { + override get code(): number { return 0x08_00_00_03; } } export class ServerBlockedError extends AvailabilityError { - get code(): number { + override get code(): number { return 0x08_00_00_04; } } @@ -542,7 +550,7 @@ export class BackendError extends EdgeDBError { } export class UnsupportedBackendFeatureError extends BackendError { - get code(): number { + override get code(): number { return 0x09_00_01_00; } } @@ -554,7 +562,7 @@ export class LogMessage extends EdgeDBError { } export class WarningMessage extends LogMessage { - get code(): number { + override get code(): number { return 0xf0_01_00_00; } } @@ -566,85 +574,85 @@ export class ClientError extends EdgeDBError { } export class ClientConnectionError extends ClientError { - get code(): number { + override get code(): number { return 0xff_01_00_00; } } export class ClientConnectionFailedError extends ClientConnectionError { - get code(): number { + override get code(): number { return 0xff_01_01_00; } } export class ClientConnectionFailedTemporarilyError extends ClientConnectionFailedError { - protected static tags = { + protected static override tags = { [tags.SHOULD_RECONNECT]: true, [tags.SHOULD_RETRY]: true, }; - get code(): number { + override get code(): number { return 0xff_01_01_01; } } export class ClientConnectionTimeoutError extends ClientConnectionError { - protected static tags = { + protected static override tags = { [tags.SHOULD_RECONNECT]: true, [tags.SHOULD_RETRY]: true, }; - get code(): number { + override get code(): number { return 0xff_01_02_00; } } export class ClientConnectionClosedError extends ClientConnectionError { - protected static tags = { + protected static override tags = { [tags.SHOULD_RECONNECT]: true, [tags.SHOULD_RETRY]: true, }; - get code(): number { + override get code(): number { return 0xff_01_03_00; } } export class InterfaceError extends ClientError { - get code(): number { + override get code(): number { return 0xff_02_00_00; } } export class QueryArgumentError extends InterfaceError { - get code(): number { + override get code(): number { return 0xff_02_01_00; } } export class MissingArgumentError extends QueryArgumentError { - get code(): number { + override get code(): number { return 0xff_02_01_01; } } export class UnknownArgumentError extends QueryArgumentError { - get code(): number { + override get code(): number { return 0xff_02_01_02; } } export class InvalidArgumentError extends QueryArgumentError { - get code(): number { + override get code(): number { return 0xff_02_01_03; } } export class NoDataError extends ClientError { - get code(): number { + override get code(): number { return 0xff_03_00_00; } } export class InternalClientError extends ClientError { - get code(): number { + override get code(): number { return 0xff_04_00_00; } } diff --git a/packages/driver/src/errors/map.ts b/packages/driver/src/errors/map.ts index 69a67eddc..7f9cf1fef 100644 --- a/packages/driver/src/errors/map.ts +++ b/packages/driver/src/errors/map.ts @@ -53,6 +53,7 @@ errorMapping.set(0x04_03_00_03, errors.UnknownPropertyError); errorMapping.set(0x04_03_00_04, errors.UnknownUserError); errorMapping.set(0x04_03_00_05, errors.UnknownDatabaseError); errorMapping.set(0x04_03_00_06, errors.UnknownParameterError); +errorMapping.set(0x04_03_00_07, errors.DeprecatedScopingError); errorMapping.set(0x04_04_00_00, errors.SchemaError); errorMapping.set(0x04_05_00_00, errors.SchemaDefinitionError); errorMapping.set(0x04_05_01_00, errors.InvalidDefinitionError); diff --git a/packages/driver/src/fetchConn.ts b/packages/driver/src/fetchConn.ts index 5f9f76296..6212a3df1 100644 --- a/packages/driver/src/fetchConn.ts +++ b/packages/driver/src/fetchConn.ts @@ -68,7 +68,7 @@ class BaseFetchConnection extends BaseRawConnection { this.authenticatedFetch = fetch; } - protected async _waitForMessage(): Promise { + protected override async _waitForMessage(): Promise { if (this.buffer.takeMessage()) { return; } @@ -141,11 +141,11 @@ class BaseFetchConnection extends BaseRawConnection { } } - protected _sendData(data: Uint8Array): void { + protected override _sendData(data: Uint8Array): void { this.__sendData(data); } - async fetch(...args: Parameters) { + override async fetch(...args: Parameters) { // In protocol v3 the format of the parse/execute messages depend on the // protocol version. In the fetch conn we don't know the server's supported // proto version until after the first message is sent, so the first @@ -183,9 +183,9 @@ class BaseFetchConnection extends BaseRawConnection { } export class AdminUIFetchConnection extends BaseFetchConnection { - adminUIMode = true; + override adminUIMode = true; - static create( + static override create( this: T, fetch: AuthenticatedFetch, registry: CodecsRegistry, diff --git a/packages/driver/src/rawConn.ts b/packages/driver/src/rawConn.ts index c7852b383..b8c61ecf3 100644 --- a/packages/driver/src/rawConn.ts +++ b/packages/driver/src/rawConn.ts @@ -194,7 +194,7 @@ export class RawConnection extends BaseRawConnection { } } - protected async _waitForMessage(): Promise { + protected override async _waitForMessage(): Promise { if (this.buffer.takeMessage()) { return; } @@ -213,7 +213,7 @@ export class RawConnection extends BaseRawConnection { } } - protected _sendData(data: Uint8Array): void { + protected override _sendData(data: Uint8Array): void { this.sock.write(data); } @@ -236,14 +236,14 @@ export class RawConnection extends BaseRawConnection { return tls.connect(opts); } - protected _abort(): void { + protected override _abort(): void { if (this.sock && this.connected) { this.sock.destroy(); } super._abort(); } - async close(): Promise { + override async close(): Promise { if (this.sock && this.connected) { this.sock.write( new WriteMessageBuffer().beginMessage(chars.$X).endMessage().unwrap(), diff --git a/packages/driver/src/reflection/strictMap.ts b/packages/driver/src/reflection/strictMap.ts index 3ed819b5b..647b2c0df 100644 --- a/packages/driver/src/reflection/strictMap.ts +++ b/packages/driver/src/reflection/strictMap.ts @@ -21,7 +21,7 @@ export class StrictMap extends Map { error on missing keys instead of returning an undefined. This is easier to work with when everything is strictly typed. */ - get(key: K): V { + override get(key: K): V { if (!this.has(key)) { throw new Error(`key "${key}" is not found`); } diff --git a/packages/tsconfig/base.json b/packages/tsconfig/base.json index 0c2758394..24996518c 100644 --- a/packages/tsconfig/base.json +++ b/packages/tsconfig/base.json @@ -14,6 +14,7 @@ "noImplicitThis": true, "removeComments": true, "stripInternal": true, + "noImplicitOverride": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "useDefineForClassFields": true,