fix lint errors
This commit is contained in:
		
							parent
							
								
									cbd6cf1d1a
								
							
						
					
					
						commit
						97ac139ca8
					
				
					 35 changed files with 71 additions and 74 deletions
				
			
		| 
						 | 
				
			
			@ -8,13 +8,35 @@
 | 
			
		|||
    "plugins": [
 | 
			
		||||
        "@typescript-eslint"
 | 
			
		||||
    ],
 | 
			
		||||
    "extends": [
 | 
			
		||||
        "eslint:recommended",
 | 
			
		||||
        "plugin:@typescript-eslint/recommended"
 | 
			
		||||
    ],
 | 
			
		||||
    "rules": {
 | 
			
		||||
        "@typescript-eslint/naming-convention": "off",
 | 
			
		||||
        "@typescript-eslint/semi": "warn",
 | 
			
		||||
        "curly": "warn",
 | 
			
		||||
        "eqeqeq": "warn",
 | 
			
		||||
        "no-throw-literal": "warn",
 | 
			
		||||
        "semi": "off"
 | 
			
		||||
        "semi": "off",
 | 
			
		||||
        "@typescript-eslint/no-unused-vars": [
 | 
			
		||||
            "error",
 | 
			
		||||
            {
 | 
			
		||||
                "argsIgnorePattern": "^_"
 | 
			
		||||
            }
 | 
			
		||||
        ],
 | 
			
		||||
        "no-unused-vars": "off",
 | 
			
		||||
        "no-useless-escape": "off",
 | 
			
		||||
        "no-inner-declarations": "off",
 | 
			
		||||
        "no-case-declarations": "off",
 | 
			
		||||
        "@typescript-eslint/prefer-regexp-exec": "off",
 | 
			
		||||
        "@typescript-eslint/no-inferrable-types": "off",
 | 
			
		||||
        "@typescript-eslint/unbound-method": "off",
 | 
			
		||||
        "@typescript-eslint/no-unnecessary-type-assertion": "off",
 | 
			
		||||
        "@typescript-eslint/restrict-template-expressions": "off",
 | 
			
		||||
        "@typescript-eslint/no-namespace": "off",
 | 
			
		||||
        "@typescript-eslint/ban-types": "off",
 | 
			
		||||
        "@typescript-eslint/no-explicit-any": "off"
 | 
			
		||||
    },
 | 
			
		||||
    "ignorePatterns": [
 | 
			
		||||
        "**/*.d.ts"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,12 @@
 | 
			
		|||
import { Client, Collection, CreatedCollection, CreatedRule, DatabaseClient, Rule, SDK } from "../appwrite";
 | 
			
		||||
import { CreateRuleWizardContext } from "../ui/createRuleWizard";
 | 
			
		||||
import { Client, Collection, CreatedCollection, CreatedRule, DatabaseClient, Rule } from "../appwrite";
 | 
			
		||||
import { AppwriteSDK } from '../constants';
 | 
			
		||||
import AppwriteCall from "../utils/AppwriteCall";
 | 
			
		||||
 | 
			
		||||
const sdk: SDK = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
export class Database {
 | 
			
		||||
    private readonly database: DatabaseClient;
 | 
			
		||||
 | 
			
		||||
    constructor(client: Client) {
 | 
			
		||||
        this.database = new sdk.Database(client);
 | 
			
		||||
        this.database = new AppwriteSDK.Database(client);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async getCollection(collectionId: string): Promise<Collection | undefined> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,11 @@
 | 
			
		|||
import { MarkdownString } from 'vscode';
 | 
			
		||||
import { AppwriteHealth, Client, HealthClient, SDK } from "../appwrite";
 | 
			
		||||
const sdk: SDK = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
import { AppwriteHealth, Client, HealthClient } from "../appwrite";
 | 
			
		||||
import { AppwriteSDK } from '../constants';
 | 
			
		||||
export class Health {
 | 
			
		||||
    private readonly health: HealthClient;
 | 
			
		||||
 | 
			
		||||
    constructor(client: Client) {
 | 
			
		||||
        this.health = new sdk.Health(client);
 | 
			
		||||
        this.health = new AppwriteSDK.Health(client);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,12 @@
 | 
			
		|||
import { Client, Collection, CreatedCollection, CreatedRule, DatabaseClient, File, FilesList, Rule, SDK, StorageClient } from "../appwrite";
 | 
			
		||||
import { CreateRuleWizardContext } from "../ui/createRuleWizard";
 | 
			
		||||
import { Client, FilesList, StorageClient } from "../appwrite";
 | 
			
		||||
import { AppwriteSDK } from '../constants';
 | 
			
		||||
import AppwriteCall from "../utils/AppwriteCall";
 | 
			
		||||
 | 
			
		||||
const sdk: SDK = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
export class Storage {
 | 
			
		||||
    private readonly storage: StorageClient;
 | 
			
		||||
 | 
			
		||||
    constructor(client: Client) {
 | 
			
		||||
        this.storage = new sdk.Storage(client);
 | 
			
		||||
        this.storage = new AppwriteSDK.Storage(client);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async listFiles(): Promise<FilesList | undefined> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,14 +1,13 @@
 | 
			
		|||
import { window } from "vscode";
 | 
			
		||||
import { Client, Log, SDK, User, UsersClient } from "../appwrite";
 | 
			
		||||
import { ext } from "../extensionVariables";
 | 
			
		||||
import { Client, Log, User, UsersClient } from "../appwrite";
 | 
			
		||||
import { AppwriteSDK } from "../constants";
 | 
			
		||||
import AppwriteCall from "../utils/AppwriteCall";
 | 
			
		||||
const sdk: SDK = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
export class Users {
 | 
			
		||||
    private readonly users: UsersClient;
 | 
			
		||||
 | 
			
		||||
    constructor(client: Client) {
 | 
			
		||||
        this.users = new sdk.Users(client);
 | 
			
		||||
        this.users = new AppwriteSDK.Users(client);
 | 
			
		||||
    }
 | 
			
		||||
    public async createNewUser(context: CreateUserContext): Promise<void> {
 | 
			
		||||
        await AppwriteCall<User, void>(this.users.create(context.email, context.password, context.name), (user) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +22,7 @@ export class Users {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    public async getLogs(userId: string): Promise<Log[]> {
 | 
			
		||||
        return await AppwriteCall<Log[], Log[]>(this.users.getLogs(userId)) ?? [];
 | 
			
		||||
        return (await AppwriteCall<Log[], Log[]>(this.users.getLogs(userId))) ?? [];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,11 @@
 | 
			
		|||
import { Client, SDK } from "./appwrite";
 | 
			
		||||
import { Client } from "./appwrite";
 | 
			
		||||
import { Database } from "./appwrite/Database";
 | 
			
		||||
import { Health } from "./appwrite/Health";
 | 
			
		||||
import { Storage } from "./appwrite/Storage";
 | 
			
		||||
import { Users } from "./appwrite/Users";
 | 
			
		||||
import { AppwriteSDK } from "./constants";
 | 
			
		||||
import { AppwriteProjectConfiguration } from "./settings";
 | 
			
		||||
 | 
			
		||||
const sdk: SDK = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
export let client: Client;
 | 
			
		||||
export let clientConfig: { endpoint: string; projectId: string; secret: string };
 | 
			
		||||
export let usersClient: Users | undefined;
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +14,7 @@ export let databaseClient: Database | undefined;
 | 
			
		|||
export let storageClient: Storage | undefined;
 | 
			
		||||
 | 
			
		||||
function initAppwriteClient({ endpoint, projectId, secret }: AppwriteProjectConfiguration) {
 | 
			
		||||
    client = new sdk.Client();
 | 
			
		||||
    client = new AppwriteSDK.Client();
 | 
			
		||||
    clientConfig = { endpoint, projectId, secret };
 | 
			
		||||
    client.setEndpoint(endpoint).setProject(projectId).setKey(secret);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +26,7 @@ function initAppwriteClient({ endpoint, projectId, secret }: AppwriteProjectConf
 | 
			
		|||
    return client;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function createAppwriteClient(config?: AppwriteProjectConfiguration) {
 | 
			
		||||
export function createAppwriteClient(config?: AppwriteProjectConfiguration): void {
 | 
			
		||||
    if (config) {
 | 
			
		||||
        initAppwriteClient(config);
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ import { addProjectConfiguration } from '../settings';
 | 
			
		|||
import { addProjectWizard } from "../ui/AddProjectWizard";
 | 
			
		||||
import { refreshTree } from '../utils/refreshTree';
 | 
			
		||||
 | 
			
		||||
export async function connectAppwrite() {
 | 
			
		||||
export async function connectAppwrite():  Promise<void> {
 | 
			
		||||
    const projectConfiguration = await addProjectWizard();
 | 
			
		||||
    if (projectConfiguration) {
 | 
			
		||||
        addProjectConfiguration(projectConfiguration);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ export async function deleteDocument(documentTreeItem: DocumentTreeItem): Promis
 | 
			
		|||
        const shouldDelete = await confirmDialog(`Delete document "${document["$id"]}" from ${collection.name}?`);
 | 
			
		||||
        if (shouldDelete) {
 | 
			
		||||
            await databaseClient.deleteDocument(collection.$id, document["$id"]);
 | 
			
		||||
            documentTreeItem.parent.window.showInformationMessage(`Deleted document "${document["$id"]}" from ${collection.name}.`);
 | 
			
		||||
            window.showInformationMessage(`Deleted document "${document["$id"]}" from ${collection.name}.`);
 | 
			
		||||
        }
 | 
			
		||||
    } catch (e) {
 | 
			
		||||
        window.showErrorMessage(e);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,6 @@
 | 
			
		|||
import { window } from "vscode";
 | 
			
		||||
import { databaseClient } from "../../../client";
 | 
			
		||||
import { CollapsableTreeItem } from "../../../tree/CollapsableTreeItem";
 | 
			
		||||
import { PermissionsTreeItem } from "../../../tree/database/settings/PermissionsTreeItem";
 | 
			
		||||
import { PermissionTreeItem } from "../../../tree/database/settings/PermissionTreeItem";
 | 
			
		||||
 | 
			
		||||
export type CreatePermissionWizardContext = {
 | 
			
		||||
    kind: "read" | "write";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import { CollectionTreeItem } from "../../tree/database/CollectionTreeItem";
 | 
			
		||||
 | 
			
		||||
export async function refreshCollection(collectionTreeItem: CollectionTreeItem) {
 | 
			
		||||
export async function refreshCollection(collectionTreeItem: CollectionTreeItem):  Promise<void> {
 | 
			
		||||
    await collectionTreeItem.refresh();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ import { window } from "vscode";
 | 
			
		|||
import { createAppwriteClient } from '../../client';
 | 
			
		||||
import { addProjectWizard } from "../../ui/AddProjectWizard";
 | 
			
		||||
 | 
			
		||||
export async function addProject() {
 | 
			
		||||
export async function addProject(): Promise<void> {
 | 
			
		||||
    const projectConfiguration = await addProjectWizard();
 | 
			
		||||
 | 
			
		||||
    if (projectConfiguration) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import { removeProjectConfig } from "../../settings";
 | 
			
		||||
import { ProjectTreeItem } from "../../tree/projects/ProjectTreeItem";
 | 
			
		||||
 | 
			
		||||
export async function removeProject(project: ProjectTreeItem | string) {
 | 
			
		||||
export async function removeProject(project: ProjectTreeItem | string): Promise<void> {
 | 
			
		||||
    if (typeof project === "string") {
 | 
			
		||||
        await removeProjectConfig(project);
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import { setActiveProjectId } from '../../settings';
 | 
			
		||||
import { ProjectTreeItem } from "../../tree/projects/ProjectTreeItem";
 | 
			
		||||
 | 
			
		||||
export async function setActiveProject(treeItem: ProjectTreeItem) {
 | 
			
		||||
export async function setActiveProject(treeItem: ProjectTreeItem): Promise<void> {
 | 
			
		||||
    if (treeItem === undefined) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import { commands, ExtensionContext } from "vscode";
 | 
			
		||||
import { AppwriteTree, ext } from "../extensionVariables";
 | 
			
		||||
import { AppwriteTree } from "../extensionVariables";
 | 
			
		||||
import { refreshAllViews, refreshTree } from "../utils/refreshTree";
 | 
			
		||||
import { connectAppwrite } from "./connectAppwrite";
 | 
			
		||||
import { createCollection } from "./database/createCollection";
 | 
			
		||||
| 
						 | 
				
			
			@ -86,11 +86,11 @@ export function registerCommands(context: ExtensionContext): void {
 | 
			
		|||
    registerCommand("editPermission", editPermission, "database");
 | 
			
		||||
 | 
			
		||||
    /** Health **/
 | 
			
		||||
    registerCommand("refreshHealth", () => {}, "health");
 | 
			
		||||
    registerCommand("refreshHealth", undefined, "health");
 | 
			
		||||
    registerCommand("openHealthDocumentation", () => openDocumentation("health"));
 | 
			
		||||
 | 
			
		||||
    /** Storage **/
 | 
			
		||||
    registerCommand("refreshStorage", () => {}, "storage");
 | 
			
		||||
    registerCommand("refreshStorage", undefined, "storage");
 | 
			
		||||
    registerCommand("openStorageDocumentation", () => openDocumentation("storage"));
 | 
			
		||||
 | 
			
		||||
    /** Projects **/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@ function getUserUrl(userId: string, endpoint: string, projectId: string): string
 | 
			
		|||
    return `${getConsoleUrlFromEndpoint(endpoint)}/users/user?id=${userId}&project=${projectId}`;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function openUserInConsole(item: UserTreeItem) {
 | 
			
		||||
export async function openUserInConsole(item: UserTreeItem): Promise<void> {
 | 
			
		||||
    const url = getUserUrl(item.user.$id, clientConfig.endpoint, clientConfig.projectId);
 | 
			
		||||
 | 
			
		||||
    await commands.executeCommand("vscode.open", Uri.parse(url));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import { ext } from "../../extensionVariables";
 | 
			
		||||
 | 
			
		||||
export async function refreshUsersList() {
 | 
			
		||||
export async function refreshUsersList(): Promise<void> {
 | 
			
		||||
    ext.tree?.users?.refresh();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ import { UserPrefsTreeItem } from "../../tree/users/properties/UserPrefsTreeItem
 | 
			
		|||
import { UserTreeItem } from '../../tree/users/UserTreeItem';
 | 
			
		||||
import { openReadOnlyJson } from "../../ui/openReadonlyContent";
 | 
			
		||||
 | 
			
		||||
export async function viewUserPrefs(item: UserPrefsTreeItem | UserTreeItem) {
 | 
			
		||||
export async function viewUserPrefs(item: UserPrefsTreeItem | UserTreeItem):  Promise<void> {
 | 
			
		||||
    const userItem = item instanceof UserPrefsTreeItem ? item.parent : item;
 | 
			
		||||
    const prefs = userItem.user.prefs;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
import type { SDK } from './appwrite';
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
 | 
			
		||||
export const AppwriteSDK: SDK = require('node-appwrite') as SDK;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ import * as vscode from "vscode";
 | 
			
		|||
import { createAppwriteClient } from "./client";
 | 
			
		||||
import { registerCommands } from "./commands/registerCommands";
 | 
			
		||||
import { ext } from "./extensionVariables";
 | 
			
		||||
import { getActiveProjectConfiguration, getActiveProjectId, getDefaultProject } from "./settings";
 | 
			
		||||
import { getActiveProjectConfiguration } from "./settings";
 | 
			
		||||
import { DatabaseTreeItemProvider } from "./tree/database/DatabaseTreeItemProvider";
 | 
			
		||||
import { HealthTreeItemProvider } from "./tree/health/HealthTreeItemProvider";
 | 
			
		||||
import { ProjectsTreeItemProvider } from "./tree/projects/ProjectsTreeItemProvider";
 | 
			
		||||
| 
						 | 
				
			
			@ -39,5 +39,3 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
 | 
			
		|||
 | 
			
		||||
    registerCommands(context);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function deactivate() {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import { ExtensionContext, OutputChannel } from "vscode";
 | 
			
		||||
import { ExtensionContext } from "vscode";
 | 
			
		||||
import { DatabaseTreeItemProvider } from './tree/database/DatabaseTreeItemProvider';
 | 
			
		||||
import { HealthTreeItemProvider } from './tree/health/HealthTreeItemProvider';
 | 
			
		||||
import { ProjectsTreeItemProvider } from './tree/projects/ProjectsTreeItemProvider';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
 | 
			
		||||
import { TreeItem, TreeItemCollapsibleState } from "vscode";
 | 
			
		||||
import { AppwriteTreeItemBase } from "../ui/AppwriteTreeItemBase";
 | 
			
		||||
import { ChildTreeItem } from "./ChildTreeItem";
 | 
			
		||||
 | 
			
		||||
export class CollapsableTreeItem<Parent> extends AppwriteTreeItemBase<Parent> {
 | 
			
		||||
    constructor(parent: Parent, item: Partial<TreeItem> & { label: string }, private readonly children: TreeItem[], public readonly brand?: string) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
import * as vscode from "vscode";
 | 
			
		||||
import { client } from "../../client";
 | 
			
		||||
import AppwriteCall from "../../utils/AppwriteCall";
 | 
			
		||||
import { Collection, CollectionsList, DocumentsList } from "../../appwrite";
 | 
			
		||||
import { Collection, CollectionsList } from "../../appwrite";
 | 
			
		||||
import { CollectionTreeItem } from "./CollectionTreeItem";
 | 
			
		||||
import { AppwriteSDK } from "../../constants";
 | 
			
		||||
import { AppwriteTreeItemBase } from "../../ui/AppwriteTreeItemBase";
 | 
			
		||||
| 
						 | 
				
			
			@ -14,8 +14,6 @@ export class DatabaseTreeItemProvider implements vscode.TreeDataProvider<vscode.
 | 
			
		|||
 | 
			
		||||
    readonly onDidChangeTreeData: vscode.Event<vscode.TreeItem | undefined | void> = this._onDidChangeTreeData.event;
 | 
			
		||||
 | 
			
		||||
    constructor() {}
 | 
			
		||||
 | 
			
		||||
    refresh(): void {
 | 
			
		||||
        ext.outputChannel?.appendLine('refresh database');
 | 
			
		||||
        this._onDidChangeTreeData.fire();
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +37,7 @@ export class DatabaseTreeItemProvider implements vscode.TreeDataProvider<vscode.
 | 
			
		|||
            return parent.getChildren?.() ?? [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let databaseSdk = new AppwriteSDK.Database(client);
 | 
			
		||||
        const databaseSdk = new AppwriteSDK.Database(client);
 | 
			
		||||
 | 
			
		||||
        const collectionsList = await AppwriteCall<CollectionsList, CollectionsList>(databaseSdk.listCollections());
 | 
			
		||||
        if (collectionsList) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ import { ChildTreeItem } from '../ChildTreeItem';
 | 
			
		|||
import { DocumentsTreeItem } from './DocumentsTreeItem';
 | 
			
		||||
 | 
			
		||||
export class DocumentTreeItem extends ChildTreeItem<DocumentsTreeItem> {
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
			
		||||
    constructor(parent: DocumentsTreeItem, public readonly document: Record<string, any>) {
 | 
			
		||||
        super(parent, {
 | 
			
		||||
            label: document['$id'],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,13 +9,12 @@ import { CollectionTreeItem } from "./CollectionTreeItem";
 | 
			
		|||
import { DocumentTreeItem } from "./DocumentTreeItem";
 | 
			
		||||
 | 
			
		||||
export class DocumentsTreeItem extends AppwriteTreeItemBase<CollectionTreeItem> {
 | 
			
		||||
    window: any;
 | 
			
		||||
    constructor(parent: CollectionTreeItem) {
 | 
			
		||||
        super(parent, "Documents");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async getChildren(): Promise<TreeItem[]> {
 | 
			
		||||
        let databaseSdk = new AppwriteSDK.Database(client);
 | 
			
		||||
        const databaseSdk = new AppwriteSDK.Database(client);
 | 
			
		||||
        const documentList = await AppwriteCall<DocumentsList>(databaseSdk.listDocuments(this.parent.collection.$id));
 | 
			
		||||
        if (documentList === undefined) {
 | 
			
		||||
            return [];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
import { AppwriteTreeItemBase } from "../../../ui/AppwriteTreeItemBase";
 | 
			
		||||
import { ChildTreeItem } from "../../ChildTreeItem";
 | 
			
		||||
import { PermissionsTreeItem } from "./PermissionsTreeItem";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
import { TreeItem } from "vscode";
 | 
			
		||||
import { Rule } from "../../../appwrite";
 | 
			
		||||
import { ChildTreeItem } from "../../ChildTreeItem";
 | 
			
		||||
import { RulesTreeItem } from "./RulesTreeItem";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@ import * as vscode from "vscode";
 | 
			
		|||
import { MarkdownString } from 'vscode';
 | 
			
		||||
 | 
			
		||||
export class HealthTreeItem extends vscode.TreeItem {
 | 
			
		||||
    constructor(public readonly label: string, status: any, tooltip?: string | MarkdownString | undefined) {
 | 
			
		||||
    constructor(public readonly label: string, status: "check" | "error" | any, tooltip?: string | MarkdownString | undefined) {
 | 
			
		||||
        super(label);
 | 
			
		||||
        console.log(status);
 | 
			
		||||
        this.label = label;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,15 +3,12 @@ import { healthClient } from "../../client";
 | 
			
		|||
import { ext } from "../../extensionVariables";
 | 
			
		||||
import { HealthTreeItem } from "./HealthTreeItem";
 | 
			
		||||
import * as dayjs from "dayjs";
 | 
			
		||||
import * as relativeTime from "dayjs/plugin/relativeTime";
 | 
			
		||||
import * as localizedFormat from "dayjs/plugin/localizedFormat";
 | 
			
		||||
import { healthTooltips } from "../../appwrite/Health";
 | 
			
		||||
import { AppwriteHealth } from "../../appwrite";
 | 
			
		||||
// dayjs.extend(relativeTime);
 | 
			
		||||
dayjs.extend(localizedFormat);
 | 
			
		||||
 | 
			
		||||
type PartialRecord<K extends string | number | symbol, T> = { [P in K]?: T };
 | 
			
		||||
 | 
			
		||||
export class HealthTreeItemProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
 | 
			
		||||
    private _onDidChangeTreeData: vscode.EventEmitter<HealthTreeItem | undefined | void> = new vscode.EventEmitter<
 | 
			
		||||
        HealthTreeItem | undefined | void
 | 
			
		||||
| 
						 | 
				
			
			@ -21,8 +18,6 @@ export class HealthTreeItemProvider implements vscode.TreeDataProvider<vscode.Tr
 | 
			
		|||
 | 
			
		||||
    readonly onDidChangeTreeData: vscode.Event<HealthTreeItem | undefined | void> = this._onDidChangeTreeData.event;
 | 
			
		||||
 | 
			
		||||
    constructor() {}
 | 
			
		||||
 | 
			
		||||
    refresh(): void {
 | 
			
		||||
        this._onDidChangeTreeData.fire();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
import * as vscode from "vscode";
 | 
			
		||||
import { getActiveProjectId, getAppwriteProjects } from "../../settings";
 | 
			
		||||
import { refreshTree } from "../../utils/refreshTree";
 | 
			
		||||
import { ProjectTreeItem } from "./ProjectTreeItem";
 | 
			
		||||
 | 
			
		||||
export class ProjectsTreeItemProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +25,7 @@ export class ProjectsTreeItemProvider implements vscode.TreeDataProvider<vscode.
 | 
			
		|||
        return element;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async getChildren(element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
 | 
			
		||||
    async getChildren(_element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
 | 
			
		||||
        const configs = await getAppwriteProjects();
 | 
			
		||||
        if (configs === undefined || configs.length === 0) {
 | 
			
		||||
            return [];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,8 +9,6 @@ export class StorageTreeItemProvider implements vscode.TreeDataProvider<vscode.T
 | 
			
		|||
 | 
			
		||||
    readonly onDidChangeTreeData: vscode.Event<vscode.TreeItem | undefined | void> = this._onDidChangeTreeData.event;
 | 
			
		||||
 | 
			
		||||
    constructor() {}
 | 
			
		||||
 | 
			
		||||
    refresh(): void {
 | 
			
		||||
        this._onDidChangeTreeData.fire();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +17,7 @@ export class StorageTreeItemProvider implements vscode.TreeDataProvider<vscode.T
 | 
			
		|||
        return element;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async getChildren(element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
 | 
			
		||||
    async getChildren(_element?: vscode.TreeItem): Promise<vscode.TreeItem[]> {
 | 
			
		||||
        if (storageClient === undefined) {
 | 
			
		||||
            return [];
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@ import { ThemeIcon } from "vscode";
 | 
			
		|||
import { UserPrefsTreeItem } from "./properties/UserPrefsTreeItem";
 | 
			
		||||
import { ChildTreeItem } from "../ChildTreeItem";
 | 
			
		||||
import { UserTreeItem } from "./UserTreeItem";
 | 
			
		||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
 | 
			
		||||
const sdk = require("node-appwrite");
 | 
			
		||||
 | 
			
		||||
export class UserTreeItemProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +16,6 @@ export class UserTreeItemProvider implements vscode.TreeDataProvider<vscode.Tree
 | 
			
		|||
 | 
			
		||||
    readonly onDidChangeTreeData: vscode.Event<UserTreeItem | undefined | void> = this._onDidChangeTreeData.event;
 | 
			
		||||
 | 
			
		||||
    constructor() {}
 | 
			
		||||
 | 
			
		||||
    refresh(): void {
 | 
			
		||||
        this._onDidChangeTreeData.fire();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -63,10 +62,10 @@ export class UserTreeItemProvider implements vscode.TreeDataProvider<vscode.Tree
 | 
			
		|||
            return Promise.resolve(items);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let usersSdk = new sdk.Users(client);
 | 
			
		||||
        const usersSdk = new sdk.Users(client);
 | 
			
		||||
        const usersList = await AppwriteCall<UsersList, UsersList>(usersSdk.list());
 | 
			
		||||
        if (usersList) {
 | 
			
		||||
            const userTreeItems = usersList.users.map((user: any) => new UserTreeItem(user)) ?? [];
 | 
			
		||||
            const userTreeItems = usersList.users.map((user: User) => new UserTreeItem(user)) ?? [];
 | 
			
		||||
            const headerItem: vscode.TreeItem = {
 | 
			
		||||
                label: `Total users: ${usersList.sum}`,
 | 
			
		||||
            };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
import { OutputChannel, ViewColumn, window, workspace, WorkspaceConfiguration } from "vscode";
 | 
			
		||||
 | 
			
		||||
// tslint:disable-next-line: export-name
 | 
			
		||||
export function createAppwriteOutputChannel(name: string, extensionPrefix: string) {
 | 
			
		||||
export function createAppwriteOutputChannel(name: string, extensionPrefix: string): AppwriteOutputChannel {
 | 
			
		||||
    return new AppwriteOutputChannel(name, extensionPrefix);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -50,8 +50,8 @@ export class AppwriteOutputChannel {
 | 
			
		|||
 | 
			
		||||
    public show(preserveFocus?: boolean | undefined): void;
 | 
			
		||||
    public show(column?: ViewColumn | undefined, preserveFocus?: boolean | undefined): void;
 | 
			
		||||
    // tslint:disable-next-line: no-any
 | 
			
		||||
    public show(_column?: any, preserveFocus?: boolean | undefined): void {
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
 | 
			
		||||
    public show(_column?: unknown, preserveFocus?: boolean | undefined): void {
 | 
			
		||||
        this._outputChannel.show(preserveFocus);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
import { TreeDataProvider, TreeItem } from "vscode";
 | 
			
		||||
import { TreeItem } from "vscode";
 | 
			
		||||
 | 
			
		||||
export abstract class AppwriteTreeItemBase<Parent = void> extends TreeItem {
 | 
			
		||||
    constructor(public readonly parent: Parent, label: string) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ export abstract class BaseEditor<ContextT> implements vscode.Disposable {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private async updateEditor(data: string, textEditor?: vscode.TextEditor): Promise<void> {
 | 
			
		||||
        if (!!textEditor) {
 | 
			
		||||
        if (textEditor) {
 | 
			
		||||
            await BaseEditor.writeToEditor(textEditor, data);
 | 
			
		||||
            this.ignoreSave = true;
 | 
			
		||||
            try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
import { QuickPickItem, window } from "vscode";
 | 
			
		||||
import { AppwriteProjectConfiguration } from "../settings";
 | 
			
		||||
 | 
			
		||||
export type CreateRuleWizardContext = {
 | 
			
		||||
    label: string;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue