@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>
286 lines (261 loc) • 7.8 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 { SDKValidationError } from "./sdkvalidationerror.js";
export type GetIntegrationResourceRequest = {
/**
* The ID of the integration configuration (installation) the resource belongs to
*/
integrationConfigurationId: string;
/**
* The ID provided by the 3rd party provider for the given resource
*/
resourceId: string;
};
/**
* The current status of the resource
*/
export const GetIntegrationResourceStatus = {
Error: "error",
Onboarding: "onboarding",
Pending: "pending",
Ready: "ready",
Resumed: "resumed",
Suspended: "suspended",
Uninstalled: "uninstalled",
} as const;
/**
* The current status of the resource
*/
export type GetIntegrationResourceStatus = ClosedEnum<
typeof GetIntegrationResourceStatus
>;
export type Experimentation = {
edgeConfigSyncingEnabled?: boolean | undefined;
edgeConfigId?: string | undefined;
edgeConfigTokenId?: string | undefined;
};
/**
* Any settings provided for the resource to support its product's protocols
*/
export type ProtocolSettings = {
experimentation?: Experimentation | undefined;
};
export const GetIntegrationResourceLevel = {
Error: "error",
Info: "info",
Warn: "warn",
} as const;
export type GetIntegrationResourceLevel = ClosedEnum<
typeof GetIntegrationResourceLevel
>;
/**
* The notification, if set, displayed to the user when viewing the resource in Vercel
*/
export type GetIntegrationResourceNotification = {
level: GetIntegrationResourceLevel;
title: string;
message?: string | undefined;
href?: string | undefined;
};
export type GetIntegrationResourceMetadata =
| string
| number
| Array<string>
| Array<number>
| boolean;
export type GetIntegrationResourceResponseBody = {
/**
* The ID provided by the 3rd party provider for the given resource
*/
id: string;
/**
* The ID assigned by Vercel for the given resource
*/
internalId: string;
/**
* The name of the resource as it is recorded in Vercel
*/
name: string;
/**
* The current status of the resource
*/
status?: GetIntegrationResourceStatus | undefined;
/**
* The ID of the product the resource is derived from
*/
productId: string;
/**
* Any settings provided for the resource to support its product's protocols
*/
protocolSettings?: ProtocolSettings | undefined;
/**
* The notification, if set, displayed to the user when viewing the resource in Vercel
*/
notification?: GetIntegrationResourceNotification | undefined;
/**
* The ID of the billing plan the resource is subscribed to, if applicable
*/
billingPlanId?: string | undefined;
/**
* The configured metadata for the resource as defined by its product's Metadata Schema
*/
metadata?: {
[k: string]: string | number | Array<string> | Array<number> | boolean;
} | undefined;
};
/** @internal */
export type GetIntegrationResourceRequest$Outbound = {
integrationConfigurationId: string;
resourceId: string;
};
/** @internal */
export const GetIntegrationResourceRequest$outboundSchema: z.ZodType<
GetIntegrationResourceRequest$Outbound,
z.ZodTypeDef,
GetIntegrationResourceRequest
> = z.object({
integrationConfigurationId: z.string(),
resourceId: z.string(),
});
export function getIntegrationResourceRequestToJSON(
getIntegrationResourceRequest: GetIntegrationResourceRequest,
): string {
return JSON.stringify(
GetIntegrationResourceRequest$outboundSchema.parse(
getIntegrationResourceRequest,
),
);
}
/** @internal */
export const GetIntegrationResourceStatus$inboundSchema: z.ZodNativeEnum<
typeof GetIntegrationResourceStatus
> = z.nativeEnum(GetIntegrationResourceStatus);
/** @internal */
export const Experimentation$inboundSchema: z.ZodType<
Experimentation,
z.ZodTypeDef,
unknown
> = z.object({
edgeConfigSyncingEnabled: types.optional(types.boolean()),
edgeConfigId: types.optional(types.string()),
edgeConfigTokenId: types.optional(types.string()),
});
export function experimentationFromJSON(
jsonString: string,
): SafeParseResult<Experimentation, SDKValidationError> {
return safeParse(
jsonString,
(x) => Experimentation$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Experimentation' from JSON`,
);
}
/** @internal */
export const ProtocolSettings$inboundSchema: z.ZodType<
ProtocolSettings,
z.ZodTypeDef,
unknown
> = z.object({
experimentation: types.optional(z.lazy(() => Experimentation$inboundSchema)),
});
export function protocolSettingsFromJSON(
jsonString: string,
): SafeParseResult<ProtocolSettings, SDKValidationError> {
return safeParse(
jsonString,
(x) => ProtocolSettings$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'ProtocolSettings' from JSON`,
);
}
/** @internal */
export const GetIntegrationResourceLevel$inboundSchema: z.ZodNativeEnum<
typeof GetIntegrationResourceLevel
> = z.nativeEnum(GetIntegrationResourceLevel);
/** @internal */
export const GetIntegrationResourceNotification$inboundSchema: z.ZodType<
GetIntegrationResourceNotification,
z.ZodTypeDef,
unknown
> = z.object({
level: GetIntegrationResourceLevel$inboundSchema,
title: types.string(),
message: types.optional(types.string()),
href: types.optional(types.string()),
});
export function getIntegrationResourceNotificationFromJSON(
jsonString: string,
): SafeParseResult<GetIntegrationResourceNotification, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
GetIntegrationResourceNotification$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetIntegrationResourceNotification' from JSON`,
);
}
/** @internal */
export const GetIntegrationResourceMetadata$inboundSchema: z.ZodType<
GetIntegrationResourceMetadata,
z.ZodTypeDef,
unknown
> = smartUnion([
types.string(),
types.number(),
z.array(types.string()),
z.array(types.number()),
types.boolean(),
]);
export function getIntegrationResourceMetadataFromJSON(
jsonString: string,
): SafeParseResult<GetIntegrationResourceMetadata, SDKValidationError> {
return safeParse(
jsonString,
(x) => GetIntegrationResourceMetadata$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetIntegrationResourceMetadata' from JSON`,
);
}
/** @internal */
export const GetIntegrationResourceResponseBody$inboundSchema: z.ZodType<
GetIntegrationResourceResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
id: types.string(),
internalId: types.string(),
name: types.string(),
status: types.optional(GetIntegrationResourceStatus$inboundSchema),
productId: types.string(),
protocolSettings: types.optional(
z.lazy(() => ProtocolSettings$inboundSchema),
),
notification: types.optional(
z.lazy(() => GetIntegrationResourceNotification$inboundSchema),
),
billingPlanId: types.optional(types.string()),
metadata: types.optional(
z.record(
smartUnion([
types.string(),
types.number(),
z.array(types.string()),
z.array(types.number()),
types.boolean(),
]),
),
),
});
export function getIntegrationResourceResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<GetIntegrationResourceResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) =>
GetIntegrationResourceResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'GetIntegrationResourceResponseBody' from JSON`,
);
}