Add promise() schema builder#159
Merged
andrewzolotukhin merged 7 commits intodevelopmentfrom Apr 10, 2026
Merged
Conversation
…amples Agent-Logs-Url: https://github.com/cleverbrush/framework/sessions/931a7d5d-bd3f-4cb8-8cff-63c6f1d8dd80 Co-authored-by: andrewzolotukhin <1894885+andrewzolotukhin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/cleverbrush/framework/sessions/931a7d5d-bd3f-4cb8-8cff-63c6f1d8dd80 Co-authored-by: andrewzolotukhin <1894885+andrewzolotukhin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add a promise schema builder for resolving to Promise<T> type
Add Apr 10, 2026
promise() schema builder
- Updated bundle sizes in `bundle-sizes.json` for `@cleverbrush/schema` and `@cleverbrush/schema/core`. - Adjusted bundle size badge in `libs/schema/README.md` to reflect new gzip size. - Modified coverage badge in `libs/schema/README.md` to show updated coverage percentage. - Refactored tests in `PromiseSchemaBuilder.test.ts` to remove unnecessary async/await usage. - Cleaned up constructor formatting in `PromiseSchemaBuilder.ts`. - Reorganized exports in `core.ts`, `index.ts`, and `schemaDeclarations.ts` for consistency.
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces first-class Promise support to @cleverbrush/schema via a new PromiseSchemaBuilder and promise() factory, including exports, docs, tests, and playground examples.
Changes:
- Added
PromiseSchemaBuilder+promise()factory with resolved-type typing via.hasResolvedType(schema)andpromise(schema)shorthand. - Integrated builder into package exports/build (tsup entry, subpath export) and updated docs/playground examples.
- Added dedicated unit + type tests and regenerated generated artifacts (playground declarations, bundle/bench metadata).
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/app/playground/schemaDeclarations.ts | Regenerated playground type declarations to include PromiseSchemaBuilder/promise exports. |
| website/app/playground/examples/index.ts | Added “Promise Schemas” playground group and two new examples. |
| README.md | Updated root coverage badge (generated). |
| libs/schema/tsup.config.ts | Added PromiseSchemaBuilder.ts to build entrypoints. |
| libs/schema/src/index.ts | Exported PromiseSchemaBuilder, promise, and ExtendedPromise from main entrypoint. |
| libs/schema/src/extensions/index.ts | Added ExtendedPromise type and exported promise from extensions entrypoint. |
| libs/schema/src/core.ts | Exported PromiseSchemaBuilder and promise from core. |
| libs/schema/src/builders/PromiseSchemaBuilder.ts | Implemented the new builder + factory and introspection support. |
| libs/schema/src/builders/PromiseSchemaBuilder.test.ts | Added unit + type tests for promise validation, typing, and immutability. |
| libs/schema/README.md | Documented promise(schema?) and added a “Promise Schemas” section + export list updates. |
| libs/schema/package.json | Added subpath export @cleverbrush/schema/promise. |
| bundle-sizes.json | Updated bundle size snapshot (generated). |
| bench-results.json | Updated benchmark snapshot (generated). |
| .changeset/add-promise-schema-builder.md | Added changeset for a minor release including usage notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Introduced PromiseSchemaBuilder to handle promise-like values in schema validation. - Updated the README to reflect the new bundle size for the schema library. - Adjusted bundle sizes in bundle-sizes.json to reflect recent changes. - Enhanced type definitions to include promise-related types in schema declarations.
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
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.
@cleverbrush/schemahad no way to validatePromisevalues or expressPromise<T>in the inferred type system.New:
PromiseSchemaBuilder+promise()factoryChanges
PromiseSchemaBuilder.ts— new builder extendingSchemaBuilder. Validates via thenable duck-typing (typeof .then === 'function'). Supports.hasResolvedType(schema)to set the resolved-value type; factory shorthandpromise(schema?)as sugar. All standard methods preserved (optional,nullable,default,brand,readonly,hasType, etc.).introspect().resolvedTypeexposes the schema for tooling.PromiseSchemaBuilder.test.ts— 25 unit + type tests covering validation, optional/required,hasResolvedType,promise(schema)shorthand, immutability, and type inference.PromiseSchemaBuilder,promise,ExtendedPromiseadded tocore.ts,index.ts, andextensions/index.ts. Subpath export@cleverbrush/schema/promiseadded topackage.jsonandtsup.config.ts.promise()added to the API table and builder classes list; new "Promise Schemas" section with usage examples.@cleverbrush/schema.schemaDeclarations.tsregenerated from build; two new examples (promise-schema,promise-typed) added to the website playground.