/** * @fileoverview Shared HubSpot types: `JsonRecord`, `HubSpotAuthMode`, `HubSpotAuthInput`, `HubSpotPageInfo`, `HubSpotCrmRecord`, `HubSpotAccountInfo`, `HubSpotSearchFilter`, `HubSpotFilterGroup`, and related shapes. * Import from `kody:@kody/hubspot/types` when typing HubSpot helpers. Default export returns a type-name catalog. * * @example * import { type HubSpotAuthMode } from 'kody:@kody/hubspot/types' */ export type JsonRecord = Record export type HubSpotAuthMode = 'oauth' | 'privateApp' export type HubSpotAuthInput = { /** Saved OAuth integration name. Defaults to `hubspot`. */ integrationName?: string /** Alias of `integrationName`. */ integration?: string /** * Short account alias. `work` → `hubspot-work`. Values that already start * with `hubspot-` are used as-is. `default` / `hubspot` / omitted → `hubspot`. */ account?: string /** User secret name for a private app token. Defaults to `hubspotPrivateAppToken`. */ secretName?: string /** Force OAuth or private-app auth when both exist. */ auth?: HubSpotAuthMode } export type HubSpotPageInfo = { hasNextPage: boolean after: string | null } export type HubSpotCrmRecord = { id: string objectType: string properties: Record createdAt: string | null updatedAt: string | null archived: boolean | null } export type HubSpotAccountInfo = { hasPortalId: boolean accountType: string | null timeZone: string | null uiDomain: string | null } export type HubSpotSearchFilter = { propertyName: string operator: string value?: string values?: Array highValue?: string } export type HubSpotFilterGroup = { filters: Array } export type DryRunResult = { dryRun: true wouldCall: T } /** * Shared HubSpot types and parsing helpers for this package. * Import from `kody:@kody/hubspot/types` when typing other HubSpot exports. * * @returns Catalog of exported type/helper names for agent discovery. * * @example * import types from 'kody:@kody/hubspot/types' * const catalog = await types() */ export function requireRecord(value: unknown, label: string): JsonRecord { if (!value || typeof value !== 'object' || Array.isArray(value)) { throw new Error(`${label} must be an object.`) } return value as JsonRecord } export function requireString( value: unknown, label: string, options: { allowEmpty?: boolean } = {}, ): string { if (typeof value !== 'string' || (!options.allowEmpty && value.trim().length === 0)) { throw new Error( `${label} must be ${options.allowEmpty ? 'a string' : 'a non-empty string'}.`, ) } return options.allowEmpty ? value : value.trim() } export function optionalString(value: unknown, label: string): string | undefined { if (value === undefined || value === null) return undefined return requireString(value, label) } export function optionalBoolean(value: unknown, label: string): boolean | undefined { if (value === undefined) return undefined if (typeof value !== 'boolean') throw new Error(`${label} must be a boolean.`) return value } export function optionalStringArray(value: unknown, label: string): Array | undefined { if (value === undefined || value === null) return undefined if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings.`) return value.map((item, index) => requireString(item, `${label}[${index}]`)) } export function clampInt( value: unknown, min: number, max: number, fallback: number, label = 'limit', ): number { if (value === undefined || value === null) return fallback if (typeof value !== 'number' || !Number.isInteger(value)) { throw new Error(`${label} must be an integer.`) } if (value < min || value > max) { throw new Error(`${label} must be between ${min} and ${max}.`) } return value } export function compactRecord(value: T): T { const output: JsonRecord = {} for (const [key, item] of Object.entries(value)) { if (item === undefined) continue output[key] = item } return output as T } /** * Shared HubSpot types for this package: `JsonRecord`, `HubSpotAuthMode`, `HubSpotAuthInput`, `HubSpotPageInfo`, `HubSpotCrmRecord`, `HubSpotAccountInfo`, `HubSpotSearchFilter`, `HubSpotFilterGroup`, and related shapes. * Import from `kody:@kody/hubspot/types` when typing HubSpot helpers without pulling runtime clients. * * @returns Catalog of exported type names for agent discovery. * * @example * import types from 'kody:@kody/hubspot/types' * const catalog = await types() */ export default async function typesOverview() { return { auth: ['HubSpotAuthInput', 'HubSpotAuthMode'], models: ['HubSpotCrmRecord', 'HubSpotAccountInfo', 'HubSpotSearchFilter'], } }