mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-05-24 13:45:03 +00:00
refactor: migrate db tauri commands to drizzle
This commit is contained in:
parent
92c69430ff
commit
8fd3223b66
@ -7,10 +7,11 @@ import { decideKkrpcSerialization } from "@/utils/kkrpc"
|
|||||||
import { sleep } from "@/utils/time"
|
import { sleep } from "@/utils/time"
|
||||||
import { trimSlash } from "@/utils/url"
|
import { trimSlash } from "@/utils/url"
|
||||||
import { constructExtensionSupportDir } from "@kksh/api"
|
import { constructExtensionSupportDir } from "@kksh/api"
|
||||||
import { db, spawnExtensionFileServer } from "@kksh/api/commands"
|
import { spawnExtensionFileServer } from "@kksh/api/commands"
|
||||||
import type { HeadlessCommand } from "@kksh/api/headless"
|
import type { HeadlessCommand } from "@kksh/api/headless"
|
||||||
import { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
|
import { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
|
||||||
import { constructJarvisServerAPIWithPermissions, type IApp } from "@kksh/api/ui"
|
import { constructJarvisServerAPIWithPermissions, type IApp } from "@kksh/api/ui"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { launchNewExtWindow, loadExtensionManifestFromDisk } from "@kksh/extension"
|
import { launchNewExtWindow, loadExtensionManifestFromDisk } from "@kksh/extension"
|
||||||
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
|
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
|
||||||
import { convertFileSrc } from "@tauri-apps/api/core"
|
import { convertFileSrc } from "@tauri-apps/api/core"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { db } from "@kksh/api/commands"
|
|
||||||
import type { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
|
import type { CustomUiCmd, ExtPackageJsonExtra, HeadlessCmd, TemplateUiCmd } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import * as extAPI from "@kksh/extension"
|
import * as extAPI from "@kksh/extension"
|
||||||
import * as path from "@tauri-apps/api/path"
|
import * as path from "@tauri-apps/api/path"
|
||||||
import Fuse from "fuse.js"
|
import Fuse from "fuse.js"
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<svelte:window on:keydown={handleKeyDown} />
|
<svelte:window on:keydown={handleKeyDown} />
|
||||||
|
|
||||||
|
<div class="fixed h-12 w-full" data-tauri-drag-region></div>
|
||||||
<Layouts.Center class="min-h-screen py-5">
|
<Layouts.Center class="min-h-screen py-5">
|
||||||
<Error.RawErrorJSONPreset
|
<Error.RawErrorJSONPreset
|
||||||
title="Error"
|
title="Error"
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import { systemCommands, systemCommandsFiltered } from "@/cmds/system"
|
import { systemCommands, systemCommandsFiltered } from "@/cmds/system"
|
||||||
import AppsCmds from "@/components/main/AppsCmds.svelte"
|
import AppsCmds from "@/components/main/AppsCmds.svelte"
|
||||||
import { i18n } from "@/i18n"
|
import { i18n } from "@/i18n"
|
||||||
import { getUniqueExtensionByIdentifier } from "@/orm/cmds"
|
|
||||||
import { db } from "@/orm/database"
|
|
||||||
import * as m from "@/paraglide/messages"
|
import * as m from "@/paraglide/messages"
|
||||||
import {
|
import {
|
||||||
appConfig,
|
appConfig,
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
import { goHome } from "@/utils/route"
|
import { goHome } from "@/utils/route"
|
||||||
import { listenToNewClipboardItem, listenToWindowFocus } from "@/utils/tauri-events"
|
import { listenToNewClipboardItem, listenToWindowFocus } from "@/utils/tauri-events"
|
||||||
import Icon from "@iconify/svelte"
|
import Icon from "@iconify/svelte"
|
||||||
import { ClipboardContentType, db } from "@kksh/api/commands"
|
import { ClipboardContentType } from "@kksh/api/commands"
|
||||||
import { SearchModeEnum, SQLSortOrderEnum, type ExtData } from "@kksh/api/models"
|
import { SearchModeEnum, SQLSortOrderEnum, type ExtData } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { Button, Command, Resizable } from "@kksh/svelte5"
|
import { Button, Command, Resizable } from "@kksh/svelte5"
|
||||||
import { Constants } from "@kksh/ui"
|
import { Constants } from "@kksh/ui"
|
||||||
import { CustomCommandInput, GlobalCommandPaletteFooter } from "@kksh/ui/main"
|
import { CustomCommandInput, GlobalCommandPaletteFooter } from "@kksh/ui/main"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { cn } from "@/utils"
|
import { cn } from "@/utils"
|
||||||
import { db } from "@kksh/api/commands"
|
|
||||||
import type { ExtData } from "@kksh/api/models"
|
import type { ExtData } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { Resizable, Separator } from "@kksh/svelte5"
|
import { Resizable, Separator } from "@kksh/svelte5"
|
||||||
import { convertFileSrc } from "@tauri-apps/api/core"
|
import { convertFileSrc } from "@tauri-apps/api/core"
|
||||||
import DOMPurify from "dompurify"
|
import DOMPurify from "dompurify"
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
import { positionToCssStyleString, positionToTailwindClasses } from "@/utils/style"
|
import { positionToCssStyleString, positionToTailwindClasses } from "@/utils/style"
|
||||||
import { sleep } from "@/utils/time"
|
import { sleep } from "@/utils/time"
|
||||||
import { isInMainWindow } from "@/utils/window"
|
import { isInMainWindow } from "@/utils/window"
|
||||||
import { db } from "@kksh/api/commands"
|
|
||||||
import { CustomPosition, ThemeColor, type Position } from "@kksh/api/models"
|
import { CustomPosition, ThemeColor, type Position } from "@kksh/api/models"
|
||||||
import {
|
import {
|
||||||
constructJarvisServerAPIWithPermissions,
|
constructJarvisServerAPIWithPermissions,
|
||||||
@ -19,6 +18,7 @@
|
|||||||
type IUiCustom
|
type IUiCustom
|
||||||
} from "@kksh/api/ui"
|
} from "@kksh/api/ui"
|
||||||
import { toast, type IUiCustomServer1, type IUiCustomServer2 } from "@kksh/api/ui/custom"
|
import { toast, type IUiCustomServer1, type IUiCustomServer2 } from "@kksh/api/ui/custom"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { Button } from "@kksh/svelte5"
|
import { Button } from "@kksh/svelte5"
|
||||||
import { cn } from "@kksh/ui/utils"
|
import { cn } from "@kksh/ui/utils"
|
||||||
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
|
import type { IKunkunFullServerAPI } from "@kunkunapi/src/api/server"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { KunkunIframeExtParams } from "@/cmds/ext"
|
import { KunkunIframeExtParams } from "@/cmds/ext"
|
||||||
import { i18n } from "@/i18n"
|
import { i18n } from "@/i18n"
|
||||||
import { appState } from "@/stores/appState"
|
|
||||||
import { db, unregisterExtensionWindow } from "@kksh/api/commands"
|
|
||||||
import type { Ext as ExtInfoInDB, ExtPackageJsonExtra } from "@kksh/api/models"
|
import type { Ext as ExtInfoInDB, ExtPackageJsonExtra } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
||||||
import { error as svError } from "@sveltejs/kit"
|
import { error as svError } from "@sveltejs/kit"
|
||||||
import { join } from "@tauri-apps/api/path"
|
import { join } from "@tauri-apps/api/path"
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
} from "@/utils/tauri-events.js"
|
} from "@/utils/tauri-events.js"
|
||||||
import { sleep } from "@/utils/time.js"
|
import { sleep } from "@/utils/time.js"
|
||||||
import { isInMainWindow } from "@/utils/window.js"
|
import { isInMainWindow } from "@/utils/window.js"
|
||||||
import { db } from "@kksh/api/commands"
|
|
||||||
import {
|
import {
|
||||||
constructJarvisServerAPIWithPermissions,
|
constructJarvisServerAPIWithPermissions,
|
||||||
type IApp,
|
type IApp,
|
||||||
@ -29,6 +28,7 @@
|
|||||||
type IComponent,
|
type IComponent,
|
||||||
type TemplateUiCommand
|
type TemplateUiCommand
|
||||||
} from "@kksh/api/ui/template"
|
} from "@kksh/api/ui/template"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { Button, Form } from "@kksh/svelte5"
|
import { Button, Form } from "@kksh/svelte5"
|
||||||
import { LoadingBar } from "@kksh/ui"
|
import { LoadingBar } from "@kksh/ui"
|
||||||
import { Templates } from "@kksh/ui/extension"
|
import { Templates } from "@kksh/ui/extension"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { KunkunTemplateExtParams } from "@/cmds/ext"
|
import { KunkunTemplateExtParams } from "@/cmds/ext"
|
||||||
import { i18n } from "@/i18n"
|
import { i18n } from "@/i18n"
|
||||||
import { db, unregisterExtensionWindow } from "@kksh/api/commands"
|
import type { ExtPackageJsonExtra } from "@kksh/api/models"
|
||||||
import type { Ext as ExtInfoInDB, ExtPackageJsonExtra } from "@kksh/api/models"
|
import { db } from "@kksh/drizzle"
|
||||||
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
||||||
import { error as sbError, error as svError } from "@sveltejs/kit"
|
import { error as sbError, error as svError } from "@sveltejs/kit"
|
||||||
import { join } from "@tauri-apps/api/path"
|
import { join } from "@tauri-apps/api/path"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as m from "@/paraglide/messages"
|
import * as m from "@/paraglide/messages"
|
||||||
import { db } from "@kksh/api/commands"
|
import { db } from "@kksh/drizzle"
|
||||||
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
import { loadExtensionManifestFromDisk } from "@kksh/extension"
|
||||||
import { Button, Dialog, Table } from "@kksh/svelte5"
|
import { Button, Dialog, Table } from "@kksh/svelte5"
|
||||||
import { join } from "@tauri-apps/api/path"
|
import { join } from "@tauri-apps/api/path"
|
||||||
|
@ -7,13 +7,12 @@
|
|||||||
getUniqueExtensionByPath,
|
getUniqueExtensionByPath,
|
||||||
searchExtensionData,
|
searchExtensionData,
|
||||||
updateCmdByID
|
updateCmdByID
|
||||||
} from "@/orm/cmds"
|
} from "@kksh/drizzle/api"
|
||||||
import * as schema from "@kksh/drizzle/schema"
|
import * as schema from "@kksh/drizzle/schema"
|
||||||
import { Button, Input } from "@kksh/svelte5"
|
import { Button, Input } from "@kksh/svelte5"
|
||||||
import { CmdTypeEnum, Ext } from "@kunkunapi/src/models/extension"
|
import { CmdTypeEnum, Ext } from "@kunkunapi/src/models/extension"
|
||||||
import { SearchModeEnum, SQLSortOrderEnum } from "@kunkunapi/src/models/sql"
|
import { SearchModeEnum, SQLSortOrderEnum } from "@kunkunapi/src/models/sql"
|
||||||
import { db } from "$lib/orm/database"
|
// import * as orm from "drizzle-orm"
|
||||||
import * as orm from "drizzle-orm"
|
|
||||||
import { Inspect } from "svelte-inspect-value"
|
import { Inspect } from "svelte-inspect-value"
|
||||||
import { toast } from "svelte-sonner"
|
import { toast } from "svelte-sonner"
|
||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
|
@ -20,9 +20,10 @@ import type {
|
|||||||
IPath as ITauriPath
|
IPath as ITauriPath
|
||||||
} from "tauri-api-adapter"
|
} from "tauri-api-adapter"
|
||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
import { KV, type JarvisExtDB } from "../commands/db"
|
|
||||||
import type { fileSearch } from "../commands/fileSearch"
|
import type { fileSearch } from "../commands/fileSearch"
|
||||||
import { type AppInfo } from "../models/apps"
|
import { type AppInfo } from "../models/apps"
|
||||||
|
import { type ExtData } from "../models/extension"
|
||||||
|
import { ExtDataField, SearchMode, SQLSortOrder } from "../models/sql"
|
||||||
import type { LightMode, Position, Radius, ThemeColor } from "../models/styles"
|
import type { LightMode, Position, Radius, ThemeColor } from "../models/styles"
|
||||||
import type { DenoSysOptions } from "../permissions/schema"
|
import type { DenoSysOptions } from "../permissions/schema"
|
||||||
|
|
||||||
@ -154,23 +155,34 @@ export interface IUiCustom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IDb {
|
export interface IDb {
|
||||||
add: typeof JarvisExtDB.prototype.add
|
add: (data: { data: string; dataType?: string; searchText?: string }) => Promise<void>
|
||||||
delete: typeof JarvisExtDB.prototype.delete
|
delete: (dataId: number) => Promise<void>
|
||||||
search: typeof JarvisExtDB.prototype.search
|
search: (searchParams: {
|
||||||
retrieveAll: typeof JarvisExtDB.prototype.retrieveAll
|
dataId?: number
|
||||||
retrieveAllByType: typeof JarvisExtDB.prototype.retrieveAllByType
|
searchMode?: SearchMode
|
||||||
deleteAll: typeof JarvisExtDB.prototype.deleteAll
|
dataType?: string
|
||||||
update: typeof JarvisExtDB.prototype.update
|
searchText?: string
|
||||||
|
afterCreatedAt?: Date
|
||||||
|
beforeCreatedAt?: Date
|
||||||
|
limit?: number
|
||||||
|
orderByCreatedAt?: SQLSortOrder
|
||||||
|
orderByUpdatedAt?: SQLSortOrder
|
||||||
|
fields?: ExtDataField[]
|
||||||
|
}) => Promise<ExtData[]>
|
||||||
|
retrieveAll: (options: { fields?: ExtDataField[] }) => Promise<ExtData[]>
|
||||||
|
retrieveAllByType: (dataType: string) => Promise<ExtData[]>
|
||||||
|
deleteAll: () => Promise<void>
|
||||||
|
update: (data: { dataId: number; data: string; searchText?: string }) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A key-value store built on top of the Database API (based on sqlite)
|
* A key-value store built on top of the Database API (based on sqlite)
|
||||||
*/
|
*/
|
||||||
export interface IKV {
|
export interface IKV {
|
||||||
get: typeof KV.prototype.get
|
get: <T = string>(key: string) => Promise<T | null | undefined>
|
||||||
set: typeof KV.prototype.set
|
set: (key: string, value: string) => Promise<void>
|
||||||
exists: typeof KV.prototype.exists
|
exists: (key: string) => Promise<boolean>
|
||||||
delete: typeof KV.prototype.delete
|
delete: (key: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFs {
|
export interface IFs {
|
||||||
|
@ -1,465 +0,0 @@
|
|||||||
import { invoke } from "@tauri-apps/api/core"
|
|
||||||
import { array, literal, optional, parse, safeParse, union, type InferOutput } from "valibot"
|
|
||||||
import { KUNKUN_EXT_IDENTIFIER } from "../constants"
|
|
||||||
import { CmdType, Ext, ExtCmd, ExtData } from "../models/extension"
|
|
||||||
import { convertDateToSqliteString, SearchMode, SearchModeEnum, SQLSortOrder } from "../models/sql"
|
|
||||||
import { generateJarvisPluginCommand } from "./common"
|
|
||||||
|
|
||||||
export interface QueryResult {
|
|
||||||
/** The number of rows affected by the query. */
|
|
||||||
rowsAffected: number
|
|
||||||
/**
|
|
||||||
* The last inserted `id`.
|
|
||||||
*
|
|
||||||
* This value is not set for Postgres databases. If the
|
|
||||||
* last inserted id is required on Postgres, the `select` function
|
|
||||||
* must be used, with a `RETURNING` clause
|
|
||||||
* (`INSERT INTO todos (title) VALUES ($1) RETURNING id`).
|
|
||||||
*/
|
|
||||||
lastInsertId?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export function select(query: string, values: any[]) {
|
|
||||||
return invoke<any[]>(generateJarvisPluginCommand("select"), {
|
|
||||||
query,
|
|
||||||
values
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function execute(query: string, values: any[]) {
|
|
||||||
return invoke<QueryResult>(generateJarvisPluginCommand("execute"), {
|
|
||||||
query,
|
|
||||||
values
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Extension CRUD */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
export function createExtension(ext: {
|
|
||||||
identifier: string
|
|
||||||
version: string
|
|
||||||
enabled?: boolean
|
|
||||||
path?: string
|
|
||||||
data?: any
|
|
||||||
}) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("create_extension"), ext)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAllExtensions() {
|
|
||||||
return invoke<Ext[]>(generateJarvisPluginCommand("get_all_extensions"))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUniqueExtensionByIdentifier(identifier: string) {
|
|
||||||
return invoke<Ext | undefined>(
|
|
||||||
generateJarvisPluginCommand("get_unique_extension_by_identifier"),
|
|
||||||
{
|
|
||||||
identifier
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getUniqueExtensionByPath(path: string) {
|
|
||||||
return invoke<Ext | undefined>(generateJarvisPluginCommand("get_unique_extension_by_path"), {
|
|
||||||
path
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAllExtensionsByIdentifier(identifier: string) {
|
|
||||||
return invoke<Ext[]>(generateJarvisPluginCommand("get_all_extensions_by_identifier"), {
|
|
||||||
identifier
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this function when you expect the extension to exist. Such as builtin extensions.
|
|
||||||
* @param identifier
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
export function getExtensionByIdentifierExpectExists(identifier: string): Promise<Ext> {
|
|
||||||
return getUniqueExtensionByIdentifier(identifier).then((ext) => {
|
|
||||||
if (!ext) {
|
|
||||||
throw new Error(`Unexpexted Error: Extension ${identifier} not found`)
|
|
||||||
}
|
|
||||||
return ext
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: clean this up
|
|
||||||
// export function deleteExtensionByIdentifier(identifier: string) {
|
|
||||||
// return invoke<void>(generateJarvisPluginCommand("delete_extension_by_identifier"), { identifier })
|
|
||||||
// }
|
|
||||||
|
|
||||||
export function deleteExtensionByPath(path: string) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("delete_extension_by_path"), {
|
|
||||||
path
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteExtensionByExtId(extId: string) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("delete_extension_by_ext_id"), { extId })
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Extension Command CRUD */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
export function createCommand(data: {
|
|
||||||
extId: number
|
|
||||||
name: string
|
|
||||||
cmdType: CmdType
|
|
||||||
data: string
|
|
||||||
alias?: string
|
|
||||||
hotkey?: string
|
|
||||||
enabled?: boolean
|
|
||||||
}) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("create_command"), {
|
|
||||||
...data,
|
|
||||||
enabled: data.enabled ?? false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCommandById(cmdId: number) {
|
|
||||||
return invoke<ExtCmd | undefined>(generateJarvisPluginCommand("get_command_by_id"), { cmdId })
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCommandsByExtId(extId: number) {
|
|
||||||
return invoke<ExtCmd[]>(generateJarvisPluginCommand("get_commands_by_ext_id"), { extId })
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteCommandById(cmdId: number) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("delete_command_by_id"), {
|
|
||||||
cmdId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateCommandById(data: {
|
|
||||||
cmdId: number
|
|
||||||
name: string
|
|
||||||
cmdType: CmdType
|
|
||||||
data: string
|
|
||||||
alias?: string
|
|
||||||
hotkey?: string
|
|
||||||
enabled: boolean
|
|
||||||
}) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("update_command_by_id"), data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Extension Data CRUD */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
export const ExtDataField = union([literal("data"), literal("search_text")])
|
|
||||||
export type ExtDataField = InferOutput<typeof ExtDataField>
|
|
||||||
|
|
||||||
function convertRawExtDataToExtData(rawData?: {
|
|
||||||
createdAt: string
|
|
||||||
updatedAt: string
|
|
||||||
data: null | string
|
|
||||||
searchText: null | string
|
|
||||||
}): ExtData | undefined {
|
|
||||||
if (!rawData) {
|
|
||||||
return rawData
|
|
||||||
}
|
|
||||||
const parsedRes = safeParse(ExtData, {
|
|
||||||
...rawData,
|
|
||||||
createdAt: new Date(rawData.createdAt),
|
|
||||||
updatedAt: new Date(rawData.updatedAt),
|
|
||||||
data: rawData.data ?? undefined,
|
|
||||||
searchText: rawData.searchText ?? undefined
|
|
||||||
})
|
|
||||||
if (parsedRes.success) {
|
|
||||||
return parsedRes.output
|
|
||||||
} else {
|
|
||||||
console.error("Extension Data Parse Failure", parsedRes.issues)
|
|
||||||
throw new Error("Fail to parse extension data")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createExtensionData(data: {
|
|
||||||
extId: number
|
|
||||||
dataType: string
|
|
||||||
data: string
|
|
||||||
searchText?: string
|
|
||||||
}) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("create_extension_data"), data)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getExtensionDataById(dataId: number, fields?: ExtDataField[]) {
|
|
||||||
return invoke<
|
|
||||||
| (ExtData & {
|
|
||||||
createdAt: string
|
|
||||||
updatedAt: string
|
|
||||||
data: null | string
|
|
||||||
searchText: null | string
|
|
||||||
})
|
|
||||||
| undefined
|
|
||||||
>(generateJarvisPluginCommand("get_extension_data_by_id"), {
|
|
||||||
dataId,
|
|
||||||
fields
|
|
||||||
}).then(convertRawExtDataToExtData)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fields option can be used to select optional fields. By default, if left empty, data and searchText are not returned.
|
|
||||||
* This is because data and searchText can be large and we don't want to return them by default.
|
|
||||||
* If you just want to get data ids in order to delete them, retrieving all data is not necessary.
|
|
||||||
* @param searchParams
|
|
||||||
*/
|
|
||||||
export async function searchExtensionData(searchParams: {
|
|
||||||
extId: number
|
|
||||||
searchMode: SearchMode
|
|
||||||
dataId?: number
|
|
||||||
dataType?: string
|
|
||||||
searchText?: string
|
|
||||||
afterCreatedAt?: string
|
|
||||||
beforeCreatedAt?: string
|
|
||||||
limit?: number
|
|
||||||
offset?: number
|
|
||||||
orderByCreatedAt?: SQLSortOrder
|
|
||||||
orderByUpdatedAt?: SQLSortOrder
|
|
||||||
fields?: ExtDataField[]
|
|
||||||
}): Promise<ExtData[]> {
|
|
||||||
const fields = parse(optional(array(ExtDataField), []), searchParams.fields)
|
|
||||||
let items = await invoke<
|
|
||||||
(ExtData & {
|
|
||||||
createdAt: string
|
|
||||||
updatedAt: string
|
|
||||||
data: null | string
|
|
||||||
searchText: null | string
|
|
||||||
})[]
|
|
||||||
>(generateJarvisPluginCommand("search_extension_data"), {
|
|
||||||
searchQuery: {
|
|
||||||
...searchParams,
|
|
||||||
fields
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return items.map(convertRawExtDataToExtData).filter((item) => item) as ExtData[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteExtensionDataById(dataId: number) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("delete_extension_data_by_id"), { dataId })
|
|
||||||
}
|
|
||||||
|
|
||||||
export function updateExtensionDataById(data: {
|
|
||||||
dataId: number
|
|
||||||
data: string
|
|
||||||
searchText?: string
|
|
||||||
}) {
|
|
||||||
return invoke<void>(generateJarvisPluginCommand("update_extension_data_by_id"), data)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* Built-in Extensions */
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
export function getExtClipboard() {
|
|
||||||
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_CLIPBOARD_EXT_IDENTIFIER)
|
|
||||||
}
|
|
||||||
export function getExtQuickLinks() {
|
|
||||||
return getExtensionByIdentifierExpectExists(
|
|
||||||
KUNKUN_EXT_IDENTIFIER.KUNKUN_QUICK_LINKS_EXT_IDENTIFIER
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export function getExtRemote() {
|
|
||||||
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_REMOTE_EXT_IDENTIFIER)
|
|
||||||
}
|
|
||||||
export function getExtScriptCmd() {
|
|
||||||
return getExtensionByIdentifierExpectExists(
|
|
||||||
KUNKUN_EXT_IDENTIFIER.KUNKUN_SCRIPT_CMD_EXT_IDENTIFIER
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export function getExtDev() {
|
|
||||||
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_DEV_EXT_IDENTIFIER)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Database API for extensions.
|
|
||||||
* Extensions shouldn't have full access to the database, they can only access their own data.
|
|
||||||
* When an extension is loaded, the main thread will create an instance of this class and
|
|
||||||
* expose it to the extension.
|
|
||||||
*/
|
|
||||||
export class JarvisExtDB {
|
|
||||||
extId: number
|
|
||||||
|
|
||||||
constructor(extId: number) {
|
|
||||||
this.extId = extId
|
|
||||||
}
|
|
||||||
|
|
||||||
async add(data: { data: string; dataType?: string; searchText?: string }) {
|
|
||||||
return createExtensionData({
|
|
||||||
data: data.data,
|
|
||||||
dataType: data.dataType ?? "default",
|
|
||||||
searchText: data.searchText,
|
|
||||||
extId: this.extId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(dataId: number): Promise<void> {
|
|
||||||
// Verify if this data belongs to this extension
|
|
||||||
const d = await getExtensionDataById(dataId)
|
|
||||||
if (!d || d.extId !== this.extId) {
|
|
||||||
throw new Error("Extension Data not found")
|
|
||||||
}
|
|
||||||
return await deleteExtensionDataById(dataId)
|
|
||||||
}
|
|
||||||
|
|
||||||
async search(searchParams: {
|
|
||||||
dataId?: number
|
|
||||||
searchMode?: SearchMode
|
|
||||||
dataType?: string
|
|
||||||
searchText?: string
|
|
||||||
afterCreatedAt?: Date
|
|
||||||
beforeCreatedAt?: Date
|
|
||||||
limit?: number
|
|
||||||
orderByCreatedAt?: SQLSortOrder
|
|
||||||
orderByUpdatedAt?: SQLSortOrder
|
|
||||||
fields?: ExtDataField[]
|
|
||||||
}): Promise<ExtData[]> {
|
|
||||||
const beforeCreatedAt = searchParams.beforeCreatedAt
|
|
||||||
? convertDateToSqliteString(searchParams.beforeCreatedAt)
|
|
||||||
: undefined
|
|
||||||
const afterCreatedAt = searchParams.afterCreatedAt
|
|
||||||
? convertDateToSqliteString(searchParams.afterCreatedAt)
|
|
||||||
: undefined
|
|
||||||
return searchExtensionData({
|
|
||||||
...searchParams,
|
|
||||||
searchMode: searchParams.searchMode ?? SearchModeEnum.FTS,
|
|
||||||
extId: this.extId,
|
|
||||||
beforeCreatedAt,
|
|
||||||
afterCreatedAt
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve all data of this extension.
|
|
||||||
* Use `search()` method for more advanced search.
|
|
||||||
* @param options optional fields to retrieve. By default, data and searchText are not returned.
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
retrieveAll(options: { fields?: ExtDataField[] }): Promise<ExtData[]> {
|
|
||||||
return this.search({ fields: options.fields })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve all data of this extension by type.
|
|
||||||
* Use `search()` method for more advanced search.
|
|
||||||
* @param dataType
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
retrieveAllByType(dataType: string): Promise<ExtData[]> {
|
|
||||||
return this.search({ dataType })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete all data of this extension.
|
|
||||||
*/
|
|
||||||
deleteAll(): Promise<void> {
|
|
||||||
return this.search({})
|
|
||||||
.then((items) => {
|
|
||||||
return Promise.all(items.map((item) => this.delete(item.dataId)))
|
|
||||||
})
|
|
||||||
.then(() => {})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update data and searchText of this extension.
|
|
||||||
* @param dataId unique id of the data
|
|
||||||
* @param data
|
|
||||||
* @param searchText
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
async update(data: { dataId: number; data: string; searchText?: string }): Promise<void> {
|
|
||||||
const d = await getExtensionDataById(data.dataId)
|
|
||||||
if (!d || d.extId !== this.extId) {
|
|
||||||
throw new Error("Extension Data not found")
|
|
||||||
}
|
|
||||||
return updateExtensionDataById(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class KV {
|
|
||||||
extId: number
|
|
||||||
db: JarvisExtDB
|
|
||||||
private DataType: string = "kunkun_kv"
|
|
||||||
|
|
||||||
constructor(extId: number) {
|
|
||||||
this.extId = extId
|
|
||||||
this.db = new JarvisExtDB(extId)
|
|
||||||
}
|
|
||||||
|
|
||||||
get<T = string>(key: string): Promise<T | null | undefined> {
|
|
||||||
return this.db
|
|
||||||
.search({
|
|
||||||
dataType: this.DataType,
|
|
||||||
searchText: key,
|
|
||||||
searchMode: SearchModeEnum.ExactMatch,
|
|
||||||
fields: ["search_text", "data"]
|
|
||||||
})
|
|
||||||
.then((items) => {
|
|
||||||
if (items.length === 0) {
|
|
||||||
return null
|
|
||||||
} else if (items.length > 1) {
|
|
||||||
throw new Error("Multiple KVs with the same key")
|
|
||||||
}
|
|
||||||
return items[0].data ? (JSON.parse(items[0].data).value as T) : null
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.warn(err)
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
set(key: string, value: string): Promise<void> {
|
|
||||||
return this.db
|
|
||||||
.search({
|
|
||||||
dataType: this.DataType,
|
|
||||||
searchText: key,
|
|
||||||
searchMode: SearchModeEnum.ExactMatch
|
|
||||||
})
|
|
||||||
.then((items) => {
|
|
||||||
if (items.length === 0) {
|
|
||||||
return this.db.add({
|
|
||||||
data: JSON.stringify({ value: value }),
|
|
||||||
dataType: this.DataType,
|
|
||||||
searchText: key
|
|
||||||
})
|
|
||||||
} else if (items.length === 1) {
|
|
||||||
return this.db.update({
|
|
||||||
dataId: items[0].dataId,
|
|
||||||
data: JSON.stringify({ value: value }),
|
|
||||||
searchText: key
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
return Promise.all(items.map((item) => this.db.delete(item.dataId))).then(() =>
|
|
||||||
Promise.resolve()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(key: string): Promise<void> {
|
|
||||||
return this.db
|
|
||||||
.search({
|
|
||||||
dataType: this.DataType,
|
|
||||||
searchText: key,
|
|
||||||
searchMode: SearchModeEnum.ExactMatch
|
|
||||||
})
|
|
||||||
.then((items) => {
|
|
||||||
return Promise.all(items.map((item) => this.db.delete(item.dataId))).then(() =>
|
|
||||||
Promise.resolve()
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
exists(key: string): Promise<boolean> {
|
|
||||||
return this.db
|
|
||||||
.search({
|
|
||||||
dataType: this.DataType,
|
|
||||||
searchText: key,
|
|
||||||
searchMode: SearchModeEnum.ExactMatch,
|
|
||||||
fields: []
|
|
||||||
})
|
|
||||||
.then((items) => {
|
|
||||||
return items.length > 0
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,8 +5,7 @@ export * from "./tools"
|
|||||||
export * from "./extension"
|
export * from "./extension"
|
||||||
export * from "./system"
|
export * from "./system"
|
||||||
export * from "./store"
|
export * from "./store"
|
||||||
export * as db from "./db"
|
export * as sql from "./sql"
|
||||||
export { JarvisExtDB } from "./db"
|
|
||||||
export * from "./clipboard"
|
export * from "./clipboard"
|
||||||
export * from "./fileSearch"
|
export * from "./fileSearch"
|
||||||
export * from "./utils"
|
export * from "./utils"
|
||||||
|
30
packages/api/src/commands/sql.ts
Normal file
30
packages/api/src/commands/sql.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core"
|
||||||
|
import { generateJarvisPluginCommand } from "./common"
|
||||||
|
|
||||||
|
export interface QueryResult {
|
||||||
|
/** The number of rows affected by the query. */
|
||||||
|
rowsAffected: number
|
||||||
|
/**
|
||||||
|
* The last inserted `id`.
|
||||||
|
*
|
||||||
|
* This value is not set for Postgres databases. If the
|
||||||
|
* last inserted id is required on Postgres, the `select` function
|
||||||
|
* must be used, with a `RETURNING` clause
|
||||||
|
* (`INSERT INTO todos (title) VALUES ($1) RETURNING id`).
|
||||||
|
*/
|
||||||
|
lastInsertId?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export function select(query: string, values: any[]) {
|
||||||
|
return invoke<any[]>(generateJarvisPluginCommand("select"), {
|
||||||
|
query,
|
||||||
|
values
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function execute(query: string, values: any[]) {
|
||||||
|
return invoke<QueryResult>(generateJarvisPluginCommand("execute"), {
|
||||||
|
query,
|
||||||
|
values
|
||||||
|
})
|
||||||
|
}
|
@ -18,10 +18,7 @@ export const Ext = v.object({
|
|||||||
extId: v.number(),
|
extId: v.number(),
|
||||||
identifier: v.string(),
|
identifier: v.string(),
|
||||||
version: v.string(),
|
version: v.string(),
|
||||||
enabled: v.pipe(
|
enabled: v.boolean(),
|
||||||
v.number(),
|
|
||||||
v.transform((input) => Boolean(input))
|
|
||||||
),
|
|
||||||
installedAt: v.string(),
|
installedAt: v.string(),
|
||||||
path: v.optional(v.nullable(v.string())),
|
path: v.optional(v.nullable(v.string())),
|
||||||
data: v.optional(v.any())
|
data: v.optional(v.any())
|
||||||
@ -49,11 +46,9 @@ export const ExtCmd = v.object({
|
|||||||
data: v.string(),
|
data: v.string(),
|
||||||
alias: v.optional(v.nullable(v.string())),
|
alias: v.optional(v.nullable(v.string())),
|
||||||
hotkey: v.optional(v.nullable(v.string())),
|
hotkey: v.optional(v.nullable(v.string())),
|
||||||
enabled: v.pipe(
|
enabled: v.boolean()
|
||||||
v.number(),
|
|
||||||
v.transform((input) => Boolean(input))
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export type ExtCmd = v.InferOutput<typeof ExtCmd>
|
export type ExtCmd = v.InferOutput<typeof ExtCmd>
|
||||||
|
|
||||||
export const QuickLinkCmd = v.object({
|
export const QuickLinkCmd = v.object({
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { enum_, type InferOutput } from "valibot"
|
import * as v from "valibot"
|
||||||
|
|
||||||
export enum SQLSortOrderEnum {
|
export enum SQLSortOrderEnum {
|
||||||
Asc = "ASC",
|
Asc = "ASC",
|
||||||
Desc = "DESC"
|
Desc = "DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SQLSortOrder = enum_(SQLSortOrderEnum)
|
export const SQLSortOrder = v.enum_(SQLSortOrderEnum)
|
||||||
export type SQLSortOrder = InferOutput<typeof SQLSortOrder>
|
export type SQLSortOrder = v.InferOutput<typeof SQLSortOrder>
|
||||||
|
|
||||||
export enum SearchModeEnum {
|
export enum SearchModeEnum {
|
||||||
ExactMatch = "exact_match",
|
ExactMatch = "exact_match",
|
||||||
@ -14,8 +14,8 @@ export enum SearchModeEnum {
|
|||||||
FTS = "fts"
|
FTS = "fts"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SearchMode = enum_(SearchModeEnum)
|
export const SearchMode = v.enum_(SearchModeEnum)
|
||||||
export type SearchMode = InferOutput<typeof SearchMode>
|
export type SearchMode = v.InferOutput<typeof SearchMode>
|
||||||
|
|
||||||
export function convertDateToSqliteString(date: Date) {
|
export function convertDateToSqliteString(date: Date) {
|
||||||
const pad = (num: number) => num.toString().padStart(2, "0")
|
const pad = (num: number) => num.toString().padStart(2, "0")
|
||||||
@ -29,3 +29,6 @@ export function convertDateToSqliteString(date: Date) {
|
|||||||
|
|
||||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ExtDataField = v.union([v.literal("data"), v.literal("search_text")])
|
||||||
|
export type ExtDataField = v.InferOutput<typeof ExtDataField>
|
||||||
|
@ -17,7 +17,8 @@ export const extensions = sqliteTable("extensions", {
|
|||||||
extId: integer("ext_id").primaryKey({ autoIncrement: true }),
|
extId: integer("ext_id").primaryKey({ autoIncrement: true }),
|
||||||
identifier: text().notNull(),
|
identifier: text().notNull(),
|
||||||
version: text().notNull(),
|
version: text().notNull(),
|
||||||
enabled: numeric().default(sql`(TRUE)`),
|
// enabled: numeric().default(sql`(TRUE)`),
|
||||||
|
enabled: integer({ mode: "boolean" }),
|
||||||
path: text(),
|
path: text(),
|
||||||
data: numeric(),
|
data: numeric(),
|
||||||
installedAt: numeric("installed_at").default(sql`(CURRENT_TIMESTAMP)`)
|
installedAt: numeric("installed_at").default(sql`(CURRENT_TIMESTAMP)`)
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * as schema from "./drizzle/schema"
|
export * as schema from "./drizzle/schema"
|
||||||
export * as relations from "./drizzle/relations"
|
export * as relations from "./drizzle/relations"
|
||||||
|
export * as db from "./src/apis"
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts",
|
".": "./index.ts",
|
||||||
|
"./api": "./src/apis.ts",
|
||||||
"./schema": "./drizzle/schema.ts",
|
"./schema": "./drizzle/schema.ts",
|
||||||
"./relations": "./drizzle/relations.ts"
|
"./relations": "./drizzle/relations.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as relations from "@kksh/drizzle/relations"
|
import { KUNKUN_EXT_IDENTIFIER, type IDb, type IKV } from "@kksh/api"
|
||||||
import * as schema from "../drizzle/schema"
|
|
||||||
import {
|
import {
|
||||||
CmdType,
|
CmdType,
|
||||||
|
convertDateToSqliteString,
|
||||||
Ext,
|
Ext,
|
||||||
ExtCmd,
|
ExtCmd,
|
||||||
ExtData,
|
ExtData,
|
||||||
@ -10,44 +10,71 @@ import {
|
|||||||
SQLSortOrder,
|
SQLSortOrder,
|
||||||
SQLSortOrderEnum
|
SQLSortOrderEnum
|
||||||
} from "@kksh/api/models"
|
} from "@kksh/api/models"
|
||||||
|
import * as relations from "@kksh/drizzle/relations"
|
||||||
import * as orm from "drizzle-orm"
|
import * as orm from "drizzle-orm"
|
||||||
import type { SelectedFields } from "drizzle-orm/sqlite-core"
|
import type { SelectedFields } from "drizzle-orm/sqlite-core"
|
||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
|
import * as schema from "../drizzle/schema"
|
||||||
import { db } from "./proxy"
|
import { db } from "./proxy"
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* Built-in Extensions */
|
/* Built-in Extensions */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
export function getExtClipboard() {
|
export function getExtClipboard(): Promise<Ext> {
|
||||||
// return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_CLIPBOARD_EXT_IDENTIFIER)
|
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_CLIPBOARD_EXT_IDENTIFIER)
|
||||||
}
|
}
|
||||||
export function getExtQuickLinks() {
|
export function getExtQuickLinks(): Promise<Ext> {
|
||||||
// return getExtensionByIdentifierExpectExists(
|
return getExtensionByIdentifierExpectExists(
|
||||||
// KUNKUN_EXT_IDENTIFIER.KUNKUN_QUICK_LINKS_EXT_IDENTIFIER
|
KUNKUN_EXT_IDENTIFIER.KUNKUN_QUICK_LINKS_EXT_IDENTIFIER
|
||||||
// )
|
)
|
||||||
}
|
}
|
||||||
export function getExtRemote() {
|
export function getExtRemote(): Promise<Ext> {
|
||||||
// return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_REMOTE_EXT_IDENTIFIER)
|
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_REMOTE_EXT_IDENTIFIER)
|
||||||
}
|
}
|
||||||
export function getExtScriptCmd() {
|
export function getExtScriptCmd(): Promise<Ext> {
|
||||||
// return getExtensionByIdentifierExpectExists(
|
return getExtensionByIdentifierExpectExists(
|
||||||
// KUNKUN_EXT_IDENTIFIER.KUNKUN_SCRIPT_CMD_EXT_IDENTIFIER
|
KUNKUN_EXT_IDENTIFIER.KUNKUN_SCRIPT_CMD_EXT_IDENTIFIER
|
||||||
// )
|
)
|
||||||
}
|
}
|
||||||
export function getExtDev() {
|
export function getExtDev(): Promise<Ext> {
|
||||||
// return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_DEV_EXT_IDENTIFIER)
|
return getExtensionByIdentifierExpectExists(KUNKUN_EXT_IDENTIFIER.KUNKUN_DEV_EXT_IDENTIFIER)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* Extension CRUD */
|
/* Extension CRUD */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
export function createExtension(ext: {
|
||||||
|
identifier: string
|
||||||
|
version: string
|
||||||
|
enabled?: boolean
|
||||||
|
path?: string
|
||||||
|
data?: any
|
||||||
|
}) {
|
||||||
|
return db
|
||||||
|
.insert(schema.extensions)
|
||||||
|
.values({
|
||||||
|
identifier: ext.identifier,
|
||||||
|
version: ext.version,
|
||||||
|
enabled: ext.enabled,
|
||||||
|
path: ext.path,
|
||||||
|
data: ext.data
|
||||||
|
})
|
||||||
|
.run()
|
||||||
|
}
|
||||||
|
|
||||||
export async function getUniqueExtensionByIdentifier(identifier: string): Promise<Ext | undefined> {
|
export async function getUniqueExtensionByIdentifier(identifier: string): Promise<Ext | undefined> {
|
||||||
const ext = await db
|
const ext = await db
|
||||||
.select()
|
.select()
|
||||||
.from(schema.extensions)
|
.from(schema.extensions)
|
||||||
.where(orm.eq(schema.extensions.identifier, identifier))
|
.where(orm.eq(schema.extensions.identifier, identifier))
|
||||||
.get()
|
.get()
|
||||||
return v.parse(v.optional(Ext), ext)
|
const result = v.safeParse(v.optional(Ext), ext)
|
||||||
|
if (!result.success) {
|
||||||
|
console.error("Failed to parse extension:", v.flatten(result.issues))
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const parsed = result.output
|
||||||
|
return parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,20 +138,29 @@ export function deleteExtensionByExtId(extId: number): Promise<void> {
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* Extension Command CRUD */
|
/* Extension Command CRUD */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
export function createCommand(data: {
|
||||||
// export async function getExtensionWithCmdsByIdentifier(identifier: string): Promise<ExtWithCmds> {
|
extId: number
|
||||||
// const ext = await db
|
name: string
|
||||||
// .select({
|
cmdType: CmdType
|
||||||
// ...schema.extensions,
|
data: string
|
||||||
// commands: relations.commandsRelations
|
alias?: string
|
||||||
// })
|
hotkey?: string
|
||||||
// .from(schema.extensions)
|
enabled?: boolean
|
||||||
// .leftJoin(schema.commands, orm.eq(schema.extensions.extId, schema.commands.extId))
|
}) {
|
||||||
// .where(orm.eq(schema.extensions.identifier, identifier))
|
return db
|
||||||
// .get()
|
.insert(schema.commands)
|
||||||
|
.values({
|
||||||
// // return v.parse(v.nullable(ExtWithCmds), ext);
|
extId: data.extId,
|
||||||
// }
|
name: data.name,
|
||||||
|
type: data.cmdType,
|
||||||
|
data: data.data,
|
||||||
|
alias: data.alias,
|
||||||
|
hotkey: data.hotkey,
|
||||||
|
enabled: data.enabled ?? true
|
||||||
|
})
|
||||||
|
.run()
|
||||||
|
.then(() => undefined)
|
||||||
|
}
|
||||||
|
|
||||||
export async function getCmdById(cmdId: number): Promise<ExtCmd> {
|
export async function getCmdById(cmdId: number): Promise<ExtCmd> {
|
||||||
const cmd = await db
|
const cmd = await db
|
||||||
@ -362,28 +398,219 @@ export async function searchExtensionData(searchParams: {
|
|||||||
.filter((item): item is ExtData => item !== undefined)
|
.filter((item): item is ExtData => item !== undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function deleteExtensionDataById(dataId: number) {
|
export function deleteExtensionDataById(dataId: number) {
|
||||||
|
return db
|
||||||
// return invoke<void>(generateJarvisPluginCommand("delete_extension_data_by_id"), { dataId })
|
.delete(schema.extensionData)
|
||||||
|
.where(orm.eq(schema.extensionData.dataId, dataId))
|
||||||
|
.run()
|
||||||
|
.then(() => undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateExtensionDataById(data: {
|
export function updateExtensionDataById(data: {
|
||||||
dataId: number
|
dataId: number
|
||||||
data: string
|
data: string
|
||||||
searchText?: string
|
searchText?: string
|
||||||
}) {
|
}): Promise<void> {
|
||||||
// return invoke<void>(generateJarvisPluginCommand("update_extension_data_by_id"), data)
|
return db
|
||||||
|
.update(schema.extensionData)
|
||||||
|
.set({
|
||||||
|
data: data.data,
|
||||||
|
searchText: data.searchText
|
||||||
|
})
|
||||||
|
.where(orm.eq(schema.extensionData.dataId, data.dataId))
|
||||||
|
.run()
|
||||||
|
.then(() => undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database API for extensions.
|
||||||
|
* Extensions shouldn't have full access to the database, they can only access their own data.
|
||||||
|
* When an extension is loaded, the main thread will create an instance of this class and
|
||||||
|
* expose it to the extension.
|
||||||
|
*/
|
||||||
|
export class JarvisExtDB implements IDb {
|
||||||
|
extId: number
|
||||||
|
|
||||||
// export async function getNCommands(n: number):
|
constructor(extId: number) {
|
||||||
// export function createExtension(ext: {
|
this.extId = extId
|
||||||
// identifier: string
|
}
|
||||||
// version: string
|
|
||||||
// enabled?: boolean
|
async add(data: { data: string; dataType?: string; searchText?: string }): Promise<void> {
|
||||||
// path?: string
|
return createExtensionData({
|
||||||
// data?: any
|
data: data.data,
|
||||||
// }) {
|
dataType: data.dataType ?? "default",
|
||||||
// return invoke<void>(generateJarvisPluginCommand("create_extension"), ext)
|
searchText: data.searchText,
|
||||||
// }
|
extId: this.extId
|
||||||
|
}).then(() => undefined)
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(dataId: number): Promise<void> {
|
||||||
|
// Verify if this data belongs to this extension
|
||||||
|
const d = await getExtensionDataById(dataId)
|
||||||
|
if (!d || d.extId !== this.extId) {
|
||||||
|
throw new Error("Extension Data not found")
|
||||||
|
}
|
||||||
|
return await deleteExtensionDataById(dataId)
|
||||||
|
}
|
||||||
|
|
||||||
|
async search(searchParams: {
|
||||||
|
dataId?: number
|
||||||
|
searchMode?: SearchMode
|
||||||
|
dataType?: string
|
||||||
|
searchText?: string
|
||||||
|
afterCreatedAt?: Date
|
||||||
|
beforeCreatedAt?: Date
|
||||||
|
limit?: number
|
||||||
|
orderByCreatedAt?: SQLSortOrder
|
||||||
|
orderByUpdatedAt?: SQLSortOrder
|
||||||
|
fields?: ExtDataField[]
|
||||||
|
}): Promise<ExtData[]> {
|
||||||
|
const beforeCreatedAt = searchParams.beforeCreatedAt
|
||||||
|
? convertDateToSqliteString(searchParams.beforeCreatedAt)
|
||||||
|
: undefined
|
||||||
|
const afterCreatedAt = searchParams.afterCreatedAt
|
||||||
|
? convertDateToSqliteString(searchParams.afterCreatedAt)
|
||||||
|
: undefined
|
||||||
|
return searchExtensionData({
|
||||||
|
...searchParams,
|
||||||
|
searchMode: searchParams.searchMode ?? SearchModeEnum.FTS,
|
||||||
|
extId: this.extId,
|
||||||
|
beforeCreatedAt,
|
||||||
|
afterCreatedAt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all data of this extension.
|
||||||
|
* Use `search()` method for more advanced search.
|
||||||
|
* @param options optional fields to retrieve. By default, data and searchText are not returned.
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
retrieveAll(options: { fields?: ExtDataField[] }): Promise<ExtData[]> {
|
||||||
|
return this.search({ fields: options.fields })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve all data of this extension by type.
|
||||||
|
* Use `search()` method for more advanced search.
|
||||||
|
* @param dataType
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
retrieveAllByType(dataType: string): Promise<ExtData[]> {
|
||||||
|
return this.search({ dataType })
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all data of this extension.
|
||||||
|
*/
|
||||||
|
deleteAll(): Promise<void> {
|
||||||
|
return this.search({})
|
||||||
|
.then((items) => {
|
||||||
|
return Promise.all(items.map((item) => this.delete(item.dataId)))
|
||||||
|
})
|
||||||
|
.then(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update data and searchText of this extension.
|
||||||
|
* @param dataId unique id of the data
|
||||||
|
* @param data
|
||||||
|
* @param searchText
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async update(data: { dataId: number; data: string; searchText?: string }): Promise<void> {
|
||||||
|
const d = await getExtensionDataById(data.dataId)
|
||||||
|
if (!d || d.extId !== this.extId) {
|
||||||
|
throw new Error("Extension Data not found")
|
||||||
|
}
|
||||||
|
return updateExtensionDataById(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class KV implements IKV {
|
||||||
|
extId: number
|
||||||
|
db: JarvisExtDB
|
||||||
|
private DataType: string = "kunkun_kv"
|
||||||
|
|
||||||
|
constructor(extId: number) {
|
||||||
|
this.extId = extId
|
||||||
|
this.db = new JarvisExtDB(extId)
|
||||||
|
}
|
||||||
|
|
||||||
|
get<T = string>(key: string): Promise<T | null | undefined> {
|
||||||
|
return this.db
|
||||||
|
.search({
|
||||||
|
dataType: this.DataType,
|
||||||
|
searchText: key,
|
||||||
|
searchMode: SearchModeEnum.ExactMatch,
|
||||||
|
fields: ["search_text", "data"]
|
||||||
|
})
|
||||||
|
.then((items) => {
|
||||||
|
if (items.length === 0) {
|
||||||
|
return null
|
||||||
|
} else if (items.length > 1) {
|
||||||
|
throw new Error("Multiple KVs with the same key")
|
||||||
|
}
|
||||||
|
return items[0]?.data ? (JSON.parse(items[0].data).value as T) : null
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn(err)
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key: string, value: string): Promise<void> {
|
||||||
|
return this.db
|
||||||
|
.search({
|
||||||
|
dataType: this.DataType,
|
||||||
|
searchText: key,
|
||||||
|
searchMode: SearchModeEnum.ExactMatch
|
||||||
|
})
|
||||||
|
.then((items) => {
|
||||||
|
if (items.length === 0) {
|
||||||
|
return this.db.add({
|
||||||
|
data: JSON.stringify({ value: value }),
|
||||||
|
dataType: this.DataType,
|
||||||
|
searchText: key
|
||||||
|
})
|
||||||
|
} else if (items.length === 1) {
|
||||||
|
return this.db.update({
|
||||||
|
dataId: items[0]!.dataId,
|
||||||
|
data: JSON.stringify({ value: value }),
|
||||||
|
searchText: key
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.all(items.map((item) => this.db.delete(item.dataId))).then(() =>
|
||||||
|
Promise.resolve()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(key: string): Promise<void> {
|
||||||
|
return this.db
|
||||||
|
.search({
|
||||||
|
dataType: this.DataType,
|
||||||
|
searchText: key,
|
||||||
|
searchMode: SearchModeEnum.ExactMatch
|
||||||
|
})
|
||||||
|
.then((items) => {
|
||||||
|
return Promise.all(items.map((item) => this.db.delete(item.dataId))).then(() =>
|
||||||
|
Promise.resolve()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
exists(key: string): Promise<boolean> {
|
||||||
|
return this.db
|
||||||
|
.search({
|
||||||
|
dataType: this.DataType,
|
||||||
|
searchText: key,
|
||||||
|
searchMode: SearchModeEnum.ExactMatch,
|
||||||
|
fields: []
|
||||||
|
})
|
||||||
|
.then((items) => {
|
||||||
|
return items.length > 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,36 +1,31 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { db as dbCmd } from "@kksh/api/commands"
|
import { sql } from "@kksh/api/commands"
|
||||||
import * as schema from "../drizzle/schema"
|
|
||||||
import { error } from "@tauri-apps/plugin-log"
|
import { error } from "@tauri-apps/plugin-log"
|
||||||
import { drizzle } from "drizzle-orm/sqlite-proxy"
|
import { drizzle } from "drizzle-orm/sqlite-proxy"
|
||||||
|
import * as schema from "../drizzle/schema"
|
||||||
/**
|
|
||||||
* Loads the sqlite database via the Tauri Proxy.
|
|
||||||
*/
|
|
||||||
// export const sqlite = await Database.load("sqlite:test.db");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The drizzle database instance.
|
* The drizzle database instance.
|
||||||
*/
|
*/
|
||||||
export const db = drizzle<typeof schema>(
|
export const db = drizzle<typeof schema>(
|
||||||
async (sql, params, method) => {
|
async (sqlQuery, params, method) => {
|
||||||
let rows: any = []
|
let rows: any = []
|
||||||
let results = []
|
let results = []
|
||||||
console.log({
|
console.log({
|
||||||
sql,
|
sql: sqlQuery,
|
||||||
params,
|
params,
|
||||||
method
|
method
|
||||||
})
|
})
|
||||||
console.log(sql)
|
console.log(sqlQuery)
|
||||||
// If the query is a SELECT, use the select method
|
// If the query is a SELECT, use the select method
|
||||||
if (isSelectQuery(sql)) {
|
if (isSelectQuery(sqlQuery)) {
|
||||||
rows = await dbCmd.select(sql, params).catch((e) => {
|
rows = await sql.select(sqlQuery, params).catch((e) => {
|
||||||
error("SQL Error:", e)
|
error("SQL Error:", e)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, use the execute method
|
// Otherwise, use the execute method
|
||||||
rows = await dbCmd.execute(sql, params).catch((e) => {
|
rows = await sql.execute(sqlQuery, params).catch((e) => {
|
||||||
error("SQL Error:", e)
|
error("SQL Error:", e)
|
||||||
return []
|
return []
|
||||||
})
|
})
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kksh/api": "workspace:*",
|
"@kksh/api": "workspace:*",
|
||||||
|
"@kksh/drizzle": "workspace:*",
|
||||||
"@std/semver": "npm:@jsr/std__semver@^1.0.4",
|
"@std/semver": "npm:@jsr/std__semver@^1.0.4",
|
||||||
"@tauri-apps/plugin-upload": "^2.2.1",
|
"@tauri-apps/plugin-upload": "^2.2.1",
|
||||||
"semver": "^7.7.1",
|
"semver": "^7.7.1",
|
||||||
|
@ -1,14 +1,6 @@
|
|||||||
import { db } from "@kksh/api/commands"
|
import { CmdTypeEnum, ExtPackageJson, Icon, QuickLinkCmd } from "@kksh/api/models"
|
||||||
import {
|
import { db } from "@kksh/drizzle"
|
||||||
CmdTypeEnum,
|
|
||||||
ExtCmd,
|
|
||||||
ExtPackageJson,
|
|
||||||
ExtPackageJsonExtra,
|
|
||||||
Icon,
|
|
||||||
QuickLinkCmd
|
|
||||||
} from "@kksh/api/models"
|
|
||||||
import * as v from "valibot"
|
import * as v from "valibot"
|
||||||
import { isExtPathInDev } from "./utils"
|
|
||||||
|
|
||||||
export async function upsertExtension(extPkgJson: ExtPackageJson, extFullPath: string) {
|
export async function upsertExtension(extPkgJson: ExtPackageJson, extFullPath: string) {
|
||||||
const extInDb = await db.getUniqueExtensionByIdentifier(extPkgJson.kunkun.identifier)
|
const extInDb = await db.getUniqueExtensionByIdentifier(extPkgJson.kunkun.identifier)
|
||||||
@ -39,7 +31,7 @@ export async function createQuickLinkCommand(name: string, link: string, icon: I
|
|||||||
export async function getAllQuickLinkCommands(): Promise<QuickLinkCmd[]> {
|
export async function getAllQuickLinkCommands(): Promise<QuickLinkCmd[]> {
|
||||||
const extension = await db.getExtQuickLinks()
|
const extension = await db.getExtQuickLinks()
|
||||||
const cmds = await db.getCommandsByExtId(extension.extId)
|
const cmds = await db.getCommandsByExtId(extension.extId)
|
||||||
return cmds
|
const parsedCmds = cmds
|
||||||
.map((cmd) => {
|
.map((cmd) => {
|
||||||
try {
|
try {
|
||||||
cmd.data = JSON.parse(cmd.data)
|
cmd.data = JSON.parse(cmd.data)
|
||||||
@ -55,4 +47,5 @@ export async function getAllQuickLinkCommands(): Promise<QuickLinkCmd[]> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter((cmd) => cmd !== null)
|
.filter((cmd) => cmd !== null)
|
||||||
|
return parsedCmds
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
* including install, uninstall, upgrade, check app-extension compatibility, etc.
|
* including install, uninstall, upgrade, check app-extension compatibility, etc.
|
||||||
*/
|
*/
|
||||||
import { isCompatible } from "@kksh/api"
|
import { isCompatible } from "@kksh/api"
|
||||||
import { copy_dir_all, db, decompressTarball } from "@kksh/api/commands"
|
import { copy_dir_all, decompressTarball } from "@kksh/api/commands"
|
||||||
import type { ExtensionStoreListItem, ExtPackageJsonExtra } from "@kksh/api/models"
|
import type { ExtensionStoreListItem, ExtPackageJsonExtra } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { greaterThan, parse as parseSemver } from "@std/semver"
|
import { greaterThan, parse as parseSemver } from "@std/semver"
|
||||||
import * as path from "@tauri-apps/api/path"
|
import * as path from "@tauri-apps/api/path"
|
||||||
import * as dialog from "@tauri-apps/plugin-dialog"
|
import * as dialog from "@tauri-apps/plugin-dialog"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { db } from "@kksh/api/commands"
|
|
||||||
import { ExtPackageJson, ExtPackageJsonExtra, License } from "@kksh/api/models"
|
import { ExtPackageJson, ExtPackageJsonExtra, License } from "@kksh/api/models"
|
||||||
|
import { db } from "@kksh/drizzle"
|
||||||
import { basename, dirname, join } from "@tauri-apps/api/path"
|
import { basename, dirname, join } from "@tauri-apps/api/path"
|
||||||
import { readDir, readTextFile } from "@tauri-apps/plugin-fs"
|
import { readDir, readTextFile } from "@tauri-apps/plugin-fs"
|
||||||
import { debug, error } from "@tauri-apps/plugin-log"
|
import { debug, error } from "@tauri-apps/plugin-log"
|
||||||
@ -77,7 +77,7 @@ export function loadAllExtensionsFromDisk(
|
|||||||
* @returns loaded extensions
|
* @returns loaded extensions
|
||||||
*/
|
*/
|
||||||
export async function loadAllExtensionsFromDb(): Promise<ExtPackageJsonExtra[]> {
|
export async function loadAllExtensionsFromDb(): Promise<ExtPackageJsonExtra[]> {
|
||||||
const allDbExts = await (await db.getAllExtensions()).filter((ext) => ext.path)
|
const allDbExts = (await db.getAllExtensions()).filter((ext) => ext.path)
|
||||||
const results: ExtPackageJsonExtra[] = []
|
const results: ExtPackageJsonExtra[] = []
|
||||||
for (const ext of allDbExts) {
|
for (const ext of allDbExts) {
|
||||||
if (!ext.path) continue
|
if (!ext.path) continue
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
## Permission Table
|
## Permission Table
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
@ -7,7 +6,6 @@
|
|||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import autoAnimate from "@formkit/auto-animate"
|
|
||||||
import Icon from "@iconify/svelte"
|
import Icon from "@iconify/svelte"
|
||||||
import { Button, ButtonModule, Collapsible, ScrollArea } from "@kksh/svelte5"
|
import { Button, ButtonModule, Collapsible, ScrollArea } from "@kksh/svelte5"
|
||||||
import { Error, Layouts, Shiki } from "@kksh/ui"
|
import { Error, Layouts, Shiki } from "@kksh/ui"
|
||||||
import { ChevronsUpDown } from "lucide-svelte"
|
import { ChevronsUpDown } from "lucide-svelte"
|
||||||
import { type Snippet } from "svelte"
|
import { type Snippet } from "svelte"
|
||||||
import { fade, slide } from "svelte/transition"
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
title,
|
title,
|
||||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -588,6 +588,9 @@ importers:
|
|||||||
'@kksh/api':
|
'@kksh/api':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../api
|
version: link:../api
|
||||||
|
'@kksh/drizzle':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../drizzle
|
||||||
'@std/semver':
|
'@std/semver':
|
||||||
specifier: npm:@jsr/std__semver@^1.0.4
|
specifier: npm:@jsr/std__semver@^1.0.4
|
||||||
version: '@jsr/std__semver@1.0.3'
|
version: '@jsr/std__semver@1.0.3'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user