@wordpress/core-data 4.2.0-next.e230fbab09.0 → 4.3.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 (118) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +41 -8
  3. package/build/actions.js +61 -41
  4. package/build/actions.js.map +1 -1
  5. package/build/entities.js +36 -23
  6. package/build/entities.js.map +1 -1
  7. package/build/entity-provider.js +46 -44
  8. package/build/entity-provider.js.map +1 -1
  9. package/build/entity-types/{base-entity-types.js → base-entity-records.js} +9 -9
  10. package/build/entity-types/base-entity-records.js.map +1 -0
  11. package/build/fetch/__experimental-fetch-link-suggestions.js +1 -1
  12. package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  13. package/build/fetch/__experimental-fetch-url-data.js +1 -1
  14. package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
  15. package/build/hooks/use-entity-record.js +15 -5
  16. package/build/hooks/use-entity-record.js.map +1 -1
  17. package/build/hooks/use-entity-records.js +17 -5
  18. package/build/hooks/use-entity-records.js.map +1 -1
  19. package/build/index.js +9 -21
  20. package/build/index.js.map +1 -1
  21. package/build/queried-data/actions.js +4 -4
  22. package/build/queried-data/actions.js.map +1 -1
  23. package/build/queried-data/get-query-parts.js +7 -3
  24. package/build/queried-data/get-query-parts.js.map +1 -1
  25. package/build/queried-data/reducer.js +8 -6
  26. package/build/queried-data/reducer.js.map +1 -1
  27. package/build/reducer.js +16 -16
  28. package/build/reducer.js.map +1 -1
  29. package/build/resolvers.js +17 -23
  30. package/build/resolvers.js.map +1 -1
  31. package/build/selectors.js +92 -51
  32. package/build/selectors.js.map +1 -1
  33. package/build/utils/conservative-map-item.js +1 -1
  34. package/build/utils/conservative-map-item.js.map +1 -1
  35. package/build/utils/is-raw-attribute.js +1 -1
  36. package/build/utils/is-raw-attribute.js.map +1 -1
  37. package/build-module/actions.js +62 -42
  38. package/build-module/actions.js.map +1 -1
  39. package/build-module/entities.js +32 -19
  40. package/build-module/entities.js.map +1 -1
  41. package/build-module/entity-provider.js +47 -45
  42. package/build-module/entity-provider.js.map +1 -1
  43. package/build-module/entity-types/{base-entity-types.js → base-entity-records.js} +7 -7
  44. package/build-module/entity-types/base-entity-records.js.map +1 -0
  45. package/build-module/fetch/__experimental-fetch-link-suggestions.js +1 -1
  46. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  47. package/build-module/fetch/__experimental-fetch-url-data.js +1 -1
  48. package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
  49. package/build-module/hooks/use-entity-record.js +15 -5
  50. package/build-module/hooks/use-entity-record.js.map +1 -1
  51. package/build-module/hooks/use-entity-records.js +17 -5
  52. package/build-module/hooks/use-entity-records.js.map +1 -1
  53. package/build-module/index.js +10 -22
  54. package/build-module/index.js.map +1 -1
  55. package/build-module/queried-data/actions.js +4 -4
  56. package/build-module/queried-data/actions.js.map +1 -1
  57. package/build-module/queried-data/get-query-parts.js +7 -3
  58. package/build-module/queried-data/get-query-parts.js.map +1 -1
  59. package/build-module/queried-data/reducer.js +8 -6
  60. package/build-module/queried-data/reducer.js.map +1 -1
  61. package/build-module/reducer.js +17 -17
  62. package/build-module/reducer.js.map +1 -1
  63. package/build-module/resolvers.js +18 -24
  64. package/build-module/resolvers.js.map +1 -1
  65. package/build-module/selectors.js +88 -51
  66. package/build-module/selectors.js.map +1 -1
  67. package/build-module/utils/conservative-map-item.js +1 -1
  68. package/build-module/utils/conservative-map-item.js.map +1 -1
  69. package/build-module/utils/is-raw-attribute.js +1 -1
  70. package/build-module/utils/is-raw-attribute.js.map +1 -1
  71. package/package.json +11 -11
  72. package/src/actions.js +62 -42
  73. package/src/entities.js +43 -17
  74. package/src/entity-provider.js +50 -44
  75. package/src/entity-types/attachment.ts +5 -5
  76. package/src/entity-types/{base-entity-types.ts → base-entity-records.ts} +5 -5
  77. package/src/entity-types/comment.ts +5 -5
  78. package/src/entity-types/helpers.ts +1 -1
  79. package/src/entity-types/index.ts +4 -4
  80. package/src/entity-types/menu-location.ts +5 -5
  81. package/src/entity-types/nav-menu-item.ts +10 -5
  82. package/src/entity-types/nav-menu.ts +5 -5
  83. package/src/entity-types/navigation-area.ts +5 -5
  84. package/src/entity-types/page.ts +5 -5
  85. package/src/entity-types/plugin.ts +10 -5
  86. package/src/entity-types/post.ts +5 -5
  87. package/src/entity-types/settings.ts +10 -5
  88. package/src/entity-types/sidebar.ts +6 -7
  89. package/src/entity-types/taxonomy.ts +5 -5
  90. package/src/entity-types/theme.ts +5 -5
  91. package/src/entity-types/type.ts +5 -5
  92. package/src/entity-types/user.ts +10 -5
  93. package/src/entity-types/widget-type.ts +5 -5
  94. package/src/entity-types/widget.ts +5 -5
  95. package/src/entity-types/wp-template-part.ts +5 -5
  96. package/src/entity-types/wp-template.ts +5 -5
  97. package/src/fetch/__experimental-fetch-link-suggestions.js +1 -1
  98. package/src/fetch/__experimental-fetch-url-data.js +1 -0
  99. package/src/hooks/use-entity-record.ts +19 -8
  100. package/src/hooks/use-entity-records.ts +26 -9
  101. package/src/index.js +10 -15
  102. package/src/locks/test/selectors.js +4 -4
  103. package/src/queried-data/actions.js +4 -4
  104. package/src/queried-data/get-query-parts.js +5 -5
  105. package/src/queried-data/reducer.js +6 -6
  106. package/src/reducer.js +17 -17
  107. package/src/resolvers.js +25 -30
  108. package/src/selectors.js +92 -53
  109. package/src/test/actions.js +138 -33
  110. package/src/test/entities.js +11 -11
  111. package/src/test/reducer.js +4 -4
  112. package/src/test/resolvers.js +5 -5
  113. package/src/test/selectors.js +22 -22
  114. package/src/utils/conservative-map-item.js +1 -1
  115. package/src/utils/is-raw-attribute.js +1 -1
  116. package/src/utils/test/is-raw-attribute.js +4 -4
  117. package/build/entity-types/base-entity-types.js.map +0 -1
  118. package/build-module/entity-types/base-entity-types.js.map +0 -1
