Skip to content

Conversation

@mathpirate
Copy link
Contributor

@mathpirate mathpirate commented Nov 4, 2025

Clean up various parts of the schema-generator and ts-transformers package in light of new CELL_BRAND mechanism


Summary by cubic

Centralized CELL_BRAND detection in @commontools/schema-generator/cell-brand and updated schema-generator and ts-transformers to use it. Wrapper detection now relies on brands for Cell/Stream/OpaqueRef, supports brand variants, and correctly handles unions (optional/nullable).

  • New Features

    • Schema generation recognizes comparable, readonly, writeonly as Cell; stream and opaque as expected.
    • Added tests and fixtures for brand variants and opaque detection.
  • Refactors

    • Moved brand logic to packages/schema-generator/src/typescript/cell-brand.ts and exported as @commontools/schema-generator/cell-brand.
    • Simplified CommonToolsFormatter and IntersectionFormatter to use the shared brand API.
    • Removed legacy, intersection-based OpaqueRef detection and duplicate brand code in ts-transformers.
    • Updated Deno imports to include @commontools/schema-generator/cell-brand.
    • Enforced CELL_BRAND for wrapper detection in schema-generator; updated test prelude and fixtures.

Written for commit 6a66c46. Summary will update automatically on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 14 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/utils/src/typescript/cell-brand.ts">

<violation number="1" location="packages/utils/src/typescript/cell-brand.ts:51">
extractWrapperTypeReference never inspects union types, so a branded wrapper like `Cell&lt;T&gt; | undefined` falls through and returns `undefined`, even though getCellBrand already found the CELL_BRAND. Optional or nullable cells are therefore treated as non-cells, breaking schema/transformer logic that relies on wrapper info.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

return prop;
}
}
return undefined;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Nov 4, 2025

Choose a reason for hiding this comment

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

extractWrapperTypeReference never inspects union types, so a branded wrapper like Cell<T> | undefined falls through and returns undefined, even though getCellBrand already found the CELL_BRAND. Optional or nullable cells are therefore treated as non-cells, breaking schema/transformer logic that relies on wrapper info.

Prompt for AI agents
Address the following comment on packages/utils/src/typescript/cell-brand.ts at line 51:

<comment>extractWrapperTypeReference never inspects union types, so a branded wrapper like `Cell&lt;T&gt; | undefined` falls through and returns `undefined`, even though getCellBrand already found the CELL_BRAND. Optional or nullable cells are therefore treated as non-cells, breaking schema/transformer logic that relies on wrapper info.</comment>

<file context>
@@ -0,0 +1,219 @@
+      return prop;
+    }
+  }
+  return undefined;
+}
+
</file context>
Fix with Cubic

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@mathpirate mathpirate force-pushed the dx1/cleanup-cell-brand-detection branch from 5879f1d to f39b87f Compare November 5, 2025 18:18
@mathpirate mathpirate merged commit 545bbf1 into main Nov 5, 2025
8 checks passed
@mathpirate mathpirate deleted the dx1/cleanup-cell-brand-detection branch November 5, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants