summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-js-sdk/lib/models/MSC3089TreeSpace.d.ts
blob: fce3d152b16c3593c9120922f83333fc84eddcf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import { MatrixClient } from "../client";
import { IEncryptedFile } from "../@types/event";
import { Room } from "./room";
import { IContent } from "./event";
import { MSC3089Branch } from "./MSC3089Branch";
import { ISendEventResponse } from "../@types/requests";
import { FileType } from "../http-api";
/**
 * The recommended defaults for a tree space's power levels. Note that this
 * is UNSTABLE and subject to breaking changes without notice.
 */
export declare const DEFAULT_TREE_POWER_LEVELS_TEMPLATE: {
    invite: number;
    kick: number;
    ban: number;
    redact: number;
    state_default: number;
    events_default: number;
    users_default: number;
    events: {
        "m.room.power_levels": number;
        "m.room.history_visibility": number;
        "m.room.tombstone": number;
        "m.room.encryption": number;
        "m.room.name": number;
        "m.room.message": number;
        "m.room.encrypted": number;
        "m.sticker": number;
    };
    users: {};
};
/**
 * Ease-of-use representation for power levels represented as simple roles.
 * Note that this is UNSTABLE and subject to breaking changes without notice.
 */
export declare enum TreePermissions {
    Viewer = "viewer",
    Editor = "editor",
    Owner = "owner"
}
/**
 * Represents a [MSC3089](https://github.com/matrix-org/matrix-doc/pull/3089)
 * file tree Space. Note that this is UNSTABLE and subject to breaking changes
 * without notice.
 */
export declare class MSC3089TreeSpace {
    private client;
    readonly roomId: string;
    readonly room: Room;
    constructor(client: MatrixClient, roomId: string);
    /**
     * Syntactic sugar for room ID of the Space.
     */
    get id(): string;
    /**
     * Whether or not this is a top level space.
     */
    get isTopLevel(): boolean;
    /**
     * Sets the name of the tree space.
     * @param name - The new name for the space.
     * @returns Promise which resolves when complete.
     */
    setName(name: string): Promise<void>;
    /**
     * Invites a user to the tree space. They will be given the default Viewer
     * permission level unless specified elsewhere.
     * @param userId - The user ID to invite.
     * @param andSubspaces - True (default) to invite the user to all
     * directories/subspaces too, recursively.
     * @param shareHistoryKeys - True (default) to share encryption keys
     * with the invited user. This will allow them to decrypt the events (files)
     * in the tree. Keys will not be shared if the room is lacking appropriate
     * history visibility (by default, history visibility is "shared" in trees,
     * which is an appropriate visibility for these purposes).
     * @returns Promise which resolves when complete.
     */
    invite(userId: string, andSubspaces?: boolean, shareHistoryKeys?: boolean): Promise<void>;
    private retryInvite;
    /**
     * Sets the permissions of a user to the given role. Note that if setting a user
     * to Owner then they will NOT be able to be demoted. If the user does not have
     * permission to change the power level of the target, an error will be thrown.
     * @param userId - The user ID to change the role of.
     * @param role - The role to assign.
     * @returns Promise which resolves when complete.
     */
    setPermissions(userId: string, role: TreePermissions): Promise<void>;
    /**
     * Gets the current permissions of a user. Note that any users missing explicit permissions (or not
     * in the space) will be considered Viewers. Appropriate membership checks need to be performed
     * elsewhere.
     * @param userId - The user ID to check permissions of.
     * @returns The permissions for the user, defaulting to Viewer.
     */
    getPermissions(userId: string): TreePermissions;
    /**
     * Creates a directory under this tree space, represented as another tree space.
     * @param name - The name for the directory.
     * @returns Promise which resolves to the created directory.
     */
    createDirectory(name: string): Promise<MSC3089TreeSpace>;
    /**
     * Gets a list of all known immediate subdirectories to this tree space.
     * @returns The tree spaces (directories). May be empty, but not null.
     */
    getDirectories(): MSC3089TreeSpace[];
    /**
     * Gets a subdirectory of a given ID under this tree space. Note that this will not recurse
     * into children and instead only look one level deep.
     * @param roomId - The room ID (directory ID) to find.
     * @returns The directory, or undefined if not found.
     */
    getDirectory(roomId: string): MSC3089TreeSpace | undefined;
    /**
     * Deletes the tree, kicking all members and deleting **all subdirectories**.
     * @returns Promise which resolves when complete.
     */
    delete(): Promise<void>;
    private getOrderedChildren;
    private getParentRoom;
    /**
     * Gets the current order index for this directory. Note that if this is the top level space
     * then -1 will be returned.
     * @returns The order index of this space.
     */
    getOrder(): number;
    /**
     * Sets the order index for this directory within its parent. Note that if this is a top level
     * space then an error will be thrown. -1 can be used to move the child to the start, and numbers
     * larger than the number of children can be used to move the child to the end.
     * @param index - The new order index for this space.
     * @returns Promise which resolves when complete.
     * @throws Throws if this is a top level space.
     */
    setOrder(index: number): Promise<void>;
    /**
     * Creates (uploads) a new file to this tree. The file must have already been encrypted for the room.
     * The file contents are in a type that is compatible with MatrixClient.uploadContent().
     * @param name - The name of the file.
     * @param encryptedContents - The encrypted contents.
     * @param info - The encrypted file information.
     * @param additionalContent - Optional event content fields to include in the message.
     * @returns Promise which resolves to the file event's sent response.
     */
    createFile(name: string, encryptedContents: FileType, info: Partial<IEncryptedFile>, additionalContent?: IContent): Promise<ISendEventResponse>;
    /**
     * Retrieves a file from the tree.
     * @param fileEventId - The event ID of the file.
     * @returns The file, or null if not found.
     */
    getFile(fileEventId: string): MSC3089Branch | null;
    /**
     * Gets an array of all known files for the tree.
     * @returns The known files. May be empty, but not null.
     */
    listFiles(): MSC3089Branch[];
    /**
     * Gets an array of all known files for the tree, including inactive/invalid ones.
     * @returns The known files. May be empty, but not null.
     */
    listAllFiles(): MSC3089Branch[];
}
//# sourceMappingURL=MSC3089TreeSpace.d.ts.map