@wordpress/core-data 6.3.3 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/actions.js +6 -6
  4. package/build/actions.js.map +1 -1
  5. package/build/entities.js +7 -7
  6. package/build/entities.js.map +1 -1
  7. package/build/hooks/use-entity-record.js +4 -4
  8. package/build/hooks/use-entity-record.js.map +1 -1
  9. package/build/hooks/use-entity-records.js +4 -4
  10. package/build/hooks/use-entity-records.js.map +1 -1
  11. package/build/hooks/use-resource-permissions.js +2 -2
  12. package/build/hooks/use-resource-permissions.js.map +1 -1
  13. package/build/queried-data/selectors.js +4 -1
  14. package/build/queried-data/selectors.js.map +1 -1
  15. package/build/reducer.js +3 -1
  16. package/build/reducer.js.map +1 -1
  17. package/build/selectors.js +158 -135
  18. package/build/selectors.js.map +1 -1
  19. package/build-module/actions.js +6 -6
  20. package/build-module/actions.js.map +1 -1
  21. package/build-module/entities.js +7 -6
  22. package/build-module/entities.js.map +1 -1
  23. package/build-module/hooks/use-entity-record.js +4 -4
  24. package/build-module/hooks/use-entity-record.js.map +1 -1
  25. package/build-module/hooks/use-entity-records.js +4 -4
  26. package/build-module/hooks/use-entity-records.js.map +1 -1
  27. package/build-module/hooks/use-resource-permissions.js +2 -2
  28. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  29. package/build-module/queried-data/selectors.js +5 -2
  30. package/build-module/queried-data/selectors.js.map +1 -1
  31. package/build-module/reducer.js +4 -2
  32. package/build-module/reducer.js.map +1 -1
  33. package/build-module/selectors.js +159 -136
  34. package/build-module/selectors.js.map +1 -1
  35. package/build-types/actions.d.ts +1 -1
  36. package/build-types/actions.d.ts.map +1 -1
  37. package/build-types/entities.d.ts.map +1 -1
  38. package/build-types/hooks/use-entity-record.d.ts +4 -4
  39. package/build-types/hooks/use-entity-records.d.ts +4 -4
  40. package/build-types/hooks/use-resource-permissions.d.ts +2 -2
  41. package/build-types/index.d.ts +1 -1
  42. package/build-types/queried-data/selectors.d.ts.map +1 -1
  43. package/build-types/reducer.d.ts.map +1 -1
  44. package/build-types/selectors.d.ts +130 -117
  45. package/build-types/selectors.d.ts.map +1 -1
  46. package/package.json +12 -12
  47. package/src/actions.js +6 -6
  48. package/src/entities.js +1 -2
  49. package/src/hooks/use-entity-record.ts +4 -4
  50. package/src/hooks/use-entity-records.ts +4 -4
  51. package/src/hooks/use-resource-permissions.ts +2 -2
  52. package/src/queried-data/selectors.js +5 -2
  53. package/src/reducer.js +2 -6
  54. package/src/selectors.ts +174 -218
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -58,10 +58,10 @@ export interface Options {
58
58
  *
59
59
  * @since 6.1.0 Introduced in WordPress core.
60
60
  *
61
- * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
62
- * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
63
- * @param recordId ID of the requested entity record.
64
- * @param options Optional hook options.
61
+ * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
62
+ * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
63
+ * @param recordId ID of the requested entity record.
64
+ * @param options Optional hook options.
65
65
  * @example
66
66
  * ```js
67
67
  * import { useEntityRecord } from '@wordpress/core-data';
@@ -37,10 +37,10 @@ const EMPTY_ARRAY = [];
37
37
  *
38
38
  * @since 6.1.0 Introduced in WordPress core.
39
39
  *
40
- * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
41
- * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
42
- * @param queryArgs Optional HTTP query description for how to fetch the data, passed to the requested API endpoint.
43
- * @param options Optional hook options.
40
+ * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.
41
+ * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.
42
+ * @param queryArgs Optional HTTP query description for how to fetch the data, passed to the requested API endpoint.
43
+ * @param options Optional hook options.
44
44
  * @example
45
45
  * ```js
46
46
  * import { useEntityRecord } from '@wordpress/core-data';
@@ -46,8 +46,8 @@ type ResourcePermissionsResolution< IdType > = [
46
46
  *
47
47
  * @since 6.1.0 Introduced in WordPress core.
48
48
  *
49
- * @param resource The resource in question, e.g. media.
50
- * @param id ID of a specific resource entry, if needed, e.g. 10.
49
+ * @param resource The resource in question, e.g. media.
50
+ * @param id ID of a specific resource entry, if needed, e.g. 10.
51
51
  *
52
52
  * @example
53
53
  * ```js
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import createSelector from 'rememo';
5
5
  import EquivalentKeyMap from 'equivalent-key-map';
6
- import { get, set } from 'lodash';
6
+ import { set } from 'lodash';
7
7
 
8
8
  /**
9
9
  * Internal dependencies
@@ -66,7 +66,10 @@ function getQueriedItemsUncached( state, query ) {
66
66
 
67
67
  for ( let f = 0; f < fields.length; f++ ) {
68
68
  const field = fields[ f ].split( '.' );
69
- const value = get( item, field );
69
+ let value = item;
70
+ field.forEach( ( fieldName ) => {
71
+ value = value[ fieldName ];
72
+ } );
70
73
  set( filteredItem, field, value );
71
74
  }
72
75
  } else {
package/src/reducer.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import fastDeepEqual from 'fast-deep-equal/es6';
5
- import { groupBy, get } from 'lodash';
5
+ import { groupBy } from 'lodash';
6
6
 
7
7
  /**
8
8
  * WordPress dependencies
@@ -245,11 +245,7 @@ function entity( entityConfig ) {
245
245
  // comparison.
246
246
  ! fastDeepEqual(
247
247
  edits[ key ],
248
- get(
249
- record[ key ],
250
- 'raw',
251
- record[ key ]
252
- )
248
+ record[ key ]?.raw ?? record[ key ]
253
249
  ) &&
254
250
  // Sometimes the server alters the sent value which means
255
251
  // we need to also remove the edits before the api request.