diff options
| author | Frank <[email protected]> | 2025-09-18 01:32:40 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-09-18 01:32:40 -0400 |
| commit | fc4f281408c56ab12db571a470456212a479edf5 (patch) | |
| tree | 309d23b0c497bc61af6f8e650a6036fa41d7cbdb /cloud/core/src/actor.ts | |
| parent | f8c4f713a5b48892899d0ac195c3470ab7ef764c (diff) | |
| download | opencode-fc4f281408c56ab12db571a470456212a479edf5.tar.gz opencode-fc4f281408c56ab12db571a470456212a479edf5.zip | |
wip: zen
Diffstat (limited to 'cloud/core/src/actor.ts')
| -rw-r--r-- | cloud/core/src/actor.ts | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/cloud/core/src/actor.ts b/cloud/core/src/actor.ts deleted file mode 100644 index 0d13f7216..000000000 --- a/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`) - } -} |
