File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed
Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 156156 },
157157 "packages/enterprise": {
158158 "name": "@opencode-ai/enterprise",
159+ "version": "0.0.0",
159160 "dependencies": {
160161 "@opencode-ai/util": "workspace:*",
161162 "@solidjs/router": "^0.15.0",
344345 "packages/util": {
345346 "name": "@opencode-ai/util",
346347 "version": "0.0.0",
348+ "dependencies": {
349+ "zod": "catalog:",
350+ },
347351 "devDependencies": {
348352 "typescript": "catalog:",
349353 },
Original file line number Diff line number Diff line change 1+ import { fn } from "@opencode-ai/util/fn"
2+ import z from "zod"
3+ import { Storage } from "./storage"
4+
5+ export namespace Share {
6+ export const Info = z . object ( {
7+ id : z . string ( ) ,
8+ secret : z . string ( ) ,
9+ } )
10+ export type Info = z . infer < typeof Info >
11+
12+ export const create = fn ( Info . pick ( { id : true } ) , async ( body ) => {
13+ const info : Info = {
14+ id : body . id ,
15+ secret : crypto . randomUUID ( ) ,
16+ }
17+ await Storage . write ( [ "share" , info . id ] , info )
18+ } )
19+ }
Original file line number Diff line number Diff line change 99 "scripts" : {
1010 "typecheck" : " tsc --noEmit"
1111 },
12+ "dependencies" : {
13+ "zod" : " catalog:"
14+ },
1215 "devDependencies" : {
1316 "typescript" : " catalog:"
1417 }
Original file line number Diff line number Diff line change 1+ import { z } from "zod"
2+
3+ export function fn < T extends z . ZodType , Result > ( schema : T , cb : ( input : z . infer < T > ) => Result ) {
4+ const result = ( input : z . infer < T > ) => {
5+ const parsed = schema . parse ( input )
6+ return cb ( parsed )
7+ }
8+ result . force = ( input : z . infer < T > ) => cb ( input )
9+ result . schema = schema
10+ return result
11+ }
You can’t perform that action at this time.
0 commit comments