UNPKG

attio-js

Version:

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

564 lines 21.6 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"; import { OutputValue$inboundSchema, OutputValue$outboundSchema, } from "./outputvalue.js"; /** * The type of the attribute. */ export const AttributeType = { Text: "text", Number: "number", Checkbox: "checkbox", Currency: "currency", Date: "date", Timestamp: "timestamp", Rating: "rating", Status: "status", Select: "select", RecordReference: "record-reference", ActorReference: "actor-reference", Location: "location", Domain: "domain", EmailAddress: "email-address", PhoneNumber: "phone-number", Interaction: "interaction", PersonalName: "personal-name", }; export const TypeStatic = { Static: "static", }; export const TypeDynamic = { Dynamic: "dynamic", }; /** * For actor reference attributes, you may pass a dynamic value of `"current-user"`. When creating new records or entries, this will cause the actor reference value to be populated with either the workspace member or API token that created the record/entry. */ export const Template = { CurrentUser: "current-user", }; /** * The ISO4217 code representing the currency that values for this attribute should be stored in. */ export const DefaultCurrencyCode = { Aud: "AUD", Brl: "BRL", Bel: "BEL", Cad: "CAD", Cny: "CNY", Cop: "COP", Czk: "CZK", Dkk: "DKK", Eur: "EUR", Hkd: "HKD", Isk: "ISK", Inr: "INR", Ils: "ILS", Jpy: "JPY", Krw: "KRW", Myr: "MYR", Mxn: "MXN", Ntd: "NTD", Nzd: "NZD", Ngn: "NGN", Nok: "NOK", Xpf: "XPF", Pen: "PEN", Php: "PHP", Pln: "PLN", Gbp: "GBP", Sar: "SAR", Sgd: "SGD", Zar: "ZAR", Sek: "SEK", Chf: "CHF", Aed: "AED", Usd: "USD", }; /** * How the currency should be displayed across the app. "code" will display the ISO currency code e.g. "USD", "name" will display the localized currency name e.g. "British pound", "narrowSymbol" will display "$1" instead of "US$1" and "symbol" will display a localized currency symbol such as "$". */ export const DisplayType = { Code: "code", Name: "name", NarrowSymbol: "narrowSymbol", Symbol: "symbol", }; /** @internal */ export const AttributeId$inboundSchema = z.object({ workspace_id: z.string(), object_id: z.string(), attribute_id: z.string(), }).transform((v) => { return remap$(v, { "workspace_id": "workspaceId", "object_id": "objectId", "attribute_id": "attributeId", }); }); /** @internal */ export const AttributeId$outboundSchema = z.object({ workspaceId: z.string(), objectId: z.string(), attributeId: z.string(), }).transform((v) => { return remap$(v, { workspaceId: "workspace_id", objectId: "object_id", attributeId: "attribute_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var AttributeId$; (function (AttributeId$) { /** @deprecated use `AttributeId$inboundSchema` instead. */ AttributeId$.inboundSchema = AttributeId$inboundSchema; /** @deprecated use `AttributeId$outboundSchema` instead. */ AttributeId$.outboundSchema = AttributeId$outboundSchema; })(AttributeId$ || (AttributeId$ = {})); export function attributeIdToJSON(attributeId) { return JSON.stringify(AttributeId$outboundSchema.parse(attributeId)); } export function attributeIdFromJSON(jsonString) { return safeParse(jsonString, (x) => AttributeId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AttributeId' from JSON`); } /** @internal */ export const AttributeType$inboundSchema = z.nativeEnum(AttributeType); /** @internal */ export const AttributeType$outboundSchema = AttributeType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var AttributeType$; (function (AttributeType$) { /** @deprecated use `AttributeType$inboundSchema` instead. */ AttributeType$.inboundSchema = AttributeType$inboundSchema; /** @deprecated use `AttributeType$outboundSchema` instead. */ AttributeType$.outboundSchema = AttributeType$outboundSchema; })(AttributeType$ || (AttributeType$ = {})); /** @internal */ export const TypeStatic$inboundSchema = z .nativeEnum(TypeStatic); /** @internal */ export const TypeStatic$outboundSchema = TypeStatic$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var TypeStatic$; (function (TypeStatic$) { /** @deprecated use `TypeStatic$inboundSchema` instead. */ TypeStatic$.inboundSchema = TypeStatic$inboundSchema; /** @deprecated use `TypeStatic$outboundSchema` instead. */ TypeStatic$.outboundSchema = TypeStatic$outboundSchema; })(TypeStatic$ || (TypeStatic$ = {})); /** @internal */ export const DefaultValueStatic$inboundSchema = z.object({ type: TypeStatic$inboundSchema, template: z.array(OutputValue$inboundSchema), }); /** @internal */ export const DefaultValueStatic$outboundSchema = z.object({ type: TypeStatic$outboundSchema, template: z.array(OutputValue$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var DefaultValueStatic$; (function (DefaultValueStatic$) { /** @deprecated use `DefaultValueStatic$inboundSchema` instead. */ DefaultValueStatic$.inboundSchema = DefaultValueStatic$inboundSchema; /** @deprecated use `DefaultValueStatic$outboundSchema` instead. */ DefaultValueStatic$.outboundSchema = DefaultValueStatic$outboundSchema; })(DefaultValueStatic$ || (DefaultValueStatic$ = {})); export function defaultValueStaticToJSON(defaultValueStatic) { return JSON.stringify(DefaultValueStatic$outboundSchema.parse(defaultValueStatic)); } export function defaultValueStaticFromJSON(jsonString) { return safeParse(jsonString, (x) => DefaultValueStatic$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DefaultValueStatic' from JSON`); } /** @internal */ export const TypeDynamic$inboundSchema = z .nativeEnum(TypeDynamic); /** @internal */ export const TypeDynamic$outboundSchema = TypeDynamic$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var TypeDynamic$; (function (TypeDynamic$) { /** @deprecated use `TypeDynamic$inboundSchema` instead. */ TypeDynamic$.inboundSchema = TypeDynamic$inboundSchema; /** @deprecated use `TypeDynamic$outboundSchema` instead. */ TypeDynamic$.outboundSchema = TypeDynamic$outboundSchema; })(TypeDynamic$ || (TypeDynamic$ = {})); /** @internal */ export const Template$inboundSchema = z .nativeEnum(Template); /** @internal */ export const Template$outboundSchema = Template$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Template$; (function (Template$) { /** @deprecated use `Template$inboundSchema` instead. */ Template$.inboundSchema = Template$inboundSchema; /** @deprecated use `Template$outboundSchema` instead. */ Template$.outboundSchema = Template$outboundSchema; })(Template$ || (Template$ = {})); /** @internal */ export const DefaultValueDynamic$inboundSchema = z.object({ type: TypeDynamic$inboundSchema, template: z.any().optional(), }); /** @internal */ export const DefaultValueDynamic$outboundSchema = z.object({ type: TypeDynamic$outboundSchema, template: z.any().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var DefaultValueDynamic$; (function (DefaultValueDynamic$) { /** @deprecated use `DefaultValueDynamic$inboundSchema` instead. */ DefaultValueDynamic$.inboundSchema = DefaultValueDynamic$inboundSchema; /** @deprecated use `DefaultValueDynamic$outboundSchema` instead. */ DefaultValueDynamic$.outboundSchema = DefaultValueDynamic$outboundSchema; })(DefaultValueDynamic$ || (DefaultValueDynamic$ = {})); export function defaultValueDynamicToJSON(defaultValueDynamic) { return JSON.stringify(DefaultValueDynamic$outboundSchema.parse(defaultValueDynamic)); } export function defaultValueDynamicFromJSON(jsonString) { return safeParse(jsonString, (x) => DefaultValueDynamic$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DefaultValueDynamic' from JSON`); } /** @internal */ export const DefaultValue$inboundSchema = z.union([ z.lazy(() => DefaultValueDynamic$inboundSchema), z.lazy(() => DefaultValueStatic$inboundSchema), ]); /** @internal */ export const DefaultValue$outboundSchema = z.union([ z.lazy(() => DefaultValueDynamic$outboundSchema), z.lazy(() => DefaultValueStatic$outboundSchema), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var DefaultValue$; (function (DefaultValue$) { /** @deprecated use `DefaultValue$inboundSchema` instead. */ DefaultValue$.inboundSchema = DefaultValue$inboundSchema; /** @deprecated use `DefaultValue$outboundSchema` instead. */ DefaultValue$.outboundSchema = DefaultValue$outboundSchema; })(DefaultValue$ || (DefaultValue$ = {})); export function defaultValueToJSON(defaultValue) { return JSON.stringify(DefaultValue$outboundSchema.parse(defaultValue)); } export function defaultValueFromJSON(jsonString) { return safeParse(jsonString, (x) => DefaultValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DefaultValue' from JSON`); } /** @internal */ export const RelationshipId$inboundSchema = z.object({ workspace_id: z.string(), object_id: z.string(), attribute_id: z.string(), }).transform((v) => { return remap$(v, { "workspace_id": "workspaceId", "object_id": "objectId", "attribute_id": "attributeId", }); }); /** @internal */ export const RelationshipId$outboundSchema = z.object({ workspaceId: z.string(), objectId: z.string(), attributeId: z.string(), }).transform((v) => { return remap$(v, { workspaceId: "workspace_id", objectId: "object_id", attributeId: "attribute_id", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var RelationshipId$; (function (RelationshipId$) { /** @deprecated use `RelationshipId$inboundSchema` instead. */ RelationshipId$.inboundSchema = RelationshipId$inboundSchema; /** @deprecated use `RelationshipId$outboundSchema` instead. */ RelationshipId$.outboundSchema = RelationshipId$outboundSchema; })(RelationshipId$ || (RelationshipId$ = {})); export function relationshipIdToJSON(relationshipId) { return JSON.stringify(RelationshipId$outboundSchema.parse(relationshipId)); } export function relationshipIdFromJSON(jsonString) { return safeParse(jsonString, (x) => RelationshipId$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RelationshipId' from JSON`); } /** @internal */ export const Relationship$inboundSchema = z.object({ id: z.lazy(() => RelationshipId$inboundSchema), }); /** @internal */ export const Relationship$outboundSchema = z.object({ id: z.lazy(() => RelationshipId$outboundSchema), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Relationship$; (function (Relationship$) { /** @deprecated use `Relationship$inboundSchema` instead. */ Relationship$.inboundSchema = Relationship$inboundSchema; /** @deprecated use `Relationship$outboundSchema` instead. */ Relationship$.outboundSchema = Relationship$outboundSchema; })(Relationship$ || (Relationship$ = {})); export function relationshipToJSON(relationship) { return JSON.stringify(Relationship$outboundSchema.parse(relationship)); } export function relationshipFromJSON(jsonString) { return safeParse(jsonString, (x) => Relationship$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Relationship' from JSON`); } /** @internal */ export const DefaultCurrencyCode$inboundSchema = z.nativeEnum(DefaultCurrencyCode); /** @internal */ export const DefaultCurrencyCode$outboundSchema = DefaultCurrencyCode$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var DefaultCurrencyCode$; (function (DefaultCurrencyCode$) { /** @deprecated use `DefaultCurrencyCode$inboundSchema` instead. */ DefaultCurrencyCode$.inboundSchema = DefaultCurrencyCode$inboundSchema; /** @deprecated use `DefaultCurrencyCode$outboundSchema` instead. */ DefaultCurrencyCode$.outboundSchema = DefaultCurrencyCode$outboundSchema; })(DefaultCurrencyCode$ || (DefaultCurrencyCode$ = {})); /** @internal */ export const DisplayType$inboundSchema = z .nativeEnum(DisplayType); /** @internal */ export const DisplayType$outboundSchema = DisplayType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var DisplayType$; (function (DisplayType$) { /** @deprecated use `DisplayType$inboundSchema` instead. */ DisplayType$.inboundSchema = DisplayType$inboundSchema; /** @deprecated use `DisplayType$outboundSchema` instead. */ DisplayType$.outboundSchema = DisplayType$outboundSchema; })(DisplayType$ || (DisplayType$ = {})); /** @internal */ export const Currency$inboundSchema = z.object({ default_currency_code: z.nullable(DefaultCurrencyCode$inboundSchema), display_type: z.nullable(DisplayType$inboundSchema), }).transform((v) => { return remap$(v, { "default_currency_code": "defaultCurrencyCode", "display_type": "displayType", }); }); /** @internal */ export const Currency$outboundSchema = z.object({ defaultCurrencyCode: z.nullable(DefaultCurrencyCode$outboundSchema), displayType: z.nullable(DisplayType$outboundSchema), }).transform((v) => { return remap$(v, { defaultCurrencyCode: "default_currency_code", displayType: "display_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Currency$; (function (Currency$) { /** @deprecated use `Currency$inboundSchema` instead. */ Currency$.inboundSchema = Currency$inboundSchema; /** @deprecated use `Currency$outboundSchema` instead. */ Currency$.outboundSchema = Currency$outboundSchema; })(Currency$ || (Currency$ = {})); export function currencyToJSON(currency) { return JSON.stringify(Currency$outboundSchema.parse(currency)); } export function currencyFromJSON(jsonString) { return safeParse(jsonString, (x) => Currency$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Currency' from JSON`); } /** @internal */ export const RecordReference$inboundSchema = z.object({ allowed_object_ids: z.nullable(z.array(z.string())), }).transform((v) => { return remap$(v, { "allowed_object_ids": "allowedObjectIds", }); }); /** @internal */ export const RecordReference$outboundSchema = z.object({ allowedObjectIds: z.nullable(z.array(z.string())), }).transform((v) => { return remap$(v, { allowedObjectIds: "allowed_object_ids", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var RecordReference$; (function (RecordReference$) { /** @deprecated use `RecordReference$inboundSchema` instead. */ RecordReference$.inboundSchema = RecordReference$inboundSchema; /** @deprecated use `RecordReference$outboundSchema` instead. */ RecordReference$.outboundSchema = RecordReference$outboundSchema; })(RecordReference$ || (RecordReference$ = {})); export function recordReferenceToJSON(recordReference) { return JSON.stringify(RecordReference$outboundSchema.parse(recordReference)); } export function recordReferenceFromJSON(jsonString) { return safeParse(jsonString, (x) => RecordReference$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RecordReference' from JSON`); } /** @internal */ export const Config$inboundSchema = z .object({ currency: z.lazy(() => Currency$inboundSchema), record_reference: z.lazy(() => RecordReference$inboundSchema), }).transform((v) => { return remap$(v, { "record_reference": "recordReference", }); }); /** @internal */ export const Config$outboundSchema = z.object({ currency: z.lazy(() => Currency$outboundSchema), recordReference: z.lazy(() => RecordReference$outboundSchema), }).transform((v) => { return remap$(v, { recordReference: "record_reference", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Config$; (function (Config$) { /** @deprecated use `Config$inboundSchema` instead. */ Config$.inboundSchema = Config$inboundSchema; /** @deprecated use `Config$outboundSchema` instead. */ Config$.outboundSchema = Config$outboundSchema; })(Config$ || (Config$ = {})); export function configToJSON(config) { return JSON.stringify(Config$outboundSchema.parse(config)); } export function configFromJSON(jsonString) { return safeParse(jsonString, (x) => Config$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Config' from JSON`); } /** @internal */ export const Attribute$inboundSchema = z.object({ id: z.lazy(() => AttributeId$inboundSchema), title: z.string(), description: z.nullable(z.string()), api_slug: z.string(), type: AttributeType$inboundSchema, is_system_attribute: z.boolean(), is_writable: z.boolean(), is_required: z.boolean(), is_unique: z.boolean(), is_multiselect: z.boolean(), is_default_value_enabled: z.boolean(), is_archived: z.boolean(), default_value: z.nullable(z.union([ z.lazy(() => DefaultValueDynamic$inboundSchema), z.lazy(() => DefaultValueStatic$inboundSchema), ])), relationship: z.nullable(z.lazy(() => Relationship$inboundSchema)), created_at: z.string(), config: z.lazy(() => Config$inboundSchema), }).transform((v) => { return remap$(v, { "api_slug": "apiSlug", "is_system_attribute": "isSystemAttribute", "is_writable": "isWritable", "is_required": "isRequired", "is_unique": "isUnique", "is_multiselect": "isMultiselect", "is_default_value_enabled": "isDefaultValueEnabled", "is_archived": "isArchived", "default_value": "defaultValue", "created_at": "createdAt", }); }); /** @internal */ export const Attribute$outboundSchema = z.object({ id: z.lazy(() => AttributeId$outboundSchema), title: z.string(), description: z.nullable(z.string()), apiSlug: z.string(), type: AttributeType$outboundSchema, isSystemAttribute: z.boolean(), isWritable: z.boolean(), isRequired: z.boolean(), isUnique: z.boolean(), isMultiselect: z.boolean(), isDefaultValueEnabled: z.boolean(), isArchived: z.boolean(), defaultValue: z.nullable(z.union([ z.lazy(() => DefaultValueDynamic$outboundSchema), z.lazy(() => DefaultValueStatic$outboundSchema), ])), relationship: z.nullable(z.lazy(() => Relationship$outboundSchema)), createdAt: z.string(), config: z.lazy(() => Config$outboundSchema), }).transform((v) => { return remap$(v, { apiSlug: "api_slug", isSystemAttribute: "is_system_attribute", isWritable: "is_writable", isRequired: "is_required", isUnique: "is_unique", isMultiselect: "is_multiselect", isDefaultValueEnabled: "is_default_value_enabled", isArchived: "is_archived", defaultValue: "default_value", createdAt: "created_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export var Attribute$; (function (Attribute$) { /** @deprecated use `Attribute$inboundSchema` instead. */ Attribute$.inboundSchema = Attribute$inboundSchema; /** @deprecated use `Attribute$outboundSchema` instead. */ Attribute$.outboundSchema = Attribute$outboundSchema; })(Attribute$ || (Attribute$ = {})); export function attributeToJSON(attribute) { return JSON.stringify(Attribute$outboundSchema.parse(attribute)); } export function attributeFromJSON(jsonString) { return safeParse(jsonString, (x) => Attribute$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Attribute' from JSON`); } //# sourceMappingURL=attribute.js.map