Merge branch 'feat-g4' of github.com:appwrite/console into feat-g4

This commit is contained in:
Torsten Dittmann committed 2023-08-17 13:14:40 +02:00
commit 300fc15a5e
15 files changed
+161 -202

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
"@analytics/google-tag-manager": "^0.5.3",
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.125",
"@appwrite.io/pink": "0.0.7-next.1",
"@appwrite.io/pink-icons": "0.0.7-next.1",
"@appwrite.io/pink-icons": "^0.0.7-next.1",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
+2 -2
View File
@@ -19,10 +19,10 @@
},
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@analytics/google-tag-manager": "^0.5.3",
"@appwrite.io/console": "npm:matej-appwrite-console@7.1.125",
"@appwrite.io/pink": "0.0.7-next.1",
"@appwrite.io/pink-icons": "0.0.7-next.1",
"@analytics/google-tag-manager": "^0.5.3",
"@appwrite.io/pink-icons": "^0.0.7-next.1",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
+7 -17
View File
@@ -26,21 +26,18 @@
}
beforeNavigate((n) => {
if ($log.show) {
if (n.type === 'popstate') {
n.cancel();
}
$log.show = false;
if (!$log.show) return;
if (n.type === 'popstate') {
n.cancel();
}
$log.show = false;
});
$: execution = $log.data;
$: func = $log.func;
$: if (execution) {
if (execution.errors) {
selectedResponse = 'errors';
}
$: if (execution?.errors) {
selectedResponse = 'errors';
}
</script>
@@ -84,20 +81,13 @@
{calculateTime(execution.duration)}
</time>
</li>
<!-- <li class="text">
<b>Cold-start duration:</b>
<time> ?? </time>
</li> -->
<li class="text">
<b>Created at:</b>
<time>
{toLocaleDateTime(execution.$createdAt)}
</time>
</li>
<!-- <li class="text">
<b>Host:</b>
<span> ??</span>
</li> -->
</ul>
<div class="status u-margin-inline-start-auto">
<Status status={execution.status}>{execution.status}</Status>
+6 -7
View File
@@ -30,13 +30,12 @@
* Cancel navigation when wizard is open and triggered by popstate
*/
beforeNavigate((n) => {
if ($wizard.show || $wizard.cover) {
if (n.type === 'popstate') {
n.cancel();
}
if (n.type !== 'leave') {
wizard.hide();
}
if (!$wizard.show || !$wizard.cover) return;
if (n.type === 'popstate') {
n.cancel();
}
if (n.type !== 'leave') {
wizard.hide();
}
});
</script>
+46 -45
View File
@@ -2,8 +2,9 @@ export const marketplace = [
{
icon: 'icon-lightning-bolt',
id: 'starter',
name: 'Starter',
tagline: 'A simple function. Create something awesome! 🚀',
name: 'Starter function',
tagline:
'A simple function to get started. Edit this function to explore endless possibilities with Appwrite Functions. 🚀',
permissions: ['any'],
events: [],
cron: '',
@@ -49,7 +50,7 @@ export const marketplace = [
variables: [
{
name: 'APPWRITE_API_KEY',
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: false
@@ -60,7 +61,7 @@ export const marketplace = [
icon: 'icon-open-ai',
id: 'prompt-chatgpt',
name: 'Prompt ChatGPT',
tagline: 'Ask question, and let OpenAI GPT-3.5-turbo answer.',
tagline: 'Ask questions and let OpenAI GPT-3.5-turbo answer.',
permissions: ['any'],
events: [],
cron: '',
@@ -82,14 +83,14 @@ export const marketplace = [
variables: [
{
name: 'OPENAI_API_KEY',
description: `A unique key used to authenticate with the OpenAI API. Please note that this is a paid service and you will be charged for each request made to the API. <a class="u-bold" target="_blank" href="https://platform.openai.com/docs/quickstart/add-your-api-key">Learn More</a>`,
description: `A unique key used to authenticate with the OpenAI API. This is a paid service and you will be charged for each request made to the API. <a class="u-bold" target="_blank" href="https://platform.openai.com/docs/quickstart/add-your-api-key">Learn more</a>.`,
value: '',
placeholder: 'sk-wzG...vcy',
required: true
},
{
name: 'OPENAI_MAX_TOKENS',
description: `The maximum number of tokens that the OpenAI response should contain. Be aware that OpenAI models read and write a maximum number of tokens per API call, which varies depending on the model. For GPT-3.5-turbo, the limit is 4096 tokens. <a class="u-bold" target="_blank" href="https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them">Learn More</a>`,
description: `The maximum number of tokens that the OpenAI response should contain. Be aware that OpenAI models read and write a maximum number of tokens per API call, which varies depending on the model. For GPT-3.5-turbo, the limit is 4096 tokens. <a class="u-bold" target="_blank" href="https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them">Learn more</a>.`,
value: '512',
placeholder: '512',
required: false
@@ -122,7 +123,7 @@ export const marketplace = [
variables: [
{
name: 'PERSPECTIVE_API_KEY',
description: `Google Perspective API key. It authenticates your function, allowing it to interact with the API. <a class="u-bold" target="_blank" href="https://developers.google.com/codelabs/setup-perspective-api">Learn More</a>`,
description: `Google Perspective API key. It authenticates your function, allowing it to interact with the API. <a class="u-bold" target="_blank" href="https://developers.google.com/codelabs/setup-perspective-api">Learn more</a>.`,
value: '',
placeholder: 'AIzaS...fk-fuM',
required: true
@@ -134,7 +135,7 @@ export const marketplace = [
id: 'censor-with-redact',
name: 'Censor with Redact',
tagline:
'Cesnor sensitive information from a provided text string using Redact API by Pangea.',
'Censor sensitive information from a provided text string using Redact API by Pangea.',
permissions: ['any'],
events: [],
cron: '',
@@ -156,7 +157,7 @@ export const marketplace = [
variables: [
{
name: 'PANGEA_REDACT_TOKEN',
description: `Access token for the Pangea Redact API. <a class="u-bold" target="_blank" href="https://pangea.cloud/docs/redact/getting-started/configuration">Learn More</a>`,
description: `Access token for the Pangea Redact API. <a class="u-bold" target="_blank" href="https://pangea.cloud/docs/redact/getting-started/configuration">Learn more</a>.`,
value: '',
placeholder: 'pts_7p4...5wl4',
required: true
@@ -191,7 +192,7 @@ export const marketplace = [
{
icon: 'icon-discord',
id: 'discord-command-bot',
name: 'Discord Command Bot',
name: 'Discord command bot',
tagline: 'Simple command using Discord Interactions.',
permissions: ['any'],
events: [],
@@ -214,7 +215,7 @@ export const marketplace = [
variables: [
{
name: 'DISCORD_PUBLIC_KEY',
description: `Discord Public Key to verify request signature. <a class="u-bold" target="_blank" href="https://discord.com/developers/docs/tutorials/hosting-on-cloudflare-workers#creating-an-app-on-discord">Learn More</a>`,
description: `Discord Public Key to verify request signature. <a class="u-bold" target="_blank" href="https://discord.com/developers/docs/tutorials/hosting-on-cloudflare-workers#creating-an-app-on-discord">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: true
@@ -224,9 +225,9 @@ export const marketplace = [
{
icon: 'icon-github',
id: 'github-issue-bot',
name: 'GitHub Issue Bot',
name: 'GitHub issue bot',
tagline:
'Automate the process of responding to newly opened issues on a GitHub repository.',
'Automate the process of responding to newly opened issues in a GitHub repository.',
permissions: ['any'],
events: [],
cron: '',
@@ -248,14 +249,14 @@ export const marketplace = [
variables: [
{
name: 'GITHUB_TOKEN',
description: `A personal access token from GitHub with the necessary permissions to post comments on issues. <a class="u-bold" target="_blank" href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">Learn More</a>`,
description: `A personal access token from GitHub with the necessary permissions to post comments on issues. <a class="u-bold" target="_blank" href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">Learn more</a>.`,
value: '',
placeholder: 'ghp_1...',
required: true
},
{
name: 'GITHUB_WEBHOOK_SECRET',
description: `The secret used to verify that the webhook request comes from GitHub. <a class="u-bold" target="_blank" href="https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks">Learn More</a>`,
description: `The secret used to verify that the webhook request comes from GitHub. <a class="u-bold" target="_blank" href="https://docs.github.com/en/developers/webhooks-and-events/securing-your-webhooks">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: true
@@ -265,7 +266,7 @@ export const marketplace = [
{
icon: 'icon-bookmark',
id: 'url-shortener',
name: 'URL Shortener',
name: 'URL shortener',
tagline: 'Generate URL with short ID and redirect to the original URL when visited.',
permissions: ['any'],
events: [],
@@ -288,28 +289,28 @@ export const marketplace = [
variables: [
{
name: 'APPWRITE_API_KEY',
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: true
},
{
name: 'APPWRITE_ENDPOINT',
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: 'https://cloud.appwrite.io/v1',
placeholder: 'https://cloud.appwrite.io/v1',
required: false
},
{
name: 'APPWRITE_DATABASE_ID',
description: `The ID of the database to store the short URLs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn More</a>`,
description: `The ID of the database to store the short URLs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn more</a>.`,
value: 'urlShortener',
placeholder: 'urlShortener',
required: false
},
{
name: 'APPWRITE_COLLECTION_ID',
description: `The ID of the collection to store the short URLs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn More</a>`,
description: `The ID of the collection to store the short URLs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn more</a>.`,
value: 'urls',
placeholder: 'urls',
required: false
@@ -342,44 +343,44 @@ export const marketplace = [
variables: [
{
name: 'APPWRITE_API_KEY',
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: true
},
{
name: 'APPWRITE_DATABASE_ID',
description: `The ID of the Appwrite database that contains the collection to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn More</a>`,
description: `The ID of the Appwrite database that contains the collection to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn more</a>.`,
placeholder: '64a55...7b912',
required: true
},
{
name: 'APPWRITE_COLLECTION_ID',
description: `The ID of the collection in the Appwrite database to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn More</a>`,
description: `The ID of the collection in the Appwrite database to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn more</a>.`,
placeholder: '7c3e8...2a9f1',
required: true
},
{
name: 'ALGOLIA_ADMIN_API_KEY',
description: `The admin API Key for your Algolia service. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn More</a>`,
description: `The admin API Key for your Algolia service. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn more</a>.`,
placeholder: 'fd0aa...136a8',
required: true
},
{
name: 'ALGOLIA_INDEX_ID',
description: `The ID of the index in Algolia where the documents are to be synced. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/api-client/methods/indexing/">Learn More</a>`,
description: `The ID of the index in Algolia where the documents are to be synced. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/api-client/methods/indexing/">Learn more</a>.`,
placeholder: 'appwrite_index',
required: true
},
{
name: 'ALGOLIA_SEARCH_API_KEY',
description: `The search API Key for your Algolia service. This key is used for searching the synced index. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn More</a>`,
description: `The search API Key for your Algolia service. This key is used for searching the synced index. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn more</a>.`,
placeholder: 'bf2f5...df733',
required: true
},
{
name: 'APPWRITE_ENDPOINT',
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: 'https://cloud.appwrite.io/v1',
placeholder: 'https://cloud.appwrite.io/v1',
required: false
@@ -412,50 +413,50 @@ export const marketplace = [
variables: [
{
name: 'APPWRITE_API_KEY',
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The API Key to talk to Appwrite backend APIs. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: '',
placeholder: 'd1efb...aec35',
required: true
},
{
name: 'APPWRITE_DATABASE_ID',
description: `The ID of the Appwrite database that contains the collection to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn More</a>`,
description: `The ID of the Appwrite database that contains the collection to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/databases">Learn more</a>.`,
placeholder: '64a55...7b912',
required: true
},
{
name: 'APPWRITE_COLLECTION_ID',
description: `The ID of the collection in the Appwrite database to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn More</a>`,
description: `The ID of the collection in the Appwrite database to sync. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/collections">Learn more</a>.`,
placeholder: '7c3e8...2a9f1',
required: true
},
{
name: 'MEILISEARCH_ENDPOINT',
description: `The host URL of the Meilisearch server. <a class="u-bold" target="_blank" href="https://www.meilisearch.com/docs/learn/getting_started/quick_start/">Learn More</a>`,
description: `The host URL of the Meilisearch server. <a class="u-bold" target="_blank" href="https://www.meilisearch.com/docs/learn/getting_started/quick_start/">Learn more</a>.`,
placeholder: 'http://127.0.0.1:7700',
required: true
},
{
name: 'MEILISEARCH_ADMIN_API_KEY',
description: `The admin API key for Meilisearch. <a class="u-bold" target="_blank" href="https://docs.meilisearch.com/reference/api/keys/">Learn More</a>`,
description: `The admin API key for Meilisearch. <a class="u-bold" target="_blank" href="https://docs.meilisearch.com/reference/api/keys/">Learn more</a>.`,
placeholder: 'masterKey1234',
required: true
},
{
name: 'MEILISEARCH_SEARCH_API_KEY',
description: `API Key for Meilisearch search operations. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn More</a>`,
description: `API Key for Meilisearch search operations. <a class="u-bold" target="_blank" href="https://www.algolia.com/doc/guides/security/api-keys/">Learn more</a>.`,
placeholder: 'searchKey1234',
required: true
},
{
name: 'MEILISEARCH_INDEX_NAME',
description: `Name of the Meilisearch index to which the documents will be synchronized. <a class="u-bold" target="_blank" href="https://www.meilisearch.com/docs/learn/core_concepts/indexes/">Learn More</a>`,
description: `Name of the Meilisearch index to which the documents will be synchronized. <a class="u-bold" target="_blank" href="https://www.meilisearch.com/docs/learn/core_concepts/indexes/">Learn more</a>.`,
placeholder: 'appwrite_index',
required: true
},
{
name: 'APPWRITE_ENDPOINT',
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn More</a>`,
description: `The URL endpoint of the Appwrite server. <a class="u-bold" target="_blank" href="https://appwrite.io/docs/getting-started-for-server">Learn more</a>.`,
value: 'https://cloud.appwrite.io/v1',
placeholder: 'https://cloud.appwrite.io/v1',
required: false
@@ -488,26 +489,26 @@ export const marketplace = [
variables: [
{
name: 'VONAGE_API_KEY',
description: `API Key to use the Vonage API. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-">Learn More</a>`,
description: `API Key to use the Vonage API. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-">Learn more</a>.`,
value: '',
placeholder: '62...97',
required: true
},
{
name: 'VONAGE_API_SECRET',
description: `Secret to use the Vonage API. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-">Learn More</a>`,
description: `Secret to use the Vonage API. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/204014493-How-do-I-find-my-Voice-API-key-and-API-secret-">Learn more</a>.`,
placeholder: 'Zjc...5PH',
required: true
},
{
name: 'VONAGE_API_SIGNATURE_SECRET',
description: `Secret to verify the JWT token sent by Vonage. <a class="u-bold" target="_blank" href="https://developer.vonage.com/en/getting-started/concepts/signing-messages">Learn More</a>`,
description: `Secret to verify the JWT token sent by Vonage. <a class="u-bold" target="_blank" href="https://developer.vonage.com/en/getting-started/concepts/signing-messages">Learn more</a>.`,
placeholder: 'NXOi3...IBHDa',
required: true
},
{
name: 'VONAGE_WHATSAPP_NUMBER',
description: `Vonage WhatsApp number to send messages from. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/4431993282580-Where-do-I-find-my-WhatsApp-Number-Certificate-">Learn More</a>`,
description: `Vonage WhatsApp number to send messages from. <a class="u-bold" target="_blank" href="https://api.support.vonage.com/hc/en-us/articles/4431993282580-Where-do-I-find-my-WhatsApp-Number-Certificate-">Learn more</a>.`,
placeholder: '+14000000102',
required: true
}
@@ -516,7 +517,7 @@ export const marketplace = [
{
icon: 'icon-bell',
id: 'push-notification-with-fcm',
name: 'Push Notification with FCM',
name: 'Push notification with FCM',
tagline: 'Send push notifications to your users using Firebase Cloud Messaging (FCM).',
permissions: ['any'],
events: [],
@@ -539,26 +540,26 @@ export const marketplace = [
variables: [
{
name: 'FCM_PROJECT_ID',
description: `A unique identifier for your FCM project. <a class="u-bold" target="_blank" href="https://firebase.google.com/docs/projects/learn-more#project-id">Learn More</a>`,
description: `A unique identifier for your FCM project. <a class="u-bold" target="_blank" href="https://firebase.google.com/docs/projects/learn-more#project-id">Learn more</a>.`,
value: '',
placeholder: 'mywebapp-f6e57',
required: true
},
{
name: 'FCM_CLIENT_EMAIL',
description: `Your FCM service account email. <a class="u-bold" target="_blank" href="https://github.com/appwrite/templates/tree/main/node/push-notification-with-fcm#:~:text=Documentation-,FCM%3A%20SDK%20Setup,-FCM_PRIVATE_KEY">Learn More</a>`,
description: `Your FCM service account email. <a class="u-bold" target="_blank" href="https://github.com/appwrite/templates/tree/main/node/push-notification-with-fcm#:~:text=Documentation-,FCM%3A%20SDK%20Setup,-FCM_PRIVATE_KEY">Learn more</a>.`,
placeholder: 'fcm-adminsdk-2f0de@test-f7q57.iam.gserviceaccount.com',
required: true
},
{
name: 'FCM_PRIVATE_KEY',
description: `A unique private key used to authenticate with FCM. <a class="u-bold" target="_blank" href="https://github.com/appwrite/templates/tree/main/node/push-notification-with-fcm#:~:text=Documentation-,FCM%3A%20SDK%20Setup,-FCM_DATABASE_URL">Learn More</a>`,
description: `A unique private key used to authenticate with FCM. <a class="u-bold" target="_blank" href="https://github.com/appwrite/templates/tree/main/node/push-notification-with-fcm#:~:text=Documentation-,FCM%3A%20SDK%20Setup,-FCM_DATABASE_URL">Learn more</a>.`,
placeholder: '0b683...75675',
required: true
},
{
name: 'FCM_DATABASE_URL',
description: `URL of your FCM database. <a class="u-bold" target="_blank" href="https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments">Learn More</a>`,
description: `URL of your FCM database. <a class="u-bold" target="_blank" href="https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments">Learn more</a>.`,
placeholder: 'https://my-app-f298e.firebaseio.com',
required: true
}
@@ -567,7 +568,7 @@ export const marketplace = [
{
icon: 'icon-mail',
id: 'email-contact-form',
name: 'Email Contact Form',
name: 'Email contact form',
tagline: 'Sends an email with the contents of a HTML form.',
permissions: ['any'],
events: [],
+37 -28
View File
@@ -21,34 +21,43 @@
import ExecuteAccess from './steps/executeAccess.svelte';
async function create() {
const response = await sdk.forProject.functions.create(
$createFunction.$id || ID.unique(),
$createFunction.name,
$createFunction.runtime,
$createFunction.entrypoint,
$createFunction.execute || undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
$createFunction.commands || undefined
);
await sdk.forProject.functions.createDeployment(
response.$id,
$createFunctionDeployment[0],
true
);
goto(`${base}/console/project-${$page.params.project}/functions/function-${response.$id}`);
addNotification({
message: `${$createFunction.name} has been created`,
type: 'success'
});
trackEvent(Submit.FunctionCreate, {
customId: !!$createFunction.$id
});
resetState();
wizard.hide();
try {
const response = await sdk.forProject.functions.create(
$createFunction.$id || ID.unique(),
$createFunction.name,
$createFunction.runtime,
$createFunction.entrypoint,
$createFunction.execute || undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
$createFunction.commands || undefined
);
await sdk.forProject.functions.createDeployment(
response.$id,
$createFunctionDeployment[0],
true
);
goto(
`${base}/console/project-${$page.params.project}/functions/function-${response.$id}`
);
addNotification({
message: `${$createFunction.name} has been created`,
type: 'success'
});
trackEvent(Submit.FunctionCreate, {
customId: !!$createFunction.$id
});
resetState();
wizard.hide();
} catch (error) {
addNotification({
message: error.message,
type: 'error'
});
}
}
function resetState() {
@@ -53,6 +53,29 @@
wizard.hide();
}
// async function generateApiKey() {
// try {
// 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;
// addNotification({
// type: 'success',
// message: 'Key generated successfully.'
// });
// } catch (error) {
// addNotification({
// type: 'error',
// message: error.message
// });
// } finally {
// generatingApiKey = false;
// }
// }
function resetState() {
wizard.hide();
templateConfig.set(null);
@@ -12,12 +12,6 @@
if (!$templateConfig.runtime) {
throw new Error('Please select a runtime.');
}
for (const variable of $template.variables) {
if (!variable.required) {
continue;
}
}
}
async function loadRuntimes() {
@@ -1,52 +1,10 @@
<script lang="ts">
import { page } from '$app/stores';
import Alert from '$lib/components/alert.svelte';
import Button from '$lib/elements/forms/button.svelte';
import InputText from '$lib/elements/forms/inputText.svelte';
import { WizardStep } from '$lib/layout';
import { sdk } from '$lib/stores/sdk';
import { template, templateConfig } from '../store';
import { scopes } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
let generatingApiKey = false;
let showApiKeyCheck = false;
async function generateApiKey() {
if (generatingApiKey) {
return;
}
generatingApiKey = true;
try {
const key = await await sdk.forConsole.projects.createKey(
$page.params.project,
'Generated for Template',
scopes.map((scope) => scope.scope)
);
$templateConfig.variables['APPWRITE_API_KEY'] = key.secret;
showApiKeyCheck = true;
addNotification({
type: 'success',
message: 'Key generated successfully.'
});
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
} finally {
generatingApiKey = false;
}
}
import { FormList, Helper, InputChoice } from '$lib/elements/forms';
async function beforeSubmit() {
if (!$templateConfig.runtime) {
throw new Error('Please select a runtime.');
}
for (const variable of $template.variables) {
if (!variable.required) {
continue;
@@ -66,65 +24,48 @@
runtime.
</svelte:fragment>
<div class="u-flex u-flex-vertical u-gap-24">
{#if $template.variables.length > 0}
{#if $template?.variables?.length}
<div class="u-flex u-flex-vertical u-gap-16">
<p class="text u-bold">Environment variables</p>
<div class="u-flex u-flex-vertical u-gap-16">
{#each $template.variables as variable}
<div>
{#if variable.name === 'APPWRITE_API_KEY'}
<Alert type="info">
<svelte:fragment slot="title">API key creation</svelte:fragment>
<p class="text">
By clicking generate button, an API key will be
automatically generated in the background, and filled into
input field. This API key will be granted all scopes and
will never expire.
</p>
</Alert>
{/if}
<div class="u-margin-block-start-12 u-flex u-gap-8 u-cross-end">
<div class="u-width-full-line">
{#each $template.variables as variable}
{#if variable.name === 'APPWRITE_API_KEY'}
<div
class="box"
style:--box-padding="1rem"
style:--box-border-radius="var(--border-radius-small)">
<FormList>
<div>
<InputText
id={variable.name}
label={variable.name}
placeholder={variable.placeholder ?? ''}
required={variable.required}
autocomplete={false}
bind:value={$templateConfig.variables[variable.name]} />
bind:value={$templateConfig.appwriteApiKey} />
<Helper type="neutral">
This API key will allow you to interact with the Appwrite
server APIs. <a
href="http://#"
target="_blank"
rel="noopener noreferrer"
class="link">Learn more</a
>.
</Helper>
</div>
{#if variable.name === 'APPWRITE_API_KEY'}
<Button
disabled={$templateConfig.variables[variable.name]
? true
: false}
secondary
on:click={generateApiKey}>
{#if showApiKeyCheck && ($templateConfig.variables[variable.name] ? true : false)}
<span class="icon-check" aria-hidden="true" />
{/if}
{#if generatingApiKey}
<span class="loader is-small" />
{:else if showApiKeyCheck && ($templateConfig.variables[variable.name] ? true : false)}
<span class="text">Generated</span>
{:else}
<span class="text">Generate</span>
{/if}
</Button>
{/if}
</div>
<div class="u-margin-block-start-4">
<p class="helper">
<span class="icon-info" aria-hidden="true" />
<span class="text">{@html variable.description}</span>
</p>
</div>
<InputChoice id="generate" label="Generate API key on completion">
The <code class="inline-code">APPWRITE_API_KEY</code> will be automatically
generated for your project and applied to this function once it's
created.
</InputChoice>
</FormList>
</div>
{/each}
</div>
{/if}
<Helper type="neutral">
{@html variable.description}
</Helper>
{/each}
</div>
{/if}
</div>
+1
View File
@@ -13,6 +13,7 @@ export const templateConfig = writable<{
repositoryName: string;
repositoryPrivate: boolean;
repositoryId: string;
appwriteApiKey?: string;
}>();
export const repository = writable<Models.ProviderRepository>();
export const installation = writable<Models.Installation>();
@@ -84,6 +84,7 @@
<div class="u-margin-block-start-24">
<Alert
isStandalone
dismissible={false}
type="info"
buttons={[
{
@@ -11,6 +11,6 @@ export const load: LayoutLoad = async ({ depends }) => {
return {
header: Header,
breadcrumbs: Breadcrumbs,
installations: await sdk.forProject.vcs.listInstallations([Query.limit(100)])
installations: sdk.forProject.vcs.listInstallations([Query.limit(100)])
};
};
@@ -13,8 +13,8 @@ export const load: LayoutLoad = async ({ params, depends }) => {
return {
header: Header,
breadcrumbs: Breadcrumbs,
function: await sdk.forProject.functions.get(params.function),
domain: await sdk.forProject.proxy.listRules([
function: sdk.forProject.functions.get(params.function),
domain: sdk.forProject.proxy.listRules([
Query.equal('resourceType', 'function'),
Query.equal('resourceId', params.function),
Query.limit(1)
@@ -116,7 +116,7 @@
<div class="u-flex u-gap-12 u-cross-center">
<a
class="u-underline u-cursor-pointer"
href={'//' + data.domain.rules[0].domain}
href={`https//${data.domain.rules[0].domain}`}
target="_blank">
{data.domain.rules[0].domain}
</a>
@@ -21,7 +21,7 @@
);
addNotification({
type: 'success',
message: `${$func.name} has been redeployed.`
message: `Redeploying ${$func.name}`
});
trackEvent(Submit.FunctionRedeploy);