-
Notifications
You must be signed in to change notification settings - Fork 152
Public API for Custom Operators with Factory Helpers #1106
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
base: claude/auto-register-operators-016i3ACKCCt2WbkPRApMpqju
Are you sure you want to change the base?
Public API for Custom Operators with Factory Helpers #1106
Conversation
|
| Name | Type |
|---|---|
| @tanstack/db | Patch |
| @tanstack/angular-db | Patch |
| @tanstack/electric-db-collection | Patch |
| @tanstack/offline-transactions | Patch |
| @tanstack/powersync-db-collection | Patch |
| @tanstack/query-db-collection | Patch |
| @tanstack/react-db | Patch |
| @tanstack/rxdb-db-collection | Patch |
| @tanstack/solid-db | Patch |
| @tanstack/svelte-db | Patch |
| @tanstack/trailbase-db-collection | Patch |
| @tanstack/vue-db | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
01b917f to
98b251a
Compare
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: +467 B (+0.48%) Total Size: 97.2 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.35 kB ℹ️ View Unchanged
|
be91eeb to
dd23147
Compare
KyleAMathews
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Merge (double-merge) away!
|
chatgpt's review https://chatgpt.com/share/6960421c-26c4-800c-af32-2ae0f8ce98a8 |
stacked on #944
PR: Public API for Custom Operators with Factory Helpers
Summary
This PR adds a clean public API (
defineOperator,defineAggregate) for users to create custom operators and aggregates, along with factory helpers that reduce boilerplate for common patterns.Changes
New Files
define.ts- Public API fordefineOperatoranddefineAggregatefactories.ts- Factory helpers:comparison(),transform(),numeric(),pattern(),booleanOp()Refactored Built-in Operators
All built-in operators now use the new factory helpers, significantly reducing code duplication:
eq,gt,gte,lt,lte) - Usecomparison()helperand,or) - UsebooleanOp()helperadd,subtract,multiply,divide) - Usenumeric()helperupper,lower) - Usetransform()helperlike,ilike) - Usepattern()helperisNull,isUndefined,not) - UsedefineOperatordirectlyTree-Shaking Improvements
/*#__PURE__*/annotations to all factory calls for better tree-shakingNew Exports
Usage Examples
Custom Operator with Factory Helper
Custom Operator with Inline Compile Function
Custom Aggregate
API Design Notes
compileproperty: Named to reflect the two-phase execution - called once during query compilation to create the per-row evaluatorTArgssupports named tuples like[value: number, min: number]for better IDE experienceTypedEvaluatorFactoryfor type safety while remaining compatible with the internalEvaluatorFactoryTests
custom-operators.test.tsandcustom-aggregates.test.tscustom-operators.test-d.tsandcustom-aggregates.test-d.ts