Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
5b14e62
refactor: refactoring core and make create table work
nichenqin Dec 19, 2025
6887643
feat: v2 support all basic type
nichenqin Dec 19, 2025
409c82f
feat: fill all basic field options
nichenqin Dec 20, 2025
e4e5e2d
feat: v2 core logger
nichenqin Dec 20, 2025
5d023c2
feat: command & event handler bus
nichenqin Dec 20, 2025
437a51d
chore: v2 github action
nichenqin Dec 20, 2025
9cf64b2
chore: add opentelemetry/instrumentation-pg
nichenqin Dec 20, 2025
f6873b8
chore: trace v2 packages
nichenqin Dec 20, 2025
c65e91e
test: add benchmark test
nichenqin Dec 20, 2025
056be78
chore: add dbFieldName dbTableName to domain
nichenqin Dec 20, 2025
3131543
feat: get table by id
nichenqin Dec 20, 2025
c446840
test: benchmark test bun
nichenqin Dec 21, 2025
517ae6e
chore: change contract api route name
nichenqin Dec 21, 2025
e1c18a6
feat: playground for v2
nichenqin Dec 21, 2025
ea73d46
feat: update package.json to use ES modules and improve TypeScript co…
nichenqin Dec 21, 2025
b99ca9c
refactor: update formatting types to use const assertions and remove …
nichenqin Dec 22, 2025
054b8cb
feat(playground): add TableMetaPage component and related functionality
nichenqin Dec 22, 2025
1de0fca
refactor: remove unused mapTableDtoToDomain function and update imports
nichenqin Dec 22, 2025
4bf6c80
feat: implement listTables functionality
nichenqin Dec 22, 2025
a4c9163
docs: add architecture documentation
nichenqin Dec 22, 2025
9088252
feat: integrate OpenTelemetry for tracing and monitoring in playgroun…
nichenqin Dec 22, 2025
6f31c0d
chore: teable ignore playground
nichenqin Dec 22, 2025
8e80746
feat: support formula field
nichenqin Dec 22, 2025
1756604
refactor: update development and build scripts for v2
nichenqin Dec 23, 2025
7c3ea90
refactor: update import statements to use 'resolution-mode' and adjus…
nichenqin Dec 23, 2025
4a6728d
chore: update test github action
nichenqin Dec 23, 2025
ac330b5
refactor: add 'module' field to package.json for ES module support
nichenqin Dec 23, 2025
8eb8ffa
refactor: migrate from v2-db-postgres to v2-adapter-db-postgres-pg
nichenqin Dec 23, 2025
6ed93de
feat: add unit tests for formula functions and related components
nichenqin Dec 23, 2025
345a716
feat: enhance PlaygroundShell with base ID switching functionality
nichenqin Dec 23, 2025
e0123f7
feat: add ViewColumnMeta management to View class and implement delet…
nichenqin Dec 23, 2025
877f91c
feat: add Tabs component and integrate with TableMetaPage for enhance…
nichenqin Dec 23, 2025
4a2c688
feat: implement computed field functionality and update related mappings
nichenqin Dec 23, 2025
ae57db3
feat: introduce table templates package with reusable field templates…
nichenqin Dec 23, 2025
f077f6f
feat: update table name
nichenqin Dec 23, 2025
77b010e
feat: logger adapter pino
nichenqin Dec 23, 2025
fdded72
chore: playground layout
nichenqin Dec 24, 2025
d0ea530
chore: playground ui ux
nichenqin Dec 24, 2025
778333c
feat: create field command
nichenqin Dec 24, 2025
1fdbfb5
feat: playground create field ui
nichenqin Dec 24, 2025
0de0dae
feat: enhance OpenTelemetry integration with new withSpan method and …
nichenqin Dec 24, 2025
d28ed68
feat: add smooth scrolling to active table in PlaygroundSidebar
nichenqin Dec 24, 2025
d22ef8f
refactor: streamline Postgres table schema handling and enhance archi…
nichenqin Dec 25, 2025
db05970
feat: add link field entity
nichenqin Dec 25, 2025
2a04d0f
feat: refactor table field handling and introduce new field creation …
nichenqin Dec 25, 2025
a323478
feat: link field
nichenqin Dec 26, 2025
1186c91
test: add link core test
nichenqin Dec 26, 2025
ad1b848
chore: rename packages
nichenqin Dec 26, 2025
0d77a52
fix: link reference table
nichenqin Dec 26, 2025
c5711a1
feat: rollup field
nichenqin Dec 27, 2025
79101b9
feat: add rollup lookup options persistence and default name generati…
nichenqin Dec 28, 2025
5c75b29
feat: implement unique field name generation and update logging mecha…
nichenqin Dec 28, 2025
009d252
refactor: update specs method usage in various handlers and tests
nichenqin Dec 28, 2025
afd48d9
feat: create rollup field issue
nichenqin Dec 28, 2025
5f6b2e0
feat: pglite db adapter
nichenqin Dec 28, 2025
0a52d40
feat: sandbox
nichenqin Dec 29, 2025
b5aae3e
refactor: replace RegularOrpcProvider with RemoteOrpcProvider and upd…
nichenqin Dec 29, 2025
2988c43
refactor: update imports and remove unused KyselyPGlite browser file
nichenqin Dec 29, 2025
6d639a8
feat: enhance memory ports and add new tokens
nichenqin Dec 29, 2025
bd6f0b8
refactor: update package dependencies and improve test configurations
nichenqin Dec 29, 2025
a204989
chore: delete field
nichenqin Dec 29, 2025
81d500f
feat: implement RecordFilterMapper for building record condition spec…
nichenqin Dec 30, 2025
a377ab9
feat: add support for new field types
nichenqin Dec 30, 2025
c8cda15
feat: implement various field types and enhance record condition spec…
nichenqin Dec 31, 2025
bec276b
feat: update playground components and enhance table handling with ne…
nichenqin Dec 31, 2025
b3fb97c
feat(v2): add PostgresTableRecordQueryBuilder for computed field reso…
nichenqin Jan 1, 2026
2de1d60
feat(v2): add PhysicalTableRecordQueryBuilder for direct column selec…
nichenqin Jan 1, 2026
ed042a6
refactor(v2): rename Physical to Stored query builder
nichenqin Jan 1, 2026
8c3c1f8
refactor(v2): move computed query builder to computed/ folder
nichenqin Jan 1, 2026
dc354fa
feat(v2): add indexes for link field FK columns
nichenqin Jan 1, 2026
8035f1d
feat(v2): integrate TableRecordQueryBuilderManager for dynamic query …
nichenqin Jan 1, 2026
181577a
refactor(v2): extract PostgresTableRecordQueryRepository to separate …
nichenqin Jan 1, 2026
e53778d
fix(playground): update search parameter handling in PlaygroundSideba…
nichenqin Jan 1, 2026
2955f18
feat(playground): implement DataTable for improved table rendering in…
nichenqin Jan 1, 2026
c3c4d56
chore(playground): update dependencies and add @tanstack/react-table …
nichenqin Jan 1, 2026
ddcd8fc
chore(v2): add @teable/v2-adapter-record-repository-postgres to tsconfig
nichenqin Jan 1, 2026
3aa5ccf
feat(playground): enhance Playground with new field inputs and create…
nichenqin Jan 2, 2026
0765b4b
feat(v2): enhance tracing with teable-specific attributes in query an…
nichenqin Jan 2, 2026
4f50f90
feat(v2): add CSV import functionality with streaming support
nichenqin Jan 3, 2026
44b9318
chore: ignore dist folders under packages/v2
nichenqin Jan 3, 2026
15cd6d0
feat(v2): add URL import and pagination for CSV
nichenqin Jan 3, 2026
ae4011f
feat(v2): implement computed update functionality in record repository
nichenqin Jan 4, 2026
2d459d9
feat(v2): create tables with seed records
nichenqin Jan 5, 2026
a140613
feat: support v2 API for update and create records
boris-w Jan 5, 2026
c54a777
feat(v2): implement computed update run tracking and enhance logging …
nichenqin Jan 5, 2026
5445727
feat(v2): implement delete records and get record by ID endpoints
nichenqin Jan 6, 2026
6f6ed99
feat(v2): enforce source visibility for TypeScript packages
nichenqin Jan 6, 2026
502a36c
feat(v2): enhance Playground with schema check and record deletion fe…
nichenqin Jan 6, 2026
457d0a2
feat(v2): introduce conditional lookup and rollup fields with associa…
nichenqin Jan 6, 2026
fb0ad85
feat(v2): add conditional rollup and lookup options with configuratio…
nichenqin Jan 6, 2026
981b60a
refactor(benchmarks): implement field factories for create table scen…
nichenqin Jan 6, 2026
c955453
feat(v2): update TypeScript configurations and enhance e2e tests for …
nichenqin Jan 6, 2026
554cbf3
chore(v2): update TypeScript configuration to include adapter-record-…
nichenqin Jan 6, 2026
68a92bf
feat(v2): add teable-v2-table-template documentation and enhance Play…
nichenqin Jan 7, 2026
9c259f2
feat(v2): enhance computed field updates and improve TypeScript confi…
nichenqin Jan 7, 2026
b93e451
feat(v2): enhance e2e tests with explicit cell value assertions and i…
nichenqin Jan 7, 2026
d44c04d
feat(v2): implement deferred foreign key handling and update test cas…
nichenqin Jan 7, 2026
5e12880
feat(v2): improve foreign key handling in e2e tests and refine relate…
nichenqin Jan 7, 2026
22a220b
feat(v2): implement conditional lookup and rollup field handling in q…
nichenqin Jan 7, 2026
7bfa0a7
fix(v2): remove trailing space in jsonb_agg SQL expression
nichenqin Jan 7, 2026
853f50c
test(v2-e2e): formula as link title via lookup
nichenqin Jan 7, 2026
791ea59
feat(v2): add create record benchmarks for various frameworks and upd…
nichenqin Jan 7, 2026
9c80964
feat(v2): add computed CTE batch benchmarks for bun framework
nichenqin Jan 7, 2026
b3c34fc
feat(v2): integrate command explain functionality with SQL formatting…
nichenqin Jan 7, 2026
ce04efb
feat(playground): update styles and enhance UI components
nichenqin Jan 7, 2026
acdba84
test(v2): add PGlite unit tests for schema rules
nichenqin Jan 8, 2026
d6f94d1
fix(formula-sql-pg): fix conditionalRollup column type and comparison…
nichenqin Jan 8, 2026
534d80f
feat(v2): introduce new adapter for PostgreSQL table repository
nichenqin Jan 8, 2026
520627c
chore: update style
nichenqin Jan 8, 2026
848efcd
fix(playground): only submit dirty fields in update record form
nichenqin Jan 8, 2026
d970fa6
feat(v2): explain computed update reasons
nichenqin Jan 8, 2026
eb99bf9
fix(v2): show link relation triggers in explain
nichenqin Jan 8, 2026
9f3385f
docs: add git hygiene rule
nichenqin Jan 8, 2026
7541563
refactor(v2): enhance update strategies to prevent duplicate updates
nichenqin Jan 8, 2026
3f33cb2
chore: add trailing newlines to various files for consistency
nichenqin Jan 8, 2026
b633049
refactor(v2): update ESLint configuration and streamline type imports
nichenqin Jan 8, 2026
2650f36
test(v2): enhance ComputedUpdateWorker tests for changeType handling
nichenqin Jan 8, 2026
d102d5c
feat(playground): integrate Radix UI context menu and enhance UI comp…
nichenqin Jan 9, 2026
e8f1f4f
feat(v2): implement computed update locks for concurrency control
nichenqin Jan 9, 2026
051185f
feat(playground): add database URL management and connection testing
nichenqin Jan 9, 2026
99bb67b
feat(debug-data): introduce read-only debug access and field relation…
nichenqin Jan 9, 2026
c43d205
feat(mock-records): add mock data generation capabilities for Teable v2
nichenqin Jan 9, 2026
e455762
fix(command-explain): properly quote schema.table in DELETE SQL
nichenqin Jan 10, 2026
e1b262c
feat(teable-v2-package-guide): add comprehensive guide for creating v…
nichenqin Jan 10, 2026
6658ffe
refactor(v2-core): extract table record methods
nichenqin Jan 10, 2026
f07064d
refactor(v2-core): extract table rename method
nichenqin Jan 10, 2026
e56ff34
refactor(v2-devtools): migrate to Effect CLI and add records query co…
nichenqin Jan 10, 2026
cf346f8
fix(v2-core): use type-only import for LinkTitleResolverService
nichenqin Jan 10, 2026
6eea1da
perf(v2-computed): optimize insert and delete computed updates
nichenqin Jan 10, 2026
b3b4754
feat(v2-devtools): add tables create and describe-schema commands
nichenqin Jan 10, 2026
14ae0a6
fix(v2-computed): track condition filter fields in dependency graph
nichenqin Jan 10, 2026
a4e7f59
fix(v2): correct tsconfig path alias for adapter-table-repository-pos…
nichenqin Jan 10, 2026
b43653c
fix(v2): add path alias for adapter-table-repository-postgres in tsco…
nichenqin Jan 10, 2026
7394709
feat(v2): enhance table repository with new field mappings and debugg…
nichenqin Jan 10, 2026
10c42cc
refactor(v2): remove PostgresSchemaIntrospector integration tests and…
nichenqin Jan 10, 2026
d311ac2
refactor(v2): streamline field factory definitions in benchmarks
nichenqin Jan 10, 2026
75daeb3
feat(v2-devtools): introduce PGlite support and enhance debugging cap…
nichenqin Jan 10, 2026
ba8f252
feat(v2-command-explain): add ESLint configuration and TypeScript sup…
nichenqin Jan 10, 2026
86b5e04
refactor(v2-devtools): clean up SKILL.md and remove localhost check
nichenqin Jan 10, 2026
6c3767d
feat(v2-devtools): integrate DotTea structure import functionality
nichenqin Jan 11, 2026
7bb5f40
feat(v2-devtools): enhance SKILL.md and improve computed field propag…
nichenqin Jan 11, 2026
a549447
feat(v2): enhance computed field handling and improve query performance
nichenqin Jan 11, 2026
6dd6d58
refactor(v2): remove unused export and optimize SQL queries in tests
nichenqin Jan 11, 2026
5620720
feat(v2): implement advisory locks for linked records to prevent dead…
nichenqin Jan 11, 2026
045da88
feat(playground): add MetaCheckPanel and enhance playground functiona…
nichenqin Jan 12, 2026
ab8324d
fix(playground): enhance RecordCreateDialog and RecordUpdateDialog la…
nichenqin Jan 12, 2026
b36737c
feat(v2): enhance TimeZone handling with new formats and error messages
nichenqin Jan 12, 2026
a6047c0
feat(v2): add base APIs and lookup casting
nichenqin Jan 12, 2026
4a57b62
feat(playground): add SQL step card with copy functionality
nichenqin Jan 12, 2026
349913c
feat(v2): introduce FieldHasError handling and update related components
nichenqin Jan 12, 2026
1375aee
feat(v2): add hasError field handling tests for computed fields
nichenqin Jan 12, 2026
b2b5553
refactor(tests): remove redundant invalid input tests from CreateTabl…
nichenqin Jan 12, 2026
8e5906d
test: update SQL query expectations in updateOne tests
nichenqin Jan 12, 2026
e90b2a4
fix(v2): make link order column optional
nichenqin Jan 12, 2026
f0be4d0
refactor(tests): update SQL snapshots for various functions
nichenqin Jan 12, 2026
b57e60f
feat(devtools): enhance record management capabilities
nichenqin Jan 12, 2026
39d89d7
feat(playground): enhance record detail display with field type icons
nichenqin Jan 12, 2026
88cc5a4
chore(docs): remove outdated observability and DLQ replay documentation
nichenqin Jan 12, 2026
4754601
refactor(playground): replace navigate with Link component in TableMe…
nichenqin Jan 12, 2026
74fc12a
feat(v2): enhance cross-base link handling in computed updates
nichenqin Jan 12, 2026
658fa27
fix(tests): update computed field update tests for step validation
nichenqin Jan 13, 2026
b0bbc37
feat(computed): optimize same-table batch processing and enhance outb…
nichenqin Jan 13, 2026
d745015
fix(tests): update computed field updater tests for SQL output consis…
nichenqin Jan 13, 2026
fe8af88
feat(tests): enhance ComputedUpdateWorker tests with new dependencies
nichenqin Jan 13, 2026
4bd4365
feat(projections): refactor event handling to fetch table data directly
nichenqin Jan 13, 2026
4f33889
feat(generated-columns): implement support for generated column metad…
nichenqin Jan 13, 2026
35ab1cb
feat(playground): implement realtime record synchronization and display
nichenqin Jan 13, 2026
63612b9
fix(tests): update ArrayFunctions snapshots for consistent output
nichenqin Jan 13, 2026
f4816d7
feat(playground): add Computed Tasks panel and related API routes
nichenqin Jan 13, 2026
e767f9b
feat(playground): enhance task retry functionality and improve event …
nichenqin Jan 13, 2026
950b567
fix(computed): include cross-base fields in dependency graph for comp…
nichenqin Jan 13, 2026
1b389fb
feat(tests): add new skills and enhance testing framework
nichenqin Jan 14, 2026
fc0198e
refactor(generators): update field ID generation to use a global coun…
nichenqin Jan 14, 2026
c046144
chore(workflows): update unit tests workflow to run packages in parallel
nichenqin Jan 14, 2026
a6f6572
chore(workflows): refine test workflows and enhance report generation
nichenqin Jan 14, 2026
2954851
feat(tests): add comprehensive tests for Realtime projections and Tab…
nichenqin Jan 14, 2026
4ebdb86
fix(tests): correct expected values in cross-table chain matrix tests
nichenqin Jan 14, 2026
62a8354
refactor(tests): enhance formula test scenarios for clarity and detail
nichenqin Jan 14, 2026
bf374aa
feat(formula): add locale/timezone helpers and expand tests
nichenqin Jan 14, 2026
cd15665
chore(workflows): remove redundant test summary job from CI workflow
nichenqin Jan 14, 2026
2701173
refactor(schema): update schema validation rules to allow optional fi…
nichenqin Jan 14, 2026
a28a2f7
feat(schema): enhance ReferenceRule ID generation with unique counters
nichenqin Jan 14, 2026
e9e3b03
feat(field-dependency): introduce field dependency core package
nichenqin Jan 14, 2026
a35bf61
fix(field-dependency): enhance error handling for missing field options
nichenqin Jan 14, 2026
41a752a
feat(link-field): introduce LinkFieldLabel component for enhanced lin…
nichenqin Jan 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
609 changes: 609 additions & 0 deletions .claude/skills/teable-v2-devtools/SKILL.md

Large diffs are not rendered by default.

209 changes: 209 additions & 0 deletions .claude/skills/teable-v2-package-guide/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Teable V2 Package Creation Guide

## When to Use This Skill

Use this skill when you need to:
- Create a new v2 package
- Configure package.json for v2 packages
- Set up TypeScript configuration
- Understand the v2 package conventions

## Package Location

All v2 packages are located in `packages/v2/` directory.

## Creating a New Package

### 1. Directory Structure

```
packages/v2/<package-name>/
├── src/
│ └── index.ts # Main entry point
├── package.json
├── tsconfig.json
├── tsconfig.build.json
└── tsdown.config.ts # Optional, for custom build config
```

### 2. Package.json Configuration

**IMPORTANT: Development-Friendly Exports**

The key to avoiding rebuilds during development is the `exports` configuration:

```json
{
"name": "@teable/v2-<package-name>",
"version": "0.0.0",
"private": true,
"license": "MIT",
"type": "module",
"sideEffects": false,
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "src/index.ts",
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts",
"module": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"files": [
"dist",
"src"
],
"scripts": {
"build": "tsdown --tsconfig tsconfig.build.json",
"dev": "tsdown --tsconfig tsconfig.build.json --watch",
"clean": "rimraf ./dist ./coverage ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./.eslintcache",
"lint": "eslint . --ext .ts,.js,.mjs,.cjs,.mts,.cts --cache --cache-location ../../../.cache/eslint/v2-<package-name>.eslintcache",
"typecheck": "tsc --project ./tsconfig.json --noEmit",
"test-unit": "vitest run --silent",
"test-unit-cover": "pnpm test-unit --coverage",
"fix-all-files": "eslint . --ext .ts,.js,.mjs,.cjs,.mts,.cts --fix"
},
"dependencies": {
// Add your dependencies here
},
"devDependencies": {
"@teable/v2-tsdown-config": "workspace:*",
"@teable/eslint-config-bases": "workspace:^",
"@types/node": "22.18.0",
"@vitest/coverage-v8": "4.0.16",
"eslint": "8.57.0",
"prettier": "3.2.5",
"rimraf": "5.0.5",
"tsdown": "0.18.1",
"typescript": "5.4.3",
"vite-tsconfig-paths": "4.3.2",
"vitest": "4.0.16"
}
}
```

