Schema SDK
The eidos.space.schema object provides methods for managing the lifecycle of tables, fields, and views.
Table Operations
Section titled “Table Operations”createTable(input)
Section titled “createTable(input)”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)getTable(tableId)
Section titled “getTable(tableId)”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.`)listTables()
Section titled “listTables()”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})`))updateTable(tableId, input)
Section titled “updateTable(tableId, input)”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" })deleteTable(tableId)
Section titled “deleteTable(tableId)”Permanently delete a table.
async deleteTable(tableId: string): Promise<boolean>Field Operations
Section titled “Field Operations”addField(tableId, input)
Section titled “addField(tableId, input)”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",})updateField(tableId, columnName, input)
Section titled “updateField(tableId, columnName, input)”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",})deleteField(tableId, columnName)
Section titled “deleteField(tableId, columnName)”Delete a field from a table.
async deleteField(tableId: string, columnName: string): Promise<boolean>View Operations
Section titled “View Operations”createView(tableId, input)
Section titled “createView(tableId, input)”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",})listViews(tableId)
Section titled “listViews(tableId)”List all views for a table.
async listViews(tableId: string): Promise<ViewInfo[]>deleteView(tableId, viewId)
Section titled “deleteView(tableId, viewId)”Delete a view.
async deleteView(tableId: string, viewId: string): Promise<boolean>Schema Import / Export
Section titled “Schema Import / Export”These two methods let you share a table’s structure (field definitions) as a compact, portable string — without any row data.
export(tableId)
Section titled “export(tableId)”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/sharingconst encoded = btoa( encodeURIComponent(JSON.stringify(schema)).replace( /%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(parseInt(p1, 16)) ))console.log(encoded) // "eyJ2ZXJzaW9uIjox..."import(schema, nameOverride?)
Section titled “import(schema, nameOverride?)”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— ATableSchemaExportobject (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 objectconst schema = JSON.parse( decodeURIComponent( atob(encodedString) .split("") .map((c) => "%" + c.charCodeAt(0).toString(16).padStart(2, "0")) .join("") ))
// Create the tableconst table = await eidos.space.schema.import(schema)console.log("Created:", table.name, "with", table.fields.length, "fields")
// Create with a different nameconst copy = await eidos.space.schema.import(schema, "My Copy")Round-trip example:
// Export from source tableconst 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)")