-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Runtime: Deprecate runtime/server/export.go – migrate frontend to use…
… the new Export API (#3419) * added export impl * UI changes to use the new API * updated limit clause --------- Co-authored-by: Aditya Hegde <[email protected]>
- Loading branch information
1 parent
52d519c
commit a61340d
Showing
6 changed files
with
164 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { | ||
createQueryServiceExport, | ||
RpcStatus, | ||
V1ExportFormat, | ||
} from "@rilldata/web-common/runtime-client"; | ||
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store"; | ||
import { createMutation, CreateMutationOptions } from "@tanstack/svelte-query"; | ||
import type { MutationFunction } from "@tanstack/svelte-query"; | ||
import { get } from "svelte/store"; | ||
|
||
export type ExportTableRequest = { | ||
instanceId: string; | ||
format: V1ExportFormat; | ||
tableName: string; | ||
}; | ||
|
||
export function createExportTableMutation< | ||
TError = { response: { data: RpcStatus } }, | ||
TContext = unknown | ||
>(options?: { | ||
mutation?: CreateMutationOptions< | ||
Awaited<Promise<void>>, | ||
TError, | ||
{ data: ExportTableRequest }, | ||
TContext | ||
>; | ||
}) { | ||
const { mutation: mutationOptions } = options ?? {}; | ||
const exporter = createQueryServiceExport(); | ||
|
||
const mutationFn: MutationFunction< | ||
Awaited<Promise<void>>, | ||
{ data: ExportTableRequest } | ||
> = async (props) => { | ||
const { data } = props ?? {}; | ||
if (!data.instanceId) throw new Error("Missing instanceId"); | ||
|
||
const exportResp = await get(exporter).mutateAsync({ | ||
instanceId: data.instanceId, | ||
data: { | ||
format: data.format, | ||
query: { | ||
tableRowsRequest: { | ||
instanceId: data.instanceId, | ||
tableName: data.tableName, | ||
}, | ||
}, | ||
}, | ||
}); | ||
const downloadUrl = `${get(runtime).host}${exportResp.downloadUrlPath}`; | ||
window.open(downloadUrl, "_self"); | ||
}; | ||
|
||
return createMutation< | ||
Awaited<Promise<void>>, | ||
TError, | ||
{ data: ExportTableRequest }, | ||
TContext | ||
>(mutationFn, mutationOptions); | ||
} |
a61340d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://ui.rilldata.io as production
🚀 Deployed on https://654d8f29c49a670fd5e10da1--rill-ui-stage.netlify.app