diff --git a/src/@types/partials.ts b/src/@types/partials.ts index e4700b3c1..a729d80dc 100644 --- a/src/@types/partials.ts +++ b/src/@types/partials.ts @@ -82,3 +82,12 @@ export enum HistoryVisibility { Shared = "shared", WorldReadable = "world_readable", } + +export interface IUsageLimit { + // "hs_disabled" is NOT a specced string, but is used in Synapse + // This is tracked over at https://github.com/matrix-org/synapse/issues/9237 + // eslint-disable-next-line camelcase + limit_type: "monthly_active_user" | "hs_disabled" | string; + // eslint-disable-next-line camelcase + admin_contact?: string; +} diff --git a/src/client.ts b/src/client.ts index a54161d6d..bd3a631fe 100644 --- a/src/client.ts +++ b/src/client.ts @@ -97,7 +97,7 @@ import { IRecoveryKey, ISecretStorageKeyInfo, } from "./crypto/api"; -import { SyncState } from "./sync.api"; +import { SyncState } from "./sync"; import { EventTimelineSet } from "./models/event-timeline-set"; import { VerificationRequest } from "./crypto/verification/request/VerificationRequest"; import { VerificationBase as Verification } from "./crypto/verification/Base"; diff --git a/src/http-api.ts b/src/http-api.ts index ac98c35ae..077a254e9 100644 --- a/src/http-api.ts +++ b/src/http-api.ts @@ -30,7 +30,7 @@ import type { Request as _Request, CoreOptions } from "request"; // waiting for the delay to elapse. import * as callbacks from "./realtime-callbacks"; import { IUploadOpts } from "./@types/requests"; -import { IAbortablePromise } from "./@types/partials"; +import { IAbortablePromise, IUsageLimit } from "./@types/partials"; import { IDeferred } from "./utils"; import { Callback } from "./client"; import * as utils from "./utils"; @@ -1015,7 +1015,7 @@ function getResponseContentType(response: XMLHttpRequest | IncomingMessage): Par } } -interface IErrorJson { +interface IErrorJson extends Partial { [key: string]: any; // extensible errcode?: string; error?: string; diff --git a/src/sync.api.ts b/src/sync.api.ts deleted file mode 100644 index 384e027f6..000000000 --- a/src/sync.api.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright 2021 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// TODO: Merge this with sync.js once converted - -export enum SyncState { - Error = "ERROR", - Prepared = "PREPARED", - Stopped = "STOPPED", - Syncing = "SYNCING", - Catchup = "CATCHUP", - Reconnecting = "RECONNECTING", -} diff --git a/src/sync.ts b/src/sync.ts index f870284f6..88d12f9ef 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -34,7 +34,6 @@ import { PushProcessor } from "./pushprocessor"; import { logger } from './logger'; import { InvalidStoreError } from './errors'; import { IStoredClientOpts, MatrixClient, PendingEventOrdering } from "./client"; -import { SyncState } from "./sync.api"; import { Category, IEphemeral, @@ -68,6 +67,15 @@ const BUFFER_PERIOD_MS = 80 * 1000; // keepAlive is successful but the server /sync fails. const FAILED_SYNC_ERROR_THRESHOLD = 3; +export enum SyncState { + Error = "ERROR", + Prepared = "PREPARED", + Stopped = "STOPPED", + Syncing = "SYNCING", + Catchup = "CATCHUP", + Reconnecting = "RECONNECTING", +} + function getFilterName(userId: string, suffix?: string): string { // scope this on the user ID because people may login on many accounts // and they all need to be stored! @@ -87,7 +95,7 @@ interface ISyncOptions { } export interface ISyncStateData { - error?: Error; + error?: MatrixError; oldSyncToken?: string; nextSyncToken?: string; catchingUp?: boolean; @@ -477,7 +485,7 @@ export class SyncApi { return this.syncStateData; } - public async recoverFromSyncStartupError(savedSyncPromise: Promise, err: Error): Promise { + public async recoverFromSyncStartupError(savedSyncPromise: Promise, err: MatrixError): Promise { // Wait for the saved sync to complete - we send the pushrules and filter requests // before the saved sync has finished so they can run in parallel, but only process // the results after the saved sync is done. Equivalently, we wait for it to finish