feat: Migrate reference system from ZodRef to transform-based architecture#587
Conversation
🦋 Changeset detectedLatest commit: 1abe446 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Caution Review failedFailed to post review comments. WalkthroughThis change migrates the project's reference and schema handling from a legacy ZodRef-based approach to a new transform-based architecture using context-aware schema creator functions and marker classes. It replaces direct Zod schema manipulation with context-driven APIs for references and entities, introduces new deserialization and parsing methods, updates deletion behaviors, and refactors affected tests, plugins, and UI components to use the new system. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI_Component
participant useDefinitionSchema
participant SchemaCreator
participant DefinitionSchemaParserContext
participant ReferenceMarkers
User->>UI_Component: Interacts with form/component
UI_Component->>useDefinitionSchema: Requests schema (creatorFn)
useDefinitionSchema->>DefinitionSchemaParserContext: Retrieves context
useDefinitionSchema->>SchemaCreator: Calls creatorFn(context)
SchemaCreator->>ReferenceMarkers: Uses ctx.withRef/withEnt/withRefBuilder to define schema
SchemaCreator-->>useDefinitionSchema: Returns Zod schema with markers
useDefinitionSchema-->>UI_Component: Returns ready-to-use schema
UI_Component->>Form: Passes schema for validation/parsing
Form->>ReferenceMarkers: Handles reference/entity markers during parse
sequenceDiagram
participant Deserializer
participant deserializeSchemaWithTransformedReferences
participant SchemaCreator
participant extractDefinitionRefs
participant resolveReferencesToIds
Deserializer->>deserializeSchemaWithTransformedReferences: Provide schemaCreator, input, options
deserializeSchemaWithTransformedReferences->>SchemaCreator: Call with context to get schema
deserializeSchemaWithTransformedReferences->>extractDefinitionRefs: Extract references/entities from input
extractDefinitionRefs-->>deserializeSchemaWithTransformedReferences: Return payload (data, refs, entities)
deserializeSchemaWithTransformedReferences->>resolveReferencesToIds: Resolve names to IDs in data
resolveReferencesToIds-->>deserializeSchemaWithTransformedReferences: Return fully resolved data
deserializeSchemaWithTransformedReferences-->>Deserializer: Return parsed, reference-resolved output
Possibly related PRs
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the project’s reference-handling system from a Zod‐based wrapper approach (ZodRef) to a new transform‐based architecture powered by definitionSchema and context builders (withRef, withEnt, withRefBuilder). Key changes include:
- Replacing all
zEnt/zRef/zRefBuilderusages withctx.withEnt/ctx.withRef/ctx.withRefBuilderinsidedefinitionSchemacreators. - Introducing a unified
useDefinitionSchemahook in place ofusePluginEnhancedSchemaand updating all React components to consume context‐aware schemas. - Refactoring core reference serialization, deserialization, and deletion logic to use transformed references, updating unit/integration tests accordingly.
Reviewed Changes
Copilot reviewed 96 out of 97 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/project-builder-lib/src/references/deserialize-schema.ts | Updated to use transform‐based parsing (parseSchemaWithTransformedReferences) but missing imports for Zod types in the signature. |
| plugins/plugin-auth/src/roles/schema.ts | Refined createAuthRolesSchema, but an extra closing bracket was introduced in the .superRefine chain. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
packages/project-builder-lib/src/references/deserialize-schema.ts:37
- The return type references
z.ZodTypeandTypeOfbut neitherznorTypeOfare imported in this file. Addimport { z, TypeOf } from 'zod'or switch todef.InferOutput<T>to ensure the type annotation compiles correctly.
ReturnType<T> extends z.ZodType ? TypeOf<ReturnType<T>> : unknown
plugins/plugin-auth/src/roles/schema.ts:66
- In the
createAuthRolesSchemadefinition, the extra]before the closing parenthesis causes a syntax error. The chain should end with).superRefine(...))—remove the stray]so the parentheses properly match thearray(...).superRefine(...)call.
]),
Summary by CodeRabbit
New Features
Refactor
SET_UNDEFINEDinstead ofSET_NULL, with improved array handling.Bug Fixes
Documentation
Chores