### Key Export Configuration Explained

```json
"exports": {
".": {
"types": "./src/index.ts", // TypeScript types from source
"import": "./src/index.ts", // ESM import uses source directly
"module": "./dist/index.js", // Bundlers use built output
"require": "./dist/index.cjs" // CommonJS uses built output
}
}
```

**Why this works:**
- `types` and `import` point to `./src/index.ts` - this allows other packages to import TypeScript source directly during development
- `module` and `require` point to `./dist/` - this is used by bundlers and production builds
- No rebuild needed when you change source code - other packages see changes immediately

### 3. TypeScript Configuration

**tsconfig.json** (for development/typechecking):
```json
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"types": ["node"]
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
```

**tsconfig.build.json** (for building):
```json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"]
}
```

### 4. Build Configuration (Optional)

**tsdown.config.ts**:
```typescript
import { defineConfig } from '@teable/v2-tsdown-config';

export default defineConfig();
```

## Common Patterns

### Workspace Dependencies

Use `workspace:*` for internal dependencies:
```json
"dependencies": {
"@teable/v2-core": "workspace:*",
"@teable/v2-di": "workspace:*"
}
```

### Dependency Injection

V2 packages use `@teable/v2-di` for DI:
```typescript
import { injectable, inject } from '@teable/v2-di';

@injectable()
export class MyService {
constructor(
@inject(someToken) private readonly dependency: SomeDependency
) {}
}
```

