@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
744 lines (696 loc) • 23.9 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { smartUnion } from "../types/smartUnion.js";
import {
ConnectTriggerConfiguration,
ConnectTriggerConfiguration$inboundSchema,
} from "./connecttriggerconfiguration.js";
import {
ConnectTriggerDestination,
ConnectTriggerDestination$inboundSchema,
} from "./connecttriggerdestination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
export const CreatedByEnvironment = {
Development: "development",
Preview: "preview",
Production: "production",
} as const;
export type CreatedByEnvironment = ClosedEnum<typeof CreatedByEnvironment>;
/**
* Deployment environment of the project principal.
*/
export type CreatedByEnvironmentTarget = string | CreatedByEnvironment;
/**
* Principal that originally created the connector — either a Vercel user (interactive dashboard / CLI flow) or a Vercel deployment (OIDC-authenticated project, used by runtime auto-provisioning). See {@link ConnexPrincipal}. Optional: pre-existing rows from before this shape was introduced may carry no attribution at all.
*/
export type CreatedBy2 = {
/**
* Principal kind.
*/
type: "project";
/**
* Vercel project ID.
*/
id: string;
/**
* Deployment environment of the project principal.
*/
environment: string | CreatedByEnvironment;
};
/**
* Principal that originally created the connector — either a Vercel user (interactive dashboard / CLI flow) or a Vercel deployment (OIDC-authenticated project, used by runtime auto-provisioning). See {@link ConnexPrincipal}. Optional: pre-existing rows from before this shape was introduced may carry no attribution at all.
*/
export type CreatedBy1 = {
/**
* Principal kind.
*/
type: "user";
/**
* Vercel user ID.
*/
id: string;
};
/**
* Principal that created the connector.
*/
export type ConnectConnectorCreateResultCreatedBy = CreatedBy1 | CreatedBy2;
export const UpdatedByEnvironmentTargetUpdatedByEnvironment = {
Development: "development",
Preview: "preview",
Production: "production",
} as const;
export type UpdatedByEnvironmentTargetUpdatedByEnvironment = ClosedEnum<
typeof UpdatedByEnvironmentTargetUpdatedByEnvironment
>;
/**
* Deployment environment of the project principal.
*/
export type UpdatedByEnvironmentTarget =
| string
| UpdatedByEnvironmentTargetUpdatedByEnvironment;
/**
* Principal that most recently mutated the connector. Same shape as {@link createdBy} but tracks the most recent updater, not the original creator. At create time the two fields point at the same principal; they diverge on the first subsequent update.
*/
export type ConnectConnectorCreateResultUpdatedBy2 = {
/**
* Principal kind.
*/
type: "project";
/**
* Vercel project ID.
*/
id: string;
/**
* Deployment environment of the project principal.
*/
environment: string | UpdatedByEnvironmentTargetUpdatedByEnvironment;
};
/**
* Principal that most recently mutated the connector. Same shape as {@link createdBy} but tracks the most recent updater, not the original creator. At create time the two fields point at the same principal; they diverge on the first subsequent update.
*/
export type ConnectConnectorCreateResultUpdatedBy1 = {
/**
* Principal kind.
*/
type: "user";
/**
* Vercel user ID.
*/
id: string;
};
/**
* Principal that most recently updated the connector.
*/
export type ConnectConnectorCreateResultUpdatedBy =
| ConnectConnectorCreateResultUpdatedBy1
| ConnectConnectorCreateResultUpdatedBy2;
/**
* How the connector row was originally created. New create paths stamp this explicitly; older rows may omit it.
*/
export const ConnectConnectorCreateResultCreationMode = {
Managed: "managed",
Manual: "manual",
} as const;
/**
* How the connector row was originally created. New create paths stamp this explicitly; older rows may omit it.
*/
export type ConnectConnectorCreateResultCreationMode = ClosedEnum<
typeof ConnectConnectorCreateResultCreationMode
>;
/**
* Managed connector metadata exposed without leaking the manager connector or installation identifiers.
*/
export type ConnectConnectorCreateResultManaged = {
/**
* Whether Vercel synchronizes provider-side configuration.
*/
sync?: boolean | undefined;
};
/**
* Connector implementation type.
*/
export const ConnectConnectorCreateResultType = {
ApiKey: "api-key",
AwsAlpha: "aws-alpha",
Custom: "custom",
Discord: "discord",
Github: "github",
Linear: "linear",
Linq: "linq",
MicrosoftEntra: "microsoft-entra",
MicrosoftTeams: "microsoft-teams",
Oauth: "oauth",
Photon: "photon",
Salesforce: "salesforce",
Sendblue: "sendblue",
Slack: "slack",
Snowflake: "snowflake",
SnowflakeWif: "snowflake-wif",
} as const;
/**
* Connector implementation type.
*/
export type ConnectConnectorCreateResultType = ClosedEnum<
typeof ConnectConnectorCreateResultType
>;
/**
* App-token capabilities and known grants for the connector.
*/
export type ConnectConnectorCreateResultAppTokens = {
/**
* Whether one app token can be used across installations.
*/
crossInstallation: boolean;
/**
* Whether callers can narrow app-token grants per request.
*/
supportsRefinement: boolean;
/**
* Whether callers can request resource-specific app tokens.
*/
supportsResources?: boolean | undefined;
/**
* True when changing app token grants requires reinstalling the app, so tokens cannot be partitioned independently by requester environment.
*/
requiresReinstallation?: boolean | undefined;
/**
* Known allowed app-level scopes. For Slack this is the bot scope set configured on the app; for OAuth it is the connector's enabled `clientCredentials.scopes` configuration.
*/
scopes?: Array<string> | undefined;
/**
* Supported OAuth authorization-detail type names.
*/
supportedAuthorizationDetails?: Array<string> | undefined;
/**
* Link to the page on the service where this connector's app-level permissions are declared and granted, when the service has one and it differs from `clientUrl`.
*/
permissionsUrl?: string | undefined;
};
/**
* User-token capabilities and known grants for the connector.
*/
export type ConnectConnectorCreateResultUserTokens = {
/**
* Whether one user token can be used across installations.
*/
crossInstallation: boolean;
/**
* Whether callers can narrow user-token grants per request.
*/
supportsRefinement: boolean;
/**
* Whether callers can request resource-specific user tokens.
*/
supportsResources?: boolean | undefined;
/**
* Known allowed user-level scopes. For Slack this is the user scope set configured on the app; for OAuth it is the connector's enabled `userAuthorization.scopes` configuration.
*/
scopes?: Array<string> | undefined;
/**
* Supported OAuth authorization-detail type names.
*/
supportedAuthorizationDetails?: Array<string> | undefined;
/**
* User authorization is completed by the Connect consent screen submitting a credential instead of an OAuth redirect.
*/
manualCredentialInput?: boolean | undefined;
};
/**
* Whether the connector icon can propagate to the provider.
*/
export const ConnectConnectorCreateResultSupportsIcon = {
False: "false",
Maybe: "maybe",
True: "true",
} as const;
/**
* Whether the connector icon can propagate to the provider.
*/
export type ConnectConnectorCreateResultSupportsIcon = ClosedEnum<
typeof ConnectConnectorCreateResultSupportsIcon
>;
/**
* Connector created by the request.
*/
export type ConnectConnectorCreateResult = {
/**
* Stable `scl_` connector ID. Use this value directly in `{connector}`.
*/
id: string;
/**
* Team-scoped UID. URL-encode this value before using it in `{connector}`.
*/
uid: string;
/**
* Installation used when a token request does not specify an installation.
*/
defaultInstallationId?: string | undefined;
/**
* Creation time in epoch milliseconds.
*/
createdAt: number;
/**
* Last update time in epoch milliseconds.
*/
updatedAt: number;
/**
* Time when this connector started requiring reinstallation because an installation-affecting app-token grant changed.
*/
reinstallAt?: number | undefined;
/**
* Principal that created the connector.
*/
createdBy?: CreatedBy1 | CreatedBy2 | undefined;
/**
* Principal that most recently updated the connector.
*/
updatedBy?:
| ConnectConnectorCreateResultUpdatedBy1
| ConnectConnectorCreateResultUpdatedBy2
| undefined;
/**
* How the connector row was originally created. New create paths stamp this explicitly; older rows may omit it.
*/
creationMode?: ConnectConnectorCreateResultCreationMode | undefined;
/**
* Managed connector metadata exposed without leaking the manager connector or installation identifiers.
*/
managed?: ConnectConnectorCreateResultManaged | undefined;
/**
* Connector implementation type.
*/
type: ConnectConnectorCreateResultType;
/**
* Best-effort identifier of the third-party service this connector represents, independent of `type`. Examples: `'slack'`, `'mcp.linear.app'`, and `'auth.example.com'`. Always present in API responses.
*/
service: string;
/**
* The connection method this connector was created from, when the create request named one.
*/
connectionMethod?: string | undefined;
/**
* Which of the service's products/surfaces this connector points at.
*/
target?: string | undefined;
/**
* Connector name within the owning team.
*/
name: string;
/**
* Human-readable connector name.
*/
displayName: string;
/**
* Provider-side URL for viewing or managing the resource represented by the connector. The destination can be an app, account, phone line, or service instance, depending on the connector type.
*/
clientUrl?: string | null | undefined;
/**
* Redirect URI registered with the third-party service for this connector, if any. Used by `startAuthorization`/`startInstallation` to replay the exact URI back to the provider's token endpoint. Absent on connectors created before this field was introduced; those callers fall back to the `https://connect.vercel.com/callback` default.
*/
redirectUri?: string | undefined;
/**
* Human-readable name of the connector type.
*/
typeName: string;
/**
* Icon identifier supplied by the connector type.
*/
typeIcon?: string | undefined;
/**
* Public website for the connected service.
*/
website?: string | undefined;
/**
* Developer website for the connected service.
*/
devsite?: string | undefined;
/**
* Developer documentation for the connected service.
*/
docsite?: string | undefined;
/**
* Connector branding icon. SHA-1 hash that resolves to the uploaded icon through the Vercel avatar service. Consumers render this with `https://vercel.com/api/www/avatar/{icon}`.
*/
icon?: string | undefined;
/**
* Hex background color (e.g., `#000000`) for branding.
*/
backgroundColor?: string | undefined;
/**
* Hex accent color (e.g., `#000000`) for branding.
*/
accentColor?: string | undefined;
/**
* Token subject types supported by the connector.
*/
supportedSubjectTypes: Array<string>;
/**
* App-token capabilities and known grants for the connector.
*/
appTokens?: ConnectConnectorCreateResultAppTokens | undefined;
/**
* User-token capabilities and known grants for the connector.
*/
userTokens?: ConnectConnectorCreateResultUserTokens | undefined;
/**
* Whether the connector supports an installation flow.
*/
supportsInstallation: boolean;
/**
* Whether Connect can revoke tokens for this connector.
*/
supportsRevocation: boolean;
/**
* Whether this connector type supports trigger webhooks. Derived from the type definition; indicates that `triggers` and `triggerDestinations` may be meaningful for this connector.
*/
supportsTriggers: boolean;
/**
* Whether the connector icon can propagate to the provider.
*/
supportsIcon: ConnectConnectorCreateResultSupportsIcon;
/**
* Incoming trigger configuration. Only present when enabled.
*/
triggers?: ConnectTriggerConfiguration | undefined;
/**
* Known events this connector subscribes to (e.g. Slack bot events, GitHub webhook events). Names are type-specific and validated by the managed-create flow when forwarded to the third-party service.
*/
events?: Array<string> | undefined;
/**
* Destinations that incoming triggers should be forwarded to. Limited to 3 entries. Set the initial destination with `triggerDestination` during creation. Replace the complete set with `PATCH /v1/connect/connectors/{connector}/trigger-destinations`.
*/
triggerDestinations?: Array<ConnectTriggerDestination> | undefined;
};
/** @internal */
export const CreatedByEnvironment$inboundSchema: z.ZodNativeEnum<
typeof CreatedByEnvironment
> = z.nativeEnum(CreatedByEnvironment);
/** @internal */
export const CreatedByEnvironmentTarget$inboundSchema: z.ZodType<
CreatedByEnvironmentTarget,
z.ZodTypeDef,
unknown
> = smartUnion([types.string(), CreatedByEnvironment$inboundSchema]);
export function createdByEnvironmentTargetFromJSON(
jsonString: string,
): SafeParseResult<CreatedByEnvironmentTarget, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreatedByEnvironmentTarget$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreatedByEnvironmentTarget' from JSON`,
);
}
/** @internal */
export const CreatedBy2$inboundSchema: z.ZodType<
CreatedBy2,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("project"),
id: types.string(),
environment: smartUnion([types.string(), CreatedByEnvironment$inboundSchema]),
});
export function createdBy2FromJSON(
jsonString: string,
): SafeParseResult<CreatedBy2, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreatedBy2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreatedBy2' from JSON`,
);
}
/** @internal */
export const CreatedBy1$inboundSchema: z.ZodType<
CreatedBy1,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("user"),
id: types.string(),
});
export function createdBy1FromJSON(
jsonString: string,
): SafeParseResult<CreatedBy1, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreatedBy1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreatedBy1' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultCreatedBy$inboundSchema: z.ZodType<
ConnectConnectorCreateResultCreatedBy,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => CreatedBy1$inboundSchema),
z.lazy(() => CreatedBy2$inboundSchema),
]);
export function connectConnectorCreateResultCreatedByFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultCreatedBy, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultCreatedBy$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultCreatedBy' from JSON`,
);
}
/** @internal */
export const UpdatedByEnvironmentTargetUpdatedByEnvironment$inboundSchema:
z.ZodNativeEnum<typeof UpdatedByEnvironmentTargetUpdatedByEnvironment> = z
.nativeEnum(UpdatedByEnvironmentTargetUpdatedByEnvironment);
/** @internal */
export const UpdatedByEnvironmentTarget$inboundSchema: z.ZodType<
UpdatedByEnvironmentTarget,
z.ZodTypeDef,
unknown
> = smartUnion([
types.string(),
UpdatedByEnvironmentTargetUpdatedByEnvironment$inboundSchema,
]);
export function updatedByEnvironmentTargetFromJSON(
jsonString: string,
): SafeParseResult<UpdatedByEnvironmentTarget, SDKValidationError> {
return safeParse(
jsonString,
(x) => UpdatedByEnvironmentTarget$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'UpdatedByEnvironmentTarget' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultUpdatedBy2$inboundSchema: z.ZodType<
ConnectConnectorCreateResultUpdatedBy2,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("project"),
id: types.string(),
environment: smartUnion([
types.string(),
UpdatedByEnvironmentTargetUpdatedByEnvironment$inboundSchema,
]),
});
export function connectConnectorCreateResultUpdatedBy2FromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultUpdatedBy2, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultUpdatedBy2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultUpdatedBy2' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultUpdatedBy1$inboundSchema: z.ZodType<
ConnectConnectorCreateResultUpdatedBy1,
z.ZodTypeDef,
unknown
> = z.object({
type: types.literal("user"),
id: types.string(),
});
export function connectConnectorCreateResultUpdatedBy1FromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultUpdatedBy1, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultUpdatedBy1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultUpdatedBy1' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultUpdatedBy$inboundSchema: z.ZodType<
ConnectConnectorCreateResultUpdatedBy,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => ConnectConnectorCreateResultUpdatedBy1$inboundSchema),
z.lazy(() => ConnectConnectorCreateResultUpdatedBy2$inboundSchema),
]);
export function connectConnectorCreateResultUpdatedByFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultUpdatedBy, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultUpdatedBy$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultUpdatedBy' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultCreationMode$inboundSchema:
z.ZodNativeEnum<typeof ConnectConnectorCreateResultCreationMode> = z
.nativeEnum(ConnectConnectorCreateResultCreationMode);
/** @internal */
export const ConnectConnectorCreateResultManaged$inboundSchema: z.ZodType<
ConnectConnectorCreateResultManaged,
z.ZodTypeDef,
unknown
> = z.object({
sync: types.optional(types.boolean()),
});
export function connectConnectorCreateResultManagedFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultManaged, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultManaged$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultManaged' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultType$inboundSchema: z.ZodNativeEnum<
typeof ConnectConnectorCreateResultType
> = z.nativeEnum(ConnectConnectorCreateResultType);
/** @internal */
export const ConnectConnectorCreateResultAppTokens$inboundSchema: z.ZodType<
ConnectConnectorCreateResultAppTokens,
z.ZodTypeDef,
unknown
> = z.object({
crossInstallation: types.boolean(),
supportsRefinement: types.boolean(),
supportsResources: types.optional(types.boolean()),
requiresReinstallation: types.optional(types.boolean()),
scopes: types.optional(z.array(types.string())),
supportedAuthorizationDetails: types.optional(z.array(types.string())),
permissionsUrl: types.optional(types.string()),
});
export function connectConnectorCreateResultAppTokensFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultAppTokens, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultAppTokens$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultAppTokens' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultUserTokens$inboundSchema: z.ZodType<
ConnectConnectorCreateResultUserTokens,
z.ZodTypeDef,
unknown
> = z.object({
crossInstallation: types.boolean(),
supportsRefinement: types.boolean(),
supportsResources: types.optional(types.boolean()),
scopes: types.optional(z.array(types.string())),
supportedAuthorizationDetails: types.optional(z.array(types.string())),
manualCredentialInput: types.optional(types.boolean()),
});
export function connectConnectorCreateResultUserTokensFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResultUserTokens, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
ConnectConnectorCreateResultUserTokens$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResultUserTokens' from JSON`,
);
}
/** @internal */
export const ConnectConnectorCreateResultSupportsIcon$inboundSchema:
z.ZodNativeEnum<typeof ConnectConnectorCreateResultSupportsIcon> = z
.nativeEnum(ConnectConnectorCreateResultSupportsIcon);
/** @internal */
export const ConnectConnectorCreateResult$inboundSchema: z.ZodType<
ConnectConnectorCreateResult,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
uid: types.string(),
defaultInstallationId: types.optional(types.string()),
createdAt: types.number(),
updatedAt: types.number(),
reinstallAt: types.optional(types.number()),
createdBy: types.optional(
z.union([
z.lazy(() => CreatedBy1$inboundSchema),
z.lazy(() => CreatedBy2$inboundSchema),
]),
),
updatedBy: types.optional(
z.union([
z.lazy(() => ConnectConnectorCreateResultUpdatedBy1$inboundSchema),
z.lazy(() => ConnectConnectorCreateResultUpdatedBy2$inboundSchema),
]),
),
creationMode: types.optional(
ConnectConnectorCreateResultCreationMode$inboundSchema,
),
managed: types.optional(
z.lazy(() => ConnectConnectorCreateResultManaged$inboundSchema),
),
type: ConnectConnectorCreateResultType$inboundSchema,
service: types.string(),
connectionMethod: types.optional(types.string()),
target: types.optional(types.string()),
name: types.string(),
displayName: types.string(),
clientUrl: z.nullable(types.string()).optional(),
redirectUri: types.optional(types.string()),
typeName: types.string(),
typeIcon: types.optional(types.string()),
website: types.optional(types.string()),
devsite: types.optional(types.string()),
docsite: types.optional(types.string()),
icon: types.optional(types.string()),
backgroundColor: types.optional(types.string()),
accentColor: types.optional(types.string()),
supportedSubjectTypes: z.array(types.string()),
appTokens: types.optional(
z.lazy(() => ConnectConnectorCreateResultAppTokens$inboundSchema),
),
userTokens: types.optional(
z.lazy(() => ConnectConnectorCreateResultUserTokens$inboundSchema),
),
supportsInstallation: types.boolean(),
supportsRevocation: types.boolean(),
supportsTriggers: types.boolean(),
supportsIcon: ConnectConnectorCreateResultSupportsIcon$inboundSchema,
triggers: types.optional(ConnectTriggerConfiguration$inboundSchema),
events: types.optional(z.array(types.string())),
triggerDestinations: types.optional(
z.array(ConnectTriggerDestination$inboundSchema),
),
});
export function connectConnectorCreateResultFromJSON(
jsonString: string,
): SafeParseResult<ConnectConnectorCreateResult, SDKValidationError> {
return safeParse(
jsonString,
(x) => ConnectConnectorCreateResult$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ConnectConnectorCreateResult' from JSON`,
);
}