summaryrefslogtreecommitdiffhomepage
path: root/packages/cloud/core/src/actor.ts
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-09-18 10:59:01 -0400
committerFrank <[email protected]>2025-09-18 10:59:01 -0400
commit4ceabdffa07b1af8d99eb73622a4d549d99ec6d2 (patch)
tree72e2ae62084a9e24cc76caffbd1f30dafc69ea56 /packages/cloud/core/src/actor.ts
parentc87480cf931a6f8f8b55552558ef521f1918b578 (diff)
downloadopencode-4ceabdffa07b1af8d99eb73622a4d549d99ec6d2.tar.gz
opencode-4ceabdffa07b1af8d99eb73622a4d549d99ec6d2.zip
wip: zen
Diffstat (limited to 'packages/cloud/core/src/actor.ts')
-rw-r--r--packages/cloud/core/src/actor.ts74
1 files changed, 0 insertions, 74 deletions
diff --git a/packages/cloud/core/src/actor.ts b/packages/cloud/core/src/actor.ts
deleted file mode 100644
index 0d13f7216..000000000
--- a/packages/cloud/core/src/actor.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { Context } from "./context"
-import { Log } from "./util/log"
-
-export namespace Actor {
- interface Account {
- type: "account"
- properties: {
- accountID: string
- email: string
- }
- }
-
- interface Public {
- type: "public"
- properties: {}
- }
-
- interface User {
- type: "user"
- properties: {
- userID: string
- workspaceID: string
- }
- }
-
- interface System {
- type: "system"
- properties: {
- workspaceID: string
- }
- }
-
- export type Info = Account | Public | User | System
-
- const ctx = Context.create<Info>()
- export const use = ctx.use
-
- const log = Log.create().tag("namespace", "actor")
-
- export function provide<R, T extends Info["type"]>(
- type: T,
- properties: Extract<Info, { type: T }>["properties"],
- cb: () => R,
- ) {
- return ctx.provide(
- {
- type,
- properties,
- } as any,
- () => {
- return Log.provide({ ...properties }, () => {
- log.info("provided")
- return cb()
- })
- },
- )
- }
-
- export function assert<T extends Info["type"]>(type: T) {
- const actor = use()
- if (actor.type !== type) {
- throw new Error(`Expected actor type ${type}, got ${actor.type}`)
- }
- return actor as Extract<Info, { type: T }>
- }
-
- export function workspace() {
- const actor = use()
- if ("workspaceID" in actor.properties) {
- return actor.properties.workspaceID
- }
- throw new Error(`actor of type "${actor.type}" is not associated with a workspace`)
- }
-}