-
Notifications
You must be signed in to change notification settings - Fork 0
feat: AppSheet Field Type Support and Validation Enhancement (SOSO-247) #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Phase 1: Type System Extension **Breaking Changes (v2.0.0):** - Removed old generic types (string, number, boolean, date, array, object) - Replaced with AppSheet-specific types (Text, Email, URL, Phone, etc.) - All fields now require full FieldDefinition object format - Renamed 'enum' property to 'allowedValues' **New Features:** - Added 27 AppSheet field types across all categories: - Core types: Text, Number, Date, DateTime, Time, Duration, YesNo - Specialized text: Name, Email, URL, Phone, Address - Specialized numbers: Decimal, Percent, Price - Selection: Enum, EnumList - Media: Image, File, Drawing, Signature - Tracking: ChangeCounter, ChangeTimestamp, ChangeLocation - References: Ref, RefList - Special: Color, Show **Enhanced Validation:** - Email format validation (RFC 5322) - URL format validation - Phone number validation (international format) - Enum: single value validation - EnumList: array validation with allowed values - Percent: range validation (0.00 to 1.00) - Date/DateTime: ISO format validation - YesNo: boolean or "Yes"/"No" string validation **Updated Components:** - src/types/schema.ts: New AppSheetFieldType enum and FieldDefinition interface - src/client/DynamicTable.ts: Complete validation logic for all field types - src/cli/SchemaInspector.ts: Auto-detection of AppSheet types from data **Tests:** - Added 34 comprehensive tests for all field type validations - All 82 tests passing (48 existing + 34 new) - Test coverage for Email, URL, Phone, Enum, EnumList, Percent, Date, DateTime, YesNo **Migration Notes:** - Old schemas with generic types will no longer work - Migration guide will be provided in Phase 4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…s (Phase 2) Phase 2: Validation Enhancement **Refactoring:** - Extracted validation logic from DynamicTable into separate validator classes - Created modular, reusable validation architecture **New Validator Classes:** - BaseTypeValidator: JavaScript primitive type validation (string, number, boolean, array) - FormatValidator: Format-specific validation (Email, URL, Phone, Date, DateTime, Percent) - AppSheetTypeValidator: Main validator orchestrating base type + format validation **Benefits:** - Cleaner separation of concerns - Reusable validation logic across the codebase - Easier to test validators in isolation - Better maintainability and extensibility **Changes:** - src/utils/validators/BaseTypeValidator.ts: NEW - Base type validation - src/utils/validators/FormatValidator.ts: NEW - Format validation utilities - src/utils/validators/AppSheetTypeValidator.ts: NEW - AppSheet type orchestrator - src/utils/validators/index.ts: NEW - Validator exports - src/client/DynamicTable.ts: REFACTORED - Uses validator classes instead of inline logic - src/utils/index.ts: Export validators **Testing:** - All 82 tests still passing - No breaking changes for existing functionality - Validation behavior remains identical **Next Steps:** - Phase 3: SchemaInspector enhancement (allowedValues extraction) - Phase 4: Documentation updates - Phase 5: Additional testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…ase 3)
Phase 3: SchemaInspector Enhancement
**Improved Type Inference:**
- Analyze multiple rows (up to 100) instead of just the first row
- More accurate pattern detection with improved heuristics
- Better phone number validation (avoid false positives)
- DateTime detection prioritized over Date detection
**Enum/EnumList Auto-Detection:**
- Automatic Enum detection based on unique value ratio
- Heuristic: Fields with ≤10 unique values or <20% unique ratio
- Extract allowedValues automatically from actual data
- Supports both Enum (single value) and EnumList (arrays)
**Features:**
- looksLikeEnum(): Smart enum detection based on data patterns
- extractAllowedValues(): Collects unique values for Enum/EnumList
- Improved inferType(): Better pattern matching order and accuracy
- Multi-row analysis for more reliable type inference
**Use Cases:**
- Auto-detect status fields as Enum with extracted values
- Identify category/priority/type fields automatically
- Extract all possible enum values from existing data
- Generate more accurate schemas with less manual work
**Changes:**
- src/cli/SchemaInspector.ts:
- inspectTable(): Analyze up to 100 rows instead of 1
- inferType(): Improved pattern detection logic
- looksLikeEnum(): NEW - Enum detection heuristic
- extractAllowedValues(): NEW - Extract enum values from data
**Testing:**
- All 82 tests still passing
- Build successful
- No breaking changes
**Example Output:**
```yaml
fields:
status:
type: Enum
allowedValues: ["Active", "Inactive", "Pending"]
tags:
type: EnumList
allowedValues: ["JavaScript", "TypeScript", "React", "Node.js"]
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Phase 4: Documentation **Updated CLAUDE.md:** - Added Validators section documenting modular validation architecture - Enhanced SchemaInspector section with smart enum detection details - Updated schema structure to v2.0.0 format with all 27 AppSheet types - Added validation examples with error messages - Added Breaking Changes section with migration example - Updated error handling section for field-level validation **Created MIGRATION.md:** - Complete migration guide from v1.x to v2.0.0 - Step-by-step migration instructions - Type mapping reference table (old → new types) - Common migration patterns with examples - Automated migration script template - Troubleshooting section for common errors - Validation changes documentation **Documentation Highlights:** - All 27 AppSheet field types documented and categorized - Schema format examples for v2.0.0 - Validation error examples for common cases - CLI usage for schema generation - Breaking changes clearly marked - Migration estimated time: 15-30 minutes per schema **Changes:** - CLAUDE.md: Updated with v2.0.0 features and breaking changes - MIGRATION.md: NEW - Comprehensive migration guide **Testing:** - All 82 tests passing - Build successful - Documentation reviewed **Next Steps:** - Phase 5: Additional testing (if needed) - Update package.json version to 2.0.0 - Create release notes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added extensive test coverage for AppSheet field type validation: **DynamicTable Tests** (now 100% coverage): - Query methods (findAll, findOne, find with/without selector) - Delete operations - Metadata methods (getDefinition, getTableName, getKeyField) - Integration tests with realistic workflows: * Complete CRUD workflow with mixed field types * Validation errors in multi-step workflow * Batch operations with partial updates - Edge cases: * Multiple validation failures * Null/undefined values for optional fields * Row index in error messages **SchemaInspector Tests** (62 new tests): - Type inference for all AppSheet types (Email, URL, Phone, Date, DateTime, Percent, Number, YesNo, EnumList) - Enum detection heuristics (≤10 unique values, <20% unique ratio) - AllowedValues extraction for Enum/EnumList - Multi-row analysis (100 rows) - Key field detection (id, _RowNumber, Key) - Empty table handling - Schema name conversion - Error handling - GenerateSchema for multiple tables - Mixed type scenarios **Test Results**: - 126 tests total (+44 new tests) - All tests passing ✅ - Coverage: 81.88% statements, 74.17% branches - DynamicTable.ts: 100% coverage ✅ Fixes for test compatibility: - Fixed delete mock responses to use DeleteResponse interface - Fixed enum detection test with higher unique ratio - Fixed error message format expectations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implementation of SOSO-247: AppSheet Field Type Support and Validation Enhancement - a breaking change for v2.0.0.
This PR replaces generic TypeScript types with 27 AppSheet-specific field types and implements comprehensive validation for all field types.
Breaking Changes⚠️
This is a major version bump to v2.0.0 with the following breaking changes:
string,number,boolean,date,array,object) removedemail: string) removedemail: { type: 'Email', required: true })enumrenamed toallowedValuesSee MIGRATION.md for complete migration guide.
Implementation Overview
Phase 1: Type System Extension
AppSheetFieldTypeunion typeFieldDefinitioninterface withallowedValues,referencedTable,appSheetConfigPhase 2: Validation Enhancement
BaseTypeValidator- JavaScript primitive validationFormatValidator- Format-specific validation (Email, URL, Phone, Date patterns, Percent range)AppSheetTypeValidator- Main orchestrator for all AppSheet typesPhase 3: SchemaInspector Enhancement
allowedValuesextraction for Enum/EnumList fieldsPhase 4: Documentation
Phase 5: Testing
Test Results
AppSheet Field Types
Core Types
Specialized Text Types
Specialized Number Types
Selection Types
Media Types
Tracking Types
Reference Types
Special Types
Migration Example
Validation Examples
Commits
Checklist
Related
🤖 Generated with Claude Code