Skip to content

Types

Shared interfaces and error classes.

Type Aliases

ts
type ValueInputOption = "RAW" | "USER_ENTERED"
type ValueRenderOption = "FORMATTED_VALUE" | "UNFORMATTED_VALUE" | "FORMULA"

Interfaces

TabInstance

ts
interface TabInstance {
  getClient(): sheets_v4.Sheets
  getSheetId(): string
  getTitle(): string
  getWorksheetId(): number
  getHeaders(): string[]
  getSchema(): z.ZodObject | null
}

RowInstance

ts
interface RowInstance {
  getTab(): TabInstance
  getRowIndex(): number
}

SheetInstance

ts
interface SheetInstance {
  getClient(): sheets_v4.Sheets
  getId(): string
}

Error Classes

ClassDescription
ValueErrorInvalid configuration
ValidationErrorZod schema validation failed. Has .cause (original ZodError)
SheetNotFoundErrorSpreadsheet not found
TabNotFoundErrorWorksheet tab not found
ts
import { ValidationError } from "betterspread"

try {
  await tab.append({ values: badData })
} catch (err) {
  if (err instanceof ValidationError) {
    console.error(err.message)
    console.error(err.cause) // ZodError
  }
}