<commit_before>// Type definitions for matrix-appservice-bridge 1.11
// Project: https://github.com/matrix-org/matrix-appservice-bridge
// Definitions by: <NAME> (李卓桓) <https://github.com/huan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1

/// <reference types="node" />

import { EventEmitter } from 'events';

import {
    EventType,
    MsgType,
    MatrixClient,
    MembershipType,
} from 'matrix-js-sdk';

export type Controller = any;

export namespace AppServiceRegistration {
    function generateToken(): string;
}

export interface AppServiceRegistration {
    sender_localpart: string;
}

export interface BridgeOptions {
    controller: Controller;
    domain: string;
    homeserverUrl: string;
    registration: AppServiceRegistration;
    suppressEcho?: boolean;     // True to stop receiving onEvent callbacks for events which were sent by a bridge user. Default: true.
}

export interface BridgeConfig {
    schema: string;
}

export interface CliOptions {
    bridgeConfig?: BridgeConfig;
    enableRegistration?: boolean;
    enableLocalpart?: boolean;
    generateRegistration: (reg: any, callback: (r: any) => void) => void;
    port: number;
    registrationPath?: string;
    run: (port: number, config: any) => void;
}

export interface RoomMemberDict {
    [id: string]: {
    display_name: string,
    avatar_url: string,
    };
}
export interface RemoteRoomDict {
    [id: string]: RemoteRoom;
}
export interface EntryDict {
    [id: string]: Entry[];
}

export interface RoomInfo {
    id: string;         // The matrix room ID
    state: object[];       // The raw state events for this room
    realJoinedUsers: string[];  //  A list of user IDs of real matrix users that have joined this room.
    remoteJoinedUsers: string[];  //  A list of
}

export interface Entry {
    id: string;             //  The unique ID for this entry.
    matrix_id: string;             // "room_id",
    remote_id: string;             // "remote_room_id",
    matrix: null | MatrixRoom;  // <nullable> The matrix room, if applicable.
    remote: null | RemoteRoom;  // <nullable> The remote room, if applicable.
    data: null | object;      //  <nullable> Information about this mapping, which may be an empty.
}

/* ************* */

export type AppService = any;

export class AppServiceBot {
    constructor(
    client: MatrixClient,
    registration: AppServiceRegistration,
    memberCache: MembershipCache,
    )
    getJoinedMembers(roomId: string): Promise<RoomMemberDict>;
    getJoinedRooms(): Promise<string[]>;
    isRemoteUser(userId: string): boolean;
}

export interface ProvisionedUser {
    name?: string;      // The display name to set for the provisioned user.
    url?: string;      // The avatar URL to set for the provisioned user.
    remote?: RemoteUser;  //
}

export interface ThirdPartyLocationResult {
    alias: string;  // The Matrix room alias to the portal room representing this 3PL
    protocol: string;  // The name of the 3PE protocol
    fields: object;  // The normalised values of the location query field data.
}

export type BridgeGetProtocol = any;
export type BridgeGetLocation = any;
export type BridgeParseLocation = any;
export type BridgeGetUser = any;
export type BridgeParseUser = any;
export type BridgeThirdPartyProtocolResult = any;

export interface BridgeThirdPartyLookup {
    protocols: string[];        // list of recognised protocol names. If present, lookups for unrecognised protocols will be automatically rejected.
    getProtocol: BridgeGetProtocol;    // Function. Called for requests for 3PE query metadata.
    getLocation: BridgeGetLocation;    // Function. Called for requests for 3PLs.
    parseLocation: BridgeParseLocation;  // Function. Called for reverse parse requests on 3PL aliases.
    getUser: BridgeGetUser;        // Function. Called for requests for 3PUs.
    parseUser: BridgeParseUser;      // Function. Called for reverse parse requests on 3PU user IDs.
}

export interface ThirdPartyUserResult {
    userid: string;  // The Matrix user ID for the virtual representing this 3PU
    protocol: string;  // The name of the 3PE protocol
    fields: object;  // The normalised values of the user query field data.
}

export class RequestFactory {
    constructor()

    addDefaultRejectCallback(fn: (request: Request, reject: any) => any): void;
    addDefaultResolveCallback(fn: (request: Request, reject: any) => any): void;
    addDefaultTimeoutCallback(fn: (request: Request) => any, durationMs: number): void;
    newRequest(opts?: object): Request;
}

export class ClientFactory {
    constructor(options: any)

    configure(baseUrl: string, appServiceToken: string, appServiceUserId: string): void;
    getClientAs(userId?: string, request?: Request): MatrixClient;
    setLogFunction(func: (...args: any) => any): void;
}

export interface ProvisionedRoom {
    creationOpts: {
    room_alias_name: string
    name?: string,
    topic?: string
    };
    remote?: RemoteRoom;
}

