Skip to content

Commit 6cbf153

Browse files
Feature: functions (#15)
* Basic functions create tag and create execution feature * Detailed function support, create tag still broken * create tag and pick folder * edit changelog and bump extension version * fix linting
1 parent b4e5fdc commit 6cbf153

52 files changed

Lines changed: 1722 additions & 4573 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## [Unreleased]
88

9+
## [0.1.0] - 2021-5-29
10+
11+
## Functions!
12+
### Added
13+
- Ability to create and delete Appwrite functions
14+
- Edit function settings
15+
- View, and delete tags (creating tags is broken currently)
16+
- Create and view function executions
17+
- View execution output and errors
18+
919
## [0.0.9] - 2021-5-21
1020
- Remove temporary fix for Appwrite https://github.com/appwrite/appwrite/issues/1171. Upstream issue was resolved.
1121

package-lock.json

Lines changed: 159 additions & 4557 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 193 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-appwrite",
33
"displayName": "Appwrite",
44
"description": "Manage your Appwrite resources right from VS Code!",
5-
"version": "0.0.9",
5+
"version": "0.1.0",
66
"engines": {
77
"vscode": "^1.55.0"
88
},
@@ -30,7 +30,9 @@
3030
"onView:Users",
3131
"onView:Database",
3232
"onView:Health",
33-
"onCommand:vscode-appwrite.AddProject"
33+
"onView:Functions",
34+
"onCommand:vscode-appwrite.AddProject",
35+
"onCommand:vscode-appwrite.CreateTag"
3436
],
3537
"main": "./dist/extension.js",
3638
"contributes": {
@@ -184,10 +186,99 @@
184186
"title": "Refresh projects",
185187
"icon": "$(refresh)"
186188
},
189+
{
190+
"command": "vscode-appwrite.refreshFunctions",
191+
"title": "Refresh functions",
192+
"icon": "$(refresh)"
193+
},
187194
{
188195
"command": "vscode-appwrite.removeProject",
189196
"title": "Remove project",
190197
"icon": "$(trash)"
198+
},
199+
{
200+
"command": "vscode-appwrite.CreateTag",
201+
"title": "Create function tag",
202+
"icon": "$(cloud-upload)"
203+
},
204+
{
205+
"command": "vscode-appwrite.deleteTag",
206+
"title": "Delete tag",
207+
"icon": "$(trash)"
208+
},
209+
{
210+
"command": "vscode-appwrite.CreateExecution",
211+
"title": "Execute"
212+
},
213+
{
214+
"command": "vscode-appwrite.activateTag",
215+
"title": "Activate"
216+
},
217+
{
218+
"command": "vscode-appwrite.editValue",
219+
"title": "Edit",
220+
"icon": "$(edit)"
221+
},
222+
{
223+
"command": "vscode-appwrite.deleteFunction",
224+
"title": "Delete",
225+
"icon": "$(trash)"
226+
},
227+
{
228+
"command": "vscode-appwrite.openFunctionsDocumentation",
229+
"title": "Open functions documentation",
230+
"icon": "$(book)"
231+
},
232+
{
233+
"command": "vscode-appwrite.createFunction",
234+
"title": "Create function",
235+
"icon": "$(add)"
236+
},
237+
{
238+
"command": "vscode-appwrite.createFunctionVar",
239+
"title": "Create variable",
240+
"icon": "$(add)"
241+
},
242+
{
243+
"command": "vscode-appwrite.deleteFunctionVar",
244+
"title": "Delete variable",
245+
"icon": "$(trash)"
246+
},
247+
{
248+
"command": "vscode-appwrite.viewExecutionOutput",
249+
"title": "View execution stdout",
250+
"enablement": "viewItem =~ /^((execution|execution_outputOnly))$/"
251+
},
252+
{
253+
"command": "vscode-appwrite.viewExecutionErrors",
254+
"title": "View execution stderr",
255+
"enablement": "viewItem =~ /^((execution|execution_errorOnly))$/"
256+
},
257+
{
258+
"command": "vscode-appwrite.copyExecutionOutput",
259+
"title": "Copy execution stdout",
260+
"enablement": "viewItem =~ /^((execution|execution_outputOnly))$/"
261+
},
262+
{
263+
"command": "vscode-appwrite.copyExecutionErrors",
264+
"title": "Copy execution stderr",
265+
"enablement": "viewItem =~ /^((execution|execution_errorOnly))$/"
266+
},
267+
{
268+
"command": "vscode-appwrite.openExecutionsInBrowser",
269+
"title": "View executions in browser",
270+
"enablement": "viewItem =~ /^(executions)$/",
271+
"icon": "$(link-external)"
272+
},
273+
{
274+
"command": "vscode-appwrite.openFunctionTagsInBrowser",
275+
"title": "Open function tags in browser",
276+
"icon": "$(link-external)"
277+
},
278+
{
279+
"command": "vscode-appwrite.openFunctionSettingsInBrowser",
280+
"title": "Open function settings in browser",
281+
"icon": "$(link-external)"
191282
}
192283
],
193284
"views": {
@@ -211,6 +302,10 @@
211302
{
212303
"id": "Projects",
213304
"name": "Projects"
305+
},
306+
{
307+
"id": "Functions",
308+
"name": "Functions (Preview)"
214309
}
215310
]
216311
},
@@ -276,14 +371,24 @@
276371
"when": "view == Storage",
277372
"group": "navigation"
278373
},
374+
{
375+
"command": "vscode-appwrite.openFunctionsDocumentation",
376+
"when": "view == Functions",
377+
"group": "navigation"
378+
},
279379
{
280380
"command": "vscode-appwrite.refreshProjects",
281381
"when": "view == Projects",
282382
"group": "navigation"
283383
},
284384
{
285-
"command": "vscode-appwrite.addProject",
286-
"when": "view == Projects",
385+
"command": "vscode-appwrite.refreshFunctions",
386+
"when": "view == Functions",
387+
"group": "navigation"
388+
},
389+
{
390+
"command": "vscode-appwrite.createFunction",
391+
"when": "view == Functions",
287392
"group": "navigation"
288393
}
289394
],
@@ -383,6 +488,85 @@
383488
{
384489
"command": "vscode-appwrite.removeProject",
385490
"when": "viewItem =~ /(appwriteProject)/"
491+
},
492+
{
493+
"command": "vscode-appwrite.CreateExecution",
494+
"when": "viewItem =~ /^(function)$/",
495+
"group": "inline"
496+
},
497+
{
498+
"command": "vscode-appwrite.activateTag",
499+
"when": "viewItem =~ /^(tag)$/",
500+
"group": "inline"
501+
},
502+
{
503+
"command": "vscode-appwrite.editValue",
504+
"when": "viewItem =~ /^(editable)/",
505+
"group": "inline"
506+
},
507+
{
508+
"command": "vscode-appwrite.deleteFunction",
509+
"when": "viewItem =~ /^(function)$/"
510+
},
511+
{
512+
"command": "vscode-appwrite.deleteFunctionVar",
513+
"when": "viewItem =~ /(var)$/"
514+
},
515+
{
516+
"command": "vscode-appwrite.createFunctionVar",
517+
"when": "viewItem =~ /^(vars)$/",
518+
"group": "inline"
519+
},
520+
{
521+
"command": "vscode-appwrite.deleteTag",
522+
"when": "viewItem =~ /^(tag)$/"
523+
},
524+
{
525+
"command": "vscode-appwrite.viewExecutionErrors",
526+
"when": "viewItem =~ /^execution[^s]*$/",
527+
"group": "view@1"
528+
},
529+
{
530+
"command": "vscode-appwrite.viewExecutionOutput",
531+
"when": "viewItem =~ /^execution[^s]*$/",
532+
"group": "view@1"
533+
},
534+
{
535+
"command": "vscode-appwrite.copyExecutionErrors",
536+
"when": "viewItem =~ /^execution[^s]*$/",
537+
"group": "copy@2"
538+
},
539+
{
540+
"command": "vscode-appwrite.copyExecutionOutput",
541+
"when": "viewItem =~ /^execution[^s]*$/",
542+
"group": "copy@2"
543+
},
544+
{
545+
"command": "vscode-appwrite.openExecutionsInBrowser",
546+
"when": "viewItem =~ /^executions$/",
547+
"group": "inline"
548+
},
549+
{
550+
"command": "vscode-appwrite.openFunctionTagsInBrowser",
551+
"when": "viewItem =~ /^tags$/",
552+
"group": "inline"
553+
},
554+
{
555+
"command": "vscode-appwrite.openFunctionSettingsInBrowser",
556+
"when": "viewItem =~ /^functionSettings$/",
557+
"group": "inline"
558+
},
559+
{
560+
"command": "vscode-appwrite.CreateTag",
561+
"when": "viewItem =~ /^tags$/",
562+
"group": "inline"
563+
}
564+
],
565+
"explorer/context": [
566+
{
567+
"command": "vscode-appwrite.CreateTag",
568+
"when": "explorerResourceIsFolder == true",
569+
"group": "appwrite@1"
386570
}
387571
],
388572
"commandPalette": [
@@ -499,6 +683,7 @@
499683
"@types/glob": "^7.1.3",
500684
"@types/mocha": "^8.0.4",
501685
"@types/node": "^12.11.7",
686+
"@types/tar": "^4.0.4",
502687
"@types/vscode": "^1.55.0",
503688
"@typescript-eslint/eslint-plugin": "^4.14.1",
504689
"@typescript-eslint/parser": "^4.14.1",
@@ -513,8 +698,11 @@
513698
"webpack-cli": "^4.4.0"
514699
},
515700
"dependencies": {
701+
"cron-validate": "^1.4.3",
702+
"cronstrue": "^1.113.0",
516703
"dayjs": "^1.10.4",
517704
"fs-extra": "^9.1.0",
518-
"node-appwrite": "^2.2.1"
705+
"node-appwrite": "^2.2.3",
706+
"tar": "^6.1.0"
519707
}
520708
}

