@wordpress/core-data 4.6.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +209 -119
  3. package/build/actions.js.map +1 -1
  4. package/build/batch/create-batch.js +1 -1
  5. package/build/batch/create-batch.js.map +1 -1
  6. package/build/entities.js +49 -35
  7. package/build/entities.js.map +1 -1
  8. package/build/entity-provider.js.map +1 -1
  9. package/build/entity-types/entities.js +6 -0
  10. package/build/entity-types/entities.js.map +1 -0
  11. package/build/hooks/constants.js +0 -2
  12. package/build/hooks/constants.js.map +1 -1
  13. package/build/hooks/index.js +38 -0
  14. package/build/hooks/index.js.map +1 -0
  15. package/build/hooks/use-entity-record.js +22 -8
  16. package/build/hooks/use-entity-record.js.map +1 -1
  17. package/build/hooks/use-entity-records.js +21 -8
  18. package/build/hooks/use-entity-records.js.map +1 -1
  19. package/build/hooks/use-query-select.js.map +1 -1
  20. package/build/index.js +17 -21
  21. package/build/index.js.map +1 -1
  22. package/build/queried-data/selectors.js.map +1 -1
  23. package/build/resolvers.js.map +1 -1
  24. package/build/selectors.js +206 -169
  25. package/build/selectors.js.map +1 -1
  26. package/build/utils/forward-resolver.js.map +1 -1
  27. package/build/utils/on-sub-key.js.map +1 -1
  28. package/build/utils/with-weak-map-cache.js +1 -7
  29. package/build/utils/with-weak-map-cache.js.map +1 -1
  30. package/build-module/actions.js.map +1 -1
  31. package/build-module/batch/create-batch.js +2 -2
  32. package/build-module/batch/create-batch.js.map +1 -1
  33. package/build-module/entities.js +49 -35
  34. package/build-module/entities.js.map +1 -1
  35. package/build-module/entity-provider.js.map +1 -1
  36. package/build-module/entity-types/entities.js +2 -0
  37. package/build-module/entity-types/entities.js.map +1 -0
  38. package/build-module/hooks/constants.js +0 -1
  39. package/build-module/hooks/constants.js.map +1 -1
  40. package/build-module/hooks/index.js +3 -0
  41. package/build-module/hooks/index.js.map +1 -0
  42. package/build-module/hooks/use-entity-record.js +18 -7
  43. package/build-module/hooks/use-entity-record.js.map +1 -1
  44. package/build-module/hooks/use-entity-records.js +17 -7
  45. package/build-module/hooks/use-entity-records.js.map +1 -1
  46. package/build-module/hooks/use-query-select.js.map +1 -1
  47. package/build-module/index.js +2 -3
  48. package/build-module/index.js.map +1 -1
  49. package/build-module/queried-data/selectors.js.map +1 -1
  50. package/build-module/resolvers.js.map +1 -1
  51. package/build-module/selectors.js +203 -166
  52. package/build-module/selectors.js.map +1 -1
  53. package/build-module/utils/forward-resolver.js.map +1 -1
  54. package/build-module/utils/on-sub-key.js.map +1 -1
  55. package/build-module/utils/with-weak-map-cache.js +1 -6
  56. package/build-module/utils/with-weak-map-cache.js.map +1 -1
  57. package/package.json +12 -12
  58. package/src/actions.js +389 -372
  59. package/src/batch/create-batch.js +2 -2
  60. package/src/entities.ts +357 -135
  61. package/src/entity-provider.js +4 -6
  62. package/src/entity-types/attachment.ts +4 -3
  63. package/src/entity-types/comment.ts +4 -3
  64. package/src/entity-types/entities.ts +130 -0
  65. package/src/entity-types/index.ts +115 -20
  66. package/src/entity-types/menu-location.ts +4 -3
  67. package/src/entity-types/nav-menu-item.ts +4 -3
  68. package/src/entity-types/nav-menu.ts +3 -3
  69. package/src/entity-types/page.ts +3 -3
  70. package/src/entity-types/plugin.ts +3 -3
  71. package/src/entity-types/post.ts +3 -3
  72. package/src/entity-types/settings.ts +3 -3
  73. package/src/entity-types/sidebar.ts +4 -3
  74. package/src/entity-types/taxonomy.ts +4 -3
  75. package/src/entity-types/theme.ts +3 -3
  76. package/src/entity-types/type.ts +3 -3
  77. package/src/entity-types/user.ts +3 -3
  78. package/src/entity-types/widget-type.ts +4 -3
  79. package/src/entity-types/widget.ts +3 -3
  80. package/src/entity-types/wp-template-part.ts +4 -3
  81. package/src/entity-types/wp-template.ts +4 -3
  82. package/src/fetch/test/__experimental-fetch-link-suggestions.js +2 -4
  83. package/src/hooks/constants.ts +1 -2
  84. package/src/hooks/index.ts +8 -0
  85. package/src/hooks/test/use-query-select.js +4 -2
  86. package/src/hooks/use-entity-record.ts +31 -9
  87. package/src/hooks/use-entity-records.ts +28 -30
  88. package/src/hooks/use-query-select.ts +26 -24
  89. package/src/index.js +2 -3
  90. package/src/locks/test/selectors.js +2 -1
  91. package/src/queried-data/selectors.js +2 -8
  92. package/src/resolvers.js +344 -325
  93. package/src/selectors.ts +639 -296
  94. package/src/test/resolvers.js +1 -3
  95. package/src/test/selectors.js +1 -2
  96. package/src/utils/forward-resolver.js +6 -5
  97. package/src/utils/on-sub-key.js +20 -20
  98. package/src/utils/with-weak-map-cache.js +1 -6
