@wordpress/core-data 4.4.5 → 4.7.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 (44) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +175 -85
  3. package/build/entities.js +3 -0
  4. package/build/entities.js.map +1 -1
  5. package/build/hooks/constants.js +0 -2
  6. package/build/hooks/constants.js.map +1 -1
  7. package/build/hooks/index.js +38 -0
  8. package/build/hooks/index.js.map +1 -0
  9. package/build/hooks/use-entity-record.js +22 -8
  10. package/build/hooks/use-entity-record.js.map +1 -1
  11. package/build/hooks/use-entity-records.js +21 -8
  12. package/build/hooks/use-entity-records.js.map +1 -1
  13. package/build/index.js +17 -21
  14. package/build/index.js.map +1 -1
  15. package/build/selectors.js +163 -163
  16. package/build/selectors.js.map +1 -1
  17. package/build-module/entities.js +3 -0
  18. package/build-module/entities.js.map +1 -1
  19. package/build-module/hooks/constants.js +0 -1
  20. package/build-module/hooks/constants.js.map +1 -1
  21. package/build-module/hooks/index.js +3 -0
  22. package/build-module/hooks/index.js.map +1 -0
  23. package/build-module/hooks/use-entity-record.js +18 -7
  24. package/build-module/hooks/use-entity-record.js.map +1 -1
  25. package/build-module/hooks/use-entity-records.js +17 -7
  26. package/build-module/hooks/use-entity-records.js.map +1 -1
  27. package/build-module/index.js +2 -3
  28. package/build-module/index.js.map +1 -1
  29. package/build-module/selectors.js +164 -163
  30. package/build-module/selectors.js.map +1 -1
  31. package/package.json +11 -11
  32. package/src/entities.ts +1 -0
  33. package/src/hooks/constants.ts +1 -2
  34. package/src/hooks/index.ts +8 -0
  35. package/src/hooks/test/use-entity-record.js +1 -0
  36. package/src/hooks/test/use-entity-records.js +1 -0
  37. package/src/hooks/test/use-query-select.js +1 -0
  38. package/src/hooks/use-entity-record.ts +32 -9
  39. package/src/hooks/use-entity-records.ts +28 -30
  40. package/src/index.js +2 -3
  41. package/src/selectors.ts +406 -216
  42. package/src/test/actions.js +16 -0
  43. package/src/test/entities.js +5 -0
  44. package/src/test/resolvers.js +11 -0
@@ -18,6 +18,7 @@ import { STORE_NAME } from './name';
18
18
  import { getQueriedItems } from './queried-data';
19
19
  import { DEFAULT_ENTITY_KEY } from './entities';
20
20
  import { getNormalizedCommaSeparable, isRawAttribute } from './utils';
21
+
21
22
  /**
22
23
  * Shared reference to an empty object for cases where it is important to avoid
23
24
  * returning a new object reference on every invocation, as in a connected or
@@ -25,16 +26,15 @@ import { getNormalizedCommaSeparable, isRawAttribute } from './utils';
25
26
  * This should be used as a last resort, since the normalized data should be
26
27
  * maintained by the reducer result in state.
27
28
  */
28
-
29
29
  const EMPTY_OBJECT = {};
30
30
  /**
31
31
  * Returns true if a request is in progress for embed preview data, or false
32
32
  * otherwise.
33
33
  *
34
- * @param {Object} state Data state.
35
- * @param {string} url URL the preview would be for.
34
+ * @param state Data state.
35
+ * @param url URL the preview would be for.
36
36
  *
37
- * @return {boolean} Whether a request is in progress for an embed preview.
37
+ * @return Whether a request is in progress for an embed preview.
38
38
  */
39
39
 
