From 56cc9ee9eeae2cb5be7022fc20e3961330cede3d Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Mar 2024 14:58:07 +0100 Subject: [PATCH 01/33] feat: add invoice last error --- src/lib/sdk/billing.ts | 1 + .../billing/+page.svelte | 20 ++++--- .../billing/paymentHistory.svelte | 58 +++++++++++++++---- 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 60165d453..687ed4c4a 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -48,6 +48,7 @@ export type Invoice = { rate: number; desc: string; }[]; + lastError?: string; }; export type InvoiceList = { diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte index 379814dd1..15d12017a 100644 --- a/src/routes/console/organization-[organization]/billing/+page.svelte +++ b/src/routes/console/organization-[organization]/billing/+page.svelte @@ -76,13 +76,19 @@ {#if $failedInvoice} - - - The scheduled payment for {$organization.name} failed - - To avoid service disruptions in organization's your projects, please verify your payment - details and update them if necessary. - + {#if $failedInvoice?.lastError} + + The scheduled payment for {$organization.name} failed due to following error: {$failedInvoice.lastError} + + {:else} + + + The scheduled payment for {$organization.name} failed + + To avoid service disruptions in organization's your projects, please verify your payment + details and update them if necessary. + + {/if} {/if} {#if defaultPaymentMethod?.failed && !backupPaymentMethod} diff --git a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte index a8caf4348..8339ac60b 100644 --- a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte @@ -22,7 +22,7 @@ } from '$lib/elements/table'; import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; - import type { InvoiceList } from '$lib/sdk/billing'; + import type { Invoice, InvoiceList } from '$lib/sdk/billing'; import { sdk } from '$lib/stores/sdk'; import { VARS } from '$lib/system'; import { Query } from '@appwrite.io/console'; @@ -31,6 +31,7 @@ import { selectedInvoice, showRetryModal } from './store'; let showDropdown = []; + let showFailedError = false; let offset = 0; let invoiceList: InvoiceList = { @@ -51,6 +52,11 @@ ]); } + function retryPayment(invoice: Invoice) { + $selectedInvoice = invoice; + $showRetryModal = true; + } + $: if (offset !== null) { request(); } @@ -82,14 +88,45 @@ - - {status === 'requires_authentication' ? 'failed' : status} - + {#if invoice?.lastError} + + (showFailedError = true)} + button> + {status === 'requires_authentication' + ? 'failed' + : status} + + +
  • + The scheduled payment has failed. . +
  • +
    +
    + {:else} + + {status === 'requires_authentication' + ? 'failed' + : status} + + {/if}
    {formatCurrency(invoice.amount)} @@ -132,8 +169,7 @@ { - $selectedInvoice = invoice; - $showRetryModal = true; + retryPayment(invoice); showDropdown[i] = !showDropdown[i]; trackEvent(`click_retry_payment`, { from: 'button', From c9763b6810d714852a17e3bcd023b881b3b3458a Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Mar 2024 16:33:50 +0100 Subject: [PATCH 02/33] feat: invoice alert --- src/lib/stores/billing.ts | 8 ++++---- .../organization-[organization]/billing/+page.svelte | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index c213a7147..f577abd94 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -77,18 +77,18 @@ export function getServiceLimit(serviceId: PlanServices, tier: Tier = null): num } export const failedInvoice = cachedStore< - false | Invoice, + Invoice, { load: (orgId: string) => Promise; } >('failedInvoice', function ({ set }) { return { load: async (orgId) => { - if (!isCloud) set(false); + if (!isCloud) set(null); const invoices = await sdk.forConsole.billing.listInvoices(orgId); const failedInvoices = invoices.invoices.filter((i) => i.status === 'failed'); // const failedInvoices = invoices.invoices; - if (failedInvoices.length > 0) { + if (failedInvoices?.length > 0) { const firstFailed = failedInvoices[0]; const today = new Date(); const thirtyDaysAgo = new Date(today.setDate(today.getDate() - 30)); @@ -96,7 +96,7 @@ export const failedInvoice = cachedStore< if (failedDate < thirtyDaysAgo) { readOnly.set(true); } - } else set(false); + } else set(null); } }; }); diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte index 15d12017a..c437fd53f 100644 --- a/src/routes/console/organization-[organization]/billing/+page.svelte +++ b/src/routes/console/organization-[organization]/billing/+page.svelte @@ -22,6 +22,7 @@ import { BillingPlan } from '$lib/constants'; import RetryPaymentModal from './retryPaymentModal.svelte'; import { selectedInvoice, showRetryModal } from './store'; + import { Button } from '$lib/elements/forms'; $: defaultPaymentMethod = $paymentMethods?.paymentMethods?.find( (method: PaymentMethodData) => method.$id === $organization?.paymentMethodId @@ -79,6 +80,14 @@ {#if $failedInvoice?.lastError} The scheduled payment for {$organization.name} failed due to following error: {$failedInvoice.lastError} + + + {:else} From 589ad86048f38fbc891e7056a05b2809191276b7 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 20 Mar 2024 17:53:53 +0100 Subject: [PATCH 03/33] feat: add alert to payment method --- src/lib/components/creditCardInfo.svelte | 5 +++++ src/lib/sdk/billing.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/src/lib/components/creditCardInfo.svelte b/src/lib/components/creditCardInfo.svelte index b3b89d0d7..fdbd08abe 100644 --- a/src/lib/components/creditCardInfo.svelte +++ b/src/lib/components/creditCardInfo.svelte @@ -33,4 +33,9 @@ This payment method has expired {/if} + {#if paymentMethod?.lastError} + + {paymentMethod.lastError} + + {/if} diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 687ed4c4a..d935bd84e 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -19,6 +19,7 @@ export type PaymentMethodData = { failed: boolean; name: string; mandateId?: string; + lastError?: string; }; export type PaymentList = { From 79a2853984031a1faff3173ea6d11f300d723953 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:52:21 +0100 Subject: [PATCH 04/33] feat: new templates --- src/lib/stores/marketplace.ts | 732 ++++++++++++++++++++++++++++++++++ 1 file changed, 732 insertions(+) diff --git a/src/lib/stores/marketplace.ts b/src/lib/stores/marketplace.ts index 5e74be642..e7190d2a3 100644 --- a/src/lib/stores/marketplace.ts +++ b/src/lib/stores/marketplace.ts @@ -902,6 +902,738 @@ export const marketplace: MarketplaceTemplate[] = [ type: 'text' } ] + }, + { + icon: 'icon-chip', + id: 'text-generation-with-huggingface', + name: 'Text generation', + tagline: 'Generate text using the Hugging Face inference API.', + permissions: ['any'], + events: [], + cron: '', + timeout: 30, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/text-generation-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'language-translation-with-huggingface', + name: 'Language translation', + tagline: 'Translate text using the Hugging Face inference API.', + permissions: ['any'], + events: [], + cron: '', + timeout: 30, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/language-translation-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'image-classification-with-huggingface', + name: 'Image classification', + tagline: 'Classify images using the Hugging Face inference API.', + permissions: ['any'], + events: ['buckets.*.files.*.create'], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install && npm run setup', + 'src/main.js', + 'node/image-classification-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's Server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the responses are stored. Learn more.`, + value: 'ai', + placeholder: 'ai', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the responses are stored. Learn more.`, + value: 'image_classification', + placeholder: 'image_classification', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_BUCKET_ID', + description: `The ID of the bucket where the images are stored. Learn more.`, + value: 'image_classification', + placeholder: 'image_classification', + required: false, + type: 'text' + }, + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'object-detection-with-huggingface', + name: 'Object detection', + tagline: 'Detect objects in images using the Hugging Face inference API.', + permissions: ['any'], + events: ['buckets.*.files.*.create'], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install && npm run setup', + 'src/main.js', + 'node/object-detection-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the responses are stored. Learn more.`, + value: 'ai', + placeholder: 'ai', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the responses are stored. Learn more.`, + value: 'object_detection', + placeholder: 'object_detection', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_BUCKET_ID', + description: `The ID of the bucket where the images are stored. Learn more.`, + value: 'object_detection', + placeholder: 'object_detection', + required: false, + type: 'text' + }, + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'speech-recognition-with-huggingface', + name: 'Speech recognition', + tagline: 'Transcribe audio to text using the Hugging Face inference API.', + permissions: ['any'], + events: ['buckets.*.files.*.create'], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install && npm run setup', + 'src/main.js', + 'node/speech-recognition-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the responses are stored. Learn more.`, + value: 'ai', + placeholder: 'ai', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the responses are stored. Learn more.`, + value: 'speech_recognition', + placeholder: 'speech_recognition', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_BUCKET_ID', + description: `The ID of the bucket where audio is stored. Learn more.`, + value: 'speech_recognition', + placeholder: 'speech_recognition', + required: false, + type: 'text' + }, + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'text-to-speech-with-huggingface', + name: 'Text to speech', + tagline: 'Convert text to speech using the Hugging Face inference API.', + permissions: ['any'], + events: ['databases.*.collections.*.documents.*.create'], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install && npm run setup', + 'src/main.js', + 'node/text-to-speech-with-huggingface' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the responses are stored. Learn more.`, + value: 'ai', + placeholder: 'ai', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the responses are stored. Learn more.`, + value: 'speech_recognition', + placeholder: 'speech_recognition', + required: false, + type: 'text' + }, + { + name: 'APPWRITE_BUCKET_ID', + description: `The ID of the bucket where audio is stored. Learn more.`, + value: 'speech_recognition', + placeholder: 'speech_recognition', + required: false, + type: 'text' + }, + { + name: 'HUGGINGFACE_ACCESS_TOKEN', + description: `Secret for sending requests to the Hugging Face API. Learn more.`, + placeholder: 'hf_MUvn...', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'chat-with-perplexity-ai', + name: 'Chat with Perplexity AI', + tagline: 'Create a chatbot using the Perplexity AI API.', + permissions: ['any'], + events: [], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/chat-with-perplexity-ai' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'PERPLEXITY_API_KEY', + description: `A unique key used to authenticate with the Perplexity API. Learn more.`, + placeholder: `pplex-68...999`, + required: true, + type: 'password' + }, + { + name: 'PERPLEXITY_MAX_TOKENS', + description: `The maximum number of tokens to generate. Learn more.`, + placeholder: `512`, + required: false, + type: 'number' + } + ] + }, + { + icon: 'icon-chip', + id: 'generate-with-replicate', + name: 'Generate with Replicate', + tagline: "Generate text, audio and images using Replicate's API.", + permissions: ['any'], + events: [], + cron: '', + timeout: 300, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/generate-with-replicate' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'REPLICATE_API_KEY', + description: `A unique key used to authenticate with the Replicate API. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'chat-with-perplexity-ai', + name: 'Chat with Perplexity AI', + tagline: 'Create a chatbot using the Perplexity AI API.', + permissions: ['any'], + events: [], + cron: '', + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/chat-with-perplexity-ai' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'PERPLEXITY_API_KEY', + description: `A unique key used to authenticate with the Perplexity API. Learn more.`, + placeholder: `pplex-68...999`, + required: true, + type: 'password' + }, + { + name: 'PERPLEXITY_MAX_TOKENS', + description: `The maximum number of tokens to generate. Learn more.`, + placeholder: `512`, + required: false, + type: 'number' + } + ] + }, + { + icon: 'icon-chip', + id: 'generate-with-replicate', + name: 'Generate with Replicate', + tagline: "Generate text, audio and images using Replicate's API.", + permissions: ['any'], + events: [], + cron: '', + timeout: 300, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/generate-with-replicate' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'REPLICATE_API_KEY', + description: `A unique key used to authenticate with the Replicate API. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + } + ] + }, + { + icon: 'icon-chip', + id: 'sync-with-pinecone', + name: 'Sync with Pinecone', + tagline: "Sync your Appwrite database with Pinecone's vector database.", + permissions: ['any'], + events: [], + cron: '', + timeout: 30, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/sync-with-pinecone' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'OPENAI_API_KEY', + 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, + type: 'password' + }, + { + name: 'PINECONE_API_KEY', + description: `A unique key used to authenticate with the Pinecone API. Learn more.`, + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'PINECONE_INDEX_NAME', + description: `The name of the index in Pinecone. Learn more.`, + placeholder: 'my-index', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the documents are stored. Learn more.`, + placeholder: 'my-database', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the documents are stored. Learn more.`, + placeholder: 'my-collection', + required: true, + type: 'text' + } + ] + }, + { + icon: 'icon-chip', + id: 'rag-with-langchain', + name: 'RAG with LangChain', + tagline: 'Generate text using a LangChain RAG model', + permissions: ['any'], + events: [], + cron: '', + timeout: 30, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/rag-with-langchain' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'OPENAI_API_KEY', + 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, + type: 'password' + }, + { + name: 'PINECONE_API_KEY', + description: `A unique key used to authenticate with the Pinecone API. Learn more.`, + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'PINECONE_INDEX_NAME', + description: `The name of the index in Pinecone. Learn more.`, + placeholder: 'my-index', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the documents are stored. Learn more.`, + placeholder: 'my-database', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the documents are stored. Learn more.`, + placeholder: 'my-collection', + required: true, + type: 'text' + } + ] + }, + { + icon: 'icon-chip', + id: 'speak-with-elevenlabs', + name: 'Speak with ElevenLabs', + tagline: 'Convert text to speech using the ElevenLabs API.', + permissions: ['any'], + cron: '', + events: [], + timeout: 15, + usecases: ['AI'], + runtimes: [ + ...getRuntimes( + TemplateRuntimes.NODE, + 'npm install', + 'src/main.js', + 'node/speak-with-elevenlabs' + ) + ], + instructions: `For documentation and instructions check out file.`, + vcsProvider: 'github', + providerRepositoryId: 'templates', + providerOwner: 'appwrite', + providerBranch: 'main', + variables: [ + { + name: 'ELEVENLABS_API_KEY', + description: `A unique key used to authenticate with the ElevenLabs API. Learn more.`, + placeholder: 'd03xxxxxxxx26', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_API_KEY', + description: `The API Key to authenticate against Appwrite's server APIs. Learn more.`, + value: '', + placeholder: 'd1efb...aec35', + required: true, + type: 'password' + }, + { + name: 'APPWRITE_ENDPOINT', + description: `The URL endpoint of the Appwrite server. Learn more.`, + value: 'https://cloud.appwrite.io/v1', + placeholder: 'https://cloud.appwrite.io/v1', + required: false, + type: 'url' + }, + { + name: 'APPWRITE_DATABASE_ID', + description: `The ID of the database where the responses are stored. Learn more.`, + placeholder: 'my-database', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_COLLECTION_ID', + description: `The ID of the collection where the responses are stored. Learn more.`, + placeholder: 'my-collection', + required: true, + type: 'text' + }, + { + name: 'APPWRITE_BUCKET_ID', + description: `The ID of the bucket where audio is stored. Learn more.`, + placeholder: 'generated_speech', + required: true, + type: 'text' + } + ] } ]; From ec6a93cdc3e709d0a4612e5a437b7b5e7c4c9891 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:27:11 +0100 Subject: [PATCH 05/33] chore: remove duplicate perplexity --- src/lib/stores/marketplace.ts | 40 ----------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/lib/stores/marketplace.ts b/src/lib/stores/marketplace.ts index e7190d2a3..02484e498 100644 --- a/src/lib/stores/marketplace.ts +++ b/src/lib/stores/marketplace.ts @@ -1261,46 +1261,6 @@ export const marketplace: MarketplaceTemplate[] = [ } ] }, - { - icon: 'icon-chip', - id: 'chat-with-perplexity-ai', - name: 'Chat with Perplexity AI', - tagline: 'Create a chatbot using the Perplexity AI API.', - permissions: ['any'], - events: [], - cron: '', - timeout: 15, - usecases: ['AI'], - runtimes: [ - ...getRuntimes( - TemplateRuntimes.NODE, - 'npm install', - 'src/main.js', - 'node/chat-with-perplexity-ai' - ) - ], - instructions: `For documentation and instructions check out file.`, - vcsProvider: 'github', - providerRepositoryId: 'templates', - providerOwner: 'appwrite', - providerBranch: 'main', - variables: [ - { - name: 'PERPLEXITY_API_KEY', - description: `A unique key used to authenticate with the Perplexity API. Learn more.`, - placeholder: `pplex-68...999`, - required: true, - type: 'password' - }, - { - name: 'PERPLEXITY_MAX_TOKENS', - description: `The maximum number of tokens to generate. Learn more.`, - placeholder: `512`, - required: false, - type: 'number' - } - ] - }, { icon: 'icon-chip', id: 'generate-with-replicate', From 95dc555ee3a02577056c39c701b2fdf08a107043 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 2 Apr 2024 17:23:12 +0200 Subject: [PATCH 06/33] fix: race condition during invalidation --- .../function-[function]/settings/+page.svelte | 11 +++++------ .../console/project-[project]/updateVariables.svelte | 8 +++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte index 4dac5f427..2384dc1bd 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte @@ -24,21 +24,20 @@ const sdkCreateVariable = async (key: string, value: string) => { await sdk.forProject.functions.createVariable($func.$id, key, value); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; const sdkUpdateVariable = async (variableId: string, key: string, value: string) => { await sdk.forProject.functions.updateVariable($func.$id, variableId, key, value); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; const sdkDeleteVariable = async (variableId: string) => { await sdk.forProject.functions.deleteVariable($func.$id, variableId); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.FUNCTION); + await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; + + $: console.log(data.variables); diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 8a17fa61d..892ed7ef4 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -138,9 +138,11 @@ selectedVar = null; showPromoteModal = false; - await invalidate(Dependencies.FUNCTION); - await invalidate(Dependencies.VARIABLES); - await invalidate(Dependencies.PROJECT_VARIABLES); + await Promise.all([ + await invalidate(Dependencies.FUNCTION), + await invalidate(Dependencies.VARIABLES), + await invalidate(Dependencies.PROJECT_VARIABLES) + ]); addNotification({ type: 'success', From 230a7621b446d9f5976b383b722b781a4deabb00 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 2 Apr 2024 17:23:49 +0200 Subject: [PATCH 07/33] remove console log --- .../functions/function-[function]/settings/+page.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte index 2384dc1bd..db5149a6a 100644 --- a/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte +++ b/src/routes/console/project-[project]/functions/function-[function]/settings/+page.svelte @@ -36,8 +36,6 @@ await sdk.forProject.functions.deleteVariable($func.$id, variableId); await Promise.all([invalidate(Dependencies.VARIABLES), invalidate(Dependencies.FUNCTION)]); }; - - $: console.log(data.variables); From b79e0347a5dcaffa1393b0bb39ba60ad3d6a879d Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 2 Apr 2024 17:30:40 +0200 Subject: [PATCH 08/33] fix: upload wizard not closing --- .../storage/bucket-[bucket]/create-file/create.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte b/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte index 99c989561..aeed538c9 100644 --- a/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte +++ b/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte @@ -29,7 +29,7 @@ async function create() { try { - await uploader.uploadFile( + uploader.uploadFile( bucketId, $createFile.id ?? ID.unique(), $createFile.files[0], From b3b42ee512fd89c7b5240eae1ea8f130737a564c Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 3 Apr 2024 14:03:13 +0200 Subject: [PATCH 09/33] feat: add downgrade alerts --- .../confirmDetails.svelte | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte index a67c5086e..b89bc897c 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/confirmDetails.svelte @@ -1,5 +1,5 @@ + +{#if $organization?.$id && $organization?.billingPlan === BillingPlan.STARTER && $readOnly && !$page.url.pathname.includes('/console/account')} + + + Usage for the {$organization.name} organization has reached the limits of the Starter + plan. Consider upgrading to increase your resource usage. + + + + + + +{/if} diff --git a/src/lib/layout/header.svelte b/src/lib/layout/header.svelte index 9dbc534c5..16c97001a 100644 --- a/src/lib/layout/header.svelte +++ b/src/lib/layout/header.svelte @@ -24,9 +24,6 @@ import CreateOrganizationCloud from '$routes/console/createOrganizationCloud.svelte'; import { Feedback } from '$lib/components/feedback'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; - import { Pill } from '$lib/elements'; - import { showExcess } from '$routes/console/organization-[organization]/store'; - import { readOnly } from '$lib/stores/billing'; import { BillingPlan } from '$lib/constants'; let showDropdown = false; @@ -105,17 +102,6 @@ {/if} -{#if !$page.url.pathname.includes('/console/account') && $readOnly} -
    - ($showExcess = true)}> -
    -
    -
    -
    -{/if} -
    Bandwidth -

    Calculated for all bandwidth used in your project.

    +

    + Calculated for all bandwidth used across your project. Resets at the start of each + billing cycle. +

    {#if network} {@const humanized = humanFileSize(total(network))} From ada46586e8a547ba117b82e6acf82cf7b2e24d1e Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 5 Apr 2024 17:15:17 +0200 Subject: [PATCH 14/33] feat: add notificaiton for when a service is over the 75% mark --- src/lib/stores/billing.ts | 62 +++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 8155f4a4a..50f03d7a4 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -24,6 +24,10 @@ import { BillingPlan } from '$lib/constants'; import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte'; import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte'; import LimitReached from '$lib/components/billing/alerts/limitReached.svelte'; +import { wizard } from './wizard'; +import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; +import { trackEvent } from '$lib/actions/analytics'; +import { browser } from '$app/environment'; export type Tier = 'tier-0' | 'tier-1' | 'tier-2'; @@ -189,19 +193,20 @@ export async function checkForUsageLimit(org: Organization) { return; } const { bandwidth, documents, executions, storage, users } = org?.billingLimits ?? {}; + const resources = [ + { value: bandwidth, name: 'bandwidth' }, + { value: documents, name: 'documents' }, + { value: executions, name: 'executions' }, + { value: storage, name: 'storage' }, + { value: users, name: 'users' } + ]; + const members = await sdk.forConsole.teams.listMemberships(org.$id); const plan = get(plansInfo)?.get(org.billingPlan); const membersOverflow = members?.total > plan.members ? members.total - (plan.members || members.total) : 0; - if ( - bandwidth >= 100 || - documents >= 100 || - executions >= 100 || - storage >= 100 || - users >= 100 || - membersOverflow > 0 - ) { + if (resources.some((r) => r.value >= 100) || membersOverflow > 0) { readOnly.set(true); headerAlert.add({ id: 'limitReached', @@ -209,15 +214,40 @@ export async function checkForUsageLimit(org: Organization) { show: true, importance: 7 }); - } else if ( - bandwidth >= 75 || - documents >= 75 || - executions >= 75 || - storage >= 75 || - users >= 75 - ) { + } else if (resources.some((r) => r.value >= 75)) { readOnly.set(false); - //show notification + if (browser) { + const lastNotification = + parseInt(localStorage.getItem('limitReachedNotification')) ?? 0; + const now = new Date().getTime(); + if (now - lastNotification < 1000 * 60 * 60 * 24 * 3) return; + + localStorage.setItem('limitReachedNotification', now.toString()); + addNotification({ + type: 'warning', + isHtml: true, + timeout: 0, + message: `${org.name} has reached 75% of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`, + buttons: [ + { + name: 'View usage', + method: () => { + goto(`${base}/console/organization-${org.$id}/usage`); + } + }, + { + name: 'Upgrade plan', + method: () => { + wizard.start(ChangeOrganizationTierCloud); + trackEvent('click_organization_upgrade', { + from: 'button', + source: 'limit_reached_notification' + }); + } + } + ] + }); + } } else { readOnly.set(false); } From 9210a73b412e4e9f4fb6282da87f1355c4b5b468 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:22:00 +0100 Subject: [PATCH 15/33] fix: runtimes list --- src/routes/console/project-[project]/functions/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/functions/store.ts b/src/routes/console/project-[project]/functions/store.ts index 4a52582a7..8e8c7db77 100644 --- a/src/routes/console/project-[project]/functions/store.ts +++ b/src/routes/console/project-[project]/functions/store.ts @@ -3,7 +3,7 @@ import { derived } from 'svelte/store'; import type { Models } from '@appwrite.io/console'; export const runtimesList = derived(page, async ($page) => { - const { runtimes } = (await $page.data.runtimes) as Models.RuntimeList; + const { runtimes } = (await $page.data.runtimesList) as Models.RuntimeList; const filtered = runtimes.filter((runtime) => !runtime.name.startsWith('python-ml')); return { runtimes: filtered, total: filtered.length }; }); From 4d5950a6372d7cbf0c25f178a915ae45444692f7 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 5 Apr 2024 19:05:55 +0100 Subject: [PATCH 16/33] fix: runtimes list --- src/routes/console/project-[project]/functions/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/functions/store.ts b/src/routes/console/project-[project]/functions/store.ts index 8e8c7db77..172a5ce42 100644 --- a/src/routes/console/project-[project]/functions/store.ts +++ b/src/routes/console/project-[project]/functions/store.ts @@ -4,7 +4,7 @@ import type { Models } from '@appwrite.io/console'; export const runtimesList = derived(page, async ($page) => { const { runtimes } = (await $page.data.runtimesList) as Models.RuntimeList; - const filtered = runtimes.filter((runtime) => !runtime.name.startsWith('python-ml')); + const filtered = runtimes.filter((runtime) => !runtime.$id.startsWith('python-ml')); return { runtimes: filtered, total: filtered.length }; }); From 330a447196011ec3841b7431807bcc135265d505 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 8 Apr 2024 13:26:41 +0200 Subject: [PATCH 17/33] feat: show notification once a day --- src/lib/stores/billing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 50f03d7a4..362dcdf6e 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -220,7 +220,7 @@ export async function checkForUsageLimit(org: Organization) { const lastNotification = parseInt(localStorage.getItem('limitReachedNotification')) ?? 0; const now = new Date().getTime(); - if (now - lastNotification < 1000 * 60 * 60 * 24 * 3) return; + if (now - lastNotification < 1000 * 60 * 60 * 24) return; localStorage.setItem('limitReachedNotification', now.toString()); addNotification({ From 6e09e6cc756de7d58e984b2692737c26e062bfa8 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 8 Apr 2024 13:32:18 +0200 Subject: [PATCH 18/33] feat: update message --- src/lib/stores/billing.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 362dcdf6e..be97eab8a 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -223,11 +223,15 @@ export async function checkForUsageLimit(org: Organization) { if (now - lastNotification < 1000 * 60 * 60 * 24) return; localStorage.setItem('limitReachedNotification', now.toString()); + let message = `${org.name} has reached 75% of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`; + if (resources.filter((r) => r.value >= 75)?.length > 1) { + message = `Usage for ${org.name} has reached 75% of the Starter plan limit. Upgrade to ensure there are no service disruptions.`; + } addNotification({ type: 'warning', isHtml: true, timeout: 0, - message: `${org.name} has reached 75% of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`, + message, buttons: [ { name: 'View usage', From 3da6609257e0afd197bd94705b21c3662b6aece7 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 8 Apr 2024 15:08:14 +0200 Subject: [PATCH 19/33] chore: remove old upload modal --- .../storage/bucket-[bucket]/create.svelte | 105 ------------------ 1 file changed, 105 deletions(-) delete mode 100644 src/routes/console/project-[project]/storage/bucket-[bucket]/create.svelte diff --git a/src/routes/console/project-[project]/storage/bucket-[bucket]/create.svelte b/src/routes/console/project-[project]/storage/bucket-[bucket]/create.svelte deleted file mode 100644 index 209f1ded2..000000000 --- a/src/routes/console/project-[project]/storage/bucket-[bucket]/create.svelte +++ /dev/null @@ -1,105 +0,0 @@ - - - - -
    - -
    - - {#if !showCustomId} -
    - (showCustomId = !showCustomId)}> - -
    - {:else} - - {/if} - Permissions -

    - Choose who can access your buckets and files. For more information, visit our - - Permissions guide - . -

    - {#if $bucket.fileSecurity} -
    - - File security enabled - Users will be able to access this file if they have been granted - either File or Bucket permissions. - -
    -
    - -
    - {:else} - - File security disabled - If you want to assign file permissions, navigate to Bucket settings and enable file security. - Otherwise, only Bucket permissions will be used. - - {/if} -
    - - - - -
    From 1de5e3bc98946c2ad48d97ab08d31f821f4c0f99 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 8 Apr 2024 15:08:29 +0200 Subject: [PATCH 20/33] chore: success notification copy --- .../storage/bucket-[bucket]/create-file/create.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte b/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte index aeed538c9..66315f0dd 100644 --- a/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte +++ b/src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte @@ -42,7 +42,7 @@ addNotification({ type: 'success', - message: `File has been uploaded` + message: `File upload in progress` }); trackEvent(Submit.FileCreate, { customId: !!$createFile.id From 5ec52553a22e632fd06e1d30d611bf5d7686029a Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 09:46:44 +0200 Subject: [PATCH 21/33] fix: replace card flow --- .../billing/replaceCard.svelte | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index 639964119..92e1bd949 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -5,7 +5,7 @@ import { sdk } from '$lib/stores/sdk'; import { organization } from '$lib/stores/organization'; import { Dependencies } from '$lib/constants'; - import { submitStripeCard } from '$lib/stores/stripe'; + import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe'; import { onMount } from 'svelte'; import type { PaymentList } from '$lib/sdk/billing'; import { addNotification } from '$lib/stores/notifications'; @@ -21,13 +21,19 @@ onMount(async () => { methods = await sdk.forConsole.billing.listPaymentMethods(); - - if (!$organization.paymentMethodId && !$organization.backupPaymentMethodId) { - selectedPaymentMethodId = methods?.total ? methods.paymentMethods[0].$id : null; - } selectedPaymentMethodId = isBackup ? $organization.backupPaymentMethodId : $organization.paymentMethodId; + if (!$organization.paymentMethodId && !$organization.backupPaymentMethodId) { + selectedPaymentMethodId = methods?.total ? methods.paymentMethods[0].$id : null; + } + // If the selected payment method does not belong to the current user, reset it + if ( + methods?.total && + !methods.paymentMethods.some((method) => method.$id === selectedPaymentMethodId) + ) { + selectedPaymentMethodId = null; + } }); async function handleSubmit() { @@ -82,6 +88,14 @@ $: filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4); + $: if (selectedPaymentMethodId === null && !$isStripeInitialized) { + initializeStripe(); + } + + $: if (selectedPaymentMethodId) { + isStripeInitialized.set(false); + } + $: if (!show) { selectedPaymentMethodId = null; } From 1e19bd505f12adb9de9efcab226accab3796f1d2 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 09:53:08 +0200 Subject: [PATCH 22/33] fix: logic --- .../billing/replaceCard.svelte | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index 92e1bd949..bf0f62916 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -21,18 +21,20 @@ onMount(async () => { methods = await sdk.forConsole.billing.listPaymentMethods(); - selectedPaymentMethodId = isBackup - ? $organization.backupPaymentMethodId - : $organization.paymentMethodId; + if (!$organization.paymentMethodId && !$organization.backupPaymentMethodId) { selectedPaymentMethodId = methods?.total ? methods.paymentMethods[0].$id : null; - } - // If the selected payment method does not belong to the current user, reset it - if ( - methods?.total && - !methods.paymentMethods.some((method) => method.$id === selectedPaymentMethodId) - ) { - selectedPaymentMethodId = null; + } else { + selectedPaymentMethodId = isBackup + ? $organization.backupPaymentMethodId + : $organization.paymentMethodId; + // If the selected payment method does not belong to the current user, select the first one. + if ( + methods?.total && + !methods.paymentMethods.some((method) => method.$id === selectedPaymentMethodId) + ) { + selectedPaymentMethodId = methods.paymentMethods[0].$id; + } } }); From d4d43b678b80fd5708926538009565441917d0df Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 09:56:50 +0200 Subject: [PATCH 23/33] Update src/routes/console/project-[project]/updateVariables.svelte Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/console/project-[project]/updateVariables.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 892ed7ef4..035d4c480 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -139,9 +139,9 @@ showPromoteModal = false; await Promise.all([ - await invalidate(Dependencies.FUNCTION), - await invalidate(Dependencies.VARIABLES), - await invalidate(Dependencies.PROJECT_VARIABLES) + invalidate(Dependencies.FUNCTION), + invalidate(Dependencies.VARIABLES), + invalidate(Dependencies.PROJECT_VARIABLES) ]); addNotification({ From 4d88ef4dd5ea7fa191868a09f7db04d2a6d6ab2f Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 10:01:01 +0200 Subject: [PATCH 24/33] chore: linter --- src/routes/console/project-[project]/updateVariables.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/project-[project]/updateVariables.svelte b/src/routes/console/project-[project]/updateVariables.svelte index 035d4c480..7396219fa 100644 --- a/src/routes/console/project-[project]/updateVariables.svelte +++ b/src/routes/console/project-[project]/updateVariables.svelte @@ -139,9 +139,9 @@ showPromoteModal = false; await Promise.all([ - invalidate(Dependencies.FUNCTION), - invalidate(Dependencies.VARIABLES), - invalidate(Dependencies.PROJECT_VARIABLES) + invalidate(Dependencies.FUNCTION), + invalidate(Dependencies.VARIABLES), + invalidate(Dependencies.PROJECT_VARIABLES) ]); addNotification({ From d1514904cf83729718b410e7aaf4430104765149 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 10:23:55 +0200 Subject: [PATCH 25/33] chore: copy change from "delete" to "remove" --- .../billing/deleteOrgPayment.svelte | 13 ++++++------- .../billing/paymentMethods.svelte | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/routes/console/organization-[organization]/billing/deleteOrgPayment.svelte b/src/routes/console/organization-[organization]/billing/deleteOrgPayment.svelte index 747b538ec..e2de60520 100644 --- a/src/routes/console/organization-[organization]/billing/deleteOrgPayment.svelte +++ b/src/routes/console/organization-[organization]/billing/deleteOrgPayment.svelte @@ -58,11 +58,10 @@ headerDivider={false} title="Unable to delete payment method">

    - The {isBackup ? 'backup' : 'default'} payment method cannot be deleted as + The {isBackup ? 'backup' : 'default'} payment method cannot be removed as {$organization?.name} - has an upcoming invoice. To proceed with deletion, set a {isBackup - ? 'default' - : 'backup'} or add a new {isBackup ? 'backup' : 'default'} payment method. + has an upcoming invoice. To proceed, set a {isBackup ? 'default' : 'backup'} or add a new + {isBackup ? 'backup' : 'default'} payment method.

    @@ -76,13 +75,13 @@ icon="exclamation" state="warning" headerDivider={false} - title="Delete payment method"> + title="Remove payment method">

    - Are you sure you want to delete the payment method from {$organization?.name}? + Are you sure you want to remove the payment method from {$organization?.name}?

    - + {/if} diff --git a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte index ae44de05e..5a41e40a7 100644 --- a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte @@ -137,7 +137,7 @@ showDelete = true; showDropdown = false; }}> - Delete + Remove
    From cd550315df9865e9e977c82cafbd50a342705807 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 15:34:12 +0200 Subject: [PATCH 26/33] fix: retry payment modal No method selected when the organization paymentMethod belongs to someone else --- .../billing/retryPaymentModal.svelte | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte b/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte index e0f034029..06dde940f 100644 --- a/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte +++ b/src/routes/console/organization-[organization]/billing/retryPaymentModal.svelte @@ -30,8 +30,21 @@ let paymentMethodId: string; let setAsDefault = false; - onMount(() => { - paymentMethodId = $organization.paymentMethodId; + onMount(async () => { + if (!$organization.paymentMethodId && !$organization.backupPaymentMethodId) { + paymentMethodId = $paymentMethods?.total ? $paymentMethods.paymentMethods[0].$id : null; + } else { + paymentMethodId = $organization.paymentMethodId + ? $organization.paymentMethodId + : $organization.backupPaymentMethodId; + // If the selected payment method does not belong to the current user, select the first one. + if ( + $paymentMethods?.total && + !$paymentMethods.paymentMethods.some((method) => method.$id === paymentMethodId) + ) { + paymentMethodId = $paymentMethods.paymentMethods[0].$id; + } + } }); async function handleSubmit() { From 01f1d4f6621707fdf19cf3c2fdca85777d9a5b5f Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 9 Apr 2024 16:26:55 +0200 Subject: [PATCH 27/33] chore: remove browser check --- src/lib/stores/billing.ts | 66 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index be97eab8a..3d827cf5c 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -27,7 +27,6 @@ import LimitReached from '$lib/components/billing/alerts/limitReached.svelte'; import { wizard } from './wizard'; import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte'; import { trackEvent } from '$lib/actions/analytics'; -import { browser } from '$app/environment'; export type Tier = 'tier-0' | 'tier-1' | 'tier-2'; @@ -216,42 +215,39 @@ export async function checkForUsageLimit(org: Organization) { }); } else if (resources.some((r) => r.value >= 75)) { readOnly.set(false); - if (browser) { - const lastNotification = - parseInt(localStorage.getItem('limitReachedNotification')) ?? 0; - const now = new Date().getTime(); - if (now - lastNotification < 1000 * 60 * 60 * 24) return; + const lastNotification = parseInt(localStorage.getItem('limitReachedNotification')) ?? 0; + const now = new Date().getTime(); + if (now - lastNotification < 1000 * 60 * 60 * 24) return; - localStorage.setItem('limitReachedNotification', now.toString()); - let message = `${org.name} has reached 75% of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`; - if (resources.filter((r) => r.value >= 75)?.length > 1) { - message = `Usage for ${org.name} has reached 75% of the Starter plan limit. Upgrade to ensure there are no service disruptions.`; - } - addNotification({ - type: 'warning', - isHtml: true, - timeout: 0, - message, - buttons: [ - { - name: 'View usage', - method: () => { - goto(`${base}/console/organization-${org.$id}/usage`); - } - }, - { - name: 'Upgrade plan', - method: () => { - wizard.start(ChangeOrganizationTierCloud); - trackEvent('click_organization_upgrade', { - from: 'button', - source: 'limit_reached_notification' - }); - } - } - ] - }); + localStorage.setItem('limitReachedNotification', now.toString()); + let message = `${org.name} has reached 75% of the Starter plan's ${resources.find((r) => r.value >= 75).name} limit. Upgrade to ensure there are no service disruptions.`; + if (resources.filter((r) => r.value >= 75)?.length > 1) { + message = `Usage for ${org.name} has reached 75% of the Starter plan limit. Upgrade to ensure there are no service disruptions.`; } + addNotification({ + type: 'warning', + isHtml: true, + timeout: 0, + message, + buttons: [ + { + name: 'View usage', + method: () => { + goto(`${base}/console/organization-${org.$id}/usage`); + } + }, + { + name: 'Upgrade plan', + method: () => { + wizard.start(ChangeOrganizationTierCloud); + trackEvent('click_organization_upgrade', { + from: 'button', + source: 'limit_reached_notification' + }); + } + } + ] + }); } else { readOnly.set(false); } From dd11d7924df4c5a1631dd4a1839e61c230411a51 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 11 Apr 2024 14:33:26 +0200 Subject: [PATCH 28/33] fix: header alert not showing on first load --- src/lib/stores/billing.ts | 2 +- src/routes/console/+layout.svelte | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index fcdb3ab83..81675b4f6 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -183,7 +183,7 @@ export function calculateTrialDay(org: Organization) { } export async function checkForUsageLimit(org: Organization) { - if (org.billingPlan !== BillingPlan.STARTER) { + if (org?.billingPlan !== BillingPlan.STARTER) { readOnly.set(false); return; } diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte index dd45948cc..ad4d7c0ab 100644 --- a/src/routes/console/+layout.svelte +++ b/src/routes/console/+layout.svelte @@ -274,6 +274,7 @@ await checkPaymentAuthorizationRequired(org); await checkForMandate(org); } + $activeHeaderAlert = headerAlert.get(); } }); From 5a0d8f57d2bae4f90cd10a84c8e8690210d299a1 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 12 Apr 2024 14:47:22 +0200 Subject: [PATCH 29/33] chore: bump version to 0.1.0 --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index a5c6c42b5..351b33296 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,8 @@ "name": "@appwrite/console", "dependencies": { "@appwrite.io/console": "^0.5.0", - "@appwrite.io/pink": "0.3.0", - "@appwrite.io/pink-icons": "0.3.0", + "@appwrite.io/pink": "0.10.0", + "@appwrite.io/pink-icons": "0.10.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", @@ -167,19 +167,19 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.3.0.tgz", - "integrity": "sha512-VTYCfcEGnqScwGta7ort/qoKN0Gnyq2h/ROYcp9meEFSCjYBWMgWZWbwSSXsL8vwwxnN9aTh1sO5mJX0zHAPVg==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.10.0.tgz", + "integrity": "sha512-/9YLPNQRgqUZ3UJJ/N+2XsCbPr1AJWvuc9jWw1dmgLObs1rklpkVPGH7Qhx08j/7GehDWeYmYWhPiN2jxJ3WZg==", "dependencies": { - "@appwrite.io/pink-icons": "0.3.0", + "@appwrite.io/pink-icons": "0.10.0", "normalize.css": "^8.0.1", "the-new-css-reset": "^1.11.2" } }, "node_modules/@appwrite.io/pink-icons": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.3.0.tgz", - "integrity": "sha512-Jus3jsWMidne02/mqXbRtLFsuiYQiB3fjZ2ip8auqwhvk65yzGtodPiTPA8Us1fD2vaRlNx/jER5MK0XmqXKxg==" + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.10.0.tgz", + "integrity": "sha512-sqrXAI2brrRGqn+klXMaT/rL+pvF9qegAS3vx3XqI4c6tpTBDEueUhq0B/ZoFyhx/PiBKGsrXPTTwiVH+18DSg==" }, "node_modules/@babel/code-frame": { "version": "7.23.5", diff --git a/package.json b/package.json index d3d09d56f..e89c79e28 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@appwrite.io/console": "^0.5.0", - "@appwrite.io/pink": "0.3.0", - "@appwrite.io/pink-icons": "0.3.0", + "@appwrite.io/pink": "0.10.0", + "@appwrite.io/pink-icons": "0.10.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", From 65ceb9f2d898e1979c51bc90200949f5215a6c29 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 12 Apr 2024 14:59:30 +0200 Subject: [PATCH 30/33] fix: hide modal when not shown --- src/lib/components/modalWrapper.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/components/modalWrapper.svelte b/src/lib/components/modalWrapper.svelte index 0e28bdf61..541355566 100644 --- a/src/lib/components/modalWrapper.svelte +++ b/src/lib/components/modalWrapper.svelte @@ -70,6 +70,7 @@ Date: Mon, 15 Apr 2024 14:19:23 +0200 Subject: [PATCH 31/33] fix: textareas --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 351b33296..2fc31fab0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,8 @@ "name": "@appwrite/console", "dependencies": { "@appwrite.io/console": "^0.5.0", - "@appwrite.io/pink": "0.10.0", - "@appwrite.io/pink-icons": "0.10.0", + "@appwrite.io/pink": "0.11.0", + "@appwrite.io/pink-icons": "0.11.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", @@ -167,19 +167,19 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.10.0.tgz", - "integrity": "sha512-/9YLPNQRgqUZ3UJJ/N+2XsCbPr1AJWvuc9jWw1dmgLObs1rklpkVPGH7Qhx08j/7GehDWeYmYWhPiN2jxJ3WZg==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.11.0.tgz", + "integrity": "sha512-0/ztJxeV6Cy1FnXy2ClLELzDnR4eRtGAhQ24napCg0VwOFevSIc0S7jcRrWVyA6WRuwex4eGiEn2JeYMTq70Xg==", "dependencies": { - "@appwrite.io/pink-icons": "0.10.0", + "@appwrite.io/pink-icons": "0.11.0", "normalize.css": "^8.0.1", "the-new-css-reset": "^1.11.2" } }, "node_modules/@appwrite.io/pink-icons": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.10.0.tgz", - "integrity": "sha512-sqrXAI2brrRGqn+klXMaT/rL+pvF9qegAS3vx3XqI4c6tpTBDEueUhq0B/ZoFyhx/PiBKGsrXPTTwiVH+18DSg==" + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.11.0.tgz", + "integrity": "sha512-FOvP87m4S17QRQPrLzsSlwrbIeJNJi5RliGUQYONIhmI0PiwE4Xm5LXFE+NqFYsR56w2X3jYdJIHdIdZlH3XjA==" }, "node_modules/@babel/code-frame": { "version": "7.23.5", diff --git a/package.json b/package.json index e89c79e28..863f04765 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@appwrite.io/console": "^0.5.0", - "@appwrite.io/pink": "0.10.0", - "@appwrite.io/pink-icons": "0.10.0", + "@appwrite.io/pink": "0.11.0", + "@appwrite.io/pink-icons": "0.11.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", From 4c5748903c36b356093bef74db3eb5c232e7ffc3 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 17 Apr 2024 11:59:28 +0200 Subject: [PATCH 32/33] fix: add option to pass final action directly to the wizard so it can be awaited --- src/lib/layout/wizard.svelte | 15 +++++++++++---- .../createProjectCloud.svelte | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index b55c4ff3c..e8e525572 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -24,6 +24,7 @@ export let steps: WizardStepsType; export let confirmExit = false; export let finalAction = 'Create'; + export let finalMethod: () => Promise = null; const dispatch = createEventDispatcher(); @@ -94,11 +95,17 @@ } } else { $wizard.nextDisabled = true; - trackEvent('wizard_finish'); - dispatch('finish'); - setTimeout(() => { + if (finalMethod) { + await finalMethod(); $wizard.nextDisabled = false; - }, 2000); + } else { + trackEvent('wizard_finish'); + dispatch('finish'); + + setTimeout(() => { + $wizard.nextDisabled = false; + }, 2000); + } } } else { if (steps.get($wizard.step + 1)?.disabled) { diff --git a/src/routes/console/organization-[organization]/createProjectCloud.svelte b/src/routes/console/organization-[organization]/createProjectCloud.svelte index 4c228c28e..953c70023 100644 --- a/src/routes/console/organization-[organization]/createProjectCloud.svelte +++ b/src/routes/console/organization-[organization]/createProjectCloud.svelte @@ -67,4 +67,4 @@ }); - + From becf053f33ccd6d864265bd02af944538d49fb83 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 17 Apr 2024 12:04:55 +0200 Subject: [PATCH 33/33] chore: add tracking --- src/lib/layout/wizard.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/layout/wizard.svelte b/src/lib/layout/wizard.svelte index e8e525572..145926af6 100644 --- a/src/lib/layout/wizard.svelte +++ b/src/lib/layout/wizard.svelte @@ -97,6 +97,7 @@ $wizard.nextDisabled = true; if (finalMethod) { await finalMethod(); + trackEvent('wizard_finish'); $wizard.nextDisabled = false; } else { trackEvent('wizard_finish');