wip: cloud
This commit is contained in:
@@ -1,7 +1,16 @@
|
|||||||
import { Actor } from "@opencode/cloud-core/actor.js"
|
import { Actor } from "@opencode/cloud-core/actor.js"
|
||||||
import { getActor } from "./auth"
|
import { getActor } from "./auth"
|
||||||
|
import { query } from "@solidjs/router"
|
||||||
|
|
||||||
export async function withActor<T>(fn: () => T) {
|
export async function withActor<T>(fn: () => T) {
|
||||||
const actor = await getActor()
|
const actor = await getActor()
|
||||||
return Actor.provide(actor.type, actor.properties, fn)
|
return Actor.provide(actor.type, actor.properties, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function actorQuery<T>(cb: () => T, name: string) {
|
||||||
|
"use server"
|
||||||
|
return query(async () => {
|
||||||
|
const actor = await getActor()
|
||||||
|
return withActor(cb)
|
||||||
|
}, name)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
import "./workspace.css"
|
||||||
import { useAuthSession } from "~/context/auth.session"
|
import { useAuthSession } from "~/context/auth.session"
|
||||||
import { IconLogo } from "../component/icon"
|
import { IconLogo } from "../component/icon"
|
||||||
import "./workspace.css"
|
|
||||||
import { action, redirect, RouteSectionProps } from "@solidjs/router"
|
import { action, redirect, RouteSectionProps } from "@solidjs/router"
|
||||||
|
|
||||||
const logout = action(async () => {
|
const logout = action(async () => {
|
||||||
|
|||||||
@@ -13,26 +13,27 @@ import { Actor } from "@opencode/cloud-core/actor.js"
|
|||||||
// Keys related queries and actions
|
// Keys related queries and actions
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
const listKeys = query(async () => {
|
|
||||||
|
const listKeys = query(() => {
|
||||||
"use server"
|
"use server"
|
||||||
return withActor(() => Key.list())
|
return withActor(() => Key.list())
|
||||||
}, "keys")
|
}, "key.list")
|
||||||
|
|
||||||
const createKey = action(async (name: string) => {
|
const createKey = action(async (name: string) => {
|
||||||
"use server"
|
"use server"
|
||||||
return json(
|
return json(
|
||||||
withActor(() => Key.create({ name })),
|
withActor(() => Key.create({ name })),
|
||||||
{ revalidate: "keys" },
|
{ revalidate: listKeys.key },
|
||||||
)
|
)
|
||||||
}, "createKey")
|
}, "key.create")
|
||||||
|
|
||||||
const removeKey = action(async (id: string) => {
|
const removeKey = action(async (id: string) => {
|
||||||
"use server"
|
"use server"
|
||||||
return json(
|
return json(
|
||||||
withActor(() => Key.remove({ id })),
|
withActor(() => Key.remove({ id })),
|
||||||
{ revalidate: "keys" },
|
{ revalidate: listKeys.key },
|
||||||
)
|
)
|
||||||
}, "removeKey")
|
}, "key.remove")
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Billing related queries and actions
|
// Billing related queries and actions
|
||||||
|
|||||||
Reference in New Issue
Block a user