/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.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 LogUnifiedApi = { 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 LogUnifiedApi = OpenEnum; 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: LogUnifiedApi; }; /** @internal */ export const Operation$inboundSchema: z.ZodType< Operation, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), name: types.string(), }) ); 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 = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), name: types.string(), }) ); 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 LogUnifiedApi$inboundSchema: z.ZodType< LogUnifiedApi, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(LogUnifiedApi)); /** @internal */ export const Log$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ api_style: types.string(), base_url: types.string(), child_request: types.boolean(), consumer_id: types.string(), duration: types.number(), error_message: z.nullable(types.string()).optional(), execution: types.number(), has_children: types.boolean(), http_method: types.string(), id: types.string(), latency: types.number(), operation: z.lazy(() => Operation$inboundSchema), parent_id: types.nullable(types.string()), path: types.string(), sandbox: types.boolean(), service: z.lazy(() => Service$inboundSchema), source_ip: z.nullable(types.string()).optional(), status_code: types.number(), success: types.boolean(), timestamp: types.string(), unified_api: LogUnifiedApi$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", }); }) ); export function logFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Log$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Log' from JSON`, ); }