Skip to content
Open
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
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@8f00f95",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@341620a",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
"@appwrite.io/pink-legacy": "^1.0.3",
Expand Down
3 changes: 1 addition & 2 deletions src/lib/components/domains/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export function isProxyRuleVerified(status: ProxyRuleStatusValue): boolean {
}

export function normalizeProxyRuleStatus(status: ProxyRuleStatusValue): ProxyRuleStatusValue {
if (status === ProxyRuleStatus.Created) {
if (status === 'created') {
return ProxyRuleStatus.Unverified;
}

return status;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/domains/viewLogsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });
.proxy.updateRuleStatus({ ruleId: selectedProxyRule.$id });

await invalidate(Dependencies.DOMAINS);
show = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ async function updateProjectOAuth({
clientSecret: getSecret('clientSecret'),
wellKnownURL: getDetail('wellKnownURL'),
authorizationURL: getDetail('authorizationURL'),
tokenUrl: getDetail('tokenUrl'),
userInfoUrl: getDetail('userInfoUrl'),
tokenURL: getDetail('tokenUrl'),
userInfoURL: getDetail('userInfoUrl'),
enabled
});
case OAuthProvider.Okta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
import type { Column, ColumnType } from '$lib/helpers/types';
import { Container } from '$lib/layout';
import { preferences } from '$lib/stores/preferences';
import { Icon, Layout, Divider, Tooltip } from '@appwrite.io/pink-svelte';
import {
Icon,
Layout,
Divider,
Tooltip,
Selector,
Typography,
Dialog
} from '@appwrite.io/pink-svelte';
import type { PageProps } from './$types';
import FilePicker from '$lib/components/filePicker.svelte';
import { page } from '$app/state';
Expand All @@ -21,7 +29,7 @@
IconUpload,
IconDownload
} from '@appwrite.io/pink-icons-svelte';
import { type Models } from '@appwrite.io/console';
import { OnDuplicate, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { goto } from '$app/navigation';
import { resolve } from '$app/paths';
Expand Down Expand Up @@ -49,7 +57,11 @@

let isRefreshing = $state(false);
let showImportJson = $state(false);
let showImportOptions = $state(false);
let showCustomColumnsModal = $state(false);
let importOnDuplicate: OnDuplicate = $state(OnDuplicate.Fail);
let pendingFile: Models.File | null = $state(null);
let pendingLocalFile = $state(false);

let columnsError: string = $state(null);
let spreadsheet: SpreadSheet | null = $state(null);
Expand All @@ -74,17 +86,28 @@
return queryParam ? `${url}?query=${encodeURIComponent(queryParam)}` : url;
}

async function onSelect(file: Models.File, localFile = false) {
function onSelect(file: Models.File, localFile = false) {
pendingFile = file;
pendingLocalFile = localFile;
importOnDuplicate = OnDuplicate.Fail;
showImportOptions = true;
}

async function startImport() {
if (!pendingFile) return;

showImportOptions = false;
$isCollectionsJsonImportInProgress = true;

try {
await sdk
.forProject(page.params.region, page.params.project)
.migrations.createJSONImport({
bucketId: file.bucketId,
fileId: file.$id,
bucketId: pendingFile.bucketId,
fileId: pendingFile.$id,
resourceId: `${page.params.database}:${page.params.collection}`,
internalFile: localFile
internalFile: pendingLocalFile,
onDuplicate: importOnDuplicate
});

addNotification({
Expand All @@ -101,6 +124,7 @@
});
} finally {
$isCollectionsJsonImportInProgress = false;
pendingFile = null;
}
}

Expand Down Expand Up @@ -343,6 +367,52 @@
}} />
{/if}

<Dialog title="Import options" bind:open={showImportOptions}>
<Layout.Stack gap="l">
<Typography.Text variant="m-400">
Choose how to handle documents that already exist in this collection.
</Typography.Text>
<Layout.Stack gap="m">
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Fail}
label="Fail on duplicate (default)">
<svelte:fragment slot="description">
Import aborts on the first document with a matching ID.
</svelte:fragment>
</Selector.Radio>
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Skip}
label="Skip existing documents">
<svelte:fragment slot="description">
Documents with matching IDs will be silently skipped.
</svelte:fragment>
</Selector.Radio>
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Overwrite}
label="Overwrite existing documents">
<svelte:fragment slot="description">
Documents with matching IDs will be updated with the imported data.
</svelte:fragment>
</Selector.Radio>
</Layout.Stack>
</Layout.Stack>
<svelte:fragment slot="footer">
<Layout.Stack direction="row" gap="s" justifyContent="flex-end">
<Button text on:click={() => (showImportOptions = false)}>Cancel</Button>
<Button on:click={startImport}>Start import</Button>
</Layout.Stack>
</svelte:fragment>
</Dialog>

