@wordpress/core-data 4.13.0 → 5.0.1-next.957ca95e4c.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 (201) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +148 -65
  3. package/build/entities.js +38 -51
  4. package/build/entities.js.map +1 -1
  5. package/build/hooks/index.js +14 -0
  6. package/build/hooks/index.js.map +1 -1
  7. package/build/hooks/use-entity-record.js +10 -6
  8. package/build/hooks/use-entity-record.js.map +1 -1
  9. package/build/hooks/use-entity-records.js +2 -0
  10. package/build/hooks/use-entity-records.js.map +1 -1
  11. package/build/hooks/use-query-select.js +5 -2
  12. package/build/hooks/use-query-select.js.map +1 -1
  13. package/build/hooks/use-resource-permissions.js +74 -11
  14. package/build/hooks/use-resource-permissions.js.map +1 -1
  15. package/build/index.js +1 -30
  16. package/build/index.js.map +1 -1
  17. package/build/resolvers.js +17 -21
  18. package/build/resolvers.js.map +1 -1
  19. package/build/selectors.js +9 -46
  20. package/build/selectors.js.map +1 -1
  21. package/build-module/entities.js +38 -52
  22. package/build-module/entities.js.map +1 -1
  23. package/build-module/hooks/index.js +1 -0
  24. package/build-module/hooks/index.js.map +1 -1
  25. package/build-module/hooks/use-entity-record.js +10 -6
  26. package/build-module/hooks/use-entity-record.js.map +1 -1
  27. package/build-module/hooks/use-entity-records.js +2 -0
  28. package/build-module/hooks/use-entity-records.js.map +1 -1
  29. package/build-module/hooks/use-query-select.js +4 -1
  30. package/build-module/hooks/use-query-select.js.map +1 -1
  31. package/build-module/hooks/use-resource-permissions.js +70 -10
  32. package/build-module/hooks/use-resource-permissions.js.map +1 -1
  33. package/build-module/index.js +0 -5
  34. package/build-module/index.js.map +1 -1
  35. package/build-module/resolvers.js +17 -21
  36. package/build-module/resolvers.js.map +1 -1
  37. package/build-module/selectors.js +7 -44
  38. package/build-module/selectors.js.map +1 -1
  39. package/build-types/actions.d.ts +188 -0
  40. package/build-types/actions.d.ts.map +1 -0
  41. package/build-types/batch/create-batch.d.ts +71 -0
  42. package/build-types/batch/create-batch.d.ts.map +1 -0
  43. package/build-types/batch/default-processor.d.ts +11 -0
  44. package/build-types/batch/default-processor.d.ts.map +1 -0
  45. package/build-types/batch/index.d.ts +3 -0
  46. package/build-types/batch/index.d.ts.map +1 -0
  47. package/build-types/entities.d.ts +128 -0
  48. package/build-types/entities.d.ts.map +1 -0
  49. package/build-types/entity-provider.d.ts +68 -0
  50. package/build-types/entity-provider.d.ts.map +1 -0
  51. package/build-types/entity-types/attachment.d.ts +121 -0
  52. package/build-types/entity-types/attachment.d.ts.map +1 -0
  53. package/build-types/entity-types/base-entity-records.d.ts +37 -0
  54. package/build-types/entity-types/base-entity-records.d.ts.map +1 -0
  55. package/build-types/entity-types/comment.d.ts +82 -0
  56. package/build-types/entity-types/comment.d.ts.map +1 -0
  57. package/build-types/entity-types/helpers.d.ts +123 -0
  58. package/build-types/entity-types/helpers.d.ts.map +1 -0
  59. package/build-types/entity-types/index.d.ts +64 -0
  60. package/build-types/entity-types/index.d.ts.map +1 -0
  61. package/build-types/entity-types/menu-location.d.ts +25 -0
  62. package/build-types/entity-types/menu-location.d.ts.map +1 -0
  63. package/build-types/entity-types/nav-menu-item.d.ts +88 -0
  64. package/build-types/entity-types/nav-menu-item.d.ts.map +1 -0
  65. package/build-types/entity-types/nav-menu.d.ts +45 -0
  66. package/build-types/entity-types/nav-menu.d.ts.map +1 -0
  67. package/build-types/entity-types/page.d.ts +120 -0
  68. package/build-types/entity-types/page.d.ts.map +1 -0
  69. package/build-types/entity-types/plugin.d.ts +62 -0
  70. package/build-types/entity-types/plugin.d.ts.map +1 -0
  71. package/build-types/entity-types/post.d.ts +128 -0
  72. package/build-types/entity-types/post.d.ts.map +1 -0
  73. package/build-types/entity-types/settings.d.ts +89 -0
  74. package/build-types/entity-types/settings.d.ts.map +1 -0
  75. package/build-types/entity-types/sidebar.d.ts +55 -0
  76. package/build-types/entity-types/sidebar.d.ts.map +1 -0
  77. package/build-types/entity-types/taxonomy.d.ts +83 -0
  78. package/build-types/entity-types/taxonomy.d.ts.map +1 -0
  79. package/build-types/entity-types/theme.d.ts +206 -0
  80. package/build-types/entity-types/theme.d.ts.map +1 -0
  81. package/build-types/entity-types/type.d.ts +71 -0
  82. package/build-types/entity-types/type.d.ts.map +1 -0
  83. package/build-types/entity-types/user.d.ts +93 -0
  84. package/build-types/entity-types/user.d.ts.map +1 -0
  85. package/build-types/entity-types/widget-type.d.ts +33 -0
  86. package/build-types/entity-types/widget-type.d.ts.map +1 -0
  87. package/build-types/entity-types/widget.d.ts +59 -0
  88. package/build-types/entity-types/widget.d.ts.map +1 -0
  89. package/build-types/entity-types/wp-template-part.d.ts +80 -0
  90. package/build-types/entity-types/wp-template-part.d.ts.map +1 -0
  91. package/build-types/entity-types/wp-template.d.ts +80 -0
  92. package/build-types/entity-types/wp-template.d.ts.map +1 -0
  93. package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts +139 -0
  94. package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -0
  95. package/build-types/fetch/__experimental-fetch-url-data.d.ts +35 -0
  96. package/build-types/fetch/__experimental-fetch-url-data.d.ts.map +1 -0
  97. package/build-types/fetch/index.d.ts +3 -0
  98. package/build-types/fetch/index.d.ts.map +1 -0
  99. package/build-types/hooks/constants.d.ts +7 -0
  100. package/build-types/hooks/constants.d.ts.map +1 -0
  101. package/build-types/hooks/index.d.ts +4 -0
  102. package/build-types/hooks/index.d.ts.map +1 -0
  103. package/build-types/hooks/memoize.d.ts +3 -0
  104. package/build-types/hooks/memoize.d.ts.map +1 -0
  105. package/build-types/hooks/use-entity-record.d.ts +124 -0
  106. package/build-types/hooks/use-entity-record.d.ts.map +1 -0
  107. package/build-types/hooks/use-entity-records.d.ts +49 -0
  108. package/build-types/hooks/use-entity-records.d.ts.map +1 -0
  109. package/build-types/hooks/use-query-select.d.ts +46 -0
  110. package/build-types/hooks/use-query-select.d.ts.map +1 -0
  111. package/build-types/hooks/use-resource-permissions.d.ts +99 -0
  112. package/build-types/hooks/use-resource-permissions.d.ts.map +1 -0
  113. package/build-types/index.d.ts +131 -0
  114. package/build-types/index.d.ts.map +1 -0
  115. package/build-types/locks/actions.d.ts +7 -0
  116. package/build-types/locks/actions.d.ts.map +1 -0
  117. package/build-types/locks/engine.d.ts +5 -0
  118. package/build-types/locks/engine.d.ts.map +1 -0
  119. package/build-types/locks/reducer.d.ts +10 -0
  120. package/build-types/locks/reducer.d.ts.map +1 -0
  121. package/build-types/locks/selectors.d.ts +5 -0
  122. package/build-types/locks/selectors.d.ts.map +1 -0
  123. package/build-types/locks/utils.d.ts +8 -0
  124. package/build-types/locks/utils.d.ts.map +1 -0
  125. package/build-types/name.d.ts +8 -0
  126. package/build-types/name.d.ts.map +1 -0
  127. package/build-types/queried-data/actions.d.ts +32 -0
  128. package/build-types/queried-data/actions.d.ts.map +1 -0
  129. package/build-types/queried-data/get-query-parts.d.ts +60 -0
  130. package/build-types/queried-data/get-query-parts.d.ts.map +1 -0
  131. package/build-types/queried-data/index.d.ts +4 -0
  132. package/build-types/queried-data/index.d.ts.map +1 -0
  133. package/build-types/queried-data/reducer.d.ts +54 -0
  134. package/build-types/queried-data/reducer.d.ts.map +1 -0
  135. package/build-types/queried-data/selectors.d.ts +16 -0
  136. package/build-types/queried-data/selectors.d.ts.map +1 -0
  137. package/build-types/reducer.d.ts +156 -0
  138. package/build-types/reducer.d.ts.map +1 -0
  139. package/build-types/resolvers.d.ts +74 -0
  140. package/build-types/resolvers.d.ts.map +1 -0
  141. package/build-types/selectors.d.ts +524 -0
  142. package/build-types/selectors.d.ts.map +1 -0
  143. package/build-types/types.d.ts +4 -0
  144. package/build-types/types.d.ts.map +1 -0
  145. package/build-types/utils/conservative-map-item.d.ts +12 -0
  146. package/build-types/utils/conservative-map-item.d.ts.map +1 -0
  147. package/build-types/utils/forward-resolver.d.ts +10 -0
  148. package/build-types/utils/forward-resolver.d.ts.map +1 -0
  149. package/build-types/utils/get-normalized-comma-separable.d.ts +12 -0
  150. package/build-types/utils/get-normalized-comma-separable.d.ts.map +1 -0
  151. package/build-types/utils/if-matching-action.d.ts +14 -0
  152. package/build-types/utils/if-matching-action.d.ts.map +1 -0
  153. package/build-types/utils/index.d.ts +9 -0
  154. package/build-types/utils/index.d.ts.map +1 -0
  155. package/build-types/utils/is-raw-attribute.d.ts +10 -0
  156. package/build-types/utils/is-raw-attribute.d.ts.map +1 -0
  157. package/build-types/utils/on-sub-key.d.ts +4 -0
  158. package/build-types/utils/on-sub-key.d.ts.map +1 -0
  159. package/build-types/utils/replace-action.d.ts +13 -0
  160. package/build-types/utils/replace-action.d.ts.map +1 -0
  161. package/build-types/utils/with-weak-map-cache.d.ts +12 -0
  162. package/build-types/utils/with-weak-map-cache.d.ts.map +1 -0
  163. package/package.json +13 -11
  164. package/src/entities.js +325 -0
  165. package/src/entity-types/attachment.ts +3 -4
  166. package/src/entity-types/comment.ts +3 -4
  167. package/src/entity-types/index.ts +31 -88
  168. package/src/entity-types/menu-location.ts +3 -4
  169. package/src/entity-types/nav-menu-item.ts +3 -4
  170. package/src/entity-types/nav-menu.ts +3 -3
  171. package/src/entity-types/page.ts +3 -3
  172. package/src/entity-types/plugin.ts +3 -3
  173. package/src/entity-types/post.ts +3 -3
  174. package/src/entity-types/settings.ts +3 -3
  175. package/src/entity-types/sidebar.ts +3 -4
  176. package/src/entity-types/taxonomy.ts +3 -4
  177. package/src/entity-types/theme.ts +7 -3
  178. package/src/entity-types/type.ts +3 -3
  179. package/src/entity-types/user.ts +3 -3
  180. package/src/entity-types/widget-type.ts +3 -4
  181. package/src/entity-types/widget.ts +3 -3
  182. package/src/entity-types/wp-template-part.ts +3 -4
  183. package/src/entity-types/wp-template.ts +3 -4
  184. package/src/hooks/index.ts +4 -0
  185. package/src/hooks/test/use-entity-record.js +41 -1
  186. package/src/hooks/test/use-resource-permissions.js +32 -36
  187. package/src/hooks/use-entity-record.ts +18 -6
  188. package/src/hooks/use-entity-records.ts +2 -0
  189. package/src/hooks/use-query-select.ts +4 -1
  190. package/src/hooks/use-resource-permissions.ts +84 -20
  191. package/src/index.js +0 -5
  192. package/src/resolvers.js +36 -24
  193. package/src/selectors.ts +202 -341
  194. package/tsconfig.json +21 -0
  195. package/tsconfig.tsbuildinfo +1 -0
  196. package/build/entity-types/entities.js +0 -6
  197. package/build/entity-types/entities.js.map +0 -1
  198. package/build-module/entity-types/entities.js +0 -2
  199. package/build-module/entity-types/entities.js.map +0 -1
  200. package/src/entities.ts +0 -548
  201. package/src/entity-types/entities.ts +0 -130
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["entitySelectors","rootEntitiesConfig","reduce","result","entity","kind","name","state","key","query","selectors","getEntityRecord","getEntityRecords","entityResolvers","resolvers","pluralMethodName","args","shouldInvalidate","action","entityActions","actions","saveEntityRecord","deleteEntityRecord","storeConfig","reducer","store","STORE_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAuDA;;AAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAHA;;AACA;;AACA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AA5EA;AACA;AACA;;AAGA;AACA;AACA;AASA;AACA;AACA;AACA;AAEA,MAAMA,eAAe,GAAGC,6BAAmBC,MAAnB,CAA2B,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACxE,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiBF,MAAvB;;AACAD,EAAAA,M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ress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { rootEntitiesConfig, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, query ) =>\n\t\tselectors.getEntityRecords( state, kind, name, query );\n\treturn result;\n}, {} );\n\nconst entityResolvers = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\treturn result;\n}, {} );\n\nconst entityActions = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = ( key ) =>\n\t\tactions.saveEntityRecord( kind, name, key );\n\tresult[ getMethodName( kind, name, 'delete' ) ] = ( key, query ) =>\n\t\tactions.deleteEntityRecord( kind, name, key, query );\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: { ...actions, ...entityActions, ...createLocksActions() },\n\tselectors: { ...selectors, ...entitySelectors },\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\n\nregister( store );\n\nexport { default as EntityProvider } from './entity-provider';\nexport { default as useEntityRecord } from './hooks/use-entity-record';\nexport { default as useEntityRecords } from './hooks/use-entity-records';\nexport { default as __experimentalUseResourcePermissions } from './hooks/use-resource-permissions';\nexport * from './entity-provider';\nexport * from './entity-types';\nexport * from './fetch';\nexport * from './hooks';\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/index.js"],"names":["entitySelectors","rootEntitiesConfig","reduce","result","entity","kind","name","state","key","query","selectors","getEntityRecord","getEntityRecords","entityResolvers","resolvers","pluralMethodName","args","shouldInvalidate","action","entityActions","actions","saveEntityRecord","deleteEntityRecord","storeConfig","reducer","store","STORE_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAqDA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AAvEA;AACA;AACA;;AAGA;AACA;AACA;AASA;AACA;AACA;AACA;AAEA,MAAMA,eAAe,GAAGC,6BAAmBC,MAAnB,CAA2B,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACxE,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAiBF,MAAvB;;AACAD,EAAAA,MAAM,CAAE,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ependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { rootEntitiesConfig, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, query ) =>\n\t\tselectors.getEntityRecords( state, kind, name, query );\n\treturn result;\n}, {} );\n\nconst entityResolvers = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\treturn result;\n}, {} );\n\nconst entityActions = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = ( key ) =>\n\t\tactions.saveEntityRecord( kind, name, key );\n\tresult[ getMethodName( kind, name, 'delete' ) ] = ( key, query ) =>\n\t\tactions.deleteEntityRecord( kind, name, key, query );\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: { ...actions, ...entityActions, ...createLocksActions() },\n\tselectors: { ...selectors, ...entitySelectors },\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\n\nregister( store );\n\nexport { default as EntityProvider } from './entity-provider';\nexport * from './entity-provider';\nexport * from './entity-types';\nexport * from './fetch';\nexport * from './hooks';\n"]}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.getThemeSupports = exports.getRawEntityRecord = exports.getEntityRecords = exports.getEntityRecord = exports.getEmbedPreview = exports.getEditedEntityRecord = exports.getCurrentUser = exports.getCurrentTheme = exports.getBlockPatterns = exports.getBlockPatternCategories = exports.getAutosaves = exports.getAutosave = exports.getAuthors = exports.canUserEditEntityRecord = exports.canUser = exports.__experimentalGetTemplateForLink = exports.__experimentalGetCurrentThemeGlobalStylesVariations = exports.__experimentalGetCurrentThemeBaseGlobalStyles = exports.__experimentalGetCurrentGlobalStylesId = void 0;
9
9
 
