@wordpress/core-data 4.2.0 → 4.4.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 (147) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +68 -11
  3. package/build/actions.js +61 -41
  4. package/build/actions.js.map +1 -1
  5. package/build/batch/default-processor.js +1 -1
  6. package/build/batch/default-processor.js.map +1 -1
  7. package/build/entities.js +36 -23
  8. package/build/entities.js.map +1 -1
  9. package/build/entity-provider.js +46 -44
  10. package/build/entity-provider.js.map +1 -1
  11. package/build/entity-types/{base-entity-types.js → base-entity-records.js} +9 -9
  12. package/build/entity-types/base-entity-records.js.map +1 -0
  13. package/build/fetch/__experimental-fetch-link-suggestions.js +48 -11
  14. package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  15. package/build/fetch/__experimental-fetch-url-data.js +1 -1
  16. package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
  17. package/build/hooks/use-entity-record.js +15 -5
  18. package/build/hooks/use-entity-record.js.map +1 -1
  19. package/build/hooks/use-entity-records.js +14 -2
  20. package/build/hooks/use-entity-records.js.map +1 -1
  21. package/build/hooks/use-query-select.js.map +1 -1
  22. package/build/index.js +9 -21
  23. package/build/index.js.map +1 -1
  24. package/build/queried-data/actions.js +4 -4
  25. package/build/queried-data/actions.js.map +1 -1
  26. package/build/queried-data/get-query-parts.js +7 -3
  27. package/build/queried-data/get-query-parts.js.map +1 -1
  28. package/build/queried-data/reducer.js +8 -6
  29. package/build/queried-data/reducer.js.map +1 -1
  30. package/build/reducer.js +77 -25
  31. package/build/reducer.js.map +1 -1
  32. package/build/resolvers.js +48 -24
  33. package/build/resolvers.js.map +1 -1
  34. package/build/selectors.js +122 -55
  35. package/build/selectors.js.map +1 -1
  36. package/build/types.js +6 -0
  37. package/build/types.js.map +1 -0
  38. package/build/utils/conservative-map-item.js +1 -1
  39. package/build/utils/conservative-map-item.js.map +1 -1
  40. package/build/utils/if-matching-action.js +4 -2
  41. package/build/utils/if-matching-action.js.map +1 -1
  42. package/build/utils/is-raw-attribute.js +1 -1
  43. package/build/utils/is-raw-attribute.js.map +1 -1
  44. package/build/utils/on-sub-key.js +3 -1
  45. package/build/utils/on-sub-key.js.map +1 -1
  46. package/build/utils/replace-action.js +4 -2
  47. package/build/utils/replace-action.js.map +1 -1
  48. package/build-module/actions.js +62 -42
  49. package/build-module/actions.js.map +1 -1
  50. package/build-module/batch/default-processor.js +1 -1
  51. package/build-module/batch/default-processor.js.map +1 -1
  52. package/build-module/entities.js +32 -19
  53. package/build-module/entities.js.map +1 -1
  54. package/build-module/entity-provider.js +47 -45
  55. package/build-module/entity-provider.js.map +1 -1
  56. package/build-module/entity-types/{base-entity-types.js → base-entity-records.js} +7 -7
  57. package/build-module/entity-types/base-entity-records.js.map +1 -0
  58. package/build-module/fetch/__experimental-fetch-link-suggestions.js +48 -11
  59. package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
  60. package/build-module/fetch/__experimental-fetch-url-data.js +1 -1
  61. package/build-module/fetch/__experimental-fetch-url-data.js.map +1 -1
  62. package/build-module/hooks/use-entity-record.js +15 -5
  63. package/build-module/hooks/use-entity-record.js.map +1 -1
  64. package/build-module/hooks/use-entity-records.js +14 -2
  65. package/build-module/hooks/use-entity-records.js.map +1 -1
  66. package/build-module/hooks/use-query-select.js.map +1 -1
  67. package/build-module/index.js +10 -22
  68. package/build-module/index.js.map +1 -1
  69. package/build-module/queried-data/actions.js +4 -4
  70. package/build-module/queried-data/actions.js.map +1 -1
  71. package/build-module/queried-data/get-query-parts.js +7 -3
  72. package/build-module/queried-data/get-query-parts.js.map +1 -1
  73. package/build-module/queried-data/reducer.js +8 -6
  74. package/build-module/queried-data/reducer.js.map +1 -1
  75. package/build-module/reducer.js +75 -26
  76. package/build-module/reducer.js.map +1 -1
  77. package/build-module/resolvers.js +42 -24
  78. package/build-module/resolvers.js.map +1 -1
  79. package/build-module/selectors.js +114 -55
  80. package/build-module/selectors.js.map +1 -1
  81. package/build-module/types.js +2 -0
  82. package/build-module/types.js.map +1 -0
  83. package/build-module/utils/conservative-map-item.js +1 -1
  84. package/build-module/utils/conservative-map-item.js.map +1 -1
  85. package/build-module/utils/if-matching-action.js +4 -2
  86. package/build-module/utils/if-matching-action.js.map +1 -1
  87. package/build-module/utils/is-raw-attribute.js +1 -1
  88. package/build-module/utils/is-raw-attribute.js.map +1 -1
  89. package/build-module/utils/on-sub-key.js +3 -1
  90. package/build-module/utils/on-sub-key.js.map +1 -1
  91. package/build-module/utils/replace-action.js +4 -2
  92. package/build-module/utils/replace-action.js.map +1 -1
  93. package/package.json +11 -11
  94. package/src/actions.js +62 -42
  95. package/src/batch/default-processor.js +1 -0
  96. package/src/{entities.js → entities.ts} +50 -21
  97. package/src/entity-provider.js +50 -44
  98. package/src/entity-types/attachment.ts +5 -5
  99. package/src/entity-types/{base-entity-types.ts → base-entity-records.ts} +5 -5
  100. package/src/entity-types/comment.ts +5 -5
  101. package/src/entity-types/helpers.ts +1 -1
  102. package/src/entity-types/index.ts +4 -4
  103. package/src/entity-types/menu-location.ts +5 -5
  104. package/src/entity-types/nav-menu-item.ts +10 -5
  105. package/src/entity-types/nav-menu.ts +5 -5
  106. package/src/entity-types/navigation-area.ts +5 -5
  107. package/src/entity-types/page.ts +5 -5
  108. package/src/entity-types/plugin.ts +10 -5
  109. package/src/entity-types/post.ts +5 -5
  110. package/src/entity-types/settings.ts +10 -5
  111. package/src/entity-types/sidebar.ts +6 -7
  112. package/src/entity-types/taxonomy.ts +5 -5
  113. package/src/entity-types/theme.ts +5 -5
  114. package/src/entity-types/type.ts +5 -5
  115. package/src/entity-types/user.ts +10 -5
  116. package/src/entity-types/widget-type.ts +5 -5
  117. package/src/entity-types/widget.ts +5 -5
  118. package/src/entity-types/wp-template-part.ts +5 -5
  119. package/src/entity-types/wp-template.ts +5 -5
  120. package/src/fetch/__experimental-fetch-link-suggestions.js +56 -20
  121. package/src/fetch/__experimental-fetch-url-data.js +1 -0
  122. package/src/fetch/test/__experimental-fetch-link-suggestions.js +39 -1
  123. package/src/hooks/use-entity-record.ts +19 -8
  124. package/src/hooks/use-entity-records.ts +23 -6
  125. package/src/hooks/use-query-select.ts +12 -7
  126. package/src/index.js +10 -15
  127. package/src/locks/test/selectors.js +4 -4
  128. package/src/queried-data/actions.js +4 -4
  129. package/src/queried-data/get-query-parts.js +5 -5
  130. package/src/queried-data/reducer.js +6 -6
  131. package/src/reducer.js +67 -24
  132. package/src/resolvers.js +39 -30
  133. package/src/{selectors.js → selectors.ts} +118 -57
  134. package/src/test/actions.js +138 -33
  135. package/src/test/entities.js +11 -11
  136. package/src/test/reducer.js +4 -4
  137. package/src/test/resolvers.js +5 -5
  138. package/src/test/selectors.js +22 -22
  139. package/src/types.ts +3 -0
  140. package/src/utils/conservative-map-item.js +1 -1
  141. package/src/utils/if-matching-action.js +4 -2
  142. package/src/utils/is-raw-attribute.js +1 -1
  143. package/src/utils/on-sub-key.js +3 -1
  144. package/src/utils/replace-action.js +4 -2
  145. package/src/utils/test/is-raw-attribute.js +4 -4
  146. package/build/entity-types/base-entity-types.js.map +0 -1
  147. package/build-module/entity-types/base-entity-types.js.map +0 -1
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { isEqual } from 'lodash';
5
5
  /**
6
- * Given the current and next item entity, returns the minimally "modified"
6
+ * Given the current and next item entity record, returns the minimally "modified"
7
7
  * result of the next item, preferring value references from the original item
8
8
  * if equal. If all values match, the original item is returned.
9
9
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/utils/conservative-map-item.js"],"names":["isEqual","conservativeMapItem","item","nextItem","hasChanges","result","key","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,mBAAT,CAA8BC,IAA9B,EAAoCC,QAApC,EAA+C;AAC7D;AACA,MAAK,CAAED,IAAP,EAAc;AACb,WAAOC,QAAP;AACA;;AAED,MAAIC,UAAU,GAAG,KAAjB;AACA,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,MAAMC,GAAZ,IAAmBH,QAAnB,EAA8B;AAC7B,QAAKH,OAAO,CAAEE,IAAI,CAAEI,GAAF,CAAN,EAAeH,QAAQ,CAAEG,GAAF,CAAvB,CAAZ,EAA+C;AAC9CD,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBJ,IAAI,CAAEI,GAAF,CAApB;AACA,KAFD,MAEO;AACNF,MAAAA,UAAU,GAAG,IAAb;AACAC,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBH,QAAQ,CAAEG,GAAF,CAAxB;AACA;AACD;;AAED,MAAK,CAAEF,UAAP,EAAoB;AACnB,WAAOF,IAAP;AACA,GAnB4D,CAqB7D;AACA;AACA;;;AACA,OAAM,MAAMI,GAAZ,IAAmBJ,IAAnB,EAA0B;AACzB,QAAK,CAAEG,MAAM,CAACE,cAAP,CAAuBD,GAAvB,CAAP,EAAsC;AACrCD,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBJ,IAAI,CAAEI,GAAF,CAApB;AACA;AACD;;AAED,SAAOD,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * Given the current and next item entity, returns the minimally \"modified\"\n * result of the next item, preferring value references from the original item\n * if equal. If all values match, the original item is returned.\n *\n * @param {Object} item Original item.\n * @param {Object} nextItem Next item.\n *\n * @return {Object} Minimally modified merged item.\n */\nexport default function conservativeMapItem( item, nextItem ) {\n\t// Return next item in its entirety if there is no original item.\n\tif ( ! item ) {\n\t\treturn nextItem;\n\t}\n\n\tlet hasChanges = false;\n\tconst result = {};\n\tfor ( const key in nextItem ) {\n\t\tif ( isEqual( item[ key ], nextItem[ key ] ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t} else {\n\t\t\thasChanges = true;\n\t\t\tresult[ key ] = nextItem[ key ];\n\t\t}\n\t}\n\n\tif ( ! hasChanges ) {\n\t\treturn item;\n\t}\n\n\t// Only at this point, backfill properties from the original item which\n\t// weren't explicitly set into the result above. This is an optimization\n\t// to allow `hasChanges` to return early.\n\tfor ( const key in item ) {\n\t\tif ( ! result.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/utils/conservative-map-item.js"],"names":["isEqual","conservativeMapItem","item","nextItem","hasChanges","result","key","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,mBAAT,CAA8BC,IAA9B,EAAoCC,QAApC,EAA+C;AAC7D;AACA,MAAK,CAAED,IAAP,EAAc;AACb,WAAOC,QAAP;AACA;;AAED,MAAIC,UAAU,GAAG,KAAjB;AACA,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,MAAMC,GAAZ,IAAmBH,QAAnB,EAA8B;AAC7B,QAAKH,OAAO,CAAEE,IAAI,CAAEI,GAAF,CAAN,EAAeH,QAAQ,CAAEG,GAAF,CAAvB,CAAZ,EAA+C;AAC9CD,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBJ,IAAI,CAAEI,GAAF,CAApB;AACA,KAFD,MAEO;AACNF,MAAAA,UAAU,GAAG,IAAb;AACAC,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBH,QAAQ,CAAEG,GAAF,CAAxB;AACA;AACD;;AAED,MAAK,CAAEF,UAAP,EAAoB;AACnB,WAAOF,IAAP;AACA,GAnB4D,CAqB7D;AACA;AACA;;;AACA,OAAM,MAAMI,GAAZ,IAAmBJ,IAAnB,EAA0B;AACzB,QAAK,CAAEG,MAAM,CAACE,cAAP,CAAuBD,GAAvB,CAAP,EAAsC;AACrCD,MAAAA,MAAM,CAAEC,GAAF,CAAN,GAAgBJ,IAAI,CAAEI,GAAF,CAApB;AACA;AACD;;AAED,SAAOD,MAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * Given the current and next item entity record, returns the minimally \"modified\"\n * result of the next item, preferring value references from the original item\n * if equal. If all values match, the original item is returned.\n *\n * @param {Object} item Original item.\n * @param {Object} nextItem Next item.\n *\n * @return {Object} Minimally modified merged item.\n */\nexport default function conservativeMapItem( item, nextItem ) {\n\t// Return next item in its entirety if there is no original item.\n\tif ( ! item ) {\n\t\treturn nextItem;\n\t}\n\n\tlet hasChanges = false;\n\tconst result = {};\n\tfor ( const key in nextItem ) {\n\t\tif ( isEqual( item[ key ], nextItem[ key ] ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t} else {\n\t\t\thasChanges = true;\n\t\t\tresult[ key ] = nextItem[ key ];\n\t\t}\n\t}\n\n\tif ( ! hasChanges ) {\n\t\treturn item;\n\t}\n\n\t// Only at this point, backfill properties from the original item which\n\t// weren't explicitly set into the result above. This is an optimization\n\t// to allow `hasChanges` to return early.\n\tfor ( const key in item ) {\n\t\tif ( ! result.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t}\n\t}\n\n\treturn result;\n}\n"]}
@@ -1,11 +1,13 @@
1
+ /** @typedef {import('../types').AnyFunction} AnyFunction */
2
+
1
3
  /**
2
4
  * A higher-order reducer creator which invokes the original reducer only if
3
5
  * the dispatching action matches the given predicate, **OR** if state is
4
6
  * initializing (undefined).
5
7
  *
6
- * @param {Function} isMatch Function predicate for allowing reducer call.
8
+ * @param {AnyFunction} isMatch Function predicate for allowing reducer call.
7
9
  *
8
- * @return {Function} Higher-order reducer.
10
+ * @return {AnyFunction} Higher-order reducer.
9
11
  */
10
12
  const ifMatchingAction = isMatch => reducer => (state, action) => {
11
13
  if (state === undefined || isMatch(action)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/utils/if-matching-action.js"],"names":["ifMatchingAction","isMatch","reducer","state","action","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,GAAKC,OAAF,IAAiBC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AAC3E,MAAKD,KAAK,KAAKE,SAAV,IAAuBJ,OAAO,CAAEG,MAAF,CAAnC,EAAgD;AAC/C,WAAOF,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAd;AACA;;AAED,SAAOD,KAAP;AACA,CAND;;AAQA,eAAeH,gBAAf","sourcesContent":["/**\n * A higher-order reducer creator which invokes the original reducer only if\n * the dispatching action matches the given predicate, **OR** if state is\n * initializing (undefined).\n *\n * @param {Function} isMatch Function predicate for allowing reducer call.\n *\n * @return {Function} Higher-order reducer.\n */\nconst ifMatchingAction = ( isMatch ) => ( reducer ) => ( state, action ) => {\n\tif ( state === undefined || isMatch( action ) ) {\n\t\treturn reducer( state, action );\n\t}\n\n\treturn state;\n};\n\nexport default ifMatchingAction;\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/utils/if-matching-action.js"],"names":["ifMatchingAction","isMatch","reducer","state","action","undefined"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,GAAKC,OAAF,IAAiBC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AAC3E,MAAKD,KAAK,KAAKE,SAAV,IAAuBJ,OAAO,CAAEG,MAAF,CAAnC,EAAgD;AAC/C,WAAOF,OAAO,CAAEC,KAAF,EAASC,MAAT,CAAd;AACA;;AAED,SAAOD,KAAP;AACA,CAND;;AAQA,eAAeH,gBAAf","sourcesContent":["/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * A higher-order reducer creator which invokes the original reducer only if\n * the dispatching action matches the given predicate, **OR** if state is\n * initializing (undefined).\n *\n * @param {AnyFunction} isMatch Function predicate for allowing reducer call.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nconst ifMatchingAction = ( isMatch ) => ( reducer ) => ( state, action ) => {\n\tif ( state === undefined || isMatch( action ) ) {\n\t\treturn reducer( state, action );\n\t}\n\n\treturn state;\n};\n\nexport default ifMatchingAction;\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Checks whether the attribute is a "raw" attribute or not.
3
3
  *
4
- * @param {Object} entity Entity data.
4
+ * @param {Object} entity Entity record.
5
5
  * @param {string} attribute Attribute name.
6
6
  *
7
7
  * @return {boolean} Is the attribute raw
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/utils/is-raw-attribute.js"],"names":["isRawAttribute","entity","attribute","rawAttributes","includes"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAT,CAAyBC,MAAzB,EAAiCC,SAAjC,EAA6C;AAC3D,SAAO,CAAED,MAAM,CAACE,aAAP,IAAwB,EAA1B,EAA+BC,QAA/B,CAAyCF,SAAzC,CAAP;AACA","sourcesContent":["/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity Entity data.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/utils/is-raw-attribute.js"],"names":["isRawAttribute","entity","attribute","rawAttributes","includes"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAT,CAAyBC,MAAzB,EAAiCC,SAAjC,EAA6C;AAC3D,SAAO,CAAED,MAAM,CAACE,aAAP,IAAwB,EAA1B,EAA+BC,QAA/B,CAAyCF,SAAzC,CAAP;AACA","sourcesContent":["/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity Entity record.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n"]}
@@ -1,10 +1,12 @@
1
+ /** @typedef {import('../types').AnyFunction} AnyFunction */
2
+
1
3
  /**
2
4
  * Higher-order reducer creator which creates a combined reducer object, keyed
3
5
  * by a property on the action object.
4
6
  *
5
7
  * @param {string} actionProperty Action property by which to key object.
6
8
  *
7
- * @return {Function} Higher-order reducer.
9
+ * @return {AnyFunction} Higher-order reducer.
8
10
  */
9
11
  export const onSubKey = actionProperty => reducer => function () {
10
12
  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,YAGxD;AAAA,MAFJC,KAEI,uEAFI,EAEJ;AAAA,MADJC,MACI;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;AAwBP,eAAeP,QAAf","sourcesContent":["/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {Function} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/utils/on-sub-key.js"],"names":["onSubKey","actionProperty","reducer","state","action","key","undefined","nextKeyState"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAKC,cAAF,IAAwBC,OAAF,IAAe,YAGxD;AAAA,MAFJC,KAEI,uEAFI,EAEJ;AAAA,MADJC,MACI;AACJ;AACA;AACA,QAAMC,GAAG,GAAGD,MAAM,CAAEH,cAAF,CAAlB;;AACA,MAAKI,GAAG,KAAKC,SAAb,EAAyB;AACxB,WAAOH,KAAP;AACA,GANG,CAQJ;AACA;;;AACA,QAAMI,YAAY,GAAGL,OAAO,CAAEC,KAAK,CAAEE,GAAF,CAAP,EAAgBD,MAAhB,CAA5B;;AACA,MAAKG,YAAY,KAAKJ,KAAK,CAAEE,GAAF,CAA3B,EAAqC;AACpC,WAAOF,KAAP;AACA;;AAED,SAAO,EACN,GAAGA,KADG;AAEN,KAAEE,GAAF,GAASE;AAFH,GAAP;AAIA,CAtBM;AAwBP,eAAeP,QAAf","sourcesContent":["/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nexport const onSubKey = ( actionProperty ) => ( reducer ) => (\n\tstate = {},\n\taction\n) => {\n\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t// where reducer is scoped by action shape.\n\tconst key = action[ actionProperty ];\n\tif ( key === undefined ) {\n\t\treturn state;\n\t}\n\n\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t// reducer which returns undefined on a key which is not yet tracked.\n\tconst nextKeyState = reducer( state[ key ], action );\n\tif ( nextKeyState === state[ key ] ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t...state,\n\t\t[ key ]: nextKeyState,\n\t};\n};\n\nexport default onSubKey;\n"]}
@@ -1,10 +1,12 @@
1
+ /** @typedef {import('../types').AnyFunction} AnyFunction */
2
+
1
3
  /**
2
4
  * Higher-order reducer creator which substitutes the action object before
3
5
  * passing to the original reducer.
4
6
  *
5
- * @param {Function} replacer Function mapping original action to replacement.
7
+ * @param {AnyFunction} replacer Function mapping original action to replacement.
6
8
  *
7
- * @return {Function} Higher-order reducer.
9
+ * @return {AnyFunction} Higher-order reducer.
8
10
  */
9
11
  const replaceAction = replacer => reducer => (state, action) => {
10
12
  return reducer(state, replacer(action));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/utils/replace-action.js"],"names":["replaceAction","replacer","reducer","state","action"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,aAAa,GAAKC,QAAF,IAAkBC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACzE,SAAOF,OAAO,CAAEC,KAAF,EAASF,QAAQ,CAAEG,MAAF,CAAjB,CAAd;AACA,CAFD;;AAIA,eAAeJ,aAAf","sourcesContent":["/**\n * Higher-order reducer creator which substitutes the action object before\n * passing to the original reducer.\n *\n * @param {Function} replacer Function mapping original action to replacement.\n *\n * @return {Function} Higher-order reducer.\n */\nconst replaceAction = ( replacer ) => ( reducer ) => ( state, action ) => {\n\treturn reducer( state, replacer( action ) );\n};\n\nexport default replaceAction;\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/utils/replace-action.js"],"names":["replaceAction","replacer","reducer","state","action"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,aAAa,GAAKC,QAAF,IAAkBC,OAAF,IAAe,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACzE,SAAOF,OAAO,CAAEC,KAAF,EAASF,QAAQ,CAAEG,MAAF,CAAjB,CAAd;AACA,CAFD;;AAIA,eAAeJ,aAAf","sourcesContent":["/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which substitutes the action object before\n * passing to the original reducer.\n *\n * @param {AnyFunction} replacer Function mapping original action to replacement.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nconst replaceAction = ( replacer ) => ( reducer ) => ( state, action ) => {\n\treturn reducer( state, replacer( action ) );\n};\n\nexport default replaceAction;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/core-data",
3
- "version": "4.2.0",
3
+ "version": "4.4.0",
4
4
  "description": "Access to and manipulation of core WordPress entities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -30,15 +30,15 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.16.0",
33
- "@wordpress/api-fetch": "^6.1.0",
34
- "@wordpress/blocks": "^11.3.0",
35
- "@wordpress/data": "^6.4.0",
36
- "@wordpress/deprecated": "^3.4.0",
37
- "@wordpress/element": "^4.2.0",
38
- "@wordpress/html-entities": "^3.4.0",
39
- "@wordpress/i18n": "^4.4.0",
40
- "@wordpress/is-shallow-equal": "^4.4.0",
41
- "@wordpress/url": "^3.5.0",
33
+ "@wordpress/api-fetch": "^6.3.0",
34
+ "@wordpress/blocks": "^11.5.0",
35
+ "@wordpress/data": "^6.6.0",
36
+ "@wordpress/deprecated": "^3.6.0",
37
+ "@wordpress/element": "^4.4.0",
38
+ "@wordpress/html-entities": "^3.6.0",
39
+ "@wordpress/i18n": "^4.6.0",
40
+ "@wordpress/is-shallow-equal": "^4.6.0",
41
+ "@wordpress/url": "^3.7.0",
42
42
  "equivalent-key-map": "^0.2.2",
43
43
  "lodash": "^4.17.21",
44
44
  "memize": "^1.1.0",
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "c37fd7edbc3e379540d7b24fce75a6f640a434ae"
54
+ "gitHead": "11eb1241e63c9240018323551c6753f8a5fa96f9"
55
55
  }
package/src/actions.js CHANGED
@@ -15,7 +15,7 @@ import deprecated from '@wordpress/deprecated';
15
15
  * Internal dependencies
16
16
  */
17
17
  import { receiveItems, removeItems, receiveQueriedItems } from './queried-data';
18
- import { getKindEntities, DEFAULT_ENTITY_KEY } from './entities';
18
+ import { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
19
19
  import { createBatch } from './batch';
20
20
  import { STORE_NAME } from './name';
21
21
 
@@ -66,8 +66,8 @@ export function addEntities( entities ) {
66
66
  /**
67
67
  * Returns an action object used in signalling that entity records have been received.
68
68
  *
69
- * @param {string} kind Kind of the received entity.
70
- * @param {string} name Name of the received entity.
69
+ * @param {string} kind Kind of the received entity record.
70
+ * @param {string} name Name of the received entity record.
71
71
  * @param {Array|Object} records Records received.
72
72
  * @param {?Object} query Query Object.
73
73
  * @param {?boolean} invalidateCache Should invalidate query caches.
@@ -209,34 +209,36 @@ export function receiveEmbedPreview( url, preview ) {
209
209
  /**
210
210
  * Action triggered to delete an entity record.
211
211
  *
212
- * @param {string} kind Kind of the deleted entity.
213
- * @param {string} name Name of the deleted entity.
214
- * @param {string} recordId Record ID of the deleted entity.
215
- * @param {?Object} query Special query parameters for the
216
- * DELETE API call.
217
- * @param {Object} [options] Delete options.
218
- * @param {Function} [options.__unstableFetch] Internal use only. Function to
219
- * call instead of `apiFetch()`.
220
- * Must return a promise.
212
+ * @param {string} kind Kind of the deleted entity.
213
+ * @param {string} name Name of the deleted entity.
214
+ * @param {string} recordId Record ID of the deleted entity.
215
+ * @param {?Object} query Special query parameters for the
216
+ * DELETE API call.
217
+ * @param {Object} [options] Delete options.
218
+ * @param {Function} [options.__unstableFetch] Internal use only. Function to
219
+ * call instead of `apiFetch()`.
220
+ * Must return a promise.
221
+ * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
222
+ * the exceptions. Defaults to false.
221
223
  */
222
224
  export const deleteEntityRecord = (
223
225
  kind,
224
226
  name,
225
227
  recordId,
226
228
  query,
227
- { __unstableFetch = apiFetch } = {}
229
+ { __unstableFetch = apiFetch, throwOnError = false } = {}
228
230
  ) => async ( { dispatch } ) => {
229
- const entities = await dispatch( getKindEntities( kind ) );
230
- const entity = find( entities, { kind, name } );
231
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
232
+ const entityConfig = find( configs, { kind, name } );
231
233
  let error;
232
234
  let deletedRecord = false;
233
- if ( ! entity || entity?.__experimentalNoFetch ) {
235
+ if ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {
234
236
  return;
235
237
  }
236
238
 
237
239
  const lock = await dispatch.__unstableAcquireStoreLock(
238
240
  STORE_NAME,
239
- [ 'entities', 'data', kind, name, recordId ],
241
+ [ 'entities', 'records', kind, name, recordId ],
240
242
  { exclusive: true }
241
243
  );
242
244
 
@@ -248,8 +250,9 @@ export const deleteEntityRecord = (
248
250
  recordId,
249
251
  } );
250
252
 
253
+ let hasError = false;
251
254
  try {
252
- let path = `${ entity.baseURL }/${ recordId }`;
255
+ let path = `${ entityConfig.baseURL }/${ recordId }`;
253
256
 
254
257
  if ( query ) {
255
258
  path = addQueryArgs( path, query );
@@ -262,6 +265,7 @@ export const deleteEntityRecord = (
262
265
 
263
266
  await dispatch( removeItems( kind, name, recordId, true ) );
264
267
  } catch ( _error ) {
268
+ hasError = true;
265
269
  error = _error;
266
270
  }
267
271
 
@@ -273,6 +277,10 @@ export const deleteEntityRecord = (
273
277
  error,
274
278
  } );
275
279
 
280
+ if ( hasError && throwOnError ) {
281
+ throw error;
282
+ }
283
+
276
284
  return deletedRecord;
277
285
  } finally {
278
286
  dispatch.__unstableReleaseStoreLock( lock );
@@ -299,13 +307,13 @@ export const editEntityRecord = (
299
307
  edits,
300
308
  options = {}
301
309
  ) => ( { select, dispatch } ) => {
302
- const entity = select.getEntity( kind, name );
303
- if ( ! entity ) {
310
+ const entityConfig = select.getEntityConfig( kind, name );
311
+ if ( ! entityConfig ) {
304
312
  throw new Error(
305
313
  `The entity being edited (${ kind }, ${ name }) does not have a loaded config.`
306
314
  );
307
315
  }
308
- const { transientEdits = {}, mergedEdits = {} } = entity;
316
+ const { transientEdits = {}, mergedEdits = {} } = entityConfig;
309
317
  const record = select.getRawEntityRecord( kind, name, recordId );
310
318
  const editedRecord = select.getEditedEntityRecord( kind, name, recordId );
311
319
 
@@ -386,32 +394,38 @@ export function __unstableCreateUndoLevel() {
386
394
  /**
387
395
  * Action triggered to save an entity record.
388
396
  *
389
- * @param {string} kind Kind of the received entity.
390
- * @param {string} name Name of the received entity.
391
- * @param {Object} record Record to be saved.
392
- * @param {Object} options Saving options.
393
- * @param {boolean} [options.isAutosave=false] Whether this is an autosave.
394
- * @param {Function} [options.__unstableFetch] Internal use only. Function to
395
- * call instead of `apiFetch()`.
396
- * Must return a promise.
397
+ * @param {string} kind Kind of the received entity.
398
+ * @param {string} name Name of the received entity.
399
+ * @param {Object} record Record to be saved.
400
+ * @param {Object} options Saving options.
401
+ * @param {boolean} [options.isAutosave=false] Whether this is an autosave.
402
+ * @param {Function} [options.__unstableFetch] Internal use only. Function to
403
+ * call instead of `apiFetch()`.
404
+ * Must return a promise.
405
+ * @param {boolean} [options.throwOnError=false] If false, this action suppresses all
406
+ * the exceptions. Defaults to false.
397
407
  */
398
408
  export const saveEntityRecord = (
399
409
  kind,
400
410
  name,
401
411
  record,
402
- { isAutosave = false, __unstableFetch = apiFetch } = {}
412
+ {
413
+ isAutosave = false,
414
+ __unstableFetch = apiFetch,
415
+ throwOnError = false,
416
+ } = {}
403
417
  ) => async ( { select, resolveSelect, dispatch } ) => {
404
- const entities = await dispatch( getKindEntities( kind ) );
405
- const entity = find( entities, { kind, name } );
406
- if ( ! entity || entity?.__experimentalNoFetch ) {
418
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
419
+ const entityConfig = find( configs, { kind, name } );
420
+ if ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {
407
421
  return;
408
422
  }
409
- const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
423
+ const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
410
424
  const recordId = record[ entityIdKey ];
411
425
 
412
426
  const lock = await dispatch.__unstableAcquireStoreLock(
413
427
  STORE_NAME,
414
- [ 'entities', 'data', kind, name, recordId || uuid() ],
428
+ [ 'entities', 'records', kind, name, recordId || uuid() ],
415
429
  { exclusive: true }
416
430
  );
417
431
 
@@ -445,8 +459,9 @@ export const saveEntityRecord = (
445
459
  } );
446
460
  let updatedRecord;
447
461
  let error;
462
+ let hasError = false;
448
463
  try {
449
- const path = `${ entity.baseURL }${
464
+ const path = `${ entityConfig.baseURL }${
450
465
  recordId ? '/' + recordId : ''
451
466
  }`;
452
467
  const persistedRecord = select.getRawEntityRecord(
@@ -543,10 +558,10 @@ export const saveEntityRecord = (
543
558
  }
544
559
  } else {
545
560
  let edits = record;
546
- if ( entity.__unstablePrePersist ) {
561
+ if ( entityConfig.__unstablePrePersist ) {
547
562
  edits = {
548
563
  ...edits,
549
- ...entity.__unstablePrePersist(
564
+ ...entityConfig.__unstablePrePersist(
550
565
  persistedRecord,
551
566
  edits
552
567
  ),
@@ -567,6 +582,7 @@ export const saveEntityRecord = (
567
582
  );
568
583
  }
569
584
  } catch ( _error ) {
585
+ hasError = true;
570
586
  error = _error;
571
587
  }
572
588
  dispatch( {
@@ -578,6 +594,10 @@ export const saveEntityRecord = (
578
594
  isAutosave,
579
595
  } );
580
596
 
597
+ if ( hasError && throwOnError ) {
598
+ throw error;
599
+ }
600
+
581
601
  return updatedRecord;
582
602
  } finally {
583
603
  dispatch.__unstableReleaseStoreLock( lock );
@@ -659,12 +679,12 @@ export const saveEditedEntityRecord = (
659
679
  if ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {
660
680
  return;
661
681
  }
662
- const entities = await dispatch( getKindEntities( kind ) );
663
- const entity = find( entities, { kind, name } );
664
- if ( ! entity ) {
682
+ const configs = await dispatch( getOrLoadEntitiesConfig( kind ) );
683
+ const entityConfig = find( configs, { kind, name } );
684
+ if ( ! entityConfig ) {
665
685
  return;
666
686
  }
667
- const entityIdKey = entity.key || DEFAULT_ENTITY_KEY;
687
+ const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
668
688
 
669
689
  const edits = select.getEntityRecordNonTransientEdits(
670
690
  kind,
@@ -36,6 +36,7 @@ export default async function defaultProcessor( requests ) {
36
36
 
37
37
  const results = [];
38
38
 
39
+ // @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.
39
40
  for ( const batchRequests of chunk( requests, maxItems ) ) {
40
41
  const batchResponse = await apiFetch( {
41
42
  path: '/batch/v1',
@@ -13,17 +13,31 @@ import { __ } from '@wordpress/i18n';
13
13
  * Internal dependencies
14
14
  */
15
15
  import { addEntities } from './actions';
16
+ import type { Post, Taxonomy, Type, Updatable } from './entity-types';
16
17
 
17
18
  export const DEFAULT_ENTITY_KEY = 'id';
18
19
 
19
20
  const POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];
20
21
 
21
- export const defaultEntities = [
22
+ export const rootEntitiesConfig = [
22
23
  {
23
24
  label: __( 'Base' ),
24
25
  name: '__unstableBase',
25
26
  kind: 'root',
26
27
  baseURL: '/',
28
+ baseURLParams: {
29
+ _fields: [
30
+ 'description',
31
+ 'gmt_offset',
32
+ 'home',
33
+ 'name',
34
+ 'site_icon',
35
+ 'site_icon_url',
36
+ 'site_logo',
37
+ 'timezone_string',
38
+ 'url',
39
+ ].join( ',' ),
40
+ },
27
41
  },
28
42
  {
29
43
  label: __( 'Site' ),
@@ -50,6 +64,7 @@ export const defaultEntities = [
50
64
  baseURLParams: { context: 'edit' },
51
65
  plural: 'mediaItems',
52
66
  label: __( 'Media' ),
67
+ rawAttributes: [ 'caption', 'title', 'description' ],
53
68
  },
54
69
  {
55
70
  name: 'taxonomy',
@@ -164,9 +179,9 @@ export const defaultEntities = [
164
179
  },
165
180
  ];
166
181
 
167
- export const kinds = [
168
- { name: 'postType', loadEntities: loadPostTypeEntities },
169
- { name: 'taxonomy', loadEntities: loadTaxonomyEntities },
182
+ export const additionalEntityConfigLoaders = [
183
+ { kind: 'postType', loadEntities: loadPostTypeEntities },
184
+ { kind: 'taxonomy', loadEntities: loadTaxonomyEntities },
170
185
  ];
171
186
 
172
187
  /**
@@ -177,7 +192,7 @@ export const kinds = [
177
192
  * @return {Object} Updated edits.
178
193
  */
179
194
  export const prePersistPostType = ( persistedRecord, edits ) => {
180
- const newEdits = {};
195
+ const newEdits = {} as Partial< Updatable< Post< 'edit' > > >;
181
196
 
182
197
  if ( persistedRecord?.status === 'auto-draft' ) {
183
198
  // Saving an auto-draft should create a draft by default.
@@ -205,7 +220,9 @@ export const prePersistPostType = ( persistedRecord, edits ) => {
205
220
  * @return {Promise} Entities promise
206
221
  */
207
222
  async function loadPostTypeEntities() {
208
- const postTypes = await apiFetch( { path: '/wp/v2/types?context=view' } );
223
+ const postTypes = ( await apiFetch( {
224
+ path: '/wp/v2/types?context=view',
225
+ } ) ) as Record< string, Type< 'view' > >;
209
226
  return map( postTypes, ( postType, name ) => {
210
227
  const isTemplate = [ 'wp_template', 'wp_template_part' ].includes(
211
228
  name
@@ -239,9 +256,9 @@ async function loadPostTypeEntities() {
239
256
  * @return {Promise} Entities promise
240
257
  */
241
258
  async function loadTaxonomyEntities() {
242
- const taxonomies = await apiFetch( {
259
+ const taxonomies = ( await apiFetch( {
243
260
  path: '/wp/v2/taxonomies?context=view',
244
- } );
261
+ } ) ) as Record< string, Taxonomy< 'view' > >;
245
262
  return map( taxonomies, ( taxonomy, name ) => {
246
263
  const namespace = taxonomy?.rest_namespace ?? 'wp/v2';
247
264
  return {
@@ -257,6 +274,15 @@ async function loadTaxonomyEntities() {
257
274
  /**
258
275
  * Returns the entity's getter method name given its kind and name.
259
276
  *
277
+ * @example
278
+ * ```js
279
+ * const nameSingular = getMethodName( 'root', 'theme', 'get' );
280
+ * // nameSingular is getRootTheme
281
+ *
282
+ * const namePlural = getMethodName( 'root', 'theme', 'set' );
283
+ * // namePlural is setRootThemes
284
+ * ```
285
+ *
260
286
  * @param {string} kind Entity kind.
261
287
  * @param {string} name Entity name.
262
288
  * @param {string} prefix Function prefix.
@@ -270,13 +296,13 @@ export const getMethodName = (
270
296
  prefix = 'get',
271
297
  usePlural = false
272
298
  ) => {
273
- const entity = find( defaultEntities, { kind, name } );
299
+ const entityConfig = find( rootEntitiesConfig, { kind, name } );
274
300
  const kindPrefix = kind === 'root' ? '' : upperFirst( camelCase( kind ) );
275
301
  const nameSuffix =
276
302
  upperFirst( camelCase( name ) ) + ( usePlural ? 's' : '' );
277
303
  const suffix =
278
- usePlural && entity.plural
279
- ? upperFirst( camelCase( entity.plural ) )
304
+ usePlural && entityConfig?.plural
305
+ ? upperFirst( camelCase( entityConfig.plural ) )
280
306
  : nameSuffix;
281
307
  return `${ prefix }${ kindPrefix }${ suffix }`;
282
308
  };
@@ -286,21 +312,24 @@ export const getMethodName = (
286
312
  *
287
313
  * @param {string} kind Kind
288
314
  *
289
- * @return {Array} Entities
315
+ * @return {(thunkArgs: object) => Promise<Array>} Entities
290
316
  */
291
- export const getKindEntities = ( kind ) => async ( { select, dispatch } ) => {
292
- let entities = select.getEntitiesByKind( kind );
293
- if ( entities && entities.length !== 0 ) {
294
- return entities;
317
+ export const getOrLoadEntitiesConfig = ( kind ) => async ( {
318
+ select,
319
+ dispatch,
320
+ } ) => {
321
+ let configs = select.getEntitiesConfig( kind );
322
+ if ( configs && configs.length !== 0 ) {
323
+ return configs;
295
324
  }
296
325
 
297
- const kindConfig = find( kinds, { name: kind } );
298
- if ( ! kindConfig ) {
326
+ const loader = find( additionalEntityConfigLoaders, { kind } );
327
+ if ( ! loader ) {
299
328
  return [];
300
329
  }
301
330
 
302
- entities = await kindConfig.loadEntities();
303
- dispatch( addEntities( entities ) );
331
+ configs = await loader.loadEntities();
332
+ dispatch( addEntities( configs ) );
304
333
 
305
- return entities;
334
+ return configs;
306
335
  };