@wordpress/core-data 4.8.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +56 -56
  3. package/build/actions.js.map +1 -1
  4. package/build/batch/create-batch.js +1 -1
  5. package/build/batch/create-batch.js.map +1 -1
  6. package/build/entities.js.map +1 -1
  7. package/build/entity-provider.js.map +1 -1
  8. package/build/hooks/use-entity-record.js.map +1 -1
  9. package/build/hooks/use-query-select.js.map +1 -1
  10. package/build/queried-data/selectors.js.map +1 -1
  11. package/build/resolvers.js.map +1 -1
  12. package/build/selectors.js +45 -8
  13. package/build/selectors.js.map +1 -1
  14. package/build/utils/forward-resolver.js.map +1 -1
  15. package/build/utils/on-sub-key.js.map +1 -1
  16. package/build/utils/with-weak-map-cache.js +1 -7
  17. package/build/utils/with-weak-map-cache.js.map +1 -1
  18. package/build-module/actions.js.map +1 -1
  19. package/build-module/batch/create-batch.js +2 -2
  20. package/build-module/batch/create-batch.js.map +1 -1
  21. package/build-module/entities.js.map +1 -1
  22. package/build-module/entity-provider.js.map +1 -1
  23. package/build-module/hooks/use-entity-record.js.map +1 -1
  24. package/build-module/hooks/use-query-select.js.map +1 -1
  25. package/build-module/queried-data/selectors.js.map +1 -1
  26. package/build-module/resolvers.js.map +1 -1
  27. package/build-module/selectors.js +40 -4
  28. package/build-module/selectors.js.map +1 -1
  29. package/build-module/utils/forward-resolver.js.map +1 -1
  30. package/build-module/utils/on-sub-key.js.map +1 -1
  31. package/build-module/utils/with-weak-map-cache.js +1 -6
  32. package/build-module/utils/with-weak-map-cache.js.map +1 -1
  33. package/package.json +11 -11
  34. package/src/actions.js +389 -372
  35. package/src/batch/create-batch.js +2 -2
  36. package/src/entities.ts +16 -17
  37. package/src/entity-provider.js +4 -6
  38. package/src/entity-types/attachment.ts +4 -3
  39. package/src/entity-types/comment.ts +4 -3
  40. package/src/entity-types/entities.ts +5 -2
  41. package/src/entity-types/index.ts +114 -20
  42. package/src/entity-types/menu-location.ts +4 -3
  43. package/src/entity-types/nav-menu-item.ts +4 -3
  44. package/src/entity-types/nav-menu.ts +3 -3
  45. package/src/entity-types/page.ts +3 -3
  46. package/src/entity-types/plugin.ts +3 -3
  47. package/src/entity-types/post.ts +3 -3
  48. package/src/entity-types/settings.ts +3 -3
  49. package/src/entity-types/sidebar.ts +4 -3
  50. package/src/entity-types/taxonomy.ts +4 -3
  51. package/src/entity-types/theme.ts +3 -3
  52. package/src/entity-types/type.ts +3 -3
  53. package/src/entity-types/user.ts +3 -3
  54. package/src/entity-types/widget-type.ts +4 -3
  55. package/src/entity-types/widget.ts +3 -3
  56. package/src/entity-types/wp-template-part.ts +4 -3
  57. package/src/entity-types/wp-template.ts +4 -3
  58. package/src/fetch/test/__experimental-fetch-link-suggestions.js +2 -4
  59. package/src/hooks/test/use-query-select.js +4 -2
  60. package/src/hooks/use-entity-record.ts +0 -1
  61. package/src/hooks/use-query-select.ts +26 -24
  62. package/src/locks/test/selectors.js +2 -1
  63. package/src/queried-data/selectors.js +2 -8
  64. package/src/resolvers.js +344 -325
  65. package/src/selectors.ts +347 -194
  66. package/src/test/resolvers.js +1 -3
  67. package/src/test/selectors.js +1 -2
  68. package/src/utils/forward-resolver.js +6 -5
  69. package/src/utils/on-sub-key.js +20 -20
  70. package/src/utils/with-weak-map-cache.js +1 -6
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { isFunction, zip } from 'lodash';
4
+ import { zip } from 'lodash';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -88,7 +88,7 @@ export default function createBatch( processor = defaultProcessor ) {
88
88
  pending.delete( id );
89
89
  } );