src/appwrite.d.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { ReadStream } from 'fs';
2+
import { Stream } from 'node:stream';
3+
14
export type Token = {
25
/**
36
* Token ID.
@@ -287,7 +290,7 @@ export type Rule = {
287290
list: string[];
288291
};
289292

290-
interface Permissions {
293+
export type Permissions = {
291294
read: string[];
292295
write: string[];
293296
}
@@ -356,16 +359,96 @@ export type AppwriteHealth = {
356359
};
357360

358361
export type StorageClient = {
359-
createFile: (file: any, read: string[], write: string[]) => Promise<any>;
362+
createFile: (file: any, read?: string[], write?: string[]) => Promise<any>;
360363
listFiles: () => Promise<any>;
361364
getFile: (fileId: string) => Promise<any>;
362365
};
363366

367+
type Vars = Record<string, any>;
368+
369+
export type Function = {
370+
'$id': string;
371+
'$permissions': Permissions;
372+
name: string;
373+
dateCreated: number;
374+
dateUpdated: number;
375+
status: string;
376+
env: string;
377+
tag: string;
378+
vars: Vars;
379+
events: string[];
380+
schedule: string;
381+
scheduleNext: number;
382+
schedulePrevious: number;
383+
timeout: number;
384+
}
385+
386+
export type FunctionsList = {
387+
sum: number;
388+
functions: Function[];
389+
}
390+
391+
export type Tag = {
392+
'$id': string;
393+
functionId: string;
394+
dateCreated: number;
395+
command: string;
396+
size: string;
397+
};
398+
399+
export type TagList = {
400+
sum: number;
401+
tags: Tag[];
402+
}
403+
404+
export type ExecutionStatus = "waiting" | "processing" | "completed" | "failed";
405+
406+
export type Execution = {
407+
'$id': string;
408+
functionId: string;
409+
dateCreated: number;
410+
trigger: string;
411+
status: ExecutionStatus;
412+
exitCode: number;
413+
stdout: string;
414+
stderr: string;
415+
time: number;
416+
};
417+
418+
export type ExecutionList = {
419+
sum: number;
420+
executions: Execution[];
421+
};
422+
423+
export type Search = {
424+
search?: string;
425+
limit?: number;
426+
offset?: number;
427+
orderType?: 'ASC' | 'DESC';
428+
};
429+
430+
export type FunctionsClient = {
431+
create: (name: string, execute: string[], env: string, vars?: Vars, events?: string[], schedule?: string, timeout?: number) => Promise<any>;
432+
list: (search?: string, offset?: number, limit?: number, orderType?: 'ASC' | 'DESC') => Promise<any>;
433+
get: (functionId: string) => Promise<any>;
434+
update: (functionId: string, name: string, execute: string[], vars?: Vars, events?: string[], schedule?: string, timeout?: number) => Promise<any>;
435+
updateTag: (functionId: string, tagId: string) => Promise<any>;
436+
delete: (functionId: string) => Promise<any>;
437+
createTag: (id: string, command: string, code: ReadStream) => Promise<any>;
438+
listTags: (id: string, search?: string, limit?: number, offset?: number, orderType?: 'ASC' | 'DESC') => Promise<any>;
439+
getTag: (functionId: string, tagId: string) => Promise<any>;
440+
deleteTag: (functionId: string, tagId: string) => Promise<any>;
441+
createExecution: (functionId: string, data?: string) => Promise<any>;
442+
listExecutions: (functionId: string, search?: string, limit?: number, offset?: number, orderType?: 'ASC' | 'DESC') => Promise<any>;
443+
getExecution: (functionId: string, executionId: string) => Promise<any>;
444+
}
445+
364446
export type SDK = {
365447
Client: new () => Client;
366448

367449
Users: new (client: Client) => UsersClient;
368450
Health: new (client: Client) => HealthClient;
369451
Database: new (client: Client) => DatabaseClient;
370452
Storage: new (client: Client) => StorageClient;
453+
Functions: new (client: Client) => FunctionsClient;
371454
};

0 commit comments

Comments
 (0)