@wordpress/core-data 6.3.3 → 6.5.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 (55) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/actions.js +6 -6
  4. package/build/actions.js.map +1 -1
  5. package/build/entities.js +7 -7
  6. package/build/entities.js.map +1 -1
  7. package/build/hooks/use-entity-record.js +4 -4
  8. package/build/hooks/use-entity-record.js.map +1 -1
  9. package/build/hooks/use-entity-records.js +4 -4
  10. package/build/hooks/use-entity-records.js.map +1 -1
  11. package/build/hooks/use-resource-permissions.js +2 -2
  12. package/build/hooks/use-resource-permissions.js.map +1 -1
  13. package/build/queried-data/selectors.js +4 -1
  14. package/build/queried-data/selectors.js.map +1 -1
  15. package/build/reducer.js +3 -1
  16. package/build/reducer.js.map +1 -1
  17. package/build/selectors.js +158 -135
  18. package/build/selectors.js.map +1 -1
  19. package/build-module/actions.js +6 -6
  20. package/build-module/actions.js.map +1 -1
  21. package/build-module/entities.js +7 -6
  22. package/build-module/entities.js.map +1 -1
  23. package/build-module/hooks/use-entity-record.js +4 -4
  24. package/build-module/hooks/use-entity-record.js.map +1 -1
  25. package/build-module/hooks/use-entity-records.js +4 -4
  26. package/build-module/hooks/use-entity-records.js.map +1 -1
  27. package/build-module/hooks/use-resource-permissions.js +2 -2
  28. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  29. package/build-module/queried-data/selectors.js +5 -2
  30. package/build-module/queried-data/selectors.js.map +1 -1
  31. package/build-module/reducer.js +4 -2
  32. package/build-module/reducer.js.map +1 -1
  33. package/build-module/selectors.js +159 -136
  34. package/build-module/selectors.js.map +1 -1
  35. package/build-types/actions.d.ts +1 -1
  36. package/build-types/actions.d.ts.map +1 -1
  37. package/build-types/entities.d.ts.map +1 -1
  38. package/build-types/hooks/use-entity-record.d.ts +4 -4
  39. package/build-types/hooks/use-entity-records.d.ts +4 -4
  40. package/build-types/hooks/use-resource-permissions.d.ts +2 -2
  41. package/build-types/index.d.ts +1 -1
  42. package/build-types/queried-data/selectors.d.ts.map +1 -1
  43. package/build-types/reducer.d.ts.map +1 -1
  44. package/build-types/selectors.d.ts +130 -117
  45. package/build-types/selectors.d.ts.map +1 -1
  46. package/package.json +12 -12
  47. package/src/actions.js +6 -6
  48. package/src/entities.js +1 -2
  49. package/src/hooks/use-entity-record.ts +4 -4
  50. package/src/hooks/use-entity-records.ts +4 -4
  51. package/src/hooks/use-resource-permissions.ts +2 -2
  52. package/src/queried-data/selectors.js +5 -2
  53. package/src/reducer.js +2 -6
  54. package/src/selectors.ts +174 -218
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { set, get } from 'lodash';
5
+ import { set } from 'lodash';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
@@ -31,8 +31,8 @@ const EMPTY_OBJECT = {};
31
31
  * Returns true if a request is in progress for embed preview data, or false
32
32
  * otherwise.
33
33
  *
34
- * @param state Data state.
35
- * @param url URL the preview would be for.
34
+ * @param state Data state.
35
+ * @param url URL the preview would be for.
36
36
  *
37
37
  * @return Whether a request is in progress for an embed preview.
38
38
  */
