@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>
725 lines (696 loc) • 21.7 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import {
collectExtraKeys as collectExtraKeys$,
safeParse,
} from "../lib/schemas.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";
/**
* Timestamp in milliseconds, or a valid Date string.
*
* @remarks
*
* Selects data from (including) this date and time.
* Will be adjusted according to the desired time granularity.
*/
export type CountPageviewsQueryParamSince = number | string;
/**
* Timestamp in milliseconds, or a valid Date string.
*
* @remarks
*
* Selects data until (including) this date.
* Will be adjusted according to the desired time granularity.
*/
export type CountPageviewsQueryParamUntil = number | string;
export type CountPageviewsRequest = {
/**
* The project identifier or the project name
*/
projectId: string;
/**
* Timestamp in milliseconds, or a valid Date string.
*
* @remarks
*
* Selects data from (including) this date and time.
* Will be adjusted according to the desired time granularity.
*/
since?: number | string | undefined;
/**
* Timestamp in milliseconds, or a valid Date string.
*
* @remarks
*
* Selects data until (including) this date.
* Will be adjusted according to the desired time granularity.
*/
until?: number | string | undefined;
/**
* OData-compliant filter. Encode the value when sending it in a URL.
*
* @remarks
*
* Allows filtering on one or multiple dimensions.
*
* Supported dimensions: country, deviceType, environment, requestPath, referrerHostname, osName, browserName, route, utmSource, utmMedium, utmCampaign, utmContent, utmTerm.
*
* JSON dimensions filtered by key: flags/<name>, for example flags/beta_banner eq 'true'. Wrap keys containing characters other than letters, digits, and underscores in single quotes, for example flags/'my-flag' eq 'true'.
*
* Supported operations include eq, ne, in, and logical operators and, or, not with parentheses. Functions such as startswith are supported by the OData parser.
*/
filter?: string | undefined;
/**
* 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;
};
export type CountPageviewsQuery = {
since: string;
until: string;
filter?: string | undefined;
};
export type CountPageviewsData2 = {
visitors: number;
pageviews: number;
};
export type CountPageviewsData1 = {
projectId: string;
country: string;
deviceType: string;
environment: string;
requestPath: string;
referrerHostname: string;
osName: string;
browserName: string;
route: string;
utmSource: string;
utmMedium: string;
utmCampaign: string;
utmContent: string;
utmTerm: string;
flags: string;
errorMessage: string;
entryRevalidateSeconds: string;
projectName: string;
deploymentId: string;
pathType: string;
pathTypeVariant: string;
requestHostname: string;
requestResolvedIp: string;
requestMethod: string;
requestExtension: string;
requestId: string;
requestApi: string;
referrerUrl: string;
serverActionName: string;
httpStatus: string;
errorCode: string;
source: string;
edgeType: string;
reason: string;
edgeNetworkRegion: string;
functionRegion: string;
imageTransformationRegion: string;
dataCacheRegion: string;
cause: string;
runtime: string;
provider: string;
isrCacheRegion: string;
isrAction: string;
cacheResult: string;
cacheOperation: string;
cacheHostname: string;
cachePath: string;
cacheHitState: string;
cacheHitLevel: string;
cacheApi: string;
cacheReason: string;
pprState: string;
clientIp: string;
clientIpCountry: string;
clientUserAgent: string;
httpAccept: string;
clientJa4Digest: string;
asnId: string;
asnName: string;
botName: string;
botCategory: string;
botCategoryLegacy: string;
botVerified: string;
botCheckResult: string;
deepAnalysisCheck: string;
wafAction: string;
wafRuleId: string;
ruleCategory: string;
skewProtection: string;
functionStartType: string;
functionDispatcher: string;
isAdditionalRequest: string;
originHostname: string;
originPath: string;
originRoute: string;
fetchType: string;
fetchIndex: string;
imageSource: string;
sourceImage: string;
sourceImagePathname: string;
sourceImageHostname: string;
sourceImageHash: string;
optimizedQuality: string;
optimizedWidthPixels: string;
optimizedFormatMimeType: string;
vdcOperationOrigin: string;
entryName: string;
entryId: string;
entryItemId: string;
tagName: string;
cacheTags: string;
storeId: string;
storeName: string;
blobOperationType: string;
blobOperationLevel: string;
visitorId: string;
eventName: string;
attributionTarget: string;
attributionEventName: string;
metricName: string;
attributes: string;
flagKey: string;
flagVariant: string;
flagEvaluationReason: string;
flagClientName: string;
sdkKeyId: string;
sdkKeyEnvironment: string;
reportingProjectId: string;
reportingProjectName: string;
eventData: string;
middlewareAction: string;
middlewareActionTarget: string;
aiModel: string;
aiGatewayModelId: string;
aiProvider: string;
aiModelType: string;
servedSpeed: string;
virtualModelSlug: string;
virtualModelKind: string;
inferenceEndpointSlug: string;
inferenceScope: string;
inferenceGeoRegion: string;
inferenceProviderRegion: string;
requestedInferenceRegion: string;
costCurrency: string;
marketCostCurrency: string;
cachedInputTokensCurrency: string;
cacheCreationInputTokensCurrency: string;
cacheCreation1hInputTokensCurrency: string;
surchargeCostCurrency: string;
gatewayCostCurrency: string;
keyId: string;
keyName: string;
authMethod: string;
appName: string;
codingAgent: string;
isByok: string;
spendAttribution: string;
isPrivateModel: string;
isStreaming: string;
isRequestZdr: string;
hipaaRequested: string;
quotaRequested: string;
quotaEntityId: string;
quotaEntityType: string;
videoResolution: string;
videoAspectRatio: string;
piiRedactionApplied: string;
moderationApplied: string;
queueName: string;
consumerGroup: string;
messageId: string;
eventType: string;
notificationUrl: string;
queueRegion: string;
sandboxSessionId: string;
sandboxName: string;
workflowRunId: string;
workflowName: string;
workflowStatus: string;
stepRunId: string;
workflowStepName: string;
workflowEventType: string;
region: string;
specVersion: string;
contentType: string;
rewriteDestinationHostname: string;
externalRewriteTargetHost: string;
externalRewriteTargetPath: string;
commitSha: string;
reviewConclusion: string;
pullRequestNumber: string;
repositoryName: string;
repositoryOwner: string;
reviewStatus: string;
pullRequestState: string;
triggeringTag: string;
redirectLocation: string;
microfrontendsResponseReason: string;
microfrontendsMatchedPath: string;
microfrontendsDefaultAppDeploymentId: string;
microfrontendsDefaultAppProjectId: string;
service: string;
isPrefetchRequest: string;
spendReportGroupBy: string;
spendReportDatePart: string;
providerAttemptCanonicalSlug: string;
providerAttemptCredentialType: string;
providerAttemptSuccess: string;
providerAttemptStatusCode: string;
providerAttemptTimeout: string;
providerAttemptIsFinal: string;
providerAttemptNumber: string;
providerAttemptTotalInRequest: string;
generationId: string;
sessionId: string;
contentCaptureStatus: string;
contentCaptureInputs: string;
contentCaptureOutputs: string;
transcriptStatus: string;
transcriptInputs: string;
transcriptOutputs: string;
providerAttemptError: string;
providerAttemptSafetyIdentifier: string;
providerAttemptDevSafetyIdentifier: string;
providerAttemptRegion: string;
providerAttemptModelIndex: string;
toolCallType: string;
toolCallProvider: string;
toolCallSuccess: string;
toolCallErrorType: string;
toolCallStatusCode: string;
environmentId: string;
billableRegion: string;
direction: string;
networkTenancy: string;
trafficSource: string;
networkId: string;
privatelinkEndpointId: string;
privatelinkDnsName: string;
privatelinkIpAddress: string;
additionalProperties?: { [k: string]: number | null } | undefined;
};
export type CountPageviewsData = CountPageviewsData1 | CountPageviewsData2;
export type CountPageviewsResponseBody = {
version: number;
query: CountPageviewsQuery;
data: CountPageviewsData1 | CountPageviewsData2;
};
/** @internal */
export type CountPageviewsQueryParamSince$Outbound = number | string;
/** @internal */
export const CountPageviewsQueryParamSince$outboundSchema: z.ZodType<
CountPageviewsQueryParamSince$Outbound,
z.ZodTypeDef,
CountPageviewsQueryParamSince
> = smartUnion([z.number(), z.string()]);
export function countPageviewsQueryParamSinceToJSON(
countPageviewsQueryParamSince: CountPageviewsQueryParamSince,
): string {
return JSON.stringify(
CountPageviewsQueryParamSince$outboundSchema.parse(
countPageviewsQueryParamSince,
),
);
}
/** @internal */
export type CountPageviewsQueryParamUntil$Outbound = number | string;
/** @internal */
export const CountPageviewsQueryParamUntil$outboundSchema: z.ZodType<
CountPageviewsQueryParamUntil$Outbound,
z.ZodTypeDef,
CountPageviewsQueryParamUntil
> = smartUnion([z.number(), z.string()]);
export function countPageviewsQueryParamUntilToJSON(
countPageviewsQueryParamUntil: CountPageviewsQueryParamUntil,
): string {
return JSON.stringify(
CountPageviewsQueryParamUntil$outboundSchema.parse(
countPageviewsQueryParamUntil,
),
);
}
/** @internal */
export type CountPageviewsRequest$Outbound = {
projectId: string;
since?: number | string | undefined;
until?: number | string | undefined;
filter?: string | undefined;
teamId?: string | undefined;
slug?: string | undefined;
};
/** @internal */
export const CountPageviewsRequest$outboundSchema: z.ZodType<
CountPageviewsRequest$Outbound,
z.ZodTypeDef,
CountPageviewsRequest
> = z.object({
projectId: z.string(),
since: smartUnion([z.number(), z.string()]).optional(),
until: smartUnion([z.number(), z.string()]).optional(),
filter: z.string().optional(),
teamId: z.string().optional(),
slug: z.string().optional(),
});
export function countPageviewsRequestToJSON(
countPageviewsRequest: CountPageviewsRequest,
): string {
return JSON.stringify(
CountPageviewsRequest$outboundSchema.parse(countPageviewsRequest),
);
}
/** @internal */
export const CountPageviewsQuery$inboundSchema: z.ZodType<
CountPageviewsQuery,
z.ZodTypeDef,
unknown
> = z.object({
since: types.string(),
until: types.string(),
filter: types.optional(types.string()),
});
export function countPageviewsQueryFromJSON(
jsonString: string,
): SafeParseResult<CountPageviewsQuery, SDKValidationError> {
return safeParse(
jsonString,
(x) => CountPageviewsQuery$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CountPageviewsQuery' from JSON`,
);
}
/** @internal */
export const CountPageviewsData2$inboundSchema: z.ZodType<
CountPageviewsData2,
z.ZodTypeDef,
unknown
> = z.object({
visitors: types.number(),
pageviews: types.number(),
});
export function countPageviewsData2FromJSON(
jsonString: string,
): SafeParseResult<CountPageviewsData2, SDKValidationError> {
return safeParse(
jsonString,
(x) => CountPageviewsData2$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CountPageviewsData2' from JSON`,
);
}
/** @internal */
export const CountPageviewsData1$inboundSchema: z.ZodType<
CountPageviewsData1,
z.ZodTypeDef,
unknown
> = collectExtraKeys$(
z.object({
projectId: types.string(),
country: types.string(),
deviceType: types.string(),
environment: types.string(),
requestPath: types.string(),
referrerHostname: types.string(),
osName: types.string(),
browserName: types.string(),
route: types.string(),
utmSource: types.string(),
utmMedium: types.string(),
utmCampaign: types.string(),
utmContent: types.string(),
utmTerm: types.string(),
flags: types.string(),
errorMessage: types.string(),
entryRevalidateSeconds: types.string(),
projectName: types.string(),
deploymentId: types.string(),
pathType: types.string(),
pathTypeVariant: types.string(),
requestHostname: types.string(),
requestResolvedIp: types.string(),
requestMethod: types.string(),
requestExtension: types.string(),
requestId: types.string(),
requestApi: types.string(),
referrerUrl: types.string(),
serverActionName: types.string(),
httpStatus: types.string(),
errorCode: types.string(),
source: types.string(),
edgeType: types.string(),
reason: types.string(),
edgeNetworkRegion: types.string(),
functionRegion: types.string(),
imageTransformationRegion: types.string(),
dataCacheRegion: types.string(),
cause: types.string(),
runtime: types.string(),
provider: types.string(),
isrCacheRegion: types.string(),
isrAction: types.string(),
cacheResult: types.string(),
cacheOperation: types.string(),
cacheHostname: types.string(),
cachePath: types.string(),
cacheHitState: types.string(),
cacheHitLevel: types.string(),
cacheApi: types.string(),
cacheReason: types.string(),
pprState: types.string(),
clientIp: types.string(),
clientIpCountry: types.string(),
clientUserAgent: types.string(),
httpAccept: types.string(),
clientJa4Digest: types.string(),
asnId: types.string(),
asnName: types.string(),
botName: types.string(),
botCategory: types.string(),
botCategoryLegacy: types.string(),
botVerified: types.string(),
botCheckResult: types.string(),
deepAnalysisCheck: types.string(),
wafAction: types.string(),
wafRuleId: types.string(),
ruleCategory: types.string(),
skewProtection: types.string(),
functionStartType: types.string(),
functionDispatcher: types.string(),
isAdditionalRequest: types.string(),
originHostname: types.string(),
originPath: types.string(),
originRoute: types.string(),
fetchType: types.string(),
fetchIndex: types.string(),
imageSource: types.string(),
sourceImage: types.string(),
sourceImagePathname: types.string(),
sourceImageHostname: types.string(),
sourceImageHash: types.string(),
optimizedQuality: types.string(),
optimizedWidthPixels: types.string(),
optimizedFormatMimeType: types.string(),
vdcOperationOrigin: types.string(),
entryName: types.string(),
entryId: types.string(),
entryItemId: types.string(),
tagName: types.string(),
cacheTags: types.string(),
storeId: types.string(),
storeName: types.string(),
blobOperationType: types.string(),
blobOperationLevel: types.string(),
visitorId: types.string(),
eventName: types.string(),
attributionTarget: types.string(),
attributionEventName: types.string(),
metricName: types.string(),
attributes: types.string(),
flagKey: types.string(),
flagVariant: types.string(),
flagEvaluationReason: types.string(),
flagClientName: types.string(),
sdkKeyId: types.string(),
sdkKeyEnvironment: types.string(),
reportingProjectId: types.string(),
reportingProjectName: types.string(),
eventData: types.string(),
middlewareAction: types.string(),
middlewareActionTarget: types.string(),
aiModel: types.string(),
aiGatewayModelId: types.string(),
aiProvider: types.string(),
aiModelType: types.string(),
servedSpeed: types.string(),
virtualModelSlug: types.string(),
virtualModelKind: types.string(),
inferenceEndpointSlug: types.string(),
inferenceScope: types.string(),
inferenceGeoRegion: types.string(),
inferenceProviderRegion: types.string(),
requestedInferenceRegion: types.string(),
costCurrency: types.string(),
marketCostCurrency: types.string(),
cachedInputTokensCurrency: types.string(),
cacheCreationInputTokensCurrency: types.string(),
cacheCreation1hInputTokensCurrency: types.string(),
surchargeCostCurrency: types.string(),
gatewayCostCurrency: types.string(),
keyId: types.string(),
keyName: types.string(),
authMethod: types.string(),
appName: types.string(),
codingAgent: types.string(),
isByok: types.string(),
spendAttribution: types.string(),
isPrivateModel: types.string(),
isStreaming: types.string(),
isRequestZdr: types.string(),
hipaaRequested: types.string(),
quotaRequested: types.string(),
quotaEntityId: types.string(),
quotaEntityType: types.string(),
videoResolution: types.string(),
videoAspectRatio: types.string(),
piiRedactionApplied: types.string(),
moderationApplied: types.string(),
queueName: types.string(),
consumerGroup: types.string(),
messageId: types.string(),
eventType: types.string(),
notificationUrl: types.string(),
queueRegion: types.string(),
sandboxSessionId: types.string(),
sandboxName: types.string(),
workflowRunId: types.string(),
workflowName: types.string(),
workflowStatus: types.string(),
stepRunId: types.string(),
workflowStepName: types.string(),
workflowEventType: types.string(),
region: types.string(),
specVersion: types.string(),
contentType: types.string(),
rewriteDestinationHostname: types.string(),
externalRewriteTargetHost: types.string(),
externalRewriteTargetPath: types.string(),
commitSha: types.string(),
reviewConclusion: types.string(),
pullRequestNumber: types.string(),
repositoryName: types.string(),
repositoryOwner: types.string(),
reviewStatus: types.string(),
pullRequestState: types.string(),
triggeringTag: types.string(),
redirectLocation: types.string(),
microfrontendsResponseReason: types.string(),
microfrontendsMatchedPath: types.string(),
microfrontendsDefaultAppDeploymentId: types.string(),
microfrontendsDefaultAppProjectId: types.string(),
service: types.string(),
isPrefetchRequest: types.string(),
spendReportGroupBy: types.string(),
spendReportDatePart: types.string(),
providerAttemptCanonicalSlug: types.string(),
providerAttemptCredentialType: types.string(),
providerAttemptSuccess: types.string(),
providerAttemptStatusCode: types.string(),
providerAttemptTimeout: types.string(),
providerAttemptIsFinal: types.string(),
providerAttemptNumber: types.string(),
providerAttemptTotalInRequest: types.string(),
generationId: types.string(),
sessionId: types.string(),
contentCaptureStatus: types.string(),
contentCaptureInputs: types.string(),
contentCaptureOutputs: types.string(),
transcriptStatus: types.string(),
transcriptInputs: types.string(),
transcriptOutputs: types.string(),
providerAttemptError: types.string(),
providerAttemptSafetyIdentifier: types.string(),
providerAttemptDevSafetyIdentifier: types.string(),
providerAttemptRegion: types.string(),
providerAttemptModelIndex: types.string(),
toolCallType: types.string(),
toolCallProvider: types.string(),
toolCallSuccess: types.string(),
toolCallErrorType: types.string(),
toolCallStatusCode: types.string(),
environmentId: types.string(),
billableRegion: types.string(),
direction: types.string(),
networkTenancy: types.string(),
trafficSource: types.string(),
networkId: types.string(),
privatelinkEndpointId: types.string(),
privatelinkDnsName: types.string(),
privatelinkIpAddress: types.string(),
}).catchall(types.number()),
"additionalProperties",
true,
);
export function countPageviewsData1FromJSON(
jsonString: string,
): SafeParseResult<CountPageviewsData1, SDKValidationError> {
return safeParse(
jsonString,
(x) => CountPageviewsData1$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CountPageviewsData1' from JSON`,
);
}
/** @internal */
export const CountPageviewsData$inboundSchema: z.ZodType<
CountPageviewsData,
z.ZodTypeDef,
unknown
> = smartUnion([
z.lazy(() => CountPageviewsData1$inboundSchema),
z.lazy(() => CountPageviewsData2$inboundSchema),
]);
export function countPageviewsDataFromJSON(
jsonString: string,
): SafeParseResult<CountPageviewsData, SDKValidationError> {
return safeParse(
jsonString,
(x) => CountPageviewsData$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CountPageviewsData' from JSON`,
);
}
/** @internal */
export const CountPageviewsResponseBody$inboundSchema: z.ZodType<
CountPageviewsResponseBody,
z.ZodTypeDef,
unknown
> = z.object({
version: types.number(),
query: z.lazy(() => CountPageviewsQuery$inboundSchema),
data: smartUnion([
z.lazy(() => CountPageviewsData1$inboundSchema),
z.lazy(() => CountPageviewsData2$inboundSchema),
]),
});
export function countPageviewsResponseBodyFromJSON(
jsonString: string,
): SafeParseResult<CountPageviewsResponseBody, SDKValidationError> {
return safeParse(
jsonString,
(x) => CountPageviewsResponseBody$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'CountPageviewsResponseBody' from JSON`,
);
}