Skip to content

fix: resolve build errors in metadata and client-react packages#642

Merged
hotlong merged 2 commits into
mainfrom
copilot/fix-build-and-test-another-one
Feb 12, 2026
Merged

fix: resolve build errors in metadata and client-react packages#642
hotlong merged 2 commits into
mainfrom
copilot/fix-build-and-test-another-one

Conversation

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

DTS build fails in @objectstack/metadata and @objectstack/client-react due to type mismatches against updated spec contracts.

@objectstack/metadata

  • TS6133: Prefix unused type param in validate()_type
  • TS2416: watch(type, callback: WatchCallback): void conflicts with IMetadataService.watch? which expects MetadataWatchCallback → MetadataWatchHandle. Renamed internal methods to addWatchCallback/removeWatchCallback (protected) to eliminate the signature clash. watchService() already implements the contract correctly and now calls the renamed internals.

@objectstack/client-react

  • PaginatedResult<T> was refactored to use records/total but data-hooks.tsx still referenced old value/count properties
  • metadata-hooks.tsx called non-existent client.meta.getObject()client.meta.getItem('object', name)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel

vercel Bot commented Feb 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Feb 12, 2026 11:27am
spec Ready Ready Preview, Comment Feb 12, 2026 11:27am

Request Review

- Fix TS6133 unused 'type' param in MetadataManager.validate()
- Fix TS2416 watch() signature conflict with IMetadataService contract
- Fix PaginatedResult property references (count→total, value→records)
- Fix getObject→getItem('object', name) in metadata-hooks

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong
hotlong requested a review from Copilot February 12, 2026 06:52
Copilot AI changed the title [WIP] Fix build and test issues fix: resolve build errors in metadata and client-react packages Feb 12, 2026
Copilot AI requested a review from hotlong February 12, 2026 06:54
@hotlong
hotlong marked this pull request as ready for review February 12, 2026 06:57
@hotlong
hotlong merged commit 8864c7e into main Feb 12, 2026
7 of 9 checks passed

Copilot AI left a comment

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.

Pull request overview

This PR fixes TypeScript build errors across @objectstack/metadata and @objectstack/client-react by aligning method names with contract types and updating client-side pagination/metadata access to match the current @objectstack/client response shapes.

Changes:

  • Update MetadataManager internals to avoid a type conflict with the IMetadataService.watch? contract and fix an unused parameter warning.
  • Update React client hooks to use the current pagination fields (total, records) and metadata fetch API (getItem).
  • Adjust metadata tests to use the renamed internal watch-callback helpers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/metadata/src/metadata.test.ts Updates watch/unwatch tests to call the renamed internal watch-callback helpers.
packages/metadata/src/metadata-manager.ts Renames internal watch/unwatch helpers and silences an unused validate parameter warning.
packages/client-react/src/metadata-hooks.tsx Switches object fetch to client.meta.getItem('object', name) for the non-cached path.
packages/client-react/src/data-hooks.tsx Updates pagination field usage to total/records to match PaginatedResult.

@@ -623,7 +623,7 @@ export class MetadataManager implements IMetadataService {
* Validate a metadata item against its type schema.

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

validate() JSDoc says it validates “against its type schema”, but the implementation doesn’t use type at all (now _type) and only performs basic structural checks. Either implement type-based validation (e.g., via the registered type registry) or update the comment/parameter name to avoid implying schema validation.

Suggested change
* Validate a metadata item against its type schema.
* Perform basic structural validation for a metadata item.
* Ensures the payload is a non-null object with a name field and optional label.

Copilot uses AI. Check for mistakes.
// Determine if there's a next page
const fetchedCount = result.value?.length ?? 0;
const fetchedCount = result.records?.length ?? 0;
const hasMore = fetchedCount === pageSize;

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

useInfiniteQuery computes hasMore purely from records.length === pageSize, but PaginatedResult also supports a server-provided hasMore flag. If the backend returns hasMore: false while still returning a full page, this hook will incorrectly keep enabling “load more”. Prefer honoring result.hasMore when present (fallback to the length check otherwise).

Suggested change
const hasMore = fetchedCount === pageSize;
const hasMore =
typeof result.hasMore === 'boolean' ? result.hasMore : fetchedCount === pageSize;

Copilot uses AI. Check for mistakes.
Comment on lines 191 to +211
@@ -207,8 +207,8 @@ describe('MetadataManager', () => {

it('should unwatch callback', () => {
const callback = vi.fn();
manager.watch('object', callback);
manager.unwatch('object', callback);
(manager as any).addWatchCallback('object', callback);
(manager as any).removeWatchCallback('object', callback);

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

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

This test suite is still labeled "watch / unwatch" but it now exercises addWatchCallback / removeWatchCallback. Renaming the describe/it titles to match the current API will keep test intent clear (especially since watch/unwatch no longer exist on MetadataManager).

Copilot uses AI. Check for mistakes.
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.

3 participants