Skip to content

refactor: enhance resource schema validation with comprehensive Zod types#151

Merged
kfirstri merged 6 commits into
mainfrom
entity-schema-poc
Jan 31, 2026
Merged

refactor: enhance resource schema validation with comprehensive Zod types#151
kfirstri merged 6 commits into
mainfrom
entity-schema-poc

Conversation

@ozsay

@ozsay ozsay commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds comprehensive Zod schema validation for Entity, Agent, and Function resources to align with backend requirements. The changes enforce strict validation for row-level security (RLS) conditions with recursive schemas, tool configurations for agents, nested property definitions for entities, and improved function schema validation. Error handling has been enhanced to include resource file paths when validation fails, making debugging easier.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • Entity schema: Added comprehensive property validation with recursive definitions for nested objects/arrays, RLS validation supporting logical operators ($or, $and, $nor) and field conditions ($in, $nin, $ne, $all), support for various property types (string, number, boolean, array, object, binary) with format constraints (date, email, uuid, etc.), and strict alphanumeric name validation
  • Agent schema: Added validation for tool configurations (entity operations and backend functions), made description and instructions required fields, and added optional WhatsApp greeting support
  • Function schema: Removed unused model field and deprecated empty triggers field, strengthened name validation to prevent dots, added FunctionDeploySchema for deployment validation, and improved error messages for entry points and file arrays
  • Error handling: Enhanced agent and entity config readers to use safeParse() and include resource file paths in validation error messages
  • Test fixture: Updated task.json entity to use correct properties structure instead of deprecated fields format

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated AGENTS.md if I made architectural changes

Additional Notes

These schema changes enforce stricter validation matching backend expectations. Key improvements include:

  • Recursive property definitions enabling nested structures with type safety
  • Comprehensive RLS condition validation with support for user conditions (role, email, id, data.*) and field conditions with operators
  • Removal of deprecated/unused fields (model, triggers)
  • Better developer experience with error messages that include the exact resource file path where validation failed

Breaking Changes: Existing projects must update their configurations:

  • Entities must use type: "object" and properties structure (not fields)
  • Agents must include required description and instructions fields
  • Function names cannot contain dots
  • All schemas are now strictly validated against backend requirements

🤖 Generated by Claude | 2026-01-31 09:45 UTC

@github-actions

github-actions Bot commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.25-pr.151.d222362

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.25-pr.151.d222362"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.25-pr.151.d222362"
  }
}

Preview published to npm registry — try new features instantly!

@claude

claude Bot commented Jan 28, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@ozsay ozsay changed the title test: add entity schema validation with 140 fixtures feat: migrate entity schema validation to Zod with 140 test fixtures Jan 29, 2026
@ozsay ozsay changed the title feat: migrate entity schema validation to Zod with 140 test fixtures refactor: enhance entity schema validation with comprehensive Zod types Jan 29, 2026
Comment thread package.json Outdated
"@rollup/rollup-linux-x64-gnu": "^4.56.0"
}
},
"packageManager": "yarn@4.12.0+sha256.1fe4e1193cbcd13a48d8f436bb17d3c672b049a5e32a758aab9866a073db1702"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ffs my aliases

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove some of the huge commends, and also we don't need to export everything since it's not used progrematically.

* Field-level RLS - controls which fields users can access within records
* Only allows: read, write, create, update, delete
*/
const FieldRLSSchema = z.strictObject({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is verified against the apper codebase?
I remember only read and write being supported in FLS, might be wrong

Comment thread src/core/resources/entity/schema.ts Outdated
/**
* Property definition - recursive structure for field definitions
*/
type PropertyDefinitionType = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can infer types, no need to write them twice

@kfirstri kfirstri moved this from Backlog to In review in CLI Development Jan 29, 2026
@ozsay ozsay force-pushed the entity-schema-poc branch from 3cc8947 to 8d2b047 Compare January 29, 2026 13:09
@ozsay ozsay changed the title refactor: enhance entity schema validation with comprehensive Zod types refactor: enhance resource schema validation with comprehensive Zod types Jan 29, 2026

@kfirstri kfirstri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@kfirstri kfirstri merged commit f8f4d12 into main Jan 31, 2026
6 checks passed
@kfirstri kfirstri deleted the entity-schema-poc branch January 31, 2026 09:42
@github-project-automation github-project-automation Bot moved this from In review to Done in CLI Development Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants