Skip to content

Schema SDK

The eidos.space.schema object provides methods for managing the lifecycle of tables, fields, and views.

Create a new table with specified fields.

async createTable(input: CreateTableInput): Promise<TableInfo>

Example:

const table = await eidos.space.schema.createTable({
name: "Tasks",
fields: [
{
name: "Priority",
columnName: "priority",
type: "select",
property: {
options: [
{ name: "High", color: "red" },
{ name: "Low", color: "blue" },
],
},
},
{ name: "Deadline", columnName: "deadline", type: "date" },
],
})
console.log("Created table ID:", table.id)

Get detailed information about a specific table.

async getTable(tableId: string): Promise<TableInfo>

Example:

const tableInfo = await eidos.space.schema.getTable("table_id_here")
console.log(`Table ${tableInfo.name} has ${tableInfo.fields.length} fields.`)

List all tables in the current space.

async listTables(): Promise<TableListItem[]>

Example:

const tables = await eidos.space.schema.listTables()
tables.forEach((t) => console.log(`${t.name} (${t.id})`))

Update table metadata (e.g., rename).

async updateTable(tableId: string, input: UpdateTableInput): Promise<TableInfo>

Example:

await eidos.space.schema.updateTable("table_id", { name: "New Name" })

Permanently delete a table.

async deleteTable(tableId: string): Promise<boolean>

Add a new field to an existing table.

async addField(tableId: string, input: CreateFieldInput): Promise<FieldInfo>

Example:

await eidos.space.schema.addField("table_id", {
name: "New Field",
columnName: "new_field",
type: "text",
})

Update field metadata.

async updateField(tableId: string, columnName: string, input: UpdateFieldInput): Promise<FieldInfo>

Example:

await eidos.space.schema.updateField("table_id", "priority", {
name: "Task Priority",
})

Delete a field from a table.

async deleteField(tableId: string, columnName: string): Promise<boolean>

Create a new view for a table.

async createView(tableId: string, input: CreateViewInput): Promise<ViewInfo>

Example:

await eidos.space.schema.createView("table_id", {
name: "My Kanban",
type: "kanban",
})

List all views for a table.

async listViews(tableId: string): Promise<ViewInfo[]>

Delete a view.

async deleteView(tableId: string, viewId: string): Promise<boolean>

These two methods let you share a table’s structure (field definitions) as a compact, portable string — without any row data.

Export a table’s schema as a portable object. System fields (_id, title, timestamps, etc.) are automatically excluded.

async export(tableId: string): Promise<TableSchemaExport>
interface TableSchemaExport {
version: 1
name: string
fields: CreateFieldInput[]
}

Example — copy to clipboard as base64:

const schema = await eidos.space.schema.export("table_id_here")
// Encode to base64 for easy copying/sharing
const encoded = btoa(
encodeURIComponent(JSON.stringify(schema)).replace(
/%([0-9A-F]{2})/g,
(_, p1) => String.fromCharCode(parseInt(p1, 16))
)
)
console.log(encoded) // "eyJ2ZXJzaW9uIjox..."

Create a new table from a previously exported schema. This is the counterpart to export().

async import(schema: TableSchemaExport, nameOverride?: string): Promise<TableInfo>

Parameters:

  • schema — A TableSchemaExport object (e.g., decoded from a base64 string)
  • nameOverride — Optional: override the table name from the schema

Example — decode base64 and recreate the table:

// Decode the base64 string back to a schema object
const schema = JSON.parse(
decodeURIComponent(
atob(encodedString)
.split("")
.map((c) => "%" + c.charCodeAt(0).toString(16).padStart(2, "0"))
.join("")
)
)
// Create the table
const table = await eidos.space.schema.import(schema)
console.log("Created:", table.name, "with", table.fields.length, "fields")
// Create with a different name
const copy = await eidos.space.schema.import(schema, "My Copy")

Round-trip example:

// Export from source table
const schema = await eidos.space.schema.export(sourceTableId)
// Share `schema` or encode it — then recreate elsewhere:
const newTable = await eidos.space.schema.import(schema, "Tasks (Copy)")