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