export class Bridge {
    constructor(opts: BridgeOptions)
    run(port: number, config: object, appServiceInstance?: AppService): void;
    getIntent(userId?: string, request?: Request): Intent;<commit_msg>fix public property opts (#42769)<commit_after>// Type definitions for matrix-appservice-bridge 1.11
// Project: https://github.com/matrix-org/matrix-appservice-bridge
// Definitions by: <NAME> (李卓桓) <https://github.com/huan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.1

/// <reference types="node" />

import { EventEmitter } from 'events';

import {
    EventType,
    MsgType,
    MatrixClient,
    MembershipType,
} from 'matrix-js-sdk';

export type Controller = any;

export namespace AppServiceRegistration {
    function generateToken(): string;
}

export interface AppServiceRegistration {
    sender_localpart: string;
}

export interface BridgeOptions {
    controller: Controller;
    domain: string;
    homeserverUrl: string;
    registration: AppServiceRegistration;
    suppressEcho?: boolean;     // True to stop receiving onEvent callbacks for events which were sent by a bridge user. Default: true.
}

export interface BridgeConfig {
    schema: string;
}

export interface CliOptions {
    bridgeConfig?: BridgeConfig;
    enableRegistration?: boolean;
    enableLocalpart?: boolean;
    generateRegistration: (reg: any, callback: (r: any) => void) => void;
    port: number;
    registrationPath?: string;
    run: (port: number, config: any) => void;
}

export interface RoomMemberDict {
    [id: string]: {
    display_name: string,
    avatar_url: string,
    };
}
export interface RemoteRoomDict {
    [id: string]: RemoteRoom;
}
export interface EntryDict {
    [id: string]: Entry[];
}

export interface RoomInfo {
    id: string;         // The matrix room ID
    state: object[];       // The raw state events for this room
    realJoinedUsers: string[];  //  A list of user IDs of real matrix users that have joined this room.
    remoteJoinedUsers: string[];  //  A list of
}

export interface Entry {
    id: string;             //  The unique ID for this entry.
    matrix_id: string;             // "room_id",
    remote_id: string;             // "remote_room_id",
    matrix: null | MatrixRoom;  // <nullable> The matrix room, if applicable.
    remote: null | RemoteRoom;  // <nullable> The remote room, if applicable.
    data: null | object;      //  <nullable> Information about this mapping, which may be an empty.
}

/* ************* */

export type AppService = any;

export class AppServiceBot {
    constructor(
    client: MatrixClient,
    registration: AppServiceRegistration,
    memberCache: MembershipCache,
    )
    getJoinedMembers(roomId: string): Promise<RoomMemberDict>;
    getJoinedRooms(): Promise<string[]>;
    isRemoteUser(userId: string): boolean;
}

export interface ProvisionedUser {
    name?: string;      // The display name to set for the provisioned user.
    url?: string;      // The avatar URL to set for the provisioned user.
    remote?: RemoteUser;  //
}

export interface ThirdPartyLocationResult {
    alias: string;  // The Matrix room alias to the portal room representing this 3PL
    protocol: string;  // The name of the 3PE protocol
    fields: object;  // The normalised values of the location query field data.
}

export type BridgeGetProtocol = any;
export type BridgeGetLocation = any;
export type BridgeParseLocation = any;
export type BridgeGetUser = any;
export type BridgeParseUser = any;
export type BridgeThirdPartyProtocolResult = any;

export interface BridgeThirdPartyLookup {
    protocols: string[];        // list of recognised protocol names. If present, lookups for unrecognised protocols will be automatically rejected.
    getProtocol: BridgeGetProtocol;    // Function. Called for requests for 3PE query metadata.
    getLocation: BridgeGetLocation;    // Function. Called for requests for 3PLs.
    parseLocation: BridgeParseLocation;  // Function. Called for reverse parse requests on 3PL aliases.
    getUser: BridgeGetUser;        // Function. Called for requests for 3PUs.
    parseUser: BridgeParseUser;      // Function. Called for reverse parse requests on 3PU user IDs.
}

export interface ThirdPartyUserResult {
    userid: string;  // The Matrix user ID for the virtual representing this 3PU
    protocol: string;  // The name of the 3PE protocol
    fields: object;  // The normalised values of the user query field data.
}

export class RequestFactory {
    constructor()

    addDefaultRejectCallback(fn: (request: Request, reject: any) => any): void;
    addDefaultResolveCallback(fn: (request: Request, reject: any) => any): void;
    addDefaultTimeoutCallback(fn: (request: Request) => any, durationMs: number): void;
    newRequest(opts?: object): Request;
}

export class ClientFactory {
    constructor(options: any)

    configure(baseUrl: string, appServiceToken: string, appServiceUserId: string): void;
    getClientAs(userId?: string, request?: Request): MatrixClient;
    setLogFunction(func: (...args: any) => any): void;
}

export interface ProvisionedRoom {
    creationOpts: {
    room_alias_name: string
    name?: string,
    topic?: string
    };
    remote?: RemoteRoom;
}

export class Bridge {
    opts: BridgeOptions;
    constructor(opts: BridgeOptions);
    run(port: number, config: object, appServiceInstance?: AppService): void;
    getIntent(userId?: string, request?: Request): Intent;
{'fraction_non_alphanumeric': 0.09901178259217028, 'fraction_numerical': 0.003135689851767389, 'mean_word_length': 3.511358765537934, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4140940', 'n_tokens_mistral': 2897, 'n_tokens_neox': 2862, 'n_words': 1017}