Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { Dependencies } from '$lib/constants';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { ID } from '@appwrite.io/console';
import { ID, Region } from '@appwrite.io/console';
import { createProject } from './wizard/store';
import { wizard } from '$lib/stores/wizard';

Expand All @@ -22,11 +22,12 @@

async function create() {
try {
// TODO: fix typing once SDK is updated
const project = await sdk.forConsole.projects.create(
$createProject?.id ?? ID.unique(),
$createProject.name,
teamId,
$createProject.region
$createProject.region as Region
);
trackEvent(Submit.ProjectCreate, {
customId: !!$createProject?.id,
Expand Down
15 changes: 13 additions & 2 deletions src/routes/console/project-[project]/auth/templates/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<script context="module" lang="ts">
export async function loadEmailTemplate(projectId: string, type: string, locale: string) {
try {
return await sdk.forConsole.projects.getEmailTemplate(projectId, type, locale);
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
return await sdk.forConsole.projects.getEmailTemplate(
projectId,
type as TemplateType,
locale as TemplateLocale
);
} catch (e) {
addNotification({
type: 'error',
Expand All @@ -11,7 +16,12 @@
}
export async function loadSmsTemplate(projectId: string, type: string, locale: string) {
try {
return await sdk.forConsole.projects.getSmsTemplate(projectId, type, locale);
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
return await sdk.forConsole.projects.getSmsTemplate(
projectId,
type as TemplateType,
locale as TemplateLocale
);
} catch (e) {
addNotification({
type: 'error',
Expand Down Expand Up @@ -44,6 +54,7 @@
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { wizard } from '$lib/stores/wizard';
import { BillingPlan } from '$lib/constants';
import type { TemplateLocale, TemplateType } from '@appwrite.io/console';

const projectId = $page.params.project;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import deepEqual from 'deep-equal';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Box } from '$lib/components';
import { TemplateLocale, TemplateType } from '@appwrite.io/console';
import { isValueOfStringEnum } from '$lib/helpers/types';
import type { TemplateLocale, TemplateType } from '@appwrite.io/console';

export let loading = false;
let openResetModal = false;
Expand All @@ -32,12 +31,13 @@
return;
}

if (!isValueOfStringEnum(TemplateType, $emailTemplate.type)) {
throw new Error(`Invalid template type: ${$emailTemplate.type}`);
}
if (!isValueOfStringEnum(TemplateLocale, $emailTemplate.locale)) {
throw new Error(`Invalid template locale: ${$emailTemplate.locale}`);
}
// TODO: uncomment after SDK is updated
// if (!isValueOfStringEnum(TemplateType, $emailTemplate.type)) {
// throw new Error(`Invalid template type: ${$emailTemplate.type}`);
// }
// if (!isValueOfStringEnum(TemplateLocale, $emailTemplate.locale)) {
// throw new Error(`Invalid template locale: ${$emailTemplate.locale}`);
// }
try {
switch ($emailTemplate.type) {
case 'invitation':
Expand All @@ -53,10 +53,11 @@
eventType = Submit.EmailUpdateVerificationTemplate;
break;
}
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
await sdk.forConsole.projects.updateEmailTemplate(
$project.$id,
$emailTemplate.type ? $emailTemplate.type : undefined,
$emailTemplate.locale ? $emailTemplate.locale : undefined,
$emailTemplate.type ? ($emailTemplate.type as TemplateType) : undefined,
$emailTemplate.locale ? ($emailTemplate.locale as TemplateLocale) : undefined,
$emailTemplate.subject ? $emailTemplate.subject : undefined,
$emailTemplate.message ? $emailTemplate.message : undefined,
$emailTemplate.senderName ? $emailTemplate.senderName : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { TemplateLocale, TemplateType } from '@appwrite.io/console';
import { project } from '../../store';
import { loadEmailTemplate } from './+page.svelte';
import { baseEmailTemplate, emailTemplate } from './store';
Expand All @@ -14,10 +15,11 @@

async function reset() {
try {
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
await sdk.forConsole.projects.deleteEmailTemplate(
$project.$id,
$emailTemplate.type,
$emailTemplate.locale
$emailTemplate.type as TemplateType,
$emailTemplate.locale as TemplateLocale
);
$emailTemplate = await loadEmailTemplate(
$project.$id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { sdk } from '$lib/stores/sdk';
import type { TemplateLocale, TemplateType } from '@appwrite.io/console';
import { project } from '../../store';
import { loadSmsTemplate } from './+page.svelte';
import { baseSmsTemplate, smsTemplate } from './store';
Expand All @@ -13,10 +14,11 @@

async function reset() {
try {
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
await sdk.forConsole.projects.deleteSmsTemplate(
$project.$id,
$smsTemplate.type,
$smsTemplate.locale
$smsTemplate.type as TemplateType,
$smsTemplate.locale as TemplateLocale
);

$smsTemplate = await loadSmsTemplate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import deepEqual from 'deep-equal';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Box } from '$lib/components';
import type { TemplateLocale, TemplateType } from '@appwrite.io/console';

export let loading = false;
const projectId = $page.params.project;
Expand Down Expand Up @@ -35,10 +36,11 @@
eventType = Submit.SmsUpdateVerificationTemplate;
break;
}
// TODO: fix TemplateType and TemplateLocale typing once SDK is updated
await sdk.forConsole.projects.updateSmsTemplate(
projectId,
$smsTemplate.type,
$smsTemplate.locale,
$smsTemplate.type as TemplateType,
$smsTemplate.locale as TemplateLocale,
$smsTemplate.message
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@
$providerParams[$wizardProvider] = {
providerId: $provider.$id,
name: $provider.name,
enabled: $provider.enabled,
enabled: $provider.enabled
};
if ('serviceAccountJSON' in $provider.credentials) {
const serviceAccountJSON = $provider.credentials['serviceAccountJSON'];
if (typeof serviceAccountJSON === 'string') {
$providerParams[$wizardProvider].serviceAccountJSON = serviceAccountJSON;
} else if (serviceAccountJSON instanceof Object) {
$providerParams[$wizardProvider].serviceAccountJSON = JSON.stringify(serviceAccountJSON);
$providerParams[$wizardProvider].serviceAccountJSON =
JSON.stringify(serviceAccountJSON);
}
}
break;
Expand Down
4 changes: 3 additions & 1 deletion src/routes/mfa/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
async function verify() {
try {
disabled = true;
const challenge = await sdk.forConsole.account.createChallenge(AuthenticatorProvider.Totp);
const challenge = await sdk.forConsole.account.createChallenge(
AuthenticatorProvider.Totp
);
await sdk.forConsole.account.updateChallenge(challenge.$id, code);
await invalidate(Dependencies.ACCOUNT);
trackEvent(Submit.AccountCreate);
Expand Down