@@ -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) {
@@ -148,20 +148,38 @@ export function getEntityConfig(state, kind, name) {
148
148
  name
149
149
  });
150
150
  }
151
+ /**
152
+ * GetEntityRecord is declared as an *interface*, but it actually describes
153
+ * the specifies the getEntityRecord *function* signature. It may seem unusual,
154
+ * but it's just how TypeScript implements function overloading.
155
+ *
156
+ * More accurately, GetEntityRecord distinguishes between two different signatures
157
+ * the getEntityRecord selector has:
158
+ *
159
+ * 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >
160
+ * 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>
161
+ *
162
+ * Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
163
+ * we can't use a single function signature with a return type such as:
164
+ *
165
+ * Fields extends undefined
166
+ * ? EntityRecordOf< K, N, C >
167
+ * : Partial< EntityRecordOf< K, N, C > >
168
+ */
169
+
151
170
  /**
152
171
  * Returns the Entity's record object by key. Returns `null` if the value is not
153
172
  * yet received, undefined if the value entity is known to not exist, or the
154
173
  * entity object if it exists and is received.
155
174
  *
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.
175
+ * @param state State tree
176
+ * @param kind Entity kind.
177
+ * @param name Entity name.
178
+ * @param key Record's key
179
+ * @param query Optional query.
161
180
  *
162
- * @return {Object|undefined} Record.
181
+ * @return Record.
163
182
  */
