Skip to content

Commit a149bc4

Browse files
Core Data: PR 7: Convert the resolvers to TypeScript (#85069)
* Core Data: Convert the resolvers to TypeScript and add the thunk arguments type * Core Data: Accept array allow hints, keyed collections and null IDs in the resolvers * Core Data: Add the CHANGELOG entry for #85069 * Core Data: Type the cache key arguments of the canUser resolver
1 parent 46ff453 commit a149bc4

7 files changed

Lines changed: 539 additions & 311 deletions

File tree

‎packages/core-data/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Internal
66

7+
- Convert the resolvers to TypeScript and add the store thunk arguments type ([#85069](https://github.com/WordPress/gutenberg/pull/85069)).
78
- Convert the entities config and the store reducer to TypeScript, and add the store `Action` type ([#85065](https://github.com/WordPress/gutenberg/pull/85065)).
89
- Convert the entity hooks, the entity providers and the parsed blocks cache to TypeScript ([#85063](https://github.com/WordPress/gutenberg/pull/85063)).
910
- Convert the batch and fetch helpers to TypeScript ([#85062](https://github.com/WordPress/gutenberg/pull/85062)).

‎packages/core-data/src/private-types.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Types internal to the package, which the package root does not re-export.
33
*/
44
import type { Block } from '@wordpress/blocks';
5+
import type { ThunkArgs } from '@wordpress/data';
56
import type { ConnectionStatus } from '@wordpress/sync';
67
import type { HistoryRecord } from '@wordpress/undo-manager';
78
import type * as ET from './entity-types';
@@ -236,3 +237,33 @@ export interface UsersState {
236237
byId: Record< ItemId, ET.User< 'view' > >;
237238
queries: Record< string, Array< ItemId > >;
238239
}
240+
241+
/**
242+
* The argument of the core data thunks, with the private selectors and
243+
* actions.
244+
*/
245+
export type CoreDataThunkArgs = ThunkArgs<
246+
typeof import( '.' ).store,
247+
typeof import( './private-selectors' ),
248+
typeof import( './private-actions' )
249+
>;
250+
251+
/**
252+
* A record received from the REST API.
253+
*/
254+
export type RestRecord = Record< string, unknown > & {
255+
_links?: RestLinks;
256+
};
257+
258+
/**
259+
* The links of a REST API record that core data reads.
260+
*/
261+
export interface RestLinks {
262+
self?: Array< {
263+
href?: string;
264+
targetHints?: { allow?: ReadonlyArray< string > };
265+
} >;
266+
'version-history'?: Array< { href?: string } >;
267+
'wp:user-global-styles'?: Array< { href?: string } >;
268+
[ relation: string ]: unknown;
269+
}

‎packages/core-data/src/queried-data/types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export interface ReceiveItemsAction {
9797
meta?: QueriedMeta | null;
9898
query?: Query | null;
9999
key?: string;
100+
invalidateCache?: boolean;
100101
}
101102

102103
/**

0 commit comments

Comments
 (0)