Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
|
8b286657b0 | ||
|
6a2fbb956b | ||
|
f9d42ad703 | ||
|
e76dbc9e89 | ||
|
883893aaab | ||
|
47c405a9f5 |
14 changed files with 122 additions and 5440 deletions
48
.github/ISSUE_TEMPLATE/bug.yaml
vendored
Normal file
48
.github/ISSUE_TEMPLATE/bug.yaml
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
name: Bug Report
|
||||
description: File a bug report
|
||||
title: "[Bug] "
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Reproduction steps
|
||||
description: "How do you trigger this bug? Please walk us through it step by step."
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
...
|
||||
render: bash
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: What version of VS Code are you using?
|
||||
options:
|
||||
- Stable (Default)
|
||||
- Insiders
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: os
|
||||
attributes:
|
||||
label: What operating system are you seeing the problem on?
|
||||
multiple: true
|
||||
options:
|
||||
- All
|
||||
- Windows
|
||||
- macOS
|
||||
- Linux
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant log output
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||
render: shell
|
|
@ -6,6 +6,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.1.3] - 2021-6-17
|
||||
## Added
|
||||
- New feature! JSON strings inside documents will now be automatically formatted as JSON when viewing documents. You can turn this feature off via the `appwrite.formatJsonStrings` setting.
|
||||
|
||||
## [0.1.2] - 2021-6-03
|
||||
## Added
|
||||
- Ability to set the `list`, `default` and `array` properties when creating a new collection. | [Issue #20](https://github.com/streamlux/vscode-appwrite/issues/20) | [PR #21](https://github.com/streamlux/vscode-appwrite/pull/21) | Thanks [@Maatteogekko](https://github.com/Maatteogekko)!
|
||||
|
|
5347
package-lock.json
generated
5347
package-lock.json
generated
File diff suppressed because it is too large
Load diff
41
package.json
41
package.json
|
@ -2,7 +2,7 @@
|
|||
"name": "vscode-appwrite",
|
||||
"displayName": "Appwrite",
|
||||
"description": "Manage your Appwrite resources right from VS Code!",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"engines": {
|
||||
"vscode": "^1.55.0"
|
||||
},
|
||||
|
@ -335,28 +335,10 @@
|
|||
"icon": "$(link-external)",
|
||||
"category": "Appwrite"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.openCollectionInBrowser",
|
||||
"title": "Open collection in browser",
|
||||
"icon": "$(link-external)",
|
||||
"category": "Appwrite"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.viewMore",
|
||||
"title": "View more",
|
||||
"category": "Appwrite"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.uploadFile",
|
||||
"title": "Upload file to storage",
|
||||
"icon": "$(cloud-upload)",
|
||||
"category": "Appwrite"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.downloadFile",
|
||||
"title": "Download file",
|
||||
"icon": "$(cloud-download)",
|
||||
"category": "Appwrite"
|
||||
}
|
||||
],
|
||||
"views": {
|
||||
|
@ -468,11 +450,6 @@
|
|||
"command": "vscode-appwrite.createFunction",
|
||||
"when": "view == Functions",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.uploadFile",
|
||||
"when": "view == Storage",
|
||||
"group": "navigation"
|
||||
}
|
||||
],
|
||||
"view/item/context": [
|
||||
|
@ -511,11 +488,6 @@
|
|||
"command": "vscode-appwrite.viewCollectionAsJson",
|
||||
"when": "viewItem == collection"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.openCollectionInBrowser",
|
||||
"when": "viewItem == collection",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.deleteCollection",
|
||||
"when": "viewItem == collection"
|
||||
|
@ -648,11 +620,6 @@
|
|||
"command": "vscode-appwrite.CreateTag",
|
||||
"when": "viewItem =~ /^tags$/",
|
||||
"group": "inline"
|
||||
},
|
||||
{
|
||||
"command": "vscode-appwrite.downloadFile",
|
||||
"when": "viewItem =~ /^file$/",
|
||||
"group": "inline"
|
||||
}
|
||||
],
|
||||
"explorer/context": [
|
||||
|
@ -759,6 +726,11 @@
|
|||
"type": "string",
|
||||
"default": "",
|
||||
"markdownDescription": "Project id of the active project, see [docs](https://github.com/streamlux/vscode-appwrite/) for more information."
|
||||
},
|
||||
"appwrite.formatJsonStrings": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"markdownDescription": "Format JSON strings when viewing documents"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -797,7 +769,6 @@
|
|||
"cron-validate": "^1.4.3",
|
||||
"cronstrue": "^1.113.0",
|
||||
"dayjs": "^1.10.4",
|
||||
"downloads-folder": "^3.0.1",
|
||||
"fs-extra": "^9.1.0",
|
||||
"node-appwrite": "^2.2.3",
|
||||
"tar": "^6.1.0"
|
||||
|
|
3
src/appwrite.d.ts
vendored
3
src/appwrite.d.ts
vendored
|
@ -362,9 +362,6 @@ export type StorageClient = {
|
|||
createFile: (file: any, read?: string[], write?: string[]) => Promise<any>;
|
||||
listFiles: () => Promise<any>;
|
||||
getFile: (fileId: string) => Promise<any>;
|
||||
getFileDownload: (fileId: string) => Promise<any>;
|
||||
getFileView: (fileId: string) => Promise<any>;
|
||||
deleteFile: (fileId: string) => Promise<any>;
|
||||
};
|
||||
|
||||
type Vars = Record<string, any>;
|
||||
|
|
|
@ -14,14 +14,6 @@ export class Storage {
|
|||
return await AppwriteCall(this.storage.listFiles());
|
||||
}
|
||||
|
||||
public async getFileDownload(fileId: string): Promise<any> {
|
||||
return await AppwriteCall(this.storage.getFileDownload(fileId));
|
||||
}
|
||||
|
||||
public async getFileView(fileId: string): Promise<any> {
|
||||
return await AppwriteCall(this.storage.getFileView(fileId));
|
||||
}
|
||||
|
||||
public async createFile(file: ReadStream): Promise<void> {
|
||||
return await AppwriteCall(this.storage.createFile(file));
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import { CollectionTreeItem } from '../../tree/database/CollectionTreeItem';
|
||||
import { openUrl } from '../../utils/openUrl';
|
||||
|
||||
export async function openCollectionInBrowser(treeItem: CollectionTreeItem): Promise<void> {
|
||||
openUrl(treeItem.getUrl());
|
||||
}
|
|
@ -1,8 +1,30 @@
|
|||
import { workspace } from "vscode";
|
||||
import { DocumentTreeItem } from "../../tree/database/DocumentTreeItem";
|
||||
import { openReadOnlyJson } from "../../ui/openReadonlyContent";
|
||||
|
||||
function parseJSONString(str: string): { valid: boolean; value: any } {
|
||||
try {
|
||||
return { value: JSON.parse(str), valid: true };
|
||||
} catch (e) {
|
||||
return { value: str, valid: false };
|
||||
}
|
||||
}
|
||||
|
||||
export async function viewDocumentAsJson(documentTreeItem: DocumentTreeItem): Promise<void> {
|
||||
const documentId = documentTreeItem.document["$id"];
|
||||
const document = documentTreeItem.document;
|
||||
const documentId = document["$id"];
|
||||
|
||||
const formatJsonStrings = workspace.getConfiguration("appwrite").get<Boolean>("formatJsonStrings");
|
||||
|
||||
if (formatJsonStrings) {
|
||||
Object.entries(document).forEach(([key, value]) => {
|
||||
if (typeof value === "string") {
|
||||
const result = parseJSONString(value);
|
||||
document[key] = result.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await openReadOnlyJson(
|
||||
{
|
||||
label: documentId,
|
||||
|
|
|
@ -8,9 +8,6 @@ import { selectWorkspaceFolder } from "../../utils/workspace";
|
|||
import { ProgressMessage } from "../../utils/types";
|
||||
import { Tag } from "../../appwrite";
|
||||
import { activateTag } from "./activateTag";
|
||||
import { sleep } from '../../utils/sleep';
|
||||
import { openFunctionTagsInBrowser } from './openFunctionTagsInBrowser';
|
||||
import { executeFunction } from './createExecution';
|
||||
|
||||
export async function createTag(item?: TagsTreeItem | Uri): Promise<void> {
|
||||
if (item instanceof Uri) {
|
||||
|
@ -139,8 +136,7 @@ async function createTagFromUri(functionId: string, command: string, uri: Uri, p
|
|||
return;
|
||||
}
|
||||
// somehow makes the upload work
|
||||
// await workspace.fs.readFile(Uri.file(tarFilePath));
|
||||
await sleep(1000);
|
||||
await workspace.fs.readFile(Uri.file(tarFilePath));
|
||||
progress.report({ message: "Uploading tag", increment: 60 });
|
||||
try {
|
||||
return await functionsClient.createTag(functionId, command, fs.createReadStream(tarFilePath));
|
||||
|
@ -159,17 +155,9 @@ async function tagNotification(tag: Tag): Promise<void> {
|
|||
);
|
||||
if (action === "Activate tag") {
|
||||
await activateTag(tag);
|
||||
const action = await window.showInformationMessage(
|
||||
`Successfully activated tag.`,
|
||||
"Execute function",
|
||||
);
|
||||
if (action === 'Execute function') {
|
||||
await executeFunction(tag.functionId);
|
||||
}
|
||||
}
|
||||
if (action === "View in console") {
|
||||
//
|
||||
await openFunctionTagsInBrowser(tag.functionId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,11 @@ import { ExecutionsTreeItem } from '../../tree/functions/executions/ExecutionsTr
|
|||
import { openUrl } from '../../utils/openUrl';
|
||||
import { getConsoleUrlFromEndpoint } from '../users/openUserInConsole';
|
||||
|
||||
export async function openFunctionTagsInBrowser(treeItem: ExecutionsTreeItem | string): Promise<void> {
|
||||
|
||||
const funcId = treeItem instanceof ExecutionsTreeItem ? treeItem.parent.func.$id : treeItem;
|
||||
|
||||
export async function openFunctionTagsInBrowser(treeItem: ExecutionsTreeItem): Promise<void> {
|
||||
const func = treeItem.parent.func;
|
||||
|
||||
const consoleUrl = getConsoleUrlFromEndpoint(clientConfig.endpoint);
|
||||
// https://console.streamlux.com/console/functions/function?id=60b1836a8e5d9&project=605ce39a30c01
|
||||
const url = `${consoleUrl}/functions/function?id=${funcId}&project=${clientConfig.projectId}`;
|
||||
const url = `${consoleUrl}/functions/function?id=${func.$id}&project=${clientConfig.projectId}`;
|
||||
openUrl(url);
|
||||
}
|
||||
|
|
|
@ -43,9 +43,6 @@ import { openFunctionSettingsInBrowser } from './functions/openFunctionSettingsI
|
|||
import { openFunctionTagsInBrowser } from './functions/openFunctionTagsInBrowser';
|
||||
|
||||
import { viewMore } from './common/viewMore';
|
||||
import { openCollectionInBrowser } from './database/openCollectionInBrowser';
|
||||
import { uploadFile } from './storage/uploadFile';
|
||||
import { downloadFile } from './storage/downloadFile';
|
||||
|
||||
class CommandRegistrar {
|
||||
constructor(private readonly context: ExtensionContext) {}
|
||||
|
@ -109,7 +106,6 @@ export function registerCommands(context: ExtensionContext): void {
|
|||
registerCommand("createPermission", createPermission, "database");
|
||||
registerCommand("deletePermission", deletePermission, "database");
|
||||
registerCommand("editPermission", editPermission, "database");
|
||||
registerCommand("openCollectionInBrowser", openCollectionInBrowser);
|
||||
|
||||
/** Health **/
|
||||
registerCommand("refreshHealth", undefined, "health");
|
||||
|
@ -117,9 +113,6 @@ export function registerCommands(context: ExtensionContext): void {
|
|||
|
||||
/** Storage **/
|
||||
registerCommand("refreshStorage", undefined, "storage");
|
||||
registerCommand("uploadFile", uploadFile, "storage");
|
||||
registerCommand("downloadFile", downloadFile);
|
||||
|
||||
registerCommand("openStorageDocumentation", () => openDocumentation("storage"));
|
||||
|
||||
/** Projects **/
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
import { ProgressLocation, Uri, window, workspace } from "vscode";
|
||||
import { storageClient } from "../../client";
|
||||
import * as fs from "fs";
|
||||
import { FileTreeItem } from "../../tree/storage/FileTreeItem";
|
||||
import downloadsFolder = require("downloads-folder");
|
||||
import { File } from "../../appwrite";
|
||||
import { ProgressMessage } from "../../utils/types";
|
||||
import { CancellationToken } from "vscode";
|
||||
|
||||
export async function downloadFile(item: FileTreeItem | File): Promise<void> {
|
||||
const file = item instanceof FileTreeItem ? item.file : item;
|
||||
|
||||
const data = await window.withProgress(
|
||||
{ location: ProgressLocation.Notification, title: `Downloading ${file.name}`, cancellable: false },
|
||||
async (progress: ProgressMessage, _token: CancellationToken): Promise<Buffer> => {
|
||||
const data = await storageClient?.getFileDownload(file.$id);
|
||||
progress.report({ message: "Download finished" });
|
||||
return data;
|
||||
}
|
||||
);
|
||||
|
||||
const defaultUriBase = workspace.workspaceFolders?.[0].uri ?? Uri.parse(downloadsFolder());
|
||||
const defaultUri = Uri.joinPath(defaultUriBase, file.name);
|
||||
|
||||
const destination = await window.showSaveDialog({ saveLabel: "Save", title: file.name, defaultUri });
|
||||
if (data && destination) {
|
||||
await fs.promises.writeFile(destination.fsPath, data);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
import { window } from "vscode";
|
||||
import { storageClient } from "../../client";
|
||||
import * as fs from "fs";
|
||||
|
||||
export async function uploadFile(): Promise<void> {
|
||||
try {
|
||||
const file = await window.showOpenDialog({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false });
|
||||
if (file) {
|
||||
await storageClient?.createFile(fs.createReadStream(file[0].fsPath));
|
||||
}
|
||||
} catch (e) {
|
||||
window.showErrorMessage("Failed to upload file.");
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { Collection } from "../../appwrite";
|
||||
import { clientConfig, databaseClient } from "../../client";
|
||||
import { getConsoleUrlFromEndpoint } from '../../commands/users/openUserInConsole';
|
||||
import { databaseClient } from "../../client";
|
||||
import { AppwriteTreeItemBase } from "../../ui/AppwriteTreeItemBase";
|
||||
import { DatabaseTreeItemProvider } from "./DatabaseTreeItemProvider";
|
||||
import { DocumentsTreeItem } from "./DocumentsTreeItem";
|
||||
|
@ -13,12 +12,6 @@ export class CollectionTreeItem extends AppwriteTreeItemBase {
|
|||
super(undefined, collection.name);
|
||||
}
|
||||
|
||||
// https://console.streamlux.com/console/database/collection?id=607cb2d6a21a8&project=605ce39a30c01
|
||||
public getUrl(): string {
|
||||
const consoleUrl = getConsoleUrlFromEndpoint(clientConfig.endpoint);
|
||||
return `${consoleUrl}/database/collection?id=${this.collection.$id}&project=${clientConfig.projectId}`;
|
||||
}
|
||||
|
||||
public async getChildren(): Promise<TreeItem[]> {
|
||||
return [new RulesTreeItem(this), new PermissionsTreeItem(this), new DocumentsTreeItem(this)];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue