diff --git a/apps/desktop/src/lib/constants.ts b/apps/desktop/src/lib/constants.ts index 686f993..51c078d 100644 --- a/apps/desktop/src/lib/constants.ts +++ b/apps/desktop/src/lib/constants.ts @@ -1,10 +1,10 @@ import { appIsDev } from "@kksh/api/commands" import { appDataDir, join } from "@tauri-apps/api/path" import * as fs from "@tauri-apps/plugin-fs" -import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_PROJECT_ID } from "$env/static/public" +import { PUBLIC_SUPABASE_ANON_KEY, PUBLIC_SUPABASE_URL } from "$env/static/public" export const SUPABASE_ANON_KEY = PUBLIC_SUPABASE_ANON_KEY -export const SUPABASE_URL = `https://${PUBLIC_SUPABASE_PROJECT_ID}.supabase.co` +export const SUPABASE_URL = PUBLIC_SUPABASE_URL export const SUPABASE_GRAPHQL_ENDPOINT = `${SUPABASE_URL}/graphql/v1` export function getExtensionsFolder() { return appDataDir() diff --git a/apps/desktop/src/lib/supabase.ts b/apps/desktop/src/lib/supabase.ts index a9927cd..e7041e7 100644 --- a/apps/desktop/src/lib/supabase.ts +++ b/apps/desktop/src/lib/supabase.ts @@ -1,7 +1,19 @@ -import { createSB, SupabaseAPI } from "@kksh/supabase" +import { SupabaseAPI } from "@kksh/supabase/api" +import type { Database } from "@kksh/supabase/types" +import { createClient, SupabaseClient } from "@supabase/supabase-js" import { SUPABASE_ANON_KEY, SUPABASE_URL } from "./constants" -export const supabase = createSB(SUPABASE_URL, SUPABASE_ANON_KEY) +// export const supabase = createSB(SUPABASE_URL, SUPABASE_ANON_KEY) +export const supabase: SupabaseClient = createClient( + SUPABASE_URL, + SUPABASE_ANON_KEY, + { + auth: { + flowType: "pkce" + } + } +) + export const storage = supabase.storage export const supabaseExtensionsStorage = supabase.storage.from("extensions") export const supabaseAPI = new SupabaseAPI(supabase) diff --git a/apps/desktop/src/routes/app/+page.svelte b/apps/desktop/src/routes/app/+page.svelte index 763dba1..69abce8 100644 --- a/apps/desktop/src/routes/app/+page.svelte +++ b/apps/desktop/src/routes/app/+page.svelte @@ -37,8 +37,12 @@ let inputEle: HTMLInputElement | null = $state(null) function onKeyDown(event: KeyboardEvent) { if (event.key === "Escape") { - ;(event.target as HTMLInputElement).value = "" - $appState.searchTerm = "" + if ((event.target as HTMLInputElement).value === "") { + getCurrentWindow().hide() + } else { + ;(event.target as HTMLInputElement).value = "" + $appState.searchTerm = "" + } } } diff --git a/apps/desktop/src/routes/app/extension/store/+page.svelte b/apps/desktop/src/routes/app/extension/store/+page.svelte index fb8e2a7..ae6f15d 100644 --- a/apps/desktop/src/routes/app/extension/store/+page.svelte +++ b/apps/desktop/src/routes/app/extension/store/+page.svelte @@ -4,8 +4,9 @@ import { supabaseAPI } from "@/supabase" import { goBackOnEscapeClearSearchTerm, goHomeOnEscapeClearSearchTerm } from "@/utils/key" import { goBack, goHome } from "@/utils/route" - import { SBExt, type Tables } from "@kksh/supabase" + import { SBExt } from "@kksh/supabase/models" import type { ExtPublishMetadata } from "@kksh/supabase/models" + import { type Tables } from "@kksh/supabase/types" import { Button, Command } from "@kksh/svelte5" import { Constants } from "@kksh/ui" import { ExtListItem } from "@kksh/ui/extension" diff --git a/apps/desktop/src/routes/app/extension/store/+page.ts b/apps/desktop/src/routes/app/extension/store/+page.ts index 41e0ff3..c34e63f 100644 --- a/apps/desktop/src/routes/app/extension/store/+page.ts +++ b/apps/desktop/src/routes/app/extension/store/+page.ts @@ -2,7 +2,7 @@ import { appConfig, extensions, installedStoreExts } from "@/stores" import { supabaseAPI } from "@/supabase" import type { ExtPackageJsonExtra } from "@kksh/api/models" import { isExtPathInDev, isUpgradable } from "@kksh/extension" -import { SBExt } from "@kksh/supabase" +import { SBExt } from "@kksh/supabase/models" import { error } from "@sveltejs/kit" import { derived, get, type Readable } from "svelte/store" import type { PageLoad } from "./$types" diff --git a/apps/desktop/src/routes/app/extension/store/[identifier]/+page.svelte b/apps/desktop/src/routes/app/extension/store/[identifier]/+page.svelte index 60fc9f4..82c5e3e 100644 --- a/apps/desktop/src/routes/app/extension/store/[identifier]/+page.svelte +++ b/apps/desktop/src/routes/app/extension/store/[identifier]/+page.svelte @@ -19,15 +19,18 @@ import { getInstallExtras } from "./helper.js" const { data } = $props() - const ext: Tables<"ext_publish"> & { metadata: ExtPublishMetadata } = $derived(data.ext) + const extPublish: Tables<"ext_publish"> & { metadata: ExtPublishMetadata } = $derived( + data.extPublish + ) + const ext: Tables<"extensions"> = $derived(data.ext) const manifest = $derived(data.manifest) const installedExt = storeDerived(installedStoreExts, ($e) => { - return $e.find((e) => e.kunkun.identifier === ext.identifier) + return $e.find((e) => e.kunkun.identifier === extPublish.identifier) }) const isUpgradable = $derived( $installedExt - ? greaterThan(parseSemver(ext.version), parseSemver($installedExt.version)) + ? greaterThan(parseSemver(extPublish.version), parseSemver($installedExt.version)) : false ) $effect(() => { @@ -67,30 +70,30 @@ }) const demoImages = $derived( - ext.demo_images.map((src) => supabaseAPI.translateExtensionFilePathToUrl(src)) + extPublish.demo_images.map((src) => supabaseAPI.translateExtensionFilePathToUrl(src)) ) async function onInstallSelected() { loading.install = true - const tarballUrl = ext.tarball_path.startsWith("http") - ? ext.tarball_path - : supabaseAPI.translateExtensionFilePathToUrl(ext.tarball_path) - const installExtras = await getInstallExtras(ext) + const tarballUrl = extPublish.tarball_path.startsWith("http") + ? extPublish.tarball_path + : supabaseAPI.translateExtensionFilePathToUrl(extPublish.tarball_path) + const installExtras = await getInstallExtras(extPublish) const installDir = await getExtensionsFolder() return extensions .installFromTarballUrl(tarballUrl, installDir, installExtras) - .then(() => toast.success(`Plugin ${ext.name} Installed`)) + .then(() => toast.success(`Plugin ${extPublish.name} Installed`)) .then((loadedExt) => { - info(`Successfully installed ${ext.name}`) + info(`Successfully installed ${extPublish.name}`) supabaseAPI.incrementDownloads({ - identifier: ext.identifier, - version: ext.version + identifier: extPublish.identifier, + version: extPublish.version }) showBtn.install = false showBtn.uninstall = true }) .catch((err) => { - error(`Fail to install tarball (${ext.identifier}): ${err}`) + error(`Fail to install tarball (${extPublish.identifier}): ${err}`) toast.error("Fail to install tarball", { description: err }) }) .finally(() => { @@ -100,11 +103,13 @@ function onUpgradeSelected() { loading.upgrade = true - const tarballUrl = supabaseAPI.translateExtensionFilePathToUrl(ext.tarball_path) + const tarballUrl = supabaseAPI.translateExtensionFilePathToUrl(extPublish.tarball_path) return extensions - .upgradeStoreExtension(ext.identifier, tarballUrl) + .upgradeStoreExtension(extPublish.identifier, tarballUrl) .then((newExt) => { - toast.success(`${ext.name} Upgraded from ${$installedExt?.version} to ${newExt.version}`) + toast.success( + `${extPublish.name} Upgraded from ${$installedExt?.version} to ${newExt.version}` + ) }) .catch((err) => { toast.error("Fail to upgrade extension", { description: err }) @@ -121,7 +126,7 @@ function onUninstallSelected() { loading.uninstall = true return extensions - .uninstallStoreExtensionByIdentifier(ext.identifier) + .uninstallStoreExtensionByIdentifier(extPublish.identifier) .then((uninstalledExt) => { toast.success(`${uninstalledExt.name} Uninstalled`) loading.uninstall = false @@ -130,7 +135,7 @@ }) .catch((err) => { toast.error("Fail to uninstall extension", { description: err }) - error(`Fail to uninstall store extension (${ext.identifier}): ${err}`) + error(`Fail to uninstall store extension (${extPublish.identifier}): ${err}`) }) .finally(() => {}) } @@ -162,6 +167,7 @@ & { metadata: ExtPublishMetadata } + extPublish: Tables<"ext_publish"> & { metadata: ExtPublishMetadata } + ext: Tables<"extensions"> manifest: KunkunExtManifest params: { identifier: string } }> => { - const { error: dbError, data: ext } = await supabaseAPI.getLatestExtPublish(params.identifier) - const metadataParse = v.safeParse(ExtPublishMetadata, ext?.metadata ?? {}) + const { error: dbError, data: extPublish } = await supabaseAPI.getLatestExtPublish( + params.identifier + ) + const metadataParse = v.safeParse(ExtPublishMetadata, extPublish?.metadata ?? {}) if (dbError) { return error(400, { message: dbError.message }) } const metadata = metadataParse.success ? metadataParse.output : {} - const parseManifest = v.safeParse(KunkunExtManifest, ext.manifest) + const parseManifest = v.safeParse(KunkunExtManifest, extPublish.manifest) if (!parseManifest.success) { const errMsg = "Invalid extension manifest, you may need to upgrade your app." toast.error(errMsg) throw error(400, errMsg) } + const { data: ext, error: extError } = await supabaseAPI.getExtension(params.identifier) + if (extError) { + return error(400, { + message: extError.message + }) + } + return { - ext: { ...ext, metadata }, + extPublish: { ...extPublish, metadata }, + ext, params, manifest: parseManifest.output } diff --git a/packages/api/src/models/manifest.ts b/packages/api/src/models/manifest.ts index 2929a6f..058639a 100644 --- a/packages/api/src/models/manifest.ts +++ b/packages/api/src/models/manifest.ts @@ -139,10 +139,35 @@ const Person = v.union([ }), v.string("GitHub Username") ]) - +export const License = v.union([ + v.literal("AGPL-3.0-only"), + v.literal("Apache-2.0"), + v.literal("BSD-2-Clause"), + v.literal("BSD-3-Clause"), + v.literal("BSL-1.0"), + v.literal("CC0-1.0"), + v.literal("CDDL-1.0"), + v.literal("CDDL-1.1"), + v.literal("EPL-1.0"), + v.literal("EPL-2.0"), + v.literal("GPL-2.0-only"), + v.literal("GPL-3.0-only"), + v.literal("ISC"), + v.literal("LGPL-2.0-only"), + v.literal("LGPL-2.1-only"), + v.literal("LGPL-2.1-or-later"), + v.literal("LGPL-3.0-only"), + v.literal("LGPL-3.0-or-later"), + v.literal("MIT"), + v.literal("MPL-2.0"), + v.literal("MS-PL"), + v.literal("UNLICENSED") +]) +export type License = v.InferOutput export const ExtPackageJson = v.object({ name: v.string("Package name for the extension (just a regular npm package name)"), version: v.string("Version of the extension"), + license: License, author: v.optional(Person), draft: v.optional(v.boolean("Whether the extension is a draft, draft will not be published")), contributors: v.optional(v.array(Person, "Contributors of the extension")), diff --git a/packages/ci/scripts/init-env.ts b/packages/ci/scripts/init-env.ts index 3b4338c..88ef2d0 100644 --- a/packages/ci/scripts/init-env.ts +++ b/packages/ci/scripts/init-env.ts @@ -5,27 +5,34 @@ import { writeFileSync } from "fs" import { join } from "path" import { REPO_ROOT } from "@/path" +import * as v from "valibot" console.log("Init Env") const defaultEnvUrl = `https://storage.kunkun.sh/env.json` const res = await fetch(defaultEnvUrl) -const env = await res.json() +const env = v.parse( + v.object({ + SUPABASE_URL: v.string(), + SUPABASE_ANON_KEY: v.string() + }), + await res.json() +) let envContent = "" if (!process.env.SUPABASE_ANON_KEY) { process.env.SUPABASE_ANON_KEY = env.SUPABASE_ANON_KEY } -if (!process.env.SUPABASE_PROJECT_ID) { - process.env.SUPABASE_PROJECT_ID = env.SUPABASE_PROJECT_ID +if (!process.env.SUPABASE_URL) { + process.env.SUPABASE_URL = env.SUPABASE_URL } if (process.env.SUPABASE_ANON_KEY) { envContent += `SUPABASE_ANON_KEY=${process.env.SUPABASE_ANON_KEY}\n` } -if (process.env.SUPABASE_PROJECT_ID) { - const supabaseUrl = `https://${process.env.SUPABASE_PROJECT_ID}.supabase.co` +if (process.env.SUPABASE_URL) { + const supabaseUrl = process.env.SUPABASE_URL const supabaseGraphqlEndpoint = `${supabaseUrl}/graphql/v1` envContent += ` SUPABASE_GRAPHQL_ENDPOINT=${supabaseGraphqlEndpoint} @@ -47,7 +54,7 @@ writeFileSync( join(REPO_ROOT, "apps/desktop/.env"), ` PUBLIC_SUPABASE_ANON_KEY=${process.env.SUPABASE_ANON_KEY} -PUBLIC_SUPABASE_PROJECT_ID=${process.env.SUPABASE_PROJECT_ID} +PUBLIC_SUPABASE_URL=${process.env.SUPABASE_URL} ` ) // writeFileSync(join(__dirname, "../packages/gql/.env"), envContent) diff --git a/packages/extension/src/install.ts b/packages/extension/src/install.ts index 1ff4ffd..4a01c3b 100644 --- a/packages/extension/src/install.ts +++ b/packages/extension/src/install.ts @@ -5,7 +5,7 @@ import { isCompatible } from "@kksh/api" import { db, decompressTarball } from "@kksh/api/commands" import type { ExtPackageJsonExtra } from "@kksh/api/models" -import { SBExt } from "@kksh/supabase" +import { SBExt } from "@kksh/supabase/models" import { greaterThan, parse as parseSemver } from "@std/semver" import * as path from "@tauri-apps/api/path" import * as dialog from "@tauri-apps/plugin-dialog" diff --git a/packages/extension/src/load.ts b/packages/extension/src/load.ts index 76c53e1..9ff330d 100644 --- a/packages/extension/src/load.ts +++ b/packages/extension/src/load.ts @@ -1,11 +1,16 @@ import { db } from "@kksh/api/commands" -import { ExtPackageJson, ExtPackageJsonExtra } from "@kksh/api/models" +import { ExtPackageJson, ExtPackageJsonExtra, License } from "@kksh/api/models" import { basename, dirname, join } from "@tauri-apps/api/path" import { readDir, readTextFile } from "@tauri-apps/plugin-fs" import { debug, error } from "@tauri-apps/plugin-log" import * as v from "valibot" import { upsertExtension } from "./db" +const OptionalExtPackageJson = v.object({ + ...ExtPackageJson.entries, + license: v.optional(License, "MIT") // TODO: remove this optional package json later +}) + /** * * @param manifestPath absolute path to package.json @@ -15,10 +20,10 @@ export function loadExtensionManifestFromDisk(manifestPath: string): Promise { const json = JSON.parse(content) - const parse = v.safeParse(ExtPackageJson, json) + const parse = v.safeParse(OptionalExtPackageJson, json) if (parse.issues) { error(`Fail to load extension from ${manifestPath}. See console for parse error.`) - console.error("Parse Error:", v.flatten(parse.issues)) + console.error("Parse Error:", v.flatten(parse.issues)) throw new Error(`Invalid manifest: ${manifestPath}`) } else { // debug(`Loaded extension ${parse.output.kunkun.identifier} from ${manifestPath}`) diff --git a/packages/extensions/demo-worker-template-ext/package.json b/packages/extensions/demo-worker-template-ext/package.json index 76f309b..b2ab18a 100644 --- a/packages/extensions/demo-worker-template-ext/package.json +++ b/packages/extensions/demo-worker-template-ext/package.json @@ -3,6 +3,7 @@ "name": "demo-template-extension", "version": "0.0.5", "type": "module", + "license": "MIT", "kunkun": { "name": "Demo Template Extension", "shortDescription": "Demo Template Extension", diff --git a/packages/extensions/ext-sveltekit-exp/package.json b/packages/extensions/ext-sveltekit-exp/package.json index 6112cad..80657cd 100644 --- a/packages/extensions/ext-sveltekit-exp/package.json +++ b/packages/extensions/ext-sveltekit-exp/package.json @@ -2,7 +2,7 @@ "$schema": "https://schema.kunkun.sh", "name": "ext-sveltekit-exp", "version": "0.0.5", - "private": true, + "license": "MIT", "kunkun": { "name": "TODO: Change Display Name", "shortDescription": "A Custom UI template for sveltekit", diff --git a/packages/extensions/form-view/package.json b/packages/extensions/form-view/package.json index bb71d28..4bafaa8 100644 --- a/packages/extensions/form-view/package.json +++ b/packages/extensions/form-view/package.json @@ -3,6 +3,7 @@ "name": "form-view", "version": "0.0.4", "type": "module", + "license": "MIT", "kunkun": { "name": "Form View", "shortDescription": "A Worker Extension Template", diff --git a/packages/package-registry/src/jsr/__tests__/api.test.ts b/packages/package-registry/src/jsr/__tests__/api.test.ts index daec706..ea97b02 100644 --- a/packages/package-registry/src/jsr/__tests__/api.test.ts +++ b/packages/package-registry/src/jsr/__tests__/api.test.ts @@ -52,7 +52,7 @@ describe("Test the helper functions", () => { const packageJson = await getJsrPackageSrcFile( "kunkun", "ext-image-processing", - "0.0.6", + "0.0.20", "package.json" ) expect(packageJson).toBeDefined() diff --git a/packages/package-registry/src/jsr/__tests__/ext-pkg.test.ts b/packages/package-registry/src/jsr/__tests__/ext-pkg.test.ts index 7442645..d2e9a50 100644 --- a/packages/package-registry/src/jsr/__tests__/ext-pkg.test.ts +++ b/packages/package-registry/src/jsr/__tests__/ext-pkg.test.ts @@ -66,13 +66,13 @@ describe("Validate Jsr package as Kunkun extension", () => { jsrPackage: { scope: "kunkun", name: "ext-image-processing", - version: "0.0.18" + version: "0.0.20" }, githubUsername: "HuakunShen" }) expect(res.data).toBeDefined() - expect(res.data?.rekorLogIndex).toBe("161854127") - expect(res.data?.github.commit).toBe("4db8d65b5e3fa115da6e31bd945f5c610c4a21cb") + expect(res.data?.rekorLogIndex).toBe("163385336") + expect(res.data?.github.commit).toBe("56fb480efbcb4497fa5483d4a660a82f83dc8ac3") expect(res.data?.github.owner).toBe("kunkunsh") expect(res.data?.github.repo).toBe("kunkun-ext-image-processing") // expect(res.data?.github.githubActionInvocationId).toBe("48b7dff528bc6a175ce9ee99e6d8de0c718e70a0") diff --git a/packages/package-registry/src/jsr/index.ts b/packages/package-registry/src/jsr/index.ts index 8f2d0e8..6f53236 100644 --- a/packages/package-registry/src/jsr/index.ts +++ b/packages/package-registry/src/jsr/index.ts @@ -4,7 +4,7 @@ import { getPackageVersion, type GitHubRepository } from "@huakunshen/jsr-client/hey-api-client" -import { ExtPackageJson } from "@kksh/api/models" +import { ExtPackageJson, License } from "@kksh/api/models" import * as v from "valibot" import { authenticatedUserIsMemberOfGitHubOrg, userIsPublicMemberOfGitHubOrg } from "../github" import type { ExtensionPublishValidationData } from "../models" @@ -300,6 +300,15 @@ export async function validateJsrPackageAsKunkunExtension(payload: { } catch (error) { return { error: "Failed to parse package.json" } } + if (!packageJson.license) { + return { error: "Package license field is not found" } + } + + const licenseParsed = v.safeParse(License, packageJson.license) + if (!licenseParsed.success) { + return { error: `Package license field ${packageJson.license} is not valid` } + } + if (packageJson.version !== payload.jsrPackage.version) { // no need to fetch jsr.json or deno.json content, as we already know the version is valid with JSR API return { @@ -349,6 +358,7 @@ export async function validateJsrPackageAsKunkunExtension(payload: { data: { pkgJson: parseResult.output, tarballUrl, + license: parseResult.output.license, shasum, apiVersion, tarballSize, diff --git a/packages/package-registry/src/models.ts b/packages/package-registry/src/models.ts index 17fb69e..3614bba 100644 --- a/packages/package-registry/src/models.ts +++ b/packages/package-registry/src/models.ts @@ -1,4 +1,4 @@ -import { ExtPackageJson } from "@kksh/api/models" +import { ExtPackageJson, License } from "@kksh/api/models" import * as v from "valibot" export const RawRekorLogEntry = v.object({ @@ -66,6 +66,7 @@ export const ExtensionPublishValidationData = v.object({ apiVersion: v.string(), rekorLogIndex: v.string(), tarballSize: v.number(), + license: License, github: v.object({ githubActionInvocationId: v.string(), commit: v.string(), diff --git a/packages/package-registry/src/npm/__tests__/ext.test.ts b/packages/package-registry/src/npm/__tests__/ext.test.ts index 898f8b4..f592405 100644 --- a/packages/package-registry/src/npm/__tests__/ext.test.ts +++ b/packages/package-registry/src/npm/__tests__/ext.test.ts @@ -5,13 +5,13 @@ describe("validate kunkun extension", () => { test("A working extension", async () => { const res = await validateNpmPackageAsKunkunExtension({ pkgName: "kunkun-ext-ossinsight", - version: "0.0.1", + version: "0.0.4", githubUsername: "huakunshen" }) expect(res.error).toBeUndefined() - expect(res.data?.github.commit).toBe("8af7eced43a5d240fa3390c7e297178ecb63c344") + expect(res.data?.github.commit).toBe("50b8de4b8801d1c9fa55eb44ff678cd1b3370691") expect(res.data?.github.owner).toBe("kunkunsh") - expect(res.data?.rekorLogIndex).toBe("162214778") + expect(res.data?.rekorLogIndex).toBe("163394172") expect(res.data?.github.repo).toBe("kunkun-ext-ossinsight") }) @@ -32,7 +32,7 @@ describe("validate kunkun extension", () => { ( await validateNpmPackageAsKunkunExtension({ pkgName: "kunkun-ext-ossinsight", - version: "0.0.1", + version: "0.0.4", githubUsername: "huakun" }) ).error diff --git a/packages/package-registry/src/npm/index.ts b/packages/package-registry/src/npm/index.ts index 94c5dcb..cfcf455 100644 --- a/packages/package-registry/src/npm/index.ts +++ b/packages/package-registry/src/npm/index.ts @@ -1,4 +1,4 @@ -import { ExtPackageJson } from "@kksh/api/models" +import { ExtPackageJson, License } from "@kksh/api/models" import * as v from "valibot" import { authenticatedUserIsMemberOfGitHubOrg, @@ -196,6 +196,15 @@ export async function validateNpmPackageAsKunkunExtension(payload: { return { error: "Could not find package.json in NPM package" } } + if (!packageJson.license) { + return { error: "Package license field is not found" } + } + + const licenseParsed = v.safeParse(License, packageJson.license) + if (!licenseParsed.success) { + return { error: `Package license field ${packageJson.license} is not valid` } + } + const parseResult = v.safeParse(ExtPackageJson, packageJson) if (!parseResult.success) { console.log(v.flatten(parseResult.issues)) @@ -223,6 +232,7 @@ export async function validateNpmPackageAsKunkunExtension(payload: { return { data: { pkgJson: parseResult.output, + license: licenseParsed.output, tarballUrl, shasum, apiVersion, diff --git a/packages/schema/package.json b/packages/schema/package.json index 6665278..ecb0a1e 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -15,7 +15,9 @@ }, "devDependencies": { "@types/bun": "latest", - "@valibot/to-json-schema": "1.0.0-beta.3" + "@kksh/supabase": "workspace:*", + "@supabase/supabase-js": "^2.47.16", + "@valibot/to-json-schema": "1.0.0-beta.4" }, "peerDependencies": { "@kksh/supabase": "workspace:*", diff --git a/packages/schema/scripts/upload-schema-to-supabase.ts b/packages/schema/scripts/upload-schema-to-supabase.ts index 3ace1d8..09b56d8 100644 --- a/packages/schema/scripts/upload-schema-to-supabase.ts +++ b/packages/schema/scripts/upload-schema-to-supabase.ts @@ -1,10 +1,11 @@ import { ExtPackageJson } from "@kksh/api/models" -import { createSB } from "@kksh/supabase" +import { type Database } from "@kksh/supabase/types" +import { createClient } from "@supabase/supabase-js" import { parse, string } from "valibot" import * as v from "valibot" import { getJsonSchema } from "../src" -const supabase = createSB( +const supabase = createClient( parse(string(), process.env.SUPABASE_URL), parse(string(), process.env.SUPABASE_SERVICE_ROLE_KEY) ) diff --git a/packages/supabase/package.json b/packages/supabase/package.json index a474856..f6cbe6c 100644 --- a/packages/supabase/package.json +++ b/packages/supabase/package.json @@ -6,6 +6,7 @@ }, "exports": { ".": "./src/index.ts", + "./api": "./src/api.ts", "./models": "./src/models.ts", "./types": "./src/database.types.ts" }, diff --git a/packages/supabase/src/api.ts b/packages/supabase/src/api.ts index 68e0ecb..710d378 100644 --- a/packages/supabase/src/api.ts +++ b/packages/supabase/src/api.ts @@ -42,6 +42,15 @@ export class SupabaseAPI { .single() } + getExtension(identifier: string) { + return this.supabase + .from("extensions") + .select("*") + .eq("identifier", identifier) + .limit(1) + .single() + } + async incrementDownloads({ identifier, version diff --git a/packages/supabase/src/index.ts b/packages/supabase/src/index.ts index 75bdcf2..a6cf570 100644 --- a/packages/supabase/src/index.ts +++ b/packages/supabase/src/index.ts @@ -1,14 +1,10 @@ import { createClient } from "@supabase/supabase-js" import type { Database } from "./database.types" -export function createSB(supabaseUrl: string, supabaseAnonKey: string) { - return createClient(supabaseUrl, supabaseAnonKey, { - auth: { - flowType: "pkce" - } - }) -} -export { SupabaseAPI } from "./api" - -export type { Database, Tables } from "./database.types" -export { SBExt } from "./models" +// export function createSB(supabaseUrl: string, supabaseAnonKey: string) { +// return createClient(supabaseUrl, supabaseAnonKey, { +// auth: { +// flowType: "pkce" +// } +// }) +// } diff --git a/packages/tauri-plugins/jarvis/package.json b/packages/tauri-plugins/jarvis/package.json index b297fa5..24694a7 100644 --- a/packages/tauri-plugins/jarvis/package.json +++ b/packages/tauri-plugins/jarvis/package.json @@ -7,10 +7,11 @@ }, "devDependencies": { "@kksh/supabase": "workspace:*", + "@supabase/supabase-js": "^2.47.16", "@kksh/ci": "workspace:*", "@types/bun": "latest" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "^5.7.3" } } diff --git a/packages/tauri-plugins/jarvis/permissions/autogenerated/reference.md b/packages/tauri-plugins/jarvis/permissions/autogenerated/reference.md index 7020b75..19f9805 100644 --- a/packages/tauri-plugins/jarvis/permissions/autogenerated/reference.md +++ b/packages/tauri-plugins/jarvis/permissions/autogenerated/reference.md @@ -1,3 +1,4 @@ + ## Permission Table @@ -6,6 +7,7 @@ +
Description
diff --git a/packages/tauri-plugins/jarvis/setup.ts b/packages/tauri-plugins/jarvis/setup.ts index 83fd076..b91d3f9 100644 --- a/packages/tauri-plugins/jarvis/setup.ts +++ b/packages/tauri-plugins/jarvis/setup.ts @@ -1,11 +1,12 @@ import { writeFileSync } from "fs" -import { createSB } from "@kksh/supabase" +import { type Database } from "@kksh/supabase/types" +import { createClient } from "@supabase/supabase-js" if (!process.env.SUPABASE_URL || !process.env.SUPABASE_ANON_KEY) { throw new Error("SUPABASE_URL and SUPABASE_ANON_KEY must be set") } -const supabase = createSB(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY) +const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_ANON_KEY) const { data, error } = await supabase.storage.from("pub").download("server_public_key.pem") if (error) { diff --git a/packages/templates/template-ext-headless/package.json b/packages/templates/template-ext-headless/package.json index 517d19d..a64f586 100644 --- a/packages/templates/template-ext-headless/package.json +++ b/packages/templates/template-ext-headless/package.json @@ -2,6 +2,7 @@ "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-headless", "version": "0.0.4", + "license": "MIT", "type": "module", "kunkun": { "name": "TODO: Extension Display Name", diff --git a/packages/templates/template-ext-next/package.json b/packages/templates/template-ext-next/package.json index 575059c..84023c3 100644 --- a/packages/templates/template-ext-next/package.json +++ b/packages/templates/template-ext-next/package.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-next", "version": "0.1.3", - "private": true, + "license": "MIT", "kunkun": { "name": "TODO: Change Display Name", "shortDescription": "A Custom UI template for next", diff --git a/packages/templates/template-ext-nuxt/package.json b/packages/templates/template-ext-nuxt/package.json index 59cd565..85e97e2 100644 --- a/packages/templates/template-ext-nuxt/package.json +++ b/packages/templates/template-ext-nuxt/package.json @@ -2,8 +2,8 @@ "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-nuxt", "version": "0.0.5", - "private": true, "type": "module", + "license": "MIT", "kunkun": { "name": "TODO: Change Display Name", "shortDescription": "A Custom UI template for nuxt", diff --git a/packages/templates/template-ext-react/package.json b/packages/templates/template-ext-react/package.json index 97eb0b6..49c62b0 100644 --- a/packages/templates/template-ext-react/package.json +++ b/packages/templates/template-ext-react/package.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-react", - "private": true, + "license": "MIT", "version": "0.0.4", "type": "module", "kunkun": { diff --git a/packages/templates/template-ext-svelte/package.json b/packages/templates/template-ext-svelte/package.json index 3668be3..57488ff 100644 --- a/packages/templates/template-ext-svelte/package.json +++ b/packages/templates/template-ext-svelte/package.json @@ -1,7 +1,7 @@ { "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-svelte", - "private": true, + "license": "MIT", "version": "0.0.4", "type": "module", "kunkun": { diff --git a/packages/templates/template-ext-sveltekit/package.json b/packages/templates/template-ext-sveltekit/package.json index 938c76b..a15a03d 100644 --- a/packages/templates/template-ext-sveltekit/package.json +++ b/packages/templates/template-ext-sveltekit/package.json @@ -2,7 +2,7 @@ "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-sveltekit", "version": "0.0.5", - "private": true, + "license": "MIT", "kunkun": { "name": "TODO: Change Display Name", "shortDescription": "A Custom UI template for sveltekit", diff --git a/packages/templates/template-ext-vue/package.json b/packages/templates/template-ext-vue/package.json index 5695d36..f5fa3dc 100644 --- a/packages/templates/template-ext-vue/package.json +++ b/packages/templates/template-ext-vue/package.json @@ -1,6 +1,6 @@ { "name": "template-ext-vue", - "private": true, + "license": "MIT", "version": "0.0.2", "type": "module", "scripts": { diff --git a/packages/templates/template-ext-worker/package.json b/packages/templates/template-ext-worker/package.json index 332fc27..69fbbca 100644 --- a/packages/templates/template-ext-worker/package.json +++ b/packages/templates/template-ext-worker/package.json @@ -2,6 +2,7 @@ "$schema": "./node_modules/@kksh/api/dist/schema.json", "name": "template-ext-worker", "version": "0.0.4", + "license": "MIT", "type": "module", "kunkun": { "name": "TODO: Extension Display Name", diff --git a/packages/ui/src/components/common/date/DatePickerWithPreset.svelte b/packages/ui/src/components/common/date/DatePickerWithPreset.svelte index d82e34b..14b7bb4 100644 --- a/packages/ui/src/components/common/date/DatePickerWithPreset.svelte +++ b/packages/ui/src/components/common/date/DatePickerWithPreset.svelte @@ -44,7 +44,7 @@ type="single" value={valueString} controlledValue - onValueChange={(v) => { + onValueChange={(v: string) => { if (!v) return date = today(getLocalTimeZone()).add({ days: Number.parseInt(v) }) }} diff --git a/packages/ui/src/components/extension/ExtListItem.svelte b/packages/ui/src/components/extension/ExtListItem.svelte index f5952d2..0496beb 100644 --- a/packages/ui/src/components/extension/ExtListItem.svelte +++ b/packages/ui/src/components/extension/ExtListItem.svelte @@ -1,7 +1,7 @@