refactor(WIP): enable strict null checks

This commit is contained in:
tglide committed 2022-12-16 20:00:28 +00:00
1 parent f29d619506
commit 2991a80807
116 files changed
+317 -236

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
import Base from './base.svelte';
export let series: BarSeriesOption[];
export let options: EChartsOption = null;
export let options: EChartsOption | null = null;
</script>
<Base
+1 -1
View File
@@ -5,7 +5,7 @@
import Base from './base.svelte';
export let series: LineSeriesOption[];
export let options: EChartsOption = null;
export let options: EChartsOption | null = null;
</script>
<Base
+1 -1
View File
@@ -5,7 +5,7 @@
export let isDashed = false;
export let isButton = false;
export let danger = false;
export let href: string = null;
export let href: string | null = null;
function getElement(): string {
switch (true) {
+1 -1
View File
@@ -5,7 +5,7 @@
export let offset = 0;
export let limit = $cardLimit;
export let total = 0;
export let event: string = null;
export let event: string | null = null;
</script>
<ul
+2 -2
View File
@@ -13,8 +13,8 @@
import { afterUpdate } from 'svelte';
import { Copy } from '.';
export let label: string = null;
export let labelIcon: 'code' | 'android' | 'flutter' | 'apple' = null;
export let label: string | null = null;
export let labelIcon: 'code' | 'android' | 'flutter' | 'apple' | null = null;
export let code: string;
export let language: 'js' | 'html' | 'dart' | 'kotlin' | 'json' | 'sh' | 'yml' | 'swift';
export let withLineNumbers = false;
+1 -1
View File
@@ -5,7 +5,7 @@
import { addNotification } from '$lib/stores/notifications';
export let value: string;
export let event: string = null;
export let event: string | null = null;
let content = 'Click to copy';
+1 -1
View File
@@ -4,7 +4,7 @@
import { addNotification } from '$lib/stores/notifications';
export let value: string;
export let label: string = null;
export let label: string | null = null;
export let showLabel = false;
let content = 'Click to copy';
+1 -1
View File
@@ -5,7 +5,7 @@
export let show = false;
export let name: string;
export let id: string;
export let id: string | null;
$: if (!show) {
id = null;
+1 -1
View File
@@ -7,7 +7,7 @@
export let scrollable = false;
export let childStart = false;
export let noArrow = false;
export let width: string = null;
export let width: string | null = null;
</script>
<Drop bind:show {placement} {childStart} {noArrow}>
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
export let disabled = false;
export let icon: string = null;
export let icon: string | null = null;
</script>
<li class="drop-list-item">
+1 -1
View File
@@ -2,7 +2,7 @@
import { clickOnEnter } from '$lib/helpers/a11y';
export let href: string;
export let icon: string = null;
export let icon: string | null = null;
export let disabled = false;
</script>
+2 -2
View File
@@ -7,8 +7,8 @@
import { trackEvent } from '$lib/actions/analytics';
export let single = false;
export let target: string = null;
export let href: string = null;
export let target: string | null = null;
export let href: string | null = null;
function track() {
if (target) {
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { clickOnEnter } from '$lib/helpers/a11y';
export let value: number = null;
export let value: number | null = null;
</script>
<fieldset class="u-margin-block-start-8">
+6 -6
View File
@@ -23,12 +23,12 @@
attributes?: string[];
};
let selectedService: Service = null;
let selectedResource: Resource = null;
let selectedAction: Action = null;
let selectedAttribute: string = null;
let helper: string = null;
let inputData: string = null;
let selectedService: Service | null = null;
let selectedResource: Resource | null = null;
let selectedAction: Action | null = null;
let selectedAttribute: string | null = null;
let helper: string | null = null;
let inputData: string | null = null;
let showInput = false;
const dispatch = createEventDispatcher();
+1 -1
View File
@@ -13,7 +13,7 @@
export let show = false;
let value: number = null;
let value: number | null = null;
let message: string;
let email: string;
let name: string;
+1 -1
View File
@@ -2,7 +2,7 @@
export let tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
export let size: '1' | '2' | '3' | '4' | '5' | '6' | '7';
export let trimmed = true;
export let id: string = null;
export let id: string | null = null;
</script>
<svelte:element this={tag} class={`heading-level-${size}`} class:u-trim-1={trimmed} {id}>
+2 -2
View File
@@ -4,9 +4,9 @@
import { trackEvent } from '$lib/actions/analytics';
export let show = false;
export let size: 'small' | 'big' = null;
export let size: 'small' | 'big' | null = null;
export let warning = false;
export let error: string = null;
export let error: string | undefined | null = null;
export let closable = true;
let dialog: HTMLDialogElement;
+2 -2
View File
@@ -2,8 +2,8 @@
import { trackEvent } from '$lib/actions/analytics';
export let selected = false;
export let href: string = null;
export let event: string = null;
export let href: string | null = null;
export let event: string | null = null;
function track() {
if (!event) return;
+3 -3
View File
@@ -8,11 +8,11 @@
export let disabled = false;
export let round = false;
export let external = false;
export let href: string = null;
export let href: string | null = null;
export let fullWidth = false;
export let ariaLabel: string = null;
export let ariaLabel: string | null = null;
export let noMargin = false;
export let event: string = null;
export let event: string | null = null;
function track() {
if (!event) {
+3 -3
View File
@@ -5,14 +5,14 @@
export let label: string;
export let showLabel = true;
export let id: string;
export let value: string = null;
export let value: string | null = null;
export let placeholder = '* * * * *';
export let required = false;
export let disabled = false;
export let readonly = false;
export let autofocus = false;
export let maxlength: number = null;
export let minlength: number = null;
export let maxlength: number | null = null;
export let minlength: number | null = null;
export let step: number | 'any' = 1;
let element: HTMLInputElement;
+1 -1
View File
@@ -12,7 +12,7 @@
export let readonly = false;
export let autofocus = false;
export let autocomplete = false;
export let maxlength: number = null;
export let maxlength: number | null = null;
// https://www.geeksforgeeks.org/how-to-validate-a-domain-name-using-regular-expression/
const pattern = String.raw`^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$`;
+1 -1
View File
@@ -2,7 +2,7 @@
import { Trim } from '$lib/components';
import { Button } from '.';
export let label: string = null;
export let label: string | null = null;
export let files: FileList;
export let list = new DataTransfer();
export let allowedFileExtensions: string[] = [];
+3 -3
View File
@@ -5,14 +5,14 @@
export let label: string;
export let showLabel = true;
export let id: string;
export let value: number = null;
export let value: number | null = null;
export let placeholder = '';
export let required = false;
export let disabled = false;
export let readonly = false;
export let autofocus = false;
export let min: number = null;
export let max: number = null;
export let min: number | null = null;
export let max: number | null = null;
export let step: number | 'any' = 1;
let element: HTMLInputElement;
+3 -3
View File
@@ -5,7 +5,7 @@
export let id: string;
export let label: string;
export let showLabel = true;
export let value = '';
export let value: string | null = '';
export let placeholder = '';
export let required = false;
export let disabled = false;
@@ -14,10 +14,10 @@
export let autocomplete = false;
export let showPasswordButton = false;
export let minlength = 8;
export let maxlength: number = null;
export let maxlength: number | null = null;
let element: HTMLInputElement;
let error: string;
let error: string | null;
let showInPlainText = false;
onMount(() => {
+1 -1
View File
@@ -12,7 +12,7 @@
export let readonly = false;
export let autofocus = false;
export let autocomplete = false;
export let maxlength: number = null;
export let maxlength: number | null = null;
const pattern = String.raw`^\+?[1-9]\d{1,14}$`;
+2 -2
View File
@@ -3,12 +3,12 @@
export let label: string;
export let id: string;
export let value = false;
export let value: boolean | null = false;
export let required = false;
export let disabled = false;
let element: HTMLInputElement;
let error: string;
let error: string | null = null;
const handleInvalid = (event: Event) => {
event.preventDefault();
+5 -5
View File
@@ -5,19 +5,19 @@
export let label: string;
export let showLabel = true;
export let id: string;
export let value = '';
export let id: string | null;
export let value: string | null = '';
export let placeholder = '';
export let required = false;
export let disabled = false;
export let readonly = false;
export let autofocus = false;
export let autocomplete = false;
export let maxlength: number = null;
export let tooltip: string = null;
export let maxlength: number | null = null;
export let tooltip: string | null = null;
let element: HTMLInputElement;
let error: string;
let error: string | null;
onMount(() => {
if (element && autofocus) {
+1 -1
View File
@@ -11,7 +11,7 @@
export let disabled = false;
export let readonly = false;
export let autofocus = false;
export let maxlength: number = null;
export let maxlength: number | null = null;
let element: HTMLTextAreaElement;
let error: string;
+1 -1
View File
@@ -12,7 +12,7 @@
export let readonly = false;
export let autofocus = false;
export let autocomplete = false;
export let maxlength: number = null;
export let maxlength: number | null = null;
let element: HTMLInputElement;
let error: string;
+1 -1
View File
@@ -8,7 +8,7 @@
export let button = false;
export let submit = false;
export let external = false;
export let href: string = null;
export let href: string | null = null;
export let trim = false;
let element: HTMLButtonElement;
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
export let title = '';
export let onlyDesktop = false;
export let width: number = null;
export let width: number | null = null;
export let showOverflow = false;
</script>
+1 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
export let width: number = null;
export let width: number | null = null;
</script>
<div
+22
View File
@@ -0,0 +1,22 @@
export function isString(value: unknown): value is string {
return typeof value === 'string';
}
export function isBoolean(value: unknown): value is boolean {
return typeof value === 'boolean';
}
export function isNumber(value: unknown): value is number {
return typeof value === 'number';
}
export function isTypeArray<T>(
values: unknown,
checker: (value: unknown) => value is T
): values is T[] {
return Array.isArray(values) && values.every(checker);
}
export function isStringArray(values: unknown): values is string[] {
return isTypeArray(values, isString);
}
+1 -1
View File
@@ -1,6 +1,6 @@
<script lang="ts">
export let overlapCover = false;
export let size: 'small' | 'medium' | 'large' | 'xl' = null;
export let size: 'small' | 'medium' | 'large' | 'xl' | null = null;
$: style = size
? `--p-container-max-size: var(--container-max-size, var(--container-size-${size}))`
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
export let adjustContentToCover = false;
export let size: 'small' | 'medium' | 'large' | 'xl' = null;
export let size: 'small' | 'medium' | 'large' | 'xl' | null = null;
$: style = size
? `--p-container-max-size: var(--container-max-size, var(--container-size-${size}))`
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts">
import { Heading } from '$lib/components';
export let href: string = null;
export let href: string | null = null;
</script>
<Heading size="4" tag="h1" trimmed={false}>
+1 -1
View File
@@ -35,7 +35,7 @@
export let readMetadata: MetricMetadata;
export let updatedMetadata: MetricMetadata;
export let deletedMetadata: MetricMetadata;
export let path: string = null;
export let path: string | null = null;
</script>
<Container>
+1 -1
View File
@@ -5,7 +5,7 @@
/**
* Pass callback that is run before the Form submit, can be canceled with throwing an exception.
*/
export let beforeSubmit: () => Promise<void> = null;
export let beforeSubmit: () => Promise<void> | null = null;
if (beforeSubmit) {
wizard.setInterceptor(beforeSubmit);
+2 -2
View File
@@ -1,7 +1,7 @@
<script>
<script lang="ts">
import { Tabs, Tab } from '../components';
export let tabs = [];
export let tabs: Array<{ href: string; title: string }> = [];
</script>
<Tabs>
+1 -1
View File
@@ -2,7 +2,7 @@
import InputText from '$lib/elements/forms/inputText.svelte';
import WizardStep from '$lib/layout/wizardStep.svelte';
let value: string = null;
let value: string | null = null;
async function beforeSubmit() {
if (value === 'fail') {
+5 -1
View File
@@ -7,8 +7,12 @@ export type Service = {
value: boolean | null;
};
type ServicesObj = {
list: Array<Service>;
};
function createServices() {
const { subscribe, set } = writable({
const { subscribe, set } = writable<ServicesObj>({
list: [
{
label: 'Account',
+1 -1
View File
@@ -12,7 +12,7 @@
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
let name: string = null,
let name: string | null = null,
email: string = null,
emailPassword: string = null,
newPassword: string = null,
@@ -12,11 +12,11 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let keyID: string = null;
let teamID: string = null;
let p8: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let keyID: string | null = null;
let teamID: string | null = null;
let p8: string | null = null;
onMount(() => {
appId ??= provider.appId;
@@ -12,10 +12,10 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let clientSecret: string = null;
let auth0Domain: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let clientSecret: string | null = null;
let auth0Domain: string | null = null;
let error: string;
onMount(() => {
@@ -12,10 +12,10 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let clientSecret: string = null;
let authentikDomain: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let clientSecret: string | null = null;
let authentikDomain: string | null = null;
let error: string;
onMount(() => {
@@ -12,10 +12,10 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let clientSecret: string = null;
let endpoint: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let clientSecret: string | null = null;
let endpoint: string | null = null;
let error: string;
onMount(() => {
@@ -14,9 +14,9 @@
const projectId = $page.params.project;
let enabled: boolean = null;
let appId: string = null;
let secret: string = null;
let enabled: boolean | null = null;
let appId: string | null = null;
let secret: string | null = null;
onMount(() => {
enabled ??= provider.enabled;
@@ -12,10 +12,10 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let clientSecret: string = null;
let tenantID: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let clientSecret: string | null = null;
let tenantID: string | null = null;
let error: string;
onMount(() => {
@@ -12,11 +12,11 @@
export let provider: Provider;
let appId: string = null;
let enabled: boolean = null;
let clientSecret: string = null;
let oktaDomain: string = null;
let authorizationServerId: string = null;
let appId: string | null = null;
let enabled: boolean | null = null;
let clientSecret: string | null = null;
let oktaDomain: string | null = null;
let authorizationServerId: string | null = null;
onMount(() => {
appId ??= provider.appId;
@@ -14,7 +14,7 @@
import { trackEvent } from '$lib/actions/analytics';
let showDelete = false;
let teamName: string = null;
let teamName: string | null = null;
onMount(async () => {
teamName ??= $team.name;
@@ -9,7 +9,7 @@
import { onMount } from 'svelte';
import { user } from './store';
let userEmail: string = null;
let userEmail: string | null = null;
onMount(async () => {
userEmail ??= $user.email;
});
@@ -9,7 +9,7 @@
import { onMount } from 'svelte';
import { user } from './store';
let userName: string = null;
let userName: string | null = null;
onMount(async () => {
userName ??= $user.name;
});
@@ -6,7 +6,7 @@
import { sdkForProject } from '$lib/stores/sdk';
import { user } from './store';
let newPassword: string = null;
let newPassword: string | null = null;
async function updatePassword() {
try {
@@ -9,7 +9,7 @@
import { onMount } from 'svelte';
import { user } from './store';
let userPhone: string = null;
let userPhone: string | null = null;
onMount(async () => {
userPhone ??= $user.phone;
});
@@ -21,7 +21,7 @@
}
}
let prefs: [string, unknown][] = null;
let prefs: [string, unknown][] | null = null;
let arePrefsDisabled = true;
onMount(async () => {
@@ -11,7 +11,7 @@
const dispatch = createEventDispatcher();
let name = '';
let id: string = null;
let id: string | null = null;
let showCustomId = false;
const create = async () => {
@@ -19,7 +19,7 @@
import Overview from './overview.svelte';
let showDropdown = [];
let selectedAttribute: Attributes = null;
let selectedAttribute: Attributes | null = null;
let showCreate = false;
let showDelete = false;
let showOverview = false;
@@ -22,7 +22,7 @@
<script lang="ts">
import { InputChoice, InputSelect } from '$lib/elements/forms';
export let selectedAttribute: Models.AttributeBoolean = null;
export let selectedAttribute: Models.AttributeBoolean | null = null;
export let data: Partial<Models.AttributeBoolean> = {
required: false,
array: false,
@@ -22,7 +22,7 @@
<script lang="ts">
import { InputChoice, InputDateTime } from '$lib/elements/forms';
export let selectedAttribute: Models.AttributeDatetime = null;
export let selectedAttribute: Models.AttributeDatetime | null = null;
export let data: Partial<Models.AttributeDatetime>;
$: if (selectedAttribute) {
@@ -23,7 +23,7 @@
<script lang="ts">
import { InputChoice, InputEmail } from '$lib/elements/forms';
export let selectedAttribute: Models.AttributeEmail = null;
export let selectedAttribute: Models.AttributeEmail | null = null;
export let data: Partial<Models.AttributeEmail>;
$: if (selectedAttribute) {
@@ -12,7 +12,7 @@
export let showCreate = false;
let key: string = null;
let key: string | null = null;
let selectedOption = null;
let data: Partial<Attributes> = {
required: false,
@@ -22,7 +22,7 @@
import { Button } from '$lib/elements/forms';
let showDropdown = [];
let selectedIndex: Models.Index = null;
let selectedIndex: Models.Index | null = null;
let showCreateIndex = false;
let showOverview = false;
let showDelete = false;
@@ -14,12 +14,12 @@
import { remove } from '$lib/helpers/array';
export let showCreateIndex = false;
export let externalAttribute: Attributes = null;
export let externalAttribute: Attributes | null = null;
const databaseId = $page.params.database;
let error: string;
let key: string = null;
let key: string | null = null;
let types = [
{ value: 'key', label: 'Key' },
{ value: 'unique', label: 'Unique' },
@@ -4,7 +4,7 @@
import type { Models } from '@aw-labs/appwrite-console';
export let showOverview = false;
export let selectedIndex: Models.Index = null;
export let selectedIndex: Models.Index | null = null;
//TODO: add error message when index failed
</script>
@@ -22,7 +22,7 @@
let showError: false | 'name' | 'size' = false,
errorMessage = 'Something went wrong',
errorType: 'error' | 'warning' | 'success' = 'error';
let enabled: boolean = null,
let enabled: boolean | null = null,
collectionName: string = null,
collectionDocumentSecurity: boolean = null,
collectionPermissions: string[] = null,
@@ -15,7 +15,7 @@
const dispatch = createEventDispatcher();
let name = '';
let id: string = null;
let id: string | null = null;
let showCustomId = false;
const create = async () => {
@@ -17,7 +17,7 @@
let showError: false | 'name' | 'email' | 'password' = false;
let errorMessage = 'Something went wrong';
let errorType: 'error' | 'warning' | 'success' = 'error';
let databaseName: string = null;
let databaseName: string | null = null;
onMount(async () => {
databaseName ??= $database.name;
@@ -6,7 +6,7 @@
import type { Models } from '@aw-labs/appwrite-console';
export let showCreate = false;
export let selectedVar: Partial<Models.Variable> = null;
export let selectedVar: Partial<Models.Variable> | null = null;
let pair = {
$id: selectedVar?.$id,
@@ -47,7 +47,7 @@
let showDelete = false;
let showActivate = false;
let selectedDeployment: Models.Deployment = null;
let selectedDeployment: Models.Deployment | null = null;
const handleActivate = () => {
invalidate(Dependencies.DEPLOYMENTS);
@@ -8,7 +8,7 @@
import { createEventDispatcher } from 'svelte';
export let showActivate = false;
export let selectedDeployment: Models.Deployment = null;
export let selectedDeployment: Models.Deployment | null = null;
const dispatch = createEventDispatcher();
@@ -9,7 +9,7 @@
import type { Models } from '@aw-labs/appwrite-console';
export let showDelete = false;
export let selectedDeployment: Models.Deployment = null;
export let selectedDeployment: Models.Deployment | null = null;
const handleSubmit = async () => {
try {
@@ -8,10 +8,10 @@
import { sdkForProject } from '$lib/stores/sdk';
import type { Models } from '@aw-labs/appwrite-console';
export let selectedFunction: Models.Function = null;
export let selectedFunction: Models.Function | null = null;
let show = false;
let data: string = null;
let data: string | null = null;
let showJson = false;
let submitting = false;
@@ -37,14 +37,14 @@
const functionId = $page.params.function;
let showDelete = false;
let selectedVar: Models.Variable = null;
let selectedVar: Models.Variable | null = null;
// let showVariablesUpload = false;
let showVariablesModal = false;
let showVariablesValue = [];
let showVariablesDropdown = [];
let timeout: number = null;
let functionName: string = null;
let functionSchedule: string = null;
let timeout: number | null = null;
let functionName: string | null = null;
let functionSchedule: string | null = null;
let permissions: string[] = [];
let arePermsDisabled = true;
@@ -17,7 +17,7 @@
let showCreate = false;
let selectedVar: Partial<Models.Variable> = null;
let selectedVar: Partial<Models.Variable> | null = null;
let showDropdown = [];
function handleCreated(dispatchEvent: CustomEvent) {
@@ -3,18 +3,13 @@
notation: 'compact'
});
// TODO: metric type is wrong
export function last(set: Array<unknown>): Models.Metric | null {
return (set as Models.Metric[]).slice(-1)[0] ?? null;
}
// TODO: metric type is wrong
export function total(set: Array<unknown>): number {
return (set as Models.Metric[]).reduce((prev, curr) => prev + curr.value, 0);
}
export function format(number: number): string {
return formatter.format(number);
export function format(number: number | undefined): string {
return formatter.format(number ?? 0);
}
</script>
@@ -33,8 +28,9 @@
import Bandwith from './bandwith.svelte';
import Requests from './requests.svelte';
import Onboard from './onboard.svelte';
import { last } from '$lib/layout/usage.svelte';
$: projectId = $page.params.project;
$: projectId = $page.params.project ?? '';
$: path = `/console/project-${projectId}/overview`;
let period: UsagePeriods = '30d';
@@ -65,7 +61,7 @@
<Onboard {projectId} />
{:else}
{#if $usage}
{@const storage = humanFileSize(last($usage.storage).value)}
{@const storage = humanFileSize(last($usage.storage)?.value ?? 0)}
<section class="common-section">
<div class="grid-dashboard-1s-2m-6l">
<div class="card is-2-columns-medium-screen is-3-columns-large-screen">
@@ -89,14 +85,14 @@
<div class="grid-item-1-end-start">
<div class="heading-level-4">
{format(last($usage.documents).value)}
{format(last($usage.documents)?.value)}
</div>
<div>Documents</div>
</div>
<div class="grid-item-1-end-end">
<div class="text">
Databases: {format(last($usage.databases).value)}
Databases: {format(last($usage.databases)?.value)}
</div>
</div>
</div>
@@ -124,7 +120,7 @@
<div class="grid-item-1-end-end">
<div class="text">
Buckets: {format(last($usage.buckets).value)}
Buckets: {format(last($usage.buckets)?.value)}
</div>
</div>
</div>
@@ -144,7 +140,7 @@
<div class="grid-item-1-end-start">
<div class="heading-level-4">
{format(last($usage.users).value)}
{format(last($usage.users)?.value ?? 0)}
</div>
<div>Users</div>
</div>
@@ -165,7 +161,7 @@
<div class="grid-item-1-end-start">
<div class="heading-level-4">
{format(last($usage.executions).value)}
{format(last($usage.executions)?.value)}
</div>
<div>Executions</div>
</div>
@@ -196,9 +192,10 @@
aria-label="Show items in end side">
<span class="icon-cheveron-right" aria-hidden="true" />
</button>
<ul class="tabs-list" data-sveltekit-noscroll>
<ul class="tabs-list">
<li class="tabs-item">
<a
data-sveltekit-noscroll
class="tabs-button"
href={`${path}/platforms`}
class:is-selected={$page.url.pathname === `${path}/platforms`}>
@@ -207,6 +204,7 @@
</li>
<li class="tabs-item">
<a
data-sveltekit-noscroll
class="tabs-button"
href={`${path}/keys`}
class:is-selected={$page.url.pathname === `${path}/keys`}>
@@ -16,10 +16,10 @@
import { trackEvent } from '$lib/actions/analytics';
let showDelete = false;
let name: string = null;
let secret: string = null;
let expire: string = null;
let scopes: string[] = null;
let name: string = '';
let secret: string = '';
let expire: string = '';
let scopes: string[] = [];
onMount(() => {
name ??= $key.name;
@@ -13,8 +13,17 @@
import { onboarding } from '../../store';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { isString, isStringArray } from '$lib/helpers/type';
async function onFinish() {
if (
!isString($page.params.project) ||
!isString($key.name) ||
!isStringArray($key.scopes)
) {
return;
}
try {
const { $id } = await sdkForConsole.projects.createKey(
$page.params.project,
@@ -40,7 +40,7 @@
};
let showDelete = false;
let name: string = null;
let name: string;
onMount(() => {
name ??= data.platform.name;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let hostname: string = null;
let hostname: string;
onMount(() => {
hostname ??= $platform.hostname;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -10,7 +10,7 @@
import { project } from '../../../store';
import { platform } from './store';
let key: string = null;
let key: string;
onMount(() => {
key ??= $platform.key;
@@ -9,7 +9,7 @@
import { project } from '../../../store';
import { platform } from './store';
let hostname: string = null;
let hostname: string;
onMount(() => {
hostname ??= $platform.hostname;
@@ -15,7 +15,7 @@
import { page } from '$app/stores';
import { trackEvent } from '$lib/actions/analytics';
let name: string = null;
let name: string;
let showDelete = false;
const endpoint = sdkForConsole.client.config.endpoint;
const projectId = $page.params.project;
@@ -46,7 +46,8 @@
await sdkForConsole.projects.updateServiceStatus(
$project.$id,
service.method,
service.value
// Worst case scenario, an error notification will be shown
service.value as boolean
);
invalidate(Dependencies.PROJECT);
addNotification({
@@ -10,8 +10,8 @@
export let showDelete = false;
let password: string = null;
let name: string = null;
let password: string;
let name: string;
const handleDelete = async () => {
try {
@@ -23,6 +23,7 @@
import Create from '../create.svelte';
import Delete from '../delete.svelte';
import { trackEvent } from '$lib/actions/analytics';
import { isString } from '$lib/helpers/type';
export let data: PageData;
@@ -37,6 +38,7 @@
};
const refreshDomain = async (domain: Models.Domain) => {
if (!isString(projectId)) return;
const domainId = domain.$id;
try {
isVerifying[domainId] = true;
@@ -13,9 +13,9 @@
import { domain } from './store';
const target = window?.location.hostname ?? '';
$: parts = $domain.domain.split('.');
$: parts = $domain.domain?.split('.') || [];
$: registerable = [parts[parts.length - 2], parts[parts.length - 1]].join('.');
$: cnameValue = $domain.domain.replace('.' + registerable, '');
$: cnameValue = $domain.domain?.replace('.' + registerable, '');
</script>
<Table noStyles noMargin>
@@ -1,6 +1,7 @@
<script lang="ts">
import { trackEvent } from '$lib/actions/analytics';
import { FormList, InputDomain } from '$lib/elements/forms';
import { isString } from '$lib/helpers/type';
import { WizardStep } from '$lib/layout';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../../../store';
@@ -8,6 +9,7 @@
const projectId = $project.$id;
const createDomain = async () => {
if (!isString($domain.domain)) return;
if ($domain.$id) {
await sdkForConsole.projects.deleteDomain(projectId, $domain.$id);
}
@@ -5,13 +5,17 @@
import { project } from '../../../store';
import CnameTable from './cnameTable.svelte';
import VerificationBox from './verificationBox.svelte';
import { isString } from '$lib/helpers/type';
const projectId = $project.$id;
let certificate = false;
const checkCertificate = () => {
const domainId = $domain.$id;
if (!isString(domainId)) return;
setTimeout(async () => {
const result = await sdkForConsole.projects.getDomain(projectId, $domain.$id);
const result = await sdkForConsole.projects.getDomain(projectId, domainId);
if (!result.certificateId) {
checkCertificate();
return;
@@ -5,6 +5,7 @@
import { project } from '../../../store';
import { addNotification } from '$lib/stores/notifications';
import { Pill } from '$lib/elements';
import { isString } from '$lib/helpers/type';
const projectId = $project.$id;
@@ -12,11 +13,14 @@
export let isVerified = false;
const verifyDomain = async () => {
const domainId = $domain.$id;
if (!isString(domainId)) return;
isVerifying = true;
try {
const result = await sdkForConsole.projects.updateDomainVerification(
projectId,
$domain.$id
domainId
);
isVerified = result.verification;
} catch (error) {
@@ -23,15 +23,16 @@
import { Dependencies } from '$lib/constants';
import { writable, type Writable } from 'svelte/store';
import { trackEvent } from '$lib/actions/analytics';
import { isString } from '$lib/helpers/type';
const projectId = $page.params.project;
let name: string = null;
let url: string = null;
let name: string | null = null;
let url: string | null = null;
const eventSet: Writable<Set<string>> = writable(new Set());
let httpUser: string = null;
let httpPass: string = null;
let httpUser: string | null = null;
let httpPass: string | null = null;
let security = false;
let showDelete = false;
let showCreateEvent = false;
@@ -48,6 +49,8 @@
});
async function updateName() {
if (!isString(projectId) || !isString(name)) return;
try {
await sdkForConsole.projects.updateWebhook(
projectId,
@@ -73,6 +76,7 @@
}
}
async function updateUrl() {
if (projectId === undefined || url === null) return;
try {
await sdkForConsole.projects.updateWebhook(
projectId,
@@ -98,6 +102,7 @@
}
}
async function updateEvents() {
if (projectId === undefined) return;
try {
await sdkForConsole.projects.updateWebhook(
projectId,
@@ -125,6 +130,7 @@
}
async function updateSecurity() {
if (projectId === undefined || httpUser === null || httpPass === null) return;
try {
await sdkForConsole.projects.updateWebhook(
projectId,
@@ -5,6 +5,7 @@
import { Modal } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { isString } from '$lib/helpers/type';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { webhook } from './store';
@@ -13,6 +14,7 @@
const projectId = $page.params.project;
async function regenerate() {
if (!isString(projectId)) return;
try {
await sdkForConsole.projects.updateWebhookSignature(projectId, $webhook.$id);
invalidate(Dependencies.WEBHOOK);
@@ -13,18 +13,20 @@
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { isBoolean } from '$lib/helpers/type';
const projectId = $page.params.project;
const create = async () => {
if (!isBoolean($createWebhook.security)) return;
try {
await sdkForConsole.projects.createWebhook(
projectId,
$createWebhook.name,
$createWebhook.events,
$createWebhook.url,
projectId ?? '',
$createWebhook.name ?? '',
$createWebhook.events ?? [],
$createWebhook.url ?? '',
$createWebhook.security,
$createWebhook.httpUser,
$createWebhook.httpPass
$createWebhook.httpUser ?? '',
$createWebhook.httpPass ?? ''
);
invalidate(Dependencies.WEBHOOKS);
addNotification({
@@ -43,12 +45,8 @@
onDestroy(() => {
$createWebhook = {
name: null,
url: null,
events: [],
security: false,
httpUser: null,
httpPass: null
security: false
};
});
@@ -2,10 +2,10 @@ import type { Models } from '@aw-labs/appwrite-console';
import { writable } from 'svelte/store';
export const createWebhook = writable<Partial<Models.Webhook>>({
name: null,
url: null,
name: undefined,
url: undefined,
events: [],
security: false,
httpUser: null,
httpPass: null
httpUser: undefined,
httpPass: undefined
});
Loaded 100 of 116 files, more files were not shown because too many files have changed in this diff. Show more