<Modal
title="Custom columns"
bind:error={columnsError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
import { Container } from '$lib/layout';
import { preferences } from '$lib/stores/preferences';
import { canWriteTables, canWriteRows } from '$lib/stores/roles';
import { Icon, Layout, Divider, Tooltip, Typography, Link } from '@appwrite.io/pink-svelte';
import {
Dialog,
Icon,
Layout,
Divider,
Selector,
Tooltip,
Typography,
Link
} from '@appwrite.io/pink-svelte';
import type { PageData } from './$types';
import {
tableColumns,
Expand All @@ -34,7 +43,7 @@
IconUpload,
IconDownload
} from '@appwrite.io/pink-icons-svelte';
import type { Models } from '@appwrite.io/console';
import { OnDuplicate, type Models } from '@appwrite.io/console';
import CreateRow from '$database/table-[table]/rows/create.svelte';
import { onDestroy } from 'svelte';
import { isCloud } from '$lib/system';
Expand All @@ -56,6 +65,10 @@

let isRefreshing = false;
let showImportCSV = false;
let showImportOptions = false;
let importOnDuplicate: OnDuplicate = OnDuplicate.Fail;
let pendingFile: Models.File | null = null;
let pendingLocalFile = false;

// todo: might need a type fix here.
const filterColumns = writable<Column[]>([]);
Expand Down Expand Up @@ -107,17 +120,28 @@

$: disableButton = canShowSuggestionsSheet;

async function onSelect(file: Models.File, localFile = false) {
function onSelect(file: Models.File, localFile = false) {
pendingFile = file;
pendingLocalFile = localFile;
importOnDuplicate = OnDuplicate.Fail;
showImportOptions = true;
}

async function startImport() {
if (!pendingFile) return;

showImportOptions = false;
$isTablesCsvImportInProgress = true;

try {
await sdk
.forProject(page.params.region, page.params.project)
.migrations.createCSVImport({
bucketId: file.bucketId,
fileId: file.$id,
bucketId: pendingFile.bucketId,
fileId: pendingFile.$id,
resourceId: `${page.params.database}:${page.params.table}`,
internalFile: localFile
internalFile: pendingLocalFile,
onDuplicate: importOnDuplicate
});

addNotification({
Expand All @@ -134,6 +158,7 @@
});
} finally {
$isTablesCsvImportInProgress = false;
pendingFile = null;
}
}

Expand Down Expand Up @@ -434,6 +459,52 @@
}} />
{/if}

<Dialog title="Import options" bind:open={showImportOptions}>
<Layout.Stack gap="l">
<Typography.Text variant="m-400">
Choose how to handle documents that already exist in this table.
</Typography.Text>
<Layout.Stack gap="m">
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Fail}
label="Fail on duplicate (default)">
<svelte:fragment slot="description">
Migration aborts on the first row with a matching ID.
</svelte:fragment>
</Selector.Radio>
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Skip}
label="Skip existing documents">
<svelte:fragment slot="description">
Documents with matching IDs will be silently skipped.
</svelte:fragment>
</Selector.Radio>
<Selector.Radio
size="s"
bind:group={importOnDuplicate}
name="importOnDuplicate"
value={OnDuplicate.Overwrite}
label="Overwrite existing documents">
<svelte:fragment slot="description">
Documents with matching IDs will be updated with the imported data.
</svelte:fragment>
</Selector.Radio>
</Layout.Stack>
</Layout.Stack>
<svelte:fragment slot="footer">
<Layout.Stack direction="row" gap="s" justifyContent="flex-end">
<Button text on:click={() => (showImportOptions = false)}>Cancel</Button>
<Button on:click={startImport}>Start import</Button>
</Layout.Stack>
</svelte:fragment>
</Dialog>

<CreateRow
{table}
bind:showSheet={$showRowCreateSheet.show}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { tick } from 'svelte';
import { isRelationship, isRelationshipToMany } from './store';
import { isRelationship, isRelationshipToMany, buildPayload } from './store';
import type { RowValue } from './store';
import { hash } from '$lib/helpers/string';

type CreateRow = {
Expand Down Expand Up @@ -70,7 +71,7 @@
function prepareRowPayload(createRowObject: CreateRow): object {
const { row, columns } = createRowObject;

const payload = structuredClone(row);
const payload = structuredClone(row) as Record<string, RowValue>;

for (const column of columns) {
if (isRelationship(column) && !isRelationshipToMany(column)) {
Expand All @@ -79,15 +80,21 @@

if (value && typeof value === 'object') {
if (Array.isArray(value)) {
payload[key] = value.map((item) => item?.$id).filter(Boolean);
payload[key] = value
.map((item) =>
item && typeof item === 'object' && '$id' in item
? (item.$id as string)
: null
)
.filter(Boolean);
} else {
payload[key] = (value as { $id: string })['$id'];
}
}
}
}

return payload;
return buildPayload(columns, payload);
}

async function create(): Promise<boolean> {
Expand Down
Loading
Loading