/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The request as defined in OpenApi Spec. */ export type Operation = { /** * The OpenApi Operation Id associated with the request */ id: string; /** * The OpenApi Operation name associated with the request */ name: string; }; /** * Apideck service provider associated with request. */ export type Service = { /** * Apideck service provider id. */ id: string; /** * Apideck service provider name. */ name: string; }; /** * Which Unified Api request was made to. */ export const UnifiedApi = { Crm: "crm", Lead: "lead", Proxy: "proxy", Vault: "vault", Accounting: "accounting", Hris: "hris", Ats: "ats", Ecommerce: "ecommerce", IssueTracking: "issue-tracking", Pos: "pos", FileStorage: "file-storage", Sms: "sms", } as const; /** * Which Unified Api request was made to. */ export type UnifiedApi = ClosedEnum; export type Log = { /** * Indicates if the request was made via REST or Graphql endpoint. */ apiStyle: string; /** * The Apideck base URL the request was made to. */ baseUrl: string; /** * Indicates whether or not this is a child or parent request. */ childRequest: boolean; /** * The consumer Id associated with the request. */ consumerId: string; /** * The entire execution time in milliseconds it took to call the Apideck service provider. */ duration: number; /** * If error occurred, this is brief explanation */ errorMessage?: string | null | undefined; /** * The entire execution time in milliseconds it took to make the request. */ execution: number; /** * When request is a parent request, this indicates if there are child requests associated. */ hasChildren: boolean; /** * HTTP Method of request. */ httpMethod: string; /** * UUID acting as Request Identifier. */ id: string; /** * Latency added by making this request via Unified Api. */ latency: number; /** * The request as defined in OpenApi Spec. */ operation: Operation; /** * When request is a child request, this UUID indicates it's parent request. */ parentId: string | null; /** * The path component of the URI the request was made to. */ path: string; /** * Indicates whether the request was made using Apidecks sandbox credentials or not. */ sandbox: boolean; /** * Apideck service provider associated with request. */ service: Service; /** * The IP address of the source of the request. */ sourceIp?: string | null | undefined; /** * HTTP Status code that was returned. */ statusCode: number; /** * Whether or not the request was successful. */ success: boolean; /** * ISO Date and time when the request was made. */ timestamp: string; /** * Which Unified Api request was made to. */ unifiedApi: UnifiedApi; }; /** @internal */ export const Operation$inboundSchema: z.ZodType< Operation, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.string(), }); /** @internal */ export type Operation$Outbound = { id: string; name: string; }; /** @internal */ export const Operation$outboundSchema: z.ZodType< Operation$Outbound, z.ZodTypeDef, Operation > = z.object({ id: z.string(), name: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Operation$ { /** @deprecated use `Operation$inboundSchema` instead. */ export const inboundSchema = Operation$inboundSchema; /** @deprecated use `Operation$outboundSchema` instead. */ export const outboundSchema = Operation$outboundSchema; /** @deprecated use `Operation$Outbound` instead. */ export type Outbound = Operation$Outbound; } export function operationToJSON(operation: Operation): string { return JSON.stringify(Operation$outboundSchema.parse(operation)); } export function operationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Operation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Operation' from JSON`, ); } /** @internal */ export const Service$inboundSchema: z.ZodType = z.object({ id: z.string(), name: z.string(), }); /** @internal */ export type Service$Outbound = { id: string; name: string; }; /** @internal */ export const Service$outboundSchema: z.ZodType< Service$Outbound, z.ZodTypeDef, Service > = z.object({ id: z.string(), name: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Service$ { /** @deprecated use `Service$inboundSchema` instead. */ export const inboundSchema = Service$inboundSchema; /** @deprecated use `Service$outboundSchema` instead. */ export const outboundSchema = Service$outboundSchema; /** @deprecated use `Service$Outbound` instead. */ export type Outbound = Service$Outbound; } export function serviceToJSON(service: Service): string { return JSON.stringify(Service$outboundSchema.parse(service)); } export function serviceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Service$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Service' from JSON`, ); } /** @internal */ export const UnifiedApi$inboundSchema: z.ZodNativeEnum = z .nativeEnum(UnifiedApi); /** @internal */ export const UnifiedApi$outboundSchema: z.ZodNativeEnum = UnifiedApi$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UnifiedApi$ { /** @deprecated use `UnifiedApi$inboundSchema` instead. */ export const inboundSchema = UnifiedApi$inboundSchema; /** @deprecated use `UnifiedApi$outboundSchema` instead. */ export const outboundSchema = UnifiedApi$outboundSchema; } /** @internal */ export const Log$inboundSchema: z.ZodType = z .object({ api_style: z.string(), base_url: z.string(), child_request: z.boolean(), consumer_id: z.string(), duration: z.number(), error_message: z.nullable(z.string()).optional(), execution: z.number().int(), has_children: z.boolean(), http_method: z.string(), id: z.string(), latency: z.number(), operation: z.lazy(() => Operation$inboundSchema), parent_id: z.nullable(z.string()), path: z.string(), sandbox: z.boolean(), service: z.lazy(() => Service$inboundSchema), source_ip: z.nullable(z.string()).optional(), status_code: z.number().int(), success: z.boolean(), timestamp: z.string(), unified_api: UnifiedApi$inboundSchema, }).transform((v) => { return remap$(v, { "api_style": "apiStyle", "base_url": "baseUrl", "child_request": "childRequest", "consumer_id": "consumerId", "error_message": "errorMessage", "has_children": "hasChildren", "http_method": "httpMethod", "parent_id": "parentId", "source_ip": "sourceIp", "status_code": "statusCode", "unified_api": "unifiedApi", }); }); /** @internal */ export type Log$Outbound = { api_style: string; base_url: string; child_request: boolean; consumer_id: string; duration: number; error_message?: string | null | undefined; execution: number; has_children: boolean; http_method: string; id: string; latency: number; operation: Operation$Outbound; parent_id: string | null; path: string; sandbox: boolean; service: Service$Outbound; source_ip?: string | null | undefined; status_code: number; success: boolean; timestamp: string; unified_api: string; }; /** @internal */ export const Log$outboundSchema: z.ZodType = z .object({ apiStyle: z.string(), baseUrl: z.string(), childRequest: z.boolean(), consumerId: z.string(), duration: z.number(), errorMessage: z.nullable(z.string()).optional(), execution: z.number().int(), hasChildren: z.boolean(), httpMethod: z.string(), id: z.string(), latency: z.number(), operation: z.lazy(() => Operation$outboundSchema), parentId: z.nullable(z.string()), path: z.string(), sandbox: z.boolean(), service: z.lazy(() => Service$outboundSchema), sourceIp: z.nullable(z.string()).optional(), statusCode: z.number().int(), success: z.boolean(), timestamp: z.string(), unifiedApi: UnifiedApi$outboundSchema, }).transform((v) => { return remap$(v, { apiStyle: "api_style", baseUrl: "base_url", childRequest: "child_request", consumerId: "consumer_id", errorMessage: "error_message", hasChildren: "has_children", httpMethod: "http_method", parentId: "parent_id", sourceIp: "source_ip", statusCode: "status_code", unifiedApi: "unified_api", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Log$ { /** @deprecated use `Log$inboundSchema` instead. */ export const inboundSchema = Log$inboundSchema; /** @deprecated use `Log$outboundSchema` instead. */ export const outboundSchema = Log$outboundSchema; /** @deprecated use `Log$Outbound` instead. */ export type Outbound = Log$Outbound; } export function logToJSON(log: Log): string { return JSON.stringify(Log$outboundSchema.parse(log)); } export function logFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Log$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Log' from JSON`, ); }