UNPKG

@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>

593 lines 24.1 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import * as types from "../types/primitives.js"; import { smartUnion } from "../types/smartUnion.js"; export const DataType = { UserLower: "user", OrganizationLower: "organization", UserMixed: "User", OrganizationMixed: "Organization", }; export const Use = { Sig: "sig", Enc: "enc", }; export const CreatedByEnvironment = { Development: "development", Preview: "preview", Production: "production", }; export const UpdatedByEnvironment = { Development: "development", Preview: "preview", Production: "production", }; export const CreateConnectorType = { ApiKey: "api-key", Custom: "custom", Github: "github", Linear: "linear", Oauth: "oauth", Salesforce: "salesforce", Slack: "slack", Snowflake: "snowflake", SnowflakeWif: "snowflake-wif", }; export const SupportsIcon = { False: "false", Maybe: "maybe", True: "true", }; export const CreateConnectorEnvironments = { Development: "development", Preview: "preview", Production: "production", }; /** @internal */ export const TypeSnowflakeWif$outboundSchema = z.object({ clientName: z.string(), accountIdentifier: z.string().optional(), extras: z.record(z.any()).optional(), }); export function typeSnowflakeWifToJSON(typeSnowflakeWif) { return JSON.stringify(TypeSnowflakeWif$outboundSchema.parse(typeSnowflakeWif)); } /** @internal */ export const TypeSnowflake$outboundSchema = z.object({ clientName: z.string(), accountIdentifier: z.string(), defaultSessionRole: z.string().optional(), extras: z.record(z.any()).optional(), }); export function typeSnowflakeToJSON(typeSnowflake) { return JSON.stringify(TypeSnowflake$outboundSchema.parse(typeSnowflake)); } /** @internal */ export const SlackTeam$outboundSchema = z.object({ id: z.string(), name: z.string().optional(), domain: z.string().optional(), }); export function slackTeamToJSON(slackTeam) { return JSON.stringify(SlackTeam$outboundSchema.parse(slackTeam)); } /** @internal */ export const TypeSlack$outboundSchema = z.object({ appId: z.string(), appName: z.string(), clientId: z.string(), clientSecret: z.string(), slackTeam: z.lazy(() => SlackTeam$outboundSchema).optional(), signingSecret: z.string().optional(), verificationToken: z.string().optional(), botScopes: z.array(z.string()).optional(), userScopes: z.array(z.string()).optional(), extras: z.record(z.any()).optional(), }); export function typeSlackToJSON(typeSlack) { return JSON.stringify(TypeSlack$outboundSchema.parse(typeSlack)); } /** @internal */ export const TypeSalesforce$outboundSchema = z.object({ consumerKey: z.string(), consumerSecret: z.string(), loginHost: z.string(), }); export function typeSalesforceToJSON(typeSalesforce) { return JSON.stringify(TypeSalesforce$outboundSchema.parse(typeSalesforce)); } /** @internal */ export const OwnerOrganization$outboundSchema = z.object({ id: z.string(), slug: z.string(), name: z.string(), logoUrl: z.nullable(z.string()).optional(), }); export function ownerOrganizationToJSON(ownerOrganization) { return JSON.stringify(OwnerOrganization$outboundSchema.parse(ownerOrganization)); } /** @internal */ export const Application$outboundSchema = z.object({ id: z.string(), clientId: z.string(), name: z.string(), description: z.nullable(z.string()).optional(), developer: z.nullable(z.string()).optional(), developerUrl: z.nullable(z.string()).optional(), imageUrl: z.nullable(z.string()).optional(), redirectUris: z.array(z.string()).optional(), distribution: z.nullable(z.string()).optional(), webhookResourceTypes: z.array(z.string()).optional(), webhookUrl: z.nullable(z.string()).optional(), webhookEnabled: z.boolean().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), }); export function applicationToJSON(application) { return JSON.stringify(Application$outboundSchema.parse(application)); } /** @internal */ export const TypeLinear$outboundSchema = z.object({ appId: z.string().optional(), appName: z.string().optional(), clientId: z.string(), clientSecret: z.string(), webhookSecret: z.string().optional(), appScopes: z.array(z.string()).optional(), userScopes: z.array(z.string()).optional(), ownerOrganization: z.lazy(() => OwnerOrganization$outboundSchema).optional(), application: z.lazy(() => Application$outboundSchema).optional(), extras: z.record(z.any()).optional(), }); export function typeLinearToJSON(typeLinear) { return JSON.stringify(TypeLinear$outboundSchema.parse(typeLinear)); } /** @internal */ export const DataType$outboundSchema = z .nativeEnum(DataType); /** @internal */ export const Owner$outboundSchema = z.object({ type: DataType$outboundSchema, id: z.number().int(), slug: z.string(), name: z.string().optional(), }); export function ownerToJSON(owner) { return JSON.stringify(Owner$outboundSchema.parse(owner)); } /** @internal */ export const TypeGithub$outboundSchema = z.object({ appId: z.number().int(), appSlug: z.string(), appName: z.string(), clientId: z.string(), owner: z.lazy(() => Owner$outboundSchema).optional(), clientSecret: z.string().optional(), privateKeyPem: z.string().optional(), webhookSecret: z.string().optional(), extras: z.record(z.any()).optional(), }); export function typeGithubToJSON(typeGithub) { return JSON.stringify(TypeGithub$outboundSchema.parse(typeGithub)); } /** @internal */ export const Values$outboundSchema = z.object({ value: z.string(), scope: z.string().optional(), expiresAt: z.number().int().optional(), }); export function valuesToJSON(values) { return JSON.stringify(Values$outboundSchema.parse(values)); } /** @internal */ export const TypeApiKey$outboundSchema = z.object({ values: z.array(z.lazy(() => Values$outboundSchema)), }); export function typeApiKeyToJSON(typeApiKey) { return JSON.stringify(TypeApiKey$outboundSchema.parse(typeApiKey)); } /** @internal */ export const Use$outboundSchema = z.nativeEnum(Use); /** @internal */ export const Keys$outboundSchema = z.object({ kty: z.string(), kid: z.string().optional(), use: Use$outboundSchema.optional(), keyOps: z.array(z.string()).optional(), alg: z.string().optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { keyOps: "key_ops", additionalProperties: null, }), }; }); export function keysToJSON(keys) { return JSON.stringify(Keys$outboundSchema.parse(keys)); } /** @internal */ export const Jwks$outboundSchema = z.object({ keys: z.array(z.lazy(() => Keys$outboundSchema)), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { additionalProperties: null, }), }; }); export function jwksToJSON(jwks) { return JSON.stringify(Jwks$outboundSchema.parse(jwks)); } /** @internal */ export const ServerConfig$outboundSchema = z.object({ issuer: z.string().optional(), authorizationEndpoint: z.string().optional(), tokenEndpoint: z.string().optional(), userinfoEndpoint: z.string().optional(), jwksUri: z.string().optional(), jwks: z.lazy(() => Jwks$outboundSchema).optional(), revocationEndpoint: z.string().optional(), introspectionEndpoint: z.string().optional(), endSessionEndpoint: z.string().optional(), deviceAuthorizationEndpoint: z.string().optional(), registrationEndpoint: z.string().optional(), responseTypesSupported: z.array(z.string()).optional(), tokenEndpointAuthMethodsSupported: z.array(z.string()).optional(), tokenEndpointAuthSigningAlgValuesSupported: z.array(z.string()).optional(), scopesSupported: z.array(z.string()).optional(), grantTypesSupported: z.array(z.string()).optional(), responseModesSupported: z.array(z.string()).optional(), subjectTypesSupported: z.array(z.string()).optional(), idTokenSigningAlgValuesSupported: z.array(z.string()).optional(), idTokenEncryptionAlgValuesSupported: z.array(z.string()).optional(), idTokenEncryptionEncValuesSupported: z.array(z.string()).optional(), claimTypesSupported: z.array(z.string()).optional(), claimsSupported: z.array(z.string()).optional(), codeChallengeMethodsSupported: z.array(z.string()).optional(), promptValuesSupported: z.array(z.string()).optional(), claimsParameterSupported: z.boolean().optional(), requestParameterSupported: z.boolean().optional(), requestUriParameterSupported: z.boolean().optional(), requireRequestUriRegistration: z.boolean().optional(), serviceDocumentation: z.string().optional(), opPolicyUri: z.string().optional(), opTosUri: z.string().optional(), logoUri: z.string().optional(), clientIdMetadataDocumentSupported: z.boolean().optional(), authorizationDetailsTypesSupported: z.array(z.string()).optional(), additionalProperties: z.record(z.any()).optional(), }).transform((v) => { return { ...v.additionalProperties, ...remap$(v, { authorizationEndpoint: "authorization_endpoint", tokenEndpoint: "token_endpoint", userinfoEndpoint: "userinfo_endpoint", jwksUri: "jwks_uri", revocationEndpoint: "revocation_endpoint", introspectionEndpoint: "introspection_endpoint", endSessionEndpoint: "end_session_endpoint", deviceAuthorizationEndpoint: "device_authorization_endpoint", registrationEndpoint: "registration_endpoint", responseTypesSupported: "response_types_supported", tokenEndpointAuthMethodsSupported: "token_endpoint_auth_methods_supported", tokenEndpointAuthSigningAlgValuesSupported: "token_endpoint_auth_signing_alg_values_supported", scopesSupported: "scopes_supported", grantTypesSupported: "grant_types_supported", responseModesSupported: "response_modes_supported", subjectTypesSupported: "subject_types_supported", idTokenSigningAlgValuesSupported: "id_token_signing_alg_values_supported", idTokenEncryptionAlgValuesSupported: "id_token_encryption_alg_values_supported", idTokenEncryptionEncValuesSupported: "id_token_encryption_enc_values_supported", claimTypesSupported: "claim_types_supported", claimsSupported: "claims_supported", codeChallengeMethodsSupported: "code_challenge_methods_supported", promptValuesSupported: "prompt_values_supported", claimsParameterSupported: "claims_parameter_supported", requestParameterSupported: "request_parameter_supported", requestUriParameterSupported: "request_uri_parameter_supported", requireRequestUriRegistration: "require_request_uri_registration", serviceDocumentation: "service_documentation", opPolicyUri: "op_policy_uri", opTosUri: "op_tos_uri", logoUri: "logo_uri", clientIdMetadataDocumentSupported: "client_id_metadata_document_supported", authorizationDetailsTypesSupported: "authorization_details_types_supported", additionalProperties: null, }), }; }); export function serverConfigToJSON(serverConfig) { return JSON.stringify(ServerConfig$outboundSchema.parse(serverConfig)); } /** @internal */ export const UserAuthorization$outboundSchema = z.object({ enabled: z.boolean(), scopes: z.array(z.string()).optional(), }); export function userAuthorizationToJSON(userAuthorization) { return JSON.stringify(UserAuthorization$outboundSchema.parse(userAuthorization)); } /** @internal */ export const RefreshTokens$outboundSchema = z.object({ enabled: z.boolean(), }); export function refreshTokensToJSON(refreshTokens) { return JSON.stringify(RefreshTokens$outboundSchema.parse(refreshTokens)); } /** @internal */ export const ClientCredentials$outboundSchema = z.object({ enabled: z.boolean(), scopes: z.array(z.string()).optional(), }); export function clientCredentialsToJSON(clientCredentials) { return JSON.stringify(ClientCredentials$outboundSchema.parse(clientCredentials)); } /** @internal */ export const JwtBearer$outboundSchema = z.object({ enabled: z.boolean().optional(), scopes: z.array(z.string()).optional(), sub: z.string().optional(), iss: z.string().optional(), aud: z.string().optional(), additionalClaims: z.record(z.any()).optional(), ttl: z.number().optional(), useClientCredentials: z.boolean().optional(), }); export function jwtBearerToJSON(jwtBearer) { return JSON.stringify(JwtBearer$outboundSchema.parse(jwtBearer)); } /** @internal */ export const TypeOauth$outboundSchema = z.object({ serverUrl: z.string().optional(), serverConfig: z.lazy(() => ServerConfig$outboundSchema).optional(), clientId: z.string(), clientSecret: z.string().optional(), tokenEndpointAuthMethod: z.string().default("client_secret_post"), responseType: z.string().optional(), pkceRequired: z.boolean().optional(), codeChallengeMethod: z.string().optional(), userAuthorization: z.lazy(() => UserAuthorization$outboundSchema).optional(), refreshTokens: z.lazy(() => RefreshTokens$outboundSchema).optional(), clientCredentials: z.lazy(() => ClientCredentials$outboundSchema).optional(), defaultAudience: z.string().optional(), authorizationUrlParams: z.record(z.string()).optional(), jwtBearer: z.lazy(() => JwtBearer$outboundSchema).optional(), }); export function typeOauthToJSON(typeOauth) { return JSON.stringify(TypeOauth$outboundSchema.parse(typeOauth)); } /** @internal */ export const CreateConnectorData$outboundSchema = smartUnion([ z.lazy(() => TypeGithub$outboundSchema), z.lazy(() => TypeSlack$outboundSchema), z.lazy(() => TypeSalesforce$outboundSchema), z.lazy(() => TypeLinear$outboundSchema), z.lazy(() => TypeSnowflake$outboundSchema), z.lazy(() => TypeOauth$outboundSchema), z.lazy(() => TypeApiKey$outboundSchema), z.lazy(() => TypeSnowflakeWif$outboundSchema), z.record(z.any()), ]); export function createConnectorDataToJSON(createConnectorData) { return JSON.stringify(CreateConnectorData$outboundSchema.parse(createConnectorData)); } /** @internal */ export const CreateConnectorRequestBody$outboundSchema = z.object({ type: z.string(), service: z.string().optional(), uid: z.string().optional(), name: z.string().optional(), projectId: z.string().optional(), environments: z.array(z.string()).optional(), triggers: z.boolean().optional(), events: z.array(z.string()).optional(), icon: z.string().optional(), backgroundColor: z.string().optional(), accentColor: z.string().optional(), data: smartUnion([ z.lazy(() => TypeGithub$outboundSchema), z.lazy(() => TypeSlack$outboundSchema), z.lazy(() => TypeSalesforce$outboundSchema), z.lazy(() => TypeLinear$outboundSchema), z.lazy(() => TypeSnowflake$outboundSchema), z.lazy(() => TypeOauth$outboundSchema), z.lazy(() => TypeApiKey$outboundSchema), z.lazy(() => TypeSnowflakeWif$outboundSchema), z.record(z.any()), ]), }); export function createConnectorRequestBodyToJSON(createConnectorRequestBody) { return JSON.stringify(CreateConnectorRequestBody$outboundSchema.parse(createConnectorRequestBody)); } /** @internal */ export const CreatedByEnvironment$inboundSchema = z.nativeEnum(CreatedByEnvironment); /** @internal */ export const CreatedBy2$inboundSchema = z.object({ type: types.literal("project"), id: types.string(), environment: CreatedByEnvironment$inboundSchema, }); export function createdBy2FromJSON(jsonString) { return safeParse(jsonString, (x) => CreatedBy2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatedBy2' from JSON`); } /** @internal */ export const CreatedBy1$inboundSchema = z.object({ type: types.literal("user"), id: types.string(), }); export function createdBy1FromJSON(jsonString) { return safeParse(jsonString, (x) => CreatedBy1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatedBy1' from JSON`); } /** @internal */ export const CreatedBy$inboundSchema = z.union([ z.lazy(() => CreatedBy1$inboundSchema), z.lazy(() => CreatedBy2$inboundSchema), ]); export function createdByFromJSON(jsonString) { return safeParse(jsonString, (x) => CreatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatedBy' from JSON`); } /** @internal */ export const UpdatedByEnvironment$inboundSchema = z.nativeEnum(UpdatedByEnvironment); /** @internal */ export const UpdatedBy2$inboundSchema = z.object({ type: types.literal("project"), id: types.string(), environment: UpdatedByEnvironment$inboundSchema, }); export function updatedBy2FromJSON(jsonString) { return safeParse(jsonString, (x) => UpdatedBy2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdatedBy2' from JSON`); } /** @internal */ export const UpdatedBy1$inboundSchema = z.object({ type: types.literal("user"), id: types.string(), }); export function updatedBy1FromJSON(jsonString) { return safeParse(jsonString, (x) => UpdatedBy1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdatedBy1' from JSON`); } /** @internal */ export const UpdatedBy$inboundSchema = z.union([ z.lazy(() => UpdatedBy1$inboundSchema), z.lazy(() => UpdatedBy2$inboundSchema), ]); export function updatedByFromJSON(jsonString) { return safeParse(jsonString, (x) => UpdatedBy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdatedBy' from JSON`); } /** @internal */ export const CreateConnectorType$inboundSchema = z.nativeEnum(CreateConnectorType); /** @internal */ export const AppTokens$inboundSchema = z.object({ crossInstallation: types.boolean(), supportsRefinement: types.boolean(), requiresReinstallation: types.optional(types.boolean()), scopes: types.optional(z.array(types.string())), supportedAuthorizationDetails: types.optional(z.array(types.string())), }); export function appTokensFromJSON(jsonString) { return safeParse(jsonString, (x) => AppTokens$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AppTokens' from JSON`); } /** @internal */ export const UserTokens$inboundSchema = z.object({ crossInstallation: types.boolean(), supportsRefinement: types.boolean(), scopes: types.optional(z.array(types.string())), supportedAuthorizationDetails: types.optional(z.array(types.string())), }); export function userTokensFromJSON(jsonString) { return safeParse(jsonString, (x) => UserTokens$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UserTokens' from JSON`); } /** @internal */ export const SupportsIcon$inboundSchema = z.nativeEnum(SupportsIcon); /** @internal */ export const Triggers$inboundSchema = z.object({ enabled: types.boolean(), }); export function triggersFromJSON(jsonString) { return safeParse(jsonString, (x) => Triggers$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Triggers' from JSON`); } /** @internal */ export const TriggerDestinations$inboundSchema = z.object({ projectId: types.string(), branch: types.optional(types.string()), path: types.optional(types.string()), }); export function triggerDestinationsFromJSON(jsonString) { return safeParse(jsonString, (x) => TriggerDestinations$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TriggerDestinations' from JSON`); } /** @internal */ export const CreateConnectorProject$inboundSchema = z.object({ id: types.string(), name: types.string(), }); export function createConnectorProjectFromJSON(jsonString) { return safeParse(jsonString, (x) => CreateConnectorProject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateConnectorProject' from JSON`); } /** @internal */ export const CreateConnectorEnvironments$inboundSchema = z.nativeEnum(CreateConnectorEnvironments); /** @internal */ export const CreateConnectorItems$inboundSchema = z.object({ clientId: types.string(), projectId: types.string(), project: types.optional(z.lazy(() => CreateConnectorProject$inboundSchema)), environments: z.array(CreateConnectorEnvironments$inboundSchema), createdAt: types.number(), updatedAt: types.number(), }); export function createConnectorItemsFromJSON(jsonString) { return safeParse(jsonString, (x) => CreateConnectorItems$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateConnectorItems' from JSON`); } /** @internal */ export const CreateConnectorProjects$inboundSchema = z.object({ items: z.array(z.lazy(() => CreateConnectorItems$inboundSchema)), hasMore: types.boolean(), cursor: z.nullable(types.string()).optional(), }); export function createConnectorProjectsFromJSON(jsonString) { return safeParse(jsonString, (x) => CreateConnectorProjects$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateConnectorProjects' from JSON`); } /** @internal */ export const Includes$inboundSchema = z.object({ projects: types.optional(z.lazy(() => CreateConnectorProjects$inboundSchema)), }); export function includesFromJSON(jsonString) { return safeParse(jsonString, (x) => Includes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Includes' from JSON`); } /** @internal */ export const CreateConnectorResponseBody$inboundSchema = z.object({ id: types.string(), ownerId: types.string(), createdAt: types.number(), updatedAt: types.number(), deletedAt: types.optional(types.number()), createdBy: types.optional(z.union([ z.lazy(() => CreatedBy1$inboundSchema), z.lazy(() => CreatedBy2$inboundSchema), ])), updatedBy: types.optional(z.union([ z.lazy(() => UpdatedBy1$inboundSchema), z.lazy(() => UpdatedBy2$inboundSchema), ])), public: types.boolean(), uid: types.string(), type: CreateConnectorType$inboundSchema, service: types.string(), name: types.string(), clientUrl: z.nullable(types.string()).optional(), redirectUri: types.optional(types.string()), defaultInstallationId: types.optional(types.string()), data: z.record(z.any()), 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(() => AppTokens$inboundSchema)), userTokens: types.optional(z.lazy(() => UserTokens$inboundSchema)), supportsInstallation: types.boolean(), supportsRevocation: types.boolean(), ownerTenantId: types.optional(types.string()), supportsTriggers: types.boolean(), supportsIcon: SupportsIcon$inboundSchema, triggers: types.optional(z.lazy(() => Triggers$inboundSchema)), events: types.optional(z.array(types.string())), triggerDestinations: types.optional(z.array(z.lazy(() => TriggerDestinations$inboundSchema))), includes: types.optional(z.lazy(() => Includes$inboundSchema)), }); export function createConnectorResponseBodyFromJSON(jsonString) { return safeParse(jsonString, (x) => CreateConnectorResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateConnectorResponseBody' from JSON`); } //# sourceMappingURL=createconnectorop.js.map