164
-
165
183
  export const getEntityRecord = createSelector((state, kind, name, key, query) => {
166
184
  var _query$context, _queriedState$items$c;
167
185
 
@@ -211,12 +229,12 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
211
229
  /**
212
230
  * 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
231
  *
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
232
+ * @param state State tree
233
+ * @param kind Entity kind.
234
+ * @param name Entity name.
235
+ * @param key Record's key
218
236
  *
219
- * @return {Object|null} Record.
237
+ * @return Record.
220
238
  */
221
239
 
222
240
  export function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
@@ -226,12 +244,12 @@ export function __experimentalGetEntityRecordNoResolver(state, kind, name, key)
226
244
  * Returns the entity's record object by key,
227
245
  * with its attributes mapped to their raw values.
228
246
  *
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.
247
+ * @param state State tree.
248
+ * @param kind Entity kind.
249
+ * @param name Entity name.
250
+ * @param key Record's key.
233
251
  *
234
- * @return {Object?} Object with the entity's raw attributes.
252
+ * @return Object with the entity's raw attributes.
235
253
  */
236
254
 
237
255
  export const getRawEntityRecord = createSelector((state, kind, name, key) => {
@@ -258,29 +276,47 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
258
276
  * Returns true if records have been received for the given set of parameters,
259
277
  * or false otherwise.
260
278
  *
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.
279
+ * @param state State tree
280
+ * @param kind Entity kind.
281
+ * @param name Entity name.
282
+ * @param query Optional terms query.
265
283
  *
266
- * @return {boolean} Whether entity records have been received.
284
+ * @return Whether entity records have been received.
267
285
  */
268
286
 
269
287
  export function hasEntityRecords(state, kind, name, query) {
270
288
  return Array.isArray(getEntityRecords(state, kind, name, query));
271
289
  }
272
290
  /**
273
- * Returns the Entity's records.
291
+ * GetEntityRecord is declared as an *interface*, but it actually describes
292
+ * the specifies the getEntityRecord *function* signature. It may seem unusual,
293
+ * but it's just how TypeScript implements function overloading.
274
294
  *
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.
295
+ * More accurately, GetEntityRecord distinguishes between two different signatures
296
+ * the getEntityRecord selector has:
279
297
  *
280
- * @return {?Array} Records.
298
+ * 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >[]
299
+ * 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>[]
300
+ *
301
+ * Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
302
+ * we can't use a single function signature with a return type such as:
303
+ *
304
+ * Fields extends undefined
305
+ * ? EntityRecordOf< K, N, C >[]
306
+ * : Partial< EntityRecordOf< K, N, C > >[]
281
307
  */
282
308
 
283
- export function getEntityRecords(state, kind, name, query) {
309
+ /**
310
+ * Returns the Entity's records.
311
+ *
312
+ * @param state State tree
313
+ * @param kind Entity kind.
314
+ * @param name Entity name.
315
+ * @param query Optional terms query.
316
+ *
317
+ * @return Records.
318
+ */
319
+ export const getEntityRecords = (state, kind, name, query) => {
284
320
  // Queried data state is prepopulated for all known entities. If this is not
285
321
  // assigned for the given parameters, then it is known to not exist.
286
322
  const queriedState = get(state.entities.records, [kind, name, 'queriedData']);
@@ -290,15 +326,15 @@ export function getEntityRecords(state, kind, name, query) {
290
326
  }
291
327
 
292
328
  return getQueriedItems(queriedState, query);
293
- }
329
+ };
330
+
294
331
  /**
295
332
  * Returns the list of dirty entity records.
296
333
  *
297
- * @param {Object} state State tree.
334
+ * @param state State tree.
298
335
  *
299
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records
336
+ * @return The list of updated records
300
337
  */
301
-
302
338
  export const __experimentalGetDirtyEntityRecords = createSelector(state => {
303
339
  const {
304
340
  entities: {
@@ -335,9 +371,9 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
335
371
  /**
336
372
  * Returns the list of entities currently being saved.
337
373
  *
338
- * @param {Object} state State tree.
374
+ * @param state State tree.
339
375
  *
340
- * @return {[{ title: string, key: string, name: string, kind: string }]} The list of records being saved.
376
+ * @return The list of records being saved.
341
377
  */
342
378
 
343
379
  export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
@@ -374,12 +410,12 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
374
410
  /**
375
411
  * Returns the specified entity record's edits.
376
412
  *
377
- * @param {Object} state State tree.
378
- * @param {string} kind Entity kind.
379
- * @param {string} name Entity name.
380
- * @param {number} recordId Record ID.
413
+ * @param state State tree.
414
+ * @param kind Entity kind.
415
+ * @param name Entity name.
416
+ * @param recordId Record ID.
381
417
  *
382
- * @return {Object?} The entity record's edits.
418
+ * @return The entity record's edits.
383
419
  */
384
420
 
385
421
  export function getEntityRecordEdits(state, kind, name, recordId) {
@@ -392,12 +428,12 @@ export function getEntityRecordEdits(state, kind, name, recordId) {
392
428
  * are not considered for change detection.
393
429
  * They are defined in the entity's config.
394
430
  *
395
- * @param {Object} state State tree.
396
- * @param {string} kind Entity kind.
397
- * @param {string} name Entity name.
398
- * @param {number} recordId Record ID.
431
+ * @param state State tree.
432
+ * @param kind Entity kind.
433
+ * @param name Entity name.
434
+ * @param recordId Record ID.
399
435
  *
400
- * @return {Object?} The entity record's non transient edits.
436
+ * @return The entity record's non transient edits.
401
437
  */
402
438
 
403
439
  export const getEntityRecordNonTransientEdits = createSelector((state, kind, name, recordId) => {
@@ -422,12 +458,12 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
422
458
  * Returns true if the specified entity record has edits,
423
459
  * and false otherwise.
424
460
  *
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.
461
+ * @param state State tree.
462
+ * @param kind Entity kind.
463
+ * @param name Entity name.
464
+ * @param recordId Record ID.
429
465
  *
430
- * @return {boolean} Whether the entity record has edits or not.
466
+ * @return Whether the entity record has edits or not.
431
467
  */
432
468
 
433
469
  export function hasEditsForEntityRecord(state, kind, name, recordId) {
@@ -436,12 +472,12 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
436
472
  /**
437
473
  * Returns the specified entity record, merged with its edits.
438
474
  *
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.
475
+ * @param state State tree.
476
+ * @param kind Entity kind.
477
+ * @param name Entity name.
478
+ * @param recordId Record ID.
443
479
  *
444
- * @return {Object?} The entity record, merged with its edits.
480
+ * @return The entity record, merged with its edits.
445
481
  */
446
482
 
447
483
  export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
@@ -455,12 +491,12 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
455
491
  /**
456
492
  * Returns true if the specified entity record is autosaving, and false otherwise.
457
493
  *
458
- * @param {Object} state State tree.
459
- * @param {string} kind Entity kind.
460
- * @param {string} name Entity name.
461
- * @param {number} recordId Record ID.
494
+ * @param state State tree.
495
+ * @param kind Entity kind.
496
+ * @param name Entity name.
497
+ * @param recordId Record ID.
462
498
  *
463
- * @return {boolean} Whether the entity record is autosaving or not.
499
+ * @return Whether the entity record is autosaving or not.
464
500
  */
465
501
 
466
502
  export function isAutosavingEntityRecord(state, kind, name, recordId) {
@@ -473,12 +509,12 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
473
509
  /**
474
510
  * Returns true if the specified entity record is saving, and false otherwise.
475
511
  *
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.
512
+ * @param state State tree.
513
+ * @param kind Entity kind.
514
+ * @param name Entity name.
515
+ * @param recordId Record ID.
480
516
  *
481
- * @return {boolean} Whether the entity record is saving or not.
517
+ * @return Whether the entity record is saving or not.
482
518
  */
483
519
 
484
520
  export function isSavingEntityRecord(state, kind, name, recordId) {
@@ -487,12 +523,12 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
487
523
  /**
488
524
  * Returns true if the specified entity record is deleting, and false otherwise.
489
525
  *
490
- * @param {Object} state State tree.
491
- * @param {string} kind Entity kind.
492
- * @param {string} name Entity name.
493
- * @param {number} recordId Record ID.
526
+ * @param state State tree.
527
+ * @param kind Entity kind.
528
+ * @param name Entity name.
529
+ * @param recordId Record ID.
494
530
  *
495
- * @return {boolean} Whether the entity record is deleting or not.
531
+ * @return Whether the entity record is deleting or not.
496
532
  */
497
533
 
498
534
  export function isDeletingEntityRecord(state, kind, name, recordId) {
@@ -501,12 +537,12 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
501
537
  /**
502
538
  * Returns the specified entity record's last save error.
503
539
  *
504
- * @param {Object} state State tree.
505
- * @param {string} kind Entity kind.
506
- * @param {string} name Entity name.
507
- * @param {number} recordId Record ID.
540
+ * @param state State tree.
541
+ * @param kind Entity kind.
542
+ * @param name Entity name.
543
+ * @param recordId Record ID.
508
544
  *
509
- * @return {Object?} The entity record's save error.
545
+ * @return The entity record's save error.
510
546
  */
511
547
 
512
548
  export function getLastEntitySaveError(state, kind, name, recordId) {
@@ -515,12 +551,12 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
515
551
  /**
516
552
  * Returns the specified entity record's last delete error.
517
553
  *
518
- * @param {Object} state State tree.
519
- * @param {string} kind Entity kind.
520
- * @param {string} name Entity name.
521
- * @param {number} recordId Record ID.
554
+ * @param state State tree.
555
+ * @param kind Entity kind.
556
+ * @param name Entity name.
557
+ * @param recordId Record ID.
522
558
  *
523
- * @return {Object?} The entity record's save error.
559
+ * @return The entity record's save error.
524
560
  */
525
561
 
526
562
  export function getLastEntityDeleteError(state, kind, name, recordId) {
@@ -533,9 +569,9 @@ export function getLastEntityDeleteError(state, kind, name, recordId) {
533
569
  * of the history stack we are at. 0 is the
534
570
  * last edit, -1 is the second last, and so on.
535
571
  *
536
- * @param {Object} state State tree.
572
+ * @param state State tree.
537
573
  *
538
- * @return {number} The current undo offset.
574
+ * @return The current undo offset.
539
575
  */
540
576
 
541
577
  function getCurrentUndoOffset(state) {
@@ -545,9 +581,9 @@ function getCurrentUndoOffset(state) {
545
581
  * Returns the previous edit from the current undo offset
546
582
  * for the entity records edits history, if any.
547
583
  *
548
- * @param {Object} state State tree.
584
+ * @param state State tree.
549
585
  *
550
- * @return {Object?} The edit.
586
+ * @return The edit.
551
587
  */
552
588
 
553
589
 
@@ -558,9 +594,9 @@ export function getUndoEdit(state) {
558
594
  * Returns the next edit from the current undo offset
559
595
  * for the entity records edits history, if any.
560
596
  *
561
- * @param {Object} state State tree.
597
+ * @param state State tree.
562
598
  *
563
- * @return {Object?} The edit.
599
+ * @return The edit.
564
600
  */
565
601
 
566
602
  export function getRedoEdit(state) {
@@ -570,9 +606,9 @@ export function getRedoEdit(state) {
570
606
  * Returns true if there is a previous edit from the current undo offset
571
607
  * for the entity records edits history, and false otherwise.
572
608
  *
573
- * @param {Object} state State tree.
609
+ * @param state State tree.
574
610
  *
575
- * @return {boolean} Whether there is a previous edit or not.
611
+ * @return Whether there is a previous edit or not.
576
612
  */
577
613
 
578
614
  export function hasUndo(state) {
@@ -582,9 +618,9 @@ export function hasUndo(state) {
582
618
  * Returns true if there is a next edit from the current undo offset
583
619
  * for the entity records edits history, and false otherwise.
584
620
  *
585
- * @param {Object} state State tree.
621
+ * @param state State tree.
586
622
  *
587
- * @return {boolean} Whether there is a next edit or not.
623
+ * @return Whether there is a next edit or not.
588
624
  */
589
625
 
590
626
  export function hasRedo(state) {
@@ -593,9 +629,9 @@ export function hasRedo(state) {
593
629
  /**
594
630
  * Return the current theme.
595
631
  *
596
- * @param {Object} state Data state.
632
+ * @param state Data state.
597
633
  *
598
- * @return {Object} The current theme.
634
+ * @return The current theme.
599
635
  */
600
636
 
601
637
  export function getCurrentTheme(state) {
@@ -604,9 +640,9 @@ export function getCurrentTheme(state) {
604
640
  /**
605
641
  * Return the ID of the current global styles object.
606
642
  *
607
- * @param {Object} state Data state.
643
+ * @param state Data state.
608
644
  *
609
- * @return {string} The current global styles ID.
645
+ * @return The current global styles ID.
610
646
  */
611
647
 
612
648
  export function __experimentalGetCurrentGlobalStylesId(state) {
@@ -615,9 +651,9 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
615
651
  /**
616
652
  * Return theme supports data in the index.
617
653
  *
618
- * @param {Object} state Data state.
654
+ * @param state Data state.
619
655
  *
620
- * @return {*} Index data.
656
+ * @return Index data.
621
657
  */
622
658
 
623
659
  export function getThemeSupports(state) {
@@ -628,10 +664,10 @@ export function getThemeSupports(state) {
628
664
  /**
629
665
  * Returns the embed preview for the given URL.
630
666
  *
631
- * @param {Object} state Data state.
632
- * @param {string} url Embedded URL.
667
+ * @param state Data state.
668
+ * @param url Embedded URL.
633
669
  *
634
- * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
670
+ * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
635
671
  */
636
672
 
637
673
  export function getEmbedPreview(state, url) {
@@ -644,10 +680,10 @@ export function getEmbedPreview(state, url) {
644
680
  * We need to be able to determine if a URL is embeddable or not, based on what we
645
681
  * get back from the oEmbed preview API.
646
682
  *
647
- * @param {Object} state Data state.
648
- * @param {string} url Embedded URL.
683
+ * @param state Data state.
684
+ * @param url Embedded URL.
649
685
  *
650
- * @return {boolean} Is the preview for the URL an oEmbed link fallback.
686
+ * @return Is the preview for the URL an oEmbed link fallback.
651
687
  */
652
688
 
653
689
  export function isPreviewEmbedFallback(state, url) {
@@ -669,12 +705,12 @@ export function isPreviewEmbedFallback(state, url) {
669
705
  *
670
706
  * https://developer.wordpress.org/rest-api/reference/
671
707
  *
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.
708
+ * @param state Data state.
709
+ * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
710
+ * @param resource REST resource to check, e.g. 'media' or 'posts'.
711
+ * @param id Optional ID of the rest resource to check.
676
712
  *
677
- * @return {boolean|undefined} Whether or not the user can perform the action,
713
+ * @return Whether or not the user can perform the action,
678
714
  * or `undefined` if the OPTIONS request is still being made.
679
715
  */
680
716
 
@@ -690,11 +726,11 @@ export function canUser(state, action, resource, id) {
690
726
  *
691
727
  * https://developer.wordpress.org/rest-api/reference/
692
728
  *
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,
729
+ * @param state Data state.
730
+ * @param kind Entity kind.
731
+ * @param name Entity name.
732
+ * @param recordId Record's id.
733
+ * @return Whether or not the user can edit,
698
734
  * or `undefined` if the OPTIONS request is still being made.
699
735
  */
700
736
 
@@ -714,11 +750,11 @@ export function canUserEditEntityRecord(state, kind, name, recordId) {
714
750
  * May return multiple autosaves since the backend stores one autosave per
715
751
  * author for each post.
716
752
  *
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.
753
+ * @param state State tree.
754
+ * @param postType The type of the parent post.
755
+ * @param postId The id of the parent post.
720
756
  *
721
- * @return {?Array} An array of autosaves for the post, or undefined if there is none.
757
+ * @return An array of autosaves for the post, or undefined if there is none.
722
758
  */
723
759
 
724
760
  export function getAutosaves(state, postType, postId) {
@@ -727,12 +763,12 @@ export function getAutosaves(state, postType, postId) {
727
763
  /**
728
764
  * Returns the autosave for the post and author.
729
765
  *
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.
766
+ * @param state State tree.
767
+ * @param postType The type of the parent post.
768
+ * @param postId The id of the parent post.
769
+ * @param authorId The id of the author.
734
770
  *
735
- * @return {?Object} The autosave for the post and author.
771
+ * @return The autosave for the post and author.
736
772
  */
737
773
 
738
774
  export function getAutosave(state, postType, postId, authorId) {
@@ -748,11 +784,11 @@ export function getAutosave(state, postType, postId, authorId) {
748
784
  /**
749
785
  * Returns true if the REST request for autosaves has completed.
750
786
  *
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.
787
+ * @param state State tree.
788
+ * @param postType The type of the parent post.
789
+ * @param postId The id of the parent post.
754
790
  *
755
- * @return {boolean} True if the REST request was completed. False otherwise.
791
+ * @return True if the REST request was completed. False otherwise.
756
792
  */
757
793
 
758
794
  export const hasFetchedAutosaves = createRegistrySelector(select => (state, postType, postId) => {
@@ -772,19 +808,20 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
772
808
  * );
773
809
  * ```
774
810
  *
775
- * @param {Object} state Editor state.
811
+ * @param state Editor state.
776
812
  *
777
- * @return {*} A value whose reference will change only when an edit occurs.
813
+ * @return A value whose reference will change only when an edit occurs.
778
814
  */
779
815
 
780
- export const getReferenceByDistinctEdits = createSelector(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
816
+ export const getReferenceByDistinctEdits = createSelector( // This unused state argument is listed here for the documentation generating tool (docgen).
817
+ state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
781
818
  /**
782
819
  * Retrieve the frontend template used for a given link.
783
820
  *
784
- * @param {Object} state Editor state.
785
- * @param {string} link Link.
821
+ * @param state Editor state.
822
+ * @param link Link.
786
823
  *
787
- * @return {Object?} The template record.
824
+ * @return The template record.
788
825
  */
789
826
 
790
827
  export function __experimentalGetTemplateForLink(state, link) {
@@ -802,9 +839,9 @@ export function __experimentalGetTemplateForLink(state, link) {
802
839
  /**
803
840
  * Retrieve the current theme's base global styles
804
841
  *
805
- * @param {Object} state Editor state.
842
+ * @param state Editor state.
806
843
  *
807
- * @return {Object|null} The Global Styles object.
844
+ * @return The Global Styles object.
808
845
  */
809
846
 
810
847
  export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
@@ -819,9 +856,9 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
819
856
  /**
820
857
  * Return the ID of the current global styles object.
821
858
  *
822
- * @param {Object} state Data state.
859
+ * @param state Data state.
823
860
  *
824
- * @return {string|null} The current global styles ID.
861
+ * @return The current global styles ID.
825
862
  */
826
863
 
827
864
  export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
@@ -836,9 +873,9 @@ export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
836
873
  /**
837
874
  * Retrieve the list of registered block patterns.
838
875
  *
839
- * @param {Object} state Data state.
876
+ * @param state Data state.
840
877
  *
841
- * @return {Array} Block pattern list.
878
+ * @return Block pattern list.
842
879
  */
843
880
 
844
881
  export function getBlockPatterns(state) {
@@ -847,9 +884,9 @@ export function getBlockPatterns(state) {
847
884
  /**
848
885
  * Retrieve the list of registered block pattern categories.
849
886
  *
850
- * @param {Object} state Data state.
887
+ * @param state Data state.
851
888
  *
852
- * @return {Array} Block pattern category list.
889
+ * @return Block pattern category list.
853
890
  */
854
891
 
855
892
  export function getBlockPatternCategories(state) {