### Error Handling

Use `neverthrow` for Result types:
```typescript
import { ok, err, Result } from 'neverthrow';
import { domainError, type DomainError } from '@teable/v2-core';

function doSomething(): Result<Data, DomainError> {
if (error) {
return err(domainError.invariant({ message: 'Something went wrong' }));
}
return ok(data);
}
```

## Checklist for New Package

- [ ] Create directory `packages/v2/<package-name>/`
- [ ] Create `src/index.ts` with exports
- [ ] Configure `package.json` with correct exports (pointing to source)
- [ ] Create `tsconfig.json` and `tsconfig.build.json`
- [ ] Add to root `pnpm-workspace.yaml` if needed
- [ ] Run `pnpm install` to link workspace dependencies
- [ ] Verify imports work without building: `pnpm typecheck`

## Troubleshooting

### "Cannot find module" errors
1. Check that `exports` in `package.json` points to correct paths
2. Ensure `types` field points to `src/index.ts`
3. Run `pnpm install` to refresh workspace links

### Changes not reflected in other packages
1. Verify `exports.import` points to `./src/index.ts` (not `./dist/`)
2. Check if the consuming package has cached the old build
3. Restart TypeScript server in your IDE

### Build errors
1. Ensure `tsconfig.build.json` excludes test files
2. Check that all dependencies are properly declared
3. Run `pnpm clean` before rebuilding
65 changes: 65 additions & 0 deletions .claude/skills/teable-v2-table-template/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: teable-v2-table-template
description: Create or update Teable v2 table templates in packages/v2/table-templates (template seeds, fields, records, and exports).
---

