/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { ClosedEnum } from "../../types/enums.js"; /** * Rich context object with id and optional data */ export type GenerateConnectOauthUrlRequestDtoContext2 = { id: string; /** * Optional additional context data */ data?: { [k: string]: any } | undefined; }; export type GenerateConnectOauthUrlRequestDtoContext = | GenerateConnectOauthUrlRequestDtoContext2 | string; /** * Connection mode that determines how the channel connection is scoped. "subscriber" (default) associates the connection with a specific subscriber. "shared" associates the connection with a context instead of a subscriber. */ export const GenerateConnectOauthUrlRequestDtoConnectionMode = { Subscriber: "subscriber", Shared: "shared", } as const; /** * Connection mode that determines how the channel connection is scoped. "subscriber" (default) associates the connection with a specific subscriber. "shared" associates the connection with a context instead of a subscriber. */ export type GenerateConnectOauthUrlRequestDtoConnectionMode = ClosedEnum< typeof GenerateConnectOauthUrlRequestDtoConnectionMode >; export type GenerateConnectOauthUrlRequestDto = { /** * The subscriber ID to associate with the channel connection. For Slack: optional for workspace connections (required only for incoming-webhook scope). For MS Teams: optional. Admin consent is tenant-wide. */ subscriberId?: string | undefined; /** * Integration identifier */ integrationIdentifier: string; /** * Identifier of the channel connection that will be created. Generated automatically if not provided. */ connectionIdentifier?: string | undefined; context?: | { [k: string]: GenerateConnectOauthUrlRequestDtoContext2 | string } | undefined; /** * **Slack only**: OAuth scopes to request during authorization. If not specified, default scopes will be used: chat:write, chat:write.public, channels:read, groups:read, users:read, users:read.email. **MS Teams**: ignored — uses admin consent with pre-configured Azure AD permissions. */ scope?: Array | undefined; /** * Connection mode that determines how the channel connection is scoped. "subscriber" (default) associates the connection with a specific subscriber. "shared" associates the connection with a context instead of a subscriber. */ connectionMode?: GenerateConnectOauthUrlRequestDtoConnectionMode | undefined; /** * When true (default when connectionMode is "subscriber"), after the workspace/tenant connection is created the OAuth flow also links the subscriber who clicked "Connect" as a personal endpoint. For Slack, uses the authed_user.id returned by oauth.v2.access — no extra redirect. For MS Teams, triggers a second OAuth redirect for delegated user-identity consent. Set to false to only create the workspace connection without linking the individual user. */ autoLinkUser?: boolean | undefined; }; /** @internal */ export type GenerateConnectOauthUrlRequestDtoContext2$Outbound = { id: string; data?: { [k: string]: any } | undefined; }; /** @internal */ export const GenerateConnectOauthUrlRequestDtoContext2$outboundSchema: z.ZodType< GenerateConnectOauthUrlRequestDtoContext2$Outbound, z.ZodTypeDef, GenerateConnectOauthUrlRequestDtoContext2 > = z.object({ id: z.string(), data: z.record(z.any()).optional(), }); export function generateConnectOauthUrlRequestDtoContext2ToJSON( generateConnectOauthUrlRequestDtoContext2: GenerateConnectOauthUrlRequestDtoContext2, ): string { return JSON.stringify( GenerateConnectOauthUrlRequestDtoContext2$outboundSchema.parse( generateConnectOauthUrlRequestDtoContext2, ), ); } /** @internal */ export type GenerateConnectOauthUrlRequestDtoContext$Outbound = | GenerateConnectOauthUrlRequestDtoContext2$Outbound | string; /** @internal */ export const GenerateConnectOauthUrlRequestDtoContext$outboundSchema: z.ZodType< GenerateConnectOauthUrlRequestDtoContext$Outbound, z.ZodTypeDef, GenerateConnectOauthUrlRequestDtoContext > = z.union([ z.lazy(() => GenerateConnectOauthUrlRequestDtoContext2$outboundSchema), z.string(), ]); export function generateConnectOauthUrlRequestDtoContextToJSON( generateConnectOauthUrlRequestDtoContext: GenerateConnectOauthUrlRequestDtoContext, ): string { return JSON.stringify( GenerateConnectOauthUrlRequestDtoContext$outboundSchema.parse( generateConnectOauthUrlRequestDtoContext, ), ); } /** @internal */ export const GenerateConnectOauthUrlRequestDtoConnectionMode$outboundSchema: z.ZodNativeEnum = z .nativeEnum(GenerateConnectOauthUrlRequestDtoConnectionMode); /** @internal */ export type GenerateConnectOauthUrlRequestDto$Outbound = { subscriberId?: string | undefined; integrationIdentifier: string; connectionIdentifier?: string | undefined; context?: { [k: string]: GenerateConnectOauthUrlRequestDtoContext2$Outbound | string; } | undefined; scope?: Array | undefined; connectionMode?: string | undefined; autoLinkUser?: boolean | undefined; }; /** @internal */ export const GenerateConnectOauthUrlRequestDto$outboundSchema: z.ZodType< GenerateConnectOauthUrlRequestDto$Outbound, z.ZodTypeDef, GenerateConnectOauthUrlRequestDto > = z.object({ subscriberId: z.string().optional(), integrationIdentifier: z.string(), connectionIdentifier: z.string().optional(), context: z.record( z.union([ z.lazy(() => GenerateConnectOauthUrlRequestDtoContext2$outboundSchema), z.string(), ]), ).optional(), scope: z.array(z.string()).optional(), connectionMode: GenerateConnectOauthUrlRequestDtoConnectionMode$outboundSchema .optional(), autoLinkUser: z.boolean().optional(), }); export function generateConnectOauthUrlRequestDtoToJSON( generateConnectOauthUrlRequestDto: GenerateConnectOauthUrlRequestDto, ): string { return JSON.stringify( GenerateConnectOauthUrlRequestDto$outboundSchema.parse( generateConnectOauthUrlRequestDto, ), ); }