Merge branch 'appwrite:main' into bug-7362-file-extension-validation

This commit is contained in:
Sourab Pramanik authored and GitHub committed 2024-04-09 20:05:52 +05:30
commit 8c25d57915
32 files changed
+734 -744

No files matched your search

+560 -618
View File
File diff suppressed because it is too large. Load diff
+1 -2
View File
@@ -18,7 +18,7 @@
"e2e": "playwright test tests/e2e"
},
"dependencies": {
"@appwrite.io/console": "^0.6.0",
"@appwrite.io/console": "^0.6.1",
"@appwrite.io/pink": "0.8.0",
"@appwrite.io/pink-icons": "0.8.0",
"@popperjs/core": "^2.11.8",
@@ -31,7 +31,6 @@
"deep-equal": "^2.2.2",
"dotenv": "^16.3.1",
"echarts": "^5.4.3",
"logrocket": "^5.0.1",
"nanoid": "^4.0.2",
"plausible-tracker": "^0.3.8",
"pretty-bytes": "^6.1.1",
+2 -1
View File
@@ -106,6 +106,7 @@
<svelte:window on:click={onBlur} on:keydown={onKeyDown} />
<div
class="u-min-width-0"
class:drop-wrapper={!noStyle}
class:u-cross-child-start={childStart}
class:u-width-full-line={wrapperFullWidth}
@@ -119,7 +120,7 @@
bind:this={tooltip}
class:u-width-full-line={fullWidth}
style:--arrow-size={`${arrowSize}px`}
style:z-index="10">
style:z-index="1">
<div
class="drop-arrow"
class:is-popover={isPopover}
+5 -1
View File
@@ -10,6 +10,10 @@
export { classes as class };
</script>
<svelte:element this={tag} class={`heading-level-${size} ${classes}`} class:u-trim-1={trimmed} {id}>
<svelte:element
this={tag}
class={`heading-level-${size} u-min-width-0 ${classes}`}
class:u-trim-1={trimmed}
{id}>
<slot />
</svelte:element>
+1
View File
@@ -279,6 +279,7 @@ export const paymentMissingMandate = writable<PaymentMethodData>(null);
export async function checkForMandate(org: Organization) {
const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId;
if (!paymentId) return;
const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId);
if (paymentMethod.mandateId === null && paymentMethod.country === 'in') {
headerAlert.add({
+10 -6
View File
@@ -51,7 +51,7 @@ export async function unmountPaymentElement() {
elements = null;
}
export async function submitStripeCard(name: string, urlRoute?: string) {
export async function submitStripeCard(name: string, organizationId?: string) {
try {
// If a payment method was created during initialization, use it, otherwise create a new one
if (!paymentMethod) {
@@ -62,16 +62,20 @@ export async function submitStripeCard(name: string, urlRoute?: string) {
// // Element needs to be submitted before confirming the setup intent
elements.submit();
const baseUrl = 'https://cloud.appwrite.io/console/';
const baseUrl = 'https://cloud.appwrite.io/console';
const accountUrl = `${baseUrl}/account/payments?clientSecret=${clientSecret}`;
const orgUrl = `${baseUrl}/organization-${organizationId}/billing?clientSecret=${clientSecret}`;
const returnUrl = new URL(organizationId ? orgUrl : accountUrl);
returnUrl.searchParams.append('clientSecret', clientSecret);
returnUrl.searchParams.append('paymentMethodId', paymentMethod.$id);
const { setupIntent, error } = await get(stripe).confirmSetup({
elements,
clientSecret,
confirmParams: {
return_url: `${baseUrl}${
urlRoute ??
`organization-${get(organization).$id}/billing?clientSecret=${clientSecret}`
}`,
return_url: returnUrl.toString(),
payment_method_data: {
billing_details: {
name
@@ -73,7 +73,7 @@
{#if hasInstallations}
{#await loadInstallations()}
<div class="u-flex u-gap-16">
<div class="u-width-full-line">
<ul class="u-width-full-line">
<InputSelect
disabled
id="installation"
@@ -86,7 +86,7 @@
}
]}
value={null} />
</div>
</ul>
<ul class="u-width-full-line">
<InputSearch placeholder="Search repositories" disabled />
</ul>
+2 -14
View File
@@ -3,17 +3,16 @@
import { afterNavigate, goto } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { isTrackingAllowed, trackPageView } from '$lib/actions/analytics';
import { trackPageView } from '$lib/actions/analytics';
import { Notifications, Progress } from '$lib/layout';
import { app } from '$lib/stores/app';
import { ENV, isCloud } from '$lib/system';
import * as Sentry from '@sentry/svelte';
import LogRocket from 'logrocket';
import { onMount } from 'svelte';
import Loading from './loading.svelte';
import { loading, requestedMigration } from './store';
import { parseIfString } from '$lib/helpers/object';
import Consent, { consent } from '$lib/components/consent.svelte';
import Consent from '$lib/components/consent.svelte';
import type { Models } from '@appwrite.io/console';
onMount(async () => {
@@ -31,17 +30,6 @@
integrations: [new Sentry.BrowserTracing()],
tracesSampleRate: 1.0
});
/**
* LogRocket
*/
if ($consent?.accepted?.analytics && isCloud && isTrackingAllowed()) {
LogRocket.init('rgthvf/appwrite', {
dom: {
inputSanitizer: true
}
});
}
}
/**
-6
View File
@@ -1,7 +1,6 @@
import '@appwrite.io/pink';
import '@appwrite.io/pink-icons';
import 'tippy.js/dist/tippy.css';
import LogRocket from 'logrocket';
import { sdk } from '$lib/stores/sdk';
import { redirect } from '@sveltejs/kit';
import { Dependencies } from '$lib/constants';
@@ -21,11 +20,6 @@ export const load: LayoutLoad = async ({ depends, url }) => {
try {
const account = await sdk.forConsole.account.get<{ organization?: string }>();
LogRocket.identify(account.$id, {
name: account.name,
email: account.email
});
return {
account,
organizations: await sdk.forConsole.teams.list()
+5 -3
View File
@@ -6,7 +6,9 @@
</script>
<Container>
<Heading size="1" tag="h3">{$page.error.status || 'Invalid Argument'}</Heading>
<Heading size="3" tag="h4">{$page.error.message}</Heading>
<Button href="/console">Back to the console</Button>
<div class="u-flex-vertical u-gap-16">
<Heading size="1" tag="h3">{$page.error.status || 'Invalid Argument'}</Heading>
<Heading size="4" tag="h4" trimmed={false}>{$page.error.message}</Heading>
<Button href="/console">Back to the console</Button>
</div>
</Container>
+7 -5
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { INTERVAL } from '$lib/constants';
import { BillingPlan, INTERVAL } from '$lib/constants';
import { Logs } from '$lib/layout';
import Footer from '$lib/layout/footer.svelte';
import Header from '$lib/layout/header.svelte';
@@ -258,12 +258,14 @@
organization.subscribe(async (org) => {
if (!org) return;
if (isCloud) {
calculateTrialDay(org);
await paymentExpired(org);
await checkForUsageLimit(org);
checkForMarkedForDeletion(org);
await checkPaymentAuthorizationRequired(org);
await checkForMandate(org);
if (org?.billingPlan !== BillingPlan.STARTER) {
calculateTrialDay(org);
await paymentExpired(org);
await checkPaymentAuthorizationRequired(org);
await checkForMandate(org);
}
}
});
@@ -3,8 +3,19 @@
import { Container } from '$lib/layout';
import PaymentMethods from './paymentMethods.svelte';
import BillingAddress from './billingAddress.svelte';
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { confirmPayment } from '$lib/stores/stripe';
let showPayment = false;
onMount(async () => {
if ($page.url.searchParams.has('clientSecret')) {
const clientSecret = $page.url.searchParams.get('clientSecret');
const paymentMethodId = $page.url.searchParams.get('paymentMethodId');
await confirmPayment('', clientSecret, paymentMethodId);
}
});
</script>
<Container>
@@ -6,6 +6,7 @@
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
import { page } from '$app/stores';
export let show = false;
@@ -20,7 +21,7 @@
async function handleSubmit() {
try {
const card = await submitStripeCard(name);
const card = await submitStripeCard(name, $page?.params?.organization ?? null);
invalidate(Dependencies.PAYMENT_METHODS);
dispatch('submit', card);
show = false;
@@ -33,7 +33,7 @@
async function handleSubmit() {
try {
if (!selectedPaymentMethodId) {
const method = await submitStripeCard(name);
const method = await submitStripeCard(name, $organization.$id);
selectedPaymentMethodId = method.$id;
}
isBackup
@@ -39,7 +39,7 @@
try {
if (paymentMethodId === null) {
try {
const method = await submitStripeCard(name);
const method = await submitStripeCard(name, $organization.$id);
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
if (card?.last4) {
paymentMethodId = card.$id;
@@ -9,6 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { PaymentBoxes } from '$lib/components/billing';
import { addCreditWizardStore } from '../store';
import { organization } from '$lib/stores/organization';
let methods: PaymentList;
let name: string;
@@ -21,7 +22,7 @@
async function handleSubmit() {
try {
const method = await submitStripeCard(name);
const method = await submitStripeCard(name, $organization.$id);
$addCreditWizardStore.paymentMethodId = method.$id;
invalidate(Dependencies.PAYMENT_METHODS);
} catch (e) {
@@ -2,7 +2,15 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { tooltip } from '$lib/actions/tooltip';
import { AvatarGroup, DropList, DropListItem, DropListLink, Tab, Tabs } from '$lib/components';
import {
AvatarGroup,
DropList,
DropListItem,
DropListLink,
Heading,
Tab,
Tabs
} from '$lib/components';
import { BillingPlan } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
@@ -41,6 +49,13 @@
$: avatars = $members.memberships?.map((m) => m.userName) ?? [];
$: organizationId = $page.params.organization;
$: path = `/console/organization-${organizationId}`;
$: permanentTabSettings = [
{
href: `${path}/settings`,
event: 'settings',
title: 'Settings'
}
];
$: permanentTabs = [
{
href: path,
@@ -55,13 +70,7 @@
hasChildren: true
}
];
$: permanentTabSettings = [
{
href: `${path}/settings`,
event: 'settings',
title: 'Settings'
}
];
$: tabs = isCloud
? [
...permanentTabs,
@@ -84,13 +93,15 @@
{#if $organization?.$id}
<Cover>
<svelte:fragment slot="header">
<DropList bind:show={showDropdown} placement="bottom-start" noArrow scrollable>
<DropList bind:show={showDropdown} placement="bottom-end" noArrow scrollable>
<button
class="button is-text u-padding-inline-0"
class="button is-text u-padding-inline-0 u-max-width-100-percent"
on:click={() => (showDropdown = !showDropdown)}>
<h1 class="heading-level-4 u-flex u-cross-center u-gap-8">
<span class="u-flex u-cross-center u-gap-8">
{$organization.name}
<Heading tag="h1" size="4" class="u-flex u-cross-center u-gap-8">
<span class="u-flex u-cross-center u-gap-8 u-min-width-0">
<span class="u-trim">
{$organization.name}
</span>
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER}
<Pill>FREE</Pill>
{/if}
@@ -109,7 +120,7 @@
<span
class={`icon-cheveron-${showDropdown ? 'up' : 'down'}`}
aria-hidden="true" />
</h1>
</Heading>
</button>
<svelte:fragment slot="list">
{#each $organizationList.teams as org}
@@ -64,10 +64,12 @@
deleted.
</p>
<p class="text"><b>This action is irreversible.</b></p>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete relationship between <b data-private>{selectedAttribute.key}</b> to
<b data-private>{selectedAttribute.twoWayKey}</b>
</InputChoice>
<ul>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete relationship between <b data-private>{selectedAttribute.key}</b> to
<b data-private>{selectedAttribute.twoWayKey}</b>
</InputChoice>
</ul>
</div>
{/if}
@@ -107,9 +107,11 @@
<div class="u-flex u-flex-vertical u-gap-16">
<Alert>To change the selection edit the relationship settings.</Alert>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete document from <span data-private>{$collection.name}</span>
</InputChoice>
<ul>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete document from <span data-private>{$collection.name}</span>
</InputChoice>
</ul>
</div>
{/if}
@@ -301,9 +301,11 @@
<div class="u-flex u-flex-vertical u-gap-16">
<Alert>To change the selection edit the relationship settings.</Alert>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete document from <span data-private>{$collection.name}</span>
</InputChoice>
<ul>
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
Delete document from <span data-private>{$collection.name}</span>
</InputChoice>
</ul>
</div>
{:else}
<p class="u-bold">This action is irreversible.</p>
@@ -148,6 +148,8 @@
}
]
});
$wizard.finalAction = create;
</script>
<Wizard title="Create message" steps={stepsComponents} on:finish={create} finalAction="Send" />
<Wizard title="Create message" steps={stepsComponents} finalAction="Send" />
@@ -33,7 +33,7 @@
response = await sdk.forProject.messaging.createMsg91Provider(
providerId,
$providerParams[$provider].name,
$providerParams[$provider].from,
$providerParams[$provider].templateId,
$providerParams[$provider].senderId,
$providerParams[$provider].authKey,
$providerParams[$provider].enabled
@@ -38,7 +38,7 @@
providerId: $providerData.$id,
name: $providerData.name,
enabled: $providerData.enabled,
from: $providerData.options['from'],
templateId: $providerData.credentials['templateId'],
senderId: $providerData.credentials['senderId'],
authKey: $providerData.credentials['authKey']
};
@@ -142,7 +142,8 @@
authKey: $providerData.credentials['authKey'],
authKeyId: $providerData.credentials['authKeyId'],
teamId: $providerData.credentials['teamId'],
bundleId: $providerData.credentials['bundleId']
bundleId: $providerData.credentials['bundleId'],
sandbox: $providerData.options['sandbox']
};
break;
}
@@ -26,6 +26,7 @@
let updated = false;
let newMemberModal = false;
let message = '';
let ready = false;
const { displayName } = getProviderDisplayNameAndIcon(provider);
@@ -61,6 +62,7 @@
originalfiles[input.name] = dataTransfer.files;
}
}
ready = true;
});
async function update() {
@@ -90,9 +92,9 @@
providerId,
undefined,
undefined,
formValues['templateId'],
formValues['senderId'],
formValues['authKey'],
formValues['from']
formValues['authKey']
);
break;
case Providers.Telesign:
@@ -184,7 +186,8 @@
formValues['authKey'],
formValues['authKeyId'],
formValues['teamId'],
formValues['bundleId']
formValues['bundleId'],
formValues['sandbox']
);
break;
}
@@ -228,7 +231,10 @@
provider settings.
</p>
<svelte:fragment slot="aside">
<SettingsFormList bind:files {inputs} bind:params={formValues} />
<!-- Must wait until ready or else the files input won't be set properly -->
{#if ready}
<SettingsFormList bind:files {inputs} bind:params={formValues} />
{/if}
</svelte:fragment>
<svelte:fragment slot="actions">
@@ -1,7 +1,7 @@
import type { Column } from '$lib/helpers/types';
import { MessagingProviderType, SmtpEncryption } from '@appwrite.io/console';
import { writable } from 'svelte/store';
import { Providers } from '../provider.svelte';
import { MessagingProviderType, SmtpEncryption } from '@appwrite.io/console';
export const columns = writable<Column[]>([
{ id: '$id', title: 'Provider ID', type: 'string', show: true },
@@ -304,7 +304,7 @@ export const providers: ProvidersMap = {
[Providers.SMTP]: {
classIcon: 'mail',
title: 'SMTP',
description: 'Generic SMTP server.',
description: 'Generic SMTP server',
configure: [
{
label: 'Server host',
@@ -465,14 +465,18 @@ export const providers: ProvidersMap = {
placeholder: 'Enter sender ID',
popover: [
'<b>How to create a Sender ID?</b>',
'Head to <b><a class="link" href="https://control.msg91.com/signin/" target="_blank" rel="noopener noreferrer">MSG91</a> dashboard -> SMS -> Sender ID -> Create sender ID.</b>'
'Head to <b><a class="link" href="https://control.msg91.com/signin/" target="_blank" rel="noopener noreferrer">MSG91</a> dashboard -> SMS -> Sender ID -> Create Sender ID.</b>'
]
},
{
label: 'Sender number',
name: 'from',
type: 'phone',
placeholder: 'Enter phone'
label: 'Template ID',
name: 'templateId',
type: 'text',
placeholder: 'Enter template ID',
popover: [
'<b>How to create a Template ID?</b>',
'Head to <b><a class="link" href="https://control.msg91.com/signin/" target="_blank" rel="noopener noreferrer">MSG91</a> dashboard -> SMS -> Templates -> Create Template.</b>'
]
}
]
},
@@ -590,7 +594,7 @@ export type TwilioProviderParams = ProviderParams & {
};
export type Msg91ProviderParams = ProviderParams & {
from: string;
templateId: string;
senderId: string;
authKey: string;
};
@@ -29,7 +29,7 @@
providerId: id,
name: name,
enabled: true,
from: '',
templateId: '',
senderId: '',
authKey: ''
};
@@ -5,6 +5,9 @@
import { MessagingProviderType } from '@appwrite.io/console';
import { messageParams, providerType } from './store';
import { isSameDay, toLocaleDateISO, toLocaleTimeISO } from '$lib/helpers/date';
import { wizard } from '$lib/stores/wizard';
import { Modal } from '$lib/components';
import { topicsById } from '../store';
let when: 'now' | 'later' = 'now';
let now = new Date();
@@ -13,6 +16,21 @@
let time: string;
let dateTime: Date;
let docsUrl = `https://appwrite.io/docs/products/messaging`;
let showConfimation = false;
let totalTargets = $messageParams[$providerType].targets?.length ?? 0;
const topics = $messageParams[$providerType].topics;
for (const topic of topics) {
if ($providerType == MessagingProviderType.Push) {
totalTargets += $topicsById[topic].pushTotal;
} else if ($providerType == MessagingProviderType.Email) {
totalTargets += $topicsById[topic].emailTotal;
} else if ($providerType == MessagingProviderType.Sms) {
totalTargets += $topicsById[topic].smsTotal;
}
}
switch ($providerType) {
case MessagingProviderType.Email:
@@ -40,6 +58,18 @@
timeZoneName: 'longGeneric'
};
async function askForConfirmation() {
$wizard.interceptorNotificationEnabled = false;
showConfimation = true;
throw 'Show confirmation';
}
async function submit() {
$wizard.interceptorNotificationEnabled = true;
await $wizard.finalAction();
showConfimation = false;
}
$: if (when === 'now') {
date = time = '';
}
@@ -56,7 +86,7 @@
}
</script>
<WizardStep>
<WizardStep beforeSubmit={askForConfirmation}>
<svelte:fragment slot="title">Schedule</svelte:fragment>
<svelte:fragment slot="subtitle"
>Schedule the time you want to deliver this message. Learn more in our <Button
@@ -97,16 +127,14 @@
</Helper>
</WizardStep>
<!-- <Modal
title="Send message"
bind:show={showDelete}
onSubmit={deleteAccount}
icon="exclamation"
state="warning"
headerDivider={false}>
<p>Are you sure you want to delete your account?</p>
<Modal title="Send message" bind:show={showConfimation} headerDivider={false} onSubmit={submit}>
<p>
You are about to send a message to an estimated <span class="u-bold">{totalTargets}</span> recipients.
Would you like to proceed?
</p>
<p class="u-bold">This action is irreversible.</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
<Button secondary submit>Delete</Button>
<Button text on:click={() => (showConfimation = false)}>Cancel</Button>
<Button secondary submit>Send</Button>
</svelte:fragment>
</Modal> -->
</Modal>
@@ -4,7 +4,6 @@
import { wizard } from '$lib/stores/wizard';
import { createPlatform } from './wizard/store';
import { Dependencies } from '$lib/constants';
import { onboarding } from '../../store';
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
import Step1 from './wizard/android/step1.svelte';
import Step2 from './wizard/android/step2.svelte';
@@ -12,10 +11,7 @@
import Step4 from './wizard/step4.svelte';
async function onFinish() {
await Promise.all([
$onboarding && invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
createPlatform.reset();
wizard.hide();
}
@@ -9,13 +9,10 @@
import Step3 from './wizard/apple/step3.svelte';
import Step4 from './wizard/step4.svelte';
import { Dependencies } from '$lib/constants';
import { onboarding } from '../../store';
async function onFinish() {
await Promise.all([
$onboarding && invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
createPlatform.reset();
wizard.hide();
}
@@ -9,13 +9,10 @@
import Step3 from './wizard/flutter/step3.svelte';
import Step4 from './wizard/step4.svelte';
import { Dependencies } from '$lib/constants';
import { onboarding } from '../../store';
async function onFinish() {
await Promise.all([
$onboarding && invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
createPlatform.reset();
wizard.hide();
}
@@ -9,13 +9,10 @@
import Step3 from './wizard/web/step3.svelte';
import Step4 from './wizard/step4.svelte';
import { Dependencies } from '$lib/constants';
import { onboarding } from '../../store';
async function onFinish() {
await Promise.all([
$onboarding && invalidate(Dependencies.PROJECT),
invalidate(Dependencies.PLATFORMS)
]);
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
createPlatform.reset();
wizard.hide();
}
@@ -10,9 +10,9 @@
import { Dependencies } from '$lib/constants';
import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
import { organization } from '$lib/stores/organization';
import { symmetricDifference } from '$lib/helpers/array';
import { showUsageRatesModal } from '$lib/stores/billing';
import { PaymentBoxes } from '$lib/components/billing';
import { page } from '$app/stores';
let methods: PaymentList;
let filteredMethods: PaymentMethodData[];
@@ -48,15 +48,10 @@
}
} else {
try {
await submitStripeCard(name);
const latestMethods = await sdk.forConsole.billing.listPaymentMethods();
const paymentMethod = symmetricDifference(
methods.paymentMethods,
latestMethods.paymentMethods
)[0] as PaymentMethodData;
const card = await sdk.forConsole.billing.getPaymentMethod(paymentMethod.$id);
const method = await submitStripeCard(name, $page?.params?.organization ?? null);
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
if (card?.last4) {
$changeOrganizationTier.paymentMethodId = paymentMethod.$id;
$changeOrganizationTier.paymentMethodId = method.$id;
} else {
throw new Error(
'The payment method you selected is not valid. Please select a different one.'