# Teable v2 Table Template Skill

Use this skill when you need to add or modify table templates in the v2 codebase. Templates live in `packages/v2/table-templates/src/index.ts`.

## Quick workflow

1. Open the template source file: `packages/v2/table-templates/src/index.ts`.
2. Add a seed builder:
- Single table: create a `createXSeed(): SingleTableSeed`.
- Multi table: create a `createXTemplateSeed(): TemplateSeed`.
3. Use helpers for IDs and select options:
- `createFieldId()` for field IDs
- `createTableId()` if you must predefine table IDs
- `createSelectOption()` for single/multi-select choices
4. Create the template definition:
- Single table: `singleTable(key, name, description, createXSeed, defaultRecordCount)`
- Multi table: `createTemplate(key, name, description, createXTemplateSeed, defaultRecordCount)`
5. Export the template and add it to `tableTemplates` array.
6. If you need a field-only helper, export `createXFields = () => createXSeed().fields;`.

## Notes and conventions

- Keep templates in `packages/v2/table-templates/src/index.ts` (this package is the single source of truth).
- The `createInput` generator in `TableTemplateDefinition` handles optional record seeding and name prefixing. You only need to supply seed fields and records.
- Prefer `singleTable(...)` unless the template truly needs multiple tables (e.g., CRM with Companies + Contacts).
- Use string keys that are stable and URL-safe (e.g., `content-calendar`, `bug-triage`).
- When seeding records, keep records small and representative; use `normalizeTemplateRecords` behavior to cap or pad.
- New templates should cover as many field types as possible, as long as the business context makes sense (use `allFieldTypesTemplate` for inspiration).