90
90
 
91
- if ( isFunction( inputOrThunk ) ) {
91
+ if ( typeof inputOrThunk === 'function' ) {
92
92
  return Promise.resolve( inputOrThunk( add ) ).finally( () => {
93
93
  pending.delete( id );
94
94
  } );
package/src/entities.ts CHANGED
@@ -515,7 +515,7 @@ export const getMethodName = (
515
515
  const nameSuffix =
516
516
  upperFirst( camelCase( name ) ) + ( usePlural ? 's' : '' );
517
517
  const suffix =
518
- usePlural && 'plural' in entityConfig && entityConfig?.plural
518
+ usePlural && 'plural' in entityConfig! && entityConfig?.plural
519
519
  ? upperFirst( camelCase( entityConfig.plural ) )
520
520
  : nameSuffix;
521
521
  return `${ prefix }${ kindPrefix }${ suffix }`;
@@ -528,22 +528,21 @@ export const getMethodName = (
528
528
  *
529
529
  * @return {(thunkArgs: object) => Promise<Array>} Entities
530
530
  */
531
- export const getOrLoadEntitiesConfig = ( kind ) => async ( {
532
- select,
533
- dispatch,
534
- } ) => {
535
- let configs = select.getEntitiesConfig( kind );
536
- if ( configs && configs.length !== 0 ) {
537
- return configs;
538
- }
531
+ export const getOrLoadEntitiesConfig =
532
+ ( kind ) =>
533
+ async ( { select, dispatch } ) => {
534
+ let configs = select.getEntitiesConfig( kind );
535
+ if ( configs && configs.length !== 0 ) {
536
+ return configs;
537
+ }
539
538
 
540
- const loader = find( additionalEntityConfigLoaders, { kind } );
541
- if ( ! loader ) {
542
- return [];
543
- }
539
+ const loader = find( additionalEntityConfigLoaders, { kind } );
540
+ if ( ! loader ) {
541
+ return [];
542
+ }
544
543
 
545
- configs = await loader.loadEntities();
546
- dispatch( addEntities( configs ) );
544
+ configs = await loader.loadEntities();
545
+ dispatch( addEntities( configs ) );
547
546
 
548
- return configs;
549
- };
547
+ return configs;
548
+ };
@@ -105,9 +105,8 @@ export function useEntityProp( kind, name, prop, _id ) {
105
105
 
106
106
  const { value, fullValue } = useSelect(
107
107
  ( select ) => {
108
- const { getEntityRecord, getEditedEntityRecord } = select(
109
- STORE_NAME
110
- );
108
+ const { getEntityRecord, getEditedEntityRecord } =
109
+ select( STORE_NAME );
111
110
  const record = getEntityRecord( kind, name, id ); // Trigger resolver.
112
111
  const editedRecord = getEditedEntityRecord( kind, name, id );
113
112
  return record && editedRecord
@@ -164,9 +163,8 @@ export function useEntityBlockEditor( kind, name, { id: _id } = {} ) {
164
163
  },
165
164
  [ kind, name, id ]
166
165
  );
167
- const { __unstableCreateUndoLevel, editEntityRecord } = useDispatch(
168
- STORE_NAME
169
- );
166
+ const { __unstableCreateUndoLevel, editEntityRecord } =
167
+ useDispatch( STORE_NAME );
170
168
 
171
169
  useEffect( () => {
172
170
  // Load the blocks from the content if not already in state
@@ -13,6 +13,7 @@ import type {
13
13
  } from './helpers';
14
14
 
15
15
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
16
+ import type { DefaultContextOf } from './index';
16
17
 
17
18
  declare module './base-entity-records' {
18
19
  export namespace BaseEntityRecords {
@@ -141,6 +142,6 @@ declare module './base-entity-records' {
141
142
  }
142
143
  }
143
144
 
144
- export type Attachment< C extends Context > = OmitNevers<
145
- _BaseEntityRecords.Attachment< C >
146
- >;
145
+ export type Attachment<
146
+ C extends Context = DefaultContextOf< 'root', 'media' >
147
+ > = OmitNevers< _BaseEntityRecords.Attachment< C > >;
@@ -9,6 +9,7 @@ import type {
9
9
  RenderedText,
10
10
  } from './helpers';
11
11
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
12
+ import type { DefaultContextOf } from './index';
12
13
 
13
14
  export type CommentStatus = 'hold' | 'approve' | 'spam' | 'trash' | '1' | '0';
14
15
 
@@ -91,6 +92,6 @@ declare module './base-entity-records' {
91
92
  }
92
93
  }
93
94
 
94
- export type Comment< C extends Context > = OmitNevers<
95
- _BaseEntityRecords.Comment< C >
96
- >;
95
+ export type Comment<
96
+ C extends Context = DefaultContextOf< 'root', 'comment' >
97
+ > = OmitNevers< _BaseEntityRecords.Comment< C > >;
@@ -2,7 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import type { Context } from './helpers';
5
- import { EntityRecord } from './index';
5
+ import type { EntityRecord } from './index';
6
6
 
7
7
  /**
8
8
  * HTTP Query parameters sent with the API request to fetch the entity records.
@@ -48,7 +48,10 @@ export type EntityType<
48
48
 
49
49
  type RequiredConfigKeys = 'name' | 'kind' | 'key' | 'baseURLParams';
50
50
 
51
- interface EntityConfig< R extends EntityRecord< C >, C extends Context > {
51
+ export interface EntityConfig<
52
+ R extends EntityRecord< C >,
53
+ C extends Context
54
+ > {
52
55
  /** Path in WP REST API from which to request records of this entity. */
53
56
  baseURL: string;
54
57
 
@@ -20,6 +20,7 @@ import type { Widget } from './widget';
20
20
  import type { WidgetType } from './widget-type';
21
21
  import type { WpTemplate } from './wp-template';
22
22
  import type { WpTemplatePart } from './wp-template-part';
23
+ import type { CoreEntities } from '../entities';
23
24
 
24
25
  export type { EntityType } from './entities';
25
26
  export type { BaseEntityRecords } from './base-entity-records';
@@ -47,24 +48,117 @@ export type {
47
48
  WpTemplatePart,
48
49
  };
49
50
 
50
- export type EntityRecord< C extends Context > =
51
- | Attachment< C >
52
- | Comment< C >
53
- | MenuLocation< C >
54
- | NavMenu< C >
55
- | NavMenuItem< C >
56
- | Page< C >
57
- | Plugin< C >
58
- | Post< C >
59
- | Settings< C >
60
- | Sidebar< C >
61
- | Taxonomy< C >
62
- | Theme< C >
63
- | Type< C >
64
- | User< C >
65
- | Widget< C >
66
- | WidgetType< C >
67
- | WpTemplate< C >
68
- | WpTemplatePart< C >;
69
-
70
51
  export type UpdatableEntityRecord = Updatable< EntityRecord< 'edit' > >;
52
+
53
+ /**
54
+ * An interface that may be extended to add types for new entities. Each entry
55
+ * must be a union of entity definitions adhering to the EntityInterface type.
56
+ *
57
+ * Example:
58
+ *
59
+ * ```ts
60
+ * import type { Context } from '@wordpress/core-data';
61
+ * // ...
62
+ *
63
+ * interface Order {
64
+ * id: number;
65
+ * clientId: number;
66
+ * // ...
67
+ * }
68
+ *
69
+ * type OrderEntity = {
70
+ * kind: 'myPlugin';
71
+ * name: 'order';
72
+ * recordType: Order;
73
+ * }
74
+ *
75
+ * declare module '@wordpress/core-data' {
76
+ * export interface PerPackageEntities< C extends Context > {
77
+ * myPlugin: OrderEntity | ClientEntity
78
+ * }
79
+ * }
80
+ *
81
+ * const c = getEntityRecord( 'myPlugin', 'order', 15 );
82
+ * // c is of the type Order
83
+ * ```
84
+ */
85
+ export interface PerPackageEntityConfig< C extends Context > {
86
+ core: CoreEntities< C >;
87
+ }
88
+
89
+ /**
90
+ * A union of all the registered entities.
91
+ */
92
+ type EntityConfig< C extends Context = any > =
93
+ PerPackageEntityConfig< C >[ keyof PerPackageEntityConfig< C > ];
94
+
95
+ /**
96
+ * A union of all known record types.
97
+ */
98
+ export type EntityRecord< C extends Context = any > =
99
+ EntityConfig< C >[ 'record' ];
100
+
101
+ /**
102
+ * An entity corresponding to a specified record type.
103
+ */
104
+ export type EntityConfigOf<
105
+ RecordOrKind extends EntityRecord | Kind,
106
+ N extends Name | undefined = undefined
107
+ > = RecordOrKind extends EntityRecord
108
+ ? Extract< EntityConfig, { record: RecordOrKind } >
109
+ : Extract< EntityConfig, { config: { kind: RecordOrKind; name: N } } >;
110
+
111
+ /**
112
+ * Name of the requested entity.
113
+ */
114
+ export type NameOf< R extends EntityRecord > =
115
+ EntityConfigOf< R >[ 'config' ][ 'name' ];
116
+
117
+ /**
118
+ * Kind of the requested entity.
119
+ */
120
+ export type KindOf< R extends EntityRecord > =
121
+ EntityConfigOf< R >[ 'config' ][ 'kind' ];
122
+
123
+ /**
124
+ * Primary key type of the requested entity, sourced from PerPackageEntities.
125
+ *
126
+ * For core entities, the key type is computed using the entity configuration in entities.js.
127
+ */
128
+ export type KeyOf<
129
+ RecordOrKind extends EntityRecord | Kind,
130
+ N extends Name | undefined = undefined,
131
+ E extends EntityConfig = EntityConfigOf< RecordOrKind, N >
132
+ > = ( E[ 'key' ] extends keyof E[ 'record' ]
133
+ ? E[ 'record' ][ E[ 'key' ] ]
134
+ : never ) &
135
+ ( number | string );
136
+
137
+ /**
138
+ * Default context of the requested entity, sourced from PerPackageEntities.
139
+ *
140
+ * For core entities, the default context is extracted from the entity configuration
141
+ * in entities.js.
142
+ */
143
+ export type DefaultContextOf<
144
+ RecordOrKind extends EntityRecord | Kind,
145
+ N extends Name | undefined = undefined
146
+ > = EntityConfigOf< RecordOrKind, N >[ 'defaultContext' ];
147
+
148
+ /**
149
+ * An entity record type associated with specified kind and name, sourced from PerPackageEntities.
150
+ */
151
+ export type EntityRecordOf<
152
+ K extends Kind,
153
+ N extends Name,
154
+ C extends Context = DefaultContextOf< K, N >
155
+ > = Extract< EntityConfig< C >, { config: { kind: K; name: N } } >[ 'record' ];
156
+
157
+ /**
158
+ * A union of all known entity kinds.
159
+ */
160
+ export type Kind = EntityConfig[ 'config' ][ 'kind' ];
161
+ /**
162
+ * A union of all known entity names.
163
+ */
164
+ export type Name = EntityConfig[ 'config' ][ 'name' ];
@@ -4,6 +4,7 @@
4
4
  import type { Context, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -24,6 +25,6 @@ declare module './base-entity-records' {
24
25
  }
25
26
  }
26
27
 
27
- export type MenuLocation< C extends Context > = OmitNevers<
28
- _BaseEntityRecords.MenuLocation< C >
29
- >;
28
+ export type MenuLocation<
29
+ C extends Context = DefaultContextOf< 'root', 'menuLocation' >
30
+ > = OmitNevers< _BaseEntityRecords.MenuLocation< C > >;
@@ -9,6 +9,7 @@ import type {
9
9
  } from './helpers';
10
10
 
11
11
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
12
+ import type { DefaultContextOf } from './index';
12
13
 
13
14
  export type NavMenuItemType =
14
15
  | 'taxonomy'
@@ -106,6 +107,6 @@ declare module './base-entity-records' {
106
107
  }
107
108
  }
108
109
 
109
- export type NavMenuItem< C extends Context > = OmitNevers<
110
- _BaseEntityRecords.NavMenuItem< C >
111
- >;
110
+ export type NavMenuItem<
111
+ C extends Context = DefaultContextOf< 'root', 'menuItem' >
112
+ > = OmitNevers< _BaseEntityRecords.NavMenuItem< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, ContextualField, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -48,6 +49,5 @@ declare module './base-entity-records' {
48
49
  }
49
50
  }
50
51
 
51
- export type NavMenu< C extends Context > = OmitNevers<
52
- _BaseEntityRecords.NavMenu< C >
53
- >;
52
+ export type NavMenu< C extends Context = DefaultContextOf< 'root', 'menu' > > =
53
+ OmitNevers< _BaseEntityRecords.NavMenu< C > >;
@@ -12,6 +12,7 @@ import type {
12
12
  } from './helpers';
13
13
 
14
14
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
15
+ import type { DefaultContextOf } from './index';
15
16
 
16
17
  declare module './base-entity-records' {
17
18
  export namespace BaseEntityRecords {
@@ -139,6 +140,5 @@ declare module './base-entity-records' {
139
140
  }
140
141
  }
141
142
 
142
- export type Page< C extends Context > = OmitNevers<
143
- _BaseEntityRecords.Page< C >
144
- >;
143
+ export type Page< C extends Context = DefaultContextOf< 'postType', 'page' > > =
144
+ OmitNevers< _BaseEntityRecords.Page< C > >;
@@ -9,6 +9,7 @@ import type {
9
9
  } from './helpers';
10
10
 
11
11
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
12
+ import type { DefaultContextOf } from './index';
12
13
 
13
14
  declare module './base-entity-records' {
14
15
  export namespace BaseEntityRecords {
@@ -74,6 +75,5 @@ declare module './base-entity-records' {
74
75
  }
75
76
 
76
77
  export type PluginStatus = 'active' | 'inactive';
77
- export type Plugin< C extends Context > = OmitNevers<
78
- _BaseEntityRecords.Plugin< C >
79
- >;
78
+ export type Plugin< C extends Context = DefaultContextOf< 'root', 'plugin' > > =
79
+ OmitNevers< _BaseEntityRecords.Plugin< C > >;
@@ -13,6 +13,7 @@ import type {
13
13
  } from './helpers';
14
14
 
15
15
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
16
+ import type { DefaultContextOf } from './index';
16
17
 
17
18
  declare module './base-entity-records' {
18
19
  export namespace BaseEntityRecords {
@@ -148,6 +149,5 @@ declare module './base-entity-records' {
148
149
  }
149
150
  }
150
151
 
151
- export type Post< C extends Context > = OmitNevers<
152
- _BaseEntityRecords.Post< C >
153
- >;
152
+ export type Post< C extends Context = DefaultContextOf< 'postType', 'post' > > =
153
+ OmitNevers< _BaseEntityRecords.Post< C > >;
@@ -9,6 +9,7 @@ import type {
9
9
  } from './helpers';
10
10
 
11
11
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
12
+ import type { DefaultContextOf } from './index';
12
13
 
13
14
  declare module './base-entity-records' {
14
15
  export namespace BaseEntityRecords {
@@ -93,6 +94,5 @@ declare module './base-entity-records' {
93
94
  }
94
95
  }
95
96
 
96
- export type Settings< C extends Context > = OmitNevers<
97
- _BaseEntityRecords.Settings< C >
98
- >;
97
+ export type Settings< C extends Context = DefaultContextOf< 'root', 'site' > > =
98
+ OmitNevers< _BaseEntityRecords.Settings< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -54,6 +55,6 @@ declare module './base-entity-records' {
54
55
 
55
56
  type SidebarStatus = 'active' | 'inactive';
56
57
 
57
- export type Sidebar< C extends Context > = OmitNevers<
58
- _BaseEntityRecords.Sidebar< C >
59
- >;
58
+ export type Sidebar<
59
+ C extends Context = DefaultContextOf< 'root', 'sidebar' >
60
+ > = OmitNevers< _BaseEntityRecords.Sidebar< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, ContextualField, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -87,6 +88,6 @@ declare module './base-entity-records' {
87
88
  }
88
89
  }
89
90
 
90
- export type Taxonomy< C extends Context > = OmitNevers<
91
- _BaseEntityRecords.Taxonomy< C >
92
- >;
91
+ export type Taxonomy<
92
+ C extends Context = DefaultContextOf< 'postType', 'taxonomy' >
93
+ > = OmitNevers< _BaseEntityRecords.Taxonomy< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, PostFormat, RenderedText, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -217,6 +218,5 @@ declare module './base-entity-records' {
217
218
  }
218
219
  }
219
220
 
220
- export type Theme< C extends Context > = OmitNevers<
221
- _BaseEntityRecords.Theme< C >
222
- >;
221
+ export type Theme< C extends Context = DefaultContextOf< 'root', 'theme' > > =
222
+ OmitNevers< _BaseEntityRecords.Theme< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, ContextualField, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -75,6 +76,5 @@ declare module './base-entity-records' {
75
76
  }
76
77
  }
77
78
 
78
- export type Type< C extends Context > = OmitNevers<
79
- _BaseEntityRecords.Type< C >
80
- >;
79
+ export type Type< C extends Context = DefaultContextOf< 'root', 'postType' > > =
80
+ OmitNevers< _BaseEntityRecords.Type< C > >;
@@ -9,6 +9,7 @@ import type {
9
9
  } from './helpers';
10
10
 
11
11
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
12
+ import type { DefaultContextOf } from './index';
12
13
 
13
14
  declare module './base-entity-records' {
14
15
  export namespace BaseEntityRecords {
@@ -109,6 +110,5 @@ declare module './base-entity-records' {
109
110
  }
110
111
  }
111
112
 
112
- export type User< C extends Context > = OmitNevers<
113
- _BaseEntityRecords.User< C >
114
- >;
113
+ export type User< C extends Context = DefaultContextOf< 'root', 'user' > > =
114
+ OmitNevers< _BaseEntityRecords.User< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -32,6 +33,6 @@ declare module './base-entity-records' {
32
33
  }
33
34
  }
34
35
 
35
- export type WidgetType< C extends Context > = OmitNevers<
36
- _BaseEntityRecords.WidgetType< C >
37
- >;
36
+ export type WidgetType<
37
+ C extends Context = DefaultContextOf< 'root', 'widgetType' >
38
+ > = OmitNevers< _BaseEntityRecords.WidgetType< C > >;
@@ -4,6 +4,7 @@
4
4
  import type { Context, ContextualField, OmitNevers } from './helpers';
5
5
 
6
6
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
7
+ import type { DefaultContextOf } from './index';
7
8
 
8
9
  declare module './base-entity-records' {
9
10
  export namespace BaseEntityRecords {
@@ -59,6 +60,5 @@ declare module './base-entity-records' {
59
60
  }
60
61
  }
61
62
 
62
- export type Widget< C extends Context > = OmitNevers<
63
- _BaseEntityRecords.Widget< C >
64
- >;
63
+ export type Widget< C extends Context = DefaultContextOf< 'root', 'widget' > > =
64
+ OmitNevers< _BaseEntityRecords.Widget< C > >;
@@ -10,6 +10,7 @@ import type {
10
10
  } from './helpers';
11
11
 
12
12
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
13
+ import type { DefaultContextOf } from './index';
13
14
 
14
15
  declare module './base-entity-records' {
15
16
  export namespace BaseEntityRecords {
@@ -89,6 +90,6 @@ declare module './base-entity-records' {
89
90
  }
90
91
  }
91
92
 
92
- export type WpTemplatePart< C extends Context > = OmitNevers<
93
- _BaseEntityRecords.WpTemplatePart< C >
94
- >;
93
+ export type WpTemplatePart<
94
+ C extends Context = DefaultContextOf< 'postType', 'wp_template_part' >
95
+ > = OmitNevers< _BaseEntityRecords.WpTemplatePart< C > >;
@@ -10,6 +10,7 @@ import type {
10
10
  } from './helpers';
11
11
 
12
12
  import type { BaseEntityRecords as _BaseEntityRecords } from './base-entity-records';
13
+ import type { DefaultContextOf } from './index';
13
14
 
14
15
  declare module './base-entity-records' {
15
16
  export namespace BaseEntityRecords {
@@ -89,6 +90,6 @@ declare module './base-entity-records' {
89
90
  }
90
91
  }
91
92
 
92
- export type WpTemplate< C extends Context > = OmitNevers<
93
- _BaseEntityRecords.WpTemplate< C >
94
- >;
93
+ export type WpTemplate<
94
+ C extends Context = DefaultContextOf< 'postType', 'wp_template' >
95
+ > = OmitNevers< _BaseEntityRecords.WpTemplate< C > >;
@@ -175,8 +175,7 @@ describe( 'fetchLinkSuggestions', () => {
175
175
  {
176
176
  id: 54,
177
177
  title: 'Some Test Media Title',
178
- url:
179
- 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
178
+ url: 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
180
179
  type: 'attachment',
181
180
  kind: 'media',
182
181
  },
@@ -225,8 +224,7 @@ describe( 'fetchLinkSuggestions', () => {
225
224
  {
226
225
  id: 54,
227
226
  title: 'Some Test Media Title',
228
- url:
229
- 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
227
+ url: 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
230
228
  type: 'attachment',
231
229
  kind: 'media',
232
230
  },
@@ -145,8 +145,10 @@ describe( 'useQuerySelect', () => {
145
145
  } ),
146
146
  },
147
147
  resolvers: {
148
- getResolvedFoo: () => ( { dispatch } ) =>
149
- dispatch.receiveFoo( 5 ),
148
+ getResolvedFoo:
149
+ () =>
150
+ ( { dispatch } ) =>
151
+ dispatch.receiveFoo( 5 ),
150
152
  },
151
153
  selectors: {
152
154
  getResolvedFoo: ( state, arg ) => state.resolvedFoo + arg,
@@ -9,7 +9,6 @@ import deprecated from '@wordpress/deprecated';
9
9
  import useQuerySelect from './use-query-select';
10
10
  import { store as coreStore } from '../';
11
11
  import type { Status } from './constants';
12
- import useEntityRecords from './use-entity-records';
13
12
 
14
13
  export interface EntityRecordResolution< RecordType > {
15
14
  /** The requested entity record */