Add function entrypoint

This commit is contained in:
Matej Bačo
2023-03-16 11:06:22 +01:00
parent 3f08894914
commit a1184fc2bb
7 changed files with 79 additions and 16 deletions
+7 -7
View File
@@ -9,7 +9,7 @@
"version": "0.0.1",
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.10",
"@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.12",
"@aw-labs/icons": "0.0.0-77",
"@aw-labs/ui": "0.0.0-77",
"@popperjs/core": "^2.11.6",
@@ -146,9 +146,9 @@
},
"node_modules/@aw-labs/appwrite-console": {
"name": "matej-appwrite-console",
"version": "7.1.10",
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.10.tgz",
"integrity": "sha512-GlNTTkJ5iHpUYgyJ3rexeGmCdD2WQ0zwSw6yFA2lf4aLVh+VuZQdoEEmW0K1dpTnBtg8EGkqhMCIIZTRV4mgcw==",
"version": "7.1.12",
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.12.tgz",
"integrity": "sha512-5vHZZKR/d6cf1xlia38fKubZkUBnio6KuTgFUKRpoh0NzdNNMeavKD1KsWC1mH/hpKnhzVks+h2Y5zZq2ShD8g==",
"dependencies": {
"cross-fetch": "3.1.5",
"isomorphic-form-data": "2.0.0"
@@ -7741,9 +7741,9 @@
"integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g=="
},
"@aw-labs/appwrite-console": {
"version": "npm:matej-appwrite-console@7.1.10",
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.10.tgz",
"integrity": "sha512-GlNTTkJ5iHpUYgyJ3rexeGmCdD2WQ0zwSw6yFA2lf4aLVh+VuZQdoEEmW0K1dpTnBtg8EGkqhMCIIZTRV4mgcw==",
"version": "npm:matej-appwrite-console@7.1.12",
"resolved": "https://registry.npmjs.org/matej-appwrite-console/-/matej-appwrite-console-7.1.12.tgz",
"integrity": "sha512-5vHZZKR/d6cf1xlia38fKubZkUBnio6KuTgFUKRpoh0NzdNNMeavKD1KsWC1mH/hpKnhzVks+h2Y5zZq2ShD8g==",
"requires": {
"cross-fetch": "3.1.5",
"isomorphic-form-data": "2.0.0"
+1 -1
View File
@@ -21,7 +21,7 @@
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"analytics": "^0.8.1",
"@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.10",
"@aw-labs/appwrite-console": "npm:matej-appwrite-console@7.1.12",
"@aw-labs/icons": "0.0.0-77",
"@aw-labs/ui": "0.0.0-77",
"@popperjs/core": "^2.11.6",
+1 -1
View File
@@ -2,10 +2,10 @@
import { Pill } from '$lib/elements';
import Prism from 'prismjs';
import 'prismjs/components/prism-ruby';
import 'prismjs/components/prism-php';
import 'prismjs/components/prism-dart';
import 'prismjs/components/prism-kotlin';
import 'prismjs/components/prism-python';
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-json';
import 'prismjs/components/prism-bash';
import 'prismjs/components/prism-yaml';
@@ -51,6 +51,7 @@
Swift
</Tab>
</Tabs>
<p>Code snippet showing how to read environment variables in Appwrite Functions.</p>
{#if language === Language.NodeJs}
@@ -230,6 +230,7 @@
on:click={() => {
snippetKey = variable.key;
showSnippet = true;
showVariablesDropdown[i] = false;
}}>
Code snippets
</DropListItem>
@@ -173,7 +173,7 @@
placeholder={`main.${lang}`}
id="entrypoint"
bind:value={entrypoint}
required />
required={false} />
<InputFile label="Gzipped code (tar.gz)" allowedFileExtensions={['gz']} bind:files />
<InputChoice label="Activate Deployment after build" id="activate" bind:value={active}>
This deployment will be activated after the build is completed.</InputChoice>
@@ -35,6 +35,7 @@
let permissions: string[] = [];
let arePermsDisabled = true;
let logging: boolean = null;
let entrypoint: string = null;
const eventSet: Writable<Set<string>> = writable(new Set());
let showEvents = false;
@@ -46,6 +47,7 @@
functionSchedule ??= $func.schedule;
permissions = $func.execute;
logging = $func.logging;
entrypoint ??= $func.entrypoint;
$eventSet = new Set($func.events);
});
@@ -59,7 +61,8 @@
$func.schedule,
$func.timeout,
$func.enabled,
$func.logging
$func.logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
addNotification({
@@ -85,7 +88,8 @@
$func.schedule,
$func.timeout,
$func.enabled,
logging
logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
addNotification({
@@ -111,7 +115,8 @@
$func.schedule,
$func.timeout,
$func.enabled,
$func.logging
$func.logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
addNotification({
@@ -137,7 +142,8 @@
$func.schedule,
$func.timeout,
$func.enabled,
$func.logging
$func.logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
addNotification({
@@ -163,7 +169,8 @@
functionSchedule,
$func.timeout,
$func.enabled,
$func.logging
$func.logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
@@ -190,7 +197,8 @@
$func.schedule,
timeout,
$func.enabled,
$func.logging
$func.logging,
$func.entrypoint
);
invalidate(Dependencies.FUNCTION);
@@ -207,6 +215,34 @@
}
}
async function updateDeploymentSettings() {
try {
await sdkForProject.functions.update(
functionId,
$func.name,
$func.execute,
$func.events,
$func.schedule,
$func.timeout,
$func.enabled,
$func.logging,
entrypoint
);
invalidate(Dependencies.FUNCTION);
addNotification({
type: 'success',
message: 'Deployment settings has been updated'
});
trackEvent('submit_function_update_deployment_settings');
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
function handleEvent(event: CustomEvent) {
eventSet.set($eventSet.add(event.detail));
}
@@ -290,6 +326,31 @@
</CardGrid>
</Form>
<Form on:submit={updateDeploymentSettings}>
<CardGrid>
<Heading tag="h6" size="7">Update Deployment Settings</Heading>
<p>
These settings are used default values when creating a deployment. They can be
ovewritten when creating deployment.
</p>
<svelte:fragment slot="aside">
<ul>
<InputText
id="entrypoint"
label="Entrypoint"
placeholder="main.js"
autocomplete={false}
bind:value={entrypoint} />
</ul>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button
disabled={entrypoint === $func.entrypoint}
on:click={updateDeploymentSettings}>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
<Form on:submit={updateLogging}>
<CardGrid>
<Heading tag="h6" size="7">Update Logging</Heading>