10
- var _lodash = require("lodash");
10
+ var _changeCase = require("change-case");
11
11
 
12
12
  var _url = require("@wordpress/url");
13
13
 
@@ -86,10 +86,7 @@ const getEntityRecord = function (kind, name) {
86
86
  dispatch
87
87
  } = _ref3;
88
88
  const configs = await dispatch((0, _entities.getOrLoadEntitiesConfig)(kind));
89
- const entityConfig = (0, _lodash.find)(configs, {
90
- kind,
91
- name
92
- });
89
+ const entityConfig = configs.find(config => config.name === name && config.kind === kind);
93
90
 
94
91
  if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
95
92
  return;
@@ -105,7 +102,7 @@ const getEntityRecord = function (kind, name) {
105
102
  // records are stored by ID reference. Thus, fields must always include
106
103
  // the ID.
107
104
  query = { ...query,
108
- _fields: (0, _lodash.uniq)([...((0, _utils.getNormalizedCommaSeparable)(query._fields) || []), entityConfig.key || _entities.DEFAULT_ENTITY_KEY]).join()
105
+ _fields: [...new Set([...((0, _utils.getNormalizedCommaSeparable)(query._fields) || []), entityConfig.key || _entities.DEFAULT_ENTITY_KEY])].join()
109
106
  };
110
107
  } // Disable reason: While true that an early return could leave `path`
