UNPKG

attio-js

Version:

Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.

174 lines 6.44 kB
/* * 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"; /** * The type of token, always Bearer for tokens acquired via the OAuth 2.0 flow. */ export const TokenType = { Bearer: "Bearer", }; /** * The issuer of the token. Always attio.com */ export const Iss = { AttioCom: "attio.com", }; /** @internal */ export const TokenType$inboundSchema = z .nativeEnum(TokenType); /** @internal */ export const TokenType$outboundSchema = TokenType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var TokenType$; (function (TokenType$) { /** @deprecated use `TokenType$inboundSchema` instead. */ TokenType$.inboundSchema = TokenType$inboundSchema; /** @deprecated use `TokenType$outboundSchema` instead. */ TokenType$.outboundSchema = TokenType$outboundSchema; })(TokenType$ || (TokenType$ = {})); /** @internal */ export const Iss$inboundSchema = z.nativeEnum(Iss); /** @internal */ export const Iss$outboundSchema = Iss$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Iss$; (function (Iss$) { /** @deprecated use `Iss$inboundSchema` instead. */ Iss$.inboundSchema = Iss$inboundSchema; /** @deprecated use `Iss$outboundSchema` instead. */ Iss$.outboundSchema = Iss$outboundSchema; })(Iss$ || (Iss$ = {})); /** @internal */ export const Bearer$inboundSchema = z .object({ active: z.boolean(), scope: z.string(), client_id: z.string(), token_type: TokenType$inboundSchema, exp: z.nullable(z.number()), iat: z.number(), sub: z.string(), aud: z.string(), iss: Iss$inboundSchema, authorized_by_workspace_member_id: z.nullable(z.string()), workspace_id: z.string(), workspace_name: z.string(), workspace_slug: z.string(), workspace_logo_url: z.nullable(z.string()), }).transform((v) => { return remap$(v, { "client_id": "clientId", "token_type": "tokenType", "authorized_by_workspace_member_id": "authorizedByWorkspaceMemberId", "workspace_id": "workspaceId", "workspace_name": "workspaceName", "workspace_slug": "workspaceSlug", "workspace_logo_url": "workspaceLogoUrl", }); }); /** @internal */ export const Bearer$outboundSchema = z.object({ active: z.boolean(), scope: z.string(), clientId: z.string(), tokenType: TokenType$outboundSchema, exp: z.nullable(z.number()), iat: z.number(), sub: z.string(), aud: z.string(), iss: Iss$outboundSchema, authorizedByWorkspaceMemberId: z.nullable(z.string()), workspaceId: z.string(), workspaceName: z.string(), workspaceSlug: z.string(), workspaceLogoUrl: z.nullable(z.string()), }).transform((v) => { return remap$(v, { clientId: "client_id", tokenType: "token_type", authorizedByWorkspaceMemberId: "authorized_by_workspace_member_id", workspaceId: "workspace_id", workspaceName: "workspace_name", workspaceSlug: "workspace_slug", workspaceLogoUrl: "workspace_logo_url", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Bearer$; (function (Bearer$) { /** @deprecated use `Bearer$inboundSchema` instead. */ Bearer$.inboundSchema = Bearer$inboundSchema; /** @deprecated use `Bearer$outboundSchema` instead. */ Bearer$.outboundSchema = Bearer$outboundSchema; })(Bearer$ || (Bearer$ = {})); export function bearerToJSON(bearer) { return JSON.stringify(Bearer$outboundSchema.parse(bearer)); } export function bearerFromJSON(jsonString) { return safeParse(jsonString, (x) => Bearer$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Bearer' from JSON`); } /** @internal */ export const ResponseBody$inboundSchema = z.object({ active: z.boolean(), }); /** @internal */ export const ResponseBody$outboundSchema = z.object({ active: z.boolean(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var ResponseBody$; (function (ResponseBody$) { /** @deprecated use `ResponseBody$inboundSchema` instead. */ ResponseBody$.inboundSchema = ResponseBody$inboundSchema; /** @deprecated use `ResponseBody$outboundSchema` instead. */ ResponseBody$.outboundSchema = ResponseBody$outboundSchema; })(ResponseBody$ || (ResponseBody$ = {})); export function responseBodyToJSON(responseBody) { return JSON.stringify(ResponseBody$outboundSchema.parse(responseBody)); } export function responseBodyFromJSON(jsonString) { return safeParse(jsonString, (x) => ResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponseBody' from JSON`); } /** @internal */ export const GetV2SelfResponse$inboundSchema = z.union([ z.lazy(() => ResponseBody$inboundSchema), z.lazy(() => Bearer$inboundSchema), ]); /** @internal */ export const GetV2SelfResponse$outboundSchema = z.union([ z.lazy(() => ResponseBody$outboundSchema), z.lazy(() => Bearer$outboundSchema), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var GetV2SelfResponse$; (function (GetV2SelfResponse$) { /** @deprecated use `GetV2SelfResponse$inboundSchema` instead. */ GetV2SelfResponse$.inboundSchema = GetV2SelfResponse$inboundSchema; /** @deprecated use `GetV2SelfResponse$outboundSchema` instead. */ GetV2SelfResponse$.outboundSchema = GetV2SelfResponse$outboundSchema; })(GetV2SelfResponse$ || (GetV2SelfResponse$ = {})); export function getV2SelfResponseToJSON(getV2SelfResponse) { return JSON.stringify(GetV2SelfResponse$outboundSchema.parse(getV2SelfResponse)); } export function getV2SelfResponseFromJSON(jsonString) { return safeParse(jsonString, (x) => GetV2SelfResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetV2SelfResponse' from JSON`); } //# sourceMappingURL=getv2self.js.map