Skip to content

Commit 3b3bbaa

Browse files
Copilothotlong
andcommitted
fix: resolve build errors in metadata, client-react packages
- 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>
1 parent 88aaabb commit 3b3bbaa

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

packages/client-react/src/data-hooks.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ export function usePagination<T = any>(
392392
skip: (page - 1) * pageSize
393393
});
394394

395-
const totalCount = queryResult.data?.count || 0;
395+
const totalCount = queryResult.data?.total || 0;
396396
const totalPages = Math.ceil(totalCount / pageSize);
397397
const hasNextPage = page < totalPages;
398398
const hasPreviousPage = page > 1;
@@ -546,7 +546,7 @@ export function useInfiniteQuery<T = any>(
546546
}
547547

548548
// Determine if there's a next page
549-
const fetchedCount = result.value?.length ?? 0;
549+
const fetchedCount = result.records?.length ?? 0;
550550
const hasMore = fetchedCount === pageSize;
551551
setHasNextPage(hasMore);
552552

@@ -580,7 +580,7 @@ export function useInfiniteQuery<T = any>(
580580
await fetchPage(0);
581581
}, [fetchPage]);
582582

583-
const flatData = pages.flatMap(page => page.value ?? []);
583+
const flatData = pages.flatMap(page => page.records ?? []);
584584

585585
return {
586586
data: pages,

packages/client-react/src/metadata-hooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function useObject(
112112
onSuccess?.(result.data || data);
113113
} else {
114114
// Direct fetch without cache
115-
const result = await client.meta.getObject(objectName);
115+
const result = await client.meta.getItem('object', objectName);
116116
setData(result);
117117
onSuccess?.(result);
118118
}

packages/metadata/src/metadata-manager.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ export class MetadataManager implements IMetadataService {
519519
data: event.data,
520520
});
521521
};
522-
this.watch(type, wrappedCallback);
522+
this.addWatchCallback(type, wrappedCallback);
523523
return {
524-
unsubscribe: () => this.unwatch(type, wrappedCallback),
524+
unsubscribe: () => this.removeWatchCallback(type, wrappedCallback),
525525
};
526526
}
527527

@@ -623,7 +623,7 @@ export class MetadataManager implements IMetadataService {
623623
* Validate a metadata item against its type schema.
624624
* Returns validation result with errors and warnings.
625625
*/
626-
async validate(type: string, data: unknown): Promise<MetadataValidationResult> {
626+
async validate(_type: string, data: unknown): Promise<MetadataValidationResult> {
627627
// Basic structural validation
628628
if (data === null || data === undefined) {
629629
return {
@@ -856,19 +856,19 @@ export class MetadataManager implements IMetadataService {
856856
}
857857

858858
/**
859-
* Watch for metadata changes (legacy API)
859+
* Register a watch callback for metadata changes
860860
*/
861-
watch(type: string, callback: WatchCallback): void {
861+
protected addWatchCallback(type: string, callback: WatchCallback): void {
862862
if (!this.watchCallbacks.has(type)) {
863863
this.watchCallbacks.set(type, new Set());
864864
}
865865
this.watchCallbacks.get(type)!.add(callback);
866866
}
867867

868868
/**
869-
* Unwatch metadata changes (legacy API)
869+
* Remove a watch callback for metadata changes
870870
*/
871-
unwatch(type: string, callback: WatchCallback): void {
871+
protected removeWatchCallback(type: string, callback: WatchCallback): void {
872872
const callbacks = this.watchCallbacks.get(type);
873873
if (callbacks) {
874874
callbacks.delete(callback);

packages/metadata/src/metadata.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe('MetadataManager', () => {
191191
describe('watch / unwatch', () => {
192192
it('should register and invoke watch callbacks', () => {
193193
const callback = vi.fn();
194-
manager.watch('object', callback);
194+
(manager as any).addWatchCallback('object', callback);
195195

196196
// Trigger via protected method — cast to access it
197197
(manager as any).notifyWatchers('object', {
@@ -207,8 +207,8 @@ describe('MetadataManager', () => {
207207

208208
it('should unwatch callback', () => {
209209
const callback = vi.fn();
210-
manager.watch('object', callback);
211-
manager.unwatch('object', callback);
210+
(manager as any).addWatchCallback('object', callback);
211+
(manager as any).removeWatchCallback('object', callback);
212212

213213
(manager as any).notifyWatchers('object', {
214214
type: 'changed',
@@ -222,7 +222,7 @@ describe('MetadataManager', () => {
222222
});
223223

224224
it('should not throw when unwatching non-existent callback', () => {
225-
expect(() => manager.unwatch('object', vi.fn())).not.toThrow();
225+
expect(() => (manager as any).removeWatchCallback('object', vi.fn())).not.toThrow();
226226
});
227227
});
228228

0 commit comments

Comments
 (0)