40
40
  export const isRequestingEmbedPreview = createRegistrySelector(select => (state, url) => {
@@ -45,10 +45,10 @@ 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 {Object} state Data state.
49
- * @param {Object|undefined} query Optional object of query parameters to
50
- * include with request.
51
- * @return {Array} Authors list.
48
+ * @param state Data state.
49
+ * @param query Optional object of query parameters to
50
+ * include with request.
51
+ * @return Authors list.
52
52
  */
53
53
 
54
54
  export function getAuthors(state, query) {
@@ -62,9 +62,9 @@ export function getAuthors(state, query) {
62
62
  /**
63
63
  * Returns the current user.
64
64
  *
65
- * @param {Object} state Data state.
65
+ * @param state Data state.
66
66
  *
67
- * @return {Object} Current user object.
67
+ * @return Current user object.
68
68
  */
69
69
 
70
70
  export function getCurrentUser(state) {
@@ -73,10 +73,10 @@ export function getCurrentUser(state) {
73
73
  /**
74
74
  * Returns all the users returned by a query ID.
75
75
  *
76
- * @param {Object} state Data state.
77
- * @param {string} queryID Query ID.
76
+ * @param state Data state.
77
+ * @param queryID Query ID.
78
78
  *
79
- * @return {Array} Users list.
79
+ * @return Users list.
80
80
  */
81
81
 
82
82
  export const getUserQueryResults = createSelector((state, queryID) => {
@@ -87,10 +87,10 @@ export const getUserQueryResults = createSelector((state, queryID) => {
87
87
  * Returns the loaded entities for the given kind.
88
88
  *
89
89
  * @deprecated since WordPress 6.0. Use getEntitiesConfig instead
90
- * @param {Object} state Data state.
91
- * @param {string} kind Entity kind.
90
+ * @param state Data state.
91
+ * @param kind Entity kind.
92
92
  *
93
- * @return {Array<Object>} Array of entities with config matching kind.
93
+ * @return Array of entities with config matching kind.
94
94
  */
95
95
 
96
96
  export function getEntitiesByKind(state, kind) {
@@ -103,10 +103,10 @@ export function getEntitiesByKind(state, kind) {
103
103
  /**
104
104
  * Returns the loaded entities for the given kind.
105
105
  *
106
- * @param {Object} state Data state.
107
- * @param {string} kind Entity kind.
106
+ * @param state Data state.
107
+ * @param kind Entity kind.
108
108
  *
109
- * @return {Array<Object>} Array of entities with config matching kind.
109
+ * @return Array of entities with config matching kind.
110
110
  */
111
111
 
112
112
  export function getEntitiesConfig(state, kind) {
@@ -118,11 +118,11 @@ 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 {Object} state Data state.
122
- * @param {string} kind Entity kind.
123
- * @param {string} name Entity name.
121
+ * @param state Data state.
122
+ * @param kind Entity kind.
123
+ * @param name Entity name.
124
124
  *
125
- * @return {Object} Entity config
125
+ * @return Entity config
126
126
  */
127
127
 
128
128
  export function getEntity(state, kind, name) {
@@ -135,11 +135,11 @@ export function getEntity(state, kind, name) {
135
135
  /**
136
136
  * Returns the entity config given its kind and name.
137
137
  *
138
- * @param {Object} state Data state.
139
- * @param {string} kind Entity kind.
140
- * @param {string} name Entity name.
138
+ * @param state Data state.
139
+ * @param kind Entity kind.
140
+ * @param name Entity name.
141
141
  *
142
- * @return {Object} Entity config
142
+ * @return Entity config
143
143
  */
144
144
 
145
145
  export function getEntityConfig(state, kind, name) {
@@ -153,13 +153,13 @@ export function getEntityConfig(state, kind, name) {
153
153
  * yet received, undefined if the value entity is known to not exist, or the
154
154
  * entity object if it exists and is received.
155
155
  *
156
- * @param {Object} state State tree
157
- * @param {string} kind Entity kind.
158
- * @param {string} name Entity name.
159
- * @param {number} key Record's key
160
- * @param {?Object} query Optional query.
156
+ * @param state State tree
157
+ * @param kind Entity kind.
158
+ * @param name Entity name.
159
+ * @param key Record's key
160
+ * @param query Optional query.
161
161
  *
162
- * @return {Object|undefined} Record.
162
+ * @return Record.
163
163
  */
164
164
 
165
165
  export const getEntityRecord = createSelector((state, kind, name, key, query) => {
@@ -211,12 +211,12 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
211
211
  /**
212
212
  * 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.
213
213
  *
214
- * @param {Object} state State tree
215
- * @param {string} kind Entity kind.
216
- * @param {string} name Entity name.
217
- * @param {number} key Record's key
214
+ * @param state State tree
215
+ * @param kind Entity kind.
216
+ * @param name Entity name.
217
+ * @param key Record's key
218
218
  *
219
- * @return {Object|null} Record.
219
+ * @return Record.
220
220
  */
221
221
 
222
222
  export function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
@@ -226,12 +226,12 @@ export function __experimentalGetEntityRecordNoResolver(state, kind, name, key)
226
226
  * Returns the entity's record object by key,
227
227
  * with its attributes mapped to their raw values.
228
228
  *
229
- * @param {Object} state State tree.
230
- * @param {string} kind Entity kind.
231
- * @param {string} name Entity name.
232
- * @param {number} key Record's key.
229
+ * @param state State tree.
230
+ * @param kind Entity kind.
231
+ * @param name Entity name.
232
+ * @param key Record's key.
233
233
  *
234
- * @return {Object?} Object with the entity's raw attributes.
234
+ * @return Object with the entity's raw attributes.
235
235
  */
236
236
 
237
237
  export const getRawEntityRecord = createSelector((state, kind, name, key) => {
@@ -258,12 +258,12 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
258
258
  * Returns true if records have been received for the given set of parameters,
259
259
  * or false otherwise.
260
260
  *
261
- * @param {Object} state State tree
262
- * @param {string} kind Entity kind.
263
- * @param {string} name Entity name.
264
- * @param {?Object} query Optional terms query.
261
+ * @param state State tree
262
+ * @param kind Entity kind.
263
+ * @param name Entity name.
264
+ * @param query Optional terms query.
265
265
  *
266
- * @return {boolean} Whether entity records have been received.
266
+ * @return Whether entity records have been received.
267
267
  */
268
268
 
269
269
  export function hasEntityRecords(state, kind, name, query) {
@@ -272,12 +272,12 @@ export function hasEntityRecords(state, kind, name, query) {
272
272
  /**
273
273
  * Returns the Entity's records.
274
274
  *
275
- * @param {Object} state State tree
276
- * @param {string} kind Entity kind.
277
- * @param {string} name Entity name.
278
- * @param {?Object} query Optional terms query.
275
+ * @param state State tree
276
+ * @param kind Entity kind.
277
+ * @param name Entity name.
278
+ * @param query Optional terms query.
279
279
  *
280
- * @return {?Array} Records.
280
+ * @return Records.
281
281
  */
282
282
 
283
283
  export function getEntityRecords(state, kind, name, query) {
@@ -291,14 +291,14 @@ export function getEntityRecords(state, kind, name, query) {
291
291
 
292
292
  return getQueriedItems(queriedState, query);
293
293
  }
294
+
294
295
  /**
295
- * Returns the list of dirty entity records.
296
+ * Returns the list of dirty entity records.
296
297
  *
297
- * @param {Object} state State tree.
298
+ * @param state State tree.
298
299
  *
299
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records
300
+ * @return The list of updated records
300
301
  */
301
-
302
302
  export const __experimentalGetDirtyEntityRecords = createSelector(state => {
303
303
  const {
304
304
  entities: {
@@ -335,9 +335,9 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
335
335
  /**
336
336
  * Returns the list of entities currently being saved.
337
337
  *
338
- * @param {Object} state State tree.
338
+ * @param state State tree.
339
339
  *
340
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of records being saved.
340
+ * @return The list of records being saved.
341
341
  */
342
342
 
343
343
  export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
@@ -374,12 +374,12 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
374
374
  /**
375
375
  * Returns the specified entity record's edits.
376
376
  *
377
- * @param {Object} state State tree.
378
- * @param {string} kind Entity kind.
379
- * @param {string} name Entity name.
380
- * @param {number} recordId Record ID.
377
+ * @param state State tree.
378
+ * @param kind Entity kind.
379
+ * @param name Entity name.
380
+ * @param recordId Record ID.
381
381
  *
382
- * @return {Object?} The entity record's edits.
382
+ * @return The entity record's edits.
383
383
  */
384
384
 
385
385
  export function getEntityRecordEdits(state, kind, name, recordId) {
@@ -392,12 +392,12 @@ export function getEntityRecordEdits(state, kind, name, recordId) {
392
392
  * are not considered for change detection.
393
393
  * They are defined in the entity's config.
394
394
  *
395
- * @param {Object} state State tree.
396
- * @param {string} kind Entity kind.
397
- * @param {string} name Entity name.
398
- * @param {number} recordId Record ID.
395
+ * @param state State tree.
396
+ * @param kind Entity kind.
397
+ * @param name Entity name.
398
+ * @param recordId Record ID.
399
399
  *
400
- * @return {Object?} The entity record's non transient edits.
400
+ * @return The entity record's non transient edits.
401
401
  */
402
402
 
403
403
  export const getEntityRecordNonTransientEdits = createSelector((state, kind, name, recordId) => {
@@ -422,12 +422,12 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
422
422
  * Returns true if the specified entity record has edits,
423
423
  * and false otherwise.
424
424
  *
425
- * @param {Object} state State tree.
426
- * @param {string} kind Entity kind.
427
- * @param {string} name Entity name.
428
- * @param {number|string} recordId Record ID.
425
+ * @param state State tree.
426
+ * @param kind Entity kind.
427
+ * @param name Entity name.
428
+ * @param recordId Record ID.
429
429
  *
430
- * @return {boolean} Whether the entity record has edits or not.
430
+ * @return Whether the entity record has edits or not.
431
431
  */
432
432
 
433
433
  export function hasEditsForEntityRecord(state, kind, name, recordId) {
@@ -436,12 +436,12 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
436
436
  /**
437
437
  * Returns the specified entity record, merged with its edits.
438
438
  *
439
- * @param {Object} state State tree.
440
- * @param {string} kind Entity kind.
441
- * @param {string} name Entity name.
442
- * @param {number|string} recordId Record ID.
439
+ * @param state State tree.
440
+ * @param kind Entity kind.
441
+ * @param name Entity name.
442
+ * @param recordId Record ID.
443
443
  *
444
- * @return {Object?} The entity record, merged with its edits.
444
+ * @return The entity record, merged with its edits.
445
445
  */
446
446
 
447
447
  export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
@@ -455,12 +455,12 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
455
455
  /**
456
456
  * Returns true if the specified entity record is autosaving, and false otherwise.
457
457
  *
458
- * @param {Object} state State tree.
459
- * @param {string} kind Entity kind.
460
- * @param {string} name Entity name.
461
- * @param {number} recordId Record ID.
458
+ * @param state State tree.
459
+ * @param kind Entity kind.
460
+ * @param name Entity name.
461
+ * @param recordId Record ID.
462
462
  *
463
- * @return {boolean} Whether the entity record is autosaving or not.
463
+ * @return Whether the entity record is autosaving or not.
464
464
  */
465
465
 
466
466
  export function isAutosavingEntityRecord(state, kind, name, recordId) {
@@ -473,12 +473,12 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
473
473
  /**
474
474
  * Returns true if the specified entity record is saving, and false otherwise.
475
475
  *
476
- * @param {Object} state State tree.
477
- * @param {string} kind Entity kind.
478
- * @param {string} name Entity name.
479
- * @param {number|string} recordId Record ID.
476
+ * @param state State tree.
477
+ * @param kind Entity kind.
478
+ * @param name Entity name.
479
+ * @param recordId Record ID.
480
480
  *
481
- * @return {boolean} Whether the entity record is saving or not.
481
+ * @return Whether the entity record is saving or not.
482
482
  */
483
483
 
484
484
  export function isSavingEntityRecord(state, kind, name, recordId) {
@@ -487,12 +487,12 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
487
487
  /**
488
488
  * Returns true if the specified entity record is deleting, and false otherwise.
489
489
  *
490
- * @param {Object} state State tree.
491
- * @param {string} kind Entity kind.
492
- * @param {string} name Entity name.
493
- * @param {number} recordId Record ID.
490
+ * @param state State tree.
491
+ * @param kind Entity kind.
492
+ * @param name Entity name.
493
+ * @param recordId Record ID.
494
494
  *
495
- * @return {boolean} Whether the entity record is deleting or not.
495
+ * @return Whether the entity record is deleting or not.
496
496
  */
497
497
 
498
498
  export function isDeletingEntityRecord(state, kind, name, recordId) {
@@ -501,12 +501,12 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
501
501
  /**
502
502
  * Returns the specified entity record's last save error.
503
503
  *
504
- * @param {Object} state State tree.
505
- * @param {string} kind Entity kind.
506
- * @param {string} name Entity name.
507
- * @param {number} recordId Record ID.
504
+ * @param state State tree.
505
+ * @param kind Entity kind.
506
+ * @param name Entity name.
507
+ * @param recordId Record ID.
508
508
  *
509
- * @return {Object?} The entity record's save error.
509
+ * @return The entity record's save error.
510
510
  */
511
511
 
512
512
  export function getLastEntitySaveError(state, kind, name, recordId) {
@@ -515,12 +515,12 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
515
515
  /**
516
516
  * Returns the specified entity record's last delete error.
517
517
  *
518
- * @param {Object} state State tree.
519
- * @param {string} kind Entity kind.
520
- * @param {string} name Entity name.
521
- * @param {number} recordId Record ID.
518
+ * @param state State tree.
519
+ * @param kind Entity kind.
520
+ * @param name Entity name.
521
+ * @param recordId Record ID.
522
522
  *
523
- * @return {Object?} The entity record's save error.
523
+ * @return The entity record's save error.
524
524
  */
525
525
 
526
526
  export function getLastEntityDeleteError(state, kind, name, recordId) {
@@ -533,9 +533,9 @@ export function getLastEntityDeleteError(state, kind, name, recordId) {
533
533
  * of the history stack we are at. 0 is the
534
534
  * last edit, -1 is the second last, and so on.
535
535
  *
536
- * @param {Object} state State tree.
536
+ * @param state State tree.
537
537
  *
538
- * @return {number} The current undo offset.
538
+ * @return The current undo offset.
539
539
  */
540
540
 
541
541
  function getCurrentUndoOffset(state) {
@@ -545,9 +545,9 @@ function getCurrentUndoOffset(state) {
545
545
  * Returns the previous edit from the current undo offset
546
546
  * for the entity records edits history, if any.
547
547
  *
548
- * @param {Object} state State tree.
548
+ * @param state State tree.
549
549
  *
550
- * @return {Object?} The edit.
550
+ * @return The edit.
551
551
  */
552
552
 
553
553
 
@@ -558,9 +558,9 @@ export function getUndoEdit(state) {
558
558
  * Returns the next edit from the current undo offset
559
559
  * for the entity records edits history, if any.
560
560
  *
561
- * @param {Object} state State tree.
561
+ * @param state State tree.
562
562
  *
563
- * @return {Object?} The edit.
563
+ * @return The edit.
564
564
  */
565
565
 
566
566
  export function getRedoEdit(state) {
@@ -570,9 +570,9 @@ export function getRedoEdit(state) {
570
570
  * Returns true if there is a previous edit from the current undo offset
571
571
  * for the entity records edits history, and false otherwise.
572
572
  *
573
- * @param {Object} state State tree.
573
+ * @param state State tree.
574
574
  *
575
- * @return {boolean} Whether there is a previous edit or not.
575
+ * @return Whether there is a previous edit or not.
576
576
  */
577
577
 
578
578
  export function hasUndo(state) {
@@ -582,9 +582,9 @@ export function hasUndo(state) {
582
582
  * Returns true if there is a next edit from the current undo offset
583
583
  * for the entity records edits history, and false otherwise.
584
584
  *
585
- * @param {Object} state State tree.
585
+ * @param state State tree.
586
586
  *
587
- * @return {boolean} Whether there is a next edit or not.
587
+ * @return Whether there is a next edit or not.
588
588
  */
589
589
 
590
590
  export function hasRedo(state) {
@@ -593,9 +593,9 @@ export function hasRedo(state) {
593
593
  /**
594
594
  * Return the current theme.
595
595
  *
596
- * @param {Object} state Data state.
596
+ * @param state Data state.
597
597
  *
598
- * @return {Object} The current theme.
598
+ * @return The current theme.
599
599
  */
600
600
 
601
601
  export function getCurrentTheme(state) {
@@ -604,9 +604,9 @@ export function getCurrentTheme(state) {
604
604
  /**
605
605
  * Return the ID of the current global styles object.
606
606
  *
607
- * @param {Object} state Data state.
607
+ * @param state Data state.
608
608
  *
609
- * @return {string} The current global styles ID.
609
+ * @return The current global styles ID.
610
610
  */
611
611
 
612
612
  export function __experimentalGetCurrentGlobalStylesId(state) {
@@ -615,9 +615,9 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
615
615
  /**
616
616
  * Return theme supports data in the index.
617
617
  *
618
- * @param {Object} state Data state.
618
+ * @param state Data state.
619
619
  *
620
- * @return {*} Index data.
620
+ * @return Index data.
621
621
  */
622
622
 
623
623
  export function getThemeSupports(state) {
@@ -628,10 +628,10 @@ export function getThemeSupports(state) {
628
628
  /**
629
629
  * Returns the embed preview for the given URL.
630
630
  *
631
- * @param {Object} state Data state.
632
- * @param {string} url Embedded URL.
631
+ * @param state Data state.
632
+ * @param url Embedded URL.
633
633
  *
634
- * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
634
+ * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
635
635
  */
636
636
 
637
637
  export function getEmbedPreview(state, url) {
@@ -644,10 +644,10 @@ export function getEmbedPreview(state, url) {
644
644
  * We need to be able to determine if a URL is embeddable or not, based on what we
645
645
  * get back from the oEmbed preview API.
646
646
  *
647
- * @param {Object} state Data state.
648
- * @param {string} url Embedded URL.
647
+ * @param state Data state.
648
+ * @param url Embedded URL.
649
649
  *
650
- * @return {boolean} Is the preview for the URL an oEmbed link fallback.
650
+ * @return Is the preview for the URL an oEmbed link fallback.
651
651
  */
652
652
 
653
653
  export function isPreviewEmbedFallback(state, url) {
@@ -669,12 +669,12 @@ export function isPreviewEmbedFallback(state, url) {
669
669
  *
670
670
  * https://developer.wordpress.org/rest-api/reference/
671
671
  *
672
- * @param {Object} state Data state.
673
- * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'.
674
- * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.
675
- * @param {string=} id Optional ID of the rest resource to check.
672
+ * @param state Data state.
673
+ * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
674
+ * @param resource REST resource to check, e.g. 'media' or 'posts'.
675
+ * @param id Optional ID of the rest resource to check.
676
676
  *
677
- * @return {boolean|undefined} Whether or not the user can perform the action,
677
+ * @return Whether or not the user can perform the action,
678
678
  * or `undefined` if the OPTIONS request is still being made.
679
679
  */
680
680
 
@@ -690,11 +690,11 @@ export function canUser(state, action, resource, id) {
690
690
  *
691
691
  * https://developer.wordpress.org/rest-api/reference/
692
692
  *
693
- * @param {Object} state Data state.
694
- * @param {string} kind Entity kind.
695
- * @param {string} name Entity name.
696
- * @param {string} recordId Record's id.
697
- * @return {boolean|undefined} Whether or not the user can edit,
693
+ * @param state Data state.
694
+ * @param kind Entity kind.
695
+ * @param name Entity name.
696
+ * @param recordId Record's id.
697
+ * @return Whether or not the user can edit,
698
698
  * or `undefined` if the OPTIONS request is still being made.
699
699
  */
700
700
 
@@ -714,11 +714,11 @@ export function canUserEditEntityRecord(state, kind, name, recordId) {
714
714
  * May return multiple autosaves since the backend stores one autosave per
715
715
  * author for each post.
716
716
  *
717
- * @param {Object} state State tree.
718
- * @param {string} postType The type of the parent post.
719
- * @param {number} postId The id of the parent post.
717
+ * @param state State tree.
718
+ * @param postType The type of the parent post.
719
+ * @param postId The id of the parent post.
720
720
  *
721
- * @return {?Array} An array of autosaves for the post, or undefined if there is none.
721
+ * @return An array of autosaves for the post, or undefined if there is none.
722
722
  */
723
723
 
724
724
  export function getAutosaves(state, postType, postId) {
@@ -727,12 +727,12 @@ export function getAutosaves(state, postType, postId) {
727
727
  /**
728
728
  * Returns the autosave for the post and author.
729
729
  *
730
- * @param {Object} state State tree.
731
- * @param {string} postType The type of the parent post.
732
- * @param {number} postId The id of the parent post.
733
- * @param {number} authorId The id of the author.
730
+ * @param state State tree.
731
+ * @param postType The type of the parent post.
732
+ * @param postId The id of the parent post.
733
+ * @param authorId The id of the author.
734
734
  *
735
- * @return {?Object} The autosave for the post and author.
735
+ * @return The autosave for the post and author.
736
736
  */
737
737
 
738
738
  export function getAutosave(state, postType, postId, authorId) {
@@ -748,11 +748,11 @@ export function getAutosave(state, postType, postId, authorId) {
748
748
  /**
749
749
  * Returns true if the REST request for autosaves has completed.
750
750
  *
751
- * @param {Object} state State tree.
752
- * @param {string} postType The type of the parent post.
753
- * @param {number} postId The id of the parent post.
751
+ * @param state State tree.
752
+ * @param postType The type of the parent post.
753
+ * @param postId The id of the parent post.
754
754
  *
755
- * @return {boolean} True if the REST request was completed. False otherwise.
755
+ * @return True if the REST request was completed. False otherwise.
756
756
  */
757
757
 
758
758
  export const hasFetchedAutosaves = createRegistrySelector(select => (state, postType, postId) => {
@@ -772,19 +772,20 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
772
772
  * );
773
773
  * ```
774
774
  *
775
- * @param {Object} state Editor state.
775
+ * @param state Editor state.
776
776
  *
777
- * @return {*} A value whose reference will change only when an edit occurs.
777
+ * @return A value whose reference will change only when an edit occurs.
778
778
  */
779
779
 
780
- export const getReferenceByDistinctEdits = createSelector(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
780
+ export const getReferenceByDistinctEdits = createSelector( // This unused state argument is listed here for the documentation generating tool (docgen).
781
+ state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
781
782
  /**
782
783
  * Retrieve the frontend template used for a given link.
783
784
  *
784
- * @param {Object} state Editor state.
785
- * @param {string} link Link.
785
+ * @param state Editor state.
786
+ * @param link Link.
786
787
  *
787
- * @return {Object?} The template record.
788
+ * @return The template record.
788
789
  */
789
790
 
790
791
  export function __experimentalGetTemplateForLink(state, link) {
@@ -802,9 +803,9 @@ export function __experimentalGetTemplateForLink(state, link) {
802
803
  /**
803
804
  * Retrieve the current theme's base global styles
804
805
  *
805
- * @param {Object} state Editor state.
806
+ * @param state Editor state.
806
807
  *
807
- * @return {Object|null} The Global Styles object.
808
+ * @return The Global Styles object.
808
809
  */
809
810
 
810
811
  export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
@@ -819,9 +820,9 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
819
820
  /**
820
821
  * Return the ID of the current global styles object.
821
822
  *
822
- * @param {Object} state Data state.
823
+ * @param state Data state.
823
824
  *
824
- * @return {string|null} The current global styles ID.
825
+ * @return The current global styles ID.
825
826
  */
826
827
 
827
828
  export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
@@ -836,9 +837,9 @@ export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
836
837
  /**
837
838
  * Retrieve the list of registered block patterns.
838
839
  *
839
- * @param {Object} state Data state.
840
+ * @param state Data state.
840
841
  *
841
- * @return {Array} Block pattern list.
842
+ * @return Block pattern list.
842
843
  */
843
844
 
844
845
  export function getBlockPatterns(state) {
@@ -847,9 +848,9 @@ export function getBlockPatterns(state) {
847
848
  /**
848
849
  * Retrieve the list of registered block pattern categories.
849
850
  *
850
- * @param {Object} state Data state.
851
+ * @param state Data state.
851
852
  *
852
- * @return {Array} Block pattern category list.
853
+ * @return Block pattern category list.
853
854
  */
854
855
 
855
856
  export function getBlockPatternCategories(state) {