package/src/reducer.js CHANGED
@@ -14,7 +14,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
14
14
  */
15
15
  import { ifMatchingAction, replaceAction } from './utils';
16
16
  import { reducer as queriedDataReducer } from './queried-data';
17
- import { defaultEntities, DEFAULT_ENTITY_KEY } from './entities';
17
+ import { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
18
18
 
19
19
  /**
20
20
  * Reducer managing terms state. Keyed by taxonomy slug, the value is either
@@ -105,10 +105,10 @@ export function taxonomies( state = [], action ) {
105
105
  /**
106
106
  * Reducer managing the current theme.
107
107
  *
108
- * @param {string} state Current state.
109
- * @param {Object} action Dispatched action.
108
+ * @param {string|undefined} state Current state.
109
+ * @param {Object} action Dispatched action.
110
110
  *
111
- * @return {string} Updated state.
111
+ * @return {string|undefined} Updated state.
112
112
  */
113
113
  export function currentTheme( state = undefined, action ) {
114
114
  switch ( action.type ) {
@@ -122,10 +122,10 @@ export function currentTheme( state = undefined, action ) {
122
122
  /**
123
123
  * Reducer managing the current global styles id.
124
124
  *
125
- * @param {string} state Current state.
126
- * @param {Object} action Dispatched action.
125
+ * @param {string|undefined} state Current state.
126
+ * @param {Object} action Dispatched action.
127
127
  *
128
- * @return {string} Updated state.
128
+ * @return {string|undefined} Updated state.
129
129
  */
130
130
  export function currentGlobalStylesId( state = undefined, action ) {
131
131
  switch ( action.type ) {
@@ -139,10 +139,10 @@ export function currentGlobalStylesId( state = undefined, action ) {
139
139
  /**
140
140
  * Reducer managing the theme base global styles.
141
141
  *
142
- * @param {string} state Current state.
143
- * @param {Object} action Dispatched action.
142
+ * @param {Record<string, object>} state Current state.
143
+ * @param {Object} action Dispatched action.
144
144
  *
145
- * @return {string} Updated state.
145
+ * @return {Record<string, object>} Updated state.
146
146
  */
147
147
  export function themeBaseGlobalStyles( state = {}, action ) {
148
148
  switch ( action.type ) {
@@ -159,10 +159,10 @@ export function themeBaseGlobalStyles( state = {}, action ) {
159
159
  /**
160
160
  * Reducer managing the theme global styles variations.
161
161
  *
162
- * @param {string} state Current state.
163
- * @param {Object} action Dispatched action.
162
+ * @param {Record<string, object>} state Current state.
163
+ * @param {Object} action Dispatched action.
164
164
  *
165
- * @return {string} Updated state.
165
+ * @return {Record<string, object>} Updated state.
166
166
  */
167
167
  export function themeGlobalStyleVariations( state = {}, action ) {
168
168
  switch ( action.type ) {
@@ -335,7 +335,7 @@ function entity( entityConfig ) {
335
335
  *
336
336
  * @return {Object} Updated state.
337
337
  */
338
- export function entitiesConfig( state = defaultEntities, action ) {
338
+ export function entitiesConfig( state = rootEntitiesConfig, action ) {
339
339
  switch ( action.type ) {
340
340
  case 'ADD_ENTITIES':
341
341
  return [ ...state, ...action.entities ];
@@ -380,10 +380,10 @@ export const entities = ( state = {}, action ) => {
380
380
  );
381
381
  }
382
382
 
383
- const newData = entitiesDataReducer( state.data, action );
383
+ const newData = entitiesDataReducer( state.records, action );
384
384
 
385
385
  if (
386
- newData === state.data &&
386
+ newData === state.records &&
387
387
  newConfig === state.config &&
388
388
  entitiesDataReducer === state.reducer
389
389
  ) {
@@ -392,7 +392,7 @@ export const entities = ( state = {}, action ) => {
392
392
 
393
393
  return {
394
394
  reducer: entitiesDataReducer,
395
- data: newData,
395
+ records: newData,
396
396
  config: newConfig,
397
397
  };
398
398
  };
package/src/resolvers.js CHANGED
@@ -13,7 +13,7 @@ import apiFetch from '@wordpress/api-fetch';
13
13
  * Internal dependencies
14
14
  */
15
15
  import { STORE_NAME } from './name';
16
- import { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';
16
+ import { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
17
17
  import { forwardResolver, getNormalizedCommaSeparable } from './utils';
18
18
 
19
19
  /**
@@ -52,15 +52,15 @@ export const getEntityRecord = ( kind, name, key = '', query ) => async ( {
52
52
  select,
53
53
  dispatch,
54
54
  } ) => {
55
- const entities = await dispatch( getKindEntities( kind ) );
56
- const entity = find( entities, { kind, name } );
57
- if ( ! entity || entity?.__experimentalNoFetch ) {
55
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
56
+ const entityConfig = find( configs, { kind, name } );
57
+ if ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {
58
58
  return;
59
59
  }
60
60
 
61
61
  const lock = await dispatch.__unstableAcquireStoreLock(
62
62
  STORE_NAME,
63
- [ 'entities', 'data', kind, name, key ],
63
+ [ 'entities', 'records', kind, name, key ],
64
64
  { exclusive: false }
65
65
  );
66
66
 
@@ -73,7 +73,7 @@ export const getEntityRecord = ( kind, name, key = '', query ) => async ( {
73
73
  ...query,
74
74
  _fields: uniq( [
75
75
  ...( getNormalizedCommaSeparable( query._fields ) || [] ),
76
- entity.key || DEFAULT_ENTITY_KEY,
76
+ entityConfig.key || DEFAULT_ENTITY_KEY,
77
77
  ] ).join(),
78
78
  };
79
79
  }
@@ -85,10 +85,13 @@ export const getEntityRecord = ( kind, name, key = '', query ) => async ( {
85
85
  // for how the request is made to the REST API.
86
86
 
87
87
  // eslint-disable-next-line @wordpress/no-unused-vars-before-return
88
- const path = addQueryArgs( entity.baseURL + ( key ? '/' + key : '' ), {
89
- ...entity.baseURLParams,
90
- ...query,
91
- } );
88
+ const path = addQueryArgs(
89
+ entityConfig.baseURL + ( key ? '/' + key : '' ),
90
+ {
91
+ ...entityConfig.baseURLParams,
92
+ ...query,
93
+ }
94
+ );
92
95
 
93
96
  if ( query !== undefined ) {
94
97
  query = { ...query, include: [ key ] };
@@ -104,10 +107,6 @@ export const getEntityRecord = ( kind, name, key = '', query ) => async ( {
104
107
 
105
108
  const record = await apiFetch( { path } );
106
109
  dispatch.receiveEntityRecords( kind, name, record, query );
107
- } catch ( error ) {
108
- // We need a way to handle and access REST API errors in state
109
- // Until then, catching the error ensures the resolver is marked as resolved.
110
- // See similar implementation in `getEntityRecords()`.
111
110
  } finally {
112
111
  dispatch.__unstableReleaseStoreLock( lock );
113
112
  }
@@ -133,15 +132,15 @@ export const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );
133
132
  export const getEntityRecords = ( kind, name, query = {} ) => async ( {
134
133
  dispatch,
135
134
  } ) => {
136
- const entities = await dispatch( getKindEntities( kind ) );
137
- const entity = find( entities, { kind, name } );
138
- if ( ! entity || entity?.__experimentalNoFetch ) {
135
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
136
+ const entityConfig = find( configs, { kind, name } );
137
+ if ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {
139
138
  return;
140
139
  }
141
140
 
142
141
  const lock = await dispatch.__unstableAcquireStoreLock(
143
142
  STORE_NAME,
144
- [ 'entities', 'data', kind, name ],
143
+ [ 'entities', 'records', kind, name ],
145
144
  { exclusive: false }
146
145
  );
147
146
 
@@ -154,13 +153,13 @@ export const getEntityRecords = ( kind, name, query = {} ) => async ( {
154
153
  ...query,
155
154
  _fields: uniq( [
156
155
  ...( getNormalizedCommaSeparable( query._fields ) || [] ),
157
- entity.key || DEFAULT_ENTITY_KEY,
156
+ entityConfig.key || DEFAULT_ENTITY_KEY,
158
157
  ] ).join(),
159
158
  };
160
159
  }
161
160
 
162
- const path = addQueryArgs( entity.baseURL, {
163
- ...entity.baseURLParams,
161
+ const path = addQueryArgs( entityConfig.baseURL, {
162
+ ...entityConfig.baseURLParams,
164
163
  ...query,
165
164
  } );
166
165
 
@@ -186,7 +185,7 @@ export const getEntityRecords = ( kind, name, query = {} ) => async ( {
186
185
  // resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
187
186
  // See https://github.com/WordPress/gutenberg/pull/26575
188
187
  if ( ! query?._fields && ! query.context ) {
189
- const key = entity.key || DEFAULT_ENTITY_KEY;
188
+ const key = entityConfig.key || DEFAULT_ENTITY_KEY;
190
189
  const resolutionsArgs = records
191
190
  .filter( ( record ) => record[ key ] )
192
191
  .map( ( record ) => [ kind, name, record[ key ] ] );
@@ -202,10 +201,6 @@ export const getEntityRecords = ( kind, name, query = {} ) => async ( {
202
201
  args: resolutionsArgs,
203
202
  } );
204
203
  }
205
- } catch ( error ) {
206
- // We need a way to handle and access REST API errors in state
207
- // Until then, catching the error ensures the resolver is marked as resolved.
208
- // See similar implementation in `getEntityRecord()`.
209
204
  } finally {
210
205
  dispatch.__unstableReleaseStoreLock( lock );
211
206
  }
@@ -312,13 +307,13 @@ export const canUser = ( action, resource, id ) => async ( { dispatch } ) => {
312
307
  export const canUserEditEntityRecord = ( kind, name, recordId ) => async ( {
313
308
  dispatch,
314
309
  } ) => {
315
- const entities = await dispatch( getKindEntities( kind ) );
316
- const entity = find( entities, { kind, name } );
317
- if ( ! entity ) {
310
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
311
+ const entityConfig = find( configs, { kind, name } );
312
+ if ( ! entityConfig ) {
318
313
  return;
319
314
  }
320
315
 
321
- const resource = entity.__unstable_rest_base;
316
+ const resource = entityConfig.__unstable_rest_base;
322
317
  await dispatch( canUser( 'update', resource, recordId ) );
323
318
  };
324
319
 
package/src/selectors.js CHANGED
@@ -95,27 +95,62 @@ export const getUserQueryResults = createSelector(
95
95
  );
96
96
 
97
97
  /**
98
- * Returns whether the entities for the give kind are loaded.
98
+ * Returns the loaded entities for the given kind.
99
99
  *
100
+ * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
100
101
  * @param {Object} state Data state.
101
102
  * @param {string} kind Entity kind.
102
103
  *
103
104
  * @return {Array<Object>} Array of entities with config matching kind.
104
105
  */
105
106
  export function getEntitiesByKind( state, kind ) {
107
+ deprecated( "wp.data.select( 'core' ).getEntitiesByKind()", {
108
+ since: '6.0',
109
+ alternative: "wp.data.select( 'core' ).getEntitiesConfig()",
110
+ } );
111
+ return getEntitiesConfig( state, kind );
112
+ }
113
+
114
+ /**
115
+ * Returns the loaded entities for the given kind.
116
+ *
117
+ * @param {Object} state Data state.
118
+ * @param {string} kind Entity kind.
119
+ *
120
+ * @return {Array<Object>} Array of entities with config matching kind.
121
+ */
122
+ export function getEntitiesConfig( state, kind ) {
106
123
  return filter( state.entities.config, { kind } );
107
124
  }
108
125
 
109
126
  /**
110
- * Returns the entity object given its kind and name.
127
+ * Returns the entity config given its kind and name.
111
128
  *
129
+ * @deprecated since WordPress 6.0. Use getEntityConfig instead
112
130
  * @param {Object} state Data state.
113
131
  * @param {string} kind Entity kind.
114
132
  * @param {string} name Entity name.
115
133
  *
116
- * @return {Object} Entity
134
+ * @return {Object} Entity config
117
135
  */
118
136
  export function getEntity( state, kind, name ) {
137
+ deprecated( "wp.data.select( 'core' ).getEntity()", {
138
+ since: '6.0',
139
+ alternative: "wp.data.select( 'core' ).getEntityConfig()",
140
+ } );
141
+ return getEntityConfig( state, kind, name );
142
+ }
143
+
144
+ /**
145
+ * Returns the entity config given its kind and name.
146
+ *
147
+ * @param {Object} state Data state.
148
+ * @param {string} kind Entity kind.
149
+ * @param {string} name Entity name.
150
+ *
151
+ * @return {Object} Entity config
152
+ */
153
+ export function getEntityConfig( state, kind, name ) {
119
154
  return find( state.entities.config, { kind, name } );
120
155
  }
121
156
 
@@ -130,11 +165,11 @@ export function getEntity( state, kind, name ) {
130
165
  * @param {number} key Record's key
131
166
  * @param {?Object} query Optional query.
132
167
  *
133
- * @return {Object?} Record.
168
+ * @return {Object|undefined} Record.
134
169
  */
135
170
  export const getEntityRecord = createSelector(
136
171
  ( state, kind, name, key, query ) => {
137
- const queriedState = get( state.entities.data, [
172
+ const queriedState = get( state.entities.records, [
138
173
  kind,
139
174
  name,
140
175
  'queriedData',
@@ -156,7 +191,7 @@ export const getEntityRecord = createSelector(
156
191
  const item = queriedState.items[ context ]?.[ key ];
157
192
  if ( item && query._fields ) {
158
193
  const filteredItem = {};
159
- const fields = getNormalizedCommaSeparable( query._fields );
194
+ const fields = getNormalizedCommaSeparable( query._fields ) ?? [];
160
195
  for ( let f = 0; f < fields.length; f++ ) {
161
196
  const field = fields[ f ].split( '.' );
162
197
  const value = get( item, field );
@@ -170,7 +205,7 @@ export const getEntityRecord = createSelector(
170
205
  ( state, kind, name, recordId, query ) => {
171
206
  const context = query?.context ?? 'default';
172
207
  return [
173
- get( state.entities.data, [
208
+ get( state.entities.records, [
174
209
  kind,
175
210
  name,
176
211
  'queriedData',
@@ -178,7 +213,7 @@ export const getEntityRecord = createSelector(
178
213
  context,
179
214
  recordId,
180
215
  ] ),
181
- get( state.entities.data, [
216
+ get( state.entities.records, [
182
217
  kind,
183
218
  name,
184
219
  'queriedData',
@@ -191,7 +226,7 @@ export const getEntityRecord = createSelector(
191
226
  );
192
227
 
193
228
  /**
194
- * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity from the API if the entity record isn't available in the local state.
229
+ * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
195
230
  *
196
231
  * @param {Object} state State tree
197
232
  * @param {string} kind Entity kind.
@@ -226,7 +261,9 @@ export const getRawEntityRecord = createSelector(
226
261
  return (
227
262
  record &&
228
263
  Object.keys( record ).reduce( ( accumulator, _key ) => {
229
- if ( isRawAttribute( getEntity( state, kind, name ), _key ) ) {
264
+ if (
265
+ isRawAttribute( getEntityConfig( state, kind, name ), _key )
266
+ ) {
230
267
  // Because edits are the "raw" attribute values,
231
268
  // we return those from record selectors to make rendering,
232
269
  // comparisons, and joins with edits easier.
@@ -246,7 +283,7 @@ export const getRawEntityRecord = createSelector(
246
283
  const context = query?.context ?? 'default';
247
284
  return [
248
285
  state.entities.config,
249
- get( state.entities.data, [
286
+ get( state.entities.records, [
250
287
  kind,
251
288
  name,
252
289
  'queriedData',
@@ -254,7 +291,7 @@ export const getRawEntityRecord = createSelector(
254
291
  context,
255
292
  recordId,
256
293
  ] ),
257
- get( state.entities.data, [
294
+ get( state.entities.records, [
258
295
  kind,
259
296
  name,
260
297
  'queriedData',
@@ -294,7 +331,7 @@ export function hasEntityRecords( state, kind, name, query ) {
294
331
  export function getEntityRecords( state, kind, name, query ) {
295
332
  // Queried data state is prepopulated for all known entities. If this is not
296
333
  // assigned for the given parameters, then it is known to not exist.
297
- const queriedState = get( state.entities.data, [
334
+ const queriedState = get( state.entities.records, [
298
335
  kind,
299
336
  name,
300
337
  'queriedData',
@@ -315,13 +352,13 @@ export function getEntityRecords( state, kind, name, query ) {
315
352
  export const __experimentalGetDirtyEntityRecords = createSelector(
316
353
  ( state ) => {
317
354
  const {
318
- entities: { data },
355
+ entities: { records },
319
356
  } = state;
320
357
  const dirtyRecords = [];
321
- Object.keys( data ).forEach( ( kind ) => {
322
- Object.keys( data[ kind ] ).forEach( ( name ) => {
358
+ Object.keys( records ).forEach( ( kind ) => {
359
+ Object.keys( records[ kind ] ).forEach( ( name ) => {
323
360
  const primaryKeys = Object.keys(
324
- data[ kind ][ name ].edits
361
+ records[ kind ][ name ].edits
325
362
  ).filter(
326
363
  ( primaryKey ) =>
327
364
  // The entity record must exist (not be deleted),
@@ -331,7 +368,7 @@ export const __experimentalGetDirtyEntityRecords = createSelector(
331
368
  );
332
369
 
333
370
  if ( primaryKeys.length ) {
334
- const entity = getEntity( state, kind, name );
371
+ const entityConfig = getEntityConfig( state, kind, name );
335
372
  primaryKeys.forEach( ( primaryKey ) => {
336
373
  const entityRecord = getEditedEntityRecord(
337
374
  state,
@@ -344,9 +381,10 @@ export const __experimentalGetDirtyEntityRecords = createSelector(
344
381
  // when it's used as an object key.
345
382
  key:
346
383
  entityRecord[
347
- entity.key || DEFAULT_ENTITY_KEY
384
+ entityConfig.key || DEFAULT_ENTITY_KEY
348
385
  ],
349
- title: entity?.getTitle?.( entityRecord ) || '',
386
+ title:
387
+ entityConfig?.getTitle?.( entityRecord ) || '',
350
388
  name,
351
389
  kind,
352
390
  } );
@@ -357,7 +395,7 @@ export const __experimentalGetDirtyEntityRecords = createSelector(
357
395
 
358
396
  return dirtyRecords;
359
397
  },
360
- ( state ) => [ state.entities.data ]
398
+ ( state ) => [ state.entities.records ]
361
399
  );
362
400
 
363
401
  /**
@@ -370,19 +408,19 @@ export const __experimentalGetDirtyEntityRecords = createSelector(
370
408
  export const __experimentalGetEntitiesBeingSaved = createSelector(
371
409
  ( state ) => {
372
410
  const {
373
- entities: { data },
411
+ entities: { records },
374
412
  } = state;
375
413
  const recordsBeingSaved = [];
376
- Object.keys( data ).forEach( ( kind ) => {
377
- Object.keys( data[ kind ] ).forEach( ( name ) => {
414
+ Object.keys( records ).forEach( ( kind ) => {
415
+ Object.keys( records[ kind ] ).forEach( ( name ) => {
378
416
  const primaryKeys = Object.keys(
379
- data[ kind ][ name ].saving
417
+ records[ kind ][ name ].saving
380
418
  ).filter( ( primaryKey ) =>
381
419
  isSavingEntityRecord( state, kind, name, primaryKey )
382
420
  );
383
421
 
384
422
  if ( primaryKeys.length ) {
385
- const entity = getEntity( state, kind, name );
423
+ const entityConfig = getEntityConfig( state, kind, name );
386
424
  primaryKeys.forEach( ( primaryKey ) => {
387
425
  const entityRecord = getEditedEntityRecord(
388
426
  state,
@@ -395,9 +433,10 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(
395
433
  // when it's used as an object key.
396
434
  key:
397
435
  entityRecord[
398
- entity.key || DEFAULT_ENTITY_KEY
436
+ entityConfig.key || DEFAULT_ENTITY_KEY
399
437
  ],
400
- title: entity?.getTitle?.( entityRecord ) || '',
438
+ title:
439
+ entityConfig?.getTitle?.( entityRecord ) || '',
401
440
  name,
402
441
  kind,
403
442
  } );
@@ -407,7 +446,7 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(
407
446
  } );
408
447
  return recordsBeingSaved;
409
448
  },
410
- ( state ) => [ state.entities.data ]
449
+ ( state ) => [ state.entities.records ]
411
450
  );
412
451
 
413
452
  /**
@@ -421,7 +460,7 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(
421
460
  * @return {Object?} The entity record's edits.
422
461
  */
423
462
  export function getEntityRecordEdits( state, kind, name, recordId ) {
424
- return get( state.entities.data, [ kind, name, 'edits', recordId ] );
463
+ return get( state.entities.records, [ kind, name, 'edits', recordId ] );
425
464
  }
426
465
 
427
466
  /**
@@ -440,7 +479,7 @@ export function getEntityRecordEdits( state, kind, name, recordId ) {
440
479
  */
441
480
  export const getEntityRecordNonTransientEdits = createSelector(
442
481
  ( state, kind, name, recordId ) => {
443
- const { transientEdits } = getEntity( state, kind, name ) || {};
482
+ const { transientEdits } = getEntityConfig( state, kind, name ) || {};
444
483
  const edits = getEntityRecordEdits( state, kind, name, recordId ) || {};
445
484
  if ( ! transientEdits ) {
446
485
  return edits;
@@ -454,7 +493,7 @@ export const getEntityRecordNonTransientEdits = createSelector(
454
493
  },
455
494
  ( state, kind, name, recordId ) => [
456
495
  state.entities.config,
457
- get( state.entities.data, [ kind, name, 'edits', recordId ] ),
496
+ get( state.entities.records, [ kind, name, 'edits', recordId ] ),
458
497
  ]
459
498
  );
460
499
 
@@ -481,10 +520,10 @@ export function hasEditsForEntityRecord( state, kind, name, recordId ) {
481
520
  /**
482
521
  * Returns the specified entity record, merged with its edits.
483
522
  *
484
- * @param {Object} state State tree.
485
- * @param {string} kind Entity kind.
486
- * @param {string} name Entity name.
487
- * @param {number} recordId Record ID.
523
+ * @param {Object} state State tree.
524
+ * @param {string} kind Entity kind.
525
+ * @param {string} name Entity name.
526
+ * @param {number|string} recordId Record ID.
488
527
  *
489
528
  * @return {Object?} The entity record, merged with its edits.
490
529
  */
@@ -497,7 +536,7 @@ export const getEditedEntityRecord = createSelector(
497
536
  const context = query?.context ?? 'default';
498
537
  return [
499
538
  state.entities.config,
500
- get( state.entities.data, [
539
+ get( state.entities.records, [
501
540
  kind,
502
541
  name,
503
542
  'queriedData',
@@ -505,7 +544,7 @@ export const getEditedEntityRecord = createSelector(
505
544
  context,
506
545
  recordId,
507
546
  ] ),
508
- get( state.entities.data, [
547
+ get( state.entities.records, [
509
548
  kind,
510
549
  name,
511
550
  'queriedData',
@@ -513,7 +552,7 @@ export const getEditedEntityRecord = createSelector(
513
552
  context,
514
553
  recordId,
515
554
  ] ),
516
- get( state.entities.data, [ kind, name, 'edits', recordId ] ),
555
+ get( state.entities.records, [ kind, name, 'edits', recordId ] ),
517
556
  ];
518
557
  }
519
558
  );
@@ -530,7 +569,7 @@ export const getEditedEntityRecord = createSelector(
530
569
  */
531
570
  export function isAutosavingEntityRecord( state, kind, name, recordId ) {
532
571
  const { pending, isAutosave } = get(
533
- state.entities.data,
572
+ state.entities.records,
534
573
  [ kind, name, 'saving', recordId ],
535
574
  {}
536
575
  );
@@ -540,16 +579,16 @@ export function isAutosavingEntityRecord( state, kind, name, recordId ) {
540
579
  /**
541
580
  * Returns true if the specified entity record is saving, and false otherwise.
542
581
  *
543
- * @param {Object} state State tree.
544
- * @param {string} kind Entity kind.
545
- * @param {string} name Entity name.
546
- * @param {number} recordId Record ID.
582
+ * @param {Object} state State tree.
583
+ * @param {string} kind Entity kind.
584
+ * @param {string} name Entity name.
585
+ * @param {number|string} recordId Record ID.
547
586
  *
548
587
  * @return {boolean} Whether the entity record is saving or not.
549
588
  */
550
589
  export function isSavingEntityRecord( state, kind, name, recordId ) {
551
590
  return get(
552
- state.entities.data,
591
+ state.entities.records,
553
592
  [ kind, name, 'saving', recordId, 'pending' ],
554
593
  false
555
594
  );
@@ -567,7 +606,7 @@ export function isSavingEntityRecord( state, kind, name, recordId ) {
567
606
  */
568
607
  export function isDeletingEntityRecord( state, kind, name, recordId ) {
569
608
  return get(
570
- state.entities.data,
609
+ state.entities.records,
571
610
  [ kind, name, 'deleting', recordId, 'pending' ],
572
611
  false
573
612
  );
@@ -584,7 +623,7 @@ export function isDeletingEntityRecord( state, kind, name, recordId ) {
584
623
  * @return {Object?} The entity record's save error.
585
624
  */
586
625
  export function getLastEntitySaveError( state, kind, name, recordId ) {
587
- return get( state.entities.data, [
626
+ return get( state.entities.records, [
588
627
  kind,
589
628
  name,
590
629
  'saving',
@@ -604,7 +643,7 @@ export function getLastEntitySaveError( state, kind, name, recordId ) {
604
643
  * @return {Object?} The entity record's save error.
605
644
  */
606
645
  export function getLastEntityDeleteError( state, kind, name, recordId ) {
607
- return get( state.entities.data, [
646
+ return get( state.entities.records, [
608
647
  kind,
609
648
  name,
610
649
  'deleting',
@@ -780,11 +819,11 @@ export function canUser( state, action, resource, id ) {
780
819
  * or `undefined` if the OPTIONS request is still being made.
781
820
  */
782
821
  export function canUserEditEntityRecord( state, kind, name, recordId ) {
783
- const entity = getEntity( state, kind, name );
784
- if ( ! entity ) {
822
+ const entityConfig = getEntityConfig( state, kind, name );
823
+ if ( ! entityConfig ) {
785
824
  return false;
786
825
  }
787
- const resource = entity.__unstable_rest_base;
826
+ const resource = entityConfig.__unstable_rest_base;
788
827
 
789
828
  return canUser( state, 'update', resource, recordId );
790
829
  }
@@ -899,7 +938,7 @@ export function __experimentalGetTemplateForLink( state, link ) {
899
938
  *
900
939
  * @param {Object} state Editor state.
901
940
  *
902
- * @return {Object?} The Global Styles object.
941
+ * @return {Object|null} The Global Styles object.
903
942
  */
904
943
  export function __experimentalGetCurrentThemeBaseGlobalStyles( state ) {
905
944
  const currentTheme = getCurrentTheme( state );
@@ -914,7 +953,7 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles( state ) {
914
953
  *
915
954
  * @param {Object} state Data state.
916
955
  *
917
- * @return {string} The current global styles ID.
956
+ * @return {string|null} The current global styles ID.
918
957
  */
919
958
  export function __experimentalGetCurrentThemeGlobalStylesVariations( state ) {
920
959
  const currentTheme = getCurrentTheme( state );