@@ -45,9 +45,9 @@ export const isRequestingEmbedPreview = createRegistrySelector(select => (state,
45
45
  *
46
46
  * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
47
47
  *
48
- * @param state Data state.
49
- * @param query Optional object of query parameters to
50
- * include with request.
48
+ * @param state Data state.
49
+ * @param query Optional object of query parameters to
50
+ * include with request.
51
51
  * @return Authors list.
52
52
  */
53
53
 
@@ -62,7 +62,7 @@ export function getAuthors(state, query) {
62
62
  /**
63
63
  * Returns the current user.
64
64
  *
65
- * @param state Data state.
65
+ * @param state Data state.
66
66
  *
67
67
  * @return Current user object.
68
68
  */
@@ -73,8 +73,8 @@ export function getCurrentUser(state) {
73
73
  /**
74
74
  * Returns all the users returned by a query ID.
75
75
  *
76
- * @param state Data state.
77
- * @param queryID Query ID.
76
+ * @param state Data state.
77
+ * @param queryID Query ID.
78
78
  *
79
79
  * @return Users list.
80
80
  */
@@ -89,8 +89,8 @@ export const getUserQueryResults = createSelector((state, queryID) => {
89
89
  * Returns the loaded entities for the given kind.
90
90
  *
91
91
  * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
92
- * @param state Data state.
93
- * @param kind Entity kind.
92
+ * @param state Data state.
93
+ * @param kind Entity kind.
94
94
  *
95
95
  * @return Array of entities with config matching kind.
96
96
  */
@@ -105,8 +105,8 @@ export function getEntitiesByKind(state, kind) {
105
105
  /**
106
106
  * Returns the loaded entities for the given kind.
107
107
  *
108
- * @param state Data state.
109
- * @param kind Entity kind.
108
+ * @param state Data state.
109
+ * @param kind Entity kind.
110
110
  *
111
111
  * @return Array of entities with config matching kind.
112
112
  */
@@ -118,9 +118,9 @@ export function getEntitiesConfig(state, kind) {
118
118
  * Returns the entity config given its kind and name.
119
119
  *
120
120
  * @deprecated since WordPress 6.0. Use getEntityConfig instead
121
- * @param state Data state.
122
- * @param kind Entity kind.
123
- * @param name Entity name.
121
+ * @param state Data state.
122
+ * @param kind Entity kind.
123
+ * @param name Entity name.
124
124
  *
125
125
  * @return Entity config
126
126
  */
@@ -135,9 +135,9 @@ export function getEntity(state, kind, name) {
135
135
  /**
136
136
  * Returns the entity config given its kind and name.
137
137
  *
138
- * @param state Data state.
139
- * @param kind Entity kind.
140
- * @param name Entity name.
138
+ * @param state Data state.
139
+ * @param kind Entity kind.
140
+ * @param name Entity name.
141
141
  *
142
142
  * @return Entity config
143
143
  */
@@ -177,19 +177,19 @@ export function getEntityConfig(state, kind, name) {
177
177
  * yet received, undefined if the value entity is known to not exist, or the
178
178
  * entity object if it exists and is received.
179
179
  *
180
- * @param state State tree
181
- * @param kind Entity kind.
182
- * @param name Entity name.
183
- * @param key Record's key
184
- * @param query Optional query. If requesting specific
185
- * fields, fields must always include the ID.
180
+ * @param state State tree
181
+ * @param kind Entity kind.
182
+ * @param name Entity name.
183
+ * @param key Record's key
184
+ * @param query Optional query. If requesting specific
185
+ * fields, fields must always include the ID.
186
186
  *
187
187
  * @return Record.
188
188
  */
189
189
  export const getEntityRecord = createSelector((state, kind, name, key, query) => {
190
- var _query$context, _queriedState$items$c;
190
+ var _state$entities$recor, _state$entities$recor2, _state$entities$recor3, _query$context, _queriedState$items$c;
191
191
 
192
- const queriedState = get(state.entities.records, [kind, name, 'queriedData']);
192
+ const queriedState = (_state$entities$recor = state.entities.records) === null || _state$entities$recor === void 0 ? void 0 : (_state$entities$recor2 = _state$entities$recor[kind]) === null || _state$entities$recor2 === void 0 ? void 0 : (_state$entities$recor3 = _state$entities$recor2[name]) === null || _state$entities$recor3 === void 0 ? void 0 : _state$entities$recor3.queriedData;
193
193
 
194
194
  if (!queriedState) {
195
195
  return undefined;
@@ -218,7 +218,10 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
218
218
 
219
219
  for (let f = 0; f < fields.length; f++) {
220
220
  const field = fields[f].split('.');
221
- const value = get(item, field);
221
+ let value = item;
222
+ field.forEach(fieldName => {
223
+ value = value[fieldName];
224
+ });
222
225
  set(filteredItem, field, value);
223
226
  }
224
227
 
@@ -227,18 +230,18 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
227
230
 
228
231
  return item;
229
232
  }, (state, kind, name, recordId, query) => {
230
- var _query$context2;
233
+ var _query$context2, _state$entities$recor4, _state$entities$recor5, _state$entities$recor6, _state$entities$recor7, _state$entities$recor8, _state$entities$recor9, _state$entities$recor10, _state$entities$recor11, _state$entities$recor12, _state$entities$recor13;
231
234
 
232
235
  const context = (_query$context2 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context2 !== void 0 ? _query$context2 : 'default';
233
- return [get(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), get(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
236
+ return [(_state$entities$recor4 = state.entities.records) === null || _state$entities$recor4 === void 0 ? void 0 : (_state$entities$recor5 = _state$entities$recor4[kind]) === null || _state$entities$recor5 === void 0 ? void 0 : (_state$entities$recor6 = _state$entities$recor5[name]) === null || _state$entities$recor6 === void 0 ? void 0 : (_state$entities$recor7 = _state$entities$recor6.queriedData) === null || _state$entities$recor7 === void 0 ? void 0 : (_state$entities$recor8 = _state$entities$recor7.items[context]) === null || _state$entities$recor8 === void 0 ? void 0 : _state$entities$recor8[recordId], (_state$entities$recor9 = state.entities.records) === null || _state$entities$recor9 === void 0 ? void 0 : (_state$entities$recor10 = _state$entities$recor9[kind]) === null || _state$entities$recor10 === void 0 ? void 0 : (_state$entities$recor11 = _state$entities$recor10[name]) === null || _state$entities$recor11 === void 0 ? void 0 : (_state$entities$recor12 = _state$entities$recor11.queriedData) === null || _state$entities$recor12 === void 0 ? void 0 : (_state$entities$recor13 = _state$entities$recor12.itemIsComplete[context]) === null || _state$entities$recor13 === void 0 ? void 0 : _state$entities$recor13[recordId]];
234
237
  });
235
238
  /**
236
239
  * 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.
237
240
  *
238
- * @param state State tree
239
- * @param kind Entity kind.
240
- * @param name Entity name.
241
- * @param key Record's key
241
+ * @param state State tree
242
+ * @param kind Entity kind.
243
+ * @param name Entity name.
244
+ * @param key Record's key
242
245
  *
243
246
  * @return Record.
244
247
  */
@@ -250,10 +253,10 @@ export function __experimentalGetEntityRecordNoResolver(state, kind, name, key)
250
253
  * Returns the entity's record object by key,
251
254
  * with its attributes mapped to their raw values.
252
255
  *
253
- * @param state State tree.
254
- * @param kind Entity kind.
255
- * @param name Entity name.
256
- * @param key Record's key.
256
+ * @param state State tree.
257
+ * @param kind Entity kind.
258
+ * @param name Entity name.
259
+ * @param key Record's key.
257
260
  *
258
261
  * @return Object with the entity's raw attributes.
259
262
  */
@@ -262,10 +265,12 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
262
265
  const record = getEntityRecord(state, kind, name, key);
263
266
  return record && Object.keys(record).reduce((accumulator, _key) => {
264
267
  if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
268
+ var _record$_key$raw, _record$_key;
269
+
265
270
  // Because edits are the "raw" attribute values,
266
271
  // we return those from record selectors to make rendering,
267
272
  // comparisons, and joins with edits easier.
268
- accumulator[_key] = get(record[_key], 'raw', record[_key]);
273
+ accumulator[_key] = (_record$_key$raw = (_record$_key = record[_key]) === null || _record$_key === void 0 ? void 0 : _record$_key.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
269
274
  } else {
270
275
  accumulator[_key] = record[_key];
271
276
  }
@@ -273,19 +278,19 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
273
278
  return accumulator;
274
279
  }, {});
275
280
  }, (state, kind, name, recordId, query) => {
276
- var _query$context3;
281
+ var _query$context3, _state$entities$recor14, _state$entities$recor15, _state$entities$recor16, _state$entities$recor17, _state$entities$recor18, _state$entities$recor19, _state$entities$recor20, _state$entities$recor21, _state$entities$recor22, _state$entities$recor23;
277
282
 
278
283
  const context = (_query$context3 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context3 !== void 0 ? _query$context3 : 'default';
279
- return [state.entities.config, get(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), get(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId])];
284
+ return [state.entities.config, (_state$entities$recor14 = state.entities.records) === null || _state$entities$recor14 === void 0 ? void 0 : (_state$entities$recor15 = _state$entities$recor14[kind]) === null || _state$entities$recor15 === void 0 ? void 0 : (_state$entities$recor16 = _state$entities$recor15[name]) === null || _state$entities$recor16 === void 0 ? void 0 : (_state$entities$recor17 = _state$entities$recor16.queriedData) === null || _state$entities$recor17 === void 0 ? void 0 : (_state$entities$recor18 = _state$entities$recor17.items[context]) === null || _state$entities$recor18 === void 0 ? void 0 : _state$entities$recor18[recordId], (_state$entities$recor19 = state.entities.records) === null || _state$entities$recor19 === void 0 ? void 0 : (_state$entities$recor20 = _state$entities$recor19[kind]) === null || _state$entities$recor20 === void 0 ? void 0 : (_state$entities$recor21 = _state$entities$recor20[name]) === null || _state$entities$recor21 === void 0 ? void 0 : (_state$entities$recor22 = _state$entities$recor21.queriedData) === null || _state$entities$recor22 === void 0 ? void 0 : (_state$entities$recor23 = _state$entities$recor22.itemIsComplete[context]) === null || _state$entities$recor23 === void 0 ? void 0 : _state$entities$recor23[recordId]];
280
285
  });
281
286
  /**
282
287
  * Returns true if records have been received for the given set of parameters,
283
288
  * or false otherwise.
284
289
  *
285
- * @param state State tree
286
- * @param kind Entity kind.
287
- * @param name Entity name.
288
- * @param query Optional terms query.
290
+ * @param state State tree
291
+ * @param kind Entity kind.
292
+ * @param name Entity name.
293
+ * @param query Optional terms query.
289
294
  *
290
295
  * @return Whether entity records have been received.
291
296
  */
@@ -305,18 +310,20 @@ export function hasEntityRecords(state, kind, name, query) {
305
310
  /**
306
311
  * Returns the Entity's records.
307
312
  *
308
- * @param state State tree
309
- * @param kind Entity kind.
310
- * @param name Entity name.
311
- * @param query Optional terms query. If requesting specific
312
- * fields, fields must always include the ID.
313
+ * @param state State tree
314
+ * @param kind Entity kind.
315
+ * @param name Entity name.
316
+ * @param query Optional terms query. If requesting specific
317
+ * fields, fields must always include the ID.
313
318
  *
314
319
  * @return Records.
315
320
  */
316
321
  export const getEntityRecords = (state, kind, name, query) => {
322
+ var _state$entities$recor24, _state$entities$recor25, _state$entities$recor26;
323
+
317
324
  // Queried data state is prepopulated for all known entities. If this is not
318
325
  // assigned for the given parameters, then it is known to not exist.
319
- const queriedState = get(state.entities.records, [kind, name, 'queriedData']);
326
+ const queriedState = (_state$entities$recor24 = state.entities.records) === null || _state$entities$recor24 === void 0 ? void 0 : (_state$entities$recor25 = _state$entities$recor24[kind]) === null || _state$entities$recor25 === void 0 ? void 0 : (_state$entities$recor26 = _state$entities$recor25[name]) === null || _state$entities$recor26 === void 0 ? void 0 : _state$entities$recor26.queriedData;
320
327
 
321
328
  if (!queriedState) {
322
329
  return null;
@@ -328,7 +335,7 @@ export const getEntityRecords = (state, kind, name, query) => {
328
335
  /**
329
336
  * Returns the list of dirty entity records.
330
337
  *
331
- * @param state State tree.
338
+ * @param state State tree.
332
339
  *
333
340
  * @return The list of updated records
334
341
  */
@@ -368,7 +375,7 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
368
375
  /**
369
376
  * Returns the list of entities currently being saved.
370
377
  *
371
- * @param state State tree.
378
+ * @param state State tree.
372
379
  *
373
380
  * @return The list of records being saved.
374
381
  */
@@ -407,16 +414,18 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
407
414
  /**
408
415
  * Returns the specified entity record's edits.
409
416
  *
410
- * @param state State tree.
411
- * @param kind Entity kind.
412
- * @param name Entity name.
413
- * @param recordId Record ID.
417
+ * @param state State tree.
418
+ * @param kind Entity kind.
419
+ * @param name Entity name.
420
+ * @param recordId Record ID.
414
421
  *
415
422
  * @return The entity record's edits.
416
423
  */
417
424
 
418
425
  export function getEntityRecordEdits(state, kind, name, recordId) {
419
- return get(state.entities.records, [kind, name, 'edits', recordId]);
426
+ var _state$entities$recor27, _state$entities$recor28, _state$entities$recor29, _state$entities$recor30;
427
+
428
+ return (_state$entities$recor27 = state.entities.records) === null || _state$entities$recor27 === void 0 ? void 0 : (_state$entities$recor28 = _state$entities$recor27[kind]) === null || _state$entities$recor28 === void 0 ? void 0 : (_state$entities$recor29 = _state$entities$recor28[name]) === null || _state$entities$recor29 === void 0 ? void 0 : (_state$entities$recor30 = _state$entities$recor29.edits) === null || _state$entities$recor30 === void 0 ? void 0 : _state$entities$recor30[recordId];
420
429
  }
421
430
  /**
422
431
  * Returns the specified entity record's non transient edits.
@@ -425,10 +434,10 @@ export function getEntityRecordEdits(state, kind, name, recordId) {
425
434
  * are not considered for change detection.
426
435
  * They are defined in the entity's config.
427
436
  *
428
- * @param state State tree.
429
- * @param kind Entity kind.
430
- * @param name Entity name.
431
- * @param recordId Record ID.
437
+ * @param state State tree.
438
+ * @param kind Entity kind.
439
+ * @param name Entity name.
440
+ * @param recordId Record ID.
432
441
  *
433
442
  * @return The entity record's non transient edits.
434
443
  */
@@ -450,15 +459,19 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
450
459
 
451
460
  return acc;
452
461
  }, {});
453
- }, (state, kind, name, recordId) => [state.entities.config, get(state.entities.records, [kind, name, 'edits', recordId])]);
462
+ }, (state, kind, name, recordId) => {
463
+ var _state$entities$recor31, _state$entities$recor32, _state$entities$recor33, _state$entities$recor34;
464
+
465
+ return [state.entities.config, (_state$entities$recor31 = state.entities.records) === null || _state$entities$recor31 === void 0 ? void 0 : (_state$entities$recor32 = _state$entities$recor31[kind]) === null || _state$entities$recor32 === void 0 ? void 0 : (_state$entities$recor33 = _state$entities$recor32[name]) === null || _state$entities$recor33 === void 0 ? void 0 : (_state$entities$recor34 = _state$entities$recor33.edits) === null || _state$entities$recor34 === void 0 ? void 0 : _state$entities$recor34[recordId]];
466
+ });
454
467
  /**
455
468
  * Returns true if the specified entity record has edits,
456
469
  * and false otherwise.
457
470
  *
458
- * @param state State tree.
459
- * @param kind Entity kind.
460
- * @param name Entity name.
461
- * @param recordId Record ID.
471
+ * @param state State tree.
472
+ * @param kind Entity kind.
473
+ * @param name Entity name.
474
+ * @param recordId Record ID.
462
475
  *
463
476
  * @return Whether the entity record has edits or not.
464
477
  */
@@ -469,10 +482,10 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
469
482
  /**
470
483
  * Returns the specified entity record, merged with its edits.
471
484
  *
472
- * @param state State tree.
473
- * @param kind Entity kind.
474
- * @param name Entity name.
475
- * @param recordId Record ID.
485
+ * @param state State tree.
486
+ * @param kind Entity kind.
487
+ * @param name Entity name.
488
+ * @param recordId Record ID.
476
489
  *
477
490
  * @return The entity record, merged with its edits.
478
491
  */
@@ -480,84 +493,94 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
480
493
  export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
481
494
  ...getEntityRecordEdits(state, kind, name, recordId)
482
495
  }), (state, kind, name, recordId, query) => {
483
- var _query$context4;
496
+ var _query$context4, _state$entities$recor35, _state$entities$recor36, _state$entities$recor37, _state$entities$recor38, _state$entities$recor39, _state$entities$recor40, _state$entities$recor41, _state$entities$recor42, _state$entities$recor43, _state$entities$recor44, _state$entities$recor45, _state$entities$recor46;
484
497
 
485
498
  const context = (_query$context4 = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context4 !== void 0 ? _query$context4 : 'default';
486
- return [state.entities.config, get(state.entities.records, [kind, name, 'queriedData', 'items', context, recordId]), get(state.entities.records, [kind, name, 'queriedData', 'itemIsComplete', context, recordId]), get(state.entities.records, [kind, name, 'edits', recordId])];
499
+ return [state.entities.config, (_state$entities$recor35 = state.entities.records) === null || _state$entities$recor35 === void 0 ? void 0 : (_state$entities$recor36 = _state$entities$recor35[kind]) === null || _state$entities$recor36 === void 0 ? void 0 : (_state$entities$recor37 = _state$entities$recor36[name]) === null || _state$entities$recor37 === void 0 ? void 0 : (_state$entities$recor38 = _state$entities$recor37.queriedData.items[context]) === null || _state$entities$recor38 === void 0 ? void 0 : _state$entities$recor38[recordId], (_state$entities$recor39 = state.entities.records) === null || _state$entities$recor39 === void 0 ? void 0 : (_state$entities$recor40 = _state$entities$recor39[kind]) === null || _state$entities$recor40 === void 0 ? void 0 : (_state$entities$recor41 = _state$entities$recor40[name]) === null || _state$entities$recor41 === void 0 ? void 0 : (_state$entities$recor42 = _state$entities$recor41.queriedData.itemIsComplete[context]) === null || _state$entities$recor42 === void 0 ? void 0 : _state$entities$recor42[recordId], (_state$entities$recor43 = state.entities.records) === null || _state$entities$recor43 === void 0 ? void 0 : (_state$entities$recor44 = _state$entities$recor43[kind]) === null || _state$entities$recor44 === void 0 ? void 0 : (_state$entities$recor45 = _state$entities$recor44[name]) === null || _state$entities$recor45 === void 0 ? void 0 : (_state$entities$recor46 = _state$entities$recor45.edits) === null || _state$entities$recor46 === void 0 ? void 0 : _state$entities$recor46[recordId]];
487
500
  });
488
501
  /**
489
502
  * Returns true if the specified entity record is autosaving, and false otherwise.
490
503
  *
491
- * @param state State tree.
492
- * @param kind Entity kind.
493
- * @param name Entity name.
494
- * @param recordId Record ID.
504
+ * @param state State tree.
505
+ * @param kind Entity kind.
506
+ * @param name Entity name.
507
+ * @param recordId Record ID.
495
508
  *
496
509
  * @return Whether the entity record is autosaving or not.
497
510
  */
498
511
 
499
512
  export function isAutosavingEntityRecord(state, kind, name, recordId) {
513
+ var _state$entities$recor47, _state$entities$recor48, _state$entities$recor49, _state$entities$recor50, _state$entities$recor51;
514
+
500
515
  const {
501
516
  pending,
502
517
  isAutosave
503
- } = get(state.entities.records, [kind, name, 'saving', recordId], {});
518
+ } = (_state$entities$recor47 = (_state$entities$recor48 = state.entities.records) === null || _state$entities$recor48 === void 0 ? void 0 : (_state$entities$recor49 = _state$entities$recor48[kind]) === null || _state$entities$recor49 === void 0 ? void 0 : (_state$entities$recor50 = _state$entities$recor49[name]) === null || _state$entities$recor50 === void 0 ? void 0 : (_state$entities$recor51 = _state$entities$recor50.saving) === null || _state$entities$recor51 === void 0 ? void 0 : _state$entities$recor51[recordId]) !== null && _state$entities$recor47 !== void 0 ? _state$entities$recor47 : {};
504
519
  return Boolean(pending && isAutosave);
505
520
  }
506
521
  /**
507
522
  * Returns true if the specified entity record is saving, and false otherwise.
508
523
  *
509
- * @param state State tree.
510
- * @param kind Entity kind.
511
- * @param name Entity name.
512
- * @param recordId Record ID.
524
+ * @param state State tree.
525
+ * @param kind Entity kind.
526
+ * @param name Entity name.
527
+ * @param recordId Record ID.
513
528
  *
514
529
  * @return Whether the entity record is saving or not.
515
530
  */
516
531
 
517
532
  export function isSavingEntityRecord(state, kind, name, recordId) {
518
- return get(state.entities.records, [kind, name, 'saving', recordId, 'pending'], false);
533
+ var _state$entities$recor52, _state$entities$recor53, _state$entities$recor54, _state$entities$recor55, _state$entities$recor56, _state$entities$recor57;
534
+
535
+ return (_state$entities$recor52 = (_state$entities$recor53 = state.entities.records) === null || _state$entities$recor53 === void 0 ? void 0 : (_state$entities$recor54 = _state$entities$recor53[kind]) === null || _state$entities$recor54 === void 0 ? void 0 : (_state$entities$recor55 = _state$entities$recor54[name]) === null || _state$entities$recor55 === void 0 ? void 0 : (_state$entities$recor56 = _state$entities$recor55.saving) === null || _state$entities$recor56 === void 0 ? void 0 : (_state$entities$recor57 = _state$entities$recor56[recordId]) === null || _state$entities$recor57 === void 0 ? void 0 : _state$entities$recor57.pending) !== null && _state$entities$recor52 !== void 0 ? _state$entities$recor52 : false;
519
536
  }
520
537
  /**
521
538
  * Returns true if the specified entity record is deleting, and false otherwise.
522
539
  *
523
- * @param state State tree.
524
- * @param kind Entity kind.
525
- * @param name Entity name.
526
- * @param recordId Record ID.
540
+ * @param state State tree.
541
+ * @param kind Entity kind.
542
+ * @param name Entity name.
543
+ * @param recordId Record ID.
527
544
  *
528
545
  * @return Whether the entity record is deleting or not.
529
546
  */
530
547
 
531
548
  export function isDeletingEntityRecord(state, kind, name, recordId) {
532
- return get(state.entities.records, [kind, name, 'deleting', recordId, 'pending'], false);
549
+ var _state$entities$recor58, _state$entities$recor59, _state$entities$recor60, _state$entities$recor61, _state$entities$recor62, _state$entities$recor63;
550
+
551
+ return (_state$entities$recor58 = (_state$entities$recor59 = state.entities.records) === null || _state$entities$recor59 === void 0 ? void 0 : (_state$entities$recor60 = _state$entities$recor59[kind]) === null || _state$entities$recor60 === void 0 ? void 0 : (_state$entities$recor61 = _state$entities$recor60[name]) === null || _state$entities$recor61 === void 0 ? void 0 : (_state$entities$recor62 = _state$entities$recor61.deleting) === null || _state$entities$recor62 === void 0 ? void 0 : (_state$entities$recor63 = _state$entities$recor62[recordId]) === null || _state$entities$recor63 === void 0 ? void 0 : _state$entities$recor63.pending) !== null && _state$entities$recor58 !== void 0 ? _state$entities$recor58 : false;
533
552
  }
534
553
  /**
535
554
  * Returns the specified entity record's last save error.
536
555
  *
537
- * @param state State tree.
538
- * @param kind Entity kind.
539
- * @param name Entity name.
540
- * @param recordId Record ID.
556
+ * @param state State tree.
557
+ * @param kind Entity kind.
558
+ * @param name Entity name.
559
+ * @param recordId Record ID.
541
560
  *
542
561
  * @return The entity record's save error.
543
562
  */
544
563
 
545
564
  export function getLastEntitySaveError(state, kind, name, recordId) {
546
- return get(state.entities.records, [kind, name, 'saving', recordId, 'error']);
565
+ var _state$entities$recor64, _state$entities$recor65, _state$entities$recor66, _state$entities$recor67, _state$entities$recor68;
566
+
567
+ return (_state$entities$recor64 = state.entities.records) === null || _state$entities$recor64 === void 0 ? void 0 : (_state$entities$recor65 = _state$entities$recor64[kind]) === null || _state$entities$recor65 === void 0 ? void 0 : (_state$entities$recor66 = _state$entities$recor65[name]) === null || _state$entities$recor66 === void 0 ? void 0 : (_state$entities$recor67 = _state$entities$recor66.saving) === null || _state$entities$recor67 === void 0 ? void 0 : (_state$entities$recor68 = _state$entities$recor67[recordId]) === null || _state$entities$recor68 === void 0 ? void 0 : _state$entities$recor68.error;
547
568
  }
548
569
  /**
549
570
  * Returns the specified entity record's last delete error.
550
571
  *
551
- * @param state State tree.
552
- * @param kind Entity kind.
553
- * @param name Entity name.
554
- * @param recordId Record ID.
572
+ * @param state State tree.
573
+ * @param kind Entity kind.
574
+ * @param name Entity name.
575
+ * @param recordId Record ID.
555
576
  *
556
577
  * @return The entity record's save error.
557
578
  */
558
579
 
559
580
  export function getLastEntityDeleteError(state, kind, name, recordId) {
560
- return get(state.entities.records, [kind, name, 'deleting', recordId, 'error']);
581
+ var _state$entities$recor69, _state$entities$recor70, _state$entities$recor71, _state$entities$recor72, _state$entities$recor73;
582
+
583
+ return (_state$entities$recor69 = state.entities.records) === null || _state$entities$recor69 === void 0 ? void 0 : (_state$entities$recor70 = _state$entities$recor69[kind]) === null || _state$entities$recor70 === void 0 ? void 0 : (_state$entities$recor71 = _state$entities$recor70[name]) === null || _state$entities$recor71 === void 0 ? void 0 : (_state$entities$recor72 = _state$entities$recor71.deleting) === null || _state$entities$recor72 === void 0 ? void 0 : (_state$entities$recor73 = _state$entities$recor72[recordId]) === null || _state$entities$recor73 === void 0 ? void 0 : _state$entities$recor73.error;
561
584
  }
562
585
  /**
563
586
  * Returns the current undo offset for the
@@ -566,7 +589,7 @@ export function getLastEntityDeleteError(state, kind, name, recordId) {
566
589
  * of the history stack we are at. 0 is the
567
590
  * last edit, -1 is the second last, and so on.
568
591
  *
569
- * @param state State tree.
592
+ * @param state State tree.
570
593
  *
571
594
  * @return The current undo offset.
572
595
  */
@@ -578,7 +601,7 @@ function getCurrentUndoOffset(state) {
578
601
  * Returns the previous edit from the current undo offset
579
602
  * for the entity records edits history, if any.
580
603
  *
581
- * @param state State tree.
604
+ * @param state State tree.
582
605
  *
583
606
  * @return The edit.
584
607
  */
@@ -591,7 +614,7 @@ export function getUndoEdit(state) {
591
614
  * Returns the next edit from the current undo offset
592
615
  * for the entity records edits history, if any.
593
616
  *
594
- * @param state State tree.
617
+ * @param state State tree.
595
618
  *
596
619
  * @return The edit.
597
620
  */
@@ -603,7 +626,7 @@ export function getRedoEdit(state) {
603
626
  * Returns true if there is a previous edit from the current undo offset
604
627
  * for the entity records edits history, and false otherwise.
605
628
  *
606
- * @param state State tree.
629
+ * @param state State tree.
607
630
  *
608
631
  * @return Whether there is a previous edit or not.
609
632
  */
@@ -615,7 +638,7 @@ export function hasUndo(state) {
615
638
  * Returns true if there is a next edit from the current undo offset
616
639
  * for the entity records edits history, and false otherwise.
617
640
  *
618
- * @param state State tree.
641
+ * @param state State tree.
619
642
  *
620
643
  * @return Whether there is a next edit or not.
621
644
  */
@@ -626,7 +649,7 @@ export function hasRedo(state) {
626
649
  /**
627
650
  * Return the current theme.
628
651
  *
629
- * @param state Data state.
652
+ * @param state Data state.
630
653
  *
631
654
  * @return The current theme.
632
655
  */
@@ -637,7 +660,7 @@ export function getCurrentTheme(state) {
637
660
  /**
638
661
  * Return the ID of the current global styles object.
639
662
  *
640
- * @param state Data state.
663
+ * @param state Data state.
641
664
  *
642
665
  * @return The current global styles ID.
643
666
  */
@@ -648,7 +671,7 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
648
671
  /**
649
672
  * Return theme supports data in the index.
650
673
  *
651
- * @param state Data state.
674
+ * @param state Data state.
652
675
  *
653
676
  * @return Index data.
654
677
  */
@@ -661,8 +684,8 @@ export function getThemeSupports(state) {
661
684
  /**
662
685
  * Returns the embed preview for the given URL.
663
686
  *
664
- * @param state Data state.
665
- * @param url Embedded URL.
687
+ * @param state Data state.
688
+ * @param url Embedded URL.
666
689
  *
667
690
  * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
668
691
  */
@@ -677,8 +700,8 @@ export function getEmbedPreview(state, url) {
677
700
  * We need to be able to determine if a URL is embeddable or not, based on what we
678
701
  * get back from the oEmbed preview API.
679
702
  *
680
- * @param state Data state.
681
- * @param url Embedded URL.
703
+ * @param state Data state.
704
+ * @param url Embedded URL.
682
705
  *
683
706
  * @return Is the preview for the URL an oEmbed link fallback.
684
707
  */
@@ -702,10 +725,10 @@ export function isPreviewEmbedFallback(state, url) {
702
725
  *
703
726
  * https://developer.wordpress.org/rest-api/reference/
704
727
  *
705
- * @param state Data state.
706
- * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
707
- * @param resource REST resource to check, e.g. 'media' or 'posts'.
708
- * @param id Optional ID of the rest resource to check.
728
+ * @param state Data state.
729
+ * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
730
+ * @param resource REST resource to check, e.g. 'media' or 'posts'.
731
+ * @param id Optional ID of the rest resource to check.
709
732
  *
710
733
  * @return Whether or not the user can perform the action,
711
734
  * or `undefined` if the OPTIONS request is still being made.
@@ -713,7 +736,7 @@ export function isPreviewEmbedFallback(state, url) {
713
736
 
714
737
  export function canUser(state, action, resource, id) {
715
738
  const key = [action, resource, id].filter(Boolean).join('/');
716
- return get(state, ['userPermissions', key]);
739
+ return state.userPermissions[key];
717
740
  }
718
741
  /**
719
742
  * Returns whether the current user can edit the given entity.
@@ -723,10 +746,10 @@ export function canUser(state, action, resource, id) {
723
746
  *
724
747
  * https://developer.wordpress.org/rest-api/reference/
725
748
  *
726
- * @param state Data state.
727
- * @param kind Entity kind.
728
- * @param name Entity name.
729
- * @param recordId Record's id.
749
+ * @param state Data state.
750
+ * @param kind Entity kind.
751
+ * @param name Entity name.
752
+ * @param recordId Record's id.
730
753
  * @return Whether or not the user can edit,
731
754
  * or `undefined` if the OPTIONS request is still being made.
732
755
  */
@@ -747,9 +770,9 @@ export function canUserEditEntityRecord(state, kind, name, recordId) {
747
770
  * May return multiple autosaves since the backend stores one autosave per
748
771
  * author for each post.
749
772
  *
750
- * @param state State tree.
751
- * @param postType The type of the parent post.
752
- * @param postId The id of the parent post.
773
+ * @param state State tree.
774
+ * @param postType The type of the parent post.
775
+ * @param postId The id of the parent post.
753
776
  *
754
777
  * @return An array of autosaves for the post, or undefined if there is none.
755
778
  */
@@ -760,10 +783,10 @@ export function getAutosaves(state, postType, postId) {
760
783
  /**
761
784
  * Returns the autosave for the post and author.
762
785
  *
763
- * @param state State tree.
764
- * @param postType The type of the parent post.
765
- * @param postId The id of the parent post.
766
- * @param authorId The id of the author.
786
+ * @param state State tree.
787
+ * @param postType The type of the parent post.
788
+ * @param postId The id of the parent post.
789
+ * @param authorId The id of the author.
767
790
  *
768
791
  * @return The autosave for the post and author.
769
792
  */
@@ -779,9 +802,9 @@ export function getAutosave(state, postType, postId, authorId) {
779
802
  /**
780
803
  * Returns true if the REST request for autosaves has completed.
781
804
  *
782
- * @param state State tree.
783
- * @param postType The type of the parent post.
784
- * @param postId The id of the parent post.
805
+ * @param state State tree.
806
+ * @param postType The type of the parent post.
807
+ * @param postId The id of the parent post.
785
808
  *
786
809
  * @return True if the REST request was completed. False otherwise.
787
810
  */
@@ -803,7 +826,7 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
803
826
  * );
804
827
  * ```
805
828
  *
806
- * @param state Editor state.
829
+ * @param state Editor state.
807
830
  *
808
831
  * @return A value whose reference will change only when an edit occurs.
809
832
  */
@@ -813,8 +836,8 @@ state => [], state => [state.undo.length, state.undo.offset, state.undo.flattene
813
836
  /**
814
837
  * Retrieve the frontend template used for a given link.
815
838
  *
816
- * @param state Editor state.
817
- * @param link Link.
839
+ * @param state Editor state.
840
+ * @param link Link.
818
841
  *
819
842
  * @return The template record.
820
843
  */
@@ -833,7 +856,7 @@ export function __experimentalGetTemplateForLink(state, link) {
833
856
  /**
834
857
  * Retrieve the current theme's base global styles
835
858
  *
836
- * @param state Editor state.
859
+ * @param state Editor state.
837
860
  *
838
861
  * @return The Global Styles object.
839
862
  */
@@ -850,7 +873,7 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
850
873
  /**
851
874
  * Return the ID of the current global styles object.
852
875
  *
853
- * @param state Data state.
876
+ * @param state Data state.
854
877
  *
855
878
  * @return The current global styles ID.
856
879
  */
@@ -867,7 +890,7 @@ export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
867
890
  /**
868
891
  * Retrieve the list of registered block patterns.
869
892
  *
870
- * @param state Data state.
893
+ * @param state Data state.
871
894
  *
872
895
  * @return Block pattern list.
873
896
  */
@@ -878,7 +901,7 @@ export function getBlockPatterns(state) {
878
901
  /**
879
902
  * Retrieve the list of registered block pattern categories.
880
903
  *
881
- * @param state Data state.
904
+ * @param state Data state.
882
905
  *
883
906
  * @return Block pattern category list.
884
907
  */