@wordpress/core-data 4.14.1-next.d6164808d3.0 → 5.0.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.
- package/CHANGELOG.md +7 -1
- package/README.md +73 -61
- package/build/entities.js +31 -46
- package/build/entities.js.map +1 -1
- package/build/hooks/use-entity-record.js +4 -2
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +2 -0
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/hooks/use-query-select.js +5 -2
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/hooks/use-resource-permissions.js +22 -6
- package/build/hooks/use-resource-permissions.js.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/resolvers.js +45 -21
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +9 -46
- package/build/selectors.js.map +1 -1
- package/build-module/entities.js +31 -46
- package/build-module/entities.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +4 -2
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +2 -0
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/hooks/use-query-select.js +4 -1
- package/build-module/hooks/use-query-select.js.map +1 -1
- package/build-module/hooks/use-resource-permissions.js +22 -6
- package/build-module/hooks/use-resource-permissions.js.map +1 -1
- package/build-module/index.js +0 -2
- package/build-module/index.js.map +1 -1
- package/build-module/resolvers.js +45 -21
- package/build-module/resolvers.js.map +1 -1
- package/build-module/selectors.js +7 -44
- package/build-module/selectors.js.map +1 -1
- package/build-types/actions.d.ts +188 -0
- package/build-types/actions.d.ts.map +1 -0
- package/build-types/batch/create-batch.d.ts +71 -0
- package/build-types/batch/create-batch.d.ts.map +1 -0
- package/build-types/batch/default-processor.d.ts +11 -0
- package/build-types/batch/default-processor.d.ts.map +1 -0
- package/build-types/batch/index.d.ts +3 -0
- package/build-types/batch/index.d.ts.map +1 -0
- package/build-types/entities.d.ts +128 -0
- package/build-types/entities.d.ts.map +1 -0
- package/build-types/entity-provider.d.ts +68 -0
- package/build-types/entity-provider.d.ts.map +1 -0
- package/build-types/entity-types/attachment.d.ts +121 -0
- package/build-types/entity-types/attachment.d.ts.map +1 -0
- package/build-types/entity-types/base-entity-records.d.ts +37 -0
- package/build-types/entity-types/base-entity-records.d.ts.map +1 -0
- package/build-types/entity-types/comment.d.ts +82 -0
- package/build-types/entity-types/comment.d.ts.map +1 -0
- package/build-types/entity-types/helpers.d.ts +123 -0
- package/build-types/entity-types/helpers.d.ts.map +1 -0
- package/build-types/entity-types/index.d.ts +64 -0
- package/build-types/entity-types/index.d.ts.map +1 -0
- package/build-types/entity-types/menu-location.d.ts +25 -0
- package/build-types/entity-types/menu-location.d.ts.map +1 -0
- package/build-types/entity-types/nav-menu-item.d.ts +88 -0
- package/build-types/entity-types/nav-menu-item.d.ts.map +1 -0
- package/build-types/entity-types/nav-menu.d.ts +45 -0
- package/build-types/entity-types/nav-menu.d.ts.map +1 -0
- package/build-types/entity-types/page.d.ts +120 -0
- package/build-types/entity-types/page.d.ts.map +1 -0
- package/build-types/entity-types/plugin.d.ts +62 -0
- package/build-types/entity-types/plugin.d.ts.map +1 -0
- package/build-types/entity-types/post.d.ts +128 -0
- package/build-types/entity-types/post.d.ts.map +1 -0
- package/build-types/entity-types/settings.d.ts +89 -0
- package/build-types/entity-types/settings.d.ts.map +1 -0
- package/build-types/entity-types/sidebar.d.ts +55 -0
- package/build-types/entity-types/sidebar.d.ts.map +1 -0
- package/build-types/entity-types/taxonomy.d.ts +83 -0
- package/build-types/entity-types/taxonomy.d.ts.map +1 -0
- package/build-types/entity-types/theme.d.ts +206 -0
- package/build-types/entity-types/theme.d.ts.map +1 -0
- package/build-types/entity-types/type.d.ts +71 -0
- package/build-types/entity-types/type.d.ts.map +1 -0
- package/build-types/entity-types/user.d.ts +93 -0
- package/build-types/entity-types/user.d.ts.map +1 -0
- package/build-types/entity-types/widget-type.d.ts +33 -0
- package/build-types/entity-types/widget-type.d.ts.map +1 -0
- package/build-types/entity-types/widget.d.ts +59 -0
- package/build-types/entity-types/widget.d.ts.map +1 -0
- package/build-types/entity-types/wp-template-part.d.ts +80 -0
- package/build-types/entity-types/wp-template-part.d.ts.map +1 -0
- package/build-types/entity-types/wp-template.d.ts +80 -0
- package/build-types/entity-types/wp-template.d.ts.map +1 -0
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts +139 -0
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -0
- package/build-types/fetch/__experimental-fetch-url-data.d.ts +35 -0
- package/build-types/fetch/__experimental-fetch-url-data.d.ts.map +1 -0
- package/build-types/fetch/index.d.ts +3 -0
- package/build-types/fetch/index.d.ts.map +1 -0
- package/build-types/hooks/constants.d.ts +7 -0
- package/build-types/hooks/constants.d.ts.map +1 -0
- package/build-types/hooks/index.d.ts +4 -0
- package/build-types/hooks/index.d.ts.map +1 -0
- package/build-types/hooks/memoize.d.ts +3 -0
- package/build-types/hooks/memoize.d.ts.map +1 -0
- package/build-types/hooks/use-entity-record.d.ts +124 -0
- package/build-types/hooks/use-entity-record.d.ts.map +1 -0
- package/build-types/hooks/use-entity-records.d.ts +49 -0
- package/build-types/hooks/use-entity-records.d.ts.map +1 -0
- package/build-types/hooks/use-query-select.d.ts +46 -0
- package/build-types/hooks/use-query-select.d.ts.map +1 -0
- package/build-types/hooks/use-resource-permissions.d.ts +99 -0
- package/build-types/hooks/use-resource-permissions.d.ts.map +1 -0
- package/build-types/index.d.ts +131 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/locks/actions.d.ts +7 -0
- package/build-types/locks/actions.d.ts.map +1 -0
- package/build-types/locks/engine.d.ts +5 -0
- package/build-types/locks/engine.d.ts.map +1 -0
- package/build-types/locks/reducer.d.ts +10 -0
- package/build-types/locks/reducer.d.ts.map +1 -0
- package/build-types/locks/selectors.d.ts +5 -0
- package/build-types/locks/selectors.d.ts.map +1 -0
- package/build-types/locks/utils.d.ts +8 -0
- package/build-types/locks/utils.d.ts.map +1 -0
- package/build-types/name.d.ts +8 -0
- package/build-types/name.d.ts.map +1 -0
- package/build-types/queried-data/actions.d.ts +32 -0
- package/build-types/queried-data/actions.d.ts.map +1 -0
- package/build-types/queried-data/get-query-parts.d.ts +60 -0
- package/build-types/queried-data/get-query-parts.d.ts.map +1 -0
- package/build-types/queried-data/index.d.ts +4 -0
- package/build-types/queried-data/index.d.ts.map +1 -0
- package/build-types/queried-data/reducer.d.ts +54 -0
- package/build-types/queried-data/reducer.d.ts.map +1 -0
- package/build-types/queried-data/selectors.d.ts +16 -0
- package/build-types/queried-data/selectors.d.ts.map +1 -0
- package/build-types/reducer.d.ts +156 -0
- package/build-types/reducer.d.ts.map +1 -0
- package/build-types/resolvers.d.ts +75 -0
- package/build-types/resolvers.d.ts.map +1 -0
- package/build-types/selectors.d.ts +524 -0
- package/build-types/selectors.d.ts.map +1 -0
- package/build-types/types.d.ts +4 -0
- package/build-types/types.d.ts.map +1 -0
- package/build-types/utils/conservative-map-item.d.ts +12 -0
- package/build-types/utils/conservative-map-item.d.ts.map +1 -0
- package/build-types/utils/forward-resolver.d.ts +10 -0
- package/build-types/utils/forward-resolver.d.ts.map +1 -0
- package/build-types/utils/get-normalized-comma-separable.d.ts +12 -0
- package/build-types/utils/get-normalized-comma-separable.d.ts.map +1 -0
- package/build-types/utils/if-matching-action.d.ts +14 -0
- package/build-types/utils/if-matching-action.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +9 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/is-raw-attribute.d.ts +10 -0
- package/build-types/utils/is-raw-attribute.d.ts.map +1 -0
- package/build-types/utils/on-sub-key.d.ts +4 -0
- package/build-types/utils/on-sub-key.d.ts.map +1 -0
- package/build-types/utils/replace-action.d.ts +13 -0
- package/build-types/utils/replace-action.d.ts.map +1 -0
- package/build-types/utils/with-weak-map-cache.d.ts +12 -0
- package/build-types/utils/with-weak-map-cache.d.ts.map +1 -0
- package/package.json +12 -11
- package/src/entities.js +325 -0
- package/src/entity-types/attachment.ts +3 -4
- package/src/entity-types/comment.ts +3 -4
- package/src/entity-types/index.ts +31 -88
- package/src/entity-types/menu-location.ts +3 -4
- package/src/entity-types/nav-menu-item.ts +3 -4
- package/src/entity-types/nav-menu.ts +3 -3
- package/src/entity-types/page.ts +3 -3
- package/src/entity-types/plugin.ts +3 -3
- package/src/entity-types/post.ts +3 -3
- package/src/entity-types/settings.ts +3 -3
- package/src/entity-types/sidebar.ts +3 -4
- package/src/entity-types/taxonomy.ts +3 -4
- package/src/entity-types/theme.ts +3 -3
- package/src/entity-types/type.ts +3 -3
- package/src/entity-types/user.ts +3 -3
- package/src/entity-types/widget-type.ts +3 -4
- package/src/entity-types/widget.ts +3 -3
- package/src/entity-types/wp-template-part.ts +3 -4
- package/src/entity-types/wp-template.ts +3 -4
- package/src/hooks/test/use-entity-record.js +41 -1
- package/src/hooks/test/use-resource-permissions.js +4 -0
- package/src/hooks/use-entity-record.ts +12 -2
- package/src/hooks/use-entity-records.ts +2 -0
- package/src/hooks/use-query-select.ts +4 -1
- package/src/hooks/use-resource-permissions.ts +28 -6
- package/src/index.js +0 -2
- package/src/resolvers.js +46 -23
- package/src/selectors.ts +202 -341
- package/src/test/resolvers.js +118 -4
- package/tsconfig.json +21 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/build/entity-types/entities.js +0 -6
- package/build/entity-types/entities.js.map +0 -1
- package/build-module/entity-types/entities.js +0 -2
- package/build-module/entity-types/entities.js.map +0 -1
- package/src/entities.ts +0 -550
- package/src/entity-types/entities.ts +0 -130
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -189,7 +189,7 @@ _Parameters_
|
|
|
189
189
|
- _state_ `State`: Data state.
|
|
190
190
|
- _action_ `string`: Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
191
191
|
- _resource_ `string`: REST resource to check, e.g. 'media' or 'posts'.
|
|
192
|
-
- _id_ `
|
|
192
|
+
- _id_ `EntityRecordKey`: Optional ID of the rest resource to check.
|
|
193
193
|
|
|
194
194
|
_Returns_
|
|
195
195
|
|
|
@@ -207,9 +207,9 @@ Calling this may trigger an OPTIONS request to the REST API via the
|
|
|
207
207
|
_Parameters_
|
|
208
208
|
|
|
209
209
|
- _state_ `State`: Data state.
|
|
210
|
-
- _kind_ `
|
|
211
|
-
- _name_ `
|
|
212
|
-
- _recordId_ `
|
|
210
|
+
- _kind_ `string`: Entity kind.
|
|
211
|
+
- _name_ `string`: Entity name.
|
|
212
|
+
- _recordId_ `EntityRecordKey`: Record's id.
|
|
213
213
|
|
|
214
214
|
_Returns_
|
|
215
215
|
|
|
@@ -224,11 +224,11 @@ Returns all available authors.
|
|
|
224
224
|
_Parameters_
|
|
225
225
|
|
|
226
226
|
- _state_ `State`: Data state.
|
|
227
|
-
- _query_ `
|
|
227
|
+
- _query_ `GetRecordsHttpQuery`: Optional object of query parameters to include with request.
|
|
228
228
|
|
|
229
229
|
_Returns_
|
|
230
230
|
|
|
231
|
-
- `User
|
|
231
|
+
- `ET.User[]`: Authors list.
|
|
232
232
|
|
|
233
233
|
### getAutosave
|
|
234
234
|
|
|
@@ -238,8 +238,8 @@ _Parameters_
|
|
|
238
238
|
|
|
239
239
|
- _state_ `State`: State tree.
|
|
240
240
|
- _postType_ `string`: The type of the parent post.
|
|
241
|
-
- _postId_ `
|
|
242
|
-
- _authorId_ `
|
|
241
|
+
- _postId_ `EntityRecordKey`: The id of the parent post.
|
|
242
|
+
- _authorId_ `EntityRecordKey`: The id of the author.
|
|
243
243
|
|
|
244
244
|
_Returns_
|
|
245
245
|
|
|
@@ -256,7 +256,7 @@ _Parameters_
|
|
|
256
256
|
|
|
257
257
|
- _state_ `State`: State tree.
|
|
258
258
|
- _postType_ `string`: The type of the parent post.
|
|
259
|
-
- _postId_ `
|
|
259
|
+
- _postId_ `EntityRecordKey`: The id of the parent post.
|
|
260
260
|
|
|
261
261
|
_Returns_
|
|
262
262
|
|
|
@@ -308,7 +308,7 @@ _Parameters_
|
|
|
308
308
|
|
|
309
309
|
_Returns_
|
|
310
310
|
|
|
311
|
-
- `
|
|
311
|
+
- `undefined< 'edit' >`: Current user object.
|
|
312
312
|
|
|
313
313
|
### getEditedEntityRecord
|
|
314
314
|
|
|
@@ -317,13 +317,13 @@ Returns the specified entity record, merged with its edits.
|
|
|
317
317
|
_Parameters_
|
|
318
318
|
|
|
319
319
|
- _state_ `State`: State tree.
|
|
320
|
-
- _kind_ `
|
|
321
|
-
- _name_ `
|
|
322
|
-
- _recordId_ `
|
|
320
|
+
- _kind_ `string`: Entity kind.
|
|
321
|
+
- _name_ `string`: Entity name.
|
|
322
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
323
323
|
|
|
324
324
|
_Returns_
|
|
325
325
|
|
|
326
|
-
- `EntityRecord | undefined`: The entity record, merged with its edits.
|
|
326
|
+
- `undefined< EntityRecord > | undefined`: The entity record, merged with its edits.
|
|
327
327
|
|
|
328
328
|
### getEmbedPreview
|
|
329
329
|
|
|
@@ -347,7 +347,7 @@ Returns the loaded entities for the given kind.
|
|
|
347
347
|
_Parameters_
|
|
348
348
|
|
|
349
349
|
- _state_ `State`: Data state.
|
|
350
|
-
- _kind_ `
|
|
350
|
+
- _kind_ `string`: Entity kind.
|
|
351
351
|
|
|
352
352
|
_Returns_
|
|
353
353
|
|
|
@@ -360,7 +360,7 @@ Returns the loaded entities for the given kind.
|
|
|
360
360
|
_Parameters_
|
|
361
361
|
|
|
362
362
|
- _state_ `State`: Data state.
|
|
363
|
-
- _kind_ `
|
|
363
|
+
- _kind_ `string`: Entity kind.
|
|
364
364
|
|
|
365
365
|
_Returns_
|
|
366
366
|
|
|
@@ -375,8 +375,8 @@ Returns the entity config given its kind and name.
|
|
|
375
375
|
_Parameters_
|
|
376
376
|
|
|
377
377
|
- _state_ `State`: Data state.
|
|
378
|
-
- _kind_ `
|
|
379
|
-
- _name_ `
|
|
378
|
+
- _kind_ `string`: Entity kind.
|
|
379
|
+
- _name_ `string`: Entity name.
|
|
380
380
|
|
|
381
381
|
_Returns_
|
|
382
382
|
|
|
@@ -389,8 +389,8 @@ Returns the entity config given its kind and name.
|
|
|
389
389
|
_Parameters_
|
|
390
390
|
|
|
391
391
|
- _state_ `State`: Data state.
|
|
392
|
-
- _kind_ `
|
|
393
|
-
- _name_ `
|
|
392
|
+
- _kind_ `string`: Entity kind.
|
|
393
|
+
- _name_ `string`: Entity name.
|
|
394
394
|
|
|
395
395
|
_Returns_
|
|
396
396
|
|
|
@@ -405,14 +405,14 @@ entity object if it exists and is received.
|
|
|
405
405
|
_Parameters_
|
|
406
406
|
|
|
407
407
|
- _state_ `State`: State tree
|
|
408
|
-
- _kind_ `
|
|
409
|
-
- _name_ `
|
|
410
|
-
- _key_ `
|
|
411
|
-
- _query_ Optional query. If requesting specific fields, fields must always include the ID.
|
|
408
|
+
- _kind_ `string`: Entity kind.
|
|
409
|
+
- _name_ `string`: Entity name.
|
|
410
|
+
- _key_ `EntityRecordKey`: Record's key
|
|
411
|
+
- _query_ `GetRecordsHttpQuery`: Optional query. If requesting specific fields, fields must always include the ID.
|
|
412
412
|
|
|
413
413
|
_Returns_
|
|
414
414
|
|
|
415
|
-
- Record.
|
|
415
|
+
- `EntityRecord | undefined`: Record.
|
|
416
416
|
|
|
417
417
|
### getEntityRecordEdits
|
|
418
418
|
|
|
@@ -421,9 +421,9 @@ Returns the specified entity record's edits.
|
|
|
421
421
|
_Parameters_
|
|
422
422
|
|
|
423
423
|
- _state_ `State`: State tree.
|
|
424
|
-
- _kind_ `
|
|
425
|
-
- _name_ `
|
|
426
|
-
- _recordId_ `
|
|
424
|
+
- _kind_ `string`: Entity kind.
|
|
425
|
+
- _name_ `string`: Entity name.
|
|
426
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
427
427
|
|
|
428
428
|
_Returns_
|
|
429
429
|
|
|
@@ -440,9 +440,9 @@ They are defined in the entity's config.
|
|
|
440
440
|
_Parameters_
|
|
441
441
|
|
|
442
442
|
- _state_ `State`: State tree.
|
|
443
|
-
- _kind_ `
|
|
444
|
-
- _name_ `
|
|
445
|
-
- _recordId_ `
|
|
443
|
+
- _kind_ `string`: Entity kind.
|
|
444
|
+
- _name_ `string`: Entity name.
|
|
445
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
446
446
|
|
|
447
447
|
_Returns_
|
|
448
448
|
|
|
@@ -455,13 +455,13 @@ Returns the Entity's records.
|
|
|
455
455
|
_Parameters_
|
|
456
456
|
|
|
457
457
|
- _state_ `State`: State tree
|
|
458
|
-
- _kind_ `
|
|
459
|
-
- _name_ `
|
|
460
|
-
- _query_ Optional terms query. If requesting specific fields, fields must always include the ID.
|
|
458
|
+
- _kind_ `string`: Entity kind.
|
|
459
|
+
- _name_ `string`: Entity name.
|
|
460
|
+
- _query_ `GetRecordsHttpQuery`: Optional terms query. If requesting specific fields, fields must always include the ID.
|
|
461
461
|
|
|
462
462
|
_Returns_
|
|
463
463
|
|
|
464
|
-
- Records.
|
|
464
|
+
- `EntityRecord[] | null`: Records.
|
|
465
465
|
|
|
466
466
|
### getLastEntityDeleteError
|
|
467
467
|
|
|
@@ -470,9 +470,9 @@ Returns the specified entity record's last delete error.
|
|
|
470
470
|
_Parameters_
|
|
471
471
|
|
|
472
472
|
- _state_ `State`: State tree.
|
|
473
|
-
- _kind_ `
|
|
474
|
-
- _name_ `
|
|
475
|
-
- _recordId_ `
|
|
473
|
+
- _kind_ `string`: Entity kind.
|
|
474
|
+
- _name_ `string`: Entity name.
|
|
475
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
476
476
|
|
|
477
477
|
_Returns_
|
|
478
478
|
|
|
@@ -485,9 +485,9 @@ Returns the specified entity record's last save error.
|
|
|
485
485
|
_Parameters_
|
|
486
486
|
|
|
487
487
|
- _state_ `State`: State tree.
|
|
488
|
-
- _kind_ `
|
|
489
|
-
- _name_ `
|
|
490
|
-
- _recordId_ `
|
|
488
|
+
- _kind_ `string`: Entity kind.
|
|
489
|
+
- _name_ `string`: Entity name.
|
|
490
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
491
491
|
|
|
492
492
|
_Returns_
|
|
493
493
|
|
|
@@ -501,9 +501,9 @@ with its attributes mapped to their raw values.
|
|
|
501
501
|
_Parameters_
|
|
502
502
|
|
|
503
503
|
- _state_ `State`: State tree.
|
|
504
|
-
- _kind_ `
|
|
505
|
-
- _name_ `
|
|
506
|
-
- _key_ `
|
|
504
|
+
- _kind_ `string`: Entity kind.
|
|
505
|
+
- _name_ `string`: Entity name.
|
|
506
|
+
- _key_ `EntityRecordKey`: Record's key.
|
|
507
507
|
|
|
508
508
|
_Returns_
|
|
509
509
|
|
|
@@ -579,7 +579,7 @@ _Parameters_
|
|
|
579
579
|
|
|
580
580
|
_Returns_
|
|
581
581
|
|
|
582
|
-
- `
|
|
582
|
+
- `undefined< 'edit' >[]`: Users list.
|
|
583
583
|
|
|
584
584
|
### hasEditsForEntityRecord
|
|
585
585
|
|
|
@@ -589,9 +589,9 @@ and false otherwise.
|
|
|
589
589
|
_Parameters_
|
|
590
590
|
|
|
591
591
|
- _state_ `State`: State tree.
|
|
592
|
-
- _kind_ `
|
|
593
|
-
- _name_ `
|
|
594
|
-
- _recordId_ `
|
|
592
|
+
- _kind_ `string`: Entity kind.
|
|
593
|
+
- _name_ `string`: Entity name.
|
|
594
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
595
595
|
|
|
596
596
|
_Returns_
|
|
597
597
|
|
|
@@ -605,9 +605,9 @@ or false otherwise.
|
|
|
605
605
|
_Parameters_
|
|
606
606
|
|
|
607
607
|
- _state_ `State`: State tree
|
|
608
|
-
- _kind_ `
|
|
609
|
-
- _name_ `
|
|
610
|
-
- _query_ `
|
|
608
|
+
- _kind_ `string`: Entity kind.
|
|
609
|
+
- _name_ `string`: Entity name.
|
|
610
|
+
- _query_ `GetRecordsHttpQuery`: Optional terms query.
|
|
611
611
|
|
|
612
612
|
_Returns_
|
|
613
613
|
|
|
@@ -621,7 +621,7 @@ _Parameters_
|
|
|
621
621
|
|
|
622
622
|
- _state_ `State`: State tree.
|
|
623
623
|
- _postType_ `string`: The type of the parent post.
|
|
624
|
-
- _postId_ `
|
|
624
|
+
- _postId_ `EntityRecordKey`: The id of the parent post.
|
|
625
625
|
|
|
626
626
|
_Returns_
|
|
627
627
|
|
|
@@ -660,9 +660,9 @@ Returns true if the specified entity record is autosaving, and false otherwise.
|
|
|
660
660
|
_Parameters_
|
|
661
661
|
|
|
662
662
|
- _state_ `State`: State tree.
|
|
663
|
-
- _kind_ `
|
|
664
|
-
- _name_ `
|
|
665
|
-
- _recordId_ `
|
|
663
|
+
- _kind_ `string`: Entity kind.
|
|
664
|
+
- _name_ `string`: Entity name.
|
|
665
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
666
666
|
|
|
667
667
|
_Returns_
|
|
668
668
|
|
|
@@ -675,9 +675,9 @@ Returns true if the specified entity record is deleting, and false otherwise.
|
|
|
675
675
|
_Parameters_
|
|
676
676
|
|
|
677
677
|
- _state_ `State`: State tree.
|
|
678
|
-
- _kind_ `
|
|
679
|
-
- _name_ `
|
|
680
|
-
- _recordId_ `
|
|
678
|
+
- _kind_ `string`: Entity kind.
|
|
679
|
+
- _name_ `string`: Entity name.
|
|
680
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
681
681
|
|
|
682
682
|
_Returns_
|
|
683
683
|
|
|
@@ -721,9 +721,9 @@ Returns true if the specified entity record is saving, and false otherwise.
|
|
|
721
721
|
_Parameters_
|
|
722
722
|
|
|
723
723
|
- _state_ `State`: State tree.
|
|
724
|
-
- _kind_ `
|
|
725
|
-
- _name_ `
|
|
726
|
-
- _recordId_ `
|
|
724
|
+
- _kind_ `string`: Entity kind.
|
|
725
|
+
- _name_ `string`: Entity name.
|
|
726
|
+
- _recordId_ `EntityRecordKey`: Record ID.
|
|
727
727
|
|
|
728
728
|
_Returns_
|
|
729
729
|
|
|
@@ -831,6 +831,10 @@ _Returns_
|
|
|
831
831
|
|
|
832
832
|
- `EntityRecordResolution< RecordType >`: Entity record data.
|
|
833
833
|
|
|
834
|
+
_Changelog_
|
|
835
|
+
|
|
836
|
+
`6.1.0` Introduced in WordPress core.
|
|
837
|
+
|
|
834
838
|
### useEntityRecords
|
|
835
839
|
|
|
836
840
|
Resolves the specified entity records.
|
|
@@ -875,6 +879,10 @@ _Returns_
|
|
|
875
879
|
|
|
876
880
|
- `EntityRecordsResolution< RecordType >`: Entity records data.
|
|
877
881
|
|
|
882
|
+
_Changelog_
|
|
883
|
+
|
|
884
|
+
`6.1.0` Introduced in WordPress core.
|
|
885
|
+
|
|
878
886
|
### useResourcePermissions
|
|
879
887
|
|
|
880
888
|
Resolves resource permissions.
|
|
@@ -941,6 +949,10 @@ _Returns_
|
|
|
941
949
|
|
|
942
950
|
- `ResourcePermissionsResolution< IdType >`: Entity records data.
|
|
943
951
|
|
|
952
|
+
_Changelog_
|
|
953
|
+
|
|
954
|
+
`6.1.0` Introduced in WordPress core.
|
|
955
|
+
|
|
944
956
|
<!-- END TOKEN(Autogenerated hooks|src/hooks/index.ts) -->
|
|
945
957
|
|
|
946
958
|
## Contributing to this package
|
package/build/entities.js
CHANGED
|
@@ -31,18 +31,15 @@ var _actions = require("./actions");
|
|
|
31
31
|
const DEFAULT_ENTITY_KEY = 'id';
|
|
32
32
|
exports.DEFAULT_ENTITY_KEY = DEFAULT_ENTITY_KEY;
|
|
33
33
|
const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const rootEntitiesConfig = [{
|
|
35
|
+
label: (0, _i18n.__)('Base'),
|
|
36
36
|
kind: 'root',
|
|
37
|
-
|
|
37
|
+
name: '__unstableBase',
|
|
38
|
+
baseURL: '/',
|
|
38
39
|
baseURLParams: {
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
label: (0, _i18n.__)('Media'),
|
|
43
|
-
rawAttributes: ['caption', 'title', 'description']
|
|
44
|
-
};
|
|
45
|
-
const siteConfig = {
|
|
40
|
+
_fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url'].join(',')
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
46
43
|
label: (0, _i18n.__)('Site'),
|
|
47
44
|
name: 'site',
|
|
48
45
|
kind: 'root',
|
|
@@ -50,8 +47,7 @@ const siteConfig = {
|
|
|
50
47
|
getTitle: record => {
|
|
51
48
|
return (0, _lodash.get)(record, ['title'], (0, _i18n.__)('Site Title'));
|
|
52
49
|
}
|
|
53
|
-
}
|
|
54
|
-
const postTypeConfig = {
|
|
50
|
+
}, {
|
|
55
51
|
label: (0, _i18n.__)('Post Type'),
|
|
56
52
|
name: 'postType',
|
|
57
53
|
kind: 'root',
|
|
@@ -60,8 +56,17 @@ const postTypeConfig = {
|
|
|
60
56
|
baseURLParams: {
|
|
61
57
|
context: 'edit'
|
|
62
58
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
59
|
+
}, {
|
|
60
|
+
name: 'media',
|
|
61
|
+
kind: 'root',
|
|
62
|
+
baseURL: '/wp/v2/media',
|
|
63
|
+
baseURLParams: {
|
|
64
|
+
context: 'edit'
|
|
65
|
+
},
|
|
66
|
+
plural: 'mediaItems',
|
|
67
|
+
label: (0, _i18n.__)('Media'),
|
|
68
|
+
rawAttributes: ['caption', 'title', 'description']
|
|
69
|
+
}, {
|
|
65
70
|
name: 'taxonomy',
|
|
66
71
|
kind: 'root',
|
|
67
72
|
key: 'slug',
|
|
@@ -71,8 +76,7 @@ const taxonomyConfig = {
|
|
|
71
76
|
},
|
|
72
77
|
plural: 'taxonomies',
|
|
73
78
|
label: (0, _i18n.__)('Taxonomy')
|
|
74
|
-
}
|
|
75
|
-
const sidebarConfig = {
|
|
79
|
+
}, {
|
|
76
80
|
name: 'sidebar',
|
|
77
81
|
kind: 'root',
|
|
78
82
|
baseURL: '/wp/v2/sidebars',
|
|
@@ -84,8 +88,7 @@ const sidebarConfig = {
|
|
|
84
88
|
blocks: true
|
|
85
89
|
},
|
|
86
90
|
label: (0, _i18n.__)('Widget areas')
|
|
87
|
-
}
|
|
88
|
-
const widgetConfig = {
|
|
91
|
+
}, {
|
|
89
92
|
name: 'widget',
|
|
90
93
|
kind: 'root',
|
|
91
94
|
baseURL: '/wp/v2/widgets',
|
|
@@ -97,8 +100,7 @@ const widgetConfig = {
|
|
|
97
100
|
blocks: true
|
|
98
101
|
},
|
|
99
102
|
label: (0, _i18n.__)('Widgets')
|
|
100
|
-
}
|
|
101
|
-
const widgetTypeConfig = {
|
|
103
|
+
}, {
|
|
102
104
|
name: 'widgetType',
|
|
103
105
|
kind: 'root',
|
|
104
106
|
baseURL: '/wp/v2/widget-types',
|
|
@@ -107,8 +109,7 @@ const widgetTypeConfig = {
|
|
|
107
109
|
},
|
|
108
110
|
plural: 'widgetTypes',
|
|
109
111
|
label: (0, _i18n.__)('Widget types')
|
|
110
|
-
}
|
|
111
|
-
const userConfig = {
|
|
112
|
+
}, {
|
|
112
113
|
label: (0, _i18n.__)('User'),
|
|
113
114
|
name: 'user',
|
|
114
115
|
kind: 'root',
|
|
@@ -117,8 +118,7 @@ const userConfig = {
|
|
|
117
118
|
context: 'edit'
|
|
118
119
|
},
|
|
119
120
|
plural: 'users'
|
|
120
|
-
}
|
|
121
|
-
const commentConfig = {
|
|
121
|
+
}, {
|
|
122
122
|
name: 'comment',
|
|
123
123
|
kind: 'root',
|
|
124
124
|
baseURL: '/wp/v2/comments',
|
|
@@ -127,8 +127,7 @@ const commentConfig = {
|
|
|
127
127
|
},
|
|
128
128
|
plural: 'comments',
|
|
129
129
|
label: (0, _i18n.__)('Comment')
|
|
130
|
-
}
|
|
131
|
-
const menuConfig = {
|
|
130
|
+
}, {
|
|
132
131
|
name: 'menu',
|
|
133
132
|
kind: 'root',
|
|
134
133
|
baseURL: '/wp/v2/menus',
|
|
@@ -137,8 +136,7 @@ const menuConfig = {
|
|
|
137
136
|
},
|
|
138
137
|
plural: 'menus',
|
|
139
138
|
label: (0, _i18n.__)('Menu')
|
|
140
|
-
}
|
|
141
|
-
const menuItemConfig = {
|
|
139
|
+
}, {
|
|
142
140
|
name: 'menuItem',
|
|
143
141
|
kind: 'root',
|
|
144
142
|
baseURL: '/wp/v2/menu-items',
|
|
@@ -148,8 +146,7 @@ const menuItemConfig = {
|
|
|
148
146
|
plural: 'menuItems',
|
|
149
147
|
label: (0, _i18n.__)('Menu Item'),
|
|
150
148
|
rawAttributes: ['title']
|
|
151
|
-
}
|
|
152
|
-
const menuLocationConfig = {
|
|
149
|
+
}, {
|
|
153
150
|
name: 'menuLocation',
|
|
154
151
|
kind: 'root',
|
|
155
152
|
baseURL: '/wp/v2/menu-locations',
|
|
@@ -159,8 +156,7 @@ const menuLocationConfig = {
|
|
|
159
156
|
plural: 'menuLocations',
|
|
160
157
|
label: (0, _i18n.__)('Menu Location'),
|
|
161
158
|
key: 'name'
|
|
162
|
-
}
|
|
163
|
-
const globalStyleConfig = {
|
|
159
|
+
}, {
|
|
164
160
|
label: (0, _i18n.__)('Global Styles'),
|
|
165
161
|
name: 'globalStyles',
|
|
166
162
|
kind: 'root',
|
|
@@ -175,8 +171,7 @@ const globalStyleConfig = {
|
|
|
175
171
|
|
|
176
172
|
return (record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) || (record === null || record === void 0 ? void 0 : record.title);
|
|
177
173
|
}
|
|
178
|
-
}
|
|
179
|
-
const themeConfig = {
|
|
174
|
+
}, {
|
|
180
175
|
label: (0, _i18n.__)('Themes'),
|
|
181
176
|
name: 'theme',
|
|
182
177
|
kind: 'root',
|
|
@@ -185,8 +180,7 @@ const themeConfig = {
|
|
|
185
180
|
context: 'edit'
|
|
186
181
|
},
|
|
187
182
|
key: 'stylesheet'
|
|
188
|
-
}
|
|
189
|
-
const pluginConfig = {
|
|
183
|
+
}, {
|
|
190
184
|
label: (0, _i18n.__)('Plugins'),
|
|
191
185
|
name: 'plugin',
|
|
192
186
|
kind: 'root',
|
|
@@ -195,16 +189,7 @@ const pluginConfig = {
|
|
|
195
189
|
context: 'edit'
|
|
196
190
|
},
|
|
197
191
|
key: 'plugin'
|
|
198
|
-
};
|
|
199
|
-
const rootEntitiesConfig = [{
|
|
200
|
-
label: (0, _i18n.__)('Base'),
|
|
201
|
-
kind: 'root',
|
|
202
|
-
name: '__unstableBase',
|
|
203
|
-
baseURL: '/',
|
|
204
|
-
baseURLParams: {
|
|
205
|
-
_fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url'].join(',')
|
|
206
|
-
}
|
|
207
|
-
}, siteConfig, postTypeConfig, attachmentConfig, taxonomyConfig, sidebarConfig, widgetConfig, widgetTypeConfig, userConfig, commentConfig, menuConfig, menuItemConfig, menuLocationConfig, globalStyleConfig, themeConfig, pluginConfig];
|
|
192
|
+
}];
|
|
208
193
|
exports.rootEntitiesConfig = rootEntitiesConfig;
|
|
209
194
|
const additionalEntityConfigLoaders = [{
|
|
210
195
|
kind: 'postType',
|
package/build/entities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/core-data/src/entities.ts"],"names":["DEFAULT_ENTITY_KEY","POST_RAW_ATTRIBUTES","attachmentConfig","name","kind","baseURL","baseURLParams","context","plural","label","rawAttributes","siteConfig","getTitle","record","postTypeConfig","key","taxonomyConfig","sidebarConfig","transientEdits","blocks","widgetConfig","widgetTypeConfig","userConfig","commentConfig","menuConfig","menuItemConfig","menuLocationConfig","globalStyleConfig","title","rendered","themeConfig","pluginConfig","rootEntitiesConfig","_fields","join","additionalEntityConfigLoaders","loadEntities","loadPostTypeEntities","loadTaxonomyEntities","prePersistPostType","persistedRecord","edits","newEdits","status","postTypes","path","postType","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","slug","String","id","__unstablePrePersist","undefined","__unstable_rest_base","taxonomies","taxonomy","getMethodName","prefix","usePlural","entityConfig","kindPrefix","nameSuffix","suffix","getOrLoadEntitiesConfig","select","dispatch","configs","getEntitiesConfig","length","loader"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AAYO,MAAMA,kBAAkB,GAAG,IAA3B;;AAEP,MAAMC,mBAAmB,GAAG,CAAE,OAAF,EAAW,SAAX,EAAsB,SAAtB,CAA5B;AAYA,MAAMC,gBAA8C,GAAG;AACtDC,EAAAA,IAAI,EAAE,OADgD;AAEtDC,EAAAA,IAAI,EAAE,MAFgD;AAGtDC,EAAAA,OAAO,EAAE,cAH6C;AAItDC,EAAAA,aAAa,EAAE;AAAEC,IAAAA,OAAO,EAAE;AAAX,GAJuC;AAKtDC,EAAAA,MAAM,EAAE,YAL8C;AAMtDC,EAAAA,KAAK,EAAE,cAAI,OAAJ,CAN+C;AAOtDC,EAAAA,aAAa,EAAE,CAAE,SAAF,EAAa,OAAb,EAAsB,aAAtB;AAPuC,CAAvD;AAmBA,MAAMC,UAAkC,GAAG;AAC1CF,EAAAA,KAAK,EAAE,cAAI,MAAJ,CADmC;AAE1CN,EAAAA,IAAI,EAAE,MAFoC;AAG1CC,EAAAA,IAAI,EAAE,MAHoC;AAI1CC,EAAAA,OAAO,EAAE,iBAJiC;AAK1CO,EAAAA,QAAQ,EAAIC,MAAF,IAA0C;AACnD,WAAO,iBAAKA,MAAL,EAAa,CAAE,OAAF,CAAb,EAA0B,cAAI,YAAJ,CAA1B,CAAP;AACA;AAPyC,CAA3C;AAqBA,MAAMC,cAA0C,GAAG;AAClDL,EAAAA,KAAK,EAAE,cAAI,WAAJ,CAD2C;AAElDN,EAAAA,IAAI,EAAE,UAF4C;AAGlDC,EAAAA,IAAI,EAAE,MAH4C;AAIlDW,EAAAA,GAAG,EAAE,MAJ6C;AAKlDV,EAAAA,OAAO,EAAE,cALyC;AAMlDC,EAAAA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,GAAG,kBAAMzC,6BAAN,EAAqC;AAAE/B,IAAAA;AAAF,GAArC,CAAf;;AACA,MAAK,CAAEwE,MAAP,EAAgB;AACf,WAAO,EAAP;AACA;;AAEDH,EAAAA,OAAO,GAAG,MAAMG,MAAM,CAACxC,YAAP,EAAhB;AACAoC,EAAAA,QAAQ,CAAE,0BAAaC,OAAb,CAAF,CAAR;AAEA,SAAOA,OAAP;AACA,CAjBK","sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\nimport { map, find, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { addEntities } from './actions';\nimport type * as Records from './entity-types';\nimport type {\n\tEntityType,\n\tContext,\n\tPost,\n\tTaxonomy,\n\tType,\n\tUpdatable,\n} from './entity-types';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\n\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\ntype AttachmentEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'media';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Attachment< C >,\n\tC\n>;\n\nconst attachmentConfig: AttachmentEntity[ 'config' ] = {\n\tname: 'media',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/media',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'mediaItems',\n\tlabel: __( 'Media' ),\n\trawAttributes: [ 'caption', 'title', 'description' ],\n};\n\ntype SiteEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'site';\n\t\tkind: 'root';\n\t},\n\tRecords.Settings< C >,\n\tC\n>;\n\nconst siteConfig: SiteEntity[ 'config' ] = {\n\tlabel: __( 'Site' ),\n\tname: 'site',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/settings',\n\tgetTitle: ( record: Records.Settings< 'edit' > ) => {\n\t\treturn get( record, [ 'title' ], __( 'Site Title' ) );\n\t},\n};\n\ntype PostTypeEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'postType';\n\t\tkind: 'root';\n\t\tkey: 'slug';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Type< C >,\n\tC\n>;\n\nconst postTypeConfig: PostTypeEntity[ 'config' ] = {\n\tlabel: __( 'Post Type' ),\n\tname: 'postType',\n\tkind: 'root',\n\tkey: 'slug',\n\tbaseURL: '/wp/v2/types',\n\tbaseURLParams: { context: 'edit' },\n};\n\ntype TaxonomyEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'taxonomy';\n\t\tkind: 'root';\n\t\tkey: 'slug';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Taxonomy< C >,\n\tC\n>;\n\nconst taxonomyConfig: TaxonomyEntity[ 'config' ] = {\n\tname: 'taxonomy',\n\tkind: 'root',\n\tkey: 'slug',\n\tbaseURL: '/wp/v2/taxonomies',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'taxonomies',\n\tlabel: __( 'Taxonomy' ),\n};\n\ntype SidebarEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'sidebar';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Sidebar< C >,\n\tC\n>;\n\nconst sidebarConfig: SidebarEntity[ 'config' ] = {\n\tname: 'sidebar',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/sidebars',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'sidebars',\n\ttransientEdits: { blocks: true },\n\tlabel: __( 'Widget areas' ),\n};\n\ntype WidgetEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'widget';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Widget< C >,\n\tC\n>;\nconst widgetConfig: WidgetEntity[ 'config' ] = {\n\tname: 'widget',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/widgets',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'widgets',\n\ttransientEdits: { blocks: true },\n\tlabel: __( 'Widgets' ),\n};\n\ntype WidgetTypeEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'widgetType';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.WidgetType< C >,\n\tC\n>;\nconst widgetTypeConfig: WidgetTypeEntity[ 'config' ] = {\n\tname: 'widgetType',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/widget-types',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'widgetTypes',\n\tlabel: __( 'Widget types' ),\n};\n\ntype UserEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'user';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.User< C >,\n\tC\n>;\nconst userConfig: UserEntity[ 'config' ] = {\n\tlabel: __( 'User' ),\n\tname: 'user',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/users',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'users',\n};\n\ntype CommentEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'comment';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.Comment< C >,\n\tC\n>;\nconst commentConfig: CommentEntity[ 'config' ] = {\n\tname: 'comment',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/comments',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'comments',\n\tlabel: __( 'Comment' ),\n};\n\ntype NavMenuEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'menu';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.NavMenu< C >,\n\tC\n>;\n\nconst menuConfig: NavMenuEntity[ 'config' ] = {\n\tname: 'menu',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/menus',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'menus',\n\tlabel: __( 'Menu' ),\n};\n\ntype NavMenuItemEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'menuItem';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.NavMenuItem< C >,\n\tC\n>;\n\nconst menuItemConfig: NavMenuItemEntity[ 'config' ] = {\n\tname: 'menuItem',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/menu-items',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'menuItems',\n\tlabel: __( 'Menu Item' ),\n\trawAttributes: [ 'title' ],\n};\n\ntype MenuLocationEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'menuLocation';\n\t\tkind: 'root';\n\t\tkey: 'name';\n\t\tbaseURLParams: { context: 'edit' };\n\t},\n\tRecords.MenuLocation< C >,\n\tC\n>;\n\nconst menuLocationConfig: MenuLocationEntity[ 'config' ] = {\n\tname: 'menuLocation',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/menu-locations',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'menuLocations',\n\tlabel: __( 'Menu Location' ),\n\tkey: 'name',\n};\n\nconst globalStyleConfig = {\n\tlabel: __( 'Global Styles' ),\n\tname: 'globalStyles',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/global-styles',\n\tbaseURLParams: { context: 'edit' },\n\tplural: 'globalStylesVariations', // Should be different than name.\n\tgetTitle: ( record ) => record?.title?.rendered || record?.title,\n};\n\ntype ThemeEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'theme';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t\tkey: 'stylesheet';\n\t},\n\tRecords.Theme< C >,\n\tC\n>;\n\nconst themeConfig: ThemeEntity[ 'config' ] = {\n\tlabel: __( 'Themes' ),\n\tname: 'theme',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/themes',\n\tbaseURLParams: { context: 'edit' },\n\tkey: 'stylesheet',\n};\n\ntype PluginEntity< C extends Context = Context > = EntityType<\n\t{\n\t\tname: 'plugin';\n\t\tkind: 'root';\n\t\tbaseURLParams: { context: 'edit' };\n\t\tkey: 'plugin';\n\t},\n\tRecords.Plugin< C >,\n\tC\n>;\nconst pluginConfig: PluginEntity[ 'config' ] = {\n\tlabel: __( 'Plugins' ),\n\tname: 'plugin',\n\tkind: 'root',\n\tbaseURL: '/wp/v2/plugins',\n\tbaseURLParams: { context: 'edit' },\n\tkey: 'plugin',\n};\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t].join( ',' ),\n\t\t},\n\t},\n\tsiteConfig,\n\tpostTypeConfig,\n\tattachmentConfig,\n\ttaxonomyConfig,\n\tsidebarConfig,\n\twidgetConfig,\n\twidgetTypeConfig,\n\tuserConfig,\n\tcommentConfig,\n\tmenuConfig,\n\tmenuItemConfig,\n\tmenuLocationConfig,\n\tglobalStyleConfig,\n\tthemeConfig,\n\tpluginConfig,\n];\n\ntype PostTypeConfig = {\n\tkind: 'postType';\n\tkey: 'id';\n\tdefaultContext: 'edit';\n};\n\ntype PostEntity< C extends Context = Context > = EntityType<\n\tPostTypeConfig & { name: 'post' },\n\tRecords.Post< C >,\n\tC\n>;\ntype PageEntity< C extends Context > = EntityType<\n\tPostTypeConfig & { name: 'page' },\n\tRecords.Page< C >,\n\tC\n>;\ntype WpTemplateEntity< C extends Context > = EntityType<\n\tPostTypeConfig & { name: 'wp_template' },\n\tRecords.WpTemplate< C >,\n\tC\n>;\ntype WpTemplatePartEntity< C extends Context > = EntityType<\n\tPostTypeConfig & { name: 'wp_template_part' },\n\tRecords.WpTemplatePart< C >,\n\tC\n>;\n\nexport type CoreEntities< C extends Context > =\n\t| SiteEntity< C >\n\t| PostTypeEntity< C >\n\t| AttachmentEntity< C >\n\t| TaxonomyEntity< C >\n\t| SidebarEntity< C >\n\t| WidgetEntity< C >\n\t| WidgetTypeEntity< C >\n\t| UserEntity< C >\n\t| CommentEntity< C >\n\t| NavMenuEntity< C >\n\t| NavMenuItemEntity< C >\n\t| MenuLocationEntity< C >\n\t| ThemeEntity< C >\n\t| PluginEntity< C >\n\t| PostEntity< C >\n\t| PageEntity< C >\n\t| WpTemplateEntity< C >\n\t| WpTemplatePartEntity< C >;\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n];\n\n/**\n * Returns a function to be used to retrieve extra edits to apply before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = ( persistedRecord, edits ) => {\n\tconst newEdits = {} as Partial< Updatable< Post< 'edit' > > >;\n\n\tif ( persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = ( await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} ) ) as Record< string, Type< 'view' > >;\n\treturn map( postTypes, ( postType, name ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\tblocks: true,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: isTemplate ? undefined : prePersistPostType,\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = ( await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} ) ) as Record< string, Taxonomy< 'view' > >;\n\treturn map( taxonomies, ( taxonomy, name ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the entity's getter method name given its kind and name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'theme', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} prefix Function prefix.\n * @param {boolean} usePlural Whether to use the plural form or not.\n *\n * @return {string} Method name\n */\nexport const getMethodName = (\n\tkind,\n\tname,\n\tprefix = 'get',\n\tusePlural = false\n) => {\n\tconst entityConfig = find( rootEntitiesConfig, { kind, name } );\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst nameSuffix = pascalCase( name ) + ( usePlural ? 's' : '' );\n\tconst suffix =\n\t\tusePlural && 'plural' in entityConfig! && entityConfig?.plural\n\t\t\t? pascalCase( entityConfig.plural )\n\t\t\t: nameSuffix;\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n\n/**\n * Loads the kind entities into the store.\n *\n * @param {string} kind Kind\n *\n * @return {(thunkArgs: object) => Promise<Array>} Entities\n */\nexport const getOrLoadEntitiesConfig =\n\t( kind ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tlet configs = select.getEntitiesConfig( kind );\n\t\tif ( configs && configs.length !== 0 ) {\n\t\t\treturn configs;\n\t\t}\n\n\t\tconst loader = find( additionalEntityConfigLoaders, { kind } );\n\t\tif ( ! loader ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconfigs = await loader.loadEntities();\n\t\tdispatch( addEntities( configs ) );\n\n\t\treturn configs;\n\t};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/core-data/src/entities.js"],"names":["DEFAULT_ENTITY_KEY","POST_RAW_ATTRIBUTES","rootEntitiesConfig","label","kind","name","baseURL","baseURLParams","_fields","join","getTitle","record","key","context","plural","rawAttributes","transientEdits","blocks","title","rendered","additionalEntityConfigLoaders","loadEntities","loadPostTypeEntities","loadTaxonomyEntities","prePersistPostType","persistedRecord","edits","newEdits","status","postTypes","path","postType","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","slug","String","id","__unstablePrePersist","undefined","__unstable_rest_base","taxonomies","taxonomy","getMethodName","prefix","usePlural","entityConfig","kindPrefix","nameSuffix","suffix","getOrLoadEntitiesConfig","select","dispat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AACA;AACA;;;;;AACO,MAAMC,uBAAuB,GACjCnD,IAAF,IACA,cAAkC;AAAA,MAA1B;AAAEoD,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA0B;AACjC,MAAIC,OAAO,GAAGF,MAAM,CAACG,iBAAP,CAA0BvD,IAA1B,CAAd;;AACA,MAAKsD,OAAO,IAAIA,OAAO,CAACE,MAAR,KAAmB,CAAnC,EAAuC;AACtC,WAAOF,OAAP;AACA;;AAED,QAAMG,MAAM,GAAG,kBAAMzC,6BAAN,EAAqC;AAAEhB,IAAAA;AAAF,GAArC,CAAf;;AACA,MAAK,CAAEyD,MAAP,EAAgB;AACf,WAAO,EAAP;AACA;;AAEDH,EAAAA,OAAO,GAAG,MAAMG,MAAM,CAACxC,YAAP,EAAhB;AACAoC,EAAAA,QAAQ,CAAE,0BAAaC,OAAb,CAAF,CAAR;AAEA,SAAOA,OAAP;AACA,CAjBK","sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\nimport { map, find, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { addEntities } from './actions';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\n\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t].join( ',' ),\n\t\t},\n\t},\n\t{\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/settings',\n\t\tgetTitle: ( record ) => {\n\t\t\treturn get( record, [ 'title' ], __( 'Site Title' ) );\n\t\t},\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different than name.\n\t\tgetTitle: ( record ) => record?.title?.rendered || record?.title,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'plugin',\n\t},\n];\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n];\n\n/**\n * Returns a function to be used to retrieve extra edits to apply before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = ( persistedRecord, edits ) => {\n\tconst newEdits = {};\n\n\tif ( persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} );\n\treturn map( postTypes, ( postType, name ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\tblocks: true,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: isTemplate ? undefined : prePersistPostType,\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn map( taxonomies, ( taxonomy, name ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the entity's getter method name given its kind and name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'theme', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} prefix Function prefix.\n * @param {boolean} usePlural Whether to use the plural form or not.\n *\n * @return {string} Method name\n */\nexport const getMethodName = (\n\tkind,\n\tname,\n\tprefix = 'get',\n\tusePlural = false\n) => {\n\tconst entityConfig = find( rootEntitiesConfig, { kind, name } );\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst nameSuffix = pascalCase( name ) + ( usePlural ? 's' : '' );\n\tconst suffix =\n\t\tusePlural && 'plural' in entityConfig && entityConfig?.plural\n\t\t\t? pascalCase( entityConfig.plural )\n\t\t\t: nameSuffix;\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n\n/**\n * Loads the kind entities into the store.\n *\n * @param {string} kind Kind\n *\n * @return {(thunkArgs: object) => Promise<Array>} Entities\n */\nexport const getOrLoadEntitiesConfig =\n\t( kind ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tlet configs = select.getEntitiesConfig( kind );\n\t\tif ( configs && configs.length !== 0 ) {\n\t\t\treturn configs;\n\t\t}\n\n\t\tconst loader = find( additionalEntityConfigLoaders, { kind } );\n\t\tif ( ! loader ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconfigs = await loader.loadEntities();\n\t\tdispatch( addEntities( configs ) );\n\n\t\treturn configs;\n\t};\n"]}
|
|
@@ -29,6 +29,8 @@ var _ = require("../");
|
|
|
29
29
|
/**
|
|
30
30
|
* Resolves the specified entity record.
|
|
31
31
|
*
|
|
32
|
+
* @since 6.1.0 Introduced in WordPress core.
|
|
33
|
+
*
|
|
32
34
|
* @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
|
|
33
35
|
* @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
|
|
34
36
|
* @param recordId ID of the requested entity record.
|
|
@@ -134,8 +136,8 @@ function useEntityRecord(kind, name, recordId) {
|
|
|
134
136
|
editedRecord,
|
|
135
137
|
hasEdits
|
|
136
138
|
} = (0, _data.useSelect)(select => ({
|
|
137
|
-
editedRecord: select(_.store).getEditedEntityRecord(),
|
|
138
|
-
hasEdits: select(_.store).hasEditsForEntityRecord()
|
|
139
|
+
editedRecord: select(_.store).getEditedEntityRecord(kind, name, recordId),
|
|
140
|
+
hasEdits: select(_.store).hasEditsForEntityRecord(kind, name, recordId)
|
|
139
141
|
}), [kind, name, recordId]);
|
|
140
142
|
const {
|
|
141
143
|
data: record,
|