## Example pattern

```ts
const createMyTemplateSeed = (): SingleTableSeed => {
const nameFieldId = createFieldId();
return {
fields: [{ type: 'singleLineText', id: nameFieldId, name: 'Name' }],
records: [{ fields: { [nameFieldId]: 'Example' } }],
};
};

export const myTemplate = singleTable(
'my-template',
'My Template',
'Short description.',
createMyTemplateSeed,
1
);

export const tableTemplates = [
// ...existing templates,
myTemplate,
] as const;
```

## References

- Source of truth: `packages/v2/table-templates/src/index.ts`
- Package note: `packages/v2/table-templates/ARCHITECTURE.md`
- E2E contract: ensure `creates tables for every template with seeded records` passes in `packages/v2/e2e`.
- Suggested run: `pnpm -C packages/v2/e2e test -- --runInBand --testNamePattern "creates tables for every template with seeded records"`
73 changes: 73 additions & 0 deletions .claude/skills/teable-v2-test-debug/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: teable-v2-test-debug
description: Debug Teable v2 tests and failing test cases by prioritizing data reproduction and inspection. Use when asked to debug a test file/spec (unit, integration, or e2e) in packages/v2/*, especially when failures might be caused by table schema, relations, or stored/computed data drift; workflow uses v2-devtools CLI to create a similar table first, then inspects real DB data/relations, and only then reviews code logic.
---

# Teable V2 Test Debug

## Overview

Follow a data-first debugging workflow for Teable v2 tests. The default order is: reproduce data with devtools, inspect real DB data/relations, then analyze code logic.

## Workflow: Data-first test debugging

### 1) Capture failure context

- Identify the failing test name, file path, and the exact assertion that failed.
- Note the expected vs actual values and any IDs shown in logs (base/table/field/record).
- If the failure is e2e or integration, confirm which base or seed data was used.

### 2) Reproduce with devtools first (create similar table)

- Use the v2-devtools CLI to create a minimal table that mirrors the test schema.
- Prefer CLI-based table creation and mock data over hand-written SQL.
- If the schema is complex, build only the fields involved in the failing assertion.

Common commands:

```bash
# Get field schema documentation before creating tables
pnpm --filter @teable/v2-devtools cli tables describe-schema

# Create a table with minimal fields
pnpm --filter @teable/v2-devtools cli tables create --base-id bse... --name "Test Table" --fields '[{"type":"singleLineText","name":"Name","isPrimary":true}]'

# Generate mock records if data shape matters
pnpm --filter @teable/v2-devtools cli mock generate --table-id tbl... --count 10 --seed 12345
```

If the v2-devtools skill exists, open `/Users/nichenqin/projects/teable/.codex/skills/teable-v2-devtools/SKILL.md` for the full command reference and validation rules.

### 3) Inspect real DB data and relations

- Compare application layer vs underlying data first; use stored/computed modes.
- Inspect dependencies and relations to confirm lookup/rollup/formula inputs.
- Validate schema constraints if missing indexes or FK columns are suspected.

Common commands:

```bash
# App-layer data (stored/computed) vs underlying
pnpm --filter @teable/v2-devtools cli records list --table-id tbl... --mode stored --limit 10
pnpm --filter @teable/v2-devtools cli records list --table-id tbl... --mode computed --limit 10
pnpm --filter @teable/v2-devtools cli underlying records --table-id tbl... --limit 10

# Inspect a field and its dependencies
pnpm --filter @teable/v2-devtools cli underlying field --field-id fld...
pnpm --filter @teable/v2-devtools cli relations --field-id fld... --direction up --level 2

# Check schema integrity if queries are slow or failing
pnpm --filter @teable/v2-devtools cli schema table --table-id tbl...
```

### 4) Only then review code logic

- Map the observed data mismatch back to the handler, visitor, or mapper.
- Verify spec/visitor logic before touching application wiring.
- If the bug is only reproducible with real DB data, prefer adjusting fixtures or seeding rather than altering logic.

### 5) Decide next action

- If app-layer vs underlying differs, focus on computed/stored pipeline and mappers.
- If dependencies are wrong, fix field definitions or relation setup first.
- If reproduction fails on minimal data, debug core logic with a tight fixture.
Loading
Loading