Skip to content

Commit f80343b

Browse files
committed
fix annotation
1 parent 9b805e1 commit f80343b

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

packages/opencode/src/auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export namespace Auth {
3232
token: Schema.String,
3333
}) {}
3434

35-
const _Info = Schema.Union([Oauth, Api, WellKnown])
35+
const _Info = Schema.Union([Oauth, Api, WellKnown]).annotate({ discriminator: "type", identifier: "Auth" })
3636
export const Info = Object.assign(_Info, { zod: zod(_Info) })
3737
export type Info = Schema.Schema.Type<typeof _Info>
3838

packages/opencode/src/util/effect-zod.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ function union(ast: SchemaAST.Union): z.ZodTypeAny {
6060
const items = ast.types.map(walk)
6161
if (items.length === 1) return items[0]
6262
if (items.length < 2) return fail(ast)
63+
64+
const discriminator = (ast as any).annotations?.discriminator
65+
if (discriminator) {
66+
return z.discriminatedUnion(discriminator, items as [z.ZodObject<any>, z.ZodObject<any>, ...z.ZodObject<any>[]])
67+
}
68+
6369
return z.union(items as [z.ZodTypeAny, z.ZodTypeAny, ...Array<z.ZodTypeAny>])
6470
}
6571

packages/sdk/js/src/v2/gen/sdk.gen.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { client } from "./client.gen.js"
44
import { buildClientParams, type Client, type Options as Options2, type TDataShape } from "./client/index.js"
55
import type {
66
AgentPartInput,
7-
ApiAuth,
87
AppAgentsResponses,
98
AppLogErrors,
109
AppLogResponses,
1110
AppSkillsResponses,
11+
Auth as Auth3,
1212
AuthRemoveErrors,
1313
AuthRemoveResponses,
1414
AuthSetErrors,
@@ -63,7 +63,6 @@ import type {
6363
McpLocalConfig,
6464
McpRemoteConfig,
6565
McpStatusResponses,
66-
OAuth,
6766
OutputFormat,
6867
Part as Part2,
6968
PartDeleteErrors,
@@ -174,7 +173,6 @@ import type {
174173
TuiShowToastResponses,
175174
TuiSubmitPromptResponses,
176175
VcsGetResponses,
177-
WellKnownAuth,
178176
WorktreeCreateErrors,
179177
WorktreeCreateInput,
180178
WorktreeCreateResponses,
@@ -339,7 +337,7 @@ export class Auth extends HeyApiClient {
339337
public set<ThrowOnError extends boolean = false>(
340338
parameters: {
341339
providerID: string
342-
body?: OAuth | ApiAuth | WellKnownAuth
340+
auth?: Auth3
343341
},
344342
options?: Options<never, ThrowOnError>,
345343
) {
@@ -349,7 +347,7 @@ export class Auth extends HeyApiClient {
349347
{
350348
args: [
351349
{ in: "path", key: "providerID" },
352-
{ key: "body", map: "body" },
350+
{ key: "auth", map: "body" },
353351
],
354352
},
355353
],

packages/sdk/js/src/v2/gen/types.gen.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,8 @@ export type WellKnownAuth = {
15341534
token: string
15351535
}
15361536

1537+
export type Auth = OAuth | ApiAuth | WellKnownAuth
1538+
15371539
export type NotFoundError = {
15381540
name: "NotFoundError"
15391541
data: {
@@ -2056,7 +2058,7 @@ export type AuthRemoveResponses = {
20562058
export type AuthRemoveResponse = AuthRemoveResponses[keyof AuthRemoveResponses]
20572059

20582060
export type AuthSetData = {
2059-
body?: OAuth | ApiAuth | WellKnownAuth
2061+
body?: Auth
20602062
path: {
20612063
providerID: string
20622064
}

0 commit comments

Comments
 (0)