@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>
436 lines (400 loc) • 12.1 kB
text/typescript
/*
* 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 { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";
/**
* The delivery log format
*/
export const CreateLogDrainDeliveryFormat = {
Json: "json",
Ndjson: "ndjson",
} as const;
/**
* The delivery log format
*/
export type CreateLogDrainDeliveryFormat = ClosedEnum<
typeof CreateLogDrainDeliveryFormat
>;
export const CreateLogDrainSources = {
Static: "static",
Lambda: "lambda",
Build: "build",
Edge: "edge",
External: "external",
Firewall: "firewall",
} as const;
export type CreateLogDrainSources = ClosedEnum<typeof CreateLogDrainSources>;
export const CreateLogDrainEnvironments = {
Preview: "preview",
Production: "production",
} as const;
export type CreateLogDrainEnvironments = ClosedEnum<
typeof CreateLogDrainEnvironments
>;
export type CreateLogDrainRequestBody = {
/**
* The name of the log drain
*/
name: string;
projectIds?: Array<string> | undefined;
/**
* A secret to sign log drain notification headers so a consumer can verify their authenticity
*/
secret?: string | undefined;
/**
* The delivery log format
*/
deliveryFormat?: CreateLogDrainDeliveryFormat | undefined;
/**
* The url where you will receive logs. The protocol must be `https://` or `http://` when type is `json` and `ndjson`.
*/
url: string;
sources?: Array<CreateLogDrainSources> | undefined;
/**
* Headers to be sent together with the request
*/
headers?: { [k: string]: string } | undefined;
environments?: Array<CreateLogDrainEnvironments> | undefined;
};
export type CreateLogDrainRequest = {
/**
* The Team identifier to perform the request on behalf of.
*/
teamId?: string | undefined;
/**
* The Team slug to perform the request on behalf of.
*/
slug?: string | undefined;
requestBody: CreateLogDrainRequestBody;
};
/**
* The delivery log format
*/
export const CreateLogDrainLogDrainsDeliveryFormat = {
Json: "json",
Ndjson: "ndjson",
Protobuf: "protobuf",
} as const;
/**
* The delivery log format
*/
export type CreateLogDrainLogDrainsDeliveryFormat = ClosedEnum<
typeof CreateLogDrainLogDrainsDeliveryFormat
>;
/**
* The sources from which logs are currently being delivered to this log drain.
*/
export const CreateLogDrainLogDrainsSources = {
Build: "build",
Edge: "edge",
External: "external",
Firewall: "firewall",
Lambda: "lambda",
Redirect: "redirect",
Static: "static",
} as const;
/**
* The sources from which logs are currently being delivered to this log drain.
*/
export type CreateLogDrainLogDrainsSources = ClosedEnum<
typeof CreateLogDrainLogDrainsSources
>;
/**
* Whether the log drain was created by an integration or by a user
*/
export const CreateLogDrainCreatedFrom = {
Integration: "integration",
SelfServed: "self-served",
} as const;
/**
* Whether the log drain was created by an integration or by a user
*/
export type CreateLogDrainCreatedFrom = ClosedEnum<
typeof CreateLogDrainCreatedFrom
>;
/**
* The environment of log drain
*/
export const CreateLogDrainLogDrainsEnvironments = {
Preview: "preview",
Production: "production",
} as const;
/**
* The environment of log drain
*/
export type CreateLogDrainLogDrainsEnvironments = ClosedEnum<
typeof CreateLogDrainLogDrainsEnvironments
>;
export type CreateLogDrainSource2 = {
kind: "integration";
resourceId?: string | undefined;
externalResourceId?: string | undefined;
integrationId: string;
integrationConfigurationId: string;
};
export type CreateLogDrainSource1 = {
kind: "self-served";
};
export type CreateLogDrainSource =
| CreateLogDrainSource1
| CreateLogDrainSource2;
/**
* The log drain was successfully created
*/
export type CreateLogDrainResponseBody = {
/**
* The oauth2 client application id that created this log drain
*/
clientId?: string | undefined;
/**
* The client configuration this log drain was created with
*/
configurationId?: string | undefined;
/**
* A timestamp that tells you when the log drain was created
*/
createdAt: number;
/**
* The unique identifier of the log drain. Always prefixed with `ld_`
*/
id: string;
/**
* The delivery log format
*/
deliveryFormat?: CreateLogDrainLogDrainsDeliveryFormat | undefined;
/**
* The name of the log drain
*/
name: string;
/**
* The identifier of the team or user whose events will trigger the log drain
*/
ownerId: string;
projectId?: string | null | undefined;
/**
* The identifier of the projects this log drain is associated with
*/
projectIds?: Array<string> | undefined;
/**
* The URL to call when logs are generated
*/
url: string;
/**
* The sources from which logs are currently being delivered to this log drain.
*/
sources?: Array<CreateLogDrainLogDrainsSources> | undefined;
/**
* Whether the log drain was created by an integration or by a user
*/
createdFrom?: CreateLogDrainCreatedFrom | undefined;
/**
* The headers to send with the request
*/
headers?: { [k: string]: string } | undefined;
/**
* The environment of log drain
*/
environments?: Array<CreateLogDrainLogDrainsEnvironments> | undefined;
/**
* The branch regexp of log drain
*/
branch?: string | undefined;
/**
* The sampling rate of log drain
*/
samplingRate?: number | undefined;
source: CreateLogDrainSource1 | CreateLogDrainSource2;
};
/** @internal */
export const CreateLogDrainDeliveryFormat$outboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainDeliveryFormat
> = z.nativeEnum(CreateLogDrainDeliveryFormat);
/** @internal */
export const CreateLogDrainSources$outboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainSources
> = z.nativeEnum(CreateLogDrainSources);
/** @internal */
export const CreateLogDrainEnvironments$outboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainEnvironments
> = z.nativeEnum(CreateLogDrainEnvironments);
/** @internal */
export type CreateLogDrainRequestBody$Outbound = {
name: string;
projectIds?: Array<string> | undefined;
secret?: string | undefined;
deliveryFormat?: string | undefined;
url: string;
sources?: Array<string> | undefined;
headers?: { [k: string]: string } | undefined;
environments?: Array<string> | undefined;
};
/** @internal */
export const CreateLogDrainRequestBody$outboundSchema: z.ZodType<
CreateLogDrainRequestBody$Outbound,
z.ZodTypeDef,
CreateLogDrainRequestBody
> = z.object({
name: z.string(),
projectIds: z.array(z.string()).optional(),
secret: z.string().optional(),
deliveryFormat: CreateLogDrainDeliveryFormat$outboundSchema.optional(),
url: z.string(),
sources: z.array(CreateLogDrainSources$outboundSchema).optional(),
headers: z.record(z.string()).optional(),
environments: z.array(CreateLogDrainEnvironments$outboundSchema).optional(),
});
export function createLogDrainRequestBodyToJSON(
createLogDrainRequestBody: CreateLogDrainRequestBody,
): string {
return JSON.stringify(
CreateLogDrainRequestBody$outboundSchema.parse(createLogDrainRequestBody),
);
}
/** @internal */
export type CreateLogDrainRequest$Outbound = {
teamId?: string | undefined;
slug?: string | undefined;
RequestBody: CreateLogDrainRequestBody$Outbound;
};
/** @internal */
export const CreateLogDrainRequest$outboundSchema: z.ZodType<
CreateLogDrainRequest$Outbound,
z.ZodTypeDef,
CreateLogDrainRequest
> = z.object({
teamId: z.string().optional(),
slug: z.string().optional(),
requestBody: z.lazy(() => CreateLogDrainRequestBody$outboundSchema),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function createLogDrainRequestToJSON(
createLogDrainRequest: CreateLogDrainRequest,
): string {
return JSON.stringify(
CreateLogDrainRequest$outboundSchema.parse(createLogDrainRequest),
);
}
/** @internal */
export const CreateLogDrainLogDrainsDeliveryFormat$inboundSchema:
z.ZodNativeEnum<typeof CreateLogDrainLogDrainsDeliveryFormat> = z.nativeEnum(
CreateLogDrainLogDrainsDeliveryFormat,
);
/** @internal */
export const CreateLogDrainLogDrainsSources$inboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainLogDrainsSources
> = z.nativeEnum(CreateLogDrainLogDrainsSources);
/** @internal */
export const CreateLogDrainCreatedFrom$inboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainCreatedFrom
> = z.nativeEnum(CreateLogDrainCreatedFrom);
/** @internal */
export const CreateLogDrainLogDrainsEnvironments$inboundSchema: z.ZodNativeEnum<
typeof CreateLogDrainLogDrainsEnvironments
> = z.nativeEnum(CreateLogDrainLogDrainsEnvironments);
/** @internal */
export const CreateLogDrainSource2$inboundSchema: z.ZodType<
CreateLogDrainSource2,
z.ZodTypeDef,
unknown
> = z.object({
kind: types.literal("integration"),
resourceId: types.optional(types.string()),
externalResourceId: types.optional(types.string()),
integrationId: types.string(),
integrationConfigurationId: types.string(),
});
export function createLogDrainSource2FromJSON(
jsonString: string,
): SafeParseResult<CreateLogDrainSource2, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateLogDrainSource2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateLogDrainSource2' from JSON`,
);
}
/** @internal */
export const CreateLogDrainSource1$inboundSchema: z.ZodType<
CreateLogDrainSource1,
z.ZodTypeDef,
unknown
> = z.object({
kind: types.literal("self-served"),
});
export function createLogDrainSource1FromJSON(
jsonString: string,
): SafeParseResult<CreateLogDrainSource1, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateLogDrainSource1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateLogDrainSource1' from JSON`,
);
}
/** @internal */
export const CreateLogDrainSource$inboundSchema: z.ZodType<
CreateLogDrainSource,
z.ZodTypeDef,
unknown
> = z.union([
z.lazy(() => CreateLogDrainSource1$inboundSchema),
z.lazy(() => CreateLogDrainSource2$inboundSchema),
]);
export function createLogDrainSourceFromJSON(
jsonString: string,
): SafeParseResult<CreateLogDrainSource, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateLogDrainSource$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateLogDrainSource' from JSON`,
);
}
/** @internal */
export const CreateLogDrainResponseBody$inboundSchema: z.ZodType<
CreateLogDrainResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
clientId: types.optional(types.string()),
configurationId: types.optional(types.string()),
createdAt: types.number(),
id: types.string(),
deliveryFormat: types.optional(
CreateLogDrainLogDrainsDeliveryFormat$inboundSchema,
),
name: types.string(),
ownerId: types.string(),
projectId: z.nullable(types.string()).optional(),
projectIds: types.optional(z.array(types.string())),
url: types.string(),
sources: types.optional(
z.array(CreateLogDrainLogDrainsSources$inboundSchema),
),
createdFrom: types.optional(CreateLogDrainCreatedFrom$inboundSchema),
headers: types.optional(z.record(types.string())),
environments: types.optional(
z.array(CreateLogDrainLogDrainsEnvironments$inboundSchema),
),
branch: types.optional(types.string()),
samplingRate: types.optional(types.number()),
source: z.union([
z.lazy(() => CreateLogDrainSource1$inboundSchema),
z.lazy(() => CreateLogDrainSource2$inboundSchema),
]),
});
export function createLogDrainResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<CreateLogDrainResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => CreateLogDrainResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CreateLogDrainResponseBody' from JSON`,
);
}