diff --git a/src/lib/stores/marketplace.ts b/src/lib/stores/marketplace.ts
index 8853016a8..655bab32c 100644
--- a/src/lib/stores/marketplace.ts
+++ b/src/lib/stores/marketplace.ts
@@ -631,14 +631,14 @@ export const marketplace = [
}
];
-type Runtime = {
+export type Runtime = {
name: string;
commands: string;
entrypoint: string;
providerRootDirectory: string;
};
-type Variable = {
+export type Variable = {
name: string;
description: string;
value?: string;
diff --git a/src/lib/wizards/functions/components/appwriteVariable.svelte b/src/lib/wizards/functions/components/appwriteVariable.svelte
new file mode 100644
index 000000000..0458450f7
--- /dev/null
+++ b/src/lib/wizards/functions/components/appwriteVariable.svelte
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+ This API key will allow you to interact with the Appwrite server APIs. Learn more.
+
+
+
+ The APPWRITE_API_KEY will be automatically generated for
+ your project and applied to this function once it's created.
+
+
+
diff --git a/src/lib/wizards/functions/createTemplate.svelte b/src/lib/wizards/functions/createTemplate.svelte
index b22637ef0..5ca177875 100644
--- a/src/lib/wizards/functions/createTemplate.svelte
+++ b/src/lib/wizards/functions/createTemplate.svelte
@@ -22,14 +22,16 @@
const runtimeDetail = $template.runtimes.find(
(r) => r.name === $templateConfig.runtime
);
-
- const key = await sdk.forConsole.projects.createKey(
- $page.params.project,
- 'Generated for Template',
- scopes.map((scope) => scope.scope)
- );
- $templateConfig.variables['APPWRITE_API_KEY'] = key.secret;
-
+ if ($templateConfig.appwriteApiKey) {
+ $templateConfig.variables['APPWRITE_API_KEY'] = $templateConfig.appwriteApiKey;
+ } else if ($templateConfig?.generateKey) {
+ const key = await sdk.forConsole.projects.createKey(
+ $page.params.project,
+ 'Generated for Template',
+ scopes.map((scope) => scope.scope)
+ );
+ $templateConfig.variables['APPWRITE_API_KEY'] = key.secret;
+ }
const response = await sdk.forProject.functions.create(
$templateConfig.$id || ID.unique(),
$templateConfig.name,
diff --git a/src/lib/wizards/functions/steps/templateVariables.svelte b/src/lib/wizards/functions/steps/templateVariables.svelte
index 945b53955..d845fcdf5 100644
--- a/src/lib/wizards/functions/steps/templateVariables.svelte
+++ b/src/lib/wizards/functions/steps/templateVariables.svelte
@@ -2,8 +2,9 @@
import InputText from '$lib/elements/forms/inputText.svelte';
import { WizardStep } from '$lib/layout';
import { template, templateConfig } from '../store';
- import { FormList, Helper, InputChoice } from '$lib/elements/forms';
+ import { FormList, Helper } from '$lib/elements/forms';
import { Card, Collapsible, CollapsibleItem } from '$lib/components';
+ import AppwriteVariable from '../components/appwriteVariable.svelte';
async function beforeSubmit() {
for (const variable of $template.variables) {
@@ -17,13 +18,8 @@
}
}
- $: appwriteVariable = $template.variables.find((v) => v.name === 'APPWRITE_API_KEY');
- $: requiredVariables = $template?.variables?.filter(
- (v) => v.required && v.name !== 'APPWRITE_API_KEY'
- );
- $: optionalVariables = $template?.variables?.filter(
- (v) => !v.required && v.name !== 'APPWRITE_API_KEY'
- );
+ $: requiredVariables = $template?.variables?.filter((v) => v.required);
+ $: optionalVariables = $template?.variables?.filter((v) => !v.required);
@@ -43,58 +39,32 @@
{#each requiredVariables as variable}
-
-
+ {#if variable.name === 'APPWRITE_API_KEY'}
+
+ {:else}
+
+
-
- {@html variable.description}
-
-
+
+ {@html variable.description}
+
+
+ {/if}
{/each}
{/if}
- {#if appwriteVariable}
-
-
-
-
-
- This API key will allow you to interact with the Appwrite server APIs. Learn more.
-
-
-
- The APPWRITE_API_KEY will be automatically generated
- for your project and applied to this function once it's created.
-
-
-
- {/if}
{#if optionalVariables?.length}
-
+
Optional variables
{optionalVariables.length}
@@ -102,19 +72,23 @@
{#each optionalVariables as variable}
-
-
+ {#if variable.name === 'APPWRITE_API_KEY'}
+
+ {:else}
+
+
-
- {@html variable.description}
-
-
+
+ {@html variable.description}
+
+
+ {/if}
{/each}
diff --git a/src/lib/wizards/functions/store.ts b/src/lib/wizards/functions/store.ts
index e1bd417ae..878fbdcc5 100644
--- a/src/lib/wizards/functions/store.ts
+++ b/src/lib/wizards/functions/store.ts
@@ -14,6 +14,7 @@ export const templateConfig = writable<{
repositoryPrivate: boolean;
repositoryId: string;
appwriteApiKey?: string;
+ generateKey?: boolean;
}>();
export const repository = writable();
export const installation = writable();