diff --git a/package-lock.json b/package-lock.json index a968c3872..8c3a99105 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index dc9714c77..af7df857e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/lib/layout/logs.svelte b/src/lib/layout/logs.svelte index 21c31dc7f..2f1607cf8 100644 --- a/src/lib/layout/logs.svelte +++ b/src/lib/layout/logs.svelte @@ -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'; } @@ -84,20 +81,13 @@ {calculateTime(execution.duration)} - +
  • Created at:
  • -
    {execution.status} diff --git a/src/lib/layout/shell.svelte b/src/lib/layout/shell.svelte index c3cc62ae0..132f458e8 100644 --- a/src/lib/layout/shell.svelte +++ b/src/lib/layout/shell.svelte @@ -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(); } }); diff --git a/src/lib/stores/marketplace.ts b/src/lib/stores/marketplace.ts index 774ff4de1..7636674e3 100644 --- a/src/lib/stores/marketplace.ts +++ b/src/lib/stores/marketplace.ts @@ -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. Learn More`, + description: `The API Key to talk to Appwrite backend APIs. Learn more.`, 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. Learn More`, + 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. Learn more.`, 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. Learn More`, + 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. Learn more.`, 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. Learn More`, + description: `Google Perspective API key. It authenticates your function, allowing it to interact with the API. Learn more.`, 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. Learn More`, + description: `Access token for the Pangea Redact API. Learn more.`, 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. Learn More`, + description: `Discord Public Key to verify request signature. Learn more.`, 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. Learn More`, + description: `A personal access token from GitHub with the necessary permissions to post comments on issues. Learn more.`, value: '', placeholder: 'ghp_1...', required: true }, { name: 'GITHUB_WEBHOOK_SECRET', - description: `The secret used to verify that the webhook request comes from GitHub. Learn More`, + description: `The secret used to verify that the webhook request comes from GitHub. Learn more.`, 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. Learn More`, + description: `The API Key to talk to Appwrite backend APIs. Learn more.`, value: '', placeholder: 'd1efb...aec35', required: true }, { name: 'APPWRITE_ENDPOINT', - description: `The URL endpoint of the Appwrite server. Learn More`, + description: `The URL endpoint of the Appwrite server. Learn more.`, 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. Learn More`, + description: `The ID of the database to store the short URLs. Learn more.`, value: 'urlShortener', placeholder: 'urlShortener', required: false }, { name: 'APPWRITE_COLLECTION_ID', - description: `The ID of the collection to store the short URLs. Learn More`, + description: `The ID of the collection to store the short URLs. Learn more.`, 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. Learn More`, + description: `The API Key to talk to Appwrite backend APIs. Learn more.`, value: '', placeholder: 'd1efb...aec35', required: true }, { name: 'APPWRITE_DATABASE_ID', - description: `The ID of the Appwrite database that contains the collection to sync. Learn More`, + description: `The ID of the Appwrite database that contains the collection to sync. Learn more.`, placeholder: '64a55...7b912', required: true }, { name: 'APPWRITE_COLLECTION_ID', - description: `The ID of the collection in the Appwrite database to sync. Learn More`, + description: `The ID of the collection in the Appwrite database to sync. Learn more.`, placeholder: '7c3e8...2a9f1', required: true }, { name: 'ALGOLIA_ADMIN_API_KEY', - description: `The admin API Key for your Algolia service. Learn More`, + description: `The admin API Key for your Algolia service. Learn more.`, placeholder: 'fd0aa...136a8', required: true }, { name: 'ALGOLIA_INDEX_ID', - description: `The ID of the index in Algolia where the documents are to be synced. Learn More`, + description: `The ID of the index in Algolia where the documents are to be synced. Learn more.`, 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. Learn More`, + description: `The search API Key for your Algolia service. This key is used for searching the synced index. Learn more.`, placeholder: 'bf2f5...df733', required: true }, { name: 'APPWRITE_ENDPOINT', - description: `The URL endpoint of the Appwrite server. Learn More`, + description: `The URL endpoint of the Appwrite server. Learn more.`, 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. Learn More`, + description: `The API Key to talk to Appwrite backend APIs. Learn more.`, value: '', placeholder: 'd1efb...aec35', required: true }, { name: 'APPWRITE_DATABASE_ID', - description: `The ID of the Appwrite database that contains the collection to sync. Learn More`, + description: `The ID of the Appwrite database that contains the collection to sync. Learn more.`, placeholder: '64a55...7b912', required: true }, { name: 'APPWRITE_COLLECTION_ID', - description: `The ID of the collection in the Appwrite database to sync. Learn More`, + description: `The ID of the collection in the Appwrite database to sync. Learn more.`, placeholder: '7c3e8...2a9f1', required: true }, { name: 'MEILISEARCH_ENDPOINT', - description: `The host URL of the Meilisearch server. Learn More`, + description: `The host URL of the Meilisearch server. Learn more.`, placeholder: 'http://127.0.0.1:7700', required: true }, { name: 'MEILISEARCH_ADMIN_API_KEY', - description: `The admin API key for Meilisearch. Learn More`, + description: `The admin API key for Meilisearch. Learn more.`, placeholder: 'masterKey1234', required: true }, { name: 'MEILISEARCH_SEARCH_API_KEY', - description: `API Key for Meilisearch search operations. Learn More`, + description: `API Key for Meilisearch search operations. Learn more.`, placeholder: 'searchKey1234', required: true }, { name: 'MEILISEARCH_INDEX_NAME', - description: `Name of the Meilisearch index to which the documents will be synchronized. Learn More`, + description: `Name of the Meilisearch index to which the documents will be synchronized. Learn more.`, placeholder: 'appwrite_index', required: true }, { name: 'APPWRITE_ENDPOINT', - description: `The URL endpoint of the Appwrite server. Learn More`, + description: `The URL endpoint of the Appwrite server. Learn more.`, 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. Learn More`, + description: `API Key to use the Vonage API. Learn more.`, value: '', placeholder: '62...97', required: true }, { name: 'VONAGE_API_SECRET', - description: `Secret to use the Vonage API. Learn More`, + description: `Secret to use the Vonage API. Learn more.`, placeholder: 'Zjc...5PH', required: true }, { name: 'VONAGE_API_SIGNATURE_SECRET', - description: `Secret to verify the JWT token sent by Vonage. Learn More`, + description: `Secret to verify the JWT token sent by Vonage. Learn more.`, placeholder: 'NXOi3...IBHDa', required: true }, { name: 'VONAGE_WHATSAPP_NUMBER', - description: `Vonage WhatsApp number to send messages from. Learn More`, + description: `Vonage WhatsApp number to send messages from. Learn more.`, 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. Learn More`, + description: `A unique identifier for your FCM project. Learn more.`, value: '', placeholder: 'mywebapp-f6e57', required: true }, { name: 'FCM_CLIENT_EMAIL', - description: `Your FCM service account email. Learn More`, + description: `Your FCM service account email. Learn more.`, 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. Learn More`, + description: `A unique private key used to authenticate with FCM. Learn more.`, placeholder: '0b683...75675', required: true }, { name: 'FCM_DATABASE_URL', - description: `URL of your FCM database. Learn More`, + description: `URL of your FCM database. Learn more.`, 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: [], diff --git a/src/lib/wizards/functions/createManual.svelte b/src/lib/wizards/functions/createManual.svelte index c9a5276d8..7d6af860d 100644 --- a/src/lib/wizards/functions/createManual.svelte +++ b/src/lib/wizards/functions/createManual.svelte @@ -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() { diff --git a/src/lib/wizards/functions/createTemplate.svelte b/src/lib/wizards/functions/createTemplate.svelte index 5d9fe8a18..992d4ddd6 100644 --- a/src/lib/wizards/functions/createTemplate.svelte +++ b/src/lib/wizards/functions/createTemplate.svelte @@ -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); diff --git a/src/lib/wizards/functions/steps/templateConfiguration.svelte b/src/lib/wizards/functions/steps/templateConfiguration.svelte index 0bd54ed76..56b8efb37 100644 --- a/src/lib/wizards/functions/steps/templateConfiguration.svelte +++ b/src/lib/wizards/functions/steps/templateConfiguration.svelte @@ -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() { diff --git a/src/lib/wizards/functions/steps/templateVariables.svelte b/src/lib/wizards/functions/steps/templateVariables.svelte index 52a5a05da..da61d5045 100644 --- a/src/lib/wizards/functions/steps/templateVariables.svelte +++ b/src/lib/wizards/functions/steps/templateVariables.svelte @@ -1,52 +1,10 @@