diff options
| author | Dax Raad <[email protected]> | 2025-11-24 22:58:47 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-11-24 22:58:47 -0500 |
| commit | 69d1381ba334037cc57eef483c1b23b58b0f314e (patch) | |
| tree | a0514664e068cc43af0b39a4878c50427a313334 /packages/enterprise/src/core | |
| parent | ccec8c479248fdaefaaf9ad9606bfc4eecb042c9 (diff) | |
| download | opencode-69d1381ba334037cc57eef483c1b23b58b0f314e.tar.gz opencode-69d1381ba334037cc57eef483c1b23b58b0f314e.zip | |
core: refactor share system to separate session IDs from share IDs
- Generate shorter share IDs from session IDs for better URL structure
- Update API routes to use shareID parameter instead of sessionID
- Improve sync mechanism with better data queuing and deduplication
- Maintain backward compatibility while improving security and organization
Diffstat (limited to 'packages/enterprise/src/core')
| -rw-r--r-- | packages/enterprise/src/core/share.ts | 23 | ||||
| -rw-r--r-- | packages/enterprise/src/core/storage.ts | 1 |
2 files changed, 9 insertions, 15 deletions
diff --git a/packages/enterprise/src/core/share.ts b/packages/enterprise/src/core/share.ts index c24077ec3..dff7d0d74 100644 --- a/packages/enterprise/src/core/share.ts +++ b/packages/enterprise/src/core/share.ts @@ -8,6 +8,7 @@ export namespace Share { export const Info = z.object({ id: z.string(), secret: z.string(), + sessionID: z.string(), }) export type Info = z.infer<typeof Info> @@ -29,19 +30,16 @@ export namespace Share { data: z.custom<FileDiff[]>(), }), z.object({ - type: z.literal("session_status"), - data: z.custom<SessionStatus>(), - }), - z.object({ type: z.literal("model"), data: z.custom<Model[]>(), }), ]) export type Data = z.infer<typeof Data> - export const create = fn(Info.pick({ id: true }), async (body) => { + export const create = fn(z.object({ sessionID: z.string() }), async (body) => { const info: Info = { - id: body.id, + id: body.sessionID.slice(-8), + sessionID: body.sessionID, secret: crypto.randomUUID(), } const exists = await get(info.id) @@ -51,8 +49,8 @@ export namespace Share { return info }) - async function get(sessionID: string) { - return Storage.read<Info>(["share", sessionID]) + export async function get(id: string) { + return Storage.read<Info>(["share", id]) } export const remove = fn(Info.pick({ id: true, secret: true }), async (body) => { @@ -66,8 +64,8 @@ export namespace Share { } }) - export async function data(sessionID: string) { - const list = await Storage.list(["share_data", sessionID]) + export async function data(id: string) { + const list = await Storage.list(["share_data", id]) const promises = [] for (const item of list) { promises.push( @@ -85,7 +83,7 @@ export namespace Share { export const sync = fn( z.object({ - share: Info, + share: Info.pick({ id: true, secret: true }), data: Data.array(), }), async (input) => { @@ -112,9 +110,6 @@ export namespace Share { case "session_diff": await Storage.write(["share_data", input.share.id, "session_diff"], item.data) break - case "session_status": - await Storage.write(["share_data", input.share.id, "session_status"], item.data) - break case "model": await Storage.write(["share_data", input.share.id, "model"], item.data) break diff --git a/packages/enterprise/src/core/storage.ts b/packages/enterprise/src/core/storage.ts index fb33ef389..db03e2160 100644 --- a/packages/enterprise/src/core/storage.ts +++ b/packages/enterprise/src/core/storage.ts @@ -19,7 +19,6 @@ export namespace Storage { return { async read(path: string): Promise<string | undefined> { try { - console.log("reading", bucket, path) const command = new GetObjectCommand({ Bucket: bucket, Key: path, |