111
108
  // unused, it's important that path is derived using the query prior to
@@ -173,10 +170,7 @@ const getEntityRecords = function (kind, name) {
173
170
  dispatch
174
171
  } = _ref4;
175
172
  const configs = await dispatch((0, _entities.getOrLoadEntitiesConfig)(kind));
176
- const entityConfig = (0, _lodash.find)(configs, {
177
- kind,
178
- name
179
- });
173
+ const entityConfig = configs.find(config => config.name === name && config.kind === kind);
180
174
 
181
175
  if (!entityConfig || entityConfig !== null && entityConfig !== void 0 && entityConfig.__experimentalNoFetch) {
182
176
  return;
@@ -194,7 +188,7 @@ const getEntityRecords = function (kind, name) {
194
188
  // records are stored by ID reference. Thus, fields must always include
195
189
  // the ID.
196
190
  query = { ...query,
197
- _fields: (0, _lodash.uniq)([...((0, _utils.getNormalizedCommaSeparable)(query._fields) || []), entityConfig.key || _entities.DEFAULT_ENTITY_KEY]).join()
191
+ _fields: [...new Set([...((0, _utils.getNormalizedCommaSeparable)(query._fields) || []), entityConfig.key || _entities.DEFAULT_ENTITY_KEY])].join()
198
192
  };
199
193
  }
200
194
 
@@ -309,7 +303,7 @@ const getEmbedPreview = url => async _ref6 => {
309
303
  exports.getEmbedPreview = getEmbedPreview;
310
304
 
311
305
  const canUser = (action, resource, id) => async _ref7 => {
312
- var _response$headers;
306
+ var _response$headers, _allowHeader$includes;
313
307
 
314
308
  let {
315
309
  dispatch
@@ -346,7 +340,7 @@ const canUser = (action, resource, id) => async _ref7 => {
346
340
 
347
341
  const allowHeader = (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers.get('allow');
348
342
  const key = [action, resource, id].filter(Boolean).join('/');
349
- const isAllowed = (0, _lodash.includes)(allowHeader, method);
343
+ const isAllowed = (allowHeader === null || allowHeader === void 0 ? void 0 : (_allowHeader$includes = allowHeader.includes) === null || _allowHeader$includes === void 0 ? void 0 : _allowHeader$includes.call(allowHeader, method)) || (allowHeader === null || allowHeader === void 0 ? void 0 : allowHeader.allow) === method;
350
344
  dispatch.receiveUserPermission(key, isAllowed);
351
345
  };
352
346
  /**
@@ -366,10 +360,7 @@ const canUserEditEntityRecord = (kind, name, recordId) => async _ref8 => {
366
360
  dispatch
367
361
  } = _ref8;
368
362
  const configs = await dispatch((0, _entities.getOrLoadEntitiesConfig)(kind));
369
- const entityConfig = (0, _lodash.find)(configs, {
370
- kind,
371
- name
372
- });
363
+ const entityConfig = configs.find(config => config.name === name && config.kind === kind);
373
364
 
374
365
  if (!entityConfig) {
375
366
  return;
@@ -475,6 +466,8 @@ __experimentalGetTemplateForLink.shouldInvalidate = action => {
475
466
  };
476
467
 
477
468
  const __experimentalGetCurrentGlobalStylesId = () => async _ref13 => {
469
+ var _activeThemes$, _activeThemes$$_links, _activeThemes$$_links2, _activeThemes$$_links3;
470
+
478
471
  let {
479
472
  dispatch,
480
473
  resolveSelect
@@ -482,7 +475,7 @@ const __experimentalGetCurrentGlobalStylesId = () => async _ref13 => {
482
475
  const activeThemes = await resolveSelect.getEntityRecords('root', 'theme', {
483
476
  status: 'active'
484
477
  });
485
- const globalStylesURL = (0, _lodash.get)(activeThemes, [0, '_links', 'wp:user-global-styles', 0, 'href']);
478
+ const globalStylesURL = activeThemes === null || activeThemes === void 0 ? void 0 : (_activeThemes$ = activeThemes[0]) === null || _activeThemes$ === void 0 ? void 0 : (_activeThemes$$_links = _activeThemes$._links) === null || _activeThemes$$_links === void 0 ? void 0 : (_activeThemes$$_links2 = _activeThemes$$_links['wp:user-global-styles']) === null || _activeThemes$$_links2 === void 0 ? void 0 : (_activeThemes$$_links3 = _activeThemes$$_links2[0]) === null || _activeThemes$$_links3 === void 0 ? void 0 : _activeThemes$$_links3.href;
486
479
 
487
480
  if (globalStylesURL) {
488
481
  const globalStylesObject = await (0, _apiFetch.default)({
@@ -532,7 +525,10 @@ const getBlockPatterns = () => async _ref16 => {
532
525
  const restPatterns = await (0, _apiFetch.default)({
533
526
  path: '/wp/v2/block-patterns/patterns'
534
527
  });
535
- const patterns = (0, _lodash.map)(restPatterns, pattern => (0, _lodash.mapKeys)(pattern, (value, key) => (0, _lodash.camelCase)(key)));
528
+ const patterns = restPatterns === null || restPatterns === void 0 ? void 0 : restPatterns.map(pattern => Object.fromEntries(Object.entries(pattern).map(_ref17 => {
529
+ let [key, value] = _ref17;
530
+ return [(0, _changeCase.camelCase)(key), value];
531
+ })));
536
532
  dispatch({
537
533
  type: 'RECEIVE_BLOCK_PATTERNS',
538
534
  patterns
@@ -541,10 +537,10 @@ const getBlockPatterns = () => async _ref16 => {
541
537
 
542
538
  exports.getBlockPatterns = getBlockPatterns;
543
539
 
544
- const getBlockPatternCategories = () => async _ref17 => {
540
+ const getBlockPatternCategories = () => async _ref18 => {
545
541
  let {
546
542
  dispatch
547
- } = _ref17;
543
+ } = _ref18;
548
544
  const categories = await (0, _apiFetch.default)({
549
545
  path: '/wp/v2/block-patterns/categories'
550
546
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","configs","entityConfig","__experimentalNoFetch","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","undefined","_fields","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","resource","id","methods","create","read","update","delete","method","Error","response","parse","allowHeader","headers","get","Boolean","isAllowed","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","window","fetch","then","res","json","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getBlockPatterns","restPatterns","patterns","pattern","value","getBlockPatternCategories","categories"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GACpBC,KAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AACzB,QAAMC,IAAI,GAAG,uBACZ,wCADY,EAEZF,KAFY,CAAb;AAIA,QAAMG,KAAK,GAAG,MAAM,uBAAU;AAAED,IAAAA;AAAF,GAAV,CAApB;AACAD,EAAAA,QAAQ,CAACG,gBAAT,CAA2BF,IAA3B,EAAiCC,KAAjC;AACA,CATK;AAWP;AACA;AACA;;;;;AACO,MAAME,cAAc,GAC1B,MACA,eAA0B;AAAA,MAAlB;AAAEJ,IAAAA;AAAF,GAAkB;AACzB,QAAMK,WAAW,GAAG,MAAM,uBAAU;AAAEJ,IAAAA,IAAI,EAAE;AAAR,GAAV,CAA1B;AACAD,EAAAA,QAAQ,CAACM,kBAAT,CAA6BD,WAA7B;AACA,CALK;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,eAAe,GAC3B,UAAEC,IAAF,EAAQC,IAAR;AAAA,MAAcC,GAAd,uEAAoB,EAApB;AAAA,MAAwBX,KAAxB;A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AGAD,EAAAA,QAAQ,CAAE;AAAE6C,IAAAA,IAAI,EAAE,kCAAR;AAA4C8E,IAAAA;AAA5C,GAAF,CAAR;AACA,CAPK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, find, get, includes, map, mapKeys, uniq } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors =\n\t( query ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst path = addQueryArgs(\n\t\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\t\tquery\n\t\t);\n\t\tconst users = await apiFetch( { path } );\n\t\tdispatch.receiveUserQuery( path, users );\n\t};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\t\tdispatch.receiveCurrentUser( currentUser );\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} key Record's key\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request. If requesting specific\n * fields, fields must always include the ID.\n */\nexport const getEntityRecord =\n\t( kind, name, key = '', query ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = find( configs, { kind, name } );\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, key ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: uniq( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ).join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t// additional query modifications in the condition below, since those\n\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t// for how the request is made to the REST API.\n\n\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t{\n\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t...query,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( query !== undefined ) {\n\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst record = await apiFetch( { path } );\n\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getRawEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests the entity's records from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {Object?} query Query Object. If requesting specific fields, fields\n * must always include the ID.\n */\nexport const getEntityRecords =\n\t( kind, name, query = {} ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = find( configs, { kind, name } );\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: uniq( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ).join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( entityConfig.baseURL, {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\n\t\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t// explicitely set these fields as \"undefined\"\n\t\t\t// that way we consider the query \"fullfilled\".\n\t\t\tif ( query._fields ) {\n\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn record;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\ngetEntityRecords.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\tkind === action.kind &&\n\t\tname === action.name\n\t);\n};\n\n/**\n * Requests the current theme.\n */\nexport const getCurrentTheme =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\n\t\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n\t};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview =\n\t( url ) =>\n\tasync ( { dispatch } ) => {\n\t\ttry {\n\t\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t\t} );\n\t\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t\t} catch ( error ) {\n\t\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\t\tdispatch.receiveEmbedPreview( url, false );\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} action Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( action, resource, id ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst methods = {\n\t\t\tcreate: 'POST',\n\t\t\tread: 'GET',\n\t\t\tupdate: 'PUT',\n\t\t\tdelete: 'DELETE',\n\t\t};\n\n\t\tconst method = methods[ action ];\n\t\tif ( ! method ) {\n\t\t\tthrow new Error( `'${ action }' is not a valid action.` );\n\t\t}\n\n\t\tconst path = id\n\t\t\t? `/wp/v2/${ resource }/${ id }`\n\t\t\t: `/wp/v2/${ resource }`;\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\t\treturn;\n\t\t}\n\n\t\t// Optional chaining operator is used here because the API requests don't\n\t\t// return the expected result in the native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst allowHeader = response.headers?.get( 'allow' );\n\t\tconst key = [ action, resource, id ].filter( Boolean ).join( '/' );\n\t\tconst isAllowed = includes( allowHeader, method );\n\t\tdispatch.receiveUserPermission( key, isAllowed );\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = find( configs, { kind, name } );\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resource = entityConfig.__unstable_rest_base;\n\t\tawait dispatch( canUser( 'update', resource, recordId ) );\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosaves =\n\t( postType, postId ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst { rest_base: restBase, rest_namespace: restNamespace = 'wp/v2' } =\n\t\t\tawait resolveSelect.getPostType( postType );\n\t\tconst autosaves = await apiFetch( {\n\t\t\tpath: `/${ restNamespace }/${ restBase }/${ postId }/autosaves?context=edit`,\n\t\t} );\n\n\t\tif ( autosaves && autosaves.length ) {\n\t\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t\t}\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * This resolver exists to ensure the underlying autosaves are fetched via\n * `getAutosaves` when a call to the `getAutosave` selector is made.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosave =\n\t( postType, postId ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect.getAutosaves( postType, postId );\n\t};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink =\n\t( link ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\t// Ideally this should be using an apiFetch call\n\t\t// We could potentially do so by adding a \"filter\" to the `wp_template` end point.\n\t\t// Also it seems the returned object is not a regular REST API post type.\n\t\tlet template;\n\t\ttry {\n\t\t\ttemplate = await window\n\t\t\t\t.fetch( addQueryArgs( link, { '_wp-find-template': true } ) )\n\t\t\t\t.then( ( res ) => res.json() )\n\t\t\t\t.then( ( { data } ) => data );\n\t\t} catch ( e ) {\n\t\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t\t}\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = await resolveSelect.getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t[ record ],\n\t\t\t\t{\n\t\t\t\t\t'find-template': link,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\t\tconst globalStylesURL = get( activeThemes, [\n\t\t\t0,\n\t\t\t'_links',\n\t\t\t'wp:user-global-styles',\n\t\t\t0,\n\t\t\t'href',\n\t\t] );\n\t\tif ( globalStylesURL ) {\n\t\t\tconst globalStylesObject = await apiFetch( {\n\t\t\t\turl: globalStylesURL,\n\t\t\t} );\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\t\tglobalStylesObject.id\n\t\t\t);\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tthemeGlobalStyles\n\t\t);\n\t};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tvariations\n\t\t);\n\t};\n\nexport const getBlockPatterns =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst restPatterns = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/patterns',\n\t\t} );\n\t\tconst patterns = map( restPatterns, ( pattern ) =>\n\t\t\tmapKeys( pattern, ( value, key ) => camelCase( key ) )\n\t\t);\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\nexport const getBlockPatternCategories =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst categories = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/categories',\n\t\t} );\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n\t};\n"]}
1
+ {"version":3,"sources":["@wordpress/core-data/src/resolvers.js"],"names":["getAuthors","query","dispatch","path","users","receiveUserQuery","getCurrentUser","currentUser","receiveCurrentUser","getEntityRecord","kind","name","key","select","configs","entityConfig","find","config","__experimentalNoFetch","lock","__unstableAcquireStoreLock","STORE_NAME","exclusive","undefined","_fields","Set","DEFAULT_ENTITY_KEY","join","baseURL","baseURLParams","include","hasRecords","hasEntityRecords","record","receiveEntityRecords","__unstableReleaseStoreLock","getRawEntityRecord","getEditedEntityRecord","getEntityRecords","records","Object","values","map","split","forEach","field","hasOwnProperty","context","resolutionsArgs","filter","type","selectorName","args","shouldInvalidate","action","invalidateCache","getCurrentTheme","resolveSelect","activeThemes","status","receiveCurrentTheme","getThemeSupports","getEmbedPreview","url","embedProxyResponse","receiveEmbedPreview","error","canUser","resource","id","methods","create","read","update","delete","method","Error","response","parse","allowHeader","headers","get","Boolean","isAllowed","includes","allow","receiveUserPermission","canUserEditEntityRecord","recordId","__unstable_rest_base","getAutosaves","postType","postId","rest_base","restBase","rest_namespace","restNamespace","getPostType","autosaves","length","receiveAutosaves","getAutosave","__experimentalGetTemplateForLink","link","template","window","fetch","then","res","json","data","e","__experimentalGetCurrentGlobalStylesId","globalStylesURL","_links","href","globalStylesObject","__experimentalReceiveCurrentGlobalStylesId","__experimentalGetCurrentThemeBaseGlobalStyles","currentTheme","themeGlobalStyles","stylesheet","__experimentalReceiveThemeBaseGlobalStyles","__experimentalGetCurrentThemeGlobalStylesVariations","variations","__experimentalReceiveThemeGlobalStyleVariations","getBlockPatterns","restPatterns","patterns","pattern","fromEntries","entries","value","getBlockPatternCategories","categories"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,UAAU,GACpBC,KAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AACzB,QAAMC,IAAI,GAAG,uBACZ,wCADY,EAEZF,KAFY,CAAb;AAIA,QAAMG,KAAK,GAAG,MAAM,uBAAU;AAAED,IAAAA;AAAF,GAAV,CAApB;AACAD,EAAAA,QAAQ,CAACG,gBAAT,CAA2BF,IA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AAM9D,aAAa,CAACD,eAAd,EAA3B;AACA,QAAMoE,UAAU,GAAG,MAAM,uBAAU;AAClCzH,IAAAA,IAAI,EAAG,+BAA+BoH,YAAY,CAACE,UAAY;AAD7B,GAAV,CAAzB;;AAGAvH,EAAAA,QAAQ,CAAC2H,+CAAT,CACCN,YAAY,CAACE,UADd,EAECG,UAFD;AAIA,CAXK;;;;AAaA,MAAME,gBAAgB,GAC5B,MACA,gBAA0B;AAAA,MAAlB;AAAE5H,IAAAA;AAAF,GAAkB;AACzB,QAAM6H,YAAY,GAAG,MAAM,uBAAU;AACpC5H,IAAAA,IAAI,EAAE;AAD8B,GAAV,CAA3B;AAGA,QAAM6H,QAAQ,GAAGD,YAAH,aAAGA,YAAH,uBAAGA,YAAY,CAAErF,GAAd,CAAqBuF,OAAF,IACnCzF,MAAM,CAAC0F,WAAP,CACC1F,MAAM,CAAC2F,OAAP,CAAgBF,OAAhB,EAA0BvF,GAA1B,CAA+B;AAAA,QAAE,CAAE9B,GAAF,EAAOwH,KAAP,CAAF;AAAA,WAAsB,CACpD,2BAAWxH,GAAX,CADoD,EAEpDwH,KAFoD,CAAtB;AAAA,GAA/B,CADD,CADgB,CAAjB;AAQAlI,EAAAA,QAAQ,CAAE;AAAEgD,IAAAA,IAAI,EAAE,wBAAR;AAAkC8E,IAAAA;AAAlC,GAAF,CAAR;AACA,CAfK;;;;AAiBA,MAAMK,yBAAyB,GACrC,MACA,gBAA0B;AAAA,MAAlB;AAAEnI,IAAAA;AAAF,GAAkB;AACzB,QAAMoI,UAAU,GAAG,MAAM,uBAAU;AAClCnI,IAAAA,IAAI,EAAE;AAD4B,GAAV,CAAzB;AAGAD,EAAAA,QAAQ,CAAE;AAAEgD,IAAAA,IAAI,EAAE,kCAAR;AAA4CoF,IAAAA;AAA5C,GAAF,CAAR;AACA,CAPK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { forwardResolver, getNormalizedCommaSeparable } from './utils';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request.\n */\nexport const getAuthors =\n\t( query ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst path = addQueryArgs(\n\t\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\t\tquery\n\t\t);\n\t\tconst users = await apiFetch( { path } );\n\t\tdispatch.receiveUserQuery( path, users );\n\t};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\t\tdispatch.receiveCurrentUser( currentUser );\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {number|string} key Record's key\n * @param {Object|undefined} query Optional object of query parameters to\n * include with request. If requesting specific\n * fields, fields must always include the ID.\n */\nexport const getEntityRecord =\n\t( kind, name, key = '', query ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, key ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Disable reason: While true that an early return could leave `path`\n\t\t\t// unused, it's important that path is derived using the query prior to\n\t\t\t// additional query modifications in the condition below, since those\n\t\t\t// modifications are relevant to how the data is tracked in state, and not\n\t\t\t// for how the request is made to the REST API.\n\n\t\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.baseURL + ( key ? '/' + key : '' ),\n\t\t\t\t{\n\t\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t\t...query,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( query !== undefined ) {\n\t\t\t\tquery = { ...query, include: [ key ] };\n\n\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t// and without causing `getEntityRecords` resolution to occur.\n\t\t\t\tconst hasRecords = select.hasEntityRecords( kind, name, query );\n\t\t\t\tif ( hasRecords ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst record = await apiFetch( { path } );\n\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getRawEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests the entity's records from the REST API.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {Object?} query Query Object. If requesting specific fields, fields\n * must always include the ID.\n */\nexport const getEntityRecords =\n\t( kind, name, query = {} ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig || entityConfig?.__experimentalNoFetch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( entityConfig.baseURL, {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\n\t\t\tlet records = Object.values( await apiFetch( { path } ) );\n\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t// explicitely set these fields as \"undefined\"\n\t\t\t// that way we consider the query \"fullfilled\".\n\t\t\tif ( query._fields ) {\n\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn record;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tdispatch.receiveEntityRecords( kind, name, records, query );\n\n\t\t\t// When requesting all fields, the list of results can be used to\n\t\t\t// resolve the `getEntityRecord` selector in addition to `getEntityRecords`.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/26575\n\t\t\tif ( ! query?._fields && ! query.context ) {\n\t\t\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t.map( ( record ) => [ kind, name, record[ key ] ] );\n\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'START_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: 'FINISH_RESOLUTIONS',\n\t\t\t\t\tselectorName: 'getEntityRecord',\n\t\t\t\t\targs: resolutionsArgs,\n\t\t\t\t} );\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\ngetEntityRecords.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\tkind === action.kind &&\n\t\tname === action.name\n\t);\n};\n\n/**\n * Requests the current theme.\n */\nexport const getCurrentTheme =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\n\t\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n\t};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview =\n\t( url ) =>\n\tasync ( { dispatch } ) => {\n\t\ttry {\n\t\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t\t} );\n\t\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t\t} catch ( error ) {\n\t\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\t\tdispatch.receiveEmbedPreview( url, false );\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} action Action to check. One of: 'create', 'read', 'update',\n * 'delete'.\n * @param {string} resource REST resource to check, e.g. 'media' or 'posts'.\n * @param {?string} id ID of the rest resource to check.\n */\nexport const canUser =\n\t( action, resource, id ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst methods = {\n\t\t\tcreate: 'POST',\n\t\t\tread: 'GET',\n\t\t\tupdate: 'PUT',\n\t\t\tdelete: 'DELETE',\n\t\t};\n\n\t\tconst method = methods[ action ];\n\t\tif ( ! method ) {\n\t\t\tthrow new Error( `'${ action }' is not a valid action.` );\n\t\t}\n\n\t\tconst path = id\n\t\t\t? `/wp/v2/${ resource }/${ id }`\n\t\t\t: `/wp/v2/${ resource }`;\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\t\treturn;\n\t\t}\n\n\t\t// Optional chaining operator is used here because the API requests don't\n\t\t// return the expected result in the native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst allowHeader = response.headers?.get( 'allow' );\n\t\tconst key = [ action, resource, id ].filter( Boolean ).join( '/' );\n\t\tconst isAllowed =\n\t\t\tallowHeader?.includes?.( method ) || allowHeader?.allow === method;\n\t\tdispatch.receiveUserPermission( key, isAllowed );\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst configs = await dispatch( getOrLoadEntitiesConfig( kind ) );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst resource = entityConfig.__unstable_rest_base;\n\t\tawait dispatch( canUser( 'update', resource, recordId ) );\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosaves =\n\t( postType, postId ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst { rest_base: restBase, rest_namespace: restNamespace = 'wp/v2' } =\n\t\t\tawait resolveSelect.getPostType( postType );\n\t\tconst autosaves = await apiFetch( {\n\t\t\tpath: `/${ restNamespace }/${ restBase }/${ postId }/autosaves?context=edit`,\n\t\t} );\n\n\t\tif ( autosaves && autosaves.length ) {\n\t\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t\t}\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * This resolver exists to ensure the underlying autosaves are fetched via\n * `getAutosaves` when a call to the `getAutosave` selector is made.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId The id of the parent post.\n */\nexport const getAutosave =\n\t( postType, postId ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect.getAutosaves( postType, postId );\n\t};\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param {string} link Link.\n */\nexport const __experimentalGetTemplateForLink =\n\t( link ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\t// Ideally this should be using an apiFetch call\n\t\t// We could potentially do so by adding a \"filter\" to the `wp_template` end point.\n\t\t// Also it seems the returned object is not a regular REST API post type.\n\t\tlet template;\n\t\ttry {\n\t\t\ttemplate = await window\n\t\t\t\t.fetch( addQueryArgs( link, { '_wp-find-template': true } ) )\n\t\t\t\t.then( ( res ) => res.json() )\n\t\t\t\t.then( ( { data } ) => data );\n\t\t} catch ( e ) {\n\t\t\t// For non-FSE themes, it is possible that this request returns an error.\n\t\t}\n\n\t\tif ( ! template ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst record = await resolveSelect.getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( record ) {\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t[ record ],\n\t\t\t\t{\n\t\t\t\t\t'find-template': link,\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t};\n\n__experimentalGetTemplateForLink.shouldInvalidate = ( action ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\nexport const __experimentalGetCurrentGlobalStylesId =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\t\tconst globalStylesURL =\n\t\t\tactiveThemes?.[ 0 ]?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]\n\t\t\t\t?.href;\n\t\tif ( globalStylesURL ) {\n\t\t\tconst globalStylesObject = await apiFetch( {\n\t\t\t\turl: globalStylesURL,\n\t\t\t} );\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId(\n\t\t\t\tglobalStylesObject.id\n\t\t\t);\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tthemeGlobalStyles\n\t\t);\n\t};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tvariations\n\t\t);\n\t};\n\nexport const getBlockPatterns =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst restPatterns = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/patterns',\n\t\t} );\n\t\tconst patterns = restPatterns?.map( ( pattern ) =>\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries( pattern ).map( ( [ key, value ] ) => [\n\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\tvalue,\n\t\t\t\t] )\n\t\t\t)\n\t\t);\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\nexport const getBlockPatternCategories =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst categories = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/categories',\n\t\t} );\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n\t};\n"]}
@@ -216,26 +216,6 @@ function getEntityConfig(state, kind, name) {
216
216
  name
217
217
  });
218
218
  }
219
- /**
220
- * GetEntityRecord is declared as an *interface*, but it actually describes
221
- * the specifies the getEntityRecord *function* signature. It may seem unusual,
222
- * but it's just how TypeScript implements function overloading.
223
- *
224
- * More accurately, GetEntityRecord distinguishes between two different signatures
225
- * the getEntityRecord selector has:
226
- *
227
- * 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >
228
- * 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>
229
- *
230
- * Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
231
- * we can't use a single function signature with a return type such as:
232
- *
233
- * Fields extends undefined
234
- * ? EntityRecordOf< K, N, C >
235
- * : Partial< EntityRecordOf< K, N, C > >
236
- */
237
-
238
-
239
219
  /**
240
220
  * Returns the Entity's record object by key. Returns `null` if the value is not
241
221
  * yet received, undefined if the value entity is known to not exist, or the
@@ -250,6 +230,8 @@ function getEntityConfig(state, kind, name) {
250
230
  *
251
231
  * @return Record.
252
232
  */
233
+
234
+
253
235
  const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) => {
254
236
  var _query$context, _queriedState$items$c;
255
237
 
@@ -362,26 +344,6 @@ exports.getRawEntityRecord = getRawEntityRecord;
362
344
  function hasEntityRecords(state, kind, name, query) {
363
345
  return Array.isArray(getEntityRecords(state, kind, name, query));
364
346
  }
365
- /**
366
- * GetEntityRecord is declared as an *interface*, but it actually describes
367
- * the specifies the getEntityRecord *function* signature. It may seem unusual,
368
- * but it's just how TypeScript implements function overloading.
369
- *
370
- * More accurately, GetEntityRecord distinguishes between two different signatures
371
- * the getEntityRecord selector has:
372
- *
373
- * 1. When query._fields is not given, the returned type is EntityRecordOf< K, N, C >[]
374
- * 2. When query._fields is given, the returned type is Partial<EntityRecordOf< K, N, C >>[]
375
- *
376
- * Unfortunately, due to a TypeScript limitation (https://github.com/microsoft/TypeScript/issues/23132)
377
- * we can't use a single function signature with a return type such as:
378
- *
379
- * Fields extends undefined
380
- * ? EntityRecordOf< K, N, C >[]
381
- * : Partial< EntityRecordOf< K, N, C > >[]
382
- */
383
-
384
-
385
347
  /**
386
348
  * Returns the Entity's records.
387
349
  *
@@ -393,6 +355,8 @@ function hasEntityRecords(state, kind, name, query) {
393
355
  *
394
356
  * @return Records.
395
357
  */
358
+
359
+
396
360
  const getEntityRecords = (state, kind, name, query) => {
397
361
  // Queried data state is prepopulated for all known entities. If this is not
398
362
  // assigned for the given parameters, then it is known to not exist.
@@ -436,7 +400,7 @@ const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
436
400
  dirtyRecords.push({
437
401
  // We avoid using primaryKey because it's transformed into a string
438
402
  // when it's used as an object key.
439
- key: entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY],
403
+ key: entityRecord ? entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY] : undefined,
440
404
  title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl = entityConfig.getTitle) === null || _entityConfig$getTitl === void 0 ? void 0 : _entityConfig$getTitl.call(entityConfig, entityRecord)) || '',
441
405
  name,
442
406
  kind
@@ -478,7 +442,7 @@ const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
478
442
  recordsBeingSaved.push({
479
443
  // We avoid using primaryKey because it's transformed into a string
480
444
  // when it's used as an object key.
481
- key: entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY],
445
+ key: entityRecord ? entityRecord[entityConfig.key || _entities.DEFAULT_ENTITY_KEY] : undefined,
482
446
  title: (entityConfig === null || entityConfig === void 0 ? void 0 : (_entityConfig$getTitl2 = entityConfig.getTitle) === null || _entityConfig$getTitl2 === void 0 ? void 0 : _entityConfig$getTitl2.call(entityConfig, entityRecord)) || '',
483
447
  name,
484
448
  kind
@@ -940,13 +904,12 @@ function __experimentalGetTemplateForLink(state, link) {
940
904
  const records = getEntityRecords(state, 'postType', 'wp_template', {
941
905
  'find-template': link
942
906
  });
943
- const template = records !== null && records !== void 0 && records.length ? records[0] : null;
944
907
 
945
- if (template) {
946
- return getEditedEntityRecord(state, 'postType', 'wp_template', template.id);
908
+ if (records !== null && records !== void 0 && records.length) {
909
+ return getEditedEntityRecord(state, 'postType', 'wp_template', records[0].id);
947
910
  }
948
911
 
949
- return template;
912
+ return null;
950
913
  }
951
914
  /**
952
915
  * Retrieve the current theme's base global styles