@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>
115 lines (109 loc) • 3.7 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import {
ConnectConnectorUpdateData,
ConnectConnectorUpdateData$Outbound,
ConnectConnectorUpdateData$outboundSchema,
} from "./connectconnectorupdatedata.js";
/**
* Connector fields to update.
*/
export type ConnectUpdateConnectorRequest = {
/**
* Whether the triggers are enabled for this connector.
*/
triggers?: boolean | undefined;
/**
* Default trigger events for this connector.
*/
events?: Array<string> | undefined;
/**
* Provider configuration fields for the connector type.
*/
data?: ConnectConnectorUpdateData | undefined;
/**
* SHA-1 digest of a PNG or JPEG icon that is at least 640 by 640 pixels. This field does not accept a URL or image bytes.
*
* @remarks
*
* First compute the digest and upload the raw image with [POST /v2/files](https://vercel.com/docs/rest-api/deployments/upload-deployment-files). Send `Content-Length` and the same 40-character digest in `x-vercel-digest`. Then set `icon` to that digest.
*
* ```js
* import { createHash } from 'node:crypto';
* import { readFile } from 'node:fs/promises';
*
* const VERCEL_TOKEN = process.env.VERCEL_TOKEN;
* const connectorId = 'scl_...';
* const bytes = await readFile('icon.png');
* const digest = createHash('sha1').update(bytes).digest('hex');
*
* await fetch('https://api.vercel.com/v2/files', {
* method: 'POST',
* headers: {
* Authorization: `Bearer ${VERCEL_TOKEN}`,
* 'Content-Type': 'application/octet-stream',
* 'Content-Length': String(bytes.length),
* 'x-vercel-digest': digest,
* },
* body: bytes,
* });
*
* await fetch(`https://api.vercel.com/v2/connect/connectors/${connectorId}`, {
* method: 'PATCH',
* headers: {
* Authorization: `Bearer ${VERCEL_TOKEN}`,
* 'Content-Type': 'application/json',
* },
* body: JSON.stringify({ icon: digest }),
* });
* ```
*/
icon?: string | undefined;
backgroundColor?: string | undefined;
accentColor?: string | undefined;
/**
* Full team-scoped UID, such as `slack/my-bot`. It cannot contain whitespace, `%`, `#`, control characters, or Vercel-owned namespaces. Changing it breaks callers that use the old UID. The stable connector ID does not change.
*/
uid?: string | undefined;
/**
* Display name for the connector. It is trimmed and cannot be empty or contain control characters.
*/
name?: string | undefined;
};
/** @internal */
export type ConnectUpdateConnectorRequest$Outbound = {
triggers?: boolean | undefined;
events?: Array<string> | undefined;
data?: ConnectConnectorUpdateData$Outbound | undefined;
icon?: string | undefined;
backgroundColor?: string | undefined;
accentColor?: string | undefined;
uid?: string | undefined;
name?: string | undefined;
};
/** @internal */
export const ConnectUpdateConnectorRequest$outboundSchema: z.ZodType<
ConnectUpdateConnectorRequest$Outbound,
z.ZodTypeDef,
ConnectUpdateConnectorRequest
> = z.object({
triggers: z.boolean().optional(),
events: z.array(z.string()).optional(),
data: ConnectConnectorUpdateData$outboundSchema.optional(),
icon: z.string().optional(),
backgroundColor: z.string().optional(),
accentColor: z.string().optional(),
uid: z.string().optional(),
name: z.string().optional(),
});
export function connectUpdateConnectorRequestToJSON(
connectUpdateConnectorRequest: ConnectUpdateConnectorRequest,
): string {
return JSON.stringify(
ConnectUpdateConnectorRequest$outboundSchema.parse(
connectUpdateConnectorRequest,
),
);
}